From ce31dacf723cdc1d20b50d9eb20d58ed48adfc99 Mon Sep 17 00:00:00 2001 From: QQ Date: Sat, 14 Nov 2026 14:54:34 +0800 Subject: [PATCH] Import packages/plugin/src/codex/session-id.ts --- packages/plugin/src/codex/session-id.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 packages/plugin/src/codex/session-id.ts diff --git a/packages/plugin/src/codex/session-id.ts b/packages/plugin/src/codex/session-id.ts new file mode 100644 index 0000000..d26a0d9 --- /dev/null +++ b/packages/plugin/src/codex/session-id.ts @@ -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 +}