@sentry/junior 0.286.0 → 0.288.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.
Files changed (78) hide show
  1. package/dist/{adapter-JQZaJ-B_.js → adapter-Cikcqdty.js} +1 -1
  2. package/dist/{admin-Dm2bimJ-.js → admin-BcSxHuTB.js} +2 -1
  3. package/dist/{agent-runner-DGCwOEyL.js → agent-runner-9MXyWUL8.js} +784 -368
  4. package/dist/api/schema.d.ts +2 -2
  5. package/dist/api/schema.js +9 -8
  6. package/dist/api.d.ts +1 -1
  7. package/dist/api.js +411 -65
  8. package/dist/{app-BKq0JzWx.d.ts → app-BUklJVBe.d.ts} +4 -2
  9. package/dist/app.d.ts +1 -1
  10. package/dist/app.js +555 -71
  11. package/dist/{assistant-reply-CAPafcUY.js → assistant-reply-mj47jMRV.js} +1 -1
  12. package/dist/{automation-B-jJN_gM.js → automation-DDXwHQs5.js} +4 -7
  13. package/dist/{background-compaction-queue-Btu2oab_.js → background-compaction-queue-CjllSPir.js} +161 -90
  14. package/dist/{briefs-UMeYehUe.js → briefs-DW9iuolG.js} +7 -5
  15. package/dist/{catalog-runtime-Bym8GVdh.js → catalog-runtime-B3gfH58M.js} +1 -1
  16. package/dist/cli/chat.js +14 -14
  17. package/dist/cli/check.js +3 -3
  18. package/dist/cli/main.js +3 -3
  19. package/dist/cli/plugins.js +4 -4
  20. package/dist/cli/snapshot-create.js +4 -4
  21. package/dist/cli/upgrade.d.ts +1 -1
  22. package/dist/cli/upgrade.js +3 -3
  23. package/dist/config-CLJcyYEF.js +1762 -0
  24. package/dist/{connections-CQ7p0aNJ.js → connections-BtdJftow.js} +9 -9
  25. package/dist/{conversation-BusI2uzj.js → conversation-DhoqHtQ7.js} +30 -6
  26. package/dist/{conversation-pending-messages-DwehU0Fd.js → conversation-pending-messages-DHV0S4uF.js} +2 -5
  27. package/dist/{conversation-privacy-Cd_nZZBM.js → conversation-privacy-BPirIVlX.js} +1 -1
  28. package/dist/core-model-BTt5E5b0.js +182 -0
  29. package/dist/{credential-sync-DmiJi_At.js → credential-sync-Co8Q2xRW.js} +28 -20
  30. package/dist/{viewer-CH-ASQzh.js → db-Co7DTYYh.js} +62 -358
  31. package/dist/{db-C5zi4ecs.d.ts → db-zIs8-Ba3.d.ts} +6 -2
  32. package/dist/{executor-Dipi2Ixl.js → executor-m0kIN71Q.js} +102 -14
  33. package/dist/{media-B-BpXo41.js → history-IjdmO_r6.js} +8 -88
  34. package/dist/instrumentation.js +2 -2
  35. package/dist/{logging-CMFhLLj4.js → logging-DbD-dErY.js} +3 -2
  36. package/dist/media-BAHvgkok.js +85 -0
  37. package/dist/{message-D1xLljUF.js → message-DKTdTYm-.js} +10 -10
  38. package/dist/nitro.d.ts +1 -1
  39. package/dist/nitro.js +19 -41
  40. package/dist/{oauth-callback-server-DCAFIUQr.js → oauth-callback-server-CpbepSbp.js} +2 -2
  41. package/dist/{projection-CoeMNxJ4.js → projection-BViECfYu.js} +361 -746
  42. package/dist/{prompt-C9OQEfan.js → prompt-KT6MaDHN.js} +1 -1
  43. package/dist/{registry-u-sFYtx_.js → registry-D-Acyjhh.js} +1 -1
  44. package/dist/{reporting-window-B4TwyuJo.js → reporting-window-B3Ze-Qnt.js} +4 -1
  45. package/dist/{resolve-DYqgL3Eo.js → resolve-gkT2R66z.js} +3 -3
  46. package/dist/{result-CescSwAw.js → result-DHmCFEt8.js} +8 -8
  47. package/dist/{runner-Cr67a8TB.js → runner-DBKjGjH-.js} +8 -8
  48. package/dist/{sandbox-egress-signals-DLOazy5W.js → sandbox-egress-signals-9n8hqx29.js} +1 -1
  49. package/dist/{schedule-BTp__wrw.js → schedule-cP0AACm1.js} +11 -2
  50. package/dist/{schema-Ih60j59-.d.ts → schema-B_6aOcx5.d.ts} +159 -3
  51. package/dist/{schema-BUSi3sgv.js → schema-DxicIQbc.js} +79 -14
  52. package/dist/{service-account-CsKxktLk.js → service-account-Bi0HsY6w.js} +3 -3
  53. package/dist/{service-account-CGEqz9wG.js → service-account-CDlC9ssy.js} +3 -3
  54. package/dist/{session-stop-CGz5DByb.js → session-stop-BWOsuo8p.js} +62 -20
  55. package/dist/{skills-COCqf61f.js → skills-DO5K68Rq.js} +2 -2
  56. package/dist/spawn-BBqZDcPa.js +79 -0
  57. package/dist/{stop-GyFZkHuQ.js → stop-WC97cmHz.js} +832 -552
  58. package/dist/{store-D0-8plWp.js → store-ByR1Lr7e.js} +4 -16
  59. package/dist/{task-runner-xPuQmEot.js → task-runner-B-Ewf8TX.js} +30 -21
  60. package/dist/{turn-failure-response-BOviBdT-.js → turn-failure-response-CpdPoZSl.js} +25 -11
  61. package/dist/{validation-DZDKorGz.js → validation-B4sbIoES.js} +1 -1
  62. package/dist/{version-BTIz7fGi.js → version-D6lpuAgL.js} +1 -1
  63. package/dist/version.js +1 -1
  64. package/dist/viewer-CeP27tC3.js +337 -0
  65. package/dist/warmup-P_GJCL1c.js +767 -0
  66. package/dist/{work-C75_IM5e.js → work-DI7x1Slm.js} +32 -20
  67. package/dist/{worker-Dl47I729.js → worker-CYPTOT4j.js} +6 -7
  68. package/migrations/0088_conversation_unsubscribe.sql +1 -0
  69. package/migrations/0089_conversation_paused_status.sql +3 -0
  70. package/migrations/0090_guardian_review_time_index.sql +20 -0
  71. package/migrations/meta/0088_snapshot.json +4372 -0
  72. package/migrations/meta/0089_snapshot.json +4372 -0
  73. package/migrations/meta/0090_snapshot.json +4388 -0
  74. package/migrations/meta/_journal.json +21 -0
  75. package/package.json +5 -4
  76. package/dist/client-B0aAs7wC.js +0 -793
  77. package/dist/config-B9f9Lqo5.js +0 -579
  78. package/dist/spawn-C8F_iXWO.js +0 -42
