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.
This commit is contained in:
lotherk committed 2026-11-11 10:25:49 +00:00
1 parent a6d54d120b
commit 9c205dcd21
13 files changed
+363 -24

No files matched your search

+8 -2
View File
@@ -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
+6 -4
View File
@@ -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.
+2
View File
@@ -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
+229 -4
View File
@@ -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 "
+35
View File
@@ -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;
}
+6
View File
@@ -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 */
+5 -4
View File
@@ -53,8 +53,8 @@ hr { border: 0; border-top: 1px solid #1d2126; margin: 3em 0 1.5em 0; }
<h1>splinter<span>_</span></h1>
<p class="lead">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.</p>
<p class="meta"><b>29277</b> lines of C99/POSIX &middot;
<b>26</b> tools &middot; <b>35</b> test programs &middot;
<p class="meta"><b>29543</b> lines of C99/POSIX &middot;
<b>27</b> tools &middot; <b>35</b> test programs &middot;
<b>16</b> plugins &middot; <b>42</b> palettes &middot; BSD-3-Clause</p>
<h2>What it is</h2>
@@ -187,7 +187,7 @@ in the header before anybody reads its prose.</p>
<p>As a client splinter fetches an MCP server's tools. As a server it offers its
own:</p>
<pre><span class="u">$</span> 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)</pre>
splinter: MCP server on 0.0.0.0:8098 (27 tools, read only)</pre>
<p>Another agent gets <code>initialize</code>, <code>tools/list</code> and
<code>tools/call</code>. Read tools are served; mutating and destructive ones only
with <code>--autonomous</code> &mdash; a foreign agent does not run shell commands
@@ -219,7 +219,8 @@ model is told the path. A mutating tool pauses as
<code>INPUT_REQUIRED</code>; a follow-up with <code>taskId</code> and
<code>yes</code>/<code>no</code> resumes; <code>SubscribeToTask</code> sends
the state once and ends the stream; on the client side <code>a2a_subscribe</code>
reads a remote task's events as text. Beyond loopback the bearer token is
reads a remote task's events as text and <code>a2a_send</code> attaches a file
(base64) to a message. Beyond loopback the bearer token is
required.</p>
<h2>Kid mode</h2>
+5 -4
View File
@@ -53,8 +53,8 @@ hr { border: 0; border-top: 1px solid #1d2126; margin: 3em 0 1.5em 0; }
<h1>splinter<span>_</span></h1>
<p class="lead">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.</p>
<p class="meta"><b>29277</b> Zeilen C99/POSIX &middot;
<b>26</b> Werkzeuge &middot; <b>35</b> Test-Programme &middot;
<p class="meta"><b>29543</b> Zeilen C99/POSIX &middot;
<b>27</b> Werkzeuge &middot; <b>35</b> Test-Programme &middot;
<b>16</b> Plugins &middot; <b>42</b> Farbschemata &middot; BSD-3-Clause</p>
<h2>Was es ist</h2>
@@ -188,7 +188,7 @@ ist in der Kopfzeile sichtbar, bevor jemand seinen Text liest.</p>
<p>Als Client holt splinter die Werkzeuge eines MCP-Servers. Als Server stellt es
seine eigenen hin:</p>
<pre><span class="u">$</span> 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)</pre>
splinter: MCP server on 0.0.0.0:8098 (27 tools, read only)</pre>
<p>Ein anderer Agent bekommt <code>initialize</code>, <code>tools/list</code> und
<code>tools/call</code>. Lesende Werkzeuge werden bedient, mutierende und
destruktive nur mit <code>--autonomous</code> &mdash; ein fremder Agent fuehrt hier
@@ -220,7 +220,8 @@ geholt; binaere <code>file</code>/<code>raw</code>-Teile landen im
<code>INPUT_REQUIRED</code>; ein Folgeaufruf mit <code>taskId</code> und
<code>yes</code>/<code>no</code> setzt fort; <code>SubscribeToTask</code>
schickt den Zustand einmal und schliesst den Stream; als Client liest
<code>a2a_subscribe</code> die Ereignisse eines fremden Tasks als Text. Jenseits von
<code>a2a_subscribe</code> die Ereignisse eines fremden Tasks als Text, und
<code>a2a_send</code> haengt eine Datei (base64) an eine Nachricht. Jenseits von
Loopback ist der Bearer-Token Pflicht.</p>
<h2>Kindermodus</h2>
+4 -4
View File
@@ -53,8 +53,8 @@ hr { border: 0; border-top: 1px solid #1d2126; margin: 3em 0 1.5em 0; }
<h1>splinter<span>_</span></h1>
<p class="lead">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.</p>
<p class="meta"><b>29277</b> linhas C99/POSIX &middot;
<b>26</b> ferramentas &middot; <b>35</b> programas de teste &middot;
<p class="meta"><b>29543</b> linhas C99/POSIX &middot;
<b>27</b> ferramentas &middot; <b>35</b> programas de teste &middot;
<b>16</b> plugins &middot; <b>42</b> paletas &middot; BSD-3-Clause</p>
<h2>O que e</h2>
@@ -80,7 +80,7 @@ transcript na ordem em que acontecem.</p>
entrar na frente com um gate: permitir, negar com motivo, ou nao opinar.</p>
<h2>Ferramentas</h2>
<p>26 ferramentas: <code>read</code>, <code>write</code>, <code>edit</code>,
<p>27 ferramentas: <code>read</code>, <code>write</code>, <code>edit</code>,
<code>search</code>, <code>list</code>, <code>run</code>, <code>folder_history</code>,
<code>delegate</code>, <code>delegate_parallel</code>, as de leitura do sistema e as de
skills, memoria e pesquisa na web.</p>
@@ -139,7 +139,7 @@ poe suas proprias chaves.</p>
<h2>As duas direcoes: MCP</h2>
<pre><span class="u">$</span> 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)</pre>
splinter: MCP server on 0.0.0.0:8098 (27 tools, read only)</pre>
<p>Como cliente busca ferramentas; como servidor oferece as suas. Mutar so com
<code>--autonomous</code>.</p>
+16
View File
@@ -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")
+26
View File
@@ -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
+17
View File
@@ -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 */
+4 -2
View File
@@ -466,7 +466,8 @@ geholt; binaere <code>file</code>/<code>raw</code>-Teile landen im
<code>INPUT_REQUIRED</code>; ein Folgeaufruf mit <code>taskId</code> und
<code>yes</code>/<code>no</code> setzt fort; <code>SubscribeToTask</code>
schickt den Zustand einmal und schliesst den Stream; als Client liest
<code>a2a_subscribe</code> die Ereignisse eines fremden Tasks als Text. Jenseits von
<code>a2a_subscribe</code> die Ereignisse eines fremden Tasks als Text, und
<code>a2a_send</code> haengt eine Datei (base64) an eine Nachricht. Jenseits von
Loopback ist der Bearer-Token Pflicht.</p>""",
]
@@ -522,7 +523,8 @@ model is told the path. A mutating tool pauses as
<code>INPUT_REQUIRED</code>; a follow-up with <code>taskId</code> and
<code>yes</code>/<code>no</code> resumes; <code>SubscribeToTask</code> sends
the state once and ends the stream; on the client side <code>a2a_subscribe</code>
reads a remote task's events as text. Beyond loopback the bearer token is
reads a remote task's events as text and <code>a2a_send</code> attaches a file
(base64) to a message. Beyond loopback the bearer token is
required.</p>""",
]