winclaw 2026.3.23 → 2026.3.24

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 (115) hide show
  1. package/dist/build-info.json +3 -3
  2. package/dist/canvas-host/a2ui/.bundle.hash +1 -1
  3. package/dist/{command-registry-CWxe1f-O.js → command-registry-BuD_6BPC.js} +4 -4
  4. package/dist/{completion-cli-DisKMPGI.js → completion-cli-D1JwPDe8.js} +1 -1
  5. package/dist/{completion-cli-BKoxA3-3.js → completion-cli-DEdrrUes.js} +2 -2
  6. package/dist/control-ui/assets/{index-DrWLR6Yv.js → index-Cu86kp_Y.js} +12 -6
  7. package/dist/control-ui/assets/index-Cu86kp_Y.js.map +1 -0
  8. package/dist/control-ui/index.html +1 -1
  9. package/dist/{doctor-completion-BtQY4Eaa.js → doctor-completion-Ci7xnsZS.js} +1 -1
  10. package/dist/{doctor-completion-t3rdrQev.js → doctor-completion-c53YitHu.js} +1 -1
  11. package/dist/entry.js +2 -2
  12. package/dist/{gateway-cli-Juhp3APs.js → gateway-cli-D_ZC2p7V.js} +12 -5
  13. package/dist/{gateway-cli-BeABpkZ1.js → gateway-cli-_PR4sDAN.js} +12 -5
  14. package/dist/index.js +1 -1
  15. package/dist/{onboard-lgDkrSqS.js → onboard-CUIqz7hg.js} +1 -1
  16. package/dist/{onboard-DSE0sFKG.js → onboard-fEj7bmJO.js} +1 -1
  17. package/dist/{onboarding-D713_nF-.js → onboarding-CvbfBQuP.js} +1 -1
  18. package/dist/{onboarding-tBrb0kFS.js → onboarding-Dvrz8TFV.js} +1 -1
  19. package/dist/{onboarding.finalize-DenRnQtC.js → onboarding.finalize-C9lZcSvn.js} +3 -3
  20. package/dist/{onboarding.finalize-femvpEYf.js → onboarding.finalize-Dj4KSLky.js} +4 -4
  21. package/dist/plugin-sdk/accounts-B71rIfIG.js +35 -0
  22. package/dist/plugin-sdk/accounts-Bh_CxVlh.js +46 -0
  23. package/dist/plugin-sdk/accounts-BoD7489q.js +288 -0
  24. package/dist/plugin-sdk/active-listener-6CPAmAh-.js +50 -0
  25. package/dist/plugin-sdk/api-key-rotation-DEDhmJAk.js +181 -0
  26. package/dist/plugin-sdk/audio-preflight-CMPZ9BXN.js +69 -0
  27. package/dist/plugin-sdk/audio-transcription-runner-CdADoJed.js +2176 -0
  28. package/dist/plugin-sdk/audit-membership-runtime-CxP2fdgS.js +58 -0
  29. package/dist/plugin-sdk/channel-activity-9ivqqvRB.js +94 -0
  30. package/dist/plugin-sdk/channel-web-kABzYw2i.js +2256 -0
  31. package/dist/plugin-sdk/chrome-B1yeIHRg.js +2415 -0
  32. package/dist/plugin-sdk/commands-registry-D-wyzYid.js +1125 -0
  33. package/dist/plugin-sdk/compat.js +50 -50
  34. package/dist/plugin-sdk/config-CmS6HzGU.js +17959 -0
  35. package/dist/plugin-sdk/deliver-Cy287pZ5.js +1719 -0
  36. package/dist/plugin-sdk/deliver-runtime-BH3fUFW1.js +32 -0
  37. package/dist/plugin-sdk/deps-send-discord.runtime-CLboFQJz.js +23 -0
  38. package/dist/plugin-sdk/deps-send-imessage.runtime-BVlGKP96.js +22 -0
  39. package/dist/plugin-sdk/deps-send-signal.runtime-0640YmBr.js +21 -0
  40. package/dist/plugin-sdk/deps-send-slack.runtime-BqbFKjcg.js +19 -0
  41. package/dist/plugin-sdk/deps-send-telegram.runtime-1a2RXcA2.js +24 -0
  42. package/dist/plugin-sdk/deps-send-whatsapp.runtime-BHndscAh.js +57 -0
  43. package/dist/plugin-sdk/diagnostic-DGt5TnqW.js +319 -0
  44. package/dist/plugin-sdk/errors-D7zDdduc.js +54 -0
  45. package/dist/plugin-sdk/fetch-guard-BsatETDz.js +156 -0
  46. package/dist/plugin-sdk/fs-safe-ynDN1AOr.js +352 -0
  47. package/dist/plugin-sdk/image-6No3eiOM.js +2314 -0
  48. package/dist/plugin-sdk/image-ops-CmFoHyKE.js +584 -0
  49. package/dist/plugin-sdk/image-runtime-D57a2W4s.js +25 -0
  50. package/dist/plugin-sdk/infra/grc-client.d.ts +3 -0
  51. package/dist/plugin-sdk/ir-CX1ZjDTn.js +1296 -0
  52. package/dist/plugin-sdk/local-roots-DnE8988Y.js +186 -0
  53. package/dist/plugin-sdk/logger-cN8CgKqt.js +1163 -0
  54. package/dist/plugin-sdk/login-hk6_2GSM.js +57 -0
  55. package/dist/plugin-sdk/login-qr-UaVS_Rce.js +320 -0
  56. package/dist/plugin-sdk/manager-CBP2ZQ5W.js +3929 -0
  57. package/dist/plugin-sdk/manager-runtime-3rKbDrJp.js +15 -0
  58. package/dist/plugin-sdk/outbound-B0Ab6CJM.js +212 -0
  59. package/dist/plugin-sdk/outbound-attachment-CktA053B.js +19 -0
  60. package/dist/plugin-sdk/path-alias-guards-WXu8eYZ3.js +43 -0
  61. package/dist/plugin-sdk/paths-Brta7ydd.js +166 -0
  62. package/dist/plugin-sdk/pi-embedded-helpers-BfbOXbe6.js +9627 -0
  63. package/dist/plugin-sdk/pi-model-discovery-ruarR-_j.js +134 -0
  64. package/dist/plugin-sdk/pi-model-discovery-runtime-26px0QfL.js +8 -0
  65. package/dist/plugin-sdk/pi-tools.before-tool-call.runtime-VVLpfXqQ.js +354 -0
  66. package/dist/plugin-sdk/plugins-C995vsQz.js +864 -0
  67. package/dist/plugin-sdk/proxy-fetch-iSQrNgP-.js +38 -0
  68. package/dist/plugin-sdk/pw-ai-BJXHSS3q.js +1938 -0
  69. package/dist/plugin-sdk/qmd-manager-A7m15SeJ.js +1448 -0
  70. package/dist/plugin-sdk/query-expansion-DngcFbkC.js +1011 -0
  71. package/dist/plugin-sdk/redact-CIb5VTTO.js +319 -0
  72. package/dist/plugin-sdk/reply-Cq6NqOE1.js +100211 -0
  73. package/dist/plugin-sdk/resolve-outbound-target-CQ6hRY-h.js +40 -0
  74. package/dist/plugin-sdk/run-with-concurrency-BlfAoChN.js +1994 -0
  75. package/dist/plugin-sdk/runtime-whatsapp-login.runtime-YsrzSsFL.js +10 -0
  76. package/dist/plugin-sdk/runtime-whatsapp-outbound.runtime-DL6Ses5K.js +19 -0
  77. package/dist/plugin-sdk/send-BEy8EUzH.js +414 -0
  78. package/dist/plugin-sdk/send-CWP6COto.js +3135 -0
  79. package/dist/plugin-sdk/send-DQTgt3Cu.js +540 -0
  80. package/dist/plugin-sdk/send-DzpV-k17.js +2587 -0
  81. package/dist/plugin-sdk/send-HuIksBS6.js +503 -0
  82. package/dist/plugin-sdk/session-Cc3Y4mXL.js +169 -0
  83. package/dist/plugin-sdk/skill-commands-p8Zwjnwy.js +353 -0
  84. package/dist/plugin-sdk/skills-k8XpacZa.js +1428 -0
  85. package/dist/plugin-sdk/slash-commands.runtime-ynnr6oUR.js +13 -0
  86. package/dist/plugin-sdk/slash-dispatch.runtime-Cw2wTfnn.js +52 -0
  87. package/dist/plugin-sdk/slash-skill-commands.runtime-eAk1jhVy.js +16 -0
  88. package/dist/plugin-sdk/ssrf-DZSsYJgJ.js +202 -0
  89. package/dist/plugin-sdk/store-Cn0oLCP4.js +81 -0
  90. package/dist/plugin-sdk/subagent-registry-runtime-0Y9lMsGe.js +52 -0
  91. package/dist/plugin-sdk/tables-KWxXnbkq.js +55 -0
  92. package/dist/plugin-sdk/target-errors-Cr0q4o7K.js +195 -0
  93. package/dist/plugin-sdk/thinking-CfA6xbI_.js +1206 -0
  94. package/dist/plugin-sdk/tokens-B-D1YRTV.js +52 -0
  95. package/dist/plugin-sdk/tool-images-CVV7LNFW.js +274 -0
  96. package/dist/plugin-sdk/twitch.js +2 -2
  97. package/dist/plugin-sdk/web-CyZHlJH6.js +56 -0
  98. package/dist/plugin-sdk/whatsapp-actions-CLNhBLJz.js +80 -0
  99. package/dist/plugin-sdk/zalouser.js +2 -2
  100. package/dist/{program-N2SbF1HK.js → program-CqEfrLyo.js} +2 -2
  101. package/dist/{program-context-DMg-_LjD.js → program-context-tqafV77z.js} +6 -6
  102. package/dist/{prompt-select-styled-BehogMCm.js → prompt-select-styled-BSrb2lr9.js} +1 -1
  103. package/dist/{prompt-select-styled-pMhNy-Rt.js → prompt-select-styled-Dl7CZy-J.js} +1 -1
  104. package/dist/{register.maintenance-Cc675Yxz.js → register.maintenance-D46HRdZD.js} +4 -4
  105. package/dist/{register.maintenance-GewLmA3i.js → register.maintenance-DNLLj2AS.js} +5 -5
  106. package/dist/{register.onboard-45htf4DA.js → register.onboard-B599JCYg.js} +2 -2
  107. package/dist/{register.onboard-Jv--xCKB.js → register.onboard-BsI-SljF.js} +2 -2
  108. package/dist/{register.setup-Bm99k2pm.js → register.setup-BSIjdjo-.js} +2 -2
  109. package/dist/{register.setup-CqrPLejH.js → register.setup-D404yEAW.js} +2 -2
  110. package/dist/{register.subclis-4LlGcEld.js → register.subclis-Dg6jbQKe.js} +3 -3
  111. package/dist/{run-main-B3eIQkhk.js → run-main-B8FEqSuE.js} +3 -3
  112. package/dist/{update-cli-Bk3xkEPl.js → update-cli-BLkqLhYY.js} +5 -5
  113. package/dist/{update-cli-G1w1hdg4.js → update-cli-CjTN5f_O.js} +4 -4
  114. package/package.json +1 -1
  115. package/dist/control-ui/assets/index-DrWLR6Yv.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2026.3.23",
3
- "commit": "78c5bea872f8a80c273eec21efaa780e9b11f3a7",
4
- "builtAt": "2026-03-21T04:25:19.566Z"
2
+ "version": "2026.3.24",
3
+ "commit": "b13cd1b96297936bd298d9af5b09cc264bd26647",
4
+ "builtAt": "2026-03-22T03:54:04.165Z"
5
5
  }
@@ -1 +1 @@
1
- 680d0c29e9ea1a7ce7f7bb2602381ee11c83057ad98714e558ff8f20a2e70416
1
+ 1671f27c08fb549bd97a983f65bbf570de72b12717ac8f6c4c55aea63069b784
@@ -1,6 +1,6 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-Cbj13DAv.js";
2
2
  import { Ct as hasHelpOrVersion, bt as getPrimaryCommand } from "./entry.js";
3
- import { i as registerSubCliCommands, o as removeCommandByName, s as reparseProgramFromActionArgs } from "./register.subclis-4LlGcEld.js";
3
+ import { i as registerSubCliCommands, o as removeCommandByName, s as reparseProgramFromActionArgs } from "./register.subclis-Dg6jbQKe.js";
4
4
 
5
5
  //#region src/cli/program/command-registry.ts
6
6
  var command_registry_exports = /* @__PURE__ */ __exportAll({
@@ -22,7 +22,7 @@ const coreEntries = [
22
22
  hasSubcommands: false
23
23
  }],
24
24
  register: async ({ program }) => {
25
- (await import("./register.setup-CqrPLejH.js")).registerSetupCommand(program);
25
+ (await import("./register.setup-D404yEAW.js")).registerSetupCommand(program);
26
26
  }
27
27
  },
28
28
  {
@@ -32,7 +32,7 @@ const coreEntries = [
32
32
  hasSubcommands: false
33
33
  }],
34
34
  register: async ({ program }) => {
35
- (await import("./register.onboard-45htf4DA.js")).registerOnboardCommand(program);
35
+ (await import("./register.onboard-B599JCYg.js")).registerOnboardCommand(program);
36
36
  }
37
37
  },
38
38
  {
@@ -79,7 +79,7 @@ const coreEntries = [
79
79
  }
80
80
  ],
81
81
  register: async ({ program }) => {
82
- (await import("./register.maintenance-GewLmA3i.js")).registerMaintenanceCommands(program);
82
+ (await import("./register.maintenance-DNLLj2AS.js")).registerMaintenanceCommands(program);
83
83
  }
84
84
  },
