@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,282 +1 @@
1
- const TOP_LEVEL_MANAGED_SERVICES = ["acp", "a2a", "mcp", "ag-ui"];
2
- export function parseTopLevelManagedServiceOptions(args) {
3
- let workspaceRoot;
4
- let hostname;
5
- let services;
6
- let acpPort;
7
- let a2aPort;
8
- let mcpPort;
9
- let agUiPort;
10
- const parsePort = (value, label) => {
11
- if (!value) {
12
- return { error: `Missing value for ${label}` };
13
- }
14
- const parsedPort = Number.parseInt(value, 10);
15
- if (!Number.isFinite(parsedPort) || parsedPort < 0) {
16
- return { error: `Invalid ${label} value: ${value}` };
17
- }
18
- return parsedPort;
19
- };
20
- for (let index = 0; index < args.length; index += 1) {
21
- const arg = args[index];
22
- if (arg === "--workspace" || arg === "-w") {
23
- const value = args[index + 1];
24
- if (!value) {
25
- return { services: services ?? [...TOP_LEVEL_MANAGED_SERVICES], hostname, acpPort, a2aPort, mcpPort, agUiPort, error: "Missing value for --workspace" };
26
- }
27
- workspaceRoot = value;
28
- index += 1;
29
- continue;
30
- }
31
- if (arg === "--services") {
32
- const value = args[index + 1];
33
- if (!value) {
34
- return { services: services ?? [...TOP_LEVEL_MANAGED_SERVICES], workspaceRoot, hostname, acpPort, a2aPort, mcpPort, agUiPort, error: "Missing value for --services" };
35
- }
36
- const parsedServices = value
37
- .split(",")
38
- .map((item) => item.trim())
39
- .filter(Boolean);
40
- if (parsedServices.length === 0) {
41
- return { services: services ?? [...TOP_LEVEL_MANAGED_SERVICES], workspaceRoot, hostname, acpPort, a2aPort, mcpPort, agUiPort, error: "Missing value for --services" };
42
- }
43
- const invalidService = parsedServices.find((service) => !TOP_LEVEL_MANAGED_SERVICES.includes(service));
44
- if (invalidService) {
45
- return {
46
- services: services ?? [...TOP_LEVEL_MANAGED_SERVICES],
47
- workspaceRoot,
48
- hostname,
49
- acpPort,
50
- a2aPort,
51
- mcpPort,
52
- agUiPort,
53
- error: `Unsupported managed service: ${invalidService}`,
54
- };
55
- }
56
- services = Array.from(new Set(parsedServices));
57
- index += 1;
58
- continue;
59
- }
60
- if (arg === "--host") {
61
- const value = args[index + 1];
62
- if (!value) {
63
- return { services: services ?? [...TOP_LEVEL_MANAGED_SERVICES], workspaceRoot, acpPort, a2aPort, mcpPort, agUiPort, error: "Missing value for --host" };
64
- }
65
- hostname = value;
66
- index += 1;
67
- continue;
68
- }
69
- if (arg === "--acp-port") {
70
- const parsedPort = parsePort(args[index + 1], "--acp-port");
71
- if (typeof parsedPort !== "number") {
72
- return { services: services ?? [...TOP_LEVEL_MANAGED_SERVICES], workspaceRoot, hostname, acpPort, a2aPort, mcpPort, agUiPort, error: parsedPort.error };
73
- }
74
- acpPort = parsedPort;
75
- index += 1;
76
- continue;
77
- }
78
- if (arg === "--a2a-port") {
79
- const parsedPort = parsePort(args[index + 1], "--a2a-port");
80
- if (typeof parsedPort !== "number") {
81
- return { services: services ?? [...TOP_LEVEL_MANAGED_SERVICES], workspaceRoot, hostname, acpPort, a2aPort, mcpPort, agUiPort, error: parsedPort.error };
82
- }
83
- a2aPort = parsedPort;
84
- index += 1;
85
- continue;
86
- }
87
- if (arg === "--mcp-port") {
88
- const parsedPort = parsePort(args[index + 1], "--mcp-port");
89
- if (typeof parsedPort !== "number") {
90
- return { services: services ?? [...TOP_LEVEL_MANAGED_SERVICES], workspaceRoot, hostname, acpPort, a2aPort, mcpPort, agUiPort, error: parsedPort.error };
91
- }
92
- mcpPort = parsedPort;
93
- index += 1;
94
- continue;
95
- }
96
- if (arg === "--ag-ui-port") {
97
- const parsedPort = parsePort(args[index + 1], "--ag-ui-port");
98
- if (typeof parsedPort !== "number") {
99
- return { services: services ?? [...TOP_LEVEL_MANAGED_SERVICES], workspaceRoot, hostname, acpPort, a2aPort, mcpPort, agUiPort, error: parsedPort.error };
100
- }
101
- agUiPort = parsedPort;
102
- index += 1;
103
- continue;
104
- }
105
- return { services: services ?? [...TOP_LEVEL_MANAGED_SERVICES], workspaceRoot, hostname, acpPort, a2aPort, mcpPort, agUiPort, error: `Unknown option: ${arg}` };
106
- }
107
- return {
108
- workspaceRoot,
109
- services: services ?? [...TOP_LEVEL_MANAGED_SERVICES],
110
- hostname,
111
- acpPort,
112
- a2aPort,
113
- mcpPort,
114
- agUiPort,
115
- };
116
- }
117
- export function parseAcpServeOptions(args, defaultTransport = "stdio") {
118
- let workspaceRoot;
119
- let transport = defaultTransport;
120
- let hostname;
121
- let port;
122
- for (let index = 0; index < args.length; index += 1) {
123
- const arg = args[index];
124
- if (arg === "--workspace") {
125
- const value = args[index + 1];
126
- if (!value) {
127
- return { transport, hostname, port, error: "Missing value for --workspace" };
128
- }
129
- workspaceRoot = value;
130
- index += 1;
131
- continue;
132
- }
133
- if (arg === "--transport") {
134
- const value = args[index + 1];
135
- if (!value) {
136
- return { transport, hostname, port, error: "Missing value for --transport" };
137
- }
138
- if (value !== "stdio" && value !== "http") {
139
- return { transport, hostname, port, error: `Unsupported ACP transport: ${value}` };
140
- }
141
- transport = value;
142
- index += 1;
143
- continue;
144
- }
145
- if (arg === "--host") {
146
- const value = args[index + 1];
147
- if (!value) {
148
- return { transport, hostname, port, error: "Missing value for --host" };
149
- }
150
- hostname = value;
151
- index += 1;
152
- continue;
153
- }
154
- if (arg === "--port") {
155
- const value = args[index + 1];
156
- if (!value) {
157
- return { transport, hostname, port, error: "Missing value for --port" };
158
- }
159
- const parsedPort = Number.parseInt(value, 10);
160
- if (!Number.isFinite(parsedPort) || parsedPort < 0) {
161
- return { transport, hostname, port, error: `Invalid ACP port: ${value}` };
162
- }
163
- port = parsedPort;
164
- index += 1;
165
- continue;
166
- }
167
- return { transport, hostname, port, error: `Unknown option: ${arg}` };
168
- }
169
- return { workspaceRoot, transport, hostname, port };
170
- }
171
- export function parseWorkspaceOnlyOptions(args) {
172
- let workspaceRoot;
173
- for (let index = 0; index < args.length; index += 1) {
174
- const arg = args[index];
175
- if (arg === "--workspace") {
176
- const value = args[index + 1];
177
- if (!value) {
178
- return { error: "Missing value for --workspace" };
179
- }
180
- workspaceRoot = value;
181
- index += 1;
182
- continue;
183
- }
184
- return { error: `Unknown option: ${arg}` };
185
- }
186
- return { workspaceRoot };
187
- }
188
- export function parseHttpServeOptions(args, serviceLabel = "HTTP") {
189
- let workspaceRoot;
190
- let hostname;
191
- let port;
192
- for (let index = 0; index < args.length; index += 1) {
193
- const arg = args[index];
194
- if (arg === "--workspace") {
195
- const value = args[index + 1];
196
- if (!value) {
197
- return { hostname, port, error: "Missing value for --workspace" };
198
- }
199
- workspaceRoot = value;
200
- index += 1;
201
- continue;
202
- }
203
- if (arg === "--host") {
204
- const value = args[index + 1];
205
- if (!value) {
206
- return { workspaceRoot, port, error: "Missing value for --host" };
207
- }
208
- hostname = value;
209
- index += 1;
210
- continue;
211
- }
212
- if (arg === "--port") {
213
- const value = args[index + 1];
214
- if (!value) {
215
- return { workspaceRoot, hostname, error: "Missing value for --port" };
216
- }
217
- const parsedPort = Number.parseInt(value, 10);
218
- if (!Number.isFinite(parsedPort) || parsedPort < 0) {
219
- return { workspaceRoot, hostname, error: `Invalid ${serviceLabel} port: ${value}` };
220
- }
221
- port = parsedPort;
222
- index += 1;
223
- continue;
224
- }
225
- return { workspaceRoot, hostname, port, error: `Unknown option: ${arg}` };
226
- }
227
- return { workspaceRoot, hostname, port };
228
- }
229
- export function parseRuntimeMcpServeOptions(args, defaultTransport = "stdio") {
230
- let workspaceRoot;
231
- let transport = defaultTransport;
232
- let hostname;
233
- let port;
234
- for (let index = 0; index < args.length; index += 1) {
235
- const arg = args[index];
236
- if (arg === "--workspace") {
237
- const value = args[index + 1];
238
- if (!value) {
239
- return { transport, hostname, port, error: "Missing value for --workspace" };
240
- }
241
- workspaceRoot = value;
242
- index += 1;
243
- continue;
244
- }
245
- if (arg === "--transport") {
246
- const value = args[index + 1];
247
- if (!value) {
248
- return { transport, hostname, port, error: "Missing value for --transport" };
249
- }
250
- if (value !== "stdio" && value !== "streamable-http") {
251
- return { transport, hostname, port, error: `Unsupported runtime MCP transport: ${value}` };
252
- }
253
- transport = value;
254
- index += 1;
255
- continue;
256
- }
257
- if (arg === "--host") {
258
- const value = args[index + 1];
259
- if (!value) {
260
- return { transport, hostname, port, error: "Missing value for --host" };
261
- }
262
- hostname = value;
263
- index += 1;
264
- continue;
265
- }
266
- if (arg === "--port") {
267
- const value = args[index + 1];
268
- if (!value) {
269
- return { transport, hostname, port, error: "Missing value for --port" };
270
- }
271
- const parsedPort = Number.parseInt(value, 10);
272
- if (!Number.isFinite(parsedPort) || parsedPort < 0) {
273
- return { transport, hostname, port, error: `Invalid runtime MCP port: ${value}` };
274
- }
275
- port = parsedPort;
276
- index += 1;
277
- continue;
278
- }
279
- return { transport, hostname, port, error: `Unknown option: ${arg}` };
280
- }
281
- return { workspaceRoot, transport, hostname, port };
282
- }
1
+ const l=["acp","a2a","mcp","ag-ui"];function w(s){let a,u,r,t,e,o,i;const n=(p,f)=>{if(!p)return{error:`Missing value for ${f}`};const c=Number.parseInt(p,10);return!Number.isFinite(c)||c<0?{error:`Invalid ${f} value: ${p}`}:c};for(let p=0;p<s.length;p+=1){const f=s[p];if(f==="--workspace"||f==="-w"){const c=s[p+1];if(!c)return{services:r??[...l],hostname:u,acpPort:t,a2aPort:e,mcpPort:o,agUiPort:i,error:"Missing value for --workspace"};a=c,p+=1;continue}if(f==="--services"){const c=s[p+1];if(!c)return{services:r??[...l],workspaceRoot:a,hostname:u,acpPort:t,a2aPort:e,mcpPort:o,agUiPort:i,error:"Missing value for --services"};const v=c.split(",").map(d=>d.trim()).filter(Boolean);if(v.length===0)return{services:r??[...l],workspaceRoot:a,hostname:u,acpPort:t,a2aPort:e,mcpPort:o,agUiPort:i,error:"Missing value for --services"};const m=v.find(d=>!l.includes(d));if(m)return{services:r??[...l],workspaceRoot:a,hostname:u,acpPort:t,a2aPort:e,mcpPort:o,agUiPort:i,error:`Unsupported managed service: ${m}`};r=Array.from(new Set(v)),p+=1;continue}if(f==="--host"){const c=s[p+1];if(!c)return{services:r??[...l],workspaceRoot:a,acpPort:t,a2aPort:e,mcpPort:o,agUiPort:i,error:"Missing value for --host"};u=c,p+=1;continue}if(f==="--acp-port"){const c=n(s[p+1],"--acp-port");if(typeof c!="number")return{services:r??[...l],workspaceRoot:a,hostname:u,acpPort:t,a2aPort:e,mcpPort:o,agUiPort:i,error:c.error};t=c,p+=1;continue}if(f==="--a2a-port"){const c=n(s[p+1],"--a2a-port");if(typeof c!="number")return{services:r??[...l],workspaceRoot:a,hostname:u,acpPort:t,a2aPort:e,mcpPort:o,agUiPort:i,error:c.error};e=c,p+=1;continue}if(f==="--mcp-port"){const c=n(s[p+1],"--mcp-port");if(typeof c!="number")return{services:r??[...l],workspaceRoot:a,hostname:u,acpPort:t,a2aPort:e,mcpPort:o,agUiPort:i,error:c.error};o=c,p+=1;continue}if(f==="--ag-ui-port"){const c=n(s[p+1],"--ag-ui-port");if(typeof c!="number")return{services:r??[...l],workspaceRoot:a,hostname:u,acpPort:t,a2aPort:e,mcpPort:o,agUiPort:i,error:c.error};i=c,p+=1;continue}return{services:r??[...l],workspaceRoot:a,hostname:u,acpPort:t,a2aPort:e,mcpPort:o,agUiPort:i,error:`Unknown option: ${f}`}}return{workspaceRoot:a,services:r??[...l],hostname:u,acpPort:t,a2aPort:e,mcpPort:o,agUiPort:i}}function M(s,a="stdio"){let u,r=a,t,e;for(let o=0;o<s.length;o+=1){const i=s[o];if(i==="--workspace"){const n=s[o+1];if(!n)return{transport:r,hostname:t,port:e,error:"Missing value for --workspace"};u=n,o+=1;continue}if(i==="--transport"){const n=s[o+1];if(!n)return{transport:r,hostname:t,port:e,error:"Missing value for --transport"};if(n!=="stdio"&&n!=="http")return{transport:r,hostname:t,port:e,error:`Unsupported ACP transport: ${n}`};r=n,o+=1;continue}if(i==="--host"){const n=s[o+1];if(!n)return{transport:r,hostname:t,port:e,error:"Missing value for --host"};t=n,o+=1;continue}if(i==="--port"){const n=s[o+1];if(!n)return{transport:r,hostname:t,port:e,error:"Missing value for --port"};const p=Number.parseInt(n,10);if(!Number.isFinite(p)||p<0)return{transport:r,hostname:t,port:e,error:`Invalid ACP port: ${n}`};e=p,o+=1;continue}return{transport:r,hostname:t,port:e,error:`Unknown option: ${i}`}}return{workspaceRoot:u,transport:r,hostname:t,port:e}}function k(s){let a;for(let u=0;u<s.length;u+=1){const r=s[u];if(r==="--workspace"){const t=s[u+1];if(!t)return{error:"Missing value for --workspace"};a=t,u+=1;continue}return{error:`Unknown option: ${r}`}}return{workspaceRoot:a}}function h(s,a="HTTP"){let u,r,t;for(let e=0;e<s.length;e+=1){const o=s[e];if(o==="--workspace"){const i=s[e+1];if(!i)return{hostname:r,port:t,error:"Missing value for --workspace"};u=i,e+=1;continue}if(o==="--host"){const i=s[e+1];if(!i)return{workspaceRoot:u,port:t,error:"Missing value for --host"};r=i,e+=1;continue}if(o==="--port"){const i=s[e+1];if(!i)return{workspaceRoot:u,hostname:r,error:"Missing value for --port"};const n=Number.parseInt(i,10);if(!Number.isFinite(n)||n<0)return{workspaceRoot:u,hostname:r,error:`Invalid ${a} port: ${i}`};t=n,e+=1;continue}return{workspaceRoot:u,hostname:r,port:t,error:`Unknown option: ${o}`}}return{workspaceRoot:u,hostname:r,port:t}}function P(s,a="stdio"){let u,r=a,t,e;for(let o=0;o<s.length;o+=1){const i=s[o];if(i==="--workspace"){const n=s[o+1];if(!n)return{transport:r,hostname:t,port:e,error:"Missing value for --workspace"};u=n,o+=1;continue}if(i==="--transport"){const n=s[o+1];if(!n)return{transport:r,hostname:t,port:e,error:"Missing value for --transport"};if(n!=="stdio"&&n!=="streamable-http")return{transport:r,hostname:t,port:e,error:`Unsupported runtime MCP transport: ${n}`};r=n,o+=1;continue}if(i==="--host"){const n=s[o+1];if(!n)return{transport:r,hostname:t,port:e,error:"Missing value for --host"};t=n,o+=1;continue}if(i==="--port"){const n=s[o+1];if(!n)return{transport:r,hostname:t,port:e,error:"Missing value for --port"};const p=Number.parseInt(n,10);if(!Number.isFinite(p)||p<0)return{transport:r,hostname:t,port:e,error:`Invalid runtime MCP port: ${n}`};e=p,o+=1;continue}return{transport:r,hostname:t,port:e,error:`Unknown option: ${i}`}}return{workspaceRoot:u,transport:r,hostname:t,port:e}}export{M as parseAcpServeOptions,h as parseHttpServeOptions,P as parseRuntimeMcpServeOptions,w as parseTopLevelManagedServiceOptions,k as parseWorkspaceOnlyOptions};
@@ -1,5 +1,4 @@
1
- export function renderUsage() {
2
- return `Usage:
1
+ function e(){return`Usage:
3
2
  agent-harness init <project-name> [--template deep-research|single-agent] [--provider <provider>] [--model <model>] [--with-web-search|--no-web-search]
4
3
  agent-harness chat [-w <path>] [--transport stdio|http] [--host <hostname>] [--port <port>] [--agent <agentId>] [--session <sessionId>] [--message <text>]
5
4
  agent-harness [-w <path>] [prompt]
@@ -35,20 +34,4 @@ export function renderUsage() {
35
34
  Run botbotgo or agent-harness from any folder.
36
35
  If ./config/ is absent, the runtime falls back to the bundled system defaults and bundled resources.
37
36
  Chat defaults to the current directory as the workspace. Use -w to point at another workspace.
38
- `;
39
- }
40
- export function isTopLevelCliCommand(value) {
41
- return value === "init"
42
- || value === "chat"
43
- || value === "start"
44
- || value === "stop"
45
- || value === "acp"
46
- || value === "a2a"
47
- || value === "ag-ui"
48
- || value === "mcp"
49
- || value === "runtime"
50
- || value === "runtime-mcp";
51
- }
52
- export { parseChatOptions, parseInitOptions } from "./options-init-chat.js";
53
- export { parseAcpServeOptions, parseHttpServeOptions, parseTopLevelManagedServiceOptions, parseRuntimeMcpServeOptions, parseWorkspaceOnlyOptions, } from "./options-serve.js";
54
- export { parseRuntimeExportOptions, parseRuntimeInspectOptions, parseScheduledRunOptions, } from "./options-runtime.js";
37
+ `}function s(t){return t==="init"||t==="chat"||t==="start"||t==="stop"||t==="acp"||t==="a2a"||t==="ag-ui"||t==="mcp"||t==="runtime"||t==="runtime-mcp"}import{parseChatOptions as o,parseInitOptions as p}from"./options-init-chat.js";import{parseAcpServeOptions as h,parseHttpServeOptions as i,parseTopLevelManagedServiceOptions as c,parseRuntimeMcpServeOptions as m,parseWorkspaceOnlyOptions as g}from"./options-serve.js";import{parseRuntimeExportOptions as u,parseRuntimeInspectOptions as w,parseScheduledRunOptions as k}from"./options-runtime.js";export{s as isTopLevelCliCommand,h as parseAcpServeOptions,o as parseChatOptions,i as parseHttpServeOptions,p as parseInitOptions,u as parseRuntimeExportOptions,w as parseRuntimeInspectOptions,m as parseRuntimeMcpServeOptions,k as parseScheduledRunOptions,c as parseTopLevelManagedServiceOptions,g as parseWorkspaceOnlyOptions,e as renderUsage};
@@ -1,139 +1 @@
1
- import { EventEmitter } from "node:events";
2
- const CLI_IGNORED_STDERR_WARNING_SNIPPETS = [
3
- "llamaindex was already imported. This breaks constructor checks and will lead to issues!",
4
- "MaxListenersExceededWarning: Possible EventEmitter memory leak detected.",
5
- "(Use `node --trace-warnings ...` to show where the warning was created)",
6
- ];
7
- export function isChatServerNoiseLine(line) {
8
- const trimmed = line.trim();
9
- if (!trimmed) {
10
- return true;
11
- }
12
- return (trimmed.startsWith("Serving ACP over stdio from ") ||
13
- trimmed === "langsmith/experimental/sandbox is in alpha. This feature is experimental, and breaking changes are expected." ||
14
- trimmed === "llamaindex was already imported. This breaks constructor checks and will lead to issues!");
15
- }
16
- export function installCliWriteListenerGuard(streams, minimum = 64) {
17
- const restore = [];
18
- for (const stream of streams) {
19
- if (!stream?.getMaxListeners || !stream?.setMaxListeners) {
20
- continue;
21
- }
22
- const previous = stream.getMaxListeners();
23
- if (previous === 0 || previous >= minimum) {
24
- continue;
25
- }
26
- stream.setMaxListeners(minimum);
27
- restore.push(() => stream.setMaxListeners?.(previous));
28
- }
29
- return () => {
30
- for (const reset of restore.reverse()) {
31
- reset();
32
- }
33
- };
34
- }
35
- export function installCliEmitterListenerGuard(minimum = 64) {
36
- const previous = EventEmitter.defaultMaxListeners;
37
- const hadPrototypeMaxListeners = Object.prototype.hasOwnProperty.call(EventEmitter.prototype, "_maxListeners");
38
- const previousPrototypeMaxListeners = EventEmitter.prototype._maxListeners;
39
- if (previous === 0 || previous >= minimum) {
40
- return () => undefined;
41
- }
42
- EventEmitter.defaultMaxListeners = minimum;
43
- EventEmitter.prototype._maxListeners = minimum;
44
- return () => {
45
- EventEmitter.defaultMaxListeners = previous;
46
- if (hadPrototypeMaxListeners) {
47
- EventEmitter.prototype._maxListeners = previousPrototypeMaxListeners;
48
- return;
49
- }
50
- delete EventEmitter.prototype._maxListeners;
51
- };
52
- }
53
- export function installCliStderrNoiseFilter(enabled) {
54
- if (!enabled) {
55
- return () => undefined;
56
- }
57
- const originalStderrWrite = process.stderr.write.bind(process.stderr);
58
- process.stderr.write = ((chunk, encoding, callback) => {
59
- const text = typeof chunk === "string"
60
- ? chunk
61
- : chunk instanceof Uint8Array
62
- ? Buffer.from(chunk).toString(typeof encoding === "string" ? encoding : undefined)
63
- : "";
64
- if (CLI_IGNORED_STDERR_WARNING_SNIPPETS.some((snippet) => text.includes(snippet))) {
65
- if (typeof encoding === "function") {
66
- encoding();
67
- }
68
- else if (typeof callback === "function") {
69
- callback();
70
- }
71
- return true;
72
- }
73
- if (typeof encoding === "function") {
74
- return originalStderrWrite(chunk, encoding);
75
- }
76
- return originalStderrWrite(chunk, encoding, callback);
77
- });
78
- return () => {
79
- process.stderr.write = originalStderrWrite;
80
- };
81
- }
82
- export function installCliWarningFilter() {
83
- const originalEmitWarning = process.emitWarning.bind(process);
84
- process.emitWarning = ((warning, ...args) => {
85
- const text = typeof warning === "string" ? warning : warning?.message ?? "";
86
- const name = typeof warning === "string" ? String(args[1] ?? args[0] ?? "") : warning?.name ?? "";
87
- if (CLI_IGNORED_STDERR_WARNING_SNIPPETS.some((snippet) => text.includes(snippet))
88
- || name === "MaxListenersExceededWarning") {
89
- return;
90
- }
91
- return originalEmitWarning(warning, ...args);
92
- });
93
- return () => {
94
- process.emitWarning = originalEmitWarning;
95
- };
96
- }
97
- function terminateChatSubprocess(child, signal = "SIGTERM") {
98
- if (child.killed || child.exitCode !== null || child.signalCode !== null) {
99
- return;
100
- }
101
- try {
102
- child.kill(signal);
103
- }
104
- catch {
105
- // Ignore termination races during shutdown.
106
- }
107
- }
108
- export function installChatSubprocessExitGuard(child, host = process) {
109
- let cleanedUp = false;
110
- let forceKillTimer;
111
- const handleParentExit = () => {
112
- terminateChatSubprocess(child, "SIGTERM");
113
- if (!forceKillTimer && child.exitCode === null && child.signalCode === null) {
114
- forceKillTimer = setTimeout(() => {
115
- terminateChatSubprocess(child, "SIGKILL");
116
- }, 2_000);
117
- forceKillTimer.unref?.();
118
- }
119
- };
120
- const cleanup = () => {
121
- if (cleanedUp) {
122
- return;
123
- }
124
- cleanedUp = true;
125
- if (forceKillTimer) {
126
- clearTimeout(forceKillTimer);
127
- forceKillTimer = undefined;
128
- }
129
- host.off("beforeExit", handleParentExit);
130
- host.off("exit", handleParentExit);
131
- child.off("close", cleanup);
132
- child.off("exit", cleanup);
133
- };
134
- host.on("beforeExit", handleParentExit);
135
- host.on("exit", handleParentExit);
136
- child.on("close", cleanup);
137
- child.on("exit", cleanup);
138
- return cleanup;
139
- }
1
+ import{EventEmitter as o}from"node:events";const a=["llamaindex was already imported. This breaks constructor checks and will lead to issues!","MaxListenersExceededWarning: Possible EventEmitter memory leak detected.","(Use `node --trace-warnings ...` to show where the warning was created)"];function p(t){const e=t.trim();return e?e.startsWith("Serving ACP over stdio from ")||e==="langsmith/experimental/sandbox is in alpha. This feature is experimental, and breaking changes are expected."||e==="llamaindex was already imported. This breaks constructor checks and will lead to issues!":!0}function x(t,e=64){const s=[];for(const r of t){if(!r?.getMaxListeners||!r?.setMaxListeners)continue;const n=r.getMaxListeners();n===0||n>=e||(r.setMaxListeners(e),s.push(()=>r.setMaxListeners?.(n)))}return()=>{for(const r of s.reverse())r()}}function c(t=64){const e=o.defaultMaxListeners,s=Object.prototype.hasOwnProperty.call(o.prototype,"_maxListeners"),r=o.prototype._maxListeners;return e===0||e>=t?()=>{}:(o.defaultMaxListeners=t,o.prototype._maxListeners=t,()=>{if(o.defaultMaxListeners=e,s){o.prototype._maxListeners=r;return}delete o.prototype._maxListeners})}function d(t){if(!t)return()=>{};const e=process.stderr.write.bind(process.stderr);return process.stderr.write=((s,r,n)=>{const i=typeof s=="string"?s:s instanceof Uint8Array?Buffer.from(s).toString(typeof r=="string"?r:void 0):"";return a.some(l=>i.includes(l))?(typeof r=="function"?r():typeof n=="function"&&n(),!0):typeof r=="function"?e(s,r):e(s,r,n)}),()=>{process.stderr.write=e}}function m(){const t=process.emitWarning.bind(process);return process.emitWarning=((e,...s)=>{const r=typeof e=="string"?e:e?.message??"",n=typeof e=="string"?String(s[1]??s[0]??""):e?.name??"";if(!(a.some(i=>r.includes(i))||n==="MaxListenersExceededWarning"))return t(e,...s)}),()=>{process.emitWarning=t}}function f(t,e="SIGTERM"){if(!(t.killed||t.exitCode!==null||t.signalCode!==null))try{t.kill(e)}catch{}}function L(t,e=process){let s=!1,r;const n=()=>{f(t,"SIGTERM"),!r&&t.exitCode===null&&t.signalCode===null&&(r=setTimeout(()=>{f(t,"SIGKILL")},2e3),r.unref?.())},i=()=>{s||(s=!0,r&&(clearTimeout(r),r=void 0),e.off("beforeExit",n),e.off("exit",n),t.off("close",i),t.off("exit",i))};return e.on("beforeExit",n),e.on("exit",n),t.on("close",i),t.on("exit",i),i}export{L as installChatSubprocessExitGuard,c as installCliEmitterListenerGuard,d as installCliStderrNoiseFilter,m as installCliWarningFilter,x as installCliWriteListenerGuard,p as isChatServerNoiseLine};