bots-garden/sidekickspublic Fork
⑂ 2ec3a89
Commits
⬇ Clone ▾
git clone https://git.rickub.com/bots-garden/sidekicks.git
git clone ssh://git@rickub.com/bots-garden/sidekicks.git

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

Download ZIP

#91 Outils list_channels, list_agents, search_messages ; réglage agentTools (enabled, offer)

Les agents qui découvrent les outils du client (mini-me) peuvent lister les
channels et les agents, et chercher dans tout l'historique d'un channel
(sans casse ni accents, extraits). agentTools.enabled (défaut true) et
agentTools.offer filtrent les six outils proposés ; un nom inconnu est un
avertissement, l'éditeur Settings propose les noms. Tests ; docs EN + FR.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
k33g committed 2026-11-11T00:54:41+01:00 Browse files
2ec3a89 parent: bf87a0b
modified .tickets/issues/0091-outils-pour-les-agents-chercher-dans-l-historiqu.yaml +40 -10
@@ -1,12 +1,12 @@
11 # Managed by IssueSpec. Hand edits are welcome; keep the schema valid.
22 id: 91
33 title: "Outils pour les agents : chercher dans l'historique d'un channel, lister les channels et les agents ; réglage pour les désactiver ou les filtrer"
4-state: open
4+state: closed
55 author:
66 name: k33g
77 email: ph.charriere@gmail.com
88 createdAt: 2026-11-10T23:41:38.000Z
9-updatedAt: 2026-11-10T23:46:12.000Z
9+updatedAt: 2026-11-10T23:54:34.000Z
1010 labels:
1111 - "kind::feature"
1212 - "area::acp"
@@ -84,44 +84,54 @@ body: |
8484 tasks:
8585 - id: 1
8686 title: "Réglage agentTools (enabled, défaut true ; offer, filtre des outils) : config, schéma, validation, Settings"
87- state: open
87+ state: closed
8888 priority: high
8989 author:
9090 name: k33g
9191 email: ph.charriere@gmail.com
9292 createdAt: 2026-11-10T23:41:38.000Z
93+ updatedAt: 2026-11-10T23:54:34.000Z
94+ closedAt: 2026-11-10T23:54:34.000Z
9395 - id: 2
9496 title: "Désactivé ou filtré : rien d'annoncé à initialize pour les outils retirés, -32601"
95- state: open
97+ state: closed
9698 priority: high
9799 author:
98100 name: k33g
99101 email: ph.charriere@gmail.com
100102 createdAt: 2026-11-10T23:41:38.000Z
103+ updatedAt: 2026-11-10T23:54:34.000Z
104+ closedAt: 2026-11-10T23:54:34.000Z
101105 - id: 3
102106 title: "Outil list_channels"
103- state: open
107+ state: closed
104108 priority: medium
105109 author:
106110 name: k33g
107111 email: ph.charriere@gmail.com
108112 createdAt: 2026-11-10T23:41:38.000Z
113+ updatedAt: 2026-11-10T23:54:34.000Z
114+ closedAt: 2026-11-10T23:54:34.000Z
109115 - id: 4
110116 title: "Outil list_agents"
111- state: open
117+ state: closed
112118 priority: medium
113119 author:
114120 name: k33g
115121 email: ph.charriere@gmail.com
116122 createdAt: 2026-11-10T23:41:38.000Z
123+ updatedAt: 2026-11-10T23:54:34.000Z
124+ closedAt: 2026-11-10T23:54:34.000Z
117125 - id: 5
118126 title: "Outil search_messages (store : parcours des messages d'un channel, sans casse ni accents)"
119- state: open
127+ state: closed
120128 priority: high
121129 author:
122130 name: k33g
123131 email: ph.charriere@gmail.com
124132 createdAt: 2026-11-10T23:41:38.000Z
133+ updatedAt: 2026-11-10T23:54:34.000Z
134+ closedAt: 2026-11-10T23:54:34.000Z
125135 - id: 6
126136 title: "Décider la portée : channels dont l'agent est membre ou tous"
127137 state: closed
@@ -134,20 +144,24 @@ tasks:
134144 closedAt: 2026-11-10T23:46:12.000Z
135145 - id: 7
136146 title: "Tests ; essai avec Riker"
137- state: open
147+ state: closed
138148 priority: high
139149 author:
140150 name: k33g
141151 email: ph.charriere@gmail.com
142152 createdAt: 2026-11-10T23:41:38.000Z
153+ updatedAt: 2026-11-10T23:54:34.000Z
154+ closedAt: 2026-11-10T23:54:34.000Z
143155 - id: 8
144156 title: "Documentation EN + FR (config, référence, guide, explication)"
145- state: open
157+ state: closed
146158 priority: medium
147159 author:
148160 name: k33g
149161 email: ph.charriere@gmail.com
150162 createdAt: 2026-11-10T23:41:38.000Z
163+ updatedAt: 2026-11-10T23:54:34.000Z
164+ closedAt: 2026-11-10T23:54:34.000Z
151165 comments:
152166 - id: 1
153167 author:
@@ -157,4 +171,20 @@ comments:
157171 body: |
158172 Décidé : un agent lit déjà l'historique des channels dont il est membre ; outils activés, il peut lister et
159173 chercher dans **tous** les channels. Pour restreindre, on filtre les outils proposés avec `agentTools.offer`.
160-
174+ - id: 2
175+ author:
176+ name: k33g
177+ email: ph.charriere@gmail.com
178+ createdAt: 2026-11-10T23:54:34.000Z
179+ body: |
180+ Fait.
181+ - Réglage `agentTools` ([internal/config/config.go](internal/config/config.go)) : `enabled` (défaut `true`) et
182+ `offer` (liste, absente : tous) ; `config.AgentToolNames` ; un nom inconnu est un avertissement ; schéma JSON
183+ (`examples` : l'éditeur Settings propose les noms après `- `) ; configuration par défaut.
184+ - Recherche et résumés : [internal/channels/search.go](internal/channels/search.go) (`Summaries`, `ChannelNamed`,
185+ `Search` : tout l'historique enregistré, sans casse ni accents, extrait de 80 caractères de chaque côté).
186+ - Outils `list_channels`, `list_agents`, `search_messages` : [internal/app/historytools.go](internal/app/historytools.go) ;
187+ filtre des six outils dans `clientTools`. Un outil retiré n'est ni annoncé ni répondu (`-32601`).
188+ - Tests : config (défaut, désactivé, filtre, liste vide, nom inconnu), recherche, résumés, outils, filtre.
189+ - Docs EN + FR : référence de la configuration (`agentTools`), référence des outils, guide, explication « Pourquoi ACP ».
190+ - Reste : l'essai avec Riker sur le Mac.
@@ -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: 912 id: 91
3 title: "Outils pour les agents : chercher dans l'historique d'un channel, lister les channels et les agents ; réglage pour les désactiver ou les filtrer"3 title: "Outils pour les agents : chercher dans l'historique d'un channel, lister les channels et les agents ; réglage pour les désactiver ou les filtrer"
4-state: open4+state: closed
5 author:5 author:
6 name: k33g6 name: k33g
7 email: ph.charriere@gmail.com7 email: ph.charriere@gmail.com
8 createdAt: 2026-11-10T23:41:38.000Z8 createdAt: 2026-11-10T23:41:38.000Z
9-updatedAt: 2026-11-10T23:46:12.000Z9+updatedAt: 2026-11-10T23:54:34.000Z
10 labels:10 labels:
11 - "kind::feature"11 - "kind::feature"
12 - "area::acp"12 - "area::acp"
@@ -84,44 +84,54 @@ body: |
84 tasks:84 tasks:
85 - id: 185 - id: 1
86 title: "Réglage agentTools (enabled, défaut true ; offer, filtre des outils) : config, schéma, validation, Settings"86 title: "Réglage agentTools (enabled, défaut true ; offer, filtre des outils) : config, schéma, validation, Settings"
87- state: open87+ state: closed
88 priority: high88 priority: high
89 author:89 author:
90 name: k33g90 name: k33g
91 email: ph.charriere@gmail.com91 email: ph.charriere@gmail.com
92 createdAt: 2026-11-10T23:41:38.000Z92 createdAt: 2026-11-10T23:41:38.000Z
93+ updatedAt: 2026-11-10T23:54:34.000Z
94+ closedAt: 2026-11-10T23:54:34.000Z
93 - id: 295 - id: 2
94 title: "Désactivé ou filtré : rien d'annoncé à initialize pour les outils retirés, -32601"96 title: "Désactivé ou filtré : rien d'annoncé à initialize pour les outils retirés, -32601"
95- state: open97+ state: closed
96 priority: high98 priority: high
97 author:99 author:
98 name: k33g100 name: k33g
99 email: ph.charriere@gmail.com101 email: ph.charriere@gmail.com
100 createdAt: 2026-11-10T23:41:38.000Z102 createdAt: 2026-11-10T23:41:38.000Z
103+ updatedAt: 2026-11-10T23:54:34.000Z
104+ closedAt: 2026-11-10T23:54:34.000Z
101 - id: 3105 - id: 3
102 title: "Outil list_channels"106 title: "Outil list_channels"
103- state: open107+ state: closed
104 priority: medium108 priority: medium
105 author:109 author:
106 name: k33g110 name: k33g
107 email: ph.charriere@gmail.com111 email: ph.charriere@gmail.com
108 createdAt: 2026-11-10T23:41:38.000Z112 createdAt: 2026-11-10T23:41:38.000Z
113+ updatedAt: 2026-11-10T23:54:34.000Z
114+ closedAt: 2026-11-10T23:54:34.000Z
109 - id: 4115 - id: 4
110 title: "Outil list_agents"116 title: "Outil list_agents"
111- state: open117+ state: closed
112 priority: medium118 priority: medium
113 author:119 author:
114 name: k33g120 name: k33g
115 email: ph.charriere@gmail.com121 email: ph.charriere@gmail.com
116 createdAt: 2026-11-10T23:41:38.000Z122 createdAt: 2026-11-10T23:41:38.000Z
123+ updatedAt: 2026-11-10T23:54:34.000Z
124+ closedAt: 2026-11-10T23:54:34.000Z
117 - id: 5125 - id: 5
118 title: "Outil search_messages (store : parcours des messages d'un channel, sans casse ni accents)"126 title: "Outil search_messages (store : parcours des messages d'un channel, sans casse ni accents)"
119- state: open127+ state: closed
120 priority: high128 priority: high
121 author:129 author:
122 name: k33g130 name: k33g
123 email: ph.charriere@gmail.com131 email: ph.charriere@gmail.com
124 createdAt: 2026-11-10T23:41:38.000Z132 createdAt: 2026-11-10T23:41:38.000Z
133+ updatedAt: 2026-11-10T23:54:34.000Z
134+ closedAt: 2026-11-10T23:54:34.000Z
125 - id: 6135 - id: 6
126 title: "Décider la portée : channels dont l'agent est membre ou tous"136 title: "Décider la portée : channels dont l'agent est membre ou tous"
127 state: closed137 state: closed
@@ -134,20 +144,24 @@ tasks:
134 closedAt: 2026-11-10T23:46:12.000Z144 closedAt: 2026-11-10T23:46:12.000Z
135 - id: 7145 - id: 7
136 title: "Tests ; essai avec Riker"146 title: "Tests ; essai avec Riker"
137- state: open147+ state: closed
138 priority: high148 priority: high
139 author:149 author:
140 name: k33g150 name: k33g
141 email: ph.charriere@gmail.com151 email: ph.charriere@gmail.com
142 createdAt: 2026-11-10T23:41:38.000Z152 createdAt: 2026-11-10T23:41:38.000Z
153+ updatedAt: 2026-11-10T23:54:34.000Z
154+ closedAt: 2026-11-10T23:54:34.000Z
143 - id: 8155 - id: 8
144 title: "Documentation EN + FR (config, référence, guide, explication)"156 title: "Documentation EN + FR (config, référence, guide, explication)"
145- state: open157+ state: closed
146 priority: medium158 priority: medium
147 author:159 author:
148 name: k33g160 name: k33g
149 email: ph.charriere@gmail.com161 email: ph.charriere@gmail.com
150 createdAt: 2026-11-10T23:41:38.000Z162 createdAt: 2026-11-10T23:41:38.000Z
163+ updatedAt: 2026-11-10T23:54:34.000Z
164+ closedAt: 2026-11-10T23:54:34.000Z
151 comments:165 comments:
152 - id: 1166 - id: 1
153 author:167 author:
@@ -157,4 +171,20 @@ comments:
157 body: |171 body: |
158 Décidé : un agent lit déjà l'historique des channels dont il est membre ; outils activés, il peut lister et172 Décidé : un agent lit déjà l'historique des channels dont il est membre ; outils activés, il peut lister et
159 chercher dans **tous** les channels. Pour restreindre, on filtre les outils proposés avec `agentTools.offer`.173 chercher dans **tous** les channels. Pour restreindre, on filtre les outils proposés avec `agentTools.offer`.
160-174+ - id: 2
175+ author:
176+ name: k33g
177+ email: ph.charriere@gmail.com
178+ createdAt: 2026-11-10T23:54:34.000Z
179+ body: |
180+ Fait.
181+ - Réglage `agentTools` ([internal/config/config.go](internal/config/config.go)) : `enabled` (défaut `true`) et
182+ `offer` (liste, absente : tous) ; `config.AgentToolNames` ; un nom inconnu est un avertissement ; schéma JSON
183+ (`examples` : l'éditeur Settings propose les noms après `- `) ; configuration par défaut.
184+ - Recherche et résumés : [internal/channels/search.go](internal/channels/search.go) (`Summaries`, `ChannelNamed`,
185+ `Search` : tout l'historique enregistré, sans casse ni accents, extrait de 80 caractères de chaque côté).
186+ - Outils `list_channels`, `list_agents`, `search_messages` : [internal/app/historytools.go](internal/app/historytools.go) ;
187+ filtre des six outils dans `clientTools`. Un outil retiré n'est ni annoncé ni répondu (`-32601`).
188+ - Tests : config (défaut, désactivé, filtre, liste vide, nom inconnu), recherche, résumés, outils, filtre.
189+ - Docs EN + FR : référence de la configuration (`agentTools`), référence des outils, guide, explication « Pourquoi ACP ».
190+ - Reste : l'essai avec Riker sur le Mac.
modified docs/en/explanation/why-acp.md +2 -0
@@ -23,6 +23,8 @@ ACP lets a client answer methods of its own (names starting with `_`), but says
2323
2424 Few ACP agents can use these tools. ACP defines how a client answers an extension method, not how an agent finds out which ones exist: discovering a client's tools and handing them to a model is a convention between the two sides, and each agent would need its own. mini-me has one, `acp.clientTools`, and its documentation describes it as a specification any client can implement; that is the one Sidekicks follows. Claude (`claude-agent-acp`), Codex (`codex-acp`), Gemini (`gemini --acp`) and docker-agent do not discover client tools today: they start and answer as before, without them. If another agent adopts a discovery convention, Sidekicks can answer it with the same tools, since only the way the list is announced differs.
2525
26+Some tools read Sidekicks' history (issue #91): the list of channels and a search in any of them. An agent already reads the history of the channels it is a member of, since it is told what it has not seen; these tools open the others too. That is deliberate: asking an agent "what did we decide about Lyon last week?" is useful precisely when the decision was taken elsewhere. The user keeps the choice with one setting, `agentTools`, on by default: off, or a list of the tools offered. It is global rather than per agent because a per-agent list would have to be kept in step with every agent added, for a need nobody has yet; it can come later. The search reads the stored messages one by one, since the store has no text index: a channel's history is small enough for it.
27+
2628 ## Rejected alternatives
2729
2830 - **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.
@@ -23,6 +23,8 @@ ACP lets a client answer methods of its own (names starting with `_`), but says
23 23
24 Few ACP agents can use these tools. ACP defines how a client answers an extension method, not how an agent finds out which ones exist: discovering a client's tools and handing them to a model is a convention between the two sides, and each agent would need its own. mini-me has one, `acp.clientTools`, and its documentation describes it as a specification any client can implement; that is the one Sidekicks follows. Claude (`claude-agent-acp`), Codex (`codex-acp`), Gemini (`gemini --acp`) and docker-agent do not discover client tools today: they start and answer as before, without them. If another agent adopts a discovery convention, Sidekicks can answer it with the same tools, since only the way the list is announced differs.24 Few ACP agents can use these tools. ACP defines how a client answers an extension method, not how an agent finds out which ones exist: discovering a client's tools and handing them to a model is a convention between the two sides, and each agent would need its own. mini-me has one, `acp.clientTools`, and its documentation describes it as a specification any client can implement; that is the one Sidekicks follows. Claude (`claude-agent-acp`), Codex (`codex-acp`), Gemini (`gemini --acp`) and docker-agent do not discover client tools today: they start and answer as before, without them. If another agent adopts a discovery convention, Sidekicks can answer it with the same tools, since only the way the list is announced differs.
25 25
26+Some tools read Sidekicks' history (issue #91): the list of channels and a search in any of them. An agent already reads the history of the channels it is a member of, since it is told what it has not seen; these tools open the others too. That is deliberate: asking an agent "what did we decide about Lyon last week?" is useful precisely when the decision was taken elsewhere. The user keeps the choice with one setting, `agentTools`, on by default: off, or a list of the tools offered. It is global rather than per agent because a per-agent list would have to be kept in step with every agent added, for a need nobody has yet; it can come later. The search reads the stored messages one by one, since the store has no text index: a channel's history is small enough for it.
27+
26 ## Rejected alternatives28 ## Rejected alternatives
27 29
28 - **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.30 - **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.
modified docs/en/how-to/use-sidekicks-tools-from-an-agent.md +19 -2
@@ -1,6 +1,6 @@
11 # How to let an agent use Sidekicks' tools
22
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. Few ACP agents can discover the tools of their client; mini-me can, which is why this guide uses it. It assumes the agent is already added (see [Add an agent](add-an-agent.md)) and started with `--acp --config <file>`.
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, the channel it is talking in, the list of channels and of agents, and a search in the history of any channel. Few ACP agents can discover the tools of their client; mini-me can, which is why this guide uses it. It assumes the agent is already added (see [Add an agent](add-an-agent.md)) and started with `--acp --config <file>`.
44
55 ## Steps
66
@@ -19,7 +19,10 @@ This guide shows how to let a mini-me agent (`mm`) call the tools Sidekicks offe
1919 3. Ask it, for instance in `#general`:
2020 - `@riker what is the memory pressure?` — it calls `client_memory_pressure`;
2121 - `@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`.
22+ - `@riker which channel are we in, and who is here?` — it calls `client_current_channel`;
23+ - `@riker list the channels` — it calls `client_list_channels`;
24+ - `@riker which agents are there?` — it calls `client_list_agents`;
25+ - `@riker what did we say about Lyon in #general?` — it calls `client_search_messages` with `query: Lyon` and `channel: general`.
2326
2427 The call shows in its answer like any tool call (`client: memory_pressure`), and in its log (`[acp] client tools (meta): …` at start).
2528
@@ -27,6 +30,20 @@ A small model calls a tool more readily when its instructions name it: add to it
2730
2831 ## Variants
2932
33+- **Choose the tools offered, or turn them off**: in **Settings**, add to the configuration of Sidekicks
34+
35+ ```yaml
36+ agentTools:
37+ enabled: true # false: no tool at all
38+ offer: # only these; without "offer", all of them
39+ - memory_pressure
40+ - current_channel
41+ - list_agents
42+ ```
43+
44+ then save and restart the agents (the tools are read when an agent starts). The editor suggests the names after `- `. An unknown name is shown as a warning.
45+- **Keep an agent to its own channels**: `list_channels` and `search_messages` read every channel and direct conversation, not only the agent's. Leave them out of `offer` if that is not wanted.
46+
3047 - **`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.
3148 - **`permissions: ask`**, or `auto` without `yolo: true`: each call asks the user first, with the usual permission card (`client: <name>`).
3249 - **Another agent** (Claude, Codex, Gemini, docker-agent): the tools are offered too, but these agents do not discover a client's tools and ignore them; they work as before. Few ACP agents can discover them today: mini-me can ([why](../explanation/why-acp.md#offering-tools-to-the-agents)).
@@ -1,6 +1,6 @@
1 # How to let an agent use Sidekicks' tools1 # How to let an agent use Sidekicks' tools
2 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. Few ACP agents can discover the tools of their client; mini-me can, which is why this guide uses it. It assumes the agent is already added (see [Add an agent](add-an-agent.md)) and started with `--acp --config <file>`.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, the channel it is talking in, the list of channels and of agents, and a search in the history of any channel. Few ACP agents can discover the tools of their client; mini-me can, which is why this guide uses it. It assumes the agent is already added (see [Add an agent](add-an-agent.md)) and started with `--acp --config <file>`.
4 4
5 ## Steps5 ## Steps
6 6
@@ -19,7 +19,10 @@ This guide shows how to let a mini-me agent (`mm`) call the tools Sidekicks offe
19 3. Ask it, for instance in `#general`:19 3. Ask it, for instance in `#general`:
20 - `@riker what is the memory pressure?` — it calls `client_memory_pressure`;20 - `@riker what is the memory pressure?` — it calls `client_memory_pressure`;
21 - `@riker what is Sidekicks?` — it calls `client_about_sidekicks`;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`.22+ - `@riker which channel are we in, and who is here?` — it calls `client_current_channel`;
23+ - `@riker list the channels` — it calls `client_list_channels`;
24+ - `@riker which agents are there?` — it calls `client_list_agents`;
25+ - `@riker what did we say about Lyon in #general?` — it calls `client_search_messages` with `query: Lyon` and `channel: general`.
23 26
24 The call shows in its answer like any tool call (`client: memory_pressure`), and in its log (`[acp] client tools (meta): …` at start).27 The call shows in its answer like any tool call (`client: memory_pressure`), and in its log (`[acp] client tools (meta): …` at start).
25 28
@@ -27,6 +30,20 @@ A small model calls a tool more readily when its instructions name it: add to it
27 30
28 ## Variants31 ## Variants
29 32
33+- **Choose the tools offered, or turn them off**: in **Settings**, add to the configuration of Sidekicks
34+
35+ ```yaml
36+ agentTools:
37+ enabled: true # false: no tool at all
38+ offer: # only these; without "offer", all of them
39+ - memory_pressure
40+ - current_channel
41+ - list_agents
42+ ```
43+
44+ then save and restart the agents (the tools are read when an agent starts). The editor suggests the names after `- `. An unknown name is shown as a warning.
45+- **Keep an agent to its own channels**: `list_channels` and `search_messages` read every channel and direct conversation, not only the agent's. Leave them out of `offer` if that is not wanted.
46+
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.47 - **`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>`).48 - **`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 discover a client's tools and ignore them; they work as before. Few ACP agents can discover them today: mini-me can ([why](../explanation/why-acp.md#offering-tools-to-the-agents)).49 - **Another agent** (Claude, Codex, Gemini, docker-agent): the tools are offered too, but these agents do not discover a client's tools and ignore them; they work as before. Few ACP agents can discover them today: mini-me can ([why](../explanation/why-acp.md#offering-tools-to-the-agents)).
modified docs/en/reference/agents-and-events.md +5 -2
@@ -237,15 +237,18 @@ A file opened for editing has `path, content, version`; `version` identifies the
237237
238238 ## Tools offered to the agents
239239
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. Few ACP agents discover a client's tools: among the agents Sidekicks documents, only mini-me does (not Claude, Codex, Gemini nor docker-agent).
240+Issues #90 and #91. Sidekicks offers every agent six tools, as [`agentTools`](configuration.md#agenttools) allows (all by default), 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. Few ACP agents discover a client's tools: among the agents Sidekicks documents, only mini-me does (not Claude, Codex, Gemini nor docker-agent).
241241
242242 | Tool (the model sees) | Method | Returns |
243243 | --- | --- | --- |
244244 | `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 |
245245 | `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+| `list_channels` (`client_list_channels`) | `_com.rickub.sidekicks/channels/list` | Every channel and direct conversation, oldest first: `#name: description. Members: @a (you), @b. 12 messages, the last on 2026-11-10 14:05.`, or `@alice (direct conversation between the user and @alice)` |
247+| `list_agents` (`client_list_agents`) | `_com.rickub.sidekicks/agents/list` | Every agent of the configuration: `@name (you), title: description. Runs on the user's computer` (or `in a Docker container`, `in an sbx sandbox`) `; ready.` (its state: `stopped`, `starting`, `ready`, `busy`, `error`) |
248+| `search_messages` (`client_search_messages`) | `_com.rickub.sidekicks/messages/search` | The user and agent messages of a channel that contain `query`, case and accents ignored, the most recent first: `- 2026-11-10 14:05, @alice: …excerpt around the match…` (80 characters on each side). Parameters: `query` (required), `channel` (`general`, `#general`, or `@alice` for a direct conversation; default: the channel of the call's session), `limit` (default 10, at most 50). The whole stored history is read, not only the messages shown. An unknown channel is an error that lists the channels |
246249 | `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 |
247250
248-None takes a parameter. The protocol:
251+Only `search_messages` takes parameters; its `inputSchema` says `query` is required. `list_channels` and `search_messages` read **every** channel, not only the ones the agent is a member of (it already reads those): leave them out of `agentTools.offer` when that is not wanted. A tool left out, or every tool with `enabled: false`, is not announced, and its method answers `-32601`. The protocol:
249252
250253 | Step | What Sidekicks does |
251254 | --- | --- |
@@ -237,15 +237,18 @@ A file opened for editing has `path, content, version`; `version` identifies the
237 237
238 ## Tools offered to the agents238 ## Tools offered to the agents
239 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. Few ACP agents discover a client's tools: among the agents Sidekicks documents, only mini-me does (not Claude, Codex, Gemini nor docker-agent).240+Issues #90 and #91. Sidekicks offers every agent six tools, as [`agentTools`](configuration.md#agenttools) allows (all by default), 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. Few ACP agents discover a client's tools: among the agents Sidekicks documents, only mini-me does (not Claude, Codex, Gemini nor docker-agent).
241 241
242 | Tool (the model sees) | Method | Returns |242 | Tool (the model sees) | Method | Returns |
243 | --- | --- | --- |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 |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 |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+| `list_channels` (`client_list_channels`) | `_com.rickub.sidekicks/channels/list` | Every channel and direct conversation, oldest first: `#name: description. Members: @a (you), @b. 12 messages, the last on 2026-11-10 14:05.`, or `@alice (direct conversation between the user and @alice)` |
247+| `list_agents` (`client_list_agents`) | `_com.rickub.sidekicks/agents/list` | Every agent of the configuration: `@name (you), title: description. Runs on the user's computer` (or `in a Docker container`, `in an sbx sandbox`) `; ready.` (its state: `stopped`, `starting`, `ready`, `busy`, `error`) |
248+| `search_messages` (`client_search_messages`) | `_com.rickub.sidekicks/messages/search` | The user and agent messages of a channel that contain `query`, case and accents ignored, the most recent first: `- 2026-11-10 14:05, @alice: …excerpt around the match…` (80 characters on each side). Parameters: `query` (required), `channel` (`general`, `#general`, or `@alice` for a direct conversation; default: the channel of the call's session), `limit` (default 10, at most 50). The whole stored history is read, not only the messages shown. An unknown channel is an error that lists the channels |
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 |249 | `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 250
248-None takes a parameter. The protocol:251+Only `search_messages` takes parameters; its `inputSchema` says `query` is required. `list_channels` and `search_messages` read **every** channel, not only the ones the agent is a member of (it already reads those): leave them out of `agentTools.offer` when that is not wanted. A tool left out, or every tool with `enabled: false`, is not announced, and its method answers `-32601`. The protocol:
249 252
250 | Step | What Sidekicks does |253 | Step | What Sidekicks does |
251 | --- | --- |254 | --- | --- |
modified docs/en/reference/configuration.md +20 -1
@@ -38,6 +38,7 @@ The file is looked up in this order; the first one that applies wins:
3838 | `version` | integer | yes | — | Format version; only `1` exists. A later format increments it, so Sidekicks can migrate or refuse an old file explicitly. |
3939 | `ui` | object | no | | Interface preferences. |
4040 | `limits` | object | no | | Resource limits. |
41+| `agentTools` | object | no | | The tools Sidekicks offers the agents ([below](#agenttools)). |
4142 | `agents` | list of agents | yes | | The agents available with `@name`. May be empty. |
4243 | `channels` | list of channels | no | `[]` | Channels created at startup when they do not exist yet. |
4344
@@ -58,6 +59,23 @@ Unknown keys are **errors**, at every level: a misspelt `comand:` must be report
5859 | `stopIdleAgentsAfter` | Go duration (`30s`, `10m`, `1h30m`), or `0` (number or text) | `10m` | Stops an agent unused for this long, to free its memory. `0` never stops it. |
5960 | `maxAgentHandoffs` | integer, 0 to 10 | `3` | In a channel, how many times one message may be handed from agent to agent: an agent whose answer mentions another member with `@name` gives it the floor ([Manage channels](../how-to/manage-channels.md#let-the-agents-call-each-other)). Once the limit is reached the chain stops, and says so. `0` turns it off. |
6061
62+### `agentTools`
63+
64+The tools Sidekicks offers the agents that can discover them: today, mini-me agents whose file has `acp.clientTools` ([Let an agent use Sidekicks' tools](../how-to/use-sidekicks-tools-from-an-agent.md)). Few ACP agents discover a client's tools; the others ignore them. Read when an agent starts: restart a running agent to apply a change.
65+
66+| Key | Type | Default | Meaning |
67+| --- | --- | --- | --- |
68+| `enabled` | boolean | `true` | `false`: no tool is offered; an agent that calls one anyway gets "Method not found". |
69+| `offer` | list of tool names | all | Only these tools are offered. The names: `memory_pressure`, `about_sidekicks`, `current_channel`, `list_channels`, `list_agents`, `search_messages` ([what each returns](agents-and-events.md#tools-offered-to-the-agents)). An unknown name is a warning; an empty list offers none. |
70+
71+`list_channels` and `search_messages` read **every** channel and direct conversation, not only those of the agent: leave them out of `offer` to keep an agent to its own channels.
72+
73+```yaml
74+agentTools:
75+ enabled: true
76+ offer: [memory_pressure, about_sidekicks, current_channel, list_agents]
77+```
78+
6179 ### An agent
6280
6381 | Key | Type | Required | Default | Meaning |
@@ -168,7 +186,8 @@ JSON Schema cannot express them; the configuration loader (issue #9) checks them
168186 1. agent names are unique;
169187 2. channel names are unique;
170188 3. every name in a channel's `agents` is the name of an agent;
171-4. `command` exists (in `PATH`, or as a file) — reported as a warning, since an agent may be installed later.
189+4. `command` exists (in `PATH`, or as a file) — reported as a warning, since an agent may be installed later;
190+5. every name of `agentTools.offer` is a tool — reported as a warning (`no tool is called "memory"; the tools are: …`): the other names still work.
172191
173192 ## Error messages
174193
@@ -38,6 +38,7 @@ The file is looked up in this order; the first one that applies wins:
38 | `version` | integer | yes | — | Format version; only `1` exists. A later format increments it, so Sidekicks can migrate or refuse an old file explicitly. |38 | `version` | integer | yes | — | Format version; only `1` exists. A later format increments it, so Sidekicks can migrate or refuse an old file explicitly. |
39 | `ui` | object | no | | Interface preferences. |39 | `ui` | object | no | | Interface preferences. |
40 | `limits` | object | no | | Resource limits. |40 | `limits` | object | no | | Resource limits. |
41+| `agentTools` | object | no | | The tools Sidekicks offers the agents ([below](#agenttools)). |
41 | `agents` | list of agents | yes | | The agents available with `@name`. May be empty. |42 | `agents` | list of agents | yes | | The agents available with `@name`. May be empty. |
42 | `channels` | list of channels | no | `[]` | Channels created at startup when they do not exist yet. |43 | `channels` | list of channels | no | `[]` | Channels created at startup when they do not exist yet. |
43 44
@@ -58,6 +59,23 @@ Unknown keys are **errors**, at every level: a misspelt `comand:` must be report
58 | `stopIdleAgentsAfter` | Go duration (`30s`, `10m`, `1h30m`), or `0` (number or text) | `10m` | Stops an agent unused for this long, to free its memory. `0` never stops it. |59 | `stopIdleAgentsAfter` | Go duration (`30s`, `10m`, `1h30m`), or `0` (number or text) | `10m` | Stops an agent unused for this long, to free its memory. `0` never stops it. |
59 | `maxAgentHandoffs` | integer, 0 to 10 | `3` | In a channel, how many times one message may be handed from agent to agent: an agent whose answer mentions another member with `@name` gives it the floor ([Manage channels](../how-to/manage-channels.md#let-the-agents-call-each-other)). Once the limit is reached the chain stops, and says so. `0` turns it off. |60 | `maxAgentHandoffs` | integer, 0 to 10 | `3` | In a channel, how many times one message may be handed from agent to agent: an agent whose answer mentions another member with `@name` gives it the floor ([Manage channels](../how-to/manage-channels.md#let-the-agents-call-each-other)). Once the limit is reached the chain stops, and says so. `0` turns it off. |
60 61
62+### `agentTools`
63+
64+The tools Sidekicks offers the agents that can discover them: today, mini-me agents whose file has `acp.clientTools` ([Let an agent use Sidekicks' tools](../how-to/use-sidekicks-tools-from-an-agent.md)). Few ACP agents discover a client's tools; the others ignore them. Read when an agent starts: restart a running agent to apply a change.
65+
66+| Key | Type | Default | Meaning |
67+| --- | --- | --- | --- |
68+| `enabled` | boolean | `true` | `false`: no tool is offered; an agent that calls one anyway gets "Method not found". |
69+| `offer` | list of tool names | all | Only these tools are offered. The names: `memory_pressure`, `about_sidekicks`, `current_channel`, `list_channels`, `list_agents`, `search_messages` ([what each returns](agents-and-events.md#tools-offered-to-the-agents)). An unknown name is a warning; an empty list offers none. |
70+
71+`list_channels` and `search_messages` read **every** channel and direct conversation, not only those of the agent: leave them out of `offer` to keep an agent to its own channels.
72+
73+```yaml
74+agentTools:
75+ enabled: true
76+ offer: [memory_pressure, about_sidekicks, current_channel, list_agents]
77+```
78+
61 ### An agent79 ### An agent
62 80
63 | Key | Type | Required | Default | Meaning |81 | Key | Type | Required | Default | Meaning |
@@ -168,7 +186,8 @@ JSON Schema cannot express them; the configuration loader (issue #9) checks them
168 1. agent names are unique;186 1. agent names are unique;
169 2. channel names are unique;187 2. channel names are unique;
170 3. every name in a channel's `agents` is the name of an agent;188 3. every name in a channel's `agents` is the name of an agent;
171-4. `command` exists (in `PATH`, or as a file) — reported as a warning, since an agent may be installed later.189+4. `command` exists (in `PATH`, or as a file) — reported as a warning, since an agent may be installed later;
190+5. every name of `agentTools.offer` is a tool — reported as a warning (`no tool is called "memory"; the tools are: …`): the other names still work.
172 191
173 ## Error messages192 ## Error messages
174 193
modified docs/fr/explanation/pourquoi-acp.md +2 -0
@@ -23,6 +23,8 @@ ACP permet à un client de répondre à ses propres méthodes (dont le nom comme
2323
2424 Peu d'agents ACP savent utiliser ces outils. ACP définit comment un client répond à une méthode d'extension, pas comment un agent apprend lesquelles existent : découvrir les outils d'un client et les donner à un modèle est une convention entre les deux côtés, et chaque agent aurait la sienne. mini-me en a une, `acp.clientTools`, que sa documentation décrit comme une spécification que tout client peut implémenter ; c'est celle que suit Sidekicks. Claude (`claude-agent-acp`), Codex (`codex-acp`), Gemini (`gemini --acp`) et docker-agent ne découvrent pas aujourd'hui les outils d'un client : ils démarrent et répondent comme avant, sans eux. Si un autre agent adopte une convention de découverte, Sidekicks pourra lui répondre avec les mêmes outils : seule la façon d'annoncer la liste change.
2525
26+Certains outils lisent l'historique de Sidekicks (ticket #91) : la liste des channels et une recherche dans n'importe lequel. Un agent lit déjà l'historique des channels dont il est membre, puisqu'on lui transmet ce qu'il n'a pas vu ; ces outils lui ouvrent aussi les autres. C'est voulu : demander à un agent « qu'avait-on décidé pour Lyon la semaine dernière ? » est utile justement quand la décision a été prise ailleurs. L'utilisateur garde le choix avec un seul réglage, `agentTools`, activé par défaut : désactivé, ou une liste des outils proposés. Il est global plutôt que par agent, car une liste par agent devrait être tenue à jour à chaque agent ajouté, pour un besoin que personne n'a encore ; elle pourra venir plus tard. La recherche lit les messages enregistrés un à un, faute d'index de texte dans le store : l'historique d'un channel est assez petit pour cela.
27+
2628 ## Alternatives écartées
2729
2830 - **É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.
@@ -23,6 +23,8 @@ ACP permet à un client de répondre à ses propres méthodes (dont le nom comme
23 23
24 Peu d'agents ACP savent utiliser ces outils. ACP définit comment un client répond à une méthode d'extension, pas comment un agent apprend lesquelles existent : découvrir les outils d'un client et les donner à un modèle est une convention entre les deux côtés, et chaque agent aurait la sienne. mini-me en a une, `acp.clientTools`, que sa documentation décrit comme une spécification que tout client peut implémenter ; c'est celle que suit Sidekicks. Claude (`claude-agent-acp`), Codex (`codex-acp`), Gemini (`gemini --acp`) et docker-agent ne découvrent pas aujourd'hui les outils d'un client : ils démarrent et répondent comme avant, sans eux. Si un autre agent adopte une convention de découverte, Sidekicks pourra lui répondre avec les mêmes outils : seule la façon d'annoncer la liste change.24 Peu d'agents ACP savent utiliser ces outils. ACP définit comment un client répond à une méthode d'extension, pas comment un agent apprend lesquelles existent : découvrir les outils d'un client et les donner à un modèle est une convention entre les deux côtés, et chaque agent aurait la sienne. mini-me en a une, `acp.clientTools`, que sa documentation décrit comme une spécification que tout client peut implémenter ; c'est celle que suit Sidekicks. Claude (`claude-agent-acp`), Codex (`codex-acp`), Gemini (`gemini --acp`) et docker-agent ne découvrent pas aujourd'hui les outils d'un client : ils démarrent et répondent comme avant, sans eux. Si un autre agent adopte une convention de découverte, Sidekicks pourra lui répondre avec les mêmes outils : seule la façon d'annoncer la liste change.
25 25
26+Certains outils lisent l'historique de Sidekicks (ticket #91) : la liste des channels et une recherche dans n'importe lequel. Un agent lit déjà l'historique des channels dont il est membre, puisqu'on lui transmet ce qu'il n'a pas vu ; ces outils lui ouvrent aussi les autres. C'est voulu : demander à un agent « qu'avait-on décidé pour Lyon la semaine dernière ? » est utile justement quand la décision a été prise ailleurs. L'utilisateur garde le choix avec un seul réglage, `agentTools`, activé par défaut : désactivé, ou une liste des outils proposés. Il est global plutôt que par agent, car une liste par agent devrait être tenue à jour à chaque agent ajouté, pour un besoin que personne n'a encore ; elle pourra venir plus tard. La recherche lit les messages enregistrés un à un, faute d'index de texte dans le store : l'historique d'un channel est assez petit pour cela.
27+
26 ## Alternatives écartées28 ## Alternatives écartées
27 29
28 - **É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.30 - **É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.
modified docs/fr/how-to/utiliser-les-outils-de-sidekicks-depuis-un-agent.md +19 -2
@@ -1,6 +1,6 @@
11 # Laisser un agent utiliser les outils de Sidekicks
22
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. Peu d'agents ACP savent découvrir les outils de leur client ; mini-me le sait, c'est pourquoi ce guide l'utilise. Il suppose l'agent déjà ajouté (voir [Ajouter un agent](ajouter-un-agent.md)) et démarré avec `--acp --config <fichier>`.
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, le channel où il parle, la liste des channels et des agents, et une recherche dans l'historique de n'importe quel channel. Peu d'agents ACP savent découvrir les outils de leur client ; mini-me le sait, c'est pourquoi ce guide l'utilise. Il suppose l'agent déjà ajouté (voir [Ajouter un agent](ajouter-un-agent.md)) et démarré avec `--acp --config <fichier>`.
44
55 ## Étapes
66
@@ -19,7 +19,10 @@ Ce guide montre comment laisser un agent mini-me (`mm`) appeler les outils que S
1919 3. Demandez-lui, par exemple dans `#general` :
2020 - `@riker quelle est la pression mémoire ?` — il appelle `client_memory_pressure` ;
2121 - `@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`.
22+ - `@riker dans quel channel sommes-nous, et qui est là ?` — il appelle `client_current_channel` ;
23+ - `@riker liste les channels` — il appelle `client_list_channels` ;
24+ - `@riker quels agents y a-t-il ?` — il appelle `client_list_agents` ;
25+ - `@riker qu'a-t-on dit sur Lyon dans #general ?` — il appelle `client_search_messages` avec `query: Lyon` et `channel: general`.
2326
2427 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).
2528
@@ -27,6 +30,20 @@ Un petit modèle appelle plus volontiers un outil que ses instructions nomment :
2730
2831 ## Variantes
2932
33+- **Choisir les outils proposés, ou les désactiver** : dans **Settings**, ajoutez à la configuration de Sidekicks
34+
35+ ```yaml
36+ agentTools:
37+ enabled: true # false : aucun outil
38+ offer: # seulement ceux-ci ; sans « offer », tous
39+ - memory_pressure
40+ - current_channel
41+ - list_agents
42+ ```
43+
44+ puis enregistrez et redémarrez les agents (les outils sont lus au démarrage d'un agent). L'éditeur propose les noms après `- `. Un nom inconnu s'affiche en avertissement.
45+- **Cantonner un agent à ses propres channels** : `list_channels` et `search_messages` lisent tous les channels et conversations directes, pas seulement ceux de l'agent. Retirez-les d'`offer` si ce n'est pas souhaité.
46+
3047 - **`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.
3148 - **`permissions: ask`**, ou `auto` sans `yolo: true` : chaque appel demande d'abord à l'utilisateur, avec la carte de permission habituelle (`client: <nom>`).
3249 - **Un autre agent** (Claude, Codex, Gemini, docker-agent) : les outils lui sont proposés aussi, mais ces agents ne découvrent pas les outils d'un client et les ignorent ; ils fonctionnent comme avant. Peu d'agents ACP savent les découvrir aujourd'hui : mini-me le sait ([pourquoi](../explanation/pourquoi-acp.md#proposer-des-outils-aux-agents)).
@@ -1,6 +1,6 @@
1 # Laisser un agent utiliser les outils de Sidekicks1 # Laisser un agent utiliser les outils de Sidekicks
2 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. Peu d'agents ACP savent découvrir les outils de leur client ; mini-me le sait, c'est pourquoi ce guide l'utilise. Il suppose l'agent déjà ajouté (voir [Ajouter un agent](ajouter-un-agent.md)) et démarré avec `--acp --config <fichier>`.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, le channel où il parle, la liste des channels et des agents, et une recherche dans l'historique de n'importe quel channel. Peu d'agents ACP savent découvrir les outils de leur client ; mini-me le sait, c'est pourquoi ce guide l'utilise. Il suppose l'agent déjà ajouté (voir [Ajouter un agent](ajouter-un-agent.md)) et démarré avec `--acp --config <fichier>`.
4 4
5 ## Étapes5 ## Étapes
6 6
@@ -19,7 +19,10 @@ Ce guide montre comment laisser un agent mini-me (`mm`) appeler les outils que S
19 3. Demandez-lui, par exemple dans `#general` :19 3. Demandez-lui, par exemple dans `#general` :
20 - `@riker quelle est la pression mémoire ?` — il appelle `client_memory_pressure` ;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` ;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`.22+ - `@riker dans quel channel sommes-nous, et qui est là ?` — il appelle `client_current_channel` ;
23+ - `@riker liste les channels` — il appelle `client_list_channels` ;
24+ - `@riker quels agents y a-t-il ?` — il appelle `client_list_agents` ;
25+ - `@riker qu'a-t-on dit sur Lyon dans #general ?` — il appelle `client_search_messages` avec `query: Lyon` et `channel: general`.
23 26
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).27 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 28
@@ -27,6 +30,20 @@ Un petit modèle appelle plus volontiers un outil que ses instructions nomment :
27 30
28 ## Variantes31 ## Variantes
29 32
33+- **Choisir les outils proposés, ou les désactiver** : dans **Settings**, ajoutez à la configuration de Sidekicks
34+
35+ ```yaml
36+ agentTools:
37+ enabled: true # false : aucun outil
38+ offer: # seulement ceux-ci ; sans « offer », tous
39+ - memory_pressure
40+ - current_channel
41+ - list_agents
42+ ```
43+
44+ puis enregistrez et redémarrez les agents (les outils sont lus au démarrage d'un agent). L'éditeur propose les noms après `- `. Un nom inconnu s'affiche en avertissement.
45+- **Cantonner un agent à ses propres channels** : `list_channels` et `search_messages` lisent tous les channels et conversations directes, pas seulement ceux de l'agent. Retirez-les d'`offer` si ce n'est pas souhaité.
46+
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.47 - **`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>`).48 - **`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 découvrent pas les outils d'un client et les ignorent ; ils fonctionnent comme avant. Peu d'agents ACP savent les découvrir aujourd'hui : mini-me le sait ([pourquoi](../explanation/pourquoi-acp.md#proposer-des-outils-aux-agents)).49 - **Un autre agent** (Claude, Codex, Gemini, docker-agent) : les outils lui sont proposés aussi, mais ces agents ne découvrent pas les outils d'un client et les ignorent ; ils fonctionnent comme avant. Peu d'agents ACP savent les découvrir aujourd'hui : mini-me le sait ([pourquoi](../explanation/pourquoi-acp.md#proposer-des-outils-aux-agents)).
modified docs/fr/reference/agents-et-evenements.md +5 -2
@@ -237,15 +237,18 @@ Un fichier ouvert pour modification a `path, content, version` ; `version` ident
237237
238238 ## Outils proposés aux agents
239239
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. Peu d'agents ACP découvrent les outils d'un client : parmi les agents que documente Sidekicks, seul mini-me le fait (ni Claude, ni Codex, ni Gemini, ni docker-agent).
240+Tickets #90 et #91. Sidekicks propose six outils à chaque agent, dans la limite de [`agentTools`](configuration.md#agenttools) (tous par défaut), 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. Peu d'agents ACP découvrent les outils d'un client : parmi les agents que documente Sidekicks, seul mini-me le fait (ni Claude, ni Codex, ni Gemini, ni docker-agent).
241241
242242 | Outil (le modèle voit) | Méthode | Renvoie |
243243 | --- | --- | --- |
244244 | `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 |
245245 | `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+| `list_channels` (`client_list_channels`) | `_com.rickub.sidekicks/channels/list` | Tous les channels et conversations directes, du plus ancien au plus récent : `#nom: description. Members: @a (you), @b. 12 messages, the last on 2026-11-10 14:05.`, ou `@alice (direct conversation between the user and @alice)` |
247+| `list_agents` (`client_list_agents`) | `_com.rickub.sidekicks/agents/list` | Tous les agents de la configuration : `@nom (you), titre: description. Runs on the user's computer` (ou `in a Docker container`, `in an sbx sandbox`) `; ready.` (son état : `stopped`, `starting`, `ready`, `busy`, `error`) |
248+| `search_messages` (`client_search_messages`) | `_com.rickub.sidekicks/messages/search` | Les messages de l'utilisateur et des agents d'un channel qui contiennent `query`, sans tenir compte de la casse ni des accents, du plus récent au plus ancien : `- 2026-11-10 14:05, @alice: …extrait autour du texte trouvé…` (80 caractères de chaque côté). Paramètres : `query` (obligatoire), `channel` (`general`, `#general`, ou `@alice` pour une conversation directe ; par défaut, le channel de la session de l'appel), `limit` (10 par défaut, 50 au plus). Tout l'historique enregistré est lu, pas seulement les messages affichés. Un channel inconnu est une erreur qui liste les channels |
246249 | `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 |
247250
248-Aucun n'a de paramètre. Le protocole :
251+Seul `search_messages` a des paramètres ; son `inputSchema` indique que `query` est obligatoire. `list_channels` et `search_messages` lisent **tous** les channels, pas seulement ceux dont l'agent est membre (il lit déjà ceux-là) : retirez-les d'`agentTools.offer` si ce n'est pas souhaité. Un outil retiré, ou tous les outils avec `enabled: false`, n'est pas annoncé, et sa méthode répond `-32601`. Le protocole :
249252
250253 | Étape | Ce que fait Sidekicks |
251254 | --- | --- |
@@ -237,15 +237,18 @@ Un fichier ouvert pour modification a `path, content, version` ; `version` ident
237 237
238 ## Outils proposés aux agents238 ## Outils proposés aux agents
239 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. Peu d'agents ACP découvrent les outils d'un client : parmi les agents que documente Sidekicks, seul mini-me le fait (ni Claude, ni Codex, ni Gemini, ni docker-agent).240+Tickets #90 et #91. Sidekicks propose six outils à chaque agent, dans la limite de [`agentTools`](configuration.md#agenttools) (tous par défaut), 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. Peu d'agents ACP découvrent les outils d'un client : parmi les agents que documente Sidekicks, seul mini-me le fait (ni Claude, ni Codex, ni Gemini, ni docker-agent).
241 241
242 | Outil (le modèle voit) | Méthode | Renvoie |242 | Outil (le modèle voit) | Méthode | Renvoie |
243 | --- | --- | --- |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 |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 |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+| `list_channels` (`client_list_channels`) | `_com.rickub.sidekicks/channels/list` | Tous les channels et conversations directes, du plus ancien au plus récent : `#nom: description. Members: @a (you), @b. 12 messages, the last on 2026-11-10 14:05.`, ou `@alice (direct conversation between the user and @alice)` |
247+| `list_agents` (`client_list_agents`) | `_com.rickub.sidekicks/agents/list` | Tous les agents de la configuration : `@nom (you), titre: description. Runs on the user's computer` (ou `in a Docker container`, `in an sbx sandbox`) `; ready.` (son état : `stopped`, `starting`, `ready`, `busy`, `error`) |
248+| `search_messages` (`client_search_messages`) | `_com.rickub.sidekicks/messages/search` | Les messages de l'utilisateur et des agents d'un channel qui contiennent `query`, sans tenir compte de la casse ni des accents, du plus récent au plus ancien : `- 2026-11-10 14:05, @alice: …extrait autour du texte trouvé…` (80 caractères de chaque côté). Paramètres : `query` (obligatoire), `channel` (`general`, `#general`, ou `@alice` pour une conversation directe ; par défaut, le channel de la session de l'appel), `limit` (10 par défaut, 50 au plus). Tout l'historique enregistré est lu, pas seulement les messages affichés. Un channel inconnu est une erreur qui liste les channels |
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 |249 | `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 250
248-Aucun n'a de paramètre. Le protocole :251+Seul `search_messages` a des paramètres ; son `inputSchema` indique que `query` est obligatoire. `list_channels` et `search_messages` lisent **tous** les channels, pas seulement ceux dont l'agent est membre (il lit déjà ceux-là) : retirez-les d'`agentTools.offer` si ce n'est pas souhaité. Un outil retiré, ou tous les outils avec `enabled: false`, n'est pas annoncé, et sa méthode répond `-32601`. Le protocole :
249 252
250 | Étape | Ce que fait Sidekicks |253 | Étape | Ce que fait Sidekicks |
251 | --- | --- |254 | --- | --- |
modified docs/fr/reference/configuration.md +20 -1
@@ -38,6 +38,7 @@ Le fichier est cherché dans cet ordre ; la première source applicable l'emport
3838 | `version` | entier | oui | — | Version du format ; seule `1` existe. Un format ultérieur l'incrémente, pour que Sidekicks puisse migrer ou refuser explicitement un ancien fichier. |
3939 | `ui` | objet | non | | Préférences d'interface. |
4040 | `limits` | objet | non | | Limites de ressources. |
41+| `agentTools` | objet | non | | Les outils que Sidekicks propose aux agents ([plus bas](#agenttools)). |
4142 | `agents` | liste d'agents | oui | | Les agents disponibles avec `@nom`. Peut être vide. |
4243 | `channels` | liste de channels | non | `[]` | Channels créés au démarrage s'ils n'existent pas encore. |
4344
@@ -58,6 +59,23 @@ Les clés inconnues sont des **erreurs**, à tous les niveaux : une faute de fra
5859 | `stopIdleAgentsAfter` | durée Go (`30s`, `10m`, `1h30m`), ou `0` (nombre ou texte) | `10m` | Arrête un agent inutilisé depuis ce délai pour libérer sa mémoire. `0` ne l'arrête jamais. |
5960 | `maxAgentHandoffs` | entier, de 0 à 10 | `3` | Dans un channel, combien de fois un même message peut passer d'agent en agent : un agent dont la réponse mentionne un autre membre avec `@nom` lui passe la parole ([Gérer les channels](../how-to/gerer-les-channels.md#laisser-les-agents-sappeler-entre-eux)). La limite atteinte, la chaîne s'arrête et le dit. `0` désactive. |
6061
62+### `agentTools`
63+
64+Les outils que Sidekicks propose aux agents capables de les découvrir : aujourd'hui, les agents mini-me dont le fichier contient `acp.clientTools` ([Laisser un agent utiliser les outils de Sidekicks](../how-to/utiliser-les-outils-de-sidekicks-depuis-un-agent.md)). Peu d'agents ACP découvrent les outils d'un client ; les autres les ignorent. Lu au démarrage d'un agent : redémarrez un agent en marche pour appliquer un changement.
65+
66+| Clé | Type | Défaut | Signification |
67+| --- | --- | --- | --- |
68+| `enabled` | booléen | `true` | `false` : aucun outil n'est proposé ; un agent qui en appelle un quand même reçoit « Method not found ». |
69+| `offer` | liste de noms d'outils | tous | Seulement ces outils sont proposés. Les noms : `memory_pressure`, `about_sidekicks`, `current_channel`, `list_channels`, `list_agents`, `search_messages` ([ce que renvoie chacun](agents-et-evenements.md#outils-proposés-aux-agents)). Un nom inconnu est un avertissement ; une liste vide n'en propose aucun. |
70+
71+`list_channels` et `search_messages` lisent **tous** les channels et conversations directes, pas seulement ceux de l'agent : retirez-les d'`offer` pour cantonner un agent à ses propres channels.
72+
73+```yaml
74+agentTools:
75+ enabled: true
76+ offer: [memory_pressure, about_sidekicks, current_channel, list_agents]
77+```
78+
6179 ### Un agent
6280
6381 | Clé | Type | Obligatoire | Défaut | Signification |
@@ -168,7 +186,8 @@ JSON Schema ne sait pas les exprimer ; le chargeur de configuration (issue #9) l
168186 1. les noms d'agents sont uniques ;
169187 2. les noms de channels sont uniques ;
170188 3. chaque nom de la liste `agents` d'un channel est le nom d'un agent ;
171-4. `command` existe (dans le `PATH`, ou comme fichier) — signalé comme avertissement, car un agent peut être installé plus tard.
189+4. `command` existe (dans le `PATH`, ou comme fichier) — signalé comme avertissement, car un agent peut être installé plus tard ;
190+5. chaque nom d'`agentTools.offer` est un outil — signalé comme avertissement (`aucun outil ne s'appelle « memory » ; outils connus : …`) : les autres noms fonctionnent.
172191
173192 ## Messages d'erreur
174193
@@ -38,6 +38,7 @@ Le fichier est cherché dans cet ordre ; la première source applicable l'emport
38 | `version` | entier | oui | — | Version du format ; seule `1` existe. Un format ultérieur l'incrémente, pour que Sidekicks puisse migrer ou refuser explicitement un ancien fichier. |38 | `version` | entier | oui | — | Version du format ; seule `1` existe. Un format ultérieur l'incrémente, pour que Sidekicks puisse migrer ou refuser explicitement un ancien fichier. |
39 | `ui` | objet | non | | Préférences d'interface. |39 | `ui` | objet | non | | Préférences d'interface. |
40 | `limits` | objet | non | | Limites de ressources. |40 | `limits` | objet | non | | Limites de ressources. |
41+| `agentTools` | objet | non | | Les outils que Sidekicks propose aux agents ([plus bas](#agenttools)). |
41 | `agents` | liste d'agents | oui | | Les agents disponibles avec `@nom`. Peut être vide. |42 | `agents` | liste d'agents | oui | | Les agents disponibles avec `@nom`. Peut être vide. |
42 | `channels` | liste de channels | non | `[]` | Channels créés au démarrage s'ils n'existent pas encore. |43 | `channels` | liste de channels | non | `[]` | Channels créés au démarrage s'ils n'existent pas encore. |
43 44
@@ -58,6 +59,23 @@ Les clés inconnues sont des **erreurs**, à tous les niveaux : une faute de fra
58 | `stopIdleAgentsAfter` | durée Go (`30s`, `10m`, `1h30m`), ou `0` (nombre ou texte) | `10m` | Arrête un agent inutilisé depuis ce délai pour libérer sa mémoire. `0` ne l'arrête jamais. |59 | `stopIdleAgentsAfter` | durée Go (`30s`, `10m`, `1h30m`), ou `0` (nombre ou texte) | `10m` | Arrête un agent inutilisé depuis ce délai pour libérer sa mémoire. `0` ne l'arrête jamais. |
59 | `maxAgentHandoffs` | entier, de 0 à 10 | `3` | Dans un channel, combien de fois un même message peut passer d'agent en agent : un agent dont la réponse mentionne un autre membre avec `@nom` lui passe la parole ([Gérer les channels](../how-to/gerer-les-channels.md#laisser-les-agents-sappeler-entre-eux)). La limite atteinte, la chaîne s'arrête et le dit. `0` désactive. |60 | `maxAgentHandoffs` | entier, de 0 à 10 | `3` | Dans un channel, combien de fois un même message peut passer d'agent en agent : un agent dont la réponse mentionne un autre membre avec `@nom` lui passe la parole ([Gérer les channels](../how-to/gerer-les-channels.md#laisser-les-agents-sappeler-entre-eux)). La limite atteinte, la chaîne s'arrête et le dit. `0` désactive. |
60 61
62+### `agentTools`
63+
64+Les outils que Sidekicks propose aux agents capables de les découvrir : aujourd'hui, les agents mini-me dont le fichier contient `acp.clientTools` ([Laisser un agent utiliser les outils de Sidekicks](../how-to/utiliser-les-outils-de-sidekicks-depuis-un-agent.md)). Peu d'agents ACP découvrent les outils d'un client ; les autres les ignorent. Lu au démarrage d'un agent : redémarrez un agent en marche pour appliquer un changement.
65+
66+| Clé | Type | Défaut | Signification |
67+| --- | --- | --- | --- |
68+| `enabled` | booléen | `true` | `false` : aucun outil n'est proposé ; un agent qui en appelle un quand même reçoit « Method not found ». |
69+| `offer` | liste de noms d'outils | tous | Seulement ces outils sont proposés. Les noms : `memory_pressure`, `about_sidekicks`, `current_channel`, `list_channels`, `list_agents`, `search_messages` ([ce que renvoie chacun](agents-et-evenements.md#outils-proposés-aux-agents)). Un nom inconnu est un avertissement ; une liste vide n'en propose aucun. |
70+
71+`list_channels` et `search_messages` lisent **tous** les channels et conversations directes, pas seulement ceux de l'agent : retirez-les d'`offer` pour cantonner un agent à ses propres channels.
72+
73+```yaml
74+agentTools:
75+ enabled: true
76+ offer: [memory_pressure, about_sidekicks, current_channel, list_agents]
77+```
78+
61 ### Un agent79 ### Un agent
62 80
63 | Clé | Type | Obligatoire | Défaut | Signification |81 | Clé | Type | Obligatoire | Défaut | Signification |
@@ -168,7 +186,8 @@ JSON Schema ne sait pas les exprimer ; le chargeur de configuration (issue #9) l
168 1. les noms d'agents sont uniques ;186 1. les noms d'agents sont uniques ;
169 2. les noms de channels sont uniques ;187 2. les noms de channels sont uniques ;
170 3. chaque nom de la liste `agents` d'un channel est le nom d'un agent ;188 3. chaque nom de la liste `agents` d'un channel est le nom d'un agent ;
171-4. `command` existe (dans le `PATH`, ou comme fichier) — signalé comme avertissement, car un agent peut être installé plus tard.189+4. `command` existe (dans le `PATH`, ou comme fichier) — signalé comme avertissement, car un agent peut être installé plus tard ;
190+5. chaque nom d'`agentTools.offer` est un outil — signalé comme avertissement (`aucun outil ne s'appelle « memory » ; outils connus : …`) : les autres noms fonctionnent.
172 191
173 ## Messages d'erreur192 ## Messages d'erreur
174 193
modified frontend/src/lib/yamlSchema.test.ts +10 -1
@@ -11,7 +11,8 @@ const labels = (suggestions: Array<{ label: string }>) => suggestions.map((sugge
1111
1212 describe('createSchemaIndex', () => {
1313 it('lists the keys of the schema, following $ref and list items', () => {
14- expect(labels(schema.keysAt([]))).toEqual(['version', 'ui', 'limits', 'agents', 'channels'])
14+ expect(labels(schema.keysAt([]))).toEqual(['version', 'ui', 'limits', 'agentTools', 'agents', 'channels'])
15+ expect(labels(schema.keysAt(['agentTools']))).toEqual(['enabled', 'offer'])
1516 expect(labels(schema.keysAt(['agents', item]))).toContain('workspace')
1617 expect(labels(schema.keysAt(['agents', item, 'runtime']))).toEqual(['type', 'container', 'sandbox', 'workspacePath', 'lifecycle'])
1718 expect(labels(schema.keysAt(['agents', item, 'runtime', 'lifecycle']))).toEqual(['folder', 'create', 'stop', 'remove'])
@@ -71,6 +72,14 @@ describe('suggestionsAt', () => {
7172 expect(labels(result.options)).toEqual(['system', 'light', 'dark'])
7273 })
7374
75+ it('suggests the tools in the list of agentTools.offer', () => {
76+ const result = suggestionsAt(schema, ['agentTools:', ' offer:', ' - mem'], 2, 9)!
77+ expect(result.kind).toBe('value')
78+ expect(result.word).toBe('mem')
79+ expect(labels(result.options)).toContain('memory_pressure')
80+ expect(labels(result.options)).toContain('search_messages')
81+ })
82+
7483 it('suggests nothing in the middle of a value', () => {
7584 expect(suggestionsAt(schema, ['agents:', ' - name: alice smith'], 1, 20)).toBeNull()
7685 })
@@ -11,7 +11,8 @@ const labels = (suggestions: Array<{ label: string }>) => suggestions.map((sugge
11 11
12 describe('createSchemaIndex', () => {12 describe('createSchemaIndex', () => {
13 it('lists the keys of the schema, following $ref and list items', () => {13 it('lists the keys of the schema, following $ref and list items', () => {
14- expect(labels(schema.keysAt([]))).toEqual(['version', 'ui', 'limits', 'agents', 'channels'])14+ expect(labels(schema.keysAt([]))).toEqual(['version', 'ui', 'limits', 'agentTools', 'agents', 'channels'])
15+ expect(labels(schema.keysAt(['agentTools']))).toEqual(['enabled', 'offer'])
15 expect(labels(schema.keysAt(['agents', item]))).toContain('workspace')16 expect(labels(schema.keysAt(['agents', item]))).toContain('workspace')
16 expect(labels(schema.keysAt(['agents', item, 'runtime']))).toEqual(['type', 'container', 'sandbox', 'workspacePath', 'lifecycle'])17 expect(labels(schema.keysAt(['agents', item, 'runtime']))).toEqual(['type', 'container', 'sandbox', 'workspacePath', 'lifecycle'])
17 expect(labels(schema.keysAt(['agents', item, 'runtime', 'lifecycle']))).toEqual(['folder', 'create', 'stop', 'remove'])18 expect(labels(schema.keysAt(['agents', item, 'runtime', 'lifecycle']))).toEqual(['folder', 'create', 'stop', 'remove'])
@@ -71,6 +72,14 @@ describe('suggestionsAt', () => {
71 expect(labels(result.options)).toEqual(['system', 'light', 'dark'])72 expect(labels(result.options)).toEqual(['system', 'light', 'dark'])
72 })73 })
73 74
75+ it('suggests the tools in the list of agentTools.offer', () => {
76+ const result = suggestionsAt(schema, ['agentTools:', ' offer:', ' - mem'], 2, 9)!
77+ expect(result.kind).toBe('value')
78+ expect(result.word).toBe('mem')
79+ expect(labels(result.options)).toContain('memory_pressure')
80+ expect(labels(result.options)).toContain('search_messages')
81+ })
82+
74 it('suggests nothing in the middle of a value', () => {83 it('suggests nothing in the middle of a value', () => {
75 expect(suggestionsAt(schema, ['agents:', ' - name: alice smith'], 1, 20)).toBeNull()84 expect(suggestionsAt(schema, ['agents:', ' - name: alice smith'], 1, 20)).toBeNull()
76 })85 })
modified frontend/src/lib/yamlSchema.ts +11 -3
@@ -12,6 +12,8 @@ interface SchemaNode {
1212 items?: SchemaNode
1313 enum?: unknown[]
1414 const?: unknown
15+ /** Values worth suggesting without forbidding others (agentTools.offer). */
16+ examples?: unknown[]
1517 $defs?: Record<string, SchemaNode>
1618 }
1719
@@ -55,7 +57,7 @@ export function createSchemaIndex(root: SchemaNode) {
5557 },
5658 valuesAt(path: string[]): Suggestion[] {
5759 const node = nodeAt(path)
58- const values = node?.enum ?? (node?.const !== undefined ? [node.const] : [])
60+ const values = node?.enum ?? (node?.const !== undefined ? [node.const] : (node?.examples ?? []))
5961 return values.map((value) => ({ label: String(value) }))
6062 },
6163 }
@@ -107,7 +109,8 @@ export function contextPath(lines: string[], lineIndex: number): string[] {
107109
108110 /**
109111 * What to suggest at the caret: keys at the start of a line (possibly after
110- * "- "), or the values of the key on the left of "key: ".
112+ * "- "), the values of a list of plain values after "- ", or the values of
113+ * the key on the left of "key: ".
111114 */
112115 export function suggestionsAt(index: ReturnType<typeof createSchemaIndex>, lines: string[], lineIndex: number, column: number) {
113116 const before = (lines[lineIndex] ?? '').slice(0, column)
@@ -118,7 +121,12 @@ export function suggestionsAt(index: ReturnType<typeof createSchemaIndex>, lines
118121 }
119122 const key = /^\s*(?:-\s+)?([A-Za-z_][\w-]*)?$/.exec(before)
120123 if (key) {
121- return { kind: 'key' as const, word: key[1] ?? '', options: index.keysAt(contextPath([...lines.slice(0, lineIndex), before], lineIndex)) }
124+ const path = contextPath([...lines.slice(0, lineIndex), before], lineIndex)
125+ const keys = index.keysAt(path)
126+ if (keys.length === 0 && /^\s*-\s+/.test(before)) {
127+ return { kind: 'value' as const, word: key[1] ?? '', options: index.valuesAt(path) }
128+ }
129+ return { kind: 'key' as const, word: key[1] ?? '', options: keys }
122130 }
123131 return null
124132 }
@@ -12,6 +12,8 @@ interface SchemaNode {
12 items?: SchemaNode12 items?: SchemaNode
13 enum?: unknown[]13 enum?: unknown[]
14 const?: unknown14 const?: unknown
15+ /** Values worth suggesting without forbidding others (agentTools.offer). */
16+ examples?: unknown[]
15 $defs?: Record<string, SchemaNode>17 $defs?: Record<string, SchemaNode>
16 }18 }
17 19
@@ -55,7 +57,7 @@ export function createSchemaIndex(root: SchemaNode) {
55 },57 },
56 valuesAt(path: string[]): Suggestion[] {58 valuesAt(path: string[]): Suggestion[] {
57 const node = nodeAt(path)59 const node = nodeAt(path)
58- const values = node?.enum ?? (node?.const !== undefined ? [node.const] : [])60+ const values = node?.enum ?? (node?.const !== undefined ? [node.const] : (node?.examples ?? []))
59 return values.map((value) => ({ label: String(value) }))61 return values.map((value) => ({ label: String(value) }))
60 },62 },
61 }63 }
@@ -107,7 +109,8 @@ export function contextPath(lines: string[], lineIndex: number): string[] {
107 109
108 /**110 /**
109 * What to suggest at the caret: keys at the start of a line (possibly after111 * What to suggest at the caret: keys at the start of a line (possibly after
110- * "- "), or the values of the key on the left of "key: ".112+ * "- "), the values of a list of plain values after "- ", or the values of
113+ * the key on the left of "key: ".
111 */114 */
112 export function suggestionsAt(index: ReturnType<typeof createSchemaIndex>, lines: string[], lineIndex: number, column: number) {115 export function suggestionsAt(index: ReturnType<typeof createSchemaIndex>, lines: string[], lineIndex: number, column: number) {
113 const before = (lines[lineIndex] ?? '').slice(0, column)116 const before = (lines[lineIndex] ?? '').slice(0, column)
@@ -118,7 +121,12 @@ export function suggestionsAt(index: ReturnType<typeof createSchemaIndex>, lines
118 }121 }
119 const key = /^\s*(?:-\s+)?([A-Za-z_][\w-]*)?$/.exec(before)122 const key = /^\s*(?:-\s+)?([A-Za-z_][\w-]*)?$/.exec(before)
120 if (key) {123 if (key) {
121- return { kind: 'key' as const, word: key[1] ?? '', options: index.keysAt(contextPath([...lines.slice(0, lineIndex), before], lineIndex)) }124+ const path = contextPath([...lines.slice(0, lineIndex), before], lineIndex)
125+ const keys = index.keysAt(path)
126+ if (keys.length === 0 && /^\s*-\s+/.test(before)) {
127+ return { kind: 'value' as const, word: key[1] ?? '', options: index.valuesAt(path) }
128+ }
129+ return { kind: 'key' as const, word: key[1] ?? '', options: keys }
122 }130 }
123 return null131 return null
124 }132 }
modified internal/app/clienttools.go +36 -10
@@ -16,9 +16,10 @@ import (
1616 "go.yaml.in/yaml/v3"
1717 )
1818
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.
19+// The tools Sidekicks offers every agent (issues #90 and #91), as
20+// agentTools in the configuration allows. An agent that knows the protocol
21+// of mini-me (acp.clientTools in its file) gives them to its model as
22+// client_<name>; the others ignore them.
2223
2324 // ReleasesURL is where Sidekicks is published.
2425 const ReleasesURL = "https://rickub.com/bots-garden/sidekicks/releases"
@@ -30,9 +31,36 @@ const (
3031 ChannelMethod = "_com.rickub.sidekicks/channel/current"
3132 )
3233
33-// clientTools are the tools offered to the agent of definition.
34+// clientTools are the tools offered to the agent of definition: the ones
35+// agentTools of the current configuration offers, read when it starts.
3436 func (c *Core) clientTools(definition config.Agent) []acp.Tool {
35- agent := definition.Name
37+ c.mu.Lock()
38+ settings := config.AgentTools{Enabled: true}
39+ if c.cfg != nil {
40+ settings = c.cfg.AgentTools
41+ }
42+ c.mu.Unlock()
43+ var offered []acp.Tool
44+ for _, tool := range append(c.systemTools(definition.Name), c.historyTools(definition.Name)...) {
45+ if settings.Offers(tool.Name) {
46+ offered = append(offered, tool)
47+ }
48+ }
49+ return offered
50+}
51+
52+// channelManager is the channels' manager, nil before it is open.
53+func (c *Core) channelManager() (*channels.Manager, error) {
54+ c.mu.Lock()
55+ defer c.mu.Unlock()
56+ if c.channels == nil {
57+ return nil, errors.New("no channel is open in Sidekicks")
58+ }
59+ return c.channels, nil
60+}
61+
62+// systemTools tell about the computer, Sidekicks and the current channel (issue #90).
63+func (c *Core) systemTools(agent string) []acp.Tool {
3664 return []acp.Tool{
3765 {
3866 Name: "memory_pressure",
@@ -59,11 +87,9 @@ func (c *Core) clientTools(definition config.Agent) []acp.Tool {
5987 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.",
6088 Method: ChannelMethod,
6189 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")
90+ manager, err := c.channelManager()
91+ if err != nil {
92+ return "", err
6793 }
6894 channel, ok := manager.SessionChannel(agent, sessionID)
6995 if !ok {
@@ -16,9 +16,10 @@ import (
16 "go.yaml.in/yaml/v3"16 "go.yaml.in/yaml/v3"
17 )17 )
18 18
19-// The tools Sidekicks offers every agent (issue #90). An agent that knows19+// The tools Sidekicks offers every agent (issues #90 and #91), as
20-// the protocol of mini-me (acp.clientTools in its file) gives them to its20+// agentTools in the configuration allows. An agent that knows the protocol
21-// model as client_<name>; the others ignore them.21+// of mini-me (acp.clientTools in its file) gives them to its model as
22+// client_<name>; the others ignore them.
22 23
23 // ReleasesURL is where Sidekicks is published.24 // ReleasesURL is where Sidekicks is published.
24 const ReleasesURL = "https://rickub.com/bots-garden/sidekicks/releases"25 const ReleasesURL = "https://rickub.com/bots-garden/sidekicks/releases"
@@ -30,9 +31,36 @@ const (
30 ChannelMethod = "_com.rickub.sidekicks/channel/current"31 ChannelMethod = "_com.rickub.sidekicks/channel/current"
31 )32 )
32 33
33-// clientTools are the tools offered to the agent of definition.34+// clientTools are the tools offered to the agent of definition: the ones
35+// agentTools of the current configuration offers, read when it starts.
34 func (c *Core) clientTools(definition config.Agent) []acp.Tool {36 func (c *Core) clientTools(definition config.Agent) []acp.Tool {
35- agent := definition.Name37+ c.mu.Lock()
38+ settings := config.AgentTools{Enabled: true}
39+ if c.cfg != nil {
40+ settings = c.cfg.AgentTools
41+ }
42+ c.mu.Unlock()
43+ var offered []acp.Tool
44+ for _, tool := range append(c.systemTools(definition.Name), c.historyTools(definition.Name)...) {
45+ if settings.Offers(tool.Name) {
46+ offered = append(offered, tool)
47+ }
48+ }
49+ return offered
50+}
51+
52+// channelManager is the channels' manager, nil before it is open.
53+func (c *Core) channelManager() (*channels.Manager, error) {
54+ c.mu.Lock()
55+ defer c.mu.Unlock()
56+ if c.channels == nil {
57+ return nil, errors.New("no channel is open in Sidekicks")
58+ }
59+ return c.channels, nil
60+}
61+
62+// systemTools tell about the computer, Sidekicks and the current channel (issue #90).
63+func (c *Core) systemTools(agent string) []acp.Tool {
36 return []acp.Tool{64 return []acp.Tool{
37 {65 {
38 Name: "memory_pressure",66 Name: "memory_pressure",
@@ -59,11 +87,9 @@ func (c *Core) clientTools(definition config.Agent) []acp.Tool {
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.",87 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,88 Method: ChannelMethod,
61 Call: func(_ context.Context, sessionID string, _ map[string]any) (string, error) {89 Call: func(_ context.Context, sessionID string, _ map[string]any) (string, error) {
62- c.mu.Lock()90+ manager, err := c.channelManager()
63- manager := c.channels91+ if err != nil {
64- c.mu.Unlock()92+ return "", err
65- if manager == nil {
66- return "", errors.New("no channel is open in Sidekicks")
67 }93 }
68 channel, ok := manager.SessionChannel(agent, sessionID)94 channel, ok := manager.SessionChannel(agent, sessionID)
69 if !ok {95 if !ok {
modified internal/app/clienttools_test.go +57 -6
@@ -21,12 +21,13 @@ import (
2121
2222 // Issue #90: the tools Sidekicks offers the agents.
2323
24-// offeredTools has riker answer in #general and returns how it was started.
25-func offeredTools(t *testing.T) acp.Spec {
24+// offeredTools has riker answer in #general, with settings (YAML) in the
25+// configuration, and returns how it was started.
26+func offeredTools(t *testing.T, settings string) acp.Spec {
2627 t.Helper()
2728 directory := t.TempDir()
2829 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+ write(t, path, "version: 1\n"+settings+"agents:\n - name: riker\n command: mm\n args: [--acp, --config, agent.yaml]\n workspace: riker\n")
3031 var mu sync.Mutex
3132 var spec acp.Spec
3233 start := func(_ context.Context, started acp.Spec, _ func(string)) (agents.Conn, error) {
@@ -62,8 +63,8 @@ func offeredTools(t *testing.T) acp.Spec {
6263 }
6364
6465 func TestTheAgentsAreOfferedSidekicksTools(t *testing.T) {
65- spec := offeredTools(t)
66- if spec.ClientVersion != "1.4.0" || spec.ToolDiscovery != acp.DiscoveryMeta || len(spec.Tools) != 3 {
66+ spec := offeredTools(t, "")
67+ if spec.ClientVersion != "1.4.0" || spec.ToolDiscovery != acp.DiscoveryMeta || len(spec.Tools) != 6 {
6768 t.Fatalf("spec: version %q, discovery %q, %d tools", spec.ClientVersion, spec.ToolDiscovery, len(spec.Tools))
6869 }
6970 for _, tool := range spec.Tools {
@@ -75,7 +76,7 @@ func TestTheAgentsAreOfferedSidekicksTools(t *testing.T) {
7576
7677 func TestTheToolsAnswerForTheCallersSession(t *testing.T) {
7778 tools := map[string]acp.Tool{}
78- for _, tool := range offeredTools(t).Tools {
79+ for _, tool := range offeredTools(t, "").Tools {
7980 tools[tool.Name] = tool
8081 }
8182 text, err := tools["current_channel"].Call(context.Background(), "s-1", nil)
@@ -117,3 +118,53 @@ func TestToolTexts(t *testing.T) {
117118 t.Fatalf("the version of build/config.yml: %v", err)
118119 }
119120 }
121+
122+// Issue #91: the history tools, and agentTools.
123+
124+func toolsOf(spec acp.Spec) map[string]acp.Tool {
125+ tools := map[string]acp.Tool{}
126+ for _, tool := range spec.Tools {
127+ tools[tool.Name] = tool
128+ }
129+ return tools
130+}
131+
132+func TestAgentToolsChoosesTheToolsOffered(t *testing.T) {
133+ if spec := offeredTools(t, "agentTools:\n enabled: false\n"); len(spec.Tools) != 0 {
134+ t.Fatalf("disabled: %d tools", len(spec.Tools))
135+ }
136+ spec := offeredTools(t, "agentTools:\n offer: [memory_pressure, list_agents]\n")
137+ if tools := toolsOf(spec); len(tools) != 2 || tools["memory_pressure"].Call == nil || tools["list_agents"].Call == nil {
138+ t.Fatalf("filtered: %+v", spec.Tools)
139+ }
140+}
141+
142+func TestTheHistoryToolsReadEveryChannel(t *testing.T) {
143+ tools := toolsOf(offeredTools(t, ""))
144+ text, err := tools["list_channels"].Call(context.Background(), "s-1", nil)
145+ if err != nil || !strings.Contains(text, "- #general: the bridge. Members: @riker (you). 2 messages, the last on ") {
146+ t.Fatalf("list_channels: %q %v", text, err)
147+ }
148+ text, err = tools["list_agents"].Call(context.Background(), "s-1", nil)
149+ if err != nil || !strings.Contains(text, "1 agents:\n- @riker (you). Runs on the user's computer; ") {
150+ t.Fatalf("list_agents: %q %v", text, err)
151+ }
152+ search := tools["search_messages"]
153+ if search.InputSchema["required"].([]string)[0] != "query" {
154+ t.Fatalf("schema: %+v", search.InputSchema)
155+ }
156+ text, err = search.Call(context.Background(), "s-1", map[string]any{"query": "HI"})
157+ if err != nil || !strings.Contains(text, `1 messages of #general contain "HI", the most recent first:`) || !strings.Contains(text, ", the user: @riker hi") {
158+ t.Fatalf("search in this channel: %q %v", text, err)
159+ }
160+ text, err = search.Call(context.Background(), "", map[string]any{"query": "ok", "channel": "#general", "limit": float64(5)})
161+ if err != nil || !strings.Contains(text, ", @riker: ok") {
162+ t.Fatalf("search in a named channel: %q %v", text, err)
163+ }
164+ if _, err := search.Call(context.Background(), "", map[string]any{"query": "ok", "channel": "bridge"}); err == nil || !strings.Contains(err.Error(), "the channels are: #general") {
165+ t.Fatalf("unknown channel: %v", err)
166+ }
167+ if _, err := search.Call(context.Background(), "s-1", map[string]any{}); err == nil {
168+ t.Fatal("query is required")
169+ }
170+}
@@ -21,12 +21,13 @@ import (
21 21
22 // Issue #90: the tools Sidekicks offers the agents.22 // Issue #90: the tools Sidekicks offers the agents.
23 23
24-// offeredTools has riker answer in #general and returns how it was started.24+// offeredTools has riker answer in #general, with settings (YAML) in the
25-func offeredTools(t *testing.T) acp.Spec {25+// configuration, and returns how it was started.
26+func offeredTools(t *testing.T, settings string) acp.Spec {
26 t.Helper()27 t.Helper()
27 directory := t.TempDir()28 directory := t.TempDir()
28 path := filepath.Join(directory, "config.yaml")29 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+ write(t, path, "version: 1\n"+settings+"agents:\n - name: riker\n command: mm\n args: [--acp, --config, agent.yaml]\n workspace: riker\n")
30 var mu sync.Mutex31 var mu sync.Mutex
31 var spec acp.Spec32 var spec acp.Spec
32 start := func(_ context.Context, started acp.Spec, _ func(string)) (agents.Conn, error) {33 start := func(_ context.Context, started acp.Spec, _ func(string)) (agents.Conn, error) {
@@ -62,8 +63,8 @@ func offeredTools(t *testing.T) acp.Spec {
62 }63 }
63 64
64 func TestTheAgentsAreOfferedSidekicksTools(t *testing.T) {65 func TestTheAgentsAreOfferedSidekicksTools(t *testing.T) {
65- spec := offeredTools(t)66+ spec := offeredTools(t, "")
66- if spec.ClientVersion != "1.4.0" || spec.ToolDiscovery != acp.DiscoveryMeta || len(spec.Tools) != 3 {67+ if spec.ClientVersion != "1.4.0" || spec.ToolDiscovery != acp.DiscoveryMeta || len(spec.Tools) != 6 {
67 t.Fatalf("spec: version %q, discovery %q, %d tools", spec.ClientVersion, spec.ToolDiscovery, len(spec.Tools))68 t.Fatalf("spec: version %q, discovery %q, %d tools", spec.ClientVersion, spec.ToolDiscovery, len(spec.Tools))
68 }69 }
69 for _, tool := range spec.Tools {70 for _, tool := range spec.Tools {
@@ -75,7 +76,7 @@ func TestTheAgentsAreOfferedSidekicksTools(t *testing.T) {
75 76
76 func TestTheToolsAnswerForTheCallersSession(t *testing.T) {77 func TestTheToolsAnswerForTheCallersSession(t *testing.T) {
77 tools := map[string]acp.Tool{}78 tools := map[string]acp.Tool{}
78- for _, tool := range offeredTools(t).Tools {79+ for _, tool := range offeredTools(t, "").Tools {
79 tools[tool.Name] = tool80 tools[tool.Name] = tool
80 }81 }
81 text, err := tools["current_channel"].Call(context.Background(), "s-1", nil)82 text, err := tools["current_channel"].Call(context.Background(), "s-1", nil)
@@ -117,3 +118,53 @@ func TestToolTexts(t *testing.T) {
117 t.Fatalf("the version of build/config.yml: %v", err)118 t.Fatalf("the version of build/config.yml: %v", err)
118 }119 }
119 }120 }
121+
122+// Issue #91: the history tools, and agentTools.
123+
124+func toolsOf(spec acp.Spec) map[string]acp.Tool {
125+ tools := map[string]acp.Tool{}
126+ for _, tool := range spec.Tools {
127+ tools[tool.Name] = tool
128+ }
129+ return tools
130+}
131+
132+func TestAgentToolsChoosesTheToolsOffered(t *testing.T) {
133+ if spec := offeredTools(t, "agentTools:\n enabled: false\n"); len(spec.Tools) != 0 {
134+ t.Fatalf("disabled: %d tools", len(spec.Tools))
135+ }
136+ spec := offeredTools(t, "agentTools:\n offer: [memory_pressure, list_agents]\n")
137+ if tools := toolsOf(spec); len(tools) != 2 || tools["memory_pressure"].Call == nil || tools["list_agents"].Call == nil {
138+ t.Fatalf("filtered: %+v", spec.Tools)
139+ }
140+}
141+
142+func TestTheHistoryToolsReadEveryChannel(t *testing.T) {
143+ tools := toolsOf(offeredTools(t, ""))
144+ text, err := tools["list_channels"].Call(context.Background(), "s-1", nil)
145+ if err != nil || !strings.Contains(text, "- #general: the bridge. Members: @riker (you). 2 messages, the last on ") {
146+ t.Fatalf("list_channels: %q %v", text, err)
147+ }
148+ text, err = tools["list_agents"].Call(context.Background(), "s-1", nil)
149+ if err != nil || !strings.Contains(text, "1 agents:\n- @riker (you). Runs on the user's computer; ") {
150+ t.Fatalf("list_agents: %q %v", text, err)
151+ }
152+ search := tools["search_messages"]
153+ if search.InputSchema["required"].([]string)[0] != "query" {
154+ t.Fatalf("schema: %+v", search.InputSchema)
155+ }
156+ text, err = search.Call(context.Background(), "s-1", map[string]any{"query": "HI"})
157+ if err != nil || !strings.Contains(text, `1 messages of #general contain "HI", the most recent first:`) || !strings.Contains(text, ", the user: @riker hi") {
158+ t.Fatalf("search in this channel: %q %v", text, err)
159+ }
160+ text, err = search.Call(context.Background(), "", map[string]any{"query": "ok", "channel": "#general", "limit": float64(5)})
161+ if err != nil || !strings.Contains(text, ", @riker: ok") {
162+ t.Fatalf("search in a named channel: %q %v", text, err)
163+ }
164+ if _, err := search.Call(context.Background(), "", map[string]any{"query": "ok", "channel": "bridge"}); err == nil || !strings.Contains(err.Error(), "the channels are: #general") {
165+ t.Fatalf("unknown channel: %v", err)
166+ }
167+ if _, err := search.Call(context.Background(), "s-1", map[string]any{}); err == nil {
168+ t.Fatal("query is required")
169+ }
170+}
added internal/app/historytools.go +221 -0
new file mode 100644
@@ -0,0 +1,221 @@
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+ "strings"
10+
11+ "git.rickub.com/bots-garden/sidekicks/internal/acp"
12+ "git.rickub.com/bots-garden/sidekicks/internal/agents"
13+ "git.rickub.com/bots-garden/sidekicks/internal/channels"
14+)
15+
16+// The tools that read what Sidekicks knows (issue #91): its channels, its
17+// agents and the history of every channel. An agent already reads the
18+// history of the channels it is a member of; with these tools it reads all
19+// of them. agentTools.offer leaves them out when that is not wanted.
20+
21+// The methods of the history tools.
22+const (
23+ ChannelsMethod = "_com.rickub.sidekicks/channels/list"
24+ AgentsMethod = "_com.rickub.sidekicks/agents/list"
25+ SearchMethod = "_com.rickub.sidekicks/messages/search"
26+)
27+
28+// The number of messages search_messages returns: by default, and at most.
29+const (
30+ DefaultSearchLimit = 10
31+ MaxSearchLimit = 50
32+)
33+
34+func (c *Core) historyTools(agent string) []acp.Tool {
35+ return []acp.Tool{
36+ {
37+ Name: "list_channels",
38+ Description: "List the Sidekicks channels and direct conversations: name, description, members, number of messages and date of the last one. Call it to know where a topic was discussed before searching.",
39+ Method: ChannelsMethod,
40+ Call: func(context.Context, string, map[string]any) (string, error) {
41+ manager, err := c.channelManager()
42+ if err != nil {
43+ return "", err
44+ }
45+ summaries, err := manager.Summaries()
46+ if err != nil {
47+ return "", err
48+ }
49+ return ChannelsText(summaries, agent), nil
50+ },
51+ },
52+ {
53+ Name: "list_agents",
54+ Description: "List the agents of Sidekicks: the name to mention them with (@name), what they do, where they run and whether they are running. Call it to know who can help.",
55+ Method: AgentsMethod,
56+ Call: func(context.Context, string, map[string]any) (string, error) {
57+ return AgentsText(c.manager.Statuses(), agent), nil
58+ },
59+ },
60+ {
61+ Name: "search_messages",
62+ Description: "Search the whole history of a Sidekicks channel, or of a direct conversation, for messages containing a text (case and accents ignored), the most recent first. Without channel, the channel of this conversation.",
63+ Method: SearchMethod,
64+ InputSchema: map[string]any{
65+ "type": "object",
66+ "properties": map[string]any{
67+ "query": map[string]any{"type": "string", "description": "The text to find, e.g. a word or a name."},
68+ "channel": map[string]any{"type": "string", "description": "The channel's name (general or #general), or @agent for a direct conversation with that agent. Default: this conversation's channel."},
69+ "limit": map[string]any{"type": "integer", "description": fmt.Sprintf("How many messages at most (default %d, at most %d).", DefaultSearchLimit, MaxSearchLimit)},
70+ },
71+ "required": []string{"query"},
72+ },
73+ Call: func(_ context.Context, sessionID string, arguments map[string]any) (string, error) {
74+ return c.search(agent, sessionID, arguments)
75+ },
76+ },
77+ }
78+}
79+
80+// search runs search_messages for agent, called in sessionID.
81+func (c *Core) search(agent, sessionID string, arguments map[string]any) (string, error) {
82+ manager, err := c.channelManager()
83+ if err != nil {
84+ return "", err
85+ }
86+ query, _ := arguments["query"].(string)
87+ if strings.TrimSpace(query) == "" {
88+ return "", errors.New("query is missing: give the text to find")
89+ }
90+ limit := DefaultSearchLimit
91+ if number, ok := arguments["limit"].(float64); ok && number >= 1 {
92+ limit = min(int(number), MaxSearchLimit)
93+ }
94+ channel, err := searchedChannel(manager, agent, sessionID, arguments)
95+ if err != nil {
96+ return "", err
97+ }
98+ found, err := manager.Search(channel.ID, query, limit)
99+ if err != nil {
100+ return "", err
101+ }
102+ return SearchText(channel, query, found), nil
103+}
104+
105+// searchedChannel is the channel arguments name, or the one of sessionID.
106+func searchedChannel(manager *channels.Manager, agent, sessionID string, arguments map[string]any) (channels.Channel, error) {
107+ name, _ := arguments["channel"].(string)
108+ if strings.TrimSpace(name) == "" {
109+ if channel, ok := manager.SessionChannel(agent, sessionID); ok {
110+ return channel, nil
111+ }
112+ return channels.Channel{}, errors.New("this session belongs to no channel: give the channel to search")
113+ }
114+ channel, err := manager.ChannelNamed(name)
115+ if err != nil {
116+ var known []string
117+ for _, channel := range manager.Channels() {
118+ known = append(known, channelName(channel))
119+ }
120+ return channels.Channel{}, fmt.Errorf("no channel is called %q; the channels are: %s", name, strings.Join(known, ", "))
121+ }
122+ return channel, nil
123+}
124+
125+// channelName is how the tools name a channel: #general, or @alice for a
126+// direct conversation.
127+func channelName(channel channels.Channel) string {
128+ if channel.Direct != "" {
129+ return "@" + channel.Direct
130+ }
131+ return "#" + channel.Name
132+}
133+
134+// ChannelsText tells summaries to a model; agent is the one asking.
135+func ChannelsText(summaries []channels.Summary, agent string) string {
136+ if len(summaries) == 0 {
137+ return "Sidekicks has no channel yet."
138+ }
139+ lines := []string{fmt.Sprintf("%d channels and direct conversations:", len(summaries))}
140+ for _, summary := range summaries {
141+ channel := summary.Channel
142+ line := "- " + channelName(channel)
143+ if channel.Direct != "" {
144+ line += " (direct conversation between the user and @" + channel.Direct + ")"
145+ } else {
146+ if channel.Description != "" {
147+ line += ": " + channel.Description
148+ }
149+ line += ". Members: " + mentions(channel.Members, agent)
150+ }
151+ line += fmt.Sprintf(". %d messages", summary.Messages)
152+ if !summary.Last.IsZero() {
153+ line += ", the last on " + summary.Last.Local().Format("2006-01-02 15:04")
154+ }
155+ lines = append(lines, line+".")
156+ }
157+ return strings.Join(lines, "\n")
158+}
159+
160+func mentions(members []string, agent string) string {
161+ if len(members) == 0 {
162+ return "none"
163+ }
164+ var names []string
165+ for _, member := range members {
166+ name := "@" + member
167+ if member == agent {
168+ name += " (you)"
169+ }
170+ names = append(names, name)
171+ }
172+ return strings.Join(names, ", ")
173+}
174+
175+// AgentsText tells statuses to a model; agent is the one asking.
176+func AgentsText(statuses []agents.Status, agent string) string {
177+ if len(statuses) == 0 {
178+ return "Sidekicks has no agent."
179+ }
180+ lines := []string{fmt.Sprintf("%d agents:", len(statuses))}
181+ for _, status := range statuses {
182+ line := "- @" + status.Name
183+ if status.Name == agent {
184+ line += " (you)"
185+ }
186+ if status.Title != "" && status.Title != status.Name {
187+ line += ", " + status.Title
188+ }
189+ if status.Description != "" {
190+ line += ": " + status.Description
191+ }
192+ lines = append(lines, fmt.Sprintf("%s. Runs %s; %s.", line, where(status.Runtime), status.State))
193+ }
194+ return strings.Join(lines, "\n")
195+}
196+
197+func where(runtime string) string {
198+ switch runtime {
199+ case "container":
200+ return "in a Docker container"
201+ case "sbx":
202+ return "in an sbx sandbox"
203+ }
204+ return "on the user's computer"
205+}
206+
207+// SearchText tells a model what a search for query in channel found.
208+func SearchText(channel channels.Channel, query string, found []channels.Found) string {
209+ if len(found) == 0 {
210+ return fmt.Sprintf("No message of %s contains %q.", channelName(channel), query)
211+ }
212+ lines := []string{fmt.Sprintf("%d messages of %s contain %q, the most recent first:", len(found), channelName(channel), query)}
213+ for _, match := range found {
214+ author := "the user"
215+ if match.Message.Role == channels.RoleAgent {
216+ author = "@" + match.Message.Agent
217+ }
218+ lines = append(lines, fmt.Sprintf("- %s, %s: %s", match.Message.CreatedAt.Local().Format("2006-01-02 15:04"), author, match.Excerpt))
219+ }
220+ return strings.Join(lines, "\n")
221+}
new file mode 100644
@@ -0,0 +1,221 @@
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+ "strings"
10+
11+ "git.rickub.com/bots-garden/sidekicks/internal/acp"
12+ "git.rickub.com/bots-garden/sidekicks/internal/agents"
13+ "git.rickub.com/bots-garden/sidekicks/internal/channels"
14+)
15+
16+// The tools that read what Sidekicks knows (issue #91): its channels, its
17+// agents and the history of every channel. An agent already reads the
18+// history of the channels it is a member of; with these tools it reads all
19+// of them. agentTools.offer leaves them out when that is not wanted.
20+
21+// The methods of the history tools.
22+const (
23+ ChannelsMethod = "_com.rickub.sidekicks/channels/list"
24+ AgentsMethod = "_com.rickub.sidekicks/agents/list"
25+ SearchMethod = "_com.rickub.sidekicks/messages/search"
26+)
27+
28+// The number of messages search_messages returns: by default, and at most.
29+const (
30+ DefaultSearchLimit = 10
31+ MaxSearchLimit = 50
32+)
33+
34+func (c *Core) historyTools(agent string) []acp.Tool {
35+ return []acp.Tool{
36+ {
37+ Name: "list_channels",
38+ Description: "List the Sidekicks channels and direct conversations: name, description, members, number of messages and date of the last one. Call it to know where a topic was discussed before searching.",
39+ Method: ChannelsMethod,
40+ Call: func(context.Context, string, map[string]any) (string, error) {
41+ manager, err := c.channelManager()
42+ if err != nil {
43+ return "", err
44+ }
45+ summaries, err := manager.Summaries()
46+ if err != nil {
47+ return "", err
48+ }
49+ return ChannelsText(summaries, agent), nil
50+ },
51+ },
52+ {
53+ Name: "list_agents",
54+ Description: "List the agents of Sidekicks: the name to mention them with (@name), what they do, where they run and whether they are running. Call it to know who can help.",
55+ Method: AgentsMethod,
56+ Call: func(context.Context, string, map[string]any) (string, error) {
57+ return AgentsText(c.manager.Statuses(), agent), nil
58+ },
59+ },
60+ {
61+ Name: "search_messages",
62+ Description: "Search the whole history of a Sidekicks channel, or of a direct conversation, for messages containing a text (case and accents ignored), the most recent first. Without channel, the channel of this conversation.",
63+ Method: SearchMethod,
64+ InputSchema: map[string]any{
65+ "type": "object",
66+ "properties": map[string]any{
67+ "query": map[string]any{"type": "string", "description": "The text to find, e.g. a word or a name."},
68+ "channel": map[string]any{"type": "string", "description": "The channel's name (general or #general), or @agent for a direct conversation with that agent. Default: this conversation's channel."},
69+ "limit": map[string]any{"type": "integer", "description": fmt.Sprintf("How many messages at most (default %d, at most %d).", DefaultSearchLimit, MaxSearchLimit)},
70+ },
71+ "required": []string{"query"},
72+ },
73+ Call: func(_ context.Context, sessionID string, arguments map[string]any) (string, error) {
74+ return c.search(agent, sessionID, arguments)
75+ },
76+ },
77+ }
78+}
79+
80+// search runs search_messages for agent, called in sessionID.
81+func (c *Core) search(agent, sessionID string, arguments map[string]any) (string, error) {
82+ manager, err := c.channelManager()
83+ if err != nil {
84+ return "", err
85+ }
86+ query, _ := arguments["query"].(string)
87+ if strings.TrimSpace(query) == "" {
88+ return "", errors.New("query is missing: give the text to find")
89+ }
90+ limit := DefaultSearchLimit
91+ if number, ok := arguments["limit"].(float64); ok && number >= 1 {
92+ limit = min(int(number), MaxSearchLimit)
93+ }
94+ channel, err := searchedChannel(manager, agent, sessionID, arguments)
95+ if err != nil {
96+ return "", err
97+ }
98+ found, err := manager.Search(channel.ID, query, limit)
99+ if err != nil {
100+ return "", err
101+ }
102+ return SearchText(channel, query, found), nil
103+}
104+
105+// searchedChannel is the channel arguments name, or the one of sessionID.
106+func searchedChannel(manager *channels.Manager, agent, sessionID string, arguments map[string]any) (channels.Channel, error) {
107+ name, _ := arguments["channel"].(string)
108+ if strings.TrimSpace(name) == "" {
109+ if channel, ok := manager.SessionChannel(agent, sessionID); ok {
110+ return channel, nil
111+ }
112+ return channels.Channel{}, errors.New("this session belongs to no channel: give the channel to search")
113+ }
114+ channel, err := manager.ChannelNamed(name)
115+ if err != nil {
116+ var known []string
117+ for _, channel := range manager.Channels() {
118+ known = append(known, channelName(channel))
119+ }
120+ return channels.Channel{}, fmt.Errorf("no channel is called %q; the channels are: %s", name, strings.Join(known, ", "))
121+ }
122+ return channel, nil
123+}
124+
125+// channelName is how the tools name a channel: #general, or @alice for a
126+// direct conversation.
127+func channelName(channel channels.Channel) string {
128+ if channel.Direct != "" {
129+ return "@" + channel.Direct
130+ }
131+ return "#" + channel.Name
132+}
133+
134+// ChannelsText tells summaries to a model; agent is the one asking.
135+func ChannelsText(summaries []channels.Summary, agent string) string {
136+ if len(summaries) == 0 {
137+ return "Sidekicks has no channel yet."
138+ }
139+ lines := []string{fmt.Sprintf("%d channels and direct conversations:", len(summaries))}
140+ for _, summary := range summaries {
141+ channel := summary.Channel
142+ line := "- " + channelName(channel)
143+ if channel.Direct != "" {
144+ line += " (direct conversation between the user and @" + channel.Direct + ")"
145+ } else {
146+ if channel.Description != "" {
147+ line += ": " + channel.Description
148+ }
149+ line += ". Members: " + mentions(channel.Members, agent)
150+ }
151+ line += fmt.Sprintf(". %d messages", summary.Messages)
152+ if !summary.Last.IsZero() {
153+ line += ", the last on " + summary.Last.Local().Format("2006-01-02 15:04")
154+ }
155+ lines = append(lines, line+".")
156+ }
157+ return strings.Join(lines, "\n")
158+}
159+
160+func mentions(members []string, agent string) string {
161+ if len(members) == 0 {
162+ return "none"
163+ }
164+ var names []string
165+ for _, member := range members {
166+ name := "@" + member
167+ if member == agent {
168+ name += " (you)"
169+ }
170+ names = append(names, name)
171+ }
172+ return strings.Join(names, ", ")
173+}
174+
175+// AgentsText tells statuses to a model; agent is the one asking.
176+func AgentsText(statuses []agents.Status, agent string) string {
177+ if len(statuses) == 0 {
178+ return "Sidekicks has no agent."
179+ }
180+ lines := []string{fmt.Sprintf("%d agents:", len(statuses))}
181+ for _, status := range statuses {
182+ line := "- @" + status.Name
183+ if status.Name == agent {
184+ line += " (you)"
185+ }
186+ if status.Title != "" && status.Title != status.Name {
187+ line += ", " + status.Title
188+ }
189+ if status.Description != "" {
190+ line += ": " + status.Description
191+ }
192+ lines = append(lines, fmt.Sprintf("%s. Runs %s; %s.", line, where(status.Runtime), status.State))
193+ }
194+ return strings.Join(lines, "\n")
195+}
196+
197+func where(runtime string) string {
198+ switch runtime {
199+ case "container":
200+ return "in a Docker container"
201+ case "sbx":
202+ return "in an sbx sandbox"
203+ }
204+ return "on the user's computer"
205+}
206+
207+// SearchText tells a model what a search for query in channel found.
208+func SearchText(channel channels.Channel, query string, found []channels.Found) string {
209+ if len(found) == 0 {
210+ return fmt.Sprintf("No message of %s contains %q.", channelName(channel), query)
211+ }
212+ lines := []string{fmt.Sprintf("%d messages of %s contain %q, the most recent first:", len(found), channelName(channel), query)}
213+ for _, match := range found {
214+ author := "the user"
215+ if match.Message.Role == channels.RoleAgent {
216+ author = "@" + match.Message.Agent
217+ }
218+ lines = append(lines, fmt.Sprintf("- %s, %s: %s", match.Message.CreatedAt.Local().Format("2006-01-02 15:04"), author, match.Excerpt))
219+ }
220+ return strings.Join(lines, "\n")
221+}
added internal/channels/search.go +161 -0
new file mode 100644
@@ -0,0 +1,161 @@
1+// Copyright (c) 2026 Philippe Charrière — Sidekicks Source-Available License 1.0, see LICENSE
2+
3+package channels
4+
5+import (
6+ "encoding/json"
7+ "errors"
8+ "fmt"
9+ "math"
10+ "strings"
11+ "time"
12+ "unicode"
13+
14+ "golang.org/x/text/unicode/norm"
15+)
16+
17+// What the agents' tools read in the history (issue #91): a summary of each
18+// channel, and a search in the whole history of one, beyond the messages
19+// the interface has loaded. The store has no text index: a search reads the
20+// channel's messages.
21+
22+// Summary is a channel with the size of its history.
23+type Summary struct {
24+ Channel Channel
25+ Messages int
26+ // Last is when the last message was written; zero without messages.
27+ Last time.Time
28+}
29+
30+// Found is a message that matches a search, with the text around the match.
31+type Found struct {
32+ Message Message
33+ Excerpt string
34+}
35+
36+// Summaries returns every channel and direct conversation, oldest first,
37+// with how many user and agent messages it holds and when the last one was
38+// written.
39+func (m *Manager) Summaries() ([]Summary, error) {
40+ m.mu.Lock()
41+ list := m.list()
42+ m.mu.Unlock()
43+ summaries := make([]Summary, 0, len(list))
44+ for _, channel := range list {
45+ messages, err := m.history(channel.ID)
46+ if err != nil {
47+ return nil, err
48+ }
49+ summary := Summary{Channel: channel}
50+ for _, message := range messages {
51+ if message.Role == RoleSystem {
52+ continue
53+ }
54+ summary.Messages++
55+ summary.Last = message.CreatedAt
56+ }
57+ summaries = append(summaries, summary)
58+ }
59+ return summaries, nil
60+}
61+
62+// ChannelNamed finds a channel by its name ("general" or "#general"), or a
63+// direct conversation by its agent ("@alice").
64+func (m *Manager) ChannelNamed(name string) (Channel, error) {
65+ name = strings.TrimSpace(name)
66+ m.mu.Lock()
67+ defer m.mu.Unlock()
68+ for _, id := range m.order {
69+ ch := m.channels[id]
70+ direct := ch.info.Direct != "" && name == "@"+ch.info.Direct
71+ named := ch.info.Direct == "" && strings.EqualFold(strings.TrimSpace(ch.info.Name), strings.TrimPrefix(name, "#"))
72+ if direct || named {
73+ return ch.view(), nil
74+ }
75+ }
76+ return Channel{}, fmt.Errorf("%w: %q", ErrUnknownChannel, name)
77+}
78+
79+// Search returns the user and agent messages of a channel whose text
80+// contains query, ignoring case and accents, the most recent first, at most
81+// limit of them.
82+//
83+// found, err := manager.Search(general.ID, "lyon", 10)
84+func (m *Manager) Search(channelID, query string, limit int) ([]Found, error) {
85+ wanted := fold(strings.TrimSpace(query))
86+ if len(wanted) == 0 {
87+ return nil, errors.New("the search is empty")
88+ }
89+ messages, err := m.history(channelID)
90+ if err != nil {
91+ return nil, err
92+ }
93+ var found []Found
94+ for i := len(messages) - 1; i >= 0 && len(found) < limit; i-- {
95+ message := messages[i]
96+ if message.Role == RoleSystem {
97+ continue
98+ }
99+ text := []rune(textOf(message))
100+ if at := index(fold(string(text)), wanted); at >= 0 {
101+ found = append(found, Found{Message: *message, Excerpt: excerpt(text, at, len(wanted))})
102+ }
103+ }
104+ return found, nil
105+}
106+
107+// history reads every stored message of a channel, oldest first.
108+func (m *Manager) history(channelID string) ([]*Message, error) {
109+ stored, _, err := m.db.Messages(channelID, "", math.MaxInt)
110+ if err != nil {
111+ return nil, err
112+ }
113+ messages := make([]*Message, 0, len(stored))
114+ for _, data := range stored {
115+ message := &Message{}
116+ if err := json.Unmarshal(data, message); err != nil {
117+ return nil, err
118+ }
119+ messages = append(messages, message)
120+ }
121+ return messages, nil
122+}
123+
124+// fold lowers text and strips its accents rune by rune, so that a position
125+// in the result is a position in []rune(text).
126+func fold(text string) []rune {
127+ runes := []rune(text)
128+ for i, r := range runes {
129+ base := []rune(norm.NFD.String(string(unicode.ToLower(r))))
130+ if len(base) > 0 {
131+ runes[i] = base[0]
132+ }
133+ }
134+ return runes
135+}
136+
137+// index is the position of wanted in text, -1 when absent.
138+func index(text, wanted []rune) int {
139+ for i := 0; i+len(wanted) <= len(text); i++ {
140+ if string(text[i:i+len(wanted)]) == string(wanted) {
141+ return i
142+ }
143+ }
144+ return -1
145+}
146+
147+// excerptAround is how many characters an excerpt keeps on each side of a match.
148+const excerptAround = 80
149+
150+// excerpt is the text around text[at:at+length], on one line.
151+func excerpt(text []rune, at, length int) string {
152+ start, end := max(0, at-excerptAround), min(len(text), at+length+excerptAround)
153+ result := strings.Join(strings.Fields(string(text[start:end])), " ")
154+ if start > 0 {
155+ result = "…" + result
156+ }
157+ if end < len(text) {
158+ result += "…"
159+ }
160+ return result
161+}
new file mode 100644
@@ -0,0 +1,161 @@
1+// Copyright (c) 2026 Philippe Charrière — Sidekicks Source-Available License 1.0, see LICENSE
2+
3+package channels
4+
5+import (
6+ "encoding/json"
7+ "errors"
8+ "fmt"
9+ "math"
10+ "strings"
11+ "time"
12+ "unicode"
13+
14+ "golang.org/x/text/unicode/norm"
15+)
16+
17+// What the agents' tools read in the history (issue #91): a summary of each
18+// channel, and a search in the whole history of one, beyond the messages
19+// the interface has loaded. The store has no text index: a search reads the
20+// channel's messages.
21+
22+// Summary is a channel with the size of its history.
23+type Summary struct {
24+ Channel Channel
25+ Messages int
26+ // Last is when the last message was written; zero without messages.
27+ Last time.Time
28+}
29+
30+// Found is a message that matches a search, with the text around the match.
31+type Found struct {
32+ Message Message
33+ Excerpt string
34+}
35+
36+// Summaries returns every channel and direct conversation, oldest first,
37+// with how many user and agent messages it holds and when the last one was
38+// written.
39+func (m *Manager) Summaries() ([]Summary, error) {
40+ m.mu.Lock()
41+ list := m.list()
42+ m.mu.Unlock()
43+ summaries := make([]Summary, 0, len(list))
44+ for _, channel := range list {
45+ messages, err := m.history(channel.ID)
46+ if err != nil {
47+ return nil, err
48+ }
49+ summary := Summary{Channel: channel}
50+ for _, message := range messages {
51+ if message.Role == RoleSystem {
52+ continue
53+ }
54+ summary.Messages++
55+ summary.Last = message.CreatedAt
56+ }
57+ summaries = append(summaries, summary)
58+ }
59+ return summaries, nil
60+}
61+
62+// ChannelNamed finds a channel by its name ("general" or "#general"), or a
63+// direct conversation by its agent ("@alice").
64+func (m *Manager) ChannelNamed(name string) (Channel, error) {
65+ name = strings.TrimSpace(name)
66+ m.mu.Lock()
67+ defer m.mu.Unlock()
68+ for _, id := range m.order {
69+ ch := m.channels[id]
70+ direct := ch.info.Direct != "" && name == "@"+ch.info.Direct
71+ named := ch.info.Direct == "" && strings.EqualFold(strings.TrimSpace(ch.info.Name), strings.TrimPrefix(name, "#"))
72+ if direct || named {
73+ return ch.view(), nil
74+ }
75+ }
76+ return Channel{}, fmt.Errorf("%w: %q", ErrUnknownChannel, name)
77+}
78+
79+// Search returns the user and agent messages of a channel whose text
80+// contains query, ignoring case and accents, the most recent first, at most
81+// limit of them.
82+//
83+// found, err := manager.Search(general.ID, "lyon", 10)
84+func (m *Manager) Search(channelID, query string, limit int) ([]Found, error) {
85+ wanted := fold(strings.TrimSpace(query))
86+ if len(wanted) == 0 {
87+ return nil, errors.New("the search is empty")
88+ }
89+ messages, err := m.history(channelID)
90+ if err != nil {
91+ return nil, err
92+ }
93+ var found []Found
94+ for i := len(messages) - 1; i >= 0 && len(found) < limit; i-- {
95+ message := messages[i]
96+ if message.Role == RoleSystem {
97+ continue
98+ }
99+ text := []rune(textOf(message))
100+ if at := index(fold(string(text)), wanted); at >= 0 {
101+ found = append(found, Found{Message: *message, Excerpt: excerpt(text, at, len(wanted))})
102+ }
103+ }
104+ return found, nil
105+}
106+
107+// history reads every stored message of a channel, oldest first.
108+func (m *Manager) history(channelID string) ([]*Message, error) {
109+ stored, _, err := m.db.Messages(channelID, "", math.MaxInt)
110+ if err != nil {
111+ return nil, err
112+ }
113+ messages := make([]*Message, 0, len(stored))
114+ for _, data := range stored {
115+ message := &Message{}
116+ if err := json.Unmarshal(data, message); err != nil {
117+ return nil, err
118+ }
119+ messages = append(messages, message)
120+ }
121+ return messages, nil
122+}
123+
124+// fold lowers text and strips its accents rune by rune, so that a position
125+// in the result is a position in []rune(text).
126+func fold(text string) []rune {
127+ runes := []rune(text)
128+ for i, r := range runes {
129+ base := []rune(norm.NFD.String(string(unicode.ToLower(r))))
130+ if len(base) > 0 {
131+ runes[i] = base[0]
132+ }
133+ }
134+ return runes
135+}
136+
137+// index is the position of wanted in text, -1 when absent.
138+func index(text, wanted []rune) int {
139+ for i := 0; i+len(wanted) <= len(text); i++ {
140+ if string(text[i:i+len(wanted)]) == string(wanted) {
141+ return i
142+ }
143+ }
144+ return -1
145+}
146+
147+// excerptAround is how many characters an excerpt keeps on each side of a match.
148+const excerptAround = 80
149+
150+// excerpt is the text around text[at:at+length], on one line.
151+func excerpt(text []rune, at, length int) string {
152+ start, end := max(0, at-excerptAround), min(len(text), at+length+excerptAround)
153+ result := strings.Join(strings.Fields(string(text[start:end])), " ")
154+ if start > 0 {
155+ result = "…" + result
156+ }
157+ if end < len(text) {
158+ result += "…"
159+ }
160+ return result
161+}
added internal/channels/search_test.go +96 -0
new file mode 100644
@@ -0,0 +1,96 @@
1+// Copyright (c) 2026 Philippe Charrière — Sidekicks Source-Available License 1.0, see LICENSE
2+
3+package channels_test
4+
5+import (
6+ "errors"
7+ "strings"
8+ "testing"
9+
10+ "git.rickub.com/bots-garden/sidekicks/internal/channels"
11+)
12+
13+// Issue #91: what the agents' tools read in the history.
14+
15+func TestSearchFindsTheMessagesIgnoringCaseAndAccents(t *testing.T) {
16+ f := setup(t, nil)
17+ general := f.channel(t, "general", "alice")
18+ f.source.conn("alice").reply = func(prompt string) string {
19+ if strings.Contains(prompt, "train") {
20+ return "Le TGV pour Lyon part à 8 h, gare de Lyon."
21+ }
22+ return "alice ok"
23+ }
24+ f.send(t, general.ID, "@alice quel train pour lyon ?")
25+ f.idle(t, general.ID, 2)
26+ f.send(t, general.ID, "@alice et le café ?")
27+ f.idle(t, general.ID, 4)
28+ f.send(t, general.ID, "@alice merci, Lyon c'est noté")
29+ f.idle(t, general.ID, 6)
30+
31+ found, err := f.manager.Search(general.ID, "LYÖN", 10)
32+ if err != nil {
33+ t.Fatal(err)
34+ }
35+ var got []string
36+ for _, match := range found {
37+ got = append(got, string(match.Message.Role)+":"+match.Excerpt)
38+ }
39+ want := "user:@alice merci, Lyon c'est noté | agent:Le TGV pour Lyon part à 8 h, gare de Lyon. | user:@alice quel train pour lyon ?"
40+ if strings.Join(got, " | ") != want {
41+ t.Fatalf("most recent first:\n got %s\nwant %s", strings.Join(got, " | "), want)
42+ }
43+ if found, _ := f.manager.Search(general.ID, "cafe", 10); len(found) != 1 {
44+ t.Fatalf("café is found as cafe: %+v", found)
45+ }
46+ if found, _ := f.manager.Search(general.ID, "lyon", 2); len(found) != 2 {
47+ t.Fatalf("at most the limit: %d", len(found))
48+ }
49+ if _, err := f.manager.Search(general.ID, " ", 10); err == nil {
50+ t.Fatal("an empty search is an error")
51+ }
52+}
53+
54+func TestALongMessageGivesAnExcerpt(t *testing.T) {
55+ f := setup(t, nil)
56+ general := f.channel(t, "general", "alice")
57+ f.send(t, general.ID, "@alice "+strings.Repeat("blah ", 40)+"needle "+strings.Repeat("bleh ", 40))
58+ f.idle(t, general.ID, 2)
59+ found, _ := f.manager.Search(general.ID, "needle", 10)
60+ if len(found) != 1 || !strings.HasPrefix(found[0].Excerpt, "…") || !strings.HasSuffix(found[0].Excerpt, "…") ||
61+ !strings.Contains(found[0].Excerpt, "needle") || len([]rune(found[0].Excerpt)) > 200 {
62+ t.Fatalf("excerpt: %+v", found)
63+ }
64+}
65+
66+func TestSummariesAndChannelNames(t *testing.T) {
67+ f := setup(t, nil)
68+ general := f.channel(t, "general", "alice")
69+ f.channel(t, "random")
70+ f.send(t, general.ID, "@alice hi")
71+ f.idle(t, general.ID, 2)
72+ direct, _ := f.manager.Direct("bob")
73+
74+ summaries, err := f.manager.Summaries()
75+ if err != nil {
76+ t.Fatal(err)
77+ }
78+ counts := map[string]int{}
79+ for _, summary := range summaries {
80+ counts[summary.Channel.ID] = summary.Messages
81+ if summary.Channel.ID == general.ID && summary.Last.IsZero() {
82+ t.Fatal("the last message has a date")
83+ }
84+ }
85+ if len(summaries) != 3 || counts[general.ID] != 2 || counts[direct.ID] != 0 {
86+ t.Fatalf("summaries: %+v", summaries)
87+ }
88+ for name, want := range map[string]string{"general": general.ID, "#General": general.ID, "@bob": direct.ID} {
89+ if got, err := f.manager.ChannelNamed(name); err != nil || got.ID != want {
90+ t.Errorf("%s: got %+v %v", name, got, err)
91+ }
92+ }
93+ if _, err := f.manager.ChannelNamed("nowhere"); !errors.Is(err, channels.ErrUnknownChannel) {
94+ t.Fatalf("unknown: %v", err)
95+ }
96+}
new file mode 100644
@@ -0,0 +1,96 @@
1+// Copyright (c) 2026 Philippe Charrière — Sidekicks Source-Available License 1.0, see LICENSE
2+
3+package channels_test
4+
5+import (
6+ "errors"
7+ "strings"
8+ "testing"
9+
10+ "git.rickub.com/bots-garden/sidekicks/internal/channels"
11+)
12+
13+// Issue #91: what the agents' tools read in the history.
14+
15+func TestSearchFindsTheMessagesIgnoringCaseAndAccents(t *testing.T) {
16+ f := setup(t, nil)
17+ general := f.channel(t, "general", "alice")
18+ f.source.conn("alice").reply = func(prompt string) string {
19+ if strings.Contains(prompt, "train") {
20+ return "Le TGV pour Lyon part à 8 h, gare de Lyon."
21+ }
22+ return "alice ok"
23+ }
24+ f.send(t, general.ID, "@alice quel train pour lyon ?")
25+ f.idle(t, general.ID, 2)
26+ f.send(t, general.ID, "@alice et le café ?")
27+ f.idle(t, general.ID, 4)
28+ f.send(t, general.ID, "@alice merci, Lyon c'est noté")
29+ f.idle(t, general.ID, 6)
30+
31+ found, err := f.manager.Search(general.ID, "LYÖN", 10)
32+ if err != nil {
33+ t.Fatal(err)
34+ }
35+ var got []string
36+ for _, match := range found {
37+ got = append(got, string(match.Message.Role)+":"+match.Excerpt)
38+ }
39+ want := "user:@alice merci, Lyon c'est noté | agent:Le TGV pour Lyon part à 8 h, gare de Lyon. | user:@alice quel train pour lyon ?"
40+ if strings.Join(got, " | ") != want {
41+ t.Fatalf("most recent first:\n got %s\nwant %s", strings.Join(got, " | "), want)
42+ }
43+ if found, _ := f.manager.Search(general.ID, "cafe", 10); len(found) != 1 {
44+ t.Fatalf("café is found as cafe: %+v", found)
45+ }
46+ if found, _ := f.manager.Search(general.ID, "lyon", 2); len(found) != 2 {
47+ t.Fatalf("at most the limit: %d", len(found))
48+ }
49+ if _, err := f.manager.Search(general.ID, " ", 10); err == nil {
50+ t.Fatal("an empty search is an error")
51+ }
52+}
53+
54+func TestALongMessageGivesAnExcerpt(t *testing.T) {
55+ f := setup(t, nil)
56+ general := f.channel(t, "general", "alice")
57+ f.send(t, general.ID, "@alice "+strings.Repeat("blah ", 40)+"needle "+strings.Repeat("bleh ", 40))
58+ f.idle(t, general.ID, 2)
59+ found, _ := f.manager.Search(general.ID, "needle", 10)
60+ if len(found) != 1 || !strings.HasPrefix(found[0].Excerpt, "…") || !strings.HasSuffix(found[0].Excerpt, "…") ||
61+ !strings.Contains(found[0].Excerpt, "needle") || len([]rune(found[0].Excerpt)) > 200 {
62+ t.Fatalf("excerpt: %+v", found)
63+ }
64+}
65+
66+func TestSummariesAndChannelNames(t *testing.T) {
67+ f := setup(t, nil)
68+ general := f.channel(t, "general", "alice")
69+ f.channel(t, "random")
70+ f.send(t, general.ID, "@alice hi")
71+ f.idle(t, general.ID, 2)
72+ direct, _ := f.manager.Direct("bob")
73+
74+ summaries, err := f.manager.Summaries()
75+ if err != nil {
76+ t.Fatal(err)
77+ }
78+ counts := map[string]int{}
79+ for _, summary := range summaries {
80+ counts[summary.Channel.ID] = summary.Messages
81+ if summary.Channel.ID == general.ID && summary.Last.IsZero() {
82+ t.Fatal("the last message has a date")
83+ }
84+ }
85+ if len(summaries) != 3 || counts[general.ID] != 2 || counts[direct.ID] != 0 {
86+ t.Fatalf("summaries: %+v", summaries)
87+ }
88+ for name, want := range map[string]string{"general": general.ID, "#General": general.ID, "@bob": direct.ID} {
89+ if got, err := f.manager.ChannelNamed(name); err != nil || got.ID != want {
90+ t.Errorf("%s: got %+v %v", name, got, err)
91+ }
92+ }
93+ if _, err := f.manager.ChannelNamed("nowhere"); !errors.Is(err, channels.ErrUnknownChannel) {
94+ t.Fatalf("unknown: %v", err)
95+ }
96+}
modified internal/config/config.go +53 -7
@@ -22,6 +22,7 @@ import (
2222 "os"
2323 "os/exec"
2424 "path/filepath"
25+ "slices"
2526 "strings"
2627 "time"
2728
@@ -41,12 +42,14 @@ const (
4142 // Config is a loaded configuration: defaults applied and paths absolute.
4243 type Config struct {
4344 // Path is the absolute path of the file it was loaded from.
44- Path string
45- Version int
46- UI UI
47- Limits Limits
48- Agents []Agent
49- Channels []Channel
45+ Path string
46+ Version int
47+ UI UI
48+ Limits Limits
49+ // AgentTools says which tools Sidekicks offers the agents (issues #90 and #91).
50+ AgentTools AgentTools
51+ Agents []Agent
52+ Channels []Channel
5053 // Warnings are problems that do not prevent using the configuration,
5154 // such as an agent command that cannot be found yet.
5255 Warnings []Problem
@@ -69,6 +72,23 @@ type Limits struct {
6972 MaxAgentHandoffs int
7073 }
7174
75+// AgentToolNames are the tools Sidekicks can offer the agents, the names
76+// agentTools.offer accepts (issues #90 and #91).
77+var AgentToolNames = []string{"memory_pressure", "about_sidekicks", "current_channel", "list_channels", "list_agents", "search_messages"}
78+
79+// AgentTools says which tools Sidekicks offers the agents.
80+type AgentTools struct {
81+ // Enabled is false when no tool is offered; true by default.
82+ Enabled bool
83+ // Offer lists the tools offered; nil offers them all.
84+ Offer []string
85+}
86+
87+// Offers tells whether the tool called name is offered.
88+func (tools AgentTools) Offers(name string) bool {
89+ return tools.Enabled && (tools.Offer == nil || slices.Contains(tools.Offer, name))
90+}
91+
7292 // Agent describes one agent Sidekicks can start.
7393 type Agent struct {
7494 Name string
@@ -319,7 +339,7 @@ func Parse(content []byte, path string) (*Config, error) {
319339 }
320340 cfg := raw.toConfig(filepath.Dir(path))
321341 cfg.Path = path
322- cfg.Warnings = withLanguage(commandWarnings(cfg, &root, language), language)
342+ cfg.Warnings = withLanguage(append(commandWarnings(cfg, &root, language), toolWarnings(cfg, &root, language)...), language)
323343 return cfg, nil
324344 }
325345
@@ -335,6 +355,10 @@ type rawConfig struct {
335355 StopIdleAgentsAfter string `yaml:"stopIdleAgentsAfter"`
336356 MaxAgentHandoffs *int `yaml:"maxAgentHandoffs"`
337357 } `yaml:"limits"`
358+ AgentTools struct {
359+ Enabled *bool `yaml:"enabled"`
360+ Offer *[]string `yaml:"offer"`
361+ } `yaml:"agentTools"`
338362 Agents []struct {
339363 Name string `yaml:"name"`
340364 Title string `yaml:"title"`
@@ -376,6 +400,10 @@ func (raw *rawConfig) toConfig(baseDir string) *Config {
376400 MaxAgentHandoffs: DefaultMaxAgentHandoffs,
377401 },
378402 }
403+ cfg.AgentTools.Enabled = raw.AgentTools.Enabled == nil || *raw.AgentTools.Enabled
404+ if raw.AgentTools.Offer != nil {
405+ cfg.AgentTools.Offer = append([]string{}, *raw.AgentTools.Offer...)
406+ }
379407 if raw.Limits.MaxAgentHandoffs != nil {
380408 cfg.Limits.MaxAgentHandoffs = *raw.Limits.MaxAgentHandoffs
381409 }
@@ -493,6 +521,24 @@ func commandWarnings(cfg *Config, root *yaml.Node, language string) []Problem {
493521 return warnings
494522 }
495523
524+// toolWarnings reports the names of agentTools.offer that are no tool: they
525+// offer nothing, the other names still work.
526+func toolWarnings(cfg *Config, root *yaml.Node, language string) []Problem {
527+ var warnings []Problem
528+ for index, name := range cfg.AgentTools.Offer {
529+ if slices.Contains(AgentToolNames, name) {
530+ continue
531+ }
532+ path := []string{"agentTools", "offer", fmt.Sprint(index)}
533+ line, column := position(root, path)
534+ warnings = append(warnings, Problem{
535+ Line: line, Column: column, Path: displayPath(path), Warning: true,
536+ Message: message(language, msgUnknownTool, name, strings.Join(AgentToolNames, ", ")),
537+ })
538+ }
539+ return warnings
540+}
541+
496542 func commandExists(command string) bool {
497543 if filepath.IsAbs(command) {
498544 info, err := os.Stat(command)
@@ -22,6 +22,7 @@ import (
22 "os"22 "os"
23 "os/exec"23 "os/exec"
24 "path/filepath"24 "path/filepath"
25+ "slices"
25 "strings"26 "strings"
26 "time"27 "time"
27 28
@@ -41,12 +42,14 @@ const (
41 // Config is a loaded configuration: defaults applied and paths absolute.42 // Config is a loaded configuration: defaults applied and paths absolute.
42 type Config struct {43 type Config struct {
43 // Path is the absolute path of the file it was loaded from.44 // Path is the absolute path of the file it was loaded from.
44- Path string45+ Path string
45- Version int46+ Version int
46- UI UI47+ UI UI
47- Limits Limits48+ Limits Limits
48- Agents []Agent49+ // AgentTools says which tools Sidekicks offers the agents (issues #90 and #91).
49- Channels []Channel50+ AgentTools AgentTools
51+ Agents []Agent
52+ Channels []Channel
50 // Warnings are problems that do not prevent using the configuration,53 // Warnings are problems that do not prevent using the configuration,
51 // such as an agent command that cannot be found yet.54 // such as an agent command that cannot be found yet.
52 Warnings []Problem55 Warnings []Problem
@@ -69,6 +72,23 @@ type Limits struct {
69 MaxAgentHandoffs int72 MaxAgentHandoffs int
70 }73 }
71 74
75+// AgentToolNames are the tools Sidekicks can offer the agents, the names
76+// agentTools.offer accepts (issues #90 and #91).
77+var AgentToolNames = []string{"memory_pressure", "about_sidekicks", "current_channel", "list_channels", "list_agents", "search_messages"}
78+
79+// AgentTools says which tools Sidekicks offers the agents.
80+type AgentTools struct {
81+ // Enabled is false when no tool is offered; true by default.
82+ Enabled bool
83+ // Offer lists the tools offered; nil offers them all.
84+ Offer []string
85+}
86+
87+// Offers tells whether the tool called name is offered.
88+func (tools AgentTools) Offers(name string) bool {
89+ return tools.Enabled && (tools.Offer == nil || slices.Contains(tools.Offer, name))
90+}
91+
72 // Agent describes one agent Sidekicks can start.92 // Agent describes one agent Sidekicks can start.
73 type Agent struct {93 type Agent struct {
74 Name string94 Name string
@@ -319,7 +339,7 @@ func Parse(content []byte, path string) (*Config, error) {
319 }339 }
320 cfg := raw.toConfig(filepath.Dir(path))340 cfg := raw.toConfig(filepath.Dir(path))
321 cfg.Path = path341 cfg.Path = path
322- cfg.Warnings = withLanguage(commandWarnings(cfg, &root, language), language)342+ cfg.Warnings = withLanguage(append(commandWarnings(cfg, &root, language), toolWarnings(cfg, &root, language)...), language)
323 return cfg, nil343 return cfg, nil
324 }344 }
325 345
@@ -335,6 +355,10 @@ type rawConfig struct {
335 StopIdleAgentsAfter string `yaml:"stopIdleAgentsAfter"`355 StopIdleAgentsAfter string `yaml:"stopIdleAgentsAfter"`
336 MaxAgentHandoffs *int `yaml:"maxAgentHandoffs"`356 MaxAgentHandoffs *int `yaml:"maxAgentHandoffs"`
337 } `yaml:"limits"`357 } `yaml:"limits"`
358+ AgentTools struct {
359+ Enabled *bool `yaml:"enabled"`
360+ Offer *[]string `yaml:"offer"`
361+ } `yaml:"agentTools"`
338 Agents []struct {362 Agents []struct {
339 Name string `yaml:"name"`363 Name string `yaml:"name"`
340 Title string `yaml:"title"`364 Title string `yaml:"title"`
@@ -376,6 +400,10 @@ func (raw *rawConfig) toConfig(baseDir string) *Config {
376 MaxAgentHandoffs: DefaultMaxAgentHandoffs,400 MaxAgentHandoffs: DefaultMaxAgentHandoffs,
377 },401 },
378 }402 }
403+ cfg.AgentTools.Enabled = raw.AgentTools.Enabled == nil || *raw.AgentTools.Enabled
404+ if raw.AgentTools.Offer != nil {
405+ cfg.AgentTools.Offer = append([]string{}, *raw.AgentTools.Offer...)
406+ }
379 if raw.Limits.MaxAgentHandoffs != nil {407 if raw.Limits.MaxAgentHandoffs != nil {
380 cfg.Limits.MaxAgentHandoffs = *raw.Limits.MaxAgentHandoffs408 cfg.Limits.MaxAgentHandoffs = *raw.Limits.MaxAgentHandoffs
381 }409 }
@@ -493,6 +521,24 @@ func commandWarnings(cfg *Config, root *yaml.Node, language string) []Problem {
493 return warnings521 return warnings
494 }522 }
495 523
524+// toolWarnings reports the names of agentTools.offer that are no tool: they
525+// offer nothing, the other names still work.
526+func toolWarnings(cfg *Config, root *yaml.Node, language string) []Problem {
527+ var warnings []Problem
528+ for index, name := range cfg.AgentTools.Offer {
529+ if slices.Contains(AgentToolNames, name) {
530+ continue
531+ }
532+ path := []string{"agentTools", "offer", fmt.Sprint(index)}
533+ line, column := position(root, path)
534+ warnings = append(warnings, Problem{
535+ Line: line, Column: column, Path: displayPath(path), Warning: true,
536+ Message: message(language, msgUnknownTool, name, strings.Join(AgentToolNames, ", ")),
537+ })
538+ }
539+ return warnings
540+}
541+
496 func commandExists(command string) bool {542 func commandExists(command string) bool {
497 if filepath.IsAbs(command) {543 if filepath.IsAbs(command) {
498 info, err := os.Stat(command)544 info, err := os.Stat(command)
modified internal/config/config_test.go +42 -0
@@ -571,3 +571,45 @@ agents:
571571 }
572572 }
573573 }
574+
575+func TestAgentToolsAreOfferedByDefaultAndCanBeFiltered(t *testing.T) {
576+ cases := []struct {
577+ name, yaml string
578+ offered []string
579+ refused []string
580+ }{
581+ {"absent: all", "", config.AgentToolNames, nil},
582+ {"disabled", "agentTools:\n enabled: false\n", nil, config.AgentToolNames},
583+ {"filtered", "agentTools:\n offer: [memory_pressure, list_agents]\n", []string{"memory_pressure", "list_agents"}, []string{"search_messages", "current_channel"}},
584+ {"empty list", "agentTools:\n offer: []\n", nil, config.AgentToolNames},
585+ }
586+ for _, c := range cases {
587+ cfg, err := parse(t, "version: 1\n"+c.yaml+"agents: []\n")
588+ if err != nil {
589+ t.Fatalf("%s: %v", c.name, err)
590+ }
591+ for _, name := range c.offered {
592+ if !cfg.AgentTools.Offers(name) {
593+ t.Errorf("%s: %s should be offered", c.name, name)
594+ }
595+ }
596+ for _, name := range c.refused {
597+ if cfg.AgentTools.Offers(name) {
598+ t.Errorf("%s: %s should not be offered", c.name, name)
599+ }
600+ }
601+ }
602+}
603+
604+func TestAnUnknownToolIsOnlyAWarning(t *testing.T) {
605+ cfg, err := parse(t, "version: 1\nagentTools:\n offer:\n - memory_pressure\n - memory\nagents: []\n")
606+ if err != nil {
607+ t.Fatal(err)
608+ }
609+ if len(cfg.Warnings) != 1 || cfg.Warnings[0].Line != 5 || cfg.Warnings[0].Path != "agentTools.offer[1]" || !strings.Contains(cfg.Warnings[0].Message, `no tool is called "memory"; the tools are: memory_pressure, `) {
610+ t.Fatalf("want one warning at line 5, got %+v", cfg.Warnings)
611+ }
612+ if _, err := parse(t, "version: 1\nagentTools:\n enabled: yes please\nagents: []\n"); err == nil {
613+ t.Fatal("enabled is a boolean")
614+ }
615+}
@@ -571,3 +571,45 @@ agents:
571 }571 }
572 }572 }
573 }573 }
574+
575+func TestAgentToolsAreOfferedByDefaultAndCanBeFiltered(t *testing.T) {
576+ cases := []struct {
577+ name, yaml string
578+ offered []string
579+ refused []string
580+ }{
581+ {"absent: all", "", config.AgentToolNames, nil},
582+ {"disabled", "agentTools:\n enabled: false\n", nil, config.AgentToolNames},
583+ {"filtered", "agentTools:\n offer: [memory_pressure, list_agents]\n", []string{"memory_pressure", "list_agents"}, []string{"search_messages", "current_channel"}},
584+ {"empty list", "agentTools:\n offer: []\n", nil, config.AgentToolNames},
585+ }
586+ for _, c := range cases {
587+ cfg, err := parse(t, "version: 1\n"+c.yaml+"agents: []\n")
588+ if err != nil {
589+ t.Fatalf("%s: %v", c.name, err)
590+ }
591+ for _, name := range c.offered {
592+ if !cfg.AgentTools.Offers(name) {
593+ t.Errorf("%s: %s should be offered", c.name, name)
594+ }
595+ }
596+ for _, name := range c.refused {
597+ if cfg.AgentTools.Offers(name) {
598+ t.Errorf("%s: %s should not be offered", c.name, name)
599+ }
600+ }
601+ }
602+}
603+
604+func TestAnUnknownToolIsOnlyAWarning(t *testing.T) {
605+ cfg, err := parse(t, "version: 1\nagentTools:\n offer:\n - memory_pressure\n - memory\nagents: []\n")
606+ if err != nil {
607+ t.Fatal(err)
608+ }
609+ if len(cfg.Warnings) != 1 || cfg.Warnings[0].Line != 5 || cfg.Warnings[0].Path != "agentTools.offer[1]" || !strings.Contains(cfg.Warnings[0].Message, `no tool is called "memory"; the tools are: memory_pressure, `) {
610+ t.Fatalf("want one warning at line 5, got %+v", cfg.Warnings)
611+ }
612+ if _, err := parse(t, "version: 1\nagentTools:\n enabled: yes please\nagents: []\n"); err == nil {
613+ t.Fatal("enabled is a boolean")
614+ }
615+}
modified internal/config/default.go +6 -0
@@ -30,6 +30,12 @@ limits:
3030 # An agent unused for this long is stopped to free memory (e.g. 30s, 10m, 1h).
3131 stopIdleAgentsAfter: 10m
3232
33+# Tools Sidekicks offers the agents that can use them (mini-me): the memory
34+# pressure, the channels, the agents, a search in the history of every
35+# channel. false: no tool. To offer only some, list them under "offer:".
36+agentTools:
37+ enabled: true
38+
3339 # The agents: call them in a conversation by clicking their name.
3440 # The simplest way to add one is the "Add an agent" button of Sidekicks.
3541 agents: []
@@ -30,6 +30,12 @@ limits:
30 # An agent unused for this long is stopped to free memory (e.g. 30s, 10m, 1h).30 # An agent unused for this long is stopped to free memory (e.g. 30s, 10m, 1h).
31 stopIdleAgentsAfter: 10m31 stopIdleAgentsAfter: 10m
32 32
33+# Tools Sidekicks offers the agents that can use them (mini-me): the memory
34+# pressure, the channels, the agents, a search in the history of every
35+# channel. false: no tool. To offer only some, list them under "offer:".
36+agentTools:
37+ enabled: true
38+
33 # The agents: call them in a conversation by clicking their name.39 # The agents: call them in a conversation by clicking their name.
34 # The simplest way to add one is the "Add an agent" button of Sidekicks.40 # The simplest way to add one is the "Add an agent" button of Sidekicks.
35 agents: []41 agents: []
modified internal/config/problems.go +3 -0
@@ -90,6 +90,7 @@ const (
9090 msgDuplicateChan = "duplicateChan" // name
9191 msgUnknownMember = "unknownMember" // agent
9292 msgCommandNotFound = "commandNotFound" // command, agent
93+ msgUnknownTool = "unknownTool" // name, known names
9394 msgAbsolutePath = "absolutePath" // value
9495 msgTooLong = "tooLong" // maximum
9596 msgEmpty = "empty" // —
@@ -113,6 +114,7 @@ var messages = map[string]map[string]string{
113114 msgDuplicateChan: "il y a déjà un channel nommé « %s » ; les noms doivent être uniques",
114115 msgUnknownMember: "aucun agent ne s'appelle « %s »",
115116 msgCommandNotFound: "la commande « %s » de l'agent « %s » est introuvable ; installez-la ou corrigez le chemin",
117+ msgUnknownTool: "aucun outil ne s'appelle « %s » ; outils connus : %s",
116118 msgAbsolutePath: "« %s » doit être un chemin absolu (commençant par /)",
117119 msgTooLong: "texte trop long : %d caractères au maximum",
118120 msgEmpty: "la valeur ne peut pas être vide",
@@ -134,6 +136,7 @@ var messages = map[string]map[string]string{
134136 msgDuplicateChan: "there is already a channel called \"%s\"; names must be unique",
135137 msgUnknownMember: "no agent is called \"%s\"",
136138 msgCommandNotFound: "the command \"%s\" of agent \"%s\" cannot be found; install it or fix the path",
139+ msgUnknownTool: "no tool is called \"%s\"; the tools are: %s",
137140 msgAbsolutePath: "\"%s\" must be an absolute path (starting with /)",
138141 msgTooLong: "text too long: %d characters at most",
139142 msgEmpty: "the value cannot be empty",
@@ -90,6 +90,7 @@ const (
90 msgDuplicateChan = "duplicateChan" // name90 msgDuplicateChan = "duplicateChan" // name
91 msgUnknownMember = "unknownMember" // agent91 msgUnknownMember = "unknownMember" // agent
92 msgCommandNotFound = "commandNotFound" // command, agent92 msgCommandNotFound = "commandNotFound" // command, agent
93+ msgUnknownTool = "unknownTool" // name, known names
93 msgAbsolutePath = "absolutePath" // value94 msgAbsolutePath = "absolutePath" // value
94 msgTooLong = "tooLong" // maximum95 msgTooLong = "tooLong" // maximum
95 msgEmpty = "empty" // —96 msgEmpty = "empty" // —
@@ -113,6 +114,7 @@ var messages = map[string]map[string]string{
113 msgDuplicateChan: "il y a déjà un channel nommé « %s » ; les noms doivent être uniques",114 msgDuplicateChan: "il y a déjà un channel nommé « %s » ; les noms doivent être uniques",
114 msgUnknownMember: "aucun agent ne s'appelle « %s »",115 msgUnknownMember: "aucun agent ne s'appelle « %s »",
115 msgCommandNotFound: "la commande « %s » de l'agent « %s » est introuvable ; installez-la ou corrigez le chemin",116 msgCommandNotFound: "la commande « %s » de l'agent « %s » est introuvable ; installez-la ou corrigez le chemin",
117+ msgUnknownTool: "aucun outil ne s'appelle « %s » ; outils connus : %s",
116 msgAbsolutePath: "« %s » doit être un chemin absolu (commençant par /)",118 msgAbsolutePath: "« %s » doit être un chemin absolu (commençant par /)",
117 msgTooLong: "texte trop long : %d caractères au maximum",119 msgTooLong: "texte trop long : %d caractères au maximum",
118 msgEmpty: "la valeur ne peut pas être vide",120 msgEmpty: "la valeur ne peut pas être vide",
@@ -134,6 +136,7 @@ var messages = map[string]map[string]string{
134 msgDuplicateChan: "there is already a channel called \"%s\"; names must be unique",136 msgDuplicateChan: "there is already a channel called \"%s\"; names must be unique",
135 msgUnknownMember: "no agent is called \"%s\"",137 msgUnknownMember: "no agent is called \"%s\"",
136 msgCommandNotFound: "the command \"%s\" of agent \"%s\" cannot be found; install it or fix the path",138 msgCommandNotFound: "the command \"%s\" of agent \"%s\" cannot be found; install it or fix the path",
139+ msgUnknownTool: "no tool is called \"%s\"; the tools are: %s",
137 msgAbsolutePath: "\"%s\" must be an absolute path (starting with /)",140 msgAbsolutePath: "\"%s\" must be an absolute path (starting with /)",
138 msgTooLong: "text too long: %d characters at most",141 msgTooLong: "text too long: %d characters at most",
139 msgEmpty: "the value cannot be empty",142 msgEmpty: "the value cannot be empty",
modified schema/config.schema.json +31 -0
@@ -20,6 +20,9 @@
2020 "limits": {
2121 "$ref": "#/$defs/limits"
2222 },
23+ "agentTools": {
24+ "$ref": "#/$defs/agentTools"
25+ },
2326 "agents": {
2427 "description": "The agents available with @name. Names must be unique.",
2528 "type": "array",
@@ -94,6 +97,34 @@
9497 }
9598 }
9699 },
100+ "agentTools": {
101+ "description": "The tools Sidekicks offers the agents that can discover them (mini-me, with acp.clientTools in its file). Read when an agent starts.",
102+ "type": "object",
103+ "additionalProperties": false,
104+ "properties": {
105+ "enabled": {
106+ "description": "false: no tool is offered to the agents.",
107+ "type": "boolean",
108+ "default": true
109+ },
110+ "offer": {
111+ "description": "Only these tools are offered; absent: all of them. The tools: memory_pressure, about_sidekicks, current_channel, list_channels, list_agents, search_messages (list_channels and search_messages read the history of every channel).",
112+ "type": "array",
113+ "uniqueItems": true,
114+ "items": {
115+ "type": "string",
116+ "examples": [
117+ "memory_pressure",
118+ "about_sidekicks",
119+ "current_channel",
120+ "list_channels",
121+ "list_agents",
122+ "search_messages"
123+ ]
124+ }
125+ }
126+ }
127+ },
97128 "agent": {
98129 "type": "object",
99130 "additionalProperties": false,
@@ -20,6 +20,9 @@
20 "limits": {20 "limits": {
21 "$ref": "#/$defs/limits"21 "$ref": "#/$defs/limits"
22 },22 },
23+ "agentTools": {
24+ "$ref": "#/$defs/agentTools"
25+ },
23 "agents": {26 "agents": {
24 "description": "The agents available with @name. Names must be unique.",27 "description": "The agents available with @name. Names must be unique.",
25 "type": "array",28 "type": "array",
@@ -94,6 +97,34 @@
94 }97 }
95 }98 }
96 },99 },
100+ "agentTools": {
101+ "description": "The tools Sidekicks offers the agents that can discover them (mini-me, with acp.clientTools in its file). Read when an agent starts.",
102+ "type": "object",
103+ "additionalProperties": false,
104+ "properties": {
105+ "enabled": {
106+ "description": "false: no tool is offered to the agents.",
107+ "type": "boolean",
108+ "default": true
109+ },
110+ "offer": {
111+ "description": "Only these tools are offered; absent: all of them. The tools: memory_pressure, about_sidekicks, current_channel, list_channels, list_agents, search_messages (list_channels and search_messages read the history of every channel).",
112+ "type": "array",
113+ "uniqueItems": true,
114+ "items": {
115+ "type": "string",
116+ "examples": [
117+ "memory_pressure",
118+ "about_sidekicks",
119+ "current_channel",
120+ "list_channels",
121+ "list_agents",
122+ "search_messages"
123+ ]
124+ }
125+ }
126+ }
127+ },
97 "agent": {128 "agent": {
98 "type": "object",129 "type": "object",
99 "additionalProperties": false,130 "additionalProperties": false,