@fungi.computer/grove 0.0.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{Effect-BEduymlz.js → Effect-CxgtVs4O.js} +1 -1
- package/dist/assets/{anthropic-messages-Bnv5qjAJ.js → anthropic-messages-DVt3Yh9K.js} +3 -3
- package/dist/assets/base-face-BaB6vmvy.js +1 -0
- package/dist/assets/burger-CoqBXzRV.js +1 -0
- package/dist/assets/cat-2dRm7fBw.js +1 -0
- package/dist/assets/compat-fz0ZcRJH.js +2 -0
- package/dist/assets/document-D5hwZS3o.js +1 -0
- package/dist/assets/extension-hook-0UB2lkEs.js +560 -0
- package/dist/assets/{extensions-1Fd4Wd8r.js → extensions-CAsZR9ky.js} +1 -1
- package/dist/assets/index-Bw6tV9qS.css +1 -0
- package/dist/assets/index-DRDNbHYF.js +171 -0
- package/dist/assets/mushroom-B9t9hgQE.js +1 -0
- package/dist/assets/{node.browser-CwSOSQcL.js → node.browser-hsQQ6fyG.js} +1 -1
- package/dist/assets/{openai-codex-responses-BMz-j1hp.js → openai-codex-responses-CA-ivUEd.js} +1 -1
- package/dist/assets/parakeet-conversation-w0nznEs9.js +3 -0
- package/dist/assets/renderer-s3PB0XrL.js +1 -0
- package/dist/assets/runtime-core-GKyHklNK.js +2 -0
- package/dist/index.html +6 -4
- package/package.json +15 -12
- package/dist/assets/base-face-CJPKiwfc.js +0 -1
- package/dist/assets/burger-DMbWZ2jd.js +0 -1
- package/dist/assets/cat-UfLh6DHG.js +0 -1
- package/dist/assets/compat-CvJ9Wfru.js +0 -2
- package/dist/assets/extension-hook-DvcdepgP.js +0 -560
- package/dist/assets/index-DBHVAvuX.css +0 -1
- package/dist/assets/index-hJphFjkO.js +0 -171
- package/dist/assets/mushroom-BBaCYNmw.js +0 -1
- package/dist/assets/parakeet-conversation-C3pQoKx-.js +0 -3
- package/dist/assets/renderer-BdjuCi44.js +0 -1
- package/dist/assets/runtime-core-CvcjUkf6.js +0 -2
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./renderer-BdjuCi44.js";import{t}from"./index-hJphFjkO.js";var n={version:1,name:`mushroom`,renderer:`zdog`,controls:{body:{type:`color`,label:`body`,default:`#fff7e4`},cap:{type:`color`,label:`cap`,default:`#f98284`},capSpot:{type:`color`,label:`capSpot`,default:`#ffe6c6`},eye:{type:`color`,label:`eye`,default:`#28282e`},mouth:{type:`color`,label:`mouth`,default:`#28282e`},blush:{type:`color`,label:`blush`,default:`#feaae4`},dead:{type:`color`,label:`dead`,default:`#6c5671`},deadTongue:{type:`color`,label:`deadTongue`,default:`#d9c8bf`},tongue:{type:`color`,label:`tongue`,default:`#f98284`},sweat:{type:`color`,label:`sweat`,default:`#accce4`},white:{type:`color`,label:`white`,default:`#ffffff`}},data:JSON.parse(`{"root":"node-0","nodes":[{"id":"node-0","kind":"group","options":{"name":"root"}},{"id":"node-1","parent":"node-0","kind":"group","options":{"name":"body","updateSort":true}},{"id":"node-2","parent":"node-1","kind":"hemisphere","options":{"name":"body.hemisphere","translate":{"y":2},"rotate":{"x":4.71238898038469},"color":"\\u0000sprite-color:body","stroke":false,"backface":"\\u0000sprite-color:cap","diameter":32}},{"id":"node-3","parent":"node-1","kind":"hemisphere","options":{"name":"cap.hemisphere","translate":{"y":2},"rotate":{"x":1.5707963267948966},"color":"\\u0000sprite-color:cap","stroke":false,"backface":"\\u0000sprite-color:capSpot","diameter":42}},{"id":"node-4","parent":"node-3","kind":"shape","options":{"name":"cap.spot.front","translate":{"x":-8,"y":8,"z":12},"color":"\\u0000sprite-color:capSpot","stroke":12,"path":[{"x":0,"y":0}]}},{"id":"node-5","parent":"node-3","kind":"shape","options":{"name":"cap.spot.top","translate":{"x":8,"y":-4,"z":13},"color":"\\u0000sprite-color:capSpot","stroke":18,"path":[{"x":0,"y":0}]}},{"id":"node-6","parent":"node-1","kind":"group","options":{"name":"face","translate":{"y":7,"z":8}}},{"id":"node-7","parent":"node-6","kind":"group","options":{"name":"eyes"}},{"id":"node-8","parent":"node-7","kind":"group","options":{"name":"eyes.normal"}},{"id":"node-9","parent":"node-8","kind":"group","options":{"translate":{"x":-6,"y":-2}}},{"id":"node-10","parent":"node-9","kind":"ellipse","options":{"color":"\\u0000sprite-color:eye","stroke":1.5,"fill":true,"width":3,"height":5}},{"id":"node-11","parent":"node-9","kind":"ellipse","options":{"translate":{"y":-1,"z":1},"color":"\\u0000sprite-color:white","stroke":0.5,"fill":true,"width":1.5,"height":2}},{"id":"node-12","parent":"node-8","kind":"group","options":{"translate":{"x":6,"y":-2}}},{"id":"node-13","parent":"node-12","kind":"ellipse","options":{"color":"\\u0000sprite-color:eye","stroke":1.5,"fill":true,"width":3,"height":5}},{"id":"node-14","parent":"node-12","kind":"ellipse","options":{"translate":{"y":-1,"z":1},"color":"\\u0000sprite-color:white","stroke":0.5,"fill":true,"width":1.5,"height":2}},{"id":"node-15","parent":"node-7","kind":"group","options":{"name":"eyes.sad"}},{"id":"node-16","parent":"node-15","kind":"group","options":{"translate":{"x":-6,"y":-1},"rotate":{"z":0.2}}},{"id":"node-17","parent":"node-16","kind":"ellipse","options":{"color":"\\u0000sprite-color:eye","stroke":1.5,"fill":true,"width":3,"height":4}},{"id":"node-18","parent":"node-16","kind":"ellipse","options":{"translate":{"y":-1,"z":1},"color":"\\u0000sprite-color:white","stroke":0.5,"fill":true,"width":1.5,"height":2}},{"id":"node-19","parent":"node-15","kind":"group","options":{"translate":{"x":6,"y":-1},"rotate":{"z":-0.2}}},{"id":"node-20","parent":"node-19","kind":"ellipse","options":{"color":"\\u0000sprite-color:eye","stroke":1.5,"fill":true,"width":3,"height":4}},{"id":"node-21","parent":"node-19","kind":"ellipse","options":{"translate":{"y":-1,"z":1},"color":"\\u0000sprite-color:white","stroke":0.5,"fill":true,"width":1.5,"height":2}},{"id":"node-22","parent":"node-7","kind":"group","options":{"name":"eyes.surprised"}},{"id":"node-23","parent":"node-22","kind":"group","options":{"translate":{"x":-6,"y":-2}}},{"id":"node-24","parent":"node-23","kind":"ellipse","options":{"color":"\\u0000sprite-color:eye","stroke":1.5,"fill":true,"width":4,"height":5}},{"id":"node-25","parent":"node-23","kind":"ellipse","options":{"translate":{"y":-1,"z":1},"color":"\\u0000sprite-color:white","stroke":0.5,"fill":true,"width":1.5,"height":2}},{"id":"node-26","parent":"node-22","kind":"group","options":{"translate":{"x":6,"y":-2}}},{"id":"node-27","parent":"node-26","kind":"ellipse","options":{"color":"\\u0000sprite-color:eye","stroke":1.5,"fill":true,"width":4,"height":5}},{"id":"node-28","parent":"node-26","kind":"ellipse","options":{"translate":{"y":-1,"z":1},"color":"\\u0000sprite-color:white","stroke":0.5,"fill":true,"width":1.5,"height":2}},{"id":"node-29","parent":"node-7","kind":"group","options":{"name":"eyes.happy"}},{"id":"node-30","parent":"node-29","kind":"shape","options":{"translate":{"x":-6,"y":-2},"color":"\\u0000sprite-color:eye","stroke":1.5,"path":[{"x":-2.5,"y":2},{"bezier":[{"x":-1,"y":-1.5},{"x":1,"y":-1.5},{"x":2.5,"y":2}]}],"closed":false}},{"id":"node-31","parent":"node-29","kind":"shape","options":{"translate":{"x":6,"y":-2},"color":"\\u0000sprite-color:eye","stroke":1.5,"path":[{"x":-2.5,"y":2},{"bezier":[{"x":-1,"y":-1.5},{"x":1,"y":-1.5},{"x":2.5,"y":2}]}],"closed":false}},{"id":"node-32","parent":"node-7","kind":"group","options":{"name":"eyes.angry"}},{"id":"node-33","parent":"node-32","kind":"group","options":{"translate":{"x":-6,"y":-1},"rotate":{"z":-0.3}}},{"id":"node-34","parent":"node-33","kind":"ellipse","options":{"color":"\\u0000sprite-color:eye","stroke":1.5,"fill":true,"width":3,"height":4}},{"id":"node-35","parent":"node-33","kind":"shape","options":{"translate":{"y":-1},"color":"\\u0000sprite-color:eye","stroke":1.5,"path":[{"x":-3,"y":-3},{"x":3,"y":-2}]}},{"id":"node-36","parent":"node-32","kind":"group","options":{"translate":{"x":6,"y":-1},"rotate":{"z":0.3}}},{"id":"node-37","parent":"node-36","kind":"ellipse","options":{"color":"\\u0000sprite-color:eye","stroke":1.5,"fill":true,"width":3,"height":4}},{"id":"node-38","parent":"node-36","kind":"shape","options":{"translate":{"y":-1},"color":"\\u0000sprite-color:eye","stroke":1.5,"path":[{"x":-3,"y":-3},{"x":3,"y":-2}]}},{"id":"node-39","parent":"node-7","kind":"group","options":{"name":"eyes.dead"}},{"id":"node-40","parent":"node-39","kind":"group","options":{"translate":{"x":-6,"y":-2}}},{"id":"node-41","parent":"node-40","kind":"shape","options":{"color":"\\u0000sprite-color:dead","stroke":1.5,"path":[{"x":-2,"y":-3},{"x":2,"y":3}]}},{"id":"node-42","parent":"node-40","kind":"shape","options":{"color":"\\u0000sprite-color:dead","stroke":1.5,"path":[{"x":2,"y":-3},{"x":-2,"y":3}]}},{"id":"node-43","parent":"node-39","kind":"group","options":{"translate":{"x":6,"y":-2}}},{"id":"node-44","parent":"node-43","kind":"shape","options":{"color":"\\u0000sprite-color:dead","stroke":1.5,"path":[{"x":-2,"y":-3},{"x":2,"y":3}]}},{"id":"node-45","parent":"node-43","kind":"shape","options":{"color":"\\u0000sprite-color:dead","stroke":1.5,"path":[{"x":2,"y":-3},{"x":-2,"y":3}]}},{"id":"node-46","parent":"node-7","kind":"group","options":{"name":"eyes.confused"}},{"id":"node-47","parent":"node-46","kind":"group","options":{"translate":{"x":-6,"y":-2}}},{"id":"node-48","parent":"node-47","kind":"ellipse","options":{"color":"\\u0000sprite-color:eye","stroke":1.5,"fill":true,"width":3,"height":5}},{"id":"node-49","parent":"node-47","kind":"shape","options":{"color":"\\u0000sprite-color:eye","stroke":1.5,"path":[{"x":-3,"y":-4},{"x":3,"y":-2}]}},{"id":"node-50","parent":"node-46","kind":"group","options":{"translate":{"x":6,"y":-2}}},{"id":"node-51","parent":"node-50","kind":"ellipse","options":{"color":"\\u0000sprite-color:eye","stroke":1.5,"fill":true,"width":3,"height":5}},{"id":"node-52","parent":"node-7","kind":"group","options":{"name":"eyes.sleepy"}},{"id":"node-53","parent":"node-52","kind":"shape","options":{"translate":{"x":-6,"y":-1},"color":"\\u0000sprite-color:eye","stroke":1.5,"path":[{"x":-2.5,"y":1},{"bezier":[{"x":-1,"y":0},{"x":1,"y":0},{"x":2.5,"y":1}]}],"closed":false}},{"id":"node-54","parent":"node-52","kind":"shape","options":{"translate":{"x":6,"y":-1},"color":"\\u0000sprite-color:eye","stroke":1.5,"path":[{"x":-2.5,"y":1},{"bezier":[{"x":-1,"y":0},{"x":1,"y":0},{"x":2.5,"y":1}]}],"closed":false}},{"id":"node-55","parent":"node-7","kind":"group","options":{"name":"eyes.nervous"}},{"id":"node-56","parent":"node-55","kind":"group","options":{"translate":{"x":-6,"y":-2}}},{"id":"node-57","parent":"node-56","kind":"ellipse","options":{"color":"\\u0000sprite-color:eye","stroke":1.5,"fill":true,"width":3,"height":5}},{"id":"node-58","parent":"node-55","kind":"group","options":{"translate":{"x":6,"y":-2}}},{"id":"node-59","parent":"node-58","kind":"ellipse","options":{"color":"\\u0000sprite-color:eye","stroke":1.5,"fill":true,"width":3,"height":5}},{"id":"node-60","parent":"node-55","kind":"group","options":{"translate":{"x":10,"y":4}}},{"id":"node-61","parent":"node-60","kind":"shape","options":{"color":"\\u0000sprite-color:sweat","stroke":2,"path":[{"x":0,"y":-4}]}},{"id":"node-62","parent":"node-60","kind":"ellipse","options":{"translate":{"y":2},"color":"\\u0000sprite-color:sweat","stroke":0,"fill":true,"width":3,"height":4}},{"id":"node-63","parent":"node-7","kind":"group","options":{"name":"eyes.shy"}},{"id":"node-64","parent":"node-63","kind":"ellipse","options":{"translate":{"x":-6,"y":-2},"color":"\\u0000sprite-color:eye","stroke":1.5,"fill":true,"width":2.5,"height":2}},{"id":"node-65","parent":"node-63","kind":"ellipse","options":{"translate":{"x":6,"y":-2},"color":"\\u0000sprite-color:eye","stroke":1.5,"fill":true,"width":2.5,"height":2}},{"id":"node-66","parent":"node-7","kind":"group","options":{"name":"eyes.cute"}},{"id":"node-67","parent":"node-66","kind":"group","options":{"translate":{"x":-6,"y":-1}}},{"id":"node-68","parent":"node-67","kind":"ellipse","options":{"color":"\\u0000sprite-color:eye","stroke":1.5,"fill":true,"width":5,"height":6}},{"id":"node-69","parent":"node-67","kind":"ellipse","options":{"translate":{"y":-1.5,"z":1},"color":"\\u0000sprite-color:white","stroke":0,"fill":true,"width":2.5,"height":3}},{"id":"node-70","parent":"node-67","kind":"ellipse","options":{"translate":{"x":-1.5,"y":1.5,"z":1},"color":"\\u0000sprite-color:white","stroke":0,"fill":true,"width":1,"height":1}},{"id":"node-71","parent":"node-66","kind":"group","options":{"translate":{"x":6,"y":-1}}},{"id":"node-72","parent":"node-71","kind":"ellipse","options":{"color":"\\u0000sprite-color:eye","stroke":1.5,"fill":true,"width":5,"height":6}},{"id":"node-73","parent":"node-71","kind":"ellipse","options":{"translate":{"y":-1.5,"z":1},"color":"\\u0000sprite-color:white","stroke":0,"fill":true,"width":2.5,"height":3}},{"id":"node-74","parent":"node-71","kind":"ellipse","options":{"translate":{"x":-1.5,"y":1.5,"z":1},"color":"\\u0000sprite-color:white","stroke":0,"fill":true,"width":1,"height":1}},{"id":"node-75","parent":"node-7","kind":"group","options":{"name":"eyes.wink"}},{"id":"node-76","parent":"node-75","kind":"group","options":{"name":"eyes.wink.left"}},{"id":"node-77","parent":"node-76","kind":"shape","options":{"translate":{"x":-6,"y":-2},"color":"\\u0000sprite-color:eye","stroke":1.5,"path":[{"x":-2.5,"y":2},{"bezier":[{"x":-1,"y":-1.5},{"x":1,"y":-1.5},{"x":2.5,"y":2}]}],"closed":false}},{"id":"node-78","parent":"node-76","kind":"ellipse","options":{"translate":{"x":6,"y":-2},"color":"\\u0000sprite-color:eye","stroke":1.5,"fill":true,"width":3,"height":5}},{"id":"node-79","parent":"node-75","kind":"group","options":{"name":"eyes.wink.right"}},{"id":"node-80","parent":"node-79","kind":"shape","options":{"translate":{"x":6,"y":-2},"color":"\\u0000sprite-color:eye","stroke":1.5,"path":[{"x":-2.5,"y":2},{"bezier":[{"x":-1,"y":-1.5},{"x":1,"y":-1.5},{"x":2.5,"y":2}]}],"closed":false}},{"id":"node-81","parent":"node-79","kind":"ellipse","options":{"translate":{"x":-6,"y":-2},"color":"\\u0000sprite-color:eye","stroke":1.5,"fill":true,"width":3,"height":5}},{"id":"node-82","parent":"node-6","kind":"group","options":{"name":"mouth"}},{"id":"node-83","parent":"node-82","kind":"shape","options":{"name":"mouth.normal","translate":{"y":2},"color":"\\u0000sprite-color:mouth","stroke":1.5,"path":[{"x":-2.5,"y":0},{"x":2.5,"y":0}],"closed":false}},{"id":"node-84","parent":"node-82","kind":"shape","options":{"name":"mouth.happy","translate":{"y":2},"color":"\\u0000sprite-color:mouth","stroke":1.5,"path":[{"x":-2.5,"y":2},{"bezier":[{"x":0,"y":4},{"x":2.5,"y":2},{"x":2.5,"y":2}]}],"closed":false}},{"id":"node-85","parent":"node-82","kind":"shape","options":{"name":"mouth.sad","translate":{"y":2},"color":"\\u0000sprite-color:mouth","stroke":1.5,"path":[{"x":-2.5,"y":2},{"bezier":[{"x":0,"y":0},{"x":2.5,"y":2},{"x":2.5,"y":2}]}],"closed":false}},{"id":"node-86","parent":"node-82","kind":"shape","options":{"name":"mouth.small","translate":{"y":2},"color":"\\u0000sprite-color:mouth","stroke":1,"path":[{"x":-1.5,"y":0},{"x":1.5,"y":0}],"closed":false}},{"id":"node-87","parent":"node-82","kind":"shape","options":{"name":"mouth.worried","translate":{"y":2},"color":"\\u0000sprite-color:mouth","stroke":1,"path":[{"x":-2,"y":1},{"bezier":[{"x":-0.5,"y":0.5},{"x":0.5,"y":0.5},{"x":2,"y":1}]}],"closed":false}},{"id":"node-88","parent":"node-82","kind":"ellipse","options":{"name":"mouth.pout","translate":{"y":3},"color":"\\u0000sprite-color:mouth","stroke":1.5,"fill":true,"width":2,"height":2.5}},{"id":"node-89","parent":"node-82","kind":"ellipse","options":{"name":"mouth.surprised","translate":{"y":3},"color":"\\u0000sprite-color:mouth","stroke":1.5,"fill":true,"width":3,"height":4}},{"id":"node-90","parent":"node-82","kind":"group","options":{"name":"mouth.dead","translate":{"y":5}}},{"id":"node-91","parent":"node-90","kind":"ellipse","options":{"color":"\\u0000sprite-color:dead","stroke":1.5,"fill":true,"width":3,"height":2}},{"id":"node-92","parent":"node-90","kind":"ellipse","options":{"translate":{"y":0.5},"color":"\\u0000sprite-color:deadTongue","stroke":0,"fill":true,"width":1.5,"height":1}},{"id":"node-93","parent":"node-82","kind":"group","options":{"name":"mouth.open","translate":{"y":2}}},{"id":"node-94","parent":"node-93","kind":"ellipse","options":{"color":"\\u0000sprite-color:mouth","stroke":1.5,"fill":true,"width":6,"height":4}},{"id":"node-95","parent":"node-93","kind":"ellipse","options":{"name":"mouth.tongue","translate":{"y":1},"color":"\\u0000sprite-color:tongue","stroke":0,"fill":true,"width":3,"height":1.5}},{"id":"node-96","parent":"node-6","kind":"group","options":{"name":"blush.off"}},{"id":"node-97","parent":"node-6","kind":"group","options":{"name":"blush.medium"}},{"id":"node-98","parent":"node-97","kind":"ellipse","options":{"translate":{"x":-10,"y":4},"color":"\\u0000sprite-color:blush","stroke":1,"fill":true,"width":5,"height":2.5}},{"id":"node-99","parent":"node-97","kind":"ellipse","options":{"translate":{"x":10,"y":4},"color":"\\u0000sprite-color:blush","stroke":1,"fill":true,"width":5,"height":2.5}}],"palette":{"body":"#fff7e4","cap":"#f98284","capSpot":"#ffe6c6","eye":"#28282e","mouth":"#28282e","blush":"#feaae4","dead":"#6c5671","deadTongue":"#d9c8bf","tongue":"#f98284","sweat":"#accce4","white":"#ffffff"},"variants":{"eyes":{"normal":"node-8","happy":"node-29","sad":"node-15","angry":"node-32","surprised":"node-22","dead":"node-39","confused":"node-46","sleepy":"node-52","nervous":"node-55","shy":"node-63","wink":"node-76","cute":"node-66","wink.left":"node-76","wink.right":"node-79"},"mouth":{"normal":"node-83","happy":"node-84","sad":"node-85","angry":"node-85","surprised":"node-89","dead":"node-90","small":"node-86","worried":"node-87","pout":"node-88","open":"node-93"},"blush":{"off":"node-96","small":"node-97","medium":"node-97","big":"node-97"}},"expressions":{"angry":{"variants":{"eyes":"angry","mouth":"angry","blush":"off"},"motion":{"target":"root","translate":{"x":1,"y":0},"durationMs":150,"repeat":"none"}},"confused":{"variants":{"eyes":"confused","mouth":"normal","blush":"off"},"motion":{"target":"root","translate":{"x":0,"y":0.5},"durationMs":150,"repeat":"none"}},"cute":{"variants":{"eyes":"cute","mouth":"happy","blush":"big"},"motion":{"target":"root","translate":{"x":0,"y":-2.5},"durationMs":150,"repeat":"none"}},"dead":{"variants":{"eyes":"dead","mouth":"dead","blush":"off"}},"happy":{"variants":{"eyes":"happy","mouth":"happy","blush":"medium"},"motion":{"target":"root","translate":{"x":0,"y":-2},"durationMs":150,"repeat":"none"}},"nervous":{"variants":{"eyes":"nervous","mouth":"worried","blush":"off"},"motion":{"target":"root","translate":{"x":-0.5,"y":-1},"durationMs":150,"repeat":"none"}},"normal":{"variants":{"eyes":"normal","mouth":"normal","blush":"off"},"motion":{"target":"root","translate":{"x":0,"y":1},"durationMs":150,"repeat":"none"}},"pleading":{"variants":{"eyes":"cute","mouth":"pout","blush":"medium"},"motion":{"target":"root","translate":{"x":0,"y":-1},"durationMs":150,"repeat":"none"}},"sad":{"variants":{"eyes":"sad","mouth":"sad","blush":"off"},"motion":{"target":"root","translate":{"x":0,"y":2},"durationMs":150,"repeat":"none"}},"shy":{"variants":{"eyes":"shy","mouth":"small","blush":"small"},"motion":{"target":"root","translate":{"x":0,"y":1.5},"durationMs":150,"repeat":"none"}},"sleepy":{"variants":{"eyes":"sleepy","mouth":"small","blush":"off"},"motion":{"target":"root","translate":{"x":0,"y":2},"durationMs":150,"repeat":"none"}},"surprised":{"variants":{"eyes":"surprised","mouth":"surprised","blush":"off"},"motion":{"target":"root","translate":{"x":0,"y":-3},"durationMs":150,"repeat":"none"}},"wink":{"variants":{"mouth":"happy","blush":"small"},"variantChoices":{"eyes":["wink.left","wink.right"]},"motion":{"target":"root","translate":{"x":0,"y":-1.5},"durationMs":150,"repeat":"none"}}},"activities":{"idle":{"motion":{"target":"root","translate":{"y":0.5},"durationMs":2000,"repeat":"yoyo"},"mouseInfluence":1},"listening":{"motion":{"target":"root","rotate":{"x":-0.2},"durationMs":300,"repeat":"yoyo"},"mouseInfluence":0.3},"processing":{"mouseInfluence":0.2},"speaking":{"motion":{"target":"root","translate":{"y":0.5},"durationMs":1500,"repeat":"yoyo"},"mouseInfluence":0,"mouthCycle":[{"durationMs":100,"mouth":"open"},{"durationMs":150,"mouth":"base"},{"durationMs":100,"mouth":"open"},{"durationMs":200,"mouth":"base"}]},"thinking":{"motion":{"target":"root","rotate":{"z":0.1},"durationMs":800,"repeat":"yoyo"},"mouseInfluence":0},"error":{"motion":{"target":"root","rotate":{"x":0.9},"durationMs":600,"repeat":"none"},"mouseInfluence":0.1,"geometry":{"eyes":"dead","mouth":"dead"}}},"defaultPresentation":{"activity":"idle","expression":"sleepy"}}`)},r={document:t.parse(n),render:e};export{r as default};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{$i as t,Bi as n,Jn as r,fa as i,na as a,oa as o,ra as s,sa as c,ut as l}from"./Effect-BEduymlz.js";import{$r as u,Ci as d,Cr as f,Di as p,Fi as m,Fr as h,Hr as ee,Ii as g,Ir as te,Mr as _,Nr as ne,Pi as v,Sr as y,Tr as b,Vn as re,Xr as ie,ci as ae,cr as x,di as S,dr as C,hi as oe,hr as w,i as T,ji as E,mr as D,or as O,wr as k,xr as A}from"./extension-hook-DvcdepgP.js";import{$ as se,G as ce,J as le,K as ue,Q as de,X as j,Y as fe,Z as pe,_ as M,a as me,c as N,et as he,f as ge,g as P,h as _e,i as ve,m as ye,n as be,o as xe,p as Se,q as Ce,r as we,s as Te,tt as Ee}from"./index-hJphFjkO.js";import"./extensions-1Fd4Wd8r.js";function F(e){return b({nextSequence:C.check(ae(0)),omitted:C.check(S(0)),events:O(b({id:k,sequence:C,at:C,commandId:A(k),event:e}))})}new TextEncoder;var I=te(e=>_e.safeParse(e).success,{representation:{id:`@fungi.computer/whistle/catalog-step/v1`,payload:null}});l(()=>re());var L=k.pipe(h(p(1)),h(d(4e3)),h(E(/\S/u,{message:`Goal objective is blank`})));k.pipe(h(p(1)),h(d(1e3)),h(E(/\S/u)));var De=k.pipe(h(p(1)),h(d(256))),R=b({revision:k,objective:L,state:w([`active`,`paused`,`complete`,`blocked`]),stopReason:A(k)}),Oe=_([b({action:D(`set`),objective:L,requestId:De,expectedRevision:m(A(k)),confirmed:m(x)}),b({action:w([`pause`,`resume`,`replace`,`clear`])}),b({})]),ke=b({goal:A(R),history:F(R)}),Ae={id:T.make(`botanical-session-goal`),commands:{goal:{scope:`session`,input:Oe,output:I},pause:{scope:`session`,input:b({}),output:R},resume:{scope:`session`,input:b({}),output:R},clear:{scope:`session`,input:b({}),output:b({})},set:{scope:`session`,input:b({objective:L,expectedRevision:A(k),requestId:De}),output:b({goal:R,accepted:b({status:D(`accepted`),commandId:k})})}},projection:{schema:ke}},z=e=>e.state===`blocked`?`error`:e.state===`complete`?`settled`:e.state===`paused`?`muted`:`running`,je=P(Ae,{correlatedPrompts:`note`,contribute:e=>{if(e.status!==`running`||e.value===null)return{chips:[],panel:[],timeline:{cells:[],omitted:0},waiting:null};let{goal:t,history:n}=e.value,r=[];if(t!==null){let e={id:`goal`,title:t.objective,detail:`Goal · ${t.state}`,tone:z(t)};r.push(t.state===`active`||t.state===`paused`?{...e,actions:[{id:`goal`,label:t.state===`active`?`Pause goal`:`Resume goal`,input:{action:t.state===`active`?`pause`:`resume`}}]}:e),t.stopReason!==null&&r.push({id:`reason`,title:t.stopReason.slice(0,4096),tone:`attention`})}return{chips:t===null?[]:[{id:`goal`,order:1,row:{id:`goal`,title:`Goal ${t.state}${t.stopReason?.startsWith(`Stalled:`)?`: stalled`:``}`,tone:z(t)}}],panel:r,timeline:{omitted:n.omitted,cells:n.events.map(({event:e,...t})=>({...t,rows:[{id:`state`,title:`Goal ${e.state}`,tone:z(e)},{id:`objective`,title:e.objective},...e.stopReason===null?[]:[{id:`reason`,title:e.stopReason.slice(0,4096),tone:z(e)}]]}))},waiting:null}}}),B=k.pipe(h(p(1)),h(d(262144))),V=k.pipe(h(p(1)),h(d(200))),Me=b({expression:k.pipe(h(p(1)),h(d(256))),timeZone:k.pipe(h(p(1)),h(d(128)))}),H=b({loopId:k,origin:w([`human`,`model`]),expiresAt:A(C),prompt:B,mode:w([`self_paced`,`fixed_interval`]),cron:A(Me),state:w([`active`,`paused`,`finished`,`failed`,`cancelled`]),commandId:k,reason:A(k),nextDueAt:A(C),lastError:A(k)}),Ne=b({loop:H,accepted:b({status:D(`accepted`),commandId:k})}),Pe=_([b({action:D(`start`),text:B,requestId:V}),b({action:w([`status`,`pause`,`resume`,`stop`,`new`])}),b({})]),Fe=b({loop:A(H),history:F(H)}),Ie={id:T.make(`botanical-session-loop`),commands:{loop:{scope:`session`,input:Pe,output:I},startSelfPaced:{scope:`session`,input:b({prompt:B,requestId:V}),output:Ne},startFixedInterval:{scope:`session`,input:b({prompt:B,requestId:V,...Me.fields}),output:Ne},pause:{scope:`session`,input:b({}),output:H},resume:{scope:`session`,input:b({}),output:H},stop:{scope:`session`,input:b({}),output:H}},projection:{schema:Fe}},U=e=>e.state===`failed`?`error`:e.state===`active`?`running`:e.state===`paused`?`muted`:`settled`,Le=e=>new Intl.DateTimeFormat(void 0,{year:`numeric`,month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`,timeZoneName:`short`}).format(e),Re=P(Ie,{contribute:e=>{if(e.status!==`running`||e.value===null)return{chips:[],panel:[],timeline:{cells:[],omitted:0},waiting:null};let{loop:t,history:n}=e.value,r=t!==null&&t.state===`active`&&t.nextDueAt!==null;return{chips:t===null||t.state!==`active`&&t.state!==`paused`?[]:[{id:`loop`,order:2,row:{id:`loop`,title:`Loop ${t.mode===`self_paced`?`self-paced`:`fixed`}${r?` (waiting)`:``}`,tone:U(t)}}],panel:t===null?[]:[{id:`loop`,title:`Loop · ${t.state} · ${t.mode===`self_paced`?`self-paced`:`${t.cron?.expression??`fixed`} ${t.cron?.timeZone??``}`}${t.nextDueAt===null?``:` · Next ${Le(t.nextDueAt)}`}`,detail:t.prompt.slice(0,1024),tone:U(t)},...t.lastError===null?[]:[{id:`error`,title:t.lastError.slice(0,4096),tone:`error`}]],timeline:{omitted:n.omitted,cells:n.events.map(({event:e,...t})=>({...t,rows:[{id:`loop`,title:`Loop ${e.state}`,detail:(e.lastError??e.reason??e.prompt).slice(0,1024),tone:U(e)}]}))},waiting:r?{summary:`Waiting until ${Le(t.nextDueAt)}`,cancel:{id:`loop`,label:`stop loop`,input:{action:`stop`}}}:null}}}),W=b({explanation:g(k.pipe(h(d(2e3)))),steps:O(b({step:k.pipe(h(p(1)),h(d(500))),status:w([`pending`,`in_progress`,`completed`])})).pipe(h(d(50)))});W.pipe(h(v(e=>e.steps.filter(e=>e.status===`in_progress`).length<=1||`At most one plan step may be in progress`)));function ze(e){return e.steps.some(e=>e.status!==`completed`)}var Be=b({plan:W,history:F(W)}),Ve=_([b({action:D(`clear`)}),b({})]),He={id:T.make(`botanical-session-plan`),commands:{plan:{scope:`session`,input:Ve,output:I}},projection:{schema:Be}},Ue=e=>{let t=e.steps.findIndex(e=>e.status===`in_progress`),n=e.steps.filter(e=>e.status===`completed`).length;return{title:(t<0?e.steps.find(e=>e.status===`pending`):e.steps[t])?.step??`Plan complete`,detail:`${String(t<0?n:t+1)}/${String(e.steps.length)}`}},We=e=>e.steps.map((e,t)=>({id:String(t),title:e.step,tone:e.status===`completed`?`settled`:e.status===`in_progress`?`running`:`muted`})),Ge=P(He,{contribute:e=>({chips:[],panel:e.status!==`running`||e.value===null||!ze(e.value.plan)?[]:[{id:`plan`,...Ue(e.value.plan),actions:[{id:`plan`,label:`Clear plan`,input:{action:`clear`}}],inspection:{commandId:`plan`,title:`Plan`,rows:We(e.value.plan)}}],timeline:{cells:[],omitted:0},waiting:null})}),G=e=>k.check(p(1),d(e),E(/\S/u)),Ke=b({id:G(32).check(E(/^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$/u)),header:G(12),question:G(1e3),options:O(b({label:G(60),description:G(300)})).check(p(2),d(4),v(e=>new Set(e.map(e=>e.label)).size===e.length||`Option labels must be unique`,{representation:{id:`botanical/ask/unique-option-labels`,payload:null}})),multiple:g(x)}),qe=O(Ke).check(p(1),d(4),v(e=>new Set(e.map(e=>e.id)).size===e.length||`Question ids must be unique`,{representation:{id:`botanical/ask/unique-question-ids`,payload:null}})),Je=b({askId:k,questions:qe,status:w([`live`,`parked`]),createdAt:y,expiresAt:A(y)}),Ye=b({asks:O(Je).check(d(4))}),K=G(256),q=f(Ke.fields.id,b({selected:O(G(60)).check(d(4)),text:g(k.check(d(4e3)))})),J=b({askId:G(256),requestId:K,answers:q}),Xe=b({askId:G(256),requestId:K,note:g(k.check(d(4e3)))}),Ze=w([`answered`,`declined`,`withdrawn`,`expired`,`cancelled`,`undeliverable`]),Qe=_([b({result:D(`accepted`),via:w([`in_turn`,`follow_up`])}),b({result:D(`closed`),status:Ze}),b({result:D(`not_found`)})]),Y={askId:J.fields.askId,requestId:K,index:y.check(oe(),u({minimum:0,maximum:3})),answers:q},$e=_([b({stage:D(`multiple`),...Y,selection:k.check(d(1e3))}),b({stage:D(`selection`),...Y,selection:k.check(d(1e3))}),b({stage:D(`text`),...Y,selected:q.value.fields.selected,text:k.check(d(4e3))}),b({askId:J.fields.askId}),b({})]),et={id:T.make(`botanical-session-question`),commands:{answerFlow:{scope:`session`,input:$e,output:I},answer:{scope:`session`,input:J,output:Qe},decline:{scope:`session`,input:Xe,output:Qe},list:{scope:`session`,input:b({}),output:Ye}},projection:{schema:Ye}},tt=P(et,{contribute:e=>({chips:[],panel:e.status!==`running`||e.value===null?[]:e.value.asks.map(e=>{let t=e.questions[0];return{id:e.askId,title:`${t?.question??`Question`}${e.questions.length>1?` (+${String(e.questions.length-1)} more)`:``}`,detail:t?.options.map(e=>e.label).join(` · `)??``,tone:`attention`,actions:[{id:`answerFlow`,label:`Answer`,input:{askId:e.askId}}]}}),timeline:{cells:[],omitted:0},waiting:null})}),X=k.check(p(1),d(256)),nt=w([`working`,`waiting`,`idle`,`failed`,`unavailable`]),rt=b({agentId:X,name:X,sessionId:A(X),state:nt,attention:g(k.check(d(200)))}),it=b({agents:O(rt).check(d(16)),more:C.check(S(0))}),at={id:T.make(`botanical-session-subagents`),commands:{},projection:{schema:it}},ot={working:{label:`working`,tone:`running`,status:`info`},waiting:{label:`waiting on you`,tone:`attention`,status:`warning`},idle:{label:`idle`,tone:`settled`,status:`success`},failed:{label:`failed`,tone:`error`,status:`error`},unavailable:{label:`unavailable`,tone:`muted`,status:`neutral`}};function st(e){let t=ot[e.state],n={id:e.agentId,title:`${e.name} · ${t.label}`,tone:t.tone,status:{label:t.label,tone:t.status}},r=e.attention===void 0?n:{...n,detail:e.attention};return e.sessionId===null?{...r,detail:e.attention??`not messaged yet`}:{...r,open:{params:[{key:`agent`,value:e.agentId},{key:`session`,value:e.sessionId}]}}}var ct=P(at,{contribute:e=>({chips:[],panel:e.status!==`running`||e.value===null?[]:[...e.value.agents.map(st),...e.value.more===0?[]:[{id:`more`,title:`${String(e.value.more)} more sub-agent${e.value.more===1?``:`s`}`,tone:`muted`}]],timeline:{cells:[],omitted:0},waiting:null})});function lt(e,t){if(e===null||!URL.canParse(t))return!1;let n=new URL(t);return n.protocol!==`https:`||n.hash!==`#team-billing`?!1:(e.openTeamBilling().catch(t=>(console.error(`Chat Billing navigation failed`,t),e.showToast({message:`Billing could not be opened. Please try again.`,tone:`error`}))),!0)}var Z=e(Ee(),1),Q=he();function ut(e){if(e.name!==`execute`||e.status!==`completed`)return;let t=e.result?.content;if(t?.length!==1||t[0]?.type!==`text`)return;let n=ee(ie(ne))(t[0].text);if(r(n))return;let i=ye.safeParse(n.value);return i.success?i.data.file:void 0}function dt({item:e,ui:t}){let n=ut(e),[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(!1);if(!n)return null;let s=async()=>{i(!0),o(!1);try{await t.openNavigation(n)}catch(e){console.error(`Chat file navigation failed`,e),o(!0)}finally{i(!1)}};return(0,Q.jsxs)(`div`,{className:`px-3 py-2`,children:[(0,Q.jsx)(M,{variant:`ghost`,size:`sm`,disabled:r,onClick:()=>void s(),type:`button`,children:r?`Opening file…`:`Open ${n.path} in Inkcap`}),a?(0,Q.jsx)(`p`,{role:`alert`,children:`The file could not be opened. Try again.`}):null]})}var ft=o({kind:t(`generated`),file:o({computerId:c().min(1),path:c().min(1)}),format:n([`png`,`jpeg`,`gif`,`webp`,`mp4`]),width:a(),height:a(),bytes:a(),costMilliunits:a(),receipt:c()});function pt(e){if(e.name!==`execute`||e.status!==`completed`)return;let t=e.result?.content??[],n=t.at(0);if(n?.type!==`text`||t.slice(1).some(e=>e.type!==`image`))return;let i=ee(ie(ne))(n.text);if(r(i))return;let a=ft.safeParse(i.value);return a.success?a.data:void 0}function mt({item:e,ui:t}){let n=pt(e),[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(!1);if(!n)return null;let s=async()=>{i(!0),o(!1);try{await t.openNavigation(n.file)}catch(e){console.error(`Chat image navigation failed`,e),o(!0)}finally{i(!1)}};return(0,Q.jsxs)(`div`,{className:`px-3 py-2`,children:[(0,Q.jsx)(M,{variant:`ghost`,size:`sm`,disabled:r,onClick:()=>void s(),type:`button`,children:r?`Opening file…`:`Open ${n.file.path} in Inkcap`}),a?(0,Q.jsx)(`p`,{role:`alert`,children:`The file could not be opened. Try again.`}):null]})}var ht=(0,Z.forwardRef)(function({heading:e,eyebrow:t,cover:n,action:r,children:i,className:a,...o},s){return(0,Q.jsxs)(ue,{...o,className:j(`caps-game-share`,a),ref:s,children:[n?(0,Q.jsx)(`div`,{className:`caps-game-share-cover`,children:n}):null,(0,Q.jsxs)(fe,{children:[t,(0,Q.jsx)(`h3`,{className:`caps-game-share-heading`,children:e})]}),(0,Q.jsx)(Ce,{className:`gap-sm`,children:i}),(0,Q.jsx)(le,{children:(0,Q.jsx)(M,{asChild:!0,variant:`primary`,className:`caps-game-share-action`,children:r})})]})});function gt(e){let t=0;return e.map(e=>{let n={...e,offset:t};return t+=e.text.length,n})}function _t({value:e,label:t,fieldLabel:n,displayValue:r,layout:i,title:a,tokens:o,className:s,...c}){let l=(0,Z.useId)(),[u,d]=(0,Z.useState)({kind:`ready`}),f=o?o.map(e=>e.text).join(``):e,p=async()=>{d(await navigator.clipboard.writeText(f).then(()=>({kind:`copied`}),e=>({kind:`failed`,cause:e})))};if(n!==void 0)return(0,Q.jsxs)(`div`,{...c,className:j(`caps-copy-field-input`,s),children:[(0,Q.jsx)(xe,{htmlFor:l,children:n}),(0,Q.jsxs)(me,{children:[(0,Q.jsx)(ve,{className:`caps-copy-field-control`,"aria-label":n,id:l,onFocus:e=>{e.currentTarget.select()},readOnly:!0,value:r??f}),(0,Q.jsx)(M,{onClick:()=>void p(),size:`sm`,variant:`outline`,children:u.kind===`copied`?`Copied`:t??`Copy`})]}),u.kind===`failed`?(0,Q.jsx)(`span`,{role:`status`,children:`Could not copy. Select the text to copy it.`}):null]});let m=u.kind===`copied`?`Copied`:u.kind===`failed`?`Copy failed`:t??`Copy`;return i===`block`?(0,Q.jsxs)(`figure`,{...c,className:j(`caps-copy-field-block`,s),"data-state":u.kind,children:[(0,Q.jsxs)(`figcaption`,{className:`caps-copy-field-header`,children:[(0,Q.jsx)(`span`,{className:`caps-copy-field-title`,children:a}),(0,Q.jsxs)(M,{onClick:()=>void p(),size:`sm`,variant:u.kind===`copied`?`ghost`:`outline`,children:[u.kind===`copied`?(0,Q.jsx)(N,{"aria-hidden":`true`,size:15}):(0,Q.jsx)(Te,{"aria-hidden":`true`,size:15}),m]}),(0,Q.jsx)(ce,{role:`status`,children:u.kind===`copied`?`Copied to the clipboard`:u.kind===`failed`?`Could not copy. Select the code to copy it.`:``})]}),(0,Q.jsx)(`pre`,{className:`caps-copy-field-code`,tabIndex:0,children:(0,Q.jsx)(`code`,{children:o?gt(o).map(e=>(0,Q.jsx)(`span`,{className:`caps-copy-field-token`,"data-kind":e.kind,children:e.text},e.offset)):f})})]}):(0,Q.jsxs)(`div`,{...c,className:j(`caps-copy-field`,s),children:[(0,Q.jsx)(`code`,{className:`caps-copy-field-value`,children:f}),(0,Q.jsxs)(M,{"aria-label":`${m}: ${f}`,onClick:()=>void p(),size:`sm`,variant:`outline`,children:[u.kind===`copied`?(0,Q.jsx)(N,{size:15}):(0,Q.jsx)(Te,{size:15}),m]})]})}var vt=s({game:s({title:c().min(1),summary:c(),coverUrl:i().nullable(),shareUrl:i()})});function $(e){let t=/(?:^|\n)\s*Share:\s*(https?:\/\/[^\s<>]+)/iu.exec(e);if(!t?.[1])return null;let n=t[1].replace(/[.,;!?]+$/u,``);if(!URL.canParse(n))return null;let r=new URL(n);return r.username||r.password||r.hash||r.protocol===`http:`&&![`localhost`,`127.0.0.1`].includes(r.hostname)?null:r.href}function yt(e){return $(e)?e.split(`
|
|
2
|
-
`).filter(e=>!/^\s*Share:\s*/iu.test(e)).join(`
|
|
3
|
-
`).trim():e}function bt(e){let t=new URL(e),n=/^\/([a-z0-9]+(?:-[a-z0-9]+)*)\/?$/u.exec(t.pathname)?.[1];return!n||t.search?null:new URL(`/api/games/${n}`,t.origin)}function xt({reply:e,previewGame:t}){let n=$(e),r=n?bt(n):null,{data:i}=se({queryKey:pe.of(null,`game-share`,n),enabled:r!==null&&t===void 0,queryFn:async({signal:e})=>{if(!r)return null;let t=await fetch(r,{signal:e});if(!t.ok)return null;let i=vt.safeParse(await t.json());return i.success&&i.data.game.shareUrl===n?i.data.game:null}}),a=t??i;if(!n)return null;let o=new URL(n),s=`${o.host}${o.pathname.replace(/\/$/u,``)}`,c=a?.coverUrl&&r?t?a.coverUrl:new URL(`${r.pathname}/cover`,r.origin).href:null;return(0,Q.jsxs)(ht,{"data-game-share-card":`true`,"data-theme":`vishnu`,heading:a?.title??`Your game is ready`,eyebrow:(0,Q.jsx)(we,{tone:`secondary`,variant:`quiet`,children:`Made with your Agent`}),cover:c?(0,Q.jsx)(`img`,{alt:`A scene from ${a?.title??`your game`}`,src:c}):null,action:(0,Q.jsx)(`a`,{href:n,rel:`noopener noreferrer`,target:`_blank`,children:`Play ↗`}),children:[a?.summary?(0,Q.jsx)(`p`,{className:`text-sm`,children:a.summary}):null,(0,Q.jsx)(_t,{displayValue:s,fieldLabel:`Share link`,label:`Copy link`,value:n})]})}var St=[je,Re,Ge,tt,ct],Ct=e=>(0,Q.jsx)(xt,{reply:e});function wt({prefill:e,onPrefilled:t}){let n=Se(),r=(0,Z.useRef)(null);return(0,Z.useEffect)(()=>{!e||r.current===e.requestId||(r.current=e.requestId,n.setDraft(e.text),t())},[n.setDraft,t,e]),null}function Tt({session:e,connection:t,commands:n,prefill:r=null,onPrefilled:i=()=>void 0,onOpen:a}){let o=t?.ui??null,s=(0,Z.useCallback)(e=>lt(o,e),[o]),c=(0,Z.useCallback)(e=>o?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(dt,{item:e,ui:o}),(0,Q.jsx)(mt,{item:e,ui:o})]}):null,[o]);return(0,Q.jsxs)(ge,{session:e,clients:St,authorOf:de,children:[(0,Q.jsx)(wt,{prefill:r,onPrefilled:i}),(0,Q.jsx)(be,{onLink:s,onOpen:a,composerActionVariant:`outline`,commands:n,renderAssistantAttachment:Ct,formatAssistantText:yt,renderToolActions:c})]})}export{Tt as ParakeetConversation};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e,t}from"./rolldown-runtime-hePW80VL.js";import{$i as n,A as r,Bi as i,Ji as a,Ki as o,Xi as s,aa as c,la as l,na as u,oa as d,r as f,sa as p,t as m,ua as h,ut as g}from"./Effect-BEduymlz.js";import{A as _,B as v,C as ee,D as y,E as te,F as ne,H as b,I as x,L as re,M as ie,N as S,O as ae,P as C,R as oe,S as se,T as ce,U as le,V as ue,W as de,b as fe,j as pe,k as me,v as he,w as ge,x as w,y as _e,z as ve}from"./index-hJphFjkO.js";var ye=(e,t)=>{if(ve(t,`<`)){let n=t[1]===`<`,r=e._tail,i=r?r._offset+r._delay:0;return n?i:i+r.duration}},T=(e,t)=>{let n=e.iterationDuration;if(n===1e-11&&(n=0),x(t))return n;if(S(+t))return+t;let r=t,i=e?e.labels:null,a=!ie(i),o=ye(e,r),s=!x(o),c=le.exec(r);if(c){let e=c[0],t=r.split(e),l=a&&t[0]?i[t[0]]:n,u=s?o:a?l:n,d=+t[1];return te(u,d,e[0])}return s?o:a?x(i[r])?n:i[r]:n};function be(e){return me((e.iterationDuration+e._loopDelay)*e.iterationCount-e._loopDelay)||1e-11}function E(e,t,n,r,i,a){let o=S(e.duration)&&e.duration<=1e-11?n-b:n;t.composition&&ce(t,o,1,1,de.AUTO);let s=r?new he(r,e,t,o,!1,i,a):new w(e,t,o);return t.composition&&s.init(!0),ae(t,s),_(t,e=>{let n=e._offset+e._delay+e.duration;n>t.iterationDuration&&(t.iterationDuration=n)}),t.duration=be(t),t}var D=0,xe=class extends w{constructor(e={}){super(e,null,0),++D,this.id=x(e.id)?D:e.id,this.duration=0,this.labels={};let t=e.defaults,n=v.defaults;this.defaults=t?re(t,n):n,this.composition=y(e.composition,!0),this.onRender=e.onRender||n.onRender;let r=y(e.playbackEase,n.playbackEase);this._ease=r?_e(r):null,this.iterationDuration=0}add(e,t,n){let r=C(t),i=C(e);if(r||i){if(this._hasChildren=!0,r){let r=t,i=v.editor&&v.editor.addTimelineChild,a=n&&n.type===`Stagger`&&v.editor,o=pe(n)?n:null;if(o||a){let t=fe(e),a=this.duration,s=this.iterationDuration,c=r.id,l=0,u=t.length,d=i?i(e,r,this.id,n,u):null,f=o||v.editor.resolveStagger(n.defaultValue);t.forEach(e=>{let n={...d||r};this.duration=a,this.iterationDuration=s,x(c)||(n.id=c+`-`+l);let i=T(this,f(e,l,t,null,this));E(n,this,i,e,l,t),l++})}else{let t=i?i(e,r,this.id,n):r,a=n&&n.type?n.defaultValue:n;E(t,this,T(this,a),e)}}else E(e,this,T(this,t));return this.composition&&this.init(!0),this}}sync(e,t){if(x(e)||e&&x(e.pause))return this;e.pause();let n=+(e.effect?e.effect.getTiming().duration:e.duration);!x(e)&&!x(e.persist)&&(e.persist=!0);let r=v.editor,i=r&&r.addTimelineChild;r&&r.addTimelineSync&&(t=r.addTimelineSync(e,t,this.id),r.addTimelineChild=null);let a=this.add(e,{currentTime:[0,n],duration:n,delay:0,ease:`linear`,playbackEase:`linear`},t);return r&&(r.addTimelineChild=i),a}set(e,t,n){return x(t)?this:(t.duration=b,t.composition=ue.replace,this.add(e,t,n))}call(e,t){return x(e)||e&&!pe(e)?this:(v.editor&&v.editor.addTimelineCall&&(t=v.editor.addTimelineCall(e,t,this.id)),this.add({duration:0,delay:0,onComplete:()=>e(this)},t))}label(e,t){return x(e)||e&&!ne(e)?this:(v.editor&&v.editor.addTimelineLabel&&(t=v.editor.addTimelineLabel(e,t,this.id)),this.labels[e]=T(this,t),this)}remove(e,t){return ee(fe(e),this,t),this}stretch(e){let t=this.duration;if(t===oe(e))return this;let n=e/t,r=this.labels;_(this,e=>e.stretch(e.duration*n));for(let e in r)r[e]*=n;return super.stretch(e)}refresh(){return _(this,e=>{e.refresh&&e.refresh()}),this}revert(){return super.revert(),_(this,e=>e.revert,!0),ge(this)}then(e){return super.then(e)}},Se=e=>v.editor?v.editor.addTimeline(e):new xe(e).init(),Ce=`\0sprite-color:`,O=e=>e?.startsWith(`\0sprite-color:`)?e.slice(14):void 0,k=d({x:u().optional(),y:u().optional(),z:u().optional()}),A=d({x:u(),y:u(),z:u().optional()}),j=d({name:p().min(1).optional(),x:u().optional(),y:u().optional(),z:u().optional(),translate:k.optional(),rotate:k.optional(),scale:k.optional(),visible:a().optional(),color:p().optional(),stroke:h([u().nonnegative(),n(!1)]).optional(),fill:a().optional(),backface:p().optional(),frontFace:p().optional(),updateSort:a().optional()}),M={id:p().min(1),parent:p().min(1).optional()},N=s(`kind`,[d({...M,kind:n(`group`),options:j}),d({...M,kind:n(`shape`),options:j.extend({path:o(h([A,d({bezier:l([A,A,A])})])).optional(),closed:a().optional()})}),d({...M,kind:n(`ellipse`),options:j.extend({width:u(),height:u()})}),d({...M,kind:n(`hemisphere`),options:j.extend({diameter:u()})}),d({...M,kind:n(`cylinder`),options:j.extend({diameter:u(),length:u()})})]),P=d({target:p().min(1),translate:k.optional(),rotate:k.optional(),durationMs:u().nonnegative().optional(),repeat:i([`none`,`loop`,`yoyo`]).optional()}),we=d({variants:c(p(),p()).optional(),variantChoices:c(p(),o(p()).min(1)).optional(),blush:u().optional(),motion:P.optional()}),Te=d({motion:P.optional(),mouseInfluence:u().optional(),geometry:d({expression:p().optional(),eyes:p().optional(),mouth:p().optional(),blush:u().optional()}).optional(),mouthCycle:o(d({durationMs:u().positive(),mouth:i([`base`,`open`])})).min(1).optional()}),F=d({root:p().min(1),nodes:o(N).min(1),palette:c(p(),p()),variants:c(p(),c(p(),p())),expressions:c(p(),we),activities:c(p(),Te),defaultPresentation:d({activity:p(),expression:p()})}).superRefine((e,t)=>{let n=new Set,r=new Set,i=e=>{t.addIssue({code:`custom`,message:e})};for(let t of e.nodes){(n.has(t.id)||t.parent!==void 0&&!n.has(t.parent)||t.parent===void 0&&t.id!==e.root)&&i(`Scene needs unique, parent-first nodes and one root`),n.add(t.id),t.options.name&&(r.has(t.options.name)&&i(`Duplicate Sprite node name: ${t.options.name}`),r.add(t.options.name));for(let n of[t.options.color,t.options.backface,t.options.frontFace]){let t=O(n);t!==void 0&&!Object.hasOwn(e.palette,t)&&i(`Unknown Sprite palette slot: ${t}`)}}n.has(e.root)||i(`Scene root is missing`);for(let t of Object.values(e.variants))for(let e of Object.values(t))n.has(e)||i(`Variant node is missing`);Object.hasOwn(e.expressions,e.defaultPresentation.expression)||i(`Unknown Sprite default expression: ${e.defaultPresentation.expression}`),![`idle`,`listening`,`processing`,`speaking`,`thinking`,`error`].includes(e.defaultPresentation.activity)&&!Object.hasOwn(e.activities,e.defaultPresentation.activity)&&i(`Unknown Sprite default activity: ${e.defaultPresentation.activity}`);let a=(t,n)=>{(!Object.hasOwn(e.variants,t)||!Object.hasOwn(e.variants[t]??{},n))&&i(`Unknown Sprite variant: ${t}.${n}`)},o=e=>{r.has(e)||i(`Unknown Sprite motion target: ${e}`)},s=e=>e===0?`off`:e<=.5?`small`:e<=.8?`medium`:`big`;for(let[t,n]of Object.entries(e.expressions)){for(let[e,t]of Object.entries(n.variants??{}))a(e,t);for(let[e,t]of Object.entries(n.variantChoices??{}))for(let n of t)a(e,n);n.blush!==void 0&&a(`blush`,s(n.blush)),n.motion&&o(n.motion.target),t.trim()||i(`Sprite expression name cannot be empty`)}for(let[t,n]of Object.entries(e.activities)){n.motion&&o(n.motion.target);let r=n.geometry;r?.expression&&!Object.hasOwn(e.expressions,r.expression)&&i(`Unknown Sprite activity.${t}.geometry.expression: ${r.expression}`),r?.eyes&&a(`eyes`,r.eyes),r?.mouth&&a(`mouth`,r.mouth),r?.blush!==void 0&&a(`blush`,s(r.blush)),t.trim()||i(`Sprite activity name cannot be empty`)}}),I=t(((e,t)=>{(function(e,n){typeof t==`object`&&t.exports?t.exports=n():e.Zdog=n()})(e,function(){var e={};e.TAU=Math.PI*2,e.extend=function(e,t){for(var n in t)e[n]=t[n];return e},e.lerp=function(e,t,n){return(t-e)*n+e},e.modulo=function(e,t){return(e%t+t)%t};var t={2:function(e){return e*e},3:function(e){return e*e*e},4:function(e){return e*e*e*e},5:function(e){return e*e*e*e*e}};return e.easeInOut=function(e,n){if(n==1)return e;e=Math.max(0,Math.min(1,e));var r=e<.5,i=r?e:1-e;i/=.5;var a=(t[n]||t[2])(i);return a/=2,r?a:1-a},e})})),L=t(((e,t)=>{(function(e,n){typeof t==`object`&&t.exports?t.exports=n():e.Zdog.CanvasRenderer=n()})(e,function(){var e={isCanvas:!0};return e.begin=function(e){e.beginPath()},e.move=function(e,t,n){e.moveTo(n.x,n.y)},e.line=function(e,t,n){e.lineTo(n.x,n.y)},e.bezier=function(e,t,n,r,i){e.bezierCurveTo(n.x,n.y,r.x,r.y,i.x,i.y)},e.closePath=function(e){e.closePath()},e.setPath=function(){},e.renderPath=function(t,n,r,i){this.begin(t,n),r.forEach(function(r){r.render(t,n,e)}),i&&this.closePath(t,n)},e.stroke=function(e,t,n,r,i){n&&(e.strokeStyle=r,e.lineWidth=i,e.stroke())},e.fill=function(e,t,n,r){n&&(e.fillStyle=r,e.fill())},e.end=function(){},e})})),R=t(((e,t)=>{(function(e,n){typeof t==`object`&&t.exports?t.exports=n():e.Zdog.SvgRenderer=n()})(e,function(){var e={isSvg:!0},t=e.round=function(e){return Math.round(e*1e3)/1e3};function n(e){return t(e.x)+`,`+t(e.y)+` `}return e.begin=function(){},e.move=function(e,t,r){return`M`+n(r)},e.line=function(e,t,r){return`L`+n(r)},e.bezier=function(e,t,r,i,a){return`C`+n(r)+n(i)+n(a)},e.closePath=function(){return`Z`},e.setPath=function(e,t,n){t.setAttribute(`d`,n)},e.renderPath=function(t,n,r,i){var a=``;r.forEach(function(r){a+=r.render(t,n,e)}),i&&(a+=this.closePath(t,n)),this.setPath(t,n,a)},e.stroke=function(e,t,n,r,i){n&&(t.setAttribute(`stroke`,r),t.setAttribute(`stroke-width`,i))},e.fill=function(e,t,n,r){var i=n?r:`none`;t.setAttribute(`fill`,i)},e.end=function(e,t){e.appendChild(t)},e})})),z=t(((e,t)=>{(function(e,n){if(typeof t==`object`&&t.exports)t.exports=n(I());else{var r=e.Zdog;r.Vector=n(r)}})(e,function(e){function t(e){this.set(e)}var n=e.TAU;t.prototype.set=function(e){return this.x=e&&e.x||0,this.y=e&&e.y||0,this.z=e&&e.z||0,this},t.prototype.write=function(e){return e?(this.x=e.x==null?this.x:e.x,this.y=e.y==null?this.y:e.y,this.z=e.z==null?this.z:e.z,this):this},t.prototype.rotate=function(e){if(e)return this.rotateZ(e.z),this.rotateY(e.y),this.rotateX(e.x),this},t.prototype.rotateZ=function(e){r(this,e,`x`,`y`)},t.prototype.rotateX=function(e){r(this,e,`y`,`z`)},t.prototype.rotateY=function(e){r(this,e,`x`,`z`)};function r(e,t,r,i){if(!(!t||t%n===0)){var a=Math.cos(t),o=Math.sin(t),s=e[r],c=e[i];e[r]=s*a-c*o,e[i]=c*a+s*o}}t.prototype.isSame=function(e){return e?this.x===e.x&&this.y===e.y&&this.z===e.z:!1},t.prototype.add=function(e){return e?(this.x+=e.x||0,this.y+=e.y||0,this.z+=e.z||0,this):this},t.prototype.subtract=function(e){return e?(this.x-=e.x||0,this.y-=e.y||0,this.z-=e.z||0,this):this},t.prototype.multiply=function(e){return e==null||(typeof e==`number`?(this.x*=e,this.y*=e,this.z*=e):(this.x*=e.x==null?1:e.x,this.y*=e.y==null?1:e.y,this.z*=e.z==null?1:e.z)),this},t.prototype.transform=function(e,t,n){return this.multiply(n),this.rotate(t),this.add(e),this},t.prototype.lerp=function(t,n){return this.x=e.lerp(this.x,t.x||0,n),this.y=e.lerp(this.y,t.y||0,n),this.z=e.lerp(this.z,t.z||0,n),this},t.prototype.magnitude=function(){return i(this.x*this.x+this.y*this.y+this.z*this.z)};function i(e){return Math.abs(e-1)<1e-8?1:Math.sqrt(e)}return t.prototype.magnitude2d=function(){return i(this.x*this.x+this.y*this.y)},t.prototype.copy=function(){return new t(this)},t})})),B=t(((e,t)=>{(function(e,n){if(typeof t==`object`&&t.exports)t.exports=n(I(),z(),L(),R());else{var r=e.Zdog;r.Anchor=n(r,r.Vector,r.CanvasRenderer,r.SvgRenderer)}})(e,function(e,t,n,r){var i=e.TAU,a={x:1,y:1,z:1};function o(e){this.create(e||{})}o.prototype.create=function(n){this.children=[],e.extend(this,this.constructor.defaults),this.setOptions(n),this.translate=new t(n.translate),this.rotate=new t(n.rotate),this.scale=new t(a).multiply(this.scale),this.origin=new t,this.renderOrigin=new t,this.addTo&&this.addTo.addChild(this)},o.defaults={},o.optionKeys=Object.keys(o.defaults).concat([`rotate`,`translate`,`scale`,`addTo`]),o.prototype.setOptions=function(e){var t=this.constructor.optionKeys;for(var n in e)t.indexOf(n)!=-1&&(this[n]=e[n])},o.prototype.addChild=function(e){this.children.indexOf(e)==-1&&(e.remove(),e.addTo=this,this.children.push(e))},o.prototype.removeChild=function(e){var t=this.children.indexOf(e);t!=-1&&this.children.splice(t,1)},o.prototype.remove=function(){this.addTo&&this.addTo.removeChild(this)},o.prototype.update=function(){this.reset(),this.children.forEach(function(e){e.update()}),this.transform(this.translate,this.rotate,this.scale)},o.prototype.reset=function(){this.renderOrigin.set(this.origin)},o.prototype.transform=function(e,t,n){this.renderOrigin.transform(e,t,n),this.children.forEach(function(r){r.transform(e,t,n)})},o.prototype.updateGraph=function(){this.update(),this.updateFlatGraph(),this.flatGraph.forEach(function(e){e.updateSortValue()}),this.flatGraph.sort(o.shapeSorter)},o.shapeSorter=function(e,t){return e.sortValue-t.sortValue},Object.defineProperty(o.prototype,"flatGraph",{get:function(){return this._flatGraph||this.updateFlatGraph(),this._flatGraph},set:function(e){this._flatGraph=e}}),o.prototype.updateFlatGraph=function(){this.flatGraph=this.getFlatGraph()},o.prototype.getFlatGraph=function(){var e=[this];return this.addChildFlatGraph(e)},o.prototype.addChildFlatGraph=function(e){return this.children.forEach(function(t){var n=t.getFlatGraph();Array.prototype.push.apply(e,n)}),e},o.prototype.updateSortValue=function(){this.sortValue=this.renderOrigin.z},o.prototype.render=function(){},o.prototype.renderGraphCanvas=function(e){if(!e)throw Error(`ctx is `+e+`. Canvas context required for render. Check .renderGraphCanvas( ctx ).`);this.flatGraph.forEach(function(t){t.render(e,n)})},o.prototype.renderGraphSvg=function(e){if(!e)throw Error(`svg is `+e+`. SVG required for render. Check .renderGraphSvg( svg ).`);this.flatGraph.forEach(function(t){t.render(e,r)})},o.prototype.copy=function(t){var n={};this.constructor.optionKeys.forEach(function(e){n[e]=this[e]},this),e.extend(n,t);var r=this.constructor;return new r(n)},o.prototype.copyGraph=function(e){var t=this.copy(e);return this.children.forEach(function(e){e.copyGraph({addTo:t})}),t},o.prototype.normalizeRotate=function(){this.rotate.x=e.modulo(this.rotate.x,i),this.rotate.y=e.modulo(this.rotate.y,i),this.rotate.z=e.modulo(this.rotate.z,i)};function s(t){return function(n){function r(e){this.create(e||{})}return r.prototype=Object.create(t.prototype),r.prototype.constructor=r,r.defaults=e.extend({},t.defaults),e.extend(r.defaults,n),r.optionKeys=t.optionKeys.slice(0),Object.keys(r.defaults).forEach(function(e){!r.optionKeys.indexOf(e)!=1&&r.optionKeys.push(e)}),r.subclass=s(r),r}}return o.subclass=s(o),o})})),V=t(((e,t)=>{(function(e,n){typeof t==`object`&&t.exports?t.exports=n():e.Zdog.Dragger=n()})(e,function(){var e=typeof window<`u`,t=`mousedown`,n=`mousemove`,r=`mouseup`;e&&(window.PointerEvent?(t=`pointerdown`,n=`pointermove`,r=`pointerup`):`ontouchstart`in window&&(t=`touchstart`,n=`touchmove`,r=`touchend`));function i(){}function a(e){this.create(e||{})}return a.prototype.create=function(e){this.onDragStart=e.onDragStart||i,this.onDragMove=e.onDragMove||i,this.onDragEnd=e.onDragEnd||i,this.bindDrag(e.startElement)},a.prototype.bindDrag=function(e){e=this.getQueryElement(e),e&&(e.style.touchAction=`none`,e.addEventListener(t,this))},a.prototype.getQueryElement=function(e){return typeof e==`string`&&(e=document.querySelector(e)),e},a.prototype.handleEvent=function(e){var t=this[`on`+e.type];t&&t.call(this,e)},a.prototype.onmousedown=a.prototype.onpointerdown=function(e){this.dragStart(e,e)},a.prototype.ontouchstart=function(e){this.dragStart(e,e.changedTouches[0])},a.prototype.dragStart=function(t,i){t.preventDefault(),this.dragStartX=i.pageX,this.dragStartY=i.pageY,e&&(window.addEventListener(n,this),window.addEventListener(r,this)),this.onDragStart(i)},a.prototype.ontouchmove=function(e){this.dragMove(e,e.changedTouches[0])},a.prototype.onmousemove=a.prototype.onpointermove=function(e){this.dragMove(e,e)},a.prototype.dragMove=function(e,t){e.preventDefault();var n=t.pageX-this.dragStartX,r=t.pageY-this.dragStartY;this.onDragMove(t,n,r)},a.prototype.onmouseup=a.prototype.onpointerup=a.prototype.ontouchend=a.prototype.dragEnd=function(){window.removeEventListener(n,this),window.removeEventListener(r,this),this.onDragEnd()},a})})),Ee=t(((e,t)=>{(function(e,n){if(typeof t==`object`&&t.exports)t.exports=n(I(),B(),V());else{var r=e.Zdog;r.Illustration=n(r,r.Anchor,r.Dragger)}})(e,function(e,t,n){function r(){}var i=e.TAU,a=t.subclass({element:void 0,centered:!0,zoom:1,dragRotate:!1,resize:!1,onPrerender:r,onDragStart:r,onDragMove:r,onDragEnd:r,onResize:r});e.extend(a.prototype,n.prototype),a.prototype.create=function(e){t.prototype.create.call(this,e),n.prototype.create.call(this,e),this.setElement(this.element),this.setDragRotate(this.dragRotate),this.setResize(this.resize)},a.prototype.setElement=function(e){if(e=this.getQueryElement(e),!e)throw Error(`Zdog.Illustration element required. Set to `+e);var t=e.nodeName.toLowerCase();t==`canvas`?this.setCanvas(e):t==`svg`&&this.setSvg(e)},a.prototype.setSize=function(e,t){e=Math.round(e),t=Math.round(t),this.isCanvas?this.setSizeCanvas(e,t):this.isSvg&&this.setSizeSvg(e,t)},a.prototype.setResize=function(e){this.resize=e,this.resizeListener||=this.onWindowResize.bind(this),e?(window.addEventListener(`resize`,this.resizeListener),this.onWindowResize()):window.removeEventListener(`resize`,this.resizeListener)},a.prototype.onWindowResize=function(){this.setMeasuredSize(),this.onResize(this.width,this.height)},a.prototype.setMeasuredSize=function(){var e,t;if(this.resize==`fullscreen`)e=window.innerWidth,t=window.innerHeight;else{var n=this.element.getBoundingClientRect();e=n.width,t=n.height}this.setSize(e,t)},a.prototype.renderGraph=function(e){this.isCanvas?this.renderGraphCanvas(e):this.isSvg&&this.renderGraphSvg(e)},a.prototype.updateRenderGraph=function(e){this.updateGraph(),this.renderGraph(e)},a.prototype.setCanvas=function(e){this.element=e,this.isCanvas=!0,this.ctx=this.element.getContext(`2d`),this.setSizeCanvas(e.width,e.height)},a.prototype.setSizeCanvas=function(e,t){this.width=e,this.height=t;var n=this.pixelRatio=window.devicePixelRatio||1;this.element.width=this.canvasWidth=e*n,this.element.height=this.canvasHeight=t*n,n>1&&!this.resize&&(this.element.style.width=e+`px`,this.element.style.height=t+`px`)},a.prototype.renderGraphCanvas=function(e){e||=this,this.prerenderCanvas(),t.prototype.renderGraphCanvas.call(e,this.ctx),this.postrenderCanvas()},a.prototype.prerenderCanvas=function(){var e=this.ctx;if(e.lineCap=`round`,e.lineJoin=`round`,e.clearRect(0,0,this.canvasWidth,this.canvasHeight),e.save(),this.centered){var t=this.width/2*this.pixelRatio,n=this.height/2*this.pixelRatio;e.translate(t,n)}var r=this.pixelRatio*this.zoom;e.scale(r,r),this.onPrerender(e)},a.prototype.postrenderCanvas=function(){this.ctx.restore()},a.prototype.setSvg=function(e){this.element=e,this.isSvg=!0,this.pixelRatio=1;var t=e.getAttribute(`width`),n=e.getAttribute(`height`);this.setSizeSvg(t,n)},a.prototype.setSizeSvg=function(e,t){this.width=e,this.height=t;var n=e/this.zoom,r=t/this.zoom,i=this.centered?-n/2:0,a=this.centered?-r/2:0;this.element.setAttribute(`viewBox`,i+` `+a+` `+n+` `+r),this.resize?(this.element.removeAttribute(`width`),this.element.removeAttribute(`height`)):(this.element.setAttribute(`width`,e),this.element.setAttribute(`height`,t))},a.prototype.renderGraphSvg=function(e){e||=this,o(this.element),this.onPrerender(this.element),t.prototype.renderGraphSvg.call(e,this.element)};function o(e){for(;e.firstChild;)e.removeChild(e.firstChild)}return a.prototype.setDragRotate=function(e){if(e)e===!0&&(e=this);else return;this.dragRotate=e,this.bindDrag(this.element)},a.prototype.dragStart=function(){this.dragStartRX=this.dragRotate.rotate.x,this.dragStartRY=this.dragRotate.rotate.y,n.prototype.dragStart.apply(this,arguments)},a.prototype.dragMove=function(e,t){var r=t.pageX-this.dragStartX,a=t.pageY-this.dragStartY,o=Math.min(this.width,this.height),s=r/o*i,c=a/o*i;this.dragRotate.rotate.x=this.dragStartRX-c,this.dragRotate.rotate.y=this.dragStartRY-s,n.prototype.dragMove.apply(this,arguments)},a})})),H=t(((e,t)=>{(function(e,n){if(typeof t==`object`&&t.exports)t.exports=n(z());else{var r=e.Zdog;r.PathCommand=n(r.Vector)}})(e,function(e){function t(t,i,a){this.method=t,this.points=i.map(n),this.renderPoints=i.map(r),this.previousPoint=a,this.endRenderPoint=this.renderPoints[this.renderPoints.length-1],t==`arc`&&(this.controlPoints=[new e,new e])}function n(t){return t instanceof e?t:new e(t)}function r(t){return new e(t)}t.prototype.reset=function(){var e=this.points;this.renderPoints.forEach(function(t,n){var r=e[n];t.set(r)})},t.prototype.transform=function(e,t,n){this.renderPoints.forEach(function(r){r.transform(e,t,n)})},t.prototype.render=function(e,t,n){return this[this.method](e,t,n)},t.prototype.move=function(e,t,n){return n.move(e,t,this.renderPoints[0])},t.prototype.line=function(e,t,n){return n.line(e,t,this.renderPoints[0])},t.prototype.bezier=function(e,t,n){var r=this.renderPoints[0],i=this.renderPoints[1],a=this.renderPoints[2];return n.bezier(e,t,r,i,a)};var i=9/16;return t.prototype.arc=function(e,t,n){var r=this.previousPoint,a=this.renderPoints[0],o=this.renderPoints[1],s=this.controlPoints[0],c=this.controlPoints[1];return s.set(r).lerp(a,i),c.set(o).lerp(a,i),n.bezier(e,t,s,c,o)},t})})),U=t(((e,t)=>{(function(e,n){if(typeof t==`object`&&t.exports)t.exports=n(I(),z(),H(),B());else{var r=e.Zdog;r.Shape=n(r,r.Vector,r.PathCommand,r.Anchor)}})(e,function(e,t,n,r){var i=r.subclass({stroke:1,fill:!1,color:`#333`,closed:!0,visible:!0,path:[{}],front:{z:1},backface:!0});i.prototype.create=function(e){r.prototype.create.call(this,e),this.updatePath(),this.front=new t(e.front||this.front),this.renderFront=new t(this.front),this.renderNormal=new t};var a=[`move`,`line`,`bezier`,`arc`];i.prototype.updatePath=function(){this.setPath(),this.updatePathCommands()},i.prototype.setPath=function(){},i.prototype.updatePathCommands=function(){var e;this.pathCommands=this.path.map(function(t,r){var i=Object.keys(t),o=i[0],s=t[o];(i.length!=1||a.indexOf(o)==-1)&&(o=`line`,s=t),(o==`line`||o==`move`)&&!Array.isArray(s)&&(s=[s]),o=r===0?`move`:o;var c=new n(o,s,e);return e=c.endRenderPoint,c})},i.prototype.reset=function(){this.renderOrigin.set(this.origin),this.renderFront.set(this.front),this.pathCommands.forEach(function(e){e.reset()})},i.prototype.transform=function(e,t,n){this.renderOrigin.transform(e,t,n),this.renderFront.transform(e,t,n),this.renderNormal.set(this.renderOrigin).subtract(this.renderFront),this.pathCommands.forEach(function(r){r.transform(e,t,n)}),this.children.forEach(function(r){r.transform(e,t,n)})},i.prototype.updateSortValue=function(){var e=this.pathCommands.length,t=this.pathCommands[0].endRenderPoint,n=this.pathCommands[e-1].endRenderPoint;e>2&&t.isSame(n)&&--e;for(var r=0,i=0;i<e;i++)r+=this.pathCommands[i].endRenderPoint.z;this.sortValue=r/e},i.prototype.render=function(e,t){var n=this.pathCommands.length;if(!(!this.visible||!n)&&(this.isFacingBack=this.renderNormal.z>0,!(!this.backface&&this.isFacingBack))){if(!t)throw Error(`Zdog renderer required. Set to `+t);var r=n==1;t.isCanvas&&r?this.renderCanvasDot(e,t):this.renderPath(e,t)}};var o=e.TAU;i.prototype.renderCanvasDot=function(e){var t=this.getLineWidth();if(t){e.fillStyle=this.getRenderColor();var n=this.pathCommands[0].endRenderPoint;e.beginPath();var r=t/2;e.arc(n.x,n.y,r,0,o),e.fill()}},i.prototype.getLineWidth=function(){return this.stroke?this.stroke==1?1:this.stroke:0},i.prototype.getRenderColor=function(){return typeof this.backface==`string`&&this.isFacingBack?this.backface:this.color},i.prototype.renderPath=function(e,t){var n=this.getRenderElement(e,t),r=(this.pathCommands.length!=2||this.pathCommands[1].method!=`line`)&&this.closed,i=this.getRenderColor();t.renderPath(e,n,this.pathCommands,r),t.stroke(e,n,this.stroke,i,this.getLineWidth()),t.fill(e,n,this.fill,i),t.end(e,n)};var s=`http://www.w3.org/2000/svg`;return i.prototype.getRenderElement=function(e,t){if(t.isSvg)return this.svgElement||(this.svgElement=document.createElementNS(s,`path`),this.svgElement.setAttribute(`stroke-linecap`,`round`),this.svgElement.setAttribute(`stroke-linejoin`,`round`)),this.svgElement},i})})),W=t(((e,t)=>{(function(e,n){if(typeof t==`object`&&t.exports)t.exports=n(B());else{var r=e.Zdog;r.Group=n(r.Anchor)}})(e,function(e){var t=e.subclass({updateSort:!1,visible:!0});return t.prototype.updateSortValue=function(){var t=0;this.flatGraph.forEach(function(e){e.updateSortValue(),t+=e.sortValue}),this.sortValue=t/this.flatGraph.length,this.updateSort&&this.flatGraph.sort(e.shapeSorter)},t.prototype.render=function(e,t){this.visible&&this.flatGraph.forEach(function(n){n.render(e,t)})},t.prototype.updateFlatGraph=function(){var e=[];this.flatGraph=this.addChildFlatGraph(e)},t.prototype.getFlatGraph=function(){return[this]},t})})),G=t(((e,t)=>{(function(e,n){if(typeof t==`object`&&t.exports)t.exports=n(U());else{var r=e.Zdog;r.Rect=n(r.Shape)}})(e,function(e){var t=e.subclass({width:1,height:1});return t.prototype.setPath=function(){var e=this.width/2,t=this.height/2;this.path=[{x:-e,y:-t},{x:e,y:-t},{x:e,y:t},{x:-e,y:t}]},t})})),De=t(((e,t)=>{(function(e,n){if(typeof t==`object`&&t.exports)t.exports=n(U());else{var r=e.Zdog;r.RoundedRect=n(r.Shape)}})(e,function(e){var t=e.subclass({width:1,height:1,cornerRadius:.25,closed:!1});return t.prototype.setPath=function(){var e=this.width/2,t=this.height/2,n=Math.min(e,t),r=Math.min(this.cornerRadius,n),i=e-r,a=t-r,o=[{x:i,y:-t},{arc:[{x:e,y:-t},{x:e,y:-a}]}];a&&o.push({x:e,y:a}),o.push({arc:[{x:e,y:t},{x:i,y:t}]}),i&&o.push({x:-i,y:t}),o.push({arc:[{x:-e,y:t},{x:-e,y:a}]}),a&&o.push({x:-e,y:-a}),o.push({arc:[{x:-e,y:-t},{x:-i,y:-t}]}),i&&o.push({x:i,y:-t}),this.path=o},t})})),K=t(((e,t)=>{(function(e,n){if(typeof t==`object`&&t.exports)t.exports=n(U());else{var r=e.Zdog;r.Ellipse=n(r.Shape)}})(e,function(e){var t=e.subclass({diameter:1,width:void 0,height:void 0,quarters:4,closed:!1});return t.prototype.setPath=function(){var e=this.width==null?this.diameter:this.width,t=this.height==null?this.diameter:this.height,n=e/2,r=t/2;this.path=[{x:0,y:-r},{arc:[{x:n,y:-r},{x:n,y:0}]}],this.quarters>1&&this.path.push({arc:[{x:n,y:r},{x:0,y:r}]}),this.quarters>2&&this.path.push({arc:[{x:-n,y:r},{x:-n,y:0}]}),this.quarters>3&&this.path.push({arc:[{x:-n,y:-r},{x:0,y:-r}]})},t})})),Oe=t(((e,t)=>{(function(e,n){if(typeof t==`object`&&t.exports)t.exports=n(I(),U());else{var r=e.Zdog;r.Polygon=n(r,r.Shape)}})(e,function(e,t){var n=t.subclass({sides:3,radius:.5}),r=e.TAU;return n.prototype.setPath=function(){this.path=[];for(var e=0;e<this.sides;e++){var t=e/this.sides*r-r/4,n=Math.cos(t)*this.radius,i=Math.sin(t)*this.radius;this.path.push({x:n,y:i})}},n})})),ke=t(((e,t)=>{(function(e,n){if(typeof t==`object`&&t.exports)t.exports=n(I(),z(),B(),K());else{var r=e.Zdog;r.Hemisphere=n(r,r.Vector,r.Anchor,r.Ellipse)}})(e,function(e,t,n,r){var i=r.subclass({fill:!0}),a=e.TAU;i.prototype.create=function(){r.prototype.create.apply(this,arguments),this.apex=new n({addTo:this,translate:{z:this.diameter/2}}),this.renderCentroid=new t},i.prototype.updateSortValue=function(){this.renderCentroid.set(this.renderOrigin).lerp(this.apex.renderOrigin,3/8),this.sortValue=this.renderCentroid.z},i.prototype.render=function(e,t){this.renderDome(e,t),r.prototype.render.apply(this,arguments)},i.prototype.renderDome=function(e,t){if(this.visible){var n=this.getDomeRenderElement(e,t),r=Math.atan2(this.renderNormal.y,this.renderNormal.x),i=this.diameter/2*this.renderNormal.magnitude(),o=this.renderOrigin.x,s=this.renderOrigin.y;if(t.isCanvas){var c=r+a/4,l=r-a/4;e.beginPath(),e.arc(o,s,i,c,l)}else t.isSvg&&(r=(r-a/4)/a*360,this.domeSvgElement.setAttribute(`d`,`M `+-i+`,0 A `+i+`,`+i+` 0 0 1 `+i+`,0`),this.domeSvgElement.setAttribute(`transform`,`translate(`+o+`,`+s+` ) rotate(`+r+`)`));t.stroke(e,n,this.stroke,this.color,this.getLineWidth()),t.fill(e,n,this.fill,this.color),t.end(e,n)}};var o=`http://www.w3.org/2000/svg`;return i.prototype.getDomeRenderElement=function(e,t){if(t.isSvg)return this.domeSvgElement||(this.domeSvgElement=document.createElementNS(o,`path`),this.domeSvgElement.setAttribute(`stroke-linecap`,`round`),this.domeSvgElement.setAttribute(`stroke-linejoin`,`round`)),this.domeSvgElement},i})})),Ae=t(((e,t)=>{(function(e,n){if(typeof t==`object`&&t.exports)t.exports=n(I(),H(),U(),W(),K());else{var r=e.Zdog;r.Cylinder=n(r,r.PathCommand,r.Shape,r.Group,r.Ellipse)}})(e,function(e,t,n,r,i){function a(){}var o=r.subclass({color:`#333`,updateSort:!0});o.prototype.create=function(){r.prototype.create.apply(this,arguments),this.pathCommands=[new t(`move`,[{}]),new t(`line`,[{}])]},o.prototype.render=function(e,t){this.renderCylinderSurface(e,t),r.prototype.render.apply(this,arguments)},o.prototype.renderCylinderSurface=function(e,t){if(this.visible){var n=this.getRenderElement(e,t),r=this.frontBase,i=this.rearBase,a=r.renderNormal.magnitude(),o=r.diameter*a+r.getLineWidth();this.pathCommands[0].renderPoints[0].set(r.renderOrigin),this.pathCommands[1].renderPoints[0].set(i.renderOrigin),t.isCanvas&&(e.lineCap=`butt`),t.renderPath(e,n,this.pathCommands),t.stroke(e,n,!0,this.color,o),t.end(e,n),t.isCanvas&&(e.lineCap=`round`)}};var s=`http://www.w3.org/2000/svg`;o.prototype.getRenderElement=function(e,t){if(t.isSvg)return this.svgElement||=document.createElementNS(s,`path`),this.svgElement},o.prototype.copyGraph=a;var c=i.subclass();c.prototype.copyGraph=a;var l=n.subclass({diameter:1,length:1,frontFace:void 0,fill:!0}),u=e.TAU;return l.prototype.create=function(){n.prototype.create.apply(this,arguments),this.group=new o({addTo:this,color:this.color,visible:this.visible});var e=this.length/2,t=this.backface||!0;this.frontBase=this.group.frontBase=new i({addTo:this.group,diameter:this.diameter,translate:{z:e},rotate:{y:u/2},color:this.color,stroke:this.stroke,fill:this.fill,backface:this.frontFace||t,visible:this.visible}),this.rearBase=this.group.rearBase=this.frontBase.copy({translate:{z:-e},rotate:{y:0},backface:t})},l.prototype.render=function(){},[`stroke`,`fill`,`color`,`visible`].forEach(function(e){var t=`_`+e;Object.defineProperty(l.prototype,e,{get:function(){return this[t]},set:function(n){this[t]=n,this.frontBase&&(this.frontBase[e]=n,this.rearBase[e]=n,this.group[e]=n)}})}),l})})),je=t(((e,t)=>{(function(e,n){if(typeof t==`object`&&t.exports)t.exports=n(I(),z(),H(),B(),K());else{var r=e.Zdog;r.Cone=n(r,r.Vector,r.PathCommand,r.Anchor,r.Ellipse)}})(e,function(e,t,n,r,i){var a=i.subclass({length:1,fill:!0}),o=e.TAU;a.prototype.create=function(){i.prototype.create.apply(this,arguments),this.apex=new r({addTo:this,translate:{z:this.length}}),this.renderApex=new t,this.renderCentroid=new t,this.tangentA=new t,this.tangentB=new t,this.surfacePathCommands=[new n(`move`,[{}]),new n(`line`,[{}]),new n(`line`,[{}])]},a.prototype.updateSortValue=function(){this.renderCentroid.set(this.renderOrigin).lerp(this.apex.renderOrigin,1/3),this.sortValue=this.renderCentroid.z},a.prototype.render=function(e,t){this.renderConeSurface(e,t),i.prototype.render.apply(this,arguments)},a.prototype.renderConeSurface=function(e,t){if(this.visible){this.renderApex.set(this.apex.renderOrigin).subtract(this.renderOrigin);var n=this.renderNormal.magnitude(),r=this.renderApex.magnitude2d(),i=this.renderNormal.magnitude2d(),a=Math.acos(i/n),s=Math.sin(a),c=this.diameter/2*n;if(c*s<r){var l=Math.atan2(this.renderNormal.y,this.renderNormal.x)+o/2,u=r/s,d=Math.acos(c/u),f=this.tangentA,p=this.tangentB;f.x=Math.cos(d)*c*s,f.y=Math.sin(d)*c,p.set(this.tangentA),p.y*=-1,f.rotateZ(l),p.rotateZ(l),f.add(this.renderOrigin),p.add(this.renderOrigin),this.setSurfaceRenderPoint(0,f),this.setSurfaceRenderPoint(1,this.apex.renderOrigin),this.setSurfaceRenderPoint(2,p);var m=this.getSurfaceRenderElement(e,t);t.renderPath(e,m,this.surfacePathCommands),t.stroke(e,m,this.stroke,this.color,this.getLineWidth()),t.fill(e,m,this.fill,this.color),t.end(e,m)}}};var s=`http://www.w3.org/2000/svg`;return a.prototype.getSurfaceRenderElement=function(e,t){if(t.isSvg)return this.surfaceSvgElement||(this.surfaceSvgElement=document.createElementNS(s,`path`),this.surfaceSvgElement.setAttribute(`stroke-linecap`,`round`),this.surfaceSvgElement.setAttribute(`stroke-linejoin`,`round`)),this.surfaceSvgElement},a.prototype.setSurfaceRenderPoint=function(e,t){this.surfacePathCommands[e].renderPoints[0].set(t)},a})})),Me=t(((e,t)=>{(function(e,n){if(typeof t==`object`&&t.exports)t.exports=n(I(),B(),U(),G());else{var r=e.Zdog;r.Box=n(r,r.Anchor,r.Shape,r.Rect)}})(e,function(e,t,n,r){var i=r.subclass();i.prototype.copyGraph=function(){};var a=e.TAU,o=[`frontFace`,`rearFace`,`leftFace`,`rightFace`,`topFace`,`bottomFace`],s=e.extend({},n.defaults);delete s.path,o.forEach(function(e){s[e]=!0}),e.extend(s,{width:1,height:1,depth:1,fill:!0});var c=t.subclass(s);return c.prototype.create=function(e){t.prototype.create.call(this,e),this.updatePath(),this.fill=this.fill},c.prototype.updatePath=function(){o.forEach(function(e){this[e]=this[e]},this)},o.forEach(function(e){var t=`_`+e;Object.defineProperty(c.prototype,e,{get:function(){return this[t]},set:function(n){this[t]=n,this.setFace(e,n)}})}),c.prototype.setFace=function(e,t){var n=e+`Rect`,r=this[n];if(!t){this.removeChild(r);return}var a=this.getFaceOptions(e);a.color=typeof t==`string`?t:this.color,r?r.setOptions(a):r=this[n]=new i(a),r.updatePath(),this.addChild(r)},c.prototype.getFaceOptions=function(e){return{frontFace:{width:this.width,height:this.height,translate:{z:this.depth/2}},rearFace:{width:this.width,height:this.height,translate:{z:-this.depth/2},rotate:{y:a/2}},leftFace:{width:this.depth,height:this.height,translate:{x:-this.width/2},rotate:{y:-a/4}},rightFace:{width:this.depth,height:this.height,translate:{x:this.width/2},rotate:{y:a/4}},topFace:{width:this.width,height:this.depth,translate:{y:-this.height/2},rotate:{x:-a/4}},bottomFace:{width:this.width,height:this.depth,translate:{y:this.height/2},rotate:{x:a/4}}}[e]},[`color`,`stroke`,`fill`,`backface`,`front`,`visible`].forEach(function(e){var t=`_`+e;Object.defineProperty(c.prototype,e,{get:function(){return this[t]},set:function(n){this[t]=n,o.forEach(function(t){var r=this[t+`Rect`],i=typeof this[t]==`string`;r&&!(e==`color`&&i)&&(r[e]=n)},this)}})}),c})})),q=e(t(((e,t)=>{(function(e,n){typeof t==`object`&&t.exports?t.exports=n(I(),L(),R(),z(),B(),V(),Ee(),H(),U(),W(),G(),De(),K(),Oe(),ke(),Ae(),je(),Me()):typeof define==`function`&&define.amd&&define(`zdog`,[],e.Zdog)})(e,function(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_){return e.CanvasRenderer=t,e.SvgRenderer=n,e.Vector=r,e.Anchor=i,e.Dragger=a,e.Illustration=o,e.PathCommand=s,e.Shape=c,e.Group=l,e.Rect=u,e.RoundedRect=d,e.Ellipse=f,e.Polygon=p,e.Hemisphere=m,e.Cylinder=h,e.Cone=g,e.Box=_,e})}))(),1),J=new Map([[`idle`,{geometry:{},motion:{target:`root`,translate:{y:.5},durationMs:2e3,repeat:`yoyo`},mouseInfluence:1}],[`listening`,{geometry:{},motion:{target:`root`,rotate:{x:-.2},durationMs:300,repeat:`yoyo`},mouseInfluence:.3}],[`processing`,{geometry:{},mouseInfluence:.2}],[`speaking`,{geometry:{},motion:{target:`root`,translate:{y:.5},durationMs:1500,repeat:`yoyo`},mouseInfluence:0,mouthCycle:[{durationMs:100,mouth:`open`},{durationMs:150,mouth:`base`},{durationMs:100,mouth:`open`},{durationMs:200,mouth:`base`}]}],[`thinking`,{geometry:{},motion:{target:`root`,rotate:{z:.1},durationMs:800,repeat:`yoyo`},mouseInfluence:0}],[`error`,{geometry:{expression:`dead`},mouseInfluence:.1}]]),Ne=48,Y=(e,t)=>Math.min(e,t)/Ne,X=e=>e!==void 0&&e>0?e:1,Pe=(e,t,n,r)=>{let i=Math.min(1,Math.sqrt(n/(e*t*r*r)));return[Math.max(1,Math.floor(e*i)),Math.max(1,Math.floor(t*i))]},Fe=(e,t)=>{if(!Number.isFinite(e))throw Error(`Sprite ${t} must be finite`)},Z=(e,t)=>{let n=e.ownerDocument.defaultView,r=n?.getComputedStyle(e)?.[t]??``,i=Number.parseFloat(r);if(i>0&&r.trim().endsWith(`px`))return i;let a=e.style[t],o=Number.parseFloat(a);if(o>0&&a.trim().endsWith(`px`))return o;let s=e.getBoundingClientRect(),c=t===`width`?s.width:s.height;if(c>0)return c;for(let r=e.parentElement;r;r=r.parentElement){let e=n?.getComputedStyle(r)[t],i=Number.parseFloat(e??``);if(i>0&&e?.trim().endsWith(`px`))return i}return e[t]||48},Q=e=>{if(!e)return{};let t={};return e.x!==void 0&&(t.x=e.x),e.y!==void 0&&(t.y=e.y),e.z!==void 0&&(t.z=e.z),t},$=e=>e?e<=.5?`small`:e<=.8?`medium`:`big`:`off`,Ie=e=>{let t=new Map,n=new Map;for(let r of e.nodes){let e=r.parent===void 0?void 0:t.get(r.parent),i={kind:r.kind,name:r.options.name,children:[],options:r.options};t.set(r.id,i),i.name&&n.set(i.name,i),e?.children.push(i)}let r=t.get(e.root);if(!r)throw Error(`Portable Zdog scene has no root`);let i=new Map;for(let[n,r]of Object.entries(e.variants)){let e=new Map;for(let[n,i]of Object.entries(r)){let r=t.get(i);if(!r)throw Error(`Portable Zdog variant node is missing: ${i}`);e.set(n,r)}i.set(n,e)}return{root:r,nodesByName:n,variants:i,palette:e.palette,activities:e.activities,expressions:e.expressions}},Le=class{internals;target;view;onInvalidate;maxPixels;originalStyle;originalHasInlineWidth;originalHasInlineHeight;originalWidthAttribute;originalHeightAttribute;illustration;avatar;animationPivot;items=new Map;variantItems=new Map;palette;mouseListener;resizeObserver;animationTween=null;mouthCycleTimeline=null;entryTween=null;mouseX=0;mouseY=0;mouseInfluence=1;dirty=!0;destroyed=!1;paused=!1;lastRenderTime=0;constructor({target:e,scene:t,onInvalidate:n,palette:r,maxPixels:i}){this.target=e,this.view=e.ownerDocument.defaultView,this.onInvalidate=n,this.maxPixels=i,this.originalStyle=e.getAttribute(`style`),this.originalHasInlineWidth=e.style.width!==``,this.originalHasInlineHeight=e.style.height!==``,this.originalWidthAttribute=e.getAttribute(`width`),this.originalHeightAttribute=e.getAttribute(`height`),this.internals=Ie(t),this.palette={...this.internals.palette};for(let[e,t]of Object.entries(r??{})){if(!(e in this.internals.palette))throw Error(`Unknown Sprite palette slot: ${e}`);t!==void 0&&(this.palette[e]=t)}let a=Z(e,`width`),o=Z(e,`height`),[s,c]=Pe(a,o,i,X(this.view?.devicePixelRatio));e.width=Math.round(s),e.height=Math.round(c),this.illustration=new q.Illustration({element:e,resize:!1,zoom:Y(s,c)}),this.illustration.setSize(s,c),this.preserveCanvasStyle(a,o),this.avatar=new q.Group({addTo:this.illustration,rotate:{x:-q.TAU/1.05}}),this.animationPivot=new q.Group({addTo:this.avatar}),this.createScene(this.internals.root,this.animationPivot),this.indexVariants(),this.mouseListener=e=>{this.onMouseMove(e)},this.view?.addEventListener(`mousemove`,this.mouseListener);let l=globalThis.ResizeObserver;this.resizeObserver=new l(()=>{this.destroyed||this.resize()});try{this.resizeObserver.observe(e),this.present({activity:t.defaultPresentation.activity,expression:t.defaultPresentation.expression})}catch(e){throw this.stopAnimations(),this.view?.removeEventListener(`mousemove`,this.mouseListener),this.resizeObserver.disconnect(),e}}present(e){if(this.assertAlive(),!(e.expression in this.internals.expressions))throw Error(`Unknown Sprite expression: ${e.expression}`);if(!(e.activity in this.internals.activities)&&!J.has(e.activity))throw Error(`Unknown Sprite activity: ${e.activity}`);this.stopAnimations();let t=this.activitySpec(e.activity),n=this.internals.expressions[e.expression],r=t.geometry?.expression??e.expression,i=this.internals.expressions[r]??n;this.mouseInfluence=t.mouseInfluence??1,this.applyVariants(i,t.geometry),this.resetPivot(),t.motion&&this.startMotion(t.motion,!0),i?.motion&&this.startMotion(i.motion,!1),t.mouthCycle&&this.internals.variants.get(`mouth`)?.size&&this.startMouthCycle(t.mouthCycle,i),this.dirty=!0,this.pause(this.paused)}setPalette(e){this.assertAlive();for(let t of Object.keys(e))if(!Object.hasOwn(this.internals.palette,t))throw Error(`Unknown Sprite palette slot: ${t}`);Object.assign(this.palette,this.internals.palette,e);for(let[e,t]of this.items){for(let n of[`color`,`backface`,`frontFace`]){let r=e.options[n],i=O(r);i&&(t[n]=this.palette[i])}e.kind===`cylinder`&&t.frontBase!==void 0&&t.rearBase!==void 0&&(t.frontFace?t.frontBase.backface=t.frontFace:t.backface?t.frontBase.backface=t.backface:t.frontBase.backface=!0,t.backface?t.rearBase.backface=t.backface:t.rearBase.backface=!0)}this.dirty=!0,this.onInvalidate()}pause(e){this.paused=e;for(let t of[this.animationTween,this.mouthCycleTimeline,this.entryTween])e?t?.pause():t?.resume()}tick(e){if(this.destroyed||!this.illustration.ctx)return!1;let t=this.hasActiveTween();return(this.dirty||t||this.mouseNeedsRender())&&e-this.lastRenderTime>=1e3/24&&(this.updateMouseTracking(),this.illustration.updateRenderGraph(),this.lastRenderTime=e,this.dirty=!1),this.dirty||this.hasActiveTween()||this.mouseNeedsRender()}renderStill(){this.destroyed||!this.dirty||!this.illustration.ctx||(this.illustration.updateRenderGraph(),this.dirty=!1)}resize(){this.assertAlive();let e=Z(this.target,`width`),t=Z(this.target,`height`),[n,r]=Pe(e,t,this.maxPixels,X(this.view?.devicePixelRatio));this.illustration.zoom=Y(n,r),this.illustration.setSize(n,r),this.preserveCanvasStyle(e,t),this.dirty=!0,this.onInvalidate()}destroy(){if(this.destroyed)throw Error(`Sprite instance has already been destroyed`);this.destroyed=!0,this.stopAnimations(),this.view?.removeEventListener(`mousemove`,this.mouseListener),this.resizeObserver.disconnect();let e=this.target.getContext(`2d`);e&&e.clearRect(0,0,this.target.width,this.target.height),this.restoreCanvasAttributes()}createScene(e,t){let n={...e.options};delete n.parent,delete n.name,delete n.x,delete n.y,delete n.z,n.addTo=t,n.translate?n.translate=Q(n.translate):(e.options.x!==void 0||e.options.y!==void 0||e.options.z!==void 0)&&(n.translate=Q({x:e.options.x,y:e.options.y,z:e.options.z}));let r=O(n.color);r&&(n.color=this.palette[r]);let i=O(n.backface);i&&(n.backface=this.palette[i]);let a=O(n.frontFace);a&&(n.frontFace=this.palette[a]);let o;switch(e.kind){case`group`:o=new q.Group(n);break;case`shape`:n.path=n.path??[{}],o=new q.Shape(n);break;case`ellipse`:o=new q.Ellipse(n);break;case`hemisphere`:o=new q.Hemisphere(n);break;case`cylinder`:o=new q.Cylinder(n)}this.items.set(e,o);for(let t of e.children)this.createScene(t,o);return o}indexVariants(){for(let[e,t]of this.internals.variants.entries()){let n=new Map;for(let[e,r]of t.entries()){let t=this.items.get(r);t&&n.set(e,t)}this.variantItems.set(e,n)}}applyVariants(e,t){for(let e of this.variantItems.values())for(let t of e.values())t.visible=!1;let n={...e?.variants};for(let[t,r]of Object.entries(e?.variantChoices??{})){let e=r[Math.min(r.length-1,Math.floor(Math.random()*r.length))];e!==void 0&&(n[t]=e)}t?.eyes&&(n.eyes=t.eyes),t?.mouth&&(n.mouth=t.mouth),t?.blush===void 0?e?.blush!==void 0&&(n.blush=$(e.blush)):n.blush=$(t.blush);for(let[e,t]of Object.entries(n)){let n=this.variantItems.get(e)?.get(t);n&&(n.visible=!0)}}activitySpec(e){let t=J.get(e)??{geometry:{},mouseInfluence:1},n=this.internals.activities[e];if(!n)return t;let r=n.motion??t.motion,i=n.mouthCycle??t.mouthCycle,a={...t,...n,geometry:{...t.geometry,...n.geometry}};return r!==void 0&&(a.motion=r),i!==void 0&&(a.mouthCycle=i),a}startMotion(e,t){let n=this.internals.nodesByName.get(e.target),r=n===this.internals.root?this.animationPivot:n?this.items.get(n):void 0;if(!r)return;let i=Se({loop:e.repeat===`loop`||e.repeat===`yoyo`,alternate:e.repeat===`yoyo`}),a=e.durationMs??1e3;e.translate&&i.add(r.translate,{...Q(e.translate),duration:a,ease:`inOutSine`},0),e.rotate&&i.add(r.rotate,{...Q(e.rotate),duration:a,ease:`inOutSine`},0),t?this.animationTween=i:this.entryTween=i}startMouthCycle(e,t){let n=[],r=0;for(let i of e)Fe(i.durationMs,`mouthCycle.durationMs`),r+=i.durationMs,n.push({until:r,mouth:i.mouth===`open`?`open`:t?.variants?.mouth});let i;this.mouthCycleTimeline=se({duration:r,loop:!0,onUpdate:e=>{let t=n.find(t=>e.iterationCurrentTime<t.until)?.mouth;t&&t!==i&&(i=t,this.showVariant(`mouth`,t))},onLoop:()=>{i=void 0}})}showVariant(e,t){let n=this.variantItems.get(e);if(n===void 0)return;let r=n.get(t);if(r!==void 0){for(let e of n.values())e.visible=!1;r.visible=!0,this.dirty=!0}}resetPivot(){Object.assign(this.animationPivot.rotate,{x:0,y:0,z:0}),Object.assign(this.animationPivot.translate,{x:0,y:0,z:0}),Object.assign(this.avatar.rotate,{x:-q.TAU/1.05,y:0,z:0})}stopAnimations(){this.animationTween?.cancel(),this.mouthCycleTimeline?.cancel(),this.entryTween?.cancel(),this.animationTween=null,this.mouthCycleTimeline=null,this.entryTween=null}hasActiveTween(){return[this.animationTween,this.mouthCycleTimeline,this.entryTween].some(e=>e!==null&&!e.paused&&!e.completed&&!e.cancelled)}onMouseMove(e){if(this.destroyed||this.paused)return;let t=this.target.getBoundingClientRect(),n=t.width||1,r=t.height||1;this.mouseX=Math.max(-1,Math.min(1,(e.clientX-t.left-n/2)/(n/2))),this.mouseY=Math.max(-1,Math.min(1,(e.clientY-t.top-r/2)/(r/2))),this.dirty=!0,this.onInvalidate()}updateMouseTracking(){let e=-this.mouseX*.4*this.mouseInfluence,t=-q.TAU/1.05-this.mouseY*.2*this.mouseInfluence,n=(e-this.avatar.rotate.y)*.08,r=(t-this.avatar.rotate.x)*.08;this.avatar.rotate.y+=n,this.avatar.rotate.x+=r,(Math.abs(n)>.001||Math.abs(r)>.001)&&(this.dirty=!0)}mouseNeedsRender(){return Math.abs(this.avatar.rotate.y+this.mouseX*.4*this.mouseInfluence)>.001||Math.abs(this.avatar.rotate.x+q.TAU/1.05+this.mouseY*.2*this.mouseInfluence)>.001}assertAlive(){if(this.destroyed)throw Error(`Sprite instance has been destroyed`)}restoreCanvasAttributes(){this.originalStyle===null?this.target.removeAttribute(`style`):this.target.setAttribute(`style`,this.originalStyle),this.originalWidthAttribute===null?this.target.removeAttribute(`width`):this.target.setAttribute(`width`,this.originalWidthAttribute),this.originalHeightAttribute===null?this.target.removeAttribute(`height`):this.target.setAttribute(`height`,this.originalHeightAttribute)}preserveCanvasStyle(e,t){this.originalStyle!==null&&this.target.setAttribute(`style`,this.originalStyle),this.originalHasInlineWidth||(this.target.style.width=`${String(Math.round(e))}px`),this.originalHasInlineHeight||(this.target.style.height=`${String(Math.round(t))}px`)}},Re=e=>new Le(e),ze=e=>r(function*(){let t=F.parse(e.document.data),n=yield*m(g(()=>e.target.ownerDocument.createElement(`canvas`)),e=>g(()=>{e.remove()}));n.style.cssText=`width:100%;height:100%;display:block`,e.target.replaceChildren(n);let r=e.target.ownerDocument.defaultView;if(!r)throw Error(`Zdog avatar requires a browser window`);let i,a=!0,o=!1,s=()=>{a||o||i!==void 0||(i=r.requestAnimationFrame(e=>{i=void 0,l.tick(e)&&s()}))},c=()=>{o||(a?l.renderStill():s())},l=yield*m(g(()=>Re({target:n,scene:t,onInvalidate:c,maxPixels:e.maxPixels})),e=>g(()=>{e.destroy()}));yield*f(()=>g(()=>{o=!0,i!==void 0&&r.cancelAnimationFrame(i)})),l.pause(!0);let u,d;return{activities:[`idle`,`listening`,`processing`,`speaking`,`thinking`,`error`,...Object.keys(t.activities)],expressions:[t.defaultPresentation.expression,...Object.keys(t.expressions)].filter((e,t,n)=>n.indexOf(e)===t),set(e){let n={};for(let[t,r]of Object.entries(e.appearance)){let e=p().safeParse(r);if(!e.success)throw Error(`Zdog palette value must be a color: ${t}`);n[t]=e.data}let r=JSON.stringify(n);r!==d&&(l.setPalette(n),d=r);let i=e.expression??t.defaultPresentation.expression;if(!i)throw Error(`Zdog avatar needs an expression`);let a=JSON.stringify([e.activity,i]);a!==u&&(l.present({activity:e.activity,expression:i}),u=a),c()},pause(e){a=e,l.pause(e),a&&i!==void 0&&(r.cancelAnimationFrame(i),i=void 0),c()}}});export{Ce as i,F as n,N as r,ze as t};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/compat-CvJ9Wfru.js","assets/extension-hook-DvcdepgP.js","assets/Effect-BEduymlz.js","assets/preload-helper-mbhLTglw.js","assets/provider-env-CcCbsTJq.js","assets/rolldown-runtime-hePW80VL.js","assets/diagnostics-CmW2yJSB.js","assets/models-CcNnosqL.js","assets/json-parse-nqKewMRF.js","assets/openai-codex-responses-BMz-j1hp.js","assets/headers-FK4rgixo.js","assets/transform-messages-CrQEqmfx.js","assets/error-body-pkrba6pf.js","assets/openai-prompt-cache-DXo9f3w5.js","assets/openai-responses-shared-DzD8B6NI.js","assets/sanitize-unicode-DmIE6hZJ.js","assets/hash-yQufAZII.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{n as e}from"./rolldown-runtime-hePW80VL.js";import{A as t,Gn as n,I as r,In as i,Jn as a,Kn as o,N as s,Nr as c,P as l,Q as u,U as d,Wn as f,X as p,Xn as m,Z as ee,_ as h,_t as te,a as g,at as ne,c as _,ct as v,d as re,dt as y,er as b,ft as ie,g as x,gt as S,h as C,ht as w,i as ae,it as oe,lt as T,m as E,n as D,nr as O,o as se,p as ce,q as le,r as k,rr as A,s as j,t as ue,ui as M,ut as N,vt as de,w as fe,y as P,yt as F,z as pe}from"./Effect-BEduymlz.js";import{$ as me,$t as he,A as ge,An as I,At as _e,B as ve,Bi as L,Bt as ye,C as be,Ca as xe,Ci as Se,Cr as Ce,Ct as we,D as Te,Da as Ee,Di as R,Dn as De,Dt as Oe,E as ke,Ea as Ae,Er as je,Et as Me,F as Ne,Fi as Pe,Fn as Fe,Fr as z,Ft as Ie,G as Le,Gn as Re,Gr as ze,Gt as Be,H as Ve,Ht as He,I as Ue,Ii as B,It as We,J as Ge,Ji as Ke,Jt as qe,K as Je,Kr as Ye,Kt as Xe,L as Ze,Ln as Qe,Lt as $e,M as et,Mn as tt,Mr as nt,Mt as rt,N as it,Nn as V,Nr as at,Nt as ot,O as st,On as ct,Or as lt,Ot as ut,P as dt,Pi as ft,Pt as pt,Q as mt,Qn as ht,Qt as gt,R as _t,Ri as vt,Rr as yt,Rt as bt,S as xt,Sa as St,Sr as Ct,St as wt,T as Tt,Tn as Et,Tr as H,Tt as Dt,U as Ot,Ur as U,Vi as kt,Vn as At,Vt as jt,W as Mt,Wr as Nt,Wt as Pt,X as Ft,Xr as It,Xt as Lt,Y as Rt,Yn as zt,Yr as Bt,Yt as Vt,Z as Ht,Zt as Ut,_ as Wt,_n as Gt,_t as Kt,a as qt,an as Jt,at as Yt,b as Xt,ba as Zt,bn as Qt,bt as $t,c as en,ca as tn,ci as nn,cr as rn,ct as an,d as on,da as sn,di as cn,dn as ln,dr as un,dt as dn,en as fn,er as pn,et as mn,f as hn,fn as gn,fr as _n,ft as vn,g as yn,gt as bn,h as xn,hr as Sn,ht as Cn,i as wn,in as W,it as Tn,j as En,ja as Dn,ji as On,jn as kn,jr as An,jt as G,k as jn,kt as Mn,l as Nn,la as Pn,lt as Fn,m as In,ma as Ln,mr as Rn,mt as zn,n as Bn,nn as Vn,nt as Hn,o as Un,on as Wn,or as K,ot as Gn,p as Kn,pa as qn,pn as Jn,pr as Yn,pt as Xn,q as Zn,qr as Qn,qt as $n,r as er,rn as tr,rt as nr,s as rr,sa as ir,sn as ar,sr as or,st as sr,t as cr,tn as lr,tt as ur,u as dr,un as fr,ur as pr,ut as mr,v as hr,vr as gr,vt as _r,w as vr,wa as yr,wr as br,wt as xr,x as Sr,xa as Cr,xt as wr,y as Tr,yi as Er,yr as Dr,yt as Or,z as kr,zi as q,zn as Ar,zr as jr,zt as Mr}from"./extension-hook-DvcdepgP.js";import{d as Nr,g as Pr,t as Fr}from"./preload-helper-mbhLTglw.js";import{d as Ir,l as Lr,u as Rr}from"./index-hJphFjkO.js";import{a as zr,i as Br,n as Vr,o as Hr,r as Ur,t as Wr}from"./extensions-1Fd4Wd8r.js";var Gr=vt(()=>gi),Kr=K(Gr),qr=H({id:Dr,payload:_n}),Jr=H({...qr.fields,schemas:Pe(Kr)});function Yr(e){let t={};for(let[n,r]of Object.entries(e))Ke(r)&&c(t,n,r);return Object.keys(t).length===0?b():O(t)}var Xr=Pe(Ce(br,at)).pipe(Qn(B(Yn),{decode:ir(),encode:Pn(e=>a(e)||e.value===void 0?b():Yr(e.value))})),Zr=vt(()=>ei),Qr=K(Zr),$r={annotations:Xr,checks:Qr},ei=nt([H({_tag:q(`Filter`),representation:Jr,annotations:Xr,aborted:rn}),H({_tag:q(`FilterGroup`),representation:Pe(Jr),annotations:Xr,checks:gr(Zr)})]);function J(e){return H({_tag:q(e),...$r})}var ti=H({_tag:q(`Declaration`),representation:qr,annotations:Xr,typeParameters:Kr,checks:Qr}),ni=H({_tag:q(`Suspend`),annotations:Xr,checks:lt([]),thunk:Gr});function ri(e,t){return t.pipe(Qn(H({type:q(e),value:t}),{decode:tn(e=>e.value),encode:tn(t=>({type:e,value:t}))}))}var ii=ri(`string`,br),ai=ri(`number`,Ct),oi=H({_tag:q(`Literal`),...$r,literal:nt([ii,ri(`number`,pr),ri(`bigint`,or),ri(`boolean`,rn)])}),si=H({_tag:q(`UniqueSymbol`),...$r,symbol:je}),ci=H({_tag:q(`Enum`),...$r,enums:K(lt([br,nt([ii,ai])]))}),li=H({_tag:q(`TemplateLiteral`),...$r,parts:Kr}),ui=H({isOptional:rn,type:Gr,annotations:Xr}),di=H({_tag:q(`Arrays`),...$r,elements:K(ui),rest:Kr}),fi=H({name:nt([ii,ai,ri(`symbol`,je)]),type:Gr,isOptional:rn,isMutable:rn,annotations:Xr}),pi=H({parameter:Gr,type:Gr}),mi=H({_tag:q(`Objects`),...$r,propertySignatures:K(fi),indexSignatures:K(pi)}),hi=H({_tag:q(`Union`),...$r,types:Kr,options:B(H({mode:B(Sn([`anyOf`,`oneOf`]))}))}),gi=nt([ti,H({_tag:q(`Reference`),$ref:Dr}),ni,J(`Null`),J(`Undefined`),J(`Void`),J(`Never`),J(`Unknown`),J(`Any`),J(`String`),J(`Number`),J(`Boolean`),J(`BigInt`),J(`Symbol`),J(`ObjectKeyword`),oi,si,ci,li,di,mi,hi]),_i=Ye(L(H({representation:Gr,references:Ce(br,Gr)})));function vi(e){return _i(e)}var yi=Symbol.for(`@fungi.computer/shiitake/extension-definition-reader`);function bi(e){return e[yi]?.()}var xi=0xffffffffffff,Si=(1n<<41n)-1n,Ci=-1,Y;function wi(e){let t=e??Date.now();if(!Number.isInteger(t)||t<0||t>xi)throw RangeError(`UUIDv7 timestamp must be an integer between 0 and ${xi}`);let n=e===void 0?Math.max(t,Ci):e;e===void 0&&(Ci=n);let r=new Uint8Array(16);if(globalThis.crypto.getRandomValues(r),Y===void 0)Y=BigInt(r[1])<<32n|BigInt(r[2])<<24n|BigInt(r[3])<<16n|BigInt(r[4])<<8n|BigInt(r[5]);else{if(Y===Si)throw RangeError(`UUIDv7 generator sequence exhausted`);Y++}let i=BigInt(n);for(let e=5;e>=0;e--)r[e]=Number(i>>BigInt((5-e)*8))&255;r[6]=112|Number(Y>>37n&15n),r[7]=Number(Y>>29n&255n),r[8]=128|Number(Y>>23n&63n),r[9]=Number(Y>>15n&255n),r[10]=Number(Y>>7n&255n),r[11]=Number((Y&127n)<<1n)|r[11]&1;let a=Array.from(r,e=>e.toString(16).padStart(2,`0`));return`${a.slice(0,4).join(``)}-${a.slice(4,6).join(``)}-${a.slice(6,8).join(``)}-${a.slice(8,10).join(``)}-${a.slice(10).join(``)}`}function Ti(e){return St(e,{onFailure:h,onSuccess:()=>F})}function Ei(e,t){return pe(e,{onFailure:e=>C(t).pipe(g(h(e))),onSuccess:()=>t})}function Di(e,t){let n={_tag:`open`},r=r=>Ei(e,t).pipe(C,P(e=>N(()=>{r.result=e,n={_tag:`closed`}}).pipe(g(r.settled.open),g(Ti(e)))),te);return T(()=>{if(n._tag===`closed`)return F;if(n._tag!==`open`){let e=n;return e.settled.await.pipe(g(T(()=>{let t=e.result;return t===void 0?ce(Error(`Agent close settlement was not recorded`)):Ti(t)})))}let e={_tag:`running`,settled:pn(!1)};return n=e,r(e)})}function Oi(e,t,n,r){let i=Ge(e,t);if(n.state===`idle`)return{facts:{queue:{state:`idle`},cancellationRequested:!1,retry:null,activeTool:null,lastModelChoiceSequence:i,compaction:null},progress:null};if(n.state===`queued`)return{facts:{queue:{state:`queued`,commandId:n.jobId,runningWork:r},cancellationRequested:n.cancellationRequested,retry:null,activeTool:null,lastModelChoiceSequence:i,compaction:null},progress:null};let a=Rt(e,t,n.jobId),o=a?.event.type===`auto_retry_start`?{attempt:a.event.attempt,maxAttempts:a.event.maxAttempts,delayMs:a.event.delayMs,errorMessage:a.event.errorMessage,scheduledAt:a.timestamp}:null;return{facts:{queue:{state:`running`,commandId:n.jobId},cancellationRequested:n.cancellationRequested,retry:o,activeTool:Zn(e,t,n.jobId)??null,lastModelChoiceSequence:i,compaction:_t(e,t)},progress:kr(e,t,n.jobId)}}function ki(e){return new V(`model`,`rejected`,e)}function Ai(e,t){let n={input:e.input+t.input,output:e.output+t.output,cacheRead:e.cacheRead+t.cacheRead,cacheWrite:e.cacheWrite+t.cacheWrite,totalTokens:e.totalTokens+t.totalTokens,cost:{input:e.cost.input+t.cost.input,output:e.cost.output+t.cost.output,cacheRead:e.cost.cacheRead+t.cost.cacheRead,cacheWrite:e.cost.cacheWrite+t.cost.cacheWrite,total:e.cost.total+t.cost.total}};return(e.cacheWrite1h!==void 0||t.cacheWrite1h!==void 0)&&(n.cacheWrite1h=(e.cacheWrite1h??0)+(t.cacheWrite1h??0)),(e.reasoning!==void 0||t.reasoning!==void 0)&&(n.reasoning=(e.reasoning??0)+(t.reasoning??0)),n}function ji(e){let t;for(let n of e)n.kind===`compaction`&&(t=n);let n=t,r=n===void 0?0:Math.max(0,e.findIndex(({id:e})=>e===n.firstKeptEntryId)),i=e.flatMap((e,t)=>e.kind===`message`&&t>=r?[e.message]:[]);return n===void 0?i:[zn(n.summary,n.timestamp),...i]}function Mi(e,t,n){let r=bn(),i=t[n];if(i?.kind===`compaction`&&i.details!==void 0){for(let e of i.details.readFiles)r.read.add(e);for(let e of i.details.modifiedFiles)r.edited.add(e)}for(let t of e)Or(t,r);return r}function Ni(e){return e.role!==`toolResult`}function Pi(e,t,n,r){let i=e.flatMap((e,r)=>e.kind===`message`&&r>=t&&r<n&&Ni(e.message)?[r]:[]),a=i[0];if(a===void 0)return;let o=0,s=a;for(let a=n-1;a>=t;--a){let t=e[a];if(t?.kind===`message`&&(o+=_r(t.message),o>=r)){s=i.find(e=>e>=a)??i.at(-1)??s;break}}return s}function Fi(e,t,n){let r=e[n],i=r?.kind===`message`&&r.message.role===`user`,a=-1;if(!i)for(let r=n;r>=t;--r){let t=e[r];if(t?.kind===`message`&&t.message.role===`user`){a=r;break}}return{isSplitTurn:!i&&a>=0,turnStartIndex:a}}function Ii(e,t,n,r){let i=Pi(e,t,n,r);return i===void 0?{firstKeptEntryIndex:t,isSplitTurn:!1,turnStartIndex:-1}:{firstKeptEntryIndex:i,...Fi(e,t,i)}}function Li(e,t){if(e.at(-1)?.kind===`compaction`)return;let n,r=-1,i=0;for(let t=e.length-1;t>=0;--t){let a=e[t];if(a?.kind===`compaction`){n=a.summary,r=t;let o=e.findIndex(e=>e.id===a.firstKeptEntryId);i=o>=0?o:t+1;break}}let a=e.flatMap((e,t)=>e.kind===`message`&&t>=i?[e]:[]),o=Kt(ji(e)).tokens,s=Ii(a,0,a.length,t.keepRecentTokens),c=a[s.firstKeptEntryIndex];if(c?.kind!==`message`)return;let l=s.isSplitTurn?s.turnStartIndex:s.firstKeptEntryIndex,u=Object.freeze(a.slice(0,l).map(({message:e})=>e)),d=Object.freeze(s.isSplitTurn?a.slice(s.turnStartIndex,s.firstKeptEntryIndex).map(({message:e})=>e):[]);if(u.length===0&&d.length===0)return;let f=Mi(u,e,r);for(let e of d)Or(e,f);let p={firstKeptEntryId:c.id,messagesToSummarize:u,turnPrefixMessages:d,isSplitTurn:s.isSplitTurn,tokensBefore:o,fileOps:f,settings:t};return n===void 0?p:{...p,previousSummary:n}}var Ri={enabled:!0,maxRetries:3,baseDelayMs:2e3};function zi(e,t,n,r){let i={...n,cacheRetention:`none`,sessionId:n.sessionId??wi()};return Gt(()=>r?Promise.resolve(r(e,Nr(t),i)).then(e=>e.result()):Fr(async()=>{let{completeSimple:e}=await import(`./compat-CvJ9Wfru.js`);return{completeSimple:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16])).then(({completeSimple:n})=>n(e,t,i)),Ri,i.signal)}function Bi(e){return{systemPrompt:dn,messages:[{role:`user`,content:[{type:`text`,text:e}],timestamp:Date.now()}]}}function Vi(e,t,n){let r=e.previousSummary??``,i=t?Xn:mr,a=n===void 0?i:`${i}\n\nAdditional focus: ${n}`;return`<conversation>\n${wr(e.messagesToSummarize)}\n</conversation>\n\n${t?`<previous-summary>\n${r}\n</previous-summary>\n\n`:``}${a}`}function Hi(e){return`# Conversation\n${wr(e.turnPrefixMessages)}\n\n# Instructions\n${vn}`}async function Ui(e,t,n,r,i,a){let o=n===void 0?{maxTokens:t}:{maxTokens:t,signal:n},s=await zi(e,Bi(r),o,a),c=we(s,i);if(c!==void 0)throw Error(c);return s}function Wi(e,t,n,r,i,a){return e.messagesToSummarize.length===0?Promise.resolve(void 0):Ui(t,n,r,Vi(e,e.previousSummary!==void 0&&e.previousSummary.length>0,i),`Summarization`,a)}function Gi(e,t,n,r){return!e.isSplitTurn||e.turnPrefixMessages.length===0?Promise.resolve(void 0):Ui(t,Math.min(Math.floor(.5*e.settings.reserveTokens),t.maxTokens>0?t.maxTokens:1/0),n,Hi(e),`Turn prefix summarization`,r)}function Ki(e,t,n){let r,i;if(e.isSplitTurn){if(n===void 0)throw Error(`Split-turn compaction did not produce a prefix summary`);r=`${t===void 0?e.previousSummary??`No prior history.`:Pr(t.content)}\n\n---\n\n**Turn Context (split turn):**\n\n${Pr(n.content)}`,i=t===void 0?n.usage:Ai(t.usage,n.usage)}else{if(t===void 0)throw Error(`Compaction did not produce a history summary`);r=Pr(t.content),i=t.usage}let a=Cn(e.fileOps);return{summary:r+$t(a.readFiles,a.modifiedFiles),firstKeptEntryId:e.firstKeptEntryId,tokensBefore:e.tokensBefore,usage:i,details:a}}async function qi(e,t,n,r,i){return Ki(e,await Wi(e,t,Math.min(Math.floor(.8*e.settings.reserveTokens),t.maxTokens>0?t.maxTokens:1/0),n,r,i),e.isSplitTurn&&e.turnPrefixMessages.length>0?await Gi(e,t,n,i):void 0)}function Ji(e,t,n,r){return w({try:i=>qi(e,t,i,r,n),catch:e=>ki(e instanceof Error?e.message:String(e))})}function Yi(e,t,n){return{messagesToSummarize:e.messagesToSummarize,turnPrefixMessages:e.turnPrefixMessages,result:t,contextRevision:n}}function Xi(e){return new V(`runtime`,`rejected`,e)}var Zi={handoff:`The compaction handoff failed; the conversation context is unchanged`,conflict:`The Session changed during compaction; the conversation context is unchanged`},Qi=class extends V{phase;constructor(e){super(e===`conflict`?`store`:`runtime`,e===`conflict`?`conflict`:`rejected`,Zi[e]),this.phase=e}get diagnostic(){return Zi[this.phase]}};function $i(e,t){let n=Tn(e,t),r=Hn(e),i=[];for(let t of e){let e=$n(t.entry);if(e!==void 0&&!r.has(e.workId)){i.push({id:t.id,kind:`message`,message:Pt(e)});continue}if(t.entry.kind===`operator`){i.push({id:t.id,kind:`message`,message:Xe(t.entry)});continue}if(t.entry.kind===`message`){n.has(t.id)&&i.push({id:t.id,kind:`message`,message:t.entry.value});continue}if(t.entry.kind===`compaction`){let e={id:t.id,kind:`compaction`,timestamp:t.timestamp,firstKeptEntryId:t.entry.firstKeptEntryId,summary:t.entry.summary,usage:t.entry.usage};i.push(t.entry.details===void 0?e:{...e,details:t.entry.details})}}return i}function ea(e,t,n){return S({try:()=>Ht(e,{sessionId:t,workId:n}),catch:e=>e instanceof V&&e.cause===`context_too_large`?e:Xi(`Woodstock selected lineage is unavailable`)})}function ta(e,t){let n=e.reduce((e,t)=>t.entry.kind===`compaction`?t.timestamp:e,void 0),r=Kt(t),i=r.lastUsageIndex,a=i===null?void 0:t[i];return n===void 0||a?.role!==`assistant`||a.timestamp>n?r.tokens:t.reduce((e,t)=>e+_r(t),0)}function na(e,t,n,r){let i={...t,id:`${t.id}:compaction`,parentId:t.id,sequence:t.sequence+1,timestamp:Date.now(),entry:n};return Ot([...e,i],r).reduce((e,t)=>e+_r(t),0)}function ra(e,t,n){return T(()=>(Ue(e.store,e.sessionId,n.trigger),ia(e,t,n).pipe(E(N(()=>{Ze(e.store,e.sessionId)})))))}function ia(e,n,i){return t(function*(){let t=Li($i(n,e.workId),e.settings);if(t===void 0)return;let a=n.at(-1);if(a===void 0)return;let o=yield*Ji(t,e.model,e.stream,i.instructions);e.handoff!==void 0&&(yield*e.handoff.consume(Yi(t,o,a.id)).pipe(r(()=>new Qi(`handoff`))));let s=na(n,a,{kind:`compaction`,resumesRun:i.resumesRun,trigger:i.trigger,workId:e.workId,firstKeptEntryId:o.firstKeptEntryId,summary:o.summary,tokensBefore:o.tokensBefore,usage:o.usage,contextRevision:a.id},e.workId),c=yield*S({try:()=>on(e.store,{sessionId:e.sessionId,resumesRun:i.resumesRun,trigger:i.trigger,tokensAfter:s,expectedLeafId:a.id,workId:e.workId,firstKeptEntryId:o.firstKeptEntryId,summary:o.summary,tokensBefore:o.tokensBefore,usage:o.usage,contextRevision:a.id,details:o.details}),catch:e=>e instanceof V?e.cause===`conflict`?new Qi(`conflict`):e:Xi(`Woodstock compaction append failed`)}),l=[...n,c];return{path:l,messages:Ot(l,e.workId)}})}function aa(e){return e instanceof Qi?e.diagnostic:e.boundary===`model`?e.message:`Compaction failed (${e.boundary}: ${e.cause})`}function oa(e,t,n){return S({try:()=>{dr(e.store,{sessionId:e.sessionId,workId:e.workId,trigger:t,result:n===void 0?`nothing_to_compact`:`failed`,diagnostic:n===void 0?void 0:aa(n)})},catch:e=>e instanceof V?e:Xi(`Compaction notice could not be recorded`)})}function sa(e,t,n){return u(ra(e,t,n)).pipe(P(t=>t._tag===`Success`?v(t.success):oa(e,n.trigger,t.failure).pipe(j(void 0))))}function ca(e){return e.resuming===!0||!wt(ta(e.path,e.messages),e.model.contextWindow,e.settings)?v({path:e.path,messages:e.messages}):sa(e,e.path,{trigger:`threshold`,resumesRun:!1}).pipe(l(t=>t??{path:e.path,messages:e.messages}))}function la(e,t){let n=ln(e.message,t.contextWindow),r=Qt(e.message,t.maxTokens);return{triggered:n||r,overflow:n,retry:(n||r)&&e.message.stopReason!==`stop`}}function ua(e){let t=e.at(-1);return t?.role===`assistant`&&(t.stopReason===`error`||t.stopReason===`length`)?e.slice(0,-1):e}function da(e,t,n,r){if(!e.settings.enabled)return v(void 0);let i=wt(ta(t.path,[...t.messages,...n.messages.slice(t.newMessageCount)]),e.model.contextWindow,e.settings);return r.triggered||i?ea(e.store,e.sessionId,e.workId):v(void 0)}function fa(e,n){return(r,i)=>t(function*(){if(!wt(ta(n.path,r),e.model.contextWindow,e.settings))return;let t=yield*sa(e,yield*ea(e.store,e.sessionId,e.workId),{trigger:`threshold`,resumesRun:!1});if(t!==void 0)return n.path=t.path,n.messages=t.messages,n.newMessageCount=i,t.messages})}function pa(e,n){return t(function*(){let t=n,r=n.path.some(({entry:t})=>t.kind===`compaction`&&t.workId===e.workId&&t.resumesRun===!0);for(;;){let n={path:t.path,messages:t.messages,newMessageCount:0},i=yield*e.run(n.messages,fa(e,n)),a=la(i,e.model),o=yield*da(e,n,i,a);if(o===void 0||a.retry&&r)return i;let s=yield*sa(e,o,{trigger:a.overflow?`overflow`:`threshold`,resumesRun:a.retry});if(s===void 0||!a.retry)return i;t={path:s.path,messages:ua(s.messages)},r=!0}})}function ma(e){return e.settings.enabled?ca(e).pipe(P(t=>pa(e,t))):pa(e,e)}function ha(e){return e.path.some(({entry:t})=>(t.kind===`compaction`||t.kind===`compaction_notice`)&&t.workId===e.workId)?v(`compacted`):ra(e,e.path,{trigger:`manual`,resumesRun:!1,instructions:e.instructions}).pipe(ie(t=>oa(e,`manual`,t)),P(t=>t===void 0?oa(e,`manual`,void 0).pipe(j(`nothing_to_compact`)):v(`compacted`)))}function ga(e,t){let n=Ht(e,{sessionId:t}),r=Ot(n);return r.length===0?null:ta(n,r)}var _a=new WeakMap;function va(e){let t=_a.get(e);if(t!==void 0)return t;let n=new Map;return _a.set(e,n),n}function ya(e,n,r){return t(function*(){let t=yield*u(S({try:()=>({tokens:ga(e.store,r),preference:me(e.store,r)}),catch:e=>e}));if(t._tag===`Failure`||t.success.tokens===null)return;let{tokens:i,preference:a}=t.success,o=va(n),s=JSON.stringify(a),c=o.get(r);if(c?.preference===s)return Object.freeze({tokens:i,window:c.window});let d=e.model.describe;if(d===void 0)return Object.freeze({tokens:i,window:null});let f=yield*d({sessionId:r,preference:a}).pipe(l(({contextWindow:e})=>e),re(e=>N(()=>{Jt(`session-context.describe`,e)})));return f===void 0?Object.freeze({tokens:i,window:null}):(o.set(r,{preference:s,window:f}),Object.freeze({tokens:i,window:f}))})}function ba(e){return Object.freeze({list:e.assertOpen.pipe(l(()=>e.extensions.list())),resume:t=>e.assertOpen.pipe(g(e.extensions.resume(t))),call:(t,n,r)=>e.assertOpen.pipe(g(e.extensions.call({scope:`agent`},t,n,r)))})}function xa(e,t,n){return t.readQueueHead(n).pipe(P(r=>(r.state===`queued`?t.runningWork(r.jobId):v(null)).pipe(l(t=>Oi(e.store,n,r,t)))))}function Sa(e,t){return t===void 0?e:Object.freeze({...e,context:t})}function Ca(e,t,n,r){return xa(e,t,n).pipe(P(i=>xt(e.store,n,i,r,()=>t.extensions.project(n))),P(r=>ya(e,t,n).pipe(l(e=>Sa(r,e)))))}function wa(e,t,n){return e.assertOpen.pipe(g(S({try:()=>n(I(t)),catch:e=>e instanceof V?e:new V(`store`,`rejected`,`Session owner operation failed`)})))}function Ta(e,t){return S({try:()=>{let n=ct(t);if(n._tag===`Failure`)throw new V(`contract`,`invalid`,`Session command is invalid`);return Object.freeze({sessionId:I(e),command:n.success})},catch:e=>e instanceof V?e:new V(`contract`,`invalid`,`Session command is invalid`)})}function Ea(e,t){return S({try:()=>Object.freeze({sessionId:I(e),options:kn(t)}),catch:e=>e instanceof V?e:new V(`contract`,`invalid`,`Subscribe options are invalid`)})}function Da(e,t,n,r=!1){return t.assertOpen.pipe(g(Ca(e,t,n,{includeSandboxFailures:r})),l(e=>Object.freeze({kind:`reset`,reason:`history_unavailable`,cursor:e.cursor,baseline:e})))}function Oa(e){return[[e],O({after:e.cursor??void 0,delivery:e.baseline.hasMore?`replay`:`live`,awaitSignal:!e.baseline.hasMore})]}function ka(e,t,n,r,i,a,o=!1){return zt({after:i,delivery:a,awaitSignal:!1},i=>(i.awaitSignal?n.awaitSignal.pipe(P(e=>n.pollSignal.pipe(l(t=>t===void 0?e:Vn(e,t))))):n.pollSignal).pipe(P(n=>n===`closed`?v([[],b()]):n===`reset`?Da(e,t,r,o).pipe(l(Oa)):t.assertOpen.pipe(g(xa(e,t,r)),P(a=>n===`progress`&&i.delivery===`live`&&a.progress!==null?v([[{kind:`progress`,progress:a.progress,activity:a.facts}],O({...i,awaitSignal:!0})]):vr(e.store,r,i.after,i.delivery,a,()=>t.extensions.project(r),o).pipe(P(n=>{if(n.kind===`reset`)return Da(e,t,r,o).pipe(l(Oa));let a={after:n.frames.flatMap(e=>e.kind===`progress`?[]:[e.cursor]).at(-1)??i.after,delivery:n.hasMore?i.delivery:`live`,awaitSignal:!n.hasMore};return(n.frames.some(e=>e.kind===`update`)?ya(e,t,r):v(void 0)).pipe(l(e=>[e===void 0?n.frames:n.frames.map(t=>t.kind===`update`?Object.freeze({...t,context:e}):t),O(a)]))})))))))}function Aa(e,t,n,r,i){return ht(t.assertOpen.pipe(g(Ea(r,i)),P(r=>ue(n.register(r.sessionId),e=>N(e.close)).pipe(l(n=>ka(e,t,n,r.sessionId,r.options.after,`replay`,r.options.includeSandboxFailures===!0))))))}function ja(e,t){return S({try:()=>Object.freeze({sessionId:I(e),options:De(t)}),catch:e=>e instanceof V?e:new V(`contract`,`invalid`,`Watch options are invalid`)})}function Ma(e,n,r,i,a){return n.assertOpen.pipe(g(ja(i,a)),P(i=>de(a=>t(function*(){let t=yield*r.register(i.sessionId);return yield*a(n.assertOpen.pipe(g(Ca(e,n,i.sessionId,i.options)),l(r=>Object.freeze({snapshot:r,changes:ka(e,n,t,i.sessionId,r.cursor??void 0,`live`,i.options.includeSandboxFailures===!0).pipe(Re(N(t.close))),close:N(t.close)})))).pipe(d(()=>N(t.close)))}))))}function Na(e,t,n,r,i,a){let o={sessionId:t,command:n,when:`now`,origin:{kind:`user`}};return r!==void 0&&(o={...o,meta:r}),i!==void 0&&(o={...o,mail:i}),a!==void 0&&(o={...o,reply:a}),e.assertOpen.pipe(g(e.door.admit(o)),P(e=>e.status===`accepted`?v({status:`accepted`,commandId:e.commandId}):x(new V(`runtime`,`unavailable`,`Session command was not admitted`))))}function Pa(e,t,n,r,i){return t.assertOpen.pipe(g(Kn(e.store,n,r.commandId,r.onlyIfPending,()=>t.readQueueHeadTransactional(n),t.recordAcceptedCancellation,i)),P(e=>e===void 0?v({status:`too_late`,commandId:r.commandId}):(e.active?t.signalCancellation(e.accepted.commandId,e.accepted.entryId):t.requestWake).pipe(j({status:`accepted`,commandId:e.accepted.commandId}))))}function Fa(e,t,n,r){return t.assertOpen.pipe(g(t.commit(Nn(e.store,n,()=>t.readQueueHeadTransactional(n),t.recordAcceptedCancellation,r))),P(e=>e===void 0?t.requestWake:t.signalCancellation(e.commandId,e.entryId)))}function Ia(e,t,n,r){return t.assertOpen.pipe(g(hn(e.store,{sessionId:n,type:`branch`,entryId:r.entryId,assertIdleSession:t.assertIdleSession})),j(void 0))}function La(e,t,n,r){return t.assertOpen.pipe(g(yn(e.store,{sessionId:n,type:`fork`,entryId:r.entryId,assertIdleSession:t.assertIdleSession})))}function Ra(e,t,n,r,i){return t.assertOpen.pipe(g(Ta(n,i)),P(t=>za(e,r).pipe(l(e=>({...t,checked:e})))),P(({sessionId:n,command:r,checked:i})=>{switch(r.type){case`prompt`:case`compact`:return Na(t,n,r,i);case`abort`:return Fa(e,t,n,i).pipe(j(void 0));case`cancel`:return Pa(e,t,n,r,i);case`branch`:return Ia(e,t,n,r);case`fork`:return La(e,t,n,r);case`operator`:return t.assertOpen.pipe(g(ge(e.store,{sessionId:n,requestId:r.requestId,author:r.author,meta:i,text:r.text,assertIdleSession:t.assertIdleSession})),j(void 0));case`title`:return t.commit(wa(t,n,t=>{ur(e.store,t,r.title)})).pipe(j(void 0))}}))}function za(e,t){return S({try:()=>t===void 0?void 0:Ut(e.meta,t),catch:e=>e instanceof V?e:new V(`contract`,`invalid`,`Host metadata is invalid`)})}function Ba(e,t){let n=tr(e.store),i=(i,a)=>{function o(n){return Ra(e,t,i,a,n)}return Object.freeze({command:o,abort:o({type:`abort`}),send:(e,t)=>N(()=>t?.requestId??At()).pipe(P(n=>{let i={type:`prompt`,delivery:t?.delivery??`steer`,requestId:n,text:e};return o(t?.images===void 0?i:{...i,images:t.images}).pipe(r(e=>e.requestId===n?e:new V(e.boundary,e.cause,e.message,n)))})),cancel:e=>o({type:`cancel`,...e}),modelPreference:Object.freeze({read:wa(t,i,t=>me(e.store,t)),set:n=>S({try:()=>Fe(n),catch:()=>new V(`contract`,`invalid`,`Model preference is invalid`)}).pipe(P(n=>t.commit(wa(t,i,t=>(mn(e.store,t,n),t))).pipe(y(t=>N(()=>{W(e.store,t)})),_)))}),extension:e=>Object.freeze({call:(n,r)=>t.assertOpen.pipe(g(t.extensions.call({scope:`session`,sessionId:i},e,n,r)))}),read:n=>t.assertOpen.pipe(g(Ca(e,t,i,n))),subscribe:r=>Aa(e,t,n,i,r),watch:r=>Ma(e,t,n,i,r)})},a=Object.freeze({createSession:n=>t.assertOpen.pipe(g(In(e.store,n,t.storage.admitNew))),deleteSession:n=>t.assertOpen.pipe(g(xn(e.store,{sessionId:n,assertIdleSession:t.assertIdleSession}))),listSessions:n=>t.assertOpen.pipe(g(be(e.store,n))),extensions:ba(t),session:e=>i(e,void 0),close:t.beginClose.pipe(g(n.close))});return Object.freeze({...a,grants:Object.freeze({deliver:(n,r)=>wa(t,n,t=>e.store.transactionSync(()=>sr(e.store,t,r))),read:n=>wa(t,n,t=>an(e.store,t))}),withMeta:e=>Object.freeze({...a,session:t=>i(t,e)})})}function Va(e,t,n,r){return Na(e,t.to.sessionId,{requestId:t.key,delivery:r===void 0?`followUp`:`steer`,type:`prompt`,text:t.content},n,t,r)}var Ha=H({fork:Sn([`inherit-at-fork-point`,`current`,`fresh`]),maxBytes:un.pipe(z(nn(0)),z(Er(2**53-1)))});function Ua(e,t){let n=Bt(e.schema)(t);if(n._tag===`Failure`)throw new Br({reason:`encode`,message:`Session document does not match its schema`});let r=U(Wn)(n.success);if(r._tag===`Failure`)throw new Br({reason:`encode`,message:`Session document must encode finite JSON`});let i=JSON.stringify(r.success);if(new TextEncoder().encode(i).byteLength>e.maxBytes)throw new Br({reason:`bound`,message:`Session document exceeds maxBytes`});return i}function Wa(e){return{...Nt(Ha)(e),schema:vi(kt(e.schema)),initial:Ua(e,e.initial)}}var Ga=64,Ka=Sn([`state`,`attention`,`settled`,`send`,`timers`,`commands`,`projection`,`run_tools`,`files`,`prompt`,`compaction_handoff`]),qa=K(Ka).pipe(z(Se(10))),Ja=H({protocol:Rn(`shiitake.extension/v0`),id:Un,version:en,requests:qa}),Ya=K(H({id:Un,capabilities:qa,grantKey:B(Un)})).pipe(z(Se(Ga))),Xa=br.pipe(z(On(/^[a-z][A-Za-z0-9_]{0,63}$/u))),Za=U(Ja,{onExcessProperty:`error`}),Qa=U(Ya,{onExcessProperty:`error`}),$a=U(Xa);function X(e){return new V(`extensions`,`invalid`,e)}function eo(e){return new Set(e).size!==e.length}function to(e){return JSON.stringify(e,(e,t)=>M(t)?Object.fromEntries(Object.entries(t).sort(([e],[t])=>e<t?-1:+(e>t))):t)}function no(e){return w({try:async()=>{let t=await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(e));return Array.from(new Uint8Array(t),e=>e.toString(16).padStart(2,`0`)).join(``)},catch:()=>new V(`extensions`,`rejected`,`Extension digest failed`)})}function ro(e,t){let{manifest:n,contract:r,state:i,config:a,catalog:o}=e,s={manifest:{protocol:n.protocol,id:n.id,version:n.version,requests:[...n.requests].sort()},commands:Object.fromEntries(Object.entries(r.commands).map(([e,t])=>[e,{scope:t.scope,input:vi(kt(t.input)),output:vi(kt(t.output))}])),projection:r.projection===null?null:vi(kt(r.projection.schema)),state:{version:i.version,collections:Object.fromEntries(Object.entries(i.collections).map(([e,t])=>[e,vi(kt(t.schema))]))},config:a},c=Object.keys(t).length===0?s:{...s,documents:Object.fromEntries(Object.entries(t).map(([e,t])=>[e,Wa(t)]))};return o===void 0?c:{...c,catalog:o}}function io(e){if(Za(e.manifest)._tag===`Failure`)throw X(`Extension manifest is invalid`);let t=e.manifest;if(eo(t.requests))throw X(`Extension capability requests are invalid`);if(e.contract.id!==t.id)throw X(`Extension contract identity does not match its manifest`);if(!Number.isSafeInteger(e.state.version)||e.state.version<1)throw X(`Extension state version is invalid`);for(let t of Object.keys(e.state.collections))if(t===`update`||t===`read`||t===`observe`||$a(t)._tag===`Failure`)throw X(`Extension collection name is invalid`);if(e.catalog!==void 0&&!t.requests.includes(`commands`))throw X(`An extension catalog requires the commands capability`);return t}function ao(e){return t(function*(){let n=e?.roster??[],r=e?.grants??[],i=yield*S({try:()=>{if(n.length>Ga)throw X(`Extension roster is invalid`);let e=n.map(e=>{let t=bi(e);if(t===void 0)throw X(`Extension roster entry was not defined`);let n=t.documents??{};for(let[e,t]of Object.entries(n)){if($a(e)._tag===`Failure`)throw X(`Session document name is invalid`);Wa(t)}let r=io(t);if(Object.keys(n).length>0&&!r.requests.includes(`state`))throw X(`Session documents require the state capability`);return{definition:t,documents:n,manifest:r}});if(eo(e.map(({manifest:e})=>e.id)))throw new V(`extensions`,`conflict`,`Extension identities conflict`);let t=Qa(r);if(t._tag===`Failure`)throw X(`Extension grants are invalid`);if(eo(t.success.map(({id:e})=>e)))throw X(`Extension grant identities are invalid`);let i=new Map;for(let n of t.success){let t=e.find(({manifest:e})=>e.id===n.id);if(t===void 0||eo(n.capabilities)||n.capabilities.some(e=>!t.manifest.requests.includes(e)))throw X(`Extension grant is invalid`);i.set(n.id,n.capabilities)}if(e.filter(({manifest:e})=>i.get(e.id)?.includes(`compaction_handoff`)).length>1)throw new V(`extensions`,`conflict`,`Compaction handoff slot is already owned`);if(e.filter(({manifest:e})=>i.get(e.id)?.includes(`files`)).length>1)throw new V(`extensions`,`conflict`,`Files slot is already owned`);return e.map(e=>({...e,grants:i.get(e.manifest.id)??[]})).sort((e,t)=>e.manifest.id<t.manifest.id?-1:+(e.manifest.id>t.manifest.id))},catch:e=>e instanceof V?e:X(`Extension roster is invalid`)});return yield*fe(i,e=>t(function*(){let t=`sha256:${yield*no(yield*S({try:()=>to(ro(e.definition,e.documents)),catch:()=>X(`Extension schemas cannot be described`)}))}`,n=[...e.grants].sort(),r=`sha256:${yield*no(to([t,n]))}`;return Object.freeze({id:e.manifest.id,manifest:e.manifest,definition:e.definition,documents:e.documents,grants:new Set(n),revision:Nt(rr)(t),fingerprint:Nt(qt)(r)})}))})}function oo(e){return no(to({protocol:`shiitake.extension/v0`,runContract:1,fileTools:[...e].sort()}))}var so=un.pipe(z(cn(0)),z(Er(2**53-1))),co=H({reserveTokens:B(so),keepRecentTokens:B(so)}),lo=H({enabled:B(rn),reserveTokens:B(so),keepRecentTokens:B(so),modelOverrides:B(Ce(br,co))}),uo=U(lo,{onExcessProperty:`error`});function fo(e){let t=uo(e??{});if(t._tag===`Failure`)throw new V(`contract`,`invalid`,`Compaction settings must be non-negative whole token counts`);let n=t.success;return e=>{let t=n.modelOverrides?.[`${e.provider}/${e.id}`];return{enabled:n.enabled??Fn.enabled,reserveTokens:t?.reserveTokens??n.reserveTokens??Fn.reserveTokens,keepRecentTokens:t?.keepRecentTokens??n.keepRecentTokens??Fn.keepRecentTokens}}}function po(e){return new V(`runtime`,`rejected`,e)}var mo={missing:`Instruction capabilities have no tool runtime`,runtime:`Tool runtime failed`,lease:`Tool lease failed`},ho=class extends V{phase;constructor(e){super(`runtime`,`rejected`,mo[e]),this.phase=e}get diagnostic(){return mo[this.phase]}};function go(e){return e.type===`retry_attempt_started`?{type:`auto_retry_attempt`,run:e.run,attempt:e.attempt}:e.type===`retry_scheduled`?{type:`auto_retry_start`,run:e.run,attempt:e.attempt,maxAttempts:e.maxAttempts,delayMs:e.delayMs,errorMessage:e.errorMessage}:e.finalError===void 0?{type:`auto_retry_end`,run:e.run,attempt:e.attempt,success:e.success}:{type:`auto_retry_end`,run:e.run,attempt:e.attempt,success:e.success,finalError:e.finalError}}function _o(e,n,i,a,o,s,c){let l=e.tools,u=o.modules??[],d=[...u,...s];return l===void 0?u.length>0||c.length>0?x(new ho(`missing`)):v([]):t(function*(){let t={sessionId:n,commandId:i};a!==void 0&&(t={...t,meta:a});let o={sources:l.sources,session:t,sandbox:l.sandbox,onSandboxFailure:t=>En(e.store,{sessionId:n,commandId:i},t).pipe(le),modules:[...l.modules,...d],tools:c,access:{...l.access,sessionGrants:()=>an(e.store,n)?.grants??{}}},s=yield*(yield*fr(l.execution===void 0?o:{...o,execution:l.execution}).pipe(r(()=>new ho(`runtime`)))).acquire().pipe(r(()=>new ho(`lease`)));return[s.executeTool,...s.tools]})}function vo(e,n,i,a,o,s,c){return ne(t(function*(){let t=yield*e.instructions.load({sessionId:n.command.sessionId,commandId:n.command.entry.workId}),u=t.release;u!==void 0&&(yield*k(()=>N(u)));let d=yield*Lr(e.model.acquire({sessionId:n.command.sessionId,preference:n.modelPreference})),f=yield*_o(e,n.command.sessionId,n.command.entry.workId,n.command.entry.meta,t,a,o),p=Object.freeze({sessionId:n.command.sessionId,requestId:n.command.entry.requestId,commandId:n.command.entry.workId}),m=yield*hr(e.store,p,i),ee=t=>dt(e.store,{sessionId:p.sessionId,workId:p.commandId,delivery:t}).pipe(l(e=>e.map(({message:e})=>e)),r(e=>({_tag:`MuleError`,phase:`control`,message:e instanceof V?e.message:`Session control delivery failed`}))),h=n.resume,te=fo(e.compaction)(d.model);return yield*ma({store:e.store,sessionId:n.command.sessionId,workId:n.command.entry.workId,model:d.model,stream:d.stream,handoff:s,settings:te,path:n.path,messages:n.messages,resuming:h!==void 0,run:(n,i)=>{let a=h;h=void 0;let o=e=>m(e),s={model:d.model,modelStreamIdleTimeoutMs:e.modelStreamIdleTimeoutMs??3e5,retry:e.retry??Jn,retryAfterMs:d.retryAfterMs,systemPrompt:t.text,prepareSystemPrompt:()=>(c===void 0?v([]):c()).pipe(l(e=>t.text+e.map(({name:e,text:t})=>`\n\n[extension:${e}]\n${t}`).join(``)),r(e=>({_tag:`MuleError`,phase:`model`,message:`Extension prompt is unavailable`,cause:e}))),messages:n,resume:a,tools:f,getSteeringMessages:()=>ee(`steer`),prepareNextTurn:e=>i(e.context,e.newMessages.length).pipe(r(e=>({_tag:`MuleError`,phase:`control`,message:e.message}))),onRetry:t=>jn(e.store,p,go(t),t.turn)};return gn.run(d.stream===void 0?s:{...s,stream:d.stream},o).pipe(r(e=>po(e.phase===`model`?e.message:`Mule rejected the durable command run`)))}})}))}function yo(e,n,r){return ne(t(function*(){let t=yield*Lr(e.model.acquire({sessionId:n.command.sessionId,preference:n.modelPreference})),i=n.command.entry;return yield*ha({store:e.store,sessionId:n.command.sessionId,workId:i.workId,model:t.model,stream:t.stream,handoff:r,settings:fo(e.compaction)(t.model),path:n.path,instructions:Be(i)?i.instructions:void 0})}))}var bo=Object.freeze({maxRecoveries:2});function xo(e){return new V(`runtime`,`rejected`,e)}function So(e){let t=`${e.boundary}:${e.cause}`,n=e instanceof ho||e instanceof Qi?e.diagnostic:e.boundary===`model`?e.message:void 0;return{kind:`failed`,reason:n===void 0?t:`${t}: ${n}`.slice(0,200)}}function Co(e,t){return s(`shiitake_run_failed`,Dn(t)).pipe(se({workId:e,reason:`${t.boundary}:${t.cause}`}))}function wo(e,n,r,i){return t(function*(){W(e.store,r.queue);let t=yield*S({try:()=>Lt(r),catch:()=>xo(`Agent work payload is invalid`)}),a=yield*Wt(e.store,t.work);if(a.abnormalTerminal!==void 0)return{kind:a.abnormalTerminal};let o=i?.incompatibleMigrations()[0];if(o!==void 0)return yield*s(`shiitake_run_contract_changed`).pipe(se({workId:r.jobId,terminal:`contract_changed: ${o}`})),yield*x(xo(`contract_changed: ${o}`));let c=new Set(i?.runParticipants().map(([e])=>e)??[]);if(Be(a.command.entry))return yield*yo(e,a,i?.compactionHandoff(c)),yield*et(e.store,{sessionId:a.command.sessionId,commandFactId:t.work.commandFactId,workId:a.command.entry.workId,outcome:`completed`}),{kind:`completed`};let u=yield*S({try:()=>Sr(e.store,t.work.sessionId,t.work.commandFactId,a.command.entry.workId),catch:()=>xo(`Accepted run origin is unavailable`)}),d={sessionId:a.command.sessionId,workId:a.command.entry.workId,origin:u===null?null:{extensionId:Nt(wn)(u.extensionId),correlation:u.correlation}},f=i===void 0?[]:yield*i.filesForRun(d,c),p=i===void 0?[]:yield*fe([...c],t=>i.modulesForRun(d,new Set([t])).pipe(P(n=>S({try:()=>{let r=e.extensions.grants.find(e=>e.id===t)?.grantKey??t;return n.map(e=>ar.grantAs(e,r))},catch:()=>xo(`Extension tools are invalid`)})))).pipe(l(e=>e.flat())),m=i?.compactionHandoff(c);switch((yield*vo(e,a,{core:f.length===0?n:yield*oo(f.map(e=>e.descriptor.name)),extensions:i?.runParticipants()??[]},p,f,m,i===void 0?void 0:()=>i.promptSections(d,c))).status){case`completed`:return{kind:`completed`};case`cancelled`:return{kind:`cancelled`};case`failed`:return{kind:`failed`}}}).pipe(re(e=>Co(r.jobId,e).pipe(j(So(e)))))}var To=U(ve,{onExcessProperty:`error`}),Eo=U(An(rn)),Do=U(qe,{onExcessProperty:`error`});function Oo(e){if(e.reply===void 0)return;let t=tt(Do(e.reply),`Verified Agent reply is invalid`),n=e.mail;if(n?.replyTo.length!==0||n.from.agentId!==t.agentId||n.from.sessionId!==t.sessionId||e.command.type!==`prompt`||e.command.delivery!==`steer`)throw new V(`contract`,`invalid`,`Verified Agent reply does not match its mail`);return t}function ko(e){let t=t=>({sessionId:I(t.sessionId),requireExistingSession:tt(Eo(t.requireExistingSession),`Session admission condition is invalid`)??!1,command:tt(Et(t.command),`Session command is invalid`),origin:tt(To(t.origin),`Session command origin is invalid`),when:t.when,mail:t.mail,reply:Oo(t),meta:t.meta===void 0?void 0:Ut(e.hostMeta,t.meta)}),n=(t,n)=>{let{sessionId:r,origin:i}=t,a=t.command;if(t.requireExistingSession&&!Le(e.owner,r))throw new V(`contract`,`closed`,`Session target is unavailable`);let o=e.readQueueHead(r);if(t.when===`idle`&&o.state!==`idle`&&Ft(e.owner,r,a.requestId)===void 0)return Object.freeze({status:`not_ready`});a.type===`prompt`&&Ft(e.owner,r,a.requestId)===void 0&&e.admitNew();let s=a.type===`prompt`&&a.delivery===`steer`&&o.state===`running`&&!o.cancellationRequested?o.jobId:void 0,c=Ve(e.owner,r,a,t.meta,i,e.contract(),s===void 0?n=>{e.enqueue(n,t.mail)}:void 0,s,t.reply);return n.set(r,(n.get(r)??!1)||c.delivery===`new`),Object.freeze({status:`accepted`,commandId:c.accepted.commandId,delivery:c.delivery})},r=(t,r)=>T(()=>{let i=new Map,a=S({try:()=>(i.clear(),e.owner.transactionSync(()=>t(e=>n(e,i)))),catch:e=>e instanceof V?e:new V(`store`,`unavailable`,`Session command admission is unavailable`)});return(r===`request`?e.commit(a):a).pipe(y(()=>N(()=>{for(let[t,n]of i)n&&W(e.owner,t)})),y(()=>i.size>0?e.requestWake:F))});return Object.freeze({transact:(e,n=`request`)=>r(n=>e(e=>n(t(e))),n),admit:(e,n)=>S({try:()=>t(e),catch:e=>e instanceof V?e:new V(`contract`,`invalid`,`Session command is invalid`)}).pipe(P(e=>r(t=>t(e),n??`request`)))})}var Ao=`core`,jo=256,Mo=1048576,No=512,Po=64,Fo=new TextEncoder,Io=U(K(H({name:br.pipe(z(On(/^[a-z][A-Za-z0-9_-]{0,63}$/u))),text:br.pipe(z(R(1)),z(ft(e=>Fo.encode(e).byteLength<=8192)))})).pipe(z(Se(16)))),Lo=class extends Error{};function Ro(e){return e.length<=No?e:`${e.slice(0,511)}…`}var zo=jr(It(Wn));function Bo(e){return e instanceof zr?e.reason:`${e._tag}: ${e.message}`}function Vo(e){return e instanceof zr||e instanceof Br||e instanceof Wr||e instanceof Vr}function Ho(e,t){let n=Ee(t);if(m(n)){let t=n.value;return t instanceof zr?Ro(t.reason):Ro(Vo(t)?`${e}: ${Bo(t)}`:`${e} failed`)}let r=i(Ae(t));return m(r)?r.value instanceof Error?Ro(r.value.name===`AsyncFiberError`?`${e} crossed an asynchronous boundary inside a core transaction`:`${e} defect: ${r.value.message}`):Ro(`${e} defect`):Ro(`${e} was interrupted`)}function Uo(e){let t=Ee(e);return a(t)||t.value instanceof zr}function Z(e,t){return new Br({reason:e,message:t})}function Wo(e,t){return e.length>=1&&e.length<=jo?v(e):x(Z(`bound`,`${t} must be 1..256 characters`))}function Go(e){let t=Ro(e.message);if(e instanceof Vr)switch(e.reason){case`invalid`:return new V(`contract`,`invalid`,t);case`conflict`:return new V(`store`,`conflict`,t);case`not_found`:return new V(`store`,`rejected`,t);case`rejected`:return new V(`extensions`,`rejected`,t)}if(e instanceof Wr)switch(e.reason){case`invalid`:return new V(`contract`,`invalid`,t);case`conflict`:return new V(`contract`,`conflict`,t);case`closed`:return new V(`runtime`,`closed`,t)}return e.reason===`bound`?new V(`contract`,`invalid`,t):new V(`store`,`unavailable`,t)}function Ko(e){let{owner:r}=e,i=new WeakMap,c=new Map,u=new Set,ee,te=new Set,ne=new Set,_,ie=e=>Object.freeze({extensionId:e}),w=e=>P(Ur,t=>t.extensionId===e?F:ce(Error(`Extension read used another extension's context`))),E=e=>P(Hr,t=>{let n=i.get(t);return n?.extensionId===e?v(n):ce(Error(`Extension write used outside its own core transaction`))}),D=e=>S({try:e,catch:()=>Z(`unavailable`,`Extension state is unavailable`)}),k=(e,t)=>e.admitted.grants.has(t)?F:x(Z(`unavailable`,`Extension is not granted ${t}`));function ue(e,t,n){let i=e.admitted.id,a=yt(It(n.schema)),o=ze(n.schema),s=e=>{let n=a(e);return n._tag===`Failure`?x(Z(`decode`,`Stored ${t} record is invalid`)):v(n.success)};return Object.freeze({peek:n=>{if(ee!==i||!e.admitted.grants.has(`state`))throw Error(`Extension read used outside its own projection`);let o=ot(r,i,t,n);if(o===void 0)return b();let s=a(o);if(s._tag===`Failure`)throw Z(`decode`,`Stored ${t} record is invalid`);return O(s.success)},peekPage:n=>{if(ee!==i||!e.admitted.grants.has(`state`))throw Error(`Extension read used outside its own projection`);if(!Number.isSafeInteger(n.limit)||n.limit<1||n.limit>Po)throw Z(`bound`,`Page limit must be 1..64`);return pt(r,i,t,n).map(e=>{let n=a(e);if(n._tag===`Failure`)throw Z(`decode`,`Stored ${t} record is invalid`);return n.success})},get:n=>w(i).pipe(g(k(e,`state`)),g(D(()=>ot(r,i,t,n))),P(e=>e===void 0?v(b()):s(e).pipe(l(O)))),page:n=>w(i).pipe(g(k(e,`state`)),g(Number.isSafeInteger(n.limit)&&n.limit>=1&&n.limit<=Po?F:x(Z(`bound`,`Page limit must be 1..64`))),g(D(()=>pt(r,i,t,n))),P(e=>fe(e,s))),put:a=>E(i).pipe(g(k(e,`state`)),g(T(()=>{let e=o(a);if(e._tag===`Failure`)return x(Z(`encode`,`The ${t} record does not match its schema`));let s=JSON.stringify(e.success);if(Fo.encode(s).byteLength>Mo)return x(Z(`bound`,`The ${t} record exceeds 1 MiB`));let c=n.index?.(a)??null;return ae([Wo(n.key(a),`A record key`),c===null?v(null):Wo(c,`A record index`)]).pipe(P(([e,n])=>D(()=>{Mr(r,i,t,e,n,s)})))}))),remove:n=>E(i).pipe(g(k(e,`state`)),g(D(()=>{Oe(r,i,t,n)})))})}function M(e,t,n){let i=e.admitted.id,a=yt(It(n.schema)),o=ze(n.schema),s=()=>{if(!te.has(i)||!e.admitted.grants.has(`state`))throw Z(`unavailable`,`Extension state update is unavailable`)},c=e=>{if(e.length<1||e.length>jo)throw Z(`bound`,`A record key must be 1..256 characters`);return e},l=e=>{let n=a(e);if(n._tag===`Failure`)throw Z(`decode`,`Stored ${t} record is invalid`);return n.success};return Object.freeze({get:e=>{s();let n=ot(r,i,t,c(e));return n===void 0?b():O(l(n))},page:e=>{if(s(),!Number.isSafeInteger(e.limit)||e.limit<1||e.limit>Po)throw Z(`bound`,`Page limit must be 1..64`);return pt(r,i,t,e).map(l)},put:e=>{s();let a=o(e);if(a._tag===`Failure`)throw Z(`encode`,`The ${t} record does not match its schema`);let l=JSON.stringify(a.success);if(Fo.encode(l).byteLength>Mo)throw Z(`bound`,`The ${t} record exceeds 1 MiB`);let u=n.index?.(e)??null;u!==null&&c(u),Mr(r,i,t,c(n.key(e)),u,l)},remove:e=>{s(),Oe(r,i,t,c(e))}})}function de(e){let t=e.admitted.id;return Object.freeze({set:(n,i)=>E(t).pipe(y(()=>k(e,`timers`)),y(()=>Wo(n,`A timer key`)),y(()=>Number.isSafeInteger(i)&&i>=0?F:x(Z(`bound`,`A timer instant is invalid`))),P(e=>D(()=>{He(r,t,n,i),e.timersChanged=!0}))),cancel:n=>E(t).pipe(y(()=>k(e,`timers`)),P(e=>D(()=>{ut(r,t,n),e.timersChanged=!0}))),read:i=>w(t).pipe(g(k(e,`timers`)),g(D(()=>$e(r,t,i))),l(n))})}function pe(t){let n=t.admitted.id,i=(i,a)=>E(n).pipe(y(()=>k(t,`attention`)),P(t=>S({try:()=>{I(i),a(),Yt(r,i,e.readQueueHead(i)),t.observed.add(i)},catch:e=>e instanceof V&&e.cause===`invalid`?Z(`bound`,e.message):Z(`unavailable`,`Attention update is unavailable`)})));return{set:(e,t)=>{let a=U(Qe,{onExcessProperty:`error`})(t);return a._tag===`Failure`?x(Z(`bound`,`Attention item is invalid`)):i(e,()=>{if(!Le(r,e))throw Error(`Attention Session is unavailable`);lr(r,e,n,a.success)})},clear:(e,t)=>Wo(t,`An attention id`).pipe(g(i(e,()=>{gt(r,e,n,t)})))}}function me(e){let t=e.admitted.id;return n=>E(t).pipe(P(r=>e.admitted.grants.has(`send`)?S({try:()=>{let{requireExistingSession:e=!1}=n,i=r.admit({sessionId:n.sessionId,requireExistingSession:e,command:{type:`prompt`,requestId:n.prompt.requestId,delivery:n.prompt.delivery,text:n.prompt.text},when:n.when,origin:{kind:`extension`,extensionId:t,correlation:n.correlation??null}});return i.status===`accepted`?{_tag:`Accepted`,commandId:i.commandId,delivery:i.delivery}:{_tag:`NotReady`}},catch:e=>new Wr({reason:e instanceof V?e.cause===`conflict`?`conflict`:e.cause===`closed`?`closed`:`invalid`:`invalid`,message:e instanceof V?e.message:`Session command is invalid`})}):x(new Wr({reason:`closed`,message:`Extension is not granted send`}))))}function ge(n,a,o){return T(()=>{let s,c,u=Error(`Extension transaction rolled back`);return e.door.transact(e=>{let t=ie(n.admitted.id);c={extensionId:n.admitted.id,admit:e,observed:new Set,timersChanged:!1},i.set(t,c),ne.add(n.admitted.id);let r=_;_=c;try{s=oe(a.pipe(p(Hr,t),p(Ur,t)))}finally{_=r,i.delete(t),ne.delete(n.admitted.id)}if(Zt(s))throw u;return s.value},o).pipe(l(()=>{if(s===void 0)throw Error(`Extension transaction returned no exit`);return s}),re(e=>s!==void 0&&Zt(s)?v(s):x(e)),y(n=>Cr(n)&&c!==void 0?t(function*(){for(let e of c?.observed??[])W(r,e);o===`request`&&c?.timersChanged===!0&&(yield*e.requestWake)}):F))})}function ve(t){let n=``;for(let i=0;i<Ar;i+=Po){let i=he(r,t,n);for(let t of i)Yt(r,t,e.readQueueHead(t)),queueMicrotask(()=>{W(r,t)});let a=i.at(-1);if(i.length<Po||a===void 0)return;n=a}}function L(e,n,i,a){let o=Date.now();e.status=`stopped`,e.reason=n,e.stoppedAt=o;let c=S({try:()=>{let t=()=>{jt(r,e.admitted.id,{status:`stopped`,reason:n,stoppedAt:o,revision:e.admitted.revision}),ve(e.admitted.id)};a===`own-transaction`?r.transactionSync(t):t()},catch:t=>new V(`store`,`unavailable`,`Extension ${e.admitted.id} stop status is unavailable`,void 0,t)});return t(function*(){let t=yield*C(c);return yield*s(`shiitake_extension_stopped`).pipe(se({extensionId:e.admitted.id,reason:n,cause:i===void 0?null:Dn(i),durable:Cr(t)})),yield*t})}function be(e,t,n){e.status=`stopped`,e.reason=t,e.stoppedAt=Date.now();let i=()=>{jt(r,e.admitted.id,{status:`stopped`,reason:t,stoppedAt:e.stoppedAt,revision:e.admitted.revision}),ve(e.admitted.id)};try{n===`own-transaction`?r.transactionSync(i):i()}catch(t){throw new V(`store`,`unavailable`,`Extension ${e.admitted.id} stop status is unavailable`,void 0,t)}}function Se(e,t,n){let i=t=>{if(_?.extensionId!==e.admitted.id||!e.admitted.grants.has(`state`))throw Z(`unavailable`,`Session documents require the extension's state transaction`);return I(t),_},a=a=>{i(a);let o=mt(r,a,e.admitted.id,t)??Ua(n,n.initial);if(Fo.encode(o).byteLength>n.maxBytes)throw Z(`bound`,`Session document exceeds maxBytes`);let s=U(It(n.schema))(o);if(s._tag===`Failure`)throw Z(`decode`,`Stored session document does not match its schema`);return s.success};return Object.freeze({read:a,update:(o,s)=>{let c=i(o),l=s(a(o));nr(r,o,e.admitted.id,t,Ua(n,l)),c.observed.add(o)}})}function Ce(e){let t=new Set;return Object.freeze({collection:(t,n)=>ue(e,t,n),updateCollection:(t,n)=>M(e,t,n),document:(t,n)=>Se(e,t,n),update:n=>{let i=e.admitted.id;if(e.status!==`running`||!e.admitted.grants.has(`state`)||te.has(i)||ne.has(i)||ee===i)throw Z(`unavailable`,`Extension state update is unavailable`);try{let e=r.transactionSync(()=>{te.add(i);try{return er(n,void 0)}finally{te.delete(i)}});for(let e of t)W(r,e);return e}catch(t){if(!(t instanceof cr))throw t;let n=t.message;throw be(e,n,`own-transaction`),new zr({reason:n})}finally{t.clear()}},observeUpdate:n=>{if(!te.has(e.admitted.id))throw Z(`unavailable`,`Extension observation is unavailable`);t.add(I(n))},context:Object.freeze({manifest:e.admitted.manifest,revision:e.admitted.revision,grants:Object.freeze([...e.admitted.grants]),send:me(e),timers:de(e),attention:pe(e),hasPendingSteer:t=>w(e.admitted.id).pipe(g(k(e,`run_tools`)),g(D(()=>Mt(r,I(t.sessionId),t.workId)))),hasSuccessfulToolResult:(t,n)=>w(e.admitted.id).pipe(g(k(e,`run_tools`)),g(D(()=>Je(r,I(t.sessionId),t.workId,n)))),observe:t=>E(e.admitted.id).pipe(l(e=>{e.observed.add(t)})),transact:t=>(e.status===`running`?ge(e,t,`request`).pipe(le):x(new zr({reason:e.reason??`Extension is stopped`}))).pipe(P(t=>{if(Cr(t))return v(t.value);if(!Uo(t.cause))return h(t.cause);let n=Ho(`transact`,t.cause);return L(e,n,t.cause,`own-transaction`).pipe(P(()=>x(new zr({reason:n}))))}))})})}function we(e){let{id:t,definition:n,revision:i}=e.admitted,a=n.state.version;r.transactionSync(()=>{let e=Ie(r,t);if(e!==void 0&&e.version>a)throw new V(`extensions`,`conflict`,`Stored ${t} state version ${String(e.version)} is newer than ${String(a)}`);if(e!==void 0&&e.version<a){let i=_e(r,t).map(e=>({collection:e.collection,key:e.key,value:zo(e.valueJson)}));for(let r=e.version;r<a;r+=1){let e=n.state.migrations[r];if(e===void 0)throw new Lo(`Missing ${t} state migration from ${String(r)}`);try{i=i.flatMap(t=>e(t))}catch(e){throw new Lo(`Failed ${t} state migration from ${String(r)}`,{cause:e})}}Me(r,t);for(let e of i){let i=n.state.collections[e.collection];if(i===void 0)throw new Lo(`Migrated ${t} record names an undeclared collection`);let a=i.indexFromEncoded(e.value);if(a._tag===`Failure`)throw new Lo(`Migrated ${t} ${e.collection} record is invalid`);Mr(r,t,e.collection,e.key,a.success,JSON.stringify(e.value))}}ye(r,t,a,i)})}function Te(e,t){let n=Ce(e);return T(()=>e.admitted.definition.activate(n)).pipe(p(sn,t),C,P(t=>Cr(t)?(e.hooks=t.value,F):L(e,Ho(`activation`,t.cause),t.cause,`own-transaction`)))}let R=e=>[...c.values()].filter(t=>t.status===`running`&&t.hooks!==void 0&&t.admitted.grants.has(e));function De(e){return Object.freeze({id:e.admitted.id,version:e.admitted.manifest.version,revision:e.admitted.revision,status:e.status,reason:e.reason,stoppedAt:e.stoppedAt})}function ke(e){return e.status===`running`&&e.hooks!==void 0&&(e.admitted.grants.has(`run_tools`)||e.admitted.grants.has(`files`)||e.admitted.grants.has(`prompt`)||e.admitted.grants.has(`compaction_handoff`))}function Ae(e,t,n){return C(n.pipe(p(Ur,ie(e.admitted.id)))).pipe(P(n=>Cr(n)?v(O(n.value)):L(e,Ho(t,n.cause),n.cause,`own-transaction`).pipe(j(b()))))}let je=(e,t,n)=>Zt(n)?L(e,Ho(t,n.cause),n.cause,`own-transaction`):F;function Ne(e){return S({try:()=>{we(e),r.transactionSync(()=>{for(let[t,n]of Object.entries(e.admitted.documents))xr(r,{extensionId:e.admitted.id,name:t,initialJson:Ua(n,n.initial),fork:n.fork,maxBytes:n.maxBytes})})},catch:e=>e}).pipe(j(!0),re(t=>t instanceof V?x(t):(t instanceof Lo&&(e.admitted.grants.has(`run_tools`)||e.admitted.grants.has(`files`)||e.admitted.grants.has(`prompt`)||e.admitted.grants.has(`compaction_handoff`))&&u.add(e.admitted.id),L(e,Ro(t instanceof Error?`migration: ${t.message}`:`migration failed`),yr(t),`own-transaction`).pipe(j(!1)))))}return t(function*(){let n=yield*Ln();for(let t of e.admitted){let e=We(r,t.id),i=e?.status===`stopped`&&e.revision===t.revision,a={admitted:t,hooks:void 0,status:i?`stopped`:`running`,reason:i?e.reason:null,stoppedAt:i?e.stoppedAt:null};c.set(t.id,a),yield*S({try:()=>{t.grants.has(`settled`)&&r.transactionSync(()=>{G(r,t.id)===void 0&&Dt(r,t.id,G(r,`core`)??0)})},catch:()=>new V(`store`,`unavailable`,`Settled cursor is unavailable`)}),(yield*Ne(a).pipe(d(()=>qn(n,xe))))&&(i||(yield*S({try:()=>{r.transactionSync(()=>{jt(r,t.id,{status:`running`,reason:null,stoppedAt:null,revision:t.revision}),ve(t.id)})},catch:()=>new V(`store`,`unavailable`,`Extension status is unavailable`)}),yield*Te(a,n)))}yield*S({try:()=>{r.transactionSync(()=>{let t=fn(r,e.admitted.filter(e=>e.grants.has(`attention`)).map(e=>e.id));for(let e of t)ve(e)})},catch:()=>new V(`store`,`unavailable`,`Attention grants are unavailable`)});let i={runParticipants:()=>[...c.values()].filter(ke).map(e=>[e.admitted.id,e.admitted.fingerprint]),incompatibleMigrations:()=>[...u],modulesForRun:(e,t)=>fe(R(`run_tools`),n=>{let r=n.hooks?.moduleForRun;return!t.has(n.admitted.id)||r===void 0?v(b()):Ae(n,`moduleForRun`,T(()=>r(e))).pipe(l(f))}).pipe(l(e=>e.flatMap(A))),filesForRun:(e,n)=>t(function*(){let t=R(`files`).find(e=>n.has(e.admitted.id));if(t===void 0)return[];let r=t.hooks?.filesForRun;if(r===void 0)return yield*L(t,`files: granted capability has no handler`,void 0,`own-transaction`),yield*x(new V(`extensions`,`rejected`,`Extension Files are unavailable`));let i=yield*Ae(t,`filesForRun`,T(()=>r(e)));return a(i)?yield*x(new V(`extensions`,`rejected`,`Extension Files capture failed`)):Object.freeze([...o(i.value,()=>[])])}),promptSections:(e,n)=>t(function*(){let t=[],r=0;for(let i of R(`prompt`)){if(!n.has(i.admitted.id))continue;let a=i.hooks?.prompt;if(a===void 0)return yield*L(i,`prompt: granted capability has no handler`,void 0,`own-transaction`),yield*x(new V(`extensions`,`rejected`,`Extension prompt is unavailable`));let o=yield*C(Bn(()=>a(e)).pipe(p(Ur,ie(i.admitted.id))));if(Zt(o))return yield*L(i,Ho(`prompt`,o.cause),o.cause,`own-transaction`),yield*x(new V(`extensions`,`rejected`,`Extension prompt failed`));let s=Io(o.value),c=s._tag===`Success`?s.success:[];if(r+=c.reduce((e,t)=>e+Fo.encode(t.text).byteLength,0),s._tag===`Failure`||new Set(c.map(({name:e})=>e)).size!==c.length||r>65536)return yield*L(i,`prompt: section is invalid or exceeds its bound`,void 0,`own-transaction`),yield*x(new V(`extensions`,`rejected`,`Extension prompt is invalid`));t.push(...[...c].sort((e,t)=>e.name<t.name?-1:+(e.name>t.name)).map(e=>({name:`${i.admitted.id}.${e.name}`,text:e.text})))}return t}),compactionHandoff:e=>R(`compaction_handoff`).find(({admitted:t})=>e.has(t.id))?.hooks?.compactionHandoff,settledConsumers:()=>R(`settled`).map(e=>({id:e.admitted.id,cursor:G(r,e.admitted.id)??0})),deliverSettled:(e,t)=>fe(R(`settled`),n=>T(()=>{let i=G(r,n.admitted.id)??0;if(t<=i)return F;let a=e.filter(({sequence:e})=>e>i),o=n.hooks?.onSettled;return ge(n,(o===void 0||a.length===0?F:o(a)).pipe(g(N(()=>{Dt(r,n.admitted.id,t)}))),`reconcile`).pipe(P(e=>je(n,`onSettled`,e)))}),{discard:!0}),fireDueTimers:e=>t(function*(){let t=R(`timers`).map(({admitted:e})=>e.id),n=rt(r,t,e,Po);for(let t of n){let n=c.get(t.extensionId);if(n?.status!==`running`)continue;let i=n.hooks?.onTimer,a=yield*ge(n,T(()=>$e(r,t.extensionId,t.key)===t.dueAt?(ut(r,t.extensionId,t.key),i===void 0?F:i({key:t.key,dueAt:t.dueAt,firedAt:e})):F),`reconcile`);yield*je(n,`onTimer`,a)}return n.length===Po}),timerWake:e=>bt(r,R(`timers`).map(({admitted:e})=>e.id),e),project:e=>{let t={};for(let n of c.values()){let r=n.admitted.grants.has(`projection`),i=n.admitted.grants.has(`commands`)?n.admitted.definition.catalog:void 0;if(!r&&i===void 0)continue;let a=n.admitted.revision,o=n.admitted.definition.contract.projection,s=n.hooks?.project;if(n.status===`running`&&n.hooks!==void 0){let c=!r||s===void 0||o===null?O(null):(()=>{let t=null,r;ee=n.admitted.id;try{let r=er(()=>s(e),void 0);if(m(r)){let e=ze(o.schema)(r.value);if(e._tag===`Failure`)throw Error(`Extension projection is invalid`);let a=U(Wn)(e.success);if(a._tag===`Failure`)throw Error(`Extension projection is not JSON`);t=a.success;let s=n.hooks.projectCatalog;i!==void 0&&s!==void 0&&(i=Nt(Wn)(er(()=>s(a.success),void 0)))}}catch(e){r=e}finally{ee=void 0}return r===void 0?O(t):(be(n,Ro(r instanceof Error?`project defect: ${r.message}`:`project defect`),`enclosing-transaction`),b())})();if(m(c)){t[n.admitted.id]=Object.freeze(i===void 0?{status:`running`,revision:a,value:c.value}:{status:`running`,revision:a,value:c.value,catalog:i});continue}}t[n.admitted.id]=Object.freeze({status:`stopped`,revision:a,reason:n.reason??`Extension did not activate`})}return Object.freeze(t)},call:(e,n,r,i)=>t(function*(){let t=c.get(n);if(t?.admitted.grants.has(`commands`)!==!0)return yield*x(new V(`extensions`,`unavailable`,`Extension is unavailable`));if(t.status!==`running`||t.hooks===void 0)return yield*x(new V(`extensions`,`unavailable`,`Extension ${n} is stopped: ${t.reason??`not activated`}`));let a=t.admitted.definition.contract.commands,o=Object.hasOwn(a,r)?a[r]:void 0;if(o?.scope!==e.scope)return yield*x(new V(`contract`,`invalid`,`Extension command is unknown`));let s=e.scope===`session`?yield*S({try:()=>I(e.sessionId),catch:()=>new V(`contract`,`invalid`,`Session id is invalid`)}):null,l=t.hooks.commands.get(r);if(l===void 0)return U(o.input,{onExcessProperty:`error`})(i)._tag===`Failure`?yield*x(new V(`contract`,`invalid`,`Extension command input is invalid`)):(yield*L(t,`command ${r} has no handler`,void 0,`own-transaction`),yield*x(new V(`extensions`,`unavailable`,`Extension is stopped`)));let u=l({sessionId:s,input:i});if(u._tag===`Failure`)return yield*x(new V(`contract`,`invalid`,`Extension command input is invalid`));let d=yield*ge(t,u.success(),`request`);if(Cr(d))return d.value;let f=Ee(d.cause);if(m(f)&&!Uo(d.cause))return yield*x(Go(f.value));let p=Ho(`command ${r}`,d.cause);return yield*L(t,p,d.cause,`own-transaction`),yield*x(new V(`extensions`,`unavailable`,`Extension ${n} is stopped: ${p}`))}),list:()=>[...c.values()].map(De),resume:i=>t(function*(){let t=c.get(i);return t===void 0?yield*x(new V(`extensions`,`unavailable`,`Extension is unavailable`)):(t.status===`stopped`&&(yield*S({try:()=>{r.transactionSync(()=>{jt(r,t.admitted.id,{status:`running`,reason:null,stoppedAt:null,revision:t.admitted.revision}),ve(t.admitted.id)})},catch:()=>new V(`store`,`unavailable`,`Extension status is unavailable`)}),t.status=`running`,t.reason=null,t.stoppedAt=null,t.hooks===void 0&&(yield*Ne(t))&&(yield*Te(t,n)),yield*e.requestWake),De(t))}),close:qn(n,xe)};return Object.freeze(i)})}var qo=64;function Q(e){return new V(`runtime`,`rejected`,e)}function Jo(e,n,i){return n===void 0?F:t(function*(){let t=yield*S({try:()=>Lt(i),catch:()=>Q(`Agent work payload is invalid`)}),a=i.outcome===`cancelled`?``:yield*ke(e,t.work),o=yield*st(e,t.work,i.outcome),s=i.outcome===`completed`||i.outcome===`cancelled`?void 0:yield*Te(e,t.work),c=s===void 0?{job:i,content:a}:{job:i,content:a,diagnostic:s};yield*n.fanOut(o===void 0?c:{...c,meta:o}).pipe(r(()=>Q(`Agent reply fan-out is unavailable`)))})}function Yo(e,n){let r=n.outcome;return r!==`interrupted`&&r!==`cancelled`&&r!==`failed`?F:t(function*(){let t=yield*S({try:()=>Lt(n),catch:()=>Q(`Agent work payload is invalid`)});yield*et(e,{sessionId:t.work.sessionId,commandFactId:t.work.commandFactId,workId:n.jobId,outcome:r,diagnostic:n.failureReason})})}function Xo(e,n,r){return t(function*(){let t=yield*S({try:()=>Lt(r),catch:()=>Q(`Agent work payload is invalid`)}),i=r.outcome===`outcome_unknown`?`interrupted`:r.outcome;yield*it(e,{sessionId:t.work.sessionId,parentWorkId:r.jobId,outcome:i,enqueue:e=>{n.transactional.enqueueAcceptedJob(Vt({work:{...e,recovery:bo}}))}})})}function Zo(e){return e===void 0?F:e.drainOutbox().pipe(r(()=>Q(`Agent reply delivery is unavailable`)))}function Qo(e,t){let n=Lt(t.job),r=Tt(e,n.work.sessionId,n.work.commandFactId,t.job.jobId);return Object.freeze({sequence:t.sequence,sessionId:n.work.sessionId,workId:t.job.jobId,outcome:t.job.outcome,terminal:r.terminal,toolCalls:r.toolCalls,origin:r.origin===null?null:Object.freeze({extensionId:Nt(wn)(r.origin.extensionId),correlation:r.origin.correlation})})}function $o(e,n,r,i){return fe(i,i=>t(function*(){W(e,i.job.queue),yield*Yo(e,i.job),yield*Xo(e,n,i.job),yield*Jo(e,r,i.job),yield*S({try:()=>{Dt(e,Ao,i.sequence)},catch:()=>Q(`Settled cursor is unavailable`)})}),{discard:!0})}function es(e){return t(function*(){if((yield*e.watchdog.tick()).status===`busy`)return yield*x(Q(`Runtime reconciliation is already active`));let t=yield*S({try:()=>G(e.store,`core`)??0,catch:()=>Q(`Settled cursor is unavailable`)}),n=e.extensions.settledConsumers(),r=Math.min(t,...n.map(({cursor:e})=>e)),i=yield*e.watchdog.readSettled(qo,r),a=yield*C($o(e.store,e.watchdog,e.mailRoom,i.filter(({sequence:e})=>e>t))),o=yield*S({try:()=>{let t=G(e.store,`core`)??0;return i.filter(({sequence:e})=>e<=t).map(t=>Qo(e.store,t))},catch:()=>Q(`Settled run facts are unavailable`)});yield*e.extensions.deliverSettled(o,G(e.store,`core`)??0);let s=yield*e.extensions.fireDueTimers(Date.now());if((i.length===qo||s)&&(yield*e.requestWake),yield*Zo(e.mailRoom),Zt(a))return yield*h(a.cause)}).pipe(r(e=>e instanceof V?e:Q(`Runtime reconciliation failed`)))}function $(e){return new V(`runtime`,`rejected`,e)}function ts(e,n,i,a){return t(function*(){if(e.hostJobs?.lane==="default")return yield*x($(`Host lane conflicts with Agent work`));let o=`open`,s,c,u=pn(!1),f=e=>N(()=>{o===`open`&&(s??=e)}),p=T(()=>o===`open`?(o=`closing`,c=s,u.open):F).pipe(te),m={},ne={current:void 0},_=T(()=>m.requestWake??x($(`Runtime host is unavailable`))),b={current:void 0},C=new Set,w=new Map,oe={owner:e.store,isAlive:()=>v(!1),executor:{execute:t=>D(N(()=>{let n=t.lane===e.hostJobs?.lane?{kind:`host`,lane:t.lane,jobId:t.jobId}:{kind:`session`,sessionId:t.queue,commandId:t.jobId};w.set(n.kind===`host`?`host`:`serial`,n),n.kind===`session`&&C.add(t.queue),W(e.store,null)}),()=>t.lane===e.hostJobs?.lane?b.current?.execute(t)??x(new Ir(`execution_failed`)):wo(e,n,t,ne.current),()=>N(()=>{t.lane!==e.hostJobs?.lane&&C.delete(t.queue),w.delete(t.lane===e.hostJobs?.lane?`host`:`serial`),W(e.store,null)}))},wake:{recompute:()=>_.pipe(r(()=>new Ir(`wake_unavailable`)))},project:t=>{Gn(e.store,t,Date.now())}},O=yield*(e.hostJobs===void 0?Rr(oe):Rr({...oe,concurrentLane:e.hostJobs.lane}).pipe(y(t=>N(()=>{b.current=e.hostJobs?.open(t)})))).pipe(r(()=>$(`Watchdog is unavailable`))),se=()=>({core:n,extensions:[...ne.current?.runParticipants()??[]]});yield*S({try:()=>fo(e.compaction),catch:e=>e instanceof V?e:$(`Compaction settings are unavailable`)});let ce=yield*S({try:()=>Ne(e.storageBudget),catch:e=>e instanceof V?e:$(`Storage budget is unavailable`)}),k=ko({owner:e.store,admitNew:ce.admitNew,hostMeta:e.meta,contract:se,enqueue:(e,t)=>{let n={work:{...e,recovery:bo}};O.transactional.enqueueAcceptedJob(Vt(t===void 0?n:{...n,mail:t}))},readQueueHead:e=>O.transactional.readQueueHead(e),commit:e=>T(()=>m.commit===void 0?x($(`Runtime host is unavailable`)):m.commit(e)),requestWake:_});yield*S({try:()=>{Mn(e.store),G(e.store,`core`)===void 0&&e.store.transactionSync(()=>{Dt(e.store,Ao,0)})},catch:()=>new V(`store`,`unavailable`,`Extension store is unavailable`)});let A=yield*Ko({owner:e.store,readQueueHead:e=>O.transactional.readQueueHead(e),door:k,admitted:i,requestWake:_});ne.current=A;let j=es({watchdog:O,store:e.store,extensions:A,requestWake:_,mailRoom:a}).pipe(ie(f)),ue=t(function*(){let t=yield*O.hasPendingWork,n=Date.now(),r=yield*S({try:()=>[G(e.store,`core`)??0,...A.settledConsumers().map(({cursor:e})=>e)],catch:()=>$(`Settled cursor is unavailable`)}),i=(yield*O.readSettled(1,Math.min(...r))).length>0,a=yield*S({try:()=>A.timerWake(n),catch:()=>$(`Extension timers are unavailable`)});return{pending:t||i||a.due,nextWakeAt:a.nextWakeAt}}),M=yield*e.runtime.bind({reconcile:j,pendingWork:ue.pipe(r(()=>$(`Pending work is unavailable`)))}).pipe(d(()=>A.close.pipe(le))),de=T(()=>o===`open`?ee(M.requestWake.pipe(re(f)),u.await):F);return m.requestWake=de,m.commit=M.commit,yield*M.requestWake.pipe(d(()=>ae([M.close,A.close]).pipe(le))),Object.freeze({activeSessions:N(()=>[...C]),runningWork:t=>O.read(t).pipe(l(t=>t.status===`found`?w.get(t.job.lane===e.hostJobs?.lane?`host`:`serial`)??null:null),r(e=>new V(`runtime`,`rejected`,`Running work is unavailable`,void 0,e))),extensions:A,commit:M.commit,assertOpen:T(()=>o===`open`?F:x(new V(`runtime`,`closed`,`Shiitake is closed`))),beginClose:p,door:k,storage:ce,recordAcceptedCancellation:({jobId:e,cancellationId:t,onlyIfPending:n})=>O.transactional.recordCancellationIntent({jobId:e,cancellationId:t,onlyIfQueued:n}),assertIdleSession:e=>{try{if(O.transactional.readQueueHead(e).state!==`idle`)throw new V(`runtime`,`conflict`,`Session branch or fork requires an idle Session`)}catch(e){throw e instanceof V?e:$(`Session status is unavailable`)}},signalCancellation:(e,t)=>O.cancel({jobId:e,cancellationId:t}).pipe(P(e=>e.status===`recorded`||e.status===`replayed`?F:x($(`Cancellation is unavailable`))),r(()=>$(`Cancellation is unavailable`))),readQueueHead:e=>O.readQueueHead(e).pipe(r(()=>$(`Session status is unavailable`))),readQueueHeadTransactional:e=>O.transactional.readQueueHead(e),requestWake:de,close:p.pipe(g(pe(M.close,{onFailure:e=>A.close.pipe(g(c===void 0?h(e):x(c))),onSuccess:()=>A.close.pipe(g(c===void 0?F:x(c)))})),E(N(()=>{o=`closed`})))})})}var ns=e({openRuntimeCore:()=>rs});function rs(e,n){return t(function*(){let t=yield*ao(e.extensions),r=yield*oo([]);yield*Tr(e.store);let i=yield*ts(e,r,t,n),a=Ba(e,i),o=Object.freeze({session:a.session,createSession:a.createSession,deleteSession:a.deleteSession,listSessions:a.listSessions,extensions:a.extensions,close:Di(a.close,i.close)}),s=Object.freeze({...o,grants:a.grants,withMeta:e=>Object.freeze({...o,session:a.withMeta(e).session})});return Object.freeze({agent:s,readSettlement:(t,n)=>i.assertOpen.pipe(g(Xt(e.store,t,n))),activeSessions:i.activeSessions,acceptMail:(e,t,n)=>Va(i,e,t,n)})})}export{wi as n,rs as openRuntimeCore,ns as t};
|