whale-code 6.4.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.
- package/README.md +95 -0
- package/bin/swag-agent.js +9 -0
- package/bin/swagmanager-mcp.js +321 -0
- package/dist/cli/app.d.ts +26 -0
- package/dist/cli/app.js +64 -0
- package/dist/cli/chat/AgentSelector.d.ts +14 -0
- package/dist/cli/chat/AgentSelector.js +14 -0
- package/dist/cli/chat/ChatApp.d.ts +9 -0
- package/dist/cli/chat/ChatApp.js +267 -0
- package/dist/cli/chat/ChatInput.d.ts +39 -0
- package/dist/cli/chat/ChatInput.js +509 -0
- package/dist/cli/chat/MarkdownText.d.ts +10 -0
- package/dist/cli/chat/MarkdownText.js +20 -0
- package/dist/cli/chat/MessageList.d.ts +37 -0
- package/dist/cli/chat/MessageList.js +80 -0
- package/dist/cli/chat/ModelSelector.d.ts +20 -0
- package/dist/cli/chat/ModelSelector.js +73 -0
- package/dist/cli/chat/RewindViewer.d.ts +26 -0
- package/dist/cli/chat/RewindViewer.js +185 -0
- package/dist/cli/chat/StoreSelector.d.ts +14 -0
- package/dist/cli/chat/StoreSelector.js +24 -0
- package/dist/cli/chat/StreamingText.d.ts +12 -0
- package/dist/cli/chat/StreamingText.js +12 -0
- package/dist/cli/chat/SubagentPanel.d.ts +45 -0
- package/dist/cli/chat/SubagentPanel.js +110 -0
- package/dist/cli/chat/TeamPanel.d.ts +21 -0
- package/dist/cli/chat/TeamPanel.js +42 -0
- package/dist/cli/chat/ToolIndicator.d.ts +25 -0
- package/dist/cli/chat/ToolIndicator.js +436 -0
- package/dist/cli/chat/hooks/useAgentLoop.d.ts +39 -0
- package/dist/cli/chat/hooks/useAgentLoop.js +382 -0
- package/dist/cli/chat/hooks/useSlashCommands.d.ts +37 -0
- package/dist/cli/chat/hooks/useSlashCommands.js +387 -0
- package/dist/cli/commands/config-cmd.d.ts +10 -0
- package/dist/cli/commands/config-cmd.js +99 -0
- package/dist/cli/commands/doctor.d.ts +14 -0
- package/dist/cli/commands/doctor.js +172 -0
- package/dist/cli/commands/init.d.ts +16 -0
- package/dist/cli/commands/init.js +278 -0
- package/dist/cli/commands/mcp.d.ts +12 -0
- package/dist/cli/commands/mcp.js +162 -0
- package/dist/cli/login/LoginApp.d.ts +7 -0
- package/dist/cli/login/LoginApp.js +157 -0
- package/dist/cli/print-mode.d.ts +31 -0
- package/dist/cli/print-mode.js +202 -0
- package/dist/cli/serve-mode.d.ts +37 -0
- package/dist/cli/serve-mode.js +636 -0
- package/dist/cli/services/agent-definitions.d.ts +25 -0
- package/dist/cli/services/agent-definitions.js +91 -0
- package/dist/cli/services/agent-events.d.ts +178 -0
- package/dist/cli/services/agent-events.js +175 -0
- package/dist/cli/services/agent-loop.d.ts +90 -0
- package/dist/cli/services/agent-loop.js +762 -0
- package/dist/cli/services/agent-worker-base.d.ts +97 -0
- package/dist/cli/services/agent-worker-base.js +220 -0
- package/dist/cli/services/auth-service.d.ts +30 -0
- package/dist/cli/services/auth-service.js +160 -0
- package/dist/cli/services/background-processes.d.ts +126 -0
- package/dist/cli/services/background-processes.js +318 -0
- package/dist/cli/services/browser-auth.d.ts +24 -0
- package/dist/cli/services/browser-auth.js +180 -0
- package/dist/cli/services/claude-md-loader.d.ts +16 -0
- package/dist/cli/services/claude-md-loader.js +58 -0
- package/dist/cli/services/config-store.d.ts +47 -0
- package/dist/cli/services/config-store.js +79 -0
- package/dist/cli/services/debug-log.d.ts +10 -0
- package/dist/cli/services/debug-log.js +52 -0
- package/dist/cli/services/error-logger.d.ts +58 -0
- package/dist/cli/services/error-logger.js +269 -0
- package/dist/cli/services/file-history.d.ts +21 -0
- package/dist/cli/services/file-history.js +83 -0
- package/dist/cli/services/format-server-response.d.ts +16 -0
- package/dist/cli/services/format-server-response.js +440 -0
- package/dist/cli/services/git-context.d.ts +11 -0
- package/dist/cli/services/git-context.js +66 -0
- package/dist/cli/services/hooks.d.ts +85 -0
- package/dist/cli/services/hooks.js +258 -0
- package/dist/cli/services/interactive-tools.d.ts +125 -0
- package/dist/cli/services/interactive-tools.js +260 -0
- package/dist/cli/services/keybinding-manager.d.ts +52 -0
- package/dist/cli/services/keybinding-manager.js +115 -0
- package/dist/cli/services/local-tools.d.ts +22 -0
- package/dist/cli/services/local-tools.js +697 -0
- package/dist/cli/services/lsp-manager.d.ts +18 -0
- package/dist/cli/services/lsp-manager.js +717 -0
- package/dist/cli/services/mcp-client.d.ts +48 -0
- package/dist/cli/services/mcp-client.js +157 -0
- package/dist/cli/services/memory-manager.d.ts +16 -0
- package/dist/cli/services/memory-manager.js +57 -0
- package/dist/cli/services/model-manager.d.ts +18 -0
- package/dist/cli/services/model-manager.js +71 -0
- package/dist/cli/services/model-router.d.ts +26 -0
- package/dist/cli/services/model-router.js +149 -0
- package/dist/cli/services/permission-modes.d.ts +13 -0
- package/dist/cli/services/permission-modes.js +43 -0
- package/dist/cli/services/rewind.d.ts +84 -0
- package/dist/cli/services/rewind.js +194 -0
- package/dist/cli/services/ripgrep.d.ts +28 -0
- package/dist/cli/services/ripgrep.js +138 -0
- package/dist/cli/services/sandbox.d.ts +29 -0
- package/dist/cli/services/sandbox.js +97 -0
- package/dist/cli/services/server-tools.d.ts +61 -0
- package/dist/cli/services/server-tools.js +543 -0
- package/dist/cli/services/session-persistence.d.ts +23 -0
- package/dist/cli/services/session-persistence.js +99 -0
- package/dist/cli/services/subagent-worker.d.ts +19 -0
- package/dist/cli/services/subagent-worker.js +41 -0
- package/dist/cli/services/subagent.d.ts +47 -0
- package/dist/cli/services/subagent.js +647 -0
- package/dist/cli/services/system-prompt.d.ts +7 -0
- package/dist/cli/services/system-prompt.js +198 -0
- package/dist/cli/services/team-lead.d.ts +73 -0
- package/dist/cli/services/team-lead.js +512 -0
- package/dist/cli/services/team-state.d.ts +77 -0
- package/dist/cli/services/team-state.js +398 -0
- package/dist/cli/services/teammate.d.ts +31 -0
- package/dist/cli/services/teammate.js +689 -0
- package/dist/cli/services/telemetry.d.ts +61 -0
- package/dist/cli/services/telemetry.js +209 -0
- package/dist/cli/services/tools/agent-tools.d.ts +14 -0
- package/dist/cli/services/tools/agent-tools.js +347 -0
- package/dist/cli/services/tools/file-ops.d.ts +15 -0
- package/dist/cli/services/tools/file-ops.js +487 -0
- package/dist/cli/services/tools/search-tools.d.ts +8 -0
- package/dist/cli/services/tools/search-tools.js +186 -0
- package/dist/cli/services/tools/shell-exec.d.ts +10 -0
- package/dist/cli/services/tools/shell-exec.js +168 -0
- package/dist/cli/services/tools/task-manager.d.ts +28 -0
- package/dist/cli/services/tools/task-manager.js +209 -0
- package/dist/cli/services/tools/web-tools.d.ts +11 -0
- package/dist/cli/services/tools/web-tools.js +395 -0
- package/dist/cli/setup/SetupApp.d.ts +9 -0
- package/dist/cli/setup/SetupApp.js +191 -0
- package/dist/cli/shared/MatrixIntro.d.ts +4 -0
- package/dist/cli/shared/MatrixIntro.js +83 -0
- package/dist/cli/shared/Theme.d.ts +74 -0
- package/dist/cli/shared/Theme.js +127 -0
- package/dist/cli/shared/WhaleBanner.d.ts +10 -0
- package/dist/cli/shared/WhaleBanner.js +12 -0
- package/dist/cli/shared/markdown.d.ts +21 -0
- package/dist/cli/shared/markdown.js +756 -0
- package/dist/cli/status/StatusApp.d.ts +4 -0
- package/dist/cli/status/StatusApp.js +105 -0
- package/dist/cli/stores/StoreApp.d.ts +7 -0
- package/dist/cli/stores/StoreApp.js +81 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +538 -0
- package/dist/local-agent/connection.d.ts +48 -0
- package/dist/local-agent/connection.js +332 -0
- package/dist/local-agent/discovery.d.ts +18 -0
- package/dist/local-agent/discovery.js +146 -0
- package/dist/local-agent/executor.d.ts +34 -0
- package/dist/local-agent/executor.js +241 -0
- package/dist/local-agent/index.d.ts +14 -0
- package/dist/local-agent/index.js +198 -0
- package/dist/node/adapters/base.d.ts +35 -0
- package/dist/node/adapters/base.js +10 -0
- package/dist/node/adapters/discord.d.ts +29 -0
- package/dist/node/adapters/discord.js +299 -0
- package/dist/node/adapters/email.d.ts +23 -0
- package/dist/node/adapters/email.js +218 -0
- package/dist/node/adapters/imessage.d.ts +17 -0
- package/dist/node/adapters/imessage.js +118 -0
- package/dist/node/adapters/slack.d.ts +26 -0
- package/dist/node/adapters/slack.js +259 -0
- package/dist/node/adapters/sms.d.ts +23 -0
- package/dist/node/adapters/sms.js +161 -0
- package/dist/node/adapters/telegram.d.ts +17 -0
- package/dist/node/adapters/telegram.js +101 -0
- package/dist/node/adapters/webchat.d.ts +27 -0
- package/dist/node/adapters/webchat.js +160 -0
- package/dist/node/adapters/whatsapp.d.ts +28 -0
- package/dist/node/adapters/whatsapp.js +230 -0
- package/dist/node/cli.d.ts +2 -0
- package/dist/node/cli.js +325 -0
- package/dist/node/config.d.ts +17 -0
- package/dist/node/config.js +31 -0
- package/dist/node/runtime.d.ts +50 -0
- package/dist/node/runtime.js +351 -0
- package/dist/server/handlers/__test-utils__/mock-supabase.d.ts +11 -0
- package/dist/server/handlers/__test-utils__/mock-supabase.js +393 -0
- package/dist/server/handlers/analytics.d.ts +17 -0
- package/dist/server/handlers/analytics.js +266 -0
- package/dist/server/handlers/api-keys.d.ts +6 -0
- package/dist/server/handlers/api-keys.js +221 -0
- package/dist/server/handlers/billing.d.ts +33 -0
- package/dist/server/handlers/billing.js +272 -0
- package/dist/server/handlers/browser.d.ts +10 -0
- package/dist/server/handlers/browser.js +517 -0
- package/dist/server/handlers/catalog.d.ts +99 -0
- package/dist/server/handlers/catalog.js +976 -0
- package/dist/server/handlers/comms.d.ts +254 -0
- package/dist/server/handlers/comms.js +588 -0
- package/dist/server/handlers/creations.d.ts +6 -0
- package/dist/server/handlers/creations.js +479 -0
- package/dist/server/handlers/crm.d.ts +89 -0
- package/dist/server/handlers/crm.js +538 -0
- package/dist/server/handlers/discovery.d.ts +6 -0
- package/dist/server/handlers/discovery.js +288 -0
- package/dist/server/handlers/embeddings.d.ts +92 -0
- package/dist/server/handlers/embeddings.js +197 -0
- package/dist/server/handlers/enrichment.d.ts +8 -0
- package/dist/server/handlers/enrichment.js +768 -0
- package/dist/server/handlers/image-gen.d.ts +6 -0
- package/dist/server/handlers/image-gen.js +409 -0
- package/dist/server/handlers/inventory.d.ts +319 -0
- package/dist/server/handlers/inventory.js +447 -0
- package/dist/server/handlers/kali.d.ts +10 -0
- package/dist/server/handlers/kali.js +210 -0
- package/dist/server/handlers/llm-providers.d.ts +6 -0
- package/dist/server/handlers/llm-providers.js +673 -0
- package/dist/server/handlers/local-agent.d.ts +6 -0
- package/dist/server/handlers/local-agent.js +118 -0
- package/dist/server/handlers/meta-ads.d.ts +111 -0
- package/dist/server/handlers/meta-ads.js +2279 -0
- package/dist/server/handlers/nodes.d.ts +33 -0
- package/dist/server/handlers/nodes.js +699 -0
- package/dist/server/handlers/operations.d.ts +138 -0
- package/dist/server/handlers/operations.js +131 -0
- package/dist/server/handlers/platform.d.ts +23 -0
- package/dist/server/handlers/platform.js +227 -0
- package/dist/server/handlers/supply-chain.d.ts +19 -0
- package/dist/server/handlers/supply-chain.js +327 -0
- package/dist/server/handlers/transcription.d.ts +17 -0
- package/dist/server/handlers/transcription.js +121 -0
- package/dist/server/handlers/video-gen.d.ts +6 -0
- package/dist/server/handlers/video-gen.js +466 -0
- package/dist/server/handlers/voice.d.ts +8 -0
- package/dist/server/handlers/voice.js +1146 -0
- package/dist/server/handlers/workflow-steps.d.ts +86 -0
- package/dist/server/handlers/workflow-steps.js +2349 -0
- package/dist/server/handlers/workflows.d.ts +7 -0
- package/dist/server/handlers/workflows.js +989 -0
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +2427 -0
- package/dist/server/lib/batch-client.d.ts +80 -0
- package/dist/server/lib/batch-client.js +467 -0
- package/dist/server/lib/code-worker-pool.d.ts +31 -0
- package/dist/server/lib/code-worker-pool.js +224 -0
- package/dist/server/lib/code-worker.d.ts +1 -0
- package/dist/server/lib/code-worker.js +188 -0
- package/dist/server/lib/compaction-service.d.ts +32 -0
- package/dist/server/lib/compaction-service.js +162 -0
- package/dist/server/lib/logger.d.ts +19 -0
- package/dist/server/lib/logger.js +46 -0
- package/dist/server/lib/otel.d.ts +38 -0
- package/dist/server/lib/otel.js +126 -0
- package/dist/server/lib/pg-rate-limiter.d.ts +21 -0
- package/dist/server/lib/pg-rate-limiter.js +86 -0
- package/dist/server/lib/prompt-sanitizer.d.ts +37 -0
- package/dist/server/lib/prompt-sanitizer.js +177 -0
- package/dist/server/lib/provider-capabilities.d.ts +85 -0
- package/dist/server/lib/provider-capabilities.js +190 -0
- package/dist/server/lib/provider-failover.d.ts +74 -0
- package/dist/server/lib/provider-failover.js +210 -0
- package/dist/server/lib/rate-limiter.d.ts +39 -0
- package/dist/server/lib/rate-limiter.js +147 -0
- package/dist/server/lib/server-agent-loop.d.ts +107 -0
- package/dist/server/lib/server-agent-loop.js +667 -0
- package/dist/server/lib/server-subagent.d.ts +78 -0
- package/dist/server/lib/server-subagent.js +203 -0
- package/dist/server/lib/session-checkpoint.d.ts +51 -0
- package/dist/server/lib/session-checkpoint.js +145 -0
- package/dist/server/lib/ssrf-guard.d.ts +13 -0
- package/dist/server/lib/ssrf-guard.js +240 -0
- package/dist/server/lib/supabase-client.d.ts +7 -0
- package/dist/server/lib/supabase-client.js +78 -0
- package/dist/server/lib/template-resolver.d.ts +31 -0
- package/dist/server/lib/template-resolver.js +215 -0
- package/dist/server/lib/utils.d.ts +16 -0
- package/dist/server/lib/utils.js +147 -0
- package/dist/server/local-agent-gateway.d.ts +82 -0
- package/dist/server/local-agent-gateway.js +426 -0
- package/dist/server/providers/anthropic.d.ts +20 -0
- package/dist/server/providers/anthropic.js +199 -0
- package/dist/server/providers/bedrock.d.ts +20 -0
- package/dist/server/providers/bedrock.js +194 -0
- package/dist/server/providers/gemini.d.ts +24 -0
- package/dist/server/providers/gemini.js +486 -0
- package/dist/server/providers/openai.d.ts +24 -0
- package/dist/server/providers/openai.js +522 -0
- package/dist/server/providers/registry.d.ts +32 -0
- package/dist/server/providers/registry.js +58 -0
- package/dist/server/providers/shared.d.ts +32 -0
- package/dist/server/providers/shared.js +124 -0
- package/dist/server/providers/types.d.ts +92 -0
- package/dist/server/providers/types.js +12 -0
- package/dist/server/proxy-handlers.d.ts +6 -0
- package/dist/server/proxy-handlers.js +89 -0
- package/dist/server/tool-router.d.ts +149 -0
- package/dist/server/tool-router.js +803 -0
- package/dist/server/validation.d.ts +24 -0
- package/dist/server/validation.js +301 -0
- package/dist/server/worker.d.ts +19 -0
- package/dist/server/worker.js +201 -0
- package/dist/setup.d.ts +8 -0
- package/dist/setup.js +181 -0
- package/dist/shared/agent-core.d.ts +157 -0
- package/dist/shared/agent-core.js +534 -0
- package/dist/shared/anthropic-types.d.ts +105 -0
- package/dist/shared/anthropic-types.js +7 -0
- package/dist/shared/api-client.d.ts +90 -0
- package/dist/shared/api-client.js +379 -0
- package/dist/shared/constants.d.ts +33 -0
- package/dist/shared/constants.js +80 -0
- package/dist/shared/sse-parser.d.ts +26 -0
- package/dist/shared/sse-parser.js +259 -0
- package/dist/shared/tool-dispatch.d.ts +52 -0
- package/dist/shared/tool-dispatch.js +191 -0
- package/dist/shared/types.d.ts +72 -0
- package/dist/shared/types.js +7 -0
- package/dist/updater.d.ts +25 -0
- package/dist/updater.js +140 -0
- package/dist/webchat/widget.d.ts +0 -0
- package/dist/webchat/widget.js +397 -0
- package/package.json +95 -0
- package/src/cli/services/builtin-skills/commit.md +19 -0
- package/src/cli/services/builtin-skills/review-pr.md +21 -0
- package/src/cli/services/builtin-skills/review.md +18 -0
|
@@ -0,0 +1,436 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* ToolIndicator — polished tool call rendering
|
|
4
|
+
*
|
|
5
|
+
* Every result gets syntax highlighting via MarkdownText.
|
|
6
|
+
* Financial-aware: green for gains, red for deductions/negatives.
|
|
7
|
+
* Params: purple keys, typed values (blue dates, green money, red negatives).
|
|
8
|
+
* Duration badge, tool type glyph.
|
|
9
|
+
*/
|
|
10
|
+
import React, { useMemo, useState, useEffect } from "react";
|
|
11
|
+
import { Box, Text } from "ink";
|
|
12
|
+
import Spinner from "ink-spinner";
|
|
13
|
+
import { MarkdownText } from "./MarkdownText.js";
|
|
14
|
+
import { colors } from "../shared/Theme.js";
|
|
15
|
+
import { contentWidth } from "../shared/markdown.js";
|
|
16
|
+
import { isLocalTool } from "../services/local-tools.js";
|
|
17
|
+
import os from "os";
|
|
18
|
+
// ============================================================================
|
|
19
|
+
// CONSTANTS
|
|
20
|
+
// ============================================================================
|
|
21
|
+
const AUTO_EXPAND_THRESHOLD = 12;
|
|
22
|
+
const PREVIEW_LINES = 6;
|
|
23
|
+
// ============================================================================
|
|
24
|
+
// HELPERS
|
|
25
|
+
// ============================================================================
|
|
26
|
+
/** Shorten an absolute path for display: strip cwd, collapse home, truncate */
|
|
27
|
+
export function shortenPath(fullPath, maxLen = 40) {
|
|
28
|
+
let p = fullPath;
|
|
29
|
+
const cwd = process.cwd();
|
|
30
|
+
if (p.startsWith(cwd + "/"))
|
|
31
|
+
p = p.slice(cwd.length + 1);
|
|
32
|
+
else if (p.startsWith(cwd))
|
|
33
|
+
p = p.slice(cwd.length);
|
|
34
|
+
else {
|
|
35
|
+
const home = os.homedir();
|
|
36
|
+
if (p.startsWith(home))
|
|
37
|
+
p = "~" + p.slice(home.length);
|
|
38
|
+
}
|
|
39
|
+
if (p.length <= maxLen)
|
|
40
|
+
return p;
|
|
41
|
+
const parts = p.split("/");
|
|
42
|
+
const file = parts.pop();
|
|
43
|
+
if (file.length >= maxLen - 4)
|
|
44
|
+
return "…/" + file.slice(-(maxLen - 4));
|
|
45
|
+
const parent = parts.pop();
|
|
46
|
+
return parent ? "…/" + parent + "/" + file : "…/" + file;
|
|
47
|
+
}
|
|
48
|
+
function formatDuration(ms) {
|
|
49
|
+
if (ms < 1000)
|
|
50
|
+
return `${ms}ms`;
|
|
51
|
+
if (ms < 10000)
|
|
52
|
+
return `${(ms / 1000).toFixed(1)}s`;
|
|
53
|
+
return `${Math.round(ms / 1000)}s`;
|
|
54
|
+
}
|
|
55
|
+
/** Compact one-line context */
|
|
56
|
+
function formatContext(name, input) {
|
|
57
|
+
if (!input)
|
|
58
|
+
return "";
|
|
59
|
+
if (name === "read_file" || name === "write_file" || name === "edit_file" || name === "list_directory") {
|
|
60
|
+
return input.path ? shortenPath(String(input.path)) : "";
|
|
61
|
+
}
|
|
62
|
+
if (name === "run_command") {
|
|
63
|
+
let cmd = String(input.command || "");
|
|
64
|
+
// Mask passwords/secrets in display
|
|
65
|
+
cmd = cmd.replace(/(?:PASSWORD|SECRET|TOKEN|KEY)=['"][^'"]*['"]/gi, (m) => {
|
|
66
|
+
const eq = m.indexOf("=");
|
|
67
|
+
return m.slice(0, eq + 1) + "'••••'";
|
|
68
|
+
});
|
|
69
|
+
// Adaptive truncation — fit within one terminal line
|
|
70
|
+
const maxCtx = Math.min(60, Math.max(20, contentWidth() - 40));
|
|
71
|
+
return cmd.length > maxCtx ? cmd.slice(0, maxCtx - 1) + "…" : cmd;
|
|
72
|
+
}
|
|
73
|
+
if (name === "search_files") {
|
|
74
|
+
const parts = [input.pattern, input.path ? shortenPath(String(input.path)) : null].filter(Boolean);
|
|
75
|
+
return parts.join(" in ");
|
|
76
|
+
}
|
|
77
|
+
if (name === "search_content") {
|
|
78
|
+
const q = String(input.query || "");
|
|
79
|
+
const p = input.path ? ` in ${shortenPath(String(input.path))}` : "";
|
|
80
|
+
return q.length > 30 ? q.slice(0, 27) + "…" + p : q + p;
|
|
81
|
+
}
|
|
82
|
+
if (name === "grep") {
|
|
83
|
+
const parts = [input.pattern, input.path ? shortenPath(String(input.path)) : null].filter(Boolean);
|
|
84
|
+
return parts.join(" in ");
|
|
85
|
+
}
|
|
86
|
+
if (name === "glob") {
|
|
87
|
+
const parts = [input.pattern, input.path ? shortenPath(String(input.path)) : null].filter(Boolean);
|
|
88
|
+
return parts.join(" in ");
|
|
89
|
+
}
|
|
90
|
+
if (name === "multi_edit") {
|
|
91
|
+
const edits = (input.edits ?? []);
|
|
92
|
+
return input.file_path ? `${shortenPath(String(input.file_path))} (${edits.length} edits)` : "";
|
|
93
|
+
}
|
|
94
|
+
if (name === "task") {
|
|
95
|
+
const type = input.subagent_type || "";
|
|
96
|
+
const model = input.model || "sonnet";
|
|
97
|
+
return `${type} (${model})`;
|
|
98
|
+
}
|
|
99
|
+
if (name === "lsp") {
|
|
100
|
+
const op = input.operation || "";
|
|
101
|
+
const fp = input.filePath ? shortenPath(String(input.filePath)) : "";
|
|
102
|
+
const ln = input.line ? `:${input.line}` : "";
|
|
103
|
+
return `${op} ${fp}${ln}`;
|
|
104
|
+
}
|
|
105
|
+
// Kali — show the command being executed (most useful context)
|
|
106
|
+
if (name === "kali" && input.command) {
|
|
107
|
+
let cmd = String(input.command);
|
|
108
|
+
const maxCtx = Math.min(60, Math.max(20, contentWidth() - 40));
|
|
109
|
+
cmd = cmd.length > maxCtx ? cmd.slice(0, maxCtx - 1) + "…" : cmd;
|
|
110
|
+
const action = input.action ? String(input.action) + " " : "";
|
|
111
|
+
return action + cmd;
|
|
112
|
+
}
|
|
113
|
+
// Server tools → action + key param
|
|
114
|
+
if (input.action) {
|
|
115
|
+
const parts = [String(input.action)];
|
|
116
|
+
if (input.query)
|
|
117
|
+
parts.push(String(input.query).slice(0, 25));
|
|
118
|
+
else if (input.command)
|
|
119
|
+
parts.push(String(input.command).slice(0, 40));
|
|
120
|
+
else if (input.name)
|
|
121
|
+
parts.push(String(input.name));
|
|
122
|
+
else if (input.period)
|
|
123
|
+
parts.push(String(input.period));
|
|
124
|
+
else if (input.product_id)
|
|
125
|
+
parts.push(String(input.product_id).slice(0, 12));
|
|
126
|
+
else if (input.location_id)
|
|
127
|
+
parts.push(String(input.location_id).slice(0, 12));
|
|
128
|
+
else if (input.customer_id)
|
|
129
|
+
parts.push(String(input.customer_id).slice(0, 12));
|
|
130
|
+
else if (input.order_id)
|
|
131
|
+
parts.push(String(input.order_id).slice(0, 12));
|
|
132
|
+
return parts.join(" ");
|
|
133
|
+
}
|
|
134
|
+
return "";
|
|
135
|
+
}
|
|
136
|
+
const LANG_MAP = {
|
|
137
|
+
ts: "typescript", tsx: "tsx", js: "javascript", jsx: "jsx",
|
|
138
|
+
py: "python", rs: "rust", go: "go", rb: "ruby",
|
|
139
|
+
swift: "swift", kt: "kotlin", java: "java", c: "c", cpp: "cpp",
|
|
140
|
+
css: "css", html: "html", json: "json", yaml: "yaml", yml: "yaml",
|
|
141
|
+
toml: "toml", md: "markdown", sh: "bash", zsh: "bash",
|
|
142
|
+
sql: "sql", xml: "xml",
|
|
143
|
+
};
|
|
144
|
+
const CATEGORY_STYLES = {
|
|
145
|
+
read: { icon: "◇", color: colors.info },
|
|
146
|
+
write: { icon: "◆", color: colors.success },
|
|
147
|
+
edit: { icon: "±", color: colors.warning },
|
|
148
|
+
search: { icon: "⊕", color: colors.purple },
|
|
149
|
+
command: { icon: "$", color: colors.pink },
|
|
150
|
+
directory: { icon: "▤", color: colors.indigo },
|
|
151
|
+
web: { icon: "◎", color: colors.brand },
|
|
152
|
+
agent: { icon: "⊛", color: colors.purple },
|
|
153
|
+
todo: { icon: "☐", color: colors.success },
|
|
154
|
+
notebook: { icon: "◫", color: colors.warning },
|
|
155
|
+
server: { icon: "▹", color: colors.pink },
|
|
156
|
+
lsp: { icon: "⊞", color: colors.info },
|
|
157
|
+
interactive: { icon: "▹", color: colors.indigo },
|
|
158
|
+
};
|
|
159
|
+
const TOOL_CATEGORY_MAP = {
|
|
160
|
+
read_file: "read",
|
|
161
|
+
write_file: "write",
|
|
162
|
+
edit_file: "edit",
|
|
163
|
+
multi_edit: "edit",
|
|
164
|
+
search_files: "search",
|
|
165
|
+
search_content: "search",
|
|
166
|
+
glob: "search",
|
|
167
|
+
grep: "search",
|
|
168
|
+
run_command: "command",
|
|
169
|
+
list_directory: "directory",
|
|
170
|
+
web_fetch: "web",
|
|
171
|
+
web_search: "web",
|
|
172
|
+
task: "agent",
|
|
173
|
+
team_create: "agent",
|
|
174
|
+
tasks: "todo",
|
|
175
|
+
config: "command",
|
|
176
|
+
ask_user: "command",
|
|
177
|
+
bash_output: "command",
|
|
178
|
+
kill_shell: "command",
|
|
179
|
+
list_shells: "command",
|
|
180
|
+
notebook_edit: "notebook",
|
|
181
|
+
task_output: "agent",
|
|
182
|
+
task_stop: "agent",
|
|
183
|
+
lsp: "lsp",
|
|
184
|
+
enter_plan_mode: "interactive",
|
|
185
|
+
exit_plan_mode: "interactive",
|
|
186
|
+
ask_user_question: "interactive",
|
|
187
|
+
skill: "command",
|
|
188
|
+
};
|
|
189
|
+
function getToolCategory(name) {
|
|
190
|
+
return TOOL_CATEGORY_MAP[name] || (isLocalTool(name) ? "command" : "server");
|
|
191
|
+
}
|
|
192
|
+
// Human-readable tool display names (Claude Code parity)
|
|
193
|
+
const TOOL_DISPLAY_NAMES = {
|
|
194
|
+
read_file: "Read",
|
|
195
|
+
write_file: "Write",
|
|
196
|
+
edit_file: "Edit",
|
|
197
|
+
multi_edit: "MultiEdit",
|
|
198
|
+
search_files: "Search",
|
|
199
|
+
search_content: "Search",
|
|
200
|
+
glob: "Glob",
|
|
201
|
+
grep: "Grep",
|
|
202
|
+
run_command: "Bash",
|
|
203
|
+
list_directory: "List",
|
|
204
|
+
web_fetch: "WebFetch",
|
|
205
|
+
web_search: "WebSearch",
|
|
206
|
+
task: "Task",
|
|
207
|
+
team_create: "Team",
|
|
208
|
+
tasks: "Tasks",
|
|
209
|
+
config: "Config",
|
|
210
|
+
ask_user: "AskUser",
|
|
211
|
+
bash_output: "TaskOutput",
|
|
212
|
+
kill_shell: "TaskStop",
|
|
213
|
+
list_shells: "Tasks",
|
|
214
|
+
notebook_edit: "NotebookEdit",
|
|
215
|
+
task_output: "TaskOutput",
|
|
216
|
+
task_stop: "TaskStop",
|
|
217
|
+
lsp: "LSP",
|
|
218
|
+
enter_plan_mode: "PlanMode",
|
|
219
|
+
exit_plan_mode: "PlanMode",
|
|
220
|
+
ask_user_question: "AskUser",
|
|
221
|
+
skill: "Skill",
|
|
222
|
+
};
|
|
223
|
+
export function getDisplayName(name) {
|
|
224
|
+
return TOOL_DISPLAY_NAMES[name] || name;
|
|
225
|
+
}
|
|
226
|
+
/** Shorten absolute paths in search/grep results for readable display */
|
|
227
|
+
function formatSearchResult(result) {
|
|
228
|
+
return result.split("\n").map(line => {
|
|
229
|
+
// Match "path:line:col:content" or "path:line:content" (grep/ripgrep output)
|
|
230
|
+
const grepMatch = line.match(/^(\/[^:]+):(\d+(?::\d+)?):(.*)$/);
|
|
231
|
+
if (grepMatch) {
|
|
232
|
+
const [, filePath, lineCol, rest] = grepMatch;
|
|
233
|
+
return `${shortenPath(filePath, 35)}:${lineCol}:${rest}`;
|
|
234
|
+
}
|
|
235
|
+
// Match plain absolute paths (glob results)
|
|
236
|
+
if (line.startsWith("/")) {
|
|
237
|
+
return shortenPath(line.trim(), 60);
|
|
238
|
+
}
|
|
239
|
+
return line;
|
|
240
|
+
}).join("\n");
|
|
241
|
+
}
|
|
242
|
+
const PLAIN_TEXT_TOOLS = new Set(["enter_plan_mode", "exit_plan_mode", "ask_user_question", "skill"]);
|
|
243
|
+
function detectLang(toolName, input) {
|
|
244
|
+
if (toolName === "edit_file" || toolName === "multi_edit")
|
|
245
|
+
return "diff";
|
|
246
|
+
if (toolName === "read_file" && input?.path) {
|
|
247
|
+
const p = String(input.path);
|
|
248
|
+
const base = p.split("/").pop() || "";
|
|
249
|
+
// .env, .env.local, .env.production, etc. → bash (KEY=VALUE syntax)
|
|
250
|
+
if (base.startsWith(".env"))
|
|
251
|
+
return "bash";
|
|
252
|
+
const ext = base.split(".").pop()?.toLowerCase() || "";
|
|
253
|
+
return LANG_MAP[ext] || "";
|
|
254
|
+
}
|
|
255
|
+
if (toolName === "run_command" || toolName === "list_directory")
|
|
256
|
+
return "bash";
|
|
257
|
+
// Interactive/plain tools — render as plain text or markdown (not JSON fences)
|
|
258
|
+
if (PLAIN_TEXT_TOOLS.has(toolName))
|
|
259
|
+
return "";
|
|
260
|
+
if (!isLocalTool(toolName))
|
|
261
|
+
return "json";
|
|
262
|
+
return "";
|
|
263
|
+
}
|
|
264
|
+
function wrapInFence(content, lang, subtitle) {
|
|
265
|
+
if (content.includes("```"))
|
|
266
|
+
return content;
|
|
267
|
+
// Detect formatted markdown (tables, bold, headings) — render as markdown, not fenced
|
|
268
|
+
const t = content.trim();
|
|
269
|
+
if (t.startsWith("**") || t.startsWith("| ") || t.startsWith("# "))
|
|
270
|
+
return content;
|
|
271
|
+
// For server tools, detect JSON
|
|
272
|
+
if (!lang) {
|
|
273
|
+
if ((t.startsWith("{") || t.startsWith("[")) && (t.endsWith("}") || t.endsWith("]"))) {
|
|
274
|
+
lang = "json";
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
// Only add :subtitle when lang is non-empty (prevents "```:path" which has no valid lang)
|
|
278
|
+
const fence = (lang && subtitle) ? lang + ":" + subtitle : lang;
|
|
279
|
+
return "```" + fence + "\n" + content + "\n```";
|
|
280
|
+
}
|
|
281
|
+
// ============================================================================
|
|
282
|
+
// COMPONENT
|
|
283
|
+
// ============================================================================
|
|
284
|
+
export const ToolIndicator = React.memo(function ToolIndicator({ id: _id, name, status, result, input, durationMs, expanded = false, count }) {
|
|
285
|
+
const context = useMemo(() => formatContext(name, input), [name, input]);
|
|
286
|
+
const lineCount = useMemo(() => result ? result.split("\n").length : 0, [result]);
|
|
287
|
+
// Elapsed time counter for running tools
|
|
288
|
+
const [elapsed, setElapsed] = useState(0);
|
|
289
|
+
useEffect(() => {
|
|
290
|
+
if (status !== "running")
|
|
291
|
+
return;
|
|
292
|
+
setElapsed(0);
|
|
293
|
+
const t = setInterval(() => setElapsed(e => e + 1), 1000);
|
|
294
|
+
return () => clearInterval(t);
|
|
295
|
+
}, [status]);
|
|
296
|
+
// Detect lang — writes with diffs get "diff" treatment
|
|
297
|
+
const lang = useMemo(() => {
|
|
298
|
+
const base = detectLang(name, input);
|
|
299
|
+
if (base)
|
|
300
|
+
return base;
|
|
301
|
+
if (name === "write_file" && result?.includes("\n@@"))
|
|
302
|
+
return "diff";
|
|
303
|
+
return base;
|
|
304
|
+
}, [name, input, result]);
|
|
305
|
+
// Category-based styling
|
|
306
|
+
const category = getToolCategory(name);
|
|
307
|
+
const catStyle = CATEGORY_STYLES[category];
|
|
308
|
+
// Extract file path for code block subtitle
|
|
309
|
+
const filePath = useMemo(() => {
|
|
310
|
+
if (!input)
|
|
311
|
+
return undefined;
|
|
312
|
+
const p = input.path || input.file_path;
|
|
313
|
+
return p ? String(p) : undefined;
|
|
314
|
+
}, [input]);
|
|
315
|
+
// Category-specific summary metrics
|
|
316
|
+
const summary = useMemo(() => {
|
|
317
|
+
if (!result || status !== "success")
|
|
318
|
+
return null;
|
|
319
|
+
if (category === "read") {
|
|
320
|
+
const lc = result.split("\n").length;
|
|
321
|
+
return { type: "read", label: `Read ${lc} line${lc !== 1 ? "s" : ""}` };
|
|
322
|
+
}
|
|
323
|
+
if (category === "write") {
|
|
324
|
+
// Overwrite with diff — show +N -N badge
|
|
325
|
+
const diffMatch = result.match(/Added (\d+) lines?, removed (\d+) lines?/i);
|
|
326
|
+
if (diffMatch) {
|
|
327
|
+
return { type: "edit", added: parseInt(diffMatch[1]), removed: parseInt(diffMatch[2]) };
|
|
328
|
+
}
|
|
329
|
+
const lineMatch = result.match(/\((\d+) lines?, (\d+) chars\)/);
|
|
330
|
+
if (lineMatch) {
|
|
331
|
+
const lines = parseInt(lineMatch[1]);
|
|
332
|
+
const label = `Wrote ${lines} line${lines !== 1 ? "s" : ""}`;
|
|
333
|
+
return { type: "write", label };
|
|
334
|
+
}
|
|
335
|
+
const charMatch = result.match(/\((\d+) chars\)/);
|
|
336
|
+
if (charMatch) {
|
|
337
|
+
const chars = parseInt(charMatch[1]);
|
|
338
|
+
const label = chars >= 1000 ? `Wrote ${(chars / 1000).toFixed(1)}K chars` : `Wrote ${chars} chars`;
|
|
339
|
+
return { type: "write", label };
|
|
340
|
+
}
|
|
341
|
+
return { type: "write", label: "Written" };
|
|
342
|
+
}
|
|
343
|
+
if (category === "edit") {
|
|
344
|
+
let added = 0, removed = 0;
|
|
345
|
+
for (const line of result.split("\n")) {
|
|
346
|
+
if (line.startsWith("+"))
|
|
347
|
+
added++;
|
|
348
|
+
else if (line.startsWith("-"))
|
|
349
|
+
removed++;
|
|
350
|
+
}
|
|
351
|
+
if (added > 0 || removed > 0)
|
|
352
|
+
return { type: "edit", added, removed };
|
|
353
|
+
}
|
|
354
|
+
if (category === "search") {
|
|
355
|
+
const lines = result.split("\n").filter(l => l.trim());
|
|
356
|
+
const files = new Set(lines.map(l => l.split(":")[0]).filter(f => f.includes("/") || f.includes(".")));
|
|
357
|
+
if (lines.length > 0)
|
|
358
|
+
return { type: "search", matches: lines.length, files: files.size };
|
|
359
|
+
}
|
|
360
|
+
if (category === "command") {
|
|
361
|
+
const lines = result.split("\n").filter(l => l.trim());
|
|
362
|
+
if (lines.length > 0)
|
|
363
|
+
return { type: "command", label: `${lines.length} line${lines.length !== 1 ? "s" : ""} output` };
|
|
364
|
+
}
|
|
365
|
+
if (category === "directory") {
|
|
366
|
+
const items = result.split("\n").filter(l => l.trim());
|
|
367
|
+
if (items.length > 0)
|
|
368
|
+
return { type: "directory", label: `${items.length} item${items.length !== 1 ? "s" : ""}` };
|
|
369
|
+
}
|
|
370
|
+
if (category === "web") {
|
|
371
|
+
const chars = result.length;
|
|
372
|
+
const label = chars >= 1000 ? `${(chars / 1000).toFixed(1)}K chars` : `${chars} chars`;
|
|
373
|
+
return { type: "web", label: `fetched ${label}` };
|
|
374
|
+
}
|
|
375
|
+
// Server tools with formatted markdown — extract bold title as summary
|
|
376
|
+
if (category === "server" && result.trim().startsWith("**")) {
|
|
377
|
+
const firstLine = result.trim().split("\n")[0];
|
|
378
|
+
const match = firstLine.match(/^\*\*(.+?)\*\*/);
|
|
379
|
+
if (match)
|
|
380
|
+
return { type: "server", label: match[1] };
|
|
381
|
+
}
|
|
382
|
+
return null;
|
|
383
|
+
}, [result, status, category]);
|
|
384
|
+
// Live output lines (last 6) for running commands
|
|
385
|
+
const liveLines = useMemo(() => {
|
|
386
|
+
if (status !== "running" || !result)
|
|
387
|
+
return [];
|
|
388
|
+
return result.split("\n").filter(l => l.trim()).slice(-6);
|
|
389
|
+
}, [status, result]);
|
|
390
|
+
// ── RUNNING ──
|
|
391
|
+
if (status === "running") {
|
|
392
|
+
return (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Box, { children: [_jsx(Text, { color: catStyle.color, children: _jsx(Spinner, { type: "dots" }) }), _jsxs(Text, { color: catStyle.color, children: [" ", catStyle.icon] }), _jsxs(Text, { color: catStyle.color, bold: true, children: [" ", getDisplayName(name)] }), context ? _jsxs(Text, { color: colors.dim, children: [" ", context] }) : null, elapsed >= 2 && _jsxs(Text, { color: elapsed >= 30 ? colors.warning : colors.dim, children: [" ", formatDuration(elapsed * 1000)] })] }), liveLines.length > 0 && (_jsx(Box, { flexDirection: "column", marginLeft: 4, children: liveLines.map((line, i) => (_jsx(Text, { color: colors.tertiary, wrap: "truncate", children: line }, i))) }))] }));
|
|
393
|
+
}
|
|
394
|
+
// ── ERROR ──
|
|
395
|
+
if (status === "error") {
|
|
396
|
+
return (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Box, { children: [_jsx(Text, { color: colors.error, bold: true, children: "\u2715" }), _jsxs(Text, { color: catStyle.color, children: [" ", catStyle.icon] }), _jsxs(Text, { color: catStyle.color, bold: true, children: [" ", getDisplayName(name)] }), context ? _jsxs(Text, { color: colors.dim, children: [" ", context] }) : null, durationMs !== undefined && _jsxs(Text, { color: colors.dim, children: [" ", formatDuration(durationMs)] })] }), result && (_jsx(Box, { marginLeft: 2, children: _jsx(MarkdownText, { text: "```\n" + result.split("\n").slice(0, PREVIEW_LINES).join("\n") + "\n```" }) }))] }));
|
|
397
|
+
}
|
|
398
|
+
// ── SUCCESS ──
|
|
399
|
+
const hasResult = !!(result && result.trim());
|
|
400
|
+
const isShort = lineCount <= AUTO_EXPAND_THRESHOLD;
|
|
401
|
+
// Read/write results stay collapsed (just header line) — Claude Code parity.
|
|
402
|
+
// Edit/search/command results auto-expand if short enough.
|
|
403
|
+
// Writes with diffs auto-expand like edits.
|
|
404
|
+
const hasDiff = lang === "diff";
|
|
405
|
+
const collapseByDefault = category === "read" || (category === "write" && !hasDiff) || category === "directory";
|
|
406
|
+
// Interactive tools (plan mode) always expand to show their content
|
|
407
|
+
const alwaysExpand = category === "interactive";
|
|
408
|
+
const isGrouped = (count ?? 0) > 1;
|
|
409
|
+
const showFull = hasResult && !isGrouped && (expanded || alwaysExpand || (isShort && !collapseByDefault));
|
|
410
|
+
// For grouped tools, extract a one-line summary so they aren't completely invisible
|
|
411
|
+
const groupSummaryLine = useMemo(() => {
|
|
412
|
+
if (!isGrouped || !result)
|
|
413
|
+
return null;
|
|
414
|
+
const firstLine = result.split("\n").find(l => l.trim() && !l.startsWith("**Success**") && !l.startsWith("**Killed**"));
|
|
415
|
+
if (!firstLine)
|
|
416
|
+
return null;
|
|
417
|
+
const trimmed = firstLine.replace(/^\*\*\w+\*\*:\s*/, "").trim();
|
|
418
|
+
return trimmed.length > 80 ? trimmed.slice(0, 77) + "…" : trimmed;
|
|
419
|
+
}, [isGrouped, result]);
|
|
420
|
+
return (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Box, { children: [_jsx(Text, { color: colors.success, children: "\u2713" }), _jsxs(Text, { color: catStyle.color, children: [" ", catStyle.icon] }), _jsxs(Text, { color: catStyle.color, bold: true, children: [" ", getDisplayName(name)] }), context ? _jsxs(Text, { color: colors.dim, children: [" ", context] }) : null, durationMs !== undefined && (durationMs > 3000
|
|
421
|
+
? _jsxs(Text, { color: colors.warning, children: [" ", formatDuration(durationMs)] })
|
|
422
|
+
: _jsxs(Text, { color: colors.dim, children: [" ", formatDuration(durationMs)] })), summary?.type === "edit" && category === "edit" && (_jsxs(_Fragment, { children: [_jsxs(Text, { color: colors.success, children: [" +", summary.added] }), _jsxs(Text, { color: colors.error, children: [" -", summary.removed] })] })), summary?.type === "search" && (_jsxs(Text, { color: colors.dim, children: [" ", summary.matches, " match", summary.matches !== 1 ? "es" : "", summary.files > 0 ? ` in ${summary.files} file${summary.files !== 1 ? "s" : ""}` : ""] })), summary && "label" in summary && summary.type !== "server" && (_jsxs(Text, { color: colors.dim, children: [" ", summary.label] })), summary?.type === "server" && (_jsxs(Text, { color: colors.info, children: [" ", summary.label] })), !summary && hasResult && !showFull && _jsxs(Text, { color: colors.dim, children: [" ", lineCount, " lines"] }), (count ?? 0) > 1 && _jsxs(Text, { color: colors.dim, dimColor: true, children: [" \u00D7 ", count] })] }), isGrouped && groupSummaryLine && (_jsx(Box, { marginLeft: 4, children: _jsx(Text, { color: colors.tertiary, wrap: "truncate", children: groupSummaryLine }) })), category === "write" && hasDiff && summary?.type === "edit" && (_jsxs(Box, { marginLeft: 2, children: [_jsx(Text, { color: colors.tertiary, children: "\u2514 Added " }), _jsx(Text, { color: colors.success, children: summary.added }), _jsx(Text, { color: colors.tertiary, children: " lines, removed " }), _jsx(Text, { color: colors.error, children: summary.removed }), _jsx(Text, { color: colors.tertiary, children: " lines" })] })), showFull && (_jsx(Box, { marginLeft: 2, flexDirection: "column", children: _jsx(MarkdownText, { text: category === "agent"
|
|
423
|
+
? result
|
|
424
|
+
: wrapInFence(category === "search" ? formatSearchResult(result) : result, lang, filePath) }) })), hasResult && !showFull && !collapseByDefault && !isGrouped && (_jsxs(Box, { flexDirection: "column", marginLeft: 2, children: [_jsx(MarkdownText, { text: category === "agent"
|
|
425
|
+
? result.split("\n").slice(0, PREVIEW_LINES).join("\n")
|
|
426
|
+
: wrapInFence((category === "search" ? formatSearchResult(result) : result).split("\n").slice(0, PREVIEW_LINES).join("\n"), lang, filePath) }), _jsxs(Text, { color: colors.quaternary, children: [" \u2514 +", lineCount - PREVIEW_LINES, " lines "] }), _jsx(Text, { color: colors.tertiary, dimColor: true, children: "^E" })] }))] }));
|
|
427
|
+
}, (prev, next) => {
|
|
428
|
+
// Custom comparator: skip deep-comparing input object reference
|
|
429
|
+
return prev.id === next.id
|
|
430
|
+
&& prev.status === next.status
|
|
431
|
+
&& prev.expanded === next.expanded
|
|
432
|
+
&& prev.result === next.result
|
|
433
|
+
&& prev.durationMs === next.durationMs
|
|
434
|
+
&& prev.name === next.name
|
|
435
|
+
&& prev.count === next.count;
|
|
436
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useAgentLoop — agent loop runner extracted from ChatApp
|
|
3
|
+
*
|
|
4
|
+
* All consumers should import from ChatApp (re-export facade).
|
|
5
|
+
*/
|
|
6
|
+
import type Anthropic from "@anthropic-ai/sdk";
|
|
7
|
+
import { RewindManager } from "../../services/rewind.js";
|
|
8
|
+
import type { ChatMessage, ToolCall } from "../MessageList.js";
|
|
9
|
+
import type { SubagentActivityState, CompletedSubagentInfo } from "../SubagentPanel.js";
|
|
10
|
+
import type { ImageAttachment } from "../ChatInput.js";
|
|
11
|
+
export interface AgentLoopDeps {
|
|
12
|
+
isStreaming: boolean;
|
|
13
|
+
thinkingEnabled: boolean;
|
|
14
|
+
conversationRef: React.MutableRefObject<Anthropic.MessageParam[]>;
|
|
15
|
+
abortRef: React.MutableRefObject<AbortController | null>;
|
|
16
|
+
accTextRef: React.MutableRefObject<string>;
|
|
17
|
+
lastContentUpdateRef: React.MutableRefObject<number>;
|
|
18
|
+
thinkingVerbRef: React.MutableRefObject<string>;
|
|
19
|
+
rewindManagerRef: React.MutableRefObject<RewindManager>;
|
|
20
|
+
turnIndexRef: React.MutableRefObject<number>;
|
|
21
|
+
setMessages: React.Dispatch<React.SetStateAction<ChatMessage[]>>;
|
|
22
|
+
setStreamingText: React.Dispatch<React.SetStateAction<string>>;
|
|
23
|
+
setIsStreaming: React.Dispatch<React.SetStateAction<boolean>>;
|
|
24
|
+
setActiveTools: React.Dispatch<React.SetStateAction<ToolCall[]>>;
|
|
25
|
+
setSubagentActivity: React.Dispatch<React.SetStateAction<Map<string, SubagentActivityState>>>;
|
|
26
|
+
setCompletedSubagents: React.Dispatch<React.SetStateAction<CompletedSubagentInfo[]>>;
|
|
27
|
+
setTeamState: React.Dispatch<React.SetStateAction<{
|
|
28
|
+
name: string;
|
|
29
|
+
tasksCompleted: number;
|
|
30
|
+
tasksTotal: number;
|
|
31
|
+
teammates: Map<string, {
|
|
32
|
+
name: string;
|
|
33
|
+
status: string;
|
|
34
|
+
}>;
|
|
35
|
+
} | null>>;
|
|
36
|
+
}
|
|
37
|
+
export declare function useAgentLoop(deps: AgentLoopDeps): {
|
|
38
|
+
handleSend: (userMessage: string, images?: ImageAttachment[]) => Promise<void>;
|
|
39
|
+
};
|