@botbotgo/agent-harness 0.0.475 → 0.0.476

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 (227) hide show
  1. package/README.md +3 -1234
  2. package/README.zh.md +3 -1191
  3. package/dist/acp.js +1 -1
  4. package/dist/api.js +1 -404
  5. package/dist/benchmark/checkpoint-resume-cost-benchmark.js +1 -55
  6. package/dist/benchmark/deepagent-local-model-benchmark.js +2 -35
  7. package/dist/benchmark/upstream-runtime-ab-benchmark.js +1 -179
  8. package/dist/cli/chat-interactive.js +25 -244
  9. package/dist/cli/chat-rendering.js +6 -100
  10. package/dist/cli/chat-stream.js +23 -512
  11. package/dist/cli/chat-ui.js +21 -199
  12. package/dist/cli/chat-workspace.js +2 -210
  13. package/dist/cli/main.js +21 -428
  14. package/dist/cli/managed-service-commands.js +9 -63
  15. package/dist/cli/managed-service.js +2 -137
  16. package/dist/cli/options-init-chat.js +1 -108
  17. package/dist/cli/options-runtime.js +1 -158
  18. package/dist/cli/options-serve.js +1 -282
  19. package/dist/cli/options.js +2 -19
  20. package/dist/cli/process-guards.js +1 -139
  21. package/dist/cli/request-tree.js +7 -296
  22. package/dist/cli/runtime-commands.js +12 -258
  23. package/dist/cli/runtime-output.js +16 -155
  24. package/dist/cli/server-commands.js +16 -270
  25. package/dist/cli/workspace.js +1 -67
  26. package/dist/cli.js +1 -7
  27. package/dist/client/acp.js +1 -1
  28. package/dist/client/in-process.js +1 -67
  29. package/dist/client/index.js +1 -2
  30. package/dist/client/types.js +0 -1
  31. package/dist/client.js +1 -1
  32. package/dist/contracts/core.js +1 -1
  33. package/dist/contracts/runtime-evaluation.js +0 -1
  34. package/dist/contracts/runtime-memory.js +0 -1
  35. package/dist/contracts/runtime-observability.js +0 -1
  36. package/dist/contracts/runtime-requests.js +0 -1
  37. package/dist/contracts/runtime-scheduling.js +0 -1
  38. package/dist/contracts/runtime.js +1 -27
  39. package/dist/contracts/types.js +1 -3
  40. package/dist/contracts/workspace.js +0 -1
  41. package/dist/flow/build-flow-graph.js +1 -50
  42. package/dist/flow/export-mermaid.js +2 -464
  43. package/dist/flow/export-sequence-mermaid.js +2 -325
  44. package/dist/flow/flow-graph-normalization.js +1 -214
  45. package/dist/flow/flow-graph-runtime.js +1 -107
  46. package/dist/flow/flow-graph-upstream.js +1 -494
  47. package/dist/flow/index.js +1 -3
  48. package/dist/flow/types.js +0 -1
  49. package/dist/index.js +1 -5
  50. package/dist/init-project.js +1 -1
  51. package/dist/knowledge/config.js +1 -32
  52. package/dist/knowledge/contracts.js +0 -1
  53. package/dist/knowledge/index.js +1 -2
  54. package/dist/knowledge/module.js +12 -909
  55. package/dist/knowledge/procedural/config.js +1 -125
  56. package/dist/knowledge/procedural/index.js +1 -2
  57. package/dist/knowledge/procedural/manager.js +9 -345
  58. package/dist/mcp.js +1 -2
  59. package/dist/package-version.d.ts +1 -1
  60. package/dist/package-version.js +1 -2
  61. package/dist/persistence/file-store.js +3 -758
  62. package/dist/persistence/sqlite-request-context-store.js +5 -54
  63. package/dist/persistence/sqlite-request-queue-store.js +10 -108
  64. package/dist/persistence/sqlite-runtime.js +1 -86
  65. package/dist/persistence/sqlite-store.js +62 -810
  66. package/dist/persistence/types.js +0 -1
  67. package/dist/projections/presentation.js +37 -206
  68. package/dist/projections/request-events.js +2 -502
  69. package/dist/projections/upstream-events.js +1 -201
  70. package/dist/protocol/a2a/http-discovery.js +1 -178
  71. package/dist/protocol/a2a/http-rpc.js +6 -622
  72. package/dist/protocol/a2a/http.js +1 -138
  73. package/dist/protocol/a2a/task-state.js +3 -317
  74. package/dist/protocol/acp/client.js +8 -294
  75. package/dist/protocol/acp/harness-client.js +1 -218
  76. package/dist/protocol/acp/http.js +5 -130
  77. package/dist/protocol/acp/server.js +1 -310
  78. package/dist/protocol/acp/stdio.js +2 -69
  79. package/dist/protocol/ag-ui/http.js +3 -378
  80. package/dist/protocol/mcp/server.js +1 -428
  81. package/dist/resource/backend/workspace-scoped-backend.js +1 -319
  82. package/dist/resource/isolation.js +1 -237
  83. package/dist/resource/mcp/tool-support.js +3 -296
  84. package/dist/resource/mcp-tool-support.js +1 -2
  85. package/dist/resource/providers/resource-provider.js +1 -215
  86. package/dist/resource/resource-impl.js +1 -3
  87. package/dist/resource/resource-types.js +0 -1
  88. package/dist/resource/resource.js +1 -1
  89. package/dist/resource/sources.js +1 -247
  90. package/dist/resource/tools/function-tool-resolver.js +2 -272
  91. package/dist/runtime/adapter/compat/deepagent-compat.js +1 -29
  92. package/dist/runtime/adapter/compat/openai-compatible.js +1 -55
  93. package/dist/runtime/adapter/direct-builtin-utility.js +2 -90
  94. package/dist/runtime/adapter/flow/execution-context.js +1 -71
  95. package/dist/runtime/adapter/flow/invocation-flow.js +8 -425
  96. package/dist/runtime/adapter/flow/invoke-runtime.js +1 -20
  97. package/dist/runtime/adapter/flow/stream-runtime.js +11 -1395
  98. package/dist/runtime/adapter/invocation-result.js +2 -473
  99. package/dist/runtime/adapter/local-tool-invocation.js +6 -638
  100. package/dist/runtime/adapter/middleware/context-hygiene.js +1 -83
  101. package/dist/runtime/adapter/middleware-assembly.js +5 -477
  102. package/dist/runtime/adapter/model/invocation-request.js +3 -183
  103. package/dist/runtime/adapter/model/message-assembly.js +1 -28
  104. package/dist/runtime/adapter/model/model-providers.js +23 -1115
  105. package/dist/runtime/adapter/model/prompted-json-tool-call-capture.js +1 -40
  106. package/dist/runtime/adapter/model/prompted-json-tool-policy.js +1 -22
  107. package/dist/runtime/adapter/resilience.js +1 -104
  108. package/dist/runtime/adapter/runtime-adapter-support.js +3 -141
  109. package/dist/runtime/adapter/runtime-shell.js +5 -166
  110. package/dist/runtime/adapter/stream-event-projection.js +2 -622
  111. package/dist/runtime/adapter/stream-text-consumption.js +1 -18
  112. package/dist/runtime/adapter/terminal-status.js +2 -67
  113. package/dist/runtime/adapter/tool/builtin-middleware-tools.js +6 -627
  114. package/dist/runtime/adapter/tool/declared-middleware.js +1 -154
  115. package/dist/runtime/adapter/tool/interrupt-policy.js +1 -34
  116. package/dist/runtime/adapter/tool/provider-tool.js +1 -25
  117. package/dist/runtime/adapter/tool/resolved-tool.js +1 -225
  118. package/dist/runtime/adapter/tool/tool-arguments.js +3 -486
  119. package/dist/runtime/adapter/tool/tool-hitl.js +1 -346
  120. package/dist/runtime/adapter/tool/tool-name-mapping.js +1 -128
  121. package/dist/runtime/adapter/tool/tool-output-artifacts.js +2 -88
  122. package/dist/runtime/adapter/tool/tool-replay.js +1 -37
  123. package/dist/runtime/adapter/tool-resolution.js +1 -86
  124. package/dist/runtime/adapter/upstream-configurable-keys.js +1 -2
  125. package/dist/runtime/agent-runtime-adapter.js +60 -2338
  126. package/dist/runtime/agent-runtime-assembly.js +7 -249
  127. package/dist/runtime/env/runtime-env.js +1 -62
  128. package/dist/runtime/harness/background-runtime.js +1 -8
  129. package/dist/runtime/harness/bindings.js +1 -58
  130. package/dist/runtime/harness/events/event-bus.js +1 -16
  131. package/dist/runtime/harness/events/event-sink.js +1 -61
  132. package/dist/runtime/harness/events/events.js +1 -80
  133. package/dist/runtime/harness/events/listener-runtime.js +1 -13
  134. package/dist/runtime/harness/events/runtime-event-operations.js +1 -9
  135. package/dist/runtime/harness/events/streaming.js +1 -100
  136. package/dist/runtime/harness/events/timeline.js +1 -52
  137. package/dist/runtime/harness/public-shapes.js +1 -186
  138. package/dist/runtime/harness/run/artifact-paths.js +1 -15
  139. package/dist/runtime/harness/run/governance.js +1 -295
  140. package/dist/runtime/harness/run/helpers.js +1 -71
  141. package/dist/runtime/harness/run/inspection.js +1 -409
  142. package/dist/runtime/harness/run/operator-overview.js +1 -80
  143. package/dist/runtime/harness/run/queue-diagnostics.js +1 -15
  144. package/dist/runtime/harness/run/recovery.js +1 -162
  145. package/dist/runtime/harness/run/resources.js +1 -60
  146. package/dist/runtime/harness/run/resume.js +1 -56
  147. package/dist/runtime/harness/run/routing.js +1 -48
  148. package/dist/runtime/harness/run/run-lifecycle.js +1 -66
  149. package/dist/runtime/harness/run/run-operations.js +1 -217
  150. package/dist/runtime/harness/run/run-queue.js +1 -43
  151. package/dist/runtime/harness/run/run-slot-acquisition.js +1 -157
  152. package/dist/runtime/harness/run/session-records.js +1 -97
  153. package/dist/runtime/harness/run/start-run.js +1 -120
  154. package/dist/runtime/harness/run/startup-runtime.js +1 -69
  155. package/dist/runtime/harness/run/stream-run.js +8 -1418
  156. package/dist/runtime/harness/run/surface-semantics.js +1 -79
  157. package/dist/runtime/harness/runtime-defaults.js +1 -39
  158. package/dist/runtime/harness/system/boundary-analysis.js +1 -234
  159. package/dist/runtime/harness/system/health-monitor.js +1 -258
  160. package/dist/runtime/harness/system/inventory.js +1 -129
  161. package/dist/runtime/harness/system/mem0-ingestion-sync.js +5 -345
  162. package/dist/runtime/harness/system/policy-engine.js +1 -175
  163. package/dist/runtime/harness/system/runtime-memory-candidates.js +4 -110
  164. package/dist/runtime/harness/system/runtime-memory-consolidation.js +1 -51
  165. package/dist/runtime/harness/system/runtime-memory-manager.js +10 -693
  166. package/dist/runtime/harness/system/runtime-memory-policy.js +1 -155
  167. package/dist/runtime/harness/system/runtime-memory-records.js +11 -577
  168. package/dist/runtime/harness/system/runtime-memory-sync.js +5 -206
  169. package/dist/runtime/harness/system/session-memory-sync.js +3 -113
  170. package/dist/runtime/harness/system/skill-requirements.js +1 -112
  171. package/dist/runtime/harness/system/store.js +9 -365
  172. package/dist/runtime/harness/tool-gateway/index.js +1 -2
  173. package/dist/runtime/harness/tool-gateway/policy.js +1 -45
  174. package/dist/runtime/harness/tool-gateway/validation.js +1 -176
  175. package/dist/runtime/harness/tool-schema.js +1 -3
  176. package/dist/runtime/harness.js +3 -1490
  177. package/dist/runtime/index.js +1 -3
  178. package/dist/runtime/layout/runtime-layout.js +1 -31
  179. package/dist/runtime/maintenance/checkpoint-maintenance.js +2 -178
  180. package/dist/runtime/maintenance/file-checkpoint-saver.js +1 -106
  181. package/dist/runtime/maintenance/runtime-record-maintenance.js +2 -169
  182. package/dist/runtime/maintenance/sqlite-checkpoint-saver.js +4 -289
  183. package/dist/runtime/parsing/output-content.js +10 -550
  184. package/dist/runtime/parsing/output-parsing.js +1 -4
  185. package/dist/runtime/parsing/output-recovery.js +3 -213
  186. package/dist/runtime/parsing/output-tool-args.js +7 -663
  187. package/dist/runtime/parsing/stream-event-parsing.js +3 -362
  188. package/dist/runtime/prompts/runtime-prompts.js +4 -73
  189. package/dist/runtime/scheduling/system-schedule-manager.js +11 -532
  190. package/dist/runtime/skills/skill-metadata.js +1 -197
  191. package/dist/runtime/startup-tracing.js +2 -37
  192. package/dist/runtime/support/compiled-binding.js +1 -290
  193. package/dist/runtime/support/embedding-models.js +1 -118
  194. package/dist/runtime/support/harness-support.js +5 -137
  195. package/dist/runtime/support/llamaindex.js +1 -108
  196. package/dist/runtime/support/runtime-adapter-options.js +1 -29
  197. package/dist/runtime/support/runtime-factories.js +1 -51
  198. package/dist/runtime/support/vector-stores.js +9 -270
  199. package/dist/scaffold/init-project.js +54 -233
  200. package/dist/tooling/extensions.js +1 -311
  201. package/dist/tooling/module-loader.js +1 -55
  202. package/dist/tools.js +1 -176
  203. package/dist/utils/agent-display.js +1 -18
  204. package/dist/utils/bundled-text.js +4 -39
  205. package/dist/utils/compiled-binding.js +1 -33
  206. package/dist/utils/fs.js +2 -45
  207. package/dist/utils/id.js +1 -9
  208. package/dist/utils/message-content.js +1 -30
  209. package/dist/utils/object.js +1 -6
  210. package/dist/workspace/agent-binding-compiler.js +3 -613
  211. package/dist/workspace/compile.js +1 -472
  212. package/dist/workspace/framework-contract-validation.js +2 -322
  213. package/dist/workspace/index.js +1 -1
  214. package/dist/workspace/object-loader-paths.js +1 -71
  215. package/dist/workspace/object-loader-readers.js +1 -187
  216. package/dist/workspace/object-loader.js +1 -754
  217. package/dist/workspace/resource-compilers.js +1 -374
  218. package/dist/workspace/support/agent-capabilities.js +1 -37
  219. package/dist/workspace/support/agent-execution-config.js +1 -44
  220. package/dist/workspace/support/discovery.js +1 -147
  221. package/dist/workspace/support/source-collectors.js +1 -30
  222. package/dist/workspace/support/source-protocols.js +2 -192
  223. package/dist/workspace/support/workspace-ref-utils.js +1 -362
  224. package/dist/workspace/tool-hydration.js +1 -280
  225. package/dist/workspace/validate.js +1 -99
  226. package/dist/workspace/yaml-object-reader.js +1 -285
  227. package/package.json +7 -3
