@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
@@ -1,201 +1 @@
1
- import { extractInterruptPayload, extractReasoningStreamOutput, extractToolResult } from "../runtime/parsing/stream-event-parsing.js";
2
- function asObject(value) {
3
- return typeof value === "object" && value !== null ? value : null;
4
- }
5
- function readStringArray(value) {
6
- return Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
7
- }
8
- function normalizeSegment(value) {
9
- return value
10
- .replace(/[_-]+/g, " ")
11
- .replace(/\s+/g, " ")
12
- .trim();
13
- }
14
- function titleCase(value) {
15
- return normalizeSegment(value)
16
- .split(" ")
17
- .filter(Boolean)
18
- .map((part) => part.charAt(0).toUpperCase() + part.slice(1))
19
- .join(" ");
20
- }
21
- function readEventContext(event) {
22
- const typed = asObject(event);
23
- return {
24
- eventName: typeof typed?.event === 'string' ? typed.event : "",
25
- name: typeof typed?.name === 'string' ? typed.name : "",
26
- runType: typeof typed?.run_type === 'string' ? typed.run_type : "",
27
- tags: readStringArray(typed?.tags),
28
- ns: readStringArray(typed?.ns),
29
- };
30
- }
31
- function normalizeSemanticHint(value) {
32
- return value
33
- .replace(/([a-z0-9])([A-Z])/g, "$1 $2")
34
- .replace(/[.:/]+/g, " ")
35
- .replace(/[_-]+/g, " ")
36
- .replace(/\s+/g, " ")
37
- .trim()
38
- .toLowerCase();
39
- }
40
- function isExactSemanticHint(values, expected) {
41
- return values.includes(expected);
42
- }
43
- function classifyStepCategory(context) {
44
- const hints = [context.name, context.runType, ...context.tags, ...context.ns].map(normalizeSemanticHint);
45
- if (context.runType === "memory"
46
- || isExactSemanticHint(hints, "memory")) {
47
- return "memory";
48
- }
49
- if (isExactSemanticHint(hints, "skill")) {
50
- return "skill";
51
- }
52
- if (context.eventName.startsWith("on_tool_") || context.runType === "tool") {
53
- return "tool";
54
- }
55
- return "chain";
56
- }
57
- function buildStepLabel(category, status, name) {
58
- const displayName = titleCase(name || category);
59
- if (category === "llm") {
60
- return status === "started" ? `Calling LLM ${displayName}` : `Completed LLM ${displayName}`;
61
- }
62
- if (category === "tool") {
63
- if (status === "failed") {
64
- return `Tool ${displayName} failed`;
65
- }
66
- return status === "started" ? `Calling tool ${displayName}` : `Completed tool ${displayName}`;
67
- }
68
- if (category === "skill") {
69
- return status === "started" ? `Calling skill ${displayName}` : `Completed skill ${displayName}`;
70
- }
71
- if (category === "memory") {
72
- return status === "started" ? `Accessing memory ${displayName}` : `Completed memory ${displayName}`;
73
- }
74
- return status === "started" ? `Running ${displayName}` : `Completed ${displayName}`;
75
- }
76
- function createProjectionKey(parts) {
77
- return JSON.stringify(parts, (_key, value) => {
78
- if (typeof value === "string" && value.length > 512) {
79
- return `${value.slice(0, 497)}...[${value.length} chars]`;
80
- }
81
- return value;
82
- });
83
- }
84
- export function createUpstreamTimelineReducer() {
85
- const emittedStepKeys = new Set();
86
- const emittedToolResultKeys = new Set();
87
- return {
88
- consume(event) {
89
- const projections = [];
90
- const context = readEventContext(event);
91
- const reasoning = extractReasoningStreamOutput(event);
92
- if (reasoning) {
93
- projections.push({
94
- type: "thinking",
95
- text: reasoning,
96
- });
97
- }
98
- const interruptPayload = extractInterruptPayload(event);
99
- if (interruptPayload) {
100
- const key = createProjectionKey(["approval", context.eventName || "interrupt", interruptPayload]);
101
- if (!emittedStepKeys.has(key)) {
102
- emittedStepKeys.add(key);
103
- projections.push({
104
- type: "step",
105
- step: "Waiting for approval",
106
- category: "approval",
107
- status: "started",
108
- key,
109
- });
110
- }
111
- }
112
- if (context.eventName === "on_chat_model_start") {
113
- const stepName = context.name || "model";
114
- const key = createProjectionKey(["llm", "started", stepName]);
115
- if (!emittedStepKeys.has(key)) {
116
- emittedStepKeys.add(key);
117
- projections.push({
118
- type: "step",
119
- step: buildStepLabel("llm", "started", stepName),
120
- category: "llm",
121
- status: "started",
122
- key,
123
- });
124
- }
125
- }
126
- if (context.eventName === "on_chat_model_end") {
127
- const stepName = context.name || "model";
128
- const key = createProjectionKey(["llm", "completed", stepName]);
129
- if (!emittedStepKeys.has(key)) {
130
- emittedStepKeys.add(key);
131
- projections.push({
132
- type: "step",
133
- step: buildStepLabel("llm", "completed", stepName),
134
- category: "llm",
135
- status: "completed",
136
- key,
137
- });
138
- }
139
- }
140
- if (context.eventName === "on_tool_start"
141
- || (context.eventName === "on_chain_start" && context.runType === "tool")
142
- || context.eventName === "on_chain_start") {
143
- const category = classifyStepCategory(context);
144
- if (category !== "llm") {
145
- const stepName = context.name || context.runType || "chain";
146
- const key = createProjectionKey([category, "started", stepName]);
147
- if (!emittedStepKeys.has(key)) {
148
- emittedStepKeys.add(key);
149
- projections.push({
150
- type: "step",
151
- step: buildStepLabel(category, "started", stepName),
152
- category,
153
- status: "started",
154
- key,
155
- });
156
- }
157
- }
158
- }
159
- const toolResult = extractToolResult(event);
160
- if (toolResult) {
161
- const resultKey = createProjectionKey(["tool-result", toolResult.toolName, toolResult.output, toolResult.isError === true]);
162
- if (!emittedToolResultKeys.has(resultKey)) {
163
- emittedToolResultKeys.add(resultKey);
164
- projections.push({
165
- type: "tool-result",
166
- toolName: toolResult.toolName,
167
- output: toolResult.output,
168
- ...(toolResult.isError !== undefined ? { isError: toolResult.isError } : {}),
169
- key: resultKey,
170
- });
171
- }
172
- const stepKey = createProjectionKey(["tool", toolResult.isError ? "failed" : "completed", toolResult.toolName]);
173
- if (!emittedStepKeys.has(stepKey)) {
174
- emittedStepKeys.add(stepKey);
175
- projections.push({
176
- type: "step",
177
- step: buildStepLabel("tool", toolResult.isError ? "failed" : "completed", toolResult.toolName),
178
- category: "tool",
179
- status: toolResult.isError ? "failed" : "completed",
180
- key: stepKey,
181
- });
182
- }
183
- }
184
- if (context.eventName === "on_chain_end" && context.runType !== "tool" && context.name) {
185
- const category = classifyStepCategory(context);
186
- const key = createProjectionKey([category, "completed", context.name]);
187
- if (!emittedStepKeys.has(key)) {
188
- emittedStepKeys.add(key);
189
- projections.push({
190
- type: "step",
191
- step: buildStepLabel(category, "completed", context.name),
192
- category,
193
- status: "completed",
194
- key,
195
- });
196
- }
197
- }
198
- return projections;
199
- },
200
- };
201
- }
1
+ import{extractInterruptPayload as g,extractReasoningStreamOutput as h,extractToolResult as _}from"../runtime/parsing/stream-event-parsing.js";function N(e){return typeof e=="object"&&e!==null?e:null}function d(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function $(e){return e.replace(/[_-]+/g," ").replace(/\s+/g," ").trim()}function k(e){return $(e).split(" ").filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function C(e){const t=N(e);return{eventName:typeof t?.event=="string"?t.event:"",name:typeof t?.name=="string"?t.name:"",runType:typeof t?.run_type=="string"?t.run_type:"",tags:d(t?.tags),ns:d(t?.ns)}}function S(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[.:/]+/g," ").replace(/[_-]+/g," ").replace(/\s+/g," ").trim().toLowerCase()}function y(e,t){return e.includes(t)}function f(e){const t=[e.name,e.runType,...e.tags,...e.ns].map(S);return e.runType==="memory"||y(t,"memory")?"memory":y(t,"skill")?"skill":e.eventName.startsWith("on_tool_")||e.runType==="tool"?"tool":"chain"}function p(e,t,i){const n=k(i||e);return e==="llm"?t==="started"?`Calling LLM ${n}`:`Completed LLM ${n}`:e==="tool"?t==="failed"?`Tool ${n} failed`:t==="started"?`Calling tool ${n}`:`Completed tool ${n}`:e==="skill"?t==="started"?`Calling skill ${n}`:`Completed skill ${n}`:e==="memory"?t==="started"?`Accessing memory ${n}`:`Completed memory ${n}`:t==="started"?`Running ${n}`:`Completed ${n}`}function l(e){return JSON.stringify(e,(t,i)=>typeof i=="string"&&i.length>512?`${i.slice(0,497)}...[${i.length} chars]`:i)}function E(){const e=new Set,t=new Set;return{consume(i){const n=[],o=C(i),c=h(i);c&&n.push({type:"thinking",text:c});const u=g(i);if(u){const r=l(["approval",o.eventName||"interrupt",u]);e.has(r)||(e.add(r),n.push({type:"step",step:"Waiting for approval",category:"approval",status:"started",key:r}))}if(o.eventName==="on_chat_model_start"){const r=o.name||"model",s=l(["llm","started",r]);e.has(s)||(e.add(s),n.push({type:"step",step:p("llm","started",r),category:"llm",status:"started",key:s}))}if(o.eventName==="on_chat_model_end"){const r=o.name||"model",s=l(["llm","completed",r]);e.has(s)||(e.add(s),n.push({type:"step",step:p("llm","completed",r),category:"llm",status:"completed",key:s}))}if(o.eventName==="on_tool_start"||o.eventName==="on_chain_start"&&o.runType==="tool"||o.eventName==="on_chain_start"){const r=f(o);if(r!=="llm"){const s=o.name||o.runType||"chain",m=l([r,"started",s]);e.has(m)||(e.add(m),n.push({type:"step",step:p(r,"started",s),category:r,status:"started",key:m}))}}const a=_(i);if(a){const r=l(["tool-result",a.toolName,a.output,a.isError===!0]);t.has(r)||(t.add(r),n.push({type:"tool-result",toolName:a.toolName,output:a.output,...a.isError!==void 0?{isError:a.isError}:{},key:r}));const s=l(["tool",a.isError?"failed":"completed",a.toolName]);e.has(s)||(e.add(s),n.push({type:"step",step:p("tool",a.isError?"failed":"completed",a.toolName),category:"tool",status:a.isError?"failed":"completed",key:s}))}if(o.eventName==="on_chain_end"&&o.runType!=="tool"&&o.name){const r=f(o),s=l([r,"completed",o.name]);e.has(s)||(e.add(s),n.push({type:"step",step:p(r,"completed",o.name),category:r,status:"completed",key:s}))}return n}}}export{E as createUpstreamTimelineReducer};
@@ -1,178 +1 @@
1
- import { AGENT_HARNESS_VERSION } from "../../package-version.js";
2
- export const SUPPORTED_A2A_VERSIONS = ["1.0", "0.3"];
3
- export function normalizePath(value, fallback) {
4
- const source = typeof value === "string" && value.trim().length > 0 ? value.trim() : fallback;
5
- return source.startsWith("/") ? source : `/${source}`;
6
- }
7
- export function writeJson(response, statusCode, payload) {
8
- response.statusCode = statusCode;
9
- response.setHeader("content-type", "application/json; charset=utf-8");
10
- response.end(JSON.stringify(payload));
11
- }
12
- export function writeA2aDiscoveryHeaders(response) {
13
- response.setHeader("A2A-Version", "1.0");
14
- response.setHeader("A2A-Supported-Versions", SUPPORTED_A2A_VERSIONS.join(", "));
15
- }
16
- function normalizeNonEmptyStringArray(value) {
17
- if (!Array.isArray(value)) {
18
- return undefined;
19
- }
20
- const items = value.map((item) => item.trim()).filter((item) => item.length > 0);
21
- return items.length > 0 ? items : undefined;
22
- }
23
- function buildDiscoveryMetadata(options) {
24
- const registryUrls = normalizeNonEmptyStringArray(options.registryUrls);
25
- const signature = options.agentCardSignature?.signature?.trim();
26
- const algorithm = options.agentCardSignature?.algorithm?.trim();
27
- const keyId = options.agentCardSignature?.keyId?.trim();
28
- if (!registryUrls && (!signature || !algorithm)) {
29
- return undefined;
30
- }
31
- return {
32
- ...(registryUrls ? { registryUrls } : {}),
33
- ...(signature && algorithm
34
- ? {
35
- signedAgentCard: {
36
- algorithm,
37
- signature,
38
- ...(keyId ? { keyId } : {}),
39
- },
40
- }
41
- : {}),
42
- };
43
- }
44
- export function writeOptionalAgentCardIntegrityHeaders(response, options) {
45
- const registryUrls = normalizeNonEmptyStringArray(options.registryUrls);
46
- if (registryUrls) {
47
- response.setHeader("X-A2A-Registry-Urls", registryUrls.join(", "));
48
- }
49
- const signature = options.agentCardSignature?.signature?.trim();
50
- const algorithm = options.agentCardSignature?.algorithm?.trim();
51
- const keyId = options.agentCardSignature?.keyId?.trim();
52
- if (signature && algorithm) {
53
- response.setHeader("X-A2A-Agent-Card-Signature", signature);
54
- response.setHeader("X-A2A-Agent-Card-Alg", algorithm);
55
- if (keyId) {
56
- response.setHeader("X-A2A-Agent-Card-Key-Id", keyId);
57
- }
58
- }
59
- }
60
- function readServiceParameter(requestUrl, request, name) {
61
- const headerValue = request.headers[name.toLowerCase()];
62
- if (typeof headerValue === "string") {
63
- return headerValue;
64
- }
65
- if (Array.isArray(headerValue)) {
66
- return headerValue.join(",");
67
- }
68
- return requestUrl.searchParams.get(name) ?? undefined;
69
- }
70
- export function parseA2aServiceParameters(requestUrl, request) {
71
- const requestedVersion = readServiceParameter(requestUrl, request, "A2A-Version")?.trim() ?? "";
72
- const normalizedVersion = requestedVersion.length === 0 ? "0.3" : requestedVersion;
73
- if (!SUPPORTED_A2A_VERSIONS.includes(normalizedVersion)) {
74
- return null;
75
- }
76
- const requestedExtensions = readServiceParameter(requestUrl, request, "A2A-Extensions") ?? "";
77
- return {
78
- version: normalizedVersion,
79
- extensions: requestedExtensions
80
- .split(",")
81
- .map((entry) => entry.trim())
82
- .filter((entry) => entry.length > 0),
83
- };
84
- }
85
- export function acceptsSse(request) {
86
- const accept = request.headers.accept;
87
- if (accept === undefined) {
88
- return false;
89
- }
90
- const values = Array.isArray(accept) ? accept : [accept];
91
- return values.some((value) => value.includes("text/event-stream"));
92
- }
93
- export function buildAgentCard(runtime, options) {
94
- const inventory = runtime.describeWorkspaceInventory();
95
- const discovery = buildDiscoveryMetadata({
96
- registryUrls: options.registryUrls,
97
- agentCardSignature: options.agentCardSignature,
98
- });
99
- const skills = inventory.agents.map((agent) => ({
100
- id: agent.id,
101
- name: agent.id,
102
- description: agent.description || `Agent ${agent.id}`,
103
- tags: ["agent-harness", agent.parentAgentId ? "subagent" : "agent"],
104
- examples: [`Send a task to ${agent.id}.`],
105
- }));
106
- return {
107
- name: options.agentName,
108
- description: options.agentDescription,
109
- version: AGENT_HARNESS_VERSION,
110
- protocolVersion: "1.0",
111
- url: options.rpcUrl,
112
- preferredTransport: "JSONRPC",
113
- supportedInterfaces: [
114
- {
115
- url: options.rpcUrl,
116
- protocolBinding: "JSONRPC",
117
- protocolVersion: "1.0",
118
- },
119
- {
120
- url: options.rpcUrl,
121
- protocolBinding: "JSONRPC",
122
- protocolVersion: "0.3",
123
- },
124
- ],
125
- capabilities: {
126
- streaming: true,
127
- pushNotifications: true,
128
- extendedAgentCard: true,
129
- },
130
- defaultInputModes: ["text/plain"],
131
- defaultOutputModes: ["text/plain"],
132
- skills,
133
- ...(discovery
134
- ? {
135
- metadata: {
136
- agentHarness: {
137
- discovery,
138
- },
139
- },
140
- }
141
- : {}),
142
- ...(options.documentationUrl ? { documentationUrl: options.documentationUrl } : {}),
143
- ...(options.provider ? { provider: options.provider } : {}),
144
- ...(options.defaultAgentId ? { defaultAgentId: options.defaultAgentId } : {}),
145
- };
146
- }
147
- export function buildExtendedAgentCard(runtime, options) {
148
- const inventory = runtime.describeWorkspaceInventory();
149
- const card = buildAgentCard(runtime, options);
150
- const discovery = buildDiscoveryMetadata({
151
- registryUrls: options.registryUrls,
152
- agentCardSignature: options.agentCardSignature,
153
- });
154
- return {
155
- ...card,
156
- metadata: {
157
- agentHarness: {
158
- runtime: {
159
- product: "agent-harness",
160
- protocolSurface: "a2a-http",
161
- ...(options.defaultAgentId ? { defaultAgentId: options.defaultAgentId } : {}),
162
- },
163
- protocolSurfaces: ["A2A", "ACP", "AG-UI", "runtime MCP"],
164
- inventory: {
165
- agentCount: inventory.agents.length,
166
- subagentCount: inventory.agents.filter((agent) => Boolean(agent.parentAgentId)).length,
167
- },
168
- ...(discovery ? { discovery } : {}),
169
- agents: inventory.agents.map((agent) => ({
170
- id: agent.id,
171
- name: agent.id,
172
- description: agent.description || `Agent ${agent.id}`,
173
- kind: agent.parentAgentId ? "subagent" : "agent",
174
- })),
175
- },
176
- },
177
- };
178
- }
1
+ import{AGENT_HARNESS_VERSION as g}from"../../package-version.js";const d=["1.0","0.3"];function A(t,e){const r=typeof t=="string"&&t.trim().length>0?t.trim():e;return r.startsWith("/")?r:`/${r}`}function f(t,e,r){t.statusCode=e,t.setHeader("content-type","application/json; charset=utf-8"),t.end(JSON.stringify(r))}function m(t){t.setHeader("A2A-Version","1.0"),t.setHeader("A2A-Supported-Versions",d.join(", "))}function s(t){if(!Array.isArray(t))return;const e=t.map(r=>r.trim()).filter(r=>r.length>0);return e.length>0?e:void 0}function o(t){const e=s(t.registryUrls),r=t.agentCardSignature?.signature?.trim(),n=t.agentCardSignature?.algorithm?.trim(),i=t.agentCardSignature?.keyId?.trim();if(!(!e&&(!r||!n)))return{...e?{registryUrls:e}:{},...r&&n?{signedAgentCard:{algorithm:n,signature:r,...i?{keyId:i}:{}}}:{}}}function p(t,e){const r=s(e.registryUrls);r&&t.setHeader("X-A2A-Registry-Urls",r.join(", "));const n=e.agentCardSignature?.signature?.trim(),i=e.agentCardSignature?.algorithm?.trim(),a=e.agentCardSignature?.keyId?.trim();n&&i&&(t.setHeader("X-A2A-Agent-Card-Signature",n),t.setHeader("X-A2A-Agent-Card-Alg",i),a&&t.setHeader("X-A2A-Agent-Card-Key-Id",a))}function u(t,e,r){const n=e.headers[r.toLowerCase()];return typeof n=="string"?n:Array.isArray(n)?n.join(","):t.searchParams.get(r)??void 0}function y(t,e){const r=u(t,e,"A2A-Version")?.trim()??"",n=r.length===0?"0.3":r;if(!d.includes(n))return null;const i=u(t,e,"A2A-Extensions")??"";return{version:n,extensions:i.split(",").map(a=>a.trim()).filter(a=>a.length>0)}}function S(t){const e=t.headers.accept;return e===void 0?!1:(Array.isArray(e)?e:[e]).some(n=>n.includes("text/event-stream"))}function c(t,e){const r=t.describeWorkspaceInventory(),n=o({registryUrls:e.registryUrls,agentCardSignature:e.agentCardSignature}),i=r.agents.map(a=>({id:a.id,name:a.id,description:a.description||`Agent ${a.id}`,tags:["agent-harness",a.parentAgentId?"subagent":"agent"],examples:[`Send a task to ${a.id}.`]}));return{name:e.agentName,description:e.agentDescription,version:g,protocolVersion:"1.0",url:e.rpcUrl,preferredTransport:"JSONRPC",supportedInterfaces:[{url:e.rpcUrl,protocolBinding:"JSONRPC",protocolVersion:"1.0"},{url:e.rpcUrl,protocolBinding:"JSONRPC",protocolVersion:"0.3"}],capabilities:{streaming:!0,pushNotifications:!0,extendedAgentCard:!0},defaultInputModes:["text/plain"],defaultOutputModes:["text/plain"],skills:i,...n?{metadata:{agentHarness:{discovery:n}}}:{},...e.documentationUrl?{documentationUrl:e.documentationUrl}:{},...e.provider?{provider:e.provider}:{},...e.defaultAgentId?{defaultAgentId:e.defaultAgentId}:{}}}function C(t,e){const r=t.describeWorkspaceInventory(),n=c(t,e),i=o({registryUrls:e.registryUrls,agentCardSignature:e.agentCardSignature});return{...n,metadata:{agentHarness:{runtime:{product:"agent-harness",protocolSurface:"a2a-http",...e.defaultAgentId?{defaultAgentId:e.defaultAgentId}:{}},protocolSurfaces:["A2A","ACP","AG-UI","runtime MCP"],inventory:{agentCount:r.agents.length,subagentCount:r.agents.filter(a=>!!a.parentAgentId).length},...i?{discovery:i}:{},agents:r.agents.map(a=>({id:a.id,name:a.id,description:a.description||`Agent ${a.id}`,kind:a.parentAgentId?"subagent":"agent"}))}}}}export{d as SUPPORTED_A2A_VERSIONS,S as acceptsSse,c as buildAgentCard,C as buildExtendedAgentCard,A as normalizePath,y as parseA2aServiceParameters,m as writeA2aDiscoveryHeaders,f as writeJson,p as writeOptionalAgentCardIntegrityHeaders};