85
85
  {
@@ -4,7 +4,7 @@ import { p as theme } from "./globals-mxjDvm3x.js";
4
4
  import { h as pathExists } from "./utils-D2mWpsBR.js";
5
5
  import { i as routeLogsToStderr } from "./subsystem-notCuUgs.js";
6
6
  import { t as formatDocsLink } from "./links-UVNtH_G6.js";
7
- import { a as registerCoreCliByName, c as getSubCliEntries, l as registerSubCliByName, r as getCoreCliCommandNames, t as getProgramContext } from "./program-context-DMg-_LjD.js";
7
+ import { a as registerCoreCliByName, c as getSubCliEntries, l as registerSubCliByName, r as getCoreCliCommandNames, t as getProgramContext } from "./program-context-tqafV77z.js";
8
8
  import os from "node:os";
9
9
  import path from "node:path";
10
10
  import fs from "node:fs/promises";
@@ -2,8 +2,8 @@ import { t as __exportAll } from "./rolldown-runtime-Cbj13DAv.js";
2
2
  import { P as theme, ot as resolveStateDir, u as routeLogsToStderr } from "./entry.js";
3
3
  import { m as pathExists } from "./utils-hiIKrqOK.js";
4
4
  import { t as formatDocsLink } from "./links-Bcv6_maG.js";
5
- import { n as getSubCliEntries, r as registerSubCliByName } from "./register.subclis-4LlGcEld.js";
6
- import { i as registerCoreCliByName, n as getCoreCliCommandNames } from "./command-registry-CWxe1f-O.js";
5
+ import { n as getSubCliEntries, r as registerSubCliByName } from "./register.subclis-Dg6jbQKe.js";
6
+ import { i as registerCoreCliByName, n as getCoreCliCommandNames } from "./command-registry-BuD_6BPC.js";
7
7
  import { t as getProgramContext } from "./program-context-gd4x_qEm.js";
8
8
  import os from "node:os";
9
9
  import path from "node:path";
@@ -123,7 +123,7 @@
123
123
  </div>
124
124
  `}function td(e){const t={name:e?.name??"",displayName:e?.displayName??"",about:e?.about??"",picture:e?.picture??"",banner:e?.banner??"",website:e?.website??"",nip05:e?.nip05??"",lud16:e?.lud16??""};return{values:t,original:{...t},saving:!1,importing:!1,error:null,success:null,fieldErrors:{},showAdvanced:!!(e?.banner||e?.website||e?.nip05||e?.lud16)}}async function nd(e,t){await qc(e,t),await me(e,!0)}async function sd(e){await Gc(e),await me(e,!0)}async function id(e){await Vc(e),await me(e,!0)}async function ad(e){await Dn(e),await Ee(e),await me(e,!0)}async function od(e){await Ee(e),await me(e,!0)}function rd(e){if(!Array.isArray(e))return{};const t={};for(const n of e){if(typeof n!="string")continue;const[s,...i]=n.split(":");if(!s||i.length===0)continue;const a=s.trim(),o=i.join(":").trim();a&&o&&(t[a]=o)}return t}function Rr(e){return(e.channelsSnapshot?.channelAccounts?.nostr??[])[0]?.accountId??e.nostrProfileAccountId??"default"}function Pr(e,t=""){return`/api/channels/nostr/${encodeURIComponent(e)}/profile${t}`}function ld(e,t,n){e.nostrProfileAccountId=t,e.nostrProfileFormState=td(n??void 0)}function cd(e){e.nostrProfileFormState=null,e.nostrProfileAccountId=null}function dd(e,t,n){const s=e.nostrProfileFormState;s&&(e.nostrProfileFormState={...s,values:{...s.values,[t]:n},fieldErrors:{...s.fieldErrors,[t]:""}})}function ud(e){const t=e.nostrProfileFormState;t&&(e.nostrProfileFormState={...t,showAdvanced:!t.showAdvanced})}async function gd(e){const t=e.nostrProfileFormState;if(!t||t.saving)return;const n=Rr(e);e.nostrProfileFormState={...t,saving:!0,error:null,success:null,fieldErrors:{}};try{const s=await fetch(Pr(n),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t.values)}),i=await s.json().catch(()=>null);if(!s.ok||i?.ok===!1||!i){const a=i?.error??`Profile update failed (${s.status})`;e.nostrProfileFormState={...t,saving:!1,error:a,success:null,fieldErrors:rd(i?.details)};return}if(!i.persisted){e.nostrProfileFormState={...t,saving:!1,error:"Profile publish failed on all relays.",success:null};return}e.nostrProfileFormState={...t,saving:!1,error:null,success:"Profile published to relays.",fieldErrors:{},original:{...t.values}},await me(e,!0)}catch(s){e.nostrProfileFormState={...t,saving:!1,error:`Profile update failed: ${String(s)}`,success:null}}}async function pd(e){const t=e.nostrProfileFormState;if(!t||t.importing)return;const n=Rr(e);e.nostrProfileFormState={...t,importing:!0,error:null,success:null};try{const s=await fetch(Pr(n,"/import"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({autoMerge:!0})}),i=await s.json().catch(()=>null);if(!s.ok||i?.ok===!1||!i){const c=i?.error??`Profile import failed (${s.status})`;e.nostrProfileFormState={...t,importing:!1,error:c,success:null};return}const a=i.merged??i.imported??null,o=a?{...t.values,...a}:t.values,l=!!(o.banner||o.website||o.nip05||o.lud16);e.nostrProfileFormState={...t,importing:!1,values:o,error:null,success:i.saved?"Profile imported from relays. Review and publish.":"Profile imported. Review and publish.",showAdvanced:l},i.saved&&await me(e,!0)}catch(s){e.nostrProfileFormState={...t,importing:!1,error:`Profile import failed: ${String(s)}`,success:null}}}function Ri(e){const t=(e??"").trim().toLowerCase();if(!t)return null;const n=t.split(":").filter(Boolean);if(n.length<3||n[0]!=="agent")return null;const s=n[1]?.trim(),i=n.slice(2).join(":");return!s||!i?null:{agentId:s,rest:i}}const ti=450;function cn(e,t=!1,n=!1){e.chatScrollFrame&&cancelAnimationFrame(e.chatScrollFrame),e.chatScrollTimeout!=null&&(clearTimeout(e.chatScrollTimeout),e.chatScrollTimeout=null);const s=()=>{const i=e.querySelector(".chat-thread");if(i){const a=getComputedStyle(i).overflowY;if(a==="auto"||a==="scroll"||i.scrollHeight-i.clientHeight>1)return i}return document.scrollingElement??document.documentElement};e.updateComplete.then(()=>{e.chatScrollFrame=requestAnimationFrame(()=>{e.chatScrollFrame=null;const i=s();if(!i)return;const a=i.scrollHeight-i.scrollTop-i.clientHeight,o=t&&!e.chatHasAutoScrolled;if(!(o||e.chatUserNearBottom||a<ti)){e.chatNewMessagesBelow=!0;return}o&&(e.chatHasAutoScrolled=!0);const c=n&&(typeof window>"u"||typeof window.matchMedia!="function"||!window.matchMedia("(prefers-reduced-motion: reduce)").matches),g=i.scrollHeight;typeof i.scrollTo=="function"?i.scrollTo({top:g,behavior:c?"smooth":"auto"}):i.scrollTop=g,e.chatUserNearBottom=!0,e.chatNewMessagesBelow=!1;const u=o?150:120;e.chatScrollTimeout=window.setTimeout(()=>{e.chatScrollTimeout=null;const p=s();if(!p)return;const h=p.scrollHeight-p.scrollTop-p.clientHeight;(o||e.chatUserNearBottom||h<ti)&&(p.scrollTop=p.scrollHeight,e.chatUserNearBottom=!0)},u)})})}function Dr(e,t=!1){e.logsScrollFrame&&cancelAnimationFrame(e.logsScrollFrame),e.updateComplete.then(()=>{e.logsScrollFrame=requestAnimationFrame(()=>{e.logsScrollFrame=null;const n=e.querySelector(".log-stream");if(!n)return;const s=n.scrollHeight-n.scrollTop-n.clientHeight;(t||s<80)&&(n.scrollTop=n.scrollHeight)})})}function fd(e,t){const n=t.currentTarget;if(!n)return;const s=n.scrollHeight-n.scrollTop-n.clientHeight;e.chatUserNearBottom=s<ti,e.chatUserNearBottom&&(e.chatNewMessagesBelow=!1)}function hd(e,t){const n=t.currentTarget;if(!n)return;const s=n.scrollHeight-n.scrollTop-n.clientHeight;e.logsAtBottom=s<80}function eo(e){e.chatHasAutoScrolled=!1,e.chatUserNearBottom=!0,e.chatNewMessagesBelow=!1}function md(e,t){if(e.length===0)return;const n=new Blob([`${e.join(`
125
125
  `)}
126
- `],{type:"text/plain"}),s=URL.createObjectURL(n),i=document.createElement("a"),a=new Date().toISOString().slice(0,19).replace(/[:T]/g,"-");i.href=s,i.download=`winclaw-logs-${t}-${a}.log`,i.click(),URL.revokeObjectURL(s)}function vd(e){if(typeof ResizeObserver>"u")return;const t=e.querySelector(".topbar");if(!t)return;const n=()=>{const{height:s}=t.getBoundingClientRect();e.style.setProperty("--topbar-height",`${s}px`)};n(),e.topbarObserver=new ResizeObserver(()=>n()),e.topbarObserver.observe(t)}async function ss(e){if(!(!e.client||!e.connected)&&!e.debugLoading){e.debugLoading=!0;try{const[t,n,s,i]=await Promise.all([e.client.request("status",{}),e.client.request("health",{}),e.client.request("models.list",{}),e.client.request("last-heartbeat",{})]);e.debugStatus=t,e.debugHealth=n;const a=s;e.debugModels=Array.isArray(a?.models)?a?.models:[],e.debugHeartbeat=i}catch(t){e.debugCallError=String(t)}finally{e.debugLoading=!1}}}async function bd(e){if(!(!e.client||!e.connected)){e.debugCallError=null,e.debugCallResult=null;try{const t=e.debugCallParams.trim()?JSON.parse(e.debugCallParams):{},n=await e.client.request(e.debugCallMethod.trim(),t);e.debugCallResult=JSON.stringify(n,null,2)}catch(t){e.debugCallError=String(t)}}}const yd=2e3,xd=new Set(["trace","debug","info","warn","error","fatal"]);function wd(e){if(typeof e!="string")return null;const t=e.trim();if(!t.startsWith("{")||!t.endsWith("}"))return null;try{const n=JSON.parse(t);return!n||typeof n!="object"?null:n}catch{return null}}function $d(e){if(typeof e!="string")return null;const t=e.toLowerCase();return xd.has(t)?t:null}function kd(e){if(!e.trim())return{raw:e,message:e};try{const t=JSON.parse(e),n=t&&typeof t._meta=="object"&&t._meta!==null?t._meta:null,s=typeof t.time=="string"?t.time:typeof n?.date=="string"?n?.date:null,i=$d(n?.logLevelName??n?.level),a=typeof t[0]=="string"?t[0]:typeof n?.name=="string"?n?.name:null,o=wd(a);let l=null;o&&(typeof o.subsystem=="string"?l=o.subsystem:typeof o.module=="string"&&(l=o.module)),!l&&a&&a.length<120&&(l=a);let c=null;return typeof t[1]=="string"?c=t[1]:!o&&typeof t[0]=="string"?c=t[0]:typeof t.message=="string"&&(c=t.message),{raw:e,time:s,level:i,subsystem:l,message:c??e,meta:n??void 0}}catch{return{raw:e,message:e}}}async function Pi(e,t){if(!(!e.client||!e.connected)&&!(e.logsLoading&&!t?.quiet)){t?.quiet||(e.logsLoading=!0),e.logsError=null;try{const s=await e.client.request("logs.tail",{cursor:t?.reset?void 0:e.logsCursor??void 0,limit:e.logsLimit,maxBytes:e.logsMaxBytes}),a=(Array.isArray(s.lines)?s.lines.filter(l=>typeof l=="string"):[]).map(kd),o=!!(t?.reset||s.reset||e.logsCursor==null);e.logsEntries=o?a:[...e.logsEntries,...a].slice(-yd),typeof s.cursor=="number"&&(e.logsCursor=s.cursor),typeof s.file=="string"&&(e.logsFile=s.file),e.logsTruncated=!!s.truncated,e.logsLastFetchAt=Date.now()}catch(n){e.logsError=String(n)}finally{t?.quiet||(e.logsLoading=!1)}}}async function is(e,t){if(!(!e.client||!e.connected)&&!e.nodesLoading){e.nodesLoading=!0,t?.quiet||(e.lastError=null);try{const n=await e.client.request("node.list",{});e.nodes=Array.isArray(n.nodes)?n.nodes:[]}catch(n){t?.quiet||(e.lastError=String(n))}finally{e.nodesLoading=!1}}}function Sd(e){e.nodesPollInterval==null&&(e.nodesPollInterval=window.setInterval(()=>{is(e,{quiet:!0})},5e3))}function Ad(e){e.nodesPollInterval!=null&&(clearInterval(e.nodesPollInterval),e.nodesPollInterval=null)}function Di(e){e.logsPollInterval==null&&(e.logsPollInterval=window.setInterval(()=>{e.tab==="logs"&&Pi(e,{quiet:!0})},2e3))}function Fi(e){e.logsPollInterval!=null&&(clearInterval(e.logsPollInterval),e.logsPollInterval=null)}function Ni(e){e.debugPollInterval==null&&(e.debugPollInterval=window.setInterval(()=>{e.tab==="debug"&&ss(e)},3e3))}function Oi(e){e.debugPollInterval!=null&&(clearInterval(e.debugPollInterval),e.debugPollInterval=null)}async function Fr(e,t){if(!(!e.client||!e.connected||e.agentIdentityLoading)&&!e.agentIdentityById[t]){e.agentIdentityLoading=!0,e.agentIdentityError=null;try{const n=await e.client.request("agent.identity.get",{agentId:t});n&&(e.agentIdentityById={...e.agentIdentityById,[t]:n})}catch(n){e.agentIdentityError=String(n)}finally{e.agentIdentityLoading=!1}}}async function Nr(e,t){if(!e.client||!e.connected||e.agentIdentityLoading)return;const n=t.filter(s=>!e.agentIdentityById[s]);if(n.length!==0){e.agentIdentityLoading=!0,e.agentIdentityError=null;try{for(const s of n){const i=await e.client.request("agent.identity.get",{agentId:s});i&&(e.agentIdentityById={...e.agentIdentityById,[s]:i})}}catch(s){e.agentIdentityError=String(s)}finally{e.agentIdentityLoading=!1}}}async function Fn(e,t){if(!(!e.client||!e.connected)&&!e.agentSkillsLoading){e.agentSkillsLoading=!0,e.agentSkillsError=null;try{const n=await e.client.request("skills.status",{agentId:t});n&&(e.agentSkillsReport=n,e.agentSkillsAgentId=t)}catch(n){e.agentSkillsError=String(n)}finally{e.agentSkillsLoading=!1}}}async function Bi(e,t){if(!(!e.client||!e.connected)&&!e.agentsLoading){e.agentsLoading=!0,e.agentsError=null;try{const n=await e.client.request("agents.list",{});if(n){e.agentsList=n;const s=e.agentsSelectedId,i=n.agents.some(a=>a.id===s);(!s||!i)&&(e.agentsSelectedId=n.defaultId??n.agents[0]?.id??null)}}catch(n){e.agentsError=String(n)}finally{e.agentsLoading=!1}}}function Ui(e,t){if(e==null||!Number.isFinite(e)||e<=0)return;if(e<1e3)return`${Math.round(e)}ms`;const n=t?.spaced?" ":"",s=Math.round(e/1e3),i=Math.floor(s/3600),a=Math.floor(s%3600/60),o=s%60;if(i>=24){const l=Math.floor(i/24),c=i%24;return c>0?`${l}d${n}${c}h`:`${l}d`}return i>0?a>0?`${i}h${n}${a}m`:`${i}h`:a>0?o>0?`${a}m${n}${o}s`:`${a}m`:`${o}s`}function zi(e,t="n/a"){if(e==null||!Number.isFinite(e)||e<0)return t;if(e<1e3)return`${Math.round(e)}ms`;const n=Math.round(e/1e3);if(n<60)return`${n}s`;const s=Math.round(n/60);if(s<60)return`${s}m`;const i=Math.round(s/60);return i<24?`${i}h`:`${Math.round(i/24)}d`}function V(e,t){const n=t?.fallback??"n/a";if(e==null||!Number.isFinite(e))return n;const s=Date.now()-e,i=Math.abs(s),a=s>=0,o=Math.round(i/1e3);if(o<60)return a?"just now":"in <1m";const l=Math.round(o/60);if(l<60)return a?`${l}m ago`:`in ${l}m`;const c=Math.round(l/60);if(c<48)return a?`${c}h ago`:`in ${c}h`;const g=Math.round(c/24);return a?`${g}d ago`:`in ${g}d`}function to(e){const t=[],n=/(^|\n)(```|~~~)[^\n]*\n[\s\S]*?(?:\n\2(?:\n|$)|$)/g;for(const i of e.matchAll(n)){const a=(i.index??0)+i[1].length;t.push({start:a,end:a+i[0].length-i[1].length})}const s=/`+[^`]+`+/g;for(const i of e.matchAll(s)){const a=i.index??0,o=a+i[0].length;t.some(c=>a>=c.start&&o<=c.end)||t.push({start:a,end:o})}return t.sort((i,a)=>i.start-a.start),t}function no(e,t){return t.some(n=>e>=n.start&&e<n.end)}const Cd=/<\s*\/?\s*(?:think(?:ing)?|thought|antthinking|final)\b/i,$n=/<\s*\/?\s*final\b[^<>]*>/gi,so=/<\s*(\/?)\s*(?:think(?:ing)?|thought|antthinking)\b[^<>]*>/gi;function Td(e,t){return e.trimStart()}function _d(e,t){if(!e||!Cd.test(e))return e;let n=e;if($n.test(n)){$n.lastIndex=0;const l=[],c=to(n);for(const g of n.matchAll($n)){const u=g.index??0;l.push({start:u,length:g[0].length,inCode:no(u,c)})}for(let g=l.length-1;g>=0;g--){const u=l[g];u.inCode||(n=n.slice(0,u.start)+n.slice(u.start+u.length))}}else $n.lastIndex=0;const s=to(n);so.lastIndex=0;let i="",a=0,o=!1;for(const l of n.matchAll(so)){const c=l.index??0,g=l[1]==="/";no(c,s)||(o?g&&(o=!1):(i+=n.slice(a,c),g||(o=!0)),a=c+l[0].length)}return i+=n.slice(a),Td(i)}function vt(e){return!e&&e!==0?"n/a":new Date(e).toLocaleString()}function ni(e){return!e||e.length===0?"none":e.filter(t=>!!(t&&t.trim())).join(", ")}function si(e,t=120){return e.length<=t?e:`${e.slice(0,Math.max(0,t-1))}…`}function Or(e,t){return e.length<=t?{text:e,truncated:!1,total:e.length}:{text:e.slice(0,Math.max(0,t)),truncated:!0,total:e.length}}function zn(e,t){const n=Number(e);return Number.isFinite(n)?n:t}function Es(e){return _d(e)}async function dn(e){if(!(!e.client||!e.connected))try{const t=await e.client.request("cron.status",{});e.cronStatus=t}catch(t){e.cronError=String(t)}}async function as(e){if(!(!e.client||!e.connected)&&!e.cronLoading){e.cronLoading=!0,e.cronError=null;try{const t=await e.client.request("cron.list",{includeDisabled:!0});e.cronJobs=Array.isArray(t.jobs)?t.jobs:[]}catch(t){e.cronError=String(t)}finally{e.cronLoading=!1}}}function Ed(e){if(e.scheduleKind==="at"){const n=Date.parse(e.scheduleAt);if(!Number.isFinite(n))throw new Error("Invalid run time.");return{kind:"at",at:new Date(n).toISOString()}}if(e.scheduleKind==="every"){const n=zn(e.everyAmount,0);if(n<=0)throw new Error("Invalid interval amount.");const s=e.everyUnit;return{kind:"every",everyMs:n*(s==="minutes"?6e4:s==="hours"?36e5:864e5)}}const t=e.cronExpr.trim();if(!t)throw new Error("Cron expression required.");return{kind:"cron",expr:t,tz:e.cronTz.trim()||void 0}}function Ld(e){if(e.payloadKind==="systemEvent"){const i=e.payloadText.trim();if(!i)throw new Error("System event text required.");return{kind:"systemEvent",text:i}}const t=e.payloadText.trim();if(!t)throw new Error("Agent message required.");const n={kind:"agentTurn",message:t},s=zn(e.timeoutSeconds,0);return s>0&&(n.timeoutSeconds=s),n}async function Id(e){if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{const t=Ed(e.cronForm),n=Ld(e.cronForm),s=e.cronForm.sessionTarget==="isolated"&&e.cronForm.payloadKind==="agentTurn"&&e.cronForm.deliveryMode?{mode:e.cronForm.deliveryMode==="announce"?"announce":"none",channel:e.cronForm.deliveryChannel.trim()||"last",to:e.cronForm.deliveryTo.trim()||void 0}:void 0,i=e.cronForm.agentId.trim(),a={name:e.cronForm.name.trim(),description:e.cronForm.description.trim()||void 0,agentId:i||void 0,enabled:e.cronForm.enabled,schedule:t,sessionTarget:e.cronForm.sessionTarget,wakeMode:e.cronForm.wakeMode,payload:n,delivery:s};if(!a.name)throw new Error("Name required.");await e.client.request("cron.add",a),e.cronForm={...e.cronForm,name:"",description:"",payloadText:""},await as(e),await dn(e)}catch(t){e.cronError=String(t)}finally{e.cronBusy=!1}}}async function Md(e,t,n){if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{await e.client.request("cron.update",{id:t.id,patch:{enabled:n}}),await as(e),await dn(e)}catch(s){e.cronError=String(s)}finally{e.cronBusy=!1}}}async function Rd(e,t){if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{await e.client.request("cron.run",{id:t.id,mode:"force"}),await Br(e,t.id)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function Pd(e,t){if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{await e.client.request("cron.remove",{id:t.id}),e.cronRunsJobId===t.id&&(e.cronRunsJobId=null,e.cronRuns=[]),await as(e),await dn(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function Br(e,t){if(!(!e.client||!e.connected))try{const n=await e.client.request("cron.runs",{id:t,limit:50});e.cronRunsJobId=t,e.cronRuns=Array.isArray(n.entries)?n.entries:[]}catch(n){e.cronError=String(n)}}const Ur="winclaw.device.auth.v1";function Hi(e){return e.trim()}function Dd(e){if(!Array.isArray(e))return[];const t=new Set;for(const n of e){const s=n.trim();s&&t.add(s)}return[...t].toSorted()}function Ki(){try{const e=window.localStorage.getItem(Ur);if(!e)return null;const t=JSON.parse(e);return!t||t.version!==1||!t.deviceId||typeof t.deviceId!="string"||!t.tokens||typeof t.tokens!="object"?null:t}catch{return null}}function zr(e){try{window.localStorage.setItem(Ur,JSON.stringify(e))}catch{}}function Fd(e){const t=Ki();if(!t||t.deviceId!==e.deviceId)return null;const n=Hi(e.role),s=t.tokens[n];return!s||typeof s.token!="string"?null:s}function Hr(e){const t=Hi(e.role),n={version:1,deviceId:e.deviceId,tokens:{}},s=Ki();s&&s.deviceId===e.deviceId&&(n.tokens={...s.tokens});const i={token:e.token,role:t,scopes:Dd(e.scopes),updatedAtMs:Date.now()};return n.tokens[t]=i,zr(n),i}function Kr(e){const t=Ki();if(!t||t.deviceId!==e.deviceId)return;const n=Hi(e.role);if(!t.tokens[n])return;const s={...t,tokens:{...t.tokens}};delete s.tokens[n],zr(s)}const jr={p:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,n:0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3edn,h:8n,a:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffecn,d:0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3n,Gx:0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,Gy:0x6666666666666666666666666666666666666666666666666666666666666658n},{p:ue,n:Nn,Gx:io,Gy:ao,a:Ls,d:Is,h:Nd}=jr,bt=32,ji=64,Od=(...e)=>{"captureStackTrace"in Error&&typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(...e)},oe=(e="")=>{const t=new Error(e);throw Od(t,oe),t},Bd=e=>typeof e=="bigint",Ud=e=>typeof e=="string",zd=e=>e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array",Je=(e,t,n="")=>{const s=zd(e),i=e?.length,a=t!==void 0;if(!s||a&&i!==t){const o=n&&`"${n}" `,l=a?` of length ${t}`:"",c=s?`length=${i}`:`type=${typeof e}`;oe(o+"expected Uint8Array"+l+", got "+c)}return e},os=e=>new Uint8Array(e),Wr=e=>Uint8Array.from(e),qr=(e,t)=>e.toString(16).padStart(t,"0"),Gr=e=>Array.from(Je(e)).map(t=>qr(t,2)).join(""),Ke={_0:48,_9:57,A:65,F:70,a:97,f:102},oo=e=>{if(e>=Ke._0&&e<=Ke._9)return e-Ke._0;if(e>=Ke.A&&e<=Ke.F)return e-(Ke.A-10);if(e>=Ke.a&&e<=Ke.f)return e-(Ke.a-10)},Vr=e=>{const t="hex invalid";if(!Ud(e))return oe(t);const n=e.length,s=n/2;if(n%2)return oe(t);const i=os(s);for(let a=0,o=0;a<s;a++,o+=2){const l=oo(e.charCodeAt(o)),c=oo(e.charCodeAt(o+1));if(l===void 0||c===void 0)return oe(t);i[a]=l*16+c}return i},Qr=()=>globalThis?.crypto,Hd=()=>Qr()?.subtle??oe("crypto.subtle must be defined, consider polyfill"),an=(...e)=>{const t=os(e.reduce((s,i)=>s+Je(i).length,0));let n=0;return e.forEach(s=>{t.set(s,n),n+=s.length}),t},Kd=(e=bt)=>Qr().getRandomValues(os(e)),Hn=BigInt,rt=(e,t,n,s="bad number: out of range")=>Bd(e)&&t<=e&&e<n?e:oe(s),D=(e,t=ue)=>{const n=e%t;return n>=0n?n:t+n},Yr=e=>D(e,Nn),jd=(e,t)=>{(e===0n||t<=0n)&&oe("no inverse n="+e+" mod="+t);let n=D(e,t),s=t,i=0n,a=1n;for(;n!==0n;){const o=s/n,l=s%n,c=i-a*o;s=n,n=l,i=a,a=c}return s===1n?D(i,t):oe("no inverse")},Wd=e=>{const t=el[e];return typeof t!="function"&&oe("hashes."+e+" not set"),t},Ms=e=>e instanceof ke?e:oe("Point expected"),ii=2n**256n;class ke{static BASE;static ZERO;X;Y;Z;T;constructor(t,n,s,i){const a=ii;this.X=rt(t,0n,a),this.Y=rt(n,0n,a),this.Z=rt(s,1n,a),this.T=rt(i,0n,a),Object.freeze(this)}static CURVE(){return jr}static fromAffine(t){return new ke(t.x,t.y,1n,D(t.x*t.y))}static fromBytes(t,n=!1){const s=Is,i=Wr(Je(t,bt)),a=t[31];i[31]=a&-129;const o=Zr(i);rt(o,0n,n?ii:ue);const c=D(o*o),g=D(c-1n),u=D(s*c+1n);let{isValid:p,value:h}=Gd(g,u);p||oe("bad point: y not sqrt");const d=(h&1n)===1n,f=(a&128)!==0;return!n&&h===0n&&f&&oe("bad point: x==0, isLastByteOdd"),f!==d&&(h=D(-h)),new ke(h,o,1n,D(h*o))}static fromHex(t,n){return ke.fromBytes(Vr(t),n)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}assertValidity(){const t=Ls,n=Is,s=this;if(s.is0())return oe("bad point: ZERO");const{X:i,Y:a,Z:o,T:l}=s,c=D(i*i),g=D(a*a),u=D(o*o),p=D(u*u),h=D(c*t),d=D(u*D(h+g)),f=D(p+D(n*D(c*g)));if(d!==f)return oe("bad point: equation left != right (1)");const v=D(i*a),A=D(o*l);return v!==A?oe("bad point: equation left != right (2)"):this}equals(t){const{X:n,Y:s,Z:i}=this,{X:a,Y:o,Z:l}=Ms(t),c=D(n*l),g=D(a*i),u=D(s*l),p=D(o*i);return c===g&&u===p}is0(){return this.equals(Et)}negate(){return new ke(D(-this.X),this.Y,this.Z,D(-this.T))}double(){const{X:t,Y:n,Z:s}=this,i=Ls,a=D(t*t),o=D(n*n),l=D(2n*D(s*s)),c=D(i*a),g=t+n,u=D(D(g*g)-a-o),p=c+o,h=p-l,d=c-o,f=D(u*h),v=D(p*d),A=D(u*d),k=D(h*p);return new ke(f,v,k,A)}add(t){const{X:n,Y:s,Z:i,T:a}=this,{X:o,Y:l,Z:c,T:g}=Ms(t),u=Ls,p=Is,h=D(n*o),d=D(s*l),f=D(a*p*g),v=D(i*c),A=D((n+s)*(o+l)-h-d),k=D(v-f),$=D(v+f),C=D(d-u*h),S=D(A*k),_=D($*C),T=D(A*C),M=D(k*$);return new ke(S,_,M,T)}subtract(t){return this.add(Ms(t).negate())}multiply(t,n=!0){if(!n&&(t===0n||this.is0()))return Et;if(rt(t,1n,Nn),t===1n)return this;if(this.equals(yt))return iu(t).p;let s=Et,i=yt;for(let a=this;t>0n;a=a.double(),t>>=1n)t&1n?s=s.add(a):n&&(i=i.add(a));return s}multiplyUnsafe(t){return this.multiply(t,!1)}toAffine(){const{X:t,Y:n,Z:s}=this;if(this.equals(Et))return{x:0n,y:1n};const i=jd(s,ue);D(s*i)!==1n&&oe("invalid inverse");const a=D(t*i),o=D(n*i);return{x:a,y:o}}toBytes(){const{x:t,y:n}=this.assertValidity().toAffine(),s=Jr(n);return s[31]|=t&1n?128:0,s}toHex(){return Gr(this.toBytes())}clearCofactor(){return this.multiply(Hn(Nd),!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){let t=this.multiply(Nn/2n,!1).double();return Nn%2n&&(t=t.add(this)),t.is0()}}const yt=new ke(io,ao,1n,D(io*ao)),Et=new ke(0n,1n,1n,0n);ke.BASE=yt;ke.ZERO=Et;const Jr=e=>Vr(qr(rt(e,0n,ii),ji)).reverse(),Zr=e=>Hn("0x"+Gr(Wr(Je(e)).reverse())),Me=(e,t)=>{let n=e;for(;t-- >0n;)n*=n,n%=ue;return n},qd=e=>{const n=e*e%ue*e%ue,s=Me(n,2n)*n%ue,i=Me(s,1n)*e%ue,a=Me(i,5n)*i%ue,o=Me(a,10n)*a%ue,l=Me(o,20n)*o%ue,c=Me(l,40n)*l%ue,g=Me(c,80n)*c%ue,u=Me(g,80n)*c%ue,p=Me(u,10n)*a%ue;return{pow_p_5_8:Me(p,2n)*e%ue,b2:n}},ro=0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0n,Gd=(e,t)=>{const n=D(t*t*t),s=D(n*n*t),i=qd(e*s).pow_p_5_8;let a=D(e*n*i);const o=D(t*a*a),l=a,c=D(a*ro),g=o===e,u=o===D(-e),p=o===D(-e*ro);return g&&(a=l),(u||p)&&(a=c),(D(a)&1n)===1n&&(a=D(-a)),{isValid:g||u,value:a}},ai=e=>Yr(Zr(e)),Wi=(...e)=>el.sha512Async(an(...e)),Vd=(...e)=>Wd("sha512")(an(...e)),Xr=e=>{const t=e.slice(0,bt);t[0]&=248,t[31]&=127,t[31]|=64;const n=e.slice(bt,ji),s=ai(t),i=yt.multiply(s),a=i.toBytes();return{head:t,prefix:n,scalar:s,point:i,pointBytes:a}},qi=e=>Wi(Je(e,bt)).then(Xr),Qd=e=>Xr(Vd(Je(e,bt))),Yd=e=>qi(e).then(t=>t.pointBytes),Jd=e=>Wi(e.hashable).then(e.finish),Zd=(e,t,n)=>{const{pointBytes:s,scalar:i}=e,a=ai(t),o=yt.multiply(a).toBytes();return{hashable:an(o,s,n),finish:g=>{const u=Yr(a+ai(g)*i);return Je(an(o,Jr(u)),ji)}}},Xd=async(e,t)=>{const n=Je(e),s=await qi(t),i=await Wi(s.prefix,n);return Jd(Zd(s,i,n))},el={sha512Async:async e=>{const t=Hd(),n=an(e);return os(await t.digest("SHA-512",n.buffer))},sha512:void 0},eu=(e=Kd(bt))=>e,tu={getExtendedPublicKeyAsync:qi,getExtendedPublicKey:Qd,randomSecretKey:eu},Kn=8,nu=256,tl=Math.ceil(nu/Kn)+1,oi=2**(Kn-1),su=()=>{const e=[];let t=yt,n=t;for(let s=0;s<tl;s++){n=t,e.push(n);for(let i=1;i<oi;i++)n=n.add(t),e.push(n);t=n.double()}return e};let lo;const co=(e,t)=>{const n=t.negate();return e?n:t},iu=e=>{const t=lo||(lo=su());let n=Et,s=yt;const i=2**Kn,a=i,o=Hn(i-1),l=Hn(Kn);for(let c=0;c<tl;c++){let g=Number(e&o);e>>=l,g>oi&&(g-=a,e+=1n);const u=c*oi,p=u,h=u+Math.abs(g)-1,d=c%2!==0,f=g<0;g===0?s=s.add(co(d,t[p])):n=n.add(co(f,t[h]))}return e!==0n&&oe("invalid wnaf"),{p:n,f:s}},Rs="winclaw-device-identity-v1";function ri(e){let t="";for(const n of e)t+=String.fromCharCode(n);return btoa(t).replaceAll("+","-").replaceAll("/","_").replace(/=+$/g,"")}function nl(e){const t=e.replaceAll("-","+").replaceAll("_","/"),n=t+"=".repeat((4-t.length%4)%4),s=atob(n),i=new Uint8Array(s.length);for(let a=0;a<s.length;a+=1)i[a]=s.charCodeAt(a);return i}function au(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}async function sl(e){const t=await crypto.subtle.digest("SHA-256",e.slice().buffer);return au(new Uint8Array(t))}async function ou(){const e=tu.randomSecretKey(),t=await Yd(e);return{deviceId:await sl(t),publicKey:ri(t),privateKey:ri(e)}}async function Gi(){try{const n=localStorage.getItem(Rs);if(n){const s=JSON.parse(n);if(s?.version===1&&typeof s.deviceId=="string"&&typeof s.publicKey=="string"&&typeof s.privateKey=="string"){const i=await sl(nl(s.publicKey));if(i!==s.deviceId){const a={...s,deviceId:i};return localStorage.setItem(Rs,JSON.stringify(a)),{deviceId:i,publicKey:s.publicKey,privateKey:s.privateKey}}return{deviceId:s.deviceId,publicKey:s.publicKey,privateKey:s.privateKey}}}}catch{}const e=await ou(),t={version:1,deviceId:e.deviceId,publicKey:e.publicKey,privateKey:e.privateKey,createdAtMs:Date.now()};return localStorage.setItem(Rs,JSON.stringify(t)),e}async function ru(e,t){const n=nl(e),s=new TextEncoder().encode(t),i=await Xd(s,n);return ri(i)}async function Ze(e,t){if(!(!e.client||!e.connected)&&!e.devicesLoading){e.devicesLoading=!0,t?.quiet||(e.devicesError=null);try{const n=await e.client.request("device.pair.list",{});e.devicesList={pending:Array.isArray(n?.pending)?n.pending:[],paired:Array.isArray(n?.paired)?n.paired:[]}}catch(n){t?.quiet||(e.devicesError=String(n))}finally{e.devicesLoading=!1}}}async function lu(e,t){if(!(!e.client||!e.connected))try{await e.client.request("device.pair.approve",{requestId:t}),await Ze(e)}catch(n){e.devicesError=String(n)}}async function cu(e,t){if(!(!e.client||!e.connected||!window.confirm("Reject this device pairing request?")))try{await e.client.request("device.pair.reject",{requestId:t}),await Ze(e)}catch(s){e.devicesError=String(s)}}async function du(e,t){if(!(!e.client||!e.connected))try{const n=await e.client.request("device.token.rotate",t);if(n?.token){const s=await Gi(),i=n.role??t.role;(n.deviceId===s.deviceId||t.deviceId===s.deviceId)&&Hr({deviceId:s.deviceId,role:i,token:n.token,scopes:n.scopes??t.scopes??[]}),window.prompt("New device token (copy and store securely):",n.token)}await Ze(e)}catch(n){e.devicesError=String(n)}}async function uu(e,t){if(!(!e.client||!e.connected||!window.confirm(`Revoke token for ${t.deviceId} (${t.role})?`)))try{await e.client.request("device.token.revoke",t);const s=await Gi();t.deviceId===s.deviceId&&Kr({deviceId:s.deviceId,role:t.role}),await Ze(e)}catch(s){e.devicesError=String(s)}}function gu(e){if(!e||e.kind==="gateway")return{method:"exec.approvals.get",params:{}};const t=e.nodeId.trim();return t?{method:"exec.approvals.node.get",params:{nodeId:t}}:null}function pu(e,t){if(!e||e.kind==="gateway")return{method:"exec.approvals.set",params:t};const n=e.nodeId.trim();return n?{method:"exec.approvals.node.set",params:{...t,nodeId:n}}:null}async function Vi(e,t){if(!(!e.client||!e.connected)&&!e.execApprovalsLoading){e.execApprovalsLoading=!0,e.lastError=null;try{const n=gu(t);if(!n){e.lastError="Select a node before loading exec approvals.";return}const s=await e.client.request(n.method,n.params);fu(e,s)}catch(n){e.lastError=String(n)}finally{e.execApprovalsLoading=!1}}}function fu(e,t){e.execApprovalsSnapshot=t,e.execApprovalsDirty||(e.execApprovalsForm=mt(t.file??{}))}async function hu(e,t){if(!(!e.client||!e.connected)){e.execApprovalsSaving=!0,e.lastError=null;try{const n=e.execApprovalsSnapshot?.hash;if(!n){e.lastError="Exec approvals hash missing; reload and retry.";return}const s=e.execApprovalsForm??e.execApprovalsSnapshot?.file??{},i=pu(t,{file:s,baseHash:n});if(!i){e.lastError="Select a node before saving exec approvals.";return}await e.client.request(i.method,i.params),e.execApprovalsDirty=!1,await Vi(e,t)}catch(n){e.lastError=String(n)}finally{e.execApprovalsSaving=!1}}}function mu(e,t,n){const s=mt(e.execApprovalsForm??e.execApprovalsSnapshot?.file??{});Lr(s,t,n),e.execApprovalsForm=s,e.execApprovalsDirty=!0}function vu(e,t){const n=mt(e.execApprovalsForm??e.execApprovalsSnapshot?.file??{});Ir(n,t),e.execApprovalsForm=n,e.execApprovalsDirty=!0}async function Qi(e){if(!(!e.client||!e.connected)&&!e.personalInfoLoading){e.personalInfoLoading=!0,e.personalInfoError=null,e.personalInfoSuccess=null;try{const t=await e.client.request("personal-info.get",{});e.personalInfo=t,e.personalInfoForm={...t},e.personalInfoDirty=!1}catch(t){e.personalInfoError=String(t)}finally{e.personalInfoLoading=!1}}}async function bu(e){if(!(!e.client||!e.connected||!e.personalInfoForm)){e.personalInfoSaving=!0,e.personalInfoError=null,e.personalInfoSuccess=null;try{const t=await e.client.request("personal-info.save",{employeeId:e.personalInfoForm.employeeId,employeeName:e.personalInfoForm.employeeName,employeeEmail:e.personalInfoForm.employeeEmail});e.personalInfoDirty=!1;let n="保存しました";t.grcSynced?n+=" (GRC同期完了)":t.grcError&&(n+=` (GRC同期失敗: ${t.grcError})`),e.personalInfoSuccess=n,await Qi(e)}catch(t){e.personalInfoError=String(t)}finally{e.personalInfoSaving=!1}}}function yu(e,t,n){e.personalInfoForm&&(e.personalInfoForm={...e.personalInfoForm,[t]:n},e.personalInfoDirty=!0,e.personalInfoSuccess=null)}async function Yi(e){if(!(!e.client||!e.connected)&&!e.presenceLoading){e.presenceLoading=!0,e.presenceError=null,e.presenceStatus=null;try{const t=await e.client.request("system-presence",{});Array.isArray(t)?(e.presenceEntries=t,e.presenceStatus=t.length===0?"No instances yet.":null):(e.presenceEntries=[],e.presenceStatus="No presence payload.")}catch(t){e.presenceError=String(t)}finally{e.presenceLoading=!1}}}async function Xe(e,t){if(!(!e.client||!e.connected)&&!e.sessionsLoading){e.sessionsLoading=!0,e.sessionsError=null;try{const n=t?.includeGlobal??e.sessionsIncludeGlobal,s=t?.includeUnknown??e.sessionsIncludeUnknown,i=t?.activeMinutes??zn(e.sessionsFilterActive,0),a=t?.limit??zn(e.sessionsFilterLimit,0),o={includeGlobal:n,includeUnknown:s,includeDerivedTitles:!0};i>0&&(o.activeMinutes=i),a>0&&(o.limit=a);const l=await e.client.request("sessions.list",o);l&&(e.sessionsResult=l)}catch(n){e.sessionsError=String(n)}finally{e.sessionsLoading=!1}}}async function Ji(e,t,n){if(!e.client||!e.connected)return;const s={key:t};"label"in n&&(s.label=n.label),"thinkingLevel"in n&&(s.thinkingLevel=n.thinkingLevel),"verboseLevel"in n&&(s.verboseLevel=n.verboseLevel),"reasoningLevel"in n&&(s.reasoningLevel=n.reasoningLevel),"model"in n&&(s.model=n.model),"workspace"in n&&(s.workspace=n.workspace);try{await e.client.request("sessions.patch",s),await Xe(e)}catch(i){e.sessionsError=String(i)}}async function xu(e,t){if(!(!e.client||!e.connected||e.sessionsLoading||!window.confirm(`Delete session "${t}"?
126
+ `],{type:"text/plain"}),s=URL.createObjectURL(n),i=document.createElement("a"),a=new Date().toISOString().slice(0,19).replace(/[:T]/g,"-");i.href=s,i.download=`winclaw-logs-${t}-${a}.log`,i.click(),URL.revokeObjectURL(s)}function vd(e){if(typeof ResizeObserver>"u")return;const t=e.querySelector(".topbar");if(!t)return;const n=()=>{const{height:s}=t.getBoundingClientRect();e.style.setProperty("--topbar-height",`${s}px`)};n(),e.topbarObserver=new ResizeObserver(()=>n()),e.topbarObserver.observe(t)}async function ss(e){if(!(!e.client||!e.connected)&&!e.debugLoading){e.debugLoading=!0;try{const[t,n,s,i]=await Promise.all([e.client.request("status",{}),e.client.request("health",{}),e.client.request("models.list",{}),e.client.request("last-heartbeat",{})]);e.debugStatus=t,e.debugHealth=n;const a=s;e.debugModels=Array.isArray(a?.models)?a?.models:[],e.debugHeartbeat=i}catch(t){e.debugCallError=String(t)}finally{e.debugLoading=!1}}}async function bd(e){if(!(!e.client||!e.connected)){e.debugCallError=null,e.debugCallResult=null;try{const t=e.debugCallParams.trim()?JSON.parse(e.debugCallParams):{},n=await e.client.request(e.debugCallMethod.trim(),t);e.debugCallResult=JSON.stringify(n,null,2)}catch(t){e.debugCallError=String(t)}}}const yd=2e3,xd=new Set(["trace","debug","info","warn","error","fatal"]);function wd(e){if(typeof e!="string")return null;const t=e.trim();if(!t.startsWith("{")||!t.endsWith("}"))return null;try{const n=JSON.parse(t);return!n||typeof n!="object"?null:n}catch{return null}}function $d(e){if(typeof e!="string")return null;const t=e.toLowerCase();return xd.has(t)?t:null}function kd(e){if(!e.trim())return{raw:e,message:e};try{const t=JSON.parse(e),n=t&&typeof t._meta=="object"&&t._meta!==null?t._meta:null,s=typeof t.time=="string"?t.time:typeof n?.date=="string"?n?.date:null,i=$d(n?.logLevelName??n?.level),a=typeof t[0]=="string"?t[0]:typeof n?.name=="string"?n?.name:null,o=wd(a);let l=null;o&&(typeof o.subsystem=="string"?l=o.subsystem:typeof o.module=="string"&&(l=o.module)),!l&&a&&a.length<120&&(l=a);let c=null;return typeof t[1]=="string"?c=t[1]:!o&&typeof t[0]=="string"?c=t[0]:typeof t.message=="string"&&(c=t.message),{raw:e,time:s,level:i,subsystem:l,message:c??e,meta:n??void 0}}catch{return{raw:e,message:e}}}async function Pi(e,t){if(!(!e.client||!e.connected)&&!(e.logsLoading&&!t?.quiet)){t?.quiet||(e.logsLoading=!0),e.logsError=null;try{const s=await e.client.request("logs.tail",{cursor:t?.reset?void 0:e.logsCursor??void 0,limit:e.logsLimit,maxBytes:e.logsMaxBytes}),a=(Array.isArray(s.lines)?s.lines.filter(l=>typeof l=="string"):[]).map(kd),o=!!(t?.reset||s.reset||e.logsCursor==null);e.logsEntries=o?a:[...e.logsEntries,...a].slice(-yd),typeof s.cursor=="number"&&(e.logsCursor=s.cursor),typeof s.file=="string"&&(e.logsFile=s.file),e.logsTruncated=!!s.truncated,e.logsLastFetchAt=Date.now()}catch(n){e.logsError=String(n)}finally{t?.quiet||(e.logsLoading=!1)}}}async function is(e,t){if(!(!e.client||!e.connected)&&!e.nodesLoading){e.nodesLoading=!0,t?.quiet||(e.lastError=null);try{const n=await e.client.request("node.list",{});e.nodes=Array.isArray(n.nodes)?n.nodes:[]}catch(n){t?.quiet||(e.lastError=String(n))}finally{e.nodesLoading=!1}}}function Sd(e){e.nodesPollInterval==null&&(e.nodesPollInterval=window.setInterval(()=>{is(e,{quiet:!0})},5e3))}function Ad(e){e.nodesPollInterval!=null&&(clearInterval(e.nodesPollInterval),e.nodesPollInterval=null)}function Di(e){e.logsPollInterval==null&&(e.logsPollInterval=window.setInterval(()=>{e.tab==="logs"&&Pi(e,{quiet:!0})},2e3))}function Fi(e){e.logsPollInterval!=null&&(clearInterval(e.logsPollInterval),e.logsPollInterval=null)}function Ni(e){e.debugPollInterval==null&&(e.debugPollInterval=window.setInterval(()=>{e.tab==="debug"&&ss(e)},3e3))}function Oi(e){e.debugPollInterval!=null&&(clearInterval(e.debugPollInterval),e.debugPollInterval=null)}async function Fr(e,t){if(!(!e.client||!e.connected||e.agentIdentityLoading)&&!e.agentIdentityById[t]){e.agentIdentityLoading=!0,e.agentIdentityError=null;try{const n=await e.client.request("agent.identity.get",{agentId:t});n&&(e.agentIdentityById={...e.agentIdentityById,[t]:n})}catch(n){e.agentIdentityError=String(n)}finally{e.agentIdentityLoading=!1}}}async function Nr(e,t){if(!e.client||!e.connected||e.agentIdentityLoading)return;const n=t.filter(s=>!e.agentIdentityById[s]);if(n.length!==0){e.agentIdentityLoading=!0,e.agentIdentityError=null;try{for(const s of n){const i=await e.client.request("agent.identity.get",{agentId:s});i&&(e.agentIdentityById={...e.agentIdentityById,[s]:i})}}catch(s){e.agentIdentityError=String(s)}finally{e.agentIdentityLoading=!1}}}async function Fn(e,t){if(!(!e.client||!e.connected)&&!e.agentSkillsLoading){e.agentSkillsLoading=!0,e.agentSkillsError=null;try{const n=await e.client.request("skills.status",{agentId:t});n&&(e.agentSkillsReport=n,e.agentSkillsAgentId=t)}catch(n){e.agentSkillsError=String(n)}finally{e.agentSkillsLoading=!1}}}async function Bi(e,t){if(!(!e.client||!e.connected)&&!e.agentsLoading){e.agentsLoading=!0,e.agentsError=null;try{const n=await e.client.request("agents.list",{});if(n){e.agentsList=n;const s=e.agentsSelectedId,i=n.agents.some(a=>a.id===s);(!s||!i)&&(e.agentsSelectedId=n.defaultId??n.agents[0]?.id??null)}}catch(n){e.agentsError=String(n)}finally{e.agentsLoading=!1}}}function Ui(e,t){if(e==null||!Number.isFinite(e)||e<=0)return;if(e<1e3)return`${Math.round(e)}ms`;const n=t?.spaced?" ":"",s=Math.round(e/1e3),i=Math.floor(s/3600),a=Math.floor(s%3600/60),o=s%60;if(i>=24){const l=Math.floor(i/24),c=i%24;return c>0?`${l}d${n}${c}h`:`${l}d`}return i>0?a>0?`${i}h${n}${a}m`:`${i}h`:a>0?o>0?`${a}m${n}${o}s`:`${a}m`:`${o}s`}function zi(e,t="n/a"){if(e==null||!Number.isFinite(e)||e<0)return t;if(e<1e3)return`${Math.round(e)}ms`;const n=Math.round(e/1e3);if(n<60)return`${n}s`;const s=Math.round(n/60);if(s<60)return`${s}m`;const i=Math.round(s/60);return i<24?`${i}h`:`${Math.round(i/24)}d`}function V(e,t){const n=t?.fallback??"n/a";if(e==null||!Number.isFinite(e))return n;const s=Date.now()-e,i=Math.abs(s),a=s>=0,o=Math.round(i/1e3);if(o<60)return a?"just now":"in <1m";const l=Math.round(o/60);if(l<60)return a?`${l}m ago`:`in ${l}m`;const c=Math.round(l/60);if(c<48)return a?`${c}h ago`:`in ${c}h`;const g=Math.round(c/24);return a?`${g}d ago`:`in ${g}d`}function to(e){const t=[],n=/(^|\n)(```|~~~)[^\n]*\n[\s\S]*?(?:\n\2(?:\n|$)|$)/g;for(const i of e.matchAll(n)){const a=(i.index??0)+i[1].length;t.push({start:a,end:a+i[0].length-i[1].length})}const s=/`+[^`]+`+/g;for(const i of e.matchAll(s)){const a=i.index??0,o=a+i[0].length;t.some(c=>a>=c.start&&o<=c.end)||t.push({start:a,end:o})}return t.sort((i,a)=>i.start-a.start),t}function no(e,t){return t.some(n=>e>=n.start&&e<n.end)}const Cd=/<\s*\/?\s*(?:think(?:ing)?|thought|antthinking|final)\b/i,$n=/<\s*\/?\s*final\b[^<>]*>/gi,so=/<\s*(\/?)\s*(?:think(?:ing)?|thought|antthinking)\b[^<>]*>/gi;function Td(e,t){return e.trimStart()}function _d(e,t){if(!e||!Cd.test(e))return e;let n=e;if($n.test(n)){$n.lastIndex=0;const l=[],c=to(n);for(const g of n.matchAll($n)){const u=g.index??0;l.push({start:u,length:g[0].length,inCode:no(u,c)})}for(let g=l.length-1;g>=0;g--){const u=l[g];u.inCode||(n=n.slice(0,u.start)+n.slice(u.start+u.length))}}else $n.lastIndex=0;const s=to(n);so.lastIndex=0;let i="",a=0,o=!1;for(const l of n.matchAll(so)){const c=l.index??0,g=l[1]==="/";no(c,s)||(o?g&&(o=!1):(i+=n.slice(a,c),g||(o=!0)),a=c+l[0].length)}return i+=n.slice(a),Td(i)}function vt(e){return!e&&e!==0?"n/a":new Date(e).toLocaleString()}function ni(e){return!e||e.length===0?"none":e.filter(t=>!!(t&&t.trim())).join(", ")}function si(e,t=120){return e.length<=t?e:`${e.slice(0,Math.max(0,t-1))}…`}function Or(e,t){return e.length<=t?{text:e,truncated:!1,total:e.length}:{text:e.slice(0,Math.max(0,t)),truncated:!0,total:e.length}}function zn(e,t){const n=Number(e);return Number.isFinite(n)?n:t}function Es(e){return _d(e)}async function dn(e){if(!(!e.client||!e.connected))try{const t=await e.client.request("cron.status",{});e.cronStatus=t}catch(t){e.cronError=String(t)}}async function as(e){if(!(!e.client||!e.connected)&&!e.cronLoading){e.cronLoading=!0,e.cronError=null;try{const t=await e.client.request("cron.list",{includeDisabled:!0});e.cronJobs=Array.isArray(t.jobs)?t.jobs:[]}catch(t){e.cronError=String(t)}finally{e.cronLoading=!1}}}function Ed(e){if(e.scheduleKind==="at"){const n=Date.parse(e.scheduleAt);if(!Number.isFinite(n))throw new Error("Invalid run time.");return{kind:"at",at:new Date(n).toISOString()}}if(e.scheduleKind==="every"){const n=zn(e.everyAmount,0);if(n<=0)throw new Error("Invalid interval amount.");const s=e.everyUnit;return{kind:"every",everyMs:n*(s==="minutes"?6e4:s==="hours"?36e5:864e5)}}const t=e.cronExpr.trim();if(!t)throw new Error("Cron expression required.");return{kind:"cron",expr:t,tz:e.cronTz.trim()||void 0}}function Ld(e){if(e.payloadKind==="systemEvent"){const i=e.payloadText.trim();if(!i)throw new Error("System event text required.");return{kind:"systemEvent",text:i}}const t=e.payloadText.trim();if(!t)throw new Error("Agent message required.");const n={kind:"agentTurn",message:t},s=zn(e.timeoutSeconds,0);return s>0&&(n.timeoutSeconds=s),n}async function Id(e){if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{const t=Ed(e.cronForm),n=Ld(e.cronForm),s=e.cronForm.sessionTarget==="isolated"&&e.cronForm.payloadKind==="agentTurn"&&e.cronForm.deliveryMode?{mode:e.cronForm.deliveryMode==="announce"?"announce":"none",channel:e.cronForm.deliveryChannel.trim()||"last",to:e.cronForm.deliveryTo.trim()||void 0}:void 0,i=e.cronForm.agentId.trim(),a={name:e.cronForm.name.trim(),description:e.cronForm.description.trim()||void 0,agentId:i||void 0,enabled:e.cronForm.enabled,schedule:t,sessionTarget:e.cronForm.sessionTarget,wakeMode:e.cronForm.wakeMode,payload:n,delivery:s};if(!a.name)throw new Error("Name required.");await e.client.request("cron.add",a),e.cronForm={...e.cronForm,name:"",description:"",payloadText:""},await as(e),await dn(e)}catch(t){e.cronError=String(t)}finally{e.cronBusy=!1}}}async function Md(e,t,n){if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{await e.client.request("cron.update",{id:t.id,patch:{enabled:n}}),await as(e),await dn(e)}catch(s){e.cronError=String(s)}finally{e.cronBusy=!1}}}async function Rd(e,t){if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{await e.client.request("cron.run",{id:t.id,mode:"force"}),await Br(e,t.id)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function Pd(e,t){if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{await e.client.request("cron.remove",{id:t.id}),e.cronRunsJobId===t.id&&(e.cronRunsJobId=null,e.cronRuns=[]),await as(e),await dn(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function Br(e,t){if(!(!e.client||!e.connected))try{const n=await e.client.request("cron.runs",{id:t,limit:50});e.cronRunsJobId=t,e.cronRuns=Array.isArray(n.entries)?n.entries:[]}catch(n){e.cronError=String(n)}}const Ur="winclaw.device.auth.v1";function Hi(e){return e.trim()}function Dd(e){if(!Array.isArray(e))return[];const t=new Set;for(const n of e){const s=n.trim();s&&t.add(s)}return[...t].toSorted()}function Ki(){try{const e=window.localStorage.getItem(Ur);if(!e)return null;const t=JSON.parse(e);return!t||t.version!==1||!t.deviceId||typeof t.deviceId!="string"||!t.tokens||typeof t.tokens!="object"?null:t}catch{return null}}function zr(e){try{window.localStorage.setItem(Ur,JSON.stringify(e))}catch{}}function Fd(e){const t=Ki();if(!t||t.deviceId!==e.deviceId)return null;const n=Hi(e.role),s=t.tokens[n];return!s||typeof s.token!="string"?null:s}function Hr(e){const t=Hi(e.role),n={version:1,deviceId:e.deviceId,tokens:{}},s=Ki();s&&s.deviceId===e.deviceId&&(n.tokens={...s.tokens});const i={token:e.token,role:t,scopes:Dd(e.scopes),updatedAtMs:Date.now()};return n.tokens[t]=i,zr(n),i}function Kr(e){const t=Ki();if(!t||t.deviceId!==e.deviceId)return;const n=Hi(e.role);if(!t.tokens[n])return;const s={...t,tokens:{...t.tokens}};delete s.tokens[n],zr(s)}const jr={p:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,n:0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3edn,h:8n,a:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffecn,d:0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3n,Gx:0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,Gy:0x6666666666666666666666666666666666666666666666666666666666666658n},{p:ue,n:Nn,Gx:io,Gy:ao,a:Ls,d:Is,h:Nd}=jr,bt=32,ji=64,Od=(...e)=>{"captureStackTrace"in Error&&typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(...e)},oe=(e="")=>{const t=new Error(e);throw Od(t,oe),t},Bd=e=>typeof e=="bigint",Ud=e=>typeof e=="string",zd=e=>e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array",Je=(e,t,n="")=>{const s=zd(e),i=e?.length,a=t!==void 0;if(!s||a&&i!==t){const o=n&&`"${n}" `,l=a?` of length ${t}`:"",c=s?`length=${i}`:`type=${typeof e}`;oe(o+"expected Uint8Array"+l+", got "+c)}return e},os=e=>new Uint8Array(e),Wr=e=>Uint8Array.from(e),qr=(e,t)=>e.toString(16).padStart(t,"0"),Gr=e=>Array.from(Je(e)).map(t=>qr(t,2)).join(""),Ke={_0:48,_9:57,A:65,F:70,a:97,f:102},oo=e=>{if(e>=Ke._0&&e<=Ke._9)return e-Ke._0;if(e>=Ke.A&&e<=Ke.F)return e-(Ke.A-10);if(e>=Ke.a&&e<=Ke.f)return e-(Ke.a-10)},Vr=e=>{const t="hex invalid";if(!Ud(e))return oe(t);const n=e.length,s=n/2;if(n%2)return oe(t);const i=os(s);for(let a=0,o=0;a<s;a++,o+=2){const l=oo(e.charCodeAt(o)),c=oo(e.charCodeAt(o+1));if(l===void 0||c===void 0)return oe(t);i[a]=l*16+c}return i},Qr=()=>globalThis?.crypto,Hd=()=>Qr()?.subtle??oe("crypto.subtle must be defined, consider polyfill"),an=(...e)=>{const t=os(e.reduce((s,i)=>s+Je(i).length,0));let n=0;return e.forEach(s=>{t.set(s,n),n+=s.length}),t},Kd=(e=bt)=>Qr().getRandomValues(os(e)),Hn=BigInt,rt=(e,t,n,s="bad number: out of range")=>Bd(e)&&t<=e&&e<n?e:oe(s),D=(e,t=ue)=>{const n=e%t;return n>=0n?n:t+n},Yr=e=>D(e,Nn),jd=(e,t)=>{(e===0n||t<=0n)&&oe("no inverse n="+e+" mod="+t);let n=D(e,t),s=t,i=0n,a=1n;for(;n!==0n;){const o=s/n,l=s%n,c=i-a*o;s=n,n=l,i=a,a=c}return s===1n?D(i,t):oe("no inverse")},Wd=e=>{const t=el[e];return typeof t!="function"&&oe("hashes."+e+" not set"),t},Ms=e=>e instanceof ke?e:oe("Point expected"),ii=2n**256n;class ke{static BASE;static ZERO;X;Y;Z;T;constructor(t,n,s,i){const a=ii;this.X=rt(t,0n,a),this.Y=rt(n,0n,a),this.Z=rt(s,1n,a),this.T=rt(i,0n,a),Object.freeze(this)}static CURVE(){return jr}static fromAffine(t){return new ke(t.x,t.y,1n,D(t.x*t.y))}static fromBytes(t,n=!1){const s=Is,i=Wr(Je(t,bt)),a=t[31];i[31]=a&-129;const o=Zr(i);rt(o,0n,n?ii:ue);const c=D(o*o),g=D(c-1n),u=D(s*c+1n);let{isValid:p,value:h}=Gd(g,u);p||oe("bad point: y not sqrt");const d=(h&1n)===1n,f=(a&128)!==0;return!n&&h===0n&&f&&oe("bad point: x==0, isLastByteOdd"),f!==d&&(h=D(-h)),new ke(h,o,1n,D(h*o))}static fromHex(t,n){return ke.fromBytes(Vr(t),n)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}assertValidity(){const t=Ls,n=Is,s=this;if(s.is0())return oe("bad point: ZERO");const{X:i,Y:a,Z:o,T:l}=s,c=D(i*i),g=D(a*a),u=D(o*o),p=D(u*u),h=D(c*t),d=D(u*D(h+g)),f=D(p+D(n*D(c*g)));if(d!==f)return oe("bad point: equation left != right (1)");const v=D(i*a),A=D(o*l);return v!==A?oe("bad point: equation left != right (2)"):this}equals(t){const{X:n,Y:s,Z:i}=this,{X:a,Y:o,Z:l}=Ms(t),c=D(n*l),g=D(a*i),u=D(s*l),p=D(o*i);return c===g&&u===p}is0(){return this.equals(Et)}negate(){return new ke(D(-this.X),this.Y,this.Z,D(-this.T))}double(){const{X:t,Y:n,Z:s}=this,i=Ls,a=D(t*t),o=D(n*n),l=D(2n*D(s*s)),c=D(i*a),g=t+n,u=D(D(g*g)-a-o),p=c+o,h=p-l,d=c-o,f=D(u*h),v=D(p*d),A=D(u*d),k=D(h*p);return new ke(f,v,k,A)}add(t){const{X:n,Y:s,Z:i,T:a}=this,{X:o,Y:l,Z:c,T:g}=Ms(t),u=Ls,p=Is,h=D(n*o),d=D(s*l),f=D(a*p*g),v=D(i*c),A=D((n+s)*(o+l)-h-d),k=D(v-f),$=D(v+f),C=D(d-u*h),S=D(A*k),_=D($*C),T=D(A*C),M=D(k*$);return new ke(S,_,M,T)}subtract(t){return this.add(Ms(t).negate())}multiply(t,n=!0){if(!n&&(t===0n||this.is0()))return Et;if(rt(t,1n,Nn),t===1n)return this;if(this.equals(yt))return iu(t).p;let s=Et,i=yt;for(let a=this;t>0n;a=a.double(),t>>=1n)t&1n?s=s.add(a):n&&(i=i.add(a));return s}multiplyUnsafe(t){return this.multiply(t,!1)}toAffine(){const{X:t,Y:n,Z:s}=this;if(this.equals(Et))return{x:0n,y:1n};const i=jd(s,ue);D(s*i)!==1n&&oe("invalid inverse");const a=D(t*i),o=D(n*i);return{x:a,y:o}}toBytes(){const{x:t,y:n}=this.assertValidity().toAffine(),s=Jr(n);return s[31]|=t&1n?128:0,s}toHex(){return Gr(this.toBytes())}clearCofactor(){return this.multiply(Hn(Nd),!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){let t=this.multiply(Nn/2n,!1).double();return Nn%2n&&(t=t.add(this)),t.is0()}}const yt=new ke(io,ao,1n,D(io*ao)),Et=new ke(0n,1n,1n,0n);ke.BASE=yt;ke.ZERO=Et;const Jr=e=>Vr(qr(rt(e,0n,ii),ji)).reverse(),Zr=e=>Hn("0x"+Gr(Wr(Je(e)).reverse())),Me=(e,t)=>{let n=e;for(;t-- >0n;)n*=n,n%=ue;return n},qd=e=>{const n=e*e%ue*e%ue,s=Me(n,2n)*n%ue,i=Me(s,1n)*e%ue,a=Me(i,5n)*i%ue,o=Me(a,10n)*a%ue,l=Me(o,20n)*o%ue,c=Me(l,40n)*l%ue,g=Me(c,80n)*c%ue,u=Me(g,80n)*c%ue,p=Me(u,10n)*a%ue;return{pow_p_5_8:Me(p,2n)*e%ue,b2:n}},ro=0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0n,Gd=(e,t)=>{const n=D(t*t*t),s=D(n*n*t),i=qd(e*s).pow_p_5_8;let a=D(e*n*i);const o=D(t*a*a),l=a,c=D(a*ro),g=o===e,u=o===D(-e),p=o===D(-e*ro);return g&&(a=l),(u||p)&&(a=c),(D(a)&1n)===1n&&(a=D(-a)),{isValid:g||u,value:a}},ai=e=>Yr(Zr(e)),Wi=(...e)=>el.sha512Async(an(...e)),Vd=(...e)=>Wd("sha512")(an(...e)),Xr=e=>{const t=e.slice(0,bt);t[0]&=248,t[31]&=127,t[31]|=64;const n=e.slice(bt,ji),s=ai(t),i=yt.multiply(s),a=i.toBytes();return{head:t,prefix:n,scalar:s,point:i,pointBytes:a}},qi=e=>Wi(Je(e,bt)).then(Xr),Qd=e=>Xr(Vd(Je(e,bt))),Yd=e=>qi(e).then(t=>t.pointBytes),Jd=e=>Wi(e.hashable).then(e.finish),Zd=(e,t,n)=>{const{pointBytes:s,scalar:i}=e,a=ai(t),o=yt.multiply(a).toBytes();return{hashable:an(o,s,n),finish:g=>{const u=Yr(a+ai(g)*i);return Je(an(o,Jr(u)),ji)}}},Xd=async(e,t)=>{const n=Je(e),s=await qi(t),i=await Wi(s.prefix,n);return Jd(Zd(s,i,n))},el={sha512Async:async e=>{const t=Hd(),n=an(e);return os(await t.digest("SHA-512",n.buffer))},sha512:void 0},eu=(e=Kd(bt))=>e,tu={getExtendedPublicKeyAsync:qi,getExtendedPublicKey:Qd,randomSecretKey:eu},Kn=8,nu=256,tl=Math.ceil(nu/Kn)+1,oi=2**(Kn-1),su=()=>{const e=[];let t=yt,n=t;for(let s=0;s<tl;s++){n=t,e.push(n);for(let i=1;i<oi;i++)n=n.add(t),e.push(n);t=n.double()}return e};let lo;const co=(e,t)=>{const n=t.negate();return e?n:t},iu=e=>{const t=lo||(lo=su());let n=Et,s=yt;const i=2**Kn,a=i,o=Hn(i-1),l=Hn(Kn);for(let c=0;c<tl;c++){let g=Number(e&o);e>>=l,g>oi&&(g-=a,e+=1n);const u=c*oi,p=u,h=u+Math.abs(g)-1,d=c%2!==0,f=g<0;g===0?s=s.add(co(d,t[p])):n=n.add(co(f,t[h]))}return e!==0n&&oe("invalid wnaf"),{p:n,f:s}},Rs="winclaw-device-identity-v1";function ri(e){let t="";for(const n of e)t+=String.fromCharCode(n);return btoa(t).replaceAll("+","-").replaceAll("/","_").replace(/=+$/g,"")}function nl(e){const t=e.replaceAll("-","+").replaceAll("_","/"),n=t+"=".repeat((4-t.length%4)%4),s=atob(n),i=new Uint8Array(s.length);for(let a=0;a<s.length;a+=1)i[a]=s.charCodeAt(a);return i}function au(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}async function sl(e){const t=await crypto.subtle.digest("SHA-256",e.slice().buffer);return au(new Uint8Array(t))}async function ou(){const e=tu.randomSecretKey(),t=await Yd(e);return{deviceId:await sl(t),publicKey:ri(t),privateKey:ri(e)}}async function Gi(){try{const n=localStorage.getItem(Rs);if(n){const s=JSON.parse(n);if(s?.version===1&&typeof s.deviceId=="string"&&typeof s.publicKey=="string"&&typeof s.privateKey=="string"){const i=await sl(nl(s.publicKey));if(i!==s.deviceId){const a={...s,deviceId:i};return localStorage.setItem(Rs,JSON.stringify(a)),{deviceId:i,publicKey:s.publicKey,privateKey:s.privateKey}}return{deviceId:s.deviceId,publicKey:s.publicKey,privateKey:s.privateKey}}}}catch{}const e=await ou(),t={version:1,deviceId:e.deviceId,publicKey:e.publicKey,privateKey:e.privateKey,createdAtMs:Date.now()};return localStorage.setItem(Rs,JSON.stringify(t)),e}async function ru(e,t){const n=nl(e),s=new TextEncoder().encode(t),i=await Xd(s,n);return ri(i)}async function Ze(e,t){if(!(!e.client||!e.connected)&&!e.devicesLoading){e.devicesLoading=!0,t?.quiet||(e.devicesError=null);try{const n=await e.client.request("device.pair.list",{});e.devicesList={pending:Array.isArray(n?.pending)?n.pending:[],paired:Array.isArray(n?.paired)?n.paired:[]}}catch(n){t?.quiet||(e.devicesError=String(n))}finally{e.devicesLoading=!1}}}async function lu(e,t){if(!(!e.client||!e.connected))try{await e.client.request("device.pair.approve",{requestId:t}),await Ze(e)}catch(n){e.devicesError=String(n)}}async function cu(e,t){if(!(!e.client||!e.connected||!window.confirm("Reject this device pairing request?")))try{await e.client.request("device.pair.reject",{requestId:t}),await Ze(e)}catch(s){e.devicesError=String(s)}}async function du(e,t){if(!(!e.client||!e.connected))try{const n=await e.client.request("device.token.rotate",t);if(n?.token){const s=await Gi(),i=n.role??t.role;(n.deviceId===s.deviceId||t.deviceId===s.deviceId)&&Hr({deviceId:s.deviceId,role:i,token:n.token,scopes:n.scopes??t.scopes??[]}),window.prompt("New device token (copy and store securely):",n.token)}await Ze(e)}catch(n){e.devicesError=String(n)}}async function uu(e,t){if(!(!e.client||!e.connected||!window.confirm(`Revoke token for ${t.deviceId} (${t.role})?`)))try{await e.client.request("device.token.revoke",t);const s=await Gi();t.deviceId===s.deviceId&&Kr({deviceId:s.deviceId,role:t.role}),await Ze(e)}catch(s){e.devicesError=String(s)}}function gu(e){if(!e||e.kind==="gateway")return{method:"exec.approvals.get",params:{}};const t=e.nodeId.trim();return t?{method:"exec.approvals.node.get",params:{nodeId:t}}:null}function pu(e,t){if(!e||e.kind==="gateway")return{method:"exec.approvals.set",params:t};const n=e.nodeId.trim();return n?{method:"exec.approvals.node.set",params:{...t,nodeId:n}}:null}async function Vi(e,t){if(!(!e.client||!e.connected)&&!e.execApprovalsLoading){e.execApprovalsLoading=!0,e.lastError=null;try{const n=gu(t);if(!n){e.lastError="Select a node before loading exec approvals.";return}const s=await e.client.request(n.method,n.params);fu(e,s)}catch(n){e.lastError=String(n)}finally{e.execApprovalsLoading=!1}}}function fu(e,t){e.execApprovalsSnapshot=t,e.execApprovalsDirty||(e.execApprovalsForm=mt(t.file??{}))}async function hu(e,t){if(!(!e.client||!e.connected)){e.execApprovalsSaving=!0,e.lastError=null;try{const n=e.execApprovalsSnapshot?.hash;if(!n){e.lastError="Exec approvals hash missing; reload and retry.";return}const s=e.execApprovalsForm??e.execApprovalsSnapshot?.file??{},i=pu(t,{file:s,baseHash:n});if(!i){e.lastError="Select a node before saving exec approvals.";return}await e.client.request(i.method,i.params),e.execApprovalsDirty=!1,await Vi(e,t)}catch(n){e.lastError=String(n)}finally{e.execApprovalsSaving=!1}}}function mu(e,t,n){const s=mt(e.execApprovalsForm??e.execApprovalsSnapshot?.file??{});Lr(s,t,n),e.execApprovalsForm=s,e.execApprovalsDirty=!0}function vu(e,t){const n=mt(e.execApprovalsForm??e.execApprovalsSnapshot?.file??{});Ir(n,t),e.execApprovalsForm=n,e.execApprovalsDirty=!0}async function Qi(e){if(!(!e.client||!e.connected)&&!e.personalInfoLoading){e.personalInfoLoading=!0,e.personalInfoError=null,e.personalInfoSuccess=null;try{const t=await e.client.request("personal-info.get",{});e.personalInfo=t,e.personalInfoForm={...t},e.personalInfoDirty=!1}catch(t){e.personalInfoError=String(t)}finally{e.personalInfoLoading=!1}}}async function bu(e){if(!(!e.client||!e.connected||!e.personalInfoForm)){e.personalInfoSaving=!0,e.personalInfoError=null,e.personalInfoSuccess=null;try{const t=await e.client.request("personal-info.save",{employeeId:e.personalInfoForm.employeeId,employeeName:e.personalInfoForm.employeeName,employeeEmail:e.personalInfoForm.employeeEmail,grcUrl:e.personalInfoForm.grcUrl});e.personalInfoDirty=!1;let n="保存しました";t.grcSynced?n+=" (GRC同期完了)":t.grcError&&(n+=` (GRC同期失敗: ${t.grcError})`),e.personalInfoSuccess=n,await Qi(e)}catch(t){e.personalInfoError=String(t)}finally{e.personalInfoSaving=!1}}}function yu(e,t,n){e.personalInfoForm&&(e.personalInfoForm={...e.personalInfoForm,[t]:n},e.personalInfoDirty=!0,e.personalInfoSuccess=null)}async function Yi(e){if(!(!e.client||!e.connected)&&!e.presenceLoading){e.presenceLoading=!0,e.presenceError=null,e.presenceStatus=null;try{const t=await e.client.request("system-presence",{});Array.isArray(t)?(e.presenceEntries=t,e.presenceStatus=t.length===0?"No instances yet.":null):(e.presenceEntries=[],e.presenceStatus="No presence payload.")}catch(t){e.presenceError=String(t)}finally{e.presenceLoading=!1}}}async function Xe(e,t){if(!(!e.client||!e.connected)&&!e.sessionsLoading){e.sessionsLoading=!0,e.sessionsError=null;try{const n=t?.includeGlobal??e.sessionsIncludeGlobal,s=t?.includeUnknown??e.sessionsIncludeUnknown,i=t?.activeMinutes??zn(e.sessionsFilterActive,0),a=t?.limit??zn(e.sessionsFilterLimit,0),o={includeGlobal:n,includeUnknown:s,includeDerivedTitles:!0};i>0&&(o.activeMinutes=i),a>0&&(o.limit=a);const l=await e.client.request("sessions.list",o);l&&(e.sessionsResult=l)}catch(n){e.sessionsError=String(n)}finally{e.sessionsLoading=!1}}}async function Ji(e,t,n){if(!e.client||!e.connected)return;const s={key:t};"label"in n&&(s.label=n.label),"thinkingLevel"in n&&(s.thinkingLevel=n.thinkingLevel),"verboseLevel"in n&&(s.verboseLevel=n.verboseLevel),"reasoningLevel"in n&&(s.reasoningLevel=n.reasoningLevel),"model"in n&&(s.model=n.model),"workspace"in n&&(s.workspace=n.workspace);try{await e.client.request("sessions.patch",s),await Xe(e)}catch(i){e.sessionsError=String(i)}}async function xu(e,t){if(!(!e.client||!e.connected||e.sessionsLoading||!window.confirm(`Delete session "${t}"?
127
127
 
