@magpie-community/opencode-grok-auth 0.1.16 → 0.1.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.mjs +15 -1
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -462,12 +462,24 @@ function modelOf(id) {
462
462
 
463
463
  // ---- sign-in ------------------------------------------------------------------
464
464
 
465
+ // opensPage is whether `grok login --device-auth` opens its page in the
466
+ // browser itself, which it does wherever it can: on macOS (NSWorkspace) and
467
+ // Windows (ShellExecute) always, with nothing to turn it off; on Linux and
468
+ // the BSDs through $BROWSER, else xdg-open where a display is. There it is
469
+ // given a $BROWSER that opens nothing, and the one who asked (magpie, which
470
+ // knows where the user's browser is) opens it; here the sign-in says the
471
+ // page is open already, so it isn't opened a second time (andyfmyth on X:
472
+ // "每次都会弹两次验证").
473
+ const opensPage = () => process.platform === "darwin" || process.platform === "win32"
474
+
465
475
  // login runs `grok login --device-auth` in home and hands on the first link
466
476
  // it prints; done is settled when the command is.
467
477
  function login(exe, home) {
478
+ const env = envFor(home)
479
+ if (!opensPage()) env.BROWSER = "true"
468
480
  const child = spawn(exe, ["login", "--device-auth"], {
469
481
  cwd: homedir(),
470
- env: envFor(home),
482
+ env,
471
483
  stdio: ["ignore", "pipe", "pipe"],
472
484
  })
473
485
  const tail = []
@@ -533,6 +545,8 @@ async function signIn() {
533
545
  }
534
546
  return {
535
547
  url,
548
+ // not OpenCode's: the page is open already, by Grok Build itself
549
+ opened: opensPage(),
536
550
  instructions: "Approve the sign-in on the page; Grok Build finishes it.",
537
551
  method: "auto",
538
552
  callback: async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magpie-community/opencode-grok-auth",
3
- "version": "0.1.16",
3
+ "version": "0.1.17",
4
4
  "description": "OpenCode provider plugin: Grok (SuperGrok / X Premium+) through the Grok Build CLI's sign-in",
5
5
  "type": "module",
6
6
  "main": "./index.mjs",