@bike4mind/cli 1.1.0 → 2.0.0

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 (28) hide show
  1. package/README.md +4 -1
  2. package/bin/bike4mind-cli.mjs +0 -5
  3. package/dist/AgentHistoryStore-DIMzvf-y.mjs +18200 -0
  4. package/dist/{ApiClient-BOWpVvTq.mjs → ApiClient-BTI0-m0g.mjs} +44 -5
  5. package/dist/{BubblewrapRuntime-CkL9-gnG.mjs → BubblewrapRuntime-5bLPTwEC.mjs} +2 -2
  6. package/dist/{ConfigStore-DdHHCH2t.mjs → ConfigStore-DIs-K9oD.mjs} +3541 -1625
  7. package/dist/{ProxyManager-C1-lgzEU.mjs → ProxyManager-B0-RuR2w.mjs} +21 -4
  8. package/dist/{SandboxOrchestrator-CIegJrCj.mjs → SandboxOrchestrator-BcUv9fQ3.mjs} +46 -12
  9. package/dist/{SandboxRuntimeAdapter-ChGlxSGQ.mjs → SandboxRuntimeAdapter-BgLUVTJL.mjs} +2 -2
  10. package/dist/{SandboxRuntimeAdapter-CKelGICD.mjs → SandboxRuntimeAdapter-BmHELLuM.mjs} +1 -1
  11. package/dist/{SeatbeltRuntime-Qqt19cAN.mjs → SeatbeltRuntime-C_Y8q8Mr.mjs} +9 -1
  12. package/dist/buildAgent-DOvEp92a.mjs +2106 -0
  13. package/dist/commands/acpCommand.mjs +9 -6
  14. package/dist/commands/apiCommand.mjs +1 -1
  15. package/dist/commands/doctorCommand.mjs +1 -1
  16. package/dist/commands/envCommand.mjs +1 -1
  17. package/dist/commands/headlessCommand.mjs +27 -16
  18. package/dist/commands/mcpCommand.mjs +3 -3
  19. package/dist/commands/pluginCommand.mjs +1 -1
  20. package/dist/commands/updateCommand.mjs +1 -1
  21. package/dist/index.mjs +954 -122
  22. package/dist/{package-Bqg2LSnH.mjs → package-Dl_F2Fah.mjs} +1 -1
  23. package/dist/{serve-DO9Edl5S.mjs → serve-Y2zMbfGs.mjs} +237 -73
  24. package/package.json +11 -12
  25. package/dist/AgentHistoryStore-kT9eNMRO.mjs +0 -39471
  26. package/dist/ProxyManager-B1jFWL7b.mjs +0 -3
  27. package/dist/SandboxOrchestrator-BbMDgjzr.mjs +0 -3
  28. package/dist/buildAgent-B_kArQ_Y.mjs +0 -833
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
- import { $ as CustomCommandStore, A as createAgentDelegateTool, C as createTodoStore, D as createCoordinateTaskTool, F as PermissionManager, J as setWebSocketToolExecutor, L as wrapTools, O as createResumeAgentTool, Q as RemoteSkillSource, S as createFindDefinitionTool, T as createSkillTool, b as createGetFileStructureTool, et as CheckpointStore, j as FallbackLlmBackend, k as createBackgroundAgentTools, tt as SessionStore, w as createWriteTodosTool } from "../AgentHistoryStore-kT9eNMRO.mjs";
3
- import { n as logger, p as requireApiUrl, s as isReadOnlyTool, t as ConfigStore } from "../ConfigStore-DdHHCH2t.mjs";
4
- import { t as ApiClient } from "../ApiClient-BOWpVvTq.mjs";
5
- import { a as createToolSearchTool, i as buildLlmBackend, n as buildSupportingStores, o as deferredToolRegistry, r as buildSandbox, s as NotifyingLlmBackend, t as buildAgent } from "../buildAgent-B_kArQ_Y.mjs";
2
+ import { $ as CustomCommandStore, A as createAgentDelegateTool, C as createTodoStore, D as createCoordinateTaskTool, F as PermissionManager, J as setWebSocketToolExecutor, L as wrapTools, O as createResumeAgentTool, Q as RemoteSkillSource, S as createFindDefinitionTool, T as createSkillTool, b as createGetFileStructureTool, et as CheckpointStore, j as FallbackLlmBackend, k as createBackgroundAgentTools, s as buildSandbox, tt as SessionStore, w as createWriteTodosTool } from "../AgentHistoryStore-DIMzvf-y.mjs";
3
+ import { _ as requireApiUrl, d as isReadOnlyTool, n as logger, t as ConfigStore } from "../ConfigStore-DIs-K9oD.mjs";
4
+ import { a as deferredToolRegistry, i as createToolSearchTool, n as buildSupportingStores, o as NotifyingLlmBackend, r as buildLlmBackend, t as buildAgent } from "../buildAgent-DOvEp92a.mjs";
5
+ import { t as ApiClient } from "../ApiClient-BTI0-m0g.mjs";
6
6
  import { randomUUID } from "crypto";
