@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
@@ -0,0 +1,150 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } var _class;// src/usage/throughputTracker.ts
2
+ var THROUGHPUT_RETENTION_MS = 15 * 6e4;
3
+ var THROUGHPUT_SAMPLE_LIMIT = 2e4;
4
+ var THROUGHPUT_WINDOWS_MS = [6e4, 3e5, 9e5];
5
+ var THROUGHPUT_BUCKET_COUNT = 30;
6
+ var COMPACT_THRESHOLD = 1024;
7
+ var UsageThroughputTracker = (_class = class {
8
+ __init() {this.samples = []}
9
+ /** Index of the oldest live sample; slots before it are consumed. */
10
+ __init2() {this.head = 0}
11
+
12
+ /** Newest ts dropped by the sample CAP (not by retention). Null when none. */
13
+ __init3() {this.evictedThroughTs = null}
14
+ constructor(now = Date.now()) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);
15
+ this.startedAt = now;
16
+ }
17
+ /** Record one served request. O(1) amortised; never touches disk. */
18
+ record(input, now = Date.now()) {
19
+ this.samples.push({
20
+ ts: _nullishCoalesce(input.ts, () => ( now)),
21
+ inputTokens: input.inputTokens,
22
+ outputTokens: input.outputTokens,
23
+ cacheReadTokens: input.cacheReadTokens,
24
+ cacheCreationTokens: input.cacheCreationTokens,
25
+ reasoningTokens: input.reasoningTokens,
26
+ costUsd: input.costUsd
27
+ });
28
+ this.prune(now);
29
+ }
30
+ /** Aggregate every reported window plus the shared trend series. */
31
+ snapshot(now = Date.now()) {
32
+ this.prune(now);
33
+ return {
34
+ available: true,
35
+ collectedAt: now,
36
+ startedAt: this.startedAt,
37
+ retentionMs: THROUGHPUT_RETENTION_MS,
38
+ bucketMs: THROUGHPUT_RETENTION_MS / THROUGHPUT_BUCKET_COUNT,
39
+ windows: THROUGHPUT_WINDOWS_MS.map((windowMs) => this.window(windowMs, now)),
40
+ buckets: this.buckets(now)
41
+ };
42
+ }
43
+ /** Drop all samples (tests / teardown). `startedAt` is unchanged. */
44
+ clear() {
45
+ this.samples = [];
46
+ this.head = 0;
47
+ this.evictedThroughTs = null;
48
+ }
49
+ /**
50
+ * Drop samples past the retention horizon, then enforce the sample cap.
51
+ *
52
+ * Retention pruning uses the CALLER's `now`, which is never later than a
53
+ * subsequent snapshot's `now`, so it can only ever keep MORE than the widest
54
+ * window needs — it can never shave data off the 15-minute window.
55
+ */
56
+ prune(now) {
57
+ const cutoff = now - THROUGHPUT_RETENTION_MS;
58
+ while (this.head < this.samples.length && this.samples[this.head].ts < cutoff) {
59
+ this.head += 1;
60
+ }
61
+ while (this.samples.length - this.head > THROUGHPUT_SAMPLE_LIMIT) {
62
+ const dropped = this.samples[this.head];
63
+ this.evictedThroughTs = this.evictedThroughTs === null ? dropped.ts : Math.max(this.evictedThroughTs, dropped.ts);
64
+ this.head += 1;
65
+ }
66
+ if (this.head >= COMPACT_THRESHOLD) {
67
+ this.samples = this.samples.slice(this.head);
68
+ this.head = 0;
69
+ }
70
+ }
71
+ window(windowMs, now) {
72
+ const startTs = now - windowMs;
73
+ const row = {
74
+ windowMs,
75
+ requests: 0,
76
+ inputTokens: 0,
77
+ outputTokens: 0,
78
+ cacheReadTokens: 0,
79
+ cacheCreationTokens: 0,
80
+ reasoningTokens: 0,
81
+ totalTokens: 0,
82
+ costUsd: 0,
83
+ requestsPerMinute: 0,
84
+ tokensPerMinute: 0,
85
+ inputTokensPerMinute: 0,
86
+ outputTokensPerMinute: 0,
87
+ costUsdPerMinute: 0,
88
+ complete: this.evictedThroughTs === null || this.evictedThroughTs < startTs
89
+ };
90
+ for (let i = this.head; i < this.samples.length; i += 1) {
91
+ const sample = this.samples[i];
92
+ if (sample.ts < startTs) continue;
93
+ row.requests += 1;
94
+ row.inputTokens += sample.inputTokens;
95
+ row.outputTokens += sample.outputTokens;
96
+ row.cacheReadTokens += sample.cacheReadTokens;
97
+ row.cacheCreationTokens += sample.cacheCreationTokens;
98
+ row.reasoningTokens += sample.reasoningTokens;
99
+ row.costUsd += sample.costUsd;
100
+ }
101
+ row.totalTokens = row.inputTokens + row.outputTokens + row.cacheReadTokens + row.cacheCreationTokens;
102
+ const minutes = windowMs / 6e4;
103
+ row.requestsPerMinute = row.requests / minutes;
104
+ row.tokensPerMinute = row.totalTokens / minutes;
105
+ row.inputTokensPerMinute = row.inputTokens / minutes;
106
+ row.outputTokensPerMinute = row.outputTokens / minutes;
107
+ row.costUsdPerMinute = row.costUsd / minutes;
108
+ return row;
109
+ }
110
+ buckets(now) {
111
+ const bucketMs = THROUGHPUT_RETENTION_MS / THROUGHPUT_BUCKET_COUNT;
112
+ const endTs = Math.floor(now / bucketMs) * bucketMs + bucketMs;
113
+ const startTs = endTs - THROUGHPUT_RETENTION_MS;
114
+ const out = [];
115
+ for (let i = 0; i < THROUGHPUT_BUCKET_COUNT; i += 1) {
116
+ out.push({ startTs: startTs + i * bucketMs, requests: 0, tokens: 0 });
117
+ }
118
+ for (let i = this.head; i < this.samples.length; i += 1) {
119
+ const sample = this.samples[i];
120
+ if (sample.ts < startTs || sample.ts >= endTs) continue;
121
+ const bucket = out[Math.floor((sample.ts - startTs) / bucketMs)];
122
+ if (!bucket) continue;
123
+ bucket.requests += 1;
124
+ bucket.tokens += sample.inputTokens + sample.outputTokens + sample.cacheReadTokens + sample.cacheCreationTokens;
125
+ }
126
+ return out;
127
+ }
128
+ }, _class);
129
+ var sharedTracker = null;
130
+ function getSharedUsageThroughputTracker() {
131
+ if (!sharedTracker) sharedTracker = new UsageThroughputTracker();
132
+ return sharedTracker;
133
+ }
134
+ function setSharedUsageThroughputTracker(instance) {
135
+ sharedTracker = instance;
136
+ }
137
+ function __resetSharedUsageThroughputTrackerForTests() {
138
+ sharedTracker = null;
139
+ }
140
+
141
+
142
+
143
+
144
+
145
+
146
+
147
+
148
+
149
+
150
+ exports.THROUGHPUT_RETENTION_MS = THROUGHPUT_RETENTION_MS; exports.THROUGHPUT_SAMPLE_LIMIT = THROUGHPUT_SAMPLE_LIMIT; exports.THROUGHPUT_WINDOWS_MS = THROUGHPUT_WINDOWS_MS; exports.THROUGHPUT_BUCKET_COUNT = THROUGHPUT_BUCKET_COUNT; exports.UsageThroughputTracker = UsageThroughputTracker; exports.getSharedUsageThroughputTracker = getSharedUsageThroughputTracker; exports.setSharedUsageThroughputTracker = setSharedUsageThroughputTracker; exports.__resetSharedUsageThroughputTrackerForTests = __resetSharedUsageThroughputTrackerForTests;
@@ -1,4 +1,13 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/transformer/transformers/utils/gemini.response-in.ts
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
+
3
+ var _chunk77USGNRWcjs = require('./chunk-77USGNRW.cjs');
4
+
5
+
6
+
7
+
8
+ var _chunkAOFWNWLTcjs = require('./chunk-AOFWNWLT.cjs');
9
+
10
+ // src/transformer/transformers/utils/gemini.response-in.ts
2
11
  var FINISH_REASON_TO_GEMINI = {
3
12
  stop: "STOP",
4
13
  length: "MAX_TOKENS",
@@ -685,7 +694,7 @@ function transformTool(tool) {
685
694
  }
686
695
 
687
696
  // src/transformer/transformers/utils/gemini.util.ts
688
- function buildRequestBody(request) {
697
+ function buildRequestBody(request, provider, preserveNativeEffort = false) {
689
698
  const tools = [];
690
699
  const functionDeclarations = _optionalChain([request, 'access', _99 => _99.tools, 'optionalAccess', _100 => _100.filter, 'call', _101 => _101((tool) => tool.function.name !== "web_search"), 'optionalAccess', _102 => _102.map, 'call', _103 => _103((tool) => ({
691
700
  name: tool.function.name,
@@ -795,27 +804,24 @@ function buildRequestBody(request) {
795
804
  if (request.max_tokens !== void 0) {
796
805
  generationConfig.maxOutputTokens = request.max_tokens;
797
806
  }
798
- if (_optionalChain([request, 'access', _117 => _117.reasoning, 'optionalAccess', _118 => _118.effort]) && request.reasoning.effort !== "none") {
807
+ const reasoningPlan = _chunkAOFWNWLTcjs.resolveReasoningPlan.call(void 0, {
808
+ intent: _chunkAOFWNWLTcjs.extractReasoningIntent.call(void 0, request),
809
+ model: request.model,
810
+ provider,
811
+ target: "gemini",
812
+ requestMaxTokens: request.max_tokens,
813
+ preserveNativeEffort
814
+ });
815
+ if (_optionalChain([reasoningPlan, 'optionalAccess', _117 => _117.kind]) === "level") {
799
816
  generationConfig.thinkingConfig = {
800
- includeThoughts: true
817
+ includeThoughts: reasoningPlan.enabled,
818
+ thinkingLevel: reasoningPlan.effort
819
+ };
820
+ } else if (_optionalChain([reasoningPlan, 'optionalAccess', _118 => _118.kind]) === "budget") {
821
+ generationConfig.thinkingConfig = {
822
+ includeThoughts: reasoningPlan.enabled,
823
+ thinkingBudget: reasoningPlan.budgetTokens
801
824
  };
802
- if (request.model.includes("gemini-3")) {
803
- generationConfig.thinkingConfig.thinkingLevel = request.reasoning.effort;
804
- } else {
805
- const thinkingBudgets = request.model.includes("pro") ? [128, 32768] : [0, 24576];
806
- const maxTokens = request.reasoning.max_tokens;
807
- if (typeof maxTokens !== "undefined") {
808
- let thinkingBudget;
809
- if (maxTokens >= thinkingBudgets[0] && maxTokens <= thinkingBudgets[1]) {
810
- thinkingBudget = maxTokens;
811
- } else if (maxTokens < thinkingBudgets[0]) {
812
- thinkingBudget = thinkingBudgets[0];
813
- } else {
814
- thinkingBudget = thinkingBudgets[1];
815
- }
816
- generationConfig.thinkingConfig.thinkingBudget = thinkingBudget;
817
- }
818
- }
819
825
  }
820
826
  const body = {
821
827
  contents,
@@ -859,6 +865,17 @@ function transformRequestOut(request) {
859
865
  stream,
860
866
  tool_choice: toolChoice
861
867
  };
868
+ const thinkingConfig = _optionalChain([generationConfig, 'optionalAccess', _123 => _123.thinkingConfig]);
869
+ const discreteEffort = _chunkAOFWNWLTcjs.normalizeThinkLevel.call(void 0, _optionalChain([thinkingConfig, 'optionalAccess', _124 => _124.thinkingLevel]));
870
+ if (discreteEffort) {
871
+ unifiedRequest.reasoning = {
872
+ effort: discreteEffort,
873
+ enabled: discreteEffort !== "none"
874
+ };
875
+ } else if (typeof _optionalChain([thinkingConfig, 'optionalAccess', _125 => _125.thinkingBudget]) === "number" && Number.isFinite(thinkingConfig.thinkingBudget) && thinkingConfig.thinkingBudget >= 0) {
876
+ const budget = thinkingConfig.thinkingBudget;
877
+ unifiedRequest.reasoning = budget === 0 ? { effort: "none", enabled: false, max_tokens: 0 } : { effort: _chunk77USGNRWcjs.getThinkLevel.call(void 0, budget), enabled: true, max_tokens: budget };
878
+ }
862
879
  if (Array.isArray(contents)) {
863
880
  const toolCallIdsByName = /* @__PURE__ */ new Map();
864
881
  for (const content of contents) {
@@ -897,14 +914,14 @@ function transformRequestOut(request) {
897
914
  } else if ("inlineData" in part || "file_data" in part) {
898
915
  const inline = part.inlineData;
899
916
  const fileData = part.file_data;
900
- if (_optionalChain([inline, 'optionalAccess', _123 => _123.data])) {
917
+ if (_optionalChain([inline, 'optionalAccess', _126 => _126.data])) {
901
918
  const mime = inline.mime_type || "image/png";
902
919
  contentParts.push({
903
920
  type: "image_url",
904
921
  image_url: { url: `data:${mime};base64,${inline.data}` },
905
922
  media_type: mime
906
923
  });
907
- } else if (_optionalChain([fileData, 'optionalAccess', _124 => _124.file_uri])) {
924
+ } else if (_optionalChain([fileData, 'optionalAccess', _127 => _127.file_uri])) {
908
925
  contentParts.push({
909
926
  type: "image_url",
910
927
  image_url: { url: fileData.file_uri },
@@ -924,7 +941,7 @@ function transformRequestOut(request) {
924
941
  const queue = toolCallIdsByName.get(fnName);
925
942
  const id = queue && queue.length > 0 ? queue.shift() : `tool_${Math.random().toString(36).substring(2, 15)}`;
926
943
  const response = fr.functionResponse.response;
927
- const result = _optionalChain([response, 'optionalAccess', _125 => _125.result]);
944
+ const result = _optionalChain([response, 'optionalAccess', _128 => _128.result]);
928
945
  const toolContent = typeof result === "string" ? result : result !== void 0 ? JSON.stringify(result) : response !== void 0 ? JSON.stringify(response) : "";
929
946
  unifiedRequest.messages.push({
930
947
  role: "tool",
@@ -1,3 +1,12 @@
1
+ import {
2
+ getThinkLevel
3
+ } from "./chunk-WYVGULTQ.js";
4
+ import {
5
+ extractReasoningIntent,
6
+ normalizeThinkLevel,
7
+ resolveReasoningPlan
8
+ } from "./chunk-N2EIM2XJ.js";
9
+
1
10
  // src/transformer/transformers/utils/gemini.response-in.ts
2
11
  var FINISH_REASON_TO_GEMINI = {
3
12
  stop: "STOP",
@@ -685,7 +694,7 @@ function transformTool(tool) {
685
694
  }
686
695
 
687
696
  // src/transformer/transformers/utils/gemini.util.ts
688
- function buildRequestBody(request) {
697
+ function buildRequestBody(request, provider, preserveNativeEffort = false) {
689
698
  const tools = [];
690
699
  const functionDeclarations = request.tools?.filter((tool) => tool.function.name !== "web_search")?.map((tool) => ({
691
700
  name: tool.function.name,
@@ -795,27 +804,24 @@ function buildRequestBody(request) {
795
804
  if (request.max_tokens !== void 0) {
796
805
  generationConfig.maxOutputTokens = request.max_tokens;
797
806
  }
798
- if (request.reasoning?.effort && request.reasoning.effort !== "none") {
807
+ const reasoningPlan = resolveReasoningPlan({
808
+ intent: extractReasoningIntent(request),
809
+ model: request.model,
810
+ provider,
811
+ target: "gemini",
812
+ requestMaxTokens: request.max_tokens,
813
+ preserveNativeEffort
814
+ });
815
+ if (reasoningPlan?.kind === "level") {
799
816
  generationConfig.thinkingConfig = {
800
- includeThoughts: true
817
+ includeThoughts: reasoningPlan.enabled,
818
+ thinkingLevel: reasoningPlan.effort
819
+ };
820
+ } else if (reasoningPlan?.kind === "budget") {
821
+ generationConfig.thinkingConfig = {
822
+ includeThoughts: reasoningPlan.enabled,
823
+ thinkingBudget: reasoningPlan.budgetTokens
801
824
  };
802
- if (request.model.includes("gemini-3")) {
803
- generationConfig.thinkingConfig.thinkingLevel = request.reasoning.effort;
804
- } else {
805
- const thinkingBudgets = request.model.includes("pro") ? [128, 32768] : [0, 24576];
806
- const maxTokens = request.reasoning.max_tokens;
807
- if (typeof maxTokens !== "undefined") {
808
- let thinkingBudget;
809
- if (maxTokens >= thinkingBudgets[0] && maxTokens <= thinkingBudgets[1]) {
810
- thinkingBudget = maxTokens;
811
- } else if (maxTokens < thinkingBudgets[0]) {
812
- thinkingBudget = thinkingBudgets[0];
813
- } else {
814
- thinkingBudget = thinkingBudgets[1];
815
- }
816
- generationConfig.thinkingConfig.thinkingBudget = thinkingBudget;
817
- }
818
- }
819
825
  }
820
826
  const body = {
821
827
  contents,
@@ -859,6 +865,17 @@ function transformRequestOut(request) {
859
865
  stream,
860
866
  tool_choice: toolChoice
861
867
  };
868
+ const thinkingConfig = generationConfig?.thinkingConfig;
869
+ const discreteEffort = normalizeThinkLevel(thinkingConfig?.thinkingLevel);
870
+ if (discreteEffort) {
871
+ unifiedRequest.reasoning = {
872
+ effort: discreteEffort,
873
+ enabled: discreteEffort !== "none"
874
+ };
875
+ } else if (typeof thinkingConfig?.thinkingBudget === "number" && Number.isFinite(thinkingConfig.thinkingBudget) && thinkingConfig.thinkingBudget >= 0) {
876
+ const budget = thinkingConfig.thinkingBudget;
877
+ unifiedRequest.reasoning = budget === 0 ? { effort: "none", enabled: false, max_tokens: 0 } : { effort: getThinkLevel(budget), enabled: true, max_tokens: budget };
878
+ }
862
879
  if (Array.isArray(contents)) {
863
880
  const toolCallIdsByName = /* @__PURE__ */ new Map();
864
881
  for (const content of contents) {