@omnicross/core 0.1.8 → 0.1.10

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 (113) hide show
  1. package/dist/auth/GeminiCodeAssistProjectResolver.cjs +5 -3
  2. package/dist/auth/GeminiCodeAssistProjectResolver.js +4 -2
  3. package/dist/{chunk-N5T4M4GU.js → chunk-2UTGX6FM.js} +2 -2
  4. package/dist/{chunk-32O35CIF.js → chunk-45FHEOKW.js} +22 -7
  5. package/dist/{chunk-LVUCAWMK.js → chunk-55FMGZ3L.js} +13 -5
  6. package/dist/{chunk-OF3BECU2.cjs → chunk-56QD3YW6.cjs} +18 -5
  7. package/dist/{chunk-V4TXMEJS.cjs → chunk-5LNYGCIW.cjs} +15 -7
  8. package/dist/{chunk-EPN67EGP.cjs → chunk-5UK3KLE2.cjs} +9 -1
  9. package/dist/chunk-6D4W22P4.js +150 -0
  10. package/dist/chunk-77USGNRW.cjs +37 -0
  11. package/dist/chunk-AOFWNWLT.cjs +203 -0
  12. package/dist/{chunk-UAPBLNN2.js → chunk-AQDON6MB.js} +8 -0
  13. package/dist/{chunk-LB6EBS6Y.js → chunk-CCVRRJOX.js} +17 -4
  14. package/dist/{chunk-OVQBNVSV.cjs → chunk-CMVXX7ON.cjs} +42 -27
  15. package/dist/{chunk-QYC54PMG.js → chunk-FEBAQI5A.js} +255 -92
  16. package/dist/{chunk-7C7DET6S.js → chunk-GXEZ2R3E.js} +156 -1
  17. package/dist/{chunk-PEGTIPB3.js → chunk-HKB656B4.js} +37 -43
  18. package/dist/chunk-N2EIM2XJ.js +203 -0
  19. package/dist/{chunk-MYYR3HZL.js → chunk-NGYOO5TO.js} +5 -5
  20. package/dist/{chunk-OKMJLEXX.cjs → chunk-OC6DOOFX.cjs} +5 -5
  21. package/dist/{chunk-2Z4XM3H5.cjs → chunk-P7EM6BND.cjs} +10 -10
  22. package/dist/chunk-QUSEZNYS.cjs +150 -0
  23. package/dist/{chunk-KBM2W6UY.cjs → chunk-RICPANBY.cjs} +41 -24
  24. package/dist/{chunk-TOVPMMHM.js → chunk-S3DYFEBE.js} +37 -20
  25. package/dist/{chunk-26K6T2YS.cjs → chunk-TIT74RIL.cjs} +407 -244
  26. package/dist/{chunk-XPIOJQS2.cjs → chunk-UWDW6PN3.cjs} +159 -4
  27. package/dist/chunk-WYVGULTQ.js +37 -0
  28. package/dist/{chunk-OXHNSZ53.cjs → chunk-ZQQUD66M.cjs} +54 -60
  29. package/dist/completion/CompletionService.cjs +15 -13
  30. package/dist/completion/CompletionService.js +14 -12
  31. package/dist/completion.cjs +15 -13
  32. package/dist/completion.js +14 -12
  33. package/dist/index.cjs +15 -13
  34. package/dist/index.d.cts +2 -2
  35. package/dist/index.d.ts +2 -2
  36. package/dist/index.js +14 -12
  37. package/dist/outbound-api/auditCapture.cjs +2 -2
  38. package/dist/outbound-api/auditCapture.d.cts +6 -0
  39. package/dist/outbound-api/auditCapture.d.ts +6 -0
  40. package/dist/outbound-api/auditCapture.js +1 -1
  41. package/dist/outbound-api/routeResolver.d.cts +1 -1
  42. package/dist/outbound-api/routeResolver.d.ts +1 -1
  43. package/dist/outbound-api/types.d.cts +1 -1
  44. package/dist/outbound-api/types.d.ts +1 -1
  45. package/dist/outbound-api.cjs +15 -13
  46. package/dist/outbound-api.d.cts +3 -2
  47. package/dist/outbound-api.d.ts +3 -2
  48. package/dist/outbound-api.js +14 -12
  49. package/dist/pipeline/AccountAllowanceScheduling.d.cts +1 -1
  50. package/dist/pipeline/AccountAllowanceScheduling.d.ts +1 -1
  51. package/dist/pipeline/executeProviderCall.d.cts +2 -0
  52. package/dist/pipeline/executeProviderCall.d.ts +2 -0
  53. package/dist/pipeline/resolveProviderChain.d.cts +1 -0
  54. package/dist/pipeline/resolveProviderChain.d.ts +1 -0
  55. package/dist/pipeline/resolveSubscriptionChain.d.cts +2 -0
  56. package/dist/pipeline/resolveSubscriptionChain.d.ts +2 -0
  57. package/dist/ports/provider-config-source.d.cts +1 -0
  58. package/dist/ports/provider-config-source.d.ts +1 -0
  59. package/dist/ports.d.cts +1 -1
  60. package/dist/ports.d.ts +1 -1
  61. package/dist/provider-proxy/ProviderProxy.cjs +15 -13
  62. package/dist/provider-proxy/ProviderProxy.js +14 -12
  63. package/dist/provider-proxy/ingress/providerProxyShared.cjs +15 -13
  64. package/dist/provider-proxy/ingress/providerProxyShared.js +14 -12
  65. package/dist/provider-proxy.cjs +15 -13
  66. package/dist/provider-proxy.js +14 -12
  67. package/dist/transformer/TransformerChainExecutor.d.cts +2 -0
  68. package/dist/transformer/TransformerChainExecutor.d.ts +2 -0
  69. package/dist/transformer/TransformerService.d.cts +2 -0
  70. package/dist/transformer/TransformerService.d.ts +2 -0
  71. package/dist/transformer/transformers/AnthropicTransformer.cjs +4 -2
  72. package/dist/transformer/transformers/AnthropicTransformer.d.cts +7 -2
  73. package/dist/transformer/transformers/AnthropicTransformer.d.ts +7 -2
  74. package/dist/transformer/transformers/AnthropicTransformer.js +3 -1
  75. package/dist/transformer/transformers/GeminiCodeAssistTransformer.cjs +5 -3
  76. package/dist/transformer/transformers/GeminiCodeAssistTransformer.d.cts +2 -0
  77. package/dist/transformer/transformers/GeminiCodeAssistTransformer.d.ts +2 -0
  78. package/dist/transformer/transformers/GeminiCodeAssistTransformer.js +4 -2
  79. package/dist/transformer/transformers/GeminiTransformer.cjs +5 -3
  80. package/dist/transformer/transformers/GeminiTransformer.d.cts +4 -2
  81. package/dist/transformer/transformers/GeminiTransformer.d.ts +4 -2
  82. package/dist/transformer/transformers/GeminiTransformer.js +4 -2
  83. package/dist/transformer/transformers/OpenAIResponseTransformer.cjs +3 -2
  84. package/dist/transformer/transformers/OpenAIResponseTransformer.d.cts +4 -2
  85. package/dist/transformer/transformers/OpenAIResponseTransformer.d.ts +4 -2
  86. package/dist/transformer/transformers/OpenAIResponseTransformer.js +2 -1
  87. package/dist/transformer/transformers/OpenAITransformer.cjs +3 -2
  88. package/dist/transformer/transformers/OpenAITransformer.d.cts +3 -1
  89. package/dist/transformer/transformers/OpenAITransformer.d.ts +3 -1
  90. package/dist/transformer/transformers/OpenAITransformer.js +2 -1
  91. package/dist/transformer/transformers.cjs +10 -8
  92. package/dist/transformer/transformers.d.cts +2 -0
  93. package/dist/transformer/transformers.d.ts +2 -0
  94. package/dist/transformer/transformers.js +9 -7
  95. package/dist/transformer/types.d.cts +16 -5
  96. package/dist/transformer/types.d.ts +16 -5
  97. package/dist/transformer.cjs +28 -9
  98. package/dist/transformer.d.cts +76 -1
  99. package/dist/transformer.d.ts +76 -1
  100. package/dist/transformer.js +28 -9
  101. package/dist/usage/usage-recorder.cjs +2 -2
  102. package/dist/usage/usage-recorder.d.cts +12 -2
  103. package/dist/usage/usage-recorder.d.ts +12 -2
  104. package/dist/usage/usage-recorder.js +1 -1
  105. package/dist/usage.cjs +20 -3
  106. package/dist/usage.d.cts +149 -0
  107. package/dist/usage.d.ts +149 -0
  108. package/dist/usage.js +20 -3
  109. package/package.json +2 -2
  110. package/dist/chunk-7VU7V2E4.js +0 -0
  111. package/dist/chunk-FZ46M34D.cjs +0 -1
  112. /package/dist/{chunk-EYZYXJTJ.cjs → chunk-QVOB2DNX.cjs} +0 -0
  113. /package/dist/{chunk-46RLHI7D.js → chunk-WTQMX2Q6.js} +0 -0