7
7
  import { existsSync, realpathSync, statSync } from "fs";
8
8
  import { isAbsolute } from "path";
@@ -575,6 +575,7 @@ var AcpServer = class {
575
575
  }
576
576
  async buildStack() {
577
577
  const config = await this.configStore.load();
578
+ this.configStore.warnPendingMcpApprovals();
578
579
  await this.loadCustomCommands();
579
580
  const authTokens = await this.configStore.getAuthTokens();
580
581
  if (!authTokens) throw RequestError.authRequired(void 0, "Not authenticated. Run `b4m /login` first.");
@@ -700,8 +701,10 @@ var AcpServer = class {
700
701
  customCommandStore: this.customCommandStore,
701
702
  subagentOrchestrator: orchestrator,
702
703
  sessionId,
703
- permissionManager,
704
- promptFn: this.promptFn,
704
+ permission: {
705
+ permissionManager,
706
+ promptFn: this.promptFn
707
+ },
705
708
  allowedDirectories
706
709
  })] : []
707
710
  ], cliWrapDeps);
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { f as parseApiUrl, m as resolveApiEndpoint, t as ConfigStore } from "../ConfigStore-DdHHCH2t.mjs";
2
+ import { g as parseApiUrl, t as ConfigStore, v as resolveApiEndpoint } from "../ConfigStore-DIs-K9oD.mjs";
3
3
  //#region src/commands/apiCommand.ts
