Files
plugins/packages/gcp-ai/package.json
T
yetone 5112465ca1 gcp-ai 0.2.1: Gemini's history rules before Vertex, no 400 "Requests ending with a model turn" (#734)
The loader's fetch now hardens a generateContent/streamGenerateContent
body the way magpie's gateway builds Gemini contents (codeassist.go):
- contents ending with the model's turn get a user turn after it
  ("Continue.", or the summary ask when the system prompt is an agent's
  compaction prompt);
- contents opening with the model's turn get Gemini CLI's
  "[Continuing from previous AI thoughts...]" user turn before it;
- a user turn holding a functionResponse beside the user's text is split,
  the responses (and their images) first, the text in a turn of its own.
A body that needs none of it goes byte for byte; countTokens and the
model list are not read. lib/history.mjs, test/history.test.mjs.

Note: magpie's gateway already builds a plugin's @ai-sdk/google request
through buildCodeAssistSent, so those rules reach this plugin from magpie
too (yetone/magpie test TestPluginGeminiNeverAskedEndingWithModel, red
with the gateway's guard removed). This covers a body that reaches the
plugin without them: OpenCode's own @ai-sdk/google, or a magpie path that
skips the build. The reporter's exact request body is not in the issue,
so the tests use #734's conversation shape (Codex compaction after the
model's reply) and #1533's (tool output + compaction prompt in one turn).

Run on mote (mote-run): node --test test/history.test.mjs 5/5; the
package's npm run check + node --test test/*.test.mjs 105 tests, 91 pass,
0 fail (14 skipped, Windows-only); bun scripts/check.mjs exit 0.
Broken by hand: the fetch without hardenRequest fails the end-to-end
test (Vertex fake answers 400 "ending with a model turn").
Not tried: a real Vertex account (none in a sandbox here).
2026-11-05 01:45:46 +08:00

55 lines
4.7 KiB
JSON

{
"name": "@magpie-community/opencode-gcp-ai-auth",
"version": "0.2.1",
"description": "Vertex AI models and Google Cloud promotional credits, signed with your own gcloud / ADC login",
"type": "module",
"main": "./opencode.mjs",
"exports": { ".": "./opencode2.mjs" },
"files": [
"index.mjs",
"opencode.mjs",
"opencode2.mjs",
"lib/",
"assets/",
"README.md",
"LICENSE"
],
"engines": {
"node": ">=22"
},
"scripts": {
"check": "node --check index.mjs && node --check lib/browser.mjs && node --check lib/credentials.mjs && node --check lib/credits.mjs && node --check lib/endpoint.mjs && node --check lib/models.mjs && node --check lib/fetch_credits.mjs && node --check lib/history.mjs",
"models": "node lib/fetch_credits.mjs models",
"test": "node --test test/*.test.mjs",
"credits": "node lib/fetch_credits.mjs credits",
"login": "node lib/fetch_credits.mjs login",
"credentials": "node lib/fetch_credits.mjs credentials"
},
"keywords": [
"opencode",
"opencode-plugin",
"magpie",
"gcp-ai",
"gcp",
"vertex",
"credits",
"usage",
"quota",
"magpie-plugin",
"google-cloud",
"vertex-ai",
"gemini",
"adc",
"gcloud"
],
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/magpie-community/plugins.git",
"directory": "packages/gcp-ai"
},
"magpie": {
"icon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAMAAAD04JH5AAABRFBMVEVHcEyHwD7utQMdg+3/PSUOhfsUmsIKifYHhv4Gu2QKhv3+SYv/ODntxgIHvlYXhPkLhv0Hhv7xzAEGhv0IprTpzwEOwFQXwk3/Kyz/N0X/TDX/QSRJzSn/JTLR1AT5zwD/qgBa0R//cAU/euj/hgKp1wj/fQP/XghvctcAh///Ii8AiP8Cv1EAi/4AvVoMwkj+0gD/ywAAjvv/KCf/JjwHhvz41QAAu2UAkfYAle/t1gAaxT4An9r/xQAApMwAqLwArawAmuYAuXEsyTMAsZvg1wEAtIz/LU262AX/LyL/lgD/igEAtn7P2AP/sgA/zSj/uQD/fgL/oQD/NR6i1wr/qgD/vwD/Oxn/dAOL1g//N2JS0CH/XQj/Tw1k0xn/SRF31RP/ZQb/Vgv/QXj/bAT3zwD/RBT/QhZrcdWRYbbOUJVHcEy+/fmgAAAAbHRSTlMADiQZRkInsPSr3PyQid6bwn1hV7DBQmixKGgSt9tD5t3aonfm3L/Xzv///////////////////////////////////////////////////////////////////////////////////////wBrqzMYAAAHzUlEQVR4nO2aCVdSWxiGRVCZxIFEBkkztSujoMcBtTQyzSnNMjXLa0RX/f8/4O7hnD3vM4mtddflPTiwBJ53v9+3B1j29HTVVVddddXVf1aZUDY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