@imenam/mcp-organizer 1.0.19 → 1.0.21

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 (106) hide show
  1. package/README.md +103 -29
  2. package/dist/shared/logic/attachments.d.ts +28 -0
  3. package/dist/shared/logic/attachments.js +52 -0
  4. package/dist/shared/logic/documents.d.ts +22 -0
  5. package/dist/shared/logic/documents.js +38 -0
  6. package/dist/shared/logic/line-diff.d.ts +13 -0
  7. package/dist/shared/logic/line-diff.js +66 -0
  8. package/dist/shared/logic/notes.d.ts +12 -0
  9. package/dist/shared/logic/notes.js +23 -0
  10. package/dist/shared/logic/timer.d.ts +69 -0
  11. package/dist/shared/logic/timer.js +87 -0
  12. package/dist/shared/schemas/agent-api.schema.d.ts +10 -29
  13. package/dist/shared/schemas/agent-api.schema.js +4 -15
  14. package/dist/shared/schemas/agent-tools.schema.d.ts +522 -2
  15. package/dist/shared/schemas/agent-tools.schema.js +111 -6
  16. package/dist/shared/schemas/api.schema.d.ts +7 -0
  17. package/dist/shared/schemas/api.schema.js +6 -0
  18. package/dist/shared/schemas/documents-api.schema.d.ts +49 -0
  19. package/dist/shared/schemas/documents-api.schema.js +38 -0
  20. package/dist/shared/schemas/entities.schema.d.ts +107 -54
  21. package/dist/shared/schemas/entities.schema.js +81 -10
  22. package/dist/shared/schemas/enums.schema.d.ts +19 -3
  23. package/dist/shared/schemas/enums.schema.js +8 -2
  24. package/dist/shared/schemas/gui-api.schema.d.ts +1 -0
  25. package/dist/shared/schemas/gui-api.schema.js +2 -0
  26. package/dist/shared/schemas/history-api.schema.d.ts +961 -0
  27. package/dist/shared/schemas/history-api.schema.js +104 -0
  28. package/dist/shared/schemas/notes-api.schema.d.ts +54 -0
  29. package/dist/shared/schemas/notes-api.schema.js +38 -0
  30. package/dist/shared/schemas/notifications-api.schema.d.ts +12 -0
  31. package/dist/shared/schemas/notifications-api.schema.js +4 -1
  32. package/dist/shared/schemas/tasks-api.schema.d.ts +39 -0
  33. package/dist/shared/schemas/tasks-api.schema.js +5 -0
  34. package/dist/shared/schemas/timers-api.schema.d.ts +119 -0
  35. package/dist/shared/schemas/timers-api.schema.js +44 -0
  36. package/dist/shared/schemas/views-api.schema.d.ts +16 -0
  37. package/dist/shared/schemas/views-api.schema.js +4 -2
  38. package/dist/src/agent-api/documents.d.ts +3 -0
  39. package/dist/src/agent-api/documents.js +66 -0
  40. package/dist/src/agent-api/history.d.ts +3 -0
  41. package/dist/src/agent-api/history.js +103 -0
  42. package/dist/src/agent-api/notes.d.ts +3 -0
  43. package/dist/src/agent-api/notes.js +39 -0
  44. package/dist/src/agent-api/requests.js +2 -1
  45. package/dist/src/agent-api/router.js +5 -1
  46. package/dist/src/agent-api/tasks.js +17 -6
  47. package/dist/src/agent-api/timers.d.ts +2 -0
  48. package/dist/src/agent-api/timers.js +170 -0
  49. package/dist/src/agent-api/types.d.ts +3 -0
  50. package/dist/src/agent-api/views.js +15 -30
  51. package/dist/src/cli/backup.js +3 -3
  52. package/dist/src/core/accounts.d.ts +12 -5
  53. package/dist/src/core/accounts.js +28 -10
  54. package/dist/src/core/agent.d.ts +27 -3
  55. package/dist/src/core/agent.js +118 -1
  56. package/dist/src/core/attachments.d.ts +6 -3
  57. package/dist/src/core/attachments.js +9 -4
  58. package/dist/src/core/board-views.js +4 -4
  59. package/dist/src/core/document-text.d.ts +17 -0
  60. package/dist/src/core/document-text.js +118 -0
  61. package/dist/src/core/documents.d.ts +22 -0
  62. package/dist/src/core/documents.js +168 -0
  63. package/dist/src/core/history-events.d.ts +34 -0
  64. package/dist/src/core/history-events.js +236 -0
  65. package/dist/src/core/history.js +33 -3
  66. package/dist/src/core/migrations.js +153 -0
  67. package/dist/src/core/notes.d.ts +23 -0
  68. package/dist/src/core/notes.js +78 -0
  69. package/dist/src/core/notifications.d.ts +48 -5
  70. package/dist/src/core/notifications.js +209 -33
  71. package/dist/src/core/password-reset.d.ts +37 -0
  72. package/dist/src/core/password-reset.js +56 -0
  73. package/dist/src/core/requests.d.ts +4 -3
  74. package/dist/src/core/requests.js +5 -4
  75. package/dist/src/core/snapshots.d.ts +3 -3
  76. package/dist/src/core/snapshots.js +3 -1
  77. package/dist/src/core/space-history.d.ts +18 -0
  78. package/dist/src/core/space-history.js +86 -0
  79. package/dist/src/core/spaces.d.ts +1 -1
  80. package/dist/src/core/spaces.js +4 -4
  81. package/dist/src/core/store.d.ts +154 -11
  82. package/dist/src/core/store.js +479 -52
  83. package/dist/src/core/task-history.d.ts +9 -5
  84. package/dist/src/core/task-history.js +17 -25
  85. package/dist/src/core/tasks.d.ts +2 -2
  86. package/dist/src/core/tasks.js +13 -2
  87. package/dist/src/core/timers.d.ts +33 -0
  88. package/dist/src/core/timers.js +101 -0
  89. package/dist/src/core/versions.d.ts +22 -0
  90. package/dist/src/core/versions.js +106 -0
  91. package/dist/src/gui-api.d.ts +4 -1
  92. package/dist/src/gui-api.js +85 -6
  93. package/dist/src/mcp/start.d.ts +1 -1
  94. package/dist/src/mcp/start.js +12 -7
  95. package/dist/src/mcp/tools.js +129 -3
  96. package/dist/src/server/app.d.ts +4 -2
  97. package/dist/src/server/app.js +21 -5
  98. package/dist/src/server/login-limiter.d.ts +27 -1
  99. package/dist/src/server/login-limiter.js +31 -1
  100. package/dist/src/server/start.js +1 -0
  101. package/gui/dist/assets/index-DbzcjyaW.js +104 -0
  102. package/gui/dist/assets/index-Dvf5Yo0e.css +1 -0
  103. package/gui/dist/index.html +2 -2
  104. package/package.json +1 -1
  105. package/gui/dist/assets/index-B-AB8nGt.css +0 -1
  106. package/gui/dist/assets/index-DU-RfoVk.js +0 -99