@@ -11,6 +11,156 @@ var _chunkXSVNC2UDcjs = require('./chunk-XSVNC2UD.cjs');
11
11
 
12
12
  // src/outbound-api/auditCapture.ts
13
13
  var _crypto = require('crypto');
14
+
15
+ // src/outbound-api/auditSseCompact.ts
16
+ var MERGED_FRAMES_FIELD = "_omnicrossMergedFrames";
17
+ function asObject(value) {
18
+ return value !== null && typeof value === "object" && !Array.isArray(value) ? value : null;
19
+ }
20
+ function scalar(value) {
21
+ return typeof value === "string" || typeof value === "number" ? String(value) : "";
22
+ }
23
+ function classify(payload) {
24
+ const type = scalar(payload["type"]);
25
+ if (type === "content_block_delta") {
26
+ const delta = asObject(payload["delta"]);
27
+ const deltaType = scalar(_optionalChain([delta, 'optionalAccess', _ => _["type"]]));
28
+ const field = deltaType === "text_delta" ? "text" : deltaType === "thinking_delta" ? "thinking" : deltaType === "input_json_delta" ? "partial_json" : null;
29
+ if (!delta || !field || typeof delta[field] !== "string") return null;
30
+ return {
31
+ channel: "anthropic:" + scalar(payload["index"]) + ":" + deltaType,
32
+ text: delta[field],
33
+ payload,
34
+ textPath: ["delta", field]
35
+ };
36
+ }
37
+ if (type.endsWith(".delta") && typeof payload["delta"] === "string") {
38
+ const channel = [
39
+ "responses",
40
+ type,
41
+ scalar(payload["item_id"]),
42
+ scalar(payload["output_index"]),
43
+ scalar(payload["content_index"])
44
+ ].join(":");
45
+ return { channel, text: payload["delta"], payload, textPath: ["delta"] };
46
+ }
47
+ const choices = payload["choices"];
48
+ if (Array.isArray(choices) && choices.length === 1) {
49
+ const choice = asObject(choices[0]);
50
+ const delta = asObject(_optionalChain([choice, 'optionalAccess', _2 => _2["delta"]]));
51
+ if (choice && delta && typeof delta["content"] === "string" && choice["finish_reason"] == null && delta["tool_calls"] === void 0 && delta["function_call"] === void 0) {
52
+ return {
53
+ channel: "chat:" + scalar(choice["index"]),
54
+ text: delta["content"],
55
+ payload,
56
+ textPath: ["choices", "0", "delta", "content"]
57
+ };
58
+ }
59
+ }
60
+ return null;
61
+ }
62
+ function withMergedText(frame, text, mergedCount) {
63
+ const clone = JSON.parse(JSON.stringify(frame.payload));
64
+ let cursor = clone;
65
+ for (let i = 0; i < frame.textPath.length - 1; i += 1) {
66
+ const step = frame.textPath[i];
67
+ const next = Array.isArray(cursor) ? cursor[Number(step)] : cursor[step];
68
+ if (next === null || typeof next !== "object") return clone;
69
+ cursor = next;
70
+ }
71
+ const leaf = frame.textPath[frame.textPath.length - 1];
72
+ if (Array.isArray(cursor)) cursor[Number(leaf)] = text;
73
+ else cursor[leaf] = text;
74
+ clone[MERGED_FRAMES_FIELD] = mergedCount;
75
+ return clone;
76
+ }
77
+ function splitBlocks(text, nl) {
78
+ const blocks = [];
79
+ let head = [];
80
+ let data = null;
81
+ let raw = [];
82
+ const flush = () => {
83
+ if (raw.length === 0) return;
84
+ blocks.push({ head, data, raw: raw.join(nl) });
85
+ head = [];
86
+ data = null;
87
+ raw = [];
88
+ };
89
+ for (const line of text.split(nl)) {
90
+ if (line.trim() === "") {
91
+ flush();
92
+ continue;
93
+ }
94
+ raw.push(line);
95
+ if (line.startsWith("data:")) {
96
+ const payload = line.slice("data:".length).trimStart();
97
+ data = data === null ? payload : data + nl + payload;
98
+ } else {
99
+ head.push(line);
100
+ }
101
+ }
102
+ flush();
103
+ return blocks;
104
+ }
105
+ function compactSseBody(text) {
106
+ if (!text || !text.includes("data:")) return text;
107
+ const nl = "\n";
108
+ const blocks = splitBlocks(text, nl);
109
+ if (blocks.length === 0) return text;
110
+ const out = [];
111
+ let runFrame = null;
112
+ let runBlock = null;
113
+ let runText = "";
114
+ let runCount = 0;
115
+ let merged = 0;
116
+ const flushRun = () => {
117
+ if (runFrame === null || runBlock === null) return;
118
+ if (runCount === 1) {
119
+ out.push(runBlock.raw);
120
+ } else {
121
+ const payload = withMergedText(runFrame, runText, runCount);
122
+ out.push([...runBlock.head, "data: " + JSON.stringify(payload)].join(nl));
123
+ merged += runCount;
124
+ }
125
+ runFrame = null;
126
+ runBlock = null;
127
+ runText = "";
128
+ runCount = 0;
129
+ };
130
+ for (const block of blocks) {
131
+ let frame = null;
132
+ if (block.data !== null && block.data !== "[DONE]") {
133
+ try {
134
+ const parsed = asObject(JSON.parse(block.data));
135
+ if (parsed) frame = classify(parsed);
136
+ } catch (e) {
137
+ frame = null;
138
+ }
139
+ }
140
+ if (frame === null) {
141
+ flushRun();
142
+ out.push(block.raw);
143
+ continue;
144
+ }
145
+ const open = runFrame;
146
+ if (open !== null && open.channel === frame.channel) {
147
+ runText += frame.text;
148
+ runCount += 1;
149
+ continue;
150
+ }
151
+ flushRun();
152
+ runFrame = frame;
153
+ runBlock = block;
154
+ runText = frame.text;
155
+ runCount = 1;
156
+ }
157
+ flushRun();
158
+ if (merged === 0) return text;
159
+ const trailer = /\s$/.test(text) ? nl + nl : "";
160
+ return out.join(nl + nl) + trailer;
161
+ }
162
+
163
+ // src/outbound-api/auditCapture.ts
14
164
  function completeUtf8PrefixLength(buf) {
15
165
  if (buf.length === 0) return 0;
16
166
  let leadIndex = buf.length - 1;
@@ -39,11 +189,11 @@ function resolveClientIp(req, trustForwardedFor) {
39
189
  const xff = req.headers["x-forwarded-for"];
40
190
  const raw = Array.isArray(xff) ? xff[0] : xff;
41
191
  if (typeof raw === "string" && raw.trim()) {
42
- const first = _optionalChain([raw, 'access', _ => _.split, 'call', _2 => _2(","), 'access', _3 => _3[0], 'optionalAccess', _4 => _4.trim, 'call', _5 => _5()]);
192
+ const first = _optionalChain([raw, 'access', _3 => _3.split, 'call', _4 => _4(","), 'access', _5 => _5[0], 'optionalAccess', _6 => _6.trim, 'call', _7 => _7()]);
43
193
  if (first) return first;
44
194
  }
45
195
  }
46
- return _nullishCoalesce(_optionalChain([req, 'access', _6 => _6.socket, 'optionalAccess', _7 => _7.remoteAddress]), () => ( void 0));
196
+ return _nullishCoalesce(_optionalChain([req, 'access', _8 => _8.socket, 'optionalAccess', _9 => _9.remoteAddress]), () => ( void 0));
47
197
  }
