bots-garden/mini-mepublic Fork
⑂ ba7f6a9
Commits
⬇ Clone ▾
git clone https://git.rickub.com/bots-garden/mini-me.git
git clone ssh://git@rickub.com/bots-garden/mini-me.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

Download ZIP

✨ /a2a-<name> (#263): talk to a remote A2A agent from the terminal, the window and the editor

- one command per agent of a2a.agents (internal/command/a2a.go); the
  message goes straight to the agent, the answer is shown under its name
  and joins the history like /ask-<name>'s
- tools.A2ASend: one sender, one conversation (contextId) per agent, shared
  by the ask_a2a_agent tool and the command
- handlers: line mode, window (outcome "a2a"), ACP
- docs EN+FR (slash commands, tools), demo README: how to use it in the TUI

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
agent committed 2026-11-25T06:40:08+01:00 Browse files
ba7f6a9 parent: 7ce08fd
added .tickets/issues/0263-a2a-a2a-name-command-talk-to-a-remote-a2a-agent-f.yaml +91 -0
new file mode 100644
@@ -0,0 +1,91 @@
1+# Managed by IssueSpec. Hand edits are welcome; keep the schema valid.
2+id: 263
3+title: "A2A: /a2a-<name> command — talk to a remote A2A agent from the window, the terminal and the editor"
4+state: closed
5+author:
6+ name: k33g
7+ email: ph.charriere@gmail.com
8+createdAt: 2026-11-25T05:32:07.000Z
9+updatedAt: 2026-11-25T05:39:55.000Z
10+labels:
11+ - enhancement
12+ - kind::feature
13+milestone: v2.0.1
14+epic: A2A
15+related:
16+ - 243
17+body: |
18+ Asked by the user (2026-11-25): "how do I use A2A from the TUI?". Until
19+ now only the model could talk to a remote A2A agent (the
20+ `ask_a2a_agent` tool); `mm a2a-send` works from a shell, its answer
21+ outside the conversation.
22+
23+ ## What it does
24+ `/a2a-<name> <message>` — one command per agent of `a2a.agents`, in the
25+ terminal, the window and the editor (like `/ask-<name>` for
26+ `mmConfigs`): the message goes straight to that agent, without the
27+ model; the answer is shown under the agent's name and joins the history
28+ as the same pair as /ask (`[asked <name> (A2A): …]` /
29+ `[<name>'s answer]`), so the next question can use it. The conversation
30+ with the agent is the one `ask_a2a_agent` uses (one `contextId` per
31+ agent, shared): `tools.A2ASend`.
32+
33+ ## Acceptance criteria
34+ - The command exists only when `a2a.agents` names agents; `/help` and
35+ the `/` picker list it.
36+ - Answer shown and kept in the history; cancel keeps nothing; a failure
37+ leaves the history unchanged.
38+ - Tests; docs EN+FR (slash commands, tools, the demo README).
39+tasks:
40+ - id: 1
41+ title: Command family (internal/command/a2a.go) and the shared sender tools.A2ASend
42+ state: closed
43+ priority: high
44+ author:
45+ name: k33g
46+ email: ph.charriere@gmail.com
47+ createdAt: 2026-11-25T05:32:07.000Z
48+ updatedAt: 2026-11-25T05:32:07.000Z
49+ closedAt: 2026-11-25T05:32:07.000Z
50+ - id: 2
51+ title: Line mode, window and editor (ACP) handlers
52+ state: closed
53+ priority: high
54+ author:
55+ name: k33g
56+ email: ph.charriere@gmail.com
57+ createdAt: 2026-11-25T05:32:07.000Z
58+ updatedAt: 2026-11-25T05:32:07.000Z
59+ closedAt: 2026-11-25T05:32:07.000Z
60+ - id: 3
61+ title: Tests, live check (line mode and the window via tmux), docs EN+FR
62+ state: closed
63+ priority: medium
64+ author:
65+ name: k33g
66+ email: ph.charriere@gmail.com
67+ createdAt: 2026-11-25T05:32:07.000Z
68+ updatedAt: 2026-11-25T05:32:07.000Z
69+ closedAt: 2026-11-25T05:32:07.000Z
70+comments:
71+ - id: 1
72+ author:
73+ name: k33g
74+ email: ph.charriere@gmail.com
75+ createdAt: 2026-11-25T05:32:07.000Z
76+ body: |
77+ Implemented on branch `feature/a2a-command` (not committed). Live in
78+ the sandbox with demos/a2a-discussion (LFM3 1.7B): line mode —
79+ `/help` lists `/a2a-alice` and `/a2a-bob`, alice answers, the answer
80+ is in the history; window (tmux) — the answer under "‣ alice", then a
81+ question to the moderator's model quotes what Alice said. The editor
82+ path (ACP) is covered by the build and mirrors /ask-<name>; not run
83+ live. Seen, not mm's: LFM3 1.7B leaked a `</think>` into an answer with
84+ enable_thinking false.
85+ - id: 2
86+ author:
87+ name: k33g
88+ email: ph.charriere@gmail.com
89+ createdAt: 2026-11-25T05:39:55.000Z
90+ body: |
91+ Validated by the user; merged into `main`.
new file mode 100644
@@ -0,0 +1,91 @@
1+# Managed by IssueSpec. Hand edits are welcome; keep the schema valid.
2+id: 263
3+title: "A2A: /a2a-<name> command — talk to a remote A2A agent from the window, the terminal and the editor"
4+state: closed
5+author:
6+ name: k33g
7+ email: ph.charriere@gmail.com
8+createdAt: 2026-11-25T05:32:07.000Z
9+updatedAt: 2026-11-25T05:39:55.000Z
10+labels:
11+ - enhancement
12+ - kind::feature
13+milestone: v2.0.1
14+epic: A2A
15+related:
16+ - 243
17+body: |
18+ Asked by the user (2026-11-25): "how do I use A2A from the TUI?". Until
19+ now only the model could talk to a remote A2A agent (the
20+ `ask_a2a_agent` tool); `mm a2a-send` works from a shell, its answer
21+ outside the conversation.
22+
23+ ## What it does
24+ `/a2a-<name> <message>` — one command per agent of `a2a.agents`, in the
25+ terminal, the window and the editor (like `/ask-<name>` for
26+ `mmConfigs`): the message goes straight to that agent, without the
27+ model; the answer is shown under the agent's name and joins the history
28+ as the same pair as /ask (`[asked <name> (A2A): …]` /
29+ `[<name>'s answer]`), so the next question can use it. The conversation
30+ with the agent is the one `ask_a2a_agent` uses (one `contextId` per
31+ agent, shared): `tools.A2ASend`.
32+
33+ ## Acceptance criteria
34+ - The command exists only when `a2a.agents` names agents; `/help` and
35+ the `/` picker list it.
36+ - Answer shown and kept in the history; cancel keeps nothing; a failure
37+ leaves the history unchanged.
38+ - Tests; docs EN+FR (slash commands, tools, the demo README).
39+tasks:
40+ - id: 1
41+ title: Command family (internal/command/a2a.go) and the shared sender tools.A2ASend
42+ state: closed
43+ priority: high
44+ author:
45+ name: k33g
46+ email: ph.charriere@gmail.com
47+ createdAt: 2026-11-25T05:32:07.000Z
48+ updatedAt: 2026-11-25T05:32:07.000Z
49+ closedAt: 2026-11-25T05:32:07.000Z
50+ - id: 2
51+ title: Line mode, window and editor (ACP) handlers
52+ state: closed
53+ priority: high
54+ author:
55+ name: k33g
56+ email: ph.charriere@gmail.com
57+ createdAt: 2026-11-25T05:32:07.000Z
58+ updatedAt: 2026-11-25T05:32:07.000Z
59+ closedAt: 2026-11-25T05:32:07.000Z
60+ - id: 3
61+ title: Tests, live check (line mode and the window via tmux), docs EN+FR
62+ state: closed
63+ priority: medium
64+ author:
65+ name: k33g
66+ email: ph.charriere@gmail.com
67+ createdAt: 2026-11-25T05:32:07.000Z
68+ updatedAt: 2026-11-25T05:32:07.000Z
69+ closedAt: 2026-11-25T05:32:07.000Z
70+comments:
71+ - id: 1
72+ author:
73+ name: k33g
74+ email: ph.charriere@gmail.com
75+ createdAt: 2026-11-25T05:32:07.000Z
76+ body: |
77+ Implemented on branch `feature/a2a-command` (not committed). Live in
78+ the sandbox with demos/a2a-discussion (LFM3 1.7B): line mode —
79+ `/help` lists `/a2a-alice` and `/a2a-bob`, alice answers, the answer
80+ is in the history; window (tmux) — the answer under "‣ alice", then a
81+ question to the moderator's model quotes what Alice said. The editor
82+ path (ACP) is covered by the build and mirrors /ask-<name>; not run
83+ live. Seen, not mm's: LFM3 1.7B leaked a `</think>` into an answer with
84+ enable_thinking false.
85+ - id: 2
86+ author:
87+ name: k33g
88+ email: ph.charriere@gmail.com
89+ createdAt: 2026-11-25T05:39:55.000Z
90+ body: |
91+ Validated by the user; merged into `main`.
modified demos/a2a-discussion/README.en.md +12 -1
@@ -49,7 +49,18 @@ Each call is one `mm a2a-send` (see below); each agent keeps its side of the con
4949 ../../mm moderator.yaml -p "Run a debate on: Should cities ban cars from their centre?"
5050 ```
5151
52-**3. Talk to one agent yourself.**
52+**3. Talk to one agent yourself.** In the window (or the line mode) of an agent that declares them under `a2a.agents` — the moderator does —, `/a2a-<name> <message>` sends your message straight to that agent, and its answer joins the conversation for your next question:
53+
54+```text
55+../../mm -tui moderator.yaml
56+> /a2a-alice In one sentence: should cities ban cars?
57+ ‣ alice
58+ Yes—cities can ban cars to cut emissions and congestion; …
59+ 🗣 alice's answer is in the history for your next question
60+> In one sentence, what did Alice just say?
61+```
62+
63+From a shell:
5364
5465 ```bash
5566 ../../mm a2a-send http://127.0.0.1:9101 "Why should we plant more trees in cities?"
@@ -49,7 +49,18 @@ Each call is one `mm a2a-send` (see below); each agent keeps its side of the con
49 ../../mm moderator.yaml -p "Run a debate on: Should cities ban cars from their centre?"49 ../../mm moderator.yaml -p "Run a debate on: Should cities ban cars from their centre?"
50 ```50 ```
51 51
52-**3. Talk to one agent yourself.**52+**3. Talk to one agent yourself.** In the window (or the line mode) of an agent that declares them under `a2a.agents` — the moderator does —, `/a2a-<name> <message>` sends your message straight to that agent, and its answer joins the conversation for your next question:
53+
54+```text
55+../../mm -tui moderator.yaml
56+> /a2a-alice In one sentence: should cities ban cars?
57+ ‣ alice
58+ Yes—cities can ban cars to cut emissions and congestion; …
59+ 🗣 alice's answer is in the history for your next question
60+> In one sentence, what did Alice just say?
61+```
62+
63+From a shell:
53 64
54 ```bash65 ```bash
55 ../../mm a2a-send http://127.0.0.1:9101 "Why should we plant more trees in cities?"66 ../../mm a2a-send http://127.0.0.1:9101 "Why should we plant more trees in cities?"
modified demos/a2a-discussion/README.fr.md +12 -1
@@ -49,7 +49,18 @@ Chaque appel est un `mm a2a-send` (voir plus bas) ; chaque agent garde sa part d
4949 ../../mm moderator.yaml -p "Run a debate on: Should cities ban cars from their centre?"
5050 ```
5151
52-**3. Parler vous-même à un agent.**
52+**3. Parler vous-même à un agent.** Dans la fenêtre (ou le mode ligne) d'un agent qui les déclare sous `a2a.agents` — c'est le cas du modérateur —, `/a2a-<nom> <message>` envoie votre message directement à cet agent, et sa réponse entre dans la conversation pour votre question suivante :
53+
54+```text
55+../../mm -tui moderator.yaml
56+> /a2a-alice In one sentence: should cities ban cars?
57+ ‣ alice
58+ Yes—cities can ban cars to cut emissions and congestion; …
59+ 🗣 alice's answer is in the history for your next question
60+> In one sentence, what did Alice just say?
61+```
62+
63+Depuis un shell :
5364
5465 ```bash
5566 ../../mm a2a-send http://127.0.0.1:9101 "Why should we plant more trees in cities?"
@@ -49,7 +49,18 @@ Chaque appel est un `mm a2a-send` (voir plus bas) ; chaque agent garde sa part d
49 ../../mm moderator.yaml -p "Run a debate on: Should cities ban cars from their centre?"49 ../../mm moderator.yaml -p "Run a debate on: Should cities ban cars from their centre?"
50 ```50 ```
51 51
52-**3. Parler vous-même à un agent.**52+**3. Parler vous-même à un agent.** Dans la fenêtre (ou le mode ligne) d'un agent qui les déclare sous `a2a.agents` — c'est le cas du modérateur —, `/a2a-<nom> <message>` envoie votre message directement à cet agent, et sa réponse entre dans la conversation pour votre question suivante :
53+
54+```text
55+../../mm -tui moderator.yaml
56+> /a2a-alice In one sentence: should cities ban cars?
57+ ‣ alice
58+ Yes—cities can ban cars to cut emissions and congestion; …
59+ 🗣 alice's answer is in the history for your next question
60+> In one sentence, what did Alice just say?
61+```
62+
63+Depuis un shell :
53 64
54 ```bash65 ```bash
55 ../../mm a2a-send http://127.0.0.1:9101 "Why should we plant more trees in cities?"66 ../../mm a2a-send http://127.0.0.1:9101 "Why should we plant more trees in cities?"
modified docs/en/reference/slash-commands.md +16 -0
@@ -64,6 +64,22 @@ The transcript sent by the context forms holds the user's questions, the assista
6464 | `<name> gave no answer` | The agent ended its turn without any text. |
6565 | `this agent was itself asked through 2 level(s) of /ask; it cannot ask further (max 2)` | `MM_ASK_DEPTH` is 2. |
6666
67+## Talking to an A2A agent
68+
69+Present only when `a2a.agents` declares at least one remote A2A agent (ticket 263); `/help` and the `/` picker list them. `<name>` is a key of `a2a.agents`.
70+
71+| Command | Front ends | Effect |
72+|---------|------------|--------|
73+| `/a2a-<name> <message>` | terminal, window, editor | Sends `<message>` to `<name>` over A2A, without going through the model. |
74+
75+| Item | Behaviour |
76+|------|-----------|
77+| Conversation | The same one as the [`ask_a2a_agent`](tools.md#ask_a2a_agent) tool's with that agent: one A2A `contextId` per agent, for the life of the process. |
78+| While it runs | `🤝 <name> (A2A)`, spinner `Waiting for <name>` (terminal). `Ctrl+C` (terminal), `Esc` / `Ctrl+C` (window), `session/cancel` (editor) stop the wait: nothing is kept. |
79+| Answered | Shown under `<name>` (window: `‣ <name>`; terminal: `🤝 <name>: …`), then `🗣 <name>'s answer is in the history for your next question`. Two messages appended, as for `/ask`: user `[asked <name> (A2A): <message>]`, assistant `[<name>'s answer]` + the answer, capped at `maxOutput`. |
80+| Failed | History unchanged; `⚠️ <name> did not answer: …` (terminal, editor), `[<name> did not answer: …]` (window). |
81+| No message | `nothing to say: type the message after the command`. |
82+
6783 ## `@path` in a question
6884
6985 | Input | Effect |
@@ -64,6 +64,22 @@ The transcript sent by the context forms holds the user's questions, the assista
64 | `<name> gave no answer` | The agent ended its turn without any text. |64 | `<name> gave no answer` | The agent ended its turn without any text. |
65 | `this agent was itself asked through 2 level(s) of /ask; it cannot ask further (max 2)` | `MM_ASK_DEPTH` is 2. |65 | `this agent was itself asked through 2 level(s) of /ask; it cannot ask further (max 2)` | `MM_ASK_DEPTH` is 2. |
66 66
67+## Talking to an A2A agent
68+
69+Present only when `a2a.agents` declares at least one remote A2A agent (ticket 263); `/help` and the `/` picker list them. `<name>` is a key of `a2a.agents`.
70+
71+| Command | Front ends | Effect |
72+|---------|------------|--------|
73+| `/a2a-<name> <message>` | terminal, window, editor | Sends `<message>` to `<name>` over A2A, without going through the model. |
74+
75+| Item | Behaviour |
76+|------|-----------|
77+| Conversation | The same one as the [`ask_a2a_agent`](tools.md#ask_a2a_agent) tool's with that agent: one A2A `contextId` per agent, for the life of the process. |
78+| While it runs | `🤝 <name> (A2A)`, spinner `Waiting for <name>` (terminal). `Ctrl+C` (terminal), `Esc` / `Ctrl+C` (window), `session/cancel` (editor) stop the wait: nothing is kept. |
79+| Answered | Shown under `<name>` (window: `‣ <name>`; terminal: `🤝 <name>: …`), then `🗣 <name>'s answer is in the history for your next question`. Two messages appended, as for `/ask`: user `[asked <name> (A2A): <message>]`, assistant `[<name>'s answer]` + the answer, capped at `maxOutput`. |
80+| Failed | History unchanged; `⚠️ <name> did not answer: …` (terminal, editor), `[<name> did not answer: …]` (window). |
81+| No message | `nothing to say: type the message after the command`. |
82+
67 ## `@path` in a question83 ## `@path` in a question
68 84
69 | Input | Effect |85 | Input | Effect |
modified docs/en/reference/tools.md +1 -1
@@ -273,7 +273,7 @@ Declared when `a2a.agents` names at least one agent. Sends a message to a remote
273273
274274 | Aspect | Behaviour |
275275 |--------|-----------|
276-| Conversation | Goes on from one call to the next: the A2A `contextId` is kept per agent, for the life of the process. |
276+| Conversation | Goes on from one call to the next: the A2A `contextId` is kept per agent, for the life of the process — shared with the [`/a2a-<name>`](slash-commands.md#talking-to-an-a2a-agent) command. |
277277 | Protocol | A2A 1.0 (`SendMessage`), then 0.3 (`message/send`) if the agent does not know it. Blocking: waits for the finished task, up to 10 minutes; the generation's watchdog does not count that wait. |
278278 | Result | The agent's answer; `[ask_a2a_agent: <agent> did not answer — <reason>]` on a failure, `[ask_a2a_agent: no agent "<name>" — use one of: …]` for an unknown name. |
279279 | Terminal display | `🤝 ask_a2a_agent: <agent>`, spinner `Waiting for <agent>`, then the answer echoed. |
@@ -273,7 +273,7 @@ Declared when `a2a.agents` names at least one agent. Sends a message to a remote
273 273
274 | Aspect | Behaviour |274 | Aspect | Behaviour |
275 |--------|-----------|275 |--------|-----------|
276-| Conversation | Goes on from one call to the next: the A2A `contextId` is kept per agent, for the life of the process. |276+| Conversation | Goes on from one call to the next: the A2A `contextId` is kept per agent, for the life of the process — shared with the [`/a2a-<name>`](slash-commands.md#talking-to-an-a2a-agent) command. |
277 | Protocol | A2A 1.0 (`SendMessage`), then 0.3 (`message/send`) if the agent does not know it. Blocking: waits for the finished task, up to 10 minutes; the generation's watchdog does not count that wait. |277 | Protocol | A2A 1.0 (`SendMessage`), then 0.3 (`message/send`) if the agent does not know it. Blocking: waits for the finished task, up to 10 minutes; the generation's watchdog does not count that wait. |
278 | Result | The agent's answer; `[ask_a2a_agent: <agent> did not answer — <reason>]` on a failure, `[ask_a2a_agent: no agent "<name>" — use one of: …]` for an unknown name. |278 | Result | The agent's answer; `[ask_a2a_agent: <agent> did not answer — <reason>]` on a failure, `[ask_a2a_agent: no agent "<name>" — use one of: …]` for an unknown name. |
279 | Terminal display | `🤝 ask_a2a_agent: <agent>`, spinner `Waiting for <agent>`, then the answer echoed. |279 | Terminal display | `🤝 ask_a2a_agent: <agent>`, spinner `Waiting for <agent>`, then the answer echoed. |
modified docs/fr/reference/slash-commands.md +16 -0
@@ -64,6 +64,22 @@ La transcription envoyée par les formes avec contexte contient les questions de
6464 | `<nom> gave no answer` | L'agent a terminé son tour sans aucun texte. |
6565 | `this agent was itself asked through 2 level(s) of /ask; it cannot ask further (max 2)` | `MM_ASK_DEPTH` vaut 2. |
6666
67+## Parler à un agent A2A
68+
69+Présentes seulement quand `a2a.agents` déclare au moins un agent A2A distant (ticket 263) ; `/help` et le sélecteur `/` les listent. `<nom>` est une clé de `a2a.agents`.
70+
71+| Commande | Interfaces | Effet |
72+|----------|------------|-------|
73+| `/a2a-<nom> <message>` | terminal, fenêtre, éditeur | Envoie `<message>` à `<nom>` par A2A, sans passer par le modèle. |
74+
75+| Élément | Comportement |
76+|---------|--------------|
77+| Conversation | La même que celle de l'outil [`ask_a2a_agent`](tools.md#ask_a2a_agent) avec cet agent : un `contextId` A2A par agent, pour la durée du processus. |
78+| Pendant l'appel | `🤝 <nom> (A2A)`, spinner `Waiting for <nom>` (terminal). `Ctrl+C` (terminal), `Échap` / `Ctrl+C` (fenêtre), `session/cancel` (éditeur) arrêtent l'attente : rien n'est gardé. |
79+| Réponse reçue | Affichée sous `<nom>` (fenêtre : `‣ <nom>` ; terminal : `🤝 <nom>: …`), puis `🗣 <nom>'s answer is in the history for your next question`. Deux messages ajoutés, comme pour `/ask` : utilisateur `[asked <nom> (A2A): <message>]`, assistant `[<nom>'s answer]` + la réponse, limitée à `maxOutput`. |
80+| Échec | Historique inchangé ; `⚠️ <nom> did not answer: …` (terminal, éditeur), `[<nom> did not answer: …]` (fenêtre). |
81+| Pas de message | `nothing to say: type the message after the command`. |
82+
6783 ## `@chemin` dans une question
6884
6985 | Saisie | Effet |
@@ -64,6 +64,22 @@ La transcription envoyée par les formes avec contexte contient les questions de
64 | `<nom> gave no answer` | L'agent a terminé son tour sans aucun texte. |64 | `<nom> gave no answer` | L'agent a terminé son tour sans aucun texte. |
65 | `this agent was itself asked through 2 level(s) of /ask; it cannot ask further (max 2)` | `MM_ASK_DEPTH` vaut 2. |65 | `this agent was itself asked through 2 level(s) of /ask; it cannot ask further (max 2)` | `MM_ASK_DEPTH` vaut 2. |
66 66
67+## Parler à un agent A2A
68+
69+Présentes seulement quand `a2a.agents` déclare au moins un agent A2A distant (ticket 263) ; `/help` et le sélecteur `/` les listent. `<nom>` est une clé de `a2a.agents`.
70+
71+| Commande | Interfaces | Effet |
72+|----------|------------|-------|
73+| `/a2a-<nom> <message>` | terminal, fenêtre, éditeur | Envoie `<message>` à `<nom>` par A2A, sans passer par le modèle. |
74+
75+| Élément | Comportement |
76+|---------|--------------|
77+| Conversation | La même que celle de l'outil [`ask_a2a_agent`](tools.md#ask_a2a_agent) avec cet agent : un `contextId` A2A par agent, pour la durée du processus. |
78+| Pendant l'appel | `🤝 <nom> (A2A)`, spinner `Waiting for <nom>` (terminal). `Ctrl+C` (terminal), `Échap` / `Ctrl+C` (fenêtre), `session/cancel` (éditeur) arrêtent l'attente : rien n'est gardé. |
79+| Réponse reçue | Affichée sous `<nom>` (fenêtre : `‣ <nom>` ; terminal : `🤝 <nom>: …`), puis `🗣 <nom>'s answer is in the history for your next question`. Deux messages ajoutés, comme pour `/ask` : utilisateur `[asked <nom> (A2A): <message>]`, assistant `[<nom>'s answer]` + la réponse, limitée à `maxOutput`. |
80+| Échec | Historique inchangé ; `⚠️ <nom> did not answer: …` (terminal, éditeur), `[<nom> did not answer: …]` (fenêtre). |
81+| Pas de message | `nothing to say: type the message after the command`. |
82+
67 ## `@chemin` dans une question83 ## `@chemin` dans une question
68 84
69 | Saisie | Effet |85 | Saisie | Effet |
modified docs/fr/reference/tools.md +1 -1
@@ -273,7 +273,7 @@ Déclaré quand `a2a.agents` nomme au moins un agent. Envoie un message à un ag
273273
274274 | Aspect | Comportement |
275275 |--------|--------------|
276-| Conversation | Se poursuit d'un appel à l'autre : le `contextId` A2A est gardé par agent, pour la durée du processus. |
276+| Conversation | Se poursuit d'un appel à l'autre : le `contextId` A2A est gardé par agent, pour la durée du processus — partagé avec la commande [`/a2a-<nom>`](slash-commands.md#parler-à-un-agent-a2a). |
277277 | Protocole | A2A 1.0 (`SendMessage`), puis 0.3 (`message/send`) si l'agent ne la connaît pas. Bloquant : attend la tâche terminée, jusqu'à 10 minutes ; le watchdog de la génération ne compte pas cette attente. |
278278 | Résultat | La réponse de l'agent ; `[ask_a2a_agent: <agent> did not answer — <raison>]` en cas d'échec, `[ask_a2a_agent: no agent "<nom>" — use one of: …]` pour un nom inconnu. |
279279 | Affichage terminal | `🤝 ask_a2a_agent: <agent>`, spinner `Waiting for <agent>`, puis la réponse affichée. |
@@ -273,7 +273,7 @@ Déclaré quand `a2a.agents` nomme au moins un agent. Envoie un message à un ag
273 273
274 | Aspect | Comportement |274 | Aspect | Comportement |
275 |--------|--------------|275 |--------|--------------|
276-| Conversation | Se poursuit d'un appel à l'autre : le `contextId` A2A est gardé par agent, pour la durée du processus. |276+| Conversation | Se poursuit d'un appel à l'autre : le `contextId` A2A est gardé par agent, pour la durée du processus — partagé avec la commande [`/a2a-<nom>`](slash-commands.md#parler-à-un-agent-a2a). |
277 | Protocole | A2A 1.0 (`SendMessage`), puis 0.3 (`message/send`) si l'agent ne la connaît pas. Bloquant : attend la tâche terminée, jusqu'à 10 minutes ; le watchdog de la génération ne compte pas cette attente. |277 | Protocole | A2A 1.0 (`SendMessage`), puis 0.3 (`message/send`) si l'agent ne la connaît pas. Bloquant : attend la tâche terminée, jusqu'à 10 minutes ; le watchdog de la génération ne compte pas cette attente. |
278 | Résultat | La réponse de l'agent ; `[ask_a2a_agent: <agent> did not answer — <raison>]` en cas d'échec, `[ask_a2a_agent: no agent "<nom>" — use one of: …]` pour un nom inconnu. |278 | Résultat | La réponse de l'agent ; `[ask_a2a_agent: <agent> did not answer — <raison>]` en cas d'échec, `[ask_a2a_agent: no agent "<nom>" — use one of: …]` pour un nom inconnu. |
279 | Affichage terminal | `🤝 ask_a2a_agent: <agent>`, spinner `Waiting for <agent>`, puis la réponse affichée. |279 | Affichage terminal | `🤝 ask_a2a_agent: <agent>`, spinner `Waiting for <agent>`, puis la réponse affichée. |
added internal/acp/a2a.go +40 -0
new file mode 100644
@@ -0,0 +1,40 @@
1+package acp
2+
3+import (
4+ "context"
5+ "fmt"
6+ "os"
7+
8+ "mm/internal/ask"
9+ "mm/internal/command"
10+ "mm/internal/config"
11+ "mm/internal/tools"
12+
13+ sdk "github.com/coder/acp-go-sdk"
14+)
15+
16+// a2aAgent is the editor's /a2a-<name> (ticket 263): the remote A2A agent
17+// answers in the agent's message, and the exchange joins the session's
18+// history, like /ask-<name>.
19+func (f *front) a2aAgent(ctx, turnCtx context.Context, sid sdk.SessionId, s *session, k *sink, req command.A2ARequest, parseErr error) (sdk.PromptResponse, error) {
20+ if parseErr != nil {
21+ k.Text("⚠️ " + parseErr.Error())
22+ return sdk.PromptResponse{StopReason: sdk.StopReasonEndTurn, Usage: s.usage.totals()}, nil
23+ }
24+ k.Text("🤝 " + req.Agent + " (A2A)\n\n")
25+ answer, err := tools.A2ASend(turnCtx, req.Agent, req.Message, false)
26+ switch {
27+ case turnCtx.Err() != nil:
28+ return sdk.PromptResponse{StopReason: sdk.StopReasonCancelled, Usage: s.usage.totals()}, nil
29+ case err != nil:
30+ fmt.Fprintf(os.Stderr, "[acp] session %s: /a2a-%s failed: %v\n", sid, req.Agent, err)
31+ k.Text(fmt.Sprintf("⚠️ %s did not answer: %v", req.Agent, err))
32+ return sdk.PromptResponse{StopReason: sdk.StopReasonEndTurn, Usage: s.usage.totals()}, nil
33+ }
34+ k.Text(answer)
35+ s.messages = append(s.messages, ask.Exchange(req.Agent, "A2A", false, req.Message, answer, config.Cfg.MaxOutput)...)
36+ f.persist(sid, s)
37+ fmt.Fprintf(os.Stderr, "[acp] session %s: /a2a-%s answered\n", sid, req.Agent)
38+ f.sendUsage(context.WithoutCancel(ctx), sid, contextUsed(s))
39+ return sdk.PromptResponse{StopReason: sdk.StopReasonEndTurn, Usage: s.usage.totals()}, nil
40+}
new file mode 100644
@@ -0,0 +1,40 @@
1+package acp
2+
3+import (
4+ "context"
5+ "fmt"
6+ "os"
7+
8+ "mm/internal/ask"
9+ "mm/internal/command"
10+ "mm/internal/config"
11+ "mm/internal/tools"
12+
13+ sdk "github.com/coder/acp-go-sdk"
14+)
15+
16+// a2aAgent is the editor's /a2a-<name> (ticket 263): the remote A2A agent
17+// answers in the agent's message, and the exchange joins the session's
18+// history, like /ask-<name>.
19+func (f *front) a2aAgent(ctx, turnCtx context.Context, sid sdk.SessionId, s *session, k *sink, req command.A2ARequest, parseErr error) (sdk.PromptResponse, error) {
20+ if parseErr != nil {
21+ k.Text("⚠️ " + parseErr.Error())
22+ return sdk.PromptResponse{StopReason: sdk.StopReasonEndTurn, Usage: s.usage.totals()}, nil
23+ }
24+ k.Text("🤝 " + req.Agent + " (A2A)\n\n")
25+ answer, err := tools.A2ASend(turnCtx, req.Agent, req.Message, false)
26+ switch {
27+ case turnCtx.Err() != nil:
28+ return sdk.PromptResponse{StopReason: sdk.StopReasonCancelled, Usage: s.usage.totals()}, nil
29+ case err != nil:
30+ fmt.Fprintf(os.Stderr, "[acp] session %s: /a2a-%s failed: %v\n", sid, req.Agent, err)
31+ k.Text(fmt.Sprintf("⚠️ %s did not answer: %v", req.Agent, err))
32+ return sdk.PromptResponse{StopReason: sdk.StopReasonEndTurn, Usage: s.usage.totals()}, nil
33+ }
34+ k.Text(answer)
35+ s.messages = append(s.messages, ask.Exchange(req.Agent, "A2A", false, req.Message, answer, config.Cfg.MaxOutput)...)
36+ f.persist(sid, s)
37+ fmt.Fprintf(os.Stderr, "[acp] session %s: /a2a-%s answered\n", sid, req.Agent)
38+ f.sendUsage(context.WithoutCancel(ctx), sid, contextUsed(s))
39+ return sdk.PromptResponse{StopReason: sdk.StopReasonEndTurn, Usage: s.usage.totals()}, nil
40+}
modified internal/acp/acp.go +4 -0
@@ -388,6 +388,10 @@ func (f *front) Prompt(ctx context.Context, p sdk.PromptRequest) (sdk.PromptResp
388388 if req, isAsk, err := command.ParseAsk(input); isAsk {
389389 return f.askAgent(ctx, turnCtx, p.SessionId, s, k, req, err)
390390 }
391+ // /a2a-alice: a remote A2A agent answers (a2a.go, ticket 263).
392+ if req, isA2A, err := command.ParseA2A(input); isA2A {
393+ return f.a2aAgent(ctx, turnCtx, p.SessionId, s, k, req, err)
394+ }
391395
392396 // A typed "@path" — the editor's picker bypassed, or an editor without
393397 // one — is understood like the resource_link the picker would have sent,
@@ -388,6 +388,10 @@ func (f *front) Prompt(ctx context.Context, p sdk.PromptRequest) (sdk.PromptResp
388 if req, isAsk, err := command.ParseAsk(input); isAsk {388 if req, isAsk, err := command.ParseAsk(input); isAsk {
389 return f.askAgent(ctx, turnCtx, p.SessionId, s, k, req, err)389 return f.askAgent(ctx, turnCtx, p.SessionId, s, k, req, err)
390 }390 }
391+ // /a2a-alice: a remote A2A agent answers (a2a.go, ticket 263).
392+ if req, isA2A, err := command.ParseA2A(input); isA2A {
393+ return f.a2aAgent(ctx, turnCtx, p.SessionId, s, k, req, err)
394+ }
391 395
392 // A typed "@path" — the editor's picker bypassed, or an editor without396 // A typed "@path" — the editor's picker bypassed, or an editor without
393 // one — is understood like the resource_link the picker would have sent,397 // one — is understood like the resource_link the picker would have sent,
added internal/agent/a2a.go +54 -0
new file mode 100644
@@ -0,0 +1,54 @@
1+package agent
2+
3+import (
4+ "context"
5+ "fmt"
6+ "os"
7+
8+ "mm/internal/ask"
9+ "mm/internal/command"
10+ "mm/internal/config"
11+ "mm/internal/spinner"
12+ "mm/internal/tools"
13+
14+ "github.com/firebase/genkit/go/ai"
15+)
16+
17+// a2aLine is the line mode's /a2a-<name> (ticket 263): the remote A2A agent
18+// answers, its answer is printed and joins the history for the next
19+// question — the same pair as /ask-<name> — without going through the
20+// model. Ctrl-C stops the wait; nothing is kept then.
21+func a2aLine(ctx context.Context, req command.A2ARequest, messages []*ai.Message, sigCh <-chan os.Signal) []*ai.Message {
22+ dimln("🤝 " + req.Agent + " (A2A)")
23+ actx, cancel := context.WithCancel(ctx)
24+ defer cancel()
25+ type result struct {
26+ answer string
27+ err error
28+ }
29+ done := make(chan result, 1)
30+ spinner.Start("Waiting for " + req.Agent)
31+ go func() {
32+ answer, err := tools.A2ASend(actx, req.Agent, req.Message, false)
33+ done <- result{answer, err}
34+ }()
35+ var res result
36+ select {
37+ case res = <-done:
38+ case <-sigCh:
39+ cancel()
40+ res = <-done
41+ }
42+ spinner.Stop()
43+ switch {
44+ case res.err != nil && actx.Err() != nil:
45+ fmt.Println("\n🔴 Interrupted — nothing kept.")
46+ return messages
47+ case res.err != nil:
48+ fmt.Printf("⚠️ %s did not answer: %v\n", req.Agent, res.err)
49+ return messages
50+ }
51+ fmt.Printf("\n🤝 %s: %s\n", req.Agent, res.answer)
52+ dimln("🗣 " + req.Agent + "'s answer is in the history for your next question")
53+ return append(messages, ask.Exchange(req.Agent, "A2A", false, req.Message, res.answer, config.Cfg.MaxOutput)...)
54+}
new file mode 100644
@@ -0,0 +1,54 @@
1+package agent
2+
3+import (
4+ "context"
5+ "fmt"
6+ "os"
7+
8+ "mm/internal/ask"
9+ "mm/internal/command"
10+ "mm/internal/config"
11+ "mm/internal/spinner"
12+ "mm/internal/tools"
13+
14+ "github.com/firebase/genkit/go/ai"
15+)
16+
17+// a2aLine is the line mode's /a2a-<name> (ticket 263): the remote A2A agent
18+// answers, its answer is printed and joins the history for the next
19+// question — the same pair as /ask-<name> — without going through the
20+// model. Ctrl-C stops the wait; nothing is kept then.
21+func a2aLine(ctx context.Context, req command.A2ARequest, messages []*ai.Message, sigCh <-chan os.Signal) []*ai.Message {
22+ dimln("🤝 " + req.Agent + " (A2A)")
23+ actx, cancel := context.WithCancel(ctx)
24+ defer cancel()
25+ type result struct {
26+ answer string
27+ err error
28+ }
29+ done := make(chan result, 1)
30+ spinner.Start("Waiting for " + req.Agent)
31+ go func() {
32+ answer, err := tools.A2ASend(actx, req.Agent, req.Message, false)
33+ done <- result{answer, err}
34+ }()
35+ var res result
36+ select {
37+ case res = <-done:
38+ case <-sigCh:
39+ cancel()
40+ res = <-done
41+ }
42+ spinner.Stop()
43+ switch {
44+ case res.err != nil && actx.Err() != nil:
45+ fmt.Println("\n🔴 Interrupted — nothing kept.")
46+ return messages
47+ case res.err != nil:
48+ fmt.Printf("⚠️ %s did not answer: %v\n", req.Agent, res.err)
49+ return messages
50+ }
51+ fmt.Printf("\n🤝 %s: %s\n", req.Agent, res.answer)
52+ dimln("🗣 " + req.Agent + "'s answer is in the history for your next question")
53+ return append(messages, ask.Exchange(req.Agent, "A2A", false, req.Message, res.answer, config.Cfg.MaxOutput)...)
54+}
modified internal/agent/agent.go +11 -0
@@ -157,6 +157,17 @@ func Run(ctx context.Context, e *engine.Engine, system string, tools []ai.ToolRe
157157 }
158158 continue
159159 }
160+ // /a2a-alice: a remote A2A agent answers (ticket 263), its answer
161+ // joins the history like /ask's.
162+ if req, ok, err := command.ParseA2A(input); ok {
163+ if err != nil {
164+ fmt.Println("⚠️ " + err.Error())
165+ continue
166+ }
167+ messages = a2aLine(ctx, req, messages, sigCh)
168+ save(keep, messages)
169+ continue
170+ }
160171 if next, handled := (&loop{ctx: ctx, e: e, d: d, keep: keep, system: system}).historyCommand(input, messages); handled {
161172 messages = next
162173 continue
@@ -157,6 +157,17 @@ func Run(ctx context.Context, e *engine.Engine, system string, tools []ai.ToolRe
157 }157 }
158 continue158 continue
159 }159 }
160+ // /a2a-alice: a remote A2A agent answers (ticket 263), its answer
161+ // joins the history like /ask's.
162+ if req, ok, err := command.ParseA2A(input); ok {
163+ if err != nil {
164+ fmt.Println("⚠️ " + err.Error())
165+ continue
166+ }
167+ messages = a2aLine(ctx, req, messages, sigCh)
168+ save(keep, messages)
169+ continue
170+ }
160 if next, handled := (&loop{ctx: ctx, e: e, d: d, keep: keep, system: system}).historyCommand(input, messages); handled {171 if next, handled := (&loop{ctx: ctx, e: e, d: d, keep: keep, system: system}).historyCommand(input, messages); handled {
161 messages = next172 messages = next
162 continue173 continue
added internal/command/a2a.go +67 -0
new file mode 100644
@@ -0,0 +1,67 @@
1+package command
2+
3+import (
4+ "errors"
5+ "strings"
6+)
7+
8+// The /a2a-<name> family (ticket 263): talk yourself to a remote A2A agent of
9+// a2a.agents — its answer joins the history for the next question, as with
10+// /ask-<name>, without going through the model. Generated by SetA2AAgents,
11+// one command per agent, in every front end (the editor's `/` menu included):
12+//
13+// /a2a-alice What do you think of remote work?
14+const A2APrefix = "a2a-"
15+
16+// a2aCommands is the generated part of the table; empty when a2a.agents names
17+// no agent.
18+var a2aCommands []Command
19+
20+// SetA2AAgents generates /a2a-<name> for the given agents (sorted by the
21+// caller — config.A2AAgentNames). Called once by main; nil removes them.
22+//
23+// command.SetA2AAgents([]string{"alice", "bob"})
24+func SetA2AAgents(names []string) {
25+ a2aCommands = nil
26+ for _, name := range names {
27+ a2aCommands = append(a2aCommands, Command{
28+ Name: A2APrefix + name,
29+ Description: "Talk to " + name + " (a remote A2A agent); its answer stays in the history",
30+ Fronts: Terminal | Editor | Window,
31+ TakesArg: true,
32+ Hint: "<message>",
33+ })
34+ }
35+}
36+
37+// A2ARequest is one /a2a-<name>, parsed.
38+type A2ARequest struct {
39+ Agent string // a name of a2a.agents
40+ Message string // what to say, trimmed, never empty
41+}
42+
43+// ParseA2A recognises the /a2a-<name> family. ok says the input IS one of
44+// those commands; err then says what is wrong with it (no message).
45+//
46+// req, ok, err := command.ParseA2A("/a2a-alice hello")
47+// // req == A2ARequest{Agent: "alice", Message: "hello"}, ok, err == nil
48+func ParseA2A(input string) (req A2ARequest, ok bool, err error) {
49+ cmd, arg, found := Parse(input)
50+ if !found || !strings.HasPrefix(cmd.Name, A2APrefix) || !isA2ACommand(cmd.Name) {
51+ return A2ARequest{}, false, nil
52+ }
53+ req = A2ARequest{Agent: strings.TrimPrefix(cmd.Name, A2APrefix), Message: strings.TrimSpace(arg)}
54+ if req.Message == "" {
55+ return req, true, errors.New("nothing to say: type the message after the command")
56+ }
57+ return req, true, nil
58+}
59+
60+func isA2ACommand(name string) bool {
61+ for _, c := range a2aCommands {
62+ if c.Name == name {
63+ return true
64+ }
65+ }
66+ return false
67+}
new file mode 100644
@@ -0,0 +1,67 @@
1+package command
2+
3+import (
4+ "errors"
5+ "strings"
6+)
7+
8+// The /a2a-<name> family (ticket 263): talk yourself to a remote A2A agent of
9+// a2a.agents — its answer joins the history for the next question, as with
10+// /ask-<name>, without going through the model. Generated by SetA2AAgents,
11+// one command per agent, in every front end (the editor's `/` menu included):
12+//
13+// /a2a-alice What do you think of remote work?
14+const A2APrefix = "a2a-"
15+
16+// a2aCommands is the generated part of the table; empty when a2a.agents names
17+// no agent.
18+var a2aCommands []Command
19+
20+// SetA2AAgents generates /a2a-<name> for the given agents (sorted by the
21+// caller — config.A2AAgentNames). Called once by main; nil removes them.
22+//
23+// command.SetA2AAgents([]string{"alice", "bob"})
24+func SetA2AAgents(names []string) {
25+ a2aCommands = nil
26+ for _, name := range names {
27+ a2aCommands = append(a2aCommands, Command{
28+ Name: A2APrefix + name,
29+ Description: "Talk to " + name + " (a remote A2A agent); its answer stays in the history",
30+ Fronts: Terminal | Editor | Window,
31+ TakesArg: true,
32+ Hint: "<message>",
33+ })
34+ }
35+}
36+
37+// A2ARequest is one /a2a-<name>, parsed.
38+type A2ARequest struct {
39+ Agent string // a name of a2a.agents
40+ Message string // what to say, trimmed, never empty
41+}
42+
43+// ParseA2A recognises the /a2a-<name> family. ok says the input IS one of
44+// those commands; err then says what is wrong with it (no message).
45+//
46+// req, ok, err := command.ParseA2A("/a2a-alice hello")
47+// // req == A2ARequest{Agent: "alice", Message: "hello"}, ok, err == nil
48+func ParseA2A(input string) (req A2ARequest, ok bool, err error) {
49+ cmd, arg, found := Parse(input)
50+ if !found || !strings.HasPrefix(cmd.Name, A2APrefix) || !isA2ACommand(cmd.Name) {
51+ return A2ARequest{}, false, nil
52+ }
53+ req = A2ARequest{Agent: strings.TrimPrefix(cmd.Name, A2APrefix), Message: strings.TrimSpace(arg)}
54+ if req.Message == "" {
55+ return req, true, errors.New("nothing to say: type the message after the command")
56+ }
57+ return req, true, nil
58+}
59+
60+func isA2ACommand(name string) bool {
61+ for _, c := range a2aCommands {
62+ if c.Name == name {
63+ return true
64+ }
65+ }
66+ return false
67+}
added internal/command/a2a_test.go +39 -0
new file mode 100644
@@ -0,0 +1,39 @@
1+package command
2+
3+import (
4+ "strings"
5+ "testing"
6+)
7+
8+// Ticket 263: one /a2a-<name> per agent, in every front end; an unknown name
9+// is not one of them (it is an unknown command), an empty message is.
10+func TestA2ACommands(t *testing.T) {
11+ SetA2AAgents([]string{"alice", "bob"})
12+ t.Cleanup(func() { SetA2AAgents(nil) })
13+
14+ req, ok, err := ParseA2A("/a2a-alice What do you think? ")
15+ if !ok || err != nil || req.Agent != "alice" || req.Message != "What do you think?" {
16+ t.Errorf("alice: %+v %v %v", req, ok, err)
17+ }
18+ if _, ok, err := ParseA2A("/a2a-bob"); !ok || err == nil || !strings.Contains(err.Error(), "nothing to say") {
19+ t.Errorf("empty message: ok %v, err %v", ok, err)
20+ }
21+ for _, in := range []string{"/a2a-zed hi", "/ask-alice hi", "hello", "/a2a hi"} {
22+ if _, ok, _ := ParseA2A(in); ok {
23+ t.Errorf("%q recognised as /a2a-<name>", in)
24+ }
25+ }
26+ for _, f := range []Front{Terminal, Editor, Window} {
27+ names := ""
28+ for _, c := range For(f) {
29+ names += c.Name + " "
30+ }
31+ if !strings.Contains(names, "a2a-alice ") || !strings.Contains(names, "a2a-bob ") {
32+ t.Errorf("front %v lacks the a2a commands: %s", f, names)
33+ }
34+ }
35+ SetA2AAgents(nil)
36+ if _, ok, _ := ParseA2A("/a2a-alice hi"); ok {
37+ t.Error("no agents: /a2a-alice still recognised")
38+ }
39+}
new file mode 100644
@@ -0,0 +1,39 @@
1+package command
2+
3+import (
4+ "strings"
5+ "testing"
6+)
7+
8+// Ticket 263: one /a2a-<name> per agent, in every front end; an unknown name
9+// is not one of them (it is an unknown command), an empty message is.
10+func TestA2ACommands(t *testing.T) {
11+ SetA2AAgents([]string{"alice", "bob"})
12+ t.Cleanup(func() { SetA2AAgents(nil) })
13+
14+ req, ok, err := ParseA2A("/a2a-alice What do you think? ")
15+ if !ok || err != nil || req.Agent != "alice" || req.Message != "What do you think?" {
16+ t.Errorf("alice: %+v %v %v", req, ok, err)
17+ }
18+ if _, ok, err := ParseA2A("/a2a-bob"); !ok || err == nil || !strings.Contains(err.Error(), "nothing to say") {
19+ t.Errorf("empty message: ok %v, err %v", ok, err)
20+ }
21+ for _, in := range []string{"/a2a-zed hi", "/ask-alice hi", "hello", "/a2a hi"} {
22+ if _, ok, _ := ParseA2A(in); ok {
23+ t.Errorf("%q recognised as /a2a-<name>", in)
24+ }
25+ }
26+ for _, f := range []Front{Terminal, Editor, Window} {
27+ names := ""
28+ for _, c := range For(f) {
29+ names += c.Name + " "
30+ }
31+ if !strings.Contains(names, "a2a-alice ") || !strings.Contains(names, "a2a-bob ") {
32+ t.Errorf("front %v lacks the a2a commands: %s", f, names)
33+ }
34+ }
35+ SetA2AAgents(nil)
36+ if _, ok, _ := ParseA2A("/a2a-alice hi"); ok {
37+ t.Error("no agents: /a2a-alice still recognised")
38+ }
39+}
modified internal/command/command.go +1 -1
@@ -87,7 +87,7 @@ var table = []Command{
8787 // when the configuration allows it (unload.go), then the /ask family generated
8888 // from the configured agents (ask.go).
8989 func All() []Command {
90- return append(append(append(append(append([]Command(nil), table...), memoryCommands...), docsCommands...), unloadCommands...), askCommands...)
90+ return append(append(append(append(append(append([]Command(nil), table...), memoryCommands...), docsCommands...), unloadCommands...), askCommands...), a2aCommands...)
9191 }
9292
9393 // For returns the commands front f offers, in display order.
@@ -87,7 +87,7 @@ var table = []Command{
87 // when the configuration allows it (unload.go), then the /ask family generated87 // when the configuration allows it (unload.go), then the /ask family generated
88 // from the configured agents (ask.go).88 // from the configured agents (ask.go).
89 func All() []Command {89 func All() []Command {
90- return append(append(append(append(append([]Command(nil), table...), memoryCommands...), docsCommands...), unloadCommands...), askCommands...)90+ return append(append(append(append(append(append([]Command(nil), table...), memoryCommands...), docsCommands...), unloadCommands...), askCommands...), a2aCommands...)
91 }91 }
92 92
93 // For returns the commands front f offers, in display order.93 // For returns the commands front f offers, in display order.
modified internal/tools/a2a.go +37 -21
@@ -39,6 +39,40 @@ var (
3939 a2aContexts = map[string]string{} // agent name → contextId
4040 )
4141
42+// A2ASend sends message to the agent name of a2a.agents and returns its
43+// answer, trimmed. The conversation with that agent goes on from one call to
44+// the next — the tool's and the /a2a-<name> command's alike: they share it,
45+// for this process. newConversation starts a new one. Bounded by
46+// a2aTimeout.
47+//
48+// answer, err := tools.A2ASend(ctx, "alice", "Your opening argument?", false)
49+func A2ASend(ctx context.Context, name, message string, newConversation bool) (string, error) {
50+ agent, ok := config.Cfg.A2A.Agents[name]
51+ if !ok {
52+ return "", fmt.Errorf("no agent %q — use one of: %s", name, strings.Join(config.A2AAgentNames(), ", "))
53+ }
54+ a2aMu.Lock()
55+ if newConversation {
56+ delete(a2aContexts, name)
57+ }
58+ contextID := a2aContexts[name]
59+ a2aMu.Unlock()
60+
61+ token := ""
62+ if agent.TokenEnv != "" {
63+ token = os.Getenv(agent.TokenEnv)
64+ }
65+ ctx, cancel := context.WithTimeout(ctx, a2aTimeout)
66+ defer cancel()
67+ answer, ctxID, err := a2a.Client{}.Send(ctx, agent.URL, token, contextID, message)
68+ if ctxID != "" {
69+ a2aMu.Lock()
70+ a2aContexts[name] = ctxID
71+ a2aMu.Unlock()
72+ }
73+ return strings.TrimSpace(answer), err
74+}
75+
4276 // AskA2AAgent declares the tool over the agents of a2a.agents.
4377 func AskA2AAgent(g *genkit.Genkit, d *detector.LoopDetector) ai.ToolRef {
4478 return genkit.DefineTool(g, "ask_a2a_agent", askA2ADescription(),
@@ -62,7 +96,7 @@ Agents:`)
6296 }
6397
6498 func askA2A(ctx context.Context, d *detector.LoopDetector, in askA2AInput) (string, error) {
65- agent, ok := config.Cfg.A2A.Agents[in.Agent]
99+ _, ok := config.Cfg.A2A.Agents[in.Agent]
66100 key := in.Agent + ": " + in.Message
67101 title := "ask_a2a_agent: " + in.Agent
68102 if !ok {
@@ -73,34 +107,16 @@ func askA2A(ctx context.Context, d *detector.LoopDetector, in askA2AInput) (stri
73107 return recordFailure(d, "ask_a2a_agent", key, "[ask_a2a_agent: empty message — say something to the agent]")
74108 }
75109
76- a2aMu.Lock()
77- if in.NewConversation {
78- delete(a2aContexts, in.Agent)
79- }
80- contextID := a2aContexts[in.Agent]
81- a2aMu.Unlock()
82-
83110 // The remote agent's model can think for minutes, and nothing streams
84111 // back meanwhile: the call beats the generation's watchdog every second
85112 // (like ask_user waiting for a person), bounded by a2aTimeout instead.
86113 beat := engine.Heartbeat(ctx)
87114 call := func() (string, bool) {
88- token := ""
89- if agent.TokenEnv != "" {
90- token = os.Getenv(agent.TokenEnv)
91- }
92- cctx, cancel := context.WithTimeout(ctx, a2aTimeout)
93- defer cancel()
94- answer, ctxID, err := a2a.Client{}.Send(cctx, agent.URL, token, contextID, in.Message)
95- if ctxID != "" {
96- a2aMu.Lock()
97- a2aContexts[in.Agent] = ctxID
98- a2aMu.Unlock()
99- }
115+ answer, err := A2ASend(ctx, in.Agent, in.Message, in.NewConversation)
100116 if err != nil {
101117 return fmt.Sprintf("[ask_a2a_agent: %s did not answer — %v]", in.Agent, err), true
102118 }
103- return strings.TrimSpace(answer), false
119+ return answer, false
104120 }
105121 run := func() (string, bool) {
106122 type result struct {
@@ -39,6 +39,40 @@ var (
39 a2aContexts = map[string]string{} // agent name → contextId39 a2aContexts = map[string]string{} // agent name → contextId
40 )40 )
41 41
42+// A2ASend sends message to the agent name of a2a.agents and returns its
43+// answer, trimmed. The conversation with that agent goes on from one call to
44+// the next — the tool's and the /a2a-<name> command's alike: they share it,
45+// for this process. newConversation starts a new one. Bounded by
46+// a2aTimeout.
47+//
48+// answer, err := tools.A2ASend(ctx, "alice", "Your opening argument?", false)
49+func A2ASend(ctx context.Context, name, message string, newConversation bool) (string, error) {
50+ agent, ok := config.Cfg.A2A.Agents[name]
51+ if !ok {
52+ return "", fmt.Errorf("no agent %q — use one of: %s", name, strings.Join(config.A2AAgentNames(), ", "))
53+ }
54+ a2aMu.Lock()
55+ if newConversation {
56+ delete(a2aContexts, name)
57+ }
58+ contextID := a2aContexts[name]
59+ a2aMu.Unlock()
60+
61+ token := ""
62+ if agent.TokenEnv != "" {
63+ token = os.Getenv(agent.TokenEnv)
64+ }
65+ ctx, cancel := context.WithTimeout(ctx, a2aTimeout)
66+ defer cancel()
67+ answer, ctxID, err := a2a.Client{}.Send(ctx, agent.URL, token, contextID, message)
68+ if ctxID != "" {
69+ a2aMu.Lock()
70+ a2aContexts[name] = ctxID
71+ a2aMu.Unlock()
72+ }
73+ return strings.TrimSpace(answer), err
74+}
75+
42 // AskA2AAgent declares the tool over the agents of a2a.agents.76 // AskA2AAgent declares the tool over the agents of a2a.agents.
43 func AskA2AAgent(g *genkit.Genkit, d *detector.LoopDetector) ai.ToolRef {77 func AskA2AAgent(g *genkit.Genkit, d *detector.LoopDetector) ai.ToolRef {
44 return genkit.DefineTool(g, "ask_a2a_agent", askA2ADescription(),78 return genkit.DefineTool(g, "ask_a2a_agent", askA2ADescription(),
@@ -62,7 +96,7 @@ Agents:`)
62 }96 }
63 97
64 func askA2A(ctx context.Context, d *detector.LoopDetector, in askA2AInput) (string, error) {98 func askA2A(ctx context.Context, d *detector.LoopDetector, in askA2AInput) (string, error) {
65- agent, ok := config.Cfg.A2A.Agents[in.Agent]99+ _, ok := config.Cfg.A2A.Agents[in.Agent]
66 key := in.Agent + ": " + in.Message100 key := in.Agent + ": " + in.Message
67 title := "ask_a2a_agent: " + in.Agent101 title := "ask_a2a_agent: " + in.Agent
68 if !ok {102 if !ok {
@@ -73,34 +107,16 @@ func askA2A(ctx context.Context, d *detector.LoopDetector, in askA2AInput) (stri
73 return recordFailure(d, "ask_a2a_agent", key, "[ask_a2a_agent: empty message — say something to the agent]")107 return recordFailure(d, "ask_a2a_agent", key, "[ask_a2a_agent: empty message — say something to the agent]")
74 }108 }
75 109
76- a2aMu.Lock()
77- if in.NewConversation {
78- delete(a2aContexts, in.Agent)
79- }
80- contextID := a2aContexts[in.Agent]
81- a2aMu.Unlock()
82-
83 // The remote agent's model can think for minutes, and nothing streams110 // The remote agent's model can think for minutes, and nothing streams
84 // back meanwhile: the call beats the generation's watchdog every second111 // back meanwhile: the call beats the generation's watchdog every second
85 // (like ask_user waiting for a person), bounded by a2aTimeout instead.112 // (like ask_user waiting for a person), bounded by a2aTimeout instead.
86 beat := engine.Heartbeat(ctx)113 beat := engine.Heartbeat(ctx)
87 call := func() (string, bool) {114 call := func() (string, bool) {
88- token := ""115+ answer, err := A2ASend(ctx, in.Agent, in.Message, in.NewConversation)
89- if agent.TokenEnv != "" {
90- token = os.Getenv(agent.TokenEnv)
91- }
92- cctx, cancel := context.WithTimeout(ctx, a2aTimeout)
93- defer cancel()
94- answer, ctxID, err := a2a.Client{}.Send(cctx, agent.URL, token, contextID, in.Message)
95- if ctxID != "" {
96- a2aMu.Lock()
97- a2aContexts[in.Agent] = ctxID
98- a2aMu.Unlock()
99- }
100 if err != nil {116 if err != nil {
101 return fmt.Sprintf("[ask_a2a_agent: %s did not answer — %v]", in.Agent, err), true117 return fmt.Sprintf("[ask_a2a_agent: %s did not answer — %v]", in.Agent, err), true
102 }118 }
103- return strings.TrimSpace(answer), false119+ return answer, false
104 }120 }
105 run := func() (string, bool) {121 run := func() (string, bool) {
106 type result struct {122 type result struct {
added internal/tools/a2a_test.go +42 -0
new file mode 100644
@@ -0,0 +1,42 @@
1+package tools
2+
3+import (
4+ "context"
5+ "net/http/httptest"
6+ "strings"
7+ "testing"
8+
9+ "mm/internal/a2a"
10+ "mm/internal/config"
11+)
12+
13+// A2ASend (ticket 263) keeps one conversation per agent across calls — the
14+// tool's and the /a2a-<name> command's — and starts a new one on request.
15+func TestA2ASendKeepsTheConversation(t *testing.T) {
16+ seen := map[string][]string{}
17+ srv := httptest.NewServer(a2a.NewServer(a2a.AgentCard{Name: "alice"}, func(_ context.Context, contextID, text string) (string, error) {
18+ seen[contextID] = append(seen[contextID], text)
19+ return strings.Join(seen[contextID], " + "), nil
20+ }, ""))
21+ t.Cleanup(srv.Close)
22+ saved := config.Cfg.A2A
23+ t.Cleanup(func() { config.Cfg.A2A = saved })
24+ config.Cfg.A2A.Agents = map[string]config.A2AAgent{"alice": {URL: srv.URL}}
25+ a2aMu.Lock()
26+ delete(a2aContexts, "alice")
27+ a2aMu.Unlock()
28+
29+ ctx := context.Background()
30+ if a, err := A2ASend(ctx, "alice", "one", false); err != nil || a != "one" {
31+ t.Fatalf("first: %q %v", a, err)
32+ }
33+ if a, err := A2ASend(ctx, "alice", "two", false); err != nil || a != "one + two" {
34+ t.Fatalf("second, same conversation: %q %v", a, err)
35+ }
36+ if a, err := A2ASend(ctx, "alice", "fresh", true); err != nil || a != "fresh" || len(seen) != 2 {
37+ t.Fatalf("new conversation: %q %v (%d conversations)", a, err, len(seen))
38+ }
39+ if _, err := A2ASend(ctx, "zed", "hi", false); err == nil || !strings.Contains(err.Error(), "use one of: alice") {
40+ t.Errorf("unknown agent: %v", err)
41+ }
42+}
new file mode 100644
@@ -0,0 +1,42 @@
1+package tools
2+
3+import (
4+ "context"
5+ "net/http/httptest"
6+ "strings"
7+ "testing"
8+
9+ "mm/internal/a2a"
10+ "mm/internal/config"
11+)
12+
13+// A2ASend (ticket 263) keeps one conversation per agent across calls — the
14+// tool's and the /a2a-<name> command's — and starts a new one on request.
15+func TestA2ASendKeepsTheConversation(t *testing.T) {
16+ seen := map[string][]string{}
17+ srv := httptest.NewServer(a2a.NewServer(a2a.AgentCard{Name: "alice"}, func(_ context.Context, contextID, text string) (string, error) {
18+ seen[contextID] = append(seen[contextID], text)
19+ return strings.Join(seen[contextID], " + "), nil
20+ }, ""))
21+ t.Cleanup(srv.Close)
22+ saved := config.Cfg.A2A
23+ t.Cleanup(func() { config.Cfg.A2A = saved })
24+ config.Cfg.A2A.Agents = map[string]config.A2AAgent{"alice": {URL: srv.URL}}
25+ a2aMu.Lock()
26+ delete(a2aContexts, "alice")
27+ a2aMu.Unlock()
28+
29+ ctx := context.Background()
30+ if a, err := A2ASend(ctx, "alice", "one", false); err != nil || a != "one" {
31+ t.Fatalf("first: %q %v", a, err)
32+ }
33+ if a, err := A2ASend(ctx, "alice", "two", false); err != nil || a != "one + two" {
34+ t.Fatalf("second, same conversation: %q %v", a, err)
35+ }
36+ if a, err := A2ASend(ctx, "alice", "fresh", true); err != nil || a != "fresh" || len(seen) != 2 {
37+ t.Fatalf("new conversation: %q %v (%d conversations)", a, err, len(seen))
38+ }
39+ if _, err := A2ASend(ctx, "zed", "hi", false); err == nil || !strings.Contains(err.Error(), "use one of: alice") {
40+ t.Errorf("unknown agent: %v", err)
41+ }
42+}
added internal/tui/a2a.go +55 -0
new file mode 100644
@@ -0,0 +1,55 @@
1+// The window's side of /a2a-<name> (ticket 263): a remote A2A agent answers
2+// in the conversation, under its name, and its answer joins the history for
3+// the next question — the same pair as /ask. Run like a turn, on a
4+// goroutine settled by the loop goroutine, so Esc and Ctrl-C stop it.
5+
6+package tui
7+
8+import (
9+ "context"
10+ "fmt"
11+
12+ "mm/internal/ask"
13+ "mm/internal/command"
14+ "mm/internal/config"
15+ "mm/internal/tools"
16+
17+ "github.com/firebase/genkit/go/ai"
18+)
19+
20+// startA2A shows the command as typed and sends the message on a goroutine.
21+func (r *runner) startA2A(p Prompt, req command.A2ARequest) {
22+ r.t.AddUser(p.Display())
23+ r.t.Notice("🤝 " + req.Agent + " (A2A)")
24+ ctx, cancel := context.WithCancel(context.Background())
25+ r.cancel = cancel
26+ r.cancelled.Store(false)
27+ r.busy.Store("asking " + req.Agent)
28+ r.watch.start()
29+ msgs := append([]*ai.Message(nil), r.messages...)
30+ go func() {
31+ answer, err := tools.A2ASend(ctx, req.Agent, req.Message, false)
32+ exchange := ask.Exchange(req.Agent, "A2A", false, req.Message, answer, config.Cfg.MaxOutput)
33+ r.results <- outcome{kind: "a2a", messages: append(msgs, exchange...), err: err, cancelled: ctx.Err() != nil, line: req.Agent, answer: answer}
34+ r.wake()
35+ }()
36+}
37+
38+// applyA2A shows the answer under the agent's name and keeps the exchange,
39+// only when the agent answered.
40+func (r *runner) applyA2A(res outcome) {
41+ switch {
42+ case res.err != nil && res.cancelled:
43+ r.t.Notice("🔴 Aborted — nothing kept.")
44+ case res.err != nil:
45+ r.t.Error(fmt.Sprintf("[%s did not answer: %v]", res.line, res.err))
46+ default:
47+ r.t.SetSpeaker(res.line)
48+ r.t.Chunk(res.answer)
49+ r.t.Close()
50+ r.t.SetSpeaker("")
51+ r.messages = res.messages
52+ r.save()
53+ r.t.Notice(fmt.Sprintf("🗣 %s's answer is in the history for your next question", res.line))
54+ }
55+}
new file mode 100644
@@ -0,0 +1,55 @@
1+// The window's side of /a2a-<name> (ticket 263): a remote A2A agent answers
2+// in the conversation, under its name, and its answer joins the history for
3+// the next question — the same pair as /ask. Run like a turn, on a
4+// goroutine settled by the loop goroutine, so Esc and Ctrl-C stop it.
5+
6+package tui
7+
8+import (
9+ "context"
10+ "fmt"
11+
12+ "mm/internal/ask"
13+ "mm/internal/command"
14+ "mm/internal/config"
15+ "mm/internal/tools"
16+
17+ "github.com/firebase/genkit/go/ai"
18+)
19+
20+// startA2A shows the command as typed and sends the message on a goroutine.
21+func (r *runner) startA2A(p Prompt, req command.A2ARequest) {
22+ r.t.AddUser(p.Display())
23+ r.t.Notice("🤝 " + req.Agent + " (A2A)")
24+ ctx, cancel := context.WithCancel(context.Background())
25+ r.cancel = cancel
26+ r.cancelled.Store(false)
27+ r.busy.Store("asking " + req.Agent)
28+ r.watch.start()
29+ msgs := append([]*ai.Message(nil), r.messages...)
30+ go func() {
31+ answer, err := tools.A2ASend(ctx, req.Agent, req.Message, false)
32+ exchange := ask.Exchange(req.Agent, "A2A", false, req.Message, answer, config.Cfg.MaxOutput)
33+ r.results <- outcome{kind: "a2a", messages: append(msgs, exchange...), err: err, cancelled: ctx.Err() != nil, line: req.Agent, answer: answer}
34+ r.wake()
35+ }()
36+}
37+
38+// applyA2A shows the answer under the agent's name and keeps the exchange,
39+// only when the agent answered.
40+func (r *runner) applyA2A(res outcome) {
41+ switch {
42+ case res.err != nil && res.cancelled:
43+ r.t.Notice("🔴 Aborted — nothing kept.")
44+ case res.err != nil:
45+ r.t.Error(fmt.Sprintf("[%s did not answer: %v]", res.line, res.err))
46+ default:
47+ r.t.SetSpeaker(res.line)
48+ r.t.Chunk(res.answer)
49+ r.t.Close()
50+ r.t.SetSpeaker("")
51+ r.messages = res.messages
52+ r.save()
53+ r.t.Notice(fmt.Sprintf("🗣 %s's answer is in the history for your next question", res.line))
54+ }
55+}
modified internal/tui/commands.go +8 -0
@@ -84,6 +84,14 @@ func (r *runner) dispatch(p Prompt) {
8484 r.startAsk(p, req)
8585 return
8686 }
87+ if req, isA2A, err := command.ParseA2A(p.Typed); isA2A {
88+ if err != nil {
89+ r.t.Error("⚠️ " + err.Error())
90+ return
91+ }
92+ r.startA2A(p, req)
93+ return
94+ }
8795 cmd, arg, ok := command.Parse(p.Typed)
8896 if !ok {
8997 r.startTurn(p)
@@ -84,6 +84,14 @@ func (r *runner) dispatch(p Prompt) {
84 r.startAsk(p, req)84 r.startAsk(p, req)
85 return85 return
86 }86 }
87+ if req, isA2A, err := command.ParseA2A(p.Typed); isA2A {
88+ if err != nil {
89+ r.t.Error("⚠️ " + err.Error())
90+ return
91+ }
92+ r.startA2A(p, req)
93+ return
94+ }
87 cmd, arg, ok := command.Parse(p.Typed)95 cmd, arg, ok := command.Parse(p.Typed)
88 if !ok {96 if !ok {
89 r.startTurn(p)97 r.startTurn(p)
modified internal/tui/turn.go +6 -1
@@ -77,7 +77,8 @@ type Copier interface {
7777 // outcome is what a background job — a turn or a compaction — reports back
7878 // to the loop goroutine.
7979 type outcome struct {
80- kind string // "turn", "compact" or "ask"
80+ kind string // "turn", "compact", "ask" or "a2a"
81+ answer string // "a2a": the remote agent's answer, to show
8182 messages []*ai.Message
8283 before int
8384 resp *ai.ModelResponse
@@ -324,6 +325,10 @@ func (r *runner) apply(res outcome) {
324325 r.applyAsk(res)
325326 return
326327 }
328+ if res.kind == "a2a" {
329+ r.applyA2A(res)
330+ return
331+ }
327332 if res.kind == "compact" {
328333 r.messages = res.messages
329334 switch {
@@ -77,7 +77,8 @@ type Copier interface {
77 // outcome is what a background job — a turn or a compaction — reports back77 // outcome is what a background job — a turn or a compaction — reports back
78 // to the loop goroutine.78 // to the loop goroutine.
79 type outcome struct {79 type outcome struct {
80- kind string // "turn", "compact" or "ask"80+ kind string // "turn", "compact", "ask" or "a2a"
81+ answer string // "a2a": the remote agent's answer, to show
81 messages []*ai.Message82 messages []*ai.Message
82 before int83 before int
83 resp *ai.ModelResponse84 resp *ai.ModelResponse
@@ -324,6 +325,10 @@ func (r *runner) apply(res outcome) {
324 r.applyAsk(res)325 r.applyAsk(res)
325 return326 return
326 }327 }
328+ if res.kind == "a2a" {
329+ r.applyA2A(res)
330+ return
331+ }
327 if res.kind == "compact" {332 if res.kind == "compact" {
328 r.messages = res.messages333 r.messages = res.messages
329 switch {334 switch {
modified main.go +1 -0
@@ -267,6 +267,7 @@ func main() {
267267 // commands join the shared table before any front end reads it, and their
268268 // processes start on the first ask and stop when this one exits.
269269 command.SetAgents(config.AgentNames())
270+ command.SetA2AAgents(config.A2AAgentNames())
270271 command.SetUnload(config.Cfg.UnloadModels)
271272 command.SetMemory(config.Cfg.Sessions.MemoryCommand())
272273 command.SetDocs(config.Cfg.DocSearch.DocsCommand())
@@ -267,6 +267,7 @@ func main() {
267 // commands join the shared table before any front end reads it, and their267 // commands join the shared table before any front end reads it, and their
268 // processes start on the first ask and stop when this one exits.268 // processes start on the first ask and stop when this one exits.
269 command.SetAgents(config.AgentNames())269 command.SetAgents(config.AgentNames())
270+ command.SetA2AAgents(config.A2AAgentNames())
270 command.SetUnload(config.Cfg.UnloadModels)271 command.SetUnload(config.Cfg.UnloadModels)
271 command.SetMemory(config.Cfg.Sessions.MemoryCommand())272 command.SetMemory(config.Cfg.Sessions.MemoryCommand())
272 command.SetDocs(config.Cfg.DocSearch.DocsCommand())273 command.SetDocs(config.Cfg.DocSearch.DocsCommand())