moi-computer 0.0.3 → 0.1.1
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 +2 -2
- 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/ChatInput.tsx +194 -13
- package/client/components/ChatPanel.tsx +116 -47
- package/client/components/ChatPopup.tsx +1 -1
- package/client/components/IconMcp.tsx +21 -0
- 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 +111 -531
- package/client/components/WidgetShell.tsx +1 -1
- package/client/components/WorkspacesPage.tsx +12 -4
- package/client/components/layout/SidebarLayout.tsx +18 -9
- 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/dialog.tsx +58 -0
- package/client/components/ui/hover-card.tsx +44 -0
- package/client/components/ui/switch.tsx +23 -0
- package/client/components/ui/tooltip.tsx +54 -0
- package/client/externalize-react.ts +6 -0
- 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 +48 -2
- package/client/index.html +9 -5
- 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/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/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/dropbox-4m5s9mgr.png +0 -0
- package/dist/elevenlabs-2nzzej1t.png +0 -0
- package/dist/exa-qqj3vr0x.png +0 -0
- package/dist/firecrawl-w2t8nehx.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/huggingface-kxzaxj83.png +0 -0
- package/dist/index.html +10 -6
- package/dist/intercom-td763jt8.png +0 -0
- package/dist/monday-jdbs4wwf.png +0 -0
- package/dist/mongodb-emzxvhd5.png +0 -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/shopify-90dadaav.png +0 -0
- package/dist/snowflake-hfpykpgy.png +0 -0
- package/dist/telegram-v6tjyrs7.png +0 -0
- package/dist/twilio-dpyjdwpj.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 +11 -5
- package/server/CLAUDE.md +4 -1
- 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 +965 -73
- package/server/constants.ts +1 -1
- 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 +108 -253
- 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/dist/chunk-4615fa69.js +0 -67
- package/dist/chunk-582xmy05.css +0 -1
- 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,315 @@
|
|
|
1
|
+
// Test fixtures for <ToolCallGroup>. Real tool calls captured from the live API
|
|
2
|
+
// events stream of the "spoiled" workspace's Notion thread (session 3cc7132d…),
|
|
3
|
+
// fetched via GET /api/workspaces/:id/sessions/:sid/events.
|
|
4
|
+
//
|
|
5
|
+
// Tool outputs are VERBATIM from that stream — not truncated here. Note the
|
|
6
|
+
// adapter (lib/claude-adapter.ts `blockOutputText`) caps each result at 4000
|
|
7
|
+
// chars at ingest, so a long result (e.g. notionSearch) ends exactly where the
|
|
8
|
+
// stream ends. Two exceptions: `toolSearch` (output reconstructed from the raw
|
|
9
|
+
// JSONL — see below) and `readFile` (synthesized — see below).
|
|
10
|
+
//
|
|
11
|
+
// `FIXTURE_CWD` is that workspace's working directory — pass it to the group so
|
|
12
|
+
// file paths render shortened (relative), exactly like the live chat.
|
|
13
|
+
//
|
|
14
|
+
// The lists are `Part[]` (reasoning + tool-call), so a run reads as a mixed
|
|
15
|
+
// timeline. The `thinking` and `githubCall` items come from a different thread
|
|
16
|
+
// ("lilmd-demo", session c3d7caba) — see their definitions below.
|
|
17
|
+
import type { Part, ToolCall } from '@/lib/types'
|
|
18
|
+
|
|
19
|
+
export const FIXTURE_CWD = '/Users/molefrog/git/spoiled'
|
|
20
|
+
|
|
21
|
+
// `select:`-style tool discovery. The API stream shows this empty because the
|
|
22
|
+
// adapter's `blockOutputText()` keeps only `text` blocks and a ToolSearch result
|
|
23
|
+
// is all `tool_reference` blocks. The `output` below is reconstructed from the
|
|
24
|
+
// raw session JSONL — the names of the tools this call loaded into context, one
|
|
25
|
+
// per line (the data the adapter currently drops; a real ToolSearch card would
|
|
26
|
+
// render these).
|
|
27
|
+
const toolSearch: ToolCall = {
|
|
28
|
+
toolCallId: 'toolu_01GoGuLKFHZKsukHfGymeaKz',
|
|
29
|
+
name: 'ToolSearch',
|
|
30
|
+
caller: 'model',
|
|
31
|
+
provider: 'claude-code',
|
|
32
|
+
state: 'success',
|
|
33
|
+
input: {
|
|
34
|
+
query:
|
|
35
|
+
'select:mcp__notion__notion-search,mcp__notion__notion-get-teams,mcp__notion__notion-get-users',
|
|
36
|
+
max_results: 3
|
|
37
|
+
},
|
|
38
|
+
output: 'mcp__notion__notion-search\nmcp__notion__notion-get-teams\nmcp__notion__notion-get-users'
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Native MCP call: server is encoded in the name (`mcp__notion__notion-search`),
|
|
42
|
+
// `caller` is still `model`, and `mcpServer` is absent. The current chat renders
|
|
43
|
+
// these via the generic card (the MCP card only matches `mcporter call …` Bash).
|
|
44
|
+
const notionSearch: ToolCall = {
|
|
45
|
+
toolCallId: 'toolu_01PQt8FuJScNcAqqNscG35nd',
|
|
46
|
+
name: 'mcp__notion__notion-search',
|
|
47
|
+
caller: 'model',
|
|
48
|
+
provider: 'claude-code',
|
|
49
|
+
state: 'success',
|
|
50
|
+
input: {
|
|
51
|
+
query: 'project notes docs overview',
|
|
52
|
+
query_type: 'internal',
|
|
53
|
+
page_size: 25
|
|
54
|
+
},
|
|
55
|
+
output:
|
|
56
|
+
'{"results":[{"id":"49ec4ef2-0d62-4511-9dc9-5b7f38409a22","title":"Lecture Notes","url":"https://app.notion.com/p/49ec4ef20d6245119dc95b7f38409a22?pvs=1","type":"page","highlight":"Lecture Notes","timestamp":"2024-10-17T13:51:00.000Z"},{"id":"9f5d18aa-6741-4993-88bc-5adf2dabb8da","title":"To-Do","url":"https://app.notion.com/p/9f5d18aa6741499388bc5adf2dabb8da?pvs=1","type":"page","highlight":"https://docs.mcp-use.com/typescript/server/ui-widgets docs.mcp-use.com/typescript/server/ui-widgets","timestamp":"2026-06-15T13:14:00.000Z"},{"id":"211536fd-e65b-433f-92bf-aa95efa91f35","title":"Plans & Notes","url":"https://app.notion.com/p/211536fde65b433f92bfaa95efa91f35?pvs=1","type":"database","highlight":"Plans & Notes","timestamp":"2024-02-06T10:02:00.000Z"},{"id":"29d78a44-b678-8035-b58e-d33e3ce86f5e","title":"RAG & Agents Notes","url":"https://app.notion.com/p/29d78a44b6788035b58ed33e3ce86f5e?pvs=1","type":"page","highlight":"speculative RAG research.google/blog/speculative-rag-enhancing-retrieval-augmented-generation-through-drafting/ — generate N drafts in parallel (multiple perspective of the doc)","timestamp":"2025-11-03T08:07:00.000Z"},{"id":"31878a44-b678-80df-ade3-dd8cec63de64","title":"CRM","url":"https://app.notion.com/p/31878a44b67880dfade3dd8cec63de64?pvs=1","type":"database","highlight":"CRM","timestamp":"2026-06-09T08:00:00.000Z"},{"id":"f9f78a44-b678-823e-9795-01de5d5f6734","title":"AI meeting notes","url":"https://app.notion.com/p/f9f78a44b678823e979501de5d5f6734?pvs=1","type":"database","highlight":"AI meeting notes","timestamp":"2025-11-06T15:22:00.000Z"},{"id":"31a78a44-b678-801d-948f-c47118e21516","title":"illustrations","url":"https://app.notion.com/p/31a78a44b678801d948fc47118e21516?pvs=1","type":"page","highlight":"illustrations","timestamp":"2026-06-09T18:01:00.000Z"},{"id":"564db5b4-8d50-4938-8808-716a4e89dba6","title":"Weekly Update: March 4 2019","url":"https://app.notion.com/p/564db5b48d5049388808716a4e89dba6?pvs=1","type":"page","highlight":"add backlog project for migrating V1 users","timestamp":"2022-07-30T18:34:00.000Z"},{"id":"2e178a44-b678-807b-9340-e1e830e38c50","title":"ficus.io","url":"https://app.notion.com/p/2e178a44b678807b9340e1e830e38c50?pvs=1","type":"page","highlight":"Collaborative documents (Google Docs style)","timestamp":"2026-06-15T08:15:00.000Z"},{"id":"31e78a44-b678-806b-9a90-efaac9d864cf","title":"User Widget Submissions","url":"https://app.notion.com/p/31e78a44b678806b9a90efaac9d864cf?pvs=1","type":"database","highlight":"User Widget Submissions","timestamp":"2026-03-09T13:03:00.000Z"},{"id":"7e2bbddd-ce16-4002-bcb1-ead4923b9963","title":"Beta feedback (KDK playtesters)","url":"https://app.notion.com/p/7e2bbdddce164002bcb1ead4923b9963?pvs=1","type":"database","highlight":"Beta feedback (KDK playtesters)","timestamp":"2026-04-22T11:56:00.000Z"},{"id":"34878a44-b678-80f3-8f04-cc7fef16e055","title":"moi-w","url":"https://app.notion.com/p/34878a44b67880f38f04cc7fef16e055?pvs=1","type":"page","highlight":"Pi Coding Agent github.com/badlogic/pi-mono/blob/main/packages/coding-agent/docs/sdk.md","timestamp":"2026-04-21T09:42:00.000Z"},{"id":"34978a44-b678-8145-9023-ffb37c04037d","title":"Jonas Bartasius","url":"https://app.notion.com/p/34978a44b67881459023ffb37c04037d?pvs=1","type":"page","highlight":"Jonas Bartasius","timestamp":"2026-04-21T13:07:00.000Z"},{"id":"36578a44-b678-81ea-845c-d7cc7c2ad2c4","title":"Sales Operations","url":"https://app.notion.com/p/36578a44b67881ea845cd7cc7c2ad2c4?pvs=1","type":"page","highlight":"📘 Sales Agent Context — full briefing doc (product, voice, CRM snapshot)","timestamp":"2026-06-09T08:44:00.000Z"},{"id":"31b78a44-b678-802c-a8e7-d897826cf96d","title":"old","url":"https://app.notion.com/p/31b78a44b678802ca8e7d897826cf96d?pvs=1","type":"page","highlight":"Notes:","timestamp":"2026-03-06T16:31:00.000Z"},{"id":"b78788f6-9908-4d54-be46-a974ac5019da","title":"Weekly Update: Jan 28 2019","url":"https://app.notion.com/p/b78788f699084d54be46a974ac5019da'
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const notionFetchOpenSource: ToolCall = {
|
|
60
|
+
toolCallId: 'toolu_01YLadtEch5JsyvhAoD5C2fk',
|
|
61
|
+
name: 'mcp__notion__notion-fetch',
|
|
62
|
+
caller: 'model',
|
|
63
|
+
provider: 'claude-code',
|
|
64
|
+
state: 'success',
|
|
65
|
+
input: {
|
|
66
|
+
id: '233f350e-1f0f-47cd-9422-bd7dbc54d536'
|
|
67
|
+
},
|
|
68
|
+
output:
|
|
69
|
+
'{"metadata":{"type":"page"},"title":"🛥 Open-Source","url":"https://app.notion.com/p/233f350e1f0f47cd9422bd7dbc54d536","text":"Here is the result of \\"view\\" for the Page with URL https://app.notion.com/p/233f350e1f0f47cd9422bd7dbc54d536 as of 2026-05-29T13:08:56.275Z:\\n<page url=\\"https://app.notion.com/p/233f350e1f0f47cd9422bd7dbc54d536\\" icon=\\"🛥\\">\\n<ancestor-path></ancestor-path>\\n<properties>\\n{\\"title\\":\\"Open-Source\\"}\\n</properties>\\n<content>\\n<page url=\\"https://app.notion.com/p/164f35996438406fac456aeef33a046d\\">wouter</page>\\n<page url=\\"https://app.notion.com/p/72c25fbe45af40c28a19f635332f9c4c\\">spoiled</page>\\n<page url=\\"https://app.notion.com/p/68d8786d210d42e0888168401a40345e\\">retreat</page>\\n<page url=\\"https://app.notion.com/p/01f714ee111a4df295726341c22decbc\\">presa</page>\\n<page url=\\"https://app.notion.com/p/3184781d05c743628f0c0b864b4182ee\\">`use-leader`</page>\\n<page url=\\"https://app.notion.com/p/6d1a390c1e5d4e888f6cdb86e5adcb9d\\">use-pong</page>\\n<empty-block/>\\n<empty-block/>\\n</content>\\n</page>"}'
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const notionFetchSpoiled: ToolCall = {
|
|
73
|
+
toolCallId: 'toolu_0179zYKPrLE7vwAHQNpchHzT',
|
|
74
|
+
name: 'mcp__notion__notion-fetch',
|
|
75
|
+
caller: 'model',
|
|
76
|
+
provider: 'claude-code',
|
|
77
|
+
state: 'success',
|
|
78
|
+
input: {
|
|
79
|
+
id: '72c25fbe45af40c28a19f635332f9c4c'
|
|
80
|
+
},
|
|
81
|
+
output:
|
|
82
|
+
'{"metadata":{"type":"page"},"title":"spoiled","url":"https://app.notion.com/p/72c25fbe45af40c28a19f635332f9c4c","text":"Here is the result of \\"view\\" for the Page with URL https://app.notion.com/p/72c25fbe45af40c28a19f635332f9c4c as of 2024-04-19T10:05:10.098Z:\\n<page url=\\"https://app.notion.com/p/72c25fbe45af40c28a19f635332f9c4c\\" icon=\\"https://prod-files-secure.s3.us-west-2.amazonaws.com/99bed442-8dd1-4df6-b9ae-7261db17cdd8/3a9f6ee3-4e85-450f-859b-5a2ed2297f35/favicon.svg\\">\\n<ancestor-path>\\n<parent-page url=\\"https://app.notion.com/p/233f350e1f0f47cd9422bd7dbc54d536\\" title=\\"Open-Source\\"/>\\n</ancestor-path>\\n<properties>\\n{\\"title\\":\\"spoiled\\"}\\n</properties>\\n<content>\\n- [x] Подумать, как разделить шум и анимацию контента\\n- [x] Basic API для реакта\\n\\t- [x] Controlled/uncontrolled\\n\\t- [x] SSR: ok! Если перенесем transitions в реакт\\n\\t- [x] \\\\<spoiler\\\\> tag is not supported\\n\\t- [x] Detach on unmount\\n\\t- [x] `asChild` prop\\n\\t- [x] Block elements and `tagName`\\n\\t- [x] Reveal on `hover`\\n\\t- [x] Pass noise options\\n\\t- [x] asChild types\\n\\t- [x] Content transitions\\n- [x] Следить за объектом в VisibilityObserver\\n- [x] По умолчанию спойлер без транзишена. Для этого нужно сделать враппер, который через `:has` выключает селектор. Но тогда как должны анимироваться блоки? Но тогда не получится `asChild` сделать.\\n- [x] Dark/light theme, none, auto, accent color\\n- [x] Demo: light/dark theme\\n- [x] `useIsomorphicLayoutEffect`\\n- [x] Проверить селектор для текста\\n- [x] Билд и пакет\\n- [x] Лайтово опубликовать и подключить к Domik\\n- [x] Fallback для Safari + Firefox. Анимированная гифка. Можно взять три слоя сдвинутых не по простым числам. 3, 5, 7, 19 и взять три четыре кадра\\n- [x] data-hidden\\n- [x] Для фоллбека сделать pixelRatio\\n- [x] Как должны загружаться стили? Подключать отдельно.\\n- [x] Простой README\\n- [x] Сделать правильную анимацию\\n- [ ] Use inline style in SSR\\n<empty-block/>\\n```javascript\\n// Default spoiler: uncontrolled, light theme, reveals on hover, creates \\n// inline <spoiler> element, opacity no transition, does not mimic words\\n\\n/**\\n * Elements \\n */\\n<Spoiler>Hello!</Spoiler> // <spoiler>Hello!</spoiler>\\n<Spoiler className=\\"custom\\">Hello!</Spoiler>\\n\\n// block elements \\n<Spoiler block><img /></Spoiler> // <div><img /></div>\\n<Spoiler tagName=\\"div\\"><img /></Spoiler> // alias\\n\\n// advanced\\n<Spoiler asChild><blockquote aria-label=\\"hello\\" /></Spoiler>\\n\\n/**\\n * Controlled/uncontrolled component \\n */\\n\\n<Spoiler /> // reveal is hover and uncontrolled\\n<Spoiler revealOn=\\"hover\\" />\\n<Spoiler revealOn=\\"click\\" />\\n<Spoiler defaultHidden={false} onChange={(value) => change} />\\n\\n// when `hidden` option is provided, it becomes controlled and\\n// `revealOn` and `defaultHidden` have no effect \\n<Spoiler hidden={true}>Always hidden</Spoiler> // controlled\\n<Spoiler hidden={value} onClick={() => setValue()}</Spoiler> // controlled\\n\\n/** \\n * Theming \\n */\\n\\n<Spoiler /> // default theme is `light`\\n<Spoiler theme=\\"dark\\" />\\n<Spoiler theme=\\"auto\\" /> // system-defined\\n<Spoiler theme=\\"dark\\" accentColor=\\"red\\" /> // use `colord` here\\n\\n/**\\n * Content transitions \\n */\\n\\n// disable noise animation start/stop\\n<Spoiler noiseTransition={false}></Spoiler> \\n\\n// this should disable default stylesheet injection (!) for simple opacity\\n<Spoiler><FadeTransition>Hey<FadeTransition></Spoiler> // animated opacity\\n<Spoiler><IrisTransition>Hey<IrisTransition></Spoiler> // animated mask\\n\\n/**\\n * Noise options\\n */\\n<Spoiler fps={12} gap={false} mimicWords>Text with words</Spoiler>\\n<Spoiler fps=\\"performance\\">Text with words</Spoiler>\\n\\n/** \\n\\t* Styling \\n */\\n\\nimport { Spoiler } from \\"spoiled\\"\\n\\nimport { Spoiler } from \\"spoiled/unstyled\\"\\nimport \\"spoiled/styles.css\\"\\n```\\n<empty-block/>\\n<empty-block/>\\n<page url=\\"https://app.notion.com/p/69226847251d43898b7ec135fcb86c36\\">Spoiled: website</page>\\n</content>\\n</page>"}'
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const bash: ToolCall = {
|
|
86
|
+
toolCallId: 'toolu_01WXqjUXgUJPaexqLb7pZkgH',
|
|
87
|
+
name: 'Bash',
|
|
88
|
+
caller: 'model',
|
|
89
|
+
provider: 'claude-code',
|
|
90
|
+
state: 'success',
|
|
91
|
+
input: {
|
|
92
|
+
command:
|
|
93
|
+
'pwd && echo "---" && ls -la && echo "--- git ---" && git rev-parse --is-inside-work-tree 2>/dev/null && git remote -v 2>/dev/null',
|
|
94
|
+
description: 'Show current directory and git info'
|
|
95
|
+
},
|
|
96
|
+
output:
|
|
97
|
+
'/Users/molefrog/git/spoiled\n---\ntotal 232\ndrwxr-xr-x 19 molefrog staff 608 Jun 9 19:41 .\ndrwxr-xr-x 52 molefrog staff 1664 Jun 15 10:32 ..\ndrwx------ 3 molefrog staff 96 Nov 17 2025 .claude\n-rw-r--r--@ 1 molefrog staff 6148 Nov 13 2025 .DS_Store\ndrwxr-xr-x 15 molefrog staff 480 May 23 09:30 .git\n-rw-r--r-- 1 molefrog staff 294 May 23 08:52 .gitignore\ndrwxr-xr-x@ 3 molefrog staff 96 Jun 9 19:41 .moi\n-rw-r--r-- 1 molefrog staff 95 Nov 13 2025 .prettierrc\n-rw-r--r-- 1 molefrog staff 73126 May 23 09:29 bun.lock\ndrwxr-xr-x@ 8 molefrog staff 256 May 23 09:31 esm\n-rw-r--r-- 1 molefrog staff 1210 Nov 13 2025 LICENSE\ndrwxr-xr-x 160 molefrog staff 5120 May 23 09:30 node_modules\n-rw-r--r-- 1 molefrog staff 2072 May 23 08:52 package.json\n-rw-r--r--@ 1 molefrog staff 4600 May 5 21:49 README.md\ndrwxr-xr-x 16 molefrog staff 512 May 5 21:50 src\n-rw-r--r-- 1 molefrog staff 605 Nov 13 2025 tsconfig.json\n-rw-r--r-- 1 molefrog staff 233 Nov 13 2025 tsconfig.node.json\n-rw-r--r-- 1 molefrog staff 1582 May 23 08:52 vite.config.ts\ndrwxr-xr-x 11 molefrog staff 352 May 5 21:49 web\n--- git ---\ntrue\norigin\tgit@github.com:molefrog/spoiled.git (fetch)\norigin\tgit@github.com:molefrog/spoiled.git (push)'
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Synthesized to match a real Claude Read result (cat -n style body): neither
|
|
101
|
+
// recorded thread included a Read, but the group spec calls for one.
|
|
102
|
+
const readFile: ToolCall = {
|
|
103
|
+
toolCallId: 'toolu_fixture_read_readme',
|
|
104
|
+
name: 'Read',
|
|
105
|
+
caller: 'model',
|
|
106
|
+
provider: 'claude-code',
|
|
107
|
+
state: 'success',
|
|
108
|
+
input: {
|
|
109
|
+
file_path: '/Users/molefrog/git/spoiled/docs/open-source/README.md'
|
|
110
|
+
},
|
|
111
|
+
output:
|
|
112
|
+
' 1\t# 🛥 Open-Source\n 2\t\n 3\tWorking notes, specs, and ideas for my open-source projects.\n 4\t\n 5\t| Project | What it is |\n 6\t|---------|------------|\n 7\t| wouter | Minimalist hooks-based router for React |\n 8\t| spoiled | <Spoiler> reveal effect for React |\n'
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// A native GitHub MCP call (from the lilmd-demo thread). Renders via the same
|
|
116
|
+
// native-MCP path as notion: github logo + "Github" + `get_me`.
|
|
117
|
+
const githubCall: ToolCall = {
|
|
118
|
+
toolCallId: 'toolu_01BN1AFsafzezpUwm8uhGWKa',
|
|
119
|
+
name: 'mcp__github__get_me',
|
|
120
|
+
caller: 'model',
|
|
121
|
+
provider: 'claude-code',
|
|
122
|
+
state: 'success',
|
|
123
|
+
input: {},
|
|
124
|
+
output:
|
|
125
|
+
'{"login":"molefrog","id":671276,"profile_url":"https://github.com/molefrog","avatar_url":"https://avatars.githubusercontent.com/u/671276?v=4","details":{"name":"Alexey Taktarov","blog":"https://molefrog.com","location":"Copenhagen","hireable":true,"twitter_username":"mlfrg","public_repos":64,"public_gists":10,"followers":700,"following":444,"created_at":"2011-03-15T15:58:23Z","updated_at":"2026-06-13T09:04:50Z"}}'
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// A reasoning ("Thinking") step (from the lilmd-demo thread). It's a Part, not a
|
|
129
|
+
// ToolCall, which is why the lists are `Part[]`.
|
|
130
|
+
const thinking: Part = {
|
|
131
|
+
type: 'reasoning',
|
|
132
|
+
text: 'The user is greeting me casually with "Hey bro". This is a friendly greeting and they\'re not asking me to do anything specific yet. I should respond in a friendly, casual way and let them know I\'m ready to help with whatever they need.'
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// A Skill launch (from the lilmd-demo thread). `name: 'Skill'` + a `skill`
|
|
136
|
+
// sidecar; renders as a "Loading Skill" timeline row.
|
|
137
|
+
const skillCall: ToolCall = {
|
|
138
|
+
toolCallId: 'toolu_01ADt4E1V39b8rhGUEuTQvdP',
|
|
139
|
+
name: 'Skill',
|
|
140
|
+
caller: 'model',
|
|
141
|
+
provider: 'claude-code',
|
|
142
|
+
state: 'success',
|
|
143
|
+
input: { skill: 'widgets' },
|
|
144
|
+
skill: { skillName: 'widgets' },
|
|
145
|
+
output: 'Launching skill: widgets'
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// Variant 1 — a single tool call (the degenerate group).
|
|
149
|
+
export const singleToolCall: Part[] = [{ type: 'tool-call', call: bash }]
|
|
150
|
+
|
|
151
|
+
// Variant 2 — a realistic mixed timeline: thinking, tool search, skill, 2 notion,
|
|
152
|
+
// read file, bash, notion, then a github call.
|
|
153
|
+
export const multipleToolCalls: Part[] = [
|
|
154
|
+
thinking,
|
|
155
|
+
{ type: 'tool-call', call: toolSearch },
|
|
156
|
+
{ type: 'tool-call', call: skillCall },
|
|
157
|
+
{ type: 'tool-call', call: notionSearch },
|
|
158
|
+
{ type: 'tool-call', call: notionFetchOpenSource },
|
|
159
|
+
{ type: 'tool-call', call: readFile },
|
|
160
|
+
{ type: 'tool-call', call: bash },
|
|
161
|
+
{ type: 'tool-call', call: notionFetchSpoiled },
|
|
162
|
+
{ type: 'tool-call', call: githubCall }
|
|
163
|
+
]
|
|
164
|
+
|
|
165
|
+
// A still-running Bash — no output yet, state 'running'. Dotted (not MCP), so
|
|
166
|
+
// its timeline node renders a spinner instead of a dot.
|
|
167
|
+
const runningBash: ToolCall = {
|
|
168
|
+
toolCallId: 'toolu_fixture_running_bash',
|
|
169
|
+
name: 'Bash',
|
|
170
|
+
caller: 'model',
|
|
171
|
+
provider: 'claude-code',
|
|
172
|
+
state: 'running',
|
|
173
|
+
input: { command: 'bun test --coverage', description: 'Run the test suite' }
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// Variant 3 — a live (mid-flight) trace, rendered with `processing`. Exercises
|
|
177
|
+
// the in-progress states in one view: a finished "Thought", a running dotted
|
|
178
|
+
// tool (spinner node), and a trailing live "Thinking" (spinner node). The last
|
|
179
|
+
// two wouldn't co-occur in a real stream — this is a state showcase.
|
|
180
|
+
export const liveToolCalls: Part[] = [
|
|
181
|
+
thinking,
|
|
182
|
+
{ type: 'tool-call', call: toolSearch },
|
|
183
|
+
{ type: 'tool-call', call: notionSearch },
|
|
184
|
+
{ type: 'tool-call', call: runningBash },
|
|
185
|
+
{
|
|
186
|
+
type: 'reasoning',
|
|
187
|
+
text: 'The test run is still going. Once it passes I will write the summary into docs/ and open a PR.'
|
|
188
|
+
}
|
|
189
|
+
]
|
|
190
|
+
|
|
191
|
+
// A *streaming* subagent (caller='subagent', name='Agent'), captured live from a
|
|
192
|
+
// real Explore subagent run. The `subagent` record fills in incrementally from
|
|
193
|
+
// `task_*` events (lib/claude-adapter.ts): `progress[]` accumulates one "latest
|
|
194
|
+
// action" line per tool use (the last is what the collapsed card shows live),
|
|
195
|
+
// alongside `status`, `usage`, and a growing `transcript`. None of it is
|
|
196
|
+
// persisted — a finished/replayed Agent call has none of this, only a live one
|
|
197
|
+
// does. Here it's mid-run (status 'running'): `input` and `progress` are real;
|
|
198
|
+
// the transcript is a trimmed version of the work so far.
|
|
199
|
+
const subagentCall: ToolCall = {
|
|
200
|
+
toolCallId: 'toolu_01Qievnpu7yZAt9TWejhzAHu',
|
|
201
|
+
name: 'Agent',
|
|
202
|
+
caller: 'subagent',
|
|
203
|
+
provider: 'claude-code',
|
|
204
|
+
state: 'running',
|
|
205
|
+
input: {
|
|
206
|
+
description: 'Explore lilmd-demo repo structure and purpose',
|
|
207
|
+
subagent_type: 'Explore',
|
|
208
|
+
prompt:
|
|
209
|
+
'Explore the lilmd-demo repository to understand what it is. Look at the repo structure, what lilmd is, example markdown, and the purpose. Give a comprehensive overview citing specific files.'
|
|
210
|
+
},
|
|
211
|
+
// Still streaming — no final result yet.
|
|
212
|
+
output: '',
|
|
213
|
+
subagent: {
|
|
214
|
+
taskId: 'task_explore_lilmd',
|
|
215
|
+
description: 'Explore lilmd-demo repo structure and purpose',
|
|
216
|
+
status: 'running',
|
|
217
|
+
usage: { totalTokens: 18407, toolUses: 8, durationMs: 10725 },
|
|
218
|
+
// Real captured progress — each entry is the "latest action" at that step.
|
|
219
|
+
progress: [
|
|
220
|
+
'Reading ~/git/lilmd-demo',
|
|
221
|
+
'Reading README.md',
|
|
222
|
+
'Reading package.json',
|
|
223
|
+
'Reading CLAUDE.md',
|
|
224
|
+
'Running ls -la /Users/molefrog/git/lilmd-demo/',
|
|
225
|
+
'Finding **/*.md',
|
|
226
|
+
'Finding **/*.{js,ts,jsx,tsx}',
|
|
227
|
+
'Running head -100 /Users/molefrog/git/lilmd-demo/challenger-report.md'
|
|
228
|
+
],
|
|
229
|
+
transcript: [
|
|
230
|
+
{
|
|
231
|
+
id: 'sub-1',
|
|
232
|
+
role: 'assistant',
|
|
233
|
+
origin: { kind: 'user-input' },
|
|
234
|
+
parts: [
|
|
235
|
+
{
|
|
236
|
+
type: 'reasoning',
|
|
237
|
+
text: 'Let me map the repo: list the markdown files, read the README, then see what the lilmd binary does.'
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
type: 'tool-call',
|
|
241
|
+
call: {
|
|
242
|
+
toolCallId: 'sub-glob',
|
|
243
|
+
name: 'Glob',
|
|
244
|
+
caller: 'model',
|
|
245
|
+
provider: 'claude-code',
|
|
246
|
+
state: 'success',
|
|
247
|
+
input: { pattern: '**/*.md' },
|
|
248
|
+
output:
|
|
249
|
+
'README.md\ndocs/challenger-report.md\ndocs/sections/01-introduction.md\ndocs/sections/02-findings.md'
|
|
250
|
+
}
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
type: 'tool-call',
|
|
254
|
+
call: {
|
|
255
|
+
toolCallId: 'sub-bash',
|
|
256
|
+
name: 'Bash',
|
|
257
|
+
caller: 'model',
|
|
258
|
+
provider: 'claude-code',
|
|
259
|
+
state: 'success',
|
|
260
|
+
input: { command: 'lilmd --help' },
|
|
261
|
+
output:
|
|
262
|
+
'lilmd — navigate large markdown\n\nUSAGE: lilmd <file> <command>\n\nCOMMANDS:\n toc print the table of contents\n read read a section (fuzzy/regex/path selector)\n search full-text search'
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
]
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
id: 'sub-2',
|
|
269
|
+
role: 'assistant',
|
|
270
|
+
origin: { kind: 'user-input' },
|
|
271
|
+
parts: [
|
|
272
|
+
{
|
|
273
|
+
type: 'text',
|
|
274
|
+
text: '## Comprehensive Overview of lilmd-demo\n\n**lilmd-demo** showcases **lilmd**, a CLI for large markdown documents, using the Challenger report as a large-document fixture.'
|
|
275
|
+
}
|
|
276
|
+
]
|
|
277
|
+
}
|
|
278
|
+
]
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
// The same subagent once it has finished: status 'completed', a final summary in
|
|
283
|
+
// `output`, and the toolUses count shown in place of the latest-action line.
|
|
284
|
+
const subagentDoneCall: ToolCall = {
|
|
285
|
+
...subagentCall,
|
|
286
|
+
toolCallId: 'toolu_01Qievnpu7yZAt9TWejhzAHv',
|
|
287
|
+
state: 'success',
|
|
288
|
+
output:
|
|
289
|
+
'lilmd-demo showcases **lilmd**, a CLI for navigating large markdown documents. The repo is a demo harness: a single `challenger-report.md` fixture plus a thin CLI (`toc`/`read`/`search`) that fuzzy-selects sections. README and CLAUDE.md frame it as a worked example, not a library.',
|
|
290
|
+
subagent: {
|
|
291
|
+
...subagentCall.subagent!,
|
|
292
|
+
taskId: 'task_explore_lilmd_done',
|
|
293
|
+
status: 'completed'
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
// Variant 4 — a streamed subagent call (the card we show when an Agent tool is
|
|
298
|
+
// running). Iterate on it in /playground/tool-calls.
|
|
299
|
+
export const subagentTrace: Part[] = [
|
|
300
|
+
{
|
|
301
|
+
type: 'reasoning',
|
|
302
|
+
text: 'This needs a deeper look — let me spin up an Explore subagent to map the repo while I keep going.'
|
|
303
|
+
},
|
|
304
|
+
{ type: 'tool-call', call: subagentCall }
|
|
305
|
+
]
|
|
306
|
+
|
|
307
|
+
// Variant 5 — the same subagent after it finished, so we can style the completed
|
|
308
|
+
// card (✓, tool-count sub-line, no shimmer) alongside the running one.
|
|
309
|
+
export const subagentDoneTrace: Part[] = [
|
|
310
|
+
{
|
|
311
|
+
type: 'reasoning',
|
|
312
|
+
text: 'This needs a deeper look — let me spin up an Explore subagent to map the repo while I keep going.'
|
|
313
|
+
},
|
|
314
|
+
{ type: 'tool-call', call: subagentDoneCall }
|
|
315
|
+
]
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
// Formatting utils for tool rows: turn a raw ToolCall into the display name and
|
|
2
|
+
// one-line brief, and parse the two MCP call shapes. Pure functions, no React.
|
|
3
|
+
import { relative } from 'pathe'
|
|
4
|
+
|
|
5
|
+
import type { ToolCall } from '@/lib/types'
|
|
6
|
+
|
|
7
|
+
export type McpRef = { server: string; tool: string; rest: string }
|
|
8
|
+
|
|
9
|
+
// Detect a `mcporter call <server>.<tool> [args...]` invocation inside a shell
|
|
10
|
+
// command. Accepts any prefix (env VAR=…, `$(which mcporter)`, `npx mcporter`),
|
|
11
|
+
// stops at the first command separator so a chained command doesn't bleed into
|
|
12
|
+
// `rest`. Returns null for non-`call` invocations.
|
|
13
|
+
export function parseMcporterCall(call: ToolCall): McpRef | null {
|
|
14
|
+
const isShell = call.name === 'Bash' || call.name === 'exec'
|
|
15
|
+
if (!isShell) return null
|
|
16
|
+
const input = (call.input as Record<string, unknown>) ?? {}
|
|
17
|
+
const command = typeof input.command === 'string' ? input.command : ''
|
|
18
|
+
if (!command) return null
|
|
19
|
+
const m = command.match(
|
|
20
|
+
/(?:^|\s|\$\()mcporter(?:\)?)\s+call\s+([A-Za-z0-9_-]+)\.([A-Za-z0-9_-]+)((?:\s+(?!&&|\|\||;|\|)\S+)*)/
|
|
21
|
+
)
|
|
22
|
+
if (!m) return null
|
|
23
|
+
return { server: m[1], tool: m[2], rest: (m[3] ?? '').trim() }
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Native MCP tool calls arrive as `mcp__<server>__<tool>` (the server is encoded
|
|
27
|
+
// in the name; `caller` is `model` and `mcpServer` is unset). Server tokens use
|
|
28
|
+
// single underscores, so split on the FIRST `__` after the prefix.
|
|
29
|
+
// e.g. `mcp__notion__notion-search` → notion / notion-search.
|
|
30
|
+
export function parseNativeMcp(call: ToolCall): McpRef | null {
|
|
31
|
+
const name = call.name
|
|
32
|
+
if (!name.startsWith('mcp__')) return null
|
|
33
|
+
const rest = name.slice(5)
|
|
34
|
+
const i = rest.indexOf('__')
|
|
35
|
+
if (i <= 0) return null
|
|
36
|
+
return { server: rest.slice(0, i), tool: rest.slice(i + 2), rest: '' }
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Drop the redundant server prefix many MCP tools repeat — the icon + server name
|
|
40
|
+
// already identify it: `notion-search` → `search`, `notion-get-teams` →
|
|
41
|
+
// `get-teams`. Tools that don't repeat the server pass through unchanged.
|
|
42
|
+
export function formatMcpTool(server: string, tool: string): string {
|
|
43
|
+
const lower = tool.toLowerCase()
|
|
44
|
+
const sep = ['-', '_', '.'].find(s => lower.startsWith(server.toLowerCase() + s))
|
|
45
|
+
return sep ? tool.slice(server.length + 1) : tool
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function getInputValue(input: Record<string, unknown>, key: string): string {
|
|
49
|
+
const value = input[key]
|
|
50
|
+
return typeof value === 'string' ? value : ''
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Human byte size of a string (UTF-8): `124B`, `2.5KB`.
|
|
54
|
+
export function formatBytes(text: string): string {
|
|
55
|
+
const n = new TextEncoder().encode(text).length
|
|
56
|
+
return n < 1024 ? `${n}B` : `${(n / 1024).toFixed(1)}KB`
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Compact wall-clock duration: sub-second → "850ms", under a minute → "3.2s" /
|
|
60
|
+
// "11s", longer → "1m 5s". Used on the subagent card's duration badge.
|
|
61
|
+
export function formatDuration(ms: number): string {
|
|
62
|
+
if (ms < 1000) return `${Math.round(ms)}ms`
|
|
63
|
+
const s = ms / 1000
|
|
64
|
+
if (s < 60) return `${s < 10 ? s.toFixed(1) : Math.round(s)}s`
|
|
65
|
+
const m = Math.floor(s / 60)
|
|
66
|
+
const rem = Math.round(s % 60)
|
|
67
|
+
return rem ? `${m}m ${rem}s` : `${m}m`
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function makeShortenPaths(cwd: string | null) {
|
|
71
|
+
return (s: string) =>
|
|
72
|
+
s.replace(/\/[^\s"']+/g, p => {
|
|
73
|
+
if (!cwd) return p
|
|
74
|
+
const rel = relative(cwd, p)
|
|
75
|
+
return rel.startsWith('..') ? p : rel
|
|
76
|
+
})
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Tool name → user-facing label, picked per provider. Adapters send the raw
|
|
80
|
+
// upstream tool name; the UI humanizes it. Unknown names fall through to the raw
|
|
81
|
+
// name so plugin tools still render something.
|
|
82
|
+
const OPENCLAW_TOOL_LABELS: Record<string, string> = {
|
|
83
|
+
read: 'Read file',
|
|
84
|
+
write: 'Write file',
|
|
85
|
+
edit: 'Edit file',
|
|
86
|
+
apply_patch: 'Edit',
|
|
87
|
+
exec: 'Bash',
|
|
88
|
+
process: 'Manage process',
|
|
89
|
+
web_search: 'Web search',
|
|
90
|
+
web_fetch: 'Fetch',
|
|
91
|
+
sessions_list: 'List sessions',
|
|
92
|
+
sessions_history: 'Recall session',
|
|
93
|
+
sessions_yield: 'Yield to session',
|
|
94
|
+
sessions_send: 'Send to session',
|
|
95
|
+
sessions_spawn: 'Spawn session',
|
|
96
|
+
subagents: 'Run sub-agent',
|
|
97
|
+
agents_list: 'List agents',
|
|
98
|
+
session_status: 'Session status',
|
|
99
|
+
image: 'Analyze image',
|
|
100
|
+
image_generate: 'Generate image',
|
|
101
|
+
memory_get: 'Read memory',
|
|
102
|
+
memory_search: 'Search memory',
|
|
103
|
+
update_plan: 'Update plan',
|
|
104
|
+
message: 'Send message',
|
|
105
|
+
browser: 'Browser',
|
|
106
|
+
canvas: 'Canvas',
|
|
107
|
+
cron: 'Cron',
|
|
108
|
+
gateway: 'Gateway',
|
|
109
|
+
code_execution: 'Run Python',
|
|
110
|
+
tts: 'Text-to-speech',
|
|
111
|
+
music_generate: 'Generate music',
|
|
112
|
+
video_generate: 'Generate video',
|
|
113
|
+
x_search: 'Search X'
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Claude tool names are mostly already presentable (Read, Bash, …); only a few
|
|
117
|
+
// need spacing/relabelling.
|
|
118
|
+
const CLAUDE_TOOL_LABELS: Record<string, string> = {
|
|
119
|
+
ToolSearch: 'Tool Search',
|
|
120
|
+
WebSearch: 'Web Search',
|
|
121
|
+
WebFetch: 'Web Fetch'
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export function getToolDisplayName(call: ToolCall): string {
|
|
125
|
+
if (call.provider === 'openclaw') return OPENCLAW_TOOL_LABELS[call.name] ?? call.name
|
|
126
|
+
return CLAUDE_TOOL_LABELS[call.name] ?? call.name
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Short tool label from a fully-qualified MCP tool name: `mcp__notion__notion-
|
|
130
|
+
// search` → `notion-search` (drop the `mcp__<server>__` prefix). Plain names
|
|
131
|
+
// pass through.
|
|
132
|
+
function shortToolName(name: string): string {
|
|
133
|
+
if (!name.startsWith('mcp__')) return name
|
|
134
|
+
const parts = name.slice(5).split('__')
|
|
135
|
+
return parts.length >= 2 ? parts.slice(1).join('__') : parts[0]
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export function formatInputBrief(call: ToolCall, cwd: string | null): string {
|
|
139
|
+
const input = (call.input as Record<string, unknown>) ?? {}
|
|
140
|
+
const shorten = makeShortenPaths(cwd)
|
|
141
|
+
if (call.provider === 'openclaw') return formatOpenClawBrief(call.name, input, shorten)
|
|
142
|
+
return formatClaudeBrief(call.name, input, shorten)
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function formatClaudeBrief(
|
|
146
|
+
tool: string,
|
|
147
|
+
input: Record<string, unknown>,
|
|
148
|
+
shorten: (s: string) => string
|
|
149
|
+
): string {
|
|
150
|
+
if (tool === 'Bash') return shorten(`$ ${getInputValue(input, 'command')}`)
|
|
151
|
+
if (tool === 'Read' || tool === 'Write' || tool === 'Edit')
|
|
152
|
+
return shorten(getInputValue(input, 'file_path'))
|
|
153
|
+
if (tool === 'Glob') return shorten(getInputValue(input, 'pattern'))
|
|
154
|
+
if (tool === 'Grep')
|
|
155
|
+
return `/${getInputValue(input, 'pattern')}/ ${shorten(getInputValue(input, 'path'))}`
|
|
156
|
+
if (tool === 'WebSearch') return getInputValue(input, 'query')
|
|
157
|
+
if (tool === 'WebFetch') return getInputValue(input, 'url')
|
|
158
|
+
if (tool === 'ToolSearch') {
|
|
159
|
+
const query = getInputValue(input, 'query')
|
|
160
|
+
// `select:a,b,c` loads those tools → list their short names; otherwise it's a
|
|
161
|
+
// free-text discovery query → show it as-is.
|
|
162
|
+
if (query.startsWith('select:')) return query.slice(7).split(',').map(shortToolName).join(', ')
|
|
163
|
+
return query
|
|
164
|
+
}
|
|
165
|
+
return ''
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function formatOpenClawBrief(
|
|
169
|
+
tool: string,
|
|
170
|
+
input: Record<string, unknown>,
|
|
171
|
+
shorten: (s: string) => string
|
|
172
|
+
): string {
|
|
173
|
+
if (tool === 'read' || tool === 'write' || tool === 'edit')
|
|
174
|
+
return shorten(getInputValue(input, 'path'))
|
|
175
|
+
if (tool === 'apply_patch') {
|
|
176
|
+
const patch = getInputValue(input, 'patch')
|
|
177
|
+
const firstLine = patch.split('\n').find(l => l.startsWith('*** ')) ?? patch.split('\n')[0]
|
|
178
|
+
return shorten(firstLine ?? '')
|
|
179
|
+
}
|
|
180
|
+
if (tool === 'exec') return shorten(`$ ${getInputValue(input, 'command')}`)
|
|
181
|
+
if (tool === 'process') {
|
|
182
|
+
const action = getInputValue(input, 'action')
|
|
183
|
+
const name = getInputValue(input, 'name')
|
|
184
|
+
return [action, name].filter(Boolean).join(' ') || shorten(getInputValue(input, 'command'))
|
|
185
|
+
}
|
|
186
|
+
if (tool === 'web_search' || tool === 'x_search') return getInputValue(input, 'query')
|
|
187
|
+
if (tool === 'web_fetch') return getInputValue(input, 'url')
|
|
188
|
+
if (tool === 'memory_search') return getInputValue(input, 'query')
|
|
189
|
+
if (tool === 'memory_get') return getInputValue(input, 'key') || getInputValue(input, 'name')
|
|
190
|
+
if (tool === 'sessions_history' || tool === 'sessions_send' || tool === 'sessions_yield')
|
|
191
|
+
return getInputValue(input, 'sessionKey') || getInputValue(input, 'agentId')
|
|
192
|
+
if (tool === 'sessions_list' || tool === 'agents_list') return getInputValue(input, 'agentId')
|
|
193
|
+
if (tool === 'subagents' || tool === 'sessions_spawn')
|
|
194
|
+
return getInputValue(input, 'task') || getInputValue(input, 'agentId')
|
|
195
|
+
if (tool === 'image' || tool === 'image_generate')
|
|
196
|
+
return getInputValue(input, 'prompt') || shorten(getInputValue(input, 'path'))
|
|
197
|
+
if (tool === 'message') return getInputValue(input, 'recipient') || getInputValue(input, 'to')
|
|
198
|
+
if (tool === 'update_plan') {
|
|
199
|
+
const plan = input.plan
|
|
200
|
+
if (Array.isArray(plan)) {
|
|
201
|
+
const inProgress = plan.find(
|
|
202
|
+
(p): p is { step: string } =>
|
|
203
|
+
!!p && typeof p === 'object' && (p as { status?: unknown }).status === 'in_progress'
|
|
204
|
+
)
|
|
205
|
+
const step = inProgress?.step ?? (plan[0] as { step?: unknown })?.step
|
|
206
|
+
if (typeof step === 'string') return step
|
|
207
|
+
}
|
|
208
|
+
return ''
|
|
209
|
+
}
|
|
210
|
+
return ''
|
|
211
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Dialog as DialogPrimitive } from '@base-ui/react/dialog'
|
|
2
|
+
|
|
3
|
+
import { cn } from '@/client/lib/cn'
|
|
4
|
+
|
|
5
|
+
function Dialog({ ...props }: DialogPrimitive.Root.Props) {
|
|
6
|
+
return <DialogPrimitive.Root data-slot="dialog" {...props} />
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function DialogTrigger({ ...props }: DialogPrimitive.Trigger.Props) {
|
|
10
|
+
return <DialogPrimitive.Trigger data-slot="dialog-trigger" {...props} />
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function DialogClose({ ...props }: DialogPrimitive.Close.Props) {
|
|
14
|
+
return <DialogPrimitive.Close data-slot="dialog-close" {...props} />
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function DialogContent({ className, children, ...props }: DialogPrimitive.Popup.Props) {
|
|
18
|
+
return (
|
|
19
|
+
<DialogPrimitive.Portal>
|
|
20
|
+
<DialogPrimitive.Backdrop
|
|
21
|
+
data-slot="dialog-backdrop"
|
|
22
|
+
className="fixed inset-0 z-50 bg-black/40 duration-150 data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0"
|
|
23
|
+
/>
|
|
24
|
+
<DialogPrimitive.Popup
|
|
25
|
+
data-slot="dialog-content"
|
|
26
|
+
className={cn(
|
|
27
|
+
'fixed top-1/2 left-1/2 z-50 origin-center -translate-x-1/2 -translate-y-1/2 overflow-hidden rounded-xl bg-card text-card-foreground shadow-xl ring-1 ring-foreground/10 outline-hidden duration-150 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95',
|
|
28
|
+
className
|
|
29
|
+
)}
|
|
30
|
+
{...props}
|
|
31
|
+
>
|
|
32
|
+
{children}
|
|
33
|
+
</DialogPrimitive.Popup>
|
|
34
|
+
</DialogPrimitive.Portal>
|
|
35
|
+
)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function DialogTitle({ className, ...props }: DialogPrimitive.Title.Props) {
|
|
39
|
+
return (
|
|
40
|
+
<DialogPrimitive.Title
|
|
41
|
+
data-slot="dialog-title"
|
|
42
|
+
className={cn('text-lg font-semibold', className)}
|
|
43
|
+
{...props}
|
|
44
|
+
/>
|
|
45
|
+
)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function DialogDescription({ className, ...props }: DialogPrimitive.Description.Props) {
|
|
49
|
+
return (
|
|
50
|
+
<DialogPrimitive.Description
|
|
51
|
+
data-slot="dialog-description"
|
|
52
|
+
className={cn('text-sm text-muted-foreground', className)}
|
|
53
|
+
{...props}
|
|
54
|
+
/>
|
|
55
|
+
)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export { Dialog, DialogClose, DialogContent, DialogDescription, DialogTitle, DialogTrigger }
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { PreviewCard as PreviewCardPrimitive } from '@base-ui/react/preview-card'
|
|
2
|
+
|
|
3
|
+
import { cn } from '@/client/lib/cn'
|
|
4
|
+
|
|
5
|
+
function HoverCard({ ...props }: PreviewCardPrimitive.Root.Props) {
|
|
6
|
+
return <PreviewCardPrimitive.Root data-slot="hover-card" {...props} />
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function HoverCardTrigger({ ...props }: PreviewCardPrimitive.Trigger.Props) {
|
|
10
|
+
return <PreviewCardPrimitive.Trigger data-slot="hover-card-trigger" {...props} />
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function HoverCardContent({
|
|
14
|
+
className,
|
|
15
|
+
side = 'bottom',
|
|
16
|
+
sideOffset = 4,
|
|
17
|
+
align = 'center',
|
|
18
|
+
alignOffset = 4,
|
|
19
|
+
...props
|
|
20
|
+
}: PreviewCardPrimitive.Popup.Props &
|
|
21
|
+
Pick<PreviewCardPrimitive.Positioner.Props, 'align' | 'alignOffset' | 'side' | 'sideOffset'>) {
|
|
22
|
+
return (
|
|
23
|
+
<PreviewCardPrimitive.Portal data-slot="hover-card-portal">
|
|
24
|
+
<PreviewCardPrimitive.Positioner
|
|
25
|
+
align={align}
|
|
26
|
+
alignOffset={alignOffset}
|
|
27
|
+
side={side}
|
|
28
|
+
sideOffset={sideOffset}
|
|
29
|
+
className="isolate z-50"
|
|
30
|
+
>
|
|
31
|
+
<PreviewCardPrimitive.Popup
|
|
32
|
+
data-slot="hover-card-content"
|
|
33
|
+
className={cn(
|
|
34
|
+
'z-50 w-64 origin-(--transform-origin) rounded-lg bg-popover p-2.5 text-sm text-popover-foreground shadow-md ring-1 ring-foreground/10 outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95',
|
|
35
|
+
className
|
|
36
|
+
)}
|
|
37
|
+
{...props}
|
|
38
|
+
/>
|
|
39
|
+
</PreviewCardPrimitive.Positioner>
|
|
40
|
+
</PreviewCardPrimitive.Portal>
|
|
41
|
+
)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export { HoverCard, HoverCardTrigger, HoverCardContent }
|