48
198
  function beginAuditCapture(req, res, now) {
49
199
  const config = _chunkAEOZIDEBcjs.getAuditCaptureConfig.call(void 0, );
@@ -112,18 +262,23 @@ function beginAuditCapture(req, res, now) {
112
262
  if (!record.provider && usage.provider) record.provider = usage.provider;
113
263
  }
114
264
  if (ctx.error) record.error = _chunkFCR77GYMcjs.redactAuditText.call(void 0, ctx.error);
265
+ if (ctx.sessionKey) record.sessionKey = ctx.sessionKey;
115
266
  if (config.captureBodies) {
116
267
  if (requestBody != null && requestBody.length > 0) {
117
268
  record.requestBody = requestBody;
118
269
  }
119
270
  if (responseChunks.length > 0) {
120
271
  const captured = Buffer.concat(responseChunks, responseBytes);
121
- const body = decodeCapturedBody(captured, responseTruncated);
272
+ const decoded = decodeCapturedBody(captured, responseTruncated);
273
+ const body = config.compactStreamingBodies ? compactSseBody(decoded) : decoded;
122
274
  record.responseBody = truncateToBytes(_chunkFCR77GYMcjs.redactAuditText.call(void 0, body), config.maxBodyBytes);
123
275
  }
276
+ if (record.requestBody !== void 0 || record.responseBody !== void 0) {
277
+ record.hasBody = true;
278
+ }
124
279
  }
125
280
  _chunkAEOZIDEBcjs.recordAudit.call(void 0, record);
126
- } catch (e) {
281
+ } catch (e2) {
127
282
  }
128
283
  };
129
284
  res.once("close", finalize);
