| 88 | } |
| 89 | |
| 90 | export function createArcticTui(options?: TuiOptions) { |
| 91 | const args = [] |
| 92 | |
| 93 | if (options?.project) { |
| 94 | args.push(`--project=${options.project}`) |
| 95 | } |
| 96 | if (options?.model) { |
| 97 | args.push(`--model=${options.model}`) |
| 98 | } |
| 99 | if (options?.session) { |
| 100 | args.push(`--session=${options.session}`) |
| 101 | } |
| 102 | if (options?.agent) { |
| 103 | args.push(`--agent=${options.agent}`) |
| 104 | } |
| 105 | |
| 106 | const proc = spawn(`arctic`, args, { |
| 107 | signal: options?.signal, |
| 108 | stdio: "inherit", |
| 109 | env: { |
| 110 | ...process.env, |
| 111 | ARCTIC_CONFIG_CONTENT: JSON.stringify(options?.config ?? {}), |
| 112 | }, |
| 113 | }) |
| 114 | |
| 115 | return { |
| 116 | close() { |
| 117 | proc.kill() |
| 118 | }, |
| 119 | } |
| 120 | } |