package/dist/acp.js CHANGED
@@ -1 +1 @@
1
- export * from "./protocol/acp/server.js";
1
+ export*from"./protocol/acp/server.js";
package/dist/api.js CHANGED
@@ -1,404 +1 @@
1
- import { AgentHarnessRuntime } from "./runtime/harness.js";
2
- import { buildFlowGraph, exportFlowGraphToMermaid as exportFlowGraphFromGraph, exportFlowGraphToSequenceMermaid as exportSequenceGraphFromGraph, } from "./flow/index.js";
3
- import { serveA2aOverHttp } from "./protocol/a2a/http.js";
4
- import { serveAgUiOverHttp } from "./protocol/ag-ui/http.js";
5
- import { serveAcpOverHttp } from "./protocol/acp/http.js";
6
- import { serveAcpOverStdio } from "./protocol/acp/stdio.js";
7
- import { normalizeMessageContent } from "./utils/message-content.js";
8
- import { loadWorkspace } from "./workspace/compile.js";
9
- import { traceStartupStage } from "./runtime/startup-tracing.js";
10
- export { AgentHarnessAcpServer, createAcpServer } from "./acp.js";
11
- export { createAcpStdioClient } from "./protocol/acp/client.js";
12
- export { AgentHarnessRuntime } from "./runtime/harness.js";
13
- export { createUpstreamTimelineReducer } from "./projections/upstream-events.js";
14
- function toApprovalRecord(record) {
15
- return {
16
- approvalId: record.approvalId,
17
- pendingActionId: record.pendingActionId,
18
- sessionId: record.sessionId,
19
- requestId: record.requestId,
20
- toolName: record.toolName,
21
- ...(record.approvalReason ? { approvalReason: record.approvalReason } : {}),
22
- status: record.status,
23
- requestedAt: record.requestedAt,
24
- resolvedAt: record.resolvedAt,
25
- allowedDecisions: record.allowedDecisions,
26
- inputPreview: record.inputPreview,
27
- };
28
- }
29
- function toPublicEventType(eventType) {
30
- return eventType;
31
- }
32
- function toPublicEvent(event) {
33
- return {
34
- eventId: event.eventId,
35
- eventType: toPublicEventType(event.eventType),
36
- timestamp: event.timestamp,
37
- sessionId: event.sessionId,
38
- requestId: event.requestId,
39
- sequence: event.sequence,
40
- source: event.source,
41
- payload: event.payload,
42
- };
43
- }
44
- function toPublicTraceItem(input) {
45
- const typed = typeof input.item === "object" && input.item !== null
46
- ? input.item
47
- : null;
48
- if (!typed?.surfaceItem) {
49
- return null;
50
- }
51
- return {
52
- sessionId: input.sessionId,
53
- requestId: input.requestId,
54
- surfaceItem: typed.surfaceItem,
55
- event: typed.event,
56
- };
57
- }
58
- function toPublicRequestListeners(listeners) {
59
- if (!listeners) {
60
- return undefined;
61
- }
62
- return {
63
- onEvent: listeners.onEvent ? async (event) => listeners.onEvent(toPublicEvent(event)) : undefined,
64
- onUpstreamEvent: listeners.onUpstreamEvent,
65
- onTraceItem: listeners.onTraceItem
66
- ? async (item) => listeners.onTraceItem({
67
- sessionId: item.sessionId,
68
- requestId: item.requestId,
69
- surfaceItem: item.surfaceItem,
70
- event: item.event,
71
- })
72
- : undefined,
73
- onPlanState: listeners.onPlanState,
74
- };
75
- }
76
- function toRequestArtifactListing(listing) {
77
- return {
78
- sessionId: listing.sessionId,
79
- requestId: listing.requestId,
80
- items: listing.items,
81
- };
82
- }
83
- function toRequestPackage(pkg) {
84
- return {
85
- session: pkg.session,
86
- request: pkg.request,
87
- approvals: pkg.approvals.map(toApprovalRecord),
88
- transcript: pkg.transcript,
89
- events: pkg.events.map(toPublicEvent),
90
- artifacts: pkg.artifacts,
91
- governance: pkg.governance,
92
- ...(pkg.runtimeHealth ? { runtimeHealth: pkg.runtimeHealth } : {}),
93
- };
94
- }
95
- function toPublicRequestResult(result) {
96
- return {
97
- sessionId: result.sessionId,
98
- requestId: result.requestId,
99
- state: result.state,
100
- output: result.output,
101
- finalMessageText: result.finalMessageText,
102
- outputContent: result.outputContent,
103
- contentBlocks: result.contentBlocks,
104
- structuredResponse: result.structuredResponse,
105
- interruptContent: result.interruptContent,
106
- agentId: result.agentId,
107
- approvalId: result.approvalId,
108
- pendingActionId: result.pendingActionId,
109
- delegationId: result.delegationId,
110
- artifacts: result.artifacts,
111
- metadata: result.metadata,
112
- };
113
- }
114
- function toInternalRequestOptions(options) {
115
- const legacyListeners = toPublicRequestListeners(options.listeners);
116
- const mergedListeners = legacyListeners || options.eventListener || options.dataListener
117
- ? {
118
- ...(legacyListeners ?? {}),
119
- ...(options.eventListener ? { eventListener: options.eventListener } : {}),
120
- ...(options.dataListener ? { dataListener: options.dataListener } : {}),
121
- }
122
- : undefined;
123
- if ("decision" in options) {
124
- return {
125
- approvalId: options.approvalId,
126
- decision: options.decision,
127
- editedInput: options.editedInput,
128
- listeners: mergedListeners,
129
- requestId: options.requestId,
130
- sessionId: options.sessionId,
131
- };
132
- }
133
- return {
134
- agentId: options.agentId,
135
- input: options.input,
136
- invocation: options.invocation,
137
- listeners: mergedListeners,
138
- priority: options.priority,
139
- sessionId: options.sessionId,
140
- };
141
- }
142
- function toInternalResumeOptions(options) {
143
- return {
144
- approvalId: options.approvalId,
145
- decision: options.decision,
146
- editedInput: options.editedInput,
147
- requestId: options.requestId,
148
- sessionId: options.sessionId,
149
- };
150
- }
151
- function toPublicRequestSummary(summary) {
152
- return {
153
- requestId: summary.requestId,
154
- sessionId: summary.sessionId,
155
- agentId: summary.agentId,
156
- parentRequestId: summary.parentRequestId,
157
- executionMode: summary.executionMode,
158
- adapterKind: summary.adapterKind,
159
- createdAt: summary.createdAt,
160
- updatedAt: summary.updatedAt,
161
- state: summary.state,
162
- checkpointRef: summary.checkpointRef,
163
- resumable: summary.resumable,
164
- startedAt: summary.startedAt,
165
- endedAt: summary.endedAt,
166
- lastActivityAt: summary.lastActivityAt,
167
- currentAgentId: summary.currentAgentId,
168
- delegationChain: summary.delegationChain,
169
- runtimeSnapshot: summary.runtimeSnapshot,
170
- };
171
- }
172
- export async function createAgentHarness(workspaceRoot = process.cwd(), options = {}) {
173
- const workspace = await traceStartupStage("createAgentHarness.loadWorkspace", () => loadWorkspace(workspaceRoot, options.load ?? {}), {
174
- workspaceRoot,
175
- });
176
- const harness = await traceStartupStage("createAgentHarness.constructRuntime", async () => new AgentHarnessRuntime(workspace, options.adapter ?? {}), {
177
- workspaceRoot,
178
- });
179
- await traceStartupStage("createAgentHarness.initializeRuntime", () => harness.initialize(), {
180
- workspaceRoot,
181
- });
182
- return harness;
183
- }
184
- export function normalizeUserChatInput(input, options = {}) {
185
- const content = typeof input === "object" && input !== null && "role" in input
186
- ? normalizeUserChatMessage(input).content
187
- : normalizeMessageContent(input);
188
- return options.invocation ? { input: content, invocation: options.invocation } : { input: content };
189
- }
190
- export async function request(runtime, options) {
191
- return toPublicRequestResult(await runtime.run(toInternalRequestOptions(options)));
192
- }
193
- export async function memorize(runtime, input) {
194
- return runtime.memorize(input);
195
- }
196
- export async function recall(runtime, input) {
197
- return runtime.recall(input);
198
- }
199
- export async function listMemories(runtime, input = {}) {
200
- return runtime.listMemories(input);
201
- }
202
- export async function updateMemory(runtime, input) {
203
- return runtime.updateMemory(input);
204
- }
205
- export async function removeMemory(runtime, input) {
206
- return runtime.removeMemory(input);
207
- }
208
- export function subscribe(runtime, listener) {
209
- return runtime.subscribe(async (event) => {
210
- await listener(toPublicEvent(event));
211
- });
212
- }
213
- export async function listSessions(runtime, filter) {
214
- return runtime.listSessions(filter);
215
- }
216
- export async function listSessionSummaries(runtime, filter) {
217
- return runtime.listSessionSummaries(filter);
218
- }
219
- export async function listRequests(runtime, filter) {
220
- return runtime.listRequests(filter);
221
- }
222
- export async function getSession(runtime, sessionId) {
223
- return runtime.getSessionRecord(sessionId);
224
- }
225
- export async function getRequest(runtime, requestId) {
226
- return runtime.getRequest(requestId);
227
- }
228
- async function buildRequestFlowGraph(runtime, input) {
229
- const request = await runtime.getRequest(input.requestId);
230
- if (!request) {
231
- throw new Error(`Request ${input.requestId} was not found.`);
232
- }
233
- if (request.sessionId !== input.sessionId) {
234
- throw new Error(`Request ${input.requestId} belongs to session ${request.sessionId}, not ${input.sessionId}.`);
235
- }
236
- const traceItems = (request.traceItems ?? [])
237
- .map((item) => toPublicTraceItem({
238
- sessionId: input.sessionId,
239
- requestId: input.requestId,
240
- item,
241
- }))
242
- .filter((item) => item !== null);
243
- return buildFlowGraph({
244
- sessionId: input.sessionId,
245
- requestId: input.requestId,
246
- runtimeTimeline: request.runtimeTimeline,
247
- upstreamEvents: traceItems,
248
- metadata: {
249
- state: request.state,
250
- ...(request.runtimeSnapshot ? { runtimeSnapshot: request.runtimeSnapshot } : {}),
251
- },
252
- });
253
- }
254
- export async function exportFlow(runtime, input) {
255
- return exportFlowGraphFromGraph(await buildRequestFlowGraph(runtime, input), {
256
- direction: "TD",
257
- includeGroups: false,
258
- includeKinds: ["agent", "llm", "tool", "skill", "memory"],
259
- });
260
- }
261
- export async function exportSequence(runtime, input) {
262
- return exportSequenceGraphFromGraph(await buildRequestFlowGraph(runtime, input));
263
- }
264
- export async function deleteSession(runtime, sessionId) {
265
- return runtime.deleteSession(sessionId);
266
- }
267
- export async function listApprovals(runtime, filter) {
268
- return (await runtime.listApprovals({
269
- requestId: filter?.requestId,
270
- status: filter?.status,
271
- sessionId: filter?.sessionId,
272
- })).map(toApprovalRecord);
273
- }
274
- export async function getApproval(runtime, approvalId) {
275
- const record = await runtime.getApproval(approvalId);
276
- return record ? toApprovalRecord(record) : null;
277
- }
278
- export async function listRequestArtifacts(runtime, input) {
279
- return toRequestArtifactListing(await runtime.listRequestArtifacts(input.sessionId, input.requestId));
280
- }
281
- export async function getArtifact(runtime, input) {
282
- return runtime.readRequestArtifact(input.sessionId, input.requestId, input.artifactPath);
283
- }
284
- export async function getRequestPlanState(runtime, input) {
285
- return runtime.getRequestPlanState(input.sessionId, input.requestId);
286
- }
287
- export async function recordArtifact(runtime, input) {
288
- return runtime.recordArtifact(input);
289
- }
290
- export async function listRequestEvents(runtime, input) {
291
- return (await runtime.listRequestEvents(input.sessionId, input.requestId)).map(toPublicEvent);
292
- }
293
- export async function listRequestTraceItems(runtime, input) {
294
- const request = await runtime.getRequest(input.requestId);
295
- if (!request) {
296
- throw new Error(`Request ${input.requestId} was not found.`);
297
- }
298
- if (request.sessionId !== input.sessionId) {
299
- throw new Error(`Request ${input.requestId} belongs to session ${request.sessionId}, not ${input.sessionId}.`);
300
- }
301
- return (request.traceItems ?? [])
302
- .map((item) => toPublicTraceItem({
303
- sessionId: input.sessionId,
304
- requestId: input.requestId,
305
- item,
306
- }))
307
- .filter((item) => item !== null);
308
- }
309
- export async function getHealth(runtime) {
310
- return runtime.getHealth();
311
- }
312
- export async function getOperatorOverview(runtime, options) {
313
- const overview = await runtime.getOperatorOverview(options);
314
- const requestOverview = {
315
- total: overview.requests.total,
316
- states: overview.requests.states,
317
- items: overview.requests.items.map(toPublicRequestSummary),
318
- };
319
- return {
320
- ...overview,
321
- approvals: {
322
- total: overview.approvals.total,
323
- items: overview.approvals.items.map(toApprovalRecord),
324
- },
325
- requests: requestOverview,
326
- };
327
- }
328
- export async function exportRequestPackage(runtime, input) {
329
- const pkg = await runtime.exportRequestPackage(input);
330
- return {
331
- ...toRequestPackage(pkg),
332
- planState: await runtime.getRequestPlanState(input.sessionId, input.requestId),
333
- };
334
- }
335
- export async function exportSessionPackage(runtime, input) {
336
- return runtime.exportSessionPackage(input);
337
- }
338
- export async function exportEvaluationBundle(runtime, input) {
339
- return runtime.exportEvaluationBundle(input);
340
- }
341
- export async function replayEvaluationBundle(runtime, input) {
342
- const replayed = await runtime.replayEvaluationBundle(input);
343
- return {
344
- ...replayed,
345
- result: toPublicRequestResult(replayed.result),
346
- };
347
- }
348
- export function serveAcpStdio(runtime, options) {
349
- return serveAcpOverStdio(runtime, options);
350
- }
351
- export async function serveAcpHttp(runtime, options) {
352
- return serveAcpOverHttp(runtime, options);
353
- }
354
- export async function serveAgUiHttp(runtime, options) {
355
- return serveAgUiOverHttp(runtime, options);
356
- }
357
- export async function serveA2aHttp(runtime, options) {
358
- return serveA2aOverHttp(runtime, options);
359
- }
360
- export function listAgentSkills(runtime, agentId, options) {
361
- return runtime.listAgentSkills(agentId, options);
362
- }
363
- export function getAgent(runtime, agentId, options) {
364
- return runtime.getAgent(agentId, options);
365
- }
366
- export function describeInventory(runtime, options) {
367
- return runtime.describeWorkspaceInventory(options);
368
- }
369
- export function analyzeBoundaries(runtime, options) {
370
- return runtime.analyzeWorkspaceBoundaries(options);
371
- }
372
- export async function resolveApproval(runtime, options) {
373
- return toPublicRequestResult(await runtime.resume(toInternalResumeOptions(options)));
374
- }
375
- export async function cancelRequest(runtime, options) {
376
- return toPublicRequestResult(await runtime.cancelRequest(options));
377
- }
378
- export async function stop(runtime) {
379
- return runtime.stop();
380
- }
381
- export async function createToolMcpServer(runtime, options) {
382
- return runtime.createToolMcpServer(options);
383
- }
384
- export async function serveToolsOverStdio(runtime, options) {
385
- return runtime.serveToolsOverStdio(options);
386
- }
387
- export async function createRuntimeMcpServer(runtime, options) {
388
- return runtime.createRuntimeMcpServer(options);
389
- }
390
- export async function serveRuntimeMcpOverStdio(runtime, options) {
391
- return runtime.serveRuntimeMcpOverStdio(options);
392
- }
393
- export async function serveRuntimeMcpOverStreamableHttp(runtime, options) {
394
- return runtime.serveRuntimeMcpOverStreamableHttp(options);
395
- }
396
- function normalizeUserChatMessage(message) {
397
- if (message.role !== "user") {
398
- throw new Error("normalizeUserChatInput only accepts user-role chat messages.");
399
- }
400
- return {
401
- role: "user",
402
- content: normalizeMessageContent(message.content),
403
- };
404
- }
1
+ import{AgentHarnessRuntime as l}from"./runtime/harness.js";import{buildFlowGraph as I,exportFlowGraphToMermaid as f,exportFlowGraphToSequenceMermaid as v}from"./flow/index.js";import{serveA2aOverHttp as m}from"./protocol/a2a/http.js";import{serveAgUiOverHttp as q}from"./protocol/ag-ui/http.js";import{serveAcpOverHttp as x}from"./protocol/acp/http.js";import{serveAcpOverStdio as A}from"./protocol/acp/stdio.js";import{normalizeMessageContent as c}from"./utils/message-content.js";import{loadWorkspace as g}from"./workspace/compile.js";import{traceStartupStage as u}from"./runtime/startup-tracing.js";import{AgentHarnessAcpServer as Le,createAcpServer as Ce}from"./acp.js";import{createAcpStdioClient as Ge}from"./protocol/acp/client.js";import{AgentHarnessRuntime as Fe}from"./runtime/harness.js";import{createUpstreamTimelineReducer as $e}from"./projections/upstream-events.js";function s(e){return{approvalId:e.approvalId,pendingActionId:e.pendingActionId,sessionId:e.sessionId,requestId:e.requestId,toolName:e.toolName,...e.approvalReason?{approvalReason:e.approvalReason}:{},status:e.status,requestedAt:e.requestedAt,resolvedAt:e.resolvedAt,allowedDecisions:e.allowedDecisions,inputPreview:e.inputPreview}}function B(e){return e}function o(e){return{eventId:e.eventId,eventType:e.eventType,timestamp:e.timestamp,sessionId:e.sessionId,requestId:e.requestId,sequence:e.sequence,source:e.source,payload:e.payload}}function d(e){const t=typeof e.item=="object"&&e.item!==null?e.item:null;return t?.surfaceItem?{sessionId:e.sessionId,requestId:e.requestId,surfaceItem:t.surfaceItem,event:t.event}:null}function y(e){if(e)return{onEvent:e.onEvent?async t=>e.onEvent(o(t)):void 0,onUpstreamEvent:e.onUpstreamEvent,onTraceItem:e.onTraceItem?async t=>e.onTraceItem({sessionId:t.sessionId,requestId:t.requestId,surfaceItem:t.surfaceItem,event:t.event}):void 0,onPlanState:e.onPlanState}}function R(e){return{sessionId:e.sessionId,requestId:e.requestId,items:e.items}}function S(e){return{session:e.session,request:e.request,approvals:e.approvals.map(s),transcript:e.transcript,events:e.events.map(o),artifacts:e.artifacts,governance:e.governance,...e.runtimeHealth?{runtimeHealth:e.runtimeHealth}:{}}}function a(e){return{sessionId:e.sessionId,requestId:e.requestId,state:e.state,output:e.output,finalMessageText:e.finalMessageText,outputContent:e.outputContent,contentBlocks:e.contentBlocks,structuredResponse:e.structuredResponse,interruptContent:e.interruptContent,agentId:e.agentId,approvalId:e.approvalId,pendingActionId:e.pendingActionId,delegationId:e.delegationId,artifacts:e.artifacts,metadata:e.metadata}}function w(e){const t=y(e.listeners),n=t||e.eventListener||e.dataListener?{...t??{},...e.eventListener?{eventListener:e.eventListener}:{},...e.dataListener?{dataListener:e.dataListener}:{}}:void 0;return"decision"in e?{approvalId:e.approvalId,decision:e.decision,editedInput:e.editedInput,listeners:n,requestId:e.requestId,sessionId:e.sessionId}:{agentId:e.agentId,input:e.input,invocation:e.invocation,listeners:n,priority:e.priority,sessionId:e.sessionId}}function h(e){return{approvalId:e.approvalId,decision:e.decision,editedInput:e.editedInput,requestId:e.requestId,sessionId:e.sessionId}}function b(e){return{requestId:e.requestId,sessionId:e.sessionId,agentId:e.agentId,parentRequestId:e.parentRequestId,executionMode:e.executionMode,adapterKind:e.adapterKind,createdAt:e.createdAt,updatedAt:e.updatedAt,state:e.state,checkpointRef:e.checkpointRef,resumable:e.resumable,startedAt:e.startedAt,endedAt:e.endedAt,lastActivityAt:e.lastActivityAt,currentAgentId:e.currentAgentId,delegationChain:e.delegationChain,runtimeSnapshot:e.runtimeSnapshot}}async function F(e=process.cwd(),t={}){const n=await u("createAgentHarness.loadWorkspace",()=>g(e,t.load??{}),{workspaceRoot:e}),r=await u("createAgentHarness.constructRuntime",async()=>new l(n,t.adapter??{}),{workspaceRoot:e});return await u("createAgentHarness.initializeRuntime",()=>r.initialize(),{workspaceRoot:e}),r}function U(e,t={}){const n=typeof e=="object"&&e!==null&&"role"in e?M(e).content:c(e);return t.invocation?{input:n,invocation:t.invocation}:{input:n}}async function $(e,t){return a(await e.run(w(t)))}async function k(e,t){return e.memorize(t)}async function W(e,t){return e.recall(t)}async function D(e,t={}){return e.listMemories(t)}async function K(e,t){return e.updateMemory(t)}async function j(e,t){return e.removeMemory(t)}function N(e,t){return e.subscribe(async n=>{await t(o(n))})}async function J(e,t){return e.listSessions(t)}async function Q(e,t){return e.listSessionSummaries(t)}async function V(e,t){return e.listRequests(t)}async function X(e,t){return e.getSessionRecord(t)}async function Y(e,t){return e.getRequest(t)}async function p(e,t){const n=await e.getRequest(t.requestId);if(!n)throw new Error(`Request ${t.requestId} was not found.`);if(n.sessionId!==t.sessionId)throw new Error(`Request ${t.requestId} belongs to session ${n.sessionId}, not ${t.sessionId}.`);const r=(n.traceItems??[]).map(i=>d({sessionId:t.sessionId,requestId:t.requestId,item:i})).filter(i=>i!==null);return I({sessionId:t.sessionId,requestId:t.requestId,runtimeTimeline:n.runtimeTimeline,upstreamEvents:r,metadata:{state:n.state,...n.runtimeSnapshot?{runtimeSnapshot:n.runtimeSnapshot}:{}}})}async function Z(e,t){return f(await p(e,t),{direction:"TD",includeGroups:!1,includeKinds:["agent","llm","tool","skill","memory"]})}async function _(e,t){return v(await p(e,t))}async function ee(e,t){return e.deleteSession(t)}async function te(e,t){return(await e.listApprovals({requestId:t?.requestId,status:t?.status,sessionId:t?.sessionId})).map(s)}async function ne(e,t){const n=await e.getApproval(t);return n?s(n):null}async function re(e,t){return R(await e.listRequestArtifacts(t.sessionId,t.requestId))}async function se(e,t){return e.readRequestArtifact(t.sessionId,t.requestId,t.artifactPath)}async function oe(e,t){return e.getRequestPlanState(t.sessionId,t.requestId)}async function ae(e,t){return e.recordArtifact(t)}async function ie(e,t){return(await e.listRequestEvents(t.sessionId,t.requestId)).map(o)}async function ue(e,t){const n=await e.getRequest(t.requestId);if(!n)throw new Error(`Request ${t.requestId} was not found.`);if(n.sessionId!==t.sessionId)throw new Error(`Request ${t.requestId} belongs to session ${n.sessionId}, not ${t.sessionId}.`);return(n.traceItems??[]).map(r=>d({sessionId:t.sessionId,requestId:t.requestId,item:r})).filter(r=>r!==null)}async function ce(e){return e.getHealth()}async function de(e,t){const n=await e.getOperatorOverview(t),r={total:n.requests.total,states:n.requests.states,items:n.requests.items.map(b)};return{...n,approvals:{total:n.approvals.total,items:n.approvals.items.map(s)},requests:r}}async function pe(e,t){const n=await e.exportRequestPackage(t);return{...S(n),planState:await e.getRequestPlanState(t.sessionId,t.requestId)}}async function le(e,t){return e.exportSessionPackage(t)}async function Ie(e,t){return e.exportEvaluationBundle(t)}async function fe(e,t){const n=await e.replayEvaluationBundle(t);return{...n,result:a(n.result)}}function ve(e,t){return A(e,t)}async function me(e,t){return x(e,t)}async function qe(e,t){return q(e,t)}async function xe(e,t){return m(e,t)}function Ae(e,t,n){return e.listAgentSkills(t,n)}function ge(e,t,n){return e.getAgent(t,n)}function ye(e,t){return e.describeWorkspaceInventory(t)}function Re(e,t){return e.analyzeWorkspaceBoundaries(t)}async function Se(e,t){return a(await e.resume(h(t)))}async function we(e,t){return a(await e.cancelRequest(t))}async function he(e){return e.stop()}async function be(e,t){return e.createToolMcpServer(t)}async function Me(e,t){return e.serveToolsOverStdio(t)}async function He(e,t){return e.createRuntimeMcpServer(t)}async function Te(e,t){return e.serveRuntimeMcpOverStdio(t)}async function Ee(e,t){return e.serveRuntimeMcpOverStreamableHttp(t)}function M(e){if(e.role!=="user")throw new Error("normalizeUserChatInput only accepts user-role chat messages.");return{role:"user",content:c(e.content)}}export{Le as AgentHarnessAcpServer,Fe as AgentHarnessRuntime,Re as analyzeBoundaries,we as cancelRequest,Ce as createAcpServer,Ge as createAcpStdioClient,F as createAgentHarness,He as createRuntimeMcpServer,be as createToolMcpServer,$e as createUpstreamTimelineReducer,ee as deleteSession,ye as describeInventory,Ie as exportEvaluationBundle,Z as exportFlow,pe as exportRequestPackage,_ as exportSequence,le as exportSessionPackage,ge as getAgent,ne as getApproval,se as getArtifact,ce as getHealth,de as getOperatorOverview,Y as getRequest,oe as getRequestPlanState,X as getSession,Ae as listAgentSkills,te as listApprovals,D as listMemories,re as listRequestArtifacts,ie as listRequestEvents,ue as listRequestTraceItems,V as listRequests,Q as listSessionSummaries,J as listSessions,k as memorize,U as normalizeUserChatInput,W as recall,ae as recordArtifact,j as removeMemory,fe as replayEvaluationBundle,$ as request,Se as resolveApproval,xe as serveA2aHttp,me as serveAcpHttp,ve as serveAcpStdio,qe as serveAgUiHttp,Te as serveRuntimeMcpOverStdio,Ee as serveRuntimeMcpOverStreamableHttp,Me as serveToolsOverStdio,he as stop,N as subscribe,K as updateMemory};
@@ -1,55 +1 @@
1
- export const DEFAULT_CHECKPOINT_RESUME_CHECKPOINTERS = Object.freeze(["memory", "sqlite"]);
2
- export const DEFAULT_RESUME_COST_INFRA_RETRIES = 2;
3
- function average(values) {
4
- return Number((values.reduce((sum, value) => sum + value, 0) / values.length).toFixed(2));
5
- }
6
- function averageOrNull(values) {
7
- return values.length > 0 ? average(values) : null;
8
- }
9
- export function resolveCheckpointResumeCheckpointers(rawValue) {
10
- if (!rawValue) {
11
- return [...DEFAULT_CHECKPOINT_RESUME_CHECKPOINTERS];
12
- }
13
- const parsed = rawValue
14
- .split(",")
15
- .map((value) => value.trim().toLowerCase())
16
- .filter((value) => value === "memory" || value === "sqlite");
17
- return parsed.length > 0 ? parsed : [...DEFAULT_CHECKPOINT_RESUME_CHECKPOINTERS];
18
- }
19
- export function resolveResumeCostInfraRetries(rawValue) {
20
- if (!rawValue) {
21
- return DEFAULT_RESUME_COST_INFRA_RETRIES;
22
- }
23
- const parsed = Number(rawValue);
24
- return Number.isInteger(parsed) && parsed >= 0 ? parsed : DEFAULT_RESUME_COST_INFRA_RETRIES;
25
- }
26
- export function isRetryableResumeCostError(message) {
27
- if (!message) {
28
- return false;
29
- }
30
- const normalized = message.toLowerCase();
31
- return (normalized.includes("connection error") ||
32
- normalized.includes("network error") ||
33
- normalized.includes("fetch failed") ||
34
- normalized.includes("socket hang up") ||
35
- normalized.includes("econnreset") ||
36
- normalized.includes("timed out"));
37
- }
38
- export function aggregateCheckpointResumeRuns(model, checkpointerKind, runs) {
39
- const successfulRuns = runs.filter((run) => run.status === "completed");
40
- return {
41
- model,
42
- checkpointerKind,
43
- repetitions: runs.length,
44
- successCount: successfulRuns.length,
45
- failureCount: runs.length - successfulRuns.length,
46
- avgInitialApprovalMs: averageOrNull(successfulRuns.map((run) => run.initialApprovalMs)),
47
- avgSameProcessResumeMs: averageOrNull(successfulRuns.map((run) => run.sameProcessResumeMs)),
48
- avgCrossRestartResumeMs: averageOrNull(successfulRuns
49
- .map((run) => run.crossRestartResumeMs)
50
- .filter((value) => value !== null)),
51
- avgTotalMeasuredMs: averageOrNull(successfulRuns.map((run) => run.totalMeasuredMs)),
52
- avgApprovalPassCount: averageOrNull(successfulRuns.map((run) => run.approvalPassCount)),
53
- crossRestartSuccessCount: successfulRuns.filter((run) => run.crossRestartSupported).length,
54
- };
55
- }
1
+ const u=Object.freeze(["memory","sqlite"]),i=2;function a(t){return Number((t.reduce((e,s)=>e+s,0)/t.length).toFixed(2))}function o(t){return t.length>0?a(t):null}function c(t){if(!t)return[...u];const e=t.split(",").map(s=>s.trim().toLowerCase()).filter(s=>s==="memory"||s==="sqlite");return e.length>0?e:[...u]}function l(t){if(!t)return i;const e=Number(t);return Number.isInteger(e)&&e>=0?e:i}function p(t){if(!t)return!1;const e=t.toLowerCase();return e.includes("connection error")||e.includes("network error")||e.includes("fetch failed")||e.includes("socket hang up")||e.includes("econnreset")||e.includes("timed out")}function m(t,e,s){const n=s.filter(r=>r.status==="completed");return{model:t,checkpointerKind:e,repetitions:s.length,successCount:n.length,failureCount:s.length-n.length,avgInitialApprovalMs:o(n.map(r=>r.initialApprovalMs)),avgSameProcessResumeMs:o(n.map(r=>r.sameProcessResumeMs)),avgCrossRestartResumeMs:o(n.map(r=>r.crossRestartResumeMs).filter(r=>r!==null)),avgTotalMeasuredMs:o(n.map(r=>r.totalMeasuredMs)),avgApprovalPassCount:o(n.map(r=>r.approvalPassCount)),crossRestartSuccessCount:n.filter(r=>r.crossRestartSupported).length}}export{u as DEFAULT_CHECKPOINT_RESUME_CHECKPOINTERS,i as DEFAULT_RESUME_COST_INFRA_RETRIES,m as aggregateCheckpointResumeRuns,p as isRetryableResumeCostError,c as resolveCheckpointResumeCheckpointers,l as resolveResumeCostInfraRetries};
@@ -1,35 +1,2 @@
1
- export const DEFAULT_SERIAL_BENCHMARK_MODELS = Object.freeze([
2
- "qwen3.5:0.8b",
3
- "qwen3.5:2b",
4
- "qwen3.5:4b",
5
- "qwen3.5:9b",
6
- "gpt-oss",
7
- ]);
8
- export function resolveSerialBenchmarkModels(rawValue) {
9
- if (!rawValue) {
10
- return [...DEFAULT_SERIAL_BENCHMARK_MODELS];
11
- }
12
- const parsed = rawValue.split(",").map((value) => value.trim()).filter(Boolean);
13
- return parsed.length > 0 ? parsed : [...DEFAULT_SERIAL_BENCHMARK_MODELS];
14
- }
15
- export function buildWarmupRequestPayload(model, token) {
16
- return {
17
- model,
18
- temperature: 0,
19
- max_tokens: 32,
20
- messages: [
21
- {
22
- role: "user",
23
- content: `Reply with exactly: WARMUP_OK ${token}`,
24
- },
25
- ],
26
- };
27
- }
28
- export function extractWarmupOutput(payload) {
29
- const content = payload.choices?.[0]?.message?.content ?? "";
30
- const reasoning = payload.choices?.[0]?.message?.reasoning ?? "";
31
- return {
32
- output: `${content}\n${reasoning}`.trim(),
33
- completionTokens: payload.usage?.completion_tokens ?? 0,
34
- };
35
- }
1
+ const o=Object.freeze(["qwen3.5:0.8b","qwen3.5:2b","qwen3.5:4b","qwen3.5:9b","gpt-oss"]);function r(e){if(!e)return[...o];const t=e.split(",").map(n=>n.trim()).filter(Boolean);return t.length>0?t:[...o]}function s(e,t){return{model:e,temperature:0,max_tokens:32,messages:[{role:"user",content:`Reply with exactly: WARMUP_OK ${t}`}]}}function c(e){const t=e.choices?.[0]?.message?.content??"",n=e.choices?.[0]?.message?.reasoning??"";return{output:`${t}
2
+ ${n}`.trim(),completionTokens:e.usage?.completion_tokens??0}}export{o as DEFAULT_SERIAL_BENCHMARK_MODELS,s as buildWarmupRequestPayload,c as extractWarmupOutput,r as resolveSerialBenchmarkModels};