@imenam/mcp-organizer 0.0.0-stage → 1.0.1

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 (155) hide show
  1. package/README.md +529 -2
  2. package/dist/shared/logic/first-account.d.ts +13 -0
  3. package/dist/shared/logic/first-account.js +15 -0
  4. package/dist/shared/logic/labels.d.ts +5 -0
  5. package/dist/shared/logic/labels.js +17 -0
  6. package/dist/shared/logic/positions.d.ts +9 -0
  7. package/dist/shared/logic/positions.js +19 -0
  8. package/dist/shared/logic/spaces.d.ts +13 -0
  9. package/dist/shared/logic/spaces.js +48 -0
  10. package/dist/shared/logic/test-summary.d.ts +28 -0
  11. package/dist/shared/logic/test-summary.js +35 -0
  12. package/dist/shared/schemas/agent-api.schema.d.ts +268 -0
  13. package/dist/shared/schemas/agent-api.schema.js +94 -0
  14. package/dist/shared/schemas/agent-tools.schema.d.ts +724 -0
  15. package/dist/shared/schemas/agent-tools.schema.js +165 -0
  16. package/dist/shared/schemas/api.schema.d.ts +249 -0
  17. package/dist/shared/schemas/api.schema.js +116 -0
  18. package/dist/shared/schemas/entities.schema.d.ts +472 -0
  19. package/dist/shared/schemas/entities.schema.js +262 -0
  20. package/dist/shared/schemas/enums.schema.d.ts +135 -0
  21. package/dist/shared/schemas/enums.schema.js +58 -0
  22. package/dist/shared/schemas/gui-api.schema.d.ts +53 -0
  23. package/dist/shared/schemas/gui-api.schema.js +20 -0
  24. package/dist/shared/schemas/ideas-api.schema.d.ts +81 -0
  25. package/dist/shared/schemas/ideas-api.schema.js +40 -0
  26. package/dist/shared/schemas/notifications-api.schema.d.ts +87 -0
  27. package/dist/shared/schemas/notifications-api.schema.js +58 -0
  28. package/dist/shared/schemas/tasks-api.schema.d.ts +675 -0
  29. package/dist/shared/schemas/tasks-api.schema.js +225 -0
  30. package/dist/shared/schemas/tokens-api.schema.d.ts +106 -0
  31. package/dist/shared/schemas/tokens-api.schema.js +42 -0
  32. package/dist/shared/schemas/transcription-api.schema.d.ts +15 -0
  33. package/dist/shared/schemas/transcription-api.schema.js +12 -0
  34. package/dist/src/agent-api/checklist.d.ts +3 -0
  35. package/dist/src/agent-api/checklist.js +127 -0
  36. package/dist/src/agent-api/ideas.d.ts +3 -0
  37. package/dist/src/agent-api/ideas.js +93 -0
  38. package/dist/src/agent-api/requests.d.ts +3 -0
  39. package/dist/src/agent-api/requests.js +60 -0
  40. package/dist/src/agent-api/router.d.ts +3 -0
  41. package/dist/src/agent-api/router.js +40 -0
  42. package/dist/src/agent-api/tasks.d.ts +2 -0
  43. package/dist/src/agent-api/tasks.js +290 -0
  44. package/dist/src/agent-api/types.d.ts +41 -0
  45. package/dist/src/agent-api/types.js +14 -0
  46. package/dist/src/cli/backup.d.ts +12 -0
  47. package/dist/src/cli/backup.js +126 -0
  48. package/dist/src/cli/prompt.d.ts +7 -0
  49. package/dist/src/cli/prompt.js +40 -0
  50. package/dist/src/cli/set-user.d.ts +2 -0
  51. package/dist/src/cli/set-user.js +114 -0
  52. package/dist/src/cli/setup-mcp.d.ts +10 -0
  53. package/dist/src/cli/setup-mcp.js +110 -0
  54. package/dist/src/cli/setup.d.ts +39 -0
  55. package/dist/src/cli/setup.js +626 -0
  56. package/dist/src/core/accounts.d.ts +129 -0
  57. package/dist/src/core/accounts.js +284 -0
  58. package/dist/src/core/agent-tokens.d.ts +31 -0
  59. package/dist/src/core/agent-tokens.js +120 -0
  60. package/dist/src/core/agent.d.ts +71 -0
  61. package/dist/src/core/agent.js +358 -0
  62. package/dist/src/core/attachments.d.ts +21 -0
  63. package/dist/src/core/attachments.js +44 -0
  64. package/dist/src/core/data-dir.d.ts +5 -0
  65. package/dist/src/core/data-dir.js +11 -0
  66. package/dist/src/core/db.d.ts +13 -0
  67. package/dist/src/core/db.js +38 -0
  68. package/dist/src/core/env-file.d.ts +11 -0
  69. package/dist/src/core/env-file.js +36 -0
  70. package/dist/src/core/errors.d.ts +24 -0
  71. package/dist/src/core/errors.js +42 -0
  72. package/dist/src/core/history.d.ts +34 -0
  73. package/dist/src/core/history.js +279 -0
  74. package/dist/src/core/ideas.d.ts +16 -0
  75. package/dist/src/core/ideas.js +100 -0
  76. package/dist/src/core/ids.d.ts +2 -0
  77. package/dist/src/core/ids.js +5 -0
  78. package/dist/src/core/log-dir.d.ts +2 -0
  79. package/dist/src/core/log-dir.js +9 -0
  80. package/dist/src/core/logger.d.ts +14 -0
  81. package/dist/src/core/logger.js +37 -0
  82. package/dist/src/core/mail.d.ts +43 -0
  83. package/dist/src/core/mail.js +44 -0
  84. package/dist/src/core/mcp-entry.d.ts +20 -0
  85. package/dist/src/core/mcp-entry.js +15 -0
  86. package/dist/src/core/migrations.d.ts +18 -0
  87. package/dist/src/core/migrations.js +404 -0
  88. package/dist/src/core/native-sqlite.d.ts +2 -0
  89. package/dist/src/core/native-sqlite.js +23 -0
  90. package/dist/src/core/notifications.d.ts +46 -0
  91. package/dist/src/core/notifications.js +173 -0
  92. package/dist/src/core/project-root.d.ts +2 -0
  93. package/dist/src/core/project-root.js +13 -0
  94. package/dist/src/core/requests.d.ts +49 -0
  95. package/dist/src/core/requests.js +239 -0
  96. package/dist/src/core/snapshots.d.ts +32 -0
  97. package/dist/src/core/snapshots.js +35 -0
  98. package/dist/src/core/spaces.d.ts +66 -0
  99. package/dist/src/core/spaces.js +252 -0
  100. package/dist/src/core/store.d.ts +565 -0
  101. package/dist/src/core/store.js +2093 -0
  102. package/dist/src/core/task-history.d.ts +7 -0
  103. package/dist/src/core/task-history.js +41 -0
  104. package/dist/src/core/tasks.d.ts +58 -0
  105. package/dist/src/core/tasks.js +389 -0
  106. package/dist/src/core/test-tasks.d.ts +19 -0
  107. package/dist/src/core/test-tasks.js +135 -0
  108. package/dist/src/core/transcription.d.ts +45 -0
  109. package/dist/src/core/transcription.js +92 -0
  110. package/dist/src/deploy/env-render.d.ts +26 -0
  111. package/dist/src/deploy/env-render.js +98 -0
  112. package/dist/src/deploy/templates.d.ts +38 -0
  113. package/dist/src/deploy/templates.js +130 -0
  114. package/dist/src/gui-api.d.ts +37 -0
  115. package/dist/src/gui-api.js +383 -0
  116. package/dist/src/index.d.ts +2 -0
  117. package/dist/src/index.js +100 -0
  118. package/dist/src/mcp/client.d.ts +23 -0
  119. package/dist/src/mcp/client.js +81 -0
  120. package/dist/src/mcp/start.d.ts +14 -0
  121. package/dist/src/mcp/start.js +104 -0
  122. package/dist/src/mcp/tools.d.ts +46 -0
  123. package/dist/src/mcp/tools.js +348 -0
  124. package/dist/src/server/app.d.ts +25 -0
  125. package/dist/src/server/app.js +290 -0
  126. package/dist/src/server/config.d.ts +23 -0
  127. package/dist/src/server/config.js +75 -0
  128. package/dist/src/server/limits.d.ts +2 -0
  129. package/dist/src/server/limits.js +4 -0
  130. package/dist/src/server/login-limiter.d.ts +36 -0
  131. package/dist/src/server/login-limiter.js +81 -0
  132. package/dist/src/server/start.d.ts +5 -0
  133. package/dist/src/server/start.js +88 -0
  134. package/dist/src/version.d.ts +1 -0
  135. package/dist/src/version.js +16 -0
  136. package/gui/dist/assets/index-DwkXx4Q2.js +70 -0
  137. package/gui/dist/assets/index-lnvnkDdg.css +1 -0
  138. package/gui/dist/assets/inter-cyrillic-ext-wght-normal-BOeWTOD4.woff2 +0 -0
  139. package/gui/dist/assets/inter-cyrillic-wght-normal-DqGufNeO.woff2 +0 -0
  140. package/gui/dist/assets/inter-greek-ext-wght-normal-DlzME5K_.woff2 +0 -0
  141. package/gui/dist/assets/inter-greek-wght-normal-CkhJZR-_.woff2 +0 -0
  142. package/gui/dist/assets/inter-latin-ext-wght-normal-DO1Apj_S.woff2 +0 -0
  143. package/gui/dist/assets/inter-latin-wght-normal-Dx4kXJAl.woff2 +0 -0
  144. package/gui/dist/assets/inter-vietnamese-wght-normal-CBcvBZtf.woff2 +0 -0
  145. package/gui/dist/assets/jetbrains-mono-cyrillic-400-normal-BEIGL1Tu.woff2 +0 -0
  146. package/gui/dist/assets/jetbrains-mono-cyrillic-400-normal-ugxPyKxw.woff +0 -0
  147. package/gui/dist/assets/jetbrains-mono-greek-400-normal-B9oWc5Lo.woff +0 -0
  148. package/gui/dist/assets/jetbrains-mono-greek-400-normal-C190GLew.woff2 +0 -0
  149. package/gui/dist/assets/jetbrains-mono-latin-400-normal-6-qcROiO.woff +0 -0
  150. package/gui/dist/assets/jetbrains-mono-latin-400-normal-V6pRDFza.woff2 +0 -0
  151. package/gui/dist/assets/jetbrains-mono-latin-ext-400-normal-Bc8Ftmh3.woff2 +0 -0
  152. package/gui/dist/assets/jetbrains-mono-latin-ext-400-normal-fXTG6kC5.woff +0 -0
  153. package/gui/dist/assets/jetbrains-mono-vietnamese-400-normal-CqNFfHCs.woff +0 -0
  154. package/gui/dist/index.html +13 -0
  155. package/package.json +66 -4
@@ -0,0 +1,262 @@
1
+ import { z } from "zod";
2
+ import { AccessLinkPurposeSchema, ActorTypeSchema, AgentOperationSchema, EntityTypeSchema, IdeaOriginSchema, MAX_TASK_DEPTH, MemberRoleSchema, NotificationTypeSchema, RequestKindSchema, RequestStatusSchema, SpaceKindSchema, TaskPrioritySchema, TaskStatusSchema, TaskTypeSchema, TestResultValueSchema, UserStatusSchema, VersionedEntityTypeSchema, } from "./enums.schema.js";
3
+ /** Entités du modèle de données, telles que lues et écrites par le store. */
4
+ export const IdSchema = z.string().min(1);
5
+ export const TimestampSchema = z.iso.datetime();
6
+ /** Adresse e-mail normalisée : rognée et en minuscules. */
7
+ export const EmailSchema = z
8
+ .string()
9
+ .trim()
10
+ .toLowerCase()
11
+ .pipe(z.email());
12
+ /** Préfixe des numéros de tâche d'un espace (`ORG` dans `ORG-41`). */
13
+ export const KeyPrefixSchema = z.string().regex(/^[A-Z][A-Z0-9]{1,9}$/, "must be 2 to 10 uppercase letters or digits, starting with a letter");
14
+ /** Rang fractionnaire d'un élément dans sa liste ou sa colonne. */
15
+ export const PositionSchema = z.number().finite();
16
+ export const UserSchema = z.object({
17
+ id: IdSchema,
18
+ email: EmailSchema,
19
+ /** Nom affiché, choisi à l'activation : absent tant que le compte est `invited`. */
20
+ displayName: z.string().min(1).nullable(),
21
+ passwordHash: z.string().min(1).nullable(),
22
+ status: UserStatusSchema,
23
+ createdAt: TimestampSchema,
24
+ });
25
+ export const AccessLinkSchema = z.object({
26
+ id: IdSchema,
27
+ userId: IdSchema,
28
+ purpose: AccessLinkPurposeSchema,
29
+ /** Invitation qui a émis le lien ; un lien d'invitation n'accepte qu'elle. */
30
+ invitationId: IdSchema.nullable(),
31
+ tokenHash: z.string().min(1),
32
+ expiresAt: TimestampSchema,
33
+ usedAt: TimestampSchema.nullable(),
34
+ createdAt: TimestampSchema,
35
+ });
36
+ export const SessionSchema = z.object({
37
+ idHash: z.string().min(1),
38
+ userId: IdSchema,
39
+ createdAt: TimestampSchema,
40
+ expiresAt: TimestampSchema,
41
+ });
42
+ /**
43
+ * Jeton d'agent : il couvre un espace dont son propriétaire est membre.
44
+ * `tokenHash` est le sha256 du jeton, qui n'est jamais stocké en clair ;
45
+ * `prefix` en garde le début, pour le reconnaître dans la liste.
46
+ */
47
+ export const AgentTokenSchema = z.object({
48
+ id: IdSchema,
49
+ userId: IdSchema,
50
+ spaceId: IdSchema,
51
+ name: z.string().trim().min(1),
52
+ prefix: z.string().min(1),
53
+ tokenHash: z.string().regex(/^[0-9a-f]{64}$/),
54
+ createdAt: TimestampSchema,
55
+ lastUsedAt: TimestampSchema.nullable(),
56
+ expiresAt: TimestampSchema.nullable(),
57
+ revokedAt: TimestampSchema.nullable(),
58
+ });
59
+ export const UserSettingsSchema = z.object({
60
+ userId: IdSchema,
61
+ notifyAssignApp: z.boolean(),
62
+ notifyAssignEmail: z.boolean(),
63
+ notifyCommentApp: z.boolean(),
64
+ notifyCommentEmail: z.boolean(),
65
+ });
66
+ export const SpaceSchema = z.object({
67
+ id: IdSchema,
68
+ name: z.string().trim().min(1),
69
+ kind: SpaceKindSchema,
70
+ ownerId: IdSchema,
71
+ keyPrefix: KeyPrefixSchema,
72
+ nextTaskNumber: z.number().int().min(1),
73
+ createdAt: TimestampSchema,
74
+ });
75
+ export const MembershipSchema = z.object({
76
+ spaceId: IdSchema,
77
+ userId: IdSchema,
78
+ role: MemberRoleSchema,
79
+ joinedAt: TimestampSchema,
80
+ });
81
+ export const InvitationSchema = z.object({
82
+ id: IdSchema,
83
+ spaceId: IdSchema,
84
+ email: EmailSchema,
85
+ invitedBy: IdSchema,
86
+ createdAt: TimestampSchema,
87
+ expiresAt: TimestampSchema,
88
+ acceptedAt: TimestampSchema.nullable(),
89
+ revokedAt: TimestampSchema.nullable(),
90
+ /** Refus de l'invitation par son destinataire. */
91
+ declinedAt: TimestampSchema.nullable(),
92
+ });
93
+ export const TaskSchema = z.object({
94
+ id: IdSchema,
95
+ spaceId: IdSchema,
96
+ number: z.number().int().min(1),
97
+ parentId: IdSchema.nullable(),
98
+ depth: z.number().int().min(0).max(MAX_TASK_DEPTH),
99
+ type: TaskTypeSchema,
100
+ title: z.string().trim().min(1),
101
+ /** Markdown. */
102
+ description: z.string(),
103
+ status: TaskStatusSchema,
104
+ priority: TaskPrioritySchema,
105
+ position: PositionSchema,
106
+ /** Tâche que vérifie une tâche de test (même espace, pas elle-même) ; null sinon. */
107
+ testedTaskId: IdSchema.nullable(),
108
+ createdBy: IdSchema,
109
+ createdAt: TimestampSchema,
110
+ updatedAt: TimestampSchema,
111
+ version: z.number().int().min(1),
112
+ });
113
+ export const TaskAssigneeSchema = z.object({ taskId: IdSchema, userId: IdSchema });
114
+ export const TagSchema = z.object({ id: IdSchema, spaceId: IdSchema, name: z.string().trim().min(1) });
115
+ export const TaskTagSchema = z.object({ taskId: IdSchema, tagId: IdSchema });
116
+ export const ChecklistItemSchema = z.object({
117
+ id: IdSchema,
118
+ taskId: IdSchema,
119
+ text: z.string().trim().min(1),
120
+ done: z.boolean(),
121
+ position: PositionSchema,
122
+ });
123
+ export const TestCheckpointSchema = z.object({
124
+ id: IdSchema,
125
+ taskId: IdSchema,
126
+ text: z.string().trim().min(1),
127
+ position: PositionSchema,
128
+ });
129
+ export const TestResultSchema = z.object({
130
+ checkpointId: IdSchema,
131
+ testerId: IdSchema,
132
+ result: TestResultValueSchema,
133
+ comment: z.string(),
134
+ updatedAt: TimestampSchema,
135
+ });
136
+ export const TestReviewSchema = z.object({
137
+ id: IdSchema,
138
+ taskId: IdSchema,
139
+ testerId: IdSchema,
140
+ text: z.string(),
141
+ submittedAt: TimestampSchema.nullable(),
142
+ requestId: IdSchema.nullable(),
143
+ });
144
+ export const CommentSchema = z.object({
145
+ id: IdSchema,
146
+ taskId: IdSchema,
147
+ authorId: IdSchema,
148
+ body: z.string().trim().min(1),
149
+ createdAt: TimestampSchema,
150
+ editedAt: TimestampSchema.nullable(),
151
+ /** Demande pour laquelle l'agent a écrit le commentaire, au nom de son auteur ; null pour un commentaire d'utilisateur. */
152
+ requestId: IdSchema.nullable(),
153
+ });
154
+ export const AttachmentSchema = z.object({
155
+ id: IdSchema,
156
+ taskId: IdSchema,
157
+ uploaderId: IdSchema,
158
+ filename: z.string().min(1),
159
+ mime: z.string().min(1),
160
+ size: z.number().int().min(0),
161
+ storagePath: z.string().min(1),
162
+ createdAt: TimestampSchema,
163
+ });
164
+ export const IdeaSchema = z.object({
165
+ id: IdSchema,
166
+ spaceId: IdSchema,
167
+ authorId: IdSchema,
168
+ text: z.string().trim().min(1),
169
+ origin: IdeaOriginSchema,
170
+ requestId: IdSchema.nullable(),
171
+ promotedTaskId: IdSchema.nullable(),
172
+ archivedAt: TimestampSchema.nullable(),
173
+ createdAt: TimestampSchema,
174
+ });
175
+ export const AgentRequestSchema = z.object({
176
+ id: IdSchema,
177
+ authorId: IdSchema,
178
+ /** Espace où la demande est écrite, et où l'agent agit. */
179
+ targetSpaceId: IdSchema,
180
+ kind: RequestKindSchema,
181
+ contextTaskId: IdSchema.nullable(),
182
+ contextIdeaId: IdSchema.nullable(),
183
+ text: z.string().trim().min(1),
184
+ status: RequestStatusSchema,
185
+ reply: z.string().nullable(),
186
+ failureReason: z.string().nullable(),
187
+ createdAt: TimestampSchema,
188
+ updatedAt: TimestampSchema,
189
+ claimedAt: TimestampSchema.nullable(),
190
+ /** Jeton d'agent qui a pris la demande ; seul ce jeton agit pour elle. */
191
+ claimedByTokenId: IdSchema.nullable(),
192
+ completedAt: TimestampSchema.nullable(),
193
+ cancelledBy: IdSchema.nullable(),
194
+ });
195
+ export const AgentActionSchema = z.object({
196
+ id: IdSchema,
197
+ requestId: IdSchema,
198
+ seq: z.number().int().min(1),
199
+ entityType: EntityTypeSchema,
200
+ entityId: IdSchema,
201
+ operation: AgentOperationSchema,
202
+ before: z.unknown().nullable(),
203
+ after: z.unknown().nullable(),
204
+ summary: z.string().min(1),
205
+ createdAt: TimestampSchema,
206
+ undoneAt: TimestampSchema.nullable(),
207
+ undoneBy: IdSchema.nullable(),
208
+ /** Jeton d'agent qui a fait l'action. */
209
+ tokenId: IdSchema.nullable(),
210
+ });
211
+ /** Instantané d'une tâche : ses champs, ses assignés et ses tags. */
212
+ export const TaskSnapshotSchema = TaskSchema.extend({
213
+ assigneeIds: z.array(IdSchema),
214
+ tagIds: z.array(IdSchema),
215
+ });
216
+ /** Champs d'une tâche que l'historique compare et restaure (assignés et tags compris). */
217
+ export const TASK_RESTORABLE_FIELDS = ["title", "description", "status", "priority", "type", "parentId", "testedTaskId", "assigneeIds", "tagIds"];
218
+ /** Instantané d'une idée. */
219
+ export const IdeaSnapshotSchema = IdeaSchema;
220
+ /**
221
+ * Version d'une entité versionnée. `snapshot` vaut null pour la version qui
222
+ * enregistre la suppression. Pour une action de l'agent, `actorId` est le
223
+ * propriétaire du jeton, au nom de qui l'agent agit, et `tokenId` ce jeton.
224
+ */
225
+ export const EntityVersionSchema = z.object({
226
+ entityType: VersionedEntityTypeSchema,
227
+ entityId: IdSchema,
228
+ version: z.number().int().min(1),
229
+ snapshot: z.union([TaskSnapshotSchema, IdeaSnapshotSchema]).nullable(),
230
+ actorType: ActorTypeSchema,
231
+ actorId: IdSchema,
232
+ requestId: IdSchema.nullable(),
233
+ tokenId: IdSchema.nullable(),
234
+ createdAt: TimestampSchema,
235
+ });
236
+ export const NotificationSchema = z.object({
237
+ id: IdSchema,
238
+ userId: IdSchema,
239
+ type: NotificationTypeSchema,
240
+ taskId: IdSchema,
241
+ actorType: ActorTypeSchema,
242
+ actorId: IdSchema.nullable(),
243
+ requestId: IdSchema.nullable(),
244
+ commentId: IdSchema.nullable(),
245
+ /** Faux quand le destinataire a désactivé ce type de notification dans l'application : la ligne ne suit alors que l'envoi de l'e-mail. */
246
+ inApp: z.boolean(),
247
+ createdAt: TimestampSchema,
248
+ readAt: TimestampSchema.nullable(),
249
+ emailedAt: TimestampSchema.nullable(),
250
+ emailError: z.string().nullable(),
251
+ });
252
+ /** Ligne du journal des changements, lu par le polling de la GUI. */
253
+ export const ChangeSchema = z.object({
254
+ seq: z.number().int().min(1),
255
+ spaceId: IdSchema.nullable(),
256
+ userId: IdSchema.nullable(),
257
+ entityType: EntityTypeSchema,
258
+ entityId: IdSchema,
259
+ /** Tâche concernée : la tâche modifiée, ou celle qui porte l'élément modifié (checklist, commentaire…). */
260
+ taskId: IdSchema.nullable(),
261
+ at: TimestampSchema,
262
+ });
@@ -0,0 +1,135 @@
1
+ import { z } from "zod";
2
+ /** Valeurs énumérées du modèle de données, partagées par le serveur et la GUI. */
3
+ export declare const USER_STATUSES: readonly ["invited", "active", "disabled"];
4
+ export declare const UserStatusSchema: z.ZodEnum<{
5
+ active: "active";
6
+ disabled: "disabled";
7
+ invited: "invited";
8
+ }>;
9
+ export type UserStatus = z.infer<typeof UserStatusSchema>;
10
+ export declare const ACCESS_LINK_PURPOSES: readonly ["invite", "reset"];
11
+ export declare const AccessLinkPurposeSchema: z.ZodEnum<{
12
+ invite: "invite";
13
+ reset: "reset";
14
+ }>;
15
+ export type AccessLinkPurpose = z.infer<typeof AccessLinkPurposeSchema>;
16
+ export declare const SPACE_KINDS: readonly ["personal", "shared"];
17
+ export declare const SpaceKindSchema: z.ZodEnum<{
18
+ personal: "personal";
19
+ shared: "shared";
20
+ }>;
21
+ export type SpaceKind = z.infer<typeof SpaceKindSchema>;
22
+ export declare const MEMBER_ROLES: readonly ["owner", "member"];
23
+ export declare const MemberRoleSchema: z.ZodEnum<{
24
+ member: "member";
25
+ owner: "owner";
26
+ }>;
27
+ export type MemberRole = z.infer<typeof MemberRoleSchema>;
28
+ export declare const TASK_TYPES: readonly ["standard", "test"];
29
+ export declare const TaskTypeSchema: z.ZodEnum<{
30
+ standard: "standard";
31
+ test: "test";
32
+ }>;
33
+ export type TaskType = z.infer<typeof TaskTypeSchema>;
34
+ /** Colonnes du Kanban, dans l'ordre d'affichage. */
35
+ export declare const TASK_STATUSES: readonly ["todo", "doing", "review", "done"];
36
+ export declare const TaskStatusSchema: z.ZodEnum<{
37
+ doing: "doing";
38
+ done: "done";
39
+ review: "review";
40
+ todo: "todo";
41
+ }>;
42
+ export type TaskStatus = z.infer<typeof TaskStatusSchema>;
43
+ export declare const TASK_PRIORITIES: readonly ["low", "medium", "high", "critical"];
44
+ export declare const TaskPrioritySchema: z.ZodEnum<{
45
+ critical: "critical";
46
+ high: "high";
47
+ low: "low";
48
+ medium: "medium";
49
+ }>;
50
+ export type TaskPriority = z.infer<typeof TaskPrioritySchema>;
51
+ /** Profondeur maximale d'une tâche : tâche (0) > sous-tâche (1) > sous-sous-tâche (2). */
52
+ export declare const MAX_TASK_DEPTH = 2;
53
+ export declare const TEST_RESULTS: readonly ["ok", "ko", "blocked", "untested"];
54
+ export declare const TestResultValueSchema: z.ZodEnum<{
55
+ blocked: "blocked";
56
+ ko: "ko";
57
+ ok: "ok";
58
+ untested: "untested";
59
+ }>;
60
+ export type TestResultValue = z.infer<typeof TestResultValueSchema>;
61
+ export declare const IDEA_ORIGINS: readonly ["manual", "agent"];
62
+ export declare const IdeaOriginSchema: z.ZodEnum<{
63
+ agent: "agent";
64
+ manual: "manual";
65
+ }>;
66
+ export type IdeaOrigin = z.infer<typeof IdeaOriginSchema>;
67
+ export declare const REQUEST_KINDS: readonly ["idea", "remark", "test_review", "message", "idea_promotion"];
68
+ export declare const RequestKindSchema: z.ZodEnum<{
69
+ idea: "idea";
70
+ idea_promotion: "idea_promotion";
71
+ message: "message";
72
+ remark: "remark";
73
+ test_review: "test_review";
74
+ }>;
75
+ export type RequestKind = z.infer<typeof RequestKindSchema>;
76
+ export declare const REQUEST_STATUSES: readonly ["pending", "processing", "done", "failed", "cancelled"];
77
+ export declare const RequestStatusSchema: z.ZodEnum<{
78
+ cancelled: "cancelled";
79
+ done: "done";
80
+ failed: "failed";
81
+ pending: "pending";
82
+ processing: "processing";
83
+ }>;
84
+ export type RequestStatus = z.infer<typeof RequestStatusSchema>;
85
+ export declare const AGENT_OPERATIONS: readonly ["create", "update", "delete", "move", "assign"];
86
+ export declare const AgentOperationSchema: z.ZodEnum<{
87
+ assign: "assign";
88
+ create: "create";
89
+ delete: "delete";
90
+ move: "move";
91
+ update: "update";
92
+ }>;
93
+ export type AgentOperation = z.infer<typeof AgentOperationSchema>;
94
+ export declare const ACTOR_TYPES: readonly ["user", "agent"];
95
+ export declare const ActorTypeSchema: z.ZodEnum<{
96
+ agent: "agent";
97
+ user: "user";
98
+ }>;
99
+ export type ActorType = z.infer<typeof ActorTypeSchema>;
100
+ export declare const NOTIFICATION_TYPES: readonly ["assigned", "comment"];
101
+ export declare const NotificationTypeSchema: z.ZodEnum<{
102
+ assigned: "assigned";
103
+ comment: "comment";
104
+ }>;
105
+ export type NotificationType = z.infer<typeof NotificationTypeSchema>;
106
+ /** Types d'entités nommés dans le journal `Change`, les versions et les actions de l'agent. */
107
+ export declare const ENTITY_TYPES: readonly ["user", "user_settings", "space", "membership", "invitation", "task", "tag", "checklist_item", "test_checkpoint", "test_result", "test_review", "comment", "attachment", "idea", "agent_request", "agent_action", "agent_token", "notification"];
108
+ export declare const EntityTypeSchema: z.ZodEnum<{
109
+ agent_action: "agent_action";
110
+ agent_request: "agent_request";
111
+ agent_token: "agent_token";
112
+ attachment: "attachment";
113
+ checklist_item: "checklist_item";
114
+ comment: "comment";
115
+ idea: "idea";
116
+ invitation: "invitation";
117
+ membership: "membership";
118
+ notification: "notification";
119
+ space: "space";
120
+ tag: "tag";
121
+ task: "task";
122
+ test_checkpoint: "test_checkpoint";
123
+ test_result: "test_result";
124
+ test_review: "test_review";
125
+ user: "user";
126
+ user_settings: "user_settings";
127
+ }>;
128
+ export type EntityType = z.infer<typeof EntityTypeSchema>;
129
+ /** Entités dont chaque modification produit une `EntityVersion`. */
130
+ export declare const VERSIONED_ENTITY_TYPES: readonly ["task", "idea"];
131
+ export declare const VersionedEntityTypeSchema: z.ZodEnum<{
132
+ idea: "idea";
133
+ task: "task";
134
+ }>;
135
+ export type VersionedEntityType = z.infer<typeof VersionedEntityTypeSchema>;
@@ -0,0 +1,58 @@
1
+ import { z } from "zod";
2
+ /** Valeurs énumérées du modèle de données, partagées par le serveur et la GUI. */
3
+ export const USER_STATUSES = ["invited", "active", "disabled"];
4
+ export const UserStatusSchema = z.enum(USER_STATUSES);
5
+ export const ACCESS_LINK_PURPOSES = ["invite", "reset"];
6
+ export const AccessLinkPurposeSchema = z.enum(ACCESS_LINK_PURPOSES);
7
+ export const SPACE_KINDS = ["personal", "shared"];
8
+ export const SpaceKindSchema = z.enum(SPACE_KINDS);
9
+ export const MEMBER_ROLES = ["owner", "member"];
10
+ export const MemberRoleSchema = z.enum(MEMBER_ROLES);
11
+ export const TASK_TYPES = ["standard", "test"];
12
+ export const TaskTypeSchema = z.enum(TASK_TYPES);
13
+ /** Colonnes du Kanban, dans l'ordre d'affichage. */
14
+ export const TASK_STATUSES = ["todo", "doing", "review", "done"];
15
+ export const TaskStatusSchema = z.enum(TASK_STATUSES);
16
+ export const TASK_PRIORITIES = ["low", "medium", "high", "critical"];
17
+ export const TaskPrioritySchema = z.enum(TASK_PRIORITIES);
18
+ /** Profondeur maximale d'une tâche : tâche (0) > sous-tâche (1) > sous-sous-tâche (2). */
19
+ export const MAX_TASK_DEPTH = 2;
20
+ export const TEST_RESULTS = ["ok", "ko", "blocked", "untested"];
21
+ export const TestResultValueSchema = z.enum(TEST_RESULTS);
22
+ export const IDEA_ORIGINS = ["manual", "agent"];
23
+ export const IdeaOriginSchema = z.enum(IDEA_ORIGINS);
24
+ export const REQUEST_KINDS = ["idea", "remark", "test_review", "message", "idea_promotion"];
25
+ export const RequestKindSchema = z.enum(REQUEST_KINDS);
26
+ export const REQUEST_STATUSES = ["pending", "processing", "done", "failed", "cancelled"];
27
+ export const RequestStatusSchema = z.enum(REQUEST_STATUSES);
28
+ export const AGENT_OPERATIONS = ["create", "update", "delete", "move", "assign"];
29
+ export const AgentOperationSchema = z.enum(AGENT_OPERATIONS);
30
+ export const ACTOR_TYPES = ["user", "agent"];
31
+ export const ActorTypeSchema = z.enum(ACTOR_TYPES);
32
+ export const NOTIFICATION_TYPES = ["assigned", "comment"];
33
+ export const NotificationTypeSchema = z.enum(NOTIFICATION_TYPES);
34
+ /** Types d'entités nommés dans le journal `Change`, les versions et les actions de l'agent. */
35
+ export const ENTITY_TYPES = [
36
+ "user",
37
+ "user_settings",
38
+ "space",
39
+ "membership",
40
+ "invitation",
41
+ "task",
42
+ "tag",
43
+ "checklist_item",
44
+ "test_checkpoint",
45
+ "test_result",
46
+ "test_review",
47
+ "comment",
48
+ "attachment",
49
+ "idea",
50
+ "agent_request",
51
+ "agent_action",
52
+ "agent_token",
53
+ "notification",
54
+ ];
55
+ export const EntityTypeSchema = z.enum(ENTITY_TYPES);
56
+ /** Entités dont chaque modification produit une `EntityVersion`. */
57
+ export const VERSIONED_ENTITY_TYPES = ["task", "idea"];
58
+ export const VersionedEntityTypeSchema = z.enum(VERSIONED_ENTITY_TYPES);
@@ -0,0 +1,53 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Nature d'une erreur de l'API de la GUI, qui fixe son code HTTP :
4
+ * invalid → 400, unauthorized → 401, forbidden → 403, not_found → 404,
5
+ * conflict → 409, too_large → 413, internal → 500, upstream → 502 (service
6
+ * externe), unavailable → 503.
7
+ */
8
+ export declare const API_ERROR_KINDS: readonly ["invalid", "unauthorized", "forbidden", "not_found", "conflict", "too_large", "internal", "upstream", "unavailable"];
9
+ export type ApiErrorKind = (typeof API_ERROR_KINDS)[number];
10
+ /** Requête `/api/*` de la GUI, telle que le serveur web la transmet au routeur de l'API. */
11
+ export interface ApiRequestData {
12
+ method: string;
13
+ /** Chemin sous `/api`, par exemple `/health`. */
14
+ path: string;
15
+ query: Record<string, string>;
16
+ body?: unknown;
17
+ /** Valeur du cookie de session transmise par le navigateur, null sans cookie. */
18
+ sessionToken: string | null;
19
+ }
20
+ /** Session à poser dans le cookie du navigateur : jeton opaque et fin de validité (ISO 8601). */
21
+ export interface SessionCookie {
22
+ token: string;
23
+ expiresAt: string;
24
+ }
25
+ /** Fichier renvoyé tel quel au navigateur (téléchargement d'une pièce jointe). */
26
+ export interface ApiFile {
27
+ contentBase64: string;
28
+ mime: string;
29
+ filename: string;
30
+ }
31
+ /**
32
+ * Réponse du routeur de l'API à une requête `/api/*`. `session` pose (ou
33
+ * prolonge) le cookie de session ; `null` l'efface ; absent, le cookie est
34
+ * laissé tel quel. Avec `file`, le serveur web renvoie ce fichier au lieu du
35
+ * corps JSON.
36
+ */
37
+ export interface ApiResponseData {
38
+ body: unknown;
39
+ session?: SessionCookie | null;
40
+ file?: ApiFile;
41
+ }
42
+ /** En-tête posé sur une erreur relayée d'un service externe : un 401 de Groq ne ferme pas la session. */
43
+ export declare const UPSTREAM_ERROR_HEADER = "X-Organizer-Error-Source";
44
+ /** Nom du cookie de session de la GUI. */
45
+ export declare const SESSION_COOKIE_NAME = "organizer_session";
46
+ /** Réponse de `GET /api/health`. */
47
+ export declare const HealthResponseSchema: z.ZodObject<{
48
+ status: z.ZodLiteral<"ok">;
49
+ version: z.ZodString;
50
+ schemaVersion: z.ZodNumber;
51
+ accountsExist: z.ZodBoolean;
52
+ }, z.core.$strip>;
53
+ export type HealthResponse = z.infer<typeof HealthResponseSchema>;
@@ -0,0 +1,20 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Nature d'une erreur de l'API de la GUI, qui fixe son code HTTP :
4
+ * invalid → 400, unauthorized → 401, forbidden → 403, not_found → 404,
5
+ * conflict → 409, too_large → 413, internal → 500, upstream → 502 (service
6
+ * externe), unavailable → 503.
7
+ */
8
+ export const API_ERROR_KINDS = ["invalid", "unauthorized", "forbidden", "not_found", "conflict", "too_large", "internal", "upstream", "unavailable"];
9
+ /** En-tête posé sur une erreur relayée d'un service externe : un 401 de Groq ne ferme pas la session. */
10
+ export const UPSTREAM_ERROR_HEADER = "X-Organizer-Error-Source";
11
+ /** Nom du cookie de session de la GUI. */
12
+ export const SESSION_COOKIE_NAME = "organizer_session";
13
+ /** Réponse de `GET /api/health`. */
14
+ export const HealthResponseSchema = z.object({
15
+ status: z.literal("ok"),
16
+ version: z.string(),
17
+ schemaVersion: z.number().int(),
18
+ /** Faux tant qu'aucun compte n'existe : la connexion est alors impossible. */
19
+ accountsExist: z.boolean(),
20
+ });
@@ -0,0 +1,81 @@
1
+ import { z } from "zod";
2
+ /** Corps des requêtes et des réponses de la boîte à idées de la GUI. */
3
+ export declare const MAX_IDEA_LENGTH = 5000;
4
+ export declare const IdeaTextSchema: z.ZodString;
5
+ /** Idée telle que l'affiche la page Idées. */
6
+ export declare const IdeaViewSchema: z.ZodObject<{
7
+ id: z.ZodString;
8
+ text: z.ZodString;
9
+ origin: z.ZodEnum<{
10
+ agent: "agent";
11
+ manual: "manual";
12
+ }>;
13
+ authorId: z.ZodString;
14
+ authorName: z.ZodString;
15
+ createdAt: z.ZodISODateTime;
16
+ archivedAt: z.ZodNullable<z.ZodISODateTime>;
17
+ promotedTask: z.ZodNullable<z.ZodObject<{
18
+ id: z.ZodString;
19
+ key: z.ZodString;
20
+ title: z.ZodString;
21
+ }, z.core.$strip>>;
22
+ pendingPromotion: z.ZodNullable<z.ZodObject<{
23
+ requestId: z.ZodString;
24
+ status: z.ZodEnum<{
25
+ pending: "pending";
26
+ processing: "processing";
27
+ }>;
28
+ }, z.core.$strip>>;
29
+ }, z.core.$strip>;
30
+ export type IdeaView = z.infer<typeof IdeaViewSchema>;
31
+ export declare const IdeaListResponseSchema: z.ZodObject<{
32
+ ideas: z.ZodArray<z.ZodObject<{
33
+ id: z.ZodString;
34
+ text: z.ZodString;
35
+ origin: z.ZodEnum<{
36
+ agent: "agent";
37
+ manual: "manual";
38
+ }>;
39
+ authorId: z.ZodString;
40
+ authorName: z.ZodString;
41
+ createdAt: z.ZodISODateTime;
42
+ archivedAt: z.ZodNullable<z.ZodISODateTime>;
43
+ promotedTask: z.ZodNullable<z.ZodObject<{
44
+ id: z.ZodString;
45
+ key: z.ZodString;
46
+ title: z.ZodString;
47
+ }, z.core.$strip>>;
48
+ pendingPromotion: z.ZodNullable<z.ZodObject<{
49
+ requestId: z.ZodString;
50
+ status: z.ZodEnum<{
51
+ pending: "pending";
52
+ processing: "processing";
53
+ }>;
54
+ }, z.core.$strip>>;
55
+ }, z.core.$strip>>;
56
+ activeCount: z.ZodNumber;
57
+ }, z.core.$strip>;
58
+ export type IdeaListResponse = z.infer<typeof IdeaListResponseSchema>;
59
+ export declare const CreateIdeaRequestSchema: z.ZodObject<{
60
+ text: z.ZodString;
61
+ }, z.core.$strip>;
62
+ export type CreateIdeaRequest = z.infer<typeof CreateIdeaRequestSchema>;
63
+ export declare const UpdateIdeaRequestSchema: z.ZodObject<{
64
+ archived: z.ZodBoolean;
65
+ }, z.core.$strip>;
66
+ export type UpdateIdeaRequest = z.infer<typeof UpdateIdeaRequestSchema>;
67
+ /** Promotion manuelle : la tâche créée en colonne « À faire », avec l'idée pour description. */
68
+ export declare const PromoteIdeaRequestSchema: z.ZodObject<{
69
+ title: z.ZodString;
70
+ type: z.ZodEnum<{
71
+ standard: "standard";
72
+ test: "test";
73
+ }>;
74
+ priority: z.ZodEnum<{
75
+ critical: "critical";
76
+ high: "high";
77
+ low: "low";
78
+ medium: "medium";
79
+ }>;
80
+ }, z.core.$strip>;
81
+ export type PromoteIdeaRequest = z.infer<typeof PromoteIdeaRequestSchema>;
@@ -0,0 +1,40 @@
1
+ import { z } from "zod";
2
+ import { IdeaOriginSchema, TaskPrioritySchema, TaskTypeSchema } from "./enums.schema.js";
3
+ import { IdSchema, TimestampSchema } from "./entities.schema.js";
4
+ import { TaskRefSchema, TaskTitleSchema } from "./tasks-api.schema.js";
5
+ /** Corps des requêtes et des réponses de la boîte à idées de la GUI. */
6
+ export const MAX_IDEA_LENGTH = 5_000;
7
+ export const IdeaTextSchema = z
8
+ .string()
9
+ .trim()
10
+ .min(1, "L'idée est vide : écrivez-la avant de l'ajouter.")
11
+ .max(MAX_IDEA_LENGTH, `L'idée dépasse ${MAX_IDEA_LENGTH} caractères.`);
12
+ /** Idée telle que l'affiche la page Idées. */
13
+ export const IdeaViewSchema = z.object({
14
+ id: IdSchema,
15
+ text: z.string(),
16
+ /** `agent` pour une idée classée par l'agent dans la boîte. */
17
+ origin: IdeaOriginSchema,
18
+ authorId: IdSchema,
19
+ authorName: z.string(),
20
+ createdAt: TimestampSchema,
21
+ archivedAt: TimestampSchema.nullable(),
22
+ /** Tâche issue de l'idée, si elle a été promue et que la tâche existe. */
23
+ promotedTask: TaskRefSchema.nullable(),
24
+ /** Promotion confiée à l'agent, en attente ou en cours de traitement. */
25
+ pendingPromotion: z.object({ requestId: IdSchema, status: z.enum(["pending", "processing"]) }).nullable(),
26
+ });
27
+ export const IdeaListResponseSchema = z.object({
28
+ /** Idées de l'espace, de la plus récente à la plus ancienne : actives, archivées et promues. */
29
+ ideas: z.array(IdeaViewSchema),
30
+ /** Idées ni archivées ni promues. */
31
+ activeCount: z.number().int().min(0),
32
+ });
33
+ export const CreateIdeaRequestSchema = z.object({ text: IdeaTextSchema });
34
+ export const UpdateIdeaRequestSchema = z.object({ archived: z.boolean() });
35
+ /** Promotion manuelle : la tâche créée en colonne « À faire », avec l'idée pour description. */
36
+ export const PromoteIdeaRequestSchema = z.object({
37
+ title: TaskTitleSchema,
38
+ type: TaskTypeSchema,
39
+ priority: TaskPrioritySchema,
40
+ });