Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ The rest is written by hand.
| Module | Prefix | Routes |
| --- | --- | --- |
| addons.py | /api/addons | 3 |
| agent_access.py | /api/agent-access | 6 |
| agent_access.py | /api/agent-access | 7 |
| agent_connect.py | /api/agents | 2 |
| assets.py | /api/assets | 3 |
| automation.py | /api/rpc | 3 |
Expand Down Expand Up @@ -130,6 +130,7 @@ the automation transports.
- `openh264.py`
- `package_registry.py`
- `paths.py`
- `peer_process.py`
- `pixel_effects.py`
- `planar.py`
- `planar_bench.py`
Expand Down
2 changes: 1 addition & 1 deletion .docs/wiki/Automation.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Automation

Use the running desktop engine's loopback URL, or the development engine at `http://127.0.0.1:8040`. The desktop port is assigned by the OS and appears in the engine startup log. POST JSON-RPC 2.0 with `Content-Type: application/json` and `x-formcut-local: 1`. Methods that change nothing answer at `/api/rpc/read` for any local program. Everything else at `/api/rpc` and every other write needs the per-launch window key, which only the formcut window holds; the header alone is not enough. A program outside the window asks first: `POST /api/agent-access/request` with `{"tool": "...", "agent": "..."}` follows the choice in Settings, Connections, Outside agents (Ask each time, the default, puts Deny, Allow once and Always allow in the window and waits up to two minutes, refusing at once when no window is open; Allowed answers at once; Blocked refuses) and answers with a pass for that task, sent as `x-formcut-agent-pass` and ended with `DELETE /api/agent-access/pass`. A pass cannot change that choice, answer the window's questions or open a terminal. The MCP server does all of this for each tool that is not read-only. The `/api/rpc/ws` websocket is the window's.
Use the running desktop engine's loopback URL, or the development engine at `http://127.0.0.1:8040`. The desktop port is assigned by the OS and appears in the engine startup log. POST JSON-RPC 2.0 with `Content-Type: application/json` and `x-formcut-local: 1`. Methods that change nothing answer at `/api/rpc/read` for any local program. Everything else at `/api/rpc` and every other write needs the per-launch window key, which only the formcut window holds; the header alone is not enough. A program outside the window asks first: `POST /api/agent-access/request` with `{"tool": "...", "agent": "..."}` follows the choice in Settings, Connections, Outside agents (Ask each time, the default, puts Deny, Allow once and Always allow in the window and waits up to two minutes, refusing at once when no window is open; Allowed answers at once; Blocked refuses) and answers with a pass for that task, sent as `x-formcut-agent-pass` and ended with `DELETE /api/agent-access/pass`. A pass cannot change that choice, answer the window's questions or open a terminal. A pass lasts fifteen minutes, and time the computer spends asleep counts toward them. A job started with it in those fifteen minutes (a render, a transcription, a download) keeps it after them until that job finishes, fails or is cancelled, six hours at most, but only for that job: `job.status`, `job.result` and `job.cancel` over `/api/rpc` and `DELETE /api/jobs/{id}`. Every other write is refused, starting another job included, so ask again for those. A program that keeps one pass for its whole connection can say so with `"session": true` and its process id as `"pid"`. When that id is the process at the other end of the request's connection, formcut finds it from the system's own list of connections, the question also offers `session`, Allow for this session, and that answer gives a pass with no fifteen-minute limit (`"session": true` and `"seconds": null` in the reply). A request from any other process, or one whose process formcut cannot find, is not offered it. The pass lasts until the program ends it with `DELETE /api/agent-access/pass`, that process is gone (a new process given the same id later does not count), or formcut quits; `GET /api/agent-access/pass` with the pass says whether it is still good. Choosing Blocked ends every pass at once. The MCP server asks this way and keeps a session pass until its client disconnects. The window's dialog, the family's shared dock (module 2.2.1), shows Deny, Allow once and Always allow only, so Allow for this session cannot yet be chosen there. The MCP server does all of this for each tool that is not read-only. The `/api/rpc/ws` websocket is the window's.

```json
{"jsonrpc":"2.0","id":1,"method":"capabilities"}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@

## Built for agents

FormCut ships an MCP server with 34 workflow tools; the interface, the JSON-RPC surface and the MCP server edit the same project. Tools that only read run at once; before any other tool FormCut asks in its window (Deny, Allow once, Always allow), and Settings, Connections, Outside agents can make that Allowed or Blocked. Only the FormCut window can change that choice or make other changes without asking.
FormCut ships an MCP server with 34 workflow tools; the interface, the JSON-RPC surface and the MCP server edit the same project. Tools that only read run at once; before any other tool FormCut asks in its window (Deny, Allow once, Always allow), and Settings, Connections, Outside agents can make that Allowed or Blocked. An allowed agent's pass lasts fifteen minutes, time asleep included. A render or other job it started keeps it longer, until the job is finished and six hours at most, but then only to check or cancel that job. Only the FormCut window can change that choice or make other changes without asking.

```sh
./formcut mcp # MCP server on stdio, starts the engine if nothing answers
Expand Down
13 changes: 13 additions & 0 deletions backend/HASHOUT_LOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@

