Import packages/plugin/src/codex/session-id.ts
This commit is contained in:
parent
4d6bab9022
commit
ce31dacf72
|
|
@ -0,0 +1,14 @@
|
|||
import { RpcError } from '../safe-error.js'
|
||||
|
||||
/** Parse the public CodeX session identity without treating it as a Harness agent id. */
|
||||
export function parseCodexSessionId(value: unknown): { sessionId: string; threadId: string } | undefined {
|
||||
if (typeof value !== 'string') return undefined
|
||||
const match = /^codex:([A-Za-z0-9][A-Za-z0-9._-]{0,255})$/.exec(value)
|
||||
return match === null ? undefined : { sessionId: value, threadId: match[1]! }
|
||||
}
|
||||
|
||||
export function requireCodexSessionId(value: unknown): { sessionId: string; threadId: string } {
|
||||
const parsed = parseCodexSessionId(value)
|
||||
if (parsed === undefined) throw new RpcError('CODEX_SESSION_INVALID', 'The CodeX session identifier is invalid.')
|
||||
return parsed
|
||||
}
|
||||
Loading…
Reference in New Issue