moi-computer 0.0.2 → 0.1.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/bin/moi.mjs +3 -1
- package/bunfig.toml +4 -0
- package/client/api/workspaces.ts +277 -6
- package/client/assets/mcp/agentation.png +0 -0
- package/client/assets/mcp/airtable.png +0 -0
- package/client/assets/mcp/apollo.png +0 -0
- package/client/assets/mcp/asana.png +0 -0
- package/client/assets/mcp/box.png +0 -0
- package/client/assets/mcp/chrome.svg +33 -0
- package/client/assets/mcp/clickup.png +0 -0
- package/client/assets/mcp/cloudflare.png +0 -0
- package/client/assets/mcp/context7.png +0 -0
- package/client/assets/mcp/datadog.png +0 -0
- package/client/assets/mcp/dropbox.png +0 -0
- package/client/assets/mcp/elevenlabs.png +0 -0
- package/client/assets/mcp/exa.png +0 -0
- package/client/assets/mcp/firecrawl.png +0 -0
- package/client/assets/mcp/gmail.png +0 -0
- package/client/assets/mcp/googlecalendar.png +0 -0
- package/client/assets/mcp/googledrive.png +0 -0
- package/client/assets/mcp/grafana.png +0 -0
- package/client/assets/mcp/huggingface.png +0 -0
- package/client/assets/mcp/intercom.png +0 -0
- package/client/assets/mcp/monday.png +0 -0
- package/client/assets/mcp/mongodb.png +0 -0
- package/client/assets/mcp/paper.png +0 -0
- package/client/assets/mcp/paypal.png +0 -0
- package/client/assets/mcp/perplexity.png +0 -0
- package/client/assets/mcp/postgresql.png +0 -0
- package/client/assets/mcp/posthog.png +0 -0
- package/client/assets/mcp/puppeteer.png +0 -0
- package/client/assets/mcp/railway.png +0 -0
- package/client/assets/mcp/redis.png +0 -0
- package/client/assets/mcp/salesforce.png +0 -0
- package/client/assets/mcp/shopify.png +0 -0
- package/client/assets/mcp/snowflake.png +0 -0
- package/client/assets/mcp/telegram.png +0 -0
- package/client/assets/mcp/twilio.png +0 -0
- package/client/assets/mcp/zapier.png +0 -0
- package/client/components/App.tsx +7 -1
- package/client/components/BottomPanel.tsx +2 -2
- package/client/components/ChatInput.tsx +195 -14
- package/client/components/ChatPanel.tsx +118 -49
- package/client/components/ChatPopup.tsx +2 -2
- package/client/components/CustomizePanel.tsx +8 -8
- package/client/components/HiddenPanel.tsx +1 -1
- package/client/components/HomePage.tsx +1 -1
- package/client/components/IconMcp.tsx +21 -0
- package/client/components/MarkdownContent.tsx +2 -2
- package/client/components/McpMenu.tsx +125 -0
- package/client/components/ModelPicker.tsx +147 -0
- package/client/components/Scratchpad.tsx +775 -0
- package/client/components/ShimmerText.tsx +20 -0
- package/client/components/ThreadSelector.tsx +2 -2
- package/client/components/TurnView.tsx +114 -534
- package/client/components/WidgetErrorBoundary.tsx +2 -2
- package/client/components/WidgetFrame.tsx +1 -1
- package/client/components/WidgetShell.tsx +2 -2
- package/client/components/Widgets.tsx +2 -2
- package/client/components/WorkspacePreview.tsx +3 -3
- package/client/components/WorkspacesPage.tsx +28 -20
- package/client/components/layout/SidebarLayout.tsx +24 -15
- package/client/components/playground/PixelPainter.tsx +2 -2
- package/client/components/playground/PlaygroundPage.tsx +1 -1
- package/client/components/playground/ToolCallsPage.tsx +81 -0
- package/client/components/routes/workspace/[id].tsx +534 -141
- package/client/components/routes/workspace/create.tsx +155 -0
- package/client/components/settings/IconPicker.tsx +590 -0
- package/client/components/settings/SettingsPages.tsx +307 -0
- package/client/components/settings/WorkspaceSettings.tsx +92 -0
- package/client/components/tool-group/CodeBlock.tsx +41 -0
- package/client/components/tool-group/Collapse.tsx +28 -0
- package/client/components/tool-group/ReadImagePreview.tsx +46 -0
- package/client/components/tool-group/SubagentCard.tsx +135 -0
- package/client/components/tool-group/TimelineRow.tsx +147 -0
- package/client/components/tool-group/ToolCallGroup.tsx +231 -0
- package/client/components/tool-group/ToolOutput.tsx +139 -0
- package/client/components/tool-group/detect.ts +93 -0
- package/client/components/tool-group/fixtures.ts +315 -0
- package/client/components/tool-group/format.ts +211 -0
- package/client/components/tool-group/index.ts +9 -0
- package/client/components/ui/button.tsx +4 -4
- package/client/components/ui/dialog.tsx +58 -0
- package/client/components/ui/dropdown-menu.tsx +9 -9
- package/client/components/ui/hover-card.tsx +44 -0
- package/client/components/ui/popover.tsx +1 -1
- package/client/components/ui/switch.tsx +23 -0
- package/client/components/ui/tooltip.tsx +54 -0
- package/client/externalize-react.ts +11 -5
- package/client/hooks/useApplet.ts +117 -0
- package/client/hooks/useChat.ts +162 -62
- package/client/hooks/useMeiEvents.ts +9 -2
- package/client/hooks/useStickToBottom.ts +86 -0
- package/client/hooks/useWorkspaceTheme.ts +8 -2
- package/client/index.css +49 -3
- package/client/index.html +22 -18
- package/client/index.tsx +29 -2
- package/client/lib/WorkspaceContext.tsx +5 -8
- package/client/lib/WorkspaceLayoutContext.tsx +30 -10
- package/client/lib/applet-cache.ts +54 -0
- package/client/lib/connection.ts +237 -0
- package/client/lib/flags.ts +10 -0
- package/client/lib/mcp-icons.ts +142 -10
- package/client/lib/preview-turn.ts +37 -0
- package/client/lib/render-icon.ts +173 -0
- package/client/lib/scratch-executor.ts +20 -0
- package/client/lib/uploads.ts +18 -0
- package/client/main.tsx +5 -0
- package/client/store/live.ts +282 -0
- package/client/structured-clone-shim.ts +14 -0
- package/client/theme.css +2 -2
- package/client/vendor/emojibase/en/data.json +1 -0
- package/client/vendor/emojibase/en/messages.json +1 -0
- package/client/vendor/react/development/_impl/react-dom-client.js +15871 -0
- package/client/vendor/react/development/_impl/react-dom.js +223 -0
- package/client/vendor/react/development/_impl/react-jsx-dev-runtime.js +256 -0
- package/client/vendor/react/development/_impl/react-jsx-runtime.js +260 -0
- package/client/vendor/react/development/_impl/react.js +863 -0
- package/client/vendor/react/development/react-dom-client.js +6 -0
- package/client/vendor/react/development/react-dom.js +17 -0
- package/client/vendor/react/development/react-jsx-dev-runtime.js +5 -0
- package/client/vendor/react/development/react-jsx-runtime.js +6 -0
- package/client/vendor/react/development/react.js +47 -0
- package/client/vendor/react/production/_impl/react-dom-client.js +10361 -0
- package/client/vendor/react/production/_impl/react-dom.js +184 -0
- package/client/vendor/react/production/_impl/react-jsx-dev-runtime.js +37 -0
- package/client/vendor/react/production/_impl/react-jsx-runtime.js +60 -0
- package/client/vendor/react/production/_impl/react.js +428 -0
- package/client/vendor/react/production/react-dom-client.js +6 -0
- package/client/vendor/react/production/react-dom.js +17 -0
- package/client/vendor/react/production/react-jsx-dev-runtime.js +5 -0
- package/client/vendor/react/production/react-jsx-runtime.js +6 -0
- package/client/vendor/react/production/react.js +47 -0
- package/dist/agentation-4s0nn45p.png +0 -0
- package/dist/airtable-hsa66v6q.png +0 -0
- package/dist/apollo-2ed5dy2d.png +0 -0
- package/dist/asana-tvgtwbx2.png +0 -0
- package/dist/atlassian-b3tq39hs.png +0 -0
- package/dist/box-w3n36t5g.png +0 -0
- package/dist/chrome-tspm94rw.svg +33 -0
- package/dist/chunk-kc6e9nd4.css +1 -0
- package/dist/chunk-yf3p7qg7.js +673 -0
- package/dist/claude-z2xnay0d.svg +3 -0
- package/dist/clickup-qqrqqvqb.png +0 -0
- package/dist/cloudflare-j9p931v6.png +0 -0
- package/dist/context7-8ht0xjfy.png +0 -0
- package/dist/datadog-70ne3yzt.png +0 -0
- package/dist/discord-vejhptwx.png +0 -0
- package/dist/dropbox-4m5s9mgr.png +0 -0
- package/dist/elevenlabs-2nzzej1t.png +0 -0
- package/dist/exa-qqj3vr0x.png +0 -0
- package/dist/favicon-nbmyjfjh.png +0 -0
- package/dist/figma-y9898rry.png +0 -0
- package/dist/firecrawl-w2t8nehx.png +0 -0
- package/dist/github-av5r5y3e.png +0 -0
- package/dist/gitlab-4pv5vm6b.png +0 -0
- package/dist/gmail-sg6a5v3x.png +0 -0
- package/dist/googlecalendar-nqhh2v7r.png +0 -0
- package/dist/googledrive-6s8xyab7.png +0 -0
- package/dist/grafana-1yfsnwr6.png +0 -0
- package/dist/granola-7j3b0nk2.png +0 -0
- package/dist/hermes-nous-pznd63x9.png +0 -0
- package/dist/hubspot-hghcmc2t.png +0 -0
- package/dist/huggingface-kxzaxj83.png +0 -0
- package/dist/index.html +47 -0
- package/dist/intercom-td763jt8.png +0 -0
- package/dist/linear-v9s3az2d.png +0 -0
- package/dist/monday-jdbs4wwf.png +0 -0
- package/dist/mongodb-emzxvhd5.png +0 -0
- package/dist/neon-zj4qar44.png +0 -0
- package/dist/notion-w034c0b8.png +0 -0
- package/dist/openclaw-a2pyfhpn.svg +22 -0
- package/dist/paper-zbt34fab.png +0 -0
- package/dist/paypal-kwwf7xsc.png +0 -0
- package/dist/perplexity-4y63rxvj.png +0 -0
- package/dist/postgresql-qsspbsr1.png +0 -0
- package/dist/posthog-sphppc4w.png +0 -0
- package/dist/puppeteer-2xjt1a9b.png +0 -0
- package/dist/railway-834de8d2.png +0 -0
- package/dist/redis-spm6w2m1.png +0 -0
- package/dist/salesforce-1mk56v4z.png +0 -0
- package/dist/sentry-hdwpmvek.png +0 -0
- package/dist/shopify-90dadaav.png +0 -0
- package/dist/slack-1c1wj62s.png +0 -0
- package/dist/snowflake-hfpykpgy.png +0 -0
- package/dist/stripe-zrfaqbj3.png +0 -0
- package/dist/supabase-4vg33zf2.png +0 -0
- package/dist/telegram-v6tjyrs7.png +0 -0
- package/dist/twilio-dpyjdwpj.png +0 -0
- package/dist/vercel-7d0ssw28.png +0 -0
- package/dist/zapier-p67qfch0.png +0 -0
- package/lib/attachment-note.ts +48 -0
- package/lib/claude-adapter.ts +219 -29
- package/lib/format.ts +32 -0
- package/lib/types.ts +314 -6
- package/package.json +21 -31
- package/server/CLAUDE.md +3 -0
- package/server/agent.ts +25 -118
- package/server/api.ts +593 -0
- package/server/applets.ts +396 -0
- package/server/build-applet.ts +580 -0
- package/server/cc-session.ts +611 -0
- package/server/cli-colors.ts +17 -0
- package/server/cli-ui.ts +52 -0
- package/server/cli.ts +970 -72
- package/server/control.ts +166 -19
- package/server/debug.ts +10 -0
- package/server/events.ts +24 -0
- package/server/functions-worker.ts +18 -2
- package/server/functions.ts +59 -12
- package/server/icon.ts +13 -0
- package/server/layout.ts +25 -3
- package/server/mcp.ts +125 -0
- package/server/moi-scaffold.ts +85 -0
- package/server/openclaw-session.ts +41 -10
- package/server/openclaw.ts +22 -0
- package/server/preview.ts +70 -0
- package/server/registry.ts +32 -2
- package/server/scratchpad-executor.ts +380 -0
- package/server/scratchpad-relay.ts +45 -0
- package/server/scratchpad.ts +171 -0
- package/server/skill-version.ts +146 -0
- package/server/skills-template.ts +6 -1
- package/server/state.ts +22 -36
- package/server/static.ts +23 -0
- package/server/status.ts +94 -0
- package/server/thread-config.ts +125 -0
- package/server/uploads.ts +0 -0
- package/server/vendor.ts +63 -0
- package/server/views.ts +0 -0
- package/server/web.ts +113 -223
- package/server/widgets.ts +52 -142
- package/server/workspace-config.ts +37 -0
- package/server/workspace-env.ts +407 -0
- package/server/workspace-init.ts +66 -0
- package/workspace/.claude/skills/moi-workspace/DESIGN.md +109 -0
- package/workspace/.claude/skills/moi-workspace/SCRATCHPAD.md +57 -0
- package/workspace/.claude/skills/moi-workspace/SKILL.md +252 -0
- package/workspace/.claude/skills/moi-workspace/VIEW-DESIGN.md +22 -0
- package/client/hooks/useWidget.ts +0 -72
- package/client/hooks/useWidgetList.ts +0 -30
- package/client/lib/ws.ts +0 -129
- package/client/store/chat.tsx +0 -162
- package/server/build-widget.ts +0 -343
- package/workspace/.claude/skills/widgets/DESIGN.md +0 -630
- package/workspace/.claude/skills/widgets/SKILL.md +0 -176
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
// Timeline rail primitives shared by every row in <ToolCallGroup>: the row
|
|
2
|
+
// wrapper that draws the 1px vertical rule + node, the disclosure chevron, the
|
|
3
|
+
// shared header layout, and the node-box markers (icon / MCP logo). Kept free of
|
|
4
|
+
// any dependency on the rows themselves, so both ToolCallGroup and SubagentCard
|
|
5
|
+
// can build on them without a cycle.
|
|
6
|
+
import type { ReactNode } from 'react'
|
|
7
|
+
|
|
8
|
+
import { IconChevronRight, IconLoader2, IconPackage } from '@tabler/icons-react'
|
|
9
|
+
import { motion } from 'motion/react'
|
|
10
|
+
|
|
11
|
+
import { IconMcp } from '@/client/components/IconMcp'
|
|
12
|
+
import { cn } from '@/client/lib/cn'
|
|
13
|
+
|
|
14
|
+
// Where a row sits in the group — drives which rail segments to draw so the rule
|
|
15
|
+
// starts on the first node and ends on the last.
|
|
16
|
+
export type RowPosition = { isFirst: boolean; isLast: boolean }
|
|
17
|
+
|
|
18
|
+
// Header layout shared by every row's clickable button. The `group/row` token
|
|
19
|
+
// lives here (on the button, not the row wrapper) so a nested sub-timeline's
|
|
20
|
+
// chevrons don't all reveal when a parent card is hovered.
|
|
21
|
+
export const HEADER = 'group/row flex w-full items-center gap-2 py-1.5 text-left select-none'
|
|
22
|
+
|
|
23
|
+
// Row wrapper + left timeline rail: one node per row linked by a 1px vertical
|
|
24
|
+
// rule. The node sits at the header's first-line center (`top-[15px]`); the rule
|
|
25
|
+
// above spans 0→node, below spans node→bottom (covering an expanded body down to
|
|
26
|
+
// the next node). Adjacent rows are flush, so segments join. `marker` replaces
|
|
27
|
+
// the dot with a custom node (e.g. an MCP server logo).
|
|
28
|
+
type TimelineRowProps = RowPosition & {
|
|
29
|
+
marker?: ReactNode
|
|
30
|
+
// In-progress dotted row: a small spinner replaces the dot node (ignored when
|
|
31
|
+
// `marker` is set — icon rows keep their logo and spin in the header).
|
|
32
|
+
loading?: boolean
|
|
33
|
+
isError?: boolean
|
|
34
|
+
children: ReactNode
|
|
35
|
+
}
|
|
36
|
+
export function TimelineRow({
|
|
37
|
+
isFirst,
|
|
38
|
+
isLast,
|
|
39
|
+
marker,
|
|
40
|
+
loading = false,
|
|
41
|
+
isError = false,
|
|
42
|
+
children
|
|
43
|
+
}: TimelineRowProps) {
|
|
44
|
+
return (
|
|
45
|
+
<div className="relative flex gap-2.5">
|
|
46
|
+
{/* Odd rail width (13px) puts the centerline on a half-pixel, so a crisp
|
|
47
|
+
1px rule lands on a single pixel column instead of straddling two. */}
|
|
48
|
+
<div className="relative w-[13px] shrink-0">
|
|
49
|
+
{!isFirst && (
|
|
50
|
+
<span className="absolute top-0 left-1/2 h-4 w-px -translate-x-1/2 bg-border" />
|
|
51
|
+
)}
|
|
52
|
+
{!isLast && (
|
|
53
|
+
<span className="absolute top-[15px] bottom-0 left-1/2 w-px -translate-x-1/2 bg-border" />
|
|
54
|
+
)}
|
|
55
|
+
{marker ? (
|
|
56
|
+
<span className="absolute top-[15px] left-1/2 z-10 -translate-x-1/2 -translate-y-1/2">
|
|
57
|
+
{marker}
|
|
58
|
+
</span>
|
|
59
|
+
) : loading ? (
|
|
60
|
+
// A spinner node stands in for the dot; bg-background carves the rule.
|
|
61
|
+
<span className="absolute top-[15px] left-1/2 z-10 flex -translate-x-1/2 -translate-y-1/2 rounded-full bg-background p-0.5">
|
|
62
|
+
<IconLoader2 size={10} stroke={2.75} className="animate-spin text-ring" />
|
|
63
|
+
</span>
|
|
64
|
+
) : (
|
|
65
|
+
// Background-colored ring carves a gap in the rule around the dot.
|
|
66
|
+
<span
|
|
67
|
+
className={cn(
|
|
68
|
+
'absolute top-[15px] left-1/2 z-10 size-[5px] -translate-x-1/2 -translate-y-1/2 rounded-full ring-3 ring-background',
|
|
69
|
+
isError ? 'bg-red-400' : 'bg-border'
|
|
70
|
+
)}
|
|
71
|
+
/>
|
|
72
|
+
)}
|
|
73
|
+
</div>
|
|
74
|
+
{children}
|
|
75
|
+
</div>
|
|
76
|
+
)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Disclosure chevron — hidden until its own header (group/row) is hovered or the
|
|
80
|
+
// row is open; rotates with a spring (same feel as the meta-ficus accordion). The
|
|
81
|
+
// group lives on the header button, not the whole row, so a nested sub-timeline's
|
|
82
|
+
// chevrons don't all reveal when the parent card is hovered.
|
|
83
|
+
export function RowChevron({ open }: { open: boolean }) {
|
|
84
|
+
return (
|
|
85
|
+
<motion.span
|
|
86
|
+
animate={{ rotate: open ? 90 : 0 }}
|
|
87
|
+
transition={{ type: 'spring', duration: 0.2, bounce: 0.1 }}
|
|
88
|
+
className={cn(
|
|
89
|
+
'flex shrink-0',
|
|
90
|
+
open ? 'opacity-100' : 'opacity-0 group-hover/row:opacity-100'
|
|
91
|
+
)}
|
|
92
|
+
>
|
|
93
|
+
<IconChevronRight size={12} stroke={2.2} />
|
|
94
|
+
</motion.span>
|
|
95
|
+
)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// A rounded node box used as a timeline marker (size-4 by default). The bg-colored
|
|
99
|
+
// ring carves it out of the rule, matching the dot rows. Shared by the MCP logo,
|
|
100
|
+
// the skill node, and the (larger) subagent node; pass `className` to resize.
|
|
101
|
+
export function NodeBox({ children, className }: { children: ReactNode; className?: string }) {
|
|
102
|
+
return (
|
|
103
|
+
<span
|
|
104
|
+
className={cn(
|
|
105
|
+
'flex size-4 items-center justify-center overflow-hidden rounded-[4px] bg-muted ring-2 ring-background',
|
|
106
|
+
className
|
|
107
|
+
)}
|
|
108
|
+
>
|
|
109
|
+
{children}
|
|
110
|
+
</span>
|
|
111
|
+
)
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// A Tabler icon centered in the node box (e.g. the skill package node, or the
|
|
115
|
+
// MCP fallback plug). size/stroke default to the plug's values; the skill node
|
|
116
|
+
// overrides them.
|
|
117
|
+
export function IconMarker({
|
|
118
|
+
icon: Icon,
|
|
119
|
+
size = 12,
|
|
120
|
+
stroke = 1.5
|
|
121
|
+
}: {
|
|
122
|
+
icon: typeof IconPackage
|
|
123
|
+
size?: number
|
|
124
|
+
stroke?: number
|
|
125
|
+
}) {
|
|
126
|
+
return (
|
|
127
|
+
<NodeBox>
|
|
128
|
+
<Icon size={size} stroke={stroke} className="text-muted-foreground" />
|
|
129
|
+
</NodeBox>
|
|
130
|
+
)
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// The MCP server logo, used as the timeline node. Falls back to the generic MCP
|
|
134
|
+
// glyph (same as the workspace header) when the server has no known logo.
|
|
135
|
+
export function McpLogo({ src }: { src?: string }) {
|
|
136
|
+
if (!src)
|
|
137
|
+
return (
|
|
138
|
+
<NodeBox>
|
|
139
|
+
<IconMcp className="size-3 text-muted-foreground" />
|
|
140
|
+
</NodeBox>
|
|
141
|
+
)
|
|
142
|
+
return (
|
|
143
|
+
<NodeBox>
|
|
144
|
+
<img src={src} alt="" className="size-full object-cover" />
|
|
145
|
+
</NodeBox>
|
|
146
|
+
)
|
|
147
|
+
}
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
// Renders a mixed timeline of agent parts (reasoning + tool calls). Standalone —
|
|
2
|
+
// lifted from the chat transcript (client/components/TurnView.tsx) so we can
|
|
3
|
+
// iterate on the design in isolation (see /playground/tool-calls). Takes
|
|
4
|
+
// `Part[]` directly and `cwd` as a prop, so it renders with no workspace
|
|
5
|
+
// provider mounted.
|
|
6
|
+
//
|
|
7
|
+
// Layout: each row is a two-column flex — a left timeline rail (one node per row
|
|
8
|
+
// linked by a 1px rule) and a collapsible header/body. The rail primitives live
|
|
9
|
+
// in ./TimelineRow; the subagent card in ./SubagentCard; the body animates open
|
|
10
|
+
// (./Collapse, height spring) and renders via ./ToolOutput (syntax-highlighted
|
|
11
|
+
// code/json when detected, plain text otherwise). Formatting + detection live in
|
|
12
|
+
// ./format and ./detect.
|
|
13
|
+
import { type ReactNode, useState } from 'react'
|
|
14
|
+
|
|
15
|
+
import { IconLoader2, IconPackage } from '@tabler/icons-react'
|
|
16
|
+
|
|
17
|
+
import { cn } from '@/client/lib/cn'
|
|
18
|
+
import { formatMcpServerName, getMcpIcon } from '@/client/lib/mcp-icons'
|
|
19
|
+
import type { Part, ToolCall } from '@/lib/types'
|
|
20
|
+
|
|
21
|
+
import { Collapse } from './Collapse'
|
|
22
|
+
import { ReadImagePreview, readImageRelPath } from './ReadImagePreview'
|
|
23
|
+
import { SubagentCard } from './SubagentCard'
|
|
24
|
+
import {
|
|
25
|
+
HEADER,
|
|
26
|
+
IconMarker,
|
|
27
|
+
McpLogo,
|
|
28
|
+
RowChevron,
|
|
29
|
+
type RowPosition,
|
|
30
|
+
TimelineRow
|
|
31
|
+
} from './TimelineRow'
|
|
32
|
+
import { ToolOutput } from './ToolOutput'
|
|
33
|
+
import {
|
|
34
|
+
formatInputBrief,
|
|
35
|
+
formatMcpTool,
|
|
36
|
+
getToolDisplayName,
|
|
37
|
+
parseMcporterCall,
|
|
38
|
+
parseNativeMcp
|
|
39
|
+
} from './format'
|
|
40
|
+
|
|
41
|
+
type ToolCallGroupProps = {
|
|
42
|
+
// A mixed timeline of parts; reasoning + tool-call render, others are skipped.
|
|
43
|
+
parts: Part[]
|
|
44
|
+
// Working directory used to shorten absolute paths in tool briefs. Pass the
|
|
45
|
+
// workspace cwd to match the live chat; null leaves paths absolute.
|
|
46
|
+
cwd?: string | null
|
|
47
|
+
// Whether the agent is still working. Drives the live last row: a trailing
|
|
48
|
+
// reasoning shows "Thinking" (vs "Thought"); a trailing running tool spins.
|
|
49
|
+
processing?: boolean
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function ToolCallGroup({ parts, cwd = null, processing = false }: ToolCallGroupProps) {
|
|
53
|
+
const rows = parts.filter(p => p.type === 'reasoning' || p.type === 'tool-call')
|
|
54
|
+
return (
|
|
55
|
+
<div className="flex flex-col">
|
|
56
|
+
{rows.map((part, i) => {
|
|
57
|
+
const isLast = i === rows.length - 1
|
|
58
|
+
const pos = { isFirst: i === 0, isLast }
|
|
59
|
+
if (part.type === 'reasoning')
|
|
60
|
+
// A reasoning block reads as live "Thinking" only while it's the last
|
|
61
|
+
// row of an active stream; anything after it makes it a done "Thought".
|
|
62
|
+
return (
|
|
63
|
+
<ReasoningRow key={i} text={part.text} inProgress={processing && isLast} {...pos} />
|
|
64
|
+
)
|
|
65
|
+
return <ToolCallCard key={part.call.toolCallId || i} call={part.call} cwd={cwd} {...pos} />
|
|
66
|
+
})}
|
|
67
|
+
</div>
|
|
68
|
+
)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
type ToolRowProps = RowPosition & {
|
|
72
|
+
call: ToolCall
|
|
73
|
+
leading?: ReactNode
|
|
74
|
+
marker?: ReactNode
|
|
75
|
+
name: string
|
|
76
|
+
brief: string
|
|
77
|
+
// Extra expanded content rendered above the output (e.g. the image a Read
|
|
78
|
+
// tool call opened).
|
|
79
|
+
preview?: ReactNode
|
|
80
|
+
}
|
|
81
|
+
function ToolRow({ isFirst, isLast, call, leading, marker, name, brief, preview }: ToolRowProps) {
|
|
82
|
+
const [open, setOpen] = useState(false)
|
|
83
|
+
const isError = call.state === 'error'
|
|
84
|
+
const isRunning = call.state === 'running' || call.state === 'pending'
|
|
85
|
+
const output = isError
|
|
86
|
+
? (call.errorText ?? '')
|
|
87
|
+
: typeof call.output === 'string'
|
|
88
|
+
? call.output
|
|
89
|
+
: ''
|
|
90
|
+
const hasBody = !!(output || isError || preview)
|
|
91
|
+
const title = brief ? `${name}: ${brief}` : name
|
|
92
|
+
|
|
93
|
+
return (
|
|
94
|
+
<TimelineRow
|
|
95
|
+
isFirst={isFirst}
|
|
96
|
+
isLast={isLast}
|
|
97
|
+
marker={marker}
|
|
98
|
+
loading={isRunning}
|
|
99
|
+
isError={isError}
|
|
100
|
+
>
|
|
101
|
+
<div className="min-w-0 flex-1">
|
|
102
|
+
<button
|
|
103
|
+
type="button"
|
|
104
|
+
title={title}
|
|
105
|
+
onClick={() => hasBody && setOpen(o => !o)}
|
|
106
|
+
className={cn(HEADER, hasBody ? 'cursor-pointer' : 'cursor-default')}
|
|
107
|
+
>
|
|
108
|
+
{leading}
|
|
109
|
+
<span className="shrink-0 text-xs font-medium whitespace-nowrap">{name}</span>
|
|
110
|
+
{brief && (
|
|
111
|
+
<span className="min-w-0 self-baseline truncate text-[12px] text-ring">{brief}</span>
|
|
112
|
+
)}
|
|
113
|
+
{/* Dotted rows spin at the node instead; only icon (MCP) rows, whose
|
|
114
|
+
node can't spin, keep a header spinner. */}
|
|
115
|
+
{isRunning && marker && (
|
|
116
|
+
<IconLoader2 size={12} stroke={1.5} className="shrink-0 animate-spin text-ring" />
|
|
117
|
+
)}
|
|
118
|
+
{hasBody && <RowChevron open={open} />}
|
|
119
|
+
</button>
|
|
120
|
+
{hasBody && (
|
|
121
|
+
<Collapse open={open}>
|
|
122
|
+
<div className="mt-1 mb-1 flex flex-col gap-1.5">
|
|
123
|
+
{preview}
|
|
124
|
+
{(output || isError) && <ToolOutput call={call} output={output} isError={isError} />}
|
|
125
|
+
</div>
|
|
126
|
+
</Collapse>
|
|
127
|
+
)}
|
|
128
|
+
</div>
|
|
129
|
+
</TimelineRow>
|
|
130
|
+
)
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// Reasoning row — collapsible thought text as italic prose. Labelled "Thinking"
|
|
134
|
+
// while live (spinner node), "Thought" once done (dot node). No leading glyph.
|
|
135
|
+
// While live (`inProgress` — the last row of an active stream) it stays expanded
|
|
136
|
+
// so the streaming thought is visible; it collapses on its own the moment
|
|
137
|
+
// anything follows it (a text/tool row makes it no longer the last row, so
|
|
138
|
+
// `inProgress` goes false and it reverts to the user's collapsed default).
|
|
139
|
+
type ReasoningRowProps = RowPosition & { text: string; inProgress?: boolean }
|
|
140
|
+
function ReasoningRow({ isFirst, isLast, text, inProgress = false }: ReasoningRowProps) {
|
|
141
|
+
const [open, setOpen] = useState(false)
|
|
142
|
+
const label = inProgress ? 'Thinking' : 'Thought'
|
|
143
|
+
const expanded = inProgress || open
|
|
144
|
+
return (
|
|
145
|
+
<TimelineRow isFirst={isFirst} isLast={isLast} loading={inProgress}>
|
|
146
|
+
<div className="min-w-0 flex-1">
|
|
147
|
+
<button
|
|
148
|
+
type="button"
|
|
149
|
+
title={`${label}: ${text}`}
|
|
150
|
+
onClick={() => setOpen(o => !o)}
|
|
151
|
+
className={cn(HEADER, 'cursor-pointer')}
|
|
152
|
+
>
|
|
153
|
+
<span className="text-xs font-medium text-muted-foreground">{label}</span>
|
|
154
|
+
<RowChevron open={expanded} />
|
|
155
|
+
</button>
|
|
156
|
+
<Collapse open={expanded}>
|
|
157
|
+
<div className="mt-1 mb-1 pr-2 text-xs leading-relaxed whitespace-pre-wrap text-muted-foreground">
|
|
158
|
+
{text}
|
|
159
|
+
</div>
|
|
160
|
+
</Collapse>
|
|
161
|
+
</div>
|
|
162
|
+
</TimelineRow>
|
|
163
|
+
)
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// Dispatch a tool call to the right row chrome: a subagent card for an Agent
|
|
167
|
+
// call, a "Loading Skill" row for a Skill call, the server-branded card for an
|
|
168
|
+
// MCP shape (`mcporter call …` Bash or a native `mcp__server__tool` name), else a
|
|
169
|
+
// plain tool row.
|
|
170
|
+
type ToolCallCardProps = RowPosition & { call: ToolCall; cwd: string | null }
|
|
171
|
+
function ToolCallCard({ call, cwd, isFirst, isLast }: ToolCallCardProps) {
|
|
172
|
+
if (call.caller === 'subagent') {
|
|
173
|
+
return <SubagentCard call={call} cwd={cwd} isFirst={isFirst} isLast={isLast} />
|
|
174
|
+
}
|
|
175
|
+
if (call.name === 'Skill' && call.skill) {
|
|
176
|
+
// On success, swap the timeline dot for a package icon node (same box as the
|
|
177
|
+
// MCP logo). Running keeps the spinner node; an error keeps the red dot.
|
|
178
|
+
const succeeded = call.state === 'success'
|
|
179
|
+
return (
|
|
180
|
+
<ToolRow
|
|
181
|
+
isFirst={isFirst}
|
|
182
|
+
isLast={isLast}
|
|
183
|
+
call={call}
|
|
184
|
+
marker={succeeded ? <IconMarker icon={IconPackage} size={14} stroke={1.75} /> : undefined}
|
|
185
|
+
name="Loading Skill"
|
|
186
|
+
brief={call.skill.skillName}
|
|
187
|
+
/>
|
|
188
|
+
)
|
|
189
|
+
}
|
|
190
|
+
const mcp = parseMcporterCall(call) ?? parseNativeMcp(call)
|
|
191
|
+
if (mcp) {
|
|
192
|
+
const fn = formatMcpTool(mcp.server, mcp.tool)
|
|
193
|
+
return (
|
|
194
|
+
<ToolRow
|
|
195
|
+
isFirst={isFirst}
|
|
196
|
+
isLast={isLast}
|
|
197
|
+
call={call}
|
|
198
|
+
marker={<McpLogo src={getMcpIcon(mcp.server)} />}
|
|
199
|
+
name={formatMcpServerName(mcp.server)}
|
|
200
|
+
brief={mcp.rest ? `${fn} ${mcp.rest}` : fn}
|
|
201
|
+
/>
|
|
202
|
+
)
|
|
203
|
+
}
|
|
204
|
+
// A Read of a workspace image gets the actual picture in its expanded body
|
|
205
|
+
// (skipped while errored — the file likely wasn't readable).
|
|
206
|
+
const imageRelPath = call.state === 'error' ? null : readImageRelPath(call, cwd)
|
|
207
|
+
return (
|
|
208
|
+
<ToolRow
|
|
209
|
+
isFirst={isFirst}
|
|
210
|
+
isLast={isLast}
|
|
211
|
+
call={call}
|
|
212
|
+
leading={<CallerBadge call={call} />}
|
|
213
|
+
name={getToolDisplayName(call)}
|
|
214
|
+
brief={formatInputBrief(call, cwd)}
|
|
215
|
+
preview={imageRelPath ? <ReadImagePreview relPath={imageRelPath} /> : undefined}
|
|
216
|
+
/>
|
|
217
|
+
)
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
function CallerBadge({ call }: { call: ToolCall }) {
|
|
221
|
+
if (call.caller !== 'mcp' && call.caller !== 'server-tool') return null
|
|
222
|
+
const label =
|
|
223
|
+
call.caller === 'mcp'
|
|
224
|
+
? `mcp${call.mcpServer ? `:${call.mcpServer.slice(0, 8)}` : ''}`
|
|
225
|
+
: 'server'
|
|
226
|
+
return (
|
|
227
|
+
<span className="shrink-0 rounded border border-border px-1 text-[9px] text-muted-foreground uppercase">
|
|
228
|
+
{label}
|
|
229
|
+
</span>
|
|
230
|
+
)
|
|
231
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { useEffect, useMemo, useState } from 'react'
|
|
2
|
+
|
|
3
|
+
import { IconCheck, IconCopy } from '@tabler/icons-react'
|
|
4
|
+
|
|
5
|
+
import { cn } from '@/client/lib/cn'
|
|
6
|
+
import type { ToolCall } from '@/lib/types'
|
|
7
|
+
|
|
8
|
+
import { CodeBlock } from './CodeBlock'
|
|
9
|
+
import { detectOutput } from './detect'
|
|
10
|
+
import { formatBytes } from './format'
|
|
11
|
+
|
|
12
|
+
type ToolOutputProps = { call: ToolCall; output: string; isError: boolean }
|
|
13
|
+
|
|
14
|
+
const PRE = 'max-h-[280px] overflow-auto px-3 py-2.5 font-mono text-xs leading-relaxed'
|
|
15
|
+
|
|
16
|
+
// Renders a tool result, choosing a view from `detectOutput`: a syntax-
|
|
17
|
+
// highlighted code/json block (with a raw ↔ formatted switch), or plain text.
|
|
18
|
+
export function ToolOutput({ call, output, isError }: ToolOutputProps) {
|
|
19
|
+
const [raw, setRaw] = useState(false)
|
|
20
|
+
// Detection runs JSON.parse/stringify — memoize so toggling raw/json (or any
|
|
21
|
+
// re-render) doesn't re-detect. Errors always render as plain red text.
|
|
22
|
+
const view = useMemo(
|
|
23
|
+
() => (isError ? ({ kind: 'plain' } as const) : detectOutput(call, output)),
|
|
24
|
+
[call, output, isError]
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
if (view.kind === 'plain') {
|
|
28
|
+
return (
|
|
29
|
+
<div
|
|
30
|
+
className={cn(
|
|
31
|
+
'rounded-md border',
|
|
32
|
+
isError ? 'border-red-200 bg-red-50' : 'border-border bg-muted'
|
|
33
|
+
)}
|
|
34
|
+
>
|
|
35
|
+
<pre
|
|
36
|
+
className={cn(
|
|
37
|
+
PRE,
|
|
38
|
+
'break-all whitespace-pre-wrap',
|
|
39
|
+
isError ? 'text-red-800' : 'text-muted-foreground'
|
|
40
|
+
)}
|
|
41
|
+
>
|
|
42
|
+
{output || '(empty)'}
|
|
43
|
+
</pre>
|
|
44
|
+
</div>
|
|
45
|
+
)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<div className="overflow-hidden rounded-md border border-border bg-muted">
|
|
50
|
+
{/* Size is always the raw output; copy grabs whatever's currently shown. */}
|
|
51
|
+
<Header
|
|
52
|
+
raw={raw}
|
|
53
|
+
onRaw={setRaw}
|
|
54
|
+
label={view.label}
|
|
55
|
+
size={formatBytes(output)}
|
|
56
|
+
copyText={raw ? output : view.code}
|
|
57
|
+
/>
|
|
58
|
+
{raw ? (
|
|
59
|
+
<pre className={cn(PRE, 'break-all whitespace-pre-wrap text-muted-foreground')}>
|
|
60
|
+
{output || '(empty)'}
|
|
61
|
+
</pre>
|
|
62
|
+
) : (
|
|
63
|
+
<CodeBlock code={view.code} className={cn(PRE, 'text-muted-foreground')} />
|
|
64
|
+
)}
|
|
65
|
+
</div>
|
|
66
|
+
)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
type HeaderProps = {
|
|
70
|
+
raw: boolean
|
|
71
|
+
onRaw: (raw: boolean) => void
|
|
72
|
+
label: string
|
|
73
|
+
size: string
|
|
74
|
+
copyText: string
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Output toolbar: a left outline switch (<label> | raw), and on the right the
|
|
78
|
+
// raw byte size + a copy button.
|
|
79
|
+
function Header({ raw, onRaw, label, size, copyText }: HeaderProps) {
|
|
80
|
+
const options: [boolean, string][] = [
|
|
81
|
+
[false, label],
|
|
82
|
+
[true, 'raw']
|
|
83
|
+
]
|
|
84
|
+
return (
|
|
85
|
+
<div className="flex items-center gap-1 border-b border-border px-2 py-1">
|
|
86
|
+
{options.map(([value, text]) => (
|
|
87
|
+
<button
|
|
88
|
+
key={text}
|
|
89
|
+
type="button"
|
|
90
|
+
onClick={() => onRaw(value)}
|
|
91
|
+
className={cn(
|
|
92
|
+
'rounded-md px-1.5 py-0.5 text-[10px] font-medium tracking-wide uppercase transition-colors',
|
|
93
|
+
raw === value
|
|
94
|
+
? 'bg-background text-foreground shadow-[inset_0_0_0_1px_var(--border)]'
|
|
95
|
+
: 'text-muted-foreground hover:text-foreground'
|
|
96
|
+
)}
|
|
97
|
+
>
|
|
98
|
+
{text}
|
|
99
|
+
</button>
|
|
100
|
+
))}
|
|
101
|
+
<div className="flex-1" />
|
|
102
|
+
<span className="text-[10px] font-medium text-muted-foreground tabular-nums">{size}</span>
|
|
103
|
+
<CopyButton text={copyText} />
|
|
104
|
+
</div>
|
|
105
|
+
)
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function CopyButton({ text }: { text: string }) {
|
|
109
|
+
const [copied, setCopied] = useState(false)
|
|
110
|
+
|
|
111
|
+
// Revert the check after a moment; cleanup cancels it if the row collapses.
|
|
112
|
+
useEffect(() => {
|
|
113
|
+
if (!copied) return
|
|
114
|
+
const t = setTimeout(() => setCopied(false), 1500)
|
|
115
|
+
return () => clearTimeout(t)
|
|
116
|
+
}, [copied])
|
|
117
|
+
|
|
118
|
+
const copy = () => {
|
|
119
|
+
navigator.clipboard
|
|
120
|
+
?.writeText(text)
|
|
121
|
+
.then(() => setCopied(true))
|
|
122
|
+
.catch(() => {})
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return (
|
|
126
|
+
<button
|
|
127
|
+
type="button"
|
|
128
|
+
onClick={copy}
|
|
129
|
+
aria-label={copied ? 'Copied' : 'Copy'}
|
|
130
|
+
className="flex size-5 items-center justify-center rounded text-muted-foreground transition-colors hover:text-foreground"
|
|
131
|
+
>
|
|
132
|
+
{copied ? (
|
|
133
|
+
<IconCheck size={13} stroke={1.5} className="text-foreground" />
|
|
134
|
+
) : (
|
|
135
|
+
<IconCopy size={13} stroke={1.5} />
|
|
136
|
+
)}
|
|
137
|
+
</button>
|
|
138
|
+
)
|
|
139
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
// Detection heuristics for how to render a tool result. Pure, no React. The
|
|
2
|
+
// highlighter (sugar-high) is language-agnostic, so `label` is display-only.
|
|
3
|
+
import type { ToolCall } from '@/lib/types'
|
|
4
|
+
|
|
5
|
+
// File extension → a short language label for the code-block header.
|
|
6
|
+
const EXT_LANG: Record<string, string> = {
|
|
7
|
+
ts: 'ts',
|
|
8
|
+
tsx: 'tsx',
|
|
9
|
+
js: 'js',
|
|
10
|
+
jsx: 'jsx',
|
|
11
|
+
mjs: 'js',
|
|
12
|
+
cjs: 'js',
|
|
13
|
+
json: 'json',
|
|
14
|
+
md: 'md',
|
|
15
|
+
mdx: 'mdx',
|
|
16
|
+
css: 'css',
|
|
17
|
+
scss: 'scss',
|
|
18
|
+
html: 'html',
|
|
19
|
+
py: 'py',
|
|
20
|
+
rb: 'rb',
|
|
21
|
+
go: 'go',
|
|
22
|
+
rs: 'rs',
|
|
23
|
+
java: 'java',
|
|
24
|
+
c: 'c',
|
|
25
|
+
h: 'c',
|
|
26
|
+
cpp: 'cpp',
|
|
27
|
+
sh: 'sh',
|
|
28
|
+
bash: 'sh',
|
|
29
|
+
yml: 'yaml',
|
|
30
|
+
yaml: 'yaml',
|
|
31
|
+
toml: 'toml',
|
|
32
|
+
sql: 'sql',
|
|
33
|
+
php: 'php',
|
|
34
|
+
swift: 'swift',
|
|
35
|
+
kt: 'kt'
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function langForPath(path: string): string | null {
|
|
39
|
+
const base = path.split(/[\\/]/).pop() ?? ''
|
|
40
|
+
const i = base.lastIndexOf('.')
|
|
41
|
+
const ext = i > 0 ? base.slice(i + 1).toLowerCase() : ''
|
|
42
|
+
return EXT_LANG[ext] ?? null
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Cheap JSON guard before JSON.parse: trimmed text starts with `{`/`[` and round
|
|
46
|
+
// -trips. Returns the pretty-printed form, or null (skips prose without parsing).
|
|
47
|
+
function tryJson(text: string): string | null {
|
|
48
|
+
const t = text.trim()
|
|
49
|
+
if (t.length < 2 || !(t.startsWith('{') || t.startsWith('['))) return null
|
|
50
|
+
try {
|
|
51
|
+
return JSON.stringify(JSON.parse(t), null, 2)
|
|
52
|
+
} catch {
|
|
53
|
+
return null
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Strip Claude's `Read` cat -n gutter (`␣␣␣12\t…`) so the highlighter sees clean
|
|
58
|
+
// source. No-op when no line matches the gutter shape.
|
|
59
|
+
function stripReadGutter(text: string): string {
|
|
60
|
+
const lines = text.split('\n')
|
|
61
|
+
if (!lines.some(l => /^\s*\d+\t/.test(l))) return text
|
|
62
|
+
return lines.map(l => l.replace(/^\s*\d+\t/, '')).join('\n')
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// 'plain' → render the raw output as-is (no switch). 'highlight' → render a
|
|
66
|
+
// raw ↔ <label> switch over a syntax-highlighted `code` block.
|
|
67
|
+
export type OutputView = { kind: 'plain' } | { kind: 'highlight'; code: string; label: string }
|
|
68
|
+
|
|
69
|
+
// Decide how to render a tool result. File read/write with a code extension wins
|
|
70
|
+
// (reads carry content in the output, writes in the input); otherwise a
|
|
71
|
+
// JSON-looking output; otherwise plain text.
|
|
72
|
+
export function detectOutput(call: ToolCall, output: string): OutputView {
|
|
73
|
+
const input = (call.input as Record<string, unknown>) ?? {}
|
|
74
|
+
const path =
|
|
75
|
+
typeof input.file_path === 'string'
|
|
76
|
+
? input.file_path
|
|
77
|
+
: typeof input.path === 'string'
|
|
78
|
+
? input.path
|
|
79
|
+
: ''
|
|
80
|
+
const lang = path ? langForPath(path) : null
|
|
81
|
+
|
|
82
|
+
const isRead = call.name === 'Read' || call.name === 'read'
|
|
83
|
+
const isWrite = call.name === 'Write' || call.name === 'write'
|
|
84
|
+
if (lang && isRead && output)
|
|
85
|
+
return { kind: 'highlight', code: stripReadGutter(output), label: lang }
|
|
86
|
+
if (lang && isWrite && typeof input.content === 'string' && input.content)
|
|
87
|
+
return { kind: 'highlight', code: input.content, label: lang }
|
|
88
|
+
|
|
89
|
+
const pretty = tryJson(output)
|
|
90
|
+
if (pretty) return { kind: 'highlight', code: pretty, label: 'json' }
|
|
91
|
+
|
|
92
|
+
return { kind: 'plain' }
|
|
93
|
+
}
|