@@ -0,0 +1,37 @@
1
+ // src/transformer/transformers/AnthropicTypes.ts
2
+ function getThinkLevel(budgetTokens) {
3
+ if (!budgetTokens || budgetTokens <= 0) return "none";
4
+ if (budgetTokens < 4096) return "low";
5
+ if (budgetTokens < 16384) return "medium";
6
+ return "high";
7
+ }
8
+ function formatBase64(data, mediaType) {
9
+ if (data.startsWith("data:")) return data;
10
+ return `data:${mediaType || "image/png"};base64,${data}`;
11
+ }
12
+ function flattenToolResultContent(content) {
13
+ if (typeof content === "string") return content;
14
+ if (content == null) return "";
15
+ if (!Array.isArray(content)) return JSON.stringify(content);
16
+ const parts = [];
17
+ for (const block of content) {
18
+ if (typeof block === "string") {
19
+ parts.push(block);
20
+ continue;
21
+ }
22
+ if (!block || typeof block !== "object") continue;
23
+ const typed = block;
24
+ if (typed.type === "image" || typed.type === "image_url") {
25
+ parts.push("[image omitted]");
26
+ } else if (typeof typed.text === "string") {
27
+ parts.push(typed.text);
28
+ }
29
+ }
30
+ return parts.filter((text) => text !== "").join("\n");
31
+ }
32
+
33
+ export {
34
+ getThinkLevel,
35
+ formatBase64,
36
+ flattenToolResultContent
37
+ };
@@ -2,6 +2,16 @@
2
2
 
3
3
  var _chunk5RSZYQJHcjs = require('./chunk-5RSZYQJH.cjs');
4
4
 
5
+
6
+
7
+
8
+ var _chunk77USGNRWcjs = require('./chunk-77USGNRW.cjs');
9
+
10
+
11
+
12
+
13
+ var _chunkAOFWNWLTcjs = require('./chunk-AOFWNWLT.cjs');
14
+
5
15
  // src/transformer/transformers/AnthropicToolHandling.ts
6
16
  function isServerSideTool(tool) {
7
17
  const type = String(tool.type || "");
@@ -18,38 +28,6 @@ function convertAnthropicToolsToOpenAI(tools) {
18
28
  }));
19
29
  }
20
30
 
21
- // src/transformer/transformers/AnthropicTypes.ts
22
- function getThinkLevel(budgetTokens) {
23
- if (!budgetTokens || budgetTokens <= 0) return "none";
24
- if (budgetTokens < 4096) return "low";
25
- if (budgetTokens < 16384) return "medium";
26
- return "high";
27
- }
28
- function formatBase64(data, mediaType) {
29
- if (data.startsWith("data:")) return data;
30
- return `data:${mediaType || "image/png"};base64,${data}`;
31
- }
32
- function flattenToolResultContent(content) {
33
- if (typeof content === "string") return content;
34
- if (content == null) return "";
35
- if (!Array.isArray(content)) return JSON.stringify(content);
36
- const parts = [];
37
- for (const block of content) {
38
- if (typeof block === "string") {
39
- parts.push(block);
40
- continue;
41
- }
42
- if (!block || typeof block !== "object") continue;
43
- const typed = block;
44
- if (typed.type === "image" || typed.type === "image_url") {
45
- parts.push("[image omitted]");
46
- } else if (typeof typed.text === "string") {
47
- parts.push(typed.text);
48
- }
49
- }
50
- return parts.filter((text) => text !== "").join("\n");
51
- }
52
-
53
31
  // src/anthropicMaxTokens.ts
54
32
  var _canonicalmodels = require('@omnicross/contracts/canonical-models');
55
33
  var ANTHROPIC_FALLBACK_MAX_TOKENS = 128e3;
@@ -65,7 +43,7 @@ function resolveAnthropicMaxTokens(model, requested) {
65
43
  }
66
44
 
67
45
  // src/transformer/transformers/AnthropicRequestBuilder.ts
