@imenam/mcp-organizer 1.0.16 → 1.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -32
- package/dist/shared/schemas/admin-api.schema.d.ts +29 -0
- package/dist/shared/schemas/admin-api.schema.js +24 -0
- package/dist/shared/schemas/agent-api.schema.d.ts +3 -0
- package/dist/shared/schemas/agent-tools.schema.d.ts +149 -0
- package/dist/shared/schemas/agent-tools.schema.js +49 -1
- package/dist/shared/schemas/entities.schema.d.ts +56 -0
- package/dist/shared/schemas/entities.schema.js +33 -0
- package/dist/shared/schemas/enums.schema.d.ts +2 -1
- package/dist/shared/schemas/enums.schema.js +1 -0
- package/dist/shared/schemas/tasks-api.schema.d.ts +51 -0
- package/dist/shared/schemas/tasks-api.schema.js +23 -1
- package/dist/src/agent-api/questions.d.ts +15 -0
- package/dist/src/agent-api/questions.js +128 -0
- package/dist/src/agent-api/router.js +2 -1
- package/dist/src/agent-api/tasks.js +5 -0
- package/dist/src/cli/setup.js +5 -11
- package/dist/src/core/claude-connection.d.ts +31 -0
- package/dist/src/core/claude-connection.js +127 -0
- package/dist/src/core/history.js +21 -1
- package/dist/src/core/migrations.js +36 -0
- package/dist/src/core/questions.d.ts +13 -0
- package/dist/src/core/questions.js +33 -0
- package/dist/src/core/snapshots.d.ts +3 -3
- package/dist/src/core/snapshots.js +3 -1
- package/dist/src/core/store.d.ts +61 -2
- package/dist/src/core/store.js +240 -2
- package/dist/src/core/tasks.js +2 -0
- package/dist/src/deploy/env-render.js +1 -1
- package/dist/src/gui-api.d.ts +8 -1
- package/dist/src/gui-api.js +25 -7
- package/dist/src/mcp/start.d.ts +1 -1
- package/dist/src/mcp/start.js +2 -2
- package/dist/src/mcp/tools.js +55 -3
- package/dist/src/server/runner.d.ts +10 -0
- package/dist/src/server/runner.js +80 -8
- package/dist/src/server/start.js +8 -3
- package/gui/dist/assets/index-BJHJo6-f.css +1 -0
- package/gui/dist/assets/index-vy2WydDd.js +99 -0
- package/gui/dist/index.html +2 -2
- package/package.json +1 -1
- package/gui/dist/assets/index-DrGANOy-.css +0 -1
- package/gui/dist/assets/index-hlJlOrjE.js +0 -99
|
@@ -201,6 +201,60 @@ export declare const ChecklistItemSchema: z.ZodObject<{
|
|
|
201
201
|
position: z.ZodNumber;
|
|
202
202
|
}, z.core.$strip>;
|
|
203
203
|
export type ChecklistItem = z.infer<typeof ChecklistItemSchema>;
|
|
204
|
+
export declare const MAX_QUESTION_LENGTH = 500;
|
|
205
|
+
export declare const MAX_QUESTION_OPTION_LABEL_LENGTH = 200;
|
|
206
|
+
export declare const MAX_QUESTION_OPTION_DETAIL_LENGTH = 4000;
|
|
207
|
+
export declare const MAX_QUESTION_OPTIONS = 10;
|
|
208
|
+
export declare const MAX_OTHER_ANSWER_LENGTH = 4000;
|
|
209
|
+
/**
|
|
210
|
+
* Question posée par l'agent dans une tâche : un choix unique ou multiple
|
|
211
|
+
* parmi des propositions, et une réponse libre (`otherAnswer`). Pour un choix
|
|
212
|
+
* unique, la réponse est une proposition ou la réponse libre, pas les deux.
|
|
213
|
+
* `answeredBy` et `answeredAt` désignent le membre qui a répondu en dernier.
|
|
214
|
+
*/
|
|
215
|
+
export declare const TaskQuestionSchema: z.ZodObject<{
|
|
216
|
+
id: z.ZodString;
|
|
217
|
+
taskId: z.ZodString;
|
|
218
|
+
text: z.ZodString;
|
|
219
|
+
multiple: z.ZodBoolean;
|
|
220
|
+
otherAnswer: z.ZodNullable<z.ZodString>;
|
|
221
|
+
answeredBy: z.ZodNullable<z.ZodString>;
|
|
222
|
+
answeredAt: z.ZodNullable<z.ZodISODateTime>;
|
|
223
|
+
position: z.ZodNumber;
|
|
224
|
+
}, z.core.$strip>;
|
|
225
|
+
export type TaskQuestion = z.infer<typeof TaskQuestionSchema>;
|
|
226
|
+
/** Proposition d'une question : libellé, détail en markdown, recommandation de l'agent et choix du membre. */
|
|
227
|
+
export declare const QuestionOptionSchema: z.ZodObject<{
|
|
228
|
+
id: z.ZodString;
|
|
229
|
+
questionId: z.ZodString;
|
|
230
|
+
label: z.ZodString;
|
|
231
|
+
detail: z.ZodString;
|
|
232
|
+
recommended: z.ZodBoolean;
|
|
233
|
+
selected: z.ZodBoolean;
|
|
234
|
+
position: z.ZodNumber;
|
|
235
|
+
}, z.core.$strip>;
|
|
236
|
+
export type QuestionOption = z.infer<typeof QuestionOptionSchema>;
|
|
237
|
+
/** Question avec ses propositions, dans l'ordre : l'état que l'agent modifie et que l'annulation restaure. */
|
|
238
|
+
export declare const QuestionSnapshotSchema: z.ZodObject<{
|
|
239
|
+
id: z.ZodString;
|
|
240
|
+
taskId: z.ZodString;
|
|
241
|
+
text: z.ZodString;
|
|
242
|
+
multiple: z.ZodBoolean;
|
|
243
|
+
otherAnswer: z.ZodNullable<z.ZodString>;
|
|
244
|
+
answeredBy: z.ZodNullable<z.ZodString>;
|
|
245
|
+
answeredAt: z.ZodNullable<z.ZodISODateTime>;
|
|
246
|
+
position: z.ZodNumber;
|
|
247
|
+
options: z.ZodArray<z.ZodObject<{
|
|
248
|
+
id: z.ZodString;
|
|
249
|
+
questionId: z.ZodString;
|
|
250
|
+
label: z.ZodString;
|
|
251
|
+
detail: z.ZodString;
|
|
252
|
+
recommended: z.ZodBoolean;
|
|
253
|
+
selected: z.ZodBoolean;
|
|
254
|
+
position: z.ZodNumber;
|
|
255
|
+
}, z.core.$strip>>;
|
|
256
|
+
}, z.core.$strip>;
|
|
257
|
+
export type QuestionSnapshot = z.infer<typeof QuestionSnapshotSchema>;
|
|
204
258
|
export declare const TestCheckpointSchema: z.ZodObject<{
|
|
205
259
|
id: z.ZodString;
|
|
206
260
|
taskId: z.ZodString;
|
|
@@ -391,6 +445,7 @@ export declare const AgentActionSchema: z.ZodObject<{
|
|
|
391
445
|
space: "space";
|
|
392
446
|
tag: "tag";
|
|
393
447
|
task: "task";
|
|
448
|
+
task_question: "task_question";
|
|
394
449
|
test_checkpoint: "test_checkpoint";
|
|
395
450
|
test_result: "test_result";
|
|
396
451
|
test_review: "test_review";
|
|
@@ -581,6 +636,7 @@ export declare const ChangeSchema: z.ZodObject<{
|
|
|
581
636
|
space: "space";
|
|
582
637
|
tag: "tag";
|
|
583
638
|
task: "task";
|
|
639
|
+
task_question: "task_question";
|
|
584
640
|
test_checkpoint: "test_checkpoint";
|
|
585
641
|
test_result: "test_result";
|
|
586
642
|
test_review: "test_review";
|
|
@@ -152,6 +152,39 @@ export const ChecklistItemSchema = z.object({
|
|
|
152
152
|
done: z.boolean(),
|
|
153
153
|
position: PositionSchema,
|
|
154
154
|
});
|
|
155
|
+
export const MAX_QUESTION_LENGTH = 500;
|
|
156
|
+
export const MAX_QUESTION_OPTION_LABEL_LENGTH = 200;
|
|
157
|
+
export const MAX_QUESTION_OPTION_DETAIL_LENGTH = 4000;
|
|
158
|
+
export const MAX_QUESTION_OPTIONS = 10;
|
|
159
|
+
export const MAX_OTHER_ANSWER_LENGTH = 4000;
|
|
160
|
+
/**
|
|
161
|
+
* Question posée par l'agent dans une tâche : un choix unique ou multiple
|
|
162
|
+
* parmi des propositions, et une réponse libre (`otherAnswer`). Pour un choix
|
|
163
|
+
* unique, la réponse est une proposition ou la réponse libre, pas les deux.
|
|
164
|
+
* `answeredBy` et `answeredAt` désignent le membre qui a répondu en dernier.
|
|
165
|
+
*/
|
|
166
|
+
export const TaskQuestionSchema = z.object({
|
|
167
|
+
id: IdSchema,
|
|
168
|
+
taskId: IdSchema,
|
|
169
|
+
text: z.string().trim().min(1).max(MAX_QUESTION_LENGTH),
|
|
170
|
+
multiple: z.boolean(),
|
|
171
|
+
otherAnswer: z.string().trim().min(1).max(MAX_OTHER_ANSWER_LENGTH).nullable(),
|
|
172
|
+
answeredBy: IdSchema.nullable(),
|
|
173
|
+
answeredAt: TimestampSchema.nullable(),
|
|
174
|
+
position: PositionSchema,
|
|
175
|
+
});
|
|
176
|
+
/** Proposition d'une question : libellé, détail en markdown, recommandation de l'agent et choix du membre. */
|
|
177
|
+
export const QuestionOptionSchema = z.object({
|
|
178
|
+
id: IdSchema,
|
|
179
|
+
questionId: IdSchema,
|
|
180
|
+
label: z.string().trim().min(1).max(MAX_QUESTION_OPTION_LABEL_LENGTH),
|
|
181
|
+
detail: z.string().max(MAX_QUESTION_OPTION_DETAIL_LENGTH),
|
|
182
|
+
recommended: z.boolean(),
|
|
183
|
+
selected: z.boolean(),
|
|
184
|
+
position: PositionSchema,
|
|
185
|
+
});
|
|
186
|
+
/** Question avec ses propositions, dans l'ordre : l'état que l'agent modifie et que l'annulation restaure. */
|
|
187
|
+
export const QuestionSnapshotSchema = TaskQuestionSchema.extend({ options: z.array(QuestionOptionSchema) });
|
|
155
188
|
export const TestCheckpointSchema = z.object({
|
|
156
189
|
id: IdSchema,
|
|
157
190
|
taskId: IdSchema,
|
|
@@ -123,7 +123,7 @@ export declare const NotificationTypeSchema: z.ZodEnum<{
|
|
|
123
123
|
}>;
|
|
124
124
|
export type NotificationType = z.infer<typeof NotificationTypeSchema>;
|
|
125
125
|
/** Types d'entités nommés dans le journal `Change`, les versions et les actions de l'agent. */
|
|
126
|
-
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", "follow_up", "agent_token", "notification", "board_view", "agent_instructions"];
|
|
126
|
+
export declare const ENTITY_TYPES: readonly ["user", "user_settings", "space", "membership", "invitation", "task", "tag", "checklist_item", "task_question", "test_checkpoint", "test_result", "test_review", "comment", "attachment", "idea", "agent_request", "agent_action", "follow_up", "agent_token", "notification", "board_view", "agent_instructions"];
|
|
127
127
|
export declare const EntityTypeSchema: z.ZodEnum<{
|
|
128
128
|
agent_action: "agent_action";
|
|
129
129
|
agent_instructions: "agent_instructions";
|
|
@@ -141,6 +141,7 @@ export declare const EntityTypeSchema: z.ZodEnum<{
|
|
|
141
141
|
space: "space";
|
|
142
142
|
tag: "tag";
|
|
143
143
|
task: "task";
|
|
144
|
+
task_question: "task_question";
|
|
144
145
|
test_checkpoint: "test_checkpoint";
|
|
145
146
|
test_result: "test_result";
|
|
146
147
|
test_review: "test_review";
|
|
@@ -224,6 +224,32 @@ export declare const ChecklistItemViewSchema: z.ZodObject<{
|
|
|
224
224
|
position: z.ZodNumber;
|
|
225
225
|
}, z.core.$strip>;
|
|
226
226
|
export type ChecklistItemView = z.infer<typeof ChecklistItemViewSchema>;
|
|
227
|
+
/** Proposition d'une question : libellé, détail en markdown, recommandation de l'agent, choix des membres. */
|
|
228
|
+
export declare const QuestionOptionViewSchema: z.ZodObject<{
|
|
229
|
+
id: z.ZodString;
|
|
230
|
+
label: z.ZodString;
|
|
231
|
+
detail: z.ZodString;
|
|
232
|
+
recommended: z.ZodBoolean;
|
|
233
|
+
selected: z.ZodBoolean;
|
|
234
|
+
}, z.core.$strip>;
|
|
235
|
+
export type QuestionOptionView = z.infer<typeof QuestionOptionViewSchema>;
|
|
236
|
+
/** Question posée par l'agent : propositions, réponse libre, et membre qui a répondu en dernier. */
|
|
237
|
+
export declare const QuestionViewSchema: z.ZodObject<{
|
|
238
|
+
id: z.ZodString;
|
|
239
|
+
text: z.ZodString;
|
|
240
|
+
multiple: z.ZodBoolean;
|
|
241
|
+
options: z.ZodArray<z.ZodObject<{
|
|
242
|
+
id: z.ZodString;
|
|
243
|
+
label: z.ZodString;
|
|
244
|
+
detail: z.ZodString;
|
|
245
|
+
recommended: z.ZodBoolean;
|
|
246
|
+
selected: z.ZodBoolean;
|
|
247
|
+
}, z.core.$strip>>;
|
|
248
|
+
otherAnswer: z.ZodNullable<z.ZodString>;
|
|
249
|
+
answeredBy: z.ZodNullable<z.ZodString>;
|
|
250
|
+
answeredAt: z.ZodNullable<z.ZodISODateTime>;
|
|
251
|
+
}, z.core.$strip>;
|
|
252
|
+
export type QuestionView = z.infer<typeof QuestionViewSchema>;
|
|
227
253
|
/** Point à régler d'une demande traitée, tel que l'affichent la page Agent, sa modale et les commentaires d'une tâche. */
|
|
228
254
|
export declare const FollowUpViewSchema: z.ZodObject<{
|
|
229
255
|
id: z.ZodString;
|
|
@@ -498,6 +524,21 @@ export declare const TaskDetailResponseSchema: z.ZodObject<{
|
|
|
498
524
|
}, z.core.$strip>>;
|
|
499
525
|
children: z.ZodArray<z.ZodObject</*elided*/ any, z.core.$strip>>;
|
|
500
526
|
}, z.core.$strip>>;
|
|
527
|
+
questions: z.ZodArray<z.ZodObject<{
|
|
528
|
+
id: z.ZodString;
|
|
529
|
+
text: z.ZodString;
|
|
530
|
+
multiple: z.ZodBoolean;
|
|
531
|
+
options: z.ZodArray<z.ZodObject<{
|
|
532
|
+
id: z.ZodString;
|
|
533
|
+
label: z.ZodString;
|
|
534
|
+
detail: z.ZodString;
|
|
535
|
+
recommended: z.ZodBoolean;
|
|
536
|
+
selected: z.ZodBoolean;
|
|
537
|
+
}, z.core.$strip>>;
|
|
538
|
+
otherAnswer: z.ZodNullable<z.ZodString>;
|
|
539
|
+
answeredBy: z.ZodNullable<z.ZodString>;
|
|
540
|
+
answeredAt: z.ZodNullable<z.ZodISODateTime>;
|
|
541
|
+
}, z.core.$strip>>;
|
|
501
542
|
checklist: z.ZodArray<z.ZodObject<{
|
|
502
543
|
id: z.ZodString;
|
|
503
544
|
text: z.ZodString;
|
|
@@ -702,6 +743,15 @@ export declare const UpdateChecklistItemRequestSchema: z.ZodObject<{
|
|
|
702
743
|
done: z.ZodOptional<z.ZodBoolean>;
|
|
703
744
|
}, z.core.$strip>;
|
|
704
745
|
export type UpdateChecklistItemRequest = z.infer<typeof UpdateChecklistItemRequestSchema>;
|
|
746
|
+
/**
|
|
747
|
+
* Réponse à une question : propositions choisies et réponse libre, qui
|
|
748
|
+
* remplacent la réponse précédente ; un choix unique en prend une seule.
|
|
749
|
+
*/
|
|
750
|
+
export declare const AnswerQuestionRequestSchema: z.ZodObject<{
|
|
751
|
+
selectedOptionIds: z.ZodArray<z.ZodString>;
|
|
752
|
+
otherAnswer: z.ZodNullable<z.ZodString>;
|
|
753
|
+
}, z.core.$strip>;
|
|
754
|
+
export type AnswerQuestionRequest = z.infer<typeof AnswerQuestionRequestSchema>;
|
|
705
755
|
/** Réordonnancement : élément après lequel se placer (null : en tête). */
|
|
706
756
|
export declare const MoveAfterRequestSchema: z.ZodObject<{
|
|
707
757
|
afterId: z.ZodNullable<z.ZodString>;
|
|
@@ -774,6 +824,7 @@ export declare const ChangesResponseSchema: z.ZodObject<{
|
|
|
774
824
|
space: "space";
|
|
775
825
|
tag: "tag";
|
|
776
826
|
task: "task";
|
|
827
|
+
task_question: "task_question";
|
|
777
828
|
test_checkpoint: "test_checkpoint";
|
|
778
829
|
test_result: "test_result";
|
|
779
830
|
test_review: "test_review";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { RequestStatusSchema, TaskPrioritySchema, TaskStatusSchema, TaskTypeSchema, TestResultValueSchema } from "./enums.schema.js";
|
|
3
|
-
import { ChangeSchema, EmailSchema, IdSchema, PositionSchema, TimestampSchema } from "./entities.schema.js";
|
|
3
|
+
import { ChangeSchema, EmailSchema, IdSchema, MAX_OTHER_ANSWER_LENGTH, PositionSchema, TimestampSchema } from "./entities.schema.js";
|
|
4
4
|
/** Corps des requêtes et des réponses de l'API des tâches de la GUI. */
|
|
5
5
|
/** Taille maximale d'une pièce jointe : 20 Mo. */
|
|
6
6
|
export const MAX_ATTACHMENT_BYTES = 20 * 1024 * 1024;
|
|
@@ -95,6 +95,18 @@ export const TaskRefSchema = z.object({ id: IdSchema, key: z.string(), title: z.
|
|
|
95
95
|
/** `GET task-keys/:key` : espace du texte où la clé est écrite, préféré parmi ceux qui portent son préfixe. */
|
|
96
96
|
export const TaskKeyQuerySchema = z.object({ spaceId: IdSchema.optional() }).strict();
|
|
97
97
|
export const ChecklistItemViewSchema = z.object({ id: IdSchema, text: z.string(), done: z.boolean(), position: PositionSchema });
|
|
98
|
+
/** Proposition d'une question : libellé, détail en markdown, recommandation de l'agent, choix des membres. */
|
|
99
|
+
export const QuestionOptionViewSchema = z.object({ id: IdSchema, label: z.string(), detail: z.string(), recommended: z.boolean(), selected: z.boolean() });
|
|
100
|
+
/** Question posée par l'agent : propositions, réponse libre, et membre qui a répondu en dernier. */
|
|
101
|
+
export const QuestionViewSchema = z.object({
|
|
102
|
+
id: IdSchema,
|
|
103
|
+
text: z.string(),
|
|
104
|
+
multiple: z.boolean(),
|
|
105
|
+
options: z.array(QuestionOptionViewSchema),
|
|
106
|
+
otherAnswer: z.string().nullable(),
|
|
107
|
+
answeredBy: z.string().nullable(),
|
|
108
|
+
answeredAt: TimestampSchema.nullable(),
|
|
109
|
+
});
|
|
98
110
|
/** Point à régler d'une demande traitée, tel que l'affichent la page Agent, sa modale et les commentaires d'une tâche. */
|
|
99
111
|
export const FollowUpViewSchema = z.object({
|
|
100
112
|
id: IdSchema,
|
|
@@ -195,6 +207,8 @@ export const TaskDetailResponseSchema = z.object({
|
|
|
195
207
|
/** Tâche vérifiée par une tâche de test. */
|
|
196
208
|
testedTask: TaskRefSchema.nullable(),
|
|
197
209
|
children: z.array(TaskNodeSchema),
|
|
210
|
+
/** Questions posées par l'agent, dans l'ordre. */
|
|
211
|
+
questions: z.array(QuestionViewSchema),
|
|
198
212
|
checklist: z.array(ChecklistItemViewSchema),
|
|
199
213
|
/** Points de vérification, résultats et reviews d'une tâche de test ; null pour une tâche standard. */
|
|
200
214
|
test: TestDetailSchema.nullable(),
|
|
@@ -236,6 +250,14 @@ export const AddChecklistItemRequestSchema = z.object({ text: ChecklistTextSchem
|
|
|
236
250
|
export const UpdateChecklistItemRequestSchema = z
|
|
237
251
|
.object({ text: ChecklistTextSchema.optional(), done: z.boolean().optional() })
|
|
238
252
|
.refine((patch) => patch.text !== undefined || patch.done !== undefined, "Aucune modification demandée.");
|
|
253
|
+
/**
|
|
254
|
+
* Réponse à une question : propositions choisies et réponse libre, qui
|
|
255
|
+
* remplacent la réponse précédente ; un choix unique en prend une seule.
|
|
256
|
+
*/
|
|
257
|
+
export const AnswerQuestionRequestSchema = z.object({
|
|
258
|
+
selectedOptionIds: z.array(IdSchema),
|
|
259
|
+
otherAnswer: z.string().max(MAX_OTHER_ANSWER_LENGTH, `La réponse dépasse ${MAX_OTHER_ANSWER_LENGTH} caractères.`).nullable(),
|
|
260
|
+
});
|
|
239
261
|
/** Réordonnancement : élément après lequel se placer (null : en tête). */
|
|
240
262
|
export const MoveAfterRequestSchema = z.object({ afterId: IdSchema.nullable() });
|
|
241
263
|
export const CheckpointTextSchema = z.string().trim().min(1, "Le point de vérification est vide.").max(500);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type AgentQuestion } from "../../shared/schemas/agent-tools.schema.js";
|
|
2
|
+
import type { QuestionSnapshot } from "../../shared/schemas/entities.schema.js";
|
|
3
|
+
import type { Store } from "../core/store.js";
|
|
4
|
+
import { type AgentRoute } from "./types.js";
|
|
5
|
+
/**
|
|
6
|
+
* Questions d'une tâche : l'agent pose les questions et leurs propositions,
|
|
7
|
+
* les membres y répondent depuis le site. Les opérations s'appliquent en
|
|
8
|
+
* ordre, tout ou rien ; chacune est une action du lot sur la question.
|
|
9
|
+
*/
|
|
10
|
+
export declare const questionRoutes: AgentRoute[];
|
|
11
|
+
/** Questions d'une tâche avec leurs propositions, dans l'ordre. */
|
|
12
|
+
export declare function questionsOf(store: Store, taskId: string): QuestionSnapshot[];
|
|
13
|
+
export declare function questionData(store: Store, question: QuestionSnapshot): AgentQuestion;
|
|
14
|
+
/** Questions rédigées pour l'agent : propositions avec leur identifiant et leur détail, réponse des membres. */
|
|
15
|
+
export declare function questionLines(store: Store, questions: readonly QuestionSnapshot[]): string[];
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { EditQuestionsBodySchema, QuestionsDataSchema } from "../../shared/schemas/agent-tools.schema.js";
|
|
2
|
+
import { actFor, ago, quote, resolveTask, taskData, taskKey, userLabel } from "../core/agent.js";
|
|
3
|
+
import { NotFoundError, OrganizerError } from "../core/errors.js";
|
|
4
|
+
import { parseInput, respond } from "./types.js";
|
|
5
|
+
/**
|
|
6
|
+
* Questions d'une tâche : l'agent pose les questions et leurs propositions,
|
|
7
|
+
* les membres y répondent depuis le site. Les opérations s'appliquent en
|
|
8
|
+
* ordre, tout ou rien ; chacune est une action du lot sur la question.
|
|
9
|
+
*/
|
|
10
|
+
export const questionRoutes = [
|
|
11
|
+
{
|
|
12
|
+
method: "POST",
|
|
13
|
+
path: "/tasks/:ref/questions",
|
|
14
|
+
handle: ({ store }, { agent, params, body }) => {
|
|
15
|
+
const input = parseInput(EditQuestionsBodySchema, body);
|
|
16
|
+
const { task, outcomes } = actFor(store, agent, input.request_id, (tx, space) => {
|
|
17
|
+
const task = resolveTask(tx.store, space, params.ref);
|
|
18
|
+
return { task, outcomes: input.operations.map((operation) => apply(tx, task, operation)) };
|
|
19
|
+
});
|
|
20
|
+
const questions = questionsOf(store, task.id);
|
|
21
|
+
return respond(QuestionsDataSchema, `${taskKey(store, task)}: ${outcomes.join("; ")}.\n${questionLines(store, questions).join("\n")}`, {
|
|
22
|
+
task: taskData(store, task),
|
|
23
|
+
questions: questions.map((question) => questionData(store, question)),
|
|
24
|
+
});
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
];
|
|
28
|
+
/** Questions d'une tâche avec leurs propositions, dans l'ordre. */
|
|
29
|
+
export function questionsOf(store, taskId) {
|
|
30
|
+
return store.listQuestions(taskId).map((question) => store.questionSnapshot(question.id));
|
|
31
|
+
}
|
|
32
|
+
export function questionData(store, question) {
|
|
33
|
+
const author = question.answeredBy === null ? null : store.findUser(question.answeredBy);
|
|
34
|
+
return {
|
|
35
|
+
id: question.id,
|
|
36
|
+
text: question.text,
|
|
37
|
+
multiple: question.multiple,
|
|
38
|
+
options: question.options.map(({ id, label, detail, recommended, selected }) => ({ id, label, detail, recommended, selected })),
|
|
39
|
+
otherAnswer: question.otherAnswer,
|
|
40
|
+
answeredBy: question.answeredBy === null ? null : author ? userLabel(author) : "a former member",
|
|
41
|
+
answeredAt: question.answeredAt,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/** Questions rédigées pour l'agent : propositions avec leur identifiant et leur détail, réponse des membres. */
|
|
45
|
+
export function questionLines(store, questions) {
|
|
46
|
+
const answered = questions.filter((question) => question.answeredAt !== null).length;
|
|
47
|
+
const lines = [`Questions (${answered}/${questions.length} answered):`];
|
|
48
|
+
if (questions.length === 0)
|
|
49
|
+
return [...lines, "(none)"];
|
|
50
|
+
questions.forEach((question, index) => {
|
|
51
|
+
const data = questionData(store, question);
|
|
52
|
+
lines.push(`${index + 1}. ${question.text} (${question.multiple ? "multiple choice" : "single choice"}, id ${question.id})`);
|
|
53
|
+
for (const option of question.options) {
|
|
54
|
+
lines.push(` - [${option.selected ? "x" : " "}] ${option.label} (${option.recommended ? "recommended, " : ""}id ${option.id})`);
|
|
55
|
+
for (const line of option.detail.split(/\r?\n/).filter((text) => text.trim() !== ""))
|
|
56
|
+
lines.push(` ${line}`);
|
|
57
|
+
}
|
|
58
|
+
if (question.otherAnswer !== null)
|
|
59
|
+
lines.push(` Free answer: ${question.otherAnswer}`);
|
|
60
|
+
lines.push(data.answeredAt === null ? " Not answered yet." : ` Answered by ${data.answeredBy}, ${ago(data.answeredAt)}.`);
|
|
61
|
+
});
|
|
62
|
+
return lines;
|
|
63
|
+
}
|
|
64
|
+
function requireQuestion(tx, task, questionId) {
|
|
65
|
+
const question = tx.store.findQuestionSnapshot(questionId);
|
|
66
|
+
if (!question || question.taskId !== task.id)
|
|
67
|
+
throw new NotFoundError(`Question ${questionId} is not in this task. Call get_task to get the question ids.`);
|
|
68
|
+
return question;
|
|
69
|
+
}
|
|
70
|
+
function requireOption(tx, task, optionId) {
|
|
71
|
+
const option = tx.store.findQuestionOption(optionId);
|
|
72
|
+
const question = option === null ? null : tx.store.findQuestionSnapshot(option.questionId);
|
|
73
|
+
if (!question || question.taskId !== task.id)
|
|
74
|
+
throw new NotFoundError(`Option ${optionId} is not in this task. Call get_task to get the option ids.`);
|
|
75
|
+
return question;
|
|
76
|
+
}
|
|
77
|
+
/** Applique une opération et l'enregistre dans le lot ; renvoie sa description pour la réponse. */
|
|
78
|
+
function apply(tx, task, operation) {
|
|
79
|
+
const record = (operationType, before, after, summary) => tx.recordAgentAction({ entityType: "task_question", entityId: (after ?? before).id, operation: operationType, before, after, summary, taskId: task.id });
|
|
80
|
+
switch (operation.action) {
|
|
81
|
+
case "add_question": {
|
|
82
|
+
const question = tx.addQuestion(task.id, { text: operation.text, multiple: operation.multiple ?? false, options: operation.options });
|
|
83
|
+
record("create", null, question, `Question posée : ${quote(question.text)}`);
|
|
84
|
+
return `added question ${question.id}`;
|
|
85
|
+
}
|
|
86
|
+
case "update_question": {
|
|
87
|
+
if (operation.text === undefined && operation.multiple === undefined)
|
|
88
|
+
throw new OrganizerError(`Nothing to update on question ${operation.question_id}: give text or multiple.`);
|
|
89
|
+
const before = requireQuestion(tx, task, operation.question_id);
|
|
90
|
+
const after = tx.updateQuestion(before.id, { text: operation.text, multiple: operation.multiple });
|
|
91
|
+
const parts = [];
|
|
92
|
+
if (after.text !== before.text)
|
|
93
|
+
parts.push(`Question ${quote(before.text)} reformulée en ${quote(after.text)}`);
|
|
94
|
+
if (after.multiple !== before.multiple)
|
|
95
|
+
parts.push(`Question ${quote(after.text)} : ${after.multiple ? "plusieurs choix" : "un seul choix"}`);
|
|
96
|
+
record("update", before, after, parts.join(" · ") || `Question ${quote(after.text)} inchangée`);
|
|
97
|
+
return `updated question ${after.id}`;
|
|
98
|
+
}
|
|
99
|
+
case "delete_question": {
|
|
100
|
+
const before = requireQuestion(tx, task, operation.question_id);
|
|
101
|
+
tx.deleteQuestion(before.id);
|
|
102
|
+
record("delete", before, null, `Question supprimée : ${quote(before.text)}`);
|
|
103
|
+
return `deleted question ${before.id}`;
|
|
104
|
+
}
|
|
105
|
+
case "add_option": {
|
|
106
|
+
const before = requireQuestion(tx, task, operation.question_id);
|
|
107
|
+
const option = tx.addQuestionOption(before.id, { label: operation.label, detail: operation.detail, recommended: operation.recommended });
|
|
108
|
+
record("update", before, tx.store.questionSnapshot(before.id), `Proposition ${quote(option.label)} ajoutée à ${quote(before.text)}`);
|
|
109
|
+
return `added option ${option.id} to question ${before.id}`;
|
|
110
|
+
}
|
|
111
|
+
case "update_option": {
|
|
112
|
+
if (operation.label === undefined && operation.detail === undefined && operation.recommended === undefined) {
|
|
113
|
+
throw new OrganizerError(`Nothing to update on option ${operation.option_id}: give label, detail or recommended.`);
|
|
114
|
+
}
|
|
115
|
+
const before = requireOption(tx, task, operation.option_id);
|
|
116
|
+
const option = tx.updateQuestionOption(operation.option_id, { label: operation.label, detail: operation.detail, recommended: operation.recommended });
|
|
117
|
+
record("update", before, tx.store.questionSnapshot(before.id), `Proposition ${quote(option.label)} de ${quote(before.text)} modifiée`);
|
|
118
|
+
return `updated option ${option.id}`;
|
|
119
|
+
}
|
|
120
|
+
case "delete_option": {
|
|
121
|
+
const before = requireOption(tx, task, operation.option_id);
|
|
122
|
+
const label = before.options.find((option) => option.id === operation.option_id).label;
|
|
123
|
+
tx.deleteQuestionOption(operation.option_id);
|
|
124
|
+
record("update", before, tx.store.questionSnapshot(before.id), `Proposition ${quote(label)} retirée de ${quote(before.text)}`);
|
|
125
|
+
return `deleted option ${operation.option_id}`;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { resolveAgentToken } from "../core/agent-tokens.js";
|
|
2
2
|
import { NotFoundError, OrganizerError } from "../core/errors.js";
|
|
3
3
|
import { checklistRoutes } from "./checklist.js";
|
|
4
|
+
import { questionRoutes } from "./questions.js";
|
|
4
5
|
import { ideaRoutes } from "./ideas.js";
|
|
5
6
|
import { notificationRoutes } from "./notifications.js";
|
|
6
7
|
import { requestRoutes } from "./requests.js";
|
|
@@ -14,7 +15,7 @@ function compile(route) {
|
|
|
14
15
|
});
|
|
15
16
|
return { route, pattern: new RegExp(`^${source}$`), keys };
|
|
16
17
|
}
|
|
17
|
-
const ROUTES = [...requestRoutes, ...taskRoutes, ...checklistRoutes, ...ideaRoutes, ...viewRoutes, ...notificationRoutes].map(compile);
|
|
18
|
+
const ROUTES = [...requestRoutes, ...taskRoutes, ...checklistRoutes, ...questionRoutes, ...ideaRoutes, ...viewRoutes, ...notificationRoutes].map(compile);
|
|
18
19
|
/** Segment de chemin décodé ; un encodage `%` invalide est une erreur 400. */
|
|
19
20
|
function decodeSegment(raw) {
|
|
20
21
|
try {
|
|
@@ -2,6 +2,7 @@ import { AddCommentBodySchema, CommentDataSchema, ContextDataSchema, CreateTaskB
|
|
|
2
2
|
import { combinedResult } from "../../shared/logic/test-summary.js";
|
|
3
3
|
import { actFor, ago, assigneesSummary, createdTaskSummary, ideaData, memberData, recentIdeas, requireText, resolveMembers, resolveTask, spaceContextLines, spaceData, taskData, taskKey, taskUpdateSummary, treeData, userLabel, } from "../core/agent.js";
|
|
4
4
|
import { OrganizerError } from "../core/errors.js";
|
|
5
|
+
import { questionData, questionLines, questionsOf } from "./questions.js";
|
|
5
6
|
import { parseInput, respond } from "./types.js";
|
|
6
7
|
/** Espace du jeton et ses tâches : contexte, lecture, recherche, création, modification, assignés, tags, commentaires. */
|
|
7
8
|
/** Nombre de commentaires récents affichés par get_task. */
|
|
@@ -55,6 +56,9 @@ export const taskRoutes = [
|
|
|
55
56
|
lines.push(`Tags: ${summary.tags.length > 0 ? summary.tags.join(", ") : "none"}`);
|
|
56
57
|
lines.push(`Created by ${name(task.createdBy)} ${ago(task.createdAt)}, updated ${ago(task.updatedAt)}.`);
|
|
57
58
|
lines.push("", "Description:", task.description.trim() === "" ? "(empty)" : task.description);
|
|
59
|
+
const questions = questionsOf(store, task.id);
|
|
60
|
+
if (questions.length > 0)
|
|
61
|
+
lines.push("", ...questionLines(store, questions));
|
|
58
62
|
const checklist = task.type === "standard" ? store.listChecklist(task.id) : [];
|
|
59
63
|
const checkpoints = [];
|
|
60
64
|
if (task.type === "standard") {
|
|
@@ -102,6 +106,7 @@ export const taskRoutes = [
|
|
|
102
106
|
testedTaskKey: tested ? taskKey(store, tested) : null,
|
|
103
107
|
checklist: checklist.map((item) => ({ id: item.id, text: item.text, done: item.done })),
|
|
104
108
|
checkpoints,
|
|
109
|
+
questions: questions.map((question) => questionData(store, question)),
|
|
105
110
|
children: children.map((child) => taskData(store, child)),
|
|
106
111
|
comments: comments.map((comment) => ({
|
|
107
112
|
id: comment.id,
|
package/dist/src/cli/setup.js
CHANGED
|
@@ -447,10 +447,8 @@ function installClaude(home, binary) {
|
|
|
447
447
|
}
|
|
448
448
|
say(` Claude Code installé : ${binary}`);
|
|
449
449
|
}
|
|
450
|
-
/**
|
|
451
|
-
|
|
452
|
-
return `env HOME=${home} CLAUDE_CONFIG_DIR=${home} ${command}`;
|
|
453
|
-
}
|
|
450
|
+
/** Connexion de Claude pour le runner : depuis la page Administration, sans terminal sur le serveur. */
|
|
451
|
+
const CLAUDE_CONNECTION_STEP = "Runner : une fois le site lancé, connectez Claude dans la page Administration, section « Connexion de Claude » (token créé par `claude setup-token` sur votre ordinateur).";
|
|
454
452
|
// --- Écriture ----------------------------------------------------------------
|
|
455
453
|
/** Écrit un fichier lisible par son seul propriétaire, par remplacement atomique. */
|
|
456
454
|
function writePrivateFile(target, content) {
|
|
@@ -482,12 +480,9 @@ function printNextSteps(answers, context, outputDir, local, runnerCommand) {
|
|
|
482
480
|
const unit = path.join(outputDir, SYSTEMD_UNIT_FILENAME);
|
|
483
481
|
const nginx = path.join(outputDir, NGINX_FILENAME);
|
|
484
482
|
const serverName = new URL(answers.publicUrl).hostname;
|
|
485
|
-
const claudeHome = runnerClaudeDir(answers.dataDir);
|
|
486
483
|
if (local) {
|
|
487
|
-
if (runnerCommand !== null)
|
|
488
|
-
say(
|
|
489
|
-
say(` ${claudeLoginCommand(claudeHome, runnerCommand)}`);
|
|
490
|
-
}
|
|
484
|
+
if (runnerCommand !== null)
|
|
485
|
+
say(` ${CLAUDE_CONNECTION_STEP}`);
|
|
491
486
|
say(" Essai local : lancez le site, puis ouvrez l'URL publique.");
|
|
492
487
|
say(` node ${path.join(context.installDir, "dist", "src", "index.js")} --server --dotenv=${context.envFilePath}`);
|
|
493
488
|
say(` ${answers.publicUrl}`);
|
|
@@ -507,8 +502,7 @@ function printNextSteps(answers, context, outputDir, local, runnerCommand) {
|
|
|
507
502
|
say("");
|
|
508
503
|
let next = 3;
|
|
509
504
|
if (runnerCommand !== null) {
|
|
510
|
-
say(` ${next++}.
|
|
511
|
-
say(` sudo -u ${context.serviceUser} ${claudeLoginCommand(claudeHome, runnerCommand)}`);
|
|
505
|
+
say(` ${next++}. ${CLAUDE_CONNECTION_STEP}`);
|
|
512
506
|
say("");
|
|
513
507
|
}
|
|
514
508
|
say(` ${next++}. Certificat, puis nginx :`);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ClaudeConnectionView, RunnerStatus } from "../../shared/schemas/admin-api.schema.js";
|
|
2
|
+
import type { Store } from "./store.js";
|
|
3
|
+
/**
|
|
4
|
+
* Connexion de Claude pour le runner : un token d'abonnement créé par
|
|
5
|
+
* `claude setup-token`, collé par un administrateur dans la page
|
|
6
|
+
* Administration, vérifié par une requête minimale, puis gardé en base chiffré
|
|
7
|
+
* en AES-256-GCM. La clé est un fichier du répertoire de données, hors de la
|
|
8
|
+
* base, lisible par le seul compte du site, créé au premier enregistrement.
|
|
9
|
+
* L'API ne rend jamais le token, seulement ses 4 derniers caractères.
|
|
10
|
+
*/
|
|
11
|
+
/** Fichier de la clé de chiffrement du token, dans le répertoire de données. */
|
|
12
|
+
export declare const CLAUDE_KEY_FILE = "claude-token.key";
|
|
13
|
+
export declare function claudeKeyPath(dataDir: string): string;
|
|
14
|
+
/** Chiffre `token` : `v1.<iv>.<tag>.<données>`, en base64url. */
|
|
15
|
+
export declare function encryptToken(key: Buffer, token: string): string;
|
|
16
|
+
/** Déchiffre un token chiffré par `encryptToken` ; erreur si la clé ne correspond pas ou si le chiffré a été altéré. */
|
|
17
|
+
export declare function decryptToken(key: Buffer, blob: string): string;
|
|
18
|
+
/** État de la connexion, sans le token. */
|
|
19
|
+
export declare function claudeConnectionView(store: Store): ClaudeConnectionView;
|
|
20
|
+
/** État de la connexion, pour un administrateur. */
|
|
21
|
+
export declare function getClaudeConnection(store: Store, userId: string): ClaudeConnectionView;
|
|
22
|
+
/** Chiffre et enregistre `token` au nom de `userId`, sans le vérifier. */
|
|
23
|
+
export declare function storeClaudeToken(store: Store, dataDir: string, userId: string, token: string): ClaudeConnectionView;
|
|
24
|
+
/** Vérifie `token` avec `check` (requête minimale à Claude), puis l'enregistre chiffré ; un token refusé n'est pas enregistré. */
|
|
25
|
+
export declare function saveClaudeToken(store: Store, dataDir: string, userId: string, token: string, check: (token: string) => Promise<void>): Promise<ClaudeConnectionView>;
|
|
26
|
+
/** Token enregistré, déchiffré ; erreur si la clé manque ou ne correspond pas. */
|
|
27
|
+
export declare function readClaudeToken(store: Store, dataDir: string): string | null;
|
|
28
|
+
/** État du runner quand sa commande est configurée : désactivé sans token, ou avec un token refusé par Claude. */
|
|
29
|
+
export declare function claudeRunnerStatus(store: Store): RunnerStatus;
|
|
30
|
+
/** Vrai si `text`, écrit par Claude Code, dit que le token n'est pas accepté. */
|
|
31
|
+
export declare function isAuthFailure(text: string | null): boolean;
|