@sqdr2/dsh-agent-studio-fusion 0.0.0-stage → 1.0.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/CHANGELOG.md +629 -0
- package/INSTALL.md +72 -0
- package/INSTALL.zh.md +73 -0
- package/LICENSE +201 -0
- package/README.en.md +207 -0
- package/README.md +207 -2
- package/RELEASING.md +136 -0
- package/RELEASING.zh.md +128 -0
- package/assets/icon.svg +10 -0
- package/assets/mermaid.min.js +3636 -0
- package/contracts/fusion.ts +422 -0
- package/contracts/storage.sql +86 -0
- package/cordis.patch.yml +3 -0
- package/docs/ATTRIBUTION-ACP.md +117 -0
- package/docs/ATTRIBUTION-AGY.md +139 -0
- package/docs/COMPATIBILITY.md +242 -0
- package/docs/EVIDENCE.md +141 -0
- package/docs/MIGRATION-ACP.md +195 -0
- package/docs/MIGRATION-AGY.md +282 -0
- package/dshx.yml +58 -0
- package/lib/assets/mermaid.min.js +3636 -0
- package/lib/bridge.mjs +138 -0
- package/lib/client.js +7130 -0
- package/lib/client.js.map +7 -0
- package/lib/dsh-agent-studio-fusion.js +26686 -0
- package/lib/types/activity.d.ts +34 -0
- package/lib/types/approval/logical.d.ts +10 -0
- package/lib/types/benchmark/naive.d.ts +37 -0
- package/lib/types/benchmark/native-run.d.ts +68 -0
- package/lib/types/benchmark/output-limits.d.ts +19 -0
- package/lib/types/bilingual.d.ts +2 -0
- package/lib/types/client/AcpSettingsGuide.d.ts +15 -0
- package/lib/types/client/ActivityRows.d.ts +8 -0
- package/lib/types/client/FusionCache.d.ts +4 -0
- package/lib/types/client/FusionHint.d.ts +9 -0
- package/lib/types/client/FusionHistory.d.ts +7 -0
- package/lib/types/client/FusionPanelIcon.d.ts +13 -0
- package/lib/types/client/FusionPermission.d.ts +15 -0
- package/lib/types/client/FusionRecovery.d.ts +5 -0
- package/lib/types/client/FusionSettings.d.ts +17 -0
- package/lib/types/client/FusionStatus.d.ts +12 -0
- package/lib/types/client/FusionTool.d.ts +4 -0
- package/lib/types/client/acp-import.d.ts +82 -0
- package/lib/types/client/activity-model.d.ts +14 -0
- package/lib/types/client/agy/AgyConsole.d.ts +42 -0
- package/lib/types/client/agy/brand-icons.d.ts +34 -0
- package/lib/types/client/agy/decisions.d.ts +23 -0
- package/lib/types/client/agy/images.d.ts +13 -0
- package/lib/types/client/agy/locale.d.ts +26 -0
- package/lib/types/client/agy/locales.d.ts +174 -0
- package/lib/types/client/agy/scroll-guard.d.ts +24 -0
- package/lib/types/client/agy/toolview.d.ts +169 -0
- package/lib/types/client/agy-activity.d.ts +49 -0
- package/lib/types/client/i18n.d.ts +15 -0
- package/lib/types/client/index.d.ts +22 -0
- package/lib/types/client/settings-events.d.ts +2 -0
- package/lib/types/client/status-polling.d.ts +13 -0
- package/lib/types/client/studio-brand.d.ts +12 -0
- package/lib/types/context/guard.d.ts +21 -0
- package/lib/types/context/handoff.d.ts +17 -0
- package/lib/types/contracts.d.ts +494 -0
- package/lib/types/digest.d.ts +5 -0
- package/lib/types/dsh-agent-studio-fusion.d.ts +27 -0
- package/lib/types/dsh-fusion.d.ts +1 -0
- package/lib/types/errors.d.ts +28 -0
- package/lib/types/evidence/gate.d.ts +23 -0
- package/lib/types/evidence/receipts.d.ts +65 -0
- package/lib/types/execution/write-lease.d.ts +42 -0
- package/lib/types/host/acp/adapter.d.ts +107 -0
- package/lib/types/host/acp/agent-process.d.ts +126 -0
- package/lib/types/host/acp/bridge-route.d.ts +13 -0
- package/lib/types/host/acp/bridge.d.ts +149 -0
- package/lib/types/host/acp/chunk-translator.d.ts +29 -0
- package/lib/types/host/acp/config.d.ts +21 -0
- package/lib/types/host/acp/context-windows.d.ts +32 -0
- package/lib/types/host/acp/host.d.ts +41 -0
- package/lib/types/host/acp/index.d.ts +33 -0
- package/lib/types/host/acp/permission.d.ts +28 -0
- package/lib/types/host/acp/prompt-capabilities.d.ts +35 -0
- package/lib/types/host/acp/request-image.d.ts +32 -0
- package/lib/types/host/acp/transcript.d.ts +33 -0
- package/lib/types/host/acp/types.d.ts +54 -0
- package/lib/types/host/agy/adapter.d.ts +347 -0
- package/lib/types/host/agy/agy-db.d.ts +67 -0
- package/lib/types/host/agy/agy-log.d.ts +13 -0
- package/lib/types/host/agy/agy-usage.d.ts +52 -0
- package/lib/types/host/agy/ask-tool.d.ts +7 -0
- package/lib/types/host/agy/atomic-write.d.ts +4 -0
- package/lib/types/host/agy/auth.d.ts +49 -0
- package/lib/types/host/agy/auto-updater.d.ts +38 -0
- package/lib/types/host/agy/commands.d.ts +39 -0
- package/lib/types/host/agy/config.d.ts +37 -0
- package/lib/types/host/agy/credential-slot.d.ts +252 -0
- package/lib/types/host/agy/diagnostics.d.ts +19 -0
- package/lib/types/host/agy/discovery.d.ts +21 -0
- package/lib/types/host/agy/dsh-goal.d.ts +43 -0
- package/lib/types/host/agy/index.d.ts +13 -0
- package/lib/types/host/agy/mapper.d.ts +145 -0
- package/lib/types/host/agy/mcp-bridge.d.ts +72 -0
- package/lib/types/host/agy/media-route.d.ts +23 -0
- package/lib/types/host/agy/media.d.ts +54 -0
- package/lib/types/host/agy/mirror-tool.d.ts +60 -0
- package/lib/types/host/agy/models.d.ts +90 -0
- package/lib/types/host/agy/net.d.ts +10 -0
- package/lib/types/host/agy/oauth.d.ts +77 -0
- package/lib/types/host/agy/oneshot.d.ts +35 -0
- package/lib/types/host/agy/parser.d.ts +42 -0
- package/lib/types/host/agy/pool-auth.d.ts +70 -0
- package/lib/types/host/agy/pool-types.d.ts +145 -0
- package/lib/types/host/agy/pool.d.ts +231 -0
- package/lib/types/host/agy/quota.d.ts +352 -0
- package/lib/types/host/agy/read-json-body.d.ts +15 -0
- package/lib/types/host/agy/recording.d.ts +199 -0
- package/lib/types/host/agy/runner.d.ts +192 -0
- package/lib/types/host/agy/sessions.d.ts +53 -0
- package/lib/types/host/agy/types.d.ts +425 -0
- package/lib/types/host/agy/warmup.d.ts +82 -0
- package/lib/types/host/agy/wincred.d.ts +35 -0
- package/lib/types/host/authority.d.ts +50 -0
- package/lib/types/host/bindings.d.ts +30 -0
- package/lib/types/host/cache-defaults.d.ts +48 -0
- package/lib/types/host/cache-policy.d.ts +165 -0
- package/lib/types/host/change-evidence.d.ts +38 -0
- package/lib/types/host/compaction-routing.d.ts +15 -0
- package/lib/types/host/coordinator.d.ts +222 -0
- package/lib/types/host/evidence-page.d.ts +13 -0
- package/lib/types/host/history.d.ts +106 -0
- package/lib/types/host/http.d.ts +4 -0
- package/lib/types/host/model-output.d.ts +13 -0
- package/lib/types/host/native-activity.d.ts +26 -0
- package/lib/types/host/native-approvals.d.ts +29 -0
- package/lib/types/host/native-auxiliary.d.ts +17 -0
- package/lib/types/host/native-budget.d.ts +33 -0
- package/lib/types/host/native-checks.d.ts +130 -0
- package/lib/types/host/native-compaction.d.ts +8 -0
- package/lib/types/host/native-context.d.ts +36 -0
- package/lib/types/host/native-effects.d.ts +120 -0
- package/lib/types/host/native-evidence.d.ts +4 -0
- package/lib/types/host/native-exploration.d.ts +15 -0
- package/lib/types/host/native-keepalive.d.ts +82 -0
- package/lib/types/host/native-model-control.d.ts +124 -0
- package/lib/types/host/native-on-demand-context.d.ts +39 -0
- package/lib/types/host/native-request.d.ts +5 -0
- package/lib/types/host/native-review.d.ts +11 -0
- package/lib/types/host/native-role-sandbox.d.ts +57 -0
- package/lib/types/host/native-scopes.d.ts +70 -0
- package/lib/types/host/native-selection.d.ts +39 -0
- package/lib/types/host/native-task-context.d.ts +39 -0
- package/lib/types/host/native-usage.d.ts +46 -0
- package/lib/types/host/native-worker-brief.d.ts +74 -0
- package/lib/types/host/native-worker-notices.d.ts +15 -0
- package/lib/types/host/native-worker.d.ts +44 -0
- package/lib/types/host/native-workflow.d.ts +41 -0
- package/lib/types/host/pairs.d.ts +47 -0
- package/lib/types/host/price-settings.d.ts +14 -0
- package/lib/types/host/read-tools.d.ts +22 -0
- package/lib/types/host/route-transport.d.ts +22 -0
- package/lib/types/host/settings.d.ts +58 -0
- package/lib/types/host/shell.d.ts +37 -0
- package/lib/types/host/status.d.ts +7 -0
- package/lib/types/host/subagent-seam.d.ts +11 -0
- package/lib/types/host/text-report.d.ts +56 -0
- package/lib/types/host/tool-table.d.ts +35 -0
- package/lib/types/host/worker-terminal.d.ts +94 -0
- package/lib/types/host/workspace-guard.d.ts +13 -0
- package/lib/types/host/workspace.d.ts +52 -0
- package/lib/types/identity.d.ts +82 -0
- package/lib/types/index.d.ts +34 -0
- package/lib/types/message-source.d.ts +35 -0
- package/lib/types/profile/compactor.d.ts +5 -0
- package/lib/types/profile/keepalive.d.ts +3 -0
- package/lib/types/profile/resolve.d.ts +17 -0
- package/lib/types/prompts.d.ts +8 -0
- package/lib/types/recovery/reconcile.d.ts +28 -0
- package/lib/types/review/dispatch.d.ts +20 -0
- package/lib/types/review/protocol.d.ts +51 -0
- package/lib/types/review/ticket.d.ts +32 -0
- package/lib/types/status.d.ts +145 -0
- package/lib/types/store-migration.d.ts +29 -0
- package/lib/types/task/deletion.d.ts +64 -0
- package/lib/types/task/reducer.d.ts +6 -0
- package/lib/types/task/sqlite-store.d.ts +71 -0
- package/lib/types/task/state.d.ts +51 -0
- package/lib/types/task/status-index.d.ts +28 -0
- package/lib/types/task/store.d.ts +48 -0
- package/lib/types/usage/budget.d.ts +27 -0
- package/lib/types/usage/cost.d.ts +77 -0
- package/lib/types/usage/ledger.d.ts +66 -0
- package/lib/types/usage/normalize.d.ts +50 -0
- package/lib/types/usage/price-cards.d.ts +65 -0
- package/lib/types/usage/pricing.d.ts +18 -0
- package/package.json +197 -4
- package/profiles/fusion-auto.example.json +45 -0
- package/prompts/compact.md +7 -0
- package/prompts/lead.md +52 -0
- package/prompts/model-lead.md +16 -0
- package/prompts/model-worker.md +9 -0
- package/prompts/worker.md +25 -0
- package/src/activity.ts +78 -0
- package/src/approval/logical.ts +44 -0
- package/src/benchmark/naive.ts +216 -0
- package/src/benchmark/native-run.ts +215 -0
- package/src/benchmark/output-limits.ts +33 -0
- package/src/bilingual.ts +2 -0
- package/src/client/AcpSettingsGuide.tsx +469 -0
- package/src/client/ActivityRows.tsx +73 -0
- package/src/client/FusionCache.tsx +130 -0
- package/src/client/FusionHint.tsx +46 -0
- package/src/client/FusionHistory.tsx +260 -0
- package/src/client/FusionPanelIcon.tsx +39 -0
- package/src/client/FusionPermission.tsx +52 -0
- package/src/client/FusionRecovery.tsx +69 -0
- package/src/client/FusionSettings.tsx +362 -0
- package/src/client/FusionStatus.tsx +138 -0
- package/src/client/FusionTool.tsx +66 -0
- package/src/client/acp-import.ts +303 -0
- package/src/client/activity-model.ts +31 -0
- package/src/client/agy/AgyConsole.tsx +2213 -0
- package/src/client/agy/brand-icons.ts +43 -0
- package/src/client/agy/decisions.ts +344 -0
- package/src/client/agy/images.ts +605 -0
- package/src/client/agy/locale.ts +75 -0
- package/src/client/agy/locales.ts +332 -0
- package/src/client/agy/scroll-guard.ts +106 -0
- package/src/client/agy/toolview.ts +1903 -0
- package/src/client/agy-activity.ts +174 -0
- package/src/client/i18n.ts +30 -0
- package/src/client/index.ts +89 -0
- package/src/client/settings-events.ts +3 -0
- package/src/client/status-polling.ts +93 -0
- package/src/client/studio-brand.ts +13 -0
- package/src/context/guard.ts +81 -0
- package/src/context/handoff.ts +28 -0
- package/src/contracts.ts +489 -0
- package/src/digest.ts +28 -0
- package/src/dsh-agent-studio-fusion.ts +480 -0
- package/src/dsh-fusion.ts +1 -0
- package/src/errors.ts +34 -0
- package/src/evidence/gate.ts +290 -0
- package/src/evidence/receipts.ts +175 -0
- package/src/execution/write-lease.ts +187 -0
- package/src/host/acp/adapter.ts +692 -0
- package/src/host/acp/agent-process.ts +621 -0
- package/src/host/acp/bridge-route.ts +29 -0
- package/src/host/acp/bridge.ts +601 -0
- package/src/host/acp/chunk-translator.ts +200 -0
- package/src/host/acp/config.ts +57 -0
- package/src/host/acp/context-windows.ts +89 -0
- package/src/host/acp/host.ts +43 -0
- package/src/host/acp/index.ts +186 -0
- package/src/host/acp/permission.ts +129 -0
- package/src/host/acp/prompt-capabilities.ts +112 -0
- package/src/host/acp/request-image.ts +68 -0
- package/src/host/acp/transcript.ts +200 -0
- package/src/host/acp/types.ts +58 -0
- package/src/host/agy/adapter.ts +2790 -0
- package/src/host/agy/agy-db.ts +682 -0
- package/src/host/agy/agy-log.ts +81 -0
- package/src/host/agy/agy-usage.ts +253 -0
- package/src/host/agy/ask-tool.ts +141 -0
- package/src/host/agy/atomic-write.ts +35 -0
- package/src/host/agy/auth.ts +267 -0
- package/src/host/agy/auto-updater.ts +127 -0
- package/src/host/agy/bridge.mjs +138 -0
- package/src/host/agy/commands.ts +628 -0
- package/src/host/agy/config.ts +261 -0
- package/src/host/agy/credential-slot.ts +1326 -0
- package/src/host/agy/diagnostics.ts +118 -0
- package/src/host/agy/discovery.ts +71 -0
- package/src/host/agy/dsh-goal.ts +248 -0
- package/src/host/agy/index.ts +1279 -0
- package/src/host/agy/mapper.ts +593 -0
- package/src/host/agy/mcp-bridge.ts +450 -0
- package/src/host/agy/media-route.ts +247 -0
- package/src/host/agy/media.ts +163 -0
- package/src/host/agy/mirror-tool.ts +756 -0
- package/src/host/agy/models.ts +404 -0
- package/src/host/agy/net.ts +54 -0
- package/src/host/agy/oauth.ts +366 -0
- package/src/host/agy/oneshot.ts +198 -0
- package/src/host/agy/parser.ts +330 -0
- package/src/host/agy/pool-auth.ts +304 -0
- package/src/host/agy/pool-types.ts +204 -0
- package/src/host/agy/pool.ts +1050 -0
- package/src/host/agy/quota.ts +1420 -0
- package/src/host/agy/read-json-body.ts +70 -0
- package/src/host/agy/recording.ts +447 -0
- package/src/host/agy/runner.ts +830 -0
- package/src/host/agy/sessions.ts +153 -0
- package/src/host/agy/types.ts +657 -0
- package/src/host/agy/warmup.ts +614 -0
- package/src/host/agy/wincred.ts +354 -0
- package/src/host/authority.ts +231 -0
- package/src/host/bindings.ts +91 -0
- package/src/host/cache-defaults.ts +103 -0
- package/src/host/cache-policy.ts +180 -0
- package/src/host/change-evidence.ts +156 -0
- package/src/host/compaction-routing.ts +46 -0
- package/src/host/coordinator.ts +2675 -0
- package/src/host/evidence-page.ts +25 -0
- package/src/host/history.ts +180 -0
- package/src/host/http.ts +30 -0
- package/src/host/model-output.ts +22 -0
- package/src/host/native-activity.ts +205 -0
- package/src/host/native-approvals.ts +196 -0
- package/src/host/native-auxiliary.ts +19 -0
- package/src/host/native-budget.ts +112 -0
- package/src/host/native-checks.ts +562 -0
- package/src/host/native-compaction.ts +34 -0
- package/src/host/native-context.ts +204 -0
- package/src/host/native-effects.ts +379 -0
- package/src/host/native-evidence.ts +31 -0
- package/src/host/native-exploration.ts +114 -0
- package/src/host/native-keepalive.ts +292 -0
- package/src/host/native-model-control.ts +343 -0
- package/src/host/native-on-demand-context.ts +74 -0
- package/src/host/native-request.ts +12 -0
- package/src/host/native-review.ts +51 -0
- package/src/host/native-role-sandbox.ts +183 -0
- package/src/host/native-scopes.ts +255 -0
- package/src/host/native-selection.ts +154 -0
- package/src/host/native-task-context.ts +264 -0
- package/src/host/native-usage.ts +121 -0
- package/src/host/native-worker-brief.ts +135 -0
- package/src/host/native-worker-notices.ts +72 -0
- package/src/host/native-worker.ts +215 -0
- package/src/host/native-workflow.ts +103 -0
- package/src/host/pairs.ts +180 -0
- package/src/host/price-settings.ts +27 -0
- package/src/host/read-tools.ts +34 -0
- package/src/host/route-transport.ts +54 -0
- package/src/host/settings.ts +126 -0
- package/src/host/shell.ts +42 -0
- package/src/host/status.ts +181 -0
- package/src/host/subagent-seam.ts +21 -0
- package/src/host/text-report.ts +124 -0
- package/src/host/tool-table.ts +56 -0
- package/src/host/worker-terminal.ts +145 -0
- package/src/host/workspace-guard.ts +17 -0
- package/src/host/workspace.ts +184 -0
- package/src/identity.ts +117 -0
- package/src/index.ts +50 -0
- package/src/message-source.ts +33 -0
- package/src/profile/compactor.ts +26 -0
- package/src/profile/keepalive.ts +13 -0
- package/src/profile/resolve.ts +131 -0
- package/src/prompts.ts +32 -0
- package/src/recovery/reconcile.ts +38 -0
- package/src/review/dispatch.ts +48 -0
- package/src/review/protocol.ts +212 -0
- package/src/review/ticket.ts +166 -0
- package/src/status.ts +113 -0
- package/src/store-migration.ts +65 -0
- package/src/task/deletion.ts +105 -0
- package/src/task/reducer.ts +684 -0
- package/src/task/sqlite-store.ts +386 -0
- package/src/task/state.ts +72 -0
- package/src/task/status-index.ts +198 -0
- package/src/task/store.ts +287 -0
- package/src/usage/budget.ts +88 -0
- package/src/usage/cost.ts +194 -0
- package/src/usage/ledger.ts +218 -0
- package/src/usage/normalize.ts +308 -0
- package/src/usage/price-cards.ts +122 -0
- package/src/usage/pricing.ts +95 -0
|
@@ -0,0 +1,1903 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Native tool-card toolviews for the built-in Antigravity route.
|
|
3
|
+
*
|
|
4
|
+
* Ported from dsh-agy-worker (`src/client/toolview.ts`), MIT License,
|
|
5
|
+
* Copyright (c) 2026 dsh-agy-worker contributors; dsh-agy-worker is a fork of
|
|
6
|
+
* dsh-agy-link (https://github.com/amlyczz/dsh-agy-link). See
|
|
7
|
+
* docs/ATTRIBUTION-AGY.md.
|
|
8
|
+
*
|
|
9
|
+
* Two keyed `tool.call.toolview` views, exactly as upstream registered them:
|
|
10
|
+
* - `agy_tool` — the mirror step a bridge route reports under its transport;
|
|
11
|
+
* - `run_code` — Code Mode's wrapper. A keyed entry REPLACES the Host's
|
|
12
|
+
* generic code row, so the wrapper case is recognized with the
|
|
13
|
+
* same strict parser Fusion uses for its own activity
|
|
14
|
+
* (`mirrorStepInvocation`) and everything else renders as an
|
|
15
|
+
* ordinary code card through {@link AgyCodeToolView}.
|
|
16
|
+
* Every other registration the standalone plugin made is absent: Fusion keeps
|
|
17
|
+
* its own `main` / `sidebar.panellist` entries and its own activity cards.
|
|
18
|
+
*
|
|
19
|
+
* Presentation matches the official DSH tool row and card:
|
|
20
|
+
* - Collapsed state: clean, borderless 24px row with official tool SVG icon,
|
|
21
|
+
* tool title, separator dot, and summary/preview.
|
|
22
|
+
* - Mouse hover on small icon: smoothly transitions to the chevron down arrow.
|
|
23
|
+
* - Expanded state: leading icon is the chevron down arrow.
|
|
24
|
+
* - Expanded card: rounded 12px card with header (prompt/cwd/path + Copy button)
|
|
25
|
+
* and scrollable content (max-height with custom scrollbars) for long outputs.
|
|
26
|
+
*/
|
|
27
|
+
import * as React from 'react';
|
|
28
|
+
import { mirrorStepInvocation } from '../../activity.js';
|
|
29
|
+
import { insertTextIntoChatComposer } from './decisions.js';
|
|
30
|
+
import { openLightbox, isImageFile, buildMediaUrl } from './images.js';
|
|
31
|
+
|
|
32
|
+
type ReactApi = {
|
|
33
|
+
createElement: (type: unknown, props?: Record<string, unknown> | null, ...children: unknown[]) => unknown;
|
|
34
|
+
useState: <S>(initial: S) => [S, (next: S | ((prev: S) => S)) => void];
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* The React surface these cards use. Upstream read it through the module
|
|
39
|
+
* loader's `require` shim; the Fusion bundle imports React directly, so the
|
|
40
|
+
* shim is the same object — the call sites stay verbatim.
|
|
41
|
+
*/
|
|
42
|
+
function react(): ReactApi {
|
|
43
|
+
return React as unknown as ReactApi;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function makeToggle(setValue: (next: boolean | ((prev: boolean) => boolean)) => void): () => void {
|
|
47
|
+
return () => setValue((prev: boolean) => !prev);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Cache user-expanded tool cards across TanStack Virtualizer remount cycles */
|
|
51
|
+
const expandedToolBlockKeys = new Set<string>();
|
|
52
|
+
|
|
53
|
+
export function clearExpandedToolBlockKeysForTest(): void {
|
|
54
|
+
expandedToolBlockKeys.clear();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function useToggle(initial: boolean = false, key?: string): [boolean, () => void] {
|
|
58
|
+
const R2 = react();
|
|
59
|
+
const init = key ? expandedToolBlockKeys.has(key) : initial;
|
|
60
|
+
const [value, setValue] = R2.useState<boolean>(init) as [boolean, (next: boolean | ((prev: boolean) => boolean)) => void];
|
|
61
|
+
const toggle = () => {
|
|
62
|
+
setValue((prev: boolean) => {
|
|
63
|
+
const next = !prev;
|
|
64
|
+
if (key) {
|
|
65
|
+
if (next) expandedToolBlockKeys.add(key);
|
|
66
|
+
else expandedToolBlockKeys.delete(key);
|
|
67
|
+
}
|
|
68
|
+
return next;
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
return [value, toggle];
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function hx(type: unknown, props?: Record<string, unknown> | null, ...children: unknown[]): unknown {
|
|
75
|
+
return react().createElement(type, props, ...children);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// ---- Official DSH SVGs (100% faithful to native DSH client-ui) ----------
|
|
79
|
+
|
|
80
|
+
export function IconChevronDownOutline14(size = 14, className = ''): unknown {
|
|
81
|
+
return hx('svg', {
|
|
82
|
+
width: size,
|
|
83
|
+
height: size,
|
|
84
|
+
className: className || undefined,
|
|
85
|
+
viewBox: '0 0 14 14',
|
|
86
|
+
fill: 'none',
|
|
87
|
+
style: { display: 'block', flexShrink: 0 },
|
|
88
|
+
'aria-hidden': true,
|
|
89
|
+
}, hx('path', {
|
|
90
|
+
d: 'M11.8486 5.5L11.4238 5.92383L8.69727 8.65137C8.44157 8.90706 8.21562 9.13382 8.01172 9.29785C7.79912 9.46883 7.55595 9.61756 7.25 9.66602C7.08435 9.69222 6.91565 9.69222 6.75 9.66602C6.44405 9.61756 6.20088 9.46883 5.98828 9.29785C5.78438 9.13382 5.55843 8.90706 5.30273 8.65137L2.57617 5.92383L2.15137 5.5L3 4.65137L3.42383 5.07617L6.15137 7.80273C6.42595 8.07732 6.59876 8.24849 6.74023 8.3623C6.87291 8.46904 6.92272 8.47813 6.9375 8.48047C6.97895 8.48703 7.02105 8.48703 7.0625 8.48047C7.07728 8.47813 7.12709 8.46904 7.25977 8.3623C7.40124 8.24849 7.57405 8.07732 7.84863 7.80273L10.5762 5.07617L11 4.65137L11.8486 5.5Z',
|
|
91
|
+
fill: 'currentColor',
|
|
92
|
+
}));
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export function IconApiOutline14(size = 14, className = ''): unknown {
|
|
96
|
+
return hx('svg', {
|
|
97
|
+
width: size,
|
|
98
|
+
height: size,
|
|
99
|
+
className: className || undefined,
|
|
100
|
+
viewBox: '0 0 14 14',
|
|
101
|
+
fill: 'none',
|
|
102
|
+
style: { display: 'block', flexShrink: 0 },
|
|
103
|
+
'aria-hidden': true,
|
|
104
|
+
},
|
|
105
|
+
hx('path', {
|
|
106
|
+
transform: 'translate(0.6689 1.073)',
|
|
107
|
+
d: 'M11.4818 5.57813C11.4818 4.45301 11.4807 3.66237 11.4075 3.05908C11.3359 2.46953 11.2024 2.13852 10.9939 1.89441C10.9247 1.81341 10.8493 1.73801 10.7683 1.66882C10.5242 1.46033 10.1932 1.32686 9.60364 1.25525C9.00034 1.18198 8.20974 1.18091 7.0846 1.18091L5.57813 1.18091C4.45301 1.18091 3.66238 1.18198 3.05908 1.25525C2.46953 1.32686 2.13852 1.46033 1.89441 1.66882C1.81341 1.73801 1.73801 1.81341 1.66882 1.89441C1.46033 2.13852 1.32686 2.46953 1.25525 3.05908C1.18198 3.66238 1.18091 4.45301 1.18091 5.57813L1.18091 6.2771C1.18091 7.40218 1.18197 8.19288 1.25525 8.79614C1.32687 9.38553 1.46036 9.71674 1.66882 9.96082C1.73797 10.0417 1.81347 10.1173 1.89441 10.1864C2.13851 10.3948 2.46965 10.5275 3.05908 10.5991C3.66238 10.6724 4.45298 10.6735 5.57813 10.6735L7.0846 10.6735C8.20977 10.6735 9.00033 10.6724 9.60364 10.5991C10.1931 10.5275 10.5242 10.3948 10.7683 10.1864C10.8493 10.1173 10.9247 10.0417 10.9939 9.96082C11.2024 9.71674 11.3358 9.38553 11.4075 8.79614C11.4808 8.19288 11.4818 7.40218 11.4818 6.2771L11.4818 5.57813ZM12.6627 6.2771C12.6627 7.37222 12.6637 8.247 12.5798 8.93799C12.4942 9.64284 12.3133 10.2359 11.8928 10.7282C11.7834 10.8562 11.6637 10.9751 11.5356 11.0845C11.0434 11.5049 10.4511 11.6867 9.74634 11.7723C9.05525 11.8563 8.17999 11.8552 7.0846 11.8552L5.57813 11.8552C4.48273 11.8552 3.60747 11.8563 2.91638 11.7723C2.21157 11.6867 1.61933 11.5049 1.12708 11.0845C0.99901 10.9751 0.879281 10.8562 0.769898 10.7282C0.349454 10.2359 0.168506 9.64284 0.0828864 8.93799C-0.00101964 8.247 4.88512e-07 7.37222 6.47206e-07 6.2771L6.47206e-07 5.57813C6.47206e-07 4.48273 -0.00106163 3.60747 0.0828864 2.91638C0.168502 2.21168 0.349594 1.61928 0.769898 1.12708C0.879302 0.998981 0.998981 0.879302 1.12708 0.769898C1.61928 0.349594 2.21168 0.168502 2.91638 0.0828864C3.60747 -0.00106163 4.48273 6.47206e-07 5.57813 6.47206e-07L7.0846 6.47206e-07C8.17999 6.47206e-07 9.05525 -0.00106163 9.74634 0.0828864C10.451 0.168505 11.0434 0.349587 11.5356 0.769898C11.6637 0.879302 11.7834 0.998981 11.8928 1.12708C12.3131 1.61928 12.4942 2.21169 12.5798 2.91638C12.6638 3.60747 12.6627 4.48273 12.6627 5.57813L12.6627 6.2771Z',
|
|
108
|
+
fill: 'currentColor',
|
|
109
|
+
}),
|
|
110
|
+
hx('path', {
|
|
111
|
+
transform: 'translate(0.6689 1.073)',
|
|
112
|
+
d: 'M6.02607 5.50955L6.44306 5.9274L3.84284 8.52762L3.425 8.11063L3.00715 7.69278L4.77253 5.9274L3.00715 4.16202L3.84284 3.32633L6.02607 5.50955Z',
|
|
113
|
+
fill: 'currentColor',
|
|
114
|
+
}),
|
|
115
|
+
hx('path', {
|
|
116
|
+
transform: 'translate(0.6689 1.073)',
|
|
117
|
+
d: 'M9.23789 7.35397L9.23789 8.53488L6.96238 8.53488L6.96238 7.35397L9.23789 7.35397Z',
|
|
118
|
+
fill: 'currentColor',
|
|
119
|
+
}),
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export function IconEditOutline16(size = 14, className = ''): unknown {
|
|
124
|
+
return hx('svg', {
|
|
125
|
+
width: size,
|
|
126
|
+
height: size,
|
|
127
|
+
className: className || undefined,
|
|
128
|
+
viewBox: '0 0 16 16',
|
|
129
|
+
fill: 'none',
|
|
130
|
+
style: { display: 'block', flexShrink: 0 },
|
|
131
|
+
'aria-hidden': true,
|
|
132
|
+
}, hx('path', {
|
|
133
|
+
d: 'M9.94076 1.34942C10.7047 0.90231 11.6503 0.902415 12.4143 1.34942C12.7061 1.52015 12.9688 1.79118 13.3104 2.13284C13.6521 2.47448 13.9231 2.73721 14.0939 3.02894C14.5408 3.79294 14.5409 4.73856 14.0939 5.50251C13.9231 5.79415 13.652 6.05704 13.3104 6.39861L6.65932 13.0497C6.28068 13.4284 6.00695 13.7108 5.66543 13.9097C5.32391 14.1085 4.94315 14.2074 4.42705 14.3498L3.24394 14.6761C2.77527 14.8054 2.34538 14.9262 2.00131 14.9684C1.65196 15.0112 1.17964 15.0013 0.810764 14.6325C0.441921 14.2637 0.432107 13.7913 0.47486 13.442C0.517035 13.0979 0.6379 12.668 0.767181 12.1993L1.09352 11.0162C1.23588 10.5001 1.33481 10.1193 1.5336 9.77784C1.7325 9.43632 2.0149 9.1626 2.39355 8.78395L9.04466 2.13284C9.38625 1.79126 9.64911 1.52016 9.94076 1.34942ZM15.5427 14.8398H7.55223L8.96707 13.425H15.5427V14.8398ZM3.39382 9.78422C2.965 10.213 2.84244 10.3436 2.75709 10.49C2.67183 10.6366 2.61862 10.8079 2.45733 11.3925L2.13099 12.5756C2.00183 13.0439 1.92194 13.3419 1.88863 13.5536C2.10041 13.5204 2.39872 13.4416 2.86764 13.3123L4.05075 12.9859C4.63544 12.8246 4.80669 12.7715 4.95323 12.6862C5.09968 12.6008 5.23022 12.4783 5.65905 12.0494L10.721 6.98644L8.45577 4.72121L3.39382 9.78422ZM11.7 2.57079C11.3774 2.38198 10.9777 2.38198 10.6551 2.57079C10.5602 2.62647 10.4487 2.72931 10.0449 3.13311L9.45604 3.72094L11.7213 5.98617L12.3102 5.39833C12.7139 4.99457 12.8168 4.88307 12.8725 4.78818C13.0613 4.46561 13.0612 4.06585 12.8725 3.74326C12.8169 3.64827 12.7146 3.53752 12.3102 3.13311C11.9057 2.72863 11.795 2.6264 11.7 2.57079Z',
|
|
134
|
+
fill: 'currentColor',
|
|
135
|
+
}));
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export function IconBrowseOutline16(size = 14, className = ''): unknown {
|
|
139
|
+
return hx('svg', {
|
|
140
|
+
width: size,
|
|
141
|
+
height: size,
|
|
142
|
+
className: className || undefined,
|
|
143
|
+
viewBox: '0 0 16 16',
|
|
144
|
+
fill: 'none',
|
|
145
|
+
style: { display: 'block', flexShrink: 0 },
|
|
146
|
+
'aria-hidden': true,
|
|
147
|
+
},
|
|
148
|
+
hx('path', { d: 'M11.2426 4.80473V6.10551H4.75819V4.80473H11.2426Z', fill: 'currentColor' }),
|
|
149
|
+
hx('path', { d: 'M9.40858 7.84478V9.14557H4.75819V7.84478H9.40858Z', fill: 'currentColor' }),
|
|
150
|
+
hx('path', {
|
|
151
|
+
d: 'M9.23438 0.546389C10.1941 0.546389 10.9683 0.544914 11.5859 0.611819C12.2161 0.680096 12.7634 0.825745 13.2393 1.17139C13.5172 1.3733 13.7619 1.61812 13.9639 1.896C14.3096 2.37183 14.4551 2.91922 14.5234 3.54932C14.5903 4.16686 14.5889 4.94133 14.5889 5.90088V10.0981C14.5889 11.0576 14.5903 11.8321 14.5234 12.4497C14.4552 13.0798 14.3094 13.6272 13.9639 14.103C13.7619 14.381 13.5172 14.6257 13.2393 14.8276C12.7633 15.1734 12.2163 15.3189 11.5859 15.3872C10.9683 15.4541 10.1942 15.4536 9.23438 15.4536H6.76563C5.80591 15.4536 5.03168 15.4541 4.41407 15.3872C3.78385 15.3189 3.23665 15.1734 2.76074 14.8276C2.48291 14.6257 2.23802 14.3809 2.03614 14.103C1.69066 13.6272 1.54483 13.0798 1.47657 12.4497C1.40973 11.8321 1.41114 11.0576 1.41114 10.0981V5.90088C1.41113 4.94132 1.40966 4.16686 1.47657 3.54932C1.54488 2.91921 1.69042 2.37184 2.03614 1.896C2.2381 1.61807 2.4828 1.37333 2.76074 1.17139C3.23665 0.825682 3.78386 0.680109 4.41407 0.611819C5.03168 0.544905 5.80591 0.546389 6.76563 0.546389H9.23438ZM6.76563 1.896C5.77586 1.896 5.0876 1.89738 4.55957 1.95459C4.0443 2.01043 3.76214 2.11349 3.55469 2.26416C3.39135 2.38284 3.24761 2.52662 3.12891 2.68994C2.97821 2.89736 2.8752 3.17967 2.81934 3.69483C2.76214 4.22279 2.76075 4.91131 2.76074 5.90088V10.0981C2.76074 11.0876 2.76221 11.7762 2.81934 12.3042C2.87516 12.8194 2.97829 13.1026 3.12891 13.3101C3.24754 13.4733 3.39147 13.6172 3.55469 13.7358C3.76213 13.8865 4.04438 13.9896 4.55957 14.0454C5.0876 14.1026 5.77586 14.103 6.76563 14.103H9.23438C10.2242 14.103 10.9124 14.1026 11.4404 14.0454C11.9556 13.9896 12.2379 13.8865 12.4453 13.7358C12.6086 13.6172 12.7525 13.4733 12.8711 13.3101C13.0217 13.1026 13.1248 12.8195 13.1807 12.3042C13.2378 11.7762 13.2393 11.0876 13.2393 10.0981V5.90088C13.2393 4.91131 13.2379 4.22279 13.1807 3.69483C13.1248 3.17969 13.0218 2.89736 12.8711 2.68994C12.7524 2.52667 12.6086 2.38281 12.4453 2.26416C12.2379 2.11355 11.9556 2.01041 11.4404 1.95459C10.9124 1.8974 10.2241 1.896 9.23438 1.896H6.76563Z',
|
|
152
|
+
fill: 'currentColor',
|
|
153
|
+
}),
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export function IconSearchOutline16(size = 14, className = ''): unknown {
|
|
158
|
+
return hx('svg', {
|
|
159
|
+
width: size,
|
|
160
|
+
height: size,
|
|
161
|
+
className: className || undefined,
|
|
162
|
+
viewBox: '0 0 16 16',
|
|
163
|
+
fill: 'none',
|
|
164
|
+
style: { display: 'block', flexShrink: 0 },
|
|
165
|
+
'aria-hidden': true,
|
|
166
|
+
},
|
|
167
|
+
hx('path', {
|
|
168
|
+
d: 'M11.894845 6.647401C11.894845 3.725463 9.534486 1.356779 6.623219 1.35657C3.711786 1.35657 1.351635 3.725338 1.351635 6.647401C1.351843 9.569296 3.711911 11.938273 6.623219 11.938273C9.534361 11.938064 11.894637 9.569171 11.894845 6.647401ZM13.245462 6.647401C13.245254 10.317935 10.280401 13.293613 6.623219 13.293821C2.965871 13.293821 0.000204 10.31806 0 6.647401C0 2.976574 2.965746 0 6.623219 0C10.280526 0.000205 13.245462 2.9767 13.245462 6.647401Z',
|
|
169
|
+
fill: 'currentColor',
|
|
170
|
+
}),
|
|
171
|
+
hx('path', {
|
|
172
|
+
d: 'M16.000417 15.041079L15.044449 16.000433L11.530434 12.473588L12.486298 11.514234L16.000417 15.041079Z',
|
|
173
|
+
fill: 'currentColor',
|
|
174
|
+
}),
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export function IconCodeOutline16(size = 14, className = ''): unknown {
|
|
179
|
+
return hx('svg', {
|
|
180
|
+
width: size,
|
|
181
|
+
height: size,
|
|
182
|
+
className: className || undefined,
|
|
183
|
+
viewBox: '0 0 16 16',
|
|
184
|
+
fill: 'none',
|
|
185
|
+
style: { display: 'block', flexShrink: 0 },
|
|
186
|
+
'aria-hidden': true,
|
|
187
|
+
}, hx('path', {
|
|
188
|
+
fillRule: 'evenodd',
|
|
189
|
+
clipRule: 'evenodd',
|
|
190
|
+
d: 'M12.3368 1.53569L11.931 4.43172H14.8086V5.79673H11.7404L11.1962 9.67859H14.2839V11.0436H11.0056L10.4994 14.6529L9.14873 14.4643L9.62731 11.0436H5.75876L5.25252 14.6529L3.90186 14.4643L4.38043 11.0436H1.69141V9.67859H4.57104L5.11417 5.79673H2.21609V4.43172H5.30581L5.73724 1.34713L7.08995 1.53569L6.68414 4.43172H10.5527L10.9841 1.34713L12.3368 1.53569ZM5.94937 9.67859H9.81791L10.361 5.79673H6.49353L5.94937 9.67859Z',
|
|
191
|
+
fill: 'currentColor',
|
|
192
|
+
}));
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export function IconInspectOutline12(size = 12, className = ''): unknown {
|
|
196
|
+
return hx('svg', {
|
|
197
|
+
width: size,
|
|
198
|
+
height: size,
|
|
199
|
+
className: className || undefined,
|
|
200
|
+
viewBox: '0 0 16 16',
|
|
201
|
+
fill: 'none',
|
|
202
|
+
style: { display: 'inline-block', verticalAlign: '-1.5px', flexShrink: 0 },
|
|
203
|
+
'aria-hidden': true,
|
|
204
|
+
}, hx('path', {
|
|
205
|
+
d: 'M16 8L10.8571 12V10.552L14.1383 8L10.8571 5.448V4L16 8ZM5.14286 10.552L1.86171 8L5.14286 5.448V4L0 8L5.14286 12V10.552ZM9.02514 4L5.59657 12H6.84057L10.2691 4H9.02514Z',
|
|
206
|
+
fill: 'currentColor',
|
|
207
|
+
}));
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export function IconCopyOutline16(size = 12, className = ''): unknown {
|
|
211
|
+
return hx('svg', {
|
|
212
|
+
width: size,
|
|
213
|
+
height: size,
|
|
214
|
+
className: className || undefined,
|
|
215
|
+
viewBox: '0 0 16 16',
|
|
216
|
+
fill: 'none',
|
|
217
|
+
style: { display: 'inline-block', verticalAlign: '-1.5px', flexShrink: 0 },
|
|
218
|
+
'aria-hidden': true,
|
|
219
|
+
}, hx('path', {
|
|
220
|
+
d: 'M6.14929 4.02032C7.11197 4.02032 7.87983 4.02016 8.49597 4.07598C9.12128 4.13269 9.65792 4.25188 10.1415 4.53106C10.7202 4.8653 11.2008 5.3459 11.535 5.92462C11.8142 6.40818 11.9334 6.94481 11.9901 7.57012C12.0459 8.18625 12.0458 8.95419 12.0458 9.9168C12.0458 10.8795 12.0459 11.6473 11.9901 12.2635C11.9334 12.8888 11.8142 13.4254 11.535 13.909C11.2008 14.4877 10.7202 14.9683 10.1415 15.3025C9.65792 15.5817 9.12128 15.7009 8.49597 15.7576C7.87984 15.8134 7.11196 15.8133 6.14929 15.8133C5.18667 15.8133 4.41874 15.8134 3.80261 15.7576C3.1773 15.7009 2.64067 15.5817 2.1571 15.3025C1.5784 14.9683 1.09778 14.4877 0.76355 13.909',
|
|
221
|
+
fill: 'currentColor',
|
|
222
|
+
}));
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
export function IconCheckOutline14(size = 12, className = ''): unknown {
|
|
226
|
+
return hx('svg', {
|
|
227
|
+
width: size,
|
|
228
|
+
height: size,
|
|
229
|
+
className: className || undefined,
|
|
230
|
+
viewBox: '0 0 14 14',
|
|
231
|
+
fill: 'none',
|
|
232
|
+
style: { display: 'inline-block', verticalAlign: '-1.5px', flexShrink: 0 },
|
|
233
|
+
'aria-hidden': true,
|
|
234
|
+
}, hx('path', {
|
|
235
|
+
d: 'M11.5635 4.58984L7.61426 9.07715C7.35154 9.37561 7.11346 9.64812 6.89453 9.84668C6.66593 10.054 6.38519 10.2506 6.01465 10.3164C5.82079 10.3508 5.62207 10.3529 5.42773 10.3213C5.0561 10.2609 4.77266 10.0674 4.54102 9.86328C4.31926 9.66791 4.07752 9.39911 3.81055 9.10449L2.44531 7.59863L3.55664 6.59082L4.92188 8.09766C5.21256 8.41844 5.38878 8.61191 5.53223 8.73828C5.61022 8.80699 5.65253 8.83192 5.66895 8.83984C5.69648 8.84429 5.72449 8.84467 5.75195 8.83984C5.72657 8.84451 5.75564 8.85422 5.88672 8.73535C6.02833 8.60692 6.20225 8.41088 6.48828 8.08594L10.4385 3.59961L11.5635 4.58984Z',
|
|
236
|
+
fill: 'currentColor',
|
|
237
|
+
}));
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
export function IconQuestionOutline16(size = 14, className = ''): unknown {
|
|
241
|
+
return hx('svg', {
|
|
242
|
+
width: size,
|
|
243
|
+
height: size,
|
|
244
|
+
className: className || undefined,
|
|
245
|
+
viewBox: '0 0 16 16',
|
|
246
|
+
fill: 'none',
|
|
247
|
+
style: { display: 'block', flexShrink: 0 },
|
|
248
|
+
'aria-hidden': true,
|
|
249
|
+
}, hx('path', {
|
|
250
|
+
d: 'M8 1C4.134 1 1 3.91 1 7.5c0 1.547.575 2.973 1.559 4.093L1.13 14.54a.5.5 0 00.627.63l3.238-1.079C5.875 14.316 6.91 14.5 8 14.5c3.866 0 7-2.91 7-6.5S11.866 1 8 1zm0 10.5a.75.75 0 110-1.5.75.75 0 010 1.5zm1.09-3.41c-.42.34-.59.54-.59.91H7.5v-.5c0-.66.36-1.12.82-1.48.44-.35.68-.61.68-1.02 0-.55-.45-1-1-1s-1 .45-1 1H6c0-1.1.9-2 2-2s2 .9 2 2c0 .73-.39 1.25-.91 1.67z',
|
|
251
|
+
fill: 'currentColor',
|
|
252
|
+
}));
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
export function IconImageOutline16(size = 14, className = ''): unknown {
|
|
256
|
+
return hx('svg', {
|
|
257
|
+
width: size,
|
|
258
|
+
height: size,
|
|
259
|
+
className: className || undefined,
|
|
260
|
+
viewBox: '0 0 16 16',
|
|
261
|
+
fill: 'none',
|
|
262
|
+
style: { display: 'block', flexShrink: 0 },
|
|
263
|
+
'aria-hidden': true,
|
|
264
|
+
}, hx('path', {
|
|
265
|
+
d: 'M14 3H2a1 1 0 00-1 1v8a1 1 0 001 1h12a1 1 0 001-1V4a1 1 0 00-1-1zm-1 8H3l2.5-3.2 1.8 2.3 2.7-3.5L13 11zM5.5 6a1.5 1.5 0 110-3 1.5 1.5 0 010 3z',
|
|
266
|
+
fill: 'currentColor',
|
|
267
|
+
}));
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
function toolIconFor(kind: CardKind, size = 14): unknown {
|
|
271
|
+
switch (kind) {
|
|
272
|
+
case 'terminal':
|
|
273
|
+
return IconApiOutline14(size);
|
|
274
|
+
case 'diff':
|
|
275
|
+
case 'delete':
|
|
276
|
+
return IconEditOutline16(size);
|
|
277
|
+
case 'read':
|
|
278
|
+
return IconBrowseOutline16(size);
|
|
279
|
+
case 'search':
|
|
280
|
+
case 'list':
|
|
281
|
+
return IconSearchOutline16(size);
|
|
282
|
+
case 'question':
|
|
283
|
+
return IconQuestionOutline16(size);
|
|
284
|
+
case 'image':
|
|
285
|
+
return IconImageOutline16(size);
|
|
286
|
+
default:
|
|
287
|
+
return IconCodeOutline16(size);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
// ---- Structural types -----------------------------------------------------
|
|
292
|
+
|
|
293
|
+
type ToolResultBlock = {
|
|
294
|
+
call: { name: string; argsRaw: string } | null;
|
|
295
|
+
content: readonly { type?: string; text?: string }[];
|
|
296
|
+
isError: boolean;
|
|
297
|
+
error?: { name?: string; code?: string };
|
|
298
|
+
parentCallId?: string;
|
|
299
|
+
subCalls?: readonly unknown[];
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
type RunningCallBlock = {
|
|
303
|
+
name: string;
|
|
304
|
+
argsRaw: string;
|
|
305
|
+
parentCallId?: string;
|
|
306
|
+
subCalls?: readonly unknown[];
|
|
307
|
+
call?: { name: string; argsRaw: string };
|
|
308
|
+
};
|
|
309
|
+
|
|
310
|
+
export type ToolBlock = (ToolResultBlock | RunningCallBlock) & { kind?: string };
|
|
311
|
+
|
|
312
|
+
export interface AgyToolViewProps {
|
|
313
|
+
callId: string;
|
|
314
|
+
toolName: string;
|
|
315
|
+
block: ToolBlock;
|
|
316
|
+
cwd?: string;
|
|
317
|
+
home?: string;
|
|
318
|
+
openFile?: (path: string, opts?: unknown) => void;
|
|
319
|
+
inspect?: () => void;
|
|
320
|
+
loadImage?: unknown;
|
|
321
|
+
/** Standard locale seat, supplied when the registration declares a namespace. */
|
|
322
|
+
t?: (key: string, params?: Record<string, unknown>) => string;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
// ---- argument parsing -----------------------------------------------------
|
|
326
|
+
|
|
327
|
+
function parsedArgsRaw(block: ToolBlock): string {
|
|
328
|
+
const settled = block as ToolResultBlock;
|
|
329
|
+
if ('call' in settled && settled.call !== null && typeof settled.call.argsRaw === 'string') {
|
|
330
|
+
return settled.call.argsRaw;
|
|
331
|
+
}
|
|
332
|
+
const running = block as RunningCallBlock;
|
|
333
|
+
if (typeof running.argsRaw === 'string') return running.argsRaw;
|
|
334
|
+
return '';
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
function parseArgs(block: ToolBlock): Record<string, unknown> | null {
|
|
338
|
+
const raw = parsedArgsRaw(block);
|
|
339
|
+
if (raw === '') return null;
|
|
340
|
+
try {
|
|
341
|
+
const v = JSON.parse(raw) as unknown;
|
|
342
|
+
return typeof v === 'object' && v !== null && !Array.isArray(v) ? (v as Record<string, unknown>) : null;
|
|
343
|
+
} catch {
|
|
344
|
+
return null;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
function cleanString(val: unknown): string {
|
|
349
|
+
if (typeof val !== 'string') return '';
|
|
350
|
+
let s = val.trim();
|
|
351
|
+
if ((s.startsWith('"') && s.endsWith('"')) || (s.startsWith("'") && s.endsWith("'"))) {
|
|
352
|
+
s = s.slice(1, -1).trim();
|
|
353
|
+
}
|
|
354
|
+
return s;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
function parseInnerArgs(raw: unknown): Record<string, unknown> {
|
|
358
|
+
if (raw === undefined || raw === null) return {};
|
|
359
|
+
if (typeof raw === 'object' && !Array.isArray(raw)) return raw as Record<string, unknown>;
|
|
360
|
+
if (typeof raw === 'string') {
|
|
361
|
+
let s = raw.trim();
|
|
362
|
+
if ((s.startsWith('"') && s.endsWith('"')) || (s.startsWith("'") && s.endsWith("'"))) {
|
|
363
|
+
try {
|
|
364
|
+
const unquoted = JSON.parse(s) as unknown;
|
|
365
|
+
if (typeof unquoted === 'string') s = unquoted.trim();
|
|
366
|
+
} catch {
|
|
367
|
+
// ignore
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
try {
|
|
371
|
+
const parsed = JSON.parse(s) as unknown;
|
|
372
|
+
if (typeof parsed === 'object' && parsed !== null && !Array.isArray(parsed)) {
|
|
373
|
+
return parsed as Record<string, unknown>;
|
|
374
|
+
}
|
|
375
|
+
return { value: parsed };
|
|
376
|
+
} catch {
|
|
377
|
+
return { value: raw };
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
return { value: raw };
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
function cleanResultText(text: string): string {
|
|
384
|
+
const trimmed = text.trim();
|
|
385
|
+
if (trimmed.startsWith('{') && trimmed.endsWith('}')) {
|
|
386
|
+
try {
|
|
387
|
+
const obj = JSON.parse(trimmed) as { content?: unknown };
|
|
388
|
+
if (Array.isArray(obj?.content)) {
|
|
389
|
+
const parts: string[] = [];
|
|
390
|
+
for (const item of obj.content) {
|
|
391
|
+
const blk = item as { type?: string; text?: unknown };
|
|
392
|
+
if (blk?.type === 'text' && typeof blk.text === 'string') {
|
|
393
|
+
parts.push(blk.text);
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
if (parts.length > 0) return parts.join('\n');
|
|
397
|
+
}
|
|
398
|
+
} catch {
|
|
399
|
+
// not JSON
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
return text;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
function mirrorInfo(block: ToolBlock): { tool: string; input: Record<string, unknown>; server?: string } | null {
|
|
406
|
+
const a = parseArgs(block);
|
|
407
|
+
if (a === null) return null;
|
|
408
|
+
let tool = typeof a.tool === 'string' ? a.tool : '';
|
|
409
|
+
if (tool === '') return null;
|
|
410
|
+
let input: Record<string, unknown> = {};
|
|
411
|
+
const raw = a.input;
|
|
412
|
+
if (typeof raw === 'object' && raw !== null && !Array.isArray(raw)) input = raw as Record<string, unknown>;
|
|
413
|
+
else if (typeof raw === 'string') {
|
|
414
|
+
try {
|
|
415
|
+
const p = JSON.parse(raw) as unknown;
|
|
416
|
+
if (typeof p === 'object' && p !== null && !Array.isArray(p)) input = p as Record<string, unknown>;
|
|
417
|
+
else input = { value: raw };
|
|
418
|
+
} catch {
|
|
419
|
+
input = { value: raw };
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
let server = typeof a.server === 'string' && a.server !== '' ? cleanString(a.server) : undefined;
|
|
423
|
+
|
|
424
|
+
// Unwrap MCP meta-tools: call_mcp_tool, callMcpTool, call_mcp, mcp_call
|
|
425
|
+
if (/^(call_mcp_tool|callMcpTool|call_mcp|mcp_call)$/i.test(tool)) {
|
|
426
|
+
const s = pick(input, 'ServerName', 'server_name', 'serverName', 'server');
|
|
427
|
+
if (s) server = cleanString(s);
|
|
428
|
+
const innerTool = pick(input, 'ToolName', 'tool_name', 'toolName', 'name', 'tool');
|
|
429
|
+
const rawInner = input.Arguments ?? input.arguments ?? input.args ?? input.parameters ?? input.params ?? input.input;
|
|
430
|
+
if (innerTool) {
|
|
431
|
+
tool = cleanString(innerTool);
|
|
432
|
+
input = parseInnerArgs(rawInner);
|
|
433
|
+
}
|
|
434
|
+
} else if (tool.startsWith('mcp__')) {
|
|
435
|
+
const parts = tool.slice(5).split('__');
|
|
436
|
+
if (parts.length >= 2) {
|
|
437
|
+
server = parts[0];
|
|
438
|
+
tool = parts.slice(1).join('__');
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
return { tool, input, ...(server ? { server } : {}) };
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
function pick(input: Record<string, unknown>, ...keys: string[]): string | undefined {
|
|
446
|
+
for (const k of keys) {
|
|
447
|
+
const v = input[k];
|
|
448
|
+
if (typeof v === 'string' && v !== '') return v;
|
|
449
|
+
}
|
|
450
|
+
return undefined;
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
function num(input: Record<string, unknown>, ...keys: string[]): number | undefined {
|
|
454
|
+
for (const k of keys) {
|
|
455
|
+
const v = input[k];
|
|
456
|
+
if (typeof v === 'number' && Number.isFinite(v)) return v;
|
|
457
|
+
}
|
|
458
|
+
return undefined;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
function resultText(block: ToolBlock): string {
|
|
462
|
+
const settled = block as ToolResultBlock;
|
|
463
|
+
if (!Array.isArray(settled.content)) return '';
|
|
464
|
+
const parts: string[] = [];
|
|
465
|
+
for (const b of settled.content) {
|
|
466
|
+
if (b && typeof b === 'object' && (b as { type?: string }).type === 'text' && typeof (b as { text?: unknown }).text === 'string') {
|
|
467
|
+
parts.push((b as { text: string }).text);
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
const text = parts.join('\n');
|
|
471
|
+
return cleanResultText(text);
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
function isSettled(block: ToolBlock): boolean {
|
|
475
|
+
return block.kind === 'tool-result' || 'content' in block;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
function isError(block: ToolBlock): boolean {
|
|
479
|
+
const settled = block as ToolResultBlock;
|
|
480
|
+
return settled.isError === true || (settled.error !== undefined && settled.error !== null);
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
// ---- Card classification --------------------------------------------------
|
|
484
|
+
|
|
485
|
+
const TERMINAL_TOOLS = new Set(['run_command', 'bash', 'execute_command', 'ops_bash', 'sh', 'shell']);
|
|
486
|
+
const DIFF_TOOLS = new Set(['replace_file_content', 'edit_file', 'replace_in_file', 'edit', 'write_to_file', 'write_file', 'create_file']);
|
|
487
|
+
const READ_TOOLS = new Set(['read_file', 'view_file', 'read', 'open_file']);
|
|
488
|
+
const SEARCH_TOOLS = new Set(['find_by_name', 'glob', 'ops_glob', 'search_files', 'grep_search', 'search', 'ops_grep', 'search_file_content', 'grep', 'search_web', 'web_search']);
|
|
489
|
+
const LIST_TOOLS = new Set(['list_dir', 'ls']);
|
|
490
|
+
const DELETE_TOOLS = new Set(['delete_file', 'remove_file', 'rm']);
|
|
491
|
+
const QUESTION_TOOLS = new Set(['ask_question', 'ask', 'question']);
|
|
492
|
+
const IMAGE_TOOLS = new Set(['generate_image', 'create_image', 'render_image']);
|
|
493
|
+
|
|
494
|
+
export type CardKind = 'terminal' | 'diff' | 'read' | 'search' | 'list' | 'delete' | 'question' | 'image' | 'generic';
|
|
495
|
+
|
|
496
|
+
export interface MirrorCardModel {
|
|
497
|
+
kind: CardKind;
|
|
498
|
+
tool?: string;
|
|
499
|
+
server?: string;
|
|
500
|
+
title: string;
|
|
501
|
+
command?: string;
|
|
502
|
+
cwd?: string;
|
|
503
|
+
output?: string;
|
|
504
|
+
path?: string;
|
|
505
|
+
oldText?: string | null;
|
|
506
|
+
newText?: string;
|
|
507
|
+
location?: { path: string; line?: number };
|
|
508
|
+
raw?: string;
|
|
509
|
+
questions?: Array<{ question?: string; options?: string[]; is_multi_select?: boolean }>;
|
|
510
|
+
prompt?: string;
|
|
511
|
+
imageName?: string;
|
|
512
|
+
aspectRatio?: string;
|
|
513
|
+
isImage?: boolean;
|
|
514
|
+
imagePath?: string;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
export function mirrorCardModel(block: ToolBlock, cwd?: string, home?: string): MirrorCardModel {
|
|
518
|
+
const info = mirrorInfo(block);
|
|
519
|
+
const out = resultText(block);
|
|
520
|
+
if (info === null) {
|
|
521
|
+
return { kind: 'generic', title: 'agy_tool', output: out, raw: parsedArgsRaw(block) };
|
|
522
|
+
}
|
|
523
|
+
const { tool, input } = info;
|
|
524
|
+
const desc = pick(input, 'Description', 'description', 'toolAction', 'toolSummary', 'Instruction', 'instruction');
|
|
525
|
+
|
|
526
|
+
if (QUESTION_TOOLS.has(tool)) {
|
|
527
|
+
const questionsRaw = (input as Record<string, unknown>).questions ?? (input as Record<string, unknown>).Questions;
|
|
528
|
+
const questions = Array.isArray(questionsRaw) ? (questionsRaw as Array<{ question?: string; options?: string[]; is_multi_select?: boolean }>) : [];
|
|
529
|
+
const firstQ = questions[0];
|
|
530
|
+
const qTitle = firstQ?.question ?? desc ?? 'Ask Question';
|
|
531
|
+
return {
|
|
532
|
+
kind: 'question',
|
|
533
|
+
tool,
|
|
534
|
+
server: info.server,
|
|
535
|
+
title: qTitle,
|
|
536
|
+
output: out,
|
|
537
|
+
questions,
|
|
538
|
+
raw: parsedArgsRaw(block),
|
|
539
|
+
};
|
|
540
|
+
}
|
|
541
|
+
if (IMAGE_TOOLS.has(tool)) {
|
|
542
|
+
const prompt = pick(input, 'Prompt', 'prompt') ?? '';
|
|
543
|
+
const name = pick(input, 'ImageName', 'image_name', 'name') ?? 'image';
|
|
544
|
+
const ratio = pick(input, 'AspectRatio', 'aspect_ratio') ?? '1:1';
|
|
545
|
+
return {
|
|
546
|
+
kind: 'image',
|
|
547
|
+
tool,
|
|
548
|
+
server: info.server,
|
|
549
|
+
title: desc ?? `Generate Image · ${name}`,
|
|
550
|
+
prompt,
|
|
551
|
+
imageName: name,
|
|
552
|
+
aspectRatio: ratio,
|
|
553
|
+
output: out,
|
|
554
|
+
raw: parsedArgsRaw(block),
|
|
555
|
+
};
|
|
556
|
+
}
|
|
557
|
+
if (TERMINAL_TOOLS.has(tool)) {
|
|
558
|
+
const command = pick(input, 'CommandLine', 'command_line', 'command', 'cmd', 'Cmd')
|
|
559
|
+
?? (desc && desc.startsWith('$ ') ? desc.replace(/\s*·\s*.*$/, '').replace(/^\$\s*/, '') : undefined)
|
|
560
|
+
?? JSON.stringify(input);
|
|
561
|
+
const cwdVal = pick(input, 'Cwd', 'cwd', 'WorkingDirectory', 'working_directory', 'workdir', 'WorkDir') ?? cwd;
|
|
562
|
+
const rowTitle = desc !== undefined && !desc.startsWith('$ ') && desc !== command ? desc + ' · ' + command : command;
|
|
563
|
+
return {
|
|
564
|
+
kind: 'terminal',
|
|
565
|
+
tool,
|
|
566
|
+
server: info.server,
|
|
567
|
+
title: rowTitle,
|
|
568
|
+
command,
|
|
569
|
+
...(cwdVal !== undefined ? { cwd: cwdVal } : {}),
|
|
570
|
+
output: out,
|
|
571
|
+
};
|
|
572
|
+
}
|
|
573
|
+
if (DIFF_TOOLS.has(tool)) {
|
|
574
|
+
const rawPath = pick(input, 'TargetFile', 'target_file', 'path', 'file_path', 'Path', 'FilePath', 'AbsolutePath', 'targetFile', 'filename', 'FileName') ?? 'file';
|
|
575
|
+
const path = relativize(rawPath, cwd, home);
|
|
576
|
+
const oldText = pick(input, 'TargetContent', 'target_content', 'old_string', 'oldText', 'OldString', 'OldText', 'targetContent') ?? null;
|
|
577
|
+
const newText = pick(input, 'ReplacementContent', 'replacement_content', 'new_string', 'newText', 'content', 'NewString', 'NewText', 'Content', 'replacementContent', 'CodeContent', 'code_content', 'contents', 'FileContents', 'codeContent') ?? '';
|
|
578
|
+
const action = (tool === 'write_to_file' || tool === 'write_file' || tool === 'create_file') ? 'Write' : 'Edit';
|
|
579
|
+
const isGenericDesc = desc !== undefined && /^(file edit|editing file|write file|writing file|file write|edit file|editing|writing|file create|creating file)$/i.test(desc.trim());
|
|
580
|
+
const title = desc !== undefined && !isGenericDesc && !desc.includes(path)
|
|
581
|
+
? `${action} ${path} · ${desc}`
|
|
582
|
+
: `${action} ${path}`;
|
|
583
|
+
return { kind: 'diff', tool, server: info.server, title, path: rawPath, oldText, newText, output: out };
|
|
584
|
+
}
|
|
585
|
+
if (READ_TOOLS.has(tool)) {
|
|
586
|
+
const path = pick(input, 'AbsolutePath', 'absolute_path', 'TargetFile', 'target_file', 'path', 'file_path', 'filename', 'Path', 'FilePath', 'FileName', 'targetFile') ?? '';
|
|
587
|
+
const offset = num(input, 'offset', 'Offset') ?? num(input, 'StartLine', 'start_line');
|
|
588
|
+
const line = offset !== undefined ? (offset > 0 && (tool === 'view_file' || tool === 'read_file') ? offset : offset + 1) : undefined;
|
|
589
|
+
const isImg = isImageFile(path);
|
|
590
|
+
return {
|
|
591
|
+
kind: isImg ? 'image' : 'read',
|
|
592
|
+
tool,
|
|
593
|
+
server: info.server,
|
|
594
|
+
title: desc ? `${desc} · ${path}` : path !== '' ? 'Read ' + path : 'Read',
|
|
595
|
+
path,
|
|
596
|
+
output: out,
|
|
597
|
+
isImage: isImg,
|
|
598
|
+
imagePath: isImg ? path : undefined,
|
|
599
|
+
prompt: desc,
|
|
600
|
+
imageName: path.split(/[/\\]/).pop() || 'image',
|
|
601
|
+
...(path !== '' ? { location: { path, ...(line !== undefined ? { line } : {}) } } : {}),
|
|
602
|
+
};
|
|
603
|
+
}
|
|
604
|
+
if (SEARCH_TOOLS.has(tool)) {
|
|
605
|
+
const rawPat = input.query ?? input.Query ?? input.pattern ?? input.Pattern ?? input.regex ?? input.Regex ?? input.QueryString;
|
|
606
|
+
const q = Array.isArray(rawPat) ? rawPat.join(', ') : (typeof rawPat === 'string' ? rawPat : (pick(input, 'query', 'Query', 'pattern', 'Pattern', 'regex', 'Regex', 'QueryString') ?? ''));
|
|
607
|
+
return { kind: 'search', tool, server: info.server, title: desc ?? (q !== '' ? 'Search ' + q : 'Search'), output: out };
|
|
608
|
+
}
|
|
609
|
+
if (LIST_TOOLS.has(tool)) {
|
|
610
|
+
const path = pick(input, 'DirectoryPath', 'directory_path', 'path', 'directory', 'Path', 'Directory', 'SearchDirectory', 'search_directory', 'AbsolutePath') ?? '';
|
|
611
|
+
return { kind: 'list', tool, server: info.server, title: desc ?? (path !== '' ? 'List ' + path : 'List directory'), output: out };
|
|
612
|
+
}
|
|
613
|
+
if (DELETE_TOOLS.has(tool)) {
|
|
614
|
+
const path = pick(input, 'TargetFile', 'target_file', 'path', 'file_path', 'Path', 'FilePath', 'AbsolutePath') ?? '';
|
|
615
|
+
return { kind: 'delete', tool, server: info.server, title: desc ?? 'Delete ' + path, output: out };
|
|
616
|
+
}
|
|
617
|
+
const defaultTitle = info.server ? `${info.server}: ${tool}` : (tool !== '' ? tool : 'agy_tool');
|
|
618
|
+
const title = desc ?? defaultTitle;
|
|
619
|
+
return { kind: 'generic', tool, server: info.server, title, output: out, raw: parsedArgsRaw(block) };
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
// ---- Helpers --------------------------------------------------------------
|
|
623
|
+
|
|
624
|
+
function relativize(p: string, cwd?: string, home?: string): string {
|
|
625
|
+
if (cwd && p.startsWith(cwd)) {
|
|
626
|
+
const rel = p.slice(cwd.length).replace(/^[/\\]+/, '');
|
|
627
|
+
return rel !== '' ? rel : p;
|
|
628
|
+
}
|
|
629
|
+
if (home && p.startsWith(home)) return '~' + p.slice(home.length);
|
|
630
|
+
return p;
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
function clip(s: string, max: number): string {
|
|
634
|
+
return s.length > max ? s.slice(0, max) + '\n… (+' + (s.length - max) + ' chars)' : s;
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
export function trimTrailingBlankLines(s: string): string {
|
|
638
|
+
return s.replace(/[\t ]*\r?\n[\t ]*(\r?\n[\t ]*)*$/, '\n');
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
export function previewLine(model: MirrorCardModel, cwd?: string, home?: string): string | undefined {
|
|
642
|
+
if (model.kind === 'diff') {
|
|
643
|
+
const raw = model.path ?? 'file';
|
|
644
|
+
const rel = relativize(raw, cwd, home);
|
|
645
|
+
const display = rel.length > 40 ? '…' + rel.slice(-40) : rel;
|
|
646
|
+
return model.oldText != null ? `± ${display}` : `+ ${display}`;
|
|
647
|
+
}
|
|
648
|
+
const out = model.output;
|
|
649
|
+
if (out !== undefined && out !== '') {
|
|
650
|
+
const first = out.split('\n').find((l) => l.trim() !== '');
|
|
651
|
+
if (first !== undefined && first.trim() !== '') return first.trim().slice(0, 80);
|
|
652
|
+
}
|
|
653
|
+
return undefined;
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
function cls(...names: Array<string | false | null | undefined>): string {
|
|
657
|
+
return names.filter((n): n is string => typeof n === 'string' && n !== '').join(' ');
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
type Translate = (key: string, params?: Record<string, unknown>) => string;
|
|
661
|
+
|
|
662
|
+
/**
|
|
663
|
+
* Locale lookup with an English fallback: the mirror card renders through
|
|
664
|
+
* host-provided `t` when the registration declares the namespace, but tests
|
|
665
|
+
* and hosts without the seat call it bare. The old literals were mixed
|
|
666
|
+
* 中文 and English as BOTH fallback and primary, so non-Chinese users saw
|
|
667
|
+
* Chinese buttons on mirror cards.
|
|
668
|
+
*/
|
|
669
|
+
function tr(t: Translate | undefined, key: string, fallback: string, params?: Record<string, unknown>): string {
|
|
670
|
+
if (typeof t === 'function') {
|
|
671
|
+
try {
|
|
672
|
+
const v = t(key, params);
|
|
673
|
+
if (typeof v === 'string' && v !== '' && v !== key) return v;
|
|
674
|
+
} catch {
|
|
675
|
+
// unbound namespace — fall through
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
if (params !== undefined && params.count !== undefined && fallback.includes('{count}')) {
|
|
679
|
+
return fallback.replace('{count}', String(params.count));
|
|
680
|
+
}
|
|
681
|
+
return fallback;
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
function displayTitle(model: MirrorCardModel, t?: Translate): string {
|
|
685
|
+
switch (model.kind) {
|
|
686
|
+
case 'terminal':
|
|
687
|
+
return tr(t, 'tv.command', 'Command');
|
|
688
|
+
case 'diff':
|
|
689
|
+
return (model.tool === 'write_to_file' || model.tool === 'write_file' || model.tool === 'create_file') ? tr(t, 'tv.write', 'Write') : tr(t, 'tv.edit', 'Edit');
|
|
690
|
+
case 'read':
|
|
691
|
+
return tr(t, 'tv.read', 'Read');
|
|
692
|
+
case 'search':
|
|
693
|
+
return (model.tool === 'search_web' || model.tool === 'web_search') ? tr(t, 'tv.webSearch', 'Web Search') : tr(t, 'tv.search', 'Search');
|
|
694
|
+
case 'list':
|
|
695
|
+
return tr(t, 'tv.list', 'List');
|
|
696
|
+
case 'delete':
|
|
697
|
+
return tr(t, 'tv.delete', 'Delete');
|
|
698
|
+
case 'question':
|
|
699
|
+
return tr(t, 'tv.question', 'Question');
|
|
700
|
+
case 'image':
|
|
701
|
+
return tr(t, 'tv.image', 'Image');
|
|
702
|
+
default:
|
|
703
|
+
if (model.tool && model.tool !== 'agy_tool') {
|
|
704
|
+
return model.server ? `${model.server}: ${model.tool}` : model.tool.replace(/_/g, ' ');
|
|
705
|
+
}
|
|
706
|
+
return tr(t, 'tv.tool', 'Tool');
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
function displaySummary(model: MirrorCardModel, cwd?: string, home?: string): string {
|
|
711
|
+
if (model.kind === 'terminal') {
|
|
712
|
+
return model.command ?? model.title;
|
|
713
|
+
}
|
|
714
|
+
if (model.kind === 'diff') {
|
|
715
|
+
const rawPath = model.path ?? 'file';
|
|
716
|
+
return relativize(rawPath, cwd, home);
|
|
717
|
+
}
|
|
718
|
+
if (model.kind === 'read') {
|
|
719
|
+
const rawPath = model.path ?? '';
|
|
720
|
+
return rawPath !== '' ? relativize(rawPath, cwd, home) : model.title;
|
|
721
|
+
}
|
|
722
|
+
if (model.kind === 'search') {
|
|
723
|
+
return model.title.replace(/^(Web search|Search)\s*/i, '') || model.title;
|
|
724
|
+
}
|
|
725
|
+
if (model.kind === 'list') {
|
|
726
|
+
return model.title.replace(/^List\s*(directory\s*)?/i, '') || model.title;
|
|
727
|
+
}
|
|
728
|
+
if (model.kind === 'question') {
|
|
729
|
+
return model.title;
|
|
730
|
+
}
|
|
731
|
+
if (model.kind === 'image') {
|
|
732
|
+
return model.prompt || model.title;
|
|
733
|
+
}
|
|
734
|
+
if (model.server && model.title.startsWith(`${model.server}: `)) {
|
|
735
|
+
return model.title.slice(model.server.length + 2);
|
|
736
|
+
}
|
|
737
|
+
return model.title;
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
function diffStat(model: MirrorCardModel): string | null {
|
|
741
|
+
if (model.kind !== 'diff') return null;
|
|
742
|
+
const oldText = model.oldText ?? '';
|
|
743
|
+
const newText = model.newText ?? '';
|
|
744
|
+
const oldLines = oldText === '' ? 0 : oldText.split('\n').length;
|
|
745
|
+
const newLines = newText === '' ? 0 : newText.split('\n').length;
|
|
746
|
+
if (oldLines === 0 && newLines === 0) return null;
|
|
747
|
+
if (oldLines === 0) return `+${newLines}`;
|
|
748
|
+
return `+${newLines} -${oldLines}`;
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
// ---- Copy button component ------------------------------------------------
|
|
752
|
+
|
|
753
|
+
function CopyButton({ text, labels, t }: { text: string; labels?: readonly [string, string]; t?: Translate }): unknown {
|
|
754
|
+
const [copied, setCopied] = react().useState(false);
|
|
755
|
+
const copyLabel = labels?.[0] ?? tr(t, 'code.copy', 'Copy');
|
|
756
|
+
const copiedLabel = labels?.[1] ?? tr(t, 'code.copied', 'Copied');
|
|
757
|
+
const onCopy = (e: { stopPropagation: () => void }) => {
|
|
758
|
+
e.stopPropagation();
|
|
759
|
+
if (typeof navigator !== 'undefined' && navigator.clipboard) {
|
|
760
|
+
navigator.clipboard.writeText(text).then(() => {
|
|
761
|
+
setCopied(true);
|
|
762
|
+
setTimeout(() => setCopied(false), 1500);
|
|
763
|
+
}).catch(() => {
|
|
764
|
+
// Clipboard unavailable (insecure context): show the failure on
|
|
765
|
+
// the button instead of silently doing nothing.
|
|
766
|
+
setCopied(false);
|
|
767
|
+
});
|
|
768
|
+
}
|
|
769
|
+
};
|
|
770
|
+
return hx('button', {
|
|
771
|
+
type: 'button',
|
|
772
|
+
className: 'agy-tv-copy-btn',
|
|
773
|
+
onClick: onCopy,
|
|
774
|
+
title: copied ? copiedLabel : copyLabel,
|
|
775
|
+
},
|
|
776
|
+
copied ? IconCheckOutline14(11) : IconCopyOutline16(11),
|
|
777
|
+
hx('span', null, copied ? copiedLabel : copyLabel)
|
|
778
|
+
);
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
// ---- Diff body renderer ---------------------------------------------------
|
|
782
|
+
|
|
783
|
+
/** Per-side render cap: a 5000-line write_to_file used to build 10k DOM rows
|
|
784
|
+
* inside a max-height:280px pane (99% of them invisible). */
|
|
785
|
+
const DIFF_MAX_LINES = 400;
|
|
786
|
+
|
|
787
|
+
function DiffBody({ model, t }: { model: MirrorCardModel; openFile?: (p: string, o?: unknown) => void; cwd?: string; home?: string; t?: Translate }): unknown {
|
|
788
|
+
const h = hx;
|
|
789
|
+
const oldText = model.oldText ?? '';
|
|
790
|
+
const newText = model.newText ?? '';
|
|
791
|
+
const rows: unknown[] = [];
|
|
792
|
+
const moreRow = (count: number, key: string): unknown =>
|
|
793
|
+
h('div', { key, className: 'agy-tv-diff-line', style: { color: 'var(--dsw-alias-label-tertiary)' } },
|
|
794
|
+
tr(t, 'tv.diffMore', '… {count} more lines not rendered', { count }));
|
|
795
|
+
if (oldText !== '') {
|
|
796
|
+
const lines = oldText.split('\n');
|
|
797
|
+
const shown = Math.min(lines.length, DIFF_MAX_LINES);
|
|
798
|
+
for (let i = 0; i < shown; i++) {
|
|
799
|
+
const line = lines[i];
|
|
800
|
+
rows.push(h('div', { key: 'del-' + i, className: 'agy-tv-diff-line agy-tv-diff-del' },
|
|
801
|
+
h('span', { className: 'agy-tv-diff-marker' }, '-'),
|
|
802
|
+
h('span', { style: { flex: 1 } }, line === '' ? ' ' : line)
|
|
803
|
+
));
|
|
804
|
+
}
|
|
805
|
+
if (lines.length > shown) rows.push(moreRow(lines.length - shown, 'del-more'));
|
|
806
|
+
}
|
|
807
|
+
if (newText !== '') {
|
|
808
|
+
const lines = newText.split('\n');
|
|
809
|
+
const shown = Math.min(lines.length, DIFF_MAX_LINES);
|
|
810
|
+
for (let i = 0; i < shown; i++) {
|
|
811
|
+
const line = lines[i];
|
|
812
|
+
rows.push(h('div', { key: 'add-' + i, className: 'agy-tv-diff-line agy-tv-diff-add' },
|
|
813
|
+
h('span', { className: 'agy-tv-diff-marker' }, '+'),
|
|
814
|
+
h('span', { style: { flex: 1 } }, line === '' ? ' ' : line)
|
|
815
|
+
));
|
|
816
|
+
}
|
|
817
|
+
if (lines.length > shown) rows.push(moreRow(lines.length - shown, 'add-more'));
|
|
818
|
+
}
|
|
819
|
+
if (rows.length === 0) {
|
|
820
|
+
rows.push(h('div', { key: 'empty', className: 'agy-tv-diff-line', style: { color: 'var(--dsw-alias-label-tertiary)' } }, tr(t, 'tv.noChanges', '(no textual changes)')));
|
|
821
|
+
}
|
|
822
|
+
return h('div', { className: 'agy-tv-diff-list' }, ...rows);
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
// ---- Question card renderer -----------------------------------------------
|
|
826
|
+
|
|
827
|
+
function QuestionCardBody({ model }: { model: MirrorCardModel }): unknown {
|
|
828
|
+
const h = hx;
|
|
829
|
+
const questions = model.questions ?? [];
|
|
830
|
+
const [selectedMap, setSelectedMap] = react().useState<Record<number, Set<string>>>({});
|
|
831
|
+
const [inserted, setInserted] = react().useState(false);
|
|
832
|
+
|
|
833
|
+
const toggleOption = (qIdx: number, opt: string, isMulti?: boolean) => {
|
|
834
|
+
setSelectedMap((prev) => {
|
|
835
|
+
const next = { ...prev };
|
|
836
|
+
const current = new Set(next[qIdx] ?? []);
|
|
837
|
+
if (isMulti) {
|
|
838
|
+
if (current.has(opt)) current.delete(opt);
|
|
839
|
+
else current.add(opt);
|
|
840
|
+
} else {
|
|
841
|
+
current.clear();
|
|
842
|
+
current.add(opt);
|
|
843
|
+
}
|
|
844
|
+
next[qIdx] = current;
|
|
845
|
+
return next;
|
|
846
|
+
});
|
|
847
|
+
};
|
|
848
|
+
|
|
849
|
+
const onInsert = () => {
|
|
850
|
+
const parts: string[] = [];
|
|
851
|
+
for (let i = 0; i < questions.length; i++) {
|
|
852
|
+
const sel = Array.from(selectedMap[i] ?? []);
|
|
853
|
+
if (sel.length > 0) {
|
|
854
|
+
parts.push(sel.join('; '));
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
if (parts.length > 0) {
|
|
858
|
+
const text = parts.join('\n');
|
|
859
|
+
insertTextIntoChatComposer(text);
|
|
860
|
+
setInserted(true);
|
|
861
|
+
setTimeout(() => setInserted(false), 1500);
|
|
862
|
+
}
|
|
863
|
+
};
|
|
864
|
+
|
|
865
|
+
const qNodes: unknown[] = [];
|
|
866
|
+
for (let i = 0; i < questions.length; i++) {
|
|
867
|
+
const q = questions[i];
|
|
868
|
+
if (!q) continue;
|
|
869
|
+
const options = q.options ?? [];
|
|
870
|
+
const isMulti = q.is_multi_select === true;
|
|
871
|
+
const sel = selectedMap[i] ?? new Set();
|
|
872
|
+
|
|
873
|
+
const optNodes = options.map((opt, oIdx) => {
|
|
874
|
+
const isChecked = sel.has(opt);
|
|
875
|
+
return h('button', {
|
|
876
|
+
key: 'opt-' + oIdx,
|
|
877
|
+
type: 'button',
|
|
878
|
+
className: cls('agy-tv-q-opt', isChecked && 'selected'),
|
|
879
|
+
onClick: (e: { stopPropagation: () => void }) => {
|
|
880
|
+
e.stopPropagation();
|
|
881
|
+
toggleOption(i, opt, isMulti);
|
|
882
|
+
},
|
|
883
|
+
},
|
|
884
|
+
h('span', { className: cls('agy-tv-q-check', isMulti ? 'checkbox' : 'radio', isChecked && 'checked') }),
|
|
885
|
+
h('span', { className: 'agy-tv-q-opt-text' }, opt)
|
|
886
|
+
);
|
|
887
|
+
});
|
|
888
|
+
|
|
889
|
+
qNodes.push(h('div', { key: 'q-' + i, className: 'agy-tv-q-item' },
|
|
890
|
+
h('div', { className: 'agy-tv-q-prompt' }, q.question || 'Please select:'),
|
|
891
|
+
h('div', { className: 'agy-tv-q-opts' }, ...optNodes)
|
|
892
|
+
));
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
const hasSelection = Object.values(selectedMap).some((s) => s.size > 0);
|
|
896
|
+
|
|
897
|
+
return h('div', { className: 'agy-tv-question-wrap' },
|
|
898
|
+
...qNodes,
|
|
899
|
+
h('div', { className: 'agy-tv-q-footer' },
|
|
900
|
+
h('button', {
|
|
901
|
+
type: 'button',
|
|
902
|
+
className: cls('agy-tv-q-insert-btn', hasSelection && 'active'),
|
|
903
|
+
disabled: !hasSelection,
|
|
904
|
+
onClick: (e: { stopPropagation: () => void }) => {
|
|
905
|
+
e.stopPropagation();
|
|
906
|
+
onInsert();
|
|
907
|
+
},
|
|
908
|
+
},
|
|
909
|
+
inserted ? '✓ 已填入对话框' : '💬 填入对话框 / Insert into Chat'
|
|
910
|
+
),
|
|
911
|
+
model.output ? h('div', { className: 'agy-tv-q-answered' }, `已记录: ${model.output}`) : null
|
|
912
|
+
)
|
|
913
|
+
);
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
// ---- Image card renderer --------------------------------------------------
|
|
917
|
+
|
|
918
|
+
function ImageCardBody({ model }: { model: MirrorCardModel }): unknown {
|
|
919
|
+
const h = hx;
|
|
920
|
+
const prompt = model.prompt || '';
|
|
921
|
+
const name = model.imageName || 'image';
|
|
922
|
+
const ratio = model.aspectRatio || '1:1';
|
|
923
|
+
const path = model.imagePath || model.path || '';
|
|
924
|
+
const mediaUrl = path ? buildMediaUrl(path) : null;
|
|
925
|
+
|
|
926
|
+
return h('div', { className: 'agy-tv-img-wrap' },
|
|
927
|
+
h('div', { className: 'agy-tv-img-meta' },
|
|
928
|
+
h('div', { className: 'agy-tv-img-prompt', title: prompt || name }, prompt ? `"${prompt}"` : name),
|
|
929
|
+
h('div', { className: 'agy-tv-img-badges' },
|
|
930
|
+
h('span', { className: 'agy-tv-img-badge' }, ratio),
|
|
931
|
+
...(path ? [h('span', { key: 'path', className: 'agy-tv-img-badge', title: path }, path.split(/[/\\]/).pop())] : [])
|
|
932
|
+
)
|
|
933
|
+
),
|
|
934
|
+
mediaUrl ? h('div', {
|
|
935
|
+
className: 'agy-tv-img-preview-box',
|
|
936
|
+
onClick: (e: { stopPropagation: () => void }) => {
|
|
937
|
+
e.stopPropagation();
|
|
938
|
+
openLightbox(mediaUrl, prompt || name, path);
|
|
939
|
+
},
|
|
940
|
+
title: '点击放大预览 / Click to open lightbox'
|
|
941
|
+
},
|
|
942
|
+
h('img', {
|
|
943
|
+
className: 'agy-tv-img-thumb',
|
|
944
|
+
src: mediaUrl,
|
|
945
|
+
alt: prompt || name,
|
|
946
|
+
loading: 'lazy',
|
|
947
|
+
})
|
|
948
|
+
) : null
|
|
949
|
+
);
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
// ---- Card body renderer ---------------------------------------------------
|
|
953
|
+
|
|
954
|
+
function CardBody({ model, openFile, cwd, home, inspect, t }: {
|
|
955
|
+
model: MirrorCardModel;
|
|
956
|
+
openFile?: (p: string, o?: unknown) => void;
|
|
957
|
+
cwd?: string;
|
|
958
|
+
home?: string;
|
|
959
|
+
inspect?: () => void;
|
|
960
|
+
t?: Translate;
|
|
961
|
+
}): unknown {
|
|
962
|
+
const h = hx;
|
|
963
|
+
const inspectNode = inspect !== undefined
|
|
964
|
+
? h('div', { key: 'ins', style: { padding: '4px 8px 6px' } },
|
|
965
|
+
h('button', {
|
|
966
|
+
type: 'button',
|
|
967
|
+
className: 'agy-tv-inspect-btn',
|
|
968
|
+
onClick: inspect,
|
|
969
|
+
}, IconInspectOutline12(12), tr(t, 'code.inspect', 'Inspect'))
|
|
970
|
+
)
|
|
971
|
+
: null;
|
|
972
|
+
|
|
973
|
+
switch (model.kind) {
|
|
974
|
+
case 'terminal': {
|
|
975
|
+
const rawBody = model.output !== undefined && model.output !== '' ? trimTrailingBlankLines(model.output) : tr(t, 'tv.noOutput', '(no output)');
|
|
976
|
+
const copyText = model.output !== undefined && model.output !== '' ? model.output : (model.command ?? '');
|
|
977
|
+
return h('div', { className: 'agy-tv-card' },
|
|
978
|
+
h('div', { className: 'agy-tv-card-header' },
|
|
979
|
+
h('div', { className: 'agy-tv-card-header-left' },
|
|
980
|
+
h('span', { className: 'agy-tv-prompt-glyph' }, '❯'),
|
|
981
|
+
...(model.cwd ? [h('span', { key: 'cwd', className: 'agy-tv-card-cwd' }, model.cwd)] : []),
|
|
982
|
+
h('span', { className: 'agy-tv-card-cmd', title: model.command }, model.command ?? '')
|
|
983
|
+
),
|
|
984
|
+
h(CopyButton, { text: copyText, t })
|
|
985
|
+
),
|
|
986
|
+
h('pre', { className: 'agy-tv-card-content' }, clip(rawBody, 16000)),
|
|
987
|
+
inspectNode
|
|
988
|
+
);
|
|
989
|
+
}
|
|
990
|
+
case 'diff': {
|
|
991
|
+
const path = model.path ?? 'file';
|
|
992
|
+
const pathLabel = relativize(path, cwd, home);
|
|
993
|
+
const stat = diffStat(model);
|
|
994
|
+
const copyText = model.newText ?? '';
|
|
995
|
+
return h('div', { className: 'agy-tv-card' },
|
|
996
|
+
h('div', { className: 'agy-tv-card-header' },
|
|
997
|
+
h('div', { className: 'agy-tv-card-header-left' },
|
|
998
|
+
IconEditOutline16(13),
|
|
999
|
+
h('span', { className: 'agy-tv-card-path' }, pathLabel),
|
|
1000
|
+
...(stat ? [h('span', { key: 's', className: 'agy-tv-diff-stat' }, stat)] : [])
|
|
1001
|
+
),
|
|
1002
|
+
h(CopyButton, { text: copyText })
|
|
1003
|
+
),
|
|
1004
|
+
h(DiffBody, { model, openFile, cwd, home, t }),
|
|
1005
|
+
inspectNode
|
|
1006
|
+
);
|
|
1007
|
+
}
|
|
1008
|
+
case 'read': {
|
|
1009
|
+
const path = model.path ?? 'file';
|
|
1010
|
+
const pathLabel = relativize(path, cwd, home);
|
|
1011
|
+
const rawBody = model.output !== undefined && model.output !== '' ? trimTrailingBlankLines(model.output) : tr(t, 'tv.noOutput', '(no output)');
|
|
1012
|
+
return h('div', { className: 'agy-tv-card' },
|
|
1013
|
+
h('div', { className: 'agy-tv-card-header' },
|
|
1014
|
+
h('div', { className: 'agy-tv-card-header-left' },
|
|
1015
|
+
IconBrowseOutline16(13),
|
|
1016
|
+
h('span', { className: 'agy-tv-card-path' }, pathLabel)
|
|
1017
|
+
),
|
|
1018
|
+
h(CopyButton, { text: model.output ?? '', t })
|
|
1019
|
+
),
|
|
1020
|
+
h('pre', { className: 'agy-tv-card-content' }, clip(rawBody, 16000)),
|
|
1021
|
+
inspectNode
|
|
1022
|
+
);
|
|
1023
|
+
}
|
|
1024
|
+
case 'search': {
|
|
1025
|
+
const rawBody = model.output !== undefined && model.output !== '' ? trimTrailingBlankLines(model.output) : tr(t, 'tv.noMatches', '(no matches)');
|
|
1026
|
+
return h('div', { className: 'agy-tv-card' },
|
|
1027
|
+
h('div', { className: 'agy-tv-card-header' },
|
|
1028
|
+
h('div', { className: 'agy-tv-card-header-left' },
|
|
1029
|
+
IconSearchOutline16(13),
|
|
1030
|
+
h('span', { className: 'agy-tv-card-path' }, model.title)
|
|
1031
|
+
),
|
|
1032
|
+
h(CopyButton, { text: model.output ?? '', t })
|
|
1033
|
+
),
|
|
1034
|
+
h('pre', { className: 'agy-tv-card-content' }, clip(rawBody, 16000)),
|
|
1035
|
+
inspectNode
|
|
1036
|
+
);
|
|
1037
|
+
}
|
|
1038
|
+
case 'list': {
|
|
1039
|
+
const rawBody = model.output !== undefined && model.output !== '' ? trimTrailingBlankLines(model.output) : tr(t, 'tv.emptyDir', '(empty directory)');
|
|
1040
|
+
return h('div', { className: 'agy-tv-card' },
|
|
1041
|
+
h('div', { className: 'agy-tv-card-header' },
|
|
1042
|
+
h('div', { className: 'agy-tv-card-header-left' },
|
|
1043
|
+
IconBrowseOutline16(13),
|
|
1044
|
+
h('span', { className: 'agy-tv-card-path' }, model.title)
|
|
1045
|
+
),
|
|
1046
|
+
h(CopyButton, { text: model.output ?? '', t })
|
|
1047
|
+
),
|
|
1048
|
+
h('pre', { className: 'agy-tv-card-content' }, clip(rawBody, 16000)),
|
|
1049
|
+
inspectNode
|
|
1050
|
+
);
|
|
1051
|
+
}
|
|
1052
|
+
case 'question': {
|
|
1053
|
+
return h('div', { className: 'agy-tv-card' },
|
|
1054
|
+
h('div', { className: 'agy-tv-card-header' },
|
|
1055
|
+
h('div', { className: 'agy-tv-card-header-left' },
|
|
1056
|
+
IconQuestionOutline16(13),
|
|
1057
|
+
h('span', { className: 'agy-tv-card-path' }, model.title)
|
|
1058
|
+
),
|
|
1059
|
+
h(CopyButton, { text: model.output ?? (model.raw ?? '') })
|
|
1060
|
+
),
|
|
1061
|
+
h(QuestionCardBody, { model }),
|
|
1062
|
+
inspectNode
|
|
1063
|
+
);
|
|
1064
|
+
}
|
|
1065
|
+
case 'image': {
|
|
1066
|
+
return h('div', { className: 'agy-tv-card' },
|
|
1067
|
+
h('div', { className: 'agy-tv-card-header' },
|
|
1068
|
+
h('div', { className: 'agy-tv-card-header-left' },
|
|
1069
|
+
IconImageOutline16(13),
|
|
1070
|
+
h('span', { className: 'agy-tv-card-path' }, model.imageName || 'Image')
|
|
1071
|
+
),
|
|
1072
|
+
h(CopyButton, { text: model.prompt || (model.raw ?? '') })
|
|
1073
|
+
),
|
|
1074
|
+
h(ImageCardBody, { model }),
|
|
1075
|
+
inspectNode
|
|
1076
|
+
);
|
|
1077
|
+
}
|
|
1078
|
+
default: {
|
|
1079
|
+
const copyText = model.output !== undefined && model.output !== '' ? model.output : (model.raw ?? '');
|
|
1080
|
+
const rawBody = model.output !== undefined && model.output !== ''
|
|
1081
|
+
? trimTrailingBlankLines(model.output)
|
|
1082
|
+
: (model.raw !== undefined && model.raw !== '' ? clip(model.raw, 4000) : tr(t, 'tv.noDetail', '(no detail)'));
|
|
1083
|
+
return h('div', { className: 'agy-tv-card' },
|
|
1084
|
+
h('div', { className: 'agy-tv-card-header' },
|
|
1085
|
+
h('div', { className: 'agy-tv-card-header-left' },
|
|
1086
|
+
IconCodeOutline16(13),
|
|
1087
|
+
h('span', { className: 'agy-tv-card-path' }, model.server ? `${model.server}: ${model.tool}` : (model.title || model.tool || 'Tool'))
|
|
1088
|
+
),
|
|
1089
|
+
h(CopyButton, { text: copyText, t })
|
|
1090
|
+
),
|
|
1091
|
+
h('pre', { className: 'agy-tv-card-content' }, clip(rawBody, 16000)),
|
|
1092
|
+
inspectNode
|
|
1093
|
+
);
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
// ---- Main ToolView Component ----------------------------------------------
|
|
1099
|
+
|
|
1100
|
+
export function AgyMirrorToolView(props: AgyToolViewProps): unknown {
|
|
1101
|
+
const h = hx;
|
|
1102
|
+
const { block, cwd, home, openFile, inspect, t, callId } = props;
|
|
1103
|
+
const settle = isSettled(block);
|
|
1104
|
+
const err = isError(block);
|
|
1105
|
+
const model = mirrorCardModel(block, cwd, home);
|
|
1106
|
+
const cardKey = callId ? `call:${callId}` : `${model.kind}:${model.tool ?? ''}:${model.title}:${model.path ?? model.command ?? ''}`;
|
|
1107
|
+
const [open, setOpen] = useToggle(false, cardKey);
|
|
1108
|
+
const state: 'ok' | 'err' | 'run' = !settle ? 'run' : err ? 'err' : 'ok';
|
|
1109
|
+
const title = displayTitle(model, t);
|
|
1110
|
+
const summary = displaySummary(model, cwd, home);
|
|
1111
|
+
const stat = diffStat(model);
|
|
1112
|
+
const preview = !open && model.kind !== 'diff' ? previewLine(model, cwd, home) : undefined;
|
|
1113
|
+
const hasFileLink = (model.kind === 'diff' || model.kind === 'read') && model.path && openFile !== undefined;
|
|
1114
|
+
|
|
1115
|
+
const onFileClick = (e: { stopPropagation: () => void }) => {
|
|
1116
|
+
e.stopPropagation();
|
|
1117
|
+
if (model.path && openFile) {
|
|
1118
|
+
if (model.location?.line !== undefined) openFile(model.path, { line: model.location.line });
|
|
1119
|
+
else openFile(model.path);
|
|
1120
|
+
}
|
|
1121
|
+
};
|
|
1122
|
+
|
|
1123
|
+
const leading = open
|
|
1124
|
+
? h('span', { className: 'agy-tv-chevron-open' }, IconChevronDownOutline14(14))
|
|
1125
|
+
: h('span', { className: 'agy-tv-leading' },
|
|
1126
|
+
h('span', { className: 'agy-tv-icon-idle' }, toolIconFor(model.kind, 14)),
|
|
1127
|
+
h('span', { className: 'agy-tv-chevron-hover' }, IconChevronDownOutline14(14)),
|
|
1128
|
+
);
|
|
1129
|
+
|
|
1130
|
+
const summaryNode = hasFileLink
|
|
1131
|
+
? h('button', {
|
|
1132
|
+
type: 'button',
|
|
1133
|
+
className: 'agy-tv-file-link',
|
|
1134
|
+
onClick: onFileClick,
|
|
1135
|
+
title: model.path,
|
|
1136
|
+
}, summary)
|
|
1137
|
+
: h('span', {
|
|
1138
|
+
className: cls('agy-tv-summary', err && 'agy-tv-summary-err'),
|
|
1139
|
+
title: summary,
|
|
1140
|
+
}, summary);
|
|
1141
|
+
|
|
1142
|
+
const header = h('div', {
|
|
1143
|
+
className: 'agy-tv-row',
|
|
1144
|
+
role: 'button',
|
|
1145
|
+
tabIndex: 0,
|
|
1146
|
+
'aria-expanded': open,
|
|
1147
|
+
onClick: (e: { stopPropagation: () => void }) => {
|
|
1148
|
+
e.stopPropagation();
|
|
1149
|
+
setOpen();
|
|
1150
|
+
},
|
|
1151
|
+
onKeyDown: (e: { key: string; preventDefault: () => void }) => {
|
|
1152
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
1153
|
+
e.preventDefault();
|
|
1154
|
+
setOpen();
|
|
1155
|
+
}
|
|
1156
|
+
},
|
|
1157
|
+
title: inspect !== undefined
|
|
1158
|
+
? (open ? tr(t, 'tv.hint.collapseInspect', 'Click to collapse · right-click to inspect') : tr(t, 'tv.hint.expandInspect', 'Click to expand · right-click to inspect'))
|
|
1159
|
+
: (open ? tr(t, 'tv.hint.collapse', 'Click to collapse') : tr(t, 'tv.hint.expand', 'Click to expand')),
|
|
1160
|
+
onContextMenu: inspect !== undefined ? (e: { preventDefault: () => void }) => { e.preventDefault(); inspect(); } : undefined,
|
|
1161
|
+
},
|
|
1162
|
+
leading,
|
|
1163
|
+
h('span', { className: 'agy-tv-title' }, title),
|
|
1164
|
+
h('span', { className: 'agy-tv-sep', 'aria-hidden': true }),
|
|
1165
|
+
summaryNode,
|
|
1166
|
+
...(stat !== null ? [h('span', { key: 'stat', className: 'agy-tv-diff-stat' }, stat)] : []),
|
|
1167
|
+
...(preview !== undefined ? [h('span', { key: 'prev', className: 'agy-tv-preview', title: preview }, preview)] : []),
|
|
1168
|
+
);
|
|
1169
|
+
|
|
1170
|
+
return h('div', {
|
|
1171
|
+
className: cls('agy-tv-root', open && 'agy-tv-open'),
|
|
1172
|
+
'data-state': state,
|
|
1173
|
+
'data-kind': model.kind,
|
|
1174
|
+
},
|
|
1175
|
+
header,
|
|
1176
|
+
...(open ? [h('div', { key: 'wrap', className: 'agy-tv-body-wrap' },
|
|
1177
|
+
h(CardBody, { model, openFile, cwd, home, inspect, t })
|
|
1178
|
+
)] : [])
|
|
1179
|
+
);
|
|
1180
|
+
}
|
|
1181
|
+
|
|
1182
|
+
// ---- Register into DSH slots ----------------------------------------------
|
|
1183
|
+
|
|
1184
|
+
/**
|
|
1185
|
+
* Extract the agy mirror cursor (and tool name) from a run_code program.
|
|
1186
|
+
*
|
|
1187
|
+
* Only the wrapper this bridge actually generates counts: `mirrorStepInvocation`
|
|
1188
|
+
* (src/activity.ts) requires the exact two-line shape — one comment naming the
|
|
1189
|
+
* recorded step and one `tools['agy_tool']({run, step})` call — and rejects any
|
|
1190
|
+
* other program. Anything it rejects is ordinary Code Mode and renders as code.
|
|
1191
|
+
*/
|
|
1192
|
+
export function parseAgyMirrorFromCode(argsRaw: string): { run: string; step: number; tool?: string } | null {
|
|
1193
|
+
try {
|
|
1194
|
+
const parsed = JSON.parse(argsRaw) as { code?: unknown };
|
|
1195
|
+
const code = typeof parsed?.code === 'string' ? parsed.code : '';
|
|
1196
|
+
const step = mirrorStepInvocation(code);
|
|
1197
|
+
if (step === undefined) return null;
|
|
1198
|
+
return { run: step.run, step: step.step, tool: step.tool };
|
|
1199
|
+
} catch { /* not a mirror program */ }
|
|
1200
|
+
return null;
|
|
1201
|
+
}
|
|
1202
|
+
|
|
1203
|
+
/** Project a run_code program into the fields the code card renders. */
|
|
1204
|
+
export function runCodeModel(block?: ToolBlock): { code: string; title: string } {
|
|
1205
|
+
const raw = block !== undefined ? parsedArgsRaw(block) : '{}';
|
|
1206
|
+
let code = raw;
|
|
1207
|
+
let description: string | undefined;
|
|
1208
|
+
try {
|
|
1209
|
+
const parsed = JSON.parse(raw) as { code?: unknown; description?: unknown };
|
|
1210
|
+
if (typeof parsed?.code === 'string') code = parsed.code;
|
|
1211
|
+
if (typeof parsed?.description === 'string' && parsed.description !== '') description = parsed.description;
|
|
1212
|
+
} catch { /* raw args are not JSON — show them verbatim */ }
|
|
1213
|
+
const firstLine = code.split('\n').find((line) => line.trim() !== '');
|
|
1214
|
+
const title = description
|
|
1215
|
+
?? (firstLine !== undefined && firstLine.trim() !== '' ? firstLine.trim().slice(0, 120) : 'run_code');
|
|
1216
|
+
return { code, title };
|
|
1217
|
+
}
|
|
1218
|
+
|
|
1219
|
+
/**
|
|
1220
|
+
* Ordinary run_code toolview.
|
|
1221
|
+
*
|
|
1222
|
+
* The keyed `tool.call.toolview` registration for `run_code` REPLACES the
|
|
1223
|
+
* host's built-in code row rather than adding to it, so this branch owns the
|
|
1224
|
+
* icon, title, summary and expandable body for every non-mirror program. It
|
|
1225
|
+
* reuses the same styled vocabulary as the mirror card (`agy-tv-row` and
|
|
1226
|
+
* friends) so an ordinary Code Mode call reads exactly like a native tool row.
|
|
1227
|
+
*/
|
|
1228
|
+
export function AgyCodeToolView(props?: AgyToolViewProps): unknown {
|
|
1229
|
+
const h = hx;
|
|
1230
|
+
const { block, inspect, t, callId } = props ?? ({} as AgyToolViewProps);
|
|
1231
|
+
const model = runCodeModel(block);
|
|
1232
|
+
const cardKey = callId ? `call:${callId}` : `code:${model.title}`;
|
|
1233
|
+
const [open, setOpen] = useToggle(false, cardKey);
|
|
1234
|
+
const settle = block !== undefined && isSettled(block);
|
|
1235
|
+
const err = block !== undefined && isError(block);
|
|
1236
|
+
const state: 'ok' | 'err' | 'run' = !settle ? 'run' : err ? 'err' : 'ok';
|
|
1237
|
+
const translate = (key: string): string => (typeof t === 'function' ? t(key) : key);
|
|
1238
|
+
|
|
1239
|
+
const leading = open
|
|
1240
|
+
? h('span', { className: 'agy-tv-chevron-open' }, IconChevronDownOutline14(14))
|
|
1241
|
+
: h('span', { className: 'agy-tv-leading' },
|
|
1242
|
+
h('span', { className: 'agy-tv-icon-idle' }, IconCodeOutline16(14)),
|
|
1243
|
+
h('span', { className: 'agy-tv-chevron-hover' }, IconChevronDownOutline14(14)),
|
|
1244
|
+
);
|
|
1245
|
+
|
|
1246
|
+
const header = h('div', {
|
|
1247
|
+
className: 'agy-tv-row',
|
|
1248
|
+
role: 'button',
|
|
1249
|
+
tabIndex: 0,
|
|
1250
|
+
'aria-expanded': open,
|
|
1251
|
+
onClick: (e: { stopPropagation: () => void }) => {
|
|
1252
|
+
e.stopPropagation();
|
|
1253
|
+
setOpen();
|
|
1254
|
+
},
|
|
1255
|
+
onKeyDown: (e: { key: string; preventDefault: () => void }) => {
|
|
1256
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
1257
|
+
e.preventDefault();
|
|
1258
|
+
setOpen();
|
|
1259
|
+
}
|
|
1260
|
+
},
|
|
1261
|
+
title: inspect !== undefined
|
|
1262
|
+
? (open ? tr(t, 'tv.hint.collapseInspect', 'Click to collapse · right-click to inspect') : tr(t, 'tv.hint.expandInspect', 'Click to expand · right-click to inspect'))
|
|
1263
|
+
: (open ? tr(t, 'tv.hint.collapse', 'Click to collapse') : tr(t, 'tv.hint.expand', 'Click to expand')),
|
|
1264
|
+
onContextMenu: inspect !== undefined ? (e: { preventDefault: () => void }) => { e.preventDefault(); inspect(); } : undefined,
|
|
1265
|
+
},
|
|
1266
|
+
leading,
|
|
1267
|
+
h('span', { className: 'agy-tv-title' }, translate('code.title')),
|
|
1268
|
+
h('span', { className: 'agy-tv-sep', 'aria-hidden': true }),
|
|
1269
|
+
h('span', { className: cls('agy-tv-summary', err && 'agy-tv-summary-err'), title: model.title }, model.title),
|
|
1270
|
+
);
|
|
1271
|
+
|
|
1272
|
+
const inspectNode = inspect !== undefined
|
|
1273
|
+
? h('div', { key: 'ins', style: { padding: '4px 8px 6px' } },
|
|
1274
|
+
h('button', { type: 'button', className: 'agy-tv-inspect-btn', onClick: inspect },
|
|
1275
|
+
IconInspectOutline12(12), translate('code.inspect')))
|
|
1276
|
+
: null;
|
|
1277
|
+
|
|
1278
|
+
const body = h('div', { className: 'agy-tv-card' },
|
|
1279
|
+
h('div', { className: 'agy-tv-card-header' },
|
|
1280
|
+
h('div', { className: 'agy-tv-card-header-left' },
|
|
1281
|
+
IconCodeOutline16(13),
|
|
1282
|
+
h('span', { className: 'agy-tv-card-path' }, model.title),
|
|
1283
|
+
),
|
|
1284
|
+
h(CopyButton, { text: model.code, labels: [translate('code.copy'), translate('code.copied')] }),
|
|
1285
|
+
),
|
|
1286
|
+
h('pre', { className: 'agy-tv-card-content' }, clip(model.code, 16_000)),
|
|
1287
|
+
inspectNode,
|
|
1288
|
+
);
|
|
1289
|
+
|
|
1290
|
+
return h('div', {
|
|
1291
|
+
className: cls('agy-tv-root', open && 'agy-tv-open'),
|
|
1292
|
+
'data-state': state,
|
|
1293
|
+
'data-kind': 'code',
|
|
1294
|
+
},
|
|
1295
|
+
header,
|
|
1296
|
+
...(open ? [h('div', { key: 'wrap', className: 'agy-tv-body-wrap' }, body)] : [])
|
|
1297
|
+
);
|
|
1298
|
+
}
|
|
1299
|
+
|
|
1300
|
+
/**
|
|
1301
|
+
* run_code toolview: when the program is an agy mirror wrapper, render the
|
|
1302
|
+
* native Antigravity card instead of a raw code row; every other run_code
|
|
1303
|
+
* program renders through {@link AgyCodeToolView}.
|
|
1304
|
+
*/
|
|
1305
|
+
export function AgyRunCodeToolView(props?: unknown): unknown {
|
|
1306
|
+
const typed = props as AgyToolViewProps | undefined;
|
|
1307
|
+
const block = typed?.block;
|
|
1308
|
+
const raw = block !== undefined ? parsedArgsRaw(block) : '{}';
|
|
1309
|
+
const mirror = parseAgyMirrorFromCode(raw);
|
|
1310
|
+
if (mirror === null) return AgyCodeToolView(typed);
|
|
1311
|
+
let description: string | undefined;
|
|
1312
|
+
try {
|
|
1313
|
+
const parsed = JSON.parse(raw) as { description?: unknown };
|
|
1314
|
+
if (typeof parsed?.description === 'string' && parsed.description !== '') description = parsed.description;
|
|
1315
|
+
} catch { /* ignore */ }
|
|
1316
|
+
const synthetic = {
|
|
1317
|
+
...block,
|
|
1318
|
+
call: {
|
|
1319
|
+
...((block as { call?: { name?: string; argsRaw?: string } } | undefined)?.call ?? {}),
|
|
1320
|
+
name: 'agy_tool',
|
|
1321
|
+
argsRaw: JSON.stringify({
|
|
1322
|
+
run: mirror.run,
|
|
1323
|
+
step: mirror.step,
|
|
1324
|
+
...(mirror.tool !== undefined ? { tool: mirror.tool } : {}),
|
|
1325
|
+
...(description !== undefined ? { input: { description } } : {}),
|
|
1326
|
+
}),
|
|
1327
|
+
},
|
|
1328
|
+
} as unknown as ToolBlock;
|
|
1329
|
+
return AgyMirrorToolView({ block: synthetic, t: typed?.t } as never);
|
|
1330
|
+
}
|
|
1331
|
+
|
|
1332
|
+
/**
|
|
1333
|
+
* The two keyed views this integration contributes, in registration order.
|
|
1334
|
+
*
|
|
1335
|
+
* Fusion's own client entry performs the registration (it owns the single
|
|
1336
|
+
* `slots` dependency); this module only names what to register.
|
|
1337
|
+
*/
|
|
1338
|
+
export const AGY_TOOL_VIEWS: ReadonlyArray<{
|
|
1339
|
+
key: string;
|
|
1340
|
+
label: string;
|
|
1341
|
+
component: (props?: unknown) => React.ReactNode;
|
|
1342
|
+
}> = [
|
|
1343
|
+
{ key: 'agy_tool', label: 'Antigravity tool', component: AgyMirrorToolView as (props?: unknown) => React.ReactNode },
|
|
1344
|
+
// Code Mode wraps the mirror in `run_code`. A keyed slot entry is a takeover,
|
|
1345
|
+
// not an addition, so this view also owns ordinary programs — hence the
|
|
1346
|
+
// fallback to the code card inside AgyRunCodeToolView.
|
|
1347
|
+
{ key: 'run_code', label: 'Antigravity (code mode)', component: AgyRunCodeToolView as (props?: unknown) => React.ReactNode },
|
|
1348
|
+
];
|
|
1349
|
+
|
|
1350
|
+
// ---- Official CSS Styles --------------------------------------------------
|
|
1351
|
+
|
|
1352
|
+
const ROW_CSS = `
|
|
1353
|
+
/* Container */
|
|
1354
|
+
.agy-tv-root {
|
|
1355
|
+
display: flex;
|
|
1356
|
+
flex-direction: column;
|
|
1357
|
+
width: 100%;
|
|
1358
|
+
min-width: 0;
|
|
1359
|
+
position: relative;
|
|
1360
|
+
font-family: var(--dsw-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif);
|
|
1361
|
+
margin: 2px 0;
|
|
1362
|
+
}
|
|
1363
|
+
|
|
1364
|
+
/* Collapsed Header Row */
|
|
1365
|
+
.agy-tv-row {
|
|
1366
|
+
display: flex;
|
|
1367
|
+
align-items: center;
|
|
1368
|
+
height: calc(24px + var(--dsh-content-font-delta, 0px));
|
|
1369
|
+
min-width: 0;
|
|
1370
|
+
position: relative;
|
|
1371
|
+
overflow: hidden;
|
|
1372
|
+
cursor: pointer;
|
|
1373
|
+
user-select: none;
|
|
1374
|
+
background: transparent;
|
|
1375
|
+
border: none;
|
|
1376
|
+
padding: 0;
|
|
1377
|
+
width: 100%;
|
|
1378
|
+
text-align: left;
|
|
1379
|
+
color: var(--dsw-alias-label-primary, #0f172a);
|
|
1380
|
+
}
|
|
1381
|
+
|
|
1382
|
+
/* Running sweep shimmer animation */
|
|
1383
|
+
.agy-tv-root[data-state="run"] .agy-tv-row:after {
|
|
1384
|
+
content: "";
|
|
1385
|
+
position: absolute;
|
|
1386
|
+
top: 0;
|
|
1387
|
+
bottom: 0;
|
|
1388
|
+
left: 0;
|
|
1389
|
+
width: 300px;
|
|
1390
|
+
background: linear-gradient(90deg, transparent 0%, color-mix(in srgb, var(--dsw-alias-bg-base, #ffffff) 60%, transparent) 55%, transparent 100%);
|
|
1391
|
+
pointer-events: none;
|
|
1392
|
+
animation: 2.6s ease-out infinite agy-tv-sweep;
|
|
1393
|
+
}
|
|
1394
|
+
@keyframes agy-tv-sweep {
|
|
1395
|
+
0% { left: -300px; }
|
|
1396
|
+
90%, 100% { left: 100%; }
|
|
1397
|
+
}
|
|
1398
|
+
|
|
1399
|
+
/* Leading Icon with Hover-to-Arrow transition */
|
|
1400
|
+
.agy-tv-leading {
|
|
1401
|
+
position: relative;
|
|
1402
|
+
flex: none;
|
|
1403
|
+
width: calc(16px + var(--dsh-content-font-delta, 0px));
|
|
1404
|
+
height: calc(16px + var(--dsh-content-font-delta, 0px));
|
|
1405
|
+
display: inline-flex;
|
|
1406
|
+
align-items: center;
|
|
1407
|
+
justify-content: center;
|
|
1408
|
+
margin-right: 6px;
|
|
1409
|
+
color: var(--dsw-alias-label-tertiary, #64748b);
|
|
1410
|
+
}
|
|
1411
|
+
.agy-tv-leading svg {
|
|
1412
|
+
width: calc(14px + var(--dsh-content-font-delta, 0px));
|
|
1413
|
+
height: calc(14px + var(--dsh-content-font-delta, 0px));
|
|
1414
|
+
}
|
|
1415
|
+
.agy-tv-icon-idle {
|
|
1416
|
+
display: inline-flex;
|
|
1417
|
+
opacity: 1;
|
|
1418
|
+
transition: opacity 0.1s ease;
|
|
1419
|
+
}
|
|
1420
|
+
.agy-tv-chevron-hover {
|
|
1421
|
+
position: absolute;
|
|
1422
|
+
inset: 0;
|
|
1423
|
+
margin: auto;
|
|
1424
|
+
opacity: 0;
|
|
1425
|
+
transition: opacity 0.1s ease;
|
|
1426
|
+
display: inline-flex;
|
|
1427
|
+
align-items: center;
|
|
1428
|
+
justify-content: center;
|
|
1429
|
+
color: var(--dsw-alias-label-secondary, #334155);
|
|
1430
|
+
}
|
|
1431
|
+
.agy-tv-row:hover .agy-tv-icon-idle {
|
|
1432
|
+
opacity: 0;
|
|
1433
|
+
}
|
|
1434
|
+
.agy-tv-row:hover .agy-tv-chevron-hover {
|
|
1435
|
+
opacity: 1;
|
|
1436
|
+
}
|
|
1437
|
+
.agy-tv-chevron-open {
|
|
1438
|
+
position: relative;
|
|
1439
|
+
flex: none;
|
|
1440
|
+
width: calc(16px + var(--dsh-content-font-delta, 0px));
|
|
1441
|
+
height: calc(16px + var(--dsh-content-font-delta, 0px));
|
|
1442
|
+
display: inline-flex;
|
|
1443
|
+
align-items: center;
|
|
1444
|
+
justify-content: center;
|
|
1445
|
+
margin-right: 6px;
|
|
1446
|
+
color: var(--dsw-alias-label-secondary, #334155);
|
|
1447
|
+
}
|
|
1448
|
+
.agy-tv-chevron-open svg {
|
|
1449
|
+
width: calc(14px + var(--dsh-content-font-delta, 0px));
|
|
1450
|
+
height: calc(14px + var(--dsh-content-font-delta, 0px));
|
|
1451
|
+
}
|
|
1452
|
+
|
|
1453
|
+
/* Title */
|
|
1454
|
+
.agy-tv-title {
|
|
1455
|
+
flex: none;
|
|
1456
|
+
font-size: var(--dsh-content-font-size-secondary, 13px);
|
|
1457
|
+
line-height: calc(24px + var(--dsh-content-font-delta, 0px));
|
|
1458
|
+
color: var(--dsw-alias-label-secondary, #334155);
|
|
1459
|
+
font-weight: 400;
|
|
1460
|
+
}
|
|
1461
|
+
|
|
1462
|
+
/* Dot separator */
|
|
1463
|
+
.agy-tv-sep {
|
|
1464
|
+
background: var(--dsw-alias-label-caption, #94a3b8);
|
|
1465
|
+
border-radius: 1px;
|
|
1466
|
+
flex: none;
|
|
1467
|
+
width: 2px;
|
|
1468
|
+
height: 2px;
|
|
1469
|
+
margin: 0 8px;
|
|
1470
|
+
}
|
|
1471
|
+
|
|
1472
|
+
/* Summary */
|
|
1473
|
+
.agy-tv-summary {
|
|
1474
|
+
text-overflow: ellipsis;
|
|
1475
|
+
white-space: nowrap;
|
|
1476
|
+
min-width: 0;
|
|
1477
|
+
font-size: var(--dsh-content-font-size-secondary, 13px);
|
|
1478
|
+
line-height: calc(24px + var(--dsh-content-font-delta, 0px));
|
|
1479
|
+
color: var(--dsw-alias-label-tertiary, #64748b);
|
|
1480
|
+
flex: auto;
|
|
1481
|
+
overflow: hidden;
|
|
1482
|
+
}
|
|
1483
|
+
.agy-tv-summary-err {
|
|
1484
|
+
color: var(--dsw-alias-state-error-primary, #dc2626);
|
|
1485
|
+
}
|
|
1486
|
+
|
|
1487
|
+
/* File link button */
|
|
1488
|
+
.agy-tv-file-link {
|
|
1489
|
+
text-overflow: ellipsis;
|
|
1490
|
+
white-space: nowrap;
|
|
1491
|
+
min-width: 0;
|
|
1492
|
+
font: inherit;
|
|
1493
|
+
text-align: left;
|
|
1494
|
+
font-size: var(--dsh-content-font-size-secondary, 13px);
|
|
1495
|
+
line-height: calc(24px + var(--dsh-content-font-delta, 0px));
|
|
1496
|
+
color: var(--dsw-alias-label-secondary, #334155);
|
|
1497
|
+
text-decoration: underline dotted;
|
|
1498
|
+
text-decoration-color: var(--dsw-alias-label-tertiary, #64748b);
|
|
1499
|
+
text-underline-offset: 3px;
|
|
1500
|
+
cursor: pointer;
|
|
1501
|
+
background: none;
|
|
1502
|
+
border: none;
|
|
1503
|
+
flex: 0 auto;
|
|
1504
|
+
margin: 0;
|
|
1505
|
+
padding: 0;
|
|
1506
|
+
text-decoration-thickness: 1px;
|
|
1507
|
+
overflow: hidden;
|
|
1508
|
+
}
|
|
1509
|
+
.agy-tv-file-link:hover {
|
|
1510
|
+
color: var(--dsw-alias-label-primary, #0f172a);
|
|
1511
|
+
text-decoration-color: currentColor;
|
|
1512
|
+
}
|
|
1513
|
+
|
|
1514
|
+
/* Diff stat badge (+10 -2) */
|
|
1515
|
+
.agy-tv-diff-stat {
|
|
1516
|
+
font-family: var(--ds-font-family-code, ui-monospace, monospace);
|
|
1517
|
+
font-size: calc(var(--dsh-content-font-size-secondary, 13px) - 2px);
|
|
1518
|
+
color: var(--dsw-alias-label-caption, #94a3b8);
|
|
1519
|
+
margin-left: 10px;
|
|
1520
|
+
flex: none;
|
|
1521
|
+
}
|
|
1522
|
+
|
|
1523
|
+
/* Preview text */
|
|
1524
|
+
.agy-tv-preview {
|
|
1525
|
+
font-family: var(--ds-font-family-code, ui-monospace, monospace);
|
|
1526
|
+
font-size: 11px;
|
|
1527
|
+
color: var(--dsw-alias-label-caption, #94a3b8);
|
|
1528
|
+
margin-left: 8px;
|
|
1529
|
+
overflow: hidden;
|
|
1530
|
+
text-overflow: ellipsis;
|
|
1531
|
+
white-space: nowrap;
|
|
1532
|
+
max-width: 35%;
|
|
1533
|
+
flex: none;
|
|
1534
|
+
}
|
|
1535
|
+
|
|
1536
|
+
/* Body wrap */
|
|
1537
|
+
.agy-tv-body-wrap {
|
|
1538
|
+
display: flex;
|
|
1539
|
+
flex-direction: column;
|
|
1540
|
+
}
|
|
1541
|
+
|
|
1542
|
+
/* Card container */
|
|
1543
|
+
.agy-tv-card {
|
|
1544
|
+
border: 0.5px solid var(--dsw-alias-border-l1, #e2e8f0);
|
|
1545
|
+
background: var(--dsw-alias-markdown-code-block, #f8fafc);
|
|
1546
|
+
font-family: var(--ds-font-family-code, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);
|
|
1547
|
+
font-size: 12px;
|
|
1548
|
+
line-height: 1.55;
|
|
1549
|
+
border-radius: 12px;
|
|
1550
|
+
margin: 4px 0 4px 4px;
|
|
1551
|
+
display: flex;
|
|
1552
|
+
flex-direction: column;
|
|
1553
|
+
overflow: hidden;
|
|
1554
|
+
}
|
|
1555
|
+
|
|
1556
|
+
/* Card Header */
|
|
1557
|
+
.agy-tv-card-header {
|
|
1558
|
+
display: flex;
|
|
1559
|
+
align-items: center;
|
|
1560
|
+
justify-content: space-between;
|
|
1561
|
+
gap: 12px;
|
|
1562
|
+
padding: 8px 12px;
|
|
1563
|
+
background: var(--dsw-alias-markdown-code-block-banner, rgba(0, 0, 0, 0.02));
|
|
1564
|
+
border-bottom: 0.5px solid var(--dsw-alias-border-l2, #e2e8f0);
|
|
1565
|
+
}
|
|
1566
|
+
.agy-tv-card-header-left {
|
|
1567
|
+
display: flex;
|
|
1568
|
+
align-items: baseline;
|
|
1569
|
+
gap: 8px;
|
|
1570
|
+
min-width: 0;
|
|
1571
|
+
flex: 1;
|
|
1572
|
+
overflow: hidden;
|
|
1573
|
+
}
|
|
1574
|
+
.agy-tv-prompt-glyph {
|
|
1575
|
+
color: var(--dsw-alias-label-caption, #94a3b8);
|
|
1576
|
+
flex: none;
|
|
1577
|
+
font-weight: 700;
|
|
1578
|
+
}
|
|
1579
|
+
.agy-tv-card-cwd {
|
|
1580
|
+
color: var(--dsw-alias-label-tertiary, #64748b);
|
|
1581
|
+
flex: none;
|
|
1582
|
+
overflow: hidden;
|
|
1583
|
+
text-overflow: ellipsis;
|
|
1584
|
+
white-space: nowrap;
|
|
1585
|
+
}
|
|
1586
|
+
.agy-tv-card-cmd {
|
|
1587
|
+
color: var(--dsw-alias-label-primary, #0f172a);
|
|
1588
|
+
overflow: hidden;
|
|
1589
|
+
text-overflow: ellipsis;
|
|
1590
|
+
white-space: pre;
|
|
1591
|
+
font-weight: 600;
|
|
1592
|
+
}
|
|
1593
|
+
.agy-tv-card-path {
|
|
1594
|
+
color: var(--dsw-alias-label-primary, #0f172a);
|
|
1595
|
+
font-weight: 600;
|
|
1596
|
+
overflow: hidden;
|
|
1597
|
+
text-overflow: ellipsis;
|
|
1598
|
+
white-space: nowrap;
|
|
1599
|
+
}
|
|
1600
|
+
|
|
1601
|
+
/* Copy button */
|
|
1602
|
+
.agy-tv-copy-btn {
|
|
1603
|
+
display: inline-flex;
|
|
1604
|
+
align-items: center;
|
|
1605
|
+
gap: 4px;
|
|
1606
|
+
background: transparent;
|
|
1607
|
+
border: none;
|
|
1608
|
+
padding: 2px 6px;
|
|
1609
|
+
margin: 0;
|
|
1610
|
+
color: var(--dsw-alias-label-secondary, #334155);
|
|
1611
|
+
cursor: pointer;
|
|
1612
|
+
font-size: 11px;
|
|
1613
|
+
line-height: 16px;
|
|
1614
|
+
border-radius: 4px;
|
|
1615
|
+
transition: background-color 0.1s ease, color 0.1s ease;
|
|
1616
|
+
flex: none;
|
|
1617
|
+
}
|
|
1618
|
+
.agy-tv-copy-btn:hover {
|
|
1619
|
+
background: var(--dsw-alias-interactive-bg-hover, rgba(0, 0, 0, 0.05));
|
|
1620
|
+
color: var(--dsw-alias-label-primary, #0f172a);
|
|
1621
|
+
}
|
|
1622
|
+
|
|
1623
|
+
/* Card scrollable content */
|
|
1624
|
+
.agy-tv-card-content {
|
|
1625
|
+
max-height: 260px;
|
|
1626
|
+
overflow-y: auto;
|
|
1627
|
+
overflow-x: auto;
|
|
1628
|
+
padding: 10px 14px;
|
|
1629
|
+
white-space: pre-wrap;
|
|
1630
|
+
word-break: break-word;
|
|
1631
|
+
color: var(--dsw-alias-label-secondary, #334155);
|
|
1632
|
+
scrollbar-width: thin;
|
|
1633
|
+
scrollbar-color: var(--dsw-alias-border-l3, rgba(0, 0, 0, 0.2)) transparent;
|
|
1634
|
+
}
|
|
1635
|
+
.agy-tv-card-content::-webkit-scrollbar {
|
|
1636
|
+
width: 6px;
|
|
1637
|
+
height: 6px;
|
|
1638
|
+
}
|
|
1639
|
+
.agy-tv-card-content::-webkit-scrollbar-thumb {
|
|
1640
|
+
background: var(--dsw-alias-border-l3, rgba(0, 0, 0, 0.18));
|
|
1641
|
+
border-radius: 6px;
|
|
1642
|
+
background-clip: padding-box;
|
|
1643
|
+
}
|
|
1644
|
+
.agy-tv-card-content::-webkit-scrollbar-track {
|
|
1645
|
+
background: transparent;
|
|
1646
|
+
margin: 6px 0;
|
|
1647
|
+
}
|
|
1648
|
+
|
|
1649
|
+
/* Diff lines */
|
|
1650
|
+
.agy-tv-diff-list {
|
|
1651
|
+
display: flex;
|
|
1652
|
+
flex-direction: column;
|
|
1653
|
+
padding: 6px 0;
|
|
1654
|
+
max-height: 280px;
|
|
1655
|
+
overflow-y: auto;
|
|
1656
|
+
overflow-x: auto;
|
|
1657
|
+
scrollbar-width: thin;
|
|
1658
|
+
scrollbar-color: var(--dsw-alias-border-l3, rgba(0, 0, 0, 0.2)) transparent;
|
|
1659
|
+
}
|
|
1660
|
+
.agy-tv-diff-list::-webkit-scrollbar {
|
|
1661
|
+
width: 6px;
|
|
1662
|
+
height: 6px;
|
|
1663
|
+
}
|
|
1664
|
+
.agy-tv-diff-list::-webkit-scrollbar-thumb {
|
|
1665
|
+
background: var(--dsw-alias-border-l3, rgba(0, 0, 0, 0.18));
|
|
1666
|
+
border-radius: 6px;
|
|
1667
|
+
}
|
|
1668
|
+
.agy-tv-diff-list::-webkit-scrollbar-track {
|
|
1669
|
+
background: transparent;
|
|
1670
|
+
margin: 4px 0;
|
|
1671
|
+
}
|
|
1672
|
+
.agy-tv-diff-line {
|
|
1673
|
+
display: flex;
|
|
1674
|
+
gap: 8px;
|
|
1675
|
+
padding: 0 12px;
|
|
1676
|
+
min-height: 20px;
|
|
1677
|
+
line-height: 20px;
|
|
1678
|
+
white-space: pre-wrap;
|
|
1679
|
+
word-break: break-word;
|
|
1680
|
+
}
|
|
1681
|
+
.agy-tv-diff-del {
|
|
1682
|
+
background: color-mix(in srgb, var(--dsw-alias-state-error-primary, #dc2626) 10%, transparent);
|
|
1683
|
+
color: var(--dsw-alias-state-error-primary, #dc2626);
|
|
1684
|
+
}
|
|
1685
|
+
.agy-tv-diff-add {
|
|
1686
|
+
background: color-mix(in srgb, var(--dsw-alias-state-success-primary, #059669) 10%, transparent);
|
|
1687
|
+
color: var(--dsw-alias-state-success-primary, #059669);
|
|
1688
|
+
}
|
|
1689
|
+
.agy-tv-diff-marker {
|
|
1690
|
+
flex: none;
|
|
1691
|
+
width: 14px;
|
|
1692
|
+
font-weight: 700;
|
|
1693
|
+
user-select: none;
|
|
1694
|
+
}
|
|
1695
|
+
|
|
1696
|
+
/* Inspect button */
|
|
1697
|
+
.agy-tv-inspect-btn {
|
|
1698
|
+
border: 0.5px solid var(--dsw-alias-border-l3, #cbd5e1);
|
|
1699
|
+
background: var(--dsw-alias-bg-base, #ffffff);
|
|
1700
|
+
color: var(--dsw-alias-label-secondary, #334155);
|
|
1701
|
+
cursor: pointer;
|
|
1702
|
+
opacity: 0;
|
|
1703
|
+
border-radius: 999px;
|
|
1704
|
+
align-self: flex-start;
|
|
1705
|
+
align-items: center;
|
|
1706
|
+
gap: 4px;
|
|
1707
|
+
margin: 4px 0 2px 4px;
|
|
1708
|
+
padding: 2px 8px;
|
|
1709
|
+
font-size: 11px;
|
|
1710
|
+
line-height: 16px;
|
|
1711
|
+
transition: opacity 0.1s;
|
|
1712
|
+
display: inline-flex;
|
|
1713
|
+
}
|
|
1714
|
+
.agy-tv-root:hover .agy-tv-inspect-btn,
|
|
1715
|
+
.agy-tv-inspect-btn:focus-visible {
|
|
1716
|
+
opacity: 1;
|
|
1717
|
+
}
|
|
1718
|
+
.agy-tv-inspect-btn:hover {
|
|
1719
|
+
background: var(--dsw-alias-interactive-bg-hover-solid, #f1f5f9);
|
|
1720
|
+
color: var(--dsw-alias-label-primary, #0f172a);
|
|
1721
|
+
}
|
|
1722
|
+
|
|
1723
|
+
/* Question Card Styles */
|
|
1724
|
+
.agy-tv-question-wrap {
|
|
1725
|
+
padding: 10px 14px;
|
|
1726
|
+
display: flex;
|
|
1727
|
+
flex-direction: column;
|
|
1728
|
+
gap: 10px;
|
|
1729
|
+
font-family: inherit;
|
|
1730
|
+
}
|
|
1731
|
+
.agy-tv-q-item {
|
|
1732
|
+
display: flex;
|
|
1733
|
+
flex-direction: column;
|
|
1734
|
+
gap: 6px;
|
|
1735
|
+
}
|
|
1736
|
+
.agy-tv-q-prompt {
|
|
1737
|
+
font-size: 13px;
|
|
1738
|
+
font-weight: 600;
|
|
1739
|
+
color: var(--dsw-alias-label-primary, #0f172a);
|
|
1740
|
+
}
|
|
1741
|
+
.agy-tv-q-opts {
|
|
1742
|
+
display: flex;
|
|
1743
|
+
flex-direction: column;
|
|
1744
|
+
gap: 6px;
|
|
1745
|
+
}
|
|
1746
|
+
.agy-tv-q-opt {
|
|
1747
|
+
display: flex;
|
|
1748
|
+
align-items: center;
|
|
1749
|
+
gap: 8px;
|
|
1750
|
+
padding: 6px 10px;
|
|
1751
|
+
border-radius: 6px;
|
|
1752
|
+
background: var(--dsw-alias-bg-l2, rgba(127, 127, 127, 0.08));
|
|
1753
|
+
border: 1px solid var(--dsw-alias-border-l2, rgba(127, 127, 127, 0.2));
|
|
1754
|
+
color: var(--dsw-alias-label-primary, #334155);
|
|
1755
|
+
cursor: pointer;
|
|
1756
|
+
text-align: left;
|
|
1757
|
+
font-size: 12.5px;
|
|
1758
|
+
transition: all 0.15s ease;
|
|
1759
|
+
}
|
|
1760
|
+
.agy-tv-q-opt:hover {
|
|
1761
|
+
background: var(--dsw-alias-bg-hover, rgba(127, 127, 127, 0.15));
|
|
1762
|
+
border-color: var(--dsw-alias-border-l3, rgba(127, 127, 127, 0.35));
|
|
1763
|
+
}
|
|
1764
|
+
.agy-tv-q-opt.selected {
|
|
1765
|
+
background: rgba(16, 185, 129, 0.12);
|
|
1766
|
+
border-color: #10b981;
|
|
1767
|
+
color: #10b981;
|
|
1768
|
+
}
|
|
1769
|
+
.agy-tv-q-check {
|
|
1770
|
+
width: 14px;
|
|
1771
|
+
height: 14px;
|
|
1772
|
+
border: 1.5px solid currentColor;
|
|
1773
|
+
display: inline-flex;
|
|
1774
|
+
align-items: center;
|
|
1775
|
+
justify-content: center;
|
|
1776
|
+
flex-shrink: 0;
|
|
1777
|
+
}
|
|
1778
|
+
.agy-tv-q-check.radio {
|
|
1779
|
+
border-radius: 50%;
|
|
1780
|
+
}
|
|
1781
|
+
.agy-tv-q-check.checkbox {
|
|
1782
|
+
border-radius: 3px;
|
|
1783
|
+
}
|
|
1784
|
+
.agy-tv-q-check.checked:after {
|
|
1785
|
+
content: "";
|
|
1786
|
+
width: 6px;
|
|
1787
|
+
height: 6px;
|
|
1788
|
+
background: currentColor;
|
|
1789
|
+
border-radius: inherit;
|
|
1790
|
+
}
|
|
1791
|
+
.agy-tv-q-footer {
|
|
1792
|
+
display: flex;
|
|
1793
|
+
align-items: center;
|
|
1794
|
+
justify-content: space-between;
|
|
1795
|
+
padding-top: 6px;
|
|
1796
|
+
border-top: 1px solid var(--dsw-alias-border-l2, rgba(127, 127, 127, 0.15));
|
|
1797
|
+
}
|
|
1798
|
+
.agy-tv-q-insert-btn {
|
|
1799
|
+
padding: 5px 12px;
|
|
1800
|
+
border-radius: 6px;
|
|
1801
|
+
font-size: 12px;
|
|
1802
|
+
font-weight: 600;
|
|
1803
|
+
background: rgba(16, 185, 129, 0.15);
|
|
1804
|
+
border: 1px solid #10b981;
|
|
1805
|
+
color: #10b981;
|
|
1806
|
+
cursor: pointer;
|
|
1807
|
+
transition: all 0.15s ease;
|
|
1808
|
+
}
|
|
1809
|
+
.agy-tv-q-insert-btn:disabled {
|
|
1810
|
+
opacity: 0.4;
|
|
1811
|
+
cursor: not-allowed;
|
|
1812
|
+
}
|
|
1813
|
+
.agy-tv-q-insert-btn:not(:disabled):hover {
|
|
1814
|
+
background: #10b981;
|
|
1815
|
+
color: #fff;
|
|
1816
|
+
}
|
|
1817
|
+
.agy-tv-q-answered {
|
|
1818
|
+
font-size: 11px;
|
|
1819
|
+
color: var(--dsw-alias-label-tertiary, #888);
|
|
1820
|
+
}
|
|
1821
|
+
|
|
1822
|
+
/* Image Card Styles */
|
|
1823
|
+
.agy-tv-img-wrap {
|
|
1824
|
+
padding: 10px 14px;
|
|
1825
|
+
display: flex;
|
|
1826
|
+
flex-direction: column;
|
|
1827
|
+
gap: 8px;
|
|
1828
|
+
}
|
|
1829
|
+
.agy-tv-img-meta {
|
|
1830
|
+
display: flex;
|
|
1831
|
+
align-items: center;
|
|
1832
|
+
justify-content: space-between;
|
|
1833
|
+
gap: 8px;
|
|
1834
|
+
}
|
|
1835
|
+
.agy-tv-img-prompt {
|
|
1836
|
+
font-size: 12.5px;
|
|
1837
|
+
color: var(--dsw-alias-label-primary, #334155);
|
|
1838
|
+
font-style: italic;
|
|
1839
|
+
overflow: hidden;
|
|
1840
|
+
text-overflow: ellipsis;
|
|
1841
|
+
white-space: nowrap;
|
|
1842
|
+
}
|
|
1843
|
+
.agy-tv-img-badges {
|
|
1844
|
+
display: flex;
|
|
1845
|
+
gap: 4px;
|
|
1846
|
+
flex-shrink: 0;
|
|
1847
|
+
}
|
|
1848
|
+
.agy-tv-img-badge {
|
|
1849
|
+
font-size: 11px;
|
|
1850
|
+
padding: 1px 6px;
|
|
1851
|
+
border-radius: 4px;
|
|
1852
|
+
background: var(--dsw-alias-bg-l2, rgba(127, 127, 127, 0.1));
|
|
1853
|
+
border: 1px solid var(--dsw-alias-border-l2, rgba(127, 127, 127, 0.2));
|
|
1854
|
+
color: var(--dsw-alias-label-secondary, #888);
|
|
1855
|
+
}
|
|
1856
|
+
.agy-tv-img-preview-box {
|
|
1857
|
+
max-height: 320px;
|
|
1858
|
+
overflow: hidden;
|
|
1859
|
+
border-radius: 6px;
|
|
1860
|
+
border: 1px solid var(--dsw-alias-border-l2, rgba(127, 127, 127, 0.2));
|
|
1861
|
+
display: flex;
|
|
1862
|
+
align-items: center;
|
|
1863
|
+
justify-content: center;
|
|
1864
|
+
background: repeating-conic-gradient(rgba(127,127,127,0.08) 0% 25%, transparent 0% 50%) 50% / 16px 16px;
|
|
1865
|
+
cursor: zoom-in;
|
|
1866
|
+
}
|
|
1867
|
+
.agy-tv-img-thumb {
|
|
1868
|
+
max-width: 100%;
|
|
1869
|
+
max-height: 320px;
|
|
1870
|
+
object-fit: contain;
|
|
1871
|
+
}
|
|
1872
|
+
`;
|
|
1873
|
+
|
|
1874
|
+
/**
|
|
1875
|
+
* Install the tool-card stylesheet once and hand back its remover.
|
|
1876
|
+
*
|
|
1877
|
+
* Upstream injected it at module load; a Fusion client entry must be able to
|
|
1878
|
+
* unwind what it added, so the work moved behind this function. The style id is
|
|
1879
|
+
* namespaced to this plugin.
|
|
1880
|
+
*/
|
|
1881
|
+
export function installAgyToolViewStyles(): () => void {
|
|
1882
|
+
const gDoc = (globalThis as unknown as {
|
|
1883
|
+
document?: {
|
|
1884
|
+
getElementById(id: string): unknown;
|
|
1885
|
+
createElement(tag: string): { id?: string; textContent?: string };
|
|
1886
|
+
head?: unknown;
|
|
1887
|
+
documentElement?: { appendChild(n: unknown): void };
|
|
1888
|
+
};
|
|
1889
|
+
}).document;
|
|
1890
|
+
if (gDoc === undefined || gDoc === null) return () => {};
|
|
1891
|
+
const styleId = 'dsh-fusion-agy-toolview-css';
|
|
1892
|
+
let st = gDoc.getElementById(styleId) as { id?: string; textContent?: string; remove?(): void } | null;
|
|
1893
|
+
if (st === null) {
|
|
1894
|
+
st = gDoc.createElement('style');
|
|
1895
|
+
st.id = styleId;
|
|
1896
|
+
st.textContent = ROW_CSS;
|
|
1897
|
+
const host = (gDoc.head ?? gDoc.documentElement) as unknown as { appendChild(n: unknown): void };
|
|
1898
|
+
if (host !== undefined) host.appendChild(st);
|
|
1899
|
+
}
|
|
1900
|
+
return () => {
|
|
1901
|
+
st?.remove?.();
|
|
1902
|
+
};
|
|
1903
|
+
}
|