bravecode-cli 0.1.37 → 0.1.39

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.
package/dist/cli-main.mjs CHANGED
@@ -38185,7 +38185,7 @@ var APP_VERSION, APP_NAME;
38185
38185
  var init_version = __esm({
38186
38186
  "src/version.ts"() {
38187
38187
  "use strict";
38188
- APP_VERSION = "0.1.37";
38188
+ APP_VERSION = "0.1.39";
38189
38189
  APP_NAME = "BraveCode";
38190
38190
  }
38191
38191
  });
@@ -41152,7 +41152,7 @@ IMPORTANT: Only test APIs you have authorization to test. Never attempt to acces
41152
41152
  setAutoApprove(auto) {
41153
41153
  this.autoApprove = auto;
41154
41154
  }
41155
- async run(userMessage, onChunk, signal) {
41155
+ async run(userMessage, onChunk, signal, onToolCall) {
41156
41156
  let message = userMessage;
41157
41157
  if (this.pluginHooks.beforeAgentRun) {
41158
41158
  message = await this.pluginHooks.beforeAgentRun(this.config.id, message);
@@ -41217,6 +41217,7 @@ IMPORTANT: Only test APIs you have authorization to test. Never attempt to acces
41217
41217
  if (signal?.aborted) break;
41218
41218
  const toolName = toolCall.name;
41219
41219
  const toolArgs = toolCall.arguments;
41220
+ onToolCall?.(toolCall, "running");
41220
41221
  const permission = await this.permissions.checkPermission(
41221
41222
  toolName,
41222
41223
  toolArgs,
@@ -41225,6 +41226,7 @@ IMPORTANT: Only test APIs you have authorization to test. Never attempt to acces
41225
41226
  if (permission.action === "deny") {
41226
41227
  agentLog(`
41227
41228
  > Blocked: ${toolName} (permission denied)`);
41229
+ onToolCall?.(toolCall, "error", "Permission denied");
41228
41230
  this.conversationHistory.push({
41229
41231
  role: "tool",
41230
41232
  content: "Permission denied by security policy.",
@@ -41252,6 +41254,7 @@ IMPORTANT: Only test APIs you have authorization to test. Never attempt to acces
41252
41254
  if (this.pluginHooks.afterToolCall) {
41253
41255
  result = await this.pluginHooks.afterToolCall(toolName, args, result);
41254
41256
  }
41257
+ onToolCall?.(toolCall, "done", result);
41255
41258
  this.conversationHistory.push({
41256
41259
  role: "tool",
41257
41260
  content: result,
@@ -41811,7 +41814,7 @@ var init_providers = __esm({
41811
41814
  // src/core/tui/hooks/use-agent-runner.ts
41812
41815
  import React3 from "react";
41813
41816
  function useAgentRunner() {
41814
- const { addMessage, updateMessage } = useSession();
41817
+ const { addMessage, updateMessage, addToolCall, messages } = useSession();
41815
41818
  const { currentAgent, currentModel, setRunning } = useAgent();
41816
41819
  const toast = useToast();
41817
41820
  const agentRef = React3.useRef(null);
@@ -41847,7 +41850,27 @@ function useAgentRunner() {
41847
41850
  fullContent += chunk;
41848
41851
  updateMessage(assistantMsg.id, { content: fullContent });
41849
41852
  },
41850
- abortRef.current.signal
41853
+ abortRef.current.signal,
41854
+ (toolCall, status, result) => {
41855
+ const tcState = {
41856
+ id: toolCall.id,
41857
+ name: toolCall.name,
41858
+ args: toolCall.arguments,
41859
+ status,
41860
+ result
41861
+ };
41862
+ const existingMsg = messages.find((m) => m.id === assistantMsg.id);
41863
+ const existingTc = existingMsg?.toolCalls?.find((tc) => tc.id === toolCall.id);
41864
+ if (existingTc) {
41865
+ updateMessage(assistantMsg.id, {
41866
+ toolCalls: existingMsg.toolCalls.map(
41867
+ (tc) => tc.id === toolCall.id ? tcState : tc
41868
+ )
41869
+ });
41870
+ } else {
41871
+ addToolCall(assistantMsg.id, tcState);
41872
+ }
41873
+ }
41851
41874
  );
41852
41875
  updateMessage(assistantMsg.id, { content: fullContent });
41853
41876
  } catch (err) {
@@ -42086,14 +42109,28 @@ function MessageBubble({ msg }) {
42086
42109
  paddingRight: 2,
42087
42110
  paddingTop: 0,
42088
42111
  paddingBottom: 0,
42089
- flexDirection: "column"
42112
+ flexDirection: "row",
42113
+ gap: 1
42090
42114
  }, children: [
42091
- /* @__PURE__ */ jsx("text", { fg: colors2.textMuted, children: /* @__PURE__ */ jsxs("b", { children: [
42092
- "[Tool result for ",
42115
+ /* @__PURE__ */ jsx("text", { fg: colors2.textMuted, children: /* @__PURE__ */ jsx("b", { children: "\u203A" }) }),
42116
+ /* @__PURE__ */ jsxs("text", { fg: colors2.textMuted, children: [
42093
42117
  s(msg.toolName ?? "tool"),
42094
- "]"
42095
- ] }) }),
42096
- /* @__PURE__ */ jsx("scrollbox", { style: { maxHeight: 10, backgroundColor: colors2.bgAlt }, children: /* @__PURE__ */ jsx("text", { fg: colors2.textSecondary, children: s(msg.content.length > 4e3 ? msg.content.slice(0, 4e3) + "\n... (truncated)" : msg.content) }) })
42118
+ " ",
42119
+ s(msg.content.length > 60 ? msg.content.slice(0, 60) + "\u2026" : msg.content.split("\n")[0])
42120
+ ] })
42121
+ ] });
42122
+ }
42123
+ if (isUser) {
42124
+ return /* @__PURE__ */ jsxs("box", { style: {
42125
+ paddingLeft: 1,
42126
+ paddingRight: 1,
42127
+ paddingTop: 0,
42128
+ paddingBottom: 0,
42129
+ flexDirection: "row",
42130
+ gap: 1
42131
+ }, children: [
42132
+ /* @__PURE__ */ jsx("text", { fg: colors2.primary, children: /* @__PURE__ */ jsx("b", { children: ">" }) }),
42133
+ /* @__PURE__ */ jsx("text", { fg: colors2.text, wrapMode: "word", children: s(msg.content) })
42097
42134
  ] });
42098
42135
  }
42099
42136
  return /* @__PURE__ */ jsxs("box", { style: {
@@ -42101,22 +42138,25 @@ function MessageBubble({ msg }) {
42101
42138
  paddingRight: 1,
42102
42139
  paddingTop: 0,
42103
42140
  paddingBottom: 0,
42104
- flexDirection: "column",
42105
- backgroundColor: isUser ? colors2.userMsg : colors2.assistantMsg,
42106
- border: true,
42107
- borderColor: isUser ? colors2.primaryDim : colors2.border
42141
+ flexDirection: "column"
42108
42142
  }, children: [
42109
- /* @__PURE__ */ jsxs("box", { style: { flexDirection: "row", gap: 1, marginBottom: 0 }, children: [
42110
- /* @__PURE__ */ jsx("text", { fg: isUser ? colors2.primary : colors2.textSecondary, children: /* @__PURE__ */ jsx("b", { children: isUser ? "You" : "Assistant" }) }),
42111
- /* @__PURE__ */ jsx("text", { fg: colors2.textMuted, children: s(msg.timestamp.toLocaleTimeString()) })
42112
- ] }),
42113
- /* @__PURE__ */ jsx("scrollbox", { style: { maxHeight: 40 }, children: /* @__PURE__ */ jsx("text", { fg: colors2.text, wrapMode: "word", children: s(msg.content || (isUser ? "" : " ")) }) }),
42114
- msg.toolCalls && msg.toolCalls.length > 0 ? /* @__PURE__ */ jsx("box", { style: { marginTop: 0, flexDirection: "column" }, children: msg.toolCalls.map((tc) => /* @__PURE__ */ jsx("box", { style: { flexDirection: "row", gap: 1 }, children: /* @__PURE__ */ jsx("text", { fg: tc.status === "error" ? colors2.error : colors2.info, children: /* @__PURE__ */ jsxs("b", { children: [
42115
- "[",
42116
- s(tc.name),
42117
- tc.status === "done" ? " \u2713" : tc.status === "error" ? " \u2717" : "\u2026",
42118
- "]"
42119
- ] }) }) }, s(tc.id))) }) : null
42143
+ /* @__PURE__ */ jsx("text", { fg: colors2.text, wrapMode: "word", children: s(msg.content || " ") }),
42144
+ msg.toolCalls && msg.toolCalls.length > 0 ? /* @__PURE__ */ jsx("box", { style: { marginTop: 0, flexDirection: "column", paddingLeft: 1 }, children: msg.toolCalls.map((tc) => {
42145
+ if (tc.name === "write" || tc.name === "edit") {
42146
+ const filePath = tc.args?.filePath || tc.args?.path || "";
42147
+ const isCreate = tc.name === "write";
42148
+ const icon = isCreate ? "+" : "~";
42149
+ const iconColor = isCreate ? colors2.success : colors2.warning;
42150
+ return /* @__PURE__ */ jsxs("box", { style: { flexDirection: "row", gap: 1 }, children: [
42151
+ /* @__PURE__ */ jsx("text", { fg: iconColor, children: /* @__PURE__ */ jsx("b", { children: icon }) }),
42152
+ /* @__PURE__ */ jsx("text", { fg: colors2.textSecondary, children: s(filePath) })
42153
+ ] }, s(tc.id));
42154
+ }
42155
+ return /* @__PURE__ */ jsx("box", { style: { flexDirection: "row", gap: 1 }, children: /* @__PURE__ */ jsxs("text", { fg: tc.status === "error" ? colors2.error : colors2.textMuted, children: [
42156
+ s(tc.name),
42157
+ tc.status === "done" ? " \u2713" : tc.status === "error" ? " \u2717" : "\u2026"
42158
+ ] }) }, s(tc.id));
42159
+ }) }) : null
42120
42160
  ] });
42121
42161
  }
42122
42162
  function MessageContainer() {
@@ -42468,7 +42508,8 @@ function App() {
42468
42508
  const renderer = useRenderer();
42469
42509
  const { width } = useTerminalDimensions();
42470
42510
  const [sidebarForced, setSidebarForced] = React4.useState(false);
42471
- const sidebarVisible = sidebarForced || width >= SIDEBAR_BREAKPOINT;
42511
+ const hasMessages = messages.length > 0;
42512
+ const sidebarVisible = hasMessages && (sidebarForced || width >= SIDEBAR_BREAKPOINT);
42472
42513
  const [infoCompact, setInfoCompact] = React4.useState(false);
42473
42514
  useKeyboard((key) => {
42474
42515
  if (key.ctrl && key.name === "p") {
@@ -42548,7 +42589,6 @@ function App() {
42548
42589
  }
42549
42590
  void sendMessage(value);
42550
42591
  };
42551
- const hasMessages = messages.length > 0;
42552
42592
  React4.useEffect(() => {
42553
42593
  if (width < SIDEBAR_BREAKPOINT && !sidebarForced) setInfoCompact(true);
42554
42594
  else setInfoCompact(false);