a2a: stream from the server, and test both sides together
SendStreamingMessage on the A2A server answers with SSE now: an initial task event in WORKING, one artifactUpdate per streamed chunk (a non-streaming transport sends its whole answer as one chunk), then a completed statusUpdate. An error becomes an error event; the task is still stored for GetTask. test_a2a_server.sh runs the client half against the server half through the agent card, blocking and streaming, besides the direct curl checks. README, PLUGINS.md, TODO, ROADMAP and the site follow.
This commit is contained in:
1 parent
e5c533340f
commit
76883bfa3a
10 files changed
+273
-49
No files matched your search
@@ -132,11 +132,12 @@ SPLINTER_A2A_SERVER_TOKEN=... \
|
||||
```
|
||||
|
||||
Another agent can send `SendMessage` to `POST /a2a` and poll `GetTask`; the
|
||||
agent card is served at `/.well-known/agent-card.json`. Each request runs one
|
||||
turn in its own conversation. Streaming, files, push notifications, `CancelTask`
|
||||
and continuation of an interrupted task are refused with a JSON-RPC error rather
|
||||
than half-answered. Beyond loopback the bearer token is required; there is no
|
||||
TLS, so put it behind ssh or a tunnel.
|
||||
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,
|
||||
`CancelTask` and continuation of an interrupted task are refused with a JSON-RPC
|
||||
error rather than half-answered. Beyond loopback the bearer token is required;
|
||||
there is no TLS, so put it behind ssh or a tunnel.
|
||||
|
||||
## Configuration
|
||||
|
||||
|
||||
@@ -46,17 +46,16 @@ erscheint waehrend des Laufs, Zwischenstatus wird nicht angehaengt. Task- und
|
||||
Context-Id bleiben fuer die Sitzung; ein terminaler Task verliert seine Id, der
|
||||
Context bleibt. `SPLINTER_A2A_CARD` findet den Endpunkt ueber die Agent Card.
|
||||
|
||||
Der Server ist als MVP gebaut: `src/a2aserver.c`, `POST /a2a` mit
|
||||
`SendMessage` (ein Turn in eigener Konversation, completed Task) und `GetTask`,
|
||||
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`,
|
||||
`GET /.well-known/agent-card.json`, Bearer-Token ueber
|
||||
`SPLINTER_A2A_SERVER_TOKEN` jenseits von Loopback.
|
||||
|
||||
Offen: Streaming auf der Server-Seite, Datei- und strukturierte Teile,
|
||||
Push-Notifications, `CancelTask`/`SubscribeToTask` und die Fortsetzung eines
|
||||
unterbrochenen Tasks.
|
||||
Offen: Datei- und strukturierte Teile, Push-Notifications,
|
||||
`CancelTask`/`SubscribeToTask` und die Fortsetzung eines unterbrochenen Tasks.
|
||||
|
||||
Naechster Schritt: Server-Streaming oder Multiturn, je nachdem was die Flotte
|
||||
zuerst braucht.
|
||||
Naechster Schritt: Multiturn (Task-Fortsetzung), danach Datei-Teile.
|
||||
|
||||
### 4. `~/.local/lib` enthaelt Fremdlast
|
||||
|
||||
@@ -96,10 +95,11 @@ Naechster Schritt: entscheiden, ob die npm-Reste weg duerfen. Kein Code.
|
||||
- **A2A-Client und -Server**: `plugins/a2a/a2a.c` sendet `SendMessage`
|
||||
(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`, `GetTask` und die Agent Card mit
|
||||
Bearer-Token. `tests/test_a2a.sh` prueft Task, Message, Token, Fehler,
|
||||
`src/a2aserver.c` serviert `SendMessage`, `SendStreamingMessage` (SSE),
|
||||
`GetTask` 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.
|
||||
`tests/test_a2a_server.sh` den Server und den Client gegen den Server
|
||||
(Discovery, blockierend und streamend).
|
||||
- **Fehler dabei gefunden und behoben**: `delegate_retry` las `id` und `force`
|
||||
in denselben Puffer; `json_str` haengt an, also wurde aus `job-1` mit
|
||||
`force=1` die Id `job-11` (`src/delegate.c`, `tool_delegate_retry`).
|
||||
|
||||
+9
-5
@@ -313,10 +313,14 @@ needs the agent and its authorization model, not only a transport.
|
||||
|
||||
`POST /a2a` speaks JSON-RPC: `SendMessage` runs one turn in a fresh conversation
|
||||
(system prompt plus the caller's text), stores the completed Task and returns it;
|
||||
`GetTask` returns a stored task; `GET /.well-known/agent-card.json` serves a card
|
||||
with the `JSONRPC` interface. One request at a time, one connection at a time.
|
||||
`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`
|
||||
interface. One request at a time, one connection at a time.
|
||||
|
||||
Refused with a JSON-RPC error, not half-answered: `SendStreamingMessage`,
|
||||
`CancelTask`, `SubscribeToTask`, file/structured parts and push notifications.
|
||||
Beyond loopback `SPLINTER_A2A_SERVER_TOKEN` is required and checked as
|
||||
Refused with a JSON-RPC error, not half-answered: `CancelTask`,
|
||||
`SubscribeToTask`, file/structured parts and push notifications, plus
|
||||
continuation of an interrupted task. Beyond loopback
|
||||
`SPLINTER_A2A_SERVER_TOKEN` is required and checked as
|
||||
`Authorization: Bearer ...`; there is no TLS.
|
||||
+2
-2
@@ -4,8 +4,8 @@ Stand: 2026-11-09. Die geprüfte, ausführliche Liste mit Belegen steht in
|
||||
`TODO.md`; hier bleibt die Reihenfolge, was als Nächstes gebaut wird.
|
||||
|
||||
1. **A2A: was noch fehlt** — Client (`SendMessage`, `SendStreamingMessage` in
|
||||
der UI, Agent-Card-Discovery) und Server-MVP (`SendMessage`, `GetTask`,
|
||||
Agent Card) stehen, alles mit Text. Offen sind Server-Streaming, Datei- und
|
||||
der UI, Agent-Card-Discovery) und Server (`SendMessage`, SSE-Streaming,
|
||||
`GetTask`, 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.
|
||||
|
||||
+203
-8
@@ -12,10 +12,11 @@
|
||||
* POST /a2a GetTask -> the stored task
|
||||
* GET /.well-known/agent-card.json
|
||||
*
|
||||
* Deliberately not here yet: streaming (SendStreamingMessage), file and
|
||||
* structured-data parts, push notifications, CancelTask, and multi-turn
|
||||
* continuation of an interrupted task. Each of those is refused with a
|
||||
* JSON-RPC error rather than answered with half a protocol.
|
||||
* Deliberately not here yet: file and structured-data parts, push
|
||||
* notifications, CancelTask, and multi-turn continuation of an interrupted
|
||||
* task. Each of those is refused with a JSON-RPC error rather than answered
|
||||
* with half a protocol. Streaming is served: SendStreamingMessage writes
|
||||
* artifactUpdate and statusUpdate events over SSE.
|
||||
*
|
||||
* One turn per request, one connection at a time. The conversation is local to
|
||||
* the request (the system prompt plus the caller's text), so two remote agents
|
||||
@@ -266,8 +267,14 @@ task_find(const char *id)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gen_task_id(char *out, size_t cap)
|
||||
{
|
||||
snprintf(out, cap, "task-%d-%u", (int)getpid(), g_seq + 1);
|
||||
}
|
||||
|
||||
static struct a2a_task *
|
||||
task_store(const char *context, const struct sp_buf *answer)
|
||||
task_store_id(const char *id, const char *context, const struct sp_buf *answer)
|
||||
{
|
||||
struct a2a_task *t = &g_tasks[g_seq % A2A_TASKS];
|
||||
|
||||
@@ -277,7 +284,11 @@ task_store(const char *context, const struct sp_buf *answer)
|
||||
memset(t, 0, sizeof(*t));
|
||||
if (sp_buf_init(&t->answer) != 0)
|
||||
return NULL;
|
||||
snprintf(t->id, sizeof(t->id), "task-%d-%u", (int)getpid(), g_seq);
|
||||
if (id != NULL && *id != '\0')
|
||||
snprintf(t->id, sizeof(t->id), "%s", id);
|
||||
else
|
||||
snprintf(t->id, sizeof(t->id), "task-%d-%u", (int)getpid(),
|
||||
g_seq);
|
||||
snprintf(t->context, sizeof(t->context), "%s", context);
|
||||
if (sp_buf_add(&t->answer, answer->p, answer->len) != 0) {
|
||||
sp_buf_free(&t->answer);
|
||||
@@ -287,6 +298,12 @@ task_store(const char *context, const struct sp_buf *answer)
|
||||
return t;
|
||||
}
|
||||
|
||||
static struct a2a_task *
|
||||
task_store(const char *context, const struct sp_buf *answer)
|
||||
{
|
||||
return task_store_id(NULL, context, answer);
|
||||
}
|
||||
|
||||
static void
|
||||
task_json(struct sp_buf *b, const struct a2a_task *t)
|
||||
{
|
||||
@@ -360,6 +377,185 @@ run_turn(struct sp_agent *ag, const char *text, struct sp_buf *answer,
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
* Server-side streaming: the turn runs with a callback that writes one A2A
|
||||
* artifactUpdate per chunk. A transport that cannot stream (cli, script) runs
|
||||
* to completion and its whole answer goes out as one artifact, so the shape is
|
||||
* the same for the client either way.
|
||||
*/
|
||||
struct sse_out {
|
||||
int fd;
|
||||
char id[128];
|
||||
char task_id[64];
|
||||
char context[128];
|
||||
size_t emitted;
|
||||
};
|
||||
|
||||
static void
|
||||
sse_write(struct sse_out *o, const char *result)
|
||||
{
|
||||
struct sp_buf b;
|
||||
|
||||
if (sp_buf_init(&b) != 0)
|
||||
return;
|
||||
sp_buf_printf(&b, "data: {\"jsonrpc\":\"2.0\",\"id\":%s,"
|
||||
"\"result\":%s}\n\n", o->id[0] != '\0' ? o->id : "null", result);
|
||||
write_all(o->fd, b.p, b.len);
|
||||
sp_buf_free(&b);
|
||||
}
|
||||
|
||||
static void
|
||||
sse_error(struct sse_out *o, int code, const char *message)
|
||||
{
|
||||
struct sp_buf b;
|
||||
|
||||
if (sp_buf_init(&b) != 0)
|
||||
return;
|
||||
sp_buf_printf(&b, "data: {\"jsonrpc\":\"2.0\",\"id\":%s,"
|
||||
"\"error\":{\"code\":%d,\"message\":\"",
|
||||
o->id[0] != '\0' ? o->id : "null", code);
|
||||
sp_json_escape(&b, message);
|
||||
sp_buf_puts(&b, "\"}}\n\n");
|
||||
write_all(o->fd, b.p, b.len);
|
||||
sp_buf_free(&b);
|
||||
}
|
||||
|
||||
static void
|
||||
sse_task(struct sse_out *o, const char *state)
|
||||
{
|
||||
struct sp_buf b;
|
||||
|
||||
if (sp_buf_init(&b) != 0)
|
||||
return;
|
||||
sp_buf_printf(&b, "{\"task\":{\"id\":\"%s\",\"contextId\":\"%s\","
|
||||
"\"status\":{\"state\":\"%s\"}}}", o->task_id, o->context, state);
|
||||
sse_write(o, b.p);
|
||||
sp_buf_free(&b);
|
||||
}
|
||||
|
||||
static void
|
||||
sse_artifact(struct sse_out *o, const char *text)
|
||||
{
|
||||
struct sp_buf b;
|
||||
|
||||
if (sp_buf_init(&b) != 0)
|
||||
return;
|
||||
sp_buf_printf(&b, "{\"artifactUpdate\":{\"taskId\":\"%s\","
|
||||
"\"contextId\":\"%s\",\"artifact\":{\"artifactId\":\"answer\","
|
||||
"\"parts\":[{\"text\":\"", o->task_id, o->context);
|
||||
sp_json_escape(&b, text);
|
||||
sp_buf_puts(&b, "\"}]},\"append\":true}}");
|
||||
sse_write(o, b.p);
|
||||
sp_buf_free(&b);
|
||||
o->emitted += strlen(text);
|
||||
}
|
||||
|
||||
static void
|
||||
sse_status(struct sse_out *o, const char *state)
|
||||
{
|
||||
struct sp_buf b;
|
||||
|
||||
if (sp_buf_init(&b) != 0)
|
||||
return;
|
||||
sp_buf_printf(&b, "{\"statusUpdate\":{\"taskId\":\"%s\","
|
||||
"\"contextId\":\"%s\",\"status\":{\"state\":\"%s\"}}}",
|
||||
o->task_id, o->context, state);
|
||||
sse_write(o, b.p);
|
||||
sp_buf_free(&b);
|
||||
}
|
||||
|
||||
static void
|
||||
sse_text(void *ctx, int kind, const char *text)
|
||||
{
|
||||
struct sse_out *o = ctx;
|
||||
|
||||
if (kind != SP_STREAM_TEXT || text == NULL || *text == '\0')
|
||||
return;
|
||||
sse_artifact(o, text);
|
||||
}
|
||||
|
||||
static void
|
||||
sse_start(int fd)
|
||||
{
|
||||
const char *h = "HTTP/1.1 200 OK\r\nContent-Type: text/event-stream\r\n"
|
||||
"Connection: close\r\n\r\n";
|
||||
|
||||
write_all(fd, h, strlen(h));
|
||||
}
|
||||
|
||||
static void
|
||||
handle_stream(int fd, struct sp_agent *ag, const char *id,
|
||||
const mcp_json *params)
|
||||
{
|
||||
const mcp_json *message, *parts;
|
||||
const char *ctx;
|
||||
struct sse_out o;
|
||||
struct sp_buf text, answer, err;
|
||||
struct sp_agent_config cfg;
|
||||
const struct sp_agent_config *saved;
|
||||
int rc;
|
||||
|
||||
memset(&o, 0, sizeof(o));
|
||||
memset(&text, 0, sizeof(text));
|
||||
memset(&answer, 0, sizeof(answer));
|
||||
memset(&err, 0, sizeof(err));
|
||||
o.fd = fd;
|
||||
snprintf(o.id, sizeof(o.id), "%s", id != NULL ? id : "");
|
||||
gen_task_id(o.task_id, sizeof(o.task_id));
|
||||
if (sp_buf_init(&text) != 0 || sp_buf_init(&answer) != 0 ||
|
||||
sp_buf_init(&err) != 0) {
|
||||
const char *h = "HTTP/1.1 500 Internal Server Error\r\n"
|
||||
"Content-Length: 2\r\nConnection: close\r\n\r\n{}";
|
||||
|
||||
write_all(fd, h, strlen(h));
|
||||
sp_buf_free(&text);
|
||||
sp_buf_free(&answer);
|
||||
sp_buf_free(&err);
|
||||
return;
|
||||
}
|
||||
sse_start(fd);
|
||||
message = mcp_arg(params, "message");
|
||||
parts = message != NULL ? mcp_arg(message, "parts") : NULL;
|
||||
if (!collect_text(parts, &text)) {
|
||||
sse_error(&o, -32602, "message has no text parts");
|
||||
goto out;
|
||||
}
|
||||
ctx = mcp_arg_string(message, "contextId");
|
||||
snprintf(o.context, sizeof(o.context), "%s",
|
||||
ctx != NULL && *ctx != '\0' ? ctx : "ctx-local");
|
||||
if (ag->cfg == NULL) {
|
||||
sse_error(&o, -32603, "no agent configuration");
|
||||
goto out;
|
||||
}
|
||||
sse_task(&o, "TASK_STATE_WORKING");
|
||||
saved = ag->cfg;
|
||||
cfg = *ag->cfg;
|
||||
cfg.stream = sse_text;
|
||||
cfg.stream_ctx = &o;
|
||||
ag->cfg = &cfg;
|
||||
rc = run_turn(ag, text.p != NULL ? text.p : "", &answer, &err);
|
||||
ag->cfg = saved;
|
||||
if (rc != 0) {
|
||||
sse_error(&o, -32603, err.p != NULL && err.len > 0 ?
|
||||
err.p : "the turn failed");
|
||||
goto out;
|
||||
}
|
||||
if (o.emitted == 0) {
|
||||
if (answer.p == NULL || answer.len == 0) {
|
||||
sse_error(&o, -32603, "empty answer");
|
||||
goto out;
|
||||
}
|
||||
sse_artifact(&o, answer.p);
|
||||
}
|
||||
sse_status(&o, "TASK_STATE_COMPLETED");
|
||||
(void)task_store_id(o.task_id, o.context, &answer);
|
||||
|
||||
out:
|
||||
sp_buf_free(&text);
|
||||
sp_buf_free(&answer);
|
||||
sp_buf_free(&err);
|
||||
}
|
||||
|
||||
static void
|
||||
handle_rpc(int fd, struct sp_agent *ag, const char *payload)
|
||||
{
|
||||
@@ -450,8 +646,7 @@ send_out:
|
||||
rpc_result(fd, id, out.p != NULL ? out.p : "{}");
|
||||
sp_buf_free(&out);
|
||||
} else if (strcmp(method, "SendStreamingMessage") == 0) {
|
||||
rpc_error(fd, id, -32601, "streaming is not served here; "
|
||||
"use SendMessage");
|
||||
handle_stream(fd, ag, id, params);
|
||||
} else if (strcmp(method, "CancelTask") == 0 ||
|
||||
strcmp(method, "SubscribeToTask") == 0) {
|
||||
rpc_error(fd, id, -32601, "not served here");
|
||||
|
||||
@@ -53,7 +53,7 @@ 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>23460</b> lines of C99/POSIX ·
|
||||
<p class="meta"><b>23655</b> lines of C99/POSIX ·
|
||||
<b>23</b> tools · <b>31</b> test programs ·
|
||||
<b>16</b> plugins · <b>42</b> palettes · BSD-3-Clause</p>
|
||||
|
||||
@@ -206,8 +206,8 @@ of letting it guess; the profile from the interview lives in
|
||||
itself:</p>
|
||||
<pre><span class="u">$</span> 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)</pre>
|
||||
<p><code>POST /a2a</code> takes <code>SendMessage</code> and <code>GetTask</code>
|
||||
as JSON-RPC; the agent card lives at
|
||||
<p><code>POST /a2a</code> takes <code>SendMessage</code>, <code>SendStreamingMessage</code>
|
||||
(SSE) and <code>GetTask</code> as JSON-RPC; the agent card lives at
|
||||
<code>/.well-known/agent-card.json</code>. One turn per request, its own
|
||||
conversation. Beyond loopback the bearer token is required.</p>
|
||||
|
||||
|
||||
+3
-3
@@ -53,7 +53,7 @@ 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>23460</b> Zeilen C99/POSIX ·
|
||||
<p class="meta"><b>23655</b> Zeilen C99/POSIX ·
|
||||
<b>23</b> Werkzeuge · <b>31</b> Test-Programme ·
|
||||
<b>16</b> Plugins · <b>42</b> Farbschemata · BSD-3-Clause</p>
|
||||
|
||||
@@ -207,8 +207,8 @@ ist, statt es raten zu lassen; das Profil aus dem Interview liegt in
|
||||
sich selbst hin:</p>
|
||||
<pre><span class="u">$</span> 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)</pre>
|
||||
<p><code>POST /a2a</code> nimmt <code>SendMessage</code> und <code>GetTask</code>
|
||||
als JSON-RPC; die Agent Card liegt unter
|
||||
<p><code>POST /a2a</code> nimmt <code>SendMessage</code>, <code>SendStreamingMessage</code>
|
||||
(SSE) und <code>GetTask</code> als JSON-RPC; die Agent Card liegt unter
|
||||
<code>/.well-known/agent-card.json</code>. Ein Turn pro Anfrage, eigene
|
||||
Konversation. Jenseits von Loopback ist der Bearer-Token Pflicht.</p>
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ 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>23460</b> linhas C99/POSIX ·
|
||||
<p class="meta"><b>23655</b> linhas C99/POSIX ·
|
||||
<b>23</b> ferramentas · <b>31</b> programas de teste ·
|
||||
<b>16</b> plugins · <b>42</b> paletas · BSD-3-Clause</p>
|
||||
|
||||
@@ -154,8 +154,8 @@ fecha o dia quando acaba.</p>
|
||||
si mesmo:</p>
|
||||
<pre><span class="u">$</span> 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)</pre>
|
||||
<p><code>POST /a2a</code> aceita <code>SendMessage</code> e <code>GetTask</code>
|
||||
em JSON-RPC; o agent card fica em
|
||||
<p><code>POST /a2a</code> aceita <code>SendMessage</code>, <code>SendStreamingMessage</code>
|
||||
(SSE) e <code>GetTask</code> em JSON-RPC; o agent card fica em
|
||||
<code>/.well-known/agent-card.json</code>. Um turno por requisicao, conversa
|
||||
propria. Fora do loopback o token Bearer e obrigatorio.</p>
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ cleanup() {
|
||||
}
|
||||
trap cleanup EXIT
|
||||
mkdir -p "$D/home"
|
||||
printf 'answer hallo von splinter\n' > "$D/model.txt"
|
||||
printf 'answer hallo von splinter\nanswer hallo von splinter\nanswer hallo von splinter\nanswer hallo von splinter\n' > "$D/model.txt"
|
||||
|
||||
fails=0
|
||||
check() { if "$@"; then :; else echo "FAIL $*"; fails=$((fails + 1)); fi; }
|
||||
@@ -65,9 +65,18 @@ resp2=$(post "$P" "{\"jsonrpc\":\"2.0\",\"id\":\"2\",\"method\":\"GetTask\",\"pa
|
||||
echo "$resp2" | grep -q 'hallo von splinter'
|
||||
check test $? -eq 0
|
||||
|
||||
# streaming is refused, not half-answered
|
||||
resp3=$(post "$P" "{\"jsonrpc\":\"2.0\",\"id\":\"3\",\"method\":\"SendStreamingMessage\",\"params\":{\"message\":{\"messageId\":\"m\",\"role\":\"ROLE_USER\",\"parts\":[{\"text\":\"x\"}]}}}")
|
||||
echo "$resp3" | grep -q '"code":-32601'
|
||||
# streaming: SSE with an artifact and a completed status
|
||||
resp3=$(post "$P" "{\"jsonrpc\":\"2.0\",\"id\":\"3\",\"method\":\"SendStreamingMessage\",\"params\":{\"message\":{\"messageId\":\"m\",\"role\":\"ROLE_USER\",\"parts\":[{\"text\":\"hallo\"}]}}}")
|
||||
echo "$resp3" | grep -q 'artifactUpdate'
|
||||
check test $? -eq 0
|
||||
echo "$resp3" | grep -q 'hallo von splinter'
|
||||
check test $? -eq 0
|
||||
echo "$resp3" | grep -q 'TASK_STATE_COMPLETED'
|
||||
check test $? -eq 0
|
||||
|
||||
# CancelTask is still refused, not half-answered
|
||||
resp6=$(post "$P" '{"jsonrpc":"2.0","id":"6","method":"CancelTask","params":{}}')
|
||||
echo "$resp6" | grep -q '"code":-32601'
|
||||
check test $? -eq 0
|
||||
|
||||
# a task that does not exist is a JSON-RPC error, not an empty answer
|
||||
@@ -75,6 +84,21 @@ resp4=$(post "$P" "{\"jsonrpc\":\"2.0\",\"id\":\"4\",\"method\":\"GetTask\",\"pa
|
||||
echo "$resp4" | grep -q '"code":-32001'
|
||||
check test $? -eq 0
|
||||
|
||||
# ---- the client half against the server half ----
|
||||
# discovery (the agent card names /a2a) plus a blocking turn, then the
|
||||
# streaming path: both sides of the protocol in one process pair
|
||||
cardurl="http://127.0.0.1:$P/.well-known/agent-card.json"
|
||||
out=$(HOME="$D/home" SPLINTER_A2A_CARD="$cardurl" SPLINTER_A2A_TIMEOUT=20 \
|
||||
./splinter --no-config --plugin plugins/a2a/a2a.so --transport a2a \
|
||||
--no-stream -p "hallo" 2>&1)
|
||||
echo "$out" | grep -q 'hallo von splinter'
|
||||
check test $? -eq 0
|
||||
out=$(HOME="$D/home" SPLINTER_A2A_CARD="$cardurl" SPLINTER_A2A_TIMEOUT=20 \
|
||||
./splinter --no-config --plugin plugins/a2a/a2a.so --transport a2a \
|
||||
-p "hallo" 2>&1)
|
||||
echo "$out" | grep -q 'hallo von splinter'
|
||||
check test $? -eq 0
|
||||
|
||||
# ---- token: without it a request is 401, with it the turn runs ----
|
||||
HOME="$D/home" SPLINTER_A2A_SERVER_TOKEN=tok ./splinter --no-config \
|
||||
--script "$D/model.txt" --a2a-server-listen 127.0.0.1 \
|
||||
|
||||
+6
-6
@@ -454,8 +454,8 @@ ist, statt es raten zu lassen; das Profil aus dem Interview liegt in
|
||||
sich selbst hin:</p>
|
||||
<pre><span class="u">$</span> 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)</pre>
|
||||
<p><code>POST /a2a</code> nimmt <code>SendMessage</code> und <code>GetTask</code>
|
||||
als JSON-RPC; die Agent Card liegt unter
|
||||
<p><code>POST /a2a</code> nimmt <code>SendMessage</code>, <code>SendStreamingMessage</code>
|
||||
(SSE) und <code>GetTask</code> als JSON-RPC; die Agent Card liegt unter
|
||||
<code>/.well-known/agent-card.json</code>. Ein Turn pro Anfrage, eigene
|
||||
Konversation. Jenseits von Loopback ist der Bearer-Token Pflicht.</p>""",
|
||||
]
|
||||
@@ -500,8 +500,8 @@ of letting it guess; the profile from the interview lives in
|
||||
itself:</p>
|
||||
<pre><span class="u">$</span> 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)</pre>
|
||||
<p><code>POST /a2a</code> takes <code>SendMessage</code> and <code>GetTask</code>
|
||||
as JSON-RPC; the agent card lives at
|
||||
<p><code>POST /a2a</code> takes <code>SendMessage</code>, <code>SendStreamingMessage</code>
|
||||
(SSE) and <code>GetTask</code> as JSON-RPC; the agent card lives at
|
||||
<code>/.well-known/agent-card.json</code>. One turn per request, its own
|
||||
conversation. Beyond loopback the bearer token is required.</p>""",
|
||||
]
|
||||
@@ -590,8 +590,8 @@ fecha o dia quando acaba.</p>""",
|
||||
si mesmo:</p>
|
||||
<pre><span class="u">$</span> 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)</pre>
|
||||
<p><code>POST /a2a</code> aceita <code>SendMessage</code> e <code>GetTask</code>
|
||||
em JSON-RPC; o agent card fica em
|
||||
<p><code>POST /a2a</code> aceita <code>SendMessage</code>, <code>SendStreamingMessage</code>
|
||||
(SSE) e <code>GetTask</code> em JSON-RPC; o agent card fica em
|
||||
<code>/.well-known/agent-card.json</code>. Um turno por requisicao, conversa
|
||||
propria. Fora do loopback o token Bearer e obrigatorio.</p>""",
|
||||
]
|
||||
|
||||
Reference in new issue
Block a user