@canonry/canonry 7.113.0 → 7.115.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/assets/AccessControls-BTEv8WEG.js +2 -0
- package/assets/assets/{AgentSetupPage-Bqpw8_pa.js → AgentSetupPage-CgZuonLM.js} +1 -1
- package/assets/assets/{AuditHistoryPanel-0zcL5_KV.js → AuditHistoryPanel-BzSIEL75.js} +1 -1
- package/assets/assets/{BacklinksPage-Kypu_CBg.js → BacklinksPage-ChKIJpMB.js} +1 -1
- package/assets/assets/{ChartPrimitives-CuLSMZRf.js → ChartPrimitives-IodrWRFV.js} +1 -1
- package/assets/assets/{HistoryPage-CsSkwiHD.js → HistoryPage-C3iaKueQ.js} +1 -1
- package/assets/assets/MeasurementPropertyPage-Dd7B-Ixb.js +4 -0
- package/assets/assets/ProjectPage-Ce4gBiK_.js +15 -0
- package/assets/assets/{RunsPage-CtcGk2M9.js → RunsPage-DRGUFx7X.js} +1 -1
- package/assets/assets/{ServerTrafficSection-BWd-wDZM.js → ServerTrafficSection-CrPHSAa5.js} +1 -1
- package/assets/assets/{SettingsPage-DHWJtLmM.js → SettingsPage-D6iGHRSV.js} +1 -1
- package/assets/assets/ToneBadge-D3F2fbxC.js +60 -0
- package/assets/assets/{TrafficPage-C-3_NTXQ.js → TrafficPage-DtUjNJ9U.js} +1 -1
- package/assets/assets/{TrafficSourceDetailPage-CRzsuCei.js → TrafficSourceDetailPage-o-I_uVwZ.js} +1 -1
- package/assets/assets/{account-context-DDb7nBdB.js → account-context-CBRGXimz.js} +1 -1
- package/assets/assets/{agent-trust-copy-DfskKzsn.js → agent-trust-copy-Bfe0oX0J.js} +1 -1
- package/assets/assets/{card-BM8bXgNt.js → card-Biwv3_aH.js} +1 -1
- package/assets/assets/index-CWI3NboX.js +43 -0
- package/assets/assets/{query-client-BQBRNHRa.js → query-client-CsLay1me.js} +1 -1
- package/assets/assets/{react-query-CJRQ352v.js → react-query-DNgX0alO.js} +1 -1
- package/assets/assets/{react-sigma_core.esm.min-BX0xxddn.js → react-sigma_core.esm.min-BN4etdK8.js} +1 -1
- package/assets/assets/{server-traffic-F4hKNLJy.js → server-traffic-CvK4BAVZ.js} +1 -1
- package/assets/assets/service-DxCuciCi.js +1 -0
- package/assets/index.html +8 -8
- package/dist/{ads-RNE2CDPT.js → ads-JE6P76GB.js} +3 -3
- package/dist/{agent-H3RZA7V5.js → agent-BFX6GSRF.js} +7 -7
- package/dist/{agent-ask-ZVM4P74Z.js → agent-ask-SKR5ZR3S.js} +3 -3
- package/dist/{agent-conversations-WTD4LMN3.js → agent-conversations-AI6UIDDB.js} +3 -3
- package/dist/{agent-journeys-YNBUYJH3.js → agent-journeys-PBVXSG4K.js} +3 -3
- package/dist/{agent-memory-KKTISDMW.js → agent-memory-MUPLQMXZ.js} +3 -3
- package/dist/{agent-providers-VW3PJ2CU.js → agent-providers-56SGYO6F.js} +3 -3
- package/dist/{agent-transcript-DSYFCMFG.js → agent-transcript-W2TCKZHU.js} +3 -3
- package/dist/{analytics-RUC5ENEA.js → analytics-E5DJUXYW.js} +3 -3
- package/dist/{apply-3DDFBAE4.js → apply-4BBHEPRB.js} +3 -3
- package/dist/{backfill-MBD5GR5J.js → backfill-BZOT2OWS.js} +10 -10
- package/dist/{backlinks-EWALMBY5.js → backlinks-F7KVYHNP.js} +3 -3
- package/dist/{bing-KKG2726P.js → bing-BKM3V5KY.js} +3 -3
- package/dist/{bootstrap-F4CAPH2R.js → bootstrap-MIVDV6NW.js} +10 -10
- package/dist/{cdp-4VYUIAD6.js → cdp-4DP7RUMV.js} +7 -7
- package/dist/{chunk-IXAVIBKP.js → chunk-2PDXME2V.js} +1 -1
- package/dist/{chunk-WQN32NXS.js → chunk-3BMWBXHZ.js} +1 -1
- package/dist/{chunk-YSDMYHDM.js → chunk-3NUSGD54.js} +1 -1
- package/dist/{chunk-OYOIW25C.js → chunk-4ZMO7NGG.js} +4 -4
- package/dist/{chunk-HL2BOPH3.js → chunk-64EMWVEP.js} +3 -3
- package/dist/{chunk-4HRWQTQY.js → chunk-67YNSJJY.js} +7 -7
- package/dist/{chunk-IMVE7Z6S.js → chunk-A2SB6EMM.js} +1 -1
- package/dist/{chunk-DKFVL2BE.js → chunk-ADBL7P3V.js} +2 -2
- package/dist/{chunk-BHPOICVI.js → chunk-BGIH54A3.js} +1 -1
- package/dist/{chunk-NFWEMRP5.js → chunk-CY52NTTK.js} +21 -21
- package/dist/{chunk-5IEINES2.js → chunk-F44DLEKZ.js} +1 -1
- package/dist/{chunk-3NDZ43NA.js → chunk-FBQ4ACPA.js} +4 -4
- package/dist/{chunk-CAQAEJBN.js → chunk-G5O4D7I6.js} +1 -1
- package/dist/{chunk-UNZJCCDO.js → chunk-GNXQMAHP.js} +2 -2
- package/dist/{chunk-GYFRSG7F.js → chunk-GXMQORTQ.js} +2 -2
- package/dist/{chunk-5A2HNY42.js → chunk-IOMPGPSF.js} +1 -1
- package/dist/{chunk-I2X27ECL.js → chunk-L6TNLBXW.js} +2 -2
- package/dist/{chunk-BN3PZHJW.js → chunk-LA42RIFU.js} +2 -2
- package/dist/{chunk-RFJY5UW2.js → chunk-LABWX26D.js} +240 -168
- package/dist/{chunk-2QSAPDUL.js → chunk-LK6KW5JN.js} +1 -1
- package/dist/{chunk-JEDFYKBL.js → chunk-OE5AMT4X.js} +367 -367
- package/dist/{chunk-CTUWWYNV.js → chunk-OSATM2GX.js} +3 -3
- package/dist/{chunk-VBXXP3YY.js → chunk-OTW4SJ5G.js} +6 -6
- package/dist/{chunk-3TPGHPOR.js → chunk-P5EFITKV.js} +3 -3
- package/dist/{chunk-J6UROG7V.js → chunk-PSP56PWY.js} +1 -1
- package/dist/{chunk-LAGHIZVO.js → chunk-QFIUKE5K.js} +3 -3
- package/dist/{chunk-T3IRL4TY.js → chunk-QNWN7VRZ.js} +1 -1
- package/dist/{chunk-H6LGOLBW.js → chunk-R5G7SFRX.js} +4 -4
- package/dist/{chunk-NLFXESPW.js → chunk-RRBIKOMI.js} +1 -1
- package/dist/{chunk-IXJCFQFA.js → chunk-T2AF4QN7.js} +4 -4
- package/dist/{chunk-67MQRWOS.js → chunk-TKD5RVLL.js} +2 -2
- package/dist/{chunk-OXHJGGXR.js → chunk-VUPCE7GC.js} +5 -5
- package/dist/{chunk-H3OKX3IA.js → chunk-WQXRRCFC.js} +5 -5
- package/dist/{chunk-WPTF34LH.js → chunk-X3ZK4A2L.js} +279 -90
- package/dist/{chunk-TUOPSFAU.js → chunk-YNWBNADZ.js} +3 -3
- package/dist/{chunk-IBX6VC7A.js → chunk-ZPHDPDLL.js} +3 -3
- package/dist/{citations-FWWFTIOT.js → citations-4FVSVZT2.js} +4 -4
- package/dist/{cli-catalog-RCM2HUCT.js → cli-catalog-SAUMPDAU.js} +3 -3
- package/dist/{cli-commands-FGF5ZY2E.js → cli-commands-DPRC73IM.js} +7 -7
- package/dist/cli.js +13 -13
- package/dist/{competitor-KGKTAS53.js → competitor-MJZ2BYYY.js} +3 -3
- package/dist/{content-TXZ4IOGJ.js → content-GRWRFY7N.js} +3 -3
- package/dist/{dashboard-IGBJPCUX.js → dashboard-JBXWQXYU.js} +6 -6
- package/dist/{demo-UXJ6SLWM.js → demo-W3QIXSYT.js} +1 -1
- package/dist/{demo-server-VFRGZEEQ.js → demo-server-E7KMACLN.js} +12 -12
- package/dist/{discover-EJSVZOVY.js → discover-KFWFOOT5.js} +4 -4
- package/dist/{discover-eval-6U5C6O5F.js → discover-eval-DOUPPY2M.js} +3 -3
- package/dist/{doctor-ONEJYJ2A.js → doctor-ZGZ2VEAR.js} +3 -3
- package/dist/{evidence-DRQCHIWI.js → evidence-27V4BDDW.js} +3 -3
- package/dist/{export-cmd-YJ3AFLXR.js → export-cmd-HCS5ILVI.js} +3 -3
- package/dist/{ga-AP4F2LSD.js → ga-MP2CGERV.js} +3 -3
- package/dist/{gbp-W2BZILFX.js → gbp-OLZAMOYH.js} +3 -3
- package/dist/{google-CNY7J4MZ.js → google-QB5MVADA.js} +4 -4
- package/dist/{google-marketing-OT2JSJUY.js → google-marketing-LWQPSXDT.js} +1 -1
- package/dist/{health-cmd-DU33WCDD.js → health-cmd-YITDAMGQ.js} +4 -4
- package/dist/{history-HRY6TLYX.js → history-UUSJUU64.js} +3 -3
- package/dist/index.d.ts +67 -67
- package/dist/index.js +25 -25
- package/dist/{init-XQJZ6DQX.js → init-Z337GCOA.js} +12 -12
- package/dist/{insights-SMURU5LJ.js → insights-Y2CVUEG7.js} +3 -3
- package/dist/intelligence-service-2N3SLVGN.js +16 -0
- package/dist/{journeys-BASXVLUD.js → journeys-DJ7VEJHO.js} +3 -3
- package/dist/{keys-KBHFQCQ5.js → keys-DLI7ZAYO.js} +3 -3
- package/dist/{keyword-EPNX57S2.js → keyword-VXU2JWZW.js} +3 -3
- package/dist/{logs-EHWCAIDD.js → logs-WINF42ZW.js} +3 -3
- package/dist/{mcp-TIMFG2HU.js → mcp-OBWG4O3Z.js} +4 -4
- package/dist/mcp.js +9 -9
- package/dist/{measurement-plan-T2WUFQGZ.js → measurement-plan-MFZD2EVF.js} +5 -5
- package/dist/{notify-EGJHQXJY.js → notify-UXPTKXDA.js} +3 -3
- package/dist/{organic-evidence-NZ4BYT7G.js → organic-evidence-7L6ZTSAH.js} +3 -3
- package/dist/{overview-FSTEFM7S.js → overview-M3OFICCH.js} +5 -5
- package/dist/{project-ZOGGHFMI.js → project-54O4VABG.js} +3 -3
- package/dist/{project-setup-DA55HKTE.js → project-setup-KQBXILOX.js} +3 -3
- package/dist/{query-YSZCPFUW.js → query-QAX5GMLH.js} +3 -3
- package/dist/{research-C3BDNI7X.js → research-5FO3VMLG.js} +3 -3
- package/dist/{results-export-YBHQ4GJY.js → results-export-75SDUK5R.js} +3 -3
- package/dist/{run-OI4Y4CPZ.js → run-ZYFBIQJ4.js} +5 -5
- package/dist/{schedule-HI5QUYZN.js → schedule-5MXMD6MZ.js} +3 -3
- package/dist/{search-H5VREMQP.js → search-AVVB33MS.js} +3 -3
- package/dist/{serve-OVEZ6LLG.js → serve-K7VUWZ3J.js} +26 -26
- package/dist/{session-6HUFUB6Y.js → session-M6ALLPJZ.js} +13 -13
- package/dist/{settings-M3TBHMXQ.js → settings-LJ4W7KYC.js} +3 -3
- package/dist/{sitemaps-6ZZ4LAPG.js → sitemaps-E26UGDHB.js} +3 -3
- package/dist/{skills-HWXV6FII.js → skills-KDKO76BH.js} +2 -2
- package/dist/{snapshot-VSQMPHFQ.js → snapshot-H6ESNKUI.js} +3 -3
- package/dist/{src-54XVRI7X.js → src-YZ5QIJMF.js} +2 -2
- package/dist/{status-6IB2JLE6.js → status-RTXJFACN.js} +5 -5
- package/dist/{technical-aeo-PZHXLFS4.js → technical-aeo-KMN7F4ZM.js} +3 -3
- package/dist/{telemetry-K3XNIML6.js → telemetry-GKKKHJSB.js} +4 -4
- package/dist/{tools-KQD2AZTB.js → tools-J2XJFSXA.js} +11 -11
- package/dist/{traffic-ZRFDZG7J.js → traffic-H57O776E.js} +5 -5
- package/dist/{trends-Q7YV4H6S.js → trends-JD5DR6AW.js} +3 -3
- package/dist/{users-KIC522TT.js → users-TEDPJX74.js} +3 -3
- package/dist/{visibility-stats-MN7367BK.js → visibility-stats-UQLDR4QJ.js} +4 -4
- package/dist/{wordpress-7UL7Q5HH.js → wordpress-NQGK7CYA.js} +3 -3
- package/package.json +1 -1
- package/assets/assets/AccessControls-8KGSA5-k.js +0 -2
- package/assets/assets/MeasurementPropertyPage-D4PDu2k_.js +0 -4
- package/assets/assets/ProjectPage-D00B6b7C.js +0 -15
- package/assets/assets/ToneBadge-Ci54jPqm.js +0 -60
- package/assets/assets/index-IFRMBJbA.js +0 -43
- package/assets/assets/service-D08PUQzL.js +0 -1
- package/dist/intelligence-service-UEIV4CYJ.js +0 -16
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
unknownUsageObservation,
|
|
29
29
|
usdToMicros,
|
|
30
30
|
withRetry
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-LABWX26D.js";
|
|
32
32
|
|
|
33
33
|
// ../provider-answer-services/src/core/http.ts
|
|
34
34
|
var MAX_RESPONSE_BYTES = 8 * 1024 * 1024;
|
|
@@ -239,22 +239,22 @@ function enforceAnswerPresent(parsed) {
|
|
|
239
239
|
return { ...parsed, completion: { ...parsed.completion, status: CompletionStatuses.failed, error: parsed.completion.error ?? "The response carried no answer text." } };
|
|
240
240
|
}
|
|
241
241
|
function assembleEvidence(input) {
|
|
242
|
-
const { descriptor, profile:
|
|
243
|
-
const citationBasis = citationBasisFor(
|
|
242
|
+
const { descriptor, profile: profile4, parsed } = input;
|
|
243
|
+
const citationBasis = citationBasisFor(profile4.capabilities.evidence.relationships);
|
|
244
244
|
const sources = clampAnswerSourceExcerpts(parsed.sources);
|
|
245
245
|
return {
|
|
246
246
|
version: ANSWER_EVIDENCE_VERSION,
|
|
247
247
|
identity: {
|
|
248
248
|
connection: descriptor.id,
|
|
249
|
-
route: answerServiceRouteName(descriptor.id,
|
|
249
|
+
route: answerServiceRouteName(descriptor.id, profile4.id),
|
|
250
250
|
service: descriptor.id,
|
|
251
|
-
product:
|
|
252
|
-
profile:
|
|
253
|
-
settings: { ...
|
|
254
|
-
requestedServiceModel:
|
|
251
|
+
product: profile4.product,
|
|
252
|
+
profile: profile4.id,
|
|
253
|
+
settings: { ...profile4.settings },
|
|
254
|
+
requestedServiceModel: profile4.requestedServiceModel,
|
|
255
255
|
disclosedModel: parsed.disclosedModel,
|
|
256
|
-
disclosedModelKind: parsed.disclosedModel === null ? null :
|
|
257
|
-
requestPolicy:
|
|
256
|
+
disclosedModelKind: parsed.disclosedModel === null ? null : profile4.capabilities.disclosedModelKind,
|
|
257
|
+
requestPolicy: profile4.requestPolicyVersion,
|
|
258
258
|
parserVersion: descriptor.parserVersion
|
|
259
259
|
},
|
|
260
260
|
completion: parsed.completion,
|
|
@@ -265,12 +265,12 @@ function assembleEvidence(input) {
|
|
|
265
265
|
sources,
|
|
266
266
|
searchEventCount: parsed.searchEventCount,
|
|
267
267
|
reportedSearchCount: parsed.usage.searches.basis === "reported" ? parsed.usage.searches.count : null,
|
|
268
|
-
observability:
|
|
268
|
+
observability: profile4.capabilities.evidence.retrievalObservability,
|
|
269
269
|
completion: parsed.completion
|
|
270
270
|
}),
|
|
271
271
|
citationBasis,
|
|
272
272
|
citationMeasurable: citationBasis !== "none",
|
|
273
|
-
directSourceUrls:
|
|
273
|
+
directSourceUrls: profile4.capabilities.evidence.directUrls,
|
|
274
274
|
location: input.location,
|
|
275
275
|
rawTruncated: input.rawTruncated
|
|
276
276
|
};
|
|
@@ -323,20 +323,20 @@ var AnswerServiceQueryTooLongError = class extends Error {
|
|
|
323
323
|
};
|
|
324
324
|
function profileOf(descriptor, providerName) {
|
|
325
325
|
const selection = routeSelection(providerName, answerServiceRouteFamily(descriptor));
|
|
326
|
-
const
|
|
327
|
-
if (!
|
|
326
|
+
const profile4 = selection === void 0 ? void 0 : descriptor.profiles.find((item) => item.id === selection);
|
|
327
|
+
if (!profile4) {
|
|
328
328
|
throw new Error(`Select a ${descriptor.displayName} profile (${descriptor.profiles.map((item) => answerServiceRouteName(descriptor.id, item.id)).join(", ")}); the connection alone is not an engine.`);
|
|
329
329
|
}
|
|
330
|
-
return
|
|
330
|
+
return profile4;
|
|
331
331
|
}
|
|
332
332
|
function configProblem(descriptor, config) {
|
|
333
333
|
if (!config.apiKey?.trim()) return `Missing ${descriptor.displayName} API key`;
|
|
334
334
|
if (config.baseUrl) return `${descriptor.displayName} uses a fixed endpoint; remove the base URL`;
|
|
335
335
|
return null;
|
|
336
336
|
}
|
|
337
|
-
function assertRouteModel(
|
|
338
|
-
if (config.model !== void 0 && config.model !==
|
|
339
|
-
throw new Error(`Route profile "${
|
|
337
|
+
function assertRouteModel(profile4, config) {
|
|
338
|
+
if (config.model !== void 0 && config.model !== profile4.id) {
|
|
339
|
+
throw new Error(`Route profile "${profile4.id}" cannot be overridden with "${config.model}".`);
|
|
340
340
|
}
|
|
341
341
|
}
|
|
342
342
|
function incompleteMessage(descriptor, parsed) {
|
|
@@ -355,41 +355,41 @@ function incompleteMessage(descriptor, parsed) {
|
|
|
355
355
|
function createAnswerServiceAdapter(definition, options = {}) {
|
|
356
356
|
const { descriptor } = definition;
|
|
357
357
|
const family = answerServiceRouteFamily(descriptor);
|
|
358
|
-
const profileIds = descriptor.profiles.map((
|
|
358
|
+
const profileIds = descriptor.profiles.map((profile4) => profile4.id);
|
|
359
359
|
const profilePattern = new RegExp(`^(?:${profileIds.map(escapeRegExp).join("|")})$`);
|
|
360
|
-
const transport = (config,
|
|
360
|
+
const transport = (config, profile4) => ({
|
|
361
361
|
apiKey: config.apiKey ?? "",
|
|
362
|
-
timeoutMs:
|
|
362
|
+
timeoutMs: profile4.timeoutMs,
|
|
363
363
|
...options.fetchImpl ? { fetchImpl: options.fetchImpl } : {},
|
|
364
364
|
...options.sleep ? { sleep: options.sleep } : {}
|
|
365
365
|
});
|
|
366
366
|
async function execute(input, config) {
|
|
367
|
-
const
|
|
368
|
-
assertRouteModel(
|
|
367
|
+
const profile4 = profileOf(descriptor, config.provider);
|
|
368
|
+
assertRouteModel(profile4, config);
|
|
369
369
|
const problem = configProblem(descriptor, config);
|
|
370
370
|
if (problem) throw new Error(problem);
|
|
371
|
-
if (
|
|
372
|
-
throw new Error(`${descriptor.displayName} profile "${
|
|
371
|
+
if (profile4.execution === "job") {
|
|
372
|
+
throw new Error(`${descriptor.displayName} profile "${profile4.id}" runs as an upstream job, which this release cannot run yet.`);
|
|
373
373
|
}
|
|
374
|
-
const maxQueryChars =
|
|
374
|
+
const maxQueryChars = profile4.capabilities.maxQueryChars;
|
|
375
375
|
const queryChars = [...input.query].length;
|
|
376
376
|
if (maxQueryChars !== null && queryChars > maxQueryChars) {
|
|
377
377
|
throw new AnswerServiceQueryTooLongError(descriptor.displayName, maxQueryChars, queryChars);
|
|
378
378
|
}
|
|
379
|
-
const offered = resolveLocationTreatment(input.location,
|
|
380
|
-
const built = definition.buildRequest({ query: input.query, profile:
|
|
379
|
+
const offered = resolveLocationTreatment(input.location, profile4.capabilities.location, profile4.capabilities.location.serviceDefault ?? null);
|
|
380
|
+
const built = definition.buildRequest({ query: input.query, profile: profile4, location: offered });
|
|
381
381
|
const { request } = built;
|
|
382
382
|
const location = finalizeLocationTreatment(offered, built.sentLocation);
|
|
383
383
|
let parsed;
|
|
384
384
|
let raw;
|
|
385
385
|
let bytes;
|
|
386
|
-
if (
|
|
386
|
+
if (profile4.transport === "sse") {
|
|
387
387
|
if (!definition.parseEvents || !definition.isTerminalEvent) throw new Error(`${descriptor.displayName} has no stream parser`);
|
|
388
388
|
let events;
|
|
389
389
|
let ended;
|
|
390
390
|
let requestId;
|
|
391
391
|
try {
|
|
392
|
-
const streamed = await requestStream(descriptor, request, transport(config,
|
|
392
|
+
const streamed = await requestStream(descriptor, request, transport(config, profile4), definition.isTerminalEvent, definition.errorMessage);
|
|
393
393
|
events = streamed.events;
|
|
394
394
|
ended = streamed.ended;
|
|
395
395
|
requestId = streamed.requestId;
|
|
@@ -401,18 +401,18 @@ function createAnswerServiceAdapter(definition, options = {}) {
|
|
|
401
401
|
requestId = error.requestId;
|
|
402
402
|
bytes = events.reduce((total, event) => total + event.data.length, 0);
|
|
403
403
|
}
|
|
404
|
-
parsed = enforceStreamCompletion(definition.parseEvents(events, { profile:
|
|
404
|
+
parsed = enforceStreamCompletion(definition.parseEvents(events, { profile: profile4, headerRequestId: requestId, ended }), ended);
|
|
405
405
|
raw = { events: events.map((event) => ({ event: event.event, data: event.data })), ended };
|
|
406
406
|
} else {
|
|
407
407
|
if (!definition.parseResponse) throw new Error(`${descriptor.displayName} has no response parser`);
|
|
408
|
-
const response = await requestJson(descriptor, request, transport(config,
|
|
409
|
-
parsed = definition.parseResponse(response.body, { profile:
|
|
408
|
+
const response = await requestJson(descriptor, request, transport(config, profile4), definition.errorMessage);
|
|
409
|
+
parsed = definition.parseResponse(response.body, { profile: profile4, headerRequestId: response.requestId });
|
|
410
410
|
raw = response.body;
|
|
411
411
|
bytes = response.bytes;
|
|
412
412
|
}
|
|
413
413
|
parsed = enforceAnswerPresent(parsed);
|
|
414
414
|
const stored = boundRawResponse(raw, bytes);
|
|
415
|
-
const evidence = assembleEvidence({ descriptor, profile:
|
|
415
|
+
const evidence = assembleEvidence({ descriptor, profile: profile4, parsed, location, rawTruncated: stored.truncated });
|
|
416
416
|
if (evidence.completion.status !== CompletionStatuses.complete) {
|
|
417
417
|
throw new IncompleteAnswerError(incompleteMessage(descriptor, parsed), evidence, parsed.answerText, stored.raw, { resumable: false });
|
|
418
418
|
}
|
|
@@ -452,15 +452,15 @@ function createAnswerServiceAdapter(definition, options = {}) {
|
|
|
452
452
|
}
|
|
453
453
|
}
|
|
454
454
|
function routeAdapter(route) {
|
|
455
|
-
const
|
|
455
|
+
const profile4 = profileOf(descriptor, route.name);
|
|
456
456
|
return {
|
|
457
457
|
...connection,
|
|
458
458
|
name: route.name,
|
|
459
|
-
displayName: `${
|
|
459
|
+
displayName: `${profile4.displayName} \xB7 ${descriptor.displayName}`,
|
|
460
460
|
// Only a service that sends every requested field may claim the answer was measured from there.
|
|
461
|
-
supportsLocationContext:
|
|
462
|
-
capabilities: { textGeneration: false, groundedAnswer: true, workflows: [...
|
|
463
|
-
modelRegistry: { ...connection.modelRegistry, defaultModel:
|
|
461
|
+
supportsLocationContext: profile4.capabilities.location.granularity === "full",
|
|
462
|
+
capabilities: { textGeneration: false, groundedAnswer: true, workflows: [...profile4.workflows] },
|
|
463
|
+
modelRegistry: { ...connection.modelRegistry, defaultModel: profile4.id }
|
|
464
464
|
};
|
|
465
465
|
}
|
|
466
466
|
const connection = {
|
|
@@ -476,7 +476,7 @@ function createAnswerServiceAdapter(definition, options = {}) {
|
|
|
476
476
|
keyUrl: descriptor.keyUrl,
|
|
477
477
|
modelRegistry: {
|
|
478
478
|
defaultModel: "",
|
|
479
|
-
knownModels: descriptor.profiles.map((
|
|
479
|
+
knownModels: descriptor.profiles.map((profile4) => ({ id: profile4.id, displayName: profile4.displayName, tier: "standard" })),
|
|
480
480
|
validationPattern: profilePattern,
|
|
481
481
|
validationHint: `one of the ${descriptor.displayName} profiles: ${profileIds.join(", ")}`
|
|
482
482
|
},
|
|
@@ -493,6 +493,194 @@ function createAnswerServiceAdapter(definition, options = {}) {
|
|
|
493
493
|
return connection;
|
|
494
494
|
}
|
|
495
495
|
|
|
496
|
+
// ../provider-answer-services/src/services/cloro/parse.ts
|
|
497
|
+
function nonEmptyString(value) {
|
|
498
|
+
return typeof value === "string" && value.trim() ? value : null;
|
|
499
|
+
}
|
|
500
|
+
function records(value) {
|
|
501
|
+
if (!Array.isArray(value)) return [];
|
|
502
|
+
return value.map(asRecord).filter((item) => item !== null);
|
|
503
|
+
}
|
|
504
|
+
function sourcesOf(items, relationship) {
|
|
505
|
+
const byUrl = /* @__PURE__ */ new Map();
|
|
506
|
+
for (const item of records(items)) {
|
|
507
|
+
const url = nonEmptyString(item.url);
|
|
508
|
+
if (!url) continue;
|
|
509
|
+
const existing = byUrl.get(url);
|
|
510
|
+
if (existing) {
|
|
511
|
+
existing.title ??= nonEmptyString(item.label);
|
|
512
|
+
continue;
|
|
513
|
+
}
|
|
514
|
+
byUrl.set(url, {
|
|
515
|
+
url,
|
|
516
|
+
title: nonEmptyString(item.label),
|
|
517
|
+
relationship,
|
|
518
|
+
rank: null,
|
|
519
|
+
// Only ChatGPT sends `datePublished`, verbatim (an ISO date on pills, a display date on sources).
|
|
520
|
+
publishedAt: nonEmptyString(item.datePublished),
|
|
521
|
+
upstreamId: null
|
|
522
|
+
});
|
|
523
|
+
}
|
|
524
|
+
return [...byUrl.values()];
|
|
525
|
+
}
|
|
526
|
+
function sourcesRelationship(profileId) {
|
|
527
|
+
return profileId === "bing-aimode" ? SourceRelationships["page-read"] : SourceRelationships["answer-support"];
|
|
528
|
+
}
|
|
529
|
+
function parseCloroMonitorResponse(body, context) {
|
|
530
|
+
const result = asRecord(body.result) ?? {};
|
|
531
|
+
const answerText = typeof result.text === "string" ? result.text : null;
|
|
532
|
+
const failure2 = body.success === false ? "cloro reported success: false." : answerText === null ? "The response carried no answer text." : null;
|
|
533
|
+
const completion = {
|
|
534
|
+
status: failure2 ? CompletionStatuses.failed : CompletionStatuses.complete,
|
|
535
|
+
finishReason: null,
|
|
536
|
+
upstreamStatus: null,
|
|
537
|
+
upstreamRequestId: context.headerRequestId,
|
|
538
|
+
upstreamJobId: null,
|
|
539
|
+
error: failure2
|
|
540
|
+
};
|
|
541
|
+
return {
|
|
542
|
+
answerText,
|
|
543
|
+
sources: [
|
|
544
|
+
...sourcesOf(result.citationPills, SourceRelationships["explicit-citation"]),
|
|
545
|
+
...sourcesOf(result.sources, sourcesRelationship(context.profile.id))
|
|
546
|
+
],
|
|
547
|
+
// Gemini, Google AI Mode and Bing AI Mode return no query fan-out. ChatGPT returns it only
|
|
548
|
+
// with the paid `include.searchQueries`, which is not sent.
|
|
549
|
+
searchQueries: [],
|
|
550
|
+
searchEventCount: 0,
|
|
551
|
+
completion,
|
|
552
|
+
usage: unknownUsageObservation(),
|
|
553
|
+
disclosedModel: context.profile.id === "chatgpt" ? nonEmptyString(result.model) : null
|
|
554
|
+
};
|
|
555
|
+
}
|
|
556
|
+
var CODE_EXPLANATIONS = {
|
|
557
|
+
MISSING_API_KEY: "The cloro API key is missing or invalid",
|
|
558
|
+
INVALID_API_KEY_FORMAT: "The cloro API key is missing or invalid",
|
|
559
|
+
INVALID_OR_EXPIRED_API_KEY: "The cloro API key is missing or invalid",
|
|
560
|
+
INSUFFICIENT_CREDITS: "The cloro account is out of credits"
|
|
561
|
+
};
|
|
562
|
+
function cloroErrorMessage(body) {
|
|
563
|
+
const error = asRecord(asRecord(body)?.error);
|
|
564
|
+
if (!error) return null;
|
|
565
|
+
const message = nonEmptyString(error.message);
|
|
566
|
+
const code = nonEmptyString(error.code);
|
|
567
|
+
const fields = records(error.details).map((item) => [nonEmptyString(item.field), nonEmptyString(item.message)].filter((part) => part !== null).join(": ")).filter(Boolean);
|
|
568
|
+
const text = [message, fields.length > 0 ? fields.join("; ") : null].filter((part) => part !== null).join(": ");
|
|
569
|
+
const detail = text && code ? `${text} (${code})` : text || code;
|
|
570
|
+
const explanation = code ? CODE_EXPLANATIONS[code] : void 0;
|
|
571
|
+
if (explanation) return detail ? `${explanation}. cloro said: ${detail}` : explanation;
|
|
572
|
+
return detail;
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
// ../provider-answer-services/src/services/cloro/descriptor.ts
|
|
576
|
+
var CLORO_DEFAULT_COUNTRY = "US";
|
|
577
|
+
function capabilities(id, disclosedModelKind, maxQueryChars) {
|
|
578
|
+
return {
|
|
579
|
+
groundedAnswer: true,
|
|
580
|
+
textGeneration: false,
|
|
581
|
+
structuredOutput: false,
|
|
582
|
+
evidence: {
|
|
583
|
+
// `citationPills` are the citations shown inline in the answer.
|
|
584
|
+
// `sources` are answer support on ChatGPT, Gemini and Google AI Mode
|
|
585
|
+
// ("the pages ChatGPT used for the answer", "the citations behind the
|
|
586
|
+
// answer") and page reads on Bing AI Mode ("first the pages Bing read,
|
|
587
|
+
// then any other page that a citation chip links").
|
|
588
|
+
// Neither carries character offsets into `text`.
|
|
589
|
+
relationships: [SourceRelationships["explicit-citation"], sourcesRelationship(id)],
|
|
590
|
+
spans: false,
|
|
591
|
+
// No search events are reported; only the returned sources show retrieval.
|
|
592
|
+
retrievalObservability: "sources",
|
|
593
|
+
// Pill URLs are documented as direct. AI Mode keeps Google's redirect in a separate `redirectLink`.
|
|
594
|
+
directUrls: true
|
|
595
|
+
},
|
|
596
|
+
// `country` routes the request through a proxy in that country. The
|
|
597
|
+
// surface decides how much the location changes the answer. `state`
|
|
598
|
+
// costs +2 credits and is not sent.
|
|
599
|
+
location: { granularity: "country", strength: "hint", serviceDefault: { country: CLORO_DEFAULT_COUNTRY } },
|
|
600
|
+
filters: { includeDomains: "none", excludeDomains: "none" },
|
|
601
|
+
// "`prompt`: 1–10,000 characters". Bing AI Mode accepts 3,500.
|
|
602
|
+
maxQueryChars,
|
|
603
|
+
disclosedModelKind,
|
|
604
|
+
// The response body carries no amount. cloro bills in credits and reports
|
|
605
|
+
// the charge only in the `X-Credits-Charged` header.
|
|
606
|
+
costBasis: CostBases.unknown
|
|
607
|
+
};
|
|
608
|
+
}
|
|
609
|
+
function profile(input) {
|
|
610
|
+
return {
|
|
611
|
+
id: input.id,
|
|
612
|
+
displayName: input.displayName,
|
|
613
|
+
description: input.description,
|
|
614
|
+
// The path after `/v1/`. It is `monitor/<profile id>` unless the endpoint has a different name.
|
|
615
|
+
product: input.endpoint ?? `monitor/${input.id}`,
|
|
616
|
+
execution: "sync",
|
|
617
|
+
transport: "json",
|
|
618
|
+
// cloro asks for a client timeout of at least 5 minutes: it starts no new
|
|
619
|
+
// attempt after 5 minutes, but an attempt that is running can still
|
|
620
|
+
// finish and be charged. One more minute is kept as headroom.
|
|
621
|
+
timeoutMs: 36e4,
|
|
622
|
+
// The request names no model; the surface chooses it.
|
|
623
|
+
requestedServiceModel: null,
|
|
624
|
+
settings: {},
|
|
625
|
+
requestPolicyVersion: "cloro-monitor-v1",
|
|
626
|
+
capabilities: capabilities(input.id, input.disclosedModelKind ?? DisclosedModelKinds.unknown, input.maxQueryChars ?? 1e4),
|
|
627
|
+
workflows: [ProviderWorkflows.research, ProviderWorkflows.snapshot, ProviderWorkflows["visibility-sweep"]]
|
|
628
|
+
};
|
|
629
|
+
}
|
|
630
|
+
var cloroDescriptor = {
|
|
631
|
+
id: "cloro",
|
|
632
|
+
displayName: "cloro",
|
|
633
|
+
keyUrl: "https://dashboard.cloro.dev/api-keys",
|
|
634
|
+
vendorDocsUrl: "https://cloro.dev/docs/api-reference/introduction",
|
|
635
|
+
docsPath: "docs/providers/answer-services/cloro.md",
|
|
636
|
+
auth: { scheme: "bearer" },
|
|
637
|
+
baseUrl: "https://api.cloro.dev",
|
|
638
|
+
settings: {
|
|
639
|
+
fields: [{ key: "apiKey", kind: "secret", required: true, env: "CLORO_API_KEY", label: "API key" }],
|
|
640
|
+
allowBaseUrl: false,
|
|
641
|
+
allowModel: false,
|
|
642
|
+
// `GET /v1/credits` is free (0 credits) and answers 401 for a bad key.
|
|
643
|
+
keyCheck: { method: "GET", path: "/v1/credits" }
|
|
644
|
+
},
|
|
645
|
+
// The Free plan allows 1 concurrent request; a second one gets a 429.
|
|
646
|
+
defaultQuota: { maxConcurrency: 1, maxRequestsPerMinute: 10, maxRequestsPerDay: 1e3 },
|
|
647
|
+
// cloro charges only for a 200, so an error is never billed. 429 and 503
|
|
648
|
+
// are rejections to retry after a wait. A 500 comes after cloro has
|
|
649
|
+
// already retried up to 5 attempts, so it is not retried again.
|
|
650
|
+
retry: { statuses: [429, 503] },
|
|
651
|
+
parserVersion: "cloro-monitor-1",
|
|
652
|
+
profiles: [
|
|
653
|
+
profile({ id: "chatgpt", displayName: "ChatGPT", description: "The ChatGPT answer a logged-out visitor sees, with web search.", disclosedModelKind: DisclosedModelKinds["foundation-model"] }),
|
|
654
|
+
profile({ id: "gemini", displayName: "Gemini", description: "The Gemini answer a logged-out visitor sees." }),
|
|
655
|
+
profile({ id: "aimode", displayName: "Google AI Mode", description: "The Google AI Mode answer a logged-out visitor sees." }),
|
|
656
|
+
// cloro measures the 3,500 limit after URL encoding, so a query in a
|
|
657
|
+
// non-Latin script can get a 400 with fewer characters.
|
|
658
|
+
profile({ id: "bing-aimode", displayName: "Bing AI Mode", description: "The Bing AI Mode answer a logged-out visitor sees.", endpoint: "monitor/bing/aimode", maxQueryChars: 3500 })
|
|
659
|
+
]
|
|
660
|
+
};
|
|
661
|
+
|
|
662
|
+
// ../provider-answer-services/src/services/cloro/request.ts
|
|
663
|
+
function buildCloroMonitorRequest({ query, profile: profile4, location }) {
|
|
664
|
+
const offered = location.sent?.country?.trim().toUpperCase();
|
|
665
|
+
const country = offered && /^[A-Z]{2}$/.test(offered) ? offered : null;
|
|
666
|
+
return {
|
|
667
|
+
request: {
|
|
668
|
+
method: "POST",
|
|
669
|
+
path: `/v1/${profile4.product}`,
|
|
670
|
+
body: { prompt: query, country: country ?? CLORO_DEFAULT_COUNTRY }
|
|
671
|
+
},
|
|
672
|
+
sentLocation: country ? { country } : null
|
|
673
|
+
};
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
// ../provider-answer-services/src/services/cloro/index.ts
|
|
677
|
+
var cloroMonitorService = {
|
|
678
|
+
descriptor: cloroDescriptor,
|
|
679
|
+
buildRequest: buildCloroMonitorRequest,
|
|
680
|
+
parseResponse: parseCloroMonitorResponse,
|
|
681
|
+
errorMessage: cloroErrorMessage
|
|
682
|
+
};
|
|
683
|
+
|
|
496
684
|
// ../provider-answer-services/src/services/exa/descriptor.ts
|
|
497
685
|
var CAPABILITIES = {
|
|
498
686
|
groundedAnswer: true,
|
|
@@ -520,7 +708,7 @@ var CAPABILITIES = {
|
|
|
520
708
|
// `costDollars` is documented as an estimate, not an invoice.
|
|
521
709
|
costBasis: CostBases.estimated
|
|
522
710
|
};
|
|
523
|
-
function
|
|
711
|
+
function profile2(input) {
|
|
524
712
|
return {
|
|
525
713
|
id: input.id,
|
|
526
714
|
displayName: input.displayName,
|
|
@@ -559,32 +747,32 @@ var exaDescriptor = {
|
|
|
559
747
|
retry: { statuses: [429, 503] },
|
|
560
748
|
parserVersion: "exa-answer-1",
|
|
561
749
|
profiles: [
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
750
|
+
profile2({ id: "fast", displayName: "Fast", model: "exa-fast", timeoutMs: 6e4, description: "Exa Answer with the exa-fast model." }),
|
|
751
|
+
profile2({ id: "standard", displayName: "Standard", model: "exa", timeoutMs: 12e4, description: "Exa Answer with the default exa model." }),
|
|
752
|
+
profile2({ id: "pro", displayName: "Pro", model: "exa-pro", timeoutMs: 18e4, description: "Exa Answer with the exa-pro model." }),
|
|
753
|
+
profile2({ id: "research", displayName: "Research", model: "exa-research", timeoutMs: 3e5, description: "Exa Answer with the exa-research model. Waits up to five minutes per query." })
|
|
566
754
|
]
|
|
567
755
|
};
|
|
568
756
|
|
|
569
757
|
// ../provider-answer-services/src/services/exa/parse.ts
|
|
570
|
-
function
|
|
758
|
+
function nonEmptyString2(value) {
|
|
571
759
|
return typeof value === "string" && value.trim() ? value : null;
|
|
572
760
|
}
|
|
573
|
-
function
|
|
761
|
+
function sourcesOf2(citations) {
|
|
574
762
|
if (!Array.isArray(citations)) return [];
|
|
575
763
|
const sources = [];
|
|
576
764
|
for (const item of citations) {
|
|
577
765
|
const citation = asRecord(item);
|
|
578
|
-
const url =
|
|
766
|
+
const url = nonEmptyString2(citation?.url);
|
|
579
767
|
if (!citation || !url) continue;
|
|
580
768
|
sources.push({
|
|
581
769
|
url,
|
|
582
|
-
title:
|
|
770
|
+
title: nonEmptyString2(citation.title),
|
|
583
771
|
relationship: SourceRelationships["answer-support"],
|
|
584
772
|
// The list order is not documented as a ranking.
|
|
585
773
|
rank: null,
|
|
586
|
-
publishedAt:
|
|
587
|
-
upstreamId:
|
|
774
|
+
publishedAt: nonEmptyString2(citation.publishedDate),
|
|
775
|
+
upstreamId: nonEmptyString2(citation.id)
|
|
588
776
|
});
|
|
589
777
|
}
|
|
590
778
|
return sources;
|
|
@@ -602,13 +790,13 @@ function parseExaAnswer(body, context) {
|
|
|
602
790
|
status: answerText === null ? CompletionStatuses.failed : CompletionStatuses.complete,
|
|
603
791
|
finishReason: null,
|
|
604
792
|
upstreamStatus: null,
|
|
605
|
-
upstreamRequestId:
|
|
793
|
+
upstreamRequestId: nonEmptyString2(body.requestId) ?? context.headerRequestId,
|
|
606
794
|
upstreamJobId: null,
|
|
607
795
|
error: answerText !== null ? null : asRecord(body.answer) ? STRUCTURED_ANSWER_ERROR : "The response carried no answer."
|
|
608
796
|
};
|
|
609
797
|
return {
|
|
610
798
|
answerText,
|
|
611
|
-
sources:
|
|
799
|
+
sources: sourcesOf2(body.citations),
|
|
612
800
|
searchQueries: [],
|
|
613
801
|
searchEventCount: 0,
|
|
614
802
|
completion,
|
|
@@ -625,8 +813,8 @@ var TAG_EXPLANATIONS = {
|
|
|
625
813
|
};
|
|
626
814
|
function exaErrorMessage(body) {
|
|
627
815
|
const record = asRecord(body);
|
|
628
|
-
const message =
|
|
629
|
-
const tag =
|
|
816
|
+
const message = nonEmptyString2(record?.error);
|
|
817
|
+
const tag = nonEmptyString2(record?.tag);
|
|
630
818
|
const detail = message && tag ? `${message} (${tag})` : message ?? tag;
|
|
631
819
|
const explanation = tag ? TAG_EXPLANATIONS[tag] : void 0;
|
|
632
820
|
if (explanation) return detail ? `${explanation}. Exa said: ${detail}` : explanation;
|
|
@@ -634,7 +822,7 @@ function exaErrorMessage(body) {
|
|
|
634
822
|
}
|
|
635
823
|
|
|
636
824
|
// ../provider-answer-services/src/services/exa/request.ts
|
|
637
|
-
function buildExaAnswerRequest({ query, profile:
|
|
825
|
+
function buildExaAnswerRequest({ query, profile: profile4, location }) {
|
|
638
826
|
const country = location.sent?.country;
|
|
639
827
|
return {
|
|
640
828
|
request: {
|
|
@@ -642,7 +830,7 @@ function buildExaAnswerRequest({ query, profile: profile3, location }) {
|
|
|
642
830
|
path: "/answer",
|
|
643
831
|
body: {
|
|
644
832
|
query,
|
|
645
|
-
...
|
|
833
|
+
...profile4.settings,
|
|
646
834
|
...country ? { userLocation: { country } } : {}
|
|
647
835
|
}
|
|
648
836
|
},
|
|
@@ -692,7 +880,7 @@ var CAPABILITIES2 = {
|
|
|
692
880
|
// The response carries no amount; Parallel bills per successful request.
|
|
693
881
|
costBasis: CostBases.unknown
|
|
694
882
|
};
|
|
695
|
-
function
|
|
883
|
+
function profile3(input) {
|
|
696
884
|
return {
|
|
697
885
|
id: input.effort,
|
|
698
886
|
displayName: input.displayName,
|
|
@@ -736,20 +924,20 @@ var parallelDescriptor = {
|
|
|
736
924
|
// to 20 and 30 to 60 seconds), because a request Canonry abandons may still
|
|
737
925
|
// finish upstream and be charged.
|
|
738
926
|
profiles: [
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
927
|
+
profile3({ effort: "low", displayName: "Low effort", timeoutMs: 6e4, description: "Parallel Responses with low reasoning effort, for simple fact questions." }),
|
|
928
|
+
profile3({ effort: "medium", displayName: "Medium effort", timeoutMs: 12e4, description: "Parallel Responses with medium reasoning effort (Parallel's default), for questions that need several searches." }),
|
|
929
|
+
profile3({ effort: "high", displayName: "High effort", timeoutMs: 18e4, description: "Parallel Responses with high reasoning effort, for deep research. Waits up to three minutes per query." })
|
|
742
930
|
]
|
|
743
931
|
};
|
|
744
932
|
|
|
745
933
|
// ../provider-answer-services/src/services/parallel/parse.ts
|
|
746
|
-
function
|
|
934
|
+
function nonEmptyString3(value) {
|
|
747
935
|
return typeof value === "string" && value.trim() ? value : null;
|
|
748
936
|
}
|
|
749
937
|
function count(value) {
|
|
750
938
|
return typeof value === "number" && Number.isInteger(value) && value >= 0 ? value : null;
|
|
751
939
|
}
|
|
752
|
-
function
|
|
940
|
+
function records2(value) {
|
|
753
941
|
if (!Array.isArray(value)) return [];
|
|
754
942
|
return value.map(asRecord).filter((item) => item !== null);
|
|
755
943
|
}
|
|
@@ -761,19 +949,19 @@ function readAnswer(messages) {
|
|
|
761
949
|
let text = null;
|
|
762
950
|
for (const message of messages) {
|
|
763
951
|
let messageStarted = false;
|
|
764
|
-
for (const part of
|
|
952
|
+
for (const part of records2(message.content)) {
|
|
765
953
|
if (part.type !== "output_text" || typeof part.text !== "string") continue;
|
|
766
954
|
if (text === null) text = "";
|
|
767
955
|
else if (!messageStarted) text += "\n\n";
|
|
768
956
|
messageStarted = true;
|
|
769
957
|
const offset = text.length;
|
|
770
958
|
text += part.text;
|
|
771
|
-
for (const annotation of
|
|
772
|
-
const url =
|
|
959
|
+
for (const annotation of records2(part.annotations)) {
|
|
960
|
+
const url = nonEmptyString3(annotation.url);
|
|
773
961
|
if (annotation.type !== "url_citation" || !url) continue;
|
|
774
962
|
const cited = byUrl.get(url) ?? { title: null, spans: [] };
|
|
775
963
|
byUrl.set(url, cited);
|
|
776
|
-
cited.title ??=
|
|
964
|
+
cited.title ??= nonEmptyString3(annotation.title);
|
|
777
965
|
const start = count(annotation.start_index);
|
|
778
966
|
const end = count(annotation.end_index);
|
|
779
967
|
if (start === null || end === null || end < start) continue;
|
|
@@ -801,12 +989,12 @@ function readSearchTrail(output) {
|
|
|
801
989
|
const action = asRecord(item.action);
|
|
802
990
|
if (action?.type === "search") {
|
|
803
991
|
trail.searchCount++;
|
|
804
|
-
const queries = Array.isArray(action.queries) ? action.queries.map(
|
|
805
|
-
const single =
|
|
992
|
+
const queries = Array.isArray(action.queries) ? action.queries.map(nonEmptyString3).filter((query) => query !== null) : [];
|
|
993
|
+
const single = nonEmptyString3(action.query);
|
|
806
994
|
trail.searchQueries.push(...queries.length > 0 ? queries : single ? [single] : []);
|
|
807
995
|
} else if (action?.type === "open_page") {
|
|
808
996
|
trail.pageReadCount++;
|
|
809
|
-
const url =
|
|
997
|
+
const url = nonEmptyString3(action.url);
|
|
810
998
|
if (!url) continue;
|
|
811
999
|
trail.pageReads.push({
|
|
812
1000
|
url,
|
|
@@ -814,8 +1002,8 @@ function readSearchTrail(output) {
|
|
|
814
1002
|
relationship: SourceRelationships["page-read"],
|
|
815
1003
|
rank: null,
|
|
816
1004
|
publishedAt: null,
|
|
817
|
-
upstreamId:
|
|
818
|
-
status:
|
|
1005
|
+
upstreamId: nonEmptyString3(item.id),
|
|
1006
|
+
status: nonEmptyString3(item.status)
|
|
819
1007
|
});
|
|
820
1008
|
}
|
|
821
1009
|
}
|
|
@@ -824,18 +1012,18 @@ function readSearchTrail(output) {
|
|
|
824
1012
|
function messageStatus(messages) {
|
|
825
1013
|
if (messages.length === 0) return null;
|
|
826
1014
|
const unfinished = messages.find((message) => message.status !== "completed");
|
|
827
|
-
return unfinished ?
|
|
1015
|
+
return unfinished ? nonEmptyString3(unfinished.status) ?? "missing a status" : "completed";
|
|
828
1016
|
}
|
|
829
1017
|
function failureMessage(error) {
|
|
830
1018
|
const record = asRecord(error);
|
|
831
|
-
const message =
|
|
832
|
-
const code =
|
|
1019
|
+
const message = nonEmptyString3(record?.message);
|
|
1020
|
+
const code = nonEmptyString3(record?.code);
|
|
833
1021
|
if (message && code) return `${message} (${code})`;
|
|
834
1022
|
return message ?? code ?? "Parallel reported a failure without a message.";
|
|
835
1023
|
}
|
|
836
1024
|
function completionOf(body, messages, context) {
|
|
837
|
-
const status =
|
|
838
|
-
const id =
|
|
1025
|
+
const status = nonEmptyString3(body.status);
|
|
1026
|
+
const id = nonEmptyString3(body.id);
|
|
839
1027
|
const base = {
|
|
840
1028
|
status: CompletionStatuses.failed,
|
|
841
1029
|
finishReason: null,
|
|
@@ -851,7 +1039,7 @@ function completionOf(body, messages, context) {
|
|
|
851
1039
|
if (answerStatus !== "completed") return { ...base, status: CompletionStatuses.partial, error: `The answer message is ${answerStatus}, although the response is completed.` };
|
|
852
1040
|
return { ...base, status: CompletionStatuses.complete };
|
|
853
1041
|
case "incomplete": {
|
|
854
|
-
const reason =
|
|
1042
|
+
const reason = nonEmptyString3(asRecord(body.incomplete_details)?.reason);
|
|
855
1043
|
return { ...base, status: CompletionStatuses.partial, finishReason: reason, error: `Parallel stopped before the answer was finished (${reason ?? "no reason given"}).` };
|
|
856
1044
|
}
|
|
857
1045
|
case "failed":
|
|
@@ -884,7 +1072,7 @@ function usageOf2(body, trail, complete) {
|
|
|
884
1072
|
return usage;
|
|
885
1073
|
}
|
|
886
1074
|
function parseParallelResponse(body, context) {
|
|
887
|
-
const output =
|
|
1075
|
+
const output = records2(body.output);
|
|
888
1076
|
const messages = answerMessages(output);
|
|
889
1077
|
const answer = readAnswer(messages);
|
|
890
1078
|
const trail = readSearchTrail(output);
|
|
@@ -896,7 +1084,7 @@ function parseParallelResponse(body, context) {
|
|
|
896
1084
|
searchEventCount: trail.searchCount,
|
|
897
1085
|
completion,
|
|
898
1086
|
usage: usageOf2(body, trail, completion.status === CompletionStatuses.complete),
|
|
899
|
-
disclosedModel:
|
|
1087
|
+
disclosedModel: nonEmptyString3(body.model)
|
|
900
1088
|
};
|
|
901
1089
|
}
|
|
902
1090
|
function parallelErrorMessage(body) {
|
|
@@ -904,28 +1092,28 @@ function parallelErrorMessage(body) {
|
|
|
904
1092
|
if (!record) return null;
|
|
905
1093
|
const error = asRecord(record.error);
|
|
906
1094
|
if (error) {
|
|
907
|
-
const message =
|
|
908
|
-
const kind = [
|
|
1095
|
+
const message = nonEmptyString3(error.message);
|
|
1096
|
+
const kind = [nonEmptyString3(error.type), nonEmptyString3(error.code)].filter((value) => value !== null);
|
|
909
1097
|
if (message && kind.length > 0) return `${message} (${kind.join(", ")})`;
|
|
910
1098
|
return message ?? (kind.length > 0 ? kind.join(", ") : null);
|
|
911
1099
|
}
|
|
912
1100
|
if (Array.isArray(record.detail)) {
|
|
913
|
-
const problems =
|
|
914
|
-
const message =
|
|
1101
|
+
const problems = records2(record.detail).map((item) => {
|
|
1102
|
+
const message = nonEmptyString3(item.msg);
|
|
915
1103
|
const where = Array.isArray(item.loc) ? item.loc.filter((part) => typeof part === "string" || typeof part === "number").join(".") : "";
|
|
916
1104
|
return message && where ? `${where}: ${message}` : message;
|
|
917
1105
|
}).filter((problem) => problem !== null);
|
|
918
1106
|
return problems.length > 0 ? problems.join("; ") : null;
|
|
919
1107
|
}
|
|
920
|
-
return
|
|
1108
|
+
return nonEmptyString3(record.error) ?? nonEmptyString3(record.detail);
|
|
921
1109
|
}
|
|
922
1110
|
|
|
923
1111
|
// ../provider-answer-services/src/services/parallel/request.ts
|
|
924
|
-
function buildParallelResponsesRequest({ query, profile:
|
|
925
|
-
const { model, stream } =
|
|
926
|
-
const effort =
|
|
1112
|
+
function buildParallelResponsesRequest({ query, profile: profile4 }) {
|
|
1113
|
+
const { model, stream } = profile4.settings;
|
|
1114
|
+
const effort = profile4.settings[PARALLEL_EFFORT_SETTING];
|
|
927
1115
|
if (typeof model !== "string" || typeof effort !== "string" || typeof stream !== "boolean") {
|
|
928
|
-
throw new Error(`Parallel profile "${
|
|
1116
|
+
throw new Error(`Parallel profile "${profile4.id}" is missing its model, effort or stream setting.`);
|
|
929
1117
|
}
|
|
930
1118
|
return {
|
|
931
1119
|
request: {
|
|
@@ -948,7 +1136,8 @@ var parallelResponsesService = {
|
|
|
948
1136
|
// ../provider-answer-services/src/services/index.ts
|
|
949
1137
|
var ANSWER_SERVICES = [
|
|
950
1138
|
exaAnswerService,
|
|
951
|
-
parallelResponsesService
|
|
1139
|
+
parallelResponsesService,
|
|
1140
|
+
cloroMonitorService
|
|
952
1141
|
];
|
|
953
1142
|
|
|
954
1143
|
// ../provider-answer-services/src/index.ts
|