@vxnus/siduri 0.1.8 → 0.1.11

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.
Files changed (114) hide show
  1. package/README.md +3 -4
  2. package/dist/builtin-manifests.d.ts +2 -0
  3. package/dist/builtin-manifests.js +492 -0
  4. package/dist/clean-machine-e2e.test.d.ts +1 -0
  5. package/dist/clean-machine-e2e.test.js +236 -0
  6. package/dist/configurators/behavior.d.ts +2 -0
  7. package/dist/configurators/behavior.js +36 -0
  8. package/dist/configurators/body.d.ts +2 -0
  9. package/dist/configurators/body.js +60 -0
  10. package/dist/configurators/brain.d.ts +6 -0
  11. package/dist/configurators/brain.js +80 -0
  12. package/dist/configurators/ear.d.ts +2 -0
  13. package/dist/configurators/ear.js +28 -0
  14. package/dist/configurators/hands.d.ts +2 -0
  15. package/dist/configurators/hands.js +27 -0
  16. package/dist/configurators/index.d.ts +24 -0
  17. package/dist/configurators/index.js +78 -0
  18. package/dist/configurators/knowledge.d.ts +6 -0
  19. package/dist/configurators/knowledge.js +100 -0
  20. package/dist/configurators/memory.d.ts +2 -0
  21. package/dist/configurators/memory.js +44 -0
  22. package/dist/configurators/mouth.d.ts +2 -0
  23. package/dist/configurators/mouth.js +15 -0
  24. package/dist/configurators/observation.d.ts +2 -0
  25. package/dist/configurators/observation.js +12 -0
  26. package/dist/configurators/types.d.ts +12 -0
  27. package/dist/configurators/types.js +2 -0
  28. package/dist/configurators/vision.d.ts +2 -0
  29. package/dist/configurators/vision.js +39 -0
  30. package/dist/configurators/voice.d.ts +2 -0
  31. package/dist/configurators/voice.js +477 -0
  32. package/dist/configurators.test.d.ts +1 -0
  33. package/dist/configurators.test.js +331 -0
  34. package/dist/db.d.ts +25 -0
  35. package/dist/db.js +152 -0
  36. package/dist/discovery.d.ts +13 -0
  37. package/dist/discovery.js +87 -0
  38. package/dist/discovery.test.d.ts +1 -0
  39. package/dist/discovery.test.js +69 -0
  40. package/dist/doctor-db.test.d.ts +1 -0
  41. package/dist/doctor-db.test.js +141 -0
  42. package/dist/doctor.d.ts +19 -0
  43. package/dist/doctor.js +249 -0
  44. package/dist/generator.d.ts +20 -0
  45. package/dist/generator.js +615 -0
  46. package/dist/generator.test.d.ts +1 -0
  47. package/dist/generator.test.js +197 -0
  48. package/dist/index.d.ts +20 -0
  49. package/dist/index.js +395 -0
  50. package/dist/manifest.d.ts +33 -0
  51. package/dist/manifest.js +40 -0
  52. package/dist/providers/knowledge-hub.d.ts +37 -0
  53. package/dist/providers/knowledge-hub.js +141 -0
  54. package/dist/providers/openrouter.d.ts +32 -0
  55. package/dist/providers/openrouter.js +201 -0
  56. package/dist/release-check.d.ts +9 -0
  57. package/dist/release-check.js +133 -0
  58. package/dist/runtime-parity.test.d.ts +1 -0
  59. package/dist/runtime-parity.test.js +141 -0
  60. package/dist/schema-validator.d.ts +9 -0
  61. package/dist/schema-validator.js +107 -0
  62. package/dist/web-dist/404/index.html +1 -0
  63. package/dist/web-dist/404.html +1 -0
  64. package/dist/web-dist/__next.__PAGE__.txt +35 -0
  65. package/dist/web-dist/__next._full.txt +32 -0
  66. package/dist/web-dist/__next._tree.txt +4 -0
  67. package/dist/web-dist/_next/static/chunks/09y7khbmco_v4.js +1 -0
  68. package/dist/web-dist/_next/static/chunks/0cz1d0mv5g_q7.js +1 -0
  69. package/dist/web-dist/_next/static/chunks/0uwih7sydv413.js +1 -0
  70. package/dist/web-dist/_next/static/chunks/0xhe1hasjan-9.css +1 -0
  71. package/dist/web-dist/_next/static/chunks/1_yae15ffa5f6.js +1 -0
  72. package/dist/web-dist/_next/static/chunks/2_duynll0m51m.js +30 -0
  73. package/dist/web-dist/_next/static/chunks/2kcqevsmv6kh2.js +31 -0
  74. package/dist/web-dist/_next/static/chunks/2s3d1bfr0l4b0.js +1 -0
  75. package/dist/web-dist/_next/static/chunks/32z87id9k6i2z.js +22 -0
  76. package/dist/web-dist/_next/static/chunks/3bx2gs3idjmo1.js +1 -0
  77. package/dist/web-dist/_next/static/chunks/turbopack-3eipe4c-imn5l.js +1 -0
  78. package/dist/web-dist/_next/static/media/apple-icon.2g7-yefdphkmy.png +0 -0
  79. package/dist/web-dist/_next/static/media/favicon.3rlors1ui1gw9.ico +0 -0
  80. package/dist/web-dist/_next/static/media/icon.0580nb9h-ugue.svg +4 -0
  81. package/dist/web-dist/_next/static/pWHUixFDDvANZeAf-shqT/_buildManifest.js +11 -0
  82. package/dist/web-dist/_next/static/pWHUixFDDvANZeAf-shqT/_clientMiddlewareManifest.js +1 -0
  83. package/dist/web-dist/_next/static/pWHUixFDDvANZeAf-shqT/_ssgManifest.js +1 -0
  84. package/dist/web-dist/_not-found/__next._full.txt +17 -0
  85. package/dist/web-dist/_not-found/__next._not-found.__PAGE__.txt +23 -0
  86. package/dist/web-dist/_not-found/__next._tree.txt +3 -0
  87. package/dist/web-dist/_not-found/index.html +1 -0
  88. package/dist/web-dist/_not-found/index.txt +17 -0
  89. package/dist/web-dist/apple-icon.png +0 -0
  90. package/dist/web-dist/apple-touch-icon.png +0 -0
  91. package/dist/web-dist/chat/__next._full.txt +18 -0
  92. package/dist/web-dist/chat/__next._tree.txt +3 -0
  93. package/dist/web-dist/chat/__next.chat.__PAGE__.txt +24 -0
  94. package/dist/web-dist/chat/index.html +1 -0
  95. package/dist/web-dist/chat/index.txt +18 -0
  96. package/dist/web-dist/favicon.ico +0 -0
  97. package/dist/web-dist/favicon.svg +4 -0
  98. package/dist/web-dist/icon.svg +4 -0
  99. package/dist/web-dist/index.html +1 -0
  100. package/dist/web-dist/index.txt +32 -0
  101. package/dist/web-dist/live2d/live2dcubismcore.min.js +9 -0
  102. package/dist/web-dist/logo-circle.png +0 -0
  103. package/dist/web-dist/logo-circle.svg +4 -0
  104. package/dist/web-dist/logo-white.svg +3 -0
  105. package/dist/web-dist/logo.png +0 -0
  106. package/dist/web-dist/logo.svg +3 -0
  107. package/dist/web-dist/operator/__next._full.txt +18 -0
  108. package/dist/web-dist/operator/__next._tree.txt +3 -0
  109. package/dist/web-dist/operator/__next.operator.__PAGE__.txt +24 -0
  110. package/dist/web-dist/operator/index.html +1 -0
  111. package/dist/web-dist/operator/index.txt +18 -0
  112. package/dist/web-template.d.ts +2 -0
  113. package/dist/web-template.js +557 -0
  114. package/package.json +1 -1
