@imenam/mcp-organizer 1.0.7 → 1.0.8
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 +97 -20
- package/dist/shared/schemas/admin-api.schema.d.ts +92 -0
- package/dist/shared/schemas/admin-api.schema.js +46 -1
- package/dist/shared/schemas/agent-api.schema.d.ts +25 -0
- package/dist/shared/schemas/agent-api.schema.js +10 -0
- package/dist/shared/schemas/agent-tools.schema.d.ts +14 -0
- package/dist/shared/schemas/agent-tools.schema.js +12 -1
- package/dist/shared/schemas/entities.schema.d.ts +61 -0
- package/dist/shared/schemas/entities.schema.js +44 -1
- package/dist/shared/schemas/enums.schema.d.ts +19 -1
- package/dist/shared/schemas/enums.schema.js +8 -0
- package/dist/shared/schemas/instructions-api.schema.d.ts +42 -0
- package/dist/shared/schemas/instructions-api.schema.js +25 -0
- package/dist/shared/schemas/tasks-api.schema.d.ts +2 -0
- package/dist/shared/schemas/views-api.schema.d.ts +139 -0
- package/dist/shared/schemas/views-api.schema.js +33 -0
- package/dist/src/agent-api/requests.js +4 -2
- package/dist/src/cli/setup.d.ts +9 -6
- package/dist/src/cli/setup.js +108 -35
- package/dist/src/core/admin.d.ts +15 -1
- package/dist/src/core/admin.js +45 -0
- package/dist/src/core/agent-instructions.d.ts +6 -0
- package/dist/src/core/agent-instructions.js +43 -0
- package/dist/src/core/agent.d.ts +2 -0
- package/dist/src/core/agent.js +16 -2
- package/dist/src/core/board-views.d.ts +12 -0
- package/dist/src/core/board-views.js +84 -0
- package/dist/src/core/migrations.js +66 -0
- package/dist/src/core/requests.d.ts +8 -2
- package/dist/src/core/requests.js +4 -3
- package/dist/src/core/store.d.ts +40 -4
- package/dist/src/core/store.js +180 -9
- package/dist/src/deploy/env-render.d.ts +1 -1
- package/dist/src/deploy/env-render.js +2 -0
- package/dist/src/gui-api.d.ts +12 -1
- package/dist/src/gui-api.js +51 -3
- package/dist/src/mcp/start.d.ts +1 -1
- package/dist/src/mcp/start.js +4 -4
- package/dist/src/mcp/tools.js +13 -3
- package/dist/src/server/claude-processes.d.ts +26 -0
- package/dist/src/server/claude-processes.js +72 -0
- package/dist/src/server/claude-stream.d.ts +39 -0
- package/dist/src/server/claude-stream.js +111 -0
- package/dist/src/server/runner.d.ts +40 -0
- package/dist/src/server/runner.js +157 -24
- package/dist/src/server/start.js +19 -1
- package/gui/dist/assets/index-BX6iBj41.js +70 -0
- package/gui/dist/assets/index-CXzkYy4P.css +1 -0
- package/gui/dist/index.html +2 -2
- package/package.json +1 -1
- package/gui/dist/assets/index-DuoSNpBr.js +0 -70
- package/gui/dist/assets/index-duxL0fvO.css +0 -1
|
@@ -399,6 +399,72 @@ export const MIGRATIONS = [
|
|
|
399
399
|
notify_comment_email INTEGER NOT NULL CHECK (notify_comment_email IN (0, 1)),
|
|
400
400
|
PRIMARY KEY (user_id, space_id)
|
|
401
401
|
);
|
|
402
|
+
`,
|
|
403
|
+
// Vues du tableau de bord d'un membre dans un espace : un premier regroupement (colonnes, sections),
|
|
404
|
+
// un second (lignes d'une matrice, sous-sections d'une liste) ; les filtres sont des tableaux JSON de valeurs.
|
|
405
|
+
`
|
|
406
|
+
CREATE TABLE board_views (
|
|
407
|
+
id TEXT PRIMARY KEY,
|
|
408
|
+
space_id TEXT NOT NULL REFERENCES spaces(id) ON DELETE CASCADE,
|
|
409
|
+
user_id TEXT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
|
410
|
+
name TEXT NOT NULL CHECK (name <> ''),
|
|
411
|
+
layout TEXT NOT NULL CHECK (layout IN ('kanban', 'list', 'matrix')),
|
|
412
|
+
group_by TEXT NOT NULL CHECK (group_by IN ('status', 'priority', 'none')),
|
|
413
|
+
then_by TEXT NOT NULL CHECK (then_by IN ('status', 'priority', 'none')),
|
|
414
|
+
show_empty_groups INTEGER NOT NULL CHECK (show_empty_groups IN (0, 1)),
|
|
415
|
+
statuses TEXT NOT NULL,
|
|
416
|
+
priorities TEXT NOT NULL,
|
|
417
|
+
position REAL NOT NULL,
|
|
418
|
+
created_at TEXT NOT NULL,
|
|
419
|
+
updated_at TEXT NOT NULL,
|
|
420
|
+
CHECK (layout = 'list' OR group_by <> 'none'),
|
|
421
|
+
CHECK (layout <> 'kanban' OR then_by = 'none'),
|
|
422
|
+
CHECK (layout <> 'matrix' OR then_by <> 'none'),
|
|
423
|
+
CHECK (then_by = 'none' OR (group_by <> 'none' AND then_by <> group_by))
|
|
424
|
+
);
|
|
425
|
+
CREATE INDEX board_views_member ON board_views(space_id, user_id, position);
|
|
426
|
+
`,
|
|
427
|
+
// Instructions personnalisées données à l'agent : celles du site (space_id NULL, une seule ligne), puis celles d'un espace.
|
|
428
|
+
`
|
|
429
|
+
CREATE TABLE agent_instructions (
|
|
430
|
+
space_id TEXT UNIQUE REFERENCES spaces(id) ON DELETE CASCADE,
|
|
431
|
+
text TEXT NOT NULL CHECK (text <> ''),
|
|
432
|
+
updated_at TEXT NOT NULL,
|
|
433
|
+
updated_by TEXT REFERENCES users(id) ON DELETE SET NULL
|
|
434
|
+
);
|
|
435
|
+
CREATE UNIQUE INDEX agent_instructions_site ON agent_instructions((space_id IS NULL)) WHERE space_id IS NULL;
|
|
436
|
+
`,
|
|
437
|
+
// Limites d'une session du runner (une seule ligne), et relevé de chaque session : issue, tours, tokens et coût annoncé par Claude Code.
|
|
438
|
+
`
|
|
439
|
+
CREATE TABLE runner_settings (
|
|
440
|
+
id INTEGER PRIMARY KEY CHECK (id = 1),
|
|
441
|
+
max_turns INTEGER NOT NULL CHECK (max_turns BETWEEN 1 AND 500),
|
|
442
|
+
max_minutes INTEGER NOT NULL CHECK (max_minutes BETWEEN 1 AND 120),
|
|
443
|
+
max_budget_usd REAL CHECK (max_budget_usd IS NULL OR max_budget_usd > 0),
|
|
444
|
+
updated_at TEXT,
|
|
445
|
+
updated_by TEXT REFERENCES users(id) ON DELETE SET NULL
|
|
446
|
+
);
|
|
447
|
+
INSERT INTO runner_settings (id, max_turns, max_minutes) VALUES (1, 40, 10);
|
|
448
|
+
CREATE TABLE runner_sessions (
|
|
449
|
+
id TEXT PRIMARY KEY,
|
|
450
|
+
space_id TEXT REFERENCES spaces(id) ON DELETE SET NULL,
|
|
451
|
+
space_name TEXT NOT NULL,
|
|
452
|
+
started_at TEXT NOT NULL,
|
|
453
|
+
ended_at TEXT NOT NULL,
|
|
454
|
+
outcome TEXT NOT NULL CHECK (outcome IN ('completed', 'failed', 'stopped', 'timeout', 'max_turns', 'max_budget')),
|
|
455
|
+
model TEXT,
|
|
456
|
+
turns INTEGER,
|
|
457
|
+
cost_usd REAL,
|
|
458
|
+
input_tokens INTEGER NOT NULL,
|
|
459
|
+
output_tokens INTEGER NOT NULL,
|
|
460
|
+
cache_read_tokens INTEGER NOT NULL,
|
|
461
|
+
cache_creation_tokens INTEGER NOT NULL
|
|
462
|
+
);
|
|
463
|
+
CREATE INDEX runner_sessions_started ON runner_sessions(started_at);
|
|
464
|
+
`,
|
|
465
|
+
// Points que l'auteur d'une demande traitée doit encore régler, laissés par l'agent (tableau JSON de textes).
|
|
466
|
+
`
|
|
467
|
+
ALTER TABLE agent_requests ADD COLUMN follow_ups TEXT NOT NULL DEFAULT '[]';
|
|
402
468
|
`,
|
|
403
469
|
];
|
|
404
470
|
/** Version du schéma attendue par ce code. */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Store } from "./store.js";
|
|
2
2
|
import type { AgentAction, AgentRequest } from "../../shared/schemas/entities.schema.js";
|
|
3
3
|
import type { RequestKind } from "../../shared/schemas/enums.schema.js";
|
|
4
|
-
import type { AgentActionView, RequestListResponse, RequestView } from "../../shared/schemas/agent-api.schema.js";
|
|
4
|
+
import type { AgentActionView, RequestListResponse, RequestView, RunnerFailure } from "../../shared/schemas/agent-api.schema.js";
|
|
5
5
|
/**
|
|
6
6
|
* File de l'agent vue de la GUI : dépôt d'une demande, modification et
|
|
7
7
|
* annulation tant qu'elle attend, libération d'une demande prise, liste par
|
|
@@ -43,7 +43,13 @@ export declare function getRequest(store: Store, userId: string, requestId: stri
|
|
|
43
43
|
* actifs qui couvrent l'espace, chacun avec son dernier usage et la présence
|
|
44
44
|
* de son veilleur de notifications.
|
|
45
45
|
*/
|
|
46
|
-
export declare function listRequests(store: Store, userId: string, spaceId: string,
|
|
46
|
+
export declare function listRequests(store: Store, userId: string, spaceId: string, runner: {
|
|
47
|
+
disabledReason: string | null;
|
|
48
|
+
failure: RunnerFailure | null;
|
|
49
|
+
session: {
|
|
50
|
+
startedAt: string;
|
|
51
|
+
} | null;
|
|
52
|
+
}, now?: Date): RequestListResponse;
|
|
47
53
|
/** Annule une action de l'agent. */
|
|
48
54
|
export declare function undoAction(store: Store, userId: string, actionId: string): RequestView;
|
|
49
55
|
/** Annule toutes les actions non annulées d'un lot, de la plus récente à la plus ancienne : tout le lot ou rien. */
|
|
@@ -26,7 +26,7 @@ function userName(store, userId) {
|
|
|
26
26
|
// --- Vues -----------------------------------------------------------------------
|
|
27
27
|
/** Jeton d'agent désigné par son nom et celui de son propriétaire. */
|
|
28
28
|
function agentRef(store, token) {
|
|
29
|
-
return { tokenId: token.id, name: token.name, ownerName: userName(store, token.userId) ?? "" };
|
|
29
|
+
return { tokenId: token.id, name: token.name, ownerName: userName(store, token.userId) ?? "", isRunner: token.isRunner };
|
|
30
30
|
}
|
|
31
31
|
/** Libellé de la tâche concernée par une action : `ORG-41`, « Idée » pour une idée. */
|
|
32
32
|
function actionLabel(store, action) {
|
|
@@ -96,6 +96,7 @@ export function requestView(store, userId, request) {
|
|
|
96
96
|
targetSpaceName: target.name,
|
|
97
97
|
contextTask: task ? { id: task.id, key: `${store.getSpace(task.spaceId).keyPrefix}-${task.number}`, title: task.title } : null,
|
|
98
98
|
reply: request.reply,
|
|
99
|
+
followUps: request.followUps,
|
|
99
100
|
failureReason: request.failureReason,
|
|
100
101
|
createdAt: request.createdAt,
|
|
101
102
|
updatedAt: request.updatedAt,
|
|
@@ -193,14 +194,14 @@ export function getRequest(store, userId, requestId) {
|
|
|
193
194
|
* actifs qui couvrent l'espace, chacun avec son dernier usage et la présence
|
|
194
195
|
* de son veilleur de notifications.
|
|
195
196
|
*/
|
|
196
|
-
export function listRequests(store, userId, spaceId,
|
|
197
|
+
export function listRequests(store, userId, spaceId, runner, now = new Date()) {
|
|
197
198
|
const { space } = requireMember(store, spaceId, userId);
|
|
198
199
|
const requests = store.listAgentRequestsOfSpace(spaceId, REQUESTS_PAGE_SIZE).map((request) => requestView(store, userId, request));
|
|
199
200
|
const agents = store
|
|
200
201
|
.listAgentTokensOfSpace(spaceId)
|
|
201
202
|
.filter((token) => tokenState(store, token, now) === "active" && (!token.isRunner || space.runnerAllowed))
|
|
202
203
|
.map((token) => ({ ...agentRef(store, token), lastUsedAt: token.lastUsedAt, listening: store.watchers.status(token.id).armed }));
|
|
203
|
-
return { requests, pendingCount: store.countPendingRequestsOfSpace(spaceId), agents, runnerAllowed: space.runnerAllowed, runnerDisabledReason };
|
|
204
|
+
return { requests, pendingCount: store.countPendingRequestsOfSpace(spaceId), agents, runnerAllowed: space.runnerAllowed, runnerDisabledReason: runner.disabledReason, runnerFailure: runner.failure, runnerSession: runner.session };
|
|
204
205
|
}
|
|
205
206
|
// --- Annulation -----------------------------------------------------------------
|
|
206
207
|
/**
|
package/dist/src/core/store.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type Database from "better-sqlite3";
|
|
2
2
|
import { WatcherRegistry } from "./watchers.js";
|
|
3
|
-
import { type EntityType, type MemberRole, type RequestKind, type RequestStatus, type SpaceKind, type TaskPriority, type TaskStatus, type TaskType, type TestResultValue, type AccessLinkPurpose, type AgentOperation, type UserStatus, type VersionedEntityType } from "../../shared/schemas/enums.schema.js";
|
|
4
|
-
import { type AccessLink, type AgentAction, type AgentRequest, type AgentToken, type Attachment, type Change, type ChecklistItem, type Comment, type EntityVersion, type Idea, type Invitation, type Membership, type Notification, type Session, type Space, type Tag, type Task, type TaskSnapshot, type TestCheckpoint, type TestResult, type TestReview, type User, type UserSettings, type NotificationPreferences, type SpaceNotificationSettings } from "../../shared/schemas/entities.schema.js";
|
|
3
|
+
import { type BoardGrouping, type BoardLayout, type EntityType, type MemberRole, type RequestKind, type RequestStatus, type SpaceKind, type TaskPriority, type TaskStatus, type TaskType, type TestResultValue, type AccessLinkPurpose, type AgentOperation, type UserStatus, type VersionedEntityType } from "../../shared/schemas/enums.schema.js";
|
|
4
|
+
import { type AccessLink, type AgentAction, type AgentInstructions, type AgentRequest, type AgentToken, type Attachment, type BoardView, type Change, type ChecklistItem, type Comment, type EntityVersion, type Idea, type Invitation, type Membership, type Notification, type Session, type Space, type Tag, type Task, type TaskSnapshot, type TestCheckpoint, type TestResult, type TestReview, type User, type UserSettings, type NotificationPreferences, type SpaceNotificationSettings } from "../../shared/schemas/entities.schema.js";
|
|
5
|
+
import { type RunnerSessionRecord, type RunnerSettings } from "../../shared/schemas/admin-api.schema.js";
|
|
5
6
|
/**
|
|
6
7
|
* Auteur d'une mutation : un utilisateur de la GUI, ou un agent qui agit avec
|
|
7
8
|
* son jeton pour une demande que ce jeton a prise, avec les droits du
|
|
@@ -42,6 +43,12 @@ export declare class Store {
|
|
|
42
43
|
countAdmins(): number;
|
|
43
44
|
/** Préférences de notification propres à un espace, ou null si l'utilisateur y suit celles de son compte. */
|
|
44
45
|
findSpaceNotificationSettings(userId: string, spaceId: string): SpaceNotificationSettings | null;
|
|
46
|
+
/** Limites d'une session du runner. */
|
|
47
|
+
getRunnerSettings(): RunnerSettings;
|
|
48
|
+
/** Sessions du runner commencées depuis `since`, de la plus récente à la plus ancienne. */
|
|
49
|
+
listRunnerSessionsSince(since: string): RunnerSessionRecord[];
|
|
50
|
+
/** Instructions de l'agent propres à un espace, ou celles du site quand `spaceId` est null ; null s'il n'y en a pas. */
|
|
51
|
+
findAgentInstructions(spaceId: string | null): AgentInstructions | null;
|
|
45
52
|
/** Préférences de notification qui s'appliquent à un utilisateur dans un espace : celles de l'espace, sinon celles du compte. */
|
|
46
53
|
notificationPreferences(userId: string, spaceId: string): NotificationPreferences;
|
|
47
54
|
getUserSettings(userId: string): UserSettings;
|
|
@@ -143,6 +150,10 @@ export declare class Store {
|
|
|
143
150
|
listIdeas(spaceId: string): Idea[];
|
|
144
151
|
/** Demandes de promotion (`idea_promotion`) en attente ou en cours sur les idées d'un espace. */
|
|
145
152
|
listOpenPromotionRequests(spaceId: string): AgentRequest[];
|
|
153
|
+
findBoardView(id: string): BoardView | null;
|
|
154
|
+
getBoardView(id: string): BoardView;
|
|
155
|
+
/** Vues d'un membre dans un espace, dans l'ordre des onglets. */
|
|
156
|
+
listBoardViews(spaceId: string, userId: string): BoardView[];
|
|
146
157
|
/** Tâches de test qui vérifient une tâche. */
|
|
147
158
|
listTestsOf(taskId: string): Task[];
|
|
148
159
|
findAgentRequest(id: string): AgentRequest | null;
|
|
@@ -284,6 +295,16 @@ export interface UpdateIdeaInput {
|
|
|
284
295
|
promotedTaskId?: string | null;
|
|
285
296
|
archived?: boolean;
|
|
286
297
|
}
|
|
298
|
+
/** Réglages d'une vue du tableau de bord. */
|
|
299
|
+
export interface BoardViewSettings {
|
|
300
|
+
name: string;
|
|
301
|
+
layout: BoardLayout;
|
|
302
|
+
groupBy: BoardGrouping;
|
|
303
|
+
thenBy: BoardGrouping;
|
|
304
|
+
showEmptyGroups: boolean;
|
|
305
|
+
statuses: TaskStatus[];
|
|
306
|
+
priorities: TaskPriority[];
|
|
307
|
+
}
|
|
287
308
|
/** Action de l'agent à enregistrer dans le lot de sa demande. */
|
|
288
309
|
export interface AgentActionInput {
|
|
289
310
|
entityType: EntityType;
|
|
@@ -527,6 +548,10 @@ export declare class Mutation {
|
|
|
527
548
|
updateIdea(id: string, patch: UpdateIdeaInput): Idea;
|
|
528
549
|
/** Supprime une idée ; sa version de suppression a un instantané nul. */
|
|
529
550
|
deleteIdea(id: string): void;
|
|
551
|
+
/** Ajoute une vue à celles d'un membre dans un espace, après la dernière. */
|
|
552
|
+
createBoardView(spaceId: string, userId: string, settings: BoardViewSettings): BoardView;
|
|
553
|
+
updateBoardView(id: string, patch: Partial<BoardViewSettings>): BoardView;
|
|
554
|
+
deleteBoardView(id: string): void;
|
|
530
555
|
/** Dépose une demande `pending` de l'utilisateur acteur. */
|
|
531
556
|
createAgentRequest(input: CreateAgentRequestInput): AgentRequest;
|
|
532
557
|
/** Note la modification d'une demande, pour son espace. */
|
|
@@ -539,6 +564,8 @@ export declare class Mutation {
|
|
|
539
564
|
cancelAgentRequest(id: string): AgentRequest;
|
|
540
565
|
/** Repasse en attente une demande `processing` : un agent pourra la reprendre. */
|
|
541
566
|
releaseAgentRequest(id: string): AgentRequest;
|
|
567
|
+
/** Termine en échec une demande `processing` dont l'agent a été arrêté, avec la raison montrée à son auteur. */
|
|
568
|
+
abortAgentRequest(id: string, reason: string): AgentRequest;
|
|
542
569
|
/** Demande et jeton de l'agent acteur. */
|
|
543
570
|
private agentRequest;
|
|
544
571
|
/**
|
|
@@ -547,8 +574,8 @@ export declare class Mutation {
|
|
|
547
574
|
* la transaction exclusive, garantit qu'un seul agent prend une demande donnée.
|
|
548
575
|
*/
|
|
549
576
|
claimAgentRequest(): AgentRequest;
|
|
550
|
-
/** Termine la demande de l'agent avec son message de compte rendu. */
|
|
551
|
-
completeAgentRequest(reply: string): AgentRequest;
|
|
577
|
+
/** Termine la demande de l'agent avec son message de compte rendu et les points que l'auteur doit encore régler. */
|
|
578
|
+
completeAgentRequest(reply: string, followUps: string[]): AgentRequest;
|
|
552
579
|
/** Termine la demande de l'agent en échec, avec la raison montrée à son auteur. */
|
|
553
580
|
failAgentRequest(reason: string): AgentRequest;
|
|
554
581
|
private finishAgentRequest;
|
|
@@ -579,6 +606,15 @@ export declare class Mutation {
|
|
|
579
606
|
* null les retire, et il y suit de nouveau celles de son compte.
|
|
580
607
|
*/
|
|
581
608
|
setSpaceNotificationSettings(userId: string, spaceId: string, preferences: NotificationPreferences | null): SpaceNotificationSettings | null;
|
|
609
|
+
/**
|
|
610
|
+
* Fixe les instructions de l'agent d'un espace, ou celles du site quand
|
|
611
|
+
* `spaceId` est null ; un texte vide les retire.
|
|
612
|
+
*/
|
|
613
|
+
setAgentInstructions(spaceId: string | null, text: string): AgentInstructions | null;
|
|
614
|
+
/** Fixe les limites d'une session du runner. */
|
|
615
|
+
setRunnerSettings(settings: RunnerSettings): RunnerSettings;
|
|
616
|
+
/** Enregistre le relevé d'une session du runner terminée. */
|
|
617
|
+
recordRunnerSession(record: RunnerSessionRecord): void;
|
|
582
618
|
/** Vérifie les invariants sur l'état final, puis écrit les versions et le journal. */
|
|
583
619
|
finish(): void;
|
|
584
620
|
private checkInvariants;
|
package/dist/src/core/store.js
CHANGED
|
@@ -3,8 +3,9 @@ import { ForbiddenError, InvariantError, NotFoundError, OrganizerError } from ".
|
|
|
3
3
|
import { positionBetween } from "../../shared/logic/positions.js";
|
|
4
4
|
import { newId } from "./ids.js";
|
|
5
5
|
import { WatcherRegistry } from "./watchers.js";
|
|
6
|
-
import { MAX_TASK_DEPTH, } from "../../shared/schemas/enums.schema.js";
|
|
7
|
-
import { AccessLinkSchema, AgentActionSchema, AgentTokenSchema, AgentRequestSchema, AttachmentSchema, ChangeSchema, ChecklistItemSchema, CommentSchema, EntityVersionSchema, IdeaSchema, IdeaSnapshotSchema, InvitationSchema, MembershipSchema, NotificationSchema, SessionSchema, SpaceSchema, TagSchema, TaskSchema, TaskSnapshotSchema, TestCheckpointSchema, TestResultSchema, TestReviewSchema, UserSchema, UserSettingsSchema, SpaceNotificationSettingsSchema, } from "../../shared/schemas/entities.schema.js";
|
|
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, 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";
|
|
8
9
|
/** Valide `value` avec `schema` ; une donnée invalide est une erreur métier qui liste les champs fautifs. */
|
|
9
10
|
function validate(schema, value, what) {
|
|
10
11
|
const parsed = schema.safeParse(value);
|
|
@@ -38,6 +39,26 @@ function spaceNotificationSettingsFromRow(row) {
|
|
|
38
39
|
notifyCommentEmail: bool(row.notify_comment_email),
|
|
39
40
|
});
|
|
40
41
|
}
|
|
42
|
+
function agentInstructionsFromRow(row) {
|
|
43
|
+
return AgentInstructionsSchema.parse({ spaceId: row.space_id, text: row.text, updatedAt: row.updated_at, updatedBy: row.updated_by });
|
|
44
|
+
}
|
|
45
|
+
function runnerSessionFromRow(row) {
|
|
46
|
+
return RunnerSessionRecordSchema.parse({
|
|
47
|
+
id: row.id,
|
|
48
|
+
spaceId: row.space_id,
|
|
49
|
+
spaceName: row.space_name,
|
|
50
|
+
startedAt: row.started_at,
|
|
51
|
+
endedAt: row.ended_at,
|
|
52
|
+
outcome: row.outcome,
|
|
53
|
+
model: row.model,
|
|
54
|
+
turns: row.turns,
|
|
55
|
+
costUsd: row.cost_usd,
|
|
56
|
+
inputTokens: row.input_tokens,
|
|
57
|
+
outputTokens: row.output_tokens,
|
|
58
|
+
cacheReadTokens: row.cache_read_tokens,
|
|
59
|
+
cacheCreationTokens: row.cache_creation_tokens,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
41
62
|
/** Les quatre préférences de notification d'un objet qui les porte. */
|
|
42
63
|
function preferencesOf(source) {
|
|
43
64
|
const { notifyAssignApp, notifyAssignEmail, notifyCommentApp, notifyCommentEmail } = source;
|
|
@@ -144,6 +165,23 @@ function ideaFromRow(row) {
|
|
|
144
165
|
createdAt: row.created_at,
|
|
145
166
|
});
|
|
146
167
|
}
|
|
168
|
+
function boardViewFromRow(row) {
|
|
169
|
+
return BoardViewSchema.parse({
|
|
170
|
+
id: row.id,
|
|
171
|
+
spaceId: row.space_id,
|
|
172
|
+
userId: row.user_id,
|
|
173
|
+
name: row.name,
|
|
174
|
+
layout: row.layout,
|
|
175
|
+
groupBy: row.group_by,
|
|
176
|
+
thenBy: row.then_by,
|
|
177
|
+
showEmptyGroups: bool(row.show_empty_groups),
|
|
178
|
+
statuses: JSON.parse(row.statuses),
|
|
179
|
+
priorities: JSON.parse(row.priorities),
|
|
180
|
+
position: row.position,
|
|
181
|
+
createdAt: row.created_at,
|
|
182
|
+
updatedAt: row.updated_at,
|
|
183
|
+
});
|
|
184
|
+
}
|
|
147
185
|
function requestFromRow(row) {
|
|
148
186
|
return AgentRequestSchema.parse({
|
|
149
187
|
id: row.id,
|
|
@@ -155,6 +193,7 @@ function requestFromRow(row) {
|
|
|
155
193
|
text: row.text,
|
|
156
194
|
status: row.status,
|
|
157
195
|
reply: row.reply,
|
|
196
|
+
followUps: JSON.parse(row.follow_ups),
|
|
158
197
|
failureReason: row.failure_reason,
|
|
159
198
|
createdAt: row.created_at,
|
|
160
199
|
updatedAt: row.updated_at,
|
|
@@ -340,6 +379,20 @@ export class Store {
|
|
|
340
379
|
const row = this.db.prepare("SELECT * FROM space_notification_settings WHERE user_id = ? AND space_id = ?").get(userId, spaceId);
|
|
341
380
|
return row ? spaceNotificationSettingsFromRow(row) : null;
|
|
342
381
|
}
|
|
382
|
+
/** Limites d'une session du runner. */
|
|
383
|
+
getRunnerSettings() {
|
|
384
|
+
const row = this.db.prepare("SELECT * FROM runner_settings WHERE id = 1").get();
|
|
385
|
+
return RunnerSettingsSchema.parse({ maxTurns: row.max_turns, maxMinutes: row.max_minutes, maxBudgetUsd: row.max_budget_usd });
|
|
386
|
+
}
|
|
387
|
+
/** Sessions du runner commencées depuis `since`, de la plus récente à la plus ancienne. */
|
|
388
|
+
listRunnerSessionsSince(since) {
|
|
389
|
+
return this.db.prepare("SELECT * FROM runner_sessions WHERE started_at >= ? ORDER BY started_at DESC, id").all(since).map(runnerSessionFromRow);
|
|
390
|
+
}
|
|
391
|
+
/** Instructions de l'agent propres à un espace, ou celles du site quand `spaceId` est null ; null s'il n'y en a pas. */
|
|
392
|
+
findAgentInstructions(spaceId) {
|
|
393
|
+
const row = this.db.prepare("SELECT * FROM agent_instructions WHERE space_id IS ?").get(spaceId);
|
|
394
|
+
return row ? agentInstructionsFromRow(row) : null;
|
|
395
|
+
}
|
|
343
396
|
/** Préférences de notification qui s'appliquent à un utilisateur dans un espace : celles de l'espace, sinon celles du compte. */
|
|
344
397
|
notificationPreferences(userId, spaceId) {
|
|
345
398
|
return preferencesOf(this.findSpaceNotificationSettings(userId, spaceId) ?? this.getUserSettings(userId));
|
|
@@ -668,6 +721,22 @@ export class Store {
|
|
|
668
721
|
.all(spaceId);
|
|
669
722
|
return rows.map(requestFromRow);
|
|
670
723
|
}
|
|
724
|
+
// --- Vues du tableau de bord ---
|
|
725
|
+
findBoardView(id) {
|
|
726
|
+
const row = this.db.prepare("SELECT * FROM board_views WHERE id = ?").get(id);
|
|
727
|
+
return row ? boardViewFromRow(row) : null;
|
|
728
|
+
}
|
|
729
|
+
getBoardView(id) {
|
|
730
|
+
const view = this.findBoardView(id);
|
|
731
|
+
if (!view)
|
|
732
|
+
throw new NotFoundError(`Board view ${id} not found.`);
|
|
733
|
+
return view;
|
|
734
|
+
}
|
|
735
|
+
/** Vues d'un membre dans un espace, dans l'ordre des onglets. */
|
|
736
|
+
listBoardViews(spaceId, userId) {
|
|
737
|
+
const rows = this.db.prepare("SELECT * FROM board_views WHERE space_id = ? AND user_id = ? ORDER BY position, id").all(spaceId, userId);
|
|
738
|
+
return rows.map(boardViewFromRow);
|
|
739
|
+
}
|
|
671
740
|
/** Tâches de test qui vérifient une tâche. */
|
|
672
741
|
listTestsOf(taskId) {
|
|
673
742
|
const rows = this.db.prepare("SELECT * FROM tasks WHERE tested_task_id = ? ORDER BY number").all(taskId);
|
|
@@ -1259,6 +1328,7 @@ export class Mutation {
|
|
|
1259
1328
|
throw new NotFoundError(`User ${userId} is not a member of space ${spaceId}.`);
|
|
1260
1329
|
this.db.prepare("DELETE FROM memberships WHERE space_id = ? AND user_id = ?").run(spaceId, userId);
|
|
1261
1330
|
this.db.prepare("DELETE FROM space_notification_settings WHERE space_id = ? AND user_id = ?").run(spaceId, userId);
|
|
1331
|
+
this.db.prepare("DELETE FROM board_views WHERE space_id = ? AND user_id = ?").run(spaceId, userId);
|
|
1262
1332
|
this.touch("membership", `${spaceId}:${userId}`, spaceId, userId);
|
|
1263
1333
|
const tokenIds = this.db.prepare("SELECT id FROM agent_tokens WHERE space_id = ? AND user_id = ? AND revoked_at IS NULL").pluck().all(spaceId, userId);
|
|
1264
1334
|
this.db.prepare("UPDATE agent_tokens SET revoked_at = ? WHERE space_id = ? AND user_id = ? AND revoked_at IS NULL").run(this.now, spaceId, userId);
|
|
@@ -1785,6 +1855,43 @@ export class Mutation {
|
|
|
1785
1855
|
this.db.prepare("DELETE FROM ideas WHERE id = ?").run(id);
|
|
1786
1856
|
this.touch("idea", id, idea.spaceId, null);
|
|
1787
1857
|
}
|
|
1858
|
+
// --- Vues du tableau de bord ---
|
|
1859
|
+
/** Ajoute une vue à celles d'un membre dans un espace, après la dernière. */
|
|
1860
|
+
createBoardView(spaceId, userId, settings) {
|
|
1861
|
+
if (!this.store.findMembership(spaceId, userId))
|
|
1862
|
+
throw new NotFoundError(`User ${userId} is not a member of space ${spaceId}.`);
|
|
1863
|
+
const last = this.db.prepare("SELECT MAX(position) AS max FROM board_views WHERE space_id = ? AND user_id = ?").get(spaceId, userId);
|
|
1864
|
+
const view = validate(BoardViewSchema, {
|
|
1865
|
+
id: newId(),
|
|
1866
|
+
spaceId,
|
|
1867
|
+
userId,
|
|
1868
|
+
...normalizedSettings(settings),
|
|
1869
|
+
position: last.max === null ? 1 : Math.floor(last.max) + 1,
|
|
1870
|
+
createdAt: this.now,
|
|
1871
|
+
updatedAt: this.now,
|
|
1872
|
+
}, "board view");
|
|
1873
|
+
this.db
|
|
1874
|
+
.prepare(`INSERT INTO board_views (id, space_id, user_id, name, layout, group_by, then_by, show_empty_groups, statuses, priorities, position, created_at, updated_at)
|
|
1875
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
|
|
1876
|
+
.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), view.position, view.createdAt, view.updatedAt);
|
|
1877
|
+
this.touch("board_view", view.id, null, userId);
|
|
1878
|
+
return view;
|
|
1879
|
+
}
|
|
1880
|
+
updateBoardView(id, patch) {
|
|
1881
|
+
const current = this.store.getBoardView(id);
|
|
1882
|
+
const view = validate(BoardViewSchema, { ...current, ...normalizedSettings({ ...current, ...definedFields(patch) }), updatedAt: this.now }, "board view");
|
|
1883
|
+
this.db
|
|
1884
|
+
.prepare(`UPDATE board_views SET name = ?, layout = ?, group_by = ?, then_by = ?, show_empty_groups = ?, statuses = ?, priorities = ?, updated_at = ?
|
|
1885
|
+
WHERE id = ?`)
|
|
1886
|
+
.run(view.name, view.layout, view.groupBy, view.thenBy, view.showEmptyGroups ? 1 : 0, JSON.stringify(view.statuses), JSON.stringify(view.priorities), view.updatedAt, id);
|
|
1887
|
+
this.touch("board_view", id, null, view.userId);
|
|
1888
|
+
return view;
|
|
1889
|
+
}
|
|
1890
|
+
deleteBoardView(id) {
|
|
1891
|
+
const view = this.store.getBoardView(id);
|
|
1892
|
+
this.db.prepare("DELETE FROM board_views WHERE id = ?").run(id);
|
|
1893
|
+
this.touch("board_view", id, null, view.userId);
|
|
1894
|
+
}
|
|
1788
1895
|
// --- Demandes ---
|
|
1789
1896
|
/** Dépose une demande `pending` de l'utilisateur acteur. */
|
|
1790
1897
|
createAgentRequest(input) {
|
|
@@ -1800,6 +1907,7 @@ export class Mutation {
|
|
|
1800
1907
|
text: input.text,
|
|
1801
1908
|
status: "pending",
|
|
1802
1909
|
reply: null,
|
|
1910
|
+
followUps: [],
|
|
1803
1911
|
failureReason: null,
|
|
1804
1912
|
createdAt: this.now,
|
|
1805
1913
|
updatedAt: this.now,
|
|
@@ -1865,6 +1973,18 @@ export class Mutation {
|
|
|
1865
1973
|
this.touchRequest(released);
|
|
1866
1974
|
return released;
|
|
1867
1975
|
}
|
|
1976
|
+
/** Termine en échec une demande `processing` dont l'agent a été arrêté, avec la raison montrée à son auteur. */
|
|
1977
|
+
abortAgentRequest(id, reason) {
|
|
1978
|
+
if (this.actor.type !== "user")
|
|
1979
|
+
throw new InvariantError("Only a user can abort a request.");
|
|
1980
|
+
const current = this.store.getAgentRequest(id);
|
|
1981
|
+
if (current.status !== "processing")
|
|
1982
|
+
throw new InvariantError(`Request ${id} is ${current.status}: only a processing request can be aborted.`);
|
|
1983
|
+
this.db.prepare("UPDATE agent_requests SET status = 'failed', failure_reason = ?, completed_at = ?, updated_at = ? WHERE id = ?").run(reason, this.now, this.now, id);
|
|
1984
|
+
const aborted = this.store.getAgentRequest(id);
|
|
1985
|
+
this.touchRequest(aborted);
|
|
1986
|
+
return aborted;
|
|
1987
|
+
}
|
|
1868
1988
|
/** Demande et jeton de l'agent acteur. */
|
|
1869
1989
|
agentRequest() {
|
|
1870
1990
|
if (!this.request || !this.token)
|
|
@@ -1889,15 +2009,15 @@ export class Mutation {
|
|
|
1889
2009
|
this.touchRequest(claimed);
|
|
1890
2010
|
return claimed;
|
|
1891
2011
|
}
|
|
1892
|
-
/** Termine la demande de l'agent avec son message de compte rendu. */
|
|
1893
|
-
completeAgentRequest(reply) {
|
|
1894
|
-
return this.finishAgentRequest("done", reply, "reply");
|
|
2012
|
+
/** Termine la demande de l'agent avec son message de compte rendu et les points que l'auteur doit encore régler. */
|
|
2013
|
+
completeAgentRequest(reply, followUps) {
|
|
2014
|
+
return this.finishAgentRequest("done", reply, "reply", followUps);
|
|
1895
2015
|
}
|
|
1896
2016
|
/** Termine la demande de l'agent en échec, avec la raison montrée à son auteur. */
|
|
1897
2017
|
failAgentRequest(reason) {
|
|
1898
|
-
return this.finishAgentRequest("failed", reason, "reason");
|
|
2018
|
+
return this.finishAgentRequest("failed", reason, "reason", []);
|
|
1899
2019
|
}
|
|
1900
|
-
finishAgentRequest(status, message, what) {
|
|
2020
|
+
finishAgentRequest(status, message, what, followUps) {
|
|
1901
2021
|
const { request, token } = this.agentRequest();
|
|
1902
2022
|
this.assertRequestInTokenSpace(request, token);
|
|
1903
2023
|
if (request.status !== "processing") {
|
|
@@ -1908,9 +2028,10 @@ export class Mutation {
|
|
|
1908
2028
|
if (text === "")
|
|
1909
2029
|
throw new OrganizerError(`The ${what} is empty: write a short message for the author of the request.`);
|
|
1910
2030
|
const column = status === "done" ? "reply" : "failure_reason";
|
|
2031
|
+
const points = followUps.map((point) => point.trim()).filter((point) => point !== "");
|
|
1911
2032
|
this.db
|
|
1912
|
-
.prepare(`UPDATE agent_requests SET status = ?, ${column} = ?, completed_at = ?, updated_at = ? WHERE id = ?`)
|
|
1913
|
-
.run(status, text, this.now, this.now, request.id);
|
|
2033
|
+
.prepare(`UPDATE agent_requests SET status = ?, ${column} = ?, follow_ups = ?, completed_at = ?, updated_at = ? WHERE id = ?`)
|
|
2034
|
+
.run(status, text, JSON.stringify(points), this.now, this.now, request.id);
|
|
1914
2035
|
const finished = this.store.getAgentRequest(request.id);
|
|
1915
2036
|
this.touchRequest(finished);
|
|
1916
2037
|
return finished;
|
|
@@ -2056,6 +2177,43 @@ export class Mutation {
|
|
|
2056
2177
|
.run(userId, spaceId, settings.notifyAssignApp ? 1 : 0, settings.notifyAssignEmail ? 1 : 0, settings.notifyCommentApp ? 1 : 0, settings.notifyCommentEmail ? 1 : 0);
|
|
2057
2178
|
return settings;
|
|
2058
2179
|
}
|
|
2180
|
+
/**
|
|
2181
|
+
* Fixe les instructions de l'agent d'un espace, ou celles du site quand
|
|
2182
|
+
* `spaceId` est null ; un texte vide les retire.
|
|
2183
|
+
*/
|
|
2184
|
+
setAgentInstructions(spaceId, text) {
|
|
2185
|
+
if (this.actor.type !== "user")
|
|
2186
|
+
throw new InvariantError("Only a user can change the agent instructions.");
|
|
2187
|
+
if (spaceId !== null)
|
|
2188
|
+
this.store.getSpace(spaceId);
|
|
2189
|
+
this.touch("agent_instructions", spaceId ?? "site", spaceId, null);
|
|
2190
|
+
this.db.prepare("DELETE FROM agent_instructions WHERE space_id IS ?").run(spaceId);
|
|
2191
|
+
if (text.trim() === "")
|
|
2192
|
+
return null;
|
|
2193
|
+
const instructions = validate(AgentInstructionsSchema, { spaceId, text, updatedAt: this.now, updatedBy: this.actor.userId }, "agent instructions");
|
|
2194
|
+
this.db
|
|
2195
|
+
.prepare("INSERT INTO agent_instructions (space_id, text, updated_at, updated_by) VALUES (?, ?, ?, ?)")
|
|
2196
|
+
.run(instructions.spaceId, instructions.text, instructions.updatedAt, instructions.updatedBy);
|
|
2197
|
+
return instructions;
|
|
2198
|
+
}
|
|
2199
|
+
/** Fixe les limites d'une session du runner. */
|
|
2200
|
+
setRunnerSettings(settings) {
|
|
2201
|
+
if (this.actor.type !== "user")
|
|
2202
|
+
throw new InvariantError("Only a user can change the runner settings.");
|
|
2203
|
+
const valid = validate(RunnerSettingsSchema, settings, "runner settings");
|
|
2204
|
+
this.db
|
|
2205
|
+
.prepare("UPDATE runner_settings SET max_turns = ?, max_minutes = ?, max_budget_usd = ?, updated_at = ?, updated_by = ? WHERE id = 1")
|
|
2206
|
+
.run(valid.maxTurns, valid.maxMinutes, valid.maxBudgetUsd, this.now, this.actor.userId);
|
|
2207
|
+
return valid;
|
|
2208
|
+
}
|
|
2209
|
+
/** Enregistre le relevé d'une session du runner terminée. */
|
|
2210
|
+
recordRunnerSession(record) {
|
|
2211
|
+
const valid = validate(RunnerSessionRecordSchema, record, "runner session");
|
|
2212
|
+
this.db
|
|
2213
|
+
.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)
|
|
2214
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
|
|
2215
|
+
.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);
|
|
2216
|
+
}
|
|
2059
2217
|
// --- Fin de mutation ---
|
|
2060
2218
|
/** Vérifie les invariants sur l'état final, puis écrit les versions et le journal. */
|
|
2061
2219
|
finish() {
|
|
@@ -2236,6 +2394,19 @@ export class Mutation {
|
|
|
2236
2394
|
}
|
|
2237
2395
|
}
|
|
2238
2396
|
}
|
|
2397
|
+
/** Réglages d'une vue avec des filtres sans doublon, dans l'ordre des statuts et des priorités. */
|
|
2398
|
+
function normalizedSettings(settings) {
|
|
2399
|
+
const { name, layout, groupBy, thenBy, showEmptyGroups, statuses, priorities } = settings;
|
|
2400
|
+
return {
|
|
2401
|
+
name,
|
|
2402
|
+
layout,
|
|
2403
|
+
groupBy,
|
|
2404
|
+
thenBy,
|
|
2405
|
+
showEmptyGroups,
|
|
2406
|
+
statuses: TASK_STATUSES.filter((status) => statuses.includes(status)),
|
|
2407
|
+
priorities: TASK_PRIORITIES.filter((priority) => priorities.includes(priority)),
|
|
2408
|
+
};
|
|
2409
|
+
}
|
|
2239
2410
|
/** Champs de `patch` dont la valeur n'est pas `undefined`. */
|
|
2240
2411
|
function definedFields(patch) {
|
|
2241
2412
|
return Object.fromEntries(Object.entries(patch).filter(([, value]) => value !== undefined));
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* variables gérées absentes du fichier sont ajoutées à la fin.
|
|
8
8
|
*/
|
|
9
9
|
/** Variables écrites par le setup, dans l'ordre d'un fichier neuf. */
|
|
10
|
-
export declare const MANAGED_ENV_KEYS: readonly ["ORGANIZER_PUBLIC_URL", "ORGANIZER_BASE_PATH", "PORT", "HOST", "ORGANIZER_TRUST_PROXY", "MCP_ORGANIZER_DATA_DIR", "GROQ_API_KEY", "ORGANIZER_TRANSCRIBE_MODEL", "SMTP_URL", "MAIL_FROM"];
|
|
10
|
+
export declare const MANAGED_ENV_KEYS: readonly ["ORGANIZER_PUBLIC_URL", "ORGANIZER_BASE_PATH", "PORT", "HOST", "ORGANIZER_TRUST_PROXY", "MCP_ORGANIZER_DATA_DIR", "GROQ_API_KEY", "ORGANIZER_TRANSCRIBE_MODEL", "SMTP_URL", "MAIL_FROM", "ORGANIZER_RUNNER_CLAUDE"];
|
|
11
11
|
export type ManagedEnvKey = (typeof MANAGED_ENV_KEYS)[number];
|
|
12
12
|
/**
|
|
13
13
|
* Variables d'amorçage du premier compte : le setup crée le compte en base et
|
|
@@ -18,6 +18,7 @@ export const MANAGED_ENV_KEYS = [
|
|
|
18
18
|
"ORGANIZER_TRANSCRIBE_MODEL",
|
|
19
19
|
"SMTP_URL",
|
|
20
20
|
"MAIL_FROM",
|
|
21
|
+
"ORGANIZER_RUNNER_CLAUDE",
|
|
21
22
|
];
|
|
22
23
|
/**
|
|
23
24
|
* Variables d'amorçage du premier compte : le setup crée le compte en base et
|
|
@@ -51,6 +52,7 @@ const COMMENTS = {
|
|
|
51
52
|
ORGANIZER_PUBLIC_URL: "# URL ouverte par les utilisateurs, derrière nginx.",
|
|
52
53
|
PORT: "# Écoute du site ; nginx le joint à cette adresse.",
|
|
53
54
|
MCP_ORGANIZER_DATA_DIR: "# Base SQLite, pièces jointes et journaux.",
|
|
55
|
+
ORGANIZER_RUNNER_CLAUDE: "# Claude Code du runner, connecté pour le compte du site.",
|
|
54
56
|
GROQ_API_KEY: "# Dictée vocale (Groq).",
|
|
55
57
|
SMTP_URL: "# Envoi des e-mails (invitations, notifications).",
|
|
56
58
|
};
|
package/dist/src/gui-api.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type ApiRequestData, type ApiResponseData, type ApiErrorKind } from "../shared/schemas/gui-api.schema.js";
|
|
2
|
-
import { type
|
|
2
|
+
import { type RunnerFailure } from "../shared/schemas/agent-api.schema.js";
|
|
3
|
+
import { type KillAllResponse, type RunnerStatus } from "../shared/schemas/admin-api.schema.js";
|
|
3
4
|
import type { AttachmentStorage } from "./core/attachments.js";
|
|
4
5
|
import type { Mailer } from "./core/mail.js";
|
|
5
6
|
import type { Store } from "./core/store.js";
|
|
@@ -31,6 +32,16 @@ export interface GuiApiContext {
|
|
|
31
32
|
runner: {
|
|
32
33
|
status: RunnerStatus;
|
|
33
34
|
runNow: ((spaceId: string) => void) | null;
|
|
35
|
+
/** Dernière session du runner dans un espace, quand elle a échoué. */
|
|
36
|
+
lastFailure: (spaceId: string) => RunnerFailure | null;
|
|
37
|
+
/** Session du runner en cours dans un espace. */
|
|
38
|
+
currentSession: (spaceId: string) => {
|
|
39
|
+
startedAt: string;
|
|
40
|
+
} | null;
|
|
41
|
+
/** Arrête la session en cours dans un espace ; rend les demandes passées en échec, null sans session (null quand le runner est désactivé). */
|
|
42
|
+
stopSession: ((spaceId: string, userId: string) => number | null) | null;
|
|
43
|
+
/** Arrêt d'urgence : tue tous les processus Claude Code de la machine du site. */
|
|
44
|
+
killAll: (userId: string) => Promise<KillAllResponse>;
|
|
34
45
|
};
|
|
35
46
|
/** Horloge, imposée par les tests. */
|
|
36
47
|
now?: () => Date;
|