@canonry/canonry 7.51.6 → 7.53.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/agent-workspace/skills/canonry/references/canonry-cli.md +19 -1
- package/assets/assets/{AccessControls-B5TqDgeq.js → AccessControls-B-5YUuLE.js} +1 -1
- package/assets/assets/{AuditHistoryPanel-DgxiizOW.js → AuditHistoryPanel-BkCUPvPv.js} +1 -1
- package/assets/assets/{BacklinksPage-Ay6pdphx.js → BacklinksPage-BMgHZKuw.js} +1 -1
- package/assets/assets/{HistoryPage-B11eFH21.js → HistoryPage-D2DOk7ms.js} +1 -1
- package/assets/assets/MeasurementPropertyPage-Bwv8nKS7.js +4 -0
- package/assets/assets/ProjectPage-CsJfGPx3.js +7 -0
- package/assets/assets/RunsPage-DSHDuj9b.js +1 -0
- package/assets/assets/SettingsPage-BDRdWk5X.js +1 -0
- package/assets/assets/SiteHealthSection-DV06NTxC.js +2 -0
- package/assets/assets/TrafficPage-CBMMwRfw.js +40 -0
- package/assets/assets/{TrafficSourceDetailPage-DQu0YNt2.js → TrafficSourceDetailPage-Czpt0S7j.js} +1 -1
- package/assets/assets/card-CVejjbhs.js +60 -0
- package/assets/assets/{extract-error-message-BRM1I_3L.js → extract-error-message-Co6zPipR.js} +1 -1
- package/assets/assets/{format-helpers-DrkFERj3.js → format-helpers-B_2jkVGI.js} +1 -1
- package/assets/assets/index-BnS2Vuv0.js +40 -0
- package/assets/assets/index-DgS5TTSb.css +1 -0
- package/assets/assets/{query-client-gRFnU4VF.js → query-client-BKJLgjJd.js} +1 -1
- package/assets/assets/react-query-ltP1RErY.js +1 -0
- package/assets/assets/{react-sigma_core.esm.min-D09H4byP.js → react-sigma_core.esm.min-Bjux3j_1.js} +1 -1
- package/assets/assets/service-CDsqgNrS.js +1 -0
- package/assets/index.html +8 -7
- package/dist/{ads-ABAT3K4K.js → ads-S4S74OXM.js} +3 -3
- package/dist/{agent-5G4DRLYX.js → agent-JZWKCI5V.js} +7 -7
- package/dist/{agent-ask-UDVCZRO7.js → agent-ask-N2DG5ZLZ.js} +3 -3
- package/dist/{agent-conversations-5E4JP2QZ.js → agent-conversations-7UDNE7YI.js} +3 -3
- package/dist/{agent-memory-7IIJ4HGZ.js → agent-memory-I74OWTU7.js} +3 -3
- package/dist/{agent-providers-BOXPUXZ4.js → agent-providers-MEMCZPGE.js} +3 -3
- package/dist/{agent-transcript-4O56G6PQ.js → agent-transcript-Z7VTL7PY.js} +3 -3
- package/dist/{analytics-PKMWX5XL.js → analytics-4NUSNTKT.js} +3 -3
- package/dist/{apply-OK4XEBDA.js → apply-OZKQK3YF.js} +3 -3
- package/dist/{backfill-2OT56CX2.js → backfill-PLY2NOOY.js} +9 -9
- package/dist/{backlinks-547WCHND.js → backlinks-2CMRJFWO.js} +3 -3
- package/dist/{bing-ZVBV4ZD5.js → bing-RD3DDESD.js} +3 -3
- package/dist/{bootstrap-HUB7XQ73.js → bootstrap-JOYV4SWM.js} +9 -9
- package/dist/{cdp-KQKQ4PWJ.js → cdp-LUGL3CT6.js} +7 -7
- package/dist/{chunk-HM4NNKLG.js → chunk-23UZNTF4.js} +1 -1
- package/dist/{chunk-73P65KPW.js → chunk-2EYBZYDG.js} +2 -2
- package/dist/{chunk-D6COIM3U.js → chunk-2GAXZAQJ.js} +5985 -5846
- package/dist/{chunk-VBCE4CLX.js → chunk-2HWY4NRQ.js} +3 -3
- package/dist/{chunk-ZWJRY5UI.js → chunk-2XDGFHPM.js} +6 -4
- package/dist/{chunk-I3A56PFP.js → chunk-3DO3CS7Y.js} +4 -4
- package/dist/{chunk-PCXRFT3N.js → chunk-6VSKBVB3.js} +3 -3
- package/dist/{chunk-RKIXES2B.js → chunk-6ZCZRZ66.js} +2 -2
- package/dist/{chunk-MMEO22MF.js → chunk-BGZL5RCP.js} +1 -1
- package/dist/{chunk-63ISSSGX.js → chunk-BH274VEO.js} +32 -4
- package/dist/{chunk-HACZUMGM.js → chunk-BQT7VLGM.js} +11 -1
- package/dist/{chunk-KFT5LOP2.js → chunk-C5GCRQ66.js} +10 -3
- package/dist/{chunk-7B2Q4NJE.js → chunk-DFQHGWPB.js} +1 -1
- package/dist/{chunk-TUTKNUMV.js → chunk-F55ER5RQ.js} +3 -3
- package/dist/{chunk-I77PLCWG.js → chunk-IWQGZQHE.js} +32 -12
- package/dist/{chunk-DGVUTH7W.js → chunk-JZARXJV6.js} +3031 -2283
- package/dist/{chunk-ZXUAWVWM.js → chunk-LGU3O5YP.js} +2 -2
- package/dist/{chunk-7WZ2FPB4.js → chunk-LYCYSM6O.js} +1 -1
- package/dist/chunk-N3WQHLDI.js +1199 -0
- package/dist/{chunk-WAULJDKO.js → chunk-N6MS4VG2.js} +226 -5
- package/dist/{chunk-B2FR2ZQ4.js → chunk-NKSASP4U.js} +1 -1
- package/dist/{chunk-B5J675KK.js → chunk-O3OTW7F4.js} +39 -2
- package/dist/{chunk-6G6FTDWC.js → chunk-P4SXRRB4.js} +313 -196
- package/dist/{chunk-42D2LE2B.js → chunk-QARV5HVI.js} +26 -240
- package/dist/{chunk-VYMZ3QXG.js → chunk-QNU7IIO7.js} +326 -324
- package/dist/{chunk-ISOQPVPY.js → chunk-QXJ356KK.js} +4 -4
- package/dist/{chunk-QWKPSFGL.js → chunk-RVBGFWJ3.js} +1 -1
- package/dist/{chunk-WDFI5YMD.js → chunk-SZG7S7TE.js} +1 -1
- package/dist/{chunk-GO2J7SYT.js → chunk-U7JJKXLA.js} +5 -5
- package/dist/{chunk-PITHTCAX.js → chunk-VEH4YLWR.js} +1 -1
- package/dist/{chunk-NHQ2U5I4.js → chunk-WNXKW3NS.js} +1 -1
- package/dist/{chunk-2G6IP3MO.js → chunk-XTIP5WSA.js} +11 -4
- package/dist/{chunk-U3AHE2RT.js → chunk-ZXH5IFIA.js} +4 -4
- package/dist/{citations-UYB2RU5U.js → citations-GMLBTNLW.js} +3 -3
- package/dist/{cli-catalog-F6FI7NB2.js → cli-catalog-WKUCQEWA.js} +3 -3
- package/dist/{cli-commands-ZG5ILKDA.js → cli-commands-YCHQWUNK.js} +7 -7
- package/dist/cli.js +13 -13
- package/dist/{competitor-EKP4R7YY.js → competitor-QNPVJFEI.js} +3 -3
- package/dist/{content-DREE6JF3.js → content-NFTC74HD.js} +3 -3
- package/dist/{dashboard-ZALEOLLU.js → dashboard-TMUQT5H5.js} +6 -6
- package/dist/{demo-JG4Y22O4.js → demo-O5SPVLZZ.js} +1 -1
- package/dist/{demo-server-3A4J2C65.js → demo-server-WKZ53RGK.js} +11 -11
- package/dist/{discover-W6GMD2HS.js → discover-LTTO7KHN.js} +3 -3
- package/dist/{discover-eval-CKFZHRBW.js → discover-eval-QRDNMDUE.js} +3 -3
- package/dist/{doctor-TNGBSUMA.js → doctor-SFL5FOW4.js} +3 -3
- package/dist/{evidence-3H2GFQBZ.js → evidence-J6WZ767P.js} +3 -3
- package/dist/{export-cmd-WUIKU5GK.js → export-cmd-D3JDTBDV.js} +3 -3
- package/dist/{ga-JI6REFO4.js → ga-N56LXQUN.js} +3 -3
- package/dist/{gbp-4ENDM5NS.js → gbp-7WVJYWDR.js} +3 -3
- package/dist/{google-HKQSCLOC.js → google-YLRVXYVJ.js} +4 -4
- package/dist/{google-marketing-KQR5J2S4.js → google-marketing-4DGX3RBB.js} +1 -1
- package/dist/{health-cmd-TS7EMMCS.js → health-cmd-PK3BASF6.js} +3 -3
- package/dist/{history-MSD5DK6K.js → history-UWTEZ626.js} +3 -3
- package/dist/index.d.ts +120 -48
- package/dist/index.js +23 -23
- package/dist/{init-L6WAEOWX.js → init-RBI2IOBY.js} +11 -11
- package/dist/{insights-RTZ3IZTD.js → insights-ZUC5XHFD.js} +3 -3
- package/dist/intelligence-service-JXXB43RB.js +15 -0
- package/dist/{keys-625DZBRM.js → keys-NOG3M76V.js} +3 -3
- package/dist/{keyword-CW46RNRR.js → keyword-HD57L76I.js} +3 -3
- package/dist/{logs-V33SHBIW.js → logs-VAB7ITBS.js} +3 -3
- package/dist/{mcp-DFEDPSEG.js → mcp-HYHIL5FB.js} +2 -2
- package/dist/mcp.js +9 -9
- package/dist/{measurement-plan-6W37RUOP.js → measurement-plan-GEHOHCH3.js} +5 -5
- package/dist/{notify-DSUOT7WO.js → notify-VQ2ZDGN4.js} +3 -3
- package/dist/{organic-evidence-BMN6L4OB.js → organic-evidence-6TX627YW.js} +3 -3
- package/dist/{overview-WRRMBZ6S.js → overview-XBO7WYAV.js} +4 -4
- package/dist/{project-2GJIU3FE.js → project-DR6744WZ.js} +3 -3
- package/dist/{query-3XPMGJUA.js → query-OGVTCPG5.js} +3 -3
- package/dist/{research-V433CKJ4.js → research-B2TGKSMC.js} +3 -3
- package/dist/{results-export-RGBU7QQQ.js → results-export-K7PAYPWQ.js} +3 -3
- package/dist/{run-NIAC6OJN.js → run-Y6LUMCVL.js} +4 -4
- package/dist/{schedule-KDWXRIE7.js → schedule-PNAUJ5FX.js} +3 -3
- package/dist/{search-626MPUJN.js → search-PMVOGL4U.js} +3 -3
- package/dist/{serve-73SMMASI.js → serve-PQHXSS5T.js} +67 -26
- package/dist/{session-7WWOETZB.js → session-S5NDMMKF.js} +16 -15
- package/dist/{settings-VKFQO6F2.js → settings-AL7E7QUK.js} +3 -3
- package/dist/{skills-5HC5H7TE.js → skills-GQOOTDR7.js} +2 -2
- package/dist/{snapshot-BSJUHFBC.js → snapshot-W3FXRTZM.js} +3 -3
- package/dist/{src-F6HM73TN.js → src-WZLTQFCH.js} +2 -2
- package/dist/{status-V4OWP7LZ.js → status-MBJVN4W5.js} +4 -4
- package/dist/{technical-aeo-TG7CGU3F.js → technical-aeo-Y4RFST72.js} +3 -3
- package/dist/{telemetry-O2IUNUBW.js → telemetry-VK6F5QSZ.js} +4 -4
- package/dist/{tools-2GJIDKND.js → tools-W3AQY5TY.js} +11 -11
- package/dist/{traffic-XV4I3UPH.js → traffic-ER4I6V3B.js} +5 -5
- package/dist/{users-VGBLDL5K.js → users-KZK2OF4L.js} +3 -3
- package/dist/{visibility-stats-UKJYJ6PP.js → visibility-stats-CR7BUG5G.js} +3 -3
- package/dist/{wordpress-JZA7CGC6.js → wordpress-DG5JUCAC.js} +3 -3
- package/package.json +2 -1
- package/assets/assets/MeasurementPropertyPage-1UYI7mzP.js +0 -4
- package/assets/assets/ProjectPage-DoY0hftd.js +0 -8
- package/assets/assets/RunsPage-BPBmuQAS.js +0 -1
- package/assets/assets/SettingsPage-ClKnP8xy.js +0 -1
- package/assets/assets/SiteHealthSection-PWjKMmEn.js +0 -2
- package/assets/assets/TrafficPage-DkfGiJXR.js +0 -40
- package/assets/assets/card-DYMyvhB9.js +0 -60
- package/assets/assets/index-CG1Jox52.js +0 -39
- package/assets/assets/index-CsPsaUr7.css +0 -1
- package/assets/assets/react-query-lH82FULK.js +0 -1
- package/assets/assets/service-Cx0HSnE9.js +0 -1
- package/dist/chunk-UQ3MOZGC.js +0 -644
- package/dist/intelligence-service-TH52PCNJ.js +0 -15
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
parseJsonColumn
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-BH274VEO.js";
|
|
4
4
|
import {
|
|
5
5
|
AI_ENGINE_DOMAINS,
|
|
6
6
|
AI_ENGINE_SELF_DOMAINS,
|
|
7
7
|
AnchoredSpanSources,
|
|
8
|
+
OPENROUTER_MODEL_PATTERN,
|
|
8
9
|
ProviderBatchSubmitError,
|
|
9
10
|
ProviderNames,
|
|
10
11
|
RetrievalContracts,
|
|
@@ -16,12 +17,14 @@ import {
|
|
|
16
17
|
hostOf,
|
|
17
18
|
isRetryableHttpError,
|
|
18
19
|
normalizeServedModel,
|
|
20
|
+
openRouterRouteModel,
|
|
21
|
+
openRouterRouteName,
|
|
19
22
|
registrableDomain,
|
|
20
23
|
resolveProviderModel,
|
|
21
24
|
retryAfterDelayMs,
|
|
22
25
|
usageCount,
|
|
23
26
|
withRetry
|
|
24
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-2GAXZAQJ.js";
|
|
25
28
|
|
|
26
29
|
// ../provider-openai/src/normalize.ts
|
|
27
30
|
import OpenAI from "openai";
|
|
@@ -1295,16 +1298,16 @@ function buildTrackedQueryRequest3(input) {
|
|
|
1295
1298
|
}
|
|
1296
1299
|
async function executeTrackedQuery3(input) {
|
|
1297
1300
|
const model = resolveModel2(input.config);
|
|
1298
|
-
const
|
|
1301
|
+
const request2 = buildTrackedQueryRequest3(input).body;
|
|
1299
1302
|
const client = createClient2(input.config);
|
|
1300
1303
|
let result;
|
|
1301
1304
|
try {
|
|
1302
1305
|
result = await withRetry4(
|
|
1303
1306
|
() => client.models.generateContent({
|
|
1304
1307
|
model,
|
|
1305
|
-
contents:
|
|
1308
|
+
contents: request2.contents,
|
|
1306
1309
|
config: {
|
|
1307
|
-
tools:
|
|
1310
|
+
tools: request2.tools
|
|
1308
1311
|
}
|
|
1309
1312
|
})
|
|
1310
1313
|
);
|
|
@@ -2631,6 +2634,223 @@ var museAdapter = {
|
|
|
2631
2634
|
}
|
|
2632
2635
|
};
|
|
2633
2636
|
|
|
2637
|
+
// ../provider-openrouter/src/adapter.ts
|
|
2638
|
+
var BASE_URL2 = "https://openrouter.ai/api/v1";
|
|
2639
|
+
function modelOf2(config) {
|
|
2640
|
+
const routeModel = openRouterRouteModel(config.provider);
|
|
2641
|
+
if (routeModel && config.model && routeModel !== config.model) throw new Error("OpenRouter route model cannot be overridden");
|
|
2642
|
+
const model = routeModel ?? config.model;
|
|
2643
|
+
if (!model || !openRouterRouteModel(`openrouter:${model}`)) throw new Error("Select a concrete OpenRouter text model (publisher/model)");
|
|
2644
|
+
return model;
|
|
2645
|
+
}
|
|
2646
|
+
var OpenRouterHttpError = class extends Error {
|
|
2647
|
+
constructor(status, retryAfter) {
|
|
2648
|
+
super(`OpenRouter request failed (HTTP ${status})`);
|
|
2649
|
+
this.status = status;
|
|
2650
|
+
this.retryAfter = retryAfter;
|
|
2651
|
+
this.name = "OpenRouterHttpError";
|
|
2652
|
+
}
|
|
2653
|
+
status;
|
|
2654
|
+
retryAfter;
|
|
2655
|
+
};
|
|
2656
|
+
function choiceFailure(body) {
|
|
2657
|
+
const choice = Array.isArray(body.choices) ? asRecord(body.choices[0]) : void 0;
|
|
2658
|
+
const error = asRecord(choice?.error);
|
|
2659
|
+
if (!error && choice?.finish_reason !== "error") return null;
|
|
2660
|
+
return typeof error?.code === "number" ? error.code : 502;
|
|
2661
|
+
}
|
|
2662
|
+
async function fetchOnce(config, resource, body, signal) {
|
|
2663
|
+
const response = await fetch(`${(config.baseUrl || BASE_URL2).replace(/\/+$/, "")}/${resource}`, {
|
|
2664
|
+
method: body ? "POST" : "GET",
|
|
2665
|
+
headers: { Authorization: `Bearer ${config.apiKey ?? ""}`, "Content-Type": "application/json" },
|
|
2666
|
+
...body ? { body: JSON.stringify(body) } : {},
|
|
2667
|
+
signal: signal ?? AbortSignal.timeout(12e4)
|
|
2668
|
+
});
|
|
2669
|
+
if (!response.ok) throw new OpenRouterHttpError(response.status, response.headers.get("retry-after") ?? void 0);
|
|
2670
|
+
const value = asRecord(await response.json());
|
|
2671
|
+
if (!value) throw new Error("OpenRouter returned an invalid response");
|
|
2672
|
+
const error = asRecord(value.error);
|
|
2673
|
+
if (error) throw new OpenRouterHttpError(typeof error.code === "number" ? error.code : 502);
|
|
2674
|
+
const failed = choiceFailure(value);
|
|
2675
|
+
if (failed !== null) throw new OpenRouterHttpError(failed);
|
|
2676
|
+
return value;
|
|
2677
|
+
}
|
|
2678
|
+
function request(config, resource, body, signal) {
|
|
2679
|
+
return withRetry(() => fetchOnce(config, resource, body, signal), {
|
|
2680
|
+
isRetryable: (error) => !signal?.aborted && isRetryableHttpError(error),
|
|
2681
|
+
computeDelayMs: (_attempt, error, delay) => retryAfterDelayMs(error) ?? delay
|
|
2682
|
+
});
|
|
2683
|
+
}
|
|
2684
|
+
function messageOf(body) {
|
|
2685
|
+
const choice = Array.isArray(body.choices) ? asRecord(body.choices[0]) : void 0;
|
|
2686
|
+
return asRecord(choice?.message);
|
|
2687
|
+
}
|
|
2688
|
+
function sourcesOf(body) {
|
|
2689
|
+
const annotations = messageOf(body)?.annotations;
|
|
2690
|
+
const sources = /* @__PURE__ */ new Map();
|
|
2691
|
+
if (!Array.isArray(annotations)) return [];
|
|
2692
|
+
for (const value of annotations) {
|
|
2693
|
+
const annotation = asRecord(value);
|
|
2694
|
+
if (annotation?.type !== "url_citation") continue;
|
|
2695
|
+
const citation = asRecord(annotation.url_citation);
|
|
2696
|
+
if (typeof citation?.url !== "string") continue;
|
|
2697
|
+
let uri;
|
|
2698
|
+
try {
|
|
2699
|
+
const url = new URL(citation.url);
|
|
2700
|
+
if (!["http:", "https:"].includes(url.protocol)) continue;
|
|
2701
|
+
uri = url.href;
|
|
2702
|
+
} catch {
|
|
2703
|
+
continue;
|
|
2704
|
+
}
|
|
2705
|
+
if (!hostOf(uri)) continue;
|
|
2706
|
+
sources.set(uri, { uri, title: typeof citation.title === "string" ? citation.title : hostOf(uri) });
|
|
2707
|
+
}
|
|
2708
|
+
return [...sources.values()];
|
|
2709
|
+
}
|
|
2710
|
+
function parseResponse2(body, model, provider = openRouterRouteName(model)) {
|
|
2711
|
+
const failed = choiceFailure(body);
|
|
2712
|
+
if (failed !== null) throw new OpenRouterHttpError(failed);
|
|
2713
|
+
const message = messageOf(body);
|
|
2714
|
+
if (typeof message?.content !== "string" || !message.content.trim()) throw new Error("OpenRouter returned no answer text");
|
|
2715
|
+
const groundingSources = sourcesOf(body);
|
|
2716
|
+
const usage = asRecord(body.usage);
|
|
2717
|
+
const details = asRecord(usage?.input_tokens_details) ?? asRecord(usage?.prompt_tokens_details);
|
|
2718
|
+
const choice = Array.isArray(body.choices) ? asRecord(body.choices[0]) : void 0;
|
|
2719
|
+
const cached = usageCount(details?.cached_tokens);
|
|
2720
|
+
const searchCount = usageCount(asRecord(usage?.server_tool_use)?.web_search_requests);
|
|
2721
|
+
const inputTokens = usage?.input_tokens === void 0 ? usageCount(usage?.prompt_tokens) : usageCount(usage.input_tokens);
|
|
2722
|
+
const outputTokens = usage?.output_tokens === void 0 ? usageCount(usage?.completion_tokens) : usageCount(usage.output_tokens);
|
|
2723
|
+
return {
|
|
2724
|
+
provider,
|
|
2725
|
+
model,
|
|
2726
|
+
servedModel: normalizeServedModel(body.model),
|
|
2727
|
+
rawResponse: body,
|
|
2728
|
+
groundingSources,
|
|
2729
|
+
searchQueries: [],
|
|
2730
|
+
retrievalContract: RetrievalContracts["search-required-v1"],
|
|
2731
|
+
retrievalStatus: searchCount > 0 || groundingSources.length ? RetrievalStatuses.used : RetrievalStatuses.unknown,
|
|
2732
|
+
...typeof choice?.finish_reason === "string" ? { stopReason: choice.finish_reason } : {},
|
|
2733
|
+
...usage ? { usage: {
|
|
2734
|
+
inputTokens: Math.max(0, inputTokens - cached),
|
|
2735
|
+
cachedInputTokens: cached,
|
|
2736
|
+
cacheWriteTokens: 0,
|
|
2737
|
+
outputTokens,
|
|
2738
|
+
searchCount
|
|
2739
|
+
} } : {}
|
|
2740
|
+
};
|
|
2741
|
+
}
|
|
2742
|
+
function perMillionTokens(value) {
|
|
2743
|
+
if (typeof value === "string" ? !value.trim() : typeof value !== "number") return void 0;
|
|
2744
|
+
const perToken = Number(value);
|
|
2745
|
+
if (!Number.isFinite(perToken) || perToken < 0) return void 0;
|
|
2746
|
+
return Number((perToken * 1e6).toPrecision(12));
|
|
2747
|
+
}
|
|
2748
|
+
function positiveInteger(value) {
|
|
2749
|
+
return typeof value === "number" && Number.isInteger(value) && value > 0 ? value : void 0;
|
|
2750
|
+
}
|
|
2751
|
+
function catalogMetadata(model) {
|
|
2752
|
+
const topProvider = asRecord(model.top_provider);
|
|
2753
|
+
const pricing = asRecord(model.pricing);
|
|
2754
|
+
const input = perMillionTokens(pricing?.prompt);
|
|
2755
|
+
const output = perMillionTokens(pricing?.completion);
|
|
2756
|
+
const cacheRead = perMillionTokens(pricing?.input_cache_read);
|
|
2757
|
+
const cacheWrite = perMillionTokens(pricing?.input_cache_write);
|
|
2758
|
+
const modalities = asRecord(model.architecture)?.input_modalities;
|
|
2759
|
+
const parameters = Array.isArray(model.supported_parameters) ? model.supported_parameters : void 0;
|
|
2760
|
+
const contextWindow = positiveInteger(model.context_length) ?? positiveInteger(topProvider?.context_length);
|
|
2761
|
+
const maxOutputTokens = positiveInteger(topProvider?.max_completion_tokens);
|
|
2762
|
+
return {
|
|
2763
|
+
...contextWindow ? { contextWindow } : {},
|
|
2764
|
+
...maxOutputTokens ? { maxOutputTokens } : {},
|
|
2765
|
+
...input !== void 0 && output !== void 0 ? { pricing: {
|
|
2766
|
+
input,
|
|
2767
|
+
output,
|
|
2768
|
+
...cacheRead !== void 0 ? { cacheRead } : {},
|
|
2769
|
+
...cacheWrite !== void 0 ? { cacheWrite } : {}
|
|
2770
|
+
} } : {},
|
|
2771
|
+
...Array.isArray(modalities) ? { inputModalities: modalities.filter((entry) => typeof entry === "string") } : {},
|
|
2772
|
+
...parameters ? { supportsTools: parameters.includes("tools"), supportsReasoning: parameters.includes("reasoning") } : {}
|
|
2773
|
+
};
|
|
2774
|
+
}
|
|
2775
|
+
function buildRequest(input, config) {
|
|
2776
|
+
const model = modelOf2(config);
|
|
2777
|
+
return { endpoint: "/chat/completions", body: {
|
|
2778
|
+
model,
|
|
2779
|
+
messages: [{ role: "user", content: input.query }],
|
|
2780
|
+
stream: false,
|
|
2781
|
+
tools: [{ type: "openrouter:web_search", parameters: { max_uses: 1, max_total_results: 5 } }],
|
|
2782
|
+
tool_choice: "required",
|
|
2783
|
+
max_tool_calls: 1,
|
|
2784
|
+
provider: { allow_fallbacks: false, require_parameters: true }
|
|
2785
|
+
} };
|
|
2786
|
+
}
|
|
2787
|
+
function normalize(raw) {
|
|
2788
|
+
const content = messageOf(raw.rawResponse)?.content;
|
|
2789
|
+
return {
|
|
2790
|
+
provider: raw.provider,
|
|
2791
|
+
answerText: typeof content === "string" ? content : "",
|
|
2792
|
+
citedDomains: [...new Set(raw.groundingSources.map((source) => hostOf(source.uri)).filter((host) => Boolean(host)).map((host) => registrableDomain(host) ?? host))],
|
|
2793
|
+
groundingSources: raw.groundingSources,
|
|
2794
|
+
searchQueries: raw.searchQueries,
|
|
2795
|
+
retrievalStatus: raw.retrievalStatus
|
|
2796
|
+
};
|
|
2797
|
+
}
|
|
2798
|
+
var openrouterAdapter = {
|
|
2799
|
+
name: "openrouter",
|
|
2800
|
+
displayName: "OpenRouter",
|
|
2801
|
+
mode: "api",
|
|
2802
|
+
supportsLocationContext: false,
|
|
2803
|
+
keyUrl: "https://openrouter.ai/keys",
|
|
2804
|
+
modelRegistry: { defaultModel: "", validationPattern: OPENROUTER_MODEL_PATTERN, validationHint: "a concrete text model ID, publisher/model", knownModels: [] },
|
|
2805
|
+
validateConfig(config) {
|
|
2806
|
+
if (!config.apiKey?.trim()) return { ok: false, provider: config.provider, message: "Missing OpenRouter API key" };
|
|
2807
|
+
if (config.model || openRouterRouteModel(config.provider)) {
|
|
2808
|
+
try {
|
|
2809
|
+
modelOf2(config);
|
|
2810
|
+
} catch (error) {
|
|
2811
|
+
return { ok: false, provider: config.provider, message: describeError(error) };
|
|
2812
|
+
}
|
|
2813
|
+
}
|
|
2814
|
+
return { ok: true, provider: config.provider, message: "Configuration valid", model: config.model };
|
|
2815
|
+
},
|
|
2816
|
+
async healthcheck(config) {
|
|
2817
|
+
const valid = this.validateConfig(config);
|
|
2818
|
+
if (!valid.ok) return valid;
|
|
2819
|
+
try {
|
|
2820
|
+
await request(config, "auth/key");
|
|
2821
|
+
return { ...valid, message: "OpenRouter connected" };
|
|
2822
|
+
} catch (error) {
|
|
2823
|
+
return { ok: false, provider: config.provider, message: describeError(error) };
|
|
2824
|
+
}
|
|
2825
|
+
},
|
|
2826
|
+
async listModels(config, signal) {
|
|
2827
|
+
const body = await request(config, "models", void 0, signal);
|
|
2828
|
+
if (!Array.isArray(body.data)) throw new Error("OpenRouter returned no model catalog");
|
|
2829
|
+
return body.data.flatMap((value) => {
|
|
2830
|
+
const model = asRecord(value);
|
|
2831
|
+
if (typeof model?.id !== "string" || !openRouterRouteModel(`openrouter:${model.id}`)) return [];
|
|
2832
|
+
if (model.id.endsWith(":batch")) return [];
|
|
2833
|
+
const architecture = asRecord(model.architecture);
|
|
2834
|
+
const output = architecture?.output_modalities;
|
|
2835
|
+
if (Array.isArray(output) && (!output.includes("text") || output.includes("image") || output.includes("audio"))) return [];
|
|
2836
|
+
return [{ id: model.id, displayName: typeof model.name === "string" ? model.name : model.id, tier: "standard", ...catalogMetadata(model) }];
|
|
2837
|
+
});
|
|
2838
|
+
},
|
|
2839
|
+
buildTrackedQueryRequest: buildRequest,
|
|
2840
|
+
parseTrackedQueryResponse: parseResponse2,
|
|
2841
|
+
async executeTrackedQuery(input, config) {
|
|
2842
|
+
const built = buildRequest(input, config);
|
|
2843
|
+
return parseResponse2(await request(config, "chat/completions", built.body), modelOf2(config), config.provider);
|
|
2844
|
+
},
|
|
2845
|
+
normalizeResult: normalize,
|
|
2846
|
+
async generateText(prompt, config) {
|
|
2847
|
+
const response = await request(config, "chat/completions", { model: modelOf2(config), messages: [{ role: "user", content: prompt }], provider: { allow_fallbacks: false }, stream: false });
|
|
2848
|
+
const content = messageOf(response)?.content;
|
|
2849
|
+
if (typeof content !== "string") throw new Error("OpenRouter returned no text");
|
|
2850
|
+
return content;
|
|
2851
|
+
}
|
|
2852
|
+
};
|
|
2853
|
+
|
|
2634
2854
|
// src/stored-answer-anchors.ts
|
|
2635
2855
|
function resolveStoredApiResponse(parsed) {
|
|
2636
2856
|
const nested = parsed.apiResponse;
|
|
@@ -2681,6 +2901,7 @@ export {
|
|
|
2681
2901
|
perplexityAdapter,
|
|
2682
2902
|
reparseStoredResult5,
|
|
2683
2903
|
museAdapter,
|
|
2904
|
+
openrouterAdapter,
|
|
2684
2905
|
resolveStoredApiResponse,
|
|
2685
2906
|
extractStoredAnswerAnchors
|
|
2686
2907
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
loadConfig
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-N3WQHLDI.js";
|
|
4
4
|
import {
|
|
5
5
|
PACKAGE_VERSION
|
|
6
6
|
} from "./chunk-AOJU5LKX.js";
|
|
@@ -36,7 +36,7 @@ import {
|
|
|
36
36
|
sentimentSettingsReadSchema,
|
|
37
37
|
sentimentSummaryReadSchema,
|
|
38
38
|
upgradeCommandFor
|
|
39
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-2GAXZAQJ.js";
|
|
40
40
|
|
|
41
41
|
// ../api-client-generated/src/generated/core/bodySerializer.gen.ts
|
|
42
42
|
var jsonBodySerializer = {
|
|
@@ -1063,6 +1063,24 @@ var postApiV1ProjectsByNameMeasurementPlanDraftActionsApplyPairedAssignments = (
|
|
|
1063
1063
|
...options.headers
|
|
1064
1064
|
}
|
|
1065
1065
|
});
|
|
1066
|
+
var postApiV1ProjectsByNameMeasurementPlanDraftActionsPreviewRouteMarkets = (options) => (options.client ?? client).post({
|
|
1067
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1068
|
+
url: "/api/v1/projects/{name}/measurement-plan/draft/actions/preview-route-markets",
|
|
1069
|
+
...options,
|
|
1070
|
+
headers: {
|
|
1071
|
+
"Content-Type": "application/json",
|
|
1072
|
+
...options.headers
|
|
1073
|
+
}
|
|
1074
|
+
});
|
|
1075
|
+
var postApiV1ProjectsByNameMeasurementPlanDraftActionsRouteMarkets = (options) => (options.client ?? client).post({
|
|
1076
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1077
|
+
url: "/api/v1/projects/{name}/measurement-plan/draft/actions/route-markets",
|
|
1078
|
+
...options,
|
|
1079
|
+
headers: {
|
|
1080
|
+
"Content-Type": "application/json",
|
|
1081
|
+
...options.headers
|
|
1082
|
+
}
|
|
1083
|
+
});
|
|
1066
1084
|
var postApiV1ProjectsByNameMeasurementPlanDraftActionsRemoveAssignment = (options) => (options.client ?? client).post({
|
|
1067
1085
|
security: [{ scheme: "bearer", type: "http" }],
|
|
1068
1086
|
url: "/api/v1/projects/{name}/measurement-plan/draft/actions/remove-assignment",
|
|
@@ -4228,6 +4246,25 @@ var ApiClient = class {
|
|
|
4228
4246
|
})
|
|
4229
4247
|
);
|
|
4230
4248
|
}
|
|
4249
|
+
async previewMeasurementDraftMarketRouting(project, request) {
|
|
4250
|
+
return this.invoke(
|
|
4251
|
+
() => postApiV1ProjectsByNameMeasurementPlanDraftActionsPreviewRouteMarkets({
|
|
4252
|
+
client: this.heyClient,
|
|
4253
|
+
path: { name: project },
|
|
4254
|
+
body: request
|
|
4255
|
+
})
|
|
4256
|
+
);
|
|
4257
|
+
}
|
|
4258
|
+
async routeMeasurementDraftMarkets(project, request, idempotencyKey, etag) {
|
|
4259
|
+
return this.invoke(
|
|
4260
|
+
() => postApiV1ProjectsByNameMeasurementPlanDraftActionsRouteMarkets({
|
|
4261
|
+
client: this.heyClient,
|
|
4262
|
+
path: { name: project },
|
|
4263
|
+
body: request,
|
|
4264
|
+
headers: this.measurementDraftMutationHeaders(idempotencyKey, etag)
|
|
4265
|
+
})
|
|
4266
|
+
);
|
|
4267
|
+
}
|
|
4231
4268
|
async removeMeasurementDraftAssignment(project, request, idempotencyKey, etag) {
|
|
4232
4269
|
return this.invoke(
|
|
4233
4270
|
() => postApiV1ProjectsByNameMeasurementPlanDraftActionsRemoveAssignment({
|