4
4
  /**
5
5
  * External API config command (--api-url / --reset-api)
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as version } from "../package-Bqg2LSnH.mjs";
2
+ import { t as version } from "../package-Dl_F2Fah.mjs";
3
3
  import { a as fetchLatestVersion, c as isNpmPrefixWritable, i as compareSemver } from "../updateChecker-CQW8bxo6.mjs";
4
4
  import { t as checkRipgrep } from "../ripgrepCheck-BmkyTK2i.mjs";
5
5
  import { execSync } from "child_process";
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as ConfigStore } from "../ConfigStore-DdHHCH2t.mjs";
2
+ import { t as ConfigStore } from "../ConfigStore-DIs-K9oD.mjs";
3
3
  //#region src/commands/envCommand.ts
4
4
  /**
5
5
  * Environment switching for the `--dev` / `--prod` launch flags.
@@ -1,12 +1,8 @@
1
1
  #!/usr/bin/env node
2
- import { $ as CustomCommandStore, A as createAgentDelegateTool, C as createTodoStore, D as createCoordinateTaskTool, F as PermissionManager, G as classifyCommandRisk, I as generateCliTools, J as setWebSocketToolExecutor, L as wrapTools, N as ReActAgent, O as createResumeAgentTool, Q as RemoteSkillSource, S as createFindDefinitionTool, T as createSkillTool, X as buildSystemPrompt, a as loadProjectContext, b as createGetFileStructureTool, et as CheckpointStore, i as buildProjectAgentStore, j as FallbackLlmBackend, k as createBackgroundAgentTools, n as BackgroundAgentManager, o as McpManager, r as SubagentOrchestrator, s as createSseBackend, t as AgentHistoryStore, tt as SessionStore, w as createWriteTodosTool, x as createWorkItemTools, z as SHELL_LIKE_TOOL_COMMAND_FIELDS } from "../AgentHistoryStore-kT9eNMRO.mjs";
3
- import { n as logger, p as requireApiUrl, s as isReadOnlyTool, t as ConfigStore } from "../ConfigStore-DdHHCH2t.mjs";
4
- import { t as ApiClient } from "../ApiClient-BOWpVvTq.mjs";
5
- import { t as DEFAULT_SANDBOX_CONFIG } from "../types-F61_hxmG.mjs";
2
+ import { $ as CustomCommandStore, A as createAgentDelegateTool, C as createTodoStore, D as createCoordinateTaskTool, F as PermissionManager, G as classifyCommandRisk, I as generateCliTools, J as setWebSocketToolExecutor, L as wrapTools, N as ReActAgent, O as createResumeAgentTool, Q as RemoteSkillSource, S as createFindDefinitionTool, T as createSkillTool, X as buildSystemPrompt, a as loadProjectContext, b as createGetFileStructureTool, c as createSseBackend, et as CheckpointStore, i as buildProjectAgentStore, j as FallbackLlmBackend, k as createBackgroundAgentTools, n as BackgroundAgentManager, o as McpManager, r as SubagentOrchestrator, s as buildSandbox, t as AgentHistoryStore, tt as SessionStore, w as createWriteTodosTool, x as createWorkItemTools, z as SHELL_LIKE_TOOL_COMMAND_FIELDS } from "../AgentHistoryStore-DIMzvf-y.mjs";
3
+ import { _ as requireApiUrl, d as isReadOnlyTool, n as logger, t as ConfigStore } from "../ConfigStore-DIs-K9oD.mjs";
4
+ import { t as ApiClient } from "../ApiClient-BTI0-m0g.mjs";
6
5
  import { r as reconstructTurnBlocks, t as WorkItemsClient } from "../WorkItemsClient-Cow6nXx7.mjs";
7
- import { t as createSandboxRuntime } from "../SandboxRuntimeAdapter-ChGlxSGQ.mjs";
8
- import { t as SandboxOrchestrator } from "../SandboxOrchestrator-CIegJrCj.mjs";
9
- import { t as ProxyManager } from "../ProxyManager-C1-lgzEU.mjs";
10
6
  import { randomBytes } from "crypto";
11
7
  import { v4 } from "uuid";
12
8
  import { readFile } from "fs/promises";
@@ -216,6 +212,16 @@ function resolveHeadlessPermissionDecision(params) {
216
212
  * Enables non-interactive execution for CI/CD pipelines, scripting, and automation.
217
213
  * Runs the agent once with the given prompt and exits with an appropriate exit code.
218
214
  */
215
+ /**
216
+ * Sandbox status/warning sink for headless mode. Headless emits its NDJSON protocol
217
+ * on stdout, so BOTH info and warn must go to stderr - routing either to stdout would
218
+ * corrupt the protocol stream. Exported so this invariant is unit-tested (see
219
+ * headlessSandboxLog.test.ts) rather than left as an inline lambda nothing pins.
220
+ */
221
+ const headlessSandboxLog = {
222
+ info: (line) => void process.stderr.write(`${line}\n`),
223
+ warn: (line) => void process.stderr.write(`${line}\n`)
224
+ };
219
225
  /** Read all data from stdin if it's being piped (non-TTY). Returns empty string if no piped data. */