@@ -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). 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 **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, edit_questions, add_comment, create_idea, update_idea, promote_idea, with list_views, create_view, update_view, delete_view when the author asks how their board should look, 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, 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. You cannot open the image: rely on the surrounding text, and ask its author in a comment or your reply when you need to know what it shows.\n- A **note** is a markdown draft a member writes in the space to mature a thought over several sessions. Notes never reach your queue and writing one does not notify you: read them only when a member asks you to, with get_note and search_notes (read-only). A text refers to a note by a link ending in `#/notes/<id>`; when a request links notes, claim_request shows them in full. \"Envoyer \u00E0 l'agent\" on a note queues a message that links it: process the note as that message asks (create or update tasks, ideas\u2026).\n- A **document** is a reference file a member uploads to the space (a report on the project, a specification, a data export\u2026) so that your decisions match the real state of the project. claim_request and get_context list the documents with their description; read the ones that help the request with get_document (read-only, in parts for long files). You read text files (txt, md, csv, json, yaml, xml\u2026) and the text of Word files (.docx); you cannot read PDF files or images, only their name and description: ask a member for a text, markdown or Word version when you need their content.\n- A **request** is something a member of your space asked the AI: an idea, a remark, a test review, a message or an idea promotion. It is pending, then processing once you claim it (only your token can then act for it), then done (with your reply and the points left to its author) or failed (with the reason). The points left to the author are checkboxes the members tick off. A **follow-up** is a message a member sends from a handled request: claim_request shows that original request, your reply and its points with their ids, and check_follow_ups ticks off the points the follow-up settles. A member can also hand a request to you by mentioning @agent in a comment of a task: claim_request then shows the task's thread, and complete_request posts your reply as a comment right after theirs.\n- A **batch** is the set of actions you perform for one request. Every action is logged with its before and after state and with your token, and users can undo one action or the whole batch.\n- The **history** of the space records every event, by the members and by you: tasks created, changed (with before and after values) or deleted, checklist items, ideas, members, notes and documents (comments keep their own thread). Members read it on the site and restore an old version of a task, or a deleted task, from there. Read it with get_history when a member asks who changed something or what happened to a task.\n- A **direct action** is a write you make without request_id, when your user asks you directly (in their editor, for example) rather than through a request: it is done in the name of your token's owner and forms its own batch, listed among the requests of the space as a direct action and undoable like any other. The site runner never acts directly: it always passes the request_id of the request it processes.\n- A **view** is a tab of a member's dashboard: a layout (kanban, list, matrix), groupings by status or priority, and filters on status, priority, assignees, tags and task type (standard or test). Each member has their own views in each space.\n- A **timer** measures the time a member spends on a task: a free timer, or a pomodoro that alternates work phases and breaks (default 25 / 5 / 15 min, long break after 4 cycles). Each member has their own timer on a task, only one runs at a time, and the site's clock counts it; only the work phases of a pomodoro count. The time spent on a task is the sum of the sessions of all members: read it with get_task_time. When a member asks you to measure their time, call start_timer (and stop_timer to end it): you act on the timers of the author of the request, like their views.\n- The **scope** of your work is the space of your token: you see and process the requests of all its members, and you never act outside it. You change the views and timers of the author of the request you process, and nobody else's: only when the author owns your token, or when you are the site runner. A direct action on views or timers changes those of your token's owner.\n\nWork loop, when the user asks you to process the queue:\n1. list_requests to see the pending requests of your space.\n2. claim_request on the oldest one: it becomes processing for you and you get its context (text, author, context task, for a message the previous exchanges of its author, task tree, members, recent ideas, reference documents), along with the custom instructions of the site and of the space, which you follow. get_context shows the space at any time.\n3. Read what you need with get_task and search_tasks, with get_history to know who changed what, with get_note for a note the request or a task links, and with get_document for a reference document that helps the request.\n4. Act with create_task, update_task, set_assignees, set_tags, edit_checklist, edit_questions, add_comment, create_idea, update_idea, promote_idea, with list_views, create_view, update_view, delete_view when the author asks how their board should look, with start_timer and stop_timer when the author asks to measure their time on a task, and with check_follow_ups for a follow-up \u2014 always passing the request_id. Each write is one undoable action of the batch.\n5. complete_request with a short reply in the author's language and, in follow_ups, every point the author still has to handle (or fail_request with the reason), then go back to step 1 until no request is pending.\nWhen the queue is empty, tell the user.\n\nDirect work, when the user asks you to change the space outside any request: read with get_context, get_task and search_tasks, then call the write tools without request_id. Do not claim, complete or fail anything: there is no request to close. When your user still has points to handle afterwards, leave them with report_direct.\n\nNotifications: call enable_notifications once at the start of the session and arm the watcher it hands you with Monitor, whatever the command (behind mcp-http-gateway, the gateway relay answers in place of this server and gives its own watcher command). Each request that becomes pending in your space then arrives on its own as one line (kind, author, excerpt, request id), even while you are idle: process it with the work loop above, starting with claim_request. The host stops that watcher after 30 minutes at most: each time it tells you the watcher expired, re-arm it at once with the same Monitor call; otherwise notifications stop for good. A line \"notifications stopped\" means the site refused the token, and a line \"[gateway-watch] \u2026 la veille \u00E9choue\" means the gateway watcher keeps failing: tell the user. wait_for_requests is the waiting tool of the watcher: you do not need to call it.\n\nHow to handle each kind of request:\n- **idea**: classify it. If it belongs to an existing task or sub-task, attach it there (sub-task, checklist item or comment). If it is actionable and important enough, create a task (or sub-task) with a fitting priority. Otherwise, put it in the idea box with create_idea. Prefer existing tasks over duplicates.\n- **test_review**: feed the tester's findings back into the existing tasks (status, checklist, comments, priority of the affected tasks), or create a task for each problem that has none.\n- **remark** and **message**: do whatever is useful \u2014 answer, update or create tasks, comment \u2014 and say what you did in the reply.\n- **idea_promotion**: turn the context idea into a well-formed task with promote_idea.\n\nRules: write titles, descriptions and replies in the language of the users; keep the reply short and factual (markdown is rendered); put anything the members are meant to copy and paste (a command, code, a prompt, an identifier, a URL to reuse) in a fenced markdown code block, which the site shows with a Copy button; never bury in the reply something the author must act on: it belongs in follow_ups. Errors tell you what to do next; an error about the token (missing, revoked, expired, owner no longer a member) cannot be fixed by retrying: tell the user.";
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`.
@@ -14,19 +14,24 @@ export const INSTRUCTIONS = `mcp-organizer connects you to an organizer site: a
14
14
  Your token covers exactly one space, with the rights of the user who created the token. Every tool works on that space.
