@botbotgo/agent-harness 0.0.231 → 0.0.233
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 +2 -2
- package/README.zh.md +2 -2
- package/dist/api.d.ts +5 -2
- package/dist/api.js +5 -0
- package/dist/cli.js +136 -2
- package/dist/contracts/runtime.d.ts +41 -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 +79 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1028,9 +1028,9 @@ ACP transport notes:
|
|
|
1028
1028
|
- `serveAgUiHttp(runtime)` exposes an AG-UI-compatible HTTP SSE bridge that projects runtime lifecycle, text output, upstream thinking, step progress, and tool calls onto `RUN_*`, `TEXT_MESSAGE_*`, `THINKING_TEXT_MESSAGE_*`, `STEP_*`, and `TOOL_CALL_*` events for UI clients.
|
|
1029
1029
|
- `createRuntimeMcpServer(runtime)` and `serveRuntimeMcpOverStdio(runtime)` expose the persisted runtime control surface itself as MCP tools, including sessions, requests, approvals, artifacts, events, and package export helpers.
|
|
1030
1030
|
- `listRequestEvents(...)` and `exportRequestPackage(...)` are the request-first inspection helpers.
|
|
1031
|
-
- `exportRequestPackage(...)` and `exportSessionPackage(...)` package stable runtime records, transcript, approvals, events, and
|
|
1031
|
+
- `exportRequestPackage(...)` and `exportSessionPackage(...)` package stable runtime records, transcript, approvals, events, artifacts, and governance evidence for operator tooling without reaching into persistence internals.
|
|
1032
1032
|
- `runtime/default.governance.remoteMcp` can now deny or allow specific MCP servers, raise approval requirements by transport, and stamp transport-based risk tiers into runtime governance bundles. MCP server catalogs can also declare trust tier, access mode, tenant scope, approval policy, prompt-injection risk, and OAuth scope metadata so governance bundles capture why one remote tool is treated as high-risk.
|
|
1033
1033
|
- Protocol responsibilities stay split on purpose: ACP is the primary editor/client runtime boundary, A2A is the streaming-capable agent-platform bridge with polling compatibility, AG-UI is the UI event surface, and runtime MCP is the operator-facing control plane exported as MCP tools.
|
|
1034
1034
|
- `runtime/default.observability.tracing` can now describe exporter metadata such as OTLP endpoints and propagation mode, so frozen runtime snapshots keep trace-correlation plus operator-visible export context without exposing backend-private span internals.
|
|
1035
|
-
- `agent-harness runtime overview`, `agent-harness runtime health`, `agent-harness runtime approvals list|watch`,
|
|
1035
|
+
- `agent-harness runtime overview`, `agent-harness runtime health`, `agent-harness runtime approvals list|watch`, `agent-harness runtime runs list|tail`, and `agent-harness runtime export request|session` provide a thin operator CLI over persisted runtime health, queue pressure, governance risk, approval queues, active run state, and audit-ready evidence packages.
|
|
1036
1036
|
- detailed A2A adapter guidance lives in [`docs/a2a-bridge.md`](docs/a2a-bridge.md)
|
package/README.zh.md
CHANGED
|
@@ -986,9 +986,9 @@ ACP transport 说明:
|
|
|
986
986
|
- `serveAgUiHttp(runtime)` 提供 AG-UI HTTP SSE bridge,把 runtime 生命周期、文本输出、upstream thinking、step 进度与 tool call 投影成 `RUN_*`、`TEXT_MESSAGE_*`、`THINKING_TEXT_MESSAGE_*`、`STEP_*` 与 `TOOL_CALL_*` 事件,便于 UI 客户端直接接入。
|
|
987
987
|
- `createRuntimeMcpServer(runtime)` 与 `serveRuntimeMcpOverStdio(runtime)` 会把持久化 runtime 控制面本身暴露成 MCP tools,包括 sessions、requests、approvals、artifacts、events 与 package export helpers。
|
|
988
988
|
- `listRequestEvents(...)` 与 `exportRequestPackage(...)` 是 request-first 的检查 helper。
|
|
989
|
-
- `exportRequestPackage(...)` 与 `exportSessionPackage(...)` 可把稳定 runtime 记录、transcript、approvals、events
|
|
989
|
+
- `exportRequestPackage(...)` 与 `exportSessionPackage(...)` 可把稳定 runtime 记录、transcript、approvals、events、artifacts 与 governance evidence 一起打包给管理工具,而不必直接访问 persistence 内部实现。
|
|
990
990
|
- `runtime/default.governance.remoteMcp` 现在可以按 MCP server 或 transport 做 allow/deny、审批升级,并把 transport 风险等级写进 runtime governance bundles。MCP server catalog 也可以声明 trust tier、access mode、tenant scope、approval policy、prompt-injection risk 与 OAuth scope 元数据,让治理快照能解释为什么某个远端工具被视为高风险。
|
|
991
991
|
- 协议分工要继续保持清晰:ACP 是 editor / client 的主运行时边界,A2A 是支持 streaming 且兼容轮询的 agent-platform bridge,AG-UI 是 UI 事件面,runtime MCP 是以 MCP tools 暴露的 operator control plane。
|
|
992
992
|
- `runtime/default.observability.tracing` 现在可描述 OTLP endpoint 和 propagation mode 这类 exporter 元数据,使冻结的 runtime snapshot 在保留 trace correlation 的同时,也能保留有用的导出上下文,而不暴露 backend 私有 span 细节。
|
|
993
|
-
- `agent-harness runtime overview`、`agent-harness runtime health`、`agent-harness runtime approvals list|watch` 与 `agent-harness runtime
|
|
993
|
+
- `agent-harness runtime overview`、`agent-harness runtime health`、`agent-harness runtime approvals list|watch`、`agent-harness runtime runs list|tail` 与 `agent-harness runtime export request|session` 提供了一层轻量 CLI,可直接查看 runtime health、queue pressure、governance risk、审批队列、运行状态与可审计证据包。
|
|
994
994
|
- 更详细的 A2A 适配层开发说明见 [`docs/a2a-bridge.md`](docs/a2a-bridge.md)
|
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, RuntimeGovernanceEvidence, 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";
|
|
@@ -45,6 +45,7 @@ export type Approval = {
|
|
|
45
45
|
sessionId: string;
|
|
46
46
|
requestId: string;
|
|
47
47
|
toolName: string;
|
|
48
|
+
approvalReason?: string;
|
|
48
49
|
status: "pending" | "approved" | "edited" | "rejected" | "expired";
|
|
49
50
|
requestedAt: string;
|
|
50
51
|
resolvedAt: string | null;
|
|
@@ -69,6 +70,7 @@ export type RequestPackage = {
|
|
|
69
70
|
transcript: TranscriptMessage[];
|
|
70
71
|
events: RequestEvent[];
|
|
71
72
|
artifacts: RequestArtifactListing["items"];
|
|
73
|
+
governance: RuntimeGovernanceEvidence;
|
|
72
74
|
runtimeHealth?: RuntimeHealthSnapshot;
|
|
73
75
|
};
|
|
74
76
|
export type RuntimeEvaluationReplayResult = Omit<InternalRuntimeEvaluationReplayResult, "result"> & {
|
|
@@ -135,6 +137,7 @@ export declare function updateMemory(runtime: AgentHarnessRuntime, input: Update
|
|
|
135
137
|
export declare function removeMemory(runtime: AgentHarnessRuntime, input: RemoveMemoryInput): Promise<MemoryRecord>;
|
|
136
138
|
export declare function subscribe(runtime: AgentHarnessRuntime, listener: (event: RequestEvent) => void | Promise<void>): () => void;
|
|
137
139
|
export declare function listSessions(runtime: AgentHarnessRuntime, filter?: Parameters<AgentHarnessRuntime["listSessions"]>[0]): Promise<SessionSummary[]>;
|
|
140
|
+
export declare function listSessionSummaries(runtime: AgentHarnessRuntime, filter?: Parameters<AgentHarnessRuntime["listSessionSummaries"]>[0]): Promise<SessionListSummary[]>;
|
|
138
141
|
export declare function listRequests(runtime: AgentHarnessRuntime, filter?: {
|
|
139
142
|
agentId?: string;
|
|
140
143
|
sessionId?: string;
|
package/dist/api.js
CHANGED
|
@@ -17,6 +17,7 @@ function toApprovalRecord(record) {
|
|
|
17
17
|
sessionId: record.threadId,
|
|
18
18
|
requestId: record.runId,
|
|
19
19
|
toolName: record.toolName,
|
|
20
|
+
...(record.approvalReason ? { approvalReason: record.approvalReason } : {}),
|
|
20
21
|
status: record.status,
|
|
21
22
|
requestedAt: record.requestedAt,
|
|
22
23
|
resolvedAt: record.resolvedAt,
|
|
@@ -84,6 +85,7 @@ function toRequestPackage(pkg) {
|
|
|
84
85
|
transcript: pkg.transcript,
|
|
85
86
|
events: pkg.events.map(toPublicEvent),
|
|
86
87
|
artifacts: pkg.artifacts,
|
|
88
|
+
governance: pkg.governance,
|
|
87
89
|
...(pkg.runtimeHealth ? { runtimeHealth: pkg.runtimeHealth } : {}),
|
|
88
90
|
};
|
|
89
91
|
}
|
|
@@ -193,6 +195,9 @@ export function subscribe(runtime, listener) {
|
|
|
193
195
|
export async function listSessions(runtime, filter) {
|
|
194
196
|
return runtime.listSessions(filter);
|
|
195
197
|
}
|
|
198
|
+
export async function listSessionSummaries(runtime, filter) {
|
|
199
|
+
return runtime.listSessionSummaries(filter);
|
|
200
|
+
}
|
|
196
201
|
export async function listRequests(runtime, filter) {
|
|
197
202
|
return runtime.listRequests(filter);
|
|
198
203
|
}
|
package/dist/cli.js
CHANGED
|
@@ -20,6 +20,8 @@ function renderUsage() {
|
|
|
20
20
|
agent-harness runtime approvals watch [--workspace <path>] [--status <pending|approved|edited|rejected|expired>] [--poll-ms <ms>] [--once] [--json]
|
|
21
21
|
agent-harness runtime runs list [--workspace <path>] [--agent <agentId>] [--thread <threadId>] [--state <state>] [--json]
|
|
22
22
|
agent-harness runtime runs tail [--workspace <path>] [--agent <agentId>] [--thread <threadId>] [--state <state>] [--poll-ms <ms>] [--once] [--json]
|
|
23
|
+
agent-harness runtime export request --workspace <path> --session <sessionId> --request <requestId> [--artifacts] [--artifact-contents] [--health] [--json]
|
|
24
|
+
agent-harness runtime export session --workspace <path> --session <sessionId> [--artifacts] [--artifact-contents] [--health] [--json]
|
|
23
25
|
agent-harness runtime-mcp serve [--workspace <path>]
|
|
24
26
|
`;
|
|
25
27
|
}
|
|
@@ -218,6 +220,80 @@ function parseRuntimeInspectOptions(args) {
|
|
|
218
220
|
}
|
|
219
221
|
return { workspaceRoot, json, once, pollMs, limit, status, state, agentId, threadId };
|
|
220
222
|
}
|
|
223
|
+
function parseRuntimeExportOptions(args) {
|
|
224
|
+
let workspaceRoot;
|
|
225
|
+
let sessionId;
|
|
226
|
+
let requestId;
|
|
227
|
+
let includeArtifacts = false;
|
|
228
|
+
let includeArtifactContents = false;
|
|
229
|
+
let includeRuntimeHealth = false;
|
|
230
|
+
let json = false;
|
|
231
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
232
|
+
const arg = args[index];
|
|
233
|
+
if (arg === "--artifacts") {
|
|
234
|
+
includeArtifacts = true;
|
|
235
|
+
continue;
|
|
236
|
+
}
|
|
237
|
+
if (arg === "--artifact-contents") {
|
|
238
|
+
includeArtifacts = true;
|
|
239
|
+
includeArtifactContents = true;
|
|
240
|
+
continue;
|
|
241
|
+
}
|
|
242
|
+
if (arg === "--health") {
|
|
243
|
+
includeRuntimeHealth = true;
|
|
244
|
+
continue;
|
|
245
|
+
}
|
|
246
|
+
if (arg === "--json") {
|
|
247
|
+
json = true;
|
|
248
|
+
continue;
|
|
249
|
+
}
|
|
250
|
+
if (arg === "--workspace" || arg === "--session" || arg === "--request") {
|
|
251
|
+
const value = args[index + 1];
|
|
252
|
+
if (!value) {
|
|
253
|
+
return {
|
|
254
|
+
workspaceRoot,
|
|
255
|
+
sessionId,
|
|
256
|
+
requestId,
|
|
257
|
+
includeArtifacts,
|
|
258
|
+
includeArtifactContents,
|
|
259
|
+
includeRuntimeHealth,
|
|
260
|
+
json,
|
|
261
|
+
error: `Missing value for ${arg}`,
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
if (arg === "--workspace") {
|
|
265
|
+
workspaceRoot = value;
|
|
266
|
+
}
|
|
267
|
+
else if (arg === "--session") {
|
|
268
|
+
sessionId = value;
|
|
269
|
+
}
|
|
270
|
+
else {
|
|
271
|
+
requestId = value;
|
|
272
|
+
}
|
|
273
|
+
index += 1;
|
|
274
|
+
continue;
|
|
275
|
+
}
|
|
276
|
+
return {
|
|
277
|
+
workspaceRoot,
|
|
278
|
+
sessionId,
|
|
279
|
+
requestId,
|
|
280
|
+
includeArtifacts,
|
|
281
|
+
includeArtifactContents,
|
|
282
|
+
includeRuntimeHealth,
|
|
283
|
+
json,
|
|
284
|
+
error: `Unknown option: ${arg}`,
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
return {
|
|
288
|
+
workspaceRoot,
|
|
289
|
+
sessionId,
|
|
290
|
+
requestId,
|
|
291
|
+
includeArtifacts,
|
|
292
|
+
includeArtifactContents,
|
|
293
|
+
includeRuntimeHealth,
|
|
294
|
+
json,
|
|
295
|
+
};
|
|
296
|
+
}
|
|
221
297
|
function renderJson(value) {
|
|
222
298
|
return `${JSON.stringify(value, null, 2)}\n`;
|
|
223
299
|
}
|
|
@@ -517,15 +593,73 @@ export async function runCli(argv, io = {}, deps = {}) {
|
|
|
517
593
|
}
|
|
518
594
|
}
|
|
519
595
|
if (command === "runtime") {
|
|
520
|
-
const [subcommand, possibleNestedCommand, ...remainingArgs] = [projectName, ...rest];
|
|
596
|
+
const [subcommand, possibleNestedCommand, possibleThirdCommand, ...remainingArgs] = [projectName, ...rest];
|
|
521
597
|
if (!subcommand) {
|
|
522
598
|
stderr(renderUsage());
|
|
523
599
|
return 1;
|
|
524
600
|
}
|
|
601
|
+
if (subcommand === "export") {
|
|
602
|
+
const exportTarget = possibleNestedCommand;
|
|
603
|
+
const parsed = parseRuntimeExportOptions([possibleThirdCommand, ...remainingArgs].filter((item) => typeof item === "string"));
|
|
604
|
+
if (parsed.error) {
|
|
605
|
+
stderr(`${parsed.error}\n`);
|
|
606
|
+
stderr(renderUsage());
|
|
607
|
+
return 1;
|
|
608
|
+
}
|
|
609
|
+
if (!parsed.sessionId) {
|
|
610
|
+
stderr("Missing value for --session\n");
|
|
611
|
+
stderr(renderUsage());
|
|
612
|
+
return 1;
|
|
613
|
+
}
|
|
614
|
+
if (exportTarget !== "request" && exportTarget !== "session") {
|
|
615
|
+
stderr(renderUsage());
|
|
616
|
+
return 1;
|
|
617
|
+
}
|
|
618
|
+
if (exportTarget === "request" && !parsed.requestId) {
|
|
619
|
+
stderr("Missing value for --request\n");
|
|
620
|
+
stderr(renderUsage());
|
|
621
|
+
return 1;
|
|
622
|
+
}
|
|
623
|
+
try {
|
|
624
|
+
const runtime = await createHarness(path.resolve(cwd, parsed.workspaceRoot ?? "."));
|
|
625
|
+
try {
|
|
626
|
+
if (exportTarget === "request") {
|
|
627
|
+
const pkg = await runtime.exportRequestPackage({
|
|
628
|
+
sessionId: parsed.sessionId,
|
|
629
|
+
requestId: parsed.requestId,
|
|
630
|
+
includeArtifacts: parsed.includeArtifacts,
|
|
631
|
+
includeArtifactContents: parsed.includeArtifactContents,
|
|
632
|
+
includeRuntimeHealth: parsed.includeRuntimeHealth,
|
|
633
|
+
});
|
|
634
|
+
stdout(renderJson(pkg));
|
|
635
|
+
}
|
|
636
|
+
else {
|
|
637
|
+
const pkg = await runtime.exportSessionPackage({
|
|
638
|
+
sessionId: parsed.sessionId,
|
|
639
|
+
includeArtifacts: parsed.includeArtifacts,
|
|
640
|
+
includeArtifactContents: parsed.includeArtifactContents,
|
|
641
|
+
includeRuntimeHealth: parsed.includeRuntimeHealth,
|
|
642
|
+
});
|
|
643
|
+
stdout(renderJson(pkg));
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
finally {
|
|
647
|
+
await runtime.stop();
|
|
648
|
+
}
|
|
649
|
+
return 0;
|
|
650
|
+
}
|
|
651
|
+
catch (error) {
|
|
652
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
653
|
+
stderr(`${message}\n`);
|
|
654
|
+
return 1;
|
|
655
|
+
}
|
|
656
|
+
}
|
|
525
657
|
const nestedCommand = (subcommand === "approvals" || subcommand === "runs") && possibleNestedCommand
|
|
526
658
|
? possibleNestedCommand
|
|
527
659
|
: undefined;
|
|
528
|
-
const subcommandArgs = nestedCommand
|
|
660
|
+
const subcommandArgs = nestedCommand
|
|
661
|
+
? [possibleThirdCommand, ...remainingArgs].filter((item) => typeof item === "string")
|
|
662
|
+
: [possibleNestedCommand, possibleThirdCommand, ...remainingArgs].filter((item) => typeof item === "string");
|
|
529
663
|
const parsed = parseRuntimeInspectOptions(subcommandArgs);
|
|
530
664
|
if (parsed.error) {
|
|
531
665
|
stderr(`${parsed.error}\n`);
|
|
@@ -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
|
/**
|
|
@@ -556,6 +572,7 @@ export type ApprovalRecord = {
|
|
|
556
572
|
threadId: string;
|
|
557
573
|
runId: string;
|
|
558
574
|
toolName: string;
|
|
575
|
+
approvalReason?: string;
|
|
559
576
|
status: "pending" | "approved" | "edited" | "rejected" | "expired";
|
|
560
577
|
requestedAt: string;
|
|
561
578
|
resolvedAt: string | null;
|
|
@@ -710,6 +727,21 @@ export type RuntimeRunPackageInput = {
|
|
|
710
727
|
includeArtifactContents?: boolean;
|
|
711
728
|
includeRuntimeHealth?: boolean;
|
|
712
729
|
};
|
|
730
|
+
export type RuntimeApprovalSummary = {
|
|
731
|
+
total: number;
|
|
732
|
+
pending: number;
|
|
733
|
+
approved: number;
|
|
734
|
+
edited: number;
|
|
735
|
+
rejected: number;
|
|
736
|
+
expired: number;
|
|
737
|
+
toolNames: string[];
|
|
738
|
+
approvalReasons: string[];
|
|
739
|
+
};
|
|
740
|
+
export type RuntimeGovernanceEvidence = {
|
|
741
|
+
bundles: RuntimeGovernanceBundle[];
|
|
742
|
+
approvalSummary: RuntimeApprovalSummary;
|
|
743
|
+
summary: string;
|
|
744
|
+
};
|
|
713
745
|
export type RuntimeRunPackage = {
|
|
714
746
|
session: SessionRecord | null;
|
|
715
747
|
request: RequestRecord | null;
|
|
@@ -717,6 +749,7 @@ export type RuntimeRunPackage = {
|
|
|
717
749
|
transcript: TranscriptMessage[];
|
|
718
750
|
events: HarnessEvent[];
|
|
719
751
|
artifacts: RuntimeEvaluationArtifact[];
|
|
752
|
+
governance: RuntimeGovernanceEvidence;
|
|
720
753
|
runtimeHealth?: RuntimeHealthSnapshot;
|
|
721
754
|
};
|
|
722
755
|
export type RuntimeSessionPackageInput = {
|
|
@@ -731,6 +764,14 @@ export type RuntimeSessionPackage = {
|
|
|
731
764
|
approvals: ApprovalRecord[];
|
|
732
765
|
transcript: TranscriptMessage[];
|
|
733
766
|
runs: RuntimeRunPackage[];
|
|
767
|
+
governance: {
|
|
768
|
+
runs: Array<{
|
|
769
|
+
requestId: string;
|
|
770
|
+
evidence: RuntimeGovernanceEvidence;
|
|
771
|
+
}>;
|
|
772
|
+
approvalSummary: RuntimeApprovalSummary;
|
|
773
|
+
summary: string;
|
|
774
|
+
};
|
|
734
775
|
runtimeHealth?: RuntimeHealthSnapshot;
|
|
735
776
|
};
|
|
736
777
|
export type RuntimeInventoryContext = {
|
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.232";
|
package/dist/package-version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const AGENT_HARNESS_VERSION = "0.0.
|
|
1
|
+
export const AGENT_HARNESS_VERSION = "0.0.232";
|
|
@@ -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,52 @@ 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
|
+
}
|
|
72
|
+
function summarizeApprovalEvidence(approvals) {
|
|
73
|
+
const toolNames = Array.from(new Set(approvals
|
|
74
|
+
.map((approval) => approval.toolName)
|
|
75
|
+
.filter((toolName) => typeof toolName === "string" && toolName.trim().length > 0)));
|
|
76
|
+
const approvalReasons = Array.from(new Set(approvals
|
|
77
|
+
.map((approval) => approval.approvalReason)
|
|
78
|
+
.filter((reason) => typeof reason === "string" && reason.trim().length > 0)));
|
|
79
|
+
return {
|
|
80
|
+
total: approvals.length,
|
|
81
|
+
pending: approvals.filter((approval) => approval.status === "pending").length,
|
|
82
|
+
approved: approvals.filter((approval) => approval.status === "approved").length,
|
|
83
|
+
edited: approvals.filter((approval) => approval.status === "edited").length,
|
|
84
|
+
rejected: approvals.filter((approval) => approval.status === "rejected").length,
|
|
85
|
+
expired: approvals.filter((approval) => approval.status === "expired").length,
|
|
86
|
+
toolNames,
|
|
87
|
+
approvalReasons,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
43
90
|
export class AgentHarnessRuntime {
|
|
44
91
|
workspace;
|
|
45
92
|
runtimeAdapterOptions;
|
|
@@ -312,6 +359,10 @@ export class AgentHarnessRuntime {
|
|
|
312
359
|
currentAgentId: session.currentAgentId,
|
|
313
360
|
}));
|
|
314
361
|
}
|
|
362
|
+
async listSessionSummaries(filter) {
|
|
363
|
+
const sessions = await this.persistence.listSessionSummaries(filter);
|
|
364
|
+
return sessions.map((session) => toSessionListSummary(session));
|
|
365
|
+
}
|
|
315
366
|
async listThreads(filter) {
|
|
316
367
|
const sessions = await this.listSessions(filter);
|
|
317
368
|
return sessions.map((session) => ({
|
|
@@ -677,6 +728,15 @@ export class AgentHarnessRuntime {
|
|
|
677
728
|
? { content: await this.persistence.readArtifact(input.sessionId, input.requestId, artifact.path) }
|
|
678
729
|
: {}),
|
|
679
730
|
})));
|
|
731
|
+
const approvalSummary = summarizeApprovalEvidence(approvals);
|
|
732
|
+
const bundles = request?.runtimeSnapshot?.governance?.bundles ?? [];
|
|
733
|
+
const governanceSummaryParts = [
|
|
734
|
+
`${bundles.length} governance bundle(s)`,
|
|
735
|
+
`${approvalSummary.total} approval record(s)`,
|
|
736
|
+
];
|
|
737
|
+
if (approvalSummary.approvalReasons.length > 0) {
|
|
738
|
+
governanceSummaryParts.push(`reasons=${approvalSummary.approvalReasons.join(",")}`);
|
|
739
|
+
}
|
|
680
740
|
return {
|
|
681
741
|
session,
|
|
682
742
|
request,
|
|
@@ -684,6 +744,11 @@ export class AgentHarnessRuntime {
|
|
|
684
744
|
transcript,
|
|
685
745
|
events,
|
|
686
746
|
artifacts,
|
|
747
|
+
governance: {
|
|
748
|
+
bundles,
|
|
749
|
+
approvalSummary,
|
|
750
|
+
summary: governanceSummaryParts.join(" "),
|
|
751
|
+
},
|
|
687
752
|
...(input.includeRuntimeHealth === false ? {} : { runtimeHealth: await this.getHealth() }),
|
|
688
753
|
};
|
|
689
754
|
}
|
|
@@ -700,12 +765,25 @@ export class AgentHarnessRuntime {
|
|
|
700
765
|
includeArtifactContents: input.includeArtifactContents,
|
|
701
766
|
includeRuntimeHealth: false,
|
|
702
767
|
})));
|
|
768
|
+
const approvals = await this.listApprovals({ threadId: input.sessionId });
|
|
769
|
+
const approvalSummary = summarizeApprovalEvidence(approvals);
|
|
770
|
+
const governanceRuns = runs
|
|
771
|
+
.filter((item) => item.request?.requestId)
|
|
772
|
+
.map((item) => ({
|
|
773
|
+
requestId: item.request.requestId,
|
|
774
|
+
evidence: item.governance,
|
|
775
|
+
}));
|
|
703
776
|
return {
|
|
704
777
|
session,
|
|
705
778
|
requests: runs.map((item) => item.request).filter((item) => Boolean(item)),
|
|
706
|
-
approvals
|
|
779
|
+
approvals,
|
|
707
780
|
transcript: await this.persistence.listThreadMessages(input.sessionId, 500),
|
|
708
781
|
runs,
|
|
782
|
+
governance: {
|
|
783
|
+
runs: governanceRuns,
|
|
784
|
+
approvalSummary,
|
|
785
|
+
summary: `${governanceRuns.length} run evidence package(s), ${approvalSummary.total} approval record(s)`,
|
|
786
|
+
},
|
|
709
787
|
...(input.includeRuntimeHealth === false ? {} : { runtimeHealth: await this.getHealth() }),
|
|
710
788
|
};
|
|
711
789
|
}
|