@kitn.ai/ui 0.20.1 → 0.21.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 +44 -45
- package/dist/components/artifact-card.d.ts +51 -0
- package/dist/components/artifact.d.ts +1 -1
- package/dist/components/attachments.d.ts +2 -2
- package/dist/components/audio-visualizer/index.d.ts +3 -3
- package/dist/components/audio-visualizer/labs/lab-choreography.d.ts +59 -0
- package/dist/components/audio-visualizer/labs/lab-shaders.d.ts +22 -0
- package/dist/components/audio-visualizer/labs/lab-visualizer.d.ts +18 -0
- package/dist/components/audio-visualizer/variant-aurora.d.ts +2 -2
- package/dist/components/audio-visualizer/variant-bar.d.ts +2 -2
- package/dist/components/audio-visualizer/variant-custom.d.ts +2 -2
- package/dist/components/audio-visualizer/variant-grid.d.ts +1 -1
- package/dist/components/audio-visualizer/variant-radial.d.ts +1 -1
- package/dist/components/audio-visualizer/variant-wave.d.ts +1 -1
- package/dist/components/card-fallback.d.ts +12 -2
- package/dist/components/card-renderer.d.ts +63 -2
- package/dist/components/chat-container.d.ts +3 -0
- package/dist/components/chat-scope-picker.d.ts +2 -2
- package/dist/components/chat-thread.d.ts +68 -18
- package/dist/components/choice-card.d.ts +3 -28
- package/dist/components/composer-dom.d.ts +1 -1
- package/dist/components/composer-highlight.d.ts +1 -1
- package/dist/components/composer-history.d.ts +1 -1
- package/dist/components/composer.d.ts +1 -1
- package/dist/components/confirm-card.d.ts +3 -18
- package/dist/components/context.d.ts +8 -4
- package/dist/components/conversation-item.d.ts +1 -1
- package/dist/components/conversation-list.d.ts +4 -3
- package/dist/components/embed.d.ts +3 -3
- package/dist/components/file-tree.d.ts +11 -22
- package/dist/components/form-widgets.d.ts +1 -1
- package/dist/components/form.d.ts +3 -44
- package/dist/components/link-preview.d.ts +3 -3
- package/dist/components/loader.d.ts +30 -48
- package/dist/components/message-skills.d.ts +4 -0
- package/dist/components/message.d.ts +84 -21
- package/dist/components/model-switcher.d.ts +2 -2
- package/dist/components/prompt-input.d.ts +2 -2
- package/dist/components/response-compare-types.d.ts +11 -2
- package/dist/components/response-compare.d.ts +3 -3
- package/dist/components/source.d.ts +12 -3
- package/dist/components/tasks-card.d.ts +3 -31
- package/dist/components/thread.d.ts +17 -5
- package/dist/components/toast.d.ts +2 -2
- package/dist/components/tool-classify.d.ts +8 -0
- package/dist/components/tool-types.d.ts +29 -1
- package/dist/components/tool.d.ts +3 -3
- package/dist/components/use-card-resolution.d.ts +1 -1
- package/dist/create-tween-D3Y5qiij.js +338 -0
- package/dist/create-tween-DGKY1FDY.js +341 -0
- package/dist/create-tween-paho5Rh-.js +7 -0
- package/dist/custom-elements.json +1681 -454
- 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/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-types.d.ts +70 -10
- package/dist/elements/chat-workspace.js +1 -1
- package/dist/elements/chat.js +1 -1
- package/dist/elements/checkpoint.js +1 -1
- package/dist/elements/choice.js +1 -1
- package/dist/elements/chunks/{Icon-Tj58ES_d.js → Icon-C-2LvGDG.js} +1 -1
- package/dist/elements/chunks/{action-icons-ns1Fnedj.js → action-icons-CaYoImEk.js} +1 -1
- package/dist/elements/chunks/arrow-left-Bb46H7w9.js +1 -0
- package/dist/elements/chunks/artifact-BBIscOxJ.js +1 -0
- package/dist/elements/chunks/{attachments-mCB5F1Fq.js → attachments-BB56zoji.js} +1 -1
- package/dist/elements/chunks/audio-visualizer-BxOx4THz.js +1 -0
- package/dist/elements/chunks/{badge-B4Zuajl2.js → badge-SxLSZ19R.js} +1 -1
- package/dist/elements/chunks/{button-ZWNif3--.js → button-CmkUkz6c.js} +1 -1
- package/dist/elements/chunks/card-renderer-Db4ffkWv.js +1 -0
- package/dist/elements/chunks/card-tags-D8lZ-C_U.js +1 -0
- package/dist/elements/chunks/chat-thread-B3Ks-cKr.js +1 -0
- package/dist/elements/chunks/check-C8desc_h.js +1 -0
- package/dist/elements/chunks/chevron-down-DKtc2HNB.js +1 -0
- package/dist/elements/chunks/chevron-right-Dw4GPhwL.js +1 -0
- package/dist/elements/chunks/choice-card-Q9cYYDyM.js +1 -0
- package/dist/elements/chunks/circle-BeokBsvB.js +1 -0
- package/dist/elements/chunks/circle-check-wJSqt859.js +1 -0
- package/dist/elements/chunks/{circle-x-B7faJFlY.js → circle-x-D0MEfxOM.js} +1 -1
- package/dist/elements/chunks/code-block-C8VzAraE.js +1 -0
- package/dist/elements/chunks/{collapsible-DM1Ckd4e.js → collapsible-Cvj61obE.js} +1 -1
- package/dist/elements/chunks/{composer-BguS0QL_.js → composer-D86ztyL0.js} +2 -2
- package/dist/elements/chunks/confirm-card-BdyDAGLw.js +1 -0
- package/dist/elements/chunks/context-WHDl-xSx.js +1 -0
- package/dist/elements/chunks/conversation-list-CdR14_Y4.js +1 -0
- package/dist/elements/chunks/create-tween-C_A_B638.js +7 -0
- package/dist/elements/chunks/{default-input-Cqqilg9t.js → default-input-CSZqUM81.js} +1 -1
- package/dist/elements/chunks/define-BzPnNsXg.js +1 -0
- package/dist/elements/chunks/{disclosure-CIZ5c8nO.js → disclosure-DVKsoc1F.js} +1 -1
- package/dist/elements/chunks/{download-Dsbg3ste.js → download-BjA54IMJ.js} +1 -1
- package/dist/elements/chunks/{dropdown-BDd1-Zgi.js → dropdown-BjVVHWXH.js} +1 -1
- package/dist/elements/chunks/{ellipsis-Dw6qrss-.js → ellipsis-BNedmqfi.js} +1 -1
- package/dist/elements/chunks/embed-DQsl4XEq.js +1 -0
- package/dist/elements/chunks/{external-link-Vt74zAoL.js → external-link-Di-dw2CU.js} +1 -1
- package/dist/elements/chunks/{file-text-CZrZF6_v.js → file-text-B3sAODCV.js} +1 -1
- package/dist/elements/chunks/{file-tree-DF4okKyo.js → file-tree-Dgto-bMn.js} +1 -1
- package/dist/elements/chunks/{folder-glP5rha4.js → folder-D6rMadFV.js} +1 -1
- package/dist/elements/chunks/form-CILxvhQ7.js +1 -0
- package/dist/elements/chunks/hover-card-BtiF4XiU.js +1 -0
- package/dist/elements/chunks/{icon-BLb8beoi.js → icon-DKkmze3y.js} +1 -1
- package/dist/elements/chunks/{info-CIsv92JK.js → info-CWRjZkuy.js} +1 -1
- package/dist/elements/chunks/{input-Dds1kFyt.js → input--QJBK6BA.js} +1 -1
- package/dist/elements/chunks/{kbd-De_xbgi9.js → kbd-C3zuKh8R.js} +1 -1
- package/dist/elements/chunks/{link-i4r_k7z4.js → link-BL5JA7Q0.js} +1 -1
- package/dist/elements/chunks/link-preview-CU37bbXh.js +1 -0
- package/dist/elements/chunks/{loader-BmQH4s3V.js → loader-XmpyxyRH.js} +1 -1
- package/dist/elements/chunks/{markdown-Zi21WhUz.js → markdown-3Gv5UZ_o.js} +1 -1
- package/dist/elements/chunks/message-CnBA2OUt.js +1 -0
- package/dist/elements/chunks/message-X5NZbq-W.js +1 -0
- package/dist/elements/chunks/message-square-CnpAm_P0.js +1 -0
- package/dist/elements/chunks/{minimize-2--ifeCGrl.js → minimize-2-DwyrUTcM.js} +1 -1
- package/dist/elements/chunks/{model-switcher-B94YAKsM.js → model-switcher-CclaJEHt.js} +1 -1
- package/dist/elements/chunks/{overlay-kD8dwRv_.js → overlay-Cepd-KcS.js} +1 -1
- package/dist/elements/chunks/{paperclip-q21dYOSK.js → paperclip-CdwKjrlu.js} +1 -1
- package/dist/elements/chunks/{progress-bar-BrAIIaaJ.js → progress-bar-DMVXBD3b.js} +1 -1
- package/dist/elements/chunks/{prompt-suggestion-Bjn2K-fR.js → prompt-suggestion-Di_WZE_5.js} +1 -1
- package/dist/elements/chunks/reasoning-D0jMch5u.js +1 -0
- package/dist/elements/chunks/{resizable-Dp4JExql.js → resizable-1znbL1Gv.js} +1 -1
- package/dist/elements/chunks/{rotate-cw-CFWWkpj2.js → rotate-cw-DVhhgx8n.js} +1 -1
- package/dist/elements/chunks/{scroll-area-Bb0kHH1j.js → scroll-area-Bs4bFS1P.js} +1 -1
- package/dist/elements/chunks/scroll-button-Bet5NLc4.js +1 -0
- package/dist/elements/chunks/{separator-9kRgr1X9.js → separator-C5Gh8qGC.js} +1 -1
- package/dist/elements/chunks/{settings-B8lmec4D.js → settings-5vmEFg0K.js} +1 -1
- package/dist/elements/chunks/{settings-group-I0hEuXiN.js → settings-group-BWLB38kz.js} +1 -1
- package/dist/elements/chunks/{share-C3lTiYGt.js → share-BZ3G_DaB.js} +1 -1
- package/dist/elements/chunks/skeleton-DafPJQTp.js +1 -0
- package/dist/elements/chunks/slots-CIw9RlAe.js +1 -0
- package/dist/elements/chunks/source-D_qj_6uJ.js +1 -0
- package/dist/elements/chunks/{star-CSJtGxgv.js → star-Cuv7j2IE.js} +1 -1
- package/dist/elements/chunks/{store-CHyW95TP.js → store-C1StPHfW.js} +1 -1
- package/dist/elements/chunks/tasks-card-EyoBZfpA.js +1 -0
- package/dist/elements/chunks/{text-shimmer-Cn9TmNpI.js → text-shimmer-D9gRSh34.js} +1 -1
- package/dist/elements/chunks/textarea-DuhtHfcm.js +1 -0
- package/dist/elements/chunks/{thumbs-up-PNVVThEF.js → thumbs-up-B9hwv43w.js} +1 -1
- package/dist/elements/chunks/{toast-store-DKbQn3Wn.js → toast-store-Bm3DUEDe.js} +1 -1
- package/dist/elements/chunks/{tool-DjTRpIpl.js → tool-CDtW7L0z.js} +1 -1
- package/dist/elements/chunks/tooltip-eB226mGK.js +1 -0
- package/dist/elements/chunks/{triangle-alert-DsHTHCPm.js → triangle-alert-C1SNzTqK.js} +1 -1
- package/dist/elements/chunks/use-card-resolution-YZh2MvI5.js +1 -0
- package/dist/elements/chunks/{variant-aurora-Dc4nQUia.js → variant-aurora-Cj1F7D0l.js} +2 -2
- package/dist/elements/chunks/{variant-custom-y_3kVQhS.js → variant-custom-T9gpt7QE.js} +1 -1
- package/dist/elements/chunks/{variant-wave-D5OR1-9Z.js → variant-wave-CxU9z-TE.js} +2 -2
- package/dist/elements/chunks/{video-B7vmenoC.js → video-CK4R7Rus.js} +1 -1
- package/dist/elements/chunks/x-D1qx0aLd.js +1 -0
- 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-list.js +1 -1
- package/dist/elements/default-input.d.ts +7 -7
- package/dist/elements/define.d.ts +1 -0
- package/dist/elements/dialog.js +1 -1
- package/dist/elements/disclosure.d.ts +1 -1
- package/dist/elements/editable-label.js +1 -1
- package/dist/elements/element-data-types.d.ts +107 -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-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/reasoning.js +1 -1
- package/dist/elements/register.d.ts +8 -6
- package/dist/elements/remote.js +1 -1
- package/dist/elements/resizable.js +1 -1
- package/dist/elements/response-stream.js +2 -2
- 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/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/slots.d.ts +16 -0
- 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/validate-messages.d.ts +25 -0
- package/dist/elements/voice-input.js +1 -1
- package/dist/elements/voice-output.js +1 -1
- package/dist/elements.d.ts +2725 -214
- package/dist/index.d.ts +163 -125
- package/dist/index.js +6336 -5802
- package/dist/index.server.d.ts +5 -0
- package/dist/index.server.js +5446 -4937
- package/dist/kai-provider.es.d.ts +5 -0
- package/dist/kai-provider.es.js +79 -77
- package/dist/kai.es.d.ts +5 -0
- package/dist/kai.es.js +1 -1
- package/dist/llms/llms-full.txt +762 -148
- package/dist/llms/llms.txt +57 -5
- package/dist/mcp.es.js +4010 -770
- package/dist/primitives/card-component-types.d.ts +11 -0
- package/dist/primitives/card-data-types.d.ts +196 -0
- package/dist/primitives/card-host.d.ts +1 -1
- package/dist/primitives/card-recovery.d.ts +3 -3
- package/dist/primitives/card-registry.d.ts +4 -14
- package/dist/primitives/card-resolution.d.ts +1 -1
- package/dist/primitives/card-routing.d.ts +1 -1
- package/dist/primitives/card-tags.d.ts +11 -0
- package/dist/primitives/card-validate-cards.d.ts +57 -0
- package/dist/primitives/card-validate-generator.testlib.d.ts +20 -0
- package/dist/primitives/card-validate-schemas.d.ts +17 -0
- package/dist/primitives/card-validate.d.ts +24 -0
- package/dist/primitives/create-kai-chat.d.ts +3 -3
- package/dist/primitives/embed-providers.d.ts +1 -1
- package/dist/primitives/link-preview.d.ts +1 -1
- package/dist/primitives/message-feedback.d.ts +2 -2
- package/dist/primitives/toast-store.d.ts +1 -1
- package/dist/react/index.d.ts +717 -299
- package/dist/react/use-kai-chat.d.ts +8 -4
- package/dist/react.d.ts +5 -0
- package/dist/react.js +417 -316
- package/dist/register-impl-bzrZ44ft.js +145 -0
- package/dist/remote/host-embed.d.ts +1 -1
- package/dist/remote/index.d.ts +2 -2
- package/dist/remote/provider-runtime.d.ts +2 -2
- package/dist/remote/provider.d.ts +2 -2
- package/dist/remote/validate.d.ts +1 -1
- package/dist/remote/wire.d.ts +1 -1
- package/dist/schemas/artifact.schema.json +92 -0
- package/dist/schemas/embed.schema.json +0 -2
- package/dist/schemas/from-tool-call.d.ts +48 -0
- package/dist/schemas/index.d.ts +48 -0
- package/dist/schemas/link.schema.json +0 -2
- package/dist/schemas/provider-subsets.d.ts +136 -0
- package/dist/schemas/registry.d.ts +140 -0
- package/dist/schemas/tool-defs.d.ts +121 -0
- package/dist/schemas.d.ts +5 -0
- package/dist/schemas.js +717 -0
- package/dist/solid-BCJUQqwS.js +22750 -0
- package/dist/solid-BdENBcEq.js +20108 -0
- package/dist/solid.d.ts +66 -0
- package/dist/solid.js +261 -0
- package/dist/solid.server.d.ts +5 -0
- package/dist/solid.server.js +261 -0
- package/dist/state/index.d.ts +14 -4
- package/dist/state/messages.d.ts +8 -3
- package/dist/state/mock.d.ts +46 -0
- package/dist/state/parts.d.ts +85 -0
- package/dist/state/stream.d.ts +15 -9
- package/dist/state.d.ts +5 -0
- package/dist/state.js +253 -84
- package/dist/ui/action-icons.d.ts +1 -1
- package/dist/ui/collapsible.d.ts +11 -6
- package/dist/ui/dropdown.d.ts +47 -42
- package/dist/ui/pane-group.d.ts +1 -1
- package/dist/variant-aurora-1wMcXRUS.js +381 -0
- package/dist/variant-aurora-BKHHiOgL.js +391 -0
- package/dist/{variant-aurora-DVtGqVH6.js → variant-aurora-DOb_o4pC.js} +1 -1
- package/dist/{variant-custom-Dif-IV4u.js → variant-custom-CJGB0Kbw.js} +1 -1
- package/dist/variant-custom-Co0CkXJF.js +200 -0
- package/dist/variant-custom-DWSSgmd2.js +170 -0
- package/dist/variant-wave-C3-45cL6.js +218 -0
- package/dist/{variant-wave-DbfNdvSi.js → variant-wave-CEODq-9q.js} +1 -1
- package/dist/variant-wave-jdXBnCUZ.js +208 -0
- package/dist/wire/chunk.d.ts +171 -0
- package/dist/wire/consume.d.ts +26 -0
- package/dist/wire/encode.d.ts +148 -0
- package/dist/wire/formats/anthropic.d.ts +2 -0
- package/dist/wire/formats/openai.d.ts +5 -0
- package/dist/wire/index.d.ts +14 -0
- package/dist/wire/read.d.ts +26 -0
- package/dist/wire/sink-helpers.d.ts +21 -0
- package/dist/wire/sse.d.ts +33 -0
- package/dist/wire.d.ts +5 -53
- package/dist/wire.js +898 -0
- package/frameworks/react/index.tsx +183 -154
- package/frameworks/react/runtime.tsx +21 -1
- package/frameworks/react/use-kai-chat.tsx +11 -1
- package/llms-full.txt +762 -148
- package/llms.txt +57 -5
- package/package.json +61 -8
- package/src/agent-tooling/archetypes.ts +96 -0
- package/src/agent-tooling/integrations/anthropic.ts +412 -0
- package/src/agent-tooling/integrations/cloudflare.ts +136 -52
- package/src/agent-tooling/integrations/langgraph.ts +67 -13
- package/src/agent-tooling/integrations/mastra.ts +120 -12
- package/src/agent-tooling/integrations/mock.ts +43 -8
- package/src/agent-tooling/integrations/ollama.ts +61 -24
- package/src/agent-tooling/integrations/openai.ts +87 -0
- package/src/agent-tooling/integrations/openrouter.ts +56 -8
- package/src/agent-tooling/integrations/pi.ts +79 -23
- package/src/agent-tooling/integrations/pydantic-ai.ts +24 -2
- package/src/agent-tooling/integrations/vercel-ai-sdk.ts +84 -13
- package/src/agent-tooling/mcp/manifest.ts +206 -25
- package/src/agent-tooling/mcp/tools/debug.ts +13 -7
- package/src/agent-tooling/mcp/tools/reference.ts +285 -6
- package/src/agent-tooling/mcp/tools/scaffold.ts +3345 -675
- package/src/agent-tooling/registry.ts +17 -0
- package/src/agent-tooling/types.ts +229 -1
- package/src/components/artifact-card.tsx +120 -0
- package/src/components/audio-visualizer/index.tsx +9 -0
- package/src/components/audio-visualizer/labs/lab-choreography.ts +187 -0
- package/src/components/audio-visualizer/labs/lab-shaders.ts +363 -0
- package/src/components/audio-visualizer/labs/lab-visualizer.tsx +102 -0
- package/src/components/audio-visualizer/shader-canvas.tsx +31 -1
- package/src/components/card-fallback.tsx +42 -10
- package/src/components/card-renderer.tsx +146 -9
- package/src/components/chat-container.tsx +4 -0
- package/src/components/chat-thread.tsx +118 -51
- package/src/components/choice-card.tsx +17 -29
- package/src/components/composer.tsx +12 -2
- package/src/components/confirm-card.tsx +24 -20
- package/src/components/context.tsx +12 -4
- package/src/components/conversation-list.tsx +18 -2
- package/src/components/file-tree.tsx +11 -22
- package/src/components/file-upload.tsx +14 -8
- package/src/components/form.tsx +14 -47
- package/src/components/loader.tsx +39 -12
- package/src/components/message-skills.tsx +4 -0
- package/src/components/message.tsx +294 -46
- package/src/components/reasoning.tsx +92 -5
- package/src/components/response-compare-types.ts +25 -0
- package/src/components/response-compare.tsx +4 -9
- package/src/components/source.tsx +50 -24
- package/src/components/tasks-card.tsx +10 -33
- package/src/components/thread.tsx +84 -42
- package/src/components/toast.tsx +11 -5
- package/src/components/tool-classify.ts +26 -0
- package/src/components/tool-types.ts +31 -1
- package/src/elements/agent-card.tsx +11 -11
- package/src/elements/artifact.tsx +15 -7
- package/src/elements/attachments.tsx +6 -4
- package/src/elements/avatar.tsx +1 -1
- package/src/elements/button.tsx +3 -3
- package/src/elements/card.tsx +2 -2
- package/src/elements/cards.tsx +109 -14
- package/src/elements/chain-of-thought.tsx +14 -10
- package/src/elements/chat-scope-picker.tsx +9 -7
- package/src/elements/chat-types.ts +59 -6
- package/src/elements/chat-workspace.tsx +50 -9
- package/src/elements/chat.tsx +64 -3
- package/src/elements/choice.tsx +8 -8
- package/src/elements/coachmark.tsx +1 -1
- package/src/elements/command.tsx +8 -23
- package/src/elements/compare.tsx +7 -6
- package/src/elements/compiled.css +1 -1
- package/src/elements/composer.tsx +8 -8
- package/src/elements/confirm-card.tsx +9 -9
- package/src/elements/context-meter.tsx +4 -18
- package/src/elements/conversation-list.tsx +14 -9
- package/src/elements/default-input.tsx +3 -3
- package/src/elements/define.tsx +178 -43
- package/src/elements/editable-label.tsx +17 -2
- package/src/elements/element-data-types.ts +112 -0
- package/src/elements/element-meta.json +1596 -304
- package/src/elements/element-types.d.ts +2636 -211
- package/src/elements/feedback-bar.tsx +1 -1
- package/src/elements/file-tree.tsx +1 -1
- package/src/elements/file-upload.tsx +1 -1
- package/src/elements/form.tsx +14 -6
- package/src/elements/input.tsx +1 -1
- package/src/elements/kbd.tsx +1 -1
- package/src/elements/menu.tsx +10 -29
- package/src/elements/message-skills.tsx +7 -9
- package/src/elements/message.tsx +200 -32
- package/src/elements/model-switcher.tsx +5 -3
- package/src/elements/pane.tsx +1 -1
- package/src/elements/prompt-dock.tsx +8 -8
- package/src/elements/prompt-input.tsx +10 -10
- package/src/elements/prompt-suggestions.tsx +7 -4
- package/src/elements/reasoning.tsx +1 -1
- package/src/elements/register.ts +9 -0
- package/src/elements/resizable.globals.d.ts +36 -0
- package/src/elements/resizable.tsx +24 -13
- package/src/elements/response-stream.tsx +1 -1
- package/src/elements/scroll-button.tsx +1 -1
- package/src/elements/search.tsx +6 -1
- package/src/elements/segmented.tsx +5 -11
- package/src/elements/separator.tsx +1 -1
- package/src/elements/slots.ts +57 -24
- package/src/elements/source.tsx +21 -22
- package/src/elements/switch.tsx +3 -3
- package/src/elements/tasks.tsx +5 -4
- package/src/elements/thread.tsx +36 -4
- package/src/elements/toast.tsx +3 -2
- package/src/elements/tool.tsx +1 -1
- package/src/elements/validate-messages.ts +76 -0
- package/src/elements/voice-input.tsx +7 -7
- package/src/elements/voice-output.tsx +4 -4
- package/src/index.ts +141 -6
- package/src/primitives/card-component-types.ts +63 -0
- package/src/primitives/card-data-types.ts +312 -0
- package/src/primitives/card-recovery.ts +13 -2
- package/src/primitives/card-registry.tsx +34 -23
- package/src/primitives/card-schemas/artifact.schema.json +92 -0
- package/src/primitives/card-schemas/embed.schema.json +0 -2
- package/src/primitives/card-schemas/link.schema.json +0 -2
- package/src/primitives/card-tags.ts +61 -0
- package/src/primitives/card-validate-cards.ts +255 -0
- package/src/primitives/card-validate-generator.testlib.ts +38 -0
- package/src/primitives/card-validate-schemas.ts +58 -0
- package/src/primitives/card-validate.ts +48 -20
- package/src/primitives/create-tween.ts +54 -2
- package/src/primitives/message-feedback.ts +3 -2
- package/src/primitives/use-audio-analysis.ts +20 -1
- package/src/primitives/use-sequencer.ts +20 -1
- package/src/schemas/from-tool-call.ts +151 -0
- package/src/schemas/index.ts +340 -0
- package/src/schemas/provider-subsets.ts +538 -0
- package/src/schemas/registry.ts +355 -0
- package/src/schemas/tool-defs.ts +492 -0
- package/src/solid.ts +150 -0
- package/src/state/index.ts +27 -1
- package/src/state/messages.ts +21 -4
- package/src/state/mock.ts +211 -0
- package/src/state/parts.ts +295 -0
- package/src/state/stream.ts +56 -58
- package/src/ui/collapsible.tsx +17 -5
- package/src/ui/dropdown.tsx +46 -12
- package/src/ui/overlay.tsx +10 -4
- package/src/wire/chunk.ts +201 -0
- package/src/wire/consume.ts +440 -0
- package/src/wire/encode.ts +474 -0
- package/src/wire/formats/anthropic.ts +267 -0
- package/src/wire/formats/openai.ts +187 -0
- package/src/wire/index.ts +52 -0
- package/src/wire/read.ts +152 -0
- package/src/wire/sink-helpers.ts +50 -0
- package/src/wire/sse.ts +140 -0
- package/dist/create-tween-hvpmSuwW.js +0 -7
- package/dist/elements/chunks/arrow-left-DQocUFvy.js +0 -1
- package/dist/elements/chunks/audio-visualizer-BqNy7dfm.js +0 -1
- package/dist/elements/chunks/card-BkHbp4BA.js +0 -1
- package/dist/elements/chunks/chat-thread-CkRN6pZ7.js +0 -1
- package/dist/elements/chunks/check-B9-gn6SS.js +0 -1
- package/dist/elements/chunks/chevron-down-BNsxc2hk.js +0 -1
- package/dist/elements/chunks/chevron-right-Hv00StBO.js +0 -1
- package/dist/elements/chunks/circle-0e3KJTDr.js +0 -1
- package/dist/elements/chunks/circle-check-BNAS0JEy.js +0 -1
- package/dist/elements/chunks/code-block-BFUHn6Va.js +0 -1
- package/dist/elements/chunks/context-Cb7k4F-v.js +0 -1
- package/dist/elements/chunks/conversation-list-CvoAkWhN.js +0 -1
- package/dist/elements/chunks/create-tween-oVvAIG8r.js +0 -7
- package/dist/elements/chunks/define-D1din7Ld.js +0 -1
- package/dist/elements/chunks/hover-card-Cmm6Q53m.js +0 -1
- package/dist/elements/chunks/message-BqyXDN3-.js +0 -1
- package/dist/elements/chunks/message-feedback-Djr3z6Yb.js +0 -1
- package/dist/elements/chunks/message-square-vFAgbDaX.js +0 -1
- package/dist/elements/chunks/reasoning-DTpCGtnY.js +0 -1
- package/dist/elements/chunks/scroll-button-B0cH5fXf.js +0 -1
- package/dist/elements/chunks/skeleton-DSXW5Yya.js +0 -1
- package/dist/elements/chunks/slots--V19HwUb.js +0 -1
- package/dist/elements/chunks/textarea-CUwqAX0G.js +0 -1
- package/dist/elements/chunks/tooltip-CgBZCVKp.js +0 -1
- package/dist/elements/chunks/use-card-resolution-BSu_XHjH.js +0 -1
- package/dist/elements/chunks/x-GRUeeQFT.js +0 -1
- package/dist/host-embed.d.ts +0 -33
- package/dist/kai-provider.d.ts +0 -2
- package/dist/origin.d.ts +0 -5
- package/dist/provider-runtime.d.ts +0 -27
- package/dist/register-impl-DQyejdfb.js +0 -145
- package/dist/validate.d.ts +0 -4
- package/dist/version.d.ts +0 -4
- package/src/components/component-meta.json +0 -4550
- package/src/elements/card-media.jpg +0 -0
- package/src/elements/resizable.d.ts +0 -27
- package/src/elements/video-poster.jpg +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CardEnvelope, CardContext, CardPolicy } from '../primitives/card-contract';
|
|
1
|
+
import { CardEnvelope, CardContext, CardPolicy } from '../primitives/card-contract.js';
|
|
2
2
|
export interface MountRemoteCardOptions {
|
|
3
3
|
/** Where to mount the iframe. */
|
|
4
4
|
container: HTMLElement;
|
package/dist/remote/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { mountRemoteCard } from './host-embed';
|
|
2
|
-
export type { MountRemoteCardOptions, RemoteCardHandle } from './host-embed';
|
|
1
|
+
export { mountRemoteCard } from './host-embed.js';
|
|
2
|
+
export type { MountRemoteCardOptions, RemoteCardHandle } from './host-embed.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CardEnvelope, CardHost } from '../primitives/card-contract';
|
|
2
|
-
import { JsonSchema } from '../primitives/card-validate';
|
|
1
|
+
import { CardEnvelope, CardHost } from '../primitives/card-contract.js';
|
|
2
|
+
import { JsonSchema } from '../primitives/card-validate.js';
|
|
3
3
|
/** A provider-side renderer for one card `type`. Renamed (was CardRenderer) per H-K
|
|
4
4
|
* to avoid colliding with the exported Solid `<CardRenderer>` component. */
|
|
5
5
|
export interface RemoteCardRenderer {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { createCardBridge } from './provider-runtime';
|
|
2
|
-
export type { RemoteCardRenderer, CardBridge } from './provider-runtime';
|
|
1
|
+
export { createCardBridge } from './provider-runtime.js';
|
|
2
|
+
export type { RemoteCardRenderer, CardBridge } from './provider-runtime.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CardEventKind } from '../primitives/card-contract';
|
|
1
|
+
import { CardEventKind } from '../primitives/card-contract.js';
|
|
2
2
|
/** Recursive guard (H-D): nested data/patch/context are forwarded to app handlers. */
|
|
3
3
|
export declare function hasPollutionKey(value: unknown): boolean;
|
|
4
4
|
export declare function isKnownEventKind(k: unknown): k is CardEventKind;
|
package/dist/remote/wire.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CardEnvelope, CardContext, CardEvent } from '../primitives/card-contract';
|
|
1
|
+
import { CardEnvelope, CardContext, CardEvent } from '../primitives/card-contract.js';
|
|
2
2
|
export declare const CARD_WIRE_PROTOCOL: "kitn-card";
|
|
3
3
|
export interface WireFrame<M extends WireMessage = WireMessage> {
|
|
4
4
|
protocol: typeof CARD_WIRE_PROTOCOL;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://kitn.ai/schemas/card/artifact.schema.json",
|
|
4
|
+
"title": "ArtifactCardData",
|
|
5
|
+
"description": "Generated-artifact viewer payload: a framed preview plus the source files behind it. A deliberately NARROW subset of the Artifact component's props — it says WHAT to show, never how the viewer behaves. Toolbar composition, view-state and the iframe `sandbox` are host-owned and stay off the wire, so a model cannot widen its own sandbox or hide the chrome the user needs to inspect what it built.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"additionalProperties": false,
|
|
8
|
+
"anyOf": [{ "required": ["src"] }, { "required": ["files"] }],
|
|
9
|
+
"properties": {
|
|
10
|
+
"src": {
|
|
11
|
+
"type": "string",
|
|
12
|
+
"format": "uri",
|
|
13
|
+
"description": "URL the preview iframe frames, and the target of the Home button. Omit for a source-only artifact (`tab: 'code'` with `files`).",
|
|
14
|
+
"x-kai-format": "url"
|
|
15
|
+
},
|
|
16
|
+
"files": {
|
|
17
|
+
"type": "array",
|
|
18
|
+
"description": "Files behind the artifact: the Code tab's tree, each optionally carrying its own preview url and source.",
|
|
19
|
+
"maxItems": 500,
|
|
20
|
+
"items": {
|
|
21
|
+
"type": "object",
|
|
22
|
+
"required": ["path"],
|
|
23
|
+
"additionalProperties": false,
|
|
24
|
+
"properties": {
|
|
25
|
+
"path": {
|
|
26
|
+
"type": "string",
|
|
27
|
+
"description": "Tree label/key. Folders are built from `/`-delimited segments.",
|
|
28
|
+
"maxLength": 1024
|
|
29
|
+
},
|
|
30
|
+
"url": {
|
|
31
|
+
"type": "string",
|
|
32
|
+
"format": "uri",
|
|
33
|
+
"description": "Where the preview loads this file. Defaults to `path` resolved against `src`.",
|
|
34
|
+
"x-kai-format": "url"
|
|
35
|
+
},
|
|
36
|
+
"code": {
|
|
37
|
+
"type": "string",
|
|
38
|
+
"description": "Source shown in the Code tab. Omit for binary files (image/pdf), which have no code view."
|
|
39
|
+
},
|
|
40
|
+
"language": {
|
|
41
|
+
"type": "string",
|
|
42
|
+
"description": "Language id for syntax highlighting (e.g. 'html', 'css', 'tsx').",
|
|
43
|
+
"maxLength": 40
|
|
44
|
+
},
|
|
45
|
+
"type": {
|
|
46
|
+
"type": "string",
|
|
47
|
+
"enum": ["html", "pdf", "image", "other"],
|
|
48
|
+
"description": "File kind. Drives the tree icon and whether the Code view applies; 'pdf' also routes the preview to the inline PDF viewer.",
|
|
49
|
+
"x-kai-control": "select"
|
|
50
|
+
},
|
|
51
|
+
"additions": {
|
|
52
|
+
"type": "integer",
|
|
53
|
+
"minimum": 0,
|
|
54
|
+
"description": "Lines added vs the base. Rendered as a trailing '+N' stat."
|
|
55
|
+
},
|
|
56
|
+
"deletions": {
|
|
57
|
+
"type": "integer",
|
|
58
|
+
"minimum": 0,
|
|
59
|
+
"description": "Lines removed vs the base. Rendered as a trailing '-N' stat."
|
|
60
|
+
},
|
|
61
|
+
"status": {
|
|
62
|
+
"type": "string",
|
|
63
|
+
"enum": ["added", "modified", "deleted", "renamed", "untracked"],
|
|
64
|
+
"description": "Change status vs the base. Drives a trailing status letter in the conventional VCS hue.",
|
|
65
|
+
"x-kai-control": "select"
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
"tab": {
|
|
71
|
+
"type": "string",
|
|
72
|
+
"enum": ["preview", "code"],
|
|
73
|
+
"default": "preview",
|
|
74
|
+
"description": "Which view the card OPENS on. SEED ONLY: the user can switch freely afterwards and a revision of this card will NOT move them back, because the user's choice wins over the model's. A switch is reported back as a `state` patch.",
|
|
75
|
+
"x-kai-control": "select"
|
|
76
|
+
},
|
|
77
|
+
"activeFile": {
|
|
78
|
+
"type": "string",
|
|
79
|
+
"description": "Path of the file selected in the tree when the card FIRST renders (must match a `files[].path`). Seeds the tree highlight, the Code source and the preview. SEED ONLY, like `tab`: revising this card will not move a user who has since selected a different file.",
|
|
80
|
+
"maxLength": 1024
|
|
81
|
+
},
|
|
82
|
+
"displayUrl": {
|
|
83
|
+
"type": "string",
|
|
84
|
+
"description": "Friendly address shown in the path field INSTEAD of the real url, which also makes the field read-only. Use when `src` is not consumer-facing (e.g. a `data:` blob) so a clean address is shown rather than leaking it.",
|
|
85
|
+
"maxLength": 2048
|
|
86
|
+
},
|
|
87
|
+
"height": {
|
|
88
|
+
"description": "Frame height. A bare number is px; a string is any CSS length. Defaults to 420px. REQUIRED CONCEPT, not decoration: the viewer is built to fill its container, and a message thread supplies no height, so the card sets one explicitly or the artifact collapses to zero and renders invisible.",
|
|
89
|
+
"oneOf": [{ "type": "number", "minimum": 1 }, { "type": "string", "maxLength": 32 }]
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
@@ -4,8 +4,6 @@
|
|
|
4
4
|
"title": "EmbedCardData",
|
|
5
5
|
"description": "Lazy media-embed payload (YouTube / Vimeo / generic player URL).",
|
|
6
6
|
"type": "object",
|
|
7
|
-
"x-kai-card-type": "embed",
|
|
8
|
-
"x-kai-contract-version": "1",
|
|
9
7
|
"required": ["provider"],
|
|
10
8
|
"additionalProperties": false,
|
|
11
9
|
"properties": {
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { CardEnvelope } from '../primitives/card-contract.js';
|
|
2
|
+
/**
|
|
3
|
+
* The tool-name prefix that marks a card tool.
|
|
4
|
+
*
|
|
5
|
+
* Prefixed so a developer's own `confirm` tool cannot collide with ours, and
|
|
6
|
+
* exported as a value so `cardTools()` names its tools from here instead of
|
|
7
|
+
* restating the literal. A prefix written in two places is a prefix that can drift.
|
|
8
|
+
*/
|
|
9
|
+
export declare const KAI_TOOL_PREFIX = "kai_";
|
|
10
|
+
/**
|
|
11
|
+
* The card type a tool name denotes, or `null` if the name is not a card tool.
|
|
12
|
+
*
|
|
13
|
+
* The single decision both public predicates below are derived from. The remainder
|
|
14
|
+
* after the prefix is used verbatim: card types may contain hyphens
|
|
15
|
+
* (`kai_pricing-table` -> `pricing-table`), and both providers accept
|
|
16
|
+
* `[a-zA-Z0-9_-]` in a tool name, so there is nothing to translate. Matching is
|
|
17
|
+
* case-sensitive, because tool names are.
|
|
18
|
+
*/
|
|
19
|
+
export declare function cardTypeFromToolName(name: string): string | null;
|
|
20
|
+
/** The tool name for a card type. The exact inverse of {@link cardTypeFromToolName}. */
|
|
21
|
+
export declare function toolNameForCardType(type: string): string;
|
|
22
|
+
/**
|
|
23
|
+
* Is this tool call a card, rather than one of the app's own tools?
|
|
24
|
+
*
|
|
25
|
+
* True for any `kai_`-prefixed name with a non-empty remainder. It does NOT claim
|
|
26
|
+
* the type is registered or the data is valid; see the module header for why those
|
|
27
|
+
* are the dispatcher's questions.
|
|
28
|
+
*/
|
|
29
|
+
export declare function isCardTool(name: string): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Turn a model's tool call into a `CardEnvelope`, or `null` if it is not a card tool.
|
|
32
|
+
*
|
|
33
|
+
* @param name the tool name the model called, e.g. `kai_confirm`
|
|
34
|
+
* @param input the tool arguments, used verbatim as `CardEnvelope.data`
|
|
35
|
+
* @param opts.id the provider's `tool_call_id`, used verbatim as `CardEnvelope.id`
|
|
36
|
+
*
|
|
37
|
+
* `data` is the input as given: the tool's input schema IS the card-data schema that
|
|
38
|
+
* `cardTools()` handed the model, so the mapping is identity and nothing is peeled,
|
|
39
|
+
* renamed or defaulted. In particular no `title` is set. `CardEnvelope.title` is
|
|
40
|
+
* chrome the host owns and no card-data schema offers the model one (`confirm`
|
|
41
|
+
* deliberately calls its in-body heading `heading` and says so in its description),
|
|
42
|
+
* so a caller who wants a title writes `{ ...card, title }`.
|
|
43
|
+
*
|
|
44
|
+
* Never throws.
|
|
45
|
+
*/
|
|
46
|
+
export declare function cardFromToolCall(name: string, input: unknown, opts: {
|
|
47
|
+
id: string;
|
|
48
|
+
}): CardEnvelope | null;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { JsonSchema } from '../primitives/card-validate.js';
|
|
2
|
+
/**
|
|
3
|
+
* A card schema document, as authored.
|
|
4
|
+
*
|
|
5
|
+
* Wider than {@link JsonSchema} on purpose. `JsonSchema` describes the LEAN subset
|
|
6
|
+
* `validateAgainstSchema` implements; the files also carry `$schema`, `$id`,
|
|
7
|
+
* `title`, `description`, `default`, `additionalProperties`, `x-kai-*`, and (in
|
|
8
|
+
* `embed` and `artifact`) `allOf`/`if`/`then`/`oneOf`. Reading a document as
|
|
9
|
+
* `JsonSchema` alone would quietly imply the validator understands all of it.
|
|
10
|
+
*/
|
|
11
|
+
export type CardSchema = JsonSchema & Readonly<Record<string, unknown>>;
|
|
12
|
+
/**
|
|
13
|
+
* The card-DATA schemas: one per built-in `CardEnvelope.type`, describing the
|
|
14
|
+
* `data` payload for that type. These are the tool candidates. The key IS the
|
|
15
|
+
* envelope type.
|
|
16
|
+
*/
|
|
17
|
+
export type CardSchemaName = 'artifact' | 'choice' | 'confirm' | 'embed' | 'form' | 'link' | 'tasks';
|
|
18
|
+
/**
|
|
19
|
+
* The contract shapes: the envelope itself, the event a card emits back up, and the
|
|
20
|
+
* two result payloads. Not card data and NOT tool candidates — a model is never
|
|
21
|
+
* asked to emit one of these, so keeping them out of `cardSchemas` is what stops
|
|
22
|
+
* `cardTools()` offering the model an envelope-shaped tool.
|
|
23
|
+
*/
|
|
24
|
+
export type ContractSchemaName = 'card-envelope' | 'card-event' | 'form.result' | 'tasks.result';
|
|
25
|
+
/** The 7 card-data schemas, keyed by `CardEnvelope.type`. */
|
|
26
|
+
export declare const cardSchemas: Readonly<Record<CardSchemaName, CardSchema>>;
|
|
27
|
+
/** The 4 contract shapes, keyed by file stem. */
|
|
28
|
+
export declare const contractSchemas: Readonly<Record<ContractSchemaName, CardSchema>>;
|
|
29
|
+
/** The built-in card types, in the order `cardSchemas` declares them. */
|
|
30
|
+
export declare const cardSchemaNames: readonly CardSchemaName[];
|
|
31
|
+
/** Narrow an arbitrary string to a built-in card type. */
|
|
32
|
+
export declare function isCardSchemaName(name: string): name is CardSchemaName;
|
|
33
|
+
export type { JsonSchema, ValidationResult } from '../primitives/card-validate.js';
|
|
34
|
+
export type { CardEnvelope } from '../primitives/card-contract.js';
|
|
35
|
+
export type { ArtifactCardData, ArtifactCardEnvelope, ArtifactCardFile, ArtifactCardTab, ChoiceAllowOther, ChoiceCardData, ChoiceCardEnvelope, ChoiceOption, ChoiceOptionMedia, ConfirmAction, ConfirmActionStyle, ConfirmCardData, ConfirmCardEnvelope, ConfirmTone, FormCardEnvelope, FormDefinition, FormField, TasksCardData, TasksCardEnvelope, TasksCardResult, TasksTask, } from '../primitives/card-data-types.js';
|
|
36
|
+
export type { EmbedCardData, EmbedCardEnvelope, EmbedProvider } from '../primitives/embed-providers.js';
|
|
37
|
+
export type { LinkPreviewData, LinkPreviewEnvelope } from '../primitives/link-preview.js';
|
|
38
|
+
export { cardFromToolCall, isCardTool, cardTypeFromToolName, toolNameForCardType, KAI_TOOL_PREFIX } from './from-tool-call.js';
|
|
39
|
+
export { CARD_TOOL_DESCRIPTIONS, UnsupportedCardToolSchemaError, cardTools, toAnthropicTools, toJsonSchemaTools, toOpenAITools, } from './tool-defs.js';
|
|
40
|
+
export type { AnthropicToolDef, CardToolInput, CardToolOptions, CardToolSource, JsonSchemaToolDef, OpenAIToolDef, ToolDef, ToolDefFor, ToolParameters, ToolProvider, UnsupportedCardTool, } from './tool-defs.js';
|
|
41
|
+
export { createCardRegistry } from './registry.js';
|
|
42
|
+
export type { CardRegistry, CardRegistrySpec, CustomCardSpec, IncompletePolicy } from './registry.js';
|
|
43
|
+
export { cardValidationMessage, validateCardData } from '../primitives/card-validate-cards.js';
|
|
44
|
+
export type { CardValidationIssue, CardValidationReport, CardValidationTier } from '../primitives/card-validate-cards.js';
|
|
45
|
+
export { BUILTIN_CARD_TAGS } from '../primitives/card-tags.js';
|
|
46
|
+
export type { CardTagMap } from '../primitives/card-tags.js';
|
|
47
|
+
export { ANTHROPIC_STRICT, OPENAI_STRICT, checkProviderSubset, providerSubsets } from './provider-subsets.js';
|
|
48
|
+
export type { KeywordRule, KeywordStatus, ProviderSubset, StrictProviderId, SubsetViolation } from './provider-subsets.js';
|
|
@@ -4,8 +4,6 @@
|
|
|
4
4
|
"title": "LinkPreviewData",
|
|
5
5
|
"description": "Rich link / Open-Graph preview payload. The card renders from this; it never fetches.",
|
|
6
6
|
"type": "object",
|
|
7
|
-
"x-kai-card-type": "link",
|
|
8
|
-
"x-kai-contract-version": "1",
|
|
9
7
|
"required": ["url"],
|
|
10
8
|
"additionalProperties": false,
|
|
11
9
|
"properties": {
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/** The providers whose strict subsets are documented here. */
|
|
2
|
+
export type StrictProviderId = 'openai' | 'anthropic';
|
|
3
|
+
/**
|
|
4
|
+
* How a table classifies one keyword.
|
|
5
|
+
*
|
|
6
|
+
* `annotation` is not a synonym for `supported`. JSON Schema annotations (
|
|
7
|
+
* `title`, `description`, `examples`, ...) do not constrain an instance, so a
|
|
8
|
+
* grammar compiler has nothing to compile from them and cannot reject them. They are
|
|
9
|
+
* separated from `supported` so that a table entry answers "the provider documents
|
|
10
|
+
* this" distinctly from "this cannot affect the grammar either way".
|
|
11
|
+
*/
|
|
12
|
+
export type KeywordStatus = 'supported' | 'unsupported' | 'annotation';
|
|
13
|
+
export interface KeywordRule {
|
|
14
|
+
readonly status: KeywordStatus;
|
|
15
|
+
/** Why, in the words of the source doc where possible. Surfaced in the error. */
|
|
16
|
+
readonly note: string;
|
|
17
|
+
/**
|
|
18
|
+
* A value-level constraint on an otherwise supported keyword. Returns a reason
|
|
19
|
+
* string when the specific VALUE is out of subset, or null when it is fine.
|
|
20
|
+
* This is where `minItems: 2` on Anthropic and `format: "uri"` on OpenAI live:
|
|
21
|
+
* the keyword is supported, the value is not.
|
|
22
|
+
*/
|
|
23
|
+
readonly value?: (value: unknown) => string | null;
|
|
24
|
+
}
|
|
25
|
+
export interface ProviderSubset {
|
|
26
|
+
readonly id: StrictProviderId;
|
|
27
|
+
readonly label: string;
|
|
28
|
+
/** The page these rules were read off. Quoted in every violation message. */
|
|
29
|
+
readonly source: string;
|
|
30
|
+
/** ISO date the source was last read. Rules go stale; this says how stale. */
|
|
31
|
+
readonly checkedOn: string;
|
|
32
|
+
readonly keywords: Readonly<Record<string, KeywordRule>>;
|
|
33
|
+
/** Every object subschema must carry `additionalProperties: false`. */
|
|
34
|
+
readonly requireAdditionalPropertiesFalse: boolean;
|
|
35
|
+
/** Every key of `properties` must appear in `required` (OpenAI's rule, not Anthropic's). */
|
|
36
|
+
readonly requireAllPropertiesRequired: boolean;
|
|
37
|
+
/** Whether the ROOT schema may carry `anyOf`. */
|
|
38
|
+
readonly allowRootAnyOf: boolean;
|
|
39
|
+
/** Whether `$ref` may point at an ancestor (recursion). */
|
|
40
|
+
readonly allowRecursion: boolean;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* OpenAI strict function calling / structured outputs.
|
|
44
|
+
*
|
|
45
|
+
* SOURCE: https://developers.openai.com/api/docs/guides/structured-outputs
|
|
46
|
+
* (sections "Supported schemas", "Supported properties", "Some type-specific
|
|
47
|
+
* keywords are not yet supported"), read 2026-08-11. The older
|
|
48
|
+
* platform.openai.com/docs/guides/structured-outputs URL 301s here.
|
|
49
|
+
*
|
|
50
|
+
* Quoted from that page:
|
|
51
|
+
* - supported types: "String, Number, Boolean, Integer, Object, Array, Enum, anyOf"
|
|
52
|
+
* - "Objects have `additionalProperties: false` must always be set"
|
|
53
|
+
* - "All fields or function parameters must be specified as `required`" (an optional
|
|
54
|
+
* field is emulated with a union type including `null`)
|
|
55
|
+
* - supported String properties: `pattern`, `format`
|
|
56
|
+
* - supported Number properties: `multipleOf`, `maximum`, `exclusiveMaximum`,
|
|
57
|
+
* `minimum`, `exclusiveMinimum`
|
|
58
|
+
* - supported Array properties: `minItems`, `maxItems`
|
|
59
|
+
* - not supported, composition: "`allOf`, `not`, `dependentRequired`,
|
|
60
|
+
* `dependentSchemas`, `if`, `then`, `else`"
|
|
61
|
+
* - "Root level object of a schema must be an object, and not use `anyOf`"
|
|
62
|
+
*
|
|
63
|
+
* ONE JUDGEMENT CALL, RECORDED BECAUSE IT IS A COIN FLIP.
|
|
64
|
+
* `minLength` / `maxLength` are absent from "Supported properties", which lists only
|
|
65
|
+
* `pattern` and `format` for strings. They appear once elsewhere, in the list of what
|
|
66
|
+
* is "additionally" unsupported for FINE-TUNED models, which can be read as implying
|
|
67
|
+
* base models do support them. The docs do not settle it. This table takes the
|
|
68
|
+
* allowlist reading (unsupported) because the two ways of being wrong are not
|
|
69
|
+
* symmetric: a wrong `supported` is a 400 at request time in the developer's
|
|
70
|
+
* production app with nothing local to look at, while a wrong `unsupported` is a
|
|
71
|
+
* throw on their own machine that names the keyword and the source, which they can
|
|
72
|
+
* read and argue with. If OpenAI clarifies, change this entry and the guard's
|
|
73
|
+
* expectations follow automatically.
|
|
74
|
+
*/
|
|
75
|
+
export declare const OPENAI_STRICT: ProviderSubset;
|
|
76
|
+
/**
|
|
77
|
+
* Anthropic strict tool use (`strict: true` on a tool definition).
|
|
78
|
+
*
|
|
79
|
+
* SOURCE: https://platform.claude.com/docs/en/build-with-claude/structured-outputs
|
|
80
|
+
* ("JSON Schema limitations"), read 2026-08-11. The strict-tool-use page
|
|
81
|
+
* (https://platform.claude.com/docs/en/agents-and-tools/tool-use/strict-tool-use)
|
|
82
|
+
* carries the envelope shape and defers the keyword list to that section verbatim:
|
|
83
|
+
* "For the supported JSON Schema subset, see JSON Schema limitations".
|
|
84
|
+
*
|
|
85
|
+
* Quoted supported list:
|
|
86
|
+
* - "All basic types: object, array, string, integer, number, boolean, null"
|
|
87
|
+
* - "`enum` (strings, numbers, bools, or nulls only - no complex types)"
|
|
88
|
+
* - "`const`"
|
|
89
|
+
* - "`anyOf` and `allOf` (with limitations - `allOf` with `$ref` not supported)"
|
|
90
|
+
* - "`$ref`, `$def`, and `definitions` (external `$ref` not supported)"
|
|
91
|
+
* - "`default` property for all supported types"
|
|
92
|
+
* - "`required` and `additionalProperties` (must be set to `false` for objects)"
|
|
93
|
+
* - "String formats: `date-time`, `time`, `date`, `duration`, `email`, `hostname`,
|
|
94
|
+
* `uri`, `ipv4`, `ipv6`, `uuid`"
|
|
95
|
+
* - "Array `minItems` (only values 0 and 1 supported)"
|
|
96
|
+
*
|
|
97
|
+
* Quoted NOT supported list:
|
|
98
|
+
* - "Recursive schemas"
|
|
99
|
+
* - "Complex types within enums"
|
|
100
|
+
* - "External `$ref`"
|
|
101
|
+
* - "Numerical constraints (such as `minimum`, `maximum`, `multipleOf`)"
|
|
102
|
+
* - "String constraints (`minLength`, `maxLength`)"
|
|
103
|
+
* - "Array constraints beyond `minItems` of 0 or 1"
|
|
104
|
+
* - "`additionalProperties` set to anything other than `false`"
|
|
105
|
+
*
|
|
106
|
+
* TWO PLACES THIS DIVERGES FROM WHAT THE PLAN ASSUMED, both checked twice:
|
|
107
|
+
* 1. `allOf` IS supported here (it is unsupported on OpenAI). What the kit's `embed`
|
|
108
|
+
* schema actually trips on under Anthropic is the `if`/`then` INSIDE its `allOf`,
|
|
109
|
+
* which the supported list does not mention and which is therefore unsupported.
|
|
110
|
+
* 2. `pattern` is NOT in the supported list here, though it is on OpenAI. The
|
|
111
|
+
* supported string surface on Anthropic is `format` and nothing else.
|
|
112
|
+
* Optional properties are fine here: the doc's own quick-start example ships
|
|
113
|
+
* `required: ["location"]` with a second, unlisted `unit` property.
|
|
114
|
+
*/
|
|
115
|
+
export declare const ANTHROPIC_STRICT: ProviderSubset;
|
|
116
|
+
/** The two subsets, by provider id. */
|
|
117
|
+
export declare const providerSubsets: Readonly<Record<StrictProviderId, ProviderSubset>>;
|
|
118
|
+
export interface SubsetViolation {
|
|
119
|
+
/** Where in the schema, in readable form: `(root)`, `actions`, `actions[].id`. */
|
|
120
|
+
readonly path: string;
|
|
121
|
+
/** The offending keyword, NAMED. Never a generic "unsupported schema". */
|
|
122
|
+
readonly keyword: string;
|
|
123
|
+
readonly reason: string;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Check a schema document against a provider's strict subset.
|
|
127
|
+
*
|
|
128
|
+
* Returns EVERY violation, not the first, and names the keyword and the path for
|
|
129
|
+
* each. A caller that only wants to know "can this be strict" checks `.length`.
|
|
130
|
+
*
|
|
131
|
+
* This runs against whatever it is handed. Point it at an authored card schema and
|
|
132
|
+
* it reports what the projection has to deal with; point it at a projected one and
|
|
133
|
+
* a non-empty result means the projection emitted something the provider would 400
|
|
134
|
+
* on, which is the self-consistency property `verify:tool-schemas` asserts.
|
|
135
|
+
*/
|
|
136
|
+
export declare function checkProviderSubset(schema: unknown, subset: ProviderSubset): SubsetViolation[];
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { CardComponentMap } from '../primitives/card-component-types.js';
|
|
2
|
+
import { CardTagMap } from '../primitives/card-tags.js';
|
|
3
|
+
import { JsonSchema } from '../primitives/card-validate.js';
|
|
4
|
+
import { CardValidationReport } from '../primitives/card-validate-cards.js';
|
|
5
|
+
import { CardSchema, CardSchemaName } from './index.js';
|
|
6
|
+
import { CardToolSource } from './tool-defs.js';
|
|
7
|
+
/**
|
|
8
|
+
* One custom card type: what the model should be told, and what draws it.
|
|
9
|
+
*
|
|
10
|
+
* Every member is optional because the useful combinations genuinely differ. A
|
|
11
|
+
* web-component consumer supplies `tag`; a Solid consumer supplies `component`; a
|
|
12
|
+
* backend-only registry (a route that builds tool definitions and never renders)
|
|
13
|
+
* supplies neither. Only `schema` carries a warning when absent, and the reason is on
|
|
14
|
+
* {@link CardRegistrySpec.onIncomplete}.
|
|
15
|
+
*/
|
|
16
|
+
export interface CustomCardSpec {
|
|
17
|
+
/**
|
|
18
|
+
* The JSON Schema for this card type's `data` payload.
|
|
19
|
+
*
|
|
20
|
+
* Used for BOTH ends: `cardTools()` projects it into a tool definition, and
|
|
21
|
+
* `registry.validate()` checks arriving data against it. Authored form is fine, with
|
|
22
|
+
* the descriptions left in: the projection strips what a provider cannot take, and
|
|
23
|
+
* the validator ignores keywords it does not implement.
|
|
24
|
+
*
|
|
25
|
+
* That last clause is a real limit, not a formality, and it is the same one the
|
|
26
|
+
* built-ins carry. `validateAgainstSchema` has no applicators, so `allOf`, `anyOf`,
|
|
27
|
+
* `oneOf`, `if`/`then`, `$ref` and `additionalProperties` in a custom schema are
|
|
28
|
+
* carried faithfully to the model and NOT enforced on the way back. See the
|
|
29
|
+
* NOT_ENFORCED table at the top of primitives/card-validate-schemas.ts.
|
|
30
|
+
*/
|
|
31
|
+
readonly schema?: CardSchema | JsonSchema;
|
|
32
|
+
/** The custom element that renders it, e.g. `'my-pricing-table'`. Feeds `mergeCardTags`. */
|
|
33
|
+
readonly tag?: string;
|
|
34
|
+
/** The Solid component that renders it. Feeds `mergeCardComponents`. */
|
|
35
|
+
readonly component?: CardComponentMap[string];
|
|
36
|
+
/**
|
|
37
|
+
* One sentence of PURPOSE, addressed to the model: when should it reach for this
|
|
38
|
+
* card? Not a restatement of the shape, which the schema already carries.
|
|
39
|
+
*
|
|
40
|
+
* Falls back to the schema's own `description`, then to a generated stub. See
|
|
41
|
+
* `describe()` in tool-defs.ts.
|
|
42
|
+
*/
|
|
43
|
+
readonly description?: string;
|
|
44
|
+
}
|
|
45
|
+
/** What to do about a custom card type registered with no schema. */
|
|
46
|
+
export type IncompletePolicy = 'warn' | 'throw' | 'silent';
|
|
47
|
+
export interface CardRegistrySpec {
|
|
48
|
+
/**
|
|
49
|
+
* Which BUILT-IN card types this app renders, and therefore which ones the model is
|
|
50
|
+
* offered.
|
|
51
|
+
*
|
|
52
|
+
* Omitted means all seven, which is what `cardTools({ provider })` already does and
|
|
53
|
+
* what `<kai-chat>` actually renders, so the default describes reality rather than
|
|
54
|
+
* quietly shrinking it. `use: []` means none of ours: an app whose generative UI is
|
|
55
|
+
* entirely its own.
|
|
56
|
+
*/
|
|
57
|
+
readonly use?: readonly CardSchemaName[];
|
|
58
|
+
/** This app's own card types, keyed by `CardEnvelope.type`. */
|
|
59
|
+
readonly custom?: Readonly<Record<string, CustomCardSpec>>;
|
|
60
|
+
/**
|
|
61
|
+
* How a schema-less custom type is reported. Default `'warn'`.
|
|
62
|
+
*
|
|
63
|
+
* `'throw'` for a build or a CI check that wants the hole to be fatal; `'silent'` for
|
|
64
|
+
* a card type your own code populates and a model never emits, where the warning is
|
|
65
|
+
* noise. `'silent'` is deliberately a word you have to type, so the acknowledgement is
|
|
66
|
+
* greppable instead of implied.
|
|
67
|
+
*/
|
|
68
|
+
readonly onIncomplete?: IncompletePolicy;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* An app's card types, in the one shape both ends take.
|
|
72
|
+
*
|
|
73
|
+
* ```ts
|
|
74
|
+
* // cards.ts, imported by the client AND the route
|
|
75
|
+
* export const cards = createCardRegistry({
|
|
76
|
+
* use: ['confirm', 'choice'],
|
|
77
|
+
* custom: { 'pricing-table': { schema: pricingSchema, tag: 'my-pricing-table' } },
|
|
78
|
+
* });
|
|
79
|
+
*
|
|
80
|
+
* // client
|
|
81
|
+
* chat.cardTypes = cards.tags;
|
|
82
|
+
* // server
|
|
83
|
+
* const tools = cardTools(cards, { provider: 'anthropic' });
|
|
84
|
+
* ```
|
|
85
|
+
*
|
|
86
|
+
* Extends {@link CardToolSource}, so `cardTools(registry, opts)` takes it with no
|
|
87
|
+
* signature change on that side. That interface was left open for exactly this.
|
|
88
|
+
*/
|
|
89
|
+
export interface CardRegistry extends CardToolSource {
|
|
90
|
+
/**
|
|
91
|
+
* The card types the model is offered, keyed by type. `use`d built-ins plus every
|
|
92
|
+
* custom type that HAS a schema. What `cardTools()` reads.
|
|
93
|
+
*/
|
|
94
|
+
readonly schemas: Readonly<Record<string, CardSchema>>;
|
|
95
|
+
/** Purpose sentences for custom types (and for any built-in a custom entry overrode). */
|
|
96
|
+
readonly descriptions: Readonly<Record<string, string>>;
|
|
97
|
+
/**
|
|
98
|
+
* Custom `type -> tag`, for `chat.cardTypes` / `mergeCardTags`.
|
|
99
|
+
*
|
|
100
|
+
* Custom entries ONLY. The built-in tags are not restated here because
|
|
101
|
+
* `mergeCardTags` adds all seven itself; listing the `use`d ones would read as if the
|
|
102
|
+
* others had been excluded, which is not what happens.
|
|
103
|
+
*/
|
|
104
|
+
readonly tags: CardTagMap;
|
|
105
|
+
/** Custom `type -> Solid component`, for `<CardRenderer types>` / `mergeCardComponents`. */
|
|
106
|
+
readonly components: CardComponentMap;
|
|
107
|
+
/** Every type this registry declares, schema-less ones included. Built-ins first. */
|
|
108
|
+
readonly types: readonly string[];
|
|
109
|
+
/** The built-in types in `use`, in `cardSchemas` order. */
|
|
110
|
+
readonly builtIn: readonly CardSchemaName[];
|
|
111
|
+
/** The custom types, in declaration order, schema-less ones included. */
|
|
112
|
+
readonly custom: readonly string[];
|
|
113
|
+
/** Custom types with no schema: registered, renderable, invisible to the model. */
|
|
114
|
+
readonly incomplete: readonly string[];
|
|
115
|
+
/**
|
|
116
|
+
* Custom schemas in the shape `validateCardData`'s third argument takes, so a caller
|
|
117
|
+
* that already has a `validateCardData` call can widen it without going through
|
|
118
|
+
* {@link CardRegistry.validate}.
|
|
119
|
+
*/
|
|
120
|
+
readonly validationSchemas: Readonly<Record<string, JsonSchema>>;
|
|
121
|
+
/**
|
|
122
|
+
* Validate an envelope's `data` against this registry's schema for `type`.
|
|
123
|
+
*
|
|
124
|
+
* Custom schemas win over a built-in of the same name, matching `mergeCardTags`'s
|
|
125
|
+
* consumer-wins rule. `null` means there was nothing to check (a type with no
|
|
126
|
+
* schema anywhere), which is kept distinguishable from a clean pass so a caller
|
|
127
|
+
* cannot report the second as the first.
|
|
128
|
+
*
|
|
129
|
+
* Covers all seven built-ins regardless of `use`: see the module header.
|
|
130
|
+
*/
|
|
131
|
+
validate(type: string, data: unknown): CardValidationReport | null;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Declare the card types this app renders, once, for both ends.
|
|
135
|
+
*
|
|
136
|
+
* @throws {TypeError} if `use` names something that is not a built-in card type (a
|
|
137
|
+
* typo, or a custom type that belongs in `custom`), if a custom key is empty, or if
|
|
138
|
+
* `onIncomplete: 'throw'` and a custom type has no schema.
|
|
139
|
+
*/
|
|
140
|
+
export declare function createCardRegistry(spec?: CardRegistrySpec): CardRegistry;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { CardSchema, CardSchemaName } from './index.js';
|
|
2
|
+
import { ProviderSubset, StrictProviderId, SubsetViolation } from './provider-subsets.js';
|
|
3
|
+
/** A projected schema. Deliberately loose: `type` may become `['string','null']`. */
|
|
4
|
+
export type ToolParameters = Readonly<Record<string, unknown>>;
|
|
5
|
+
/** `POST /v1/chat/completions` and `/v1/responses` tool entries. */
|
|
6
|
+
export interface OpenAIToolDef {
|
|
7
|
+
readonly type: 'function';
|
|
8
|
+
readonly function: {
|
|
9
|
+
readonly name: string;
|
|
10
|
+
readonly description: string;
|
|
11
|
+
readonly parameters: ToolParameters;
|
|
12
|
+
readonly strict?: true;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/** `POST /v1/messages` tool entries. Note `input_schema`, NOT `function.parameters`. */
|
|
16
|
+
export interface AnthropicToolDef {
|
|
17
|
+
readonly name: string;
|
|
18
|
+
readonly description: string;
|
|
19
|
+
readonly input_schema: ToolParameters;
|
|
20
|
+
readonly strict?: true;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The bare form, for the Vercel AI SDK and anything else that wants the schema
|
|
24
|
+
* without a provider envelope: `tool({ inputSchema: jsonSchema(def.schema) })`.
|
|
25
|
+
*
|
|
26
|
+
* First-class, not a fallback. A developer on `ai@7` defines tools with Zod, and
|
|
27
|
+
* handing them an OpenAI-shaped envelope they have to unwrap makes our JSON Schema an
|
|
28
|
+
* awkward second source of truth instead of the one they use.
|
|
29
|
+
*/
|
|
30
|
+
export interface JsonSchemaToolDef {
|
|
31
|
+
readonly name: string;
|
|
32
|
+
readonly description: string;
|
|
33
|
+
readonly schema: ToolParameters;
|
|
34
|
+
}
|
|
35
|
+
export type ToolProvider = 'openai' | 'anthropic' | 'jsonschema';
|
|
36
|
+
export type ToolDefFor<P extends ToolProvider> = P extends 'openai' ? OpenAIToolDef : P extends 'anthropic' ? AnthropicToolDef : JsonSchemaToolDef;
|
|
37
|
+
export type ToolDef = OpenAIToolDef | AnthropicToolDef | JsonSchemaToolDef;
|
|
38
|
+
export interface CardToolOptions<P extends ToolProvider = ToolProvider> {
|
|
39
|
+
readonly provider: P;
|
|
40
|
+
/**
|
|
41
|
+
* Opt in to the provider's grammar-constrained mode.
|
|
42
|
+
*
|
|
43
|
+
* Default `false`, because that is the mode the conformance sweep proved cards in
|
|
44
|
+
* and because, today, `true` throws for every built-in card on both providers.
|
|
45
|
+
* When it throws it names the card, the path and the keyword.
|
|
46
|
+
*/
|
|
47
|
+
readonly strict?: boolean;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Where the card types come from.
|
|
51
|
+
*
|
|
52
|
+
* Phase 1 hands this the built-in `cardSchemas` map directly. Phase 2's
|
|
53
|
+
* `createCardRegistry()` returns an object that is structurally a `CardToolSource`,
|
|
54
|
+
* so `cardTools(registry, opts)` starts working on custom card types without this
|
|
55
|
+
* signature changing. That is the seam, left open on purpose and not built yet.
|
|
56
|
+
*/
|
|
57
|
+
export interface CardToolSource {
|
|
58
|
+
readonly schemas: Readonly<Record<string, CardSchema>>;
|
|
59
|
+
/** Tool descriptions by card type. Falls back to the built-in copy, then the schema's own. */
|
|
60
|
+
readonly descriptions?: Readonly<Record<string, string>>;
|
|
61
|
+
}
|
|
62
|
+
export type CardToolInput = CardToolSource | Readonly<Record<string, CardSchema>>;
|
|
63
|
+
/**
|
|
64
|
+
* What each card is FOR, addressed to a model.
|
|
65
|
+
*
|
|
66
|
+
* This is not a sixth copy of a shape. The shape stays in the JSON Schema and is
|
|
67
|
+
* never restated here; these are one sentence each of purpose, which exists nowhere
|
|
68
|
+
* else, and which a schema's own `description` ("Data payload for a `confirm` card")
|
|
69
|
+
* does not provide because it is written for a developer reading the contract.
|
|
70
|
+
*
|
|
71
|
+
* Typed as an exhaustive `Record<CardSchemaName, string>`, so adding an eighth card
|
|
72
|
+
* type fails `tsc` here rather than silently shipping a tool with no description.
|
|
73
|
+
*/
|
|
74
|
+
export declare const CARD_TOOL_DESCRIPTIONS: Readonly<Record<CardSchemaName, string>>;
|
|
75
|
+
export interface UnsupportedCardTool {
|
|
76
|
+
readonly cardType: string;
|
|
77
|
+
readonly toolName: string;
|
|
78
|
+
readonly violations: readonly SubsetViolation[];
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Thrown by `cardTools(..., { strict: true })` when a card cannot be expressed in the
|
|
82
|
+
* provider's strict subset.
|
|
83
|
+
*
|
|
84
|
+
* Carries the structured detail as well as the message, so a build script can render
|
|
85
|
+
* it however it likes rather than parsing prose.
|
|
86
|
+
*/
|
|
87
|
+
export declare class UnsupportedCardToolSchemaError extends Error {
|
|
88
|
+
readonly name = "UnsupportedCardToolSchemaError";
|
|
89
|
+
readonly provider: StrictProviderId;
|
|
90
|
+
readonly source: string;
|
|
91
|
+
readonly cards: readonly UnsupportedCardTool[];
|
|
92
|
+
constructor(subset: ProviderSubset, cards: readonly UnsupportedCardTool[]);
|
|
93
|
+
/** Every distinct keyword named across every failing card, deduped, in order. */
|
|
94
|
+
get keywords(): string[];
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Project the card schemas into tool definitions for one provider.
|
|
98
|
+
*
|
|
99
|
+
* ```ts
|
|
100
|
+
* const tools = [...myTools, ...cardTools({ provider: 'openai' })];
|
|
101
|
+
* const tools = cardTools(cards, { provider: 'anthropic' });
|
|
102
|
+
* const tools = cardTools({ provider: 'jsonschema' }).map((t) =>
|
|
103
|
+
* tool({ description: t.description, inputSchema: jsonSchema(t.schema) }));
|
|
104
|
+
* ```
|
|
105
|
+
*
|
|
106
|
+
* @throws {UnsupportedCardToolSchemaError} with `strict: true`, naming every card,
|
|
107
|
+
* path and keyword the provider cannot express. See the file header: today that is
|
|
108
|
+
* every built-in card on both providers.
|
|
109
|
+
*/
|
|
110
|
+
export declare function cardTools<P extends ToolProvider>(opts: CardToolOptions<P>): ToolDefFor<P>[];
|
|
111
|
+
export declare function cardTools<P extends ToolProvider>(registry: CardToolInput, opts: CardToolOptions<P>): ToolDefFor<P>[];
|
|
112
|
+
/** `cardTools(registry, { provider: 'openai' })`, spelled out. */
|
|
113
|
+
export declare function toOpenAITools(registry?: CardToolInput, opts?: {
|
|
114
|
+
strict?: boolean;
|
|
115
|
+
}): OpenAIToolDef[];
|
|
116
|
+
/** `cardTools(registry, { provider: 'anthropic' })`, spelled out. */
|
|
117
|
+
export declare function toAnthropicTools(registry?: CardToolInput, opts?: {
|
|
118
|
+
strict?: boolean;
|
|
119
|
+
}): AnthropicToolDef[];
|
|
120
|
+
/** `cardTools(registry, { provider: 'jsonschema' })`, spelled out. */
|
|
121
|
+
export declare function toJsonSchemaTools(registry?: CardToolInput): JsonSchemaToolDef[];
|