Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.
/**
* Optional integration check against a real `grok agent stdio` install.
* Enable with: T3_GROK_ACP_PROBE=1 bun run test GrokAcpCliProbe
*
* The probe assumes either `XAI_API_KEY` is set in the environment or
* the user has previously run `grok login`. Without credentials the
* agent's `authenticate` request will fail and the test will surface
* the error.
*/
import * as NodeServices from "@effect/platform-node/NodeServices";
import { it } from "@effect/vitest";
import * as Effect from "effect/Effect";
import { ChildProcessSpawner } from "effect/unstable/process";
import { describe, expect } from "vite-plus/test";
import { sessionModelStateFromInitialize } from "./AcpRuntimeModel.ts";
import { makeGrokAcpRuntime } from "./GrokAcpSupport.ts";
const makeProbeRuntime = Effect.gen(function* () {
const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
return yield* makeGrokAcpRuntime({
grokSettings: { binaryPath: "grok" },
environment: process.env,
childProcessSpawner,
cwd: process.cwd(),
clientInfo: { name: "t3-grok-probe", version: "0.0.0" },
});
});
describe.runIf(process.env.T3_GROK_ACP_PROBE === "1")("Grok ACP CLI probe", () => {
it.effect("initialize advertises model state without opening a session", () =>
Effect.gen(function* () {
const runtime = yield* makeProbeRuntime;
const initialized = yield* runtime.initialize();
const models = sessionModelStateFromInitialize(initialized);
expect(initialized.protocolVersion).toBeDefined();
expect(models?.currentModelId).toBeTypeOf("string");
expect(models?.availableModels.length ?? 0).toBeGreaterThan(0);
expect(models?.availableModels.some((model) => model.modelId === "grok-build")).toBe(false);
}).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
);
it.effect("initialize and authenticate against real grok agent stdio", () =>
Effect.gen(function* () {
const runtime = yield* makeProbeRuntime;
const started = yield* runtime.start();
expect(started.initializeResult).toBeDefined();
}).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
);
it.effect("session/new advertises typed SessionModelState with at least one model", () =>
Effect.gen(function* () {
const runtime = yield* makeProbeRuntime;
const started = yield* runtime.start();
const result = started.sessionSetupResult;
expect(started.sessionId).toBeTypeOf("string");
// Modern grok-shell advertises models through the typed
// `SessionModelState` field, not via a `configOptions` entry.
// If this assertion fails the upstream surface has regressed.
const models = result.models;
expect(models).toBeDefined();
expect(models?.currentModelId).toBeTypeOf("string");
expect(models?.availableModels.length ?? 0).toBeGreaterThan(0);
}).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
);
it.effect("session/set_model accepts a no-op switch to the current model", () =>
Effect.gen(function* () {
const runtime = yield* makeProbeRuntime;
const started = yield* runtime.start();
const currentModelId = started.sessionSetupResult.models?.currentModelId?.trim();
expect(currentModelId).toBeDefined();
if (!currentModelId) return;
// No-op switch — selecting the model the session already runs on must
// succeed against every Grok build that implements `session/set_model`.
yield* runtime.setSessionModel(currentModelId);
}).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
);
});