@imenam/mcp-organizer 1.0.29 → 1.0.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/shared/schemas/admin-api.schema.d.ts +43 -1
- package/dist/shared/schemas/admin-api.schema.js +10 -1
- package/dist/src/core/migrations.js +8 -0
- package/dist/src/core/store.d.ts +7 -3
- package/dist/src/core/store.js +27 -5
- package/dist/src/mcp/client.js +3 -3
- package/dist/src/mcp/start.d.ts +1 -1
- package/dist/src/mcp/start.js +1 -1
- package/dist/src/mcp/tools.d.ts +3 -5
- package/dist/src/mcp/tools.js +43 -9
- package/dist/src/mcp/upload.d.ts +22 -3
- package/dist/src/mcp/upload.js +31 -2
- package/gui/dist/assets/index-D4I3h65z.css +1 -0
- package/gui/dist/assets/{index-BqkvnOJy.js → index-F67zTtnA.js} +26 -26
- package/gui/dist/index.html +2 -2
- package/package.json +1 -1
- package/gui/dist/assets/index-rbLhuRHl.css +0 -1
package/README.md
CHANGED
|
@@ -230,7 +230,7 @@ Les outils MCP sont destinés à l'agent ; leurs schémas JSON sont écrits à l
|
|
|
230
230
|
| `edit_checklist` | `POST tasks/:ref/checklist` | Ajoute (en fin de liste, ou juste après `after_item_id`, `null` : en tête), renomme, coche, déplace (`move`, juste après `after_item_id`) ou supprime des éléments de checklist ; ajoute, renomme, déplace ou supprime des points de vérification d'un test (tout ou rien) ; l'annulation d'un déplacement remet l'élément à sa place |
|
|
231
231
|
| `edit_questions` | `POST tasks/:ref/questions` | Pose, reformule ou supprime des questions d'une tâche (choix unique ou multiple) et leurs propositions (libellé, détail markdown, recommandation) ; les réponses appartiennent aux membres (tout ou rien) |
|
|
232
232
|
| `add_comment` | `POST tasks/:ref/comments` | Commentaire de l'agent ; assignés et commentateurs précédents notifiés |
|
|
233
|
-
| `add_attachment` | `POST tasks/:ref/attachments` (multipart) | Joint à une tâche de l'espace un fichier local désigné par son chemin absolu (`
|
|
233
|
+
| `add_attachment` | `POST tasks/:ref/attachments` (multipart) | Joint à une tâche de l'espace un fichier local désigné par son chemin absolu (`file_path`, `name` facultatif) : le mode MCP le lit et l'envoie en multipart, son contenu ne passe jamais par l'agent. À défaut, `file_content` (base64) et `file_name` portent le fichier lui-même : c'est la paire que remplit le relais de mcp-http-gateway. `comment` publie un commentaire avec la référence au fichier (miniature pour une image, nom sinon), `append_to_description` l'ajoute en fin de description. Chaque élément est une action annulable du lot |
|
|
234
234
|
| `create_idea` / `update_idea` | `POST ideas`, `PATCH ideas/:id` | Idée dans la boîte à idées ; reformulation, archivage |
|
|
235
235
|
| `promote_idea` | `POST ideas/:id/promote` | Crée une tâche à partir d'une idée et marque l'idée promue |
|
|
236
236
|
| `list_views` | `GET views?request_id=…` | Vues du tableau de bord de l'auteur de la demande (sans `request_id` : du propriétaire du jeton) : disposition, regroupements, groupes vides, filtres |
|
|
@@ -558,7 +558,7 @@ e2e/ parcours Playwright sur le site réel ; captures dans e2e/
|
|
|
558
558
|
|
|
559
559
|
Les tests ne lisent jamais la configuration du développeur : `test/launch.ts`, partagé par les tests node et les parcours e2e, lance chaque processus avec `--dotenv=<fichier vide du répertoire temporaire>` et vide toutes les variables de configuration héritées du shell. Le site de test est lancé en `--server` sur un port libre de `127.0.0.1`, avec `ORGANIZER_PUBLIC_URL=http://127.0.0.1:<port>` ; les outils sont appelés par un client MCP réel sur le mode MCP, relié à ce site par un jeton créé par l'API de l'interface (`ORGANIZER_URL`, `ORGANIZER_TOKEN`). Un test vérifie, sur une copie du package dont le `.env` détourne le répertoire de données, que ce `.env` n'atteint pas un processus lancé par les tests (et qu'il l'atteindrait sans `--dotenv`).
|
|
560
560
|
|
|
561
|
-
**Tests node** : migrations, invariants, versions, journal des changements, connexions concurrentes ; comptes (amorçage avec nom obligatoire, `--set-user` et `--name`, connexion, sessions, liens d'accès, invitations, droits, e-mail) ; mot de passe oublié (réponse identique pour une adresse inconnue, un compte invité et un compte actif, lien haché valable 30 minutes, jeton expiré, jeton réutilisé, lien remplacé par une nouvelle demande, sessions fermées, e-mail de confirmation, lien supprimé par un changement de mot de passe ou `--set-user`, 503 sans e-mail ou sans URL publique, échec d'envoi journalisé) ; profil ; jetons d'agent (affichage unique, configuration du mode MCP, hash seul en base, révocation, expiration, perte d'appartenance, espace hors de portée) ; `--claude-setup-mcp` (entrée du mode MCP, `--url` et `--token` obligatoires, fusion, `--force`, options inconnues ou invalides, fichier illisible laissé intact) ; `--setup` (`.env`, unité systemd et bloc nginx écrits, premier compte créé, `.env` existant fusionné, publication sous un chemin, valeurs incohérentes ou manquantes refusées sans rien écrire, valeurs dotenv citées, site démarré depuis le `.env` écrit) ; `--backup` (copie de la base d'un site en service et de ses pièces jointes, restaurable ; destination existante refusée sans `--force` ; pièce jointe manquante qui ne laisse aucun fichier ; répertoire sans base refusé) ; `.env` et `--dotenv` ; tâches, tâches de test, pièces jointes, notifications, rendu des e-mails (markdown vers HTML et vers texte, clés de tâche liées, images jointes en mention, HTML brut et liens `javascript:` neutralisés, gabarit avec bouton et lien des préférences, envoi en `multipart/alternative`), boîte à idées, notes (aucune demande à l'écriture, envoi à l'agent, notes référencées dans le contexte d'une demande, `search_notes` et `get_note` limités à l'espace du jeton), documents (dépôt, description, nouvelle version, téléchargement, suppression, refus de format, de taille, d'encodage, de fichier Word illisible, de nom déjà pris et d'espace plein, fichiers effacés avec l'espace, texte extrait d'un fichier Word sans dépendance, texte d'un PDF page par page, PDF scanné signalé, image montrée à l'agent, `list_documents` et `get_document` par parties limités à l'espace du jeton, documents cités par `claim_request` et `get_context`), fichiers ouverts par l'agent (image renvoyée en base64 avec son type, image trop lourde ou trop grande réduite et recompressée sous les limites de l'API de Claude, format hors API converti, texte d'un PDF, PDF sans couche texte, PDF abîmé, `get_attachment` limité à l'espace du jeton, pièces jointes citées par `get_task` et `claim_request`, bloc image relayé jusqu'au client MCP par le mode MCP), fichiers envoyés par l'agent (chemin relatif, introuvable, dossier et fichier de plus de 20 Mo refusés, tâche hors de l'espace refusée sans fichier ni lot laissés, image montrée dans un commentaire et en fin de description, autre fichier cité par son nom, lot annulé qui retire pièce jointe, commentaire et ajout à la description et efface le fichier, envoi en multipart par un vrai client MCP sur le mode MCP), chrono (sessions horodatées par le serveur, pause et reprise, un chrono par membre et par tâche, un seul en marche, phases et temps de travail d'un pomodoro, préférences pomodoro, `start_timer` / `stop_timer` / `get_task_time`, actions du lot annulables par le seul propriétaire du chrono, annulation refusée quand un autre chrono occupe la tâche, jeton d'un autre membre refusé), dictée avec un serveur Groq simulé, historique et annulation, historique de l'espace (événements dérivés des versions, renumérotations et commentaires absents, filtres par auteur, catégorie et date, pagination par curseur, diff ligne par ligne, migration qui donne leur espace aux versions et une première version invisible aux entités existantes, tâche supprimée restaurée avec ses sous-tâches et sa checklist, parent supprimé refusé, `get_history` en anglais) ; chaque outil appelé par un client MCP du SDK sur le mode MCP relié à un site de test, jeton inconnu, révoqué ou expiré, site injoignable, espace hors portée, demande prise par un autre jeton, deux jetons de deux membres sur le même espace commun (prise atomique), mode MCP sans `ORGANIZER_URL` / `ORGANIZER_TOKEN`, mode MCP qui ne charge aucun module natif ni sharp ni unpdf (crochet de résolution qui les bloque), `ORGANIZER_URL` en http refusée hors de la machine locale, redirection du site refusée sans y envoyer le jeton, `.env` du paquet ignoré par le mode MCP (lu avec `--dotenv`) ; commandes du site arrêtées avec la marche à suivre quand better-sqlite3 n'a pas de module natif (crochet de résolution qui simule l'échec) ; `list_requests` sur plus de 100 demandes closes (les plus récentes d'abord) ; jetons révoqués au départ ou au retrait de leur propriétaire, et migration qui révoque ceux des anciens membres ; erreurs internes au message générique ; sauvegarde privée pendant son écriture (droits observés hors Windows, test ignoré sous Windows) ; `--setup` qui refuse `--trust-proxy=oui` avec une écoute hors de la boucle locale, bloc nginx en `listen 443 ssl http2` ; administration et runner (premier compte administrateur, page Administration réservée, autorisation par espace, `--set-admin` et dernier administrateur protégé, session `claude -p` lancée par le site dès qu'une demande attend dans un espace autorisé ou qu'un espace est autorisé, avec les seuls outils organizer, un environnement sans les secrets du site, une configuration MCP supprimée et un jeton invalidé après la session, jeton « Runner » visible dans la page Agent et absent de Mon compte, traitement ponctuel d'une file par un administrateur même sans autorisation, refusé aux membres, sans demande en attente ou runner désactivé, runner désactivé sans `ORGANIZER_RUNNER_CLAUDE` ; connexion de Claude : runner désactivé sans token, token vérifié avant d'être enregistré, refusé aux membres, token refusé non enregistré, enregistré chiffré en AES-256-GCM avec une clé hors de la base, jamais en clair dans les fichiers de la base, passé à la session dans `CLAUDE_CODE_OAUTH_TOKEN`, file relancée à la connexion, token marqué refusé quand une session s'arrête sur un refus de Claude, clé absente ou chiffré altéré signalés) ; notifications de l'agent (présence et délai de grâce du veilleur, ligne d'une demande, `GET notifications`, attente longue réveillée par une demande créée ou libérée, curseur qui rattrape une demande arrivée entre deux attentes, expiration, jeton inconnu, durée hors limites ; `enable_notifications` puis veilleur `--watch` réel qui écrit une ligne par nouvelle demande, sans le jeton dans la conversation, « already live » une fois armé, arrêt sur jeton révoqué, refus de démarrer sans relais ; convention de mcp-http-gateway : propriété `_gateway_watch`, spécification de veille sans relais local, curseur de départ qui rattrape une demande, lignes et curseur de `wait_for_requests`, présence, arguments invalides) ; API des agents en HTTP direct (401 et 403 explicites, cookies ignorés, écriture sans `Origin`, réponses validées par les schémas partagés) ; site : `--help` (qui cite `--setup` et `--backup`) et `--version`, refus de connexion sans compte avec les commandes d'une installation par clonage et du paquet npm, démarrage refusé sans `ORGANIZER_PUBLIC_URL` ou `PORT` ou avec un chemin de base incohérent, SPA et `<base href>`, cookie (`Path`, `Secure` en https), formulaires multipart et 413 ; protections : modification refusée sans origine ou d'une origine étrangère, en-têtes de sécurité, limitation des connexions par couple (IP, e-mail) et par IP, limitation des demandes de réinitialisation par e-mail et par IP, rafale de tentatives parallèles limitée, compte non bloqué par un tiers, `X-Forwarded-For` ignoré sans `ORGANIZER_TRUST_PROXY` et pris en compte avec.
|
|
561
|
+
**Tests node** : migrations, invariants, versions, journal des changements, connexions concurrentes ; comptes (amorçage avec nom obligatoire, `--set-user` et `--name`, connexion, sessions, liens d'accès, invitations, droits, e-mail) ; mot de passe oublié (réponse identique pour une adresse inconnue, un compte invité et un compte actif, lien haché valable 30 minutes, jeton expiré, jeton réutilisé, lien remplacé par une nouvelle demande, sessions fermées, e-mail de confirmation, lien supprimé par un changement de mot de passe ou `--set-user`, 503 sans e-mail ou sans URL publique, échec d'envoi journalisé) ; profil ; jetons d'agent (affichage unique, configuration du mode MCP, hash seul en base, révocation, expiration, perte d'appartenance, espace hors de portée) ; `--claude-setup-mcp` (entrée du mode MCP, `--url` et `--token` obligatoires, fusion, `--force`, options inconnues ou invalides, fichier illisible laissé intact) ; `--setup` (`.env`, unité systemd et bloc nginx écrits, premier compte créé, `.env` existant fusionné, publication sous un chemin, valeurs incohérentes ou manquantes refusées sans rien écrire, valeurs dotenv citées, site démarré depuis le `.env` écrit) ; `--backup` (copie de la base d'un site en service et de ses pièces jointes, restaurable ; destination existante refusée sans `--force` ; pièce jointe manquante qui ne laisse aucun fichier ; répertoire sans base refusé) ; `.env` et `--dotenv` ; tâches, tâches de test, pièces jointes, notifications, rendu des e-mails (markdown vers HTML et vers texte, clés de tâche liées, images jointes en mention, HTML brut et liens `javascript:` neutralisés, gabarit avec bouton et lien des préférences, envoi en `multipart/alternative`), boîte à idées, notes (aucune demande à l'écriture, envoi à l'agent, notes référencées dans le contexte d'une demande, `search_notes` et `get_note` limités à l'espace du jeton), documents (dépôt, description, nouvelle version, téléchargement, suppression, refus de format, de taille, d'encodage, de fichier Word illisible, de nom déjà pris et d'espace plein, fichiers effacés avec l'espace, texte extrait d'un fichier Word sans dépendance, texte d'un PDF page par page, PDF scanné signalé, image montrée à l'agent, `list_documents` et `get_document` par parties limités à l'espace du jeton, documents cités par `claim_request` et `get_context`), fichiers ouverts par l'agent (image renvoyée en base64 avec son type, image trop lourde ou trop grande réduite et recompressée sous les limites de l'API de Claude, format hors API converti, texte d'un PDF, PDF sans couche texte, PDF abîmé, `get_attachment` limité à l'espace du jeton, pièces jointes citées par `get_task` et `claim_request`, bloc image relayé jusqu'au client MCP par le mode MCP), fichiers envoyés par l'agent (chemin relatif, introuvable, dossier et fichier de plus de 20 Mo refusés, tâche hors de l'espace refusée sans fichier ni lot laissés, image montrée dans un commentaire et en fin de description, autre fichier cité par son nom, lot annulé qui retire pièce jointe, commentaire et ajout à la description et efface le fichier, envoi en multipart par un vrai client MCP sur le mode MCP, fichier transmis en base64 dans `file_content` avec `file_name` comme le réécrit le relais de mcp-http-gateway, base64 invalide, `file_content` sans `file_name` et chemin et contenu donnés ensemble refusés), chrono (sessions horodatées par le serveur, pause et reprise, un chrono par membre et par tâche, un seul en marche, phases et temps de travail d'un pomodoro, préférences pomodoro, `start_timer` / `stop_timer` / `get_task_time`, actions du lot annulables par le seul propriétaire du chrono, annulation refusée quand un autre chrono occupe la tâche, jeton d'un autre membre refusé), dictée avec un serveur Groq simulé, historique et annulation, historique de l'espace (événements dérivés des versions, renumérotations et commentaires absents, filtres par auteur, catégorie et date, pagination par curseur, diff ligne par ligne, migration qui donne leur espace aux versions et une première version invisible aux entités existantes, tâche supprimée restaurée avec ses sous-tâches et sa checklist, parent supprimé refusé, `get_history` en anglais) ; chaque outil appelé par un client MCP du SDK sur le mode MCP relié à un site de test, jeton inconnu, révoqué ou expiré, site injoignable, espace hors portée, demande prise par un autre jeton, deux jetons de deux membres sur le même espace commun (prise atomique), mode MCP sans `ORGANIZER_URL` / `ORGANIZER_TOKEN`, mode MCP qui ne charge aucun module natif ni sharp ni unpdf (crochet de résolution qui les bloque), `ORGANIZER_URL` en http refusée hors de la machine locale, redirection du site refusée sans y envoyer le jeton, `.env` du paquet ignoré par le mode MCP (lu avec `--dotenv`) ; commandes du site arrêtées avec la marche à suivre quand better-sqlite3 n'a pas de module natif (crochet de résolution qui simule l'échec) ; `list_requests` sur plus de 100 demandes closes (les plus récentes d'abord) ; jetons révoqués au départ ou au retrait de leur propriétaire, et migration qui révoque ceux des anciens membres ; erreurs internes au message générique ; sauvegarde privée pendant son écriture (droits observés hors Windows, test ignoré sous Windows) ; `--setup` qui refuse `--trust-proxy=oui` avec une écoute hors de la boucle locale, bloc nginx en `listen 443 ssl http2` ; administration et runner (premier compte administrateur, page Administration réservée, autorisation par espace, `--set-admin` et dernier administrateur protégé, session `claude -p` lancée par le site dès qu'une demande attend dans un espace autorisé ou qu'un espace est autorisé, avec les seuls outils organizer, un environnement sans les secrets du site, une configuration MCP supprimée et un jeton invalidé après la session, jeton « Runner » visible dans la page Agent et absent de Mon compte, traitement ponctuel d'une file par un administrateur même sans autorisation, refusé aux membres, sans demande en attente ou runner désactivé, runner désactivé sans `ORGANIZER_RUNNER_CLAUDE` ; connexion de Claude : runner désactivé sans token, token vérifié avant d'être enregistré, refusé aux membres, token refusé non enregistré, enregistré chiffré en AES-256-GCM avec une clé hors de la base, jamais en clair dans les fichiers de la base, passé à la session dans `CLAUDE_CODE_OAUTH_TOKEN`, file relancée à la connexion, token marqué refusé quand une session s'arrête sur un refus de Claude, clé absente ou chiffré altéré signalés) ; notifications de l'agent (présence et délai de grâce du veilleur, ligne d'une demande, `GET notifications`, attente longue réveillée par une demande créée ou libérée, curseur qui rattrape une demande arrivée entre deux attentes, expiration, jeton inconnu, durée hors limites ; `enable_notifications` puis veilleur `--watch` réel qui écrit une ligne par nouvelle demande, sans le jeton dans la conversation, « already live » une fois armé, arrêt sur jeton révoqué, refus de démarrer sans relais ; convention de mcp-http-gateway : propriété `_gateway_watch`, spécification de veille sans relais local, curseur de départ qui rattrape une demande, lignes et curseur de `wait_for_requests`, présence, arguments invalides) ; API des agents en HTTP direct (401 et 403 explicites, cookies ignorés, écriture sans `Origin`, réponses validées par les schémas partagés) ; site : `--help` (qui cite `--setup` et `--backup`) et `--version`, refus de connexion sans compte avec les commandes d'une installation par clonage et du paquet npm, démarrage refusé sans `ORGANIZER_PUBLIC_URL` ou `PORT` ou avec un chemin de base incohérent, SPA et `<base href>`, cookie (`Path`, `Secure` en https), formulaires multipart et 413 ; protections : modification refusée sans origine ou d'une origine étrangère, en-têtes de sécurité, limitation des connexions par couple (IP, e-mail) et par IP, limitation des demandes de réinitialisation par e-mail et par IP, rafale de tentatives parallèles limitée, compte non bloqué par un tiers, `X-Forwarded-For` ignoré sans `ORGANIZER_TRUST_PROXY` et pris en compte avec.
|
|
562
562
|
|
|
563
563
|
**Parcours e2e** (site compilé en `--server`, port libre, répertoire de données temporaire, premier compte créé par `ORGANIZER_ADMIN_*`). Chaque page est surveillée : une exception ou une erreur de console, dont toute violation de la CSP, fait échouer le parcours.
|
|
564
564
|
|
|
@@ -678,7 +678,7 @@ Un non-membre reçoit la même réponse qu'un espace ou une tâche inexistants (
|
|
|
678
678
|
- **Pièces jointes** : 20 Mo au plus, stockées sous `<données>/attachments/<id>` ; supprimer une pièce jointe, sa tâche ou son espace efface le fichier.
|
|
679
679
|
- **Images collées** : une image du presse-papiers (Ctrl+V / Cmd+V, ou « Coller » d'un appui long dans un champ sur téléphone) collée dans le détail d'une tâche devient une pièce jointe de la tâche, nommée `capture-AAAA-MM-JJ-HHMMSS.png` (suivi de `-2`, `-3`… pour les images suivantes d'un même collage). Formats acceptés : PNG, JPEG, GIF et WebP, dans la limite des pièces jointes. L'envoi s'affiche dans la liste des pièces jointes, qui signale un format refusé ou une image trop lourde. Dans un champ de saisie, un collage qui porte aussi du texte (cellules d'un tableur) reste un collage de texte.
|
|
680
680
|
- **Fichiers vus par l'agent** : `get_attachment` (pièces jointes des tâches) et `get_document` (documents de référence) montrent une image à l'agent comme bloc de contenu image MCP, relayé tel quel par le mode MCP. Le site prépare l'image avec sharp pour l'API de Claude : une image PNG, JPEG, GIF ou WebP d'au plus 2000 px de côté et 5 Mo en base64 part telle quelle ; une image plus grande ou plus lourde (photo de téléphone, capture d'un grand écran) est réduite à 2000 px de côté, puis recompressée (PNG, ou JPEG de qualité et de taille décroissantes) jusqu'à tenir dans 5 Mo ; une image animée est réduite à sa première image et un autre format (TIFF…) converti. Une image que le site ne sait pas décoder est une erreur explicite. Le texte d'un PDF est extrait avec unpdf (pdf.js, sans module natif). Le mode MCP ne charge ni sharp ni unpdf.
|
|
681
|
-
- **Fichiers envoyés par l'agent** : `add_attachment` prend le chemin absolu d'un fichier sur la machine où tourne le mode MCP (le poste de l'utilisateur pour Claude Code, le serveur pour le runner). Le mode MCP le lit avec les droits de l'utilisateur qui l'a lancé, refuse un chemin relatif, introuvable, un dossier, un fichier spécial et un fichier de plus de 20 Mo, puis l'envoie au site en multipart (champ `file`, comme le navigateur) : le contenu ne passe jamais par la conversation de l'agent. Le type est déduit de l'extension ; tous les formats sont acceptés, comme pour les pièces jointes des membres. La pièce jointe, le commentaire qui la montre et l'ajout à la description sont trois actions du lot de la demande (ou d'une action directe) ; annuler le lot les retire et efface le fichier.
|
|
681
|
+
- **Fichiers envoyés par l'agent** : `add_attachment` prend le chemin absolu d'un fichier (`file_path`) sur la machine où tourne le mode MCP (le poste de l'utilisateur pour Claude Code, le serveur pour le runner). Le mode MCP le lit avec les droits de l'utilisateur qui l'a lancé, refuse un chemin relatif, introuvable, un dossier, un fichier spécial et un fichier de plus de 20 Mo, puis l'envoie au site en multipart (champ `file`, comme le navigateur) : le contenu ne passe jamais par la conversation de l'agent. Le type est déduit de l'extension ; tous les formats sont acceptés, comme pour les pièces jointes des membres. Dans une gateway, le mode MCP tourne sur la machine de la gateway et ne voit pas le disque de l'agent : l'outil déclare donc aussi la paire `file_path` / `file_content` de la convention de mcp-http-gateway. Le relais `--mcp` lit le fichier sur la machine de l'agent (dans les dossiers de `GATEWAY_INLINE_ROOTS`), le transmet en base64 dans `file_content` avec son nom dans `file_name`, et cache ces deux paramètres à l'agent ; le mode MCP décode le contenu (base64 invalide et fichier de plus de 20 Mo refusés) et l'envoie comme un fichier lu sur son disque. La pièce jointe, le commentaire qui la montre et l'ajout à la description sont trois actions du lot de la demande (ou d'une action directe) ; annuler le lot les retire et efface le fichier.
|
|
682
682
|
- **Images dans les textes** : une image collée dans un commentaire (zone de saisie ou modification), dans le commentaire d'un point de vérification ou dans la description, ou ajoutée par le bouton « Image » de la zone de commentaire ou par le + en bout de champ du commentaire d'un point (sur téléphone, ils ouvrent la galerie ou l'appareil photo), est jointe à la tâche puis référencée dans le texte par ``, sur sa propre ligne au curseur. Avant l'envoi, un aperçu montre la miniature de chaque image avec « Retirer », qui supprime la pièce jointe et sa référence, et les envois en cours, pendant lesquels l'envoi du commentaire attend. Publiée, l'image s'affiche en miniature dans le texte et s'ouvre en grand d'un clic ; une pièce jointe supprimée laisse « Image supprimée ». Supprimer un commentaire laisse ses images dans les pièces jointes de la tâche. Une image choisie par le bouton garde son nom de fichier.
|
|
683
683
|
- **Questions** : l'agent pose dans une tâche, de tout type, des questions qui tranchent un point avec les membres (`edit_questions`). Chacune propose des réponses, un seul choix ou plusieurs, avec un détail markdown et la recommandation de l'agent, plus une réponse libre. Tout membre de l'espace y répond depuis le détail de la tâche (`PUT /api/questions/:id/answer`) ; pour un choix unique, la réponse est une proposition ou la réponse libre. Une question est répondue dès qu'une réponse y est enregistrée, par n'importe quel membre (une proposition choisie ou une réponse libre) ; une réponse vidée la remet à trancher. Répondre n'envoie rien à l'agent : il lit les réponses avec `get_task` quand il consulte la tâche, et ne les traite que si un membre le lui demande, par un message ou par un commentaire qui mentionne `@agent`. Les questions et propositions écrites par l'agent sont des actions de son lot, annulables tant que personne n'a répondu depuis ; une question supprimée revient avec sa réponse.
|
|
684
684
|
- **Tâches de test** : des points de vérification à la place d'une checklist ; chaque testeur saisit son propre résultat par point (`ok`, `ko`, `blocked`, `untested`) et un commentaire. Le bilan d'un point est KO si un testeur a trouvé un KO, sinon Bloqué, sinon OK, sinon à vérifier. Un test peut désigner la tâche qu'il vérifie. La review se rédige en brouillon puis se soumet : elle est figée et crée une demande `test_review` qui vise l'espace de la tâche.
|
|
@@ -165,7 +165,17 @@ export declare const RunnerOutcomeSchema: z.ZodEnum<{
|
|
|
165
165
|
timeout: "timeout";
|
|
166
166
|
}>;
|
|
167
167
|
export type RunnerOutcome = z.infer<typeof RunnerOutcomeSchema>;
|
|
168
|
-
/**
|
|
168
|
+
/** Auteur d'une demande prise par une session du runner. */
|
|
169
|
+
export declare const RunnerSessionAuthorSchema: z.ZodObject<{
|
|
170
|
+
id: z.ZodString;
|
|
171
|
+
name: z.ZodString;
|
|
172
|
+
}, z.core.$strip>;
|
|
173
|
+
export type RunnerSessionAuthor = z.infer<typeof RunnerSessionAuthorSchema>;
|
|
174
|
+
/**
|
|
175
|
+
* Relevé d'une session du runner ; le coût est celui qu'annonce Claude Code,
|
|
176
|
+
* null quand la session n'a pas pu le donner. `authors` liste, par nom, les
|
|
177
|
+
* auteurs des demandes que la session a prises.
|
|
178
|
+
*/
|
|
169
179
|
export declare const RunnerSessionRecordSchema: z.ZodObject<{
|
|
170
180
|
id: z.ZodString;
|
|
171
181
|
spaceId: z.ZodNullable<z.ZodString>;
|
|
@@ -187,8 +197,36 @@ export declare const RunnerSessionRecordSchema: z.ZodObject<{
|
|
|
187
197
|
outputTokens: z.ZodNumber;
|
|
188
198
|
cacheReadTokens: z.ZodNumber;
|
|
189
199
|
cacheCreationTokens: z.ZodNumber;
|
|
200
|
+
authors: z.ZodArray<z.ZodObject<{
|
|
201
|
+
id: z.ZodString;
|
|
202
|
+
name: z.ZodString;
|
|
203
|
+
}, z.core.$strip>>;
|
|
190
204
|
}, z.core.$strip>;
|
|
191
205
|
export type RunnerSessionRecord = z.infer<typeof RunnerSessionRecordSchema>;
|
|
206
|
+
/** Relevé d'une session du runner à enregistrer ; ses auteurs se déduisent des demandes prises. */
|
|
207
|
+
export declare const NewRunnerSessionSchema: z.ZodObject<{
|
|
208
|
+
id: z.ZodString;
|
|
209
|
+
spaceId: z.ZodNullable<z.ZodString>;
|
|
210
|
+
spaceName: z.ZodString;
|
|
211
|
+
startedAt: z.ZodISODateTime;
|
|
212
|
+
endedAt: z.ZodISODateTime;
|
|
213
|
+
outcome: z.ZodEnum<{
|
|
214
|
+
completed: "completed";
|
|
215
|
+
failed: "failed";
|
|
216
|
+
max_budget: "max_budget";
|
|
217
|
+
max_turns: "max_turns";
|
|
218
|
+
stopped: "stopped";
|
|
219
|
+
timeout: "timeout";
|
|
220
|
+
}>;
|
|
221
|
+
model: z.ZodNullable<z.ZodString>;
|
|
222
|
+
turns: z.ZodNullable<z.ZodNumber>;
|
|
223
|
+
costUsd: z.ZodNullable<z.ZodNumber>;
|
|
224
|
+
inputTokens: z.ZodNumber;
|
|
225
|
+
outputTokens: z.ZodNumber;
|
|
226
|
+
cacheReadTokens: z.ZodNumber;
|
|
227
|
+
cacheCreationTokens: z.ZodNumber;
|
|
228
|
+
}, z.core.$strip>;
|
|
229
|
+
export type NewRunnerSession = z.infer<typeof NewRunnerSessionSchema>;
|
|
192
230
|
/** Requête de `GET /admin/runner/usage` : nombre de jours relevés, 14 par défaut. */
|
|
193
231
|
export declare const RunnerUsageQuerySchema: z.ZodObject<{
|
|
194
232
|
days: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
@@ -217,6 +255,10 @@ export declare const RunnerUsageResponseSchema: z.ZodObject<{
|
|
|
217
255
|
outputTokens: z.ZodNumber;
|
|
218
256
|
cacheReadTokens: z.ZodNumber;
|
|
219
257
|
cacheCreationTokens: z.ZodNumber;
|
|
258
|
+
authors: z.ZodArray<z.ZodObject<{
|
|
259
|
+
id: z.ZodString;
|
|
260
|
+
name: z.ZodString;
|
|
261
|
+
}, z.core.$strip>>;
|
|
220
262
|
}, z.core.$strip>>;
|
|
221
263
|
}, z.core.$strip>;
|
|
222
264
|
export type RunnerUsageResponse = z.infer<typeof RunnerUsageResponseSchema>;
|
|
@@ -86,7 +86,13 @@ export const SaveClaudeTokenRequestSchema = z.object({ token: z.string().trim().
|
|
|
86
86
|
/** Issue d'une session du runner. */
|
|
87
87
|
export const RUNNER_OUTCOMES = ["completed", "failed", "stopped", "timeout", "max_turns", "max_budget"];
|
|
88
88
|
export const RunnerOutcomeSchema = z.enum(RUNNER_OUTCOMES);
|
|
89
|
-
/**
|
|
89
|
+
/** Auteur d'une demande prise par une session du runner. */
|
|
90
|
+
export const RunnerSessionAuthorSchema = z.object({ id: IdSchema, name: z.string() });
|
|
91
|
+
/**
|
|
92
|
+
* Relevé d'une session du runner ; le coût est celui qu'annonce Claude Code,
|
|
93
|
+
* null quand la session n'a pas pu le donner. `authors` liste, par nom, les
|
|
94
|
+
* auteurs des demandes que la session a prises.
|
|
95
|
+
*/
|
|
90
96
|
export const RunnerSessionRecordSchema = z.object({
|
|
91
97
|
id: IdSchema,
|
|
92
98
|
spaceId: IdSchema.nullable(),
|
|
@@ -101,7 +107,10 @@ export const RunnerSessionRecordSchema = z.object({
|
|
|
101
107
|
outputTokens: z.number().int().min(0),
|
|
102
108
|
cacheReadTokens: z.number().int().min(0),
|
|
103
109
|
cacheCreationTokens: z.number().int().min(0),
|
|
110
|
+
authors: z.array(RunnerSessionAuthorSchema),
|
|
104
111
|
});
|
|
112
|
+
/** Relevé d'une session du runner à enregistrer ; ses auteurs se déduisent des demandes prises. */
|
|
113
|
+
export const NewRunnerSessionSchema = RunnerSessionRecordSchema.omit({ authors: true });
|
|
105
114
|
/** Requête de `GET /admin/runner/usage` : nombre de jours relevés, 14 par défaut. */
|
|
106
115
|
export const RunnerUsageQuerySchema = z.object({ days: z.coerce.number().int().min(1).max(90).default(14) });
|
|
107
116
|
/** `GET /admin/runner/usage` : sessions des `days` derniers jours, de la plus récente à la plus ancienne. */
|
|
@@ -766,6 +766,14 @@ export const MIGRATIONS = [
|
|
|
766
766
|
FROM documents d;
|
|
767
767
|
CREATE INDEX entity_versions_space ON entity_versions(space_id, visible, seq);
|
|
768
768
|
CREATE INDEX entity_versions_task ON entity_versions(task_id, seq);
|
|
769
|
+
`,
|
|
770
|
+
// Auteurs des demandes prises par chaque session du runner.
|
|
771
|
+
`
|
|
772
|
+
CREATE TABLE runner_session_authors (
|
|
773
|
+
session_id TEXT NOT NULL REFERENCES runner_sessions(id) ON DELETE CASCADE,
|
|
774
|
+
user_id TEXT NOT NULL REFERENCES users(id),
|
|
775
|
+
PRIMARY KEY (session_id, user_id)
|
|
776
|
+
);
|
|
769
777
|
`,
|
|
770
778
|
];
|
|
771
779
|
/** Version du schéma attendue par ce code. */
|
package/dist/src/core/store.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type Database from "better-sqlite3";
|
|
|
2
2
|
import { WatcherRegistry } from "./watchers.js";
|
|
3
3
|
import { type BoardGrouping, type BoardLayout, type EntityType, type MemberRole, type RequestKind, type RequestStatus, type SpaceKind, type TaskPriority, type TaskStatus, type TaskType, type TestResultValue, type AccessLinkPurpose, type AgentOperation, type UserStatus, type VersionedEntityType } from "../../shared/schemas/enums.schema.js";
|
|
4
4
|
import { type AccessLink, type AgentAction, type AgentInstructions, type AgentRequest, type AgentToken, type Attachment, type BoardView, type Change, type ChecklistItem, type Comment, type QuestionOption, type QuestionSnapshot, type TaskQuestion, type EntityVersion, type FollowUp, type Idea, type Invitation, type Note, type SpaceDocument, type Membership, type Notification, type Session, type Space, type Tag, type Task, type TaskSnapshot, type TestCheckpoint, type TestResult, type TestReview, type TimeSession, type PomodoroSettings, type User, type UserSettings, type NotificationPreferences, type SpaceNotificationSettings } from "../../shared/schemas/entities.schema.js";
|
|
5
|
-
import { type ClaudeConnection, type RunnerSessionRecord, type RunnerSettings } from "../../shared/schemas/admin-api.schema.js";
|
|
5
|
+
import { type ClaudeConnection, type NewRunnerSession, type RunnerSessionRecord, type RunnerSettings } from "../../shared/schemas/admin-api.schema.js";
|
|
6
6
|
/**
|
|
7
7
|
* Auteur d'une mutation : un utilisateur de la GUI, ou un agent qui agit avec
|
|
8
8
|
* son jeton, avec les droits du propriétaire du jeton, pour une demande que ce
|
|
@@ -889,8 +889,12 @@ export declare class Mutation {
|
|
|
889
889
|
setClaudeConnection(tokenCipher: string, tokenHint: string): ClaudeConnection;
|
|
890
890
|
/** Marque le token de Claude comme refusé par Claude, avec le message de Claude Code. */
|
|
891
891
|
markClaudeTokenRefused(reason: string): void;
|
|
892
|
-
/**
|
|
893
|
-
|
|
892
|
+
/**
|
|
893
|
+
* Enregistre le relevé d'une session du runner terminée, avec les auteurs des
|
|
894
|
+
* demandes de son espace que le runner a prises entre son début et sa fin
|
|
895
|
+
* (hors actions directes).
|
|
896
|
+
*/
|
|
897
|
+
recordRunnerSession(record: NewRunnerSession): void;
|
|
894
898
|
/** Vérifie les invariants sur l'état final, puis écrit les versions et le journal. */
|
|
895
899
|
finish(): void;
|
|
896
900
|
private checkInvariants;
|
package/dist/src/core/store.js
CHANGED
|
@@ -6,7 +6,7 @@ import { WatcherRegistry } from "./watchers.js";
|
|
|
6
6
|
import { isVisibleVersion, VERSION_SNAPSHOT_SCHEMAS, versionSnapshot } from "./versions.js";
|
|
7
7
|
import { MAX_TASK_DEPTH, TASK_PRIORITIES, TASK_STATUSES, TASK_TYPES, VERSIONED_ENTITY_TYPES, } from "../../shared/schemas/enums.schema.js";
|
|
8
8
|
import { AccessLinkSchema, AgentActionSchema, AgentInstructionsSchema, AgentTokenSchema, AgentRequestSchema, AttachmentSchema, BoardViewSchema, ChangeSchema, ChecklistItemSchema, CommentSchema, MAX_QUESTION_OPTIONS, QuestionOptionSchema, TaskQuestionSchema, EntityVersionSchema, FollowUpSchema, IdeaSchema, InvitationSchema, NoteSchema, SpaceDocumentSchema, MembershipSchema, NotificationSchema, SessionSchema, SpaceSchema, TagSchema, TaskSchema, TaskSnapshotSchema, TestCheckpointSchema, TestResultSchema, TestReviewSchema, TimeSessionSchema, UserSchema, UserSettingsSchema, SpaceNotificationSettingsSchema, } from "../../shared/schemas/entities.schema.js";
|
|
9
|
-
import { ClaudeConnectionSchema, RunnerSessionRecordSchema, RunnerSettingsSchema, } from "../../shared/schemas/admin-api.schema.js";
|
|
9
|
+
import { ClaudeConnectionSchema, NewRunnerSessionSchema, RunnerSessionRecordSchema, RunnerSettingsSchema, } from "../../shared/schemas/admin-api.schema.js";
|
|
10
10
|
/** Valide `value` avec `schema` ; une donnée invalide est une erreur métier qui liste les champs fautifs. */
|
|
11
11
|
function validate(schema, value, what) {
|
|
12
12
|
const parsed = schema.safeParse(value);
|
|
@@ -45,7 +45,7 @@ function spaceNotificationSettingsFromRow(row) {
|
|
|
45
45
|
function agentInstructionsFromRow(row) {
|
|
46
46
|
return AgentInstructionsSchema.parse({ spaceId: row.space_id, text: row.text, updatedAt: row.updated_at, updatedBy: row.updated_by });
|
|
47
47
|
}
|
|
48
|
-
function runnerSessionFromRow(row) {
|
|
48
|
+
function runnerSessionFromRow(row, authors) {
|
|
49
49
|
return RunnerSessionRecordSchema.parse({
|
|
50
50
|
id: row.id,
|
|
51
51
|
spaceId: row.space_id,
|
|
@@ -60,6 +60,7 @@ function runnerSessionFromRow(row) {
|
|
|
60
60
|
outputTokens: row.output_tokens,
|
|
61
61
|
cacheReadTokens: row.cache_read_tokens,
|
|
62
62
|
cacheCreationTokens: row.cache_creation_tokens,
|
|
63
|
+
authors,
|
|
63
64
|
});
|
|
64
65
|
}
|
|
65
66
|
/** Les préférences de notification d'un objet qui les porte. */
|
|
@@ -531,7 +532,19 @@ export class Store {
|
|
|
531
532
|
}
|
|
532
533
|
/** Sessions du runner commencées depuis `since`, de la plus récente à la plus ancienne. */
|
|
533
534
|
listRunnerSessionsSince(since) {
|
|
534
|
-
|
|
535
|
+
const rows = this.db.prepare("SELECT * FROM runner_sessions WHERE started_at >= ? ORDER BY started_at DESC, id").all(since);
|
|
536
|
+
const authors = new Map();
|
|
537
|
+
const authorRows = this.db
|
|
538
|
+
.prepare(`SELECT a.session_id, u.id, COALESCE(u.display_name, u.email) AS name
|
|
539
|
+
FROM runner_session_authors a JOIN runner_sessions s ON s.id = a.session_id JOIN users u ON u.id = a.user_id
|
|
540
|
+
WHERE s.started_at >= ? ORDER BY name COLLATE NOCASE, u.id`)
|
|
541
|
+
.all(since);
|
|
542
|
+
for (const row of authorRows) {
|
|
543
|
+
const list = authors.get(row.session_id) ?? [];
|
|
544
|
+
list.push({ id: row.id, name: row.name });
|
|
545
|
+
authors.set(row.session_id, list);
|
|
546
|
+
}
|
|
547
|
+
return rows.map((row) => runnerSessionFromRow(row, authors.get(row.id) ?? []));
|
|
535
548
|
}
|
|
536
549
|
/** Instructions de l'agent propres à un espace, ou celles du site quand `spaceId` est null ; null s'il n'y en a pas. */
|
|
537
550
|
findAgentInstructions(spaceId) {
|
|
@@ -3146,13 +3159,22 @@ export class Mutation {
|
|
|
3146
3159
|
markClaudeTokenRefused(reason) {
|
|
3147
3160
|
this.db.prepare("UPDATE claude_connection SET refused_at = ?, refused_reason = ? WHERE id = 1").run(this.now, reason);
|
|
3148
3161
|
}
|
|
3149
|
-
/**
|
|
3162
|
+
/**
|
|
3163
|
+
* Enregistre le relevé d'une session du runner terminée, avec les auteurs des
|
|
3164
|
+
* demandes de son espace que le runner a prises entre son début et sa fin
|
|
3165
|
+
* (hors actions directes).
|
|
3166
|
+
*/
|
|
3150
3167
|
recordRunnerSession(record) {
|
|
3151
|
-
const valid = validate(
|
|
3168
|
+
const valid = validate(NewRunnerSessionSchema, record, "runner session");
|
|
3152
3169
|
this.db
|
|
3153
3170
|
.prepare(`INSERT INTO runner_sessions (id, space_id, space_name, started_at, ended_at, outcome, model, turns, cost_usd, input_tokens, output_tokens, cache_read_tokens, cache_creation_tokens)
|
|
3154
3171
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
|
|
3155
3172
|
.run(valid.id, valid.spaceId, valid.spaceName, valid.startedAt, valid.endedAt, valid.outcome, valid.model, valid.turns, valid.costUsd, valid.inputTokens, valid.outputTokens, valid.cacheReadTokens, valid.cacheCreationTokens);
|
|
3173
|
+
this.db
|
|
3174
|
+
.prepare(`INSERT INTO runner_session_authors (session_id, user_id)
|
|
3175
|
+
SELECT DISTINCT ?, r.author_id FROM agent_requests r JOIN agent_tokens t ON t.id = r.claimed_by_token_id
|
|
3176
|
+
WHERE r.target_space_id = ? AND t.is_runner = 1 AND r.kind <> 'direct' AND r.claimed_at >= ? AND r.claimed_at <= ?`)
|
|
3177
|
+
.run(valid.id, valid.spaceId, valid.startedAt, valid.endedAt);
|
|
3156
3178
|
}
|
|
3157
3179
|
// --- Fin de mutation ---
|
|
3158
3180
|
/** Vérifie les invariants sur l'état final, puis écrit les versions et le journal. */
|
package/dist/src/mcp/client.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AgentEnvelopeSchema, AgentErrorSchema, WaitRequestsDataSchema } from "../../shared/schemas/agent-tools.schema.js";
|
|
2
2
|
import { ToolArgumentError } from "./tools.js";
|
|
3
|
-
import { LocalFileError,
|
|
3
|
+
import { LocalFileError, readUpload } from "./upload.js";
|
|
4
4
|
/**
|
|
5
5
|
* Client HTTP de l'API agent du site : seul point de sortie réseau du mode
|
|
6
6
|
* MCP. Chaque appel porte le jeton dans `Authorization: Bearer`.
|
|
@@ -29,13 +29,13 @@ function redirectTarget(response, requestUrl) {
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
32
|
-
* Formulaire multipart d'un envoi de fichier : le fichier
|
|
32
|
+
* Formulaire multipart d'un envoi de fichier : le fichier dans le champ
|
|
33
33
|
* `file`, chaque autre argument dans un champ texte.
|
|
34
34
|
*/
|
|
35
35
|
async function uploadForm(file, fields) {
|
|
36
36
|
let upload;
|
|
37
37
|
try {
|
|
38
|
-
upload = await
|
|
38
|
+
upload = await readUpload(file);
|
|
39
39
|
}
|
|
40
40
|
catch (err) {
|
|
41
41
|
if (err instanceof LocalFileError)
|
package/dist/src/mcp/start.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type SiteConnection } from "./client.js";
|
|
2
2
|
/** Présentation du serveur transmise au client MCP : concepts et déroulé. */
|
|
3
|
-
export declare const INSTRUCTIONS = "mcp-organizer connects you to an organizer site: a multi-user task manager where people organize tasks in a web app and queue requests for the AI. You, the connected agent, process those requests when the user asks you to. The site never calls an LLM: you are the intelligence.\n\nYour token covers exactly one space, with the rights of the user who created the token. Every tool works on that space.\n\nConcepts:\n- A **space** holds tasks, an idea box, notes and reference documents. A user's **personal space** is private; a **shared space** has one owner and members.\n- A **task** has a title, a markdown description, a status (todo, doing, review, done), a priority (low, medium, high, critical), assignees and tags. Tasks nest on two levels: task > sub-task > sub-sub-task. A task is either standard (with a checklist) or a test (with checkpoints that each tester marks ok, ko, blocked or untested). Any task can also carry **questions** you ask the members to settle a point: options to choose from (one, or several), each with a markdown detail, plus a free answer. The members answer on the site; an answer does not notify you. You read the answers with get_task, and act on them only when a member asks you to, in a message or in a comment mentioning @agent.\n- A task has **attachments** (files the members upload), listed by get_task with their id. Members paste screenshots into descriptions, comments and checkpoint comments: such an image is an attachment of the task, referenced in the text as ``, and get_task flags the comments and checkpoint comments that contain one. Open with get_attachment the images and PDF files that matter for the request \u2014 a screenshot attached to a failed checkpoint, an image cited in a comment mentioning @agent, a PDF specification: you see an image as it is, and read the text of a PDF (a scanned PDF without a text layer is reported as such). You can attach a file yourself with add_attachment \u2014 a screenshot you took during a test, an export or a report you generated: give the absolute path of the file on your machine; this server reads and uploads it, so its content never goes through you. Pass comment to post it in a comment (an image shows as a thumbnail) or append_to_description to reference it in the description.\n- A **note** is a markdown draft a member writes in the space to mature a thought over several sessions. Notes never reach your queue and writing one does not notify you: read them only when a member asks you to, with get_note and search_notes (read-only). A text refers to a note by a link ending in `#/notes/<id>`; when a request links notes, claim_request shows them in full. \"Envoyer \u00E0 l'agent\" on a note queues a message that links it: process the note as that message asks (create or update tasks, ideas\u2026).\n- A **document** is a reference file a member uploads to the space (a report on the project, a specification, a data export\u2026) so that your decisions match the real state of the project. claim_request and get_context list the documents with their description; read the ones that help the request with get_document (read-only, in parts for long files). You read text files (txt, md, csv, json, yaml, xml\u2026) and the text of Word files (.docx) and PDF files; an image comes as the image itself, which you see.\n- A **request** is something a member of your space asked the AI: an idea, a remark, a test review, a message or an idea promotion. It is pending, then processing once you claim it (only your token can then act for it), then done (with your reply and the points left to its author) or failed (with the reason). The points left to the author are checkboxes the members tick off. A **follow-up** is a message a member sends from a handled request: claim_request shows that original request, your reply and its points with their ids, and check_follow_ups ticks off the points the follow-up settles. A member can also hand a request to you by mentioning @agent in a comment of a task: claim_request then shows the task's thread, and complete_request posts your reply as a comment right after theirs.\n- A **batch** is the set of actions you perform for one request. Every action is logged with its before and after state and with your token, and users can undo one action or the whole batch.\n- The **history** of the space records every event, by the members and by you: tasks created, changed (with before and after values) or deleted, checklist items, ideas, members, notes and documents (comments keep their own thread). Members read it on the site and restore an old version of a task, or a deleted task, from there. Read it with get_history when a member asks who changed something or what happened to a task.\n- A **direct action** is a write you make without request_id, when your user asks you directly (in their editor, for example) rather than through a request: it is done in the name of your token's owner and forms its own batch, listed among the requests of the space as a direct action and undoable like any other. The site runner never acts directly: it always passes the request_id of the request it processes.\n- A **view** is a tab of a member's dashboard: a layout (kanban, list, matrix), groupings by status or priority, and filters on status, priority, assignees, tags and task type (standard or test). Each member has their own views in each space.\n- A **timer** measures the time a member spends on a task: a free timer, or a pomodoro that alternates work phases and breaks (default 25 / 5 / 15 min, long break after 4 cycles). Each member has their own timer on a task, only one runs at a time, and the site's clock counts it; only the work phases of a pomodoro count. The time spent on a task is the sum of the sessions of all members: read it with get_task_time. When a member asks you to measure their time, call start_timer (and stop_timer to end it): you act on the timers of the author of the request, like their views.\n- The **scope** of your work is the space of your token: you see and process the requests of all its members, and you never act outside it. You change the views and timers of the author of the request you process, and nobody else's: only when the author owns your token, or when you are the site runner. A direct action on views or timers changes those of your token's owner.\n\nWork loop, when the user asks you to process the queue:\n1. list_requests to see the pending requests of your space.\n2. claim_request on the oldest one: it becomes processing for you and you get its context (text, author, context task, for a message the previous exchanges of its author, task tree, members, recent ideas, reference documents), along with the custom instructions of the site and of the space, which you follow. get_context shows the space at any time.\n3. Read what you need with get_task and search_tasks, with get_attachment for an image or a file attached to a task, with get_history to know who changed what, with get_note for a note the request or a task links, and with get_document for a reference document that helps the request.\n4. Act with create_task, update_task, set_assignees, set_tags, edit_checklist, edit_questions, add_comment, add_attachment, create_idea, update_idea, promote_idea, with list_views, create_view, update_view, delete_view when the author asks how their board should look, with start_timer and stop_timer when the author asks to measure their time on a task, and with check_follow_ups for a follow-up \u2014 always passing the request_id. Each write is one undoable action of the batch.\n5. complete_request with a short reply in the author's language and, in follow_ups, every point the author still has to handle (or fail_request with the reason), then go back to step 1 until no request is pending.\nWhen the queue is empty, tell the user.\n\nDirect work, when the user asks you to change the space outside any request: read with get_context, get_task and search_tasks, then call the write tools without request_id. Do not claim, complete or fail anything: there is no request to close. When your user still has points to handle afterwards, leave them with report_direct.\n\nNotifications: call enable_notifications once at the start of the session and arm the watcher it hands you with Monitor, whatever the command (behind mcp-http-gateway, the gateway relay answers in place of this server and gives its own watcher command). Each request that becomes pending in your space then arrives on its own as one line (kind, author, excerpt, request id), even while you are idle: process it with the work loop above, starting with claim_request. The host stops that watcher after 30 minutes at most: each time it tells you the watcher expired, re-arm it at once with the same Monitor call; otherwise notifications stop for good. A line \"notifications stopped\" means the site refused the token, and a line \"[gateway-watch] \u2026 la veille \u00E9choue\" means the gateway watcher keeps failing: tell the user. wait_for_requests is the waiting tool of the watcher: you do not need to call it.\n\nHow to handle each kind of request:\n- **idea**: classify it. If it belongs to an existing task or sub-task, attach it there (sub-task, checklist item or comment). If it is actionable and important enough, create a task (or sub-task) with a fitting priority. Otherwise, put it in the idea box with create_idea. Prefer existing tasks over duplicates.\n- **test_review**: feed the tester's findings back into the existing tasks (status, checklist, comments, priority of the affected tasks), or create a task for each problem that has none.\n- **remark** and **message**: do whatever is useful \u2014 answer, update or create tasks, comment \u2014 and say what you did in the reply.\n- **idea_promotion**: turn the context idea into a well-formed task with promote_idea.\n\nRules: write titles, descriptions and replies in the language of the users; keep the reply short and factual (markdown is rendered); put anything the members are meant to copy and paste (a command, code, a prompt, an identifier, a URL to reuse) in a fenced markdown code block, which the site shows with a Copy button; never bury in the reply something the author must act on: it belongs in follow_ups. Errors tell you what to do next; an error about the token (missing, revoked, expired, owner no longer a member) cannot be fixed by retrying: tell the user.";
|
|
3
|
+
export declare const INSTRUCTIONS = "mcp-organizer connects you to an organizer site: a multi-user task manager where people organize tasks in a web app and queue requests for the AI. You, the connected agent, process those requests when the user asks you to. The site never calls an LLM: you are the intelligence.\n\nYour token covers exactly one space, with the rights of the user who created the token. Every tool works on that space.\n\nConcepts:\n- A **space** holds tasks, an idea box, notes and reference documents. A user's **personal space** is private; a **shared space** has one owner and members.\n- A **task** has a title, a markdown description, a status (todo, doing, review, done), a priority (low, medium, high, critical), assignees and tags. Tasks nest on two levels: task > sub-task > sub-sub-task. A task is either standard (with a checklist) or a test (with checkpoints that each tester marks ok, ko, blocked or untested). Any task can also carry **questions** you ask the members to settle a point: options to choose from (one, or several), each with a markdown detail, plus a free answer. The members answer on the site; an answer does not notify you. You read the answers with get_task, and act on them only when a member asks you to, in a message or in a comment mentioning @agent.\n- A task has **attachments** (files the members upload), listed by get_task with their id. Members paste screenshots into descriptions, comments and checkpoint comments: such an image is an attachment of the task, referenced in the text as ``, and get_task flags the comments and checkpoint comments that contain one. Open with get_attachment the images and PDF files that matter for the request \u2014 a screenshot attached to a failed checkpoint, an image cited in a comment mentioning @agent, a PDF specification: you see an image as it is, and read the text of a PDF (a scanned PDF without a text layer is reported as such). You can attach a file yourself with add_attachment \u2014 a screenshot you took during a test, an export or a report you generated: give the absolute path of the file on your machine in file_path; it is read and uploaded for you, so its content never goes through you. Pass comment to post it in a comment (an image shows as a thumbnail) or append_to_description to reference it in the description.\n- A **note** is a markdown draft a member writes in the space to mature a thought over several sessions. Notes never reach your queue and writing one does not notify you: read them only when a member asks you to, with get_note and search_notes (read-only). A text refers to a note by a link ending in `#/notes/<id>`; when a request links notes, claim_request shows them in full. \"Envoyer \u00E0 l'agent\" on a note queues a message that links it: process the note as that message asks (create or update tasks, ideas\u2026).\n- A **document** is a reference file a member uploads to the space (a report on the project, a specification, a data export\u2026) so that your decisions match the real state of the project. claim_request and get_context list the documents with their description; read the ones that help the request with get_document (read-only, in parts for long files). You read text files (txt, md, csv, json, yaml, xml\u2026) and the text of Word files (.docx) and PDF files; an image comes as the image itself, which you see.\n- A **request** is something a member of your space asked the AI: an idea, a remark, a test review, a message or an idea promotion. It is pending, then processing once you claim it (only your token can then act for it), then done (with your reply and the points left to its author) or failed (with the reason). The points left to the author are checkboxes the members tick off. A **follow-up** is a message a member sends from a handled request: claim_request shows that original request, your reply and its points with their ids, and check_follow_ups ticks off the points the follow-up settles. A member can also hand a request to you by mentioning @agent in a comment of a task: claim_request then shows the task's thread, and complete_request posts your reply as a comment right after theirs.\n- A **batch** is the set of actions you perform for one request. Every action is logged with its before and after state and with your token, and users can undo one action or the whole batch.\n- The **history** of the space records every event, by the members and by you: tasks created, changed (with before and after values) or deleted, checklist items, ideas, members, notes and documents (comments keep their own thread). Members read it on the site and restore an old version of a task, or a deleted task, from there. Read it with get_history when a member asks who changed something or what happened to a task.\n- A **direct action** is a write you make without request_id, when your user asks you directly (in their editor, for example) rather than through a request: it is done in the name of your token's owner and forms its own batch, listed among the requests of the space as a direct action and undoable like any other. The site runner never acts directly: it always passes the request_id of the request it processes.\n- A **view** is a tab of a member's dashboard: a layout (kanban, list, matrix), groupings by status or priority, and filters on status, priority, assignees, tags and task type (standard or test). Each member has their own views in each space.\n- A **timer** measures the time a member spends on a task: a free timer, or a pomodoro that alternates work phases and breaks (default 25 / 5 / 15 min, long break after 4 cycles). Each member has their own timer on a task, only one runs at a time, and the site's clock counts it; only the work phases of a pomodoro count. The time spent on a task is the sum of the sessions of all members: read it with get_task_time. When a member asks you to measure their time, call start_timer (and stop_timer to end it): you act on the timers of the author of the request, like their views.\n- The **scope** of your work is the space of your token: you see and process the requests of all its members, and you never act outside it. You change the views and timers of the author of the request you process, and nobody else's: only when the author owns your token, or when you are the site runner. A direct action on views or timers changes those of your token's owner.\n\nWork loop, when the user asks you to process the queue:\n1. list_requests to see the pending requests of your space.\n2. claim_request on the oldest one: it becomes processing for you and you get its context (text, author, context task, for a message the previous exchanges of its author, task tree, members, recent ideas, reference documents), along with the custom instructions of the site and of the space, which you follow. get_context shows the space at any time.\n3. Read what you need with get_task and search_tasks, with get_attachment for an image or a file attached to a task, with get_history to know who changed what, with get_note for a note the request or a task links, and with get_document for a reference document that helps the request.\n4. Act with create_task, update_task, set_assignees, set_tags, edit_checklist, edit_questions, add_comment, add_attachment, create_idea, update_idea, promote_idea, with list_views, create_view, update_view, delete_view when the author asks how their board should look, with start_timer and stop_timer when the author asks to measure their time on a task, and with check_follow_ups for a follow-up \u2014 always passing the request_id. Each write is one undoable action of the batch.\n5. complete_request with a short reply in the author's language and, in follow_ups, every point the author still has to handle (or fail_request with the reason), then go back to step 1 until no request is pending.\nWhen the queue is empty, tell the user.\n\nDirect work, when the user asks you to change the space outside any request: read with get_context, get_task and search_tasks, then call the write tools without request_id. Do not claim, complete or fail anything: there is no request to close. When your user still has points to handle afterwards, leave them with report_direct.\n\nNotifications: call enable_notifications once at the start of the session and arm the watcher it hands you with Monitor, whatever the command (behind mcp-http-gateway, the gateway relay answers in place of this server and gives its own watcher command). Each request that becomes pending in your space then arrives on its own as one line (kind, author, excerpt, request id), even while you are idle: process it with the work loop above, starting with claim_request. The host stops that watcher after 30 minutes at most: each time it tells you the watcher expired, re-arm it at once with the same Monitor call; otherwise notifications stop for good. A line \"notifications stopped\" means the site refused the token, and a line \"[gateway-watch] \u2026 la veille \u00E9choue\" means the gateway watcher keeps failing: tell the user. wait_for_requests is the waiting tool of the watcher: you do not need to call it.\n\nHow to handle each kind of request:\n- **idea**: classify it. If it belongs to an existing task or sub-task, attach it there (sub-task, checklist item or comment). If it is actionable and important enough, create a task (or sub-task) with a fitting priority. Otherwise, put it in the idea box with create_idea. Prefer existing tasks over duplicates.\n- **test_review**: feed the tester's findings back into the existing tasks (status, checklist, comments, priority of the affected tasks), or create a task for each problem that has none.\n- **remark** and **message**: do whatever is useful \u2014 answer, update or create tasks, comment \u2014 and say what you did in the reply.\n- **idea_promotion**: turn the context idea into a well-formed task with promote_idea.\n\nRules: write titles, descriptions and replies in the language of the users; keep the reply short and factual (markdown is rendered); put anything the members are meant to copy and paste (a command, code, a prompt, an identifier, a URL to reuse) in a fenced markdown code block, which the site shows with a Copy button; never bury in the reply something the author must act on: it belongs in follow_ups. Errors tell you what to do next; an error about the token (missing, revoked, expired, owner no longer a member) cannot be fixed by retrying: tell the user.";
|
|
4
4
|
/**
|
|
5
5
|
* Connexion au site d'après `ORGANIZER_URL` et `ORGANIZER_TOKEN` ; une valeur
|
|
6
6
|
* absente ou invalide, ou une URL http vers une autre machine, est une `ConfigError`.
|
package/dist/src/mcp/start.js
CHANGED
|
@@ -16,7 +16,7 @@ Your token covers exactly one space, with the rights of the user who created the
|
|
|
16
16
|
Concepts:
|
|
17
17
|
- A **space** holds tasks, an idea box, notes and reference documents. A user's **personal space** is private; a **shared space** has one owner and members.
|
|
18
18
|
- A **task** has a title, a markdown description, a status (todo, doing, review, done), a priority (low, medium, high, critical), assignees and tags. Tasks nest on two levels: task > sub-task > sub-sub-task. A task is either standard (with a checklist) or a test (with checkpoints that each tester marks ok, ko, blocked or untested). Any task can also carry **questions** you ask the members to settle a point: options to choose from (one, or several), each with a markdown detail, plus a free answer. The members answer on the site; an answer does not notify you. You read the answers with get_task, and act on them only when a member asks you to, in a message or in a comment mentioning @agent.
|
|
19
|
-
- A task has **attachments** (files the members upload), listed by get_task with their id. Members paste screenshots into descriptions, comments and checkpoint comments: such an image is an attachment of the task, referenced in the text as \`\`, and get_task flags the comments and checkpoint comments that contain one. Open with get_attachment the images and PDF files that matter for the request — a screenshot attached to a failed checkpoint, an image cited in a comment mentioning @agent, a PDF specification: you see an image as it is, and read the text of a PDF (a scanned PDF without a text layer is reported as such). You can attach a file yourself with add_attachment — a screenshot you took during a test, an export or a report you generated: give the absolute path of the file on your machine;
|
|
19
|
+
- A task has **attachments** (files the members upload), listed by get_task with their id. Members paste screenshots into descriptions, comments and checkpoint comments: such an image is an attachment of the task, referenced in the text as \`\`, and get_task flags the comments and checkpoint comments that contain one. Open with get_attachment the images and PDF files that matter for the request — a screenshot attached to a failed checkpoint, an image cited in a comment mentioning @agent, a PDF specification: you see an image as it is, and read the text of a PDF (a scanned PDF without a text layer is reported as such). You can attach a file yourself with add_attachment — a screenshot you took during a test, an export or a report you generated: give the absolute path of the file on your machine in file_path; it is read and uploaded for you, so its content never goes through you. Pass comment to post it in a comment (an image shows as a thumbnail) or append_to_description to reference it in the description.
|
|
20
20
|
- A **note** is a markdown draft a member writes in the space to mature a thought over several sessions. Notes never reach your queue and writing one does not notify you: read them only when a member asks you to, with get_note and search_notes (read-only). A text refers to a note by a link ending in \`#/notes/<id>\`; when a request links notes, claim_request shows them in full. "Envoyer à l'agent" on a note queues a message that links it: process the note as that message asks (create or update tasks, ideas…).
|
|
21
21
|
- A **document** is a reference file a member uploads to the space (a report on the project, a specification, a data export…) so that your decisions match the real state of the project. claim_request and get_context list the documents with their description; read the ones that help the request with get_document (read-only, in parts for long files). You read text files (txt, md, csv, json, yaml, xml…) and the text of Word files (.docx) and PDF files; an image comes as the image itself, which you see.
|
|
22
22
|
- A **request** is something a member of your space asked the AI: an idea, a remark, a test review, a message or an idea promotion. It is pending, then processing once you claim it (only your token can then act for it), then done (with your reply and the points left to its author) or failed (with the reason). The points left to the author are checkboxes the members tick off. A **follow-up** is a message a member sends from a handled request: claim_request shows that original request, your reply and its points with their ids, and check_follow_ups ticks off the points the follow-up settles. A member can also hand a request to you by mentioning @agent in a comment of a task: claim_request then shows the task's thread, and complete_request posts your reply as a comment right after theirs.
|
package/dist/src/mcp/tools.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { UploadSource } from "./upload.js";
|
|
1
2
|
/**
|
|
2
3
|
* Outils de l'agent : définition (schéma JSON écrit à la main, description
|
|
3
4
|
* en anglais) et route de l'API agent du site qui l'exécute. Le mode MCP ne
|
|
@@ -36,11 +37,8 @@ export interface ToolHttpRequest {
|
|
|
36
37
|
path: string;
|
|
37
38
|
query: Record<string, string>;
|
|
38
39
|
body: Record<string, unknown> | undefined;
|
|
39
|
-
/** Fichier
|
|
40
|
-
file?:
|
|
41
|
-
path: string;
|
|
42
|
-
name?: string;
|
|
43
|
-
};
|
|
40
|
+
/** Fichier à envoyer en multipart (champ `file`), pour un outil d'envoi. */
|
|
41
|
+
file?: UploadSource;
|
|
44
42
|
}
|
|
45
43
|
/** Argument d'appel d'outil inutilisable pour former la requête. */
|
|
46
44
|
export declare class ToolArgumentError extends Error {
|
package/dist/src/mcp/tools.js
CHANGED
|
@@ -422,13 +422,18 @@ export const AGENT_TOOLS = [
|
|
|
422
422
|
upload: true,
|
|
423
423
|
definition: {
|
|
424
424
|
name: "add_attachment",
|
|
425
|
-
description: "Attach a local file to a task of your space: a screenshot you took during a test, an export or a report you generated. Give the absolute path of the file on
|
|
425
|
+
description: "Attach a local file to a task of your space: a screenshot you took during a test, an export or a report you generated. Give the absolute path of the file on your machine in file_path: it is read and uploaded to the site for you, so its content never goes through you. Any format, up to 20 MB. To show it to the members, pass comment (a comment posted with the file shown in it: an image as a thumbnail, another file by its name) or append_to_description (the same reference added at the end of the description). Members see the file among the attachments of the task and can undo the upload with the rest of the batch.",
|
|
426
426
|
inputSchema: {
|
|
427
427
|
type: "object",
|
|
428
428
|
properties: {
|
|
429
429
|
request_id: REQUEST_ID,
|
|
430
430
|
task: TASK_REF,
|
|
431
|
-
|
|
431
|
+
file_path: { type: "string", description: "Absolute path of a regular file on your machine (e.g. C:\\Users\\me\\capture.png or /tmp/report.pdf)." },
|
|
432
|
+
file_content: {
|
|
433
|
+
type: "string",
|
|
434
|
+
description: "Content of the file encoded in base64, with file_name, in place of file_path. Only when this server cannot read your disk (it runs on another machine and no relay reads the file for you); otherwise use file_path.",
|
|
435
|
+
},
|
|
436
|
+
file_name: { type: "string", maxLength: 255, description: "Name of the file given in file_content, with its extension, which sets its type (e.g. capture.png)." },
|
|
432
437
|
name: { type: "string", maxLength: 255, description: "File name shown to the members. Default: the name of the file." },
|
|
433
438
|
comment: {
|
|
434
439
|
type: "string",
|
|
@@ -437,7 +442,7 @@ export const AGENT_TOOLS = [
|
|
|
437
442
|
},
|
|
438
443
|
append_to_description: { type: "boolean", description: "Add the reference to the file at the end of the task description. Default: false." },
|
|
439
444
|
},
|
|
440
|
-
required: ["task"
|
|
445
|
+
required: ["task"],
|
|
441
446
|
additionalProperties: false,
|
|
442
447
|
},
|
|
443
448
|
},
|
|
@@ -670,6 +675,40 @@ export const AGENT_TOOLS = [
|
|
|
670
675
|
export function findAgentTool(name) {
|
|
671
676
|
return AGENT_TOOLS.find((tool) => tool.definition.name === name);
|
|
672
677
|
}
|
|
678
|
+
/** Chaîne non vide, ou undefined pour un argument absent ; toute autre valeur est refusée. */
|
|
679
|
+
function optionalText(args, name, expected) {
|
|
680
|
+
const value = args[name];
|
|
681
|
+
if (value === undefined || value === null)
|
|
682
|
+
return undefined;
|
|
683
|
+
if (typeof value !== "string" || value.trim() === "")
|
|
684
|
+
throw new ToolArgumentError(`Invalid arguments — ${name}: expected ${expected}. Check the tool's input schema.`);
|
|
685
|
+
return value;
|
|
686
|
+
}
|
|
687
|
+
/**
|
|
688
|
+
* Fichier d'un outil d'envoi et champs de son formulaire. Le fichier vient de
|
|
689
|
+
* `file_path` ou de `file_content` (base64) avec `file_name` : la paire
|
|
690
|
+
* `file_path` / `file_content` est celle que le relais de mcp-http-gateway
|
|
691
|
+
* reconnaît pour lire le fichier sur la machine de l'agent et en transmettre
|
|
692
|
+
* le contenu.
|
|
693
|
+
*/
|
|
694
|
+
function uploadArguments(args) {
|
|
695
|
+
const { file_path: _path, file_content: _content, file_name: _fileName, name: _name, ...body } = args;
|
|
696
|
+
const filePath = optionalText(args, "file_path", "the absolute path of a file");
|
|
697
|
+
const content = optionalText(args, "file_content", "the content of the file encoded in base64");
|
|
698
|
+
const fileName = optionalText(args, "file_name", "the name of the file, with its extension");
|
|
699
|
+
const name = optionalText(args, "name", "a non-empty string");
|
|
700
|
+
const shown = name === undefined ? {} : { name };
|
|
701
|
+
if (filePath !== undefined && content !== undefined)
|
|
702
|
+
throw new ToolArgumentError("Invalid arguments — pass file_path or file_content, not both.");
|
|
703
|
+
if (content !== undefined) {
|
|
704
|
+
if (fileName === undefined)
|
|
705
|
+
throw new ToolArgumentError("Invalid arguments — file_name: expected the name of the file given in file_content, with its extension.");
|
|
706
|
+
return { body, file: { content, filename: fileName.trim(), ...shown } };
|
|
707
|
+
}
|
|
708
|
+
if (filePath === undefined)
|
|
709
|
+
throw new ToolArgumentError("Invalid arguments — file_path: expected the absolute path of a file. Check the tool's input schema.");
|
|
710
|
+
return { body, file: { path: filePath.trim(), ...shown } };
|
|
711
|
+
}
|
|
673
712
|
/**
|
|
674
713
|
* Requête HTTP d'un appel d'outil : les arguments nommés dans le chemin y
|
|
675
714
|
* sont placés (ils sont alors obligatoires et textuels), les autres vont
|
|
@@ -686,12 +725,7 @@ export function toolHttpRequest(tool, args) {
|
|
|
686
725
|
return encodeURIComponent(value.trim());
|
|
687
726
|
});
|
|
688
727
|
if (tool.upload) {
|
|
689
|
-
|
|
690
|
-
if (typeof filePath !== "string" || filePath.trim() === "")
|
|
691
|
-
throw new ToolArgumentError("Invalid arguments — path: expected the absolute path of a file. Check the tool's input schema.");
|
|
692
|
-
if (name !== undefined && (typeof name !== "string" || name.trim() === ""))
|
|
693
|
-
throw new ToolArgumentError("Invalid arguments — name: expected a non-empty string. Check the tool's input schema.");
|
|
694
|
-
return { method: tool.method, path, query: {}, body: fields, file: { path: filePath.trim(), ...(name === undefined ? {} : { name: name }) } };
|
|
728
|
+
return { method: tool.method, path, query: {}, ...uploadArguments(rest) };
|
|
695
729
|
}
|
|
696
730
|
if (tool.method !== "GET")
|
|
697
731
|
return { method: tool.method, path, query: {}, body: rest };
|
package/dist/src/mcp/upload.d.ts
CHANGED
|
@@ -1,8 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Fichier
|
|
3
|
-
* sur la machine où il tourne, avec les droits de
|
|
4
|
-
*
|
|
2
|
+
* Fichier envoyé par l'agent comme pièce jointe. Désigné par son chemin, le
|
|
3
|
+
* mode MCP le lit sur la machine où il tourne, avec les droits de
|
|
4
|
+
* l'utilisateur qui l'a lancé. Fourni en base64, il est décodé tel quel :
|
|
5
|
+
* c'est la forme que remplit le relais de mcp-http-gateway, qui lit le
|
|
6
|
+
* fichier sur la machine de l'agent quand le mode MCP tourne sur celle de
|
|
7
|
+
* la gateway.
|
|
5
8
|
*/
|
|
9
|
+
/** Source d'un envoi : chemin absolu d'un fichier local, ou contenu en base64 avec son nom de fichier. */
|
|
10
|
+
export type UploadSource = {
|
|
11
|
+
path: string;
|
|
12
|
+
name?: string;
|
|
13
|
+
} | {
|
|
14
|
+
content: string;
|
|
15
|
+
filename: string;
|
|
16
|
+
name?: string;
|
|
17
|
+
};
|
|
6
18
|
/** Fichier local lu pour l'envoi. */
|
|
7
19
|
export interface LocalUpload {
|
|
8
20
|
filename: string;
|
|
@@ -20,3 +32,10 @@ export declare function mimeOfFilename(filename: string): string;
|
|
|
20
32
|
* remplace son nom. Un lien symbolique est suivi jusqu'au fichier qu'il désigne.
|
|
21
33
|
*/
|
|
22
34
|
export declare function readLocalUpload(filePath: string, name?: string): Promise<LocalUpload>;
|
|
35
|
+
/**
|
|
36
|
+
* Décode le contenu base64 `content` d'un fichier nommé `filename`, qui
|
|
37
|
+
* donne son type ; `name` remplace ce nom. Les blancs du base64 sont ignorés.
|
|
38
|
+
*/
|
|
39
|
+
export declare function decodeInlineUpload(content: string, filename: string, name?: string): LocalUpload;
|
|
40
|
+
/** Fichier d'un envoi, lu sur le disque ou décodé du base64 selon sa source. */
|
|
41
|
+
export declare function readUpload(source: UploadSource): Promise<LocalUpload>;
|
package/dist/src/mcp/upload.js
CHANGED
|
@@ -49,8 +49,9 @@ export async function readLocalUpload(filePath, name) {
|
|
|
49
49
|
stat = await fs.stat(filePath);
|
|
50
50
|
}
|
|
51
51
|
catch (err) {
|
|
52
|
-
if (err?.code === "ENOENT" || err?.code === "ENOTDIR")
|
|
53
|
-
throw new LocalFileError(`No file at ${filePath}: check the path.`);
|
|
52
|
+
if (err?.code === "ENOENT" || err?.code === "ENOTDIR") {
|
|
53
|
+
throw new LocalFileError(`No file at ${filePath}: check the path. This server reads the path on the machine where it runs; if that is not your machine, pass the file in file_content (base64) with file_name instead.`);
|
|
54
|
+
}
|
|
54
55
|
if (err?.code === "EACCES" || err?.code === "EPERM")
|
|
55
56
|
throw new LocalFileError(`The file ${filePath} cannot be read: permission denied.`);
|
|
56
57
|
throw new LocalFileError(`The file ${filePath} cannot be read (${err?.message ?? err}).`);
|
|
@@ -77,3 +78,31 @@ export async function readLocalUpload(filePath, name) {
|
|
|
77
78
|
throw new LocalFileError("name must not be empty.");
|
|
78
79
|
return { filename, mime: mimeOfFilename(path.basename(filePath)), content };
|
|
79
80
|
}
|
|
81
|
+
/** Base64 standard : alphabet, longueur multiple de 4, au plus deux `=` en fin. */
|
|
82
|
+
function isBase64(text) {
|
|
83
|
+
return text.length % 4 === 0 && /^[A-Za-z0-9+/]*={0,2}$/.test(text);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Décode le contenu base64 `content` d'un fichier nommé `filename`, qui
|
|
87
|
+
* donne son type ; `name` remplace ce nom. Les blancs du base64 sont ignorés.
|
|
88
|
+
*/
|
|
89
|
+
export function decodeInlineUpload(content, filename, name) {
|
|
90
|
+
const compact = content.replace(/\s+/g, "");
|
|
91
|
+
if ((compact.length / 4) * 3 > MAX_ATTACHMENT_BYTES + 2) {
|
|
92
|
+
throw new LocalFileError(`The file ${filename} is too large: an attachment cannot exceed ${megabytes(MAX_ATTACHMENT_BYTES)}.`);
|
|
93
|
+
}
|
|
94
|
+
if (!isBase64(compact))
|
|
95
|
+
throw new LocalFileError("file_content must be the content of the file encoded in base64.");
|
|
96
|
+
const decoded = Buffer.from(compact, "base64");
|
|
97
|
+
if (decoded.length > MAX_ATTACHMENT_BYTES) {
|
|
98
|
+
throw new LocalFileError(`The file ${filename} is too large (${megabytes(decoded.length)}): an attachment cannot exceed ${megabytes(MAX_ATTACHMENT_BYTES)}.`);
|
|
99
|
+
}
|
|
100
|
+
const shown = (name ?? path.basename(filename)).trim();
|
|
101
|
+
if (shown === "")
|
|
102
|
+
throw new LocalFileError("name must not be empty.");
|
|
103
|
+
return { filename: shown, mime: mimeOfFilename(path.basename(filename)), content: decoded };
|
|
104
|
+
}
|
|
105
|
+
/** Fichier d'un envoi, lu sur le disque ou décodé du base64 selon sa source. */
|
|
106
|
+
export async function readUpload(source) {
|
|
107
|
+
return "content" in source ? decodeInlineUpload(source.content, source.filename, source.name) : readLocalUpload(source.path, source.name);
|
|
108
|
+
}
|