Reasoning behind engine changes, newest first.

## Unreleased · a job keeps its pass, and a pass for the agent's session (`app/agent_access.py`, `app/jobs.py`, `app/security.py`, `app/agent_mcp.py`)

- **The owner's choice.** Keep the fifteen-minute pass, but a tool call started under a pass that runs longer (a render) keeps it until the job ends. And the person can allow an agent for its session: until the agent disconnects or formcut quits.
- **Jobs.** `LocalOnly` puts the pass a request came in with in `agent_access.ADMITTED` for the length of that request; `jobs.submit` hands the new job id to `agent_access.hold`, which ties it to that pass when the pass is live, and the job's last step calls `job_ended`. A pass is good for any write while it is under fifteen minutes old, and for its jobs alone while a job is tied to it (below). A job started by the window holds nothing. Ending the pass ends the tie. Only a job started inside the pass's first fifteen minutes is tied to it, so a pass kept alive by one job cannot be stretched further by starting another.
- **Session.** `POST /api/agent-access/request` takes `session` (the agent keeps one pass for its connection) and `pid`. Only then does the question offer `session`, between `once` and `always`; a `session` answer to an agent that did not ask for one is a refusal. A session pass has no age limit and is good while its process is (below). The id must fit a process id (at most 2^31 - 1), and a process that cannot be looked at counts as gone, so one bad id cannot stop later passes being given. `GET /api/agent-access/pass` says whether a pass is good and whether it is a session's.
- **A pass a job keeps reaches only that job.** Past its fifteen minutes a pass held by jobs answers `agent_access.reach` with the ids of those jobs, not `ALL`, so `pass_valid` is false and it admits no ordinary write. `security._job_call` lets it through only for `DELETE /api/jobs/{id}` of one of those jobs and for `POST /api/rpc`, where `LocalOnly` puts the ids in `agent_access.JOBS_ONLY` and `automation.rpc` answers only `job.status`, `job.result` and `job.cancel` for them. A job started then holds nothing, since `hold` takes only a pass that reaches everything. However long its jobs run, a pass ends `PASS_MOST` (six hours) after it was given. Holds are keyed by job id and pass together and counted: `hold` answers the pass it took and the job's last step gives it back to `job_ended(job_id, held)`, so a second job with the same id, or the same job id on another pass, cannot end or take over another hold.
- **One answer per request, and the wall clock.** `LocalOnly` reads what a request's pass covers once (`security._pass_reach`, called from `security._without_key`, which answers both whether the request may go on and the job ids it was let in for) and puts those ids in `JOBS_ONLY`, so a job that ends between the two cannot leave a JSON-RPC request let in for its jobs with nothing limiting it. A request let in on the job route with no job ids in hand is limited to an empty set, which reaches no job, never to no limit. The read happens only when a pass is what decides, so reads and keyed requests do not look up a session's process. A pass also keeps the wall-clock time it was given, and its age is the larger of the steady clock's and the wall clock's: the steady clock stops while the computer sleeps, so fifteen minutes and six hours are counted in time that passed, asleep or not. A wall clock set back changes nothing, since the steady clock still counts; set forward, it ends passes early, which is the safe side.
- **A session is the asking process's.** `peer_process.owner` reads the system's socket table (`/proc/net/tcp` and each process's `fd` folder on Linux, `lsof` on macOS, `netstat -ano` on Windows) for the process at the other end of the request's loopback connection. A session is offered only when that is the `pid` the request names and its start time can be read (`startup.created`); the pass keeps both, and is live while `startup.same` finds that id with that start time, so a reused id is not the same process. A session pass with no id is not live. The lookup runs once, when the pass is asked for; each write with a session pass checks the process (on macOS that reads `ps` for the start time).
- **Blocked.** Storing Blocked now ends every pass, a session's included, rather than letting them run out.
- **MCP server.** Every ask carries `session: true` and the server's process id. A session pass is kept, checked with `GET /api/agent-access/pass` before each tool call that writes (dropped and asked again when the engine no longer takes it, after formcut was reopened), and not ended at the end of each tool call; `main` ends it when the client disconnects.
- **Not done.** The window cannot give the answer yet: the shared dock's dialog (module 2.2.1, never edited here) knows `deny`, `once` and `always` only, and the adapter keeps to those. The button needs a dock module change in FormVis, copied to the family.
- **Not run.** The Linux and Windows lookups have run here only on recorded tables and a stand-in `/proc`; the live connection test ran on macOS.
- **Tests.** `tests/test_agent_passes.py`, `tests/test_peer_process.py`.
## Unreleased · the suite's data folder on Windows is checked against the person's data folder (`tests/test_stand_in_home.py`)

- **What was there.** `test_the_data_folder_read_at_import_is_the_suites_own_and_not_under_the_persons_home` asserted that the suite's data folder is not anywhere under the person's home. On Windows the system temporary folder is `%LOCALAPPDATA%\Temp`, inside the home, so the folder `tempfile.mkdtemp` makes there always failed it (CI: `C:\Users\runneradmin\AppData\Local\Temp\formcut-tests-...`).
Expand Down
Loading
Loading