@imenam/mcp-organizer 1.0.13 → 1.0.15
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 +20 -5
- package/dist/shared/schemas/agent-api.schema.d.ts +2 -0
- package/dist/shared/schemas/agent-tools.schema.d.ts +28 -14
- package/dist/shared/schemas/agent-tools.schema.js +23 -15
- package/dist/shared/schemas/entities.schema.d.ts +1 -0
- package/dist/shared/schemas/enums.schema.d.ts +3 -1
- package/dist/shared/schemas/enums.schema.js +2 -1
- package/dist/src/agent-api/requests.d.ts +1 -1
- package/dist/src/agent-api/requests.js +17 -3
- package/dist/src/agent-api/views.js +10 -3
- package/dist/src/core/agent.d.ts +14 -4
- package/dist/src/core/agent.js +42 -1
- package/dist/src/core/migrations.d.ts +5 -0
- package/dist/src/core/migrations.js +540 -481
- package/dist/src/core/requests.js +5 -9
- package/dist/src/core/store.d.ts +21 -5
- package/dist/src/core/store.js +121 -45
- package/dist/src/index.js +29 -29
- package/dist/src/mcp/start.d.ts +1 -1
- package/dist/src/mcp/start.js +4 -1
- package/dist/src/mcp/tools.js +48 -21
- package/gui/dist/assets/{index-CkZPrGSS.js → index-DS_BdlK5.js} +23 -23
- package/gui/dist/index.html +1 -1
- package/package.json +5 -2
|
@@ -3,6 +3,7 @@ import { stoppedByReason } from "./admin.js";
|
|
|
3
3
|
import { requireMember } from "./spaces.js";
|
|
4
4
|
import { requireTask } from "./tasks.js";
|
|
5
5
|
import { undoAgentAction } from "./history.js";
|
|
6
|
+
import { actionTaskKey } from "./agent.js";
|
|
6
7
|
import { taskIdOfAction } from "./snapshots.js";
|
|
7
8
|
import { tokenState } from "./agent-tokens.js";
|
|
8
9
|
import { followUpView, openFollowUps } from "./follow-ups.js";
|
|
@@ -40,14 +41,7 @@ function actionLabel(store, action) {
|
|
|
40
41
|
return "Vue";
|
|
41
42
|
if (action.entityType === "follow_up")
|
|
42
43
|
return "Point";
|
|
43
|
-
|
|
44
|
-
const snapshot = (action.after ?? action.before);
|
|
45
|
-
const space = store.findSpace(snapshot.spaceId);
|
|
46
|
-
return space ? `${space.keyPrefix}-${snapshot.number}` : "";
|
|
47
|
-
}
|
|
48
|
-
const taskId = taskIdOfAction(action);
|
|
49
|
-
const task = taskId === null ? null : store.findTask(taskId);
|
|
50
|
-
return task ? `${store.getSpace(task.spaceId).keyPrefix}-${task.number}` : "";
|
|
44
|
+
return actionTaskKey(store, action) ?? "";
|
|
51
45
|
}
|
|
52
46
|
export function actionView(store, action) {
|
|
53
47
|
const taskId = taskIdOfAction(action);
|
|
@@ -88,7 +82,7 @@ export function requestView(store, userId, request) {
|
|
|
88
82
|
followUps: store.listFollowUps(request.id).map((followUp) => followUpView(store, followUp)),
|
|
89
83
|
failureReason: request.failureReason,
|
|
90
84
|
parent: parent ? { id: parent.id, text: parent.text, openFollowUps: openFollowUps(store, parent.id) } : null,
|
|
91
|
-
canFollowUp: member && request.parentRequestId === null && (request.status === "done" || request.status === "failed"),
|
|
85
|
+
canFollowUp: member && request.kind !== "direct" && request.parentRequestId === null && (request.status === "done" || request.status === "failed"),
|
|
92
86
|
createdAt: request.createdAt,
|
|
93
87
|
updatedAt: request.updatedAt,
|
|
94
88
|
claimedAt: request.claimedAt,
|
|
@@ -218,6 +212,8 @@ export function createSuite(store, userId, requestId, text) {
|
|
|
218
212
|
const suite = store.mutate(asUser(userId), (tx) => {
|
|
219
213
|
const request = requireVisibleRequest(tx.store, userId, requestId);
|
|
220
214
|
const origin = request.parentRequestId === null ? request : tx.store.getAgentRequest(request.parentRequestId);
|
|
215
|
+
if (origin.kind === "direct")
|
|
216
|
+
throw new InvariantError("Une action directe de l'agent n'a pas de suite : écrivez-lui un nouveau message.");
|
|
221
217
|
if (origin.status !== "done" && origin.status !== "failed") {
|
|
222
218
|
throw new InvariantError("L'agent n'a pas encore traité cette demande : attendez sa réponse pour lui demander une suite.");
|
|
223
219
|
}
|
package/dist/src/core/store.d.ts
CHANGED
|
@@ -5,15 +5,16 @@ import { type AccessLink, type AgentAction, type AgentInstructions, type AgentRe
|
|
|
5
5
|
import { 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
|
-
* son jeton
|
|
9
|
-
*
|
|
8
|
+
* son jeton, avec les droits du propriétaire du jeton, pour une demande que ce
|
|
9
|
+
* jeton a prise ou, sans demande (`requestId` nul), dans le lot direct que la
|
|
10
|
+
* mutation ouvre.
|
|
10
11
|
*/
|
|
11
12
|
export type Actor = {
|
|
12
13
|
type: "user";
|
|
13
14
|
userId: string;
|
|
14
15
|
} | {
|
|
15
16
|
type: "agent";
|
|
16
|
-
requestId: string;
|
|
17
|
+
requestId: string | null;
|
|
17
18
|
tokenId: string;
|
|
18
19
|
};
|
|
19
20
|
/**
|
|
@@ -171,6 +172,7 @@ export declare class Store {
|
|
|
171
172
|
/**
|
|
172
173
|
* Échanges clos (traités ou en échec) d'un auteur dans un espace, antérieurs à
|
|
173
174
|
* la demande `before`, du plus ancien au plus récent : les `limit` derniers.
|
|
175
|
+
* Les lots directs de l'agent n'en sont pas.
|
|
174
176
|
*/
|
|
175
177
|
listClosedRequestsOfAuthorBefore(spaceId: string, authorId: string, before: AgentRequest, limit: number): AgentRequest[];
|
|
176
178
|
/** Demandes d'un espace, de la plus récente à la plus ancienne, au plus `limit`. */
|
|
@@ -363,8 +365,8 @@ export declare class Mutation {
|
|
|
363
365
|
readonly pendingRequestIds: string[];
|
|
364
366
|
/** Espaces où la mutation a autorisé le runner. */
|
|
365
367
|
readonly runnerAllowedSpaceIds: string[];
|
|
366
|
-
/** Demande pour laquelle agit l'agent
|
|
367
|
-
private
|
|
368
|
+
/** Demande pour laquelle agit l'agent : lue au début de la mutation, ou créée par `openDirectRequest`. */
|
|
369
|
+
private request;
|
|
368
370
|
/** Jeton avec lequel agit l'agent. */
|
|
369
371
|
private readonly token;
|
|
370
372
|
/** Vrai une fois vérifié que l'agent peut écrire pour sa demande. */
|
|
@@ -602,6 +604,20 @@ export declare class Mutation {
|
|
|
602
604
|
abortAgentRequest(id: string, reason: string): AgentRequest;
|
|
603
605
|
/** Demande et jeton de l'agent acteur. */
|
|
604
606
|
private agentRequest;
|
|
607
|
+
/**
|
|
608
|
+
* Ouvre le lot d'une action directe de l'agent, sans demande : une demande
|
|
609
|
+
* `direct` du propriétaire du jeton, dans l'espace du jeton, prise par ce
|
|
610
|
+
* jeton. Le runner du site n'agit que pour les demandes qu'il prend.
|
|
611
|
+
*/
|
|
612
|
+
openDirectRequest(): AgentRequest;
|
|
613
|
+
/** Clôt le lot direct ouvert par `openDirectRequest` : la demande est traitée et son texte (markdown) liste `lines`, une ligne par action du lot. */
|
|
614
|
+
closeDirectRequest(lines: string[]): AgentRequest;
|
|
615
|
+
/**
|
|
616
|
+
* Clôt le lot direct ouvert par `openDirectRequest` en compte rendu : la
|
|
617
|
+
* demande est traitée avec `reply` pour réponse et laisse `followUps` au
|
|
618
|
+
* propriétaire du jeton, qui en est notifié.
|
|
619
|
+
*/
|
|
620
|
+
reportDirectRequest(reply: string, followUps: string[]): AgentRequest;
|
|
605
621
|
/**
|
|
606
622
|
* L'agent prend sa demande avec son jeton : `pending` devient `processing`
|
|
607
623
|
* et la demande est réservée à ce jeton. La mise à jour conditionnelle, dans
|
package/dist/src/core/store.js
CHANGED
|
@@ -337,8 +337,8 @@ function notificationFromRow(row) {
|
|
|
337
337
|
});
|
|
338
338
|
}
|
|
339
339
|
/** Jointure qui garde les notifications dont la tâche ou la demande appartient à un espace dont le destinataire est membre. */
|
|
340
|
-
const VISIBLE_NOTIFICATION_JOIN = `LEFT JOIN tasks t ON t.id = n.task_id
|
|
341
|
-
LEFT JOIN agent_requests r ON n.task_id IS NULL AND r.id = n.request_id
|
|
340
|
+
const VISIBLE_NOTIFICATION_JOIN = `LEFT JOIN tasks t ON t.id = n.task_id
|
|
341
|
+
LEFT JOIN agent_requests r ON n.task_id IS NULL AND r.id = n.request_id
|
|
342
342
|
JOIN memberships m ON m.space_id = COALESCE(t.space_id, r.target_space_id) AND m.user_id = n.user_id`;
|
|
343
343
|
/** Libellé d'une tâche dans les messages : `ORG-41`. */
|
|
344
344
|
function taskLabel(db, task) {
|
|
@@ -512,7 +512,7 @@ export class Store {
|
|
|
512
512
|
/** Espaces dont l'utilisateur est membre : son espace personnel d'abord, puis les espaces communs par nom. */
|
|
513
513
|
listSpacesOf(userId) {
|
|
514
514
|
const rows = this.db
|
|
515
|
-
.prepare(`SELECT s.* FROM spaces s JOIN memberships m ON m.space_id = s.id
|
|
515
|
+
.prepare(`SELECT s.* FROM spaces s JOIN memberships m ON m.space_id = s.id
|
|
516
516
|
WHERE m.user_id = ? ORDER BY s.kind = 'shared', s.name COLLATE NOCASE`)
|
|
517
517
|
.all(userId);
|
|
518
518
|
return rows.map(spaceFromRow);
|
|
@@ -684,7 +684,7 @@ export class Store {
|
|
|
684
684
|
/** Résultats saisis sur les points des tâches d'un espace. */
|
|
685
685
|
listTestResultsInSpace(spaceId) {
|
|
686
686
|
const rows = this.db
|
|
687
|
-
.prepare(`SELECT c.task_id, r.checkpoint_id, r.tester_id, r.result FROM test_results r
|
|
687
|
+
.prepare(`SELECT c.task_id, r.checkpoint_id, r.tester_id, r.result FROM test_results r
|
|
688
688
|
JOIN test_checkpoints c ON c.id = r.checkpoint_id JOIN tasks t ON t.id = c.task_id WHERE t.space_id = ?`)
|
|
689
689
|
.all(spaceId);
|
|
690
690
|
return rows.map((row) => ({
|
|
@@ -729,7 +729,7 @@ export class Store {
|
|
|
729
729
|
/** Pièces jointes d'une tâche et de toutes ses sous-tâches. */
|
|
730
730
|
listAttachmentsInSubtree(taskId) {
|
|
731
731
|
const rows = this.db
|
|
732
|
-
.prepare(`WITH RECURSIVE subtree(id) AS (SELECT ? UNION ALL SELECT t.id FROM tasks t JOIN subtree s ON t.parent_id = s.id)
|
|
732
|
+
.prepare(`WITH RECURSIVE subtree(id) AS (SELECT ? UNION ALL SELECT t.id FROM tasks t JOIN subtree s ON t.parent_id = s.id)
|
|
733
733
|
SELECT a.* FROM attachments a JOIN subtree s ON a.task_id = s.id`)
|
|
734
734
|
.all(taskId);
|
|
735
735
|
return rows.map(attachmentFromRow);
|
|
@@ -759,7 +759,7 @@ export class Store {
|
|
|
759
759
|
/** Demandes de promotion (`idea_promotion`) en attente ou en cours sur les idées d'un espace. */
|
|
760
760
|
listOpenPromotionRequests(spaceId) {
|
|
761
761
|
const rows = this.db
|
|
762
|
-
.prepare(`SELECT r.* FROM agent_requests r JOIN ideas i ON i.id = r.context_idea_id
|
|
762
|
+
.prepare(`SELECT r.* FROM agent_requests r JOIN ideas i ON i.id = r.context_idea_id
|
|
763
763
|
WHERE i.space_id = ? AND r.kind = 'idea_promotion' AND r.status IN ('pending', 'processing') ORDER BY r.created_at, r.id`)
|
|
764
764
|
.all(spaceId);
|
|
765
765
|
return rows.map(requestFromRow);
|
|
@@ -811,14 +811,15 @@ export class Store {
|
|
|
811
811
|
/**
|
|
812
812
|
* Échanges clos (traités ou en échec) d'un auteur dans un espace, antérieurs à
|
|
813
813
|
* la demande `before`, du plus ancien au plus récent : les `limit` derniers.
|
|
814
|
+
* Les lots directs de l'agent n'en sont pas.
|
|
814
815
|
*/
|
|
815
816
|
listClosedRequestsOfAuthorBefore(spaceId, authorId, before, limit) {
|
|
816
817
|
if (limit === 0)
|
|
817
818
|
return [];
|
|
818
819
|
const rows = this.db
|
|
819
|
-
.prepare(`SELECT * FROM agent_requests
|
|
820
|
-
WHERE target_space_id = @spaceId AND author_id = @authorId AND status IN ('done', 'failed')
|
|
821
|
-
AND (created_at < @createdAt OR (created_at = @createdAt AND id < @id))
|
|
820
|
+
.prepare(`SELECT * FROM agent_requests
|
|
821
|
+
WHERE target_space_id = @spaceId AND author_id = @authorId AND status IN ('done', 'failed') AND kind <> 'direct'
|
|
822
|
+
AND (created_at < @createdAt OR (created_at = @createdAt AND id < @id))
|
|
822
823
|
ORDER BY created_at DESC, id DESC LIMIT @limit`)
|
|
823
824
|
.all({ spaceId, authorId, createdAt: before.createdAt, id: before.id, limit });
|
|
824
825
|
return rows.map(requestFromRow).reverse();
|
|
@@ -910,8 +911,8 @@ export class Store {
|
|
|
910
911
|
*/
|
|
911
912
|
listNotifications(userId, limit, offset) {
|
|
912
913
|
const rows = this.db
|
|
913
|
-
.prepare(`SELECT n.* FROM notifications n ${VISIBLE_NOTIFICATION_JOIN}
|
|
914
|
-
WHERE n.user_id = ? AND n.in_app = 1
|
|
914
|
+
.prepare(`SELECT n.* FROM notifications n ${VISIBLE_NOTIFICATION_JOIN}
|
|
915
|
+
WHERE n.user_id = ? AND n.in_app = 1
|
|
915
916
|
ORDER BY n.read_at IS NOT NULL, n.created_at DESC, n.id DESC LIMIT ? OFFSET ?`)
|
|
916
917
|
.all(userId, limit, offset);
|
|
917
918
|
return rows.map(notificationFromRow);
|
|
@@ -919,7 +920,7 @@ export class Store {
|
|
|
919
920
|
/** Nombre de notifications non lues affichées dans l'application d'un utilisateur. */
|
|
920
921
|
countUnreadNotifications(userId) {
|
|
921
922
|
const row = this.db
|
|
922
|
-
.prepare(`SELECT COUNT(*) AS n FROM notifications n ${VISIBLE_NOTIFICATION_JOIN}
|
|
923
|
+
.prepare(`SELECT COUNT(*) AS n FROM notifications n ${VISIBLE_NOTIFICATION_JOIN}
|
|
923
924
|
WHERE n.user_id = ? AND n.in_app = 1 AND n.read_at IS NULL`)
|
|
924
925
|
.get(userId);
|
|
925
926
|
return row.n;
|
|
@@ -948,8 +949,8 @@ export class Store {
|
|
|
948
949
|
*/
|
|
949
950
|
listChangesForUser(userId, since, limit) {
|
|
950
951
|
const rows = this.db
|
|
951
|
-
.prepare(`SELECT * FROM changes WHERE seq > ?
|
|
952
|
-
AND (user_id = ? OR space_id IN (SELECT space_id FROM memberships WHERE user_id = ?))
|
|
952
|
+
.prepare(`SELECT * FROM changes WHERE seq > ?
|
|
953
|
+
AND (user_id = ? OR space_id IN (SELECT space_id FROM memberships WHERE user_id = ?))
|
|
953
954
|
ORDER BY seq LIMIT ?`)
|
|
954
955
|
.all(since, userId, userId, limit);
|
|
955
956
|
return rows.map(changeFromRow);
|
|
@@ -1027,6 +1028,10 @@ export class Store {
|
|
|
1027
1028
|
}
|
|
1028
1029
|
}
|
|
1029
1030
|
const VERSIONED = new Set(["task", "idea"]);
|
|
1031
|
+
/** Texte d'une demande `direct` dont le lot n'a aucune action. */
|
|
1032
|
+
const DIRECT_REQUEST_TEXT = "Action directe de l'agent";
|
|
1033
|
+
/** Texte d'une demande `direct` qui porte un compte rendu de l'agent et ses points à régler. */
|
|
1034
|
+
const DIRECT_REPORT_TEXT = "Compte rendu de l'agent";
|
|
1030
1035
|
/**
|
|
1031
1036
|
* Écritures d'une mutation en cours. Chaque méthode applique une modification
|
|
1032
1037
|
* et la note ; `finish` vérifie les invariants et écrit versions et journal.
|
|
@@ -1043,7 +1048,7 @@ export class Mutation {
|
|
|
1043
1048
|
pendingRequestIds = [];
|
|
1044
1049
|
/** Espaces où la mutation a autorisé le runner. */
|
|
1045
1050
|
runnerAllowedSpaceIds = [];
|
|
1046
|
-
/** Demande pour laquelle agit l'agent
|
|
1051
|
+
/** Demande pour laquelle agit l'agent : lue au début de la mutation, ou créée par `openDirectRequest`. */
|
|
1047
1052
|
request;
|
|
1048
1053
|
/** Jeton avec lequel agit l'agent. */
|
|
1049
1054
|
token;
|
|
@@ -1057,7 +1062,7 @@ export class Mutation {
|
|
|
1057
1062
|
this.actor = actor;
|
|
1058
1063
|
this.db = store.db;
|
|
1059
1064
|
if (actor.type === "agent") {
|
|
1060
|
-
this.request = this.loadAgentRequest(actor.requestId);
|
|
1065
|
+
this.request = actor.requestId === null ? null : this.loadAgentRequest(actor.requestId);
|
|
1061
1066
|
this.token = this.store.findAgentToken(actor.tokenId);
|
|
1062
1067
|
if (!this.token)
|
|
1063
1068
|
throw new NotFoundError(`Agent token ${actor.tokenId} not found.`);
|
|
@@ -1100,10 +1105,9 @@ export class Mutation {
|
|
|
1100
1105
|
* Vérifié à la première écriture d'une entité autre que la demande elle-même.
|
|
1101
1106
|
*/
|
|
1102
1107
|
assertAgentMayWrite() {
|
|
1103
|
-
|
|
1104
|
-
const token = this.token;
|
|
1105
|
-
if (!request || !token || this.agentWriteChecked)
|
|
1108
|
+
if (this.actor.type !== "agent" || this.agentWriteChecked)
|
|
1106
1109
|
return;
|
|
1110
|
+
const { request, token } = this.agentRequest();
|
|
1107
1111
|
this.assertRequestInTokenSpace(request, token);
|
|
1108
1112
|
this.assertClaimedByToken(request, token);
|
|
1109
1113
|
if (!this.store.isMember(request.targetSpaceId, token.userId)) {
|
|
@@ -1231,7 +1235,7 @@ export class Mutation {
|
|
|
1231
1235
|
if (!this.store.isMember(token.spaceId, token.userId))
|
|
1232
1236
|
throw new ForbiddenError("An agent token can only cover a space its owner is a member of.");
|
|
1233
1237
|
this.db
|
|
1234
|
-
.prepare(`INSERT INTO agent_tokens (id, user_id, space_id, name, prefix, token_hash, created_at, expires_at, is_runner)
|
|
1238
|
+
.prepare(`INSERT INTO agent_tokens (id, user_id, space_id, name, prefix, token_hash, created_at, expires_at, is_runner)
|
|
1235
1239
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`)
|
|
1236
1240
|
.run(token.id, token.userId, token.spaceId, token.name, token.prefix, token.tokenHash, token.createdAt, token.expiresAt, token.isRunner ? 1 : 0);
|
|
1237
1241
|
this.touch("agent_token", token.id, null, token.userId);
|
|
@@ -1367,7 +1371,7 @@ export class Mutation {
|
|
|
1367
1371
|
this.touch("membership", `${id}:${membership.userId}`, id, membership.userId);
|
|
1368
1372
|
}
|
|
1369
1373
|
this.db
|
|
1370
|
-
.prepare(`DELETE FROM entity_versions WHERE (entity_type = 'task' AND entity_id IN (SELECT id FROM tasks WHERE space_id = ?))
|
|
1374
|
+
.prepare(`DELETE FROM entity_versions WHERE (entity_type = 'task' AND entity_id IN (SELECT id FROM tasks WHERE space_id = ?))
|
|
1371
1375
|
OR (entity_type = 'idea' AND entity_id IN (SELECT id FROM ideas WHERE space_id = ?))`)
|
|
1372
1376
|
.run(id, id);
|
|
1373
1377
|
this.db.prepare("DELETE FROM spaces WHERE id = ?").run(id);
|
|
@@ -1443,8 +1447,8 @@ export class Mutation {
|
|
|
1443
1447
|
version: 1,
|
|
1444
1448
|
}, "task");
|
|
1445
1449
|
this.db
|
|
1446
|
-
.prepare(`INSERT INTO tasks (id, space_id, number, parent_id, depth, type, title, description, status, priority, position,
|
|
1447
|
-
created_by, created_at, updated_at, version)
|
|
1450
|
+
.prepare(`INSERT INTO tasks (id, space_id, number, parent_id, depth, type, title, description, status, priority, position,
|
|
1451
|
+
created_by, created_at, updated_at, version)
|
|
1448
1452
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
|
|
1449
1453
|
.run(task.id, task.spaceId, task.number, task.parentId, task.depth, task.type, task.title, task.description, task.status, task.priority, task.position, task.createdBy, task.createdAt, task.updatedAt, task.version);
|
|
1450
1454
|
this.db.prepare("UPDATE spaces SET next_task_number = next_task_number + 1 WHERE id = ?").run(space.id);
|
|
@@ -1478,7 +1482,7 @@ export class Mutation {
|
|
|
1478
1482
|
const testedTaskId = fields.testedTaskId !== undefined ? fields.testedTaskId : type === "standard" ? null : current.testedTaskId;
|
|
1479
1483
|
const task = validate(TaskSchema, { ...current, ...fields, parentId, depth, status, position, testedTaskId, updatedAt: this.now }, "task");
|
|
1480
1484
|
this.db
|
|
1481
|
-
.prepare(`UPDATE tasks SET parent_id = ?, depth = ?, type = ?, title = ?, description = ?, status = ?, priority = ?,
|
|
1485
|
+
.prepare(`UPDATE tasks SET parent_id = ?, depth = ?, type = ?, title = ?, description = ?, status = ?, priority = ?,
|
|
1482
1486
|
position = ?, tested_task_id = ?, updated_at = ? WHERE id = ?`)
|
|
1483
1487
|
.run(task.parentId, task.depth, task.type, task.title, task.description, task.status, task.priority, task.position, task.testedTaskId, task.updatedAt, id);
|
|
1484
1488
|
this.touch("task", id, task.spaceId, null);
|
|
@@ -1737,7 +1741,7 @@ export class Mutation {
|
|
|
1737
1741
|
updatedAt: this.now,
|
|
1738
1742
|
}, "test result");
|
|
1739
1743
|
this.db
|
|
1740
|
-
.prepare(`INSERT INTO test_results (checkpoint_id, tester_id, result, comment, updated_at) VALUES (?, ?, ?, ?, ?)
|
|
1744
|
+
.prepare(`INSERT INTO test_results (checkpoint_id, tester_id, result, comment, updated_at) VALUES (?, ?, ?, ?, ?)
|
|
1741
1745
|
ON CONFLICT (checkpoint_id, tester_id) DO UPDATE SET result = excluded.result, comment = excluded.comment, updated_at = excluded.updated_at`)
|
|
1742
1746
|
.run(result.checkpointId, result.testerId, result.result, result.comment, result.updatedAt);
|
|
1743
1747
|
this.touch("test_result", `${checkpointId}:${testerId}`, task.spaceId, null, task.id);
|
|
@@ -1900,7 +1904,7 @@ export class Mutation {
|
|
|
1900
1904
|
createdAt: this.now,
|
|
1901
1905
|
}, "idea");
|
|
1902
1906
|
this.db
|
|
1903
|
-
.prepare(`INSERT INTO ideas (id, space_id, author_id, text, origin, request_id, promoted_task_id, archived_at, created_at)
|
|
1907
|
+
.prepare(`INSERT INTO ideas (id, space_id, author_id, text, origin, request_id, promoted_task_id, archived_at, created_at)
|
|
1904
1908
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`)
|
|
1905
1909
|
.run(idea.id, idea.spaceId, idea.authorId, idea.text, idea.origin, idea.requestId, idea.promotedTaskId, idea.archivedAt, idea.createdAt);
|
|
1906
1910
|
this.touch("idea", idea.id, idea.spaceId, null);
|
|
@@ -1960,7 +1964,7 @@ export class Mutation {
|
|
|
1960
1964
|
}
|
|
1961
1965
|
insertBoardView(view) {
|
|
1962
1966
|
this.db
|
|
1963
|
-
.prepare(`INSERT INTO board_views (id, space_id, user_id, name, layout, group_by, then_by, show_empty_groups, statuses, priorities, assignee_ids, unassigned, position, created_at, updated_at)
|
|
1967
|
+
.prepare(`INSERT INTO board_views (id, space_id, user_id, name, layout, group_by, then_by, show_empty_groups, statuses, priorities, assignee_ids, unassigned, position, created_at, updated_at)
|
|
1964
1968
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
|
|
1965
1969
|
.run(view.id, view.spaceId, view.userId, view.name, view.layout, view.groupBy, view.thenBy, view.showEmptyGroups ? 1 : 0, JSON.stringify(view.statuses), JSON.stringify(view.priorities), JSON.stringify(view.assigneeIds), view.unassigned ? 1 : 0, view.position, view.createdAt, view.updatedAt);
|
|
1966
1970
|
this.touch("board_view", view.id, null, view.userId, null, view.spaceId);
|
|
@@ -1969,7 +1973,7 @@ export class Mutation {
|
|
|
1969
1973
|
const current = this.store.getBoardView(id);
|
|
1970
1974
|
const view = validate(BoardViewSchema, { ...current, ...normalizedSettings({ ...current, ...definedFields(patch) }), updatedAt: this.now }, "board view");
|
|
1971
1975
|
this.db
|
|
1972
|
-
.prepare(`UPDATE board_views SET name = ?, layout = ?, group_by = ?, then_by = ?, show_empty_groups = ?, statuses = ?, priorities = ?, assignee_ids = ?, unassigned = ?, updated_at = ?
|
|
1976
|
+
.prepare(`UPDATE board_views SET name = ?, layout = ?, group_by = ?, then_by = ?, show_empty_groups = ?, statuses = ?, priorities = ?, assignee_ids = ?, unassigned = ?, updated_at = ?
|
|
1973
1977
|
WHERE id = ?`)
|
|
1974
1978
|
.run(view.name, view.layout, view.groupBy, view.thenBy, view.showEmptyGroups ? 1 : 0, JSON.stringify(view.statuses), JSON.stringify(view.priorities), JSON.stringify(view.assigneeIds), view.unassigned ? 1 : 0, view.updatedAt, id);
|
|
1975
1979
|
this.touch("board_view", id, null, view.userId, null, view.spaceId);
|
|
@@ -2009,8 +2013,8 @@ export class Mutation {
|
|
|
2009
2013
|
}, "request");
|
|
2010
2014
|
this.store.getSpace(request.targetSpaceId);
|
|
2011
2015
|
this.db
|
|
2012
|
-
.prepare(`INSERT INTO agent_requests (id, author_id, target_space_id, kind, context_task_id, context_idea_id,
|
|
2013
|
-
text, status, parent_request_id, comment_id, created_at, updated_at)
|
|
2016
|
+
.prepare(`INSERT INTO agent_requests (id, author_id, target_space_id, kind, context_task_id, context_idea_id,
|
|
2017
|
+
text, status, parent_request_id, comment_id, created_at, updated_at)
|
|
2014
2018
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
|
|
2015
2019
|
.run(request.id, request.authorId, request.targetSpaceId, request.kind, request.contextTaskId, request.contextIdeaId, request.text, request.status, request.parentRequestId, request.commentId, request.createdAt, request.updatedAt);
|
|
2016
2020
|
this.createdRequestIds.add(request.id);
|
|
@@ -2078,7 +2082,7 @@ export class Mutation {
|
|
|
2078
2082
|
if (current.status !== "failed" || current.stoppedAt === null)
|
|
2079
2083
|
throw new InvariantError(`Request ${id} is ${current.status}: only a stopped request can be relaunched.`);
|
|
2080
2084
|
this.db
|
|
2081
|
-
.prepare(`UPDATE agent_requests SET status = 'pending', claimed_at = NULL, claimed_by_token_id = NULL, completed_at = NULL, failure_reason = NULL,
|
|
2085
|
+
.prepare(`UPDATE agent_requests SET status = 'pending', claimed_at = NULL, claimed_by_token_id = NULL, completed_at = NULL, failure_reason = NULL,
|
|
2082
2086
|
stopped_at = NULL, stopped_by = NULL, updated_at = ? WHERE id = ?`)
|
|
2083
2087
|
.run(this.now, id);
|
|
2084
2088
|
this.db.prepare("DELETE FROM follow_ups WHERE request_id = ?").run(id);
|
|
@@ -2101,10 +2105,82 @@ export class Mutation {
|
|
|
2101
2105
|
}
|
|
2102
2106
|
/** Demande et jeton de l'agent acteur. */
|
|
2103
2107
|
agentRequest() {
|
|
2104
|
-
if (!this.
|
|
2108
|
+
if (!this.token)
|
|
2105
2109
|
throw new InvariantError("Only the agent can claim, complete or fail a request, or record an agent action.");
|
|
2110
|
+
if (!this.request)
|
|
2111
|
+
throw new InvariantError("The agent acts for a request it claimed, or in a direct batch opened first.");
|
|
2106
2112
|
return { request: this.request, token: this.token };
|
|
2107
2113
|
}
|
|
2114
|
+
/**
|
|
2115
|
+
* Ouvre le lot d'une action directe de l'agent, sans demande : une demande
|
|
2116
|
+
* `direct` du propriétaire du jeton, dans l'espace du jeton, prise par ce
|
|
2117
|
+
* jeton. Le runner du site n'agit que pour les demandes qu'il prend.
|
|
2118
|
+
*/
|
|
2119
|
+
openDirectRequest() {
|
|
2120
|
+
const token = this.token;
|
|
2121
|
+
if (this.actor.type !== "agent" || this.actor.requestId !== null || !token || this.request) {
|
|
2122
|
+
throw new InvariantError("Only an agent acting without a request can open a direct batch, once per mutation.");
|
|
2123
|
+
}
|
|
2124
|
+
if (token.isRunner)
|
|
2125
|
+
throw new ForbiddenError("The site runner acts only for the requests it claims: pass the request_id of the request you process.");
|
|
2126
|
+
const request = validate(AgentRequestSchema, {
|
|
2127
|
+
id: newId(),
|
|
2128
|
+
authorId: token.userId,
|
|
2129
|
+
targetSpaceId: token.spaceId,
|
|
2130
|
+
kind: "direct",
|
|
2131
|
+
contextTaskId: null,
|
|
2132
|
+
contextIdeaId: null,
|
|
2133
|
+
text: DIRECT_REQUEST_TEXT,
|
|
2134
|
+
status: "processing",
|
|
2135
|
+
reply: null,
|
|
2136
|
+
failureReason: null,
|
|
2137
|
+
parentRequestId: null,
|
|
2138
|
+
commentId: null,
|
|
2139
|
+
createdAt: this.now,
|
|
2140
|
+
updatedAt: this.now,
|
|
2141
|
+
claimedAt: this.now,
|
|
2142
|
+
claimedByTokenId: token.id,
|
|
2143
|
+
completedAt: null,
|
|
2144
|
+
cancelledBy: null,
|
|
2145
|
+
stoppedAt: null,
|
|
2146
|
+
stoppedBy: null,
|
|
2147
|
+
}, "request");
|
|
2148
|
+
this.db
|
|
2149
|
+
.prepare(`INSERT INTO agent_requests (id, author_id, target_space_id, kind, text, status, created_at, updated_at, claimed_at, claimed_by_token_id)
|
|
2150
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
|
|
2151
|
+
.run(request.id, request.authorId, request.targetSpaceId, request.kind, request.text, request.status, request.createdAt, request.updatedAt, request.claimedAt, request.claimedByTokenId);
|
|
2152
|
+
this.createdRequestIds.add(request.id);
|
|
2153
|
+
this.request = request;
|
|
2154
|
+
this.touchRequest(request);
|
|
2155
|
+
return request;
|
|
2156
|
+
}
|
|
2157
|
+
/** Clôt le lot direct ouvert par `openDirectRequest` : la demande est traitée et son texte (markdown) liste `lines`, une ligne par action du lot. */
|
|
2158
|
+
closeDirectRequest(lines) {
|
|
2159
|
+
const { request } = this.agentRequest();
|
|
2160
|
+
if (request.kind !== "direct" || request.status !== "processing")
|
|
2161
|
+
throw new InvariantError(`Request ${request.id} is not an open direct batch.`);
|
|
2162
|
+
const text = lines.length === 0 ? DIRECT_REQUEST_TEXT : lines.length === 1 ? lines[0] : lines.map((line) => `- ${line}`).join("\n");
|
|
2163
|
+
this.db.prepare("UPDATE agent_requests SET text = ?, status = 'done', completed_at = ?, updated_at = ? WHERE id = ?").run(text, this.now, this.now, request.id);
|
|
2164
|
+
const closed = this.store.getAgentRequest(request.id);
|
|
2165
|
+
this.request = closed;
|
|
2166
|
+
this.touchRequest(closed);
|
|
2167
|
+
return closed;
|
|
2168
|
+
}
|
|
2169
|
+
/**
|
|
2170
|
+
* Clôt le lot direct ouvert par `openDirectRequest` en compte rendu : la
|
|
2171
|
+
* demande est traitée avec `reply` pour réponse et laisse `followUps` au
|
|
2172
|
+
* propriétaire du jeton, qui en est notifié.
|
|
2173
|
+
*/
|
|
2174
|
+
reportDirectRequest(reply, followUps) {
|
|
2175
|
+
const { request } = this.agentRequest();
|
|
2176
|
+
if (request.kind !== "direct" || request.status !== "processing")
|
|
2177
|
+
throw new InvariantError(`Request ${request.id} is not an open direct batch.`);
|
|
2178
|
+
if (followUps.every((point) => point.trim() === ""))
|
|
2179
|
+
throw new OrganizerError("A report leaves at least one point to your token's owner: pass them in follow_ups.");
|
|
2180
|
+
this.db.prepare("UPDATE agent_requests SET text = ? WHERE id = ?").run(DIRECT_REPORT_TEXT, request.id);
|
|
2181
|
+
this.request = this.store.getAgentRequest(request.id);
|
|
2182
|
+
return this.completeAgentRequest(reply, followUps);
|
|
2183
|
+
}
|
|
2108
2184
|
/**
|
|
2109
2185
|
* L'agent prend sa demande avec son jeton : `pending` devient `processing`
|
|
2110
2186
|
* et la demande est réservée à ce jeton. La mise à jour conditionnelle, dans
|
|
@@ -2210,7 +2286,7 @@ export class Mutation {
|
|
|
2210
2286
|
tokenId: token.id,
|
|
2211
2287
|
}, "agent action");
|
|
2212
2288
|
this.db
|
|
2213
|
-
.prepare(`INSERT INTO agent_actions (id, request_id, seq, entity_type, entity_id, operation, before, after, summary, created_at, token_id)
|
|
2289
|
+
.prepare(`INSERT INTO agent_actions (id, request_id, seq, entity_type, entity_id, operation, before, after, summary, created_at, token_id)
|
|
2214
2290
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
|
|
2215
2291
|
.run(action.id, action.requestId, action.seq, action.entityType, action.entityId, action.operation, action.before === null ? null : JSON.stringify(action.before), action.after === null ? null : JSON.stringify(action.after), action.summary, action.createdAt, action.tokenId);
|
|
2216
2292
|
this.touch("agent_action", action.id, request.targetSpaceId, null, input.taskId);
|
|
@@ -2269,7 +2345,7 @@ export class Mutation {
|
|
|
2269
2345
|
emailError: null,
|
|
2270
2346
|
}, "notification");
|
|
2271
2347
|
this.db
|
|
2272
|
-
.prepare(`INSERT INTO notifications (id, user_id, type, task_id, actor_type, actor_id, request_id, comment_id, in_app, created_at)
|
|
2348
|
+
.prepare(`INSERT INTO notifications (id, user_id, type, task_id, actor_type, actor_id, request_id, comment_id, in_app, created_at)
|
|
2273
2349
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
|
|
2274
2350
|
.run(notification.id, notification.userId, notification.type, notification.taskId, notification.actorType, notification.actorId, notification.requestId, notification.commentId, inApp ? 1 : 0, notification.createdAt);
|
|
2275
2351
|
if (inApp)
|
|
@@ -2311,7 +2387,7 @@ export class Mutation {
|
|
|
2311
2387
|
updateUserSettings(userId, patch) {
|
|
2312
2388
|
const settings = validate(UserSettingsSchema, { ...this.store.getUserSettings(userId), ...definedFields(patch) }, "settings");
|
|
2313
2389
|
this.db
|
|
2314
|
-
.prepare(`UPDATE user_settings SET notify_assign_app = ?, notify_assign_email = ?, notify_comment_app = ?, notify_comment_email = ?,
|
|
2390
|
+
.prepare(`UPDATE user_settings SET notify_assign_app = ?, notify_assign_email = ?, notify_comment_app = ?, notify_comment_email = ?,
|
|
2315
2391
|
notify_follow_up_app = ?, notify_follow_up_email = ?, assistant_history = ? WHERE user_id = ?`)
|
|
2316
2392
|
.run(settings.notifyAssignApp ? 1 : 0, settings.notifyAssignEmail ? 1 : 0, settings.notifyCommentApp ? 1 : 0, settings.notifyCommentEmail ? 1 : 0, settings.notifyFollowUpApp ? 1 : 0, settings.notifyFollowUpEmail ? 1 : 0, settings.assistantHistory, userId);
|
|
2317
2393
|
this.touch("user_settings", userId, null, userId);
|
|
@@ -2331,11 +2407,11 @@ export class Mutation {
|
|
|
2331
2407
|
}
|
|
2332
2408
|
const settings = validate(SpaceNotificationSettingsSchema, { userId, spaceId, ...preferences }, "space notification settings");
|
|
2333
2409
|
this.db
|
|
2334
|
-
.prepare(`INSERT INTO space_notification_settings (user_id, space_id, notify_assign_app, notify_assign_email, notify_comment_app, notify_comment_email,
|
|
2335
|
-
notify_follow_up_app, notify_follow_up_email)
|
|
2336
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
|
2337
|
-
ON CONFLICT (user_id, space_id) DO UPDATE SET notify_assign_app = excluded.notify_assign_app, notify_assign_email = excluded.notify_assign_email,
|
|
2338
|
-
notify_comment_app = excluded.notify_comment_app, notify_comment_email = excluded.notify_comment_email,
|
|
2410
|
+
.prepare(`INSERT INTO space_notification_settings (user_id, space_id, notify_assign_app, notify_assign_email, notify_comment_app, notify_comment_email,
|
|
2411
|
+
notify_follow_up_app, notify_follow_up_email)
|
|
2412
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
|
2413
|
+
ON CONFLICT (user_id, space_id) DO UPDATE SET notify_assign_app = excluded.notify_assign_app, notify_assign_email = excluded.notify_assign_email,
|
|
2414
|
+
notify_comment_app = excluded.notify_comment_app, notify_comment_email = excluded.notify_comment_email,
|
|
2339
2415
|
notify_follow_up_app = excluded.notify_follow_up_app, notify_follow_up_email = excluded.notify_follow_up_email`)
|
|
2340
2416
|
.run(userId, spaceId, settings.notifyAssignApp ? 1 : 0, settings.notifyAssignEmail ? 1 : 0, settings.notifyCommentApp ? 1 : 0, settings.notifyCommentEmail ? 1 : 0, settings.notifyFollowUpApp ? 1 : 0, settings.notifyFollowUpEmail ? 1 : 0);
|
|
2341
2417
|
return settings;
|
|
@@ -2373,7 +2449,7 @@ export class Mutation {
|
|
|
2373
2449
|
recordRunnerSession(record) {
|
|
2374
2450
|
const valid = validate(RunnerSessionRecordSchema, record, "runner session");
|
|
2375
2451
|
this.db
|
|
2376
|
-
.prepare(`INSERT INTO runner_sessions (id, space_id, space_name, started_at, ended_at, outcome, model, turns, cost_usd, input_tokens, output_tokens, cache_read_tokens, cache_creation_tokens)
|
|
2452
|
+
.prepare(`INSERT INTO runner_sessions (id, space_id, space_name, started_at, ended_at, outcome, model, turns, cost_usd, input_tokens, output_tokens, cache_read_tokens, cache_creation_tokens)
|
|
2377
2453
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
|
|
2378
2454
|
.run(valid.id, valid.spaceId, valid.spaceName, valid.startedAt, valid.endedAt, valid.outcome, valid.model, valid.turns, valid.costUsd, valid.inputTokens, valid.outputTokens, valid.cacheReadTokens, valid.cacheCreationTokens);
|
|
2379
2455
|
}
|
|
@@ -2453,8 +2529,8 @@ export class Mutation {
|
|
|
2453
2529
|
}
|
|
2454
2530
|
}
|
|
2455
2531
|
const outsiders = this.db
|
|
2456
|
-
.prepare(`SELECT t.number AS number, x.user_id AS user_id FROM task_assignees x JOIN tasks t ON t.id = x.task_id
|
|
2457
|
-
WHERE t.space_id = ? AND NOT EXISTS (SELECT 1 FROM memberships m WHERE m.space_id = t.space_id AND m.user_id = x.user_id)
|
|
2532
|
+
.prepare(`SELECT t.number AS number, x.user_id AS user_id FROM task_assignees x JOIN tasks t ON t.id = x.task_id
|
|
2533
|
+
WHERE t.space_id = ? AND NOT EXISTS (SELECT 1 FROM memberships m WHERE m.space_id = t.space_id AND m.user_id = x.user_id)
|
|
2458
2534
|
ORDER BY t.number LIMIT 1`)
|
|
2459
2535
|
.get(space.id);
|
|
2460
2536
|
if (outsiders) {
|
|
@@ -2526,7 +2602,7 @@ export class Mutation {
|
|
|
2526
2602
|
const actorId = this.actingUserId;
|
|
2527
2603
|
const requestId = this.request?.id ?? null;
|
|
2528
2604
|
const tokenId = this.token?.id ?? null;
|
|
2529
|
-
const insert = this.db.prepare(`INSERT INTO entity_versions (entity_type, entity_id, version, snapshot, actor_type, actor_id, request_id, created_at, token_id)
|
|
2605
|
+
const insert = this.db.prepare(`INSERT INTO entity_versions (entity_type, entity_id, version, snapshot, actor_type, actor_id, request_id, created_at, token_id)
|
|
2530
2606
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`);
|
|
2531
2607
|
for (const entry of this.touched.values()) {
|
|
2532
2608
|
if (!VERSIONED.has(entry.entityType))
|
|
@@ -2548,7 +2624,7 @@ export class Mutation {
|
|
|
2548
2624
|
}
|
|
2549
2625
|
/** Une ligne du journal par entité modifiée, avec l'auteur de la mutation. */
|
|
2550
2626
|
writeChanges() {
|
|
2551
|
-
const insert = this.db.prepare(`INSERT INTO changes (space_id, user_id, entity_type, entity_id, task_id, at, actor_type, actor_id, request_id)
|
|
2627
|
+
const insert = this.db.prepare(`INSERT INTO changes (space_id, user_id, entity_type, entity_id, task_id, at, actor_type, actor_id, request_id)
|
|
2552
2628
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`);
|
|
2553
2629
|
const actorId = this.actingUserId;
|
|
2554
2630
|
const requestId = this.request?.id ?? null;
|
package/dist/src/index.js
CHANGED
|
@@ -5,35 +5,35 @@ import { APP_VERSION } from "./version.js";
|
|
|
5
5
|
import { ConfigError } from "./core/errors.js";
|
|
6
6
|
import { findProjectRoot } from "./core/project-root.js";
|
|
7
7
|
import { loadEnvFile, resolveEnvFile, withoutEnvFileFlag } from "./core/env-file.js";
|
|
8
|
-
const USAGE = `mcp-organizer v${APP_VERSION} — gestionnaire de tâches multi-utilisateur piloté par un agent
|
|
9
|
-
|
|
10
|
-
Usage :
|
|
11
|
-
mcp-organizer Mode MCP (stdio) : outils de l'agent, relayés à l'API du site.
|
|
12
|
-
mcp-organizer --server Site web : interface, API et base de données, sur HOST:PORT.
|
|
13
|
-
mcp-organizer --set-user [email] [--name="Prénom Nom"] [--non-interactive]
|
|
14
|
-
Crée un compte ou remplace son mot de passe.
|
|
15
|
-
mcp-organizer --set-admin <email> [--revoke]
|
|
16
|
-
Accorde (ou retire) le rôle d'administrateur du site à un compte actif.
|
|
17
|
-
Le premier compte créé est administrateur d'office.
|
|
18
|
-
mcp-organizer --setup [options] Installe le site : .env, unité systemd, bloc nginx, premier compte
|
|
19
|
-
(interactif, ou --non-interactive ; --setup --help pour les options).
|
|
20
|
-
mcp-organizer --backup <fichier> [--force]
|
|
21
|
-
Sauvegarde la base (site en service ou non) et ses pièces jointes
|
|
22
|
-
(dossier <fichier>.attachments).
|
|
23
|
-
mcp-organizer --claude-setup-mcp [--force] --url=<URL du site> --token=<jeton>
|
|
24
|
-
Écrit l'entrée du mode MCP dans ./.mcp.json.
|
|
25
|
-
mcp-organizer --watch <id du jeton>
|
|
26
|
-
Veilleur de notifications : une ligne par demande passée en attente.
|
|
27
|
-
Lancé par l'outil Monitor de l'agent, avec la commande que rend
|
|
28
|
-
l'outil enable_notifications.
|
|
29
|
-
mcp-organizer --version Affiche la version.
|
|
30
|
-
mcp-organizer --help Affiche cette aide.
|
|
31
|
-
|
|
32
|
-
Option commune : --dotenv=<fichier> lit ce fichier .env. Sans elle, le site et ses commandes
|
|
33
|
-
lisent <package>/.env ; le mode MCP n'en lit aucun.
|
|
34
|
-
Le site exige PORT et ORGANIZER_PUBLIC_URL ; HOST vaut 127.0.0.1 par défaut.
|
|
35
|
-
Le mode MCP exige ORGANIZER_URL (URL publique du site, en https hors de la machine locale)
|
|
36
|
-
et ORGANIZER_TOKEN (jeton d'agent), fournis par son environnement.
|
|
8
|
+
const USAGE = `mcp-organizer v${APP_VERSION} — gestionnaire de tâches multi-utilisateur piloté par un agent
|
|
9
|
+
|
|
10
|
+
Usage :
|
|
11
|
+
mcp-organizer Mode MCP (stdio) : outils de l'agent, relayés à l'API du site.
|
|
12
|
+
mcp-organizer --server Site web : interface, API et base de données, sur HOST:PORT.
|
|
13
|
+
mcp-organizer --set-user [email] [--name="Prénom Nom"] [--non-interactive]
|
|
14
|
+
Crée un compte ou remplace son mot de passe.
|
|
15
|
+
mcp-organizer --set-admin <email> [--revoke]
|
|
16
|
+
Accorde (ou retire) le rôle d'administrateur du site à un compte actif.
|
|
17
|
+
Le premier compte créé est administrateur d'office.
|
|
18
|
+
mcp-organizer --setup [options] Installe le site : .env, unité systemd, bloc nginx, premier compte
|
|
19
|
+
(interactif, ou --non-interactive ; --setup --help pour les options).
|
|
20
|
+
mcp-organizer --backup <fichier> [--force]
|
|
21
|
+
Sauvegarde la base (site en service ou non) et ses pièces jointes
|
|
22
|
+
(dossier <fichier>.attachments).
|
|
23
|
+
mcp-organizer --claude-setup-mcp [--force] --url=<URL du site> --token=<jeton>
|
|
24
|
+
Écrit l'entrée du mode MCP dans ./.mcp.json.
|
|
25
|
+
mcp-organizer --watch <id du jeton>
|
|
26
|
+
Veilleur de notifications : une ligne par demande passée en attente.
|
|
27
|
+
Lancé par l'outil Monitor de l'agent, avec la commande que rend
|
|
28
|
+
l'outil enable_notifications.
|
|
29
|
+
mcp-organizer --version Affiche la version.
|
|
30
|
+
mcp-organizer --help Affiche cette aide.
|
|
31
|
+
|
|
32
|
+
Option commune : --dotenv=<fichier> lit ce fichier .env. Sans elle, le site et ses commandes
|
|
33
|
+
lisent <package>/.env ; le mode MCP n'en lit aucun.
|
|
34
|
+
Le site exige PORT et ORGANIZER_PUBLIC_URL ; HOST vaut 127.0.0.1 par défaut.
|
|
35
|
+
Le mode MCP exige ORGANIZER_URL (URL publique du site, en https hors de la machine locale)
|
|
36
|
+
et ORGANIZER_TOKEN (jeton d'agent), fournis par son environnement.
|
|
37
37
|
Voir le README pour la liste complète des variables.`;
|
|
38
38
|
/** Commandes qui ouvrent la base du site ; toute autre invocation démarre le mode MCP. */
|
|
39
39
|
const SITE_COMMANDS = ["--server", "--set-user", "--set-admin", "--setup", "--backup"];
|
package/dist/src/mcp/start.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type SiteConnection } from "./client.js";
|
|
2
2
|
/** Présentation du serveur transmise au client MCP : concepts et déroulé. */
|
|
3
|
-
export declare const INSTRUCTIONS = "mcp-organizer connects you to an organizer site: a multi-user task manager where people organize tasks in a web app and queue requests for the AI. You, the connected agent, process those requests when the user asks you to. The site never calls an LLM: you are the intelligence.\n\nYour token covers exactly one space, with the rights of the user who created the token. Every tool works on that space.\n\nConcepts:\n- A **space** holds tasks and an idea box. A user's **personal space** is private; a **shared space** has one owner and members.\n- A **task** has a title, a markdown description, a status (todo, doing, review, done), a priority (low, medium, high, critical), assignees and tags. Tasks nest on two levels: task > sub-task > sub-sub-task. A task is either standard (with a checklist) or a test (with checkpoints that each tester marks ok, ko, blocked or untested).\n- A **request** is something a member of your space asked the AI: an idea, a remark, a test review, a message or an idea promotion. It is pending, then processing once you claim it (only your token can then act for it), then done (with your reply and the points left to its author) or failed (with the reason). The points left to the author are checkboxes the members tick off. A **follow-up** is a message a member sends from a handled request: claim_request shows that original request, your reply and its points with their ids, and check_follow_ups ticks off the points the follow-up settles. A member can also hand a request to you by mentioning @agent in a comment of a task: claim_request then shows the task's thread, and complete_request posts your reply as a comment right after theirs.\n- A **batch** is the set of actions you perform for one request. Every action is logged with its before and after state and with your token, and users can undo one action or the whole batch.\n- A **view** is a tab of a member's dashboard: a layout (kanban, list, matrix), groupings by status or priority, and filters on status, priority and assignees. Each member has their own views in each space.\n- The **scope** of your work is the space of your token: you see and process the requests of all its members, and you never act outside it. You change the views of the author of the request you process, and nobody else's: only when the author owns your token, or when you are the site runner.\n\nWork loop, when the user asks you to process the queue:\n1. list_requests to see the pending requests of your space.\n2. claim_request on the oldest one: it becomes processing for you and you get its context (text, author, context task, for a message the previous exchanges of its author, task tree, members, recent ideas), along with the custom instructions of the site and of the space, which you follow. get_context shows the space at any time.\n3. Read what you need with get_task and search_tasks.\n4. Act with create_task, update_task, set_assignees, set_tags, edit_checklist, add_comment, create_idea, update_idea, promote_idea, with list_views, create_view, update_view, delete_view when the author asks how their board should look, and with check_follow_ups for a follow-up \u2014 always passing the request_id. Each write is one undoable action of the batch.\n5. complete_request with a short reply in the author's language and, in follow_ups, every point the author still has to handle (or fail_request with the reason), then go back to step 1 until no request is pending.\nWhen the queue is empty, tell the user.\n\nNotifications: call enable_notifications once at the start of the session and arm the watcher it hands you with Monitor, whatever the command (behind mcp-http-gateway, the gateway relay answers in place of this server and gives its own watcher command). Each request that becomes pending in your space then arrives on its own as one line (kind, author, excerpt, request id), even while you are idle: process it with the work loop above, starting with claim_request. The host stops that watcher after 30 minutes at most: each time it tells you the watcher expired, re-arm it at once with the same Monitor call; otherwise notifications stop for good. A line \"notifications stopped\" means the site refused the token, and a line \"[gateway-watch] \u2026 la veille \u00E9choue\" means the gateway watcher keeps failing: tell the user. wait_for_requests is the waiting tool of the watcher: you do not need to call it.\n\nHow to handle each kind of request:\n- **idea**: classify it. If it belongs to an existing task or sub-task, attach it there (sub-task, checklist item or comment). If it is actionable and important enough, create a task (or sub-task) with a fitting priority. Otherwise, put it in the idea box with create_idea. Prefer existing tasks over duplicates.\n- **test_review**: feed the tester's findings back into the existing tasks (status, checklist, comments, priority of the affected tasks), or create a task for each problem that has none.\n- **remark** and **message**: do whatever is useful \u2014 answer, update or create tasks, comment \u2014 and say what you did in the reply.\n- **idea_promotion**: turn the context idea into a well-formed task with promote_idea.\n\nRules: write titles, descriptions and replies in the language of the users; keep the reply short and factual (markdown is rendered); never bury in the reply something the author must act on: it belongs in follow_ups. Errors tell you what to do next; an error about the token (missing, revoked, expired, owner no longer a member) cannot be fixed by retrying: tell the user.";
|
|
3
|
+
export declare const INSTRUCTIONS = "mcp-organizer connects you to an organizer site: a multi-user task manager where people organize tasks in a web app and queue requests for the AI. You, the connected agent, process those requests when the user asks you to. The site never calls an LLM: you are the intelligence.\n\nYour token covers exactly one space, with the rights of the user who created the token. Every tool works on that space.\n\nConcepts:\n- A **space** holds tasks and an idea box. A user's **personal space** is private; a **shared space** has one owner and members.\n- A **task** has a title, a markdown description, a status (todo, doing, review, done), a priority (low, medium, high, critical), assignees and tags. Tasks nest on two levels: task > sub-task > sub-sub-task. A task is either standard (with a checklist) or a test (with checkpoints that each tester marks ok, ko, blocked or untested).\n- A **request** is something a member of your space asked the AI: an idea, a remark, a test review, a message or an idea promotion. It is pending, then processing once you claim it (only your token can then act for it), then done (with your reply and the points left to its author) or failed (with the reason). The points left to the author are checkboxes the members tick off. A **follow-up** is a message a member sends from a handled request: claim_request shows that original request, your reply and its points with their ids, and check_follow_ups ticks off the points the follow-up settles. A member can also hand a request to you by mentioning @agent in a comment of a task: claim_request then shows the task's thread, and complete_request posts your reply as a comment right after theirs.\n- A **batch** is the set of actions you perform for one request. Every action is logged with its before and after state and with your token, and users can undo one action or the whole batch.\n- A **direct action** is a write you make without request_id, when your user asks you directly (in their editor, for example) rather than through a request: it is done in the name of your token's owner and forms its own batch, listed among the requests of the space as a direct action and undoable like any other. The site runner never acts directly: it always passes the request_id of the request it processes.\n- A **view** is a tab of a member's dashboard: a layout (kanban, list, matrix), groupings by status or priority, and filters on status, priority and assignees. Each member has their own views in each space.\n- The **scope** of your work is the space of your token: you see and process the requests of all its members, and you never act outside it. You change the views of the author of the request you process, and nobody else's: only when the author owns your token, or when you are the site runner. A direct action on views changes those of your token's owner.\n\nWork loop, when the user asks you to process the queue:\n1. list_requests to see the pending requests of your space.\n2. claim_request on the oldest one: it becomes processing for you and you get its context (text, author, context task, for a message the previous exchanges of its author, task tree, members, recent ideas), along with the custom instructions of the site and of the space, which you follow. get_context shows the space at any time.\n3. Read what you need with get_task and search_tasks.\n4. Act with create_task, update_task, set_assignees, set_tags, edit_checklist, add_comment, create_idea, update_idea, promote_idea, with list_views, create_view, update_view, delete_view when the author asks how their board should look, and with check_follow_ups for a follow-up \u2014 always passing the request_id. Each write is one undoable action of the batch.\n5. complete_request with a short reply in the author's language and, in follow_ups, every point the author still has to handle (or fail_request with the reason), then go back to step 1 until no request is pending.\nWhen the queue is empty, tell the user.\n\nDirect work, when the user asks you to change the space outside any request: read with get_context, get_task and search_tasks, then call the write tools without request_id. Do not claim, complete or fail anything: there is no request to close. When your user still has points to handle afterwards, leave them with report_direct.\n\nNotifications: call enable_notifications once at the start of the session and arm the watcher it hands you with Monitor, whatever the command (behind mcp-http-gateway, the gateway relay answers in place of this server and gives its own watcher command). Each request that becomes pending in your space then arrives on its own as one line (kind, author, excerpt, request id), even while you are idle: process it with the work loop above, starting with claim_request. The host stops that watcher after 30 minutes at most: each time it tells you the watcher expired, re-arm it at once with the same Monitor call; otherwise notifications stop for good. A line \"notifications stopped\" means the site refused the token, and a line \"[gateway-watch] \u2026 la veille \u00E9choue\" means the gateway watcher keeps failing: tell the user. wait_for_requests is the waiting tool of the watcher: you do not need to call it.\n\nHow to handle each kind of request:\n- **idea**: classify it. If it belongs to an existing task or sub-task, attach it there (sub-task, checklist item or comment). If it is actionable and important enough, create a task (or sub-task) with a fitting priority. Otherwise, put it in the idea box with create_idea. Prefer existing tasks over duplicates.\n- **test_review**: feed the tester's findings back into the existing tasks (status, checklist, comments, priority of the affected tasks), or create a task for each problem that has none.\n- **remark** and **message**: do whatever is useful \u2014 answer, update or create tasks, comment \u2014 and say what you did in the reply.\n- **idea_promotion**: turn the context idea into a well-formed task with promote_idea.\n\nRules: write titles, descriptions and replies in the language of the users; keep the reply short and factual (markdown is rendered); never bury in the reply something the author must act on: it belongs in follow_ups. Errors tell you what to do next; an error about the token (missing, revoked, expired, owner no longer a member) cannot be fixed by retrying: tell the user.";
|
|
4
4
|
/**
|
|
5
5
|
* Connexion au site d'après `ORGANIZER_URL` et `ORGANIZER_TOKEN` ; une valeur
|
|
6
6
|
* absente ou invalide, ou une URL http vers une autre machine, est une `ConfigError`.
|
package/dist/src/mcp/start.js
CHANGED
|
@@ -18,8 +18,9 @@ Concepts:
|
|
|
18
18
|
- A **task** has a title, a markdown description, a status (todo, doing, review, done), a priority (low, medium, high, critical), assignees and tags. Tasks nest on two levels: task > sub-task > sub-sub-task. A task is either standard (with a checklist) or a test (with checkpoints that each tester marks ok, ko, blocked or untested).
|
|
19
19
|
- A **request** is something a member of your space asked the AI: an idea, a remark, a test review, a message or an idea promotion. It is pending, then processing once you claim it (only your token can then act for it), then done (with your reply and the points left to its author) or failed (with the reason). The points left to the author are checkboxes the members tick off. A **follow-up** is a message a member sends from a handled request: claim_request shows that original request, your reply and its points with their ids, and check_follow_ups ticks off the points the follow-up settles. A member can also hand a request to you by mentioning @agent in a comment of a task: claim_request then shows the task's thread, and complete_request posts your reply as a comment right after theirs.
|
|
20
20
|
- A **batch** is the set of actions you perform for one request. Every action is logged with its before and after state and with your token, and users can undo one action or the whole batch.
|
|
21
|
+
- A **direct action** is a write you make without request_id, when your user asks you directly (in their editor, for example) rather than through a request: it is done in the name of your token's owner and forms its own batch, listed among the requests of the space as a direct action and undoable like any other. The site runner never acts directly: it always passes the request_id of the request it processes.
|
|
21
22
|
- A **view** is a tab of a member's dashboard: a layout (kanban, list, matrix), groupings by status or priority, and filters on status, priority and assignees. Each member has their own views in each space.
|
|
22
|
-
- The **scope** of your work is the space of your token: you see and process the requests of all its members, and you never act outside it. You change the views of the author of the request you process, and nobody else's: only when the author owns your token, or when you are the site runner.
|
|
23
|
+
- The **scope** of your work is the space of your token: you see and process the requests of all its members, and you never act outside it. You change the views of the author of the request you process, and nobody else's: only when the author owns your token, or when you are the site runner. A direct action on views changes those of your token's owner.
|
|
23
24
|
|
|
24
25
|
Work loop, when the user asks you to process the queue:
|
|
25
26
|
1. list_requests to see the pending requests of your space.
|
|
@@ -29,6 +30,8 @@ Work loop, when the user asks you to process the queue:
|
|
|
29
30
|
5. complete_request with a short reply in the author's language and, in follow_ups, every point the author still has to handle (or fail_request with the reason), then go back to step 1 until no request is pending.
|
|
30
31
|
When the queue is empty, tell the user.
|
|
31
32
|
|
|
33
|
+
Direct work, when the user asks you to change the space outside any request: read with get_context, get_task and search_tasks, then call the write tools without request_id. Do not claim, complete or fail anything: there is no request to close. When your user still has points to handle afterwards, leave them with report_direct.
|
|
34
|
+
|
|
32
35
|
Notifications: call enable_notifications once at the start of the session and arm the watcher it hands you with Monitor, whatever the command (behind mcp-http-gateway, the gateway relay answers in place of this server and gives its own watcher command). Each request that becomes pending in your space then arrives on its own as one line (kind, author, excerpt, request id), even while you are idle: process it with the work loop above, starting with claim_request. The host stops that watcher after 30 minutes at most: each time it tells you the watcher expired, re-arm it at once with the same Monitor call; otherwise notifications stop for good. A line "notifications stopped" means the site refused the token, and a line "[gateway-watch] … la veille échoue" means the gateway watcher keeps failing: tell the user. wait_for_requests is the waiting tool of the watcher: you do not need to call it.
|
|
33
36
|
|
|
34
37
|
How to handle each kind of request:
|