@@ -0,0 +1,30 @@
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,12650,e=>{"use strict";var t=e.i(7863),r=e.i(61507),a=e.i(51523);function i({onSelectPrompt:e,className:r=""}){return(0,t.jsxs)("div",{className:`chat-empty-state ${r}`,"data-testid":"preferences-starter",children:[(0,t.jsx)("div",{className:"siduri-orb",children:"✦"}),(0,t.jsx)("h2",{children:"Teach Siduri your preferences."}),(0,t.jsx)("p",{children:"Choose a starting point, replace the blanks, and send it. Nothing becomes memory until you approve the receipt."}),(0,t.jsxs)("div",{className:"starter-prompts onboarding-prompts",children:[(0,t.jsxs)("button",{type:"button",onClick:()=>e("Call me [preferred name]."),children:[(0,t.jsx)("span",{children:"Identity"}),"Preferred name or title"]}),(0,t.jsxs)("button",{type:"button",onClick:()=>e("My timezone is [timezone] and my preferred language is [language]."),children:[(0,t.jsx)("span",{children:"Localization"}),"Timezone and language"]}),(0,t.jsxs)("button",{type:"button",onClick:()=>e("My preferred response style is [concise / detailed / technical]."),children:[(0,t.jsx)("span",{children:"Response style"}),"Tone and verbosity"]}),(0,t.jsxs)("button",{type:"button",onClick:()=>e("I am interested in [topics or domains of interest]."),children:[(0,t.jsx)("span",{children:"Knowledge"}),"Topics of interest"]})]}),(0,t.jsx)("p",{className:"onboarding-privacy",children:"Teach Siduri preferences explicitly. Information is stored in private memory only after you approve the receipt."})]})}function s(e){return"number"!=typeof e||isNaN(e)||e<0?0:e>1?1:e}class n{expression="neutral";action="idle";state="idle";speechId;lipSyncValue=0;reducedMotion=!1;actionStartTime=0;stateStartTime=0;lastUpdateTime=Date.now();constructor(e){e&&this.updateConfig(e)}updateConfig(e){e.expression&&e.expression!==this.expression&&(this.expression=e.expression),e.action&&e.action!==this.action&&(this.action=e.action,this.actionStartTime=Date.now()),e.state&&e.state!==this.state&&(this.state=e.state,this.stateStartTime=Date.now()),void 0!==e.speechId&&(this.speechId=e.speechId),void 0!==e.lipSyncValue&&(this.lipSyncValue=s(e.lipSyncValue)),void 0!==e.reducedMotion&&(this.reducedMotion=e.reducedMotion)}setReducedMotion(e){this.reducedMotion=e}setExpression(e){this.expression=e}setAction(e){this.action=e,this.actionStartTime=Date.now()}setState(e){this.state=e,this.stateStartTime=Date.now()}setLipSync(e){this.lipSyncValue=s(e)}calculateFrameParameters(e=Date.now()){this.lastUpdateTime,this.lastUpdateTime=e;let t=this.reducedMotion?.2:(Math.sin(e/1800)+1)*.5,r=this.reducedMotion?0:2.5*Math.sin(e/2400),a=this.reducedMotion?0:1.8*Math.cos(e/3200),i=this.reducedMotion?0:1.2*Math.sin(e/4e3),n=function(e){if(!e)return{angleX:0,angleY:0,angleZ:0,bodyAngleX:0,eyeBallX:0,eyeBallY:0,speed:1};switch(e.toLowerCase().trim()){case"nod":return{angleX:0,angleY:-12,angleZ:2,bodyAngleX:0,eyeBallX:0,eyeBallY:-.2,speed:2.5};case"wave":return{angleX:8,angleY:4,angleZ:-5,bodyAngleX:5,eyeBallX:.2,eyeBallY:.1,speed:1.8};case"listen":return{angleX:-5,angleY:2,angleZ:4,bodyAngleX:-2,eyeBallX:.1,eyeBallY:.1,speed:1};case"talk":return{angleX:2,angleY:-2,angleZ:0,bodyAngleX:0,eyeBallX:0,eyeBallY:0,speed:1.5};default:return{angleX:0,angleY:0,angleZ:0,bodyAngleX:0,eyeBallX:0,eyeBallY:0,speed:1}}}(this.action),o=(e-this.actionStartTime)/1e3,l=0,c=0,d=0,u=0;this.reducedMotion?"nod"===this.action?c=.5*n.angleY:"wave"===this.action?(l=.5*n.angleX,u=.5*n.bodyAngleX):"listen"===this.action&&(d=.5*n.angleZ,l=.5*n.angleX):"nod"===this.action?c=Math.sin(o*Math.PI*3)*n.angleY:"wave"===this.action?(d=Math.sin(o*Math.PI*2.4)*n.angleZ,l=n.angleX,u=n.bodyAngleX):"listen"===this.action?(d=n.angleZ,l=n.angleX):"talk"===this.action&&(c=2*Math.sin(4*o));let m=0;if("speaking"===this.state){let t=function(e,t){if("number"==typeof t&&!isNaN(t)&&t>0)return s(t);let r=e/1e3;return s(Math.max(0,.45*Math.sin(14*r)+.25*Math.sin(22*r)+.2*Math.sin(8*r)+.1))}(e,this.lipSyncValue);m=this.reducedMotion?.6*t:t}let h=e%4e3/4e3,p=1;return h>.95&&(p=Math.abs(Math.sin((h-.95)/.05*Math.PI-Math.PI/2))),{mouthOpenY:m,angleX:r+l,angleY:a+c,angleZ:i+d,bodyAngleX:u,breath:t,eyeOpenL:p,eyeOpenR:p}}reset(){this.expression="neutral",this.action="idle",this.state="idle",this.lipSyncValue=0,this.speechId=void 0}}async function o(e="/live2d/live2dcubismcore.min.js"){return window.Live2DCubismCore?window.Live2DCubismCore:new Promise((t,r)=>{let a=document.querySelector(`script[src="${e}"]`);if(a)return window.Live2DCubismCore?t(window.Live2DCubismCore):(a.addEventListener("load",()=>t(window.Live2DCubismCore)),void a.addEventListener("error",t=>r(Error(`Failed to load Cubism Core from ${e}: ${t}`))));let i=document.createElement("script");i.src=e,i.async=!0,i.onload=()=>{window.Live2DCubismCore?t(window.Live2DCubismCore):r(Error("Live2DCubismCore global not found after script load"))},i.onerror=()=>{let e="https://cubism.live2d.com/sdk-web/cubismcore/live2dcubismcore.min.js";console.warn(`[Live2D] Failed to load local Cubism Core, attempting fallback: ${e}`);let a=document.createElement("script");a.src=e,a.async=!0,a.onload=()=>{window.Live2DCubismCore?t(window.Live2DCubismCore):r(Error("Live2DCubismCore global not found after fallback load"))},a.onerror=e=>r(Error(`Failed to load Cubism Core from both local and remote sources: ${e}`)),document.head.appendChild(a)},document.head.appendChild(i)})}async function l(e){let t=e.lastIndexOf("/"),r=-1!==t?e.slice(0,t+1):"",a=await fetch(e);if(!a.ok)throw Error(`Failed to fetch model manifest from ${e} (${a.status})`);let i=await a.json();if(!i.FileReferences||!i.FileReferences.Moc)throw Error(`Invalid model3.json: missing Moc file reference in ${e}`);let s=r+i.FileReferences.Moc,n=await fetch(s);if(!n.ok)throw Error(`Failed to fetch .moc3 file from ${s} (${n.status})`);let o=await n.arrayBuffer(),l=(i.FileReferences.Textures||[]).map(e=>r+e),c=await Promise.all(l.map(e=>new Promise((t,r)=>{let a=new Image;a.crossOrigin="anonymous",a.onload=()=>t(a),a.onerror=t=>r(Error(`Failed to load texture from ${e}`)),a.src=e}))),d=new Map;return i.FileReferences.Expressions&&i.FileReferences.Expressions.length>0&&await Promise.all(i.FileReferences.Expressions.map(async e=>{try{let t=r+e.File,a=await fetch(t);if(a.ok){let t=await a.json();d.set(e.File,t),e.Name&&d.set(e.Name,t)}}catch{}})),{model3:i,mocBuffer:o,textures:c,expressions:d,basePath:r}}let c=`
2
+ attribute vec2 a_position;
3
+ attribute vec2 a_texCoord;
4
+ uniform mat4 u_matrix;
5
+ varying vec2 v_texCoord;
6
+ void main() {
7
+ gl_Position = u_matrix * vec4(a_position.x, a_position.y, 0.0, 1.0);
8
+ v_texCoord = vec2(a_texCoord.x, 1.0 - a_texCoord.y);
9
+ }
10
+ `,d=`
11
+ precision mediump float;
12
+ uniform sampler2D u_texture;
13
+ uniform float u_opacity;
14
+ varying vec2 v_texCoord;
15
+ void main() {
16
+ vec4 color = texture2D(u_texture, v_texCoord);
17
+ gl_FragColor = color * u_opacity;
18
+ }
19
+ `,u=`
20
+ precision mediump float;
21
+ uniform sampler2D u_texture;
22
+ varying vec2 v_texCoord;
23
+ void main() {
24
+ vec4 color = texture2D(u_texture, v_texCoord);
25
+ if (color.a < 0.1) {
26
+ discard;
27
+ }
28
+ gl_FragColor = vec4(1.0);
29
+ }
30
+ `;function m(e,t,r){let a=e.createShader(t);if(!a)throw Error("Failed to create shader");if(e.shaderSource(a,r),e.compileShader(a),!e.getShaderParameter(a,e.COMPILE_STATUS)){let t=e.getShaderInfoLog(a);throw e.deleteShader(a),Error(`Shader compilation error: ${t}`)}return a}class h{canvas;gl=null;program=null;maskProgram=null;vertexBuffer=null;uvBuffer=null;indexBuffer=null;aPositionLocation=-1;aTexCoordLocation=-1;uMatrixLocation=null;uTextureLocation=null;uOpacityLocation=null;maskAPositionLocation=-1;maskATexCoordLocation=-1;maskUMatrixLocation=null;maskUTextureLocation=null;textures=[];moc=null;model=null;core=null;paramIndices=new Map;isDisposed=!1;constructor(e){this.canvas=e}modelBounds={minX:-.39,maxX:.4,minY:-.98,maxY:.18,width:.79,height:1.16,centerX:.006,centerY:-.4};initialize(e,t){this.core=e;let r={alpha:!0,premultipliedAlpha:!0,preserveDrawingBuffer:!1,antialias:!0,stencil:!0},a=this.canvas.getContext("webgl",r)||this.canvas.getContext("experimental-webgl",r)||this.canvas.getContext("webgl2",r);if(!a)throw Error("WebGL is not supported in this browser environment");this.gl=a;let i=m(a,a.VERTEX_SHADER,c),s=m(a,a.FRAGMENT_SHADER,d),n=a.createProgram();if(!n)throw Error("Failed to create WebGL program");if(a.attachShader(n,i),a.attachShader(n,s),a.linkProgram(n),!a.getProgramParameter(n,a.LINK_STATUS))throw Error(`Program link error: ${a.getProgramInfoLog(n)}`);this.program=n,this.aPositionLocation=a.getAttribLocation(n,"a_position"),this.aTexCoordLocation=a.getAttribLocation(n,"a_texCoord"),this.uMatrixLocation=a.getUniformLocation(n,"u_matrix"),this.uTextureLocation=a.getUniformLocation(n,"u_texture"),this.uOpacityLocation=a.getUniformLocation(n,"u_opacity");let o=m(a,a.FRAGMENT_SHADER,u),l=a.createProgram();if(!l)throw Error("Failed to create Mask WebGL program");if(a.attachShader(l,i),a.attachShader(l,o),a.linkProgram(l),!a.getProgramParameter(l,a.LINK_STATUS))throw Error(`Mask Program link error: ${a.getProgramInfoLog(l)}`);if(this.maskProgram=l,this.maskAPositionLocation=a.getAttribLocation(l,"a_position"),this.maskATexCoordLocation=a.getAttribLocation(l,"a_texCoord"),this.maskUMatrixLocation=a.getUniformLocation(l,"u_matrix"),this.maskUTextureLocation=a.getUniformLocation(l,"u_texture"),this.vertexBuffer=a.createBuffer(),this.uvBuffer=a.createBuffer(),this.indexBuffer=a.createBuffer(),a.pixelStorei(a.UNPACK_PREMULTIPLY_ALPHA_WEBGL,1),this.textures=t.textures.map(e=>{let t=a.createTexture();if(!t)throw Error("Failed to create WebGL texture");return a.bindTexture(a.TEXTURE_2D,t),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.LINEAR_MIPMAP_NEAREST),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.LINEAR),a.texImage2D(a.TEXTURE_2D,0,a.RGBA,a.RGBA,a.UNSIGNED_BYTE,e),a.generateMipmap(a.TEXTURE_2D),t}),this.moc=e.Moc.fromArrayBuffer(t.mocBuffer),!this.moc)throw Error("Failed to create Live2D Moc from ArrayBuffer");if(this.model=e.Model.fromMoc(this.moc),!this.model)throw Error("Failed to create Live2D Model from Moc");let h=this.model.parameters.ids;for(let e=0;e<h.length;e++)this.paramIndices.set(h[e],e);this.initializeNeutralMouth(),this.model.update(),this.calculateModelBounds()}initializeNeutralMouth(){this.model&&(this.setParamDirect("ParamMouthOpenY",0),this.setParamDirect("ParamMouthForm",0))}setParamDirect(e,t){let r=this.paramIndices.get(e);if(void 0!==r&&this.model){let e=this.model.parameters.minimumValues[r],a=this.model.parameters.maximumValues[r];this.model.parameters.values[r]=Math.max(e,Math.min(a,t))}}calculateModelBounds(){if(!this.model)return;let e=this.model.drawables,t=e.count,r=1/0,a=-1/0,i=1/0,s=-1/0;for(let n=0;n<t;n++){let t=e.vertexPositions[n];if(t&&0!==t.length)for(let e=0;e<t.length;e+=2){let n=t[e],o=t[e+1];n<r&&(r=n),n>a&&(a=n),o<i&&(i=o),o>s&&(s=o)}}r!==1/0&&a!==-1/0&&i!==1/0&&s!==-1/0&&(this.modelBounds={minX:r,maxX:a,minY:i,maxY:s,width:a-r,height:s-i,centerX:(r+a)/2,centerY:(i+s)/2})}getModelBounds(){return{...this.modelBounds}}setParam(e,t,r=1){let a=this.paramIndices.get(e);if(void 0!==a&&this.model){let e=this.model.parameters.values[a],i=Math.max(this.model.parameters.minimumValues[a],Math.min(this.model.parameters.maximumValues[a],t));this.model.parameters.values[a]=e+(i-e)*r}}render(e,t=Date.now()){let r;if(this.isDisposed||!this.gl||!this.model||!this.program)return;let a=this.gl,i=this.canvas.width,s=this.canvas.height;if(0===i||0===s)return;let n=e.calculateFrameParameters(t);this.setParam("ParamAngleX",n.angleX,.2),this.setParam("ParamAngleY",n.angleY,.2),this.setParam("ParamAngleZ",n.angleZ,.2),this.setParam("ParamBodyAngleX",n.bodyAngleX,.15),this.setParam("ParamBreath",n.breath,.3),this.setParam("ParamEyeLOpen",n.eyeOpenL,.4),this.setParam("ParamEyeROpen",n.eyeOpenR,.4),this.setParam("ParamMouthOpenY",n.mouthOpenY,.35);let o=function(e){if(!e)return"neutral";switch(e.toLowerCase().trim()){case"surprised":return"face_aozame.exp3.json";case"concerned":case"thinking":return"eyes_zetubou.exp3.json";case"happy":return"hair_open.exp3.json";default:return"neutral"}}(e.expression);"face_aozame.exp3.json"===o?(this.setParam("Param10",1,.2),this.setParam("Param9",0,.15),this.setParam("Param11",0,.15),this.setParam("Param12",0,.15)):"eyes_zetubou.exp3.json"===o?(this.setParam("Param9",1,.2),this.setParam("Param10",0,.15),this.setParam("Param11",0,.15),this.setParam("Param12",0,.15)):"hair_open.exp3.json"===o?(this.setParam("Param11",1,.2),this.setParam("Param10",0,.15),this.setParam("Param9",0,.15),this.setParam("Param12",0,.15)):"eye_color.exp3.json"===o?(this.setParam("Param12",1,.2),this.setParam("Param10",0,.15),this.setParam("Param9",0,.15),this.setParam("Param11",0,.15)):(this.setParam("Param10",0,.15),this.setParam("Param9",0,.15),this.setParam("Param11",0,.15),this.setParam("Param12",0,.15)),this.model.update(),a.viewport(0,0,i,s),a.clearColor(0,0,0,0),a.clear(a.COLOR_BUFFER_BIT|a.STENCIL_BUFFER_BIT),a.enable(a.BLEND),a.blendFunc(a.ONE,a.ONE_MINUS_SRC_ALPHA),a.useProgram(this.program);let l=i/s,c=this.modelBounds.width,d=this.modelBounds.height,u=this.modelBounds.centerX,m=this.modelBounds.centerY,h=(r=l>=c/d?1.84/d:1.84/c*l)/l,p=new Float32Array([h,0,0,0,0,r,0,0,0,0,1,0,-u*h,-m*r,0,1]);a.uniformMatrix4fv(this.uMatrixLocation,!1,p),a.uniform1i(this.uTextureLocation,0);let f=this.model.drawables,x=f.count,g=f.renderOrders,v=[];for(let e=0;e<x;e++)v.push(e);v.sort((e,t)=>g[e]-g[t]),a.enableVertexAttribArray(this.aPositionLocation),a.enableVertexAttribArray(this.aTexCoordLocation);let b=(e,t)=>{let r=void 0!==t?t:f.opacities[e];if(r<=.001)return;let i=f.textureIndices[e],s=this.textures[i];if(!s)return;a.activeTexture(a.TEXTURE0),a.bindTexture(a.TEXTURE_2D,s),a.uniform1f(this.uOpacityLocation,r);let n=f.vertexPositions[e];a.bindBuffer(a.ARRAY_BUFFER,this.vertexBuffer),a.bufferData(a.ARRAY_BUFFER,n,a.DYNAMIC_DRAW),a.vertexAttribPointer(this.aPositionLocation,2,a.FLOAT,!1,0,0);let o=f.vertexUvs[e];a.bindBuffer(a.ARRAY_BUFFER,this.uvBuffer),a.bufferData(a.ARRAY_BUFFER,o,a.DYNAMIC_DRAW),a.vertexAttribPointer(this.aTexCoordLocation,2,a.FLOAT,!1,0,0);let l=f.indices[e];a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,this.indexBuffer),a.bufferData(a.ELEMENT_ARRAY_BUFFER,l,a.DYNAMIC_DRAW),a.drawElements(a.TRIANGLES,l.length,a.UNSIGNED_SHORT,0)},y=e=>{if(!this.maskProgram)return;a.useProgram(this.maskProgram),a.uniformMatrix4fv(this.maskUMatrixLocation,!1,p),a.uniform1i(this.maskUTextureLocation,0),a.enableVertexAttribArray(this.maskAPositionLocation),a.enableVertexAttribArray(this.maskATexCoordLocation);let t=f.textureIndices[e],r=this.textures[t];if(!r)return;a.activeTexture(a.TEXTURE0),a.bindTexture(a.TEXTURE_2D,r);let i=f.vertexPositions[e];a.bindBuffer(a.ARRAY_BUFFER,this.vertexBuffer),a.bufferData(a.ARRAY_BUFFER,i,a.DYNAMIC_DRAW),a.vertexAttribPointer(this.maskAPositionLocation,2,a.FLOAT,!1,0,0);let s=f.vertexUvs[e];a.bindBuffer(a.ARRAY_BUFFER,this.uvBuffer),a.bufferData(a.ARRAY_BUFFER,s,a.DYNAMIC_DRAW),a.vertexAttribPointer(this.maskATexCoordLocation,2,a.FLOAT,!1,0,0);let n=f.indices[e];a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,this.indexBuffer),a.bufferData(a.ELEMENT_ARRAY_BUFFER,n,a.DYNAMIC_DRAW),a.drawElements(a.TRIANGLES,n.length,a.UNSIGNED_SHORT,0),a.useProgram(this.program),a.enableVertexAttribArray(this.aPositionLocation),a.enableVertexAttribArray(this.aTexCoordLocation)},w=-1;for(let e of v)if(!(f.opacities[e]<=.001))if(f.maskCounts[e]>0){let t=f.masks[e][0];t!==w&&(w=t,a.enable(a.STENCIL_TEST),a.stencilMask(255),a.clear(a.STENCIL_BUFFER_BIT),a.stencilFunc(a.ALWAYS,1,255),a.stencilOp(a.KEEP,a.KEEP,a.REPLACE),a.colorMask(!1,!1,!1,!1),y(t),a.colorMask(!0,!0,!0,!0)),a.stencilFunc(a.EQUAL,1,255),a.stencilOp(a.KEEP,a.KEEP,a.KEEP),b(e)}else -1!==w&&(a.disable(a.STENCIL_TEST),w=-1),b(e);-1!==w&&a.disable(a.STENCIL_TEST)}dispose(){if(this.isDisposed=!0,this.gl){for(let e of this.textures)this.gl.deleteTexture(e);this.textures=[],this.vertexBuffer&&this.gl.deleteBuffer(this.vertexBuffer),this.uvBuffer&&this.gl.deleteBuffer(this.uvBuffer),this.indexBuffer&&this.gl.deleteBuffer(this.indexBuffer),this.program&&this.gl.deleteProgram(this.program)}this.model&&"function"==typeof this.model.release&&this.model.release(),this.moc&&"function"==typeof this.moc.release&&this.moc.release(),this.model=null,this.moc=null,this.gl=null}}function p({modelUrl:e,expression:a="neutral",action:i="idle",state:s="idle",speechId:c,lipSyncValue:d,durationMs:u,className:m="",onStatusChange:f}){let x=(0,r.useRef)(null),g=(0,r.useRef)(null),v=(0,r.useRef)(new n({expression:a,action:i,state:s,speechId:c,lipSyncValue:d,durationMs:u})),b=(0,r.useRef)(null),y=(0,r.useRef)(null),[w,E]=(0,r.useState)("loading"),[P,A]=(0,r.useState)(null),[_,j]=(0,r.useState)(0);return(0,r.useEffect)(()=>{if(!window.matchMedia)return;let e=window.matchMedia("(prefers-reduced-motion: reduce)"),t=()=>{v.current.setReducedMotion(e.matches)};return t(),e.addEventListener("change",t),()=>e.removeEventListener("change",t)},[]),(0,r.useEffect)(()=>{v.current.updateConfig({expression:a,action:i,state:s,speechId:c,lipSyncValue:d,durationMs:u})},[a,i,s,c,d,u]),(0,r.useEffect)(()=>{let t=!1,r=null;async function a(){if(g.current&&x.current){if(!e){E("error"),A("No Live2D model configured. Place model in assets/body/<name>/"),f?.("error","No Live2D model URL specified");return}E("loading"),f?.("loading"),A(null);try{let a=await o();if(t)return;let i=await l(e);if(t)return;let s=g.current;if(!s)return;let n=new h(s);n.initialize(a,i),b.current=n;let c=()=>{if(!x.current||!g.current)return;let e=x.current.getBoundingClientRect();if(e.width<=0||e.height<=0)return;let t=Math.min(window.devicePixelRatio||1,2),r=Math.max(1,Math.floor(e.width*t)),a=Math.max(1,Math.floor(e.height*t));(g.current.width!==r||g.current.height!==a)&&(g.current.width=r,g.current.height=a)};c(),(r=new ResizeObserver(c)).observe(x.current);let d=()=>{t||(b.current&&b.current.render(v.current,performance.now()),y.current=requestAnimationFrame(d))};y.current=requestAnimationFrame(d),E("ready"),f?.("ready")}catch(r){if(t)return;let e=r?.message||"Failed to initialize Live2D avatar";console.warn("[AvatarCanvas] Initialization error:",r),E("error"),A("Avatar model unavailable or failed to load."),f?.("error",e)}}}a();let i=g.current,s=e=>{e.preventDefault(),console.warn("[AvatarCanvas] WebGL context lost"),y.current&&cancelAnimationFrame(y.current),E("error"),A("WebGL context lost.")},n=()=>{console.log("[AvatarCanvas] WebGL context restored, re-initializing..."),a()};return i&&(i.addEventListener("webglcontextlost",s,!1),i.addEventListener("webglcontextrestored",n,!1)),()=>{t=!0,y.current&&(cancelAnimationFrame(y.current),y.current=null),r&&r.disconnect(),i&&(i.removeEventListener("webglcontextlost",s),i.removeEventListener("webglcontextrestored",n)),b.current&&(b.current.dispose(),b.current=null)}},[e,_,f]),(0,t.jsxs)("div",{ref:x,"data-testid":"avatar-canvas-container",className:`relative w-full h-full min-h-0 flex items-center justify-center overflow-hidden bg-transparent ${m}`,"aria-label":"Live2D Companion Presence",children:[(0,t.jsx)("canvas",{ref:g,role:"img","data-testid":"avatar-webgl-canvas","aria-label":"Live2D companion presence",style:{width:"100%",height:"100%",display:"block"},className:`absolute inset-0 w-full h-full block transition-opacity duration-500 ${"ready"===w?"opacity-100":"opacity-0"}`}),"loading"===w&&(0,t.jsxs)("div",{role:"status","aria-live":"polite",className:"absolute inset-0 flex flex-col items-center justify-center gap-3 bg-[#0b0b0e]/90 text-[var(--siduri-text-muted)]",children:[(0,t.jsx)("div",{className:"siduri-glyph w-10 h-10 text-base animate-pulse motion-reduce:animate-none",children:"✦"}),(0,t.jsx)("span",{className:"text-[11px] font-mono tracking-widest uppercase text-[var(--siduri-ember-light)]",children:"Initializing Presence..."})]}),"error"===w&&(0,t.jsxs)("div",{role:"alert","aria-live":"polite",className:"absolute inset-0 flex flex-col items-center justify-center p-6 text-center bg-[#0b0b0e]/95 text-[var(--siduri-text-muted)]",children:[(0,t.jsx)("div",{className:"w-8 h-8 rounded-full border border-[var(--siduri-border-subtle)] grid place-items-center text-xs text-[var(--siduri-text-dim)] mb-2 font-mono",children:"!"}),(0,t.jsx)("p",{className:"text-xs font-sans text-[var(--siduri-text-secondary)] mb-1",children:P||"Avatar unavailable in this browser."}),(0,t.jsx)("span",{className:"text-[10px] font-mono text-[var(--siduri-text-dim)] mb-3",children:"Conversational text mode remains active"}),(0,t.jsx)("button",{type:"button",onClick:()=>j(e=>e+1),className:"px-3 py-1 text-[11px] font-mono tracking-wider uppercase rounded border border-[var(--siduri-border-subtle)] hover:border-[var(--siduri-border-ember)] text-[var(--siduri-text-secondary)] hover:text-[var(--siduri-text-primary)] transition-colors focus-visible:ring-1 focus-visible:ring-[var(--siduri-border-ember)] outline-none","aria-label":"Retry avatar initialization",children:"Retry"})]})]})}var f=e.i(94108);let x="siduri.chat.conversations.v1";function g(){return"u">typeof crypto&&"randomUUID"in crypto?crypto.randomUUID():`${Date.now()}-${Math.random()}`}function v(e){return new Intl.DateTimeFormat(void 0,{hour:"numeric",minute:"2-digit"}).format(e)}e.s(["default",0,function(){let[e,s]=(0,r.useState)([]),[n,o]=(0,r.useState)(null),[l,c]=(0,r.useState)(""),[d,u]=(0,r.useState)("connecting"),[m,h]=(0,r.useState)(!1),[b,y]=(0,r.useState)(!1),[w,E]=(0,r.useState)(!1),[P,A]=(0,r.useState)(!1),[_,j]=(0,r.useState)(null),[T,L]=(0,r.useState)(void 0),C=(0,r.useRef)(null),R=(0,r.useRef)(null),N=(0,r.useRef)(null),S=(0,r.useMemo)(()=>e.find(e=>e.id===n)??null,[n,e]);function M(){return{id:g(),title:"New conversation",messages:[],updatedAt:Date.now()}}function D(e,t){s(r=>r.map(r=>r.id===e?t(r):r))}async function k(e){e.preventDefault();let t=l.trim();if(!t)return;if(/\[[^\]]+\]/.test(t))return void u("replace the blanks first");m&&N.current&&(N.current.abort("user_barge_in"),N.current=null,(0,f.interruptChat)("default","user_barge_in"));let r=S;r||(r=M(),s(e=>[r,...e]),o(r.id));let a={id:g(),role:"user",content:t,createdAt:Date.now()},i=g(),n={id:i,role:"assistant",content:"",createdAt:Date.now()},d=[...r.messages,a,n],p=0===r.messages.length?t.slice(0,42):r.title;D(r.id,e=>({...e,title:p,messages:d,updatedAt:Date.now()})),c(""),h(!0),u("streaming");let x=new AbortController;N.current=x;try{await (0,f.postStream)("/chat/stream",{id:"default",message:t,medium:"web",history:r.messages.slice(-20).map(e=>({role:e.role,content:e.content}))},{onAvatar:e=>{let t=e.speech_id;R.current&&clearTimeout(R.current),j({eventId:e.event_id,expression:e.expression||"neutral",action:e.action||"talk",state:"speaking",speechId:t,durationMs:e.durationMs});let r=e.durationMs||4500;R.current=setTimeout(()=>{j(e=>e?{...e,state:"idle",action:"idle"}:null)},r)},onChunk:e=>{e.deltaText&&D(r.id,t=>({...t,messages:t.messages.map(t=>t.id===i?{...t,content:t.content+e.deltaText}:t)})),(e.expression||e.action)&&j(t=>t?{...t,expression:e.expression||t.expression,action:e.action||t.action}:null)},onDone:e=>{let t=e.response||{},a=e.metadata?.memory_proposals,s=e.metadata?.behavioral_proposals;D(r.id,e=>({...e,messages:e.messages.map(e=>e.id===i?{...e,content:e.content||t.subtitle_en||"",spokenJa:t.spoken_ja,evidenceIds:t.evidence_ids,memoryProposals:a,behavioralProposals:s}:e),updatedAt:Date.now()})),u("online")},onInterrupted:()=>{D(r.id,e=>({...e,messages:e.messages.map(e=>e.id===i?{...e,content:e.content?`${e.content} [interrupted]`:"[interrupted]"}:e),updatedAt:Date.now()})),u("online")},onError:e=>{D(r.id,t=>({...t,messages:t.messages.map(t=>t.id===i?{...t,content:`I couldn’t reach the orchestrator. ${String(e)}`}:t),updatedAt:Date.now()})),u("offline")}},x.signal)}catch(e){x.signal.aborted||(D(r.id,t=>({...t,messages:t.messages.map(t=>t.id===i?{...t,content:`I couldn’t reach the orchestrator. ${String(e)}`}:t),updatedAt:Date.now()})),u("offline"))}finally{N.current=null,h(!1)}}(0,r.useEffect)(()=>()=>{R.current&&clearTimeout(R.current),N.current&&N.current.abort("unmounted")},[]),(0,r.useEffect)(()=>{let e=function(){try{let e=JSON.parse(window.localStorage.getItem(x)??"[]");return Array.isArray(e)?e:[]}catch{return[]}}();s(e),o(e[0]?.id??null),y(!0),(0,f.fetchApi)("/health").then(async e=>{if(e.ok){let t=await e.json().catch(()=>({}));u("online"),t.organs?.body?.modelUrl?L(t.organs.body.modelUrl):(0,f.fetchApi)("/api/models/body").then(async e=>{if(e.ok){let t=(await e.json().catch(()=>({}))).models||[],r=t.find(e=>"default"!==e);r?L(`/assets/body/${r}/model.model3.json`):t.length>0&&"default"!==t[0]&&L(`/assets/body/${t[0]}/model.model3.json`)}}).catch(()=>{})}else u("online")}).catch(()=>u("offline"))},[]),(0,r.useEffect)(()=>{b&&window.localStorage.setItem(x,JSON.stringify(e))},[e,b]),(0,r.useEffect)(()=>{C.current?.scrollTo({top:C.current.scrollHeight,behavior:"smooth"})},[n,S?.messages.length,m]);let B=S?.messages??[],I=B.at(-1)?.evidenceIds?.length??0;async function U(e,t,r){if(S)try{await (0,f.postJson)(`/memory/proposals/${r}`,{id:t,companionId:"default"});let a="approve"===r?"approved":"rejected";D(S.id,r=>({...r,messages:r.messages.map(r=>r.id===e&&r.memoryProposals?{...r,memoryProposals:r.memoryProposals.map(e=>e.proposal_id===t?{...e,status:a}:e)}:r)}))}catch(e){console.error(e)}}async function F(e,t,r){if(S)try{await (0,f.postJson)(`/memory/behavioral/${r}`,{id:t,companionId:"default"});let a="approve"===r?"confirmed":"rejected";D(S.id,r=>({...r,messages:r.messages.map(r=>r.id===e&&r.behavioralProposals?{...r,behavioralProposals:r.behavioralProposals.map(e=>e.directive_id===t?{...e,status:a}:e)}:r)}))}catch(e){console.error(e)}}return(0,t.jsxs)("div",{className:`chat-app ${w?"sidebar-collapsed":""}`,children:[(0,t.jsxs)("aside",{className:"chat-sidebar","aria-label":"Conversation history",children:[(0,t.jsxs)("div",{className:"chat-sidebar-top",children:[(0,t.jsxs)("a",{className:"chat-brand",href:"/chat",children:[(0,t.jsx)("span",{className:"chat-brand-mark",children:"S"}),(0,t.jsx)("span",{children:"SIDURI"})]}),(0,t.jsx)("button",{className:"sidebar-collapse",type:"button",onClick:()=>E(e=>!e),"aria-label":w?"Expand sidebar":"Collapse sidebar",children:w?"→":"←"})]}),(0,t.jsxs)("button",{className:"new-chat-button",type:"button",onClick:function(){let e=M();s(t=>[e,...t]),o(e.id),c(""),u("online")},children:[(0,t.jsx)("span",{children:"+"})," New conversation"]}),(0,t.jsxs)("div",{className:"history-heading",children:[(0,t.jsx)("span",{children:"Recent conversations"}),(0,t.jsx)("span",{children:e.length})]}),(0,t.jsx)("div",{className:"conversation-list",children:b?0===e.length?(0,t.jsx)("p",{className:"history-empty",children:"Your private conversations will appear here."}):e.slice().sort((e,t)=>t.updatedAt-e.updatedAt).map(r=>(0,t.jsxs)("div",{className:`conversation-row ${r.id===n?"selected":""}`,children:[(0,t.jsxs)("button",{type:"button",className:"conversation-select",onClick:()=>o(r.id),children:[(0,t.jsx)("span",{className:"conversation-title",children:r.title}),(0,t.jsx)("span",{className:"conversation-date",children:v(r.updatedAt)})]}),(0,t.jsx)("button",{type:"button",className:"conversation-delete",onClick:()=>(function(t){if(s(e=>e.filter(e=>e.id!==t)),n===t){let r=e.find(e=>e.id!==t);o(r?.id??null)}})(r.id),"aria-label":`Delete ${r.title}`,children:"×"})]},r.id)):(0,t.jsx)("p",{className:"history-empty",children:"Loading history…"})}),(0,t.jsx)("div",{className:"sidebar-footer",children:(0,t.jsxs)("a",{className:"sidebar-console",href:"/operator",children:[(0,t.jsx)("span",{children:"⌘"}),(0,t.jsx)("span",{children:"Operator console"}),(0,t.jsx)("b",{children:"↗"})]})})]}),(0,t.jsxs)("main",{className:"chat-workspace",children:[(0,t.jsxs)("div",{className:"chat-top-status flex items-center gap-2.5",children:[(0,t.jsxs)("button",{type:"button",onClick:()=>A(e=>!e),className:`connection-pill cursor-pointer transition-all focus-visible:ring-1 focus-visible:ring-[var(--siduri-border-ember)] outline-none ${P?"border-[var(--siduri-border-ember)] bg-[var(--siduri-tint-med)] text-[var(--siduri-ember-highlight)]":"hover:border-[var(--siduri-border-ember)] text-[var(--siduri-text-secondary)]"}`,"aria-label":"Toggle avatar presence","aria-expanded":P,title:P?"Disable Avatar Presence":"Enable Avatar Presence",children:[(0,t.jsx)("span",{className:`status-light ${P?"online":""}`}),(0,t.jsx)("span",{children:"Presence"})]}),(0,t.jsxs)("span",{className:"connection-pill",children:[(0,t.jsx)("span",{className:`status-light ${"online"===d?"online":""}`}),d]})]}),(0,t.jsx)("div",{className:"flex flex-col flex-1 min-h-0 w-full overflow-hidden relative",children:(0,t.jsxs)("section",{className:"conversation-surface","aria-label":"Private chat",children:[(0,t.jsxs)("div",{ref:C,className:`conversation-scroll ${P?"presence-active":""}`,"aria-live":"polite",children:[P?(0,t.jsx)("div",{className:"avatar-presence-area","data-testid":"avatar-presence-area",children:(0,t.jsx)(p,{modelUrl:T,expression:_?.expression||"neutral",action:_?.action||"idle",state:_?.state||"idle",speechId:_?.speechId,lipSyncValue:_?.lipSyncValue,durationMs:_?.durationMs,className:"w-full h-full"})}):0===B.length?(0,t.jsx)(i,{onSelectPrompt:e=>c(e)}):B.map(e=>(0,t.jsxs)("article",{className:`platform-message ${e.role}`,children:[(0,t.jsx)("div",{className:"message-avatar",children:"user"===e.role?"U":"S"}),(0,t.jsxs)("div",{className:"message-body",children:[(0,t.jsxs)("div",{className:"message-meta",children:[(0,t.jsx)("span",{children:"user"===e.role?"You":"Siduri"}),(0,t.jsx)("time",{children:v(e.createdAt)})]}),(0,t.jsx)("p",{className:"message-primary",children:"assistant"===e.role?e.spokenJa??e.content:e.content}),"assistant"===e.role&&e.spokenJa&&(0,t.jsx)("p",{className:"message-translation",children:e.content}),e.evidenceIds&&e.evidenceIds.length>0&&(0,t.jsxs)("span",{className:"evidence-chip",children:[e.evidenceIds.length," evidence link",1===e.evidenceIds.length?"":"s"]}),e.memoryProposals&&e.memoryProposals.length>0&&(0,t.jsx)("div",{className:"memory-receipts",children:e.memoryProposals.map(r=>(0,t.jsxs)("div",{className:`memory-receipt status-${r.status}`,children:[(0,t.jsxs)("strong",{children:["Remember",r.claim_type?` (${r.claim_type})`:"",":"]})," ",(0,a.formatClaimReceipt)(r),(0,t.jsx)("div",{className:"receipt-actions",children:"pending"===r.status?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("button",{type:"button",onClick:()=>U(e.id,r.proposal_id,"approve"),children:"Approve"}),(0,t.jsx)("button",{type:"button",onClick:()=>U(e.id,r.proposal_id,"reject"),children:"Reject"})]}):(0,t.jsx)("span",{children:r.status.toUpperCase()})})]},r.proposal_id))}),e.behavioralProposals&&e.behavioralProposals.length>0&&(0,t.jsx)("div",{className:"memory-receipts",children:e.behavioralProposals.map(r=>(0,t.jsxs)("div",{className:`memory-receipt status-${r.status}`,children:[(0,t.jsxs)("strong",{children:["Runtime effect [",r.knowledge_domain??r.domain," ","→ ",r.runtime_effect??r.memory_class,"]:"]})," ",(0,a.formatRuntimeEffect)(r),(0,t.jsx)("div",{className:"receipt-actions",children:"pending"===r.status?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("button",{type:"button",onClick:()=>F(e.id,r.directive_id,"approve"),children:"Approve"}),(0,t.jsx)("button",{type:"button",onClick:()=>F(e.id,r.directive_id,"reject"),children:"Reject"})]}):(0,t.jsx)("span",{children:r.status.toUpperCase()})})]},r.directive_id))})]})]},e.id)),m&&!P&&(0,t.jsxs)("div",{className:"platform-message assistant thinking-message",children:[(0,t.jsx)("div",{className:"message-avatar",children:"S"}),(0,t.jsxs)("div",{className:"message-body",children:[(0,t.jsxs)("div",{className:"message-meta",children:[(0,t.jsx)("span",{children:"Siduri"}),(0,t.jsx)("span",{className:"thinking-label",children:"thinking"})]}),(0,t.jsxs)("div",{className:"thinking-dots",children:[(0,t.jsx)("i",{}),(0,t.jsx)("i",{}),(0,t.jsx)("i",{})]})]})]})]}),(0,t.jsxs)("form",{className:"platform-composer",onSubmit:k,children:[(0,t.jsx)("textarea",{value:l,onChange:e=>c(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),e.currentTarget.form?.requestSubmit())},placeholder:"Message Siduri…",rows:1,maxLength:4e3,"aria-label":"Message Siduri"}),(0,t.jsxs)("div",{className:"composer-bottom",children:[(0,t.jsxs)("span",{children:["Private local session ·"," ",I?`${I} evidence link${1===I?"":"s"}`:"No evidence attached"]}),m&&!l.trim()?(0,t.jsx)("button",{type:"button",onClick:function(){N.current&&(N.current.abort("user_stop"),N.current=null),(0,f.interruptChat)("default","user_stop"),h(!1),u("online")},"aria-label":"Stop generation",title:"Stop generation",children:"■"}):(0,t.jsx)("button",{type:"submit",disabled:!l.trim(),"aria-label":"Send message",children:"↑"})]})]})]})}),(0,t.jsx)("p",{className:"chat-disclaimer",children:"Siduri can be uncertain. Verify important details against the evidence."})]})]})}],12650)},94108,e=>{"use strict";var t=e.i(72619);let r=t.default.env.NEXT_PUBLIC_API_URL||"";async function a(e,t){return fetch(`${r}${e}`,t)}async function i(e,t){let r=await a(e,t);if(!r.ok)throw Error(`${e} returned ${r.status}`);return r.json()}async function s(e,t){let r=await a(e,{method:"POST",headers:t?{"Content-Type":"application/json"}:void 0,body:t?"string"==typeof t?t:JSON.stringify(t):void 0});if(!r.ok)throw Error(await r.text().catch(()=>r.statusText));return r.json().catch(()=>({}))}async function n(e,t){let r=await a(e,{method:"POST",headers:t?{"Content-Type":"application/json"}:void 0,body:t?"string"==typeof t?t:JSON.stringify(t):void 0});if(!r.ok)throw Error(await r.text().catch(()=>r.statusText))}async function o(e,t,r,i){let s=await a(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),signal:i});if(!s.ok)throw Error(await s.text().catch(()=>s.statusText)||`HTTP ${s.status}`);if(!s.body)throw Error("ReadableStream not supported in response");let n=s.body.getReader(),o=new TextDecoder,l="";try{for(;;){let{done:e,value:t}=await n.read();if(e)break;let a=(l+=o.decode(t,{stream:!0})).split("\n");l=a.pop()||"";let i="message";for(let e of a){let t=e.trim();if(t){if(t.startsWith("event:"))i=t.slice(6).trim();else if(t.startsWith("data:")){let e=t.slice(5).trim();try{let t=JSON.parse(e);switch(i){case"staged":r.onStaged?.(t);break;case"chunk":r.onChunk?.(t);break;case"avatar":r.onAvatar?.(t);break;case"done":r.onDone?.(t);break;case"interrupted":r.onInterrupted?.(t);break;case"error":r.onError?.(Error(t.error||"Stream error"))}}catch{}}}}}}catch(e){if(i?.aborted)r.onInterrupted?.({reason:i.reason});else throw r.onError?.(e),e}finally{n.releaseLock()}}async function l(e="default",t="user_barge_in"){await s("/chat/interrupt",{companionId:e,reason:t}).catch(()=>{})}t.default.env.NEXT_PUBLIC_WS_URL||(window.location.protocol,window.location.host),e.s(["fetchApi",0,a,"getJson",0,i,"interruptChat",0,l,"postAction",0,n,"postJson",0,s,"postStream",0,o])},51523,e=>{"use strict";let t=new Set(["siduri","self","companion"]),r=new Set(["user","actor","owner","primary_user"]);function a(e){return e.replace(/[._]+/g," ").replace(/\s+/g," ").trim()}function i(e){let t=e.trim();return t&&!/[.!?]$/.test(t)?`${t}.`:t}function s(e){let s=e.subject?.trim()??"",n=s.toLowerCase(),o=e.predicate?.trim()??"",l=o.toLowerCase(),c=e.value?.trim()??"";if(!s||!o||!c)return i(e.content??c);if(t.has(n))return"name"===l?i(`Companion name is ${c}`):i(`Companion ${a(o)} is ${c}`);if(r.has(n))return"name"===l?i(`User name is ${c}`):"preferred_address"===l?i(`User preferred address is ${c}`):"relationship_to_siduri"===l||"relationship"===l?i(`User relationship configured as ${c}`):i(`User ${a(o)} is ${c}`);if(n.startsWith("primary_user.")||n.startsWith("user.")){let e=n.startsWith("primary_user.")?"primary_user.":"user.",t=a(s.slice(e.length)),r="uid"===l||"id"===l?"ID":a(o);return i(`User ${t} ${r} is ${c}`)}let d=a(s);return i(`${/s$/i.test(d)?`${d}'`:`${d}'s`} ${a(o)} is ${c}`)}e.s(["formatClaimReceipt",0,s,"formatRuntimeEffect",0,function(e){let n=e.subject?.trim().toLowerCase()??"",o=e.predicate?.trim().toLowerCase()??"",l=e.value?.trim()??"",c=e.behavior?.instruction?.trim()??"";return"behavioral"===e.memory_class&&c?i(c):t.has(n)&&"name"===o?i(`Set companion identity/name to ${l}`):t.has(n)?i(`Set companion ${a(o)} to ${l}`):r.has(n)&&("relationship_to_siduri"===o||"relationship"===o)?i(`Set user relationship to ${l}`):r.has(n)&&"name"===o?i(`Set user name to ${l}`):s(e)}])}]);
@@ -0,0 +1,31 @@
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,60808,(e,r,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o={WarningIcon:function(){return d},errorStyles:function(){return l},errorThemeCss:function(){return a}};for(var n in o)Object.defineProperty(t,n,{enumerable:!0,get:o[n]});e.r(36437);let i=e.r(7863);e.r(61507);let l={container:{fontFamily:'system-ui,"Segoe UI",Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji"',height:"100vh",display:"flex",alignItems:"center",justifyContent:"center"},card:{marginTop:"-32px",maxWidth:"325px",padding:"32px 28px",textAlign:"left"},icon:{marginBottom:"24px"},title:{fontSize:"24px",fontWeight:500,letterSpacing:"-0.02em",lineHeight:"32px",margin:"0 0 12px 0",color:"var(--next-error-title)"},message:{fontSize:"14px",fontWeight:400,lineHeight:"21px",margin:"0 0 20px 0",color:"var(--next-error-message)"},form:{margin:0},buttonGroup:{display:"flex",gap:"8px",alignItems:"center"},button:{display:"inline-flex",alignItems:"center",justifyContent:"center",height:"32px",padding:"0 12px",fontSize:"14px",fontWeight:500,lineHeight:"20px",borderRadius:"6px",cursor:"pointer",color:"var(--next-error-btn-text)",background:"var(--next-error-btn-bg)",border:"var(--next-error-btn-border)"},buttonSecondary:{display:"inline-flex",alignItems:"center",justifyContent:"center",height:"32px",padding:"0 12px",fontSize:"14px",fontWeight:500,lineHeight:"20px",borderRadius:"6px",cursor:"pointer",color:"var(--next-error-btn-secondary-text)",background:"var(--next-error-btn-secondary-bg)",border:"var(--next-error-btn-secondary-border)"},digestFooter:{position:"fixed",bottom:"32px",left:"0",right:"0",textAlign:"center",fontFamily:'ui-monospace,SFMono-Regular,"SF Mono",Menlo,Consolas,monospace',fontSize:"12px",lineHeight:"18px",fontWeight:400,margin:"0",color:"var(--next-error-digest)"}},a=`
2
+ :root {
3
+ --next-error-bg: #fff;
4
+ --next-error-text: #171717;
5
+ --next-error-title: #171717;
6
+ --next-error-message: #171717;
7
+ --next-error-digest: #666666;
8
+ --next-error-btn-text: #fff;
9
+ --next-error-btn-bg: #171717;
10
+ --next-error-btn-border: none;
11
+ --next-error-btn-secondary-text: #171717;
12
+ --next-error-btn-secondary-bg: transparent;
13
+ --next-error-btn-secondary-border: 1px solid rgba(0,0,0,0.08);
14
+ }
15
+ @media (prefers-color-scheme: dark) {
16
+ :root {
17
+ --next-error-bg: #0a0a0a;
18
+ --next-error-text: #ededed;
19
+ --next-error-title: #ededed;
20
+ --next-error-message: #ededed;
21
+ --next-error-digest: #a0a0a0;
22
+ --next-error-btn-text: #0a0a0a;
23
+ --next-error-btn-bg: #ededed;
24
+ --next-error-btn-border: none;
25
+ --next-error-btn-secondary-text: #ededed;
26
+ --next-error-btn-secondary-bg: transparent;
27
+ --next-error-btn-secondary-border: 1px solid rgba(255,255,255,0.14);
28
+ }
29
+ }
30
+ body { margin: 0; color: var(--next-error-text); background: var(--next-error-bg); }
31
+ `.replace(/\n\s*/g,"");function d(){return(0,i.jsx)("svg",{width:"32",height:"32",viewBox:"-0.2 -1.5 32 32",fill:"none",style:l.icon,children:(0,i.jsx)("path",{d:"M16.9328 0C18.0839 0.000116771 19.1334 0.658832 19.634 1.69531L31.4299 26.1309C32.0708 27.4588 31.1036 28.9999 29.6291 29H2.00215C0.527541 29 -0.439628 27.4588 0.201371 26.1309L11.9973 1.69531C12.4979 0.658823 13.5474 7.75066e-05 14.6984 0H16.9328ZM3.59493 26H28.0363L16.9328 3H14.6984L3.59493 26ZM15.8156 19C16.9202 19.0001 17.8156 19.8955 17.8156 21C17.8156 22.1045 16.9202 22.9999 15.8156 23C14.7111 23 13.8156 22.1046 13.8156 21C13.8156 19.8954 14.7111 19 15.8156 19ZM17.3156 16.5H14.3156V8.5H17.3156V16.5Z",fill:"var(--next-error-title)"})})}("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),r.exports=t.default)},4626,(e,r,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"default",{enumerable:!0,get:function(){return l}}),e.r(36437);let o=e.r(7863);e.r(61507);let n=e.r(68877),i=e.r(60808),l=function({error:e}){let r=e?.digest,t=!!r;return(0,n.handleISRError)({error:e}),(0,o.jsxs)("html",{id:"__next_error__",children:[(0,o.jsx)("head",{children:(0,o.jsx)("style",{dangerouslySetInnerHTML:{__html:i.errorThemeCss}})}),(0,o.jsxs)("body",{children:[(0,o.jsx)("div",{style:i.errorStyles.container,children:(0,o.jsxs)("div",{style:i.errorStyles.card,children:[(0,o.jsx)(i.WarningIcon,{}),(0,o.jsx)("h1",{style:i.errorStyles.title,children:"This page couldn’t load"}),(0,o.jsx)("p",{style:i.errorStyles.message,children:t?"A server error occurred. Reload to try again.":"Reload to try again, or go back."}),(0,o.jsxs)("div",{style:i.errorStyles.buttonGroup,children:[(0,o.jsx)("form",{style:i.errorStyles.form,children:(0,o.jsx)("button",{type:"submit",style:i.errorStyles.button,children:"Reload"})}),!t&&(0,o.jsx)("button",{type:"button",style:i.errorStyles.buttonSecondary,onClick:()=>{window.history.length>1?window.history.back():window.location.href="/"},children:"Back"})]})]})}),r&&(0,o.jsxs)("p",{style:i.errorStyles.digestFooter,children:["ERROR ",r]})]})]})};("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),r.exports=t.default)}]);
@@ -0,0 +1 @@
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,80413,(e,t,r)=>{"use strict";e.i(72619),Object.defineProperty(r,"__esModule",{value:!0});var n={default:function(){return m},useLinkStatus:function(){return v}};for(var o in n)Object.defineProperty(r,o,{enumerable:!0,get:n[o]});let u=e.r(56421),a=e.r(7863),i=u._(e.r(61507)),l=e.r(19262),c=e.r(70916),s=e.r(60474),f=e.r(82781),p=e.r(21676),d=e.r(42497),h=e.r(47040),y=e.r(95928),g=e.r(33683);function m(t){var r;let n,o,u,[m,v]=(0,i.useOptimistic)(h.IDLE_LINK_STATUS),P=(0,i.useRef)(null),{href:E,as:_,children:O,prefetch:S=null,passHref:j,replace:T,shallow:C,scroll:R,onClick:N,onMouseEnter:L,onTouchStart:x,legacyBehavior:A=!1,onNavigate:w,transitionTypes:U,ref:M,unstable_dynamicOnHover:$,...I}=t;n=O,A&&("string"==typeof n||"number"==typeof n)&&(n=(0,a.jsx)("a",{children:n}));let k=i.default.useContext(c.AppRouterContext),B=!1!==S,F=!1===S?"none":!0===S?"full":"auto",D="none"!==F?"auto"===F?g.FetchStrategy.PPR:g.FetchStrategy.Full:g.FetchStrategy.PPR,K="string"==typeof(r=_||E)?r:(0,l.formatUrl)(r);if(A){if(n?.$$typeof===Symbol.for("react.lazy"))throw Object.defineProperty(Error("`<Link legacyBehavior>` received a direct child that is either a Server Component, or JSX that was loaded with React.lazy(). This is not supported. Either remove legacyBehavior, or make the direct child a Client Component that renders the Link's `<a>` tag."),"__NEXT_ERROR_CODE",{value:"E863",enumerable:!1,configurable:!0});o=i.default.Children.only(n)}let z=A?o&&"object"==typeof o&&o.ref:M,Q,W=i.default.useCallback(e=>(null!==k&&(P.current=(0,h.mountLinkInstance)(e,K,k,D,B,v,Q)),()=>{P.current&&((0,h.unmountLinkForCurrentNavigation)(P.current),P.current=null),(0,h.unmountPrefetchableInstance)(e)}),[B,K,k,D,v,Q]),X={ref:(0,s.useMergedRef)(W,z),onClick(t){A||"function"!=typeof N||N(t),A&&o.props&&"function"==typeof o.props.onClick&&o.props.onClick(t),!k||t.defaultPrevented||function(t,r,n,o,u,a,l,c="none"){if("u">typeof window){let s,{nodeName:f}=t.currentTarget;if("A"===f.toUpperCase()&&((s=t.currentTarget.getAttribute("target"))&&"_self"!==s||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey||t.nativeEvent&&2===t.nativeEvent.which)||t.currentTarget.hasAttribute("download"))return;if(!(0,y.isLocalURL)(r)){o&&(t.preventDefault(),location.replace(r));return}if(t.preventDefault(),a){let e=!1;if(a({preventDefault:()=>{e=!0}}),e)return}let{dispatchNavigateAction:p}=e.r(16153);i.default.startTransition(()=>{p(r,o?"replace":"push",!1===u?d.ScrollBehavior.NoScroll:d.ScrollBehavior.Default,n.current,l,c)})}}(t,K,P,T,R,w,U,F)},onMouseEnter(e){A||"function"!=typeof L||L(e),A&&o.props&&"function"==typeof o.props.onMouseEnter&&o.props.onMouseEnter(e),k&&B&&(0,h.onNavigationIntent)(e.currentTarget,!0===$)},onTouchStart:function(e){A||"function"!=typeof x||x(e),A&&o.props&&"function"==typeof o.props.onTouchStart&&o.props.onTouchStart(e),k&&B&&(0,h.onNavigationIntent)(e.currentTarget,!0===$)}};return(0,f.isAbsoluteUrl)(K)?X.href=K:A&&!j&&("a"!==o.type||"href"in o.props)||(X.href=(0,p.addBasePath)(K)),u=A?i.default.cloneElement(o,X):(0,a.jsx)("a",{...I,...X,children:n}),(0,a.jsx)(b.Provider,{value:m,children:u})}let b=(0,i.createContext)(h.IDLE_LINK_STATUS),v=()=>(0,i.useContext)(b);("function"==typeof r.default||"object"==typeof r.default&&null!==r.default)&&void 0===r.default.__esModule&&(Object.defineProperty(r.default,"__esModule",{value:!0}),Object.assign(r.default,r),t.exports=r.default)},60474,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"useMergedRef",{enumerable:!0,get:function(){return o}});let n=e.r(61507);function o(e,t){let r=(0,n.useRef)(null),o=(0,n.useRef)(null);return(0,n.useCallback)(n=>{if(null===n){let e=r.current;e&&(r.current=null,e());let t=o.current;t&&(o.current=null,t())}else e&&(r.current=u(e,n)),t&&(o.current=u(t,n))},[e,t])}function u(e,t){if("function"!=typeof e)return e.current=t,()=>{e.current=null};{let r=e(t);return"function"==typeof r?r:()=>e(null)}}("function"==typeof r.default||"object"==typeof r.default&&null!==r.default)&&void 0===r.default.__esModule&&(Object.defineProperty(r.default,"__esModule",{value:!0}),Object.assign(r.default,r),t.exports=r.default)},82781,(e,t,r)=>{"use strict";e.i(72619),Object.defineProperty(r,"__esModule",{value:!0});var n={DecodeError:function(){return m},MiddlewareNotFoundError:function(){return E},MissingStaticPage:function(){return P},NormalizeError:function(){return b},PageNotFoundError:function(){return v},SP:function(){return y},ST:function(){return g},WEB_VITALS:function(){return u},execOnce:function(){return a},getDisplayName:function(){return f},getLocationOrigin:function(){return c},getURL:function(){return s},isAbsoluteUrl:function(){return l},isResSent:function(){return p},loadGetInitialProps:function(){return h},normalizeRepeatedSlashes:function(){return d},stringifyError:function(){return _}};for(var o in n)Object.defineProperty(r,o,{enumerable:!0,get:n[o]});let u=["CLS","FCP","FID","INP","LCP","TTFB"];function a(e){let t,r=!1;return(...n)=>(r||(r=!0,t=e(...n)),t)}let i=/^[a-zA-Z][a-zA-Z\d+\-.]*?:/,l=e=>{let t=e.charCodeAt(0);return!!(t>=65&&t<=90||t>=97&&t<=122)&&i.test(e)};function c(){let{protocol:e,hostname:t,port:r}=window.location;return`${e}//${t}${r?":"+r:""}`}function s(){let{href:e}=window.location,t=c();return e.substring(t.length)}function f(e){return"string"==typeof e?e:e.displayName||e.name||"Unknown"}function p(e){return e.finished||e.headersSent}function d(e){let t=e.split("?");return t[0].replace(/\\/g,"/").replace(/\/\/+/g,"/")+(t[1]?`?${t.slice(1).join("?")}`:"")}async function h(e,t){let r=t.res||t.ctx&&t.ctx.res;if(!e.getInitialProps)return t.ctx&&t.Component?{pageProps:await h(t.Component,t.ctx)}:{};let n=await e.getInitialProps(t);if(r&&p(r))return n;if(!n)throw Object.defineProperty(Error(`"${f(e)}.getInitialProps()" should resolve to an object. But found "${n}" instead.`),"__NEXT_ERROR_CODE",{value:"E1025",enumerable:!1,configurable:!0});return n}let y="u">typeof performance,g=y&&["mark","measure","getEntriesByName"].every(e=>"function"==typeof performance[e]);class m extends Error{}class b extends Error{}class v extends Error{constructor(e){super(),this.code="ENOENT",this.name="PageNotFoundError",this.message=`Cannot find module for page: ${e}`}}class P extends Error{constructor(e,t){super(),this.message=`Failed to load static file for page: ${e} ${t}`}}class E extends Error{constructor(){super(),this.code="ENOENT",this.message="Cannot find the middleware module"}}function _(e){return JSON.stringify({message:e.message,stack:e.stack})}},95928,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"isLocalURL",{enumerable:!0,get:function(){return u}});let n=e.r(82781),o=e.r(41277);function u(e){if(!(0,n.isAbsoluteUrl)(e))return!0;try{let t=(0,n.getLocationOrigin)(),r=new URL(e,t);return r.origin===t&&(0,o.hasBasePath)(r.pathname)}catch(e){return!1}}},33419,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n={assign:function(){return l},searchParamsToUrlQuery:function(){return u},urlQueryToSearchParams:function(){return i}};for(var o in n)Object.defineProperty(r,o,{enumerable:!0,get:n[o]});function u(e){let t={};for(let[r,n]of e.entries()){let e=t[r];void 0===e?t[r]=n:Array.isArray(e)?e.push(n):t[r]=[e,n]}return t}function a(e){return"string"==typeof e?e:("number"!=typeof e||isNaN(e))&&"boolean"!=typeof e?"":String(e)}function i(e){let t=new URLSearchParams;for(let[r,n]of Object.entries(e))if(Array.isArray(n))for(let e of n)t.append(r,a(e));else t.set(r,a(n));return t}function l(e,...t){for(let r of t){for(let t of r.keys())e.delete(t);for(let[t,n]of r.entries())e.append(t,n)}return e}},19262,(e,t,r)=>{"use strict";e.i(72619),Object.defineProperty(r,"__esModule",{value:!0});var n={formatUrl:function(){return i},formatWithValidation:function(){return c},urlObjectKeys:function(){return l}};for(var o in n)Object.defineProperty(r,o,{enumerable:!0,get:n[o]});let u=e.r(56421)._(e.r(33419)),a=/https?|ftp|gopher|file/;function i(e){let{auth:t,hostname:r}=e,n=e.protocol||"",o=e.pathname||"",i=e.hash||"",l=e.query||"",c=!1;t=t?encodeURIComponent(t).replace(/%3A/i,":")+"@":"",e.host?c=t+e.host:r&&(c=t+(~r.indexOf(":")?`[${r}]`:r),e.port&&(c+=":"+e.port)),l&&"object"==typeof l&&(l=String(u.urlQueryToSearchParams(l)));let s=e.search||l&&`?${l}`||"";return n&&!n.endsWith(":")&&(n+=":"),e.slashes||(!n||a.test(n))&&!1!==c?(c="//"+(c||""),o&&"/"!==o[0]&&(o="/"+o)):c||(c=""),i&&"#"!==i[0]&&(i="#"+i),s&&"?"!==s[0]&&(s="?"+s),o=o.replace(/[?#]/g,encodeURIComponent),s=s.replace("#","%23"),`${n}${c}${o}${s}${i}`}let l=["auth","hash","host","hostname","href","path","pathname","port","protocol","query","search","slashes"];function c(e){return i(e)}}]);