@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.
- package/README.md +36 -0
- package/README.zh.md +28 -0
- package/dist/acp.d.ts +86 -0
- package/dist/acp.js +208 -0
- package/dist/api.d.ts +15 -2
- package/dist/api.js +11 -0
- package/dist/contracts/runtime.d.ts +55 -0
- package/dist/flow/build-flow-graph.d.ts +2 -0
- package/dist/flow/build-flow-graph.js +737 -0
- package/dist/flow/export-mermaid.d.ts +2 -0
- package/dist/flow/export-mermaid.js +96 -0
- package/dist/flow/export-sequence-mermaid.d.ts +3 -0
- package/dist/flow/export-sequence-mermaid.js +169 -0
- package/dist/flow/index.d.ts +4 -0
- package/dist/flow/index.js +3 -0
- package/dist/flow/types.d.ts +75 -0
- package/dist/flow/types.js +1 -0
- package/dist/index.d.ts +4 -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 +1 -0
- package/dist/persistence/file-store.js +10 -1
- package/dist/persistence/types.d.ts +2 -0
- package/dist/runtime/adapter/tool/resolved-tool.d.ts +1 -1
- package/dist/runtime/agent-runtime-adapter.d.ts +5 -1
- package/dist/runtime/agent-runtime-adapter.js +61 -24
- package/dist/runtime/harness/events/streaming.js +6 -0
- package/dist/runtime/harness/run/governance.d.ts +2 -0
- package/dist/runtime/harness/run/governance.js +76 -0
- package/dist/runtime/harness/run/inspection.js +4 -0
- package/dist/runtime/harness/run/stream-run.js +1 -1
- package/dist/runtime/harness/system/policy-engine.d.ts +2 -1
- package/dist/runtime/harness/system/policy-engine.js +5 -1
- package/dist/runtime/harness.d.ts +5 -1
- package/dist/runtime/harness.js +82 -0
- package/dist/workspace/agent-binding-compiler.js +7 -1
- package/package.json +11 -2
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
const PRODUCT_VIEW_KINDS = new Set(["agent", "llm", "tool", "skill"]);
|
|
2
|
+
function sanitizeMermaidId(value) {
|
|
3
|
+
return value.replace(/[^A-Za-z0-9_]/g, "_");
|
|
4
|
+
}
|
|
5
|
+
function escapeMermaidLabel(value) {
|
|
6
|
+
return value.replace(/"/g, '\\"');
|
|
7
|
+
}
|
|
8
|
+
function renderNode(node, mermaidId) {
|
|
9
|
+
const label = escapeMermaidLabel(`${node.label} [${node.status}]`);
|
|
10
|
+
switch (node.kind) {
|
|
11
|
+
case "approval":
|
|
12
|
+
return ` ${mermaidId}{"${label}"}`;
|
|
13
|
+
case "queue":
|
|
14
|
+
return ` ${mermaidId}[/"${label}"/]`;
|
|
15
|
+
case "recovery":
|
|
16
|
+
return ` ${mermaidId}{{"${label}"}}`;
|
|
17
|
+
case "artifact":
|
|
18
|
+
return ` ${mermaidId}[("${label}")]`;
|
|
19
|
+
case "skill":
|
|
20
|
+
return ` ${mermaidId}[["${label}"]]`;
|
|
21
|
+
case "memory":
|
|
22
|
+
return ` ${mermaidId}[("${label}")]`;
|
|
23
|
+
default:
|
|
24
|
+
return ` ${mermaidId}["${label}"]`;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function renderEdge(edge, fromId, toId) {
|
|
28
|
+
const connector = edge.kind === "retry" || edge.kind === "fallback" ? "-.->" : edge.kind === "resume" ? "==>" : "-->";
|
|
29
|
+
const label = edge.label ?? edge.condition ?? (edge.kind !== "sequence" && edge.kind !== "contains" ? edge.kind : "");
|
|
30
|
+
return label
|
|
31
|
+
? ` ${fromId} ${connector}|"${escapeMermaidLabel(label)}"| ${toId}`
|
|
32
|
+
: ` ${fromId} ${connector} ${toId}`;
|
|
33
|
+
}
|
|
34
|
+
export function exportFlowGraphToMermaid(graph, options = {}) {
|
|
35
|
+
const direction = options.direction ?? "TD";
|
|
36
|
+
const view = options.view ?? "product";
|
|
37
|
+
const includedKinds = options.includeKinds
|
|
38
|
+
? new Set(options.includeKinds)
|
|
39
|
+
: view === "debug"
|
|
40
|
+
? null
|
|
41
|
+
: PRODUCT_VIEW_KINDS;
|
|
42
|
+
const includedEdgeKinds = options.includeEdgeKinds ? new Set(options.includeEdgeKinds) : null;
|
|
43
|
+
const includeGroups = options.includeGroups ?? true;
|
|
44
|
+
const includeDetails = options.includeDetails ?? false;
|
|
45
|
+
const nodes = graph.nodes.filter((node) => {
|
|
46
|
+
if (!includeDetails && node.layer === "detail") {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
return includedKinds ? includedKinds.has(node.kind) : true;
|
|
50
|
+
});
|
|
51
|
+
const nodeIdSet = new Set(nodes.map((node) => node.id));
|
|
52
|
+
const edges = graph.edges.filter((edge) => {
|
|
53
|
+
if (!nodeIdSet.has(edge.from) || !nodeIdSet.has(edge.to)) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
return includedEdgeKinds ? includedEdgeKinds.has(edge.kind) : true;
|
|
57
|
+
});
|
|
58
|
+
const lines = [`flowchart ${direction}`];
|
|
59
|
+
const mermaidIdByNodeId = new Map();
|
|
60
|
+
for (const node of nodes) {
|
|
61
|
+
mermaidIdByNodeId.set(node.id, sanitizeMermaidId(node.id));
|
|
62
|
+
}
|
|
63
|
+
if (includeGroups) {
|
|
64
|
+
const groupedNodeIds = new Set();
|
|
65
|
+
for (const group of graph.groups) {
|
|
66
|
+
const groupNodes = group.nodeIds.filter((nodeId) => nodeIdSet.has(nodeId));
|
|
67
|
+
if (groupNodes.length === 0) {
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
lines.push(` subgraph ${sanitizeMermaidId(group.id)}["${escapeMermaidLabel(group.label)}"]`);
|
|
71
|
+
for (const nodeId of groupNodes) {
|
|
72
|
+
groupedNodeIds.add(nodeId);
|
|
73
|
+
const node = nodes.find((candidate) => candidate.id === nodeId);
|
|
74
|
+
if (!node) {
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
lines.push(renderNode(node, mermaidIdByNodeId.get(node.id)));
|
|
78
|
+
}
|
|
79
|
+
lines.push(" end");
|
|
80
|
+
}
|
|
81
|
+
for (const node of nodes) {
|
|
82
|
+
if (!groupedNodeIds.has(node.id)) {
|
|
83
|
+
lines.push(renderNode(node, mermaidIdByNodeId.get(node.id)));
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
for (const node of nodes) {
|
|
89
|
+
lines.push(renderNode(node, mermaidIdByNodeId.get(node.id)));
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
for (const edge of edges) {
|
|
93
|
+
lines.push(renderEdge(edge, mermaidIdByNodeId.get(edge.from), mermaidIdByNodeId.get(edge.to)));
|
|
94
|
+
}
|
|
95
|
+
return lines.join("\n");
|
|
96
|
+
}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
const PRODUCT_VIEW_KINDS = new Set(["agent", "llm", "tool", "skill"]);
|
|
2
|
+
function sanitizeAlias(value) {
|
|
3
|
+
return value.replace(/[^A-Za-z0-9_]/g, "_");
|
|
4
|
+
}
|
|
5
|
+
function escapeLabel(value) {
|
|
6
|
+
return value.replace(/"/g, '\\"');
|
|
7
|
+
}
|
|
8
|
+
function selectNodes(graph, options) {
|
|
9
|
+
const includedKinds = options.includeKinds
|
|
10
|
+
? new Set(options.includeKinds)
|
|
11
|
+
: options.view === "debug"
|
|
12
|
+
? null
|
|
13
|
+
: PRODUCT_VIEW_KINDS;
|
|
14
|
+
return graph.nodes.filter((node) => {
|
|
15
|
+
if (node.layer === "detail") {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
if (includedKinds) {
|
|
19
|
+
return includedKinds.has(node.kind);
|
|
20
|
+
}
|
|
21
|
+
return node.kind === "run"
|
|
22
|
+
|| node.kind === "agent"
|
|
23
|
+
|| node.kind === "approval"
|
|
24
|
+
|| node.kind === "recovery"
|
|
25
|
+
|| node.kind === "llm"
|
|
26
|
+
|| node.kind === "tool"
|
|
27
|
+
|| node.kind === "skill"
|
|
28
|
+
|| node.kind === "artifact";
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
function getParticipantsForNode(node) {
|
|
32
|
+
const runtimeParticipant = { id: "runtime", alias: "Runtime", label: "Runtime" };
|
|
33
|
+
const agentParticipant = {
|
|
34
|
+
id: `agent:${node.agentId ?? "agent"}`,
|
|
35
|
+
alias: sanitizeAlias(`Agent_${node.agentId ?? "agent"}`),
|
|
36
|
+
label: `Agent${node.agentId ? `:${node.agentId}` : ""}`,
|
|
37
|
+
};
|
|
38
|
+
if (node.kind === "run") {
|
|
39
|
+
return [
|
|
40
|
+
{ id: "user", alias: "User", label: "User" },
|
|
41
|
+
runtimeParticipant,
|
|
42
|
+
agentParticipant,
|
|
43
|
+
];
|
|
44
|
+
}
|
|
45
|
+
if (node.kind === "agent") {
|
|
46
|
+
const fromAgentId = typeof node.detail.fromAgentId === "string" ? node.detail.fromAgentId : "agent";
|
|
47
|
+
return [
|
|
48
|
+
{
|
|
49
|
+
id: `agent:${fromAgentId}`,
|
|
50
|
+
alias: sanitizeAlias(`Agent_${fromAgentId}`),
|
|
51
|
+
label: `Agent:${fromAgentId}`,
|
|
52
|
+
},
|
|
53
|
+
agentParticipant,
|
|
54
|
+
];
|
|
55
|
+
}
|
|
56
|
+
if (node.kind === "approval") {
|
|
57
|
+
return [
|
|
58
|
+
runtimeParticipant,
|
|
59
|
+
{ id: "operator", alias: "Operator", label: "Operator" },
|
|
60
|
+
];
|
|
61
|
+
}
|
|
62
|
+
if (node.kind === "llm") {
|
|
63
|
+
return [
|
|
64
|
+
agentParticipant,
|
|
65
|
+
{ id: "model", alias: "Model", label: "Model" },
|
|
66
|
+
];
|
|
67
|
+
}
|
|
68
|
+
if (node.kind === "tool") {
|
|
69
|
+
return [
|
|
70
|
+
agentParticipant,
|
|
71
|
+
{
|
|
72
|
+
id: `tool:${node.label}`,
|
|
73
|
+
alias: sanitizeAlias(`Tool_${node.label}`),
|
|
74
|
+
label: `Tool:${node.label.replace(/\s+\[[^\]]+\]$/, "")}`,
|
|
75
|
+
},
|
|
76
|
+
];
|
|
77
|
+
}
|
|
78
|
+
if (node.kind === "skill") {
|
|
79
|
+
return [
|
|
80
|
+
agentParticipant,
|
|
81
|
+
{ id: "skill", alias: "Skill", label: "Skill" },
|
|
82
|
+
];
|
|
83
|
+
}
|
|
84
|
+
if (node.kind === "recovery") {
|
|
85
|
+
return [
|
|
86
|
+
runtimeParticipant,
|
|
87
|
+
agentParticipant,
|
|
88
|
+
];
|
|
89
|
+
}
|
|
90
|
+
if (node.kind === "artifact") {
|
|
91
|
+
return [
|
|
92
|
+
runtimeParticipant,
|
|
93
|
+
{ id: "artifact", alias: "ArtifactStore", label: "ArtifactStore" },
|
|
94
|
+
];
|
|
95
|
+
}
|
|
96
|
+
return [runtimeParticipant, agentParticipant];
|
|
97
|
+
}
|
|
98
|
+
function renderArrowForNode(node) {
|
|
99
|
+
if (node.kind === "run" && node.status === "started") {
|
|
100
|
+
return { from: "User", to: "Runtime", text: node.label };
|
|
101
|
+
}
|
|
102
|
+
if (node.kind === "run" && (node.status === "completed" || node.status === "failed")) {
|
|
103
|
+
return { from: "Runtime", to: "User", text: node.label };
|
|
104
|
+
}
|
|
105
|
+
if (node.kind === "agent") {
|
|
106
|
+
const fromAgentId = typeof node.detail.fromAgentId === "string" ? node.detail.fromAgentId : "agent";
|
|
107
|
+
return {
|
|
108
|
+
from: sanitizeAlias(`Agent_${fromAgentId}`),
|
|
109
|
+
to: sanitizeAlias(`Agent_${node.agentId ?? "agent"}`),
|
|
110
|
+
text: node.label,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
if (node.kind === "approval" && node.status === "waiting") {
|
|
114
|
+
return { from: "Runtime", to: "Operator", text: node.label };
|
|
115
|
+
}
|
|
116
|
+
if (node.kind === "approval" && node.status === "resolved") {
|
|
117
|
+
return { from: "Operator", to: "Runtime", text: node.label };
|
|
118
|
+
}
|
|
119
|
+
if (node.kind === "recovery") {
|
|
120
|
+
return { from: "Runtime", to: sanitizeAlias(`Agent_${node.agentId ?? "agent"}`), text: node.label };
|
|
121
|
+
}
|
|
122
|
+
if (node.kind === "llm") {
|
|
123
|
+
return {
|
|
124
|
+
from: sanitizeAlias(`Agent_${node.agentId ?? "agent"}`),
|
|
125
|
+
to: "Model",
|
|
126
|
+
text: node.label,
|
|
127
|
+
dashed: node.status === "completed" || node.status === "failed",
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
if (node.kind === "tool") {
|
|
131
|
+
return {
|
|
132
|
+
from: sanitizeAlias(`Agent_${node.agentId ?? "agent"}`),
|
|
133
|
+
to: sanitizeAlias(`Tool_${node.label}`),
|
|
134
|
+
text: node.label,
|
|
135
|
+
dashed: node.status === "completed" || node.status === "failed",
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
if (node.kind === "skill") {
|
|
139
|
+
return {
|
|
140
|
+
from: sanitizeAlias(`Agent_${node.agentId ?? "agent"}`),
|
|
141
|
+
to: "Skill",
|
|
142
|
+
text: node.label,
|
|
143
|
+
dashed: node.status === "completed" || node.status === "failed",
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
if (node.kind === "artifact") {
|
|
147
|
+
return { from: "Runtime", to: "ArtifactStore", text: node.label };
|
|
148
|
+
}
|
|
149
|
+
return { from: "Runtime", to: sanitizeAlias(`Agent_${node.agentId ?? "agent"}`), text: node.label };
|
|
150
|
+
}
|
|
151
|
+
export function exportFlowGraphToSequenceMermaid(graph, options = {}) {
|
|
152
|
+
const nodes = selectNodes(graph, options);
|
|
153
|
+
const lines = ["sequenceDiagram"];
|
|
154
|
+
const participants = new Map();
|
|
155
|
+
for (const node of nodes) {
|
|
156
|
+
for (const participant of getParticipantsForNode(node)) {
|
|
157
|
+
participants.set(participant.id, participant);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
for (const participant of participants.values()) {
|
|
161
|
+
lines.push(` participant ${participant.alias} as ${escapeLabel(participant.label)}`);
|
|
162
|
+
}
|
|
163
|
+
for (const node of nodes) {
|
|
164
|
+
const arrow = renderArrowForNode(node);
|
|
165
|
+
const connector = arrow.dashed ? "-->>" : "->>";
|
|
166
|
+
lines.push(` ${arrow.from}${connector}${arrow.to}: ${escapeLabel(node.label)}`);
|
|
167
|
+
}
|
|
168
|
+
return lines.join("\n");
|
|
169
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { buildFlowGraph } from "./build-flow-graph.js";
|
|
2
|
+
export { exportFlowGraphToMermaid } from "./export-mermaid.js";
|
|
3
|
+
export { exportFlowGraphToSequenceMermaid } from "./export-sequence-mermaid.js";
|
|
4
|
+
export type { BuildFlowGraphInput, FlowEdge, FlowEdgeKind, FlowGraph, FlowGraphMermaidOptions, FlowGraphSequenceMermaidOptions, FlowGroup, FlowGroupKind, FlowNode, FlowNodeKind, FlowNodeLayer, FlowNodeStatus, } from "./types.js";
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { HarnessEvent, RuntimeTimelineItem } from "../contracts/types.js";
|
|
2
|
+
import type { UpstreamTimelineProjection } from "../upstream-events.js";
|
|
3
|
+
export type FlowNodeLayer = "runtime" | "execution" | "attempt" | "detail";
|
|
4
|
+
export type FlowNodeKind = "run" | "agent" | "queue" | "approval" | "recovery" | "artifact" | "llm" | "tool" | "skill" | "memory" | "chain" | "result" | "thinking" | "other";
|
|
5
|
+
export type FlowNodeStatus = "pending" | "started" | "completed" | "failed" | "waiting" | "resolved" | "skipped";
|
|
6
|
+
export type FlowEdgeKind = "sequence" | "contains" | "approval" | "resume" | "retry" | "fallback" | "result" | "spawn";
|
|
7
|
+
export type FlowGroupKind = "segment" | "approval-window" | "attempt-set" | "agent-scope";
|
|
8
|
+
export type FlowNode = {
|
|
9
|
+
id: string;
|
|
10
|
+
layer: FlowNodeLayer;
|
|
11
|
+
kind: FlowNodeKind;
|
|
12
|
+
label: string;
|
|
13
|
+
status: FlowNodeStatus;
|
|
14
|
+
threadId: string;
|
|
15
|
+
runId: string;
|
|
16
|
+
agentId?: string;
|
|
17
|
+
startedAt?: string;
|
|
18
|
+
endedAt?: string;
|
|
19
|
+
sequenceStart?: number;
|
|
20
|
+
sequenceEnd?: number;
|
|
21
|
+
parentNodeId?: string;
|
|
22
|
+
groupId?: string;
|
|
23
|
+
sourceEventIds: string[];
|
|
24
|
+
detail: Record<string, unknown>;
|
|
25
|
+
};
|
|
26
|
+
export type FlowEdge = {
|
|
27
|
+
id: string;
|
|
28
|
+
from: string;
|
|
29
|
+
to: string;
|
|
30
|
+
kind: FlowEdgeKind;
|
|
31
|
+
label?: string;
|
|
32
|
+
condition?: string;
|
|
33
|
+
sourceEventIds: string[];
|
|
34
|
+
confidence?: number;
|
|
35
|
+
};
|
|
36
|
+
export type FlowGroup = {
|
|
37
|
+
id: string;
|
|
38
|
+
kind: FlowGroupKind;
|
|
39
|
+
label: string;
|
|
40
|
+
nodeIds: string[];
|
|
41
|
+
startedAt?: string;
|
|
42
|
+
endedAt?: string;
|
|
43
|
+
};
|
|
44
|
+
export type FlowGraph = {
|
|
45
|
+
graphId: string;
|
|
46
|
+
scope: "run" | "thread";
|
|
47
|
+
threadId: string;
|
|
48
|
+
runId: string;
|
|
49
|
+
nodes: FlowNode[];
|
|
50
|
+
edges: FlowEdge[];
|
|
51
|
+
groups: FlowGroup[];
|
|
52
|
+
metadata: Record<string, unknown>;
|
|
53
|
+
};
|
|
54
|
+
export type BuildFlowGraphInput = {
|
|
55
|
+
threadId?: string;
|
|
56
|
+
runId?: string;
|
|
57
|
+
scope?: FlowGraph["scope"];
|
|
58
|
+
runtimeEvents?: readonly HarnessEvent[];
|
|
59
|
+
runtimeTimeline?: readonly RuntimeTimelineItem[];
|
|
60
|
+
upstreamEvents?: readonly unknown[];
|
|
61
|
+
upstreamProjections?: readonly UpstreamTimelineProjection[];
|
|
62
|
+
metadata?: Record<string, unknown>;
|
|
63
|
+
};
|
|
64
|
+
export type FlowGraphMermaidOptions = {
|
|
65
|
+
view?: "product" | "debug";
|
|
66
|
+
direction?: "TD" | "LR";
|
|
67
|
+
includeGroups?: boolean;
|
|
68
|
+
includeDetails?: boolean;
|
|
69
|
+
includeKinds?: readonly FlowNodeKind[];
|
|
70
|
+
includeEdgeKinds?: readonly FlowEdgeKind[];
|
|
71
|
+
};
|
|
72
|
+
export type FlowGraphSequenceMermaidOptions = {
|
|
73
|
+
view?: "product" | "debug";
|
|
74
|
+
includeKinds?: readonly FlowNodeKind[];
|
|
75
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
export { AgentHarnessRuntime, cancelRun, createAgentHarness, createUpstreamTimelineReducer, createToolMcpServer, deleteSession, describeInventory, getAgent, getApproval, getRequest, getHealth, listMemories, getSession, listAgentSkills, listApprovals, listRequests, listSessions, memorize, normalizeUserChatInput, recall, removeMemory, resolveApproval, run, serveToolsOverStdio, subscribe, stop, updateMemory, } from "./api.js";
|
|
2
|
-
export type {
|
|
1
|
+
export { AgentHarnessAcpServer, AgentHarnessRuntime, buildFlowGraph, cancelRun, createAgentHarness, createAcpServer, createUpstreamTimelineReducer, createToolMcpServer, deleteSession, describeInventory, exportEvaluationBundle, getArtifact, getAgent, getApproval, getRequest, getHealth, listMemories, getSession, listAgentSkills, listArtifacts, listApprovals, listRequests, listSessions, memorize, normalizeUserChatInput, recall, removeMemory, resolveApproval, run, serveToolsOverStdio, subscribe, stop, updateMemory, exportFlowGraphToMermaid, exportFlowGraphToSequenceMermaid, } from "./api.js";
|
|
2
|
+
export type { AcpApproval, AcpArtifact, AcpEventNotification, AcpJsonRpcError, AcpJsonRpcRequest, AcpJsonRpcResponse, AcpJsonRpcSuccess, AcpRequestRecord, AcpRunRequestParams, AcpServerCapabilities, AcpSessionRecord, } from "./acp.js";
|
|
3
|
+
export type { ListMemoriesInput, ListMemoriesResult, MemoryDecision, MemoryKind, MemoryRecord, MemoryScope, MemorizeInput, MemorizeResult, NormalizeUserChatInputOptions, RecallInput, RecallResult, RemoveMemoryInput, RuntimeEvaluationExport, RuntimeEvaluationExportInput, UpdateMemoryInput, UserChatInput, UserChatMessage, } from "./api.js";
|
|
4
|
+
export type { BuildFlowGraphInput, FlowEdge, FlowEdgeKind, FlowGraph, FlowGraphMermaidOptions, FlowGraphSequenceMermaidOptions, FlowGroup, FlowGroupKind, FlowNode, FlowNodeKind, FlowNodeLayer, FlowNodeStatus, } from "./flow/index.js";
|
|
3
5
|
export type { ToolMcpServerOptions } from "./mcp.js";
|
|
4
6
|
export { tool } from "./tools.js";
|
|
5
7
|
export type { UpstreamTimelineProjection, UpstreamTimelineReducer } from "./upstream-events.js";
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { AgentHarnessRuntime, cancelRun, createAgentHarness, createUpstreamTimelineReducer, createToolMcpServer, deleteSession, describeInventory, getAgent, getApproval, getRequest, getHealth, listMemories, getSession, listAgentSkills, listApprovals, listRequests, listSessions, memorize, normalizeUserChatInput, recall, removeMemory, resolveApproval, run, serveToolsOverStdio, subscribe, stop, updateMemory, } from "./api.js";
|
|
1
|
+
export { AgentHarnessAcpServer, AgentHarnessRuntime, buildFlowGraph, cancelRun, createAgentHarness, createAcpServer, createUpstreamTimelineReducer, createToolMcpServer, deleteSession, describeInventory, exportEvaluationBundle, getArtifact, getAgent, getApproval, getRequest, getHealth, listMemories, getSession, listAgentSkills, listArtifacts, listApprovals, listRequests, listSessions, memorize, normalizeUserChatInput, recall, removeMemory, resolveApproval, run, 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.157";
|
package/dist/package-version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const AGENT_HARNESS_VERSION = "0.0.
|
|
1
|
+
export const AGENT_HARNESS_VERSION = "0.0.157";
|
|
@@ -69,6 +69,7 @@ export declare class FilePersistence implements RuntimePersistence {
|
|
|
69
69
|
resolveApproval(threadId: string, runId: string, approvalId: string, status: InternalApprovalRecord["status"]): Promise<InternalApprovalRecord>;
|
|
70
70
|
createArtifact(threadId: string, runId: string, artifact: ArtifactRecord, content: unknown): Promise<ArtifactRecord>;
|
|
71
71
|
listArtifacts(threadId: string, runId: string): Promise<ArtifactListing>;
|
|
72
|
+
readArtifact(threadId: string, runId: string, artifactPath: string): Promise<unknown>;
|
|
72
73
|
appendThreadMessage(threadId: string, message: TranscriptMessage): Promise<void>;
|
|
73
74
|
listThreadMessages(threadId: string, limit?: number): Promise<TranscriptMessage[]>;
|
|
74
75
|
saveRecoveryIntent(threadId: string, runId: string, intent: RecoveryIntent): Promise<void>;
|
|
@@ -328,7 +328,9 @@ export class FilePersistence {
|
|
|
328
328
|
if (!(await fileExists(eventsDir))) {
|
|
329
329
|
return [];
|
|
330
330
|
}
|
|
331
|
-
const entries = (await readdir(eventsDir))
|
|
331
|
+
const entries = (await readdir(eventsDir))
|
|
332
|
+
.filter((entry) => entry.endsWith(".json"))
|
|
333
|
+
.sort((left, right) => left.localeCompare(right));
|
|
332
334
|
return Promise.all(entries.map((entry) => readJson(path.join(eventsDir, entry))));
|
|
333
335
|
}
|
|
334
336
|
async listApprovals(filter = {}) {
|
|
@@ -460,6 +462,13 @@ export class FilePersistence {
|
|
|
460
462
|
async listArtifacts(threadId, runId) {
|
|
461
463
|
return readJson(path.join(this.runDir(threadId, runId), "artifacts.json"));
|
|
462
464
|
}
|
|
465
|
+
async readArtifact(threadId, runId, artifactPath) {
|
|
466
|
+
const filePath = path.join(this.runDir(threadId, runId), artifactPath);
|
|
467
|
+
if (!(await fileExists(filePath))) {
|
|
468
|
+
return null;
|
|
469
|
+
}
|
|
470
|
+
return readJson(filePath);
|
|
471
|
+
}
|
|
463
472
|
async appendThreadMessage(threadId, message) {
|
|
464
473
|
const messagesPath = path.join(this.threadDir(threadId), "messages.json");
|
|
465
474
|
const current = (await fileExists(messagesPath))
|
|
@@ -120,6 +120,7 @@ export interface RuntimePersistence {
|
|
|
120
120
|
}): Promise<void>;
|
|
121
121
|
setRunState(threadId: string, runId: string, state: RunState, checkpointRef?: string | null): Promise<void>;
|
|
122
122
|
appendEvent(event: HarnessEvent): Promise<void>;
|
|
123
|
+
listRunEvents(threadId: string, runId: string): Promise<HarnessEvent[]>;
|
|
123
124
|
listSessions(filter?: ThreadSummaryFilter): Promise<ThreadSummary[]>;
|
|
124
125
|
listRuns(filter?: RunSummaryFilter): Promise<RunSummary[]>;
|
|
125
126
|
getRun(runId: string): Promise<RunSummary | null>;
|
|
@@ -147,6 +148,7 @@ export interface RuntimePersistence {
|
|
|
147
148
|
resolveApproval(threadId: string, runId: string, approvalId: string, status: InternalApprovalRecord["status"]): Promise<InternalApprovalRecord>;
|
|
148
149
|
createArtifact(threadId: string, runId: string, artifact: ArtifactRecord, content: unknown): Promise<ArtifactRecord>;
|
|
149
150
|
listArtifacts(threadId: string, runId: string): Promise<ArtifactListing>;
|
|
151
|
+
readArtifact(threadId: string, runId: string, artifactPath: string): Promise<unknown>;
|
|
150
152
|
appendThreadMessage(threadId: string, message: TranscriptMessage): Promise<void>;
|
|
151
153
|
listThreadMessages(threadId: string, limit?: number): Promise<TranscriptMessage[]>;
|
|
152
154
|
saveRecoveryIntent(threadId: string, runId: string, intent: RecoveryIntent): Promise<void>;
|
|
@@ -14,5 +14,5 @@ export declare function wrapResolvedToolWithModelFacingName<T>(resolvedTool: T,
|
|
|
14
14
|
export declare function hasCallableToolHandler(value: unknown): value is ResolvedToolLike;
|
|
15
15
|
export declare function normalizeResolvedToolSchema(resolvedTool: ResolvedToolLike): Record<string, unknown> | {
|
|
16
16
|
parse?: (input: unknown) => unknown;
|
|
17
|
-
} | z.ZodObject<{},
|
|
17
|
+
} | z.ZodObject<{}, z.core.$loose> | undefined;
|
|
18
18
|
export declare function asStructuredExecutableTool(resolvedTool: unknown, modelFacingName: string, description: string): unknown;
|
|
@@ -63,6 +63,7 @@ export declare class AgentRuntimeAdapter {
|
|
|
63
63
|
private resolveTools;
|
|
64
64
|
private getToolNameMapping;
|
|
65
65
|
private resolveFilesystemBackend;
|
|
66
|
+
private resolveFilesystemRootDir;
|
|
66
67
|
private resolveBuiltinMiddlewareBackend;
|
|
67
68
|
private createDeclaredMiddlewareResolverOptions;
|
|
68
69
|
private createAssemblyResolvers;
|
|
@@ -75,7 +76,10 @@ export declare class AgentRuntimeAdapter {
|
|
|
75
76
|
private createLangChainRunnable;
|
|
76
77
|
private createRunnable;
|
|
77
78
|
private createDeepAgentRunnable;
|
|
78
|
-
|
|
79
|
+
private buildRunnableCacheKey;
|
|
80
|
+
create(binding: CompiledAgentBinding, options?: {
|
|
81
|
+
threadId?: string;
|
|
82
|
+
}): Promise<RunnableLike>;
|
|
79
83
|
invoke(binding: CompiledAgentBinding, input: MessageContent, threadId: string, runId: string, resumePayload?: unknown, history?: TranscriptMessage[], options?: {
|
|
80
84
|
context?: Record<string, unknown>;
|
|
81
85
|
state?: Record<string, unknown>;
|