getkova 2026.4.21 → 2026.4.22

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 (102) hide show
  1. package/dist/control-ui/apple-touch-icon.png +0 -0
  2. package/dist/control-ui/assets/agents-CLtFQRXd.js +918 -0
  3. package/dist/control-ui/assets/agents-CLtFQRXd.js.map +1 -0
  4. package/dist/control-ui/assets/anthropic-CFEPAL-v.js +37 -0
  5. package/dist/control-ui/assets/anthropic-CFEPAL-v.js.map +1 -0
  6. package/dist/control-ui/assets/azure-openai-responses-CxiWQLmZ.js +2 -0
  7. package/dist/control-ui/assets/azure-openai-responses-CxiWQLmZ.js.map +1 -0
  8. package/dist/control-ui/assets/briefing-DS4VWpUL.js +121 -0
  9. package/dist/control-ui/assets/briefing-DS4VWpUL.js.map +1 -0
  10. package/dist/control-ui/assets/canvas-BfC_2Nqy.js +17 -0
  11. package/dist/control-ui/assets/canvas-BfC_2Nqy.js.map +1 -0
  12. package/dist/control-ui/assets/channel-config-extras-YNNd-4PG.js +2 -0
  13. package/dist/control-ui/assets/channel-config-extras-YNNd-4PG.js.map +1 -0
  14. package/dist/control-ui/assets/channels-BKdM7i5r.js +471 -0
  15. package/dist/control-ui/assets/channels-BKdM7i5r.js.map +1 -0
  16. package/dist/control-ui/assets/cron-C11m3yJi.js +928 -0
  17. package/dist/control-ui/assets/cron-C11m3yJi.js.map +1 -0
  18. package/dist/control-ui/assets/de-rLAkQOBc.js +2 -0
  19. package/dist/control-ui/assets/de-rLAkQOBc.js.map +1 -0
  20. package/dist/control-ui/assets/debug-DFf2qCcM.js +94 -0
  21. package/dist/control-ui/assets/debug-DFf2qCcM.js.map +1 -0
  22. package/dist/control-ui/assets/dist-D8DZLmCF.js +18 -0
  23. package/dist/control-ui/assets/dist-D8DZLmCF.js.map +1 -0
  24. package/dist/control-ui/assets/employees-DV-5FV4K.js +104 -0
  25. package/dist/control-ui/assets/employees-DV-5FV4K.js.map +1 -0
  26. package/dist/control-ui/assets/es-CIeD3O54.js +2 -0
  27. package/dist/control-ui/assets/es-CIeD3O54.js.map +1 -0
  28. package/dist/control-ui/assets/event-stream-B8X6sYaV.js +2 -0
  29. package/dist/control-ui/assets/event-stream-B8X6sYaV.js.map +1 -0
  30. package/dist/control-ui/assets/format-BahKhiOC.js +2 -0
  31. package/dist/control-ui/assets/format-BahKhiOC.js.map +1 -0
  32. package/dist/control-ui/assets/github-copilot-headers-CrI0CIJ7.js +2 -0
  33. package/dist/control-ui/assets/github-copilot-headers-CrI0CIJ7.js.map +1 -0
  34. package/dist/control-ui/assets/google-BT0bmsh5.js +2 -0
  35. package/dist/control-ui/assets/google-BT0bmsh5.js.map +1 -0
  36. package/dist/control-ui/assets/google-gemini-cli-BpxbH95Q.js +3 -0
  37. package/dist/control-ui/assets/google-gemini-cli-BpxbH95Q.js.map +1 -0
  38. package/dist/control-ui/assets/google-shared-CbPHVnPr.js +12 -0
  39. package/dist/control-ui/assets/google-shared-CbPHVnPr.js.map +1 -0
  40. package/dist/control-ui/assets/google-vertex-lQwbjEII.js +2 -0
  41. package/dist/control-ui/assets/google-vertex-lQwbjEII.js.map +1 -0
  42. package/dist/control-ui/assets/hash-Bt1aVMQ3.js +2 -0
  43. package/dist/control-ui/assets/hash-Bt1aVMQ3.js.map +1 -0
  44. package/dist/control-ui/assets/inbox-C4tOnlJr.js +100 -0
  45. package/dist/control-ui/assets/inbox-C4tOnlJr.js.map +1 -0
  46. package/dist/control-ui/assets/index-DYMuTfvX.css +1 -0
  47. package/dist/control-ui/assets/index-XGDpaFxG.js +5482 -0
  48. package/dist/control-ui/assets/index-XGDpaFxG.js.map +1 -0
  49. package/dist/control-ui/assets/instances-Cyr-tbN6.js +57 -0
  50. package/dist/control-ui/assets/instances-Cyr-tbN6.js.map +1 -0
  51. package/dist/control-ui/assets/kova-logo.png +0 -0
  52. package/dist/control-ui/assets/lit-zdTgzAJI.js +3 -0
  53. package/dist/control-ui/assets/lit-zdTgzAJI.js.map +1 -0
  54. package/dist/control-ui/assets/local-storage-D3baoRWx.js +2 -0
  55. package/dist/control-ui/assets/local-storage-D3baoRWx.js.map +1 -0
  56. package/dist/control-ui/assets/logs-B7--7dYP.js +74 -0
  57. package/dist/control-ui/assets/logs-B7--7dYP.js.map +1 -0
  58. package/dist/control-ui/assets/meetings-DSqn6s7n.js +185 -0
  59. package/dist/control-ui/assets/meetings-DSqn6s7n.js.map +1 -0
  60. package/dist/control-ui/assets/mistral-CBrDC_Gv.js +8 -0
  61. package/dist/control-ui/assets/mistral-CBrDC_Gv.js.map +1 -0
  62. package/dist/control-ui/assets/nodes-Cvq_sAqT.js +430 -0
  63. package/dist/control-ui/assets/nodes-Cvq_sAqT.js.map +1 -0
  64. package/dist/control-ui/assets/openai-Cn7eGqwa.js +17 -0
  65. package/dist/control-ui/assets/openai-Cn7eGqwa.js.map +1 -0
  66. package/dist/control-ui/assets/openai-codex-responses-DuhESMYF.js +8 -0
  67. package/dist/control-ui/assets/openai-codex-responses-DuhESMYF.js.map +1 -0
  68. package/dist/control-ui/assets/openai-completions-Bv33lqKL.js +6 -0
  69. package/dist/control-ui/assets/openai-completions-Bv33lqKL.js.map +1 -0
  70. package/dist/control-ui/assets/openai-responses-BPxpapOg.js +2 -0
  71. package/dist/control-ui/assets/openai-responses-BPxpapOg.js.map +1 -0
  72. package/dist/control-ui/assets/openai-responses-shared-8nKH8ywL.js +11 -0
  73. package/dist/control-ui/assets/openai-responses-shared-8nKH8ywL.js.map +1 -0
  74. package/dist/control-ui/assets/pdf-BwYFZMZM.js +57 -0
  75. package/dist/control-ui/assets/pdf-BwYFZMZM.js.map +1 -0
  76. package/dist/control-ui/assets/pdf.worker.min-BmpgcBpm.js +2 -0
  77. package/dist/control-ui/assets/pdf.worker.min-BmpgcBpm.js.map +1 -0
  78. package/dist/control-ui/assets/pdf.worker.min-C8PGFc0r.mjs +28 -0
  79. package/dist/control-ui/assets/preload-helper-Chd9yIcd.js +1 -0
  80. package/dist/control-ui/assets/pt-BR-lSsBb08k.js +2 -0
  81. package/dist/control-ui/assets/pt-BR-lSsBb08k.js.map +1 -0
  82. package/dist/control-ui/assets/routing-DizI_FiJ.js +157 -0
  83. package/dist/control-ui/assets/routing-DizI_FiJ.js.map +1 -0
  84. package/dist/control-ui/assets/sessions-N9rgJP2R.js +236 -0
  85. package/dist/control-ui/assets/sessions-N9rgJP2R.js.map +1 -0
  86. package/dist/control-ui/assets/skills-D1vP4MkL.js +280 -0
  87. package/dist/control-ui/assets/skills-D1vP4MkL.js.map +1 -0
  88. package/dist/control-ui/assets/skills-shared-Bg0Qcnkp.js +11 -0
  89. package/dist/control-ui/assets/skills-shared-Bg0Qcnkp.js.map +1 -0
  90. package/dist/control-ui/assets/transform-messages-XKqwKV3D.js +2 -0
  91. package/dist/control-ui/assets/transform-messages-XKqwKV3D.js.map +1 -0
  92. package/dist/control-ui/assets/zh-CN-C5tPG8Eu.js +2 -0
  93. package/dist/control-ui/assets/zh-CN-C5tPG8Eu.js.map +1 -0
  94. package/dist/control-ui/assets/zh-TW-CPSoC7Wz.js +2 -0
  95. package/dist/control-ui/assets/zh-TW-CPSoC7Wz.js.map +1 -0
  96. package/dist/control-ui/favicon-32.png +0 -0
  97. package/dist/control-ui/favicon.ico +0 -0
  98. package/dist/control-ui/favicon.png +0 -0
  99. package/dist/control-ui/favicon.svg +22 -0
  100. package/dist/control-ui/index.html +73 -0
  101. package/dist/control-ui/openclaw-canvas-auth-sw.js +57 -0
  102. package/package.json +1 -1
