#90 Outils proposés aux agents en tant que client ACP (org.mini-me/tools)
Sidekicks offre trois outils aux agents par les méthodes d'extension ACP, avec le protocole de mini-me : memory_pressure, about_sidekicks et current_channel. La liste part dans le _meta d'initialize, ou seulement la capacité quand le fichier de l'agent demande discovery: request ; _org.mini-me/tools/list et les méthodes des outils sont répondus au format MCP. clientInfo.version porte la vraie version (build/config.yml embarqué). Tests avec un faux agent ACP ; docs EN + FR. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
0f4a300 parent: d6c1074 modified
.tickets/issues/0090-proposer-des-outils-aux-agents-en-tant-que-clien.yaml +47 -11 | @@ -1,12 +1,12 @@ | ||
| 1 | 1 | # Managed by IssueSpec. Hand edits are welcome; keep the schema valid. |
| 2 | 2 | id: 90 |
| 3 | 3 | title: "Proposer des outils aux agents en tant que client ACP (extensions org.mini-me/tools)" |
| 4 | -state: open | |
| 4 | +state: closed | |
| 5 | 5 | author: |
| 6 | 6 | name: k33g |
| 7 | 7 | email: ph.charriere@gmail.com |
| 8 | 8 | createdAt: 2026-11-10T23:22:37.000Z |
| 9 | -updatedAt: 2026-11-10T23:22:37.000Z | |
| 9 | +updatedAt: 2026-11-10T23:28:58.000Z | |
| 10 | 10 | labels: |
| 11 | 11 | - "kind::feature" |
| 12 | 12 | - "area::acp" |
| @@ -73,66 +73,102 @@ body: | | ||
| 73 | 73 | tasks: |
| 74 | 74 | - id: 1 |
| 75 | 75 | title: "Annoncer la liste dans initialize (_meta org.mini-me/tools) et répondre aux méthodes d'extension" |
| 76 | - state: open | |
| 76 | + state: closed | |
| 77 | 77 | priority: high |
| 78 | 78 | author: |
| 79 | 79 | name: k33g |
| 80 | 80 | email: ph.charriere@gmail.com |
| 81 | 81 | createdAt: 2026-11-10T23:22:37.000Z |
| 82 | + updatedAt: 2026-11-10T23:28:58.000Z | |
| 83 | + closedAt: 2026-11-10T23:28:58.000Z | |
| 82 | 84 | - id: 2 |
| 83 | 85 | title: "Registre d'outils et correspondance sessionId → channel" |
| 84 | - state: open | |
| 86 | + state: closed | |
| 85 | 87 | priority: high |
| 86 | 88 | author: |
| 87 | 89 | name: k33g |
| 88 | 90 | email: ph.charriere@gmail.com |
| 89 | 91 | createdAt: 2026-11-10T23:22:37.000Z |
| 92 | + updatedAt: 2026-11-10T23:28:58.000Z | |
| 93 | + closedAt: 2026-11-10T23:28:58.000Z | |
| 90 | 94 | - id: 3 |
| 91 | 95 | title: "Outil memory_pressure" |
| 92 | - state: open | |
| 96 | + state: closed | |
| 93 | 97 | priority: medium |
| 94 | 98 | author: |
| 95 | 99 | name: k33g |
| 96 | 100 | email: ph.charriere@gmail.com |
| 97 | 101 | createdAt: 2026-11-10T23:22:37.000Z |
| 102 | + updatedAt: 2026-11-10T23:28:58.000Z | |
| 103 | + closedAt: 2026-11-10T23:28:58.000Z | |
| 98 | 104 | - id: 4 |
| 99 | 105 | title: "Outil about_sidekicks (version injectée au build, ClientInfo.Version)" |
| 100 | - state: open | |
| 106 | + state: closed | |
| 101 | 107 | priority: medium |
| 102 | 108 | author: |
| 103 | 109 | name: k33g |
| 104 | 110 | email: ph.charriere@gmail.com |
| 105 | 111 | createdAt: 2026-11-10T23:22:37.000Z |
| 112 | + updatedAt: 2026-11-10T23:28:58.000Z | |
| 113 | + closedAt: 2026-11-10T23:28:58.000Z | |
| 106 | 114 | - id: 5 |
| 107 | 115 | title: "Outil current_channel" |
| 108 | - state: open | |
| 116 | + state: closed | |
| 109 | 117 | priority: medium |
| 110 | 118 | author: |
| 111 | 119 | name: k33g |
| 112 | 120 | email: ph.charriere@gmail.com |
| 113 | 121 | createdAt: 2026-11-10T23:22:37.000Z |
| 122 | + updatedAt: 2026-11-10T23:28:58.000Z | |
| 123 | + closedAt: 2026-11-10T23:28:58.000Z | |
| 114 | 124 | - id: 6 |
| 115 | 125 | title: "Mode de découverte request : décider et implémenter _org.mini-me/tools/list" |
| 116 | - state: open | |
| 126 | + state: closed | |
| 117 | 127 | priority: medium |
| 118 | 128 | author: |
| 119 | 129 | name: k33g |
| 120 | 130 | email: ph.charriere@gmail.com |
| 121 | 131 | createdAt: 2026-11-10T23:22:37.000Z |
| 132 | + updatedAt: 2026-11-10T23:28:58.000Z | |
| 133 | + closedAt: 2026-11-10T23:28:58.000Z | |
| 122 | 134 | - id: 7 |
| 123 | 135 | title: "Tests avec un faux agent qui appelle les méthodes ; essai avec Riker" |
| 124 | - state: open | |
| 136 | + state: closed | |
| 125 | 137 | priority: high |
| 126 | 138 | author: |
| 127 | 139 | name: k33g |
| 128 | 140 | email: ph.charriere@gmail.com |
| 129 | 141 | createdAt: 2026-11-10T23:22:37.000Z |
| 142 | + updatedAt: 2026-11-10T23:28:58.000Z | |
| 143 | + closedAt: 2026-11-10T23:28:58.000Z | |
| 130 | 144 | - id: 8 |
| 131 | 145 | title: "Documentation EN + FR" |
| 132 | - state: open | |
| 146 | + state: closed | |
| 133 | 147 | priority: medium |
| 134 | 148 | author: |
| 135 | 149 | name: k33g |
| 136 | 150 | email: ph.charriere@gmail.com |
| 137 | 151 | createdAt: 2026-11-10T23:22:37.000Z |
| 138 | -comments: [] | |
| 152 | + updatedAt: 2026-11-10T23:28:58.000Z | |
| 153 | + closedAt: 2026-11-10T23:28:58.000Z | |
| 154 | +comments: | |
| 155 | + - id: 1 | |
| 156 | + author: | |
| 157 | + name: k33g | |
| 158 | + email: ph.charriere@gmail.com | |
| 159 | + createdAt: 2026-11-10T23:28:58.000Z | |
| 160 | + body: | | |
| 161 | + Fait. | |
| 162 | + - [internal/acp/tools.go](internal/acp/tools.go) : `acp.Tool`, la liste dans `clientCapabilities._meta["org.mini-me/tools"]` | |
| 163 | + (ou `true` en mode `request`), `HandleExtensionMethod` répond à `_org.mini-me/tools/list`, aux méthodes des | |
| 164 | + outils (résultat au format MCP, `isError` en cas d'échec) et `-32601` au reste. `clientInfo.version` est la vraie version. | |
| 165 | + - Mode de découverte : **lu dans le fichier de l'agent** (`--config <fichier>`, `acp.clientTools.discovery`), | |
| 166 | + [internal/agents/discovery.go](internal/agents/discovery.go) ; `meta` par défaut. | |
| 167 | + - Outils : [internal/app/clienttools.go](internal/app/clienttools.go) ; `current_channel` retrouve le channel par | |
| 168 | + `channels.Manager.SessionChannel(agent, sessionId)`. Version : `build/config.yml` embarqué dans `main.go`. | |
| 169 | + - Tests : faux agent ACP qui appelle la liste, un outil, un outil en échec et une méthode inconnue | |
| 170 | + ([internal/acp/tools_test.go](internal/acp/tools_test.go)) ; découverte ; channel d'une session ; textes des outils. | |
| 171 | + - Docs EN + FR : guide « Laisser un agent utiliser les outils de Sidekicks », référence « Outils proposés aux agents », | |
| 172 | + explication dans « Pourquoi ACP ». | |
| 173 | + - Reste à faire sur le Mac : l'essai avec Riker (`mm` n'est pas dans la sandbox de développement). | |
| 174 | + | |
| @@ -1,12 +1,12 @@ | |||
| 1 | # Managed by IssueSpec. Hand edits are welcome; keep the schema valid. | 1 | # Managed by IssueSpec. Hand edits are welcome; keep the schema valid. |
| 2 | id: 90 | 2 | id: 90 |
| 3 | title: "Proposer des outils aux agents en tant que client ACP (extensions org.mini-me/tools)" | 3 | title: "Proposer des outils aux agents en tant que client ACP (extensions org.mini-me/tools)" |
| 4 | -state: open | 4 | +state: closed |
| 5 | author: | 5 | author: |
| 6 | name: k33g | 6 | name: k33g |
| 7 | email: ph.charriere@gmail.com | 7 | email: ph.charriere@gmail.com |
| 8 | createdAt: 2026-11-10T23:22:37.000Z | 8 | createdAt: 2026-11-10T23:22:37.000Z |
| 9 | -updatedAt: 2026-11-10T23:22:37.000Z | 9 | +updatedAt: 2026-11-10T23:28:58.000Z |
| 10 | labels: | 10 | labels: |
| 11 | - "kind::feature" | 11 | - "kind::feature" |
| 12 | - "area::acp" | 12 | - "area::acp" |
| @@ -73,66 +73,102 @@ body: | | |||
| 73 | tasks: | 73 | tasks: |
| 74 | - id: 1 | 74 | - id: 1 |
| 75 | title: "Annoncer la liste dans initialize (_meta org.mini-me/tools) et répondre aux méthodes d'extension" | 75 | title: "Annoncer la liste dans initialize (_meta org.mini-me/tools) et répondre aux méthodes d'extension" |
| 76 | - state: open | 76 | + state: closed |
| 77 | priority: high | 77 | priority: high |
| 78 | author: | 78 | author: |
| 79 | name: k33g | 79 | name: k33g |
| 80 | email: ph.charriere@gmail.com | 80 | email: ph.charriere@gmail.com |
| 81 | createdAt: 2026-11-10T23:22:37.000Z | 81 | createdAt: 2026-11-10T23:22:37.000Z |
| 82 | + updatedAt: 2026-11-10T23:28:58.000Z | ||
| 83 | + closedAt: 2026-11-10T23:28:58.000Z | ||
| 82 | - id: 2 | 84 | - id: 2 |
| 83 | title: "Registre d'outils et correspondance sessionId → channel" | 85 | title: "Registre d'outils et correspondance sessionId → channel" |
| 84 | - state: open | 86 | + state: closed |
| 85 | priority: high | 87 | priority: high |
| 86 | author: | 88 | author: |
| 87 | name: k33g | 89 | name: k33g |
| 88 | email: ph.charriere@gmail.com | 90 | email: ph.charriere@gmail.com |
| 89 | createdAt: 2026-11-10T23:22:37.000Z | 91 | createdAt: 2026-11-10T23:22:37.000Z |
| 92 | + updatedAt: 2026-11-10T23:28:58.000Z | ||
| 93 | + closedAt: 2026-11-10T23:28:58.000Z | ||
| 90 | - id: 3 | 94 | - id: 3 |
| 91 | title: "Outil memory_pressure" | 95 | title: "Outil memory_pressure" |
| 92 | - state: open | 96 | + state: closed |
| 93 | priority: medium | 97 | priority: medium |
| 94 | author: | 98 | author: |
| 95 | name: k33g | 99 | name: k33g |
| 96 | email: ph.charriere@gmail.com | 100 | email: ph.charriere@gmail.com |
| 97 | createdAt: 2026-11-10T23:22:37.000Z | 101 | createdAt: 2026-11-10T23:22:37.000Z |
| 102 | + updatedAt: 2026-11-10T23:28:58.000Z | ||
| 103 | + closedAt: 2026-11-10T23:28:58.000Z | ||
| 98 | - id: 4 | 104 | - id: 4 |
| 99 | title: "Outil about_sidekicks (version injectée au build, ClientInfo.Version)" | 105 | title: "Outil about_sidekicks (version injectée au build, ClientInfo.Version)" |
| 100 | - state: open | 106 | + state: closed |
| 101 | priority: medium | 107 | priority: medium |
| 102 | author: | 108 | author: |
| 103 | name: k33g | 109 | name: k33g |
| 104 | email: ph.charriere@gmail.com | 110 | email: ph.charriere@gmail.com |
| 105 | createdAt: 2026-11-10T23:22:37.000Z | 111 | createdAt: 2026-11-10T23:22:37.000Z |
| 112 | + updatedAt: 2026-11-10T23:28:58.000Z | ||
| 113 | + closedAt: 2026-11-10T23:28:58.000Z | ||
| 106 | - id: 5 | 114 | - id: 5 |
| 107 | title: "Outil current_channel" | 115 | title: "Outil current_channel" |
| 108 | - state: open | 116 | + state: closed |
| 109 | priority: medium | 117 | priority: medium |
| 110 | author: | 118 | author: |
| 111 | name: k33g | 119 | name: k33g |
| 112 | email: ph.charriere@gmail.com | 120 | email: ph.charriere@gmail.com |
| 113 | createdAt: 2026-11-10T23:22:37.000Z | 121 | createdAt: 2026-11-10T23:22:37.000Z |
| 122 | + updatedAt: 2026-11-10T23:28:58.000Z | ||
| 123 | + closedAt: 2026-11-10T23:28:58.000Z | ||
| 114 | - id: 6 | 124 | - id: 6 |
| 115 | title: "Mode de découverte request : décider et implémenter _org.mini-me/tools/list" | 125 | title: "Mode de découverte request : décider et implémenter _org.mini-me/tools/list" |
| 116 | - state: open | 126 | + state: closed |
| 117 | priority: medium | 127 | priority: medium |
| 118 | author: | 128 | author: |
| 119 | name: k33g | 129 | name: k33g |
| 120 | email: ph.charriere@gmail.com | 130 | email: ph.charriere@gmail.com |
| 121 | createdAt: 2026-11-10T23:22:37.000Z | 131 | createdAt: 2026-11-10T23:22:37.000Z |
| 132 | + updatedAt: 2026-11-10T23:28:58.000Z | ||
| 133 | + closedAt: 2026-11-10T23:28:58.000Z | ||
| 122 | - id: 7 | 134 | - id: 7 |
| 123 | title: "Tests avec un faux agent qui appelle les méthodes ; essai avec Riker" | 135 | title: "Tests avec un faux agent qui appelle les méthodes ; essai avec Riker" |
| 124 | - state: open | 136 | + state: closed |
| 125 | priority: high | 137 | priority: high |
| 126 | author: | 138 | author: |
| 127 | name: k33g | 139 | name: k33g |
| 128 | email: ph.charriere@gmail.com | 140 | email: ph.charriere@gmail.com |
| 129 | createdAt: 2026-11-10T23:22:37.000Z | 141 | createdAt: 2026-11-10T23:22:37.000Z |
| 142 | + updatedAt: 2026-11-10T23:28:58.000Z | ||
| 143 | + closedAt: 2026-11-10T23:28:58.000Z | ||
| 130 | - id: 8 | 144 | - id: 8 |
| 131 | title: "Documentation EN + FR" | 145 | title: "Documentation EN + FR" |
| 132 | - state: open | 146 | + state: closed |
| 133 | priority: medium | 147 | priority: medium |
| 134 | author: | 148 | author: |
| 135 | name: k33g | 149 | name: k33g |
| 136 | email: ph.charriere@gmail.com | 150 | email: ph.charriere@gmail.com |
| 137 | createdAt: 2026-11-10T23:22:37.000Z | 151 | createdAt: 2026-11-10T23:22:37.000Z |
| 138 | -comments: [] | 152 | + updatedAt: 2026-11-10T23:28:58.000Z |
| 153 | + closedAt: 2026-11-10T23:28:58.000Z | ||
| 154 | +comments: | ||
| 155 | + - id: 1 | ||
| 156 | + author: | ||
| 157 | + name: k33g | ||
| 158 | + email: ph.charriere@gmail.com | ||
| 159 | + createdAt: 2026-11-10T23:28:58.000Z | ||
| 160 | + body: | | ||
| 161 | + Fait. | ||
| 162 | + - [internal/acp/tools.go](internal/acp/tools.go) : `acp.Tool`, la liste dans `clientCapabilities._meta["org.mini-me/tools"]` | ||
| 163 | + (ou `true` en mode `request`), `HandleExtensionMethod` répond à `_org.mini-me/tools/list`, aux méthodes des | ||
| 164 | + outils (résultat au format MCP, `isError` en cas d'échec) et `-32601` au reste. `clientInfo.version` est la vraie version. | ||
| 165 | + - Mode de découverte : **lu dans le fichier de l'agent** (`--config <fichier>`, `acp.clientTools.discovery`), | ||
| 166 | + [internal/agents/discovery.go](internal/agents/discovery.go) ; `meta` par défaut. | ||
| 167 | + - Outils : [internal/app/clienttools.go](internal/app/clienttools.go) ; `current_channel` retrouve le channel par | ||
| 168 | + `channels.Manager.SessionChannel(agent, sessionId)`. Version : `build/config.yml` embarqué dans `main.go`. | ||
| 169 | + - Tests : faux agent ACP qui appelle la liste, un outil, un outil en échec et une méthode inconnue | ||
| 170 | + ([internal/acp/tools_test.go](internal/acp/tools_test.go)) ; découverte ; channel d'une session ; textes des outils. | ||
| 171 | + - Docs EN + FR : guide « Laisser un agent utiliser les outils de Sidekicks », référence « Outils proposés aux agents », | ||
| 172 | + explication dans « Pourquoi ACP ». | ||
| 173 | + - Reste à faire sur le Mac : l'essai avec Riker (`mm` n'est pas dans la sandbox de développement). | ||
| 174 | + | ||
modified
docs/en/README.md +1 -1 | @@ -7,7 +7,7 @@ This documentation follows [Diátaxis](https://diataxis.fr): pick the section th | ||
| 7 | 7 | | You want to… | Section | Pages | |
| 8 | 8 | | --- | --- | --- | |
| 9 | 9 | | **learn** by doing | Tutorials | [Your first agent, without writing any configuration](tutorials/your-first-agent.md) · [A channel with two agents](tutorials/first-channel.md) · [Your first conversation with an agent](tutorials/first-conversation.md) · [Your first launch of Sidekicks](tutorials/first-launch.md) · [Your first ACP exchange with a test agent](tutorials/first-acp-exchange.md) | |
| 10 | -| **do** a specific task | How-to guides | [Install Sidekicks](how-to/install-sidekicks.md) · [Add an agent](how-to/add-an-agent.md) · [Work with an agent's files and terminal](how-to/work-with-an-agents-files.md) · [Run an agent in a Docker container](how-to/run-an-agent-in-docker.md) · [Run an agent in an sbx sandbox](how-to/run-an-agent-in-a-sandbox.md) · [Add a Claude agent in an sbx sandbox](how-to/add-a-claude-agent-in-a-sandbox.md) · [Add a Codex agent in an sbx sandbox](how-to/add-a-codex-agent-in-a-sandbox.md) · [Add a Gemini agent in an sbx sandbox](how-to/add-a-gemini-agent-in-a-sandbox.md) · [Join files to a message](how-to/join-files-to-a-message.md) · [Manage channels and their agents](how-to/manage-channels.md) · [Edit or switch the configuration](how-to/edit-or-switch-the-configuration.md) · [Reset Sidekicks](how-to/reset-sidekicks.md) · [Watch the memory pressure](how-to/watch-the-memory-pressure.md) · [Develop the application](how-to/develop-the-application.md) · [Run the tests](how-to/run-the-tests.md) · [Check a change before merging it](how-to/check-before-merging.md) · [Run a test agent](how-to/run-a-test-agent.md) · [Run the end-to-end scenarios (v0.1)](how-to/run-the-end-to-end-scenarios.md) · [Set the version](how-to/set-the-version.md) · [Publish a release](how-to/publish-a-release.md) · [Sign and notarize for macOS](how-to/sign-and-notarize-on-macos.md) · [Test issue #52 on macOS](how-to/test-issue-52-on-macos.md) · [Test issues #49 and #50 on macOS](how-to/test-issues-49-and-50-on-macos.md) · [Test issue #47 on macOS](how-to/test-issue-47-on-macos.md) · [Test milestone M4 on macOS](how-to/test-milestone-m4-on-macos.md) · [Test milestone M3 on macOS](how-to/test-milestone-m3-on-macos.md) · [Test milestone M2 on macOS](how-to/test-milestone-m2-on-macos.md) · [Test milestone M1 on macOS](how-to/test-milestone-m1-on-macos.md) · [Test milestone Initialize on macOS](how-to/test-milestone-initialize-on-macos.md) | | |
| 10 | +| **do** a specific task | How-to guides | [Install Sidekicks](how-to/install-sidekicks.md) · [Add an agent](how-to/add-an-agent.md) · [Work with an agent's files and terminal](how-to/work-with-an-agents-files.md) · [Run an agent in a Docker container](how-to/run-an-agent-in-docker.md) · [Run an agent in an sbx sandbox](how-to/run-an-agent-in-a-sandbox.md) · [Add a Claude agent in an sbx sandbox](how-to/add-a-claude-agent-in-a-sandbox.md) · [Add a Codex agent in an sbx sandbox](how-to/add-a-codex-agent-in-a-sandbox.md) · [Add a Gemini agent in an sbx sandbox](how-to/add-a-gemini-agent-in-a-sandbox.md) · [Join files to a message](how-to/join-files-to-a-message.md) · [Manage channels and their agents](how-to/manage-channels.md) · [Edit or switch the configuration](how-to/edit-or-switch-the-configuration.md) · [Reset Sidekicks](how-to/reset-sidekicks.md) · [Watch the memory pressure](how-to/watch-the-memory-pressure.md) · [Let an agent use Sidekicks' tools](how-to/use-sidekicks-tools-from-an-agent.md) · [Develop the application](how-to/develop-the-application.md) · [Run the tests](how-to/run-the-tests.md) · [Check a change before merging it](how-to/check-before-merging.md) · [Run a test agent](how-to/run-a-test-agent.md) · [Run the end-to-end scenarios (v0.1)](how-to/run-the-end-to-end-scenarios.md) · [Set the version](how-to/set-the-version.md) · [Publish a release](how-to/publish-a-release.md) · [Sign and notarize for macOS](how-to/sign-and-notarize-on-macos.md) · [Test issue #52 on macOS](how-to/test-issue-52-on-macos.md) · [Test issues #49 and #50 on macOS](how-to/test-issues-49-and-50-on-macos.md) · [Test issue #47 on macOS](how-to/test-issue-47-on-macos.md) · [Test milestone M4 on macOS](how-to/test-milestone-m4-on-macos.md) · [Test milestone M3 on macOS](how-to/test-milestone-m3-on-macos.md) · [Test milestone M2 on macOS](how-to/test-milestone-m2-on-macos.md) · [Test milestone M1 on macOS](how-to/test-milestone-m1-on-macos.md) · [Test milestone Initialize on macOS](how-to/test-milestone-initialize-on-macos.md) | | |
| 11 | 11 | | **look up** an exact detail | Reference | [The configuration file](reference/configuration.md) · [Keyboard shortcuts](reference/keyboard-shortcuts.md) · [Agents, channels and events](reference/agents-and-events.md) · [Commands](reference/commands.md) · [scripts/agents.sh](reference/agents-script.md) | |
| 12 | 12 | | **understand** why | Explanation | [Workspaces and terminals](explanation/workspaces-and-terminals.md) · [Channels and what each agent knows](explanation/channels-and-context.md) · [Permissions and trust](explanation/permissions.md) · [Why ACP](explanation/why-acp.md) · [The interface stack](explanation/ui-stack.md) · [Architecture](explanation/architecture.md) · [Memory and local models](explanation/memory-and-local-models.md) | |
| 13 | 13 | |
| @@ -7,7 +7,7 @@ This documentation follows [Diátaxis](https://diataxis.fr): pick the section th | |||
| 7 | | You want to… | Section | Pages | | 7 | | You want to… | Section | Pages | |
| 8 | | --- | --- | --- | | 8 | | --- | --- | --- | |
| 9 | | **learn** by doing | Tutorials | [Your first agent, without writing any configuration](tutorials/your-first-agent.md) · [A channel with two agents](tutorials/first-channel.md) · [Your first conversation with an agent](tutorials/first-conversation.md) · [Your first launch of Sidekicks](tutorials/first-launch.md) · [Your first ACP exchange with a test agent](tutorials/first-acp-exchange.md) | | 9 | | **learn** by doing | Tutorials | [Your first agent, without writing any configuration](tutorials/your-first-agent.md) · [A channel with two agents](tutorials/first-channel.md) · [Your first conversation with an agent](tutorials/first-conversation.md) · [Your first launch of Sidekicks](tutorials/first-launch.md) · [Your first ACP exchange with a test agent](tutorials/first-acp-exchange.md) | |
| 10 | -| **do** a specific task | How-to guides | [Install Sidekicks](how-to/install-sidekicks.md) · [Add an agent](how-to/add-an-agent.md) · [Work with an agent's files and terminal](how-to/work-with-an-agents-files.md) · [Run an agent in a Docker container](how-to/run-an-agent-in-docker.md) · [Run an agent in an sbx sandbox](how-to/run-an-agent-in-a-sandbox.md) · [Add a Claude agent in an sbx sandbox](how-to/add-a-claude-agent-in-a-sandbox.md) · [Add a Codex agent in an sbx sandbox](how-to/add-a-codex-agent-in-a-sandbox.md) · [Add a Gemini agent in an sbx sandbox](how-to/add-a-gemini-agent-in-a-sandbox.md) · [Join files to a message](how-to/join-files-to-a-message.md) · [Manage channels and their agents](how-to/manage-channels.md) · [Edit or switch the configuration](how-to/edit-or-switch-the-configuration.md) · [Reset Sidekicks](how-to/reset-sidekicks.md) · [Watch the memory pressure](how-to/watch-the-memory-pressure.md) · [Develop the application](how-to/develop-the-application.md) · [Run the tests](how-to/run-the-tests.md) · [Check a change before merging it](how-to/check-before-merging.md) · [Run a test agent](how-to/run-a-test-agent.md) · [Run the end-to-end scenarios (v0.1)](how-to/run-the-end-to-end-scenarios.md) · [Set the version](how-to/set-the-version.md) · [Publish a release](how-to/publish-a-release.md) · [Sign and notarize for macOS](how-to/sign-and-notarize-on-macos.md) · [Test issue #52 on macOS](how-to/test-issue-52-on-macos.md) · [Test issues #49 and #50 on macOS](how-to/test-issues-49-and-50-on-macos.md) · [Test issue #47 on macOS](how-to/test-issue-47-on-macos.md) · [Test milestone M4 on macOS](how-to/test-milestone-m4-on-macos.md) · [Test milestone M3 on macOS](how-to/test-milestone-m3-on-macos.md) · [Test milestone M2 on macOS](how-to/test-milestone-m2-on-macos.md) · [Test milestone M1 on macOS](how-to/test-milestone-m1-on-macos.md) · [Test milestone Initialize on macOS](how-to/test-milestone-initialize-on-macos.md) | | 10 | +| **do** a specific task | How-to guides | [Install Sidekicks](how-to/install-sidekicks.md) · [Add an agent](how-to/add-an-agent.md) · [Work with an agent's files and terminal](how-to/work-with-an-agents-files.md) · [Run an agent in a Docker container](how-to/run-an-agent-in-docker.md) · [Run an agent in an sbx sandbox](how-to/run-an-agent-in-a-sandbox.md) · [Add a Claude agent in an sbx sandbox](how-to/add-a-claude-agent-in-a-sandbox.md) · [Add a Codex agent in an sbx sandbox](how-to/add-a-codex-agent-in-a-sandbox.md) · [Add a Gemini agent in an sbx sandbox](how-to/add-a-gemini-agent-in-a-sandbox.md) · [Join files to a message](how-to/join-files-to-a-message.md) · [Manage channels and their agents](how-to/manage-channels.md) · [Edit or switch the configuration](how-to/edit-or-switch-the-configuration.md) · [Reset Sidekicks](how-to/reset-sidekicks.md) · [Watch the memory pressure](how-to/watch-the-memory-pressure.md) · [Let an agent use Sidekicks' tools](how-to/use-sidekicks-tools-from-an-agent.md) · [Develop the application](how-to/develop-the-application.md) · [Run the tests](how-to/run-the-tests.md) · [Check a change before merging it](how-to/check-before-merging.md) · [Run a test agent](how-to/run-a-test-agent.md) · [Run the end-to-end scenarios (v0.1)](how-to/run-the-end-to-end-scenarios.md) · [Set the version](how-to/set-the-version.md) · [Publish a release](how-to/publish-a-release.md) · [Sign and notarize for macOS](how-to/sign-and-notarize-on-macos.md) · [Test issue #52 on macOS](how-to/test-issue-52-on-macos.md) · [Test issues #49 and #50 on macOS](how-to/test-issues-49-and-50-on-macos.md) · [Test issue #47 on macOS](how-to/test-issue-47-on-macos.md) · [Test milestone M4 on macOS](how-to/test-milestone-m4-on-macos.md) · [Test milestone M3 on macOS](how-to/test-milestone-m3-on-macos.md) · [Test milestone M2 on macOS](how-to/test-milestone-m2-on-macos.md) · [Test milestone M1 on macOS](how-to/test-milestone-m1-on-macos.md) · [Test milestone Initialize on macOS](how-to/test-milestone-initialize-on-macos.md) | |
| 11 | | **look up** an exact detail | Reference | [The configuration file](reference/configuration.md) · [Keyboard shortcuts](reference/keyboard-shortcuts.md) · [Agents, channels and events](reference/agents-and-events.md) · [Commands](reference/commands.md) · [scripts/agents.sh](reference/agents-script.md) | | 11 | | **look up** an exact detail | Reference | [The configuration file](reference/configuration.md) · [Keyboard shortcuts](reference/keyboard-shortcuts.md) · [Agents, channels and events](reference/agents-and-events.md) · [Commands](reference/commands.md) · [scripts/agents.sh](reference/agents-script.md) | |
| 12 | | **understand** why | Explanation | [Workspaces and terminals](explanation/workspaces-and-terminals.md) · [Channels and what each agent knows](explanation/channels-and-context.md) · [Permissions and trust](explanation/permissions.md) · [Why ACP](explanation/why-acp.md) · [The interface stack](explanation/ui-stack.md) · [Architecture](explanation/architecture.md) · [Memory and local models](explanation/memory-and-local-models.md) | | 12 | | **understand** why | Explanation | [Workspaces and terminals](explanation/workspaces-and-terminals.md) · [Channels and what each agent knows](explanation/channels-and-context.md) · [Permissions and trust](explanation/permissions.md) · [Why ACP](explanation/why-acp.md) · [The interface stack](explanation/ui-stack.md) · [Architecture](explanation/architecture.md) · [Memory and local models](explanation/memory-and-local-models.md) | |
| 13 | 13 | ||
modified
docs/en/explanation/why-acp.md +4 -0 | @@ -17,6 +17,10 @@ Reading a specification is not the same as watching an agent. The spike drove th | ||
| 17 | 17 | - **Skills are slash commands.** Garfield's skills arrive as commands, and `/idioms Il pleut des cordes.` sent as plain text runs the skill. In a channel with several agents, `/garfield:idioms …` only needs Sidekicks to strip the agent's name and send the rest to Garfield. |
| 18 | 18 | - **A small model does not take no for an answer.** Refused once, Riker retried the same action forty times in different forms until mm gave up with an error. A permission dialog that only offers "allow" and "reject" leaves a non-technical user facing forty dialogs; hence "never in this conversation" and "stop the agent" (see the [wireframe](../../design/04-permission.png)). |
| 19 | 19 | |
| 20 | +## Offering tools to the agents | |
| 21 | + | |
| 22 | +ACP lets a client answer methods of its own (names starting with `_`), but says nothing about how an agent learns them, nor how a model calls them. mini-me fills that gap with a small protocol, `org.mini-me/tools`: the client lists its tools, and mm turns each one into a tool of its model, `client_<name>`. Sidekicks speaks it (issue #90) because only Sidekicks knows some things an agent is asked about: the memory pressure of the computer it shares with the agents, the version of the application, the channel a conversation happens in and who else is there. Offering a tool costs an agent nothing when it does not know the protocol: the list travels in `_meta`, which ACP tells every agent to ignore when it does not understand it. Sidekicks follows the agent's choice of discovery, read in its file, rather than a setting of its own: the agent's file already says it, and two places to keep in step would drift apart. | |
| 23 | + | |
| 20 | 24 | ## Rejected alternatives |
| 21 | 25 | |
| 22 | 26 | - **Writing the JSON-RPC layer by hand**: possible, but the Go SDK by Coder is generated from the official schema, covers every v1 message, and has no dependencies. Owning that code would be cost without benefit. |
| @@ -17,6 +17,10 @@ Reading a specification is not the same as watching an agent. The spike drove th | |||
| 17 | - **Skills are slash commands.** Garfield's skills arrive as commands, and `/idioms Il pleut des cordes.` sent as plain text runs the skill. In a channel with several agents, `/garfield:idioms …` only needs Sidekicks to strip the agent's name and send the rest to Garfield. | 17 | - **Skills are slash commands.** Garfield's skills arrive as commands, and `/idioms Il pleut des cordes.` sent as plain text runs the skill. In a channel with several agents, `/garfield:idioms …` only needs Sidekicks to strip the agent's name and send the rest to Garfield. |
| 18 | - **A small model does not take no for an answer.** Refused once, Riker retried the same action forty times in different forms until mm gave up with an error. A permission dialog that only offers "allow" and "reject" leaves a non-technical user facing forty dialogs; hence "never in this conversation" and "stop the agent" (see the [wireframe](../../design/04-permission.png)). | 18 | - **A small model does not take no for an answer.** Refused once, Riker retried the same action forty times in different forms until mm gave up with an error. A permission dialog that only offers "allow" and "reject" leaves a non-technical user facing forty dialogs; hence "never in this conversation" and "stop the agent" (see the [wireframe](../../design/04-permission.png)). |
| 19 | 19 | ||
| 20 | +## Offering tools to the agents | ||
| 21 | + | ||
| 22 | +ACP lets a client answer methods of its own (names starting with `_`), but says nothing about how an agent learns them, nor how a model calls them. mini-me fills that gap with a small protocol, `org.mini-me/tools`: the client lists its tools, and mm turns each one into a tool of its model, `client_<name>`. Sidekicks speaks it (issue #90) because only Sidekicks knows some things an agent is asked about: the memory pressure of the computer it shares with the agents, the version of the application, the channel a conversation happens in and who else is there. Offering a tool costs an agent nothing when it does not know the protocol: the list travels in `_meta`, which ACP tells every agent to ignore when it does not understand it. Sidekicks follows the agent's choice of discovery, read in its file, rather than a setting of its own: the agent's file already says it, and two places to keep in step would drift apart. | ||
| 23 | + | ||
| 20 | ## Rejected alternatives | 24 | ## Rejected alternatives |
| 21 | 25 | ||
| 22 | - **Writing the JSON-RPC layer by hand**: possible, but the Go SDK by Coder is generated from the official schema, covers every v1 message, and has no dependencies. Owning that code would be cost without benefit. | 26 | - **Writing the JSON-RPC layer by hand**: possible, but the Go SDK by Coder is generated from the official schema, covers every v1 message, and has no dependencies. Owning that code would be cost without benefit. |
added
docs/en/how-to/use-sidekicks-tools-from-an-agent.md +37 -0 | new file mode 100644 | ||
| @@ -0,0 +1,37 @@ | ||
| 1 | +# How to let an agent use Sidekicks' tools | |
| 2 | + | |
| 3 | +This guide shows how to let a mini-me agent (`mm`) call the tools Sidekicks offers it: the memory pressure of the computer, what Sidekicks is, and the channel it is talking in. It assumes the agent is already added (see [Add an agent](add-an-agent.md)) and started with `--acp --config <file>`. | |
| 4 | + | |
| 5 | +## Steps | |
| 6 | + | |
| 7 | +1. Open the agent's file (`agent.yaml`) and add, under `acp:`: | |
| 8 | + | |
| 9 | + ```yaml | |
| 10 | + acp: | |
| 11 | + clientTools: | |
| 12 | + enabled: true | |
| 13 | + discovery: meta # or request | |
| 14 | + permissions: auto # ask: the user allows each call | |
| 15 | + timeout: 30s | |
| 16 | + ``` | |
| 17 | + | |
| 18 | +2. Restart the agent: in Sidekicks, **Stop** then send it a message, or quit and relaunch Sidekicks. The tools are offered when the agent starts. | |
| 19 | +3. Ask it, for instance in `#general`: | |
| 20 | + - `@riker what is the memory pressure?` — it calls `client_memory_pressure`; | |
| 21 | + - `@riker what is Sidekicks?` — it calls `client_about_sidekicks`; | |
| 22 | + - `@riker which channel are we in, and who is here?` — it calls `client_current_channel`. | |
| 23 | + | |
| 24 | + The call shows in its answer like any tool call (`client: memory_pressure`), and in its log (`[acp] client tools (meta): …` at start). | |
| 25 | + | |
| 26 | +A small model calls a tool more readily when its instructions name it: add to its `system:` a line such as "Call client_current_channel to know where you are and who is there." | |
| 27 | + | |
| 28 | +## Variants | |
| 29 | + | |
| 30 | +- **`discovery: request`**: Sidekicks reads the agent's file (the one after `--config`) to know it, announces the tools only, and gives the list each time the agent opens a session. The file is read on this computer: an agent in a sandbox or a container must have it at the same path, which the assistant's sbx and Docker variants already require. | |
| 31 | +- **`permissions: ask`**, or `auto` without `yolo: true`: each call asks the user first, with the usual permission card (`client: <name>`). | |
| 32 | +- **Another agent** (Claude, Codex, Gemini, docker-agent): the tools are offered too, but these agents do not know mini-me's protocol and ignore them. | |
| 33 | + | |
| 34 | +## See also | |
| 35 | + | |
| 36 | +- What each tool returns, and the protocol: [Tools offered to the agents](../reference/agents-and-events.md#tools-offered-to-the-agents) | |
| 37 | +- [Why Sidekicks speaks ACP](../explanation/why-acp.md#offering-tools-to-the-agents) | |
| new file mode 100644 | |||
| @@ -0,0 +1,37 @@ | |||
| 1 | +# How to let an agent use Sidekicks' tools | ||
| 2 | + | ||
| 3 | +This guide shows how to let a mini-me agent (`mm`) call the tools Sidekicks offers it: the memory pressure of the computer, what Sidekicks is, and the channel it is talking in. It assumes the agent is already added (see [Add an agent](add-an-agent.md)) and started with `--acp --config <file>`. | ||
| 4 | + | ||
| 5 | +## Steps | ||
| 6 | + | ||
| 7 | +1. Open the agent's file (`agent.yaml`) and add, under `acp:`: | ||
| 8 | + | ||
| 9 | + ```yaml | ||
| 10 | + acp: | ||
| 11 | + clientTools: | ||
| 12 | + enabled: true | ||
| 13 | + discovery: meta # or request | ||
| 14 | + permissions: auto # ask: the user allows each call | ||
| 15 | + timeout: 30s | ||
| 16 | + ``` | ||
| 17 | + | ||
| 18 | +2. Restart the agent: in Sidekicks, **Stop** then send it a message, or quit and relaunch Sidekicks. The tools are offered when the agent starts. | ||
| 19 | +3. Ask it, for instance in `#general`: | ||
| 20 | + - `@riker what is the memory pressure?` — it calls `client_memory_pressure`; | ||
| 21 | + - `@riker what is Sidekicks?` — it calls `client_about_sidekicks`; | ||
| 22 | + - `@riker which channel are we in, and who is here?` — it calls `client_current_channel`. | ||
| 23 | + | ||
| 24 | + The call shows in its answer like any tool call (`client: memory_pressure`), and in its log (`[acp] client tools (meta): …` at start). | ||
| 25 | + | ||
| 26 | +A small model calls a tool more readily when its instructions name it: add to its `system:` a line such as "Call client_current_channel to know where you are and who is there." | ||
| 27 | + | ||
| 28 | +## Variants | ||
| 29 | + | ||
| 30 | +- **`discovery: request`**: Sidekicks reads the agent's file (the one after `--config`) to know it, announces the tools only, and gives the list each time the agent opens a session. The file is read on this computer: an agent in a sandbox or a container must have it at the same path, which the assistant's sbx and Docker variants already require. | ||
| 31 | +- **`permissions: ask`**, or `auto` without `yolo: true`: each call asks the user first, with the usual permission card (`client: <name>`). | ||
| 32 | +- **Another agent** (Claude, Codex, Gemini, docker-agent): the tools are offered too, but these agents do not know mini-me's protocol and ignore them. | ||
| 33 | + | ||
| 34 | +## See also | ||
| 35 | + | ||
| 36 | +- What each tool returns, and the protocol: [Tools offered to the agents](../reference/agents-and-events.md#tools-offered-to-the-agents) | ||
| 37 | +- [Why Sidekicks speaks ACP](../explanation/why-acp.md#offering-tools-to-the-agents) | ||
modified
docs/en/reference/agents-and-events.md +21 -0 | @@ -235,6 +235,27 @@ A file opened for editing has `path, content, version`; `version` identifies the | ||
| 235 | 235 | | `ChooseCompose()` | The native file dialog, for a Compose file. | |
| 236 | 236 | | `Reset(choice)` | The Danger zone: `settings` (default configuration, preferences forgotten), `history` (this configuration's), `allHistory` (every configuration's) or `everything`. Each thing reset is first kept as a dated copy; returns `{copies[]}`. The history is reopened empty and the declared channels created again; then `config:changed` is sent. | |
| 237 | 237 | |
| 238 | +## Tools offered to the agents | |
| 239 | + | |
| 240 | +Issue #90. Sidekicks offers every agent three tools, with mini-me's protocol (`org.mini-me/tools`, ACP extension methods). An agent that knows it (`acp.clientTools` in an `mm` file) gives them to its model as `client_<name>`; the others ignore them. | |
| 241 | + | |
| 242 | +| Tool (the model sees) | Method | Returns | | |
| 243 | +| --- | --- | --- | | |
| 244 | +| `memory_pressure` (`client_memory_pressure`) | `_com.rickub.sidekicks/system/memory` | `Memory pressure: warning (yellow). Used: 24.0 GB of 32.0 GB (75 %).`, as the **Log** panel shows it ([Watch the memory pressure](../how-to/watch-the-memory-pressure.md)); `The memory cannot be measured on this computer.` where it cannot be | | |
| 245 | +| `about_sidekicks` (`client_about_sidekicks`) | `_com.rickub.sidekicks/about` | Sidekicks' version (`info.version` of `build/config.yml`, `dev` for a development build), the system and architecture, what Sidekicks is, the agent's name in it, the releases page | | |
| 246 | +| `current_channel` (`client_current_channel`) | `_com.rickub.sidekicks/channel/current` | `Channel #<name>.`, its description and its members (`you (@agent), @other, and the user.`), or `A direct conversation between the user and you (<agent>)…`. The channel is the one whose session (`_meta["org.mini-me/sessionId"]` of the call) the agent holds; a session of no channel is an error | | |
| 247 | + | |
| 248 | +None takes a parameter. The protocol: | |
| 249 | + | |
| 250 | +| Step | What Sidekicks does | | |
| 251 | +| --- | --- | | |
| 252 | +| `initialize` | `clientCapabilities._meta["org.mini-me/tools"]` holds the list (`name, description, method`), or `true` when the agent's file says `acp.clientTools.discovery: request`. The file is the one after `--config` (or `-config`) in the agent's arguments, relative to its folder; without it, or unreadable, `meta`. `clientInfo.version` is Sidekicks' version | | |
| 253 | +| `_org.mini-me/tools/list` | answered with `{"tools": [...]}` | | |
| 254 | +| a tool's method | answered with `{"content":[{"type":"text","text":"…"}],"isError":false}`; a failure has `isError: true` and says why | | |
| 255 | +| any other `_…` method | JSON-RPC error `-32601` (Method not found) | | |
| 256 | + | |
| 257 | +With `acp.clientTools.permissions: ask` (or `auto` without `yolo`), mm asks before each call: the permission card shows `client: <name>`. | |
| 258 | + | |
| 238 | 259 | ## Stopping an agent |
| 239 | 260 | |
| 240 | 261 | The agent's stdin is closed; after 5 s the agent and its children get SIGTERM (time for `scripts/agents.sh` to unload the model); after 3 more seconds, SIGKILL. |
| @@ -235,6 +235,27 @@ A file opened for editing has `path, content, version`; `version` identifies the | |||
| 235 | | `ChooseCompose()` | The native file dialog, for a Compose file. | | 235 | | `ChooseCompose()` | The native file dialog, for a Compose file. | |
| 236 | | `Reset(choice)` | The Danger zone: `settings` (default configuration, preferences forgotten), `history` (this configuration's), `allHistory` (every configuration's) or `everything`. Each thing reset is first kept as a dated copy; returns `{copies[]}`. The history is reopened empty and the declared channels created again; then `config:changed` is sent. | | 236 | | `Reset(choice)` | The Danger zone: `settings` (default configuration, preferences forgotten), `history` (this configuration's), `allHistory` (every configuration's) or `everything`. Each thing reset is first kept as a dated copy; returns `{copies[]}`. The history is reopened empty and the declared channels created again; then `config:changed` is sent. | |
| 237 | 237 | ||
| 238 | +## Tools offered to the agents | ||
| 239 | + | ||
| 240 | +Issue #90. Sidekicks offers every agent three tools, with mini-me's protocol (`org.mini-me/tools`, ACP extension methods). An agent that knows it (`acp.clientTools` in an `mm` file) gives them to its model as `client_<name>`; the others ignore them. | ||
| 241 | + | ||
| 242 | +| Tool (the model sees) | Method | Returns | | ||
| 243 | +| --- | --- | --- | | ||
| 244 | +| `memory_pressure` (`client_memory_pressure`) | `_com.rickub.sidekicks/system/memory` | `Memory pressure: warning (yellow). Used: 24.0 GB of 32.0 GB (75 %).`, as the **Log** panel shows it ([Watch the memory pressure](../how-to/watch-the-memory-pressure.md)); `The memory cannot be measured on this computer.` where it cannot be | | ||
| 245 | +| `about_sidekicks` (`client_about_sidekicks`) | `_com.rickub.sidekicks/about` | Sidekicks' version (`info.version` of `build/config.yml`, `dev` for a development build), the system and architecture, what Sidekicks is, the agent's name in it, the releases page | | ||
| 246 | +| `current_channel` (`client_current_channel`) | `_com.rickub.sidekicks/channel/current` | `Channel #<name>.`, its description and its members (`you (@agent), @other, and the user.`), or `A direct conversation between the user and you (<agent>)…`. The channel is the one whose session (`_meta["org.mini-me/sessionId"]` of the call) the agent holds; a session of no channel is an error | | ||
| 247 | + | ||
| 248 | +None takes a parameter. The protocol: | ||
| 249 | + | ||
| 250 | +| Step | What Sidekicks does | | ||
| 251 | +| --- | --- | | ||
| 252 | +| `initialize` | `clientCapabilities._meta["org.mini-me/tools"]` holds the list (`name, description, method`), or `true` when the agent's file says `acp.clientTools.discovery: request`. The file is the one after `--config` (or `-config`) in the agent's arguments, relative to its folder; without it, or unreadable, `meta`. `clientInfo.version` is Sidekicks' version | | ||
| 253 | +| `_org.mini-me/tools/list` | answered with `{"tools": [...]}` | | ||
| 254 | +| a tool's method | answered with `{"content":[{"type":"text","text":"…"}],"isError":false}`; a failure has `isError: true` and says why | | ||
| 255 | +| any other `_…` method | JSON-RPC error `-32601` (Method not found) | | ||
| 256 | + | ||
| 257 | +With `acp.clientTools.permissions: ask` (or `auto` without `yolo`), mm asks before each call: the permission card shows `client: <name>`. | ||
| 258 | + | ||
| 238 | ## Stopping an agent | 259 | ## Stopping an agent |
| 239 | 260 | ||
| 240 | The agent's stdin is closed; after 5 s the agent and its children get SIGTERM (time for `scripts/agents.sh` to unload the model); after 3 more seconds, SIGKILL. | 261 | The agent's stdin is closed; after 5 s the agent and its children get SIGTERM (time for `scripts/agents.sh` to unload the model); after 3 more seconds, SIGKILL. |
modified
docs/fr/README.md +1 -1 | @@ -7,7 +7,7 @@ Cette documentation suit la méthode [Diátaxis](https://diataxis.fr) : choisiss | ||
| 7 | 7 | | Vous voulez… | Section | Pages | |
| 8 | 8 | | --- | --- | --- | |
| 9 | 9 | | **apprendre** en pratiquant | Tutoriels | [Votre premier agent, sans écrire de configuration](tutorials/premier-agent.md) · [Un channel avec deux agents](tutorials/premier-channel.md) · [Votre première conversation avec un agent](tutorials/premiere-conversation.md) · [Votre premier lancement de Sidekicks](tutorials/premier-lancement.md) · [Votre premier échange ACP avec un agent de test](tutorials/premier-echange-acp.md) | |
| 10 | -| **réaliser** une tâche précise | Guides pratiques | [Installer Sidekicks](how-to/installer-sidekicks.md) · [Ajouter un agent](how-to/ajouter-un-agent.md) · [Travailler avec les fichiers et le terminal d'un agent](how-to/fichiers-et-terminal-d-un-agent.md) · [Lancer un agent dans un conteneur Docker](how-to/lancer-un-agent-dans-docker.md) · [Lancer un agent dans une sandbox sbx](how-to/lancer-un-agent-dans-une-sandbox.md) · [Ajouter un agent Claude dans une sandbox sbx](how-to/ajouter-un-agent-claude-dans-une-sandbox.md) · [Ajouter un agent Codex dans une sandbox sbx](how-to/ajouter-un-agent-codex-dans-une-sandbox.md) · [Ajouter un agent Gemini dans une sandbox sbx](how-to/ajouter-un-agent-gemini-dans-une-sandbox.md) · [Joindre des fichiers à un message](how-to/joindre-des-fichiers-a-un-message.md) · [Gérer les channels et leurs agents](how-to/gerer-les-channels.md) · [Modifier ou changer la configuration](how-to/modifier-ou-changer-la-configuration.md) · [Repartir de zéro](how-to/repartir-de-zero.md) · [Surveiller la pression mémoire](how-to/surveiller-la-pression-memoire.md) · [Développer l'application](how-to/developper-l-application.md) · [Lancer les tests](how-to/lancer-les-tests.md) · [Vérifier une modification avant de la fusionner](how-to/verifier-avant-de-fusionner.md) · [Lancer un agent de test](how-to/lancer-un-agent-de-test.md) · [Dérouler les scénarios de bout en bout (v0.1)](how-to/derouler-les-scenarios-de-bout-en-bout.md) · [Définir la version](how-to/definir-la-version.md) · [Tester la CI locale (temporaire)](how-to/tester-la-ci-locale.md) · [Publier une release](how-to/publier-une-release.md) · [Signer et notariser pour macOS](how-to/signer-et-notariser-sous-macos.md) · [Tester l'issue #52 sous macOS](how-to/tester-l-issue-52-sous-macos.md) · [Tester les issues #49 et #50 sous macOS](how-to/tester-les-issues-49-et-50-sous-macos.md) · [Tester l'issue #47 sous macOS](how-to/tester-l-issue-47-sous-macos.md) · [Tester la milestone M4 sous macOS](how-to/tester-la-milestone-m4-sous-macos.md) · [Tester la milestone M3 sous macOS](how-to/tester-la-milestone-m3-sous-macos.md) · [Tester la milestone M2 sous macOS](how-to/tester-la-milestone-m2-sous-macos.md) · [Tester la milestone M1 sous macOS](how-to/tester-la-milestone-m1-sous-macos.md) · [Tester la milestone Initialize sous macOS](how-to/tester-la-milestone-initialize-sous-macos.md) | | |
| 10 | +| **réaliser** une tâche précise | Guides pratiques | [Installer Sidekicks](how-to/installer-sidekicks.md) · [Ajouter un agent](how-to/ajouter-un-agent.md) · [Travailler avec les fichiers et le terminal d'un agent](how-to/fichiers-et-terminal-d-un-agent.md) · [Lancer un agent dans un conteneur Docker](how-to/lancer-un-agent-dans-docker.md) · [Lancer un agent dans une sandbox sbx](how-to/lancer-un-agent-dans-une-sandbox.md) · [Ajouter un agent Claude dans une sandbox sbx](how-to/ajouter-un-agent-claude-dans-une-sandbox.md) · [Ajouter un agent Codex dans une sandbox sbx](how-to/ajouter-un-agent-codex-dans-une-sandbox.md) · [Ajouter un agent Gemini dans une sandbox sbx](how-to/ajouter-un-agent-gemini-dans-une-sandbox.md) · [Joindre des fichiers à un message](how-to/joindre-des-fichiers-a-un-message.md) · [Gérer les channels et leurs agents](how-to/gerer-les-channels.md) · [Modifier ou changer la configuration](how-to/modifier-ou-changer-la-configuration.md) · [Repartir de zéro](how-to/repartir-de-zero.md) · [Surveiller la pression mémoire](how-to/surveiller-la-pression-memoire.md) · [Laisser un agent utiliser les outils de Sidekicks](how-to/utiliser-les-outils-de-sidekicks-depuis-un-agent.md) · [Développer l'application](how-to/developper-l-application.md) · [Lancer les tests](how-to/lancer-les-tests.md) · [Vérifier une modification avant de la fusionner](how-to/verifier-avant-de-fusionner.md) · [Lancer un agent de test](how-to/lancer-un-agent-de-test.md) · [Dérouler les scénarios de bout en bout (v0.1)](how-to/derouler-les-scenarios-de-bout-en-bout.md) · [Définir la version](how-to/definir-la-version.md) · [Tester la CI locale (temporaire)](how-to/tester-la-ci-locale.md) · [Publier une release](how-to/publier-une-release.md) · [Signer et notariser pour macOS](how-to/signer-et-notariser-sous-macos.md) · [Tester l'issue #52 sous macOS](how-to/tester-l-issue-52-sous-macos.md) · [Tester les issues #49 et #50 sous macOS](how-to/tester-les-issues-49-et-50-sous-macos.md) · [Tester l'issue #47 sous macOS](how-to/tester-l-issue-47-sous-macos.md) · [Tester la milestone M4 sous macOS](how-to/tester-la-milestone-m4-sous-macos.md) · [Tester la milestone M3 sous macOS](how-to/tester-la-milestone-m3-sous-macos.md) · [Tester la milestone M2 sous macOS](how-to/tester-la-milestone-m2-sous-macos.md) · [Tester la milestone M1 sous macOS](how-to/tester-la-milestone-m1-sous-macos.md) · [Tester la milestone Initialize sous macOS](how-to/tester-la-milestone-initialize-sous-macos.md) | | |
| 11 | 11 | | **consulter** un détail exact | Référence | [Le fichier de configuration](reference/configuration.md) · [Raccourcis clavier](reference/raccourcis-clavier.md) · [Agents, channels et événements](reference/agents-et-evenements.md) · [Commandes](reference/commandes.md) · [scripts/agents.sh](reference/script-agents.md) | |
| 12 | 12 | | **comprendre** le pourquoi | Explications | [Workspaces et terminaux](explanation/workspaces-et-terminaux.md) · [Les channels et ce que sait chaque agent](explanation/channels-et-contexte.md) · [Permissions et confiance](explanation/permissions-et-confiance.md) · [Pourquoi ACP](explanation/pourquoi-acp.md) · [La stack de l'interface](explanation/stack-interface.md) · [Architecture](explanation/architecture.md) · [Mémoire et modèles locaux](explanation/memoire-et-modeles-locaux.md) | |
| 13 | 13 | |
| @@ -7,7 +7,7 @@ Cette documentation suit la méthode [Diátaxis](https://diataxis.fr) : choisiss | |||
| 7 | | Vous voulez… | Section | Pages | | 7 | | Vous voulez… | Section | Pages | |
| 8 | | --- | --- | --- | | 8 | | --- | --- | --- | |
| 9 | | **apprendre** en pratiquant | Tutoriels | [Votre premier agent, sans écrire de configuration](tutorials/premier-agent.md) · [Un channel avec deux agents](tutorials/premier-channel.md) · [Votre première conversation avec un agent](tutorials/premiere-conversation.md) · [Votre premier lancement de Sidekicks](tutorials/premier-lancement.md) · [Votre premier échange ACP avec un agent de test](tutorials/premier-echange-acp.md) | | 9 | | **apprendre** en pratiquant | Tutoriels | [Votre premier agent, sans écrire de configuration](tutorials/premier-agent.md) · [Un channel avec deux agents](tutorials/premier-channel.md) · [Votre première conversation avec un agent](tutorials/premiere-conversation.md) · [Votre premier lancement de Sidekicks](tutorials/premier-lancement.md) · [Votre premier échange ACP avec un agent de test](tutorials/premier-echange-acp.md) | |
| 10 | -| **réaliser** une tâche précise | Guides pratiques | [Installer Sidekicks](how-to/installer-sidekicks.md) · [Ajouter un agent](how-to/ajouter-un-agent.md) · [Travailler avec les fichiers et le terminal d'un agent](how-to/fichiers-et-terminal-d-un-agent.md) · [Lancer un agent dans un conteneur Docker](how-to/lancer-un-agent-dans-docker.md) · [Lancer un agent dans une sandbox sbx](how-to/lancer-un-agent-dans-une-sandbox.md) · [Ajouter un agent Claude dans une sandbox sbx](how-to/ajouter-un-agent-claude-dans-une-sandbox.md) · [Ajouter un agent Codex dans une sandbox sbx](how-to/ajouter-un-agent-codex-dans-une-sandbox.md) · [Ajouter un agent Gemini dans une sandbox sbx](how-to/ajouter-un-agent-gemini-dans-une-sandbox.md) · [Joindre des fichiers à un message](how-to/joindre-des-fichiers-a-un-message.md) · [Gérer les channels et leurs agents](how-to/gerer-les-channels.md) · [Modifier ou changer la configuration](how-to/modifier-ou-changer-la-configuration.md) · [Repartir de zéro](how-to/repartir-de-zero.md) · [Surveiller la pression mémoire](how-to/surveiller-la-pression-memoire.md) · [Développer l'application](how-to/developper-l-application.md) · [Lancer les tests](how-to/lancer-les-tests.md) · [Vérifier une modification avant de la fusionner](how-to/verifier-avant-de-fusionner.md) · [Lancer un agent de test](how-to/lancer-un-agent-de-test.md) · [Dérouler les scénarios de bout en bout (v0.1)](how-to/derouler-les-scenarios-de-bout-en-bout.md) · [Définir la version](how-to/definir-la-version.md) · [Tester la CI locale (temporaire)](how-to/tester-la-ci-locale.md) · [Publier une release](how-to/publier-une-release.md) · [Signer et notariser pour macOS](how-to/signer-et-notariser-sous-macos.md) · [Tester l'issue #52 sous macOS](how-to/tester-l-issue-52-sous-macos.md) · [Tester les issues #49 et #50 sous macOS](how-to/tester-les-issues-49-et-50-sous-macos.md) · [Tester l'issue #47 sous macOS](how-to/tester-l-issue-47-sous-macos.md) · [Tester la milestone M4 sous macOS](how-to/tester-la-milestone-m4-sous-macos.md) · [Tester la milestone M3 sous macOS](how-to/tester-la-milestone-m3-sous-macos.md) · [Tester la milestone M2 sous macOS](how-to/tester-la-milestone-m2-sous-macos.md) · [Tester la milestone M1 sous macOS](how-to/tester-la-milestone-m1-sous-macos.md) · [Tester la milestone Initialize sous macOS](how-to/tester-la-milestone-initialize-sous-macos.md) | | 10 | +| **réaliser** une tâche précise | Guides pratiques | [Installer Sidekicks](how-to/installer-sidekicks.md) · [Ajouter un agent](how-to/ajouter-un-agent.md) · [Travailler avec les fichiers et le terminal d'un agent](how-to/fichiers-et-terminal-d-un-agent.md) · [Lancer un agent dans un conteneur Docker](how-to/lancer-un-agent-dans-docker.md) · [Lancer un agent dans une sandbox sbx](how-to/lancer-un-agent-dans-une-sandbox.md) · [Ajouter un agent Claude dans une sandbox sbx](how-to/ajouter-un-agent-claude-dans-une-sandbox.md) · [Ajouter un agent Codex dans une sandbox sbx](how-to/ajouter-un-agent-codex-dans-une-sandbox.md) · [Ajouter un agent Gemini dans une sandbox sbx](how-to/ajouter-un-agent-gemini-dans-une-sandbox.md) · [Joindre des fichiers à un message](how-to/joindre-des-fichiers-a-un-message.md) · [Gérer les channels et leurs agents](how-to/gerer-les-channels.md) · [Modifier ou changer la configuration](how-to/modifier-ou-changer-la-configuration.md) · [Repartir de zéro](how-to/repartir-de-zero.md) · [Surveiller la pression mémoire](how-to/surveiller-la-pression-memoire.md) · [Laisser un agent utiliser les outils de Sidekicks](how-to/utiliser-les-outils-de-sidekicks-depuis-un-agent.md) · [Développer l'application](how-to/developper-l-application.md) · [Lancer les tests](how-to/lancer-les-tests.md) · [Vérifier une modification avant de la fusionner](how-to/verifier-avant-de-fusionner.md) · [Lancer un agent de test](how-to/lancer-un-agent-de-test.md) · [Dérouler les scénarios de bout en bout (v0.1)](how-to/derouler-les-scenarios-de-bout-en-bout.md) · [Définir la version](how-to/definir-la-version.md) · [Tester la CI locale (temporaire)](how-to/tester-la-ci-locale.md) · [Publier une release](how-to/publier-une-release.md) · [Signer et notariser pour macOS](how-to/signer-et-notariser-sous-macos.md) · [Tester l'issue #52 sous macOS](how-to/tester-l-issue-52-sous-macos.md) · [Tester les issues #49 et #50 sous macOS](how-to/tester-les-issues-49-et-50-sous-macos.md) · [Tester l'issue #47 sous macOS](how-to/tester-l-issue-47-sous-macos.md) · [Tester la milestone M4 sous macOS](how-to/tester-la-milestone-m4-sous-macos.md) · [Tester la milestone M3 sous macOS](how-to/tester-la-milestone-m3-sous-macos.md) · [Tester la milestone M2 sous macOS](how-to/tester-la-milestone-m2-sous-macos.md) · [Tester la milestone M1 sous macOS](how-to/tester-la-milestone-m1-sous-macos.md) · [Tester la milestone Initialize sous macOS](how-to/tester-la-milestone-initialize-sous-macos.md) | |
| 11 | | **consulter** un détail exact | Référence | [Le fichier de configuration](reference/configuration.md) · [Raccourcis clavier](reference/raccourcis-clavier.md) · [Agents, channels et événements](reference/agents-et-evenements.md) · [Commandes](reference/commandes.md) · [scripts/agents.sh](reference/script-agents.md) | | 11 | | **consulter** un détail exact | Référence | [Le fichier de configuration](reference/configuration.md) · [Raccourcis clavier](reference/raccourcis-clavier.md) · [Agents, channels et événements](reference/agents-et-evenements.md) · [Commandes](reference/commandes.md) · [scripts/agents.sh](reference/script-agents.md) | |
| 12 | | **comprendre** le pourquoi | Explications | [Workspaces et terminaux](explanation/workspaces-et-terminaux.md) · [Les channels et ce que sait chaque agent](explanation/channels-et-contexte.md) · [Permissions et confiance](explanation/permissions-et-confiance.md) · [Pourquoi ACP](explanation/pourquoi-acp.md) · [La stack de l'interface](explanation/stack-interface.md) · [Architecture](explanation/architecture.md) · [Mémoire et modèles locaux](explanation/memoire-et-modeles-locaux.md) | | 12 | | **comprendre** le pourquoi | Explications | [Workspaces et terminaux](explanation/workspaces-et-terminaux.md) · [Les channels et ce que sait chaque agent](explanation/channels-et-contexte.md) · [Permissions et confiance](explanation/permissions-et-confiance.md) · [Pourquoi ACP](explanation/pourquoi-acp.md) · [La stack de l'interface](explanation/stack-interface.md) · [Architecture](explanation/architecture.md) · [Mémoire et modèles locaux](explanation/memoire-et-modeles-locaux.md) | |
| 13 | 13 | ||
modified
docs/fr/explanation/pourquoi-acp.md +4 -0 | @@ -17,6 +17,10 @@ Lire une spécification n'est pas observer un agent. Le spike a piloté les agen | ||
| 17 | 17 | - **Les skills sont des commandes slash.** Les skills de Garfield arrivent comme des commandes, et `/idioms Il pleut des cordes.` envoyé comme simple texte lance le skill. Dans un channel à plusieurs agents, `/garfield:idioms …` demande seulement à Sidekicks de retirer le nom de l'agent et d'envoyer le reste à Garfield. |
| 18 | 18 | - **Un petit modèle n'accepte pas un refus.** Refusé une fois, Riker a retenté la même action quarante fois sous des formes différentes, jusqu'à ce que mm abandonne sur une erreur. Un dialogue de permission qui ne propose que « autoriser » et « refuser » mettrait un utilisateur non technique face à quarante dialogues ; d'où « jamais dans cette conversation » et « arrêter l'agent » (voir la [maquette](../../design/04-permission.png)). |
| 19 | 19 | |
| 20 | +## Proposer des outils aux agents | |
| 21 | + | |
| 22 | +ACP permet à un client de répondre à ses propres méthodes (dont le nom commence par `_`), mais ne dit ni comment un agent les découvre, ni comment un modèle les appelle. mini-me comble ce manque avec un petit protocole, `org.mini-me/tools` : le client liste ses outils, et mm fait de chacun un outil de son modèle, `client_<nom>`. Sidekicks le parle (ticket #90) parce que lui seul sait certaines choses qu'on demande à un agent : la pression mémoire de l'ordinateur qu'il partage avec les agents, la version de l'application, le channel où se passe une conversation et qui d'autre y est. Proposer un outil ne coûte rien à un agent qui ne connaît pas le protocole : la liste voyage dans `_meta`, qu'ACP demande à tout agent d'ignorer quand il ne le comprend pas. Sidekicks suit le mode de découverte choisi par l'agent, lu dans son fichier, plutôt qu'un réglage à lui : le fichier de l'agent le dit déjà, et deux endroits à garder d'accord finiraient par diverger. | |
| 23 | + | |
| 20 | 24 | ## Alternatives écartées |
| 21 | 25 | |
| 22 | 26 | - **Écrire la couche JSON-RPC à la main** : possible, mais le SDK Go de Coder est généré depuis le schéma officiel, couvre tous les messages v1 et n'a aucune dépendance. Maintenir ce code nous-mêmes coûterait sans rien apporter. |
| @@ -17,6 +17,10 @@ Lire une spécification n'est pas observer un agent. Le spike a piloté les agen | |||
| 17 | - **Les skills sont des commandes slash.** Les skills de Garfield arrivent comme des commandes, et `/idioms Il pleut des cordes.` envoyé comme simple texte lance le skill. Dans un channel à plusieurs agents, `/garfield:idioms …` demande seulement à Sidekicks de retirer le nom de l'agent et d'envoyer le reste à Garfield. | 17 | - **Les skills sont des commandes slash.** Les skills de Garfield arrivent comme des commandes, et `/idioms Il pleut des cordes.` envoyé comme simple texte lance le skill. Dans un channel à plusieurs agents, `/garfield:idioms …` demande seulement à Sidekicks de retirer le nom de l'agent et d'envoyer le reste à Garfield. |
| 18 | - **Un petit modèle n'accepte pas un refus.** Refusé une fois, Riker a retenté la même action quarante fois sous des formes différentes, jusqu'à ce que mm abandonne sur une erreur. Un dialogue de permission qui ne propose que « autoriser » et « refuser » mettrait un utilisateur non technique face à quarante dialogues ; d'où « jamais dans cette conversation » et « arrêter l'agent » (voir la [maquette](../../design/04-permission.png)). | 18 | - **Un petit modèle n'accepte pas un refus.** Refusé une fois, Riker a retenté la même action quarante fois sous des formes différentes, jusqu'à ce que mm abandonne sur une erreur. Un dialogue de permission qui ne propose que « autoriser » et « refuser » mettrait un utilisateur non technique face à quarante dialogues ; d'où « jamais dans cette conversation » et « arrêter l'agent » (voir la [maquette](../../design/04-permission.png)). |
| 19 | 19 | ||
| 20 | +## Proposer des outils aux agents | ||
| 21 | + | ||
| 22 | +ACP permet à un client de répondre à ses propres méthodes (dont le nom commence par `_`), mais ne dit ni comment un agent les découvre, ni comment un modèle les appelle. mini-me comble ce manque avec un petit protocole, `org.mini-me/tools` : le client liste ses outils, et mm fait de chacun un outil de son modèle, `client_<nom>`. Sidekicks le parle (ticket #90) parce que lui seul sait certaines choses qu'on demande à un agent : la pression mémoire de l'ordinateur qu'il partage avec les agents, la version de l'application, le channel où se passe une conversation et qui d'autre y est. Proposer un outil ne coûte rien à un agent qui ne connaît pas le protocole : la liste voyage dans `_meta`, qu'ACP demande à tout agent d'ignorer quand il ne le comprend pas. Sidekicks suit le mode de découverte choisi par l'agent, lu dans son fichier, plutôt qu'un réglage à lui : le fichier de l'agent le dit déjà, et deux endroits à garder d'accord finiraient par diverger. | ||
| 23 | + | ||
| 20 | ## Alternatives écartées | 24 | ## Alternatives écartées |
| 21 | 25 | ||
| 22 | - **Écrire la couche JSON-RPC à la main** : possible, mais le SDK Go de Coder est généré depuis le schéma officiel, couvre tous les messages v1 et n'a aucune dépendance. Maintenir ce code nous-mêmes coûterait sans rien apporter. | 26 | - **Écrire la couche JSON-RPC à la main** : possible, mais le SDK Go de Coder est généré depuis le schéma officiel, couvre tous les messages v1 et n'a aucune dépendance. Maintenir ce code nous-mêmes coûterait sans rien apporter. |
added
docs/fr/how-to/utiliser-les-outils-de-sidekicks-depuis-un-agent.md +37 -0 | new file mode 100644 | ||
| @@ -0,0 +1,37 @@ | ||
| 1 | +# Laisser un agent utiliser les outils de Sidekicks | |
| 2 | + | |
| 3 | +Ce guide montre comment laisser un agent mini-me (`mm`) appeler les outils que Sidekicks lui propose : la pression mémoire de l'ordinateur, ce qu'est Sidekicks, et le channel où il parle. Il suppose l'agent déjà ajouté (voir [Ajouter un agent](ajouter-un-agent.md)) et démarré avec `--acp --config <fichier>`. | |
| 4 | + | |
| 5 | +## Étapes | |
| 6 | + | |
| 7 | +1. Ouvrez le fichier de l'agent (`agent.yaml`) et ajoutez, sous `acp:` : | |
| 8 | + | |
| 9 | + ```yaml | |
| 10 | + acp: | |
| 11 | + clientTools: | |
| 12 | + enabled: true | |
| 13 | + discovery: meta # ou request | |
| 14 | + permissions: auto # ask : l'utilisateur autorise chaque appel | |
| 15 | + timeout: 30s | |
| 16 | + ``` | |
| 17 | + | |
| 18 | +2. Redémarrez l'agent : dans Sidekicks, **Stop** puis envoyez-lui un message, ou quittez et relancez Sidekicks. Les outils sont proposés au démarrage de l'agent. | |
| 19 | +3. Demandez-lui, par exemple dans `#general` : | |
| 20 | + - `@riker quelle est la pression mémoire ?` — il appelle `client_memory_pressure` ; | |
| 21 | + - `@riker qu'est-ce que Sidekicks ?` — il appelle `client_about_sidekicks` ; | |
| 22 | + - `@riker dans quel channel sommes-nous, et qui est là ?` — il appelle `client_current_channel`. | |
| 23 | + | |
| 24 | + L'appel s'affiche dans sa réponse comme tout appel d'outil (`client: memory_pressure`), et dans son journal (`[acp] client tools (meta): …` au démarrage). | |
| 25 | + | |
| 26 | +Un petit modèle appelle plus volontiers un outil que ses instructions nomment : ajoutez à son `system:` une ligne comme « Call client_current_channel to know where you are and who is there. » | |
| 27 | + | |
| 28 | +## Variantes | |
| 29 | + | |
| 30 | +- **`discovery: request`** : Sidekicks lit le fichier de l'agent (celui qui suit `--config`) pour le savoir, annonce seulement les outils, et donne la liste à chaque ouverture de session. Le fichier est lu sur cet ordinateur : un agent dans une sandbox ou un conteneur doit l'avoir au même chemin, ce que demandent déjà les variantes sbx et Docker de l'assistant. | |
| 31 | +- **`permissions: ask`**, ou `auto` sans `yolo: true` : chaque appel demande d'abord à l'utilisateur, avec la carte de permission habituelle (`client: <nom>`). | |
| 32 | +- **Un autre agent** (Claude, Codex, Gemini, docker-agent) : les outils lui sont proposés aussi, mais ces agents ne connaissent pas le protocole de mini-me et les ignorent. | |
| 33 | + | |
| 34 | +## Voir aussi | |
| 35 | + | |
| 36 | +- Ce que renvoie chaque outil, et le protocole : [Outils proposés aux agents](../reference/agents-et-evenements.md#outils-proposés-aux-agents) | |
| 37 | +- [Pourquoi Sidekicks parle ACP](../explanation/pourquoi-acp.md#proposer-des-outils-aux-agents) | |
| new file mode 100644 | |||
| @@ -0,0 +1,37 @@ | |||
| 1 | +# Laisser un agent utiliser les outils de Sidekicks | ||
| 2 | + | ||
| 3 | +Ce guide montre comment laisser un agent mini-me (`mm`) appeler les outils que Sidekicks lui propose : la pression mémoire de l'ordinateur, ce qu'est Sidekicks, et le channel où il parle. Il suppose l'agent déjà ajouté (voir [Ajouter un agent](ajouter-un-agent.md)) et démarré avec `--acp --config <fichier>`. | ||
| 4 | + | ||
| 5 | +## Étapes | ||
| 6 | + | ||
| 7 | +1. Ouvrez le fichier de l'agent (`agent.yaml`) et ajoutez, sous `acp:` : | ||
| 8 | + | ||
| 9 | + ```yaml | ||
| 10 | + acp: | ||
| 11 | + clientTools: | ||
| 12 | + enabled: true | ||
| 13 | + discovery: meta # ou request | ||
| 14 | + permissions: auto # ask : l'utilisateur autorise chaque appel | ||
| 15 | + timeout: 30s | ||
| 16 | + ``` | ||
| 17 | + | ||
| 18 | +2. Redémarrez l'agent : dans Sidekicks, **Stop** puis envoyez-lui un message, ou quittez et relancez Sidekicks. Les outils sont proposés au démarrage de l'agent. | ||
| 19 | +3. Demandez-lui, par exemple dans `#general` : | ||
| 20 | + - `@riker quelle est la pression mémoire ?` — il appelle `client_memory_pressure` ; | ||
| 21 | + - `@riker qu'est-ce que Sidekicks ?` — il appelle `client_about_sidekicks` ; | ||
| 22 | + - `@riker dans quel channel sommes-nous, et qui est là ?` — il appelle `client_current_channel`. | ||
| 23 | + | ||
| 24 | + L'appel s'affiche dans sa réponse comme tout appel d'outil (`client: memory_pressure`), et dans son journal (`[acp] client tools (meta): …` au démarrage). | ||
| 25 | + | ||
| 26 | +Un petit modèle appelle plus volontiers un outil que ses instructions nomment : ajoutez à son `system:` une ligne comme « Call client_current_channel to know where you are and who is there. » | ||
| 27 | + | ||
| 28 | +## Variantes | ||
| 29 | + | ||
| 30 | +- **`discovery: request`** : Sidekicks lit le fichier de l'agent (celui qui suit `--config`) pour le savoir, annonce seulement les outils, et donne la liste à chaque ouverture de session. Le fichier est lu sur cet ordinateur : un agent dans une sandbox ou un conteneur doit l'avoir au même chemin, ce que demandent déjà les variantes sbx et Docker de l'assistant. | ||
| 31 | +- **`permissions: ask`**, ou `auto` sans `yolo: true` : chaque appel demande d'abord à l'utilisateur, avec la carte de permission habituelle (`client: <nom>`). | ||
| 32 | +- **Un autre agent** (Claude, Codex, Gemini, docker-agent) : les outils lui sont proposés aussi, mais ces agents ne connaissent pas le protocole de mini-me et les ignorent. | ||
| 33 | + | ||
| 34 | +## Voir aussi | ||
| 35 | + | ||
| 36 | +- Ce que renvoie chaque outil, et le protocole : [Outils proposés aux agents](../reference/agents-et-evenements.md#outils-proposés-aux-agents) | ||
| 37 | +- [Pourquoi Sidekicks parle ACP](../explanation/pourquoi-acp.md#proposer-des-outils-aux-agents) | ||
modified
docs/fr/reference/agents-et-evenements.md +21 -0 | @@ -235,6 +235,27 @@ Un fichier ouvert pour modification a `path, content, version` ; `version` ident | ||
| 235 | 235 | | `ChooseCompose()` | Le sélecteur de fichier natif, pour un fichier Compose. | |
| 236 | 236 | | `Reset(choice)` | La Danger zone : `settings` (configuration par défaut, préférences oubliées), `history` (celui de cette configuration), `allHistory` (celui de toutes les configurations) ou `everything`. Chaque élément réinitialisé est d'abord gardé en copie datée ; renvoie `{copies[]}`. L'historique est rouvert vide et les channels déclarés sont recréés ; puis `config:changed` est envoyé. | |
| 237 | 237 | |
| 238 | +## Outils proposés aux agents | |
| 239 | + | |
| 240 | +Ticket #90. Sidekicks propose trois outils à chaque agent, avec le protocole de mini-me (`org.mini-me/tools`, méthodes d'extension ACP). Un agent qui le connaît (`acp.clientTools` dans un fichier `mm`) les donne à son modèle sous le nom `client_<nom>` ; les autres les ignorent. | |
| 241 | + | |
| 242 | +| Outil (le modèle voit) | Méthode | Renvoie | | |
| 243 | +| --- | --- | --- | | |
| 244 | +| `memory_pressure` (`client_memory_pressure`) | `_com.rickub.sidekicks/system/memory` | `Memory pressure: warning (yellow). Used: 24.0 GB of 32.0 GB (75 %).`, comme l'affiche le panneau **Log** ([Surveiller la pression mémoire](../how-to/surveiller-la-pression-memoire.md)) ; `The memory cannot be measured on this computer.` là où elle ne se mesure pas | | |
| 245 | +| `about_sidekicks` (`client_about_sidekicks`) | `_com.rickub.sidekicks/about` | la version de Sidekicks (`info.version` de `build/config.yml`, `dev` pour une version de développement), le système et l'architecture, ce qu'est Sidekicks, le nom de l'agent dans Sidekicks, la page des releases | | |
| 246 | +| `current_channel` (`client_current_channel`) | `_com.rickub.sidekicks/channel/current` | `Channel #<nom>.`, sa description et ses membres (`you (@agent), @autre, and the user.`), ou `A direct conversation between the user and you (<agent>)…`. Le channel est celui dont l'agent tient la session (`_meta["org.mini-me/sessionId"]` de l'appel) ; une session d'aucun channel est une erreur | | |
| 247 | + | |
| 248 | +Aucun n'a de paramètre. Le protocole : | |
| 249 | + | |
| 250 | +| Étape | Ce que fait Sidekicks | | |
| 251 | +| --- | --- | | |
| 252 | +| `initialize` | `clientCapabilities._meta["org.mini-me/tools"]` contient la liste (`name, description, method`), ou `true` quand le fichier de l'agent indique `acp.clientTools.discovery: request`. Le fichier est celui qui suit `--config` (ou `-config`) dans les arguments de l'agent, relatif à son dossier ; sans lui, ou illisible : `meta`. `clientInfo.version` est la version de Sidekicks | | |
| 253 | +| `_org.mini-me/tools/list` | répond `{"tools": [...]}` | | |
| 254 | +| la méthode d'un outil | répond `{"content":[{"type":"text","text":"…"}],"isError":false}` ; un échec a `isError: true` et dit pourquoi | | |
| 255 | +| toute autre méthode `_…` | erreur JSON-RPC `-32601` (Method not found) | | |
| 256 | + | |
| 257 | +Avec `acp.clientTools.permissions: ask` (ou `auto` sans `yolo`), mm demande avant chaque appel : la carte de permission affiche `client: <nom>`. | |
| 258 | + | |
| 238 | 259 | ## Arrêt d'un agent |
| 239 | 260 | |
| 240 | 261 | L'entrée standard de l'agent est fermée ; après 5 s, l'agent et ses enfants reçoivent SIGTERM (le temps pour `scripts/agents.sh` de décharger le modèle) ; 3 s plus tard, SIGKILL. |
| @@ -235,6 +235,27 @@ Un fichier ouvert pour modification a `path, content, version` ; `version` ident | |||
| 235 | | `ChooseCompose()` | Le sélecteur de fichier natif, pour un fichier Compose. | | 235 | | `ChooseCompose()` | Le sélecteur de fichier natif, pour un fichier Compose. | |
| 236 | | `Reset(choice)` | La Danger zone : `settings` (configuration par défaut, préférences oubliées), `history` (celui de cette configuration), `allHistory` (celui de toutes les configurations) ou `everything`. Chaque élément réinitialisé est d'abord gardé en copie datée ; renvoie `{copies[]}`. L'historique est rouvert vide et les channels déclarés sont recréés ; puis `config:changed` est envoyé. | | 236 | | `Reset(choice)` | La Danger zone : `settings` (configuration par défaut, préférences oubliées), `history` (celui de cette configuration), `allHistory` (celui de toutes les configurations) ou `everything`. Chaque élément réinitialisé est d'abord gardé en copie datée ; renvoie `{copies[]}`. L'historique est rouvert vide et les channels déclarés sont recréés ; puis `config:changed` est envoyé. | |
| 237 | 237 | ||
| 238 | +## Outils proposés aux agents | ||
| 239 | + | ||
| 240 | +Ticket #90. Sidekicks propose trois outils à chaque agent, avec le protocole de mini-me (`org.mini-me/tools`, méthodes d'extension ACP). Un agent qui le connaît (`acp.clientTools` dans un fichier `mm`) les donne à son modèle sous le nom `client_<nom>` ; les autres les ignorent. | ||
| 241 | + | ||
| 242 | +| Outil (le modèle voit) | Méthode | Renvoie | | ||
| 243 | +| --- | --- | --- | | ||
| 244 | +| `memory_pressure` (`client_memory_pressure`) | `_com.rickub.sidekicks/system/memory` | `Memory pressure: warning (yellow). Used: 24.0 GB of 32.0 GB (75 %).`, comme l'affiche le panneau **Log** ([Surveiller la pression mémoire](../how-to/surveiller-la-pression-memoire.md)) ; `The memory cannot be measured on this computer.` là où elle ne se mesure pas | | ||
| 245 | +| `about_sidekicks` (`client_about_sidekicks`) | `_com.rickub.sidekicks/about` | la version de Sidekicks (`info.version` de `build/config.yml`, `dev` pour une version de développement), le système et l'architecture, ce qu'est Sidekicks, le nom de l'agent dans Sidekicks, la page des releases | | ||
| 246 | +| `current_channel` (`client_current_channel`) | `_com.rickub.sidekicks/channel/current` | `Channel #<nom>.`, sa description et ses membres (`you (@agent), @autre, and the user.`), ou `A direct conversation between the user and you (<agent>)…`. Le channel est celui dont l'agent tient la session (`_meta["org.mini-me/sessionId"]` de l'appel) ; une session d'aucun channel est une erreur | | ||
| 247 | + | ||
| 248 | +Aucun n'a de paramètre. Le protocole : | ||
| 249 | + | ||
| 250 | +| Étape | Ce que fait Sidekicks | | ||
| 251 | +| --- | --- | | ||
| 252 | +| `initialize` | `clientCapabilities._meta["org.mini-me/tools"]` contient la liste (`name, description, method`), ou `true` quand le fichier de l'agent indique `acp.clientTools.discovery: request`. Le fichier est celui qui suit `--config` (ou `-config`) dans les arguments de l'agent, relatif à son dossier ; sans lui, ou illisible : `meta`. `clientInfo.version` est la version de Sidekicks | | ||
| 253 | +| `_org.mini-me/tools/list` | répond `{"tools": [...]}` | | ||
| 254 | +| la méthode d'un outil | répond `{"content":[{"type":"text","text":"…"}],"isError":false}` ; un échec a `isError: true` et dit pourquoi | | ||
| 255 | +| toute autre méthode `_…` | erreur JSON-RPC `-32601` (Method not found) | | ||
| 256 | + | ||
| 257 | +Avec `acp.clientTools.permissions: ask` (ou `auto` sans `yolo`), mm demande avant chaque appel : la carte de permission affiche `client: <nom>`. | ||
| 258 | + | ||
| 238 | ## Arrêt d'un agent | 259 | ## Arrêt d'un agent |
| 239 | 260 | ||
| 240 | L'entrée standard de l'agent est fermée ; après 5 s, l'agent et ses enfants reçoivent SIGTERM (le temps pour `scripts/agents.sh` de décharger le modèle) ; 3 s plus tard, SIGKILL. | 261 | L'entrée standard de l'agent est fermée ; après 5 s, l'agent et ses enfants reçoivent SIGTERM (le temps pour `scripts/agents.sh` de décharger le modèle) ; 3 s plus tard, SIGKILL. |
modified
internal/acp/client.go +4 -3 | @@ -9,11 +9,12 @@ import ( | ||
| 9 | 9 | ) |
| 10 | 10 | |
| 11 | 11 | // client answers the requests an agent sends to Sidekicks: session updates |
| 12 | -// and permission requests go to the handler of their session; file and | |
| 13 | -// terminal access — which Sidekicks does not advertise (ADR 0001, decision 5) | |
| 14 | -// — is refused. | |
| 12 | +// and permission requests go to the handler of their session; the tools | |
| 13 | +// Sidekicks offers are answered (tools.go); file and terminal access — which | |
| 14 | +// Sidekicks does not advertise (ADR 0001, decision 5) — is refused. | |
| 15 | 15 | type client struct { |
| 16 | 16 | sessions *sessions |
| 17 | + tools []Tool | |
| 17 | 18 | } |
| 18 | 19 | |
| 19 | 20 | func (c *client) SessionUpdate(_ context.Context, notification sdk.SessionNotification) error { |
| @@ -9,11 +9,12 @@ import ( | |||
| 9 | ) | 9 | ) |
| 10 | 10 | ||
| 11 | // client answers the requests an agent sends to Sidekicks: session updates | 11 | // client answers the requests an agent sends to Sidekicks: session updates |
| 12 | -// and permission requests go to the handler of their session; file and | 12 | +// and permission requests go to the handler of their session; the tools |
| 13 | -// terminal access — which Sidekicks does not advertise (ADR 0001, decision 5) | 13 | +// Sidekicks offers are answered (tools.go); file and terminal access — which |
| 14 | -// — is refused. | 14 | +// Sidekicks does not advertise (ADR 0001, decision 5) — is refused. |
| 15 | type client struct { | 15 | type client struct { |
| 16 | sessions *sessions | 16 | sessions *sessions |
| 17 | + tools []Tool | ||
| 17 | } | 18 | } |
| 18 | 19 | ||
| 19 | func (c *client) SessionUpdate(_ context.Context, notification sdk.SessionNotification) error { | 20 | func (c *client) SessionUpdate(_ context.Context, notification sdk.SessionNotification) error { |
modified
internal/acp/conn.go +16 -3 | @@ -58,6 +58,12 @@ type Spec struct { | ||
| 58 | 58 | Env map[string]string |
| 59 | 59 | // Dir is the working directory of the process: the agent's workspace. |
| 60 | 60 | Dir string |
| 61 | + // Tools are offered to the agent (issue #90), the way ToolDiscovery | |
| 62 | + // says: DiscoveryMeta ("" too) or DiscoveryRequest. | |
| 63 | + Tools []Tool | |
| 64 | + ToolDiscovery string | |
| 65 | + // ClientVersion is Sidekicks' version, told in initialize. | |
| 66 | + ClientVersion string | |
| 61 | 67 | } |
| 62 | 68 | |
| 63 | 69 | // Options tunes Start. The zero value is usable. |
| @@ -153,7 +159,7 @@ func (c *Conn) launch(onStderr func(string)) error { | ||
| 153 | 159 | stderrDone := make(chan struct{}) |
| 154 | 160 | go c.readStderr(stderr, onStderr, stderrDone) |
| 155 | 161 | go c.wait(stderrDone) |
| 156 | - c.connection = sdk.NewClientSideConnection(&client{sessions: c.sessions}, stdin, stdout) | |
| 162 | + c.connection = sdk.NewClientSideConnection(&client{sessions: c.sessions, tools: c.spec.Tools}, stdin, stdout) | |
| 157 | 163 | // The SDK logs its own diagnostics ("connection closed"…); the agent's |
| 158 | 164 | // stderr already tells what matters. |
| 159 | 165 | c.connection.SetLogger(slog.New(slog.NewTextHandler(io.Discard, nil))) |
| @@ -201,8 +207,8 @@ func (c *Conn) initialize(ctx context.Context) error { | ||
| 201 | 207 | go func() { |
| 202 | 208 | response, err := c.connection.Initialize(ctx, sdk.InitializeRequest{ |
| 203 | 209 | ProtocolVersion: sdk.ProtocolVersion(ProtocolVersion), |
| 204 | - ClientCapabilities: sdk.ClientCapabilities{}, | |
| 205 | - ClientInfo: &sdk.Implementation{Name: "sidekicks", Version: "0.0.1"}, | |
| 210 | + ClientCapabilities: sdk.ClientCapabilities{Meta: toolsMeta(c.spec.Tools, c.spec.ToolDiscovery)}, | |
| 211 | + ClientInfo: &sdk.Implementation{Name: "sidekicks", Version: clientVersion(c.spec.ClientVersion)}, | |
| 206 | 212 | }) |
| 207 | 213 | answer <- result{response, err} |
| 208 | 214 | }() |
| @@ -226,6 +232,13 @@ func (c *Conn) initialize(ctx context.Context) error { | ||
| 226 | 232 | // handshakeError explains a failed initialize. An agent that exits right |
| 227 | 233 | // away makes the SDK report "peer disconnected before response": the exit |
| 228 | 234 | // status (with the stderr lines added by startError) says more. |
| 235 | +func clientVersion(version string) string { | |
| 236 | + if version == "" { | |
| 237 | + return "dev" | |
| 238 | + } | |
| 239 | + return version | |
| 240 | +} | |
| 241 | + | |
| 229 | 242 | func (c *Conn) handshakeError(err error) error { |
| 230 | 243 | select { |
| 231 | 244 | case <-c.done: |
| @@ -58,6 +58,12 @@ type Spec struct { | |||
| 58 | Env map[string]string | 58 | Env map[string]string |
| 59 | // Dir is the working directory of the process: the agent's workspace. | 59 | // Dir is the working directory of the process: the agent's workspace. |
| 60 | Dir string | 60 | Dir string |
| 61 | + // Tools are offered to the agent (issue #90), the way ToolDiscovery | ||
| 62 | + // says: DiscoveryMeta ("" too) or DiscoveryRequest. | ||
| 63 | + Tools []Tool | ||
| 64 | + ToolDiscovery string | ||
| 65 | + // ClientVersion is Sidekicks' version, told in initialize. | ||
| 66 | + ClientVersion string | ||
| 61 | } | 67 | } |
| 62 | 68 | ||
| 63 | // Options tunes Start. The zero value is usable. | 69 | // Options tunes Start. The zero value is usable. |
| @@ -153,7 +159,7 @@ func (c *Conn) launch(onStderr func(string)) error { | |||
| 153 | stderrDone := make(chan struct{}) | 159 | stderrDone := make(chan struct{}) |
| 154 | go c.readStderr(stderr, onStderr, stderrDone) | 160 | go c.readStderr(stderr, onStderr, stderrDone) |
| 155 | go c.wait(stderrDone) | 161 | go c.wait(stderrDone) |
| 156 | - c.connection = sdk.NewClientSideConnection(&client{sessions: c.sessions}, stdin, stdout) | 162 | + c.connection = sdk.NewClientSideConnection(&client{sessions: c.sessions, tools: c.spec.Tools}, stdin, stdout) |
| 157 | // The SDK logs its own diagnostics ("connection closed"…); the agent's | 163 | // The SDK logs its own diagnostics ("connection closed"…); the agent's |
| 158 | // stderr already tells what matters. | 164 | // stderr already tells what matters. |
| 159 | c.connection.SetLogger(slog.New(slog.NewTextHandler(io.Discard, nil))) | 165 | c.connection.SetLogger(slog.New(slog.NewTextHandler(io.Discard, nil))) |
| @@ -201,8 +207,8 @@ func (c *Conn) initialize(ctx context.Context) error { | |||
| 201 | go func() { | 207 | go func() { |
| 202 | response, err := c.connection.Initialize(ctx, sdk.InitializeRequest{ | 208 | response, err := c.connection.Initialize(ctx, sdk.InitializeRequest{ |
| 203 | ProtocolVersion: sdk.ProtocolVersion(ProtocolVersion), | 209 | ProtocolVersion: sdk.ProtocolVersion(ProtocolVersion), |
| 204 | - ClientCapabilities: sdk.ClientCapabilities{}, | 210 | + ClientCapabilities: sdk.ClientCapabilities{Meta: toolsMeta(c.spec.Tools, c.spec.ToolDiscovery)}, |
| 205 | - ClientInfo: &sdk.Implementation{Name: "sidekicks", Version: "0.0.1"}, | 211 | + ClientInfo: &sdk.Implementation{Name: "sidekicks", Version: clientVersion(c.spec.ClientVersion)}, |
| 206 | }) | 212 | }) |
| 207 | answer <- result{response, err} | 213 | answer <- result{response, err} |
| 208 | }() | 214 | }() |
| @@ -226,6 +232,13 @@ func (c *Conn) initialize(ctx context.Context) error { | |||
| 226 | // handshakeError explains a failed initialize. An agent that exits right | 232 | // handshakeError explains a failed initialize. An agent that exits right |
| 227 | // away makes the SDK report "peer disconnected before response": the exit | 233 | // away makes the SDK report "peer disconnected before response": the exit |
| 228 | // status (with the stderr lines added by startError) says more. | 234 | // status (with the stderr lines added by startError) says more. |
| 235 | +func clientVersion(version string) string { | ||
| 236 | + if version == "" { | ||
| 237 | + return "dev" | ||
| 238 | + } | ||
| 239 | + return version | ||
| 240 | +} | ||
| 241 | + | ||
| 229 | func (c *Conn) handshakeError(err error) error { | 242 | func (c *Conn) handshakeError(err error) error { |
| 230 | select { | 243 | select { |
| 231 | case <-c.done: | 244 | case <-c.done: |
modified
internal/acp/conn_test.go +19 -1 | @@ -4,6 +4,7 @@ package acp_test | ||
| 4 | 4 | |
| 5 | 5 | import ( |
| 6 | 6 | "context" |
| 7 | + "encoding/json" | |
| 7 | 8 | "errors" |
| 8 | 9 | "fmt" |
| 9 | 10 | "os" |
| @@ -242,9 +243,12 @@ func runFakeAgent(mode string) int { | ||
| 242 | 243 | type fakeAgent struct { |
| 243 | 244 | mode string |
| 244 | 245 | conn *sdk.AgentSideConnection |
| 246 | + // client is what Sidekicks said about itself in initialize. | |
| 247 | + client sdk.InitializeRequest | |
| 245 | 248 | } |
| 246 | 249 | |
| 247 | -func (a *fakeAgent) Initialize(context.Context, sdk.InitializeRequest) (sdk.InitializeResponse, error) { | |
| 250 | +func (a *fakeAgent) Initialize(_ context.Context, request sdk.InitializeRequest) (sdk.InitializeResponse, error) { | |
| 251 | + a.client = request | |
| 248 | 252 | version := 1 |
| 249 | 253 | if a.mode == "version-2" { |
| 250 | 254 | version = 2 |
| @@ -322,6 +326,20 @@ func (a *fakeAgent) Prompt(ctx context.Context, request sdk.PromptRequest) (sdk. | ||
| 322 | 326 | send(sdk.UpdateToolCall("call_1", sdk.WithUpdateStatus(sdk.ToolCallStatusCompleted), |
| 323 | 327 | sdk.WithUpdateContent([]sdk.ToolCallContent{sdk.ToolContent(sdk.TextBlock("written")), sdk.ToolDiffContent("/w/notes.txt", "hello")}))) |
| 324 | 328 | return sdk.PromptResponse{StopReason: sdk.StopReasonEndTurn}, nil |
| 329 | + case "client-tools": | |
| 330 | + // Like mm with acp.clientTools: report what initialize offered, ask | |
| 331 | + // for the list, call a tool, then a method nobody answers. | |
| 332 | + meta, _ := json.Marshal(a.client.ClientCapabilities.Meta) | |
| 333 | + send(sdk.UpdateAgentMessageText("meta=" + string(meta) + " version=" + a.client.ClientInfo.Version + "\n")) | |
| 334 | + list, err := a.conn.CallExtension(ctx, "_org.mini-me/tools/list", map[string]any{"sessionId": "s-1", "cwd": "/w"}) | |
| 335 | + send(sdk.UpdateAgentMessageText(fmt.Sprintf("list=%s %v\n", list, err))) | |
| 336 | + call, err := a.conn.CallExtension(ctx, "_test/echo", map[string]any{"word": "hi", "_meta": map[string]any{"org.mini-me/sessionId": "s-1"}}) | |
| 337 | + send(sdk.UpdateAgentMessageText(fmt.Sprintf("call=%s %v\n", call, err))) | |
| 338 | + failing, err := a.conn.CallExtension(ctx, "_test/fail", nil) | |
| 339 | + send(sdk.UpdateAgentMessageText(fmt.Sprintf("fail=%s %v\n", failing, err))) | |
| 340 | + _, err = a.conn.CallExtension(ctx, "_test/missing", nil) | |
| 341 | + send(sdk.UpdateAgentMessageText(fmt.Sprintf("missing=%v", err))) | |
| 342 | + return sdk.PromptResponse{StopReason: sdk.StopReasonEndTurn}, nil | |
| 325 | 343 | case "long": |
| 326 | 344 | for { |
| 327 | 345 | select { |
| @@ -4,6 +4,7 @@ package acp_test | |||
| 4 | 4 | ||
| 5 | import ( | 5 | import ( |
| 6 | "context" | 6 | "context" |
| 7 | + "encoding/json" | ||
| 7 | "errors" | 8 | "errors" |
| 8 | "fmt" | 9 | "fmt" |
| 9 | "os" | 10 | "os" |
| @@ -242,9 +243,12 @@ func runFakeAgent(mode string) int { | |||
| 242 | type fakeAgent struct { | 243 | type fakeAgent struct { |
| 243 | mode string | 244 | mode string |
| 244 | conn *sdk.AgentSideConnection | 245 | conn *sdk.AgentSideConnection |
| 246 | + // client is what Sidekicks said about itself in initialize. | ||
| 247 | + client sdk.InitializeRequest | ||
| 245 | } | 248 | } |
| 246 | 249 | ||
| 247 | -func (a *fakeAgent) Initialize(context.Context, sdk.InitializeRequest) (sdk.InitializeResponse, error) { | 250 | +func (a *fakeAgent) Initialize(_ context.Context, request sdk.InitializeRequest) (sdk.InitializeResponse, error) { |
| 251 | + a.client = request | ||
| 248 | version := 1 | 252 | version := 1 |
| 249 | if a.mode == "version-2" { | 253 | if a.mode == "version-2" { |
| 250 | version = 2 | 254 | version = 2 |
| @@ -322,6 +326,20 @@ func (a *fakeAgent) Prompt(ctx context.Context, request sdk.PromptRequest) (sdk. | |||
| 322 | send(sdk.UpdateToolCall("call_1", sdk.WithUpdateStatus(sdk.ToolCallStatusCompleted), | 326 | send(sdk.UpdateToolCall("call_1", sdk.WithUpdateStatus(sdk.ToolCallStatusCompleted), |
| 323 | sdk.WithUpdateContent([]sdk.ToolCallContent{sdk.ToolContent(sdk.TextBlock("written")), sdk.ToolDiffContent("/w/notes.txt", "hello")}))) | 327 | sdk.WithUpdateContent([]sdk.ToolCallContent{sdk.ToolContent(sdk.TextBlock("written")), sdk.ToolDiffContent("/w/notes.txt", "hello")}))) |
| 324 | return sdk.PromptResponse{StopReason: sdk.StopReasonEndTurn}, nil | 328 | return sdk.PromptResponse{StopReason: sdk.StopReasonEndTurn}, nil |
| 329 | + case "client-tools": | ||
| 330 | + // Like mm with acp.clientTools: report what initialize offered, ask | ||
| 331 | + // for the list, call a tool, then a method nobody answers. | ||
| 332 | + meta, _ := json.Marshal(a.client.ClientCapabilities.Meta) | ||
| 333 | + send(sdk.UpdateAgentMessageText("meta=" + string(meta) + " version=" + a.client.ClientInfo.Version + "\n")) | ||
| 334 | + list, err := a.conn.CallExtension(ctx, "_org.mini-me/tools/list", map[string]any{"sessionId": "s-1", "cwd": "/w"}) | ||
| 335 | + send(sdk.UpdateAgentMessageText(fmt.Sprintf("list=%s %v\n", list, err))) | ||
| 336 | + call, err := a.conn.CallExtension(ctx, "_test/echo", map[string]any{"word": "hi", "_meta": map[string]any{"org.mini-me/sessionId": "s-1"}}) | ||
| 337 | + send(sdk.UpdateAgentMessageText(fmt.Sprintf("call=%s %v\n", call, err))) | ||
| 338 | + failing, err := a.conn.CallExtension(ctx, "_test/fail", nil) | ||
| 339 | + send(sdk.UpdateAgentMessageText(fmt.Sprintf("fail=%s %v\n", failing, err))) | ||
| 340 | + _, err = a.conn.CallExtension(ctx, "_test/missing", nil) | ||
| 341 | + send(sdk.UpdateAgentMessageText(fmt.Sprintf("missing=%v", err))) | ||
| 342 | + return sdk.PromptResponse{StopReason: sdk.StopReasonEndTurn}, nil | ||
| 325 | case "long": | 343 | case "long": |
| 326 | for { | 344 | for { |
| 327 | select { | 345 | select { |
added
internal/acp/tools.go +110 -0 | new file mode 100644 | ||
| @@ -0,0 +1,110 @@ | ||
| 1 | +// Copyright (c) 2026 Philippe Charrière — Sidekicks Source-Available License 1.0, see LICENSE | |
| 2 | + | |
| 3 | +package acp | |
| 4 | + | |
| 5 | +import ( | |
| 6 | + "context" | |
| 7 | + "encoding/json" | |
| 8 | + | |
| 9 | + sdk "github.com/coder/acp-go-sdk" | |
| 10 | +) | |
| 11 | + | |
| 12 | +// The tools Sidekicks offers an agent (issue #90), with the protocol of | |
| 13 | +// mini-me ("org.mini-me/tools"): ACP extension methods, whose names start | |
| 14 | +// with "_", that the agent calls when its model calls client_<name>. | |
| 15 | +// | |
| 16 | +// Discovery "meta" puts the list in the _meta of the initialize request; | |
| 17 | +// "request" announces the capability only (true) and answers the agent's | |
| 18 | +// _org.mini-me/tools/list when it opens a session. A call carries the | |
| 19 | +// model's arguments at the top of its params, and the session in | |
| 20 | +// _meta["org.mini-me/sessionId"]; the answer has the shape of an MCP | |
| 21 | +// tools/call result. | |
| 22 | +const ( | |
| 23 | + // ToolsMetaKey is the key of clientCapabilities._meta that offers the tools. | |
| 24 | + ToolsMetaKey = "org.mini-me/tools" | |
| 25 | + // ToolsListMethod is the request with which the agent asks for the tools. | |
| 26 | + ToolsListMethod = "_org.mini-me/tools/list" | |
| 27 | + // SessionMetaKey is the key of a call's params._meta that names its session. | |
| 28 | + SessionMetaKey = "org.mini-me/sessionId" | |
| 29 | + // DiscoveryMeta and DiscoveryRequest are the two ways to offer the tools | |
| 30 | + // (acp.clientTools.discovery in a mini-me agent's file). | |
| 31 | + DiscoveryMeta = "meta" | |
| 32 | + DiscoveryRequest = "request" | |
| 33 | +) | |
| 34 | + | |
| 35 | +// Tool is a tool Sidekicks offers the agent. The model sees it as | |
| 36 | +// client_<Name>; the agent calls Method, which starts with "_". | |
| 37 | +type Tool struct { | |
| 38 | + Name string `json:"name"` | |
| 39 | + Description string `json:"description,omitempty"` | |
| 40 | + Method string `json:"method"` | |
| 41 | + // InputSchema is the JSON schema of the arguments; nil: no parameter. | |
| 42 | + InputSchema map[string]any `json:"inputSchema,omitempty"` | |
| 43 | + // Call answers a call: sessionID is the session it belongs to ("" when | |
| 44 | + // the agent does not say), arguments are the model's. An error is given | |
| 45 | + // to the model as a failed call. | |
| 46 | + Call func(ctx context.Context, sessionID string, arguments map[string]any) (string, error) `json:"-"` | |
| 47 | +} | |
| 48 | + | |
| 49 | +// toolsMeta is the _meta of the initialize request that offers tools with | |
| 50 | +// discovery; nil without tools. | |
| 51 | +func toolsMeta(tools []Tool, discovery string) map[string]any { | |
| 52 | + if len(tools) == 0 { | |
| 53 | + return nil | |
| 54 | + } | |
| 55 | + if discovery == DiscoveryRequest { | |
| 56 | + return map[string]any{ToolsMetaKey: true} | |
| 57 | + } | |
| 58 | + return map[string]any{ToolsMetaKey: tools} | |
| 59 | +} | |
| 60 | + | |
| 61 | +// toolText is one block of a tool result. | |
| 62 | +type toolText struct { | |
| 63 | + Type string `json:"type"` | |
| 64 | + Text string `json:"text"` | |
| 65 | +} | |
| 66 | + | |
| 67 | +// toolResult is the answer to a call: an MCP tools/call result. | |
| 68 | +type toolResult struct { | |
| 69 | + Content []toolText `json:"content"` | |
| 70 | + IsError bool `json:"isError"` | |
| 71 | +} | |
| 72 | + | |
| 73 | +// HandleExtensionMethod answers the agent's extension requests: the list of | |
| 74 | +// tools, and the calls of each tool. Any other method is not found. | |
| 75 | +func (c *client) HandleExtensionMethod(ctx context.Context, method string, params json.RawMessage) (any, error) { | |
| 76 | + if method == ToolsListMethod && len(c.tools) > 0 { | |
| 77 | + return map[string]any{"tools": c.tools}, nil | |
| 78 | + } | |
| 79 | + for _, tool := range c.tools { | |
| 80 | + if tool.Method == method { | |
| 81 | + return callTool(ctx, tool, params), nil | |
| 82 | + } | |
| 83 | + } | |
| 84 | + return nil, sdk.NewMethodNotFound(method) | |
| 85 | +} | |
| 86 | + | |
| 87 | +// callTool runs tool with the arguments of params, apart from _meta, which | |
| 88 | +// names the session. | |
| 89 | +func callTool(ctx context.Context, tool Tool, params json.RawMessage) toolResult { | |
| 90 | + arguments := map[string]any{} | |
| 91 | + if len(params) > 0 && string(params) != "null" { | |
| 92 | + if err := json.Unmarshal(params, &arguments); err != nil { | |
| 93 | + return failed("the arguments are not a JSON object: " + err.Error()) | |
| 94 | + } | |
| 95 | + } | |
| 96 | + sessionID := "" | |
| 97 | + if meta, ok := arguments["_meta"].(map[string]any); ok { | |
| 98 | + sessionID, _ = meta[SessionMetaKey].(string) | |
| 99 | + } | |
| 100 | + delete(arguments, "_meta") | |
| 101 | + text, err := tool.Call(ctx, sessionID, arguments) | |
| 102 | + if err != nil { | |
| 103 | + return failed(err.Error()) | |
| 104 | + } | |
| 105 | + return toolResult{Content: []toolText{{Type: "text", Text: text}}} | |
| 106 | +} | |
| 107 | + | |
| 108 | +func failed(text string) toolResult { | |
| 109 | + return toolResult{Content: []toolText{{Type: "text", Text: text}}, IsError: true} | |
| 110 | +} | |
| new file mode 100644 | |||
| @@ -0,0 +1,110 @@ | |||
| 1 | +// Copyright (c) 2026 Philippe Charrière — Sidekicks Source-Available License 1.0, see LICENSE | ||
| 2 | + | ||
| 3 | +package acp | ||
| 4 | + | ||
| 5 | +import ( | ||
| 6 | + "context" | ||
| 7 | + "encoding/json" | ||
| 8 | + | ||
| 9 | + sdk "github.com/coder/acp-go-sdk" | ||
| 10 | +) | ||
| 11 | + | ||
| 12 | +// The tools Sidekicks offers an agent (issue #90), with the protocol of | ||
| 13 | +// mini-me ("org.mini-me/tools"): ACP extension methods, whose names start | ||
| 14 | +// with "_", that the agent calls when its model calls client_<name>. | ||
| 15 | +// | ||
| 16 | +// Discovery "meta" puts the list in the _meta of the initialize request; | ||
| 17 | +// "request" announces the capability only (true) and answers the agent's | ||
| 18 | +// _org.mini-me/tools/list when it opens a session. A call carries the | ||
| 19 | +// model's arguments at the top of its params, and the session in | ||
| 20 | +// _meta["org.mini-me/sessionId"]; the answer has the shape of an MCP | ||
| 21 | +// tools/call result. | ||
| 22 | +const ( | ||
| 23 | + // ToolsMetaKey is the key of clientCapabilities._meta that offers the tools. | ||
| 24 | + ToolsMetaKey = "org.mini-me/tools" | ||
| 25 | + // ToolsListMethod is the request with which the agent asks for the tools. | ||
| 26 | + ToolsListMethod = "_org.mini-me/tools/list" | ||
| 27 | + // SessionMetaKey is the key of a call's params._meta that names its session. | ||
| 28 | + SessionMetaKey = "org.mini-me/sessionId" | ||
| 29 | + // DiscoveryMeta and DiscoveryRequest are the two ways to offer the tools | ||
| 30 | + // (acp.clientTools.discovery in a mini-me agent's file). | ||
| 31 | + DiscoveryMeta = "meta" | ||
| 32 | + DiscoveryRequest = "request" | ||
| 33 | +) | ||
| 34 | + | ||
| 35 | +// Tool is a tool Sidekicks offers the agent. The model sees it as | ||
| 36 | +// client_<Name>; the agent calls Method, which starts with "_". | ||
| 37 | +type Tool struct { | ||
| 38 | + Name string `json:"name"` | ||
| 39 | + Description string `json:"description,omitempty"` | ||
| 40 | + Method string `json:"method"` | ||
| 41 | + // InputSchema is the JSON schema of the arguments; nil: no parameter. | ||
| 42 | + InputSchema map[string]any `json:"inputSchema,omitempty"` | ||
| 43 | + // Call answers a call: sessionID is the session it belongs to ("" when | ||
| 44 | + // the agent does not say), arguments are the model's. An error is given | ||
| 45 | + // to the model as a failed call. | ||
| 46 | + Call func(ctx context.Context, sessionID string, arguments map[string]any) (string, error) `json:"-"` | ||
| 47 | +} | ||
| 48 | + | ||
| 49 | +// toolsMeta is the _meta of the initialize request that offers tools with | ||
| 50 | +// discovery; nil without tools. | ||
| 51 | +func toolsMeta(tools []Tool, discovery string) map[string]any { | ||
| 52 | + if len(tools) == 0 { | ||
| 53 | + return nil | ||
| 54 | + } | ||
| 55 | + if discovery == DiscoveryRequest { | ||
| 56 | + return map[string]any{ToolsMetaKey: true} | ||
| 57 | + } | ||
| 58 | + return map[string]any{ToolsMetaKey: tools} | ||
| 59 | +} | ||
| 60 | + | ||
| 61 | +// toolText is one block of a tool result. | ||
| 62 | +type toolText struct { | ||
| 63 | + Type string `json:"type"` | ||
| 64 | + Text string `json:"text"` | ||
| 65 | +} | ||
| 66 | + | ||
| 67 | +// toolResult is the answer to a call: an MCP tools/call result. | ||
| 68 | +type toolResult struct { | ||
| 69 | + Content []toolText `json:"content"` | ||
| 70 | + IsError bool `json:"isError"` | ||
| 71 | +} | ||
| 72 | + | ||
| 73 | +// HandleExtensionMethod answers the agent's extension requests: the list of | ||
| 74 | +// tools, and the calls of each tool. Any other method is not found. | ||
| 75 | +func (c *client) HandleExtensionMethod(ctx context.Context, method string, params json.RawMessage) (any, error) { | ||
| 76 | + if method == ToolsListMethod && len(c.tools) > 0 { | ||
| 77 | + return map[string]any{"tools": c.tools}, nil | ||
| 78 | + } | ||
| 79 | + for _, tool := range c.tools { | ||
| 80 | + if tool.Method == method { | ||
| 81 | + return callTool(ctx, tool, params), nil | ||
| 82 | + } | ||
| 83 | + } | ||
| 84 | + return nil, sdk.NewMethodNotFound(method) | ||
| 85 | +} | ||
| 86 | + | ||
| 87 | +// callTool runs tool with the arguments of params, apart from _meta, which | ||
| 88 | +// names the session. | ||
| 89 | +func callTool(ctx context.Context, tool Tool, params json.RawMessage) toolResult { | ||
| 90 | + arguments := map[string]any{} | ||
| 91 | + if len(params) > 0 && string(params) != "null" { | ||
| 92 | + if err := json.Unmarshal(params, &arguments); err != nil { | ||
| 93 | + return failed("the arguments are not a JSON object: " + err.Error()) | ||
| 94 | + } | ||
| 95 | + } | ||
| 96 | + sessionID := "" | ||
| 97 | + if meta, ok := arguments["_meta"].(map[string]any); ok { | ||
| 98 | + sessionID, _ = meta[SessionMetaKey].(string) | ||
| 99 | + } | ||
| 100 | + delete(arguments, "_meta") | ||
| 101 | + text, err := tool.Call(ctx, sessionID, arguments) | ||
| 102 | + if err != nil { | ||
| 103 | + return failed(err.Error()) | ||
| 104 | + } | ||
| 105 | + return toolResult{Content: []toolText{{Type: "text", Text: text}}} | ||
| 106 | +} | ||
| 107 | + | ||
| 108 | +func failed(text string) toolResult { | ||
| 109 | + return toolResult{Content: []toolText{{Type: "text", Text: text}}, IsError: true} | ||
| 110 | +} | ||
added
internal/acp/tools_test.go +111 -0 | new file mode 100644 | ||
| @@ -0,0 +1,111 @@ | ||
| 1 | +// Copyright (c) 2026 Philippe Charrière — Sidekicks Source-Available License 1.0, see LICENSE | |
| 2 | + | |
| 3 | +package acp_test | |
| 4 | + | |
| 5 | +import ( | |
| 6 | + "context" | |
| 7 | + "errors" | |
| 8 | + "fmt" | |
| 9 | + "strings" | |
| 10 | + "testing" | |
| 11 | + | |
| 12 | + "git.rickub.com/bots-garden/sidekicks/internal/acp" | |
| 13 | +) | |
| 14 | + | |
| 15 | +// Issue #90: Sidekicks offers tools to the agent with the protocol of mini-me. | |
| 16 | + | |
| 17 | +func testTools() []acp.Tool { | |
| 18 | + return []acp.Tool{ | |
| 19 | + {Name: "echo", Description: "Say the word back.", Method: "_test/echo", | |
| 20 | + InputSchema: map[string]any{"type": "object", "properties": map[string]any{"word": map[string]any{"type": "string"}}}, | |
| 21 | + Call: func(_ context.Context, sessionID string, arguments map[string]any) (string, error) { | |
| 22 | + return fmt.Sprintf("%v in %s (%d argument)", arguments["word"], sessionID, len(arguments)), nil | |
| 23 | + }}, | |
| 24 | + {Name: "fail", Method: "_test/fail", Call: func(context.Context, string, map[string]any) (string, error) { | |
| 25 | + return "", errors.New("no memory status here") | |
| 26 | + }}, | |
| 27 | + } | |
| 28 | +} | |
| 29 | + | |
| 30 | +// toolsTurn has the fake agent call the tools offered with discovery and | |
| 31 | +// returns what it reports, one line per step. | |
| 32 | +func toolsTurn(t *testing.T, discovery string) map[string]string { | |
| 33 | + t.Helper() | |
| 34 | + spec := fakeSpec(t, "ready") | |
| 35 | + spec.Tools, spec.ToolDiscovery, spec.ClientVersion = testTools(), discovery, "1.4.0" | |
| 36 | + conn, err := acp.Start(context.Background(), spec, acp.Options{}) | |
| 37 | + if err != nil { | |
| 38 | + t.Fatal(err) | |
| 39 | + } | |
| 40 | + t.Cleanup(func() { _ = conn.Close(context.Background()) }) | |
| 41 | + handler := &recordingHandler{} | |
| 42 | + id, err := conn.NewSession(context.Background(), t.TempDir(), handler) | |
| 43 | + if err != nil { | |
| 44 | + t.Fatal(err) | |
| 45 | + } | |
| 46 | + if _, err := conn.Prompt(context.Background(), id, "client-tools"); err != nil { | |
| 47 | + t.Fatal(err) | |
| 48 | + } | |
| 49 | + var text strings.Builder | |
| 50 | + for _, update := range handler.ofKind(acp.UpdateMessage) { | |
| 51 | + text.WriteString(update.Text) | |
| 52 | + } | |
| 53 | + steps := map[string]string{} | |
| 54 | + for _, line := range strings.Split(text.String(), "\n") { | |
| 55 | + key, value, _ := strings.Cut(line, "=") | |
| 56 | + steps[key] = value | |
| 57 | + } | |
| 58 | + return steps | |
| 59 | +} | |
| 60 | + | |
| 61 | +func TestTheToolsAreOfferedInInitialize(t *testing.T) { | |
| 62 | + steps := toolsTurn(t, acp.DiscoveryMeta) | |
| 63 | + for _, want := range []string{`"org.mini-me/tools":[`, `"name":"echo"`, `"method":"_test/echo"`, `"description":"Say the word back."`, `"inputSchema":{`, `{"method":"_test/fail","name":"fail"}`, `version=1.4.0`} { | |
| 64 | + if !strings.Contains(steps["meta"], want) { | |
| 65 | + t.Fatalf("initialize lacks %s: %s", want, steps["meta"]) | |
| 66 | + } | |
| 67 | + } | |
| 68 | +} | |
| 69 | + | |
| 70 | +func TestDiscoveryRequestAnnouncesTheCapabilityAndAnswersTheList(t *testing.T) { | |
| 71 | + steps := toolsTurn(t, acp.DiscoveryRequest) | |
| 72 | + if !strings.HasPrefix(steps["meta"], `{"org.mini-me/tools":true}`) { | |
| 73 | + t.Fatalf("only the capability: %s", steps["meta"]) | |
| 74 | + } | |
| 75 | + if !strings.HasPrefix(steps["list"], `{"tools":[{"name":"echo"`) || !strings.HasSuffix(steps["list"], "<nil>") { | |
| 76 | + t.Fatalf("list: %s", steps["list"]) | |
| 77 | + } | |
| 78 | +} | |
| 79 | + | |
| 80 | +func TestAToolCallGetsItsArgumentsAndSession(t *testing.T) { | |
| 81 | + steps := toolsTurn(t, acp.DiscoveryMeta) | |
| 82 | + if steps["call"] != `{"content":[{"type":"text","text":"hi in s-1 (1 argument)"}],"isError":false} <nil>` { | |
| 83 | + t.Fatalf("call: %s", steps["call"]) | |
| 84 | + } | |
| 85 | + if steps["fail"] != `{"content":[{"type":"text","text":"no memory status here"}],"isError":true} <nil>` { | |
| 86 | + t.Fatalf("a failing tool is a failed call: %s", steps["fail"]) | |
| 87 | + } | |
| 88 | + if !strings.Contains(steps["missing"], "Method not found") { | |
| 89 | + t.Fatalf("an unknown method is not found: %s", steps["missing"]) | |
| 90 | + } | |
| 91 | +} | |
| 92 | + | |
| 93 | +func TestAnAgentWithoutToolsIsOfferedNothing(t *testing.T) { | |
| 94 | + conn, err := acp.Start(context.Background(), fakeSpec(t, "ready"), acp.Options{}) | |
| 95 | + if err != nil { | |
| 96 | + t.Fatal(err) | |
| 97 | + } | |
| 98 | + t.Cleanup(func() { _ = conn.Close(context.Background()) }) | |
| 99 | + handler := &recordingHandler{} | |
| 100 | + id, _ := conn.NewSession(context.Background(), t.TempDir(), handler) | |
| 101 | + if _, err := conn.Prompt(context.Background(), id, "client-tools"); err != nil { | |
| 102 | + t.Fatal(err) | |
| 103 | + } | |
| 104 | + var text strings.Builder | |
| 105 | + for _, update := range handler.ofKind(acp.UpdateMessage) { | |
| 106 | + text.WriteString(update.Text) | |
| 107 | + } | |
| 108 | + if !strings.HasPrefix(text.String(), "meta=null version=dev") || !strings.Contains(text.String(), `list=null {"code":-32601`) { | |
| 109 | + t.Fatalf("no tools, no list: %s", text.String()) | |
| 110 | + } | |
| 111 | +} | |
| new file mode 100644 | |||
| @@ -0,0 +1,111 @@ | |||
| 1 | +// Copyright (c) 2026 Philippe Charrière — Sidekicks Source-Available License 1.0, see LICENSE | ||
| 2 | + | ||
| 3 | +package acp_test | ||
| 4 | + | ||
| 5 | +import ( | ||
| 6 | + "context" | ||
| 7 | + "errors" | ||
| 8 | + "fmt" | ||
| 9 | + "strings" | ||
| 10 | + "testing" | ||
| 11 | + | ||
| 12 | + "git.rickub.com/bots-garden/sidekicks/internal/acp" | ||
| 13 | +) | ||
| 14 | + | ||
| 15 | +// Issue #90: Sidekicks offers tools to the agent with the protocol of mini-me. | ||
| 16 | + | ||
| 17 | +func testTools() []acp.Tool { | ||
| 18 | + return []acp.Tool{ | ||
| 19 | + {Name: "echo", Description: "Say the word back.", Method: "_test/echo", | ||
| 20 | + InputSchema: map[string]any{"type": "object", "properties": map[string]any{"word": map[string]any{"type": "string"}}}, | ||
| 21 | + Call: func(_ context.Context, sessionID string, arguments map[string]any) (string, error) { | ||
| 22 | + return fmt.Sprintf("%v in %s (%d argument)", arguments["word"], sessionID, len(arguments)), nil | ||
| 23 | + }}, | ||
| 24 | + {Name: "fail", Method: "_test/fail", Call: func(context.Context, string, map[string]any) (string, error) { | ||
| 25 | + return "", errors.New("no memory status here") | ||
| 26 | + }}, | ||
| 27 | + } | ||
| 28 | +} | ||
| 29 | + | ||
| 30 | +// toolsTurn has the fake agent call the tools offered with discovery and | ||
| 31 | +// returns what it reports, one line per step. | ||
| 32 | +func toolsTurn(t *testing.T, discovery string) map[string]string { | ||
| 33 | + t.Helper() | ||
| 34 | + spec := fakeSpec(t, "ready") | ||
| 35 | + spec.Tools, spec.ToolDiscovery, spec.ClientVersion = testTools(), discovery, "1.4.0" | ||
| 36 | + conn, err := acp.Start(context.Background(), spec, acp.Options{}) | ||
| 37 | + if err != nil { | ||
| 38 | + t.Fatal(err) | ||
| 39 | + } | ||
| 40 | + t.Cleanup(func() { _ = conn.Close(context.Background()) }) | ||
| 41 | + handler := &recordingHandler{} | ||
| 42 | + id, err := conn.NewSession(context.Background(), t.TempDir(), handler) | ||
| 43 | + if err != nil { | ||
| 44 | + t.Fatal(err) | ||
| 45 | + } | ||
| 46 | + if _, err := conn.Prompt(context.Background(), id, "client-tools"); err != nil { | ||
| 47 | + t.Fatal(err) | ||
| 48 | + } | ||
| 49 | + var text strings.Builder | ||
| 50 | + for _, update := range handler.ofKind(acp.UpdateMessage) { | ||
| 51 | + text.WriteString(update.Text) | ||
| 52 | + } | ||
| 53 | + steps := map[string]string{} | ||
| 54 | + for _, line := range strings.Split(text.String(), "\n") { | ||
| 55 | + key, value, _ := strings.Cut(line, "=") | ||
| 56 | + steps[key] = value | ||
| 57 | + } | ||
| 58 | + return steps | ||
| 59 | +} | ||
| 60 | + | ||
| 61 | +func TestTheToolsAreOfferedInInitialize(t *testing.T) { | ||
| 62 | + steps := toolsTurn(t, acp.DiscoveryMeta) | ||
| 63 | + for _, want := range []string{`"org.mini-me/tools":[`, `"name":"echo"`, `"method":"_test/echo"`, `"description":"Say the word back."`, `"inputSchema":{`, `{"method":"_test/fail","name":"fail"}`, `version=1.4.0`} { | ||
| 64 | + if !strings.Contains(steps["meta"], want) { | ||
| 65 | + t.Fatalf("initialize lacks %s: %s", want, steps["meta"]) | ||
| 66 | + } | ||
| 67 | + } | ||
| 68 | +} | ||
| 69 | + | ||
| 70 | +func TestDiscoveryRequestAnnouncesTheCapabilityAndAnswersTheList(t *testing.T) { | ||
| 71 | + steps := toolsTurn(t, acp.DiscoveryRequest) | ||
| 72 | + if !strings.HasPrefix(steps["meta"], `{"org.mini-me/tools":true}`) { | ||
| 73 | + t.Fatalf("only the capability: %s", steps["meta"]) | ||
| 74 | + } | ||
| 75 | + if !strings.HasPrefix(steps["list"], `{"tools":[{"name":"echo"`) || !strings.HasSuffix(steps["list"], "<nil>") { | ||
| 76 | + t.Fatalf("list: %s", steps["list"]) | ||
| 77 | + } | ||
| 78 | +} | ||
| 79 | + | ||
| 80 | +func TestAToolCallGetsItsArgumentsAndSession(t *testing.T) { | ||
| 81 | + steps := toolsTurn(t, acp.DiscoveryMeta) | ||
| 82 | + if steps["call"] != `{"content":[{"type":"text","text":"hi in s-1 (1 argument)"}],"isError":false} <nil>` { | ||
| 83 | + t.Fatalf("call: %s", steps["call"]) | ||
| 84 | + } | ||
| 85 | + if steps["fail"] != `{"content":[{"type":"text","text":"no memory status here"}],"isError":true} <nil>` { | ||
| 86 | + t.Fatalf("a failing tool is a failed call: %s", steps["fail"]) | ||
| 87 | + } | ||
| 88 | + if !strings.Contains(steps["missing"], "Method not found") { | ||
| 89 | + t.Fatalf("an unknown method is not found: %s", steps["missing"]) | ||
| 90 | + } | ||
| 91 | +} | ||
| 92 | + | ||
| 93 | +func TestAnAgentWithoutToolsIsOfferedNothing(t *testing.T) { | ||
| 94 | + conn, err := acp.Start(context.Background(), fakeSpec(t, "ready"), acp.Options{}) | ||
| 95 | + if err != nil { | ||
| 96 | + t.Fatal(err) | ||
| 97 | + } | ||
| 98 | + t.Cleanup(func() { _ = conn.Close(context.Background()) }) | ||
| 99 | + handler := &recordingHandler{} | ||
| 100 | + id, _ := conn.NewSession(context.Background(), t.TempDir(), handler) | ||
| 101 | + if _, err := conn.Prompt(context.Background(), id, "client-tools"); err != nil { | ||
| 102 | + t.Fatal(err) | ||
| 103 | + } | ||
| 104 | + var text strings.Builder | ||
| 105 | + for _, update := range handler.ofKind(acp.UpdateMessage) { | ||
| 106 | + text.WriteString(update.Text) | ||
| 107 | + } | ||
| 108 | + if !strings.HasPrefix(text.String(), "meta=null version=dev") || !strings.Contains(text.String(), `list=null {"code":-32601`) { | ||
| 109 | + t.Fatalf("no tools, no list: %s", text.String()) | ||
| 110 | + } | ||
| 111 | +} | ||
added
internal/agents/discovery.go +62 -0 | new file mode 100644 | ||
| @@ -0,0 +1,62 @@ | ||
| 1 | +// Copyright (c) 2026 Philippe Charrière — Sidekicks Source-Available License 1.0, see LICENSE | |
| 2 | + | |
| 3 | +package agents | |
| 4 | + | |
| 5 | +import ( | |
| 6 | + "os" | |
| 7 | + "path/filepath" | |
| 8 | + "strings" | |
| 9 | + | |
| 10 | + "git.rickub.com/bots-garden/sidekicks/internal/acp" | |
| 11 | + "git.rickub.com/bots-garden/sidekicks/internal/config" | |
| 12 | + "go.yaml.in/yaml/v3" | |
| 13 | +) | |
| 14 | + | |
| 15 | +// ToolDiscovery is how the agent of definition wants the tools Sidekicks | |
| 16 | +// offers (issue #90): acp.DiscoveryRequest when the file it is started with | |
| 17 | +// (--config <file>, as mm is) says acp.clientTools.discovery: request; | |
| 18 | +// acp.DiscoveryMeta otherwise, mini-me's default. The file is read on this | |
| 19 | +// computer: an agent in a sandbox or a container has it at the same path. | |
| 20 | +// | |
| 21 | +// ToolDiscovery(config.Agent{Command: "mm", Args: []string{"--acp", "--config", "agent.yaml"}, Workspace: "/agents/riker"}) | |
| 22 | +func ToolDiscovery(definition config.Agent) string { | |
| 23 | + path := configFileOf(definition.Args) | |
| 24 | + if path == "" { | |
| 25 | + return acp.DiscoveryMeta | |
| 26 | + } | |
| 27 | + if !filepath.IsAbs(path) { | |
| 28 | + path = filepath.Join(definition.Workspace, path) | |
| 29 | + } | |
| 30 | + data, err := os.ReadFile(path) | |
| 31 | + if err != nil { | |
| 32 | + return acp.DiscoveryMeta | |
| 33 | + } | |
| 34 | + var file struct { | |
| 35 | + ACP struct { | |
| 36 | + ClientTools struct { | |
| 37 | + Discovery string `yaml:"discovery"` | |
| 38 | + } `yaml:"clientTools"` | |
| 39 | + } `yaml:"acp"` | |
| 40 | + } | |
| 41 | + if yaml.Unmarshal(data, &file) != nil || file.ACP.ClientTools.Discovery != acp.DiscoveryRequest { | |
| 42 | + return acp.DiscoveryMeta | |
| 43 | + } | |
| 44 | + return acp.DiscoveryRequest | |
| 45 | +} | |
| 46 | + | |
| 47 | +// configFileOf is the file given with --config or -config in args, "" without. | |
| 48 | +func configFileOf(args []string) string { | |
| 49 | + for i, arg := range args { | |
| 50 | + name, value, joined := strings.Cut(strings.TrimLeft(arg, "-"), "=") | |
| 51 | + if !strings.HasPrefix(arg, "-") || name != "config" { | |
| 52 | + continue | |
| 53 | + } | |
| 54 | + if joined { | |
| 55 | + return value | |
| 56 | + } | |
| 57 | + if i+1 < len(args) { | |
| 58 | + return args[i+1] | |
| 59 | + } | |
| 60 | + } | |
| 61 | + return "" | |
| 62 | +} | |
| new file mode 100644 | |||
| @@ -0,0 +1,62 @@ | |||
| 1 | +// Copyright (c) 2026 Philippe Charrière — Sidekicks Source-Available License 1.0, see LICENSE | ||
| 2 | + | ||
| 3 | +package agents | ||
| 4 | + | ||
| 5 | +import ( | ||
| 6 | + "os" | ||
| 7 | + "path/filepath" | ||
| 8 | + "strings" | ||
| 9 | + | ||
| 10 | + "git.rickub.com/bots-garden/sidekicks/internal/acp" | ||
| 11 | + "git.rickub.com/bots-garden/sidekicks/internal/config" | ||
| 12 | + "go.yaml.in/yaml/v3" | ||
| 13 | +) | ||
| 14 | + | ||
| 15 | +// ToolDiscovery is how the agent of definition wants the tools Sidekicks | ||
| 16 | +// offers (issue #90): acp.DiscoveryRequest when the file it is started with | ||
| 17 | +// (--config <file>, as mm is) says acp.clientTools.discovery: request; | ||
| 18 | +// acp.DiscoveryMeta otherwise, mini-me's default. The file is read on this | ||
| 19 | +// computer: an agent in a sandbox or a container has it at the same path. | ||
| 20 | +// | ||
| 21 | +// ToolDiscovery(config.Agent{Command: "mm", Args: []string{"--acp", "--config", "agent.yaml"}, Workspace: "/agents/riker"}) | ||
| 22 | +func ToolDiscovery(definition config.Agent) string { | ||
| 23 | + path := configFileOf(definition.Args) | ||
| 24 | + if path == "" { | ||
| 25 | + return acp.DiscoveryMeta | ||
| 26 | + } | ||
| 27 | + if !filepath.IsAbs(path) { | ||
| 28 | + path = filepath.Join(definition.Workspace, path) | ||
| 29 | + } | ||
| 30 | + data, err := os.ReadFile(path) | ||
| 31 | + if err != nil { | ||
| 32 | + return acp.DiscoveryMeta | ||
| 33 | + } | ||
| 34 | + var file struct { | ||
| 35 | + ACP struct { | ||
| 36 | + ClientTools struct { | ||
| 37 | + Discovery string `yaml:"discovery"` | ||
| 38 | + } `yaml:"clientTools"` | ||
| 39 | + } `yaml:"acp"` | ||
| 40 | + } | ||
| 41 | + if yaml.Unmarshal(data, &file) != nil || file.ACP.ClientTools.Discovery != acp.DiscoveryRequest { | ||
| 42 | + return acp.DiscoveryMeta | ||
| 43 | + } | ||
| 44 | + return acp.DiscoveryRequest | ||
| 45 | +} | ||
| 46 | + | ||
| 47 | +// configFileOf is the file given with --config or -config in args, "" without. | ||
| 48 | +func configFileOf(args []string) string { | ||
| 49 | + for i, arg := range args { | ||
| 50 | + name, value, joined := strings.Cut(strings.TrimLeft(arg, "-"), "=") | ||
| 51 | + if !strings.HasPrefix(arg, "-") || name != "config" { | ||
| 52 | + continue | ||
| 53 | + } | ||
| 54 | + if joined { | ||
| 55 | + return value | ||
| 56 | + } | ||
| 57 | + if i+1 < len(args) { | ||
| 58 | + return args[i+1] | ||
| 59 | + } | ||
| 60 | + } | ||
| 61 | + return "" | ||
| 62 | +} | ||
added
internal/agents/discovery_test.go +44 -0 | new file mode 100644 | ||
| @@ -0,0 +1,44 @@ | ||
| 1 | +// Copyright (c) 2026 Philippe Charrière — Sidekicks Source-Available License 1.0, see LICENSE | |
| 2 | + | |
| 3 | +package agents_test | |
| 4 | + | |
| 5 | +import ( | |
| 6 | + "os" | |
| 7 | + "path/filepath" | |
| 8 | + "testing" | |
| 9 | + | |
| 10 | + "git.rickub.com/bots-garden/sidekicks/internal/acp" | |
| 11 | + "git.rickub.com/bots-garden/sidekicks/internal/agents" | |
| 12 | + "git.rickub.com/bots-garden/sidekicks/internal/config" | |
| 13 | +) | |
| 14 | + | |
| 15 | +func TestToolDiscoveryFollowsTheAgentsFile(t *testing.T) { | |
| 16 | + dir := t.TempDir() | |
| 17 | + write := func(name, content string) { | |
| 18 | + if err := os.WriteFile(filepath.Join(dir, name), []byte(content), 0o644); err != nil { | |
| 19 | + t.Fatal(err) | |
| 20 | + } | |
| 21 | + } | |
| 22 | + write("request.yaml", "acp:\n clientTools:\n enabled: true\n discovery: request\n") | |
| 23 | + write("meta.yaml", "acp:\n clientTools:\n discovery: meta\n") | |
| 24 | + write("none.yaml", "model: x\n") | |
| 25 | + cases := []struct { | |
| 26 | + args []string | |
| 27 | + want string | |
| 28 | + }{ | |
| 29 | + {[]string{"--acp", "--config", "request.yaml"}, acp.DiscoveryRequest}, | |
| 30 | + {[]string{"-acp", "-config", filepath.Join(dir, "request.yaml")}, acp.DiscoveryRequest}, | |
| 31 | + {[]string{"--acp", "--config=request.yaml"}, acp.DiscoveryRequest}, | |
| 32 | + {[]string{"exec", "-i", "box", "mm", "--acp", "--config", "request.yaml"}, acp.DiscoveryRequest}, | |
| 33 | + {[]string{"--acp", "--config", "meta.yaml"}, acp.DiscoveryMeta}, | |
| 34 | + {[]string{"--acp", "--config", "none.yaml"}, acp.DiscoveryMeta}, | |
| 35 | + {[]string{"--acp", "--config", "missing.yaml"}, acp.DiscoveryMeta}, | |
| 36 | + {[]string{"serve", "acp", "agent.yaml"}, acp.DiscoveryMeta}, | |
| 37 | + {nil, acp.DiscoveryMeta}, | |
| 38 | + } | |
| 39 | + for _, c := range cases { | |
| 40 | + if got := agents.ToolDiscovery(config.Agent{Command: "mm", Args: c.args, Workspace: dir}); got != c.want { | |
| 41 | + t.Errorf("%q: got %s, want %s", c.args, got, c.want) | |
| 42 | + } | |
| 43 | + } | |
| 44 | +} | |
| new file mode 100644 | |||
| @@ -0,0 +1,44 @@ | |||
| 1 | +// Copyright (c) 2026 Philippe Charrière — Sidekicks Source-Available License 1.0, see LICENSE | ||
| 2 | + | ||
| 3 | +package agents_test | ||
| 4 | + | ||
| 5 | +import ( | ||
| 6 | + "os" | ||
| 7 | + "path/filepath" | ||
| 8 | + "testing" | ||
| 9 | + | ||
| 10 | + "git.rickub.com/bots-garden/sidekicks/internal/acp" | ||
| 11 | + "git.rickub.com/bots-garden/sidekicks/internal/agents" | ||
| 12 | + "git.rickub.com/bots-garden/sidekicks/internal/config" | ||
| 13 | +) | ||
| 14 | + | ||
| 15 | +func TestToolDiscoveryFollowsTheAgentsFile(t *testing.T) { | ||
| 16 | + dir := t.TempDir() | ||
| 17 | + write := func(name, content string) { | ||
| 18 | + if err := os.WriteFile(filepath.Join(dir, name), []byte(content), 0o644); err != nil { | ||
| 19 | + t.Fatal(err) | ||
| 20 | + } | ||
| 21 | + } | ||
| 22 | + write("request.yaml", "acp:\n clientTools:\n enabled: true\n discovery: request\n") | ||
| 23 | + write("meta.yaml", "acp:\n clientTools:\n discovery: meta\n") | ||
| 24 | + write("none.yaml", "model: x\n") | ||
| 25 | + cases := []struct { | ||
| 26 | + args []string | ||
| 27 | + want string | ||
| 28 | + }{ | ||
| 29 | + {[]string{"--acp", "--config", "request.yaml"}, acp.DiscoveryRequest}, | ||
| 30 | + {[]string{"-acp", "-config", filepath.Join(dir, "request.yaml")}, acp.DiscoveryRequest}, | ||
| 31 | + {[]string{"--acp", "--config=request.yaml"}, acp.DiscoveryRequest}, | ||
| 32 | + {[]string{"exec", "-i", "box", "mm", "--acp", "--config", "request.yaml"}, acp.DiscoveryRequest}, | ||
| 33 | + {[]string{"--acp", "--config", "meta.yaml"}, acp.DiscoveryMeta}, | ||
| 34 | + {[]string{"--acp", "--config", "none.yaml"}, acp.DiscoveryMeta}, | ||
| 35 | + {[]string{"--acp", "--config", "missing.yaml"}, acp.DiscoveryMeta}, | ||
| 36 | + {[]string{"serve", "acp", "agent.yaml"}, acp.DiscoveryMeta}, | ||
| 37 | + {nil, acp.DiscoveryMeta}, | ||
| 38 | + } | ||
| 39 | + for _, c := range cases { | ||
| 40 | + if got := agents.ToolDiscovery(config.Agent{Command: "mm", Args: c.args, Workspace: dir}); got != c.want { | ||
| 41 | + t.Errorf("%q: got %s, want %s", c.args, got, c.want) | ||
| 42 | + } | ||
| 43 | + } | ||
| 44 | +} | ||
modified
internal/agents/manager.go +15 -4 | @@ -98,6 +98,10 @@ type Options struct { | ||
| 98 | 98 | Prepare Preparer |
| 99 | 99 | // Now defaults to time.Now; tests control the clock with it. |
| 100 | 100 | Now func() time.Time |
| 101 | + // Tools, when set, gives the tools Sidekicks offers an agent (issue #90). | |
| 102 | + Tools func(definition config.Agent) []acp.Tool | |
| 103 | + // ClientVersion is Sidekicks' version, told to the agents. | |
| 104 | + ClientVersion string | |
| 101 | 105 | } |
| 102 | 106 | |
| 103 | 107 | // Status is the public view of an agent. |
| @@ -303,7 +307,7 @@ func (m *Manager) ensureStarted(ctx context.Context, name string) (*agent, error | ||
| 303 | 307 | var conn Conn |
| 304 | 308 | startErr := m.prepare(ctx, a, definition) |
| 305 | 309 | if startErr == nil { |
| 306 | - conn, startErr = m.options.Starter(ctx, specFor(definition), func(line string) { m.log(a, line) }) | |
| 310 | + conn, startErr = m.options.Starter(ctx, m.specFor(definition), func(line string) { m.log(a, line) }) | |
| 307 | 311 | } |
| 308 | 312 | |
| 309 | 313 | m.mu.Lock() |
| @@ -569,11 +573,18 @@ func (m *Manager) Reconfigure(ctx context.Context, definitions []config.Agent, m | ||
| 569 | 573 | } |
| 570 | 574 | } |
| 571 | 575 | |
| 572 | -func specFor(definition config.Agent) acp.Spec { | |
| 573 | - return acp.Spec{ | |
| 576 | +// specFor is how to start the agent of definition, with the tools offered | |
| 577 | +// to it, the way its file asks for them (ToolDiscovery). | |
| 578 | +func (m *Manager) specFor(definition config.Agent) acp.Spec { | |
| 579 | + spec := acp.Spec{ | |
| 574 | 580 | Name: definition.Name, Command: definition.Command, Args: definition.Args, |
| 575 | - Env: definition.Env, Dir: definition.Workspace, | |
| 581 | + Env: definition.Env, Dir: definition.Workspace, ClientVersion: m.options.ClientVersion, | |
| 576 | 582 | } |
| 583 | + if m.options.Tools != nil { | |
| 584 | + spec.Tools = m.options.Tools(definition) | |
| 585 | + spec.ToolDiscovery = ToolDiscovery(definition) | |
| 586 | + } | |
| 587 | + return spec | |
| 577 | 588 | } |
| 578 | 589 | |
| 579 | 590 | func (m *Manager) log(a *agent, line string) { |
| @@ -98,6 +98,10 @@ type Options struct { | |||
| 98 | Prepare Preparer | 98 | Prepare Preparer |
| 99 | // Now defaults to time.Now; tests control the clock with it. | 99 | // Now defaults to time.Now; tests control the clock with it. |
| 100 | Now func() time.Time | 100 | Now func() time.Time |
| 101 | + // Tools, when set, gives the tools Sidekicks offers an agent (issue #90). | ||
| 102 | + Tools func(definition config.Agent) []acp.Tool | ||
| 103 | + // ClientVersion is Sidekicks' version, told to the agents. | ||
| 104 | + ClientVersion string | ||
| 101 | } | 105 | } |
| 102 | 106 | ||
| 103 | // Status is the public view of an agent. | 107 | // Status is the public view of an agent. |
| @@ -303,7 +307,7 @@ func (m *Manager) ensureStarted(ctx context.Context, name string) (*agent, error | |||
| 303 | var conn Conn | 307 | var conn Conn |
| 304 | startErr := m.prepare(ctx, a, definition) | 308 | startErr := m.prepare(ctx, a, definition) |
| 305 | if startErr == nil { | 309 | if startErr == nil { |
| 306 | - conn, startErr = m.options.Starter(ctx, specFor(definition), func(line string) { m.log(a, line) }) | 310 | + conn, startErr = m.options.Starter(ctx, m.specFor(definition), func(line string) { m.log(a, line) }) |
| 307 | } | 311 | } |
| 308 | 312 | ||
| 309 | m.mu.Lock() | 313 | m.mu.Lock() |
| @@ -569,11 +573,18 @@ func (m *Manager) Reconfigure(ctx context.Context, definitions []config.Agent, m | |||
| 569 | } | 573 | } |
| 570 | } | 574 | } |
| 571 | 575 | ||
| 572 | -func specFor(definition config.Agent) acp.Spec { | 576 | +// specFor is how to start the agent of definition, with the tools offered |
| 573 | - return acp.Spec{ | 577 | +// to it, the way its file asks for them (ToolDiscovery). |
| 578 | +func (m *Manager) specFor(definition config.Agent) acp.Spec { | ||
| 579 | + spec := acp.Spec{ | ||
| 574 | Name: definition.Name, Command: definition.Command, Args: definition.Args, | 580 | Name: definition.Name, Command: definition.Command, Args: definition.Args, |
| 575 | - Env: definition.Env, Dir: definition.Workspace, | 581 | + Env: definition.Env, Dir: definition.Workspace, ClientVersion: m.options.ClientVersion, |
| 576 | } | 582 | } |
| 583 | + if m.options.Tools != nil { | ||
| 584 | + spec.Tools = m.options.Tools(definition) | ||
| 585 | + spec.ToolDiscovery = ToolDiscovery(definition) | ||
| 586 | + } | ||
| 587 | + return spec | ||
| 577 | } | 588 | } |
| 578 | 589 | ||
| 579 | func (m *Manager) log(a *agent, line string) { | 590 | func (m *Manager) log(a *agent, line string) { |
modified
internal/app/app.go +4 -0 | @@ -55,6 +55,9 @@ type Options struct { | ||
| 55 | 55 | // Sbx is the sbx command used to list, create, stop and remove the |
| 56 | 56 | // agents' sandboxes; "" looks it up. Tests pass a fake. |
| 57 | 57 | Sbx string |
| 58 | + // Version is Sidekicks' version (info.version of build/config.yml), told | |
| 59 | + // to the agents; "" for a development build. | |
| 60 | + Version string | |
| 58 | 61 | // OpenStore opens the history of the configuration file at path; nil |
| 59 | 62 | // opens it in the user's configuration folder (store.DirFor). |
| 60 | 63 | OpenStore func(configPath string) (*store.Store, error) |
| @@ -97,6 +100,7 @@ func New(location config.Location, options Options) *Core { | ||
| 97 | 100 | core.manager = agents.NewManager(cfg.Agents, agents.Options{ |
| 98 | 101 | MaxRunning: cfg.Limits.MaxRunningAgents, IdleTimeout: cfg.Limits.StopIdleAgentsAfter, |
| 99 | 102 | Emitter: options.Emitter, Starter: options.Starter, Prepare: core.sandboxes.Ensure, |
| 103 | + Tools: core.clientTools, ClientVersion: options.Version, | |
| 100 | 104 | }) |
| 101 | 105 | core.workspaces = newWorkspaces(options.Emitter) |
| 102 | 106 | core.workspaces.options.Sbx = options.Sbx |
| @@ -55,6 +55,9 @@ type Options struct { | |||
| 55 | // Sbx is the sbx command used to list, create, stop and remove the | 55 | // Sbx is the sbx command used to list, create, stop and remove the |
| 56 | // agents' sandboxes; "" looks it up. Tests pass a fake. | 56 | // agents' sandboxes; "" looks it up. Tests pass a fake. |
| 57 | Sbx string | 57 | Sbx string |
| 58 | + // Version is Sidekicks' version (info.version of build/config.yml), told | ||
| 59 | + // to the agents; "" for a development build. | ||
| 60 | + Version string | ||
| 58 | // OpenStore opens the history of the configuration file at path; nil | 61 | // OpenStore opens the history of the configuration file at path; nil |
| 59 | // opens it in the user's configuration folder (store.DirFor). | 62 | // opens it in the user's configuration folder (store.DirFor). |
| 60 | OpenStore func(configPath string) (*store.Store, error) | 63 | OpenStore func(configPath string) (*store.Store, error) |
| @@ -97,6 +100,7 @@ func New(location config.Location, options Options) *Core { | |||
| 97 | core.manager = agents.NewManager(cfg.Agents, agents.Options{ | 100 | core.manager = agents.NewManager(cfg.Agents, agents.Options{ |
| 98 | MaxRunning: cfg.Limits.MaxRunningAgents, IdleTimeout: cfg.Limits.StopIdleAgentsAfter, | 101 | MaxRunning: cfg.Limits.MaxRunningAgents, IdleTimeout: cfg.Limits.StopIdleAgentsAfter, |
| 99 | Emitter: options.Emitter, Starter: options.Starter, Prepare: core.sandboxes.Ensure, | 102 | Emitter: options.Emitter, Starter: options.Starter, Prepare: core.sandboxes.Ensure, |
| 103 | + Tools: core.clientTools, ClientVersion: options.Version, | ||
| 100 | }) | 104 | }) |
| 101 | core.workspaces = newWorkspaces(options.Emitter) | 105 | core.workspaces = newWorkspaces(options.Emitter) |
| 102 | core.workspaces.options.Sbx = options.Sbx | 106 | core.workspaces.options.Sbx = options.Sbx |
added
internal/app/clienttools.go +145 -0 | new file mode 100644 | ||
| @@ -0,0 +1,145 @@ | ||
| 1 | +// Copyright (c) 2026 Philippe Charrière — Sidekicks Source-Available License 1.0, see LICENSE | |
| 2 | + | |
| 3 | +package app | |
| 4 | + | |
| 5 | +import ( | |
| 6 | + "context" | |
| 7 | + "errors" | |
| 8 | + "fmt" | |
| 9 | + "runtime" | |
| 10 | + "strings" | |
| 11 | + | |
| 12 | + "git.rickub.com/bots-garden/sidekicks/internal/acp" | |
| 13 | + "git.rickub.com/bots-garden/sidekicks/internal/channels" | |
| 14 | + "git.rickub.com/bots-garden/sidekicks/internal/config" | |
| 15 | + "git.rickub.com/bots-garden/sidekicks/internal/memory" | |
| 16 | + "go.yaml.in/yaml/v3" | |
| 17 | +) | |
| 18 | + | |
| 19 | +// The tools Sidekicks offers every agent (issue #90). An agent that knows | |
| 20 | +// the protocol of mini-me (acp.clientTools in its file) gives them to its | |
| 21 | +// model as client_<name>; the others ignore them. | |
| 22 | + | |
| 23 | +// ReleasesURL is where Sidekicks is published. | |
| 24 | +const ReleasesURL = "https://rickub.com/bots-garden/sidekicks/releases" | |
| 25 | + | |
| 26 | +// The methods of the tools, under Sidekicks' reverse domain name. | |
| 27 | +const ( | |
| 28 | + MemoryMethod = "_com.rickub.sidekicks/system/memory" | |
| 29 | + AboutMethod = "_com.rickub.sidekicks/about" | |
| 30 | + ChannelMethod = "_com.rickub.sidekicks/channel/current" | |
| 31 | +) | |
| 32 | + | |
| 33 | +// clientTools are the tools offered to the agent of definition. | |
| 34 | +func (c *Core) clientTools(definition config.Agent) []acp.Tool { | |
| 35 | + agent := definition.Name | |
| 36 | + return []acp.Tool{ | |
| 37 | + { | |
| 38 | + Name: "memory_pressure", | |
| 39 | + Description: "Tell how much the memory of the user's computer is under pressure (normal, warning or critical) and how much is used. Call it before a heavy task, or when the user asks about memory or slowness.", | |
| 40 | + Method: MemoryMethod, | |
| 41 | + Call: func(context.Context, string, map[string]any) (string, error) { | |
| 42 | + status, err := memory.Read() | |
| 43 | + if err != nil { | |
| 44 | + return "", err | |
| 45 | + } | |
| 46 | + return MemoryText(status), nil | |
| 47 | + }, | |
| 48 | + }, | |
| 49 | + { | |
| 50 | + Name: "about_sidekicks", | |
| 51 | + Description: "Tell what Sidekicks is: the application the user talks to you through, its version and the computer it runs on. Call it when the user asks about Sidekicks or about where you run.", | |
| 52 | + Method: AboutMethod, | |
| 53 | + Call: func(context.Context, string, map[string]any) (string, error) { | |
| 54 | + return AboutText(c.options.Version, runtime.GOOS, runtime.GOARCH, agent), nil | |
| 55 | + }, | |
| 56 | + }, | |
| 57 | + { | |
| 58 | + Name: "current_channel", | |
| 59 | + Description: "Tell which Sidekicks channel this conversation is in: its name, its description and its members, or that it is a direct conversation with you. Call it when the user mentions the channel, or to know who else is there.", | |
| 60 | + Method: ChannelMethod, | |
| 61 | + Call: func(_ context.Context, sessionID string, _ map[string]any) (string, error) { | |
| 62 | + c.mu.Lock() | |
| 63 | + manager := c.channels | |
| 64 | + c.mu.Unlock() | |
| 65 | + if manager == nil { | |
| 66 | + return "", errors.New("no channel is open in Sidekicks") | |
| 67 | + } | |
| 68 | + channel, ok := manager.SessionChannel(agent, sessionID) | |
| 69 | + if !ok { | |
| 70 | + return "", errors.New("this session belongs to no Sidekicks channel") | |
| 71 | + } | |
| 72 | + return ChannelText(channel, agent), nil | |
| 73 | + }, | |
| 74 | + }, | |
| 75 | + } | |
| 76 | +} | |
| 77 | + | |
| 78 | +// MemoryText tells status to a model. | |
| 79 | +// | |
| 80 | +// MemoryText(memory.Status{Level: memory.Warning, Used: 24 << 30, Total: 32 << 30}) | |
| 81 | +// // "Memory pressure: warning (yellow). Used: 24.0 GB of 32.0 GB (75 %)." | |
| 82 | +func MemoryText(status memory.Status) string { | |
| 83 | + if status.Total == 0 { | |
| 84 | + return "The memory cannot be measured on this computer." | |
| 85 | + } | |
| 86 | + colours := map[memory.Level]string{memory.Normal: "green", memory.Warning: "yellow", memory.Critical: "red"} | |
| 87 | + text := fmt.Sprintf("Memory pressure: %s", status.Level) | |
| 88 | + if colour, ok := colours[status.Level]; ok { | |
| 89 | + text += " (" + colour + ")" | |
| 90 | + } | |
| 91 | + return fmt.Sprintf("%s. Used: %s of %s (%d %%).", text, gigabytes(status.Used), gigabytes(status.Total), status.Used*100/status.Total) | |
| 92 | +} | |
| 93 | + | |
| 94 | +func gigabytes(bytes uint64) string { | |
| 95 | + return fmt.Sprintf("%.1f GB", float64(bytes)/(1<<30)) | |
| 96 | +} | |
| 97 | + | |
| 98 | +// AboutText tells a model what Sidekicks is; agent is the one asking. | |
| 99 | +func AboutText(version, system, architecture, agent string) string { | |
| 100 | + if version == "" { | |
| 101 | + version = "dev" | |
| 102 | + } | |
| 103 | + return strings.Join([]string{ | |
| 104 | + fmt.Sprintf("Sidekicks %s, on %s/%s.", version, system, architecture), | |
| 105 | + "Sidekicks is a desktop application to converse with AI agents, alone or several together in channels, with the Agent Client Protocol (ACP).", | |
| 106 | + fmt.Sprintf("You are the agent %q in it: the user writes to you in a channel or a direct conversation, and mentions you with @%s.", agent, agent), | |
| 107 | + "Releases: " + ReleasesURL, | |
| 108 | + }, "\n") | |
| 109 | +} | |
| 110 | + | |
| 111 | +// ChannelText tells a model where it is talking: channel, seen by agent. | |
| 112 | +func ChannelText(channel channels.Channel, agent string) string { | |
| 113 | + if channel.Direct != "" { | |
| 114 | + return fmt.Sprintf("A direct conversation between the user and you (%s): no other agent reads it.", channel.Direct) | |
| 115 | + } | |
| 116 | + text := "Channel #" + channel.Name + "." | |
| 117 | + if channel.Description != "" { | |
| 118 | + text += "\nDescription: " + channel.Description | |
| 119 | + } | |
| 120 | + var others []string | |
| 121 | + for _, member := range channel.Members { | |
| 122 | + if member != agent { | |
| 123 | + others = append(others, "@"+member) | |
| 124 | + } | |
| 125 | + } | |
| 126 | + text += "\nMembers: you (@" + agent + ")" | |
| 127 | + if len(others) > 0 { | |
| 128 | + text += ", " + strings.Join(others, ", ") | |
| 129 | + } | |
| 130 | + return text + ", and the user." | |
| 131 | +} | |
| 132 | + | |
| 133 | +// VersionOf reads info.version in the content of build/config.yml; "" when | |
| 134 | +// it has none. | |
| 135 | +func VersionOf(buildConfig []byte) string { | |
| 136 | + var file struct { | |
| 137 | + Info struct { | |
| 138 | + Version string `yaml:"version"` | |
| 139 | + } `yaml:"info"` | |
| 140 | + } | |
| 141 | + if yaml.Unmarshal(buildConfig, &file) != nil { | |
| 142 | + return "" | |
| 143 | + } | |
| 144 | + return file.Info.Version | |
| 145 | +} | |
| new file mode 100644 | |||
| @@ -0,0 +1,145 @@ | |||
| 1 | +// Copyright (c) 2026 Philippe Charrière — Sidekicks Source-Available License 1.0, see LICENSE | ||
| 2 | + | ||
| 3 | +package app | ||
| 4 | + | ||
| 5 | +import ( | ||
| 6 | + "context" | ||
| 7 | + "errors" | ||
| 8 | + "fmt" | ||
| 9 | + "runtime" | ||
| 10 | + "strings" | ||
| 11 | + | ||
| 12 | + "git.rickub.com/bots-garden/sidekicks/internal/acp" | ||
| 13 | + "git.rickub.com/bots-garden/sidekicks/internal/channels" | ||
| 14 | + "git.rickub.com/bots-garden/sidekicks/internal/config" | ||
| 15 | + "git.rickub.com/bots-garden/sidekicks/internal/memory" | ||
| 16 | + "go.yaml.in/yaml/v3" | ||
| 17 | +) | ||
| 18 | + | ||
| 19 | +// The tools Sidekicks offers every agent (issue #90). An agent that knows | ||
| 20 | +// the protocol of mini-me (acp.clientTools in its file) gives them to its | ||
| 21 | +// model as client_<name>; the others ignore them. | ||
| 22 | + | ||
| 23 | +// ReleasesURL is where Sidekicks is published. | ||
| 24 | +const ReleasesURL = "https://rickub.com/bots-garden/sidekicks/releases" | ||
| 25 | + | ||
| 26 | +// The methods of the tools, under Sidekicks' reverse domain name. | ||
| 27 | +const ( | ||
| 28 | + MemoryMethod = "_com.rickub.sidekicks/system/memory" | ||
| 29 | + AboutMethod = "_com.rickub.sidekicks/about" | ||
| 30 | + ChannelMethod = "_com.rickub.sidekicks/channel/current" | ||
| 31 | +) | ||
| 32 | + | ||
| 33 | +// clientTools are the tools offered to the agent of definition. | ||
| 34 | +func (c *Core) clientTools(definition config.Agent) []acp.Tool { | ||
| 35 | + agent := definition.Name | ||
| 36 | + return []acp.Tool{ | ||
| 37 | + { | ||
| 38 | + Name: "memory_pressure", | ||
| 39 | + Description: "Tell how much the memory of the user's computer is under pressure (normal, warning or critical) and how much is used. Call it before a heavy task, or when the user asks about memory or slowness.", | ||
| 40 | + Method: MemoryMethod, | ||
| 41 | + Call: func(context.Context, string, map[string]any) (string, error) { | ||
| 42 | + status, err := memory.Read() | ||
| 43 | + if err != nil { | ||
| 44 | + return "", err | ||
| 45 | + } | ||
| 46 | + return MemoryText(status), nil | ||
| 47 | + }, | ||
| 48 | + }, | ||
| 49 | + { | ||
| 50 | + Name: "about_sidekicks", | ||
| 51 | + Description: "Tell what Sidekicks is: the application the user talks to you through, its version and the computer it runs on. Call it when the user asks about Sidekicks or about where you run.", | ||
| 52 | + Method: AboutMethod, | ||
| 53 | + Call: func(context.Context, string, map[string]any) (string, error) { | ||
| 54 | + return AboutText(c.options.Version, runtime.GOOS, runtime.GOARCH, agent), nil | ||
| 55 | + }, | ||
| 56 | + }, | ||
| 57 | + { | ||
| 58 | + Name: "current_channel", | ||
| 59 | + Description: "Tell which Sidekicks channel this conversation is in: its name, its description and its members, or that it is a direct conversation with you. Call it when the user mentions the channel, or to know who else is there.", | ||
| 60 | + Method: ChannelMethod, | ||
| 61 | + Call: func(_ context.Context, sessionID string, _ map[string]any) (string, error) { | ||
| 62 | + c.mu.Lock() | ||
| 63 | + manager := c.channels | ||
| 64 | + c.mu.Unlock() | ||
| 65 | + if manager == nil { | ||
| 66 | + return "", errors.New("no channel is open in Sidekicks") | ||
| 67 | + } | ||
| 68 | + channel, ok := manager.SessionChannel(agent, sessionID) | ||
| 69 | + if !ok { | ||
| 70 | + return "", errors.New("this session belongs to no Sidekicks channel") | ||
| 71 | + } | ||
| 72 | + return ChannelText(channel, agent), nil | ||
| 73 | + }, | ||
| 74 | + }, | ||
| 75 | + } | ||
| 76 | +} | ||
| 77 | + | ||
| 78 | +// MemoryText tells status to a model. | ||
| 79 | +// | ||
| 80 | +// MemoryText(memory.Status{Level: memory.Warning, Used: 24 << 30, Total: 32 << 30}) | ||
| 81 | +// // "Memory pressure: warning (yellow). Used: 24.0 GB of 32.0 GB (75 %)." | ||
| 82 | +func MemoryText(status memory.Status) string { | ||
| 83 | + if status.Total == 0 { | ||
| 84 | + return "The memory cannot be measured on this computer." | ||
| 85 | + } | ||
| 86 | + colours := map[memory.Level]string{memory.Normal: "green", memory.Warning: "yellow", memory.Critical: "red"} | ||
| 87 | + text := fmt.Sprintf("Memory pressure: %s", status.Level) | ||
| 88 | + if colour, ok := colours[status.Level]; ok { | ||
| 89 | + text += " (" + colour + ")" | ||
| 90 | + } | ||
| 91 | + return fmt.Sprintf("%s. Used: %s of %s (%d %%).", text, gigabytes(status.Used), gigabytes(status.Total), status.Used*100/status.Total) | ||
| 92 | +} | ||
| 93 | + | ||
| 94 | +func gigabytes(bytes uint64) string { | ||
| 95 | + return fmt.Sprintf("%.1f GB", float64(bytes)/(1<<30)) | ||
| 96 | +} | ||
| 97 | + | ||
| 98 | +// AboutText tells a model what Sidekicks is; agent is the one asking. | ||
| 99 | +func AboutText(version, system, architecture, agent string) string { | ||
| 100 | + if version == "" { | ||
| 101 | + version = "dev" | ||
| 102 | + } | ||
| 103 | + return strings.Join([]string{ | ||
| 104 | + fmt.Sprintf("Sidekicks %s, on %s/%s.", version, system, architecture), | ||
| 105 | + "Sidekicks is a desktop application to converse with AI agents, alone or several together in channels, with the Agent Client Protocol (ACP).", | ||
| 106 | + fmt.Sprintf("You are the agent %q in it: the user writes to you in a channel or a direct conversation, and mentions you with @%s.", agent, agent), | ||
| 107 | + "Releases: " + ReleasesURL, | ||
| 108 | + }, "\n") | ||
| 109 | +} | ||
| 110 | + | ||
| 111 | +// ChannelText tells a model where it is talking: channel, seen by agent. | ||
| 112 | +func ChannelText(channel channels.Channel, agent string) string { | ||
| 113 | + if channel.Direct != "" { | ||
| 114 | + return fmt.Sprintf("A direct conversation between the user and you (%s): no other agent reads it.", channel.Direct) | ||
| 115 | + } | ||
| 116 | + text := "Channel #" + channel.Name + "." | ||
| 117 | + if channel.Description != "" { | ||
| 118 | + text += "\nDescription: " + channel.Description | ||
| 119 | + } | ||
| 120 | + var others []string | ||
| 121 | + for _, member := range channel.Members { | ||
| 122 | + if member != agent { | ||
| 123 | + others = append(others, "@"+member) | ||
| 124 | + } | ||
| 125 | + } | ||
| 126 | + text += "\nMembers: you (@" + agent + ")" | ||
| 127 | + if len(others) > 0 { | ||
| 128 | + text += ", " + strings.Join(others, ", ") | ||
| 129 | + } | ||
| 130 | + return text + ", and the user." | ||
| 131 | +} | ||
| 132 | + | ||
| 133 | +// VersionOf reads info.version in the content of build/config.yml; "" when | ||
| 134 | +// it has none. | ||
| 135 | +func VersionOf(buildConfig []byte) string { | ||
| 136 | + var file struct { | ||
| 137 | + Info struct { | ||
| 138 | + Version string `yaml:"version"` | ||
| 139 | + } `yaml:"info"` | ||
| 140 | + } | ||
| 141 | + if yaml.Unmarshal(buildConfig, &file) != nil { | ||
| 142 | + return "" | ||
| 143 | + } | ||
| 144 | + return file.Info.Version | ||
| 145 | +} | ||
added
internal/app/clienttools_test.go +119 -0 | new file mode 100644 | ||
| @@ -0,0 +1,119 @@ | ||
| 1 | +// Copyright (c) 2026 Philippe Charrière — Sidekicks Source-Available License 1.0, see LICENSE | |
| 2 | + | |
| 3 | +package app_test | |
| 4 | + | |
| 5 | +import ( | |
| 6 | + "context" | |
| 7 | + "os" | |
| 8 | + "path/filepath" | |
| 9 | + "strings" | |
| 10 | + "sync" | |
| 11 | + "testing" | |
| 12 | + "time" | |
| 13 | + | |
| 14 | + "git.rickub.com/bots-garden/sidekicks/internal/acp" | |
| 15 | + "git.rickub.com/bots-garden/sidekicks/internal/agents" | |
| 16 | + "git.rickub.com/bots-garden/sidekicks/internal/app" | |
| 17 | + "git.rickub.com/bots-garden/sidekicks/internal/channels" | |
| 18 | + "git.rickub.com/bots-garden/sidekicks/internal/config" | |
| 19 | + "git.rickub.com/bots-garden/sidekicks/internal/memory" | |
| 20 | +) | |
| 21 | + | |
| 22 | +// Issue #90: the tools Sidekicks offers the agents. | |
| 23 | + | |
| 24 | +// offeredTools has riker answer in #general and returns how it was started. | |
| 25 | +func offeredTools(t *testing.T) acp.Spec { | |
| 26 | + t.Helper() | |
| 27 | + directory := t.TempDir() | |
| 28 | + path := filepath.Join(directory, "config.yaml") | |
| 29 | + write(t, path, "version: 1\nagents:\n - name: riker\n command: mm\n args: [--acp, --config, agent.yaml]\n workspace: riker\n") | |
| 30 | + var mu sync.Mutex | |
| 31 | + var spec acp.Spec | |
| 32 | + start := func(_ context.Context, started acp.Spec, _ func(string)) (agents.Conn, error) { | |
| 33 | + mu.Lock() | |
| 34 | + spec = started | |
| 35 | + mu.Unlock() | |
| 36 | + return &conn{done: make(chan struct{})}, nil | |
| 37 | + } | |
| 38 | + core := app.New(config.Location{Path: path, Source: config.SourceFlag}, app.Options{Starter: start, Version: "1.4.0"}) | |
| 39 | + t.Cleanup(func() { core.Shutdown(context.Background()) }) | |
| 40 | + service := &app.ChannelService{Core: core} | |
| 41 | + general, err := service.Create("general", "the bridge") | |
| 42 | + if err != nil { | |
| 43 | + t.Fatal(err) | |
| 44 | + } | |
| 45 | + if _, err := service.Send(general.ID, "@riker hi"); err != nil { | |
| 46 | + t.Fatal(err) | |
| 47 | + } | |
| 48 | + deadline := time.Now().Add(3 * time.Second) | |
| 49 | + for { | |
| 50 | + view, _ := service.Conversation(general.ID) | |
| 51 | + if !view.Busy && len(view.Messages) >= 2 { | |
| 52 | + break | |
| 53 | + } | |
| 54 | + if time.Now().After(deadline) { | |
| 55 | + t.Fatal("riker never answered") | |
| 56 | + } | |
| 57 | + time.Sleep(10 * time.Millisecond) | |
| 58 | + } | |
| 59 | + mu.Lock() | |
| 60 | + defer mu.Unlock() | |
| 61 | + return spec | |
| 62 | +} | |
| 63 | + | |
| 64 | +func TestTheAgentsAreOfferedSidekicksTools(t *testing.T) { | |
| 65 | + spec := offeredTools(t) | |
| 66 | + if spec.ClientVersion != "1.4.0" || spec.ToolDiscovery != acp.DiscoveryMeta || len(spec.Tools) != 3 { | |
| 67 | + t.Fatalf("spec: version %q, discovery %q, %d tools", spec.ClientVersion, spec.ToolDiscovery, len(spec.Tools)) | |
| 68 | + } | |
| 69 | + for _, tool := range spec.Tools { | |
| 70 | + if !strings.HasPrefix(tool.Method, "_com.rickub.sidekicks/") || tool.Description == "" { | |
| 71 | + t.Fatalf("tool %+v", tool) | |
| 72 | + } | |
| 73 | + } | |
| 74 | +} | |
| 75 | + | |
| 76 | +func TestTheToolsAnswerForTheCallersSession(t *testing.T) { | |
| 77 | + tools := map[string]acp.Tool{} | |
| 78 | + for _, tool := range offeredTools(t).Tools { | |
| 79 | + tools[tool.Name] = tool | |
| 80 | + } | |
| 81 | + text, err := tools["current_channel"].Call(context.Background(), "s-1", nil) | |
| 82 | + if err != nil || !strings.Contains(text, "Channel #general.") || !strings.Contains(text, "Description: the bridge") || !strings.Contains(text, "you (@riker)") { | |
| 83 | + t.Fatalf("current_channel: %q %v", text, err) | |
| 84 | + } | |
| 85 | + if _, err := tools["current_channel"].Call(context.Background(), "s-unknown", nil); err == nil { | |
| 86 | + t.Fatal("an unknown session is an error") | |
| 87 | + } | |
| 88 | + if text, _ := tools["about_sidekicks"].Call(context.Background(), "s-1", nil); !strings.HasPrefix(text, "Sidekicks 1.4.0, on ") || !strings.Contains(text, `"riker"`) { | |
| 89 | + t.Fatalf("about_sidekicks: %q", text) | |
| 90 | + } | |
| 91 | + if text, err := tools["memory_pressure"].Call(context.Background(), "", nil); err == nil && !strings.HasPrefix(text, "Memory pressure: ") { | |
| 92 | + t.Fatalf("memory_pressure: %q", text) | |
| 93 | + } | |
| 94 | +} | |
| 95 | + | |
| 96 | +func TestToolTexts(t *testing.T) { | |
| 97 | + if got := app.MemoryText(memory.Status{Level: memory.Warning, Used: 24 << 30, Total: 32 << 30}); got != "Memory pressure: warning (yellow). Used: 24.0 GB of 32.0 GB (75 %)." { | |
| 98 | + t.Fatalf("memory: %q", got) | |
| 99 | + } | |
| 100 | + if got := app.MemoryText(memory.Status{}); got != "The memory cannot be measured on this computer." { | |
| 101 | + t.Fatalf("no memory: %q", got) | |
| 102 | + } | |
| 103 | + if got := app.ChannelText(channels.Channel{Direct: "riker"}, "riker"); !strings.HasPrefix(got, "A direct conversation between the user and you (riker)") { | |
| 104 | + t.Fatalf("direct: %q", got) | |
| 105 | + } | |
| 106 | + if got := app.ChannelText(channels.Channel{Name: "general", Members: []string{"riker", "data"}}, "riker"); got != "Channel #general.\nMembers: you (@riker), @data, and the user." { | |
| 107 | + t.Fatalf("channel: %q", got) | |
| 108 | + } | |
| 109 | + if got := app.AboutText("", "darwin", "arm64", "riker"); !strings.HasPrefix(got, "Sidekicks dev, on darwin/arm64.") || !strings.Contains(got, app.ReleasesURL) { | |
| 110 | + t.Fatalf("about: %q", got) | |
| 111 | + } | |
| 112 | + if got := app.VersionOf([]byte("info:\n productName: \"Sidekicks\"\n version: \"1.3.0\" # The application version\n")); got != "1.3.0" { | |
| 113 | + t.Fatalf("version: %q", got) | |
| 114 | + } | |
| 115 | + data, err := os.ReadFile("../../build/config.yml") | |
| 116 | + if err != nil || app.VersionOf(data) == "" { | |
| 117 | + t.Fatalf("the version of build/config.yml: %v", err) | |
| 118 | + } | |
| 119 | +} | |
| new file mode 100644 | |||
| @@ -0,0 +1,119 @@ | |||
| 1 | +// Copyright (c) 2026 Philippe Charrière — Sidekicks Source-Available License 1.0, see LICENSE | ||
| 2 | + | ||
| 3 | +package app_test | ||
| 4 | + | ||
| 5 | +import ( | ||
| 6 | + "context" | ||
| 7 | + "os" | ||
| 8 | + "path/filepath" | ||
| 9 | + "strings" | ||
| 10 | + "sync" | ||
| 11 | + "testing" | ||
| 12 | + "time" | ||
| 13 | + | ||
| 14 | + "git.rickub.com/bots-garden/sidekicks/internal/acp" | ||
| 15 | + "git.rickub.com/bots-garden/sidekicks/internal/agents" | ||
| 16 | + "git.rickub.com/bots-garden/sidekicks/internal/app" | ||
| 17 | + "git.rickub.com/bots-garden/sidekicks/internal/channels" | ||
| 18 | + "git.rickub.com/bots-garden/sidekicks/internal/config" | ||
| 19 | + "git.rickub.com/bots-garden/sidekicks/internal/memory" | ||
| 20 | +) | ||
| 21 | + | ||
| 22 | +// Issue #90: the tools Sidekicks offers the agents. | ||
| 23 | + | ||
| 24 | +// offeredTools has riker answer in #general and returns how it was started. | ||
| 25 | +func offeredTools(t *testing.T) acp.Spec { | ||
| 26 | + t.Helper() | ||
| 27 | + directory := t.TempDir() | ||
| 28 | + path := filepath.Join(directory, "config.yaml") | ||
| 29 | + write(t, path, "version: 1\nagents:\n - name: riker\n command: mm\n args: [--acp, --config, agent.yaml]\n workspace: riker\n") | ||
| 30 | + var mu sync.Mutex | ||
| 31 | + var spec acp.Spec | ||
| 32 | + start := func(_ context.Context, started acp.Spec, _ func(string)) (agents.Conn, error) { | ||
| 33 | + mu.Lock() | ||
| 34 | + spec = started | ||
| 35 | + mu.Unlock() | ||
| 36 | + return &conn{done: make(chan struct{})}, nil | ||
| 37 | + } | ||
| 38 | + core := app.New(config.Location{Path: path, Source: config.SourceFlag}, app.Options{Starter: start, Version: "1.4.0"}) | ||
| 39 | + t.Cleanup(func() { core.Shutdown(context.Background()) }) | ||
| 40 | + service := &app.ChannelService{Core: core} | ||
| 41 | + general, err := service.Create("general", "the bridge") | ||
| 42 | + if err != nil { | ||
| 43 | + t.Fatal(err) | ||
| 44 | + } | ||
| 45 | + if _, err := service.Send(general.ID, "@riker hi"); err != nil { | ||
| 46 | + t.Fatal(err) | ||
| 47 | + } | ||
| 48 | + deadline := time.Now().Add(3 * time.Second) | ||
| 49 | + for { | ||
| 50 | + view, _ := service.Conversation(general.ID) | ||
| 51 | + if !view.Busy && len(view.Messages) >= 2 { | ||
| 52 | + break | ||
| 53 | + } | ||
| 54 | + if time.Now().After(deadline) { | ||
| 55 | + t.Fatal("riker never answered") | ||
| 56 | + } | ||
| 57 | + time.Sleep(10 * time.Millisecond) | ||
| 58 | + } | ||
| 59 | + mu.Lock() | ||
| 60 | + defer mu.Unlock() | ||
| 61 | + return spec | ||
| 62 | +} | ||
| 63 | + | ||
| 64 | +func TestTheAgentsAreOfferedSidekicksTools(t *testing.T) { | ||
| 65 | + spec := offeredTools(t) | ||
| 66 | + if spec.ClientVersion != "1.4.0" || spec.ToolDiscovery != acp.DiscoveryMeta || len(spec.Tools) != 3 { | ||
| 67 | + t.Fatalf("spec: version %q, discovery %q, %d tools", spec.ClientVersion, spec.ToolDiscovery, len(spec.Tools)) | ||
| 68 | + } | ||
| 69 | + for _, tool := range spec.Tools { | ||
| 70 | + if !strings.HasPrefix(tool.Method, "_com.rickub.sidekicks/") || tool.Description == "" { | ||
| 71 | + t.Fatalf("tool %+v", tool) | ||
| 72 | + } | ||
| 73 | + } | ||
| 74 | +} | ||
| 75 | + | ||
| 76 | +func TestTheToolsAnswerForTheCallersSession(t *testing.T) { | ||
| 77 | + tools := map[string]acp.Tool{} | ||
| 78 | + for _, tool := range offeredTools(t).Tools { | ||
| 79 | + tools[tool.Name] = tool | ||
| 80 | + } | ||
| 81 | + text, err := tools["current_channel"].Call(context.Background(), "s-1", nil) | ||
| 82 | + if err != nil || !strings.Contains(text, "Channel #general.") || !strings.Contains(text, "Description: the bridge") || !strings.Contains(text, "you (@riker)") { | ||
| 83 | + t.Fatalf("current_channel: %q %v", text, err) | ||
| 84 | + } | ||
| 85 | + if _, err := tools["current_channel"].Call(context.Background(), "s-unknown", nil); err == nil { | ||
| 86 | + t.Fatal("an unknown session is an error") | ||
| 87 | + } | ||
| 88 | + if text, _ := tools["about_sidekicks"].Call(context.Background(), "s-1", nil); !strings.HasPrefix(text, "Sidekicks 1.4.0, on ") || !strings.Contains(text, `"riker"`) { | ||
| 89 | + t.Fatalf("about_sidekicks: %q", text) | ||
| 90 | + } | ||
| 91 | + if text, err := tools["memory_pressure"].Call(context.Background(), "", nil); err == nil && !strings.HasPrefix(text, "Memory pressure: ") { | ||
| 92 | + t.Fatalf("memory_pressure: %q", text) | ||
| 93 | + } | ||
| 94 | +} | ||
| 95 | + | ||
| 96 | +func TestToolTexts(t *testing.T) { | ||
| 97 | + if got := app.MemoryText(memory.Status{Level: memory.Warning, Used: 24 << 30, Total: 32 << 30}); got != "Memory pressure: warning (yellow). Used: 24.0 GB of 32.0 GB (75 %)." { | ||
| 98 | + t.Fatalf("memory: %q", got) | ||
| 99 | + } | ||
| 100 | + if got := app.MemoryText(memory.Status{}); got != "The memory cannot be measured on this computer." { | ||
| 101 | + t.Fatalf("no memory: %q", got) | ||
| 102 | + } | ||
| 103 | + if got := app.ChannelText(channels.Channel{Direct: "riker"}, "riker"); !strings.HasPrefix(got, "A direct conversation between the user and you (riker)") { | ||
| 104 | + t.Fatalf("direct: %q", got) | ||
| 105 | + } | ||
| 106 | + if got := app.ChannelText(channels.Channel{Name: "general", Members: []string{"riker", "data"}}, "riker"); got != "Channel #general.\nMembers: you (@riker), @data, and the user." { | ||
| 107 | + t.Fatalf("channel: %q", got) | ||
| 108 | + } | ||
| 109 | + if got := app.AboutText("", "darwin", "arm64", "riker"); !strings.HasPrefix(got, "Sidekicks dev, on darwin/arm64.") || !strings.Contains(got, app.ReleasesURL) { | ||
| 110 | + t.Fatalf("about: %q", got) | ||
| 111 | + } | ||
| 112 | + if got := app.VersionOf([]byte("info:\n productName: \"Sidekicks\"\n version: \"1.3.0\" # The application version\n")); got != "1.3.0" { | ||
| 113 | + t.Fatalf("version: %q", got) | ||
| 114 | + } | ||
| 115 | + data, err := os.ReadFile("../../build/config.yml") | ||
| 116 | + if err != nil || app.VersionOf(data) == "" { | ||
| 117 | + t.Fatalf("the version of build/config.yml: %v", err) | ||
| 118 | + } | ||
| 119 | +} | ||
modified
internal/channels/channels.go +19 -0 | @@ -372,6 +372,25 @@ func (m *Manager) Channels() []Channel { | ||
| 372 | 372 | return m.list() |
| 373 | 373 | } |
| 374 | 374 | |
| 375 | +// SessionChannel is the channel (or direct conversation) in which agent | |
| 376 | +// holds the ACP session sessionID; false when none does, such as the session | |
| 377 | +// opened to unload a model. The tools Sidekicks offers the agents use it to | |
| 378 | +// know where a call comes from (issue #90). | |
| 379 | +func (m *Manager) SessionChannel(agent, sessionID string) (Channel, bool) { | |
| 380 | + m.mu.Lock() | |
| 381 | + defer m.mu.Unlock() | |
| 382 | + if sessionID == "" { | |
| 383 | + return Channel{}, false | |
| 384 | + } | |
| 385 | + for _, id := range m.order { | |
| 386 | + ch := m.channels[id] | |
| 387 | + if member := ch.member(agent); member != nil && member.SessionID == sessionID { | |
| 388 | + return ch.view(), true | |
| 389 | + } | |
| 390 | + } | |
| 391 | + return Channel{}, false | |
| 392 | +} | |
| 393 | + | |
| 375 | 394 | // Declare creates the channels of the configuration that do not exist yet |
| 376 | 395 | // and adds their missing members (ADR 0003: the YAML describes, the store |
| 377 | 396 | // remembers; nothing is removed). |
| @@ -372,6 +372,25 @@ func (m *Manager) Channels() []Channel { | |||
| 372 | return m.list() | 372 | return m.list() |
| 373 | } | 373 | } |
| 374 | 374 | ||
| 375 | +// SessionChannel is the channel (or direct conversation) in which agent | ||
| 376 | +// holds the ACP session sessionID; false when none does, such as the session | ||
| 377 | +// opened to unload a model. The tools Sidekicks offers the agents use it to | ||
| 378 | +// know where a call comes from (issue #90). | ||
| 379 | +func (m *Manager) SessionChannel(agent, sessionID string) (Channel, bool) { | ||
| 380 | + m.mu.Lock() | ||
| 381 | + defer m.mu.Unlock() | ||
| 382 | + if sessionID == "" { | ||
| 383 | + return Channel{}, false | ||
| 384 | + } | ||
| 385 | + for _, id := range m.order { | ||
| 386 | + ch := m.channels[id] | ||
| 387 | + if member := ch.member(agent); member != nil && member.SessionID == sessionID { | ||
| 388 | + return ch.view(), true | ||
| 389 | + } | ||
| 390 | + } | ||
| 391 | + return Channel{}, false | ||
| 392 | +} | ||
| 393 | + | ||
| 375 | // Declare creates the channels of the configuration that do not exist yet | 394 | // Declare creates the channels of the configuration that do not exist yet |
| 376 | // and adds their missing members (ADR 0003: the YAML describes, the store | 395 | // and adds their missing members (ADR 0003: the YAML describes, the store |
| 377 | // remembers; nothing is removed). | 396 | // remembers; nothing is removed). |
modified
internal/channels/channels_test.go +23 -0 | @@ -616,3 +616,26 @@ func ExampleManager_Send() { | ||
| 616 | 616 | } |
| 617 | 617 | // Output: agent:alice::alice ok | agent:bob::bob ok |
| 618 | 618 | } |
| 619 | + | |
| 620 | +func TestSessionChannelTellsWhereASessionBelongs(t *testing.T) { | |
| 621 | + f := setup(t, nil) | |
| 622 | + general := f.channel(t, "general", "alice", "bob") | |
| 623 | + random := f.channel(t, "random", "alice") | |
| 624 | + f.send(t, general.ID, "@alice hi") | |
| 625 | + f.idle(t, general.ID, 2) | |
| 626 | + f.send(t, random.ID, "@alice hello") | |
| 627 | + f.idle(t, random.ID, 2) | |
| 628 | + for _, want := range []channels.Channel{general, random} { | |
| 629 | + members, _ := f.db.Members(want.ID) | |
| 630 | + got, ok := f.manager.SessionChannel("alice", members[0].SessionID) | |
| 631 | + if !ok || got.ID != want.ID || got.Name != want.Name { | |
| 632 | + t.Fatalf("session %s: got %+v %v, want %s", members[0].SessionID, got, ok, want.Name) | |
| 633 | + } | |
| 634 | + } | |
| 635 | + if _, ok := f.manager.SessionChannel("bob", "alice-s1"); ok { | |
| 636 | + t.Fatal("a session belongs to its agent") | |
| 637 | + } | |
| 638 | + if _, ok := f.manager.SessionChannel("alice", ""); ok { | |
| 639 | + t.Fatal("no session, no channel") | |
| 640 | + } | |
| 641 | +} | |
| @@ -616,3 +616,26 @@ func ExampleManager_Send() { | |||
| 616 | } | 616 | } |
| 617 | // Output: agent:alice::alice ok | agent:bob::bob ok | 617 | // Output: agent:alice::alice ok | agent:bob::bob ok |
| 618 | } | 618 | } |
| 619 | + | ||
| 620 | +func TestSessionChannelTellsWhereASessionBelongs(t *testing.T) { | ||
| 621 | + f := setup(t, nil) | ||
| 622 | + general := f.channel(t, "general", "alice", "bob") | ||
| 623 | + random := f.channel(t, "random", "alice") | ||
| 624 | + f.send(t, general.ID, "@alice hi") | ||
| 625 | + f.idle(t, general.ID, 2) | ||
| 626 | + f.send(t, random.ID, "@alice hello") | ||
| 627 | + f.idle(t, random.ID, 2) | ||
| 628 | + for _, want := range []channels.Channel{general, random} { | ||
| 629 | + members, _ := f.db.Members(want.ID) | ||
| 630 | + got, ok := f.manager.SessionChannel("alice", members[0].SessionID) | ||
| 631 | + if !ok || got.ID != want.ID || got.Name != want.Name { | ||
| 632 | + t.Fatalf("session %s: got %+v %v, want %s", members[0].SessionID, got, ok, want.Name) | ||
| 633 | + } | ||
| 634 | + } | ||
| 635 | + if _, ok := f.manager.SessionChannel("bob", "alice-s1"); ok { | ||
| 636 | + t.Fatal("a session belongs to its agent") | ||
| 637 | + } | ||
| 638 | + if _, ok := f.manager.SessionChannel("alice", ""); ok { | ||
| 639 | + t.Fatal("no session, no channel") | ||
| 640 | + } | ||
| 641 | +} | ||
modified
main.go +6 -0 | @@ -31,6 +31,11 @@ import ( | ||
| 31 | 31 | //go:embed all:frontend/dist |
| 32 | 32 | var assets embed.FS |
| 33 | 33 | |
| 34 | +// buildConfig holds info.version, Sidekicks' version, told to the agents. | |
| 35 | +// | |
| 36 | +//go:embed build/config.yml | |
| 37 | +var buildConfig []byte | |
| 38 | + | |
| 34 | 39 | // titleBarInset must match --titlebar-inset in frontend/src/style.css: the |
| 35 | 40 | // height of the area covered by the macOS traffic lights. |
| 36 | 41 | const titleBarInset = 38 |
| @@ -121,6 +126,7 @@ func main() { | ||
| 121 | 126 | core := app.New(location, app.Options{ |
| 122 | 127 | Emitter: emitter, Preferences: preferences, |
| 123 | 128 | PickFile: pickFile, PickFolder: pickFolder, PickYAML: pickYAML, PickAttachment: pickAttachment, |
| 129 | + Version: app.VersionOf(buildConfig), | |
| 124 | 130 | }) |
| 125 | 131 | ctx, cancel := context.WithCancel(context.Background()) |
| 126 | 132 | |
| @@ -31,6 +31,11 @@ import ( | |||
| 31 | //go:embed all:frontend/dist | 31 | //go:embed all:frontend/dist |
| 32 | var assets embed.FS | 32 | var assets embed.FS |
| 33 | 33 | ||
| 34 | +// buildConfig holds info.version, Sidekicks' version, told to the agents. | ||
| 35 | +// | ||
| 36 | +//go:embed build/config.yml | ||
| 37 | +var buildConfig []byte | ||
| 38 | + | ||
| 34 | // titleBarInset must match --titlebar-inset in frontend/src/style.css: the | 39 | // titleBarInset must match --titlebar-inset in frontend/src/style.css: the |
| 35 | // height of the area covered by the macOS traffic lights. | 40 | // height of the area covered by the macOS traffic lights. |
| 36 | const titleBarInset = 38 | 41 | const titleBarInset = 38 |
| @@ -121,6 +126,7 @@ func main() { | |||
| 121 | core := app.New(location, app.Options{ | 126 | core := app.New(location, app.Options{ |
| 122 | Emitter: emitter, Preferences: preferences, | 127 | Emitter: emitter, Preferences: preferences, |
| 123 | PickFile: pickFile, PickFolder: pickFolder, PickYAML: pickYAML, PickAttachment: pickAttachment, | 128 | PickFile: pickFile, PickFolder: pickFolder, PickYAML: pickYAML, PickAttachment: pickAttachment, |
| 129 | + Version: app.VersionOf(buildConfig), | ||
| 124 | }) | 130 | }) |
| 125 | ctx, cancel := context.WithCancel(context.Background()) | 131 | ctx, cancel := context.WithCancel(context.Background()) |
| 126 | 132 | ||