@wenathlan/devthink 2.0.14 → 2.0.19

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 (444) hide show
  1. package/CHANGELOG.md +60 -0
  2. package/{dist/bridge.d.ts → bridge.d.ts} +1 -1
  3. package/bridge.d.ts.map +1 -0
  4. package/bridge.js +1877 -0
  5. package/bun.d.ts.map +1 -0
  6. package/bun.js +52329 -0
  7. package/caps/background.json +712 -0
  8. package/caps/cli.json +360 -0
  9. package/caps/library.json +3611 -0
  10. package/caps/mcp.json +126 -0
  11. package/caps/pagebridge.json +377 -0
  12. package/caps/popup.json +51 -0
  13. package/caps/sidepanel.json +522 -0
  14. package/checksums.txt +142 -0
  15. package/cli.d.ts.map +1 -0
  16. package/{dist/cli.js → cli.js} +2 -2
  17. package/companion.d.ts.map +1 -0
  18. package/companion.js +389 -0
  19. package/crossbrowser.d.ts.map +1 -0
  20. package/crossbrowser.js +1191 -0
  21. package/dashdone.d.ts.map +1 -0
  22. package/dashdone.js +368 -0
  23. package/deno.d.ts.map +1 -0
  24. package/deno.js +52325 -0
  25. package/devthink.umd.js +52346 -0
  26. package/fixtures/bun.ts +7 -0
  27. package/fixtures/cjs.js +6 -0
  28. package/fixtures/deno.ts +6 -0
  29. package/fixtures/example-org-pagestate.json +22 -0
  30. package/fixtures/importers/automa-workflow.json +18 -0
  31. package/fixtures/importers/selenium-side.json +20 -0
  32. package/fixtures/importers/tabular-plan.csv +7 -0
  33. package/fixtures/importers/uivision-macro.json +10 -0
  34. package/fixtures/importers/v1-plan.json +13 -0
  35. package/fixtures/mcp-client.mjs +14 -0
  36. package/fixtures/pages/checkout.html +192 -0
  37. package/fixtures/pages/dashboard.html +110 -0
  38. package/fixtures/pages/feed.html +113 -0
  39. package/fixtures/pages/product-grid.html +150 -0
  40. package/fixtures/plans/form-inventory-plan.json +11 -0
  41. package/fixtures/plans/release-notes-plan.json +11 -0
  42. package/fixtures/recipes/agentscompete.json +11 -0
  43. package/fixtures/recipes/agentsforms.json +11 -0
  44. package/fixtures/recipes/agentsmonitor.json +11 -0
  45. package/fixtures/recipes/agentsreview.json +29 -0
  46. package/fixtures/recipes/agentswarm.json +11 -0
  47. package/fixtures/recipes/fillcalendar.json +12 -0
  48. package/fixtures/recipes/fillcheckout.json +13 -0
  49. package/fixtures/recipes/filldependentdropdowns.json +12 -0
  50. package/fixtures/recipes/fillfromcsv.json +13 -0
  51. package/fixtures/recipes/fillloginform.json +12 -0
  52. package/fixtures/recipes/fillmultistepwizard.json +13 -0
  53. package/fixtures/recipes/fillregistration.json +12 -0
  54. package/fixtures/recipes/fillsearchfilters.json +12 -0
  55. package/fixtures/recipes/filltypeahead.json +11 -0
  56. package/fixtures/recipes/monitoralerts.json +12 -0
  57. package/fixtures/recipes/monitoravailability.json +11 -0
  58. package/fixtures/recipes/monitornetworkquiet.json +12 -0
  59. package/fixtures/recipes/monitorpagechanges.json +11 -0
  60. package/fixtures/recipes/monitorpricechange.json +11 -0
  61. package/fixtures/recipes/monitorschedule.json +12 -0
  62. package/fixtures/recipes/scrapedynamicprices.json +13 -0
  63. package/fixtures/recipes/scrapeimagegallery.json +12 -0
  64. package/fixtures/recipes/scrapeinfinitefeed.json +13 -0
  65. package/fixtures/recipes/scrapenestedlists.json +12 -0
  66. package/fixtures/recipes/scrapeproductgrid.json +12 -0
  67. package/fixtures/recipes/scrapereviews.json +12 -0
  68. package/fixtures/recipes/scrapesearchresults.json +12 -0
  69. package/fixtures/recipes/scrapetablepagination.json +12 -0
  70. package/fixtures/recipes/testaccessibility.json +34 -0
  71. package/fixtures/recipes/testconsoleerrors.json +12 -0
  72. package/fixtures/recipes/testdeeplinks.json +12 -0
  73. package/fixtures/recipes/testformvalidation.json +13 -0
  74. package/fixtures/recipes/testlayoutshift.json +12 -0
  75. package/fixtures/recipes/testlinkcheck.json +12 -0
  76. package/fixtures/recipes/testloadtiming.json +12 -0
  77. package/fixtures/recipes/testvisualdiff.json +12 -0
  78. package/fixtures/workflows/changelog-digest-workflow.json +13 -0
  79. package/fixtures/workflows/form-survey-workflow.json +13 -0
  80. package/gallery.json +706 -0
  81. package/hardening.d.ts.map +1 -0
  82. package/hardening.js +188 -0
  83. package/headless.d.ts.map +1 -0
  84. package/headless.js +11522 -0
  85. package/http.d.ts.map +1 -0
  86. package/http.js +2165 -0
  87. package/index.cjs +54682 -0
  88. package/index.d.ts.map +1 -0
  89. package/index.js +52310 -0
  90. package/index.neutral.js +46343 -0
  91. package/{web/manifest.json → manifest.json} +1 -1
  92. package/mcp.d.ts.map +1 -0
  93. package/mcp.js +20515 -0
  94. package/memory.d.ts.map +1 -0
  95. package/{memory.ts → memory.js} +2310 -3834
  96. package/nativehost.template.json +10 -0
  97. package/node.cjs +54686 -0
  98. package/node.d.ts.map +1 -0
  99. package/pack.d.ts.map +1 -0
  100. package/pack.js +805 -0
  101. package/package.json +83 -176
  102. package/policy.d.ts.map +1 -0
  103. package/{policy.ts → policy.js} +4679 -5073
  104. package/progress.d.ts.map +1 -0
  105. package/progress.js +645 -0
  106. package/protocol.d.ts.map +1 -0
  107. package/protocol.js +8334 -0
  108. package/schemas/audit.schema.json +226 -0
  109. package/schemas/capability.schema.json +113 -0
  110. package/schemas/envelope.schema.json +162 -0
  111. package/schemas/memory.schema.json +51 -0
  112. package/schemas/observation.schema.json +113 -0
  113. package/schemas/plan.schema.json +208 -0
  114. package/schemas/progress.schema.json +126 -0
  115. package/schemas/proposal.schema.json +68 -0
  116. package/schemas/session.schema.json +82 -0
  117. package/schemas/tool.schema.json +94 -0
  118. package/server.d.ts.map +1 -0
  119. package/server.js +28877 -0
  120. package/umd-example.html +18 -0
  121. package/umd.d.ts.map +1 -0
  122. package/accounts.ts +0 -2087
  123. package/agent.ts +0 -2331
  124. package/antigravity.ts +0 -2139
  125. package/apifreeze.ts +0 -4146
  126. package/auth.ts +0 -642
  127. package/background.ts +0 -16837
  128. package/bridge.ts +0 -2080
  129. package/build.ts +0 -54
  130. package/bun.ts +0 -26
  131. package/capture.ts +0 -1614
  132. package/checksecrets.ts +0 -72
  133. package/cjs.ts +0 -9
  134. package/cli.ts +0 -3500
  135. package/commands.ts +0 -1101
  136. package/companion.ts +0 -450
  137. package/compatibility.ts +0 -37
  138. package/config.ts +0 -3137
  139. package/constants.ts +0 -943
  140. package/core.ts +0 -1473
  141. package/crossbrowser.ts +0 -1359
  142. package/dashdone.ts +0 -605
  143. package/data.ts +0 -943
  144. package/database.ts +0 -133
  145. package/debug.ts +0 -850
  146. package/deno.ts +0 -27
  147. package/devthink.ts +0 -707
  148. package/dist/accounts.d.ts +0 -409
  149. package/dist/agent.d.ts +0 -837
  150. package/dist/antigravity.d.ts +0 -380
  151. package/dist/apifreeze.d.ts +0 -113
  152. package/dist/auth.d.ts +0 -224
  153. package/dist/capture.d.ts +0 -595
  154. package/dist/cjs.d.ts +0 -6
  155. package/dist/commands.d.ts +0 -310
  156. package/dist/compatibility.d.ts +0 -17
  157. package/dist/config.d.ts +0 -1853
  158. package/dist/constants.d.ts +0 -637
  159. package/dist/core.d.ts +0 -361
  160. package/dist/data.d.ts +0 -330
  161. package/dist/database.d.ts +0 -24
  162. package/dist/debug.d.ts +0 -270
  163. package/dist/engine.d.ts +0 -74
  164. package/dist/environments.d.ts +0 -244
  165. package/dist/evidence.d.ts +0 -277
  166. package/dist/export.d.ts +0 -311
  167. package/dist/fingerprint.d.ts +0 -594
  168. package/dist/flow.d.ts +0 -300
  169. package/dist/gates.d.ts +0 -103
  170. package/dist/identity.d.ts +0 -51
  171. package/dist/ids.d.ts +0 -7
  172. package/dist/llm.d.ts +0 -652
  173. package/dist/models.d.ts +0 -1807
  174. package/dist/net.d.ts +0 -325
  175. package/dist/neutral.d.ts +0 -41
  176. package/dist/oauth.d.ts +0 -703
  177. package/dist/page.d.ts +0 -1166
  178. package/dist/perf.d.ts +0 -481
  179. package/dist/plan.d.ts +0 -134
  180. package/dist/project.d.ts +0 -395
  181. package/dist/providers.d.ts +0 -37
  182. package/dist/quota.d.ts +0 -453
  183. package/dist/recovery.d.ts +0 -621
  184. package/dist/request.d.ts +0 -1492
  185. package/dist/run.d.ts +0 -779
  186. package/dist/runtime.d.ts +0 -212
  187. package/dist/search.d.ts +0 -375
  188. package/dist/security.d.ts +0 -534
  189. package/dist/serve.d.ts +0 -136
  190. package/dist/session.d.ts +0 -296
  191. package/dist/storage.d.ts +0 -53
  192. package/dist/streaming.d.ts +0 -1119
  193. package/dist/swarm.d.ts +0 -328
  194. package/dist/tools.d.ts +0 -170
  195. package/dist/types.d.ts +0 -8357
  196. package/dist/utils.d.ts +0 -82
  197. package/dist/version.d.ts +0 -7
  198. package/dist/versionregistry.d.ts +0 -406
  199. package/dist/views.d.ts +0 -579
  200. package/dist/workbenchsession.d.ts +0 -69
  201. package/dist/workflow.d.ts +0 -649
  202. package/docs/readme.md +0 -92
  203. package/docs/schemas/antigravity.json +0 -192
  204. package/engine.ts +0 -1524
  205. package/environments.ts +0 -1005
  206. package/evidence.ts +0 -643
  207. package/export.ts +0 -889
  208. package/fingerprint.ts +0 -1458
  209. package/flow.ts +0 -1190
  210. package/gates.ts +0 -307
  211. package/gateway.ts +0 -34
  212. package/hardening.ts +0 -191
  213. package/headless.ts +0 -369
  214. package/http.ts +0 -2110
  215. package/identity.ts +0 -246
  216. package/ids.ts +0 -26
  217. package/index.ts +0 -369
  218. package/llm.ts +0 -2682
  219. package/mcp.ts +0 -1835
  220. package/models.ts +0 -3805
  221. package/modes.ts +0 -43
  222. package/net.ts +0 -1214
  223. package/neutral.ts +0 -362
  224. package/node.ts +0 -26
  225. package/oauth.ts +0 -2216
  226. package/offscreen.ts +0 -170
  227. package/pack.ts +0 -956
  228. package/page.ts +0 -7824
  229. package/pagebridge.ts +0 -1116
  230. package/perf.ts +0 -957
  231. package/plan.ts +0 -672
  232. package/plugin.ts +0 -76
  233. package/prisma.config.ts +0 -27
  234. package/progress.ts +0 -1308
  235. package/project.ts +0 -1291
  236. package/protocol.ts +0 -4187
  237. package/providers.ts +0 -246
  238. package/quota.ts +0 -1887
  239. package/recovery.ts +0 -2433
  240. package/request.ts +0 -4482
  241. package/run.ts +0 -2135
  242. package/runtime.ts +0 -526
  243. package/search.ts +0 -1760
  244. package/security.ts +0 -1673
  245. package/serve.ts +0 -419
  246. package/server.ts +0 -5538
  247. package/session.ts +0 -1162
  248. package/storage.ts +0 -182
  249. package/streaming.ts +0 -4101
  250. package/swarm.ts +0 -884
  251. package/sync.ts +0 -56
  252. package/tests/agentcert.test.ts +0 -128
  253. package/tests/agentfleet.test.ts +0 -214
  254. package/tests/agentreview.test.ts +0 -241
  255. package/tests/agentstream.test.ts +0 -335
  256. package/tests/agentwork.test.ts +0 -356
  257. package/tests/apifreeze.test.ts +0 -290
  258. package/tests/apimap.test.ts +0 -112
  259. package/tests/approvalgate.test.ts +0 -175
  260. package/tests/artifactmanifest.test.ts +0 -204
  261. package/tests/attentionfeed.test.ts +0 -163
  262. package/tests/backgroundruns.test.ts +0 -100
  263. package/tests/batchscheduling.test.ts +0 -131
  264. package/tests/blackboard.test.ts +0 -238
  265. package/tests/bridge.test.ts +0 -1088
  266. package/tests/browsercoverage.test.ts +0 -134
  267. package/tests/browserpolyfills.test.ts +0 -124
  268. package/tests/build.mjs +0 -1260
  269. package/tests/clientauth.test.ts +0 -223
  270. package/tests/clitools.test.ts +0 -578
  271. package/tests/confirmgates.test.ts +0 -190
  272. package/tests/containerpack.test.ts +0 -143
  273. package/tests/controlflow.test.ts +0 -2120
  274. package/tests/coordination.test.ts +0 -345
  275. package/tests/copyscreen.test.ts +0 -139
  276. package/tests/core.test.ts +0 -417
  277. package/tests/costcert.test.ts +0 -95
  278. package/tests/crossbrowser.test.ts +0 -115
  279. package/tests/cspaudit.test.ts +0 -79
  280. package/tests/dashdone.test.ts +0 -615
  281. package/tests/datagrid.test.ts +0 -137
  282. package/tests/doccheck.test.ts +0 -107
  283. package/tests/dombatch.test.ts +0 -109
  284. package/tests/emulation.test.ts +0 -282
  285. package/tests/environments.test.ts +0 -259
  286. package/tests/evidenceviews.test.ts +0 -88
  287. package/tests/exporttools.test.ts +0 -185
  288. package/tests/firefoxprep.test.ts +0 -134
  289. package/tests/flowlibrary.test.ts +0 -242
  290. package/tests/flowrun.test.ts +0 -303
  291. package/tests/forensics.test.ts +0 -439
  292. package/tests/gateway.test.ts +0 -939
  293. package/tests/headlesslib.test.ts +0 -171
  294. package/tests/httpstream.test.ts +0 -277
  295. package/tests/immutablelog.test.ts +0 -157
  296. package/tests/inboundguard.test.ts +0 -177
  297. package/tests/lazyload.test.ts +0 -72
  298. package/tests/librarymodes.test.ts +0 -623
  299. package/tests/llm.test.ts +0 -696
  300. package/tests/manifest.test.ts +0 -226
  301. package/tests/maskinputs.test.ts +0 -150
  302. package/tests/matrixverify.test.ts +0 -111
  303. package/tests/mavenpack.test.ts +0 -75
  304. package/tests/mcpserver.test.ts +0 -704
  305. package/tests/memory.test.ts +0 -4155
  306. package/tests/memorycare.test.ts +0 -230
  307. package/tests/migrateplan.test.ts +0 -349
  308. package/tests/minimization.test.ts +0 -414
  309. package/tests/modelroute.test.ts +0 -112
  310. package/tests/multiagent.test.ts +0 -440
  311. package/tests/nativebridge.test.ts +0 -807
  312. package/tests/navigation.test.ts +0 -284
  313. package/tests/nugetpack.test.ts +0 -83
  314. package/tests/orchestration.test.ts +0 -449
  315. package/tests/originpolicy.test.ts +0 -405
  316. package/tests/outputcompare.test.ts +0 -97
  317. package/tests/package.test.ts +0 -91
  318. package/tests/pagebridge.test.ts +0 -5909
  319. package/tests/pentest.test.ts +0 -75
  320. package/tests/perfrecords.test.ts +0 -257
  321. package/tests/permdiff.test.ts +0 -85
  322. package/tests/phishguard.test.ts +0 -128
  323. package/tests/pickerviews.test.ts +0 -155
  324. package/tests/pipelines.test.ts +0 -381
  325. package/tests/planlint.test.ts +0 -240
  326. package/tests/planreview.test.ts +0 -383
  327. package/tests/platformtargets.test.ts +0 -56
  328. package/tests/policy.test.ts +0 -8284
  329. package/tests/portability.test.ts +0 -96
  330. package/tests/progress.test.ts +0 -1036
  331. package/tests/promptlibrary.test.ts +0 -116
  332. package/tests/protocol.test.ts +0 -4793
  333. package/tests/publishingpipeline.test.ts +0 -314
  334. package/tests/quickactions.test.ts +0 -164
  335. package/tests/readiness.test.ts +0 -78
  336. package/tests/recipes.test.ts +0 -163
  337. package/tests/redactshots.test.ts +0 -216
  338. package/tests/registernvidiakeys.ts +0 -51
  339. package/tests/relayserve.test.ts +0 -304
  340. package/tests/releasenotes.test.ts +0 -276
  341. package/tests/resilience.test.ts +0 -467
  342. package/tests/resourceaware.test.ts +0 -187
  343. package/tests/runbudget.test.ts +0 -125
  344. package/tests/runhistory.test.ts +0 -299
  345. package/tests/runreplay.test.ts +0 -113
  346. package/tests/runresume.test.ts +0 -184
  347. package/tests/runstate.test.ts +0 -288
  348. package/tests/runtimeadapters.test.ts +0 -251
  349. package/tests/safariskeleton.test.ts +0 -115
  350. package/tests/sandboxframe.test.ts +0 -196
  351. package/tests/sbom.test.ts +0 -105
  352. package/tests/secretvault.test.ts +0 -188
  353. package/tests/selcache.test.ts +0 -111
  354. package/tests/sessioninterface.test.ts +0 -791
  355. package/tests/sessions.test.ts +0 -591
  356. package/tests/siteprefs.test.ts +0 -228
  357. package/tests/snapshotdelta.test.ts +0 -165
  358. package/tests/statusviews.test.ts +0 -237
  359. package/tests/stepmeter.test.ts +0 -200
  360. package/tests/streamparse.test.ts +0 -163
  361. package/tests/stylepruning.test.ts +0 -90
  362. package/tests/surfaces.test.ts +0 -282
  363. package/tests/sweep.test.ts +0 -78
  364. package/tests/syncbridge.test.ts +0 -164
  365. package/tests/taskqueue.test.ts +0 -206
  366. package/tests/toolcalls.test.ts +0 -336
  367. package/tests/toolcatalog.test.ts +0 -201
  368. package/tests/torture-agent.test.ts +0 -706
  369. package/tests/torture-auth.test.ts +0 -461
  370. package/tests/torture-commands.test.ts +0 -895
  371. package/tests/torture-data.test.ts +0 -923
  372. package/tests/torture-environments.test.ts +0 -285
  373. package/tests/torture-export.test.ts +0 -263
  374. package/tests/torture-http.test.ts +0 -1379
  375. package/tests/torture-llm.test.ts +0 -808
  376. package/tests/torture-memory.test.ts +0 -1084
  377. package/tests/torture-plan.test.ts +0 -829
  378. package/tests/torture-run.test.ts +0 -626
  379. package/tests/torture-session.test.ts +0 -928
  380. package/tests/torture-swarm.test.ts +0 -1245
  381. package/tests/torture-tools.test.ts +0 -964
  382. package/tests/torture-workflow.test.ts +0 -2354
  383. package/tests/tourviews.test.ts +0 -52
  384. package/tests/transparency.test.ts +0 -147
  385. package/tests/trigger.test.ts +0 -941
  386. package/tests/v1sunset.test.ts +0 -428
  387. package/tests/virtlist.test.ts +0 -94
  388. package/tests/vision.test.ts +0 -540
  389. package/tests/vsixpack.test.ts +0 -145
  390. package/tests/webapi.test.ts +0 -523
  391. package/tests/workflow.test.ts +0 -1785
  392. package/tests/workfloweditor.test.ts +0 -759
  393. package/tests/xpipack.test.ts +0 -128
  394. package/tools.ts +0 -734
  395. package/types.ts +0 -9908
  396. package/umd.ts +0 -9
  397. package/utils.ts +0 -249
  398. package/version.ts +0 -8
  399. package/versionregistry.ts +0 -1310
  400. package/views.ts +0 -2153
  401. package/vitest.config.ts +0 -12
  402. package/web/App.tsx +0 -78
  403. package/web/README.md +0 -47
  404. package/web/capacitor.config.ts +0 -46
  405. package/web/const.ts +0 -19
  406. package/web/control.shell.tsx +0 -66
  407. package/web/dashboardpage.ts +0 -554
  408. package/web/db.ts +0 -493
  409. package/web/design.html +0 -541
  410. package/web/gatewayview/Gateway.tsx +0 -345
  411. package/web/gatewayview/config.ts +0 -1042
  412. package/web/gatewayview/definition.ts +0 -174
  413. package/web/icons.ts +0 -15
  414. package/web/optionspage.ts +0 -691
  415. package/web/popup.ts +0 -1651
  416. package/web/schema.prisma +0 -176
  417. package/web/sidepanel.ts +0 -7941
  418. package/web/sitemanifest.json +0 -13
  419. package/web/terminal-ui.tsx +0 -622
  420. package/web/transparencypage.ts +0 -541
  421. package/web/vite.config.ts +0 -39
  422. package/web/workspace.ts +0 -23
  423. package/workbenchmemory.ts +0 -104
  424. package/workbenchsession.ts +0 -304
  425. package/workflow.ts +0 -4495
  426. /package/{dist/bun.d.ts → bun.d.ts} +0 -0
  427. /package/{dist/cli.d.ts → cli.d.ts} +0 -0
  428. /package/{dist/companion.d.ts → companion.d.ts} +0 -0
  429. /package/{dist/crossbrowser.d.ts → crossbrowser.d.ts} +0 -0
  430. /package/{dist/dashdone.d.ts → dashdone.d.ts} +0 -0
  431. /package/{dist/deno.d.ts → deno.d.ts} +0 -0
  432. /package/{dist/hardening.d.ts → hardening.d.ts} +0 -0
  433. /package/{dist/headless.d.ts → headless.d.ts} +0 -0
  434. /package/{dist/http.d.ts → http.d.ts} +0 -0
  435. /package/{dist/index.d.ts → index.d.ts} +0 -0
  436. /package/{dist/mcp.d.ts → mcp.d.ts} +0 -0
  437. /package/{dist/memory.d.ts → memory.d.ts} +0 -0
  438. /package/{dist/node.d.ts → node.d.ts} +0 -0
  439. /package/{dist/pack.d.ts → pack.d.ts} +0 -0
  440. /package/{dist/policy.d.ts → policy.d.ts} +0 -0
  441. /package/{dist/progress.d.ts → progress.d.ts} +0 -0
  442. /package/{dist/protocol.d.ts → protocol.d.ts} +0 -0
  443. /package/{dist/server.d.ts → server.d.ts} +0 -0
  444. /package/{dist/umd.d.ts → umd.d.ts} +0 -0
