@imenam/mcp-organizer 1.0.21 → 1.0.23
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 +17 -12
- package/dist/shared/logic/documents.d.ts +2 -4
- package/dist/shared/logic/documents.js +6 -11
- package/dist/shared/schemas/agent-tools.schema.d.ts +133 -7
- package/dist/shared/schemas/agent-tools.schema.js +52 -7
- package/dist/shared/schemas/documents-api.schema.d.ts +0 -2
- package/dist/shared/schemas/documents-api.schema.js +0 -2
- package/dist/src/agent-api/attachments.d.ts +2 -0
- package/dist/src/agent-api/attachments.js +96 -0
- package/dist/src/agent-api/documents.d.ts +1 -1
- package/dist/src/agent-api/documents.js +9 -33
- package/dist/src/agent-api/files.d.ts +35 -0
- package/dist/src/agent-api/files.js +86 -0
- package/dist/src/agent-api/router.d.ts +2 -2
- package/dist/src/agent-api/router.js +5 -4
- package/dist/src/agent-api/tasks.js +5 -8
- package/dist/src/agent-api/types.d.ts +4 -2
- package/dist/src/core/agent-files.d.ts +41 -0
- package/dist/src/core/agent-files.js +102 -0
- package/dist/src/core/agent.d.ts +3 -1
- package/dist/src/core/agent.js +14 -3
- package/dist/src/core/document-text.d.ts +3 -2
- package/dist/src/core/document-text.js +3 -2
- package/dist/src/core/documents.js +0 -1
- package/dist/src/core/history.d.ts +3 -1
- package/dist/src/core/history.js +28 -11
- package/dist/src/core/mail-render.d.ts +98 -0
- package/dist/src/core/mail-render.js +447 -0
- package/dist/src/core/mail.d.ts +6 -1
- package/dist/src/core/mail.js +1 -1
- package/dist/src/core/notifications.d.ts +2 -0
- package/dist/src/core/notifications.js +70 -32
- package/dist/src/core/password-reset.js +30 -9
- package/dist/src/core/requests.d.ts +9 -4
- package/dist/src/core/requests.js +21 -10
- package/dist/src/core/snapshots.d.ts +3 -3
- package/dist/src/core/snapshots.js +3 -1
- package/dist/src/core/spaces.js +12 -5
- package/dist/src/gui-api.js +2 -2
- package/dist/src/mcp/client.d.ts +7 -4
- package/dist/src/mcp/client.js +31 -4
- package/dist/src/mcp/start.d.ts +1 -1
- package/dist/src/mcp/start.js +6 -6
- package/dist/src/mcp/tools.d.ts +11 -0
- package/dist/src/mcp/tools.js +55 -4
- package/dist/src/mcp/upload.d.ts +22 -0
- package/dist/src/mcp/upload.js +79 -0
- package/dist/src/server/app.js +38 -4
- package/gui/dist/assets/{index-DbzcjyaW.js → index-C1f7hOcM.js} +2 -2
- package/gui/dist/assets/{index-Dvf5Yo0e.css → index-CfMiwPSL.css} +1 -1
- package/gui/dist/index.html +2 -2
- package/package.json +4 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { accessLinkPath, issueAccessLink, normalizeEmail } from "./accounts.js";
|
|
2
2
|
import { OrganizerError } from "./errors.js";
|
|
3
|
+
import { renderEmail } from "./mail-render.js";
|
|
3
4
|
import { RESET_LINK_TTL_MINUTES } from "../../shared/schemas/api.schema.js";
|
|
4
5
|
function publicBase(publicUrl) {
|
|
5
6
|
return publicUrl?.trim().replace(/\/+$/, "") || null;
|
|
@@ -15,8 +16,8 @@ export function passwordResetBlocker(deps) {
|
|
|
15
16
|
return null;
|
|
16
17
|
}
|
|
17
18
|
/** Envoie un e-mail et journalise son issue. */
|
|
18
|
-
async function deliver(deps, to,
|
|
19
|
-
const outcome = await deps.mailer.send({ to,
|
|
19
|
+
async function deliver(deps, to, email, what) {
|
|
20
|
+
const outcome = await deps.mailer.send({ to, ...email });
|
|
20
21
|
if (outcome.sent)
|
|
21
22
|
deps.log.info(`Password reset: ${what} sent to ${to}.`);
|
|
22
23
|
else
|
|
@@ -42,15 +43,35 @@ export function requestPasswordReset(store, deps, rawEmail) {
|
|
|
42
43
|
const issued = store.mutate({ type: "user", userId: user.id }, (tx) => issueAccessLink(tx, user.id, "reset", null, now));
|
|
43
44
|
deps.log.info(`Password reset requested for ${email}: link issued, valid until ${issued.expiresAt}.`);
|
|
44
45
|
const url = `${publicBase(deps.publicUrl)}/${accessLinkPath(issued.token)}`;
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
const message = renderEmail({
|
|
47
|
+
subject: "Réinitialisation de votre mot de passe",
|
|
48
|
+
blocks: [
|
|
49
|
+
{ type: "paragraph", content: [`Une réinitialisation du mot de passe de votre compte mcp-organizer (${email}) a été demandée.`] },
|
|
50
|
+
{ type: "paragraph", content: [`Pour choisir un nouveau mot de passe, ouvrez ce lien, valable ${RESET_LINK_TTL_MINUTES} minutes et une seule fois.`] },
|
|
51
|
+
],
|
|
52
|
+
action: { label: "Choisir un nouveau mot de passe", url },
|
|
53
|
+
showActionUrl: true,
|
|
54
|
+
footnote: "Si vous n'êtes pas à l'origine de cette demande, ignorez ce message : votre mot de passe reste inchangé.",
|
|
55
|
+
});
|
|
56
|
+
return { delivery: deliver(deps, email, message, "reset link") };
|
|
49
57
|
}
|
|
50
58
|
/** Journalise une réinitialisation faite et envoie l'e-mail de confirmation au compte. */
|
|
51
59
|
export function confirmPasswordReset(deps, user) {
|
|
52
60
|
deps.log.info(`Password reset completed for ${user.email}: other sessions closed.`);
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
61
|
+
const base = publicBase(deps.publicUrl);
|
|
62
|
+
const message = renderEmail({
|
|
63
|
+
subject: "Votre mot de passe a été modifié",
|
|
64
|
+
blocks: [
|
|
65
|
+
{ type: "paragraph", content: [`Le mot de passe de votre compte mcp-organizer (${user.email}) vient d'être modifié, et vos autres sessions ont été fermées.`] },
|
|
66
|
+
{
|
|
67
|
+
type: "paragraph",
|
|
68
|
+
content: [
|
|
69
|
+
"Si vous n'êtes pas à l'origine de ce changement, faites immédiatement une demande depuis « Mot de passe oublié ? » sur l'écran de connexion, puis prévenez l'administrateur du site.",
|
|
70
|
+
],
|
|
71
|
+
tone: "alert",
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
action: base ? { label: "Ouvrir mcp-organizer", url: `${base}/` } : undefined,
|
|
75
|
+
});
|
|
76
|
+
return { delivery: deliver(deps, user.email, message, "confirmation") };
|
|
56
77
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { AttachmentStorage } from "./attachments.js";
|
|
1
2
|
import type { Store } from "./store.js";
|
|
2
3
|
import type { AgentAction, AgentRequest } from "../../shared/schemas/entities.schema.js";
|
|
3
4
|
import type { RequestKind } from "../../shared/schemas/enums.schema.js";
|
|
@@ -65,7 +66,11 @@ export declare function listRequests(store: Store, userId: string, spaceId: stri
|
|
|
65
66
|
startedAt: string;
|
|
66
67
|
} | null;
|
|
67
68
|
}, now?: Date): RequestListResponse;
|
|
68
|
-
/** Annule une action de l'agent
|
|
69
|
-
export declare function undoAction(store: Store, userId: string, actionId: string): RequestView;
|
|
70
|
-
/**
|
|
71
|
-
|
|
69
|
+
/** Annule une action de l'agent ; le fichier d'une pièce jointe ainsi supprimée est effacé. */
|
|
70
|
+
export declare function undoAction(store: Store, storage: AttachmentStorage, userId: string, actionId: string): RequestView;
|
|
71
|
+
/**
|
|
72
|
+
* Annule toutes les actions non annulées d'un lot, de la plus récente à la
|
|
73
|
+
* plus ancienne : tout le lot ou rien. Les fichiers des pièces jointes
|
|
74
|
+
* supprimées sont effacés.
|
|
75
|
+
*/
|
|
76
|
+
export declare function undoRequest(store: Store, storage: AttachmentStorage, userId: string, requestId: string): RequestView;
|
|
@@ -262,29 +262,40 @@ function requireUndoableRequest(request) {
|
|
|
262
262
|
if (request.status === "processing")
|
|
263
263
|
throw new InvariantError("L'agent traite encore cette demande : attendez qu'il ait terminé pour annuler ses actions.");
|
|
264
264
|
}
|
|
265
|
-
/** Annule une action de l'agent
|
|
266
|
-
export function undoAction(store, userId, actionId) {
|
|
267
|
-
const requestId = store.mutate(asUser(userId), (tx) => {
|
|
265
|
+
/** Annule une action de l'agent ; le fichier d'une pièce jointe ainsi supprimée est effacé. */
|
|
266
|
+
export function undoAction(store, storage, userId, actionId) {
|
|
267
|
+
const { requestId, removedFile } = store.mutate(asUser(userId), (tx) => {
|
|
268
268
|
const action = tx.store.findAgentAction(actionId);
|
|
269
269
|
if (!action)
|
|
270
270
|
throw new NotFoundError("Action introuvable.");
|
|
271
271
|
const request = requireVisibleRequest(tx.store, userId, action.requestId);
|
|
272
272
|
requireUndoableRequest(request);
|
|
273
|
-
undoAgentAction(tx, action);
|
|
274
|
-
return request.id;
|
|
273
|
+
return { requestId: request.id, removedFile: undoAgentAction(tx, action) };
|
|
275
274
|
});
|
|
275
|
+
if (removedFile !== null)
|
|
276
|
+
storage.remove([removedFile]);
|
|
276
277
|
return requestView(store, userId, store.getAgentRequest(requestId));
|
|
277
278
|
}
|
|
278
|
-
/**
|
|
279
|
-
|
|
280
|
-
|
|
279
|
+
/**
|
|
280
|
+
* Annule toutes les actions non annulées d'un lot, de la plus récente à la
|
|
281
|
+
* plus ancienne : tout le lot ou rien. Les fichiers des pièces jointes
|
|
282
|
+
* supprimées sont effacés.
|
|
283
|
+
*/
|
|
284
|
+
export function undoRequest(store, storage, userId, requestId) {
|
|
285
|
+
const removedFiles = store.mutate(asUser(userId), (tx) => {
|
|
281
286
|
const request = requireVisibleRequest(tx.store, userId, requestId);
|
|
282
287
|
requireUndoableRequest(request);
|
|
283
288
|
const remaining = tx.store.listAgentActions(requestId).filter((action) => action.undoneAt === null);
|
|
284
289
|
if (remaining.length === 0)
|
|
285
290
|
throw new InvariantError("Toutes les actions de ce lot sont déjà annulées.");
|
|
286
|
-
|
|
287
|
-
|
|
291
|
+
const files = [];
|
|
292
|
+
for (const action of remaining.reverse()) {
|
|
293
|
+
const removed = undoAgentAction(tx, tx.store.getAgentAction(action.id));
|
|
294
|
+
if (removed !== null)
|
|
295
|
+
files.push(removed);
|
|
296
|
+
}
|
|
297
|
+
return files;
|
|
288
298
|
});
|
|
299
|
+
storage.remove(removedFiles);
|
|
289
300
|
return requestView(store, userId, store.getAgentRequest(requestId));
|
|
290
301
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import type { Store } from "./store.js";
|
|
3
3
|
import type { EntityType } from "../../shared/schemas/enums.schema.js";
|
|
4
|
-
import { type AgentAction, type BoardView, type ChecklistItem, type Comment, type FollowUp, type Idea, type QuestionSnapshot, type TaskSnapshot, type TimeSession } from "../../shared/schemas/entities.schema.js";
|
|
4
|
+
import { type AgentAction, type Attachment, type BoardView, type ChecklistItem, type Comment, type FollowUp, type Idea, type QuestionSnapshot, type TaskSnapshot, type TimeSession } from "../../shared/schemas/entities.schema.js";
|
|
5
5
|
/** Instantanés des entités que l'agent modifie : l'état avant et après chaque action de son lot. */
|
|
6
6
|
/** Point de vérification avec les résultats saisis dessus. */
|
|
7
7
|
export declare const CheckpointSnapshotSchema: z.ZodObject<{
|
|
@@ -24,9 +24,9 @@ export declare const CheckpointSnapshotSchema: z.ZodObject<{
|
|
|
24
24
|
}, z.core.$strip>;
|
|
25
25
|
export type CheckpointSnapshot = z.infer<typeof CheckpointSnapshotSchema>;
|
|
26
26
|
/** Entités dont l'agent enregistre l'état avant et après chaque action. */
|
|
27
|
-
export type TrackedEntityType = "task" | "checklist_item" | "task_question" | "test_checkpoint" | "comment" | "idea" | "board_view" | "follow_up" | "time_session";
|
|
27
|
+
export type TrackedEntityType = "task" | "checklist_item" | "task_question" | "test_checkpoint" | "comment" | "attachment" | "idea" | "board_view" | "follow_up" | "time_session";
|
|
28
28
|
export declare function isTracked(entityType: EntityType): entityType is TrackedEntityType;
|
|
29
29
|
/** Instantané courant d'une entité, ou null si elle n'existe pas. */
|
|
30
|
-
export declare function snapshotOf(store: Store, entityType: TrackedEntityType, entityId: string): TaskSnapshot | ChecklistItem | QuestionSnapshot | CheckpointSnapshot | Comment | Idea | BoardView | FollowUp | TimeSession | null;
|
|
30
|
+
export declare function snapshotOf(store: Store, entityType: TrackedEntityType, entityId: string): TaskSnapshot | ChecklistItem | QuestionSnapshot | CheckpointSnapshot | Comment | Attachment | Idea | BoardView | FollowUp | TimeSession | null;
|
|
31
31
|
/** Tâche concernée par une action : la tâche elle-même, ou celle qui porte l'élément ; null pour une idée, une vue ou un point à régler. */
|
|
32
32
|
export declare function taskIdOfAction(action: Pick<AgentAction, "entityType" | "entityId" | "before" | "after">): string | null;
|
|
@@ -3,7 +3,7 @@ import { TestCheckpointSchema, TestResultSchema } from "../../shared/schemas/ent
|
|
|
3
3
|
/** Instantanés des entités que l'agent modifie : l'état avant et après chaque action de son lot. */
|
|
4
4
|
/** Point de vérification avec les résultats saisis dessus. */
|
|
5
5
|
export const CheckpointSnapshotSchema = TestCheckpointSchema.extend({ results: z.array(TestResultSchema) });
|
|
6
|
-
const TRACKED = new Set(["task", "checklist_item", "task_question", "test_checkpoint", "comment", "idea", "board_view", "follow_up", "time_session"]);
|
|
6
|
+
const TRACKED = new Set(["task", "checklist_item", "task_question", "test_checkpoint", "comment", "attachment", "idea", "board_view", "follow_up", "time_session"]);
|
|
7
7
|
export function isTracked(entityType) {
|
|
8
8
|
return TRACKED.has(entityType);
|
|
9
9
|
}
|
|
@@ -24,6 +24,8 @@ export function snapshotOf(store, entityType, entityId) {
|
|
|
24
24
|
}
|
|
25
25
|
case "comment":
|
|
26
26
|
return store.findComment(entityId);
|
|
27
|
+
case "attachment":
|
|
28
|
+
return store.findAttachment(entityId);
|
|
27
29
|
case "idea":
|
|
28
30
|
return store.findIdea(entityId);
|
|
29
31
|
case "board_view":
|
package/dist/src/core/spaces.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ACCESS_LINK_TTL_MS, accessLinkPath, issueAccessLink, joinInvitedSpace, normalizeEmail } from "./accounts.js";
|
|
2
2
|
import { ForbiddenError, InvariantError, NotFoundError } from "./errors.js";
|
|
3
|
+
import { renderEmail } from "./mail-render.js";
|
|
3
4
|
import { deriveKeyPrefix } from "../../shared/logic/spaces.js";
|
|
4
5
|
// --- Droits ---------------------------------------------------------------------
|
|
5
6
|
/** Espace dont `userId` est membre ; un non-membre reçoit la même réponse qu'un espace inexistant. */
|
|
@@ -151,12 +152,18 @@ async function sendInvitationEmail(deps, to, inviter, space, link) {
|
|
|
151
152
|
};
|
|
152
153
|
}
|
|
153
154
|
const url = `${base}/${link.path}`;
|
|
154
|
-
const
|
|
155
|
-
|
|
156
|
-
subject: `${
|
|
157
|
-
|
|
158
|
-
|
|
155
|
+
const inviterName = inviter.displayName ?? inviter.email;
|
|
156
|
+
const message = renderEmail({
|
|
157
|
+
subject: `${inviterName} vous invite dans « ${space.name} »`,
|
|
158
|
+
space: space.name,
|
|
159
|
+
blocks: [
|
|
160
|
+
{ type: "paragraph", content: [inviterName, " vous invite à rejoindre l'espace « ", { strong: space.name }, " » sur mcp-organizer."] },
|
|
161
|
+
{ type: "paragraph", content: [`Pour créer votre compte, ouvrez ce lien, valable jusqu'au ${new Date(link.expiresAt).toLocaleDateString("fr-FR")}.`] },
|
|
162
|
+
],
|
|
163
|
+
action: { label: "Créer mon compte", url },
|
|
164
|
+
showActionUrl: true,
|
|
159
165
|
});
|
|
166
|
+
const outcome = await deps.mailer.send({ to, ...message });
|
|
160
167
|
return outcome.sent ? { emailSent: true, reason: null } : { emailSent: false, reason: outcome.reason };
|
|
161
168
|
}
|
|
162
169
|
/**
|
package/dist/src/gui-api.js
CHANGED
|
@@ -396,14 +396,14 @@ route("PATCH", "/requests/:requestId", (ctx, { user, request, params }) => ({
|
|
|
396
396
|
route("POST", "/requests/:requestId/cancel", (ctx, { user, params }) => ({ body: cancelRequest(ctx.store, user.id, params.requestId) }));
|
|
397
397
|
route("POST", "/requests/:requestId/stop", (ctx, { user, params }) => ({ body: stopRequest(ctx.store, user.id, params.requestId, ctx.runner.stopSession) }));
|
|
398
398
|
route("POST", "/requests/:requestId/relaunch", (ctx, { user, params }) => ({ body: relaunchRequest(ctx.store, user.id, params.requestId) }));
|
|
399
|
-
route("POST", "/requests/:requestId/undo", (ctx, { user, params }) => ({ body: undoRequest(ctx.store, user.id, params.requestId) }));
|
|
399
|
+
route("POST", "/requests/:requestId/undo", (ctx, { user, params }) => ({ body: undoRequest(ctx.store, ctx.attachments, user.id, params.requestId) }));
|
|
400
400
|
route("POST", "/requests/:requestId/suites", (ctx, { user, request, params }) => ({
|
|
401
401
|
body: createSuite(ctx.store, user.id, params.requestId, parseBody(CreateSuiteSchema, request.body).text),
|
|
402
402
|
}));
|
|
403
403
|
route("PUT", "/follow-ups/:followUpId", (ctx, { user, request, params }) => ({
|
|
404
404
|
body: setFollowUpDone(ctx.store, user.id, params.followUpId, parseBody(SetFollowUpDoneSchema, request.body).done),
|
|
405
405
|
}));
|
|
406
|
-
route("POST", "/agent-actions/:actionId/undo", (ctx, { user, params }) => ({ body: undoAction(ctx.store, user.id, params.actionId) }));
|
|
406
|
+
route("POST", "/agent-actions/:actionId/undo", (ctx, { user, params }) => ({ body: undoAction(ctx.store, ctx.attachments, user.id, params.actionId) }));
|
|
407
407
|
route("GET", "/tasks/:taskId/history", (ctx, { user, params }) => ({ body: listTaskHistory(ctx.store, user.id, params.taskId) }));
|
|
408
408
|
route("POST", "/tasks/:taskId/restore", (ctx, { user, params }) => ({ body: restoreDeletedTask(ctx.store, user.id, params.taskId) }));
|
|
409
409
|
route("GET", "/spaces/:spaceId/history", (ctx, { user, request, params }) => {
|
package/dist/src/mcp/client.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { z } from "zod";
|
|
2
|
-
import { type AgentEnvelope, type WaitRequestsData } from "../../shared/schemas/agent-tools.schema.js";
|
|
3
|
-
import type
|
|
2
|
+
import { type AgentEnvelope, type AgentImageContent, type WaitRequestsData } from "../../shared/schemas/agent-tools.schema.js";
|
|
3
|
+
import { type ToolHttpRequest } from "./tools.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`.
|
|
@@ -20,8 +20,11 @@ export interface SiteConnection {
|
|
|
20
20
|
export declare class OrganizerSiteClient {
|
|
21
21
|
private readonly connection;
|
|
22
22
|
constructor(connection: SiteConnection);
|
|
23
|
-
/** Exécute la requête d'un outil et renvoie le texte rédigé pour l'agent. */
|
|
24
|
-
call(request: ToolHttpRequest): Promise<
|
|
23
|
+
/** Exécute la requête d'un outil et renvoie le texte rédigé pour l'agent, avec les images à lui montrer. */
|
|
24
|
+
call(request: ToolHttpRequest): Promise<{
|
|
25
|
+
text: string;
|
|
26
|
+
images: AgentImageContent[];
|
|
27
|
+
}>;
|
|
25
28
|
/**
|
|
26
29
|
* Attente longue des demandes qui passent en attente (`GET requests/wait`) ;
|
|
27
30
|
* le délai de l'appel couvre la durée de l'attente.
|
package/dist/src/mcp/client.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { AgentEnvelopeSchema, AgentErrorSchema, WaitRequestsDataSchema } from "../../shared/schemas/agent-tools.schema.js";
|
|
2
|
+
import { ToolArgumentError } from "./tools.js";
|
|
3
|
+
import { LocalFileError, readLocalUpload } from "./upload.js";
|
|
2
4
|
/**
|
|
3
5
|
* Client HTTP de l'API agent du site : seul point de sortie réseau du mode
|
|
4
6
|
* MCP. Chaque appel porte le jeton dans `Authorization: Bearer`.
|
|
@@ -26,14 +28,38 @@ function redirectTarget(response, requestUrl) {
|
|
|
26
28
|
return location;
|
|
27
29
|
}
|
|
28
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Formulaire multipart d'un envoi de fichier : le fichier local dans le champ
|
|
33
|
+
* `file`, chaque autre argument dans un champ texte.
|
|
34
|
+
*/
|
|
35
|
+
async function uploadForm(file, fields) {
|
|
36
|
+
let upload;
|
|
37
|
+
try {
|
|
38
|
+
upload = await readLocalUpload(file.path, file.name);
|
|
39
|
+
}
|
|
40
|
+
catch (err) {
|
|
41
|
+
if (err instanceof LocalFileError)
|
|
42
|
+
throw new ToolArgumentError(err.message);
|
|
43
|
+
throw err;
|
|
44
|
+
}
|
|
45
|
+
const form = new FormData();
|
|
46
|
+
for (const [name, value] of Object.entries(fields)) {
|
|
47
|
+
if (value === undefined || value === null)
|
|
48
|
+
continue;
|
|
49
|
+
form.set(name, typeof value === "string" ? value : JSON.stringify(value));
|
|
50
|
+
}
|
|
51
|
+
form.set("file", new Blob([new Uint8Array(upload.content)], { type: upload.mime }), upload.filename);
|
|
52
|
+
return form;
|
|
53
|
+
}
|
|
29
54
|
export class OrganizerSiteClient {
|
|
30
55
|
connection;
|
|
31
56
|
constructor(connection) {
|
|
32
57
|
this.connection = connection;
|
|
33
58
|
}
|
|
34
|
-
/** Exécute la requête d'un outil et renvoie le texte rédigé pour l'agent. */
|
|
59
|
+
/** Exécute la requête d'un outil et renvoie le texte rédigé pour l'agent, avec les images à lui montrer. */
|
|
35
60
|
async call(request) {
|
|
36
|
-
|
|
61
|
+
const envelope = await this.envelope(request);
|
|
62
|
+
return { text: envelope.text, images: envelope.images ?? [] };
|
|
37
63
|
}
|
|
38
64
|
/**
|
|
39
65
|
* Attente longue des demandes qui passent en attente (`GET requests/wait`) ;
|
|
@@ -61,6 +87,7 @@ export class OrganizerSiteClient {
|
|
|
61
87
|
const url = new URL(`${this.connection.url}/api/agent/${request.path}`);
|
|
62
88
|
for (const [name, value] of Object.entries(request.query))
|
|
63
89
|
url.searchParams.set(name, value);
|
|
90
|
+
const body = request.file ? await uploadForm(request.file, request.body ?? {}) : request.body === undefined ? undefined : JSON.stringify(request.body);
|
|
64
91
|
let response;
|
|
65
92
|
try {
|
|
66
93
|
response = await fetch(url, {
|
|
@@ -68,9 +95,9 @@ export class OrganizerSiteClient {
|
|
|
68
95
|
headers: {
|
|
69
96
|
authorization: `Bearer ${this.connection.token}`,
|
|
70
97
|
accept: "application/json",
|
|
71
|
-
...(
|
|
98
|
+
...(typeof body === "string" ? { "content-type": "application/json" } : {}),
|
|
72
99
|
},
|
|
73
|
-
body
|
|
100
|
+
body,
|
|
74
101
|
// Une redirection n'est jamais suivie : le jeton ne part que vers ORGANIZER_URL.
|
|
75
102
|
redirect: "manual",
|
|
76
103
|
signal: AbortSignal.timeout(timeoutMs),
|
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. You cannot open the image: rely on the surrounding text, and ask its author in a comment or your reply when you need to know what it shows.\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); you cannot read PDF files or images, only their name and description: ask a member for a text, markdown or Word version when you need their content.\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_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, 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; 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.";
|
|
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,9 +16,9 @@ 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.
|
|
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; 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.
|
|
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
|
-
- 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)
|
|
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.
|
|
23
23
|
- 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.
|
|
24
24
|
- 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.
|
|
@@ -30,8 +30,8 @@ Concepts:
|
|
|
30
30
|
Work loop, when the user asks you to process the queue:
|
|
31
31
|
1. list_requests to see the pending requests of your space.
|
|
32
32
|
2. 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.
|
|
33
|
-
3. Read what you need with get_task and search_tasks, 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.
|
|
34
|
-
4. Act with create_task, update_task, set_assignees, set_tags, edit_checklist, edit_questions, add_comment, 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 — always passing the request_id. Each write is one undoable action of the batch.
|
|
33
|
+
3. 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.
|
|
34
|
+
4. 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 — always passing the request_id. Each write is one undoable action of the batch.
|
|
35
35
|
5. 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.
|
|
36
36
|
When the queue is empty, tell the user.
|
|
37
37
|
|
|
@@ -117,8 +117,8 @@ export async function runMcpMode() {
|
|
|
117
117
|
if (!tool)
|
|
118
118
|
return errorResult(`Unknown tool "${name}". Call tools/list to get the available tools.`);
|
|
119
119
|
try {
|
|
120
|
-
const text = await client.call(toolHttpRequest(tool, (args ?? {})));
|
|
121
|
-
return { content: [{ type: "text", text }] };
|
|
120
|
+
const { text, images } = await client.call(toolHttpRequest(tool, (args ?? {})));
|
|
121
|
+
return { content: [{ type: "text", text }, ...images.map((image) => ({ type: "image", data: image.data, mimeType: image.mimeType }))] };
|
|
122
122
|
}
|
|
123
123
|
catch (error) {
|
|
124
124
|
if (!(error instanceof SiteError) && !(error instanceof ToolArgumentError))
|
package/dist/src/mcp/tools.d.ts
CHANGED
|
@@ -22,6 +22,12 @@ export interface AgentTool {
|
|
|
22
22
|
* encodé ; les autres arguments forment la requête d'un GET, le corps JSON sinon.
|
|
23
23
|
*/
|
|
24
24
|
path: string;
|
|
25
|
+
/**
|
|
26
|
+
* Envoi d'un fichier local : l'argument `path` désigne le fichier, que le
|
|
27
|
+
* mode MCP lit et envoie en multipart avec les autres arguments ; `name`
|
|
28
|
+
* remplace son nom.
|
|
29
|
+
*/
|
|
30
|
+
upload?: true;
|
|
25
31
|
}
|
|
26
32
|
/** Requête HTTP d'un appel d'outil. */
|
|
27
33
|
export interface ToolHttpRequest {
|
|
@@ -30,6 +36,11 @@ export interface ToolHttpRequest {
|
|
|
30
36
|
path: string;
|
|
31
37
|
query: Record<string, string>;
|
|
32
38
|
body: Record<string, unknown> | undefined;
|
|
39
|
+
/** Fichier local à envoyer en multipart (champ `file`), pour un outil d'envoi. */
|
|
40
|
+
file?: {
|
|
41
|
+
path: string;
|
|
42
|
+
name?: string;
|
|
43
|
+
};
|
|
33
44
|
}
|
|
34
45
|
/** Argument d'appel d'outil inutilisable pour former la requête. */
|
|
35
46
|
export declare class ToolArgumentError extends Error {
|
package/dist/src/mcp/tools.js
CHANGED
|
@@ -81,7 +81,7 @@ export const AGENT_TOOLS = [
|
|
|
81
81
|
path: "requests/{request_id}/claim",
|
|
82
82
|
definition: {
|
|
83
83
|
name: "claim_request",
|
|
84
|
-
description: "Claim a pending request before working on it: it becomes processing for your token only (no other agent can take it or act for it) and you get its full context — text, author, context task or idea, for a message the previous exchanges of its author (their requests and your replies), the task tree of your space with keys, statuses, priorities and assignees, its members and recent ideas. Pass this request_id to every write tool while you process it.",
|
|
84
|
+
description: "Claim a pending request before working on it: it becomes processing for your token only (no other agent can take it or act for it) and you get its full context — text, author, context task or idea, for a message the previous exchanges of its author (their requests and your replies), the context task's attachments (open them with get_attachment), the task tree of your space with keys, statuses, priorities and assignees, its members and recent ideas. Pass this request_id to every write tool while you process it.",
|
|
85
85
|
inputSchema: {
|
|
86
86
|
type: "object",
|
|
87
87
|
properties: { request_id: { type: "string", description: "Id of a pending request, from list_requests." } },
|
|
@@ -104,7 +104,7 @@ export const AGENT_TOOLS = [
|
|
|
104
104
|
path: "tasks/{task}",
|
|
105
105
|
definition: {
|
|
106
106
|
name: "get_task",
|
|
107
|
-
description: "Read one task of your space in detail: fields, parents, assignees, tags, description, questions with their options and the members' answers (ids needed by edit_questions), checklist items or test checkpoints (with their ids, needed by edit_checklist), sub-tasks, recent comments and attachments. Use it before modifying a task.",
|
|
107
|
+
description: "Read one task of your space in detail: fields, parents, assignees, tags, description, questions with their options and the members' answers (ids needed by edit_questions), checklist items or test checkpoints (with their ids, needed by edit_checklist), sub-tasks, recent comments and attachments with their id (open them with get_attachment). Use it before modifying a task.",
|
|
108
108
|
inputSchema: { type: "object", properties: { task: TASK_REF }, required: ["task"], additionalProperties: false },
|
|
109
109
|
},
|
|
110
110
|
},
|
|
@@ -163,7 +163,7 @@ export const AGENT_TOOLS = [
|
|
|
163
163
|
path: "documents",
|
|
164
164
|
definition: {
|
|
165
165
|
name: "list_documents",
|
|
166
|
-
description: "List the reference documents of your space: files the members upload (reports, specifications, exports…) so you know the real state of their project. Each one comes with its id, file name, description, format, size
|
|
166
|
+
description: "List the reference documents of your space: files the members upload (reports, specifications, exports…) so you know the real state of their project. Each one comes with its id, file name, description, format, size and version; read one with get_document.",
|
|
167
167
|
inputSchema: { type: "object", properties: {}, additionalProperties: false },
|
|
168
168
|
},
|
|
169
169
|
},
|
|
@@ -172,7 +172,7 @@ export const AGENT_TOOLS = [
|
|
|
172
172
|
path: "documents/{document}",
|
|
173
173
|
definition: {
|
|
174
174
|
name: "get_document",
|
|
175
|
-
description: "Read a reference document of your space. Text files (txt, md, csv, json, yaml, xml…) come as they are
|
|
175
|
+
description: "Read a reference document of your space. Text files (txt, md, csv, json, yaml, xml…) come as they are, Word files (.docx) and PDF files as their extracted text, in parts of 20,000 characters: the result says how many parts there are. An image comes as the image itself, which you see (reduced when it exceeds the limits of the Claude API). A PDF without a text layer (a scan) is reported as such. Read a document when it helps the request you process, for example to align tasks and priorities with a report on the project.",
|
|
176
176
|
inputSchema: {
|
|
177
177
|
type: "object",
|
|
178
178
|
properties: {
|
|
@@ -184,6 +184,23 @@ export const AGENT_TOOLS = [
|
|
|
184
184
|
},
|
|
185
185
|
},
|
|
186
186
|
},
|
|
187
|
+
{
|
|
188
|
+
method: "GET",
|
|
189
|
+
path: "attachments/{attachment}",
|
|
190
|
+
definition: {
|
|
191
|
+
name: "get_attachment",
|
|
192
|
+
description: "Open an attachment of a task of your space. An image comes as the image itself, which you see (reduced when it exceeds the limits of the Claude API); a PDF file, a text file or a Word file (.docx) comes as its extracted text, in parts of 20,000 characters. A PDF without a text layer (a scan) is reported as such. Take the id from get_task or claim_request, or from a reference  in a description, a comment or a checkpoint comment. Open the attachments that matter for the request, for example a screenshot of a failed checkpoint or one cited in a comment mentioning @agent.",
|
|
193
|
+
inputSchema: {
|
|
194
|
+
type: "object",
|
|
195
|
+
properties: {
|
|
196
|
+
attachment: { type: "string", description: "Id of an attachment of a task of your space." },
|
|
197
|
+
part: { type: "integer", minimum: 1, description: "Part of the text to read, from 1. Default: 1." },
|
|
198
|
+
},
|
|
199
|
+
required: ["attachment"],
|
|
200
|
+
additionalProperties: false,
|
|
201
|
+
},
|
|
202
|
+
},
|
|
203
|
+
},
|
|
187
204
|
{
|
|
188
205
|
method: "GET",
|
|
189
206
|
path: "history",
|
|
@@ -399,6 +416,32 @@ export const AGENT_TOOLS = [
|
|
|
399
416
|
},
|
|
400
417
|
},
|
|
401
418
|
},
|
|
419
|
+
{
|
|
420
|
+
method: "POST",
|
|
421
|
+
path: "tasks/{task}/attachments",
|
|
422
|
+
upload: true,
|
|
423
|
+
definition: {
|
|
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 the machine where you run: this MCP server reads it and uploads it to the site itself, 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
|
+
inputSchema: {
|
|
427
|
+
type: "object",
|
|
428
|
+
properties: {
|
|
429
|
+
request_id: REQUEST_ID,
|
|
430
|
+
task: TASK_REF,
|
|
431
|
+
path: { type: "string", description: "Absolute path of a regular file on the machine where you run (e.g. C:\\Users\\me\\capture.png or /tmp/report.pdf)." },
|
|
432
|
+
name: { type: "string", maxLength: 255, description: "File name shown to the members. Default: the name of the file." },
|
|
433
|
+
comment: {
|
|
434
|
+
type: "string",
|
|
435
|
+
maxLength: MAX_COMMENT_LENGTH,
|
|
436
|
+
description: "Text of a comment to post on the task, in the language of the space; the reference to the file is added after it. Omit for no comment.",
|
|
437
|
+
},
|
|
438
|
+
append_to_description: { type: "boolean", description: "Add the reference to the file at the end of the task description. Default: false." },
|
|
439
|
+
},
|
|
440
|
+
required: ["task", "path"],
|
|
441
|
+
additionalProperties: false,
|
|
442
|
+
},
|
|
443
|
+
},
|
|
444
|
+
},
|
|
402
445
|
{
|
|
403
446
|
method: "POST",
|
|
404
447
|
path: "ideas",
|
|
@@ -642,6 +685,14 @@ export function toolHttpRequest(tool, args) {
|
|
|
642
685
|
delete rest[name];
|
|
643
686
|
return encodeURIComponent(value.trim());
|
|
644
687
|
});
|
|
688
|
+
if (tool.upload) {
|
|
689
|
+
const { path: filePath, name, ...fields } = rest;
|
|
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 }) } };
|
|
695
|
+
}
|
|
645
696
|
if (tool.method !== "GET")
|
|
646
697
|
return { method: tool.method, path, query: {}, body: rest };
|
|
647
698
|
const query = {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fichier local envoyé par l'agent comme pièce jointe : le mode MCP le lit
|
|
3
|
+
* sur la machine où il tourne, avec les droits de l'utilisateur qui l'a
|
|
4
|
+
* lancé, et l'envoie au site. Son contenu ne passe jamais par l'agent.
|
|
5
|
+
*/
|
|
6
|
+
/** Fichier local lu pour l'envoi. */
|
|
7
|
+
export interface LocalUpload {
|
|
8
|
+
filename: string;
|
|
9
|
+
mime: string;
|
|
10
|
+
content: Buffer;
|
|
11
|
+
}
|
|
12
|
+
/** Fichier local refusé : chemin relatif, introuvable, dossier, fichier spécial ou trop lourd. */
|
|
13
|
+
export declare class LocalFileError extends Error {
|
|
14
|
+
constructor(message: string);
|
|
15
|
+
}
|
|
16
|
+
/** Type MIME d'un fichier d'après son extension ; `application/octet-stream` pour une extension inconnue. */
|
|
17
|
+
export declare function mimeOfFilename(filename: string): string;
|
|
18
|
+
/**
|
|
19
|
+
* Lit le fichier régulier désigné par le chemin absolu `filePath` ; `name`
|
|
20
|
+
* remplace son nom. Un lien symbolique est suivi jusqu'au fichier qu'il désigne.
|
|
21
|
+
*/
|
|
22
|
+
export declare function readLocalUpload(filePath: string, name?: string): Promise<LocalUpload>;
|