15
15
 
16
16
  Concepts:
17
- - A **space** holds tasks and an idea box. A user's **personal space** is private; a **shared space** has one owner and members.
17
+ - A **space** holds tasks, an idea box, notes and reference documents. A user's **personal space** is private; a **shared space** has one owner and members.
18
18
  - A **task** has a title, a markdown description, a status (todo, doing, review, done), a priority (low, medium, high, critical), assignees and tags. Tasks nest on two levels: task > sub-task > sub-sub-task. A task is either standard (with a checklist) or a test (with checkpoints that each tester marks ok, ko, blocked or untested). Any task can also carry **questions** you ask the members to settle a point: options to choose from (one, or several), each with a markdown detail, plus a free answer. The members answer on the site; an answer does not notify you. You read the answers with get_task, and act on them only when a member asks you to, in a message or in a comment mentioning @agent.
19
+ - A task has **attachments** (files the members upload), listed by get_task with their id. Members paste screenshots into descriptions, comments and checkpoint comments: such an image is an attachment of the task, referenced in the text as \`![file name](attachment:<id>)\`, and get_task flags the comments and checkpoint comments that contain one. You cannot open the image: rely on the surrounding text, and ask its author in a comment or your reply when you need to know what it shows.
20
+ - A **note** is a markdown draft a member writes in the space to mature a thought over several sessions. Notes never reach your queue and writing one does not notify you: read them only when a member asks you to, with get_note and search_notes (read-only). A text refers to a note by a link ending in \`#/notes/<id>\`; when a request links notes, claim_request shows them in full. "Envoyer à l'agent" on a note queues a message that links it: process the note as that message asks (create or update tasks, ideas…).
21
+ - A **document** is a reference file a member uploads to the space (a report on the project, a specification, a data export…) so that your decisions match the real state of the project. claim_request and get_context list the documents with their description; read the ones that help the request with get_document (read-only, in parts for long files). You read text files (txt, md, csv, json, yaml, xml…) and the text of Word files (.docx); you cannot read PDF files or images, only their name and description: ask a member for a text, markdown or Word version when you need their content.
19
22
  - A **request** is something a member of your space asked the AI: an idea, a remark, a test review, a message or an idea promotion. It is pending, then processing once you claim it (only your token can then act for it), then done (with your reply and the points left to its author) or failed (with the reason). The points left to the author are checkboxes the members tick off. A **follow-up** is a message a member sends from a handled request: claim_request shows that original request, your reply and its points with their ids, and check_follow_ups ticks off the points the follow-up settles. A member can also hand a request to you by mentioning @agent in a comment of a task: claim_request then shows the task's thread, and complete_request posts your reply as a comment right after theirs.
20
23
  - A **batch** is the set of actions you perform for one request. Every action is logged with its before and after state and with your token, and users can undo one action or the whole batch.
24
+ - 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.
21
25
  - 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, assignees and tags. Each member has their own views in each space.
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.
26
+ - 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.
27
+ - 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.
28
+ - 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.
24
29
 
25
30
  Work loop, when the user asks you to process the queue:
26
31
  1. list_requests to see the pending requests of your space.
27
- 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), along with the custom instructions of the site and of the space, which you follow. get_context shows the space at any time.
28
- 3. Read what you need with get_task and search_tasks.
29
- 4. Act with create_task, update_task, set_assignees, set_tags, edit_checklist, edit_questions, add_comment, create_idea, update_idea, promote_idea, with list_views, create_view, update_view, delete_view when the author asks how their board should look, and with check_follow_ups for a follow-up — always passing the request_id. Each write is one undoable action of the batch.
32
+ 2. claim_request on the oldest one: it becomes processing for you and you get its context (text, author, context task, for a message the previous exchanges of its author, task tree, members, recent ideas, reference documents), along with the custom instructions of the site and of the space, which you follow. get_context shows the space at any time.
33
+ 3. Read what you need with get_task and search_tasks, with get_history to know who changed what, with get_note for a note the request or a task links, and with get_document for a reference document that helps the request.
34
+ 4. Act with create_task, update_task, set_assignees, set_tags, edit_checklist, edit_questions, add_comment, create_idea, update_idea, promote_idea, with list_views, create_view, update_view, delete_view when the author asks how their board should look, with start_timer and stop_timer when the author asks to measure their time on a task, and with check_follow_ups for a follow-up — always passing the request_id. Each write is one undoable action of the batch.
30
35
  5. complete_request with a short reply in the author's language and, in follow_ups, every point the author still has to handle (or fail_request with the reason), then go back to step 1 until no request is pending.
31
36
  When the queue is empty, tell the user.
32
37
 
@@ -40,7 +45,7 @@ How to handle each kind of request:
40
45
  - **remark** and **message**: do whatever is useful — answer, update or create tasks, comment — and say what you did in the reply.
41
46
  - **idea_promotion**: turn the context idea into a well-formed task with promote_idea.
42
47
 
43
- Rules: 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.`;
48
+ Rules: 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.`;
44
49
  /** Hôtes de la machine locale, seuls admis en http. */
45
50
  const LOCAL_HOSTNAMES = new Set(["localhost", "127.0.0.1", "[::1]"]);
46
51
  /** Variable d'environnement non vide, ou null. */
@@ -1,4 +1,6 @@
1
- import { BOARD_GROUPINGS, BOARD_LAYOUTS, REQUEST_STATUSES, TASK_PRIORITIES, TASK_STATUSES, TASK_TYPES } from "../../shared/schemas/enums.schema.js";
1
+ import { BOARD_GROUPINGS, BOARD_LAYOUTS, REQUEST_STATUSES, TASK_PRIORITIES, TASK_STATUSES, TASK_TYPES, TIMER_MODES } from "../../shared/schemas/enums.schema.js";
2
+ import { POMODORO_LIMITS } from "../../shared/logic/timer.js";
3
+ import { HISTORY_CATEGORIES, MAX_HISTORY_PAGE } from "../../shared/schemas/history-api.schema.js";
2
4
  import { MAX_BOARD_VIEW_NAME_LENGTH, MAX_QUESTION_LENGTH, MAX_QUESTION_OPTION_DETAIL_LENGTH, MAX_QUESTION_OPTION_LABEL_LENGTH, MAX_QUESTION_OPTIONS, } from "../../shared/schemas/entities.schema.js";
3
5
  import { MAX_TAG_LENGTH, MAX_TASK_TITLE_LENGTH } from "../../shared/schemas/tasks-api.schema.js";
4
6
  import { MAX_CHECKLIST_ITEM_LENGTH, MAX_CHECKLIST_OPERATIONS, MAX_COMMENT_LENGTH, MAX_FOLLOW_UP_LENGTH, MAX_FOLLOW_UPS, MAX_IDEA_LENGTH, MAX_QUESTION_OPERATIONS, MAX_REASON_LENGTH, MAX_REPLY_LENGTH, MAX_REQUEST_LIST_LIMIT, MAX_SEARCH_LIMIT, } from "../../shared/schemas/agent-tools.schema.js";
@@ -18,6 +20,10 @@ const VIEW_REQUEST_ID = {
18
20
  type: "string",
19
21
  description: "Id of the request you claimed (status processing): you act on the board views of its author, and every write is recorded in its batch and can be undone by that author. Omit it only when your user asks you directly, outside any request: you then act on the views of your token's owner, each write forming its own batch. The site runner always passes it.",
20
22
  };
23
+ const TIMER_REQUEST_ID = {
24
+ type: "string",
25
+ description: "Id of the request you claimed (status processing): you act on the timers of its author, and every change is recorded in its batch and can be undone by that author. Omit it only when your user asks you directly, outside any request: you then act on the timers of your token's owner, each change forming its own batch. The site runner always passes it.",
26
+ };
21
27
  const VIEW_ID = { type: "string", description: "Id of a view of the request's author (or of your token's owner), from list_views." };
22
28
  /** Réglages d'une vue, communs à create_view et update_view. */
23
29
  const VIEW_SETTINGS = {
@@ -47,6 +53,11 @@ const VIEW_SETTINGS = {
47
53
  items: { type: "string" },
48
54
  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
55
  },
56
+ types: {
57
+ type: "array",
58
+ items: { type: "string", enum: [...TASK_TYPES] },
59
+ description: "Task types kept by the view: standard tasks, test tasks, or both; empty: all types.",
60
+ },
50
61
  };
51
62
  export const AGENT_TOOLS = [
52
63
  {
@@ -117,6 +128,81 @@ export const AGENT_TOOLS = [
117
128
  },
118
129
  },
119
130
  },
131
+ {
132
+ method: "GET",
133
+ path: "notes",
134
+ definition: {
135
+ name: "search_notes",
136
+ description: "Search the notes of your space by words of their title or content (most recently updated first). Notes are the members' drafts: they never reach your queue. Read them only when a member asks you to, in a request, a comment or directly.",
137
+ inputSchema: {
138
+ type: "object",
139
+ properties: {
140
+ query: { type: "string", description: "Words to look for (case-insensitive, all must match). Omit to list every note." },
141
+ limit: { type: "integer", minimum: 1, maximum: MAX_SEARCH_LIMIT, description: "Maximum number of results. Default: 30." },
142
+ },
143
+ additionalProperties: false,
144
+ },
145
+ },
146
+ },
147
+ {
148
+ method: "GET",
149
+ path: "notes/{note}",
150
+ definition: {
151
+ name: "get_note",
152
+ description: "Read one note of your space in full: title, author, dates and markdown content. A text refers to a note by a link ending in #/notes/<id>. Use it when a member asks you to process a note, or when a request, a task or a comment you work on links one.",
153
+ inputSchema: {
154
+ type: "object",
155
+ properties: { note: { type: "string", description: "Note of your space: its id, or a link that contains #/notes/<id>." } },
156
+ required: ["note"],
157
+ additionalProperties: false,
158
+ },
159
+ },
160
+ },
161
+ {
162
+ method: "GET",
163
+ path: "documents",
164
+ definition: {
165
+ name: "list_documents",
166
+ description: "List the reference documents of your space: files the members upload (reports, specifications, exports…) so you know the real state of their project. Each one comes with its id, file name, description, format, size, version and whether you can read its content.",
167
+ inputSchema: { type: "object", properties: {}, additionalProperties: false },
168
+ },
169
+ },
170
+ {
171
+ method: "GET",
172
+ path: "documents/{document}",
173
+ definition: {
174
+ name: "get_document",
175
+ description: "Read a reference document of your space. Text files (txt, md, csv, json, yaml, xml…) come as they are and Word files (.docx) as their extracted text, in parts of 20,000 characters: the result says how many parts there are. You cannot read PDF files or images: you get their name and description only. Read a document when it helps the request you process, for example to align tasks and priorities with a report on the project.",
176
+ inputSchema: {
177
+ type: "object",
178
+ properties: {
179
+ document: { type: "string", description: "Document of your space: its id, or its exact file name." },
180
+ part: { type: "integer", minimum: 1, description: "Part to read, from 1. Default: 1." },
181
+ },
182
+ required: ["document"],
183
+ additionalProperties: false,
184
+ },
185
+ },
186
+ },
187
+ {
188
+ method: "GET",
189
+ path: "history",
190
+ definition: {
191
+ name: "get_history",
192
+ description: "Read the history of your space, most recent first: who created, changed or deleted what and when — task fields with their before and after values (status, priority, assignees, tags, description…), checklist items, ideas, members, notes and documents — whether a member or the agent did it. Comments are not part of it. Pass task to read the history of one task, author and category to narrow it. Use it when a member asks who changed something, or when you need to know what happened to a task before acting on it.",
193
+ inputSchema: {
194
+ type: "object",
195
+ properties: {
196
+ task: { type: "string", description: "Task of your space (key like ORG-41, or id): only its events and those of its checklist or checkpoints. Omit for the whole space." },
197
+ author: { type: "string", description: "Member id or e-mail: only what this member did themselves; \"agent\": only what the agent did. Omit for everybody." },
198
+ category: { type: "string", enum: [...HISTORY_CATEGORIES], description: "Kind of events: task (tasks, checklists, checkpoints), idea, member (members and invitations), note or document. Omit for all." },
199
+ before: { type: "integer", minimum: 1, description: "Cursor from a previous call (its \"before\" hint): returns the older events." },
200
+ limit: { type: "integer", minimum: 1, maximum: MAX_HISTORY_PAGE, description: "Maximum number of events. Default: 30." },
201
+ },
202
+ additionalProperties: false,
203
+ },
204
+ },
205
+ },
120
206
  {
121
207
  method: "POST",
122
208
  path: "tasks",
@@ -376,7 +462,7 @@ export const AGENT_TOOLS = [
376
462
  path: "views",
377
463
  definition: {
378
464
  name: "list_views",
379
- 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.",
465
+ 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, tags and type (standard or test) of the top-level tasks. Read them before changing how someone's board looks.",
380
466
  inputSchema: { type: "object", properties: { request_id: VIEW_REQUEST_ID }, additionalProperties: false },
381
467
  },
382
468
  },
@@ -394,7 +480,7 @@ export const AGENT_TOOLS = [
394
480
  path: "views/{view_id}",
395
481
  definition: {
396
482
  name: "update_view",
397
- 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.",
483
+ 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, types) replaces the previous one. Their open dashboard switches to the view.",
398
484
  inputSchema: { type: "object", properties: { request_id: VIEW_REQUEST_ID, view_id: VIEW_ID, ...VIEW_SETTINGS }, required: ["view_id"], additionalProperties: false },
399
485
  },
400
486
  },
@@ -407,6 +493,46 @@ export const AGENT_TOOLS = [
407
493
  inputSchema: { type: "object", properties: { request_id: VIEW_REQUEST_ID, view_id: VIEW_ID }, required: ["view_id"], additionalProperties: false },
408
494
  },
409
495
  },
496
+ {
497
+ method: "GET",
498
+ path: "tasks/{task}/time",
499
+ definition: {
500
+ name: "get_task_time",
501
+ description: "Read the time spent on a task of your space: the total, the total of each member, and every timer session (member, free timer or pomodoro with its settings, running, paused or stopped, start, end, time counted). Only the work phases of a pomodoro count.",
502
+ inputSchema: { type: "object", properties: { task: TASK_REF }, required: ["task"], additionalProperties: false },
503
+ },
504
+ },
505
+ {
506
+ method: "POST",
507
+ path: "tasks/{task}/timer",
508
+ definition: {
509
+ name: "start_timer",
510
+ description: "Start measuring the time the author of a request (without request_id: your token's owner) spends on a task, when they ask for it: a free timer, or a pomodoro that alternates work phases and breaks. Each member has their own timer on a task and only one runs at a time: the timer running on another task is paused. The timer counts on the site's clock and shows on their task, card and header. Refused when they already have a timer on the task: stop_timer first.",
511
+ inputSchema: {
512
+ type: "object",
513
+ properties: {
514
+ request_id: TIMER_REQUEST_ID,
515
+ task: TASK_REF,
516
+ mode: { type: "string", enum: [...TIMER_MODES], description: "free (default) or pomodoro. Giving a pomodoro setting implies pomodoro." },
517
+ work_minutes: { type: "integer", minimum: POMODORO_LIMITS.workMinutes.min, maximum: POMODORO_LIMITS.workMinutes.max, description: "Pomodoro work phase. Default: the member's preference (25)." },
518
+ short_break_minutes: { type: "integer", minimum: POMODORO_LIMITS.shortBreakMinutes.min, maximum: POMODORO_LIMITS.shortBreakMinutes.max, description: "Pomodoro short break. Default: the member's preference (5)." },
519
+ long_break_minutes: { type: "integer", minimum: POMODORO_LIMITS.longBreakMinutes.min, maximum: POMODORO_LIMITS.longBreakMinutes.max, description: "Pomodoro long break. Default: the member's preference (15)." },
520
+ cycles: { type: "integer", minimum: POMODORO_LIMITS.cycles.min, maximum: POMODORO_LIMITS.cycles.max, description: "Work phases before the long break. Default: the member's preference (4)." },
521
+ },
522
+ required: ["task"],
523
+ additionalProperties: false,
524
+ },
525
+ },
526
+ },
527
+ {
528
+ method: "POST",
529
+ path: "tasks/{task}/timer/stop",
530
+ definition: {
531
+ name: "stop_timer",
532
+ description: "Stop the timer (running or paused) of the author of a request (without request_id: of your token's owner) on a task; its session joins the time spent on the task.",
533
+ inputSchema: { type: "object", properties: { request_id: TIMER_REQUEST_ID, task: TASK_REF }, required: ["task"], additionalProperties: false },
534
+ },
535
+ },
410
536
  {
411
537
  method: "POST",
412
538
  path: "requests/{request_id}/follow-ups",
@@ -2,10 +2,11 @@ import { Hono } from "hono";
2
2
  import { type GuiApiContext } from "../gui-api.js";
3
3
  import type { Logger } from "../core/logger.js";
4
4
  import type { SiteConfig } from "./config.js";
5
- import { LoginLimiter } from "./login-limiter.js";
5
+ import { LoginLimiter, PasswordResetLimiter } from "./login-limiter.js";
6
6
  /**
7
7
  * Serveur web du site : en-têtes de sécurité, contrôle d'origine des
8
- * modifications, limitation des connexions, API de la GUI, API des agents
8
+ * modifications, limitation des connexions et des demandes de
9
+ * réinitialisation du mot de passe, API de la GUI, API des agents
9
10
  * (`/api/agent/*`, authentifiée par jeton) et fichiers de `gui/dist`.
10
11
  */
