@agentconnect.md/daemon 1.0.0-rc.44 → 1.0.0-rc.46
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/index.js +81 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -17427,7 +17427,7 @@ const RegisterOk = object({
|
|
|
17427
17427
|
*/
|
|
17428
17428
|
/** One row in the session list (metadata + console metrics; NOT the transcript). */
|
|
17429
17429
|
const SessionListItem = object({
|
|
17430
|
-
sessionId: string()
|
|
17430
|
+
sessionId: string(),
|
|
17431
17431
|
sessionKey: SessionKey,
|
|
17432
17432
|
agentId: string().uuid(),
|
|
17433
17433
|
title: string().optional(),
|
|
@@ -17450,13 +17450,13 @@ const SessionMessage = object({
|
|
|
17450
17450
|
});
|
|
17451
17451
|
/** C→D REQ: fetch one page of a session's history from the owning daemon. */
|
|
17452
17452
|
const SessionHistoryReq = object({
|
|
17453
|
-
sessionId: string()
|
|
17453
|
+
sessionId: string(),
|
|
17454
17454
|
cursor: string().optional(),
|
|
17455
17455
|
limit: number().int().positive().max(200).default(50)
|
|
17456
17456
|
});
|
|
17457
17457
|
/** D→C REP (corr = the req id): a page of messages + the cursor for the next page. */
|
|
17458
17458
|
const SessionHistoryPage = object({
|
|
17459
|
-
sessionId: string()
|
|
17459
|
+
sessionId: string(),
|
|
17460
17460
|
messages: array(SessionMessage),
|
|
17461
17461
|
nextCursor: string().optional()
|
|
17462
17462
|
});
|
|
@@ -23392,6 +23392,29 @@ var LocalStore = class {
|
|
|
23392
23392
|
getSession(key) {
|
|
23393
23393
|
return this.db.prepare("SELECT * FROM sessions WHERE key = ?").get(key);
|
|
23394
23394
|
}
|
|
23395
|
+
/** All sessions that have an ACP id (i.e. are addressable by sessionId), newest
|
|
23396
|
+
* first. Optionally scoped to one agent. Backs `session/list` read-back. */
|
|
23397
|
+
listSessions(agentId) {
|
|
23398
|
+
if (agentId !== void 0) return this.db.prepare("SELECT * FROM sessions WHERE acpSessionId IS NOT NULL AND agentId = ? ORDER BY updatedAt DESC").all(agentId);
|
|
23399
|
+
return this.db.prepare("SELECT * FROM sessions WHERE acpSessionId IS NOT NULL ORDER BY updatedAt DESC").all();
|
|
23400
|
+
}
|
|
23401
|
+
/** Lookup by ACP session id (the protocol-facing `sessionId`), or undefined. */
|
|
23402
|
+
getSessionByAcpId(acpSessionId) {
|
|
23403
|
+
return this.db.prepare("SELECT * FROM sessions WHERE acpSessionId = ?").get(acpSessionId);
|
|
23404
|
+
}
|
|
23405
|
+
/**
|
|
23406
|
+
* One newest-first page of a thread's full transcript (all kinds), for `session/history`.
|
|
23407
|
+
* Pages backward via `beforeSeq` (the lowest seq already seen; null ⇒ newest page).
|
|
23408
|
+
* Over-fetches one row to detect `hasMore` without a second query. Rows stay seq DESC.
|
|
23409
|
+
*/
|
|
23410
|
+
transcriptPage(channel, thread, beforeSeq, limit) {
|
|
23411
|
+
const rows = beforeSeq !== null ? this.db.prepare("SELECT * FROM transcript WHERE channel = ? AND thread = ? AND seq < ? ORDER BY seq DESC LIMIT ?").all(channel, thread, beforeSeq, limit + 1) : this.db.prepare("SELECT * FROM transcript WHERE channel = ? AND thread = ? ORDER BY seq DESC LIMIT ?").all(channel, thread, limit + 1);
|
|
23412
|
+
const hasMore = rows.length > limit;
|
|
23413
|
+
return {
|
|
23414
|
+
rows: hasMore ? rows.slice(0, limit) : rows,
|
|
23415
|
+
hasMore
|
|
23416
|
+
};
|
|
23417
|
+
}
|
|
23395
23418
|
upsertSession(rec) {
|
|
23396
23419
|
this.db.prepare(`INSERT INTO sessions (key, agentId, platform, channel, thread, acpSessionId, state, lastDeliveredTs, updatedAt)
|
|
23397
23420
|
VALUES (@key, @agentId, @platform, @channel, @thread, @acpSessionId, @state, @lastDeliveredTs, @updatedAt)
|
|
@@ -81841,6 +81864,20 @@ var CpClient = class {
|
|
|
81841
81864
|
case "daemon/upgrade":
|
|
81842
81865
|
this.reply(frame, "daemon/control/ack", this.deps.configApply.applyDaemonUpgrade(frame.payload));
|
|
81843
81866
|
return;
|
|
81867
|
+
case "session/list":
|
|
81868
|
+
try {
|
|
81869
|
+
this.reply(frame, "session/list/page", this.deps.sessionRead.list(frame.payload));
|
|
81870
|
+
} catch (err) {
|
|
81871
|
+
this.sendError(frame.id, "INTERNAL", `session/list failed: ${err.message}`, false);
|
|
81872
|
+
}
|
|
81873
|
+
return;
|
|
81874
|
+
case "session/history":
|
|
81875
|
+
try {
|
|
81876
|
+
this.reply(frame, "session/history/page", this.deps.sessionRead.history(frame.payload));
|
|
81877
|
+
} catch (err) {
|
|
81878
|
+
this.sendError(frame.id, "INTERNAL", `session/history failed: ${err.message}`, false);
|
|
81879
|
+
}
|
|
81880
|
+
return;
|
|
81844
81881
|
case "agent/prompt":
|
|
81845
81882
|
this.sendError(frame.id, "INTERNAL", "agent/prompt not implemented", false);
|
|
81846
81883
|
return;
|
|
@@ -81858,6 +81895,46 @@ var CpClient = class {
|
|
|
81858
81895
|
}
|
|
81859
81896
|
};
|
|
81860
81897
|
//#endregion
|
|
81898
|
+
//#region src/cp/session-reader.ts
|
|
81899
|
+
function createSessionReader(store) {
|
|
81900
|
+
return {
|
|
81901
|
+
list(req) {
|
|
81902
|
+
return { sessions: store.listSessions(req.agentId).map((r) => ({
|
|
81903
|
+
sessionId: r.acpSessionId,
|
|
81904
|
+
sessionKey: {
|
|
81905
|
+
platform: r.platform,
|
|
81906
|
+
channel: r.channel,
|
|
81907
|
+
thread: r.thread
|
|
81908
|
+
},
|
|
81909
|
+
agentId: r.agentId,
|
|
81910
|
+
status: r.state,
|
|
81911
|
+
lastActivityAt: new Date(r.updatedAt).toISOString()
|
|
81912
|
+
})) };
|
|
81913
|
+
},
|
|
81914
|
+
history(req) {
|
|
81915
|
+
const rec = store.getSessionByAcpId(req.sessionId);
|
|
81916
|
+
if (!rec) return {
|
|
81917
|
+
sessionId: req.sessionId,
|
|
81918
|
+
messages: []
|
|
81919
|
+
};
|
|
81920
|
+
const before = req.cursor != null && Number.isFinite(Number(req.cursor)) ? Number(req.cursor) : null;
|
|
81921
|
+
const { rows, hasMore } = store.transcriptPage(rec.channel, rec.thread, before, req.limit);
|
|
81922
|
+
const messages = rows.slice().reverse().map((r) => ({
|
|
81923
|
+
seq: r.seq,
|
|
81924
|
+
sender: r.sender,
|
|
81925
|
+
ts: r.ts,
|
|
81926
|
+
kind: r.kind,
|
|
81927
|
+
text: r.text
|
|
81928
|
+
}));
|
|
81929
|
+
return {
|
|
81930
|
+
sessionId: req.sessionId,
|
|
81931
|
+
messages,
|
|
81932
|
+
...hasMore ? { nextCursor: String(rows[rows.length - 1].seq) } : {}
|
|
81933
|
+
};
|
|
81934
|
+
}
|
|
81935
|
+
};
|
|
81936
|
+
}
|
|
81937
|
+
//#endregion
|
|
81861
81938
|
//#region src/cp/cp-cron.ts
|
|
81862
81939
|
/**
|
|
81863
81940
|
* `CpCronRegistry` — the daemon's set of CP-pushed crons, keyed by `cronId`
|
|
@@ -83159,6 +83236,7 @@ var Daemon = class {
|
|
|
83159
83236
|
activeSessions: () => this.pending.size,
|
|
83160
83237
|
degradedScopes: () => this.cpDegradedScopes(),
|
|
83161
83238
|
configApply: this.cpConfigApply(),
|
|
83239
|
+
sessionRead: createSessionReader(this.store),
|
|
83162
83240
|
clock: systemClock,
|
|
83163
83241
|
connect: () => ClientTransport.dial(url),
|
|
83164
83242
|
log: this.log
|