@bytesbrains/cruise-worker 0.13.1 → 0.14.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/README.md +25 -1
- package/package.json +24 -5
- package/worker/VERSION +1 -1
- package/worker/index.js +396 -307
- package/worker/index.js.map +5 -5
- package/wrangler.template.jsonc +14 -2
- package/worker/b23bfbc792e8710d3b74284a0a1b8ab044c18897-logo-dark.png +0 -0
package/worker/index.js
CHANGED
|
@@ -1126,7 +1126,7 @@ var require_NoopTracer = __commonJS({
|
|
|
1126
1126
|
__name(this, "NoopTracer");
|
|
1127
1127
|
}
|
|
1128
1128
|
// startSpan starts a noop span.
|
|
1129
|
-
startSpan(
|
|
1129
|
+
startSpan(name2, options, context = contextApi.active()) {
|
|
1130
1130
|
const root = Boolean(options === null || options === void 0 ? void 0 : options.root);
|
|
1131
1131
|
if (root) {
|
|
1132
1132
|
return new NonRecordingSpan_1.NonRecordingSpan();
|
|
@@ -1138,7 +1138,7 @@ var require_NoopTracer = __commonJS({
|
|
|
1138
1138
|
return new NonRecordingSpan_1.NonRecordingSpan();
|
|
1139
1139
|
}
|
|
1140
1140
|
}
|
|
1141
|
-
startActiveSpan(
|
|
1141
|
+
startActiveSpan(name2, arg2, arg3, arg4) {
|
|
1142
1142
|
let opts;
|
|
1143
1143
|
let ctx;
|
|
1144
1144
|
let fn;
|
|
@@ -1155,7 +1155,7 @@ var require_NoopTracer = __commonJS({
|
|
|
1155
1155
|
fn = arg4;
|
|
1156
1156
|
}
|
|
1157
1157
|
const parentContext = ctx !== null && ctx !== void 0 ? ctx : contextApi.active();
|
|
1158
|
-
const span = this.startSpan(
|
|
1158
|
+
const span = this.startSpan(name2, opts, parentContext);
|
|
1159
1159
|
const contextWithSpanSet = (0, context_utils_1.setSpan)(parentContext, span);
|
|
1160
1160
|
return contextApi.with(contextWithSpanSet, fn, void 0, span);
|
|
1161
1161
|
}
|
|
@@ -1180,14 +1180,14 @@ var require_ProxyTracer = __commonJS({
|
|
|
1180
1180
|
static {
|
|
1181
1181
|
__name(this, "ProxyTracer");
|
|
1182
1182
|
}
|
|
1183
|
-
constructor(provider,
|
|
1183
|
+
constructor(provider, name2, version, options) {
|
|
1184
1184
|
this._provider = provider;
|
|
1185
|
-
this.name =
|
|
1185
|
+
this.name = name2;
|
|
1186
1186
|
this.version = version;
|
|
1187
1187
|
this.options = options;
|
|
1188
1188
|
}
|
|
1189
|
-
startSpan(
|
|
1190
|
-
return this._getTracer().startSpan(
|
|
1189
|
+
startSpan(name2, options, context) {
|
|
1190
|
+
return this._getTracer().startSpan(name2, options, context);
|
|
1191
1191
|
}
|
|
1192
1192
|
startActiveSpan(_name, _options, _context, _fn) {
|
|
1193
1193
|
const tracer = this._getTracer();
|
|
@@ -1248,9 +1248,9 @@ var require_ProxyTracerProvider = __commonJS({
|
|
|
1248
1248
|
/**
|
|
1249
1249
|
* Get a {@link ProxyTracer}
|
|
1250
1250
|
*/
|
|
1251
|
-
getTracer(
|
|
1251
|
+
getTracer(name2, version, options) {
|
|
1252
1252
|
var _a;
|
|
1253
|
-
return (_a = this.getDelegateTracer(
|
|
1253
|
+
return (_a = this.getDelegateTracer(name2, version, options)) !== null && _a !== void 0 ? _a : new ProxyTracer_1.ProxyTracer(this, name2, version, options);
|
|
1254
1254
|
}
|
|
1255
1255
|
getDelegate() {
|
|
1256
1256
|
var _a;
|
|
@@ -1262,9 +1262,9 @@ var require_ProxyTracerProvider = __commonJS({
|
|
|
1262
1262
|
setDelegate(delegate) {
|
|
1263
1263
|
this._delegate = delegate;
|
|
1264
1264
|
}
|
|
1265
|
-
getDelegateTracer(
|
|
1265
|
+
getDelegateTracer(name2, version, options) {
|
|
1266
1266
|
var _a;
|
|
1267
|
-
return (_a = this._delegate) === null || _a === void 0 ? void 0 : _a.getTracer(
|
|
1267
|
+
return (_a = this._delegate) === null || _a === void 0 ? void 0 : _a.getTracer(name2, version, options);
|
|
1268
1268
|
}
|
|
1269
1269
|
};
|
|
1270
1270
|
exports.ProxyTracerProvider = ProxyTracerProvider;
|
|
@@ -1516,8 +1516,8 @@ var require_metrics = __commonJS({
|
|
|
1516
1516
|
/**
|
|
1517
1517
|
* Returns a meter from the global meter provider.
|
|
1518
1518
|
*/
|
|
1519
|
-
getMeter(
|
|
1520
|
-
return this.getMeterProvider().getMeter(
|
|
1519
|
+
getMeter(name2, version, options) {
|
|
1520
|
+
return this.getMeterProvider().getMeter(name2, version, options);
|
|
1521
1521
|
}
|
|
1522
1522
|
/** Remove the global meter provider */
|
|
1523
1523
|
disable() {
|
|
@@ -1742,8 +1742,8 @@ var require_trace = __commonJS({
|
|
|
1742
1742
|
/**
|
|
1743
1743
|
* Returns a tracer from the global tracer provider.
|
|
1744
1744
|
*/
|
|
1745
|
-
getTracer(
|
|
1746
|
-
return this.getTracerProvider().getTracer(
|
|
1745
|
+
getTracer(name2, version) {
|
|
1746
|
+
return this.getTracerProvider().getTracer(name2, version);
|
|
1747
1747
|
}
|
|
1748
1748
|
/** Remove the global tracer provider */
|
|
1749
1749
|
disable() {
|
|
@@ -1985,6 +1985,27 @@ function poolsReadableBy(pool) {
|
|
|
1985
1985
|
}
|
|
1986
1986
|
__name(poolsReadableBy, "poolsReadableBy");
|
|
1987
1987
|
|
|
1988
|
+
// src/deployment-role.ts
|
|
1989
|
+
var DEPLOYMENT_ROLES = ["live", "test", "demo"];
|
|
1990
|
+
function roleByName(environment) {
|
|
1991
|
+
if (environment === "production" || environment === "selfhosted" || environment === "local") return "live";
|
|
1992
|
+
if (environment === "demo") return "demo";
|
|
1993
|
+
return "test";
|
|
1994
|
+
}
|
|
1995
|
+
__name(roleByName, "roleByName");
|
|
1996
|
+
function deploymentRole(vars) {
|
|
1997
|
+
const given = vars.DEPLOYMENT_ROLE?.trim() || null;
|
|
1998
|
+
if (given !== null && DEPLOYMENT_ROLES.includes(given)) {
|
|
1999
|
+
return { role: given, source: "explicit", given };
|
|
2000
|
+
}
|
|
2001
|
+
return { role: roleByName(vars.ENVIRONMENT), source: given === null ? "name" : "invalid", given };
|
|
2002
|
+
}
|
|
2003
|
+
__name(deploymentRole, "deploymentRole");
|
|
2004
|
+
function isCredentialFree(vars) {
|
|
2005
|
+
return deploymentRole(vars).role === "demo";
|
|
2006
|
+
}
|
|
2007
|
+
__name(isCredentialFree, "isCredentialFree");
|
|
2008
|
+
|
|
1988
2009
|
// src/keys.ts
|
|
1989
2010
|
var NAMESPACE = "cru";
|
|
1990
2011
|
var PUBLIC_LEN = 8;
|
|
@@ -1994,9 +2015,8 @@ var REJECT_AT = 248;
|
|
|
1994
2015
|
var KEY_ENVIRONMENTS = ["live", "test", "demo"];
|
|
1995
2016
|
var KEY_KINDS = [...KEY_ENVIRONMENTS, "svc"];
|
|
1996
2017
|
var KEY_PATTERN = `cru_(${KEY_KINDS.join("|")})_[A-Za-z0-9]{${PUBLIC_LEN + SECRET_LEN}}`;
|
|
1997
|
-
function keyEnvironmentFor(environment) {
|
|
1998
|
-
|
|
1999
|
-
return KEY_ENVIRONMENTS.includes(environment) ? environment : "test";
|
|
2018
|
+
function keyEnvironmentFor(environment, role) {
|
|
2019
|
+
return deploymentRole({ ENVIRONMENT: environment, ...role === void 0 ? {} : { DEPLOYMENT_ROLE: role } }).role;
|
|
2000
2020
|
}
|
|
2001
2021
|
__name(keyEnvironmentFor, "keyEnvironmentFor");
|
|
2002
2022
|
var DEMO_KEY_RATE_LIMIT_PER_MIN = 60;
|
|
@@ -2107,7 +2127,7 @@ __name(read, "read");
|
|
|
2107
2127
|
var ALLOWED_HEADERS = /* @__PURE__ */ new Set(["content-type"]);
|
|
2108
2128
|
function isHeaders(value) {
|
|
2109
2129
|
if (value === null || typeof value !== "object" || Array.isArray(value)) return false;
|
|
2110
|
-
return Object.entries(value).every(([
|
|
2130
|
+
return Object.entries(value).every(([name2, v]) => ALLOWED_HEADERS.has(name2) && typeof v === "string");
|
|
2111
2131
|
}
|
|
2112
2132
|
__name(isHeaders, "isHeaders");
|
|
2113
2133
|
var isCount = /* @__PURE__ */ __name((value) => typeof value === "number" && Number.isFinite(value) && value >= 0, "isCount");
|
|
@@ -2619,42 +2639,9 @@ async function reserveBudget(db, projectId, status, reserveMicros, wallet = null
|
|
|
2619
2639
|
}
|
|
2620
2640
|
__name(reserveBudget, "reserveBudget");
|
|
2621
2641
|
|
|
2622
|
-
// src/config.ts
|
|
2623
|
-
var CLOUDFLARE_GATEWAY = "https://gateway.ai.cloudflare.com";
|
|
2624
|
-
var GOOGLE_JWKS = "https://www.googleapis.com/service_accounts/v1/jwk/securetoken@system.gserviceaccount.com";
|
|
2625
|
-
var GOOGLE_JWKS_TIMEOUT_MS = 3e3;
|
|
2626
|
-
function overridable(env) {
|
|
2627
|
-
return env.ENVIRONMENT === "development" && env.E2E_STACK === "1";
|
|
2628
|
-
}
|
|
2629
|
-
__name(overridable, "overridable");
|
|
2630
|
-
function resolve(env, override, real) {
|
|
2631
|
-
if (!overridable(env)) return real;
|
|
2632
|
-
return override !== void 0 && override.length > 0 ? override : real;
|
|
2633
|
-
}
|
|
2634
|
-
__name(resolve, "resolve");
|
|
2635
|
-
function gatewayBaseUrl(env) {
|
|
2636
|
-
return resolve(env, env.GATEWAY_BASE_URL, CLOUDFLARE_GATEWAY);
|
|
2637
|
-
}
|
|
2638
|
-
__name(gatewayBaseUrl, "gatewayBaseUrl");
|
|
2639
|
-
function jwksUrl(env) {
|
|
2640
|
-
return resolve(env, env.JWKS_URL, GOOGLE_JWKS);
|
|
2641
|
-
}
|
|
2642
|
-
__name(jwksUrl, "jwksUrl");
|
|
2643
|
-
var STREAM_HEADER_TIMEOUT_MS = 45e3;
|
|
2644
|
-
var UNARY_RESPONSE_TIMEOUT_MS = 18e4;
|
|
2645
|
-
function upstreamDeadlineMs(env, streamed) {
|
|
2646
|
-
const fallback = streamed ? STREAM_HEADER_TIMEOUT_MS : UNARY_RESPONSE_TIMEOUT_MS;
|
|
2647
|
-
if (!overridable(env)) return fallback;
|
|
2648
|
-
const override = Number(streamed ? env.STREAM_TIMEOUT_MS : env.UNARY_TIMEOUT_MS);
|
|
2649
|
-
return Number.isSafeInteger(override) && override > 0 ? override : fallback;
|
|
2650
|
-
}
|
|
2651
|
-
__name(upstreamDeadlineMs, "upstreamDeadlineMs");
|
|
2652
|
-
var PROVIDER_KEY_PREFIX = "PROVIDER_KEY_";
|
|
2653
|
-
var CREDENTIAL_FREE_ENVIRONMENTS = ["demo"];
|
|
2654
|
-
|
|
2655
2642
|
// src/demo-charge.ts
|
|
2656
2643
|
async function demoChargeFor(env, projectId) {
|
|
2657
|
-
if (!
|
|
2644
|
+
if (!isCredentialFree(env)) return 0;
|
|
2658
2645
|
const row = await env.DB.prepare(`SELECT demo_charge_micros FROM budgets WHERE scope = 'project' AND subject = ?`).bind(projectId).first();
|
|
2659
2646
|
return row?.demo_charge_micros ?? 0;
|
|
2660
2647
|
}
|
|
@@ -2663,7 +2650,7 @@ var DEMO_CAP_SLUG = "demo-cap";
|
|
|
2663
2650
|
var DEMO_CAP_HARD_MICROS = 1e4;
|
|
2664
2651
|
var DEMO_CAP_CHARGE_MICROS = 2e3;
|
|
2665
2652
|
async function ensureDemoCapProject(env, tenantId, actor) {
|
|
2666
|
-
if (!
|
|
2653
|
+
if (!isCredentialFree(env)) return false;
|
|
2667
2654
|
const db = env.DB;
|
|
2668
2655
|
const id = `${tenantId}/${DEMO_CAP_SLUG}`;
|
|
2669
2656
|
const exists = await db.prepare(`SELECT 1 AS one FROM projects WHERE id = ?`).bind(id).first();
|
|
@@ -3965,8 +3952,8 @@ function candidateQualityRank(lane, candidates) {
|
|
|
3965
3952
|
__name(candidateQualityRank, "candidateQualityRank");
|
|
3966
3953
|
function servesTier(lane, originId, against) {
|
|
3967
3954
|
if (against === null) return false;
|
|
3968
|
-
const
|
|
3969
|
-
return
|
|
3955
|
+
const origin2 = qualityRankOf(lane, originId);
|
|
3956
|
+
return origin2 !== null && origin2 <= against;
|
|
3970
3957
|
}
|
|
3971
3958
|
__name(servesTier, "servesTier");
|
|
3972
3959
|
|
|
@@ -4466,12 +4453,12 @@ async function planCache(env, key, routed, body, header, modality, lane, laneCan
|
|
|
4466
4453
|
miss = "tier";
|
|
4467
4454
|
continue;
|
|
4468
4455
|
}
|
|
4469
|
-
const
|
|
4470
|
-
if (
|
|
4456
|
+
const origin2 = entry.originModelId === routed.id ? routed : await lookupModel(env.DB, entry.originModelId);
|
|
4457
|
+
if (origin2 === null) {
|
|
4471
4458
|
miss = "tier";
|
|
4472
4459
|
continue;
|
|
4473
4460
|
}
|
|
4474
|
-
originModel =
|
|
4461
|
+
originModel = origin2;
|
|
4475
4462
|
}
|
|
4476
4463
|
const cost = await priceUsage(env.DB, entry.originModelId, entry.usage, now);
|
|
4477
4464
|
if (!cost.priced) {
|
|
@@ -4525,10 +4512,10 @@ function serveHit(env, ctx, admission, now, serving) {
|
|
|
4525
4512
|
headers.set("x-cruise-cache-status", "HIT");
|
|
4526
4513
|
headers.set("x-cruise-cache", cacheHeader(admission.cache));
|
|
4527
4514
|
headers.set("x-cruise-key", key.prefix);
|
|
4528
|
-
for (const [
|
|
4515
|
+
for (const [name2, value] of Object.entries(budgetHeaders(budget))) headers.set(name2, value);
|
|
4529
4516
|
headers.set("x-cruise-budget-reserved", formatUsd(reservation.reserved, 4));
|
|
4530
|
-
for (const [
|
|
4531
|
-
if (wallet !== null) for (const [
|
|
4517
|
+
for (const [name2, value] of Object.entries(runHeaders(reservation.run))) headers.set(name2, value);
|
|
4518
|
+
if (wallet !== null) for (const [name2, value] of Object.entries(walletHeaders(wallet))) headers.set(name2, value);
|
|
4532
4519
|
ctx.waitUntil(touchKey(env.DB, key.keyId));
|
|
4533
4520
|
ctx.waitUntil(pruneRateBuckets(env.DB, "key", key.keyId, now));
|
|
4534
4521
|
ctx.waitUntil(
|
|
@@ -4684,6 +4671,38 @@ function liveCacheStatus(response, plan) {
|
|
|
4684
4671
|
}
|
|
4685
4672
|
__name(liveCacheStatus, "liveCacheStatus");
|
|
4686
4673
|
|
|
4674
|
+
// src/config.ts
|
|
4675
|
+
var CLOUDFLARE_GATEWAY = "https://gateway.ai.cloudflare.com";
|
|
4676
|
+
var GOOGLE_JWKS = "https://www.googleapis.com/service_accounts/v1/jwk/securetoken@system.gserviceaccount.com";
|
|
4677
|
+
var GOOGLE_JWKS_TIMEOUT_MS = 3e3;
|
|
4678
|
+
function overridable(env) {
|
|
4679
|
+
return env.ENVIRONMENT === "development" && env.E2E_STACK === "1";
|
|
4680
|
+
}
|
|
4681
|
+
__name(overridable, "overridable");
|
|
4682
|
+
function resolve(env, override, real) {
|
|
4683
|
+
if (!overridable(env)) return real;
|
|
4684
|
+
return override !== void 0 && override.length > 0 ? override : real;
|
|
4685
|
+
}
|
|
4686
|
+
__name(resolve, "resolve");
|
|
4687
|
+
function gatewayBaseUrl(env) {
|
|
4688
|
+
return resolve(env, env.GATEWAY_BASE_URL, CLOUDFLARE_GATEWAY);
|
|
4689
|
+
}
|
|
4690
|
+
__name(gatewayBaseUrl, "gatewayBaseUrl");
|
|
4691
|
+
function jwksUrl(env) {
|
|
4692
|
+
return resolve(env, env.JWKS_URL, GOOGLE_JWKS);
|
|
4693
|
+
}
|
|
4694
|
+
__name(jwksUrl, "jwksUrl");
|
|
4695
|
+
var STREAM_HEADER_TIMEOUT_MS = 45e3;
|
|
4696
|
+
var UNARY_RESPONSE_TIMEOUT_MS = 18e4;
|
|
4697
|
+
function upstreamDeadlineMs(env, streamed) {
|
|
4698
|
+
const fallback = streamed ? STREAM_HEADER_TIMEOUT_MS : UNARY_RESPONSE_TIMEOUT_MS;
|
|
4699
|
+
if (!overridable(env)) return fallback;
|
|
4700
|
+
const override = Number(streamed ? env.STREAM_TIMEOUT_MS : env.UNARY_TIMEOUT_MS);
|
|
4701
|
+
return Number.isSafeInteger(override) && override > 0 ? override : fallback;
|
|
4702
|
+
}
|
|
4703
|
+
__name(upstreamDeadlineMs, "upstreamDeadlineMs");
|
|
4704
|
+
var PROVIDER_KEY_PREFIX = "PROVIDER_KEY_";
|
|
4705
|
+
|
|
4687
4706
|
// src/refusal-metrics.ts
|
|
4688
4707
|
var LABEL = /^[a-z][a-z0-9_]{0,39}$/;
|
|
4689
4708
|
function refusalLabel(body) {
|
|
@@ -4744,7 +4763,7 @@ function parseScenario(text) {
|
|
|
4744
4763
|
}
|
|
4745
4764
|
__name(parseScenario, "parseScenario");
|
|
4746
4765
|
function rehearsalsOn(env) {
|
|
4747
|
-
return
|
|
4766
|
+
return isCredentialFree(env);
|
|
4748
4767
|
}
|
|
4749
4768
|
__name(rehearsalsOn, "rehearsalsOn");
|
|
4750
4769
|
function scenarioHeaderOf(request, env) {
|
|
@@ -4765,10 +4784,10 @@ function upstreamScenarioFor(scenario) {
|
|
|
4765
4784
|
}
|
|
4766
4785
|
__name(upstreamScenarioFor, "upstreamScenarioFor");
|
|
4767
4786
|
function withScenario(headers, scenario) {
|
|
4768
|
-
const
|
|
4769
|
-
if (
|
|
4787
|
+
const name2 = upstreamScenarioFor(scenario);
|
|
4788
|
+
if (name2 === null) return headers;
|
|
4770
4789
|
const out = new Headers(headers);
|
|
4771
|
-
out.set(EMULATOR_SCENARIO_HEADER,
|
|
4790
|
+
out.set(EMULATOR_SCENARIO_HEADER, name2);
|
|
4772
4791
|
return out;
|
|
4773
4792
|
}
|
|
4774
4793
|
__name(withScenario, "withScenario");
|
|
@@ -4799,8 +4818,8 @@ function upstreamKeyFor(env, upstreamId) {
|
|
|
4799
4818
|
}
|
|
4800
4819
|
__name(upstreamKeyFor, "upstreamKeyFor");
|
|
4801
4820
|
function providerCredential(env, upstreamId) {
|
|
4802
|
-
const
|
|
4803
|
-
const value = env[
|
|
4821
|
+
const name2 = `${PROVIDER_KEY_PREFIX}${upstreamId.toUpperCase().replace(/-/g, "_")}`;
|
|
4822
|
+
const value = env[name2];
|
|
4804
4823
|
return typeof value === "string" && value.length > 0 ? value : null;
|
|
4805
4824
|
}
|
|
4806
4825
|
__name(providerCredential, "providerCredential");
|
|
@@ -4965,13 +4984,13 @@ async function serveUnary(request, env, ctx, route2) {
|
|
|
4965
4984
|
headers.set("x-cruise-cache-status", response.headers.get("cf-aig-cache-status") === "HIT" ? "HIT" : "MISS");
|
|
4966
4985
|
headers.set("x-cruise-cache", cacheHeader(admission.cache));
|
|
4967
4986
|
headers.set("x-cruise-key", key.prefix);
|
|
4968
|
-
for (const [
|
|
4987
|
+
for (const [name2, value] of Object.entries(budgetHeaders(budget))) headers.set(name2, value);
|
|
4969
4988
|
headers.set("x-cruise-budget-reserved", formatUsd(reservation.reserved, 4));
|
|
4970
|
-
for (const [
|
|
4989
|
+
for (const [name2, value] of Object.entries(runHeaders(reservation.run))) headers.set(name2, value);
|
|
4971
4990
|
const rescued = trail.rescue(response.status);
|
|
4972
4991
|
if (rescued !== null) headers.set("x-cruise-fallback", rescued);
|
|
4973
|
-
if (wallet !== null) for (const [
|
|
4974
|
-
for (const
|
|
4992
|
+
if (wallet !== null) for (const [name2, value] of Object.entries(walletHeaders(wallet))) headers.set(name2, value);
|
|
4993
|
+
for (const name2 of STRIPPED) headers.delete(name2);
|
|
4975
4994
|
ctx.waitUntil(touchKey(env.DB, key.keyId));
|
|
4976
4995
|
ctx.waitUntil(pruneRateBuckets(env.DB, "key", key.keyId, now));
|
|
4977
4996
|
const bodyless = response.body === null;
|
|
@@ -5336,11 +5355,11 @@ function responsesTools(tools) {
|
|
|
5336
5355
|
for (const tool of tools) {
|
|
5337
5356
|
if (!isObject3(tool) || tool.type !== "function") continue;
|
|
5338
5357
|
const fn = isObject3(tool.function) ? tool.function : tool;
|
|
5339
|
-
const
|
|
5340
|
-
if (
|
|
5358
|
+
const name2 = String(fn.name ?? "");
|
|
5359
|
+
if (name2 === "") continue;
|
|
5341
5360
|
const item = {
|
|
5342
5361
|
type: "function",
|
|
5343
|
-
name,
|
|
5362
|
+
name: name2,
|
|
5344
5363
|
parameters: isObject3(fn.parameters) ? fn.parameters : { type: "object", properties: {} }
|
|
5345
5364
|
};
|
|
5346
5365
|
if (typeof fn.description === "string") item.description = fn.description;
|
|
@@ -5405,12 +5424,12 @@ function responsesInput(chatMessages) {
|
|
|
5405
5424
|
if (!isObject3(call)) continue;
|
|
5406
5425
|
const fn = isObject3(call.function) ? call.function : {};
|
|
5407
5426
|
const callId = String(call.id ?? "");
|
|
5408
|
-
const
|
|
5427
|
+
const name2 = String(fn.name ?? "");
|
|
5409
5428
|
const args = typeof fn.arguments === "string" ? fn.arguments : JSON.stringify(fn.arguments ?? {});
|
|
5410
5429
|
input.push({
|
|
5411
5430
|
type: "function_call",
|
|
5412
5431
|
call_id: callId,
|
|
5413
|
-
name,
|
|
5432
|
+
name: name2,
|
|
5414
5433
|
arguments: args
|
|
5415
5434
|
});
|
|
5416
5435
|
}
|
|
@@ -5515,12 +5534,12 @@ function fromOpenAIResponsesJson(responsesPayload, fallbackModel) {
|
|
|
5515
5534
|
}
|
|
5516
5535
|
} else if (type === "function_call") {
|
|
5517
5536
|
const callId = String(item.call_id ?? item.id ?? `call_${crypto.randomUUID().slice(0, 8)}`);
|
|
5518
|
-
const
|
|
5537
|
+
const name2 = String(item.name ?? "");
|
|
5519
5538
|
const args = typeof item.arguments === "string" ? item.arguments : JSON.stringify(item.arguments ?? {});
|
|
5520
5539
|
toolCalls.push({
|
|
5521
5540
|
id: callId,
|
|
5522
5541
|
type: "function",
|
|
5523
|
-
function: { name, arguments: args }
|
|
5542
|
+
function: { name: name2, arguments: args }
|
|
5524
5543
|
});
|
|
5525
5544
|
}
|
|
5526
5545
|
}
|
|
@@ -6769,7 +6788,7 @@ function securityHeaders() {
|
|
|
6769
6788
|
__name(securityHeaders, "securityHeaders");
|
|
6770
6789
|
function withSecurityHeaders(response) {
|
|
6771
6790
|
const headers = new Headers(response.headers);
|
|
6772
|
-
for (const [
|
|
6791
|
+
for (const [name2, value] of Object.entries(securityHeaders())) headers.set(name2, value);
|
|
6773
6792
|
return new Response(response.body, { status: response.status, statusText: response.statusText, headers });
|
|
6774
6793
|
}
|
|
6775
6794
|
__name(withSecurityHeaders, "withSecurityHeaders");
|
|
@@ -8193,10 +8212,10 @@ function liveHeaders(response, admission, served, compress) {
|
|
|
8193
8212
|
headers.set("x-cruise-cache", cacheHeader(admission.cache));
|
|
8194
8213
|
headers.set("x-cruise-compress", compress);
|
|
8195
8214
|
headers.set("x-cruise-key", admission.key.prefix);
|
|
8196
|
-
for (const [
|
|
8215
|
+
for (const [name2, value] of Object.entries(budgetHeaders(admission.budget))) headers.set(name2, value);
|
|
8197
8216
|
headers.set("x-cruise-budget-reserved", formatUsd(admission.reservation.reserved, 4));
|
|
8198
|
-
for (const [
|
|
8199
|
-
if (admission.wallet !== null) for (const [
|
|
8217
|
+
for (const [name2, value] of Object.entries(runHeaders(admission.reservation.run))) headers.set(name2, value);
|
|
8218
|
+
if (admission.wallet !== null) for (const [name2, value] of Object.entries(walletHeaders(admission.wallet))) headers.set(name2, value);
|
|
8200
8219
|
headers.delete("cf-aig-authorization");
|
|
8201
8220
|
headers.delete("authorization");
|
|
8202
8221
|
headers.delete("cf-aig-cache-key");
|
|
@@ -8955,7 +8974,7 @@ async function anthropicMessages2(request, env, ctx) {
|
|
|
8955
8974
|
}
|
|
8956
8975
|
const headers = new Headers(request.headers);
|
|
8957
8976
|
const apiKey = headers.get("x-api-key");
|
|
8958
|
-
for (const
|
|
8977
|
+
for (const name2 of MESSAGES_ONLY_HEADERS) headers.delete(name2);
|
|
8959
8978
|
if (!headers.has("authorization") && apiKey !== null) headers.set("authorization", `Bearer ${apiKey}`);
|
|
8960
8979
|
headers.set("content-type", "application/json");
|
|
8961
8980
|
const chat = new Request(new URL("/v1/chat/completions", request.url), {
|
|
@@ -9004,7 +9023,7 @@ function toChatMessages(input, instructions) {
|
|
|
9004
9023
|
}
|
|
9005
9024
|
if (type === "function_call") {
|
|
9006
9025
|
const callId = String(entry.call_id ?? entry.id ?? `call_${crypto.randomUUID().slice(0, 8)}`);
|
|
9007
|
-
const
|
|
9026
|
+
const name2 = String(entry.name ?? "");
|
|
9008
9027
|
const args = typeof entry.arguments === "string" ? entry.arguments : JSON.stringify(entry.arguments ?? {});
|
|
9009
9028
|
messages.push({
|
|
9010
9029
|
role: "assistant",
|
|
@@ -9013,7 +9032,7 @@ function toChatMessages(input, instructions) {
|
|
|
9013
9032
|
{
|
|
9014
9033
|
id: callId,
|
|
9015
9034
|
type: "function",
|
|
9016
|
-
function: { name, arguments: args }
|
|
9035
|
+
function: { name: name2, arguments: args }
|
|
9017
9036
|
}
|
|
9018
9037
|
]
|
|
9019
9038
|
});
|
|
@@ -9037,15 +9056,15 @@ function toChatTools(tools) {
|
|
|
9037
9056
|
const out = [];
|
|
9038
9057
|
for (const tool of tools) {
|
|
9039
9058
|
if (!isObject9(tool) || tool.type !== "function") continue;
|
|
9040
|
-
const
|
|
9041
|
-
if (
|
|
9059
|
+
const name2 = String(tool.name ?? (isObject9(tool.function) ? tool.function.name : ""));
|
|
9060
|
+
if (name2 === "") continue;
|
|
9042
9061
|
const desc = typeof tool.description === "string" ? tool.description : isObject9(tool.function) && typeof tool.function.description === "string" ? tool.function.description : void 0;
|
|
9043
9062
|
const params = isObject9(tool.parameters) ? tool.parameters : isObject9(tool.function) && isObject9(tool.function.parameters) ? tool.function.parameters : { type: "object", properties: {} };
|
|
9044
9063
|
const strict = tool.strict !== void 0 ? tool.strict : isObject9(tool.function) ? tool.function.strict : void 0;
|
|
9045
9064
|
out.push({
|
|
9046
9065
|
type: "function",
|
|
9047
9066
|
function: {
|
|
9048
|
-
name,
|
|
9067
|
+
name: name2,
|
|
9049
9068
|
...desc !== void 0 ? { description: desc } : {},
|
|
9050
9069
|
parameters: params,
|
|
9051
9070
|
...strict !== void 0 ? { strict } : {}
|
|
@@ -9477,8 +9496,8 @@ async function models(request, env, ctx) {
|
|
|
9477
9496
|
return { lane, summary: summariseLane(lane, listed, prices) };
|
|
9478
9497
|
}).filter((entry) => entry.summary !== null);
|
|
9479
9498
|
const headers = new Headers({ "x-cruise-project": auth.key.projectSlug });
|
|
9480
|
-
if (budget !== null) for (const [
|
|
9481
|
-
if (wallet !== null) for (const [
|
|
9499
|
+
if (budget !== null) for (const [name2, value] of Object.entries(budgetHeaders(budget))) headers.set(name2, value);
|
|
9500
|
+
if (wallet !== null) for (const [name2, value] of Object.entries(walletHeaders(wallet))) headers.set(name2, value);
|
|
9482
9501
|
return Response.json({
|
|
9483
9502
|
object: "list",
|
|
9484
9503
|
data: [
|
|
@@ -9545,7 +9564,7 @@ async function models(request, env, ctx) {
|
|
|
9545
9564
|
id: lane.id,
|
|
9546
9565
|
object: "model",
|
|
9547
9566
|
created: epochSeconds(lane.createdAt),
|
|
9548
|
-
owned_by: "
|
|
9567
|
+
owned_by: "cruise",
|
|
9549
9568
|
"x-cruise": {
|
|
9550
9569
|
// The flag is the contract; the `bb/` prefix is the convention.
|
|
9551
9570
|
lane: true,
|
|
@@ -9787,9 +9806,9 @@ async function getSpend(args, tc) {
|
|
|
9787
9806
|
);
|
|
9788
9807
|
}
|
|
9789
9808
|
__name(getSpend, "getSpend");
|
|
9790
|
-
async function callTool(
|
|
9809
|
+
async function callTool(name2, args, tc) {
|
|
9791
9810
|
const input = isObject11(args) ? args : {};
|
|
9792
|
-
switch (
|
|
9811
|
+
switch (name2) {
|
|
9793
9812
|
case "list_models":
|
|
9794
9813
|
return listModels2(input, tc);
|
|
9795
9814
|
case "get_budget":
|
|
@@ -9807,17 +9826,17 @@ var isObject12 = /* @__PURE__ */ __name((value) => typeof value === "object" &&
|
|
|
9807
9826
|
var MODERN_VERSION = "2026-07-28";
|
|
9808
9827
|
var LEGACY_VERSIONS = ["2025-11-25", "2025-06-18", "2025-03-26"];
|
|
9809
9828
|
var SUPPORTED = [MODERN_VERSION, ...LEGACY_VERSIONS];
|
|
9810
|
-
var SERVER_INFO = { name: "cruise", title: "
|
|
9829
|
+
var SERVER_INFO = { name: "cruise", title: "Cruise", version: "1.0.0" };
|
|
9811
9830
|
var INSTRUCTIONS = "Cruise is the gateway this key sends model requests through. These tools read the key's own project: `list_models` for the models and lanes it can call (and what each lane is for), `get_budget` for what is left before requests are refused, `get_spend` for what a month cost. Nothing here changes anything.";
|
|
9812
9831
|
var CAPABILITIES = { tools: {} };
|
|
9813
9832
|
var CACHE_HINTS = {
|
|
9814
9833
|
"server/discover": { ttlMs: 36e5, cacheScope: "public" },
|
|
9815
9834
|
"tools/list": { ttlMs: 3e5, cacheScope: "public" }
|
|
9816
9835
|
};
|
|
9817
|
-
function originAllowed(
|
|
9818
|
-
if (
|
|
9836
|
+
function originAllowed(origin2, env) {
|
|
9837
|
+
if (origin2 === null) return true;
|
|
9819
9838
|
const allowed = /* @__PURE__ */ new Set(["https://claude.ai", "https://claude.com", ...(env.DASHBOARD_ORIGIN ?? "").split(",").map((o) => o.trim())]);
|
|
9820
|
-
return allowed.has(
|
|
9839
|
+
return allowed.has(origin2);
|
|
9821
9840
|
}
|
|
9822
9841
|
__name(originAllowed, "originAllowed");
|
|
9823
9842
|
function rpcError(status, id, code, message, data) {
|
|
@@ -9912,7 +9931,7 @@ async function mcp(request, env, ctx) {
|
|
|
9912
9931
|
const outcome = await dispatch(
|
|
9913
9932
|
message.method,
|
|
9914
9933
|
params,
|
|
9915
|
-
(
|
|
9934
|
+
(name2, args) => callTool(name2, args, { env, ctx, key: auth.key, request, now })
|
|
9916
9935
|
);
|
|
9917
9936
|
if (outcome === "unknown_tool") return rpcError(modern ? 400 : 200, message.id, -32602, `Unknown tool: ${String(params.name)}`);
|
|
9918
9937
|
if (outcome === null) return rpcError(modern ? 404 : 200, message.id, -32601, `Method not found: ${message.method}`);
|
|
@@ -10459,13 +10478,10 @@ var billingRoutes = /* @__PURE__ */ __name(async ({ request, env, url, path, cal
|
|
|
10459
10478
|
return null;
|
|
10460
10479
|
}, "billingRoutes");
|
|
10461
10480
|
|
|
10462
|
-
// src/demo-catalogue.ts
|
|
10463
|
-
var DEMO_ENVIRONMENT = "demo";
|
|
10464
|
-
|
|
10465
10481
|
// src/tenants-prepaid.ts
|
|
10466
10482
|
var STARTING_WALLET_SOFT_MICROS = 1e6;
|
|
10467
|
-
function prepaidOn(environment) {
|
|
10468
|
-
return environment !==
|
|
10483
|
+
function prepaidOn(environment, role) {
|
|
10484
|
+
return deploymentRole({ ENVIRONMENT: environment, ...role === void 0 ? {} : { DEPLOYMENT_ROLE: role } }).role !== "demo";
|
|
10469
10485
|
}
|
|
10470
10486
|
__name(prepaidOn, "prepaidOn");
|
|
10471
10487
|
function walletInsert(db, tenantId, actor) {
|
|
@@ -10518,10 +10534,10 @@ function gatewayRefusal(gateway, operator) {
|
|
|
10518
10534
|
}
|
|
10519
10535
|
__name(gatewayRefusal, "gatewayRefusal");
|
|
10520
10536
|
function assertName(rawName) {
|
|
10521
|
-
const
|
|
10522
|
-
if (
|
|
10523
|
-
if (
|
|
10524
|
-
return
|
|
10537
|
+
const name2 = rawName.trim();
|
|
10538
|
+
if (name2 === "") throw new Error("A tenant name is required.");
|
|
10539
|
+
if (name2.length > MAX_NAME_LENGTH) throw new Error(`A tenant name cannot exceed ${MAX_NAME_LENGTH} characters.`);
|
|
10540
|
+
return name2;
|
|
10525
10541
|
}
|
|
10526
10542
|
__name(assertName, "assertName");
|
|
10527
10543
|
function assertCap(micros, label) {
|
|
@@ -10580,7 +10596,7 @@ function alreadyThere(tenant, ownerUid) {
|
|
|
10580
10596
|
__name(alreadyThere, "alreadyThere");
|
|
10581
10597
|
async function provisionTenant(db, request, actor) {
|
|
10582
10598
|
const id = await assertTenantId(db, request.id);
|
|
10583
|
-
const
|
|
10599
|
+
const name2 = assertName(request.name);
|
|
10584
10600
|
const ownerUid = assertUid(request.ownerUid);
|
|
10585
10601
|
const gateway = assertGateway(request.gateway ?? "gw-sensitive");
|
|
10586
10602
|
const gatewayRefused = gatewayRefusal(gateway, false);
|
|
@@ -10608,11 +10624,11 @@ async function provisionTenant(db, request, actor) {
|
|
|
10608
10624
|
}
|
|
10609
10625
|
try {
|
|
10610
10626
|
await db.batch([
|
|
10611
|
-
db.prepare(`INSERT INTO tenants (id, name, tier, billable) VALUES (?1, ?2, ?3, ?4)`).bind(id,
|
|
10627
|
+
db.prepare(`INSERT INTO tenants (id, name, tier, billable) VALUES (?1, ?2, ?3, ?4)`).bind(id, name2, tier, prepaid ? 1 : 0),
|
|
10612
10628
|
// `budget_behaviour` is left at its schema default of `refuse`. v0 ships
|
|
10613
10629
|
// only the refusal path — `degrade` waits on auto mode (#19) — so recording
|
|
10614
10630
|
// an intent nothing honours would be a promise to a customer we cannot keep.
|
|
10615
|
-
db.prepare(`INSERT INTO projects (id, tenant_id, slug, name, gateway) VALUES (?1, ?2, ?3, ?4, ?5)`).bind(projectId, id, STARTING_PROJECT_SLUG,
|
|
10631
|
+
db.prepare(`INSERT INTO projects (id, tenant_id, slug, name, gateway) VALUES (?1, ?2, ?3, ?4, ?5)`).bind(projectId, id, STARTING_PROJECT_SLUG, name2, gateway),
|
|
10616
10632
|
db.prepare(
|
|
10617
10633
|
`INSERT INTO budgets (scope, subject, period, soft_micros, hard_micros, updated_by)
|
|
10618
10634
|
VALUES ('project', ?1, 'day', ?2, ?3, ?4)`
|
|
@@ -10630,7 +10646,7 @@ async function provisionTenant(db, request, actor) {
|
|
|
10630
10646
|
actor,
|
|
10631
10647
|
id,
|
|
10632
10648
|
JSON.stringify({
|
|
10633
|
-
name,
|
|
10649
|
+
name: name2,
|
|
10634
10650
|
tier,
|
|
10635
10651
|
project: projectId,
|
|
10636
10652
|
gateway,
|
|
@@ -10671,8 +10687,8 @@ async function createProject(db, tenantId, request, actor, operator) {
|
|
|
10671
10687
|
`'${request.slug}' is not a valid project slug: lowercase letters, digits and dashes, up to 64 characters, starting with a letter or digit. A project id is '<tenant>/<slug>' and cannot be changed afterwards.`
|
|
10672
10688
|
);
|
|
10673
10689
|
}
|
|
10674
|
-
const
|
|
10675
|
-
if (
|
|
10690
|
+
const name2 = request.name.trim();
|
|
10691
|
+
if (name2 === "" || name2.length > 120) return refuse(400, "invalid_name", "A project name of 1 to 120 characters is required.");
|
|
10676
10692
|
let gateway;
|
|
10677
10693
|
try {
|
|
10678
10694
|
gateway = assertGateway(request.gateway ?? "gw-sensitive");
|
|
@@ -10711,11 +10727,11 @@ async function createProject(db, tenantId, request, actor, operator) {
|
|
|
10711
10727
|
const insertProject = tier.projects === null ? db.prepare(
|
|
10712
10728
|
`INSERT INTO projects (id, tenant_id, slug, name, gateway, compress)
|
|
10713
10729
|
SELECT ?1, ?2, ?3, ?4, ?5, t.default_compress FROM tenants t WHERE t.id = ?2`
|
|
10714
|
-
).bind(id, tenantId, slug,
|
|
10730
|
+
).bind(id, tenantId, slug, name2, gateway) : db.prepare(
|
|
10715
10731
|
`INSERT INTO projects (id, tenant_id, slug, name, gateway, compress)
|
|
10716
10732
|
SELECT ?1, ?2, ?3, ?4, ?5, t.default_compress FROM tenants t
|
|
10717
10733
|
WHERE t.id = ?2 AND (SELECT count(*) FROM projects WHERE tenant_id = ?2) < ?6`
|
|
10718
|
-
).bind(id, tenantId, slug,
|
|
10734
|
+
).bind(id, tenantId, slug, name2, gateway, tier.projects);
|
|
10719
10735
|
let results;
|
|
10720
10736
|
try {
|
|
10721
10737
|
results = await db.batch([
|
|
@@ -10734,7 +10750,7 @@ async function createProject(db, tenantId, request, actor, operator) {
|
|
|
10734
10750
|
crypto.randomUUID(),
|
|
10735
10751
|
actor,
|
|
10736
10752
|
id,
|
|
10737
|
-
JSON.stringify({ tenant: tenantId, name, gateway, soft_micros: softMicros, hard_micros: hardMicros }),
|
|
10753
|
+
JSON.stringify({ tenant: tenantId, name: name2, gateway, soft_micros: softMicros, hard_micros: hardMicros }),
|
|
10738
10754
|
tenantId
|
|
10739
10755
|
)
|
|
10740
10756
|
]);
|
|
@@ -10745,7 +10761,7 @@ async function createProject(db, tenantId, request, actor, operator) {
|
|
|
10745
10761
|
const raced = projectQuotaRefusal(tier, (tier.projects ?? 0) + 1);
|
|
10746
10762
|
return refuse(403, raced.code, raced.message);
|
|
10747
10763
|
}
|
|
10748
|
-
return { ok: true, project: { id, slug, name, gateway, period: "day", softMicros, hardMicros } };
|
|
10764
|
+
return { ok: true, project: { id, slug, name: name2, gateway, period: "day", softMicros, hardMicros } };
|
|
10749
10765
|
}
|
|
10750
10766
|
__name(createProject, "createProject");
|
|
10751
10767
|
|
|
@@ -10989,8 +11005,8 @@ var catalogRoutes = /* @__PURE__ */ __name(async ({ request, env, path, caller,
|
|
|
10989
11005
|
if (period !== "day" && period !== "month") {
|
|
10990
11006
|
return errorResponse(400, "invalid_request_error", "'period' is required: day or month.", { headers: cors });
|
|
10991
11007
|
}
|
|
10992
|
-
const cap = /* @__PURE__ */ __name((
|
|
10993
|
-
const value = body?.[
|
|
11008
|
+
const cap = /* @__PURE__ */ __name((name2) => {
|
|
11009
|
+
const value = body?.[name2];
|
|
10994
11010
|
if (value === null) return null;
|
|
10995
11011
|
if (typeof value === "number" && Number.isFinite(value) && value >= 0) return usdToMicros(value);
|
|
10996
11012
|
return void 0;
|
|
@@ -11319,7 +11335,7 @@ var keyRoutes = /* @__PURE__ */ __name(async ({ request, env, path, caller, cors
|
|
|
11319
11335
|
const issued = await issueKey(env.DB, {
|
|
11320
11336
|
projectId,
|
|
11321
11337
|
tenantId: caller.tenantId,
|
|
11322
|
-
environment: keyEnvironmentFor(env.ENVIRONMENT),
|
|
11338
|
+
environment: keyEnvironmentFor(env.ENVIRONMENT, env.DEPLOYMENT_ROLE),
|
|
11323
11339
|
actor: caller.identity.email ?? caller.identity.uid,
|
|
11324
11340
|
...typeof body?.name === "string" ? { name: body.name } : {},
|
|
11325
11341
|
allowedModels: Array.isArray(body?.models) ? body.models : [],
|
|
@@ -12534,8 +12550,8 @@ function nowIso() {
|
|
|
12534
12550
|
__name(nowIso, "nowIso");
|
|
12535
12551
|
function isAbort(cause) {
|
|
12536
12552
|
if (cause === null || typeof cause !== "object") return false;
|
|
12537
|
-
const
|
|
12538
|
-
return
|
|
12553
|
+
const name2 = cause.name;
|
|
12554
|
+
return name2 === "AbortError" || name2 === "TimeoutError";
|
|
12539
12555
|
}
|
|
12540
12556
|
__name(isAbort, "isAbort");
|
|
12541
12557
|
function fetchFailedOrTimeout(cause) {
|
|
@@ -12551,14 +12567,14 @@ var CREDITS_CONCURRENCY = 8;
|
|
|
12551
12567
|
var BILLING_OPENAI = "PROVIDER_BILLING_KEY_OPENAI";
|
|
12552
12568
|
var BILLING_ANTHROPIC = "PROVIDER_BILLING_KEY_ANTHROPIC";
|
|
12553
12569
|
var BILLING_CF = "CF_BILLING_TOKEN";
|
|
12554
|
-
function secret(env,
|
|
12555
|
-
const value = env[
|
|
12570
|
+
function secret(env, name2) {
|
|
12571
|
+
const value = env[name2];
|
|
12556
12572
|
return typeof value === "string" && value.length > 0 ? value : null;
|
|
12557
12573
|
}
|
|
12558
12574
|
__name(secret, "secret");
|
|
12559
12575
|
function inferenceKey(env, upstreamId) {
|
|
12560
|
-
const
|
|
12561
|
-
return secret(env,
|
|
12576
|
+
const name2 = `PROVIDER_KEY_${upstreamId.toUpperCase().replace(/-/g, "_")}`;
|
|
12577
|
+
return secret(env, name2);
|
|
12562
12578
|
}
|
|
12563
12579
|
__name(inferenceKey, "inferenceKey");
|
|
12564
12580
|
function moneyMicros(amount) {
|
|
@@ -12788,25 +12804,25 @@ __name(mapPool, "mapPool");
|
|
|
12788
12804
|
// src/upstream-health.ts
|
|
12789
12805
|
var HEALTH_BURN_DAYS = 7;
|
|
12790
12806
|
var BILLING_GOOGLE = "PROVIDER_BILLING_KEY_GOOGLE_AI_STUDIO";
|
|
12791
|
-
function secret2(env,
|
|
12792
|
-
const value = env[
|
|
12807
|
+
function secret2(env, name2) {
|
|
12808
|
+
const value = env[name2];
|
|
12793
12809
|
return typeof value === "string" && value.length > 0 ? value : null;
|
|
12794
12810
|
}
|
|
12795
12811
|
__name(secret2, "secret");
|
|
12796
12812
|
function inferenceKey2(env, upstreamId) {
|
|
12797
|
-
const
|
|
12798
|
-
return secret2(env,
|
|
12813
|
+
const name2 = `PROVIDER_KEY_${upstreamId.toUpperCase().replace(/-/g, "_")}`;
|
|
12814
|
+
return secret2(env, name2);
|
|
12799
12815
|
}
|
|
12800
12816
|
__name(inferenceKey2, "inferenceKey");
|
|
12801
|
-
function headerInt(headers,
|
|
12802
|
-
const raw = headers.get(
|
|
12817
|
+
function headerInt(headers, name2) {
|
|
12818
|
+
const raw = headers.get(name2);
|
|
12803
12819
|
if (raw === null || raw === "") return void 0;
|
|
12804
12820
|
const n = Number(raw);
|
|
12805
12821
|
return Number.isFinite(n) ? n : void 0;
|
|
12806
12822
|
}
|
|
12807
12823
|
__name(headerInt, "headerInt");
|
|
12808
|
-
function headerStr(headers,
|
|
12809
|
-
const raw = headers.get(
|
|
12824
|
+
function headerStr(headers, name2) {
|
|
12825
|
+
const raw = headers.get(name2);
|
|
12810
12826
|
return raw === null || raw === "" ? void 0 : raw;
|
|
12811
12827
|
}
|
|
12812
12828
|
__name(headerStr, "headerStr");
|
|
@@ -13484,7 +13500,7 @@ function allowedOrigins(env) {
|
|
|
13484
13500
|
}
|
|
13485
13501
|
__name(allowedOrigins, "allowedOrigins");
|
|
13486
13502
|
function corsHeaders(env, request) {
|
|
13487
|
-
const
|
|
13503
|
+
const origin2 = request.headers.get("origin") ?? "";
|
|
13488
13504
|
const headers = {
|
|
13489
13505
|
vary: "origin",
|
|
13490
13506
|
"access-control-allow-methods": "GET, POST, PUT, DELETE, OPTIONS",
|
|
@@ -13509,9 +13525,9 @@ function corsHeaders(env, request) {
|
|
|
13509
13525
|
// dashboard would see the header in the response and not in JavaScript.
|
|
13510
13526
|
"access-control-expose-headers": "server-timing"
|
|
13511
13527
|
};
|
|
13512
|
-
if (
|
|
13513
|
-
headers["access-control-allow-origin"] =
|
|
13514
|
-
headers["timing-allow-origin"] =
|
|
13528
|
+
if (origin2 !== "" && allowedOrigins(env).has(origin2)) {
|
|
13529
|
+
headers["access-control-allow-origin"] = origin2;
|
|
13530
|
+
headers["timing-allow-origin"] = origin2;
|
|
13515
13531
|
}
|
|
13516
13532
|
return headers;
|
|
13517
13533
|
}
|
|
@@ -14431,7 +14447,7 @@ async function paymentsTenants(request, env, ctx) {
|
|
|
14431
14447
|
if (typeof parsed === "string") return errorResponse(400, "invalid_request_error", parsed);
|
|
14432
14448
|
let result2;
|
|
14433
14449
|
try {
|
|
14434
|
-
result2 = await provisionTenant(env.DB, { ...toRequest(parsed), prepaid: prepaidOn(env.ENVIRONMENT) }, auth.actor);
|
|
14450
|
+
result2 = await provisionTenant(env.DB, { ...toRequest(parsed), prepaid: prepaidOn(env.ENVIRONMENT, env.DEPLOYMENT_ROLE) }, auth.actor);
|
|
14435
14451
|
} catch (cause) {
|
|
14436
14452
|
return errorResponse(400, "invalid_request_error", cause instanceof Error ? cause.message : String(cause), {
|
|
14437
14453
|
code: "provision_refused"
|
|
@@ -14826,12 +14842,82 @@ async function paymentsTierMarkup(request, env, ctx, tierId) {
|
|
|
14826
14842
|
}
|
|
14827
14843
|
__name(paymentsTierMarkup, "paymentsTierMarkup");
|
|
14828
14844
|
|
|
14845
|
+
// src/deployment-identity.ts
|
|
14846
|
+
var LOOPBACK = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "[::1]"]);
|
|
14847
|
+
function origin(raw) {
|
|
14848
|
+
if (!raw) return null;
|
|
14849
|
+
let url;
|
|
14850
|
+
try {
|
|
14851
|
+
url = new URL(raw.trim());
|
|
14852
|
+
} catch {
|
|
14853
|
+
return null;
|
|
14854
|
+
}
|
|
14855
|
+
const secure = url.protocol === "https:" || url.protocol === "http:" && LOOPBACK.has(url.hostname);
|
|
14856
|
+
if (!secure || url.username || url.password || url.search || url.hash) return null;
|
|
14857
|
+
if (url.pathname !== "/" && url.pathname !== "") return null;
|
|
14858
|
+
return url.origin;
|
|
14859
|
+
}
|
|
14860
|
+
__name(origin, "origin");
|
|
14861
|
+
function httpsUrl(raw) {
|
|
14862
|
+
if (!raw) return null;
|
|
14863
|
+
try {
|
|
14864
|
+
const url = new URL(raw.trim());
|
|
14865
|
+
return url.protocol === "https:" && !url.username && !url.password ? url.href.replace(/\/$/, "") : null;
|
|
14866
|
+
} catch {
|
|
14867
|
+
return null;
|
|
14868
|
+
}
|
|
14869
|
+
}
|
|
14870
|
+
__name(httpsUrl, "httpsUrl");
|
|
14871
|
+
function name(raw) {
|
|
14872
|
+
const value = raw?.trim();
|
|
14873
|
+
if (!value || value.length > 80 || /[\r\n<>]/.test(value)) return null;
|
|
14874
|
+
return value;
|
|
14875
|
+
}
|
|
14876
|
+
__name(name, "name");
|
|
14877
|
+
function deploymentIdentity(env) {
|
|
14878
|
+
const token = env.GOOGLE_SITE_VERIFICATION?.trim();
|
|
14879
|
+
return {
|
|
14880
|
+
base: origin(env.PUBLIC_BASE_URL),
|
|
14881
|
+
demo: origin(env.DEMO_BASE_URL),
|
|
14882
|
+
staging: origin(env.STAGING_BASE_URL),
|
|
14883
|
+
operatorName: name(env.OPERATOR_NAME),
|
|
14884
|
+
operatorUrl: httpsUrl(env.OPERATOR_URL),
|
|
14885
|
+
// The verification file's name without `.html`, as Search Console hands it out.
|
|
14886
|
+
googleSiteVerification: token && /^google[A-Za-z0-9]{8,64}$/.test(token) ? token : null
|
|
14887
|
+
};
|
|
14888
|
+
}
|
|
14889
|
+
__name(deploymentIdentity, "deploymentIdentity");
|
|
14890
|
+
function productName(identity) {
|
|
14891
|
+
return identity.operatorName ? `${identity.operatorName} Cruise` : "Cruise";
|
|
14892
|
+
}
|
|
14893
|
+
__name(productName, "productName");
|
|
14894
|
+
var GENERIC_IDENTITY = deploymentIdentity({});
|
|
14895
|
+
|
|
14829
14896
|
// src/integrate-prompt.ts
|
|
14830
|
-
|
|
14831
|
-
|
|
14832
|
-
|
|
14833
|
-
|
|
14834
|
-
|
|
14897
|
+
function baseOf(identity) {
|
|
14898
|
+
return identity.base ?? "https://<this Cruise deployment>";
|
|
14899
|
+
}
|
|
14900
|
+
__name(baseOf, "baseOf");
|
|
14901
|
+
function integrationPrompt(identity) {
|
|
14902
|
+
const base = baseOf(identity);
|
|
14903
|
+
const others = [
|
|
14904
|
+
identity.demo ? `
|
|
14905
|
+
The demo is a separate system: ${identity.demo}/v1` : "",
|
|
14906
|
+
identity.staging ? `
|
|
14907
|
+
Staging is a separate system: ${identity.staging}/v1` : ""
|
|
14908
|
+
].join("");
|
|
14909
|
+
const unset = identity.base ? "" : "\n (This deployment has not published its own address. Use the base URL\n you were given with your key.)";
|
|
14910
|
+
const demoKey = identity.demo ? identity.operatorUrl ? `A cru_demo_
|
|
14911
|
+
key comes from ${identity.operatorUrl}, which runs the demo; it is shown
|
|
14912
|
+
once, with its rate limit beside it.` : "A cru_demo_\n key comes from whoever runs the demo; it is shown once, with its rate limit\n beside it." : "";
|
|
14913
|
+
const demoBullet = identity.demo ? `- The demo holds no provider credential. Every answer there is fabricated by an
|
|
14914
|
+
emulator, every price is zero and every key is rate-limited, so nothing you
|
|
14915
|
+
do against it is billable \u2014 and nothing it returns is a real completion. It
|
|
14916
|
+
proves the wiring, not the model. Its catalogue mirrors production's model
|
|
14917
|
+
ids exactly, and that is what makes the next sentence true: what changes
|
|
14918
|
+
when you go live is the base URL and the key, and nothing else. ${demoKey}
|
|
14919
|
+
` : "";
|
|
14920
|
+
return `You are integrating ${productName(identity)} into this repository.
|
|
14835
14921
|
|
|
14836
14922
|
Cruise is an OpenAI-compatible gateway in front of every model provider: one
|
|
14837
14923
|
endpoint, per-project keys, budgets that stop a runaway loop, a cost ledger
|
|
@@ -14840,23 +14926,13 @@ pinning one. Integrating it is a change of base URL and credential, not a
|
|
|
14840
14926
|
rewrite.
|
|
14841
14927
|
|
|
14842
14928
|
FACTS \u2014 use these, do not guess them:
|
|
14843
|
-
- Base URL: ${
|
|
14844
|
-
The demo is a separate system: ${DEMO_BASE}/v1
|
|
14845
|
-
Staging is a separate system: ${STAGING_BASE}/v1
|
|
14929
|
+
- Base URL: ${base}/v1${unset}${others}
|
|
14846
14930
|
- Auth: an "Authorization: Bearer" header carrying a Cruise key. The key's
|
|
14847
14931
|
middle segment names the deployment that issued it: cru_live_ is production's,
|
|
14848
14932
|
cru_test_ staging's, cru_demo_ the demo's. A key belongs to exactly one of
|
|
14849
14933
|
them, and presenting it to another is 401 \u2014 the same answer as a key that
|
|
14850
14934
|
never existed. Use the base URL that matches the key you were given.
|
|
14851
|
-
-
|
|
14852
|
-
emulator, every price is zero and every key is rate-limited, so nothing you
|
|
14853
|
-
do against it is billable \u2014 and nothing it returns is a real completion. It
|
|
14854
|
-
proves the wiring, not the model. Its catalogue mirrors production's model
|
|
14855
|
-
ids exactly, and that is what makes the next sentence true: what changes
|
|
14856
|
-
when you go live is the base URL and the key, and nothing else. A cru_demo_
|
|
14857
|
-
key comes from signing in at ${LANDING} and opening the demo; it is shown
|
|
14858
|
-
once, with its rate limit beside it.
|
|
14859
|
-
- On the demo, the "x-cruise-scenario" header asks for the failure, so you can
|
|
14935
|
+
${demoBullet}- On the demo, the "x-cruise-scenario" header asks for the failure, so you can
|
|
14860
14936
|
rehearse each one deliberately instead of meeting it first in production.
|
|
14861
14937
|
One of: ${SCENARIOS.join(", ")}.
|
|
14862
14938
|
Anything else is a 400 with code invalid_scenario. Every attempt in the
|
|
@@ -14883,8 +14959,8 @@ FACTS \u2014 use these, do not guess them:
|
|
|
14883
14959
|
cannot draw a member that trains. Under random, weighted or graduated the
|
|
14884
14960
|
budget still caps you but per-request spend stops being predictable, and the
|
|
14885
14961
|
ledger records which policy ran.
|
|
14886
|
-
- The full reference is at ${
|
|
14887
|
-
specification at ${
|
|
14962
|
+
- The full reference is at ${base}/docs and the machine-readable
|
|
14963
|
+
specification at ${base}/openapi.json. Fetch the specification and
|
|
14888
14964
|
read it rather than inferring behaviour from this prompt.
|
|
14889
14965
|
|
|
14890
14966
|
DO, in this order:
|
|
@@ -14961,15 +15037,17 @@ DO NOT:
|
|
|
14961
15037
|
Report back with: the call sites you changed, the model ids or lanes you chose
|
|
14962
15038
|
for each and why, the headers you are now logging, and anything you found that
|
|
14963
15039
|
the specification did not answer.`;
|
|
15040
|
+
}
|
|
15041
|
+
__name(integrationPrompt, "integrationPrompt");
|
|
14964
15042
|
|
|
14965
15043
|
// src/document-metadata.ts
|
|
14966
15044
|
function escapeAttribute(value) {
|
|
14967
15045
|
return value.replaceAll("&", "&").replaceAll('"', """).replaceAll("'", "'").replaceAll("<", "<").replaceAll(">", ">");
|
|
14968
15046
|
}
|
|
14969
15047
|
__name(escapeAttribute, "escapeAttribute");
|
|
14970
|
-
function canonicalLink(
|
|
14971
|
-
if (
|
|
14972
|
-
return ` <link rel="canonical" href="${escapeAttribute(
|
|
15048
|
+
function canonicalLink(origin2, path) {
|
|
15049
|
+
if (origin2 === void 0) return "";
|
|
15050
|
+
return ` <link rel="canonical" href="${escapeAttribute(origin2)}${path}">
|
|
14973
15051
|
`;
|
|
14974
15052
|
}
|
|
14975
15053
|
__name(canonicalLink, "canonicalLink");
|
|
@@ -15025,7 +15103,7 @@ function escapeHtml(text) {
|
|
|
15025
15103
|
return text.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """);
|
|
15026
15104
|
}
|
|
15027
15105
|
__name(escapeHtml, "escapeHtml");
|
|
15028
|
-
var
|
|
15106
|
+
var curlExample = /* @__PURE__ */ __name((base) => `curl -sS -i ${base}/v1/chat/completions \\
|
|
15029
15107
|
-H "Authorization: Bearer $CRUISE_API_KEY" \\
|
|
15030
15108
|
-H "content-type: application/json" \\
|
|
15031
15109
|
-d '{"model":"bb/summarization","messages":[{"role":"user","content":"ping"}]}' \\
|
|
@@ -15033,7 +15111,7 @@ var CURL_EXAMPLE = `curl -sS -i ${PRODUCTION_BASE}/v1/chat/completions \\
|
|
|
15033
15111
|
|
|
15034
15112
|
# HTTP/2 200, and an x-cruise-model naming whichever member the lane picked.
|
|
15035
15113
|
# Any other status is the answer: 401 is the key, 429 the budget, the wallet or a
|
|
15036
|
-
# rate limit, and a 4xx or 5xx carrying x-cruise-upstream-status is the provider's own
|
|
15114
|
+
# rate limit, and a 4xx or 5xx carrying x-cruise-upstream-status is the provider's own.`, "curlExample");
|
|
15037
15115
|
var STYLE = `:root { color-scheme: light dark; --bg: #fbfbfa; --fg: #16161a; --dim: #5c5c66;
|
|
15038
15116
|
--line: #e2e2dd; --card: #ffffff; --accent: #1c4ed8; --code-bg: #f5f5f2; }
|
|
15039
15117
|
@media (prefers-color-scheme: dark) { :root { --bg: #131316; --fg: #ededf0; --dim: #a0a0ab;
|
|
@@ -15085,20 +15163,41 @@ function copyButton(target) {
|
|
|
15085
15163
|
return `<button type="button" data-copy="${target}">${COPY_ICON}<span class="label">Copy</span></button>`;
|
|
15086
15164
|
}
|
|
15087
15165
|
__name(copyButton, "copyButton");
|
|
15088
|
-
function
|
|
15089
|
-
|
|
15166
|
+
function rehearse(identity) {
|
|
15167
|
+
if (!identity.demo) return "";
|
|
15168
|
+
return ` <h2>Rehearse before you go live</h2>
|
|
15169
|
+
<p>The demo at <code>${escapeHtml(identity.demo)}/v1</code> is a complete Cruise that holds no provider
|
|
15170
|
+
credential: every answer is fabricated, every price is zero, and its catalogue carries
|
|
15171
|
+
production's model ids exactly. So <strong>what changes when you go live is the base URL and
|
|
15172
|
+
the key, and nothing else.</strong> On the demo, <code>x-cruise-scenario</code> asks for the
|
|
15173
|
+
failure \u2014 ${SCENARIOS.map((name2) => `<code>${name2}</code>`).join(", ")} \u2014 so each one is
|
|
15174
|
+
rehearsed on purpose rather than met first in production. Anything else is a <code>400</code>
|
|
15175
|
+
with code <code>invalid_scenario</code>, and on any other deployment the header is checked and
|
|
15176
|
+
then ignored.</p>
|
|
15177
|
+
|
|
15178
|
+
`;
|
|
15179
|
+
}
|
|
15180
|
+
__name(rehearse, "rehearse");
|
|
15181
|
+
function integratePage(identity) {
|
|
15182
|
+
const canonical2 = canonicalLink(identity.base ?? void 0, "/integrate");
|
|
15183
|
+
const base = baseOf(identity);
|
|
15184
|
+
const product = productName(identity);
|
|
15185
|
+
const operator = identity.operatorName ?? "whoever runs this deployment";
|
|
15186
|
+
const getKey = identity.demo ? `Get a key. ${identity.operatorUrl ? `Sign in at <a href="${escapeHtml(identity.operatorUrl)}">${escapeHtml(new URL(identity.operatorUrl).host)}</a> and open the demo for a` : "Ask for a"}
|
|
15187
|
+
<code>cru_demo_</code> key that can spend nothing, or ask ${escapeHtml(operator)} for a
|
|
15188
|
+
production key \u2014 one per project, and it is shown once.` : `Get a key from ${escapeHtml(operator)} \u2014 one per project, and it is shown once.`;
|
|
15090
15189
|
return `<!doctype html>
|
|
15091
15190
|
<html lang="en">
|
|
15092
15191
|
<head>
|
|
15093
15192
|
<meta charset="utf-8">
|
|
15094
15193
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
15095
15194
|
<title>Integrate Cruise with an agent</title>
|
|
15096
|
-
<meta name="description" content="Copy one prompt, hand it to a coding agent, and it wires this repository up to
|
|
15195
|
+
<meta name="description" content="Copy one prompt, hand it to a coding agent, and it wires this repository up to ${escapeHtml(product)}. The manual steps are here too.">
|
|
15097
15196
|
${canonical2} <style>${STYLE}</style>
|
|
15098
15197
|
</head>
|
|
15099
15198
|
<body>
|
|
15100
15199
|
<main>
|
|
15101
|
-
<p class="eyebrow"
|
|
15200
|
+
<p class="eyebrow">${escapeHtml(product)}</p>
|
|
15102
15201
|
<h1>Integrate with an agent</h1>
|
|
15103
15202
|
<p class="lede">Cruise is OpenAI-compatible, so integrating it is a change of base URL and
|
|
15104
15203
|
credential \u2014 not a rewrite. Copy the prompt below into the coding agent that already has your
|
|
@@ -15111,7 +15210,7 @@ ${canonical2} <style>${STYLE}</style>
|
|
|
15111
15210
|
<h3>Paste this into your agent, at the root of the repository you are integrating</h3>
|
|
15112
15211
|
${copyButton("prompt")}
|
|
15113
15212
|
</header>
|
|
15114
|
-
<pre class="tall" id="prompt">${escapeHtml(
|
|
15213
|
+
<pre class="tall" id="prompt">${escapeHtml(integrationPrompt(identity))}</pre>
|
|
15115
15214
|
</div>
|
|
15116
15215
|
|
|
15117
15216
|
<h2>Both ways round</h2>
|
|
@@ -15119,9 +15218,7 @@ ${canonical2} <style>${STYLE}</style>
|
|
|
15119
15218
|
<section class="way">
|
|
15120
15219
|
<h3>With an agent</h3>
|
|
15121
15220
|
<ol>
|
|
15122
|
-
<li
|
|
15123
|
-
<code>cru_demo_</code> key that can spend nothing, or ask your BytesBrains contact for a
|
|
15124
|
-
production key \u2014 one per project, and it is shown once.</li>
|
|
15221
|
+
<li>${getKey}</li>
|
|
15125
15222
|
<li>Put it where this repository already keeps secrets, as <code>CRUISE_API_KEY</code>.</li>
|
|
15126
15223
|
<li>Copy the prompt and paste it into your agent at the repository root.</li>
|
|
15127
15224
|
<li>Read the diff it proposes, and the verification output it prints, before merging.</li>
|
|
@@ -15130,7 +15227,7 @@ ${canonical2} <style>${STYLE}</style>
|
|
|
15130
15227
|
<section class="way">
|
|
15131
15228
|
<h3>By hand</h3>
|
|
15132
15229
|
<ol>
|
|
15133
|
-
<li>Point your existing OpenAI client at <code>${
|
|
15230
|
+
<li>Point your existing OpenAI client at <code>${escapeHtml(base)}/v1</code> and give it the
|
|
15134
15231
|
Cruise key. Change nothing else.</li>
|
|
15135
15232
|
<li>Call <code>GET /v1/models</code> and pick ids from what it returns, or use a lane
|
|
15136
15233
|
(<code>bb/summarization</code>) to let Cruise choose per request. The same call is
|
|
@@ -15153,20 +15250,10 @@ ${canonical2} <style>${STYLE}</style>
|
|
|
15153
15250
|
<h3>The one call that proves it</h3>
|
|
15154
15251
|
${copyButton("curl")}
|
|
15155
15252
|
</header>
|
|
15156
|
-
<pre id="curl">${escapeHtml(
|
|
15253
|
+
<pre id="curl">${escapeHtml(curlExample(base))}</pre>
|
|
15157
15254
|
</div>
|
|
15158
15255
|
|
|
15159
|
-
<h2>
|
|
15160
|
-
<p>The demo at <code>${DEMO_BASE}/v1</code> is a complete Cruise that holds no provider
|
|
15161
|
-
credential: every answer is fabricated, every price is zero, and its catalogue carries
|
|
15162
|
-
production's model ids exactly. So <strong>what changes when you go live is the base URL and
|
|
15163
|
-
the key, and nothing else.</strong> On the demo, <code>x-cruise-scenario</code> asks for the
|
|
15164
|
-
failure \u2014 ${SCENARIOS.map((name) => `<code>${name}</code>`).join(", ")} \u2014 so each one is
|
|
15165
|
-
rehearsed on purpose rather than met first in production. Anything else is a <code>400</code>
|
|
15166
|
-
with code <code>invalid_scenario</code>, and on any other deployment the header is checked and
|
|
15167
|
-
then ignored.</p>
|
|
15168
|
-
|
|
15169
|
-
<h2>Headers worth sending, once it works</h2>
|
|
15256
|
+
${rehearse(identity)} <h2>Headers worth sending, once it works</h2>
|
|
15170
15257
|
<p>None of them is required, and each is a decision the platform would otherwise have to guess.</p>
|
|
15171
15258
|
<table>
|
|
15172
15259
|
<thead><tr><th>Header</th><th>What it does</th></tr></thead>
|
|
@@ -15227,7 +15314,7 @@ ${canonical2} <style>${STYLE}</style>
|
|
|
15227
15314
|
<footer>
|
|
15228
15315
|
The full reference is at <a href="/docs">/docs</a>, and the specification it renders at
|
|
15229
15316
|
<a href="/openapi.json">/openapi.json</a> \u2014 fetch that rather than trusting a summary, including
|
|
15230
|
-
this one. Questions, or a key:
|
|
15317
|
+
this one. Questions, or a key: ${identity.operatorUrl ? `<a href="${escapeHtml(identity.operatorUrl)}">${escapeHtml(operator)}</a>` : escapeHtml(operator)}.
|
|
15231
15318
|
</footer>
|
|
15232
15319
|
</main>
|
|
15233
15320
|
<script>${COPY_SCRIPT}<\/script>
|
|
@@ -15283,7 +15370,6 @@ var PRODUCT_OF_STYLE = [
|
|
|
15283
15370
|
"font:500 12px/1.2 ui-sans-serif,system-ui,-apple-system,'Segoe UI',Roboto,sans-serif",
|
|
15284
15371
|
"text-decoration:none"
|
|
15285
15372
|
].join(";");
|
|
15286
|
-
var BB_MARK_STYLE = ["display:block", "height:14px", "width:auto"].join(";");
|
|
15287
15373
|
var SCALAR_CONFIGURATION = JSON.stringify({
|
|
15288
15374
|
customCss: [
|
|
15289
15375
|
/* Sidebar footer: leave the dark-mode toggle, drop "Powered by Scalar". */
|
|
@@ -15292,8 +15378,13 @@ var SCALAR_CONFIGURATION = JSON.stringify({
|
|
|
15292
15378
|
'img[src="/brand/cruise-logo-480.png"]{display:block;width:min(280px,100%);height:auto;border-radius:14px;margin:0 0 1.25rem}'
|
|
15293
15379
|
].join("")
|
|
15294
15380
|
});
|
|
15295
|
-
function docsPage(
|
|
15296
|
-
const canonical2 = canonicalLink(
|
|
15381
|
+
function docsPage(identity = GENERIC_IDENTITY) {
|
|
15382
|
+
const canonical2 = canonicalLink(identity.base ?? void 0, "/docs");
|
|
15383
|
+
const operator = identity.operatorName;
|
|
15384
|
+
const productOf = operator ? identity.operatorUrl ? ` <a href="${escapeAttribute(identity.operatorUrl)}" style="${PRODUCT_OF_STYLE}" rel="noopener noreferrer"><span>A product of ${escapeAttribute(operator)}</span></a>
|
|
15385
|
+
` : ` <span style="${PRODUCT_OF_STYLE}">A product of ${escapeAttribute(operator)}</span>
|
|
15386
|
+
` : "";
|
|
15387
|
+
const productOfText = operator ? ` Cruise is a product of ${escapeAttribute(operator)}.` : "";
|
|
15297
15388
|
return `<!doctype html>
|
|
15298
15389
|
<html lang="en">
|
|
15299
15390
|
<head>
|
|
@@ -15303,14 +15394,10 @@ function docsPage(origin) {
|
|
|
15303
15394
|
${canonical2} <link rel="icon" href="/brand/cruise-mark-64.png" type="image/png">
|
|
15304
15395
|
</head>
|
|
15305
15396
|
<body>
|
|
15306
|
-
<a href="
|
|
15307
|
-
<img src="/brand/logo-dark.png" width="10" height="14" alt="" style="${BB_MARK_STYLE}">
|
|
15308
|
-
<span>A product of BytesBrains</span>
|
|
15309
|
-
</a>
|
|
15310
|
-
<a href="/integrate" style="${PINNED_LINK_STYLE}">Integrate with an agent</a>
|
|
15397
|
+
${productOf} <a href="/integrate" style="${PINNED_LINK_STYLE}">Integrate with an agent</a>
|
|
15311
15398
|
<script id="api-reference" data-url="/openapi.json" data-configuration='${SCALAR_CONFIGURATION}'><\/script>
|
|
15312
15399
|
<script src="${SCALAR_URL}" integrity="${SCALAR_INTEGRITY}" crossorigin="anonymous"><\/script>
|
|
15313
|
-
<noscript><p>The API reference needs JavaScript to render. The specification itself is at <a href="/openapi.json">/openapi.json</a>. To wire a repository up to Cruise, see <a href="/integrate">/integrate</a>.
|
|
15400
|
+
<noscript><p>The API reference needs JavaScript to render. The specification itself is at <a href="/openapi.json">/openapi.json</a>. To wire a repository up to Cruise, see <a href="/integrate">/integrate</a>. ${productOfText}</p></noscript>
|
|
15314
15401
|
</body>
|
|
15315
15402
|
</html>`;
|
|
15316
15403
|
}
|
|
@@ -16373,10 +16460,10 @@ function withIdentityOutage(paths) {
|
|
|
16373
16460
|
);
|
|
16374
16461
|
}
|
|
16375
16462
|
__name(withIdentityOutage, "withIdentityOutage");
|
|
16376
|
-
var collection = /* @__PURE__ */ __name((
|
|
16463
|
+
var collection = /* @__PURE__ */ __name((name2, ref) => ({
|
|
16377
16464
|
type: "object",
|
|
16378
|
-
properties: { [
|
|
16379
|
-
required: [
|
|
16465
|
+
properties: { [name2]: { type: "array", items: { $ref: `#/components/schemas/${ref}` } } },
|
|
16466
|
+
required: [name2]
|
|
16380
16467
|
}), "collection");
|
|
16381
16468
|
var laneId = {
|
|
16382
16469
|
name: "id",
|
|
@@ -16462,7 +16549,7 @@ var controlPlanePaths = {
|
|
|
16462
16549
|
security: bearerFirebase,
|
|
16463
16550
|
summary: "Issue a key \u2014 admin or owner",
|
|
16464
16551
|
description: "The secret is in this response and nowhere else, ever. `models` restricts the key to those ids; a **lane id** means that lane and every member it allocates (#382), while a model id still means only that model \u2014 so a key scoped to `bb/agentic-coding` can call the lane and cannot pin a member by id. A lane request on a key scoped only to member models still allocates from `members \u2229 models`, and a lane with nothing in the intersection is not listed to that key.\n\n**Rate limits are set at issue** (#385): send `rate_limit_per_min` and optionally `account_rate_limit_per_min` (positive integers), the same figures the CLI's `--rate-limit` and `--account-rate-limit` write through `issueKey`. Omit either for no limit on that axis. **On the demo, every key still carries a rate limit** (#328) \u2014 a demo request costs nothing, so a budget bounds nothing there and the deployment applies its ceiling when none was asked, or clamps a higher ask; a request may ask for less and never more. Read both limits back from this response or the listing, and show them beside the key.",
|
|
16465
|
-
requestBody: { required: true, content: { "application/json": { schema: { type: "object", required: ["project"], properties: { project: { type: "string", description: "The project's **id** \u2014 the `project_id` a key listing returns, not the `project` slug beside it. Same resolution as `PUT /admin/budgets/{project}`. They hold the same string for every project seeded so far, so sending the slug works until one does not (#92)." }, name: { type: "string" }, models: { type: "array", items: { type: "string", minLength: 1 }, minItems: 1, description: 'Model or **lane** ids this key may call, or **omit** for a key that may call any \u2014 omission is the only way to ask for that. A lane id means that lane and every member it allocates (#382); a model id means only that model. **An empty entry is refused, 400** (#251): `["", "openai/gpt-4o"]` is a form with a blank row, and issuing the half that was filled in is a key with a different scope from the one the person chose. **An empty array is refused too**, because two clients have read it two ways \u2014 as a restriction to nothing, and as no restriction \u2014 and a key issued on a value the sender and the receiver disagree about is the failure this rule exists to stop. Entries are trimmed and stored once each.' }, classes: { type: "array", items: { type: "string", minLength: 1 }, minItems: 1, description: "Traffic classes this key may declare, or omit for a key that may declare any. An empty entry or an empty array is refused, as for `models`. Deliberately not an enum: the taxonomy is open (#17), and the gate is a shape \u2014 lowercase, digits and hyphens, 32 characters \u2014 not a fixed list. `scheduled`, `interactive` and `agentic` are the three in use." }, cache_pool: { type: "string", enum: ["project", "tenant", "platform"], description: "Which pool of cached answers this key shares; omit for `project`, which is the default and the only pool an unmarked key touches. `tenant` shares with every marked key in this tenant \u2014 the widening to use for scheduled pipelines, eval preparation and internal tooling, where the traffic carries no end-user content. A key reads its own pool and every narrower one and writes only its own. **This is not something a caller can ask for per request**, deliberately: a traffic class is a label the caller chooses, and a caller widening its own cache pool is the mistake that gate exists to prevent \u2014 so it is decided once, by whoever issues the key, about traffic they have read. `platform` is the pool every project
|
|
16552
|
+
requestBody: { required: true, content: { "application/json": { schema: { type: "object", required: ["project"], properties: { project: { type: "string", description: "The project's **id** \u2014 the `project_id` a key listing returns, not the `project` slug beside it. Same resolution as `PUT /admin/budgets/{project}`. They hold the same string for every project seeded so far, so sending the slug works until one does not (#92)." }, name: { type: "string" }, models: { type: "array", items: { type: "string", minLength: 1 }, minItems: 1, description: 'Model or **lane** ids this key may call, or **omit** for a key that may call any \u2014 omission is the only way to ask for that. A lane id means that lane and every member it allocates (#382); a model id means only that model. **An empty entry is refused, 400** (#251): `["", "openai/gpt-4o"]` is a form with a blank row, and issuing the half that was filled in is a key with a different scope from the one the person chose. **An empty array is refused too**, because two clients have read it two ways \u2014 as a restriction to nothing, and as no restriction \u2014 and a key issued on a value the sender and the receiver disagree about is the failure this rule exists to stop. Entries are trimmed and stored once each.' }, classes: { type: "array", items: { type: "string", minLength: 1 }, minItems: 1, description: "Traffic classes this key may declare, or omit for a key that may declare any. An empty entry or an empty array is refused, as for `models`. Deliberately not an enum: the taxonomy is open (#17), and the gate is a shape \u2014 lowercase, digits and hyphens, 32 characters \u2014 not a fixed list. `scheduled`, `interactive` and `agentic` are the three in use." }, cache_pool: { type: "string", enum: ["project", "tenant", "platform"], description: "Which pool of cached answers this key shares; omit for `project`, which is the default and the only pool an unmarked key touches. `tenant` shares with every marked key in this tenant \u2014 the widening to use for scheduled pipelines, eval preparation and internal tooling, where the traffic carries no end-user content. A key reads its own pool and every narrower one and writes only its own. **This is not something a caller can ask for per request**, deliberately: a traffic class is a label the caller chooses, and a caller widening its own cache pool is the mistake that gate exists to prevent \u2014 so it is decided once, by whoever issues the key, about traffic they have read. `platform` is the pool every project the operator runs reads, and is refused with `not_operator` for any other tenant. It can be narrowed by issuing a new key; widening is a new key too." }, rate_limit_per_min: { type: ["integer", "null"], minimum: 1, description: "Requests per minute this key may send. Omit or `null` for no per-key limit. On the demo, omitted becomes the deployment ceiling and a higher ask is clamped to it (#328, #385)." }, account_rate_limit_per_min: { type: ["integer", "null"], minimum: 1, description: "Requests per minute per end-user account behind this key. Omit or `null` for unlimited (#385)." } } }, example: { project: "my-app", name: "my-app server", rate_limit_per_min: 60 } } } },
|
|
16466
16553
|
responses: { 201: { description: "The key, for the only time it is ever returned.", content: { "application/json": { schema: { $ref: "#/components/schemas/KeyIssued" } } } }, ...errorResponses(400, 401, 403, 404) }
|
|
16467
16554
|
}
|
|
16468
16555
|
},
|
|
@@ -16490,7 +16577,7 @@ var controlPlanePaths = {
|
|
|
16490
16577
|
tags: ["Catalog"],
|
|
16491
16578
|
security: bearerFirebase,
|
|
16492
16579
|
summary: "Which hosts we can reach \u2014 owner or admin of the operating tenant",
|
|
16493
|
-
description: "**The question `/admin/models` cannot answer.** A lab with no credential has models that report `blocked_by: unmeasured` \u2014 true, and not the cause: conformance has not run because there is no key to run it against. This says which. `credential` is `held` | `missing` | `not_required`, three states and never two, and `not_required` is a real answer rather than a hedge \u2014 Workers AI bills to our Cloudflare account. Presence only: no prefix, no length, no hash, no *set at*.\n\nGated where nothing else on this plane is. Every other `/admin` read answers about the caller's own tenant; this one is about the platform, so it needs both an `owner`/`admin` role **and** membership of the tenant that operates Cruise. A customer who is `owner` of their own workspace is refused with `not_operator`, because which labs
|
|
16580
|
+
description: "**The question `/admin/models` cannot answer.** A lab with no credential has models that report `blocked_by: unmeasured` \u2014 true, and not the cause: conformance has not run because there is no key to run it against. This says which. `credential` is `held` | `missing` | `not_required`, three states and never two, and `not_required` is a real answer rather than a hedge \u2014 Workers AI bills to our Cloudflare account. Presence only: no prefix, no length, no hash, no *set at*.\n\nGated where nothing else on this plane is. Every other `/admin` read answers about the caller's own tenant; this one is about the platform, so it needs both an `owner`/`admin` role **and** membership of the tenant that operates Cruise. A customer who is `owner` of their own workspace is refused with `not_operator`, because which labs the operator holds accounts with is commercial posture rather than product state. `GET /admin/me` is where a caller checks which role they hold.",
|
|
16494
16581
|
responses: { 200: { description: "`{ upstreams: Upstream[] }`, by id, disabled ones included.", content: { "application/json": { schema: collection("upstreams", "Upstream"), example: { upstreams: [{ id: "a-lab-we-hold-a-key-for", enabled: true, credential: "held" }, { id: "a-lab-we-do-not", enabled: true, credential: "missing" }, { id: "a-lab-billed-to-our-own-account", enabled: true, credential: "not_required" }] } } } }, ...errorResponses(401, 403) }
|
|
16495
16582
|
}
|
|
16496
16583
|
},
|
|
@@ -17366,7 +17453,7 @@ var dataPlanePaths = {
|
|
|
17366
17453
|
object: "list",
|
|
17367
17454
|
data: [
|
|
17368
17455
|
{ id: "deepseek/deepseek-v4-flash", object: "model", created: 1787e6, owned_by: "deepseek", "x-cruise": { modality: "chat", tools: true, parallel_tool_calls: true, tool_choice_forced: true, web_search: null, streaming: true, usage_reported: true, vision: null, json_schema: null, max_context: 1e6, max_output: 384e3, output_limit: "stated", data_retention: null, measured_at: "2026-08-21", measurement_source: "conformance", pricing: { input_micros_per_mtok: 22e4, output_micros_per_mtok: 66e4, cached_input_micros_per_mtok: 7e3, effective_from: "2026-08-16", source: "https://api-docs.deepseek.com/quick_start/pricing", variants: [{ prompt_tokens_from: 0, peak_utc: "mon-fri@01:00-04:00,mon-fri@06:00-10:00", input_micros_per_mtok: 44e4, output_micros_per_mtok: 132e4, cached_input_micros_per_mtok: 14e3 }], components: [] } } },
|
|
17369
|
-
{ id: "bb/extraction", object: "model", created: 1787349683, owned_by: "
|
|
17456
|
+
{ id: "bb/extraction", object: "model", created: 1787349683, owned_by: "cruise", "x-cruise": { lane: true, job: "extraction", description: "Classification and extraction across many rows.", members: ["deepseek/deepseek-v4-flash", "mistral/mistral-small-latest"], selection: "cheap", modality: "chat", tools: true, parallel_tool_calls: null, tool_choice_forced: null, web_search: null, streaming: true, usage_reported: true, vision: null, json_schema: null, max_context: 262144, max_output: null, output_limit: null, any_member: { tools: true, parallel_tool_calls: true, tool_choice_forced: true, web_search: null, streaming: true, vision: null, json_schema: null }, data_retention: null, measured_at: null, measurement_source: null, pricing: { input_micros_per_mtok: 44e4, output_micros_per_mtok: 132e4, cached_input_micros_per_mtok: 14e3, effective_from: "2026-08-21", source: "maximum across members, variants included", variants: [], components: [] } } }
|
|
17370
17457
|
]
|
|
17371
17458
|
}
|
|
17372
17459
|
}
|
|
@@ -17407,7 +17494,7 @@ ${CHAT_COMPRESS_DESCRIPTION}
|
|
|
17407
17494
|
|
|
17408
17495
|
Optional request headers: \`x-cruise-class\` tags the request's traffic class (\`scheduled\`, \`interactive\`, \`agentic\`) for the ledger; \`x-cruise-lane\` tags a *pinned* request with the job it is doing, for the ledger's lane dimension \u2014 it does not allocate; \`x-cruise-selection\` overrides a lane's selection policy for this request (\`cheap\`, \`random\`, \`weighted\`, \`graduated\`; anything else is 400 \`invalid_selection\`), and is accepted and ignored on a pinned model. Whatever the policy, it chooses only among members that passed every gate \u2014 a lane requiring \`no-training-on-data\` cannot draw a member that trains. Under \`random\`, \`weighted\` or \`graduated\` the budget cap holds and the per-request spend is no longer predictable; the ledger records which policy ran. \`x-cruise-session\` pins that draw for the life of one agent run (1\u2013128 characters of letters, digits, \`._:-\`; anything else is 400 \`invalid_session\`): the first request allocates normally and answers \`x-cruise-affinity: new\`; later requests with the same key keep the same member (\`pinned\`) provided it still passes this request's hard gates, and a gate or headroom drop redraws and says \`rebound\`. A mid-request 429 still walks the chain for that turn and keeps the pin. TTL is one hour, refreshed per request; accepted and ignored on a pinned model. Affinity makes a *run* predictable and a run-to-run distribution lumpier \u2014 a pinned expensive member costs a whole run \u2014 and the cap still holds. **A session is also a run's spend** (#651): it is counted for the run's whole life, on a pinned model as well, and a project's per-run cap (\`session_hard_micros\` on its budget) refuses the run's next request with 429 \`insufficient_quota\` \`session_budget_exhausted\`, while the rest of the project keeps serving. No \`retry-after\`, since only a new session or a higher cap changes it. \`x-cruise-session-budget\` (USD, e.g. \`0.50\`; malformed is 400 \`invalid_session_budget\`) narrows that cap for one request and never widens it. A malformed value is a 400 with or without a session; a valid one without a session is ignored. \`x-cruise-route-hint\` (1\u20132048 characters; empty or longer is 400 \`invalid_route_hint\`) tells a lane's router what the request is \u2014 an issue type, an intent, a diff summary \u2014 and is the only thing a lane with \`router_input: hint\` sends it; ignored where the lane has no router. \`x-cruise-cache\` is comma-separated directives, \`scope=model|lane|off\` and \`max-age=<seconds>\`, each at most once (\`scope=lane, max-age=3600\`); anything else is 400 \`invalid_cache_header\`. It **only narrows**: a lane's own cache setting is the ceiling, and the header can shorten the age, narrow the scope or switch the cache off for one request, never widen it. \`max-age\` is what makes a request cacheable at all: with no lane setting and no header, nothing is stored and nothing is served. \`scope=lane\` serves an answer from any member the lane ranks at or above the one that would have answered, and narrows to \`model\` wherever the lane's own \`cache_scope\` is \`model\` \u2014 the header cannot widen it. \`x-cruise-compress: off\` opts one request out of tool-output compression on a project or lane that has it switched on (above); \`off\` is the only value, and anything else \u2014 \`on\` included \u2014 is 400 \`invalid_compress_header\`, because only the project or the lane can switch it on.
|
|
17409
17496
|
|
|
17410
|
-
**On the demo, \`x-cruise-scenario\` asks for the failure.** \`cruise-demo\` answers from a fabricated upstream that holds no provider credential, and this header names what that upstream should do for this one request, so an integration can rehearse each failure deliberately rather than meet it first in production. One of: ${SCENARIOS.map((
|
|
17497
|
+
**On the demo, \`x-cruise-scenario\` asks for the failure.** \`cruise-demo\` answers from a fabricated upstream that holds no provider credential, and this header names what that upstream should do for this one request, so an integration can rehearse each failure deliberately rather than meet it first in production. One of: ${SCENARIOS.map((name2) => `\`${name2}\``).join(", ")}; anything else is 400 \`invalid_scenario\`. \`refusal_200\` is a well-formed 200 with \`message.refusal\` set and no content; \`no_usage\` a 200 whose body reports no usage, billed at the reservation; \`truncated_stream\` a stream that ends without a usage frame, and the same absence unary when \`stream\` is not \`true\`; \`tool_call_no_content\` a 200 with three \`tool_calls\` and empty content; \`reasoning_exhausted\` a 200 whose every completion token was reasoning, carrying \`x-cruise-warning: reasoning_exhausted\`; \`upstream_429\` and \`upstream_5xx\` the provider's own status passed through with \`x-cruise-upstream-status\` (the 429 carries \`retry-after\`); \`budget_exhausted\` Cruise's own 429 \`insufficient_quota\` \`budget_exhausted\`, from the real budget gate, without spending anything. **Every attempt in the chain plays it**, fallbacks included, so what comes back is what Cruise answers once the chain is spent. A request under rehearsal is not served from the cache and not written to it, and \`x-cruise-cache\` says \`off\`. **A no-op on every other deployment**: the value is still checked, and a valid one does nothing, so a rehearsal header left in client code does not break the first live call.`,
|
|
17411
17498
|
requestBody: {
|
|
17412
17499
|
required: true,
|
|
17413
17500
|
content: {
|
|
@@ -17643,7 +17730,7 @@ var messagesPaths = {
|
|
|
17643
17730
|
tags: ["Data plane"],
|
|
17644
17731
|
security: bearerKey,
|
|
17645
17732
|
summary: "Anthropic Messages, for Claude Code",
|
|
17646
|
-
description: `Anthropic's Messages request and response, so **Claude Code** can use Cruise as its gateway: \`ANTHROPIC_BASE_URL=https
|
|
17733
|
+
description: `Anthropic's Messages request and response, so **Claude Code** can use Cruise as its gateway: \`ANTHROPIC_BASE_URL=https://<your Cruise deployment>\` and \`ANTHROPIC_AUTH_TOKEN=cru_live_\u2026\` (sent as \`Authorization: Bearer\`), or the key as \`x-api-key\`. Name the model as Cruise names it \u2014 a pinned id such as \`anthropic/claude-sonnet-5\`, or a lane such as \`bb/agentic-coding\`, served by whichever member the lane allocates.
|
|
17647
17734
|
|
|
17648
17735
|
**Translated onto the chat route, not a second data plane.** The body becomes a chat completion request and runs through \`/v1/chat/completions\`'s gates in the same code \u2014 key, scope, class, rate limits, measurement, the budget reservation, the wallet \u2014 and lands in the same ledger. Everything that route's description says about budgets and refusals holds here; a refusal comes back in Anthropic's error shape with Cruise's \`code\` kept beside \`type\`.
|
|
17649
17736
|
|
|
@@ -17858,7 +17945,7 @@ var mcpPaths = {
|
|
|
17858
17945
|
};
|
|
17859
17946
|
|
|
17860
17947
|
// src/openapi.ts
|
|
17861
|
-
function openapi() {
|
|
17948
|
+
function openapi(identity = GENERIC_IDENTITY) {
|
|
17862
17949
|
return {
|
|
17863
17950
|
openapi: "3.1.0",
|
|
17864
17951
|
info: {
|
|
@@ -17879,7 +17966,7 @@ Cruise sits in front of model providers. A project points any OpenAI-compatible
|
|
|
17879
17966
|
|
|
17880
17967
|
**The data plane** is \`/v1\`: called by a project's server, authenticated by a virtual key (\`Authorization: Bearer cru_live_\u2026\`). Any OpenAI client works unmodified; model ids are Cruise's (\`deepseek/deepseek-v4-flash\`, \`bb/extraction\`), not the provider's.
|
|
17881
17968
|
|
|
17882
|
-
**The control plane** is \`/admin\`: called by a person or a dashboard, authenticated by a **Firebase ID token** from the
|
|
17969
|
+
**The control plane** is \`/admin\`: called by a person or a dashboard, authenticated by a **Firebase ID token** from the deployment's Firebase identity project \u2014 the one its dashboard signs in with. The token proves who someone is; a membership row then resolves them to a **tenant** and a **role**. A valid token with no membership is refused with code \`no_membership\` and a message carrying the uid an administrator needs to grant one. Every \`/admin\` route is scoped to the caller's tenant; another tenant's objects are **absent, not forbidden** \u2014 a 404, never a 403 \u2014 so no route can confirm what exists elsewhere.
|
|
17883
17970
|
|
|
17884
17971
|
**Every \`/admin\` response carries \`Server-Timing: cruise;dur=N\`** \u2014 the milliseconds Cruise spent on that request, and the same figure it records for its own percentiles, so the two cannot disagree. It is present on refusals as well as successes, and on every response whatever the origin.
|
|
17885
17972
|
|
|
@@ -17928,10 +18015,9 @@ Three things this list used to name have since shipped and are documented above,
|
|
|
17928
18015
|
## Adopting it
|
|
17929
18016
|
|
|
17930
18017
|
\`GET /integrate\` is the short answer to "what do I change in my repository": a prompt to hand to a coding agent, and the same steps written out for a person. It is linked from \`/docs\` and needs no key.`,
|
|
17931
|
-
//
|
|
17932
|
-
//
|
|
17933
|
-
|
|
17934
|
-
contact: { name: "BytesBrains", url: LANDING }
|
|
18018
|
+
// The operator, when it said who it is: configuration, never the
|
|
18019
|
+
// request's Host, so it cannot be poisoned the way a relative `/v1` would.
|
|
18020
|
+
...identity.operatorName ? { contact: { name: identity.operatorName, ...identity.operatorUrl ? { url: identity.operatorUrl } : {} } } : {}
|
|
17935
18021
|
},
|
|
17936
18022
|
servers: [{ url: "/", description: "Wherever this document was served from." }],
|
|
17937
18023
|
tags: [
|
|
@@ -17959,7 +18045,7 @@ Three things this list used to name have since shipped and are documented above,
|
|
|
17959
18045
|
${KEY_PATTERN}
|
|
17960
18046
|
|
|
17961
18047
|
**The head is fixed width too.** Every environment's head is nine characters \u2014 \`cru_live_\`, \`cru_test_\`, \`cru_demo_\` \u2014 plus **8** more is the whole non-secret prefix, so 17 characters, and 16 for \`cru_svc_\` \u2014 leaving 32 characters of secret. So a prefix on its own can never match the rule above, which is what makes a prefix publishable at all. That is the half this API returns, and the half that is safe in a log line, an issue or a chat message; the other 32 characters exist in the issue response and nowhere else.` },
|
|
17962
|
-
firebase: { type: "http", scheme: "bearer", bearerFormat: "JWT", description: "A Firebase ID token from the
|
|
18048
|
+
firebase: { type: "http", scheme: "bearer", bearerFormat: "JWT", description: "A Firebase ID token from the deployment's Firebase identity project, obtained by signing in to its dashboard." }
|
|
17963
18049
|
},
|
|
17964
18050
|
schemas: {
|
|
17965
18051
|
Error: ERROR,
|
|
@@ -18897,11 +18983,11 @@ async function collectResults(env, projectId, jobId, polled, fetcher = fetch) {
|
|
|
18897
18983
|
const client = providerClient(env, fetcher);
|
|
18898
18984
|
const outputText = polled.outputFileId === null ? "" : await client.content(polled.outputFileId);
|
|
18899
18985
|
const errorText = polled.errorFileId === null ? "" : await client.content(polled.errorFileId);
|
|
18900
|
-
const keep = /* @__PURE__ */ __name(async (column, text,
|
|
18986
|
+
const keep = /* @__PURE__ */ __name(async (column, text, name2) => {
|
|
18901
18987
|
if (current[column] !== null || text === "") return;
|
|
18902
18988
|
const id = await resultFileId(jobId, column);
|
|
18903
18989
|
if (await readBatchFile(env.DB, projectId, id) === null) {
|
|
18904
|
-
await storeBatchFile(env, projectId, "batch_output",
|
|
18990
|
+
await storeBatchFile(env, projectId, "batch_output", name2, new TextEncoder().encode(text).buffer, id);
|
|
18905
18991
|
}
|
|
18906
18992
|
await env.DB.prepare(`UPDATE jobs SET ${column} = ?2 WHERE id = ?1 AND ${column} IS NULL`).bind(jobId, id).run();
|
|
18907
18993
|
}, "keep");
|
|
@@ -19046,14 +19132,12 @@ __name(runJob, "runJob");
|
|
|
19046
19132
|
import cruiseLogo240 from "./2c39de526314484775fdfc503fac50c437d21e4e-cruise-logo-240.png";
|
|
19047
19133
|
import cruiseLogo480 from "./63fb63e2d8ae6d8b68228768ef6c91ab8f0c0100-cruise-logo-480.png";
|
|
19048
19134
|
import cruiseMark64 from "./284906b51fc0a3173ea7d301234907f30e834f54-cruise-mark-64.png";
|
|
19049
|
-
import logoDark from "./b23bfbc792e8710d3b74284a0a1b8ab044c18897-logo-dark.png";
|
|
19050
19135
|
var PNG = "image/png";
|
|
19051
19136
|
var CACHE = "public, max-age=86400, immutable";
|
|
19052
19137
|
var FILES = {
|
|
19053
19138
|
"/brand/cruise-logo-240.png": { body: cruiseLogo240, type: PNG },
|
|
19054
19139
|
"/brand/cruise-logo-480.png": { body: cruiseLogo480, type: PNG },
|
|
19055
|
-
"/brand/cruise-mark-64.png": { body: cruiseMark64, type: PNG }
|
|
19056
|
-
"/brand/logo-dark.png": { body: logoDark, type: PNG }
|
|
19140
|
+
"/brand/cruise-mark-64.png": { body: cruiseMark64, type: PNG }
|
|
19057
19141
|
};
|
|
19058
19142
|
function brandResponse(pathname) {
|
|
19059
19143
|
const file = FILES[pathname];
|
|
@@ -19065,24 +19149,28 @@ function brandResponse(pathname) {
|
|
|
19065
19149
|
__name(brandResponse, "brandResponse");
|
|
19066
19150
|
|
|
19067
19151
|
// src/public-discovery.ts
|
|
19068
|
-
var GOOGLE_VERIFICATION_PATH = "/google7de809f46a23bb69.html";
|
|
19069
|
-
var GOOGLE_VERIFICATION_BODY = "google-site-verification: google7de809f46a23bb69.html";
|
|
19070
|
-
var PRODUCTION_ORIGIN = "https://cruise.bytesbrains.net";
|
|
19071
19152
|
var LLMS_PATH = "/llms.txt";
|
|
19072
|
-
|
|
19153
|
+
function llmsBody(identity, base) {
|
|
19154
|
+
return `# ${productName(identity)}
|
|
19073
19155
|
|
|
19074
19156
|
> Cruise is an OpenAI-compatible AI gateway with project keys, budgets, usage accounting, and model-selection lanes.
|
|
19075
19157
|
|
|
19076
19158
|
## Documentation
|
|
19077
19159
|
|
|
19078
|
-
- [API reference](${
|
|
19079
|
-
- [Integration guide](${
|
|
19080
|
-
- [OpenAPI specification](${
|
|
19160
|
+
- [API reference](${base}/docs): Human-readable reference for the public Cruise API.
|
|
19161
|
+
- [Integration guide](${base}/integrate): Steps and a prompt for connecting an existing repository to Cruise.
|
|
19162
|
+
- [OpenAPI specification](${base}/openapi.json): Machine-readable API contract; use it as the source of truth for routes, parameters, and schemas.
|
|
19081
19163
|
|
|
19082
19164
|
## Guidance
|
|
19083
19165
|
|
|
19084
19166
|
Use the API reference and OpenAPI specification together. The integration guide explains deployment-specific base URLs, authentication, model discovery, response headers, errors, streaming, caching, selection, sessions, and verification. Only the documentation URLs above are public discovery surfaces; API, admin, payment, tenant, and operational routes are not indexable documentation.
|
|
19085
19167
|
`;
|
|
19168
|
+
}
|
|
19169
|
+
__name(llmsBody, "llmsBody");
|
|
19170
|
+
function googleVerificationPath(token) {
|
|
19171
|
+
return `/${token}.html`;
|
|
19172
|
+
}
|
|
19173
|
+
__name(googleVerificationPath, "googleVerificationPath");
|
|
19086
19174
|
var DOCUMENT_PATHS = ["/docs", "/integrate"];
|
|
19087
19175
|
function methodNotAllowed(method) {
|
|
19088
19176
|
return errorResponse(405, "invalid_request_error", `Method ${method} not allowed.`);
|
|
@@ -19095,14 +19183,16 @@ function publicText(request, body, contentType) {
|
|
|
19095
19183
|
});
|
|
19096
19184
|
}
|
|
19097
19185
|
__name(publicText, "publicText");
|
|
19098
|
-
function publicDiscoveryResponse(request) {
|
|
19099
|
-
const { origin, pathname } = new URL(request.url);
|
|
19100
|
-
|
|
19101
|
-
|
|
19102
|
-
|
|
19186
|
+
function publicDiscoveryResponse(request, identity) {
|
|
19187
|
+
const { origin: origin2, pathname } = new URL(request.url);
|
|
19188
|
+
const token = identity.googleSiteVerification;
|
|
19189
|
+
if (token && pathname === googleVerificationPath(token)) {
|
|
19190
|
+
return publicText(request, `google-site-verification: ${token}.html`, "text/html; charset=UTF-8");
|
|
19191
|
+
}
|
|
19192
|
+
const base = identity.base;
|
|
19193
|
+
if (!base || origin2 !== base) return null;
|
|
19103
19194
|
if (pathname === "/sitemap.xml") {
|
|
19104
|
-
|
|
19105
|
-
const urls = DOCUMENT_PATHS.map((path) => ` <url><loc>${PRODUCTION_ORIGIN}${path}</loc></url>`).join("\n");
|
|
19195
|
+
const urls = DOCUMENT_PATHS.map((path) => ` <url><loc>${base}${path}</loc></url>`).join("\n");
|
|
19106
19196
|
const body = `<?xml version="1.0" encoding="UTF-8"?>
|
|
19107
19197
|
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
19108
19198
|
${urls}
|
|
@@ -19111,15 +19201,13 @@ ${urls}
|
|
|
19111
19201
|
return publicText(request, body, "application/xml; charset=UTF-8");
|
|
19112
19202
|
}
|
|
19113
19203
|
if (pathname === "/robots.txt") {
|
|
19114
|
-
if (origin !== PRODUCTION_ORIGIN) return null;
|
|
19115
19204
|
return publicText(request, `User-agent: *
|
|
19116
19205
|
Allow: /
|
|
19117
|
-
Sitemap: ${
|
|
19206
|
+
Sitemap: ${base}/sitemap.xml
|
|
19118
19207
|
`, "text/plain; charset=UTF-8");
|
|
19119
19208
|
}
|
|
19120
19209
|
if (pathname === LLMS_PATH) {
|
|
19121
|
-
|
|
19122
|
-
return publicText(request, LLMS_BODY, "text/plain; charset=UTF-8");
|
|
19210
|
+
return publicText(request, llmsBody(identity, base), "text/plain; charset=UTF-8");
|
|
19123
19211
|
}
|
|
19124
19212
|
return null;
|
|
19125
19213
|
}
|
|
@@ -19146,10 +19234,10 @@ function getSentryCarrier(carrier) {
|
|
|
19146
19234
|
return __SENTRY__[SDK_VERSION] = __SENTRY__[SDK_VERSION] || {};
|
|
19147
19235
|
}
|
|
19148
19236
|
__name(getSentryCarrier, "getSentryCarrier");
|
|
19149
|
-
function getGlobalSingleton(
|
|
19237
|
+
function getGlobalSingleton(name2, creator, obj = GLOBAL_OBJ) {
|
|
19150
19238
|
const __SENTRY__ = obj.__SENTRY__ = obj.__SENTRY__ || {};
|
|
19151
19239
|
const carrier = __SENTRY__[SDK_VERSION] = __SENTRY__[SDK_VERSION] || {};
|
|
19152
|
-
return carrier[
|
|
19240
|
+
return carrier[name2] || (carrier[name2] = creator());
|
|
19153
19241
|
}
|
|
19154
19242
|
__name(getGlobalSingleton, "getGlobalSingleton");
|
|
19155
19243
|
|
|
@@ -19466,11 +19554,11 @@ function isRequest(request) {
|
|
|
19466
19554
|
__name(isRequest, "isRequest");
|
|
19467
19555
|
|
|
19468
19556
|
// node_modules/@sentry/core/build/esm/utils/object.js
|
|
19469
|
-
function fill(source,
|
|
19470
|
-
if (!(
|
|
19557
|
+
function fill(source, name2, replacementFactory) {
|
|
19558
|
+
if (!(name2 in source)) {
|
|
19471
19559
|
return;
|
|
19472
19560
|
}
|
|
19473
|
-
const original = source[
|
|
19561
|
+
const original = source[name2];
|
|
19474
19562
|
if (typeof original !== "function") {
|
|
19475
19563
|
return;
|
|
19476
19564
|
}
|
|
@@ -19479,22 +19567,22 @@ function fill(source, name, replacementFactory) {
|
|
|
19479
19567
|
markFunctionWrapped(wrapped, original);
|
|
19480
19568
|
}
|
|
19481
19569
|
try {
|
|
19482
|
-
source[
|
|
19570
|
+
source[name2] = wrapped;
|
|
19483
19571
|
} catch {
|
|
19484
|
-
DEBUG_BUILD && debug.log(`Failed to replace method "${
|
|
19572
|
+
DEBUG_BUILD && debug.log(`Failed to replace method "${name2}" in object`, source);
|
|
19485
19573
|
}
|
|
19486
19574
|
}
|
|
19487
19575
|
__name(fill, "fill");
|
|
19488
|
-
function addNonEnumerableProperty(obj,
|
|
19576
|
+
function addNonEnumerableProperty(obj, name2, value) {
|
|
19489
19577
|
try {
|
|
19490
|
-
Object.defineProperty(obj,
|
|
19578
|
+
Object.defineProperty(obj, name2, {
|
|
19491
19579
|
// enumerable: false, // the default, so we can save on bundle size by not explicitly setting it
|
|
19492
19580
|
value,
|
|
19493
19581
|
writable: true,
|
|
19494
19582
|
configurable: true
|
|
19495
19583
|
});
|
|
19496
19584
|
} catch {
|
|
19497
|
-
DEBUG_BUILD && debug.log(`Failed to add non-enumerable property "${String(
|
|
19585
|
+
DEBUG_BUILD && debug.log(`Failed to add non-enumerable property "${String(name2)}" to object`, obj);
|
|
19498
19586
|
}
|
|
19499
19587
|
}
|
|
19500
19588
|
__name(addNonEnumerableProperty, "addNonEnumerableProperty");
|
|
@@ -20277,8 +20365,8 @@ var Scope = class _Scope {
|
|
|
20277
20365
|
* By default, the SDK updates the scope's transaction name automatically on sensible
|
|
20278
20366
|
* occasions, such as a page navigation or when handling a new request on the server.
|
|
20279
20367
|
*/
|
|
20280
|
-
setTransactionName(
|
|
20281
|
-
this._transactionName =
|
|
20368
|
+
setTransactionName(name2) {
|
|
20369
|
+
this._transactionName = name2;
|
|
20282
20370
|
this._notifyScopeListeners();
|
|
20283
20371
|
return this;
|
|
20284
20372
|
}
|
|
@@ -21335,7 +21423,7 @@ var TRACE_FLAG_SAMPLED = 1;
|
|
|
21335
21423
|
var hasShownSpanDropWarning = false;
|
|
21336
21424
|
function spanToTransactionTraceContext(span) {
|
|
21337
21425
|
const { spanId: span_id, traceId: trace_id } = span.spanContext();
|
|
21338
|
-
const { data, op, parent_span_id, status, origin, links } = spanToJSON(span);
|
|
21426
|
+
const { data, op, parent_span_id, status, origin: origin2, links } = spanToJSON(span);
|
|
21339
21427
|
return {
|
|
21340
21428
|
parent_span_id,
|
|
21341
21429
|
span_id,
|
|
@@ -21343,7 +21431,7 @@ function spanToTransactionTraceContext(span) {
|
|
|
21343
21431
|
data,
|
|
21344
21432
|
op,
|
|
21345
21433
|
status,
|
|
21346
|
-
origin,
|
|
21434
|
+
origin: origin2,
|
|
21347
21435
|
links
|
|
21348
21436
|
};
|
|
21349
21437
|
}
|
|
@@ -21423,12 +21511,12 @@ function spanToJSON(span) {
|
|
|
21423
21511
|
}
|
|
21424
21512
|
const { spanId: span_id, traceId: trace_id } = span.spanContext();
|
|
21425
21513
|
if (spanIsOpenTelemetrySdkTraceBaseSpan(span)) {
|
|
21426
|
-
const { attributes, startTime, name, endTime, status, links } = span;
|
|
21514
|
+
const { attributes, startTime, name: name2, endTime, status, links } = span;
|
|
21427
21515
|
return {
|
|
21428
21516
|
span_id,
|
|
21429
21517
|
trace_id,
|
|
21430
21518
|
data: attributes,
|
|
21431
|
-
description:
|
|
21519
|
+
description: name2,
|
|
21432
21520
|
parent_span_id: getOtelParentSpanId(span),
|
|
21433
21521
|
start_timestamp: spanTimeInputToSeconds(startTime),
|
|
21434
21522
|
// This is [0,0] by default in OTEL, in which case we want to interpret this as no end time
|
|
@@ -21453,9 +21541,9 @@ function spanToStreamedSpanJSON(span) {
|
|
|
21453
21541
|
}
|
|
21454
21542
|
const { spanId: span_id, traceId: trace_id } = span.spanContext();
|
|
21455
21543
|
if (spanIsOpenTelemetrySdkTraceBaseSpan(span)) {
|
|
21456
|
-
const { attributes, startTime, name, endTime, status, links } = span;
|
|
21544
|
+
const { attributes, startTime, name: name2, endTime, status, links } = span;
|
|
21457
21545
|
return {
|
|
21458
|
-
name,
|
|
21546
|
+
name: name2,
|
|
21459
21547
|
span_id,
|
|
21460
21548
|
trace_id,
|
|
21461
21549
|
parent_span_id: getOtelParentSpanId(span),
|
|
@@ -21590,11 +21678,11 @@ function showSpanDropWarning() {
|
|
|
21590
21678
|
}
|
|
21591
21679
|
}
|
|
21592
21680
|
__name(showSpanDropWarning, "showSpanDropWarning");
|
|
21593
|
-
function updateSpanName(span,
|
|
21594
|
-
span.updateName(
|
|
21681
|
+
function updateSpanName(span, name2) {
|
|
21682
|
+
span.updateName(name2);
|
|
21595
21683
|
span.setAttributes({
|
|
21596
21684
|
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: "custom",
|
|
21597
|
-
[SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME]:
|
|
21685
|
+
[SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME]: name2
|
|
21598
21686
|
});
|
|
21599
21687
|
}
|
|
21600
21688
|
__name(updateSpanName, "updateSpanName");
|
|
@@ -21811,9 +21899,9 @@ function getDynamicSamplingContextFromSpan(span) {
|
|
|
21811
21899
|
}
|
|
21812
21900
|
const dsc = getDynamicSamplingContextFromClient(span.spanContext().traceId, client);
|
|
21813
21901
|
const source = rootSpanAttributes[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE] ?? rootSpanAttributes["sentry.segment.name.source"];
|
|
21814
|
-
const
|
|
21815
|
-
if (source !== "url" &&
|
|
21816
|
-
dsc.transaction =
|
|
21902
|
+
const name2 = rootSpanJson.description;
|
|
21903
|
+
if (source !== "url" && name2) {
|
|
21904
|
+
dsc.transaction = name2;
|
|
21817
21905
|
}
|
|
21818
21906
|
if (hasSpansEnabled()) {
|
|
21819
21907
|
dsc.sampled = String(spanIsSampled(rootSpan));
|
|
@@ -21953,8 +22041,8 @@ function getSdkMetadataForEnvelopeHeader(metadataOrEvent) {
|
|
|
21953
22041
|
if (!metadataOrEvent?.sdk) {
|
|
21954
22042
|
return;
|
|
21955
22043
|
}
|
|
21956
|
-
const { name, version } = metadataOrEvent.sdk;
|
|
21957
|
-
return { name, version };
|
|
22044
|
+
const { name: name2, version } = metadataOrEvent.sdk;
|
|
22045
|
+
return { name: name2, version };
|
|
21958
22046
|
}
|
|
21959
22047
|
__name(getSdkMetadataForEnvelopeHeader, "getSdkMetadataForEnvelopeHeader");
|
|
21960
22048
|
function createEventEnvelopeHeaders(event, sdkInfo, tunnel, dsn) {
|
|
@@ -22251,11 +22339,11 @@ var SentrySpan = class {
|
|
|
22251
22339
|
/**
|
|
22252
22340
|
* @inheritDoc
|
|
22253
22341
|
*/
|
|
22254
|
-
updateName(
|
|
22342
|
+
updateName(name2) {
|
|
22255
22343
|
if (this._frozen) {
|
|
22256
22344
|
return this;
|
|
22257
22345
|
}
|
|
22258
|
-
this._name =
|
|
22346
|
+
this._name = name2;
|
|
22259
22347
|
if (!spanShouldInferOtelSource(this)) {
|
|
22260
22348
|
this.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, "custom");
|
|
22261
22349
|
}
|
|
@@ -22330,15 +22418,15 @@ var SentrySpan = class {
|
|
|
22330
22418
|
/**
|
|
22331
22419
|
* @inheritdoc
|
|
22332
22420
|
*/
|
|
22333
|
-
addEvent(
|
|
22421
|
+
addEvent(name2, attributesOrStartTime, startTime) {
|
|
22334
22422
|
if (this._frozen) {
|
|
22335
22423
|
return this;
|
|
22336
22424
|
}
|
|
22337
|
-
DEBUG_BUILD && debug.log("[Tracing] Adding an event to span:",
|
|
22425
|
+
DEBUG_BUILD && debug.log("[Tracing] Adding an event to span:", name2);
|
|
22338
22426
|
const time = isSpanTimeInput(attributesOrStartTime) ? attributesOrStartTime : startTime || timestampInSeconds();
|
|
22339
22427
|
const attributes = isSpanTimeInput(attributesOrStartTime) ? {} : attributesOrStartTime || {};
|
|
22340
22428
|
const event = {
|
|
22341
|
-
name,
|
|
22429
|
+
name: name2,
|
|
22342
22430
|
time: spanTimeInputToSeconds(time),
|
|
22343
22431
|
attributes
|
|
22344
22432
|
};
|
|
@@ -22870,8 +22958,8 @@ __name(getAcs, "getAcs");
|
|
|
22870
22958
|
function _startRootSpan(spanArguments, scope, isolationScope, parentSampled) {
|
|
22871
22959
|
const client = getClient();
|
|
22872
22960
|
const options = client?.getOptions() || {};
|
|
22873
|
-
const { name = "" } = spanArguments;
|
|
22874
|
-
const mutableSpanSamplingData = { spanAttributes: { ...spanArguments.attributes }, spanName:
|
|
22961
|
+
const { name: name2 = "" } = spanArguments;
|
|
22962
|
+
const mutableSpanSamplingData = { spanAttributes: { ...spanArguments.attributes }, spanName: name2, parentSampled };
|
|
22875
22963
|
client?.emit("beforeSampling", mutableSpanSamplingData, { decision: false });
|
|
22876
22964
|
const finalParentSampled = mutableSpanSamplingData.parentSampled ?? parentSampled;
|
|
22877
22965
|
const finalAttributes = mutableSpanSamplingData.spanAttributes;
|
|
@@ -22880,7 +22968,7 @@ function _startRootSpan(spanArguments, scope, isolationScope, parentSampled) {
|
|
|
22880
22968
|
const [sampled, sampleRate, localSampleRateWasApplied] = _isTracingSuppressed ? [false] : sampleSpan(
|
|
22881
22969
|
options,
|
|
22882
22970
|
{
|
|
22883
|
-
name,
|
|
22971
|
+
name: name2,
|
|
22884
22972
|
parentSampled: finalParentSampled,
|
|
22885
22973
|
attributes: finalAttributes,
|
|
22886
22974
|
normalizedRequest: isolationScope.getScopeData().sdkProcessingMetadata.normalizedRequest,
|
|
@@ -23773,12 +23861,12 @@ var installedIntegrations = [];
|
|
|
23773
23861
|
function filterDuplicates(integrations) {
|
|
23774
23862
|
const integrationsByName = {};
|
|
23775
23863
|
integrations.forEach((currentInstance) => {
|
|
23776
|
-
const { name } = currentInstance;
|
|
23777
|
-
const existingInstance = integrationsByName[
|
|
23864
|
+
const { name: name2 } = currentInstance;
|
|
23865
|
+
const existingInstance = integrationsByName[name2];
|
|
23778
23866
|
if (existingInstance && !existingInstance.isDefaultInstance && currentInstance.isDefaultInstance) {
|
|
23779
23867
|
return;
|
|
23780
23868
|
}
|
|
23781
|
-
integrationsByName[
|
|
23869
|
+
integrationsByName[name2] = currentInstance;
|
|
23782
23870
|
});
|
|
23783
23871
|
return Object.values(integrationsByName);
|
|
23784
23872
|
}
|
|
@@ -24286,7 +24374,7 @@ __name(getPossibleEventMessages, "getPossibleEventMessages");
|
|
|
24286
24374
|
|
|
24287
24375
|
// node_modules/@sentry/core/build/esm/utils/transactionEvent.js
|
|
24288
24376
|
function convertTransactionEventToSpanJson(event) {
|
|
24289
|
-
const { trace_id, parent_span_id, span_id, status, origin, data, op } = event.contexts?.trace ?? {};
|
|
24377
|
+
const { trace_id, parent_span_id, span_id, status, origin: origin2, data, op } = event.contexts?.trace ?? {};
|
|
24290
24378
|
return {
|
|
24291
24379
|
data: data ?? {},
|
|
24292
24380
|
description: event.transaction,
|
|
@@ -24297,7 +24385,7 @@ function convertTransactionEventToSpanJson(event) {
|
|
|
24297
24385
|
status,
|
|
24298
24386
|
timestamp: event.timestamp,
|
|
24299
24387
|
trace_id: trace_id ?? "",
|
|
24300
|
-
origin,
|
|
24388
|
+
origin: origin2,
|
|
24301
24389
|
profile_id: data?.[SEMANTIC_ATTRIBUTE_PROFILE_ID],
|
|
24302
24390
|
exclusive_time: data?.[SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME],
|
|
24303
24391
|
measurements: event.measurements,
|
|
@@ -24744,7 +24832,7 @@ var Client = class {
|
|
|
24744
24832
|
// don't support the `spotlight` option there and rely on the users
|
|
24745
24833
|
// adding the `spotlightBrowserIntegration()` to their integrations which
|
|
24746
24834
|
// wouldn't get initialized with the check below when there's no DSN set.
|
|
24747
|
-
this._options.integrations.some(({ name }) =>
|
|
24835
|
+
this._options.integrations.some(({ name: name2 }) => name2.startsWith("Spotlight"))) {
|
|
24748
24836
|
this._setupIntegrations();
|
|
24749
24837
|
}
|
|
24750
24838
|
}
|
|
@@ -25601,12 +25689,12 @@ function removeTrailingSlash(str) {
|
|
|
25601
25689
|
__name(removeTrailingSlash, "removeTrailingSlash");
|
|
25602
25690
|
|
|
25603
25691
|
// node_modules/@sentry/core/build/esm/utils/sdkMetadata.js
|
|
25604
|
-
function applySdkMetadata(options,
|
|
25692
|
+
function applySdkMetadata(options, name2, names = [name2], source = "npm") {
|
|
25605
25693
|
const sdk = (options._metadata = options._metadata || {}).sdk = options._metadata.sdk || {};
|
|
25606
25694
|
if (!sdk.name) {
|
|
25607
|
-
sdk.name = `sentry.javascript.${
|
|
25608
|
-
sdk.packages = names.map((
|
|
25609
|
-
name: `${source}:@sentry/${
|
|
25695
|
+
sdk.name = `sentry.javascript.${name2}`;
|
|
25696
|
+
sdk.packages = names.map((name22) => ({
|
|
25697
|
+
name: `${source}:@sentry/${name22}`,
|
|
25610
25698
|
version: SDK_VERSION
|
|
25611
25699
|
}));
|
|
25612
25700
|
sdk.version = SDK_VERSION;
|
|
@@ -26008,8 +26096,8 @@ function _isIgnoredTransaction(event, ignoreTransactions) {
|
|
|
26008
26096
|
if (!ignoreTransactions?.length) {
|
|
26009
26097
|
return false;
|
|
26010
26098
|
}
|
|
26011
|
-
const
|
|
26012
|
-
return
|
|
26099
|
+
const name2 = event.transaction;
|
|
26100
|
+
return name2 ? stringMatchesSomePattern(name2, ignoreTransactions) : false;
|
|
26013
26101
|
}
|
|
26014
26102
|
__name(_isIgnoredTransaction, "_isIgnoredTransaction");
|
|
26015
26103
|
function _isDeniedUrl(event, denyUrls) {
|
|
@@ -26448,7 +26536,7 @@ function addNormalizedRequestDataToSpan(span, normalizedRequest, ipAddress, incl
|
|
|
26448
26536
|
}
|
|
26449
26537
|
safeSetSpanJSONAttributes(span, attributes);
|
|
26450
26538
|
if (requestData.cookies && Object.keys(requestData.cookies).length > 0) {
|
|
26451
|
-
const cookieString = Object.entries(requestData.cookies).map(([
|
|
26539
|
+
const cookieString = Object.entries(requestData.cookies).map(([name2, value]) => `${name2}=${value}`).join("; ");
|
|
26452
26540
|
const cookieAttributes = httpHeadersToSpanAttributes({ cookie: cookieString }, dataCollection, "request");
|
|
26453
26541
|
safeSetSpanJSONAttributes(span, cookieAttributes);
|
|
26454
26542
|
}
|
|
@@ -26479,7 +26567,7 @@ function extractNormalizedRequestData(normalizedRequest, include) {
|
|
|
26479
26567
|
delete headers.cookie;
|
|
26480
26568
|
}
|
|
26481
26569
|
if (!include.ip) {
|
|
26482
|
-
const ipHeaderNamesLower = new Set(ipHeaderNames.map((
|
|
26570
|
+
const ipHeaderNamesLower = new Set(ipHeaderNames.map((name2) => name2.toLowerCase()));
|
|
26483
26571
|
for (const key of Object.keys(headers)) {
|
|
26484
26572
|
if (ipHeaderNamesLower.has(key.toLowerCase())) {
|
|
26485
26573
|
delete headers[key];
|
|
@@ -26768,8 +26856,8 @@ var _conversationIdIntegration = /* @__PURE__ */ __name((() => {
|
|
|
26768
26856
|
const isolationScopeData = getIsolationScope().getScopeData();
|
|
26769
26857
|
const conversationId = scopeData.conversationId || isolationScopeData.conversationId;
|
|
26770
26858
|
if (conversationId) {
|
|
26771
|
-
const { op, data: attributes, description:
|
|
26772
|
-
if (!op?.startsWith("gen_ai.") && !attributes["ai.operationId"] && !
|
|
26859
|
+
const { op, data: attributes, description: name2 } = spanToJSON(span);
|
|
26860
|
+
if (!op?.startsWith("gen_ai.") && !attributes["ai.operationId"] && !name2?.startsWith("ai.")) {
|
|
26773
26861
|
return;
|
|
26774
26862
|
}
|
|
26775
26863
|
span.setAttribute(GEN_AI_CONVERSATION_ID_ATTRIBUTE, conversationId);
|
|
@@ -27478,12 +27566,12 @@ function setOutputMessagesAttribute(span, { responseText, toolCalls }) {
|
|
|
27478
27566
|
continue;
|
|
27479
27567
|
}
|
|
27480
27568
|
const call = toolCall;
|
|
27481
|
-
const
|
|
27569
|
+
const name2 = call.function?.name ?? call.name;
|
|
27482
27570
|
const args = call.function?.arguments ?? call.arguments;
|
|
27483
27571
|
parts.push({
|
|
27484
27572
|
type: "tool_call",
|
|
27485
27573
|
id: call.id,
|
|
27486
|
-
name,
|
|
27574
|
+
name: name2,
|
|
27487
27575
|
arguments: typeof args === "string" ? args : JSON.stringify(args ?? {})
|
|
27488
27576
|
});
|
|
27489
27577
|
}
|
|
@@ -27523,9 +27611,9 @@ __name(addResponseAttributes, "addResponseAttributes");
|
|
|
27523
27611
|
// node_modules/@sentry/core/build/esm/tracing/workers-ai/streaming.js
|
|
27524
27612
|
function accumulateStreamingToolCalls(toolCalls, accumulator) {
|
|
27525
27613
|
for (const toolCall of toolCalls) {
|
|
27526
|
-
const
|
|
27614
|
+
const name2 = toolCall.function?.name ?? toolCall.name;
|
|
27527
27615
|
const args = toolCall.function?.arguments ?? toolCall.arguments;
|
|
27528
|
-
if (
|
|
27616
|
+
if (name2 == null && args == null) {
|
|
27529
27617
|
continue;
|
|
27530
27618
|
}
|
|
27531
27619
|
const index = toolCall.index ?? 0;
|
|
@@ -27536,13 +27624,13 @@ function accumulateStreamingToolCalls(toolCalls, accumulator) {
|
|
|
27536
27624
|
id: toolCall.id,
|
|
27537
27625
|
type: toolCall.type,
|
|
27538
27626
|
function: {
|
|
27539
|
-
name,
|
|
27627
|
+
name: name2,
|
|
27540
27628
|
arguments: args ?? ""
|
|
27541
27629
|
}
|
|
27542
27630
|
};
|
|
27543
27631
|
} else if (existing.function) {
|
|
27544
|
-
if (
|
|
27545
|
-
existing.function.name =
|
|
27632
|
+
if (name2 && !existing.function.name) {
|
|
27633
|
+
existing.function.name = name2;
|
|
27546
27634
|
}
|
|
27547
27635
|
if (args) {
|
|
27548
27636
|
existing.function.arguments = `${existing.function.arguments ?? ""}${args}`;
|
|
@@ -29242,8 +29330,8 @@ var SentryCloudflareTraceProvider = class {
|
|
|
29242
29330
|
constructor() {
|
|
29243
29331
|
this._tracers = /* @__PURE__ */ new Map();
|
|
29244
29332
|
}
|
|
29245
|
-
getTracer(
|
|
29246
|
-
const key = `${
|
|
29333
|
+
getTracer(name2, version, options) {
|
|
29334
|
+
const key = `${name2}@${version || ""}:${options?.schemaUrl || ""}`;
|
|
29247
29335
|
if (!this._tracers.has(key)) {
|
|
29248
29336
|
this._tracers.set(key, new SentryCloudflareTracer());
|
|
29249
29337
|
}
|
|
@@ -29254,21 +29342,21 @@ var SentryCloudflareTracer = class {
|
|
|
29254
29342
|
static {
|
|
29255
29343
|
__name(this, "SentryCloudflareTracer");
|
|
29256
29344
|
}
|
|
29257
|
-
startSpan(
|
|
29345
|
+
startSpan(name2, options) {
|
|
29258
29346
|
return startInactiveSpan({
|
|
29259
29347
|
...options,
|
|
29260
|
-
name,
|
|
29348
|
+
name: name2,
|
|
29261
29349
|
attributes: {
|
|
29262
29350
|
...options?.attributes,
|
|
29263
29351
|
"sentry.cloudflare_tracer": true
|
|
29264
29352
|
}
|
|
29265
29353
|
});
|
|
29266
29354
|
}
|
|
29267
|
-
startActiveSpan(
|
|
29355
|
+
startActiveSpan(name2, options, context, fn) {
|
|
29268
29356
|
const opts = typeof options === "object" && options !== null ? options : {};
|
|
29269
29357
|
const spanOpts = {
|
|
29270
29358
|
...opts,
|
|
29271
|
-
name,
|
|
29359
|
+
name: name2,
|
|
29272
29360
|
attributes: {
|
|
29273
29361
|
...opts.attributes,
|
|
29274
29362
|
"sentry.cloudflare_tracer": true
|
|
@@ -29425,7 +29513,7 @@ function init(options) {
|
|
|
29425
29513
|
transport: options.transport || makeCloudflareTransport,
|
|
29426
29514
|
flushLock
|
|
29427
29515
|
};
|
|
29428
|
-
if (options.spotlight && !clientOptions.integrations.some(({ name }) =>
|
|
29516
|
+
if (options.spotlight && !clientOptions.integrations.some(({ name: name2 }) => name2 === INTEGRATION_NAME11)) {
|
|
29429
29517
|
clientOptions.integrations.push(
|
|
29430
29518
|
spotlightIntegration({
|
|
29431
29519
|
sidecarUrl: typeof options.spotlight === "string" ? options.spotlight : void 0
|
|
@@ -30467,7 +30555,7 @@ function wrapRequestHandler(wrapperOptions, handler) {
|
|
|
30467
30555
|
const client = init({ ...options, ctx: context });
|
|
30468
30556
|
isolationScope.setClient(client);
|
|
30469
30557
|
const urlObject = parseStringToURLObject(request.url);
|
|
30470
|
-
const [
|
|
30558
|
+
const [name2, attributes] = getHttpSpanDetailsFromUrlObject(urlObject, "server", "auto.http.cloudflare", request);
|
|
30471
30559
|
const contentLength = request.headers.get("content-length");
|
|
30472
30560
|
if (contentLength) {
|
|
30473
30561
|
attributes["http.request.body.size"] = parseInt(contentLength, 10);
|
|
@@ -30510,7 +30598,7 @@ function wrapRequestHandler(wrapperOptions, handler) {
|
|
|
30510
30598
|
return continueTrace(
|
|
30511
30599
|
{ sentryTrace: request.headers.get("sentry-trace") || "", baggage: request.headers.get("baggage") },
|
|
30512
30600
|
() => {
|
|
30513
|
-
return startSpanManual({ name, attributes }, async (span) => {
|
|
30601
|
+
return startSpanManual({ name: name2, attributes }, async (span) => {
|
|
30514
30602
|
let res;
|
|
30515
30603
|
try {
|
|
30516
30604
|
res = await handler();
|
|
@@ -30833,7 +30921,7 @@ function wrapMethodWithSentry(wrapperOptions, handler, callback, noMark) {
|
|
|
30833
30921
|
handler,
|
|
30834
30922
|
(original) => new Proxy(original, {
|
|
30835
30923
|
apply(target, thisArg, rawArgs) {
|
|
30836
|
-
const { startNewTrace: startNewTrace$1, origin } = wrapperOptions;
|
|
30924
|
+
const { startNewTrace: startNewTrace$1, origin: origin2 } = wrapperOptions;
|
|
30837
30925
|
let args = rawArgs;
|
|
30838
30926
|
let rpcMeta;
|
|
30839
30927
|
if (wrapperOptions.spanOp === "rpc") {
|
|
@@ -30869,7 +30957,7 @@ function wrapMethodWithSentry(wrapperOptions, handler, callback, noMark) {
|
|
|
30869
30957
|
const onRejected = /* @__PURE__ */ __name((e) => {
|
|
30870
30958
|
captureException(e, {
|
|
30871
30959
|
mechanism: {
|
|
30872
|
-
type:
|
|
30960
|
+
type: origin2,
|
|
30873
30961
|
handled: false
|
|
30874
30962
|
}
|
|
30875
30963
|
});
|
|
@@ -30893,7 +30981,7 @@ function wrapMethodWithSentry(wrapperOptions, handler, callback, noMark) {
|
|
|
30893
30981
|
}
|
|
30894
30982
|
const attributes = wrapperOptions.spanOp ? {
|
|
30895
30983
|
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: wrapperOptions.spanOp,
|
|
30896
|
-
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]:
|
|
30984
|
+
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: origin2
|
|
30897
30985
|
} : {};
|
|
30898
30986
|
const executeSpan = /* @__PURE__ */ __name(() => {
|
|
30899
30987
|
return startSpan({ name: methodName, attributes }, (span) => {
|
|
@@ -31261,7 +31349,8 @@ var index_default = withSentry(sentryOptions, {
|
|
|
31261
31349
|
async function route(request, env, ctx) {
|
|
31262
31350
|
{
|
|
31263
31351
|
const url = new URL(request.url);
|
|
31264
|
-
const
|
|
31352
|
+
const identity = deploymentIdentity(env);
|
|
31353
|
+
const discovery = publicDiscoveryResponse(request, identity);
|
|
31265
31354
|
if (discovery !== null) return discovery;
|
|
31266
31355
|
{
|
|
31267
31356
|
const brand = brandResponse(url.pathname);
|
|
@@ -31293,14 +31382,14 @@ async function route(request, env, ctx) {
|
|
|
31293
31382
|
openapi: "GET /openapi.json",
|
|
31294
31383
|
integrate: "GET /integrate"
|
|
31295
31384
|
},
|
|
31296
|
-
operator:
|
|
31385
|
+
...identity.operatorName ? { operator: identity.operatorName } : {}
|
|
31297
31386
|
});
|
|
31298
31387
|
}
|
|
31299
31388
|
if (url.pathname === "/integrate") {
|
|
31300
31389
|
if (request.method !== "GET" && request.method !== "HEAD") {
|
|
31301
31390
|
return errorResponse(405, "invalid_request_error", `Method ${request.method} not allowed.`);
|
|
31302
31391
|
}
|
|
31303
|
-
return new Response(integratePage(
|
|
31392
|
+
return new Response(integratePage(identity), {
|
|
31304
31393
|
headers: {
|
|
31305
31394
|
"content-type": "text/html; charset=utf-8",
|
|
31306
31395
|
"cache-control": "public, max-age=300",
|
|
@@ -31314,11 +31403,11 @@ async function route(request, env, ctx) {
|
|
|
31314
31403
|
return errorResponse(405, "invalid_request_error", `Method ${request.method} not allowed.`);
|
|
31315
31404
|
}
|
|
31316
31405
|
if (url.pathname === "/openapi.json") {
|
|
31317
|
-
return Response.json(openapi(), {
|
|
31406
|
+
return Response.json(openapi(identity), {
|
|
31318
31407
|
headers: { "cache-control": "public, max-age=300", "access-control-allow-origin": "*" }
|
|
31319
31408
|
});
|
|
31320
31409
|
}
|
|
31321
|
-
return new Response(docsPage(
|
|
31410
|
+
return new Response(docsPage(identity), {
|
|
31322
31411
|
headers: {
|
|
31323
31412
|
"content-type": "text/html; charset=utf-8",
|
|
31324
31413
|
"cache-control": "public, max-age=300",
|