128
128
  Deletes the session entry and archives its transcript.`))){e.sessionsLoading=!0,e.sessionsError=null;try{await e.client.request("sessions.delete",{key:t,deleteTranscript:!0}),await Xe(e)}catch(s){e.sessionsError=String(s)}finally{e.sessionsLoading=!1}}}function Rt(e,t,n){if(!t.trim())return;const s={...e.skillMessages};n?s[t]=n:delete s[t],e.skillMessages=s}function rs(e){return e instanceof Error?e.message:String(e)}async function un(e,t){if(t?.clearMessages&&Object.keys(e.skillMessages).length>0&&(e.skillMessages={}),!(!e.client||!e.connected)&&!e.skillsLoading){e.skillsLoading=!0,e.skillsError=null;try{const n=await e.client.request("skills.status",{});n&&(e.skillsReport=n)}catch(n){e.skillsError=rs(n)}finally{e.skillsLoading=!1}}}function wu(e,t,n){e.skillEdits={...e.skillEdits,[t]:n}}async function $u(e,t,n){if(!(!e.client||!e.connected)){e.skillsBusyKey=t,e.skillsError=null;try{await e.client.request("skills.update",{skillKey:t,enabled:n}),await un(e),Rt(e,t,{kind:"success",message:n?"Skill enabled":"Skill disabled"})}catch(s){const i=rs(s);e.skillsError=i,Rt(e,t,{kind:"error",message:i})}finally{e.skillsBusyKey=null}}}async function ku(e,t){if(!(!e.client||!e.connected)){e.skillsBusyKey=t,e.skillsError=null;try{const n=e.skillEdits[t]??"";await e.client.request("skills.update",{skillKey:t,apiKey:n}),await un(e),Rt(e,t,{kind:"success",message:"API key saved"})}catch(n){const s=rs(n);e.skillsError=s,Rt(e,t,{kind:"error",message:s})}finally{e.skillsBusyKey=null}}}async function Su(e,t,n,s){if(!(!e.client||!e.connected)){e.skillsBusyKey=t,e.skillsError=null;try{const i=await e.client.request("skills.install",{name:n,installId:s,timeoutMs:12e4});await un(e),Rt(e,t,{kind:"success",message:i?.message??"Installed"})}catch(i){const a=rs(i);e.skillsError=a,Rt(e,t,{kind:"error",message:a})}finally{e.skillsBusyKey=null}}}const il={agents:"/agents",overview:"/overview",channels:"/channels",instances:"/instances",sessions:"/sessions",usage:"/usage",cron:"/cron",skills:"/skills",nodes:"/nodes",chat:"/chat",personal:"/personal",config:"/config",debug:"/debug",logs:"/logs"},al=new Map(Object.entries(il).map(([e,t])=>[t,e]));function gn(e){if(!e)return"";let t=e.trim();return t.startsWith("/")||(t=`/${t}`),t==="/"?"":(t.endsWith("/")&&(t=t.slice(0,-1)),t)}function on(e){if(!e)return"/";let t=e.trim();return t.startsWith("/")||(t=`/${t}`),t.length>1&&t.endsWith("/")&&(t=t.slice(0,-1)),t}function Zi(e,t=""){const n=gn(t),s=il[e];return n?`${n}${s}`:s}function ol(e,t=""){const n=gn(t);let s=e||"/";n&&(s===n?s="/":s.startsWith(`${n}/`)&&(s=s.slice(n.length)));let i=on(s).toLowerCase();return i.endsWith("/index.html")&&(i="/"),i==="/"?"chat":al.get(i)??null}function Au(e){let t=on(e);if(t.endsWith("/index.html")&&(t=on(t.slice(0,-11))),t==="/")return"";const n=t.split("/").filter(Boolean);if(n.length===0)return"";for(let s=0;s<n.length;s++){const i=`/${n.slice(s).join("/")}`.toLowerCase();if(al.has(i)){const a=n.slice(0,s);return a.length?`/${a.join("/")}`:""}}return`/${n.join("/")}`}function Cu(e){switch(e){case"agents":return"folder";case"chat":return"messageSquare";case"overview":return"barChart";case"channels":return"link";case"instances":return"radio";case"sessions":return"fileText";case"usage":return"barChart";case"cron":return"loader";case"skills":return"zap";case"nodes":return"monitor";case"personal":return"user";case"config":return"settings";case"debug":return"bug";case"logs":return"scrollText";default:return"folder"}}function li(e){switch(e){case"agents":return"Agents";case"overview":return"Overview";case"channels":return"Channels";case"instances":return"Instances";case"sessions":return"Sessions";case"usage":return"Usage";case"cron":return"Cron Jobs";case"skills":return"Skills";case"nodes":return"Nodes";case"chat":return"Chat";case"personal":return"個人情報";case"config":return"Config";case"debug":return"Debug";case"logs":return"Logs";default:return"Control"}}const uo=["チャット","接続・サービス","システム"],Bt=[{id:"new-chat",label:"新しい会話",category:"チャット",icon:"messageSquare",shortcut:"Ctrl+N",keywords:["new","chat","会話","新規"]},{id:"history",label:"会話履歴",category:"チャット",icon:"fileText",tab:"sessions",shortcut:"Ctrl+H",keywords:["history","履歴","sessions"]},{id:"channels",label:"チャネル管理",category:"接続・サービス",icon:"link",tab:"channels",keywords:["channels","チャネル","slack","discord","telegram"]},{id:"agents",label:"エージェント設定",category:"接続・サービス",icon:"folder",tab:"agents",keywords:["agents","エージェント"]},{id:"cron",label:"スケジュール管理",category:"接続・サービス",icon:"loader",tab:"cron",keywords:["cron","schedule","スケジュール"]},{id:"personal",label:"個人情報",category:"システム",icon:"user",tab:"personal",keywords:["personal","個人情報","従業員","employee","profile"]},{id:"settings",label:"設定",category:"システム",icon:"settings",tab:"config",shortcut:"Ctrl+,",keywords:["config","設定","settings"]},{id:"overview",label:"ダッシュボード",category:"システム",icon:"barChart",tab:"overview",keywords:["overview","ダッシュボード","dashboard"]},{id:"usage",label:"使用量を確認",category:"システム",icon:"barChart",tab:"usage",keywords:["usage","使用量","cost","コスト"]},{id:"skills",label:"スキル管理",category:"システム",icon:"zap",tab:"skills",keywords:["skills","スキル"]},{id:"logs",label:"ログ表示",category:"システム",icon:"scrollText",tab:"logs",keywords:["logs","ログ"]},{id:"debug",label:"デバッグ",category:"システム",icon:"bug",tab:"debug",keywords:["debug","デバッグ"]},{id:"nodes",label:"ノード管理",category:"システム",icon:"monitor",tab:"nodes",keywords:["nodes","ノード"]},{id:"instances",label:"インスタンス",category:"システム",icon:"radio",tab:"instances",keywords:["instances","インスタンス"]}];function Tu(e){switch(e){case"agents":return"Manage agent workspaces, tools, and identities.";case"overview":return"Gateway status, entry points, and a fast health read.";case"channels":return"Manage channels and settings.";case"instances":return"Presence beacons from connected clients and nodes.";case"sessions":return"Inspect active sessions and adjust per-session defaults.";case"usage":return"";case"cron":return"Schedule wakeups and recurring agent runs.";case"skills":return"Manage skill availability and API key injection.";case"nodes":return"Paired devices, capabilities, and command exposure.";case"chat":return"Direct gateway chat session for quick interventions.";case"personal":return"従業員ID・氏名・メールアドレスを管理します。";case"config":return"Edit ~/.winclaw/winclaw.json (WinClaw config) safely.";case"debug":return"Gateway snapshots, events, and manual RPC calls.";case"logs":return"Live tail of the gateway file logs.";default:return""}}const rl="winclaw.control.settings.v1";function _u(){const t={gatewayUrl:`${location.protocol==="https:"?"wss":"ws"}://${location.host}`,token:"",sessionKey:"main",lastActiveSessionKey:"main",theme:"system",chatFocusMode:!1,chatShowThinking:!0,splitRatio:.6,navCollapsed:!1,navGroupsCollapsed:{},openTabs:["chat"],recentCommands:[],openChatSessions:[]};try{const n=localStorage.getItem(rl);if(!n)return t;const s=JSON.parse(n);return{gatewayUrl:typeof s.gatewayUrl=="string"&&s.gatewayUrl.trim()?s.gatewayUrl.trim():t.gatewayUrl,token:typeof s.token=="string"?s.token:t.token,sessionKey:typeof s.sessionKey=="string"&&s.sessionKey.trim()?s.sessionKey.trim():t.sessionKey,lastActiveSessionKey:typeof s.lastActiveSessionKey=="string"&&s.lastActiveSessionKey.trim()?s.lastActiveSessionKey.trim():typeof s.sessionKey=="string"&&s.sessionKey.trim()||t.lastActiveSessionKey,theme:s.theme==="light"||s.theme==="dark"||s.theme==="system"?s.theme:t.theme,chatFocusMode:typeof s.chatFocusMode=="boolean"?s.chatFocusMode:t.chatFocusMode,chatShowThinking:typeof s.chatShowThinking=="boolean"?s.chatShowThinking:t.chatShowThinking,splitRatio:typeof s.splitRatio=="number"&&s.splitRatio>=.4&&s.splitRatio<=.7?s.splitRatio:t.splitRatio,navCollapsed:typeof s.navCollapsed=="boolean"?s.navCollapsed:t.navCollapsed,navGroupsCollapsed:typeof s.navGroupsCollapsed=="object"&&s.navGroupsCollapsed!==null?s.navGroupsCollapsed:t.navGroupsCollapsed,openTabs:Array.isArray(s.openTabs)&&s.openTabs.every(i=>typeof i=="string")?s.openTabs:t.openTabs,recentCommands:Array.isArray(s.recentCommands)&&s.recentCommands.every(i=>typeof i=="string")?s.recentCommands:t.recentCommands,openChatSessions:Array.isArray(s.openChatSessions)&&s.openChatSessions.every(i=>typeof i=="string")?s.openChatSessions:t.openChatSessions}}catch{return t}}function Eu(e){localStorage.setItem(rl,JSON.stringify(e))}const kn=e=>Number.isNaN(e)?.5:e<=0?0:e>=1?1:e,Lu=()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches??!1,Sn=e=>{e.classList.remove("theme-transition"),e.style.removeProperty("--theme-switch-x"),e.style.removeProperty("--theme-switch-y")},Iu=({nextTheme:e,applyTheme:t,context:n,currentTheme:s})=>{if(s===e)return;const i=globalThis.document??null;if(!i){t();return}const a=i.documentElement,o=i,l=Lu();if(!!o.startViewTransition&&!l){let g=.5,u=.5;if(n?.pointerClientX!==void 0&&n?.pointerClientY!==void 0&&typeof window<"u")g=kn(n.pointerClientX/window.innerWidth),u=kn(n.pointerClientY/window.innerHeight);else if(n?.element){const p=n.element.getBoundingClientRect();p.width>0&&p.height>0&&typeof window<"u"&&(g=kn((p.left+p.width/2)/window.innerWidth),u=kn((p.top+p.height/2)/window.innerHeight))}a.style.setProperty("--theme-switch-x",`${g*100}%`),a.style.setProperty("--theme-switch-y",`${u*100}%`),a.classList.add("theme-transition");try{const p=o.startViewTransition?.(()=>{t()});p?.finished?p.finished.finally(()=>Sn(a)):Sn(a)}catch{Sn(a),t()}return}t(),Sn(a)};function Mu(){return typeof window>"u"||typeof window.matchMedia!="function"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function Xi(e){return e==="system"?Mu():e}function Ye(e,t){const n={...t,lastActiveSessionKey:t.lastActiveSessionKey?.trim()||t.sessionKey.trim()||"main"};e.settings=n,Eu(n),t.theme!==e.theme&&(e.theme=t.theme,ls(e,Xi(t.theme))),e.applySessionKey=e.settings.lastActiveSessionKey}function ll(e,t){const n=t.trim();n&&e.settings.lastActiveSessionKey!==n&&Ye(e,{...e.settings,lastActiveSessionKey:n})}function Ru(e){if(!window.location.search&&!window.location.hash)return;const t=new URL(window.location.href),n=new URLSearchParams(t.search),s=new URLSearchParams(t.hash.startsWith("#")?t.hash.slice(1):t.hash),i=n.get("token")??s.get("token"),a=n.get("password")??s.get("password"),o=n.get("session")??s.get("session"),l=n.get("gatewayUrl")??s.get("gatewayUrl");let c=!1;if(i!=null){const u=i.trim();u&&u!==e.settings.token&&Ye(e,{...e.settings,token:u}),n.delete("token"),s.delete("token"),c=!0}if(a!=null){const u=a.trim();u&&(e.password=u),n.delete("password"),s.delete("password"),c=!0}if(o!=null){const u=o.trim();u&&(e.sessionKey=u,Ye(e,{...e.settings,sessionKey:u,lastActiveSessionKey:u}))}if(l!=null){const u=l.trim();u&&u!==e.settings.gatewayUrl&&(e.pendingGatewayUrl=u),n.delete("gatewayUrl"),s.delete("gatewayUrl"),c=!0}if(!c)return;t.search=n.toString();const g=s.toString();t.hash=g?`#${g}`:"",window.history.replaceState({},"",t.toString())}function Pu(e,t){e.tab!==t&&(e.tab=t),t==="chat"&&(e.chatHasAutoScrolled=!1),t==="logs"?Di(e):Fi(e),t==="debug"?Ni(e):Oi(e),ea(e),dl(e,t,!1)}function Du(e,t,n){Iu({nextTheme:t,applyTheme:()=>{e.theme=t,Ye(e,{...e.settings,theme:t}),ls(e,Xi(t))},context:n,currentTheme:e.theme})}async function ea(e){if(e.tab==="personal"&&await Qi(e),e.tab==="overview"&&await ul(e),e.tab==="channels"&&await Hu(e),e.tab==="instances"&&await Yi(e),e.tab==="sessions"&&await Xe(e),e.tab==="cron"&&await jn(e),e.tab==="skills"&&await un(e),e.tab==="agents"){await Bi(e),await Ee(e);const t=e.agentsList?.agents?.map(s=>s.id)??[];t.length>0&&Nr(e,t);const n=e.agentsSelectedId??e.agentsList?.defaultId??e.agentsList?.agents?.[0]?.id;n&&(Fr(e,n),e.agentsPanel==="skills"&&Fn(e,n),e.agentsPanel==="channels"&&me(e,!1),e.agentsPanel==="cron"&&jn(e))}e.tab==="nodes"&&(await is(e),await Ze(e),await Ee(e),await Vi(e)),e.tab==="chat"&&(await wl(e),cn(e,!e.chatHasAutoScrolled)),e.tab==="config"&&(await Mr(e),await Ee(e)),e.tab==="debug"&&(await ss(e),e.eventLog=e.eventLogBuffer),e.tab==="logs"&&(e.logsAtBottom=!0,await Pi(e,{reset:!0}),Dr(e,!0))}function Fu(){if(typeof window>"u")return"";const e=window.__WINCLAW_CONTROL_UI_BASE_PATH__;return typeof e=="string"&&e.trim()?gn(e):Au(window.location.pathname)}function Nu(e){e.theme=e.settings.theme??"system",ls(e,Xi(e.theme))}function ls(e,t){if(e.themeResolved=t,typeof document>"u")return;const n=document.documentElement;n.dataset.theme=t,n.style.colorScheme=t}function Ou(e){if(typeof window>"u"||typeof window.matchMedia!="function")return;if(e.themeMedia=window.matchMedia("(prefers-color-scheme: dark)"),e.themeMediaHandler=n=>{e.theme==="system"&&ls(e,n.matches?"dark":"light")},typeof e.themeMedia.addEventListener=="function"){e.themeMedia.addEventListener("change",e.themeMediaHandler);return}e.themeMedia.addListener(e.themeMediaHandler)}function Bu(e){if(!e.themeMedia||!e.themeMediaHandler)return;if(typeof e.themeMedia.removeEventListener=="function"){e.themeMedia.removeEventListener("change",e.themeMediaHandler);return}e.themeMedia.removeListener(e.themeMediaHandler),e.themeMedia=null,e.themeMediaHandler=null}function Uu(e,t){if(typeof window>"u")return;const n=ol(window.location.pathname,e.basePath)??"chat";cl(e,n),dl(e,n,t)}function zu(e){if(typeof window>"u")return;const t=ol(window.location.pathname,e.basePath);if(!t)return;const s=new URL(window.location.href).searchParams.get("session")?.trim();s&&(e.sessionKey=s,Ye(e,{...e.settings,sessionKey:s,lastActiveSessionKey:s})),cl(e,t)}function cl(e,t){e.tab!==t&&(e.tab=t),t==="chat"&&(e.chatHasAutoScrolled=!1),t==="logs"?Di(e):Fi(e),t==="debug"?Ni(e):Oi(e),e.connected&&ea(e)}function dl(e,t,n){if(typeof window>"u")return;const s=on(Zi(t,e.basePath)),i=on(window.location.pathname),a=new URL(window.location.href);t==="chat"&&e.sessionKey?a.searchParams.set("session",e.sessionKey):a.searchParams.delete("session"),i!==s&&(a.pathname=s),n?window.history.replaceState({},"",a.toString()):window.history.pushState({},"",a.toString())}async function ul(e){await Promise.all([me(e,!1),Yi(e),Xe(e),dn(e),ss(e)])}async function Hu(e){await Promise.all([me(e,!0),Mr(e),Ee(e)])}async function jn(e){await Promise.all([me(e,!1),dn(e),as(e)])}const go=50,Ku=80,ju=12e4,po=5e3;function Wu(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.text=="string")return t.text;const n=t.content;if(!Array.isArray(n))return null;const s=n.map(i=>{if(!i||typeof i!="object")return null;const a=i;return a.type==="text"&&typeof a.text=="string"?a.text:null}).filter(i=>!!i);return s.length===0?null:s.join(`
129
129
  `)}function Wn(e){if(e==null)return null;if(typeof e=="number"||typeof e=="boolean")return String(e);const t=Wu(e);let n;if(typeof e=="string")n=e;else if(t)n=t;else try{n=JSON.stringify(e,null,2)}catch{n=String(e)}const s=Or(n,ju);return s.truncated?`${s.text}
@@ -4460,15 +4460,21 @@ ${JSON.stringify(e.issues,null,2)}</pre
4460
4460
  />
4461
4461
  </label>
4462
4462
 
4463
+ <label class="field">
4464
+ <span class="field-label">GRC URL</span>
4465
+ <input
4466
+ type="url"
4467
+ .value=${t.grcUrl??""}
4468
+ placeholder="例: https://grc.myaiportal.net"
4469
+ @input=${n=>e.onFieldChange("grcUrl",n.target.value)}
4470
+ />
4471
+ </label>
4472
+
4463
4473
  <div
4464
4474
  class="callout"
4465
4475
  style="margin-top: 4px; opacity: 0.7; font-size: 0.85em;"
4466
4476
  >
4467
- <div style="margin-bottom: 4px;"><strong>GRC URL:</strong> ${t.grcUrl||"未設定"}</div>
4468
4477
  <div><strong>Node ID:</strong> ${t.nodeId||"未接続"}</div>
4469
- <div class="muted" style="margin-top: 4px; font-size: 0.9em;">
4470
- GRC URL の変更は winclaw.json の grc.url で行ってください。
4471
- </div>
4472
4478
  </div>
4473
4479
 
4474
4480
  <div class="row" style="margin-top: 8px; gap: 8px;">
@@ -7763,4 +7769,4 @@ ${JSON.stringify(e.issues,null,2)}</pre
7763
7769
  `}var Wb=Object.defineProperty,qb=Object.getOwnPropertyDescriptor,x=(e,t,n,s)=>{for(var i=s>1?void 0:s?qb(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(s?o(t,n,i):o(i))||i);return s&&i&&Wb(t,n,i),i};const ei=$g();function Gb(){if(!window.location.search)return!1;const t=new URLSearchParams(window.location.search).get("onboarding");if(!t)return!1;const n=t.trim().toLowerCase();return n==="1"||n==="true"||n==="yes"||n==="on"}let y=class extends Lt{constructor(){super(...arguments),this.settings=_u(),this.password="",this.tab="chat",this.onboarding=Gb(),this.connected=!1,this.theme=this.settings.theme??"system",this.themeResolved="dark",this.hello=null,this.lastError=null,this.eventLog=[],this.eventLogBuffer=[],this.toolStreamSyncTimer=null,this.sidebarCloseTimer=null,this.assistantName=ei.name,this.assistantAvatar=ei.avatar,this.assistantAgentId=ei.agentId??null,this.sessionKey=this.settings.sessionKey,this.chatLoading=!1,this.chatSending=!1,this.chatMessage="",this.chatMessages=[],this.chatToolMessages=[],this.chatStream=null,this.chatStreamStartedAt=null,this.chatRunId=null,this.compactionStatus=null,this.chatAvatarUrl=null,this.chatThinkingLevel=null,this.chatQueue=[],this.chatAttachments=[],this.chatManualRefreshInFlight=!1,this.sidebarOpen=!1,this.sidebarContent=null,this.sidebarError=null,this.sidebarMode=null,this.execLogEntries=[],this.execLogActive=!1,this.execLogAutoScroll=!0,this.execLogManuallyDismissed=!1,this.splitRatio=this.settings.splitRatio,this.nodesLoading=!1,this.nodes=[],this.devicesLoading=!1,this.devicesError=null,this.devicesList=null,this.execApprovalsLoading=!1,this.execApprovalsSaving=!1,this.execApprovalsDirty=!1,this.execApprovalsSnapshot=null,this.execApprovalsForm=null,this.execApprovalsSelectedAgent=null,this.execApprovalsTarget="gateway",this.execApprovalsTargetNodeId=null,this.execApprovalQueue=[],this.execApprovalBusy=!1,this.execApprovalError=null,this.pendingGatewayUrl=null,this.personalInfoLoading=!1,this.personalInfoSaving=!1,this.personalInfo=null,this.personalInfoForm=null,this.personalInfoError=null,this.personalInfoDirty=!1,this.personalInfoSuccess=null,this.configLoading=!1,this.configRaw=`{
7764
7770
  }
