#91 Agent à redémarrer quand ses outils changent ; outils à rappeler à chaque fois ; brouillon gardé par conversation
- agentTools modifié : un agent en marche dont les outils proposés diffèrent est marqué « à redémarrer » (il gardait les outils de son démarrage). - Les descriptions des outils dont le résultat change demandent au modèle de les rappeler à chaque fois au lieu de réutiliser une réponse précédente. - Le texte en cours de saisie est gardé par channel ou conversation et rendu au retour (tant que Sidekicks tourne). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1ef0bf4 parent: 2ec3a89 modified
docs/en/how-to/manage-channels.md +1 -0 | @@ -74,6 +74,7 @@ An agent does not call itself, an agent that answers your message anyway is not | ||
| 74 | 74 | |
| 75 | 75 | ## Variants |
| 76 | 76 | |
| 77 | +- **Leave a message half written**: switch to another channel or conversation; when you come back, the text you were writing is still there, until you send it. Drafts are kept while Sidekicks runs, not after quitting. | |
| 77 | 78 | - **Fold the lists of the left panel**: click the heading **AGENTS** or **CHANNELS** to fold the list under it, again to unfold it. Folded, the heading still shows how many agents or channels there are and, in blue, the answers you have not read yet. Sidekicks remembers it at the next launch. ⌘N unfolds the channels to create one; **Add an agent** stays in the command palette (⌘K) and on ⇧⌘N. |
| 78 | 79 | - **Channels from the configuration file**: channels declared under `channels:` are created at startup if they do not exist yet, with their agents; afterwards they are ordinary channels. Removing them from the file deletes nothing ([configuration reference](../reference/configuration.md)). |
| 79 | 80 | - **Start again from an empty history, for every channel at once**: use the **Danger zone** ([Reset Sidekicks](reset-sidekicks.md)), or quit Sidekicks and delete the folder `sidekicks/data/<…>` of your configuration (its location is in the [reference](../reference/agents-and-events.md#history)). The channels declared in the file come back at the next launch, empty. |
| @@ -74,6 +74,7 @@ An agent does not call itself, an agent that answers your message anyway is not | |||
| 74 | 74 | ||
| 75 | ## Variants | 75 | ## Variants |
| 76 | 76 | ||
| 77 | +- **Leave a message half written**: switch to another channel or conversation; when you come back, the text you were writing is still there, until you send it. Drafts are kept while Sidekicks runs, not after quitting. | ||
| 77 | - **Fold the lists of the left panel**: click the heading **AGENTS** or **CHANNELS** to fold the list under it, again to unfold it. Folded, the heading still shows how many agents or channels there are and, in blue, the answers you have not read yet. Sidekicks remembers it at the next launch. ⌘N unfolds the channels to create one; **Add an agent** stays in the command palette (⌘K) and on ⇧⌘N. | 78 | - **Fold the lists of the left panel**: click the heading **AGENTS** or **CHANNELS** to fold the list under it, again to unfold it. Folded, the heading still shows how many agents or channels there are and, in blue, the answers you have not read yet. Sidekicks remembers it at the next launch. ⌘N unfolds the channels to create one; **Add an agent** stays in the command palette (⌘K) and on ⇧⌘N. |
| 78 | - **Channels from the configuration file**: channels declared under `channels:` are created at startup if they do not exist yet, with their agents; afterwards they are ordinary channels. Removing them from the file deletes nothing ([configuration reference](../reference/configuration.md)). | 79 | - **Channels from the configuration file**: channels declared under `channels:` are created at startup if they do not exist yet, with their agents; afterwards they are ordinary channels. Removing them from the file deletes nothing ([configuration reference](../reference/configuration.md)). |
| 79 | - **Start again from an empty history, for every channel at once**: use the **Danger zone** ([Reset Sidekicks](reset-sidekicks.md)), or quit Sidekicks and delete the folder `sidekicks/data/<…>` of your configuration (its location is in the [reference](../reference/agents-and-events.md#history)). The channels declared in the file come back at the next launch, empty. | 80 | - **Start again from an empty history, for every channel at once**: use the **Danger zone** ([Reset Sidekicks](reset-sidekicks.md)), or quit Sidekicks and delete the folder `sidekicks/data/<…>` of your configuration (its location is in the [reference](../reference/agents-and-events.md#history)). The channels declared in the file come back at the next launch, empty. |
modified
docs/en/how-to/use-sidekicks-tools-from-an-agent.md +2 -2 | @@ -26,7 +26,7 @@ This guide shows how to let a mini-me agent (`mm`) call the tools Sidekicks offe | ||
| 26 | 26 | |
| 27 | 27 | The call shows in its answer like any tool call (`client: memory_pressure`), and in its log (`[acp] client tools (meta): …` at start). |
| 28 | 28 | |
| 29 | -A small model calls a tool more readily when its instructions name it: add to its `system:` a line such as "Call client_current_channel to know where you are and who is there." | |
| 29 | +A model may answer a question it was already asked from its earlier answer instead of calling the tool again; the descriptions of the tools whose result changes (memory, channels, agents, search) tell it to call again each time, and a small model follows that better when its instructions say it too. A small model also calls a tool more readily when its instructions name it: add to its `system:` a line such as "Call client_current_channel to know where you are and who is there." | |
| 30 | 30 | |
| 31 | 31 | ## Variants |
| 32 | 32 | |
| @@ -41,7 +41,7 @@ A small model calls a tool more readily when its instructions name it: add to it | ||
| 41 | 41 | - list_agents |
| 42 | 42 | ``` |
| 43 | 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. | |
| 44 | + then save. The tools are read when an agent starts: a running agent whose tools change shows "restart to apply changes"; restart it. The editor suggests the names after `- `. An unknown name is shown as a warning. | |
| 45 | 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 | 46 | |
| 47 | 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. |
| @@ -26,7 +26,7 @@ This guide shows how to let a mini-me agent (`mm`) call the tools Sidekicks offe | |||
| 26 | 26 | ||
| 27 | 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). |
| 28 | 28 | ||
| 29 | -A small model calls a tool more readily when its instructions name it: add to its `system:` a line such as "Call client_current_channel to know where you are and who is there." | 29 | +A model may answer a question it was already asked from its earlier answer instead of calling the tool again; the descriptions of the tools whose result changes (memory, channels, agents, search) tell it to call again each time, and a small model follows that better when its instructions say it too. A small model also calls a tool more readily when its instructions name it: add to its `system:` a line such as "Call client_current_channel to know where you are and who is there." |
| 30 | 30 | ||
| 31 | ## Variants | 31 | ## Variants |
| 32 | 32 | ||
| @@ -41,7 +41,7 @@ A small model calls a tool more readily when its instructions name it: add to it | |||
| 41 | - list_agents | 41 | - list_agents |
| 42 | ``` | 42 | ``` |
| 43 | 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. | 44 | + then save. The tools are read when an agent starts: a running agent whose tools change shows "restart to apply changes"; restart it. 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. | 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 | 46 | ||
| 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. | 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. |
modified
docs/en/reference/configuration.md +1 -1 | @@ -61,7 +61,7 @@ Unknown keys are **errors**, at every level: a misspelt `comand:` must be report | ||
| 61 | 61 | |
| 62 | 62 | ### `agentTools` |
| 63 | 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. | |
| 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: after a change, a running agent whose tools differ shows "restart to apply changes" next to its name; restart it to apply. | |
| 65 | 65 | |
| 66 | 66 | | Key | Type | Default | Meaning | |
| 67 | 67 | | --- | --- | --- | --- | |
| @@ -61,7 +61,7 @@ Unknown keys are **errors**, at every level: a misspelt `comand:` must be report | |||
| 61 | 61 | ||
| 62 | ### `agentTools` | 62 | ### `agentTools` |
| 63 | 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. | 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: after a change, a running agent whose tools differ shows "restart to apply changes" next to its name; restart it to apply. |
| 65 | 65 | ||
| 66 | | Key | Type | Default | Meaning | | 66 | | Key | Type | Default | Meaning | |
| 67 | | --- | --- | --- | --- | | 67 | | --- | --- | --- | --- | |
modified
docs/fr/how-to/gerer-les-channels.md +1 -0 | @@ -74,6 +74,7 @@ Un agent ne s'appelle pas lui-même, un agent qui répond de toute façon à vot | ||
| 74 | 74 | |
| 75 | 75 | ## Variantes |
| 76 | 76 | |
| 77 | +- **Laisser un message à moitié écrit** : passez à un autre channel ou à une autre conversation ; quand vous revenez, le texte en cours est toujours là, jusqu'à ce que vous l'envoyiez. Les brouillons sont gardés tant que Sidekicks tourne, pas après l'avoir quitté. | |
| 77 | 78 | - **Replier les listes du panneau de gauche** : cliquez sur le titre **AGENTS** ou **CHANNELS** pour replier la liste, à nouveau pour la déplier. Repliée, le titre indique toujours combien il y a d'agents ou de channels et, en bleu, les réponses pas encore lues. Sidekicks s'en souvient au lancement suivant. ⌘N déplie les channels pour en créer un ; **Ajouter un agent** reste dans la palette de commandes (⌘K) et sur ⇧⌘N. |
| 78 | 79 | - **Channels du fichier de configuration** : les channels déclarés sous `channels:` sont créés au démarrage s'ils n'existent pas encore, avec leurs agents ; ensuite ce sont des channels ordinaires. Les retirer du fichier ne supprime rien ([référence de la configuration](../reference/configuration.md)). |
| 79 | 80 | - **Repartir d'un historique vide, pour tous les channels d'un coup** : utilisez la **Danger zone** ([Repartir de zéro](repartir-de-zero.md)), ou quittez Sidekicks et supprimez le dossier `sidekicks/data/<…>` de votre configuration (son emplacement est dans la [référence](../reference/agents-et-evenements.md#historique)). Les channels déclarés dans le fichier reviennent, vides, au lancement suivant. |
| @@ -74,6 +74,7 @@ Un agent ne s'appelle pas lui-même, un agent qui répond de toute façon à vot | |||
| 74 | 74 | ||
| 75 | ## Variantes | 75 | ## Variantes |
| 76 | 76 | ||
| 77 | +- **Laisser un message à moitié écrit** : passez à un autre channel ou à une autre conversation ; quand vous revenez, le texte en cours est toujours là, jusqu'à ce que vous l'envoyiez. Les brouillons sont gardés tant que Sidekicks tourne, pas après l'avoir quitté. | ||
| 77 | - **Replier les listes du panneau de gauche** : cliquez sur le titre **AGENTS** ou **CHANNELS** pour replier la liste, à nouveau pour la déplier. Repliée, le titre indique toujours combien il y a d'agents ou de channels et, en bleu, les réponses pas encore lues. Sidekicks s'en souvient au lancement suivant. ⌘N déplie les channels pour en créer un ; **Ajouter un agent** reste dans la palette de commandes (⌘K) et sur ⇧⌘N. | 78 | - **Replier les listes du panneau de gauche** : cliquez sur le titre **AGENTS** ou **CHANNELS** pour replier la liste, à nouveau pour la déplier. Repliée, le titre indique toujours combien il y a d'agents ou de channels et, en bleu, les réponses pas encore lues. Sidekicks s'en souvient au lancement suivant. ⌘N déplie les channels pour en créer un ; **Ajouter un agent** reste dans la palette de commandes (⌘K) et sur ⇧⌘N. |
| 78 | - **Channels du fichier de configuration** : les channels déclarés sous `channels:` sont créés au démarrage s'ils n'existent pas encore, avec leurs agents ; ensuite ce sont des channels ordinaires. Les retirer du fichier ne supprime rien ([référence de la configuration](../reference/configuration.md)). | 79 | - **Channels du fichier de configuration** : les channels déclarés sous `channels:` sont créés au démarrage s'ils n'existent pas encore, avec leurs agents ; ensuite ce sont des channels ordinaires. Les retirer du fichier ne supprime rien ([référence de la configuration](../reference/configuration.md)). |
| 79 | - **Repartir d'un historique vide, pour tous les channels d'un coup** : utilisez la **Danger zone** ([Repartir de zéro](repartir-de-zero.md)), ou quittez Sidekicks et supprimez le dossier `sidekicks/data/<…>` de votre configuration (son emplacement est dans la [référence](../reference/agents-et-evenements.md#historique)). Les channels déclarés dans le fichier reviennent, vides, au lancement suivant. | 80 | - **Repartir d'un historique vide, pour tous les channels d'un coup** : utilisez la **Danger zone** ([Repartir de zéro](repartir-de-zero.md)), ou quittez Sidekicks et supprimez le dossier `sidekicks/data/<…>` de votre configuration (son emplacement est dans la [référence](../reference/agents-et-evenements.md#historique)). Les channels déclarés dans le fichier reviennent, vides, au lancement suivant. |
modified
docs/fr/how-to/utiliser-les-outils-de-sidekicks-depuis-un-agent.md +2 -2 | @@ -26,7 +26,7 @@ Ce guide montre comment laisser un agent mini-me (`mm`) appeler les outils que S | ||
| 26 | 26 | |
| 27 | 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). |
| 28 | 28 | |
| 29 | -Un petit modèle appelle plus volontiers un outil que ses instructions nomment : ajoutez à son `system:` une ligne comme « Call client_current_channel to know where you are and who is there. » | |
| 29 | +Un modèle peut répondre à une question déjà posée avec sa réponse précédente au lieu de rappeler l'outil ; les descriptions des outils dont le résultat change (mémoire, channels, agents, recherche) lui demandent de le rappeler à chaque fois, et un petit modèle le fait mieux quand ses instructions le disent aussi. Un petit modèle appelle aussi plus volontiers un outil que ses instructions nomment : ajoutez à son `system:` une ligne comme « Call client_current_channel to know where you are and who is there. » | |
| 30 | 30 | |
| 31 | 31 | ## Variantes |
| 32 | 32 | |
| @@ -41,7 +41,7 @@ Un petit modèle appelle plus volontiers un outil que ses instructions nomment : | ||
| 41 | 41 | - list_agents |
| 42 | 42 | ``` |
| 43 | 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. | |
| 44 | + puis enregistrez. Les outils sont lus au démarrage d'un agent : un agent en marche dont les outils changent affiche « à redémarrer » ; redémarrez-le. L'éditeur propose les noms après `- `. Un nom inconnu s'affiche en avertissement. | |
| 45 | 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 | 46 | |
| 47 | 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. |
| @@ -26,7 +26,7 @@ Ce guide montre comment laisser un agent mini-me (`mm`) appeler les outils que S | |||
| 26 | 26 | ||
| 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). | 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). |
| 28 | 28 | ||
| 29 | -Un petit modèle appelle plus volontiers un outil que ses instructions nomment : ajoutez à son `system:` une ligne comme « Call client_current_channel to know where you are and who is there. » | 29 | +Un modèle peut répondre à une question déjà posée avec sa réponse précédente au lieu de rappeler l'outil ; les descriptions des outils dont le résultat change (mémoire, channels, agents, recherche) lui demandent de le rappeler à chaque fois, et un petit modèle le fait mieux quand ses instructions le disent aussi. Un petit modèle appelle aussi plus volontiers un outil que ses instructions nomment : ajoutez à son `system:` une ligne comme « Call client_current_channel to know where you are and who is there. » |
| 30 | 30 | ||
| 31 | ## Variantes | 31 | ## Variantes |
| 32 | 32 | ||
| @@ -41,7 +41,7 @@ Un petit modèle appelle plus volontiers un outil que ses instructions nomment : | |||
| 41 | - list_agents | 41 | - list_agents |
| 42 | ``` | 42 | ``` |
| 43 | 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. | 44 | + puis enregistrez. Les outils sont lus au démarrage d'un agent : un agent en marche dont les outils changent affiche « à redémarrer » ; redémarrez-le. 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é. | 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 | 46 | ||
| 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. | 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. |
modified
docs/fr/reference/configuration.md +1 -1 | @@ -61,7 +61,7 @@ Les clés inconnues sont des **erreurs**, à tous les niveaux : une faute de fra | ||
| 61 | 61 | |
| 62 | 62 | ### `agentTools` |
| 63 | 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. | |
| 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 : après un changement, un agent en marche dont les outils diffèrent affiche « à redémarrer » à côté de son nom ; redémarrez-le pour appliquer. | |
| 65 | 65 | |
| 66 | 66 | | Clé | Type | Défaut | Signification | |
| 67 | 67 | | --- | --- | --- | --- | |
| @@ -61,7 +61,7 @@ Les clés inconnues sont des **erreurs**, à tous les niveaux : une faute de fra | |||
| 61 | 61 | ||
| 62 | ### `agentTools` | 62 | ### `agentTools` |
| 63 | 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. | 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 : après un changement, un agent en marche dont les outils diffèrent affiche « à redémarrer » à côté de son nom ; redémarrez-le pour appliquer. |
| 65 | 65 | ||
| 66 | | Clé | Type | Défaut | Signification | | 66 | | Clé | Type | Défaut | Signification | |
| 67 | | --- | --- | --- | --- | | 67 | | --- | --- | --- | --- | |
modified
frontend/src/lib/chat/Composer.svelte +9 -1 | @@ -1,5 +1,6 @@ | ||
| 1 | 1 | <!-- Copyright (c) 2026 Philippe Charrière — Sidekicks Source-Available License 1.0, see LICENSE --> |
| 2 | 2 | <script lang="ts"> |
| 3 | + import { untrack } from 'svelte' | |
| 3 | 4 | import { t } from '../i18n/index.svelte' |
| 4 | 5 | import { completeTrigger, createHistory, findTrigger, insertAt, type Trigger } from '../composer' |
| 5 | 6 | import type { Suggestion, Suggestions } from '../suggestions' |
| @@ -16,6 +17,8 @@ | ||
| 16 | 17 | onStop, |
| 17 | 18 | onAttach, |
| 18 | 19 | dropTarget, |
| 20 | + draft = '', | |
| 21 | + onDraft = () => {}, | |
| 19 | 22 | }: { |
| 20 | 23 | placeholder: string |
| 21 | 24 | busy?: boolean |
| @@ -32,9 +35,14 @@ | ||
| 32 | 35 | onAttach?: () => void |
| 33 | 36 | /** The id of the composer as a drop target for files (Wails files:dropped). */ |
| 34 | 37 | dropTarget?: string |
| 38 | + /** The text being written when the composer was left, given back. */ | |
| 39 | + draft?: string | |
| 40 | + /** Called with the text as it changes, to keep it as the draft. */ | |
| 41 | + onDraft?: (text: string) => void | |
| 35 | 42 | } = $props() |
| 36 | 43 | |
| 37 | - let text = $state('') | |
| 44 | + let text = $state(untrack(() => draft)) | |
| 45 | + $effect(() => onDraft(text)) | |
| 38 | 46 | let textarea: HTMLTextAreaElement |
| 39 | 47 | const history = createHistory() |
| 40 | 48 | |
| @@ -1,5 +1,6 @@ | |||
| 1 | <!-- Copyright (c) 2026 Philippe Charrière — Sidekicks Source-Available License 1.0, see LICENSE --> | 1 | <!-- Copyright (c) 2026 Philippe Charrière — Sidekicks Source-Available License 1.0, see LICENSE --> |
| 2 | <script lang="ts"> | 2 | <script lang="ts"> |
| 3 | + import { untrack } from 'svelte' | ||
| 3 | import { t } from '../i18n/index.svelte' | 4 | import { t } from '../i18n/index.svelte' |
| 4 | import { completeTrigger, createHistory, findTrigger, insertAt, type Trigger } from '../composer' | 5 | import { completeTrigger, createHistory, findTrigger, insertAt, type Trigger } from '../composer' |
| 5 | import type { Suggestion, Suggestions } from '../suggestions' | 6 | import type { Suggestion, Suggestions } from '../suggestions' |
| @@ -16,6 +17,8 @@ | |||
| 16 | onStop, | 17 | onStop, |
| 17 | onAttach, | 18 | onAttach, |
| 18 | dropTarget, | 19 | dropTarget, |
| 20 | + draft = '', | ||
| 21 | + onDraft = () => {}, | ||
| 19 | }: { | 22 | }: { |
| 20 | placeholder: string | 23 | placeholder: string |
| 21 | busy?: boolean | 24 | busy?: boolean |
| @@ -32,9 +35,14 @@ | |||
| 32 | onAttach?: () => void | 35 | onAttach?: () => void |
| 33 | /** The id of the composer as a drop target for files (Wails files:dropped). */ | 36 | /** The id of the composer as a drop target for files (Wails files:dropped). */ |
| 34 | dropTarget?: string | 37 | dropTarget?: string |
| 38 | + /** The text being written when the composer was left, given back. */ | ||
| 39 | + draft?: string | ||
| 40 | + /** Called with the text as it changes, to keep it as the draft. */ | ||
| 41 | + onDraft?: (text: string) => void | ||
| 35 | } = $props() | 42 | } = $props() |
| 36 | 43 | ||
| 37 | - let text = $state('') | 44 | + let text = $state(untrack(() => draft)) |
| 45 | + $effect(() => onDraft(text)) | ||
| 38 | let textarea: HTMLTextAreaElement | 46 | let textarea: HTMLTextAreaElement |
| 39 | const history = createHistory() | 47 | const history = createHistory() |
| 40 | 48 | ||
modified
frontend/src/lib/composer.test.ts +14 -1 | @@ -1,7 +1,7 @@ | ||
| 1 | 1 | // Copyright (c) 2026 Philippe Charrière — Sidekicks Source-Available License 1.0, see LICENSE |
| 2 | 2 | |
| 3 | 3 | import { describe, expect, it } from 'vitest' |
| 4 | -import { completeTrigger, createHistory, findTrigger, isNearBottom } from './composer' | |
| 4 | +import { completeTrigger, createDrafts, createHistory, findTrigger, isNearBottom } from './composer' | |
| 5 | 5 | |
| 6 | 6 | describe('findTrigger', () => { |
| 7 | 7 | it('finds a trigger at the start or after a space', () => { |
| @@ -49,3 +49,16 @@ describe('isNearBottom', () => { | ||
| 49 | 49 | expect(isNearBottom(500, 100, 1000)).toBe(false) |
| 50 | 50 | }) |
| 51 | 51 | }) |
| 52 | + | |
| 53 | +describe('drafts', () => { | |
| 54 | + it('gives back the text of each conversation, and forgets an empty one', () => { | |
| 55 | + const drafts = createDrafts() | |
| 56 | + drafts.keep('c1', 'Hello @ali') | |
| 57 | + drafts.keep('c2', 'other') | |
| 58 | + expect(drafts.of('c1')).toBe('Hello @ali') | |
| 59 | + expect(drafts.of('c3')).toBe('') | |
| 60 | + drafts.keep('c1', ' ') | |
| 61 | + expect(drafts.of('c1')).toBe('') | |
| 62 | + expect(drafts.of('c2')).toBe('other') | |
| 63 | + }) | |
| 64 | +}) | |
| @@ -1,7 +1,7 @@ | |||
| 1 | // Copyright (c) 2026 Philippe Charrière — Sidekicks Source-Available License 1.0, see LICENSE | 1 | // Copyright (c) 2026 Philippe Charrière — Sidekicks Source-Available License 1.0, see LICENSE |
| 2 | 2 | ||
| 3 | import { describe, expect, it } from 'vitest' | 3 | import { describe, expect, it } from 'vitest' |
| 4 | -import { completeTrigger, createHistory, findTrigger, isNearBottom } from './composer' | 4 | +import { completeTrigger, createDrafts, createHistory, findTrigger, isNearBottom } from './composer' |
| 5 | 5 | ||
| 6 | describe('findTrigger', () => { | 6 | describe('findTrigger', () => { |
| 7 | it('finds a trigger at the start or after a space', () => { | 7 | it('finds a trigger at the start or after a space', () => { |
| @@ -49,3 +49,16 @@ describe('isNearBottom', () => { | |||
| 49 | expect(isNearBottom(500, 100, 1000)).toBe(false) | 49 | expect(isNearBottom(500, 100, 1000)).toBe(false) |
| 50 | }) | 50 | }) |
| 51 | }) | 51 | }) |
| 52 | + | ||
| 53 | +describe('drafts', () => { | ||
| 54 | + it('gives back the text of each conversation, and forgets an empty one', () => { | ||
| 55 | + const drafts = createDrafts() | ||
| 56 | + drafts.keep('c1', 'Hello @ali') | ||
| 57 | + drafts.keep('c2', 'other') | ||
| 58 | + expect(drafts.of('c1')).toBe('Hello @ali') | ||
| 59 | + expect(drafts.of('c3')).toBe('') | ||
| 60 | + drafts.keep('c1', ' ') | ||
| 61 | + expect(drafts.of('c1')).toBe('') | ||
| 62 | + expect(drafts.of('c2')).toBe('other') | ||
| 63 | + }) | ||
| 64 | +}) | ||
modified
frontend/src/lib/composer.ts +22 -0 | @@ -89,3 +89,25 @@ export function createHistory() { | ||
| 89 | 89 | export function isNearBottom(scrollTop: number, clientHeight: number, scrollHeight: number, margin = 48): boolean { |
| 90 | 90 | return scrollHeight - (scrollTop + clientHeight) <= margin |
| 91 | 91 | } |
| 92 | + | |
| 93 | +/** | |
| 94 | + * The messages being written, by conversation: switching to another channel | |
| 95 | + * and back gives the text back. Kept while Sidekicks runs. | |
| 96 | + * | |
| 97 | + * @example | |
| 98 | + * drafts.keep('c1', 'Hello @ali') | |
| 99 | + * drafts.of('c1') // 'Hello @ali' | |
| 100 | + */ | |
| 101 | +export function createDrafts() { | |
| 102 | + const texts = new Map<string, string>() | |
| 103 | + return { | |
| 104 | + of: (id: string): string => texts.get(id) ?? '', | |
| 105 | + keep(id: string, text: string) { | |
| 106 | + if (text.trim() === '') texts.delete(id) | |
| 107 | + else texts.set(id, text) | |
| 108 | + }, | |
| 109 | + } | |
| 110 | +} | |
| 111 | + | |
| 112 | +/** The drafts of every conversation of the window. */ | |
| 113 | +export const drafts = createDrafts() | |
| @@ -89,3 +89,25 @@ export function createHistory() { | |||
| 89 | export function isNearBottom(scrollTop: number, clientHeight: number, scrollHeight: number, margin = 48): boolean { | 89 | export function isNearBottom(scrollTop: number, clientHeight: number, scrollHeight: number, margin = 48): boolean { |
| 90 | return scrollHeight - (scrollTop + clientHeight) <= margin | 90 | return scrollHeight - (scrollTop + clientHeight) <= margin |
| 91 | } | 91 | } |
| 92 | + | ||
| 93 | +/** | ||
| 94 | + * The messages being written, by conversation: switching to another channel | ||
| 95 | + * and back gives the text back. Kept while Sidekicks runs. | ||
| 96 | + * | ||
| 97 | + * @example | ||
| 98 | + * drafts.keep('c1', 'Hello @ali') | ||
| 99 | + * drafts.of('c1') // 'Hello @ali' | ||
| 100 | + */ | ||
| 101 | +export function createDrafts() { | ||
| 102 | + const texts = new Map<string, string>() | ||
| 103 | + return { | ||
| 104 | + of: (id: string): string => texts.get(id) ?? '', | ||
| 105 | + keep(id: string, text: string) { | ||
| 106 | + if (text.trim() === '') texts.delete(id) | ||
| 107 | + else texts.set(id, text) | ||
| 108 | + }, | ||
| 109 | + } | ||
| 110 | +} | ||
| 111 | + | ||
| 112 | +/** The drafts of every conversation of the window. */ | ||
| 113 | +export const drafts = createDrafts() | ||
modified
frontend/src/lib/panels/ConversationPanel.svelte +3 -1 | @@ -14,7 +14,7 @@ | ||
| 14 | 14 | import { textIcon } from '../avatar' |
| 15 | 15 | import ActionError from '../chat/ActionError.svelte' |
| 16 | 16 | import Logo from '../layout/Logo.svelte' |
| 17 | - import { isNearBottom, type Trigger } from '../composer' | |
| 17 | + import { drafts, isNearBottom, type Trigger } from '../composer' | |
| 18 | 18 | import { notStreaming, usagePercent } from '../conversation' |
| 19 | 19 | import { act, addMember, agentTitle, appState, cancel, channelOf, clearHistory, loadOlder, openAssistant, prepareCommands, removeMember, send } from '../state.svelte' |
| 20 | 20 | import { ConfigService, WorkspaceService } from '../../../bindings/git.rickub.com/bots-garden/sidekicks/internal/app' |
| @@ -308,6 +308,8 @@ | ||
| 308 | 308 | dropTarget={composerTarget} |
| 309 | 309 | onSend={(text) => send(channel.id, text)} |
| 310 | 310 | onStop={() => cancel(channel.id)} |
| 311 | + draft={drafts.of(channel.id)} | |
| 312 | + onDraft={(text) => drafts.keep(channel.id, text)} | |
| 311 | 313 | /> |
| 312 | 314 | {/key} |
| 313 | 315 | </div> |
| @@ -14,7 +14,7 @@ | |||
| 14 | import { textIcon } from '../avatar' | 14 | import { textIcon } from '../avatar' |
| 15 | import ActionError from '../chat/ActionError.svelte' | 15 | import ActionError from '../chat/ActionError.svelte' |
| 16 | import Logo from '../layout/Logo.svelte' | 16 | import Logo from '../layout/Logo.svelte' |
| 17 | - import { isNearBottom, type Trigger } from '../composer' | 17 | + import { drafts, isNearBottom, type Trigger } from '../composer' |
| 18 | import { notStreaming, usagePercent } from '../conversation' | 18 | import { notStreaming, usagePercent } from '../conversation' |
| 19 | import { act, addMember, agentTitle, appState, cancel, channelOf, clearHistory, loadOlder, openAssistant, prepareCommands, removeMember, send } from '../state.svelte' | 19 | import { act, addMember, agentTitle, appState, cancel, channelOf, clearHistory, loadOlder, openAssistant, prepareCommands, removeMember, send } from '../state.svelte' |
| 20 | import { ConfigService, WorkspaceService } from '../../../bindings/git.rickub.com/bots-garden/sidekicks/internal/app' | 20 | import { ConfigService, WorkspaceService } from '../../../bindings/git.rickub.com/bots-garden/sidekicks/internal/app' |
| @@ -308,6 +308,8 @@ | |||
| 308 | dropTarget={composerTarget} | 308 | dropTarget={composerTarget} |
| 309 | onSend={(text) => send(channel.id, text)} | 309 | onSend={(text) => send(channel.id, text)} |
| 310 | onStop={() => cancel(channel.id)} | 310 | onStop={() => cancel(channel.id)} |
| 311 | + draft={drafts.of(channel.id)} | ||
| 312 | + onDraft={(text) => drafts.keep(channel.id, text)} | ||
| 311 | /> | 313 | /> |
| 312 | {/key} | 314 | {/key} |
| 313 | </div> | 315 | </div> |
modified
internal/agents/manager.go +27 -5 | @@ -20,6 +20,7 @@ import ( | ||
| 20 | 20 | "os" |
| 21 | 21 | "os/exec" |
| 22 | 22 | "reflect" |
| 23 | + "slices" | |
| 23 | 24 | "strings" |
| 24 | 25 | "sync" |
| 25 | 26 | "time" |
| @@ -144,6 +145,8 @@ type agent struct { | ||
| 144 | 145 | // starting is closed when the current start attempt ends. |
| 145 | 146 | starting chan struct{} |
| 146 | 147 | outdated bool |
| 148 | + // tools are the names of the tools offered when the agent started. | |
| 149 | + tools []string | |
| 147 | 150 | // stopRequested: Stop was called while the agent was starting. |
| 148 | 151 | stopRequested bool |
| 149 | 152 | logs []string |
| @@ -305,9 +308,10 @@ func (m *Manager) ensureStarted(ctx context.Context, name string) (*agent, error | ||
| 305 | 308 | _ = conn.Close(ctx) |
| 306 | 309 | } |
| 307 | 310 | var conn Conn |
| 311 | + spec := m.specFor(definition) | |
| 308 | 312 | startErr := m.prepare(ctx, a, definition) |
| 309 | 313 | if startErr == nil { |
| 310 | - conn, startErr = m.options.Starter(ctx, m.specFor(definition), func(line string) { m.log(a, line) }) | |
| 314 | + conn, startErr = m.options.Starter(ctx, spec, func(line string) { m.log(a, line) }) | |
| 311 | 315 | } |
| 312 | 316 | |
| 313 | 317 | m.mu.Lock() |
| @@ -324,7 +328,7 @@ func (m *Manager) ensureStarted(ctx context.Context, name string) (*agent, error | ||
| 324 | 328 | go func() { _ = conn.Close(context.Background()) }() |
| 325 | 329 | return nil, fmt.Errorf("agent %s was stopped while starting", a.definition.Name) |
| 326 | 330 | } |
| 327 | - a.conn, a.users, a.outdated = conn, 0, false | |
| 331 | + a.conn, a.users, a.outdated, a.tools = conn, 0, false, toolNames(spec.Tools) | |
| 328 | 332 | a.lastUsed = m.options.Now() |
| 329 | 333 | m.setState(a, StateReady, "") |
| 330 | 334 | m.watchers.Add(1) |
| @@ -531,9 +535,17 @@ func (m *Manager) Run(ctx context.Context) { | ||
| 531 | 535 | } |
| 532 | 536 | |
| 533 | 537 | // Reconfigure applies a new configuration: new agents appear stopped, removed |
| 534 | -// agents are stopped and forgotten, and running agents whose definition | |
| 535 | -// changed keep running but are marked Outdated until restarted. | |
| 538 | +// agents are stopped and forgotten, and running agents whose definition, or | |
| 539 | +// the tools offered to them (agentTools, issue #91), changed keep running | |
| 540 | +// but are marked Outdated until restarted. | |
| 536 | 541 | func (m *Manager) Reconfigure(ctx context.Context, definitions []config.Agent, maxRunning int, idleTimeout time.Duration) { |
| 542 | + // Options.Tools reads the new configuration: outside the lock. | |
| 543 | + tools := map[string][]string{} | |
| 544 | + if m.options.Tools != nil { | |
| 545 | + for _, definition := range definitions { | |
| 546 | + tools[definition.Name] = toolNames(m.options.Tools(definition)) | |
| 547 | + } | |
| 548 | + } | |
| 537 | 549 | m.mu.Lock() |
| 538 | 550 | if maxRunning > 0 { |
| 539 | 551 | m.options.MaxRunning = maxRunning |
| @@ -550,7 +562,8 @@ func (m *Manager) Reconfigure(ctx context.Context, definitions []config.Agent, m | ||
| 550 | 562 | m.emitState(m.agents[definition.Name]) |
| 551 | 563 | continue |
| 552 | 564 | } |
| 553 | - if !reflect.DeepEqual(a.definition, definition) { | |
| 565 | + toolsChanged := m.options.Tools != nil && a.conn != nil && !slices.Equal(a.tools, tools[definition.Name]) | |
| 566 | + if !reflect.DeepEqual(a.definition, definition) || toolsChanged { | |
| 554 | 567 | a.outdated = a.conn != nil |
| 555 | 568 | a.definition = definition |
| 556 | 569 | m.emitState(a) |
| @@ -573,6 +586,15 @@ func (m *Manager) Reconfigure(ctx context.Context, definitions []config.Agent, m | ||
| 573 | 586 | } |
| 574 | 587 | } |
| 575 | 588 | |
| 589 | +// toolNames are the names of tools, in order. | |
| 590 | +func toolNames(tools []acp.Tool) []string { | |
| 591 | + names := []string{} | |
| 592 | + for _, tool := range tools { | |
| 593 | + names = append(names, tool.Name) | |
| 594 | + } | |
| 595 | + return names | |
| 596 | +} | |
| 597 | + | |
| 576 | 598 | // specFor is how to start the agent of definition, with the tools offered |
| 577 | 599 | // to it, the way its file asks for them (ToolDiscovery). |
| 578 | 600 | func (m *Manager) specFor(definition config.Agent) acp.Spec { |
| @@ -20,6 +20,7 @@ import ( | |||
| 20 | "os" | 20 | "os" |
| 21 | "os/exec" | 21 | "os/exec" |
| 22 | "reflect" | 22 | "reflect" |
| 23 | + "slices" | ||
| 23 | "strings" | 24 | "strings" |
| 24 | "sync" | 25 | "sync" |
| 25 | "time" | 26 | "time" |
| @@ -144,6 +145,8 @@ type agent struct { | |||
| 144 | // starting is closed when the current start attempt ends. | 145 | // starting is closed when the current start attempt ends. |
| 145 | starting chan struct{} | 146 | starting chan struct{} |
| 146 | outdated bool | 147 | outdated bool |
| 148 | + // tools are the names of the tools offered when the agent started. | ||
| 149 | + tools []string | ||
| 147 | // stopRequested: Stop was called while the agent was starting. | 150 | // stopRequested: Stop was called while the agent was starting. |
| 148 | stopRequested bool | 151 | stopRequested bool |
| 149 | logs []string | 152 | logs []string |
| @@ -305,9 +308,10 @@ func (m *Manager) ensureStarted(ctx context.Context, name string) (*agent, error | |||
| 305 | _ = conn.Close(ctx) | 308 | _ = conn.Close(ctx) |
| 306 | } | 309 | } |
| 307 | var conn Conn | 310 | var conn Conn |
| 311 | + spec := m.specFor(definition) | ||
| 308 | startErr := m.prepare(ctx, a, definition) | 312 | startErr := m.prepare(ctx, a, definition) |
| 309 | if startErr == nil { | 313 | if startErr == nil { |
| 310 | - conn, startErr = m.options.Starter(ctx, m.specFor(definition), func(line string) { m.log(a, line) }) | 314 | + conn, startErr = m.options.Starter(ctx, spec, func(line string) { m.log(a, line) }) |
| 311 | } | 315 | } |
| 312 | 316 | ||
| 313 | m.mu.Lock() | 317 | m.mu.Lock() |
| @@ -324,7 +328,7 @@ func (m *Manager) ensureStarted(ctx context.Context, name string) (*agent, error | |||
| 324 | go func() { _ = conn.Close(context.Background()) }() | 328 | go func() { _ = conn.Close(context.Background()) }() |
| 325 | return nil, fmt.Errorf("agent %s was stopped while starting", a.definition.Name) | 329 | return nil, fmt.Errorf("agent %s was stopped while starting", a.definition.Name) |
| 326 | } | 330 | } |
| 327 | - a.conn, a.users, a.outdated = conn, 0, false | 331 | + a.conn, a.users, a.outdated, a.tools = conn, 0, false, toolNames(spec.Tools) |
| 328 | a.lastUsed = m.options.Now() | 332 | a.lastUsed = m.options.Now() |
| 329 | m.setState(a, StateReady, "") | 333 | m.setState(a, StateReady, "") |
| 330 | m.watchers.Add(1) | 334 | m.watchers.Add(1) |
| @@ -531,9 +535,17 @@ func (m *Manager) Run(ctx context.Context) { | |||
| 531 | } | 535 | } |
| 532 | 536 | ||
| 533 | // Reconfigure applies a new configuration: new agents appear stopped, removed | 537 | // Reconfigure applies a new configuration: new agents appear stopped, removed |
| 534 | -// agents are stopped and forgotten, and running agents whose definition | 538 | +// agents are stopped and forgotten, and running agents whose definition, or |
| 535 | -// changed keep running but are marked Outdated until restarted. | 539 | +// the tools offered to them (agentTools, issue #91), changed keep running |
| 540 | +// but are marked Outdated until restarted. | ||
| 536 | func (m *Manager) Reconfigure(ctx context.Context, definitions []config.Agent, maxRunning int, idleTimeout time.Duration) { | 541 | func (m *Manager) Reconfigure(ctx context.Context, definitions []config.Agent, maxRunning int, idleTimeout time.Duration) { |
| 542 | + // Options.Tools reads the new configuration: outside the lock. | ||
| 543 | + tools := map[string][]string{} | ||
| 544 | + if m.options.Tools != nil { | ||
| 545 | + for _, definition := range definitions { | ||
| 546 | + tools[definition.Name] = toolNames(m.options.Tools(definition)) | ||
| 547 | + } | ||
| 548 | + } | ||
| 537 | m.mu.Lock() | 549 | m.mu.Lock() |
| 538 | if maxRunning > 0 { | 550 | if maxRunning > 0 { |
| 539 | m.options.MaxRunning = maxRunning | 551 | m.options.MaxRunning = maxRunning |
| @@ -550,7 +562,8 @@ func (m *Manager) Reconfigure(ctx context.Context, definitions []config.Agent, m | |||
| 550 | m.emitState(m.agents[definition.Name]) | 562 | m.emitState(m.agents[definition.Name]) |
| 551 | continue | 563 | continue |
| 552 | } | 564 | } |
| 553 | - if !reflect.DeepEqual(a.definition, definition) { | 565 | + toolsChanged := m.options.Tools != nil && a.conn != nil && !slices.Equal(a.tools, tools[definition.Name]) |
| 566 | + if !reflect.DeepEqual(a.definition, definition) || toolsChanged { | ||
| 554 | a.outdated = a.conn != nil | 567 | a.outdated = a.conn != nil |
| 555 | a.definition = definition | 568 | a.definition = definition |
| 556 | m.emitState(a) | 569 | m.emitState(a) |
| @@ -573,6 +586,15 @@ func (m *Manager) Reconfigure(ctx context.Context, definitions []config.Agent, m | |||
| 573 | } | 586 | } |
| 574 | } | 587 | } |
| 575 | 588 | ||
| 589 | +// toolNames are the names of tools, in order. | ||
| 590 | +func toolNames(tools []acp.Tool) []string { | ||
| 591 | + names := []string{} | ||
| 592 | + for _, tool := range tools { | ||
| 593 | + names = append(names, tool.Name) | ||
| 594 | + } | ||
| 595 | + return names | ||
| 596 | +} | ||
| 597 | + | ||
| 576 | // specFor is how to start the agent of definition, with the tools offered | 598 | // specFor is how to start the agent of definition, with the tools offered |
| 577 | // to it, the way its file asks for them (ToolDiscovery). | 599 | // to it, the way its file asks for them (ToolDiscovery). |
| 578 | func (m *Manager) specFor(definition config.Agent) acp.Spec { | 600 | func (m *Manager) specFor(definition config.Agent) acp.Spec { |
modified
internal/agents/manager_test.go +24 -0 | @@ -461,6 +461,30 @@ func TestReconfigure(t *testing.T) { | ||
| 461 | 461 | } |
| 462 | 462 | } |
| 463 | 463 | |
| 464 | +func TestChangingTheToolsOfferedMakesARunningAgentOutdated(t *testing.T) { | |
| 465 | + offered := []acp.Tool{{Name: "memory_pressure", Method: "_m"}} | |
| 466 | + f := &fixture{starter: newFakeStarter(), recorder: &events.Recorder{}, clock: &clock{now: time.Now()}} | |
| 467 | + f.manager = agents.NewManager(definitions("alice", "bob"), agents.Options{ | |
| 468 | + MaxRunning: maxRunning, Emitter: f.recorder, Starter: f.starter.start, Now: f.clock.Now, | |
| 469 | + Tools: func(config.Agent) []acp.Tool { return offered }, | |
| 470 | + }) | |
| 471 | + _ = f.manager.Start(ctx, "alice") | |
| 472 | + f.manager.Reconfigure(ctx, definitions("alice", "bob"), maxRunning, 0) | |
| 473 | + if f.manager.Statuses()[0].Outdated { | |
| 474 | + t.Fatal("the same tools: nothing to restart") | |
| 475 | + } | |
| 476 | + offered = append(offered, acp.Tool{Name: "search_messages", Method: "_s"}) | |
| 477 | + f.manager.Reconfigure(ctx, definitions("alice", "bob"), maxRunning, 0) | |
| 478 | + statuses := f.manager.Statuses() | |
| 479 | + if !statuses[0].Outdated || statuses[1].Outdated { | |
| 480 | + t.Fatalf("alice runs with the old tools, bob is stopped: %+v", statuses) | |
| 481 | + } | |
| 482 | + _ = f.manager.Restart(ctx, "alice") | |
| 483 | + if f.manager.Statuses()[0].Outdated { | |
| 484 | + t.Fatal("a restart offers the new tools") | |
| 485 | + } | |
| 486 | +} | |
| 487 | + | |
| 464 | 488 | func ExampleManager_Acquire() { |
| 465 | 489 | manager := agents.NewManager(definitions("alice"), agents.Options{ |
| 466 | 490 | Starter: func(context.Context, acp.Spec, func(string)) (agents.Conn, error) { return newFakeConn("alice"), nil }, |
| @@ -461,6 +461,30 @@ func TestReconfigure(t *testing.T) { | |||
| 461 | } | 461 | } |
| 462 | } | 462 | } |
| 463 | 463 | ||
| 464 | +func TestChangingTheToolsOfferedMakesARunningAgentOutdated(t *testing.T) { | ||
| 465 | + offered := []acp.Tool{{Name: "memory_pressure", Method: "_m"}} | ||
| 466 | + f := &fixture{starter: newFakeStarter(), recorder: &events.Recorder{}, clock: &clock{now: time.Now()}} | ||
| 467 | + f.manager = agents.NewManager(definitions("alice", "bob"), agents.Options{ | ||
| 468 | + MaxRunning: maxRunning, Emitter: f.recorder, Starter: f.starter.start, Now: f.clock.Now, | ||
| 469 | + Tools: func(config.Agent) []acp.Tool { return offered }, | ||
| 470 | + }) | ||
| 471 | + _ = f.manager.Start(ctx, "alice") | ||
| 472 | + f.manager.Reconfigure(ctx, definitions("alice", "bob"), maxRunning, 0) | ||
| 473 | + if f.manager.Statuses()[0].Outdated { | ||
| 474 | + t.Fatal("the same tools: nothing to restart") | ||
| 475 | + } | ||
| 476 | + offered = append(offered, acp.Tool{Name: "search_messages", Method: "_s"}) | ||
| 477 | + f.manager.Reconfigure(ctx, definitions("alice", "bob"), maxRunning, 0) | ||
| 478 | + statuses := f.manager.Statuses() | ||
| 479 | + if !statuses[0].Outdated || statuses[1].Outdated { | ||
| 480 | + t.Fatalf("alice runs with the old tools, bob is stopped: %+v", statuses) | ||
| 481 | + } | ||
| 482 | + _ = f.manager.Restart(ctx, "alice") | ||
| 483 | + if f.manager.Statuses()[0].Outdated { | ||
| 484 | + t.Fatal("a restart offers the new tools") | ||
| 485 | + } | ||
| 486 | +} | ||
| 487 | + | ||
| 464 | func ExampleManager_Acquire() { | 488 | func ExampleManager_Acquire() { |
| 465 | manager := agents.NewManager(definitions("alice"), agents.Options{ | 489 | manager := agents.NewManager(definitions("alice"), agents.Options{ |
| 466 | Starter: func(context.Context, acp.Spec, func(string)) (agents.Conn, error) { return newFakeConn("alice"), nil }, | 490 | Starter: func(context.Context, acp.Spec, func(string)) (agents.Conn, error) { return newFakeConn("alice"), nil }, |
modified
internal/app/clienttools.go +1 -1 | @@ -64,7 +64,7 @@ func (c *Core) systemTools(agent string) []acp.Tool { | ||
| 64 | 64 | return []acp.Tool{ |
| 65 | 65 | { |
| 66 | 66 | Name: "memory_pressure", |
| 67 | - Description: "Tell how much the memory of the user's computer is under pressure (normal, warning or critical) and how much is used. Call it before a heavy task, or when the user asks about memory or slowness.", | |
| 67 | + Description: "Tell how much the memory of the user's computer is under pressure (normal, warning or critical) and how much is used. Call it before a heavy task, or when the user asks about memory or slowness. The memory changes from moment to moment: call it again each time, never reuse an earlier result.", | |
| 68 | 68 | Method: MemoryMethod, |
| 69 | 69 | Call: func(context.Context, string, map[string]any) (string, error) { |
| 70 | 70 | status, err := memory.Read() |
| @@ -64,7 +64,7 @@ func (c *Core) systemTools(agent string) []acp.Tool { | |||
| 64 | return []acp.Tool{ | 64 | return []acp.Tool{ |
| 65 | { | 65 | { |
| 66 | Name: "memory_pressure", | 66 | Name: "memory_pressure", |
| 67 | - Description: "Tell how much the memory of the user's computer is under pressure (normal, warning or critical) and how much is used. Call it before a heavy task, or when the user asks about memory or slowness.", | 67 | + Description: "Tell how much the memory of the user's computer is under pressure (normal, warning or critical) and how much is used. Call it before a heavy task, or when the user asks about memory or slowness. The memory changes from moment to moment: call it again each time, never reuse an earlier result.", |
| 68 | Method: MemoryMethod, | 68 | Method: MemoryMethod, |
| 69 | Call: func(context.Context, string, map[string]any) (string, error) { | 69 | Call: func(context.Context, string, map[string]any) (string, error) { |
| 70 | status, err := memory.Read() | 70 | status, err := memory.Read() |
modified
internal/app/historytools.go +3 -3 | @@ -35,7 +35,7 @@ func (c *Core) historyTools(agent string) []acp.Tool { | ||
| 35 | 35 | return []acp.Tool{ |
| 36 | 36 | { |
| 37 | 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.", | |
| 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. Channels and messages change: call it again each time, never reuse an earlier result.", | |
| 39 | 39 | Method: ChannelsMethod, |
| 40 | 40 | Call: func(context.Context, string, map[string]any) (string, error) { |
| 41 | 41 | manager, err := c.channelManager() |
| @@ -51,7 +51,7 @@ func (c *Core) historyTools(agent string) []acp.Tool { | ||
| 51 | 51 | }, |
| 52 | 52 | { |
| 53 | 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.", | |
| 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. Their state changes: call it again each time, never reuse an earlier result.", | |
| 55 | 55 | Method: AgentsMethod, |
| 56 | 56 | Call: func(context.Context, string, map[string]any) (string, error) { |
| 57 | 57 | return AgentsText(c.manager.Statuses(), agent), nil |
| @@ -59,7 +59,7 @@ func (c *Core) historyTools(agent string) []acp.Tool { | ||
| 59 | 59 | }, |
| 60 | 60 | { |
| 61 | 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.", | |
| 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. New messages arrive: search again each time, never reuse an earlier result.", | |
| 63 | 63 | Method: SearchMethod, |
| 64 | 64 | InputSchema: map[string]any{ |
| 65 | 65 | "type": "object", |
| @@ -35,7 +35,7 @@ func (c *Core) historyTools(agent string) []acp.Tool { | |||
| 35 | return []acp.Tool{ | 35 | return []acp.Tool{ |
| 36 | { | 36 | { |
| 37 | Name: "list_channels", | 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.", | 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. Channels and messages change: call it again each time, never reuse an earlier result.", |
| 39 | Method: ChannelsMethod, | 39 | Method: ChannelsMethod, |
| 40 | Call: func(context.Context, string, map[string]any) (string, error) { | 40 | Call: func(context.Context, string, map[string]any) (string, error) { |
| 41 | manager, err := c.channelManager() | 41 | manager, err := c.channelManager() |
| @@ -51,7 +51,7 @@ func (c *Core) historyTools(agent string) []acp.Tool { | |||
| 51 | }, | 51 | }, |
| 52 | { | 52 | { |
| 53 | Name: "list_agents", | 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.", | 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. Their state changes: call it again each time, never reuse an earlier result.", |
| 55 | Method: AgentsMethod, | 55 | Method: AgentsMethod, |
| 56 | Call: func(context.Context, string, map[string]any) (string, error) { | 56 | Call: func(context.Context, string, map[string]any) (string, error) { |
| 57 | return AgentsText(c.manager.Statuses(), agent), nil | 57 | return AgentsText(c.manager.Statuses(), agent), nil |
| @@ -59,7 +59,7 @@ func (c *Core) historyTools(agent string) []acp.Tool { | |||
| 59 | }, | 59 | }, |
| 60 | { | 60 | { |
| 61 | Name: "search_messages", | 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.", | 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. New messages arrive: search again each time, never reuse an earlier result.", |
| 63 | Method: SearchMethod, | 63 | Method: SearchMethod, |
| 64 | InputSchema: map[string]any{ | 64 | InputSchema: map[string]any{ |
| 65 | "type": "object", | 65 | "type": "object", |