@agentprojectcontext/apx 1.47.0 → 1.48.1
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/package.json +1 -1
- package/src/host/daemon/api/sessions.js +6 -4
- package/src/host/daemon/api/shared.js +24 -0
- package/src/host/daemon/api/tasks.js +11 -7
- package/src/interfaces/web/dist/assets/{index-oOjZZktw.js → index-BDJfFzQk.js} +129 -129
- package/src/interfaces/web/dist/assets/{index-oOjZZktw.js.map → index-BDJfFzQk.js.map} +1 -1
- package/src/interfaces/web/dist/index.html +1 -1
- package/src/interfaces/web/src/components/Pager.tsx +102 -12
- package/src/interfaces/web/src/components/Section.tsx +15 -4
- package/src/interfaces/web/src/lib/api/sessions.ts +11 -3
- package/src/interfaces/web/src/lib/api/tasks.ts +10 -3
- package/src/interfaces/web/src/lib/http.ts +28 -0
- package/src/interfaces/web/src/screens/base/GlobalTasksTab.tsx +33 -29
- package/src/interfaces/web/src/screens/base/SessionsTab.tsx +25 -22
- package/src/interfaces/web/src/screens/project/TasksTab.tsx +20 -19
package/package.json
CHANGED
|
@@ -13,20 +13,22 @@ import {
|
|
|
13
13
|
createAgentSessionFile,
|
|
14
14
|
} from "#core/stores/sessions.js";
|
|
15
15
|
import { collectAllSessions } from "#interfaces/cli/commands/sessions.js";
|
|
16
|
+
import { pageEnvelope } from "./shared.js";
|
|
16
17
|
|
|
17
18
|
export function register(app, { projects, project }) {
|
|
18
|
-
// Cross-engine sessions (apx · claude · codex), newest first.
|
|
19
|
+
// Cross-engine sessions (apx · claude · codex), newest first. Returns a
|
|
20
|
+
// { meta, data } envelope (meta = pagination info, data = rows). Paginated
|
|
21
|
+
// via ?limit & ?offset; with no limit, data is the full set as one page.
|
|
19
22
|
app.get("/sessions", (req, res) => {
|
|
20
23
|
const engineId = req.query.engine ? String(req.query.engine) : null;
|
|
21
|
-
const limit = Math.min(parseInt(req.query.limit, 10) || 200, 1000);
|
|
22
24
|
let rows = [];
|
|
23
25
|
try {
|
|
24
26
|
rows = collectAllSessions({}, { engineId });
|
|
25
27
|
} catch (e) {
|
|
26
|
-
return res.status(500).json({ error: e.message,
|
|
28
|
+
return res.status(500).json({ error: e.message, meta: { total: 0, offset: 0, limit: null, pageSize: 0, page: 1, pageCount: 1 }, data: [] });
|
|
27
29
|
}
|
|
28
30
|
rows.sort((a, b) => (b.mtime || 0) - (a.mtime || 0));
|
|
29
|
-
res.json(
|
|
31
|
+
res.json(pageEnvelope(rows, req.query));
|
|
30
32
|
});
|
|
31
33
|
|
|
32
34
|
app.get("/projects/:pid/agents/:slug/sessions", (req, res) => {
|
|
@@ -14,6 +14,30 @@ import { CHANNELS } from "#core/constants/channels.js";
|
|
|
14
14
|
export const nowIso = () =>
|
|
15
15
|
new Date().toISOString().replace(/\.\d{3}Z$/, "Z");
|
|
16
16
|
|
|
17
|
+
// Build a { meta, data } pagination envelope from an already-sorted array.
|
|
18
|
+
// Reads ?limit & ?offset from the request query. With no `limit`, returns the
|
|
19
|
+
// full set as a single page (data = 100% of rows) so non-paginated callers get
|
|
20
|
+
// the same shape — meta just reports one page covering everything.
|
|
21
|
+
// meta: { total, offset, limit, pageSize, page, pageCount }
|
|
22
|
+
export function pageEnvelope(rows, query = {}) {
|
|
23
|
+
const total = rows.length;
|
|
24
|
+
const hasLimit = query.limit != null && query.limit !== "";
|
|
25
|
+
const limit = hasLimit ? Math.min(Math.max(parseInt(query.limit, 10) || 0, 0), 1000) : null;
|
|
26
|
+
const offset = Math.max(parseInt(query.offset, 10) || 0, 0);
|
|
27
|
+
const data = limit != null ? rows.slice(offset, offset + limit) : rows.slice(offset);
|
|
28
|
+
return {
|
|
29
|
+
meta: {
|
|
30
|
+
total,
|
|
31
|
+
offset,
|
|
32
|
+
limit,
|
|
33
|
+
pageSize: limit != null ? limit : total,
|
|
34
|
+
page: limit ? Math.floor(offset / limit) + 1 : 1,
|
|
35
|
+
pageCount: limit ? Math.max(1, Math.ceil(total / limit)) : 1,
|
|
36
|
+
},
|
|
37
|
+
data,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
17
41
|
// Trace id middleware — populates req.apxTraceId and echoes it on the response.
|
|
18
42
|
export function traceIdMiddleware(req, res, next) {
|
|
19
43
|
req.apxTraceId = req.get("x-apx-trace-id") || randomUUID();
|
|
@@ -16,9 +16,12 @@ import {
|
|
|
16
16
|
reopenTask,
|
|
17
17
|
countTasks,
|
|
18
18
|
} from "#core/stores/tasks.js";
|
|
19
|
+
import { pageEnvelope } from "./shared.js";
|
|
19
20
|
|
|
20
21
|
export function register(app, { project, projects }) {
|
|
21
|
-
// Global tasks across every project.
|
|
22
|
+
// Global tasks across every project, newest first. Returns a { meta, data }
|
|
23
|
+
// envelope. Paginated via ?limit & ?offset; with no limit, data is the full
|
|
24
|
+
// set as one page.
|
|
22
25
|
app.get("/tasks", (req, res) => {
|
|
23
26
|
const state = req.query.state || "open";
|
|
24
27
|
const out = [];
|
|
@@ -29,27 +32,28 @@ export function register(app, { project, projects }) {
|
|
|
29
32
|
try {
|
|
30
33
|
tasks = listTasks(p.storagePath, {
|
|
31
34
|
state: state === "all" ? undefined : state,
|
|
32
|
-
limit: 500,
|
|
33
35
|
});
|
|
34
36
|
} catch { /* skip project */ }
|
|
35
37
|
for (const t of tasks) out.push({ ...t, project_id: entry.id, project_name: entry.name || entry.path });
|
|
36
38
|
}
|
|
37
|
-
|
|
39
|
+
out.sort((a, b) => (b.created_at || "").localeCompare(a.created_at || ""));
|
|
40
|
+
res.json(pageEnvelope(out, req.query));
|
|
38
41
|
});
|
|
39
42
|
|
|
43
|
+
// Per-project tasks. Returns a { meta, data } envelope; with no ?limit the
|
|
44
|
+
// data array is the full filtered set (one page).
|
|
40
45
|
app.get("/projects/:pid/tasks", (req, res) => {
|
|
41
46
|
const p = project(req, res);
|
|
42
47
|
if (!p) return;
|
|
43
|
-
const { state, tag, agent, due_before, due_after
|
|
44
|
-
const
|
|
48
|
+
const { state, tag, agent, due_before, due_after } = req.query;
|
|
49
|
+
const all = listTasks(p.storagePath, {
|
|
45
50
|
state: state || undefined,
|
|
46
51
|
tag: tag || undefined,
|
|
47
52
|
agent: agent || undefined,
|
|
48
53
|
due_before: due_before || undefined,
|
|
49
54
|
due_after: due_after || undefined,
|
|
50
|
-
limit: limit ? Math.min(parseInt(limit, 10) || 0, 1000) : undefined,
|
|
51
55
|
});
|
|
52
|
-
res.json(
|
|
56
|
+
res.json(pageEnvelope(all, req.query));
|
|
53
57
|
});
|
|
54
58
|
|
|
55
59
|
app.post("/projects/:pid/tasks", (req, res) => {
|