@imenam/mcp-organizer 1.0.34 → 1.0.36

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.
Files changed (45) hide show
  1. package/README.md +34 -19
  2. package/dist/shared/schemas/agent-api.schema.d.ts +18 -0
  3. package/dist/shared/schemas/agent-api.schema.js +12 -1
  4. package/dist/shared/schemas/agent-tools.schema.d.ts +15 -1
  5. package/dist/shared/schemas/agent-tools.schema.js +22 -1
  6. package/dist/shared/schemas/broadcast-api.schema.d.ts +127 -0
  7. package/dist/shared/schemas/broadcast-api.schema.js +68 -0
  8. package/dist/shared/schemas/entities.schema.d.ts +32 -0
  9. package/dist/shared/schemas/entities.schema.js +26 -0
  10. package/dist/shared/schemas/notifications-api.schema.d.ts +8 -0
  11. package/dist/shared/schemas/notifications-api.schema.js +4 -1
  12. package/dist/shared/schemas/tasks-api.schema.d.ts +9 -1
  13. package/dist/shared/schemas/tasks-api.schema.js +5 -2
  14. package/dist/src/agent-api/attachments.js +85 -50
  15. package/dist/src/agent-api/requests.js +2 -0
  16. package/dist/src/cli/backup.js +4 -3
  17. package/dist/src/core/agent.d.ts +3 -1
  18. package/dist/src/core/agent.js +18 -2
  19. package/dist/src/core/broadcast.d.ts +40 -0
  20. package/dist/src/core/broadcast.js +92 -0
  21. package/dist/src/core/mail-render.d.ts +5 -0
  22. package/dist/src/core/mail-render.js +4 -0
  23. package/dist/src/core/mail.d.ts +2 -0
  24. package/dist/src/core/mail.js +5 -3
  25. package/dist/src/core/migrations.js +38 -0
  26. package/dist/src/core/notifications.js +2 -1
  27. package/dist/src/core/request-attachments.d.ts +33 -0
  28. package/dist/src/core/request-attachments.js +100 -0
  29. package/dist/src/core/requests.d.ts +14 -2
  30. package/dist/src/core/requests.js +67 -5
  31. package/dist/src/core/spaces.js +1 -1
  32. package/dist/src/core/store.d.ts +40 -2
  33. package/dist/src/core/store.js +127 -6
  34. package/dist/src/core/tasks.d.ts +2 -2
  35. package/dist/src/core/tasks.js +13 -3
  36. package/dist/src/gui-api.js +48 -2
  37. package/dist/src/mcp/start.d.ts +1 -1
  38. package/dist/src/mcp/start.js +4 -2
  39. package/dist/src/mcp/tools.js +27 -3
  40. package/gui/dist/assets/index-BtnMWo0A.css +1 -0
  41. package/gui/dist/assets/index-BwBO4poI.js +121 -0
  42. package/gui/dist/index.html +2 -2
  43. package/package.json +1 -1
  44. package/gui/dist/assets/index-CLW9PAC7.js +0 -104
  45. package/gui/dist/assets/index-kNRY_0Gs.css +0 -1
@@ -1,8 +1,9 @@
1
1
  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
- 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 EmailDigestMinutes, type SidebarMode, type TaskOpenMode, type User, type UserSettings, type NotificationPreferences, type SpaceNotificationSettings } from "../../shared/schemas/entities.schema.js";
4
+ import { type AccessLink, type AgentAction, type AgentInstructions, type AgentRequest, type AgentToken, type Attachment, type RequestAttachment, 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 EmailDigestMinutes, type SidebarMode, type TaskLinkLabel, type TaskOpenMode, type User, type UserSettings, type NotificationPreferences, type SpaceNotificationSettings } from "../../shared/schemas/entities.schema.js";
5
5
  import { type ClaudeConnection, type NewRunnerSession, type RunnerSessionRecord, type RunnerSettings } from "../../shared/schemas/admin-api.schema.js";
6
+ import { type BroadcastRecord, type NewBroadcast } from "../../shared/schemas/broadcast-api.schema.js";
6
7
  /**
7
8
  * Auteur d'une mutation : un utilisateur de la GUI, ou un agent qui agit avec
8
9
  * son jeton, avec les droits du propriétaire du jeton, pour une demande que ce
@@ -66,6 +67,8 @@ export declare class Store {
66
67
  getRunnerSettings(): RunnerSettings;
67
68
  /** Connexion de Claude enregistrée, ou null tant qu'aucun token ne l'est. */
68
69
  findClaudeConnection(): ClaudeConnection | null;
70
+ /** Les `limit` derniers e-mails envoyés aux utilisateurs, du plus récent au plus ancien. */
71
+ listBroadcasts(limit: number): BroadcastRecord[];
69
72
  /** Sessions du runner commencées depuis `since`, de la plus récente à la plus ancienne. */
70
73
  listRunnerSessionsSince(since: string): RunnerSessionRecord[];
71
74
  /** Instructions de l'agent propres à un espace, ou celles du site quand `spaceId` est null ; null s'il n'y en a pas. */
