fix(grok): health check, model selection, and stop all work against the real CLI #9154
Mergedt3dotgg(GitHub profile, opens in a new tab)merged 9 commits into
main fromrefs/pull/9154/headmerged by t3dotgg(GitHub profile, opens in a new tab) View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
- apps/server/src/provider/Layers/GrokProvider.test.ts line 1OutdatedResolvedby t3dotgg(GitHub profile, opens in a new tab)@@ -0,0 +1 @@1+// @effect-diagnostics nodeBuiltinImport:off
- apps/server/src/provider/Layers/GrokProvider.ts lines 428 to 428OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -354,3 +419,10 @@354419 });355420 }356421422+ // `grok models` reports login state and model slugs without starting the agent.423+ const modelsResult = yield* runGrokCliCommand(grokSettings, ["models"], environment).pipe(424+ Effect.timeoutOption(AUTH_PROBE_TIMEOUT_MS),425+ Effect.result,426+ );427+ const cliModels: GrokModelsCliOutput =428+ Result.isSuccess(modelsResult) && Option.isSome(modelsResult.success)apps/server/src/provider/Layers/GrokAdapter.ts line 1684Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -1663,7 +1671,14 @@1663- Ref.set(1664- promptFailureMessageRef,1665- mapAcpToAdapterError(PROVIDER, input.threadId, "session/prompt", error).message,1666- ).pipe(Effect.andThen(prepared.acp.drainEvents)),1667- ),1668- Effect.mapError((error) =>1669- mapAcpToAdapterError(PROVIDER, input.threadId, "session/prompt", error),1671+ const promptStart = yield* prepared.promptLifecycle.withPermit(1672+ Effect.gen(function* () {1673+ const liveCtx = sessions.get(input.threadId);1674+ const interrupted = liveCtx?.interruptedTurnIds.has(prepared.turnId) === true;1675+ if (1676+ !liveCtx ||1677+ liveCtx.acpSessionId !== prepared.acpSessionId ||1678+ prepared.promptEpoch < liveCtx.discardBeforeEpoch ||1679+ interrupted1680+ ) {1681+ return { _tag: "Skipped" as const, interrupted };1682+ }1683+ if (prepared.steeringTurnId !== undefined) {1684+ yield* Effect.ignore(
- apps/server/src/provider/Layers/GrokAdapter.ts line 1755Resolvedby t3dotgg(GitHub profile, opens in a new tab)@@ -1671,0 +1735,21 @@1735+ const result = yield* Fiber.join(promptStart.fiber).pipe(1736+ Effect.tap((promptResult) =>1737+ Effect.all(1738+ [1739+ Ref.set(promptRpcSucceeded, true),1740+ Ref.set(promptResultRef, promptResult),1741+ markPromptResponseReady(input.threadId, prepared.acpSessionId, prepared.turnId),1742+ ],1743+ { discard: true },1744+ ),1745+ ),1746+ Effect.tapError((error) =>1747+ Ref.set(1748+ promptFailureMessageRef,1749+ mapAcpToAdapterError(PROVIDER, input.threadId, "session/prompt", error).message,1750+ ).pipe(Effect.andThen(prepared.acp.drainEvents)),1751+ ),1752+ Effect.mapError((error) =>1753+ mapAcpToAdapterError(PROVIDER, input.threadId, "session/prompt", error),1754+ ),1755+ );
- apps/server/src/provider/Layers/GrokAdapter.ts lines 1684 to 1690Resolvedby t3dotgg(GitHub profile, opens in a new tab)@@ -1669 +1671,20 @@1669- mapAcpToAdapterError(PROVIDER, input.threadId, "session/prompt", error),1671+ const promptStart = yield* prepared.promptLifecycle.withPermit(1672+ Effect.gen(function* () {1673+ const liveCtx = sessions.get(input.threadId);1674+ const interrupted = liveCtx?.interruptedTurnIds.has(prepared.turnId) === true;1675+ if (1676+ !liveCtx ||1677+ liveCtx.acpSessionId !== prepared.acpSessionId ||1678+ prepared.promptEpoch < liveCtx.discardBeforeEpoch ||1679+ interrupted1680+ ) {1681+ return { _tag: "Skipped" as const, interrupted };1682+ }1683+ if (prepared.steeringTurnId !== undefined) {1684+ yield* Effect.ignore(1685+ liveCtx.acp.cancel.pipe(1686+ Effect.mapError((error) =>1687+ mapAcpToAdapterError(PROVIDER, input.threadId, "session/cancel", error),1688+ ),1689+ ),1690+ );
t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.


macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed