@godmode-team/godmode 1.8.1 → 1.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -12
- package/dist/godmode-ui/assets/{brain-tab-Z-Uwg6EX.js → brain-tab-C2AbYrWP.js} +35 -23
- package/dist/godmode-ui/assets/{connections-tab-DhJWQQBw.js → connections-tab-CwdK_wkL.js} +3 -3
- package/dist/godmode-ui/assets/ctrl-settings-nG144v_G.js +5 -0
- package/dist/godmode-ui/assets/{dashboards-tab-D22kRTMW.js → dashboards-tab-CIED6Kpa.js} +1 -1
- package/dist/godmode-ui/assets/index-Btlae9Mn.css +1 -0
- package/dist/godmode-ui/assets/{index-Covj4w7X.js → index-DzcGsUUC.js} +290 -276
- package/dist/godmode-ui/assets/{second-brain-tab-BINrzjjx.js → second-brain-tab-BK7ARED2.js} +56 -48
- package/dist/godmode-ui/assets/{team-tab-DE4DvNCS.js → team-tab-Dpl4pwK6.js} +1 -1
- package/dist/godmode-ui/assets/{today-tab-BExVN_cu.js → today-tab-ReKlJGhF.js} +1 -1
- package/dist/godmode-ui/assets/{views-settings-nvLQdpIB.js → views-settings-TQFJxfo9.js} +1 -1
- package/dist/godmode-ui/assets/work-tab-BJF_wapn.js +1 -0
- package/dist/godmode-ui/assets/{workspaces-C8dKMKC1.js → workspaces-C4ZyofCq.js} +49 -49
- package/dist/godmode-ui/index.html +4 -4
- package/dist/index.js +407 -404
- package/dist/mcp-entry.js +256 -255
- package/dist/standalone.js +395 -392
- package/openclaw.plugin.json +2 -2
- package/package.json +4 -4
- package/skill-cards/screenpipe.md +23 -15
- package/dist/godmode-ui/assets/ctrl-settings-niym-WgY.js +0 -5
- package/dist/godmode-ui/assets/index-DmEmOd0w.css +0 -1
- package/dist/godmode-ui/assets/work-tab-DOrlU-Ge.js +0 -1
package/openclaw.plugin.json
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
"id": "godmode",
|
|
3
3
|
"name": "GodMode",
|
|
4
4
|
"description": "Personal AI Operating System — your deeply contextual AI ally that manages tasks, memory, integrations, and a swarm of agents",
|
|
5
|
-
"version": "1.8.
|
|
5
|
+
"version": "1.8.3",
|
|
6
6
|
"license": "FSL-1.1-MIT",
|
|
7
7
|
"author": {
|
|
8
8
|
"name": "GodMode Team",
|
|
9
9
|
"url": "https://lifeongodmode.com"
|
|
10
10
|
},
|
|
11
|
-
"repository": "https://github.com/GodMode-Team/godmode
|
|
11
|
+
"repository": "https://github.com/GodMode-Team/godmode",
|
|
12
12
|
"homepage": "https://lifeongodmode.com",
|
|
13
13
|
"keywords": ["ai", "personal-ai", "agent", "memory", "productivity", "second-brain", "automation"],
|
|
14
14
|
"categories": ["productivity", "ai-agents", "automation", "memory"],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@godmode-team/godmode",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "GodMode - Personal AI Operating System plugin for OpenClaw",
|
|
6
6
|
"license": "FSL-1.1-MIT",
|
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
"homepage": "https://lifeongodmode.com",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
|
-
"url": "git+https://github.com/GodMode-Team/godmode
|
|
11
|
+
"url": "git+https://github.com/GodMode-Team/godmode.git"
|
|
12
12
|
},
|
|
13
13
|
"bugs": {
|
|
14
|
-
"url": "https://github.com/GodMode-Team/godmode
|
|
14
|
+
"url": "https://github.com/GodMode-Team/godmode/issues"
|
|
15
15
|
},
|
|
16
16
|
"keywords": [
|
|
17
17
|
"openclaw",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"@honcho-ai/sdk": "2.0.1",
|
|
75
75
|
"@lit/context": "1.1.6",
|
|
76
76
|
"@noble/ed25519": "3.0.0",
|
|
77
|
-
"better-sqlite3": "
|
|
77
|
+
"better-sqlite3": "^12.8.0",
|
|
78
78
|
"chokidar": "4.0.3",
|
|
79
79
|
"dompurify": "3.3.3",
|
|
80
80
|
"json5": "2.2.3",
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
---
|
|
2
2
|
domain: screenpipe
|
|
3
3
|
triggers: screenpipe, screen capture, ambient memory, screen recording, screen history, what was on my screen, what was I looking at, screen recall
|
|
4
|
-
tools: ingestion.screenpipeStatus, ingestion.
|
|
4
|
+
tools: ingestion.screenpipeStatus, ingestion.screenpipeSetup, ingestion.screenpipeInstall, ingestion.screenpipeStart, ingestion.screenpipeStop, ingestion.screenpipeConfigure, ingestion.runPipeline, secondBrain.search
|
|
5
5
|
name: godmode-screenpipe
|
|
6
|
-
version:
|
|
7
|
-
description: "Manages Screenpipe ambient memory — screen & audio capture,
|
|
6
|
+
version: 2.0.0
|
|
7
|
+
description: "Manages Screenpipe ambient memory — fully managed install, daemon lifecycle, screen & audio capture, and recall"
|
|
8
8
|
keywords: ["screenpipe", "screen", "capture", "ambient", "recall"]
|
|
9
9
|
author: godmode-team
|
|
10
10
|
clawhub: true
|
|
@@ -13,37 +13,45 @@ clawhub: true
|
|
|
13
13
|
- User mentions Screenpipe (setup, status, configuration, troubleshooting)
|
|
14
14
|
- User asks "what was on my screen" or wants to recall something they saw
|
|
15
15
|
- User wants to configure blocked apps, retention, or privacy settings
|
|
16
|
-
- Screenpipe shows as offline in the Engine panel
|
|
16
|
+
- Screenpipe shows as offline in the Engine panel or Brain tab
|
|
17
17
|
|
|
18
18
|
## How to Use
|
|
19
|
-
- `ingestion.screenpipeStatus` — check if
|
|
19
|
+
- `ingestion.screenpipeStatus` — check if installed, running, version, PID, managedByUs
|
|
20
|
+
- `ingestion.screenpipeSetup` — **one-click**: auto-installs (if needed) + starts daemon + enables. Use this for first-time setup.
|
|
21
|
+
- `ingestion.screenpipeInstall` — install only (brew on macOS, script on Linux)
|
|
22
|
+
- `ingestion.screenpipeStart` — start the daemon (must be installed first)
|
|
23
|
+
- `ingestion.screenpipeStop` — stop the daemon
|
|
20
24
|
- `ingestion.screenpipeConfigure` — { enabled?, blockedApps?, retention?, privacy? } — update settings
|
|
21
|
-
- `ingestion.screenpipeToggle` — quick enable/disable toggle
|
|
22
25
|
- `ingestion.runPipeline` — { pipeline: "screenpipe-hourly" } — manually trigger ingestion
|
|
23
26
|
- `secondBrain.search` — search for Screenpipe-captured content in the vault
|
|
24
27
|
|
|
25
28
|
## Setup Flow
|
|
26
29
|
1. Check status: `ingestion.screenpipeStatus`
|
|
27
|
-
2. If not installed:
|
|
28
|
-
3. If installed but
|
|
29
|
-
4.
|
|
30
|
-
|
|
30
|
+
2. If not installed OR not running: call `ingestion.screenpipeSetup` — it handles everything automatically (install via Homebrew, start daemon, enable config). This may take a few minutes on first install.
|
|
31
|
+
3. If installed but stopped: call `ingestion.screenpipeStart`
|
|
32
|
+
4. Configure blocked apps (e.g., banking, health apps) via `ingestion.screenpipeConfigure`
|
|
33
|
+
|
|
34
|
+
**IMPORTANT:** NEVER tell users to run CLI commands, use Homebrew directly, or visit screenpipe.com. GodMode handles the entire install and lifecycle. The user clicks one button or asks you — that's it.
|
|
31
35
|
|
|
32
36
|
## Architecture
|
|
33
|
-
- Screenpipe
|
|
37
|
+
- GodMode fully manages Screenpipe: detection, installation, daemon start/stop, health monitoring
|
|
38
|
+
- Screenpipe runs locally on the user's machine (default localhost:3030, configurable)
|
|
34
39
|
- GodMode ingests screen/audio data via hourly → daily → weekly → monthly compression
|
|
35
40
|
- Summaries are stored in memory/screenpipe/ and forwarded to Honcho
|
|
36
41
|
- Entity extraction pulls out people, decisions, URLs from screen activity
|
|
37
42
|
- All data stays local — no cloud upload
|
|
43
|
+
- PID tracking: GodMode tracks the daemon PID to know if it started the process
|
|
38
44
|
|
|
39
45
|
## Gotchas
|
|
40
|
-
-
|
|
41
|
-
- Default API URL is localhost:3030, override
|
|
46
|
+
- First install via Homebrew can take 1-5 minutes (compilation) — this is normal
|
|
47
|
+
- Default API URL is localhost:3030, user can override in screenpipe config
|
|
42
48
|
- Privacy: configure blockedApps to exclude sensitive apps (banking, medical)
|
|
43
49
|
- The ingestion pipeline runs hourly — recent screen data may not be indexed yet
|
|
50
|
+
- If daemon was started outside GodMode, `managedByUs` will be false but it still works
|
|
44
51
|
|
|
45
52
|
## Tips
|
|
46
|
-
- When user asks about Screenpipe, ALWAYS check status first with ingestion.screenpipeStatus
|
|
53
|
+
- When user asks about Screenpipe, ALWAYS check status first with `ingestion.screenpipeStatus`
|
|
54
|
+
- If not set up, offer to run `ingestion.screenpipeSetup` — don't explain CLI steps
|
|
47
55
|
- Never evaluate whether Screenpipe is "worth using" — it's already integrated. Help configure it.
|
|
48
|
-
- If offline,
|
|
56
|
+
- If offline, use `ingestion.screenpipeStart` to restart, don't tell user to open a terminal
|
|
49
57
|
- Frame privacy controls positively: "Let's make sure sensitive apps are excluded"
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index-Covj4w7X.js","./lit-core-CTInmNPB.js","./views-settings-nvLQdpIB.js","./markdown-i_gIkIP3.js","./index-DmEmOd0w.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
const Zn="modulepreload",Jn=function(n,e){return new URL(n,e).href},fn={},Yn=function(e,r,o){let i=Promise.resolve();if(r&&r.length>0){let u=function(f){return Promise.all(f.map(d=>Promise.resolve(d).then(g=>({status:"fulfilled",value:g}),g=>({status:"rejected",reason:g}))))};const c=document.getElementsByTagName("link"),l=document.querySelector("meta[property=csp-nonce]"),a=l?.nonce||l?.getAttribute("nonce");i=u(r.map(f=>{if(f=Jn(f,o),f in fn)return;fn[f]=!0;const d=f.endsWith(".css"),g=d?'[rel="stylesheet"]':"";if(o)for(let p=c.length-1;p>=0;p--){const v=c[p];if(v.href===f&&(!d||v.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${f}"]${g}`))return;const y=document.createElement("link");if(y.rel=d?"stylesheet":Zn,d||(y.as="script"),y.crossOrigin="",y.href=f,a&&y.setAttribute("nonce",a),document.head.appendChild(y),d)return new Promise((p,v)=>{y.addEventListener("load",p),y.addEventListener("error",()=>v(new Error(`Unable to preload CSS for ${f}`)))})}))}function t(c){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=c,window.dispatchEvent(l),!l.defaultPrevented)throw c}return i.then(c=>{for(const l of c||[])l.status==="rejected"&&t(l.reason);return e().catch(t)})};async function Qe(n,e){if(!(!n.client||!n.connected)&&!n.channelsLoading){n.channelsLoading=!0,n.channelsError=null;try{const r=await n.client.request("channels.status",{probe:e,timeoutMs:8e3});n.channelsSnapshot=r,n.channelsLastSuccess=Date.now()}catch(r){n.channelsError=String(r)}finally{n.channelsLoading=!1}}}async function nr(n,e){if(!(!n.client||!n.connected||n.whatsappBusy)){n.whatsappBusy=!0;try{const r=await n.client.request("web.login.start",{force:e,timeoutMs:3e4});n.whatsappLoginMessage=r.message??null,n.whatsappLoginQrDataUrl=r.qrDataUrl??null,n.whatsappLoginConnected=null}catch(r){n.whatsappLoginMessage=String(r),n.whatsappLoginQrDataUrl=null,n.whatsappLoginConnected=null}finally{n.whatsappBusy=!1}}}async function er(n){if(!(!n.client||!n.connected||n.whatsappBusy)){n.whatsappBusy=!0;try{const e=await n.client.request("web.login.wait",{timeoutMs:12e4});n.whatsappLoginMessage=e.message??null,n.whatsappLoginConnected=e.connected??null,e.connected&&(n.whatsappLoginQrDataUrl=null)}catch(e){n.whatsappLoginMessage=String(e),n.whatsappLoginConnected=null}finally{n.whatsappBusy=!1}}}async function rr(n){if(!(!n.client||!n.connected||n.whatsappBusy)){n.whatsappBusy=!0;try{await n.client.request("channels.logout",{channel:"whatsapp"}),n.whatsappLoginMessage="Logged out.",n.whatsappLoginQrDataUrl=null,n.whatsappLoginConnected=null}catch(e){n.whatsappLoginMessage=String(e)}finally{n.whatsappBusy=!1}}}function k(n){return typeof structuredClone=="function"?structuredClone(n):JSON.parse(JSON.stringify(n))}function q(n){return`${JSON.stringify(n,null,2).trimEnd()}
|
|
3
|
-
`}function bn(n,e,r){if(e.length===0)return;let o=n;for(let t=0;t<e.length-1;t+=1){const c=e[t],l=e[t+1];if(typeof c=="number"){if(!Array.isArray(o))return;o[c]==null&&(o[c]=typeof l=="number"?[]:{}),o=o[c]}else{if(typeof o!="object"||o==null)return;const a=o;a[c]==null&&(a[c]=typeof l=="number"?[]:{}),o=a[c]}}const i=e[e.length-1];if(typeof i=="number"){Array.isArray(o)&&(o[i]=r);return}typeof o=="object"&&o!=null&&(o[i]=r)}function Sn(n,e){if(e.length===0)return;let r=n;for(let i=0;i<e.length-1;i+=1){const t=e[i];if(typeof t=="number"){if(!Array.isArray(r))return;r=r[t]}else{if(typeof r!="object"||r==null)return;r=r[t]}if(r==null)return}const o=e[e.length-1];if(typeof o=="number"){Array.isArray(r)&&r.splice(o,1);return}typeof r=="object"&&r!=null&&delete r[o]}async function En(n){if(!(!n.client||!n.connected)){n.configLoading=!0,n.lastError=null;try{const e=await n.client.request("config.get",{});Hn(n,e)}catch(e){n.lastError=String(e)}finally{n.configLoading=!1}}}async function or(n){if(!(!n.client||!n.connected)&&!n.configSchemaLoading){n.configSchemaLoading=!0;try{const e=await n.client.request("config.schema",{});Xn(n,e)}catch(e){n.lastError=String(e)}finally{n.configSchemaLoading=!1}}}function Xn(n,e){n.configSchema=e.schema??null,n.configUiHints=e.uiHints??{},n.configSchemaVersion=e.version??null}function Hn(n,e){n.configSnapshot=e;const r=typeof e.raw=="string"?e.raw:e.config&&typeof e.config=="object"?q(e.config):n.configRaw;!n.configFormDirty||n.configFormMode==="raw"?n.configRaw=r:n.configForm?n.configRaw=q(n.configForm):n.configRaw=r,n.configValid=typeof e.valid=="boolean"?e.valid:null,n.configIssues=Array.isArray(e.issues)?e.issues:[],n.configFormDirty||(n.configForm=k(e.config??{}),n.configFormOriginal=k(e.config??{}),n.configRawOriginal=r)}async function Vn(n){if(!(!n.client||!n.connected)){n.configSaving=!0,n.lastError=null;try{const e=n.configFormMode==="form"&&n.configForm?q(n.configForm):n.configRaw,r=n.configSnapshot?.hash;if(!r){n.lastError="Config hash missing; reload and retry.";return}await n.client.request("config.set",{raw:e,baseHash:r}),n.configFormDirty=!1,await En(n)}catch(e){n.lastError=String(e)}finally{n.configSaving=!1}}}async function ir(n){if(!(!n.client||!n.connected)){n.configApplying=!0,n.lastError=null;try{const e=n.configFormMode==="form"&&n.configForm?q(n.configForm):n.configRaw,r=n.configSnapshot?.hash;if(!r){n.lastError="Config hash missing; reload and retry.";return}await n.client.request("config.apply",{raw:e,baseHash:r,sessionKey:n.applySessionKey}),n.configFormDirty=!1,await En(n)}catch(e){n.lastError=String(e)}finally{n.configApplying=!1}}}async function tr(n){if(!(!n.client||!n.connected)){n.updateRunning=!0,n.lastError=null;try{await n.client.request("godmode.update.run",{})}catch(e){n.lastError=String(e)}finally{n.updateRunning=!1}}}async function cr(n){if(!(!n.client||!n.connected)){n.pluginUpdateRunning=!0,n.lastError=null;try{await n.client.request("godmode.update.pluginRun",{})}catch(e){n.lastError=String(e)}finally{n.pluginUpdateRunning=!1}}}function dn(n,e,r){const o=k(n.configForm??n.configSnapshot?.config??{});bn(o,e,r),n.configForm=o,n.configFormDirty=!0,n.configFormMode==="form"&&(n.configRaw=q(o))}function sr(n,e){const r=k(n.configForm??n.configSnapshot?.config??{});Sn(r,e),n.configForm=r,n.configFormDirty=!0,n.configFormMode==="form"&&(n.configRaw=q(r))}async function lr(n,e,r){dn(n,["agents","defaults","model","primary"],e),dn(n,["agents","defaults","model","fallbacks"],r),await Vn(n)}const zn=/<\s*\/?\s*(?:think(?:ing)?|thought|antthinking|final)\b/i,_=/<\s*\/?\s*final\b[^>]*>/gi,gn=/<\s*(\/?)\s*(?:think(?:ing)?|thought|antthinking)\b[^>]*>/gi;function Wn(n,e){return n.trimStart()}function Qn(n,e){if(!n||!zn.test(n))return n;let r=n;_.test(r)?(_.lastIndex=0,r=r.replace(_,"")):_.lastIndex=0,gn.lastIndex=0;let o="",i=0,t=!1;for(const c of r.matchAll(gn)){const l=c.index??0,a=c[1]==="/";t?a&&(t=!1):(o+=r.slice(i,l),a||(t=!0)),i=l+c[0].length}return o+=r.slice(i),Wn(o)}function ar(n){return!n&&n!==0?"n/a":new Date(n).toLocaleString()}function ur(n){if(!n&&n!==0)return"n/a";const e=Date.now()-n;if(e<0)return"just now";const r=Math.round(e/1e3);if(r<60)return`${r}s ago`;const o=Math.round(r/60);if(o<60)return`${o}m ago`;const i=Math.round(o/60);return i<48?`${i}h ago`:`${Math.round(i/24)}d ago`}function fr(n){if(!n&&n!==0)return"";const e=Date.now()-n;if(e<0)return"now";const r=Math.round(e/1e3);if(r<60)return"now";const o=Math.round(r/60);if(o<60)return`${o}m`;const i=Math.round(o/60);return i<24?`${i}h`:`${Math.round(i/24)}d`}function dr(n){if(!n&&n!==0)return"n/a";if(n<1e3)return`${n}ms`;const e=Math.round(n/1e3);if(e<60)return`${e}s`;const r=Math.round(e/60);if(r<60)return`${r}m`;const o=Math.round(r/60);return o<48?`${o}h`:`${Math.round(o/24)}d`}function gr(n){return!n||n.length===0?"none":n.filter(e=>!!(e&&e.trim())).join(", ")}function yr(n,e=120){return n.length<=e?n:`${n.slice(0,Math.max(0,e-1))}…`}function pr(n,e){return n.length<=e?{text:n,truncated:!1,total:n.length}:{text:n.slice(0,Math.max(0,e)),truncated:!0,total:n.length}}function N(n,e){const r=Number(n);return Number.isFinite(r)?r:e}function hr(n){const e=n??new Date,r=e.getFullYear(),o=String(e.getMonth()+1).padStart(2,"0"),i=String(e.getDate()).padStart(2,"0");return`${r}-${o}-${i}`}function mr(n){return Qn(n)}async function ne(n){if(!(!n.client||!n.connected)&&!n.agentsLoading){n.agentsLoading=!0,n.agentsError=null;try{const e=await n.client.request("agents.list",{});e&&(n.agentsList=e)}catch(e){n.agentsError=String(e)}finally{n.agentsLoading=!1}}}async function ee(n){if(!(!n.client||!n.connected)&&!n.rosterLoading){n.rosterLoading=!0,n.rosterError=null;try{const e=await n.client.request("queue.roster",{});e?.roster&&(n.rosterData=e.roster)}catch(e){n.rosterError=String(e)}finally{n.rosterLoading=!1}}}const wr=Object.freeze(Object.defineProperty({__proto__:null,loadAgents:ne,loadRoster:ee},Symbol.toStringTag,{value:"Module"})),An="godmode.device.auth.v1";function nn(n){return n.trim()}function re(n){if(!Array.isArray(n))return[];const e=new Set;for(const r of n){const o=r.trim();o&&e.add(o)}return[...e].sort()}function en(){try{const n=window.localStorage.getItem(An);if(!n)return null;const e=JSON.parse(n);return!e||e.version!==1||!e.deviceId||typeof e.deviceId!="string"||!e.tokens||typeof e.tokens!="object"?null:e}catch{return null}}function kn(n){try{window.localStorage.setItem(An,JSON.stringify(n))}catch{}}function vr(n){const e=en();if(!e||e.deviceId!==n.deviceId)return null;const r=nn(n.role),o=e.tokens[r];return!o||typeof o.token!="string"?null:o}function oe(n){const e=nn(n.role),r={version:1,deviceId:n.deviceId,tokens:{}},o=en();o&&o.deviceId===n.deviceId&&(r.tokens={...o.tokens});const i={token:n.token,role:e,scopes:re(n.scopes),updatedAtMs:Date.now()};return r.tokens[e]=i,kn(r),i}function ie(n){const e=en();if(!e||e.deviceId!==n.deviceId)return;const r=nn(n.role);if(!e.tokens[r])return;const o={...e,tokens:{...e.tokens}};delete o.tokens[r],kn(o)}const Ln={p:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,n:0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3edn,h:8n,a:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffecn,d:0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3n,Gx:0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,Gy:0x6666666666666666666666666666666666666666666666666666666666666658n},{p:m,n:D,Gx:yn,Gy:pn,a:j,d:Z,h:te}=Ln,L=32,rn=64,ce=(...n)=>{"captureStackTrace"in Error&&typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(...n)},h=(n="")=>{const e=new Error(n);throw ce(e,h),e},se=n=>typeof n=="bigint",le=n=>typeof n=="string",ae=n=>n instanceof Uint8Array||ArrayBuffer.isView(n)&&n.constructor.name==="Uint8Array",E=(n,e,r="")=>{const o=ae(n),i=n?.length,t=e!==void 0;if(!o||t&&i!==e){const c=r&&`"${r}" `,l=t?` of length ${e}`:"",a=o?`length=${i}`:`type=${typeof n}`;h(c+"expected Uint8Array"+l+", got "+a)}return n},$=n=>new Uint8Array(n),xn=n=>Uint8Array.from(n),Tn=(n,e)=>n.toString(16).padStart(e,"0"),Cn=n=>Array.from(E(n)).map(e=>Tn(e,2)).join(""),S={_0:48,_9:57,A:65,F:70,a:97,f:102},hn=n=>{if(n>=S._0&&n<=S._9)return n-S._0;if(n>=S.A&&n<=S.F)return n-(S.A-10);if(n>=S.a&&n<=S.f)return n-(S.a-10)},qn=n=>{const e="hex invalid";if(!le(n))return h(e);const r=n.length,o=r/2;if(r%2)return h(e);const i=$(o);for(let t=0,c=0;t<o;t++,c+=2){const l=hn(n.charCodeAt(c)),a=hn(n.charCodeAt(c+1));if(l===void 0||a===void 0)return h(e);i[t]=l*16+a}return i},Fn=()=>globalThis?.crypto,ue=()=>Fn()?.subtle??h("crypto.subtle must be defined, consider polyfill"),I=(...n)=>{const e=$(n.reduce((o,i)=>o+E(i).length,0));let r=0;return n.forEach(o=>{e.set(o,r),r+=o.length}),e},fe=(n=L)=>Fn().getRandomValues($(n)),K=BigInt,A=(n,e,r,o="bad number: out of range")=>se(n)&&e<=n&&n<r?n:h(o),s=(n,e=m)=>{const r=n%e;return r>=0n?r:e+r},Mn=n=>s(n,D),de=(n,e)=>{(n===0n||e<=0n)&&h("no inverse n="+n+" mod="+e);let r=s(n,e),o=e,i=0n,t=1n;for(;r!==0n;){const c=o/r,l=o%r,a=i-t*c;o=r,r=l,i=t,t=a}return o===1n?s(i,e):h("no inverse")},ge=n=>{const e=_n[n];return typeof e!="function"&&h("hashes."+n+" not set"),e},J=n=>n instanceof w?n:h("Point expected"),H=2n**256n;class w{static BASE;static ZERO;X;Y;Z;T;constructor(e,r,o,i){const t=H;this.X=A(e,0n,t),this.Y=A(r,0n,t),this.Z=A(o,1n,t),this.T=A(i,0n,t),Object.freeze(this)}static CURVE(){return Ln}static fromAffine(e){return new w(e.x,e.y,1n,s(e.x*e.y))}static fromBytes(e,r=!1){const o=Z,i=xn(E(e,L)),t=e[31];i[31]=t&-129;const c=Bn(i);A(c,0n,r?H:m);const a=s(c*c),u=s(a-1n),f=s(o*a+1n);let{isValid:d,value:g}=pe(u,f);d||h("bad point: y not sqrt");const y=(g&1n)===1n,p=(t&128)!==0;return!r&&g===0n&&p&&h("bad point: x==0, isLastByteOdd"),p!==y&&(g=s(-g)),new w(g,c,1n,s(g*c))}static fromHex(e,r){return w.fromBytes(qn(e),r)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}assertValidity(){const e=j,r=Z,o=this;if(o.is0())return h("bad point: ZERO");const{X:i,Y:t,Z:c,T:l}=o,a=s(i*i),u=s(t*t),f=s(c*c),d=s(f*f),g=s(a*e),y=s(f*s(g+u)),p=s(d+s(r*s(a*u)));if(y!==p)return h("bad point: equation left != right (1)");const v=s(i*t),T=s(c*l);return v!==T?h("bad point: equation left != right (2)"):this}equals(e){const{X:r,Y:o,Z:i}=this,{X:t,Y:c,Z:l}=J(e),a=s(r*l),u=s(t*i),f=s(o*l),d=s(c*i);return a===u&&f===d}is0(){return this.equals(C)}negate(){return new w(s(-this.X),this.Y,this.Z,s(-this.T))}double(){const{X:e,Y:r,Z:o}=this,i=j,t=s(e*e),c=s(r*r),l=s(2n*s(o*o)),a=s(i*t),u=e+r,f=s(s(u*u)-t-c),d=a+c,g=d-l,y=a-c,p=s(f*g),v=s(d*y),T=s(f*y),R=s(g*d);return new w(p,v,R,T)}add(e){const{X:r,Y:o,Z:i,T:t}=this,{X:c,Y:l,Z:a,T:u}=J(e),f=j,d=Z,g=s(r*c),y=s(o*l),p=s(t*d*u),v=s(i*a),T=s((r+o)*(c+l)-g-y),R=s(v-p),an=s(v+p),un=s(y-f*g),Pn=s(T*R),Gn=s(an*un),Un=s(T*un),jn=s(R*an);return new w(Pn,Gn,jn,Un)}subtract(e){return this.add(J(e).negate())}multiply(e,r=!0){if(!r&&(e===0n||this.is0()))return C;if(A(e,1n,D),e===1n)return this;if(this.equals(x))return xe(e).p;let o=C,i=x;for(let t=this;e>0n;t=t.double(),e>>=1n)e&1n?o=o.add(t):r&&(i=i.add(t));return o}multiplyUnsafe(e){return this.multiply(e,!1)}toAffine(){const{X:e,Y:r,Z:o}=this;if(this.equals(C))return{x:0n,y:1n};const i=de(o,m);s(o*i)!==1n&&h("invalid inverse");const t=s(e*i),c=s(r*i);return{x:t,y:c}}toBytes(){const{x:e,y:r}=this.assertValidity().toAffine(),o=In(r);return o[31]|=e&1n?128:0,o}toHex(){return Cn(this.toBytes())}clearCofactor(){return this.multiply(K(te),!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){let e=this.multiply(D/2n,!1).double();return D%2n&&(e=e.add(this)),e.is0()}}const x=new w(yn,pn,1n,s(yn*pn)),C=new w(0n,1n,1n,0n);w.BASE=x;w.ZERO=C;const In=n=>qn(Tn(A(n,0n,H),rn)).reverse(),Bn=n=>K("0x"+Cn(xn(E(n)).reverse())),b=(n,e)=>{let r=n;for(;e-- >0n;)r*=r,r%=m;return r},ye=n=>{const r=n*n%m*n%m,o=b(r,2n)*r%m,i=b(o,1n)*n%m,t=b(i,5n)*i%m,c=b(t,10n)*t%m,l=b(c,20n)*c%m,a=b(l,40n)*l%m,u=b(a,80n)*a%m,f=b(u,80n)*a%m,d=b(f,10n)*t%m;return{pow_p_5_8:b(d,2n)*n%m,b2:r}},mn=0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0n,pe=(n,e)=>{const r=s(e*e*e),o=s(r*r*e),i=ye(n*o).pow_p_5_8;let t=s(n*r*i);const c=s(e*t*t),l=t,a=s(t*mn),u=c===n,f=c===s(-n),d=c===s(-n*mn);return u&&(t=l),(f||d)&&(t=a),(s(t)&1n)===1n&&(t=s(-t)),{isValid:u||f,value:t}},V=n=>Mn(Bn(n)),on=(...n)=>_n.sha512Async(I(...n)),he=(...n)=>ge("sha512")(I(...n)),Rn=n=>{const e=n.slice(0,L);e[0]&=248,e[31]&=127,e[31]|=64;const r=n.slice(L,rn),o=V(e),i=x.multiply(o),t=i.toBytes();return{head:e,prefix:r,scalar:o,point:i,pointBytes:t}},tn=n=>on(E(n,L)).then(Rn),me=n=>Rn(he(E(n,L))),we=n=>tn(n).then(e=>e.pointBytes),ve=n=>on(n.hashable).then(n.finish),be=(n,e,r)=>{const{pointBytes:o,scalar:i}=n,t=V(e),c=x.multiply(t).toBytes();return{hashable:I(c,o,r),finish:u=>{const f=Mn(t+V(u)*i);return E(I(c,In(f)),rn)}}},Se=async(n,e)=>{const r=E(n),o=await tn(e),i=await on(o.prefix,r);return ve(be(o,i,r))},_n={sha512Async:async n=>{const e=ue(),r=I(n);return $(await e.digest("SHA-512",r.buffer))},sha512:void 0},Ee=(n=fe(L))=>n,Ae={getExtendedPublicKeyAsync:tn,getExtendedPublicKey:me,randomSecretKey:Ee},O=8,ke=256,Dn=Math.ceil(ke/O)+1,z=2**(O-1),Le=()=>{const n=[];let e=x,r=e;for(let o=0;o<Dn;o++){r=e,n.push(r);for(let i=1;i<z;i++)r=r.add(e),n.push(r);e=r.double()}return n};let wn;const vn=(n,e)=>{const r=e.negate();return n?r:e},xe=n=>{const e=wn||(wn=Le());let r=C,o=x;const i=2**O,t=i,c=K(i-1),l=K(O);for(let a=0;a<Dn;a++){let u=Number(n&c);n>>=l,u>z&&(u-=t,n+=1n);const f=a*z,d=f,g=f+Math.abs(u)-1,y=a%2!==0,p=u<0;u===0?o=o.add(vn(y,e[d])):r=r.add(vn(p,e[g]))}return n!==0n&&h("invalid wnaf"),{p:r,f:o}},Y="godmode-device-identity-v1";function W(n){let e="";for(const r of n)e+=String.fromCharCode(r);return btoa(e).replaceAll("+","-").replaceAll("/","_").replace(/=+$/g,"")}function Nn(n){const e=n.replaceAll("-","+").replaceAll("_","/"),r=e+"=".repeat((4-e.length%4)%4),o=atob(r),i=new Uint8Array(o.length);for(let t=0;t<o.length;t+=1)i[t]=o.charCodeAt(t);return i}function Te(n){return Array.from(n).map(e=>e.toString(16).padStart(2,"0")).join("")}async function Kn(n){const e=await crypto.subtle.digest("SHA-256",n);return Te(new Uint8Array(e))}async function Ce(){const n=Ae.randomSecretKey(),e=await we(n);return{deviceId:await Kn(e),publicKey:W(e),privateKey:W(n)}}async function On(){try{const r=localStorage.getItem(Y);if(r){const o=JSON.parse(r);if(o?.version===1&&typeof o.deviceId=="string"&&typeof o.publicKey=="string"&&typeof o.privateKey=="string"){const i=await Kn(Nn(o.publicKey));if(i!==o.deviceId){const t={...o,deviceId:i};return localStorage.setItem(Y,JSON.stringify(t)),{deviceId:i,publicKey:o.publicKey,privateKey:o.privateKey}}return{deviceId:o.deviceId,publicKey:o.publicKey,privateKey:o.privateKey}}}}catch{}const n=await Ce(),e={version:1,deviceId:n.deviceId,publicKey:n.publicKey,privateKey:n.privateKey,createdAtMs:Date.now()};return localStorage.setItem(Y,JSON.stringify(e)),n}async function br(n,e){const r=Nn(n),o=new TextEncoder().encode(e),i=await Se(o,r);return W(i)}async function P(n,e){if(!(!n.client||!n.connected)&&!n.devicesLoading){n.devicesLoading=!0,e?.quiet||(n.devicesError=null);try{const r=await n.client.request("device.pair.list",{});n.devicesList={pending:Array.isArray(r?.pending)?r.pending:[],paired:Array.isArray(r?.paired)?r.paired:[]}}catch(r){e?.quiet||(n.devicesError=String(r))}finally{n.devicesLoading=!1}}}async function Sr(n,e){if(!(!n.client||!n.connected))try{await n.client.request("device.pair.approve",{requestId:e}),await P(n)}catch(r){n.devicesError=String(r)}}async function Er(n,e){if(!(!n.client||!n.connected||!window.confirm("Reject this device pairing request?")))try{await n.client.request("device.pair.reject",{requestId:e}),await P(n)}catch(o){n.devicesError=String(o)}}async function Ar(n,e){if(!(!n.client||!n.connected))try{const r=await n.client.request("device.token.rotate",e);if(r?.token){const o=await On(),i=r.role??e.role;(r.deviceId===o.deviceId||e.deviceId===o.deviceId)&&oe({deviceId:o.deviceId,role:i,token:r.token,scopes:r.scopes??e.scopes??[]}),window.prompt("New device token (copy and store securely):",r.token)}await P(n)}catch(r){n.devicesError=String(r)}}async function kr(n,e){if(!(!n.client||!n.connected||!window.confirm(`Revoke token for ${e.deviceId} (${e.role})?`)))try{await n.client.request("device.token.revoke",e);const o=await On();e.deviceId===o.deviceId&&ie({deviceId:o.deviceId,role:e.role}),await P(n)}catch(o){n.devicesError=String(o)}}async function Lr(n,e){if(!(!n.client||!n.connected)&&!n.nodesLoading){n.nodesLoading=!0,e?.quiet||(n.lastError=null);try{const r=await n.client.request("node.list",{}),o=Array.isArray(r.nodes)?r.nodes:[];JSON.stringify(o)!==JSON.stringify(n.nodes)&&(n.nodes=o)}catch(r){e?.quiet||(n.lastError=String(r))}finally{n.nodesLoading=!1}}}const $n="godmode:autoTitleCache";function qe(){try{const n=localStorage.getItem($n);if(n){const e=JSON.parse(n);return new Map(e)}}catch{}return new Map}function X(n){try{const e=[...n.entries()],r=e.length>200?e.slice(-200):e;localStorage.setItem($n,JSON.stringify(r))}catch{}}class Fe extends Map{set(e,r){return super.set(e,r),X(this),this}delete(e){const r=super.delete(e);return r&&X(this),r}clear(){super.clear(),X(this)}}const Q=new Fe(qe());async function B(n,e){if(!(!n.client||!n.connected)&&!n.sessionsLoading){n.sessionsLoading=!0,n.sessionsError=null;try{const r=e?.includeGlobal??n.sessionsIncludeGlobal,o=e?.includeUnknown??n.sessionsIncludeUnknown,i=e?.activeMinutes??N(n.sessionsFilterActive,0),t=e?.limit??N(n.sessionsFilterLimit,50),c={includeGlobal:r,includeUnknown:o};i>0&&(c.activeMinutes=i),t>0&&(c.limit=t);const l=await n.client.request("sessions.list",c);if(l){if(l.sessions){const a=new Map;if(n.sessionsResult?.sessions)for(const u of n.sessionsResult.sessions)u.displayName&&a.set(u.key,u.displayName);l.sessions=l.sessions.map(u=>{if(u.label||u.displayName)return u;let f=Q.get(u.key);if(!f){const g=u.key.split(":").pop();if(g&&g.length>=4){for(const[y,p]of Q)if(y===u.key||y.endsWith(`:${g}`)||u.key.endsWith(`:${y.split(":").pop()}`)){f=p;break}}}if(f)return{...u,displayName:f};const d=a.get(u.key);return d?{...u,displayName:d}:u})}n.sessionsResult=l}}catch(r){n.sessionsError=String(r)}finally{n.sessionsLoading=!1}}}async function Me(n,e,r){if(!n.client||!n.connected)return{ok:!1};const o={key:e};"label"in r&&(o.label=r.label),"displayName"in r&&(o.displayName=r.displayName),"thinkingLevel"in r&&(o.thinkingLevel=r.thinkingLevel),"verboseLevel"in r&&(o.verboseLevel=r.verboseLevel),"reasoningLevel"in r&&(o.reasoningLevel=r.reasoningLevel);try{const{safeRequest:i}=await Yn(async()=>{const{safeRequest:c}=await import("./index-Covj4w7X.js").then(l=>l.x);return{safeRequest:c}},__vite__mapDeps([0,1,2,3,4]),import.meta.url),t=await i(n.client,"sessions.patch",o);return t.ok?{ok:!0,canonicalKey:t.data?.key??e}:(n.sessionsError=t.error,{ok:!1})}catch(i){return n.sessionsError=String(i),{ok:!1}}}async function Ie(n,e){if(!(!n.client||!n.connected||n.sessionsLoading||!window.confirm(`Delete session "${e}"?
|
|
4
|
-
|
|
5
|
-
Deletes the session entry and archives its transcript.`))){n.sessionsLoading=!0,n.sessionsError=null;try{await n.client.request("sessions.delete",{key:e,deleteTranscript:!0}),await B(n)}catch(o){n.sessionsError=String(o)}finally{n.sessionsLoading=!1}}}async function G(n){if(!(!n.client||!n.connected)){n.archivedSessionsLoading=!0;try{const e=await n.client.request("sessions.archived",{});e?.archived&&(n.archivedSessions=e.archived)}catch{}finally{n.archivedSessionsLoading=!1}}}async function Be(n,e){if(!(!n.client||!n.connected))try{await n.client.request("sessions.archive",{sessionKey:e}),await G(n),await B(n)}catch(r){n.sessionsError=`Archive failed: ${String(r)}`}}async function Re(n,e){if(!(!n.client||!n.connected))try{await n.client.request("sessions.unarchive",{sessionKey:e}),await G(n),await B(n)}catch(r){n.sessionsError=`Unarchive failed: ${String(r)}`}}async function _e(n){if(!n.client||!n.connected)return 0;try{const r=(await n.client.request("sessions.autoArchive",{}))?.archivedCount??0;return await G(n),await B(n),r}catch(e){return n.sessionsError=`Auto-archive failed: ${String(e)}`,0}}const xr=Object.freeze(Object.defineProperty({__proto__:null,archiveSession:Be,autoTitleCache:Q,deleteSession:Ie,loadArchivedSessions:G,loadSessions:B,patchSession:Me,triggerAutoArchive:_e,unarchiveSession:Re},Symbol.toStringTag,{value:"Module"}));async function Tr(n){if(!(!n.client||!n.connected)&&!n.debugLoading){n.debugLoading=!0;try{const[e,r,o,i]=await Promise.all([n.client.request("status",{}),n.client.request("health",{}),n.client.request("models.list",{}),n.client.request("last-heartbeat",{})]);n.debugStatus=e,n.debugHealth=r;const t=o;n.debugModels=Array.isArray(t?.models)?t?.models:[],n.debugHeartbeat=i}catch(e){n.debugCallError=String(e)}finally{n.debugLoading=!1}}}async function Cr(n){if(!(!n.client||!n.connected)){n.debugCallError=null,n.debugCallResult=null;try{const e=n.debugCallParams.trim()?JSON.parse(n.debugCallParams):{},r=await n.client.request(n.debugCallMethod.trim(),e);n.debugCallResult=JSON.stringify(r,null,2)}catch(e){n.debugCallError=String(e)}}}const De=2e3,Ne=new Set(["trace","debug","info","warn","error","fatal"]);function Ke(n){if(typeof n!="string")return null;const e=n.trim();if(!e.startsWith("{")||!e.endsWith("}"))return null;try{const r=JSON.parse(e);return!r||typeof r!="object"?null:r}catch{return null}}function Oe(n){if(typeof n!="string")return null;const e=n.toLowerCase();return Ne.has(e)?e:null}function $e(n){if(!n.trim())return{raw:n,message:n};try{const e=JSON.parse(n),r=e&&typeof e._meta=="object"&&e._meta!==null?e._meta:null,o=typeof e.time=="string"?e.time:typeof r?.date=="string"?r?.date:null,i=Oe(r?.logLevelName??r?.level),t=typeof e[0]=="string"?e[0]:typeof r?.name=="string"?r?.name:null,c=Ke(t);let l=null;c&&(typeof c.subsystem=="string"?l=c.subsystem:typeof c.module=="string"&&(l=c.module)),!l&&t&&t.length<120&&(l=t);let a=null;return typeof e[1]=="string"?a=e[1]:!c&&typeof e[0]=="string"?a=e[0]:typeof e.message=="string"&&(a=e.message),{raw:n,time:o,level:i,subsystem:l,message:a??n,meta:r??void 0}}catch{return{raw:n,message:n}}}async function qr(n,e){if(!(!n.client||!n.connected)&&!(n.logsLoading&&!e?.quiet)){e?.quiet||(n.logsLoading=!0),n.logsError=null;try{const o=await n.client.request("logs.tail",{cursor:e?.reset?void 0:n.logsCursor??void 0,limit:n.logsLimit,maxBytes:n.logsMaxBytes}),t=(Array.isArray(o.lines)?o.lines.filter(l=>typeof l=="string"):[]).map($e),c=!!(e?.reset||o.reset||n.logsCursor==null);n.logsEntries=c?t:[...n.logsEntries,...t].slice(-De),typeof o.cursor=="number"&&(n.logsCursor=o.cursor),typeof o.file=="string"&&(n.logsFile=o.file),n.logsTruncated=!!o.truncated,n.logsLastFetchAt=Date.now()}catch(r){n.logsError=String(r)}finally{e?.quiet||(n.logsLoading=!1)}}}async function cn(n){if(!(!n.client||!n.connected))try{const e=await n.client.request("cron.status",{});n.cronStatus=e}catch(e){n.cronError=String(e)}}async function sn(n){if(!(!n.client||!n.connected)&&!n.cronLoading){n.cronLoading=!0,n.cronError=null;try{const e=await n.client.request("cron.list",{includeDisabled:!0});n.cronJobs=Array.isArray(e.jobs)?e.jobs:[]}catch(e){n.cronError=String(e)}finally{n.cronLoading=!1}}}function Pe(n){if(n.scheduleKind==="at"){const r=Date.parse(n.scheduleAt);if(!Number.isFinite(r))throw new Error("Invalid run time.");return{kind:"at",atMs:r}}if(n.scheduleKind==="every"){const r=N(n.everyAmount,0);if(r<=0)throw new Error("Invalid interval amount.");const o=n.everyUnit;return{kind:"every",everyMs:r*(o==="minutes"?6e4:o==="hours"?36e5:864e5)}}const e=n.cronExpr.trim();if(!e)throw new Error("Cron expression required.");return{kind:"cron",expr:e,tz:n.cronTz.trim()||void 0}}function Ge(n){if(n.payloadKind==="systemEvent"){const i=n.payloadText.trim();if(!i)throw new Error("System event text required.");return{kind:"systemEvent",text:i}}const e=n.payloadText.trim();if(!e)throw new Error("Agent message required.");const r={kind:"agentTurn",message:e};n.deliver&&(r.deliver=!0),n.channel&&(r.channel=n.channel),n.to.trim()&&(r.to=n.to.trim());const o=N(n.timeoutSeconds,0);return o>0&&(r.timeoutSeconds=o),r}async function Fr(n){if(!(!n.client||!n.connected||n.cronBusy)){n.cronBusy=!0,n.cronError=null;try{const e=Pe(n.cronForm),r=Ge(n.cronForm),o=n.cronForm.agentId.trim(),i={name:n.cronForm.name.trim(),description:n.cronForm.description.trim()||void 0,agentId:o||void 0,enabled:n.cronForm.enabled,schedule:e,sessionTarget:n.cronForm.sessionTarget,wakeMode:n.cronForm.wakeMode,payload:r,isolation:n.cronForm.postToMainPrefix.trim()&&n.cronForm.sessionTarget==="isolated"?{postToMainPrefix:n.cronForm.postToMainPrefix.trim()}:void 0};if(!i.name)throw new Error("Name required.");await n.client.request("cron.add",i),n.cronForm={...n.cronForm,name:"",description:"",payloadText:""},await sn(n),await cn(n)}catch(e){n.cronError=String(e)}finally{n.cronBusy=!1}}}async function Mr(n,e,r){if(!(!n.client||!n.connected||n.cronBusy)){n.cronBusy=!0,n.cronError=null;try{await n.client.request("cron.update",{id:e.id,patch:{enabled:r}}),await sn(n),await cn(n)}catch(o){n.cronError=String(o)}finally{n.cronBusy=!1}}}async function Ir(n,e){if(!(!n.client||!n.connected||n.cronBusy)){n.cronBusy=!0,n.cronError=null;try{await n.client.request("cron.run",{id:e.id,mode:"force"}),await Ue(n,e.id)}catch(r){n.cronError=String(r)}finally{n.cronBusy=!1}}}async function Br(n,e){if(!(!n.client||!n.connected||n.cronBusy)){n.cronBusy=!0,n.cronError=null;try{await n.client.request("cron.remove",{id:e.id}),n.cronRunsJobId===e.id&&(n.cronRunsJobId=null,n.cronRuns=[]),await sn(n),await cn(n)}catch(r){n.cronError=String(r)}finally{n.cronBusy=!1}}}async function Ue(n,e){if(!(!n.client||!n.connected))try{const r=await n.client.request("cron.runs",{id:e,limit:50});n.cronRunsJobId=e,n.cronRuns=Array.isArray(r.entries)?r.entries:[]}catch(r){n.cronError=String(r)}}async function M(n){if(!(!n.client||!n.connected)){n.guardrailsLoading=!0;try{const[e,r]=await Promise.all([n.client.request("guardrails.list",{}),n.client.request("guardrails.history",{limit:50})]);n.guardrailsData={gates:e.gates,activity:r.activity,custom:e.custom??[]}}catch(e){console.error("[Guardrails] load error:",e),n.guardrailsData=null}finally{n.guardrailsLoading=!1}}}async function je(n,e,r){if(!(!n.client||!n.connected))try{await n.client.request("guardrails.set",{gateId:e,enabled:r});const i=n.guardrailsData?.gates.find(t=>t.id===e)?.name??e;n.showToast(`${i} ${r?"enabled":"disabled"}`,"success",2e3),await M(n)}catch(o){n.showToast("Failed to update guardrail","error"),console.error("[Guardrails] toggle error:",o)}}async function Ze(n,e,r,o){if(!(!n.client||!n.connected))try{await n.client.request("guardrails.set",{gateId:e,thresholds:{[r]:o}}),n.showToast("Threshold updated","success",2e3),await M(n)}catch(i){n.showToast("Failed to update threshold","error"),console.error("[Guardrails] threshold error:",i)}}async function Je(n,e,r){if(!(!n.client||!n.connected))try{await n.client.request("guardrails.setCustom",{id:e,enabled:r}),n.showToast(`Custom rule ${r?"enabled":"disabled"}`,"success",2e3),await M(n)}catch(o){n.showToast("Failed to update custom rule","error"),console.error("[Guardrails] toggleCustom error:",o)}}async function Ye(n,e){if(!(!n.client||!n.connected))try{await n.client.request("guardrails.removeCustom",{id:e}),n.showToast("Custom rule removed","success",2e3),await M(n)}catch(r){n.showToast("Failed to remove custom rule","error"),console.error("[Guardrails] deleteCustom error:",r)}}async function Xe(n,e){if(!(!n.client||!n.connected))try{await n.client.request("guardrails.addCustom",{guardrail:{name:e.name,description:"",enabled:!0,trigger:{tool:e.tool,patterns:e.patterns},action:e.action,message:e.message,...e.redirectTo?{redirectTo:e.redirectTo}:{}}}),n.showToast("Custom rule created","success",2e3),await M(n)}catch(r){n.showToast("Failed to create custom rule","error"),console.error("[Guardrails] addCustom error:",r)}}const Rr=Object.freeze(Object.defineProperty({__proto__:null,addCustomGuardrailFromUI:Xe,deleteCustomGuardrail:Ye,loadGuardrails:M,toggleCustomGuardrail:Je,toggleGuardrail:je,updateGuardrailThreshold:Ze},Symbol.toStringTag,{value:"Module"}));function He(n){if(!n||n.kind==="gateway")return{method:"exec.approvals.get",params:{}};const e=n.nodeId.trim();return e?{method:"exec.approvals.node.get",params:{nodeId:e}}:null}function Ve(n,e){if(!n||n.kind==="gateway")return{method:"exec.approvals.set",params:e};const r=n.nodeId.trim();return r?{method:"exec.approvals.node.set",params:{...e,nodeId:r}}:null}async function ze(n,e){if(!(!n.client||!n.connected)&&!n.execApprovalsLoading){n.execApprovalsLoading=!0,n.lastError=null;try{const r=He(e);if(!r){n.lastError="Select a node before loading exec approvals.";return}const o=await n.client.request(r.method,r.params);We(n,o)}catch(r){n.lastError=String(r)}finally{n.execApprovalsLoading=!1}}}function We(n,e){n.execApprovalsSnapshot=e,n.execApprovalsDirty||(n.execApprovalsForm=k(e.file??{}))}async function _r(n,e){if(!(!n.client||!n.connected)){n.execApprovalsSaving=!0,n.lastError=null;try{const r=n.execApprovalsSnapshot?.hash;if(!r){n.lastError="Exec approvals hash missing; reload and retry.";return}const o=n.execApprovalsForm??n.execApprovalsSnapshot?.file??{},i=Ve(e,{file:o,baseHash:r});if(!i){n.lastError="Select a node before saving exec approvals.";return}await n.client.request(i.method,i.params),n.execApprovalsDirty=!1,await ze(n,e)}catch(r){n.lastError=String(r)}finally{n.execApprovalsSaving=!1}}}function Dr(n,e,r){const o=k(n.execApprovalsForm??n.execApprovalsSnapshot?.file??{});bn(o,e,r),n.execApprovalsForm=o,n.execApprovalsDirty=!0}function Nr(n,e){const r=k(n.execApprovalsForm??n.execApprovalsSnapshot?.file??{});Sn(r,e),n.execApprovalsForm=r,n.execApprovalsDirty=!0}async function Kr(n){if(!(!n.client||!n.connected)&&!n.presenceLoading){n.presenceLoading=!0,n.presenceError=null,n.presenceStatus=null;try{const e=await n.client.request("system-presence",{});Array.isArray(e)?(n.presenceEntries=e,n.presenceStatus=e.length===0?"No instances yet.":null):(n.presenceEntries=[],n.presenceStatus="No presence payload.")}catch(e){n.presenceError=String(e)}finally{n.presenceLoading=!1}}}function F(n,e,r){if(!e.trim())return;const o={...n.skillMessages};r?o[e]=r:delete o[e],n.skillMessages=o}function U(n){return n instanceof Error?n.message:String(n)}async function ln(n,e){if(e?.clearMessages&&Object.keys(n.skillMessages).length>0&&(n.skillMessages={}),!(!n.client||!n.connected)&&!n.skillsLoading){n.skillsLoading=!0,n.skillsError=null;try{const r=await n.client.request("skills.status",{});r&&(n.skillsReport=r)}catch(r){n.skillsError=U(r)}finally{n.skillsLoading=!1}}}async function Or(n){if(!(!n.client||!n.connected)){n.godmodeSkillsLoading=!0;try{const e=await n.client.request("godmode.skills.list",{});n.godmodeSkills=e??null}catch(e){console.error("[Skills] Failed to load GodMode skills:",e),n.godmodeSkills=null}finally{n.godmodeSkillsLoading=!1}}}function $r(n,e,r){n.skillEdits={...n.skillEdits,[e]:r}}async function Pr(n,e,r){if(!(!n.client||!n.connected)){n.skillsBusyKey=e,n.skillsError=null;try{await n.client.request("skills.update",{skillKey:e,enabled:r}),await ln(n),F(n,e,{kind:"success",message:r?"Skill enabled":"Skill disabled"})}catch(o){const i=U(o);n.skillsError=i,F(n,e,{kind:"error",message:i})}finally{n.skillsBusyKey=null}}}async function Gr(n,e){if(!(!n.client||!n.connected)){n.skillsBusyKey=e,n.skillsError=null;try{const r=n.skillEdits[e]??"";await n.client.request("skills.update",{skillKey:e,apiKey:r}),await ln(n),F(n,e,{kind:"success",message:"API key saved"})}catch(r){const o=U(r);n.skillsError=o,F(n,e,{kind:"error",message:o})}finally{n.skillsBusyKey=null}}}async function Ur(n,e,r,o){if(!(!n.client||!n.connected)){n.skillsBusyKey=e,n.skillsError=null;try{const i=await n.client.request("skills.install",{name:r,installId:o,timeoutMs:12e4});await ln(n),F(n,e,{kind:"success",message:i?.message??"Installed"})}catch(i){const t=U(i);n.skillsError=t,F(n,e,{kind:"error",message:t})}finally{n.skillsBusyKey=null}}}export{Dr as $,cn as A,sn as B,G as C,ln as D,Or as E,ze as F,M as G,or as H,fr as I,Me as J,_e as K,Re as L,Be as M,Ie as N,Ue as O,Br as P,Ir as Q,Mr as R,Fr as S,Ur as T,Gr as U,$r as V,Pr as W,ee as X,_r as Y,Nr as Z,Yn as _,ar as a,dn as a0,sr as a1,cr as a2,tr as a3,lr as a4,ir as a5,Cr as a6,kr as a7,Ar as a8,Er as a9,Sr as aa,hr as ab,wr as ac,xr as ad,Rr as ae,dr as b,gr as c,yr as d,rr as e,ur as f,Vn as g,En as h,mr as i,On as j,vr as k,Qe as l,br as m,oe as n,ie as o,ne as p,Lr as q,P as r,nr as s,pr as t,B as u,Q as v,er as w,qr as x,Tr as y,Kr as z};
|