Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.
TypeScript adhdagent-orchestrationai-agentscanvasclaude-codecodexcoding-agentsdeveloper-toolselectrongeminilinuxmacosmultiplexeropencodeparallel-agentsterminalterminal-emulatorterminal-multiplexertmuxworkspace-manager
fix(hook-server): build form fields as own properties
Fabricio Casalid5c3a264b737
diff --git a/src/core/agents/hook-server-form.test.ts b/src/core/agents/hook-server-form.test.tsindex b5af88111..88cd680fc 100644--- a/src/core/agents/hook-server-form.test.ts+++ b/src/core/agents/hook-server-form.test.ts@@ -16,4 +16,12 @@ describe('parseControlBody — form bodies from a native Windows curl', () => {const body = 'nodeId=n1&arg.prompt=n%C3%A3o+%E2%86%92+sim'expect(parseControlBody(body, FORM).args).toEqual({ prompt: 'não → sim' })})++ // Field names come from the request: a `__proto__` field is an ordinary key, never a prototype.+ it('keeps a __proto__ field as an own key', () => {+ const { args } = parseControlBody('nodeId=n1&__proto__=x&arg.__proto__=y&arg.title=t', FORM)+ expect(Object.getPrototypeOf(args)).toBe(Object.prototype)+ expect(Object.keys(args).sort()).toEqual(['__proto__', 'title'])+ expect(Object.getOwnPropertyDescriptor(args, '__proto__')?.value).toBe('y')+ })})diff --git a/src/core/agents/hook-server.ts b/src/core/agents/hook-server.tsindex e08890485..8449d085d 100644--- a/src/core/agents/hook-server.ts+++ b/src/core/agents/hook-server.ts@@ -142,15 +142,17 @@ function decodeFormComponent(s: string): string {}}-// Parses application/x-www-form-urlencoded bodies (what the managed script posts).+// Parses application/x-www-form-urlencoded bodies (what the managed script posts). Field names come+// from the request, so they go into a Map and out through `Object.fromEntries`, which defines own+// properties: a `__proto__` field is an ordinary key, never a prototype write.function parseForm(body: string): Record<string, string> {- const out: Record<string, string> = {}+ const out = new Map<string, string>()for (const pair of body.split('&')) {const i = pair.indexOf('=')if (i < 0) continue- out[decodeFormComponent(pair.slice(0, i))] = decodeFormComponent(pair.slice(i + 1).replace(/\+/g, ' '))+ out.set(decodeFormComponent(pair.slice(0, i)), decodeFormComponent(pair.slice(i + 1).replace(/\+/g, ' ')))}- return out+ return Object.fromEntries(out)}/**@@ -167,10 +169,11 @@ export function parseControlBody(): { nodeId: string; args: Record<string, string>; requestId?: string } {if (contentType.includes('application/x-www-form-urlencoded')) {const form = parseForm(raw)- const args: Record<string, string> = {}- for (const [k, v] of Object.entries(form)) {- if (k.startsWith('arg.') && k.length > 4) args[k.slice(4)] = v- }+ const args: Record<string, string> = Object.fromEntries(+ Object.entries(form)+ .filter(([k]) => k.startsWith('arg.') && k.length > 4)+ .map(([k, v]) => [k.slice(4), v])+ )// `requestId` is the id the shim generates once per RUN (not the caller's `--request-id`,// which arrives as `arg.request-id`): what lets the shim's own endpoint-walk re-post be// recognised as the same call. See control-request-ledger.ts.