Commit Graph
13 Commits
Author SHA1 Message Date
BFlat e1c27c729f Merge pull request #2643 from dotCooCoo/fix/control-shared-line-reader
craft-control: the server reads request lines with craft-control-protocol's bounded reader
2026-11-26 10:27:26 +07:00
BFlat 7e92cb2f6d Merge pull request #3120 from dotCooCoo/fix/control-line-reader-behavior
craft-control: the server's line reader frames request lines as craft-control-protocol's does
2026-11-26 10:26:22 +07:00
dotCooCoo 21f4e14f3b Merge fix/control-line-reader-behavior into fix/control-shared-line-reader
The behavior changes to craft-control's line reader and the \r\n fix in
craft-control-protocol now come from that branch. With it merged, this
branch only replaces the server's reader and client::outcome with
craft-control-protocol's, and the reader tests stay as they are.
2026-11-22 15:51:51 -08:00
dotCooCoo 960d2508ed craft-control: the server's line reader refuses a line past the cap in the read that ends it
craft-control's server reads request lines with its own reader. It now
frames lines as craft_control_protocol::read_bounded_line does:

- A line longer than max_line is refused even when its newline arrives
  in the same read. Before, the limit was checked only between reads,
  so such a line was accepted. A last line past the limit with no
  newline is refused too.
- A \r before the newline is dropped from the line and does not count
  toward the limit.
- A read interrupted by a signal is retried instead of closing the
  connection.
- A read that would block reports TimedOut.
- The refusal names the limit: "request line longer than N bytes;
  closing the connection" instead of "request too large".
2026-11-22 15:51:15 -08:00
dotCooCoo 8a13f644db craft-control-protocol: the line cap does not count the line's \r\n
read_bounded_line read at most max + 1 bytes, so a line of exactly max
bytes followed by \r\n stopped after the \r and was refused, while the
same line followed by \n was read. It now reads up to max + 2 bytes,
strips the \n and a \r before it, and then checks the line against max.
A line of max + 1 bytes is still refused with either ending.
2026-11-20 14:46:45 -08:00
dotCooCoo 17ba68ff57 craft-control: read request lines with craft-control-protocol's bounded reader
The server's private line reader is replaced by
craft_control_protocol::read_bounded_line, and client::outcome now
returns craft_control_protocol::reply_result. craft-control and
craft-control-protocol read the same request framing with one reader.

Behavior changes in the server's reader:
- A line longer than the server's max_line is refused even when its
  newline arrives in the same read. Before, the limit was checked only
  between reads, so such a line was accepted and up to one buffer past
  the limit was allocated.
- A read interrupted by a signal is retried instead of closing the
  connection.
- A \r before the newline is dropped from the line.
- The refusal names the limit: "request line longer than N bytes;
  closing the connection" instead of "request too large".
2026-11-20 11:29:47 -08:00
David MannandClaude Opus 5.5 1929e79ebb Merge storytold main into next (20 Nov, second sync)
Merges main at 8f92ed1334 (#2550 and the rest of main since the 20 Nov sync).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 16:38:55 +01:00
David MannandClaude Opus 5.5 f9ebae49c0 craft-control agents: default agent folder in Documents and the agent_folders tool (#2548)
An empty agent folder setting meant no file access, so an agent reached
through the launcher's MCP entry could neither open nor save a file, and
nothing told it where to put files.

- default_folder(app): Documents/ArtCraft/Agents/<App> (dirs::document_dir,
  else ~/Documents), only for plain app names.
- AgentSettings::folders / folders_with: the person's own folders win; an
  empty setting falls back to the default, created on first use.
- The live client's headless sessions use it (LiveConfig::default_folder).
- FOLDERS_TOOL, folders_tool, folders_answer: the tool each app offers so an
  agent learns the folders it may use.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 15:00:40 +01:00
David MannandClaude Opus 5.5 6195b126d2 craft-automation: re-export the agents code from craft-control (#2390)
craft_automation::agents kept its own copy of the agent settings, the
launcher's switch and the connection file beside craft_control::agents.
It now re-exports craft-control's (and with it the CLI's live client)
and keeps only the egui link host. The Agents page is unchanged.

Callers see two API changes: AgentSwitch::watch takes a closure
instead of craft_host::Wake, and the connection functions return
std::io::Error. AgentSettings is #[non_exhaustive] in another crate
now, so the trials set fields on a default instead of using struct
update syntax.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 15:14:26 +01:00
David Mann 6b16ec2b41 craft-control agents: second review round (#2141)
- The token is passed on as the app wrote it (trimmed): craft-control's
  server compares exactly and accepts any CONTROL_TOKEN of 32+ chars.
  The token file is checked as a regular file before it is opened (a
  FIFO would block the open).
- Allow Agent Control off counts as not allowed on the CLI's side too.
- A window route is dropped once no app accepts agents.
- A headless session with the app's agent folders ends when the person
  stops letting agents in.
- The launch timeout is capped and the deadline computed without
  overflow; the poll interval is kept between 1 ms and 1 s.
- The connect error names the app's window; the guide says to remove
  the connection file on quit and that one process per settings folder
  accepts agents; the AppImage mount is compared after resolving links.
- Tests for each, and a wider margin in the queued-start test.
2026-11-18 03:19:07 +01:00
David Mann aa0f72303c craft-control agents: review fixes (#2141)
- Calls queued behind a start that failed get its error instead of
  starting the app again; a later call retries.
- The started process is reaped on a thread of its own.
- APPIMAGE counts only when the CLI runs from that image's mount.
- The guide names allow_agent_control as part of the listen condition.
- A watcher thread that can't start leaves agents off.
- The watcher test waits for the thread to end instead of a fixed sleep.
2026-11-18 02:53:47 +01:00
David Mann b837aa22dc craft-control: agents in the open window for apps on main (#2141)
The ArtCraft Launcher's switch (AgentSwitch, mcp_flag, launcher_allows),
the agent settings, the connection file (agent-connection.json) and the
<id>-cli mcp side that finds the open window (Live: window while the app
accepts agents, otherwise headless or the closed-app choice; launcher
starts the app beside the CLI), behind the new feature agents. No UI
toolkit and no async runtime. Same formats as craft_automation::agents
on next, which can re-export these once the branches meet.
2026-11-18 02:35:58 +01:00
Dylan M. Taylor 472956a8d7 feat: add craft-control (control channel protocol) (#1879)
* feat: add craft-control (control channel protocol)

Port from solidcraft: the control channel any app may share, no UI toolkit.
- Per-launch token files (32 random bytes, user-only permissions)
- Loopback server with token-based authentication
- Client that talks to the loopback server
- Request/response types (ControlRequest, ControlResponse)
- Document watch for subscribed connections waiting on changes
- Effect type for requests still running when they finish

Desktop-only (wasm32 excluded): uses getrandom for token generation.
No external dependencies beyond serde and serde_json.

* fix: update test directory names from solidcraft-control to craft-control

* Record control crate dependencies in workspace lockfile

* re-trigger CI

* chore(lock): keep the wasm-bindgen family at the version main's runners install
2026-11-16 09:55:33 -05:00