@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
package/dist/src/core/store.js
CHANGED
|
@@ -4,8 +4,8 @@ import { positionBetween } from "../../shared/logic/positions.js";
|
|
|
4
4
|
import { newId } from "./ids.js";
|
|
5
5
|
import { WatcherRegistry } from "./watchers.js";
|
|
6
6
|
import { MAX_TASK_DEPTH, TASK_PRIORITIES, TASK_STATUSES, } from "../../shared/schemas/enums.schema.js";
|
|
7
|
-
import { AccessLinkSchema, AgentActionSchema, AgentInstructionsSchema, AgentTokenSchema, AgentRequestSchema, AttachmentSchema, BoardViewSchema, ChangeSchema, ChecklistItemSchema, CommentSchema, EntityVersionSchema, FollowUpSchema, IdeaSchema, IdeaSnapshotSchema, InvitationSchema, MembershipSchema, NotificationSchema, SessionSchema, SpaceSchema, TagSchema, TaskSchema, TaskSnapshotSchema, TestCheckpointSchema, TestResultSchema, TestReviewSchema, UserSchema, UserSettingsSchema, SpaceNotificationSettingsSchema, } from "../../shared/schemas/entities.schema.js";
|
|
8
|
-
import { RunnerSessionRecordSchema, RunnerSettingsSchema } from "../../shared/schemas/admin-api.schema.js";
|
|
7
|
+
import { AccessLinkSchema, AgentActionSchema, AgentInstructionsSchema, AgentTokenSchema, AgentRequestSchema, AttachmentSchema, BoardViewSchema, ChangeSchema, ChecklistItemSchema, CommentSchema, MAX_QUESTION_OPTIONS, QuestionOptionSchema, TaskQuestionSchema, EntityVersionSchema, FollowUpSchema, IdeaSchema, IdeaSnapshotSchema, InvitationSchema, MembershipSchema, NotificationSchema, SessionSchema, SpaceSchema, TagSchema, TaskSchema, TaskSnapshotSchema, TestCheckpointSchema, TestResultSchema, TestReviewSchema, UserSchema, UserSettingsSchema, SpaceNotificationSettingsSchema, } from "../../shared/schemas/entities.schema.js";
|
|
8
|
+
import { ClaudeConnectionSchema, RunnerSessionRecordSchema, RunnerSettingsSchema, } from "../../shared/schemas/admin-api.schema.js";
|
|
9
9
|
/** Valide `value` avec `schema` ; une donnée invalide est une erreur métier qui liste les champs fautifs. */
|
|
10
10
|
function validate(schema, value, what) {
|
|
11
11
|
const parsed = schema.safeParse(value);
|
|
@@ -254,6 +254,29 @@ function changeFromRow(row) {
|
|
|
254
254
|
function tagFromRow(row) {
|
|
255
255
|
return TagSchema.parse({ id: row.id, spaceId: row.space_id, name: row.name });
|
|
256
256
|
}
|
|
257
|
+
function questionFromRow(row) {
|
|
258
|
+
return TaskQuestionSchema.parse({
|
|
259
|
+
id: row.id,
|
|
260
|
+
taskId: row.task_id,
|
|
261
|
+
text: row.text,
|
|
262
|
+
multiple: bool(row.multiple),
|
|
263
|
+
otherAnswer: row.other_answer,
|
|
264
|
+
answeredBy: row.answered_by,
|
|
265
|
+
answeredAt: row.answered_at,
|
|
266
|
+
position: row.position,
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
function questionOptionFromRow(row) {
|
|
270
|
+
return QuestionOptionSchema.parse({
|
|
271
|
+
id: row.id,
|
|
272
|
+
questionId: row.question_id,
|
|
273
|
+
label: row.label,
|
|
274
|
+
detail: row.detail,
|
|
275
|
+
recommended: bool(row.recommended),
|
|
276
|
+
selected: bool(row.selected),
|
|
277
|
+
position: row.position,
|
|
278
|
+
});
|
|
279
|
+
}
|
|
257
280
|
function checklistItemFromRow(row) {
|
|
258
281
|
return ChecklistItemSchema.parse({ id: row.id, taskId: row.task_id, text: row.text, done: bool(row.done), position: row.position });
|
|
259
282
|
}
|
|
@@ -411,6 +434,20 @@ export class Store {
|
|
|
411
434
|
const row = this.db.prepare("SELECT * FROM runner_settings WHERE id = 1").get();
|
|
412
435
|
return RunnerSettingsSchema.parse({ maxTurns: row.max_turns, maxMinutes: row.max_minutes, maxBudgetUsd: row.max_budget_usd });
|
|
413
436
|
}
|
|
437
|
+
/** Connexion de Claude enregistrée, ou null tant qu'aucun token ne l'est. */
|
|
438
|
+
findClaudeConnection() {
|
|
439
|
+
const row = this.db.prepare("SELECT * FROM claude_connection WHERE id = 1").get();
|
|
440
|
+
if (!row)
|
|
441
|
+
return null;
|
|
442
|
+
return ClaudeConnectionSchema.parse({
|
|
443
|
+
tokenCipher: row.token_cipher,
|
|
444
|
+
tokenHint: row.token_hint,
|
|
445
|
+
savedAt: row.saved_at,
|
|
446
|
+
savedBy: row.saved_by,
|
|
447
|
+
refusedAt: row.refused_at,
|
|
448
|
+
refusedReason: row.refused_reason,
|
|
449
|
+
});
|
|
450
|
+
}
|
|
414
451
|
/** Sessions du runner commencées depuis `since`, de la plus récente à la plus ancienne. */
|
|
415
452
|
listRunnerSessionsSince(since) {
|
|
416
453
|
return this.db.prepare("SELECT * FROM runner_sessions WHERE started_at >= ? ORDER BY started_at DESC, id").all(since).map(runnerSessionFromRow);
|
|
@@ -634,6 +671,42 @@ export class Store {
|
|
|
634
671
|
const rows = this.db.prepare("SELECT * FROM checklist_items WHERE task_id = ? ORDER BY position").all(taskId);
|
|
635
672
|
return rows.map(checklistItemFromRow);
|
|
636
673
|
}
|
|
674
|
+
// --- Questions ---
|
|
675
|
+
findQuestion(id) {
|
|
676
|
+
const row = this.db.prepare("SELECT * FROM task_questions WHERE id = ?").get(id);
|
|
677
|
+
return row ? questionFromRow(row) : null;
|
|
678
|
+
}
|
|
679
|
+
getQuestion(id) {
|
|
680
|
+
const question = this.findQuestion(id);
|
|
681
|
+
if (!question)
|
|
682
|
+
throw new NotFoundError(`Question ${id} not found.`);
|
|
683
|
+
return question;
|
|
684
|
+
}
|
|
685
|
+
/** Questions d'une tâche, dans l'ordre. */
|
|
686
|
+
listQuestions(taskId) {
|
|
687
|
+
const rows = this.db.prepare("SELECT * FROM task_questions WHERE task_id = ? ORDER BY position").all(taskId);
|
|
688
|
+
return rows.map(questionFromRow);
|
|
689
|
+
}
|
|
690
|
+
findQuestionOption(id) {
|
|
691
|
+
const row = this.db.prepare("SELECT * FROM question_options WHERE id = ?").get(id);
|
|
692
|
+
return row ? questionOptionFromRow(row) : null;
|
|
693
|
+
}
|
|
694
|
+
/** Propositions d'une question, dans l'ordre. */
|
|
695
|
+
listQuestionOptions(questionId) {
|
|
696
|
+
const rows = this.db.prepare("SELECT * FROM question_options WHERE question_id = ? ORDER BY position").all(questionId);
|
|
697
|
+
return rows.map(questionOptionFromRow);
|
|
698
|
+
}
|
|
699
|
+
/** Question et ses propositions, ou null si elle n'existe pas. */
|
|
700
|
+
findQuestionSnapshot(id) {
|
|
701
|
+
const question = this.findQuestion(id);
|
|
702
|
+
return question ? { ...question, options: this.listQuestionOptions(id) } : null;
|
|
703
|
+
}
|
|
704
|
+
questionSnapshot(id) {
|
|
705
|
+
const snapshot = this.findQuestionSnapshot(id);
|
|
706
|
+
if (!snapshot)
|
|
707
|
+
throw new NotFoundError(`Question ${id} not found.`);
|
|
708
|
+
return snapshot;
|
|
709
|
+
}
|
|
637
710
|
// --- Tâches de test ---
|
|
638
711
|
findCheckpoint(id) {
|
|
639
712
|
const row = this.db.prepare("SELECT * FROM test_checkpoints WHERE id = ?").get(id);
|
|
@@ -1572,6 +1645,157 @@ export class Mutation {
|
|
|
1572
1645
|
this.touch("tag", tag.id, spaceId, null);
|
|
1573
1646
|
return tag;
|
|
1574
1647
|
}
|
|
1648
|
+
// --- Questions ---
|
|
1649
|
+
/** Ajoute une question en fin de liste d'une tâche, avec ses propositions dans l'ordre donné. */
|
|
1650
|
+
addQuestion(taskId, input) {
|
|
1651
|
+
const task = this.store.getTask(taskId);
|
|
1652
|
+
const last = this.store.listQuestions(taskId).at(-1);
|
|
1653
|
+
const question = validate(TaskQuestionSchema, {
|
|
1654
|
+
id: newId(),
|
|
1655
|
+
taskId,
|
|
1656
|
+
text: input.text,
|
|
1657
|
+
multiple: input.multiple,
|
|
1658
|
+
otherAnswer: null,
|
|
1659
|
+
answeredBy: null,
|
|
1660
|
+
answeredAt: null,
|
|
1661
|
+
position: positionBetween(last?.position ?? null, null),
|
|
1662
|
+
}, "question");
|
|
1663
|
+
this.insertQuestion(question);
|
|
1664
|
+
for (const option of input.options)
|
|
1665
|
+
this.addQuestionOption(question.id, option);
|
|
1666
|
+
this.touch("task_question", question.id, task.spaceId, null, taskId);
|
|
1667
|
+
return this.store.questionSnapshot(question.id);
|
|
1668
|
+
}
|
|
1669
|
+
/** Change le texte d'une question ou son type de choix ; un choix unique n'accepte qu'une réponse. */
|
|
1670
|
+
updateQuestion(id, patch) {
|
|
1671
|
+
const current = this.store.getQuestion(id);
|
|
1672
|
+
const question = validate(TaskQuestionSchema, { ...current, ...definedFields(patch) }, "question");
|
|
1673
|
+
if (!question.multiple)
|
|
1674
|
+
this.requireSingleAnswer(question, this.store.listQuestionOptions(id));
|
|
1675
|
+
this.db.prepare("UPDATE task_questions SET text = ?, multiple = ? WHERE id = ?").run(question.text, question.multiple ? 1 : 0, id);
|
|
1676
|
+
this.touchQuestion(question);
|
|
1677
|
+
return this.store.questionSnapshot(id);
|
|
1678
|
+
}
|
|
1679
|
+
deleteQuestion(id) {
|
|
1680
|
+
const question = this.store.getQuestion(id);
|
|
1681
|
+
this.db.prepare("DELETE FROM task_questions WHERE id = ?").run(id);
|
|
1682
|
+
this.touchQuestion(question);
|
|
1683
|
+
}
|
|
1684
|
+
/** Ajoute une proposition en fin de question. */
|
|
1685
|
+
addQuestionOption(questionId, input) {
|
|
1686
|
+
const question = this.store.getQuestion(questionId);
|
|
1687
|
+
const options = this.store.listQuestionOptions(questionId);
|
|
1688
|
+
if (options.length >= MAX_QUESTION_OPTIONS)
|
|
1689
|
+
throw new InvariantError(`A question has at most ${MAX_QUESTION_OPTIONS} options.`);
|
|
1690
|
+
const option = validate(QuestionOptionSchema, {
|
|
1691
|
+
id: newId(),
|
|
1692
|
+
questionId,
|
|
1693
|
+
label: input.label,
|
|
1694
|
+
detail: input.detail?.trim() ?? "",
|
|
1695
|
+
recommended: input.recommended ?? false,
|
|
1696
|
+
selected: false,
|
|
1697
|
+
position: positionBetween(options.at(-1)?.position ?? null, null),
|
|
1698
|
+
}, "question option");
|
|
1699
|
+
this.insertQuestionOption(option);
|
|
1700
|
+
this.touchQuestion(question);
|
|
1701
|
+
return option;
|
|
1702
|
+
}
|
|
1703
|
+
updateQuestionOption(id, patch) {
|
|
1704
|
+
const current = this.store.findQuestionOption(id);
|
|
1705
|
+
if (!current)
|
|
1706
|
+
throw new NotFoundError(`Question option ${id} not found.`);
|
|
1707
|
+
const option = validate(QuestionOptionSchema, { ...current, ...definedFields({ ...patch, detail: patch.detail?.trim() }) }, "question option");
|
|
1708
|
+
this.db.prepare("UPDATE question_options SET label = ?, detail = ?, recommended = ? WHERE id = ?").run(option.label, option.detail, option.recommended ? 1 : 0, id);
|
|
1709
|
+
this.touchQuestion(this.store.getQuestion(option.questionId));
|
|
1710
|
+
return option;
|
|
1711
|
+
}
|
|
1712
|
+
deleteQuestionOption(id) {
|
|
1713
|
+
const option = this.store.findQuestionOption(id);
|
|
1714
|
+
if (!option)
|
|
1715
|
+
throw new NotFoundError(`Question option ${id} not found.`);
|
|
1716
|
+
this.db.prepare("DELETE FROM question_options WHERE id = ?").run(id);
|
|
1717
|
+
this.touchQuestion(this.store.getQuestion(option.questionId));
|
|
1718
|
+
}
|
|
1719
|
+
/**
|
|
1720
|
+
* Réponse d'un membre : les propositions choisies et la réponse libre
|
|
1721
|
+
* remplacent les précédentes. Une réponse vide efface l'auteur et la date.
|
|
1722
|
+
*/
|
|
1723
|
+
answerQuestion(id, answer, userId) {
|
|
1724
|
+
const current = this.store.getQuestion(id);
|
|
1725
|
+
const options = this.store.listQuestionOptions(id);
|
|
1726
|
+
const selected = new Set(answer.selectedOptionIds);
|
|
1727
|
+
for (const optionId of selected) {
|
|
1728
|
+
if (!options.some((option) => option.id === optionId))
|
|
1729
|
+
throw new NotFoundError(`Option ${optionId} is not an option of this question.`);
|
|
1730
|
+
}
|
|
1731
|
+
const otherAnswer = answer.otherAnswer?.trim() || null;
|
|
1732
|
+
const answered = selected.size > 0 || otherAnswer !== null;
|
|
1733
|
+
const question = validate(TaskQuestionSchema, { ...current, otherAnswer, answeredBy: answered ? userId : null, answeredAt: answered ? this.now : null }, "question");
|
|
1734
|
+
const next = options.map((option) => ({ ...option, selected: selected.has(option.id) }));
|
|
1735
|
+
if (!question.multiple)
|
|
1736
|
+
this.requireSingleAnswer(question, next);
|
|
1737
|
+
this.db
|
|
1738
|
+
.prepare("UPDATE task_questions SET other_answer = ?, answered_by = ?, answered_at = ? WHERE id = ?")
|
|
1739
|
+
.run(question.otherAnswer, question.answeredBy, question.answeredAt, id);
|
|
1740
|
+
const update = this.db.prepare("UPDATE question_options SET selected = ? WHERE id = ?");
|
|
1741
|
+
for (const option of next)
|
|
1742
|
+
update.run(option.selected ? 1 : 0, option.id);
|
|
1743
|
+
this.touchQuestion(question);
|
|
1744
|
+
return this.store.questionSnapshot(id);
|
|
1745
|
+
}
|
|
1746
|
+
/** Recrée une question supprimée, avec ses identifiants, ses propositions et sa réponse. */
|
|
1747
|
+
restoreQuestion(snapshot) {
|
|
1748
|
+
const { options, ...fields } = snapshot;
|
|
1749
|
+
const question = validate(TaskQuestionSchema, fields, "question");
|
|
1750
|
+
this.insertQuestion(question);
|
|
1751
|
+
for (const option of options)
|
|
1752
|
+
this.insertQuestionOption(validate(QuestionOptionSchema, option, "question option"));
|
|
1753
|
+
this.touchQuestion(question);
|
|
1754
|
+
}
|
|
1755
|
+
/** Ramène une question à un état enregistré : texte, type de choix, réponse et propositions. */
|
|
1756
|
+
replaceQuestion(snapshot) {
|
|
1757
|
+
const { options, ...fields } = snapshot;
|
|
1758
|
+
const question = validate(TaskQuestionSchema, fields, "question");
|
|
1759
|
+
this.db
|
|
1760
|
+
.prepare("UPDATE task_questions SET text = ?, multiple = ?, other_answer = ?, answered_by = ?, answered_at = ? WHERE id = ?")
|
|
1761
|
+
.run(question.text, question.multiple ? 1 : 0, question.otherAnswer, question.answeredBy, question.answeredAt, question.id);
|
|
1762
|
+
const kept = new Set(options.map((option) => option.id));
|
|
1763
|
+
for (const option of this.store.listQuestionOptions(question.id)) {
|
|
1764
|
+
if (!kept.has(option.id))
|
|
1765
|
+
this.db.prepare("DELETE FROM question_options WHERE id = ?").run(option.id);
|
|
1766
|
+
}
|
|
1767
|
+
for (const option of options) {
|
|
1768
|
+
const valid = validate(QuestionOptionSchema, option, "question option");
|
|
1769
|
+
if (this.store.findQuestionOption(valid.id)) {
|
|
1770
|
+
this.db
|
|
1771
|
+
.prepare("UPDATE question_options SET label = ?, detail = ?, recommended = ?, selected = ?, position = ? WHERE id = ?")
|
|
1772
|
+
.run(valid.label, valid.detail, valid.recommended ? 1 : 0, valid.selected ? 1 : 0, valid.position, valid.id);
|
|
1773
|
+
}
|
|
1774
|
+
else {
|
|
1775
|
+
this.insertQuestionOption(valid);
|
|
1776
|
+
}
|
|
1777
|
+
}
|
|
1778
|
+
this.touchQuestion(question);
|
|
1779
|
+
}
|
|
1780
|
+
insertQuestion(question) {
|
|
1781
|
+
this.db
|
|
1782
|
+
.prepare("INSERT INTO task_questions (id, task_id, text, multiple, other_answer, answered_by, answered_at, position) VALUES (?, ?, ?, ?, ?, ?, ?, ?)")
|
|
1783
|
+
.run(question.id, question.taskId, question.text, question.multiple ? 1 : 0, question.otherAnswer, question.answeredBy, question.answeredAt, question.position);
|
|
1784
|
+
}
|
|
1785
|
+
insertQuestionOption(option) {
|
|
1786
|
+
this.db
|
|
1787
|
+
.prepare("INSERT INTO question_options (id, question_id, label, detail, recommended, selected, position) VALUES (?, ?, ?, ?, ?, ?, ?)")
|
|
1788
|
+
.run(option.id, option.questionId, option.label, option.detail, option.recommended ? 1 : 0, option.selected ? 1 : 0, option.position);
|
|
1789
|
+
}
|
|
1790
|
+
/** Un choix unique a pour réponse une seule proposition ou la réponse libre. */
|
|
1791
|
+
requireSingleAnswer(question, options) {
|
|
1792
|
+
const answers = options.filter((option) => option.selected).length + (question.otherAnswer === null ? 0 : 1);
|
|
1793
|
+
if (answers > 1)
|
|
1794
|
+
throw new InvariantError(`"${question.text}" is a single-choice question: it takes one option or a free answer, not ${answers}.`);
|
|
1795
|
+
}
|
|
1796
|
+
touchQuestion(question) {
|
|
1797
|
+
this.touch("task_question", question.id, this.store.getTask(question.taskId).spaceId, null, question.taskId);
|
|
1798
|
+
}
|
|
1575
1799
|
// --- Checklist ---
|
|
1576
1800
|
/** Ajoute un élément en fin de checklist d'une tâche standard. */
|
|
1577
1801
|
addChecklistItem(taskId, text) {
|
|
@@ -2446,6 +2670,20 @@ export class Mutation {
|
|
|
2446
2670
|
.run(valid.maxTurns, valid.maxMinutes, valid.maxBudgetUsd, this.now, this.actor.userId);
|
|
2447
2671
|
return valid;
|
|
2448
2672
|
}
|
|
2673
|
+
/** Enregistre le token chiffré de Claude, à la place du précédent ; un refus antérieur est effacé. */
|
|
2674
|
+
setClaudeConnection(tokenCipher, tokenHint) {
|
|
2675
|
+
if (this.actor.type !== "user")
|
|
2676
|
+
throw new InvariantError("Only a user can connect Claude.");
|
|
2677
|
+
const connection = validate(ClaudeConnectionSchema, { tokenCipher, tokenHint, savedAt: this.now, savedBy: this.actor.userId, refusedAt: null, refusedReason: null }, "Claude connection");
|
|
2678
|
+
this.db
|
|
2679
|
+
.prepare("INSERT OR REPLACE INTO claude_connection (id, token_cipher, token_hint, saved_at, saved_by, refused_at, refused_reason) VALUES (1, ?, ?, ?, ?, NULL, NULL)")
|
|
2680
|
+
.run(connection.tokenCipher, connection.tokenHint, connection.savedAt, connection.savedBy);
|
|
2681
|
+
return connection;
|
|
2682
|
+
}
|
|
2683
|
+
/** Marque le token de Claude comme refusé par Claude, avec le message de Claude Code. */
|
|
2684
|
+
markClaudeTokenRefused(reason) {
|
|
2685
|
+
this.db.prepare("UPDATE claude_connection SET refused_at = ?, refused_reason = ? WHERE id = 1").run(this.now, reason);
|
|
2686
|
+
}
|
|
2449
2687
|
/** Enregistre le relevé d'une session du runner terminée. */
|
|
2450
2688
|
recordRunnerSession(record) {
|
|
2451
2689
|
const valid = validate(RunnerSessionRecordSchema, record, "runner session");
|
package/dist/src/core/tasks.js
CHANGED
|
@@ -4,6 +4,7 @@ import { newId } from "./ids.js";
|
|
|
4
4
|
import { requireMember } from "./spaces.js";
|
|
5
5
|
import { MAX_ATTACHMENT_BYTES, } from "../../shared/schemas/tasks-api.schema.js";
|
|
6
6
|
import { summarizeTest } from "../../shared/logic/test-summary.js";
|
|
7
|
+
import { questionViews } from "./questions.js";
|
|
7
8
|
import { testDetail } from "./test-tasks.js";
|
|
8
9
|
/**
|
|
9
10
|
* Tâches, checklist, commentaires et pièces jointes, avec les droits de la
|
|
@@ -208,6 +209,7 @@ export function getTaskDetail(store, userId, taskId) {
|
|
|
208
209
|
ancestors,
|
|
209
210
|
testedTask: tested ? { id: tested.id, key: keyOf(space, tested), title: tested.title } : null,
|
|
210
211
|
children: byId.get(task.id).children,
|
|
212
|
+
questions: questionViews(store, task.id),
|
|
211
213
|
checklist,
|
|
212
214
|
test: task.type === "test" ? testDetail(store, task) : null,
|
|
213
215
|
comments,
|
|
@@ -52,7 +52,7 @@ const COMMENTS = {
|
|
|
52
52
|
ORGANIZER_PUBLIC_URL: "# URL ouverte par les utilisateurs, derrière nginx.",
|
|
53
53
|
PORT: "# Écoute du site ; nginx le joint à cette adresse.",
|
|
54
54
|
MCP_ORGANIZER_DATA_DIR: "# Base SQLite, pièces jointes et journaux.",
|
|
55
|
-
ORGANIZER_RUNNER_CLAUDE: "# Claude Code du runner
|
|
55
|
+
ORGANIZER_RUNNER_CLAUDE: "# Claude Code du runner ; Claude se connecte dans la page Administration.",
|
|
56
56
|
GROQ_API_KEY: "# Dictée vocale (Groq).",
|
|
57
57
|
SMTP_URL: "# Envoi des e-mails (invitations, notifications).",
|
|
58
58
|
};
|
package/dist/src/gui-api.d.ts
CHANGED
|
@@ -30,8 +30,13 @@ export interface GuiApiContext {
|
|
|
30
30
|
transcriber: Transcriber;
|
|
31
31
|
/** Runner du site : son état, et le lancement d'une session ponctuelle (null quand il est désactivé). */
|
|
32
32
|
runner: {
|
|
33
|
-
|
|
33
|
+
/** État du runner : sa commande, puis la connexion de Claude. */
|
|
34
|
+
status: () => RunnerStatus;
|
|
34
35
|
runNow: ((spaceId: string) => void) | null;
|
|
36
|
+
/** Vérifie un token Claude par une requête minimale (null quand la commande du runner n'est pas configurée). */
|
|
37
|
+
checkClaudeToken: ((token: string) => Promise<void>) | null;
|
|
38
|
+
/** Reprend les espaces autorisés qui ont des demandes en attente. */
|
|
39
|
+
resume: () => void;
|
|
35
40
|
/** Dernière session du runner dans un espace, quand elle a échoué. */
|
|
36
41
|
lastFailure: (spaceId: string) => RunnerFailure | null;
|
|
37
42
|
/** Session du runner en cours dans un espace. */
|
|
@@ -43,6 +48,8 @@ export interface GuiApiContext {
|
|
|
43
48
|
/** Arrêt d'urgence : tue tous les processus Claude Code de la machine du site. */
|
|
44
49
|
killAll: (userId: string) => Promise<KillAllResponse>;
|
|
45
50
|
};
|
|
51
|
+
/** Répertoire de données du site, qui porte la clé de chiffrement du token Claude. */
|
|
52
|
+
dataDir: string;
|
|
46
53
|
/** Horloge, imposée par les tests. */
|
|
47
54
|
now?: () => Date;
|
|
48
55
|
}
|
package/dist/src/gui-api.js
CHANGED
|
@@ -3,8 +3,9 @@ import { ForbiddenError, InvariantError, NotFoundError, OrganizerError, Unauthor
|
|
|
3
3
|
import { authenticate, changePassword, login, logout, redeemAccessLink, resolveAccessLink, updateDisplayName } from "./core/accounts.js";
|
|
4
4
|
import { acceptReceivedInvitation, createSharedSpace, declineReceivedInvitation, deleteSpace, inviteToSpace, leaveSpace, listMembers, listMemberSuggestions, listReceivedInvitations, listSpaces, removeMember, renameSpace, resendInvitation, revokeInvitation, } from "./core/spaces.js";
|
|
5
5
|
import { addChecklistItem, addComment, createTask, deleteAttachment, deleteChecklistItem, deleteComment, deleteTask, downloadAttachment, getBoard, getTaskDetail, listChanges, moveChecklistItem, moveTask, resolveTaskKey, setAssignees, setTags, updateChecklistItem, updateComment, updateTask, uploadAttachment, } from "./core/tasks.js";
|
|
6
|
+
import { answerQuestion } from "./core/questions.js";
|
|
6
7
|
import { addCheckpoint, deleteCheckpoint, moveCheckpoint, saveReviewDraft, setTestResult, submitReview, updateCheckpoint } from "./core/test-tasks.js";
|
|
7
|
-
import { AddChecklistItemRequestSchema, CheckpointTextRequestSchema, CommentRequestSchema, CreateTaskRequestSchema, MoveAfterRequestSchema, MoveTaskRequestSchema, ReviewDraftRequestSchema, SetAssigneesRequestSchema, SetTagsRequestSchema, SetTestResultRequestSchema, SubmitReviewRequestSchema, TaskFiltersSchema, TaskKeyQuerySchema, UpdateChecklistItemRequestSchema, UpdateTaskRequestSchema, UploadAttachmentRequestSchema, } from "../shared/schemas/tasks-api.schema.js";
|
|
8
|
+
import { AddChecklistItemRequestSchema, AnswerQuestionRequestSchema, CheckpointTextRequestSchema, CommentRequestSchema, CreateTaskRequestSchema, MoveAfterRequestSchema, MoveTaskRequestSchema, ReviewDraftRequestSchema, SetAssigneesRequestSchema, SetTagsRequestSchema, SetTestResultRequestSchema, SubmitReviewRequestSchema, TaskFiltersSchema, TaskKeyQuerySchema, UpdateChecklistItemRequestSchema, UpdateTaskRequestSchema, UploadAttachmentRequestSchema, } from "../shared/schemas/tasks-api.schema.js";
|
|
8
9
|
import { getSettings, getSpaceNotificationSettings, listNotifications, markAllNotificationsRead, markNotificationRead, unreadCount, updateSettings, updateSpaceNotificationSettings } from "./core/notifications.js";
|
|
9
10
|
import { NotificationListQuerySchema, UpdateSettingsRequestSchema, UpdateSpaceNotificationSettingsRequestSchema } from "../shared/schemas/notifications-api.schema.js";
|
|
10
11
|
import { cancelRequest, createRequest, createSuite, getRequest, listRequests, relaunchRequest, setFollowUpDone, stopRequest, undoAction, undoRequest, updateRequest, } from "./core/requests.js";
|
|
@@ -16,8 +17,9 @@ import { createIdea, delegatePromotion, listIdeas, promoteIdea, setIdeaArchived
|
|
|
16
17
|
import { CreateIdeaRequestSchema, PromoteIdeaRequestSchema, UpdateIdeaRequestSchema } from "../shared/schemas/ideas-api.schema.js";
|
|
17
18
|
import { createAgentToken, listAgentTokens, revokeAgentToken } from "./core/agent-tokens.js";
|
|
18
19
|
import { CreateTokenRequestSchema } from "../shared/schemas/tokens-api.schema.js";
|
|
20
|
+
import { getClaudeConnection, saveClaudeToken } from "./core/claude-connection.js";
|
|
19
21
|
import { getRunnerSettings, listAdminSpaces, processQueueNow, requireAdmin, runnerUsage, setRunnerAllowed, setRunnerSettings } from "./core/admin.js";
|
|
20
|
-
import { RunnerSettingsSchema, RunnerUsageQuerySchema, SetRunnerAllowedRequestSchema } from "../shared/schemas/admin-api.schema.js";
|
|
22
|
+
import { RunnerSettingsSchema, RunnerUsageQuerySchema, SaveClaudeTokenRequestSchema, SetRunnerAllowedRequestSchema } from "../shared/schemas/admin-api.schema.js";
|
|
21
23
|
import { getSiteInstructions, getSpaceInstructions, setSiteInstructions, setSpaceInstructions } from "./core/agent-instructions.js";
|
|
22
24
|
import { SetAgentInstructionsRequestSchema } from "../shared/schemas/instructions-api.schema.js";
|
|
23
25
|
import { TranscriptionError } from "./core/transcription.js";
|
|
@@ -249,6 +251,10 @@ route("DELETE", "/checklist/:itemId", (ctx, { user, params }) => {
|
|
|
249
251
|
route("POST", "/checklist/:itemId/move", (ctx, { user, request, params }) => ({
|
|
250
252
|
body: moveChecklistItem(ctx.store, user.id, params.itemId, parseBody(MoveAfterRequestSchema, request.body).afterId),
|
|
251
253
|
}));
|
|
254
|
+
// --- Questions ------------------------------------------------------------------
|
|
255
|
+
route("PUT", "/questions/:questionId/answer", (ctx, { user, request, params }) => ({
|
|
256
|
+
body: answerQuestion(ctx.store, user.id, params.questionId, parseBody(AnswerQuestionRequestSchema, request.body)),
|
|
257
|
+
}));
|
|
252
258
|
// --- Tâches de test ---------------------------------------------------------------
|
|
253
259
|
route("POST", "/tasks/:taskId/checkpoints", (ctx, { user, request, params }) => ({
|
|
254
260
|
body: addCheckpoint(ctx.store, user.id, params.taskId, parseBody(CheckpointTextRequestSchema, request.body).text),
|
|
@@ -307,7 +313,7 @@ route("POST", "/ideas/:ideaId/promote", (ctx, { user, request, params }) => ({
|
|
|
307
313
|
}));
|
|
308
314
|
route("POST", "/ideas/:ideaId/delegate", (ctx, { user, params }) => ({ body: delegatePromotion(ctx.store, user.id, params.ideaId) }));
|
|
309
315
|
// --- File de l'agent et historique -------------------------------------------------
|
|
310
|
-
route("GET", "/spaces/:spaceId/requests", (ctx, { user, params }) => ({ body: listRequests(ctx.store, user.id, params.spaceId, { disabledReason: ctx.runner.status.disabledReason, failure: ctx.runner.lastFailure(params.spaceId), session: ctx.runner.currentSession(params.spaceId) }, now(ctx)) }));
|
|
316
|
+
route("GET", "/spaces/:spaceId/requests", (ctx, { user, params }) => ({ body: listRequests(ctx.store, user.id, params.spaceId, { disabledReason: ctx.runner.status().disabledReason, failure: ctx.runner.lastFailure(params.spaceId), session: ctx.runner.currentSession(params.spaceId) }, now(ctx)) }));
|
|
311
317
|
route("POST", "/spaces/:spaceId/requests", (ctx, { user, request, params }) => ({
|
|
312
318
|
body: createRequest(ctx.store, user.id, params.spaceId, parseBody(CreateRequestSchema, request.body)),
|
|
313
319
|
}));
|
|
@@ -369,24 +375,36 @@ route("POST", "/tokens", (ctx, { user, request }) => {
|
|
|
369
375
|
});
|
|
370
376
|
route("POST", "/tokens/:tokenId/revoke", (ctx, { user, params }) => ({ body: revokeAgentToken(ctx.store, user.id, params.tokenId, now(ctx)) }));
|
|
371
377
|
// --- Administration ----------------------------------------------------------------
|
|
372
|
-
route("GET", "/admin/spaces", (ctx, { user }) => ({ body: listAdminSpaces(ctx.store, user.id, ctx.runner.status) }));
|
|
378
|
+
route("GET", "/admin/spaces", (ctx, { user }) => ({ body: listAdminSpaces(ctx.store, user.id, ctx.runner.status()) }));
|
|
373
379
|
route("POST", "/spaces/:spaceId/runner/run", (ctx, { user, params }) => {
|
|
374
380
|
requireAdmin(ctx.store, user.id);
|
|
375
381
|
const runNow = ctx.runner.runNow;
|
|
376
|
-
|
|
377
|
-
|
|
382
|
+
const status = ctx.runner.status();
|
|
383
|
+
if (!runNow || !status.enabled)
|
|
384
|
+
throw new ApiError("unavailable", `Runner désactivé : ${status.disabledReason}`);
|
|
378
385
|
return { body: processQueueNow(ctx.store, user.id, params.spaceId, runNow) };
|
|
379
386
|
});
|
|
380
387
|
route("POST", "/spaces/:spaceId/runner/stop", (ctx, { user, params }) => {
|
|
381
388
|
requireAdmin(ctx.store, user.id);
|
|
382
389
|
const stopSession = ctx.runner.stopSession;
|
|
383
390
|
if (!stopSession)
|
|
384
|
-
throw new ApiError("unavailable", `Runner désactivé : ${ctx.runner.status.disabledReason}`);
|
|
391
|
+
throw new ApiError("unavailable", `Runner désactivé : ${ctx.runner.status().disabledReason}`);
|
|
385
392
|
const abortedRequests = stopSession(params.spaceId, user.id);
|
|
386
393
|
if (abortedRequests === null)
|
|
387
394
|
throw new InvariantError("Aucune session du runner ne tourne dans cet espace.");
|
|
388
395
|
return { body: { abortedRequests } };
|
|
389
396
|
});
|
|
397
|
+
route("GET", "/admin/claude", (ctx, { user }) => ({ body: getClaudeConnection(ctx.store, user.id) }));
|
|
398
|
+
route("PUT", "/admin/claude", async (ctx, { user, request }) => {
|
|
399
|
+
requireAdmin(ctx.store, user.id);
|
|
400
|
+
const check = ctx.runner.checkClaudeToken;
|
|
401
|
+
if (!check)
|
|
402
|
+
throw new ApiError("unavailable", `Runner désactivé : ${ctx.runner.status().disabledReason}`);
|
|
403
|
+
const { token } = parseBody(SaveClaudeTokenRequestSchema, request.body);
|
|
404
|
+
const view = await saveClaudeToken(ctx.store, ctx.dataDir, user.id, token, check);
|
|
405
|
+
ctx.runner.resume();
|
|
406
|
+
return { body: view };
|
|
407
|
+
});
|
|
390
408
|
route("GET", "/admin/runner/settings", (ctx, { user }) => ({ body: getRunnerSettings(ctx.store, user.id) }));
|
|
391
409
|
route("PUT", "/admin/runner/settings", (ctx, { user, request }) => ({
|
|
392
410
|
body: setRunnerSettings(ctx.store, user.id, parseBody(RunnerSettingsSchema, request.body)),
|
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 **direct action** is a write you make without request_id, when your user asks you directly (in their editor, for example) rather than through a request: it is done in the name of your token's owner and forms its own batch, listed among the requests of the space as a direct action and undoable like any other. The site runner never acts directly: it always passes the request_id of the request it processes.\n- A **view** is a tab of a member's dashboard: a layout (kanban, list, matrix), groupings by status or priority, and filters on status, priority, assignees and tags. Each member has their own views in each space.\n- The **scope** of your work is the space of your token: you see and process the requests of all its members, and you never act outside it. You change the views of the author of the request you process, and nobody else's: only when the author owns your token, or when you are the site runner. A direct action on views changes those of your token's owner.\n\nWork loop, when the user asks you to process the queue:\n1. list_requests to see the pending requests of your space.\n2. claim_request on the oldest one: it becomes processing for you and you get its context (text, author, context task, for a message the previous exchanges of its author, task tree, members, recent ideas), along with the custom instructions of the site and of the space, which you follow. get_context shows the space at any time.\n3. Read what you need with get_task and search_tasks.\n4. Act with create_task, update_task, set_assignees, set_tags, edit_checklist, add_comment, create_idea, update_idea, promote_idea, with list_views, create_view, update_view, delete_view when the author asks how their board should look, and with check_follow_ups for a follow-up \u2014 always passing the request_id. Each write is one undoable action of the batch.\n5. complete_request with a short reply in the author's language and, in follow_ups, every point the author still has to handle (or fail_request with the reason), then go back to step 1 until no request is pending.\nWhen the queue is empty, tell the user.\n\nDirect work, when the user asks you to change the space outside any request: read with get_context, get_task and search_tasks, then call the write tools without request_id. Do not claim, complete or fail anything: there is no request to close. When your user still has points to handle afterwards, leave them with report_direct.\n\nNotifications: call enable_notifications once at the start of the session and arm the watcher it hands you with Monitor, whatever the command (behind mcp-http-gateway, the gateway relay answers in place of this server and gives its own watcher command). Each request that becomes pending in your space then arrives on its own as one line (kind, author, excerpt, request id), even while you are idle: process it with the work loop above, starting with claim_request. The host stops that watcher after 30 minutes at most: each time it tells you the watcher expired, re-arm it at once with the same Monitor call; otherwise notifications stop for good. A line \"notifications stopped\" means the site refused the token, and a line \"[gateway-watch] \u2026 la veille \u00E9choue\" means the gateway watcher keeps failing: tell the user. wait_for_requests is the waiting tool of the watcher: you do not need to call it.\n\nHow to handle each kind of request:\n- **idea**: classify it. If it belongs to an existing task or sub-task, attach it there (sub-task, checklist item or comment). If it is actionable and important enough, create a task (or sub-task) with a fitting priority. Otherwise, put it in the idea box with create_idea. Prefer existing tasks over duplicates.\n- **test_review**: feed the tester's findings back into the existing tasks (status, checklist, comments, priority of the affected tasks), or create a task for each problem that has none.\n- **remark** and **message**: do whatever is useful \u2014 answer, update or create tasks, comment \u2014 and say what you did in the reply.\n- **idea_promotion**: turn the context idea into a well-formed task with promote_idea.\n\nRules: write titles, descriptions and replies in the language of the users; keep the reply short and factual (markdown is rendered); never bury in the reply something the author must act on: it belongs in follow_ups. Errors tell you what to do next; an error about the token (missing, revoked, expired, owner no longer a member) cannot be fixed by retrying: tell the user.";
|
|
3
|
+
export declare const INSTRUCTIONS = "mcp-organizer connects you to an organizer site: a multi-user task manager where people organize tasks in a web app and queue requests for the AI. You, the connected agent, process those requests when the user asks you to. The site never calls an LLM: you are the intelligence.\n\nYour token covers exactly one space, with the rights of the user who created the token. Every tool works on that space.\n\nConcepts:\n- A **space** holds tasks and an idea box. A user's **personal space** is private; a **shared space** has one owner and members.\n- A **task** has a title, a markdown description, a status (todo, doing, review, done), a priority (low, medium, high, critical), assignees and tags. Tasks nest on two levels: task > sub-task > sub-sub-task. A task is either standard (with a checklist) or a test (with checkpoints that each tester marks ok, ko, blocked or untested). Any task can also carry **questions** you ask the members to settle a point: options to choose from (one, or several), each with a markdown detail, plus a free answer. The members answer on the site; an answer does not notify you. You read the answers with get_task, and act on them only when a member asks you to, in a message or in a comment mentioning @agent.\n- A **request** is something a member of your space asked the AI: an idea, a remark, a test review, a message or an idea promotion. It is pending, then processing once you claim it (only your token can then act for it), then done (with your reply and the points left to its author) or failed (with the reason). The points left to the author are checkboxes the members tick off. A **follow-up** is a message a member sends from a handled request: claim_request shows that original request, your reply and its points with their ids, and check_follow_ups ticks off the points the follow-up settles. A member can also hand a request to you by mentioning @agent in a comment of a task: claim_request then shows the task's thread, and complete_request posts your reply as a comment right after theirs.\n- A **batch** is the set of actions you perform for one request. Every action is logged with its before and after state and with your token, and users can undo one action or the whole batch.\n- A **direct action** is a write you make without request_id, when your user asks you directly (in their editor, for example) rather than through a request: it is done in the name of your token's owner and forms its own batch, listed among the requests of the space as a direct action and undoable like any other. The site runner never acts directly: it always passes the request_id of the request it processes.\n- A **view** is a tab of a member's dashboard: a layout (kanban, list, matrix), groupings by status or priority, and filters on status, priority, assignees and tags. Each member has their own views in each space.\n- The **scope** of your work is the space of your token: you see and process the requests of all its members, and you never act outside it. You change the views of the author of the request you process, and nobody else's: only when the author owns your token, or when you are the site runner. A direct action on views changes those of your token's owner.\n\nWork loop, when the user asks you to process the queue:\n1. list_requests to see the pending requests of your space.\n2. claim_request on the oldest one: it becomes processing for you and you get its context (text, author, context task, for a message the previous exchanges of its author, task tree, members, recent ideas), along with the custom instructions of the site and of the space, which you follow. get_context shows the space at any time.\n3. Read what you need with get_task and search_tasks.\n4. Act with create_task, update_task, set_assignees, set_tags, edit_checklist, edit_questions, add_comment, create_idea, update_idea, promote_idea, with list_views, create_view, update_view, delete_view when the author asks how their board should look, and with check_follow_ups for a follow-up \u2014 always passing the request_id. Each write is one undoable action of the batch.\n5. complete_request with a short reply in the author's language and, in follow_ups, every point the author still has to handle (or fail_request with the reason), then go back to step 1 until no request is pending.\nWhen the queue is empty, tell the user.\n\nDirect work, when the user asks you to change the space outside any request: read with get_context, get_task and search_tasks, then call the write tools without request_id. Do not claim, complete or fail anything: there is no request to close. When your user still has points to handle afterwards, leave them with report_direct.\n\nNotifications: call enable_notifications once at the start of the session and arm the watcher it hands you with Monitor, whatever the command (behind mcp-http-gateway, the gateway relay answers in place of this server and gives its own watcher command). Each request that becomes pending in your space then arrives on its own as one line (kind, author, excerpt, request id), even while you are idle: process it with the work loop above, starting with claim_request. The host stops that watcher after 30 minutes at most: each time it tells you the watcher expired, re-arm it at once with the same Monitor call; otherwise notifications stop for good. A line \"notifications stopped\" means the site refused the token, and a line \"[gateway-watch] \u2026 la veille \u00E9choue\" means the gateway watcher keeps failing: tell the user. wait_for_requests is the waiting tool of the watcher: you do not need to call it.\n\nHow to handle each kind of request:\n- **idea**: classify it. If it belongs to an existing task or sub-task, attach it there (sub-task, checklist item or comment). If it is actionable and important enough, create a task (or sub-task) with a fitting priority. Otherwise, put it in the idea box with create_idea. Prefer existing tasks over duplicates.\n- **test_review**: feed the tester's findings back into the existing tasks (status, checklist, comments, priority of the affected tasks), or create a task for each problem that has none.\n- **remark** and **message**: do whatever is useful \u2014 answer, update or create tasks, comment \u2014 and say what you did in the reply.\n- **idea_promotion**: turn the context idea into a well-formed task with promote_idea.\n\nRules: write titles, descriptions and replies in the language of the users; keep the reply short and factual (markdown is rendered); never bury in the reply something the author must act on: it belongs in follow_ups. Errors tell you what to do next; an error about the token (missing, revoked, expired, owner no longer a member) cannot be fixed by retrying: tell the user.";
|
|
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
|
@@ -15,7 +15,7 @@ Your token covers exactly one space, with the rights of the user who created the
|
|
|
15
15
|
|
|
16
16
|
Concepts:
|
|
17
17
|
- A **space** holds tasks and an idea box. A user's **personal space** is private; a **shared space** has one owner and members.
|
|
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).
|
|
18
|
+
- A **task** has a title, a markdown description, a status (todo, doing, review, done), a priority (low, medium, high, critical), assignees and tags. Tasks nest on two levels: task > sub-task > sub-sub-task. A task is either standard (with a checklist) or a test (with checkpoints that each tester marks ok, ko, blocked or untested). Any task can also carry **questions** you ask the members to settle a point: options to choose from (one, or several), each with a markdown detail, plus a free answer. The members answer on the site; an answer does not notify you. You read the answers with get_task, and act on them only when a member asks you to, in a message or in a comment mentioning @agent.
|
|
19
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
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.
|
|
@@ -26,7 +26,7 @@ Work loop, when the user asks you to process the queue:
|
|
|
26
26
|
1. list_requests to see the pending requests of your space.
|
|
27
27
|
2. claim_request on the oldest one: it becomes processing for you and you get its context (text, author, context task, for a message the previous exchanges of its author, task tree, members, recent ideas), along with the custom instructions of the site and of the space, which you follow. get_context shows the space at any time.
|
|
28
28
|
3. Read what you need with get_task and search_tasks.
|
|
29
|
-
4. Act with create_task, update_task, set_assignees, set_tags, edit_checklist, add_comment, create_idea, update_idea, promote_idea, with list_views, create_view, update_view, delete_view when the author asks how their board should look, and with check_follow_ups for a follow-up — always passing the request_id. Each write is one undoable action of the batch.
|
|
29
|
+
4. Act with create_task, update_task, set_assignees, set_tags, edit_checklist, edit_questions, add_comment, create_idea, update_idea, promote_idea, with list_views, create_view, update_view, delete_view when the author asks how their board should look, and with check_follow_ups for a follow-up — always passing the request_id. Each write is one undoable action of the batch.
|
|
30
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.
|
|
31
31
|
When the queue is empty, tell the user.
|
|
32
32
|
|
package/dist/src/mcp/tools.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BOARD_GROUPINGS, BOARD_LAYOUTS, REQUEST_STATUSES, TASK_PRIORITIES, TASK_STATUSES, TASK_TYPES } from "../../shared/schemas/enums.schema.js";
|
|
2
|
-
import { MAX_BOARD_VIEW_NAME_LENGTH } from "../../shared/schemas/entities.schema.js";
|
|
2
|
+
import { MAX_BOARD_VIEW_NAME_LENGTH, MAX_QUESTION_LENGTH, MAX_QUESTION_OPTION_DETAIL_LENGTH, MAX_QUESTION_OPTION_LABEL_LENGTH, MAX_QUESTION_OPTIONS, } from "../../shared/schemas/entities.schema.js";
|
|
3
3
|
import { MAX_TAG_LENGTH, MAX_TASK_TITLE_LENGTH } from "../../shared/schemas/tasks-api.schema.js";
|
|
4
|
-
import { MAX_CHECKLIST_ITEM_LENGTH, MAX_CHECKLIST_OPERATIONS, MAX_COMMENT_LENGTH, MAX_FOLLOW_UP_LENGTH, MAX_FOLLOW_UPS, MAX_IDEA_LENGTH, MAX_REASON_LENGTH, MAX_REPLY_LENGTH, MAX_REQUEST_LIST_LIMIT, MAX_SEARCH_LIMIT, } from "../../shared/schemas/agent-tools.schema.js";
|
|
4
|
+
import { MAX_CHECKLIST_ITEM_LENGTH, MAX_CHECKLIST_OPERATIONS, MAX_COMMENT_LENGTH, MAX_FOLLOW_UP_LENGTH, MAX_FOLLOW_UPS, MAX_IDEA_LENGTH, MAX_QUESTION_OPERATIONS, MAX_REASON_LENGTH, MAX_REPLY_LENGTH, MAX_REQUEST_LIST_LIMIT, MAX_SEARCH_LIMIT, } from "../../shared/schemas/agent-tools.schema.js";
|
|
5
5
|
/** Argument d'appel d'outil inutilisable pour former la requête. */
|
|
6
6
|
export class ToolArgumentError extends Error {
|
|
7
7
|
constructor(message) {
|
|
@@ -93,7 +93,7 @@ export const AGENT_TOOLS = [
|
|
|
93
93
|
path: "tasks/{task}",
|
|
94
94
|
definition: {
|
|
95
95
|
name: "get_task",
|
|
96
|
-
description: "Read one task of your space in detail: fields, parents, assignees, tags, description, checklist items or test checkpoints (with their ids, needed by edit_checklist), sub-tasks, recent comments and attachments. Use it before modifying a task.",
|
|
96
|
+
description: "Read one task of your space in detail: fields, parents, assignees, tags, description, questions with their options and the members' answers (ids needed by edit_questions), checklist items or test checkpoints (with their ids, needed by edit_checklist), sub-tasks, recent comments and attachments. Use it before modifying a task.",
|
|
97
97
|
inputSchema: { type: "object", properties: { task: TASK_REF }, required: ["task"], additionalProperties: false },
|
|
98
98
|
},
|
|
99
99
|
},
|
|
@@ -239,6 +239,58 @@ export const AGENT_TOOLS = [
|
|
|
239
239
|
},
|
|
240
240
|
},
|
|
241
241
|
},
|
|
242
|
+
{
|
|
243
|
+
method: "POST",
|
|
244
|
+
path: "tasks/{task}/questions",
|
|
245
|
+
definition: {
|
|
246
|
+
name: "edit_questions",
|
|
247
|
+
description: "Ask the members of your space questions on a task, to settle points you are discussing with them: each question offers options to choose from (one, or several with multiple), each with a markdown detail of what it implies, and the members may also write a free answer. Add, rephrase or delete questions and their options; the answers belong to the members, who give them on the site. Answering does not notify you: read the answers with get_task when you look at the task, and act on them when a member asks you to (a message, or a comment mentioning @agent). Operations apply in order, all or nothing; question and option ids come from get_task.",
|
|
248
|
+
inputSchema: {
|
|
249
|
+
type: "object",
|
|
250
|
+
properties: {
|
|
251
|
+
request_id: REQUEST_ID,
|
|
252
|
+
task: TASK_REF,
|
|
253
|
+
operations: {
|
|
254
|
+
type: "array",
|
|
255
|
+
minItems: 1,
|
|
256
|
+
maxItems: MAX_QUESTION_OPERATIONS,
|
|
257
|
+
items: {
|
|
258
|
+
type: "object",
|
|
259
|
+
properties: {
|
|
260
|
+
action: { type: "string", enum: ["add_question", "update_question", "delete_question", "add_option", "update_option", "delete_option"] },
|
|
261
|
+
text: { type: "string", maxLength: MAX_QUESTION_LENGTH, description: "add_question: the question; update_question: its new wording." },
|
|
262
|
+
multiple: { type: "boolean", description: "add_question / update_question: true lets the members pick several options. Default: false (a single option, or a free answer)." },
|
|
263
|
+
options: {
|
|
264
|
+
type: "array",
|
|
265
|
+
maxItems: MAX_QUESTION_OPTIONS,
|
|
266
|
+
description: "add_question: the options, in order.",
|
|
267
|
+
items: {
|
|
268
|
+
type: "object",
|
|
269
|
+
properties: {
|
|
270
|
+
label: { type: "string", maxLength: MAX_QUESTION_OPTION_LABEL_LENGTH, description: "Short name of the option." },
|
|
271
|
+
detail: { type: "string", maxLength: MAX_QUESTION_OPTION_DETAIL_LENGTH, description: "Markdown detail: what the option implies, its pros and cons." },
|
|
272
|
+
recommended: { type: "boolean", description: "Mark the option you recommend." },
|
|
273
|
+
},
|
|
274
|
+
required: ["label"],
|
|
275
|
+
additionalProperties: false,
|
|
276
|
+
},
|
|
277
|
+
},
|
|
278
|
+
question_id: { type: "string", description: "update_question / delete_question / add_option: id of the question." },
|
|
279
|
+
option_id: { type: "string", description: "update_option / delete_option: id of the option." },
|
|
280
|
+
label: { type: "string", maxLength: MAX_QUESTION_OPTION_LABEL_LENGTH, description: "add_option: label of the new option; update_option: its new label." },
|
|
281
|
+
detail: { type: "string", maxLength: MAX_QUESTION_OPTION_DETAIL_LENGTH, description: "add_option / update_option: markdown detail of the option." },
|
|
282
|
+
recommended: { type: "boolean", description: "add_option / update_option: mark or unmark the option as recommended." },
|
|
283
|
+
},
|
|
284
|
+
required: ["action"],
|
|
285
|
+
additionalProperties: false,
|
|
286
|
+
},
|
|
287
|
+
},
|
|
288
|
+
},
|
|
289
|
+
required: ["task", "operations"],
|
|
290
|
+
additionalProperties: false,
|
|
291
|
+
},
|
|
292
|
+
},
|
|
293
|
+
},
|
|
242
294
|
{
|
|
243
295
|
method: "POST",
|
|
244
296
|
path: "tasks/{task}/comments",
|
|
@@ -15,6 +15,8 @@ export interface RunnerConfig {
|
|
|
15
15
|
claudeDir: string;
|
|
16
16
|
/** Dossier des sessions : configurations MCP éphémères, dossier courant de Claude Code. */
|
|
17
17
|
workDir: string;
|
|
18
|
+
/** Répertoire de données du site, qui porte la clé de chiffrement du token Claude. */
|
|
19
|
+
dataDir: string;
|
|
18
20
|
}
|
|
19
21
|
/** Vrai si une session du runner peut joindre le site écoutant sur `host`, en http sur la machine. */
|
|
20
22
|
export declare function isRunnerHost(host: string): boolean;
|
|
@@ -78,6 +80,14 @@ export declare class SiteRunner {
|
|
|
78
80
|
/** Planifie une session pour l'espace ; un espace en cours de session est repris après elle. */
|
|
79
81
|
schedule(spaceId: string): void;
|
|
80
82
|
private drain;
|
|
83
|
+
/** Planifie les espaces autorisés qui ont des demandes en attente. */
|
|
84
|
+
resume(): void;
|
|
85
|
+
/**
|
|
86
|
+
* Vérifie un token Claude par une requête minimale (modèle Haiku, un tour,
|
|
87
|
+
* aucun outil ni serveur MCP), dans les conditions des sessions ; erreur avec
|
|
88
|
+
* la réponse de Claude Code s'il est refusé.
|
|
89
|
+
*/
|
|
90
|
+
checkToken(claudeToken: string): Promise<void>;
|
|
81
91
|
private runSession;
|
|
82
92
|
/** Enregistre le relevé de la session : issue, modèle, tours, tokens et coût annoncé par Claude Code. */
|
|
83
93
|
private record;
|