@botbotgo/agent-harness 0.0.156 → 0.0.158

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.
Files changed (38) hide show
  1. package/README.md +36 -0
  2. package/README.zh.md +28 -0
  3. package/dist/acp.d.ts +86 -0
  4. package/dist/acp.js +208 -0
  5. package/dist/api.d.ts +15 -2
  6. package/dist/api.js +11 -0
  7. package/dist/contracts/runtime.d.ts +55 -0
  8. package/dist/flow/build-flow-graph.d.ts +2 -0
  9. package/dist/flow/build-flow-graph.js +737 -0
  10. package/dist/flow/export-mermaid.d.ts +2 -0
  11. package/dist/flow/export-mermaid.js +96 -0
  12. package/dist/flow/export-sequence-mermaid.d.ts +3 -0
  13. package/dist/flow/export-sequence-mermaid.js +169 -0
  14. package/dist/flow/index.d.ts +4 -0
  15. package/dist/flow/index.js +3 -0
  16. package/dist/flow/types.d.ts +75 -0
  17. package/dist/flow/types.js +1 -0
  18. package/dist/index.d.ts +4 -2
  19. package/dist/index.js +1 -1
  20. package/dist/package-version.d.ts +1 -1
  21. package/dist/package-version.js +1 -1
  22. package/dist/persistence/file-store.d.ts +1 -0
  23. package/dist/persistence/file-store.js +10 -1
  24. package/dist/persistence/types.d.ts +2 -0
  25. package/dist/runtime/adapter/tool/resolved-tool.d.ts +1 -1
  26. package/dist/runtime/agent-runtime-adapter.d.ts +5 -1
  27. package/dist/runtime/agent-runtime-adapter.js +61 -24
  28. package/dist/runtime/harness/events/streaming.js +6 -0
  29. package/dist/runtime/harness/run/governance.d.ts +2 -0
  30. package/dist/runtime/harness/run/governance.js +76 -0
  31. package/dist/runtime/harness/run/inspection.js +4 -0
  32. package/dist/runtime/harness/run/stream-run.js +1 -1
  33. package/dist/runtime/harness/system/policy-engine.d.ts +2 -1
  34. package/dist/runtime/harness/system/policy-engine.js +5 -1
  35. package/dist/runtime/harness.d.ts +5 -1
  36. package/dist/runtime/harness.js +82 -0
  37. package/dist/workspace/agent-binding-compiler.js +7 -1
  38. package/package.json +11 -2
package/README.md CHANGED
@@ -450,10 +450,18 @@ const result = await run(runtime, {
450
450
  onEvent(event) {
451
451
  console.log(event.eventType, event.payload);
452
452
  },
453
+ onUpstreamEvent(event) {
454
+ console.log("raw upstream event", event);
455
+ },
456
+ onUpstreamItem(item) {
457
+ console.log("upstream agent", item.agentId, item.event);
458
+ },
453
459
  },
454
460
  });
455
461
  ```
456
462
 
463
+ `onUpstreamEvent(...)` preserves the raw upstream event payload. `onUpstreamItem(...)` adds runtime correlation metadata such as `threadId`, `runId`, and the current `agentId`, which is useful for flow-graph capture and delegated sub-agent inspection.
464
+
457
465
  `subscribe(...)` is the read-only observer surface over stored lifecycle events.
458
466
 
459
467
  The runtime event stream includes:
@@ -563,8 +571,14 @@ Discovery rules:
563
571
  - local tools are auto-discovered from `resources/tools/**/*.js|*.mjs|*.cjs` when they export `tool({...})`
564
572
  - skills are auto-discovered from `resources/skills/**/SKILL.md`
565
573
 
574
+ Example workspaces:
575
+
576
+ - `examples/hello-skill-app/` keeps the smallest local tool + skill workspace
577
+ - `examples/runtime-flow-demo/` runs one real hosted-model request and exports a Mermaid flowchart from runtime plus upstream events
578
+
566
579
  Workspace-local tool modules in `resources/tools/` should be exported with `tool({...})`.
567
580
  Any other local module shape is not supported, and unsupported shapes are rejected at load time.
581
+ When local tools use Zod-authored schemas, keep the workspace or isolated `resources` package on `zod@^4` so raw-shape validators and runtime parsing stay on one supported major version.
568
582
 
569
583
  Default wiring guidance:
570
584
 
@@ -796,10 +810,15 @@ spec:
796
810
  rootDir: .
797
811
  virtualMode: true
798
812
  maxFileSizeMb: 10
813
+ sessionStorage:
814
+ enabled: true
815
+ rootDir: "{runRoot}/threads/{threadId}/filesystem"
799
816
  middleware: []
800
817
  systemPrompt: Answer simple requests directly.
801
818
  ```
