@waniwani/sdk 0.4.3-beta.6 → 0.4.3-beta.8
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/dist/chat/index.js +6 -6
- package/dist/chat/index.js.map +1 -1
- package/dist/chat/styles.css +1 -1
- package/dist/mcp/index.js +4 -4
- package/dist/mcp/index.js.map +1 -1
- package/package.json +1 -1
package/dist/chat/styles.css
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! tailwindcss v4.1.18 | MIT License | https://tailwindcss.com */
|
|
2
|
-
@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-space-y-reverse:0;--tw-border-style:solid;--tw-font-weight:initial;--tw-tracking:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-duration:initial;--tw-ease:initial}}}@layer theme{:root,:host{--ww-font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;--ww-color-blue-400:oklch(70.7% .165 254.624);--ww-spacing:.25rem;--ww-container-3xl:48rem;--ww-text-xs:.75rem;--ww-text-xs--line-height:calc(1/.75);--ww-text-sm:.875rem;--ww-text-sm--line-height:calc(1.25/.875);--ww-text-base:1rem;--ww-text-base--line-height:calc(1.5/1);--ww-font-weight-medium:500;--ww-font-weight-semibold:600;--ww-tracking-wide:.025em;--ww-radius-md:.375rem;--ww-radius-lg:.5rem;--ww-radius-2xl:1rem;--ww-ease-out:cubic-bezier(0,0,.2,1);--ww-animate-spin:spin 1s linear infinite;--ww-animate-pulse:pulse 2s cubic-bezier(.4,0,.6,1)infinite;--ww-default-transition-duration:.15s;--ww-default-transition-timing-function:cubic-bezier(.4,0,.2,1);--ww-default-font-family:var(--ww-font-sans,system-ui,-apple-system,"Segoe UI",sans-serif);--ww-default-mono-font-family:var(--ww-font-mono)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--ww-default-font-family,ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji");font-feature-settings:var(--ww-default-font-feature-settings,normal);font-variation-settings:var(--ww-default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--ww-default-mono-font-family,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace);font-feature-settings:var(--ww-default-mono-font-feature-settings,normal);font-variation-settings:var(--ww-default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab, red, red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components;@layer utilities{.ww\:absolute{position:absolute}.ww\:relative{position:relative}.ww\:bottom-4{bottom:calc(var(--ww-spacing)*4)}.ww\:left-\[50\%\]{left:50%}.ww\:mx-auto{margin-inline:auto}.ww\:mt-0\.5{margin-top:calc(var(--ww-spacing)*.5)}.ww\:mt-2{margin-top:calc(var(--ww-spacing)*2)}.ww\:mb-2{margin-bottom:calc(var(--ww-spacing)*2)}.ww\:mb-4{margin-bottom:calc(var(--ww-spacing)*4)}.ww\:ml-auto{margin-left:auto}.ww\:line-clamp-1{-webkit-line-clamp:1;-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}.ww\:contents{display:contents}.ww\:flex{display:flex}.ww\:grid{display:grid}.ww\:hidden{display:none}.ww\:inline-block{display:inline-block}.ww\:inline-flex{display:inline-flex}.ww\:field-sizing-content{field-sizing:content}.ww\:size-2{width:calc(var(--ww-spacing)*2);height:calc(var(--ww-spacing)*2)}.ww\:size-3{width:calc(var(--ww-spacing)*3);height:calc(var(--ww-spacing)*3)}.ww\:size-3\.5{width:calc(var(--ww-spacing)*3.5);height:calc(var(--ww-spacing)*3.5)}.ww\:size-4{width:calc(var(--ww-spacing)*4);height:calc(var(--ww-spacing)*4)}.ww\:size-5{width:calc(var(--ww-spacing)*5);height:calc(var(--ww-spacing)*5)}.ww\:size-7{width:calc(var(--ww-spacing)*7);height:calc(var(--ww-spacing)*7)}.ww\:size-8{width:calc(var(--ww-spacing)*8);height:calc(var(--ww-spacing)*8)}.ww\:size-9{width:calc(var(--ww-spacing)*9);height:calc(var(--ww-spacing)*9)}.ww\:size-auto{width:auto;height:auto}.ww\:size-full{width:100%;height:100%}.ww\:h-7{height:calc(var(--ww-spacing)*7)}.ww\:h-8{height:calc(var(--ww-spacing)*8)}.ww\:h-9{height:calc(var(--ww-spacing)*9)}.ww\:h-16{height:calc(var(--ww-spacing)*16)}.ww\:h-auto{height:auto}.ww\:max-h-48{max-height:calc(var(--ww-spacing)*48)}.ww\:min-h-0{min-height:calc(var(--ww-spacing)*0)}.ww\:min-h-16{min-height:calc(var(--ww-spacing)*16)}.ww\:w-fit{width:fit-content}.ww\:w-full{width:100%}.ww\:max-w-3xl{max-width:var(--ww-container-3xl)}.ww\:max-w-24{max-width:calc(var(--ww-spacing)*24)}.ww\:max-w-32{max-width:calc(var(--ww-spacing)*32)}.ww\:max-w-\[80\%\]{max-width:80%}.ww\:max-w-full{max-width:100%}.ww\:min-w-0{min-width:calc(var(--ww-spacing)*0)}.ww\:flex-1{flex:1}.ww\:shrink-0{flex-shrink:0}.ww\:grow{flex-grow:1}.ww\:translate-x-\[-50\%\]{--tw-translate-x:-50%;translate:var(--tw-translate-x)var(--tw-translate-y)}.ww\:rotate-90{rotate:90deg}.ww\:rotate-180{rotate:180deg}.ww\:animate-\[ww-fade-in_0\.2s_ease-out_both\]{animation:.2s ease-out both ww-fade-in}.ww\:animate-pulse{animation:var(--ww-animate-pulse)}.ww\:animate-spin{animation:var(--ww-animate-spin)}.ww\:cursor-pointer{cursor:pointer}.ww\:resize-none{resize:none}.ww\:grid-rows-\[0fr\]{grid-template-rows:0fr}.ww\:grid-rows-\[1fr\]{grid-template-rows:1fr}.ww\:flex-col{flex-direction:column}.ww\:flex-wrap{flex-wrap:wrap}.ww\:items-center{align-items:center}.ww\:items-end{align-items:flex-end}.ww\:items-start{align-items:flex-start}.ww\:justify-between{justify-content:space-between}.ww\:justify-center{justify-content:center}.ww\:gap-1{gap:calc(var(--ww-spacing)*1)}.ww\:gap-1\.5{gap:calc(var(--ww-spacing)*1.5)}.ww\:gap-2{gap:calc(var(--ww-spacing)*2)}.ww\:gap-3{gap:calc(var(--ww-spacing)*3)}.ww\:gap-6{gap:calc(var(--ww-spacing)*6)}:where(.ww\:space-y-2>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--ww-spacing)*2)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--ww-spacing)*2)*calc(1 - var(--tw-space-y-reverse)))}:where(.ww\:space-y-3>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--ww-spacing)*3)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--ww-spacing)*3)*calc(1 - var(--tw-space-y-reverse)))}.ww\:truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.ww\:overflow-hidden{overflow:hidden}.ww\:overflow-x-auto{overflow-x:auto}.ww\:overflow-y-hidden{overflow-y:hidden}.ww\:rounded{border-radius:var(--ww-radius,16px)}.ww\:rounded-2xl{border-radius:var(--ww-radius-2xl)}.ww\:rounded-\[var\(--ww-radius\)\]{border-radius:var(--ww-radius)}.ww\:rounded-full{border-radius:3.40282e38px}.ww\:rounded-lg{border-radius:var(--ww-radius-lg)}.ww\:rounded-md{border-radius:var(--ww-radius-md)}.ww\:border{border-style:var(--tw-border-style);border-width:1px}.ww\:border-0{border-style:var(--tw-border-style);border-width:0}.ww\:border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.ww\:border-border{border-color:var(--ww-color-border,#e5e7eb)}.ww\:border-muted-foreground\/50{border-color:var(--ww-color-muted-foreground,#6b7280)}@supports (color:color-mix(in lab, red, red)){.ww\:border-muted-foreground\/50{border-color:color-mix(in oklab,var(--ww-color-muted-foreground,#6b7280)50%,transparent)}}.ww\:bg-accent{background-color:var(--ww-color-accent,#f3f4f6)}.ww\:bg-background,.ww\:bg-background\/20{background-color:var(--ww-color-background,#fff)}@supports (color:color-mix(in lab, red, red)){.ww\:bg-background\/20{background-color:color-mix(in oklab,var(--ww-color-background,#fff)20%,transparent)}}.ww\:bg-foreground{background-color:var(--ww-color-foreground,#1f2937)}.ww\:bg-input{background-color:var(--ww-color-input,#f9fafb)}.ww\:bg-muted{background-color:var(--ww-color-muted,#f1f5f9)}.ww\:bg-muted-foreground\/60{background-color:var(--ww-color-muted-foreground,#6b7280)}@supports (color:color-mix(in lab, red, red)){.ww\:bg-muted-foreground\/60{background-color:color-mix(in oklab,var(--ww-color-muted-foreground,#6b7280)60%,transparent)}}.ww\:bg-muted\/50{background-color:var(--ww-color-muted,#f1f5f9)}@supports (color:color-mix(in lab, red, red)){.ww\:bg-muted\/50{background-color:color-mix(in oklab,var(--ww-color-muted,#f1f5f9)50%,transparent)}}.ww\:bg-primary{background-color:var(--ww-color-primary,#6366f1)}.ww\:bg-tool-card{background-color:var(--ww-color-tool-card,#f4f4f5)}.ww\:bg-transparent{background-color:#0000}.ww\:object-cover{object-fit:cover}.ww\:p-1{padding:calc(var(--ww-spacing)*1)}.ww\:p-3{padding:calc(var(--ww-spacing)*3)}.ww\:px-0{padding-inline:calc(var(--ww-spacing)*0)}.ww\:px-1\.5{padding-inline:calc(var(--ww-spacing)*1.5)}.ww\:px-2{padding-inline:calc(var(--ww-spacing)*2)}.ww\:px-3{padding-inline:calc(var(--ww-spacing)*3)}.ww\:px-4{padding-inline:calc(var(--ww-spacing)*4)}.ww\:px-6{padding-inline:calc(var(--ww-spacing)*6)}.ww\:py-0\.5{padding-block:calc(var(--ww-spacing)*.5)}.ww\:py-1{padding-block:calc(var(--ww-spacing)*1)}.ww\:py-1\.5{padding-block:calc(var(--ww-spacing)*1.5)}.ww\:py-2{padding-block:calc(var(--ww-spacing)*2)}.ww\:py-2\.5{padding-block:calc(var(--ww-spacing)*2.5)}.ww\:py-3{padding-block:calc(var(--ww-spacing)*3)}.ww\:py-6{padding-block:calc(var(--ww-spacing)*6)}.ww\:pt-2{padding-top:calc(var(--ww-spacing)*2)}.ww\:pt-2\.5{padding-top:calc(var(--ww-spacing)*2.5)}.ww\:pt-3{padding-top:calc(var(--ww-spacing)*3)}.ww\:pr-3{padding-right:calc(var(--ww-spacing)*3)}.ww\:pb-1\.5{padding-bottom:calc(var(--ww-spacing)*1.5)}.ww\:pb-3{padding-bottom:calc(var(--ww-spacing)*3)}.ww\:pb-8{padding-bottom:calc(var(--ww-spacing)*8)}.ww\:pl-4{padding-left:calc(var(--ww-spacing)*4)}.ww\:text-left{text-align:left}.ww\:font-\[family-name\:var\(--ww-font\)\]{font-family:var(--ww-font)}.ww\:font-mono{font-family:var(--ww-font-mono)}.ww\:text-base{font-size:var(--ww-text-base);line-height:var(--tw-leading,var(--ww-text-base--line-height))}.ww\:text-sm{font-size:var(--ww-text-sm);line-height:var(--tw-leading,var(--ww-text-sm--line-height))}.ww\:text-xs{font-size:var(--ww-text-xs);line-height:var(--tw-leading,var(--ww-text-xs--line-height))}.ww\:text-\[10px\]{font-size:10px}.ww\:text-\[11px\]{font-size:11px}.ww\:font-medium{--tw-font-weight:var(--ww-font-weight-medium);font-weight:var(--ww-font-weight-medium)}.ww\:font-semibold{--tw-font-weight:var(--ww-font-weight-semibold);font-weight:var(--ww-font-weight-semibold)}.ww\:tracking-wide{--tw-tracking:var(--ww-tracking-wide);letter-spacing:var(--ww-tracking-wide)}.ww\:break-words{overflow-wrap:break-word}.ww\:break-all{word-break:break-all}.ww\:whitespace-pre-wrap{white-space:pre-wrap}.ww\:text-background{color:var(--ww-color-background,#fff)}.ww\:text-foreground,.ww\:text-foreground\/80{color:var(--ww-color-foreground,#1f2937)}@supports (color:color-mix(in lab, red, red)){.ww\:text-foreground\/80{color:color-mix(in oklab,var(--ww-color-foreground,#1f2937)80%,transparent)}}.ww\:text-muted-foreground{color:var(--ww-color-muted-foreground,#6b7280)}.ww\:text-primary{color:var(--ww-color-primary,#6366f1)}.ww\:text-primary-foreground{color:var(--ww-color-primary-foreground,#1f2937)}.ww\:uppercase{text-transform:uppercase}.ww\:opacity-0{opacity:0}.ww\:opacity-100{opacity:1}.ww\:shadow-sm{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a),0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ww\:ring-2{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(2px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ww\:ring-blue-400\/70{--tw-ring-color:var(--ww-color-blue-400)}@supports (color:color-mix(in lab, red, red)){.ww\:ring-blue-400\/70{--tw-ring-color:color-mix(in oklab,var(--ww-color-blue-400)70%,transparent)}}.ww\:ring-offset-2{--tw-ring-offset-width:2px;--tw-ring-offset-shadow:var(--tw-ring-inset,)0 0 0 var(--tw-ring-offset-width)var(--tw-ring-offset-color)}.ww\:ring-offset-background{--tw-ring-offset-color:var(--ww-color-background,#fff)}.ww\:transition-\[grid-template-rows\,opacity\]{transition-property:grid-template-rows,opacity;transition-timing-function:var(--tw-ease,var(--ww-default-transition-timing-function));transition-duration:var(--tw-duration,var(--ww-default-transition-duration))}.ww\:transition-all{transition-property:all;transition-timing-function:var(--tw-ease,var(--ww-default-transition-timing-function));transition-duration:var(--tw-duration,var(--ww-default-transition-duration))}.ww\:transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--ww-default-transition-timing-function));transition-duration:var(--tw-duration,var(--ww-default-transition-duration))}.ww\:transition-opacity{transition-property:opacity;transition-timing-function:var(--tw-ease,var(--ww-default-transition-timing-function));transition-duration:var(--tw-duration,var(--ww-default-transition-duration))}.ww\:transition-transform{transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,var(--ww-default-transition-timing-function));transition-duration:var(--tw-duration,var(--ww-default-transition-duration))}.ww\:duration-150{--tw-duration:.15s;transition-duration:.15s}.ww\:duration-200{--tw-duration:.2s;transition-duration:.2s}.ww\:duration-300{--tw-duration:.3s;transition-duration:.3s}.ww\:ease-out{--tw-ease:var(--ww-ease-out);transition-timing-function:var(--ww-ease-out)}.ww\:outline-none{--tw-outline-style:none;outline-style:none}@media (hover:hover){.ww\:group-hover\:opacity-0:is(:where(.ww\:group):hover *){opacity:0}.ww\:group-hover\:opacity-100:is(:where(.ww\:group):hover *){opacity:1}}.ww\:group-\[\.is-assistant\]\:text-foreground:is(:where(.ww\:group).is-assistant *){color:var(--ww-color-foreground,#1f2937)}.ww\:group-\[\.is-user\]\:ml-auto:is(:where(.ww\:group).is-user *){margin-left:auto}.ww\:group-\[\.is-user\]\:rounded-lg:is(:where(.ww\:group).is-user *){border-radius:var(--ww-radius-lg)}.ww\:group-\[\.is-user\]\:bg-user-bubble:is(:where(.ww\:group).is-user *){background-color:var(--ww-color-user-bubble,#f4f4f4)}.ww\:group-\[\.is-user\]\:px-4:is(:where(.ww\:group).is-user *){padding-inline:calc(var(--ww-spacing)*4)}.ww\:group-\[\.is-user\]\:py-3:is(:where(.ww\:group).is-user *){padding-block:calc(var(--ww-spacing)*3)}.ww\:group-\[\.is-user\]\:text-primary-foreground:is(:where(.ww\:group).is-user *){color:var(--ww-color-primary-foreground,#1f2937)}.ww\:placeholder\:text-muted-foreground::placeholder{color:var(--ww-color-muted-foreground,#6b7280)}@media (hover:hover){.ww\:hover\:border-primary\/30:hover{border-color:var(--ww-color-primary,#6366f1)}@supports (color:color-mix(in lab, red, red)){.ww\:hover\:border-primary\/30:hover{border-color:color-mix(in oklab,var(--ww-color-primary,#6366f1)30%,transparent)}}.ww\:hover\:bg-accent:hover{background-color:var(--ww-color-accent,#f3f4f6)}.ww\:hover\:bg-foreground:hover{background-color:var(--ww-color-foreground,#1f2937)}.ww\:hover\:bg-muted:hover{background-color:var(--ww-color-muted,#f1f5f9)}.ww\:hover\:bg-muted-foreground\/10:hover{background-color:var(--ww-color-muted-foreground,#6b7280)}@supports (color:color-mix(in lab, red, red)){.ww\:hover\:bg-muted-foreground\/10:hover{background-color:color-mix(in oklab,var(--ww-color-muted-foreground,#6b7280)10%,transparent)}}.ww\:hover\:bg-primary\/90:hover{background-color:var(--ww-color-primary,#6366f1)}@supports (color:color-mix(in lab, red, red)){.ww\:hover\:bg-primary\/90:hover{background-color:color-mix(in oklab,var(--ww-color-primary,#6366f1)90%,transparent)}}.ww\:hover\:text-accent-foreground:hover{color:var(--ww-color-accent-foreground,#1f2937)}.ww\:hover\:text-foreground:hover{color:var(--ww-color-foreground,#1f2937)}.ww\:hover\:underline:hover{text-decoration-line:underline}}.ww\:disabled\:pointer-events-none:disabled{pointer-events:none}.ww\:disabled\:opacity-50:disabled{opacity:.5}.ww\:\[\&\>\*\:first-child\]\:mt-0>:first-child{margin-top:calc(var(--ww-spacing)*0)}.ww\:\[\&\>\*\:last-child\]\:mb-0>:last-child{margin-bottom:calc(var(--ww-spacing)*0)}}@keyframes ww-fade-in{0%{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:translateY(0)}}@keyframes ww-fade-out{0%{opacity:1;transform:translateY(0)}to{opacity:0;transform:translateY(-4px)}}@keyframes ww-pulse{0%,80%,to{opacity:.3;transform:scale(.8)}40%{opacity:1;transform:scale(1)}}[data-waniwani-chat] ::-webkit-scrollbar{width:8px}[data-waniwani-chat] ::-webkit-scrollbar-track{background:0 0}[data-waniwani-chat] ::-webkit-scrollbar-thumb{background:var(--ww-color-border);border-radius:9999px}[data-waniwani-chat] ::-webkit-scrollbar-thumb:hover{background:var(--ww-color-muted-foreground)}[data-waniwani-chat] *{scrollbar-width:thin;scrollbar-color:var(--ww-color-border)transparent}[data-waniwani-chat]{--ww-color-background:var(--ww-bg,#fff);--ww-color-foreground:var(--ww-text,#1f2937);--ww-color-primary:var(--ww-primary,#6366f1);--ww-color-primary-foreground:var(--ww-primary-fg,#1f2937);--ww-color-muted-foreground:var(--ww-muted,#6b7280);--ww-color-border:var(--ww-border,#e5e7eb);--ww-color-input:var(--ww-input-bg,#f9fafb);--ww-color-accent:var(--ww-assistant-bubble,#f3f4f6);--ww-color-accent-foreground:var(--ww-text,#1f2937);--ww-color-user-bubble:var(--ww-user-bubble,#f4f4f4);--ww-color-card:var(--ww-bg,#fff);--ww-color-card-foreground:var(--ww-text,#1f2937);--ww-color-card-header:var(--ww-header-bg,#fff);--ww-color-card-header-foreground:var(--ww-header-text,#1f2937);--ww-color-status:var(--ww-status,#22c55e);--ww-color-tool-card:var(--ww-tool-card,#f4f4f5);--ww-radius:var(--ww-radius,16px);--ww-font-sans:var(--ww-font,system-ui,-apple-system,"Segoe UI",sans-serif)}[data-waniwani-chat] [data-streamdown=table-wrapper]{flex-direction:column;gap:.5rem;margin-top:1rem;margin-bottom:1rem;display:flex}[data-waniwani-chat] [data-streamdown=table-wrapper]>div:first-child:has(button){justify-content:flex-end;align-items:center;gap:.25rem;display:flex}[data-waniwani-chat] [data-streamdown=table-wrapper]>div:last-child{overflow-x:auto}[data-waniwani-chat] [data-streamdown=table]{border-collapse:collapse;border:1px solid var(--ww-color-border);border-radius:.75rem;width:100%;overflow:hidden}[data-waniwani-chat] [data-streamdown=table-header]{background-color:var(--ww-color-accent)}@supports (color:color-mix(in lab, red, red)){[data-waniwani-chat] [data-streamdown=table-header]{background-color:color-mix(in srgb,var(--ww-color-accent)80%,transparent)}}[data-waniwani-chat] [data-streamdown=table-body]{background-color:var(--ww-color-accent)}@supports (color:color-mix(in lab, red, red)){[data-waniwani-chat] [data-streamdown=table-body]{background-color:color-mix(in srgb,var(--ww-color-accent)40%,transparent)}}[data-waniwani-chat] [data-streamdown=table-body]>tr+tr{border-top:1px solid var(--ww-color-border)}[data-waniwani-chat] [data-streamdown=table-row]{border-bottom:1px solid var(--ww-color-border)}[data-waniwani-chat] [data-streamdown=table-header-cell]{white-space:nowrap;text-align:left;padding:.5rem 1rem;font-size:.875rem;font-weight:600}[data-waniwani-chat] [data-streamdown=table-cell]{padding:.5rem 1rem;font-size:.875rem}[data-waniwani-chat] [data-streamdown=link]{color:var(--ww-color-primary);overflow-wrap:anywhere;cursor:pointer;font-weight:500;text-decoration:underline}[data-waniwani-chat] [data-streamdown=link-safety-modal]{z-index:50;background-color:var(--ww-color-background);justify-content:center;align-items:center;display:flex;position:fixed;inset:0}@supports (color:color-mix(in lab, red, red)){[data-waniwani-chat] [data-streamdown=link-safety-modal]{background-color:color-mix(in srgb,var(--ww-color-background)50%,transparent)}}[data-waniwani-chat] [data-streamdown=link-safety-modal]{-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px)}[data-waniwani-chat] [data-streamdown=link-safety-modal]>div{border:1px solid var(--ww-color-border);background-color:var(--ww-color-background);width:100%;max-width:28rem;color:var(--ww-color-foreground);border-radius:.75rem;flex-direction:column;gap:1rem;margin:0 1rem;padding:1.5rem;display:flex;position:relative;box-shadow:0 10px 25px #0000001a}[data-waniwani-chat] [data-streamdown=link-safety-modal] button{cursor:pointer}[data-waniwani-chat] [data-streamdown=link-safety-modal]>div>button:first-child{color:var(--ww-color-muted-foreground);background:0 0;border:none;border-radius:.375rem;padding:.25rem;transition:background-color .15s,color .15s;position:absolute;top:1rem;right:1rem}[data-waniwani-chat] [data-streamdown=link-safety-modal]>div>button:first-child:hover{background-color:var(--ww-color-accent);color:var(--ww-color-foreground)}[data-waniwani-chat] [data-streamdown=link-safety-modal]>div>div:first-of-type{flex-direction:column;gap:.5rem;display:flex}[data-waniwani-chat] [data-streamdown=link-safety-modal]>div>div:first-of-type>div{align-items:center;gap:.5rem;font-size:1.125rem;font-weight:600;display:flex}[data-waniwani-chat] [data-streamdown=link-safety-modal]>div>div:first-of-type>p{color:var(--ww-color-muted-foreground);font-size:.875rem}[data-waniwani-chat] [data-streamdown=link-safety-modal]>div>div:nth-child(3){word-break:break-all;background-color:var(--ww-color-accent);border-radius:.375rem;max-height:8rem;padding:.75rem;font-family:ui-monospace,monospace;font-size:.875rem;overflow-y:auto}[data-waniwani-chat] [data-streamdown=link-safety-modal]>div>div:last-child{gap:.5rem;display:flex}[data-waniwani-chat] [data-streamdown=link-safety-modal]>div>div:last-child>button{border:none;border-radius:.375rem;flex:1;justify-content:center;align-items:center;gap:.5rem;padding:.5rem 1rem;font-size:.875rem;font-weight:500;transition:background-color .15s;display:flex}[data-waniwani-chat] [data-streamdown=link-safety-modal]>div>div:last-child>button:first-child{border:1px solid var(--ww-color-border);background-color:var(--ww-color-background);color:var(--ww-color-foreground)}[data-waniwani-chat] [data-streamdown=link-safety-modal]>div>div:last-child>button:first-child:hover{background-color:var(--ww-color-accent)}[data-waniwani-chat] [data-streamdown=link-safety-modal]>div>div:last-child>button:last-child{background-color:var(--ww-color-primary);color:#fff}[data-waniwani-chat] [data-streamdown=link-safety-modal]>div>div:last-child>button:last-child:hover{opacity:.9}[data-waniwani-chat] [data-streamdown=ordered-list]{white-space:normal;list-style-type:decimal;list-style-position:inside}[data-waniwani-chat] li [data-streamdown=ordered-list]{padding-left:1.5rem}[data-waniwani-chat] [data-streamdown=unordered-list]{white-space:normal;list-style-type:disc;list-style-position:inside}[data-waniwani-chat] li [data-streamdown=unordered-list]{padding-left:1.5rem}[data-waniwani-chat] [data-streamdown=list-item]{padding-top:.25rem;padding-bottom:.25rem}[data-waniwani-chat] [data-streamdown=list-item]>p{display:inline}[data-waniwani-chat] [data-streamdown=inline-code]{background-color:var(--ww-color-accent);border-radius:.25rem;padding:.125rem .375rem;font-family:ui-monospace,SFMono-Regular,SF Mono,Menlo,monospace;font-size:.875rem}[data-waniwani-chat] [data-streamdown=heading-1]{margin-top:1.5rem;margin-bottom:.5rem;font-size:1.875rem;font-weight:600;line-height:2.25rem}[data-waniwani-chat] [data-streamdown=heading-2]{margin-top:1.5rem;margin-bottom:.5rem;font-size:1.5rem;font-weight:600;line-height:2rem}[data-waniwani-chat] [data-streamdown=heading-3]{margin-top:1.5rem;margin-bottom:.5rem;font-size:1.25rem;font-weight:600;line-height:1.75rem}[data-waniwani-chat] [data-streamdown=heading-4]{margin-top:1.5rem;margin-bottom:.5rem;font-size:1.125rem;font-weight:600;line-height:1.75rem}[data-waniwani-chat] [data-streamdown=heading-5]{margin-top:1.5rem;margin-bottom:.5rem;font-size:1rem;font-weight:600;line-height:1.5rem}[data-waniwani-chat] [data-streamdown=heading-6]{margin-top:1.5rem;margin-bottom:.5rem;font-size:.875rem;font-weight:600;line-height:1.25rem}[data-waniwani-chat] [data-streamdown=blockquote]{border-left:4px solid var(--ww-color-muted-foreground);margin-top:1rem;margin-bottom:1rem}@supports (color:color-mix(in lab, red, red)){[data-waniwani-chat] [data-streamdown=blockquote]{border-left:4px solid color-mix(in srgb,var(--ww-color-muted-foreground)30%,transparent)}}[data-waniwani-chat] [data-streamdown=blockquote]{color:var(--ww-color-muted-foreground);padding-left:1rem;font-style:italic}[data-waniwani-chat] [data-streamdown=horizontal-rule]{border-color:var(--ww-color-border);margin-top:1.5rem;margin-bottom:1.5rem}[data-waniwani-chat] [data-streamdown=strong]{font-weight:600}[data-waniwani-chat] [data-streamdown=image-wrapper]{margin-top:1rem;margin-bottom:1rem;display:inline-block;position:relative}[data-waniwani-chat] [data-streamdown=image]{border-radius:.5rem;max-width:100%}[data-waniwani-chat] [data-streamdown=code-block]{border:1px solid var(--ww-color-border);border-radius:.75rem;width:100%;margin-top:1rem;margin-bottom:1rem;overflow:hidden}[data-waniwani-chat] [data-streamdown=code-block-header]{background-color:var(--ww-color-accent);justify-content:space-between;align-items:center;display:flex}@supports (color:color-mix(in lab, red, red)){[data-waniwani-chat] [data-streamdown=code-block-header]{background-color:color-mix(in srgb,var(--ww-color-accent)80%,transparent)}}[data-waniwani-chat] [data-streamdown=code-block-header]{color:var(--ww-color-muted-foreground);padding:.75rem;font-size:.75rem}[data-waniwani-chat] [data-streamdown=code-block-body]{padding:1rem;font-size:.875rem;overflow-x:auto}[data-waniwani-chat] [data-streamdown=code-block-copy-button],[data-waniwani-chat] [data-streamdown=code-block-download-button]{cursor:pointer;color:var(--ww-color-muted-foreground);background:0 0;border:none;padding:.25rem;transition:color .15s}[data-waniwani-chat] [data-streamdown=code-block-copy-button]:hover,[data-waniwani-chat] [data-streamdown=code-block-download-button]:hover{color:var(--ww-color-foreground)}[data-waniwani-chat] [data-streamdown=mermaid-block]{border:1px solid var(--ww-color-border);border-radius:.75rem;height:auto;margin-top:1rem;margin-bottom:1rem;padding:1rem;position:relative}[data-waniwani-chat] [data-streamdown=mermaid]{width:100%;height:100%}@property --tw-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-z{syntax:"*";inherits:false;initial-value:0}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"<length>";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-duration{syntax:"*";inherits:false}@property --tw-ease{syntax:"*";inherits:false}@keyframes spin{to{transform:rotate(360deg)}}@keyframes pulse{50%{opacity:.5}}
|
|
2
|
+
@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-space-y-reverse:0;--tw-border-style:solid;--tw-font-weight:initial;--tw-tracking:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-duration:initial;--tw-ease:initial}}}@layer theme{:root,:host{--ww-font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;--ww-color-blue-400:oklch(70.7% .165 254.624);--ww-spacing:.25rem;--ww-container-3xl:48rem;--ww-text-xs:.75rem;--ww-text-xs--line-height:calc(1/.75);--ww-text-sm:.875rem;--ww-text-sm--line-height:calc(1.25/.875);--ww-text-base:1rem;--ww-text-base--line-height:calc(1.5/1);--ww-font-weight-medium:500;--ww-font-weight-semibold:600;--ww-tracking-wide:.025em;--ww-radius-md:.375rem;--ww-radius-lg:.5rem;--ww-radius-2xl:1rem;--ww-ease-out:cubic-bezier(0,0,.2,1);--ww-animate-spin:spin 1s linear infinite;--ww-animate-pulse:pulse 2s cubic-bezier(.4,0,.6,1)infinite;--ww-default-transition-duration:.15s;--ww-default-transition-timing-function:cubic-bezier(.4,0,.2,1);--ww-default-font-family:var(--ww-font-sans,system-ui,-apple-system,"Segoe UI",sans-serif);--ww-default-mono-font-family:var(--ww-font-mono)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--ww-default-font-family,ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji");font-feature-settings:var(--ww-default-font-feature-settings,normal);font-variation-settings:var(--ww-default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--ww-default-mono-font-family,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace);font-feature-settings:var(--ww-default-mono-font-feature-settings,normal);font-variation-settings:var(--ww-default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab, red, red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components;@layer utilities{.ww\:absolute{position:absolute}.ww\:relative{position:relative}.ww\:bottom-4{bottom:calc(var(--ww-spacing)*4)}.ww\:left-\[50\%\]{left:50%}.ww\:mx-auto{margin-inline:auto}.ww\:mt-0\.5{margin-top:calc(var(--ww-spacing)*.5)}.ww\:mt-2{margin-top:calc(var(--ww-spacing)*2)}.ww\:mb-2{margin-bottom:calc(var(--ww-spacing)*2)}.ww\:mb-4{margin-bottom:calc(var(--ww-spacing)*4)}.ww\:ml-auto{margin-left:auto}.ww\:line-clamp-1{-webkit-line-clamp:1;-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}.ww\:contents{display:contents}.ww\:flex{display:flex}.ww\:grid{display:grid}.ww\:hidden{display:none}.ww\:inline-block{display:inline-block}.ww\:inline-flex{display:inline-flex}.ww\:field-sizing-content{field-sizing:content}.ww\:size-2{width:calc(var(--ww-spacing)*2);height:calc(var(--ww-spacing)*2)}.ww\:size-3{width:calc(var(--ww-spacing)*3);height:calc(var(--ww-spacing)*3)}.ww\:size-3\.5{width:calc(var(--ww-spacing)*3.5);height:calc(var(--ww-spacing)*3.5)}.ww\:size-4{width:calc(var(--ww-spacing)*4);height:calc(var(--ww-spacing)*4)}.ww\:size-5{width:calc(var(--ww-spacing)*5);height:calc(var(--ww-spacing)*5)}.ww\:size-7{width:calc(var(--ww-spacing)*7);height:calc(var(--ww-spacing)*7)}.ww\:size-8{width:calc(var(--ww-spacing)*8);height:calc(var(--ww-spacing)*8)}.ww\:size-9{width:calc(var(--ww-spacing)*9);height:calc(var(--ww-spacing)*9)}.ww\:size-auto{width:auto;height:auto}.ww\:size-full{width:100%;height:100%}.ww\:h-7{height:calc(var(--ww-spacing)*7)}.ww\:h-8{height:calc(var(--ww-spacing)*8)}.ww\:h-9{height:calc(var(--ww-spacing)*9)}.ww\:h-16{height:calc(var(--ww-spacing)*16)}.ww\:h-auto{height:auto}.ww\:max-h-48{max-height:calc(var(--ww-spacing)*48)}.ww\:min-h-0{min-height:calc(var(--ww-spacing)*0)}.ww\:min-h-16{min-height:calc(var(--ww-spacing)*16)}.ww\:w-fit{width:fit-content}.ww\:w-full{width:100%}.ww\:max-w-3xl{max-width:var(--ww-container-3xl)}.ww\:max-w-24{max-width:calc(var(--ww-spacing)*24)}.ww\:max-w-32{max-width:calc(var(--ww-spacing)*32)}.ww\:max-w-\[80\%\]{max-width:80%}.ww\:max-w-full{max-width:100%}.ww\:min-w-0{min-width:calc(var(--ww-spacing)*0)}.ww\:flex-1{flex:1}.ww\:shrink-0{flex-shrink:0}.ww\:grow{flex-grow:1}.ww\:translate-x-\[-50\%\]{--tw-translate-x:-50%;translate:var(--tw-translate-x)var(--tw-translate-y)}.ww\:rotate-90{rotate:90deg}.ww\:rotate-180{rotate:180deg}.ww\:animate-\[ww-fade-in_0\.2s_ease-out_both\]{animation:.2s ease-out both ww-fade-in}.ww\:animate-pulse{animation:var(--ww-animate-pulse)}.ww\:animate-spin{animation:var(--ww-animate-spin)}.ww\:cursor-pointer{cursor:pointer}.ww\:resize-none{resize:none}.ww\:grid-rows-\[0fr\]{grid-template-rows:0fr}.ww\:grid-rows-\[1fr\]{grid-template-rows:1fr}.ww\:flex-col{flex-direction:column}.ww\:flex-wrap{flex-wrap:wrap}.ww\:items-center{align-items:center}.ww\:items-end{align-items:flex-end}.ww\:items-start{align-items:flex-start}.ww\:justify-between{justify-content:space-between}.ww\:justify-center{justify-content:center}.ww\:gap-1{gap:calc(var(--ww-spacing)*1)}.ww\:gap-1\.5{gap:calc(var(--ww-spacing)*1.5)}.ww\:gap-2{gap:calc(var(--ww-spacing)*2)}.ww\:gap-3{gap:calc(var(--ww-spacing)*3)}.ww\:gap-6{gap:calc(var(--ww-spacing)*6)}:where(.ww\:space-y-2>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--ww-spacing)*2)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--ww-spacing)*2)*calc(1 - var(--tw-space-y-reverse)))}:where(.ww\:space-y-3>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--ww-spacing)*3)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--ww-spacing)*3)*calc(1 - var(--tw-space-y-reverse)))}.ww\:truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.ww\:overflow-hidden{overflow:hidden}.ww\:overflow-x-auto{overflow-x:auto}.ww\:overflow-y-hidden{overflow-y:hidden}.ww\:rounded{border-radius:var(--ww-radius,16px)}.ww\:rounded-2xl{border-radius:var(--ww-radius-2xl)}.ww\:rounded-\[var\(--ww-radius\)\]{border-radius:var(--ww-radius)}.ww\:rounded-full{border-radius:3.40282e38px}.ww\:rounded-lg{border-radius:var(--ww-radius-lg)}.ww\:rounded-md{border-radius:var(--ww-radius-md)}.ww\:border{border-style:var(--tw-border-style);border-width:1px}.ww\:border-0{border-style:var(--tw-border-style);border-width:0}.ww\:border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.ww\:border-border{border-color:var(--ww-color-border,#e5e7eb)}.ww\:border-current\/20{border-color:currentColor}@supports (color:color-mix(in lab, red, red)){.ww\:border-current\/20{border-color:color-mix(in oklab,currentcolor 20%,transparent)}}.ww\:border-muted-foreground\/50{border-color:var(--ww-color-muted-foreground,#6b7280)}@supports (color:color-mix(in lab, red, red)){.ww\:border-muted-foreground\/50{border-color:color-mix(in oklab,var(--ww-color-muted-foreground,#6b7280)50%,transparent)}}.ww\:bg-accent{background-color:var(--ww-color-accent,#f3f4f6)}.ww\:bg-background,.ww\:bg-background\/20{background-color:var(--ww-color-background,#fff)}@supports (color:color-mix(in lab, red, red)){.ww\:bg-background\/20{background-color:color-mix(in oklab,var(--ww-color-background,#fff)20%,transparent)}}.ww\:bg-foreground{background-color:var(--ww-color-foreground,#1f2937)}.ww\:bg-input{background-color:var(--ww-color-input,#f9fafb)}.ww\:bg-muted{background-color:var(--ww-color-muted,#f1f5f9)}.ww\:bg-muted-foreground\/60{background-color:var(--ww-color-muted-foreground,#6b7280)}@supports (color:color-mix(in lab, red, red)){.ww\:bg-muted-foreground\/60{background-color:color-mix(in oklab,var(--ww-color-muted-foreground,#6b7280)60%,transparent)}}.ww\:bg-muted\/50{background-color:var(--ww-color-muted,#f1f5f9)}@supports (color:color-mix(in lab, red, red)){.ww\:bg-muted\/50{background-color:color-mix(in oklab,var(--ww-color-muted,#f1f5f9)50%,transparent)}}.ww\:bg-primary{background-color:var(--ww-color-primary,#6366f1)}.ww\:bg-tool-card{background-color:var(--ww-color-tool-card,#f4f4f5)}.ww\:bg-transparent{background-color:#0000}.ww\:object-cover{object-fit:cover}.ww\:p-1{padding:calc(var(--ww-spacing)*1)}.ww\:p-3{padding:calc(var(--ww-spacing)*3)}.ww\:px-0{padding-inline:calc(var(--ww-spacing)*0)}.ww\:px-1\.5{padding-inline:calc(var(--ww-spacing)*1.5)}.ww\:px-2{padding-inline:calc(var(--ww-spacing)*2)}.ww\:px-3{padding-inline:calc(var(--ww-spacing)*3)}.ww\:px-4{padding-inline:calc(var(--ww-spacing)*4)}.ww\:px-6{padding-inline:calc(var(--ww-spacing)*6)}.ww\:py-0\.5{padding-block:calc(var(--ww-spacing)*.5)}.ww\:py-1{padding-block:calc(var(--ww-spacing)*1)}.ww\:py-1\.5{padding-block:calc(var(--ww-spacing)*1.5)}.ww\:py-2{padding-block:calc(var(--ww-spacing)*2)}.ww\:py-2\.5{padding-block:calc(var(--ww-spacing)*2.5)}.ww\:py-3{padding-block:calc(var(--ww-spacing)*3)}.ww\:py-6{padding-block:calc(var(--ww-spacing)*6)}.ww\:pt-2{padding-top:calc(var(--ww-spacing)*2)}.ww\:pt-2\.5{padding-top:calc(var(--ww-spacing)*2.5)}.ww\:pt-3{padding-top:calc(var(--ww-spacing)*3)}.ww\:pr-3{padding-right:calc(var(--ww-spacing)*3)}.ww\:pb-1\.5{padding-bottom:calc(var(--ww-spacing)*1.5)}.ww\:pb-3{padding-bottom:calc(var(--ww-spacing)*3)}.ww\:pb-8{padding-bottom:calc(var(--ww-spacing)*8)}.ww\:pl-4{padding-left:calc(var(--ww-spacing)*4)}.ww\:text-left{text-align:left}.ww\:font-\[family-name\:var\(--ww-font\)\]{font-family:var(--ww-font)}.ww\:font-mono{font-family:var(--ww-font-mono)}.ww\:text-base{font-size:var(--ww-text-base);line-height:var(--tw-leading,var(--ww-text-base--line-height))}.ww\:text-sm{font-size:var(--ww-text-sm);line-height:var(--tw-leading,var(--ww-text-sm--line-height))}.ww\:text-xs{font-size:var(--ww-text-xs);line-height:var(--tw-leading,var(--ww-text-xs--line-height))}.ww\:text-\[10px\]{font-size:10px}.ww\:text-\[11px\]{font-size:11px}.ww\:font-medium{--tw-font-weight:var(--ww-font-weight-medium);font-weight:var(--ww-font-weight-medium)}.ww\:font-semibold{--tw-font-weight:var(--ww-font-weight-semibold);font-weight:var(--ww-font-weight-semibold)}.ww\:tracking-wide{--tw-tracking:var(--ww-tracking-wide);letter-spacing:var(--ww-tracking-wide)}.ww\:break-words{overflow-wrap:break-word}.ww\:break-all{word-break:break-all}.ww\:whitespace-pre-wrap{white-space:pre-wrap}.ww\:text-background{color:var(--ww-color-background,#fff)}.ww\:text-foreground,.ww\:text-foreground\/80{color:var(--ww-color-foreground,#1f2937)}@supports (color:color-mix(in lab, red, red)){.ww\:text-foreground\/80{color:color-mix(in oklab,var(--ww-color-foreground,#1f2937)80%,transparent)}}.ww\:text-muted-foreground{color:var(--ww-color-muted-foreground,#6b7280)}.ww\:text-primary{color:var(--ww-color-primary,#6366f1)}.ww\:text-primary-foreground{color:var(--ww-color-primary-foreground,#1f2937)}.ww\:uppercase{text-transform:uppercase}.ww\:opacity-0{opacity:0}.ww\:opacity-60{opacity:.6}.ww\:opacity-100{opacity:1}.ww\:shadow-sm{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a),0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ww\:ring-2{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(2px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ww\:ring-blue-400\/70{--tw-ring-color:var(--ww-color-blue-400)}@supports (color:color-mix(in lab, red, red)){.ww\:ring-blue-400\/70{--tw-ring-color:color-mix(in oklab,var(--ww-color-blue-400)70%,transparent)}}.ww\:ring-offset-2{--tw-ring-offset-width:2px;--tw-ring-offset-shadow:var(--tw-ring-inset,)0 0 0 var(--tw-ring-offset-width)var(--tw-ring-offset-color)}.ww\:ring-offset-background{--tw-ring-offset-color:var(--ww-color-background,#fff)}.ww\:transition-\[grid-template-rows\,opacity\]{transition-property:grid-template-rows,opacity;transition-timing-function:var(--tw-ease,var(--ww-default-transition-timing-function));transition-duration:var(--tw-duration,var(--ww-default-transition-duration))}.ww\:transition-all{transition-property:all;transition-timing-function:var(--tw-ease,var(--ww-default-transition-timing-function));transition-duration:var(--tw-duration,var(--ww-default-transition-duration))}.ww\:transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--ww-default-transition-timing-function));transition-duration:var(--tw-duration,var(--ww-default-transition-duration))}.ww\:transition-opacity{transition-property:opacity;transition-timing-function:var(--tw-ease,var(--ww-default-transition-timing-function));transition-duration:var(--tw-duration,var(--ww-default-transition-duration))}.ww\:transition-transform{transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,var(--ww-default-transition-timing-function));transition-duration:var(--tw-duration,var(--ww-default-transition-duration))}.ww\:duration-150{--tw-duration:.15s;transition-duration:.15s}.ww\:duration-200{--tw-duration:.2s;transition-duration:.2s}.ww\:duration-300{--tw-duration:.3s;transition-duration:.3s}.ww\:ease-out{--tw-ease:var(--ww-ease-out);transition-timing-function:var(--ww-ease-out)}.ww\:outline-none{--tw-outline-style:none;outline-style:none}@media (hover:hover){.ww\:group-hover\:opacity-0:is(:where(.ww\:group):hover *){opacity:0}.ww\:group-hover\:opacity-100:is(:where(.ww\:group):hover *){opacity:1}}.ww\:group-\[\.is-assistant\]\:text-foreground:is(:where(.ww\:group).is-assistant *){color:var(--ww-color-foreground,#1f2937)}.ww\:group-\[\.is-user\]\:ml-auto:is(:where(.ww\:group).is-user *){margin-left:auto}.ww\:group-\[\.is-user\]\:rounded-lg:is(:where(.ww\:group).is-user *){border-radius:var(--ww-radius-lg)}.ww\:group-\[\.is-user\]\:bg-user-bubble:is(:where(.ww\:group).is-user *){background-color:var(--ww-color-user-bubble,#f4f4f4)}.ww\:group-\[\.is-user\]\:px-4:is(:where(.ww\:group).is-user *){padding-inline:calc(var(--ww-spacing)*4)}.ww\:group-\[\.is-user\]\:py-3:is(:where(.ww\:group).is-user *){padding-block:calc(var(--ww-spacing)*3)}.ww\:group-\[\.is-user\]\:text-primary-foreground:is(:where(.ww\:group).is-user *){color:var(--ww-color-primary-foreground,#1f2937)}.ww\:placeholder\:text-muted-foreground::placeholder{color:var(--ww-color-muted-foreground,#6b7280)}@media (hover:hover){.ww\:hover\:border-primary\/30:hover{border-color:var(--ww-color-primary,#6366f1)}@supports (color:color-mix(in lab, red, red)){.ww\:hover\:border-primary\/30:hover{border-color:color-mix(in oklab,var(--ww-color-primary,#6366f1)30%,transparent)}}.ww\:hover\:bg-accent:hover{background-color:var(--ww-color-accent,#f3f4f6)}.ww\:hover\:bg-foreground:hover{background-color:var(--ww-color-foreground,#1f2937)}.ww\:hover\:bg-muted:hover{background-color:var(--ww-color-muted,#f1f5f9)}.ww\:hover\:bg-muted-foreground\/10:hover{background-color:var(--ww-color-muted-foreground,#6b7280)}@supports (color:color-mix(in lab, red, red)){.ww\:hover\:bg-muted-foreground\/10:hover{background-color:color-mix(in oklab,var(--ww-color-muted-foreground,#6b7280)10%,transparent)}}.ww\:hover\:bg-primary\/90:hover{background-color:var(--ww-color-primary,#6366f1)}@supports (color:color-mix(in lab, red, red)){.ww\:hover\:bg-primary\/90:hover{background-color:color-mix(in oklab,var(--ww-color-primary,#6366f1)90%,transparent)}}.ww\:hover\:text-accent-foreground:hover{color:var(--ww-color-accent-foreground,#1f2937)}.ww\:hover\:text-foreground:hover{color:var(--ww-color-foreground,#1f2937)}.ww\:hover\:underline:hover{text-decoration-line:underline}}.ww\:disabled\:pointer-events-none:disabled{pointer-events:none}.ww\:disabled\:opacity-50:disabled{opacity:.5}.ww\:\[\&\>\*\:first-child\]\:mt-0>:first-child{margin-top:calc(var(--ww-spacing)*0)}.ww\:\[\&\>\*\:last-child\]\:mb-0>:last-child{margin-bottom:calc(var(--ww-spacing)*0)}}@keyframes ww-fade-in{0%{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:translateY(0)}}@keyframes ww-fade-out{0%{opacity:1;transform:translateY(0)}to{opacity:0;transform:translateY(-4px)}}@keyframes ww-pulse{0%,80%,to{opacity:.3;transform:scale(.8)}40%{opacity:1;transform:scale(1)}}[data-waniwani-chat] ::-webkit-scrollbar{width:8px}[data-waniwani-chat] ::-webkit-scrollbar-track{background:0 0}[data-waniwani-chat] ::-webkit-scrollbar-thumb{background:var(--ww-color-border);border-radius:9999px}[data-waniwani-chat] ::-webkit-scrollbar-thumb:hover{background:var(--ww-color-muted-foreground)}[data-waniwani-chat] *{scrollbar-width:thin;scrollbar-color:var(--ww-color-border)transparent}[data-waniwani-chat]{--ww-color-background:var(--ww-bg,#fff);--ww-color-foreground:var(--ww-text,#1f2937);--ww-color-primary:var(--ww-primary,#6366f1);--ww-color-primary-foreground:var(--ww-primary-fg,#1f2937);--ww-color-muted-foreground:var(--ww-muted,#6b7280);--ww-color-border:var(--ww-border,#e5e7eb);--ww-color-input:var(--ww-input-bg,#f9fafb);--ww-color-accent:var(--ww-assistant-bubble,#f3f4f6);--ww-color-accent-foreground:var(--ww-text,#1f2937);--ww-color-user-bubble:var(--ww-user-bubble,#f4f4f4);--ww-color-card:var(--ww-bg,#fff);--ww-color-card-foreground:var(--ww-text,#1f2937);--ww-color-card-header:var(--ww-header-bg,#fff);--ww-color-card-header-foreground:var(--ww-header-text,#1f2937);--ww-color-status:var(--ww-status,#22c55e);--ww-color-tool-card:var(--ww-tool-card,#f4f4f5);--ww-radius:var(--ww-radius,16px);--ww-font-sans:var(--ww-font,system-ui,-apple-system,"Segoe UI",sans-serif)}[data-waniwani-chat] [data-streamdown=table-wrapper]{flex-direction:column;gap:.5rem;margin-top:1rem;margin-bottom:1rem;display:flex}[data-waniwani-chat] [data-streamdown=table-wrapper]>div:first-child:has(button){justify-content:flex-end;align-items:center;gap:.25rem;display:flex}[data-waniwani-chat] [data-streamdown=table-wrapper]>div:last-child{overflow-x:auto}[data-waniwani-chat] [data-streamdown=table]{border-collapse:collapse;border:1px solid var(--ww-color-border);border-radius:.75rem;width:100%;overflow:hidden}[data-waniwani-chat] [data-streamdown=table-header]{background-color:var(--ww-color-accent)}@supports (color:color-mix(in lab, red, red)){[data-waniwani-chat] [data-streamdown=table-header]{background-color:color-mix(in srgb,var(--ww-color-accent)80%,transparent)}}[data-waniwani-chat] [data-streamdown=table-body]{background-color:var(--ww-color-accent)}@supports (color:color-mix(in lab, red, red)){[data-waniwani-chat] [data-streamdown=table-body]{background-color:color-mix(in srgb,var(--ww-color-accent)40%,transparent)}}[data-waniwani-chat] [data-streamdown=table-body]>tr+tr{border-top:1px solid var(--ww-color-border)}[data-waniwani-chat] [data-streamdown=table-row]{border-bottom:1px solid var(--ww-color-border)}[data-waniwani-chat] [data-streamdown=table-header-cell]{white-space:nowrap;text-align:left;padding:.5rem 1rem;font-size:.875rem;font-weight:600}[data-waniwani-chat] [data-streamdown=table-cell]{padding:.5rem 1rem;font-size:.875rem}[data-waniwani-chat] [data-streamdown=link]{color:var(--ww-color-primary);overflow-wrap:anywhere;cursor:pointer;font-weight:500;text-decoration:underline}[data-waniwani-chat] [data-streamdown=link-safety-modal]{z-index:50;background-color:var(--ww-color-background);justify-content:center;align-items:center;display:flex;position:fixed;inset:0}@supports (color:color-mix(in lab, red, red)){[data-waniwani-chat] [data-streamdown=link-safety-modal]{background-color:color-mix(in srgb,var(--ww-color-background)50%,transparent)}}[data-waniwani-chat] [data-streamdown=link-safety-modal]{-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px)}[data-waniwani-chat] [data-streamdown=link-safety-modal]>div{border:1px solid var(--ww-color-border);background-color:var(--ww-color-background);width:100%;max-width:28rem;color:var(--ww-color-foreground);border-radius:.75rem;flex-direction:column;gap:1rem;margin:0 1rem;padding:1.5rem;display:flex;position:relative;box-shadow:0 10px 25px #0000001a}[data-waniwani-chat] [data-streamdown=link-safety-modal] button{cursor:pointer}[data-waniwani-chat] [data-streamdown=link-safety-modal]>div>button:first-child{color:var(--ww-color-muted-foreground);background:0 0;border:none;border-radius:.375rem;padding:.25rem;transition:background-color .15s,color .15s;position:absolute;top:1rem;right:1rem}[data-waniwani-chat] [data-streamdown=link-safety-modal]>div>button:first-child:hover{background-color:var(--ww-color-accent);color:var(--ww-color-foreground)}[data-waniwani-chat] [data-streamdown=link-safety-modal]>div>div:first-of-type{flex-direction:column;gap:.5rem;display:flex}[data-waniwani-chat] [data-streamdown=link-safety-modal]>div>div:first-of-type>div{align-items:center;gap:.5rem;font-size:1.125rem;font-weight:600;display:flex}[data-waniwani-chat] [data-streamdown=link-safety-modal]>div>div:first-of-type>p{color:var(--ww-color-muted-foreground);font-size:.875rem}[data-waniwani-chat] [data-streamdown=link-safety-modal]>div>div:nth-child(3){word-break:break-all;background-color:var(--ww-color-accent);border-radius:.375rem;max-height:8rem;padding:.75rem;font-family:ui-monospace,monospace;font-size:.875rem;overflow-y:auto}[data-waniwani-chat] [data-streamdown=link-safety-modal]>div>div:last-child{gap:.5rem;display:flex}[data-waniwani-chat] [data-streamdown=link-safety-modal]>div>div:last-child>button{border:none;border-radius:.375rem;flex:1;justify-content:center;align-items:center;gap:.5rem;padding:.5rem 1rem;font-size:.875rem;font-weight:500;transition:background-color .15s;display:flex}[data-waniwani-chat] [data-streamdown=link-safety-modal]>div>div:last-child>button:first-child{border:1px solid var(--ww-color-border);background-color:var(--ww-color-background);color:var(--ww-color-foreground)}[data-waniwani-chat] [data-streamdown=link-safety-modal]>div>div:last-child>button:first-child:hover{background-color:var(--ww-color-accent)}[data-waniwani-chat] [data-streamdown=link-safety-modal]>div>div:last-child>button:last-child{background-color:var(--ww-color-primary);color:#fff}[data-waniwani-chat] [data-streamdown=link-safety-modal]>div>div:last-child>button:last-child:hover{opacity:.9}[data-waniwani-chat] [data-streamdown=ordered-list]{white-space:normal;list-style-type:decimal;list-style-position:inside}[data-waniwani-chat] li [data-streamdown=ordered-list]{padding-left:1.5rem}[data-waniwani-chat] [data-streamdown=unordered-list]{white-space:normal;list-style-type:disc;list-style-position:inside}[data-waniwani-chat] li [data-streamdown=unordered-list]{padding-left:1.5rem}[data-waniwani-chat] [data-streamdown=list-item]{padding-top:.25rem;padding-bottom:.25rem}[data-waniwani-chat] [data-streamdown=list-item]>p{display:inline}[data-waniwani-chat] [data-streamdown=inline-code]{background-color:var(--ww-color-accent);border-radius:.25rem;padding:.125rem .375rem;font-family:ui-monospace,SFMono-Regular,SF Mono,Menlo,monospace;font-size:.875rem}[data-waniwani-chat] [data-streamdown=heading-1]{margin-top:1.5rem;margin-bottom:.5rem;font-size:1.875rem;font-weight:600;line-height:2.25rem}[data-waniwani-chat] [data-streamdown=heading-2]{margin-top:1.5rem;margin-bottom:.5rem;font-size:1.5rem;font-weight:600;line-height:2rem}[data-waniwani-chat] [data-streamdown=heading-3]{margin-top:1.5rem;margin-bottom:.5rem;font-size:1.25rem;font-weight:600;line-height:1.75rem}[data-waniwani-chat] [data-streamdown=heading-4]{margin-top:1.5rem;margin-bottom:.5rem;font-size:1.125rem;font-weight:600;line-height:1.75rem}[data-waniwani-chat] [data-streamdown=heading-5]{margin-top:1.5rem;margin-bottom:.5rem;font-size:1rem;font-weight:600;line-height:1.5rem}[data-waniwani-chat] [data-streamdown=heading-6]{margin-top:1.5rem;margin-bottom:.5rem;font-size:.875rem;font-weight:600;line-height:1.25rem}[data-waniwani-chat] [data-streamdown=blockquote]{border-left:4px solid var(--ww-color-muted-foreground);margin-top:1rem;margin-bottom:1rem}@supports (color:color-mix(in lab, red, red)){[data-waniwani-chat] [data-streamdown=blockquote]{border-left:4px solid color-mix(in srgb,var(--ww-color-muted-foreground)30%,transparent)}}[data-waniwani-chat] [data-streamdown=blockquote]{color:var(--ww-color-muted-foreground);padding-left:1rem;font-style:italic}[data-waniwani-chat] [data-streamdown=horizontal-rule]{border-color:var(--ww-color-border);margin-top:1.5rem;margin-bottom:1.5rem}[data-waniwani-chat] [data-streamdown=strong]{font-weight:600}[data-waniwani-chat] [data-streamdown=image-wrapper]{margin-top:1rem;margin-bottom:1rem;display:inline-block;position:relative}[data-waniwani-chat] [data-streamdown=image]{border-radius:.5rem;max-width:100%}[data-waniwani-chat] [data-streamdown=code-block]{border:1px solid var(--ww-color-border);border-radius:.75rem;width:100%;margin-top:1rem;margin-bottom:1rem;overflow:hidden}[data-waniwani-chat] [data-streamdown=code-block-header]{background-color:var(--ww-color-accent);justify-content:space-between;align-items:center;display:flex}@supports (color:color-mix(in lab, red, red)){[data-waniwani-chat] [data-streamdown=code-block-header]{background-color:color-mix(in srgb,var(--ww-color-accent)80%,transparent)}}[data-waniwani-chat] [data-streamdown=code-block-header]{color:var(--ww-color-muted-foreground);padding:.75rem;font-size:.75rem}[data-waniwani-chat] [data-streamdown=code-block-body]{padding:1rem;font-size:.875rem;overflow-x:auto}[data-waniwani-chat] [data-streamdown=code-block-copy-button],[data-waniwani-chat] [data-streamdown=code-block-download-button]{cursor:pointer;color:var(--ww-color-muted-foreground);background:0 0;border:none;padding:.25rem;transition:color .15s}[data-waniwani-chat] [data-streamdown=code-block-copy-button]:hover,[data-waniwani-chat] [data-streamdown=code-block-download-button]:hover{color:var(--ww-color-foreground)}[data-waniwani-chat] [data-streamdown=mermaid-block]{border:1px solid var(--ww-color-border);border-radius:.75rem;height:auto;margin-top:1rem;margin-bottom:1rem;padding:1rem;position:relative}[data-waniwani-chat] [data-streamdown=mermaid]{width:100%;height:100%}@property --tw-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-z{syntax:"*";inherits:false;initial-value:0}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"<length>";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-duration{syntax:"*";inherits:false}@property --tw-ease{syntax:"*";inherits:false}@keyframes spin{to{transform:rotate(360deg)}}@keyframes pulse{50%{opacity:.5}}
|
package/dist/mcp/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
function
|
|
1
|
+
function L(){return typeof window<"u"&&"openai"in window?"openai":"mcp-apps"}function Pe(){return L()==="openai"}function We(){return L()==="mcp-apps"}var I="__start__",C="__end__",re=Symbol.for("waniwani.flow.interrupt"),oe=Symbol.for("waniwani.flow.widget");function ie(e,t){let n=t?.context,r=[];for(let[o,a]of Object.entries(e))if(typeof a=="object"&&a!==null&&"question"in a){let i=a;r.push({question:i.question,field:o,suggestions:i.suggestions,context:i.context,validate:i.validate})}return{__type:re,questions:r,context:n}}function se(e,t){return{__type:oe,tool:e,...t}}function ae(e){return typeof e=="object"&&e!==null&&"__type"in e&&e.__type===re}function ce(e){return typeof e=="object"&&e!==null&&"__type"in e&&e.__type===oe}import{z as U}from"zod";var Ae=["waniwani/sessionId","openai/sessionId","sessionId","conversationId","anthropic/sessionId"];function F(e){if(e)for(let t of Ae){let n=e[t];if(typeof n=="string"&&n.length>0)return n}}function K(e){return e!=null&&e!==""}async function _(e,t){return e.type==="direct"?e.to:e.condition(t)}function de(e,t,n,r){if(e.every(u=>K(r[u.field])))return null;let o=e.filter(u=>!K(r[u.field])),a=o.length===1,i=o[0];return{content:a&&i?{status:"interrupt",question:i.question,field:i.field,...i.suggestions?{suggestions:i.suggestions}:{},...i.context||t?{context:i.context??t}:{}}:{status:"interrupt",questions:o,...t?{context:t}:{}},flowTokenContent:{step:n,state:r,...a&&i?{field:i.field}:{}}}}async function A(e,t,n,r,o,a){let i=e,s={...t},u=50,c=0;for(;c++<u;){if(i===C)return{content:{status:"complete"},flowTokenContent:{state:s}};let f=n.get(i);if(!f)return{content:{status:"error",error:`Unknown node: "${i}"`}};try{let d=await f({state:s,meta:a,interrupt:ie,showWidget:se});if(ae(d)){for(let g of d.questions)g.validate&&o.set(`${i}:${g.field}`,g.validate);let p=de(d.questions,d.context,i,s);if(p)return p;for(let g of d.questions){let x=o.get(`${i}:${g.field}`);if(x)try{let k=s[g.field],R=await x(k);R&&typeof R=="object"&&(s={...s,...R})}catch(k){let R=k instanceof Error?k.message:String(k);delete s[g.field];let T=d.questions.map(E=>E.field===g.field?{...E,context:E.context?`ERROR: ${R}
|
|
2
2
|
|
|
3
|
-
${E.context}`:`ERROR: ${R}`}:E),b=
|
|
4
|
-
`)}var
|
|
5
|
-
${o}`,i=e.store??new F,s=new Map;async function u(c,f,l){if(c.action==="start"){let d=r.get(I);if(!d)return{content:{status:"error",error:"No start edge"}};let y={...c.stateUpdates??{}},p=await _(d,y);return W(p,y,n,r,s,l)}if(c.action==="continue"){if(!f)return{content:{status:"error",error:"No session ID available for continue action."}};let d=await i.get(f);if(!d)return{content:{status:"error",error:"Flow state not found. The flow may have expired."}};let y=d.state,p=d.step;if(!p)return{content:{status:"error",error:"Flow state is missing the current step. The flow may have expired."}};let w={...y,...c.stateUpdates??{}};if(d.widgetId){let g=r.get(p);if(!g)return{content:{status:"error",error:`No edge from step "${p}"`}};let x=await _(g,w);return W(x,w,n,r,s,l)}return W(p,w,n,r,s,l)}return{content:{status:"error",error:`Unknown action: "${c.action}"`}}}return{id:t.id,title:t.title,description:a,async register(c){c.registerTool(t.id,{title:t.title,description:a,inputSchema:Ue,annotations:t.annotations},(async(f,l)=>{let y=l._meta??{},p=ae(y),w=await u(f,p,y);return w.flowTokenContent&&p&&await i.set(p,w.flowTokenContent),{content:[{type:"text",text:JSON.stringify(w.content,null,2)}],_meta:y,...w.content.status==="error"?{isError:!0}:{}}}))}}}var M=class{nodes=new Map;edges=new Map;config;constructor(t){this.config=t}addNode(t,n){if(t===I||t===C)throw new Error(`"${t}" is a reserved name and cannot be used as a node name`);if(this.nodes.has(t))throw new Error(`Node "${t}" already exists`);return this.nodes.set(t,n),this}addEdge(t,n){if(this.edges.has(t))throw new Error(`Node "${t}" already has an outgoing edge. Use addConditionalEdge for branching.`);return this.edges.set(t,{type:"direct",to:n}),this}addConditionalEdge(t,n){if(this.edges.has(t))throw new Error(`Node "${t}" already has an outgoing edge.`);return this.edges.set(t,{type:"conditional",condition:n}),this}compile(t){return this.validate(),ue({config:this.config,nodes:new Map(this.nodes),edges:new Map(this.edges),store:t?.store})}validate(){if(!this.edges.has(I))throw new Error('Flow must have an entry point. Add an edge from START: .addEdge(START, "first_node")');let t=this.edges.get(I);if(t?.type==="direct"&&t.to!==C&&!this.nodes.has(t.to))throw new Error(`START edge references non-existent node: "${t.to}"`);for(let[n,r]of this.edges){if(n!==I&&!this.nodes.has(n))throw new Error(`Edge from non-existent node: "${n}"`);if(r.type==="direct"&&r.to!==C&&!this.nodes.has(r.to))throw new Error(`Edge from "${n}" references non-existent node: "${r.to}"`)}for(let[n]of this.nodes)if(!this.edges.has(n))throw new Error(`Node "${n}" has no outgoing edge. Add one with .addEdge("${n}", ...) or .addConditionalEdge("${n}", ...)`)}};function le(e){return new M(e)}function pe(e){let t=e.content;return JSON.parse(t[0]?.text??"")}async function fe(e,t){let n=t?.stateStore,r=[],o=`test-session-${Math.random().toString(36).slice(2,10)}`,a={registerTool:(...c)=>{r.push(c)}};await e.register(a);let i=r[0]?.[2];if(!i)throw new Error(`Flow "${e.id}" did not register a handler`);let s={_meta:{sessionId:o}};async function u(c){return{...c,decodedState:n?await n.get(o):null}}return{async start(c){let f=await i({action:"start",...c?{stateUpdates:c}:{}},s);return u(pe(f))},async continueWith(c){let f=await i({action:"continue",...c?{stateUpdates:c}:{}},s);return u(pe(f))},async lastState(){return n?n.get(o):null}}}var U="text/html+skybridge",D="text/html;profile=mcp-app",ge=async(e,t)=>{let n=e.endsWith("/")?e.slice(0,-1):e;return await(await fetch(`${n}${t}`)).text()};function me(e){return{"openai/widgetDescription":e.description,"openai/widgetPrefersBorder":e.prefersBorder,"openai/widgetDomain":e.widgetDomain,...e.widgetCSP&&{"openai/widgetCSP":e.widgetCSP}}}function he(e){let t=e.widgetCSP?{connectDomains:e.widgetCSP.connect_domains,resourceDomains:e.widgetCSP.resource_domains,frameDomains:e.widgetCSP.frame_domains,redirectDomains:e.widgetCSP.redirect_domains}:void 0;return{ui:{...t&&{csp:t},...e.widgetDomain&&{domain:e.widgetDomain},...e.prefersBorder!==void 0&&{prefersBorder:e.prefersBorder}}}}function H(e){return{...e.openaiTemplateUri&&{"openai/outputTemplate":e.openaiTemplateUri},"openai/toolInvocation/invoking":e.invoking,"openai/toolInvocation/invoked":e.invoked,"openai/widgetAccessible":!0,"openai/resultCanProduceWidget":!0,...e.mcpTemplateUri&&{ui:{resourceUri:e.mcpTemplateUri,...e.autoHeight&&{autoHeight:!0}}}}}function we(e){let{id:t,title:n,description:r,baseUrl:o,htmlPath:a,widgetDomain:i,prefersBorder:s=!0,autoHeight:u=!0}=e,c=e.widgetCSP??{connect_domains:[o],resource_domains:[o]};if(process.env.NODE_ENV==="development")try{let{hostname:g}=new URL(o);(g==="localhost"||g==="127.0.0.1")&&(c={...c,connect_domains:[...c.connect_domains||[],`ws://${g}:*`,`wss://${g}:*`],resource_domains:[...c.resource_domains||[],`http://${g}:*`]})}catch{}let f=`ui://widgets/apps-sdk/${t}.html`,l=`ui://widgets/ext-apps/${t}.html`,d=null,y=()=>(d||(d=ge(o,a)),d),p=r;async function w(g){let x=await y();g.registerResource(`${t}-openai-widget`,f,{title:n,description:p,mimeType:U,_meta:{"openai/widgetDescription":p,"openai/widgetPrefersBorder":s}},async k=>({contents:[{uri:k.href,mimeType:U,text:x,_meta:me({description:p,prefersBorder:s,widgetDomain:i,widgetCSP:c})}]})),g.registerResource(`${t}-mcp-widget`,l,{title:n,description:p,mimeType:D,_meta:{ui:{prefersBorder:s}}},async k=>({contents:[{uri:k.href,mimeType:D,text:x,_meta:he({description:p,prefersBorder:s,widgetCSP:c})}]}))}return{id:t,title:n,description:r,openaiUri:f,mcpUri:l,autoHeight:u,register:w}}function De(e,t){let{resource:n,description:r,inputSchema:o,annotations:a,autoInjectResultText:i=!0}=e,s=e.id??n?.id,u=e.title??n?.title;if(!s)throw new Error("createTool: `id` is required when no resource is provided");if(!u)throw new Error("createTool: `title` is required when no resource is provided");let c=n?H({openaiTemplateUri:n.openaiUri,mcpTemplateUri:n.mcpUri,invoking:e.invoking??"Loading...",invoked:e.invoked??"Loaded",autoHeight:n.autoHeight}):void 0;return{id:s,title:u,description:r,async register(f){f.registerTool(s,{title:u,description:r,inputSchema:o,annotations:a,...c&&{_meta:c}},(async(l,d)=>{let p=d._meta??{},w=await t(l,{extra:{_meta:p}});return n&&w.data?{content:[{type:"text",text:w.text}],structuredContent:w.data,_meta:{...c,...p,...i===!1?{"waniwani/autoInjectResultText":!1}:{}}}:{content:[{type:"text",text:w.text}],...w.data?{structuredContent:w.data}:{},...i===!1?{_meta:{"waniwani/autoInjectResultText":!1}}:{}}}))}}}async function Ne(e,t){await Promise.all(t.map(n=>n.register(e)))}var N=class extends Error{constructor(n,r){super(n);this.status=r;this.name="WaniWaniError"}};var Oe="@waniwani/sdk";function ye(e){let{baseUrl:t,apiKey:n}=e;function r(){if(!n)throw new Error("WANIWANI_API_KEY is not set");return n}async function o(a,i,s){let u=r(),c=`${t.replace(/\/$/,"")}${i}`,f={Authorization:`Bearer ${u}`,"X-WaniWani-SDK":Oe},l={method:a,headers:f};s!==void 0&&(f["Content-Type"]="application/json",l.body=JSON.stringify(s));let d=await fetch(c,l);if(!d.ok){let p=await d.text().catch(()=>"");throw new N(p||`KB API error: HTTP ${d.status}`,d.status)}return(await d.json()).data}return{async ingest(a){return o("POST","/api/mcp/kb/ingest",{files:a})},async search(a,i){return o("POST","/api/mcp/kb/search",{query:a,...i})},async sources(){return o("GET","/api/mcp/kb/sources")}}}import{AsyncLocalStorage as Be}from"async_hooks";var K=new Be;function Te(){return K.getStore()?.meta}var je="@waniwani/sdk";function B(e,t={}){let n=t.now??(()=>new Date),r=t.generateId??ke,o=Le(e),a=O(e.meta),i=O(e.metadata),s=He(e,a),u=S(e.eventId)??r(),c=Ke(e.timestamp,n),f=S(e.source)??t.source??je,l=V(e)?{...e}:void 0,d={...i};return Object.keys(a).length>0&&(d.meta=a),l&&(d.rawLegacy=l),{id:u,type:"mcp.event",name:o,source:f,timestamp:c,correlation:s,properties:qe(e,o),metadata:d,rawLegacy:l}}function ke(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`evt_${crypto.randomUUID()}`:`evt_${Math.random().toString(36).slice(2,10)}_${Date.now().toString(36)}`}function qe(e,t){if(!V(e))return O(e.properties);let n=$e(e,t),r=O(e.properties);return{...n,...r}}function $e(e,t){switch(t){case"tool.called":{let n={};return S(e.toolName)&&(n.name=e.toolName),S(e.toolType)&&(n.type=e.toolType),n}case"quote.succeeded":{let n={};return typeof e.quoteAmount=="number"&&(n.amount=e.quoteAmount),S(e.quoteCurrency)&&(n.currency=e.quoteCurrency),n}case"link.clicked":{let n={};return S(e.linkUrl)&&(n.url=e.linkUrl),n}case"purchase.completed":{let n={};return typeof e.purchaseAmount=="number"&&(n.amount=e.purchaseAmount),S(e.purchaseCurrency)&&(n.currency=e.purchaseCurrency),n}default:return{}}}function Le(e){return V(e)?e.eventType:e.event}function He(e,t){let n=S(e.requestId)??P(t,["openai/requestId","requestId","mcp/requestId"]),r=S(e.sessionId)??P(t,["openai/sessionId","sessionId","conversationId","anthropic/sessionId"]),o=S(e.traceId)??P(t,["openai/traceId","traceId","mcp/traceId","openai/requestId","requestId"]),a=S(e.externalUserId)??P(t,["openai/userId","externalUserId","userId","actorId"]),i=S(e.correlationId)??P(t,["correlationId","openai/requestId"])??n,s={};return r&&(s.sessionId=r),o&&(s.traceId=o),n&&(s.requestId=n),i&&(s.correlationId=i),a&&(s.externalUserId=a),s}function Ke(e,t){if(e instanceof Date)return e.toISOString();if(typeof e=="string"){let n=new Date(e);if(!Number.isNaN(n.getTime()))return n.toISOString()}return t().toISOString()}function P(e,t){for(let n of t){let r=e[n];if(typeof r=="string"&&r.trim().length>0)return r}}function O(e){return!e||typeof e!="object"||Array.isArray(e)?{}:e}function S(e){if(typeof e=="string"&&e.trim().length!==0)return e}function V(e){return"eventType"in e}var Ve="/api/mcp/events/v2/batch";var Se="@waniwani/sdk",ze=new Set([401,403]),Ye=new Set([408,425,429,500,502,503,504]);function ve(e){return new z(e)}var z=class{endpointUrl;flushIntervalMs;maxBatchSize;maxBufferSize;maxRetries;retryBaseDelayMs;retryMaxDelayMs;shutdownTimeoutMs;sdkVersion;fetchFn;logger;now;sleep;apiKey;buffer=[];flushTimer;flushScheduled=!1;flushScheduledTimer;flushInFlight;inFlightCount=0;isStopped=!1;isShuttingDown=!1;constructor(t){this.endpointUrl=Ze(t.baseUrl,t.endpointPath??Ve),this.flushIntervalMs=t.flushIntervalMs??1e3,this.maxBatchSize=t.maxBatchSize??20,this.maxBufferSize=t.maxBufferSize??1e3,this.maxRetries=t.maxRetries??3,this.retryBaseDelayMs=t.retryBaseDelayMs??200,this.retryMaxDelayMs=t.retryMaxDelayMs??2e3,this.shutdownTimeoutMs=t.shutdownTimeoutMs??2e3,this.fetchFn=t.fetchFn??fetch,this.logger=t.logger??console,this.now=t.now??(()=>new Date),this.sleep=t.sleep??(n=>new Promise(r=>setTimeout(r,n))),this.apiKey=t.apiKey,this.sdkVersion=t.sdkVersion,this.flushIntervalMs>0&&(this.flushTimer=setInterval(()=>{this.flush()},this.flushIntervalMs))}enqueue(t){if(this.isStopped||this.isShuttingDown){this.logger.warn("[WaniWani] Tracking transport is stopped, dropping event %s",t.id);return}if(this.buffer.length>=this.maxBufferSize){let n=this.buffer.length-this.maxBufferSize+1;this.buffer.splice(0,n),this.logger.warn("[WaniWani] Tracking buffer overflow, dropped %d oldest event(s)",n)}if(this.buffer.push(t),this.buffer.length>=this.maxBatchSize){this.flush();return}this.scheduleMicroFlush()}pendingEvents(){return this.buffer.length+this.inFlightCount}async flush(){return this.flushInFlight?this.flushInFlight:(this.flushInFlight=this.flushLoop().finally(()=>{this.flushInFlight=void 0}),this.flushInFlight)}async shutdown(t){this.isShuttingDown=!0,this.flushTimer&&(clearInterval(this.flushTimer),this.flushTimer=void 0),this.flushScheduledTimer&&(clearTimeout(this.flushScheduledTimer),this.flushScheduledTimer=void 0,this.flushScheduled=!1);let n=t?.timeoutMs??this.shutdownTimeoutMs,r=this.flush();if(!Number.isFinite(n)||n<=0)return await r,this.isStopped=!0,{timedOut:!1,pendingEvents:this.pendingEvents()};let o=Symbol("shutdown-timeout");return await Promise.race([r.then(()=>"flushed"),this.sleep(n).then(()=>o)])===o?(this.isStopped=!0,{timedOut:!0,pendingEvents:this.pendingEvents()}):(this.isStopped=!0,{timedOut:!1,pendingEvents:this.pendingEvents()})}scheduleMicroFlush(){this.flushScheduled||(this.flushScheduled=!0,this.flushScheduledTimer=setTimeout(()=>{this.flushScheduledTimer=void 0,this.flushScheduled=!1,this.flush()},0))}async flushLoop(){for(;this.buffer.length>0&&!this.isStopped;){let t=this.buffer.splice(0,this.maxBatchSize);await this.sendBatchWithRetry(t)}}async sendBatchWithRetry(t){let n=0,r=t;for(;r.length>0&&!this.isStopped;){this.inFlightCount=r.length;let o=await this.sendBatchOnce(r);switch(this.inFlightCount=0,o.kind){case"success":return;case"auth":this.stopTransportForAuthFailure(o.status,r.length);return;case"permanent":this.logger.error("[WaniWani] Dropping %d event(s) after permanent failure: %s",r.length,o.reason);return;case"retryable":if(n>=this.maxRetries){this.logger.error("[WaniWani] Dropping %d event(s) after retry exhaustion: %s",r.length,o.reason);return}await this.sleep(this.backoffDelayMs(n)),n+=1;continue;case"partial":if(o.permanent.length>0&&this.logger.error("[WaniWani] Dropping %d event(s) rejected as permanent",o.permanent.length),o.retryable.length===0)return;if(n>=this.maxRetries){this.logger.error("[WaniWani] Dropping %d retryable event(s) after retry exhaustion",o.retryable.length);return}r=o.retryable,await this.sleep(this.backoffDelayMs(n)),n+=1;continue}}}async sendBatchOnce(t){let n;try{n=await this.fetchFn(this.endpointUrl,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`,"X-WaniWani-SDK":Se},body:JSON.stringify(this.makeBatchRequest(t))})}catch(a){return{kind:"retryable",reason:Ge(a)}}if(ze.has(n.status))return{kind:"auth",status:n.status};if(Ye.has(n.status))return{kind:"retryable",reason:`HTTP ${n.status}`};if(!n.ok)return{kind:"permanent",reason:`HTTP ${n.status}`};let r=await Je(n);if(!r?.rejected||r.rejected.length===0)return{kind:"success"};let o=this.classifyRejectedEvents(t,r.rejected);return o.retryable.length===0&&o.permanent.length===0?{kind:"success"}:{kind:"partial",retryable:o.retryable,permanent:o.permanent}}makeBatchRequest(t){return{sentAt:this.now().toISOString(),source:{sdk:Se,version:this.sdkVersion??"0.0.0"},events:t}}classifyRejectedEvents(t,n){let r=new Map(t.map(i=>[i.id,i])),o=[],a=[];for(let i of n){let s=r.get(i.eventId);if(s){if(Xe(i)){o.push(s);continue}a.push(s)}}return{retryable:o,permanent:a}}backoffDelayMs(t){let n=this.retryBaseDelayMs*2**t;return Math.min(n,this.retryMaxDelayMs)}stopTransportForAuthFailure(t,n){this.isStopped=!0;let r=this.buffer.length;this.buffer.splice(0,r),this.logger.error("[WaniWani] Auth failure (HTTP %d). Stopping tracking transport and dropping %d queued event(s)",t,n+r)}};function Xe(e){if(e.retryable===!0)return!0;let t=e.code.toLowerCase();return t.includes("timeout")||t.includes("temporary")||t.includes("unavailable")||t.includes("rate_limit")||t.includes("transient")||t.includes("server")}async function Je(e){let t=await e.text();if(t)try{return JSON.parse(t)}catch{return}}function Ze(e,t){let n=e.endsWith("/")?e:`${e}/`,r=t.startsWith("/")?t.slice(1):t;return`${n}${r}`}function Ge(e){return e instanceof Error?e.message:String(e)}function Re(e){let{baseUrl:t,apiKey:n,tracking:r}=e;function o(){if(!n)throw new Error("WANIWANI_API_KEY is not set");return n}let a=n?ve({baseUrl:t,apiKey:n,endpointPath:r.endpointPath,flushIntervalMs:r.flushIntervalMs,maxBatchSize:r.maxBatchSize,maxBufferSize:r.maxBufferSize,maxRetries:r.maxRetries,retryBaseDelayMs:r.retryBaseDelayMs,retryMaxDelayMs:r.retryMaxDelayMs,shutdownTimeoutMs:r.shutdownTimeoutMs}):void 0,i={async identify(s,u,c){o();let f=xe(c),l=B({event:"user.identified",externalUserId:s,properties:u,meta:f});return a?.enqueue(l),{eventId:l.id}},async track(s){o();let u=xe(s.meta),c=B({...s,meta:u});return a?.enqueue(c),{eventId:c.id}},async flush(){o(),await a?.flush()},async shutdown(s){return o(),await a?.shutdown({timeoutMs:s?.timeoutMs??r.shutdownTimeoutMs})??{timedOut:!1,pendingEvents:0}}};return a&&Qe(i,r.shutdownTimeoutMs),i}function xe(e){let t=Te();if(!(!t&&!e))return t?e?{...t,...e}:t:e}function Qe(e,t){if(typeof process>"u"||typeof process.once!="function"||typeof process.on!="function")return;let n=()=>{e.shutdown({timeoutMs:t})};process.once("beforeExit",n),process.once("SIGINT",n),process.once("SIGTERM",n)}function Ee(e){let t=e?.baseUrl??"https://app.waniwani.ai",n=e?.apiKey??process.env.WANIWANI_API_KEY,r={endpointPath:e?.tracking?.endpointPath??"/api/mcp/events/v2/batch",flushIntervalMs:e?.tracking?.flushIntervalMs??1e3,maxBatchSize:e?.tracking?.maxBatchSize??20,maxBufferSize:e?.tracking?.maxBufferSize??1e3,maxRetries:e?.tracking?.maxRetries??3,retryBaseDelayMs:e?.tracking?.retryBaseDelayMs??200,retryMaxDelayMs:e?.tracking?.retryMaxDelayMs??2e3,shutdownTimeoutMs:e?.tracking?.shutdownTimeoutMs??2e3},o={baseUrl:t,apiKey:n,tracking:r},a=Re(o),i=ye(o);return{...a,kb:i,_config:o}}function et(e){let t=e.event_type??"widget_click",r=t.startsWith("widget_")?t:`widget_${t}`,o={...e.metadata??{}};return e.event_name&&(o.event_name=e.event_name),{event:r,properties:o,sessionId:e.session_id,traceId:e.trace_id,externalUserId:e.user_id,eventId:e.event_id,timestamp:e.timestamp,source:e.source??"widget"}}function tt(e){let t={apiKey:e?.apiKey,baseUrl:e?.baseUrl},n;function r(){return n||(n=Ee(t)),n}return async function(a){let i;try{i=await a.json()}catch{return new Response(JSON.stringify({error:"Invalid JSON"}),{status:400,headers:{"Content-Type":"application/json"}})}if(!Array.isArray(i.events)||i.events.length===0)return new Response(JSON.stringify({error:"Missing or empty events array"}),{status:400,headers:{"Content-Type":"application/json"}});try{let s=r(),u=[];for(let c of i.events){let f=et(c),l=await s.track(f);u.push(l.eventId)}return await s.flush(),new Response(JSON.stringify({ok:!0,accepted:u.length}),{status:200,headers:{"Content-Type":"application/json"}})}catch(s){let u=s instanceof Error?s.message:"Unknown error";return new Response(JSON.stringify({error:u}),{status:500,headers:{"Content-Type":"application/json"}})}}}var j=class{cached=null;pending=null;config;constructor(t){this.config=t}async getToken(t,n){return this.cached&&Date.now()<this.cached.expiresAt-12e4?this.cached.token:this.pending?this.pending:(this.pending=this.mint(t,n).finally(()=>{this.pending=null}),this.pending)}async mint(t,n){let r=nt(this.config.baseUrl,"/api/mcp/widget-tokens"),o={};t&&(o.sessionId=t),n&&(o.traceId=n);try{let a=await fetch(r,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.config.apiKey}`},body:JSON.stringify(o)});if(!a.ok)return null;let i=await a.json(),s=i.data&&typeof i.data=="object"?i.data:i,u=new Date(s.expiresAt).getTime();return!s.token||Number.isNaN(u)?null:(this.cached={token:s.token,expiresAt:u},s.token)}catch{return null}}};function nt(e,t){return`${e.endsWith("/")?e.slice(0,-1):e}${t}`}var Y="waniwani/userLocation";function v(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function q(e){if(!v(e))return;let t=e._meta;return v(t)?t:void 0}function X(e){if(!v(e))return;let t=e.content;return Array.isArray(t)?t.find(r=>v(r)&&r.type==="text"&&typeof r.text=="string")?.text:void 0}function rt(e,t){return typeof t=="function"?t(e)??"other":t??"other"}function J(e,t,n,r,o){let a=rt(e,n.toolType),i=q(t);return{event:"tool.called",properties:{name:e,type:a,...r??{}},meta:i,metadata:{source:"withWaniwani",...n.metadata??{},...o&&{clientInfo:o}}}}async function Z(e,t,n){try{await e.track(t)}catch(r){n?.(Q(r))}}async function G(e,t){try{await e.flush()}catch(n){t?.(Q(n))}}async function Ie(e,t,n,r){if(!v(e))return;v(e._meta)||(e._meta={});let o=e._meta,a={endpoint:`${n.replace(/\/$/,"")}/api/mcp/events/v2/batch`};if(t)try{let i=await t.getToken();i&&(a.token=i)}catch(i){r?.(Q(i))}o.waniwani=a}function Ce(e,t){let n=q(t);if(!n)return;let r=n[Y];if(!r||!v(e))return;v(e._meta)||(e._meta={});let o=e._meta;o[Y]||(o[Y]=r)}function Q(e){return e instanceof Error?e:new Error(String(e))}var be="https://app.waniwani.ai";function ot(e,t){let n=e;if(n.__waniwaniWrapped)return n;n.__waniwaniWrapped=!0;let r=t.client,o=t.injectWidgetToken!==!1,a=null;function i(){if(a)return a;let u=r._config.apiKey;return u?(a=new j({baseUrl:r._config.baseUrl??be,apiKey:u}),a):null}let s=e.registerTool.bind(e);return n.registerTool=((...u)=>{let[c,f,l]=u,d=typeof c=="string"&&c.trim().length>0?c:"unknown";if(typeof l!="function")return s(...u);let y=l;return s(c,f,async(w,g)=>{let x=q(g)??{};return K.run({meta:x},async()=>{let k=performance.now(),R=e.server?.getClientVersion?.();try{let T=await y(w,g),b=Math.round(performance.now()-k),E=v(T)&&T.isError===!0;if(E){let ee=X(T);console.error(`[waniwani] Tool "${d}" returned error${ee?`: ${ee}`:""}`)}return await Z(r,J(d,g,t,{durationMs:b,status:E?"error":"ok",...E&&{errorMessage:X(T)??"Unknown tool error"}},R),t.onError),t.flushAfterToolCall&&await G(r,t.onError),o&&await Ie(T,i(),r._config.baseUrl??be,t.onError),Ce(T,g),T}catch(T){let b=Math.round(performance.now()-k);throw await Z(r,J(d,g,t,{durationMs:b,status:"error",errorMessage:T instanceof Error?T.message:String(T)},R),t.onError),t.flushAfterToolCall&&await G(r,t.onError),T}})})}),n}export{C as END,I as START,M as StateGraph,le as createFlow,fe as createFlowTestHarness,we as createResource,De as createTool,tt as createTrackingRoute,$ as detectPlatform,Me as isMCPApps,_e as isOpenAI,Ne as registerTools,ot as withWaniwani};
|
|
3
|
+
${E.context}`:`ERROR: ${R}`}:E),b=de(T,d.context,i,s);if(b)return b;break}}let w=r.get(i);if(!w)return{content:{status:"error",error:`No outgoing edge from node "${i}"`}};i=await _(w,s);continue}if(ce(d)){let p=d.field;if(p&&K(s[p])){let w=r.get(i);if(!w)return{content:{status:"error",error:`No outgoing edge from node "${i}"`}};i=await _(w,s);continue}return{content:{status:"widget",tool:d.tool.id,data:d.data,description:d.description,...d.interactive===!1?{interactive:!1}:{}},flowTokenContent:{step:i,state:s,field:p,widgetId:d.tool.id}}}s={...s,...d};let y=r.get(i);if(!y)return{content:{status:"error",error:`No outgoing edge from node "${i}"`}};i=await _(y,s)}catch(l){return{content:{status:"error",error:l instanceof Error?l.message:String(l)},flowTokenContent:{step:i,state:s}}}}return{content:{status:"error",error:"Flow exceeded maximum iterations (possible infinite loop)"}}}var Ue="@waniwani/sdk",De="https://app.waniwani.ai",P=class{baseUrl;apiKey;constructor(t){this.baseUrl=(t?.baseUrl??process.env.WANIWANI_BASE_URL??De).replace(/\/$/,""),this.apiKey=t?.apiKey??process.env.WANIWANI_API_KEY}async get(t){if(!this.apiKey)return null;try{return await this.request("/api/mcp/redis/get",{key:t})??null}catch{return null}}async set(t,n){if(this.apiKey)try{await this.request("/api/mcp/redis/set",{key:t,value:n})}catch{}}async delete(t){if(this.apiKey)try{await this.request("/api/mcp/redis/delete",{key:t})}catch{}}async request(t,n){let r=`${this.baseUrl}${t}`,o=await fetch(r,{method:"POST",headers:{Authorization:`Bearer ${this.apiKey}`,"Content-Type":"application/json","X-WaniWani-SDK":Ue},body:JSON.stringify(n)});if(!o.ok){let i=await o.text().catch(()=>"");throw new Error(i||`Flow state API error: HTTP ${o.status}`)}return(await o.json()).data}};function Ne(e){let t=e.description??"",n=e._zod?.def;if(n?.type==="enum"&&n.entries){let r=Object.keys(n.entries).map(o=>`"${o}"`).join(" | ");return t?`${r} \u2014 ${t}`:r}return t}function ue(e){let t=["","## FLOW EXECUTION PROTOCOL","","This tool implements a multi-step conversational flow. Follow this protocol exactly:","",'1. Call with `action: "start"` to begin. If the user\'s message already'," contains answers to likely questions, extract them into `stateUpdates`"," as `{ field: value }` pairs. The engine will auto-skip steps whose"," fields are already filled."," Only extract values the user explicitly stated \u2014 do NOT guess or invent values."];if(e.state){let n=Object.entries(e.state).map(([r,o])=>{let a=Ne(o);return a?`\`${r}\` (${a})`:`\`${r}\``}).join(", ");t.push(` Known fields: ${n}.`)}return t.push("2. The response JSON `status` field tells you what to do next:",' - `"interrupt"`: Pause and ask the user. Two forms:'," a. Single question: `{ question, field, context? }` \u2014 ask `question`, store answer in `field`."," b. Multi-question: `{ questions: [{question, field}, ...], context? }` \u2014 ask ALL questions"," in one conversational message, collect all answers."," `context` (if present) is hidden AI instructions \u2014 use to shape your response, do NOT show verbatim."," Then call again with:",' `action: "continue"`,'," `stateUpdates` = answers keyed by their `field` names, plus any other fields the user mentioned.",' - `"widget"`: The flow wants to show a UI widget. Call the tool named in the `tool`'," field, passing the `data` object as the tool's input."," If the response includes `interactive: false`, the widget is display-only:"," call the display tool, show the widget, then immediately call THIS flow tool again with",' `action: "continue"`. In that case, do NOT wait for the user'," to click or use the widget, and do NOT ask them to interact with it unless the"," description explicitly says otherwise."," Otherwise, present the widget result to the user. When the user makes a choice or interacts"," with the widget, call THIS flow tool again with:",' `action: "continue"`,'," `stateUpdates` = `{ [field]: <user's selection> }` plus any other fields the user mentioned.",' - `"complete"`: The flow is done. Present the result to the user.',' - `"error"`: Something went wrong. Show the `error` message.',"","3. Do NOT invent state values. Only use `stateUpdates` for information the user explicitly provided.","4. Include only the fields the user actually answered in `stateUpdates` \u2014 do NOT guess missing ones."," If the user did not answer all pending questions, the engine will re-prompt for the remaining ones."," If the user mentioned values for other known fields, include those too \u2014"," they will be applied immediately and those steps will be auto-skipped."),t.join(`
|
|
4
|
+
`)}var Oe={action:U.enum(["start","continue"]).describe('"start" to begin the flow, "continue" to resume after a pause (interrupt or widget)'),stateUpdates:U.record(U.string(),U.unknown()).optional().describe("State field values to set before processing the next node. Use this to pass the user's answer (keyed by the field name from the response) and any other values the user mentioned.")};function le(e){let{config:t,nodes:n,edges:r}=e,o=ue(t),a=`${t.description}
|
|
5
|
+
${o}`,i=e.store??new P,s=new Map;async function u(c,f,l){if(c.action==="start"){let d=r.get(I);if(!d)return{content:{status:"error",error:"No start edge"}};let y={...c.stateUpdates??{}},p=await _(d,y);return A(p,y,n,r,s,l)}if(c.action==="continue"){if(!f)return{content:{status:"error",error:"No session ID available for continue action."}};let d=await i.get(f);if(!d)return{content:{status:"error",error:"Flow state not found. The flow may have expired."}};let y=d.state,p=d.step;if(!p)return{content:{status:"error",error:"Flow state is missing the current step. The flow may have expired."}};let w={...y,...c.stateUpdates??{}};if(d.widgetId){let g=r.get(p);if(!g)return{content:{status:"error",error:`No edge from step "${p}"`}};let x=await _(g,w);return A(x,w,n,r,s,l)}return A(p,w,n,r,s,l)}return{content:{status:"error",error:`Unknown action: "${c.action}"`}}}return{id:t.id,title:t.title,description:a,async register(c){c.registerTool(t.id,{title:t.title,description:a,inputSchema:Oe,annotations:t.annotations},(async(f,l)=>{let y=l._meta??{},p=F(y),w=await u(f,p,y);return w.flowTokenContent&&p&&await i.set(p,w.flowTokenContent),{content:[{type:"text",text:JSON.stringify(w.content,null,2)}],_meta:y,...w.content.status==="error"?{isError:!0}:{}}}))}}}var M=class{nodes=new Map;edges=new Map;config;constructor(t){this.config=t}addNode(t,n){if(t===I||t===C)throw new Error(`"${t}" is a reserved name and cannot be used as a node name`);if(this.nodes.has(t))throw new Error(`Node "${t}" already exists`);return this.nodes.set(t,n),this}addEdge(t,n){if(this.edges.has(t))throw new Error(`Node "${t}" already has an outgoing edge. Use addConditionalEdge for branching.`);return this.edges.set(t,{type:"direct",to:n}),this}addConditionalEdge(t,n){if(this.edges.has(t))throw new Error(`Node "${t}" already has an outgoing edge.`);return this.edges.set(t,{type:"conditional",condition:n}),this}compile(t){return this.validate(),le({config:this.config,nodes:new Map(this.nodes),edges:new Map(this.edges),store:t?.store})}validate(){if(!this.edges.has(I))throw new Error('Flow must have an entry point. Add an edge from START: .addEdge(START, "first_node")');let t=this.edges.get(I);if(t?.type==="direct"&&t.to!==C&&!this.nodes.has(t.to))throw new Error(`START edge references non-existent node: "${t.to}"`);for(let[n,r]of this.edges){if(n!==I&&!this.nodes.has(n))throw new Error(`Edge from non-existent node: "${n}"`);if(r.type==="direct"&&r.to!==C&&!this.nodes.has(r.to))throw new Error(`Edge from "${n}" references non-existent node: "${r.to}"`)}for(let[n]of this.nodes)if(!this.edges.has(n))throw new Error(`Node "${n}" has no outgoing edge. Add one with .addEdge("${n}", ...) or .addConditionalEdge("${n}", ...)`)}};function pe(e){return new M(e)}function fe(e){let t=e.content;return JSON.parse(t[0]?.text??"")}async function ge(e,t){let n=t?.stateStore,r=[],o=`test-session-${Math.random().toString(36).slice(2,10)}`,a={registerTool:(...c)=>{r.push(c)}};await e.register(a);let i=r[0]?.[2];if(!i)throw new Error(`Flow "${e.id}" did not register a handler`);let s={_meta:{sessionId:o}};async function u(c){return{...c,decodedState:n?await n.get(o):null}}return{async start(c){let f=await i({action:"start",...c?{stateUpdates:c}:{}},s);return u(fe(f))},async continueWith(c){let f=await i({action:"continue",...c?{stateUpdates:c}:{}},s);return u(fe(f))},async lastState(){return n?n.get(o):null}}}var D="text/html+skybridge",N="text/html;profile=mcp-app",me=async(e,t)=>{let n=e.endsWith("/")?e.slice(0,-1):e;return await(await fetch(`${n}${t}`)).text()};function he(e){return{"openai/widgetDescription":e.description,"openai/widgetPrefersBorder":e.prefersBorder,"openai/widgetDomain":e.widgetDomain,...e.widgetCSP&&{"openai/widgetCSP":e.widgetCSP}}}function we(e){let t=e.widgetCSP?{connectDomains:e.widgetCSP.connect_domains,resourceDomains:e.widgetCSP.resource_domains,frameDomains:e.widgetCSP.frame_domains,redirectDomains:e.widgetCSP.redirect_domains}:void 0;return{ui:{...t&&{csp:t},...e.widgetDomain&&{domain:e.widgetDomain},...e.prefersBorder!==void 0&&{prefersBorder:e.prefersBorder}}}}function H(e){return{...e.openaiTemplateUri&&{"openai/outputTemplate":e.openaiTemplateUri},"openai/toolInvocation/invoking":e.invoking,"openai/toolInvocation/invoked":e.invoked,"openai/widgetAccessible":!0,"openai/resultCanProduceWidget":!0,...e.mcpTemplateUri&&{ui:{resourceUri:e.mcpTemplateUri,...e.autoHeight&&{autoHeight:!0}}}}}function ye(e){let{id:t,title:n,description:r,baseUrl:o,htmlPath:a,widgetDomain:i,prefersBorder:s=!0,autoHeight:u=!0}=e,c=e.widgetCSP??{connect_domains:[o],resource_domains:[o]};if(process.env.NODE_ENV==="development")try{let{hostname:g}=new URL(o);(g==="localhost"||g==="127.0.0.1")&&(c={...c,connect_domains:[...c.connect_domains||[],`ws://${g}:*`,`wss://${g}:*`],resource_domains:[...c.resource_domains||[],`http://${g}:*`]})}catch{}let f=`ui://widgets/apps-sdk/${t}.html`,l=`ui://widgets/ext-apps/${t}.html`,d=null,y=()=>(d||(d=me(o,a)),d),p=r;async function w(g){let x=await y();g.registerResource(`${t}-openai-widget`,f,{title:n,description:p,mimeType:D,_meta:{"openai/widgetDescription":p,"openai/widgetPrefersBorder":s}},async k=>({contents:[{uri:k.href,mimeType:D,text:x,_meta:he({description:p,prefersBorder:s,widgetDomain:i,widgetCSP:c})}]})),g.registerResource(`${t}-mcp-widget`,l,{title:n,description:p,mimeType:N,_meta:{ui:{prefersBorder:s}}},async k=>({contents:[{uri:k.href,mimeType:N,text:x,_meta:we({description:p,prefersBorder:s,widgetCSP:c})}]}))}return{id:t,title:n,description:r,openaiUri:f,mcpUri:l,autoHeight:u,register:w}}function Be(e,t){let{resource:n,description:r,inputSchema:o,annotations:a,autoInjectResultText:i=!0}=e,s=e.id??n?.id,u=e.title??n?.title;if(!s)throw new Error("createTool: `id` is required when no resource is provided");if(!u)throw new Error("createTool: `title` is required when no resource is provided");let c=n?H({openaiTemplateUri:n.openaiUri,mcpTemplateUri:n.mcpUri,invoking:e.invoking??"Loading...",invoked:e.invoked??"Loaded",autoHeight:n.autoHeight}):void 0;return{id:s,title:u,description:r,async register(f){f.registerTool(s,{title:u,description:r,inputSchema:o,annotations:a,...c&&{_meta:c}},(async(l,d)=>{let p=d._meta??{},w=await t(l,{extra:{_meta:p}});return n&&w.data?{content:[{type:"text",text:w.text}],structuredContent:w.data,_meta:{...c,...p,...i===!1?{"waniwani/autoInjectResultText":!1}:{}}}:{content:[{type:"text",text:w.text}],...w.data?{structuredContent:w.data}:{},...i===!1?{_meta:{"waniwani/autoInjectResultText":!1}}:{}}}))}}}async function je(e,t){await Promise.all(t.map(n=>n.register(e)))}var O=class extends Error{constructor(n,r){super(n);this.status=r;this.name="WaniWaniError"}};var qe="@waniwani/sdk";function Te(e){let{baseUrl:t,apiKey:n}=e;function r(){if(!n)throw new Error("WANIWANI_API_KEY is not set");return n}async function o(a,i,s){let u=r(),c=`${t.replace(/\/$/,"")}${i}`,f={Authorization:`Bearer ${u}`,"X-WaniWani-SDK":qe},l={method:a,headers:f};s!==void 0&&(f["Content-Type"]="application/json",l.body=JSON.stringify(s));let d=await fetch(c,l);if(!d.ok){let p=await d.text().catch(()=>"");throw new O(p||`KB API error: HTTP ${d.status}`,d.status)}return(await d.json()).data}return{async ingest(a){return o("POST","/api/mcp/kb/ingest",{files:a})},async search(a,i){return o("POST","/api/mcp/kb/search",{query:a,...i})},async sources(){return o("GET","/api/mcp/kb/sources")}}}import{AsyncLocalStorage as $e}from"async_hooks";var V=new $e;function ke(){return V.getStore()?.meta}var Le="@waniwani/sdk";function j(e,t={}){let n=t.now??(()=>new Date),r=t.generateId??Se,o=Ve(e),a=B(e.meta),i=B(e.metadata),s=ze(e,a),u=S(e.eventId)??r(),c=Ye(e.timestamp,n),f=S(e.source)??t.source??Le,l=z(e)?{...e}:void 0,d={...i};return Object.keys(a).length>0&&(d.meta=a),l&&(d.rawLegacy=l),{id:u,type:"mcp.event",name:o,source:f,timestamp:c,correlation:s,properties:Ke(e,o),metadata:d,rawLegacy:l}}function Se(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`evt_${crypto.randomUUID()}`:`evt_${Math.random().toString(36).slice(2,10)}_${Date.now().toString(36)}`}function Ke(e,t){if(!z(e))return B(e.properties);let n=He(e,t),r=B(e.properties);return{...n,...r}}function He(e,t){switch(t){case"tool.called":{let n={};return S(e.toolName)&&(n.name=e.toolName),S(e.toolType)&&(n.type=e.toolType),n}case"quote.succeeded":{let n={};return typeof e.quoteAmount=="number"&&(n.amount=e.quoteAmount),S(e.quoteCurrency)&&(n.currency=e.quoteCurrency),n}case"link.clicked":{let n={};return S(e.linkUrl)&&(n.url=e.linkUrl),n}case"purchase.completed":{let n={};return typeof e.purchaseAmount=="number"&&(n.amount=e.purchaseAmount),S(e.purchaseCurrency)&&(n.currency=e.purchaseCurrency),n}default:return{}}}function Ve(e){return z(e)?e.eventType:e.event}function ze(e,t){let n=S(e.requestId)??W(t,["openai/requestId","requestId","mcp/requestId"]),r=S(e.sessionId)??W(t,["openai/sessionId","sessionId","conversationId","anthropic/sessionId"]),o=S(e.traceId)??W(t,["openai/traceId","traceId","mcp/traceId","openai/requestId","requestId"]),a=S(e.externalUserId)??W(t,["openai/userId","externalUserId","userId","actorId"]),i=S(e.correlationId)??W(t,["correlationId","openai/requestId"])??n,s={};return r&&(s.sessionId=r),o&&(s.traceId=o),n&&(s.requestId=n),i&&(s.correlationId=i),a&&(s.externalUserId=a),s}function Ye(e,t){if(e instanceof Date)return e.toISOString();if(typeof e=="string"){let n=new Date(e);if(!Number.isNaN(n.getTime()))return n.toISOString()}return t().toISOString()}function W(e,t){for(let n of t){let r=e[n];if(typeof r=="string"&&r.trim().length>0)return r}}function B(e){return!e||typeof e!="object"||Array.isArray(e)?{}:e}function S(e){if(typeof e=="string"&&e.trim().length!==0)return e}function z(e){return"eventType"in e}var Xe="/api/mcp/events/v2/batch";var ve="@waniwani/sdk",Je=new Set([401,403]),Ge=new Set([408,425,429,500,502,503,504]);function xe(e){return new Y(e)}var Y=class{endpointUrl;flushIntervalMs;maxBatchSize;maxBufferSize;maxRetries;retryBaseDelayMs;retryMaxDelayMs;shutdownTimeoutMs;sdkVersion;fetchFn;logger;now;sleep;apiKey;buffer=[];flushTimer;flushScheduled=!1;flushScheduledTimer;flushInFlight;inFlightCount=0;isStopped=!1;isShuttingDown=!1;constructor(t){this.endpointUrl=et(t.baseUrl,t.endpointPath??Xe),this.flushIntervalMs=t.flushIntervalMs??1e3,this.maxBatchSize=t.maxBatchSize??20,this.maxBufferSize=t.maxBufferSize??1e3,this.maxRetries=t.maxRetries??3,this.retryBaseDelayMs=t.retryBaseDelayMs??200,this.retryMaxDelayMs=t.retryMaxDelayMs??2e3,this.shutdownTimeoutMs=t.shutdownTimeoutMs??2e3,this.fetchFn=t.fetchFn??fetch,this.logger=t.logger??console,this.now=t.now??(()=>new Date),this.sleep=t.sleep??(n=>new Promise(r=>setTimeout(r,n))),this.apiKey=t.apiKey,this.sdkVersion=t.sdkVersion,this.flushIntervalMs>0&&(this.flushTimer=setInterval(()=>{this.flush()},this.flushIntervalMs))}enqueue(t){if(this.isStopped||this.isShuttingDown){this.logger.warn("[WaniWani] Tracking transport is stopped, dropping event %s",t.id);return}if(this.buffer.length>=this.maxBufferSize){let n=this.buffer.length-this.maxBufferSize+1;this.buffer.splice(0,n),this.logger.warn("[WaniWani] Tracking buffer overflow, dropped %d oldest event(s)",n)}if(this.buffer.push(t),this.buffer.length>=this.maxBatchSize){this.flush();return}this.scheduleMicroFlush()}pendingEvents(){return this.buffer.length+this.inFlightCount}async flush(){return this.flushInFlight?this.flushInFlight:(this.flushInFlight=this.flushLoop().finally(()=>{this.flushInFlight=void 0}),this.flushInFlight)}async shutdown(t){this.isShuttingDown=!0,this.flushTimer&&(clearInterval(this.flushTimer),this.flushTimer=void 0),this.flushScheduledTimer&&(clearTimeout(this.flushScheduledTimer),this.flushScheduledTimer=void 0,this.flushScheduled=!1);let n=t?.timeoutMs??this.shutdownTimeoutMs,r=this.flush();if(!Number.isFinite(n)||n<=0)return await r,this.isStopped=!0,{timedOut:!1,pendingEvents:this.pendingEvents()};let o=Symbol("shutdown-timeout");return await Promise.race([r.then(()=>"flushed"),this.sleep(n).then(()=>o)])===o?(this.isStopped=!0,{timedOut:!0,pendingEvents:this.pendingEvents()}):(this.isStopped=!0,{timedOut:!1,pendingEvents:this.pendingEvents()})}scheduleMicroFlush(){this.flushScheduled||(this.flushScheduled=!0,this.flushScheduledTimer=setTimeout(()=>{this.flushScheduledTimer=void 0,this.flushScheduled=!1,this.flush()},0))}async flushLoop(){for(;this.buffer.length>0&&!this.isStopped;){let t=this.buffer.splice(0,this.maxBatchSize);await this.sendBatchWithRetry(t)}}async sendBatchWithRetry(t){let n=0,r=t;for(;r.length>0&&!this.isStopped;){this.inFlightCount=r.length;let o=await this.sendBatchOnce(r);switch(this.inFlightCount=0,o.kind){case"success":return;case"auth":this.stopTransportForAuthFailure(o.status,r.length);return;case"permanent":this.logger.error("[WaniWani] Dropping %d event(s) after permanent failure: %s",r.length,o.reason);return;case"retryable":if(n>=this.maxRetries){this.logger.error("[WaniWani] Dropping %d event(s) after retry exhaustion: %s",r.length,o.reason);return}await this.sleep(this.backoffDelayMs(n)),n+=1;continue;case"partial":if(o.permanent.length>0&&this.logger.error("[WaniWani] Dropping %d event(s) rejected as permanent",o.permanent.length),o.retryable.length===0)return;if(n>=this.maxRetries){this.logger.error("[WaniWani] Dropping %d retryable event(s) after retry exhaustion",o.retryable.length);return}r=o.retryable,await this.sleep(this.backoffDelayMs(n)),n+=1;continue}}}async sendBatchOnce(t){let n;try{n=await this.fetchFn(this.endpointUrl,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`,"X-WaniWani-SDK":ve},body:JSON.stringify(this.makeBatchRequest(t))})}catch(a){return{kind:"retryable",reason:tt(a)}}if(Je.has(n.status))return{kind:"auth",status:n.status};if(Ge.has(n.status))return{kind:"retryable",reason:`HTTP ${n.status}`};if(!n.ok)return{kind:"permanent",reason:`HTTP ${n.status}`};let r=await Qe(n);if(!r?.rejected||r.rejected.length===0)return{kind:"success"};let o=this.classifyRejectedEvents(t,r.rejected);return o.retryable.length===0&&o.permanent.length===0?{kind:"success"}:{kind:"partial",retryable:o.retryable,permanent:o.permanent}}makeBatchRequest(t){return{sentAt:this.now().toISOString(),source:{sdk:ve,version:this.sdkVersion??"0.0.0"},events:t}}classifyRejectedEvents(t,n){let r=new Map(t.map(i=>[i.id,i])),o=[],a=[];for(let i of n){let s=r.get(i.eventId);if(s){if(Ze(i)){o.push(s);continue}a.push(s)}}return{retryable:o,permanent:a}}backoffDelayMs(t){let n=this.retryBaseDelayMs*2**t;return Math.min(n,this.retryMaxDelayMs)}stopTransportForAuthFailure(t,n){this.isStopped=!0;let r=this.buffer.length;this.buffer.splice(0,r),this.logger.error("[WaniWani] Auth failure (HTTP %d). Stopping tracking transport and dropping %d queued event(s)",t,n+r)}};function Ze(e){if(e.retryable===!0)return!0;let t=e.code.toLowerCase();return t.includes("timeout")||t.includes("temporary")||t.includes("unavailable")||t.includes("rate_limit")||t.includes("transient")||t.includes("server")}async function Qe(e){let t=await e.text();if(t)try{return JSON.parse(t)}catch{return}}function et(e,t){let n=e.endsWith("/")?e:`${e}/`,r=t.startsWith("/")?t.slice(1):t;return`${n}${r}`}function tt(e){return e instanceof Error?e.message:String(e)}function Ee(e){let{baseUrl:t,apiKey:n,tracking:r}=e;function o(){if(!n)throw new Error("WANIWANI_API_KEY is not set");return n}let a=n?xe({baseUrl:t,apiKey:n,endpointPath:r.endpointPath,flushIntervalMs:r.flushIntervalMs,maxBatchSize:r.maxBatchSize,maxBufferSize:r.maxBufferSize,maxRetries:r.maxRetries,retryBaseDelayMs:r.retryBaseDelayMs,retryMaxDelayMs:r.retryMaxDelayMs,shutdownTimeoutMs:r.shutdownTimeoutMs}):void 0,i={async identify(s,u,c){o();let f=Re(c),l=j({event:"user.identified",externalUserId:s,properties:u,meta:f});return a?.enqueue(l),{eventId:l.id}},async track(s){o();let u=Re(s.meta),c=j({...s,meta:u});return a?.enqueue(c),{eventId:c.id}},async flush(){o(),await a?.flush()},async shutdown(s){return o(),await a?.shutdown({timeoutMs:s?.timeoutMs??r.shutdownTimeoutMs})??{timedOut:!1,pendingEvents:0}}};return a&&nt(i,r.shutdownTimeoutMs),i}function Re(e){let t=ke();if(!(!t&&!e))return t?e?{...t,...e}:t:e}function nt(e,t){if(typeof process>"u"||typeof process.once!="function"||typeof process.on!="function")return;let n=()=>{e.shutdown({timeoutMs:t})};process.once("beforeExit",n),process.once("SIGINT",n),process.once("SIGTERM",n)}function Ie(e){let t=e?.baseUrl??"https://app.waniwani.ai",n=e?.apiKey??process.env.WANIWANI_API_KEY,r={endpointPath:e?.tracking?.endpointPath??"/api/mcp/events/v2/batch",flushIntervalMs:e?.tracking?.flushIntervalMs??1e3,maxBatchSize:e?.tracking?.maxBatchSize??20,maxBufferSize:e?.tracking?.maxBufferSize??1e3,maxRetries:e?.tracking?.maxRetries??3,retryBaseDelayMs:e?.tracking?.retryBaseDelayMs??200,retryMaxDelayMs:e?.tracking?.retryMaxDelayMs??2e3,shutdownTimeoutMs:e?.tracking?.shutdownTimeoutMs??2e3},o={baseUrl:t,apiKey:n,tracking:r},a=Ee(o),i=Te(o);return{...a,kb:i,_config:o}}function rt(e){let t=e.event_type??"widget_click",r=t.startsWith("widget_")?t:`widget_${t}`,o={...e.metadata??{}};return e.event_name&&(o.event_name=e.event_name),{event:r,properties:o,sessionId:e.session_id,traceId:e.trace_id,externalUserId:e.user_id,eventId:e.event_id,timestamp:e.timestamp,source:e.source??"widget"}}function ot(e){let t={apiKey:e?.apiKey,baseUrl:e?.baseUrl},n;function r(){return n||(n=Ie(t)),n}return async function(a){let i;try{i=await a.json()}catch{return new Response(JSON.stringify({error:"Invalid JSON"}),{status:400,headers:{"Content-Type":"application/json"}})}if(!Array.isArray(i.events)||i.events.length===0)return new Response(JSON.stringify({error:"Missing or empty events array"}),{status:400,headers:{"Content-Type":"application/json"}});try{let s=r(),u=[];for(let c of i.events){let f=rt(c),l=await s.track(f);u.push(l.eventId)}return await s.flush(),new Response(JSON.stringify({ok:!0,accepted:u.length}),{status:200,headers:{"Content-Type":"application/json"}})}catch(s){let u=s instanceof Error?s.message:"Unknown error";return new Response(JSON.stringify({error:u}),{status:500,headers:{"Content-Type":"application/json"}})}}}var q=class{cached=null;pending=null;config;constructor(t){this.config=t}async getToken(t,n){return this.cached&&Date.now()<this.cached.expiresAt-12e4?this.cached.token:this.pending?this.pending:(this.pending=this.mint(t,n).finally(()=>{this.pending=null}),this.pending)}async mint(t,n){let r=it(this.config.baseUrl,"/api/mcp/widget-tokens"),o={};t&&(o.sessionId=t),n&&(o.traceId=n);try{let a=await fetch(r,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.config.apiKey}`},body:JSON.stringify(o)});if(!a.ok)return null;let i=await a.json(),s=i.data&&typeof i.data=="object"?i.data:i,u=new Date(s.expiresAt).getTime();return!s.token||Number.isNaN(u)?null:(this.cached={token:s.token,expiresAt:u},s.token)}catch{return null}}};function it(e,t){return`${e.endsWith("/")?e.slice(0,-1):e}${t}`}var Ce="waniwani/sessionId",X="waniwani/geoLocation",J="waniwani/userLocation";function v(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function $(e){if(!v(e))return;let t=e._meta;return v(t)?t:void 0}function G(e){if(!v(e))return;let t=e.content;return Array.isArray(t)?t.find(r=>v(r)&&r.type==="text"&&typeof r.text=="string")?.text:void 0}function st(e,t){return typeof t=="function"?t(e)??"other":t??"other"}function Z(e,t,n,r,o){let a=st(e,n.toolType),i=$(t);return{event:"tool.called",properties:{name:e,type:a,...r??{}},meta:i,metadata:{source:"withWaniwani",...n.metadata??{},...o&&{clientInfo:o}}}}async function Q(e,t,n){try{await e.track(t)}catch(r){n?.(te(r))}}async function ee(e,t){try{await e.flush()}catch(n){t?.(te(n))}}async function be(e,t,n,r){if(!v(e))return;v(e._meta)||(e._meta={});let o=e._meta,a=v(o.waniwani)?o.waniwani:void 0,i={...a??{},endpoint:a?.endpoint??`${n.replace(/\/$/,"")}/api/mcp/events/v2/batch`};if(t)try{let c=await t.getToken();c&&(i.token=c)}catch(c){r?.(te(c))}let s=F(o);s&&(i.sessionId||(i.sessionId=s));let u=Me(o);u!==void 0&&(i.geoLocation||(i.geoLocation=u)),o.waniwani=i}function _e(e,t){let n=$(t);if(!n||!v(e))return;v(e._meta)||(e._meta={});let r=e._meta,o=F(n);o&&!r[Ce]&&(r[Ce]=o);let a=Me(n);a&&(r[X]||(r[X]=a),r[J]||(r[J]=a))}function Me(e){if(!e)return;let t=e[X]??e[J];if(v(t)||typeof t=="string")return t}function te(e){return e instanceof Error?e:new Error(String(e))}var Fe="https://app.waniwani.ai";function at(e,t){let n=e;if(n.__waniwaniWrapped)return n;n.__waniwaniWrapped=!0;let r=t.client,o=t.injectWidgetToken!==!1,a=null;function i(){if(a)return a;let u=r._config.apiKey;return u?(a=new q({baseUrl:r._config.baseUrl??Fe,apiKey:u}),a):null}let s=e.registerTool.bind(e);return n.registerTool=((...u)=>{let[c,f,l]=u,d=typeof c=="string"&&c.trim().length>0?c:"unknown";if(typeof l!="function")return s(...u);let y=l;return s(c,f,async(w,g)=>{let x=$(g)??{};return V.run({meta:x},async()=>{let k=performance.now(),R=e.server?.getClientVersion?.();try{let T=await y(w,g),b=Math.round(performance.now()-k),E=v(T)&&T.isError===!0;if(E){let ne=G(T);console.error(`[waniwani] Tool "${d}" returned error${ne?`: ${ne}`:""}`)}return await Q(r,Z(d,g,t,{durationMs:b,status:E?"error":"ok",...E&&{errorMessage:G(T)??"Unknown tool error"}},R),t.onError),t.flushAfterToolCall&&await ee(r,t.onError),_e(T,g),o&&await be(T,i(),r._config.baseUrl??Fe,t.onError),T}catch(T){let b=Math.round(performance.now()-k);throw await Q(r,Z(d,g,t,{durationMs:b,status:"error",errorMessage:T instanceof Error?T.message:String(T)},R),t.onError),t.flushAfterToolCall&&await ee(r,t.onError),T}})})}),n}export{C as END,I as START,M as StateGraph,pe as createFlow,ge as createFlowTestHarness,ye as createResource,Be as createTool,ot as createTrackingRoute,L as detectPlatform,We as isMCPApps,Pe as isOpenAI,je as registerTools,at as withWaniwani};
|
|
6
6
|
//# sourceMappingURL=index.js.map
|