@@ -190,6 +193,15 @@ export declare class Store {
190
193
  listAttachmentsInSubtree(taskId: string): Attachment[];
191
194
  /** Pièces jointes des tâches d'un espace. */
192
195
  listAttachmentsInSpace(spaceId: string): Attachment[];
196
+ findRequestAttachment(id: string): RequestAttachment | null;
197
+ /** Images d'un espace parmi `ids`, dans l'ordre de `ids` ; les identifiants inconnus ou d'un autre espace sont ignorés. */
198
+ listRequestAttachmentsOf(spaceId: string, ids: readonly string[]): RequestAttachment[];
199
+ /** Images rattachées à une demande, de la plus ancienne à la plus récente. */
200
+ listAttachmentsOfRequest(requestId: string): RequestAttachment[];
201
+ /** Images des demandes d'un espace, brouillons compris. */
202
+ listRequestAttachmentsInSpace(spaceId: string): RequestAttachment[];
203
+ /** Images déposées avant `before` et rattachées à aucune demande. */
204
+ listDraftRequestAttachmentsBefore(before: string): RequestAttachment[];
193
205
  findIdea(id: string): Idea | null;
194
206
  getIdea(id: string): Idea;
195
207
  listIdeas(spaceId: string): Idea[];
@@ -245,7 +257,7 @@ export declare class Store {
245
257
  getFollowUp(id: string): FollowUp;
246
258
  /** Nombre de demandes en attente d'un espace. */
247
259
  countPendingRequestsOfSpace(spaceId: string): number;
248
- /** Nombre de demandes d'un espace qui attendent l'utilisateur : traitées avec un point à régler ouvert, ou en échec. */
260
+ /** Nombre de demandes d'un espace qui attendent l'utilisateur : traitées avec un point à régler ouvert, ou en échec et pas ignorées. */
249
261
  countWaitingRequestsOfSpace(spaceId: string): number;
250
262
  findAgentAction(id: string): AgentAction | null;
251
263
  getAgentAction(id: string): AgentAction;
@@ -380,6 +392,7 @@ export interface UpdateUserSettingsInput {
380
392
  emailDigestMinutes?: EmailDigestMinutes | null;
381
393
  sidebarMode?: SidebarMode;
382
394
  taskOpenMode?: TaskOpenMode;
395
+ taskLinkLabel?: TaskLinkLabel;
383
396
  }
384
397
  /** Issue de l'envoi de l'e-mail d'une notification. */
385
398
  export type NotificationEmailOutcome = {
@@ -743,6 +756,23 @@ export declare class Mutation {
743
756
  }): Attachment;
744
757
  /** Supprime l'enregistrement d'une pièce jointe et le renvoie ; son fichier reste à effacer. */
745
758
  deleteAttachment(id: string): Attachment;
759
+ /** Enregistre une image de demande, encore rattachée à aucune demande, dont le fichier est déjà écrit sous `storagePath`. */
760
+ createRequestAttachment(input: {
761
+ id: string;
762
+ spaceId: string;
763
+ filename: string;
764
+ mime: string;
765
+ size: number;
766
+ storagePath: string;
767
+ }): RequestAttachment;
768
+ /**
769
+ * Rattache à la demande `requestId` celles des images `ids` que l'utilisateur
770
+ * acteur a déposées dans l'espace de la demande et qui ne sont rattachées à
771
+ * aucune demande.
772
+ */
773
+ linkRequestAttachments(requestId: string, ids: readonly string[]): void;
774
+ /** Supprime l'enregistrement d'une image de demande et le renvoie ; son fichier reste à effacer. */
775
+ deleteRequestAttachment(id: string): RequestAttachment;
746
776
  /** Profondeur d'un enfant de `parent`, qui doit être dans l'espace `spaceId` et laisser place à un niveau de plus. */
747
777
  private childDepth;
748
778
  /** Vrai si `taskId` est `rootId` ou l'une de ses sous-tâches. */
@@ -796,6 +826,12 @@ export declare class Mutation {
796
826
  stopAgentRequest(id: string, reason: string): AgentRequest;
797
827
  /** Remet en attente une demande stoppée : un agent pourra la reprendre ; les actions déjà faites restent dans son lot. */
798
828
  relaunchAgentRequest(id: string): AgentRequest;
829
+ /**
830
+ * Retire de la liste « En attente » une demande en échec, au nom de
831
+ * l'utilisateur acteur, ou l'y remet (`dismissed` faux). Ignorer une
832
+ * demande déjà ignorée garde qui l'a ignorée.
833
+ */
834
+ setAgentRequestDismissed(id: string, dismissed: boolean): AgentRequest;
799
835
  /** Termine en échec une demande `processing` dont l'agent a été arrêté, avec la raison montrée à son auteur. */
800
836
  abortAgentRequest(id: string, reason: string): AgentRequest;
801
837
  /** Demande et jeton de l'agent acteur. */
@@ -903,6 +939,8 @@ export declare class Mutation {
903
939
  setClaudeConnection(tokenCipher: string, tokenHint: string): ClaudeConnection;
904
940
  /** Marque le token de Claude comme refusé par Claude, avec le message de Claude Code. */
905
941
  markClaudeTokenRefused(reason: string): void;
942
+ /** Enregistre un e-mail envoyé aux utilisateurs. */
943
+ recordBroadcast(record: NewBroadcast): void;
906
944
  /**
907
945
  * Enregistre le relevé d'une session du runner terminée, avec les auteurs des
908
946
  * demandes de son espace que le runner a prises entre son début et sa fin
@@ -5,8 +5,9 @@ import { newId } from "./ids.js";
5
5
  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
- import { PERSONAL_SPACE_EMOJI, SHARED_SPACE_EMOJIS, 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";
8
+ import { PERSONAL_SPACE_EMOJI, SHARED_SPACE_EMOJIS, AccessLinkSchema, AgentActionSchema, AgentInstructionsSchema, AgentTokenSchema, AgentRequestSchema, AttachmentSchema, RequestAttachmentSchema, 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
9
  import { ClaudeConnectionSchema, NewRunnerSessionSchema, RunnerSessionRecordSchema, RunnerSettingsSchema, } from "../../shared/schemas/admin-api.schema.js";
10
+ import { BroadcastRecordSchema, NewBroadcastSchema } from "../../shared/schemas/broadcast-api.schema.js";
10
11
  /** Valide `value` avec `schema` ; une donnée invalide est une erreur métier qui liste les champs fautifs. */
11
12
  function validate(schema, value, what) {
12
13
  const parsed = schema.safeParse(value);
@@ -87,6 +88,7 @@ function settingsFromRow(row) {
87
88
  emailDigestMinutes: row.email_digest_minutes,
88
89
  sidebarMode: row.sidebar_mode,
89
90
  taskOpenMode: row.task_open_mode,
91
+ taskLinkLabel: row.task_link_label,
90
92
  });
91
93
  }
92
94
  function timeSessionFromRow(row) {
@@ -268,6 +270,8 @@ function requestFromRow(row) {
268
270
  cancelledBy: row.cancelled_by,
269
271
  stoppedAt: row.stopped_at,
270
272
  stoppedBy: row.stopped_by,
273
+ dismissedAt: row.dismissed_at,
274
+ dismissedBy: row.dismissed_by,
271
275
  });
272
276
  }
273
277
  function followUpFromRow(row) {
@@ -407,6 +411,19 @@ function attachmentFromRow(row) {
407
411
  createdAt: row.created_at,
408
412
  });
409
413
  }
414
+ function requestAttachmentFromRow(row) {
415
+ return RequestAttachmentSchema.parse({
416
+ id: row.id,
417
+ spaceId: row.space_id,
418
+ requestId: row.request_id,
419
+ uploaderId: row.uploader_id,
420
+ filename: row.filename,
421
+ mime: row.mime,
422
+ size: row.size,
423
+ storagePath: row.storage_path,
424
+ createdAt: row.created_at,
425
+ });
426
+ }
410
427
  function checkpointFromRow(row) {
411
428
  return TestCheckpointSchema.parse({ id: row.id, taskId: row.task_id, text: row.text, position: row.position });
412
429
  }
@@ -534,6 +551,23 @@ export class Store {
534
551
  refusedReason: row.refused_reason,
535
552
  });