220
226
  async function readStdin() {
221
227
  if (process.stdin.isTTY) return "";
@@ -244,6 +250,7 @@ async function handleHeadlessCommand(options) {
244
250
  const runId = v4();
245
251
  try {
246
252
  const config = await configStore.load();
253
+ configStore.warnPendingMcpApprovals();
247
254
  const configDirs = await configStore.getAdditionalDirectories();
248
255
  const flagDirs = process.env.B4M_ADDITIONAL_DIRS ? parseStringArray(process.env.B4M_ADDITIONAL_DIRS, "B4M_ADDITIONAL_DIRS") : [];
249
256
  const additionalDirectories = [.../* @__PURE__ */ new Set([
@@ -344,13 +351,15 @@ async function handleHeadlessCommand(options) {
344
351
  process.stderr.write("Warning: Agent requested user input; headless mode cannot respond interactively. Answering with empty response.\n");
345
352
  return Promise.resolve({ answers: [] });
346
353
  };
347
- const sandboxConfig = config.sandbox ?? DEFAULT_SANDBOX_CONFIG;
348
354
  const checkpointProjectDir = configStore.getProjectConfigDir() ?? process.cwd();
349
355
  const checkpointStore = new CheckpointStore(checkpointProjectDir);
350
- const [sandboxRuntime] = await Promise.all([createSandboxRuntime(), checkpointStore.init(session.id).catch(() => {})]);
351
- const proxyManager = new ProxyManager(sandboxConfig.network);
352
- const sandboxOrchestrator = new SandboxOrchestrator(sandboxConfig, sandboxRuntime, proxyManager);
353
- permissionManager.setSandboxState(sandboxConfig.mode, sandboxOrchestrator.isActive());
356
+ const { sandboxOrchestrator } = await buildSandbox({
357
+ config,
358
+ sessionId: session.id,
359
+ permissionManager,
360
+ checkpointStore,
361
+ log: headlessSandboxLog
362
+ });
354
363
  const agentContext = {
355
364
  currentAgent: null,
356
365
  observationQueue: []
@@ -406,8 +415,10 @@ async function handleHeadlessCommand(options) {
406
415
  customCommandStore,
407
416
  subagentOrchestrator: orchestrator,
408
417
  sessionId: session.id,
409
- permissionManager,
410
- promptFn,
418
+ permission: {
419
+ permissionManager,
420
+ promptFn
421
+ },
411
422
  allowedDirectories: additionalDirectories
412
423
  })], cliWrapDeps)[0] : null;
413
424
  const cliTools = [
@@ -432,7 +443,7 @@ async function handleHeadlessCommand(options) {
432
443
  const systemPrompt = buildSystemPrompt(config.preferences.promptVariant ?? "current", {
433
444
  contextContent: contextResult.mergedContent,
434
445
  agentStore,
435
- customCommands: customCommandStore.getAllCommands(),
446
+ customCommands: customCommandStore.getModelReachableCommands(),
436
447
  enableSkillTool,
437
448
  enableDynamicAgentCreation: false,
438
449
  additionalDirectories
@@ -567,4 +578,4 @@ async function handleHeadlessCommand(options) {
567
578
  }
568
579
  }
569
580
  //#endregion
570
- export { handleHeadlessCommand };
581
+ export { handleHeadlessCommand, headlessSandboxLog };
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import { t as ConfigStore } from "../ConfigStore-DdHHCH2t.mjs";
3
- import { t as version } from "../package-Bqg2LSnH.mjs";
2
+ import { t as ConfigStore } from "../ConfigStore-DIs-K9oD.mjs";
3
+ import { t as version } from "../package-Dl_F2Fah.mjs";
4
4
  //#region src/commands/mcpCommand.ts
5
5
  /**
6
6
  * External MCP commands (b4m mcp list, b4m mcp add, etc.)
@@ -70,7 +70,7 @@ async function handleMcpCommand(subcommand, argv) {
70
70
  await handleDisable(config, argv.name, configStore);
71
71
  break;
72
72
  case "serve": {
73
- const { handleMcpServeCommand } = await import("../serve-DO9Edl5S.mjs");
73
+ const { handleMcpServeCommand } = await import("../serve-Y2zMbfGs.mjs");
74
74
  await handleMcpServeCommand({
75
75
  http: Boolean(argv.http),
76
76
  port: typeof argv.port === "number" ? argv.port : void 0,
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { n as getDefaultPluginsDir, r as isFeatureEnabled, t as PluginStore } from "../PluginStore-DwvOJ-G3.mjs";
3
- import { t as ConfigStore } from "../ConfigStore-DdHHCH2t.mjs";
3
+ import { t as ConfigStore } from "../ConfigStore-DIs-K9oD.mjs";
4
4
  import { execFileSync } from "child_process";
5
5
  import { promises } from "fs";
6
6
  import path from "path";
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as version } from "../package-Bqg2LSnH.mjs";
2
+ import { t as version } from "../package-Dl_F2Fah.mjs";
3
3
  import { c as isNpmPrefixWritable, l as setAutoUpdatePreference, n as REEXEC_GUARD_ENV, o as forceCheckForUpdate, r as checkForUpdate, s as getAutoUpdatePreference, t as INSTALL_CMD, u as shouldAttemptAutoUpdate } from "../updateChecker-CQW8bxo6.mjs";
4
4
  import { t as checkRipgrep } from "../ripgrepCheck-BmkyTK2i.mjs";
5
5
  import { execSync, spawnSync } from "child_process";