68
- function buildAnthropicRequestBody(request) {
46
+ function buildAnthropicRequestBody(request, provider) {
69
47
  let systemContent;
70
48
  const anthropicMessages = [];
71
49
  for (let i = 0; i < request.messages.length; i++) {
@@ -202,10 +180,18 @@ function buildAnthropicRequestBody(request) {
202
180
  body.tool_choice = { type: "tool", name: request.tool_choice.function.name };
203
181
  }
204
182
  }
205
- if (_optionalChain([request, 'access', _9 => _9.reasoning, 'optionalAccess', _10 => _10.enabled])) {
206
- const budgetMap = { low: 2048, medium: 8192, high: 32768 };
207
- const budget = request.reasoning.max_tokens || budgetMap[request.reasoning.effort || "medium"] || 8192;
208
- body.thinking = { type: "enabled", budget_tokens: budget };
183
+ const reasoningPlan = _chunkAOFWNWLTcjs.resolveReasoningPlan.call(void 0, {
184
+ intent: _chunkAOFWNWLTcjs.extractReasoningIntent.call(void 0, request),
185
+ model: request.model,
186
+ provider,
187
+ target: "anthropic",
188
+ requestMaxTokens: request.max_tokens
189
+ });
190
+ if (_optionalChain([reasoningPlan, 'optionalAccess', _9 => _9.kind]) === "level" && reasoningPlan.enabled) {
191
+ body.thinking = { type: "adaptive" };
192
+ body.output_config = { effort: reasoningPlan.effort };
193
+ } else if (_optionalChain([reasoningPlan, 'optionalAccess', _10 => _10.kind]) === "budget" && reasoningPlan.enabled) {
194
+ body.thinking = { type: "enabled", budget_tokens: reasoningPlan.budgetTokens };
209
195
  body.temperature = 1;
210
196
  }
211
197
  return body;
@@ -380,7 +366,7 @@ function transformAnthropicRequestToUnified(request) {
380
366
  // Claude Code sends tool results as a block ARRAY; stringifying it
381
367
  // fed the model the literal `[{"type":"text","text":"…"}]` envelope
382
368
  // on every tool result.
383
- content: flattenToolResultContent(tool.content),
369
+ content: _chunk77USGNRWcjs.flattenToolResultContent.call(void 0, tool.content),
384
370
  tool_call_id: tool.tool_use_id,
385
371
  cache_control: tool.cache_control
386
372
  });
@@ -397,7 +383,7 @@ function transformAnthropicRequestToUnified(request) {
397
383
  return {
398
384
  type: "image_url",
399
385
  image_url: {
400
- url: imagePart.source.type === "base64" ? formatBase64(imagePart.source.data || "", imagePart.source.media_type) : imagePart.source.url || ""
386
+ url: imagePart.source.type === "base64" ? _chunk77USGNRWcjs.formatBase64.call(void 0, imagePart.source.data || "", imagePart.source.media_type) : imagePart.source.url || ""
401
387
  },
402
388
  media_type: imagePart.source.media_type
403
389
  };
@@ -461,10 +447,18 @@ function transformAnthropicRequestToUnified(request) {
461
447
  result._serverSideTools = serverSideTools;
462
448
  }
463
449
  if (anthropicRequest.thinking) {
464
- result.reasoning = {
465
- effort: getThinkLevel(anthropicRequest.thinking.budget_tokens),
466
- enabled: anthropicRequest.thinking.type === "enabled"
467
- };
450
+ if (anthropicRequest.thinking.type === "disabled") {
451
+ result.reasoning = { effort: "none", enabled: false };
452
+ } else if (anthropicRequest.thinking.type === "adaptive") {
453
+ const effort = _chunkAOFWNWLTcjs.normalizeThinkLevel.call(void 0, _optionalChain([anthropicRequest, 'access', _23 => _23.output_config, 'optionalAccess', _24 => _24.effort]));
454
+ if (effort) result.reasoning = { effort, enabled: effort !== "none" };
455
+ } else {
456
+ result.reasoning = {
457
+ effort: _chunk77USGNRWcjs.getThinkLevel.call(void 0, anthropicRequest.thinking.budget_tokens),
458
+ enabled: true,
459
+ ...typeof anthropicRequest.thinking.budget_tokens === "number" ? { max_tokens: anthropicRequest.thinking.budget_tokens } : {}
460
+ };
461
+ }
468
462
  }
469
463
  if (anthropicRequest.tool_choice) {
470
464
  if (anthropicRequest.tool_choice.type === "tool" && anthropicRequest.tool_choice.name) {
@@ -580,7 +574,7 @@ function convertAnthropicStreamToOpenAI(anthropicStream, logger) {
580
574
  `);
581
575
  } else if (event.content_block.type === "web_search_tool_result") {
582
576
  const searches = event.content_block.content;
583
- if (_optionalChain([searches, 'optionalAccess', _23 => _23.length])) {
577
+ if (_optionalChain([searches, 'optionalAccess', _25 => _25.length])) {
584
578
  const formatted = searches.map((s) => `[${s.title}](${s.url}): ${s.page_content || s.snippet || ""}`).join("\n");
585
579
  const chunk = {
586
580
  id: messageId,
@@ -628,7 +622,7 @@ ${formatted}` },
628
622
  `);
629
623
  }
630
624
  } catch (e) {
631
- _optionalChain([logger, 'optionalAccess', _24 => _24.error, 'call', _25 => _25("Error parsing Anthropic stream event:", e)]);
625
+ _optionalChain([logger, 'optionalAccess', _26 => _26.error, 'call', _27 => _27("Error parsing Anthropic stream event:", e)]);
632
626
  }
633
627
  }
634
628
  }
@@ -760,20 +754,20 @@ data: ${JSON.stringify({
760
754
 
761
755
  `);
762
756
  }
763
- const choice = _optionalChain([chunk, 'access', _26 => _26.choices, 'optionalAccess', _27 => _27[0]]);
757
+ const choice = _optionalChain([chunk, 'access', _28 => _28.choices, 'optionalAccess', _29 => _29[0]]);
764
758
  if (!choice) continue;
765
759
  if (chunk.usage) {
766
760
  stopReasonDelta = {
767
761
  type: "message_delta",
768
762
  delta: { stop_reason: "end_turn", stop_sequence: null },
769
763
  usage: {
770
- input_tokens: (chunk.usage.prompt_tokens || 0) - (_optionalChain([chunk, 'access', _28 => _28.usage, 'access', _29 => _29.prompt_tokens_details, 'optionalAccess', _30 => _30.cached_tokens]) || 0),
764
+ input_tokens: (chunk.usage.prompt_tokens || 0) - (_optionalChain([chunk, 'access', _30 => _30.usage, 'access', _31 => _31.prompt_tokens_details, 'optionalAccess', _32 => _32.cached_tokens]) || 0),
771
765
  output_tokens: chunk.usage.completion_tokens || 0,
772
- cache_read_input_tokens: _optionalChain([chunk, 'access', _31 => _31.usage, 'access', _32 => _32.prompt_tokens_details, 'optionalAccess', _33 => _33.cached_tokens]) || 0
766
+ cache_read_input_tokens: _optionalChain([chunk, 'access', _33 => _33.usage, 'access', _34 => _34.prompt_tokens_details, 'optionalAccess', _35 => _35.cached_tokens]) || 0
773
767
  }
774
768
  };
775
769
  }
776
- if (_optionalChain([choice, 'access', _34 => _34.delta, 'optionalAccess', _35 => _35.thinking])) {
770
+ if (_optionalChain([choice, 'access', _36 => _36.delta, 'optionalAccess', _37 => _37.thinking])) {
777
771
  if (!isThinkingStarted) {
778
772
  const thinkingBlockIndex = assignContentBlockIndex();
779
773
  safeEnqueue(`event: content_block_start
@@ -815,7 +809,7 @@ data: ${JSON.stringify({
815
809
  `);
816
810
  }
817
811
  }
818
- if (_optionalChain([choice, 'access', _36 => _36.delta, 'optionalAccess', _37 => _37.content])) {
812
+ if (_optionalChain([choice, 'access', _38 => _38.delta, 'optionalAccess', _39 => _39.content])) {
819
813
  if (!hasTextContentStarted) {
820
814
  if (currentContentBlockIndex >= 0 && isThinkingStarted) {
821
815
  safeEnqueue(`event: content_block_stop
@@ -847,7 +841,7 @@ data: ${JSON.stringify({
847
841
 
848
842
  `);
849
843
  }
850
- if (_optionalChain([choice, 'access', _38 => _38.delta, 'optionalAccess', _39 => _39.tool_calls])) {
844
+ if (_optionalChain([choice, 'access', _40 => _40.delta, 'optionalAccess', _41 => _41.tool_calls])) {
851
845
  for (const toolCall of choice.delta.tool_calls) {
852
846
  const toolCallIndex = _nullishCoalesce(toolCall.index, () => ( 0));
853
847
  if (!toolCallIndexToContentBlockIndex.has(toolCallIndex)) {
@@ -870,7 +864,7 @@ data: ${JSON.stringify({
870
864
  content_block: {
871
865
  type: "tool_use",
872
866
  id: toolCall.id || `call_${Date.now()}_${toolCallIndex}`,
873
- name: _optionalChain([toolCall, 'access', _40 => _40.function, 'optionalAccess', _41 => _41.name]) || `tool_${toolCallIndex}`,
867
+ name: _optionalChain([toolCall, 'access', _42 => _42.function, 'optionalAccess', _43 => _43.name]) || `tool_${toolCallIndex}`,
874
868
  input: {}
875
869
  }
876
870
  })}
@@ -878,7 +872,7 @@ data: ${JSON.stringify({
878
872
  `);
879
873
  currentContentBlockIndex = newBlockIndex;
880
874
  }
881
- if (_optionalChain([toolCall, 'access', _42 => _42.function, 'optionalAccess', _43 => _43.arguments])) {
875
+ if (_optionalChain([toolCall, 'access', _44 => _44.function, 'optionalAccess', _45 => _45.arguments])) {
882
876
  const blockIndex = toolCallIndexToContentBlockIndex.get(toolCallIndex);
883
877
  if (blockIndex !== void 0) {
884
878
  safeEnqueue(`event: content_block_delta
@@ -907,14 +901,14 @@ data: ${JSON.stringify({
907
901
  stop_sequence: null
908
902
  },
909
903
  usage: {
910
- input_tokens: (_optionalChain([chunk, 'access', _44 => _44.usage, 'optionalAccess', _45 => _45.prompt_tokens]) || 0) - (_optionalChain([chunk, 'access', _46 => _46.usage, 'optionalAccess', _47 => _47.prompt_tokens_details, 'optionalAccess', _48 => _48.cached_tokens]) || 0),
911
- output_tokens: _optionalChain([chunk, 'access', _49 => _49.usage, 'optionalAccess', _50 => _50.completion_tokens]) || 0,
912
- cache_read_input_tokens: _optionalChain([chunk, 'access', _51 => _51.usage, 'optionalAccess', _52 => _52.prompt_tokens_details, 'optionalAccess', _53 => _53.cached_tokens]) || 0
904
+ input_tokens: (_optionalChain([chunk, 'access', _46 => _46.usage, 'optionalAccess', _47 => _47.prompt_tokens]) || 0) - (_optionalChain([chunk, 'access', _48 => _48.usage, 'optionalAccess', _49 => _49.prompt_tokens_details, 'optionalAccess', _50 => _50.cached_tokens]) || 0),
905
+ output_tokens: _optionalChain([chunk, 'access', _51 => _51.usage, 'optionalAccess', _52 => _52.completion_tokens]) || 0,
906
+ cache_read_input_tokens: _optionalChain([chunk, 'access', _53 => _53.usage, 'optionalAccess', _54 => _54.prompt_tokens_details, 'optionalAccess', _55 => _55.cached_tokens]) || 0
913
907
  }
914
908
  };
915
909
  }
916
910
  } catch (e) {
917
- _optionalChain([logger, 'optionalAccess', _54 => _54.error, 'call', _55 => _55("Error parsing stream chunk:", e)]);
911
+ _optionalChain([logger, 'optionalAccess', _56 => _56.error, 'call', _57 => _57("Error parsing stream chunk:", e)]);
918
912
  }
919
913
  }
920
914
  }
@@ -938,7 +932,7 @@ var AnthropicTransformer = (_class = class {
938
932
  __init2() {this.endPoint = "/v1/messages"}
939
933
 
940
934
  constructor(options) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);
941
- this.useBearer = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _56 => _56.UseBearer]), () => ( false));
935
+ this.useBearer = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _58 => _58.UseBearer]), () => ( false));
942
936
  }
943
937
  /**
944
938
  * Handle authentication - Anthropic uses x-api-key header
@@ -994,8 +988,8 @@ var AnthropicTransformer = (_class = class {
994
988
  * This is the reverse of transformRequestOut — converts OpenAI/unified format
995
989
  * to Anthropic's expected request body structure.
996
990
  */
997
- async transformRequestIn(request, _provider, _context) {
998
- return buildAnthropicRequestBody(request);
991
+ async transformRequestIn(request, provider, _context) {
992
+ return buildAnthropicRequestBody(request, provider);
999
993
  }
1000
994
  /**
1001
995
  * Transform Anthropic response to OpenAI/unified format
@@ -1,17 +1,17 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunk26K6T2YScjs = require('../chunk-26K6T2YS.cjs');
3
+ var _chunkTIT74RILcjs = require('../chunk-TIT74RIL.cjs');
4
4
  require('../chunk-HQP3K7PU.cjs');
5
- require('../chunk-FZ46M34D.cjs');
6
- require('../chunk-2Z4XM3H5.cjs');
7
- require('../chunk-OXHNSZ53.cjs');
8
- require('../chunk-V4TXMEJS.cjs');
9
- require('../chunk-OVQBNVSV.cjs');
5
+ require('../chunk-QVOB2DNX.cjs');
6
+ require('../chunk-P7EM6BND.cjs');
7
+ require('../chunk-ZQQUD66M.cjs');
8
+ require('../chunk-5LNYGCIW.cjs');
9
+ require('../chunk-CMVXX7ON.cjs');
10
10
  require('../chunk-5RSZYQJH.cjs');
11
- require('../chunk-OF3BECU2.cjs');
12
- require('../chunk-EYZYXJTJ.cjs');
11
+ require('../chunk-56QD3YW6.cjs');
12
+ require('../chunk-QUSEZNYS.cjs');
13
13
  require('../chunk-2E42SAW3.cjs');
14
- require('../chunk-EPN67EGP.cjs');
14
+ require('../chunk-5UK3KLE2.cjs');
15
15
  require('../chunk-IIRPUVPH.cjs');
16
16
  require('../chunk-GBHYAGX3.cjs');
17
17
  require('../chunk-3OPYJG76.cjs');
@@ -38,13 +38,15 @@ require('../chunk-4VZX5F4T.cjs');
38
38
  require('../chunk-QBZJ7P2T.cjs');
39
39
  require('../chunk-4IH4EL7M.cjs');
40
40
  require('../chunk-A2YMUCBT.cjs');
41
- require('../chunk-XPIOJQS2.cjs');
41
+ require('../chunk-UWDW6PN3.cjs');
42
42
  require('../chunk-FCR77GYM.cjs');
43
43
  require('../chunk-AEOZIDEB.cjs');
44
44
  require('../chunk-XSVNC2UD.cjs');
45
45
  require('../chunk-GDIXXKF2.cjs');
46
- require('../chunk-OKMJLEXX.cjs');
47
- require('../chunk-KBM2W6UY.cjs');
46
+ require('../chunk-OC6DOOFX.cjs');
47
+ require('../chunk-RICPANBY.cjs');
48
+ require('../chunk-77USGNRW.cjs');
49
+ require('../chunk-AOFWNWLT.cjs');
48
50
  require('../chunk-RJUONLUQ.cjs');
49
51
  require('../chunk-235MXAGX.cjs');
50
52
  require('../chunk-HVBBDBS3.cjs');
@@ -55,4 +57,4 @@ require('../chunk-GMMT7RVN.cjs');
55
57
  require('../chunk-UNEFIWXI.cjs');
56
58
 
57
59
 
58
- exports.CompletionService = _chunk26K6T2YScjs.CompletionService;
60
+ exports.CompletionService = _chunkTIT74RILcjs.CompletionService;
@@ -1,17 +1,17 @@
1
1
  import {
2
2
  CompletionService
3
- } from "../chunk-QYC54PMG.js";
3
+ } from "../chunk-FEBAQI5A.js";
4
4
  import "../chunk-VVEHS2LI.js";
5
- import "../chunk-46RLHI7D.js";
6
- import "../chunk-MYYR3HZL.js";
7
- import "../chunk-PEGTIPB3.js";
8
- import "../chunk-LVUCAWMK.js";
9
- import "../chunk-32O35CIF.js";
5
+ import "../chunk-WTQMX2Q6.js";
6
+ import "../chunk-NGYOO5TO.js";
7
+ import "../chunk-HKB656B4.js";
8
+ import "../chunk-55FMGZ3L.js";
9
+ import "../chunk-45FHEOKW.js";
10
10
  import "../chunk-FU7EAR73.js";
11
- import "../chunk-LB6EBS6Y.js";
12
- import "../chunk-7VU7V2E4.js";
11
+ import "../chunk-CCVRRJOX.js";
12
+ import "../chunk-6D4W22P4.js";
13
13
  import "../chunk-FXR6N3SR.js";
14
- import "../chunk-UAPBLNN2.js";
14
+ import "../chunk-AQDON6MB.js";
15
15
  import "../chunk-WNKWAEUR.js";
16
16
  import "../chunk-MZNPGW5Q.js";
17
17
  import "../chunk-DK4A7DLE.js";
@@ -38,13 +38,15 @@ import "../chunk-EBLFCNPY.js";
38
38
  import "../chunk-AQ5TNQB7.js";
39
39
  import "../chunk-XEKD23J5.js";
40
40
  import "../chunk-H5JUT3KV.js";
41
- import "../chunk-7C7DET6S.js";
41
+ import "../chunk-GXEZ2R3E.js";
42
42
  import "../chunk-K5NM7VAH.js";
43
43
  import "../chunk-WNY4WMRF.js";
44
44
  import "../chunk-OZFM4X3S.js";
45
45
  import "../chunk-5NJLQ6T6.js";
46
- import "../chunk-N5T4M4GU.js";
47
- import "../chunk-TOVPMMHM.js";
46
+ import "../chunk-2UTGX6FM.js";
47
+ import "../chunk-S3DYFEBE.js";
48
+ import "../chunk-WYVGULTQ.js";
49
+ import "../chunk-N2EIM2XJ.js";
48
50
  import "../chunk-RJ5ZGNI3.js";
49
51
  import "../chunk-3WD4HTR2.js";
50
52
  import "../chunk-MKF46GNZ.js";
@@ -9,18 +9,18 @@
9
9
 
10
10
 
11
11
 
12
- var _chunk26K6T2YScjs = require('./chunk-26K6T2YS.cjs');
12
+ var _chunkTIT74RILcjs = require('./chunk-TIT74RIL.cjs');
13
13
  require('./chunk-HQP3K7PU.cjs');
14
- require('./chunk-FZ46M34D.cjs');
15
- require('./chunk-2Z4XM3H5.cjs');
16
- require('./chunk-OXHNSZ53.cjs');
17
- require('./chunk-V4TXMEJS.cjs');
18
- require('./chunk-OVQBNVSV.cjs');
14
+ require('./chunk-QVOB2DNX.cjs');
15
+ require('./chunk-P7EM6BND.cjs');
16
+ require('./chunk-ZQQUD66M.cjs');
17
+ require('./chunk-5LNYGCIW.cjs');
18
+ require('./chunk-CMVXX7ON.cjs');
19
19
  require('./chunk-5RSZYQJH.cjs');
20
- require('./chunk-OF3BECU2.cjs');
21
- require('./chunk-EYZYXJTJ.cjs');
20
+ require('./chunk-56QD3YW6.cjs');
21
+ require('./chunk-QUSEZNYS.cjs');
22
22
  require('./chunk-2E42SAW3.cjs');
23
- require('./chunk-EPN67EGP.cjs');
23
+ require('./chunk-5UK3KLE2.cjs');
24
24
  require('./chunk-IIRPUVPH.cjs');
25
25
  require('./chunk-GBHYAGX3.cjs');
26
26
  require('./chunk-3OPYJG76.cjs');
@@ -59,13 +59,15 @@ require('./chunk-4IH4EL7M.cjs');
59
59
 
60
60
 
61
61
  var _chunkA2YMUCBTcjs = require('./chunk-A2YMUCBT.cjs');
62
- require('./chunk-XPIOJQS2.cjs');
62
+ require('./chunk-UWDW6PN3.cjs');
63
63
  require('./chunk-FCR77GYM.cjs');
64
64
  require('./chunk-AEOZIDEB.cjs');
65
65
  require('./chunk-XSVNC2UD.cjs');
66
66
  require('./chunk-GDIXXKF2.cjs');
67
- require('./chunk-OKMJLEXX.cjs');
68
- require('./chunk-KBM2W6UY.cjs');
67
+ require('./chunk-OC6DOOFX.cjs');
68
+ require('./chunk-RICPANBY.cjs');
69
+ require('./chunk-77USGNRW.cjs');
70
+ require('./chunk-AOFWNWLT.cjs');
69
71
  require('./chunk-RJUONLUQ.cjs');
70
72
  require('./chunk-235MXAGX.cjs');
71
73
  require('./chunk-HVBBDBS3.cjs');
@@ -110,4 +112,4 @@ require('./chunk-UNEFIWXI.cjs');
110
112
 
111
113
 
112
114
 
113
- exports.BuiltinToolExecutor = _chunkNZYN7C3Pcjs.BuiltinToolExecutor; exports.CompletionService = _chunk26K6T2YScjs.CompletionService; exports.NATIVE_SEARCH_TOOL_NAMES = _chunkGMMT7RVNcjs.NATIVE_SEARCH_TOOL_NAMES; exports.addOpenRouterProviderToRequest = _chunk26K6T2YScjs.addOpenRouterProviderToRequest; exports.applyAugmentation = _chunkJMJBSACDcjs.applyAugmentation; exports.attachStreamEventBuffer = _chunk26K6T2YScjs.attach; exports.buildAnthropicApiUrl = _chunkA2YMUCBTcjs.buildAnthropicApiUrl; exports.buildAzureOpenAIApiUrl = _chunkA2YMUCBTcjs.buildAzureOpenAIApiUrl; exports.buildGeminiApiUrl = _chunkA2YMUCBTcjs.buildGeminiApiUrl; exports.buildNativeSearchAugmentation = _chunkJMJBSACDcjs.buildNativeSearchAugmentation; exports.buildOpenAIApiUrl = _chunkA2YMUCBTcjs.buildOpenAIApiUrl; exports.buildOpenAIResponseApiUrl = _chunkA2YMUCBTcjs.buildOpenAIResponseApiUrl; exports.buildProviderApiUrl = _chunkA2YMUCBTcjs.buildProviderApiUrl; exports.convertMessageToAnthropic = _chunk26K6T2YScjs.convertMessageToAnthropic; exports.convertMessageToGemini = _chunk26K6T2YScjs.convertMessageToGemini; exports.convertMessageToOpenAI = _chunk26K6T2YScjs.convertMessageToOpenAI; exports.detectNativeSearch = _chunkJMJBSACDcjs.detectNativeSearch; exports.emitStreamEvent = _chunk26K6T2YScjs.emit; exports.getBuiltinSearchTools = _chunkNZYN7C3Pcjs.getBuiltinSearchTools; exports.getOpenRouterProviderConfig = _chunk26K6T2YScjs.getOpenRouterProviderConfig; exports.getProviderHeaders = _chunkQ27JY5RGcjs.getProviderHeaders; exports.normalizeAzureEndpoint = _chunkA2YMUCBTcjs.normalizeAzureEndpoint; exports.registerStreamEventBuffer = _chunk26K6T2YScjs.register; exports.releaseStreamEventBuffer = _chunk26K6T2YScjs.release; exports.resolveApiFormat = _chunkA2YMUCBTcjs.resolveApiFormat; exports.resolveProviderEndpoint = _chunkA2YMUCBTcjs.resolveProviderEndpoint;
115
+ exports.BuiltinToolExecutor = _chunkNZYN7C3Pcjs.BuiltinToolExecutor; exports.CompletionService = _chunkTIT74RILcjs.CompletionService; exports.NATIVE_SEARCH_TOOL_NAMES = _chunkGMMT7RVNcjs.NATIVE_SEARCH_TOOL_NAMES; exports.addOpenRouterProviderToRequest = _chunkTIT74RILcjs.addOpenRouterProviderToRequest; exports.applyAugmentation = _chunkJMJBSACDcjs.applyAugmentation; exports.attachStreamEventBuffer = _chunkTIT74RILcjs.attach; exports.buildAnthropicApiUrl = _chunkA2YMUCBTcjs.buildAnthropicApiUrl; exports.buildAzureOpenAIApiUrl = _chunkA2YMUCBTcjs.buildAzureOpenAIApiUrl; exports.buildGeminiApiUrl = _chunkA2YMUCBTcjs.buildGeminiApiUrl; exports.buildNativeSearchAugmentation = _chunkJMJBSACDcjs.buildNativeSearchAugmentation; exports.buildOpenAIApiUrl = _chunkA2YMUCBTcjs.buildOpenAIApiUrl; exports.buildOpenAIResponseApiUrl = _chunkA2YMUCBTcjs.buildOpenAIResponseApiUrl; exports.buildProviderApiUrl = _chunkA2YMUCBTcjs.buildProviderApiUrl; exports.convertMessageToAnthropic = _chunkTIT74RILcjs.convertMessageToAnthropic; exports.convertMessageToGemini = _chunkTIT74RILcjs.convertMessageToGemini; exports.convertMessageToOpenAI = _chunkTIT74RILcjs.convertMessageToOpenAI; exports.detectNativeSearch = _chunkJMJBSACDcjs.detectNativeSearch; exports.emitStreamEvent = _chunkTIT74RILcjs.emit; exports.getBuiltinSearchTools = _chunkNZYN7C3Pcjs.getBuiltinSearchTools; exports.getOpenRouterProviderConfig = _chunkTIT74RILcjs.getOpenRouterProviderConfig; exports.getProviderHeaders = _chunkQ27JY5RGcjs.getProviderHeaders; exports.normalizeAzureEndpoint = _chunkA2YMUCBTcjs.normalizeAzureEndpoint; exports.registerStreamEventBuffer = _chunkTIT74RILcjs.register; exports.releaseStreamEventBuffer = _chunkTIT74RILcjs.release; exports.resolveApiFormat = _chunkA2YMUCBTcjs.resolveApiFormat; exports.resolveProviderEndpoint = _chunkA2YMUCBTcjs.resolveProviderEndpoint;