536
553
  }
554
+ /** Les `limit` derniers e-mails envoyés aux utilisateurs, du plus récent au plus ancien. */
555
+ listBroadcasts(limit) {
556
+ const rows = this.db
557
+ .prepare(`SELECT b.*, COALESCE(u.display_name, u.email) AS sender_name
558
+ FROM broadcast_emails b LEFT JOIN users u ON u.id = b.sent_by
559
+ ORDER BY b.sent_at DESC, b.id LIMIT ?`)
560
+ .all(limit);
561
+ return rows.map((row) => BroadcastRecordSchema.parse({
562
+ id: row.id,
563
+ subject: row.subject,
564
+ audience: row.audience,
565
+ sentAt: row.sent_at,
566
+ sentBy: row.sent_by ? { id: row.sent_by, name: row.sender_name } : null,
567
+ recipientCount: row.recipient_count,
568
+ failedCount: row.failed_count,
569
+ }));
570
+ }
537
571
  /** Sessions du runner commencées depuis `since`, de la plus récente à la plus ancienne. */
538
572
  listRunnerSessionsSince(since) {
539
573
  const rows = this.db.prepare("SELECT * FROM runner_sessions WHERE started_at >= ? ORDER BY started_at DESC, id").all(since);
@@ -925,6 +959,33 @@ export class Store {
925
959
  .all(spaceId);
926
960
  return rows.map(attachmentFromRow);
927
961
  }
962
+ // --- Images des demandes ---
963
+ findRequestAttachment(id) {
964
+ const row = this.db.prepare("SELECT * FROM request_attachments WHERE id = ?").get(id);
965
+ return row ? requestAttachmentFromRow(row) : null;
966
+ }
967
+ /** Images d'un espace parmi `ids`, dans l'ordre de `ids` ; les identifiants inconnus ou d'un autre espace sont ignorés. */
968
+ listRequestAttachmentsOf(spaceId, ids) {
969
+ return ids.flatMap((id) => {
970
+ const attachment = this.findRequestAttachment(id);
971
+ return attachment && attachment.spaceId === spaceId ? [attachment] : [];
972
+ });
973
+ }
974
+ /** Images rattachées à une demande, de la plus ancienne à la plus récente. */
975
+ listAttachmentsOfRequest(requestId) {
976
+ const rows = this.db.prepare("SELECT * FROM request_attachments WHERE request_id = ? ORDER BY created_at, id").all(requestId);
977
+ return rows.map(requestAttachmentFromRow);
978
+ }
979
+ /** Images des demandes d'un espace, brouillons compris. */
980
+ listRequestAttachmentsInSpace(spaceId) {
981
+ const rows = this.db.prepare("SELECT * FROM request_attachments WHERE space_id = ?").all(spaceId);
982
+ return rows.map(requestAttachmentFromRow);
983
+ }
984
+ /** Images déposées avant `before` et rattachées à aucune demande. */
985
+ listDraftRequestAttachmentsBefore(before) {
986
+ const rows = this.db.prepare("SELECT * FROM request_attachments WHERE request_id IS NULL AND created_at < ?").all(before);
987
+ return rows.map(requestAttachmentFromRow);
988
+ }
928
989
  // --- Idées ---
929
990
  findIdea(id) {
930
991
  const row = this.db.prepare("SELECT * FROM ideas WHERE id = ?").get(id);
@@ -1107,10 +1168,10 @@ export class Store {
1107
1168
  const row = this.db.prepare("SELECT COUNT(*) AS n FROM agent_requests WHERE status = 'pending' AND target_space_id = ?").get(spaceId);
1108
1169
  return row.n;
1109
1170
  }
1110
- /** Nombre de demandes d'un espace qui attendent l'utilisateur : traitées avec un point à régler ouvert, ou en échec. */
1171
+ /** Nombre de demandes d'un espace qui attendent l'utilisateur : traitées avec un point à régler ouvert, ou en échec et pas ignorées. */
1111
1172
  countWaitingRequestsOfSpace(spaceId) {
1112
1173
  const row = this.db
1113
- .prepare(`SELECT COUNT(*) AS n FROM agent_requests r WHERE r.target_space_id = ? AND (r.status = 'failed'
1174
+ .prepare(`SELECT COUNT(*) AS n FROM agent_requests r WHERE r.target_space_id = ? AND ((r.status = 'failed' AND r.dismissed_at IS NULL)
1114
1175
  OR (r.status = 'done' AND EXISTS (SELECT 1 FROM follow_ups f WHERE f.request_id = r.id AND f.done_at IS NULL)))`)
1115
1176
  .get(spaceId);
1116
1177
  return row.n;
@@ -2408,6 +2469,34 @@ export class Mutation {
2408
2469
  this.touch("attachment", id, this.store.getTask(attachment.taskId).spaceId, null, attachment.taskId);
2409
2470
  return attachment;
2410
2471
  }
2472
+ /** Enregistre une image de demande, encore rattachée à aucune demande, dont le fichier est déjà écrit sous `storagePath`. */
2473
+ createRequestAttachment(input) {
2474
+ this.store.getSpace(input.spaceId);
2475
+ const attachment = validate(RequestAttachmentSchema, { ...input, requestId: null, uploaderId: this.actingUserId, createdAt: this.now }, "request attachment");
2476
+ this.db
2477
+ .prepare("INSERT INTO request_attachments (id, space_id, request_id, uploader_id, filename, mime, size, storage_path, created_at) VALUES (?, ?, NULL, ?, ?, ?, ?, ?, ?)")
2478
+ .run(attachment.id, attachment.spaceId, attachment.uploaderId, attachment.filename, attachment.mime, attachment.size, attachment.storagePath, attachment.createdAt);
2479
+ return attachment;
2480
+ }
2481
+ /**
2482
+ * Rattache à la demande `requestId` celles des images `ids` que l'utilisateur
2483
+ * acteur a déposées dans l'espace de la demande et qui ne sont rattachées à
2484
+ * aucune demande.
2485
+ */
2486
+ linkRequestAttachments(requestId, ids) {
2487
+ const request = this.store.getAgentRequest(requestId);
2488
+ const link = this.db.prepare("UPDATE request_attachments SET request_id = ? WHERE id = ? AND space_id = ? AND uploader_id = ? AND request_id IS NULL");
2489
+ for (const id of ids)
2490
+ link.run(requestId, id, request.targetSpaceId, this.actingUserId);
2491
+ }
2492
+ /** Supprime l'enregistrement d'une image de demande et le renvoie ; son fichier reste à effacer. */
2493
+ deleteRequestAttachment(id) {
2494
+ const attachment = this.store.findRequestAttachment(id);
2495
+ if (!attachment)
2496
+ throw new NotFoundError(`Request attachment ${id} not found.`);
2497
+ this.db.prepare("DELETE FROM request_attachments WHERE id = ?").run(id);
2498
+ return attachment;
2499
+ }
2411
2500
  /** Profondeur d'un enfant de `parent`, qui doit être dans l'espace `spaceId` et laisser place à un niveau de plus. */
2412
2501
  childDepth(parent, spaceId) {
2413
2502
  if (parent.spaceId !== spaceId)
@@ -2658,6 +2747,8 @@ export class Mutation {
2658
2747
  cancelledBy: null,
2659
2748
  stoppedAt: null,
2660
2749
  stoppedBy: null,
2750
+ dismissedAt: null,
2751
+ dismissedBy: null,
2661
2752
  }, "request");
2662
2753
  this.store.getSpace(request.targetSpaceId);
2663
2754
  this.db
@@ -2732,7 +2823,7 @@ export class Mutation {
2732
2823
  throw new InvariantError(`Request ${id} is ${current.status}: only a stopped request can be relaunched.`);
2733
2824
  this.db
2734
2825
  .prepare(`UPDATE agent_requests SET status = 'pending', claimed_at = NULL, claimed_by_token_id = NULL, completed_at = NULL, failure_reason = NULL,
2735
- stopped_at = NULL, stopped_by = NULL, updated_at = ? WHERE id = ?`)
2826
+ stopped_at = NULL, stopped_by = NULL, dismissed_at = NULL, dismissed_by = NULL, updated_at = ? WHERE id = ?`)
2736
2827
  .run(this.now, id);
2737
2828
  this.db.prepare("DELETE FROM follow_ups WHERE request_id = ?").run(id);
2738
2829
  const relaunched = this.store.getAgentRequest(id);
@@ -2740,6 +2831,26 @@ export class Mutation {
2740
2831
  this.touchRequest(relaunched);
2741
2832
  return relaunched;
2742
2833
  }
2834
+ /**
2835
+ * Retire de la liste « En attente » une demande en échec, au nom de
2836
+ * l'utilisateur acteur, ou l'y remet (`dismissed` faux). Ignorer une
2837
+ * demande déjà ignorée garde qui l'a ignorée.
2838
+ */
2839
+ setAgentRequestDismissed(id, dismissed) {
2840
+ if (this.actor.type !== "user")
2841
+ throw new InvariantError("Only a user can dismiss a request.");
2842
+ const current = this.store.getAgentRequest(id);
2843
+ if (current.status !== "failed")
2844
+ throw new InvariantError(`Request ${id} is ${current.status}: only a failed request can be dismissed.`);
2845
+ if (dismissed && current.dismissedAt !== null)
2846
+ return current;
2847
+ this.db
2848
+ .prepare("UPDATE agent_requests SET dismissed_at = ?, dismissed_by = ?, updated_at = ? WHERE id = ?")
2849
+ .run(dismissed ? this.now : null, dismissed ? this.actingUserId : null, this.now, id);
2850
+ const updated = this.store.getAgentRequest(id);
2851
+ this.touchRequest(updated);
2852
+ return updated;
2853
+ }
2743
2854
  /** Termine en échec une demande `processing` dont l'agent a été arrêté, avec la raison montrée à son auteur. */
2744
2855
  abortAgentRequest(id, reason) {
2745
2856
  if (this.actor.type !== "user")
@@ -2793,6 +2904,8 @@ export class Mutation {
2793
2904
  cancelledBy: null,
2794
2905
  stoppedAt: null,
2795
2906
  stoppedBy: null,
2907
+ dismissedAt: null,
2908
+ dismissedBy: null,
2796
2909
  }, "request");
2797
2910
  this.db
2798
2911
  .prepare(`INSERT INTO agent_requests (id, author_id, target_space_id, kind, text, status, created_at, updated_at, claimed_at, claimed_by_token_id)
@@ -3136,8 +3249,8 @@ export class Mutation {
3136
3249
  this.db
3137
3250
  .prepare(`UPDATE user_settings SET notify_assign_app = ?, notify_assign_email = ?, notify_comment_app = ?, notify_comment_email = ?,
3138
3251
  notify_follow_up_app = ?, notify_follow_up_email = ?, assistant_history = ?, pomodoro_work_minutes = ?,
3139
- pomodoro_short_break_minutes = ?, pomodoro_long_break_minutes = ?, pomodoro_cycles = ?, email_digest_minutes = ?, sidebar_mode = ?, task_open_mode = ? WHERE user_id = ?`)
3140
- .run(settings.notifyAssignApp ? 1 : 0, settings.notifyAssignEmail ? 1 : 0, settings.notifyCommentApp ? 1 : 0, settings.notifyCommentEmail ? 1 : 0, settings.notifyFollowUpApp ? 1 : 0, settings.notifyFollowUpEmail ? 1 : 0, settings.assistantHistory, settings.pomodoro.workMinutes, settings.pomodoro.shortBreakMinutes, settings.pomodoro.longBreakMinutes, settings.pomodoro.cycles, settings.emailDigestMinutes, settings.sidebarMode, settings.taskOpenMode, userId);
3252
+ pomodoro_short_break_minutes = ?, pomodoro_long_break_minutes = ?, pomodoro_cycles = ?, email_digest_minutes = ?, sidebar_mode = ?, task_open_mode = ?, task_link_label = ? WHERE user_id = ?`)
3253
+ .run(settings.notifyAssignApp ? 1 : 0, settings.notifyAssignEmail ? 1 : 0, settings.notifyCommentApp ? 1 : 0, settings.notifyCommentEmail ? 1 : 0, settings.notifyFollowUpApp ? 1 : 0, settings.notifyFollowUpEmail ? 1 : 0, settings.assistantHistory, settings.pomodoro.workMinutes, settings.pomodoro.shortBreakMinutes, settings.pomodoro.longBreakMinutes, settings.pomodoro.cycles, settings.emailDigestMinutes, settings.sidebarMode, settings.taskOpenMode, settings.taskLinkLabel, userId);
3141
3254
  this.touch("user_settings", userId, null, userId);
3142
3255
  return settings;
3143
3256
  }
@@ -3207,6 +3320,14 @@ export class Mutation {
3207
3320
  markClaudeTokenRefused(reason) {
3208
3321
  this.db.prepare("UPDATE claude_connection SET refused_at = ?, refused_reason = ? WHERE id = 1").run(this.now, reason);
3209
3322
  }
3323
+ /** Enregistre un e-mail envoyé aux utilisateurs. */
3324
+ recordBroadcast(record) {
3325
+ const valid = validate(NewBroadcastSchema, record, "broadcast");
3326
+ this.db
3327
+ .prepare(`INSERT INTO broadcast_emails (id, subject, markdown, audience, sent_by, sent_at, recipient_count, failed_count)
3328
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?)`)
3329
+ .run(valid.id, valid.subject, valid.markdown, valid.audience, valid.sentBy, valid.sentAt, valid.recipientCount, valid.failedCount);
3330
+ }
3210
3331
  /**
3211
3332
  * Enregistre le relevé d'une session du runner terminée, avec les auteurs des
3212
3333
  * demandes de son espace que le runner a prises entre son début et sa fin
@@ -21,7 +21,7 @@ export declare function requireTask(store: Store, taskId: string, userId: string
21
21
  export declare function notFound(): NotFoundError;
22
22
  /**
23
23
  * Tâche désignée par sa clé (`ORG-41`) parmi les espaces de l'utilisateur,
24
- * avec son statut : celle de l'espace `contextSpaceId` s'il porte le préfixe,
24
+ * avec son statut et ses ancêtres, du premier niveau au parent : celle de l'espace `contextSpaceId` s'il porte le préfixe,
25
25
  * sinon celle du seul espace qui le porte. Plusieurs espaces candidats sans
26
26
  * contexte sont un refus.
27
27
  */
@@ -74,6 +74,6 @@ export declare function deleteComment(store: Store, userId: string, commentId: s
74
74
  * fichier écrit.
75
75
  */
76
76
  export declare function uploadAttachment(store: Store, storage: AttachmentStorage, userId: string, taskId: string, input: UploadAttachmentRequest): AttachmentView;
77
- /** Contenu d'une pièce jointe, avec son type et son nom. */
77
+ /** Contenu d'une pièce jointe d'une tâche ou d'une image de demande, avec son type et son nom. */
78
78
  export declare function downloadAttachment(store: Store, storage: AttachmentStorage, userId: string, attachmentId: string): ApiFile;
79
79
  export declare function deleteAttachment(store: Store, storage: AttachmentStorage, userId: string, attachmentId: string): void;
@@ -2,6 +2,7 @@ import { InvariantError, NotFoundError, OrganizerError } from "./errors.js";
2
2
  import { followUpView, openFollowUps } from "./follow-ups.js";
3
3
  import { newId } from "./ids.js";
4
4
  import { requireMember } from "./spaces.js";
5
+ import { downloadRequestAttachment } from "./request-attachments.js";
5
6
  import { MAX_ATTACHMENT_BYTES, } from "../../shared/schemas/tasks-api.schema.js";
6
7
  import { summarizeTest } from "../../shared/logic/test-summary.js";
7
8
  import { questionViews } from "./questions.js";
@@ -34,7 +35,7 @@ function keyOf(space, task) {
34
35
  const TASK_KEY = /^([A-Z][A-Z0-9]{1,9})-(\d+)$/;
35
36
  /**
36
37
  * Tâche désignée par sa clé (`ORG-41`) parmi les espaces de l'utilisateur,
37
- * avec son statut : celle de l'espace `contextSpaceId` s'il porte le préfixe,
38
+ * avec son statut et ses ancêtres, du premier niveau au parent : celle de l'espace `contextSpaceId` s'il porte le préfixe,
38
39
  * sinon celle du seul espace qui le porte. Plusieurs espaces candidats sans
39
40
  * contexte sont un refus.
40
41
  */
@@ -50,7 +51,13 @@ export function resolveTaskKey(store, userId, key, contextSpaceId) {
50
51
  const task = space ? store.findTaskByNumber(space.id, Number(match[2])) : null;
51
52
  if (!space || !task)
52
53
  throw notFound();
53
- return { id: task.id, key: keyOf(space, task), title: task.title, status: task.status };
54
+ const ancestors = [];
55
+ for (let parentId = task.parentId; parentId !== null;) {
56
+ const parent = store.getTask(parentId);
57
+ ancestors.unshift({ id: parent.id, key: keyOf(space, parent), title: parent.title });
58
+ parentId = parent.parentId;
59
+ }
60
+ return { id: task.id, key: keyOf(space, task), title: task.title, status: task.status, ancestors };
54
61
  }
55
62
  function membersOf(store, spaceId) {
56
63
  return store.listMemberships(spaceId).map((membership) => {
@@ -508,8 +515,11 @@ function requireAttachment(store, attachmentId, userId) {
508
515
  requireTask(store, attachment.taskId, userId);
509
516
  return attachment;
510
517
  }
511
- /** Contenu d'une pièce jointe, avec son type et son nom. */
518
+ /** Contenu d'une pièce jointe d'une tâche ou d'une image de demande, avec son type et son nom. */
512
519
  export function downloadAttachment(store, storage, userId, attachmentId) {
520
+ const ofRequest = store.findAttachment(attachmentId) ? null : downloadRequestAttachment(store, storage, userId, attachmentId);
521
+ if (ofRequest)
522
+ return ofRequest;
513
523
  const attachment = requireAttachment(store, attachmentId, userId);
514
524
  return { contentBase64: storage.read(attachment).toString("base64"), mime: attachment.mime, filename: attachment.filename };
515
525
  }
@@ -10,11 +10,12 @@ import { addCheckpoint, deleteCheckpoint, moveCheckpoint, saveReviewDraft, setTe
10
10
  import { AddChecklistItemRequestSchema, AnswerQuestionRequestSchema, CheckpointTextRequestSchema, CommentRequestSchema, CreateTaskRequestSchema, MoveAfterRequestSchema, MoveTaskRequestSchema, ReviewDraftRequestSchema, SetAssigneesRequestSchema, SetTagsRequestSchema, SetTestResultRequestSchema, SubmitReviewRequestSchema, TaskFiltersSchema, TaskKeyQuerySchema, UpdateChecklistItemRequestSchema, UpdateTaskRequestSchema, UploadAttachmentRequestSchema, } from "../shared/schemas/tasks-api.schema.js";
11
11
  import { getSettings, getSpaceNotificationSettings, listNotifications, markAllNotificationsRead, markNotificationRead, unreadCount, updateSettings, updateSpaceNotificationSettings } from "./core/notifications.js";
12
12
  import { NotificationListQuerySchema, UpdateSettingsRequestSchema, UpdateSpaceNotificationSettingsRequestSchema } from "../shared/schemas/notifications-api.schema.js";
13
- import { cancelRequest, createRequest, createSuite, getRequest, listRequests, relaunchRequest, setFollowUpDone, stopRequest, undoAction, undoRequest, updateRequest, } from "./core/requests.js";
13
+ import { cancelRequest, createRequest, createSuite, getRequest, listRequests, relaunchRequest, resendRequest, setFollowUpDone, setRequestDismissed, stopRequest, undoAction, undoRequest, updateRequest, } from "./core/requests.js";
14
14
  import { listTaskHistory, restoreTaskVersion } from "./core/task-history.js";
15
+ import { deleteRequestAttachment, uploadRequestAttachment } from "./core/request-attachments.js";
15
16
  import { listSpaceHistory, restoreDeletedTask } from "./core/space-history.js";
16
17
  import { SpaceHistoryQuerySchema } from "../shared/schemas/history-api.schema.js";
17
- import { CreateRequestSchema, CreateSuiteSchema, SetFollowUpDoneSchema, UpdateRequestSchema } from "../shared/schemas/agent-api.schema.js";
18
+ import { CreateRequestSchema, CreateSuiteSchema, ResendRequestSchema, SetFollowUpDoneSchema, SetRequestDismissedSchema, UpdateRequestSchema } from "../shared/schemas/agent-api.schema.js";
18
19
  import { createBoardView, deleteBoardView, listBoardViews, moveBoardView, updateBoardView } from "./core/board-views.js";
19
20
  import { CreateBoardViewRequestSchema, MoveBoardViewRequestSchema, UpdateBoardViewRequestSchema } from "../shared/schemas/views-api.schema.js";
20
21
  import { createIdea, delegatePromotion, listIdeas, promoteIdea, setIdeaArchived } from "./core/ideas.js";
@@ -30,6 +31,8 @@ import { getRunnerSettings, listAdminSpaces, processQueueNow, requireAdmin, runn
30
31
  import { RunnerSettingsSchema, RunnerUsageQuerySchema, SaveClaudeTokenRequestSchema, SetRunnerAllowedRequestSchema } from "../shared/schemas/admin-api.schema.js";
31
32
  import { getSiteInstructions, getSpaceInstructions, setSiteInstructions, setSpaceInstructions } from "./core/agent-instructions.js";
32
33
  import { SetAgentInstructionsRequestSchema } from "../shared/schemas/instructions-api.schema.js";
34
+ import { broadcastOverview, previewBroadcast, sendBroadcast, sendBroadcastTest } from "./core/broadcast.js";
35
+ import { BroadcastDraftSchema } from "../shared/schemas/broadcast-api.schema.js";
33
36
  import { confirmPasswordReset, passwordResetBlocker, requestPasswordReset } from "./core/password-reset.js";
34
37
  import { TranscriptionError } from "./core/transcription.js";
35
38
  import { MAX_TRANSCRIPTION_BYTES, TranscribeRequestSchema } from "../shared/schemas/transcription-api.schema.js";
@@ -339,6 +342,13 @@ route("DELETE", "/attachments/:attachmentId", (ctx, { user, params }) => {
339
342
  deleteAttachment(ctx.store, ctx.attachments, user.id, params.attachmentId);
340
343
  return { body: ok };
341
344
  });
345
+ route("POST", "/spaces/:spaceId/request-attachments", (ctx, { user, request, params }) => ({
346
+ body: uploadRequestAttachment(ctx.store, ctx.attachments, user.id, params.spaceId, parseBody(UploadAttachmentRequestSchema, request.body), now(ctx)),
347
+ }));
348
+ route("DELETE", "/request-attachments/:attachmentId", (ctx, { user, params }) => {
349
+ deleteRequestAttachment(ctx.store, ctx.attachments, user.id, params.attachmentId);
350
+ return { body: ok };
351
+ });
342
352
  // --- Idées -------------------------------------------------------------------------
343
353
  route("GET", "/spaces/:spaceId/ideas", (ctx, { user, params }) => ({ body: listIdeas(ctx.store, user.id, params.spaceId) }));
344
354
  route("POST", "/spaces/:spaceId/ideas", (ctx, { user, request, params }) => ({
@@ -398,6 +408,12 @@ route("PATCH", "/requests/:requestId", (ctx, { user, request, params }) => ({
398
408
  route("POST", "/requests/:requestId/cancel", (ctx, { user, params }) => ({ body: cancelRequest(ctx.store, user.id, params.requestId) }));
399
409
  route("POST", "/requests/:requestId/stop", (ctx, { user, params }) => ({ body: stopRequest(ctx.store, user.id, params.requestId, ctx.runner.stopSession) }));
400
410
  route("POST", "/requests/:requestId/relaunch", (ctx, { user, params }) => ({ body: relaunchRequest(ctx.store, user.id, params.requestId) }));
411
+ route("PUT", "/requests/:requestId/dismissed", (ctx, { user, request, params }) => ({
412
+ body: setRequestDismissed(ctx.store, user.id, params.requestId, parseBody(SetRequestDismissedSchema, request.body).dismissed),
413
+ }));
414
+ route("POST", "/requests/:requestId/resend", (ctx, { user, request, params }) => ({
415
+ body: resendRequest(ctx.store, user.id, params.requestId, parseBody(ResendRequestSchema, request.body).text),
416
+ }));
401
417
  route("POST", "/requests/:requestId/undo", (ctx, { user, params }) => ({ body: undoRequest(ctx.store, ctx.attachments, user.id, params.requestId) }));
402
418
  route("POST", "/requests/:requestId/suites", (ctx, { user, request, params }) => ({
403
419
  body: createSuite(ctx.store, user.id, params.requestId, parseBody(CreateSuiteSchema, request.body).text),
@@ -508,6 +524,36 @@ route("GET", "/admin/agent-instructions", (ctx, { user }) => ({ body: getSiteIns
508
524
  route("PUT", "/admin/agent-instructions", (ctx, { user, request }) => ({
509
525
  body: setSiteInstructions(ctx.store, user.id, parseBody(SetAgentInstructionsRequestSchema, request.body).text),
510
526
  }));
527
+ // --- E-mail aux utilisateurs ------------------------------------------------------
528
+ /** Dépendances de l'e-mail aux utilisateurs, tirées du contexte. */
529
+ function broadcastDeps(ctx) {
530
+ return { mailer: ctx.mailer, publicUrl: ctx.publicUrl, now: () => now(ctx) };
531
+ }
532
+ /** L'envoi d'e-mail est configuré ; sinon, erreur 503 avec ce qu'il faut configurer. */
533
+ function requireMailer(ctx) {
534
+ if (!ctx.mailer.enabled)
535
+ throw new ApiError("unavailable", ctx.mailer.disabledReason ?? "Envoi d'e-mail désactivé.");
536
+ }
537
+ route("GET", "/admin/broadcasts", (ctx, { user }) => ({ body: broadcastOverview(ctx.store, user.id, ctx.mailer) }));
538
+ route("POST", "/admin/broadcasts/preview", (ctx, { user, request }) => ({
539
+ body: previewBroadcast(ctx.store, user.id, parseBody(BroadcastDraftSchema, request.body), broadcastDeps(ctx)),
540
+ }));
541
+ route("POST", "/admin/broadcasts/test", async (ctx, { user, request }) => {
542
+ requireAdmin(ctx.store, user.id);
543
+ const draft = parseBody(BroadcastDraftSchema, request.body);
544
+ requireMailer(ctx);
545
+ const { to, outcome } = await sendBroadcastTest(ctx.store, user.id, draft, broadcastDeps(ctx));
546
+ if (!outcome.sent)
547
+ throw new ApiError("upstream", outcome.reason);
548
+ const body = { to };
549
+ return { body };
550
+ });
551
+ route("POST", "/admin/broadcasts", async (ctx, { user, request }) => {
552
+ requireAdmin(ctx.store, user.id);
553
+ const draft = parseBody(BroadcastDraftSchema, request.body);
554
+ requireMailer(ctx);
555
+ return { body: await sendBroadcast(ctx.store, user.id, draft, broadcastDeps(ctx)) };
556
+ });
511
557
  // --- Dictée ------------------------------------------------------------------------
512
558
  route("POST", "/transcribe", async (ctx, { request }) => {
513
559
  const input = parseBody(TranscribeRequestSchema, request.body);
@@ -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 `![file name](attachment:<id>)`, 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.";
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 `![file name](attachment:<id>)`, 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 request can carry **images** its author pasted in its text (`![file name](attachment:<id>)`): claim_request lists them with their id. Open them with get_attachment, and attach the ones that explain a task you create or change with copy_attachment, which copies the file on the site: the task then reads without the request.\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- **Mentions**: a text mentions a task by its key (`ORG-30`), which the site shows as a button with the task's status and its key or current title, and a page of the space by a markdown link to its address, which the site shows as a pill named after the current name of its target (the link text is only a fallback): `[Tableau de bord](#/tableau-de-bord)`. An address without a space designates the space of the text; members' mentions carry it (`#/espaces/<space id>/\u2026`). Addresses: dashboard `#/tableau-de-bord`, one of the reader's views `#/tableau-de-bord/vue/<view id>`, ideas `#/idees`, notes `#/notes`, a note `#/notes/<note id>`, documents `#/documents`, a document `#/documents/<document id>`, the agent page `#/agent` and its tabs `#/agent/file`, `#/agent/en-traitement`, `#/agent/en-attente`, `#/agent/traitees`, `#/agent/annulees`, history `#/historique`, space settings `#/espace`. Write mentions the same way in your descriptions, comments and replies.\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 of the request 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, copy_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`.
@@ -17,7 +17,9 @@ 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
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 \`![file name](attachment:<id>)\`, 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
+ - A request can carry **images** its author pasted in its text (\`![file name](attachment:<id>)\`): claim_request lists them with their id. Open them with get_attachment, and attach the ones that explain a task you create or change with copy_attachment, which copies the file on the site: the task then reads without the request.
20
21
  - 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…).
22
+ - **Mentions**: a text mentions a task by its key (\`ORG-30\`), which the site shows as a button with the task's status and its key or current title, and a page of the space by a markdown link to its address, which the site shows as a pill named after the current name of its target (the link text is only a fallback): \`[Tableau de bord](#/tableau-de-bord)\`. An address without a space designates the space of the text; members' mentions carry it (\`#/espaces/<space id>/…\`). Addresses: dashboard \`#/tableau-de-bord\`, one of the reader's views \`#/tableau-de-bord/vue/<view id>\`, ideas \`#/idees\`, notes \`#/notes\`, a note \`#/notes/<note id>\`, documents \`#/documents\`, a document \`#/documents/<document id>\`, the agent page \`#/agent\` and its tabs \`#/agent/file\`, \`#/agent/en-traitement\`, \`#/agent/en-attente\`, \`#/agent/traitees\`, \`#/agent/annulees\`, history \`#/historique\`, space settings \`#/espace\`. Write mentions the same way in your descriptions, comments and replies.
21
23
  - 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
24
  - 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
25
  - 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.
@@ -30,8 +32,8 @@ Concepts:
30
32
  Work loop, when the user asks you to process the queue:
31
33
  1. list_requests to see the pending requests of your space.
32
34
  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_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
+ 3. Read what you need with get_task and search_tasks, with get_attachment for an image of the request 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.
36
+ 4. Act with create_task, update_task, set_assignees, set_tags, edit_checklist, edit_questions, add_comment, add_attachment, copy_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
37
  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
38
  When the queue is empty, tell the user.
37
39