802
819
 
820
+ When `config.filesystem.sessionStorage.enabled: true` is set for a LangChain binding, the runtime keeps one filesystem root per persisted session/thread and reuses the same runnable cache entry for repeated work on that session instead of collapsing every run onto one shared workspace directory.
821
+
803
822
  Example orchestra host:
804
823
 
805
824
  ```yaml
@@ -860,6 +879,23 @@ Primary exports:
860
879
  - `deleteSession`
861
880
  - `listApprovals`
862
881
  - `getApproval`
882
+ - `listArtifacts`
883
+ - `getArtifact`
884
+ - `exportEvaluationBundle`
885
+ - `createAcpServer`
863
886
  - `createToolMcpServer`
864
887
  - `serveToolsOverStdio`
865
888
  - `stop`
889
+ - `createUpstreamTimelineReducer`
890
+ - `buildFlowGraph`
891
+ - `exportFlowGraphToMermaid`
892
+ - `exportFlowGraphToSequenceMermaid`
893
+
894
+ Inspection helpers:
895
+
896
+ - `createUpstreamTimelineReducer()` reduces raw upstream model/tool/chain events into ordered step-like projections for inspection and visualization.
897
+ - `buildFlowGraph(...)` combines persisted runtime timeline items with optional upstream projections into a detailed flow graph utility shape, including best-effort delegated subagent transitions when raw upstream events are available.
898
+ - `exportFlowGraphToMermaid(...)` renders that inspection graph as Mermaid flowchart text. By default it emits the product view: agent and sub-agent delegation plus user-defined model, tool, and skill calls. Use `view: "debug"` to include runtime inspection detail.
899
+ - `exportFlowGraphToSequenceMermaid(...)` renders the same inspection graph as a Mermaid sequence diagram. By default it emits only user-defined participants and calls, while `view: "debug"` includes runtime participants and lifecycle messages.
900
+
901
+ These helpers are visualization and inspection utilities. They do not introduce a canonical harness-owned execution protocol.
package/README.zh.md CHANGED
@@ -535,8 +535,14 @@ await stop(runtime);
535
535
  - 本地工具会从 `resources/tools/**/*.js|*.mjs|*.cjs` 中自动发现,前提是模块导出 `tool({...})`
536
536
  - skills 会从 `resources/skills/**/SKILL.md` 自动发现
537
537
 
538
+ 示例工作区:
539
+
540
+ - `examples/hello-skill-app/` 保留最小的本地 tool + skill 工作区
541
+ - `examples/runtime-flow-demo/` 会跑一次真实 hosted model 请求,并把 runtime 与 upstream events 导出为 Mermaid flowchart
542
+
538
543
  `resources/tools/` 下的工作区本地工具模块应统一用 `tool({...})` 导出。
539
544
  不支持历史/兼容写法,任何不带该导出形式的工具模块都会在工作区加载时被拒绝。
545
+ 若本地工具使用 Zod schema,请让工作区或隔离的 `resources` 包统一使用 `zod@^4`,避免 raw shape validator 与 runtime 解析落在不同 major 版本上。
540
546
 
541
547
  主要有三层配置:
542
548
 
@@ -763,10 +769,15 @@ spec:
763
769
  rootDir: .
764
770
  virtualMode: true
765
771
  maxFileSizeMb: 10
772
+ sessionStorage:
773
+ enabled: true
774
+ rootDir: "{runRoot}/threads/{threadId}/filesystem"
766
775
  middleware: []
767
776
  systemPrompt: Answer simple requests directly.
768
777
  ```
