Files
orca/src/shared/agent-session/agent-session-agent-availability.ts
T
Neil bf07b8f60e fix(antigravity): say Antigravity Chat isn't available on Windows instead of silently opening a terminal (#38997)
* fix(antigravity): say Antigravity Chat isn't available on Windows instead of silently opening a terminal

Google publishes no Windows agy-acp-server, so a Windows host refused
Antigravity chats with the generic 'agent' reason: launches fell back to a
terminal with no explanation and Settings showed nothing.

A Windows host now reports reason 'windows' (createSupport and published
availability), which launch receipts state as chat_unavailable_on_windows,
the new-tab picker labels 'No chat on Windows yet', and explicit-chat
failures explain. Agents and Accounts settings say so for a Windows host.
The decision is the execution host's OS, so a Windows client chatting on a
macOS or Linux host is unaffected; one predicate
(structuredChatUnavailableOnPlatform) gates it all.

Fixes #30817, STA-11245

* docs: correct chatUnavailableOnThisDesktop comment
2026-11-06 13:59:04 -08:00

70 lines
2.8 KiB
TypeScript

/**
* `agentSession.subscribeAvailability`: the health of this host's installed agents, from each
* agent's location rule and installed-release check on the host itself, not in any workspace.
* Every frame is the complete snapshot and replaces the one before. Published only by hosts
* advertising the availability capability; `agentSession.agents` stays the static list.
*/
import { z } from 'zod'
import { isStructuredAgentId } from './lifecycle/agent-session-provider-handle-encoding'
import { openEnum } from '../zod-salvage'
export const AGENT_SESSION_AVAILABILITY_METHOD = 'agentSession.subscribeAvailability'
/** Whether the program a chat start runs is on this host: `installable` is absent but Orca can
* download it; `unknown` depends on the workspace or could not be read. Older hosts omit it. */
export type AgentSessionChatProgram = 'available' | 'installable' | 'missing' | 'unknown'
/** `refused` carries the reason (`agent`: this host cannot run its chat; `windows`: the agent has
* no chat on a Windows host); `unknown` is a check that could not answer, never a refusal. */
export type AgentSessionAgentAvailability = (
| { agent: string; state: 'available' }
| { agent: string; state: 'refused'; reason?: string }
| { agent: string; state: 'unknown' }
) & { chatProgram?: AgentSessionChatProgram }
export type AgentSessionAvailabilityFrame = {
type: 'availability'
agents: AgentSessionAgentAvailability[]
}
const MAX_AGENTS = 128
const rowSchema = z.object({
agent: z.string().refine(isStructuredAgentId),
// A state this build does not know claims nothing.
state: openEnum(['available', 'refused', 'unknown'] as const, 'unknown'),
reason: z.string().max(64).optional(),
chatProgram: openEnum(['available', 'installable', 'missing', 'unknown'] as const, 'unknown')
.optional()
.catch(undefined)
})
/** One frame's answers by agent, or null when the frame is not an availability frame. */
export function decodeAgentSessionAvailabilityFrame(
value: unknown
): ReadonlyMap<string, AgentSessionAgentAvailability> | null {
if (typeof value !== 'object' || value === null || !('type' in value) || !('agents' in value)) {
return null
}
if (value.type !== 'availability' || !Array.isArray(value.agents)) {
return null
}
const byAgent = new Map<string, AgentSessionAgentAvailability>()
for (const row of value.agents.slice(0, MAX_AGENTS)) {
const parsed = rowSchema.safeParse(row)
if (!parsed.success || byAgent.has(parsed.data.agent)) {
continue
}
const { agent, state, reason, chatProgram } = parsed.data
const program = chatProgram ? { chatProgram } : {}
byAgent.set(
agent,
state === 'refused'
? { agent, state, ...(reason ? { reason } : {}), ...program }
: { agent, state, ...program }
)
}
return byAgent
}