grok 0.1.15: a sign-in without Grok Build says GROK_BIN_DIR takes one put in a folder of your own, not only the curl installer (yetone/magpie#2223, evier12345)
In magpie's Docker image there is no curl to run xAI's installer, and a grok binary dropped on PATH outside a .grok folder isn't taken (isGrokBuild keeps another program named grok out). GROK_BIN_DIR already took one as it is; the error now says so, and the README says where the CLI is looked for. Run: TMPDIR=<scratch> HOME=<scratch home> bun test in packages/grok (41 pass, 0 fail); bun scripts/check.mjs grok (✓). With index.mjs put back to 0.1.14, import.test's "no Grok Build … is refused first" fails on the new GROK_BIN_DIR assertion. Not tried in a real container from this commit; magpie's own fix (installing Grok Build before `magpie plugin login grok`) is in yetone/magpie.
This commit is contained in:
@@ -10,6 +10,13 @@ curl -fsSL https://x.ai/cli/install.sh | bash # macOS, Linux
|
||||
irm https://x.ai/cli/install.ps1 | iex # Windows
|
||||
```
|
||||
|
||||
It is found in the installer's folder (`GROK_BIN_DIR`, `GROK_HOME/bin`,
|
||||
`~/.grok/bin`), or on `PATH` when it lives under a `.grok` folder, so that
|
||||
another program named `grok` isn't taken for it. Where the installer can't
|
||||
run, such as a container without curl, put the binary in a folder of your
|
||||
own and set `GROK_BIN_DIR` to it. magpie installs Grok Build itself, as
|
||||
the installer does, before a sign-in that needs it.
|
||||
|
||||
## Sign in
|
||||
|
||||
- **Sign in with Grok Build (device code)** runs `grok login --device-auth`
|
||||
|
||||
@@ -148,6 +148,8 @@ test("what isn't an enabled CPA xAI OAuth account is refused, with no home made"
|
||||
test("no Grok Build to refresh the sign-in with is refused first", async () => {
|
||||
sandbox({ exe: false })
|
||||
await expect(importFrom(cpaFile())).rejects.toThrow("install Grok Build first")
|
||||
// one put in a folder of the user's choosing (magpie in Docker) is named too
|
||||
await expect(importFrom(cpaFile())).rejects.toThrow("set GROK_BIN_DIR to the folder holding its grok binary")
|
||||
})
|
||||
|
||||
test("a token that has already ended is still taken, its renewal left to the CLI", async () => {
|
||||
|
||||
@@ -23,6 +23,11 @@ const REFRESH_MARGIN = 5 * 60 * 1000 // a token this close to its end is renewed
|
||||
const LEAD_MS = REFRESH_MARGIN // and this close, magpie renews it ahead of time (auth.refresh)
|
||||
const LINK_WAIT = 30 * 1000
|
||||
const INSTALL = process.platform === "win32" ? "irm https://x.ai/cli/install.ps1 | iex" : "curl -fsSL https://x.ai/cli/install.sh | bash"
|
||||
// NO_CLI is what a sign-in without Grok Build says: how to install it, and
|
||||
// that one put somewhere else by hand (a container with no shell to run the
|
||||
// installer) is taken from GROK_BIN_DIR, as the installer's own folder is,
|
||||
// while one found on PATH has to be under a .grok folder (yetone/magpie#2223)
|
||||
const NO_CLI = `install Grok Build first: ${INSTALL}; or set GROK_BIN_DIR to the folder holding its grok binary`
|
||||
|
||||
// the tool types Grok's backend takes; it turns the whole request away over another
|
||||
const TOOLS = new Set(["function", "web_search", "x_search", "image_generation", "collections_search", "file_search",
|
||||
@@ -487,7 +492,7 @@ function newHome() {
|
||||
// sign-in stays as it is.
|
||||
async function signIn() {
|
||||
const exe = executable()
|
||||
if (!exe) throw new Error(`install Grok Build first: ${INSTALL}`)
|
||||
if (!exe) throw new Error(NO_CLI)
|
||||
const own = !!credential(cliHome())
|
||||
const home = own ? newHome() : cliHome()
|
||||
const { child, link, done, tail } = login(exe, home, own)
|
||||
@@ -566,7 +571,7 @@ function cpaAuthFromFile(file) {
|
||||
}
|
||||
|
||||
async function importCPA(inputs) {
|
||||
if (!executable()) throw new Error(`install Grok Build first: ${INSTALL}`)
|
||||
if (!executable()) throw new Error(NO_CLI)
|
||||
const rawPath = String(inputs?.path ?? "").trim()
|
||||
const file = resolve(rawPath === "~" ? homedir() : rawPath.startsWith("~/") ? join(homedir(), rawPath.slice(2)) : rawPath)
|
||||
if (!isFile(file)) throw new Error("choose a CPA Grok account JSON file")
|
||||
@@ -596,7 +601,7 @@ function saved(home, c) {
|
||||
|
||||
// current takes the sign-in the CLI already has, as it is.
|
||||
async function current() {
|
||||
if (!executable()) throw new Error(`install Grok Build first: ${INSTALL}`)
|
||||
if (!executable()) throw new Error(NO_CLI)
|
||||
const home = cliHome()
|
||||
if (!credential(home)) throw new Error("Grok Build is not signed in; run `grok login`, or sign in with the device code")
|
||||
const c = await token(home, false)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@magpie-community/opencode-grok-auth",
|
||||
"version": "0.1.14",
|
||||
"version": "0.1.15",
|
||||
"description": "OpenCode provider plugin: Grok (SuperGrok / X Premium+) through the Grok Build CLI's sign-in",
|
||||
"type": "module",
|
||||
"main": "./index.mjs",
|
||||
|
||||
Reference in New Issue
Block a user