@@ -0,0 +1,2 @@
1
+ function e(e,t){if(e==null||!Number.isFinite(e)||e<=0)return;if(e<1e3)return`${Math.round(e)}ms`;let n=t?.spaced?` `:``,r=Math.round(e/1e3),i=Math.floor(r/3600),a=Math.floor(r%3600/60),o=r%60;if(i>=24){let e=Math.floor(i/24),t=i%24;return t>0?`${e}d${n}${t}h`:`${e}d`}return i>0?a>0?`${i}h${n}${a}m`:`${i}h`:a>0?o>0?`${a}m${n}${o}s`:`${a}m`:`${o}s`}function t(e,t=`n/a`){if(e==null||!Number.isFinite(e)||e<0)return t;if(e<1e3)return`${Math.round(e)}ms`;let n=Math.round(e/1e3);if(n<60)return`${n}s`;let r=Math.round(n/60);if(r<60)return`${r}m`;let i=Math.round(r/60);return i<24?`${i}h`:`${Math.round(i/24)}d`}function n(e,t){let n=t?.fallback??`n/a`;if(e==null||!Number.isFinite(e))return n;let r=Date.now()-e,i=Math.abs(r),a=r>=0,o=Math.round(i/1e3);if(o<60)return a?`just now`:`in <1m`;let s=Math.round(o/60);if(s<60)return a?`${s}m ago`:`in ${s}m`;let c=Math.round(s/60);if(c<48)return a?`${c}h ago`:`in ${c}h`;let l=Math.round(c/24);if(!t?.dateFallback||l<=7)return a?`${l}d ago`:`in ${l}d`;try{return new Intl.DateTimeFormat(`en-US`,{month:`short`,day:`numeric`,...t.timezone?{timeZone:t.timezone}:{}}).format(new Date(e))}catch{return`${l}d ago`}}function r(e){let t=[];for(let n of e.matchAll(/(^|\n)(```|~~~)[^\n]*\n[\s\S]*?(?:\n\2|$)/g)){let e=(n.index??0)+n[1].length;t.push({start:e,end:e+n[0].length-n[1].length})}for(let n of e.matchAll(/`+[^`]+`+/g)){let e=n.index??0,r=e+n[0].length;t.some(t=>e>=t.start&&r<=t.end)||t.push({start:e,end:r})}return t.sort((e,t)=>e.start-t.start),t}function i(e,t){return t.some(t=>e>=t.start&&e<t.end)}var a=/<\s*\/?\s*(?:think(?:ing)?|thought|antthinking|final)\b/i,o=/<\s*\/?\s*final\b[^<>]*>/gi,s=/<\s*(\/?)\s*(?:think(?:ing)?|thought|antthinking)\b[^<>]*>/gi;function c(e,t){return t===`none`?e:t===`start`?e.trimStart():e.trim()}function l(e,t){if(!e||!a.test(e))return e;let n=t?.mode??`strict`,l=t?.trim??`both`,u=e;if(o.test(u)){o.lastIndex=0;let e=[],t=r(u);for(let n of u.matchAll(o)){let r=n.index??0;e.push({start:r,length:n[0].length,inCode:i(r,t)})}for(let t=e.length-1;t>=0;t--){let n=e[t];n.inCode||(u=u.slice(0,n.start)+u.slice(n.start+n.length))}}else o.lastIndex=0;let d=r(u);s.lastIndex=0;let f=``,p=0,m=!1;for(let e of u.matchAll(s)){let t=e.index??0,n=e[1]===`/`;i(t,d)||(m?n&&(m=!1):(f+=u.slice(p,t),n||(m=!0)),p=t+e[0].length)}return(!m||n===`preserve`)&&(f+=u.slice(p)),c(f,l)}var u=/<\s*(\/?)\s*relevant[-_]memories\b[^<>]*>/gi,d=/<\s*\/?\s*relevant[-_]memories\b/i;function f(e){if(!e||!d.test(e))return e;u.lastIndex=0;let t=r(e),n=``,a=0,o=!1;for(let r of e.matchAll(u)){let s=r.index??0;if(i(s,t))continue;let c=r[1]===`/`;o?c&&(o=!1):(n+=e.slice(a,s),c||(o=!0)),a=s+r[0].length}return o||(n+=e.slice(a)),n}function p(e){return f(l(e,{mode:`preserve`,trim:`start`})).trimStart()}function m(e){return!e&&e!==0?`n/a`:new Date(e).toLocaleString()}function h(e){return!e||e.length===0?`none`:e.filter(e=>!!(e&&e.trim())).join(`, `)}function g(e,t=120){return e.length<=t?e:`${e.slice(0,Math.max(0,t-1))}…`}function _(e,t){return e.length<=t?{text:e,truncated:!1,total:e.length}:{text:e.slice(0,Math.max(0,t)),truncated:!0,total:e.length}}function v(e,t){let n=Number(e);return Number.isFinite(n)?n:t}function y(e){return p(e)}function b(e,t=`$0.00`){return e==null||!Number.isFinite(e)?t:e===0?`$0.00`:e<.01?`$${e.toFixed(4)}`:e<1?`$${e.toFixed(3)}`:`$${e.toFixed(2)}`}function x(e,t=`0`){if(e==null||!Number.isFinite(e))return t;if(e<1e3)return String(Math.round(e));if(e<1e6){let t=e/1e3;return t<10?`${t.toFixed(1)}k`:`${Math.round(t)}k`}let n=e/1e6;return n<10?`${n.toFixed(1)}M`:`${Math.round(n)}M`}export{x as a,_ as c,t as d,m as i,n as l,b as n,y as o,h as r,v as s,g as t,e as u};
2
+ //# sourceMappingURL=format-BahKhiOC.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format-BahKhiOC.js","names":[],"sources":["../../../src/infra/format-time/format-duration.ts","../../../src/infra/format-time/format-relative.ts","../../../src/shared/text/code-regions.ts","../../../src/shared/text/reasoning-tags.ts","../../../src/shared/text/assistant-visible-text.ts","../../../ui/src/ui/format.ts"],"sourcesContent":["export type FormatDurationSecondsOptions = {\n decimals?: number;\n unit?: \"s\" | \"seconds\";\n};\n\nexport type FormatDurationCompactOptions = {\n /** Add space between units: \"2m 5s\" instead of \"2m5s\". Default: false */\n spaced?: boolean;\n};\n\nexport function formatDurationSeconds(\n ms: number,\n options: FormatDurationSecondsOptions = {},\n): string {\n if (!Number.isFinite(ms)) {\n return \"unknown\";\n }\n const decimals = options.decimals ?? 1;\n const unit = options.unit ?? \"s\";\n const seconds = Math.max(0, ms) / 1000;\n const fixed = seconds.toFixed(Math.max(0, decimals));\n const trimmed = fixed.replace(/\\.0+$/, \"\").replace(/(\\.\\d*[1-9])0+$/, \"$1\");\n return unit === \"seconds\" ? `${trimmed} seconds` : `${trimmed}s`;\n}\n\n/** Precise decimal-seconds output: \"500ms\" or \"1.23s\". Input is milliseconds. */\nexport function formatDurationPrecise(\n ms: number,\n options: FormatDurationSecondsOptions = {},\n): string {\n if (!Number.isFinite(ms)) {\n return \"unknown\";\n }\n if (ms < 1000) {\n return `${Math.max(0, Math.round(ms))}ms`;\n }\n return formatDurationSeconds(ms, {\n decimals: options.decimals ?? 2,\n unit: options.unit ?? \"s\",\n });\n}\n\n/**\n * Compact compound duration: \"500ms\", \"45s\", \"2m5s\", \"1h30m\".\n * With `spaced`: \"45s\", \"2m 5s\", \"1h 30m\".\n * Omits trailing zero components: \"1m\" not \"1m 0s\", \"2h\" not \"2h 0m\".\n * Returns undefined for null/undefined/non-finite/non-positive input.\n */\nexport function formatDurationCompact(\n ms?: number | null,\n options?: FormatDurationCompactOptions,\n): string | undefined {\n if (ms == null || !Number.isFinite(ms) || ms <= 0) {\n return undefined;\n }\n if (ms < 1000) {\n return `${Math.round(ms)}ms`;\n }\n const sep = options?.spaced ? \" \" : \"\";\n const totalSeconds = Math.round(ms / 1000);\n const hours = Math.floor(totalSeconds / 3600);\n const minutes = Math.floor((totalSeconds % 3600) / 60);\n const seconds = totalSeconds % 60;\n if (hours >= 24) {\n const days = Math.floor(hours / 24);\n const remainingHours = hours % 24;\n return remainingHours > 0 ? `${days}d${sep}${remainingHours}h` : `${days}d`;\n }\n if (hours > 0) {\n return minutes > 0 ? `${hours}h${sep}${minutes}m` : `${hours}h`;\n }\n if (minutes > 0) {\n return seconds > 0 ? `${minutes}m${sep}${seconds}s` : `${minutes}m`;\n }\n return `${seconds}s`;\n}\n\n/**\n * Rounded single-unit duration for display: \"500ms\", \"5s\", \"3m\", \"2h\", \"5d\".\n * Returns fallback string for null/undefined/non-finite input.\n */\nexport function formatDurationHuman(ms?: number | null, fallback = \"n/a\"): string {\n if (ms == null || !Number.isFinite(ms) || ms < 0) {\n return fallback;\n }\n if (ms < 1000) {\n return `${Math.round(ms)}ms`;\n }\n const sec = Math.round(ms / 1000);\n if (sec < 60) {\n return `${sec}s`;\n }\n const min = Math.round(sec / 60);\n if (min < 60) {\n return `${min}m`;\n }\n const hr = Math.round(min / 60);\n if (hr < 24) {\n return `${hr}h`;\n }\n const day = Math.round(hr / 24);\n return `${day}d`;\n}\n","/**\n * Centralized relative-time formatting utilities.\n *\n * Consolidates 7+ scattered implementations (formatAge, formatAgeShort, formatAgo,\n * formatRelativeTime, formatElapsedTime) into two functions:\n *\n * - `formatTimeAgo(durationMs)` — format a duration as \"5m ago\" / \"5m\" (for known elapsed time)\n * - `formatRelativeTimestamp(epochMs)` — format an epoch timestamp relative to now (handles future)\n */\n\nexport type FormatTimeAgoOptions = {\n /** Append \"ago\" suffix. Default: true. When false, returns bare unit: \"5m\", \"2h\" */\n suffix?: boolean;\n /** Return value for invalid/null/negative input. Default: \"unknown\" */\n fallback?: string;\n};\n\n/**\n * Format a duration (in ms) as a human-readable relative time.\n *\n * Input: how many milliseconds ago something happened.\n *\n * With suffix (default): \"just now\", \"5m ago\", \"3h ago\", \"2d ago\"\n * Without suffix: \"0s\", \"5m\", \"3h\", \"2d\"\n */\nexport function formatTimeAgo(\n durationMs: number | null | undefined,\n options?: FormatTimeAgoOptions,\n): string {\n const suffix = options?.suffix !== false;\n const fallback = options?.fallback ?? \"unknown\";\n\n if (durationMs == null || !Number.isFinite(durationMs) || durationMs < 0) {\n return fallback;\n }\n\n const totalSeconds = Math.round(durationMs / 1000);\n const minutes = Math.round(totalSeconds / 60);\n\n if (minutes < 1) {\n return suffix ? \"just now\" : `${totalSeconds}s`;\n }\n if (minutes < 60) {\n return suffix ? `${minutes}m ago` : `${minutes}m`;\n }\n const hours = Math.round(minutes / 60);\n if (hours < 48) {\n return suffix ? `${hours}h ago` : `${hours}h`;\n }\n const days = Math.round(hours / 24);\n return suffix ? `${days}d ago` : `${days}d`;\n}\n\nexport type FormatRelativeTimestampOptions = {\n /** If true, fall back to short date (e.g. \"Oct 5\") for timestamps >7 days. Default: false */\n dateFallback?: boolean;\n /** IANA timezone for date fallback display */\n timezone?: string;\n /** Return value for invalid/null input. Default: \"n/a\" */\n fallback?: string;\n};\n\n/**\n * Format an epoch timestamp relative to now.\n *\n * Handles both past (\"5m ago\") and future (\"in 5m\") timestamps.\n * Optionally falls back to a short date for timestamps older than 7 days.\n */\nexport function formatRelativeTimestamp(\n timestampMs: number | null | undefined,\n options?: FormatRelativeTimestampOptions,\n): string {\n const fallback = options?.fallback ?? \"n/a\";\n if (timestampMs == null || !Number.isFinite(timestampMs)) {\n return fallback;\n }\n\n const diff = Date.now() - timestampMs;\n const absDiff = Math.abs(diff);\n const isPast = diff >= 0;\n\n const sec = Math.round(absDiff / 1000);\n if (sec < 60) {\n return isPast ? \"just now\" : \"in <1m\";\n }\n\n const min = Math.round(sec / 60);\n if (min < 60) {\n return isPast ? `${min}m ago` : `in ${min}m`;\n }\n\n const hr = Math.round(min / 60);\n if (hr < 48) {\n return isPast ? `${hr}h ago` : `in ${hr}h`;\n }\n\n const day = Math.round(hr / 24);\n if (!options?.dateFallback || day <= 7) {\n return isPast ? `${day}d ago` : `in ${day}d`;\n }\n\n // Fall back to short date display for old timestamps\n try {\n return new Intl.DateTimeFormat(\"en-US\", {\n month: \"short\",\n day: \"numeric\",\n ...(options.timezone ? { timeZone: options.timezone } : {}),\n }).format(new Date(timestampMs));\n } catch {\n return `${day}d ago`;\n }\n}\n","export interface CodeRegion {\n start: number;\n end: number;\n}\n\nexport function findCodeRegions(text: string): CodeRegion[] {\n const regions: CodeRegion[] = [];\n\n const fencedRe = /(^|\\n)(```|~~~)[^\\n]*\\n[\\s\\S]*?(?:\\n\\2|$)/g;\n for (const match of text.matchAll(fencedRe)) {\n const start = (match.index ?? 0) + match[1].length;\n regions.push({ start, end: start + match[0].length - match[1].length });\n }\n\n const inlineRe = /`+[^`]+`+/g;\n for (const match of text.matchAll(inlineRe)) {\n const start = match.index ?? 0;\n const end = start + match[0].length;\n const insideFenced = regions.some((r) => start >= r.start && end <= r.end);\n if (!insideFenced) {\n regions.push({ start, end });\n }\n }\n\n regions.sort((a, b) => a.start - b.start);\n return regions;\n}\n\nexport function isInsideCode(pos: number, regions: CodeRegion[]): boolean {\n return regions.some((r) => pos >= r.start && pos < r.end);\n}\n","import { findCodeRegions, isInsideCode } from \"./code-regions.js\";\nexport type ReasoningTagMode = \"strict\" | \"preserve\";\nexport type ReasoningTagTrim = \"none\" | \"start\" | \"both\";\n\nconst QUICK_TAG_RE = /<\\s*\\/?\\s*(?:think(?:ing)?|thought|antthinking|final)\\b/i;\nconst FINAL_TAG_RE = /<\\s*\\/?\\s*final\\b[^<>]*>/gi;\nconst THINKING_TAG_RE = /<\\s*(\\/?)\\s*(?:think(?:ing)?|thought|antthinking)\\b[^<>]*>/gi;\n\nfunction applyTrim(value: string, mode: ReasoningTagTrim): string {\n if (mode === \"none\") {\n return value;\n }\n if (mode === \"start\") {\n return value.trimStart();\n }\n return value.trim();\n}\n\nexport function stripReasoningTagsFromText(\n text: string,\n options?: {\n mode?: ReasoningTagMode;\n trim?: ReasoningTagTrim;\n },\n): string {\n if (!text) {\n return text;\n }\n if (!QUICK_TAG_RE.test(text)) {\n return text;\n }\n\n const mode = options?.mode ?? \"strict\";\n const trimMode = options?.trim ?? \"both\";\n\n let cleaned = text;\n if (FINAL_TAG_RE.test(cleaned)) {\n FINAL_TAG_RE.lastIndex = 0;\n const finalMatches: Array<{ start: number; length: number; inCode: boolean }> = [];\n const preCodeRegions = findCodeRegions(cleaned);\n for (const match of cleaned.matchAll(FINAL_TAG_RE)) {\n const start = match.index ?? 0;\n finalMatches.push({\n start,\n length: match[0].length,\n inCode: isInsideCode(start, preCodeRegions),\n });\n }\n\n for (let i = finalMatches.length - 1; i >= 0; i--) {\n const m = finalMatches[i];\n if (!m.inCode) {\n cleaned = cleaned.slice(0, m.start) + cleaned.slice(m.start + m.length);\n }\n }\n } else {\n FINAL_TAG_RE.lastIndex = 0;\n }\n\n const codeRegions = findCodeRegions(cleaned);\n\n THINKING_TAG_RE.lastIndex = 0;\n let result = \"\";\n let lastIndex = 0;\n let inThinking = false;\n\n for (const match of cleaned.matchAll(THINKING_TAG_RE)) {\n const idx = match.index ?? 0;\n const isClose = match[1] === \"/\";\n\n if (isInsideCode(idx, codeRegions)) {\n continue;\n }\n\n if (!inThinking) {\n result += cleaned.slice(lastIndex, idx);\n if (!isClose) {\n inThinking = true;\n }\n } else if (isClose) {\n inThinking = false;\n }\n\n lastIndex = idx + match[0].length;\n }\n\n if (!inThinking || mode === \"preserve\") {\n result += cleaned.slice(lastIndex);\n }\n\n return applyTrim(result, trimMode);\n}\n","import { findCodeRegions, isInsideCode } from \"./code-regions.js\";\nimport { stripReasoningTagsFromText } from \"./reasoning-tags.js\";\n\nconst MEMORY_TAG_RE = /<\\s*(\\/?)\\s*relevant[-_]memories\\b[^<>]*>/gi;\nconst MEMORY_TAG_QUICK_RE = /<\\s*\\/?\\s*relevant[-_]memories\\b/i;\n\nfunction stripRelevantMemoriesTags(text: string): string {\n if (!text || !MEMORY_TAG_QUICK_RE.test(text)) {\n return text;\n }\n MEMORY_TAG_RE.lastIndex = 0;\n\n const codeRegions = findCodeRegions(text);\n let result = \"\";\n let lastIndex = 0;\n let inMemoryBlock = false;\n\n for (const match of text.matchAll(MEMORY_TAG_RE)) {\n const idx = match.index ?? 0;\n if (isInsideCode(idx, codeRegions)) {\n continue;\n }\n\n const isClose = match[1] === \"/\";\n if (!inMemoryBlock) {\n result += text.slice(lastIndex, idx);\n if (!isClose) {\n inMemoryBlock = true;\n }\n } else if (isClose) {\n inMemoryBlock = false;\n }\n\n lastIndex = idx + match[0].length;\n }\n\n if (!inMemoryBlock) {\n result += text.slice(lastIndex);\n }\n\n return result;\n}\n\nexport function stripAssistantInternalScaffolding(text: string): string {\n const withoutReasoning = stripReasoningTagsFromText(text, { mode: \"preserve\", trim: \"start\" });\n return stripRelevantMemoriesTags(withoutReasoning).trimStart();\n}\n","import { formatDurationHuman } from \"../../../src/infra/format-time/format-duration.ts\";\nimport { formatRelativeTimestamp } from \"../../../src/infra/format-time/format-relative.ts\";\nimport { stripAssistantInternalScaffolding } from \"../../../src/shared/text/assistant-visible-text.js\";\n\nexport { formatRelativeTimestamp, formatDurationHuman };\n\nexport function formatMs(ms?: number | null): string {\n if (!ms && ms !== 0) {\n return \"n/a\";\n }\n return new Date(ms).toLocaleString();\n}\n\nexport function formatList(values?: Array<string | null | undefined>): string {\n if (!values || values.length === 0) {\n return \"none\";\n }\n return values.filter((v): v is string => Boolean(v && v.trim())).join(\", \");\n}\n\nexport function clampText(value: string, max = 120): string {\n if (value.length <= max) {\n return value;\n }\n return `${value.slice(0, Math.max(0, max - 1))}…`;\n}\n\nexport function truncateText(\n value: string,\n max: number,\n): {\n text: string;\n truncated: boolean;\n total: number;\n} {\n if (value.length <= max) {\n return { text: value, truncated: false, total: value.length };\n }\n return {\n text: value.slice(0, Math.max(0, max)),\n truncated: true,\n total: value.length,\n };\n}\n\nexport function toNumber(value: string, fallback: number): number {\n const n = Number(value);\n return Number.isFinite(n) ? n : fallback;\n}\n\nexport function parseList(input: string): string[] {\n return input\n .split(/[,\\n]/)\n .map((v) => v.trim())\n .filter((v) => v.length > 0);\n}\n\nexport function stripThinkingTags(value: string): string {\n return stripAssistantInternalScaffolding(value);\n}\n\nexport function formatCost(cost: number | null | undefined, fallback = \"$0.00\"): string {\n if (cost == null || !Number.isFinite(cost)) {\n return fallback;\n }\n if (cost === 0) {\n return \"$0.00\";\n }\n if (cost < 0.01) {\n return `$${cost.toFixed(4)}`;\n }\n if (cost < 1) {\n return `$${cost.toFixed(3)}`;\n }\n return `$${cost.toFixed(2)}`;\n}\n\nexport function formatTokens(tokens: number | null | undefined, fallback = \"0\"): string {\n if (tokens == null || !Number.isFinite(tokens)) {\n return fallback;\n }\n if (tokens < 1000) {\n return String(Math.round(tokens));\n }\n if (tokens < 1_000_000) {\n const k = tokens / 1000;\n return k < 10 ? `${k.toFixed(1)}k` : `${Math.round(k)}k`;\n }\n const m = tokens / 1_000_000;\n return m < 10 ? `${m.toFixed(1)}M` : `${Math.round(m)}M`;\n}\n\nexport function formatPercent(value: number | null | undefined, fallback = \"—\"): string {\n if (value == null || !Number.isFinite(value)) {\n return fallback;\n }\n return `${(value * 100).toFixed(1)}%`;\n}\n"],"mappings":"AAgDA,SAAgB,EACd,EACA,EACoB,CACpB,GAAI,GAAM,MAAQ,CAAC,OAAO,SAAS,EAAG,EAAI,GAAM,EAC9C,OAEF,GAAI,EAAK,IACP,MAAO,GAAG,KAAK,MAAM,EAAG,CAAC,IAE3B,IAAM,EAAM,GAAS,OAAS,IAAM,GAC9B,EAAe,KAAK,MAAM,EAAK,IAAK,CACpC,EAAQ,KAAK,MAAM,EAAe,KAAK,CACvC,EAAU,KAAK,MAAO,EAAe,KAAQ,GAAG,CAChD,EAAU,EAAe,GAC/B,GAAI,GAAS,GAAI,CACf,IAAM,EAAO,KAAK,MAAM,EAAQ,GAAG,CAC7B,EAAiB,E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IAAS,EACJ,QAEL,EAAO,IACF,IAAI,EAAK,QAAQ,EAAE,GAExB,EAAO,EACF,IAAI,EAAK,QAAQ,EAAE,GAErB,IAAI,EAAK,QAAQ,EAAE,GAG5B,SAAgB,EAAa,EAAmC,EAAW,IAAa,CACtF,GAAI,GAAU,MAAQ,CAAC,OAAO,SAAS,EAAO,CAC5C,OAAO,EAET,GAAI,EAAS,IACX,OAAO,OAAO,KAAK,MAAM,EAAO,CAAC,CAEnC,GAAI,EAAS,IAAW,CACtB,IAAM,EAAI,EAAS,IACnB,OAAO,EAAI,GAAK,GAAG,EAAE,QAAQ,EAAE,CAAC,GAAK,GAAG,KAAK,MAAM,EAAE,CAAC,GAExD,IAAM,EAAI,EAAS,IACnB,OAAO,EAAI,GAAK,GAAG,EAAE,QAAQ,EAAE,CAAC,GAAK,GAAG,KAAK,MAAM,EAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ function e(e){let t=e[e.length-1];return t&&t.role!==`user`?`agent`:`user`}function t(e){return e.some(e=>e.role===`user`&&Array.isArray(e.content)||e.role===`toolResult`&&Array.isArray(e.content)?e.content.some(e=>e.type===`image`):!1)}function n(t){let n={"X-Initiator":e(t.messages),"Openai-Intent":`conversation-edits`};return t.hasImages&&(n[`Copilot-Vision-Request`]=`true`),n}export{t as n,n as t};
2
+ //# sourceMappingURL=github-copilot-headers-CrI0CIJ7.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"github-copilot-headers-CrI0CIJ7.js","names":[],"sources":["../../../node_modules/@mariozechner/pi-ai/dist/providers/github-copilot-headers.js"],"sourcesContent":["// Copilot expects X-Initiator to indicate whether the request is user-initiated\n// or agent-initiated (e.g. follow-up after assistant/tool messages).\nexport function inferCopilotInitiator(messages) {\n const last = messages[messages.length - 1];\n return last && last.role !== \"user\" ? \"agent\" : \"user\";\n}\n// Copilot requires Copilot-Vision-Request header when sending images\nexport function hasCopilotVisionInput(messages) {\n return messages.some((msg) => {\n if (msg.role === \"user\" && Array.isArray(msg.content)) {\n return msg.content.some((c) => c.type === \"image\");\n }\n if (msg.role === \"toolResult\" && Array.isArray(msg.content)) {\n return msg.content.some((c) => c.type === \"image\");\n }\n return false;\n });\n}\nexport function buildCopilotDynamicHeaders(params) {\n const headers = {\n \"X-Initiator\": inferCopilotInitiator(params.messages),\n \"Openai-Intent\": \"conversation-edits\",\n };\n if (params.hasImages) {\n headers[\"Copilot-Vision-Request\"] = \"true\";\n }\n return headers;\n}\n//# sourceMappingURL=github-copilot-headers.js.map"],"x_google_ignoreList":[0],"mappings":"AAEA,SAAgB,EAAsB,EAAU,CAC5C,IAAM,EAAO,EAAS,EAAS,OAAS,GACxC,OAAO,GAAQ,EAAK,OAAS,OAAS,QAAU,OAGpD,SAAgB,EAAsB,EAAU,CAC5C,OAAO,EAAS,KAAM,GACd,EAAI,OAAS,QAAU,MAAM,QAAQ,EAAI,QAAQ,EAGjD,EAAI,OAAS,cAAgB,MAAM,QAAQ,EAAI,QAAQ,CAChD,EAAI,QAAQ,KAAM,GAAM,EAAE,OAAS,QAAQ,CAE/C,GACT,CAEN,SAAgB,EAA2B,EAAQ,CAC/C,IAAM,EAAU,CACZ,cAAe,EAAsB,EAAO,SAAS,CACrD,gBAAiB,qBACpB,CAID,OAHI,EAAO,YACP,EAAQ,0BAA4B,QAEjC"}
@@ -0,0 +1,2 @@
1
+ import{n as e,t}from"./event-stream-B8X6sYaV.js";import{g as n}from"./index-XGDpaFxG.js";import{a as r,i,r as a}from"./transform-messages-XKqwKV3D.js";import{c as o,i as s,n as c,o as l,r as u,s as d,t as f}from"./google-shared-CbPHVnPr.js";var p=0,m=(r,i,a)=>{let o=new t;return(async()=>{let t={role:`assistant`,content:[],api:`google-generative-ai`,provider:r.provider,model:r.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`stop`,timestamp:Date.now()};try{let c=g(r,a?.apiKey||n(r.provider)||``,a?.headers),l=_(r,i,a),f=await a?.onPayload?.(l,r);f!==void 0&&(l=f);let m=await c.models.generateContentStream(l);o.push({type:`start`,partial:t});let h=null,v=t.content,y=()=>v.length-1;for await(let n of m){t.responseId||=n.responseId;let i=n.candidates?.[0];if(i?.content?.parts)for(let e of i.content.parts){if(e.text!==void 0){let n=u(e);(!h||n&&h.type!==`thinking`||!n&&h.type!==`text`)&&(h&&(h.type===`text`?o.push({type:`text_end`,contentIndex:v.length-1,content:h.text,partial:t}):o.push({type:`thinking_end`,contentIndex:y(),content:h.thinking,partial:t})),n?(h={type:`thinking`,thinking:``,thinkingSignature:void 0},t.content.push(h),o.push({type:`thinking_start`,contentIndex:y(),partial:t})):(h={type:`text`,text:``},t.content.push(h),o.push({type:`text_start`,contentIndex:y(),partial:t}))),h.type===`thinking`?(h.thinking+=e.text,h.thinkingSignature=d(h.thinkingSignature,e.thoughtSignature),o.push({type:`thinking_delta`,contentIndex:y(),delta:e.text,partial:t})):(h.text+=e.text,h.textSignature=d(h.textSignature,e.thoughtSignature),o.push({type:`text_delta`,contentIndex:y(),delta:e.text,partial:t}))}if(e.functionCall){h&&=(h.type===`text`?o.push({type:`text_end`,contentIndex:y(),content:h.text,partial:t}):o.push({type:`thinking_end`,contentIndex:y(),content:h.thinking,partial:t}),null);let n=e.functionCall.id,r={type:`toolCall`,id:!n||t.content.some(e=>e.type===`toolCall`&&e.id===n)?`${e.functionCall.name}_${Date.now()}_${++p}`:n,name:e.functionCall.name||``,arguments:e.functionCall.args??{},...e.thoughtSignature&&{thoughtSignature:e.thoughtSignature}};t.content.push(r),o.push({type:`toolcall_start`,contentIndex:y(),partial:t}),o.push({type:`toolcall_delta`,contentIndex:y(),delta:JSON.stringify(r.arguments),partial:t}),o.push({type:`toolcall_end`,contentIndex:y(),toolCall:r,partial:t})}}i?.finishReason&&(t.stopReason=s(i.finishReason),t.content.some(e=>e.type===`toolCall`)&&(t.stopReason=`toolUse`)),n.usageMetadata&&(t.usage={input:(n.usageMetadata.promptTokenCount||0)-(n.usageMetadata.cachedContentTokenCount||0),output:(n.usageMetadata.candidatesTokenCount||0)+(n.usageMetadata.thoughtsTokenCount||0),cacheRead:n.usageMetadata.cachedContentTokenCount||0,cacheWrite:0,totalTokens:n.usageMetadata.totalTokenCount||0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},e(r,t.usage))}if(h&&(h.type===`text`?o.push({type:`text_end`,contentIndex:y(),content:h.text,partial:t}):o.push({type:`thinking_end`,contentIndex:y(),content:h.thinking,partial:t})),a?.signal?.aborted)throw Error(`Request was aborted`);if(t.stopReason===`aborted`||t.stopReason===`error`)throw Error(`An unknown error occurred`);o.push({type:`done`,reason:t.stopReason,message:t}),o.end()}catch(e){for(let e of t.content)`index`in e&&delete e.index;t.stopReason=a?.signal?.aborted?`aborted`:`error`,t.errorMessage=e instanceof Error?e.message:JSON.stringify(e),o.push({type:`error`,reason:t.stopReason,error:t}),o.end()}})(),o},h=(e,t,r)=>{let o=r?.apiKey||n(e.provider);if(!o)throw Error(`No API key for provider: ${e.provider}`);let s=a(e,r,o);if(!r?.reasoning)return m(e,t,{...s,thinking:{enabled:!1}});let c=i(r.reasoning),l=e;return v(l)||y(l)?m(e,t,{...s,thinking:{enabled:!0,level:x(c,l)}}):m(e,t,{...s,thinking:{enabled:!0,budgetTokens:S(l,c,r.thinkingBudgets)}})};function g(e,t,n){let r={};return e.baseUrl&&(r.baseUrl=e.baseUrl,r.apiVersion=``),(e.headers||n)&&(r.headers={...e.headers,...n}),new o({apiKey:t,httpOptions:Object.keys(r).length>0?r:void 0})}function _(e,t,n={}){let i=f(e,t),a={};n.temperature!==void 0&&(a.temperature=n.temperature),n.maxTokens!==void 0&&(a.maxOutputTokens=n.maxTokens);let o={...Object.keys(a).length>0&&a,...t.systemPrompt&&{systemInstruction:r(t.systemPrompt)},...t.tools&&t.tools.length>0&&{tools:c(t.tools)}};if(t.tools&&t.tools.length>0&&n.toolChoice?o.toolConfig={functionCallingConfig:{mode:l(n.toolChoice)}}:o.toolConfig=void 0,n.thinking?.enabled&&e.reasoning){let e={includeThoughts:!0};n.thinking.level===void 0?n.thinking.budgetTokens!==void 0&&(e.thinkingBudget=n.thinking.budgetTokens):e.thinkingLevel=n.thinking.level,o.thinkingConfig=e}else e.reasoning&&n.thinking&&!n.thinking.enabled&&(o.thinkingConfig=b(e));if(n.signal){if(n.signal.aborted)throw Error(`Request aborted`);o.abortSignal=n.signal}return{model:e.id,contents:i,config:o}}function v(e){return/gemini-3(?:\.\d+)?-pro/.test(e.id.toLowerCase())}function y(e){return/gemini-3(?:\.\d+)?-flash/.test(e.id.toLowerCase())}function b(e){return v(e)?{thinkingLevel:`LOW`}:y(e)?{thinkingLevel:`MINIMAL`}:{thinkingBudget:0}}function x(e,t){if(v(t))switch(e){case`minimal`:case`low`:return`LOW`;case`medium`:case`high`:return`HIGH`}switch(e){case`minimal`:return`MINIMAL`;case`low`:return`LOW`;case`medium`:return`MEDIUM`;case`high`:return`HIGH`}}function S(e,t,n){return n?.[t]===void 0?e.id.includes(`2.5-pro`)?{minimal:128,low:2048,medium:8192,high:32768}[t]:e.id.includes(`2.5-flash`)?{minimal:128,low:2048,medium:8192,high:24576}[t]:-1:n[t]}export{m as streamGoogle,h as streamSimpleGoogle};
2
+ //# sourceMappingURL=google-BT0bmsh5.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"google-BT0bmsh5.js","names":[],"sources":["../../../node_modules/@mariozechner/pi-ai/dist/providers/google.js"],"sourcesContent":["import { GoogleGenAI, } from \"@google/genai\";\nimport { getEnvApiKey } from \"../env-api-keys.js\";\nimport { calculateCost } from \"../models.js\";\nimport { AssistantMessageEventStream } from \"../utils/event-stream.js\";\nimport { sanitizeSurrogates } from \"../utils/sanitize-unicode.js\";\nimport { convertMessages, convertTools, isThinkingPart, mapStopReason, mapToolChoice, retainThoughtSignature, } from \"./google-shared.js\";\nimport { buildBaseOptions, clampReasoning } from \"./simple-options.js\";\n// Counter for generating unique tool call IDs\nlet toolCallCounter = 0;\nexport const streamGoogle = (model, context, options) => {\n const stream = new AssistantMessageEventStream();\n (async () => {\n const output = {\n role: \"assistant\",\n content: [],\n api: \"google-generative-ai\",\n provider: model.provider,\n model: model.id,\n usage: {\n input: 0,\n output: 0,\n cacheRead: 0,\n cacheWrite: 0,\n totalTokens: 0,\n cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },\n },\n stopReason: \"stop\",\n timestamp: Date.now(),\n };\n try {\n const apiKey = options?.apiKey || getEnvApiKey(model.provider) || \"\";\n const client = createClient(model, apiKey, options?.headers);\n let params = buildParams(model, context, options);\n const nextParams = await options?.onPayload?.(params, model);\n if (nextParams !== undefined) {\n params = nextParams;\n }\n const googleStream = await client.models.generateContentStream(params);\n stream.push({ type: \"start\", partial: output });\n let currentBlock = null;\n const blocks = output.content;\n const blockIndex = () => blocks.length - 1;\n for await (const chunk of googleStream) {\n // @google/genai documents GenerateContentResponse.responseId as an output-only field\n // used to identify each response. Keep the first non-empty one from the stream.\n output.responseId ||= chunk.responseId;\n const candidate = chunk.candidates?.[0];\n if (candidate?.content?.parts) {\n for (const part of candidate.content.parts) {\n if (part.text !== undefined) {\n const isThinking = isThinkingPart(part);\n if (!currentBlock ||\n (isThinking && currentBlock.type !== \"thinking\") ||\n (!isThinking && currentBlock.type !== \"text\")) {\n if (currentBlock) {\n if (currentBlock.type === \"text\") {\n stream.push({\n type: \"text_end\",\n contentIndex: blocks.length - 1,\n content: currentBlock.text,\n partial: output,\n });\n }\n else {\n stream.push({\n type: \"thinking_end\",\n contentIndex: blockIndex(),\n content: currentBlock.thinking,\n partial: output,\n });\n }\n }\n if (isThinking) {\n currentBlock = { type: \"thinking\", thinking: \"\", thinkingSignature: undefined };\n output.content.push(currentBlock);\n stream.push({ type: \"thinking_start\", contentIndex: blockIndex(), partial: output });\n }\n else {\n currentBlock = { type: \"text\", text: \"\" };\n output.content.push(currentBlock);\n stream.push({ type: \"text_start\", contentIndex: blockIndex(), partial: output });\n }\n }\n if (currentBlock.type === \"thinking\") {\n currentBlock.thinking += part.text;\n currentBlock.thinkingSignature = retainThoughtSignature(currentBlock.thinkingSignature, part.thoughtSignature);\n stream.push({\n type: \"thinking_delta\",\n contentIndex: blockIndex(),\n delta: part.text,\n partial: output,\n });\n }\n else {\n currentBlock.text += part.text;\n currentBlock.textSignature = retainThoughtSignature(currentBlock.textSignature, part.thoughtSignature);\n stream.push({\n type: \"text_delta\",\n contentIndex: blockIndex(),\n delta: part.text,\n partial: output,\n });\n }\n }\n if (part.functionCall) {\n if (currentBlock) {\n if (currentBlock.type === \"text\") {\n stream.push({\n type: \"text_end\",\n contentIndex: blockIndex(),\n content: currentBlock.text,\n partial: output,\n });\n }\n else {\n stream.push({\n type: \"thinking_end\",\n contentIndex: blockIndex(),\n content: currentBlock.thinking,\n partial: output,\n });\n }\n currentBlock = null;\n }\n // Generate unique ID if not provided or if it's a duplicate\n const providedId = part.functionCall.id;\n const needsNewId = !providedId || output.content.some((b) => b.type === \"toolCall\" && b.id === providedId);\n const toolCallId = needsNewId\n ? `${part.functionCall.name}_${Date.now()}_${++toolCallCounter}`\n : providedId;\n const toolCall = {\n type: \"toolCall\",\n id: toolCallId,\n name: part.functionCall.name || \"\",\n arguments: part.functionCall.args ?? {},\n ...(part.thoughtSignature && { thoughtSignature: part.thoughtSignature }),\n };\n output.content.push(toolCall);\n stream.push({ type: \"toolcall_start\", contentIndex: blockIndex(), partial: output });\n stream.push({\n type: \"toolcall_delta\",\n contentIndex: blockIndex(),\n delta: JSON.stringify(toolCall.arguments),\n partial: output,\n });\n stream.push({ type: \"toolcall_end\", contentIndex: blockIndex(), toolCall, partial: output });\n }\n }\n }\n if (candidate?.finishReason) {\n output.stopReason = mapStopReason(candidate.finishReason);\n if (output.content.some((b) => b.type === \"toolCall\")) {\n output.stopReason = \"toolUse\";\n }\n }\n if (chunk.usageMetadata) {\n output.usage = {\n input: (chunk.usageMetadata.promptTokenCount || 0) - (chunk.usageMetadata.cachedContentTokenCount || 0),\n output: (chunk.usageMetadata.candidatesTokenCount || 0) + (chunk.usageMetadata.thoughtsTokenCount || 0),\n cacheRead: chunk.usageMetadata.cachedContentTokenCount || 0,\n cacheWrite: 0,\n totalTokens: chunk.usageMetadata.totalTokenCount || 0,\n cost: {\n input: 0,\n output: 0,\n cacheRead: 0,\n cacheWrite: 0,\n total: 0,\n },\n };\n calculateCost(model, output.usage);\n }\n }\n if (currentBlock) {\n if (currentBlock.type === \"text\") {\n stream.push({\n type: \"text_end\",\n contentIndex: blockIndex(),\n content: currentBlock.text,\n partial: output,\n });\n }\n else {\n stream.push({\n type: \"thinking_end\",\n contentIndex: blockIndex(),\n content: currentBlock.thinking,\n partial: output,\n });\n }\n }\n if (options?.signal?.aborted) {\n throw new Error(\"Request was aborted\");\n }\n if (output.stopReason === \"aborted\" || output.stopReason === \"error\") {\n throw new Error(\"An unknown error occurred\");\n }\n stream.push({ type: \"done\", reason: output.stopReason, message: output });\n stream.end();\n }\n catch (error) {\n // Remove internal index property used during streaming\n for (const block of output.content) {\n if (\"index\" in block) {\n delete block.index;\n }\n }\n output.stopReason = options?.signal?.aborted ? \"aborted\" : \"error\";\n output.errorMessage = error instanceof Error ? error.message : JSON.stringify(error);\n stream.push({ type: \"error\", reason: output.stopReason, error: output });\n stream.end();\n }\n })();\n return stream;\n};\nexport const streamSimpleGoogle = (model, context, options) => {\n const apiKey = options?.apiKey || getEnvApiKey(model.provider);\n if (!apiKey) {\n throw new Error(`No API key for provider: ${model.provider}`);\n }\n const base = buildBaseOptions(model, options, apiKey);\n if (!options?.reasoning) {\n return streamGoogle(model, context, { ...base, thinking: { enabled: false } });\n }\n const effort = clampReasoning(options.reasoning);\n const googleModel = model;\n if (isGemini3ProModel(googleModel) || isGemini3FlashModel(googleModel)) {\n return streamGoogle(model, context, {\n ...base,\n thinking: {\n enabled: true,\n level: getGemini3ThinkingLevel(effort, googleModel),\n },\n });\n }\n return streamGoogle(model, context, {\n ...base,\n thinking: {\n enabled: true,\n budgetTokens: getGoogleBudget(googleModel, effort, options.thinkingBudgets),\n },\n });\n};\nfunction createClient(model, apiKey, optionsHeaders) {\n const httpOptions = {};\n if (model.baseUrl) {\n httpOptions.baseUrl = model.baseUrl;\n httpOptions.apiVersion = \"\"; // baseUrl already includes version path, don't append\n }\n if (model.headers || optionsHeaders) {\n httpOptions.headers = { ...model.headers, ...optionsHeaders };\n }\n return new GoogleGenAI({\n apiKey,\n httpOptions: Object.keys(httpOptions).length > 0 ? httpOptions : undefined,\n });\n}\nfunction buildParams(model, context, options = {}) {\n const contents = convertMessages(model, context);\n const generationConfig = {};\n if (options.temperature !== undefined) {\n generationConfig.temperature = options.temperature;\n }\n if (options.maxTokens !== undefined) {\n generationConfig.maxOutputTokens = options.maxTokens;\n }\n const config = {\n ...(Object.keys(generationConfig).length > 0 && generationConfig),\n ...(context.systemPrompt && { systemInstruction: sanitizeSurrogates(context.systemPrompt) }),\n ...(context.tools && context.tools.length > 0 && { tools: convertTools(context.tools) }),\n };\n if (context.tools && context.tools.length > 0 && options.toolChoice) {\n config.toolConfig = {\n functionCallingConfig: {\n mode: mapToolChoice(options.toolChoice),\n },\n };\n }\n else {\n config.toolConfig = undefined;\n }\n if (options.thinking?.enabled && model.reasoning) {\n const thinkingConfig = { includeThoughts: true };\n if (options.thinking.level !== undefined) {\n // Cast to any since our GoogleThinkingLevel mirrors Google's ThinkingLevel enum values\n thinkingConfig.thinkingLevel = options.thinking.level;\n }\n else if (options.thinking.budgetTokens !== undefined) {\n thinkingConfig.thinkingBudget = options.thinking.budgetTokens;\n }\n config.thinkingConfig = thinkingConfig;\n }\n else if (model.reasoning && options.thinking && !options.thinking.enabled) {\n config.thinkingConfig = getDisabledThinkingConfig(model);\n }\n if (options.signal) {\n if (options.signal.aborted) {\n throw new Error(\"Request aborted\");\n }\n config.abortSignal = options.signal;\n }\n const params = {\n model: model.id,\n contents,\n config,\n };\n return params;\n}\nfunction isGemini3ProModel(model) {\n return /gemini-3(?:\\.\\d+)?-pro/.test(model.id.toLowerCase());\n}\nfunction isGemini3FlashModel(model) {\n return /gemini-3(?:\\.\\d+)?-flash/.test(model.id.toLowerCase());\n}\nfunction getDisabledThinkingConfig(model) {\n // Google docs: Gemini 3.1 Pro cannot disable thinking, and Gemini 3 Flash / Flash-Lite\n // do not support full thinking-off either. For Gemini 3 models, use the lowest supported\n // thinkingLevel without includeThoughts so hidden thinking remains invisible to pi.\n if (isGemini3ProModel(model)) {\n return { thinkingLevel: \"LOW\" };\n }\n if (isGemini3FlashModel(model)) {\n return { thinkingLevel: \"MINIMAL\" };\n }\n // Gemini 2.x supports disabling via thinkingBudget = 0.\n return { thinkingBudget: 0 };\n}\nfunction getGemini3ThinkingLevel(effort, model) {\n if (isGemini3ProModel(model)) {\n switch (effort) {\n case \"minimal\":\n case \"low\":\n return \"LOW\";\n case \"medium\":\n case \"high\":\n return \"HIGH\";\n }\n }\n switch (effort) {\n case \"minimal\":\n return \"MINIMAL\";\n case \"low\":\n return \"LOW\";\n case \"medium\":\n return \"MEDIUM\";\n case \"high\":\n return \"HIGH\";\n }\n}\nfunction getGoogleBudget(model, effort, customBudgets) {\n if (customBudgets?.[effort] !== undefined) {\n return customBudgets[effort];\n }\n if (model.id.includes(\"2.5-pro\")) {\n const budgets = {\n minimal: 128,\n low: 2048,\n medium: 8192,\n high: 32768,\n };\n return budgets[effort];\n }\n if (model.id.includes(\"2.5-flash\")) {\n const budgets = {\n minimal: 128,\n low: 2048,\n medium: 8192,\n high: 24576,\n };\n return budgets[effort];\n }\n return -1;\n}\n//# sourceMappingURL=google.js.map"],"x_google_ignoreList":[0],"mappings":"iPAQA,IAAI,EAAkB,EACT,GAAgB,EAAO,EAAS,IAAY,CACrD,IAAM,EAAS,IAAI,EA2MnB,OA1MC,SAAY,CACT,IAAM,EAAS,CACX,KAAM,YACN,QAAS,EAAE,CACX,IAAK,uBACL,SAAU,EAAM,SAChB,MAAO,EAAM,GACb,MAAO,CACH,MAAO,EACP,OAAQ,EACR,UAAW,E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OAGnB,OAAQ,EAAR,CACI,IAAK,UACD,MAAO,UACX,IAAK,MACD,MAAO,MACX,IAAK,SACD,MAAO,SACX,IAAK,OACD,MAAO,QAGnB,SAAS,EAAgB,EAAO,EAAQ,EAAe,CAsBnD,OArBI,IAAgB,KAAY,IAAA,GAG5B,EAAM,GAAG,SAAS,UAAU,CACZ,CACZ,QAAS,IACT,IAAK,KACL,OAAQ,KACR,KAAM,MACT,CACc,GAEf,EAAM,GAAG,SAAS,YAAY,CACd,CACZ,QAAS,IACT,IAAK,KACL,OAAQ,KACR,KAAM,MACT,CACc,GAEZ,GApBI,EAAc"}
@@ -0,0 +1,3 @@
1
+ import{n as e,t}from"./event-stream-B8X6sYaV.js";import{a as n,i as r,r as i}from"./transform-messages-XKqwKV3D.js";import{a,n as o,o as s,r as c,s as l,t as u}from"./google-shared-CbPHVnPr.js";var d=`https://cloudcode-pa.googleapis.com`,f=[`https://daily-cloudcode-pa.sandbox.googleapis.com`,`https://autopush-cloudcode-pa.sandbox.googleapis.com`,d],p={"User-Agent":`google-cloud-sdk vscode_cloudshelleditor/0.1`,"X-Goog-Api-Client":`gl-node/22.17.0`,"Client-Metadata":JSON.stringify({ideType:`IDE_UNSPECIFIED`,platform:`PLATFORM_UNSPECIFIED`,pluginType:`GEMINI`})},m=`1.18.4`;function h(){let e={}.PI_AI_ANTIGRAVITY_VERSION||m;return{"User-Agent":`antigravity/${e} darwin/arm64`}}var g=`You are Antigravity, a powerful agentic AI coding assistant designed by the Google Deepmind team working on Advanced Agentic Coding.You are pair programming with a USER to solve their coding task. The task may require creating a new codebase, modifying or debugging an existing codebase, or simply answering a question.**Absolute paths only****Proactiveness**`,_=0,v=3,y=1e3,b=2,x=500,S=`interleaved-thinking-2025-05-14`;function C(e,t){let n=e=>e>0?Math.ceil(e+1e3):void 0,r=t instanceof Headers?t:t?.headers;if(r){let e=r.get(`retry-after`);if(e){let t=Number(e);if(Number.isFinite(t)){let e=n(t*1e3);if(e!==void 0)return e}let r=new Date(e).getTime();if(!Number.isNaN(r)){let e=n(r-Date.now());if(e!==void 0)return e}}let t=r.get(`x-ratelimit-reset`);if(t){let e=Number.parseInt(t,10);if(!Number.isNaN(e)){let t=n(e*1e3-Date.now());if(t!==void 0)return t}}let i=r.get(`x-ratelimit-reset-after`);if(i){let e=Number(i);if(Number.isFinite(e)){let t=n(e*1e3);if(t!==void 0)return t}}}let i=e.match(/reset after (?:(\d+)h)?(?:(\d+)m)?(\d+(?:\.\d+)?)s/i);if(i){let e=i[1]?parseInt(i[1],10):0,t=i[2]?parseInt(i[2],10):0,r=parseFloat(i[3]);if(!Number.isNaN(r)){let i=n(((e*60+t)*60+r)*1e3);if(i!==void 0)return i}}let a=e.match(/Please retry in ([0-9.]+)(ms|s)/i);if(a?.[1]){let e=parseFloat(a[1]);if(!Number.isNaN(e)&&e>0){let t=n(a[2].toLowerCase()===`ms`?e:e*1e3);if(t!==void 0)return t}}let o=e.match(/"retryDelay":\s*"([0-9.]+)(ms|s)"/i);if(o?.[1]){let e=parseFloat(o[1]);if(!Number.isNaN(e)&&e>0){let t=n(o[2].toLowerCase()===`ms`?e:e*1e3);if(t!==void 0)return t}}}function w(e){return e.provider===`google-antigravity`&&e.id.startsWith(`claude-`)&&e.reasoning}function T(e){return/gemini-3(?:\.1)?-pro/.test(e.toLowerCase())}function E(e){return/gemini-3(?:\.1)?-flash/.test(e.toLowerCase())}function D(e){return T(e)||E(e)}function O(e,t){return e===429||e===500||e===502||e===503||e===504?!0:/resource.?exhausted|rate.?limit|overloaded|service.?unavailable|other.?side.?closed/i.test(t)}function k(e){try{let t=JSON.parse(e);if(t.error?.message)return t.error.message}catch{}return e}function A(e,t){return new Promise((n,r)=>{if(t?.aborted){r(Error(`Request was aborted`));return}let i=setTimeout(n,e);t?.addEventListener(`abort`,()=>{clearTimeout(i),r(Error(`Request was aborted`))})})}var j=(n,r,i)=>{let o=new t;return(async()=>{let t={role:`assistant`,content:[],api:`google-gemini-cli`,provider:n.provider,model:n.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`stop`,timestamp:Date.now()};try{let s=i?.apiKey;if(!s)throw Error(`Google Cloud Code Assist requires OAuth authentication. Use /login to authenticate.`);let u,m;try{let e=JSON.parse(s);u=e.token,m=e.projectId}catch{throw Error(`Invalid Google Cloud Code Assist credentials. Use /login to re-authenticate.`)}if(!u||!m)throw Error(`Missing token or projectId in Google Cloud credentials. Use /login to re-authenticate.`);let g=n.provider===`google-antigravity`,T=n.baseUrl?.trim(),E=T?[T]:g?f:[d],D=N(n,r,m,i,g),j=await i?.onPayload?.(D,n);j!==void 0&&(D=j);let M=g?h():p,P={Authorization:`Bearer ${u}`,"Content-Type":`application/json`,Accept:`text/event-stream`,...M,...w(n)?{"anthropic-beta":S}:{},...i?.headers},F=JSON.stringify(D),I,L,R,z=0;for(let e=0;e<=v;e++){if(i?.signal?.aborted)throw Error(`Request was aborted`);try{if(R=`${E[z]}/v1internal:streamGenerateContent?alt=sse`,I=await fetch(R,{method:`POST`,headers:P,body:F,signal:i?.signal}),I.ok)break;let t=await I.text();if((I.status===403||I.status===404)&&z<E.length-1){z++;continue}if(e<v&&O(I.status,t)){z<E.length-1&&z++;let n=C(t,I),r=n??y*2**e,a=i?.maxRetryDelayMs??6e4;if(a>0&&n&&n>a){let e=Math.ceil(n/1e3);throw Error(`Server requested ${e}s retry delay (max: ${Math.ceil(a/1e3)}s). ${k(t)}`)}await A(r,i?.signal);continue}throw Error(`Cloud Code Assist API error (${I.status}): ${k(t)}`)}catch(t){if(t instanceof Error&&(t.name===`AbortError`||t.message===`Request was aborted`))throw Error(`Request was aborted`);if(L=t instanceof Error?t:Error(String(t)),L.message===`fetch failed`&&L.cause instanceof Error&&(L=Error(`Network error: ${L.cause.message}`)),e<v){await A(y*2**e,i?.signal);continue}throw L}}if(!I||!I.ok)throw L??Error(`Failed to get response after retries`);let B=!1,V=()=>{B||=(o.push({type:`start`,partial:t}),!0)},H=()=>{t.content=[],t.usage={input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},t.stopReason=`stop`,t.errorMessage=void 0,t.timestamp=Date.now(),B=!1},U=async r=>{if(!r.body)throw Error(`No response body`);let s=!1,u=null,d=t.content,f=()=>d.length-1,p=r.body.getReader(),m=new TextDecoder,h=``,g=()=>{p.cancel().catch(()=>{})};i?.signal?.addEventListener(`abort`,g);try{for(;;){if(i?.signal?.aborted)throw Error(`Request was aborted`);let{done:r,value:g}=await p.read();if(r)break;h+=m.decode(g,{stream:!0});let v=h.split(`
2
+ `);h=v.pop()||``;for(let r of v){if(!r.startsWith(`data:`))continue;let i=r.slice(5).trim();if(!i)continue;let p;try{p=JSON.parse(i)}catch{continue}let m=p.response;if(!m)continue;t.responseId||=m.responseId;let h=m.candidates?.[0];if(h?.content?.parts)for(let e of h.content.parts){if(e.text!==void 0){s=!0;let n=c(e);(!u||n&&u.type!==`thinking`||!n&&u.type!==`text`)&&(u&&(u.type===`text`?o.push({type:`text_end`,contentIndex:d.length-1,content:u.text,partial:t}):o.push({type:`thinking_end`,contentIndex:f(),content:u.thinking,partial:t})),n?(u={type:`thinking`,thinking:``,thinkingSignature:void 0},t.content.push(u),V(),o.push({type:`thinking_start`,contentIndex:f(),partial:t})):(u={type:`text`,text:``},t.content.push(u),V(),o.push({type:`text_start`,contentIndex:f(),partial:t}))),u.type===`thinking`?(u.thinking+=e.text,u.thinkingSignature=l(u.thinkingSignature,e.thoughtSignature),o.push({type:`thinking_delta`,contentIndex:f(),delta:e.text,partial:t})):(u.text+=e.text,u.textSignature=l(u.textSignature,e.thoughtSignature),o.push({type:`text_delta`,contentIndex:f(),delta:e.text,partial:t}))}if(e.functionCall){s=!0,u&&=(u.type===`text`?o.push({type:`text_end`,contentIndex:f(),content:u.text,partial:t}):o.push({type:`thinking_end`,contentIndex:f(),content:u.thinking,partial:t}),null);let n=e.functionCall.id,r={type:`toolCall`,id:!n||t.content.some(e=>e.type===`toolCall`&&e.id===n)?`${e.functionCall.name}_${Date.now()}_${++_}`:n,name:e.functionCall.name||``,arguments:e.functionCall.args??{},...e.thoughtSignature&&{thoughtSignature:e.thoughtSignature}};t.content.push(r),V(),o.push({type:`toolcall_start`,contentIndex:f(),partial:t}),o.push({type:`toolcall_delta`,contentIndex:f(),delta:JSON.stringify(r.arguments),partial:t}),o.push({type:`toolcall_end`,contentIndex:f(),toolCall:r,partial:t})}}if(h?.finishReason&&(t.stopReason=a(h.finishReason),t.content.some(e=>e.type===`toolCall`)&&(t.stopReason=`toolUse`)),m.usageMetadata){let r=m.usageMetadata.promptTokenCount||0,i=m.usageMetadata.cachedContentTokenCount||0;t.usage={input:r-i,output:(m.usageMetadata.candidatesTokenCount||0)+(m.usageMetadata.thoughtsTokenCount||0),cacheRead:i,cacheWrite:0,totalTokens:m.usageMetadata.totalTokenCount||0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},e(n,t.usage)}}}}finally{i?.signal?.removeEventListener(`abort`,g)}return u&&(u.type===`text`?o.push({type:`text_end`,contentIndex:f(),content:u.text,partial:t}):o.push({type:`thinking_end`,contentIndex:f(),content:u.thinking,partial:t})),s},W=!1,G=I;for(let e=0;e<=b;e++){if(i?.signal?.aborted)throw Error(`Request was aborted`);if(e>0){if(await A(x*2**(e-1),i?.signal),!R)throw Error(`Missing request URL`);if(G=await fetch(R,{method:`POST`,headers:P,body:F,signal:i?.signal}),!G.ok){let e=await G.text();throw Error(`Cloud Code Assist API error (${G.status}): ${e}`)}}if(await U(G)){W=!0;break}e<b&&H()}if(!W)throw Error(`Cloud Code Assist API returned an empty response`);if(i?.signal?.aborted)throw Error(`Request was aborted`);if(t.stopReason===`aborted`||t.stopReason===`error`)throw Error(`An unknown error occurred`);o.push({type:`done`,reason:t.stopReason,message:t}),o.end()}catch(e){for(let e of t.content)`index`in e&&delete e.index;t.stopReason=i?.signal?.aborted?`aborted`:`error`,t.errorMessage=e instanceof Error?e.message:JSON.stringify(e),o.push({type:`error`,reason:t.stopReason,error:t}),o.end()}})(),o},M=(e,t,n)=>{let a=n?.apiKey;if(!a)throw Error(`Google Cloud Code Assist requires OAuth authentication. Use /login to authenticate.`);let o=i(e,n,a);if(!n?.reasoning)return j(e,t,{...o,thinking:{enabled:!1}});let s=r(n.reasoning);if(D(e.id))return j(e,t,{...o,thinking:{enabled:!0,level:F(s,e.id)}});let c={minimal:1024,low:2048,medium:8192,high:16384,...n.thinkingBudgets}[s],l=Math.min((o.maxTokens||0)+c,e.maxTokens);return l<=c&&(c=Math.max(0,l-1024)),j(e,t,{...o,maxTokens:l,thinking:{enabled:!0,budgetTokens:c}})};function N(e,t,r,i={},a=!1){let c=u(e,t),l={};i.temperature!==void 0&&(l.temperature=i.temperature),i.maxTokens!==void 0&&(l.maxOutputTokens=i.maxTokens),i.thinking?.enabled&&e.reasoning?(l.thinkingConfig={includeThoughts:!0},i.thinking.level===void 0?i.thinking.budgetTokens!==void 0&&(l.thinkingConfig.thinkingBudget=i.thinking.budgetTokens):l.thinkingConfig.thinkingLevel=i.thinking.level):e.reasoning&&i.thinking&&!i.thinking.enabled&&(l.thinkingConfig=P(e.id));let d={contents:c};if(d.sessionId=i.sessionId,t.systemPrompt&&(d.systemInstruction={parts:[{text:n(t.systemPrompt)}]}),Object.keys(l).length>0&&(d.generationConfig=l),t.tools&&t.tools.length>0){let n=e.id.startsWith(`claude-`);d.tools=o(t.tools,n),i.toolChoice&&(d.toolConfig={functionCallingConfig:{mode:s(i.toolChoice)}})}if(a){let e=d.systemInstruction?.parts??[];d.systemInstruction={role:`user`,parts:[{text:g},{text:`Please ignore following [ignore]${g}[/ignore]`},...e]}}return{project:r,model:e.id,request:d,...a?{requestType:`agent`}:{},userAgent:a?`antigravity`:`pi-coding-agent`,requestId:`${a?`agent`:`pi`}-${Date.now()}-${Math.random().toString(36).slice(2,11)}`}}function P(e){return T(e)?{thinkingLevel:`LOW`}:E(e)?{thinkingLevel:`MINIMAL`}:{thinkingBudget:0}}function F(e,t){if(T(t))switch(e){case`minimal`:case`low`:return`LOW`;case`medium`:case`high`:return`HIGH`}switch(e){case`minimal`:return`MINIMAL`;case`low`:return`LOW`;case`medium`:return`MEDIUM`;case`high`:return`HIGH`}}export{N as buildRequest,C as extractRetryDelay,j as streamGoogleGeminiCli,M as streamSimpleGoogleGeminiCli};
3
+ //# sourceMappingURL=google-gemini-cli-BpxbH95Q.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"google-gemini-cli-BpxbH95Q.js","names":[],"sources":["../../../node_modules/@mariozechner/pi-ai/dist/providers/google-gemini-cli.js"],"sourcesContent":["/**\n * Google Gemini CLI / Antigravity provider.\n * Shared implementation for both google-gemini-cli and google-antigravity providers.\n * Uses the Cloud Code Assist API endpoint to access Gemini and Claude models.\n */\nimport { calculateCost } from \"../models.js\";\nimport { AssistantMessageEventStream } from \"../utils/event-stream.js\";\nimport { sanitizeSurrogates } from \"../utils/sanitize-unicode.js\";\nimport { convertMessages, convertTools, isThinkingPart, mapStopReasonString, mapToolChoice, retainThoughtSignature, } from \"./google-shared.js\";\nimport { buildBaseOptions, clampReasoning } from \"./simple-options.js\";\nconst DEFAULT_ENDPOINT = \"https://cloudcode-pa.googleapis.com\";\nconst ANTIGRAVITY_DAILY_ENDPOINT = \"https://daily-cloudcode-pa.sandbox.googleapis.com\";\nconst ANTIGRAVITY_AUTOPUSH_ENDPOINT = \"https://autopush-cloudcode-pa.sandbox.googleapis.com\";\nconst ANTIGRAVITY_ENDPOINT_FALLBACKS = [\n ANTIGRAVITY_DAILY_ENDPOINT,\n ANTIGRAVITY_AUTOPUSH_ENDPOINT,\n DEFAULT_ENDPOINT,\n];\n// Headers for Gemini CLI (prod endpoint)\nconst GEMINI_CLI_HEADERS = {\n \"User-Agent\": \"google-cloud-sdk vscode_cloudshelleditor/0.1\",\n \"X-Goog-Api-Client\": \"gl-node/22.17.0\",\n \"Client-Metadata\": JSON.stringify({\n ideType: \"IDE_UNSPECIFIED\",\n platform: \"PLATFORM_UNSPECIFIED\",\n pluginType: \"GEMINI\",\n }),\n};\n// Headers for Antigravity (sandbox endpoint) - requires specific User-Agent\nconst DEFAULT_ANTIGRAVITY_VERSION = \"1.18.4\";\nfunction getAntigravityHeaders() {\n const version = process.env.PI_AI_ANTIGRAVITY_VERSION || DEFAULT_ANTIGRAVITY_VERSION;\n return {\n \"User-Agent\": `antigravity/${version} darwin/arm64`,\n };\n}\n// Antigravity system instruction (compact version from CLIProxyAPI).\nconst ANTIGRAVITY_SYSTEM_INSTRUCTION = \"You are Antigravity, a powerful agentic AI coding assistant designed by the Google Deepmind team working on Advanced Agentic Coding.\" +\n \"You are pair programming with a USER to solve their coding task. The task may require creating a new codebase, modifying or debugging an existing codebase, or simply answering a question.\" +\n \"**Absolute paths only**\" +\n \"**Proactiveness**\";\n// Counter for generating unique tool call IDs\nlet toolCallCounter = 0;\n// Retry configuration\nconst MAX_RETRIES = 3;\nconst BASE_DELAY_MS = 1000;\nconst MAX_EMPTY_STREAM_RETRIES = 2;\nconst EMPTY_STREAM_BASE_DELAY_MS = 500;\nconst CLAUDE_THINKING_BETA_HEADER = \"interleaved-thinking-2025-05-14\";\n/**\n * Extract retry delay from Gemini error response (in milliseconds).\n * Checks headers first (Retry-After, x-ratelimit-reset, x-ratelimit-reset-after),\n * then parses body patterns like:\n * - \"Your quota will reset after 39s\"\n * - \"Your quota will reset after 18h31m10s\"\n * - \"Please retry in Xs\" or \"Please retry in Xms\"\n * - \"retryDelay\": \"34.074824224s\" (JSON field)\n */\nexport function extractRetryDelay(errorText, response) {\n const normalizeDelay = (ms) => (ms > 0 ? Math.ceil(ms + 1000) : undefined);\n const headers = response instanceof Headers ? response : response?.headers;\n if (headers) {\n const retryAfter = headers.get(\"retry-after\");\n if (retryAfter) {\n const retryAfterSeconds = Number(retryAfter);\n if (Number.isFinite(retryAfterSeconds)) {\n const delay = normalizeDelay(retryAfterSeconds * 1000);\n if (delay !== undefined) {\n return delay;\n }\n }\n const retryAfterDate = new Date(retryAfter);\n const retryAfterMs = retryAfterDate.getTime();\n if (!Number.isNaN(retryAfterMs)) {\n const delay = normalizeDelay(retryAfterMs - Date.now());\n if (delay !== undefined) {\n return delay;\n }\n }\n }\n const rateLimitReset = headers.get(\"x-ratelimit-reset\");\n if (rateLimitReset) {\n const resetSeconds = Number.parseInt(rateLimitReset, 10);\n if (!Number.isNaN(resetSeconds)) {\n const delay = normalizeDelay(resetSeconds * 1000 - Date.now());\n if (delay !== undefined) {\n return delay;\n }\n }\n }\n const rateLimitResetAfter = headers.get(\"x-ratelimit-reset-after\");\n if (rateLimitResetAfter) {\n const resetAfterSeconds = Number(rateLimitResetAfter);\n if (Number.isFinite(resetAfterSeconds)) {\n const delay = normalizeDelay(resetAfterSeconds * 1000);\n if (delay !== undefined) {\n return delay;\n }\n }\n }\n }\n // Pattern 1: \"Your quota will reset after ...\" (formats: \"18h31m10s\", \"10m15s\", \"6s\", \"39s\")\n const durationMatch = errorText.match(/reset after (?:(\\d+)h)?(?:(\\d+)m)?(\\d+(?:\\.\\d+)?)s/i);\n if (durationMatch) {\n const hours = durationMatch[1] ? parseInt(durationMatch[1], 10) : 0;\n const minutes = durationMatch[2] ? parseInt(durationMatch[2], 10) : 0;\n const seconds = parseFloat(durationMatch[3]);\n if (!Number.isNaN(seconds)) {\n const totalMs = ((hours * 60 + minutes) * 60 + seconds) * 1000;\n const delay = normalizeDelay(totalMs);\n if (delay !== undefined) {\n return delay;\n }\n }\n }\n // Pattern 2: \"Please retry in X[ms|s]\"\n const retryInMatch = errorText.match(/Please retry in ([0-9.]+)(ms|s)/i);\n if (retryInMatch?.[1]) {\n const value = parseFloat(retryInMatch[1]);\n if (!Number.isNaN(value) && value > 0) {\n const ms = retryInMatch[2].toLowerCase() === \"ms\" ? value : value * 1000;\n const delay = normalizeDelay(ms);\n if (delay !== undefined) {\n return delay;\n }\n }\n }\n // Pattern 3: \"retryDelay\": \"34.074824224s\" (JSON field in error details)\n const retryDelayMatch = errorText.match(/\"retryDelay\":\\s*\"([0-9.]+)(ms|s)\"/i);\n if (retryDelayMatch?.[1]) {\n const value = parseFloat(retryDelayMatch[1]);\n if (!Number.isNaN(value) && value > 0) {\n const ms = retryDelayMatch[2].toLowerCase() === \"ms\" ? value : value * 1000;\n const delay = normalizeDelay(ms);\n if (delay !== undefined) {\n return delay;\n }\n }\n }\n return undefined;\n}\nfunction needsClaudeThinkingBetaHeader(model) {\n return model.provider === \"google-antigravity\" && model.id.startsWith(\"claude-\") && model.reasoning;\n}\nfunction isGemini3ProModel(modelId) {\n return /gemini-3(?:\\.1)?-pro/.test(modelId.toLowerCase());\n}\nfunction isGemini3FlashModel(modelId) {\n return /gemini-3(?:\\.1)?-flash/.test(modelId.toLowerCase());\n}\nfunction isGemini3Model(modelId) {\n return isGemini3ProModel(modelId) || isGemini3FlashModel(modelId);\n}\n/**\n * Check if an error is retryable (rate limit, server error, network error, etc.)\n */\nfunction isRetryableError(status, errorText) {\n if (status === 429 || status === 500 || status === 502 || status === 503 || status === 504) {\n return true;\n }\n return /resource.?exhausted|rate.?limit|overloaded|service.?unavailable|other.?side.?closed/i.test(errorText);\n}\n/**\n * Extract a clean, user-friendly error message from Google API error response.\n * Parses JSON error responses and returns just the message field.\n */\nfunction extractErrorMessage(errorText) {\n try {\n const parsed = JSON.parse(errorText);\n if (parsed.error?.message) {\n return parsed.error.message;\n }\n }\n catch {\n // Not JSON, return as-is\n }\n return errorText;\n}\n/**\n * Sleep for a given number of milliseconds, respecting abort signal.\n */\nfunction sleep(ms, signal) {\n return new Promise((resolve, reject) => {\n if (signal?.aborted) {\n reject(new Error(\"Request was aborted\"));\n return;\n }\n const timeout = setTimeout(resolve, ms);\n signal?.addEventListener(\"abort\", () => {\n clearTimeout(timeout);\n reject(new Error(\"Request was aborted\"));\n });\n });\n}\nexport const streamGoogleGeminiCli = (model, context, options) => {\n const stream = new AssistantMessageEventStream();\n (async () => {\n const output = {\n role: \"assistant\",\n content: [],\n api: \"google-gemini-cli\",\n provider: model.provider,\n model: model.id,\n usage: {\n input: 0,\n output: 0,\n cacheRead: 0,\n cacheWrite: 0,\n totalTokens: 0,\n cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },\n },\n stopReason: \"stop\",\n timestamp: Date.now(),\n };\n try {\n // apiKey is JSON-encoded: { token, projectId }\n const apiKeyRaw = options?.apiKey;\n if (!apiKeyRaw) {\n throw new Error(\"Google Cloud Code Assist requires OAuth authentication. Use /login to authenticate.\");\n }\n let accessToken;\n let projectId;\n try {\n const parsed = JSON.parse(apiKeyRaw);\n accessToken = parsed.token;\n projectId = parsed.projectId;\n }\n catch {\n throw new Error(\"Invalid Google Cloud Code Assist credentials. Use /login to re-authenticate.\");\n }\n if (!accessToken || !projectId) {\n throw new Error(\"Missing token or projectId in Google Cloud credentials. Use /login to re-authenticate.\");\n }\n const isAntigravity = model.provider === \"google-antigravity\";\n const baseUrl = model.baseUrl?.trim();\n const endpoints = baseUrl ? [baseUrl] : isAntigravity ? ANTIGRAVITY_ENDPOINT_FALLBACKS : [DEFAULT_ENDPOINT];\n let requestBody = buildRequest(model, context, projectId, options, isAntigravity);\n const nextRequestBody = await options?.onPayload?.(requestBody, model);\n if (nextRequestBody !== undefined) {\n requestBody = nextRequestBody;\n }\n const headers = isAntigravity ? getAntigravityHeaders() : GEMINI_CLI_HEADERS;\n const requestHeaders = {\n Authorization: `Bearer ${accessToken}`,\n \"Content-Type\": \"application/json\",\n Accept: \"text/event-stream\",\n ...headers,\n ...(needsClaudeThinkingBetaHeader(model) ? { \"anthropic-beta\": CLAUDE_THINKING_BETA_HEADER } : {}),\n ...options?.headers,\n };\n const requestBodyJson = JSON.stringify(requestBody);\n // Fetch with retry logic for rate limits, transient errors, and endpoint fallbacks.\n // On 403/404, immediately try the next endpoint (no delay).\n // On 429/5xx, retry with backoff on the same or next endpoint.\n let response;\n let lastError;\n let requestUrl;\n let endpointIndex = 0;\n for (let attempt = 0; attempt <= MAX_RETRIES; attempt++) {\n if (options?.signal?.aborted) {\n throw new Error(\"Request was aborted\");\n }\n try {\n const endpoint = endpoints[endpointIndex];\n requestUrl = `${endpoint}/v1internal:streamGenerateContent?alt=sse`;\n response = await fetch(requestUrl, {\n method: \"POST\",\n headers: requestHeaders,\n body: requestBodyJson,\n signal: options?.signal,\n });\n if (response.ok) {\n break; // Success, exit retry loop\n }\n const errorText = await response.text();\n // On 403/404, cascade to the next endpoint immediately (no delay)\n if ((response.status === 403 || response.status === 404) && endpointIndex < endpoints.length - 1) {\n endpointIndex++;\n continue;\n }\n // Check if retryable (429, 5xx, network patterns)\n if (attempt < MAX_RETRIES && isRetryableError(response.status, errorText)) {\n // Advance endpoint if possible\n if (endpointIndex < endpoints.length - 1) {\n endpointIndex++;\n }\n // Use server-provided delay or exponential backoff\n const serverDelay = extractRetryDelay(errorText, response);\n const delayMs = serverDelay ?? BASE_DELAY_MS * 2 ** attempt;\n // Check if server delay exceeds max allowed (default: 60s)\n const maxDelayMs = options?.maxRetryDelayMs ?? 60000;\n if (maxDelayMs > 0 && serverDelay && serverDelay > maxDelayMs) {\n const delaySeconds = Math.ceil(serverDelay / 1000);\n throw new Error(`Server requested ${delaySeconds}s retry delay (max: ${Math.ceil(maxDelayMs / 1000)}s). ${extractErrorMessage(errorText)}`);\n }\n await sleep(delayMs, options?.signal);\n continue;\n }\n // Not retryable or max retries exceeded\n throw new Error(`Cloud Code Assist API error (${response.status}): ${extractErrorMessage(errorText)}`);\n }\n catch (error) {\n // Check for abort - fetch throws AbortError, our code throws \"Request was aborted\"\n if (error instanceof Error) {\n if (error.name === \"AbortError\" || error.message === \"Request was aborted\") {\n throw new Error(\"Request was aborted\");\n }\n }\n // Extract detailed error message from fetch errors (Node includes cause)\n lastError = error instanceof Error ? error : new Error(String(error));\n if (lastError.message === \"fetch failed\" && lastError.cause instanceof Error) {\n lastError = new Error(`Network error: ${lastError.cause.message}`);\n }\n // Network errors are retryable\n if (attempt < MAX_RETRIES) {\n const delayMs = BASE_DELAY_MS * 2 ** attempt;\n await sleep(delayMs, options?.signal);\n continue;\n }\n throw lastError;\n }\n }\n if (!response || !response.ok) {\n throw lastError ?? new Error(\"Failed to get response after retries\");\n }\n let started = false;\n const ensureStarted = () => {\n if (!started) {\n stream.push({ type: \"start\", partial: output });\n started = true;\n }\n };\n const resetOutput = () => {\n output.content = [];\n output.usage = {\n input: 0,\n output: 0,\n cacheRead: 0,\n cacheWrite: 0,\n totalTokens: 0,\n cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },\n };\n output.stopReason = \"stop\";\n output.errorMessage = undefined;\n output.timestamp = Date.now();\n started = false;\n };\n const streamResponse = async (activeResponse) => {\n if (!activeResponse.body) {\n throw new Error(\"No response body\");\n }\n let hasContent = false;\n let currentBlock = null;\n const blocks = output.content;\n const blockIndex = () => blocks.length - 1;\n // Read SSE stream\n const reader = activeResponse.body.getReader();\n const decoder = new TextDecoder();\n let buffer = \"\";\n // Set up abort handler to cancel reader when signal fires\n const abortHandler = () => {\n void reader.cancel().catch(() => { });\n };\n options?.signal?.addEventListener(\"abort\", abortHandler);\n try {\n while (true) {\n // Check abort signal before each read\n if (options?.signal?.aborted) {\n throw new Error(\"Request was aborted\");\n }\n const { done, value } = await reader.read();\n if (done)\n break;\n buffer += decoder.decode(value, { stream: true });\n const lines = buffer.split(\"\\n\");\n buffer = lines.pop() || \"\";\n for (const line of lines) {\n if (!line.startsWith(\"data:\"))\n continue;\n const jsonStr = line.slice(5).trim();\n if (!jsonStr)\n continue;\n let chunk;\n try {\n chunk = JSON.parse(jsonStr);\n }\n catch {\n continue;\n }\n // Unwrap the response\n const responseData = chunk.response;\n if (!responseData)\n continue;\n // Cloud Code Assist mirrors Gemini's responseId field. Keep the first non-empty one.\n // A single streamed response should retain the same ID across chunks.\n output.responseId ||= responseData.responseId;\n const candidate = responseData.candidates?.[0];\n if (candidate?.content?.parts) {\n for (const part of candidate.content.parts) {\n if (part.text !== undefined) {\n hasContent = true;\n const isThinking = isThinkingPart(part);\n if (!currentBlock ||\n (isThinking && currentBlock.type !== \"thinking\") ||\n (!isThinking && currentBlock.type !== \"text\")) {\n if (currentBlock) {\n if (currentBlock.type === \"text\") {\n stream.push({\n type: \"text_end\",\n contentIndex: blocks.length - 1,\n content: currentBlock.text,\n partial: output,\n });\n }\n else {\n stream.push({\n type: \"thinking_end\",\n contentIndex: blockIndex(),\n content: currentBlock.thinking,\n partial: output,\n });\n }\n }\n if (isThinking) {\n currentBlock = { type: \"thinking\", thinking: \"\", thinkingSignature: undefined };\n output.content.push(currentBlock);\n ensureStarted();\n stream.push({\n type: \"thinking_start\",\n contentIndex: blockIndex(),\n partial: output,\n });\n }\n else {\n currentBlock = { type: \"text\", text: \"\" };\n output.content.push(currentBlock);\n ensureStarted();\n stream.push({ type: \"text_start\", contentIndex: blockIndex(), partial: output });\n }\n }\n if (currentBlock.type === \"thinking\") {\n currentBlock.thinking += part.text;\n currentBlock.thinkingSignature = retainThoughtSignature(currentBlock.thinkingSignature, part.thoughtSignature);\n stream.push({\n type: \"thinking_delta\",\n contentIndex: blockIndex(),\n delta: part.text,\n partial: output,\n });\n }\n else {\n currentBlock.text += part.text;\n currentBlock.textSignature = retainThoughtSignature(currentBlock.textSignature, part.thoughtSignature);\n stream.push({\n type: \"text_delta\",\n contentIndex: blockIndex(),\n delta: part.text,\n partial: output,\n });\n }\n }\n if (part.functionCall) {\n hasContent = true;\n if (currentBlock) {\n if (currentBlock.type === \"text\") {\n stream.push({\n type: \"text_end\",\n contentIndex: blockIndex(),\n content: currentBlock.text,\n partial: output,\n });\n }\n else {\n stream.push({\n type: \"thinking_end\",\n contentIndex: blockIndex(),\n content: currentBlock.thinking,\n partial: output,\n });\n }\n currentBlock = null;\n }\n const providedId = part.functionCall.id;\n const needsNewId = !providedId ||\n output.content.some((b) => b.type === \"toolCall\" && b.id === providedId);\n const toolCallId = needsNewId\n ? `${part.functionCall.name}_${Date.now()}_${++toolCallCounter}`\n : providedId;\n const toolCall = {\n type: \"toolCall\",\n id: toolCallId,\n name: part.functionCall.name || \"\",\n arguments: part.functionCall.args ?? {},\n ...(part.thoughtSignature && { thoughtSignature: part.thoughtSignature }),\n };\n output.content.push(toolCall);\n ensureStarted();\n stream.push({ type: \"toolcall_start\", contentIndex: blockIndex(), partial: output });\n stream.push({\n type: \"toolcall_delta\",\n contentIndex: blockIndex(),\n delta: JSON.stringify(toolCall.arguments),\n partial: output,\n });\n stream.push({\n type: \"toolcall_end\",\n contentIndex: blockIndex(),\n toolCall,\n partial: output,\n });\n }\n }\n }\n if (candidate?.finishReason) {\n output.stopReason = mapStopReasonString(candidate.finishReason);\n if (output.content.some((b) => b.type === \"toolCall\")) {\n output.stopReason = \"toolUse\";\n }\n }\n if (responseData.usageMetadata) {\n // promptTokenCount includes cachedContentTokenCount, so subtract to get fresh input\n const promptTokens = responseData.usageMetadata.promptTokenCount || 0;\n const cacheReadTokens = responseData.usageMetadata.cachedContentTokenCount || 0;\n output.usage = {\n input: promptTokens - cacheReadTokens,\n output: (responseData.usageMetadata.candidatesTokenCount || 0) +\n (responseData.usageMetadata.thoughtsTokenCount || 0),\n cacheRead: cacheReadTokens,\n cacheWrite: 0,\n totalTokens: responseData.usageMetadata.totalTokenCount || 0,\n cost: {\n input: 0,\n output: 0,\n cacheRead: 0,\n cacheWrite: 0,\n total: 0,\n },\n };\n calculateCost(model, output.usage);\n }\n }\n }\n }\n finally {\n options?.signal?.removeEventListener(\"abort\", abortHandler);\n }\n if (currentBlock) {\n if (currentBlock.type === \"text\") {\n stream.push({\n type: \"text_end\",\n contentIndex: blockIndex(),\n content: currentBlock.text,\n partial: output,\n });\n }\n else {\n stream.push({\n type: \"thinking_end\",\n contentIndex: blockIndex(),\n content: currentBlock.thinking,\n partial: output,\n });\n }\n }\n return hasContent;\n };\n let receivedContent = false;\n let currentResponse = response;\n for (let emptyAttempt = 0; emptyAttempt <= MAX_EMPTY_STREAM_RETRIES; emptyAttempt++) {\n if (options?.signal?.aborted) {\n throw new Error(\"Request was aborted\");\n }\n if (emptyAttempt > 0) {\n const backoffMs = EMPTY_STREAM_BASE_DELAY_MS * 2 ** (emptyAttempt - 1);\n await sleep(backoffMs, options?.signal);\n if (!requestUrl) {\n throw new Error(\"Missing request URL\");\n }\n currentResponse = await fetch(requestUrl, {\n method: \"POST\",\n headers: requestHeaders,\n body: requestBodyJson,\n signal: options?.signal,\n });\n if (!currentResponse.ok) {\n const retryErrorText = await currentResponse.text();\n throw new Error(`Cloud Code Assist API error (${currentResponse.status}): ${retryErrorText}`);\n }\n }\n const streamed = await streamResponse(currentResponse);\n if (streamed) {\n receivedContent = true;\n break;\n }\n if (emptyAttempt < MAX_EMPTY_STREAM_RETRIES) {\n resetOutput();\n }\n }\n if (!receivedContent) {\n throw new Error(\"Cloud Code Assist API returned an empty response\");\n }\n if (options?.signal?.aborted) {\n throw new Error(\"Request was aborted\");\n }\n if (output.stopReason === \"aborted\" || output.stopReason === \"error\") {\n throw new Error(\"An unknown error occurred\");\n }\n stream.push({ type: \"done\", reason: output.stopReason, message: output });\n stream.end();\n }\n catch (error) {\n for (const block of output.content) {\n if (\"index\" in block) {\n delete block.index;\n }\n }\n output.stopReason = options?.signal?.aborted ? \"aborted\" : \"error\";\n output.errorMessage = error instanceof Error ? error.message : JSON.stringify(error);\n stream.push({ type: \"error\", reason: output.stopReason, error: output });\n stream.end();\n }\n })();\n return stream;\n};\nexport const streamSimpleGoogleGeminiCli = (model, context, options) => {\n const apiKey = options?.apiKey;\n if (!apiKey) {\n throw new Error(\"Google Cloud Code Assist requires OAuth authentication. Use /login to authenticate.\");\n }\n const base = buildBaseOptions(model, options, apiKey);\n if (!options?.reasoning) {\n return streamGoogleGeminiCli(model, context, {\n ...base,\n thinking: { enabled: false },\n });\n }\n const effort = clampReasoning(options.reasoning);\n if (isGemini3Model(model.id)) {\n return streamGoogleGeminiCli(model, context, {\n ...base,\n thinking: {\n enabled: true,\n level: getGeminiCliThinkingLevel(effort, model.id),\n },\n });\n }\n const defaultBudgets = {\n minimal: 1024,\n low: 2048,\n medium: 8192,\n high: 16384,\n };\n const budgets = { ...defaultBudgets, ...options.thinkingBudgets };\n const minOutputTokens = 1024;\n let thinkingBudget = budgets[effort];\n const maxTokens = Math.min((base.maxTokens || 0) + thinkingBudget, model.maxTokens);\n if (maxTokens <= thinkingBudget) {\n thinkingBudget = Math.max(0, maxTokens - minOutputTokens);\n }\n return streamGoogleGeminiCli(model, context, {\n ...base,\n maxTokens,\n thinking: {\n enabled: true,\n budgetTokens: thinkingBudget,\n },\n });\n};\nexport function buildRequest(model, context, projectId, options = {}, isAntigravity = false) {\n const contents = convertMessages(model, context);\n const generationConfig = {};\n if (options.temperature !== undefined) {\n generationConfig.temperature = options.temperature;\n }\n if (options.maxTokens !== undefined) {\n generationConfig.maxOutputTokens = options.maxTokens;\n }\n // Thinking config\n if (options.thinking?.enabled && model.reasoning) {\n generationConfig.thinkingConfig = {\n includeThoughts: true,\n };\n // Gemini 3 models use thinkingLevel, older models use thinkingBudget\n if (options.thinking.level !== undefined) {\n // Cast to any since our GoogleThinkingLevel mirrors Google's ThinkingLevel enum values\n generationConfig.thinkingConfig.thinkingLevel = options.thinking.level;\n }\n else if (options.thinking.budgetTokens !== undefined) {\n generationConfig.thinkingConfig.thinkingBudget = options.thinking.budgetTokens;\n }\n }\n else if (model.reasoning && options.thinking && !options.thinking.enabled) {\n generationConfig.thinkingConfig = getDisabledThinkingConfig(model.id);\n }\n const request = {\n contents,\n };\n request.sessionId = options.sessionId;\n // System instruction must be object with parts, not plain string\n if (context.systemPrompt) {\n request.systemInstruction = {\n parts: [{ text: sanitizeSurrogates(context.systemPrompt) }],\n };\n }\n if (Object.keys(generationConfig).length > 0) {\n request.generationConfig = generationConfig;\n }\n if (context.tools && context.tools.length > 0) {\n // Claude models on Cloud Code Assist need the legacy `parameters` field;\n // the API translates it into Anthropic's `input_schema`.\n const useParameters = model.id.startsWith(\"claude-\");\n request.tools = convertTools(context.tools, useParameters);\n if (options.toolChoice) {\n request.toolConfig = {\n functionCallingConfig: {\n mode: mapToolChoice(options.toolChoice),\n },\n };\n }\n }\n if (isAntigravity) {\n const existingParts = request.systemInstruction?.parts ?? [];\n request.systemInstruction = {\n role: \"user\",\n parts: [\n { text: ANTIGRAVITY_SYSTEM_INSTRUCTION },\n { text: `Please ignore following [ignore]${ANTIGRAVITY_SYSTEM_INSTRUCTION}[/ignore]` },\n ...existingParts,\n ],\n };\n }\n return {\n project: projectId,\n model: model.id,\n request,\n ...(isAntigravity ? { requestType: \"agent\" } : {}),\n userAgent: isAntigravity ? \"antigravity\" : \"pi-coding-agent\",\n requestId: `${isAntigravity ? \"agent\" : \"pi\"}-${Date.now()}-${Math.random().toString(36).slice(2, 11)}`,\n };\n}\nfunction getDisabledThinkingConfig(modelId) {\n // Google docs: Gemini 3.1 Pro cannot disable thinking, and Gemini 3 Flash / Flash-Lite\n // do not support full thinking-off either. For Gemini 3 models, use the lowest supported\n // thinkingLevel without includeThoughts so hidden thinking remains invisible to pi.\n if (isGemini3ProModel(modelId)) {\n return { thinkingLevel: \"LOW\" };\n }\n if (isGemini3FlashModel(modelId)) {\n return { thinkingLevel: \"MINIMAL\" };\n }\n // Gemini 2.x supports disabling via thinkingBudget = 0.\n return { thinkingBudget: 0 };\n}\nfunction getGeminiCliThinkingLevel(effort, modelId) {\n if (isGemini3ProModel(modelId)) {\n switch (effort) {\n case \"minimal\":\n case \"low\":\n return \"LOW\";\n case \"medium\":\n case \"high\":\n return \"HIGH\";\n }\n }\n switch (effort) {\n case \"minimal\":\n return \"MINIMAL\";\n case \"low\":\n return \"LOW\";\n case \"medium\":\n return \"MEDIUM\";\n case \"high\":\n return \"HIGH\";\n }\n}\n//# sourceMappingURL=google-gemini-cli.js.map"],"x_google_ignoreList":[0],"mappings":"kMAUA,IAAM,EAAmB,sCAGnB,EAAiC,CAFJ,oDACG,uDAIlC,EACH,CAEK,EAAqB,CACvB,aAAc,+CACd,oBAAqB,kBACrB,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