@kitn.ai/ui 0.25.2 → 0.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -6
- package/bin/mcp.js +16 -3
- package/bin/route.js +23 -0
- package/bin/route.test.js +58 -0
- package/dist/{elements/chunks/Icon-b5A8hlHs.js → Icon-BnFKqqtY.js} +1 -1
- package/dist/action-icons-CBskfBMz.js +1 -0
- package/dist/arrow-down-Br0qtpsz.js +1 -0
- package/dist/arrow-left-Dj7xgE12.js +1 -0
- package/dist/artifact-CvXEm1lS.js +1 -0
- package/dist/assets/dev-5XzXYR21.js +91 -0
- package/dist/attachments-C43ZegEq.js +1 -0
- package/dist/audio-visualizer-B-79y1Tj.js +1 -0
- package/dist/badge-BpUbq8c0.js +1 -0
- package/dist/bash-InADTalH.js +1 -6
- package/dist/bell-sn17Ip9v.js +1 -0
- package/dist/{elements/chunks/button-B9okqG73.js → button-BH6rN0U-.js} +1 -1
- package/dist/card-renderer-Cb1gQmth.js +1 -0
- package/dist/card-routing-DifQgS7n.js +1 -0
- package/dist/check-DPeeMUYx.js +1 -0
- package/dist/checkbox-Dc9Yov_B.js +1 -0
- package/dist/checkbox-group-B1kDLLYk.js +1 -0
- package/dist/chevron-down-CHSWk7ZT.js +1 -0
- package/dist/chevron-right-B7l_fMgx.js +1 -0
- package/dist/choice-card-BT3c1S8g.js +1 -0
- package/dist/circle-Bb0yOpqM.js +1 -0
- package/dist/circle-check-BGZpCiz7.js +1 -0
- package/dist/circle-x-wobWkoSx.js +1 -0
- package/dist/{elements/chunks/cn-CU7UAWzk.js → cn-DN5AWfiS.js} +1 -1
- package/dist/code-block-CUQ5mtv0.js +1 -0
- package/dist/collapsible-CPJbf6FM.js +1 -0
- package/dist/components/attachment-types.d.ts +53 -1
- package/dist/components/attachments.d.ts +31 -0
- package/dist/components/audio-visualizer/fit-scale.d.ts +50 -0
- package/dist/components/audio-visualizer/index.d.ts +15 -1
- package/dist/components/audio-visualizer/variant-bar.d.ts +24 -1
- package/dist/components/card-renderer.d.ts +13 -0
- package/dist/components/card.d.ts +4 -0
- package/dist/components/chat-thread.d.ts +49 -42
- package/dist/components/code-block.d.ts +22 -0
- package/dist/components/conversation-item.d.ts +66 -1
- package/dist/components/conversation-list.d.ts +77 -0
- package/dist/components/form-widgets.d.ts +67 -2
- package/dist/components/form.d.ts +89 -0
- package/dist/components/message.d.ts +29 -0
- package/dist/components/reasoning.d.ts +6 -0
- package/dist/components/scroll-button.d.ts +11 -0
- package/dist/components/thread.d.ts +5 -0
- package/dist/components/toast.d.ts +2 -1
- package/dist/components/tool-types.d.ts +9 -0
- package/dist/components/voice-input.d.ts +8 -0
- package/dist/components/voice-output.d.ts +12 -1
- package/dist/components/workspace-shell.d.ts +87 -0
- package/dist/composer-CjngLzal.js +106 -0
- package/dist/confirm-card-DCx_A4bU.js +1 -0
- package/dist/construct-cli.es.js +1169 -0
- package/dist/context-BY8V-Nlp.js +1 -0
- package/dist/controllable-D43BKmtX.js +1 -0
- package/dist/conversation-list-D4lLU_yS.js +1 -0
- package/dist/copy-B6DO4PqB.js +1 -0
- package/dist/core-AYMC6_lb.js +12 -5874
- package/dist/{create-tween-CUzOlaMS.js → create-tween-BPzaefTp.js} +1 -1
- package/dist/{create-tween-B5Y4Im8G.js → create-tween-CnMHviKB.js} +1 -1
- package/dist/{create-tween-4z1XYLkR.js → create-tween-D1aiGZZh.js} +1 -1
- package/dist/{elements/chunks/create-tween-CUrM6D_o.js → create-tween-DUSQUKpr.js} +2 -2
- package/dist/css-M7EaDHN_.js +1 -6
- package/dist/custom-elements.json +3468 -1927
- package/dist/default-input-CucQEOqH.js +1 -0
- package/dist/define-CGGX-7Vg.js +1 -0
- package/dist/define.d.ts +4 -0
- package/dist/define.js +510 -0
- package/dist/define.server.d.ts +5 -0
- package/dist/define.server.js +506 -0
- package/dist/diagnostics/hook.d.ts +81 -0
- package/dist/diagnostics/index.d.ts +7 -0
- package/dist/diagnostics/report-request.d.ts +61 -0
- package/dist/diagnostics.d.ts +5 -0
- package/dist/diagnostics.js +209 -0
- package/dist/disclosure-CbLtajUQ.js +1 -0
- package/dist/dropdown-BwhViJFd.js +1 -0
- package/dist/elements/agent-card.js +1 -1
- package/dist/elements/artifact.js +1 -1
- package/dist/elements/attachments.js +1 -1
- package/dist/elements/audio-visualizer.js +1 -1
- package/dist/elements/autoloader.js +1 -1
- package/dist/elements/avatar.js +1 -1
- package/dist/elements/badge.js +1 -1
- package/dist/elements/button.js +1 -1
- package/dist/elements/card.js +1 -1
- package/dist/elements/cards.js +1 -1
- package/dist/elements/chain-of-thought.js +1 -1
- package/dist/elements/chat-scope-picker.js +1 -1
- package/dist/elements/chat-workspace.js +1 -1
- package/dist/elements/chat.js +1 -1
- package/dist/elements/checkbox-group.d.ts +1 -0
- package/dist/elements/checkbox-group.js +1 -0
- package/dist/elements/checkbox.d.ts +1 -0
- package/dist/elements/checkbox.js +1 -0
- package/dist/elements/checkpoint.js +1 -1
- package/dist/elements/choice.js +1 -1
- package/dist/elements/coachmark.js +1 -1
- package/dist/elements/code-block.js +1 -1
- package/dist/elements/command.js +1 -1
- package/dist/elements/compare.js +1 -1
- package/dist/elements/composer.js +1 -1
- package/dist/elements/confirm-card.js +1 -1
- package/dist/elements/context-meter.js +1 -1
- package/dist/elements/conversation-item.d.ts +1 -0
- package/dist/elements/conversation-item.js +1 -0
- package/dist/elements/conversation-list.js +1 -1
- package/dist/elements/default-input.d.ts +3 -3
- package/dist/elements/define-entry.d.ts +12 -0
- package/dist/elements/define.d.ts +27 -0
- package/dist/elements/diagnostic-events.d.ts +74 -0
- package/dist/elements/dialog.js +1 -1
- package/dist/elements/dock.d.ts +1 -0
- package/dist/elements/dock.js +243 -0
- package/dist/elements/dropdown.d.ts +1 -0
- package/dist/elements/dropdown.js +1 -0
- package/dist/elements/editable-label.js +1 -1
- package/dist/elements/element-data-types.d.ts +37 -0
- package/dist/elements/element-diagnostics.d.ts +81 -0
- package/dist/elements/embed.js +1 -1
- package/dist/elements/empty.js +1 -1
- package/dist/elements/feedback-bar.js +1 -1
- package/dist/elements/file-tree.js +1 -1
- package/dist/elements/file-upload.js +1 -1
- package/dist/elements/form.js +1 -1
- package/dist/elements/hover-card.js +1 -1
- package/dist/elements/icon.js +1 -1
- package/dist/elements/image.js +1 -1
- package/dist/elements/input.js +1 -1
- package/dist/elements/kbd.js +1 -1
- package/dist/elements/link-preview.js +1 -1
- package/dist/elements/loader.js +1 -1
- package/dist/elements/markdown.js +1 -1
- package/dist/elements/menu.js +1 -1
- package/dist/elements/message-skills.js +1 -1
- package/dist/elements/message.js +1 -1
- package/dist/elements/model-switcher.js +1 -1
- package/dist/elements/nav.js +1 -1
- package/dist/elements/notice.js +1 -1
- package/dist/elements/pane-grid.d.ts +1 -0
- package/dist/elements/pane-grid.js +1 -0
- package/dist/elements/pane-group.js +1 -1
- package/dist/elements/pane.js +1 -1
- package/dist/elements/popover.js +1 -1
- package/dist/elements/progress-bar.js +1 -1
- package/dist/elements/prompt-dock.js +1 -1
- package/dist/elements/prompt-input.js +1 -1
- package/dist/elements/prompt-suggestions.js +1 -1
- package/dist/elements/radio-group.d.ts +1 -0
- package/dist/elements/radio-group.js +1 -0
- package/dist/elements/reasoning.js +1 -1
- package/dist/elements/register.d.ts +2 -0
- package/dist/elements/remote.js +1 -1
- package/dist/elements/resizable.js +1 -1
- package/dist/elements/response-stream.js +3 -3
- package/dist/elements/screen.js +1 -1
- package/dist/elements/scroll-area.js +1 -1
- package/dist/elements/scroll-button.js +1 -1
- package/dist/elements/search.js +1 -1
- package/dist/elements/segmented.js +1 -1
- package/dist/elements/select.d.ts +1 -0
- package/dist/elements/select.js +1 -0
- package/dist/elements/separator.js +1 -1
- package/dist/elements/setting-item.js +1 -1
- package/dist/elements/settings-group.js +1 -1
- package/dist/elements/skeleton.js +1 -1
- package/dist/elements/slider.d.ts +1 -0
- package/dist/elements/slider.js +1 -0
- package/dist/elements/slots.d.ts +36 -4
- package/dist/elements/source.js +1 -1
- package/dist/elements/status.js +1 -1
- package/dist/elements/switch.js +1 -1
- package/dist/elements/tabs.js +1 -1
- package/dist/elements/tasks.js +1 -1
- package/dist/elements/text-shimmer.js +1 -1
- package/dist/elements/thinking-bar.js +1 -1
- package/dist/elements/thread.js +1 -1
- package/dist/elements/toast.js +1 -1
- package/dist/elements/tool.js +1 -1
- package/dist/elements/tooltip.js +1 -1
- package/dist/elements/voice-input.js +1 -1
- package/dist/elements/voice-output.js +1 -1
- package/dist/elements.d.ts +589 -167
- package/dist/{elements/chunks/ellipsis-CVxqfsDZ.js → ellipsis-DFr4Vqr3.js} +1 -1
- package/dist/embed-5s_vU4J0.js +1 -0
- package/dist/engine-javascript-vq0WuIJl.js +14 -2516
- package/dist/{elements/chunks/external-link-DG2sRdQL.js → external-link-u9d85ORQ.js} +1 -1
- package/dist/file-text-CX7_x42o.js +1 -0
- package/dist/{elements/chunks/file-tree-yGWNK0Js.js → file-tree-D3kBjXI5.js} +1 -1
- package/dist/folder-V-YdIL8f.js +1 -0
- package/dist/form-BRNUMCN2.js +1 -0
- package/dist/github-dark-dimmed-DUshB20C.js +1 -4
- package/dist/github-light-JYsPkUQd.js +1 -4
- package/dist/hover-card-DaeiYrTA.js +1 -0
- package/dist/html-CPZ3oZQ7.js +1 -10
- package/dist/icon-BpixdZNq.js +1 -0
- package/dist/{elements/chunks/index-BCRhi84a.js → index-xu_pdcPi.js} +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +8473 -6470
- package/dist/index.server.js +6495 -4958
- package/dist/info-8mFsIjS3.js +1 -0
- package/dist/input-d1Yuu-hz.js +1 -0
- package/dist/javascript-C25yR2R2.js +1 -6
- package/dist/json-DxJze_jm.js +1 -6
- package/dist/kai-provider.es.js +40 -40
- package/dist/kai.es.js +1 -1
- package/dist/kbd-961zMPFB.js +1 -0
- package/dist/link-DlZZBGaR.js +1 -0
- package/dist/{elements/chunks/link-preview-Cf5KOP-i.js → link-preview-DIIbV2Sd.js} +1 -1
- package/dist/loader-YQszHFaW.js +1 -0
- package/dist/{elements/chunks/markdown-DbozyYqa.js → markdown-CVk1MPsj.js} +1 -1
- package/dist/mcp.es.js +3873 -544
- package/dist/message-CwKVEdZg.js +1 -0
- package/dist/message-DS8lzHc1.js +1 -0
- package/dist/message-circle-Xf8Q-vZp.js +1 -0
- package/dist/message-square-Cxnwgkns.js +1 -0
- package/dist/{elements/chunks/minimize-2-SegJ_oku.js → minimize-2-UEZmP2QT.js} +1 -1
- package/dist/{elements/chunks/model-switcher-D7JrFFHp.js → model-switcher-Kk1jEQ5t.js} +1 -1
- package/dist/{elements/chunks/overlay-CV7z2YuX.js → overlay-C1od6LOz.js} +1 -1
- package/dist/panel-right-ryET0yyn.js +1 -0
- package/dist/paperclip-BDNoZFJP.js +1 -0
- package/dist/play-OFIvYXUQ.js +1 -0
- package/dist/primitives/card-data-types.d.ts +49 -0
- package/dist/primitives/card-routing.d.ts +1 -33
- package/dist/primitives/card-validate.d.ts +2 -2
- package/dist/primitives/chat-config.d.ts +29 -2
- package/dist/primitives/field-mask.d.ts +96 -0
- package/dist/primitives/field-semantics.d.ts +36 -0
- package/dist/primitives/input-mask.d.ts +46 -0
- package/dist/primitives/url-scheme-policy.d.ts +34 -0
- package/dist/primitives/use-resize-observer.d.ts +23 -0
- package/dist/primitives/use-speech-recognition.d.ts +8 -0
- package/dist/primitives/use-text-stream.d.ts +5 -0
- package/dist/progress-bar-BvYX0aoy.js +1 -0
- package/dist/prompt-suggestion-BRFu2lcu.js +1 -0
- package/dist/radio-DcL23cNJ.js +1 -0
- package/dist/react/index.d.ts +306 -283
- package/dist/react.js +309 -247
- package/dist/reasoning-Cackq4Rh.js +1 -0
- package/dist/register-impl-C7rENvPK.js +424 -0
- package/dist/{elements/chunks/resizable-Dpzjlvp4.js → resizable-Cp9HUYih.js} +1 -1
- package/dist/rotate-ccw-0DLRDHH5.js +1 -0
- package/dist/rotate-cw-DOB9IGcU.js +1 -0
- package/dist/schemas/form.schema.json +21 -1
- package/dist/schemas/index.d.ts +1 -1
- package/dist/schemas/tool-defs.d.ts +45 -0
- package/dist/schemas.js +398 -305
- package/dist/scroll-area-emVmWP4K.js +1 -0
- package/dist/scroll-button-CeP_gv1x.js +1 -0
- package/dist/select-CWmu00tS.js +1 -0
- package/dist/{elements/chunks/separator-DH2r_ZSZ.js → separator-CE6vly6z.js} +1 -1
- package/dist/{elements/chunks/settings-BFMOd6yB.js → settings-CE-78SvZ.js} +1 -1
- package/dist/{elements/chunks/settings-group-B3VZKIcz.js → settings-group-ZFWNxFQR.js} +1 -1
- package/dist/{elements/chunks/skeleton-N8BuWYmf.js → skeleton-BebdP4mf.js} +1 -1
- package/dist/slider-BAKRYUlz.js +1 -0
- package/dist/slots-DaNjX0rc.js +1 -0
- package/dist/{solid-BMuDmFo_.js → solid-BE5ui6sy.js} +10672 -8116
- package/dist/{solid-CGYNdLRR.js → solid-DFhsce3O.js} +8137 -6056
- package/dist/solid.d.ts +15 -0
- package/dist/solid.js +248 -235
- package/dist/solid.server.js +248 -235
- package/dist/source-B0FlguSx.js +1 -0
- package/dist/star-CBMZvLuN.js +1 -0
- package/dist/state/index.d.ts +5 -1
- package/dist/state/mock.d.ts +32 -2
- package/dist/state/persistence.d.ts +51 -0
- package/dist/state/stream.d.ts +50 -0
- package/dist/state/threads.d.ts +71 -0
- package/dist/state.js +297 -172
- package/dist/store-7eoadydQ.js +1 -0
- package/dist/svelte--5p79yCD.js +1 -15
- package/dist/switch-CViARZCy.js +1 -0
- package/dist/tasks-card-MjCcOhR_.js +1 -0
- package/dist/text-shimmer-DKlwRF2G.js +1 -0
- package/dist/textarea-3ay2Me2-.js +1 -0
- package/dist/theme.tokens.css +82 -13
- package/dist/{elements/chunks/thumbs-up-DQe0hvkZ.js → thumbs-up-DQcu2HMO.js} +1 -1
- package/dist/toast-store-C6yKOhbk.js +1 -0
- package/dist/{elements/chunks/tool-C1YtxwPu.js → tool-BCYNlfKy.js} +1 -1
- package/dist/{elements/chunks/tooltip-BqwnFWhn.js → tooltip-05zI4hjs.js} +1 -1
- package/dist/trash-2-BR1RxGky.js +1 -0
- package/dist/{elements/chunks/triangle-alert-B6or7F5u.js → triangle-alert-DHohDOCy.js} +1 -1
- package/dist/tsx-B8rCNbgL.js +1 -6
- package/dist/types.d.ts +4 -2
- package/dist/typescript-RycA9KXf.js +1 -6
- package/dist/ui/checkbox-group.d.ts +83 -0
- package/dist/ui/checkbox.d.ts +40 -0
- package/dist/ui/dock.d.ts +131 -0
- package/dist/ui/hover-card.d.ts +44 -0
- package/dist/ui/icon.d.ts +3 -0
- package/dist/ui/input.d.ts +48 -2
- package/dist/ui/radio.d.ts +85 -0
- package/dist/ui/select.d.ts +71 -0
- package/dist/ui/slider.d.ts +65 -0
- package/dist/ui/switch.d.ts +9 -2
- package/dist/upload-BbGW6A_u.js +1 -0
- package/dist/url-scheme-policy-DHpoTJwB.js +1 -0
- package/dist/use-card-resolution-CJW4grFa.js +1 -0
- package/dist/{variant-aurora-DwSOfraQ.js → variant-aurora-BUOVgPOB.js} +27 -27
- package/dist/{variant-aurora-wKvAQ5wp.js → variant-aurora-CUsUJvFI.js} +28 -28
- package/dist/{variant-aurora-XEkPT0_z.js → variant-aurora-CW2i4bfr.js} +2 -2
- package/dist/{elements/chunks/variant-aurora-QXTZPyST.js → variant-aurora-xiMPty8f.js} +2 -2
- package/dist/variant-custom-BQtOnmeO.js +1 -0
- package/dist/{variant-custom-BhS9wIpU.js → variant-custom-CAm9L-E5.js} +65 -65
- package/dist/{variant-custom-eFIg2XWQ.js → variant-custom-CAnzzppW.js} +40 -40
- package/dist/variant-custom-D91HjAKz.js +1 -0
- package/dist/{variant-wave-CUWGx9Bn.js → variant-wave-Ca1Ls4_y.js} +21 -21
- package/dist/{variant-wave-CbVsmgwT.js → variant-wave-CxX39DKd.js} +25 -25
- package/dist/{variant-wave-BwzrHD1s.js → variant-wave-DYyzIIZv.js} +2 -2
- package/dist/{elements/chunks/variant-wave-DDCwhLas.js → variant-wave-uY5crU_K.js} +2 -2
- package/dist/vue-BmIZj4XD.js +1 -33
- package/dist/wire/chunk.d.ts +47 -0
- package/dist/wire/diagnostics.d.ts +575 -0
- package/dist/wire/encode-probe.d.ts +70 -0
- package/dist/wire/encode.d.ts +24 -0
- package/dist/wire/index.d.ts +2 -0
- package/dist/wire/sse.d.ts +10 -2
- package/dist/wire.js +917 -480
- package/dist/x-C5m1JFgi.js +1 -0
- package/frameworks/react/index.tsx +325 -108
- package/llms-full.txt +1354 -82
- package/llms.txt +6 -3
- package/package.json +39 -6
- package/src/agent-tooling/archetypes.ts +41 -9
- package/src/agent-tooling/catalog/README.md +676 -0
- package/src/agent-tooling/catalog/catalog-types.ts +231 -0
- package/src/agent-tooling/catalog/fabrications.ts +96 -0
- package/src/agent-tooling/catalog/invariants.ts +284 -0
- package/src/agent-tooling/catalog/labs-titles.ts +114 -0
- package/src/agent-tooling/catalog/scenarios.ts +87 -0
- package/src/agent-tooling/catalog/surfaces.ts +347 -0
- package/src/agent-tooling/construct/cli-entry.ts +8 -0
- package/src/agent-tooling/construct/cli.ts +131 -0
- package/src/agent-tooling/construct/codegen.ts +1353 -0
- package/src/agent-tooling/construct/construct.v1.schema.json +250 -0
- package/src/agent-tooling/construct/dev.ts +148 -0
- package/src/agent-tooling/construct/fixtures/demo-widget.construct.json +7 -0
- package/src/agent-tooling/construct/fixtures/ops-console.construct.json +44 -0
- package/src/agent-tooling/construct/fixtures/owner-widget.construct.json +23 -0
- package/src/agent-tooling/construct/schema.ts +371 -0
- package/src/agent-tooling/integrations/anthropic.ts +7 -1
- package/src/agent-tooling/integrations/cloudflare.ts +43 -2
- package/src/agent-tooling/integrations/langgraph.ts +7 -1
- package/src/agent-tooling/integrations/mastra.ts +7 -1
- package/src/agent-tooling/integrations/mock.ts +92 -17
- package/src/agent-tooling/integrations/ollama.ts +7 -1
- package/src/agent-tooling/integrations/openai.ts +7 -1
- package/src/agent-tooling/integrations/openrouter.ts +7 -1
- package/src/agent-tooling/integrations/pi.ts +56 -1
- package/src/agent-tooling/integrations/vercel-ai-sdk.ts +7 -1
- package/src/agent-tooling/mcp/css-raw.d.ts +12 -0
- package/src/agent-tooling/mcp/manifest.ts +100 -1
- package/src/agent-tooling/mcp/server.ts +63 -6
- package/src/agent-tooling/mcp/tools/construct.ts +130 -0
- package/src/agent-tooling/mcp/tools/debug.ts +126 -4
- package/src/agent-tooling/mcp/tools/reference.ts +542 -5
- package/src/agent-tooling/mcp/tools/scaffold.ts +1834 -307
- package/src/agent-tooling/mcp/tools/theme.ts +146 -30
- package/src/agent-tooling/mcp/validate-args.ts +141 -0
- package/src/agent-tooling/recipes/composed-thread.ts +714 -0
- package/src/agent-tooling/recipes/index.ts +22 -0
- package/src/agent-tooling/recipes/types.ts +32 -0
- package/src/agent-tooling/registry.ts +24 -7
- package/src/agent-tooling/route-emit.ts +26 -2
- package/src/components/attachment-types.ts +54 -1
- package/src/components/attachments.tsx +169 -22
- package/src/components/audio-visualizer/fit-scale.ts +112 -0
- package/src/components/audio-visualizer/index.tsx +80 -3
- package/src/components/audio-visualizer/variant-aurora.tsx +10 -4
- package/src/components/audio-visualizer/variant-bar.tsx +38 -6
- package/src/components/audio-visualizer/variant-custom.tsx +8 -2
- package/src/components/audio-visualizer/variant-grid.tsx +16 -11
- package/src/components/audio-visualizer/variant-radial.tsx +15 -10
- package/src/components/audio-visualizer/variant-wave.tsx +7 -2
- package/src/components/card-renderer.tsx +39 -8
- package/src/components/card.tsx +10 -2
- package/src/components/chat-container.tsx +4 -1
- package/src/components/chat-scope-picker.tsx +2 -2
- package/src/components/chat-thread.tsx +105 -13
- package/src/components/choice-card.tsx +102 -37
- package/src/components/coachmark.tsx +1 -1
- package/src/components/code-block.tsx +81 -5
- package/src/components/composer.tsx +89 -8
- package/src/components/confirm-card.tsx +20 -4
- package/src/components/conversation-item.tsx +138 -4
- package/src/components/conversation-list.tsx +230 -15
- package/src/components/embed.tsx +4 -0
- package/src/components/empty.tsx +14 -3
- package/src/components/file-tree.tsx +5 -1
- package/src/components/form-widgets.tsx +257 -195
- package/src/components/form.tsx +336 -21
- package/src/components/loader.tsx +12 -5
- package/src/components/message-skills.tsx +1 -1
- package/src/components/message.tsx +142 -12
- package/src/components/prompt-input.tsx +7 -1
- package/src/components/prompt-suggestion.tsx +4 -1
- package/src/components/reasoning.tsx +30 -3
- package/src/components/response-compare.tsx +2 -2
- package/src/components/response-stream.tsx +13 -7
- package/src/components/screen.tsx +5 -0
- package/src/components/scroll-button.tsx +63 -4
- package/src/components/source.tsx +6 -1
- package/src/components/tasks-card.tsx +58 -16
- package/src/components/thread.tsx +10 -1
- package/src/components/toast.tsx +11 -5
- package/src/components/tool-types.ts +9 -0
- package/src/components/voice-input.tsx +35 -3
- package/src/components/voice-output.tsx +46 -6
- package/src/components/workspace-shell.tsx +285 -0
- package/src/diagnostics/hook.ts +352 -0
- package/src/diagnostics/index.ts +82 -0
- package/src/diagnostics/report-request.ts +296 -0
- package/src/elements/attachments.tsx +9 -8
- package/src/elements/audio-visualizer.tsx +48 -4
- package/src/elements/chat-workspace.tsx +159 -287
- package/src/elements/chat.tsx +31 -10
- package/src/elements/checkbox-group.tsx +164 -0
- package/src/elements/checkbox.tsx +134 -0
- package/src/elements/code-block.tsx +19 -1
- package/src/elements/command.tsx +4 -1
- package/src/elements/compiled.css +1 -1
- package/src/elements/composer.tsx +12 -1
- package/src/elements/conversation-item.tsx +120 -0
- package/src/elements/conversation-list.tsx +60 -11
- package/src/elements/default-input.tsx +5 -5
- package/src/elements/define-entry.ts +12 -0
- package/src/elements/define.tsx +168 -8
- package/src/elements/diagnostic-events.ts +114 -0
- package/src/elements/dialog.tsx +47 -0
- package/src/elements/disclosure.ts +34 -12
- package/src/elements/dock.tsx +215 -0
- package/src/elements/dropdown.tsx +123 -0
- package/src/elements/element-data-types.ts +40 -0
- package/src/elements/element-diagnostics.ts +392 -0
- package/src/elements/element-manifest.json +36 -0
- package/src/elements/element-meta.json +1483 -560
- package/src/elements/element-nonscalar.json +185 -0
- package/src/elements/element-types.d.ts +589 -167
- package/src/elements/feedback-bar.tsx +5 -0
- package/src/elements/icon-names.json +29 -0
- package/src/elements/input.tsx +312 -23
- package/src/elements/menu.tsx +13 -0
- package/src/elements/message.tsx +2 -0
- package/src/elements/pane-grid.tsx +111 -0
- package/src/elements/prompt-dock.tsx +2 -1
- package/src/elements/prompt-input.tsx +16 -10
- package/src/elements/radio-group.tsx +129 -0
- package/src/elements/register-impl.ts +52 -0
- package/src/elements/register.ts +28 -0
- package/src/elements/resizable.tsx +52 -25
- package/src/elements/scroll-button.tsx +59 -6
- package/src/elements/select.tsx +165 -0
- package/src/elements/slider.tsx +171 -0
- package/src/elements/slots.ts +108 -13
- package/src/elements/styles.css +119 -9
- package/src/elements/thinking-bar.tsx +16 -7
- package/src/elements/thread.tsx +2 -0
- package/src/elements/toast.tsx +17 -1
- package/src/elements/tool.tsx +26 -5
- package/src/elements/voice-input.tsx +11 -2
- package/src/elements/voice-output.tsx +16 -3
- package/src/index.ts +4 -1
- package/src/primitives/card-data-types.ts +49 -0
- package/src/primitives/card-host.tsx +4 -2
- package/src/primitives/card-routing.ts +7 -56
- package/src/primitives/card-schemas/form.schema.json +21 -1
- package/src/primitives/card-validate.ts +10 -2
- package/src/primitives/chat-config.tsx +33 -6
- package/src/primitives/field-mask.ts +256 -0
- package/src/primitives/field-semantics.ts +115 -0
- package/src/primitives/input-mask.ts +853 -0
- package/src/primitives/toast-store.ts +66 -4
- package/src/primitives/url-scheme-policy.ts +70 -0
- package/src/primitives/use-resize-observer.ts +33 -0
- package/src/primitives/use-speech-recognition.ts +12 -1
- package/src/primitives/use-stick-to-bottom.ts +34 -2
- package/src/primitives/use-text-stream.ts +33 -2
- package/src/remote/provider-runtime.ts +6 -3
- package/src/schemas/index.ts +1 -0
- package/src/schemas/tool-defs.ts +307 -6
- package/src/solid.ts +15 -0
- package/src/state/index.ts +13 -1
- package/src/state/mock.ts +92 -6
- package/src/state/persistence.ts +180 -0
- package/src/state/stream.ts +71 -4
- package/src/state/threads.ts +142 -0
- package/src/types.ts +4 -2
- package/src/ui/agent-card.tsx +2 -2
- package/src/ui/avatar.tsx +1 -1
- package/src/ui/checkbox-group.tsx +153 -0
- package/src/ui/checkbox.tsx +63 -0
- package/src/ui/dialog.tsx +6 -0
- package/src/ui/dock.tsx +584 -0
- package/src/ui/dropdown.tsx +67 -23
- package/src/ui/hover-card.tsx +156 -6
- package/src/ui/icon.tsx +53 -0
- package/src/ui/input.tsx +275 -16
- package/src/ui/kbd.tsx +1 -1
- package/src/ui/nav.tsx +1 -1
- package/src/ui/pane-group.tsx +2 -2
- package/src/ui/radio.tsx +150 -0
- package/src/ui/resizable.tsx +11 -0
- package/src/ui/select.tsx +168 -0
- package/src/ui/slider.tsx +178 -0
- package/src/ui/switch.tsx +49 -18
- package/src/utils/cn.ts +11 -5
- package/src/wire/chunk.ts +47 -0
- package/src/wire/consume.ts +185 -26
- package/src/wire/diagnostics.ts +727 -0
- package/src/wire/encode-probe.ts +214 -0
- package/src/wire/encode.ts +267 -14
- package/src/wire/formats/anthropic.ts +8 -1
- package/src/wire/formats/openai.ts +5 -0
- package/src/wire/index.ts +22 -0
- package/src/wire/read.ts +250 -6
- package/src/wire/sse.ts +16 -3
- package/theme.css +84 -13
- package/dist/elements/chunks/action-icons-DW9muWrY.js +0 -1
- package/dist/elements/chunks/arrow-left-iJVnQmxA.js +0 -1
- package/dist/elements/chunks/artifact-BSuPYFHY.js +0 -1
- package/dist/elements/chunks/attachments-CL6TaqIb.js +0 -1
- package/dist/elements/chunks/audio-visualizer-BuUqQmaO.js +0 -1
- package/dist/elements/chunks/badge-TIMiJFKc.js +0 -1
- package/dist/elements/chunks/bash-InADTalH.js +0 -1
- package/dist/elements/chunks/card-renderer-CSoTL_e1.js +0 -1
- package/dist/elements/chunks/card-routing-BK09BdmL.js +0 -1
- package/dist/elements/chunks/chat-thread-DxoKaStk.js +0 -1
- package/dist/elements/chunks/check-MdLzbxrm.js +0 -1
- package/dist/elements/chunks/chevron-down-MK7IzDqe.js +0 -1
- package/dist/elements/chunks/chevron-right-C5jXhmtV.js +0 -1
- package/dist/elements/chunks/choice-card-CGMc3kek.js +0 -1
- package/dist/elements/chunks/circle-BG7VkPep.js +0 -1
- package/dist/elements/chunks/circle-check-GqvO2UBs.js +0 -1
- package/dist/elements/chunks/circle-x-mhH7pOK2.js +0 -1
- package/dist/elements/chunks/code-block-ClhQO9RW.js +0 -1
- package/dist/elements/chunks/collapsible-DBcBkFPh.js +0 -1
- package/dist/elements/chunks/composer-CZZmtYOT.js +0 -69
- package/dist/elements/chunks/confirm-card-BWjf2-xo.js +0 -1
- package/dist/elements/chunks/context-hKjNqiyQ.js +0 -1
- package/dist/elements/chunks/conversation-list-CsGJjSKG.js +0 -1
- package/dist/elements/chunks/core-AYMC6_lb.js +0 -12
- package/dist/elements/chunks/css-M7EaDHN_.js +0 -1
- package/dist/elements/chunks/default-input-B1Mem5wu.js +0 -1
- package/dist/elements/chunks/define-B_tXMYRm.js +0 -1
- package/dist/elements/chunks/disclosure-DAoYOKew.js +0 -1
- package/dist/elements/chunks/download-DnCyWFJE.js +0 -1
- package/dist/elements/chunks/dropdown-CmNna5lT.js +0 -1
- package/dist/elements/chunks/embed-CjAD2jSi.js +0 -1
- package/dist/elements/chunks/engine-javascript-vq0WuIJl.js +0 -141
- package/dist/elements/chunks/file-text-D0J9F6M7.js +0 -1
- package/dist/elements/chunks/folder-NV1pi_ud.js +0 -1
- package/dist/elements/chunks/form-Cp8Y00Wn.js +0 -1
- package/dist/elements/chunks/github-dark-dimmed-DUshB20C.js +0 -1
- package/dist/elements/chunks/github-light-JYsPkUQd.js +0 -1
- package/dist/elements/chunks/hover-card-6KtXpLwT.js +0 -1
- package/dist/elements/chunks/html-CPZ3oZQ7.js +0 -1
- package/dist/elements/chunks/icon-97R8SR2p.js +0 -1
- package/dist/elements/chunks/info-C8r5Q6cc.js +0 -1
- package/dist/elements/chunks/input-DrseEjhp.js +0 -1
- package/dist/elements/chunks/javascript-C25yR2R2.js +0 -1
- package/dist/elements/chunks/json-DxJze_jm.js +0 -1
- package/dist/elements/chunks/kbd-OGJDUT-O.js +0 -1
- package/dist/elements/chunks/link-BdsfLB7b.js +0 -1
- package/dist/elements/chunks/loader-B5QzK_8_.js +0 -1
- package/dist/elements/chunks/message-CE4k-qaj.js +0 -1
- package/dist/elements/chunks/message-DtXKPqiR.js +0 -1
- package/dist/elements/chunks/message-square-C9ovmtOo.js +0 -1
- package/dist/elements/chunks/paperclip-Bg0ITU3b.js +0 -1
- package/dist/elements/chunks/progress-bar-D1_rzt6N.js +0 -1
- package/dist/elements/chunks/prompt-suggestion-D5Sm8xF1.js +0 -1
- package/dist/elements/chunks/reasoning-BrxQfpfI.js +0 -1
- package/dist/elements/chunks/rotate-cw-DzVDJOA1.js +0 -1
- package/dist/elements/chunks/scroll-area-93A1bbeG.js +0 -1
- package/dist/elements/chunks/scroll-button-CrTo7wm4.js +0 -1
- package/dist/elements/chunks/share-DgNbkJKY.js +0 -1
- package/dist/elements/chunks/slots-CIw9RlAe.js +0 -1
- package/dist/elements/chunks/source-w9V0NnBn.js +0 -1
- package/dist/elements/chunks/star-DHvACxtm.js +0 -1
- package/dist/elements/chunks/store-HIPGhNz9.js +0 -1
- package/dist/elements/chunks/svelte--5p79yCD.js +0 -1
- package/dist/elements/chunks/tasks-card-lPxoodlA.js +0 -1
- package/dist/elements/chunks/text-shimmer-BY_rI3s5.js +0 -1
- package/dist/elements/chunks/textarea-DPfuhswM.js +0 -1
- package/dist/elements/chunks/toast-store-VUZZBhzH.js +0 -1
- package/dist/elements/chunks/tsx-B8rCNbgL.js +0 -1
- package/dist/elements/chunks/typescript-RycA9KXf.js +0 -1
- package/dist/elements/chunks/use-card-resolution-DJg32jGH.js +0 -1
- package/dist/elements/chunks/variant-custom-D5ZlmziF.js +0 -1
- package/dist/elements/chunks/video-Bb86fVYI.js +0 -1
- package/dist/elements/chunks/vue-BmIZj4XD.js +0 -1
- package/dist/elements/chunks/x-BOhjBeOd.js +0 -1
- package/dist/llms/llms-full.txt +0 -2834
- package/dist/llms/llms.txt +0 -156
- package/dist/primitives/card-validate-generator.testlib.d.ts +0 -20
- package/dist/register-impl-DGmGzrEM.js +0 -145
- package/dist/ui/stat.d.ts +0 -16
- package/dist/variant-custom-MkTNTycd.js +0 -1
- package/src/primitives/card-validate-generator.testlib.ts +0 -38
- package/src/ui/stat.tsx +0 -41
- /package/dist/{elements/chunks/card-tags-D8lZ-C_U.js → card-tags-D8lZ-C_U.js} +0 -0
- /package/dist/{elements/chunks/link-preview-DNILK391.js → link-preview-DNILK391.js} +0 -0
package/README.md
CHANGED
|
@@ -75,17 +75,19 @@ The element bundle is a self-contained ES module — load it directly from [jsDe
|
|
|
75
75
|
```
|
|
76
76
|
|
|
77
77
|
<!-- x-release-please-start-version -->
|
|
78
|
-
The URLs above track the **latest** release — handy for trying things out. **For production, pin an exact version** (e.g. `@kitn.ai/ui@0.
|
|
78
|
+
The URLs above track the **latest** release — handy for trying things out. **For production, pin an exact version** (e.g. `@kitn.ai/ui@0.27.0/dist/kai.es.js`): pinned URLs are immutable and cached far more aggressively, and — since this package is pre-1.0 — pinning shields you from breaking changes in a future minor release.
|
|
79
79
|
<!-- x-release-please-end -->
|
|
80
80
|
|
|
81
81
|
> **Pin `0.25.0` or newer.** Every version from `0.14.1` through `0.24.0` is covered by a [critical security advisory](https://github.com/kitn-ai/ui/security/advisories) and is deprecated on npm. `npm install` warns you about a deprecated version; **a CDN fetch does not**, so an old pinned URL in a page keeps serving the vulnerable bundle silently.
|
|
82
82
|
|
|
83
|
-
SolidJS and the kit's CSS are bundled in, and the lazy code-highlighting chunks load from the same CDN on demand. To override design tokens, also include `theme.css
|
|
83
|
+
SolidJS and the kit's CSS are bundled in, and the lazy code-highlighting chunks load from the same CDN on demand. To override design tokens, also include `theme.tokens.css` — the browser-ready compiled build:
|
|
84
84
|
|
|
85
85
|
```html
|
|
86
|
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@kitn.ai/ui/theme.css">
|
|
86
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@kitn.ai/ui/dist/theme.tokens.css">
|
|
87
87
|
```
|
|
88
88
|
|
|
89
|
+
Not `theme.css` here: that file is Tailwind v4 *source* (its tokens live in an `@theme` block a plain `<link>` discards whole), so it only works when Tailwind processes your CSS. See [Which theme file](#which-theme-file).
|
|
90
|
+
|
|
89
91
|
### Option B — SolidJS components
|
|
90
92
|
|
|
91
93
|
```tsx
|
|
@@ -94,7 +96,7 @@ import {
|
|
|
94
96
|
Message, MessageContent,
|
|
95
97
|
PromptInput, PromptInputTextarea, PromptInputActions,
|
|
96
98
|
} from '@kitn.ai/ui';
|
|
97
|
-
import '@kitn.ai/ui/theme.css';
|
|
99
|
+
import '@kitn.ai/ui/theme.css'; // Tailwind-source; non-Tailwind builds import theme.tokens.css instead — see "Which theme file"
|
|
98
100
|
|
|
99
101
|
function App() {
|
|
100
102
|
const [input, setInput] = createSignal('');
|
|
@@ -191,7 +193,7 @@ The components are deliberately **transport-agnostic**: `<kai-chat>` just render
|
|
|
191
193
|
</script>
|
|
192
194
|
```
|
|
193
195
|
|
|
194
|
-
Key point: `chat.messages` has to be reassigned with a **new array
|
|
196
|
+
Key point, and it is not only a streaming rule: `chat.messages` has to be reassigned with a **new array**, and any message you changed has to be a **new object**. The array reference is what tells the element something changed — reassigning the same array is a no-op even if you swapped a message inside it. The new message object is what makes the change visible, because the list keys its rows by item identity. Adds, removes and reorders need only the fresh array; editing an existing message needs both, and mutating one in place won't update the view even inside a fresh array. `createAssistantStream` satisfies both halves for you; if you drive `messages` by hand — editing a message, renaming a conversation — you own it.
|
|
195
197
|
|
|
196
198
|
`@kitn.ai/ui/wire` also ships `readAnthropicStream`, the helpers for a multi-round tool loop, and a seam for a custom wire format. See the [wire adapter recipe](https://ui.kitn.ai/guides/recipes/wire-adapter/).
|
|
197
199
|
|
|
@@ -323,7 +325,14 @@ Visual appearance is driven by `--color-*` CSS custom properties in `theme.css`.
|
|
|
323
325
|
}
|
|
324
326
|
```
|
|
325
327
|
|
|
326
|
-
For
|
|
328
|
+
For web components the kit's CSS is injected into each shadow root automatically; the token stylesheet is optional and only themes host-page chrome / rebrands.
|
|
329
|
+
|
|
330
|
+
### Which theme file
|
|
331
|
+
|
|
332
|
+
Two builds of the same tokens; the condition is whether **Tailwind processes the file**:
|
|
333
|
+
|
|
334
|
+
- **`@kitn.ai/ui/theme.css`** — Tailwind v4 source (`@theme` block; needs `tailwindcss` as a peer). Import it only in an app whose build runs Tailwind over its CSS. Served raw to a browser, the `@theme` block is discarded whole and the tokens never apply.
|
|
335
|
+
- **`@kitn.ai/ui/theme.tokens.css`** — the compiled plain-CSS build of the same tokens, no toolchain requirements. Use it in every non-Tailwind bundler app and for `<link>`/CDN pages.
|
|
327
336
|
|
|
328
337
|
## For AI agents / LLMs
|
|
329
338
|
|
|
@@ -336,6 +345,8 @@ Both are auto-generated from `dist/custom-elements.json` during `npm run build`
|
|
|
336
345
|
|
|
337
346
|
> **#1 thing agents get wrong:** array/object data (`messages`, `models`, `context`, …) must be set as **JS properties**, not HTML attributes. Only scalars (`placeholder`, `loading`, `theme`) work as attributes.
|
|
338
347
|
|
|
348
|
+
> **Attachments:** `AttachmentData.url` is what reaches the model — a `data:` URI or an https URL, **never `URL.createObjectURL`**. A `blob:` URL previews perfectly and resolves only inside the tab that minted it, so `toOpenAIMessages`/`toAnthropicMessages` refuse it rather than send an address the model cannot fetch. `<kai-prompt-input>`'s paperclip already stages files as `data:` URIs; convert with `FileReader.readAsDataURL` when you stage files yourself.
|
|
349
|
+
|
|
339
350
|
## Development
|
|
340
351
|
|
|
341
352
|
```bash
|
package/bin/mcp.js
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
// fatal-error / exit handling here (a .js file, outside tsc's typed src/), so the
|
|
8
8
|
// stdio entry source stays free of Node globals.
|
|
9
9
|
import { fileURLToPath } from 'node:url';
|
|
10
|
+
import { decideEntry } from './route.js';
|
|
10
11
|
|
|
11
12
|
// stdout is the JSON-RPC channel; diagnostics must go to stderr.
|
|
12
13
|
function fatal(err) {
|
|
@@ -16,7 +17,19 @@ function fatal(err) {
|
|
|
16
17
|
process.on('unhandledRejection', fatal);
|
|
17
18
|
process.on('uncaughtException', fatal);
|
|
18
19
|
|
|
19
|
-
//
|
|
20
|
-
//
|
|
21
|
-
|
|
20
|
+
// Subcommand dispatch. `npx @kitn.ai/ui <cmd>`: `mcp` (or nothing) starts the
|
|
21
|
+
// MCP server — the historical behavior, byte-compatible and unchanged.
|
|
22
|
+
// dev/compile/eject/validate load the construct CLI. Anything else is a typo
|
|
23
|
+
// (e.g. `frobnicate`, `validat`) — it errors loudly to stderr and exits 2
|
|
24
|
+
// rather than silently falling through to the server (decideEntry, tested in
|
|
25
|
+
// route.test.js, owns that decision so it stays testable without spawning).
|
|
26
|
+
const [, , command] = process.argv;
|
|
27
|
+
const decision = decideEntry(command);
|
|
28
|
+
if (decision.kind === 'error') {
|
|
29
|
+
console.error(`[kitn-ui-mcp] ${decision.message}`);
|
|
30
|
+
process.exit(2);
|
|
31
|
+
}
|
|
32
|
+
const entry = fileURLToPath(
|
|
33
|
+
new URL(decision.kind === 'construct' ? '../dist/construct-cli.es.js' : '../dist/mcp.es.js', import.meta.url),
|
|
34
|
+
);
|
|
22
35
|
import(entry).catch(fatal);
|
package/bin/route.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Pure command-routing decision, extracted from bin/mcp.js for testability.
|
|
2
|
+
// This module has no side effects (no fs/process/import()) — bin/mcp.js does
|
|
3
|
+
// the actual dynamic import() based on what this returns.
|
|
4
|
+
export const CONSTRUCT_COMMANDS = ['dev', 'compile', 'eject', 'validate'];
|
|
5
|
+
export const KNOWN_COMMANDS = ['mcp', ...CONSTRUCT_COMMANDS];
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* `npx @kitn.ai/ui <cmd>`: `mcp` (or nothing) starts the MCP server — the
|
|
9
|
+
* historical behavior, byte-compatible and unchanged. dev/compile/eject/
|
|
10
|
+
* validate load the construct CLI. Anything else is a typo, not a server
|
|
11
|
+
* request — it must error loudly, never fall through to the server.
|
|
12
|
+
*
|
|
13
|
+
* @param {string | undefined} command
|
|
14
|
+
* @returns {{ kind: 'mcp' } | { kind: 'construct' } | { kind: 'error', message: string }}
|
|
15
|
+
*/
|
|
16
|
+
export function decideEntry(command) {
|
|
17
|
+
if (command === undefined || command === 'mcp') return { kind: 'mcp' };
|
|
18
|
+
if (CONSTRUCT_COMMANDS.includes(command)) return { kind: 'construct' };
|
|
19
|
+
return {
|
|
20
|
+
kind: 'error',
|
|
21
|
+
message: `unknown command "${command}" — valid commands: ${KNOWN_COMMANDS.join(', ')}`,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { execFileSync } from 'node:child_process';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import { dirname, join } from 'node:path';
|
|
5
|
+
import { decideEntry, CONSTRUCT_COMMANDS, KNOWN_COMMANDS } from './route.js';
|
|
6
|
+
|
|
7
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
8
|
+
const binPath = join(__dirname, 'mcp.js');
|
|
9
|
+
|
|
10
|
+
describe('decideEntry (pure routing decision)', () => {
|
|
11
|
+
it('no args -> mcp (byte-compatible historical behavior)', () => {
|
|
12
|
+
expect(decideEntry(undefined)).toEqual({ kind: 'mcp' });
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it('"mcp" -> mcp (byte-compatible historical behavior)', () => {
|
|
16
|
+
expect(decideEntry('mcp')).toEqual({ kind: 'mcp' });
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it.each(CONSTRUCT_COMMANDS)('%s -> construct', (cmd) => {
|
|
20
|
+
expect(decideEntry(cmd)).toEqual({ kind: 'construct' });
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('unknown/typo\'d command -> error naming the valid commands', () => {
|
|
24
|
+
const decision = decideEntry('frobnicate');
|
|
25
|
+
expect(decision.kind).toBe('error');
|
|
26
|
+
for (const known of KNOWN_COMMANDS) {
|
|
27
|
+
expect(decision.message).toContain(known);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
describe('bin/mcp.js dispatcher (spawned, real process)', () => {
|
|
33
|
+
it('unknown subcommand exits 2 with stderr naming valid commands, never falling through to the server', () => {
|
|
34
|
+
let status = 0;
|
|
35
|
+
let stderr = '';
|
|
36
|
+
try {
|
|
37
|
+
execFileSync('node', [binPath, 'frobnicate'], { timeout: 5000, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] });
|
|
38
|
+
} catch (err) {
|
|
39
|
+
status = err.status;
|
|
40
|
+
stderr = err.stderr;
|
|
41
|
+
}
|
|
42
|
+
expect(status).toBe(2);
|
|
43
|
+
expect(stderr).toMatch(/valid commands/i);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('a typo\'d valid-ish command (validat) also exits 2, not a hang', () => {
|
|
47
|
+
let status = 0;
|
|
48
|
+
let stderr = '';
|
|
49
|
+
try {
|
|
50
|
+
execFileSync('node', [binPath, 'validat'], { timeout: 5000, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] });
|
|
51
|
+
} catch (err) {
|
|
52
|
+
status = err.status;
|
|
53
|
+
stderr = err.stderr;
|
|
54
|
+
}
|
|
55
|
+
expect(status).toBe(2);
|
|
56
|
+
expect(stderr).toMatch(/valid commands/i);
|
|
57
|
+
});
|
|
58
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as d,
|
|
1
|
+
import{s as d,p as h,q as i,m as u,i as c,c as n,D as k,F as g,t as w}from"./define-CGGX-7Vg.js";var m={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linecap":"round","stroke-linejoin":"round"},t=m,p=w("<svg>"),v=r=>r.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),b=(...r)=>r.filter((e,s,o)=>!!e&&o.indexOf(e)===s).join(" "),f=r=>{const[e,s]=d(r,["color","size","strokeWidth","children","class","name","iconNode","absoluteStrokeWidth"]);return(()=>{var o=p();return h(o,i(t,{get width(){return e.size??t.width},get height(){return e.size??t.height},get stroke(){return e.color??t.stroke},get"stroke-width"(){return u(()=>!!e.absoluteStrokeWidth)()?Number(e.strokeWidth??t["stroke-width"])*24/Number(e.size):Number(e.strokeWidth??t["stroke-width"])},get class(){return b("lucide","lucide-icon",e.name!=null?`lucide-${v(e?.name)}`:void 0,e.class!=null?e.class:"")}},s),!0,!0),c(o,n(g,{get each(){return e.iconNode},children:([a,l])=>n(k,i({component:a},l))})),o})()},z=f;export{z as I};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{I as e}from"./Icon-BnFKqqtY.js";import{c as a,q as r}from"./define-CGGX-7Vg.js";import{f as t,t as i,b as m,s as p,p as s}from"./trash-2-BR1RxGky.js";import{c as k}from"./check-DPeeMUYx.js";import{c as n}from"./copy-B6DO4PqB.js";import{d}from"./rotate-cw-DOB9IGcU.js";import{e as f}from"./ellipsis-DFr4Vqr3.js";import{l}from"./link-DlZZBGaR.js";import{s as c}from"./star-CBMZvLuN.js";import{t as y,a as h}from"./thumbs-up-DQcu2HMO.js";import{x as v}from"./x-C5m1JFgi.js";var g=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],u=o=>a(e,r(o,{name:"RefreshCw",iconNode:g})),M=u,L=[["polyline",{points:"9 17 4 12 9 7",key:"hvgpf2"}],["path",{d:"M20 18v-2a4 4 0 0 0-4-4H4",key:"5vmcpk"}]],N=o=>a(e,r(o,{name:"Reply",iconNode:L})),b=N,w=[["polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5",key:"16drj5"}],["path",{d:"M15.54 8.46a5 5 0 0 1 0 7.07",key:"ltjumu"}],["path",{d:"M19.07 4.93a10 10 0 0 1 0 14.14",key:"1kegas"}]],x=o=>a(e,r(o,{name:"Volume2",iconNode:w})),C=x;const R={copy:n,like:h,dislike:y,regenerate:M,edit:s,share:p,bookmark:m,download:d,link:l,trash:i,check:k,x:v,star:c,flag:t,reply:b,more:f,"volume-2":C};function j(o){if(o)return R[o]}const q={copy:"Copy",like:"Like",dislike:"Dislike",regenerate:"Regenerate",edit:"Edit"};export{q as B,j as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{I as o}from"./Icon-BnFKqqtY.js";import{c as r,q as e}from"./define-CGGX-7Vg.js";var m=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],p=a=>r(o,e(a,{name:"ArrowDown",iconNode:m})),t=p;export{t as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{I as o}from"./Icon-BnFKqqtY.js";import{c as r,q as e}from"./define-CGGX-7Vg.js";var m=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],t=a=>r(o,e(a,{name:"ArrowLeft",iconNode:m})),p=t;export{p as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{q as J,s as he,g as k,k as y,j as F,x as Q,o as X,p as fe,i as c,c as a,S as g,t as v,d as p,a as z,b as Y,u as Z,m as ge,h as be,e as ve}from"./define-CGGX-7Vg.js";import{c as H}from"./cn-DN5AWfiS.js";import{B as C}from"./button-BH6rN0U-.js";import{C as me,a as pe}from"./code-block-CUQ5mtv0.js";import{F as we}from"./file-tree-D3kBjXI5.js";import{L as xe}from"./loader-YQszHFaW.js";import{i as ke,a as ee}from"./url-scheme-policy-DHpoTJwB.js";import{a as ye}from"./arrow-left-Dj7xgE12.js";import{a as ze,r as Ce,h as Te,e as Fe,c as Pe,d as Se}from"./rotate-cw-DOB9IGcU.js";import{e as re}from"./external-link-u9d85ORQ.js";import{f as Oe}from"./file-text-CX7_x42o.js";import{m as Re,a as je}from"./minimize-2-UEZmP2QT.js";const Ie="6.0.227",ne=`https://cdn.jsdelivr.net/npm/pdfjs-dist@${Ie}/build`,He=()=>import(/*@vite-ignore*/`${ne}/pdf.min.mjs`),Ne=`${ne}/pdf.worker.min.mjs`;let Ee=He,Me=Ne,N=null;function $e(){if(!N){const r=Ee;N=(async()=>{const t=await r(),e=t.default??t;return e.GlobalWorkerOptions.workerSrc=Me,e})()}return N}async function Be(r,t,e){const i=await(await $e()).getDocument({url:r}).promise;t.replaceChildren();const o=typeof window<"u"&&window.devicePixelRatio?window.devicePixelRatio:1;for(let s=1;s<=i.numPages;s++){const d=await i.getPage(s),u=d.getViewport({scale:1}),h=u.width>0?e/u.width:1,f=d.getViewport({scale:h*o}),b=document.createElement("canvas");b.width=Math.max(1,Math.floor(f.width)),b.height=Math.max(1,Math.floor(f.height)),b.setAttribute("role","img"),b.setAttribute("aria-label",`Page ${s}`),b.style.width="100%",b.style.height="auto",b.style.display="block";const w=b.getContext("2d");t.appendChild(b),await d.render({canvasContext:w,viewport:f}).promise}return{pages:i.numPages}}var Le=v('<div><div class="relative min-h-0 flex-1">'),Ue=v('<form class="min-w-0 flex-1"><label class=sr-only for=kai-artifact-path>Address</label><input id=kai-artifact-path name=kai-artifact-path type=text autocomplete=off placeholder="Enter a path or URL\u2026">'),De=v("<div class=flex-1 aria-hidden=true>"),Ae=v('<div role=tablist aria-label=View class="flex shrink-0 items-center gap-0.5 rounded-md bg-muted p-0.5">'),Ve=v('<div data-artifact-toolbar class="flex shrink-0 items-center gap-1.5 border-b border-border bg-surface px-2 py-1.5">'),We=v("<button type=button role=tab>"),Ke=v('<iframe class="absolute inset-0 h-full w-full border-0 bg-white">'),_e=v('<div class="absolute inset-0 flex"><div class="w-56 shrink-0 overflow-auto border-r border-border bg-surface-sunken py-1.5 scrollbar-thin"></div><div class="min-w-0 flex-1 overflow-auto scrollbar-thin">'),qe=v('<div class="flex h-full items-center justify-center p-6 text-sm text-muted-foreground">Select a file to view its source.'),Ge=v('<div class="flex h-full items-center justify-center p-6 text-sm text-muted-foreground">No source \u2014 this file (<!>) has no code view.'),Je=v('<div class="flex flex-wrap items-center justify-center gap-2"><a class="inline-flex h-8 items-center gap-1.5 rounded-md border border-border bg-background px-3 text-xs font-medium text-foreground transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"target=_blank rel="noopener noreferrer">Open in new tab</a><a class="inline-flex h-8 items-center gap-1.5 rounded-md border border-border bg-background px-3 text-xs font-medium text-foreground transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"download>Download'),Qe=v(`<div role=region aria-label="PDF preview unavailable"class="absolute inset-0 flex flex-col items-center justify-center gap-3 bg-card p-6 text-center"><div class="text-sm font-medium text-foreground"></div><div class="text-xs text-muted-foreground">Can't preview this PDF inline.`),Xe=v(`<div class="text-xs text-muted-foreground">Blocked: that address uses a scheme this viewer won't open.`),Ye=v('<div class="pointer-events-none absolute inset-0 flex items-center justify-center">'),Ze=v('<div class="absolute inset-0"><div role=region aria-label="PDF preview"tabindex=0 class="absolute inset-0 flex flex-col items-center gap-3 overflow-auto bg-surface-sunken p-3 scrollbar-thin focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset">');const er="allow-scripts allow-forms";function E(r,t){console.warn(`[kai-artifact] blocked unsafe url in ${r}: ${t}`)}function rr(r,t){if(r.url)return r.url;if(!t)return r.path;try{return new URL(r.path,t).href}catch{return r.path}}function nr(r,t){if(!r)return!1;const e=t.find(o=>o.url===r||o.path===r);if(e?.type==="pdf")return!0;const i=r.split(/[?#]/)[0];return/\.pdf$/i.test(i)}function tr(r){const t=J({files:[],defaultTab:"preview",sandbox:er,showNav:!0,showReload:!0,showHome:!0,showPathField:!0,showTabs:!0,expandable:!1,openInTab:!1,standalone:!1,readonlyPath:!1,maximized:!1},r),[e,i]=he(t,["src","files","tab","defaultTab","activeFile","sandbox","iframeTitle","onNavigate","onTabChange","onFileSelect","maximized","onMaximizeChange","showNav","showReload","showHome","showPathField","showTabs","expandable","openInTab","standalone","readonlyPath","displayUrl","controllerRef","class"]),[o,s]=k(e.src?[e.src]:[]),[d,u]=k(e.src?0:-1),h=()=>o()[d()]??"",f=()=>d()>0,b=()=>d()<o().length-1,w=y(()=>{const n=h();return n&&ke(n)?(E("preview",n),""):n}),[P,M]=k(e.tab??e.defaultTab),[$,B]=k(e.activeFile),[ae,ie]=k(0),[S,O]=k(e.maximized??!1);F(()=>O(e.maximized??!1));const le=()=>{var n;const l=!S();O(l),(n=e.onMaximizeChange)==null||n.call(e,l)},L=y(()=>{const n=h();return!!n&&n!=="about:blank"&&ee(n)}),U=()=>{const n=h();if(!L()){n&&n!=="about:blank"&&E("openExternal",n);return}window.open(n,"_blank","noopener,noreferrer")},D=y(()=>e.expandable&&!e.standalone),oe=y(()=>e.showNav||e.showReload||e.showHome||e.showPathField||e.showTabs||D()||e.openInTab);let x;F(()=>{e.tab!==void 0&&M(e.tab)}),F(()=>B(e.activeFile)),F(Q(()=>e.src,n=>{n&&n!==h()&&T(n)},{defer:!0}));const A=n=>n===void 0?void 0:e.files.find(l=>l.path===n),V=y(()=>A($())),se=y(()=>{const n=V();return!!n&&n.type!=="image"&&n.type!=="pdf"&&typeof n.code=="string"});function T(n){if(n===h()){j();return}s(l=>[...l.slice(0,d()+1),n]),u(l=>l+1),R()}function R(){var n;x&&(x.src=w()||"about:blank"),(n=e.onNavigate)==null||n.call(e,h())}function de(n){var l;n!==P()&&(M(n),(l=e.onTabChange)==null||l.call(e,n))}function W(n,l){var m;B(n),(m=e.onFileSelect)==null||m.call(e,n),T(rr(l,e.src))}const K=()=>{f()&&(u(n=>n-1),R())},_=()=>{b()&&(u(n=>n+1),R())};function j(){var n;x&&(x.src="about:blank",x.src=w()||"about:blank"),ie(l=>l+1),(n=e.onNavigate)==null||n.call(e,h())}const q=()=>{e.src&&T(e.src)},G=n=>{var l;S()!==n&&(O(n),(l=e.onMaximizeChange)==null||l.call(e,n))};X(()=>{var n;(n=e.controllerRef)==null||n.call(e,{back:()=>K(),forward:()=>_(),reload:()=>j(),home:()=>q(),navigate:l=>T(l),selectFile:l=>{const m=A(l);m&&W(l,m)},openExternal:()=>U(),maximize:()=>G(!0),restore:()=>G(!1)})});const ue=()=>{var n,l;try{const m=(n=x?.contentWindow)==null?void 0:n.location.href;m&&m!=="about:blank"&&m!==h()&&(s(I=>[...I.slice(0,d()+1),m]),u(I=>I+1),(l=e.onNavigate)==null||l.call(e,m))}catch{}},ce=n=>{n.preventDefault();const l=n.currentTarget.elements.namedItem("kai-artifact-path");if(e.readonlyPath||e.displayUrl!=null){l&&(l.value=e.displayUrl??h());return}l&&l.value&&T(l.value)};return(()=>{var n=Le(),l=n.firstChild;return fe(n,J({get class(){return H("flex h-full w-full flex-col overflow-hidden bg-card text-card-foreground",e.standalone&&"rounded-xl border border-border",e.class)}},i),!1,!0),c(n,a(g,{get when(){return oe()},get children(){return a(ar,{url:()=>e.displayUrl??h(),tab:P,canBack:f,canForward:b,canHome:()=>!!e.src,onBack:K,onForward:_,onReload:j,onHome:q,onSubmitPath:ce,onTab:de,showNav:()=>e.showNav,showReload:()=>e.showReload,showHome:()=>e.showHome,showPathField:()=>e.showPathField,showTabs:()=>e.showTabs,showExpand:D,showOpenInTab:()=>e.openInTab,maximized:S,onToggleMaximize:le,canOpenInTab:L,onOpenInTab:U,readonlyPath:()=>e.readonlyPath||e.displayUrl!=null})}}),l),c(l,a(g,{get when(){return P()==="preview"},get fallback(){return a(lr,{get files(){return e.files},activeFile:$,activeFileObj:V,hasSource:se,onSelect:W})},get children(){return a(g,{get when(){return nr(h(),e.files)},get fallback(){return a(ir,{ref:m=>x=m,src:w,get sandbox(){return e.sandbox},get title(){return e.iframeTitle??"Artifact preview"},onLoad:ue})},get children(){return a(sr,{get url(){return h()},get reloadKey(){return ae()}})}})}})),n})()}function ar(r){return(()=>{var t=Ve();return c(t,a(g,{get when(){return r.showNav()},get children(){return[a(C,{variant:"ghost",size:"icon-sm","aria-label":"Back",get disabled(){return!r.canBack()},onClick:()=>r.onBack(),get children(){return a(ye,{size:16,"aria-hidden":"true"})}}),a(C,{variant:"ghost",size:"icon-sm","aria-label":"Forward",get disabled(){return!r.canForward()},onClick:()=>r.onForward(),get children(){return a(ze,{size:16,"aria-hidden":"true"})}})]}}),null),c(t,a(g,{get when(){return r.showReload()},get children(){return a(C,{variant:"ghost",size:"icon-sm","aria-label":"Reload",onClick:()=>r.onReload(),get children(){return a(Ce,{size:15,"aria-hidden":"true"})}})}}),null),c(t,a(g,{get when(){return r.showHome()},get children(){return a(C,{variant:"ghost",size:"icon-sm","aria-label":"Home",get disabled(){return!r.canHome()},onClick:()=>r.onHome(),get children(){return a(Te,{size:15,"aria-hidden":"true"})}})}}),null),c(t,a(g,{get when(){return r.showPathField()},get children(){var e=Ue(),i=e.firstChild,o=i.nextSibling;return e.addEventListener("submit",s=>r.onSubmitPath(s)),p(o,"spellcheck",!1),z(s=>{var d=r.readonlyPath()||void 0,u=r.readonlyPath()?"true":void 0,h=H("h-7 w-full rounded-md border border-border px-2.5 text-xs text-foreground font-mono outline-none",r.readonlyPath()?"bg-muted/40 cursor-default":"bg-background focus-visible:ring-2 focus-visible:ring-ring");return d!==s.e&&(o.readOnly=s.e=d),u!==s.t&&p(o,"aria-readonly",s.t=u),h!==s.a&&Y(o,s.a=h),s},{e:void 0,t:void 0,a:void 0}),z(()=>o.value=r.url()),e}}),null),c(t,a(g,{get when(){return!r.showPathField()},get children(){return De()}}),null),c(t,a(g,{get when(){return r.showExpand()},get children(){return a(C,{variant:"ghost",size:"icon-sm",get"aria-label"(){return r.maximized()?"Collapse":"Expand"},get"aria-expanded"(){return r.maximized()},onClick:()=>r.onToggleMaximize(),get children(){return a(g,{get when(){return r.maximized()},get fallback(){return a(je,{size:15,"aria-hidden":"true"})},get children(){return a(Re,{size:15,"aria-hidden":"true"})}})}})}}),null),c(t,a(g,{get when(){return r.showOpenInTab()},get children(){return a(C,{variant:"ghost",size:"icon-sm","aria-label":"Open in new tab",get disabled(){return!r.canOpenInTab()},onClick:()=>r.onOpenInTab(),get children(){return a(re,{size:15,"aria-hidden":"true"})}})}}),null),c(t,a(g,{get when(){return r.showTabs()},get children(){var e=Ae();return c(e,a(te,{label:"Preview",get icon(){return a(Fe,{size:14,"aria-hidden":"true"})},get selected(){return r.tab()==="preview"},onClick:()=>r.onTab("preview")}),null),c(e,a(te,{label:"Code",get icon(){return a(Pe,{size:14,"aria-hidden":"true"})},get selected(){return r.tab()==="code"},onClick:()=>r.onTab("code")}),null),e}}),null),t})()}function te(r){return(()=>{var t=We();return t.$$click=()=>r.onClick(),c(t,()=>r.icon,null),c(t,()=>r.label,null),z(e=>{var i=r.selected,o=H("inline-flex h-6 items-center gap-1.5 rounded px-2 text-xs font-medium transition-colors outline-none","focus-visible:ring-2 focus-visible:ring-ring",r.selected?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground");return i!==e.e&&p(t,"aria-selected",e.e=i),o!==e.t&&Y(t,e.t=o),e},{e:void 0,t:void 0}),t})()}function ir(r){return(()=>{var t=Ke();t.addEventListener("load",()=>r.onLoad());var e=r.ref;return typeof e=="function"?Z(e,t):r.ref=t,z(i=>{var o=r.src()||"about:blank",s=r.sandbox,d=r.title;return o!==i.e&&p(t,"src",i.e=o),s!==i.t&&p(t,"sandbox",i.t=s),d!==i.a&&p(t,"title",i.a=d),i},{e:void 0,t:void 0,a:void 0}),t})()}function lr(r){return(()=>{var t=_e(),e=t.firstChild,i=e.nextSibling;return c(e,a(we,{get files(){return r.files},get activeFile(){return r.activeFile()},onSelect:(o,s)=>r.onSelect(o,s)})),c(i,a(g,{get when(){return r.activeFileObj()},get fallback(){return qe()},get children(){return a(g,{get when(){return r.hasSource()},get fallback(){return(()=>{var o=Ge(),s=o.firstChild,d=s.nextSibling;return d.nextSibling,c(o,()=>r.activeFileObj().type??"binary",d),o})()},get children(){return a(me,{class:"h-full rounded-none border-0",get children(){return a(pe,{get code(){return r.activeFileObj().code??""},get language(){return r.activeFileObj().language}})}})}})}})),t})()}function or(r){const t=()=>{const i=r.url.split(/[?#]/)[0];return i.slice(i.lastIndexOf("/")+1)||"document.pdf"},e=y(()=>{if(r.url){if(ee(r.url))return r.url;E("pdf fallback",r.url)}});return(()=>{var i=Qe(),o=i.firstChild;return o.nextSibling,c(i,a(Oe,{size:40,class:"text-muted-foreground","aria-hidden":"true"}),o),c(o,t),c(i,a(g,{get when(){return e()},get fallback(){return Xe()},get children(){var s=Je(),d=s.firstChild;d.firstChild;var u=d.nextSibling,h=u.firstChild;return c(d,a(re,{size:13,"aria-hidden":"true"}),null),c(u,a(Se,{size:13,"aria-hidden":"true"}),h),z(f=>{var b=e(),w=e();return b!==f.e&&p(d,"href",f.e=b),w!==f.t&&p(u,"href",f.t=w),f},{e:void 0,t:void 0}),s}}),null),i})()}function sr(r){const[t,e]=k("loading");let i,o=0,s;const d=async()=>{if(!i){e("error");return}const u=++o;e("loading");try{const h=i.clientWidth||600;await Be(r.url,i,h),u===o&&e("success")}catch{u===o&&e("error")}};return F(Q(()=>[r.url,r.reloadKey],()=>{d()})),X(()=>{if(!i||typeof ResizeObserver>"u")return;const u=new ResizeObserver(()=>{t()==="success"&&(clearTimeout(s),s=setTimeout(()=>{d()},200))});u.observe(i),be(()=>{u.disconnect(),clearTimeout(s),o++})}),(()=>{var u=Ze(),h=u.firstChild;return Z(f=>i=f,h),c(u,a(g,{get when(){return ge(()=>!0)()&&t()==="loading"},get children(){var f=Ye();return c(f,a(xe,{variant:"circular",size:"md"})),f}}),null),c(u,a(g,{get when(){return t()==="error"},get children(){return a(or,{get url(){return r.url}})}}),null),z(()=>p(h,"aria-busy",t()==="loading")),u})()}ve(["click"]);export{tr as A};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { spawn } from "node:child_process";
|
|
3
|
+
import { existsSync, readFileSync, writeFileSync, watch } from "node:fs";
|
|
4
|
+
import { join, resolve, basename, dirname } from "node:path";
|
|
5
|
+
import { v as validateConstruct, g as generateProject, w as writeProject, a as accentContrastNotice } from "../construct-cli.es.js";
|
|
6
|
+
import "zod";
|
|
7
|
+
import "node:module";
|
|
8
|
+
function workDirFor(name, root) {
|
|
9
|
+
return join(root, ".kai", name);
|
|
10
|
+
}
|
|
11
|
+
function installKey(files) {
|
|
12
|
+
const pkg = files.find((f) => f.path === "package.json");
|
|
13
|
+
return createHash("sha256").update(pkg?.code ?? "").digest("hex");
|
|
14
|
+
}
|
|
15
|
+
function regenerate(raw, sink, dir, opts = {}) {
|
|
16
|
+
const validated = validateConstruct(raw);
|
|
17
|
+
if (!validated.ok) return validated;
|
|
18
|
+
const files = generateProject(validated.construct, opts);
|
|
19
|
+
sink.write(files, dir);
|
|
20
|
+
return { ok: true, files, construct: validated.construct };
|
|
21
|
+
}
|
|
22
|
+
function regenTurn(readRaw, sink, dir, opts, io) {
|
|
23
|
+
try {
|
|
24
|
+
const raw = readRaw();
|
|
25
|
+
const out = regenerate(raw, sink, dir, opts);
|
|
26
|
+
if (!out.ok) {
|
|
27
|
+
io.error("construct rejected — last good preview stays up:");
|
|
28
|
+
for (const p of out.problems) io.error(` ${p.path || "(root)"}: ${p.message}`);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
io.log("construct changed — regenerated; Vite will hot-update the tab.");
|
|
32
|
+
const notice = accentContrastNotice(out.construct);
|
|
33
|
+
if (notice) io.log(notice);
|
|
34
|
+
} catch (err) {
|
|
35
|
+
io.error(`regen failed (${err instanceof Error ? err.message : String(err)}) — last good preview stays up`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
const KEY_FILE = ".kai-install-key";
|
|
39
|
+
async function ensureInstalled(dir, files, io) {
|
|
40
|
+
const key = installKey(files);
|
|
41
|
+
const keyPath = join(dir, KEY_FILE);
|
|
42
|
+
const installed = existsSync(keyPath) && readFileSync(keyPath, "utf8") === key;
|
|
43
|
+
if (installed) return;
|
|
44
|
+
io.log(`installing dependencies in ${dir} (first run or deps changed)…`);
|
|
45
|
+
await new Promise((done, fail) => {
|
|
46
|
+
const child = spawn("npm", ["install"], { cwd: dir, stdio: "inherit" });
|
|
47
|
+
child.on("exit", (code) => code === 0 ? done() : fail(new Error(`npm install exited ${code}`)));
|
|
48
|
+
});
|
|
49
|
+
writeFileSync(keyPath, key);
|
|
50
|
+
}
|
|
51
|
+
async function dev(constructPath, opts = {}) {
|
|
52
|
+
const io = opts.io ?? { log: (s) => console.log(s), error: (s) => console.error(s) };
|
|
53
|
+
const abs = resolve(constructPath);
|
|
54
|
+
const readRaw = () => JSON.parse(readFileSync(abs, "utf8"));
|
|
55
|
+
const first = validateConstruct(readRaw());
|
|
56
|
+
if (!first.ok) {
|
|
57
|
+
for (const p of first.problems) io.error(` ${p.path || "(root)"}: ${p.message}`);
|
|
58
|
+
process.exit(1);
|
|
59
|
+
}
|
|
60
|
+
const dir = workDirFor(first.construct.name, process.cwd());
|
|
61
|
+
const files = generateProject(first.construct, { uiSpec: opts.uiSpec });
|
|
62
|
+
writeProject(files, dir);
|
|
63
|
+
const firstNotice = accentContrastNotice(first.construct);
|
|
64
|
+
if (firstNotice) io.log(firstNotice);
|
|
65
|
+
await ensureInstalled(dir, files, io);
|
|
66
|
+
const base = basename(abs);
|
|
67
|
+
watch(dirname(abs), (_event, filename) => {
|
|
68
|
+
if (filename !== base) return;
|
|
69
|
+
regenTurn(readRaw, { write: writeProject }, dir, { uiSpec: opts.uiSpec }, io);
|
|
70
|
+
});
|
|
71
|
+
io.log(`previewing <${first.construct.name}> — edit ${abs} and watch the tab.`);
|
|
72
|
+
const vite = spawn("npm", ["run", "dev"], { cwd: dir, stdio: "inherit" });
|
|
73
|
+
const killVite = () => vite.kill();
|
|
74
|
+
process.once("exit", killVite);
|
|
75
|
+
process.once("SIGINT", killVite);
|
|
76
|
+
process.once("SIGTERM", killVite);
|
|
77
|
+
return new Promise((_, rejectP) => {
|
|
78
|
+
vite.on("exit", (code) => {
|
|
79
|
+
rejectP(new Error(`vite dev exited ${code}`));
|
|
80
|
+
process.exit(code ?? 0);
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
export {
|
|
85
|
+
dev,
|
|
86
|
+
ensureInstalled,
|
|
87
|
+
installKey,
|
|
88
|
+
regenTurn,
|
|
89
|
+
regenerate,
|
|
90
|
+
workDirFor
|
|
91
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as d,q as m,s as b,p as h,i as l,S as f,m as x,t as p,B as j,G as I,a as R,d as w}from"./define-CGGX-7Vg.js";import{c as g}from"./cn-DN5AWfiS.js";import{B as S}from"./button-BH6rN0U-.js";import{H as U,a as V,b as G}from"./hover-card-DaeiYrTA.js";import{x as O}from"./x-C5m1JFgi.js";import{I as q}from"./Icon-BnFKqqtY.js";import{f as W}from"./file-text-CX7_x42o.js";import{p as X,g as Y,i as Z}from"./paperclip-BDNoZFJP.js";var J=[["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z",key:"1mlx9k"}]],K=e=>d(q,m(e,{name:"FileCode",iconNode:J})),Q=K,_=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m14.5 12.5-5 5",key:"b62r18"}],["path",{d:"m9.5 12.5 5 5",key:"1rk7el"}]],ee=e=>d(q,m(e,{name:"FileX",iconNode:_})),te=ee;const D=[{pattern:"image/jpeg",kind:"image"},{pattern:"image/png",kind:"image"},{pattern:"image/gif",kind:"image"},{pattern:"image/webp",kind:"image"},{pattern:"application/pdf",kind:"document"},{pattern:"text/*",kind:"text"},{pattern:"application/json",kind:"text"},{pattern:"application/xml",kind:"text"},{pattern:"application/x-yaml",kind:"text"},{pattern:"application/yaml",kind:"text"}],A="text/plain",ae=["","application/octet-stream"],C=e=>e.trim().toLowerCase(),H=e=>ae.includes(e===void 0?"":C(e)),re=e=>{if(!e.startsWith("."))return e;throw new Error(`\`accept\` entry "${e}" is a file extension, and this kit takes media types only. HTML's own accept attribute does take extensions, which is exactly why this throws rather than quietly matching nothing. Use a media type instead -- "text/*" covers source files, "image/*" images, "application/pdf" PDFs, and \`encodableMediaTypes()\` is the full set. You lose nothing by dropping the extension: a file the browser cannot name is decided by decoding its bytes, which is stronger than matching its name.`)},ne=e=>(typeof e=="string"?e.split(","):e).map(C).filter(a=>a!=="").map(re),N=e=>{const a=e.indexOf("/");return a===-1?[e,""]:[e.slice(0,a),e.slice(a+1)]},k=(e,a)=>{const[r,t]=N(e),[i,n]=N(a);return r!=="*"&&r!==i?!1:t==="*"||t===n},ie=(e,a)=>{if(k(e,a))return a;if(k(a,e))return e};function P(e={}){const a=e.accept===void 0?void 0:ne(e.accept),r=[];for(const t of D){if(a===void 0){r.push({...t});continue}for(const i of a){const n=ie(t.pattern,i);n!==void 0&&!r.some(s=>s.pattern===n)&&r.push({pattern:n,kind:t.kind})}}return{types:r.map(t=>t.pattern),accept:r.map(t=>t.pattern).join(","),decide(t){const i=t===void 0?"":C(t);if(H(i))return r.some(s=>k(s.pattern,A))?{status:"undetermined"}:{status:"unsupported"};const n=r.find(s=>k(s.pattern,i));return n?{status:"allowed",kind:n.kind}:D.some(s=>k(s.pattern,i))?{status:"filtered"}:{status:"unsupported"}}}}const $=P();var T=p("<div>"),se=p("<div part=attachment>"),E=p("<span class=sr-only>"),oe=p('<img class="size-full object-cover"height=96 width=96>'),de=p('<img class="size-full rounded object-cover"height=20 width=20>'),ce=p('<span class="text-warning text-caption block truncate">unsupported attachment format'),ue=p('<div part=attachment-name><span class="block truncate">'),le=p("<div part=attachment-name>"),pe=p('<span class="text-muted-foreground text-caption block truncate">');const ge={document:W,image:Z,source:Y,text:Q,unknown:X,unsendable:te},z=e=>{if(e.type==="source-document")return"source";const a=$.decide(e.mediaType);switch(a.status){case"allowed":return a.kind;case"unsupported":return"unsendable";case"undetermined":case"filtered":return"unknown"}},me=e=>{var a;return z(e)!=="unsendable"?void 0:`${((a=e.mediaType)==null?void 0:a.trim())||"This file type"} is not one of the attachment formats a model request can carry.`},F=e=>{if(e.type==="source-document")return e.title||e.filename||"Source";const a=z(e);return e.filename||(a==="image"?"Image":"Attachment")},B=j(),L=j(),he=()=>I(B)??{variant:"grid"},M=()=>{const e=I(L);if(!e)throw new Error("Attachment components must be used within <Attachment>");return e};function fe(e){const[a,r]=b(e,["variant","class","children"]),t=()=>a.variant??"grid";return d(B.Provider,{value:{get variant(){return t()}},get children(){var i=T();return h(i,m({get class(){return g("flex items-start",t()==="list"?"flex-col gap-2":"flex-wrap gap-2",t()==="grid"&&"w-fit",a.class)}},r),!1,!0),l(i,()=>a.children),i}})}function ve(e){const[a,r]=b(e,["data","onRemove","class","children"]),t=he(),i=()=>z(a.data),n=()=>me(a.data);return d(L.Provider,{value:{get data(){return a.data},get mediaCategory(){return i()},get onRemove(){return a.onRemove},get variant(){return t.variant}},get children(){var s=se();return h(s,m({get class(){return g("group relative",t.variant==="grid"&&"size-24 overflow-hidden rounded-lg",t.variant==="inline"&&["flex h-8 cursor-pointer select-none items-center gap-1.5","rounded-md bg-surface-strong px-1.5 text-foreground","font-medium text-sm transition-all","hover:bg-muted"],t.variant==="list"&&["flex w-full items-center gap-3 rounded-lg bg-surface p-3 text-foreground","hover:bg-muted/50"],a.class)},get"data-unsendable"(){return n()===void 0?void 0:""},get title(){return n()}},r),!1,!0),l(s,d(f,{get when(){return n()},children:o=>(()=>{var u=E();return l(u,o),u})()}),null),l(s,()=>a.children,null),s}})}function ye(e){const[a,r]=b(e,["fallbackIcon","class"]),t=M(),i=()=>t.variant==="inline"?"size-3":"size-4",n=o=>d(o,{get class(){return g(i(),t.mediaCategory==="unsendable"?"text-warning":"text-muted-foreground")}}),s=()=>{if(t.mediaCategory==="image"&&t.data.type==="file"&&t.data.url)return t.variant==="grid"?(()=>{var u=oe();return R(c=>{var v=t.data.filename||"Image",y=t.data.url;return v!==c.e&&w(u,"alt",c.e=v),y!==c.t&&w(u,"src",c.t=y),c},{e:void 0,t:void 0}),u})():(()=>{var u=de();return R(c=>{var v=t.data.filename||"Image",y=t.data.url;return v!==c.e&&w(u,"alt",c.e=v),y!==c.t&&w(u,"src",c.t=y),c},{e:void 0,t:void 0}),u})();const o=ge[t.mediaCategory];return a.fallbackIcon??n(o)};return(()=>{var o=T();return h(o,m({get class(){return g("flex shrink-0 items-center justify-center overflow-hidden",t.variant==="grid"&&"size-full bg-muted",t.variant==="inline"&&"size-5 rounded bg-background",t.variant==="list"&&"size-12 rounded bg-muted",a.class)}},r),!1,!0),l(o,s),o})()}function be(e){const[a,r]=b(e,["showMediaType","class"]),t=M(),i=()=>F(t.data);return d(f,{get when(){return t.variant!=="grid"},get fallback(){return d(f,{get when(){return t.mediaCategory!=="image"},get children(){var n=le();return h(n,m({get class(){return g("absolute inset-x-0 bottom-0 truncate px-1.5 py-1 text-caption","bg-background/85 backdrop-blur-sm",t.mediaCategory==="unsendable"?"text-warning":"text-foreground",a.class)}},r),!1,!0),l(n,i),n}})},get children(){var n=ue(),s=n.firstChild;return h(n,m({get class(){return g("min-w-0 flex-1",a.class)}},r),!1,!0),l(s,i),l(n,d(f,{get when(){return x(()=>t.mediaCategory==="unsendable")()&&t.variant==="list"},get fallback(){return d(f,{get when(){return x(()=>!!(a.showMediaType&&t.variant==="list"))()&&t.data.mediaType},get children(){var o=pe();return l(o,()=>t.data.mediaType),o}})},get children(){var o=ce(),u=o.firstChild;return l(o,(()=>{var c=x(()=>!!t.data.mediaType);return()=>c()?`${t.data.mediaType} \xB7 `:""})(),u),o}}),null),n}})}function ke(e){const a=M(),r=t=>{var i;t.stopPropagation(),(i=a.onRemove)==null||i.call(a)};return d(f,{get when(){return a.onRemove},get children(){return d(S,{get"aria-label"(){return e.label??"Remove"},get class(){return g(a.variant==="grid"&&["absolute top-2 right-2 size-6 rounded-full p-0","bg-background/80 backdrop-blur-sm","opacity-0 transition-opacity group-hover:opacity-100","hover:bg-background","[&>svg]:size-3"],a.variant==="inline"&&["size-5 rounded p-0","opacity-0 transition-opacity group-hover:opacity-100","[&>svg]:size-2.5"],a.variant==="list"&&["size-8 shrink-0 rounded p-0","[&>svg]:size-4"],e.class)},onClick:r,type:"button",variant:"ghost",get children(){return[x(()=>e.children??d(O,{})),(()=>{var t=E();return l(t,()=>e.label??"Remove"),t})()]}})}})}function xe(e){return d(U,{get openDelay(){return e.openDelay??0},get closeDelay(){return e.closeDelay??0},get children(){return e.children}})}function we(e){return d(V,{get class(){return e.class},get children(){return e.children}})}function ze(e){return d(G,{get class(){return g("w-auto p-2",e.class)},get children(){return e.children}})}function Ce(e){const[a,r]=b(e,["class","children"]);return(()=>{var t=T();return h(t,m({get class(){return g("flex items-center justify-center p-4 text-muted-foreground text-sm",a.class)}},r),!1,!0),l(t,()=>a.children??"No attachments"),t})()}export{fe as A,$ as D,A as U,ve as a,xe as b,we as c,ye as d,be as e,ze as f,F as g,z as h,ke as i,Ce as j,H as n,P as r};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{g as C,j as L,h as N,k as gt,i as P,c as M,a as q,d as w,b as S,l as z,I as B,n as O,t as T,u as X,p as ft,q as I,M as H,S as mt,m as vt,r as pt,f as bt}from"./define-CGGX-7Vg.js";import{c as D}from"./cn-DN5AWfiS.js";const yt=-100,xt=-10;function kt(t){if(t===-1/0)return 0;const e=Math.max(yt,Math.min(xt,t));return Math.sqrt(1-e*-1/100)}function Mt(t,e,n,r){const i=t.slice(Math.max(0,n),Math.max(0,r)),a=i.length,c=[];for(let s=0;s<e;s++){const l=Math.floor(s*a/e),h=Math.floor((s+1)*a/e);if(h<=l){c.push(0);continue}let b=0;for(let d=l;d<h;d++)b+=kt(i[d]);c.push(b/(h-l))}return c}function At(t){if(t.length===0)return 0;let e=0;for(let n=0;n<t.length;n++){const r=t[n];e+=r*r}return Math.sqrt(e/t.length)/255}function U(t,e){if(t.length===e)return t;if(t.length>e)return t.slice(0,e);const n=t[t.length-1]??0;return[...t,...new Array(e-t.length).fill(n)]}function wt(t,e){const n=(e-1)/2,r=new Array(e);for(let i=0;i<e;i++){const a=Math.floor(Math.abs(i-n));r[i]=t[Math.min(a,t.length-1)]??0}return r}function zt(t,e){const n=new Array(e);for(let r=0;r<e;r++){const i=Math.min(r,e-r);n[r]=t[Math.min(i,t.length-1)]??0}return n}const Ct={bands:5,loPass:100,hiPass:200,updateInterval:32},Z={fftSize:2048,smoothingTimeConstant:.8},R={fftSize:512,smoothingTimeConstant:.55,minDecibels:-100,maxDecibels:-80};function _(t){return typeof t=="function"?t():t}let Y;function $t(){if(!(typeof AudioContext>"u"))return Y??(Y=new AudioContext),Y}const tt=new WeakMap,et=new WeakMap;function qt(t){return"tagName"in t}function Ft(t){if(t.state!=="suspended")return()=>{};if(typeof document>"u")return()=>{};const e=()=>{t.resume().catch(()=>{})},n=["pointerdown","keydown","touchstart"];return n.forEach(r=>document.addEventListener(r,e,{once:!0,passive:!0})),()=>n.forEach(r=>document.removeEventListener(r,e))}function Dt(t,e={}){const n={...Ct,...e},[r,i]=C(new Array(_(n.bands)).fill(0)),[a,c]=C(0);return L(()=>{const s=t(),l=_(n.bands);if(i(new Array(l).fill(0)),c(0),!s)return;const h=$t();if(!h||typeof requestAnimationFrame>"u"||typeof cancelAnimationFrame>"u")return;const b=cancelAnimationFrame.bind(globalThis),d=Ft(h);let o;if(qt(s)){const v=s;let x=tt.get(v);x||(x=h.createMediaElementSource(v),x.connect(h.destination),tt.set(v,x)),o=x}else{let v=et.get(s);v||(v=h.createMediaStreamSource(s),et.set(s,v)),o=v}const u=h.createAnalyser();u.fftSize=Z.fftSize,u.smoothingTimeConstant=Z.smoothingTimeConstant;const m=h.createAnalyser();m.fftSize=R.fftSize,m.smoothingTimeConstant=R.smoothingTimeConstant,m.minDecibels=R.minDecibels,m.maxDecibels=R.maxDecibels,o.connect(u),o.connect(m);const k=new Float32Array(u.frequencyBinCount),p=new Uint8Array(m.frequencyBinCount);let g=0,f=0;const y=v=>{v-f>=n.updateInterval&&(u.getFloatFrequencyData(k),m.getByteFrequencyData(p),i(Mt(k,l,n.loPass,n.hiPass)),c(At(p)),f=v),g=requestAnimationFrame(y)};g=requestAnimationFrame(y),N(()=>{b(g),d(),u.disconnect(),m.disconnect(),o.disconnect(u),o.disconnect(m)})}),{bands:r,volume:a}}const Et=["idle","connecting","listening","thinking","speaking","disconnected"],Nt={failed:"disconnected",initializing:"connecting","pre-connect-buffering":"connecting"};function St(t){return t?Et.includes(t)?t:Nt[t]??"idle":"idle"}function Tt(t,e){switch(t){case"connecting":{const n=[];for(let r=0;r<e;r++)n.push([r,e-1-r]);return n.length?n:[[]]}case"listening":case"thinking":return[[Math.floor(e/2)],[-1]];case"speaking":return[Array.from({length:e},(n,r)=>r)];case"disconnected":return[[]];default:return[[]]}}function It(t,e){switch(t){case"connecting":return 2e3/Math.max(1,e);case"listening":return 500;case"thinking":return 150;default:return 1e3}}function Wt(t,e,n){const r=[],i=Math.floor(e/2),a=Math.floor(t/2),c={x:Math.max(0,i-n),y:Math.max(0,a-n)},s={x:Math.min(e-1,i+n),y:Math.min(t-1,a+n)};for(let l=c.x;l<=s.x;l++)r.push({x:l,y:c.y});for(let l=c.y+1;l<=s.y;l++)r.push({x:s.x,y:l});for(let l=s.x-1;l>=c.x;l--)r.push({x:l,y:s.y});for(let l=s.y-1;l>c.y;l--)r.push({x:c.x,y:l});return r}function Lt(t,e,n,r){const i={x:Math.floor(n/2),y:Math.floor(e/2)};switch(t){case"connecting":{const a=Math.floor(Math.max(e,n)/2),c=r!==void 0?Math.min(r,a):a,s=Wt(e,n,c);return s.length?s:[i]}case"listening":{const a={x:-1,y:-1};return[i,a,a,a,a,a,a,a,a]}case"thinking":{const a=Math.floor(e/2),c=[];for(let s=0;s<n;s++)c.push({x:s,y:a});for(let s=n-1;s>=0;s--)c.push({x:s,y:a});return c.length?c:[i]}case"disconnected":return[i];default:return[i]}}function nt(t,e){const n=(r,i)=>{for(;i!==0;){const a=i;i=r%i,r=a}return r};for(let r=e;r>=1;r--)if(n(t,r)===r)return r;return 1}function Pt(t){const e=t>8?t/nt(t,4):nt(t,2),n=Math.max(1,Math.floor(e)),r=Math.floor(t/n);return Array.from({length:n},(i,a)=>Array.from({length:r},(c,s)=>s*n+a))}function Vt(t,e){switch(t){case"connecting":{const n=Math.floor(e/2),r=[];for(let i=0;i<e;i++)r.push([i,(i+n)%e]);return r.length?r:[[]]}case"listening":case"thinking":{const n=Pt(e);return n.length?n:[[]]}case"speaking":return[Array.from({length:e},(n,r)=>r)];case"disconnected":return[[]];default:return[[]]}}function Ot(t){switch(t){case"connecting":case"listening":return 500;case"thinking":return 1/0;default:return 1e3}}function Rt(t){switch(t){case"listening":return{intensity:[.5,.8],speed:2.5};case"thinking":return{intensity:[.25,.5],speed:4};case"connecting":return{intensity:[.25,.5],speed:6};case"speaking":return{intensity:.3,speed:2.5};case"disconnected":return{intensity:.3,speed:.5};default:return{intensity:.3,speed:1}}}const V=5,G=.025,J=10;function jt(t){switch(t){case"listening":return{speed:V,amplitude:G,frequency:J,opacity:[1,.3],pulseDuration:.75};case"thinking":case"connecting":return{speed:V*4,amplitude:G/4,frequency:J*4,opacity:[1,.3],pulseDuration:.4};case"speaking":case"idle":return{speed:V*2,amplitude:G,frequency:J,opacity:1,pulseDuration:0};case"disconnected":return{speed:V,amplitude:0,frequency:0,opacity:1,pulseDuration:0};default:return{speed:V,amplitude:0,frequency:0,opacity:1,pulseDuration:0}}}function K(t){const[e,n]=C(0),r=gt(()=>t());return L(()=>{const i=r();if(n(0),!Number.isFinite(i)||i<=0||typeof requestAnimationFrame>"u"||typeof cancelAnimationFrame>"u")return;const a=cancelAnimationFrame.bind(globalThis);let c=0,s=performance.now();const l=h=>{h-s>=i&&(n(b=>b+1),s=h),c=requestAnimationFrame(l)};c=requestAnimationFrame(l),N(()=>a(c))}),e}const Q={icon:24,sm:56,md:112,lg:224,xl:448},Bt={icon:2,sm:4,md:8,lg:16,xl:32},rt={icon:4,sm:8,md:16,lg:32,xl:64},it={icon:2,sm:4,md:8,lg:12,xl:16},Ht={icon:2,sm:4,md:8,lg:12,xl:16},Ut={icon:6,sm:16,md:32,lg:64,xl:128};function at(t){return t==="icon"||t==="sm"?3:5}function ot(t){return t==="icon"||t==="sm"?12:24}function st(t){return t==="icon"?3:5}var lt=T("<div>");function j(t,e){return e===!0&&t==="listening"?"speaking":t}function ut(t){const e=()=>t.barCount??at(t.size),n=()=>j(t.state,t.listeningAmplitude),r=K(()=>t.frozen?1/0:It(n(),e())),i=()=>Tt(n(),e()),a=()=>i()[r()%i().length]??[],c=()=>n()==="speaking"?U(t.bands,e()):new Array(e()).fill(0);return(()=>{var s=lt();return P(s,M(B,{get each(){return c()},children:(l,h)=>{var b;const d={index:h,highlighted:()=>a().includes(h),value:()=>l()};return((b=t.children)==null?void 0:b.call(t,d))??(()=>{var o=lt();return q(u=>{var m=d.highlighted()?"bar highlighted":"bar",k=d.index,p=d.highlighted(),g=D("rounded-full bg-current/10","data-[kai-highlighted=true]:bg-current"),f=`${rt[t.size]}px`,y=`${rt[t.size]}px`,v=`${l()*100}%`,x=t.frozen?"none":"height 100ms ease-linear, background-color 250ms ease-linear";return m!==u.e&&w(o,"part",u.e=m),k!==u.t&&w(o,"data-kai-index",u.t=k),p!==u.a&&w(o,"data-kai-highlighted",u.a=p),g!==u.o&&S(o,u.o=g),f!==u.i&&z(o,"width",u.i=f),y!==u.n&&z(o,"min-height",u.n=y),v!==u.s&&z(o,"height",u.s=v),x!==u.h&&z(o,"transition",u.h=x),u},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0}),o})()}})),q(l=>{var h=t.state,b=D("relative flex items-center justify-center",t.class),d={height:`${Q[t.size]}px`,gap:`${Bt[t.size]}px`,...t.color?{color:t.color}:{}};return h!==l.e&&w(s,"data-kai-state",l.e=h),b!==l.t&&S(s,l.t=b),l.a=O(s,d,l.a),l},{e:void 0,t:void 0,a:void 0}),s})()}function Yt(t,e){return t===void 0||e===void 0||!Number.isFinite(t)||!Number.isFinite(e)||t<=0||e<=0?1:Math.min(1,t/e)}function Gt(){const[t,e]=C(),[n,r]=C(),[i,a]=C();let c,s,l;const h=()=>{if(l)return l;if(!(typeof ResizeObserver>"u"))return l=new ResizeObserver(d=>{for(const o of d)o.target===c&&e(o.contentRect.width),o.target===s&&(r(o.contentRect.width),a(o.contentRect.height))}),l};N(()=>l?.disconnect());const b=()=>Yt(t(),n());return{observeOuter:d=>{var o;c=d,(o=h())==null||o.observe(d)},observeInner:d=>{var o;s=d,(o=h())==null||o.observe(d)},scale:b,scaledHeight:()=>{const d=b(),o=i();return d<1&&o!==void 0&&o>0?o*d:void 0}}}var ct=T("<div>");const Jt=.65,Kt=.02;function Qt(t){const e=()=>t.count??st(t.size),n=()=>e(),r=()=>t.interval??100,i=()=>Array.from({length:e()*n()},(o,u)=>u),a=()=>j(t.state,t.listeningAmplitude),c=K(()=>t.frozen||a()==="speaking"?1/0:r()),s=()=>Lt(a(),e(),n(),t.spread),l=()=>s()[c()%s().length]??{x:-1,y:-1},h=()=>a()==="speaking"?U(t.bands,n()):new Array(n()).fill(0);function b(o){if(a()==="speaking"){const u=Math.floor(o/n()),m=Math.floor(e()/2),k=Math.abs(m-u)/(m+1)*Jt,p=Math.max(k,Kt);return(h()[o%n()]??0)>=p}return a()==="idle"||a()==="disconnected"?!1:l().x===o%n()&&l().y===Math.floor(o/n())}function d(o){return a()==="speaking"?"150ms":`${r()/(b(o)?1e3:100)}s`}return(()=>{var o=ct();return P(o,M(B,{get each(){return i()},children:(u,m)=>{var k;const p={index:m,highlighted:()=>b(m),value:()=>h()[m%n()]??0};return((k=t.children)==null?void 0:k.call(t,p))??(()=>{var g=ct();return q(f=>{var y=p.highlighted()?"cell highlighted":"cell",v=p.index,x=p.highlighted(),A=D("place-self-center rounded-full bg-current/10 transition-all ease-out","data-[kai-highlighted=true]:bg-current"),$=`${it[t.size]}px`,F=`${it[t.size]}px`,W=d(m);return y!==f.e&&w(g,"part",f.e=y),v!==f.t&&w(g,"data-kai-index",f.t=v),x!==f.a&&w(g,"data-kai-highlighted",f.a=x),A!==f.o&&S(g,f.o=A),$!==f.i&&z(g,"width",f.i=$),F!==f.n&&z(g,"height",f.n=F),W!==f.s&&z(g,"transition-duration",f.s=W),f},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0}),g})()}})),q(u=>{var m=t.state,k=D("grid",t.class),p={"grid-template-columns":`repeat(${n()}, 1fr)`,gap:`${Ht[t.size]}px`,...t.color?{color:t.color}:{}};return m!==u.e&&w(o,"data-kai-state",u.e=m),k!==u.t&&S(o,u.t=k),u.a=O(o,p,u.a),u},{e:void 0,t:void 0,a:void 0}),o})()}var Xt=T("<div style=aspect-ratio:1>"),Zt=T('<div data-kai-spoke class="absolute top-1/2 left-1/2 h-1 w-1 -translate-x-1/2 -translate-y-1/2"style=transform-origin:center>'),_t=T("<div>");function te(t){const e=()=>Math.max(1,t.barCount??ot(t.size)),n=()=>t.radius??Ut[t.size];e()%4!==0&&console.warn(`<kai-audio-visualizer variant="radial">: barCount ${e()} is not divisible by 4. The ring will look asymmetric.`);const r=()=>n()*Math.PI/e(),i=()=>j(t.state,t.listeningAmplitude),a=K(()=>t.frozen?1/0:Ot(i())),c=()=>Vt(i(),e()),s=()=>i()==="thinking"?Array.from({length:e()},(b,d)=>d):c()[a()%c().length]??[],l=()=>i()==="speaking"?U(t.bands,e()):new Array(e()).fill(0),h=()=>i()==="thinking"&&!t.frozen;return(()=>{var b=Xt();return P(b,M(B,{get each(){return l()},children:(d,o)=>{const u={index:o,highlighted:()=>s().includes(o),value:()=>d()};return(()=>{var m=Zt();return P(m,()=>{var k;return((k=t.children)==null?void 0:k.call(t,u))??(()=>{var p=_t();return q(g=>{var f=u.highlighted()?"bar highlighted":"bar",y=u.index,v=u.highlighted(),x=D("origin-bottom rounded-full bg-current/10","data-[kai-highlighted=true]:bg-current"),A=`${r()}px`,$=`${r()}px`,F=`${r()*10*d()}px`,W=t.frozen?"none":"height 100ms ease-linear, background-color 150ms ease-linear";return f!==g.e&&w(p,"part",g.e=f),y!==g.t&&w(p,"data-kai-index",g.t=y),v!==g.a&&w(p,"data-kai-highlighted",g.a=v),x!==g.o&&S(p,g.o=x),A!==g.i&&z(p,"width",g.i=A),$!==g.n&&z(p,"min-height",g.n=$),F!==g.s&&z(p,"height",g.s=F),W!==g.h&&z(p,"transition",g.h=W),g},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0}),p})()}),q(k=>z(m,"transform",`rotate(${o/e()*Math.PI*2}rad) translateY(${n()}px)`)),m})()}})),q(d=>{var o=t.state,u=D("relative flex items-center justify-center",h()&&"animate-spin",t.class),m={height:`${Q[t.size]}px`,...h()?{"animation-duration":"5s"}:{},...t.color?{color:t.color}:{}};return o!==d.e&&w(b,"data-kai-state",d.e=o),u!==d.t&&S(b,d.t=u),d.a=O(b,m,d.a),d},{e:void 0,t:void 0,a:void 0}),b})()}var ee=T('<div><div style="flex:0 0 auto;align-self:flex-start">');const ne=["bar","grid","radial","wave","aurora","custom"],re={aura:"aurora"};function ie(t){return t?ne.includes(t)?t:re[t]??"bar":"bar"}function ae(){const[t,e]=C(!1);return L(()=>{var n;if(typeof matchMedia!="function")return;const r=matchMedia("(prefers-reduced-motion: reduce)");e(r.matches);const i=a=>e(a.matches);(n=r.addEventListener)==null||n.call(r,"change",i),N(()=>{var a;return(a=r.removeEventListener)==null?void 0:a.call(r,"change",i)})}),t}function oe(t){const[e,n]=C(!1);return L(()=>{var r;if(typeof matchMedia!="function")return;const i=matchMedia("(prefers-color-scheme: dark)");n(i.matches);const a=c=>n(c.matches);(r=i.addEventListener)==null||r.call(i,"change",a),N(()=>{var c;return(c=i.removeEventListener)==null?void 0:c.call(i,"change",a)})}),()=>{const r=t()??"auto";return r==="dark"||r==="auto"&&e()}}const dt={wave:()=>import("./variant-wave-DYyzIIZv.js"),aurora:()=>import("./variant-aurora-xiMPty8f.js"),custom:()=>import("./variant-custom-D91HjAKz.js")};function se(t){const e=()=>ie(t.variant),n=()=>t.size??"md",r=()=>St(t.state),i=ae(),a=oe(()=>t.theme),c=()=>e()in dt,s=()=>e()==="grid"?t.count??st(n()):e()==="radial"?t.barCount??ot(n()):t.barCount??at(n()),l=Dt(()=>t.bands?void 0:t.stream??t.audioElement,{bands:()=>Math.ceil(s()/2)}),h=()=>t.bands?t.bands:e()==="radial"?zt(l.bands(),s()):wt(l.bands(),s()),b=()=>{if(!t.bands)return l.volume();if(t.bands.length===0)return 0;let y=0;for(const v of t.bands)y+=v*v;return Math.sqrt(y/t.bands.length)},[d,o]=C(),[u,m]=C(!1);L(()=>{const y=e(),v=dt[y];if(o(void 0),m(!1),!v)return;let x=!1;v().then(A=>{x||o(()=>A.default)}).catch(A=>{x||console.warn(`<kai-audio-visualizer variant="${y}">: failed to load the shader chunk, falling back to bars.`,A)}),N(()=>{x=!0})});const k=()=>({state:r(),size:n(),frozen:i(),color:t.color,listeningAmplitude:t.listeningAmplitude}),p=()=>({...k(),children:t.children}),g=()=>t.label?{role:"img","aria-label":t.label}:{"aria-hidden":"true"},f=Gt();return(()=>{var y=ee(),v=y.firstChild,x=f.observeOuter;typeof x=="function"?X(x,y):f.observeOuter=y,ft(y,I({get class(){return D("inline-flex",t.class)}},g,{get style(){return{"max-width":"100%",...f.scaledHeight()!==void 0?{height:`${f.scaledHeight()}px`,overflow:"hidden","vertical-align":"top"}:{}}}}),!1,!0);var A=f.observeInner;return typeof A=="function"?X(A,v):f.observeInner=v,P(v,M(pt,{get fallback(){return M(ut,I(p,{get bands(){return h()},get barCount(){return t.barCount}}))},get children(){return[M(H,{get when(){return e()==="grid"},get children(){return M(Qt,I(p,{get bands(){return h()},get count(){return t.count},get spread(){return t.spread},get interval(){return t.interval}}))}}),M(H,{get when(){return e()==="radial"},get children(){return M(te,I(p,{get bands(){return h()},get barCount(){return t.barCount},get radius(){return t.radius}}))}}),M(H,{get when(){return c()},get children(){return M(mt,{get when(){return vt(()=>!u())()&&d()},get fallback(){return M(ut,I(p,{get bands(){return h()},get barCount(){return t.barCount}}))},children:$=>{const F=$();return M(F,I(k,{get bands(){return h()},get volume(){return b()},get complexity(){return t.complexity},get shader(){return t.shader},get dark(){return a()},get animateWhenNotVisible(){return t.animateWhenNotVisible},onUnavailable:()=>m(!0)}))}})}})]}})),q($=>O(v,{...f.scale()<1?{transform:`scale(${f.scale()})`,"transform-origin":"top left"}:{}},$)),y})()}function E(t){if(t==null||t==="")return;const e=Number(t);return Number.isFinite(e)?e:void 0}function ht(t,e){var n,r;const i=((n=e?.dark)==null?void 0:n.call(e))??!1,a=e!=null&&e.flag?e.flag("animateWhenNotVisible"):t.animateWhenNotVisible===!0,c=e!=null&&e.flag?e.flag("listeningAmplitude"):t.listeningAmplitude===!0;return(r=e?.reflectFlag)==null||r.call(e,"listeningAmplitude"),M(se,{get variant(){return t.variant},get state(){return t.state},get size(){return t.size},get barCount(){return E(t.barCount)},get count(){return E(t.count)},get radius(){return E(t.radius)},get spread(){return E(t.spread)},get interval(){return E(t.interval)},get color(){return t.color},get complexity(){return E(t.complexity)},get label(){return t.label},get stream(){return t.stream},get audioElement(){return t.audioElement},get bands(){return t.bands},listeningAmplitude:c,get shader(){return t.shader},animateWhenNotVisible:a,theme:i?"dark":"light"})}bt("kai-audio-visualizer",{variant:"bar",state:"idle",size:"md",barCount:void 0,count:void 0,radius:void 0,spread:void 0,interval:void 0,color:void 0,complexity:void 0,label:void 0,stream:void 0,audioElement:void 0,bands:void 0,listeningAmplitude:void 0,shader:void 0,animateWhenNotVisible:void 0},ht);export{ht as A,Q as C,j as a,E as n,Rt as s,jt as w};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{s as n,p as i,q as s,i as o,t as u}from"./define-CGGX-7Vg.js";import{c as m}from"./index-xu_pdcPi.js";import{c}from"./cn-DN5AWfiS.js";var d=u("<span>");const p=m("inline-flex items-center justify-center rounded-full text-xs font-medium min-h-5 min-w-5",{variants:{variant:{default:"bg-muted text-muted-foreground px-2 py-0.5",count:"bg-muted text-muted-foreground h-5 px-1.5",citation:"bg-primary text-primary-foreground px-1.5 py-0.5 cursor-pointer"}},defaultVariants:{variant:"default"}});function f(a){const[t,e]=n(a,["variant","class","children"]);return(()=>{var r=d();return i(r,s({get class(){return c(p({variant:t.variant}),t.class)}},e),!1,!0),o(r,()=>t.children),r})()}export{f as B};
|