11
12
  export interface SiteDeps {
@@ -15,6 +16,7 @@ export interface SiteDeps {
15
16
  /** Répertoire de la GUI compilée (`gui/dist`). */
16
17
  staticRoot: string;
17
18
  loginLimiter?: LoginLimiter;
19
+ passwordResetLimiter?: PasswordResetLimiter;
18
20
  }
19
21
  /**
20
22
  * Politique de contenu de la GUI : scripts, styles et polices du site
@@ -9,10 +9,11 @@ import { deleteCookie, getCookie, setCookie } from "hono/cookie";
9
9
  import { SESSION_COOKIE_NAME, UPSTREAM_ERROR_HEADER } from "../../shared/schemas/gui-api.schema.js";
10
10
  import { MAX_ATTACHMENT_BYTES } from "../../shared/schemas/tasks-api.schema.js";
11
11
  import { MAX_TRANSCRIPTION_BYTES } from "../../shared/schemas/transcription-api.schema.js";
12
+ import { MAX_DOCUMENT_BYTES } from "../../shared/schemas/documents-api.schema.js";
12
13
  import { errorKindOf, errorStatusOf, handleApiRequest } from "../gui-api.js";
13
14
  import { handleAgentRequest } from "../agent-api/router.js";
14
15
  import { waitForPendingRequests } from "../agent-api/notifications.js";
15
- import { LoginLimiter } from "./login-limiter.js";
16
+ import { LoginLimiter, PasswordResetLimiter } from "./login-limiter.js";
16
17
  import { MAX_BODY_BYTES } from "./limits.js";
17
18
  /**
18
19
  * Politique de contenu de la GUI : scripts, styles et polices du site
@@ -70,8 +71,11 @@ function bearerToken(c) {
70
71
  function megabytes(bytes) {
71
72
  return `${(bytes / (1024 * 1024)).toFixed(1).replace(".", ",")} Mo`;
72
73
  }
73
- /** Limite de taille d'un fichier envoyé : un enregistrement à transcrire, ou une pièce jointe. */
74
+ /** Limite de taille d'un fichier envoyé : un enregistrement à transcrire, un document d'espace, ou une pièce jointe. */
74
75
  function uploadLimit(c) {
76
+ if (/^\/api\/(spaces\/[^/]+\/documents|documents\/[^/]+\/file)$/.test(c.req.path)) {
77
+ return { maxBytes: MAX_DOCUMENT_BYTES, tooLarge: (size) => `Fichier trop volumineux (${megabytes(size)}) : un document ne dépasse pas ${megabytes(MAX_DOCUMENT_BYTES)}.` };
78
+ }
75
79
  if (c.req.path === "/api/transcribe") {
76
80
  return { maxBytes: MAX_TRANSCRIPTION_BYTES, tooLarge: (size) => `Enregistrement trop volumineux (${megabytes(size)}) : la dictée accepte ${megabytes(MAX_TRANSCRIPTION_BYTES)} au plus.` };
77
81
  }
@@ -133,7 +137,7 @@ function fileResponse(c, file) {
133
137
  function baseHref(basePath) {
134
138
  return basePath === "/" ? "/" : `${basePath}/`;
135
139
  }
136
- /** Adresse e-mail d'une tentative de connexion, normalisée, ou null si le corps n'en porte pas. */
140
+ /** Adresse e-mail d'une tentative de connexion ou d'une demande de réinitialisation, normalisée, ou null si le corps n'en porte pas. */
137
141
  function loginEmail(body) {
138
142
  const email = body?.email;
139
143
  return typeof email === "string" && email.trim() !== "" ? email.trim().toLowerCase() : null;
@@ -141,6 +145,7 @@ function loginEmail(body) {
141
145
  export function createSiteApp(deps) {
142
146
  const { config, api, logger, staticRoot } = deps;
143
147
  const loginLimiter = deps.loginLimiter ?? new LoginLimiter();
148
+ const passwordResetLimiter = deps.passwordResetLimiter ?? new PasswordResetLimiter();
144
149
  const cookieOptions = { path: config.basePath, secure: config.secureCookie };
145
150
  const app = new Hono();
146
151
  /**
@@ -204,7 +209,7 @@ export function createSiteApp(deps) {
204
209
  }
205
210
  }
206
211
  try {
207
- const response = handleAgentRequest({ store: api.store, now: api.now }, { method: c.req.method, path: c.req.path.slice(AGENT_API_PREFIX.length) || "/", query: c.req.query(), body, bearer: bearerToken(c) });
212
+ const response = handleAgentRequest({ store: api.store, attachments: api.attachments, now: api.now }, { method: c.req.method, path: c.req.path.slice(AGENT_API_PREFIX.length) || "/", query: c.req.query(), body, bearer: bearerToken(c) });
208
213
  return c.json(response);
209
214
  }
210
215
  catch (err) {
@@ -225,7 +230,7 @@ export function createSiteApp(deps) {
225
230
  // Attente longue des demandes : seule route asynchrone de l'API des agents.
226
231
  app.get(`${AGENT_API_PREFIX}/requests/wait`, async (c) => {
227
232
  try {
228
- const response = await waitForPendingRequests({ store: api.store, now: api.now }, { method: "GET", path: "/requests/wait", query: c.req.query(), bearer: bearerToken(c) }, c.req.raw.signal);
233
+ const response = await waitForPendingRequests({ store: api.store, attachments: api.attachments, now: api.now }, { method: "GET", path: "/requests/wait", query: c.req.query(), bearer: bearerToken(c) }, c.req.raw.signal);
229
234
  return c.json(response);
230
235
  }
231
236
  catch (err) {
@@ -260,6 +265,17 @@ export function createSiteApp(deps) {
260
265
  return c.json({ error: `Trop de tentatives de connexion. Réessayez dans ${minutes} minute${minutes > 1 ? "s" : ""}.` }, 429);
261
266
  }
262
267
  }
268
+ if (request.method === "POST" && request.path === "/auth/password-reset") {
269
+ const ip = clientIp(c);
270
+ const email = loginEmail(request.body);
271
+ const waitMs = passwordResetLimiter.admit(ip, email);
272
+ if (waitMs > 0) {
273
+ const minutes = Math.ceil(waitMs / 60_000);
274
+ logger.warn(`Password reset requests limited for ${ip}${email ? ` / ${email}` : ""}`);
275
+ c.header("Retry-After", String(Math.ceil(waitMs / 1000)));
276
+ return c.json({ error: `Trop de demandes de réinitialisation. Réessayez dans ${minutes} minute${minutes > 1 ? "s" : ""}.` }, 429);
277
+ }
278
+ }
263
279
  let response;
264
280
  try {
265
281
  response = await handleApiRequest(api, request);
@@ -1,5 +1,8 @@
1
1
  /**
2
- * Limitation des tentatives de connexion, par adresse IP et par couple
2
+ * Limitation des tentatives de connexion et des demandes de réinitialisation
3
+ * du mot de passe.
4
+ *
5
+ * Tentatives de connexion, par adresse IP et par couple
3
6
  * (adresse IP, adresse e-mail), sur une fenêtre glissante. Une tentative est
4
7
  * comptée dès son arrivée, avant toute vérification du mot de passe, et
5
8
  * décomptée si la connexion réussit : des tentatives simultanées ne dépassent
@@ -34,3 +37,26 @@ export declare class LoginLimiter {
34
37
  */
35
38
  begin(ip: string, email: string | null): LoginAttempt;
36
39
  }
40
+ /** Limites des demandes de réinitialisation du mot de passe. */
41
+ export interface PasswordResetLimits {
42
+ /** Durée de la fenêtre glissante. */
43
+ windowMs: number;
44
+ /** Demandes admises par adresse IP dans la fenêtre. */
45
+ maxPerIp: number;
46
+ /** Demandes admises par adresse e-mail dans la fenêtre, quelle que soit l'IP. */
47
+ maxPerEmail: number;
48
+ }
49
+ export declare const DEFAULT_PASSWORD_RESET_LIMITS: PasswordResetLimits;
50
+ /**
51
+ * Limitation des demandes de réinitialisation du mot de passe, par adresse IP
52
+ * et par adresse e-mail, sur une fenêtre glissante. Chaque demande admise est
53
+ * comptée, que l'adresse ait un compte ou non.
54
+ */
55
+ export declare class PasswordResetLimiter {
56
+ private readonly now;
57
+ private readonly byIp;
58
+ private readonly byEmail;
59
+ constructor(limits?: PasswordResetLimits, now?: () => number);
60
+ /** Millisecondes d'attente si la demande de `ip` pour `email` est refusée ; sinon 0, et la demande est comptée. */
61
+ admit(ip: string, email: string | null): number;
62
+ }
@@ -1,5 +1,8 @@
1
1
  /**
2
- * Limitation des tentatives de connexion, par adresse IP et par couple
2
+ * Limitation des tentatives de connexion et des demandes de réinitialisation
3
+ * du mot de passe.
4
+ *
5
+ * Tentatives de connexion, par adresse IP et par couple
3
6
  * (adresse IP, adresse e-mail), sur une fenêtre glissante. Une tentative est
4
7
  * comptée dès son arrivée, avant toute vérification du mot de passe, et
5
8
  * décomptée si la connexion réussit : des tentatives simultanées ne dépassent
@@ -79,3 +82,30 @@ export class LoginLimiter {
79
82
  };
80
83
  }
81
84
  }
85
+ export const DEFAULT_PASSWORD_RESET_LIMITS = { windowMs: 60 * 60 * 1000, maxPerIp: 10, maxPerEmail: 3 };
86
+ /**
87
+ * Limitation des demandes de réinitialisation du mot de passe, par adresse IP
88
+ * et par adresse e-mail, sur une fenêtre glissante. Chaque demande admise est
89
+ * comptée, que l'adresse ait un compte ou non.
90
+ */
91
+ export class PasswordResetLimiter {
92
+ now;
93
+ byIp;
94
+ byEmail;
95
+ constructor(limits = DEFAULT_PASSWORD_RESET_LIMITS, now = Date.now) {
96
+ this.now = now;
97
+ this.byIp = new SlidingWindow(limits.windowMs, limits.maxPerIp);
98
+ this.byEmail = new SlidingWindow(limits.windowMs, limits.maxPerEmail);
99
+ }
100
+ /** Millisecondes d'attente si la demande de `ip` pour `email` est refusée ; sinon 0, et la demande est comptée. */
101
+ admit(ip, email) {
102
+ const now = this.now();
103
+ const waitMs = Math.max(this.byIp.retryAfter(ip, now), email === null ? 0 : this.byEmail.retryAfter(email, now));
104
+ if (waitMs > 0)
105
+ return waitMs;
106
+ this.byIp.record(ip, now);
107
+ if (email !== null)
108
+ this.byEmail.record(email, now);
109
+ return 0;
110
+ }
111
+ }
@@ -69,6 +69,7 @@ export async function runServerMode(rootDir) {
69
69
  version: APP_VERSION,
70
70
  mailer,
71
71
  publicUrl: config.publicUrl,
72
+ log: { info: (message) => logger.info(message), error: (message) => logger.error(message) },
72
73
  attachments: new AttachmentStorage(dataDir),
73
74
  transcriber,
74
75
  dataDir,