diff --git a/scripts/src/hwlab-node-web-observe-runner-source.ts b/scripts/src/hwlab-node-web-observe-runner-source.ts index 7c380872..ef30cc2d 100644 --- a/scripts/src/hwlab-node-web-observe-runner-source.ts +++ b/scripts/src/hwlab-node-web-observe-runner-source.ts @@ -369,7 +369,13 @@ async function sendPrompt(text) { if (chatStatus < 200 || chatStatus >= 300) { throw new Error("sendPrompt observed POST /v1/agent/chat HTTP " + chatStatus + " " + chatResponse.statusText()); } - return { beforeUrl, afterUrl: currentPageUrl(), textHash: sha256Text(text), textBytes: Buffer.byteLength(text), chatSubmit: { status: chatStatus, statusText: chatResponse.statusText(), urlPath: urlPath(chatResponse.url()) }, pageId }; + let chatUrlPath = "/v1/agent/chat"; + try { + chatUrlPath = new URL(chatResponse.url()).pathname; + } catch { + chatUrlPath = "/v1/agent/chat"; + } + return { beforeUrl, afterUrl: currentPageUrl(), textHash: sha256Text(text), textBytes: Buffer.byteLength(text), chatSubmit: { status: chatStatus, statusText: chatResponse.statusText(), urlPath: chatUrlPath }, pageId }; } async function selectProvider(provider) {