@imenam/mcp-organizer 1.0.14 → 1.0.16

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.
@@ -322,6 +322,7 @@ export interface BoardViewSettings {
322
322
  priorities: TaskPriority[];
323
323
  assigneeIds: string[];
324
324
  unassigned: boolean;
325
+ tagIds: string[];
325
326
  }
326
327
  /** Action de l'agent à enregistrer dans le lot de sa demande. */
327
328
  export interface AgentActionInput {
@@ -183,6 +183,7 @@ function boardViewFromRow(row) {
183
183
  priorities: JSON.parse(row.priorities),
184
184
  assigneeIds: JSON.parse(row.assignee_ids),
185
185
  unassigned: bool(row.unassigned),
186
+ tagIds: JSON.parse(row.tag_ids),
186
187
  position: row.position,
187
188
  createdAt: row.created_at,
188
189
  updatedAt: row.updated_at,
@@ -337,8 +338,8 @@ function notificationFromRow(row) {
337
338
  });
338
339
  }
339
340
  /** Jointure qui garde les notifications dont la tâche ou la demande appartient à un espace dont le destinataire est membre. */
340
- const VISIBLE_NOTIFICATION_JOIN = `LEFT JOIN tasks t ON t.id = n.task_id
341
- LEFT JOIN agent_requests r ON n.task_id IS NULL AND r.id = n.request_id
341
+ const VISIBLE_NOTIFICATION_JOIN = `LEFT JOIN tasks t ON t.id = n.task_id
342
+ LEFT JOIN agent_requests r ON n.task_id IS NULL AND r.id = n.request_id
342
343
  JOIN memberships m ON m.space_id = COALESCE(t.space_id, r.target_space_id) AND m.user_id = n.user_id`;
343
344
  /** Libellé d'une tâche dans les messages : `ORG-41`. */
344
345
  function taskLabel(db, task) {
@@ -512,7 +513,7 @@ export class Store {
512
513
  /** Espaces dont l'utilisateur est membre : son espace personnel d'abord, puis les espaces communs par nom. */
513
514
  listSpacesOf(userId) {
514
515
  const rows = this.db
515
- .prepare(`SELECT s.* FROM spaces s JOIN memberships m ON m.space_id = s.id
516
+ .prepare(`SELECT s.* FROM spaces s JOIN memberships m ON m.space_id = s.id
516
517
  WHERE m.user_id = ? ORDER BY s.kind = 'shared', s.name COLLATE NOCASE`)
517
518
  .all(userId);
518
519
  return rows.map(spaceFromRow);
@@ -684,7 +685,7 @@ export class Store {
684
685
  /** Résultats saisis sur les points des tâches d'un espace. */
685
686
  listTestResultsInSpace(spaceId) {
686
687
  const rows = this.db
687
- .prepare(`SELECT c.task_id, r.checkpoint_id, r.tester_id, r.result FROM test_results r
688
+ .prepare(`SELECT c.task_id, r.checkpoint_id, r.tester_id, r.result FROM test_results r
688
689
  JOIN test_checkpoints c ON c.id = r.checkpoint_id JOIN tasks t ON t.id = c.task_id WHERE t.space_id = ?`)
689
690
  .all(spaceId);
690
691
  return rows.map((row) => ({
@@ -729,7 +730,7 @@ export class Store {
729
730
  /** Pièces jointes d'une tâche et de toutes ses sous-tâches. */
730
731
  listAttachmentsInSubtree(taskId) {
731
732
  const rows = this.db
732
- .prepare(`WITH RECURSIVE subtree(id) AS (SELECT ? UNION ALL SELECT t.id FROM tasks t JOIN subtree s ON t.parent_id = s.id)
733
+ .prepare(`WITH RECURSIVE subtree(id) AS (SELECT ? UNION ALL SELECT t.id FROM tasks t JOIN subtree s ON t.parent_id = s.id)
733
734
  SELECT a.* FROM attachments a JOIN subtree s ON a.task_id = s.id`)
734
735
  .all(taskId);
735
736
  return rows.map(attachmentFromRow);
@@ -759,7 +760,7 @@ export class Store {
759
760
  /** Demandes de promotion (`idea_promotion`) en attente ou en cours sur les idées d'un espace. */
760
761
  listOpenPromotionRequests(spaceId) {
761
762
  const rows = this.db
762
- .prepare(`SELECT r.* FROM agent_requests r JOIN ideas i ON i.id = r.context_idea_id
763
+ .prepare(`SELECT r.* FROM agent_requests r JOIN ideas i ON i.id = r.context_idea_id
763
764
  WHERE i.space_id = ? AND r.kind = 'idea_promotion' AND r.status IN ('pending', 'processing') ORDER BY r.created_at, r.id`)
764
765
  .all(spaceId);
765
766
  return rows.map(requestFromRow);
@@ -817,9 +818,9 @@ export class Store {
817
818
  if (limit === 0)
818
819
  return [];
819
820
  const rows = this.db
820
- .prepare(`SELECT * FROM agent_requests
821
- WHERE target_space_id = @spaceId AND author_id = @authorId AND status IN ('done', 'failed') AND kind <> 'direct'
822
- AND (created_at < @createdAt OR (created_at = @createdAt AND id < @id))
821
+ .prepare(`SELECT * FROM agent_requests
822
+ WHERE target_space_id = @spaceId AND author_id = @authorId AND status IN ('done', 'failed') AND kind <> 'direct'
823
+ AND (created_at < @createdAt OR (created_at = @createdAt AND id < @id))
823
824
  ORDER BY created_at DESC, id DESC LIMIT @limit`)
824
825
  .all({ spaceId, authorId, createdAt: before.createdAt, id: before.id, limit });
825
826
  return rows.map(requestFromRow).reverse();
@@ -911,8 +912,8 @@ export class Store {
911
912
  */
912
913
  listNotifications(userId, limit, offset) {
913
914
  const rows = this.db
914
- .prepare(`SELECT n.* FROM notifications n ${VISIBLE_NOTIFICATION_JOIN}
915
- WHERE n.user_id = ? AND n.in_app = 1
915
+ .prepare(`SELECT n.* FROM notifications n ${VISIBLE_NOTIFICATION_JOIN}
916
+ WHERE n.user_id = ? AND n.in_app = 1
916
917
  ORDER BY n.read_at IS NOT NULL, n.created_at DESC, n.id DESC LIMIT ? OFFSET ?`)
917
918
  .all(userId, limit, offset);
918
919
  return rows.map(notificationFromRow);
@@ -920,7 +921,7 @@ export class Store {
920
921
  /** Nombre de notifications non lues affichées dans l'application d'un utilisateur. */
921
922
  countUnreadNotifications(userId) {
922
923
  const row = this.db
923
- .prepare(`SELECT COUNT(*) AS n FROM notifications n ${VISIBLE_NOTIFICATION_JOIN}
924
+ .prepare(`SELECT COUNT(*) AS n FROM notifications n ${VISIBLE_NOTIFICATION_JOIN}
924
925
  WHERE n.user_id = ? AND n.in_app = 1 AND n.read_at IS NULL`)
925
926
  .get(userId);
926
927
  return row.n;
@@ -949,8 +950,8 @@ export class Store {
949
950
  */
950
951
  listChangesForUser(userId, since, limit) {
951
952
  const rows = this.db
952
- .prepare(`SELECT * FROM changes WHERE seq > ?
953
- AND (user_id = ? OR space_id IN (SELECT space_id FROM memberships WHERE user_id = ?))
953
+ .prepare(`SELECT * FROM changes WHERE seq > ?
954
+ AND (user_id = ? OR space_id IN (SELECT space_id FROM memberships WHERE user_id = ?))
954
955
  ORDER BY seq LIMIT ?`)
955
956
  .all(since, userId, userId, limit);
956
957
  return rows.map(changeFromRow);
@@ -1235,7 +1236,7 @@ export class Mutation {
1235
1236
  if (!this.store.isMember(token.spaceId, token.userId))
1236
1237
  throw new ForbiddenError("An agent token can only cover a space its owner is a member of.");
1237
1238
  this.db
1238
- .prepare(`INSERT INTO agent_tokens (id, user_id, space_id, name, prefix, token_hash, created_at, expires_at, is_runner)
1239
+ .prepare(`INSERT INTO agent_tokens (id, user_id, space_id, name, prefix, token_hash, created_at, expires_at, is_runner)
1239
1240
  VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`)
1240
1241
  .run(token.id, token.userId, token.spaceId, token.name, token.prefix, token.tokenHash, token.createdAt, token.expiresAt, token.isRunner ? 1 : 0);
1241
1242
  this.touch("agent_token", token.id, null, token.userId);
@@ -1371,7 +1372,7 @@ export class Mutation {
1371
1372
  this.touch("membership", `${id}:${membership.userId}`, id, membership.userId);
1372
1373
  }
1373
1374
  this.db
1374
- .prepare(`DELETE FROM entity_versions WHERE (entity_type = 'task' AND entity_id IN (SELECT id FROM tasks WHERE space_id = ?))
1375
+ .prepare(`DELETE FROM entity_versions WHERE (entity_type = 'task' AND entity_id IN (SELECT id FROM tasks WHERE space_id = ?))
1375
1376
  OR (entity_type = 'idea' AND entity_id IN (SELECT id FROM ideas WHERE space_id = ?))`)
1376
1377
  .run(id, id);
1377
1378
  this.db.prepare("DELETE FROM spaces WHERE id = ?").run(id);
@@ -1447,8 +1448,8 @@ export class Mutation {
1447
1448
  version: 1,
1448
1449
  }, "task");
1449
1450
  this.db
1450
- .prepare(`INSERT INTO tasks (id, space_id, number, parent_id, depth, type, title, description, status, priority, position,
1451
- created_by, created_at, updated_at, version)
1451
+ .prepare(`INSERT INTO tasks (id, space_id, number, parent_id, depth, type, title, description, status, priority, position,
1452
+ created_by, created_at, updated_at, version)
1452
1453
  VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
1453
1454
  .run(task.id, task.spaceId, task.number, task.parentId, task.depth, task.type, task.title, task.description, task.status, task.priority, task.position, task.createdBy, task.createdAt, task.updatedAt, task.version);
1454
1455
  this.db.prepare("UPDATE spaces SET next_task_number = next_task_number + 1 WHERE id = ?").run(space.id);
@@ -1482,7 +1483,7 @@ export class Mutation {
1482
1483
  const testedTaskId = fields.testedTaskId !== undefined ? fields.testedTaskId : type === "standard" ? null : current.testedTaskId;
1483
1484
  const task = validate(TaskSchema, { ...current, ...fields, parentId, depth, status, position, testedTaskId, updatedAt: this.now }, "task");
1484
1485
  this.db
1485
- .prepare(`UPDATE tasks SET parent_id = ?, depth = ?, type = ?, title = ?, description = ?, status = ?, priority = ?,
1486
+ .prepare(`UPDATE tasks SET parent_id = ?, depth = ?, type = ?, title = ?, description = ?, status = ?, priority = ?,
1486
1487
  position = ?, tested_task_id = ?, updated_at = ? WHERE id = ?`)
1487
1488
  .run(task.parentId, task.depth, task.type, task.title, task.description, task.status, task.priority, task.position, task.testedTaskId, task.updatedAt, id);
1488
1489
  this.touch("task", id, task.spaceId, null);
@@ -1741,7 +1742,7 @@ export class Mutation {
1741
1742
  updatedAt: this.now,
1742
1743
  }, "test result");
1743
1744
  this.db
1744
- .prepare(`INSERT INTO test_results (checkpoint_id, tester_id, result, comment, updated_at) VALUES (?, ?, ?, ?, ?)
1745
+ .prepare(`INSERT INTO test_results (checkpoint_id, tester_id, result, comment, updated_at) VALUES (?, ?, ?, ?, ?)
1745
1746
  ON CONFLICT (checkpoint_id, tester_id) DO UPDATE SET result = excluded.result, comment = excluded.comment, updated_at = excluded.updated_at`)
1746
1747
  .run(result.checkpointId, result.testerId, result.result, result.comment, result.updatedAt);
1747
1748
  this.touch("test_result", `${checkpointId}:${testerId}`, task.spaceId, null, task.id);
@@ -1904,7 +1905,7 @@ export class Mutation {
1904
1905
  createdAt: this.now,
1905
1906
  }, "idea");
1906
1907
  this.db
1907
- .prepare(`INSERT INTO ideas (id, space_id, author_id, text, origin, request_id, promoted_task_id, archived_at, created_at)
1908
+ .prepare(`INSERT INTO ideas (id, space_id, author_id, text, origin, request_id, promoted_task_id, archived_at, created_at)
1908
1909
  VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`)
1909
1910
  .run(idea.id, idea.spaceId, idea.authorId, idea.text, idea.origin, idea.requestId, idea.promotedTaskId, idea.archivedAt, idea.createdAt);
1910
1911
  this.touch("idea", idea.id, idea.spaceId, null);
@@ -1964,18 +1965,18 @@ export class Mutation {
1964
1965
  }
1965
1966
  insertBoardView(view) {
1966
1967
  this.db
1967
- .prepare(`INSERT INTO board_views (id, space_id, user_id, name, layout, group_by, then_by, show_empty_groups, statuses, priorities, assignee_ids, unassigned, position, created_at, updated_at)
1968
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
1969
- .run(view.id, view.spaceId, view.userId, view.name, view.layout, view.groupBy, view.thenBy, view.showEmptyGroups ? 1 : 0, JSON.stringify(view.statuses), JSON.stringify(view.priorities), JSON.stringify(view.assigneeIds), view.unassigned ? 1 : 0, view.position, view.createdAt, view.updatedAt);
1968
+ .prepare(`INSERT INTO board_views (id, space_id, user_id, name, layout, group_by, then_by, show_empty_groups, statuses, priorities, assignee_ids, unassigned, tag_ids, position, created_at, updated_at)
1969
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
1970
+ .run(view.id, view.spaceId, view.userId, view.name, view.layout, view.groupBy, view.thenBy, view.showEmptyGroups ? 1 : 0, JSON.stringify(view.statuses), JSON.stringify(view.priorities), JSON.stringify(view.assigneeIds), view.unassigned ? 1 : 0, JSON.stringify(view.tagIds), view.position, view.createdAt, view.updatedAt);
1970
1971
  this.touch("board_view", view.id, null, view.userId, null, view.spaceId);
1971
1972
  }
1972
1973
  updateBoardView(id, patch) {
1973
1974
  const current = this.store.getBoardView(id);
1974
1975
  const view = validate(BoardViewSchema, { ...current, ...normalizedSettings({ ...current, ...definedFields(patch) }), updatedAt: this.now }, "board view");
1975
1976
  this.db
1976
- .prepare(`UPDATE board_views SET name = ?, layout = ?, group_by = ?, then_by = ?, show_empty_groups = ?, statuses = ?, priorities = ?, assignee_ids = ?, unassigned = ?, updated_at = ?
1977
+ .prepare(`UPDATE board_views SET name = ?, layout = ?, group_by = ?, then_by = ?, show_empty_groups = ?, statuses = ?, priorities = ?, assignee_ids = ?, unassigned = ?, tag_ids = ?, updated_at = ?
1977
1978
  WHERE id = ?`)
1978
- .run(view.name, view.layout, view.groupBy, view.thenBy, view.showEmptyGroups ? 1 : 0, JSON.stringify(view.statuses), JSON.stringify(view.priorities), JSON.stringify(view.assigneeIds), view.unassigned ? 1 : 0, view.updatedAt, id);
1979
+ .run(view.name, view.layout, view.groupBy, view.thenBy, view.showEmptyGroups ? 1 : 0, JSON.stringify(view.statuses), JSON.stringify(view.priorities), JSON.stringify(view.assigneeIds), view.unassigned ? 1 : 0, JSON.stringify(view.tagIds), view.updatedAt, id);
1979
1980
  this.touch("board_view", id, null, view.userId, null, view.spaceId);
1980
1981
  return view;
1981
1982
  }
@@ -2013,8 +2014,8 @@ export class Mutation {
2013
2014
  }, "request");
2014
2015
  this.store.getSpace(request.targetSpaceId);
2015
2016
  this.db
2016
- .prepare(`INSERT INTO agent_requests (id, author_id, target_space_id, kind, context_task_id, context_idea_id,
2017
- text, status, parent_request_id, comment_id, created_at, updated_at)
2017
+ .prepare(`INSERT INTO agent_requests (id, author_id, target_space_id, kind, context_task_id, context_idea_id,
2018
+ text, status, parent_request_id, comment_id, created_at, updated_at)
2018
2019
  VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
2019
2020
  .run(request.id, request.authorId, request.targetSpaceId, request.kind, request.contextTaskId, request.contextIdeaId, request.text, request.status, request.parentRequestId, request.commentId, request.createdAt, request.updatedAt);
2020
2021
  this.createdRequestIds.add(request.id);
@@ -2082,7 +2083,7 @@ export class Mutation {
2082
2083
  if (current.status !== "failed" || current.stoppedAt === null)
2083
2084
  throw new InvariantError(`Request ${id} is ${current.status}: only a stopped request can be relaunched.`);
2084
2085
  this.db
2085
- .prepare(`UPDATE agent_requests SET status = 'pending', claimed_at = NULL, claimed_by_token_id = NULL, completed_at = NULL, failure_reason = NULL,
2086
+ .prepare(`UPDATE agent_requests SET status = 'pending', claimed_at = NULL, claimed_by_token_id = NULL, completed_at = NULL, failure_reason = NULL,
2086
2087
  stopped_at = NULL, stopped_by = NULL, updated_at = ? WHERE id = ?`)
2087
2088
  .run(this.now, id);
2088
2089
  this.db.prepare("DELETE FROM follow_ups WHERE request_id = ?").run(id);
@@ -2146,7 +2147,7 @@ export class Mutation {
2146
2147
  stoppedBy: null,
2147
2148
  }, "request");
2148
2149
  this.db
2149
- .prepare(`INSERT INTO agent_requests (id, author_id, target_space_id, kind, text, status, created_at, updated_at, claimed_at, claimed_by_token_id)
2150
+ .prepare(`INSERT INTO agent_requests (id, author_id, target_space_id, kind, text, status, created_at, updated_at, claimed_at, claimed_by_token_id)
2150
2151
  VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
2151
2152
  .run(request.id, request.authorId, request.targetSpaceId, request.kind, request.text, request.status, request.createdAt, request.updatedAt, request.claimedAt, request.claimedByTokenId);
2152
2153
  this.createdRequestIds.add(request.id);
@@ -2286,7 +2287,7 @@ export class Mutation {
2286
2287
  tokenId: token.id,
2287
2288
  }, "agent action");
2288
2289
  this.db
2289
- .prepare(`INSERT INTO agent_actions (id, request_id, seq, entity_type, entity_id, operation, before, after, summary, created_at, token_id)
2290
+ .prepare(`INSERT INTO agent_actions (id, request_id, seq, entity_type, entity_id, operation, before, after, summary, created_at, token_id)
2290
2291
  VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
2291
2292
  .run(action.id, action.requestId, action.seq, action.entityType, action.entityId, action.operation, action.before === null ? null : JSON.stringify(action.before), action.after === null ? null : JSON.stringify(action.after), action.summary, action.createdAt, action.tokenId);
2292
2293
  this.touch("agent_action", action.id, request.targetSpaceId, null, input.taskId);
@@ -2345,7 +2346,7 @@ export class Mutation {
2345
2346
  emailError: null,
2346
2347
  }, "notification");
2347
2348
  this.db
2348
- .prepare(`INSERT INTO notifications (id, user_id, type, task_id, actor_type, actor_id, request_id, comment_id, in_app, created_at)
2349
+ .prepare(`INSERT INTO notifications (id, user_id, type, task_id, actor_type, actor_id, request_id, comment_id, in_app, created_at)
2349
2350
  VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
2350
2351
  .run(notification.id, notification.userId, notification.type, notification.taskId, notification.actorType, notification.actorId, notification.requestId, notification.commentId, inApp ? 1 : 0, notification.createdAt);
2351
2352
  if (inApp)
@@ -2387,7 +2388,7 @@ export class Mutation {
2387
2388
  updateUserSettings(userId, patch) {
2388
2389
  const settings = validate(UserSettingsSchema, { ...this.store.getUserSettings(userId), ...definedFields(patch) }, "settings");
2389
2390
  this.db
2390
- .prepare(`UPDATE user_settings SET notify_assign_app = ?, notify_assign_email = ?, notify_comment_app = ?, notify_comment_email = ?,
2391
+ .prepare(`UPDATE user_settings SET notify_assign_app = ?, notify_assign_email = ?, notify_comment_app = ?, notify_comment_email = ?,
2391
2392
  notify_follow_up_app = ?, notify_follow_up_email = ?, assistant_history = ? WHERE user_id = ?`)
2392
2393
  .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, userId);
2393
2394
  this.touch("user_settings", userId, null, userId);
@@ -2407,11 +2408,11 @@ export class Mutation {
2407
2408
  }
2408
2409
  const settings = validate(SpaceNotificationSettingsSchema, { userId, spaceId, ...preferences }, "space notification settings");
2409
2410
  this.db
2410
- .prepare(`INSERT INTO space_notification_settings (user_id, space_id, notify_assign_app, notify_assign_email, notify_comment_app, notify_comment_email,
2411
- notify_follow_up_app, notify_follow_up_email)
2412
- VALUES (?, ?, ?, ?, ?, ?, ?, ?)
2413
- ON CONFLICT (user_id, space_id) DO UPDATE SET notify_assign_app = excluded.notify_assign_app, notify_assign_email = excluded.notify_assign_email,
2414
- notify_comment_app = excluded.notify_comment_app, notify_comment_email = excluded.notify_comment_email,
2411
+ .prepare(`INSERT INTO space_notification_settings (user_id, space_id, notify_assign_app, notify_assign_email, notify_comment_app, notify_comment_email,
2412
+ notify_follow_up_app, notify_follow_up_email)
2413
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?)
2414
+ ON CONFLICT (user_id, space_id) DO UPDATE SET notify_assign_app = excluded.notify_assign_app, notify_assign_email = excluded.notify_assign_email,
2415
+ notify_comment_app = excluded.notify_comment_app, notify_comment_email = excluded.notify_comment_email,
2415
2416
  notify_follow_up_app = excluded.notify_follow_up_app, notify_follow_up_email = excluded.notify_follow_up_email`)
2416
2417
  .run(userId, spaceId, settings.notifyAssignApp ? 1 : 0, settings.notifyAssignEmail ? 1 : 0, settings.notifyCommentApp ? 1 : 0, settings.notifyCommentEmail ? 1 : 0, settings.notifyFollowUpApp ? 1 : 0, settings.notifyFollowUpEmail ? 1 : 0);
2417
2418
  return settings;
@@ -2449,7 +2450,7 @@ export class Mutation {
2449
2450
  recordRunnerSession(record) {
2450
2451
  const valid = validate(RunnerSessionRecordSchema, record, "runner session");
2451
2452
  this.db
2452
- .prepare(`INSERT INTO runner_sessions (id, space_id, space_name, started_at, ended_at, outcome, model, turns, cost_usd, input_tokens, output_tokens, cache_read_tokens, cache_creation_tokens)
2453
+ .prepare(`INSERT INTO runner_sessions (id, space_id, space_name, started_at, ended_at, outcome, model, turns, cost_usd, input_tokens, output_tokens, cache_read_tokens, cache_creation_tokens)
2453
2454
  VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
2454
2455
  .run(valid.id, valid.spaceId, valid.spaceName, valid.startedAt, valid.endedAt, valid.outcome, valid.model, valid.turns, valid.costUsd, valid.inputTokens, valid.outputTokens, valid.cacheReadTokens, valid.cacheCreationTokens);
2455
2456
  }
@@ -2529,8 +2530,8 @@ export class Mutation {
2529
2530
  }
2530
2531
  }
2531
2532
  const outsiders = this.db
2532
- .prepare(`SELECT t.number AS number, x.user_id AS user_id FROM task_assignees x JOIN tasks t ON t.id = x.task_id
2533
- WHERE t.space_id = ? AND NOT EXISTS (SELECT 1 FROM memberships m WHERE m.space_id = t.space_id AND m.user_id = x.user_id)
2533
+ .prepare(`SELECT t.number AS number, x.user_id AS user_id FROM task_assignees x JOIN tasks t ON t.id = x.task_id
2534
+ WHERE t.space_id = ? AND NOT EXISTS (SELECT 1 FROM memberships m WHERE m.space_id = t.space_id AND m.user_id = x.user_id)
2534
2535
  ORDER BY t.number LIMIT 1`)
2535
2536
  .get(space.id);
2536
2537
  if (outsiders) {
@@ -2602,7 +2603,7 @@ export class Mutation {
2602
2603
  const actorId = this.actingUserId;
2603
2604
  const requestId = this.request?.id ?? null;
2604
2605
  const tokenId = this.token?.id ?? null;
2605
- const insert = this.db.prepare(`INSERT INTO entity_versions (entity_type, entity_id, version, snapshot, actor_type, actor_id, request_id, created_at, token_id)
2606
+ const insert = this.db.prepare(`INSERT INTO entity_versions (entity_type, entity_id, version, snapshot, actor_type, actor_id, request_id, created_at, token_id)
2606
2607
  VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`);
2607
2608
  for (const entry of this.touched.values()) {
2608
2609
  if (!VERSIONED.has(entry.entityType))
@@ -2624,7 +2625,7 @@ export class Mutation {
2624
2625
  }
2625
2626
  /** Une ligne du journal par entité modifiée, avec l'auteur de la mutation. */
2626
2627
  writeChanges() {
2627
- const insert = this.db.prepare(`INSERT INTO changes (space_id, user_id, entity_type, entity_id, task_id, at, actor_type, actor_id, request_id)
2628
+ const insert = this.db.prepare(`INSERT INTO changes (space_id, user_id, entity_type, entity_id, task_id, at, actor_type, actor_id, request_id)
2628
2629
  VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`);
2629
2630
  const actorId = this.actingUserId;
2630
2631
  const requestId = this.request?.id ?? null;
@@ -2635,7 +2636,7 @@ export class Mutation {
2635
2636
  }
2636
2637
  /** Réglages d'une vue avec des filtres sans doublon, dans l'ordre des statuts et des priorités. */
2637
2638
  function normalizedSettings(settings) {
2638
- const { name, layout, groupBy, thenBy, showEmptyGroups, statuses, priorities, assigneeIds, unassigned } = settings;
2639
+ const { name, layout, groupBy, thenBy, showEmptyGroups, statuses, priorities, assigneeIds, unassigned, tagIds } = settings;
2639
2640
  return {
2640
2641
  name,
2641
2642
  layout,
@@ -2646,6 +2647,7 @@ function normalizedSettings(settings) {
2646
2647
  priorities: TASK_PRIORITIES.filter((priority) => priorities.includes(priority)),
2647
2648
  assigneeIds: [...new Set(assigneeIds)],
2648
2649
  unassigned,
2650
+ tagIds: [...new Set(tagIds)],
2649
2651
  };
2650
2652
  }
2651
2653
  /** Champs de `patch` dont la valeur n'est pas `undefined`. */
package/dist/src/index.js CHANGED
@@ -5,35 +5,35 @@ import { APP_VERSION } from "./version.js";
5
5
  import { ConfigError } from "./core/errors.js";
6
6
  import { findProjectRoot } from "./core/project-root.js";
7
7
  import { loadEnvFile, resolveEnvFile, withoutEnvFileFlag } from "./core/env-file.js";
8
- const USAGE = `mcp-organizer v${APP_VERSION} — gestionnaire de tâches multi-utilisateur piloté par un agent
9
-
10
- Usage :
11
- mcp-organizer Mode MCP (stdio) : outils de l'agent, relayés à l'API du site.
12
- mcp-organizer --server Site web : interface, API et base de données, sur HOST:PORT.
13
- mcp-organizer --set-user [email] [--name="Prénom Nom"] [--non-interactive]
14
- Crée un compte ou remplace son mot de passe.
15
- mcp-organizer --set-admin <email> [--revoke]
16
- Accorde (ou retire) le rôle d'administrateur du site à un compte actif.
17
- Le premier compte créé est administrateur d'office.
18
- mcp-organizer --setup [options] Installe le site : .env, unité systemd, bloc nginx, premier compte
19
- (interactif, ou --non-interactive ; --setup --help pour les options).
20
- mcp-organizer --backup <fichier> [--force]
21
- Sauvegarde la base (site en service ou non) et ses pièces jointes
22
- (dossier <fichier>.attachments).
23
- mcp-organizer --claude-setup-mcp [--force] --url=<URL du site> --token=<jeton>
24
- Écrit l'entrée du mode MCP dans ./.mcp.json.
25
- mcp-organizer --watch <id du jeton>
26
- Veilleur de notifications : une ligne par demande passée en attente.
27
- Lancé par l'outil Monitor de l'agent, avec la commande que rend
28
- l'outil enable_notifications.
29
- mcp-organizer --version Affiche la version.
30
- mcp-organizer --help Affiche cette aide.
31
-
32
- Option commune : --dotenv=<fichier> lit ce fichier .env. Sans elle, le site et ses commandes
33
- lisent <package>/.env ; le mode MCP n'en lit aucun.
34
- Le site exige PORT et ORGANIZER_PUBLIC_URL ; HOST vaut 127.0.0.1 par défaut.
35
- Le mode MCP exige ORGANIZER_URL (URL publique du site, en https hors de la machine locale)
36
- et ORGANIZER_TOKEN (jeton d'agent), fournis par son environnement.
8
+ const USAGE = `mcp-organizer v${APP_VERSION} — gestionnaire de tâches multi-utilisateur piloté par un agent
9
+
10
+ Usage :
11
+ mcp-organizer Mode MCP (stdio) : outils de l'agent, relayés à l'API du site.
12
+ mcp-organizer --server Site web : interface, API et base de données, sur HOST:PORT.
13
+ mcp-organizer --set-user [email] [--name="Prénom Nom"] [--non-interactive]
14
+ Crée un compte ou remplace son mot de passe.
15
+ mcp-organizer --set-admin <email> [--revoke]
16
+ Accorde (ou retire) le rôle d'administrateur du site à un compte actif.
17
+ Le premier compte créé est administrateur d'office.
18
+ mcp-organizer --setup [options] Installe le site : .env, unité systemd, bloc nginx, premier compte
19
+ (interactif, ou --non-interactive ; --setup --help pour les options).
20
+ mcp-organizer --backup <fichier> [--force]
21
+ Sauvegarde la base (site en service ou non) et ses pièces jointes
22
+ (dossier <fichier>.attachments).
23
+ mcp-organizer --claude-setup-mcp [--force] --url=<URL du site> --token=<jeton>
24
+ Écrit l'entrée du mode MCP dans ./.mcp.json.
25
+ mcp-organizer --watch <id du jeton>
26
+ Veilleur de notifications : une ligne par demande passée en attente.
27
+ Lancé par l'outil Monitor de l'agent, avec la commande que rend
28
+ l'outil enable_notifications.
29
+ mcp-organizer --version Affiche la version.
30
+ mcp-organizer --help Affiche cette aide.
31
+
32
+ Option commune : --dotenv=<fichier> lit ce fichier .env. Sans elle, le site et ses commandes
33
+ lisent <package>/.env ; le mode MCP n'en lit aucun.
34
+ Le site exige PORT et ORGANIZER_PUBLIC_URL ; HOST vaut 127.0.0.1 par défaut.
35
+ Le mode MCP exige ORGANIZER_URL (URL publique du site, en https hors de la machine locale)
36
+ et ORGANIZER_TOKEN (jeton d'agent), fournis par son environnement.
37
37
  Voir le README pour la liste complète des variables.`;
38
38
  /** Commandes qui ouvrent la base du site ; toute autre invocation démarre le mode MCP. */
39
39
  const SITE_COMMANDS = ["--server", "--set-user", "--set-admin", "--setup", "--backup"];
@@ -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 and an idea box. 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).\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- 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 and assignees. Each member has their own views in each space.\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 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 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), 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.\n4. Act with create_task, update_task, set_assignees, set_tags, edit_checklist, 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, 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); 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 and an idea box. 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).\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- 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 and tags. Each member has their own views in each space.\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 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 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), 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.\n4. Act with create_task, update_task, set_assignees, set_tags, edit_checklist, 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, 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); 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`.
@@ -19,7 +19,7 @@ Concepts:
19
19
  - 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.
20
20
  - 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.
21
21
  - 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.
22
- - 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 and assignees. Each member has their own views in each space.
22
+ - 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 and tags. Each member has their own views in each space.
23
23
  - 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 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 changes those of your token's owner.
24
24
 
25
25
  Work loop, when the user asks you to process the queue:
@@ -42,6 +42,11 @@ const VIEW_SETTINGS = {
42
42
  description: "Member ids or e-mails: the view keeps the tasks assigned to at least one of them; empty (and unassigned false): every task.",
43
43
  },
44
44
  unassigned: { type: "boolean", description: "Also keep the tasks with no assignee." },
45
+ tags: {
46
+ type: "array",
47
+ items: { type: "string" },
48
+ description: "Tag names of your space (case-insensitive): the view keeps the tasks that carry at least one of them; empty: every task. A name that is not a tag of your space is refused, with the list of its tags.",
49
+ },
45
50
  };
46
51
  export const AGENT_TOOLS = [
47
52
  {
@@ -315,7 +320,7 @@ export const AGENT_TOOLS = [
315
320
  path: "views",
316
321
  definition: {
317
322
  name: "list_views",
318
- description: "List the board views of the author of a request (without request_id: of your token's owner), in your space: each view is a tab of their dashboard with a layout (kanban, list, matrix), groupings by status or priority, and filters on the status, priority and assignees of the top-level tasks. Read them before changing how someone's board looks.",
323
+ description: "List the board views of the author of a request (without request_id: of your token's owner), in your space: each view is a tab of their dashboard with a layout (kanban, list, matrix), groupings by status or priority, and filters on the status, priority, assignees and tags of the top-level tasks. Read them before changing how someone's board looks.",
319
324
  inputSchema: { type: "object", properties: { request_id: VIEW_REQUEST_ID }, additionalProperties: false },
320
325
  },
321
326
  },
@@ -333,7 +338,7 @@ export const AGENT_TOOLS = [
333
338
  path: "views/{view_id}",
334
339
  definition: {
335
340
  name: "update_view",
336
- description: "Change a board view of the author of a request (without request_id: of your token's owner): name, layout, groupings, empty groups, filters. Only the given settings change; a list (statuses, priorities, assignees) replaces the previous one. Their open dashboard switches to the view.",
341
+ description: "Change a board view of the author of a request (without request_id: of your token's owner): name, layout, groupings, empty groups, filters. Only the given settings change; a list (statuses, priorities, assignees, tags) replaces the previous one. Their open dashboard switches to the view.",
337
342
  inputSchema: { type: "object", properties: { request_id: VIEW_REQUEST_ID, view_id: VIEW_ID, ...VIEW_SETTINGS }, required: ["view_id"], additionalProperties: false },
338
343
  },
339
344
  },