MCPcopy Create free account
hub / github.com/Noumena-Network/code / parsePragmaTimeout

Function parsePragmaTimeout

src/tools/REPLTool/pyReplFactory.tsx:153–168  ·  view source on GitHub ↗
(code: string)

Source from the content-addressed store, hash-verified

151}
152
153function 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
170function compareVersion(left: readonly number[], right: readonly number[]): number {
171 const length = Math.max(left.length, right.length)

Callers 1

callFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected