Skip to content

armgit / ODS

Public Imported from GitHub
0

ODS V3 Pre-Release: Public testing and refinement ahead of the official V3 launch. Turn your PC, Mac, or Linux box into a private AI server.

fix(pixel): drop a reply that links a made-up preview URL (#8283)

Mike Bradley4790d5019b9b
diff --git a/ods/extensions/services/pixel-agent/plugin/preview-explanation.mjs b/ods/extensions/services/pixel-agent/plugin/preview-explanation.mjs
index 118c4b5b7..e8a79bc1e 100644
--- a/ods/extensions/services/pixel-agent/plugin/preview-explanation.mjs
+++ b/ods/extensions/services/pixel-agent/plugin/preview-explanation.mjs
@@ -25,8 +25,9 @@
// The prose passes the filter every host-composed answer passes
// (deliverableAnswer in progress-finalization.mjs). It is dropped, and the host
// delivery stands alone, when it is empty or too short, silent (NO_REPLY),
-// tool-call text, when it links any local URL other than this outcome's own
-// preview, or when it carries Portal's own wording (its check label or receipt
+// tool-call text, when it links any local URL, or any URL naming a preview
+// site, other than this outcome's own preview (a made-up preview link on an
+// invented host), or when it carries Portal's own wording (its check label or receipt
// lines, however markdown or HTML draws them): a copied or imitated host note
// must not read as Portal's. Everything added here is fixed English text.
import { NARRATION, deliverableAnswer } from './progress-finalization.mjs';
diff --git a/ods/extensions/services/pixel-agent/plugin/progress-finalization.mjs b/ods/extensions/services/pixel-agent/plugin/progress-finalization.mjs
index 4457944bc..19efc5182 100644
--- a/ods/extensions/services/pixel-agent/plugin/progress-finalization.mjs
+++ b/ods/extensions/services/pixel-agent/plugin/progress-finalization.mjs
@@ -62,6 +62,10 @@ const CONTROL_CHARACTERS = /[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/g;
// Tool-call syntax emitted as text is an attempted call, not an answer.
const TOOL_CALL_TEXT = /<\/?tool_call\b|<\|tool_call|<function[=\s>]|<\/function>|"tool_calls"\s*:|^\s*\{\s*"name"\s*:\s*"[^"\n]{1,128}"\s*,\s*"(?:arguments|parameters)"\s*:/m;
const LOCAL_URL = /\b(?:https?|wss?):\/\/(?:[^\s/?#@]*@)?(?:localhost|[a-z0-9.-]*\.localhost|127(?:\.\d{1,3}){3}|0\.0\.0\.0|\[::1?\]|host\.docker\.internal)(?::\d+)?(?:[/?#][^\s<>"'`)\]]*)?/gi;
+// Any link that names a workspace preview site, on whatever host. Unless it is
+// the allowed preview, the model made it up (Workstation06, 2026-10-27:
+// https://portal-odsp-….d.ods.workspace/preview/site-c9def…/… for a real site).
+const PREVIEW_SITE_URL = /\b(?:https?|wss?):\/\/[^\s<>"'`)\]]*\bsite-[0-9a-f]{24}\b[^\s<>"'`)\]]*/gi;
// Returns the sanitized answer, or undefined when it cannot be delivered.
export function progressFinalizationAnswer(text, options) {
@@ -73,7 +77,8 @@ export function progressFinalizationAnswer(text, options) {
// The checks every host-composed answer needs (preview-explanation.mjs too):
// visible text within bounds, no tool-call text or echoed stop text, and, when
-// local URLs are forbidden, none other than the allowed preview.
+// local URLs are forbidden, no local or preview-site link other than the
+// allowed preview.
export function deliverableAnswer(text, {localUrlsForbidden = false, allowedUrls = []} = {}) {
if (typeof text !== 'string') return undefined;
const answer = text.replace(CONTROL_CHARACTERS, '').trim();
@@ -84,7 +89,7 @@ export function deliverableAnswer(text, {localUrlsForbidden = false, allowedUrls
// Echoing the stop text or instruction is not an answer to the owner.
if (answer.includes(RUN_PROGRESS_STOP_REASON) || answer.includes('[ODS Pixel tool limit]')) return undefined;
if (localUrlsForbidden) {
- for (const match of answer.matchAll(LOCAL_URL)) {
+ for (const match of [...answer.matchAll(LOCAL_URL), ...answer.matchAll(PREVIEW_SITE_URL)]) {
const url = match[0].replace(/[.,;:!?]+$/, '');
if (!allowedUrls.some(allowed => typeof allowed === 'string' && allowed && url.startsWith(allowed.replace(/\/$/, ''))))
return undefined;
diff --git a/ods/extensions/services/pixel-agent/tests/preview_explanation_delivery.test.mjs b/ods/extensions/services/pixel-agent/tests/preview_explanation_delivery.test.mjs
index 549f90f0e..bcfaebb4b 100644
--- a/ods/extensions/services/pixel-agent/tests/preview_explanation_delivery.test.mjs
+++ b/ods/extensions/services/pixel-agent/tests/preview_explanation_delivery.test.mjs
@@ -249,6 +249,9 @@ for (const [name, reply] of [['empty', ''], ['whitespace', ' \n\t '], ['silent',
['copied stale link', 'Compare the earlier build: [Open last published preview](https://example.invalid/).'],
['another local URL', 'The arena draws again on the dev server at http://localhost:3000/ so it looks fixed to me.'],
['a stale preview link', 'Open the earlier build at http://site-0123456789abcdef01234567.localhost:9437/site-0123456789abcdef01234567/ to compare.'],
+ // Workstation06 visitor round 4 (2026-10-27): the real site id on an invented host.
+ ['a made-up link to this preview', preview => `The splitter is complete and verified.\n\n**Preview:** ` +
+ `https://portal-odsp-6682973191603e0a3ef78eca1.d.ods.workspace/preview/${preview.siteId}/${preview.sha256}`],
['too long', `The arena fill comes from line 748. ${'Detail. '.repeat(3000)}`]]) {
test(`${name} final reply keeps the existing host-only delivery`, async () => {
const plain = await elfTurn();