@@ -1,793 +0,0 @@
1
- import { E as withSpan, g as normalizeGenAiFinishReason, h as logWarn, i as extractGenAiUsageAttributes, p as logException, v as serializeGenAiAttribute } from "./logging-CMFhLLj4.js";
2
- import { a as toCanonicalInputMessage, n as getCurrentConversationPrivacy, o as toCanonicalOutputMessage, s as toGenAiMessagesTraceAttributes } from "./conversation-privacy-Cd_nZZBM.js";
3
- import { calculateCost, completeSimple, getEnvApiKey, getModels, registerApiProvider } from "@earendil-works/pi-ai/compat";
4
- import { stream as streamAnthropic, streamSimple as streamSimpleAnthropic } from "@earendil-works/pi-ai/api/anthropic-messages";
5
- import { createGatewayProvider } from "@ai-sdk/gateway";
6
- import { getVercelOidcToken } from "@vercel/oidc";
7
- import { Experimental_DecisionRefusalError, NoObjectGeneratedError, embedMany, experimental_decide, generateObject, rerank } from "ai";
8
- // src/chat/optional-string.ts
9
- /**
10
- * Normalize optional env-style strings so blank values do not masquerade as
11
- * configured inputs.
12
- */
13
- function toOptionalTrimmed(value) {
14
- if (!value) return;
15
- const trimmed = value.trim();
16
- return trimmed.length > 0 ? trimmed : void 0;
17
- }
18
- // src/chat/pi/gateway-auth.ts
19
- /**
20
- * AI Gateway credential resolution for every Junior model path.
21
- *
22
- * Prefer Vercel project OIDC so gateway usage attributes to the deploying
23
- * project. Fall back to AI_GATEWAY_API_KEY for local/CI and non-Vercel hosts.
24
- * Never cache resolved tokens: runtime OIDC rotates on each invocation.
25
- */
26
- const UNAUTHENTICATED_GATEWAY_TOKEN = "unauthenticated";
27
- /**
28
- * Resolve the AI Gateway bearer credential.
29
- *
30
- * Order:
31
- * 1. Vercel OIDC via `@vercel/oidc` (request header `x-vercel-oidc-token`,
32
- * then `VERCEL_OIDC_TOKEN`, with local refresh when needed)
33
- * 2. Explicit `AI_GATEWAY_API_KEY` / pi-ai env mapping for vercel-ai-gateway
34
- * 3. A placeholder token (`mode: "none"`), so auth fails on the server side
35
- */
36
- async function resolveGatewayCredential() {
37
- try {
38
- const oidcToken = toOptionalTrimmed(await getVercelOidcToken());
39
- if (oidcToken) return {
40
- mode: "oidc",
41
- token: oidcToken
42
- };
43
- } catch {}
44
- const apiKey = toOptionalTrimmed(getEnvApiKey("vercel-ai-gateway"));
45
- if (apiKey) return {
46
- mode: "api_key",
47
- token: apiKey
48
- };
49
- return {
50
- mode: "none",
51
- token: UNAUTHENTICATED_GATEWAY_TOKEN
52
- };
53
- }
54
- /** Resolve the bearer token string for Authorization headers and Pi getApiKey. */
55
- async function getGatewayApiKey() {
56
- return (await resolveGatewayCredential()).token;
57
- }
58
- // src/chat/services/provider-error.ts
59
- /** Structured failure produced at an AI provider boundary. */
60
- var ProviderError = class extends Error {
61
- code = "provider_error";
62
- kind;
63
- modelId;
64
- retryable;
65
- retryAfterMs;
66
- status;
67
- constructor(details) {
68
- super(`AI provider error: ${details.kind}`, details.cause !== void 0 ? { cause: details.cause } : {});
69
- this.name = "ProviderError";
70
- this.kind = details.kind;
71
- this.modelId = details.modelId;
72
- this.retryable = details.retryable;
73
- this.retryAfterMs = details.retryAfterMs;
74
- this.status = details.status;
75
- }
76
- };
77
- const NETWORK_ERROR_CODES = /* @__PURE__ */ new Set([
78
- "ECONNREFUSED",
79
- "ECONNRESET",
80
- "ENOTFOUND",
81
- "EAI_AGAIN"
82
- ]);
83
- const TIMEOUT_ERROR_CODES = /* @__PURE__ */ new Set([
84
- "ETIMEDOUT",
85
- "ECONNABORTED",
86
- "ESOCKETTIMEDOUT"
87
- ]);
88
- const CONTENT_POLICY_PATTERN = /\b(?:content|safety|usage)[ _-]?policy\b|\b(?:content|safety) (?:filter|violation)\b|\bmoderation (?:blocked|rejected|refused)\b/i;
89
- const QUOTA_PATTERN = /insufficient.?quota|quota exceeded|usage limit|available balance|out of budget|billing (?:limit|quota|error)|payment required/i;
90
- const AUTH_PATTERN = /unauthenticated|invalid.?api.?key|no api key|authentication (?:failed|error|required)|(?:invalid|missing|expired|revoked).{0,24}\bcredentials?\b|\bcredentials?\b.{0,24}(?:invalid|missing|expired|revoked)|\bno\b.{0,16}\bcredentials?\b/i;
91
- const PERMISSION_PATTERN = /permission denied|forbidden|not authorized|authorization (?:failed|required|denied)/i;
92
- const INVALID_REQUEST_PATTERN = /context.?length|context.?window|validation (?:error|failed)|bad request|unsupported model|invalid model|unknown (?:ai gateway )?model|mismatched api/i;
93
- const CAPACITY_PATTERN = /overloaded|at capacity|capacity exceeded/i;
94
- const TIMEOUT_PATTERN = /timed? out|timeout|gateway timeout/i;
95
- const NETWORK_PATTERN = /network.?error|connection (?:error|refused|lost|closed)|fetch failed|socket (?:hang up|closed)|stream ended before/i;
96
- const SERVER_PATTERN = /service(?: temporarily)?[ _-]?unavailable|server.?error|internal.?error|bad gateway|upstream (?:request )?failed/i;
97
- const TERMINAL_KINDS = /* @__PURE__ */ new Set([
98
- "auth",
99
- "permission",
100
- "invalid_request",
101
- "invalid_response",
102
- "quota",
103
- "content_policy"
104
- ]);
105
- const RETRYABLE_KINDS = /* @__PURE__ */ new Set([
106
- "rate_limit",
107
- "capacity",
108
- "timeout",
109
- "network",
110
- "server"
111
- ]);
112
- function providerMessage(error) {
113
- return (error instanceof Error ? error.message : String(error)).trim();
114
- }
115
- const PROVIDER_ERROR_SUMMARY_MAX_CHARS = 240;
116
- /** Short provider-boundary text for telemetry. Drop trailing JSON bodies. */
117
- function summarizeProviderErrorMessage(message) {
118
- const normalized = message.trim().replace(/\s+/g, " ");
119
- if (!normalized) return void 0;
120
- const jsonStart = normalized.indexOf("{");
121
- const summary = (jsonStart >= 0 ? normalized.slice(0, jsonStart) : normalized).trim();
122
- if (!summary) return void 0;
123
- return summary.length > PROVIDER_ERROR_SUMMARY_MAX_CHARS ? `${summary.slice(0, PROVIDER_ERROR_SUMMARY_MAX_CHARS)}...` : summary;
124
- }
125
- function extractTransportKind(error, depth = 0) {
126
- if (!(error instanceof Error) || depth > 4) return void 0;
127
- const providerError = error;
128
- const code = typeof providerError.code === "string" ? providerError.code.toUpperCase() : void 0;
129
- if (code && TIMEOUT_ERROR_CODES.has(code)) return "timeout";
130
- if (code && NETWORK_ERROR_CODES.has(code)) return "network";
131
- return extractTransportKind(providerError.cause, depth + 1);
132
- }
133
- function extractStatus(error, message) {
134
- if (error instanceof Error) {
135
- const providerError = error;
136
- if (typeof providerError.status === "number") return providerError.status;
137
- if (typeof providerError.statusCode === "number") return providerError.statusCode;
138
- }
139
- const match = message.match(/^(?:Error:\s*)?([45]\d\d)\b|\bstatus(?:Code)?["'=:\s]+([45]\d\d)\b/i);
140
- const status = match?.[1] ?? match?.[2];
141
- return status ? Number(status) : void 0;
142
- }
143
- function extractRetryAfterMs(error, message) {
144
- const headers = error instanceof Error ? error.responseHeaders ?? error.response?.headers : void 0;
145
- const retryAfter = headers instanceof Headers ? headers.get("retry-after") : headers && typeof headers === "object" ? Object.entries(headers).find(([name]) => name.toLowerCase() === "retry-after")?.[1] : void 0;
146
- const raw = typeof retryAfter === "string" || typeof retryAfter === "number" ? String(retryAfter) : message.match(/"retry-after"\s*:\s*"?([^",}]+)"?/i)?.[1];
147
- if (!raw) return void 0;
148
- const seconds = Number(raw);
149
- if (Number.isFinite(seconds) && seconds >= 0) return seconds * 1e3;
150
- const date = Date.parse(raw);
151
- return Number.isNaN(date) ? void 0 : Math.max(0, date - Date.now());
152
- }
153
- /** Classify stable provider signals without copying Pi's retry vocabulary. */
154
- function classifyProviderError(status, message, transportKind) {
155
- if (CONTENT_POLICY_PATTERN.test(message)) return "content_policy";
156
- if (QUOTA_PATTERN.test(message)) return "quota";
157
- if (status === 401 || AUTH_PATTERN.test(message)) return "auth";
158
- if (status === 403 || PERMISSION_PATTERN.test(message)) return "permission";
159
- if (INVALID_REQUEST_PATTERN.test(message)) return "invalid_request";
160
- if (status === 429 || /rate.?limit|too many requests/i.test(message)) return "rate_limit";
161
- if (status === 408) return "timeout";
162
- if (CAPACITY_PATTERN.test(message)) return "capacity";
163
- if (transportKind === "timeout" || TIMEOUT_PATTERN.test(message)) return "timeout";
164
- if (transportKind === "network" || NETWORK_PATTERN.test(message)) return "network";
165
- if (status !== void 0 && status >= 500 || SERVER_PATTERN.test(message)) return "server";
166
- if (status !== void 0 && status >= 400) return "invalid_request";
167
- return "unknown";
168
- }
169
- /** Normalize SDK, Gateway, and Pi failures into one provider error contract. */
170
- function createProviderError(error, options = {}) {
171
- if (error instanceof ProviderError) return error;
172
- const message = providerMessage(error);
173
- const status = extractStatus(error, message);
174
- const kind = options.kind ?? classifyProviderError(status, message, extractTransportKind(error));
175
- const retryable = !TERMINAL_KINDS.has(kind) && (options.retryable ?? RETRYABLE_KINDS.has(kind));
176
- return new ProviderError({
177
- cause: error,
178
- kind,
179
- modelId: options.modelId,
180
- retryable,
181
- retryAfterMs: extractRetryAfterMs(error, message),
182
- status
183
- });
184
- }
185
- /** Return whether a provider-boundary error should be retried. */
186
- function isProviderRetryError(error) {
187
- return error instanceof ProviderError && error.retryable;
188
- }
189
- /** Find the provider failure preserved inside a domain error cause chain. */
190
- function findProviderError(error) {
191
- const visited = /* @__PURE__ */ new Set();
192
- let current = error;
193
- while (current instanceof Error && !visited.has(current)) {
194
- if (current instanceof ProviderError) return current;
195
- visited.add(current);
196
- current = current.cause;
197
- }
198
- }
199
- /** Return stable, sanitized copy suitable for a terminal user response. */
200
- function getProviderErrorUserMessage(error) {
201
- switch (error.kind) {
202
- case "capacity": return "The selected model is temporarily unavailable because it is at capacity. Please try again shortly.";
203
- case "rate_limit": {
204
- const seconds = error.retryAfterMs ? Math.max(1, Math.ceil(error.retryAfterMs / 1e3)) : void 0;
205
- return seconds ? `The model is rate-limited. Please try again in about ${seconds} seconds.` : "The model is rate-limited. Please try again shortly.";
206
- }
207
- case "timeout":
208
- case "network":
209
- case "server": return "The model provider had a temporary connection problem. Please try again.";
210
- case "auth": return "The model provider rejected the configured credentials. This needs an administrator or configuration fix.";
211
- case "permission": return "The model provider denied access to this model or request. Ask an administrator to check model access, organization policy, and region availability.";
212
- case "quota": return "The model provider's usage quota has been exhausted. This needs an administrator or billing configuration fix.";
213
- case "content_policy": return "The model provider blocked this request under its content policy. Please revise the request and try again.";
214
- case "invalid_request": return "The model provider rejected this request as invalid. Please revise the request or ask an administrator to check the model configuration.";
215
- case "invalid_response": return "The model provider returned an invalid response. Please try again.";
216
- default: return "The model provider returned an error. Please try again.";
217
- }
218
- }
219
- /** Return safe structured fields for terminal failure telemetry. */
220
- function getProviderErrorAttributes(error) {
221
- const cause = error.cause;
222
- const causeMessage = cause instanceof Error ? cause.message : typeof cause === "string" ? cause : void 0;
223
- const summary = causeMessage ? summarizeProviderErrorMessage(causeMessage) : void 0;
224
- return {
225
- "app.ai.provider_error.kind": error.kind,
226
- "app.ai.provider_error.retryable": error.retryable,
227
- ...error.status !== void 0 ? { "app.ai.provider_error.status": error.status } : void 0,
228
- ...error.retryAfterMs !== void 0 ? { "app.ai.provider_error.retry_after_ms": error.retryAfterMs } : void 0,
229
- ...summary ? { "app.ai.provider_error.summary": summary } : void 0,
230
- ...error.modelId ? { "gen_ai.request.model": error.modelId } : void 0
231
- };
232
- }
233
- // src/chat/xml.ts
234
- /** Escape untrusted body text for a prompt tag. Quotes stay as written. */
235
- function escapeXmlText(value) {
236
- return value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;");
237
- }
238
- function escapeXml(value) {
239
- return value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll("\"", "&quot;").replaceAll("'", "&apos;");
240
- }
241
- /** Recover text escaped for an internal XML prompt boundary. */
242
- function unescapeXml(value) {
243
- return value.replaceAll("&quot;", "\"").replaceAll("&apos;", "'").replaceAll("&gt;", ">").replaceAll("&lt;", "<").replaceAll("&amp;", "&");
244
- }
245
- // src/chat/current-instruction.ts
246
- const CURRENT_INSTRUCTION_TAG = "current-instruction";
247
- const CURRENT_INSTRUCTION_OPEN_PREFIX = `<${CURRENT_INSTRUCTION_TAG}`;
248
- const CURRENT_INSTRUCTION_OPEN_BARE = `<${CURRENT_INSTRUCTION_TAG}>`;
249
- const CURRENT_INSTRUCTION_OPEN_ATTR_PREFIX = `<${CURRENT_INSTRUCTION_TAG} `;
250
- const CURRENT_INSTRUCTION_CLOSE = `\n</${CURRENT_INSTRUCTION_TAG}>`;
251
- function isCurrentInstructionOpeningTag(value) {
252
- return value === CURRENT_INSTRUCTION_OPEN_BARE || value.startsWith(CURRENT_INSTRUCTION_OPEN_ATTR_PREFIX) && value.endsWith(">");
253
- }
254
- function readCurrentInstructionBody(text) {
255
- const start = text.indexOf(CURRENT_INSTRUCTION_OPEN_PREFIX);
256
- if (start < 0) return;
257
- const openingEnd = text.indexOf(">\n", start);
258
- if (openingEnd < 0) return;
259
- if (!isCurrentInstructionOpeningTag(text.slice(start, openingEnd + 1))) return;
260
- const bodyStart = openingEnd + 2;
261
- const bodyEnd = text.indexOf(CURRENT_INSTRUCTION_CLOSE, bodyStart);
262
- if (bodyEnd < bodyStart) return;
263
- return text.slice(bodyStart, bodyEnd);
264
- }
265
- /** Render the active user task in a stable prompt boundary. */
266
- function renderCurrentInstruction(instruction, attrs) {
267
- const renderedAttrs = [
268
- attrs?.authorId ? `author_id="${escapeXml(attrs.authorId)}"` : void 0,
269
- attrs?.authorName ? `author_name="${escapeXml(attrs.authorName)}"` : void 0,
270
- attrs?.slackTs ? `slack_ts="${escapeXml(attrs.slackTs)}"` : void 0
271
- ].filter((attr) => Boolean(attr)).join(" ");
272
- return [
273
- renderedAttrs ? `<${CURRENT_INSTRUCTION_TAG} ${renderedAttrs}>` : `<${CURRENT_INSTRUCTION_TAG}>`,
274
- escapeXml(instruction),
275
- `</${CURRENT_INSTRUCTION_TAG}>`
276
- ].join("\n");
277
- }
278
- /** Recover display text from the internal current-task prompt boundary. */
279
- function unwrapCurrentInstruction(text) {
280
- const body = readCurrentInstructionBody(text);
281
- return body === void 0 ? void 0 : unescapeXml(body);
282
- }
283
- // src/chat/services/context-compaction-marker.ts
284
- const COMPACTION_SUMMARY_PREFIX = "Another language model started to solve this problem and produced a summary of its thinking process. You also have access to the state of the tools that were used by that language model. Use this to build on the work that has already been done and avoid duplicating work. Here is the summary produced by the other language model, use the information in this summary to assist with your own analysis:";
285
- /** Return whether text is one of Junior's durable compacted-context markers. */
286
- function isCompactionSummaryText(text) {
287
- const normalized = (unwrapCurrentInstruction(text) ?? text).trimStart();
288
- return normalized.startsWith("Another language model started to solve this problem and produced a summary of its thinking process. You also have access to the state of the tools that were used by that language model. Use this to build on the work that has already been done and avoid duplicating work. Here is the summary produced by the other language model, use the information in this summary to assist with your own analysis:") || normalized.startsWith("Another language model started to solve this problem and produced a summary of its thinking process. You also have access to the state of the tools that were used by that language model. Use this to build on the work that has already been done and avoid duplicating work. Here is the summary produced by the other language model, use the information in this summary to assist with your own analysis:");
289
- }
290
- /** Return whether model-visible history contains a durable compacted context marker. */
291
- function hasCompactedConversationContext(messages) {
292
- return messages.some((message) => {
293
- const content = message.content;
294
- if (typeof content === "string") return isCompactionSummaryText(content);
295
- if (!Array.isArray(content)) return false;
296
- return content.some((part) => part && typeof part === "object" && part.type === "text" && typeof part.text === "string" && isCompactionSummaryText(part.text));
297
- });
298
- }
299
- // src/chat/pi/client.ts
300
- registerApiProvider({
301
- api: "anthropic-messages",
302
- stream: streamAnthropic,
303
- streamSimple: streamSimpleAnthropic
304
- });
305
- const GATEWAY_PROVIDER = "vercel-ai-gateway";
306
- const GATEWAY_BASE_URL = "https://ai-gateway.vercel.sh";
307
- const GATEWAY_MODEL_OVERRIDES = {
308
- "anthropic/claude-opus-5.5": {
309
- id: "anthropic/claude-opus-5.5",
310
- name: "Claude Opus 5.5",
311
- api: "anthropic-messages",
312
- provider: GATEWAY_PROVIDER,
313
- baseUrl: GATEWAY_BASE_URL,
314
- reasoning: true,
315
- input: ["text", "image"],
316
- cost: {
317
- input: 4,
318
- output: 20,
319
- cacheRead: .2,
320
- cacheWrite: 5
321
- },
322
- contextWindow: 1e6,
323
- maxTokens: 128e3,
324
- thinkingLevelMap: {
325
- xhigh: "xhigh",
326
- max: "max"
327
- },
328
- compat: {
329
- forceAdaptiveThinking: true,
330
- supportsTemperature: false
331
- }
332
- },
333
- "xai/grok-4.5": {
334
- id: "xai/grok-4.5",
335
- name: "Grok 4.5",
336
- api: "anthropic-messages",
337
- provider: GATEWAY_PROVIDER,
338
- baseUrl: GATEWAY_BASE_URL,
339
- reasoning: true,
340
- input: ["text", "image"],
341
- cost: {
342
- input: 2,
343
- output: 6,
344
- cacheRead: .3,
345
- cacheWrite: 0
346
- },
347
- contextWindow: 5e5,
348
- maxTokens: 5e5
349
- },
350
- "openai/gpt-6-luna": {
351
- id: "openai/gpt-6-luna",
352
- name: "GPT-6 Luna",
353
- api: "anthropic-messages",
354
- provider: GATEWAY_PROVIDER,
355
- baseUrl: GATEWAY_BASE_URL,
356
- reasoning: true,
357
- input: ["text", "image"],
358
- cost: {
359
- input: .1,
360
- output: .5,
361
- cacheRead: .01,
362
- cacheWrite: .125,
363
- tiers: [{
364
- inputTokensAbove: 272e3,
365
- input: .2,
366
- output: .75,
367
- cacheRead: .02,
368
- cacheWrite: .25
369
- }]
370
- },
371
- contextWindow: 105e4,
372
- maxTokens: 128e3,
373
- thinkingLevelMap: {
374
- xhigh: "xhigh",
375
- max: "max"
376
- }
377
- },
378
- "openai/gpt-6-astra": {
379
- id: "openai/gpt-6-astra",
380
- name: "GPT-6 Astra",
381
- api: "anthropic-messages",
382
- provider: GATEWAY_PROVIDER,
383
- baseUrl: GATEWAY_BASE_URL,
384
- reasoning: true,
385
- input: ["text", "image"],
386
- cost: {
387
- input: 10,
388
- output: 50,
389
- cacheRead: 1,
390
- cacheWrite: 12.5,
391
- tiers: [{
392
- inputTokensAbove: 272e3,
393
- input: 20,
394
- output: 75,
395
- cacheRead: 2,
396
- cacheWrite: 25
397
- }]
398
- },
399
- contextWindow: 105e4,
400
- maxTokens: 128e3,
401
- thinkingLevelMap: {
402
- xhigh: "xhigh",
403
- max: "max"
404
- },
405
- compat: { supportsTemperature: false }
406
- }
407
- };
408
- const GEN_AI_PROVIDER_NAME = GATEWAY_PROVIDER;
409
- const GEN_AI_SERVER_ADDRESS = "ai-gateway.vercel.sh";
410
- const GEN_AI_OPERATION_CHAT = "chat";
411
- const GEN_AI_OPERATION_EMBEDDINGS = "embeddings";
412
- const GEN_AI_OPERATION_RERANK = "rerank";
413
- const GEN_AI_OPERATION_DECIDE = "decide";
414
- const EMBEDDING_INPUT_COST_USD_PER_MILLION_TOKENS = {
415
- "cohere/embed-v4.0": .12,
416
- "google/gemini-embedding-001": .15,
417
- "google/text-embedding-005": .025,
418
- "mistral/mistral-embed": .1,
419
- "openai/text-embedding-3-large": .13,
420
- "openai/text-embedding-3-small": .02,
421
- "openai/text-embedding-ada-002": .1,
422
- "voyage/voyage-3.5": .06,
423
- "voyage/voyage-3.5-lite": .02,
424
- "voyage/voyage-4": .06,
425
- "voyage/voyage-4-large": .12,
426
- "voyage/voyage-4-lite": .02
427
- };
428
- const DECISION_INPUT_COST_USD_PER_MILLION_TOKENS = {
429
- "openai/gpt-6-luna-decisions": .1,
430
- "typesafe-ai/jev": .042
431
- };
432
- function decisionCostUsd(modelId, inputTokens) {
433
- const costPerMillionTokens = DECISION_INPUT_COST_USD_PER_MILLION_TOKENS[modelId];
434
- return costPerMillionTokens === void 0 || inputTokens === void 0 ? void 0 : inputTokens * costPerMillionTokens / 1e6;
435
- }
436
- function embeddingCostUsd(modelId, inputTokens) {
437
- const costPerMillionTokens = EMBEDDING_INPUT_COST_USD_PER_MILLION_TOKENS[modelId];
438
- return costPerMillionTokens === void 0 ? void 0 : inputTokens * costPerMillionTokens / 1e6;
439
- }
440
- function extractText(message) {
441
- return (message.content ?? []).filter((part) => part.type === "text" && typeof part.text === "string").map((part) => part.text ?? "").join("").trim();
442
- }
443
- /** Resolve gateway models through local overrides, then Pi's bundled catalog. */
444
- function resolveGatewayModel(modelId) {
445
- const matched = GATEWAY_MODEL_OVERRIDES[modelId] ?? getModels(GATEWAY_PROVIDER).find((model) => model.id === modelId);
446
- if (!matched) throw new Error(`Unknown AI Gateway model id: ${modelId}`);
447
- return {
448
- ...matched,
449
- compat: {
450
- ...matched.compat,
451
- sendSessionAffinityHeaders: true
452
- }
453
- };
454
- }
455
- /** Execute a direct chat completion inside a dedicated `gen_ai.chat` span. */
456
- async function completeText(params) {
457
- const model = resolveGatewayModel(params.modelId);
458
- const credential = await resolveGatewayCredential();
459
- const apiKey = credential.token;
460
- const authMode = credential.mode;
461
- const effectivePrivacy = getCurrentConversationPrivacy() ?? "private";
462
- const messageAttributeMode = params.messageAttributeMode ?? (effectivePrivacy === "public" ? "content" : "metadata");
463
- const requestMessagesAttribute = messageAttributeMode === "content" ? serializeGenAiAttribute(params.messages.map(toCanonicalInputMessage)) : void 0;
464
- const systemInstructionsAttribute = params.system && messageAttributeMode === "content" ? serializeGenAiAttribute([{
465
- type: "text",
466
- content: params.system
467
- }]) : void 0;
468
- const baseAttributes = {
469
- "gen_ai.provider.name": GEN_AI_PROVIDER_NAME,
470
- "gen_ai.operation.name": GEN_AI_OPERATION_CHAT,
471
- "gen_ai.request.model": params.modelId,
472
- "gen_ai.output.type": "text",
473
- ...params.promptName ? { "gen_ai.prompt.name": params.promptName } : void 0,
474
- "server.address": GEN_AI_SERVER_ADDRESS,
475
- "server.port": 443,
476
- ...hasCompactedConversationContext(params.messages) ? { "gen_ai.conversation.compacted": true } : void 0,
477
- "app.conversation.privacy": effectivePrivacy,
478
- ...params.thinkingLevel ? { "gen_ai.request.reasoning.level": params.thinkingLevel } : void 0,
479
- ...params.temperature !== void 0 ? { "gen_ai.request.temperature": params.temperature } : void 0,
480
- ...params.maxTokens !== void 0 ? { "gen_ai.request.max_tokens": params.maxTokens } : void 0
481
- };
482
- const startAttributes = {
483
- ...baseAttributes,
484
- ...toGenAiMessagesTraceAttributes("gen_ai.input", params.messages),
485
- ...params.system ? { "gen_ai.system_instructions.content_chars": params.system.length } : void 0,
486
- ...systemInstructionsAttribute ? { "gen_ai.system_instructions": systemInstructionsAttribute } : void 0,
487
- ...requestMessagesAttribute ? { "gen_ai.input.messages": requestMessagesAttribute } : void 0,
488
- "gen_ai.provider.auth_mode": authMode
489
- };
490
- return withSpan(`${GEN_AI_OPERATION_CHAT} ${params.modelId}`, "gen_ai.chat", logContextFromMetadata(params.modelId, params.metadata), async (setSpanAttributes) => {
491
- let message;
492
- try {
493
- message = await completeSimple(model, {
494
- systemPrompt: params.system,
495
- messages: params.messages
496
- }, {
497
- apiKey,
498
- temperature: params.temperature,
499
- maxTokens: params.maxTokens,
500
- reasoning: params.thinkingLevel,
501
- cacheRetention: params.cacheRetention,
502
- signal: params.signal,
503
- metadata: params.metadata
504
- });
505
- } catch (error) {
506
- throw createProviderError(error, { modelId: params.modelId });
507
- }
508
- const outputText = extractText(message);
509
- const outputMessagesAttribute = serializeGenAiAttribute(messageAttributeMode === "content" ? [toCanonicalOutputMessage(message)] : void 0);
510
- const usageAttributes = extractGenAiUsageAttributes(message);
511
- setSpanAttributes({
512
- ...baseAttributes,
513
- ...toGenAiMessagesTraceAttributes("gen_ai.output", [{
514
- role: "assistant",
515
- content: outputText ? [{
516
- type: "text",
517
- text: outputText
518
- }] : []
519
- }]),
520
- ...outputMessagesAttribute ? { "gen_ai.output.messages": outputMessagesAttribute } : void 0,
521
- ...usageAttributes,
522
- ...message.stopReason ? { "gen_ai.response.finish_reasons": [normalizeGenAiFinishReason(message.stopReason)] } : void 0,
523
- ...message.model ? { "gen_ai.response.model": message.model } : void 0
524
- });
525
- if (message.stopReason === "error") {
526
- const providerMessage = message.errorMessage?.trim() || "Unknown provider error";
527
- logWarn("ai.completion.provider_error", {
528
- ...baseAttributes,
529
- "exception.message": providerMessage
530
- });
531
- throw createProviderError(providerMessage, { modelId: params.modelId });
532
- }
533
- return {
534
- message,
535
- text: outputText
536
- };
537
- }, startAttributes);
538
- }
539
- function logContextFromMetadata(modelId, metadata) {
540
- const conversationId = typeof metadata?.conversationId === "string" ? metadata.conversationId : typeof metadata?.threadId === "string" ? metadata.threadId : void 0;
541
- const messageConversationId = typeof metadata?.threadId === "string" ? metadata.threadId : void 0;
542
- const destinationName = typeof metadata?.channelId === "string" ? metadata.channelId : void 0;
543
- const runId = typeof metadata?.runId === "string" ? metadata.runId : void 0;
544
- return {
545
- modelId,
546
- ...conversationId ? { conversationId } : void 0,
547
- ...messageConversationId ? { messageConversationId } : void 0,
548
- ...destinationName ? { destinationName } : void 0,
549
- ...runId ? { runId } : void 0
550
- };
551
- }
552
- function objectCompletionCost(modelId, usage) {
553
- const cacheRead = usage.inputTokenDetails.cacheReadTokens;
554
- const cacheWrite = usage.inputTokenDetails.cacheWriteTokens;
555
- const input = usage.inputTokenDetails.noCacheTokens ?? (usage.inputTokens === void 0 ? void 0 : Math.max(0, usage.inputTokens - (cacheRead ?? 0) - (cacheWrite ?? 0)));
556
- if (input === void 0 && usage.outputTokens === void 0 && cacheRead === void 0 && cacheWrite === void 0) return;
557
- return calculateCost(resolveGatewayModel(modelId), {
558
- input: input ?? 0,
559
- output: usage.outputTokens ?? 0,
560
- cacheRead: cacheRead ?? 0,
561
- cacheWrite: cacheWrite ?? 0,
562
- ...usage.outputTokenDetails.reasoningTokens !== void 0 ? { reasoning: usage.outputTokenDetails.reasoningTokens } : void 0,
563
- totalTokens: usage.totalTokens ?? (input ?? 0) + (usage.outputTokens ?? 0) + (cacheRead ?? 0) + (cacheWrite ?? 0),
564
- cost: {
565
- input: 0,
566
- output: 0,
567
- cacheRead: 0,
568
- cacheWrite: 0,
569
- total: 0
570
- }
571
- }).total;
572
- }
573
- /** Estimate cost without changing the outcome of a successful completion. */
574
- function bestEffortObjectCompletionCost(modelId, usage) {
575
- try {
576
- return objectCompletionCost(modelId, usage);
577
- } catch (error) {
578
- logWarn("ai.completion.cost_estimate.failed", {
579
- "exception.message": error instanceof Error ? error.message : String(error),
580
- "gen_ai.request.model": modelId
581
- });
582
- return;
583
- }
584
- }
585
- /** Execute a schema-constrained completion using the AI SDK structured output path. */
586
- async function completeObject(params) {
587
- const credential = await resolveGatewayCredential();
588
- const provider = createGatewayProvider({ apiKey: credential.token });
589
- let result;
590
- try {
591
- result = await withSpan(`${GEN_AI_OPERATION_CHAT} ${params.modelId}`, "gen_ai.chat", logContextFromMetadata(params.modelId, params.metadata), async (setSpanAttributes) => {
592
- const result = await generateObject({
593
- model: provider.chat(params.modelId),
594
- schema: params.schema,
595
- prompt: params.prompt,
596
- ...params.system !== void 0 ? { system: params.system } : void 0,
597
- ...params.temperature !== void 0 ? { temperature: params.temperature } : void 0,
598
- ...params.maxTokens !== void 0 ? { maxOutputTokens: params.maxTokens } : void 0,
599
- ...params.signal !== void 0 ? { abortSignal: params.signal } : void 0
600
- });
601
- setSpanAttributes({
602
- "gen_ai.response.finish_reasons": [result.finishReason],
603
- ...extractGenAiUsageAttributes(result.usage)
604
- });
605
- return result;
606
- }, {
607
- "gen_ai.provider.name": GEN_AI_PROVIDER_NAME,
608
- "gen_ai.operation.name": GEN_AI_OPERATION_CHAT,
609
- "gen_ai.request.model": params.modelId,
610
- "gen_ai.output.type": "json",
611
- ...params.promptName ? { "gen_ai.prompt.name": params.promptName } : void 0,
612
- "server.address": GEN_AI_SERVER_ADDRESS,
613
- "server.port": 443,
614
- "gen_ai.provider.auth_mode": credential.mode,
615
- ...params.thinkingLevel ? { "gen_ai.request.reasoning.level": params.thinkingLevel } : void 0,
616
- ...params.temperature !== void 0 ? { "gen_ai.request.temperature": params.temperature } : void 0,
617
- ...params.maxTokens !== void 0 ? { "gen_ai.request.max_tokens": params.maxTokens } : void 0
618
- });
619
- } catch (error) {
620
- throw createProviderError(error, {
621
- ...NoObjectGeneratedError.isInstance(error) ? { kind: "invalid_response" } : void 0,
622
- modelId: params.modelId
623
- });
624
- }
625
- const costUsd = bestEffortObjectCompletionCost(params.modelId, result.usage);
626
- return {
627
- object: result.object,
628
- ...costUsd !== void 0 ? { costUsd } : void 0
629
- };
630
- }
631
- /** Answer typed decision questions with an AI Gateway decision model, such as Jev. */
632
- async function completeDecision(params) {
633
- const credential = await resolveGatewayCredential();
634
- const provider = createGatewayProvider({ apiKey: credential.token });
635
- try {
636
- const result = await withSpan(`${GEN_AI_OPERATION_DECIDE} ${params.modelId}`, "gen_ai.decide", logContextFromMetadata(params.modelId, params.metadata), async (setSpanAttributes) => {
637
- const result = await experimental_decide({
638
- model: provider.decisionModel(params.modelId),
639
- state: params.state,
640
- questions: params.questions,
641
- ...params.signal !== void 0 ? { abortSignal: params.signal } : void 0
642
- });
643
- const costUsd = decisionCostUsd(params.modelId, result.usage.inputTokens);
644
- setSpanAttributes(extractGenAiUsageAttributes({
645
- ...result.usage,
646
- ...costUsd !== void 0 ? { cost: {
647
- input: costUsd,
648
- total: costUsd
649
- } } : void 0
650
- }));
651
- return {
652
- answers: result.answers,
653
- costUsd
654
- };
655
- }, {
656
- "gen_ai.provider.name": GEN_AI_PROVIDER_NAME,
657
- "gen_ai.operation.name": GEN_AI_OPERATION_DECIDE,
658
- "gen_ai.request.model": params.modelId,
659
- ...params.promptName ? { "gen_ai.prompt.name": params.promptName } : void 0,
660
- "server.address": GEN_AI_SERVER_ADDRESS,
661
- "server.port": 443,
662
- "gen_ai.provider.auth_mode": credential.mode
663
- });
664
- return {
665
- answers: result.answers,
666
- ...result.costUsd !== void 0 ? { costUsd: result.costUsd } : void 0
667
- };
668
- } catch (error) {
669
- throw createProviderError(error, {
670
- ...Experimental_DecisionRefusalError.isInstance(error) ? { kind: "invalid_response" } : void 0,
671
- modelId: params.modelId
672
- });
673
- }
674
- }
675
- /** Map the input type to the provider option for models that embed queries and documents differently. */
676
- function embeddingProviderOptions(modelId, inputType) {
677
- if (inputType === void 0 || !modelId.startsWith("voyage/")) return;
678
- return { voyage: { inputType } };
679
- }
680
- /** Generate text embeddings through the host-owned AI Gateway provider. */
681
- async function embedTexts(params) {
682
- const texts = params.texts.map((text) => text.trim());
683
- if (texts.length === 0 || texts.some((text) => text.length === 0)) throw new Error("Embedding text is required.");
684
- const credential = await resolveGatewayCredential();
685
- const provider = createGatewayProvider({ apiKey: credential.token });
686
- const providerOptions = embeddingProviderOptions(params.modelId, params.inputType);
687
- try {
688
- const result = await withSpan(`${GEN_AI_OPERATION_EMBEDDINGS} ${params.modelId}`, "gen_ai.embeddings", logContextFromMetadata(params.modelId, params.metadata), async (setSpanAttributes) => {
689
- const result = await embedMany({
690
- model: provider.embeddingModel(params.modelId),
691
- values: texts,
692
- ...providerOptions !== void 0 ? { providerOptions } : void 0,
693
- ...params.signal !== void 0 ? { abortSignal: params.signal } : void 0
694
- });
695
- const dimensions = result.embeddings[0]?.length;
696
- if (result.embeddings.length !== texts.length || !dimensions || !result.embeddings.every((embedding) => embedding.length === dimensions)) throw createProviderError("Embedding provider returned invalid vectors.", {
697
- kind: "invalid_response",
698
- modelId: params.modelId
699
- });
700
- const costUsd = embeddingCostUsd(params.modelId, result.usage.tokens);
701
- setSpanAttributes({
702
- "gen_ai.embeddings.dimension.count": dimensions,
703
- ...extractGenAiUsageAttributes({
704
- inputTokens: result.usage.tokens,
705
- ...costUsd !== void 0 ? { cost: {
706
- input: costUsd,
707
- total: costUsd
708
- } } : void 0
709
- })
710
- });
711
- return {
712
- costUsd,
713
- dimensions,
714
- result
715
- };
716
- }, {
717
- "gen_ai.provider.name": GEN_AI_PROVIDER_NAME,
718
- "gen_ai.operation.name": GEN_AI_OPERATION_EMBEDDINGS,
719
- "gen_ai.request.model": params.modelId,
720
- "server.address": GEN_AI_SERVER_ADDRESS,
721
- "server.port": 443,
722
- "gen_ai.provider.auth_mode": credential.mode
723
- });
724
- return {
725
- ...result.costUsd !== void 0 ? { costUsd: result.costUsd } : void 0,
726
- dimensions: result.dimensions,
727
- model: params.modelId,
728
- provider: GEN_AI_PROVIDER_NAME,
729
- vectors: result.result.embeddings
730
- };
731
- } catch (error) {
732
- const providerError = createProviderError(error, { modelId: params.modelId });
733
- if (isProviderRetryError(providerError)) throw providerError;
734
- logException(providerError, "ai.embeddings.failed", {
735
- "gen_ai.provider.name": GEN_AI_PROVIDER_NAME,
736
- "gen_ai.operation.name": GEN_AI_OPERATION_EMBEDDINGS,
737
- "gen_ai.request.model": params.modelId
738
- });
739
- throw providerError;
740
- }
741
- }
742
- /** Read the billed cost that AI Gateway reports in provider metadata. */
743
- function gatewayCostUsd(providerMetadata) {
744
- const cost = providerMetadata?.gateway?.cost;
745
- const value = typeof cost === "string" ? Number(cost) : cost;
746
- return typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : void 0;
747
- }
748
- /** Score documents against one query through the host-owned AI Gateway provider. */
749
- async function rerankTexts(params) {
750
- const query = params.query.trim();
751
- if (!query || params.documents.length === 0) throw new Error("Reranking query and documents are required.");
752
- const credential = await resolveGatewayCredential();
753
- const provider = createGatewayProvider({ apiKey: credential.token });
754
- try {
755
- return await withSpan(`${GEN_AI_OPERATION_RERANK} ${params.modelId}`, "gen_ai.rerank", logContextFromMetadata(params.modelId, params.metadata), async (setSpanAttributes) => {
756
- const result = await rerank({
757
- model: provider.rerankingModel(params.modelId),
758
- query,
759
- documents: params.documents
760
- });
761
- const scores = params.documents.map(() => NaN);
762
- for (const { originalIndex, score } of result.ranking) scores[originalIndex] = score;
763
- if (result.ranking.length !== params.documents.length || !scores.every(Number.isFinite)) throw createProviderError("Reranking provider returned invalid scores.", {
764
- kind: "invalid_response",
765
- modelId: params.modelId
766
- });
767
- const costUsd = gatewayCostUsd(result.providerMetadata);
768
- if (costUsd !== void 0) setSpanAttributes(extractGenAiUsageAttributes({ cost: { total: costUsd } }));
769
- return {
770
- ...costUsd !== void 0 ? { costUsd } : void 0,
771
- scores
772
- };
773
- }, {
774
- "gen_ai.provider.name": GEN_AI_PROVIDER_NAME,
775
- "gen_ai.operation.name": GEN_AI_OPERATION_RERANK,
776
- "gen_ai.request.model": params.modelId,
777
- "server.address": GEN_AI_SERVER_ADDRESS,
778
- "server.port": 443,
779
- "gen_ai.provider.auth_mode": credential.mode,
780
- "app.rerank.document.count": params.documents.length
781
- });
782
- } catch (error) {
783
- const providerError = createProviderError(error, { modelId: params.modelId });
784
- if (isProviderRetryError(providerError)) throw providerError;
785
- logException(providerError, "ai.rerank.failed", {
786
- "gen_ai.provider.name": GEN_AI_PROVIDER_NAME,
787
- "gen_ai.operation.name": GEN_AI_OPERATION_RERANK,
788
- "gen_ai.request.model": params.modelId
789
- });
790
- throw providerError;
791
- }
792
- }
793
- export { resolveGatewayCredential as C, getGatewayApiKey as S, createProviderError as _, completeText as a, getProviderErrorUserMessage as b, resolveGatewayModel as c, isCompactionSummaryText as d, renderCurrentInstruction as f, ProviderError as g, escapeXmlText as h, completeObject as i, COMPACTION_SUMMARY_PREFIX as l, escapeXml as m, GEN_AI_SERVER_ADDRESS as n, embedTexts as o, unwrapCurrentInstruction as p, completeDecision as r, rerankTexts as s, GEN_AI_PROVIDER_NAME as t, hasCompactedConversationContext as u, findProviderError as v, toOptionalTrimmed as w, isProviderRetryError as x, getProviderErrorAttributes as y };