|
1 | 1 | # @effect-template/api |
2 | 2 |
|
3 | | -Clean-slate v1 HTTP API for docker-git orchestration. |
| 3 | +HTTP API for docker-git orchestration (projects, agents, logs/events, federation). |
4 | 4 |
|
5 | 5 | ## UI wrapper |
6 | 6 |
|
7 | | -После запуска API открой: |
| 7 | +After API startup open: |
8 | 8 |
|
9 | 9 | - `http://localhost:3334/` |
10 | 10 |
|
11 | | -Это встроенная фронт-обвязка для ручного тестирования endpoint-ов (проекты, агенты, логи, SSE). |
| 11 | +This page is a built-in UI shell for manual API checks without CLI. |
12 | 12 |
|
13 | | -## Run |
| 13 | +## Run (local) |
14 | 14 |
|
15 | 15 | ```bash |
16 | 16 | pnpm --filter ./packages/api build |
17 | 17 | pnpm --filter ./packages/api start |
18 | 18 | ``` |
19 | 19 |
|
20 | | -Env: |
| 20 | +## Run (dedicated Docker for API) |
21 | 21 |
|
| 22 | +From repository root: |
| 23 | + |
| 24 | +```bash |
| 25 | +docker compose -f docker-compose.api.yml up -d --build |
| 26 | +curl -s http://127.0.0.1:3334/health |
| 27 | +``` |
| 28 | + |
| 29 | +Default port mapping: |
| 30 | + |
| 31 | +- host: `127.0.0.1:3334` |
| 32 | +- container: `3334` |
| 33 | + |
| 34 | +Optional env: |
| 35 | + |
| 36 | +- `DOCKER_GIT_API_BIND_HOST` (default: `127.0.0.1`) |
22 | 37 | - `DOCKER_GIT_API_PORT` (default: `3334`) |
23 | | -- `DOCKER_GIT_PROJECTS_ROOT` (default: `~/.docker-git`) |
24 | | -- `DOCKER_GIT_API_LOG_LEVEL` (default: `info`) |
25 | | -- `DOCKER_GIT_FEDERATION_PUBLIC_ORIGIN` (optional public ActivityPub domain, e.g. `https://social.my-domain.tld`) |
| 38 | +- `DOCKER_GIT_PROJECTS_ROOT_HOST` (host path with docker-git projects, default: `/home/dev/.docker-git`) |
| 39 | +- `DOCKER_GIT_PROJECTS_ROOT` (container path, default: `/home/dev/.docker-git`) |
| 40 | +- `DOCKER_GIT_FEDERATION_PUBLIC_ORIGIN` (optional public ActivityPub origin) |
26 | 41 | - `DOCKER_GIT_FEDERATION_ACTOR` (default: `docker-git`) |
27 | 42 |
|
28 | 43 | ## Endpoints |
|
35 | 50 | - `GET /federation/followers` |
36 | 51 | - `GET /federation/following` |
37 | 52 | - `GET /federation/liked` |
38 | | -- `POST /federation/follows` (create ActivityPub `Follow` activity for task-feed subscription) |
| 53 | +- `POST /federation/follows` (create ActivityPub `Follow` subscription) |
39 | 54 | - `GET /federation/follows` |
40 | 55 | - `GET /projects` |
41 | 56 | - `GET /projects/:projectId` |
|
54 | 69 | - `POST /projects/:projectId/agents/:agentId/stop` |
55 | 70 | - `GET /projects/:projectId/agents/:agentId/logs` |
56 | 71 |
|
57 | | -## Example |
| 72 | +## Subscription workflow (ActivityPub Follow + ForgeFed issues) |
| 73 | + |
| 74 | +1. Read actor profile (contains `inbox/outbox/followers/following/liked`): |
58 | 75 |
|
59 | 76 | ```bash |
60 | | -curl -s http://localhost:3334/projects |
61 | | -curl -s -X POST http://localhost:3334/projects/<projectId>/up |
62 | | -curl -s -N http://localhost:3334/projects/<projectId>/events |
| 77 | +curl -s http://127.0.0.1:3334/federation/actor |
| 78 | +``` |
63 | 79 |
|
64 | | -curl -s http://localhost:3334/federation/actor |
| 80 | +2. Create follow subscription: |
65 | 81 |
|
66 | | -curl -s -X POST http://localhost:3334/federation/follows \ |
| 82 | +```bash |
| 83 | +curl -sS -X POST http://127.0.0.1:3334/federation/follows \ |
67 | 84 | -H 'content-type: application/json' \ |
68 | | - -d '{"domain":"social.my-domain.tld","object":"https://social.my-domain.tld/issues/followers"}' |
| 85 | + -d '{ |
| 86 | + "domain":"https://social.provercoder.ai", |
| 87 | + "actor":"https://dev.example/users/bot", |
| 88 | + "object":"https://tracker.example/issues/followers", |
| 89 | + "capability":"https://tracker.example/caps/follow" |
| 90 | + }' |
| 91 | +``` |
69 | 92 |
|
70 | | -curl -s -X POST http://localhost:3334/federation/inbox \ |
| 93 | +`domain` is used as public origin. `.example` hosts in `actor/object/capability` are normalized to that domain. |
| 94 | + |
| 95 | +3. Confirm subscription by sending `Accept` into inbox: |
| 96 | + |
| 97 | +```bash |
| 98 | +curl -sS -X POST http://127.0.0.1:3334/federation/inbox \ |
71 | 99 | -H 'content-type: application/json' \ |
72 | | - -d '{"@context":["https://www.w3.org/ns/activitystreams","https://forgefed.org/ns"],"id":"https://social.my-domain.tld/offers/42","type":"Offer","target":"https://social.my-domain.tld/issues","object":{"type":"Ticket","id":"https://social.my-domain.tld/issues/42","attributedTo":"https://origin.my-domain.tld/users/alice","summary":"Title","content":"Body"}}' |
| 100 | + -d '{ |
| 101 | + "@context":"https://www.w3.org/ns/activitystreams", |
| 102 | + "type":"Accept", |
| 103 | + "object":"https://social.provercoder.ai/federation/activities/follows/<id>" |
| 104 | + }' |
| 105 | +``` |
| 106 | + |
| 107 | +4. Verify follow state and collections: |
| 108 | + |
| 109 | +```bash |
| 110 | +curl -s http://127.0.0.1:3334/federation/follows |
| 111 | +curl -s http://127.0.0.1:3334/federation/following |
| 112 | +curl -s http://127.0.0.1:3334/federation/outbox |
| 113 | +``` |
| 114 | + |
| 115 | +5. Push issue offer through ForgeFed inbox: |
| 116 | + |
| 117 | +```bash |
| 118 | +curl -sS -X POST http://127.0.0.1:3334/federation/inbox \ |
| 119 | + -H 'content-type: application/json' \ |
| 120 | + -d '{ |
| 121 | + "@context":["https://www.w3.org/ns/activitystreams","https://forgefed.org/ns"], |
| 122 | + "id":"https://social.provercoder.ai/offers/42", |
| 123 | + "type":"Offer", |
| 124 | + "target":"https://social.provercoder.ai/issues", |
| 125 | + "object":{ |
| 126 | + "type":"Ticket", |
| 127 | + "id":"https://social.provercoder.ai/issues/42", |
| 128 | + "attributedTo":"https://origin.provercoder.ai/users/alice", |
| 129 | + "summary":"Need reproducible CI parity", |
| 130 | + "content":"Implement API behavior matching CLI." |
| 131 | + } |
| 132 | + }' |
| 133 | +``` |
| 134 | + |
| 135 | +6. Verify persisted issues: |
| 136 | + |
| 137 | +```bash |
| 138 | +curl -s http://127.0.0.1:3334/federation/issues |
73 | 139 | ``` |
0 commit comments