Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
address review (codex): match lifecycle telemetry by message, not by leading emoji
[._.]/ Adam Eivy1ac1fbd3f819
diff --git a/server/lib/README.md b/server/lib/README.mdindex a8d1af37f0..8d4bf49544 100644--- a/server/lib/README.md+++ b/server/lib/README.md@@ -24,7 +24,7 @@ The barrel `server/lib/index.js` is a machine-checkable enumeration of every pub| Module | Purpose ||---|---|| `validation.js` | Catch-all Zod schemas (app/process/provider, social accounts, GitHub, backup/sharing, document/legacy-export) + the `validateRequest` middleware + shared helpers (`optionalBooleanMap`, `isSafeRecordId`, `parsePagination`). Re-exports the per-domain validation files below so existing deep imports keep working. |-| `agentOutputMarkers.js` | Status lines PortOS itself appends to an agent's output buffer: `SENTINEL_COMPLETION_MARKER` (the line `ingestDoneSentinel` writes just before the agent's `.agent-done` summary) plus `RE_AGENT_LIFECYCLE_LINE`/`stripLifecycleLines(lines)`. Pure — shared by the emitter (`services/agentTuiSpawning.js`) and by readers that must show only the agent's own words (notably the generated PR description). |+| `agentOutputMarkers.js` | Status lines PortOS itself appends to an agent's output buffer: `SENTINEL_COMPLETION_MARKER` (the line `ingestDoneSentinel` writes just before the agent's `.agent-done` summary) plus `isAgentLifecycleLine(line)`/`stripLifecycleLines(lines)`, which match PortOS's telemetry on its actual message shapes rather than on a leading emoji (an agent's own summary may well start a line with `✅`). Pure — shared by the emitter (`services/agentTuiSpawning.js`) and by readers that must show only the agent's own words (notably the generated PR description). || `agentSentinel.js` | The `.agent-done` completion sentinel: `DONE_SENTINEL_NAME` + pure `parseSentinelPayload(contents)` → `{ summary, payload }`. Back-compat — a plain-markdown sentinel yields `payload: null`; a JSON object yields its structured `payload` for a programmatic-I/O task type's `processTaskOutput` hook. `salvageSentinelPayload(contents)` (async) is the lenient second tier — runs `jsonExtract` over a fenced/prose-trailed/control-char-corrupted envelope so a less-capable model's near-valid output still surfaces its `payload` instead of being dropped. || `agentValidation.js` | Social-bot agent schemas (personality, Moltbook/Moltworld accounts, automation schedules, agent tools + Moltworld payloads) and CoS Feature Agent definitions. || `quotaReset.js` | Normalizes provider quota reset timestamps and computes time remaining without treating unknown values as imminent resets. |diff --git a/server/lib/agentOutputMarkers.js b/server/lib/agentOutputMarkers.jsindex b171cc182b..0ee415ca07 100644--- a/server/lib/agentOutputMarkers.js+++ b/server/lib/agentOutputMarkers.js@@ -20,14 +20,41 @@export const SENTINEL_COMPLETION_MARKER = '✅ Agent signaled completion';/**- * Matches a PortOS-authored lifecycle status line. These are all emitted via the- * output spooler's `appendLine` with a leading emoji + space — a shape the agent's- * own summary essentially never takes, since it writes markdown (a bullet leads- * with `-`, a heading with `#`). Base codepoints with an optional VS16 (`️`),- * because the emitters are inconsistent about the variation selector (`⚠️` carries- * one, `⚡` does not) and a literal-only match would miss half of them.+ * The PortOS-authored lifecycle status lines, matched on their actual message+ * shapes — deliberately NOT "any line starting with an emoji."+ *+ * The agent's own summary is markdown, but nothing stops it from writing a+ * checklist line like `✅ Tests passed` or `⚠️ Known limitation: …` with no+ * leading `-`. A bare emoji-prefix test would classify those as telemetry and+ * silently delete them from the PR description — and a summary made mostly of+ * such lines could shrink under `extractAgentSummary`'s minimum length and fall+ * all the way back to commit messages. Anchoring on the message text means only+ * lines PortOS actually emits can match.+ *+ * Kept in sync with `appendLine` in `services/agentTuiSpawning.js`. Not listed:+ * the generic `❌ <summary>` from `finishStartupFailure`, whose text comes from+ * its caller and so has no fixed shape to anchor on — it only fires on a startup+ * failure, which finalizes the agent unsuccessfully and never opens a PR.+ */+const LIFECYCLE_LINE_PATTERNS = [+ /^\s*📟 TUI session started: /u,+ /^\s*📟 Prompt pasted into TUI session /u,+ /^\s*📟 Auto-confirmed .+ folder-trust prompt for session /u,+ /^\s*💡 Open the Shell tab /u,+ /^\s*⚡ Provider fallback signal: /u,+ /^\s*⏳ Max runtime reached — /u,+ /^\s*⚠️?\s*Paste verification failed /u,+ /^\s*❌ Paste (?:never landed|verification failed) /u,+];++/**+ * Is this line PortOS lifecycle telemetry rather than something the agent said?+ * @param {string} line+ * @returns {boolean}*/-export const RE_AGENT_LIFECYCLE_LINE = /^\s*(?:📟|💡|⚡|⏳|⚠|❌|✅|🌳)️?\s/u;+export function isAgentLifecycleLine(line) {+ return LIFECYCLE_LINE_PATTERNS.some(re => re.test(line));+}/*** Drop PortOS lifecycle status lines from an array of output lines.@@ -35,5 +62,5 @@ export const RE_AGENT_LIFECYCLE_LINE = /^\s*(?:📟|💡|⚡|⏳|⚠|❌|✅|* @returns {string[]}*/export function stripLifecycleLines(lines) {- return lines.filter(line => !RE_AGENT_LIFECYCLE_LINE.test(line));+ return lines.filter(line => !isAgentLifecycleLine(line));}diff --git a/server/lib/gitOutputParsers.js b/server/lib/gitOutputParsers.jsindex 0a06d71e5c..534021dfe9 100644--- a/server/lib/gitOutputParsers.js+++ b/server/lib/gitOutputParsers.js@@ -114,6 +114,11 @@ export function extractAgentSummary(output) {let summaryLines;if (markerIdx >= 0) {+ // Everything past the marker is the sentinel, appended verbatim and+ // contiguously by `ingestDoneSentinel` at the top of finalize — no other+ // `appendLine` runs after it. So take it as-is: filtering here could only+ // ever delete the agent's own words (a summary is free to contain a line+ // like "✅ Tests passed").summaryLines = lines;} else {// Find the last tool-call artifact line index.@@ -127,10 +132,12 @@ export function extractAgentSummary(output) {}}summaryLines = lastToolLine >= 0 ? lines.slice(lastToolLine + 1) : lines;+ // No marker: a TUI agent that finished without writing a sentinel (idle-+ // complete) leaves a buffer of pure telemetry, which would otherwise become+ // the whole PR body. Drop the lines PortOS is known to emit.+ summaryLines = stripLifecycleLines(summaryLines);}- summaryLines = stripLifecycleLines(summaryLines);-// Trim leading/trailing blank lineswhile (summaryLines.length && !summaryLines[0].trim()) summaryLines.shift();while (summaryLines.length && !summaryLines[summaryLines.length - 1].trim()) summaryLines.pop();diff --git a/server/lib/gitOutputParsers.test.js b/server/lib/gitOutputParsers.test.jsindex e488d0877f..fdaeb10fa1 100644--- a/server/lib/gitOutputParsers.test.js+++ b/server/lib/gitOutputParsers.test.js@@ -165,19 +165,69 @@ describe('extractAgentSummary', () => {expect(summary).toContain('## Changes');});- it('drops mid-run lifecycle warnings that land after the completion marker', () => {+ it('drops mid-run lifecycle warnings that precede the completion marker', () => {const output = ['📟 TUI session started: abc12345 (codex)','⚠️ Paste verification failed — prompt text not found in buffer, retrying in 5000ms',+ '⏳ Max runtime reached — asking the agent to wrap up','✅ Agent signaled completion','Fixed the scan-report route so deep links resolve to the SPA.',- '⏳ Max runtime reached — asking the agent to wrap up',].join('\n');const summary = extractAgentSummary(output);expect(summary).toBe('Fixed the scan-report route so deep links resolve to the SPA.');});+ // The sentinel is appended verbatim and nothing else writes after it, so a+ // summary is free to use emoji-led checklist lines of its own — stripping any+ // emoji-prefixed line would delete the agent's actual words, and a summary made+ // mostly of them could fall under the minimum length and lose the body entirely.+ it('keeps the agent\'s own emoji checklist lines inside the sentinel summary', () => {+ const output = [+ '📟 TUI session started: abc12345 (codex)',+ '💡 Open the Shell tab for live TUI output — this panel only logs lifecycle events.',+ '✅ Agent signaled completion',+ 'Reworked the exporter so every frame lands in the atlas.',+ '✅ Tests passed (1,204 server, 5,298 client)',+ '⚠️ Known limitation: the legacy 8-frame atlas is not resampled.',+ ].join('\n');++ const summary = extractAgentSummary(output);+ expect(summary).toContain('✅ Tests passed (1,204 server, 5,298 client)');+ expect(summary).toContain('⚠️ Known limitation: the legacy 8-frame atlas is not resampled.');+ expect(summary).not.toContain('TUI session started');+ expect(summary).not.toContain('Open the Shell tab');+ });++ // A short summary built entirely of emoji-led lines is exactly the case a bare+ // emoji-prefix filter would erase — it would fall under the 30-char floor and+ // return null, sending the PR body to the commit-message fallback.+ it('does not erase a summary composed of emoji-led lines', () => {+ const output = [+ '📟 TUI session started: abc12345 (codex)',+ '✅ Agent signaled completion',+ '✅ Fixed the crash on empty tag lists',+ '✅ Added a regression test for it',+ ].join('\n');++ expect(extractAgentSummary(output)).toBe(+ '✅ Fixed the crash on empty tag lists\n✅ Added a regression test for it'+ );+ });++ it('drops telemetry when a TUI agent finished without writing a sentinel', () => {+ const output = [+ '📟 TUI session started: abc12345 (codex --model gpt-5.6-terra)',+ '💡 Open the Shell tab for live TUI output — this panel only logs lifecycle events.',+ '📟 Prompt pasted into TUI session abc12345 (ready)',+ 'Rewired the exporter so every frame lands in the atlas rather than the first eight.',+ ].join('\n');++ expect(extractAgentSummary(output)).toBe(+ 'Rewired the exporter so every frame lands in the atlas rather than the first eight.'+ );+ });+it('finds the completion marker even when the sentinel summary runs past the 4000-char tail', () => {const filler = 'x'.repeat(5000);const output = [