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
fix: validate guarded runner termination requests
Adam Eivyab1e19bf50f3
diff --git a/server/cos-runner/index.js b/server/cos-runner/index.jsindex af31955d41..b1b06b0c61 100644--- a/server/cos-runner/index.js+++ b/server/cos-runner/index.js@@ -41,7 +41,7 @@ import { usableAgentPid, runnerAgentLivenessFields } from '../lib/runnerAgentLivimport { ALLOWED_COMMANDS, isAllowedCommand } from './allowedCommands.js';import { armForceKill as armForceKillShared } from './forceKill.js';import { createTuiExitHandler } from './tuiExit.js';-import { bodyErrorMessage, btwBodySchema, pauseBodySchema, spawnBodySchema, spawnTuiBodySchema } from './requestSchemas.js';+import { bodyErrorMessage, btwBodySchema, pauseBodySchema, spawnBodySchema, spawnTuiBodySchema, terminateBodySchema } from './requestSchemas.js';import { createRunnerShutdown, registerRunnerShutdownSignals } from './shutdown.js';import { createHttpDrain } from '../lib/httpDrain.js';import { PORTS } from '../lib/ports.js';@@ -790,6 +790,8 @@ app.post('/spawn', lifecycle.spawnRoute(async (req, res) => {* Terminate an agent (graceful with SIGTERM, then SIGKILL after timeout)*/app.post('/terminate/:agentId', async (req, res) => {+ const body = terminateBodySchema.safeParse(req.body ?? {});+ if (!body.success) return res.status(400).json({ error: bodyErrorMessage(body.error) });const { agentId } = req.params;const agent = activeAgents.get(agentId);@@ -797,7 +799,7 @@ app.post('/terminate/:agentId', async (req, res) => {return res.status(404).json({ error: 'Agent not found or not running' });}- if (req.body?.onlyIfPromptUnsubmitted === true) {+ if (body.data.onlyIfPromptUnsubmitted === true) {if (agent.kind !== 'tui' || agent.promptSubmitted !== false) {return res.json({ success: true, agentId, terminated: false });}diff --git a/server/cos-runner/requestSchemas.js b/server/cos-runner/requestSchemas.jsindex e5dac3e309..b8ffdbe227 100644--- a/server/cos-runner/requestSchemas.js+++ b/server/cos-runner/requestSchemas.js@@ -56,6 +56,7 @@ export const spawnBodySchema = z.object({});export const pauseBodySchema = z.object({ reason: optionalString });+export const terminateBodySchema = z.object({ onlyIfPromptUnsubmitted: z.boolean().optional() });export const btwBodySchema = z.object({ message: z.string().min(1, 'message is required') });