769
778
 
779
+ 当 LangChain 绑定启用 `config.filesystem.sessionStorage.enabled: true` 时,runtime 会为每个持久化 session/thread 维护独立的 filesystem 根目录,并按 session 复用 runnable cache,而不是把所有运行都压到同一个共享工作目录里。
780
+
770
781
  orchestra 主机示例:
771
782
 
772
783
  ```yaml
@@ -827,6 +838,23 @@ spec:
827
838
  - `deleteSession`
828
839
  - `listApprovals`
829
840
  - `getApproval`
841
+ - `listArtifacts`
842
+ - `getArtifact`
843
+ - `exportEvaluationBundle`
844
+ - `createAcpServer`
830
845
  - `createToolMcpServer`
831
846
  - `serveToolsOverStdio`
832
847
  - `stop`
848
+ - `createUpstreamTimelineReducer`
849
+ - `buildFlowGraph`
850
+ - `exportFlowGraphToMermaid`
851
+ - `exportFlowGraphToSequenceMermaid`
852
+
853
+ Inspection 辅助工具:
854
+
855
+ - `createUpstreamTimelineReducer()` 可把上游 model/tool/chain 原始事件归约成有序的 step-like 投影,便于检查和可视化。
856
+ - `buildFlowGraph(...)` 可把持久化 runtime timeline 与可选的 upstream projections 组合成详细 flow graph utility 数据结构;当提供原始 upstream events 时,也会尽力补出 subagent delegation 转移。
857
+ - `exportFlowGraphToMermaid(...)` 可把该 inspection graph 导出为 Mermaid flowchart 文本。默认输出 product 视图,只保留 agent / sub-agent delegation 以及用户定义的 model、tool、skill 调用;传 `view: "debug"` 才会带上 runtime 检查细节。
858
+ - `exportFlowGraphToSequenceMermaid(...)` 可把同一份 inspection graph 导出为 Mermaid sequence diagram。默认只输出用户定义的参与者与调用;传 `view: "debug"` 才会包含 runtime participant 与生命周期消息。
859
+
860
+ 这些 helper 只用于可视化与检查,不代表新的 harness 官方执行协议。
package/dist/acp.d.ts ADDED
@@ -0,0 +1,86 @@
1
+ import type { ArtifactRecord, HarnessEvent, RequestRecord, RunOptions, SessionRecord } from "./contracts/types.js";
2
+ import type { AgentHarnessRuntime } from "./runtime/harness.js";
3
+ import { getApproval } from "./api.js";
4
+ type JsonRpcId = string | number | null;
5
+ export type AcpJsonRpcRequest = {
6
+ jsonrpc?: "2.0";
7
+ id?: JsonRpcId;
8
+ method: string;
9
+ params?: unknown;
10
+ };
11
+ export type AcpJsonRpcError = {
12
+ jsonrpc: "2.0";
13
+ id: JsonRpcId;
14
+ error: {
15
+ code: number;
16
+ message: string;
17
+ data?: unknown;
18
+ };
19
+ };
20
+ export type AcpJsonRpcSuccess = {
21
+ jsonrpc: "2.0";
22
+ id: JsonRpcId;
23
+ result: unknown;
24
+ };
25
+ export type AcpJsonRpcResponse = AcpJsonRpcError | AcpJsonRpcSuccess;
26
+ export type AcpSessionRecord = SessionRecord;
27
+ export type AcpRequestRecord = RequestRecord;
28
+ export type AcpApproval = Awaited<ReturnType<typeof getApproval>> extends infer T ? Exclude<T, null> : never;
29
+ export type AcpArtifact = ArtifactRecord & {
30
+ content?: unknown;
31
+ };
32
+ export type AcpRunRequestParams = Omit<Extract<RunOptions, {
33
+ input: unknown;
34
+ }>, "threadId"> & {
35
+ sessionId?: string;
36
+ };
37
+ export type AcpServerCapabilities = {
38
+ sessions: {
39
+ list: true;
40
+ get: true;
41
+ };
42
+ requests: {
43
+ submit: true;
44
+ list: true;
45
+ get: true;
46
+ };
47
+ approvals: {
48
+ list: true;
49
+ get: true;
50
+ resolve: true;
51
+ };
52
+ artifacts: {
53
+ list: true;
54
+ read: true;
55
+ };
56
+ events: {
57
+ subscribe: true;
58
+ };
59
+ };
60
+ export type AcpEventNotification = {
61
+ jsonrpc: "2.0";
62
+ method: "events.runtime";
63
+ params: {
64
+ event: {
65
+ eventId: string;
66
+ eventType: string;
67
+ timestamp: string;
68
+ sessionId: string;
69
+ requestId: string;
70
+ sequence: number;
71
+ source: HarnessEvent["source"];
72
+ payload: Record<string, unknown>;
73
+ };
74
+ };
75
+ };
76
+ export declare class AgentHarnessAcpServer {
77
+ private readonly runtime;
78
+ constructor(runtime: AgentHarnessRuntime);
79
+ capabilities(): AcpServerCapabilities;
80
+ subscribe(listener: (notification: AcpEventNotification) => void): () => void;
81
+ handle(request: AcpJsonRpcRequest): Promise<AcpJsonRpcResponse | undefined>;
82
+ private methodExists;
83
+ private dispatch;
84
+ }
85
+ export declare function createAcpServer(runtime: AgentHarnessRuntime): AgentHarnessAcpServer;
86
+ export {};
package/dist/acp.js ADDED
@@ -0,0 +1,208 @@
1
+ import { getApproval, getArtifact, getRequest, getSession, listApprovals, listArtifacts, listRequests, listSessions, resolveApproval, run, } from "./api.js";
2
+ const CAPABILITIES = {
3
+ sessions: { list: true, get: true },
4
+ requests: { submit: true, list: true, get: true },
5
+ approvals: { list: true, get: true, resolve: true },
6
+ artifacts: { list: true, read: true },
7
+ events: { subscribe: true },
8
+ };
9
+ function asObject(value, method) {
10
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
11
+ throw new Error(`${method} requires an object params payload.`);
12
+ }
13
+ return value;
14
+ }
15
+ function readOptionalString(value) {
16
+ return typeof value === "string" && value.trim().length > 0 ? value.trim() : undefined;
17
+ }
18
+ function readRequiredString(value, field, method) {
19
+ const normalized = readOptionalString(value);
20
+ if (!normalized) {
21
+ throw new Error(`${method} requires ${field}.`);
22
+ }
23
+ return normalized;
24
+ }
25
+ function toNotification(event) {
26
+ return {
27
+ jsonrpc: "2.0",
28
+ method: "events.runtime",
29
+ params: {
30
+ event: {
31
+ eventId: event.eventId,
32
+ eventType: event.eventType,
33
+ timestamp: event.timestamp,
34
+ sessionId: event.threadId,
35
+ requestId: event.runId,
36
+ sequence: event.sequence,
37
+ source: event.source,
38
+ payload: event.payload,
39
+ },
40
+ },
41
+ };
42
+ }
43
+ async function readArtifactContent(runtime, params) {
44
+ const method = "artifacts.read";
45
+ const sessionId = readRequiredString(params.sessionId, "sessionId", method);
46
+ const requestId = readRequiredString(params.requestId, "requestId", method);
47
+ const artifactPath = readRequiredString(params.artifactPath, "artifactPath", method);
48
+ const listing = await listArtifacts(runtime, { sessionId, requestId });
49
+ const artifact = listing.items.find((item) => item.path === artifactPath);
50
+ if (!artifact) {
51
+ throw new Error(`Artifact not found for ${requestId}: ${artifactPath}`);
52
+ }
53
+ return {
54
+ ...artifact,
55
+ content: await getArtifact(runtime, { sessionId, requestId, artifactPath }),
56
+ };
57
+ }
58
+ export class AgentHarnessAcpServer {
59
+ runtime;
60
+ constructor(runtime) {
61
+ this.runtime = runtime;
62
+ }
63
+ capabilities() {
64
+ return CAPABILITIES;
65
+ }
66
+ subscribe(listener) {
67
+ return this.runtime.subscribe((event) => {
68
+ listener(toNotification(event));
69
+ });
70
+ }
71
+ async handle(request) {
72
+ const id = request.id ?? null;
73
+ if (!request || typeof request !== "object" || typeof request.method !== "string" || request.method.trim().length === 0) {
74
+ return {
75
+ jsonrpc: "2.0",
76
+ id,
77
+ error: {
78
+ code: -32600,
79
+ message: "Invalid JSON-RPC request.",
80
+ },
81
+ };
82
+ }
83
+ if (request.jsonrpc !== undefined && request.jsonrpc !== "2.0") {
84
+ return {
85
+ jsonrpc: "2.0",
86
+ id,
87
+ error: {
88
+ code: -32600,
89
+ message: "Only JSON-RPC 2.0 requests are supported.",
90
+ },
91
+ };
92
+ }
93
+ try {
94
+ const result = await this.dispatch(request.method, request.params);
95
+ if (request.id === undefined) {
96
+ return undefined;
97
+ }
98
+ return {
99
+ jsonrpc: "2.0",
100
+ id,
101
+ result,
102
+ };
103
+ }
104
+ catch (error) {
105
+ if (request.id === undefined) {
106
+ return undefined;
107
+ }
108
+ return {
109
+ jsonrpc: "2.0",
110
+ id,
111
+ error: {
112
+ code: this.methodExists(request.method) ? -32602 : -32601,
113
+ message: error instanceof Error ? error.message : "ACP request failed.",
114
+ },
115
+ };
116
+ }
117
+ }
118
+ methodExists(method) {
119
+ return new Set([
120
+ "capabilities.get",
121
+ "sessions.list",
122
+ "sessions.get",
123
+ "requests.submit",
124
+ "requests.list",
125
+ "requests.get",
126
+ "approvals.list",
127
+ "approvals.get",
128
+ "approvals.resolve",
129
+ "artifacts.list",
130
+ "artifacts.read",
131
+ ]).has(method);
132
+ }
133
+ async dispatch(method, params) {
134
+ switch (method) {
135
+ case "capabilities.get":
136
+ return this.capabilities();
137
+ case "sessions.list": {
138
+ const payload = params === undefined ? {} : asObject(params, method);
139
+ return listSessions(this.runtime, {
140
+ agentId: readOptionalString(payload.agentId),
141
+ });
142
+ }
143
+ case "sessions.get": {
144
+ const payload = asObject(params, method);
145
+ return getSession(this.runtime, readRequiredString(payload.sessionId, "sessionId", method));
146
+ }
147
+ case "requests.submit": {
148
+ const payload = asObject(params, method);
149
+ return run(this.runtime, {
150
+ agentId: readOptionalString(payload.agentId),
151
+ input: payload.input,
152
+ invocation: payload.invocation,
153
+ listeners: payload.listeners,
154
+ priority: typeof payload.priority === "number" ? payload.priority : undefined,
155
+ sessionId: readOptionalString(payload.sessionId),
156
+ });
157
+ }
158
+ case "requests.list": {
159
+ const payload = params === undefined ? {} : asObject(params, method);
160
+ return listRequests(this.runtime, {
161
+ agentId: readOptionalString(payload.agentId),
162
+ sessionId: readOptionalString(payload.sessionId),
163
+ state: payload.state,
164
+ });
165
+ }
166
+ case "requests.get": {
167
+ const payload = asObject(params, method);
168
+ return getRequest(this.runtime, readRequiredString(payload.requestId, "requestId", method));
169
+ }
170
+ case "approvals.list": {
171
+ const payload = params === undefined ? {} : asObject(params, method);
172
+ return listApprovals(this.runtime, {
173
+ status: payload.status,
174
+ sessionId: readOptionalString(payload.sessionId),
175
+ requestId: readOptionalString(payload.requestId),
176
+ });
177
+ }
178
+ case "approvals.get": {
179
+ const payload = asObject(params, method);
180
+ return getApproval(this.runtime, readRequiredString(payload.approvalId, "approvalId", method));
181
+ }
182
+ case "approvals.resolve": {
183
+ const payload = asObject(params, method);
184
+ return resolveApproval(this.runtime, {
185
+ approvalId: readRequiredString(payload.approvalId, "approvalId", method),
186
+ decision: payload.decision,
187
+ editedInput: payload.editedInput,
188
+ requestId: readOptionalString(payload.requestId),
189
+ sessionId: readOptionalString(payload.sessionId),
190
+ });
191
+ }
192
+ case "artifacts.list": {
193
+ const payload = asObject(params, method);
194
+ return listArtifacts(this.runtime, {
195
+ sessionId: readRequiredString(payload.sessionId, "sessionId", method),
196
+ requestId: readRequiredString(payload.requestId, "requestId", method),
197
+ });
198
+ }
199
+ case "artifacts.read":
200
+ return readArtifactContent(this.runtime, asObject(params, method));
201
+ default:
202
+ throw new Error(`Unknown ACP method: ${method}`);
203
+ }
204
+ }
205
+ }
206
+ export function createAcpServer(runtime) {
207
+ return new AgentHarnessAcpServer(runtime);
208
+ }
package/dist/api.d.ts CHANGED
@@ -1,11 +1,14 @@
1
- import type { CancelOptions, InvocationEnvelope, ListMemoriesInput, ListMemoriesResult, MemoryRecord, MemorizeInput, MemorizeResult, MessageContent, RecallInput, RecallResult, RemoveMemoryInput, RequestRecord, RequestSummary, ResumeOptions, RunDecisionOptions, RunResult, RunStartOptions, RuntimeHealthSnapshot, RuntimeAdapterOptions, SessionRecord, SessionSummary, 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, RunResult, RunStartOptions, RuntimeHealthSnapshot, RuntimeAdapterOptions, RuntimeEvaluationExport, RuntimeEvaluationExportInput, SessionRecord, SessionSummary, 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";
5
5
  import type { ToolMcpServerOptions } from "./mcp.js";
6
+ export { AgentHarnessAcpServer, createAcpServer } from "./acp.js";
7
+ export type { AcpApproval, AcpArtifact, AcpEventNotification, AcpJsonRpcError, AcpJsonRpcRequest, AcpJsonRpcResponse, AcpJsonRpcSuccess, AcpRequestRecord, AcpRunRequestParams, AcpServerCapabilities, AcpSessionRecord, } from "./acp.js";
6
8
  export { AgentHarnessRuntime } from "./runtime/harness.js";
9
+ export { buildFlowGraph, exportFlowGraphToMermaid, exportFlowGraphToSequenceMermaid } from "./flow/index.js";
7
10
  export { createUpstreamTimelineReducer } from "./upstream-events.js";
8
- export type { ListMemoriesInput, ListMemoriesResult, MemoryDecision, MemoryKind, MemoryRecord, MemoryScope, MemorizeInput, MemorizeResult, RecallInput, RecallResult, RemoveMemoryInput, UpdateMemoryInput, } from "./contracts/types.js";
11
+ export type { ListMemoriesInput, ListMemoriesResult, MemoryDecision, MemoryKind, MemoryRecord, MemoryScope, MemorizeInput, MemorizeResult, RecallInput, RecallResult, RemoveMemoryInput, RuntimeEvaluationExport, RuntimeEvaluationExportInput, UpdateMemoryInput, } from "./contracts/types.js";
9
12
  type PublicApprovalRecord = {
10
13
  approvalId: string;
11
14
  pendingActionId: string;
@@ -72,7 +75,17 @@ export declare function getRequest(runtime: AgentHarnessRuntime, requestId: stri
72
75
  export declare function deleteSession(runtime: AgentHarnessRuntime, sessionId: string): Promise<boolean>;
73
76
  export declare function listApprovals(runtime: AgentHarnessRuntime, filter?: PublicApprovalFilter): Promise<PublicApprovalRecord[]>;
74
77
  export declare function getApproval(runtime: AgentHarnessRuntime, approvalId: string): Promise<PublicApprovalRecord | null>;
78
+ export declare function listArtifacts(runtime: AgentHarnessRuntime, input: {
79
+ sessionId: string;
80
+ requestId: string;
81
+ }): Promise<ArtifactListing>;
82
+ export declare function getArtifact(runtime: AgentHarnessRuntime, input: {
83
+ sessionId: string;
84
+ requestId: string;
85
+ artifactPath: string;
86
+ }): Promise<unknown>;
75
87
  export declare function getHealth(runtime: AgentHarnessRuntime): Promise<RuntimeHealthSnapshot>;
88
+ export declare function exportEvaluationBundle(runtime: AgentHarnessRuntime, input: RuntimeEvaluationExportInput): Promise<RuntimeEvaluationExport>;
76
89
  export declare function listAgentSkills(runtime: AgentHarnessRuntime, agentId: string, options?: RequirementAssessmentOptions): InventorySkillRecord[];
77
90
  export declare function getAgent(runtime: AgentHarnessRuntime, agentId: string, options?: RequirementAssessmentOptions): InventoryAgentRecord | null;
78
91
  export declare function describeInventory(runtime: AgentHarnessRuntime, options?: RequirementAssessmentOptions): {
package/dist/api.js CHANGED
@@ -1,7 +1,9 @@
1
1
  import { AgentHarnessRuntime } from "./runtime/harness.js";
2
2
  import { normalizeMessageContent } from "./utils/message-content.js";
3
3
  import { loadWorkspace } from "./workspace/compile.js";
4
+ export { AgentHarnessAcpServer, createAcpServer } from "./acp.js";
4
5
  export { AgentHarnessRuntime } from "./runtime/harness.js";
6
+ export { buildFlowGraph, exportFlowGraphToMermaid, exportFlowGraphToSequenceMermaid } from "./flow/index.js";
5
7
  export { createUpstreamTimelineReducer } from "./upstream-events.js";
6
8
  function toSessionSummary(summary) {
7
9
  return {
@@ -178,9 +180,18 @@ export async function getApproval(runtime, approvalId) {
178
180
  const record = await runtime.getApproval(approvalId);
179
181
  return record ? toApprovalRecord(record) : null;
180
182
  }
183
+ export async function listArtifacts(runtime, input) {
184
+ return runtime.listArtifacts(input.sessionId, input.requestId);
185
+ }
186
+ export async function getArtifact(runtime, input) {
187
+ return runtime.readArtifact(input.sessionId, input.requestId, input.artifactPath);
188
+ }
181
189
  export async function getHealth(runtime) {
182
190
  return runtime.getHealth();
183
191
  }
192
+ export async function exportEvaluationBundle(runtime, input) {
193
+ return runtime.exportEvaluationBundle(input);
194
+ }
184
195
  export function listAgentSkills(runtime, agentId, options) {
185
196
  return runtime.listAgentSkills(agentId, options);
186
197
  }
@@ -96,6 +96,24 @@ export type RuntimeSnapshotTracing = {
96
96
  tags?: string[];
97
97
  metadata?: Record<string, unknown>;
98
98
  };
99
+ export type RuntimeGovernanceRiskLevel = "low" | "medium" | "high";
100
+ export type RuntimeGovernanceToolPolicy = {
101
+ toolName: string;
102
+ toolId: string;
103
+ toolType: string;
104
+ category: "local" | "backend" | "mcp" | "provider-native";
105
+ risk: RuntimeGovernanceRiskLevel;
106
+ requiresApproval: boolean;
107
+ approvalPolicy: "explicit-hitl" | "runtime-default" | "none";
108
+ hasInputSchema: boolean;
109
+ inputRiskHints: string[];
110
+ };
111
+ export type RuntimeGovernanceBundle = {
112
+ bundleId: string;
113
+ title: string;
114
+ summary: string;
115
+ toolPolicies: RuntimeGovernanceToolPolicy[];
116
+ };
99
117
  export type RuntimeSnapshot = {
100
118
  agentId: string;
101
119
  model?: RuntimeSnapshotModel;
@@ -103,6 +121,9 @@ export type RuntimeSnapshot = {
103
121
  skills: RuntimeSnapshotSkill[];
104
122
  memory: string[];
105
123
  tracing?: RuntimeSnapshotTracing;
124
+ governance?: {
125
+ bundles: RuntimeGovernanceBundle[];
126
+ };
106
127
  };
107
128
  export type MemoryCandidate = {
108
129
  content: string;
@@ -314,9 +335,16 @@ export type RunResult = {
314
335
  metadata?: Record<string, unknown>;
315
336
  };
316
337
  export type UpstreamRuntimeEvent = unknown;
338
+ export type UpstreamRuntimeEventItem = {
339
+ threadId: string;
340
+ runId: string;
341
+ agentId: string;
342
+ event: UpstreamRuntimeEvent;
343
+ };
317
344
  export type RuntimeListeners = {
318
345
  onEvent?: (event: HarnessEvent) => void | Promise<void>;
319
346
  onUpstreamEvent?: (event: UpstreamRuntimeEvent) => void | Promise<void>;
347
+ onUpstreamItem?: (item: UpstreamRuntimeEventItem) => void | Promise<void>;
320
348
  };
321
349
  export type RunListeners = RuntimeListeners;
322
350
  export type MessageContentPart = {
@@ -539,6 +567,7 @@ export type SkillPackagingConvention = {
539
567
  export type PolicyDecision = {
540
568
  allowed: boolean;
541
569
  reasons: string[];
570
+ bundles?: RuntimeGovernanceBundle[];
542
571
  };
543
572
  export type PolicyEvaluator = {
544
573
  kind: string;
@@ -548,6 +577,32 @@ export type EventSubscriber = {
548
577
  kind: string;
549
578
  onEvent: HarnessEventListener;
550
579
  };
580
+ export type RuntimeEvaluationExportInput = {
581
+ sessionId: string;
582
+ requestId: string;
583
+ includeArtifacts?: boolean;
584
+ includeArtifactContents?: boolean;
585
+ expectedOutput?: string;
586
+ rubric?: string[];
587
+ tags?: string[];
588
+ metadata?: Record<string, unknown>;
589
+ };
590
+ export type RuntimeEvaluationArtifact = ArtifactRecord & {
591
+ content?: unknown;
592
+ };
593
+ export type RuntimeEvaluationExport = {
594
+ session: SessionRecord | null;
595
+ request: RequestRecord | null;
596
+ approvals: ApprovalRecord[];
597
+ transcript: TranscriptMessage[];
598
+ events: HarnessEvent[];
599
+ artifacts: RuntimeEvaluationArtifact[];
600
+ runtimeHealth: RuntimeHealthSnapshot;
601
+ expectedOutput?: string;
602
+ rubric: string[];
603
+ tags: string[];
604
+ metadata?: Record<string, unknown>;
605
+ };
551
606
  export type RuntimeInventoryContext = {
552
607
  workspace: WorkspaceBundle;
553
608
  };
@@ -0,0 +1,2 @@
1
+ import type { BuildFlowGraphInput, FlowGraph } from "./types.js";
2
+ export declare function buildFlowGraph(input: BuildFlowGraphInput): FlowGraph;