@botbotgo/agent-harness 0.0.308 → 0.0.310

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 (195) hide show
  1. package/README.md +17 -1
  2. package/README.zh.md +17 -1
  3. package/dist/acp.d.ts +1 -116
  4. package/dist/acp.js +1 -310
  5. package/dist/api.d.ts +4 -2
  6. package/dist/api.js +4 -1
  7. package/dist/cli/chat-interactive.d.ts +24 -0
  8. package/dist/cli/chat-interactive.js +244 -0
  9. package/dist/cli/chat-rendering.d.ts +9 -0
  10. package/dist/cli/chat-rendering.js +102 -0
  11. package/dist/cli/chat-stream.d.ts +23 -0
  12. package/dist/cli/chat-stream.js +330 -0
  13. package/dist/cli/chat-ui.d.ts +20 -0
  14. package/dist/cli/chat-ui.js +198 -0
  15. package/dist/cli/chat-workspace.d.ts +15 -0
  16. package/dist/cli/chat-workspace.js +205 -0
  17. package/dist/cli/main.d.ts +52 -0
  18. package/dist/cli/main.js +323 -0
  19. package/dist/cli/managed-service-commands.d.ts +23 -0
  20. package/dist/cli/managed-service-commands.js +63 -0
  21. package/dist/cli/managed-service.d.ts +27 -0
  22. package/dist/cli/managed-service.js +61 -0
  23. package/dist/cli/options-init-chat.d.ts +16 -0
  24. package/dist/cli/options-init-chat.js +108 -0
  25. package/dist/cli/options-runtime.d.ts +27 -0
  26. package/dist/cli/options-runtime.js +158 -0
  27. package/dist/cli/options-serve.d.ts +24 -0
  28. package/dist/cli/options-serve.js +166 -0
  29. package/dist/cli/options.d.ts +5 -0
  30. package/dist/cli/options.js +47 -0
  31. package/dist/cli/process-guards.d.ts +14 -0
  32. package/dist/cli/process-guards.js +139 -0
  33. package/dist/cli/request-tree.d.ts +12 -0
  34. package/dist/cli/request-tree.js +296 -0
  35. package/dist/cli/runtime-commands.d.ts +15 -0
  36. package/dist/cli/runtime-commands.js +247 -0
  37. package/dist/cli/runtime-output.d.ts +5 -0
  38. package/dist/cli/runtime-output.js +124 -0
  39. package/dist/cli/server-commands.d.ts +36 -0
  40. package/dist/cli/server-commands.js +250 -0
  41. package/dist/cli/workspace.d.ts +6 -0
  42. package/dist/cli/workspace.js +71 -0
  43. package/dist/cli.d.ts +1 -67
  44. package/dist/cli.js +2 -2734
  45. package/dist/client/acp.d.ts +1 -50
  46. package/dist/client/acp.js +1 -219
  47. package/dist/client/in-process.d.ts +5 -5
  48. package/dist/client/index.d.ts +2 -2
  49. package/dist/client/index.js +1 -1
  50. package/dist/contracts/runtime-evaluation.d.ts +103 -0
  51. package/dist/contracts/runtime-evaluation.js +1 -0
  52. package/dist/contracts/runtime-memory.d.ts +162 -0
  53. package/dist/contracts/runtime-memory.js +1 -0
  54. package/dist/contracts/runtime-observability.d.ts +248 -0
  55. package/dist/contracts/runtime-observability.js +1 -0
  56. package/dist/contracts/runtime-requests.d.ts +342 -0
  57. package/dist/contracts/runtime-requests.js +1 -0
  58. package/dist/contracts/runtime-scheduling.d.ts +146 -0
  59. package/dist/contracts/runtime-scheduling.js +1 -0
  60. package/dist/contracts/runtime.d.ts +5 -1042
  61. package/dist/contracts/runtime.js +27 -1
  62. package/dist/flow/build-flow-graph.js +4 -875
  63. package/dist/flow/flow-graph-normalization.d.ts +56 -0
  64. package/dist/flow/flow-graph-normalization.js +214 -0
  65. package/dist/flow/flow-graph-runtime.d.ts +8 -0
  66. package/dist/flow/flow-graph-runtime.js +107 -0
  67. package/dist/flow/flow-graph-upstream.d.ts +18 -0
  68. package/dist/flow/flow-graph-upstream.js +498 -0
  69. package/dist/flow/types.d.ts +1 -1
  70. package/dist/index.d.ts +4 -4
  71. package/dist/index.js +2 -2
  72. package/dist/init-project.d.ts +1 -12
  73. package/dist/init-project.js +1 -651
  74. package/dist/{procedural → knowledge/procedural}/manager.d.ts +3 -3
  75. package/dist/{procedural → knowledge/procedural}/manager.js +6 -6
  76. package/dist/mcp.d.ts +2 -62
  77. package/dist/mcp.js +2 -253
  78. package/dist/package-version.d.ts +1 -1
  79. package/dist/package-version.js +1 -1
  80. package/dist/persistence/file-store.js +1 -1
  81. package/dist/persistence/sqlite-runtime.d.ts +19 -0
  82. package/dist/persistence/sqlite-runtime.js +86 -0
  83. package/dist/persistence/sqlite-store.js +11 -99
  84. package/dist/{request-events.d.ts → projections/request-events.d.ts} +1 -1
  85. package/dist/{upstream-events.js → projections/upstream-events.js} +1 -1
  86. package/dist/protocol/a2a/http-discovery.d.ts +39 -0
  87. package/dist/protocol/a2a/http-discovery.js +178 -0
  88. package/dist/protocol/a2a/http-rpc.d.ts +28 -0
  89. package/dist/protocol/a2a/http-rpc.js +623 -0
  90. package/dist/protocol/a2a/http.d.ts +72 -1
  91. package/dist/protocol/a2a/http.js +14 -1124
  92. package/dist/protocol/a2a/task-state.d.ts +29 -0
  93. package/dist/protocol/a2a/task-state.js +317 -0
  94. package/dist/protocol/acp/client.js +1 -1
  95. package/dist/protocol/acp/harness-client.d.ts +50 -0
  96. package/dist/protocol/acp/harness-client.js +219 -0
  97. package/dist/protocol/acp/server.d.ts +116 -0
  98. package/dist/protocol/acp/server.js +310 -0
  99. package/dist/protocol/ag-ui/http.js +1 -1
  100. package/dist/protocol/mcp/server.d.ts +76 -0
  101. package/dist/protocol/mcp/server.js +428 -0
  102. package/dist/resource/backend/workspace-scoped-backend.d.ts +40 -0
  103. package/dist/resource/backend/workspace-scoped-backend.js +296 -0
  104. package/dist/resource/mcp/tool-support.d.ts +35 -0
  105. package/dist/resource/mcp/tool-support.js +296 -0
  106. package/dist/resource/mcp-tool-support.d.ts +2 -35
  107. package/dist/resource/mcp-tool-support.js +2 -296
  108. package/dist/resource/providers/resource-provider.d.ts +22 -0
  109. package/dist/resource/providers/resource-provider.js +215 -0
  110. package/dist/resource/resource-impl.d.ts +3 -33
  111. package/dist/resource/resource-impl.js +2 -808
  112. package/dist/resource/resource-types.d.ts +33 -0
  113. package/dist/resource/resource-types.js +1 -0
  114. package/dist/resource/tools/function-tool-resolver.d.ts +2 -0
  115. package/dist/resource/tools/function-tool-resolver.js +306 -0
  116. package/dist/runtime/adapter/middleware-assembly.js +1 -1
  117. package/dist/runtime/adapter/model/invocation-request.js +2 -2
  118. package/dist/runtime/adapter/model/message-assembly.js +1 -1
  119. package/dist/runtime/agent-runtime-adapter.d.ts +3 -63
  120. package/dist/runtime/agent-runtime-adapter.js +5 -233
  121. package/dist/runtime/agent-runtime-assembly.d.ts +67 -0
  122. package/dist/runtime/agent-runtime-assembly.js +211 -0
  123. package/dist/runtime/harness/background-runtime.d.ts +1 -1
  124. package/dist/runtime/harness/events/event-sink.js +1 -1
  125. package/dist/runtime/harness/events/runtime-event-operations.d.ts +1 -1
  126. package/dist/runtime/harness/events/streaming.js +1 -1
  127. package/dist/runtime/harness/public-shapes.d.ts +43 -0
  128. package/dist/runtime/harness/public-shapes.js +186 -0
  129. package/dist/runtime/harness/run/inspection.js +2 -2
  130. package/dist/runtime/harness/run/resources.js +1 -1
  131. package/dist/runtime/harness/run/surface-semantics.js +1 -1
  132. package/dist/runtime/harness/system/inventory.d.ts +1 -1
  133. package/dist/runtime/harness/system/inventory.js +2 -2
  134. package/dist/runtime/harness/system/policy-engine.js +1 -1
  135. package/dist/runtime/harness/system/runtime-memory-manager.js +1 -1
  136. package/dist/runtime/harness/system/skill-requirements.d.ts +1 -1
  137. package/dist/runtime/harness/system/skill-requirements.js +1 -1
  138. package/dist/runtime/harness.d.ts +3 -2
  139. package/dist/runtime/harness.js +11 -191
  140. package/dist/runtime/maintenance/checkpoint-maintenance.js +1 -1
  141. package/dist/runtime/maintenance/runtime-record-maintenance.js +1 -1
  142. package/dist/runtime/parsing/output-content.d.ts +11 -0
  143. package/dist/runtime/parsing/output-content.js +442 -0
  144. package/dist/runtime/parsing/output-parsing.d.ts +3 -29
  145. package/dist/runtime/parsing/output-parsing.js +3 -806
  146. package/dist/runtime/parsing/output-recovery.d.ts +14 -0
  147. package/dist/runtime/parsing/output-recovery.js +288 -0
  148. package/dist/runtime/parsing/output-tool-args.d.ts +4 -0
  149. package/dist/runtime/parsing/output-tool-args.js +120 -0
  150. package/dist/runtime/support/runtime-factories.js +1 -1
  151. package/dist/scaffold/init-project.d.ts +12 -0
  152. package/dist/scaffold/init-project.js +651 -0
  153. package/dist/{extensions.d.ts → tooling/extensions.d.ts} +1 -1
  154. package/dist/{extensions.js → tooling/extensions.js} +3 -3
  155. package/dist/{tool-modules.d.ts → tooling/module-loader.d.ts} +1 -1
  156. package/dist/{tool-modules.js → tooling/module-loader.js} +2 -2
  157. package/dist/workspace/agent-binding-compiler.js +2 -2
  158. package/dist/workspace/compile.js +2 -2
  159. package/dist/workspace/object-loader-paths.d.ts +11 -0
  160. package/dist/workspace/object-loader-paths.js +75 -0
  161. package/dist/workspace/object-loader-readers.d.ts +21 -0
  162. package/dist/workspace/object-loader-readers.js +187 -0
  163. package/dist/workspace/object-loader.d.ts +0 -1
  164. package/dist/workspace/object-loader.js +6 -260
  165. package/dist/workspace/resource-compilers.js +1 -1
  166. package/dist/workspace/support/discovery.js +1 -1
  167. package/package.json +1 -1
  168. package/dist/runtime/adapter/index.d.ts +0 -13
  169. package/dist/runtime/adapter/index.js +0 -13
  170. package/dist/runtime/harness/index.d.ts +0 -19
  171. package/dist/runtime/harness/index.js +0 -19
  172. package/dist/runtime/maintenance/index.d.ts +0 -4
  173. package/dist/runtime/maintenance/index.js +0 -4
  174. package/dist/runtime/parsing/index.d.ts +0 -2
  175. package/dist/runtime/parsing/index.js +0 -2
  176. package/dist/runtime/support/index.d.ts +0 -4
  177. package/dist/runtime/support/index.js +0 -4
  178. package/dist/workspace/support/index.d.ts +0 -2
  179. package/dist/workspace/support/index.js +0 -2
  180. /package/dist/{procedural → knowledge/procedural}/config.d.ts +0 -0
  181. /package/dist/{procedural → knowledge/procedural}/config.js +0 -0
  182. /package/dist/{procedural → knowledge/procedural}/index.d.ts +0 -0
  183. /package/dist/{procedural → knowledge/procedural}/index.js +0 -0
  184. /package/dist/{presentation.d.ts → projections/presentation.d.ts} +0 -0
  185. /package/dist/{presentation.js → projections/presentation.js} +0 -0
  186. /package/dist/{request-events.js → projections/request-events.js} +0 -0
  187. /package/dist/{upstream-events.d.ts → projections/upstream-events.d.ts} +0 -0
  188. /package/dist/runtime/{support → env}/runtime-env.d.ts +0 -0
  189. /package/dist/runtime/{support → env}/runtime-env.js +0 -0
  190. /package/dist/runtime/{support → layout}/runtime-layout.d.ts +0 -0
  191. /package/dist/runtime/{support → layout}/runtime-layout.js +0 -0
  192. /package/dist/runtime/{support → prompts}/runtime-prompts.d.ts +0 -0
  193. /package/dist/runtime/{support → prompts}/runtime-prompts.js +0 -0
  194. /package/dist/runtime/{support → skills}/skill-metadata.d.ts +0 -0
  195. /package/dist/runtime/{support → skills}/skill-metadata.js +0 -0
