From 624fcf3d483cba9fa36ff28939f5c7fff61416b9 Mon Sep 17 00:00:00 2001
From: lotherk
Date: Tue, 10 Nov 2026 08:49:27 +0000
Subject: [PATCH] a2a: URL text parts and push-config CRUD; .local/lib
untangled
A text/plain url part is fetched from loopback or a host in
SPLINTER_A2A_URL_ALLOW (1 MiB, no redirects); binary and other media
types stay refused. The four push-config methods create/get/list/delete
in-memory configs per task.
~/.local/lib is a real directory now: libsplinter.so plus a node_modules
symlink to ../npm/node_modules. The npm tree is not leftover -- it is
the mcp-local-memory MCP server and the Python user dirs -- so npm
root -g, the module and the installed splinter are verified working;
nothing was deleted.
Full make check green.
---
TODO.md | 34 ++--
docs/PLUGINS.md | 12 +-
src/a2aserver.c | 336 ++++++++++++++++++++++++++++++++++++---
src/www/index.en.html | 5 +-
src/www/index.html | 6 +-
src/www/index.pt.html | 5 +-
tests/fake_webhook.py | 10 ++
tests/test_a2a_server.sh | 29 +++-
tools/gen_www.py | 10 +-
9 files changed, 394 insertions(+), 53 deletions(-)
diff --git a/TODO.md b/TODO.md
index 8ef4c7f..66e9c37 100644
--- a/TODO.md
+++ b/TODO.md
@@ -32,25 +32,23 @@ nicht abgerufen. Push an Webhooks und Multiturn ueber `contextId` stehen.
Der Client registriert `a2a_get_task` und `a2a_cancel_task` (read/destructive)
fuer ein lokales Modell, das ihn als Werkzeugquelle nutzt; der Server liefert
-`GetTask` als Task-Objekt (nicht als `{"task":...}`).
+`GetTask` als Task-Objekt (nicht als `{"task":...}`). Push-Configs lassen sich
+per CRUD verwalten; text/plain-URL-Teile werden von Loopback oder
+`SPLINTER_A2A_URL_ALLOW` geholt (1 MiB, keine Redirects).
-Offen: die Fortsetzung eines unterbrochenen Tasks (`INPUT_REQUIRED`) und die
-Push-Config-CRUD-Methoden. URL- und binaere Teile bleiben bewusst abgelehnt.
+Offen: die Fortsetzung eines unterbrochenen Tasks (`INPUT_REQUIRED`). Binaere
+Teile bleiben bewusst abgelehnt.
Naechster Schritt: ein pausierbarer Turn fuer INPUT_REQUIRED.
-### 2. `~/.local/lib` enthaelt Fremdlast
-
-`~/.local/lib` ist ein Symlink auf `~/.local/npm`. Dort liegen `node_modules`,
-`package.json` und `package-lock.json` aus einem frueheren Projekt (Maerz 2026) —
-und seit `make install PREFIX=$HOME/.local` auch `libsplinter.so`. Nur die
-npm-Dateien sind Fremdlast; das Verzeichnis ist inzwischen auch das
-Installationsziel.
-
-Naechster Schritt: entscheiden, ob die npm-Reste weg duerfen. Kein Code.
-
## Erledigt
+- **`~/.local/lib` entwirrt**: `~/.local/lib` ist jetzt ein echtes Verzeichnis
+ mit `libsplinter.so` und einem `node_modules`-Symlink auf
+ `../npm/node_modules`. Der npm-Baum ist keine Fremdlast: er enthaelt
+ `mcp-local-memory` (der MCP, auf den `~/.local/bin/mcp-local-memory` zeigt)
+ und die Python-User-Verzeichnisse. `npm root -g`, das Modul und
+ `~/.local/bin/splinter --version` sind geprueft; nichts geloescht.
- **Kids-Zustimmung ueber echtes Telegram**: Am 2026-11-10 wurde Anfrage
`548769685` an `@hbx_splinter_bot` geschickt; die Antwort `ok 548769685` kam
im Chat, das Gateway loeste sie auf, der `write` lief und schrieb
@@ -81,10 +79,12 @@ 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`, `ListTasks`, Multiturn ueber `contextId`, text/plain-`raw`- und
- String-`data`-Teile, Webhook-Push, `a2a_get_task`/`a2a_cancel_task` als
- Client-Werkzeuge und die Agent Card mit Bearer-Token; die Karte meldet
- `streaming:true` und `pushNotifications:true`. `tests/test_a2a.sh` prueft Task, Message, Token, Fehler,
+ `GetTask`, `ListTasks`, Multiturn ueber `contextId`, text/plain-`raw`-,
+ URL- und String-`data`-Teile, Webhook-Push samt Push-Config-CRUD,
+ `a2a_get_task`/`a2a_cancel_task` als Client-Werkzeuge und die Agent Card mit
+ Bearer-Token; die Karte meldet `streaming:true` und
+ `pushNotifications:true`. `GetTask` liefert das Task-Objekt, nicht
+ `{"task":...}`. `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), `tests/test_a2a_context.sh` die
diff --git a/docs/PLUGINS.md b/docs/PLUGINS.md
index 50fff37..bfc56b1 100644
--- a/docs/PLUGINS.md
+++ b/docs/PLUGINS.md
@@ -344,11 +344,15 @@ configuration posts the completed task to that webhook (payload: one
`StreamResponse` with `task`). Loopback is allowed by default; any other host
needs `SPLINTER_A2A_PUSH_ALLOW` (comma separated, `*` for all), which keeps a
client from turning the server into an SSRF probe. The config token travels as
-`X-A2A-Notification-Token`, the authentication as `Authorization`. The
-standalone push-config CRUD methods are not served.
+`X-A2A-Notification-Token`, the authentication as `Authorization`. The four
+push-config methods (`CreateTaskPushNotificationConfig`, `Get...`, `List...`,
+`Delete...`) manage the same configs in memory.
+
+A text/plain `url` part is fetched from loopback or a host in
+`SPLINTER_A2A_URL_ALLOW` (same syntax, 1 MiB cap, no redirects); a binary or
+other media type is refused.
Refused with a JSON-RPC error, not half-answered: `CancelTask`,
-`SubscribeToTask`, URL/binary parts, push-config CRUD, plus continuation of an
-interrupted task. Beyond loopback
+`SubscribeToTask`, binary parts and continuation of an interrupted task. Beyond loopback
`SPLINTER_A2A_SERVER_TOKEN` is required and checked as
`Authorization: Bearer ...`; there is no TLS.
diff --git a/src/a2aserver.c b/src/a2aserver.c
index 5f294ef..481d9ea 100644
--- a/src/a2aserver.c
+++ b/src/a2aserver.c
@@ -264,12 +264,15 @@ json_id(const char *payload, char *out, size_t cap)
}
}
+static int url_host_allowed(const char *url);
+static int fetch_url_text(const char *url, struct sp_buf *out);
+
/*
- * A part can be text, a string in data, or a text/plain raw part (base64). A
- * url is not fetched (that would be an SSRF hole in an agent server), and a
- * structured object is not guessed at; both are refused with
- * ContentTypeNotSupported. Returns 0 when text was collected, 1 when the
- * content cannot be used, -1 on allocation failure.
+ * A part can be text, a string in data, a text/plain raw part (base64), or a
+ * text/plain url from an allowlisted host. A structured object is not guessed
+ * at; a URL to anywhere else is refused with ContentTypeNotSupported. Returns
+ * 0 when text was collected, 1 when the content cannot be used, -1 on
+ * allocation failure.
*/
static int
append_text(struct sp_buf *out, const char *s)
@@ -328,6 +331,34 @@ collect_text(const mcp_json *parts, struct sp_buf *out)
got = 1;
continue;
}
+ {
+ const char *url = mcp_arg_string(p, "url");
+
+ if (url != NULL && *url != '\0') {
+ struct sp_buf fetched;
+
+ mt = mcp_arg_string(p, "mediaType");
+ if (mt != NULL && *mt != '\0' &&
+ strncmp(mt, "text/", 5) != 0)
+ return 1;
+ if (!url_host_allowed(url))
+ return 1;
+ if (sp_buf_init(&fetched) != 0)
+ return -1;
+ if (fetch_url_text(url, &fetched) != 0 ||
+ fetched.len == 0) {
+ sp_buf_free(&fetched);
+ return 1;
+ }
+ if (append_text(out, fetched.p) != 0) {
+ sp_buf_free(&fetched);
+ return -1;
+ }
+ sp_buf_free(&fetched);
+ got = 1;
+ continue;
+ }
+ }
return 1;
}
return got ? 0 : 1;
@@ -456,10 +487,10 @@ task_json(struct sp_buf *b, const struct a2a_task *t)
* and the token/credentials may not smuggle a header line.
*/
static int
-push_host_allowed(const char *url)
+host_allowed(const char *url, const char *envname)
{
const char *p, *host, *end;
- const char *allow = getenv("SPLINTER_A2A_PUSH_ALLOW");
+ const char *allow = getenv(envname);
char h[256], copy[512], *tok, *save;
size_t n;
@@ -500,6 +531,76 @@ push_host_allowed(const char *url)
return 0;
}
+static int
+push_host_allowed(const char *url)
+{
+ return host_allowed(url, "SPLINTER_A2A_PUSH_ALLOW");
+}
+
+static int
+url_host_allowed(const char *url)
+{
+ return host_allowed(url, "SPLINTER_A2A_URL_ALLOW");
+}
+
+/* text/plain from an allowlisted URL, capped at 1 MiB; no redirects */
+static int
+fetch_url_text(const char *url, struct sp_buf *out)
+{
+ const char *args[8];
+ struct sp_buf raw, err;
+ pid_t pid = -1;
+ char chunk[4096], *nl;
+ size_t got;
+ int fd, status = 0;
+ long http;
+
+ args[0] = "-sS";
+ args[1] = "-m";
+ args[2] = "15";
+ args[3] = "-w";
+ args[4] = "\n%{http_code}";
+ args[5] = NULL;
+ if (sp_buf_init(&raw) != 0 || sp_buf_init(&err) != 0)
+ return -1;
+ fd = sp_curl_start(args, url, NULL, 1, &pid, &err);
+ if (fd < 0)
+ goto fail;
+ while ((got = read(fd, chunk, sizeof(chunk))) > 0) {
+ if (raw.len + got > (1u << 20)) {
+ close(fd);
+ (void)kill(pid, SIGKILL);
+ (void)waitpid(pid, NULL, 0);
+ goto fail;
+ }
+ if (sp_buf_add(&raw, chunk, got) != 0) {
+ close(fd);
+ (void)kill(pid, SIGKILL);
+ (void)waitpid(pid, NULL, 0);
+ goto fail;
+ }
+ }
+ close(fd);
+ if (waitpid(pid, &status, 0) < 0 || !WIFEXITED(status) ||
+ WEXITSTATUS(status) != 0)
+ goto fail;
+ if (raw.len < 2 || (nl = strrchr(raw.p, '\n')) == NULL)
+ goto fail;
+ http = strtol(nl + 1, NULL, 10);
+ *nl = '\0';
+ if (http < 200 || http > 299)
+ goto fail;
+ sp_buf_puts(out, raw.p);
+ sp_buf_free(&raw);
+ sp_buf_free(&err);
+ return 0;
+
+fail:
+ sp_buf_free(&raw);
+ sp_buf_free(&err);
+ return -1;
+}
+
static int
has_crlf(const char *s)
{
@@ -508,16 +609,12 @@ has_crlf(const char *s)
/* 0 no push requested, 1 configured, -1 invalid, -2 host not allowed */
static int
-push_parse(const mcp_json *params, struct a2a_push *p, struct sp_buf *err)
+push_from_config(const mcp_json *pn, struct a2a_push *p, struct sp_buf *err)
{
- const mcp_json *conf, *pn, *auth;
+ const mcp_json *auth;
const char *url, *token, *scheme, *cred;
memset(p, 0, sizeof(*p));
- conf = mcp_arg(params, "configuration");
- pn = conf != NULL ? mcp_arg(conf, "taskPushNotificationConfig") : NULL;
- if (pn == NULL)
- return 0;
url = mcp_arg_string(pn, "url");
if (url == NULL || *url == '\0') {
sp_buf_puts(err, "push config has no url");
@@ -551,6 +648,81 @@ push_parse(const mcp_json *params, struct a2a_push *p, struct sp_buf *err)
return 1;
}
+static int
+push_parse(const mcp_json *params, struct a2a_push *p, struct sp_buf *err)
+{
+ const mcp_json *conf, *pn;
+
+ memset(p, 0, sizeof(*p));
+ conf = mcp_arg(params, "configuration");
+ pn = conf != NULL ? mcp_arg(conf, "taskPushNotificationConfig") : NULL;
+ if (pn == NULL)
+ return 0;
+ return push_from_config(pn, p, err);
+}
+
+struct a2a_pcfg {
+ int used;
+ char id[64];
+ char task_id[64];
+ struct a2a_push p;
+};
+
+static struct a2a_pcfg g_pcfg[32];
+static unsigned g_pcfg_seq;
+
+static struct a2a_pcfg *
+pcfg_store(const char *task_id, const struct a2a_push *p)
+{
+ struct a2a_pcfg *c = &g_pcfg[g_pcfg_seq % 32];
+
+ g_pcfg_seq++;
+ memset(c, 0, sizeof(*c));
+ c->p = *p;
+ c->p.set = 1;
+ snprintf(c->id, sizeof(c->id), "cfg-%d-%u", (int)getpid(), g_pcfg_seq);
+ snprintf(c->task_id, sizeof(c->task_id), "%s", task_id);
+ c->used = 1;
+ return c;
+}
+
+static struct a2a_pcfg *
+pcfg_find(const char *task_id, const char *id)
+{
+ size_t i;
+
+ for (i = 0; i < 32; i++)
+ if (g_pcfg[i].used && strcmp(g_pcfg[i].task_id, task_id) == 0 &&
+ (id == NULL || strcmp(g_pcfg[i].id, id) == 0))
+ return &g_pcfg[i];
+ return NULL;
+}
+
+static void
+pcfg_json(struct sp_buf *b, const struct a2a_pcfg *c)
+{
+ sp_buf_puts(b, "{\"id\":\"");
+ sp_json_escape(b, c->id);
+ sp_buf_puts(b, "\",\"taskId\":\"");
+ sp_json_escape(b, c->task_id);
+ sp_buf_puts(b, "\",\"url\":\"");
+ sp_json_escape(b, c->p.url);
+ sp_buf_puts(b, "\"");
+ if (c->p.token[0] != '\0') {
+ sp_buf_puts(b, ",\"token\":\"");
+ sp_json_escape(b, c->p.token);
+ sp_buf_puts(b, "\"");
+ }
+ if (c->p.scheme[0] != '\0') {
+ sp_buf_puts(b, ",\"authentication\":{\"scheme\":\"");
+ sp_json_escape(b, c->p.scheme);
+ sp_buf_puts(b, "\",\"credentials\":\"");
+ sp_json_escape(b, c->p.cred);
+ sp_buf_puts(b, "\"}");
+ }
+ sp_buf_puts(b, "}");
+}
+
/* best effort after the response: a push must not make the client's turn fail */
static void
push_task(const struct a2a_push *p, const struct a2a_task *t)
@@ -1061,12 +1233,136 @@ send_out:
} else if (strcmp(method, "SubscribeToTask") == 0) {
rpc_error(fd, id, -32004, "subscription is not served; use "
"SendStreamingMessage");
- } else if (strcmp(method, "CreateTaskPushNotificationConfig") == 0 ||
- strcmp(method, "GetTaskPushNotificationConfig") == 0 ||
- strcmp(method, "ListTaskPushNotificationConfigs") == 0 ||
- strcmp(method, "DeleteTaskPushNotificationConfig") == 0) {
- rpc_error(fd, id, -32004, "push config CRUD is not served; "
- "send taskPushNotificationConfig in SendMessage");
+ } else if (strcmp(method, "CreateTaskPushNotificationConfig") == 0) {
+ const char *tid = mcp_arg_string(params, "taskId");
+ struct a2a_push p;
+ struct sp_buf perr, out;
+ struct a2a_pcfg *c;
+
+ if (tid == NULL || *tid == '\0') {
+ rpc_error(fd, id, -32602, "taskId is required");
+ mcp_json_free(v);
+ return;
+ }
+ if (task_find(tid) == NULL) {
+ rpc_error(fd, id, -32001, "task not found");
+ mcp_json_free(v);
+ return;
+ }
+ memset(&perr, 0, sizeof(perr));
+ if (sp_buf_init(&perr) != 0) {
+ rpc_error(fd, id, -32603, "out of memory");
+ mcp_json_free(v);
+ return;
+ }
+ rc = push_from_config(params, &p, &perr);
+ if (rc < 0) {
+ rpc_error(fd, id, rc == -2 ? -32003 : -32602, perr.p);
+ sp_buf_free(&perr);
+ mcp_json_free(v);
+ return;
+ }
+ c = pcfg_store(tid, &p);
+ if (c == NULL) {
+ rpc_error(fd, id, -32603, "out of memory");
+ sp_buf_free(&perr);
+ mcp_json_free(v);
+ return;
+ }
+ memset(&out, 0, sizeof(out));
+ if (sp_buf_init(&out) != 0) {
+ rpc_error(fd, id, -32603, "out of memory");
+ } else {
+ pcfg_json(&out, c);
+ rpc_result(fd, id, out.p != NULL ? out.p : "{}");
+ sp_buf_free(&out);
+ }
+ sp_buf_free(&perr);
+ } else if (strcmp(method, "GetTaskPushNotificationConfig") == 0) {
+ const char *tid = mcp_arg_string(params, "taskId");
+ const char *cid = mcp_arg_string(params,
+ "pushNotificationConfigId");
+ struct a2a_pcfg *c;
+ struct sp_buf out;
+
+ if (cid == NULL)
+ cid = mcp_arg_string(params, "configId");
+ if (cid == NULL)
+ cid = mcp_arg_string(params, "id");
+ if (tid == NULL || *tid == '\0' || cid == NULL || *cid == '\0') {
+ rpc_error(fd, id, -32602, "taskId and config id are "
+ "required");
+ mcp_json_free(v);
+ return;
+ }
+ c = pcfg_find(tid, cid);
+ if (c == NULL) {
+ rpc_error(fd, id, -32001, "push config not found");
+ mcp_json_free(v);
+ return;
+ }
+ memset(&out, 0, sizeof(out));
+ if (sp_buf_init(&out) != 0) {
+ rpc_error(fd, id, -32603, "out of memory");
+ } else {
+ pcfg_json(&out, c);
+ rpc_result(fd, id, out.p != NULL ? out.p : "{}");
+ sp_buf_free(&out);
+ }
+ } else if (strcmp(method, "ListTaskPushNotificationConfigs") == 0) {
+ const char *tid = mcp_arg_string(params, "taskId");
+ struct sp_buf out;
+ size_t i;
+ int n = 0;
+
+ if (tid == NULL || *tid == '\0') {
+ rpc_error(fd, id, -32602, "taskId is required");
+ mcp_json_free(v);
+ return;
+ }
+ 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, "{\"configs\":[");
+ for (i = 0; i < 32; i++) {
+ if (!g_pcfg[i].used ||
+ strcmp(g_pcfg[i].task_id, tid) != 0)
+ continue;
+ if (n++ > 0)
+ sp_buf_puts(&out, ",");
+ pcfg_json(&out, &g_pcfg[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, "DeleteTaskPushNotificationConfig") == 0) {
+ const char *tid = mcp_arg_string(params, "taskId");
+ const char *cid = mcp_arg_string(params,
+ "pushNotificationConfigId");
+ struct a2a_pcfg *c;
+
+ if (cid == NULL)
+ cid = mcp_arg_string(params, "configId");
+ if (cid == NULL)
+ cid = mcp_arg_string(params, "id");
+ if (tid == NULL || *tid == '\0' || cid == NULL || *cid == '\0') {
+ rpc_error(fd, id, -32602, "taskId and config id are "
+ "required");
+ mcp_json_free(v);
+ return;
+ }
+ c = pcfg_find(tid, cid);
+ if (c == NULL) {
+ rpc_error(fd, id, -32001, "push config not found");
+ mcp_json_free(v);
+ return;
+ }
+ c->used = 0;
+ rpc_result(fd, id, "{}");
} else {
rpc_error(fd, id, -32601, "method not found");
}
@@ -1227,6 +1523,8 @@ sp_a2a_serve(struct sp_agent *ag, const char *ip, int port, struct sp_buf *err)
sp_conv_free(&g_ctx[i].conv);
g_ctx[i].used = 0;
}
+ for (i = 0; i < 32; i++)
+ g_pcfg[i].used = 0;
}
fprintf(stderr, "splinter: A2A server stopped\n");
return 0;
diff --git a/src/www/index.en.html b/src/www/index.en.html
index ff98997..e041870 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.
-24993 lines of C99/POSIX ·
+
25291 lines of C99/POSIX ·
25 tools · 32 test programs ·
16 plugins · 42 palettes · BSD-3-Clause
@@ -212,7 +212,8 @@ splinter: A2A server on 127.0.0.1:8099 (token required)
/.well-known/agent-card.json. A contextId is a
conversation; without one the server makes one and returns it. A
taskPushNotificationConfig posts the completed task to a webhook
-(loopback or SPLINTER_A2A_PUSH_ALLOW). Beyond loopback the bearer
+(loopback or SPLINTER_A2A_PUSH_ALLOW); push configs can be managed
+with CRUD and text/plain URLs are fetched from allowed hosts. Beyond loopback the bearer
token is required.
Kid mode
diff --git a/src/www/index.html b/src/www/index.html
index c66ec06..2ab484a 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.
-24993 Zeilen C99/POSIX ·
+
25291 Zeilen C99/POSIX ·
25 Werkzeuge · 32 Test-Programme ·
16 Plugins · 42 Farbschemata · BSD-3-Clause
@@ -213,7 +213,9 @@ splinter: A2A server on 127.0.0.1:8099 (token required)
/.well-known/agent-card.json. Ein contextId ist eine
Konversation; ohne eines legt der Server eins an und gibt es zurueck. Eine
taskPushNotificationConfig schickt den fertigen Task an einen
-Webhook (Loopback oder SPLINTER_A2A_PUSH_ALLOW). Jenseits von
+Webhook (Loopback oder SPLINTER_A2A_PUSH_ALLOW); Push-Configs
+lassen sich per CRUD verwalten, text/plain-URLs werden von erlaubten Hosts
+geholt. Jenseits von
Loopback ist der Bearer-Token Pflicht.
Kindermodus
diff --git a/src/www/index.pt.html b/src/www/index.pt.html
index 500f4a5..b9fe239 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.
-24993 linhas C99/POSIX ·
+
25291 linhas C99/POSIX ·
25 ferramentas · 32 programas de teste ·
16 plugins · 42 paletas · BSD-3-Clause
@@ -161,7 +161,8 @@ splinter: A2A server on 127.0.0.1:8099 (token required)
/.well-known/agent-card.json. Um contextId e uma conversa;
sem ele o servidor cria um e devolve. Uma taskPushNotificationConfig
envia a tarefa concluida para um webhook (loopback ou
-SPLINTER_A2A_PUSH_ALLOW). Fora do loopback o token Bearer e obrigatorio.
+SPLINTER_A2A_PUSH_ALLOW); configs de push podem ser gerenciadas por
+CRUD e URLs text/plain sao buscadas de hosts permitidos. Fora do loopback o token Bearer e obrigatorio.
diff --git a/tests/fake_webhook.py b/tests/fake_webhook.py
index d8a15e9..7b99e63 100644
--- a/tests/fake_webhook.py
+++ b/tests/fake_webhook.py
@@ -7,6 +7,16 @@ class H(http.server.BaseHTTPRequestHandler):
def log_message(self, *a):
pass
+ def do_GET(self):
+ b = b"hallo aus datei\n"
+ self.send_response(200)
+ self.send_header("Content-Type", "text/plain")
+ self.send_header("Content-Length", str(len(b)))
+ self.end_headers()
+ self.wfile.write(b)
+ with open(sys.argv[2], "a") as f:
+ f.write("get %s\n" % self.path)
+
def do_POST(self):
n = int(self.headers.get("Content-Length", 0))
body = self.rfile.read(n).decode("utf-8", "replace")
diff --git a/tests/test_a2a_server.sh b/tests/test_a2a_server.sh
index a56c148..d19d0aa 100755
--- a/tests/test_a2a_server.sh
+++ b/tests/test_a2a_server.sh
@@ -21,7 +21,7 @@ cleanup() {
}
trap cleanup EXIT
mkdir -p "$D/home"
-printf 'answer hallo von splinter\nanswer hallo von splinter\nanswer hallo von splinter\nanswer hallo von splinter\nanswer hallo von splinter\nanswer hallo von splinter\n' > "$D/model.txt"
+printf 'answer hallo von splinter\nanswer hallo von splinter\nanswer hallo von splinter\nanswer 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; }
@@ -93,9 +93,23 @@ check test $? -eq 0
resp6=$(post "$P" "{\"jsonrpc\":\"2.0\",\"id\":\"6\",\"method\":\"CancelTask\",\"params\":{\"id\":\"$id\"}}")
echo "$resp6" | grep -q '"code":-32002'
check test $? -eq 0
-# the standalone push-config CRUD is not served: UnsupportedOperation (-32004)
-resp9=$(post "$P" '{"jsonrpc":"2.0","id":"9","method":"CreateTaskPushNotificationConfig","params":{}}')
-echo "$resp9" | grep -q '"code":-32004'
+# push-config CRUD: create, get, list, delete, then get again
+resp9=$(post "$P" "{\"jsonrpc\":\"2.0\",\"id\":\"9\",\"method\":\"CreateTaskPushNotificationConfig\",\"params\":{\"taskId\":\"$id\",\"url\":\"http://127.0.0.1:$P3/hook2\",\"token\":\"t2\",\"authentication\":{\"scheme\":\"Bearer\",\"credentials\":\"c2\"}}}")
+echo "$resp9" | grep -q '"id":"cfg-'
+check test $? -eq 0
+cid=$(printf '%s' "$resp9" | python3 -c 'import json,sys; print(json.load(sys.stdin)["result"]["id"])')
+check test -n "$cid"
+resp9=$(post "$P" "{\"jsonrpc\":\"2.0\",\"id\":\"9\",\"method\":\"GetTaskPushNotificationConfig\",\"params\":{\"taskId\":\"$id\",\"pushNotificationConfigId\":\"$cid\"}}")
+echo "$resp9" | grep -q 'hook2'
+check test $? -eq 0
+resp9=$(post "$P" "{\"jsonrpc\":\"2.0\",\"id\":\"9\",\"method\":\"ListTaskPushNotificationConfigs\",\"params\":{\"taskId\":\"$id\"}}")
+echo "$resp9" | grep -q '"totalSize":1'
+check test $? -eq 0
+resp9=$(post "$P" "{\"jsonrpc\":\"2.0\",\"id\":\"9\",\"method\":\"DeleteTaskPushNotificationConfig\",\"params\":{\"taskId\":\"$id\",\"pushNotificationConfigId\":\"$cid\"}}")
+echo "$resp9" | grep -q '"result":{}'
+check test $? -eq 0
+resp9=$(post "$P" "{\"jsonrpc\":\"2.0\",\"id\":\"9\",\"method\":\"GetTaskPushNotificationConfig\",\"params\":{\"taskId\":\"$id\",\"pushNotificationConfigId\":\"$cid\"}}")
+echo "$resp9" | grep -q '"code":-32001'
check test $? -eq 0
# ListTasks: the stored task, and an empty list for another context
@@ -119,6 +133,13 @@ resp11=$(post "$P" '{"jsonrpc":"2.0","id":"11","method":"SendMessage","params":{
echo "$resp11" | grep -q '"code":-32005'
check test $? -eq 0
+# a text/plain URL on loopback is fetched; the file server sees the GET
+resp14=$(post "$P" "{\"jsonrpc\":\"2.0\",\"id\":\"14\",\"method\":\"SendMessage\",\"params\":{\"message\":{\"messageId\":\"m\",\"role\":\"ROLE_USER\",\"parts\":[{\"url\":\"http://127.0.0.1:$P3/file.txt\",\"mediaType\":\"text/plain\"}]}}}")
+echo "$resp14" | grep -q 'TASK_STATE_COMPLETED'
+check test $? -eq 0
+grep -q 'get /file.txt' "$D/hook.log"
+check test $? -eq 0
+
# a push config posts the completed task to the loopback webhook
resp12=$(post "$P" "{\"jsonrpc\":\"2.0\",\"id\":\"12\",\"method\":\"SendMessage\",\"params\":{\"message\":{\"messageId\":\"m\",\"role\":\"ROLE_USER\",\"parts\":[{\"text\":\"push\"}]},\"configuration\":{\"taskPushNotificationConfig\":{\"url\":\"http://127.0.0.1:$P3/hook\",\"token\":\"t1\",\"authentication\":{\"scheme\":\"Bearer\",\"credentials\":\"secret\"}}}}}")
echo "$resp12" | grep -q 'TASK_STATE_COMPLETED'
diff --git a/tools/gen_www.py b/tools/gen_www.py
index f0ba59f..760d72d 100644
--- a/tools/gen_www.py
+++ b/tools/gen_www.py
@@ -459,7 +459,9 @@ splinter: A2A server on 127.0.0.1:8099 (token required)
/.well-known/agent-card.json. Ein contextId ist eine
Konversation; ohne eines legt der Server eins an und gibt es zurueck. Eine
taskPushNotificationConfig schickt den fertigen Task an einen
-Webhook (Loopback oder SPLINTER_A2A_PUSH_ALLOW). Jenseits von
+Webhook (Loopback oder SPLINTER_A2A_PUSH_ALLOW); Push-Configs
+lassen sich per CRUD verwalten, text/plain-URLs werden von erlaubten Hosts
+geholt. Jenseits von
Loopback ist der Bearer-Token Pflicht.""",
]
@@ -508,7 +510,8 @@ splinter: A2A server on 127.0.0.1:8099 (token required)
/.well-known/agent-card.json. A contextId is a
conversation; without one the server makes one and returns it. A
taskPushNotificationConfig posts the completed task to a webhook
-(loopback or SPLINTER_A2A_PUSH_ALLOW). Beyond loopback the bearer
+(loopback or SPLINTER_A2A_PUSH_ALLOW); push configs can be managed
+with CRUD and text/plain URLs are fetched from allowed hosts. Beyond loopback the bearer
token is required.""",
]
@@ -603,7 +606,8 @@ splinter: A2A server on 127.0.0.1:8099 (token required)
/.well-known/agent-card.json. Um contextId e uma conversa;
sem ele o servidor cria um e devolve. Uma taskPushNotificationConfig
envia a tarefa concluida para um webhook (loopback ou
-SPLINTER_A2A_PUSH_ALLOW). Fora do loopback o token Bearer e obrigatorio.""",
+SPLINTER_A2A_PUSH_ALLOW); configs de push podem ser gerenciadas por
+CRUD e URLs text/plain sao buscadas de hosts permitidos. Fora do loopback o token Bearer e obrigatorio.""",
]