package/dist/request.d.ts DELETED
@@ -1,1492 +0,0 @@
1
- /**
2
- * @file request.ts
3
- * @module provider/request
4
- * @description
5
- * THE single request-building module of the provider family of the merged library. v2.1.14
6
- * consolidation: request.ts absorbed request-helpers.ts in full, so the
7
- * entire request-building category — schema cleaning, tool validation,
8
- * thinking budgets, fingerprint headers, session/prompt id builders, model
9
- * classification, request transforms/builders and cascade fetch — lives in
10
- * this one file.
11
- *
12
- * Third-person observer view: the library watches how OpenCode transforms
13
- * user messages (OpenAI and Anthropic shapes) into Gemini/Claude payloads
14
- * and how Antigravity Manager forwards them to cloudcode-pa.googleapis.com
15
- * without using localhost v1 proxy.
16
- *
17
- * Responsibilities:
18
- * - transformRequest: OpenCode -> Gemini normalized request (contents, system, tools, genConfig)
19
- * - buildAntigravityRequest / buildGeminiCLIRequest: wraps normalized request into
20
- * cloudcode-pa envelope with deterministic session_id / user_prompt_id (FNV-1a),
21
- * endpoint cascade, fingerprint headers, and x-goog-user-project stripping
22
- * - schema cleaning: tolerant Gemini-shaping cleanJsonSchema plus the strict
23
- * allowlist cleanJsonSchemaStrict / cleanToolSchemaTolerant family
24
- * - tool name validation, sanitization and deduplication (two parallel
25
- * families: validateToolNames and validateToolNamesDetailed)
26
- * - message normalization: normalizeMessages and normalizeIncomingMessages
27
- * - thinking level parsing, budget maps, family-aware budgets and variant hints
28
- * - deterministic id builders over FNV-1a 32/64-bit digests
29
- * - model classification (isGeminiCLIOnlyModel, isLikelyAntigravityOnlyModel,
30
- * variant extraction) and the Gemini CLI bypass constants
31
- * - google_search injection when enabled; cascade fetch with retry
32
- *
33
- * Architecture governance:
34
- * - Date: 25/08/2026 — Canto do Buriti, Piauí, Brasil
35
- * - Library-first, root-first: file lives beside its siblings (no src/ nesting)
36
- * - Only node:* builtins + global fetch (Node >=18) — zero external deps
37
- * - Direct cloudcode-pa usage: https://cloudcode-pa.googleapis.com,
38
- * https://daily-cloudcode-pa.googleapis.com,
39
- * https://daily-cloudcode-pa.sandbox.googleapis.com
40
- * - No localhost v1 base-url proxy (requisito explícito)
41
- * - Deterministic IDs via FNV-1a (32/64-bit) — reproducible per conversation
42
- * - Strip x-goog-user-project header to avoid 403 IAM (issue pi-mono #1830)
43
- * - Skip sandbox for gemini-cli models to avoid 404/403 cascade (#233)
44
- *
45
- * v2.1.14 merge notes (request.ts + request-helpers.ts -> request.ts):
46
- * - Identical duplicated symbols collapsed to a single definition.
47
- * - Divergent duplicates resolved toward the more defensive variant; the
48
- * losing variant survives under a parallel export whenever its behavior
49
- * was not equivalent:
50
- * cleanJsonSchemaStrict <- request-helpers cleanJsonSchema (strict allowlist)
51
- * cleanToolSchemaTolerant <- request-helpers cleanToolSchema (tolerant normalizer)
52
- * validateToolNamesDetailed <- request-helpers validateToolNames (rich validator)
53
- * buildGenerationConfigFromRequest <- request.ts buildGenerationConfig (request-shaped)
54
- * - Canonical fnv1a32 hashes UTF-16 code units (charCodeAt), matching the
55
- * repo-wide implementation in core.ts; the UTF-8 byte variant that lived
56
- * only in request-helpers.ts was dropped as the outlier.
57
- * - Canonical TOOL_NAME_REGEX is the letter-start + 64-cap pattern shared
58
- * with core.ts (TOOL_REGEX); the underscore-start variant was dropped.
59
- * - Canonical generateSessionId/generateUserPromptId are the validating
60
- * versions (throw RequestHelpersError on empty seed).
61
- * - The RequestHelpers barrel is re-exported from this module; the default
62
- * export remains RequestPipeline.
63
- *
64
- * @author devthink
65
- * @license MIT
66
- * @version 2.1.16
67
- */
68
- import { fnv1a32, fnv1a32Hex, isRetryableStatus } from "./core.js";
69
- export declare const TOOL_NAME_MAX_LENGTH: 64;
70
- export declare const TOOL_NAME_MIN_LENGTH: 1;
71
- export declare const THINKING_LEVEL_TO_BUDGET_GEMINI: Record<string, number>;
72
- export declare const THINKING_LEVEL_TO_BUDGET_CLAUDE: Record<string, number>;
73
- /**
74
- * Thinking budget ceiling shared by the clamp paths. v2.1.16: the value
75
- * (64000) is byte-identical to models.ts THINKING_BUDGET_MAX_CLAUDE — the
76
- * thinking-table owner — so this export now aliases that import instead of
77
- * repeating the literal.
78
- */
79
- export declare const THINKING_BUDGET_MAX: 64000;
80
- export declare const THINKING_BUDGET_MIN: 1024;
81
- export { GEMINI_CLI_OAUTH_CLIENT_ID as GEMINI_CLI_CLIENT_ID } from "./constants.js";
82
- export { GEMINI_CLI_OAUTH_CLIENT_SECRET as GEMINI_CLI_CLIENT_SECRET } from "./constants.js";
83
- import { getFingerprintHeaders } from "./fingerprint.js";
84
- import { getEndpointsForModel, isGeminiCLIOnlyModel } from "./models.js";
85
- import type { ThinkingLevel } from "./models.js";
86
- export { ENDPOINT_ORDER_ANTIGRAVITY, ENDPOINT_ORDER_GEMINI_CLI, GEMINI_CLI_ONLY_MODELS, SEARCH_MODEL, SEARCH_MODEL_PREVIEW, THINKING_BUDGET_MAP, THINKING_BUDGET_MAX_CLAUDE, THINKING_BUDGET_MAX_GEMINI, THINKING_LEVELS, getEndpointsForModel, isGeminiCLIOnlyModel, } from "./models.js";
87
- export type { ThinkingLevel } from "./models.js";
88
- /** Historical request-module alias of the models.ts owner list. */
89
- export { FETCH_AVAILABLE_MODELS_2026 as MODELS_2026 } from "./models.js";
90
- /**
91
- * Official cloudcode-pa endpoints — prod is authoritative in 2026,
92
- * daily and sandbox are rollout / canary fallbacks.
93
- * Third-person: observer copies order from Antigravity Manager binary.
94
- */
95
- /** Default cascade order for Antigravity pool (re-exported from models.ts above). */
96
- /** Stream endpoint suffix used by Antigravity */
97
- /** Antigravity version fallback — governance requires 1.19.2 (bypass ban <1.15.8) */
98
- /** Fallback project id */
99
- /** FNV-1a constants — 32-bit */
100
- /** Forbidden headers stripped case-insensitively — observer notes AM never sends them on content */
101
- /**
102
- * OpenCode function tool — accepts OpenAI, Anthropic, or Gemini pre-shaped.
103
- */
104
- export type OpenCodeTool = {
105
- type: "function";
106
- function: {
107
- name: string;
108
- description?: string;
109
- parameters?: any;
110
- };
111
- } | {
112
- name: string;
113
- description?: string;
114
- input_schema?: any;
115
- inputSchema?: any;
116
- parameters?: any;
117
- [k: string]: any;
118
- } | {
119
- functionDeclarations: Array<{
120
- name: string;
121
- description?: string;
122
- parameters?: any;
123
- }>;
124
- };
125
- export interface TransformRequestInput {
126
- /** Model id, e.g. gemini-3-flash-preview or claude-opus-4-6-thinking-low */
127
- model: string;
128
- /** Message history in OpenCode format */
129
- messages: OpenCodeMessage[];
130
- /** Optional tools — OpenAI / Anthropic / Gemini shapes tolerated */
131
- tools?: OpenCodeTool[] | any[];
132
- /** Optional system instruction as string or array of texts */
133
- system?: string | string[] | null;
134
- /** Optional thinking level minimal|low|medium|high|max — maps to budget */
135
- thinkingLevel?: ThinkingLevel | string;
136
- /** Optional explicit thinking budget — overrides level map */
137
- thinkingBudget?: number;
138
- /** Whether to inject google_search grounding tool */
139
- googleSearchEnabled?: boolean;
140
- /** Optional generationConfig passthrough (temperature, maxTokens, etc) */
141
- generationConfig?: Record<string, any>;
142
- /** Optional seed for deterministic session_id — defaults to hash of messages+model */
143
- sessionSeed?: string;
144
- /** Optional seed for user_prompt_id — defaults to last user message */
145
- userPromptSeed?: string;
146
- /** Optional projectId — not used in transformRequest but kept for symmetry */
147
- projectId?: string;
148
- }
149
- /**
150
- * Gemini content part.
151
- * v2.1.14 merge: unions the request.ts declaration (thought/thoughtSignature)
152
- * with the request-helpers.ts declaration (fileData plus the explicit
153
- * GeminiFunctionCall/GeminiFunctionResponse sub-shapes).
154
- */
155
- export interface GeminiPart {
156
- text?: string;
157
- thought?: boolean;
158
- thoughtSignature?: string;
159
- inlineData?: {
160
- mimeType: string;
161
- data: string;
162
- };
163
- fileData?: {
164
- mimeType: string;
165
- fileUri: string;
166
- };
167
- functionCall?: GeminiFunctionCall;
168
- functionResponse?: GeminiFunctionResponse;
169
- [k: string]: unknown;
170
- }
171
- /**
172
- * Gemini content turn.
173
- * v2.1.14 merge: keeps the "system" role from request.ts alongside the
174
- * user/model pair used by both halves.
175
- */
176
- export interface OpenCodeMessage {
177
- role: "system" | "user" | "assistant" | "tool" | "model" | string;
178
- content?: string | any[] | null;
179
- tool_calls?: Array<{
180
- id: string;
181
- type?: string;
182
- function: {
183
- name: string;
184
- arguments: string | object;
185
- };
186
- }>;
187
- tool_call_id?: string;
188
- name?: string;
189
- thinking?: string;
190
- signature?: string;
191
- [k: string]: any;
192
- }
193
- export interface GeminiContent {
194
- role: "user" | "model" | "system";
195
- parts: GeminiPart[];
196
- }
197
- /** System instruction content shape (live pipeline lineage). */
198
- export type GeminiSystem = {
199
- parts: GeminiPart[];
200
- } | undefined;
201
- export interface GeminiTool {
202
- functionDeclarations?: Array<{
203
- name: string;
204
- description?: string;
205
- parameters?: any;
206
- }>;
207
- }
208
- export interface TransformedRequest {
209
- /** Normalized model id stripped of antigravity- prefix for routing but original preserved */
210
- model: string;
211
- /** Original model string exactly as user provided */
212
- originalModel: string;
213
- /** Gemini contents array ready for cloudcode-pa */
214
- contents: GeminiContent[];
215
- /** System instruction aggregated */
216
- systemInstruction?: {
217
- role: "system";
218
- parts: GeminiPart[];
219
- } | null;
220
- /** Tools normalized to Gemini functionDeclarations */
221
- tools?: GeminiTool[] | null;
222
- /** Generation config with thinking budget mapped if provided */
223
- generationConfig?: Record<string, any> | null;
224
- /** Deterministic session_id via FNV-1a */
225
- sessionId: string;
226
- /** Deterministic user_prompt_id via FNV-1a */
227
- userPromptId: string;
228
- /** Thinking budget resolved */
229
- thinkingBudget?: number;
230
- /** Thinking level resolved */
231
- thinkingLevel?: ThinkingLevel;
232
- }
233
- export declare const ALLOWED_SCHEMA_KEYS: Set<string>;
234
- export declare const MAX_TOOLS_PER_REQUEST: 128;
235
- /** Allowed top-level keys of a tool definition after cleaning. */
236
- export declare const ALLOWED_TOOL_TOP_KEYS: readonly ["name", "description", "parameters"];
237
- /** Direct production cloudcode-pa endpoint — bypasses any localhost proxy. */
238
- export declare const DIRECT_ENDPOINT: "https://cloudcode-pa.googleapis.com";
239
- /** Daily (canary) cloudcode-pa endpoint. */
240
- export declare const DAILY_ENDPOINT: "https://daily-cloudcode-pa.googleapis.com";
241
- /** Autopush sandbox endpoint. */
242
- export declare const AUTOPUSH_ENDPOINT: "https://autopush-cloudcode-pa.sandbox.googleapis.com";
243
- /** Cascade order used by the observer when retrying endpoints. */
244
- export declare const ENDPOINT_CASCADE: readonly ["https://daily-cloudcode-pa.googleapis.com", "https://autopush-cloudcode-pa.sandbox.googleapis.com", "https://cloudcode-pa.googleapis.com"];
245
- /**
246
- * Headers stripped before sending to avoid 403 IAM (pi-mono #1830); Antigravity
247
- * Manager never sends these on content requests.
248
- */
249
- /**
250
- * Thrown when transformRequest cannot normalize input.
251
- */
252
- export declare class RequestTransformationError extends Error {
253
- readonly code: string;
254
- constructor(message: string, code?: string);
255
- }
256
- /**
257
- * Domain error for the merged observer helpers. Thrown instead of generic Error
258
- * so callers can distinguish cleaning/normalization failures from transport.
259
- */
260
- export declare class RequestHelpersError extends Error {
261
- readonly code: string;
262
- constructor(message: string, code?: string, cause?: unknown);
263
- }
264
- /**
265
- * Computes FNV-1a 32-bit hash.
266
- * Third-person: observer notes this hash is fast, no crypto deps, deterministic.
267
- *
268
- * @param input - string to hash
269
- * @returns unsigned 32-bit integer
270
- */
271
- /**
272
- * Generates hex string padded to 8 chars from FNV-1a.
273
- *
274
- * @param input - seed
275
- * @returns 8-char hex
276
- */
277
- /**
278
- * Returns the FNV-1a 32-bit digest of input padded to 8 hex chars.
279
- *
280
- * @param input - seed string
281
- */
282
- export declare function fnv1aHex(input: string): string;
283
- /**
284
- * Returns a 16-char hex digest from two independent FNV-1a rounds, used when
285
- * longer session ids are needed without reaching for crypto randomness.
286
- *
287
- * @param input - seed string
288
- */
289
- export declare function fnv1aHex16(input: string): string;
290
- /**
291
- * Alias kept for fingerprint.ts compatibility.
292
- */
293
- export declare const fnv1aHash: typeof fnv1a32;
294
- /**
295
- * Normalizes model id — trims, lowercases for detection, preserves original case for request.
296
- * Also strips antigravity- prefix for internal detection but keeps original model field elsewhere.
297
- *
298
- * @param modelId - raw model string
299
- * @returns object with base, original, normalized
300
- */
301
- export declare function parseModelId(modelId: string): {
302
- original: string;
303
- normalized: string;
304
- base: string;
305
- variantSuffixes: string[];
306
- };
307
- /**
308
- * Detecta se modelo só funciona via endpoint Antigravity (cloudcode-pa v1internal)
309
- * e não via genai público. Heurística baseada em prefixos e sufixos.
310
- *
311
- * @param modelId - ID do modelo (ex: "antigravity-claude-opus-4-6-thinking")
312
- * @returns true se provavelmente só funciona em Antigravity
313
- *
314
- * Regras:
315
- * - qualquer modelo começando com antigravity- => true
316
- * - contém "claude" => true (Claude só via bypass Antigravity)
317
- * - contém "customtools" => true (customtools é feature Antigravity 2026)
318
- * - está no set ANTIGRAVITY_ONLY_EXACT
319
- * - contém "rising-fact" ou "unwritten-orb" etc? Não, esses são projects, não modelos
320
- */
321
- export declare function isLikelyAntigravityOnlyModel(modelId: string): boolean;
322
- export interface ExtractVariantsResult {
323
- input: string;
324
- base: string;
325
- isAntigravity: boolean;
326
- isThinking: boolean;
327
- isCustomTools: boolean;
328
- isPreview: boolean;
329
- family: string;
330
- variants: string[];
331
- candidatesInCatalog: string[];
332
- relatedModels: Array<{
333
- id: string;
334
- inCatalog: boolean;
335
- }>;
336
- }
337
- /**
338
- * Extrai variantes de um modelId, removendo prefixos/sufixos e gerando candidatos.
339
- *
340
- * Ex: "antigravity-claude-opus-4-6-thinking" =>
341
- * base: "claude-opus-4-6"
342
- * variants: ["antigravity-claude-opus-4-6-thinking", "antigravity-claude-opus-4-6", "claude-opus-4-6-thinking", "claude-opus-4-6", ...]
343
- */
344
- export declare function extractVariants(modelId: string): ExtractVariantsResult;
345
- /**
346
- * Helper que extrai variantes de lista ou objeto
347
- */
348
- export declare function extractVariantsFromAny(input: unknown): ExtractVariantsResult[];
349
- /**
350
- * Detailed model variant extraction result used for routing and budgets.
351
- */
352
- export interface ModelVariantInfo {
353
- original: string;
354
- normalized: string;
355
- base: string;
356
- family: "gemini" | "claude" | "unknown";
357
- isPreview: boolean;
358
- isThinking: boolean;
359
- thinkingVariant: "low" | "max" | null;
360
- isCustomTools: boolean;
361
- isClaude: boolean;
362
- isGemini: boolean;
363
- isAntigravityWrapper: boolean;
364
- budgetHint?: number | undefined;
365
- group: "antigravity" | "gemini-cli";
366
- }
367
- /**
368
- * Extracts routing/budget metadata from a model id: family detection, preview
369
- * and customtools flags, thinking-low/max variant, antigravity wrapper and the
370
- * suggested quota group.
371
- *
372
- * @param modelId - raw model id
373
- * @throws {RequestHelpersError} when modelId is empty
374
- */
375
- export declare function extractModelVariant(modelId: string): ModelVariantInfo;
376
- /**
377
- * Checklist alias of {@link extractModelVariant}.
378
- */
379
- export declare const parseModelVariant: typeof extractModelVariant;
380
- /**
381
- * Builds dynamic User-Agent antigravity/{version} {os}/{arch}.
382
- * Third-person observer copies AM behavior to bypass ban on 1.11.5.
383
- *
384
- * @param version - optional semver
385
- */
386
- export declare function buildDynamicUserAgent(version?: string): string;
387
- /**
388
- * Builds Client-Metadata header.
389
- *
390
- * @param version - optional version
391
- */
392
- /**
393
- * Builds X-Goog-Api-Client header — only for gemini-cli mode.
394
- *
395
- * @param version - optional
396
- */
397
- export declare function buildApiClient(version?: string): string;
398
- /**
399
- * Generates fingerprint headers for given style.
400
- * Observer knows:
401
- * - AM only sends User-Agent on content requests (not on onboard/load)
402
- * - Never sends X-Goog-QuotaUser nor X-Client-Device-Id
403
- * - Gemini CLI includes X-Goog-Api-Client
404
- *
405
- * @param style - 'antigravity' or 'gemini-cli'
406
- * @param version - optional antigravity version
407
- * @returns headers record
408
- */
409
- /**
410
- * Alias required by checklist naming: strip x-goog-user-project header explicit.
411
- *
412
- * @param headers - headers map
413
- * @returns cleaned map
414
- */
415
- export declare function stripXGoogUserProjectHeader(headers: Record<string, string>): Record<string, string>;
416
- /**
417
- * Checks whether an HTTP status should trigger cascade retry:
418
- * 429, 403, 404 and the whole 5xx range.
419
- *
420
- * @param status - HTTP status code
421
- */
422
- /**
423
- * Recursively cleans a JSON Schema node down to only the keys listed in
424
- * {@link ALLOWED_SCHEMA_KEYS}. This removes $schema/$ref/title/
425
- * additionalProperties/default/examples and similar unknown names that trigger
426
- * "Invalid JSON payload Unknown name" errors upstream.
427
- *
428
- * v2.1.14 merge note: renamed from cleanJsonSchema (request-helpers.ts) to
429
- * cleanJsonSchemaStrict; the tolerant Gemini-shaping normalizer from
430
- * request.ts owns the cleanJsonSchema name. ALLOWED_SCHEMA_KEYS is now the
431
- * full allowlist Set from request.ts; the switch below still only emits the
432
- * six core keys, so the observable behavior of this strict cleaner is
433
- * unchanged by the merge.
434
- *
435
- * @param schema - raw schema node
436
- * @param depth - recursion guard, throws past depth 12
437
- * @returns cleaned schema object or undefined when not salvageable
438
- * @throws {RequestHelpersError} when depth exceeds 12 (possible circular schema)
439
- */
440
- export declare function cleanJsonSchemaStrict(schema: unknown, depth?: number): Record<string, unknown> | undefined;
441
- /**
442
- * Cleaned tool definition compatible with Gemini functionDeclarations.
443
- */
444
- export interface CleanedTool {
445
- name: string;
446
- description?: string | undefined;
447
- parameters: {
448
- type: "object";
449
- properties: Record<string, unknown>;
450
- required?: string[] | undefined;
451
- description?: string | undefined;
452
- };
453
- }
454
- /**
455
- * Cleans a single raw tool definition (OpenAI wrapper, Anthropic input_schema
456
- * or plain parameters) into a {@link CleanedTool} with a sanitized name and a
457
- * root-object schema enforced.
458
- *
459
- * v2.1.14 merge note: keeps its name; it now builds on
460
- * cleanJsonSchemaStrict (the strict cleaner formerly exported as the
461
- * request-helpers cleanJsonSchema).
462
- *
463
- * @param raw - raw tool definition
464
- * @throws {RequestHelpersError} on missing/invalid objects or names
465
- */
466
- export declare function cleanRawToolSchema(raw: unknown): CleanedTool;
467
- /**
468
- * Cleans an array of raw tools into deduplicated {@link CleanedTool} entries
469
- * (last wins per sanitized name), capped at {@link MAX_TOOLS_PER_REQUEST}.
470
- * Invalid tools are skipped rather than failing the request.
471
- *
472
- * @param tools - array of raw tool definitions
473
- * @throws {RequestHelpersError} when input is not an array
474
- */
475
- export declare function cleanToolsArray(tools: unknown): CleanedTool[];
476
- /**
477
- * Maps a thinking block to Gemini thought part.
478
- * For Gemini 3 and Claude via Antigravity, thought parts must have thought: true.
479
- * Optionally includes thoughtSignature for multi-turn preservation.
480
- *
481
- * @param text - thinking text
482
- * @param signature - optional signature for LRU cache in streaming.ts
483
- * @returns GeminiPart
484
- */
485
- export declare function mapThinkingBlock(text: string, signature?: string): GeminiPart;
486
- /**
487
- * Sorts parts so that thought parts come first, then text, then function calls.
488
- * Required because Gemini/Claude require thinking block order validation.
489
- *
490
- * @param parts - parts array
491
- * @returns sorted parts
492
- */
493
- export declare function sortThoughtFirst(parts: GeminiPart[]): GeminiPart[];
494
- /**
495
- * Filters and normalizes thinking content — removes empty thinking and ensures
496
- * signature preservation.
497
- *
498
- * @param parts - incoming parts
499
- * @returns filtered parts
500
- */
501
- export declare function filterAndMapThinkingParts(parts: any[]): GeminiPart[];
502
- /**
503
- * Detects thinking blocks that must be filtered before dispatch: thought flags,
504
- * type discriminators, reasoning_content/reasoning fields.
505
- *
506
- * @param block - any part-like object
507
- */
508
- export declare function isThinkingBlock(block: unknown): boolean;
509
- /**
510
- * Filters thinking blocks from a parts array.
511
- *
512
- * @param parts - array of parts in any shape
513
- * @throws {RequestHelpersError} when input is not an array
514
- */
515
- export declare function filterThinkingBlocksFromParts(parts: unknown): GeminiPart[];
516
- /**
517
- * Filters thinking parts inside each Gemini message, dropping messages that
518
- * become empty (including system).
519
- *
520
- * @param messages - Gemini-shaped messages
521
- * @throws {RequestHelpersError} when input is not an array
522
- */
523
- export declare function filterThinkingBlocksFromMessages(messages: unknown): GeminiMessage[];
524
- /**
525
- * Auto-detecting filter: routes message arrays (role+parts items) to
526
- * {@link filterThinkingBlocksFromMessages} and everything else to
527
- * {@link filterThinkingBlocksFromParts}.
528
- *
529
- * Named `filterThinkingBlocksAuto` because the historical overloaded
530
- * `filterThinkingBlocks` keeps its original tag-stripping/string semantics.
531
- *
532
- * @param input - parts array or messages array
533
- * @throws {RequestHelpersError} when input is not an array
534
- */
535
- export declare function filterThinkingBlocksAuto(input: unknown): unknown[];
536
- export interface ThoughtLikePart {
537
- thought?: boolean;
538
- thinking?: boolean;
539
- type?: string;
540
- text?: string;
541
- content?: string;
542
- reasoning?: string;
543
- [k: string]: unknown;
544
- }
545
- export declare function filterThinkingBlocks(input: string): string;
546
- export declare function filterThinkingBlocks<T extends ThoughtLikePart>(input: T[]): T[];
547
- export declare function filterThinkingBlocks(input: unknown): unknown;
548
- /**
549
- * Definition for google_search built-in grounding tool wrapped as function declaration
550
- * for compatibility with OpenCode → Gemini flow.
551
- * Observer notes: original plugin shekohex uses wrapper to call separate search API.
552
- */
553
- export declare const GOOGLE_SEARCH_FUNCTION_DECLARATION: {
554
- readonly name: "google_search";
555
- readonly description: "Search the web for real-time information, factual grounding, current events, documentation, and recent knowledge. Use when user asks for latest information, news, or requires browsing to answer.";
556
- readonly parameters: {
557
- readonly type: "OBJECT";
558
- readonly properties: {
559
- readonly query: {
560
- readonly type: "STRING";
561
- readonly description: "Search query string, 3-10 words focused keywords";
562
- };
563
- };
564
- readonly required: readonly ["query"];
565
- };
566
- };
567
- export declare const URL_CONTEXT_FUNCTION_DECLARATION: {
568
- readonly name: "url_context";
569
- readonly description: "Fetch and provide context from a URL for grounding.";
570
- readonly parameters: {
571
- readonly type: "OBJECT";
572
- readonly properties: {
573
- readonly url: {
574
- readonly type: "STRING";
575
- readonly description: "HTTP(S) URL to fetch";
576
- };
577
- };
578
- readonly required: readonly ["url"];
579
- };
580
- };
581
- /**
582
- * Injects google_search tool into declarations if enabled and not already present.
583
- *
584
- * @param declarations - existing declarations array
585
- * @param enabled - whether injection enabled
586
- * @param includeUrlContext - whether to also inject url_context
587
- * @returns new declarations array with injection
588
- */
589
- export declare function injectGoogleSearchTool(declarations: Array<{
590
- name: string;
591
- description?: string;
592
- parameters?: any;
593
- originalName: string;
594
- }>, enabled?: boolean, includeUrlContext?: boolean): Array<{
595
- name: string;
596
- description?: string;
597
- parameters?: any;
598
- originalName: string;
599
- }>;
600
- /**
601
- * Parses OpenAI tool arguments which may be stringified JSON.
602
- *
603
- * @param args - args string or object
604
- * @returns parsed object
605
- */
606
- export declare function parseFunctionArgs(args: string | object | any): Record<string, any>;
607
- /**
608
- * Attempts to extract last user prompt text for deterministic user_prompt_id.
609
- *
610
- * @param messages - messages array
611
- * @returns last user text or fallback
612
- */
613
- export declare function extractLastUserPrompt(messages: OpenCodeMessage[]): string;
614
- export interface OpenCodeContentPart {
615
- type?: string;
616
- text?: string;
617
- image_url?: {
618
- url: string;
619
- detail?: string;
620
- };
621
- id?: string;
622
- tool_call_id?: string;
623
- name?: string;
624
- function?: {
625
- name: string;
626
- arguments: string | object;
627
- };
628
- [k: string]: unknown;
629
- }
630
- export interface OpenCodeToolCall {
631
- id: string;
632
- type: "function";
633
- function: {
634
- name: string;
635
- arguments: string | object;
636
- };
637
- }
638
- export interface GeminiFunctionCall {
639
- name: string;
640
- args: Record<string, unknown>;
641
- }
642
- export interface GeminiFunctionResponse {
643
- name: string;
644
- response: Record<string, unknown>;
645
- }
646
- export interface NormalizedMessagesResult {
647
- systemInstruction?: GeminiSystemInstruction;
648
- contents: GeminiContent[];
649
- /** mensagens originais ignoradas por serem vazias */
650
- droppedCount: number;
651
- }
652
- /**
653
- * Normaliza lista de mensagens OpenCode (OpenAI-like) para formato Gemini
654
- * Cloud Code Assist v1internal.
655
- *
656
- * - system => systemInstruction (combinado)
657
- * - user => role user
658
- * - assistant => role model, com functionCall se tiver tool_calls
659
- * - tool => role user com functionResponse
660
- * - filtra thinking blocks automaticamente
661
- * - merge mensagens consecutivas de mesmo role
662
- *
663
- * @param messages - mensagens OpenCode
664
- * @param opts - includeSystemAsUser? Se true, system vai como user prefixado
665
- */
666
- export declare function normalizeMessages(messages: OpenCodeMessage[], opts?: {
667
- mergeConsecutive?: boolean;
668
- includeSystemAsUser?: boolean;
669
- filterThinking?: boolean;
670
- }): NormalizedMessagesResult;
671
- /**
672
- * Normalizes any role spelling onto the Gemini system/user/model triad.
673
- * Tool-ish roles map to user because Cloud Code Assist expects
674
- * functionResponse parts inside a user turn.
675
- *
676
- * @param rawRole - incoming role string
677
- */
678
- export declare function normalizeRole(rawRole: string): "system" | "user" | "model";
679
- /**
680
- * Normalizes one content element (string, block array or object) into Gemini
681
- * parts. Skips thinking blocks, degrades images to markers and converts
682
- * tool_use/tool_result blocks into functionCall/functionResponse parts.
683
- *
684
- * @param content - incoming content of any shape
685
- */
686
- export declare function normalizeContentToParts(content: unknown): GeminiPart[];
687
- /**
688
- * Gemini message with normalized role plus raw-role provenance.
689
- */
690
- export interface GeminiMessage {
691
- role: "system" | "user" | "model";
692
- parts: GeminiPart[];
693
- _rawRole?: string;
694
- }
695
- /**
696
- * Generic incoming OpenCode / OpenAI / Anthropic message shape.
697
- */
698
- export interface IncomingMessage {
699
- role: string;
700
- content?: string | unknown[] | Record<string, unknown> | null;
701
- name?: string;
702
- tool_calls?: Array<{
703
- id?: string;
704
- type?: string;
705
- function?: {
706
- name: string;
707
- arguments?: string | Record<string, unknown>;
708
- };
709
- }>;
710
- tool_call_id?: string;
711
- tool_use_id?: string;
712
- [k: string]: unknown;
713
- }
714
- /**
715
- * Normalizes incoming OpenCode / OpenAI / Anthropic messages into Gemini
716
- * messages: role mapping via normalizeRole, content via normalizeContentToParts,
717
- * OpenAI tool_calls converted to functionCall parts, thinking blocks filtered,
718
- * consecutive same-role messages merged (except system).
719
- *
720
- * Named `normalizeIncomingMessages` because the historical `normalizeMessages`
721
- * keeps its original signature in this module.
722
- *
723
- * @param messages - array of incoming messages of any shape
724
- * @throws {RequestHelpersError} when input is not an array
725
- */
726
- export declare function normalizeIncomingMessages(messages: unknown): GeminiMessage[];
727
- export interface EnhancedAgyError {
728
- message: string;
729
- code?: string | undefined;
730
- status?: number | undefined;
731
- statusText?: string | undefined;
732
- details?: unknown | undefined;
733
- isRetryable: boolean;
734
- isAuthError: boolean;
735
- isQuotaError: boolean;
736
- isModelError: boolean;
737
- isThinkingBudgetError: boolean;
738
- original: unknown;
739
- suggestion?: string | undefined;
740
- requestId?: string | undefined;
741
- modelId?: string | undefined;
742
- }
743
- /**
744
- * Enriquece erro vindo do Agentic SDK / Cloud Code Assist.
745
- * Detecta auth, quota, model not found, thinking budget etc e sugere correção.
746
- *
747
- * @param error - erro bruto (Error, Response, objeto, string)
748
- * @param context - contexto opcional com modelId, requestId etc
749
- */
750
- export declare function enhanceAgySdkErrorResponse(error: unknown, context?: {
751
- modelId?: string;
752
- requestId?: string;
753
- }): EnhancedAgyError;
754
- /**
755
- * Transforms OpenCode request (OpenAI/Anthropic mixed) into Gemini/Antigravity
756
- * normalized request ready for cloudcode-pa envelope.
757
- *
758
- * Steps performed by third-person observer:
759
- * - Validates model, messages
760
- * - Parses model variant to extract thinkingLevel/budget
761
- * - Aggregates system instructions
762
- * - Normalizes contents: user ↔ model, maps thinking blocks first,
763
- * handles tool_use/tool_result pairing, handles OpenAI tool_calls
764
- * - Cleans tool schemas, sanitizes tool names, ensures uniqueness
765
- * - Injects google_search tool when enabled
766
- * - Generates deterministic session_id and user_prompt_id via FNV-1a
767
- * - Builds generationConfig with thinking budget if applicable
768
- * - Supports 2026 models aliasing
769
- *
770
- * @param input - transform input
771
- * @returns transformed request
772
- * @throws RequestTransformationError on invalid input
773
- */
774
- /** X-Goog-Api-Client value observed on real Gemini CLI traffic. */
775
- /** Client metadata object injected by Gemini CLI for bypass requests. */
776
- /** Fallback project id when no cloud project is resolved. */
777
- /** Production Cloud Code Assist base endpoint. */
778
- /** Daily (canary) Cloud Code Assist base endpoint — default for pure Gemini CLI bypass. */
779
- /** v1internal method suffixes observed on Cloud Code Assist traffic.
780
- * v2.1.15 Phase A: renamed from the historical local name
781
- * CODE_ASSIST_ENDPOINTS (a method-path map) so the host-map semantic of that
782
- * name resolves to the models.ts owner; re-exported below for surface
783
- * continuity. */
784
- export declare const CODE_ASSIST_METHOD_PATHS: {
785
- readonly GENERATE: "/v1internal:generateContent";
786
- readonly STREAM_GENERATE: "/v1internal:streamGenerateContent";
787
- readonly LOAD: "/v1internal:loadCodeAssist";
788
- };
789
- /** Cloud Code Assist HOST map (canonical owner: models.ts).
790
- * @deprecated legacy alias kept for the historical request-module surface. */
791
- export { CODE_ASSIST_ENDPOINTS } from "./models.js";
792
- /**
793
- * Computes FNV-1a 64-bit hash over UTF-8 bytes.
794
- * Complements the 32-bit variant when longer deterministic digests are needed.
795
- *
796
- * @param input - string to hash
797
- * @returns unsigned 64-bit integer as bigint
798
- */
799
- export declare function fnv1a64BigInt(input: string): bigint;
800
- /**
801
- * Options controlling {@link buildUserPromptId} output shape.
802
- */
803
- export interface BuildPromptIdOptions {
804
- /** Custom prefix, defaults to "agyp_". */
805
- prefix?: string;
806
- /** Extra seed for disambiguation, e.g. projectId or sessionId. */
807
- seed?: string;
808
- /** Include timestamp? Breaks determinism, discouraged but supported. */
809
- includeTimestamp?: boolean;
810
- /** Hash length: "short" yields 8 hex chars, "long" adds a 12-char 64-bit suffix. */
811
- length?: "short" | "long";
812
- }
813
- /**
814
- * Generates a deterministic session_id via FNV-1a over the working directory.
815
- * Same directory implies same session_id, which keeps fingerprints stable.
816
- *
817
- * @param directory - optional directory; falls back to cwd, then home dir
818
- * @returns session id like `sess_1a2b3c4d5e6f7a8b9c0d`
819
- */
820
- export declare function buildSessionIdFromDir(directory?: string | null): string;
821
- /**
822
- * Generates a deterministic user_prompt_id via FNV-1a.
823
- * Used by the Cloud Code backend for deduplication.
824
- *
825
- * @param input - prompt content; objects are JSON.stringify-ed; omitted input
826
- * falls back to hostname|cwd|pid for per-workspace stability
827
- * @param opts - options object or bare seed string
828
- * @returns id like `agyp_1a2b3c4d` or `agyp_1a2b3c4d-9f8e7d6c5b4a`
829
- */
830
- export declare function buildUserPromptId(input?: string | object | null | undefined, opts?: BuildPromptIdOptions | string): string;
831
- /**
832
- * Compatibility alias for fingerprint.ts: derives the session id from a directory.
833
- * Kept alongside {@link generateSessionId}, which hashes an arbitrary seed instead.
834
- *
835
- * @param directory - optional directory path
836
- * @returns deterministic session id
837
- */
838
- export declare function buildSessionId(directory?: string): string;
839
- /**
840
- * Normalizes free-form thinking input (string, options object, or message field)
841
- * into a canonical level. Unknown values collapse to "medium"; explicit
842
- * none/off inputs yield "none".
843
- *
844
- * @param input - raw thinking spec
845
- * @returns canonical level including "none"
846
- */
847
- export declare function normalizeThinkingLevel(input: unknown): ThinkingLevel | "none";
848
- /**
849
- * Parses free-form input into a canonical thinking level. Also maps
850
- * none/off onto minimal for compatibility.
851
- *
852
- * @param input - level-like value
853
- * @returns canonical level or undefined when not parseable
854
- */
855
- export declare function parseThinkingLevel(input: unknown): ThinkingLevel | undefined;
856
- /**
857
- * Maps a thinking level (or numeric budget) onto its token budget, clamping
858
- * numbers into [THINKING_BUDGET_MIN, THINKING_BUDGET_MAX]. Unknown named levels
859
- * safely fall back to medium.
860
- *
861
- * @param level - level name, numeric budget or numeric string
862
- * @throws {RequestHelpersError} on non-finite numbers or empty strings
863
- */
864
- export declare function mapThinkingLevelToBudget(level: string | number): number;
865
- /**
866
- * Spec-required alias of {@link mapThinkingLevelToBudget}.
867
- */
868
- export declare const thinkingLevelToBudget: typeof mapThinkingLevelToBudget;
869
- /**
870
- * Budget hint for a parsed variant suffix.
871
- *
872
- * @param variant - "low", "max" or null
873
- */
874
- export declare function getThinkingBudgetForVariant(variant: "low" | "max" | null): number;
875
- /**
876
- * Anthropic/OpenAI-style content block tolerated inside OpenCode messages.
877
- */
878
- export interface OpenCodeContentBlock {
879
- type?: string;
880
- text?: string;
881
- thinking?: string;
882
- level?: ThinkingLevel | string;
883
- thought?: string;
884
- id?: string;
885
- name?: string;
886
- input?: unknown;
887
- args?: unknown;
888
- tool_use_id?: string;
889
- tool_call_id?: string;
890
- content?: unknown;
891
- source?: {
892
- type?: string;
893
- media_type?: string;
894
- data?: string;
895
- };
896
- [key: string]: unknown;
897
- }
898
- /**
899
- * Full OpenCode request envelope with thinking/search/session passthrough fields.
900
- */
901
- export interface OpenCodeRequest {
902
- model?: string;
903
- messages?: OpenCodeMessage[];
904
- tools?: OpenCodeTool[];
905
- tool_choice?: unknown;
906
- thinking?: ThinkingLevel | string | {
907
- level?: ThinkingLevel | string;
908
- budget?: number;
909
- type?: string;
910
- budget_tokens?: number;
911
- };
912
- thinkingLevel?: ThinkingLevel | string;
913
- thinking_level?: ThinkingLevel | string;
914
- directory?: string;
915
- cwd?: string;
916
- project?: string;
917
- projectId?: string;
918
- temperature?: number;
919
- top_p?: number;
920
- topP?: number;
921
- top_k?: number;
922
- topK?: number;
923
- max_tokens?: number;
924
- maxTokens?: number;
925
- google_search?: boolean;
926
- enable_google_search?: boolean;
927
- enableGoogleSearch?: boolean;
928
- session_id?: string;
929
- user_prompt_id?: string;
930
- [key: string]: unknown;
931
- }
932
- /**
933
- * System instruction shape accepted by Cloud Code Assist.
934
- */
935
- export interface GeminiSystemInstruction {
936
- role?: "system";
937
- parts: GeminiPart[];
938
- }
939
- /**
940
- * Function declaration shape used in Gemini tools payloads.
941
- */
942
- export interface GeminiFunctionDeclaration {
943
- name: string;
944
- description?: string;
945
- parameters?: any;
946
- }
947
- /**
948
- * Generation config including thinkingConfig with level/budget mapping.
949
- * v2.1.14 merge: unions the request.ts declaration (top-level thinking
950
- * compat fields) with the request-helpers.ts declaration (penalties,
951
- * responseMimeType and the index signature).
952
- */
953
- export interface GeminiGenerationConfig {
954
- temperature?: number;
955
- topP?: number;
956
- topK?: number;
957
- maxOutputTokens?: number;
958
- stopSequences?: string[];
959
- candidateCount?: number;
960
- presencePenalty?: number;
961
- frequencyPenalty?: number;
962
- thinkingConfig?: {
963
- thinkingLevel?: string;
964
- thinkingBudget?: number;
965
- includeThoughts?: boolean;
966
- };
967
- responseMimeType?: string;
968
- thinkingLevel?: string;
969
- thinkingBudget?: number;
970
- [k: string]: unknown;
971
- }
972
- /**
973
- * Inner `request` field of the Cloud Code Assist v1internal envelope.
974
- */
975
- export interface CloudCodeAssistInnerRequest {
976
- contents: GeminiContent[];
977
- systemInstruction?: GeminiSystemInstruction;
978
- tools?: any[];
979
- toolConfig?: {
980
- functionCallingConfig?: {
981
- mode: string;
982
- allowedFunctionNames?: string[];
983
- };
984
- };
985
- generationConfig?: GeminiGenerationConfig;
986
- }
987
- /**
988
- * Options bag accepted by the merged transform helpers.
989
- */
990
- export interface TransformOptions {
991
- projectId?: string;
992
- directory?: string;
993
- enableGoogleSearch?: boolean;
994
- thinkingLevel?: ThinkingLevel | string;
995
- model?: string;
996
- sessionId?: string;
997
- userPromptId?: string;
998
- temperature?: number;
999
- topP?: number;
1000
- topK?: number;
1001
- maxTokens?: number;
1002
- }
1003
- /**
1004
- * Result of {@link transformTools}: ready-made tools payload plus tool config.
1005
- */
1006
- export interface TransformToolsResult {
1007
- tools: any[] | undefined;
1008
- toolConfig?: {
1009
- functionCallingConfig: {
1010
- mode: string;
1011
- allowedFunctionNames?: string[];
1012
- };
1013
- } | undefined;
1014
- sanitizedMap: Record<string, string>;
1015
- }
1016
- /**
1017
- * Complete fetch payload for Antigravity / Cloud Code Assist endpoints.
1018
- */
1019
- export interface AntigravityFetchPayload {
1020
- url: string;
1021
- method: "POST";
1022
- headers: Record<string, string>;
1023
- body: {
1024
- model: string;
1025
- project: string;
1026
- request: CloudCodeAssistInnerRequest;
1027
- user_prompt_id: string;
1028
- session_id: string;
1029
- requestId?: string;
1030
- };
1031
- rawBody: string;
1032
- model: string;
1033
- project: string;
1034
- user_prompt_id: string;
1035
- session_id: string;
1036
- isGeminiCLIOnly: boolean;
1037
- }
1038
- /**
1039
- * Builds a GeminiGenerationConfig from an OpenCode request plus overrides.
1040
- *
1041
- * v2.1.14 merge note: renamed from buildGenerationConfig so the richer
1042
- * options-object builder merged from request-helpers.ts can own that name.
1043
- * Resolves the thinking level (override > opts > request > default) and maps
1044
- * it onto the canonical budget map.
1045
- *
1046
- * @param req - OpenCode request with optional sampling/thinking fields
1047
- * @param opts - transform-level overrides
1048
- * @param thinkingLevelOverride - explicit level that wins over everything else
1049
- * @returns generation config ready for CloudCodeAssistInnerRequest
1050
- */
1051
- export declare function buildGenerationConfigFromRequest(req: OpenCodeRequest, opts?: TransformOptions, thinkingLevelOverride?: ThinkingLevel): GeminiGenerationConfig;
1052
- export interface BuildGenerationConfigOptions {
1053
- temperature?: number;
1054
- topP?: number;
1055
- topK?: number;
1056
- maxTokens?: number;
1057
- maxOutputTokens?: number;
1058
- thinkingLevel?: ThinkingLevel;
1059
- thinkingBudget?: number;
1060
- includeThoughts?: boolean;
1061
- modelId?: string;
1062
- stopSequences?: string[];
1063
- candidateCount?: number;
1064
- presencePenalty?: number;
1065
- frequencyPenalty?: number;
1066
- responseMimeType?: string;
1067
- }
1068
- /**
1069
- * Constrói GenerationConfig para cloudcode-pa v1internal.
1070
- * Mapeia thinkingLevel (minimal/low/medium/high) para thinkingBudget.
1071
- *
1072
- * - Para modelos Gemini: minimal=0 (desativa), low=1024, medium=4096, high=8192
1073
- * - Para modelos Claude (via Antigravity): budgets maiores
1074
- * - Se thinkingBudget direto fornecido, usa direto
1075
- * - Se thinkingLevel=none/minimal com includeThoughts=false, omite includeThoughts para economia
1076
- *
1077
- * @param opts - opções de geração
1078
- * @returns config compatível com v1internal:generateContent
1079
- */
1080
- export declare function buildGenerationConfig(opts?: BuildGenerationConfigOptions): GeminiGenerationConfig;
1081
- /**
1082
- * Builds the exact header set used by Gemini CLI bypass traffic:
1083
- * User-Agent, X-Goog-Api-Client, Client-Metadata (header and mirrored
1084
- * X-Goog-Client-Metadata), JSON content type, gzip accept-encoding, and an
1085
- * optional Bearer authorization merged last so extras can override.
1086
- *
1087
- * @param token - optional OAuth token; "Bearer " prefix added when missing
1088
- * @param extra - additional headers merged after the defaults
1089
- * @returns headers record ready for fetch
1090
- */
1091
- export declare function buildBypassHeaders(token?: string, extra?: Record<string, string>): Record<string, string>;
1092
- /**
1093
- * Cleans one JSON Schema for Gemini function declarations: drops every key not
1094
- * present in {@link ALLOWED_SCHEMA_KEYS} (recursively), normalizes oneOf to
1095
- * anyOf, filters required/enum arrays, and defaults type to object when
1096
- * properties exist.
1097
- *
1098
- * @param schema - raw schema node of any shape
1099
- * @returns cleaned schema (same reference type semantics as input primitives)
1100
- */
1101
- export declare function cleanToolSchema(schema: unknown): any;
1102
- export interface CleanToolSchemaOptions {
1103
- maxDepth?: number;
1104
- keepFormat?: boolean;
1105
- keepDescription?: boolean;
1106
- }
1107
- /**
1108
- * Limpa e normaliza JSON Schema de tool para formato aceito por Gemini / Cloud Code Assist.
1109
- *
1110
- * O que faz:
1111
- * - remove $schema, $id, examples, etc
1112
- * - remove chaves undefined / null vazias
1113
- * - normaliza type para lowercase e singular
1114
- * - converte `const: X` para `enum: [X]`
1115
- * - limpa recursivamente properties, items, anyOf/oneOf/allOf
1116
- * - garante que object com properties tenha type=object
1117
- * - remove propriedades vazias
1118
- * - impede profundidade infinita (>20)
1119
- *
1120
- * v2.1.14 merge note: renamed from cleanToolSchema (request-helpers.ts) to
1121
- * cleanToolSchemaTolerant; the strict allowlist cleaner from request.ts owns
1122
- * the cleanToolSchema name.
1123
- *
1124
- * @param schema - schema bruto (any)
1125
- * @param opts - opções
1126
- * @returns schema limpo
1127
- */
1128
- export declare function cleanToolSchemaTolerant(schema: unknown, opts?: CleanToolSchemaOptions, _depth?: number): unknown;
1129
- /**
1130
- * Versão plural que limpa mapa de tools ou array de function declarations
1131
- *
1132
- * v2.1.14 merge note: canonical plural (superset of request.ts's array-only
1133
- * variant; strict-array cleaning stays available via schemas.map(cleanToolSchema)).
1134
- */
1135
- export declare function cleanToolSchemas(tools: unknown, opts?: CleanToolSchemaOptions): unknown;
1136
- /**
1137
- * Checks whether a tool name already satisfies the Gemini naming rules.
1138
- *
1139
- * @param name - candidate name
1140
- * @returns true when valid without sanitization
1141
- */
1142
- export declare function isValidToolName(name: string): boolean;
1143
- /**
1144
- * Detailed result of {@link validateToolNames}.
1145
- */
1146
- export interface ValidateToolNamesResult {
1147
- valid: string[];
1148
- invalid: string[];
1149
- sanitized: Record<string, string>;
1150
- duplicates: string[];
1151
- }
1152
- /**
1153
- * Validates a list of tool names, reporting duplicates and computing sanitized
1154
- * replacements for invalid entries.
1155
- *
1156
- * @param names - raw tool names
1157
- * @returns valid/invalid partitions plus sanitized mapping
1158
- */
1159
- export declare function validateToolNames(names: string[]): ValidateToolNamesResult;
1160
- /**
1161
- * Validates one tool name against the Gemini naming rules.
1162
- *
1163
- * @param name - candidate name of any type
1164
- */
1165
- export declare function validateToolName(name: unknown): boolean;
1166
- export interface InvalidToolName {
1167
- name: string;
1168
- reason: string;
1169
- }
1170
- export interface SanitizedToolName {
1171
- original: string;
1172
- sanitized: string;
1173
- }
1174
- export interface ValidateToolNamesDetailedResult {
1175
- valid: boolean;
1176
- validNames: string[];
1177
- invalid: InvalidToolName[];
1178
- sanitized: SanitizedToolName[];
1179
- allSanitizedValid: boolean;
1180
- }
1181
- /**
1182
- * Valida lista de nomes de tools. Gemini exige ^[A-Za-z_][A-Za-z0-9_]*$ e max 64.
1183
- *
1184
- * v2.1.14 merge note: renamed from validateToolNames (request-helpers.ts);
1185
- * the canonical TOOL_NAME_REGEX (letter start + 64 cap, from request.ts)
1186
- * now backs this validator.
1187
- *
1188
- * @param tools - array de string, array de {name}, ou Record<string,any>
1189
- * @returns resultado com valid/invalid/sanitized
1190
- */
1191
- export declare function validateToolNamesDetailed(tools: Array<string | {
1192
- name: string;
1193
- [k: string]: unknown;
1194
- }> | Record<string, unknown>): ValidateToolNamesDetailedResult;
1195
- /**
1196
- * Converts OpenCode tool definitions into the Cloud Code Assist tools payload:
1197
- * validates names, sanitizes invalid ones, cleans each schema, deduplicates by
1198
- * final name, optionally injects `{ google_search: {} }`, and emits the
1199
- * matching AUTO function-calling toolConfig.
1200
- *
1201
- * Kept alongside {@link validateAndSanitizeTools}, which returns flat
1202
- * declarations instead of a wrapped payload.
1203
- *
1204
- * @param openTools - raw tools in OpenAI/Anthropic/Gemini shapes
1205
- * @param enableGoogleSearch - inject the google_search built-in tool
1206
- * @returns tools payload, tool config and sanitized-name map
1207
- */
1208
- export declare function transformTools(openTools: OpenCodeTool[] | undefined, enableGoogleSearch?: boolean): TransformToolsResult;
1209
- /**
1210
- * Named bundle mirroring the legacy ONDA 4 module surface. The default export
1211
- * remains {@link RequestPipeline}; both barrels stay available.
1212
- */
1213
- export declare const RequestTransformer: {
1214
- readonly GEMINI_CLI_OAUTH_CLIENT_ID: string;
1215
- readonly GEMINI_CLI_OAUTH_CLIENT_SECRET: string;
1216
- readonly GEMINI_CLI_USER_AGENT: "GeminiCLI/0.57.0/gemini-3-pro-preview (linux; x64; GitHub) google-api-nodejs-client/9.15.1";
1217
- readonly X_GOOG_API_CLIENT: "gl-node/22.19.0";
1218
- readonly CLIENT_METADATA: {
1219
- readonly ideType: "IDE_UNSPECIFIED";
1220
- readonly platform: "PLATFORM_UNSPECIFIED";
1221
- readonly pluginType: "GEMINI";
1222
- };
1223
- readonly CLIENT_METADATA_STRING: "ideType=IDE_UNSPECIFIED,platform=PLATFORM_UNSPECIFIED,pluginType=GEMINI";
1224
- readonly FALLBACK_PROJECT_ID: "rising-fact-p41fc";
1225
- readonly CLOUDCODE_PA_BASE: "https://cloudcode-pa.googleapis.com";
1226
- readonly CLOUDCODE_DAILY_BASE: "https://daily-cloudcode-pa.googleapis.com";
1227
- readonly CODE_ASSIST_ENDPOINTS: {
1228
- readonly GENERATE: "/v1internal:generateContent";
1229
- readonly STREAM_GENERATE: "/v1internal:streamGenerateContent";
1230
- readonly LOAD: "/v1internal:loadCodeAssist";
1231
- };
1232
- readonly CODE_ASSIST_METHOD_PATHS: {
1233
- readonly GENERATE: "/v1internal:generateContent";
1234
- readonly STREAM_GENERATE: "/v1internal:streamGenerateContent";
1235
- readonly LOAD: "/v1internal:loadCodeAssist";
1236
- };
1237
- readonly MODELS_2026: readonly ["gemini-3-pro-preview", "gemini-3-flash-preview", "gemini-3.1-pro-preview", "gemini-3.1-pro-preview-customtools", "gemini-3-flash", "gemini-3-pro", "gemini-2.5-pro", "gemini-2.5-flash", "gemini-2.5", "claude-opus-4-6-thinking", "claude-opus-4-6-thinking-low", "claude-opus-4-6-thinking-max", "claude-sonnet-4-6", "claude-sonnet-4-6-thinking", "claude-opus-4-5-thinking", "antigravity-gemini-3-pro", "antigravity-gemini-3-flash", "antigravity-gemini-3.1-pro", "antigravity-gemini-3-pro-preview", "antigravity-gemini-3-flash-preview", "antigravity-claude-opus-4-6-thinking", "antigravity-claude-sonnet-4-6"];
1238
- readonly THINKING_BUDGET_MAP: Record<"high" | "low" | "max" | "medium" | "minimal" | "tiered", number>;
1239
- readonly fnv1a32: typeof fnv1a32;
1240
- readonly fnv1a64BigInt: typeof fnv1a64BigInt;
1241
- readonly buildSessionIdFromDir: typeof buildSessionIdFromDir;
1242
- readonly buildSessionId: typeof buildSessionId;
1243
- readonly buildUserPromptId: typeof buildUserPromptId;
1244
- readonly sanitizeToolName: typeof sanitizeToolName;
1245
- readonly isValidToolName: typeof isValidToolName;
1246
- readonly validateToolNames: typeof validateToolNames;
1247
- readonly cleanToolSchema: typeof cleanToolSchema;
1248
- readonly cleanToolSchemas: typeof cleanToolSchemas;
1249
- readonly transformTools: typeof transformTools;
1250
- readonly normalizeThinkingLevel: typeof normalizeThinkingLevel;
1251
- readonly mapThinkingLevelToBudget: typeof mapThinkingLevelToBudget;
1252
- readonly isGeminiCLIOnlyModel: typeof isGeminiCLIOnlyModel;
1253
- readonly isLikelyAntigravityOnlyModel: typeof isLikelyAntigravityOnlyModel;
1254
- readonly buildGenerationConfigFromRequest: typeof buildGenerationConfigFromRequest;
1255
- readonly buildBypassHeaders: typeof buildBypassHeaders;
1256
- readonly transformRequest: typeof transformRequest;
1257
- readonly buildAntigravityRequest: typeof buildAntigravityRequest;
1258
- readonly buildGeminiCLIRequest: typeof buildGeminiCLIRequest;
1259
- };
1260
- export declare const RequestPipeline: {
1261
- transformRequest: typeof transformRequest;
1262
- buildAntigravityRequest: typeof buildAntigravityRequest;
1263
- buildGeminiCLIRequest: typeof buildGeminiCLIRequest;
1264
- isGeminiCLIOnlyModel: typeof isGeminiCLIOnlyModel;
1265
- getEndpointsForModel: typeof getEndpointsForModel;
1266
- fnv1a32: typeof fnv1a32;
1267
- fnv1a32Hex: typeof fnv1a32Hex;
1268
- generateDeterministicId: typeof generateDeterministicId;
1269
- generateSessionId: typeof generateSessionId;
1270
- generateUserPromptId: typeof generateUserPromptId;
1271
- sanitizeToolName: typeof sanitizeToolName;
1272
- ensureUniqueToolNames: typeof ensureUniqueToolNames;
1273
- validateAndSanitizeTools: typeof validateAndSanitizeTools;
1274
- cleanJsonSchema: typeof cleanJsonSchema;
1275
- mapThinkingBlock: typeof mapThinkingBlock;
1276
- sortThoughtFirst: typeof sortThoughtFirst;
1277
- filterAndMapThinkingParts: typeof filterAndMapThinkingParts;
1278
- injectGoogleSearchTool: typeof injectGoogleSearchTool;
1279
- stripForbiddenHeaders: typeof stripForbiddenHeaders;
1280
- stripXGoogUserProjectHeader: typeof stripXGoogUserProjectHeader;
1281
- getFingerprintHeaders: typeof getFingerprintHeaders;
1282
- buildDynamicUserAgent: typeof buildDynamicUserAgent;
1283
- fetchWithCascade: typeof fetchWithCascade;
1284
- parseModelId: typeof parseModelId;
1285
- extractThinkingLevel: typeof extractThinkingLevel;
1286
- };
1287
- export declare function stripForbiddenHeaders(headers: Record<string, string>): Record<string, string>;
1288
- /** Cloud Code streaming method path (family owner — former plugin.ts local). */
1289
- export declare const STREAM_METHOD: "/v1internal:streamGenerateContent?alt=sse";
1290
- /** Cloud Code non-streaming method path. */
1291
- export declare const GENERATE_METHOD: "/v1internal:generateContent";
1292
- /** Cloud Code loadCodeAssist method path (project discovery). */
1293
- export declare const LOAD_METHOD: "/v1internal:loadCodeAssist";
1294
- /** Cloud Code onboardUser method path (project discovery). */
1295
- export declare const ONBOARD_METHOD: "/v1internal:onboardUser";
1296
- export declare const TOOL_NAME_REGEX: RegExp;
1297
- declare function sanitizeToolName(name: string): string;
1298
- declare function ensureUniqueToolNames(names: string[]): string[];
1299
- declare function cleanJsonSchema(input: any, seen?: WeakSet<object>): any;
1300
- declare function validateAndSanitizeTools(rawTools?: any[]): {
1301
- declarations: any[];
1302
- };
1303
- export declare function generateDeterministicId(seed: string): string;
1304
- export declare function generateSessionId(seed?: string, offsetEnabled?: boolean): string;
1305
- export declare function generateUserPromptId(seed?: string, offsetEnabled?: boolean): string;
1306
- interface TransformRequestOptions {
1307
- model: string;
1308
- messages?: any[] | undefined;
1309
- tools?: any[] | undefined;
1310
- system?: string | any | undefined;
1311
- thinkingLevel?: string | undefined;
1312
- thinkingBudget?: number | undefined;
1313
- googleSearchEnabled?: boolean | undefined;
1314
- generationConfig?: any | undefined;
1315
- sessionSeed?: string | undefined;
1316
- userPromptSeed?: string | undefined;
1317
- projectId?: string | undefined;
1318
- pidOffsetEnabled?: boolean | undefined;
1319
- claudeToolHardening?: boolean | undefined;
1320
- keepThinking?: boolean | undefined;
1321
- }
1322
- interface TransformResult {
1323
- contents: GeminiContent[];
1324
- systemInstruction?: GeminiSystem | undefined;
1325
- tools?: any[] | undefined;
1326
- toolConfig?: any | undefined;
1327
- generationConfig?: any | undefined;
1328
- sessionId: string;
1329
- userPromptId: string;
1330
- thinkingBudget?: number | undefined;
1331
- thinkingLevel?: ThinkingLevel | undefined;
1332
- }
1333
- declare function extractThinkingLevel(modelId: string, explicit?: string): {
1334
- level?: ThinkingLevel;
1335
- budget?: number;
1336
- };
1337
- export declare function transformRequest(opts: TransformRequestOptions): TransformResult;
1338
- export declare function buildCloudCodeBody(projectId: string, inner: TransformResult): Record<string, any>;
1339
- export interface BuildOptions {
1340
- model: string;
1341
- messages?: any[] | undefined;
1342
- tools?: any[] | undefined;
1343
- system?: any | undefined;
1344
- thinkingLevel?: string | undefined;
1345
- thinkingBudget?: number | undefined;
1346
- googleSearchEnabled?: boolean | undefined;
1347
- generationConfig?: any | undefined;
1348
- accessToken: string;
1349
- projectId: string;
1350
- endpointOverrides?: string[] | undefined;
1351
- userAgent?: string | undefined;
1352
- antigravityVersion?: string | undefined;
1353
- methodSuffix?: string | undefined;
1354
- sessionSeed?: string | undefined;
1355
- userPromptSeed?: string | undefined;
1356
- pidOffsetEnabled?: boolean | undefined;
1357
- claudeToolHardening?: boolean | undefined;
1358
- keepThinking?: boolean | undefined;
1359
- }
1360
- export interface BuildResult {
1361
- url: string;
1362
- endpoints: string[];
1363
- baseEndpoints: string[];
1364
- headers: Record<string, string>;
1365
- body: Record<string, any>;
1366
- sessionId: string;
1367
- userPromptId: string;
1368
- isGeminiCLIOnly: boolean;
1369
- method: string;
1370
- innerRequest: TransformResult;
1371
- }
1372
- export declare function buildAntigravityRequest(options: BuildOptions): BuildResult;
1373
- export declare function buildGeminiCLIRequest(options: BuildOptions): BuildResult;
1374
- export declare function fetchWithCascade(buildResult: BuildResult, fetchOptions?: {
1375
- signal?: AbortSignal;
1376
- timeoutMs?: number;
1377
- }): Promise<Response>;
1378
- export declare const BYPASS_CONSTANTS: {
1379
- readonly directEndpoint: "https://cloudcode-pa.googleapis.com";
1380
- readonly dailyEndpoint: "https://daily-cloudcode-pa.googleapis.com";
1381
- readonly sandboxEndpoint: "https://autopush-cloudcode-pa.sandbox.googleapis.com";
1382
- readonly endpointCascade: readonly ["https://daily-cloudcode-pa.googleapis.com", "https://autopush-cloudcode-pa.sandbox.googleapis.com", "https://cloudcode-pa.googleapis.com"];
1383
- readonly headersToStrip: readonly ["x-goog-user-project", "X-Goog-QuotaUser", "X-Client-Device-Id"];
1384
- readonly toolNamePattern: string;
1385
- readonly maxToolNameLength: 64;
1386
- readonly maxToolsPerRequest: 128;
1387
- readonly thinkingBudgetMap: Record<"high" | "low" | "max" | "medium" | "minimal" | "tiered", number>;
1388
- readonly fnvOffsetBasis: 2166136261;
1389
- readonly fnvPrime: 16777619;
1390
- };
1391
- /** Full Cloud Code v1internal method URLs on the production base. */
1392
- export declare const API_PATHS: {
1393
- readonly loadCodeAssist: "https://cloudcode-pa.googleapis.com/v1internal:loadCodeAssist";
1394
- readonly onboardUser: "https://cloudcode-pa.googleapis.com/v1internal:onboardUser";
1395
- readonly fetchAvailableModels: "https://cloudcode-pa.googleapis.com/v1internal:fetchAvailableModels";
1396
- readonly generateContent: "https://cloudcode-pa.googleapis.com/v1internal:generateContent";
1397
- readonly streamGenerateContent: "https://cloudcode-pa.googleapis.com/v1internal:streamGenerateContent";
1398
- readonly retrieveUserQuotaSummary: "https://cloudcode-pa.googleapis.com/v1internal:retrieveUserQuotaSummary";
1399
- };
1400
- /** Daily-build method URLs (quota lineage: antigravity quota reads the daily base). */
1401
- export declare const API_PATHS_DAILY: {
1402
- readonly loadCodeAssist: "https://daily-cloudcode-pa.googleapis.com/v1internal:loadCodeAssist";
1403
- readonly retrieveUserQuotaSummary: "https://daily-cloudcode-pa.googleapis.com/v1internal:retrieveUserQuotaSummary";
1404
- };
1405
- export declare const RequestHelpers: {
1406
- readonly GEMINI_CLI_OAUTH_CLIENT_ID: string;
1407
- readonly GEMINI_CLI_OAUTH_CLIENT_SECRET: string;
1408
- readonly GEMINI_CLI_USER_AGENT: "GeminiCLI/0.57.0/gemini-3-pro-preview (linux; x64; GitHub) google-api-nodejs-client/9.15.1";
1409
- readonly X_GOOG_API_CLIENT: "gl-node/22.19.0";
1410
- readonly CLIENT_METADATA_RAW: "ideType=IDE_UNSPECIFIED,platform=PLATFORM_UNSPECIFIED,pluginType=GEMINI";
1411
- readonly CLOUDCODE_PA_BASE: "https://cloudcode-pa.googleapis.com";
1412
- readonly PROJECT_FALLBACK: "rising-fact-p41fc";
1413
- readonly MODELS_2026: readonly ["gemini-3-pro-preview", "gemini-3-flash-preview", "gemini-3.1-pro-preview", "gemini-3.1-pro-preview-customtools", "gemini-3-flash", "gemini-3-pro", "gemini-2.5-pro", "gemini-2.5-flash", "gemini-2.5", "claude-opus-4-6-thinking", "claude-opus-4-6-thinking-low", "claude-opus-4-6-thinking-max", "claude-sonnet-4-6", "claude-sonnet-4-6-thinking", "claude-opus-4-5-thinking", "antigravity-gemini-3-pro", "antigravity-gemini-3-flash", "antigravity-gemini-3.1-pro", "antigravity-gemini-3-pro-preview", "antigravity-gemini-3-flash-preview", "antigravity-claude-opus-4-6-thinking", "antigravity-claude-sonnet-4-6"];
1414
- readonly fnv1a32: typeof fnv1a32;
1415
- readonly fnv1a64BigInt: typeof fnv1a64BigInt;
1416
- readonly buildUserPromptId: typeof buildUserPromptId;
1417
- readonly buildSessionIdFromDir: typeof buildSessionIdFromDir;
1418
- readonly isLikelyAntigravityOnlyModel: typeof isLikelyAntigravityOnlyModel;
1419
- readonly cleanToolSchemaTolerant: typeof cleanToolSchemaTolerant;
1420
- readonly cleanToolSchemas: typeof cleanToolSchemas;
1421
- readonly validateToolNamesDetailed: typeof validateToolNamesDetailed;
1422
- readonly sanitizeToolName: typeof sanitizeToolName;
1423
- readonly filterThinkingBlocks: typeof filterThinkingBlocks;
1424
- readonly normalizeMessages: typeof normalizeMessages;
1425
- readonly buildGenerationConfig: typeof buildGenerationConfig;
1426
- readonly enhanceAgySdkErrorResponse: typeof enhanceAgySdkErrorResponse;
1427
- readonly extractVariants: typeof extractVariants;
1428
- readonly extractVariantsFromAny: typeof extractVariantsFromAny;
1429
- readonly THINKING_LEVEL_TO_BUDGET_GEMINI: Record<string, number>;
1430
- readonly THINKING_LEVEL_TO_BUDGET_CLAUDE: Record<string, number>;
1431
- readonly FNV_OFFSET_BASIS: 2166136261;
1432
- readonly FNV_PRIME: 16777619;
1433
- readonly fnv1aHex: typeof fnv1aHex;
1434
- readonly fnv1aHex16: typeof fnv1aHex16;
1435
- readonly fnv1aHash: typeof fnv1a32;
1436
- readonly generateDeterministicId: typeof generateDeterministicId;
1437
- readonly generateSessionId: typeof generateSessionId;
1438
- readonly generateUserPromptId: typeof generateUserPromptId;
1439
- readonly THINKING_BUDGET_MAP: Record<"high" | "low" | "max" | "medium" | "minimal" | "tiered", number>;
1440
- readonly THINKING_LEVELS: readonly ["minimal", "low", "medium", "high", "tiered", "max"];
1441
- readonly THINKING_BUDGET_MIN: 1024;
1442
- readonly THINKING_BUDGET_MAX: 64000;
1443
- readonly THINKING_BUDGET_MAX_GEMINI: 32768;
1444
- readonly THINKING_BUDGET_MAX_CLAUDE: 64000;
1445
- readonly parseThinkingLevel: typeof parseThinkingLevel;
1446
- readonly mapThinkingLevelToBudget: typeof mapThinkingLevelToBudget;
1447
- readonly thinkingLevelToBudget: typeof mapThinkingLevelToBudget;
1448
- readonly getThinkingBudgetForVariant: typeof getThinkingBudgetForVariant;
1449
- readonly isGeminiCLIOnlyModel: typeof isGeminiCLIOnlyModel;
1450
- readonly extractModelVariant: typeof extractModelVariant;
1451
- readonly parseModelVariant: typeof extractModelVariant;
1452
- readonly TOOL_NAME_REGEX: RegExp;
1453
- readonly TOOL_NAME_MIN_LENGTH: 1;
1454
- readonly TOOL_NAME_MAX_LENGTH: 64;
1455
- readonly MAX_TOOLS_PER_REQUEST: 128;
1456
- readonly ALLOWED_SCHEMA_KEYS: Set<string>;
1457
- readonly ALLOWED_TOOL_TOP_KEYS: readonly ["name", "description", "parameters"];
1458
- readonly validateToolName: typeof validateToolName;
1459
- readonly cleanJsonSchemaStrict: typeof cleanJsonSchemaStrict;
1460
- readonly cleanRawToolSchema: typeof cleanRawToolSchema;
1461
- readonly cleanToolsArray: typeof cleanToolsArray;
1462
- readonly normalizeRole: typeof normalizeRole;
1463
- readonly normalizeContentToParts: typeof normalizeContentToParts;
1464
- readonly normalizeIncomingMessages: typeof normalizeIncomingMessages;
1465
- readonly isThinkingBlock: typeof isThinkingBlock;
1466
- readonly filterThinkingBlocksAuto: typeof filterThinkingBlocksAuto;
1467
- readonly filterThinkingBlocksFromParts: typeof filterThinkingBlocksFromParts;
1468
- readonly filterThinkingBlocksFromMessages: typeof filterThinkingBlocksFromMessages;
1469
- readonly DIRECT_ENDPOINT: "https://cloudcode-pa.googleapis.com";
1470
- readonly DAILY_ENDPOINT: "https://daily-cloudcode-pa.googleapis.com";
1471
- readonly AUTOPUSH_ENDPOINT: "https://autopush-cloudcode-pa.sandbox.googleapis.com";
1472
- readonly ENDPOINT_CASCADE: readonly ["https://daily-cloudcode-pa.googleapis.com", "https://autopush-cloudcode-pa.sandbox.googleapis.com", "https://cloudcode-pa.googleapis.com"];
1473
- readonly HEADERS_TO_STRIP: readonly ["x-goog-user-project", "X-Goog-QuotaUser", "X-Client-Device-Id"];
1474
- readonly BYPASS_CONSTANTS: {
1475
- readonly directEndpoint: "https://cloudcode-pa.googleapis.com";
1476
- readonly dailyEndpoint: "https://daily-cloudcode-pa.googleapis.com";
1477
- readonly sandboxEndpoint: "https://autopush-cloudcode-pa.sandbox.googleapis.com";
1478
- readonly endpointCascade: readonly ["https://daily-cloudcode-pa.googleapis.com", "https://autopush-cloudcode-pa.sandbox.googleapis.com", "https://cloudcode-pa.googleapis.com"];
1479
- readonly headersToStrip: readonly ["x-goog-user-project", "X-Goog-QuotaUser", "X-Client-Device-Id"];
1480
- readonly toolNamePattern: string;
1481
- readonly maxToolNameLength: 64;
1482
- readonly maxToolsPerRequest: 128;
1483
- readonly thinkingBudgetMap: Record<"high" | "low" | "max" | "medium" | "minimal" | "tiered", number>;
1484
- readonly fnvOffsetBasis: 2166136261;
1485
- readonly fnvPrime: 16777619;
1486
- };
1487
- readonly isRetryableStatus: typeof isRetryableStatus;
1488
- readonly stripForbiddenHeaders: typeof stripForbiddenHeaders;
1489
- readonly RequestHelpersError: typeof RequestHelpersError;
1490
- };
1491
- export default RequestPipeline;
1492
- //# sourceMappingURL=request.d.ts.map