From 9c205dcd21309fc4ea02b3361f9bdffb2d07f835 Mon Sep 17 00:00:00 2001
From: lotherk
Date: Wed, 11 Nov 2026 10:25:49 +0000
Subject: [PATCH] a2a: the client can send a file, and already saves what it
receives
a2a_send posts SendMessage with a text part and, when a path is given, a file
part: base64 bytes, a name (the path's last component) and a media type
guessed from the name, at most 8 MiB -- the same cap the server enforces on
the way in. The answer is text; a file the other side sends back is saved by
collect_parts and named by path, which the tool returns.
sp_b64_encode is the missing direction of the base64 helper, with vectors of
its own in test_b64: empty input, one and two trailing bytes, a NUL.
test_a2a: a real PNG is attached, the request carries name, mimeType and the
base64 bytes, and the other side names it in the answer; a missing path is an
error, not a silent empty message.
---
README.md | 10 +-
docs/PLUGINS.md | 10 +-
docs/ROADMAP.md | 2 +
plugins/a2a/a2a.c | 233 +++++++++++++++++++++++++++++++++++++++++-
src/b64.c | 35 +++++++
src/b64.h | 6 ++
src/www/index.en.html | 9 +-
src/www/index.html | 9 +-
src/www/index.pt.html | 8 +-
tests/fake_a2a.py | 16 +++
tests/test_a2a.sh | 26 +++++
tests/test_b64.c | 17 +++
tools/gen_www.py | 6 +-
13 files changed, 363 insertions(+), 24 deletions(-)
diff --git a/README.md b/README.md
index ad8adb3..a8475d6 100644
--- a/README.md
+++ b/README.md
@@ -121,8 +121,14 @@ the UI the turn streams: `SendStreamingMessage`, artifact text appearing as it
arrives. The task and context ids are kept for the session, so the next turn
continues the same A2A context. `SPLINTER_A2A_CARD` discovers the JSON-RPC
endpoint from an agent card; `SPLINTER_A2A_URL` sets it directly. One-shot mode
-streams by default; `--no-stream` asks for the blocking send. Text only; files,
-push notifications and `GetTask`/`CancelTask` are not built yet.
+streams by default; `--no-stream` asks for the blocking send.
+
+The transport sends text. A file goes with `a2a_send` — a message plus a `file`
+part (base64, 8 MiB cap, media type guessed from the name) — and a file the
+other side sends back is saved (`SPLINTER_A2A_INBOX`, default
+`$TMPDIR/splinter-a2a-inbox`) and named by path in the answer. `a2a_get_task`,
+`a2a_cancel_task` and `a2a_subscribe` (the SSE events of a task, as one text)
+use the same endpoint. Push notifications are not sent by the client.
## The other direction: splinter as an A2A server
diff --git a/docs/PLUGINS.md b/docs/PLUGINS.md
index 28a752e..0dc80eb 100644
--- a/docs/PLUGINS.md
+++ b/docs/PLUGINS.md
@@ -314,10 +314,12 @@ 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 on the client side, and named so nobody assumes otherwise:
-file/structured-data parts and push notifications (the client sends and streams). With a local
-transport, the plugin also registers `a2a_get_task`, `a2a_cancel_task` and
-`a2a_subscribe` (read/destructive/read); they use the same endpoint or card.
+The transport sends text; `a2a_send` (destructive) sends a message with an
+optional `file` part — base64, 8 MiB cap, `mimeType` guessed from the name when
+not given — and returns the other side's answer, saving a file it sends back.
+The client does not send push notifications. With a local transport, the plugin
+also registers `a2a_get_task`, `a2a_cancel_task` and `a2a_subscribe`
+(read/destructive/read); they use the same endpoint or card.
The first two return the raw task/error JSON; the subscription reads the SSE
events (`statusUpdate`, `artifactUpdate`, a whole task) into one text: the
state, the message and the artifact text, in the order the server sent them.
diff --git a/docs/ROADMAP.md b/docs/ROADMAP.md
index e481718..0ef3255 100644
--- a/docs/ROADMAP.md
+++ b/docs/ROADMAP.md
@@ -41,6 +41,8 @@ Stream.
`delegate`-Zeile in den Drop-in neben der benutzten Konfiguration, prueft sie
mit einem Test-Turn und registriert sie im laufenden Prozess
(`test_providers`, `test_gateway.sh`, `test_ui.sh`)
+- **A2A-Client mit Dateien**: `a2a_send` schickt eine Nachricht mit `file`-Teil
+ (base64, 8 MiB), empfangene Dateien landen im Inbox-Pfad (`test_a2a.sh`)
- **A2A-Client-Abo**: `a2a_subscribe` liest die Ereignisse eines fremden Tasks
als Text (Zustand, Nachricht, Artefakte) (`test_a2a.sh`)
- **Bilder als Foto**: Markdown-Bilder gehen als `sendPhoto` raus (Alt als
diff --git a/plugins/a2a/a2a.c b/plugins/a2a/a2a.c
index 3f75797..a876066 100644
--- a/plugins/a2a/a2a.c
+++ b/plugins/a2a/a2a.c
@@ -16,9 +16,10 @@
* of the session, so the next turn continues the same conversation.
*
* The tools a2a_get_task, a2a_cancel_task and a2a_subscribe use the same
- * endpoint: the subscription reads the SSE events into one text. A binary part
- * from the other agent is saved and named by path instead of being dropped.
- * The endpoint is configured directly:
+ * endpoint: the subscription reads the SSE events into one text. a2a_send
+ * attaches a file (base64 file part) to a message; a binary part from the other
+ * agent is saved and named by path instead of being dropped. The endpoint is
+ * configured directly:
*
* SPLINTER_A2A_URL the JSON-RPC endpoint (required)
* SPLINTER_A2A_TOKEN optional bearer token
@@ -1169,6 +1170,209 @@ answer_text(const char *json, struct sp_buf *out, int *seen)
mcp_json_free(v);
}
+/* the name the other side sees, and a media type it can act on */
+static const char *
+base_name(const char *path)
+{
+ const char *slash = strrchr(path, '/');
+
+ return slash != NULL ? slash + 1 : path;
+}
+
+static const char *
+guess_mime(const char *path)
+{
+ const char *dot = strrchr(path, '.');
+
+ if (dot == NULL)
+ return "application/octet-stream";
+ if (strcasecmp(dot, ".png") == 0)
+ return "image/png";
+ if (strcasecmp(dot, ".jpg") == 0 || strcasecmp(dot, ".jpeg") == 0)
+ return "image/jpeg";
+ if (strcasecmp(dot, ".gif") == 0)
+ return "image/gif";
+ if (strcasecmp(dot, ".webp") == 0)
+ return "image/webp";
+ if (strcasecmp(dot, ".pdf") == 0)
+ return "application/pdf";
+ if (strcasecmp(dot, ".json") == 0)
+ return "application/json";
+ if (strcasecmp(dot, ".md") == 0)
+ return "text/markdown";
+ if (strcasecmp(dot, ".txt") == 0)
+ return "text/plain";
+ return "application/octet-stream";
+}
+
+/* the bytes to attach: regular file, at most 8 MiB, same cap as the server */
+static int
+read_file(const char *path, struct sp_buf *out, struct sp_buf *err)
+{
+ FILE *f;
+ char chunk[4096];
+ size_t got;
+
+ f = fopen(path, "rb");
+ if (f == NULL) {
+ sp_buf_printf(err, "a2a: cannot read %s: %s", path,
+ strerror(errno));
+ return -1;
+ }
+ while ((got = fread(chunk, 1, sizeof(chunk), f)) > 0) {
+ if (out->len + got > 8u * 1024u * 1024u) {
+ sp_buf_puts(err, "a2a: the file is larger than 8 MiB");
+ fclose(f);
+ return -1;
+ }
+ if (sp_buf_add(out, chunk, got) != 0) {
+ sp_buf_puts(err, "a2a: out of memory");
+ fclose(f);
+ return -1;
+ }
+ }
+ if (ferror(f)) {
+ sp_buf_printf(err, "a2a: cannot read %s", path);
+ fclose(f);
+ return -1;
+ }
+ fclose(f);
+ if (out->len == 0) {
+ sp_buf_printf(err, "a2a: %s is empty", path);
+ return -1;
+ }
+ return 0;
+}
+
+/*
+ * a2a_send: a message, optionally with a file, on the side. The transport
+ * sends the conversation; this is for "hand this file to the other agent"
+ * without starting a whole turn. The answer is text, and a file the other side
+ * sends back is saved and named by path like any other answer.
+ */
+static int
+tool_send(const char *args, struct sp_buf *out, void *ctx)
+{
+ struct a2a_cfg *c = ctx;
+ struct sp_buf body, raw, bytes, enc, err;
+ struct sp_reply r;
+ mcp_json *v = NULL;
+ const char *text, *file, *mime, *name;
+ char rid[96], mid[96], *nl;
+ long http;
+
+ sp_buf_init(&body);
+ sp_buf_init(&raw);
+ sp_buf_init(&bytes);
+ sp_buf_init(&enc);
+ sp_buf_init(&err);
+ memset(&r, 0, sizeof(r));
+ v = args != NULL ? mcp_parse(args) : NULL;
+ if (v == NULL) {
+ sp_buf_puts(out, "error: arguments are not JSON");
+ goto out;
+ }
+ text = mcp_arg_string(v, "text");
+ file = mcp_arg_string(v, "file");
+ mime = mcp_arg_string(v, "mime");
+ name = mcp_arg_string(v, "name");
+ if (text == NULL)
+ text = "";
+ if (file != NULL && *file != '\0') {
+ if (read_file(file, &bytes, &err) != 0) {
+ sp_buf_puts(out, "error: ");
+ sp_buf_puts(out, err.p != NULL ? err.p : "cannot read");
+ goto out;
+ }
+ if (sp_b64_encode(bytes.p, bytes.len, &enc) != 0) {
+ sp_buf_puts(out, "error: out of memory");
+ goto out;
+ }
+ if (name == NULL || *name == '\0')
+ name = base_name(file);
+ if (mime == NULL || *mime == '\0')
+ mime = guess_mime(file);
+ }
+ if (*text == '\0' && enc.len == 0) {
+ sp_buf_puts(out, "error: nothing to send");
+ goto out;
+ }
+ if (discover(c, &err) != 0 || c->url[0] == '\0') {
+ sp_buf_puts(out, "error: ");
+ sp_buf_puts(out, err.p != NULL && err.len > 0 ? err.p :
+ "no SPLINTER_A2A_URL or SPLINTER_A2A_CARD");
+ goto out;
+ }
+ make_id(rid, sizeof(rid), "rpc");
+ make_id(mid, sizeof(mid), "msg");
+ if (sp_buf_printf(&body, "{\"jsonrpc\":\"2.0\",\"id\":\"%s\","
+ "\"method\":\"SendMessage\",\"params\":{\"message\":{"
+ "\"messageId\":\"%s\",\"role\":\"ROLE_USER\",", rid, mid) != 0)
+ goto oom;
+ if (c->context_id[0] != '\0') {
+ if (sp_buf_puts(&body, "\"contextId\":\"") != 0 ||
+ sp_json_escape(&body, c->context_id) != 0 ||
+ sp_buf_puts(&body, "\",") != 0)
+ goto oom;
+ }
+ if (sp_buf_puts(&body, "\"parts\":[{\"text\":\"") != 0 ||
+ sp_json_escape(&body, text) != 0 ||
+ sp_buf_puts(&body, "\"}") != 0)
+ goto oom;
+ if (enc.len > 0) {
+ if (sp_buf_puts(&body, ",{\"file\":{\"name\":\"") != 0 ||
+ sp_json_escape(&body, name) != 0 ||
+ sp_buf_puts(&body, "\",\"mimeType\":\"") != 0 ||
+ sp_json_escape(&body, mime) != 0 ||
+ sp_buf_puts(&body, "\",\"bytes\":\"") != 0 ||
+ sp_buf_add(&body, enc.p, enc.len) != 0 ||
+ sp_buf_puts(&body, "\"}}") != 0)
+ goto oom;
+ }
+ if (sp_buf_puts(&body, "]},\"configuration\":{"
+ "\"acceptedOutputModes\":[\"text/plain\"],"
+ "\"returnImmediately\":false}}}") != 0)
+ goto oom;
+ dump_request(body.p, body.len);
+ if (post(c, body.p, &raw, &err) != 0) {
+ sp_buf_puts(out, "error: ");
+ sp_buf_puts(out, err.p != NULL && err.len > 0 ? err.p :
+ "request failed");
+ goto out;
+ }
+ if (raw.len < 2 || (nl = strrchr(raw.p, '\n')) == NULL) {
+ sp_buf_puts(out, "error: unparseable response");
+ goto out;
+ }
+ http = strtol(nl + 1, NULL, 10);
+ *nl = '\0';
+ if (http < 200 || http > 299) {
+ sp_buf_printf(out, "error: HTTP %ld: %.200s", http,
+ raw.p != NULL ? raw.p : "");
+ goto out;
+ }
+ if (parse_answer(c, raw.p, &r, &err) != 0) {
+ sp_buf_puts(out, "error: ");
+ sp_buf_puts(out, err.p != NULL && err.len > 0 ? err.p :
+ "the other side did not answer");
+ goto out;
+ }
+ sp_buf_puts(out, r.content != NULL ? r.content : "");
+ goto out;
+oom:
+ sp_buf_puts(out, "error: out of memory");
+out:
+ sp_reply_free(&r);
+ if (v != NULL)
+ mcp_json_free(v);
+ sp_buf_free(&body);
+ sp_buf_free(&raw);
+ sp_buf_free(&bytes);
+ sp_buf_free(&enc);
+ sp_buf_free(&err);
+ return 0;
+}
+
static int
tool_subscribe(const char *args, struct sp_buf *out, void *ctx)
{
@@ -1385,7 +1589,7 @@ a2a_init(struct sp_host *h)
cfg.full = full != NULL && strcmp(full, "0") != 0;
{
- static struct sp_tool t_get, t_cancel, t_sub;
+ static struct sp_tool t_get, t_cancel, t_sub, t_send;
memset(&t_get, 0, sizeof(t_get));
t_get.name = "a2a_get_task";
@@ -1397,6 +1601,27 @@ a2a_init(struct sp_host *h)
t_get.ctx = &cfg;
(void)sp_host_add_tool(h, &t_get);
+ memset(&t_send, 0, sizeof(t_send));
+ t_send.name = "a2a_send";
+ t_send.description = "Send a message to the A2A agent, optionally "
+ "with a file attached (base64 in a file part), and return its "
+ "answer. A file the other side sends back is saved and named "
+ "by path.";
+ t_send.params = "{\"type\":\"object\",\"properties\":{"
+ "\"text\":{\"type\":\"string\",\"description\":"
+ "\"what to say\"},"
+ "\"file\":{\"type\":\"string\",\"description\":"
+ "\"path of a file to attach (max 8 MiB)\"},"
+ "\"mime\":{\"type\":\"string\",\"description\":"
+ "\"media type, guessed from the name otherwise\"},"
+ "\"name\":{\"type\":\"string\",\"description\":"
+ "\"file name the other side sees\"}},"
+ "\"required\":[\"text\"]}";
+ t_send.auth = SP_AUTH_DESTRUCTIVE;
+ t_send.run = tool_send;
+ t_send.ctx = &cfg;
+ (void)sp_host_add_tool(h, &t_send);
+
memset(&t_sub, 0, sizeof(t_sub));
t_sub.name = "a2a_subscribe";
t_sub.description = "Subscribe to an A2A task and return the events "
diff --git a/src/b64.c b/src/b64.c
index 11ec3f5..bc52a20 100644
--- a/src/b64.c
+++ b/src/b64.c
@@ -68,3 +68,38 @@ sp_b64_decode(const char *in, size_t len, struct sp_buf *out)
}
return 0;
}
+
+int
+sp_b64_encode(const void *data, size_t len, struct sp_buf *out)
+{
+ static const char tab[] =
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+ const unsigned char *p = data;
+ size_t i;
+
+ if (out == NULL || (data == NULL && len > 0))
+ return -1;
+ for (i = 0; i + 2 < len; i += 3) {
+ char o[4];
+
+ o[0] = tab[p[i] >> 2];
+ o[1] = tab[((p[i] & 0x03) << 4) | (p[i + 1] >> 4)];
+ o[2] = tab[((p[i + 1] & 0x0f) << 2) | (p[i + 2] >> 6)];
+ o[3] = tab[p[i + 2] & 0x3f];
+ if (sp_buf_add(out, o, 4) != 0)
+ return -1;
+ }
+ if (i < len) {
+ unsigned a = p[i];
+ unsigned b = i + 1 < len ? p[i + 1] : 0;
+ char o[4];
+
+ o[0] = tab[a >> 2];
+ o[1] = tab[((a & 0x03) << 4) | (b >> 4)];
+ o[2] = i + 1 < len ? tab[(b & 0x0f) << 2] : '=';
+ o[3] = '=';
+ if (sp_buf_add(out, o, 4) != 0)
+ return -1;
+ }
+ return 0;
+}
diff --git a/src/b64.h b/src/b64.h
index 28785af..a3afe26 100644
--- a/src/b64.h
+++ b/src/b64.h
@@ -13,4 +13,10 @@ struct sp_buf;
*/
int sp_b64_decode(const char *in, size_t len, struct sp_buf *out);
+/*
+ * The other direction: append the base64 of 'data' (with padding) to 'out'.
+ * Returns 0, or -1 when memory runs out.
+ */
+int sp_b64_encode(const void *data, size_t len, struct sp_buf *out);
+
#endif /* SPLINTER_B64_H */
diff --git a/src/www/index.en.html b/src/www/index.en.html
index 66e4da8..d6a48b0 100644
--- a/src/www/index.en.html
+++ b/src/www/index.en.html
@@ -53,8 +53,8 @@ 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.
-29277 lines of C99/POSIX ·
-26 tools · 35 test programs ·
+
29543 lines of C99/POSIX ·
+27 tools · 35 test programs ·
16 plugins · 42 palettes · BSD-3-Clause
What it is
@@ -187,7 +187,7 @@ in the header before anybody reads its prose.
As a client splinter fetches an MCP server's tools. As a server it offers its
own:
$ splinter --mcp-server-listen 0.0.0.0 --mcp-listen-port 8098
-splinter: MCP server on 0.0.0.0:8098 (26 tools, read only)
+splinter: MCP server on 0.0.0.0:8098 (27 tools, read only)
Another agent gets initialize, tools/list and
tools/call. Read tools are served; mutating and destructive ones only
with --autonomous — a foreign agent does not run shell commands
@@ -219,7 +219,8 @@ model is told the path. A mutating tool pauses as
INPUT_REQUIRED; a follow-up with taskId and
yes/no resumes; SubscribeToTask sends
the state once and ends the stream; on the client side a2a_subscribe
-reads a remote task's events as text. Beyond loopback the bearer token is
+reads a remote task's events as text and a2a_send attaches a file
+(base64) to a message. Beyond loopback the bearer token is
required.
Kid mode
diff --git a/src/www/index.html b/src/www/index.html
index e9f47c1..5a6641b 100644
--- a/src/www/index.html
+++ b/src/www/index.html
@@ -53,8 +53,8 @@ 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.
-29277 Zeilen C99/POSIX ·
-26 Werkzeuge · 35 Test-Programme ·
+
29543 Zeilen C99/POSIX ·
+27 Werkzeuge · 35 Test-Programme ·
16 Plugins · 42 Farbschemata · BSD-3-Clause
Was es ist
@@ -188,7 +188,7 @@ ist in der Kopfzeile sichtbar, bevor jemand seinen Text liest.
Als Client holt splinter die Werkzeuge eines MCP-Servers. Als Server stellt es
seine eigenen hin:
$ splinter --mcp-server-listen 0.0.0.0 --mcp-listen-port 8098
-splinter: MCP server on 0.0.0.0:8098 (26 tools, read only)
+splinter: MCP server on 0.0.0.0:8098 (27 tools, read only)
Ein anderer Agent bekommt initialize, tools/list und
tools/call. Lesende Werkzeuge werden bedient, mutierende und
destruktive nur mit --autonomous — ein fremder Agent fuehrt hier
@@ -220,7 +220,8 @@ geholt; binaere file/raw-Teile landen im
INPUT_REQUIRED; ein Folgeaufruf mit taskId und
yes/no setzt fort; SubscribeToTask
schickt den Zustand einmal und schliesst den Stream; als Client liest
-a2a_subscribe die Ereignisse eines fremden Tasks als Text. Jenseits von
+a2a_subscribe die Ereignisse eines fremden Tasks als Text, und
+a2a_send haengt eine Datei (base64) an eine Nachricht. Jenseits von
Loopback ist der Bearer-Token Pflicht.
Kindermodus
diff --git a/src/www/index.pt.html b/src/www/index.pt.html
index 8ae7a54..4d264fa 100644
--- a/src/www/index.pt.html
+++ b/src/www/index.pt.html
@@ -53,8 +53,8 @@ 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.
-29277 linhas C99/POSIX ·
-26 ferramentas · 35 programas de teste ·
+
29543 linhas C99/POSIX ·
+27 ferramentas · 35 programas de teste ·
16 plugins · 42 paletas · BSD-3-Clause
O que e
@@ -80,7 +80,7 @@ transcript na ordem em que acontecem.
entrar na frente com um gate: permitir, negar com motivo, ou nao opinar.
Ferramentas
-26 ferramentas: read, write, edit,
+
27 ferramentas: read, write, edit,
search, list, run, folder_history,
delegate, delegate_parallel, as de leitura do sistema e as de
skills, memoria e pesquisa na web.
@@ -139,7 +139,7 @@ poe suas proprias chaves.
As duas direcoes: MCP
$ splinter --mcp-server-listen 0.0.0.0 --mcp-listen-port 8098
-splinter: MCP server on 0.0.0.0:8098 (26 tools, read only)
+splinter: MCP server on 0.0.0.0:8098 (27 tools, read only)
Como cliente busca ferramentas; como servidor oferece as suas. Mutar so com
--autonomous.
diff --git a/tests/fake_a2a.py b/tests/fake_a2a.py
index 1f3e1ef..37e0b31 100644
--- a/tests/fake_a2a.py
+++ b/tests/fake_a2a.py
@@ -73,6 +73,16 @@ class H(http.server.BaseHTTPRequestHandler):
except Exception:
pass
rid = req.get("id")
+ # a file part: note it so the answer can name it
+ fpart = None
+ try:
+ for p in req["params"]["message"]["parts"]:
+ if "file" in p:
+ f = p["file"]
+ fpart = (f.get("name", ""),
+ len(base64.b64decode(f.get("bytes", ""))))
+ except Exception:
+ pass
ctype = "text/event-stream" if stream else "application/json"
method = req.get("method", "")
if method == "SubscribeToTask":
@@ -92,6 +102,12 @@ class H(http.server.BaseHTTPRequestHandler):
"artifact": {"artifactId": "a4", "parts": [
{"text": "abo teil"}]}}})).encode()
return self.reply(b, "text/event-stream")
+ if method == "SendMessage" and fpart is not None:
+ task = task_obj("TASK_STATE_COMPLETED",
+ "datei empfangen: %s %d" % fpart)
+ last_task = task
+ return self.reply({"jsonrpc": "2.0", "id": rid,
+ "result": {"task": task}})
if method == "GetTask":
task = last_task if last_task is not None else task_obj(
"TASK_STATE_COMPLETED", "a2a sagt hallo", "und tschuess")
diff --git a/tests/test_a2a.sh b/tests/test_a2a.sh
index ac850a8..fba3e4b 100755
--- a/tests/test_a2a.sh
+++ b/tests/test_a2a.sh
@@ -170,5 +170,31 @@ check test $? -eq 0
sess=$(ls -t "$D/home/.splinter"/sess-*.jsonl 2>/dev/null | head -1)
check grep -q -- '-32001' "$sess"
+# ---- a2a_send: a message with a file attached ----
+printf 'PNGDATA' > "$D/att.png"
+printf 'tool a2a_send {"text":"hier ist eine datei","file":"%s"}\nanswer done\n' \
+ "$D/att.png" > "$D/tool-send.txt"
+out=$(HOME="$D/home" SPLINTER_A2A_URL="http://127.0.0.1:$P/rpc" \
+ SPLINTER_A2A_TIMEOUT=20 ./splinter --no-config \
+ --plugin plugins/a2a/a2a.so --script "$D/tool-send.txt" \
+ -p "tool" --autonomous 2>&1)
+echo "$out" | grep -q '^done'
+check test $? -eq 0
+sess=$(ls -t "$D/home/.splinter"/sess-*.jsonl 2>/dev/null | head -1)
+check grep -q 'datei empfangen: att.png 7' "$sess"
+check grep -q '"file":{"name":"att.png","mimeType":"image/png"' "$D/req.log"
+check grep -q '"bytes":"UE5HREFUQQ=="' "$D/req.log"
+
+printf 'tool a2a_send {"text":"x","file":"%s/%s"}\nanswer done\n' \
+ "$D" "gibtsnicht.png" > "$D/tool-send2.txt"
+out=$(HOME="$D/home" SPLINTER_A2A_URL="http://127.0.0.1:$P/rpc" \
+ SPLINTER_A2A_TIMEOUT=20 ./splinter --no-config \
+ --plugin plugins/a2a/a2a.so --script "$D/tool-send2.txt" \
+ -p "tool" --autonomous 2>&1)
+echo "$out" | grep -q '^done'
+check test $? -eq 0
+sess=$(ls -t "$D/home/.splinter"/sess-*.jsonl 2>/dev/null | head -1)
+check grep -q 'cannot read' "$sess"
+
if [ "$fails" -eq 0 ]; then echo "test_a2a: ok"; exit 0; fi
exit 1
diff --git a/tests/test_b64.c b/tests/test_b64.c
index e1451fe..41a53fe 100644
--- a/tests/test_b64.c
+++ b/tests/test_b64.c
@@ -39,9 +39,26 @@ decode_is(const char *in, const char *want, size_t want_len)
sp_buf_free(&b);
}
+static void
+encode_is(const char *in, size_t len, const char *want)
+{
+ struct sp_buf b;
+
+ CHECK(sp_buf_init(&b) == 0);
+ CHECK(sp_b64_encode(in, len, &b) == 0);
+ CHECK(b.p != NULL && strcmp(b.p, want) == 0);
+ sp_buf_free(&b);
+}
+
int
main(void)
{
+ encode_is("", 0, "");
+ encode_is("hello", 5, "aGVsbG8=");
+ encode_is("Hello, World!", 13, "SGVsbG8sIFdvcmxkIQ==");
+ encode_is("\0", 1, "AA==");
+ encode_is("PNGDATA", 7, "UE5HREFUQQ==");
+
decode_is("", "", 0);
decode_is("aGVsbG8=", "hello", 5);
decode_is("aGVsbG8", "hello", 5); /* padding is optional */
diff --git a/tools/gen_www.py b/tools/gen_www.py
index 7b3ab15..f10d57c 100644
--- a/tools/gen_www.py
+++ b/tools/gen_www.py
@@ -466,7 +466,8 @@ geholt; binaere file/raw-Teile landen im
INPUT_REQUIRED; ein Folgeaufruf mit taskId und
yes/no setzt fort; SubscribeToTask
schickt den Zustand einmal und schliesst den Stream; als Client liest
-a2a_subscribe die Ereignisse eines fremden Tasks als Text. Jenseits von
+a2a_subscribe die Ereignisse eines fremden Tasks als Text, und
+a2a_send haengt eine Datei (base64) an eine Nachricht. Jenseits von
Loopback ist der Bearer-Token Pflicht.""",
]
@@ -522,7 +523,8 @@ model is told the path. A mutating tool pauses as
INPUT_REQUIRED; a follow-up with taskId and
yes/no resumes; SubscribeToTask sends
the state once and ends the stream; on the client side a2a_subscribe
-reads a remote task's events as text. Beyond loopback the bearer token is
+reads a remote task's events as text and a2a_send attaches a file
+(base64) to a message. Beyond loopback the bearer token is
required.""",
]