@dungle-scrubs/admin-ui-soft 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/GUIDE.md +110 -0
- package/LICENSE +21 -0
- package/README.md +36 -2
- package/THIRD-PARTY-NOTICES.md +25 -0
- package/UPSTREAM-VENDORED-CHANGES.md +317 -0
- package/VENDORED-CHANGES.md +60 -0
- package/dist/_virtual/_rolldown/runtime.js +13 -0
- package/dist/ai/compositions/agent-console/agent-console.d.ts +109 -0
- package/dist/ai/compositions/agent-console/agent-console.js +644 -0
- package/dist/ai/compositions/attention-feed/attention-feed.d.ts +127 -0
- package/dist/ai/compositions/attention-feed/attention-feed.js +626 -0
- package/dist/ai/compositions/conversation-browser/conversation-browser.d.ts +126 -0
- package/dist/ai/compositions/conversation-browser/conversation-browser.js +364 -0
- package/dist/ai/compositions/redaction-marker/redaction-marker.d.ts +42 -0
- package/dist/ai/compositions/redaction-marker/redaction-marker.js +202 -0
- package/dist/ai/compositions/run-inspector/json-view.js +164 -0
- package/dist/ai/compositions/run-inspector/run-inspector.d.ts +66 -0
- package/dist/ai/compositions/run-inspector/run-inspector.js +703 -0
- package/dist/ai/compositions/run-inspector/run-model.js +155 -0
- package/dist/ai/compositions/tool-approval/json-args.js +54 -0
- package/dist/ai/compositions/tool-approval/tool-approval.d.ts +57 -0
- package/dist/ai/compositions/tool-approval/tool-approval.js +331 -0
- package/dist/ai/compositions/tool-call-row/tool-call-row.js +74 -0
- package/dist/ai/compositions/transcript-viewer/to-thread-messages.js +65 -0
- package/dist/ai/compositions/transcript-viewer/transcript-viewer.d.ts +63 -0
- package/dist/ai/compositions/transcript-viewer/transcript-viewer.js +471 -0
- package/dist/ai/compositions/usage-meter/usage-format.js +107 -0
- package/dist/ai/compositions/usage-meter/usage-meter.d.ts +32 -0
- package/dist/ai/compositions/usage-meter/usage-meter.js +258 -0
- package/dist/ai/testing/mock-clock.d.ts +31 -0
- package/dist/ai/testing/mock-clock.js +66 -0
- package/dist/ai/testing/mock-reply.d.ts +70 -0
- package/dist/ai/testing/mock-reply.js +100 -0
- package/dist/ai/testing/mock-runtime.d.ts +86 -0
- package/dist/ai/testing/mock-runtime.js +384 -0
- package/dist/ai/types.d.ts +323 -0
- package/dist/ai.css +1088 -0
- package/dist/ai.d.ts +160 -0
- package/dist/ai.js +158 -0
- package/dist/components/assistant-ui/elements/activity-graph.d.ts +14 -0
- package/dist/components/assistant-ui/elements/activity-graph.js +69 -0
- package/dist/components/assistant-ui/elements/agent-card.d.ts +21 -0
- package/dist/components/assistant-ui/elements/agent-card.js +75 -0
- package/dist/components/assistant-ui/elements/agent-handoff.d.ts +13 -0
- package/dist/components/assistant-ui/elements/agent-handoff.js +47 -0
- package/dist/components/assistant-ui/elements/agent-plan.d.ts +16 -0
- package/dist/components/assistant-ui/elements/agent-plan.js +93 -0
- package/dist/components/assistant-ui/elements/agent-status.aui.d.ts +24 -0
- package/dist/components/assistant-ui/elements/agent-status.aui.js +161 -0
- package/dist/components/assistant-ui/elements/agent-status.d.ts +17 -0
- package/dist/components/assistant-ui/elements/agent-status.js +47 -0
- package/dist/components/assistant-ui/elements/approval-card.d.ts +31 -0
- package/dist/components/assistant-ui/elements/approval-card.js +99 -0
- package/dist/components/assistant-ui/elements/artifact-card.d.ts +12 -0
- package/dist/components/assistant-ui/elements/artifact-card.js +47 -0
- package/dist/components/assistant-ui/elements/assistant-modal.aui.d.ts +7 -0
- package/dist/components/assistant-ui/elements/assistant-modal.aui.js +276 -0
- package/dist/components/assistant-ui/elements/assistant-sidebar.aui.d.ts +7 -0
- package/dist/components/assistant-ui/elements/assistant-sidebar.aui.js +18 -0
- package/dist/components/assistant-ui/elements/attachment.aui.d.ts +9 -0
- package/dist/components/assistant-ui/elements/attachment.aui.js +143 -0
- package/dist/components/assistant-ui/elements/background-inbox.d.ts +18 -0
- package/dist/components/assistant-ui/elements/background-inbox.js +65 -0
- package/dist/components/assistant-ui/elements/canvas-split.d.ts +25 -0
- package/dist/components/assistant-ui/elements/canvas-split.js +106 -0
- package/dist/components/assistant-ui/elements/chart.d.ts +19 -0
- package/dist/components/assistant-ui/elements/chart.js +105 -0
- package/dist/components/assistant-ui/elements/chat-panel.d.ts +15 -0
- package/dist/components/assistant-ui/elements/chat-panel.js +82 -0
- package/dist/components/assistant-ui/elements/checkpoint-history.d.ts +17 -0
- package/dist/components/assistant-ui/elements/checkpoint-history.js +60 -0
- package/dist/components/assistant-ui/elements/code-diff.d.ts +18 -0
- package/dist/components/assistant-ui/elements/code-diff.js +89 -0
- package/dist/components/assistant-ui/elements/code-runner.d.ts +15 -0
- package/dist/components/assistant-ui/elements/code-runner.js +108 -0
- package/dist/components/assistant-ui/elements/command-palette.d.ts +20 -0
- package/dist/components/assistant-ui/elements/command-palette.js +129 -0
- package/dist/components/assistant-ui/elements/comparison-card.d.ts +18 -0
- package/dist/components/assistant-ui/elements/comparison-card.js +58 -0
- package/dist/components/assistant-ui/elements/composer-trigger-popover.aui.d.ts +51 -0
- package/dist/components/assistant-ui/elements/composer-trigger-popover.aui.js +104 -0
- package/dist/components/assistant-ui/elements/composer.d.ts +91 -0
- package/dist/components/assistant-ui/elements/composer.js +416 -0
- package/dist/components/assistant-ui/elements/computer-use.d.ts +19 -0
- package/dist/components/assistant-ui/elements/computer-use.js +84 -0
- package/dist/components/assistant-ui/elements/confidence-marker.d.ts +20 -0
- package/dist/components/assistant-ui/elements/confidence-marker.js +58 -0
- package/dist/components/assistant-ui/elements/connection-state.d.ts +13 -0
- package/dist/components/assistant-ui/elements/connection-state.js +59 -0
- package/dist/components/assistant-ui/elements/context-breakdown.d.ts +15 -0
- package/dist/components/assistant-ui/elements/context-breakdown.js +91 -0
- package/dist/components/assistant-ui/elements/context-display.aui.d.ts +25 -0
- package/dist/components/assistant-ui/elements/context-display.aui.js +26 -0
- package/dist/components/assistant-ui/elements/context-display.d.ts +43 -0
- package/dist/components/assistant-ui/elements/context-display.js +300 -0
- package/dist/components/assistant-ui/elements/conversation-map.aui.d.ts +9 -0
- package/dist/components/assistant-ui/elements/conversation-map.aui.js +177 -0
- package/dist/components/assistant-ui/elements/conversation-map.d.ts +19 -0
- package/dist/components/assistant-ui/elements/conversation-map.js +84 -0
- package/dist/components/assistant-ui/elements/conversation-search.d.ts +20 -0
- package/dist/components/assistant-ui/elements/conversation-search.js +75 -0
- package/dist/components/assistant-ui/elements/cost-meter.d.ts +19 -0
- package/dist/components/assistant-ui/elements/cost-meter.js +76 -0
- package/dist/components/assistant-ui/elements/data-table.d.ts +72 -0
- package/dist/components/assistant-ui/elements/data-table.js +368 -0
- package/dist/components/assistant-ui/elements/day-separator.d.ts +16 -0
- package/dist/components/assistant-ui/elements/day-separator.js +44 -0
- package/dist/components/assistant-ui/elements/diagram.d.ts +15 -0
- package/dist/components/assistant-ui/elements/diagram.js +65 -0
- package/dist/components/assistant-ui/elements/directive-text.aui.d.ts +11 -0
- package/dist/components/assistant-ui/elements/directive-text.aui.js +18 -0
- package/dist/components/assistant-ui/elements/directive-text.d.ts +32 -0
- package/dist/components/assistant-ui/elements/directive-text.js +35 -0
- package/dist/components/assistant-ui/elements/document-reference.d.ts +17 -0
- package/dist/components/assistant-ui/elements/document-reference.js +62 -0
- package/dist/components/assistant-ui/elements/draft-restore.d.ts +12 -0
- package/dist/components/assistant-ui/elements/draft-restore.js +43 -0
- package/dist/components/assistant-ui/elements/edit-message.d.ts +15 -0
- package/dist/components/assistant-ui/elements/edit-message.js +63 -0
- package/dist/components/assistant-ui/elements/elicitation-form.d.ts +23 -0
- package/dist/components/assistant-ui/elements/elicitation-form.js +112 -0
- package/dist/components/assistant-ui/elements/empty-state.d.ts +16 -0
- package/dist/components/assistant-ui/elements/empty-state.js +71 -0
- package/dist/components/assistant-ui/elements/error-state.d.ts +13 -0
- package/dist/components/assistant-ui/elements/error-state.js +52 -0
- package/dist/components/assistant-ui/elements/feedback-dialog.d.ts +15 -0
- package/dist/components/assistant-ui/elements/feedback-dialog.js +77 -0
- package/dist/components/assistant-ui/elements/file-tree.d.ts +20 -0
- package/dist/components/assistant-ui/elements/file-tree.js +74 -0
- package/dist/components/assistant-ui/elements/file.d.ts +52 -0
- package/dist/components/assistant-ui/elements/file.js +222 -0
- package/dist/components/assistant-ui/elements/flow-graph.d.ts +23 -0
- package/dist/components/assistant-ui/elements/flow-graph.js +72 -0
- package/dist/components/assistant-ui/elements/follow-up-suggestions.aui.d.ts +7 -0
- package/dist/components/assistant-ui/elements/follow-up-suggestions.aui.js +30 -0
- package/dist/components/assistant-ui/elements/generative-ui.d.ts +8 -0
- package/dist/components/assistant-ui/elements/generative-ui.js +27 -0
- package/dist/components/assistant-ui/elements/geo-map.d.ts +29 -0
- package/dist/components/assistant-ui/elements/geo-map.js +190 -0
- package/dist/components/assistant-ui/elements/guardrail-notice.d.ts +15 -0
- package/dist/components/assistant-ui/elements/guardrail-notice.js +59 -0
- package/dist/components/assistant-ui/elements/heat-graph.d.ts +9 -0
- package/dist/components/assistant-ui/elements/heat-graph.js +90 -0
- package/dist/components/assistant-ui/elements/image-gallery.d.ts +22 -0
- package/dist/components/assistant-ui/elements/image-gallery.js +192 -0
- package/dist/components/assistant-ui/elements/image-generation.d.ts +11 -0
- package/dist/components/assistant-ui/elements/image-generation.js +64 -0
- package/dist/components/assistant-ui/elements/image.d.ts +59 -0
- package/dist/components/assistant-ui/elements/image.js +416 -0
- package/dist/components/assistant-ui/elements/inline-citation.d.ts +23 -0
- package/dist/components/assistant-ui/elements/inline-citation.js +90 -0
- package/dist/components/assistant-ui/elements/job-progress.d.ts +25 -0
- package/dist/components/assistant-ui/elements/job-progress.js +102 -0
- package/dist/components/assistant-ui/elements/launcher-bubble.d.ts +15 -0
- package/dist/components/assistant-ui/elements/launcher-bubble.js +71 -0
- package/dist/components/assistant-ui/elements/link-preview.d.ts +17 -0
- package/dist/components/assistant-ui/elements/link-preview.js +77 -0
- package/dist/components/assistant-ui/elements/loading-state.d.ts +13 -0
- package/dist/components/assistant-ui/elements/loading-state.js +33 -0
- package/dist/components/assistant-ui/elements/logos.d.ts +10 -0
- package/dist/components/assistant-ui/elements/logos.js +63 -0
- package/dist/components/assistant-ui/elements/map-answer.d.ts +19 -0
- package/dist/components/assistant-ui/elements/map-answer.js +120 -0
- package/dist/components/assistant-ui/elements/markdown-text.d.ts +11 -0
- package/dist/components/assistant-ui/elements/markdown-text.js +152 -0
- package/dist/components/assistant-ui/elements/math-block.d.ts +25 -0
- package/dist/components/assistant-ui/elements/math-block.js +60 -0
- package/dist/components/assistant-ui/elements/mcp-config.aui.d.ts +28 -0
- package/dist/components/assistant-ui/elements/mcp-config.aui.js +380 -0
- package/dist/components/assistant-ui/elements/mcp-server-panel.d.ts +20 -0
- package/dist/components/assistant-ui/elements/mcp-server-panel.js +114 -0
- package/dist/components/assistant-ui/elements/media-player.d.ts +21 -0
- package/dist/components/assistant-ui/elements/media-player.js +302 -0
- package/dist/components/assistant-ui/elements/memory-chips.d.ts +16 -0
- package/dist/components/assistant-ui/elements/memory-chips.js +44 -0
- package/dist/components/assistant-ui/elements/mermaid-diagram.aui.d.ts +14 -0
- package/dist/components/assistant-ui/elements/mermaid-diagram.aui.js +43 -0
- package/dist/components/assistant-ui/elements/mermaid-diagram.d.ts +20 -0
- package/dist/components/assistant-ui/elements/mermaid-diagram.js +258 -0
- package/dist/components/assistant-ui/elements/message-actions.d.ts +17 -0
- package/dist/components/assistant-ui/elements/message-actions.js +57 -0
- package/dist/components/assistant-ui/elements/message-attachment.d.ts +18 -0
- package/dist/components/assistant-ui/elements/message-attachment.js +58 -0
- package/dist/components/assistant-ui/elements/message-branches.d.ts +12 -0
- package/dist/components/assistant-ui/elements/message-branches.js +55 -0
- package/dist/components/assistant-ui/elements/message-pair.d.ts +16 -0
- package/dist/components/assistant-ui/elements/message-pair.js +63 -0
- package/dist/components/assistant-ui/elements/message-queue.d.ts +15 -0
- package/dist/components/assistant-ui/elements/message-queue.js +70 -0
- package/dist/components/assistant-ui/elements/message-timing.aui.d.ts +30 -0
- package/dist/components/assistant-ui/elements/message-timing.aui.js +98 -0
- package/dist/components/assistant-ui/elements/message-timing.d.ts +14 -0
- package/dist/components/assistant-ui/elements/message-timing.js +26 -0
- package/dist/components/assistant-ui/elements/mobile-composer.d.ts +18 -0
- package/dist/components/assistant-ui/elements/mobile-composer.js +76 -0
- package/dist/components/assistant-ui/elements/model-picker.d.ts +19 -0
- package/dist/components/assistant-ui/elements/model-picker.js +68 -0
- package/dist/components/assistant-ui/elements/model-selector.aui.d.ts +23 -0
- package/dist/components/assistant-ui/elements/model-selector.aui.js +79 -0
- package/dist/components/assistant-ui/elements/model-selector.d.ts +130 -0
- package/dist/components/assistant-ui/elements/model-selector.js +399 -0
- package/dist/components/assistant-ui/elements/number-ticker.d.ts +10 -0
- package/dist/components/assistant-ui/elements/number-ticker.js +41 -0
- package/dist/components/assistant-ui/elements/onboarding.d.ts +17 -0
- package/dist/components/assistant-ui/elements/onboarding.js +69 -0
- package/dist/components/assistant-ui/elements/option-list.d.ts +39 -0
- package/dist/components/assistant-ui/elements/option-list.js +176 -0
- package/dist/components/assistant-ui/elements/permission-grant.d.ts +14 -0
- package/dist/components/assistant-ui/elements/permission-grant.js +84 -0
- package/dist/components/assistant-ui/elements/prompt-library.d.ts +20 -0
- package/dist/components/assistant-ui/elements/prompt-library.js +121 -0
- package/dist/components/assistant-ui/elements/question-flow.d.ts +24 -0
- package/dist/components/assistant-ui/elements/question-flow.js +180 -0
- package/dist/components/assistant-ui/elements/quota-banner.d.ts +14 -0
- package/dist/components/assistant-ui/elements/quota-banner.js +68 -0
- package/dist/components/assistant-ui/elements/quote-reply.d.ts +20 -0
- package/dist/components/assistant-ui/elements/quote-reply.js +66 -0
- package/dist/components/assistant-ui/elements/quote.aui.d.ts +61 -0
- package/dist/components/assistant-ui/elements/quote.aui.js +170 -0
- package/dist/components/assistant-ui/elements/read-aloud.d.ts +16 -0
- package/dist/components/assistant-ui/elements/read-aloud.js +66 -0
- package/dist/components/assistant-ui/elements/reasoning-effort.d.ts +17 -0
- package/dist/components/assistant-ui/elements/reasoning-effort.js +67 -0
- package/dist/components/assistant-ui/elements/reasoning-panel.d.ts +20 -0
- package/dist/components/assistant-ui/elements/reasoning-panel.js +60 -0
- package/dist/components/assistant-ui/elements/reasoning.aui.d.ts +24 -0
- package/dist/components/assistant-ui/elements/reasoning.aui.js +70 -0
- package/dist/components/assistant-ui/elements/reasoning.d.ts +38 -0
- package/dist/components/assistant-ui/elements/reasoning.js +194 -0
- package/dist/components/assistant-ui/elements/recommendation-card.d.ts +16 -0
- package/dist/components/assistant-ui/elements/recommendation-card.js +65 -0
- package/dist/components/assistant-ui/elements/regenerate-menu.d.ts +18 -0
- package/dist/components/assistant-ui/elements/regenerate-menu.js +46 -0
- package/dist/components/assistant-ui/elements/research-report.d.ts +19 -0
- package/dist/components/assistant-ui/elements/research-report.js +63 -0
- package/dist/components/assistant-ui/elements/retrieval-chunks.d.ts +19 -0
- package/dist/components/assistant-ui/elements/retrieval-chunks.js +86 -0
- package/dist/components/assistant-ui/elements/reviewable-diff.d.ts +21 -0
- package/dist/components/assistant-ui/elements/reviewable-diff.js +104 -0
- package/dist/components/assistant-ui/elements/schedule-card.d.ts +19 -0
- package/dist/components/assistant-ui/elements/schedule-card.js +80 -0
- package/dist/components/assistant-ui/elements/score-breakdown.d.ts +19 -0
- package/dist/components/assistant-ui/elements/score-breakdown.js +107 -0
- package/dist/components/assistant-ui/elements/scroll-anchor.d.ts +15 -0
- package/dist/components/assistant-ui/elements/scroll-anchor.js +104 -0
- package/dist/components/assistant-ui/elements/settings-panel.d.ts +23 -0
- package/dist/components/assistant-ui/elements/settings-panel.js +108 -0
- package/dist/components/assistant-ui/elements/shared-conversation.d.ts +18 -0
- package/dist/components/assistant-ui/elements/shared-conversation.js +56 -0
- package/dist/components/assistant-ui/elements/shiki-highlighter.aui.d.ts +29 -0
- package/dist/components/assistant-ui/elements/shiki-highlighter.aui.js +31 -0
- package/dist/components/assistant-ui/elements/shiki-highlighter.d.ts +26 -0
- package/dist/components/assistant-ui/elements/shiki-highlighter.js +49 -0
- package/dist/components/assistant-ui/elements/sources.aui.d.ts +24 -0
- package/dist/components/assistant-ui/elements/sources.aui.js +121 -0
- package/dist/components/assistant-ui/elements/sources.d.ts +21 -0
- package/dist/components/assistant-ui/elements/sources.js +109 -0
- package/dist/components/assistant-ui/elements/speaker-identity.d.ts +17 -0
- package/dist/components/assistant-ui/elements/speaker-identity.js +45 -0
- package/dist/components/assistant-ui/elements/spec-sheet.d.ts +17 -0
- package/dist/components/assistant-ui/elements/spec-sheet.js +39 -0
- package/dist/components/assistant-ui/elements/stopped-run.d.ts +12 -0
- package/dist/components/assistant-ui/elements/stopped-run.js +44 -0
- package/dist/components/assistant-ui/elements/streaming-text.d.ts +15 -0
- package/dist/components/assistant-ui/elements/streaming-text.js +45 -0
- package/dist/components/assistant-ui/elements/subagent-list.d.ts +17 -0
- package/dist/components/assistant-ui/elements/subagent-list.js +74 -0
- package/dist/components/assistant-ui/elements/suggestions.d.ts +14 -0
- package/dist/components/assistant-ui/elements/suggestions.js +25 -0
- package/dist/components/assistant-ui/elements/surfaces.d.ts +42 -0
- package/dist/components/assistant-ui/elements/surfaces.js +87 -0
- package/dist/components/assistant-ui/elements/syntax-highlighter.d.ts +7 -0
- package/dist/components/assistant-ui/elements/syntax-highlighter.js +41 -0
- package/dist/components/assistant-ui/elements/task-card.aui.d.ts +24 -0
- package/dist/components/assistant-ui/elements/task-card.aui.js +136 -0
- package/dist/components/assistant-ui/elements/task-card.d.ts +22 -0
- package/dist/components/assistant-ui/elements/task-card.js +104 -0
- package/dist/components/assistant-ui/elements/terminal-block.d.ts +27 -0
- package/dist/components/assistant-ui/elements/terminal-block.js +266 -0
- package/dist/components/assistant-ui/elements/thinking-indicator.d.ts +10 -0
- package/dist/components/assistant-ui/elements/thinking-indicator.js +30 -0
- package/dist/components/assistant-ui/elements/thread-list.aui.d.ts +39 -0
- package/dist/components/assistant-ui/elements/thread-list.aui.js +331 -0
- package/dist/components/assistant-ui/elements/thread-list.d.ts +19 -0
- package/dist/components/assistant-ui/elements/thread-list.js +72 -0
- package/dist/components/assistant-ui/elements/thread-search.d.ts +20 -0
- package/dist/components/assistant-ui/elements/thread-search.js +94 -0
- package/dist/components/assistant-ui/elements/thread.aui.d.ts +36 -0
- package/dist/components/assistant-ui/elements/thread.aui.js +625 -0
- package/dist/components/assistant-ui/elements/threadlist-sidebar.aui.d.ts +19 -0
- package/dist/components/assistant-ui/elements/threadlist-sidebar.aui.js +75 -0
- package/dist/components/assistant-ui/elements/timeline.d.ts +18 -0
- package/dist/components/assistant-ui/elements/timeline.js +40 -0
- package/dist/components/assistant-ui/elements/todo-list.d.ts +21 -0
- package/dist/components/assistant-ui/elements/todo-list.js +100 -0
- package/dist/components/assistant-ui/elements/tool-call.d.ts +17 -0
- package/dist/components/assistant-ui/elements/tool-call.js +70 -0
- package/dist/components/assistant-ui/elements/tool-error.d.ts +16 -0
- package/dist/components/assistant-ui/elements/tool-error.js +62 -0
- package/dist/components/assistant-ui/elements/tool-fallback.aui.d.ts +44 -0
- package/dist/components/assistant-ui/elements/tool-fallback.aui.js +542 -0
- package/dist/components/assistant-ui/elements/tool-group.aui.d.ts +37 -0
- package/dist/components/assistant-ui/elements/tool-group.aui.js +104 -0
- package/dist/components/assistant-ui/elements/tool-group.d.ts +20 -0
- package/dist/components/assistant-ui/elements/tool-group.js +71 -0
- package/dist/components/assistant-ui/elements/tool-timeline.d.ts +44 -0
- package/dist/components/assistant-ui/elements/tool-timeline.js +109 -0
- package/dist/components/assistant-ui/elements/tooltip-icon-button.d.ts +12 -0
- package/dist/components/assistant-ui/elements/tooltip-icon-button.js +30 -0
- package/dist/components/assistant-ui/elements/trace-waterfall.d.ts +33 -0
- package/dist/components/assistant-ui/elements/trace-waterfall.js +102 -0
- package/dist/components/assistant-ui/elements/typing-indicator.d.ts +9 -0
- package/dist/components/assistant-ui/elements/typing-indicator.js +45 -0
- package/dist/components/assistant-ui/elements/voice-conversation.aui.d.ts +11 -0
- package/dist/components/assistant-ui/elements/voice-conversation.aui.js +54 -0
- package/dist/components/assistant-ui/elements/voice-conversation.d.ts +21 -0
- package/dist/components/assistant-ui/elements/voice-conversation.js +110 -0
- package/dist/components/assistant-ui/elements/voice.aui.d.ts +22 -0
- package/dist/components/assistant-ui/elements/voice.aui.js +100 -0
- package/dist/components/assistant-ui/elements/voice.d.ts +15 -0
- package/dist/components/assistant-ui/elements/voice.js +400 -0
- package/dist/components/assistant-ui/elements/web-preview.d.ts +18 -0
- package/dist/components/assistant-ui/elements/web-preview.js +61 -0
- package/dist/components/assistant-ui/elements/web-search.d.ts +17 -0
- package/dist/components/assistant-ui/elements/web-search.js +54 -0
- package/dist/components/assistant-ui/utils/href.d.ts +13 -0
- package/dist/components/assistant-ui/utils/href.js +39 -0
- package/dist/components/assistant-ui/utils/range.d.ts +22 -0
- package/dist/components/assistant-ui/utils/range.js +48 -0
- package/dist/components/assistant-ui/utils/task.d.ts +14 -0
- package/dist/components/assistant-ui/utils/task.js +75 -0
- package/dist/components/icons/github.js +13 -0
- package/dist/components/theme-provider.d.ts +16 -0
- package/dist/components/theme-provider.js +116 -0
- package/dist/components/ui/accordion.d.ts +8 -0
- package/dist/components/ui/accordion.js +53 -0
- package/dist/components/ui/alert-dialog.d.ts +20 -0
- package/dist/components/ui/alert-dialog.js +93 -0
- package/dist/components/ui/alert.d.ts +12 -0
- package/dist/components/ui/alert.js +42 -0
- package/dist/components/ui/aspect-ratio.d.ts +6 -0
- package/dist/components/ui/aspect-ratio.js +13 -0
- package/dist/components/ui/attachment.d.ts +25 -0
- package/dist/components/ui/attachment.js +103 -0
- package/dist/components/ui/avatar.d.ts +13 -0
- package/dist/components/ui/avatar.js +50 -0
- package/dist/components/ui/badge.d.ts +14 -0
- package/dist/components/ui/badge.js +30 -0
- package/dist/components/ui/breadcrumb.d.ts +12 -0
- package/dist/components/ui/breadcrumb.js +71 -0
- package/dist/components/ui/bubble.d.ts +18 -0
- package/dist/components/ui/bubble.js +72 -0
- package/dist/components/ui/button-group.d.ts +12 -0
- package/dist/components/ui/button-group.js +41 -0
- package/dist/components/ui/button.d.ts +19 -0
- package/dist/components/ui/button.js +71 -0
- package/dist/components/ui/calendar.d.ts +12 -0
- package/dist/components/ui/calendar.js +108 -0
- package/dist/components/ui/card.d.ts +13 -0
- package/dist/components/ui/card.js +55 -0
- package/dist/components/ui/carousel.d.ts +30 -0
- package/dist/components/ui/carousel.js +131 -0
- package/dist/components/ui/chart.d.ts +46 -0
- package/dist/components/ui/chart.js +148 -0
- package/dist/components/ui/checkbox.d.ts +5 -0
- package/dist/components/ui/checkbox.js +20 -0
- package/dist/components/ui/collapsible.d.ts +7 -0
- package/dist/components/ui/collapsible.js +23 -0
- package/dist/components/ui/combobox.d.ts +26 -0
- package/dist/components/ui/combobox.js +161 -0
- package/dist/components/ui/command.d.ts +21 -0
- package/dist/components/ui/command.js +87 -0
- package/dist/components/ui/context-menu.d.ts +31 -0
- package/dist/components/ui/context-menu.js +132 -0
- package/dist/components/ui/dialog.d.ts +19 -0
- package/dist/components/ui/dialog.js +91 -0
- package/dist/components/ui/diff-viewer.d.ts +100 -0
- package/dist/components/ui/diff-viewer.js +461 -0
- package/dist/components/ui/direction.d.ts +2 -0
- package/dist/components/ui/direction.js +2 -0
- package/dist/components/ui/dot-matrix.d.ts +150 -0
- package/dist/components/ui/dot-matrix.js +248 -0
- package/dist/components/ui/drawer.d.ts +18 -0
- package/dist/components/ui/drawer.js +123 -0
- package/dist/components/ui/dropdown-menu.d.ts +31 -0
- package/dist/components/ui/dropdown-menu.js +136 -0
- package/dist/components/ui/empty.d.ts +13 -0
- package/dist/components/ui/empty.js +59 -0
- package/dist/components/ui/field.d.ts +26 -0
- package/dist/components/ui/field.js +109 -0
- package/dist/components/ui/hover-card.d.ts +7 -0
- package/dist/components/ui/hover-card.js +36 -0
- package/dist/components/ui/input-group.d.ts +20 -0
- package/dist/components/ui/input-group.js +77 -0
- package/dist/components/ui/input-otp.d.ts +13 -0
- package/dist/components/ui/input-otp.js +46 -0
- package/dist/components/ui/input.d.ts +5 -0
- package/dist/components/ui/input.js +14 -0
- package/dist/components/ui/item.d.ts +24 -0
- package/dist/components/ui/item.js +120 -0
- package/dist/components/ui/kbd.d.ts +5 -0
- package/dist/components/ui/kbd.js +19 -0
- package/dist/components/ui/label.d.ts +5 -0
- package/dist/components/ui/label.js +12 -0
- package/dist/components/ui/marker.d.ts +12 -0
- package/dist/components/ui/marker.js +42 -0
- package/dist/components/ui/menubar.d.ts +31 -0
- package/dist/components/ui/menubar.js +135 -0
- package/dist/components/ui/message-scroller.d.ts +12 -0
- package/dist/components/ui/message-scroller.js +59 -0
- package/dist/components/ui/message.d.ts +12 -0
- package/dist/components/ui/message.js +48 -0
- package/dist/components/ui/native-select.d.ts +10 -0
- package/dist/components/ui/native-select.js +37 -0
- package/dist/components/ui/navigation-menu.d.ts +13 -0
- package/dist/components/ui/navigation-menu.js +82 -0
- package/dist/components/ui/number-roll.d.ts +21 -0
- package/dist/components/ui/number-roll.js +269 -0
- package/dist/components/ui/pagination.d.ts +19 -0
- package/dist/components/ui/pagination.js +79 -0
- package/dist/components/ui/popover.d.ts +11 -0
- package/dist/components/ui/popover.js +54 -0
- package/dist/components/ui/progress.d.ts +9 -0
- package/dist/components/ui/progress.js +44 -0
- package/dist/components/ui/questionnaire.d.ts +21 -0
- package/dist/components/ui/questionnaire.js +169 -0
- package/dist/components/ui/radio-group.d.ts +7 -0
- package/dist/components/ui/radio-group.js +26 -0
- package/dist/components/ui/resizable.d.ts +9 -0
- package/dist/components/ui/resizable.js +28 -0
- package/dist/components/ui/scroll-area.d.ts +6 -0
- package/dist/components/ui/scroll-area.js +35 -0
- package/dist/components/ui/select.d.ts +17 -0
- package/dist/components/ui/select.js +96 -0
- package/dist/components/ui/separator.d.ts +5 -0
- package/dist/components/ui/separator.js +14 -0
- package/dist/components/ui/sheet.d.ts +16 -0
- package/dist/components/ui/sheet.js +87 -0
- package/dist/components/ui/sidebar.d.ts +65 -0
- package/dist/components/ui/sidebar.js +386 -0
- package/dist/components/ui/skeleton.d.ts +4 -0
- package/dist/components/ui/skeleton.js +12 -0
- package/dist/components/ui/slider.d.ts +5 -0
- package/dist/components/ui/slider.js +33 -0
- package/dist/components/ui/spinner.d.ts +4 -0
- package/dist/components/ui/spinner.js +15 -0
- package/dist/components/ui/switch.d.ts +7 -0
- package/dist/components/ui/switch.js +19 -0
- package/dist/components/ui/table.d.ts +12 -0
- package/dist/components/ui/table.js +65 -0
- package/dist/components/ui/tabs.d.ts +12 -0
- package/dist/components/ui/tabs.js +45 -0
- package/dist/components/ui/textarea.d.ts +5 -0
- package/dist/components/ui/textarea.js +12 -0
- package/dist/components/ui/toast.d.ts +18 -0
- package/dist/components/ui/toast.js +121 -0
- package/dist/components/ui/toggle-group.d.ts +13 -0
- package/dist/components/ui/toggle-group.js +51 -0
- package/dist/components/ui/toggle.d.ts +10 -0
- package/dist/components/ui/toggle.js +35 -0
- package/dist/components/ui/tooltip.d.ts +8 -0
- package/dist/components/ui/tooltip.js +43 -0
- package/dist/compositions/app-rail/app-rail.d.ts +19 -0
- package/dist/compositions/app-rail/app-rail.js +58 -0
- package/dist/compositions/app-shell/app-shell.d.ts +56 -0
- package/dist/compositions/app-shell/app-shell.js +143 -0
- package/dist/compositions/app-shell/theme-toggle.d.ts +10 -0
- package/dist/compositions/app-shell/theme-toggle.js +65 -0
- package/dist/compositions/confirm-action/confirm-action.d.ts +48 -0
- package/dist/compositions/confirm-action/confirm-action.js +48 -0
- package/dist/compositions/data-table/data-table-state.d.ts +23 -0
- package/dist/compositions/data-table/data-table-state.js +46 -0
- package/dist/compositions/data-table/data-table.d.ts +185 -0
- package/dist/compositions/data-table/data-table.js +615 -0
- package/dist/compositions/date-range-picker/date-range-options.d.ts +28 -0
- package/dist/compositions/date-range-picker/date-range-options.js +61 -0
- package/dist/compositions/date-range-picker/date-range-picker.d.ts +55 -0
- package/dist/compositions/date-range-picker/date-range-picker.js +409 -0
- package/dist/compositions/decision-queue/decision-queue.d.ts +114 -0
- package/dist/compositions/decision-queue/decision-queue.js +478 -0
- package/dist/compositions/event-feed/event-feed.d.ts +59 -0
- package/dist/compositions/event-feed/event-feed.js +105 -0
- package/dist/compositions/feedback.d.ts +20 -0
- package/dist/compositions/feedback.js +49 -0
- package/dist/compositions/fields.d.ts +64 -0
- package/dist/compositions/fields.js +293 -0
- package/dist/compositions/form-kit/form-context.d.ts +10 -0
- package/dist/compositions/form-kit/form-context.js +12 -0
- package/dist/compositions/form-kit/form-fields.d.ts +95 -0
- package/dist/compositions/form-kit/form-fields.js +233 -0
- package/dist/compositions/form-kit/form-kit.d.ts +128 -0
- package/dist/compositions/form-kit/form-kit.js +119 -0
- package/dist/compositions/inspector/inspector.d.ts +53 -0
- package/dist/compositions/inspector/inspector.js +80 -0
- package/dist/compositions/layout.d.ts +36 -0
- package/dist/compositions/layout.js +86 -0
- package/dist/compositions/state-blocks/state-blocks.d.ts +42 -0
- package/dist/compositions/state-blocks/state-blocks.js +81 -0
- package/dist/compositions/status-panel/status-panel.d.ts +94 -0
- package/dist/compositions/status-panel/status-panel.js +189 -0
- package/dist/fonts/InterVariable.woff2 +0 -0
- package/dist/fonts/inter.css +15 -0
- package/dist/hooks/use-attachment-src.js +35 -0
- package/dist/hooks/use-copy-to-clipboard.js +34 -0
- package/dist/hooks/use-mobile.d.ts +3 -0
- package/dist/hooks/use-mobile.js +18 -0
- package/dist/index.d.ts +102 -0
- package/dist/index.js +102 -0
- package/dist/lib/context-level.js +7 -0
- package/dist/lib/elapsed.js +61 -0
- package/dist/lib/iso-date.js +30 -0
- package/dist/lib/motion-loop.js +41 -0
- package/dist/lib/pointer.js +14 -0
- package/dist/lib/status-tone.d.ts +7 -0
- package/dist/lib/status-tone.js +55 -0
- package/dist/lib/triage-keys.js +229 -0
- package/dist/lib/utils.js +2 -0
- package/dist/motion/alert-toast/alert-toast.d.ts +51 -0
- package/dist/motion/alert-toast/alert-toast.js +226 -0
- package/dist/motion/branch-menu/branch-menu.d.ts +47 -0
- package/dist/motion/branch-menu/branch-menu.js +287 -0
- package/dist/motion/check-item/check-item.d.ts +24 -0
- package/dist/motion/check-item/check-item.js +110 -0
- package/dist/motion/dial/dial.d.ts +39 -0
- package/dist/motion/dial/dial.js +290 -0
- package/dist/motion/dictation-button/dictation-button.d.ts +45 -0
- package/dist/motion/dictation-button/dictation-button.js +232 -0
- package/dist/motion/hold-button/hold-button.d.ts +37 -0
- package/dist/motion/hold-button/hold-button.js +192 -0
- package/dist/motion/masonry-grid/masonry-grid.d.ts +42 -0
- package/dist/motion/masonry-grid/masonry-grid.js +145 -0
- package/dist/motion/prompt-composer/prompt-composer.d.ts +90 -0
- package/dist/motion/prompt-composer/prompt-composer.js +374 -0
- package/dist/motion/scrub-select/scrub-select.d.ts +33 -0
- package/dist/motion/scrub-select/scrub-select.js +346 -0
- package/dist/motion/spotlight-grid/spotlight-grid.d.ts +40 -0
- package/dist/motion/spotlight-grid/spotlight-grid.js +171 -0
- package/dist/motion/star-rating/star-rating.d.ts +32 -0
- package/dist/motion/star-rating/star-rating.js +191 -0
- package/dist/motion/status-glyph/status-glyph.d.ts +28 -0
- package/dist/motion/status-glyph/status-glyph.js +171 -0
- package/dist/motion/stepper/stepper.d.ts +56 -0
- package/dist/motion/stepper/stepper.js +211 -0
- package/dist/motion/swipe-row/swipe-row.d.ts +52 -0
- package/dist/motion/swipe-row/swipe-row.js +208 -0
- package/dist/motion/thinking-trace/thinking-trace.d.ts +32 -0
- package/dist/motion/thinking-trace/thinking-trace.js +186 -0
- package/dist/motion/tool-call-chip/tool-call-chip.d.ts +36 -0
- package/dist/motion/tool-call-chip/tool-call-chip.js +135 -0
- package/dist/motion/working-indicator/working-indicator.d.ts +38 -0
- package/dist/motion/working-indicator/working-indicator.js +171 -0
- package/dist/styles.css +828 -0
- package/dist/tokens.css +230 -0
- package/licenses/Inter-OFL.txt +92 -0
- package/licenses/assistant-ui-MIT.txt +21 -0
- package/licenses/shadcn-MIT.md +21 -0
- package/package.json +131 -3
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
//#region src/ai/compositions/run-inspector/run-model.ts
|
|
2
|
+
/** Milliseconds since the epoch for an ISO time, or `undefined` for a bad one. */
|
|
3
|
+
function timeOf(iso) {
|
|
4
|
+
if (iso === void 0) return void 0;
|
|
5
|
+
const ms = Date.parse(iso);
|
|
6
|
+
return Number.isNaN(ms) ? void 0 : ms;
|
|
7
|
+
}
|
|
8
|
+
function runBounds(run, now) {
|
|
9
|
+
const stepTimes = run.steps.flatMap((step) => [timeOf(step.startedAt), timeOf(step.endedAt)].filter((ms) => ms !== void 0));
|
|
10
|
+
const start = timeOf(run.startedAt) ?? timeOf(run.createdAt) ?? (stepTimes.length > 0 ? Math.min(...stepTimes) : 0);
|
|
11
|
+
const ended = timeOf(run.endedAt);
|
|
12
|
+
if (ended !== void 0) return {
|
|
13
|
+
start,
|
|
14
|
+
end: Math.max(ended, start),
|
|
15
|
+
ended: true
|
|
16
|
+
};
|
|
17
|
+
const reference = timeOf(now) ?? (stepTimes.length > 0 ? Math.max(...stepTimes) : void 0) ?? start;
|
|
18
|
+
return {
|
|
19
|
+
start,
|
|
20
|
+
end: Math.max(reference, start),
|
|
21
|
+
ended: false
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function stepTiming(step, bounds) {
|
|
25
|
+
const start = timeOf(step.startedAt) ?? bounds.start;
|
|
26
|
+
const end = timeOf(step.endedAt);
|
|
27
|
+
const offsetMs = Math.max(0, start - bounds.start);
|
|
28
|
+
if (end !== void 0) return {
|
|
29
|
+
offsetMs,
|
|
30
|
+
durationMs: Math.max(0, end - start),
|
|
31
|
+
open: false
|
|
32
|
+
};
|
|
33
|
+
if (step.status === "running") return {
|
|
34
|
+
offsetMs,
|
|
35
|
+
durationMs: Math.max(0, bounds.end - start),
|
|
36
|
+
open: true
|
|
37
|
+
};
|
|
38
|
+
return {
|
|
39
|
+
offsetMs,
|
|
40
|
+
durationMs: void 0,
|
|
41
|
+
open: false
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/** How deep a step nests under its parents (0 for a top-level step). */
|
|
45
|
+
function stepDepth(step, byId) {
|
|
46
|
+
let depth = 0;
|
|
47
|
+
const seen = /* @__PURE__ */ new Set([step.id]);
|
|
48
|
+
let parent = step.parentStepId ? byId.get(step.parentStepId) : void 0;
|
|
49
|
+
while (parent && !seen.has(parent.id)) {
|
|
50
|
+
seen.add(parent.id);
|
|
51
|
+
depth += 1;
|
|
52
|
+
parent = parent.parentStepId ? byId.get(parent.parentStepId) : void 0;
|
|
53
|
+
}
|
|
54
|
+
return depth;
|
|
55
|
+
}
|
|
56
|
+
/** The status word for a step, as the inspector says it. */
|
|
57
|
+
const STEP_STATUS_LABEL = {
|
|
58
|
+
pending: "Pending",
|
|
59
|
+
running: "Running",
|
|
60
|
+
succeeded: "Succeeded",
|
|
61
|
+
failed: "Failed",
|
|
62
|
+
skipped: "Skipped"
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* The status word for one step. A tool call the owner denied reads "Denied",
|
|
66
|
+
* the word its detail uses, rather than the step's generic "Skipped".
|
|
67
|
+
*/
|
|
68
|
+
function stepStatusLabel(step) {
|
|
69
|
+
return step.toolCall?.status === "denied" ? "Denied" : STEP_STATUS_LABEL[step.status];
|
|
70
|
+
}
|
|
71
|
+
/** How a retry is marked in a step's name or chip, in both views: `#2` and up. */
|
|
72
|
+
function attemptMark(step) {
|
|
73
|
+
return (step.attempt ?? 1) > 1 ? ` #${step.attempt}` : "";
|
|
74
|
+
}
|
|
75
|
+
/** The status word for a run. */
|
|
76
|
+
const RUN_STATUS_LABEL = {
|
|
77
|
+
pending: "Queued",
|
|
78
|
+
running: "Running",
|
|
79
|
+
waiting: "Waiting for approval",
|
|
80
|
+
succeeded: "Succeeded",
|
|
81
|
+
failed: "Failed",
|
|
82
|
+
cancelled: "Cancelled"
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* A step's name in the waterfall: its label, as the timeline titles it, with
|
|
86
|
+
* `#2` and up for a retry so two attempts read apart.
|
|
87
|
+
*/
|
|
88
|
+
function spanName(step) {
|
|
89
|
+
return `${step.label}${attemptMark(step)}`;
|
|
90
|
+
}
|
|
91
|
+
const SPAN_STATUS = {
|
|
92
|
+
pending: "completed",
|
|
93
|
+
running: "running",
|
|
94
|
+
succeeded: "completed",
|
|
95
|
+
failed: "failed",
|
|
96
|
+
skipped: "completed"
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* The run's steps as waterfall spans, in timeline order: each placed on the
|
|
100
|
+
* run's clock, indented by nesting. A step with no recorded length draws as a
|
|
101
|
+
* sliver at its start.
|
|
102
|
+
*/
|
|
103
|
+
function toSpans(run, bounds) {
|
|
104
|
+
const byId = new Map(run.steps.map((step) => [step.id, step]));
|
|
105
|
+
return run.steps.map((step) => {
|
|
106
|
+
const timing = stepTiming(step, bounds);
|
|
107
|
+
const duration = timing.durationMs === void 0 ? "no recorded length" : `${timing.durationMs} ms`;
|
|
108
|
+
const attempt = (step.attempt ?? 1) > 1 ? `, attempt ${step.attempt}` : "";
|
|
109
|
+
return {
|
|
110
|
+
id: step.id,
|
|
111
|
+
name: spanName(step),
|
|
112
|
+
depth: stepDepth(step, byId),
|
|
113
|
+
startMs: Math.round(timing.offsetMs),
|
|
114
|
+
durationMs: Math.round(timing.durationMs ?? 0),
|
|
115
|
+
status: SPAN_STATUS[step.status],
|
|
116
|
+
label: `${step.label}${attempt}, ${stepStatusLabel(step).toLowerCase()}, starts at ${Math.round(timing.offsetMs)} ms, ${duration}`
|
|
117
|
+
};
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* The step an inspector opens on: the first failed step a retry did not
|
|
122
|
+
* recover, else the step still running, else the first step.
|
|
123
|
+
*/
|
|
124
|
+
function defaultStepId(steps) {
|
|
125
|
+
const unrecovered = steps.find((step) => step.status === "failed" && !attemptsOf(step, steps).some((attempt) => attempt.status === "succeeded"));
|
|
126
|
+
if (unrecovered) return unrecovered.id;
|
|
127
|
+
return (steps.findLast((step) => step.status === "running") ?? steps[0])?.id ?? null;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Every attempt of the action `step` belongs to, oldest first, linked by
|
|
131
|
+
* `retryOf`. A step that was never retried returns just itself.
|
|
132
|
+
*/
|
|
133
|
+
function attemptsOf(step, steps) {
|
|
134
|
+
const byId = new Map(steps.map((item) => [item.id, item]));
|
|
135
|
+
const rootOf = (item) => {
|
|
136
|
+
let current = item;
|
|
137
|
+
const seen = /* @__PURE__ */ new Set([current.id]);
|
|
138
|
+
while (current.retryOf) {
|
|
139
|
+
const previous = byId.get(current.retryOf);
|
|
140
|
+
if (!previous || seen.has(previous.id)) break;
|
|
141
|
+
seen.add(previous.id);
|
|
142
|
+
current = previous;
|
|
143
|
+
}
|
|
144
|
+
return current.id;
|
|
145
|
+
};
|
|
146
|
+
const root = rootOf(step);
|
|
147
|
+
const group = steps.filter((item) => rootOf(item) === root);
|
|
148
|
+
return group.length > 1 ? [...group].sort((a, b) => (a.attempt ?? 1) - (b.attempt ?? 1)) : [step];
|
|
149
|
+
}
|
|
150
|
+
/** Paragraphs of reasoning or message text, split on blank lines. */
|
|
151
|
+
function paragraphsOf(text) {
|
|
152
|
+
return text.split(/\n\s*\n/).map((paragraph) => paragraph.trim()).filter((paragraph) => paragraph.length > 0);
|
|
153
|
+
}
|
|
154
|
+
//#endregion
|
|
155
|
+
export { RUN_STATUS_LABEL, STEP_STATUS_LABEL, attemptMark, attemptsOf, defaultStepId, paragraphsOf, runBounds, spanName, stepDepth, stepStatusLabel, stepTiming, timeOf, toSpans };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
//#region src/ai/compositions/tool-approval/json-args.ts
|
|
2
|
+
/** Arguments as the editor shows them: two-space indented JSON. */
|
|
3
|
+
function formatArgs(args) {
|
|
4
|
+
return JSON.stringify(args, null, 2);
|
|
5
|
+
}
|
|
6
|
+
/** One argument value as a single line: strings bare, everything else as compact JSON. */
|
|
7
|
+
function formatArgValue(value) {
|
|
8
|
+
return typeof value === "string" ? value : JSON.stringify(value);
|
|
9
|
+
}
|
|
10
|
+
function isJsonObject(value) {
|
|
11
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Reads edited argument text. It must be a JSON object, as a tool's arguments
|
|
15
|
+
* are. On success `text` is the canonical form (`formatArgs`), so edits that
|
|
16
|
+
* only change whitespace compare equal to the original.
|
|
17
|
+
*/
|
|
18
|
+
function parseArgs(text) {
|
|
19
|
+
if (text.trim() === "") return {
|
|
20
|
+
ok: false,
|
|
21
|
+
error: "Enter the arguments as a JSON object."
|
|
22
|
+
};
|
|
23
|
+
let value;
|
|
24
|
+
try {
|
|
25
|
+
value = JSON.parse(text);
|
|
26
|
+
} catch (error) {
|
|
27
|
+
return {
|
|
28
|
+
ok: false,
|
|
29
|
+
error: `Not valid JSON: ${error instanceof Error ? error.message : String(error)}`
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
if (!isJsonObject(value)) return {
|
|
33
|
+
ok: false,
|
|
34
|
+
error: "The arguments must be a JSON object, in braces."
|
|
35
|
+
};
|
|
36
|
+
return {
|
|
37
|
+
ok: true,
|
|
38
|
+
args: value,
|
|
39
|
+
text: formatArgs(value)
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* A short, one-line summary of the arguments, such as
|
|
44
|
+
* `account: fastmail, uids: [48112,48113]`, for a chip or a subtitle. The
|
|
45
|
+
* caller truncates it visually.
|
|
46
|
+
*/
|
|
47
|
+
function summarizeArgs(args, maxEntries = 3) {
|
|
48
|
+
const entries = Object.entries(args);
|
|
49
|
+
const shown = entries.slice(0, maxEntries).map(([key, value]) => `${key}: ${formatArgValue(value)}`);
|
|
50
|
+
const more = entries.length - shown.length;
|
|
51
|
+
return more > 0 ? `${shown.join(", ")}, +${more} more` : shown.join(", ");
|
|
52
|
+
}
|
|
53
|
+
//#endregion
|
|
54
|
+
export { formatArgValue, formatArgs, parseArgs, summarizeArgs };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { JsonObject, ToolCall } from "../../types.js";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
//#region src/ai/compositions/tool-approval/tool-approval.d.ts
|
|
4
|
+
export interface ToolApprovalProps extends Omit<React.ComponentProps<"div">, "children" | "title" | "onError"> {
|
|
5
|
+
/** The pending call. Its `approval` (or a status past `awaiting-approval`) settles the card. */
|
|
6
|
+
toolCall: ToolCall;
|
|
7
|
+
/** A plain-language title, such as "Purge 1 sign-in email". Defaults to the tool's name. */
|
|
8
|
+
title?: string;
|
|
9
|
+
/** The agent asking, as a display name, such as "Email agent". */
|
|
10
|
+
agent?: string;
|
|
11
|
+
/** Why the agent wants to run it, or what it will do. */
|
|
12
|
+
description?: string;
|
|
13
|
+
/**
|
|
14
|
+
* The owner approved. `amendedArgs` is set when they edited the arguments
|
|
15
|
+
* first: run the call with those instead of `toolCall.args`.
|
|
16
|
+
*/
|
|
17
|
+
onApprove: (amendedArgs?: JsonObject) => void;
|
|
18
|
+
/** The owner denied, with the optional reason they typed. */
|
|
19
|
+
onDeny: (reason?: string) => void;
|
|
20
|
+
/**
|
|
21
|
+
* The owner wants this tool allowed from now on. The card only emits the
|
|
22
|
+
* intent; the app records the standing permission (and approves this call,
|
|
23
|
+
* if that is its rule). Omit it to hide the option.
|
|
24
|
+
*/
|
|
25
|
+
onAlwaysAllow?: () => void;
|
|
26
|
+
/** Offer editing the arguments before approving. */
|
|
27
|
+
editable?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* A decision is in flight. The card stays as it is, controls disabled,
|
|
30
|
+
* until the app settles `toolCall` or sets `error`: it never assumes the
|
|
31
|
+
* decision landed.
|
|
32
|
+
*/
|
|
33
|
+
pending?: boolean;
|
|
34
|
+
/** Why the last decision failed. It shows in place until dismissed. */
|
|
35
|
+
error?: string | null;
|
|
36
|
+
/** The owner dismissed `error`. Clear it here. */
|
|
37
|
+
onDismissError?: () => void;
|
|
38
|
+
/** How long a dangerous tool's approve button must be held, in ms. */
|
|
39
|
+
holdDuration?: number;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* A card for one tool call waiting on the owner. Approve it, deny it (with an
|
|
43
|
+
* optional reason), edit its arguments and then approve (the card shows a
|
|
44
|
+
* diff of the edits and emits the amended arguments), or allow the tool from
|
|
45
|
+
* now on. A dangerous tool needs a press-and-hold to approve (HoldButton:
|
|
46
|
+
* hold Space or Enter on the keyboard).
|
|
47
|
+
*
|
|
48
|
+
* Decisions are non-optimistic: the card shows `pending` until the app
|
|
49
|
+
* settles `toolCall` (its `approval`, or a status past `awaiting-approval`),
|
|
50
|
+
* then shows the outcome as a receipt. A failed decision shows `error` in
|
|
51
|
+
* place, keeping any edits, until the owner dismisses it.
|
|
52
|
+
*
|
|
53
|
+
* Built on the registry's `elements-approval-card`, with `diff-viewer` for the
|
|
54
|
+
* edit diff and HoldButton for dangerous tools.
|
|
55
|
+
*/
|
|
56
|
+
export declare function ToolApproval({ toolCall, title, agent, description, onApprove, onDeny, onAlwaysAllow, editable, pending, error, onDismissError, holdDuration, className, ...props }: ToolApprovalProps): React.JSX.Element;
|
|
57
|
+
//#endregion
|
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
import { Alert, AlertAction, AlertDescription, AlertTitle } from "../../../components/ui/alert.js";
|
|
2
|
+
import { Spinner } from "../../../components/ui/spinner.js";
|
|
3
|
+
import { Button } from "../../../components/ui/button.js";
|
|
4
|
+
import { Input } from "../../../components/ui/input.js";
|
|
5
|
+
import { Textarea } from "../../../components/ui/textarea.js";
|
|
6
|
+
import { Field, FieldDescription, FieldError, FieldLabel } from "../../../components/ui/field.js";
|
|
7
|
+
import { HoldButton } from "../../../motion/hold-button/hold-button.js";
|
|
8
|
+
import { formatArgValue, formatArgs, parseArgs } from "./json-args.js";
|
|
9
|
+
import { ApprovalCard } from "../../../components/assistant-ui/elements/approval-card.js";
|
|
10
|
+
import { DiffViewer } from "../../../components/ui/diff-viewer.js";
|
|
11
|
+
import * as React from "react";
|
|
12
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { cn } from "cn";
|
|
14
|
+
import { AlertCircleIcon, PencilIcon, ShieldAlertIcon, WrenchIcon, XIcon } from "lucide-react";
|
|
15
|
+
//#region src/ai/compositions/tool-approval/tool-approval.tsx
|
|
16
|
+
/**
|
|
17
|
+
* The receipt a settled call shows in place of the buttons. It is worded from
|
|
18
|
+
* the record: a call with no approval on it claims no approval.
|
|
19
|
+
*/
|
|
20
|
+
function receipt(toolCall) {
|
|
21
|
+
const { approval, status } = toolCall;
|
|
22
|
+
const by = approval?.decidedBy ? ` by ${approval.decidedBy}` : "";
|
|
23
|
+
if (approval?.decision === "rejected" || status === "denied") return {
|
|
24
|
+
state: "denied",
|
|
25
|
+
label: `Denied${by}${approval?.reason ? `: ${approval.reason}` : ""}`
|
|
26
|
+
};
|
|
27
|
+
if (status === "cancelled") return {
|
|
28
|
+
state: "denied",
|
|
29
|
+
label: "Cancelled"
|
|
30
|
+
};
|
|
31
|
+
const allowed = !approval ? null : approval.byStandingPermission ? "Allowed by standing permission" : `Approved${approval.amendedArgs ? " with edits" : ""}${by}`;
|
|
32
|
+
const then = (outcome) => allowed ? `${allowed}, ${outcome}` : capitalize(outcome);
|
|
33
|
+
if (status === "failed") {
|
|
34
|
+
const why = toolCall.error ? `: ${toolCall.error.message}` : "";
|
|
35
|
+
return {
|
|
36
|
+
state: "denied",
|
|
37
|
+
label: allowed ? `${then("then failed")}${why}` : `Failed${why}`
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
if (status === "succeeded") return {
|
|
41
|
+
state: "done",
|
|
42
|
+
label: then("finished")
|
|
43
|
+
};
|
|
44
|
+
return {
|
|
45
|
+
state: "running",
|
|
46
|
+
label: then("running")
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function capitalize(text) {
|
|
50
|
+
return text.charAt(0).toUpperCase() + text.slice(1);
|
|
51
|
+
}
|
|
52
|
+
function isSettled(toolCall) {
|
|
53
|
+
return toolCall.approval !== void 0 || toolCall.status !== "awaiting-approval";
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* A card for one tool call waiting on the owner. Approve it, deny it (with an
|
|
57
|
+
* optional reason), edit its arguments and then approve (the card shows a
|
|
58
|
+
* diff of the edits and emits the amended arguments), or allow the tool from
|
|
59
|
+
* now on. A dangerous tool needs a press-and-hold to approve (HoldButton:
|
|
60
|
+
* hold Space or Enter on the keyboard).
|
|
61
|
+
*
|
|
62
|
+
* Decisions are non-optimistic: the card shows `pending` until the app
|
|
63
|
+
* settles `toolCall` (its `approval`, or a status past `awaiting-approval`),
|
|
64
|
+
* then shows the outcome as a receipt. A failed decision shows `error` in
|
|
65
|
+
* place, keeping any edits, until the owner dismisses it.
|
|
66
|
+
*
|
|
67
|
+
* Built on the registry's `elements-approval-card`, with `diff-viewer` for the
|
|
68
|
+
* edit diff and HoldButton for dangerous tools.
|
|
69
|
+
*/
|
|
70
|
+
function ToolApproval({ toolCall, title, agent, description, onApprove, onDeny, onAlwaysAllow, editable = true, pending = false, error, onDismissError, holdDuration = 1500, className, ...props }) {
|
|
71
|
+
const baseId = React.useId();
|
|
72
|
+
const [mode, setMode] = React.useState("review");
|
|
73
|
+
const [reason, setReason] = React.useState("");
|
|
74
|
+
const original = React.useMemo(() => formatArgs(toolCall.args), [toolCall.args]);
|
|
75
|
+
const [draft, setDraft] = React.useState(original);
|
|
76
|
+
const [holdHint, setHoldHint] = React.useState(false);
|
|
77
|
+
const denyButton = React.useRef(null);
|
|
78
|
+
const editButton = React.useRef(null);
|
|
79
|
+
const reasonInput = React.useRef(null);
|
|
80
|
+
const argsEditor = React.useRef(null);
|
|
81
|
+
const settled = isSettled(toolCall);
|
|
82
|
+
const dangerous = toolCall.dangerous === true;
|
|
83
|
+
const parsed = React.useMemo(() => parseArgs(draft), [draft]);
|
|
84
|
+
const changed = parsed.ok && parsed.text !== original;
|
|
85
|
+
React.useEffect(() => {
|
|
86
|
+
if (mode === "deny") reasonInput.current?.focus();
|
|
87
|
+
if (mode === "edit") argsEditor.current?.focus();
|
|
88
|
+
}, [mode]);
|
|
89
|
+
const leave = (to) => {
|
|
90
|
+
setMode("review");
|
|
91
|
+
requestAnimationFrame(() => to.current?.focus());
|
|
92
|
+
};
|
|
93
|
+
const deny = () => {
|
|
94
|
+
if (pending) return;
|
|
95
|
+
const trimmed = reason.trim();
|
|
96
|
+
onDeny(trimmed === "" ? void 0 : trimmed);
|
|
97
|
+
};
|
|
98
|
+
const approveEdited = () => {
|
|
99
|
+
if (pending || !parsed.ok || !changed) return;
|
|
100
|
+
onApprove(parsed.args);
|
|
101
|
+
};
|
|
102
|
+
const errorId = `${baseId}-error`;
|
|
103
|
+
const reasonId = `${baseId}-reason`;
|
|
104
|
+
const editorId = `${baseId}-args`;
|
|
105
|
+
const editorHelpId = `${baseId}-args-help`;
|
|
106
|
+
const holdHintId = `${baseId}-hold-hint`;
|
|
107
|
+
const secondary = "@max-sm/approval:flex-1";
|
|
108
|
+
const primary = "@max-sm/approval:w-full";
|
|
109
|
+
const approveButton = (label, onConfirm, disabled) => dangerous ? /* @__PURE__ */ jsx(HoldButton, {
|
|
110
|
+
variant: "destructive",
|
|
111
|
+
holdDuration,
|
|
112
|
+
doneLabel: "Approving",
|
|
113
|
+
disabled: disabled || pending,
|
|
114
|
+
onHold: onConfirm,
|
|
115
|
+
onTap: () => setHoldHint(true),
|
|
116
|
+
onBlur: () => setHoldHint(false),
|
|
117
|
+
"aria-describedby": holdHint ? holdHintId : void 0,
|
|
118
|
+
"data-action": "approve",
|
|
119
|
+
className: primary,
|
|
120
|
+
children: `Hold to ${label.toLowerCase()}`
|
|
121
|
+
}) : /* @__PURE__ */ jsx(Button, {
|
|
122
|
+
type: "button",
|
|
123
|
+
disabled: disabled || pending,
|
|
124
|
+
onClick: onConfirm,
|
|
125
|
+
"data-action": "approve",
|
|
126
|
+
className: primary,
|
|
127
|
+
children: label
|
|
128
|
+
});
|
|
129
|
+
const pendingStatus = pending ? /* @__PURE__ */ jsxs("span", {
|
|
130
|
+
className: "inline-flex basis-full items-center justify-end gap-1.5 text-muted-foreground text-xs",
|
|
131
|
+
children: [/* @__PURE__ */ jsx(Spinner, {
|
|
132
|
+
"aria-hidden": "true",
|
|
133
|
+
className: "size-3.5"
|
|
134
|
+
}), "Recording decision"]
|
|
135
|
+
}) : null;
|
|
136
|
+
const actions = mode === "deny" ? /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
137
|
+
pendingStatus,
|
|
138
|
+
/* @__PURE__ */ jsx(Button, {
|
|
139
|
+
type: "button",
|
|
140
|
+
variant: "ghost",
|
|
141
|
+
disabled: pending,
|
|
142
|
+
onClick: () => leave(denyButton),
|
|
143
|
+
className: secondary,
|
|
144
|
+
children: "Back"
|
|
145
|
+
}),
|
|
146
|
+
/* @__PURE__ */ jsx(Button, {
|
|
147
|
+
type: "button",
|
|
148
|
+
variant: "destructive",
|
|
149
|
+
disabled: pending,
|
|
150
|
+
onClick: deny,
|
|
151
|
+
"data-action": "deny-confirm",
|
|
152
|
+
className: primary,
|
|
153
|
+
children: "Deny"
|
|
154
|
+
})
|
|
155
|
+
] }) : mode === "edit" ? /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
156
|
+
pendingStatus,
|
|
157
|
+
/* @__PURE__ */ jsx(Button, {
|
|
158
|
+
type: "button",
|
|
159
|
+
variant: "ghost",
|
|
160
|
+
disabled: pending,
|
|
161
|
+
onClick: () => leave(editButton),
|
|
162
|
+
className: secondary,
|
|
163
|
+
children: "Cancel"
|
|
164
|
+
}),
|
|
165
|
+
approveButton("Approve with edits", approveEdited, !parsed.ok || !changed)
|
|
166
|
+
] }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
167
|
+
pendingStatus,
|
|
168
|
+
/* @__PURE__ */ jsx(Button, {
|
|
169
|
+
ref: denyButton,
|
|
170
|
+
type: "button",
|
|
171
|
+
variant: "ghost",
|
|
172
|
+
disabled: pending,
|
|
173
|
+
onClick: () => setMode("deny"),
|
|
174
|
+
"data-action": "deny",
|
|
175
|
+
className: secondary,
|
|
176
|
+
children: "Deny"
|
|
177
|
+
}),
|
|
178
|
+
editable ? /* @__PURE__ */ jsxs(Button, {
|
|
179
|
+
ref: editButton,
|
|
180
|
+
type: "button",
|
|
181
|
+
variant: "ghost",
|
|
182
|
+
disabled: pending,
|
|
183
|
+
onClick: () => {
|
|
184
|
+
setDraft(original);
|
|
185
|
+
setMode("edit");
|
|
186
|
+
},
|
|
187
|
+
"data-action": "edit",
|
|
188
|
+
className: secondary,
|
|
189
|
+
children: [/* @__PURE__ */ jsx(PencilIcon, { "aria-hidden": "true" }), "Edit"]
|
|
190
|
+
}) : null,
|
|
191
|
+
onAlwaysAllow ? /* @__PURE__ */ jsx(Button, {
|
|
192
|
+
type: "button",
|
|
193
|
+
variant: "outline",
|
|
194
|
+
disabled: pending,
|
|
195
|
+
onClick: onAlwaysAllow,
|
|
196
|
+
"data-action": "always-allow",
|
|
197
|
+
className: secondary,
|
|
198
|
+
children: "Always allow"
|
|
199
|
+
}) : null,
|
|
200
|
+
approveButton("Approve", () => onApprove(), false)
|
|
201
|
+
] });
|
|
202
|
+
const argEntries = Object.entries(toolCall.args);
|
|
203
|
+
const outcome = settled ? receipt(toolCall) : null;
|
|
204
|
+
const subtitle = [agent, title && title !== toolCall.name ? toolCall.name : null].filter(Boolean).join(" · ");
|
|
205
|
+
return /* @__PURE__ */ jsxs(ApprovalCard, {
|
|
206
|
+
...props,
|
|
207
|
+
"data-tool-approval": "",
|
|
208
|
+
"data-mode": settled ? "settled" : mode,
|
|
209
|
+
"aria-busy": pending || void 0,
|
|
210
|
+
state: outcome?.state ?? "request",
|
|
211
|
+
statusLabel: outcome?.label,
|
|
212
|
+
title: title ?? toolCall.name,
|
|
213
|
+
subtitle: subtitle || (dangerous ? "Dangerous tool" : "Tool call"),
|
|
214
|
+
description,
|
|
215
|
+
variant: dangerous ? "destructive" : "default",
|
|
216
|
+
icon: dangerous ? /* @__PURE__ */ jsx(ShieldAlertIcon, { className: "size-4" }) : /* @__PURE__ */ jsx(WrenchIcon, { className: "size-4" }),
|
|
217
|
+
details: mode === "edit" || argEntries.length === 0 ? void 0 : argEntries.map(([label, value]) => ({
|
|
218
|
+
label,
|
|
219
|
+
value: formatArgValue(value)
|
|
220
|
+
})),
|
|
221
|
+
actions: settled ? void 0 : actions,
|
|
222
|
+
className: cn("@container/approval max-w-lg", className),
|
|
223
|
+
children: [
|
|
224
|
+
!settled && mode === "deny" ? /* @__PURE__ */ jsxs(Field, {
|
|
225
|
+
"data-part": "deny-form",
|
|
226
|
+
children: [/* @__PURE__ */ jsx(FieldLabel, {
|
|
227
|
+
htmlFor: reasonId,
|
|
228
|
+
children: "Reason (optional)"
|
|
229
|
+
}), /* @__PURE__ */ jsx(Input, {
|
|
230
|
+
ref: reasonInput,
|
|
231
|
+
id: reasonId,
|
|
232
|
+
value: reason,
|
|
233
|
+
disabled: pending,
|
|
234
|
+
placeholder: "Tell the agent why",
|
|
235
|
+
autoComplete: "off",
|
|
236
|
+
onChange: (event) => setReason(event.target.value),
|
|
237
|
+
onKeyDown: (event) => {
|
|
238
|
+
if (event.key === "Enter" && !event.nativeEvent.isComposing) {
|
|
239
|
+
event.preventDefault();
|
|
240
|
+
deny();
|
|
241
|
+
} else if (event.key === "Escape" && !pending) {
|
|
242
|
+
event.preventDefault();
|
|
243
|
+
event.stopPropagation();
|
|
244
|
+
leave(denyButton);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
})]
|
|
248
|
+
}) : null,
|
|
249
|
+
!settled && mode === "edit" ? /* @__PURE__ */ jsxs("div", {
|
|
250
|
+
className: "flex flex-col gap-3",
|
|
251
|
+
"data-part": "editor",
|
|
252
|
+
children: [/* @__PURE__ */ jsxs(Field, {
|
|
253
|
+
"data-invalid": !parsed.ok || void 0,
|
|
254
|
+
children: [
|
|
255
|
+
/* @__PURE__ */ jsx(FieldLabel, {
|
|
256
|
+
htmlFor: editorId,
|
|
257
|
+
children: "Arguments (JSON)"
|
|
258
|
+
}),
|
|
259
|
+
/* @__PURE__ */ jsx(Textarea, {
|
|
260
|
+
ref: argsEditor,
|
|
261
|
+
id: editorId,
|
|
262
|
+
value: draft,
|
|
263
|
+
disabled: pending,
|
|
264
|
+
spellCheck: false,
|
|
265
|
+
autoComplete: "off",
|
|
266
|
+
"aria-invalid": !parsed.ok || void 0,
|
|
267
|
+
"aria-describedby": editorHelpId,
|
|
268
|
+
className: "max-h-72 min-h-24 rounded-xl px-3 py-2.5 font-mono text-xs/relaxed md:text-xs/relaxed",
|
|
269
|
+
onChange: (event) => setDraft(event.target.value)
|
|
270
|
+
}),
|
|
271
|
+
parsed.ok ? /* @__PURE__ */ jsx(FieldDescription, {
|
|
272
|
+
id: editorHelpId,
|
|
273
|
+
children: changed ? "The agent runs the call with these arguments." : "Change a value to approve the call with your edits."
|
|
274
|
+
}) : /* @__PURE__ */ jsx(FieldError, {
|
|
275
|
+
id: editorHelpId,
|
|
276
|
+
children: parsed.error
|
|
277
|
+
})
|
|
278
|
+
]
|
|
279
|
+
}), parsed.ok && changed ? /* @__PURE__ */ jsx(DiffViewer, {
|
|
280
|
+
oldFile: {
|
|
281
|
+
content: original,
|
|
282
|
+
name: `${toolCall.name} arguments`
|
|
283
|
+
},
|
|
284
|
+
newFile: {
|
|
285
|
+
content: parsed.text,
|
|
286
|
+
name: `${toolCall.name} arguments`
|
|
287
|
+
},
|
|
288
|
+
viewMode: "unified",
|
|
289
|
+
copyable: false,
|
|
290
|
+
className: "max-h-64 overflow-auto rounded-xl"
|
|
291
|
+
}) : null]
|
|
292
|
+
}) : null,
|
|
293
|
+
!settled && error ? /* @__PURE__ */ jsxs(Alert, {
|
|
294
|
+
variant: "destructive",
|
|
295
|
+
"data-slot": "tool-approval-error",
|
|
296
|
+
className: "rounded-xl has-data-[slot=alert-action]:pr-8",
|
|
297
|
+
children: [
|
|
298
|
+
/* @__PURE__ */ jsx(AlertCircleIcon, { "aria-hidden": "true" }),
|
|
299
|
+
/* @__PURE__ */ jsx(AlertTitle, { children: "Decision not recorded" }),
|
|
300
|
+
/* @__PURE__ */ jsx(AlertDescription, {
|
|
301
|
+
id: errorId,
|
|
302
|
+
className: "text-pretty",
|
|
303
|
+
children: error
|
|
304
|
+
}),
|
|
305
|
+
onDismissError ? /* @__PURE__ */ jsx(AlertAction, {
|
|
306
|
+
className: "top-1 right-1",
|
|
307
|
+
children: /* @__PURE__ */ jsx(Button, {
|
|
308
|
+
type: "button",
|
|
309
|
+
size: "icon-xs",
|
|
310
|
+
variant: "ghost",
|
|
311
|
+
"aria-label": "Dismiss error",
|
|
312
|
+
onClick: onDismissError,
|
|
313
|
+
children: /* @__PURE__ */ jsx(XIcon, {
|
|
314
|
+
"aria-hidden": "true",
|
|
315
|
+
className: "size-3"
|
|
316
|
+
})
|
|
317
|
+
})
|
|
318
|
+
}) : null
|
|
319
|
+
]
|
|
320
|
+
}) : null,
|
|
321
|
+
!settled && dangerous && holdHint ? /* @__PURE__ */ jsx("p", {
|
|
322
|
+
id: holdHintId,
|
|
323
|
+
role: "status",
|
|
324
|
+
className: "text-muted-foreground text-xs",
|
|
325
|
+
children: "Press and hold to approve: this tool is marked dangerous."
|
|
326
|
+
}) : null
|
|
327
|
+
]
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
//#endregion
|
|
331
|
+
export { ToolApproval };
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { cn } from "cn";
|
|
4
|
+
import { useUpdateEffect } from "ahooks";
|
|
5
|
+
import { useReducedMotionConfig } from "motion/react";
|
|
6
|
+
//#region src/ai/compositions/tool-call-row/tool-call-row.tsx
|
|
7
|
+
/**
|
|
8
|
+
* Classes for the CollapsibleTrigger around a ToolCallChip and its chevron,
|
|
9
|
+
* without a focus mark: for a row that marks keyboard focus itself.
|
|
10
|
+
*/
|
|
11
|
+
const toolCallTriggerBaseClassName = "group/trigger flex max-w-full min-w-0 items-center gap-1 rounded-md text-muted-foreground outline-none transition-colors hover:text-foreground";
|
|
12
|
+
/**
|
|
13
|
+
* Classes for the CollapsibleTrigger around a ToolCallChip and its chevron.
|
|
14
|
+
* Keyboard focus marks the chip itself, with the Button focus family (ring
|
|
15
|
+
* border plus a soft 2px ring), so no second outline wraps chip and chevron.
|
|
16
|
+
* A failed or denied chip keeps its destructive tone, as the destructive
|
|
17
|
+
* Button does, so focus never draws a grey ring around its red border.
|
|
18
|
+
*/
|
|
19
|
+
const toolCallTriggerClassName = cn(toolCallTriggerBaseClassName, "focus-visible:[&>[data-slot=tool-call-chip]]:border-ring focus-visible:[&>[data-slot=tool-call-chip]]:ring-2 focus-visible:[&>[data-slot=tool-call-chip]]:ring-ring/30", "focus-visible:[&>[data-slot=tool-call-chip][data-status=error]]:border-destructive/60 focus-visible:[&>[data-slot=tool-call-chip][data-status=error]]:ring-destructive/20 dark:focus-visible:[&>[data-slot=tool-call-chip][data-status=error]]:ring-destructive/40");
|
|
20
|
+
/**
|
|
21
|
+
* How long after a tool call opens to scroll it into view: past
|
|
22
|
+
* ToolFallback's 200ms expand animation, whose scroll lock would undo an
|
|
23
|
+
* earlier scroll.
|
|
24
|
+
*/
|
|
25
|
+
const REVEAL_DELAY_MS = 250;
|
|
26
|
+
/**
|
|
27
|
+
* Scrolls the returned ref's element into view (nearest edge) after `open`
|
|
28
|
+
* turns true, so an expanded call near the bottom of a scroller is not left
|
|
29
|
+
* cut off by its edge. Opening on mount (a deep link) scrolls nothing here.
|
|
30
|
+
*/
|
|
31
|
+
function useRevealOnOpen(open) {
|
|
32
|
+
const ref = React.useRef(null);
|
|
33
|
+
const reduced = useReducedMotionConfig() ?? false;
|
|
34
|
+
useUpdateEffect(() => {
|
|
35
|
+
if (!open) return;
|
|
36
|
+
const timer = window.setTimeout(() => {
|
|
37
|
+
ref.current?.scrollIntoView({
|
|
38
|
+
block: "nearest",
|
|
39
|
+
behavior: reduced ? "auto" : "smooth"
|
|
40
|
+
});
|
|
41
|
+
}, REVEAL_DELAY_MS);
|
|
42
|
+
return () => window.clearTimeout(timer);
|
|
43
|
+
}, [open]);
|
|
44
|
+
return ref;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* A tool call's arguments or result as indented JSON. Long lines scroll
|
|
48
|
+
* sideways inside the block instead of wrapping to column 0, and the block is
|
|
49
|
+
* focusable so a keyboard can scroll it.
|
|
50
|
+
*/
|
|
51
|
+
function ToolCallJson({ heading, text }) {
|
|
52
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
53
|
+
"data-slot": "tool-call-json",
|
|
54
|
+
children: [heading ? /* @__PURE__ */ jsx("p", {
|
|
55
|
+
className: "text-muted-foreground text-xs font-medium",
|
|
56
|
+
children: heading
|
|
57
|
+
}) : null, /* @__PURE__ */ jsx("pre", {
|
|
58
|
+
tabIndex: 0,
|
|
59
|
+
className: cn("overflow-x-auto rounded-md border border-border/60 bg-muted/50 p-2.5 text-xs whitespace-pre text-foreground/90 outline-none focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/30", heading && "mt-1"),
|
|
60
|
+
children: text
|
|
61
|
+
})]
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
/** A tool result as display text: strings as they are, anything else as JSON. */
|
|
65
|
+
function formatToolValue(value) {
|
|
66
|
+
if (typeof value === "string") return value;
|
|
67
|
+
try {
|
|
68
|
+
return JSON.stringify(value, null, 2) ?? String(value);
|
|
69
|
+
} catch {
|
|
70
|
+
return String(value);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
//#endregion
|
|
74
|
+
export { ToolCallJson, formatToolValue, toolCallTriggerBaseClassName, toolCallTriggerClassName, useRevealOnOpen };
|