Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Merge #7648 into train E2
milind-soni8ed94deda9a6
diff --cc server/drivers/acp/core.tsindex 7c13ece257,1333b07731..93a51f36dc--- a/server/drivers/acp/core.ts+++ b/server/drivers/acp/core.ts@@@ -225,17 -225,18 +225,14 @@@ export interface AcpSupport extends Acp): void;/** The authenticate methodId from initialize's authMethods; null skips authenticate. */pickAuthMethod(authMethods: Array<{ id?: string }>, env: Record<string, string | undefined>): string | null;- /** "fail": abort if auth is missing/errors (subscription CLIs).- * "fail-request": cached API credentials need no method, but a requested- * OAuth login must succeed. "continue": proceed on an ambient login. */+ /** Extra authenticate params, e.g. an API key the CLI does not read from the environment. Never logged. */+ authMeta?(env: Record<string, string | undefined>): Record<string, unknown> | undefined;- /** "fail": abort if auth is missing/errors (subscription CLIs).- * "fail-request": cached API credentials need no method, but a requested- * OAuth login must succeed. "continue": proceed on an ambient login. */++ /** "fail": abort if auth is missing/errors (subscription CLIs). "fail-request": cached API credentials need no method,++ * but a requested OAuth login must succeed. "continue": proceed on an ambient login. */authFailure: "fail" | "fail-request" | "continue";/** Whether this CLI can run a turn (env carries the merged config). */-- isAuthenticated(-- env: Record<string, string | undefined>,-- config: AcpConfig,-- instanceId: string, allowEnv?: readonly string[],-- ): boolean | Promise<boolean>;- skipAuthenticateWhenAuthenticated?: boolean;++ isAuthenticated(env: Record<string, string | undefined>, config: AcpConfig, instanceId: string, allowEnv?: readonly string[]): boolean | Promise<boolean>;++ /** Ask isAuthenticated before authenticate: this CLI's login method, run again, clears the login it holds. */ skipAuthenticateWhenAuthenticated?: boolean;/** Refuse a first-party cloud turn before spawning when snapshot auth is* false. Local injected models deliberately bypass this subscription gate. */requireAuthenticationBeforeSpawn?: boolean;@@@ -1091,12 -1092,14 +1088,13 @@@ export function createAcpDriver(support));}if (!skipSubscriptionAuthForLocalInject(turn.model) && !session.authenticated && !support.skipsAuthenticate?.(instanceId)) {- const methods: Array<{ id?: string }> = Array.isArray(session.initResult?.authMethods)- ? session.initResult.authMethods- : [];- const methodId = support.pickAuthMethod(methods, spawnEnv);- if (methodId) {+ const methods = Array.isArray(session.initResult?.authMethods) ? session.initResult.authMethods : [];+ const methodId = support.pickAuthMethod(methods, spawnEnv), skip = methodId && support.skipAuthenticateWhenAuthenticated === true && await support.isAuthenticated(spawnEnv, turnConfig, instanceId, instanceEnvNames(input.environment, spawnEnv));+ if (skip) session.authenticated = true;+ else if (methodId) {+ const meta = support.authMeta?.(spawnEnv);try {- await session.host.once("authenticate", () => retryTransient(request, "authenticate", { methodId }, INIT_TIMEOUT));+ await session.host.once("authenticate", () => retryTransient(request, "authenticate", { methodId, ...(meta ? { _meta: meta } : {}) }, INIT_TIMEOUT));session.authenticated = true;} catch (error) {const failed = signIn.authenticateFailed(error, support.authFailure); if (failed) throw failed;