Run libfx agents on a Grok plan

- Run a libfx agent on Grok with `provider: "grok"`: model requests and the model list go to xAI's Grok endpoints through the host's `fetch` instead of AI Gateway.
- Supply Grok credentials through the shared `credentials({ provider, sessionId })` callback. libfx adds the token and account id only to Grok requests, so they never reach the engine or a saved session.
- Refresh Grok tokens five minutes before they expire and once after a 401, refuse a refreshed token for a different account, and pass new tokens to `onCredentials`.
- Continue a durable Grok session in a new process, which asks `credentials` for that session's credentials.
- Sign in with a Grok plan from `libfx/grok` with device code, or by pasting the callback address, and refresh tokens from there.
This commit is contained in:
Pranit committed 2026-10-11 02:42:37 -04:00
1 parent b3c59a6ecc
commit dabb6f2294
38 files changed
+1778 -410

No files matched your search

+2 -2
View File
@@ -252,7 +252,7 @@ jobs:
run: |
node --experimental-wasm-jspi sdk/tests/test-durable.mjs memory wasm
node --experimental-wasm-jspi sdk/tests/test-durable.mjs local wasm
node --experimental-wasm-jspi sdk/tests/test-durable-codex-crash.mjs wasm
node --experimental-wasm-jspi sdk/tests/test-durable-subscription-crash.mjs wasm
- name: Type-check the TypeScript declarations
run: node sdk/tests/test-types.mjs
@@ -299,7 +299,7 @@ jobs:
node sdk/tests/test-durable.mjs memory native
node sdk/tests/test-durable.mjs local native
node sdk/tests/test-durable.mjs world native
node sdk/tests/test-durable-codex-crash.mjs native
node sdk/tests/test-durable-subscription-crash.mjs native
node sdk/tests/test-durable-core.mjs memory
node sdk/tests/test-durable-core.mjs local
node sdk/tests/test-durable-core.mjs world
+2 -2
View File
@@ -284,9 +284,9 @@ jobs:
const names = new Set(report.files.map(({ path }) => path));
const required = [
"package.json", "README.md", "LICENSE", "browser.js", "node.js", "node.cjs", "fx-sdk.js", "wasm-module.js",
"core-output.js", "fetch-cleanup.js", "mcp.js", "skills.js", "skills-node.js", "chatgpt.js", "chatgpt-sign-in.js",
"core-output.js", "fetch-cleanup.js", "mcp.js", "skills.js", "skills-node.js", "subscription.js", "oauth.js", "chatgpt.js", "chatgpt-sign-in.js", "grok.js", "grok-sign-in.js",
"durable.js", "fx-harness.js", "durable/local.mjs", "durable/vercel.mjs", "durable/world.mjs",
"types/browser.d.ts", "types/chatgpt.d.ts", "types/durable-local.d.ts", "types/durable-vercel.d.ts", "types/durable-world.d.ts", "types/libfx.d.cts", "types/mcp.d.ts", "types/node.d.cts", "types/node.d.ts", "types/skills-node.d.ts", "types/skills.d.ts", "types/wasm.d.ts",
"types/browser.d.ts", "types/chatgpt.d.ts", "types/durable-local.d.ts", "types/durable-vercel.d.ts", "types/durable-world.d.ts", "types/grok.d.ts", "types/libfx.d.cts", "types/mcp.d.ts", "types/node.d.cts", "types/node.d.ts", "types/skills-node.d.ts", "types/skills.d.ts", "types/wasm.d.ts",
"fx-core.wasm", "fx-term.wasm",
"libfx.linux-x64.node", "libfx.linux-arm64.node",
"libfx.darwin-x64.node", "libfx.darwin-arm64.node",