Files
plugins/packages/grok/package.json
T
lxyer ae51883634 grok 0.2.6: a stream cut before its first byte is asked again (#852)
A Responses stream from Grok that dies before its first byte (the
connection reset, nothing sent yet) is asked again, up to three times,
before the answer is returned. A retry's own answer is noted, so a 429
or 401 on a retry comes back as itself, not folded into a 200.

Once a byte has arrived, response.created and reasoning included, the
stream is passed on at once, one upstream chunk per pull, and cancelling
it cancels the upstream read. A later cut is not asked again and nothing
is written in its place: the stream ends, and magpie 0.1.3298 or newer
(yetone/magpie 29bfd5dc8) closes it as a whole response.failed with
created_at and sequence_number. The frames 0.2.6's first version wrote
had no sequence_number, and Grok Build failed the turn on them. An
upstream response.failed, error or response.incomplete is passed on
unchanged, and an end with no bytes is not asked again.

Run on mote (macOS 27), at 463afb79, each in a temp HOME:
- packages/grok `bun test`: 107 pass, 0 fail.
- `bun scripts/check.mjs grok`: ok.
- Repo-root `bun test` with HOME=$(mktemp -d): 6878 pass, 20 skip,
  0 fail. A first run with HOME under /tmp had 21 reds in devin, zcode
  and sap-aicore. Those tests refuse a HOME outside $TMPDIR, and
  plugins main ecab8396 had the same reds under that HOME.
- Broken by hand, cut-retry.test.mjs goes red:
  - STREAM_TRIES=1: 3 fail;
  - the retry's note() removed: the 429 test fails;
  - cancel() not passed upstream: the cancel test fails;
  - "aborted" counted as a cut: the abort test fails;
  - a later cut erroring the stream instead of ending it: 2 fail.
  Asking again after a zero-byte clean end is the one break no test
  catches.
- Real chain: Grok Build 1.0.67 and 1.0.77 (x.ai's own build, the
  reporter's version), then magpie eef99e4bb (`magpie serve`, sandbox
  HOME), then this plugin (BASE pointed at a fake), then a fake Grok
  upstream:
  - ok: "pong".
  - Cut before the first byte, then ok: "pong", with the retry inside
    the plugin.
  - Cut, then 429: magpie logs a 429 from Grok, and Grok Build retries
    on "rate limited".
  - Always cut before a byte: an empty 200, which magpie reports as a
    retryable 502. Grok Build retries it as server_error.
  - Cut after response.created, and cut after text: magpie's
    response.failed ("the reply ended before it was complete"). Grok
    Build reads it and retries it as server_error. No "missing field"
    in either version.
  - Upstream response.failed: one call, and Grok Build shows the
    vendor's own message.

Not tried: a live Grok stream cut by the real vendor.
2026-11-08 12:42:31 +08:00

17 lines
585 B
JSON

{
"name": "@magpie-community/opencode-grok-auth",
"version": "0.2.6",
"description": "OpenCode provider plugin: Grok (SuperGrok / X Premium+) through the Grok Build CLI's sign-in",
"type": "module",
"main": "./opencode.mjs",
"exports": { ".": "./opencode2.mjs" },
"files": ["index.mjs", "opencode.mjs", "opencode2.mjs", "README.md"],
"keywords": ["opencode", "opencode-plugin", "grok", "xai", "supergrok"],
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/magpie-community/plugins.git",
"directory": "packages/grok"
}
}