@botbotgo/agent-harness 0.0.231 → 0.0.232
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/api.d.ts +3 -2
- package/dist/api.js +3 -0
- package/dist/contracts/runtime.d.ts +16 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/package-version.d.ts +1 -1
- package/dist/package-version.js +1 -1
- package/dist/persistence/file-store.d.ts +2 -1
- package/dist/persistence/file-store.js +19 -0
- package/dist/persistence/sqlite-store.d.ts +2 -1
- package/dist/persistence/sqlite-store.js +59 -0
- package/dist/persistence/types.d.ts +7 -0
- package/dist/runtime/harness.d.ts +4 -1
- package/dist/runtime/harness.js +33 -0
- package/package.json +1 -1
package/dist/api.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ArtifactListing, CancelOptions, InvocationEnvelope, ListMemoriesInput, ListMemoriesResult, MemoryRecord, MemorizeInput, MemorizeResult, MessageContent, RecallInput, RecallResult, RemoveMemoryInput, RequestRecord, RequestSummary, ResumeOptions, RunDecisionOptions, RunListeners, RunResult, RunStartOptions, RuntimeHealthSnapshot, RuntimeGovernanceDiagnostics, RuntimeOperatorOverview, RuntimeQueueDiagnostics, RuntimeAdapterOptions, RuntimeEvaluationExport, RuntimeEvaluationExportInput, RuntimeEvaluationReplayInput, RuntimeEvaluationReplayResult as InternalRuntimeEvaluationReplayResult, RuntimeSessionPackage, RuntimeSessionPackageInput, SessionRecord, SessionSummary, TranscriptMessage, UpdateMemoryInput, WorkspaceLoadOptions } from "./contracts/types.js";
|
|
1
|
+
import type { ArtifactListing, CancelOptions, InvocationEnvelope, ListMemoriesInput, ListMemoriesResult, MemoryRecord, MemorizeInput, MemorizeResult, MessageContent, RecallInput, RecallResult, RemoveMemoryInput, RequestRecord, RequestSummary, ResumeOptions, RunDecisionOptions, RunListeners, RunResult, RunStartOptions, RuntimeHealthSnapshot, RuntimeGovernanceDiagnostics, RuntimeOperatorOverview, RuntimeQueueDiagnostics, RuntimeAdapterOptions, RuntimeEvaluationExport, RuntimeEvaluationExportInput, RuntimeEvaluationReplayInput, RuntimeEvaluationReplayResult as InternalRuntimeEvaluationReplayResult, RuntimeSessionPackage, RuntimeSessionPackageInput, SessionListSummary, SessionRecord, SessionSummary, TranscriptMessage, UpdateMemoryInput, WorkspaceLoadOptions } from "./contracts/types.js";
|
|
2
2
|
import { AgentHarnessRuntime } from "./runtime/harness.js";
|
|
3
3
|
import type { InventoryAgentRecord, InventorySkillRecord } from "./runtime/harness/system/inventory.js";
|
|
4
4
|
import type { RequirementAssessmentOptions } from "./runtime/harness/system/skill-requirements.js";
|
|
@@ -9,7 +9,7 @@ export type { AcpApproval, AcpArtifact, AcpEventNotification, AcpJsonRpcError, A
|
|
|
9
9
|
export { AgentHarnessRuntime } from "./runtime/harness.js";
|
|
10
10
|
export { buildFlowGraph, exportFlowGraphToMermaid, exportFlowGraphToSequenceMermaid } from "./flow/index.js";
|
|
11
11
|
export { createUpstreamTimelineReducer } from "./upstream-events.js";
|
|
12
|
-
export type { ListMemoriesInput, ListMemoriesResult, MemoryDecision, MemoryKind, MemoryRecord, MemoryScope, MemorizeInput, MemorizeResult, RecallInput, RecallResult, RemoveMemoryInput, RuntimeEvaluationExport, RuntimeEvaluationExportInput, RuntimeEvaluationReplayInput, RuntimeSessionPackageInput, RuntimeSessionPackage, UpdateMemoryInput, } from "./contracts/types.js";
|
|
12
|
+
export type { ListMemoriesInput, ListMemoriesResult, MemoryDecision, MemoryKind, MemoryRecord, MemoryScope, MemorizeInput, MemorizeResult, RecallInput, RecallResult, RemoveMemoryInput, RuntimeEvaluationExport, RuntimeEvaluationExportInput, RuntimeEvaluationReplayInput, SessionListSummary, RuntimeSessionPackageInput, RuntimeSessionPackage, UpdateMemoryInput, } from "./contracts/types.js";
|
|
13
13
|
export type { AcpHttpServer, AcpHttpServerOptions } from "./protocol/acp/http.js";
|
|
14
14
|
export type { AcpStdioClient, AcpStdioClientOptions } from "./protocol/acp/client.js";
|
|
15
15
|
export type { A2aAgentCard, A2aHttpServer, A2aHttpServerOptions, A2aTask, A2aTaskState } from "./protocol/a2a/http.js";
|
|
@@ -135,6 +135,7 @@ export declare function updateMemory(runtime: AgentHarnessRuntime, input: Update
|
|
|
135
135
|
export declare function removeMemory(runtime: AgentHarnessRuntime, input: RemoveMemoryInput): Promise<MemoryRecord>;
|
|
136
136
|
export declare function subscribe(runtime: AgentHarnessRuntime, listener: (event: RequestEvent) => void | Promise<void>): () => void;
|
|
137
137
|
export declare function listSessions(runtime: AgentHarnessRuntime, filter?: Parameters<AgentHarnessRuntime["listSessions"]>[0]): Promise<SessionSummary[]>;
|
|
138
|
+
export declare function listSessionSummaries(runtime: AgentHarnessRuntime, filter?: Parameters<AgentHarnessRuntime["listSessionSummaries"]>[0]): Promise<SessionListSummary[]>;
|
|
138
139
|
export declare function listRequests(runtime: AgentHarnessRuntime, filter?: {
|
|
139
140
|
agentId?: string;
|
|
140
141
|
sessionId?: string;
|
package/dist/api.js
CHANGED
|
@@ -193,6 +193,9 @@ export function subscribe(runtime, listener) {
|
|
|
193
193
|
export async function listSessions(runtime, filter) {
|
|
194
194
|
return runtime.listSessions(filter);
|
|
195
195
|
}
|
|
196
|
+
export async function listSessionSummaries(runtime, filter) {
|
|
197
|
+
return runtime.listSessionSummaries(filter);
|
|
198
|
+
}
|
|
196
199
|
export async function listRequests(runtime, filter) {
|
|
197
200
|
return runtime.listRequests(filter);
|
|
198
201
|
}
|
|
@@ -13,6 +13,18 @@ export type SessionSummary = {
|
|
|
13
13
|
status: RunState;
|
|
14
14
|
currentAgentId?: string;
|
|
15
15
|
};
|
|
16
|
+
/**
|
|
17
|
+
* Bulk session-history projection for conversation lists and sidebars.
|
|
18
|
+
* This stays runtime-owned and intentionally lighter than full session inspection.
|
|
19
|
+
*/
|
|
20
|
+
export type SessionListSummary = SessionSummary & {
|
|
21
|
+
entryAgentId: string;
|
|
22
|
+
messageCount: number;
|
|
23
|
+
hasVisibleMessages: boolean;
|
|
24
|
+
lastMessageRole?: TranscriptMessage["role"];
|
|
25
|
+
title?: string;
|
|
26
|
+
snippet?: string;
|
|
27
|
+
};
|
|
16
28
|
/**
|
|
17
29
|
* Backward-compatible alias for older thread/run terminology.
|
|
18
30
|
*/
|
|
@@ -20,6 +32,10 @@ export type ThreadSummary = Omit<SessionSummary, "sessionId" | "latestRequestId"
|
|
|
20
32
|
threadId: string;
|
|
21
33
|
latestRunId: string;
|
|
22
34
|
};
|
|
35
|
+
export type ThreadListSummary = Omit<SessionListSummary, "sessionId" | "latestRequestId"> & {
|
|
36
|
+
threadId: string;
|
|
37
|
+
latestRunId: string;
|
|
38
|
+
};
|
|
23
39
|
export type KnownHarnessEventType = "run.created" | "run.queued" | "run.dequeued" | "run.state.changed" | "run.resumed" | "approval.requested" | "approval.resolved" | "artifact.created" | "output.delta" | "runtime.health.changed" | "runtime.synthetic_fallback";
|
|
24
40
|
export type HarnessEventType = KnownHarnessEventType | (string & {});
|
|
25
41
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { AgentHarnessAcpServer, AgentHarnessRuntime, buildFlowGraph, cancelRun, createAgentHarness, createAcpServer, createAcpStdioClient, createRuntimeMcpServer, createUpstreamTimelineReducer, createToolMcpServer, deleteSession, describeInventory, exportEvaluationBundle, exportRequestPackage, exportSessionPackage, replayEvaluationBundle, getArtifact, getAgent, getApproval, getOperatorOverview, getRequest, getHealth, listMemories, getSession, listAgentSkills, listArtifacts, listApprovals, listRequests, listRequestEvents, listSessions, memorize, normalizeUserChatInput, request, recall, removeMemory, resolveApproval, serveA2aHttp, serveAcpHttp, serveAcpStdio, serveAgUiHttp, serveRuntimeMcpOverStdio, serveToolsOverStdio, subscribe, stop, updateMemory, exportFlowGraphToMermaid, exportFlowGraphToSequenceMermaid, } from "./api.js";
|
|
1
|
+
export { AgentHarnessAcpServer, AgentHarnessRuntime, buildFlowGraph, cancelRun, createAgentHarness, createAcpServer, createAcpStdioClient, createRuntimeMcpServer, createUpstreamTimelineReducer, createToolMcpServer, deleteSession, describeInventory, exportEvaluationBundle, exportRequestPackage, exportSessionPackage, replayEvaluationBundle, getArtifact, getAgent, getApproval, getOperatorOverview, getRequest, getHealth, listMemories, getSession, listAgentSkills, listArtifacts, listApprovals, listRequests, listRequestEvents, listSessionSummaries, listSessions, memorize, normalizeUserChatInput, request, recall, removeMemory, resolveApproval, serveA2aHttp, serveAcpHttp, serveAcpStdio, serveAgUiHttp, serveRuntimeMcpOverStdio, serveToolsOverStdio, subscribe, stop, updateMemory, exportFlowGraphToMermaid, exportFlowGraphToSequenceMermaid, } from "./api.js";
|
|
2
2
|
export type { AcpApproval, AcpArtifact, AcpEventNotification, AcpJsonRpcError, AcpJsonRpcRequest, AcpJsonRpcResponse, AcpJsonRpcSuccess, AcpRequestRecord, AcpRunRequestParams, AcpServerCapabilities, AcpSessionRecord, AcpStdioClient, AcpStdioClientOptions, } from "./acp.js";
|
|
3
|
-
export type { Approval, ListMemoriesInput, ListMemoriesResult, MemoryDecision, MemoryKind, MemoryRecord, MemoryScope, MemorizeInput, MemorizeResult, NormalizeUserChatInputOptions, OperatorOverview, PublicRunListeners, RequestArtifactListing, RequestEvent, RequestEventType, RequestPackage, RequestPackageInput, RequestResult, RequestUpstreamEventItem, RecallInput, RecallResult, RemoveMemoryInput, RuntimeEvaluationExport, RuntimeEvaluationExportInput, RuntimeEvaluationReplayInput, RuntimeEvaluationReplayResult, RuntimeSessionPackage, RuntimeSessionPackageInput, UpdateMemoryInput, UserChatInput, UserChatMessage, } from "./api.js";
|
|
3
|
+
export type { Approval, ListMemoriesInput, ListMemoriesResult, MemoryDecision, MemoryKind, MemoryRecord, MemoryScope, MemorizeInput, MemorizeResult, NormalizeUserChatInputOptions, OperatorOverview, PublicRunListeners, RequestArtifactListing, RequestEvent, RequestEventType, RequestPackage, RequestPackageInput, RequestResult, RequestUpstreamEventItem, RecallInput, RecallResult, RemoveMemoryInput, RuntimeEvaluationExport, RuntimeEvaluationExportInput, RuntimeEvaluationReplayInput, RuntimeEvaluationReplayResult, SessionListSummary, RuntimeSessionPackage, RuntimeSessionPackageInput, UpdateMemoryInput, UserChatInput, UserChatMessage, } from "./api.js";
|
|
4
4
|
export type { BuildFlowGraphInput, FlowEdge, FlowEdgeKind, FlowGraph, FlowGraphMermaidOptions, FlowGraphSequenceMermaidOptions, FlowGroup, FlowGroupKind, FlowNode, FlowNodeKind, FlowNodeLayer, FlowNodeStatus, } from "./flow/index.js";
|
|
5
5
|
export type { A2aAgentCard, A2aHttpServer, A2aHttpServerOptions, A2aTask, A2aTaskState, AcpHttpServer, AcpHttpServerOptions, AcpStdioServer, AcpStdioServerOptions, AgUiEvent, AgUiHttpServer, AgUiHttpServerOptions, AgUiRunAgentInput, } from "./api.js";
|
|
6
6
|
export type { RuntimeMcpServerOptions, ToolMcpServerOptions } from "./mcp.js";
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { AgentHarnessAcpServer, AgentHarnessRuntime, buildFlowGraph, cancelRun, createAgentHarness, createAcpServer, createAcpStdioClient, createRuntimeMcpServer, createUpstreamTimelineReducer, createToolMcpServer, deleteSession, describeInventory, exportEvaluationBundle, exportRequestPackage, exportSessionPackage, replayEvaluationBundle, getArtifact, getAgent, getApproval, getOperatorOverview, getRequest, getHealth, listMemories, getSession, listAgentSkills, listArtifacts, listApprovals, listRequests, listRequestEvents, listSessions, memorize, normalizeUserChatInput, request, recall, removeMemory, resolveApproval, serveA2aHttp, serveAcpHttp, serveAcpStdio, serveAgUiHttp, serveRuntimeMcpOverStdio, serveToolsOverStdio, subscribe, stop, updateMemory, exportFlowGraphToMermaid, exportFlowGraphToSequenceMermaid, } from "./api.js";
|
|
1
|
+
export { AgentHarnessAcpServer, AgentHarnessRuntime, buildFlowGraph, cancelRun, createAgentHarness, createAcpServer, createAcpStdioClient, createRuntimeMcpServer, createUpstreamTimelineReducer, createToolMcpServer, deleteSession, describeInventory, exportEvaluationBundle, exportRequestPackage, exportSessionPackage, replayEvaluationBundle, getArtifact, getAgent, getApproval, getOperatorOverview, getRequest, getHealth, listMemories, getSession, listAgentSkills, listArtifacts, listApprovals, listRequests, listRequestEvents, listSessionSummaries, listSessions, memorize, normalizeUserChatInput, request, recall, removeMemory, resolveApproval, serveA2aHttp, serveAcpHttp, serveAcpStdio, serveAgUiHttp, serveRuntimeMcpOverStdio, serveToolsOverStdio, subscribe, stop, updateMemory, exportFlowGraphToMermaid, exportFlowGraphToSequenceMermaid, } from "./api.js";
|
|
2
2
|
export { tool } from "./tools.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const AGENT_HARNESS_VERSION = "0.0.
|
|
1
|
+
export declare const AGENT_HARNESS_VERSION = "0.0.231";
|
package/dist/package-version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const AGENT_HARNESS_VERSION = "0.0.
|
|
1
|
+
export const AGENT_HARNESS_VERSION = "0.0.231";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ArtifactListing, ArtifactRecord, HarnessEvent, InternalApprovalRecord, RunSummary, RunState, ThreadSummary, ThreadRunRecord, TranscriptMessage } from "../contracts/types.js";
|
|
2
|
-
import type { ApprovalFilter, PersistedRunRequest, PersistedRunControlRecord, PersistedRunInspection, PersistedRunQueueRecord, PersistenceLifecycle as Lifecycle, RuntimePersistence, RecoveryIntent, PersistenceRunMeta as RunMeta, RunSummaryFilter, ThreadSummaryFilter, PersistenceThreadMeta as ThreadMeta } from "./types.js";
|
|
2
|
+
import type { ApprovalFilter, PersistedSessionListSummary, PersistedRunRequest, PersistedRunControlRecord, PersistedRunInspection, PersistedRunQueueRecord, PersistenceLifecycle as Lifecycle, RuntimePersistence, RecoveryIntent, PersistenceRunMeta as RunMeta, RunSummaryFilter, ThreadSummaryFilter, PersistenceThreadMeta as ThreadMeta } from "./types.js";
|
|
3
3
|
type RunIndexRecord = {
|
|
4
4
|
runId: string;
|
|
5
5
|
threadId: string;
|
|
@@ -40,6 +40,7 @@ export declare class FilePersistence implements RuntimePersistence {
|
|
|
40
40
|
setRunState(threadId: string, runId: string, state: RunState, checkpointRef?: string | null): Promise<void>;
|
|
41
41
|
appendEvent(event: HarnessEvent): Promise<void>;
|
|
42
42
|
listSessions(filter?: ThreadSummaryFilter): Promise<ThreadSummary[]>;
|
|
43
|
+
listSessionSummaries(filter?: ThreadSummaryFilter): Promise<PersistedSessionListSummary[]>;
|
|
43
44
|
listRunIndexes(): Promise<RunIndexRecord[]>;
|
|
44
45
|
private readRunSummary;
|
|
45
46
|
listRuns(filter?: RunSummaryFilter): Promise<RunSummary[]>;
|
|
@@ -228,6 +228,25 @@ export class FilePersistence {
|
|
|
228
228
|
.filter((record) => !filter.agentId || record.agentId === filter.agentId)
|
|
229
229
|
.sort((a, b) => b.updatedAt.localeCompare(a.updatedAt));
|
|
230
230
|
}
|
|
231
|
+
async listSessionSummaries(filter = {}) {
|
|
232
|
+
const sessions = await this.listSessions(filter);
|
|
233
|
+
const summaries = await Promise.all(sessions.map(async (session) => {
|
|
234
|
+
const [meta, messageBundle] = await Promise.all([
|
|
235
|
+
readJson(path.join(this.threadDir(session.threadId), "meta.json")),
|
|
236
|
+
readJson(path.join(this.threadDir(session.threadId), "messages.json"))
|
|
237
|
+
.catch(() => ({ threadId: session.threadId, items: [] })),
|
|
238
|
+
]);
|
|
239
|
+
const items = messageBundle.items;
|
|
240
|
+
return {
|
|
241
|
+
...session,
|
|
242
|
+
entryAgentId: meta.entryAgentId,
|
|
243
|
+
messageCount: items.length,
|
|
244
|
+
firstMessage: items[0],
|
|
245
|
+
lastMessage: items.at(-1),
|
|
246
|
+
};
|
|
247
|
+
}));
|
|
248
|
+
return summaries.sort((a, b) => b.updatedAt.localeCompare(a.updatedAt));
|
|
249
|
+
}
|
|
231
250
|
async listRunIndexes() {
|
|
232
251
|
const runIndexDir = path.join(this.runRoot, "indexes", "runs");
|
|
233
252
|
if (!(await fileExists(runIndexDir))) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ArtifactListing, ArtifactRecord, HarnessEvent, InternalApprovalRecord, RunState, RunSummary, ThreadRunRecord, ThreadSummary, TranscriptMessage } from "../contracts/types.js";
|
|
2
|
-
import type { PersistedRunRequest, PersistedRunControlRecord, PersistedRunInspection, PersistedRunQueueRecord, PersistenceLifecycle, PersistenceRunMeta, PersistenceThreadMeta, RecoveryIntent, RuntimePersistence, ApprovalFilter, RunSummaryFilter, ThreadSummaryFilter } from "./types.js";
|
|
2
|
+
import type { PersistedSessionListSummary, PersistedRunRequest, PersistedRunControlRecord, PersistedRunInspection, PersistedRunQueueRecord, PersistenceLifecycle, PersistenceRunMeta, PersistenceThreadMeta, RecoveryIntent, RuntimePersistence, ApprovalFilter, RunSummaryFilter, ThreadSummaryFilter } from "./types.js";
|
|
3
3
|
export declare function listProtectedCheckpointThreadIds(dbPath: string): Promise<Set<string>>;
|
|
4
4
|
export declare class SqlitePersistence implements RuntimePersistence {
|
|
5
5
|
private readonly runRoot;
|
|
@@ -63,6 +63,7 @@ export declare class SqlitePersistence implements RuntimePersistence {
|
|
|
63
63
|
setRunState(threadId: string, runId: string, state: RunState, checkpointRef?: string | null): Promise<void>;
|
|
64
64
|
appendEvent(event: HarnessEvent): Promise<void>;
|
|
65
65
|
listSessions(filter?: ThreadSummaryFilter): Promise<ThreadSummary[]>;
|
|
66
|
+
listSessionSummaries(filter?: ThreadSummaryFilter): Promise<PersistedSessionListSummary[]>;
|
|
66
67
|
listRuns(filter?: RunSummaryFilter): Promise<RunSummary[]>;
|
|
67
68
|
getRun(runId: string): Promise<RunSummary | null>;
|
|
68
69
|
getSession(threadId: string): Promise<ThreadSummary | null>;
|
|
@@ -633,6 +633,65 @@ export class SqlitePersistence {
|
|
|
633
633
|
ORDER BY updated_at DESC`, args);
|
|
634
634
|
return rows.map((row) => this.mapThreadSummary(row));
|
|
635
635
|
}
|
|
636
|
+
async listSessionSummaries(filter = {}) {
|
|
637
|
+
const { clause, args } = buildWhereClause([
|
|
638
|
+
["threads.entry_agent_id = ?", filter.agentId],
|
|
639
|
+
]);
|
|
640
|
+
const rows = await this.selectAll(`SELECT threads.thread_id, threads.entry_agent_id, threads.latest_run_id, threads.created_at, threads.updated_at, threads.status, run_inspection.current_agent_id,
|
|
641
|
+
COALESCE(message_counts.message_count, 0) AS message_count,
|
|
642
|
+
first_message.role AS first_message_role,
|
|
643
|
+
first_message.content_json AS first_message_content_json,
|
|
644
|
+
first_message.run_id AS first_message_run_id,
|
|
645
|
+
first_message.created_at AS first_message_created_at,
|
|
646
|
+
last_message.role AS last_message_role,
|
|
647
|
+
last_message.content_json AS last_message_content_json,
|
|
648
|
+
last_message.run_id AS last_message_run_id,
|
|
649
|
+
last_message.created_at AS last_message_created_at
|
|
650
|
+
FROM threads
|
|
651
|
+
LEFT JOIN run_inspection ON run_inspection.run_id = threads.latest_run_id
|
|
652
|
+
LEFT JOIN (
|
|
653
|
+
SELECT thread_id, COUNT(*) AS message_count
|
|
654
|
+
FROM thread_messages
|
|
655
|
+
GROUP BY thread_id
|
|
656
|
+
) message_counts ON message_counts.thread_id = threads.thread_id
|
|
657
|
+
LEFT JOIN thread_messages AS first_message ON first_message.id = (
|
|
658
|
+
SELECT message.id
|
|
659
|
+
FROM thread_messages AS message
|
|
660
|
+
WHERE message.thread_id = threads.thread_id
|
|
661
|
+
ORDER BY message.created_at ASC, message.id ASC
|
|
662
|
+
LIMIT 1
|
|
663
|
+
)
|
|
664
|
+
LEFT JOIN thread_messages AS last_message ON last_message.id = (
|
|
665
|
+
SELECT message.id
|
|
666
|
+
FROM thread_messages AS message
|
|
667
|
+
WHERE message.thread_id = threads.thread_id
|
|
668
|
+
ORDER BY message.created_at DESC, message.id DESC
|
|
669
|
+
LIMIT 1
|
|
670
|
+
)
|
|
671
|
+
${clause}
|
|
672
|
+
ORDER BY threads.updated_at DESC`, args);
|
|
673
|
+
return rows.map((row) => ({
|
|
674
|
+
...this.mapThreadSummary(row),
|
|
675
|
+
entryAgentId: asString(row.entry_agent_id),
|
|
676
|
+
messageCount: Number(row.message_count ?? 0),
|
|
677
|
+
firstMessage: row.first_message_role
|
|
678
|
+
? {
|
|
679
|
+
role: asString(row.first_message_role),
|
|
680
|
+
content: parseJson(row.first_message_content_json),
|
|
681
|
+
runId: asString(row.first_message_run_id),
|
|
682
|
+
createdAt: asString(row.first_message_created_at),
|
|
683
|
+
}
|
|
684
|
+
: undefined,
|
|
685
|
+
lastMessage: row.last_message_role
|
|
686
|
+
? {
|
|
687
|
+
role: asString(row.last_message_role),
|
|
688
|
+
content: parseJson(row.last_message_content_json),
|
|
689
|
+
runId: asString(row.last_message_run_id),
|
|
690
|
+
createdAt: asString(row.last_message_created_at),
|
|
691
|
+
}
|
|
692
|
+
: undefined,
|
|
693
|
+
}));
|
|
694
|
+
}
|
|
636
695
|
async listRuns(filter = {}) {
|
|
637
696
|
const { clause, args } = buildWhereClause([
|
|
638
697
|
["runs.agent_id = ?", filter.agentId],
|
|
@@ -82,6 +82,12 @@ export type ApprovalFilter = {
|
|
|
82
82
|
threadId?: string;
|
|
83
83
|
runId?: string;
|
|
84
84
|
};
|
|
85
|
+
export type PersistedSessionListSummary = ThreadSummary & {
|
|
86
|
+
entryAgentId: string;
|
|
87
|
+
messageCount: number;
|
|
88
|
+
firstMessage?: TranscriptMessage;
|
|
89
|
+
lastMessage?: TranscriptMessage;
|
|
90
|
+
};
|
|
85
91
|
export interface RuntimePersistence {
|
|
86
92
|
initialize(): Promise<void>;
|
|
87
93
|
bootstrapRun?(input: {
|
|
@@ -123,6 +129,7 @@ export interface RuntimePersistence {
|
|
|
123
129
|
appendEvent(event: HarnessEvent): Promise<void>;
|
|
124
130
|
listRunEvents(threadId: string, runId: string): Promise<HarnessEvent[]>;
|
|
125
131
|
listSessions(filter?: ThreadSummaryFilter): Promise<ThreadSummary[]>;
|
|
132
|
+
listSessionSummaries(filter?: ThreadSummaryFilter): Promise<PersistedSessionListSummary[]>;
|
|
126
133
|
listRuns(filter?: RunSummaryFilter): Promise<RunSummary[]>;
|
|
127
134
|
getRun(runId: string): Promise<RunSummary | null>;
|
|
128
135
|
getSession(threadId: string): Promise<ThreadSummary | null>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ApprovalRecord, ArtifactListing, CancelOptions, HarnessEvent, HarnessStreamItem, RuntimeHealthSnapshot, RuntimeOperatorOverview, ListMemoriesInput, ListMemoriesResult, MessageContent, RemoveMemoryInput, RunRecord, RunStartOptions, RestartConversationOptions, RuntimeAdapterOptions, RuntimeEvaluationExport, RuntimeEvaluationExportInput, RuntimeEvaluationReplayInput, RuntimeEvaluationReplayResult, RuntimeRunPackage, RuntimeRunPackageInput, RuntimeSessionPackage, RuntimeSessionPackageInput, ResumeOptions, RunOptions, RunResult, RunSummary, MemoryRecord, MemorizeInput, MemorizeResult, RecallInput, RecallResult, UpdateMemoryInput, SessionSummary, ThreadSummary, ThreadRecord, SessionRecord, RequestRecord, RequestSummary, WorkspaceBundle } from "../contracts/types.js";
|
|
1
|
+
import type { ApprovalRecord, ArtifactListing, CancelOptions, HarnessEvent, HarnessStreamItem, RuntimeHealthSnapshot, RuntimeOperatorOverview, ListMemoriesInput, ListMemoriesResult, MessageContent, RemoveMemoryInput, RunRecord, RunStartOptions, RestartConversationOptions, RuntimeAdapterOptions, RuntimeEvaluationExport, RuntimeEvaluationExportInput, RuntimeEvaluationReplayInput, RuntimeEvaluationReplayResult, RuntimeRunPackage, RuntimeRunPackageInput, RuntimeSessionPackage, RuntimeSessionPackageInput, ResumeOptions, RunOptions, RunResult, RunSummary, MemoryRecord, MemorizeInput, MemorizeResult, RecallInput, RecallResult, UpdateMemoryInput, SessionSummary, ThreadSummary, ThreadRecord, SessionRecord, RequestRecord, RequestSummary, SessionListSummary, WorkspaceBundle } from "../contracts/types.js";
|
|
2
2
|
import { type RuntimeMcpServerOptions, type ToolMcpServerOptions } from "../mcp.js";
|
|
3
3
|
import { type InventoryAgentRecord, type InventorySkillRecord } from "./harness/system/inventory.js";
|
|
4
4
|
import type { RequirementAssessmentOptions } from "./harness/system/skill-requirements.js";
|
|
@@ -66,6 +66,9 @@ export declare class AgentHarnessRuntime {
|
|
|
66
66
|
listSessions(filter?: {
|
|
67
67
|
agentId?: string;
|
|
68
68
|
}): Promise<SessionSummary[]>;
|
|
69
|
+
listSessionSummaries(filter?: {
|
|
70
|
+
agentId?: string;
|
|
71
|
+
}): Promise<SessionListSummary[]>;
|
|
69
72
|
listThreads(filter?: {
|
|
70
73
|
agentId?: string;
|
|
71
74
|
}): Promise<ThreadSummary[]>;
|
package/dist/runtime/harness.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { SqlitePersistence } from "../persistence/sqlite-store.js";
|
|
3
3
|
import { createPersistentId } from "../utils/id.js";
|
|
4
|
+
import { extractMessageText } from "../utils/message-content.js";
|
|
4
5
|
import { AgentRuntimeAdapter } from "./agent-runtime-adapter.js";
|
|
5
6
|
import { EventBus } from "./harness/events/event-bus.js";
|
|
6
7
|
import { createBackgroundEventRuntime } from "./harness/background-runtime.js";
|
|
@@ -40,6 +41,34 @@ import { initializeHarnessRuntime, reclaimExpiredClaimedRuns as reclaimHarnessEx
|
|
|
40
41
|
import { streamHarnessRun } from "./harness/run/stream-run.js";
|
|
41
42
|
import { defaultRequestedAgentId, prepareRunStart } from "./harness/run/start-run.js";
|
|
42
43
|
import { buildRequestInspectionRecord, buildSessionInspectionRecord, deleteSessionRecord, deleteThreadRecord, getPublicApproval, listPublicApprovals, } from "./harness/run/thread-records.js";
|
|
44
|
+
function normalizeSessionListText(content, limit) {
|
|
45
|
+
if (!content) {
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
const collapsed = extractMessageText(content).replace(/\s+/g, " ").trim();
|
|
49
|
+
if (!collapsed) {
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
return collapsed.length > limit ? `${collapsed.slice(0, limit - 1).trimEnd()}…` : collapsed;
|
|
53
|
+
}
|
|
54
|
+
function toSessionListSummary(session) {
|
|
55
|
+
const titleSource = session.firstMessage?.role === "user" ? session.firstMessage : session.lastMessage;
|
|
56
|
+
return {
|
|
57
|
+
agentId: session.agentId,
|
|
58
|
+
entryAgentId: session.entryAgentId,
|
|
59
|
+
sessionId: session.threadId,
|
|
60
|
+
latestRequestId: session.latestRunId,
|
|
61
|
+
createdAt: session.createdAt,
|
|
62
|
+
updatedAt: session.updatedAt,
|
|
63
|
+
status: session.status,
|
|
64
|
+
currentAgentId: session.currentAgentId,
|
|
65
|
+
messageCount: session.messageCount,
|
|
66
|
+
hasVisibleMessages: session.messageCount > 0,
|
|
67
|
+
lastMessageRole: session.lastMessage?.role,
|
|
68
|
+
title: normalizeSessionListText(titleSource?.content, 72),
|
|
69
|
+
snippet: normalizeSessionListText(session.lastMessage?.content, 160),
|
|
70
|
+
};
|
|
71
|
+
}
|
|
43
72
|
export class AgentHarnessRuntime {
|
|
44
73
|
workspace;
|
|
45
74
|
runtimeAdapterOptions;
|
|
@@ -312,6 +341,10 @@ export class AgentHarnessRuntime {
|
|
|
312
341
|
currentAgentId: session.currentAgentId,
|
|
313
342
|
}));
|
|
314
343
|
}
|
|
344
|
+
async listSessionSummaries(filter) {
|
|
345
|
+
const sessions = await this.persistence.listSessionSummaries(filter);
|
|
346
|
+
return sessions.map((session) => toSessionListSummary(session));
|
|
347
|
+
}
|
|
315
348
|
async listThreads(filter) {
|
|
316
349
|
const sessions = await this.listSessions(filter);
|
|
317
350
|
return sessions.map((session) => ({
|