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

sandbox-options.ts

68 lines2.0 KB

1/**
2 * Harness picker options + type guards shared by the UI and `/api/run` validation.
3 */
4​
5export const HARNESS_OPTIONS = [
6 { value: 'grok', label: 'Grok Build' },
7 { value: 'claude-code', label: 'Claude Code' },
8 { value: 'codex', label: 'Codex' },
9] as const
10​
11export type HarnessName = (typeof HARNESS_OPTIONS)[number]['value']
12​
13/** CUSTOM event name each harness emits so follow-up runs can resume its session. */
14export const HARNESS_SESSION_ID_EVENT: Record<HarnessName, string> = {
15 grok: 'grok-build.session-id',
16 'claude-code': 'claude-code.session-id',
17 codex: 'codex.session-id',
19​
20export const GROK_MODEL_OPTIONS = [
21 { value: 'composer-2.5', label: 'Composer 2.5' },
22 { value: 'grok-build-0.1', label: 'grok-build-0.1' },
23] as const
24​
25export type GrokBuildModel = (typeof GROK_MODEL_OPTIONS)[number]['value']
26​
27export const GROK_PROTOCOL_OPTIONS = [
28 { value: 'acp', label: 'ACP (default)' },
29 { value: 'streaming-json', label: 'streaming-json' },
30] as const
31​
32export type GrokBuildProtocol = (typeof GROK_PROTOCOL_OPTIONS)[number]['value']
33​
34export const GROK_TRANSPORT_OPTIONS = [
35 { value: 'auto', label: 'auto' },
36 { value: 'stdio', label: 'stdio' },
37 { value: 'websocket', label: 'websocket' },
38] as const
39​
40export type GrokTransport = (typeof GROK_TRANSPORT_OPTIONS)[number]['value']
41​
42export function isHarness(value: unknown): value is HarnessName {
43 return (
44 typeof value === 'string' &&
45 HARNESS_OPTIONS.some((option) => option.value === value)
46 )
48​
49export function isGrokModel(value: unknown): value is GrokBuildModel {
50 return (
51 typeof value === 'string' &&
52 GROK_MODEL_OPTIONS.some((option) => option.value === value)
53 )
55​
56export function isGrokProtocol(value: unknown): value is GrokBuildProtocol {
57 return (
58 typeof value === 'string' &&
59 GROK_PROTOCOL_OPTIONS.some((option) => option.value === value)
60 )
62​
63export function isGrokTransport(value: unknown): value is GrokTransport {
64 return (
65 typeof value === 'string' &&
66 GROK_TRANSPORT_OPTIONS.some((option) => option.value === value)
67 )