@@ -0,0 +1,27 @@
1
+ export type ManagedCliService = "acp" | "a2a" | "mcp";
2
+ export type ManagedCliServiceState = {
3
+ pid: number;
4
+ service: ManagedCliService;
5
+ workspaceRoot: string;
6
+ transport: "http" | "streamable-http";
7
+ hostname?: string;
8
+ port?: number;
9
+ startedAt: string;
10
+ stdoutPath: string;
11
+ stderrPath: string;
12
+ };
13
+ export declare function managedServiceLogPath(workspaceRoot: string, service: ManagedCliService, stream: "stdout" | "stderr"): string;
14
+ export declare function readManagedServiceState(workspaceRoot: string, service: ManagedCliService): Promise<ManagedCliServiceState | null>;
15
+ export declare function writeManagedServiceState(state: ManagedCliServiceState): Promise<void>;
16
+ export declare function clearManagedServiceState(workspaceRoot: string, service: ManagedCliService): Promise<void>;
17
+ export declare function defaultIsManagedProcessRunning(pid: number): boolean;
18
+ export declare function defaultSignalManagedProcess(pid: number, signal?: NodeJS.Signals): void;
19
+ export declare function defaultSpawnManagedCliProcess(input: {
20
+ args: string[];
21
+ cwd: string;
22
+ stdoutPath: string;
23
+ stderrPath: string;
24
+ }): Promise<{
25
+ pid?: number;
26
+ }>;
27
+ export declare function sleep(ms: number): Promise<void>;
@@ -0,0 +1,61 @@
1
+ import { spawn } from "node:child_process";
2
+ import { existsSync, openSync } from "node:fs";
3
+ import { mkdir, readFile, rm, writeFile } from "node:fs/promises";
4
+ import path from "node:path";
5
+ import { fileURLToPath } from "node:url";
6
+ function resolveManagedServiceRoot(workspaceRoot) {
7
+ return path.join(workspaceRoot, ".botbotgo", "services");
8
+ }
9
+ function managedServiceStatePath(workspaceRoot, service) {
10
+ return path.join(resolveManagedServiceRoot(workspaceRoot), `${service}.json`);
11
+ }
12
+ export function managedServiceLogPath(workspaceRoot, service, stream) {
13
+ return path.join(resolveManagedServiceRoot(workspaceRoot), `${service}.${stream}.log`);
14
+ }
15
+ export async function readManagedServiceState(workspaceRoot, service) {
16
+ const statePath = managedServiceStatePath(workspaceRoot, service);
17
+ if (!existsSync(statePath)) {
18
+ return null;
19
+ }
20
+ try {
21
+ return JSON.parse(await readFile(statePath, "utf8"));
22
+ }
23
+ catch {
24
+ return null;
25
+ }
26
+ }
27
+ export async function writeManagedServiceState(state) {
28
+ const statePath = managedServiceStatePath(state.workspaceRoot, state.service);
29
+ await mkdir(path.dirname(statePath), { recursive: true });
30
+ await writeFile(statePath, `${JSON.stringify(state, null, 2)}\n`, "utf8");
31
+ }
32
+ export async function clearManagedServiceState(workspaceRoot, service) {
33
+ await rm(managedServiceStatePath(workspaceRoot, service), { force: true });
34
+ }
35
+ export function defaultIsManagedProcessRunning(pid) {
36
+ try {
37
+ process.kill(pid, 0);
38
+ return true;
39
+ }
40
+ catch {
41
+ return false;
42
+ }
43
+ }
44
+ export function defaultSignalManagedProcess(pid, signal) {
45
+ process.kill(pid, signal);
46
+ }
47
+ export async function defaultSpawnManagedCliProcess(input) {
48
+ await mkdir(path.dirname(input.stdoutPath), { recursive: true });
49
+ const stdoutFd = openSync(input.stdoutPath, "a");
50
+ const stderrFd = openSync(input.stderrPath, "a");
51
+ const child = spawn(process.execPath, [fileURLToPath(import.meta.url), ...input.args], {
52
+ cwd: input.cwd,
53
+ detached: true,
54
+ stdio: ["ignore", stdoutFd, stderrFd],
55
+ });
56
+ child.unref();
57
+ return { pid: child.pid };
58
+ }
59
+ export async function sleep(ms) {
60
+ await new Promise((resolve) => setTimeout(resolve, ms));
61
+ }
@@ -0,0 +1,16 @@
1
+ import type { InitProjectOptions } from "../init-project.js";
2
+ export declare function parseInitOptions(args: string[]): {
3
+ options?: InitProjectOptions;
4
+ error?: string;
5
+ };
6
+ export declare function parseChatOptions(args: string[]): {
7
+ workspaceRoot?: string;
8
+ agentId?: string;
9
+ sessionId?: string;
10
+ message?: string;
11
+ requestEvents: boolean;
12
+ transport: "stdio" | "http";
13
+ hostname?: string;
14
+ port?: number;
15
+ error?: string;
16
+ };
@@ -0,0 +1,108 @@
1
+ function isTemplate(value) {
2
+ return value === "deep-research" || value === "single-agent";
3
+ }
4
+ export function parseInitOptions(args) {
5
+ const options = {};
6
+ for (let index = 0; index < args.length; index += 1) {
7
+ const arg = args[index];
8
+ if (arg === "--with-web-search") {
9
+ options.withWebSearch = true;
10
+ continue;
11
+ }
12
+ if (arg === "--no-web-search") {
13
+ options.withWebSearch = false;
14
+ continue;
15
+ }
16
+ if (arg === "--template" || arg === "--provider" || arg === "--model") {
17
+ const value = args[index + 1];
18
+ if (!value) {
19
+ return { error: `Missing value for ${arg}` };
20
+ }
21
+ if (arg === "--template") {
22
+ if (!isTemplate(value)) {
23
+ return { error: `Unsupported template: ${value}` };
24
+ }
25
+ options.template = value;
26
+ }
27
+ else if (arg === "--provider") {
28
+ options.provider = value;
29
+ }
30
+ else {
31
+ options.model = value;
32
+ }
33
+ index += 1;
34
+ continue;
35
+ }
36
+ return { error: `Unknown option: ${arg}` };
37
+ }
38
+ return { options };
39
+ }
40
+ export function parseChatOptions(args) {
41
+ let workspaceRoot;
42
+ let agentId;
43
+ let sessionId;
44
+ let message;
45
+ let requestEvents = false;
46
+ let transport = "stdio";
47
+ let hostname;
48
+ let port;
49
+ const positional = [];
50
+ for (let index = 0; index < args.length; index += 1) {
51
+ const arg = args[index];
52
+ if (arg === "--workspace"
53
+ || arg === "-w"
54
+ || arg === "--agent"
55
+ || arg === "--session"
56
+ || arg === "--message"
57
+ || arg === "--transport"
58
+ || arg === "--host"
59
+ || arg === "--port") {
60
+ const value = args[index + 1];
61
+ if (!value) {
62
+ return { workspaceRoot, agentId, sessionId, message, requestEvents, transport, hostname, port, error: `Missing value for ${arg}` };
63
+ }
64
+ if (arg === "--workspace" || arg === "-w") {
65
+ workspaceRoot = value;
66
+ }
67
+ else if (arg === "--agent") {
68
+ agentId = value;
69
+ }
70
+ else if (arg === "--session") {
71
+ sessionId = value;
72
+ }
73
+ else if (arg === "--message") {
74
+ message = value;
75
+ }
76
+ else if (arg === "--transport") {
77
+ if (value !== "stdio" && value !== "http") {
78
+ return { workspaceRoot, agentId, sessionId, message, requestEvents, transport, hostname, port, error: `Unsupported chat transport: ${value}` };
79
+ }
80
+ transport = value;
81
+ }
82
+ else if (arg === "--host") {
83
+ hostname = value;
84
+ }
85
+ else {
86
+ const parsedPort = Number.parseInt(value, 10);
87
+ if (!Number.isFinite(parsedPort) || parsedPort <= 0) {
88
+ return { workspaceRoot, agentId, sessionId, message, requestEvents, transport, hostname, port, error: `Invalid chat port: ${value}` };
89
+ }
90
+ port = parsedPort;
91
+ }
92
+ index += 1;
93
+ continue;
94
+ }
95
+ if (arg === "--request-events") {
96
+ requestEvents = true;
97
+ continue;
98
+ }
99
+ if (arg.startsWith("-")) {
100
+ return { workspaceRoot, agentId, sessionId, message, requestEvents, transport, hostname, port, error: `Unknown option: ${arg}` };
101
+ }
102
+ positional.push(arg);
103
+ }
104
+ if (!message && positional.length > 0) {
105
+ message = positional.join(" ");
106
+ }
107
+ return { workspaceRoot, agentId, sessionId, message, requestEvents, transport, hostname, port };
108
+ }
@@ -0,0 +1,27 @@
1
+ export declare function parseRuntimeInspectOptions(args: string[]): {
2
+ workspaceRoot?: string;
3
+ json: boolean;
4
+ once: boolean;
5
+ pollMs: number;
6
+ limit: number;
7
+ status?: string;
8
+ state?: string;
9
+ agentId?: string;
10
+ sessionId?: string;
11
+ error?: string;
12
+ };
13
+ export declare function parseRuntimeExportOptions(args: string[]): {
14
+ workspaceRoot?: string;
15
+ sessionId?: string;
16
+ requestId?: string;
17
+ includeArtifacts: boolean;
18
+ includeArtifactContents: boolean;
19
+ includeRuntimeHealth: boolean;
20
+ json: boolean;
21
+ error?: string;
22
+ };
23
+ export declare function parseScheduledRunOptions(args: string[]): {
24
+ workspaceRoot?: string;
25
+ scheduleId?: string;
26
+ error?: string;
27
+ };
@@ -0,0 +1,158 @@
1
+ export function parseRuntimeInspectOptions(args) {
2
+ let workspaceRoot;
3
+ let json = false;
4
+ let once = false;
5
+ let pollMs = 1000;
6
+ let limit = 5;
7
+ let status;
8
+ let state;
9
+ let agentId;
10
+ let sessionId;
11
+ for (let index = 0; index < args.length; index += 1) {
12
+ const arg = args[index];
13
+ if (arg === "--workspace" || arg === "--status" || arg === "--state" || arg === "--agent" || arg === "--session" || arg === "--poll-ms" || arg === "--limit") {
14
+ const value = args[index + 1];
15
+ if (!value) {
16
+ return { json, once, pollMs, limit, status, state, agentId, sessionId, error: `Missing value for ${arg}` };
17
+ }
18
+ if (arg === "--workspace") {
19
+ workspaceRoot = value;
20
+ }
21
+ else if (arg === "--status") {
22
+ status = value;
23
+ }
24
+ else if (arg === "--state") {
25
+ state = value;
26
+ }
27
+ else if (arg === "--agent") {
28
+ agentId = value;
29
+ }
30
+ else if (arg === "--session") {
31
+ sessionId = value;
32
+ }
33
+ else if (arg === "--limit") {
34
+ const parsedLimit = Number.parseInt(value, 10);
35
+ if (!Number.isFinite(parsedLimit) || parsedLimit <= 0) {
36
+ return { json, once, pollMs, limit, status, state, agentId, sessionId, error: `Invalid limit: ${value}` };
37
+ }
38
+ limit = parsedLimit;
39
+ }
40
+ else {
41
+ const parsedPoll = Number.parseInt(value, 10);
42
+ if (!Number.isFinite(parsedPoll) || parsedPoll <= 0) {
43
+ return { json, once, pollMs, limit, status, state, agentId, sessionId, error: `Invalid poll interval: ${value}` };
44
+ }
45
+ pollMs = parsedPoll;
46
+ }
47
+ index += 1;
48
+ continue;
49
+ }
50
+ if (arg === "--json") {
51
+ json = true;
52
+ continue;
53
+ }
54
+ if (arg === "--once") {
55
+ once = true;
56
+ continue;
57
+ }
58
+ return { workspaceRoot, json, once, pollMs, limit, status, state, agentId, sessionId, error: `Unknown option: ${arg}` };
59
+ }
60
+ return { workspaceRoot, json, once, pollMs, limit, status, state, agentId, sessionId };
61
+ }
62
+ export function parseRuntimeExportOptions(args) {
63
+ let workspaceRoot;
64
+ let sessionId;
65
+ let requestId;
66
+ let includeArtifacts = false;
67
+ let includeArtifactContents = false;
68
+ let includeRuntimeHealth = false;
69
+ let json = false;
70
+ for (let index = 0; index < args.length; index += 1) {
71
+ const arg = args[index];
72
+ if (arg === "--artifacts") {
73
+ includeArtifacts = true;
74
+ continue;
75
+ }
76
+ if (arg === "--artifact-contents") {
77
+ includeArtifacts = true;
78
+ includeArtifactContents = true;
79
+ continue;
80
+ }
81
+ if (arg === "--health") {
82
+ includeRuntimeHealth = true;
83
+ continue;
84
+ }
85
+ if (arg === "--json") {
86
+ json = true;
87
+ continue;
88
+ }
89
+ if (arg === "--workspace" || arg === "--session" || arg === "--request") {
90
+ const value = args[index + 1];
91
+ if (!value) {
92
+ return {
93
+ workspaceRoot,
94
+ sessionId,
95
+ requestId,
96
+ includeArtifacts,
97
+ includeArtifactContents,
98
+ includeRuntimeHealth,
99
+ json,
100
+ error: `Missing value for ${arg}`,
101
+ };
102
+ }
103
+ if (arg === "--workspace") {
104
+ workspaceRoot = value;
105
+ }
106
+ else if (arg === "--session") {
107
+ sessionId = value;
108
+ }
109
+ else {
110
+ requestId = value;
111
+ }
112
+ index += 1;
113
+ continue;
114
+ }
115
+ return {
116
+ workspaceRoot,
117
+ sessionId,
118
+ requestId,
119
+ includeArtifacts,
120
+ includeArtifactContents,
121
+ includeRuntimeHealth,
122
+ json,
123
+ error: `Unknown option: ${arg}`,
124
+ };
125
+ }
126
+ return {
127
+ workspaceRoot,
128
+ sessionId,
129
+ requestId,
130
+ includeArtifacts,
131
+ includeArtifactContents,
132
+ includeRuntimeHealth,
133
+ json,
134
+ };
135
+ }
136
+ export function parseScheduledRunOptions(args) {
137
+ let workspaceRoot;
138
+ let scheduleId;
139
+ for (let index = 0; index < args.length; index += 1) {
140
+ const arg = args[index];
141
+ if (arg === "--workspace" || arg === "--schedule") {
142
+ const value = args[index + 1];
143
+ if (!value) {
144
+ return { workspaceRoot, scheduleId, error: `Missing value for ${arg}` };
145
+ }
146
+ if (arg === "--workspace") {
147
+ workspaceRoot = value;
148
+ }
149
+ else {
150
+ scheduleId = value;
151
+ }
152
+ index += 1;
153
+ continue;
154
+ }
155
+ return { workspaceRoot, scheduleId, error: `Unknown option: ${arg}` };
156
+ }
157
+ return { workspaceRoot, scheduleId };
158
+ }
@@ -0,0 +1,24 @@
1
+ export declare function parseAcpServeOptions(args: string[], defaultTransport?: "stdio" | "http"): {
2
+ workspaceRoot?: string;
3
+ transport: "stdio" | "http";
4
+ hostname?: string;
5
+ port?: number;
6
+ error?: string;
7
+ };
8
+ export declare function parseWorkspaceOnlyOptions(args: string[]): {
9
+ workspaceRoot?: string;
10
+ error?: string;
11
+ };
12
+ export declare function parseHttpServeOptions(args: string[], serviceLabel?: string): {
13
+ workspaceRoot?: string;
14
+ hostname?: string;
15
+ port?: number;
16
+ error?: string;
17
+ };
18
+ export declare function parseRuntimeMcpServeOptions(args: string[], defaultTransport?: "stdio" | "streamable-http"): {
19
+ workspaceRoot?: string;
20
+ transport: "stdio" | "streamable-http";
21
+ hostname?: string;
22
+ port?: number;
23
+ error?: string;
24
+ };
@@ -0,0 +1,166 @@
1
+ export function parseAcpServeOptions(args, defaultTransport = "stdio") {
2
+ let workspaceRoot;
3
+ let transport = defaultTransport;
4
+ let hostname;
5
+ let port;
6
+ for (let index = 0; index < args.length; index += 1) {
7
+ const arg = args[index];
8
+ if (arg === "--workspace") {
9
+ const value = args[index + 1];
10
+ if (!value) {
11
+ return { transport, hostname, port, error: "Missing value for --workspace" };
12
+ }
13
+ workspaceRoot = value;
14
+ index += 1;
15
+ continue;
16
+ }
17
+ if (arg === "--transport") {
18
+ const value = args[index + 1];
19
+ if (!value) {
20
+ return { transport, hostname, port, error: "Missing value for --transport" };
21
+ }
22
+ if (value !== "stdio" && value !== "http") {
23
+ return { transport, hostname, port, error: `Unsupported ACP transport: ${value}` };
24
+ }
25
+ transport = value;
26
+ index += 1;
27
+ continue;
28
+ }
29
+ if (arg === "--host") {
30
+ const value = args[index + 1];
31
+ if (!value) {
32
+ return { transport, hostname, port, error: "Missing value for --host" };
33
+ }
34
+ hostname = value;
35
+ index += 1;
36
+ continue;
37
+ }
38
+ if (arg === "--port") {
39
+ const value = args[index + 1];
40
+ if (!value) {
41
+ return { transport, hostname, port, error: "Missing value for --port" };
42
+ }
43
+ const parsedPort = Number.parseInt(value, 10);
44
+ if (!Number.isFinite(parsedPort) || parsedPort < 0) {
45
+ return { transport, hostname, port, error: `Invalid ACP port: ${value}` };
46
+ }
47
+ port = parsedPort;
48
+ index += 1;
49
+ continue;
50
+ }
51
+ return { transport, hostname, port, error: `Unknown option: ${arg}` };
52
+ }
53
+ return { workspaceRoot, transport, hostname, port };
54
+ }
55
+ export function parseWorkspaceOnlyOptions(args) {
56
+ let workspaceRoot;
57
+ for (let index = 0; index < args.length; index += 1) {
58
+ const arg = args[index];
59
+ if (arg === "--workspace") {
60
+ const value = args[index + 1];
61
+ if (!value) {
62
+ return { error: "Missing value for --workspace" };
63
+ }
64
+ workspaceRoot = value;
65
+ index += 1;
66
+ continue;
67
+ }
68
+ return { error: `Unknown option: ${arg}` };
69
+ }
70
+ return { workspaceRoot };
71
+ }
72
+ export function parseHttpServeOptions(args, serviceLabel = "HTTP") {
73
+ let workspaceRoot;
74
+ let hostname;
75
+ let port;
76
+ for (let index = 0; index < args.length; index += 1) {
77
+ const arg = args[index];
78
+ if (arg === "--workspace") {
79
+ const value = args[index + 1];
80
+ if (!value) {
81
+ return { hostname, port, error: "Missing value for --workspace" };
82
+ }
83
+ workspaceRoot = value;
84
+ index += 1;
85
+ continue;
86
+ }
87
+ if (arg === "--host") {
88
+ const value = args[index + 1];
89
+ if (!value) {
90
+ return { workspaceRoot, port, error: "Missing value for --host" };
91
+ }
92
+ hostname = value;
93
+ index += 1;
94
+ continue;
95
+ }
96
+ if (arg === "--port") {
97
+ const value = args[index + 1];
98
+ if (!value) {
99
+ return { workspaceRoot, hostname, error: "Missing value for --port" };
100
+ }
101
+ const parsedPort = Number.parseInt(value, 10);
102
+ if (!Number.isFinite(parsedPort) || parsedPort < 0) {
103
+ return { workspaceRoot, hostname, error: `Invalid ${serviceLabel} port: ${value}` };
104
+ }
105
+ port = parsedPort;
106
+ index += 1;
107
+ continue;
108
+ }
109
+ return { workspaceRoot, hostname, port, error: `Unknown option: ${arg}` };
110
+ }
111
+ return { workspaceRoot, hostname, port };
112
+ }
113
+ export function parseRuntimeMcpServeOptions(args, defaultTransport = "stdio") {
114
+ let workspaceRoot;
115
+ let transport = defaultTransport;
116
+ let hostname;
117
+ let port;
118
+ for (let index = 0; index < args.length; index += 1) {
119
+ const arg = args[index];
120
+ if (arg === "--workspace") {
121
+ const value = args[index + 1];
122
+ if (!value) {
123
+ return { transport, hostname, port, error: "Missing value for --workspace" };
124
+ }
125
+ workspaceRoot = value;
126
+ index += 1;
127
+ continue;
128
+ }
129
+ if (arg === "--transport") {
130
+ const value = args[index + 1];
131
+ if (!value) {
132
+ return { transport, hostname, port, error: "Missing value for --transport" };
133
+ }
134
+ if (value !== "stdio" && value !== "streamable-http") {
135
+ return { transport, hostname, port, error: `Unsupported runtime MCP transport: ${value}` };
136
+ }
137
+ transport = value;
138
+ index += 1;
139
+ continue;
140
+ }
141
+ if (arg === "--host") {
142
+ const value = args[index + 1];
143
+ if (!value) {
144
+ return { transport, hostname, port, error: "Missing value for --host" };
145
+ }
146
+ hostname = value;
147
+ index += 1;
148
+ continue;
149
+ }
150
+ if (arg === "--port") {
151
+ const value = args[index + 1];
152
+ if (!value) {
153
+ return { transport, hostname, port, error: "Missing value for --port" };
154
+ }
155
+ const parsedPort = Number.parseInt(value, 10);
156
+ if (!Number.isFinite(parsedPort) || parsedPort < 0) {
157
+ return { transport, hostname, port, error: `Invalid runtime MCP port: ${value}` };
158
+ }
159
+ port = parsedPort;
160
+ index += 1;
161
+ continue;
162
+ }
163
+ return { transport, hostname, port, error: `Unknown option: ${arg}` };
164
+ }
165
+ return { workspaceRoot, transport, hostname, port };
166
+ }
@@ -0,0 +1,5 @@
1
+ export declare function renderUsage(): string;
2
+ export declare function isTopLevelCliCommand(value?: string): boolean;
3
+ export { parseChatOptions, parseInitOptions } from "./options-init-chat.js";
4
+ export { parseAcpServeOptions, parseHttpServeOptions, parseRuntimeMcpServeOptions, parseWorkspaceOnlyOptions, } from "./options-serve.js";
5
+ export { parseRuntimeExportOptions, parseRuntimeInspectOptions, parseScheduledRunOptions, } from "./options-runtime.js";
@@ -0,0 +1,47 @@
1
+ export function renderUsage() {
2
+ return `Usage:
3
+ agent-harness init <project-name> [--template deep-research|single-agent] [--provider <provider>] [--model <model>] [--with-web-search|--no-web-search]
4
+ agent-harness chat [-w <path>] [--transport stdio|http] [--host <hostname>] [--port <port>] [--agent <agentId>] [--session <sessionId>] [--message <text>]
5
+ agent-harness [-w <path>] [prompt]
6
+ botbotgo [-w <path>] [prompt]
7
+ agent-harness acp serve [--workspace <path>] [--transport stdio|http] [--host <hostname>] [--port <port>]
8
+ agent-harness acp start [--workspace <path>] [--host <hostname>] [--port <port>]
9
+ agent-harness acp stop [--workspace <path>]
10
+ agent-harness a2a serve [--workspace <path>] [--host <hostname>] [--port <port>]
11
+ agent-harness a2a start [--workspace <path>] [--host <hostname>] [--port <port>]
12
+ agent-harness a2a stop [--workspace <path>]
13
+ agent-harness ag-ui serve [--workspace <path>] [--host <hostname>] [--port <port>]
14
+ agent-harness runtime overview [--workspace <path>] [--limit <n>] [--json]
15
+ agent-harness runtime health [--workspace <path>] [--json]
16
+ agent-harness runtime approvals list [--workspace <path>] [--status <pending|approved|edited|rejected|expired>] [--json]
17
+ agent-harness runtime approvals watch [--workspace <path>] [--status <pending|approved|edited|rejected|expired>] [--poll-ms <ms>] [--once] [--json]
18
+ agent-harness runtime requests list [--workspace <path>] [--agent <agentId>] [--session <sessionId>] [--state <state>] [--json]
19
+ agent-harness runtime requests tail [--workspace <path>] [--agent <agentId>] [--session <sessionId>] [--state <state>] [--poll-ms <ms>] [--once] [--json]
20
+ agent-harness runtime scheduled-run --workspace <path> --schedule <scheduleId>
21
+ agent-harness runtime export request --workspace <path> --session <sessionId> --request <requestId> [--artifacts] [--artifact-contents] [--health] [--json]
22
+ agent-harness runtime export session --workspace <path> --session <sessionId> [--artifacts] [--artifact-contents] [--health] [--json]
23
+ agent-harness runtime-mcp serve [--workspace <path>] [--transport stdio|streamable-http] [--host <hostname>] [--port <port>]
24
+ agent-harness runtime-mcp start [--workspace <path>] [--host <hostname>] [--port <port>]
25
+ agent-harness runtime-mcp stop [--workspace <path>]
26
+ agent-harness mcp serve [--workspace <path>] [--transport stdio|streamable-http] [--host <hostname>] [--port <port>]
27
+ agent-harness mcp start [--workspace <path>] [--host <hostname>] [--port <port>]
28
+ agent-harness mcp stop [--workspace <path>]
29
+
30
+ Run botbotgo or agent-harness from any folder.
31
+ If ./config/ is absent, the runtime falls back to the bundled system defaults and bundled resources.
32
+ Chat defaults to the current directory as the workspace. Use -w to point at another workspace.
33
+ `;
34
+ }
35
+ export function isTopLevelCliCommand(value) {
36
+ return value === "init"
37
+ || value === "chat"
38
+ || value === "acp"
39
+ || value === "a2a"
40
+ || value === "ag-ui"
41
+ || value === "mcp"
42
+ || value === "runtime"
43
+ || value === "runtime-mcp";
44
+ }
45
+ export { parseChatOptions, parseInitOptions } from "./options-init-chat.js";
46
+ export { parseAcpServeOptions, parseHttpServeOptions, parseRuntimeMcpServeOptions, parseWorkspaceOnlyOptions, } from "./options-serve.js";
47
+ export { parseRuntimeExportOptions, parseRuntimeInspectOptions, parseScheduledRunOptions, } from "./options-runtime.js";
@@ -0,0 +1,14 @@
1
+ import type { ChildProcessWithoutNullStreams } from "node:child_process";
2
+ import type { Writable as WritableStream } from "node:stream";
3
+ type ProcessExitHookHost = Pick<NodeJS.Process, "on" | "off">;
4
+ type ListenerCapHost = WritableStream & {
5
+ getMaxListeners?: () => number;
6
+ setMaxListeners?: (n: number) => void;
7
+ };
8
+ export declare function isChatServerNoiseLine(line: string): boolean;
9
+ export declare function installCliWriteListenerGuard(streams: Array<ListenerCapHost | undefined>, minimum?: number): () => void;
10
+ export declare function installCliEmitterListenerGuard(minimum?: number): () => void;
11
+ export declare function installCliStderrNoiseFilter(enabled: boolean): () => void;
12
+ export declare function installCliWarningFilter(): () => void;
13
+ export declare function installChatSubprocessExitGuard(child: ChildProcessWithoutNullStreams, host?: ProcessExitHookHost): () => void;
14
+ export {};