@plandesk/api 0.1.0
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/dist/auth.d.ts +3 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +37 -0
- package/dist/auth.js.map +1 -0
- package/dist/events.d.ts +38 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +20 -0
- package/dist/events.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/routes/agent-runs.d.ts +4 -0
- package/dist/routes/agent-runs.d.ts.map +1 -0
- package/dist/routes/agent-runs.js +13 -0
- package/dist/routes/agent-runs.js.map +1 -0
- package/dist/routes/canvas.d.ts +4 -0
- package/dist/routes/canvas.d.ts.map +1 -0
- package/dist/routes/canvas.js +53 -0
- package/dist/routes/canvas.js.map +1 -0
- package/dist/routes/documents.d.ts +4 -0
- package/dist/routes/documents.d.ts.map +1 -0
- package/dist/routes/documents.js +88 -0
- package/dist/routes/documents.js.map +1 -0
- package/dist/routes/events.d.ts +4 -0
- package/dist/routes/events.d.ts.map +1 -0
- package/dist/routes/events.js +35 -0
- package/dist/routes/events.js.map +1 -0
- package/dist/routes/health.d.ts +3 -0
- package/dist/routes/health.d.ts.map +1 -0
- package/dist/routes/health.js +4 -0
- package/dist/routes/health.js.map +1 -0
- package/dist/routes/projects.d.ts +5 -0
- package/dist/routes/projects.d.ts.map +1 -0
- package/dist/routes/projects.js +42 -0
- package/dist/routes/projects.js.map +1 -0
- package/dist/routes/tasks.d.ts +4 -0
- package/dist/routes/tasks.d.ts.map +1 -0
- package/dist/routes/tasks.js +32 -0
- package/dist/routes/tasks.js.map +1 -0
- package/dist/routes/tokens.d.ts +4 -0
- package/dist/routes/tokens.d.ts.map +1 -0
- package/dist/routes/tokens.js +22 -0
- package/dist/routes/tokens.js.map +1 -0
- package/dist/serialize.d.ts +84 -0
- package/dist/serialize.d.ts.map +1 -0
- package/dist/serialize.js +111 -0
- package/dist/serialize.js.map +1 -0
- package/dist/server.d.ts +13 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +35 -0
- package/dist/server.js.map +1 -0
- package/dist/services/agent-runs.d.ts +48 -0
- package/dist/services/agent-runs.d.ts.map +1 -0
- package/dist/services/agent-runs.js +93 -0
- package/dist/services/agent-runs.js.map +1 -0
- package/dist/services/canvas.d.ts +100 -0
- package/dist/services/canvas.d.ts.map +1 -0
- package/dist/services/canvas.js +152 -0
- package/dist/services/canvas.js.map +1 -0
- package/dist/services/documents.d.ts +33 -0
- package/dist/services/documents.d.ts.map +1 -0
- package/dist/services/documents.js +97 -0
- package/dist/services/documents.js.map +1 -0
- package/dist/services/index.d.ts +23 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +26 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/projects.d.ts +35 -0
- package/dist/services/projects.d.ts.map +1 -0
- package/dist/services/projects.js +30 -0
- package/dist/services/projects.js.map +1 -0
- package/dist/services/tasks.d.ts +66 -0
- package/dist/services/tasks.d.ts.map +1 -0
- package/dist/services/tasks.js +64 -0
- package/dist/services/tasks.js.map +1 -0
- package/dist/services/tokens.d.ts +15 -0
- package/dist/services/tokens.d.ts.map +1 -0
- package/dist/services/tokens.js +26 -0
- package/dist/services/tokens.js.map +1 -0
- package/dist/static.d.ts +3 -0
- package/dist/static.d.ts.map +1 -0
- package/dist/static.js +27 -0
- package/dist/static.js.map +1 -0
- package/dist/test-helpers.d.ts +37 -0
- package/dist/test-helpers.d.ts.map +1 -0
- package/dist/test-helpers.js +17 -0
- package/dist/test-helpers.js.map +1 -0
- package/package.json +32 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { AgentRun, AgentRunEvent, Document, Edge, Project, Task, TaskStatus } from '@plandesk/db';
|
|
2
|
+
export type TaskStatusSummary = Record<TaskStatus, number>;
|
|
3
|
+
export declare function emptyTaskStatusSummary(): TaskStatusSummary;
|
|
4
|
+
export declare function serializeProject(project: Project): {
|
|
5
|
+
id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
description: string | null;
|
|
8
|
+
created_at: string;
|
|
9
|
+
updated_at: string;
|
|
10
|
+
};
|
|
11
|
+
export declare function serializeProjectDetail(project: Project, summary: TaskStatusSummary): {
|
|
12
|
+
summary: TaskStatusSummary;
|
|
13
|
+
id: string;
|
|
14
|
+
name: string;
|
|
15
|
+
description: string | null;
|
|
16
|
+
created_at: string;
|
|
17
|
+
updated_at: string;
|
|
18
|
+
};
|
|
19
|
+
export declare function serializeTask(task: Task): {
|
|
20
|
+
id: string;
|
|
21
|
+
project_id: string;
|
|
22
|
+
label: string;
|
|
23
|
+
status: "scope" | "todo" | "in_progress" | "done" | "backlog";
|
|
24
|
+
description: string | null;
|
|
25
|
+
x: number;
|
|
26
|
+
y: number;
|
|
27
|
+
assignee: string | null;
|
|
28
|
+
due_date: string | null;
|
|
29
|
+
created_at: string;
|
|
30
|
+
updated_at: string;
|
|
31
|
+
};
|
|
32
|
+
export type SerializedDocument = {
|
|
33
|
+
id: string;
|
|
34
|
+
project_id: string;
|
|
35
|
+
title: string;
|
|
36
|
+
body: string | null;
|
|
37
|
+
status_line: string | null;
|
|
38
|
+
parent_id: string | null;
|
|
39
|
+
linked_task_id: string | null;
|
|
40
|
+
created_at: string;
|
|
41
|
+
updated_at: string;
|
|
42
|
+
};
|
|
43
|
+
export type SerializedDocumentTree = SerializedDocument & {
|
|
44
|
+
children: SerializedDocumentTree[];
|
|
45
|
+
};
|
|
46
|
+
export declare function serializeDocument(document: Document): SerializedDocument;
|
|
47
|
+
export declare function buildDocumentTree(documents: Document[]): SerializedDocumentTree[];
|
|
48
|
+
export declare function serializeEdge(edge: Edge): {
|
|
49
|
+
id: string;
|
|
50
|
+
project_id: string;
|
|
51
|
+
from_task_id: string;
|
|
52
|
+
to_task_id: string;
|
|
53
|
+
label: string | null;
|
|
54
|
+
arrow_direction: string | null;
|
|
55
|
+
style: string | null;
|
|
56
|
+
created_at: string;
|
|
57
|
+
};
|
|
58
|
+
export declare function serializeAgentRun(run: AgentRun): {
|
|
59
|
+
id: string;
|
|
60
|
+
project_id: string;
|
|
61
|
+
status: "running" | "completed" | "failed";
|
|
62
|
+
label: string | null;
|
|
63
|
+
started_at: string;
|
|
64
|
+
completed_at: string | null;
|
|
65
|
+
};
|
|
66
|
+
export declare function serializeAgentRunEvent(event: AgentRunEvent): {
|
|
67
|
+
id: string;
|
|
68
|
+
run_id: string;
|
|
69
|
+
message: string;
|
|
70
|
+
created_at: string;
|
|
71
|
+
};
|
|
72
|
+
export type SerializedToken = {
|
|
73
|
+
id: string;
|
|
74
|
+
name: string;
|
|
75
|
+
created_at: string;
|
|
76
|
+
revoked_at: string | null;
|
|
77
|
+
};
|
|
78
|
+
export declare function serializeToken(token: {
|
|
79
|
+
id: string;
|
|
80
|
+
name: string;
|
|
81
|
+
created_at: string;
|
|
82
|
+
revoked_at: string | null;
|
|
83
|
+
}): SerializedToken;
|
|
84
|
+
//# sourceMappingURL=serialize.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serialize.d.ts","sourceRoot":"","sources":["../src/serialize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,aAAa,EACb,QAAQ,EACR,IAAI,EACJ,OAAO,EACP,IAAI,EACJ,UAAU,EACX,MAAM,cAAc,CAAC;AAGtB,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;AAE3D,wBAAgB,sBAAsB,IAAI,iBAAiB,CAE1D;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO;;;;;;EAQhD;AAED,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,iBAAiB;;;;;;;EAKlF;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI;;;;;;;;;;;;EAcv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|
2
|
+
export function emptyTaskStatusSummary() {
|
|
3
|
+
return Object.fromEntries(taskStatuses.map((status) => [status, 0]));
|
|
4
|
+
}
|
|
5
|
+
export function serializeProject(project) {
|
|
6
|
+
return {
|
|
7
|
+
id: project.id,
|
|
8
|
+
name: project.name,
|
|
9
|
+
description: project.description,
|
|
10
|
+
created_at: project.createdAt.toISOString(),
|
|
11
|
+
updated_at: project.updatedAt.toISOString(),
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export function serializeProjectDetail(project, summary) {
|
|
15
|
+
return {
|
|
16
|
+
...serializeProject(project),
|
|
17
|
+
summary,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export function serializeTask(task) {
|
|
21
|
+
return {
|
|
22
|
+
id: task.id,
|
|
23
|
+
project_id: task.projectId,
|
|
24
|
+
label: task.label,
|
|
25
|
+
status: task.status,
|
|
26
|
+
description: task.description,
|
|
27
|
+
x: task.x,
|
|
28
|
+
y: task.y,
|
|
29
|
+
assignee: task.assignee,
|
|
30
|
+
due_date: task.dueDate?.toISOString() ?? null,
|
|
31
|
+
created_at: task.createdAt.toISOString(),
|
|
32
|
+
updated_at: task.updatedAt.toISOString(),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export function serializeDocument(document) {
|
|
36
|
+
return {
|
|
37
|
+
id: document.id,
|
|
38
|
+
project_id: document.projectId,
|
|
39
|
+
title: document.title,
|
|
40
|
+
body: document.body,
|
|
41
|
+
status_line: document.statusLine,
|
|
42
|
+
parent_id: document.parentId,
|
|
43
|
+
linked_task_id: document.linkedTaskId,
|
|
44
|
+
created_at: document.createdAt.toISOString(),
|
|
45
|
+
updated_at: document.updatedAt.toISOString(),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
export function buildDocumentTree(documents) {
|
|
49
|
+
const nodes = new Map();
|
|
50
|
+
for (const document of documents) {
|
|
51
|
+
nodes.set(document.id, { ...serializeDocument(document), children: [] });
|
|
52
|
+
}
|
|
53
|
+
const roots = [];
|
|
54
|
+
for (const document of documents) {
|
|
55
|
+
const node = nodes.get(document.id);
|
|
56
|
+
if (!node) {
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
if (document.parentId === null) {
|
|
60
|
+
roots.push(node);
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
const parent = nodes.get(document.parentId);
|
|
64
|
+
if (parent) {
|
|
65
|
+
parent.children.push(node);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
roots.push(node);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return roots;
|
|
72
|
+
}
|
|
73
|
+
export function serializeEdge(edge) {
|
|
74
|
+
return {
|
|
75
|
+
id: edge.id,
|
|
76
|
+
project_id: edge.projectId,
|
|
77
|
+
from_task_id: edge.fromTaskId,
|
|
78
|
+
to_task_id: edge.toTaskId,
|
|
79
|
+
label: edge.label,
|
|
80
|
+
arrow_direction: edge.arrowDirection,
|
|
81
|
+
style: edge.style,
|
|
82
|
+
created_at: edge.createdAt.toISOString(),
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
export function serializeAgentRun(run) {
|
|
86
|
+
return {
|
|
87
|
+
id: run.id,
|
|
88
|
+
project_id: run.projectId,
|
|
89
|
+
status: run.status,
|
|
90
|
+
label: run.label,
|
|
91
|
+
started_at: run.startedAt.toISOString(),
|
|
92
|
+
completed_at: run.completedAt?.toISOString() ?? null,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
export function serializeAgentRunEvent(event) {
|
|
96
|
+
return {
|
|
97
|
+
id: event.id,
|
|
98
|
+
run_id: event.runId,
|
|
99
|
+
message: event.message,
|
|
100
|
+
created_at: event.createdAt.toISOString(),
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
export function serializeToken(token) {
|
|
104
|
+
return {
|
|
105
|
+
id: token.id,
|
|
106
|
+
name: token.name,
|
|
107
|
+
created_at: token.created_at,
|
|
108
|
+
revoked_at: token.revoked_at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CAAC;AASD,MAAM,UAAU,cAAc,CAAC,KAK9B;IACC,OAAO;QACL,EAAE,EAAE,KAAK,CAAC,EAAE;QACZ,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,UAAU,EAAE,KAAK,CAAC,UAAU;KAC7B,CAAC;AACJ,CAAC"}
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Hono } from 'hono';
|
|
2
|
+
import type { Db } from '@plandesk/db';
|
|
3
|
+
import type { EventBus } from './events.js';
|
|
4
|
+
import { type Services } from './services/index.js';
|
|
5
|
+
export type AppDeps = {
|
|
6
|
+
db: Db;
|
|
7
|
+
eventBus?: EventBus;
|
|
8
|
+
services?: Services;
|
|
9
|
+
mcp?: Hono;
|
|
10
|
+
authPassword?: string;
|
|
11
|
+
};
|
|
12
|
+
export declare function createApp(deps: AppDeps): Hono;
|
|
13
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAOvC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAK5C,OAAO,EAAkB,KAAK,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEpE,MAAM,MAAM,OAAO,GAAG;IACpB,EAAE,EAAE,EAAE,CAAC;IACP,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,GAAG,CAAC,EAAE,IAAI,CAAC;IACX,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,wBAAgB,SAAS,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAmC7C"}
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Hono } from 'hono';
|
|
2
|
+
import { createAuthMiddleware } from './auth.js';
|
|
3
|
+
import { healthRouter } from './routes/health.js';
|
|
4
|
+
import { createProjectsRouter } from './routes/projects.js';
|
|
5
|
+
import { createTasksRouter } from './routes/tasks.js';
|
|
6
|
+
import { createCanvasRouter } from './routes/canvas.js';
|
|
7
|
+
import { createDocumentsRouter } from './routes/documents.js';
|
|
8
|
+
import { createEventsRouter } from './routes/events.js';
|
|
9
|
+
import { createTokensRouter } from './routes/tokens.js';
|
|
10
|
+
import { createAgentRunsRouter } from './routes/agent-runs.js';
|
|
11
|
+
import { mountStatic } from './static.js';
|
|
12
|
+
import { createServices } from './services/index.js';
|
|
13
|
+
export function createApp(deps) {
|
|
14
|
+
const services = deps.services ?? createServices({ db: deps.db, eventBus: deps.eventBus });
|
|
15
|
+
const { eventBus, projectService, taskService, canvasService, documentService, agentRunService, tokenService, } = services;
|
|
16
|
+
const app = new Hono();
|
|
17
|
+
if (deps.authPassword !== undefined && deps.authPassword.length > 0) {
|
|
18
|
+
app.use('*', createAuthMiddleware(deps.authPassword));
|
|
19
|
+
}
|
|
20
|
+
app.route('/api/v1', healthRouter);
|
|
21
|
+
app.route('/api/v1', createProjectsRouter(projectService, taskService));
|
|
22
|
+
app.route('/api/v1', createTasksRouter(taskService));
|
|
23
|
+
app.route('/api/v1', createCanvasRouter(canvasService));
|
|
24
|
+
app.route('/api/v1', createDocumentsRouter(documentService));
|
|
25
|
+
app.route('/api/v1', createTokensRouter(tokenService));
|
|
26
|
+
app.route('/api/v1', createAgentRunsRouter(agentRunService));
|
|
27
|
+
app.route('/api/v1', createEventsRouter(eventBus));
|
|
28
|
+
mountStatic(app);
|
|
29
|
+
if (deps.mcp) {
|
|
30
|
+
app.route('/mcp', deps.mcp);
|
|
31
|
+
}
|
|
32
|
+
app.notFound((c) => c.json({ error: 'not_found' }, 404));
|
|
33
|
+
return app;
|
|
34
|
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EventBus;
|
|
6
|
+
};
|
|
7
|
+
export declare class InvalidAgentRunError extends Error {
|
|
8
|
+
constructor(message: string);
|
|
9
|
+
}
|
|
10
|
+
export declare function createAgentRunService(deps: AgentRunServiceDeps): {
|
|
11
|
+
listForProject(projectId: string): {
|
|
12
|
+
events: {
|
|
13
|
+
id: string;
|
|
14
|
+
message: string;
|
|
15
|
+
created_at: string;
|
|
16
|
+
}[];
|
|
17
|
+
id: string;
|
|
18
|
+
project_id: string;
|
|
19
|
+
status: "running" | "completed" | "failed";
|
|
20
|
+
label: string | null;
|
|
21
|
+
started_at: string;
|
|
22
|
+
completed_at: string | null;
|
|
23
|
+
}[] | undefined;
|
|
24
|
+
start(projectId: string, label?: string | null): {
|
|
25
|
+
id: string;
|
|
26
|
+
project_id: string;
|
|
27
|
+
status: "running" | "completed" | "failed";
|
|
28
|
+
label: string | null;
|
|
29
|
+
started_at: string;
|
|
30
|
+
completed_at: string | null;
|
|
31
|
+
} | undefined;
|
|
32
|
+
recordProgress(runId: string, message: string): {
|
|
33
|
+
id: string;
|
|
34
|
+
run_id: string;
|
|
35
|
+
message: string;
|
|
36
|
+
created_at: string;
|
|
37
|
+
} | undefined;
|
|
38
|
+
complete(runId: string, status: "completed" | "failed"): {
|
|
39
|
+
id: string;
|
|
40
|
+
project_id: string;
|
|
41
|
+
status: "running" | "completed" | "failed";
|
|
42
|
+
label: string | null;
|
|
43
|
+
started_at: string;
|
|
44
|
+
completed_at: string | null;
|
|
45
|
+
} | undefined;
|
|
46
|
+
};
|
|
47
|
+
export type AgentRunService = ReturnType<typeof createAgentRunService>;
|
|
48
|
+
//# sourceMappingURL=agent-runs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-runs.d.ts","sourceRoot":"","sources":["../../src/services/agent-runs.ts"],"names":[],"mappings":"AAAA,OAAO,EASL,KAAK,EAAE,EACR,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAG7C,MAAM,MAAM,mBAAmB,GAAG;IAChC,EAAE,EAAE,EAAE,CAAC;IACP,QAAQ,EAAE,QAAQ,CAAC;CACpB,CAAC;AAEF,qBAAa,oBAAqB,SAAQ,KAAK;gBACjC,OAAO,EAAE,MAAM;CAI5B;AAID,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,mBAAmB;8BAIjC,MAAM;;;;;;;;;;;;;qBA8Bf,MAAM,UAAU,MAAM,GAAG,IAAI;;;;;;;;0BAgBxB,MAAM,WAAW,MAAM;;;;;;oBAoB7B,MAAM,UAAU,WAAW,GAAG,QAAQ;;;;;;;;EA2BzD;AAED,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { createAgentRun, createAgentRunEvent, getAgentRun, getProject, listAgentRunEvents, listAgentRuns, updateAgentRunStatus, } from '@plandesk/db';
|
|
2
|
+
import { serializeAgentRun, serializeAgentRunEvent } from '../serialize.js';
|
|
3
|
+
export class InvalidAgentRunError extends Error {
|
|
4
|
+
constructor(message) {
|
|
5
|
+
super(message);
|
|
6
|
+
this.name = 'InvalidAgentRunError';
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
const terminalStatuses = new Set(['completed', 'failed']);
|
|
10
|
+
export function createAgentRunService(deps) {
|
|
11
|
+
const { db, eventBus } = deps;
|
|
12
|
+
return {
|
|
13
|
+
listForProject(projectId) {
|
|
14
|
+
const project = getProject(db, projectId);
|
|
15
|
+
if (!project) {
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
const runs = listAgentRuns(db, projectId)
|
|
19
|
+
.slice()
|
|
20
|
+
.sort((a, b) => {
|
|
21
|
+
const timeDiff = b.startedAt.getTime() - a.startedAt.getTime();
|
|
22
|
+
if (timeDiff !== 0) {
|
|
23
|
+
return timeDiff;
|
|
24
|
+
}
|
|
25
|
+
return b.id.localeCompare(a.id);
|
|
26
|
+
});
|
|
27
|
+
return runs.map((run) => {
|
|
28
|
+
const serialized = serializeAgentRun(run);
|
|
29
|
+
const events = listAgentRunEvents(db, run.id).map((event) => {
|
|
30
|
+
const serialized = serializeAgentRunEvent(event);
|
|
31
|
+
return {
|
|
32
|
+
id: serialized.id,
|
|
33
|
+
message: serialized.message,
|
|
34
|
+
created_at: serialized.created_at,
|
|
35
|
+
};
|
|
36
|
+
});
|
|
37
|
+
return { ...serialized, events };
|
|
38
|
+
});
|
|
39
|
+
},
|
|
40
|
+
start(projectId, label) {
|
|
41
|
+
const project = getProject(db, projectId);
|
|
42
|
+
if (!project) {
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
const run = createAgentRun(db, { projectId, label });
|
|
46
|
+
eventBus.emit({
|
|
47
|
+
type: 'agent_run_started',
|
|
48
|
+
runId: run.id,
|
|
49
|
+
projectId,
|
|
50
|
+
});
|
|
51
|
+
return serializeAgentRun(run);
|
|
52
|
+
},
|
|
53
|
+
recordProgress(runId, message) {
|
|
54
|
+
const run = getAgentRun(db, runId);
|
|
55
|
+
if (!run) {
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
if (terminalStatuses.has(run.status)) {
|
|
59
|
+
throw new InvalidAgentRunError('Agent run is already complete');
|
|
60
|
+
}
|
|
61
|
+
const event = createAgentRunEvent(db, { runId, message });
|
|
62
|
+
eventBus.emit({
|
|
63
|
+
type: 'agent_run_progress',
|
|
64
|
+
runId,
|
|
65
|
+
projectId: run.projectId,
|
|
66
|
+
});
|
|
67
|
+
return serializeAgentRunEvent(event);
|
|
68
|
+
},
|
|
69
|
+
complete(runId, status) {
|
|
70
|
+
const run = getAgentRun(db, runId);
|
|
71
|
+
if (!run) {
|
|
72
|
+
return undefined;
|
|
73
|
+
}
|
|
74
|
+
if (terminalStatuses.has(run.status)) {
|
|
75
|
+
throw new InvalidAgentRunError('Agent run is already complete');
|
|
76
|
+
}
|
|
77
|
+
const updated = updateAgentRunStatus(db, runId, {
|
|
78
|
+
status,
|
|
79
|
+
completedAt: new Date(),
|
|
80
|
+
});
|
|
81
|
+
if (!updated) {
|
|
82
|
+
return undefined;
|
|
83
|
+
}
|
|
84
|
+
eventBus.emit({
|
|
85
|
+
type: 'agent_run_completed',
|
|
86
|
+
runId,
|
|
87
|
+
projectId: run.projectId,
|
|
88
|
+
});
|
|
89
|
+
return serializeAgentRun(updated);
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=agent-runs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-runs.js","sourceRoot":"","sources":["../../src/services/agent-runs.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,WAAW,EACX,UAAU,EACV,kBAAkB,EAClB,aAAa,EACb,oBAAoB,GAGrB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAO5E,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAC7C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;IACrC,CAAC;CACF;AAED,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAiB,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC,CAAC;AAE1E,MAAM,UAAU,qBAAqB,CAAC,IAAyB;IAC7D,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;IAE9B,OAAO;QACL,cAAc,CAAC,SAAiB;YAC9B,MAAM,OAAO,GAAG,UAAU,CAAC,EAAE,EAAE,SAAS,CAAC,CAAC;YAC1C,IAAI,CAAC,OAAO,EAAE,CAAC;gBACb,OAAO,SAAS,CAAC;YACnB,CAAC;YAED,MAAM,IAAI,GAAG,aAAa,CAAC,EAAE,EAAE,SAAS,CAAC;iBACtC,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AC;YAED,QAAQ,CAAC,IAAI,CAAC;gBACZ,IAAI,EAAE,qBAAqB;gBAC3B,KAAK;gBACL,SAAS,EAAE,GAAG,CAAC,SAAS;aACzB,CAAC,CAAC;YAEH,OAAO,iBAAiB,CAAC,OAAO,CAAC,CAAC;QACpC,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { type Db } from '@plandesk/db';
|
|
2
|
+
import type { EventBus } from '../events.js';
|
|
3
|
+
export type CanvasServiceDeps = {
|
|
4
|
+
db: Db;
|
|
5
|
+
eventBus: EventBus;
|
|
6
|
+
};
|
|
7
|
+
export type CanvasNodeInput = {
|
|
8
|
+
id?: string;
|
|
9
|
+
x: number;
|
|
10
|
+
y: number;
|
|
11
|
+
label?: string;
|
|
12
|
+
status?: string;
|
|
13
|
+
};
|
|
14
|
+
export type CanvasEdgeInput = {
|
|
15
|
+
id?: string;
|
|
16
|
+
from_task_id: string;
|
|
17
|
+
to_task_id: string;
|
|
18
|
+
label?: string | null;
|
|
19
|
+
arrow_direction?: string | null;
|
|
20
|
+
style?: string | null;
|
|
21
|
+
};
|
|
22
|
+
export type PutCanvasLayoutInput = {
|
|
23
|
+
nodes: CanvasNodeInput[];
|
|
24
|
+
edges: CanvasEdgeInput[];
|
|
25
|
+
layout?: unknown;
|
|
26
|
+
};
|
|
27
|
+
export declare class InvalidCanvasError extends Error {
|
|
28
|
+
constructor(message: string);
|
|
29
|
+
}
|
|
30
|
+
export declare function createCanvasService(deps: CanvasServiceDeps): {
|
|
31
|
+
get(projectId: string): {
|
|
32
|
+
nodes: {
|
|
33
|
+
id: string;
|
|
34
|
+
project_id: string;
|
|
35
|
+
label: string;
|
|
36
|
+
status: "scope" | "todo" | "in_progress" | "done" | "backlog";
|
|
37
|
+
description: string | null;
|
|
38
|
+
x: number;
|
|
39
|
+
y: number;
|
|
40
|
+
assignee: string | null;
|
|
41
|
+
due_date: string | null;
|
|
42
|
+
created_at: string;
|
|
43
|
+
updated_at: string;
|
|
44
|
+
}[];
|
|
45
|
+
edges: {
|
|
46
|
+
id: string;
|
|
47
|
+
project_id: string;
|
|
48
|
+
from_task_id: string;
|
|
49
|
+
to_task_id: string;
|
|
50
|
+
label: string | null;
|
|
51
|
+
arrow_direction: string | null;
|
|
52
|
+
style: string | null;
|
|
53
|
+
created_at: string;
|
|
54
|
+
}[];
|
|
55
|
+
layout: unknown;
|
|
56
|
+
} | undefined;
|
|
57
|
+
createEdge(projectId: string, input: {
|
|
58
|
+
fromTaskId: string;
|
|
59
|
+
toTaskId: string;
|
|
60
|
+
label?: string | null;
|
|
61
|
+
style?: string | null;
|
|
62
|
+
}): {
|
|
63
|
+
id: string;
|
|
64
|
+
project_id: string;
|
|
65
|
+
from_task_id: string;
|
|
66
|
+
to_task_id: string;
|
|
67
|
+
label: string | null;
|
|
68
|
+
arrow_direction: string | null;
|
|
69
|
+
style: string | null;
|
|
70
|
+
created_at: string;
|
|
71
|
+
} | undefined;
|
|
72
|
+
putLayout(projectId: string, payload: PutCanvasLayoutInput): {
|
|
73
|
+
nodes: {
|
|
74
|
+
id: string;
|
|
75
|
+
project_id: string;
|
|
76
|
+
label: string;
|
|
77
|
+
status: "scope" | "todo" | "in_progress" | "done" | "backlog";
|
|
78
|
+
description: string | null;
|
|
79
|
+
x: number;
|
|
80
|
+
y: number;
|
|
81
|
+
assignee: string | null;
|
|
82
|
+
due_date: string | null;
|
|
83
|
+
created_at: string;
|
|
84
|
+
updated_at: string;
|
|
85
|
+
}[];
|
|
86
|
+
edges: {
|
|
87
|
+
id: string;
|
|
88
|
+
project_id: string;
|
|
89
|
+
from_task_id: string;
|
|
90
|
+
to_task_id: string;
|
|
91
|
+
label: string | null;
|
|
92
|
+
arrow_direction: string | null;
|
|
93
|
+
style: string | null;
|
|
94
|
+
created_at: string;
|
|
95
|
+
}[];
|
|
96
|
+
layout: unknown;
|
|
97
|
+
} | undefined;
|
|
98
|
+
};
|
|
99
|
+
export type CanvasService = ReturnType<typeof createCanvasService>;
|
|
100
|
+
//# sourceMappingURL=canvas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canvas.d.ts","sourceRoot":"","sources":["../../src/services/canvas.ts"],"names":[],"mappings":"AAAA,OAAO,EAYL,KAAK,EAAE,EACR,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAG7C,MAAM,MAAM,iBAAiB,GAAG;IAC9B,EAAE,EAAE,EAAE,CAAC;IACP,QAAQ,EAAE,QAAQ,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,KAAK,EAAE,eAAe,EAAE,CAAC;IACzB,KAAK,EAAE,eAAe,EAAE,CAAC;IACzB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,qBAAa,kBAAmB,SAAQ,KAAK;gBAC/B,OAAO,EAAE,MAAM;CAI5B;AAaD,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,iBAAiB;mBAexC,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;0BAUR,MAAM,SACV;QAAE,UAAU,EAAE,MAAM,CAAC;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