From 9389793402c8ad942edbd27fd9efbe798c90dd30 Mon Sep 17 00:00:00 2001
From: lotherk
Date: Mon, 9 Nov 2026 23:48:54 +0000
Subject: [PATCH] a2a: ListTasks on the server
The server can list the stored tasks now, optionally filtered by
contextId, with the pagination fields the spec requires. The test checks
the stored task and an empty list for another context. Docs and the site
name the method.
---
README.md | 3 ++-
TODO.md | 4 ++--
docs/PLUGINS.md | 7 ++++---
docs/ROADMAP.md | 2 +-
src/a2aserver.c | 41 +++++++++++++++++++++++++++++++++++++---
src/www/index.en.html | 4 ++--
src/www/index.html | 4 ++--
src/www/index.pt.html | 4 ++--
tests/test_a2a_server.sh | 8 ++++++++
tools/gen_www.py | 6 +++---
10 files changed, 64 insertions(+), 19 deletions(-)
diff --git a/README.md b/README.md
index a70f750..1ad1922 100644
--- a/README.md
+++ b/README.md
@@ -131,7 +131,8 @@ SPLINTER_A2A_SERVER_TOKEN=... \
./splinter --a2a-server-listen 127.0.0.1 --a2a-listen-port 8099
```
-Another agent can send `SendMessage` to `POST /a2a` and poll `GetTask`; the
+Another agent can send `SendMessage` to `POST /a2a` and read `GetTask` or
+`ListTasks`; the
agent card is served at `/.well-known/agent-card.json`. `SendStreamingMessage`
streams the answer as SSE artifact updates, then a completed status. Each
request runs one turn in its own conversation. File parts, push notifications,
diff --git a/TODO.md b/TODO.md
index 9d112fb..1bb1d19 100644
--- a/TODO.md
+++ b/TODO.md
@@ -48,7 +48,7 @@ Context bleibt. `SPLINTER_A2A_CARD` findet den Endpunkt ueber die Agent Card.
Der Server ist gebaut: `src/a2aserver.c`, `POST /a2a` mit `SendMessage` (ein
Turn in eigener Konversation, completed Task), `SendStreamingMessage` (SSE,
-`artifactUpdate`-Chunks, dann completed `statusUpdate`) und `GetTask`,
+`artifactUpdate`-Chunks, dann completed `statusUpdate`) `GetTask`, `ListTasks`,
`GET /.well-known/agent-card.json`, Bearer-Token ueber
`SPLINTER_A2A_SERVER_TOKEN` jenseits von Loopback.
@@ -96,7 +96,7 @@ Naechster Schritt: entscheiden, ob die npm-Reste weg duerfen. Kein Code.
(JSON-RPC 2.0, Text, blockierend), in der UI `SendStreamingMessage` (SSE,
Artefakt-Text live) und findet den Endpunkt ueber `SPLINTER_A2A_CARD`;
`src/a2aserver.c` serviert `SendMessage`, `SendStreamingMessage` (SSE),
- `GetTask` und die Agent Card mit Bearer-Token. `tests/test_a2a.sh` prueft Task, Message, Token, Fehler,
+ `GetTask`, `ListTasks` und die Agent Card mit Bearer-Token. `tests/test_a2a.sh` prueft Task, Message, Token, Fehler,
Streaming und Discovery, `tests/test_a2a_ui.sh` den Streaming-Pfad,
`tests/test_a2a_server.sh` den Server und den Client gegen den Server
(Discovery, blockierend und streamend).
diff --git a/docs/PLUGINS.md b/docs/PLUGINS.md
index 9f6d295..207896f 100644
--- a/docs/PLUGINS.md
+++ b/docs/PLUGINS.md
@@ -297,8 +297,9 @@ The endpoint can be configured directly (`SPLINTER_A2A_URL`) or discovered:
`JSONRPC` entry from `supportedInterfaces` (or the older single `url` field).
The discovered URL is kept for the session.
-Not implemented yet, and named so nobody assumes otherwise: file/structured-data
-parts, push notifications, `GetTask`/`CancelTask`, and the server direction.
+Not implemented yet on the client side, and named so nobody assumes otherwise:
+file/structured-data parts, push notifications, and `GetTask`/`CancelTask`
+(the client sends and streams; it does not poll or cancel).
`tests/fake_a2a.py` and `tests/test_a2a.sh` pin the blocking wire shape, both
result forms, the bearer token, a JSON-RPC error, streaming and discovery;
`tests/test_a2a_ui.sh` drives the streaming path through tmux.
@@ -316,7 +317,7 @@ needs the agent and its authorization model, not only a transport.
`SendStreamingMessage` runs the same turn and writes SSE `artifactUpdate` events
as the transport produces text (a non-streaming transport sends its whole answer
as one artifact), followed by a completed `statusUpdate`; `GetTask` returns a
-stored task; `GET /.well-known/agent-card.json` serves a card with the `JSONRPC`
+stored task and `ListTasks` lists them (optionally by `contextId`); `GET /.well-known/agent-card.json` serves a card with the `JSONRPC`
interface. One request at a time, one connection at a time.
Refused with a JSON-RPC error, not half-answered: `CancelTask`,
diff --git a/docs/ROADMAP.md b/docs/ROADMAP.md
index cc572d5..83e16f5 100644
--- a/docs/ROADMAP.md
+++ b/docs/ROADMAP.md
@@ -5,7 +5,7 @@ Stand: 2026-11-09. Die geprüfte, ausführliche Liste mit Belegen steht in
1. **A2A: was noch fehlt** — Client (`SendMessage`, `SendStreamingMessage` in
der UI, Agent-Card-Discovery) und Server (`SendMessage`, SSE-Streaming,
- `GetTask`, Agent Card) stehen, alles mit Text. Offen sind Datei- und
+ `GetTask`, `ListTasks`, Agent Card) stehen, alles mit Text. Offen sind Datei- und
strukturierte Teile, Push-Notifications, `CancelTask`/`SubscribeToTask` und
die Fortsetzung eines unterbrochenen Tasks. `swarm` ist nur lokale IPC im
selben Verzeichnis, kein A2A.
diff --git a/src/a2aserver.c b/src/a2aserver.c
index d035479..5ed8d5d 100644
--- a/src/a2aserver.c
+++ b/src/a2aserver.c
@@ -305,9 +305,9 @@ task_store(const char *context, const struct sp_buf *answer)
}
static void
-task_json(struct sp_buf *b, const struct a2a_task *t)
+task_obj(struct sp_buf *b, const struct a2a_task *t)
{
- sp_buf_puts(b, "{\"task\":{\"id\":\"");
+ sp_buf_puts(b, "{\"id\":\"");
sp_buf_puts(b, t->id);
sp_buf_printf(b, "\",\"contextId\":\"%s\",\"status\":{\"state\":"
"\"TASK_STATE_COMPLETED\",\"message\":{\"messageId\":\"msg-%s\","
@@ -318,7 +318,15 @@ task_json(struct sp_buf *b, const struct a2a_task *t)
sp_buf_puts(b, t->id);
sp_buf_puts(b, "\",\"parts\":[{\"text\":\"");
sp_json_escape(b, t->answer.p);
- sp_buf_puts(b, "\"}]}]}}");
+ sp_buf_puts(b, "\"}]}]}");
+}
+
+static void
+task_json(struct sp_buf *b, const struct a2a_task *t)
+{
+ sp_buf_puts(b, "{\"task\":");
+ task_obj(b, t);
+ sp_buf_puts(b, "}");
}
static void
@@ -645,6 +653,33 @@ send_out:
task_json(&out, t);
rpc_result(fd, id, out.p != NULL ? out.p : "{}");
sp_buf_free(&out);
+ } else if (strcmp(method, "ListTasks") == 0) {
+ const char *want = mcp_arg_string(params, "contextId");
+ struct sp_buf out;
+ size_t i;
+ int n = 0;
+
+ memset(&out, 0, sizeof(out));
+ if (sp_buf_init(&out) != 0) {
+ rpc_error(fd, id, -32603, "out of memory");
+ mcp_json_free(v);
+ return;
+ }
+ sp_buf_puts(&out, "{\"tasks\":[");
+ for (i = 0; i < A2A_TASKS; i++) {
+ if (!g_tasks[i].used)
+ continue;
+ if (want != NULL && *want != '\0' &&
+ strcmp(g_tasks[i].context, want) != 0)
+ continue;
+ if (n++ > 0)
+ sp_buf_puts(&out, ",");
+ task_obj(&out, &g_tasks[i]);
+ }
+ sp_buf_printf(&out, "],\"nextPageToken\":\"\",\"pageSize\":%d,"
+ "\"totalSize\":%d}", n, n);
+ rpc_result(fd, id, out.p != NULL ? out.p : "{}");
+ sp_buf_free(&out);
} else if (strcmp(method, "SendStreamingMessage") == 0) {
handle_stream(fd, ag, id, params);
} else if (strcmp(method, "CancelTask") == 0 ||
diff --git a/src/www/index.en.html b/src/www/index.en.html
index 438c36d..be7dc6b 100644
--- a/src/www/index.en.html
+++ b/src/www/index.en.html
@@ -53,7 +53,7 @@ hr { border: 0; border-top: 1px solid #1d2126; margin: 3em 0 1.5em 0; }
splinter_
An agent harness you own: chat in the terminal, tools with authorization classes, plugins, any model that speaks OpenAI — built by us so we can change it, instead of getting used to how somebody else's client behaves.
-23655 lines of C99/POSIX ·
+
23690 lines of C99/POSIX ·
23 tools · 31 test programs ·
16 plugins · 42 palettes · BSD-3-Clause
@@ -207,7 +207,7 @@ itself:
$ SPLINTER_A2A_SERVER_TOKEN=... splinter --a2a-server-listen 127.0.0.1 --a2a-listen-port 8099
splinter: A2A server on 127.0.0.1:8099 (token required)
POST /a2a takes SendMessage, SendStreamingMessage
-(SSE) and GetTask as JSON-RPC; the agent card lives at
+(SSE), GetTask and ListTasks as JSON-RPC; the agent card lives at
/.well-known/agent-card.json. One turn per request, its own
conversation. Beyond loopback the bearer token is required.
diff --git a/src/www/index.html b/src/www/index.html
index 8a7e49b..6636182 100644
--- a/src/www/index.html
+++ b/src/www/index.html
@@ -53,7 +53,7 @@ hr { border: 0; border-top: 1px solid #1d2126; margin: 3em 0 1.5em 0; }
splinter_
Ein Agent-Harness, das dir gehoert: Chat im Terminal, Werkzeuge mit Autorisierungsklassen, Plugins, jedes Modell das OpenAI spricht — von uns gebaut, damit wir es umbauen koennen, statt uns an das Verhalten eines fremden Clients zu gewoehnen.
-23655 Zeilen C99/POSIX ·
+
23690 Zeilen C99/POSIX ·
23 Werkzeuge · 31 Test-Programme ·
16 Plugins · 42 Farbschemata · BSD-3-Clause
@@ -208,7 +208,7 @@ sich selbst hin:
$ SPLINTER_A2A_SERVER_TOKEN=... splinter --a2a-server-listen 127.0.0.1 --a2a-listen-port 8099
splinter: A2A server on 127.0.0.1:8099 (token required)
POST /a2a nimmt SendMessage, SendStreamingMessage
-(SSE) und GetTask als JSON-RPC; die Agent Card liegt unter
+(SSE), GetTask und ListTasks als JSON-RPC; die Agent Card liegt unter
/.well-known/agent-card.json. Ein Turn pro Anfrage, eigene
Konversation. Jenseits von Loopback ist der Bearer-Token Pflicht.
diff --git a/src/www/index.pt.html b/src/www/index.pt.html
index 88b0dd3..6e4174a 100644
--- a/src/www/index.pt.html
+++ b/src/www/index.pt.html
@@ -53,7 +53,7 @@ hr { border: 0; border-top: 1px solid #1d2126; margin: 3em 0 1.5em 0; }
splinter_
Um harness de agente que e seu: chat no terminal, ferramentas com classes de autorizacao, plugins, qualquer modelo que fale OpenAI - escrito por nos para poder mudar-lo, em vez de nos acostumar com o comportamento de um cliente alheio.
-23655 linhas C99/POSIX ·
+
23690 linhas C99/POSIX ·
23 ferramentas · 31 programas de teste ·
16 plugins · 42 paletas · BSD-3-Clause
@@ -155,7 +155,7 @@ si mesmo:
$ SPLINTER_A2A_SERVER_TOKEN=... splinter --a2a-server-listen 127.0.0.1 --a2a-listen-port 8099
splinter: A2A server on 127.0.0.1:8099 (token required)
POST /a2a aceita SendMessage, SendStreamingMessage
-(SSE) e GetTask em JSON-RPC; o agent card fica em
+(SSE), GetTask e ListTasks em JSON-RPC; o agent card fica em
/.well-known/agent-card.json. Um turno por requisicao, conversa
propria. Fora do loopback o token Bearer e obrigatorio.
diff --git a/tests/test_a2a_server.sh b/tests/test_a2a_server.sh
index a012cf8..2b8d955 100755
--- a/tests/test_a2a_server.sh
+++ b/tests/test_a2a_server.sh
@@ -79,6 +79,14 @@ resp6=$(post "$P" '{"jsonrpc":"2.0","id":"6","method":"CancelTask","params":{}}'
echo "$resp6" | grep -q '"code":-32601'
check test $? -eq 0
+# ListTasks: the stored task, and an empty list for another context
+resp7=$(post "$P" '{"jsonrpc":"2.0","id":"7","method":"ListTasks","params":{}}')
+echo "$resp7" | grep -q "$id"
+check test $? -eq 0
+resp8=$(post "$P" '{"jsonrpc":"2.0","id":"8","method":"ListTasks","params":{"contextId":"other"}}')
+echo "$resp8" | grep -q '"tasks":\[\]'
+check test $? -eq 0
+
# a task that does not exist is a JSON-RPC error, not an empty answer
resp4=$(post "$P" "{\"jsonrpc\":\"2.0\",\"id\":\"4\",\"method\":\"GetTask\",\"params\":{\"id\":\"nope\"}}")
echo "$resp4" | grep -q '"code":-32001'
diff --git a/tools/gen_www.py b/tools/gen_www.py
index bf0c456..bab3d89 100644
--- a/tools/gen_www.py
+++ b/tools/gen_www.py
@@ -455,7 +455,7 @@ sich selbst hin:
$ SPLINTER_A2A_SERVER_TOKEN=... splinter --a2a-server-listen 127.0.0.1 --a2a-listen-port 8099
splinter: A2A server on 127.0.0.1:8099 (token required)
POST /a2a nimmt SendMessage, SendStreamingMessage
-(SSE) und GetTask als JSON-RPC; die Agent Card liegt unter
+(SSE), GetTask und ListTasks als JSON-RPC; die Agent Card liegt unter
/.well-known/agent-card.json. Ein Turn pro Anfrage, eigene
Konversation. Jenseits von Loopback ist der Bearer-Token Pflicht.
""",
]
@@ -501,7 +501,7 @@ itself:
$ SPLINTER_A2A_SERVER_TOKEN=... splinter --a2a-server-listen 127.0.0.1 --a2a-listen-port 8099
splinter: A2A server on 127.0.0.1:8099 (token required)
POST /a2a takes SendMessage, SendStreamingMessage
-(SSE) and GetTask as JSON-RPC; the agent card lives at
+(SSE), GetTask and ListTasks as JSON-RPC; the agent card lives at
/.well-known/agent-card.json. One turn per request, its own
conversation. Beyond loopback the bearer token is required.
""",
]
@@ -591,7 +591,7 @@ si mesmo:
$ SPLINTER_A2A_SERVER_TOKEN=... splinter --a2a-server-listen 127.0.0.1 --a2a-listen-port 8099
splinter: A2A server on 127.0.0.1:8099 (token required)
POST /a2a aceita SendMessage, SendStreamingMessage
-(SSE) e GetTask em JSON-RPC; o agent card fica em
+(SSE), GetTask e ListTasks em JSON-RPC; o agent card fica em
/.well-known/agent-card.json. Um turno por requisicao, conversa
propria. Fora do loopback o token Bearer e obrigatorio.
""",
]