Skip to content
Source
Sign inSign up
TanStack/ai
Open History to see the last commit

sandbox-triage-options.ts

80 lines3.1 KB

1/**
2 * Client-safe definitions for use in the /sandboxes page.
3 *
4 * This module deliberately does NOT import from sandbox-triage.ts or any
5 * harness/provider adapter packages (ai-claude-code, ai-codex, etc.) because
6 * those pull in server-only native deps (dockerode, @anthropic-ai/sdk,
7 * @modelcontextprotocol/sdk/server/streamableHttp → @hono/node-server, …)
8 * that must not reach the client bundle. All values here are pure, no imports.
9 */
10​
11// Pure string-literal types — re-exported by sandbox-triage.ts (single source of truth here).
12export type HarnessName = 'claude-code' | 'codex' | 'opencode' | 'grok' | 'acp'
13export type ProviderName = 'docker' | 'local' | 'vercel' | 'daytona' | 'railway'
14export type GrokBuildModel = 'grok-build-0.1' | 'composer-2.5'
15export type GrokBuildProtocol = 'acp' | 'streaming-json'
16export type GrokTransport = 'auto' | 'stdio' | 'websocket'
17export type Verdict = 'relevant' | 'not-relevant' | 'uncertain'
18​
19const VERDICTS: ReadonlySet<Verdict> = new Set([
20 'relevant',
21 'not-relevant',
22 'uncertain',
23])
24​
25/** Read the agent's required `VERDICT: <value>` first line. Returns null if missing/unknown. */
26export function parseVerdict(text: string): Verdict | null {
27 const line = text.split('\n').find((l) => /^\s*verdict\s*:/i.test(l))
28 if (!line) return null
29 const value = line.split(':')[1]?.trim().toLowerCase()
30 return value && VERDICTS.has(value as Verdict) ? (value as Verdict) : null
32​
33// Picker-safe shape: only the label, no factory functions or server-only deps.
34export interface PickerSpec {
35 label: string
37​
38export const HARNESSES: Record<string, PickerSpec> = {
39 grok: { label: 'Grok Build' },
40 acp: { label: 'ACP compatible (Grok)' },
41 'claude-code': { label: 'Claude Code' },
42 codex: { label: 'Codex' },
43 opencode: { label: 'OpenCode' },
45​
46export const GROK_MODEL_OPTIONS = [
47 { value: 'composer-2.5', label: 'Composer 2.5' },
48 { value: 'grok-build-0.1', label: 'grok-build-0.1' },
49] as const satisfies ReadonlyArray<{ value: GrokBuildModel; label: string }>
50​
51export const GROK_PROTOCOL_OPTIONS = [
52 { value: 'acp', label: 'ACP (default)' },
53 { value: 'streaming-json', label: 'streaming-json' },
54] as const satisfies ReadonlyArray<{ value: GrokBuildProtocol; label: string }>
55​
56export const GROK_TRANSPORT_OPTIONS = [
57 { value: 'auto', label: 'auto' },
58 { value: 'stdio', label: 'stdio' },
59 { value: 'websocket', label: 'websocket' },
60] as const satisfies ReadonlyArray<{ value: GrokTransport; label: string }>
61​
62export function isGrokModel(value: unknown): value is GrokBuildModel {
63 return GROK_MODEL_OPTIONS.some((o) => o.value === value)
65​
66export function isGrokProtocol(value: unknown): value is GrokBuildProtocol {
67 return GROK_PROTOCOL_OPTIONS.some((o) => o.value === value)
69​
70export function isGrokTransport(value: unknown): value is GrokTransport {
71 return GROK_TRANSPORT_OPTIONS.some((o) => o.value === value)
73​
74export const PROVIDERS: Record<string, PickerSpec> = {
75 docker: { label: 'Docker' },
76 local: { label: 'Local process' },
77 vercel: { label: 'Vercel' },
78 daytona: { label: 'Daytona' },
79 railway: { label: 'Railway' },