| 151 | } |
| 152 | |
| 153 | function parsePragmaTimeout(code: string): number | undefined { |
| 154 | const firstLine = code.split('\n', 1)[0]?.trimStart() ?? '' |
| 155 | if (!firstLine.startsWith('# codex-py-repl:')) { |
| 156 | return undefined |
| 157 | } |
| 158 | const pragma = firstLine.slice('# codex-py-repl:'.length).trim() |
| 159 | for (const token of pragma.split(/\s+/)) { |
| 160 | const [key, value] = token.split('=') |
| 161 | if (key !== 'timeout_ms' || !value) continue |
| 162 | const parsed = Number.parseInt(value, 10) |
| 163 | if (Number.isFinite(parsed) && parsed >= 1 && parsed <= MAX_TIMEOUT_MS) { |
| 164 | return parsed |
| 165 | } |
| 166 | } |
| 167 | return undefined |
| 168 | } |
| 169 | |
| 170 | function compareVersion(left: readonly number[], right: readonly number[]): number { |
| 171 | const length = Math.max(left.length, right.length) |