@wenathlan/devthink 2.0.13 → 2.0.15
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.
- package/CHANGELOG.md +27 -0
- package/accounts.ts +2087 -0
- package/agent.ts +2331 -0
- package/antigravity.ts +2139 -0
- package/apifreeze.ts +4146 -0
- package/auth.ts +642 -0
- package/background.ts +16837 -0
- package/bridge.ts +2080 -0
- package/build.ts +54 -0
- package/bun.ts +26 -0
- package/capture.ts +1614 -0
- package/checksecrets.ts +72 -0
- package/cjs.ts +9 -0
- package/cli.ts +3500 -0
- package/commands.ts +1101 -0
- package/companion.ts +450 -0
- package/compatibility.ts +37 -0
- package/config.ts +3137 -0
- package/constants.ts +943 -0
- package/core.ts +1473 -0
- package/crossbrowser.ts +1359 -0
- package/dashdone.ts +605 -0
- package/data.ts +943 -0
- package/database.ts +133 -0
- package/debug.ts +850 -0
- package/deno.ts +27 -0
- package/devthink.ts +707 -0
- package/dist/accounts.d.ts +409 -0
- package/dist/agent.d.ts +837 -0
- package/dist/antigravity.d.ts +380 -0
- package/dist/apifreeze.d.ts +113 -0
- package/dist/auth.d.ts +224 -0
- package/{bridge.d.ts → dist/bridge.d.ts} +1 -1
- package/dist/capture.d.ts +595 -0
- package/dist/cjs.d.ts +6 -0
- package/{cli.js → dist/cli.js} +2 -2
- package/dist/commands.d.ts +310 -0
- package/dist/compatibility.d.ts +17 -0
- package/dist/config.d.ts +1853 -0
- package/dist/constants.d.ts +637 -0
- package/dist/core.d.ts +361 -0
- package/dist/data.d.ts +330 -0
- package/dist/database.d.ts +24 -0
- package/dist/debug.d.ts +270 -0
- package/dist/engine.d.ts +74 -0
- package/dist/environments.d.ts +244 -0
- package/dist/evidence.d.ts +277 -0
- package/dist/export.d.ts +311 -0
- package/dist/fingerprint.d.ts +594 -0
- package/dist/flow.d.ts +300 -0
- package/dist/gates.d.ts +103 -0
- package/dist/identity.d.ts +51 -0
- package/dist/ids.d.ts +7 -0
- package/dist/llm.d.ts +652 -0
- package/dist/models.d.ts +1807 -0
- package/dist/net.d.ts +325 -0
- package/dist/neutral.d.ts +41 -0
- package/dist/oauth.d.ts +703 -0
- package/dist/page.d.ts +1166 -0
- package/dist/perf.d.ts +481 -0
- package/dist/plan.d.ts +134 -0
- package/dist/project.d.ts +395 -0
- package/dist/providers.d.ts +37 -0
- package/dist/quota.d.ts +453 -0
- package/dist/recovery.d.ts +621 -0
- package/dist/request.d.ts +1492 -0
- package/dist/run.d.ts +779 -0
- package/dist/runtime.d.ts +212 -0
- package/dist/search.d.ts +375 -0
- package/dist/security.d.ts +534 -0
- package/dist/serve.d.ts +136 -0
- package/dist/session.d.ts +296 -0
- package/dist/storage.d.ts +53 -0
- package/dist/streaming.d.ts +1119 -0
- package/dist/swarm.d.ts +328 -0
- package/dist/tools.d.ts +170 -0
- package/dist/types.d.ts +8357 -0
- package/dist/utils.d.ts +82 -0
- package/dist/version.d.ts +7 -0
- package/dist/versionregistry.d.ts +406 -0
- package/dist/views.d.ts +579 -0
- package/dist/workbenchsession.d.ts +69 -0
- package/dist/workflow.d.ts +649 -0
- package/docs/readme.md +92 -0
- package/docs/schemas/antigravity.json +192 -0
- package/engine.ts +1524 -0
- package/environments.ts +1005 -0
- package/evidence.ts +643 -0
- package/export.ts +889 -0
- package/fingerprint.ts +1458 -0
- package/flow.ts +1190 -0
- package/gates.ts +307 -0
- package/gateway.ts +34 -0
- package/hardening.ts +191 -0
- package/headless.ts +369 -0
- package/http.ts +2110 -0
- package/identity.ts +246 -0
- package/ids.ts +26 -0
- package/index.ts +369 -0
- package/llm.ts +2682 -0
- package/mcp.ts +1835 -0
- package/{memory.js → memory.ts} +3834 -2310
- package/models.ts +3805 -0
- package/modes.ts +43 -0
- package/net.ts +1214 -0
- package/neutral.ts +362 -0
- package/node.ts +26 -0
- package/oauth.ts +2216 -0
- package/offscreen.ts +170 -0
- package/pack.ts +956 -0
- package/package.json +175 -82
- package/page.ts +7824 -0
- package/pagebridge.ts +1116 -0
- package/perf.ts +957 -0
- package/plan.ts +672 -0
- package/plugin.ts +76 -0
- package/{policy.js → policy.ts} +5073 -4679
- package/prisma.config.ts +27 -0
- package/progress.ts +1308 -0
- package/project.ts +1291 -0
- package/protocol.ts +4187 -0
- package/providers.ts +246 -0
- package/quota.ts +1887 -0
- package/recovery.ts +2433 -0
- package/request.ts +4482 -0
- package/run.ts +2135 -0
- package/runtime.ts +526 -0
- package/search.ts +1760 -0
- package/security.ts +1673 -0
- package/serve.ts +419 -0
- package/server.ts +5538 -0
- package/session.ts +1162 -0
- package/storage.ts +182 -0
- package/streaming.ts +4101 -0
- package/swarm.ts +884 -0
- package/sync.ts +56 -0
- package/tests/agentcert.test.ts +128 -0
- package/tests/agentfleet.test.ts +214 -0
- package/tests/agentreview.test.ts +241 -0
- package/tests/agentstream.test.ts +335 -0
- package/tests/agentwork.test.ts +356 -0
- package/tests/apifreeze.test.ts +290 -0
- package/tests/apimap.test.ts +112 -0
- package/tests/approvalgate.test.ts +175 -0
- package/tests/artifactmanifest.test.ts +204 -0
- package/tests/attentionfeed.test.ts +163 -0
- package/tests/backgroundruns.test.ts +100 -0
- package/tests/batchscheduling.test.ts +131 -0
- package/tests/blackboard.test.ts +238 -0
- package/tests/bridge.test.ts +1088 -0
- package/tests/browsercoverage.test.ts +134 -0
- package/tests/browserpolyfills.test.ts +124 -0
- package/tests/build.mjs +1260 -0
- package/tests/clientauth.test.ts +223 -0
- package/tests/clitools.test.ts +578 -0
- package/tests/confirmgates.test.ts +190 -0
- package/tests/containerpack.test.ts +143 -0
- package/tests/controlflow.test.ts +2120 -0
- package/tests/coordination.test.ts +345 -0
- package/tests/copyscreen.test.ts +139 -0
- package/tests/core.test.ts +417 -0
- package/tests/costcert.test.ts +95 -0
- package/tests/crossbrowser.test.ts +115 -0
- package/tests/cspaudit.test.ts +79 -0
- package/tests/dashdone.test.ts +615 -0
- package/tests/datagrid.test.ts +137 -0
- package/tests/doccheck.test.ts +107 -0
- package/tests/dombatch.test.ts +109 -0
- package/tests/emulation.test.ts +282 -0
- package/tests/environments.test.ts +259 -0
- package/tests/evidenceviews.test.ts +88 -0
- package/tests/exporttools.test.ts +185 -0
- package/tests/firefoxprep.test.ts +134 -0
- package/tests/flowlibrary.test.ts +242 -0
- package/tests/flowrun.test.ts +303 -0
- package/tests/forensics.test.ts +439 -0
- package/tests/gateway.test.ts +939 -0
- package/tests/headlesslib.test.ts +171 -0
- package/tests/httpstream.test.ts +277 -0
- package/tests/immutablelog.test.ts +157 -0
- package/tests/inboundguard.test.ts +177 -0
- package/tests/lazyload.test.ts +72 -0
- package/tests/librarymodes.test.ts +623 -0
- package/tests/llm.test.ts +696 -0
- package/tests/manifest.test.ts +226 -0
- package/tests/maskinputs.test.ts +150 -0
- package/tests/matrixverify.test.ts +111 -0
- package/tests/mavenpack.test.ts +75 -0
- package/tests/mcpserver.test.ts +704 -0
- package/tests/memory.test.ts +4155 -0
- package/tests/memorycare.test.ts +230 -0
- package/tests/migrateplan.test.ts +349 -0
- package/tests/minimization.test.ts +414 -0
- package/tests/modelroute.test.ts +112 -0
- package/tests/multiagent.test.ts +440 -0
- package/tests/nativebridge.test.ts +807 -0
- package/tests/navigation.test.ts +284 -0
- package/tests/nugetpack.test.ts +83 -0
- package/tests/orchestration.test.ts +449 -0
- package/tests/originpolicy.test.ts +405 -0
- package/tests/outputcompare.test.ts +97 -0
- package/tests/package.test.ts +91 -0
- package/tests/pagebridge.test.ts +5909 -0
- package/tests/pentest.test.ts +75 -0
- package/tests/perfrecords.test.ts +257 -0
- package/tests/permdiff.test.ts +85 -0
- package/tests/phishguard.test.ts +128 -0
- package/tests/pickerviews.test.ts +155 -0
- package/tests/pipelines.test.ts +381 -0
- package/tests/planlint.test.ts +240 -0
- package/tests/planreview.test.ts +383 -0
- package/tests/platformtargets.test.ts +56 -0
- package/tests/policy.test.ts +8284 -0
- package/tests/portability.test.ts +96 -0
- package/tests/progress.test.ts +1036 -0
- package/tests/promptlibrary.test.ts +116 -0
- package/tests/protocol.test.ts +4793 -0
- package/tests/publishingpipeline.test.ts +314 -0
- package/tests/quickactions.test.ts +164 -0
- package/tests/readiness.test.ts +78 -0
- package/tests/recipes.test.ts +163 -0
- package/tests/redactshots.test.ts +216 -0
- package/tests/registernvidiakeys.ts +51 -0
- package/tests/relayserve.test.ts +304 -0
- package/tests/releasenotes.test.ts +276 -0
- package/tests/resilience.test.ts +467 -0
- package/tests/resourceaware.test.ts +187 -0
- package/tests/runbudget.test.ts +125 -0
- package/tests/runhistory.test.ts +299 -0
- package/tests/runreplay.test.ts +113 -0
- package/tests/runresume.test.ts +184 -0
- package/tests/runstate.test.ts +288 -0
- package/tests/runtimeadapters.test.ts +251 -0
- package/tests/safariskeleton.test.ts +115 -0
- package/tests/sandboxframe.test.ts +196 -0
- package/tests/sbom.test.ts +105 -0
- package/tests/secretvault.test.ts +188 -0
- package/tests/selcache.test.ts +111 -0
- package/tests/sessioninterface.test.ts +791 -0
- package/tests/sessions.test.ts +591 -0
- package/tests/siteprefs.test.ts +228 -0
- package/tests/snapshotdelta.test.ts +165 -0
- package/tests/statusviews.test.ts +237 -0
- package/tests/stepmeter.test.ts +200 -0
- package/tests/streamparse.test.ts +163 -0
- package/tests/stylepruning.test.ts +90 -0
- package/tests/surfaces.test.ts +282 -0
- package/tests/sweep.test.ts +78 -0
- package/tests/syncbridge.test.ts +164 -0
- package/tests/taskqueue.test.ts +206 -0
- package/tests/toolcalls.test.ts +336 -0
- package/tests/toolcatalog.test.ts +201 -0
- package/tests/torture-agent.test.ts +706 -0
- package/tests/torture-auth.test.ts +461 -0
- package/tests/torture-commands.test.ts +895 -0
- package/tests/torture-data.test.ts +923 -0
- package/tests/torture-environments.test.ts +285 -0
- package/tests/torture-export.test.ts +263 -0
- package/tests/torture-http.test.ts +1379 -0
- package/tests/torture-llm.test.ts +808 -0
- package/tests/torture-memory.test.ts +1084 -0
- package/tests/torture-plan.test.ts +829 -0
- package/tests/torture-run.test.ts +626 -0
- package/tests/torture-session.test.ts +928 -0
- package/tests/torture-swarm.test.ts +1245 -0
- package/tests/torture-tools.test.ts +964 -0
- package/tests/torture-workflow.test.ts +2354 -0
- package/tests/tourviews.test.ts +52 -0
- package/tests/transparency.test.ts +147 -0
- package/tests/trigger.test.ts +941 -0
- package/tests/v1sunset.test.ts +428 -0
- package/tests/virtlist.test.ts +94 -0
- package/tests/vision.test.ts +540 -0
- package/tests/vsixpack.test.ts +145 -0
- package/tests/webapi.test.ts +523 -0
- package/tests/workflow.test.ts +1785 -0
- package/tests/workfloweditor.test.ts +759 -0
- package/tests/xpipack.test.ts +128 -0
- package/tools.ts +734 -0
- package/types.ts +9908 -0
- package/umd.ts +9 -0
- package/utils.ts +249 -0
- package/version.ts +8 -0
- package/versionregistry.ts +1310 -0
- package/views.ts +2153 -0
- package/vitest.config.ts +12 -0
- package/web/App.tsx +78 -0
- package/web/README.md +47 -0
- package/web/capacitor.config.ts +46 -0
- package/web/const.ts +19 -0
- package/web/control.shell.tsx +66 -0
- package/web/dashboardpage.ts +554 -0
- package/web/db.ts +493 -0
- package/web/design.html +541 -0
- package/web/gatewayview/Gateway.tsx +345 -0
- package/web/gatewayview/config.ts +1042 -0
- package/web/gatewayview/definition.ts +174 -0
- package/web/icons.ts +15 -0
- package/{manifest.json → web/manifest.json} +1 -1
- package/web/optionspage.ts +691 -0
- package/web/popup.ts +1651 -0
- package/web/schema.prisma +176 -0
- package/web/sidepanel.ts +7941 -0
- package/web/sitemanifest.json +13 -0
- package/web/terminal-ui.tsx +622 -0
- package/web/transparencypage.ts +541 -0
- package/web/vite.config.ts +39 -0
- package/web/workspace.ts +23 -0
- package/workbenchmemory.ts +104 -0
- package/workbenchsession.ts +304 -0
- package/workflow.ts +4495 -0
- package/bridge.d.ts.map +0 -1
- package/bridge.js +0 -1877
- package/bun.d.ts.map +0 -1
- package/bun.js +0 -52329
- package/caps/background.json +0 -712
- package/caps/cli.json +0 -360
- package/caps/library.json +0 -3611
- package/caps/mcp.json +0 -126
- package/caps/pagebridge.json +0 -377
- package/caps/popup.json +0 -51
- package/caps/sidepanel.json +0 -522
- package/checksums.txt +0 -142
- package/cli.d.ts.map +0 -1
- package/companion.d.ts.map +0 -1
- package/companion.js +0 -389
- package/crossbrowser.d.ts.map +0 -1
- package/crossbrowser.js +0 -1191
- package/dashdone.d.ts.map +0 -1
- package/dashdone.js +0 -368
- package/deno.d.ts.map +0 -1
- package/deno.js +0 -52325
- package/devthink.umd.js +0 -52346
- package/fixtures/bun.ts +0 -7
- package/fixtures/cjs.js +0 -6
- package/fixtures/deno.ts +0 -6
- package/fixtures/example-org-pagestate.json +0 -22
- package/fixtures/importers/automa-workflow.json +0 -18
- package/fixtures/importers/selenium-side.json +0 -20
- package/fixtures/importers/tabular-plan.csv +0 -7
- package/fixtures/importers/uivision-macro.json +0 -10
- package/fixtures/importers/v1-plan.json +0 -13
- package/fixtures/mcp-client.mjs +0 -14
- package/fixtures/pages/checkout.html +0 -192
- package/fixtures/pages/dashboard.html +0 -110
- package/fixtures/pages/feed.html +0 -113
- package/fixtures/pages/product-grid.html +0 -150
- package/fixtures/plans/form-inventory-plan.json +0 -11
- package/fixtures/plans/release-notes-plan.json +0 -11
- package/fixtures/recipes/agentscompete.json +0 -11
- package/fixtures/recipes/agentsforms.json +0 -11
- package/fixtures/recipes/agentsmonitor.json +0 -11
- package/fixtures/recipes/agentsreview.json +0 -29
- package/fixtures/recipes/agentswarm.json +0 -11
- package/fixtures/recipes/fillcalendar.json +0 -12
- package/fixtures/recipes/fillcheckout.json +0 -13
- package/fixtures/recipes/filldependentdropdowns.json +0 -12
- package/fixtures/recipes/fillfromcsv.json +0 -13
- package/fixtures/recipes/fillloginform.json +0 -12
- package/fixtures/recipes/fillmultistepwizard.json +0 -13
- package/fixtures/recipes/fillregistration.json +0 -12
- package/fixtures/recipes/fillsearchfilters.json +0 -12
- package/fixtures/recipes/filltypeahead.json +0 -11
- package/fixtures/recipes/monitoralerts.json +0 -12
- package/fixtures/recipes/monitoravailability.json +0 -11
- package/fixtures/recipes/monitornetworkquiet.json +0 -12
- package/fixtures/recipes/monitorpagechanges.json +0 -11
- package/fixtures/recipes/monitorpricechange.json +0 -11
- package/fixtures/recipes/monitorschedule.json +0 -12
- package/fixtures/recipes/scrapedynamicprices.json +0 -13
- package/fixtures/recipes/scrapeimagegallery.json +0 -12
- package/fixtures/recipes/scrapeinfinitefeed.json +0 -13
- package/fixtures/recipes/scrapenestedlists.json +0 -12
- package/fixtures/recipes/scrapeproductgrid.json +0 -12
- package/fixtures/recipes/scrapereviews.json +0 -12
- package/fixtures/recipes/scrapesearchresults.json +0 -12
- package/fixtures/recipes/scrapetablepagination.json +0 -12
- package/fixtures/recipes/testaccessibility.json +0 -34
- package/fixtures/recipes/testconsoleerrors.json +0 -12
- package/fixtures/recipes/testdeeplinks.json +0 -12
- package/fixtures/recipes/testformvalidation.json +0 -13
- package/fixtures/recipes/testlayoutshift.json +0 -12
- package/fixtures/recipes/testlinkcheck.json +0 -12
- package/fixtures/recipes/testloadtiming.json +0 -12
- package/fixtures/recipes/testvisualdiff.json +0 -12
- package/fixtures/workflows/changelog-digest-workflow.json +0 -13
- package/fixtures/workflows/form-survey-workflow.json +0 -13
- package/gallery.json +0 -706
- package/hardening.d.ts.map +0 -1
- package/hardening.js +0 -188
- package/headless.d.ts.map +0 -1
- package/headless.js +0 -11522
- package/http.d.ts.map +0 -1
- package/http.js +0 -2165
- package/index.cjs +0 -54682
- package/index.d.ts.map +0 -1
- package/index.js +0 -52310
- package/index.neutral.js +0 -46343
- package/mcp.d.ts.map +0 -1
- package/mcp.js +0 -20515
- package/memory.d.ts.map +0 -1
- package/nativehost.template.json +0 -10
- package/node.cjs +0 -54686
- package/node.d.ts.map +0 -1
- package/pack.d.ts.map +0 -1
- package/pack.js +0 -805
- package/policy.d.ts.map +0 -1
- package/progress.d.ts.map +0 -1
- package/progress.js +0 -645
- package/protocol.d.ts.map +0 -1
- package/protocol.js +0 -8334
- package/schemas/audit.schema.json +0 -226
- package/schemas/capability.schema.json +0 -113
- package/schemas/envelope.schema.json +0 -162
- package/schemas/memory.schema.json +0 -51
- package/schemas/observation.schema.json +0 -113
- package/schemas/plan.schema.json +0 -208
- package/schemas/progress.schema.json +0 -126
- package/schemas/proposal.schema.json +0 -68
- package/schemas/session.schema.json +0 -82
- package/schemas/tool.schema.json +0 -94
- package/server.d.ts.map +0 -1
- package/server.js +0 -28877
- package/umd-example.html +0 -18
- package/umd.d.ts.map +0 -1
- /package/{bun.d.ts → dist/bun.d.ts} +0 -0
- /package/{cli.d.ts → dist/cli.d.ts} +0 -0
- /package/{companion.d.ts → dist/companion.d.ts} +0 -0
- /package/{crossbrowser.d.ts → dist/crossbrowser.d.ts} +0 -0
- /package/{dashdone.d.ts → dist/dashdone.d.ts} +0 -0
- /package/{deno.d.ts → dist/deno.d.ts} +0 -0
- /package/{hardening.d.ts → dist/hardening.d.ts} +0 -0
- /package/{headless.d.ts → dist/headless.d.ts} +0 -0
- /package/{http.d.ts → dist/http.d.ts} +0 -0
- /package/{index.d.ts → dist/index.d.ts} +0 -0
- /package/{mcp.d.ts → dist/mcp.d.ts} +0 -0
- /package/{memory.d.ts → dist/memory.d.ts} +0 -0
- /package/{node.d.ts → dist/node.d.ts} +0 -0
- /package/{pack.d.ts → dist/pack.d.ts} +0 -0
- /package/{policy.d.ts → dist/policy.d.ts} +0 -0
- /package/{progress.d.ts → dist/progress.d.ts} +0 -0
- /package/{protocol.d.ts → dist/protocol.d.ts} +0 -0
- /package/{server.d.ts → dist/server.d.ts} +0 -0
- /package/{umd.d.ts → dist/umd.d.ts} +0 -0
|
@@ -0,0 +1,1492 @@
|
|
|
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
|