Skip to content

fix(agents): window key for agent controls, approvals for changes that cannot be undone, safer Windows command script launches, dev origins only in dev mode - #11

Merged
nodemode-ai merged 9 commits into
mainfrom
fix/review-2026-11-28
Nov 29, 2026
Merged

nodemode-ai merged 9 commits into
mainfrom
fix/review-2026-11-28

Conversation

@gbarnai

@gbarnai gbarnai commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Agent control routes (bridge queue, tool results, approvals, policies, token rotation, activity, stop) and settings writes now require the window key, like the terminal routes. The window already sends the key on every call; the bridge goodbye beacon stays open because a beacon cannot carry a header.
  • folders_delete, tags_delete and characters_delete now ask the owner whatever the client policy, and so does projects_update when it replaces the document. Renames and cover changes still follow the policy.
  • Replacing a project document has its own approval key and that answer is never remembered, so a remembered rename never covers it. The approval dialog hides the remember box for it.
  • Any agent program started as a command script is refused when a word on its command line has control characters or characters cmd.exe reads itself (% " & | < > ^ !, or parentheses in an unquoted word). The sign-in check skips such a path.
  • Tests: pytest 556 passed, vitest 1186 passed, typecheck and build clean, self-check, versions, skills and agents sync checks pass. Not run on Windows or Linux.
  • On Windows, agent programs installed as npm-style .cmd shims now start the node script or program they wrap directly, from an argument list, without the command interpreter.
  • When the command interpreter is still needed, any argument or program path holding & | < > ^ ( ) ! % " or a control character is refused, with or without spaces, and the message says to pass long text through standard input or a file.
  • The version and sign-in checks for command scripts follow the same rules.

Tests

  • Each fix has a test that fails on the previous code where practical.
  • The repo CI commands were run locally on macOS. Every failure seen locally also fails on main in the same environment (missing local tools or platform-specific tests); none is introduced here.
  • Please rely on this PR's CI run for Linux and Windows.

For the owner

  • A few related items need an owner decision; they are listed separately, not here.

How to ship

  • Independent of other repos; merge in any order. No version bump; release as usual.

Approving a pending agent call, reading the bridge queue, posting window
tool results, changing agent policies, rotating the token, stopping agent
work and writing settings now require the window key, as the terminal
routes already do. The window sends the key on every engine call, so its
behaviour is unchanged; the bridge goodbye beacon stays open because a
beacon cannot carry a header.

Checked with python -m pytest (501 passed).
…s or replace a project

folders_delete, tags_delete and characters_delete cannot be undone, and
projects_update with a doc replaces the whole document with no earlier
version kept. They now ask the owner whatever the client policy, as
projects_delete and library_delete already do. Renames and cover changes
still follow the policy. Tool descriptions, the skill references and
agents/manifest.json (./formcraft agents sync) say so.

Checked with python -m pytest (518 passed) and check_skills.py.
…ough cmd.exe

On Windows a Claude Code installed as a .cmd or .bat script is started
through the command interpreter, which reads its own command line and
treats quotes, &, |, < > and % in it specially. The prompt from the
ask box is no longer put on that command line; it is typed into the new
tab once it starts, as a prompt for a tab already running is. A real
program (.exe) and macOS and Linux still take the prompt as an argument.
The shared agent finder is unchanged.

Checked with python -m pytest (524 passed).
config.window_origins() lists localhost and 127.0.0.1 on the Vite dev
and preview ports only when FORMCRAFT_DEV is 1. A release engine admits
its own origin and the desktop window origins, so another local server
that happens to use those ports is refused. LocalGuard accepts the
origin list as a function and reads it per request, so the switch is
honoured however the engine was started. The two dock tests that model
the Vite page now run in dev mode, as that page does.

Checked with python -m pytest (529 passed).
approval_key gave every projects_update the same key, so a remembered
yes for a rename or a cover change also covered a later call that
replaces the whole document. A projects_update with a doc now has its
own key, projects_update:doc, and that answer is never stored or
honoured, like an unpriced generate. The approval item says
rememberable false, and the window hides the remember box for it.

Checked with python -m pytest (556 passed), npm run typecheck and
npm test (1186 passed).
… read itself

When an agent program is a .cmd or .bat file it starts through
cmd.exe /c, which reads its own command line. Every word on that line
must now be text with no control characters and no % " & | < > ^ or !,
and parentheses pass only inside a word that gets quoted. Otherwise the
tab is not started and the window shows why. The Claude Code tab, the
other agent tabs and the sign-in check all go through this. A real
program and macOS and Linux are unchanged. The engine log records both
changes.

Checked with python -m pytest (556 passed).
…reter character otherwise

An agent program found as an npm-style .cmd shim is now resolved to the
node script or program it wraps and started from an argv list without
cmd.exe, for the Claude Code tab, the other agent tabs, the version
check and the sign-in check. The resolved tab takes the prompt on its
command line again.

When a shim does not resolve and cmd.exe is still used, any word,
including the program path, holding & | < > ^ ( ) ! % " or a control
character is refused whether or not it holds a space, because quoting
does not protect it there. The earlier exception for parentheses in a
quoted word is removed. The refusal says to pass long text through
standard input or a file. The version check of such a script no longer
goes through the shared finder's cmd.exe start.

Checked with python -m pytest (579 passed), npm run typecheck, npm run
build, npm test (1186 passed), the engine self-check, setup/versions.py
and check_skills.py.
@gbarnai
gbarnai requested a review from nodemode-ai as a code owner November 29, 2026 18:17
Brings the agents hardening branch up to main 0.11.0 and resolves the
six conflicts by hand.

- routers/agents.py: the bridge poll keeps the window key from this
  branch and takes main's project query; imports carry both Depends and
  Literal.
- services/agents.py: main's risk classes replace the
  projects_update:doc key, NEVER_REMEMBERED and rememberable. A
  projects_update with a doc is already risky through mcp_tools (this
  branch), so it gets a risk: key that _keepable refuses: it is never
  stored, never honoured, and no session, project or allow grant
  covers it. A rename or cover change stays a normal key.
- approvals.ts and api-agents.ts: the window reads main's keepable,
  which the engine now sends as false for a document replacement.
- test_services_agents_replace_doc.py: the two assertions that read the
  approval item read keepable instead of rememberable.
- backend and frontend HASHOUT_LOG: entries kept in date order, plus
  one entry each for this merge.

Checked: python -m pytest (579 passed), npm run typecheck, npm test
(1186 passed), npm run build, formcraft_engine.py --selfcheck,
setup/versions.py (10 sites at 0.11.0), check_skills.py and
setup/agents.py sync --check. Not run: the Windows and desktop jobs.
@nodemode-ai
nodemode-ai merged commit 4a9f3c3 into main Nov 29, 2026
5 checks passed
@nodemode-ai
nodemode-ai deleted the fix/review-2026-11-28 branch November 29, 2026 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants