@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.
Files changed (43) hide show
  1. package/README.md +31 -32
  2. package/dist/shared/schemas/admin-api.schema.d.ts +29 -0
  3. package/dist/shared/schemas/admin-api.schema.js +24 -0
  4. package/dist/shared/schemas/agent-api.schema.d.ts +3 -0
  5. package/dist/shared/schemas/agent-tools.schema.d.ts +149 -0
  6. package/dist/shared/schemas/agent-tools.schema.js +49 -1
  7. package/dist/shared/schemas/entities.schema.d.ts +56 -0
  8. package/dist/shared/schemas/entities.schema.js +33 -0
  9. package/dist/shared/schemas/enums.schema.d.ts +2 -1
  10. package/dist/shared/schemas/enums.schema.js +1 -0
  11. package/dist/shared/schemas/tasks-api.schema.d.ts +51 -0
  12. package/dist/shared/schemas/tasks-api.schema.js +23 -1
  13. package/dist/src/agent-api/questions.d.ts +15 -0
  14. package/dist/src/agent-api/questions.js +128 -0
  15. package/dist/src/agent-api/router.js +2 -1
  16. package/dist/src/agent-api/tasks.js +5 -0
  17. package/dist/src/cli/setup.js +5 -11
  18. package/dist/src/core/claude-connection.d.ts +31 -0
  19. package/dist/src/core/claude-connection.js +127 -0
  20. package/dist/src/core/history.js +21 -1
  21. package/dist/src/core/migrations.js +36 -0
  22. package/dist/src/core/questions.d.ts +13 -0
  23. package/dist/src/core/questions.js +33 -0
  24. package/dist/src/core/snapshots.d.ts +3 -3
  25. package/dist/src/core/snapshots.js +3 -1
  26. package/dist/src/core/store.d.ts +61 -2
  27. package/dist/src/core/store.js +240 -2
  28. package/dist/src/core/tasks.js +2 -0
  29. package/dist/src/deploy/env-render.js +1 -1
  30. package/dist/src/gui-api.d.ts +8 -1
  31. package/dist/src/gui-api.js +25 -7
  32. package/dist/src/mcp/start.d.ts +1 -1
  33. package/dist/src/mcp/start.js +2 -2
  34. package/dist/src/mcp/tools.js +55 -3
  35. package/dist/src/server/runner.d.ts +10 -0
  36. package/dist/src/server/runner.js +80 -8
  37. package/dist/src/server/start.js +8 -3
  38. package/gui/dist/assets/index-BJHJo6-f.css +1 -0
  39. package/gui/dist/assets/index-vy2WydDd.js +99 -0
  40. package/gui/dist/index.html +2 -2
  41. package/package.json +1 -1
  42. package/gui/dist/assets/index-DrGANOy-.css +0 -1
  43. package/gui/dist/assets/index-hlJlOrjE.js +0 -99
@@ -0,0 +1,127 @@
1
+ import crypto from "node:crypto";
2
+ import fs from "node:fs";
3
+ import path from "node:path";
4
+ import { requireAdmin } from "./admin.js";
5
+ import { OrganizerError } from "./errors.js";
6
+ /**
7
+ * Connexion de Claude pour le runner : un token d'abonnement créé par
8
+ * `claude setup-token`, collé par un administrateur dans la page
9
+ * Administration, vérifié par une requête minimale, puis gardé en base chiffré
10
+ * en AES-256-GCM. La clé est un fichier du répertoire de données, hors de la
11
+ * base, lisible par le seul compte du site, créé au premier enregistrement.
12
+ * L'API ne rend jamais le token, seulement ses 4 derniers caractères.
13
+ */
14
+ /** Fichier de la clé de chiffrement du token, dans le répertoire de données. */
15
+ export const CLAUDE_KEY_FILE = "claude-token.key";
16
+ /** Durée de validité d'un token créé par `claude setup-token`. */
17
+ const TOKEN_VALIDITY_MS = 365 * 24 * 3600_000;
18
+ const KEY_BYTES = 32;
19
+ const IV_BYTES = 12;
20
+ const CIPHER_VERSION = "v1";
21
+ export function claudeKeyPath(dataDir) {
22
+ return path.join(dataDir, CLAUDE_KEY_FILE);
23
+ }
24
+ function parseKey(file, raw) {
25
+ const key = Buffer.from(raw.trim(), "base64");
26
+ if (key.length !== KEY_BYTES)
27
+ throw new OrganizerError(`${file} n'est pas une clé de chiffrement valide : reconnectez Claude dans la page Administration.`);
28
+ return key;
29
+ }
30
+ /** Clé de chiffrement existante ; erreur si le fichier manque. */
31
+ function readKey(dataDir) {
32
+ const file = claudeKeyPath(dataDir);
33
+ let raw;
34
+ try {
35
+ raw = fs.readFileSync(file, "utf8");
36
+ }
37
+ catch (err) {
38
+ if (err?.code === "ENOENT")
39
+ throw new OrganizerError(`La clé de chiffrement du token Claude (${file}) est absente : reconnectez Claude dans la page Administration.`);
40
+ throw err;
41
+ }
42
+ return parseKey(file, raw);
43
+ }
44
+ /** Clé de chiffrement, créée au premier appel en 0600. */
45
+ function ensureKey(dataDir) {
46
+ const file = claudeKeyPath(dataDir);
47
+ try {
48
+ fs.writeFileSync(file, crypto.randomBytes(KEY_BYTES).toString("base64"), { encoding: "utf8", mode: 0o600, flag: "wx" });
49
+ }
50
+ catch (err) {
51
+ if (err?.code !== "EEXIST")
52
+ throw err;
53
+ }
54
+ return readKey(dataDir);
55
+ }
56
+ /** Chiffre `token` : `v1.<iv>.<tag>.<données>`, en base64url. */
57
+ export function encryptToken(key, token) {
58
+ const iv = crypto.randomBytes(IV_BYTES);
59
+ const cipher = crypto.createCipheriv("aes-256-gcm", key, iv);
60
+ const data = Buffer.concat([cipher.update(token, "utf8"), cipher.final()]);
61
+ return [CIPHER_VERSION, iv.toString("base64url"), cipher.getAuthTag().toString("base64url"), data.toString("base64url")].join(".");
62
+ }
63
+ /** Déchiffre un token chiffré par `encryptToken` ; erreur si la clé ne correspond pas ou si le chiffré a été altéré. */
64
+ export function decryptToken(key, blob) {
65
+ const [version, iv, tag, data] = blob.split(".");
66
+ if (version !== CIPHER_VERSION || iv === undefined || tag === undefined || data === undefined)
67
+ throw new OrganizerError("Token Claude chiffré illisible : reconnectez Claude dans la page Administration.");
68
+ try {
69
+ const decipher = crypto.createDecipheriv("aes-256-gcm", key, Buffer.from(iv, "base64url"));
70
+ decipher.setAuthTag(Buffer.from(tag, "base64url"));
71
+ return Buffer.concat([decipher.update(Buffer.from(data, "base64url")), decipher.final()]).toString("utf8");
72
+ }
73
+ catch {
74
+ throw new OrganizerError("Le token Claude ne se déchiffre pas avec la clé du répertoire de données : reconnectez Claude dans la page Administration.");
75
+ }
76
+ }
77
+ /** État de la connexion, sans le token. */
78
+ export function claudeConnectionView(store) {
79
+ const connection = store.findClaudeConnection();
80
+ if (!connection)
81
+ return { tokenHint: null, savedAt: null, expiresAt: null, refusedAt: null, refusedReason: null };
82
+ return {
83
+ tokenHint: connection.tokenHint,
84
+ savedAt: connection.savedAt,
85
+ expiresAt: new Date(Date.parse(connection.savedAt) + TOKEN_VALIDITY_MS).toISOString(),
86
+ refusedAt: connection.refusedAt,
87
+ refusedReason: connection.refusedReason,
88
+ };
89
+ }
90
+ /** État de la connexion, pour un administrateur. */
91
+ export function getClaudeConnection(store, userId) {
92
+ requireAdmin(store, userId);
93
+ return claudeConnectionView(store);
94
+ }
95
+ /** Chiffre et enregistre `token` au nom de `userId`, sans le vérifier. */
96
+ export function storeClaudeToken(store, dataDir, userId, token) {
97
+ const key = ensureKey(dataDir);
98
+ store.mutate({ type: "user", userId }, (tx) => tx.setClaudeConnection(encryptToken(key, token), token.slice(-4)));
99
+ return claudeConnectionView(store);
100
+ }
101
+ /** Vérifie `token` avec `check` (requête minimale à Claude), puis l'enregistre chiffré ; un token refusé n'est pas enregistré. */
102
+ export async function saveClaudeToken(store, dataDir, userId, token, check) {
103
+ requireAdmin(store, userId);
104
+ await check(token);
105
+ return storeClaudeToken(store, dataDir, userId, token);
106
+ }
107
+ /** Token enregistré, déchiffré ; erreur si la clé manque ou ne correspond pas. */
108
+ export function readClaudeToken(store, dataDir) {
109
+ const connection = store.findClaudeConnection();
110
+ return connection ? decryptToken(readKey(dataDir), connection.tokenCipher) : null;
111
+ }
112
+ /** État du runner quand sa commande est configurée : désactivé sans token, ou avec un token refusé par Claude. */
113
+ export function claudeRunnerStatus(store) {
114
+ const connection = store.findClaudeConnection();
115
+ if (!connection)
116
+ return { enabled: false, disabledReason: "Claude n'est pas connecté : collez un token dans la page Administration, section « Connexion de Claude »." };
117
+ if (connection.refusedAt !== null) {
118
+ return { enabled: false, disabledReason: "Claude a refusé le token (expiré ou révoqué) : reconnectez Claude dans la page Administration." };
119
+ }
120
+ return { enabled: true, disabledReason: null };
121
+ }
122
+ /** Messages de Claude Code qui signalent un token absent, expiré, révoqué ou invalide. */
123
+ const AUTH_FAILURE = /authentication_error|invalid bearer token|oauth token has expired|oauth token (?:was |has been )?revoked|invalid authentication credentials|invalid api key|not logged in|login expired|please run \/login/i;
124
+ /** Vrai si `text`, écrit par Claude Code, dit que le token n'est pas accepté. */
125
+ export function isAuthFailure(text) {
126
+ return text !== null && AUTH_FAILURE.test(text);
127
+ }
@@ -1,6 +1,6 @@
1
1
  import { ForbiddenError, InvariantError, NotFoundError } from "./errors.js";
2
2
  import { CheckpointSnapshotSchema, isTracked, snapshotOf, taskIdOfAction } from "./snapshots.js";
3
- import { BoardViewSchema, ChecklistItemSchema, FollowUpSchema, CommentSchema, IdeaSchema, TaskSnapshotSchema, TestCheckpointSchema, } from "../../shared/schemas/entities.schema.js";
3
+ import { BoardViewSchema, ChecklistItemSchema, FollowUpSchema, QuestionSnapshotSchema, CommentSchema, IdeaSchema, TaskSnapshotSchema, TestCheckpointSchema, } from "../../shared/schemas/entities.schema.js";
4
4
  /**
5
5
  * Retour à un état antérieur : annulation d'une action de l'agent, après
6
6
  * comparaison de l'état courant de l'entité avec celui que l'action a
@@ -19,6 +19,10 @@ function comparable(entityType, snapshot) {
19
19
  const item = ChecklistItemSchema.parse(snapshot);
20
20
  return [item.text, item.done];
21
21
  }
22
+ case "task_question": {
23
+ const { text, multiple, otherAnswer, options } = QuestionSnapshotSchema.parse(snapshot);
24
+ return [text, multiple, otherAnswer, options.map(({ id, label, detail, recommended, selected }) => [id, label, detail, recommended, selected])];
25
+ }
22
26
  case "test_checkpoint":
23
27
  return [TestCheckpointSchema.parse(snapshot).text];
24
28
  case "comment":
@@ -51,6 +55,8 @@ function describe(store, entityType, snapshot) {
51
55
  }
52
56
  case "checklist_item":
53
57
  return { label: `L'élément de checklist « ${ChecklistItemSchema.parse(snapshot).text} »`, feminine: false };
58
+ case "task_question":
59
+ return { label: `La question « ${excerpt(QuestionSnapshotSchema.parse(snapshot).text)} »`, feminine: true };
54
60
  case "test_checkpoint":
55
61
  return { label: `Le point de vérification « ${TestCheckpointSchema.parse(snapshot).text} »`, feminine: false };
56
62
  case "comment":
@@ -141,6 +147,7 @@ function remove(tx, entityType, current, label) {
141
147
  const dependents = [
142
148
  [store.listChildren(task.id).length, "des sous-tâches"],
143
149
  [store.listChecklist(task.id).length, "une checklist"],
150
+ [store.listQuestions(task.id).length, "des questions"],
144
151
  [store.listCheckpoints(task.id).length, "des points de vérification"],
145
152
  [store.listComments(task.id).length, "des commentaires"],
146
153
  [store.listAttachments(task.id).length, "des pièces jointes"],
@@ -155,6 +162,9 @@ function remove(tx, entityType, current, label) {
155
162
  case "checklist_item":
156
163
  tx.deleteChecklistItem(ChecklistItemSchema.parse(current).id);
157
164
  return;
165
+ case "task_question":
166
+ tx.deleteQuestion(QuestionSnapshotSchema.parse(current).id);
167
+ return;
158
168
  case "test_checkpoint": {
159
169
  const checkpoint = CheckpointSnapshotSchema.parse(current);
160
170
  if (checkpoint.results.length > 0)
@@ -188,6 +198,13 @@ function recreate(tx, entityType, before) {
188
198
  tx.restoreChecklistItem(item);
189
199
  return;
190
200
  }
201
+ case "task_question": {
202
+ const question = QuestionSnapshotSchema.parse(before);
203
+ if (!tx.store.findTask(question.taskId))
204
+ throw new InvariantError(`La tâche de la question « ${excerpt(question.text)} » n'existe plus : rien à recréer.`);
205
+ tx.restoreQuestion(question);
206
+ return;
207
+ }
191
208
  case "test_checkpoint": {
192
209
  const checkpoint = CheckpointSnapshotSchema.parse(before);
193
210
  if (!tx.store.findTask(checkpoint.taskId))
@@ -219,6 +236,9 @@ function restore(tx, entityType, entityId, before) {
219
236
  tx.updateChecklistItem(entityId, { text: item.text, done: item.done });
220
237
  return;
221
238
  }
239
+ case "task_question":
240
+ tx.replaceQuestion(QuestionSnapshotSchema.parse(before));
241
+ return;
222
242
  case "test_checkpoint":
223
243
  tx.updateCheckpoint(entityId, TestCheckpointSchema.parse(before).text);
224
244
  return;
@@ -577,6 +577,42 @@ export const MIGRATIONS = [
577
577
  ALTER TABLE board_views ADD COLUMN tag_ids TEXT NOT NULL DEFAULT '[]';
578
578
  UPDATE agent_actions SET before = json_set(before, '$.tagIds', json('[]')) WHERE entity_type = 'board_view' AND before IS NOT NULL;
579
579
  UPDATE agent_actions SET after = json_set(after, '$.tagIds', json('[]')) WHERE entity_type = 'board_view' AND after IS NOT NULL;
580
+ `,
581
+ // Questions posées par l'agent dans une tâche, leurs propositions et la réponse des membres.
582
+ `
583
+ CREATE TABLE task_questions (
584
+ id TEXT PRIMARY KEY,
585
+ task_id TEXT NOT NULL REFERENCES tasks(id) ON DELETE CASCADE,
586
+ text TEXT NOT NULL CHECK (text <> ''),
587
+ multiple INTEGER NOT NULL DEFAULT 0 CHECK (multiple IN (0, 1)),
588
+ other_answer TEXT CHECK (other_answer IS NULL OR other_answer <> ''),
589
+ answered_by TEXT REFERENCES users(id) ON DELETE SET NULL,
590
+ answered_at TEXT,
591
+ position REAL NOT NULL
592
+ );
593
+ CREATE INDEX task_questions_task ON task_questions(task_id, position);
594
+ CREATE TABLE question_options (
595
+ id TEXT PRIMARY KEY,
596
+ question_id TEXT NOT NULL REFERENCES task_questions(id) ON DELETE CASCADE,
597
+ label TEXT NOT NULL CHECK (label <> ''),
598
+ detail TEXT NOT NULL DEFAULT '',
599
+ recommended INTEGER NOT NULL DEFAULT 0 CHECK (recommended IN (0, 1)),
600
+ selected INTEGER NOT NULL DEFAULT 0 CHECK (selected IN (0, 1)),
601
+ position REAL NOT NULL
602
+ );
603
+ CREATE INDEX question_options_question ON question_options(question_id, position);
604
+ `,
605
+ // Connexion de Claude pour le runner (une seule ligne) : token d'abonnement chiffré, son indice, et son refus par Claude.
606
+ `
607
+ CREATE TABLE claude_connection (
608
+ id INTEGER PRIMARY KEY CHECK (id = 1),
609
+ token_cipher TEXT NOT NULL CHECK (token_cipher <> ''),
610
+ token_hint TEXT NOT NULL,
611
+ saved_at TEXT NOT NULL,
612
+ saved_by TEXT REFERENCES users(id) ON DELETE SET NULL,
613
+ refused_at TEXT,
614
+ refused_reason TEXT
615
+ );
580
616
  `,
581
617
  ];
582
618
  /** Version du schéma attendue par ce code. */
