@bike4mind/cli 0.2.80 → 0.2.81-conard-cc-tavern-cont.22573

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.
@@ -129,6 +129,7 @@ let ChatModels = /* @__PURE__ */ function(ChatModels) {
129
129
  ChatModels["CLAUDE_4_5_OPUS_BEDROCK"] = "global.anthropic.claude-opus-4-5-20251101-v1:0";
130
130
  ChatModels["CLAUDE_4_6_SONNET_BEDROCK"] = "global.anthropic.claude-sonnet-4-6";
131
131
  ChatModels["CLAUDE_4_6_OPUS_BEDROCK"] = "global.anthropic.claude-opus-4-6-v1";
132
+ ChatModels["CLAUDE_4_7_OPUS_BEDROCK"] = "global.anthropic.claude-opus-4-7";
132
133
  ChatModels["CLAUDE_3_OPUS"] = "claude-3-opus-20240229";
133
134
  ChatModels["CLAUDE_3_5_HAIKU_ANTHROPIC"] = "claude-3-5-haiku-20241022";
134
135
  ChatModels["CLAUDE_3_5_SONNET_ANTHROPIC"] = "claude-3-5-sonnet-20241022";
@@ -141,6 +142,7 @@ let ChatModels = /* @__PURE__ */ function(ChatModels) {
141
142
  ChatModels["CLAUDE_4_5_OPUS"] = "claude-opus-4-5-20251101";
142
143
  ChatModels["CLAUDE_4_6_SONNET"] = "claude-sonnet-4-6";
143
144
  ChatModels["CLAUDE_4_6_OPUS"] = "claude-opus-4-6";
145
+ ChatModels["CLAUDE_4_7_OPUS"] = "claude-opus-4-7";
144
146
  ChatModels["JURASSIC2_ULTRA"] = "ai21.j2-ultra-v1";
145
147
  ChatModels["JURASSIC2_MID"] = "ai21.j2-mid-v1";
146
148
  ChatModels["GEMINI_3_1_PRO_PREVIEW"] = "gemini-3.1-pro-preview";
@@ -194,6 +196,7 @@ const FIXED_TEMPERATURE_MODELS = new Set([
194
196
  ChatModels.GPT5_1_CHAT_LATEST,
195
197
  ChatModels.GPT5_2_CHAT_LATEST
196
198
  ]);
199
+ new Set([ChatModels.CLAUDE_4_7_OPUS, ChatModels.CLAUDE_4_7_OPUS_BEDROCK]);
197
200
  /**
198
201
  * Speech to Text Models
199
202
  *
@@ -334,6 +337,7 @@ const b4mLLMTools = z.enum([
334
337
  "iss_tracker",
335
338
  "planet_visibility",
336
339
  "search_knowledge_base",
340
+ "chess_engine",
337
341
  "retrieve_knowledge_content",
338
342
  "delegate_to_agent",
339
343
  "quantum_schedule",
@@ -391,6 +395,7 @@ const ArtifactMetadataSchema = z.object({
391
395
  const ArtifactTypeSchema = z.enum([
392
396
  "mermaid",
393
397
  "recharts",
398
+ "chess",
394
399
  "python",
395
400
  "react",
396
401
  "html",
@@ -467,6 +472,12 @@ const ArtifactTypeSchema = z.enum([
467
472
  description: "Financial pro-forma models and projections",
468
473
  category: "finance",
469
474
  mimeType: "application/json"
475
+ },
476
+ chess: {
477
+ name: "Chess Game",
478
+ description: "Interactive chess board with move validation and AI opponent",
479
+ category: "interactive",
480
+ mimeType: "application/json"
470
481
  }
471
482
  }).map((info) => info.category))];
472
483
  const ArtifactSchema = z.object({
@@ -547,6 +558,23 @@ ArtifactSchema.extend({
547
558
  colors: z.array(z.string()).optional()
548
559
  })
549
560
  });
561
+ ArtifactSchema.extend({
562
+ type: z.literal("chess"),
563
+ metadata: ArtifactMetadataSchema.extend({
564
+ fen: z.string().optional(),
565
+ turn: z.enum(["w", "b"]).optional(),
566
+ lastMove: z.object({
567
+ from: z.string(),
568
+ to: z.string(),
569
+ san: z.string().optional()
570
+ }).optional(),
571
+ isCheck: z.boolean().optional(),
572
+ isCheckmate: z.boolean().optional(),
573
+ isDraw: z.boolean().optional(),
574
+ isGameOver: z.boolean().optional(),
575
+ moveNumber: z.number().optional()
576
+ })
577
+ });
550
578
  ArtifactSchema.extend({
551
579
  type: z.literal("lattice"),
552
580
  metadata: ArtifactMetadataSchema.extend({
@@ -673,6 +701,11 @@ let ApiKeyScope = /* @__PURE__ */ function(ApiKeyScope) {
673
701
  ApiKeyScope["AI_CHAT"] = "ai:chat";
674
702
  ApiKeyScope["READ_PROJECTS"] = "projects:read";
675
703
  ApiKeyScope["WRITE_PROJECTS"] = "projects:write";
704
+ /** Authorizes only the cc-bridge WS actions (cc_agent_register /
705
+ * cc_agent_event / cc_agent_disconnect). Keys with this scope CANNOT
706
+ * call chat/completions — a leaked bridge key has the narrow blast
707
+ * radius of a sprite-spawning credential, not a billable AI key. */
708
+ ApiKeyScope["CC_BRIDGE"] = "cc-bridge:connect";
676
709
  ApiKeyScope["ADMIN"] = "admin:*";
677
710
  return ApiKeyScope;
678
711
  }({});
@@ -1800,6 +1833,10 @@ const TavernHeartbeatLogAction = z.object({
1800
1833
  "tool_use",
1801
1834
  "email",
1802
1835
  "move_decoration",
1836
+ "place_tile",
1837
+ "remove_tile",
1838
+ "clear_area",
1839
+ "build_room",
1803
1840
  "gate_paused",
1804
1841
  "gate_timed",
1805
1842
  "gate_proceed",
@@ -1881,6 +1918,100 @@ const TavernStockUpdateAction = z.object({
1881
1918
  totalValue: z.number()
1882
1919
  }))
1883
1920
  });
1921
+ /**
1922
+ * ========================================
1923
+ * Claude Code Bridge Actions
1924
+ *
1925
+ * Bridge (`@bike4mind/cc-bridge`) runs on the user's machine, hosts Claude
1926
+ * Code sessions, and forwards events up so each session appears as a sprite
1927
+ * in the Tavern. See CLAUDE_CODE_TAVERN_PLAN.md.
1928
+ * ========================================
1929
+ */
1930
+ /** Lifecycle status of a Claude Code session, as seen by the Tavern. */
1931
+ const CcAgentStatus = z.enum([
1932
+ "running",
1933
+ "idle",
1934
+ "awaiting_input",
1935
+ "awaiting_permission",
1936
+ "disconnected"
1937
+ ]);
1938
+ /**
1939
+ * Bridge → Server: announce a new Claude Code session.
1940
+ *
1941
+ * The server persists an ActiveCodeAgent record keyed by instanceId, picks a
1942
+ * sprite, and broadcasts an `add_entity` scene command so every connected tab
1943
+ * of the user's account sees the new agent appear in the Tavern.
1944
+ */
1945
+ /** Access-token field shared by all cc-bridge-originated actions so the cap
1946
+ * stays in sync — a token accepted by one endpoint should never be rejected
1947
+ * by another purely because of a schema mismatch. */
1948
+ const CcBridgeAccessTokenSchema = z.string().max(512).optional();
1949
+ const CcAgentRegisterAction = z.object({
1950
+ action: z.literal("cc_agent_register"),
1951
+ accessToken: CcBridgeAccessTokenSchema,
1952
+ instanceId: z.string().min(1).max(128),
1953
+ deviceId: z.string().min(1).max(128),
1954
+ workspaceName: z.string().min(1).max(200),
1955
+ workspacePath: z.string().max(1024),
1956
+ claudeVersion: z.string().max(32).optional(),
1957
+ startedAt: z.string().max(40)
1958
+ });
1959
+ /**
1960
+ * Bridge → Server: stream an event for an already-registered session.
1961
+ *
1962
+ * The bridge populates these events from two sources that can coexist:
1963
+ * 1. Claude Code hooks (SessionStart/Stop/Notification/SessionEnd) → `status`.
1964
+ * 2. Tailing the session's transcript.jsonl in `~/.claude/projects/`
1965
+ * (observer+ mode) → `message`, `tool_use`, `tool_result`.
1966
+ *
1967
+ * A future SDK-embed path (`b4m-claude`) will emit the same shapes but from
1968
+ * an in-process session rather than a tailed file; `permission_request` and
1969
+ * `artifact` variants will land with that mode.
1970
+ */
1971
+ const CcAgentEventPayload = z.discriminatedUnion("type", [
1972
+ z.object({
1973
+ type: z.literal("status"),
1974
+ status: CcAgentStatus,
1975
+ text: z.string().max(4e3).optional()
1976
+ }),
1977
+ z.object({
1978
+ type: z.literal("message"),
1979
+ role: z.enum(["user", "assistant"]),
1980
+ text: z.string().max(4e3)
1981
+ }),
1982
+ z.object({
1983
+ type: z.literal("tool_use"),
1984
+ tool: z.string().min(1).max(128),
1985
+ toolUseId: z.string().min(1).max(128),
1986
+ text: z.string().max(4e3).optional()
1987
+ }),
1988
+ z.object({
1989
+ type: z.literal("tool_result"),
1990
+ tool: z.string().min(1).max(128).optional(),
1991
+ toolUseId: z.string().min(1).max(128),
1992
+ text: z.string().max(4e3).optional(),
1993
+ isError: z.boolean().optional()
1994
+ })
1995
+ ]);
1996
+ const CcAgentEventAction = z.object({
1997
+ action: z.literal("cc_agent_event"),
1998
+ accessToken: CcBridgeAccessTokenSchema,
1999
+ instanceId: z.string().min(1).max(128),
2000
+ timestamp: z.string().datetime().max(40),
2001
+ event: CcAgentEventPayload
2002
+ });
2003
+ /**
2004
+ * Bridge → Server: the CC session ended cleanly.
2005
+ *
2006
+ * The server also sweeps `ActiveCodeAgent` records on `$disconnect`, so this
2007
+ * message is an optimization (immediate despawn) rather than a requirement.
2008
+ */
2009
+ const CcAgentDisconnectAction = z.object({
2010
+ action: z.literal("cc_agent_disconnect"),
2011
+ accessToken: CcBridgeAccessTokenSchema,
2012
+ instanceId: z.string().min(1).max(128),
2013
+ reason: z.string().max(200).optional()
2014
+ });
1884
2015
  const SessionCreatedAction = shareableDocumentSchema.extend({
1885
2016
  action: z.literal("session.created"),
1886
2017
  id: z.string(),
@@ -1930,7 +2061,10 @@ z.discriminatedUnion("action", [
1930
2061
  KeepCommandRequestAction,
1931
2062
  KeepCommandResponseAction,
1932
2063
  TavernSceneCommandRequestAction,
1933
- JupyterCellOutputAction
2064
+ JupyterCellOutputAction,
2065
+ CcAgentRegisterAction,
2066
+ CcAgentEventAction,
2067
+ CcAgentDisconnectAction
1934
2068
  ]);
1935
2069
  z.discriminatedUnion("action", [
1936
2070
  DataSubscriptionUpdateAction,
@@ -8213,7 +8347,8 @@ const CliConfigSchema = z.object({
8213
8347
  exportFormat: z.enum(["markdown", "json"]),
8214
8348
  maxIterations: z.number().nullable().prefault(10),
8215
8349
  enableSkillTool: z.boolean().optional().prefault(true),
8216
- enableDynamicAgentCreation: z.boolean().optional().prefault(false)
8350
+ enableDynamicAgentCreation: z.boolean().optional().prefault(false),
8351
+ enableCoordinatorMode: z.boolean().optional().prefault(false)
8217
8352
  }),
8218
8353
  tools: z.object({
8219
8354
  enabled: z.array(z.string()),
@@ -8245,7 +8380,8 @@ const ProjectConfigSchema = z.object({
8245
8380
  theme: z.enum(["light", "dark"]).optional(),
8246
8381
  exportFormat: z.enum(["markdown", "json"]).optional(),
8247
8382
  enableSkillTool: z.boolean().optional(),
8248
- enableDynamicAgentCreation: z.boolean().optional()
8383
+ enableDynamicAgentCreation: z.boolean().optional(),
8384
+ enableCoordinatorMode: z.boolean().optional()
8249
8385
  }).optional(),
8250
8386
  sandbox: PartialSandboxConfigSchema,
8251
8387
  additionalDirectories: z.array(z.string()).optional()
@@ -8267,7 +8403,8 @@ const ProjectLocalConfigSchema = z.object({
8267
8403
  theme: z.enum(["light", "dark"]).optional(),
8268
8404
  exportFormat: z.enum(["markdown", "json"]).optional(),
8269
8405
  enableSkillTool: z.boolean().optional(),
8270
- enableDynamicAgentCreation: z.boolean().optional()
8406
+ enableDynamicAgentCreation: z.boolean().optional(),
8407
+ enableCoordinatorMode: z.boolean().optional()
8271
8408
  }).optional(),
8272
8409
  mcpServers: McpServersSchema.optional(),
8273
8410
  sandbox: PartialSandboxConfigSchema
@@ -8293,7 +8430,8 @@ const DEFAULT_CONFIG = {
8293
8430
  exportFormat: "markdown",
8294
8431
  maxIterations: 10,
8295
8432
  enableSkillTool: true,
8296
- enableDynamicAgentCreation: false
8433
+ enableDynamicAgentCreation: false,
8434
+ enableCoordinatorMode: false
8297
8435
  },
8298
8436
  tools: {
8299
8437
  enabled: [],
@@ -0,0 +1,80 @@
1
+ ---
2
+ description: Decomposes complex tasks into subtasks with dependencies for parallel agent execution
3
+ model: claude-opus-4-6
4
+ allowed-tools:
5
+ - decompose_task
6
+ - file_read
7
+ - grep_search
8
+ - glob_files
9
+ - bash_execute
10
+ - current_datetime
11
+ denied-tools:
12
+ - create_file
13
+ - edit_file
14
+ - delete_file
15
+ - web_search
16
+ - weather_info
17
+ - agent_delegate
18
+ - create_dynamic_agent
19
+ max-iterations:
20
+ quick: 4
21
+ medium: 8
22
+ very_thorough: 14
23
+ default-thoroughness: medium
24
+ ---
25
+
26
+ You are a task decomposition coordinator. Your job is to analyze a complex user request, explore the codebase enough to understand what's involved, then decompose the work into a pipeline of subtasks that specialized agents will execute.
27
+
28
+ ## Your Process
29
+
30
+ 1. **Understand the request** — Read the task carefully. Identify what the user wants as the end result.
31
+ 2. **Explore if needed** — Use file_read, grep_search, and glob_files to understand the relevant code, patterns, and conventions. Only explore what's necessary to make good decomposition decisions.
32
+ 3. **Decompose** — Call the `decompose_task` tool with a structured set of subtasks.
33
+
34
+ ## Decomposition Principles
35
+
36
+ **Right-size the tasks:**
37
+ - Each task should be a focused unit of work for a single agent
38
+ - Too granular = overhead; too broad = defeats the purpose
39
+ - A typical decomposition has 3–7 tasks
40
+
41
+ **Dependency ordering matters:**
42
+ - Exploration tasks should come first (they gather context for later tasks)
43
+ - Implementation tasks depend on exploration
44
+ - Review/test tasks depend on implementation
45
+ - Independent tasks at the same level will run in parallel
46
+
47
+ **Choose the right agent type:**
48
+ - `explore` — Fast, read-only. Use for: finding files, understanding patterns, searching code
49
+ - `plan` — Read-only, powerful reasoning. Use for: designing complex solutions, breaking down sub-problems
50
+ - `general-purpose` — Full tool access. Use for: writing code, creating files, editing, running commands
51
+ - `review` — Read-only, thorough. Use for: code quality analysis, finding bugs, checking patterns
52
+ - `test` — Can run commands. Use for: executing tests, verifying behavior
53
+
54
+ **Write clear descriptions:**
55
+ - Each task description should be self-contained enough for the assigned agent to work without additional context
56
+ - Include relevant file paths, function names, or patterns discovered during exploration
57
+ - Specify expected output or success criteria
58
+
59
+ ## Example Decomposition
60
+
61
+ For "Add input validation to the signup form":
62
+
63
+ ```
64
+ 1. explore-signup → Explore the signup form components and existing validation patterns
65
+ 2. explore-validation → Find how validation is done elsewhere in the codebase
66
+ 3. implement-validation → Add validation logic to signup form (depends on: explore-signup, explore-validation)
67
+ 4. review-changes → Review the validation implementation for correctness (depends on: implement-validation)
68
+ 5. test-validation → Run existing tests and verify no regressions (depends on: implement-validation)
69
+ ```
70
+
71
+ ## Important
72
+
73
+ - You MUST call `decompose_task` exactly once with your final decomposition
74
+ - Do not attempt to execute the tasks yourself — your job is only to decompose
75
+ - If the task is simple enough for a single agent, decompose it into one task (the pipeline will optimize this case)
76
+ - Include enough context in task descriptions that agents can work without seeing the original request
77
+
78
+ ## Iteration Budget
79
+
80
+ You have **$MAX_ITERATIONS iterations** (thoroughness: $THOROUGHNESS). Spend most iterations on exploration if needed, then call decompose_task.
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { i as version, n as fetchLatestVersion, r as forceCheckForUpdate } from "../updateChecker-YklUziR2.mjs";
2
+ import { i as version, n as fetchLatestVersion, r as forceCheckForUpdate } from "../updateChecker-QkuqVRlz.mjs";
3
3
  import { execSync } from "child_process";
4
4
  import { constants, existsSync, promises } from "fs";
5
5
  import { homedir } from "os";
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import { B as CustomCommandStore, C as getApiUrl, E as generateCliTools, I as buildCoreSystemPrompt, P as setWebSocketToolExecutor, R as isReadOnlyTool, S as loadContextFiles, T as PermissionManager, U as SessionStore, V as CheckpointStore, _ as ServerLlmBackend, a as createBackgroundAgentTools, c as AgentStore, f as ApiClient, g as WebSocketLlmBackend, h as FallbackLlmBackend, i as createWriteTodosTool, l as SubagentOrchestrator, m as WebSocketConnectionManager, n as createFindDefinitionTool, o as BackgroundAgentManager, p as WebSocketToolExecutor, r as createTodoStore, s as createAgentDelegateTool, t as createGetFileStructureTool, u as createSkillTool, v as McpManager, z as ReActAgent } from "../tools-BYBHpm5w.mjs";
3
- import { n as logger, t as ConfigStore } from "../ConfigStore-CG7DYbjy.mjs";
2
+ import { B as ReActAgent, C as loadContextFiles, D as generateCliTools, E as PermissionManager, F as setWebSocketToolExecutor, H as CheckpointStore, L as buildCoreSystemPrompt, V as CustomCommandStore, W as SessionStore, _ as WebSocketLlmBackend, a as createCoordinateTaskTool, c as createAgentDelegateTool, d as createSkillTool, g as FallbackLlmBackend, h as WebSocketConnectionManager, i as createWriteTodosTool, l as AgentStore, m as WebSocketToolExecutor, n as createFindDefinitionTool, o as createBackgroundAgentTools, p as ApiClient, r as createTodoStore, s as BackgroundAgentManager, t as createGetFileStructureTool, u as SubagentOrchestrator, v as ServerLlmBackend, w as getApiUrl, y as McpManager, z as isReadOnlyTool } from "../tools-C7mMCjP8.mjs";
3
+ import { n as logger, t as ConfigStore } from "../ConfigStore-DTyUBb3A.mjs";
4
4
  import { t as DEFAULT_SANDBOX_CONFIG } from "../types-DBEjF9YS.mjs";
5
5
  import { t as createSandboxRuntime } from "../SandboxRuntimeAdapter-C1B4t20N.mjs";
6
6
  import { t as SandboxOrchestrator } from "../SandboxOrchestrator-BEW3rqYi.mjs";
@@ -181,6 +181,10 @@ async function handleHeadlessCommand(options) {
181
181
  getFileStructureTool
182
182
  ];
183
183
  if (skillTool) cliTools.push(skillTool);
184
+ if (config.preferences.enableCoordinatorMode === true) {
185
+ const coordinateTaskTool = createCoordinateTaskTool(orchestrator, agentStore, session.id);
186
+ cliTools.push(coordinateTaskTool);
187
+ }
184
188
  const allTools = [
185
189
  ...b4mTools,
186
190
  ...mcpTools,
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as ConfigStore } from "../ConfigStore-CG7DYbjy.mjs";
2
+ import { t as ConfigStore } from "../ConfigStore-DTyUBb3A.mjs";
3
3
  //#region src/commands/mcpCommand.ts
4
4
  /**
5
5
  * External MCP commands (b4m mcp list, b4m mcp add, etc.)
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { i as version, r as forceCheckForUpdate } from "../updateChecker-YklUziR2.mjs";
2
+ import { i as version, r as forceCheckForUpdate } from "../updateChecker-QkuqVRlz.mjs";
3
3
  import { execSync } from "child_process";
4
4
  //#region src/commands/updateCommand.ts
5
5
  /**
package/dist/index.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  import { n as useCliStore, t as selectActiveBackgroundAgents } from "./store-Dw1nZX2Y.mjs";
3
- import { A as DEFAULT_RETRY_CONFIG, B as CustomCommandStore, C as getApiUrl, D as ALWAYS_DENIED_FOR_AGENTS, E as generateCliTools, F as OllamaBackend, G as hasFileReferences, H as CommandHistoryStore, I as buildCoreSystemPrompt, J as mergeCommands, K as processFileReferences, L as buildSkillsPromptSection, M as clearFeatureModuleTools, N as registerFeatureModuleTools, O as DEFAULT_AGENT_MODEL, P as setWebSocketToolExecutor, R as isReadOnlyTool, S as loadContextFiles, T as PermissionManager, U as SessionStore, V as CheckpointStore, W as OAuthClient, X as searchFiles, Y as formatFileSize, Z as warmFileCache, _ as ServerLlmBackend, a as createBackgroundAgentTools, b as formatStep, c as AgentStore, d as parseAgentConfig, f as ApiClient, g as WebSocketLlmBackend, h as FallbackLlmBackend, i as createWriteTodosTool, j as DEFAULT_THOROUGHNESS, k as DEFAULT_MAX_ITERATIONS, l as SubagentOrchestrator, m as WebSocketConnectionManager, n as createFindDefinitionTool, o as BackgroundAgentManager, p as WebSocketToolExecutor, q as searchCommands, r as createTodoStore, s as createAgentDelegateTool, t as createGetFileStructureTool, u as createSkillTool, v as McpManager, w as getEnvironmentName, x as extractCompactInstructions, y as substituteArguments, z as ReActAgent } from "./tools-BYBHpm5w.mjs";
4
- import { Dt as validateJupyterKernelName, Ot as validateNotebookPath$1, g as ChatModels, m as CREDIT_DEDUCT_TRANSACTION_TYPES, n as logger, t as ConfigStore } from "./ConfigStore-CG7DYbjy.mjs";
5
- import { i as version, t as checkForUpdate } from "./updateChecker-YklUziR2.mjs";
3
+ import { A as DEFAULT_MAX_ITERATIONS, B as ReActAgent, C as loadContextFiles, D as generateCliTools, E as PermissionManager, F as setWebSocketToolExecutor, G as OAuthClient, H as CheckpointStore, I as OllamaBackend, J as searchCommands, K as hasFileReferences, L as buildCoreSystemPrompt, M as DEFAULT_THOROUGHNESS, N as clearFeatureModuleTools, O as ALWAYS_DENIED_FOR_AGENTS, P as registerFeatureModuleTools, Q as warmFileCache, R as buildSkillsPromptSection, S as extractCompactInstructions, T as getEnvironmentName, U as CommandHistoryStore, V as CustomCommandStore, W as SessionStore, X as formatFileSize, Y as mergeCommands, Z as searchFiles, _ as WebSocketLlmBackend, a as createCoordinateTaskTool, b as substituteArguments, c as createAgentDelegateTool, d as createSkillTool, f as parseAgentConfig, g as FallbackLlmBackend, h as WebSocketConnectionManager, i as createWriteTodosTool, j as DEFAULT_RETRY_CONFIG, k as DEFAULT_AGENT_MODEL, l as AgentStore, m as WebSocketToolExecutor, n as createFindDefinitionTool, o as createBackgroundAgentTools, p as ApiClient, q as processFileReferences, r as createTodoStore, s as BackgroundAgentManager, t as createGetFileStructureTool, u as SubagentOrchestrator, v as ServerLlmBackend, w as getApiUrl, x as formatStep, y as McpManager, z as isReadOnlyTool } from "./tools-C7mMCjP8.mjs";
4
+ import { Dt as validateJupyterKernelName, Ot as validateNotebookPath$1, g as ChatModels, m as CREDIT_DEDUCT_TRANSACTION_TYPES, n as logger, t as ConfigStore } from "./ConfigStore-DTyUBb3A.mjs";
5
+ import { i as version, t as checkForUpdate } from "./updateChecker-QkuqVRlz.mjs";
6
6
  import React, { useCallback, useEffect, useMemo, useReducer, useRef, useState } from "react";
7
7
  import { Box, Static, Text, render, useApp, useInput } from "ink";
8
8
  import { execSync } from "child_process";
@@ -1452,6 +1452,18 @@ function buildConfigItems(availableModels) {
1452
1452
  enableDynamicAgentCreation: value
1453
1453
  }
1454
1454
  })
1455
+ }, {
1456
+ key: "enableCoordinatorMode",
1457
+ label: "Coordinator Mode",
1458
+ type: "boolean",
1459
+ getValue: (config) => config.preferences.enableCoordinatorMode ?? false,
1460
+ setValue: (config, value) => ({
1461
+ ...config,
1462
+ preferences: {
1463
+ ...config.preferences,
1464
+ enableCoordinatorMode: value
1465
+ }
1466
+ })
1455
1467
  }, {
1456
1468
  key: "featuresTavern",
1457
1469
  label: "Tavern",
@@ -4445,46 +4457,26 @@ function CliApp() {
4445
4457
  console.warn("Failed to load custom commands:", error instanceof Error ? error.message : String(error));
4446
4458
  }
4447
4459
  const authTokens = await state.configStore.getAuthTokens();
4448
- let isAuthenticated = false;
4449
4460
  if (!authTokens) {
4450
- logger.debug("⚠️ Not authenticated.");
4451
- logger.debug("💡 Run /login to authenticate with your B4M account.");
4452
- logger.debug("📖 You can still browse help and documentation without authentication.");
4453
- } else {
4454
- const expiresAt = new Date(authTokens.expiresAt);
4455
- if (expiresAt <= /* @__PURE__ */ new Date()) {
4456
- console.log("\n⚠️ Authentication token expired.");
4457
- console.log("💡 Run /login to re-authenticate with your B4M account.\n");
4458
- await state.configStore.clearAuthTokens();
4459
- } else {
4460
- isAuthenticated = true;
4461
- const daysUntilExpiry = Math.floor((expiresAt.getTime() - Date.now()) / (1e3 * 60 * 60 * 24));
4462
- startupLog.push(`✅ Authenticated (expires in ${daysUntilExpiry} day${daysUntilExpiry !== 1 ? "s" : ""})`);
4463
- }
4461
+ console.log("\n🔐 Welcome to B4M CLI! Authentication is required to get started.\n");
4462
+ setState((prev) => ({
4463
+ ...prev,
4464
+ showLoginFlow: true
4465
+ }));
4466
+ return;
4464
4467
  }
4465
- if (!isAuthenticated) {
4466
- console.log("ℹ️ AI features disabled. Available commands: /login, /help, /config\n");
4467
- const minimalSession = {
4468
- id: v4(),
4469
- name: `Session ${(/* @__PURE__ */ new Date()).toLocaleString()}`,
4470
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
4471
- updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
4472
- model: "unauthenticated",
4473
- messages: [],
4474
- metadata: {
4475
- totalTokens: 0,
4476
- totalCost: 0,
4477
- toolCallCount: 0
4478
- }
4479
- };
4468
+ const expiresAt = new Date(authTokens.expiresAt);
4469
+ if (expiresAt <= /* @__PURE__ */ new Date()) {
4470
+ console.log("\n🔐 Your session has expired. Let's re-authenticate.\n");
4471
+ await state.configStore.clearAuthTokens();
4480
4472
  setState((prev) => ({
4481
4473
  ...prev,
4482
- session: minimalSession,
4483
- config
4474
+ showLoginFlow: true
4484
4475
  }));
4485
- setIsInitialized(true);
4486
4476
  return;
4487
4477
  }
4478
+ const daysUntilExpiry = Math.floor((expiresAt.getTime() - Date.now()) / (1e3 * 60 * 60 * 24));
4479
+ startupLog.push(`✅ Authenticated (expires in ${daysUntilExpiry} day${daysUntilExpiry !== 1 ? "s" : ""})`);
4488
4480
  const apiBaseURL = getApiUrl(config.apiConfig);
4489
4481
  const envName = getEnvironmentName(config.apiConfig);
4490
4482
  if (import.meta.url.includes("/src/") || process.env.NODE_ENV === "development" || envName !== "Bike4Mind") console.log(`🌍 API Environment: ${envName} (${apiBaseURL})`);
@@ -4806,6 +4798,10 @@ function CliApp() {
4806
4798
  ];
4807
4799
  if (skillTool) cliTools.push(skillTool);
4808
4800
  if (dynamicAgentTool) cliTools.push(dynamicAgentTool);
4801
+ if (config.preferences.enableCoordinatorMode === true) {
4802
+ const coordinateTaskTool = createCoordinateTaskTool(orchestrator, agentStore, newSession.id);
4803
+ cliTools.push(coordinateTaskTool);
4804
+ }
4809
4805
  const featureTools = featureRegistry.getAllTools();
4810
4806
  const allTools = [
4811
4807
  ...b4mTools,
@@ -4979,13 +4975,7 @@ function CliApp() {
4979
4975
  */
4980
4976
  const handleCustomCommandMessage = async (fullTemplate, displayMessage) => {
4981
4977
  if (!state.agent || !state.session) {
4982
- console.error("❌ Agent or session not initialized");
4983
- return;
4984
- }
4985
- const authTokens = await state.configStore.getAuthTokens();
4986
- if (!authTokens || new Date(authTokens.expiresAt) <= /* @__PURE__ */ new Date()) {
4987
- console.log("\n❌ Authentication required to use AI features.");
4988
- console.log("💡 Run /login to authenticate with your B4M account.\n");
4978
+ console.error("❌ CLI failed to initialize. Try restarting b4m.\n");
4989
4979
  return;
4990
4980
  }
4991
4981
  useCliStore.getState().setIsThinking(true);
@@ -5195,17 +5185,11 @@ function CliApp() {
5195
5185
  };
5196
5186
  const handleMessage = async (message) => {
5197
5187
  if (!state.agent || !state.session) {
5198
- console.error("❌ Agent or session not initialized");
5188
+ console.error("❌ CLI failed to initialize. Try restarting b4m.\n");
5199
5189
  return;
5200
5190
  }
5201
5191
  await state.commandHistoryStore.add(message);
5202
5192
  setCommandHistory(await state.commandHistoryStore.list());
5203
- const authTokens = await state.configStore.getAuthTokens();
5204
- if (!authTokens || new Date(authTokens.expiresAt) <= /* @__PURE__ */ new Date()) {
5205
- console.log("\n❌ Authentication required to use AI features.");
5206
- console.log("💡 Run /login to authenticate with your B4M account.\n");
5207
- return;
5208
- }
5209
5193
  const config = state.config;
5210
5194
  let activeSession = state.session;
5211
5195
  if (config?.preferences.autoCompact !== false && activeSession.messages.length >= 6) {
@@ -6839,7 +6823,9 @@ Multi-line Input:
6839
6823
  ...prev,
6840
6824
  showLoginFlow: false
6841
6825
  }));
6842
- console.error(`\n❌ Login failed: ${error.message}\n`);
6826
+ console.error(`\n❌ Login failed: ${error.message}`);
6827
+ console.log("Run b4m again when you're ready to authenticate.\n");
6828
+ exit();
6843
6829
  }
6844
6830
  });
6845
6831
  }