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
feat(cos): prompt viewer + paste-marker handshake + lifecycle line breaks
[._.]/ Adam Eivybd33f5abb9ea
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex b6b9e6cacb..386b15f5ce 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -981,6 +981,42 @@annotations on failure lines so the PR view links straight to theoffending assertion. Local `npm test` is unchanged.+- **AgentCard adds a "Prompt" button that opens the exact prompt the agent+ was given at spawn.** Useful for iterating on prompt content: the user+ can read what was pasted into the TUI / sent to the CLI, decide what's+ redundant, and trim the prompt template. New endpoint+ `GET /api/cos/agents/:id/prompt` reads the agent's saved `prompt.txt`+ (running agents from the flat dir, completed agents via the+ date-bucket index). The modal includes a "Copy" button so the prompt+ can be pasted into another tool for editing.++- **Lifecycle markers (📟 / 💡 / ✅) render as their own lines in the agent+ output panel.** Previously they collapsed onto a single line because+ `OutputBlocks` joined consecutive non-tool lines with `\n` and markdown+ collapses single newlines into spaces. Lifecycle marker lines now+ flush the current markdown block and render as standalone `<div>`s,+ mirroring the existing tool-line carve-out.++- **TUI paste→Enter handshake now waits for Claude Code's+ `[Pasted text #N]` marker instead of a fixed 400 ms delay.** Large+ prompts (seen on an 87-line paste) raced the fixed timer: Claude Code+ was still committing the paste buffer when the Enter fired, so the+ Enter was silently dropped and the user had to press Return manually.+ The spawner now polls `rawBuffer` for Claude Code's paste-commit+ marker, waits an additional 200 ms, then submits. A 3.5 s fallback+ timer fires the Enter unconditionally for prompts too small to+ trigger the marker.++- **Bad "the system will push" lines purged from the prompt for TUI+ agents.** Several spots in the prompt template still told TUI agents+ "the system will push your branch and open a pull request — do NOT+ push or open a PR yourself" even though the TUI path delegates the+ whole sequence to the agent via `/do:pr`. The Instructions step 4,+ the worktree+openPR Guideline bullet, and the Git Hygiene+ push-or-not bullet now branch on `isTui` and tell the agent to run+ the Completion Workflow's `tuiCompletionCommand` (`/do:pr` or+ `/do:push`) itself.+- **TUI agents now write a markdown task summary into `.agent-done` andPortOS ingests it as the agent's `outputBuffer`.** With per-line PTYcapture off, the agent card's "Show output" panel only showeddiff --git a/client/src/components/cos/OutputBlocks.jsx b/client/src/components/cos/OutputBlocks.jsxindex 56afe9007f..9471a2c92d 100644--- a/client/src/components/cos/OutputBlocks.jsx+++ b/client/src/components/cos/OutputBlocks.jsx@@ -4,6 +4,15 @@ import MarkdownOutput from './MarkdownOutput';export const isToolLine = (line) =>line.startsWith('🔧') || line.startsWith(' →') || line.startsWith(' ↳') || line.startsWith('[stderr]');+// Lifecycle marker lines (emitted from agentTuiSpawning.js for TUI agents)+// should render as their own one-line blocks instead of getting collapsed into+// the surrounding markdown — markdown joins consecutive single-`\n` lines+// onto one rendered line, which made the 📟 / 💡 / ✅ events run together+// in the CoS agent output panel.+const LIFECYCLE_PREFIXES = ['📟', '💡', '✅'];+export const isLifecycleLine = (line) =>+ LIFECYCLE_PREFIXES.some(p => line.startsWith(p));+const INITIAL_BLOCKS = 80;const LOAD_MORE_BLOCKS = 120;@@ -21,13 +30,18 @@ function renderBlock(block, i) {}return <div key={i} className="py-0.5 text-xs font-mono text-yellow-500 break-all">{line}</div>;}+ if (block.type === 'lifecycle') {+ return <div key={i} className="py-0.5 text-xs text-gray-400 break-words">{block.line}</div>;+ }return <MarkdownOutput key={i} content={block.content} />;}export default function OutputBlocks({ output }) {const [visibleCount, setVisibleCount] = useState(INITIAL_BLOCKS);- // Group consecutive lines: tool lines render as monospace, content lines as markdown+ // Group consecutive lines: tool lines render as monospace, lifecycle markers+ // render as their own one-line blocks, content lines fold into a single+ // markdown block.const blocks = useMemo(() => {const result = [];let mdLines = [];@@ -44,6 +58,9 @@ export default function OutputBlocks({ output }) {if (isToolLine(line)) {flushMd();result.push({ type: 'tool', line });+ } else if (isLifecycleLine(line)) {+ flushMd();+ result.push({ type: 'lifecycle', line });} else {mdLines.push(line);}diff --git a/client/src/components/cos/tabs/AgentCard.jsx b/client/src/components/cos/tabs/AgentCard.jsxindex b020a89650..c96c37328d 100644--- a/client/src/components/cos/tabs/AgentCard.jsx+++ b/client/src/components/cos/tabs/AgentCard.jsx@@ -110,6 +110,10 @@ export default function AgentCard({ agent, onKill, onDelete, onResume, completedconst [btwInput, setBtwInput] = useState('');const [sendingBtw, setSendingBtw] = useState(false);const [btwMessages, setBtwMessages] = useState(agent.btwMessages || []);+ const [promptContent, setPromptContent] = useState(null);+ const [promptOpen, setPromptOpen] = useState(false);+ const [loadingPrompt, setLoadingPrompt] = useState(false);+ const [promptError, setPromptError] = useState(null);// Sync feedback state when parent refreshes agent datauseEffect(() => {@@ -151,6 +155,29 @@ export default function AgentCard({ agent, onKill, onDelete, onResume, completed}}, [agent.id, feedbackComment, submittingFeedback, onFeedbackChange]);+ // Open the prompt modal — lazy-fetches prompt.txt the first time it opens.+ // Useful for iterating on the prompt itself (the user can see exactly what+ // was pasted into the TUI / sent to the CLI and decide what to trim).+ const openPromptModal = useCallback(async () => {+ setPromptOpen(true);+ if (promptContent !== null || loadingPrompt) return;+ setLoadingPrompt(true);+ setPromptError(null);+ const result = await api.getCosAgentPrompt(agent.id).catch(err => {+ setPromptError(err.message);+ return null;+ });+ setLoadingPrompt(false);+ if (result?.prompt) setPromptContent(result.prompt);+ }, [agent.id, promptContent, loadingPrompt]);++ const copyPromptToClipboard = useCallback(() => {+ if (!promptContent) return;+ navigator.clipboard.writeText(promptContent)+ .then(() => toast.success('Prompt copied to clipboard'))+ .catch(err => toast.error(`Failed to copy: ${err.message}`));+ }, [promptContent]);+// Send BTW message to running agentconst sendBtw = useCallback(async () => {if (sendingBtw || !btwInput.trim()) return;@@ -503,6 +530,16 @@ export default function AgentCard({ agent, onKill, onDelete, onResume, completed<span className="font-mono">shell {agent.metadata.tuiSessionId.slice(0, 6)}</span></Link>)}+ {!remote && (+ <button+ onClick={openPromptModal}+ className="flex items-center gap-1 px-2 py-0.5 rounded bg-port-border/40 text-gray-400 hover:bg-port-border/60 hover:text-white whitespace-nowrap"+ title="View the prompt this agent was given at spawn"+ >+ <MessageSquare size={10} aria-hidden="true" className="shrink-0" />+ <span>Prompt</span>+ </button>+ )}{/* Show zombie warning if PID exists but process is dead */}{!completed && agent.pid && processStats && !processStats.active && (<span className="flex items-center gap-1 px-2 py-0.5 rounded bg-port-error/20 text-port-error whitespace-nowrap"@@ -870,6 +907,60 @@ export default function AgentCard({ agent, onKill, onDelete, onResume, completed})()}</div>)}+ {promptOpen && (+ <div+ className="fixed inset-0 z-50 bg-black/70 flex items-center justify-center p-4"+ onClick={() => setPromptOpen(false)}+ >+ <div+ className="bg-port-card border border-port-border rounded-lg max-w-4xl w-full max-h-[80vh] flex flex-col"+ onClick={(e) => e.stopPropagation()}+ >+ <div className="flex items-center justify-between px-4 py-2 border-b border-port-border shrink-0">+ <div className="flex items-center gap-2">+ <MessageSquare size={14} className="text-gray-400" aria-hidden="true" />+ <span className="text-sm text-gray-300">Agent prompt</span>+ {promptContent && (+ <span className="text-xs text-gray-500 font-mono">+ {promptContent.length.toLocaleString()} chars · {promptContent.split('\n').length} lines+ </span>+ )}+ </div>+ <div className="flex items-center gap-2">+ {promptContent && (+ <button+ onClick={copyPromptToClipboard}+ className="text-xs px-2 py-1 rounded bg-port-border/40 text-gray-400 hover:text-white"+ >+ Copy+ </button>+ )}+ <button+ onClick={() => setPromptOpen(false)}+ className="text-xs px-2 py-1 rounded bg-port-border/40 text-gray-400 hover:text-white"+ aria-label="Close prompt viewer"+ >+ Close+ </button>+ </div>+ </div>+ <div className="flex-1 overflow-auto p-4">+ {loadingPrompt && (+ <div className="flex items-center gap-2 text-gray-500 text-sm">+ <Loader2 size={14} aria-hidden="true" className="animate-spin" />+ Loading prompt…+ </div>+ )}+ {promptError && (+ <div className="text-port-error text-sm">{promptError}</div>+ )}+ {!loadingPrompt && !promptError && promptContent != null && (+ <pre className="text-xs text-gray-300 font-mono whitespace-pre-wrap break-words">{promptContent}</pre>+ )}+ </div>+ </div>+ </div>+ )}</div>);}diff --git a/client/src/services/apiAgents.js b/client/src/services/apiAgents.jsindex 7d50979f43..196bdf47eb 100644--- a/client/src/services/apiAgents.js+++ b/client/src/services/apiAgents.js@@ -83,6 +83,7 @@ export const getCosAgent = (id) => request(`/cos/agents/${id}`);export const terminateCosAgent = (id) => request(`/cos/agents/${id}/terminate`, { method: 'POST' });export const killCosAgent = (id) => request(`/cos/agents/${id}/kill`, { method: 'POST' });export const getCosAgentStats = (id) => request(`/cos/agents/${id}/stats`);+export const getCosAgentPrompt = (id) => request(`/cos/agents/${id}/prompt`);export const deleteCosAgent = (id) => request(`/cos/agents/${id}`, { method: 'DELETE' });export const clearCompletedCosAgents = () => request('/cos/agents/completed', { method: 'DELETE' });export const submitCosAgentFeedback = (id, feedback) => request(`/cos/agents/${id}/feedback`, {diff --git a/server/routes/cosAgentRoutes.js b/server/routes/cosAgentRoutes.jsindex ee07a5096a..471215ec33 100644--- a/server/routes/cosAgentRoutes.js+++ b/server/routes/cosAgentRoutes.js@@ -53,6 +53,15 @@ router.get('/agents/:id', asyncHandler(async (req, res) => {res.json(agent);}));+// GET /api/cos/agents/:id/prompt - Read the prompt.txt saved at spawn time+router.get('/agents/:id/prompt', asyncHandler(async (req, res) => {+ const result = await cos.getAgentPrompt(req.params.id);+ if (result.error) {+ throw new ServerError(result.error, { status: 404, code: 'NOT_FOUND' });+ }+ res.json(result);+}));+// POST /api/cos/agents/:id/terminate - Terminate agent (graceful SIGTERM, then SIGKILL)router.post('/agents/:id/terminate', asyncHandler(async (req, res) => {const result = await cos.terminateAgent(req.params.id);diff --git a/server/services/agentPromptBuilder.js b/server/services/agentPromptBuilder.jsindex 4dbe9ba2f0..dbbeb6d104 100644--- a/server/services/agentPromptBuilder.js+++ b/server/services/agentPromptBuilder.js@@ -421,9 +421,11 @@ ${skillSection ? `## Task-Type Skill Guidelines\n\n${skillSection}\n` : ''}${too1. Analyze the task requirements carefully2. Make necessary changes to complete the task3. Test your changes when possible-4. ${worktreeInfo && willOpenPR- ? 'Commit your changes (see Git Hygiene below) — do NOT push, the system handles that on exit'- : 'Commit and push your changes (see Git Hygiene below)'}+4. ${isTui+ ? `Commit, push, and ${willOpenPR ? 'open the PR (see Completion Workflow above)' : 'push the branch (see Completion Workflow above)'}`+ : worktreeInfo && willOpenPR+ ? 'Commit your changes (see Git Hygiene below) — do NOT push, the system handles that on exit'+ : 'Commit and push your changes (see Git Hygiene below)'}5. Provide a summary of what was done## Guidelines@@ -433,15 +435,17 @@ ${skillSection ? `## Task-Type Skill Guidelines\n\n${skillSection}\n` : ''}${too- Do not make unrelated changes- If blocked, explain clearly why- Never update the PortOS changelog (\`.changelog/\`) for work on managed apps — the PortOS changelog tracks PortOS core changes only-${isTruthyMetaFn(task.metadata?.readOnly) ? `- **This is a read-only task.** Do NOT commit, push, or modify any files in the repository. Only read data and generate reports.` : worktreeInfo && willOpenPR ? `- On successful completion, the system will push your branch and open a pull request — do NOT open a PR manually. (If the task fails, no PR is opened; the worktree is then cleaned up unless a safety check preserves it for manual recovery.)${willReviewLoop ? ' For GitHub PRs, a Copilot code review will also be requested automatically (skipped on GitLab and other non-GitHub forges) — do NOT run \`/do:rpr\` or attempt to address review comments yourself; you will have already exited.' : ''}` : worktreeInfo ? `- Your worktree branch will be automatically merged back to the source branch when your task completes — do NOT open a PR.` : ``}+${isTruthyMetaFn(task.metadata?.readOnly) ? `- **This is a read-only task.** Do NOT commit, push, or modify any files in the repository. Only read data and generate reports.` : isTui ? `- On successful completion, YOU run the Completion Workflow above (\`${tuiCompletionCommand}\`, write the sentinel, \`/quit\`). PortOS will NOT push or open a PR on your behalf.` : worktreeInfo && willOpenPR ? `- On successful completion, the system will push your branch and open a pull request — do NOT open a PR manually. (If the task fails, no PR is opened; the worktree is then cleaned up unless a safety check preserves it for manual recovery.)${willReviewLoop ? ' For GitHub PRs, a Copilot code review will also be requested automatically (skipped on GitLab and other non-GitHub forges) — do NOT run \`/do:rpr\` or attempt to address review comments yourself; you will have already exited.' : ''}` : worktreeInfo ? `- Your worktree branch will be automatically merged back to the source branch when your task completes — do NOT open a PR.` : ``}## Git Hygiene (CRITICAL)- **Before starting work**, run \`git status\` to verify a clean working tree. Do NOT stash or discard uncommitted changes — other agents may be working concurrently and expecting those changes to be present. If the tree is dirty, only commit files YOU changed for this task.- **NEVER use \`git stash\`** in any form (\`git stash push\`, \`git stash pop\`, etc.). This is a multi-agent system — stashing can silently destroy or corrupt another agent's or the user's in-progress work. Work around uncommitted changes instead. (Note: the backend may use \`--autostash\` in user-triggered pull operations — that is safe because those are single-user UI actions, not concurrent agent operations.)- **Only commit files YOU changed** for this task. Never use \`git add -A\` or \`git add .\` — always stage specific files by name.-${worktreeInfo && willOpenPR- ? `- **Commit only — do NOT push.** Stage specific files, use \`feat:\`/\`fix:\`/\`breaking:\` prefix in the commit message, no Co-Authored-By annotations. The system will push your branch and open the PR after you exit, so do NOT run \`git push\` or \`/do:push\` yourself.`- : `- **Commit and push using \`/do:push\`** — this handles changelog updates, staging specific files, writing a conventional commit message, and pushing safely. If \`/do:push\` is unavailable, follow its conventions manually: stage specific files, use \`feat:\`/\`fix:\`/\`breaking:\` prefix, no Co-Authored-By annotations, and push with \`git pull --rebase && git push\`.`}+${isTui+ ? `- **Use \`${tuiCompletionCommand}\` to ${willOpenPR ? 'commit, push, and open the PR' : 'commit and push the branch'}** — see the Completion Workflow section above. Stage specific files (no \`git add -A\`), use \`feat:\`/\`fix:\`/\`breaking:\` prefix in the commit message, no Co-Authored-By annotations.`+ : worktreeInfo && willOpenPR+ ? `- **Commit only — do NOT push.** Stage specific files, use \`feat:\`/\`fix:\`/\`breaking:\` prefix in the commit message, no Co-Authored-By annotations. The system will push your branch and open the PR after you exit, so do NOT run \`git push\` or \`/do:push\` yourself.`+ : `- **Commit and push using \`/do:push\`** — this handles changelog updates, staging specific files, writing a conventional commit message, and pushing safely. If \`/do:push\` is unavailable, follow its conventions manually: stage specific files, use \`feat:\`/\`fix:\`/\`breaking:\` prefix, no Co-Authored-By annotations, and push with \`git pull --rebase && git push\`.`}${worktreeInfo ? `- **Your PR should contain only your task's commits.** If you see unrelated commits in your branch history, something is wrong — do not open a PR with other agents' work.` : `- **Commit directly to the current branch.** Do NOT create feature branches or PRs unless explicitly instructed.`}## Working Directorydiff --git a/server/services/agentTuiSpawning.js b/server/services/agentTuiSpawning.jsindex e734f4b565..56f2f1b5f1 100644--- a/server/services/agentTuiSpawning.js+++ b/server/services/agentTuiSpawning.js@@ -46,7 +46,15 @@ const OUTPUT_FLUSH_INTERVAL_MS = 250;// silent provider still gets the prompt eventually.const READY_POLL_INTERVAL_MS = 300;const READY_IDLE_THRESHOLD_MS = 1200;-const PASTE_TO_ENTER_DELAY_MS = 400;+// Wait for Claude Code's `[Pasted text #N +M lines]` marker to appear before+// sending `\r`. A fixed 400 ms timer was too short for large prompts (87++// line pastes) — Claude Code was still committing the paste buffer when the+// Enter arrived, so the Enter got swallowed. The marker is emitted as soon+// as the paste is committed and the input cursor is ready for submit.+const PASTE_MARKER_POLL_MS = 150;+const PASTE_MARKER_PATTERN = /\[Pasted text #\d+/;+const PASTE_TO_ENTER_MIN_DELAY_MS = 200;+const PASTE_TO_ENTER_FALLBACK_MS = 3500;const PASTE_DEADLINE_MS = 10000;// Sentinel-file polling. TUI agents write `.agent-done` in their workspace// when they've finished /simplify + /do:pr (or /do:push) — we poll for it@@ -188,7 +196,7 @@ export async function spawnTuiAgent(agentId, task, prompt, workspacePath, model,if (agentData?.idleTimer) clearInterval(agentData.idleTimer);if (agentData?.promptTimer) clearInterval(agentData.promptTimer);if (agentData?.doneSentinelTimer) clearInterval(agentData.doneSentinelTimer);- if (pasteEnterTimer) { clearTimeout(pasteEnterTimer); pasteEnterTimer = null; }+ if (pasteEnterTimer) { clearInterval(pasteEnterTimer); pasteEnterTimer = null; }// Drain pending parsed lines before the final state writes so completion// events don't beat the last output batch to disk.@@ -365,20 +373,46 @@ export async function spawnTuiAgent(agentId, task, prompt, workspacePath, model,// Send the bracketed-paste prompt only after the TUI has finished its initial// repaint and gone quiet — pasting during the banner/loading screen is the// failure mode that left the input empty. The `\r` is split from the paste- // write so Claude Code has time to commit the paste buffer before Enter- // fires; its handle is tracked so finish() can cancel a still-pending Enter- // if the agent ends in that window.+ // write because a fixed delay races Claude Code's paste-commit on large+ // prompts; instead we poll Claude Code's raw output for its+ // `[Pasted text #N +M lines]` marker, then wait an extra+ // PASTE_TO_ENTER_MIN_DELAY_MS before submitting. A fallback timer fires+ // the Enter unconditionally if the marker never appears (very small+ // prompts won't trigger the marker). All timers are tracked so finish()+ // can cancel pending writes if the agent ends mid-handshake.const startedAt = Date.now();const sendPrompt = (reason) => {if (finalized || promptSentAt) return;promptSentAt = Date.now();+ const rawBufferLenBeforePaste = rawBuffer.length;shellService.writeToSession(sessionId, `\x1b[200~${prompt}\x1b[201~`);- pasteEnterTimer = setTimeout(() => {- pasteEnterTimer = null;+ appendLine(`📟 Prompt pasted into TUI session ${sessionId.slice(0, 8)} (${reason})`);++ const submitEnter = () => {if (finalized) return;shellService.writeToSession(sessionId, '\r');- }, PASTE_TO_ENTER_DELAY_MS);- appendLine(`📟 Prompt pasted into TUI session ${sessionId.slice(0, 8)} (${reason})`);+ };++ const pasteSentAt = Date.now();+ pasteEnterTimer = setInterval(() => {+ if (finalized) {+ clearInterval(pasteEnterTimer);+ pasteEnterTimer = null;+ return;+ }+ const elapsed = Date.now() - pasteSentAt;+ const postPasteOutput = rawBuffer.slice(rawBufferLenBeforePaste);+ const markerSeen = PASTE_MARKER_PATTERN.test(postPasteOutput);+ // Submit when EITHER the paste-commit marker appears (preferred) or+ // the fallback window elapses (covers small prompts that don't render+ // the marker).+ if ((markerSeen && elapsed >= PASTE_TO_ENTER_MIN_DELAY_MS)+ || elapsed >= PASTE_TO_ENTER_FALLBACK_MS) {+ clearInterval(pasteEnterTimer);+ pasteEnterTimer = null;+ submitEnter();+ }+ }, PASTE_MARKER_POLL_MS);};const promptTimer = setInterval(() => {diff --git a/server/services/cos.js b/server/services/cos.jsindex d7b6685548..fda1e6e641 100644--- a/server/services/cos.js+++ b/server/services/cos.js@@ -44,7 +44,7 @@ import { cosEvents, emitLog } from './cosEvents.js';export { cosEvents, emitLog };// Agent lifecycle (re-export for backward compat with `import * as cos`)-export { registerAgent, updateAgent, completeAgent, appendAgentOutput, getAgents, getAgentDates, getAgentsByDate, getAgent, terminateAgent, killAgent, sendBtwToAgent, getAgentProcessStats, cleanupZombieAgents, deleteAgent, submitAgentFeedback, getFeedbackStats, extractTaskType, archiveStaleAgents, clearCompletedAgents, pruneOldAgentArchives } from './cosAgents.js';+export { registerAgent, updateAgent, completeAgent, appendAgentOutput, getAgents, getAgentDates, getAgentsByDate, getAgent, getAgentPrompt, terminateAgent, killAgent, sendBtwToAgent, getAgentProcessStats, cleanupZombieAgents, deleteAgent, submitAgentFeedback, getFeedbackStats, extractTaskType, archiveStaleAgents, clearCompletedAgents, pruneOldAgentArchives } from './cosAgents.js';// Reports and activity (re-export for backward compat with `import * as cos`)export { generateReport, getReport, getTodayReport, listReports, listBriefings, getBriefing, getLatestBriefing, getTodayActivity, getRecentTasks, formatRelativeTime } from './cosReports.js';diff --git a/server/services/cosAgents.js b/server/services/cosAgents.jsindex ce1775473f..41d92e20ce 100644--- a/server/services/cosAgents.js+++ b/server/services/cosAgents.js@@ -486,6 +486,20 @@ export async function getAgent(agentId) {return agent;}+// Read the prompt that was sent to an agent at spawn time.+// Used by the AgentCard UI to let the user inspect what was pasted into the+// TUI / sent to the CLI so the prompt can be iterated on.+export async function getAgentPrompt(agentId) {+ const state = await loadState();+ const agent = state.agents[agentId];+ if (!agent) return { error: 'Agent not found' };+ const agentDir = getAgentDir(agentId, agent.archiveDate);+ const promptPath = join(agentDir, 'prompt.txt');+ if (!existsSync(promptPath)) return { error: 'Prompt file not found' };+ const prompt = await readFile(promptPath, 'utf8');+ return { prompt, bytes: prompt.length };+}+// Terminate an agent (will be handled by spawner)export async function terminateAgent(agentId) {// Emit event to kill the process FIRST