Commit Graph
6 Commits
Author SHA1 Message Date
dotCooCoo 7b29a321a5 control: the launch tests run on a test clock and wait on the calls instead of on time
LiveConfig takes the clock and the sleep its launch wait uses (Instant::now
and std::thread::sleep unless a test changes them), and a hook that each
resolve calls once it has noted how many starts have finished, before it
waits for the lookup. All three are hidden from the docs.

The four launch tests in tests/agents.rs no longer depend on how fast the
machine runs:

- A launch that never finishes advances the test clock by each poll, and
  the test checks that the wait polled until the 40 ms timeout passed.
- Concurrent calls: the app accepts agents only after all four calls have
  queued and the start has begun, instead of 60 ms after the start.
- Calls behind a failed start: the start returns once all four calls have
  queued, instead of after a 5 s poll and a 250 ms sleep, and the 150 ms
  timeout passes on the test clock.
- A huge timeout or poll: the test records each sleep, checks that the
  poll is cut to 1 s, and checks that an app that never accepts agents
  gives up after 600 polls with "within 600 s", instead of checking that
  the call took less than 5 s.

The file's wait_for helper, which polled for up to 5 s, has no caller left
and is removed.
2026-11-27 17:44:57 -08:00
dotCooCoo f7d6305ee8 control: the agents switch tests drive its polls instead of waiting on time
AgentSwitch::watch_with takes a tick function in place of the poll
interval: the watch thread calls it before each poll and ends when it
returns false. AgentSwitch::watch passes one that sleeps POLL, so the
app polls as before.

The tests the_switch_wakes_once_per_change in craft-control and
craft-automation polled every 5 ms, waited up to five seconds for each
step and slept 20 to 100 ms to check that the watch had ended. They now
run each poll through a channel and wait for the thread to finish it,
so they count probes and wakes exactly: one probe per poll, one wake
per change, and no poll after the last switch is dropped.
2026-11-27 15:41:55 -08: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 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