@@ -0,0 +1,13 @@
1
+ import type { Store } from "./store.js";
2
+ import type { QuestionSnapshot } from "../../shared/schemas/entities.schema.js";
3
+ import type { AnswerQuestionRequest, QuestionView } from "../../shared/schemas/tasks-api.schema.js";
4
+ /**
5
+ * Questions d'une tâche côté site : l'agent les pose, tout membre de l'espace
6
+ * y répond. Une réponse est enregistrée sans rien envoyer à l'agent, qui la
7
+ * lit quand il consulte la tâche.
8
+ */
9
+ export declare function questionView(store: Store, question: QuestionSnapshot): QuestionView;
10
+ /** Questions d'une tâche, dans l'ordre. */
11
+ export declare function questionViews(store: Store, taskId: string): QuestionView[];
12
+ /** Enregistre la réponse d'un membre de l'espace de la tâche ; une question introuvable ou hors de ses espaces reçoit la même réponse. */
13
+ export declare function answerQuestion(store: Store, userId: string, questionId: string, answer: AnswerQuestionRequest): QuestionView;
@@ -0,0 +1,33 @@
1
+ import { NotFoundError } from "./errors.js";
2
+ /**
3
+ * Questions d'une tâche côté site : l'agent les pose, tout membre de l'espace
4
+ * y répond. Une réponse est enregistrée sans rien envoyer à l'agent, qui la
5
+ * lit quand il consulte la tâche.
6
+ */
7
+ export function questionView(store, question) {
8
+ const author = question.answeredBy === null ? null : store.findUser(question.answeredBy);
9
+ return {
10
+ id: question.id,
11
+ text: question.text,
12
+ multiple: question.multiple,
13
+ options: question.options.map(({ id, label, detail, recommended, selected }) => ({ id, label, detail, recommended, selected })),
14
+ otherAnswer: question.otherAnswer,
15
+ answeredBy: author ? (author.displayName ?? author.email) : null,
16
+ answeredAt: question.answeredAt,
17
+ };
18
+ }
19
+ /** Questions d'une tâche, dans l'ordre. */
20
+ export function questionViews(store, taskId) {
21
+ return store.listQuestions(taskId).map((question) => questionView(store, store.questionSnapshot(question.id)));
22
+ }
23
+ /** Enregistre la réponse d'un membre de l'espace de la tâche ; une question introuvable ou hors de ses espaces reçoit la même réponse. */
24
+ export function answerQuestion(store, userId, questionId, answer) {
25
+ const question = store.mutate({ type: "user", userId }, (tx) => {
26
+ const current = tx.store.findQuestion(questionId);
27
+ const task = current === null ? null : tx.store.findTask(current.taskId);
28
+ if (!current || !task || !tx.store.isMember(task.spaceId, userId))
29
+ throw new NotFoundError("Question introuvable.");
30
+ return tx.answerQuestion(questionId, answer, userId);
31
+ });
32
+ return questionView(store, question);
33
+ }
@@ -1,7 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import type { Store } from "./store.js";
3
3
  import type { EntityType } from "../../shared/schemas/enums.schema.js";
