O3: task sources and result sinks, cmd adapter protocol (closes #4)
This commit is contained in:
1 parent
2f79b69977
commit
6e1979fe7a
10 files changed
+594
-76
No files matched your search
@@ -0,0 +1,55 @@
|
||||
# `cmd` adapter protocol
|
||||
|
||||
A `cmd` adapter is any executable. orch runs `COMMAND OP` (COMMAND is split on whitespace, OP is appended),
|
||||
writes one JSON object to stdin, and expects one JSON object on stdout and exit code 0. Anything else
|
||||
(non-zero exit, non-JSON stdout, no answer within 120 s) is an adapter error. stderr is passed through.
|
||||
|
||||
Profile:
|
||||
|
||||
```toml
|
||||
repo = "/work/myrepo" # default repo for tasks without `repo`
|
||||
|
||||
[source]
|
||||
kind = "cmd"
|
||||
command = "python3 /path/to/adapter.py"
|
||||
|
||||
[sink]
|
||||
kind = "cmd" # or "local-branch" (default)
|
||||
command = "python3 /path/to/adapter.py"
|
||||
```
|
||||
|
||||
Schema: [`cmd-protocol.schema.json`](cmd-protocol.schema.json).
|
||||
|
||||
## Task
|
||||
|
||||
`{"id", "title", "body", "repo"?, ...}`. `id` is unique per source and becomes the run and branch name (orch
|
||||
sanitizes it). `repo` is a local clone path. Every other field is adapter-private (issue number, URL, ...) and
|
||||
is echoed back verbatim in later calls, so adapters stay stateless.
|
||||
|
||||
## Operations
|
||||
|
||||
| op | stdin | stdout |
|
||||
|---|---|---|
|
||||
| `list` (source) | `{}` | `{"tasks": [Task, ...]}` |
|
||||
| `claim` (source) | `{"task": Task}` | `{"claimed": bool}`; false = someone else took it, orch skips it |
|
||||
| `report` (source) | `{"task": Task, "run": Run}` | `{}`; called when a run ends in any state |
|
||||
| `publish` (sink) | `{"task": Task, "run": Run}` | `{"url": "..."}` (url optional); only for runs that ended `done` |
|
||||
|
||||
`Run`: `id, status (done|failed|needs-human), reason, branch, repo, worktree, attempts, input_tokens,
|
||||
output_tokens, published`. The work is on local branch `branch` in `repo`; a sink pushes it and opens a PR/MR,
|
||||
posts a comment, or whatever the host needs. Host credentials live in the adapter, never in orch.
|
||||
|
||||
A failing `publish` or `report` never fails the run: the error is printed and, for publish, stored in the run's
|
||||
`published` field as `publish-failed: ...`.
|
||||
|
||||
## Built-ins
|
||||
|
||||
- source `dir`: `[source] kind = "dir"`, `path = "/tasks"`. Each `*.md` file is a task (first `#` heading = title,
|
||||
rest = prompt). Claim moves it to `.running/`, report to `.done/` or `.failed/`.
|
||||
- sink `local-branch`: nothing to publish, the branch stays in the local clone.
|
||||
|
||||
## Example
|
||||
|
||||
`examples/gitea_adapter.py`: source = open issues with label `orch`, claim swaps the label to `orch-running`,
|
||||
report comments and sets `orch-done` / `orch-failed`, publish pushes the branch and opens a PR. Auth comes from
|
||||
`git credential fill`. Env: `ORCH_GITEA_HOST`, `ORCH_GITEA_REPO` (`owner/name`), `ORCH_GITEA_CLONE` (local clone).
|
||||
Reference in new issue
Block a user