7765
7771
  `,this.configRawOriginal="",this.configValid=null,this.configIssues=[],this.configSaving=!1,this.configApplying=!1,this.updateRunning=!1,this.applySessionKey=this.settings.lastActiveSessionKey,this.configSnapshot=null,this.configSchema=null,this.configSchemaVersion=null,this.configSchemaLoading=!1,this.configUiHints={},this.configForm=null,this.configFormOriginal=null,this.configFormDirty=!1,this.configFormMode="form",this.configSearchQuery="",this.configActiveSection=null,this.configActiveSubsection=null,this.channelsLoading=!1,this.channelsSnapshot=null,this.channelsError=null,this.channelsLastSuccess=null,this.whatsappLoginMessage=null,this.whatsappLoginQrDataUrl=null,this.whatsappLoginConnected=null,this.whatsappBusy=!1,this.nostrProfileFormState=null,this.nostrProfileAccountId=null,this.presenceLoading=!1,this.presenceEntries=[],this.presenceError=null,this.presenceStatus=null,this.agentsLoading=!1,this.agentsList=null,this.agentsError=null,this.agentsSelectedId=null,this.agentsPanel="overview",this.agentFilesLoading=!1,this.agentFilesError=null,this.agentFilesList=null,this.agentFileContents={},this.agentFileDrafts={},this.agentFileActive=null,this.agentFileSaving=!1,this.agentIdentityLoading=!1,this.agentIdentityError=null,this.agentIdentityById={},this.agentSkillsLoading=!1,this.agentSkillsError=null,this.agentSkillsReport=null,this.agentSkillsAgentId=null,this.sessionsLoading=!1,this.sessionsResult=null,this.sessionsError=null,this.sessionsFilterActive="",this.sessionsFilterLimit="120",this.sessionsIncludeGlobal=!0,this.sessionsIncludeUnknown=!1,this.usageLoading=!1,this.usageResult=null,this.usageCostSummary=null,this.usageError=null,this.usageStartDate=(()=>{const e=new Date;return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`})(),this.usageEndDate=(()=>{const e=new Date;return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`})(),this.usageSelectedSessions=[],this.usageSelectedDays=[],this.usageSelectedHours=[],this.usageChartMode="tokens",this.usageDailyChartMode="by-type",this.usageTimeSeriesMode="per-turn",this.usageTimeSeriesBreakdownMode="by-type",this.usageTimeSeries=null,this.usageTimeSeriesLoading=!1,this.usageSessionLogs=null,this.usageSessionLogsLoading=!1,this.usageSessionLogsExpanded=!1,this.usageQuery="",this.usageQueryDraft="",this.usageSessionSort="recent",this.usageSessionSortDir="desc",this.usageRecentSessions=[],this.usageTimeZone="local",this.usageContextExpanded=!1,this.usageHeaderPinned=!1,this.usageSessionsTab="all",this.usageVisibleColumns=["channel","agent","provider","model","messages","tools","errors","duration"],this.usageLogFilterRoles=[],this.usageLogFilterTools=[],this.usageLogFilterHasTools=!1,this.usageLogFilterQuery="",this.usageQueryDebounceTimer=null,this.cronLoading=!1,this.cronJobs=[],this.cronStatus=null,this.cronError=null,this.cronForm={...bg},this.cronRunsJobId=null,this.cronRuns=[],this.cronBusy=!1,this.skillsLoading=!1,this.skillsReport=null,this.skillsError=null,this.skillsFilter="",this.skillEdits={},this.skillsBusyKey=null,this.skillMessages={},this.modelCatalog=null,this.modelCatalogLoading=!1,this.debugLoading=!1,this.debugStatus=null,this.debugHealth=null,this.debugModels=[],this.debugHeartbeat=null,this.debugCallMethod="",this.debugCallParams="{}",this.debugCallResult=null,this.debugCallError=null,this.logsLoading=!1,this.logsError=null,this.logsFile=null,this.logsEntries=[],this.logsFilterText="",this.logsLevelFilters={...vg},this.logsAutoFollow=!0,this.logsTruncated=!1,this.logsCursor=null,this.logsLastFetchAt=null,this.logsLimit=500,this.logsMaxBytes=25e4,this.logsAtBottom=!0,this.commandPaletteOpen=!1,this.openTabs=this.settings.openTabs?.length?this.settings.openTabs:["chat"],this.statusBarExpanded=!1,this.recentCommands=this.settings.recentCommands??[],this.openChatSessions=(()=>{const e=this.settings.openChatSessions,t=this.settings.sessionKey||"main";return e&&e.length>0?e.includes(t)?e:[t,...e]:[t]})(),this.client=null,this.chatScrollFrame=null,this.chatScrollTimeout=null,this.chatHasAutoScrolled=!1,this.chatUserNearBottom=!0,this.chatNewMessagesBelow=!1,this.nodesPollInterval=null,this.logsPollInterval=null,this.debugPollInterval=null,this.logsScrollFrame=null,this.toolStreamById=new Map,this.toolStreamOrder=[],this.refreshSessionsAfterChat=new Set,this.basePath="",this.popStateHandler=()=>zu(this),this.themeMedia=null,this.themeMediaHandler=null,this.topbarObserver=null}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),Dg(this)}firstUpdated(){Fg(this)}disconnectedCallback(){Ng(this),super.disconnectedCallback()}updated(e){Og(this,e)}connect(){Cl(this)}handleChatScroll(e){fd(this,e)}handleLogsScroll(e){hd(this,e)}exportLogs(e,t){md(e,t)}resetToolStream(){cs(this)}resetChatScroll(){eo(this)}scrollToBottom(e){eo(this),cn(this,!0,!!e?.smooth)}async loadAssistantIdentity(){await kl(this)}applySettings(e){Ye(this,e)}setTab(e){Pu(this,e)}setTheme(e,t){Du(this,e,t)}async loadOverview(){await ul(this)}async loadCron(){await jn(this)}async handleAbortChat(){await na(this)}removeQueuedMessage(e){yl(this,e)}async handleSendChat(e,t){await xl(this,e,t)}async handleWhatsAppStart(e){await nd(this,e)}async handleWhatsAppWait(){await sd(this)}async handleWhatsAppLogout(){await id(this)}async handleChannelConfigSave(){await ad(this)}async handleChannelConfigReload(){await od(this)}handleNostrProfileEdit(e,t){ld(this,e,t)}handleNostrProfileCancel(){cd(this)}handleNostrProfileFieldChange(e,t){dd(this,e,t)}async handleNostrProfileSave(){await gd(this)}async handleNostrProfileImport(){await pd(this)}handleNostrProfileToggleAdvanced(){ud(this)}async handleExecApprovalDecision(e){const t=this.execApprovalQueue[0];if(!(!t||!this.client||this.execApprovalBusy)){this.execApprovalBusy=!0,this.execApprovalError=null;try{await this.client.request("exec.approval.resolve",{id:t.id,decision:e}),this.execApprovalQueue=this.execApprovalQueue.filter(n=>n.id!==t.id)}catch(n){this.execApprovalError=`Exec approval failed: ${String(n)}`}finally{this.execApprovalBusy=!1}}}handleGatewayUrlConfirm(){const e=this.pendingGatewayUrl;e&&(this.pendingGatewayUrl=null,Ye(this,{...this.settings,gatewayUrl:e}),this.connect())}handleGatewayUrlCancel(){this.pendingGatewayUrl=null}handleOpenSidebar(e){this.sidebarCloseTimer!=null&&(window.clearTimeout(this.sidebarCloseTimer),this.sidebarCloseTimer=null),this.sidebarContent=e,this.sidebarError=null,this.sidebarMode="markdown",this.sidebarOpen=!0}handleCloseSidebar(){this.sidebarOpen=!1,this.sidebarMode=null,this.sidebarCloseTimer!=null&&window.clearTimeout(this.sidebarCloseTimer),this.sidebarCloseTimer=window.setTimeout(()=>{this.sidebarOpen||(this.sidebarContent=null,this.sidebarError=null,this.sidebarCloseTimer=null)},200)}handleSplitRatioChange(e){const t=Math.max(.4,Math.min(.7,e));this.splitRatio=t,this.applySettings({...this.settings,splitRatio:t})}handleOpenExecLog(){this.sidebarMode="exec-log",this.sidebarOpen=!0,this.execLogManuallyDismissed=!1}handleCloseExecLog(){this.sidebarMode=null,this.sidebarOpen=!1,this.execLogManuallyDismissed=!0}handleClearExecLog(){this.execLogEntries=[]}handleToggleExecLogAutoScroll(){this.execLogAutoScroll=!this.execLogAutoScroll}toggleCommandPalette(){this.commandPaletteOpen=!this.commandPaletteOpen}openTabFromPalette(e){this.openTabs.includes(e)||(this.openTabs=[...this.openTabs,e]),this.setTab(e),this.commandPaletteOpen=!1,this.applySettings({...this.settings,openTabs:this.openTabs})}closeTab(e){e!=="chat"&&(this.openTabs=this.openTabs.filter(t=>t!==e),this.tab===e&&this.setTab("chat"),this.applySettings({...this.settings,openTabs:this.openTabs}))}addRecentCommand(e){const t=[e,...this.recentCommands.filter(n=>n!==e)].slice(0,5);this.recentCommands=t,this.applySettings({...this.settings,recentCommands:t})}addChatSession(e){this.openChatSessions.includes(e)||(this.openChatSessions=[...this.openChatSessions,e],this.applySettings({...this.settings,openChatSessions:this.openChatSessions}))}removeChatSession(e){if(this.openChatSessions.length<=1)return;const t=this.openChatSessions.indexOf(e);if(t!==-1){if(this.openChatSessions=this.openChatSessions.filter(n=>n!==e),this.sessionKey===e){const n=Math.min(t,this.openChatSessions.length-1),s=this.openChatSessions[n]??this.openChatSessions[0];this.switchChatSession(s)}this.applySettings({...this.settings,openChatSessions:this.openChatSessions})}}switchChatSession(e){e!==this.sessionKey&&(this.sessionKey=e,this.chatMessage="",this.chatAttachments=[],this.chatStream=null,this.chatStreamStartedAt=null,this.chatRunId=null,this.chatQueue=[],this.resetToolStream(),this.resetChatScroll(),this.applySettings({...this.settings,sessionKey:e,lastActiveSessionKey:e,openChatSessions:this.openChatSessions}),this.loadAssistantIdentity(),Ha(async()=>{const{loadChatHistory:t}=await Promise.resolve().then(()=>ug);return{loadChatHistory:t}},void 0,import.meta.url).then(({loadChatHistory:t})=>t(this)),Ha(async()=>{const{refreshChatAvatar:t}=await Promise.resolve().then(()=>mg);return{refreshChatAvatar:t}},void 0,import.meta.url).then(({refreshChatAvatar:t})=>t(this)))}render(){return jb(this)}};x([w()],y.prototype,"settings",2);x([w()],y.prototype,"password",2);x([w()],y.prototype,"tab",2);x([w()],y.prototype,"onboarding",2);x([w()],y.prototype,"connected",2);x([w()],y.prototype,"theme",2);x([w()],y.prototype,"themeResolved",2);x([w()],y.prototype,"hello",2);x([w()],y.prototype,"lastError",2);x([w()],y.prototype,"eventLog",2);x([w()],y.prototype,"assistantName",2);x([w()],y.prototype,"assistantAvatar",2);x([w()],y.prototype,"assistantAgentId",2);x([w()],y.prototype,"sessionKey",2);x([w()],y.prototype,"chatLoading",2);x([w()],y.prototype,"chatSending",2);x([w()],y.prototype,"chatMessage",2);x([w()],y.prototype,"chatMessages",2);x([w()],y.prototype,"chatToolMessages",2);x([w()],y.prototype,"chatStream",2);x([w()],y.prototype,"chatStreamStartedAt",2);x([w()],y.prototype,"chatRunId",2);x([w()],y.prototype,"compactionStatus",2);x([w()],y.prototype,"chatAvatarUrl",2);x([w()],y.prototype,"chatThinkingLevel",2);x([w()],y.prototype,"chatQueue",2);x([w()],y.prototype,"chatAttachments",2);x([w()],y.prototype,"chatManualRefreshInFlight",2);x([w()],y.prototype,"sidebarOpen",2);x([w()],y.prototype,"sidebarContent",2);x([w()],y.prototype,"sidebarError",2);x([w()],y.prototype,"sidebarMode",2);x([w()],y.prototype,"execLogEntries",2);x([w()],y.prototype,"execLogActive",2);x([w()],y.prototype,"execLogAutoScroll",2);x([w()],y.prototype,"execLogManuallyDismissed",2);x([w()],y.prototype,"splitRatio",2);x([w()],y.prototype,"nodesLoading",2);x([w()],y.prototype,"nodes",2);x([w()],y.prototype,"devicesLoading",2);x([w()],y.prototype,"devicesError",2);x([w()],y.prototype,"devicesList",2);x([w()],y.prototype,"execApprovalsLoading",2);x([w()],y.prototype,"execApprovalsSaving",2);x([w()],y.prototype,"execApprovalsDirty",2);x([w()],y.prototype,"execApprovalsSnapshot",2);x([w()],y.prototype,"execApprovalsForm",2);x([w()],y.prototype,"execApprovalsSelectedAgent",2);x([w()],y.prototype,"execApprovalsTarget",2);x([w()],y.prototype,"execApprovalsTargetNodeId",2);x([w()],y.prototype,"execApprovalQueue",2);x([w()],y.prototype,"execApprovalBusy",2);x([w()],y.prototype,"execApprovalError",2);x([w()],y.prototype,"pendingGatewayUrl",2);x([w()],y.prototype,"personalInfoLoading",2);x([w()],y.prototype,"personalInfoSaving",2);x([w()],y.prototype,"personalInfo",2);x([w()],y.prototype,"personalInfoForm",2);x([w()],y.prototype,"personalInfoError",2);x([w()],y.prototype,"personalInfoDirty",2);x([w()],y.prototype,"personalInfoSuccess",2);x([w()],y.prototype,"configLoading",2);x([w()],y.prototype,"configRaw",2);x([w()],y.prototype,"configRawOriginal",2);x([w()],y.prototype,"configValid",2);x([w()],y.prototype,"configIssues",2);x([w()],y.prototype,"configSaving",2);x([w()],y.prototype,"configApplying",2);x([w()],y.prototype,"updateRunning",2);x([w()],y.prototype,"applySessionKey",2);x([w()],y.prototype,"configSnapshot",2);x([w()],y.prototype,"configSchema",2);x([w()],y.prototype,"configSchemaVersion",2);x([w()],y.prototype,"configSchemaLoading",2);x([w()],y.prototype,"configUiHints",2);x([w()],y.prototype,"configForm",2);x([w()],y.prototype,"configFormOriginal",2);x([w()],y.prototype,"configFormDirty",2);x([w()],y.prototype,"configFormMode",2);x([w()],y.prototype,"configSearchQuery",2);x([w()],y.prototype,"configActiveSection",2);x([w()],y.prototype,"configActiveSubsection",2);x([w()],y.prototype,"channelsLoading",2);x([w()],y.prototype,"channelsSnapshot",2);x([w()],y.prototype,"channelsError",2);x([w()],y.prototype,"channelsLastSuccess",2);x([w()],y.prototype,"whatsappLoginMessage",2);x([w()],y.prototype,"whatsappLoginQrDataUrl",2);x([w()],y.prototype,"whatsappLoginConnected",2);x([w()],y.prototype,"whatsappBusy",2);x([w()],y.prototype,"nostrProfileFormState",2);x([w()],y.prototype,"nostrProfileAccountId",2);x([w()],y.prototype,"presenceLoading",2);x([w()],y.prototype,"presenceEntries",2);x([w()],y.prototype,"presenceError",2);x([w()],y.prototype,"presenceStatus",2);x([w()],y.prototype,"agentsLoading",2);x([w()],y.prototype,"agentsList",2);x([w()],y.prototype,"agentsError",2);x([w()],y.prototype,"agentsSelectedId",2);x([w()],y.prototype,"agentsPanel",2);x([w()],y.prototype,"agentFilesLoading",2);x([w()],y.prototype,"agentFilesError",2);x([w()],y.prototype,"agentFilesList",2);x([w()],y.prototype,"agentFileContents",2);x([w()],y.prototype,"agentFileDrafts",2);x([w()],y.prototype,"agentFileActive",2);x([w()],y.prototype,"agentFileSaving",2);x([w()],y.prototype,"agentIdentityLoading",2);x([w()],y.prototype,"agentIdentityError",2);x([w()],y.prototype,"agentIdentityById",2);x([w()],y.prototype,"agentSkillsLoading",2);x([w()],y.prototype,"agentSkillsError",2);x([w()],y.prototype,"agentSkillsReport",2);x([w()],y.prototype,"agentSkillsAgentId",2);x([w()],y.prototype,"sessionsLoading",2);x([w()],y.prototype,"sessionsResult",2);x([w()],y.prototype,"sessionsError",2);x([w()],y.prototype,"sessionsFilterActive",2);x([w()],y.prototype,"sessionsFilterLimit",2);x([w()],y.prototype,"sessionsIncludeGlobal",2);x([w()],y.prototype,"sessionsIncludeUnknown",2);x([w()],y.prototype,"usageLoading",2);x([w()],y.prototype,"usageResult",2);x([w()],y.prototype,"usageCostSummary",2);x([w()],y.prototype,"usageError",2);x([w()],y.prototype,"usageStartDate",2);x([w()],y.prototype,"usageEndDate",2);x([w()],y.prototype,"usageSelectedSessions",2);x([w()],y.prototype,"usageSelectedDays",2);x([w()],y.prototype,"usageSelectedHours",2);x([w()],y.prototype,"usageChartMode",2);x([w()],y.prototype,"usageDailyChartMode",2);x([w()],y.prototype,"usageTimeSeriesMode",2);x([w()],y.prototype,"usageTimeSeriesBreakdownMode",2);x([w()],y.prototype,"usageTimeSeries",2);x([w()],y.prototype,"usageTimeSeriesLoading",2);x([w()],y.prototype,"usageSessionLogs",2);x([w()],y.prototype,"usageSessionLogsLoading",2);x([w()],y.prototype,"usageSessionLogsExpanded",2);x([w()],y.prototype,"usageQuery",2);x([w()],y.prototype,"usageQueryDraft",2);x([w()],y.prototype,"usageSessionSort",2);x([w()],y.prototype,"usageSessionSortDir",2);x([w()],y.prototype,"usageRecentSessions",2);x([w()],y.prototype,"usageTimeZone",2);x([w()],y.prototype,"usageContextExpanded",2);x([w()],y.prototype,"usageHeaderPinned",2);x([w()],y.prototype,"usageSessionsTab",2);x([w()],y.prototype,"usageVisibleColumns",2);x([w()],y.prototype,"usageLogFilterRoles",2);x([w()],y.prototype,"usageLogFilterTools",2);x([w()],y.prototype,"usageLogFilterHasTools",2);x([w()],y.prototype,"usageLogFilterQuery",2);x([w()],y.prototype,"cronLoading",2);x([w()],y.prototype,"cronJobs",2);x([w()],y.prototype,"cronStatus",2);x([w()],y.prototype,"cronError",2);x([w()],y.prototype,"cronForm",2);x([w()],y.prototype,"cronRunsJobId",2);x([w()],y.prototype,"cronRuns",2);x([w()],y.prototype,"cronBusy",2);x([w()],y.prototype,"skillsLoading",2);x([w()],y.prototype,"skillsReport",2);x([w()],y.prototype,"skillsError",2);x([w()],y.prototype,"skillsFilter",2);x([w()],y.prototype,"skillEdits",2);x([w()],y.prototype,"skillsBusyKey",2);x([w()],y.prototype,"skillMessages",2);x([w()],y.prototype,"modelCatalog",2);x([w()],y.prototype,"modelCatalogLoading",2);x([w()],y.prototype,"debugLoading",2);x([w()],y.prototype,"debugStatus",2);x([w()],y.prototype,"debugHealth",2);x([w()],y.prototype,"debugModels",2);x([w()],y.prototype,"debugHeartbeat",2);x([w()],y.prototype,"debugCallMethod",2);x([w()],y.prototype,"debugCallParams",2);x([w()],y.prototype,"debugCallResult",2);x([w()],y.prototype,"debugCallError",2);x([w()],y.prototype,"logsLoading",2);x([w()],y.prototype,"logsError",2);x([w()],y.prototype,"logsFile",2);x([w()],y.prototype,"logsEntries",2);x([w()],y.prototype,"logsFilterText",2);x([w()],y.prototype,"logsLevelFilters",2);x([w()],y.prototype,"logsAutoFollow",2);x([w()],y.prototype,"logsTruncated",2);x([w()],y.prototype,"logsCursor",2);x([w()],y.prototype,"logsLastFetchAt",2);x([w()],y.prototype,"logsLimit",2);x([w()],y.prototype,"logsMaxBytes",2);x([w()],y.prototype,"logsAtBottom",2);x([w()],y.prototype,"commandPaletteOpen",2);x([w()],y.prototype,"openTabs",2);x([w()],y.prototype,"statusBarExpanded",2);x([w()],y.prototype,"recentCommands",2);x([w()],y.prototype,"openChatSessions",2);x([w()],y.prototype,"chatNewMessagesBelow",2);y=x([Er("winclaw-app")],y);
7766
- //# sourceMappingURL=index-DrWLR6Yv.js.map
7772
+ //# sourceMappingURL=index-Cu86kp_Y.js.map