4
- import { type AgentAction, type BoardView, type ChecklistItem, type Comment, type FollowUp, type Idea, type TaskSnapshot } from "../../shared/schemas/entities.schema.js";
4
+ import { type AgentAction, type BoardView, type ChecklistItem, type Comment, type FollowUp, type Idea, type QuestionSnapshot, type TaskSnapshot } from "../../shared/schemas/entities.schema.js";
5
5
  /** Instantanés des entités que l'agent modifie : l'état avant et après chaque action de son lot. */
6
6
  /** Point de vérification avec les résultats saisis dessus. */
7
7
  export declare const CheckpointSnapshotSchema: z.ZodObject<{
@@ -24,9 +24,9 @@ export declare const CheckpointSnapshotSchema: z.ZodObject<{
24
24
  }, z.core.$strip>;
25
25
  export type CheckpointSnapshot = z.infer<typeof CheckpointSnapshotSchema>;
26
26
  /** Entités dont l'agent enregistre l'état avant et après chaque action. */
27
- export type TrackedEntityType = "task" | "checklist_item" | "test_checkpoint" | "comment" | "idea" | "board_view" | "follow_up";
27
+ export type TrackedEntityType = "task" | "checklist_item" | "task_question" | "test_checkpoint" | "comment" | "idea" | "board_view" | "follow_up";
28
28
  export declare function isTracked(entityType: EntityType): entityType is TrackedEntityType;
29
29
  /** Instantané courant d'une entité, ou null si elle n'existe pas. */
30
- export declare function snapshotOf(store: Store, entityType: TrackedEntityType, entityId: string): TaskSnapshot | ChecklistItem | CheckpointSnapshot | Comment | Idea | BoardView | FollowUp | null;
30
+ export declare function snapshotOf(store: Store, entityType: TrackedEntityType, entityId: string): TaskSnapshot | ChecklistItem | QuestionSnapshot | CheckpointSnapshot | Comment | Idea | BoardView | FollowUp | null;
31
31
  /** Tâche concernée par une action : la tâche elle-même, ou celle qui porte l'élément ; null pour une idée, une vue ou un point à régler. */
32
32
  export declare function taskIdOfAction(action: Pick<AgentAction, "entityType" | "entityId" | "before" | "after">): string | null;
@@ -3,7 +3,7 @@ import { TestCheckpointSchema, TestResultSchema } from "../../shared/schemas/ent
3
3
  /** Instantanés des entités que l'agent modifie : l'état avant et après chaque action de son lot. */
4
4
  /** Point de vérification avec les résultats saisis dessus. */
5
5
  export const CheckpointSnapshotSchema = TestCheckpointSchema.extend({ results: z.array(TestResultSchema) });
6
- const TRACKED = new Set(["task", "checklist_item", "test_checkpoint", "comment", "idea", "board_view", "follow_up"]);
6
+ const TRACKED = new Set(["task", "checklist_item", "task_question", "test_checkpoint", "comment", "idea", "board_view", "follow_up"]);
7
7
  export function isTracked(entityType) {
8
8
  return TRACKED.has(entityType);
9
9
  }
@@ -14,6 +14,8 @@ export function snapshotOf(store, entityType, entityId) {
14
14
  return store.findTask(entityId) ? store.taskSnapshot(entityId) : null;
15
15
  case "checklist_item":
16
16
  return store.findChecklistItem(entityId);
17
+ case "task_question":
18
+ return store.findQuestionSnapshot(entityId);
17
19
  case "test_checkpoint": {
18
20
  const checkpoint = store.findCheckpoint(entityId);
19
21
  if (!checkpoint)
@@ -1,8 +1,8 @@
1
1
  import type Database from "better-sqlite3";
2
2
  import { WatcherRegistry } from "./watchers.js";
3
3
  import { type BoardGrouping, type BoardLayout, type EntityType, type MemberRole, type RequestKind, type RequestStatus, type SpaceKind, type TaskPriority, type TaskStatus, type TaskType, type TestResultValue, type AccessLinkPurpose, type AgentOperation, type UserStatus, type VersionedEntityType } from "../../shared/schemas/enums.schema.js";
4
- import { type AccessLink, type AgentAction, type AgentInstructions, type AgentRequest, type AgentToken, type Attachment, type BoardView, type Change, type ChecklistItem, type Comment, type EntityVersion, type FollowUp, type Idea, type Invitation, type Membership, type Notification, type Session, type Space, type Tag, type Task, type TaskSnapshot, type TestCheckpoint, type TestResult, type TestReview, type User, type UserSettings, type NotificationPreferences, type SpaceNotificationSettings } from "../../shared/schemas/entities.schema.js";
5
- import { type RunnerSessionRecord, type RunnerSettings } from "../../shared/schemas/admin-api.schema.js";
4
+ import { type AccessLink, type AgentAction, type AgentInstructions, type AgentRequest, type AgentToken, type Attachment, type BoardView, type Change, type ChecklistItem, type Comment, type QuestionOption, type QuestionSnapshot, type TaskQuestion, type EntityVersion, type FollowUp, type Idea, type Invitation, type Membership, type Notification, type Session, type Space, type Tag, type Task, type TaskSnapshot, type TestCheckpoint, type TestResult, type TestReview, type User, type UserSettings, type NotificationPreferences, type SpaceNotificationSettings } from "../../shared/schemas/entities.schema.js";
5
+ import { type ClaudeConnection, type RunnerSessionRecord, type RunnerSettings } from "../../shared/schemas/admin-api.schema.js";
6
6
  /**
7
7
  * Auteur d'une mutation : un utilisateur de la GUI, ou un agent qui agit avec
8
8
  * son jeton, avec les droits du propriétaire du jeton, pour une demande que ce
@@ -46,6 +46,8 @@ export declare class Store {
46
46
  findSpaceNotificationSettings(userId: string, spaceId: string): SpaceNotificationSettings | null;
47
47
  /** Limites d'une session du runner. */
48
48
  getRunnerSettings(): RunnerSettings;
49
+ /** Connexion de Claude enregistrée, ou null tant qu'aucun token ne l'est. */
50
+ findClaudeConnection(): ClaudeConnection | null;
49
51
  /** Sessions du runner commencées depuis `since`, de la plus récente à la plus ancienne. */
50
52
  listRunnerSessionsSince(since: string): RunnerSessionRecord[];
51
53
  /** Instructions de l'agent propres à un espace, ou celles du site quand `spaceId` est null ; null s'il n'y en a pas. */
@@ -114,6 +116,16 @@ export declare class Store {
114
116
  findChecklistItem(id: string): ChecklistItem | null;
115
117
  getChecklistItem(id: string): ChecklistItem;
116
118
  listChecklist(taskId: string): ChecklistItem[];
119
+ findQuestion(id: string): TaskQuestion | null;
120
+ getQuestion(id: string): TaskQuestion;
121
+ /** Questions d'une tâche, dans l'ordre. */
122
+ listQuestions(taskId: string): TaskQuestion[];
123
+ findQuestionOption(id: string): QuestionOption | null;
124
+ /** Propositions d'une question, dans l'ordre. */
125
+ listQuestionOptions(questionId: string): QuestionOption[];
126
+ /** Question et ses propositions, ou null si elle n'existe pas. */
127
+ findQuestionSnapshot(id: string): QuestionSnapshot | null;
128
+ questionSnapshot(id: string): QuestionSnapshot;
117
129
  findCheckpoint(id: string): TestCheckpoint | null;
118
130
  getCheckpoint(id: string): TestCheckpoint;
119
131
  /** Points de vérification d'une tâche de test, dans l'ordre. */
@@ -311,6 +323,12 @@ export interface UpdateIdeaInput {
311
323
  promotedTaskId?: string | null;
312
324
  archived?: boolean;
313
325
  }
326
+ /** Proposition d'une question à créer. */
327
+ export interface QuestionOptionInput {
328
+ label: string;
329
+ detail?: string;
330
+ recommended?: boolean;
331
+ }
314
332
  /** Réglages d'une vue du tableau de bord. */
315
333
  export interface BoardViewSettings {
316
334
  name: string;
@@ -491,6 +509,43 @@ export declare class Mutation {
491
509
  /** Remplace les tags d'une tâche ; un nom absent de l'espace y crée le tag (noms comparés sans la casse). */
492
510
  setTags(taskId: string, names: readonly string[]): Tag[];
493
511
  private createTag;
512
+ /** Ajoute une question en fin de liste d'une tâche, avec ses propositions dans l'ordre donné. */
513
+ addQuestion(taskId: string, input: {
514
+ text: string;
515
+ multiple: boolean;
516
+ options: readonly QuestionOptionInput[];
517
+ }): QuestionSnapshot;
518
+ /** Change le texte d'une question ou son type de choix ; un choix unique n'accepte qu'une réponse. */
519
+ updateQuestion(id: string, patch: {
520
+ text?: string;
521
+ multiple?: boolean;
522
+ }): QuestionSnapshot;
523
+ deleteQuestion(id: string): void;
524
+ /** Ajoute une proposition en fin de question. */
525
+ addQuestionOption(questionId: string, input: QuestionOptionInput): QuestionOption;
526
+ updateQuestionOption(id: string, patch: {
527
+ label?: string;
528
+ detail?: string;
529
+ recommended?: boolean;
530
+ }): QuestionOption;
531
+ deleteQuestionOption(id: string): void;
532
+ /**
533
+ * Réponse d'un membre : les propositions choisies et la réponse libre
534
+ * remplacent les précédentes. Une réponse vide efface l'auteur et la date.
535
+ */
536
+ answerQuestion(id: string, answer: {
537
+ selectedOptionIds: readonly string[];
538
+ otherAnswer: string | null;
539
+ }, userId: string): QuestionSnapshot;
540
+ /** Recrée une question supprimée, avec ses identifiants, ses propositions et sa réponse. */
541
+ restoreQuestion(snapshot: QuestionSnapshot): void;
542
+ /** Ramène une question à un état enregistré : texte, type de choix, réponse et propositions. */
543
+ replaceQuestion(snapshot: QuestionSnapshot): void;
544
+ private insertQuestion;
545
+ private insertQuestionOption;
546
+ /** Un choix unique a pour réponse une seule proposition ou la réponse libre. */
547
+ private requireSingleAnswer;
548
+ private touchQuestion;
494
549
  /** Ajoute un élément en fin de checklist d'une tâche standard. */
495
550
  addChecklistItem(taskId: string, text: string): ChecklistItem;
496
551
  updateChecklistItem(id: string, patch: {
@@ -676,6 +731,10 @@ export declare class Mutation {
676
731
  setAgentInstructions(spaceId: string | null, text: string): AgentInstructions | null;
677
732
  /** Fixe les limites d'une session du runner. */
678
733
  setRunnerSettings(settings: RunnerSettings): RunnerSettings;
734
+ /** Enregistre le token chiffré de Claude, à la place du précédent ; un refus antérieur est effacé. */
735
+ setClaudeConnection(tokenCipher: string, tokenHint: string): ClaudeConnection;
736
+ /** Marque le token de Claude comme refusé par Claude, avec le message de Claude Code. */
737
+ markClaudeTokenRefused(reason: string): void;
679
738
  /** Enregistre le relevé d'une session du runner terminée. */
680
739
  recordRunnerSession(record: RunnerSessionRecord): void;
681
740
  /** Vérifie les invariants sur l'état final, puis écrit les versions et le journal. */