aegisone 1.0.58 → 1.0.59

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.
@@ -352,6 +352,13 @@ const DESKTOP_CLASSES = Object.freeze(['aegis', 'byok', 'local']);
352
352
  */
353
353
  const CHAT_DELTA_CHANNEL = `${IPC_PREFIX}chatDelta`;
354
354
 
355
+ /**
356
+ * ON9 — main -> renderer push channel for the embedded terminal panel's
357
+ * data/exit frames, tagged by session id the same way CHAT_DELTA_CHANNEL is
358
+ * (see createPtyIpc below and preload.js aegis.pty.onEvent).
359
+ */
360
+ const PTY_EVENT_CHANNEL = `${IPC_PREFIX}ptyEvent`;
361
+
355
362
  /** Main -> renderer pushes for native menu accelerators (Cmd/Ctrl+N,
356
363
  * Cmd/Ctrl+K) that have no Electron role to bind to — the renderer owns
357
364
  * "new chat" and "open search" behaviour, so the menu just asks for it. */
@@ -2049,6 +2056,66 @@ function createCliFaceDispatch(deps) {
2049
2056
  };
2050
2057
  }
2051
2058
 
2059
+ /**
2060
+ * ON9 — register the embedded terminal panel's five `aegis:pty*` handlers.
2061
+ *
2062
+ * Not routed through the generic `{name: handler}` wrapper the rest of this
2063
+ * file's settings-surface dispatches use (`registerConfirmModeIpc`): that
2064
+ * wrapper drops `event`, and `ptyExec` needs `event.sender` to push streamed
2065
+ * data/exit frames the same way `chatCompletion`'s streaming branch does
2066
+ * (see `registerIpc`'s special case above). The decision logic — what counts
2067
+ * as a capable pty backend, when to refuse rather than downgrade — lives
2068
+ * entirely in `lib/local/pty-host.js`; this function is the effects: probe
2069
+ * `node-pty`, build the host once, wire five channels to it.
2070
+ */
2071
+ function createPtyIpc(ipcMain, deps) {
2072
+ const d = deps || {};
2073
+ const hostMod = d.ptyHostModule || require('./lib/local/pty-host.js');
2074
+ const nodePty = d.nodePty !== undefined ? d.nodePty : hostMod.probeNodePty();
2075
+ const host = hostMod.createPtyHost({
2076
+ nativePty: Boolean(nodePty),
2077
+ appInfo: d.appInfo,
2078
+ spawnPty: nodePty
2079
+ ? (argv, opts) =>
2080
+ nodePty.spawn(argv[0], argv.slice(1), {
2081
+ name: 'xterm-color',
2082
+ cols: opts.cols || 80,
2083
+ rows: opts.rows || 24,
2084
+ cwd: opts.cwd || process.cwd(),
2085
+ // Merged, never replaced: `command.env` from cli-face.js's
2086
+ // innerCommand() carries only the ONE switch it adds
2087
+ // (ELECTRON_RUN_AS_NODE) on the bundled branch, not a full
2088
+ // environment — `opts.env || process.env` would have handed the
2089
+ // spawned process that single variable and nothing else (no
2090
+ // PATH, no HOME), the same bug Object.assign already avoids in
2091
+ // the external-terminal path above (openCliFace's spawnChild).
2092
+ env: Object.assign({}, process.env, opts.env || {}),
2093
+ })
2094
+ : undefined,
2095
+ });
2096
+
2097
+ ipcMain.handle(`${IPC_PREFIX}ptyHello`, (_event, payload) => host.hello((payload && payload.id) || 0));
2098
+ ipcMain.handle(`${IPC_PREFIX}ptyExec`, (event, payload) => {
2099
+ const p = payload || {};
2100
+ const sender = event && event.sender;
2101
+ const emit = (frame) => {
2102
+ if (sender && !sender.isDestroyed()) sender.send(PTY_EVENT_CHANNEL, frame);
2103
+ };
2104
+ return host.exec(p.id, p.params, emit);
2105
+ });
2106
+ ipcMain.handle(`${IPC_PREFIX}ptyWrite`, (_event, payload) => {
2107
+ const p = payload || {};
2108
+ return host.write(p.id, p.data);
2109
+ });
2110
+ ipcMain.handle(`${IPC_PREFIX}ptyResize`, (_event, payload) => {
2111
+ const p = payload || {};
2112
+ return host.resize(p.id, p.cols, p.rows);
2113
+ });
2114
+ ipcMain.handle(`${IPC_PREFIX}ptyCancel`, (_event, payload) => host.cancel((payload || {}).id));
2115
+
2116
+ return host;
2117
+ }
2118
+
2052
2119
  function createSandboxPolicyDispatch(settings, sandbox, opts) {
2053
2120
  if (!settings) throw new Error('createSandboxPolicyDispatch requires a settings store');
2054
2121
  const mod = sandbox || {};
@@ -2481,7 +2548,33 @@ function createEngine(aegis, { app, safeStorage, dir: dirOverride, sessionsDir:
2481
2548
  // never as `off`. `strict` is the user's own choice and lives beside the
2482
2549
  // policy; absent means degrade-loudly, because refusing every command on an
2483
2550
  // AppArmor-restricted host would brick the product rather than protect it.
2484
- sandbox: { policy: settings.getSandboxPolicy(), strict: false, appDir: __dirname },
2551
+ //
2552
+ // A GETTER, not a captured value — the same seam the terminal face passes
2553
+ // (`cli/src/engine.js`), for the same reason, and this host had the bug that
2554
+ // comment warns about. `resolveSandbox()` in engine.js reads `policy` once
2555
+ // per turn; capturing the store's value HERE meant it read whatever existed
2556
+ // at first-window creation and never again. The visible symptom was the
2557
+ // Settings › sandbox network switch: flipping "allow network from sandboxed
2558
+ // commands" wrote to disk, repainted the caption, and left the running
2559
+ // engine enforcing the OLD axis until the app was relaunched. On Linux that
2560
+ // looked like a stale sandbox; on macOS it read as "the network approval is
2561
+ // broken", because `sandbox-seatbelt.js` is the file that turns that axis
2562
+ // into `(deny network*)` and it was being handed a policy the user had
2563
+ // already changed. Windows had the identical staleness behind an
2564
+ // unimplemented mechanism, so the toggle could never have any effect there
2565
+ // either.
2566
+ //
2567
+ // Guarded because a staged settings store may predate the accessor — the
2568
+ // same shape `cli/src/engine.js` uses. A missing accessor answers null,
2569
+ // which `resolveSandbox()` reads as "no policy was requested", i.e. the
2570
+ // pre-existing unconfined turn, never as a permissive default.
2571
+ sandbox: {
2572
+ policy: () => (typeof settings.getSandboxPolicy === 'function'
2573
+ ? settings.getSandboxPolicy()
2574
+ : null),
2575
+ strict: false,
2576
+ appDir: __dirname,
2577
+ },
2485
2578
  // Stored /permissions rules (~/plan/agent-safety-plan.md §2). The rules live
2486
2579
  // in the SHARED data dir (~/.aegiscode/permissions.json), which is the same
2487
2580
  // file the terminal face writes via `/permissions allow|deny|ask`, so a rule
@@ -6112,6 +6205,22 @@ function bootstrap() {
6112
6205
  })
6113
6206
  );
6114
6207
 
6208
+ // ON9 — the same chip's OTHER outcome: the terminal face drawn INSIDE this
6209
+ // window instead of a second OS process, when `node-pty` (an
6210
+ // optionalDependency, same discipline as `electron` itself) resolves.
6211
+ // `createPtyIpc` probes it once at bootstrap; `aegis:ptyHello`'s caps tell
6212
+ // the renderer whether to open the embedded panel or fall back to the
6213
+ // `openCliFace` path above — that choice is the renderer's, not main's.
6214
+ createPtyIpc(ipcMain, {
6215
+ appInfo: {
6216
+ packaged: app.isPackaged,
6217
+ resourcesPath: process.resourcesPath,
6218
+ appDir: __dirname,
6219
+ execPath: process.execPath,
6220
+ nodePath: process.execPath,
6221
+ },
6222
+ });
6223
+
6115
6224
  // Funnel instrumentation (Phase 2 of docs/upgrade-conversion-plan.md):
6116
6225
  // aegis:telemetryEvent / aegis:telemetryReport, backed by
6117
6226
  // lib/local/telemetry.js.
@@ -7055,6 +7164,8 @@ module.exports = {
7055
7164
  TOPUP_POLL_MS,
7056
7165
  TOPUP_POLL_TRIES,
7057
7166
  CHAT_DELTA_CHANNEL,
7167
+ PTY_EVENT_CHANNEL,
7168
+ createPtyIpc,
7058
7169
  MENU_NEW_CHAT_CHANNEL,
7059
7170
  MENU_SEARCH_CHANNEL,
7060
7171
  MENU_SEARCH_MEMORY_CHANNEL,
@@ -2,7 +2,7 @@
2
2
  "name": "aegis-desktop",
3
3
  "productName": "aegis one",
4
4
  "desktopName": "aegis-desktop",
5
- "version": "1.0.50",
5
+ "version": "1.0.51",
6
6
  "description": "Thin Electron host for AEGIS — a local chat UI over the shared client/aegis.js transport. Ships transport + UI only; engine logic stays server-side.",
7
7
  "author": {
8
8
  "name": "AEGIS Code",
@@ -37,7 +37,7 @@
37
37
  "dist": "npm run predist && npm run obf && npm run obf:check && npm run sandbox:check && npm run bytenode && npm run bytenode:check && npm run bytenode:boot && electron-builder",
38
38
  "dist:dir": "npm run predist && npm run obf && npm run obf:check && npm run sandbox:check && npm run bytenode && npm run bytenode:check && npm run bytenode:boot && electron-builder --dir",
39
39
  "obf": "node ../tools/obfuscate-faces.mjs --only desktop",
40
- "check": "node --check main.js && node --check preload.js && node --check renderer/app.js && node --check renderer/welcome-rows.js && node --check renderer/commands.js && node --check renderer/palette-filter.js && node --check renderer/shortcuts.js && node --check renderer/find-in-conversation.js && node --check renderer/composer-triggers.js && node --check renderer/nav-history.js && node --check renderer/quick.js && node --check renderer/providers.js && node --check renderer/provider-toolbar.js && node --check renderer/companion.js && node --check renderer/budget.js && node --check renderer/usage.js && node --check renderer/stream-policy.js && node --check renderer/transcript-view.js && node --check renderer/diff.js && node --check renderer/diffview.js && node --check renderer/library.js && node --check renderer/markdown.js && node --check renderer/vendor/aegis-highlight.js && node --check scripts/predist.mjs && node --check scripts/deploy-local.mjs && node --check scripts/generate-icon.mjs && node --check scripts/bundle-fonts.mjs && node --check lib/local/local.js && node --check lib/local/context.js && node --check lib/local/engine.js && node --check lib/local/session-rounds.js && node --check lib/local/tools.js && node --check lib/local/prompt.js && node --check lib/local/shell.js && node --check lib/local/exec-plan.js && node --check lib/local/agents.js && node --check lib/local/queue.js && node --check lib/local/autonomous.js && node --check lib/account-key.js && node --check lib/settings.js && node --check lib/sync/sessions.js && node --check lib/sync/memory-queue.js && node --check lib/window-state.js && node --check lib/deep-link.js && node --check lib/quick-launcher.js && node --check lib/avatar/tiers.js && node --check lib/avatar/xp.js && node --check lib/avatar/level.js && node --check lib/avatar/events.js && node --check lib/avatar/persona.js && node --check bin/aegis.js",
40
+ "check": "node --check main.js && node --check preload.js && node --check renderer/app.js && node --check renderer/welcome-rows.js && node --check renderer/commands.js && node --check renderer/palette-filter.js && node --check renderer/shortcuts.js && node --check renderer/find-in-conversation.js && node --check renderer/composer-triggers.js && node --check renderer/nav-history.js && node --check renderer/quick.js && node --check renderer/providers.js && node --check renderer/provider-toolbar.js && node --check renderer/companion.js && node --check renderer/budget.js && node --check renderer/usage.js && node --check renderer/stream-policy.js && node --check renderer/transcript-view.js && node --check renderer/diff.js && node --check renderer/diffview.js && node --check renderer/library.js && node --check renderer/markdown.js && node --check renderer/vendor/aegis-highlight.js && node --check scripts/predist.mjs && node --check scripts/deploy-local.mjs && node --check scripts/generate-icon.mjs && node --check scripts/bundle-fonts.mjs && node --check lib/local/local.js && node --check lib/local/context.js && node --check lib/local/engine.js && node --check lib/local/session-rounds.js && node --check lib/local/tools.js && node --check lib/local/prompt.js && node --check lib/local/shell.js && node --check lib/local/exec-plan.js && node --check lib/local/agents.js && node --check lib/local/queue.js && node --check lib/local/autonomous.js && node --check lib/local/pty-host.js && node --check renderer/pty-panel.js && node --check lib/account-key.js && node --check lib/settings.js && node --check lib/sync/sessions.js && node --check lib/sync/memory-queue.js && node --check lib/window-state.js && node --check lib/deep-link.js && node --check lib/quick-launcher.js && node --check lib/avatar/tiers.js && node --check lib/avatar/xp.js && node --check lib/avatar/level.js && node --check lib/avatar/events.js && node --check lib/avatar/persona.js && node --check bin/aegis.js",
41
41
  "test:shell": "node ../test/desktop-shell.mjs",
42
42
  "test:model": "node ../test/model-dispatch.mjs",
43
43
  "test:budget": "node ../test/budget.test.mjs",
@@ -86,6 +86,7 @@
86
86
  "electron-builder": "^26.15.3"
87
87
  },
88
88
  "optionalDependencies": {
89
- "electron": "^44.0.0"
89
+ "electron": "^44.0.0",
90
+ "node-pty": "^1.1.0"
90
91
  }
91
92
  }
@@ -1,3 +1,3 @@
1
1
  // SPDX-License-Identifier: AGPL-3.0-or-later
2
2
  // Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
3
- "use strict";const{contextBridge:contextBridge,ipcRenderer:ipcRenderer}=require("electron"),IPC_PREFIX="aegis:",MODEL_PREFIX="model:",SYNC_PREFIX="sync:",QUICK_PREFIX="quick:",QUEUE_PREFIX="queue:",AUTO_PREFIX="auto:",QUEUE_PROGRESS_CHANNEL=`${QUEUE_PREFIX}progress`,QUEUE_CHANGED_CHANNEL=`${QUEUE_PREFIX}changed`,CHAT_DELTA_CHANNEL="aegis:chatDelta",UPDATE_STATUS_CHANNEL="aegis:updateStatus",ACCOUNT_STATUS_CHANNEL="aegis:accountStatusChanged",MENU_NEW_CHAT_CHANNEL="aegis:menuNewChat",MENU_SEARCH_CHANNEL="aegis:menuSearch",MENU_SEARCH_MEMORY_CHANNEL="aegis:menuSearchMemory",MENU_CREDITS_CHANNEL="aegis:menuCredits",MENU_PALETTE_CHANNEL="aegis:menuPalette",MENU_TOGGLE_SIDEBAR_CHANNEL="aegis:menuToggleSidebar",MENU_FIND_CHANNEL="aegis:menuFind",MENU_GO_BACK_CHANNEL="aegis:menuGoBack",MENU_GO_FORWARD_CHANNEL="aegis:menuGoForward",MENU_EXPORT_MARKDOWN_CHANNEL="aegis:menuExportMarkdown",MENU_EXPORT_JSON_CHANNEL="aegis:menuExportJson",MENU_FINGERPRINT_CHANNEL="aegis:menuFingerprint",MENU_GOOGLE_DRIVE_CHANNEL="aegis:menuGoogleDrive",DEEP_LINK_CHANNEL="aegis:deepLink",QUICK_LAUNCHER_PUSH_CHANNEL="aegis:quickLauncherPush";function invoke(e,n){return ipcRenderer.invoke("aegis:"+e,void 0===n?void 0:n)}function invokeModel(e,n){return ipcRenderer.invoke("model:"+e,void 0===n?void 0:n)}function invokeSync(e,n){return ipcRenderer.invoke("sync:"+e,void 0===n?void 0:n)}function invokeQuick(e,n){return ipcRenderer.invoke("quick:"+e,void 0===n?void 0:n)}function invokeQueue(e,n){return ipcRenderer.invoke(QUEUE_PREFIX+e,void 0===n?void 0:n)}function invokeAuto(e,n){return ipcRenderer.invoke("auto:"+e,void 0===n?void 0:n)}function deltaListener(e,n){const o=e||null;return(e,i)=>{(i&&i.id?i.id:null)===o&&n(i)}}const api={status:()=>invoke("status"),attachments:Object.freeze({pathFor:e=>{try{const{webUtils:n}=require("electron");return n&&"function"==typeof n.getPathForFile&&n.getPathForFile(e)||""}catch{return""}},ingest:e=>invoke("attachments:ingest",{path:String(null==e?"":e)})}),setApiKey:e=>invoke("setApiKey",{key:e}),verifyApiKey:()=>invoke("verifyApiKey"),tokenBankBalance:()=>invoke("tokenBankBalance"),billingCheckout:()=>invoke("billingCheckout"),tokenBankTopup:e=>invoke("tokenBankTopup",{amountEur:e}),listModels:()=>invoke("listModels"),readTextFile:(e,n)=>{try{return ipcRenderer.sendSync("model:readTextFile",{file:e,cwd:n})}catch{return null}},chatCompletion:(e,n)=>{const o=e||{};if("function"!=typeof n)return invoke("chatCompletion",{...o,stream:!1});const i=deltaListener(o.sessionId,n),r=()=>ipcRenderer.removeListener("aegis:chatDelta",i);return ipcRenderer.on("aegis:chatDelta",i),invoke("chatCompletion",{...o,stream:!0}).then((e=>(r(),e)),(e=>{throw r(),e}))},byokStatus:()=>invoke("byokStatus"),byokSet:(e,n)=>invoke("byokSet",{provider:e,apiKey:n}),memorySearch:(e,n)=>invoke("memorySearch",{query:e,limit:n}),memorySave:e=>invoke("memorySave",{entry:e}),memoryList:e=>invoke("memoryList",{limit:e}),verifyToken:e=>invoke("verifyToken",{token:e}),memoryActivate:e=>invoke("memoryActivate",{token:e}),memoryPull:e=>invoke("memoryPull",{since:e}),memorySaveBatch:e=>invoke("memorySaveBatch",{entries:e}),memoryImport:e=>invoke("memoryImport",e||{}),sessionsImportScan:()=>invoke("sessionsImportScan"),sessionsImport:e=>invoke("sessionsImport",e||{}),importConversation:e=>invoke("importConversation",e||{}),openExternal:e=>invoke("openExternal",{url:e}),fingerprintStatus:()=>invoke("fingerprintStatus"),fingerprintKeygen:e=>invoke("fingerprintKeygen",e||{}),fingerprintMint:e=>invoke("fingerprintMint",e||{}),fingerprintVerify:e=>invoke("fingerprintVerify",e||{}),fingerprintBackup:e=>invoke("fingerprintBackup",e||{}),fingerprintPublish:e=>invoke("fingerprintPublish",e||{}),fingerprintAnchor:e=>invoke("fingerprintAnchor",e||{}),fingerprintVault:()=>invoke("fingerprintVault"),fingerprintVaultAudit:()=>invoke("fingerprintVaultAudit"),getConfirmMode:()=>invoke("getConfirmMode"),setConfirmMode:e=>invoke("setConfirmMode",{enabled:Boolean(e)}),getDevMode:()=>invoke("getDevMode"),setDevMode:e=>invoke("setDevMode",{enabled:Boolean(e)}),getModelAutoSync:()=>invoke("getModelAutoSync"),setModelAutoSync:e=>invoke("setModelAutoSync",{enabled:Boolean(e)}),getAccountUsername:()=>invoke("getAccountUsername"),setAccountUsername:e=>invoke("setAccountUsername",{username:null==e?null:String(e)}),getFontScale:()=>invoke("getFontScale"),setFontScale:e=>invoke("setFontScale",{scale:Number(e)}),getAccent:()=>invoke("getAccent"),setAccent:e=>invoke("setAccent",{name:String(e)}),getPermissionMode:()=>invoke("getPermissionMode"),setPermissionMode:e=>invoke("setPermissionMode",{mode:e?"plan":null}),permRulesList:()=>invoke("permRulesList"),permRulesAdd:(e,n)=>invoke("permRulesAdd",{list:String(e||""),rule:String(n||"")}),permRulesRemove:(e,n)=>invoke("permRulesRemove",{list:String(e||""),rule:String(n||"")}),personaRead:()=>invoke("personaRead"),personaPatch:e=>invoke("personaPatch",{patch:e||{}}),getSandboxPolicy:()=>invoke("getSandboxPolicy"),setSandboxPolicy:(e,n)=>invoke("setSandboxPolicy",{mode:String(e||""),network:String(n||"")}),getVaultBackend:()=>invoke("getVaultBackend"),openCliFace:e=>invoke("openCliFace",{args:Array.isArray(e)?e.map(String):[]}),setVaultBackend:e=>invoke("setVaultBackend",{backend:String(e||"")}),telemetryEvent:(e,n)=>{const o=n||{};return invoke("telemetryEvent",{event:null==e?"":String(e),campaign:null==o.campaign?null:String(o.campaign),surface:null==o.surface?null:String(o.surface)})},telemetryReport:()=>invoke("telemetryReport"),covenantStatus:()=>invoke("covenantStatus"),covenantGapReport:()=>invoke("covenantGapReport"),getMemoryPersist:()=>invoke("memoryPersist.get"),setMemoryPersist:e=>invoke("memoryPersist.set",{enabled:Boolean(e)}),checkForUpdates:()=>invoke("checkForUpdates"),downloadUpdate:()=>invoke("downloadUpdate"),quitAndInstallUpdate:()=>invoke("quitAndInstallUpdate"),updateStatus:()=>invoke("updateStatus"),onUpdateStatus:e=>{const n=(n,o)=>e(o);return ipcRenderer.on("aegis:updateStatus",n),()=>ipcRenderer.removeListener("aegis:updateStatus",n)},accountStatus:()=>invoke("accountStatus"),registerAccount:()=>invoke("registerAccount"),onAccountStatus:e=>{const n=(n,o)=>e(o);return ipcRenderer.on(ACCOUNT_STATUS_CHANNEL,n),()=>ipcRenderer.removeListener(ACCOUNT_STATUS_CHANNEL,n)},driveSignIn:()=>invoke("driveSignIn"),driveConnect:()=>invoke("driveConnect"),driveStatus:()=>invoke("driveStatus"),driveSyncMemory:()=>invoke("driveSyncMemory"),driveBackupConversation:e=>invoke("driveBackupConversation",{sessionId:e}),speechStatus:()=>invoke("speechStatus"),speechSet:e=>{const n=e||{},o={};return"boolean"==typeof n.enabled&&(o.enabled=n.enabled),"string"==typeof n.engine&&(o.engine="local"===n.engine?"local":"none"),"string"==typeof n.model&&(o.model=n.model),"string"==typeof n.language&&(o.language=n.language),null!=n.maxSeconds&&Number.isFinite(Number(n.maxSeconds))&&(o.maxSeconds=Number(n.maxSeconds)),invoke("speechSet",o)},speechTranscribe:e=>{const n=e||{};return invoke("speechTranscribe",{audio:n.audio,ext:null==n.ext?"webm":String(n.ext)})},skillsList:()=>invoke("skillsList"),skillsRead:e=>invoke("skillsRead",{name:String(null==e?"":e)}),skillsCreate:e=>{const n=e||{};return invoke("skillsCreate",{name:String(null==n.name?"":n.name),description:String(null==n.description?"":n.description),body:String(null==n.body?"":n.body),targetDir:String(null==n.targetDir?"":n.targetDir)})},skillsRemove:e=>invoke("skillsRemove",{name:String(null==e?"":e)}),skillsImport:e=>{const n=e||{};return invoke("skillsImport",{url:String(null==n.url?"":n.url),name:String(null==n.name?"":n.name),targetDir:String(null==n.targetDir?"":n.targetDir)})},onMenuNewChat:e=>{const n=()=>e();return ipcRenderer.on("aegis:menuNewChat",n),()=>ipcRenderer.removeListener("aegis:menuNewChat",n)},onMenuSearch:e=>{const n=()=>e();return ipcRenderer.on("aegis:menuSearch",n),()=>ipcRenderer.removeListener("aegis:menuSearch",n)},onMenuSearchMemory:e=>{const n=()=>e();return ipcRenderer.on("aegis:menuSearchMemory",n),()=>ipcRenderer.removeListener("aegis:menuSearchMemory",n)},onMenuCredits:e=>{const n=()=>e();return ipcRenderer.on("aegis:menuCredits",n),()=>ipcRenderer.removeListener("aegis:menuCredits",n)},credits:()=>invoke("credits"),onMenuPalette:e=>{const n=()=>e();return ipcRenderer.on("aegis:menuPalette",n),()=>ipcRenderer.removeListener("aegis:menuPalette",n)},onMenuToggleSidebar:e=>{const n=()=>e();return ipcRenderer.on("aegis:menuToggleSidebar",n),()=>ipcRenderer.removeListener("aegis:menuToggleSidebar",n)},onMenuFind:e=>{const n=()=>e();return ipcRenderer.on("aegis:menuFind",n),()=>ipcRenderer.removeListener("aegis:menuFind",n)},onMenuGoBack:e=>{const n=()=>e();return ipcRenderer.on("aegis:menuGoBack",n),()=>ipcRenderer.removeListener("aegis:menuGoBack",n)},onMenuGoForward:e=>{const n=()=>e();return ipcRenderer.on("aegis:menuGoForward",n),()=>ipcRenderer.removeListener("aegis:menuGoForward",n)},setNavState:e=>invoke("setNavState",e),onMenuExportMarkdown:e=>{const n=()=>e();return ipcRenderer.on("aegis:menuExportMarkdown",n),()=>ipcRenderer.removeListener("aegis:menuExportMarkdown",n)},onMenuFingerprint:e=>{const n=()=>e();return ipcRenderer.on("aegis:menuFingerprint",n),()=>ipcRenderer.removeListener("aegis:menuFingerprint",n)},onMenuGoogleDrive:e=>{const n=()=>e();return ipcRenderer.on("aegis:menuGoogleDrive",n),()=>ipcRenderer.removeListener("aegis:menuGoogleDrive",n)},onMenuExportJson:e=>{const n=()=>e();return ipcRenderer.on("aegis:menuExportJson",n),()=>ipcRenderer.removeListener("aegis:menuExportJson",n)},exportSession:(e,n)=>invoke("exportSession",{sessionId:e,format:n}),onDeepLink:e=>{const n=(n,o)=>e(o);return ipcRenderer.on("aegis:deepLink",n),()=>ipcRenderer.removeListener("aegis:deepLink",n)},onQuickLauncherPush:e=>{const n=(n,o)=>e(o);return ipcRenderer.on("aegis:quickLauncherPush",n),()=>ipcRenderer.removeListener("aegis:quickLauncherPush",n)}},models={listClasses:()=>invokeModel("listClasses"),listModels:e=>invokeModel("listModels",{class:e}),chat:(e,n)=>{const o=e||{};if("function"!=typeof n)return invokeModel("chat",o);const i=deltaListener(o.sessionId,n),r=()=>ipcRenderer.removeListener("aegis:chatDelta",i);return ipcRenderer.on("aegis:chatDelta",i),invokeModel("chat",o).then((e=>(r(),e)),(e=>{throw r(),e}))},settings:{get:()=>invokeModel("settings.get"),set:(e,n)=>invokeModel("settings.set",{provider:e,baseURL:n&&n.baseURL,key:n&&n.key}),remove:e=>invokeModel("settings.remove",{provider:e})},userModels:{get:()=>invokeModel("userModels.get"),add:(e,n)=>invokeModel("userModels.add",{provider:e,model:n}),remove:(e,n)=>invokeModel("userModels.remove",{provider:e,model:n}),discover:e=>invokeModel("userModels.discover",{provider:e}),addAll:(e,n)=>invokeModel("userModels.addAll",{provider:e,ids:n}),canDiscover:e=>invokeModel("userModels.canDiscover",{provider:e}),discoverable:()=>invokeModel("userModels.discoverable"),syncPlan:e=>invokeModel("userModels.syncPlan",{only:e}),syncApply:(e,n)=>invokeModel("userModels.syncApply",{plan:e,only:n}),syncStatus:()=>invokeModel("userModels.syncStatus"),syncNow:e=>invokeModel("userModels.syncNow",{only:e})},cancel:e=>invokeModel("cancel",{sessionId:e}),respondApproval:(e,n)=>invokeModel("respondApproval",{approvalId:e,decision:n}),respondRoundsAsk:(e,n)=>invokeModel("respondRoundsAsk",{roundsAskId:e,decision:n}),clearApprovals:e=>invokeModel("clearApprovals",{sessionId:e}),listUndoable:e=>invokeModel("listUndoable",{sessionId:e}),undoMutation:(e,n)=>invokeModel("undoMutation",{sessionId:e,id:n})},sync={listSessions:()=>invokeSync("listSessions"),searchSessions:(e,n)=>invokeSync("searchSessions",{query:e,limit:n}),open:e=>invokeSync("open",{sessionId:e}),save:e=>invokeSync("save",e||{}),nameSession:e=>invokeSync("nameSession",{sessionId:e&&e.sessionId,prompt:e&&e.prompt,class:e&&e.class,model:e&&e.model}),append:(e,n)=>invokeSync("append",{sessionId:e,message:n}),delete:e=>invokeSync("delete",{sessionId:e}),rename:(e,n)=>invokeSync("rename",{sessionId:e,title:n}),push:()=>invokeSync("push"),pull:()=>invokeSync("pull"),status:()=>invokeSync("status"),auto:()=>invokeSync("auto"),memoryPersistState:()=>invokeSync("memoryPersistState")},quickLauncher={status:()=>invokeQuick("status"),setConfig:e=>invokeQuick("setConfig",{enabled:e&&e.enabled,shortcut:e&&e.shortcut}),pushToMain:e=>invokeQuick("pushToMain",e||{})},queue={enqueue:e=>invokeQueue("enqueue",queueTaskFields(e)),list:()=>invokeQueue("list"),clear:e=>invokeQueue("clear",{all:Boolean(e)}),entitlement:e=>invokeQueue("entitlement",{force:Boolean(e)}),retry:e=>queueWithId("retry",e),remove:e=>queueWithId("remove",e),drain:()=>invokeQueue("drain",{}),proceed:()=>invokeQueue("proceed",{}),stop:e=>{const n=queueTaskId(e);return invokeQueue("stop",null==n?{}:{id:n})},onProgress:e=>{if("function"!=typeof e)return()=>{};const n=(n,o)=>e(o);return ipcRenderer.on(QUEUE_PROGRESS_CHANNEL,n),()=>ipcRenderer.removeListener(QUEUE_PROGRESS_CHANNEL,n)},onChanged:e=>{if("function"!=typeof e)return()=>{};const n=()=>e();return ipcRenderer.on(QUEUE_CHANGED_CHANNEL,n),()=>ipcRenderer.removeListener(QUEUE_CHANGED_CHANNEL,n)}},auto={status:()=>invokeAuto("autoStatus"),setDrain:e=>{const n=e||{},o={enabled:Boolean(n.enabled)};return null!=n.intervalMs&&Number.isFinite(Number(n.intervalMs))&&(o.intervalMs=Number(n.intervalMs)),invokeAuto("autoSetDrain",o)},setMint:e=>{const n=e||{};return invokeAuto("autoSetMint",{enabled:Boolean(n.enabled),publish:Boolean(n.publish)})},sealNow:e=>invokeAuto("autoSealNow",{publish:Boolean(e)})};function queueTaskId(e){const n=Number(e);return Number.isInteger(n)&&n>0?n:null}function queueWithId(e,n){const o=queueTaskId(n);return null==o?Promise.resolve({ok:!1,reason:`${e} needs a task id`}):invokeQueue(e,{id:o})}function queueTaskFields(e){const n=e||{};return{task:String(null==n.task?"":n.task),cwd:String(null==n.cwd?"":n.cwd),class:null==n.class?null:String(n.class),model:null==n.model?null:String(n.model),effort:null==n.effort?null:String(n.effort),workers:null==n.workers?null:Number(n.workers),maxRounds:null==n.maxRounds?null:Number(n.maxRounds),fanout:Boolean(n.fanout),commit:Boolean(n.commit)}}contextBridge.exposeInMainWorld("aegis",Object.freeze(api)),contextBridge.exposeInMainWorld("models",Object.freeze(models)),contextBridge.exposeInMainWorld("sync",Object.freeze(sync)),contextBridge.exposeInMainWorld("quickLauncher",Object.freeze(quickLauncher)),contextBridge.exposeInMainWorld("queue",Object.freeze(queue)),contextBridge.exposeInMainWorld("auto",Object.freeze(auto));
3
+ "use strict";const{contextBridge:contextBridge,ipcRenderer:ipcRenderer}=require("electron"),IPC_PREFIX="aegis:",MODEL_PREFIX="model:",SYNC_PREFIX="sync:",QUICK_PREFIX="quick:",QUEUE_PREFIX="queue:",AUTO_PREFIX="auto:",QUEUE_PROGRESS_CHANNEL=`${QUEUE_PREFIX}progress`,QUEUE_CHANGED_CHANNEL=`${QUEUE_PREFIX}changed`,CHAT_DELTA_CHANNEL="aegis:chatDelta",PTY_EVENT_CHANNEL="aegis:ptyEvent",UPDATE_STATUS_CHANNEL="aegis:updateStatus",ACCOUNT_STATUS_CHANNEL="aegis:accountStatusChanged",MENU_NEW_CHAT_CHANNEL="aegis:menuNewChat",MENU_SEARCH_CHANNEL="aegis:menuSearch",MENU_SEARCH_MEMORY_CHANNEL="aegis:menuSearchMemory",MENU_CREDITS_CHANNEL="aegis:menuCredits",MENU_PALETTE_CHANNEL="aegis:menuPalette",MENU_TOGGLE_SIDEBAR_CHANNEL="aegis:menuToggleSidebar",MENU_FIND_CHANNEL="aegis:menuFind",MENU_GO_BACK_CHANNEL="aegis:menuGoBack",MENU_GO_FORWARD_CHANNEL="aegis:menuGoForward",MENU_EXPORT_MARKDOWN_CHANNEL="aegis:menuExportMarkdown",MENU_EXPORT_JSON_CHANNEL="aegis:menuExportJson",MENU_FINGERPRINT_CHANNEL="aegis:menuFingerprint",MENU_GOOGLE_DRIVE_CHANNEL="aegis:menuGoogleDrive",DEEP_LINK_CHANNEL="aegis:deepLink",QUICK_LAUNCHER_PUSH_CHANNEL="aegis:quickLauncherPush";function invoke(e,n){return ipcRenderer.invoke("aegis:"+e,void 0===n?void 0:n)}function invokeModel(e,n){return ipcRenderer.invoke("model:"+e,void 0===n?void 0:n)}function invokeSync(e,n){return ipcRenderer.invoke("sync:"+e,void 0===n?void 0:n)}function invokeQuick(e,n){return ipcRenderer.invoke("quick:"+e,void 0===n?void 0:n)}function invokeQueue(e,n){return ipcRenderer.invoke(QUEUE_PREFIX+e,void 0===n?void 0:n)}function invokeAuto(e,n){return ipcRenderer.invoke("auto:"+e,void 0===n?void 0:n)}function deltaListener(e,n){const o=e||null;return(e,i)=>{(i&&i.id?i.id:null)===o&&n(i)}}const api={status:()=>invoke("status"),attachments:Object.freeze({pathFor:e=>{try{const{webUtils:n}=require("electron");return n&&"function"==typeof n.getPathForFile&&n.getPathForFile(e)||""}catch{return""}},ingest:e=>invoke("attachments:ingest",{path:String(null==e?"":e)})}),setApiKey:e=>invoke("setApiKey",{key:e}),verifyApiKey:()=>invoke("verifyApiKey"),tokenBankBalance:()=>invoke("tokenBankBalance"),billingCheckout:()=>invoke("billingCheckout"),tokenBankTopup:e=>invoke("tokenBankTopup",{amountEur:e}),listModels:()=>invoke("listModels"),readTextFile:(e,n)=>{try{return ipcRenderer.sendSync("model:readTextFile",{file:e,cwd:n})}catch{return null}},chatCompletion:(e,n)=>{const o=e||{};if("function"!=typeof n)return invoke("chatCompletion",{...o,stream:!1});const i=deltaListener(o.sessionId,n),r=()=>ipcRenderer.removeListener("aegis:chatDelta",i);return ipcRenderer.on("aegis:chatDelta",i),invoke("chatCompletion",{...o,stream:!0}).then((e=>(r(),e)),(e=>{throw r(),e}))},byokStatus:()=>invoke("byokStatus"),byokSet:(e,n)=>invoke("byokSet",{provider:e,apiKey:n}),memorySearch:(e,n)=>invoke("memorySearch",{query:e,limit:n}),memorySave:e=>invoke("memorySave",{entry:e}),memoryList:e=>invoke("memoryList",{limit:e}),verifyToken:e=>invoke("verifyToken",{token:e}),memoryActivate:e=>invoke("memoryActivate",{token:e}),memoryPull:e=>invoke("memoryPull",{since:e}),memorySaveBatch:e=>invoke("memorySaveBatch",{entries:e}),memoryImport:e=>invoke("memoryImport",e||{}),sessionsImportScan:()=>invoke("sessionsImportScan"),sessionsImport:e=>invoke("sessionsImport",e||{}),importConversation:e=>invoke("importConversation",e||{}),openExternal:e=>invoke("openExternal",{url:e}),fingerprintStatus:()=>invoke("fingerprintStatus"),fingerprintKeygen:e=>invoke("fingerprintKeygen",e||{}),fingerprintMint:e=>invoke("fingerprintMint",e||{}),fingerprintVerify:e=>invoke("fingerprintVerify",e||{}),fingerprintBackup:e=>invoke("fingerprintBackup",e||{}),fingerprintPublish:e=>invoke("fingerprintPublish",e||{}),fingerprintAnchor:e=>invoke("fingerprintAnchor",e||{}),fingerprintVault:()=>invoke("fingerprintVault"),fingerprintVaultAudit:()=>invoke("fingerprintVaultAudit"),getConfirmMode:()=>invoke("getConfirmMode"),setConfirmMode:e=>invoke("setConfirmMode",{enabled:Boolean(e)}),getDevMode:()=>invoke("getDevMode"),setDevMode:e=>invoke("setDevMode",{enabled:Boolean(e)}),getModelAutoSync:()=>invoke("getModelAutoSync"),setModelAutoSync:e=>invoke("setModelAutoSync",{enabled:Boolean(e)}),getAccountUsername:()=>invoke("getAccountUsername"),setAccountUsername:e=>invoke("setAccountUsername",{username:null==e?null:String(e)}),getFontScale:()=>invoke("getFontScale"),setFontScale:e=>invoke("setFontScale",{scale:Number(e)}),getAccent:()=>invoke("getAccent"),setAccent:e=>invoke("setAccent",{name:String(e)}),getPermissionMode:()=>invoke("getPermissionMode"),setPermissionMode:e=>invoke("setPermissionMode",{mode:e?"plan":null}),permRulesList:()=>invoke("permRulesList"),permRulesAdd:(e,n)=>invoke("permRulesAdd",{list:String(e||""),rule:String(n||"")}),permRulesRemove:(e,n)=>invoke("permRulesRemove",{list:String(e||""),rule:String(n||"")}),personaRead:()=>invoke("personaRead"),personaPatch:e=>invoke("personaPatch",{patch:e||{}}),getSandboxPolicy:()=>invoke("getSandboxPolicy"),setSandboxPolicy:(e,n)=>invoke("setSandboxPolicy",{mode:String(e||""),network:String(n||"")}),getVaultBackend:()=>invoke("getVaultBackend"),openCliFace:e=>invoke("openCliFace",{args:Array.isArray(e)?e.map(String):[]}),pty:Object.freeze({hello:()=>invoke("ptyHello",{}),exec:(e,n)=>invoke("ptyExec",{id:e,params:n||{}}),write:(e,n)=>invoke("ptyWrite",{id:e,data:String(null==n?"":n)}),resize:(e,n,o)=>invoke("ptyResize",{id:e,cols:Number(n)||0,rows:Number(o)||0}),cancel:e=>invoke("ptyCancel",{id:e}),onEvent:(e,n)=>{const o=(o,i)=>{i&&i.id===e&&n(i)};return ipcRenderer.on("aegis:ptyEvent",o),()=>ipcRenderer.removeListener("aegis:ptyEvent",o)}}),setVaultBackend:e=>invoke("setVaultBackend",{backend:String(e||"")}),telemetryEvent:(e,n)=>{const o=n||{};return invoke("telemetryEvent",{event:null==e?"":String(e),campaign:null==o.campaign?null:String(o.campaign),surface:null==o.surface?null:String(o.surface)})},telemetryReport:()=>invoke("telemetryReport"),covenantStatus:()=>invoke("covenantStatus"),covenantGapReport:()=>invoke("covenantGapReport"),getMemoryPersist:()=>invoke("memoryPersist.get"),setMemoryPersist:e=>invoke("memoryPersist.set",{enabled:Boolean(e)}),checkForUpdates:()=>invoke("checkForUpdates"),downloadUpdate:()=>invoke("downloadUpdate"),quitAndInstallUpdate:()=>invoke("quitAndInstallUpdate"),updateStatus:()=>invoke("updateStatus"),onUpdateStatus:e=>{const n=(n,o)=>e(o);return ipcRenderer.on("aegis:updateStatus",n),()=>ipcRenderer.removeListener("aegis:updateStatus",n)},accountStatus:()=>invoke("accountStatus"),registerAccount:()=>invoke("registerAccount"),onAccountStatus:e=>{const n=(n,o)=>e(o);return ipcRenderer.on(ACCOUNT_STATUS_CHANNEL,n),()=>ipcRenderer.removeListener(ACCOUNT_STATUS_CHANNEL,n)},driveSignIn:()=>invoke("driveSignIn"),driveConnect:()=>invoke("driveConnect"),driveStatus:()=>invoke("driveStatus"),driveSyncMemory:()=>invoke("driveSyncMemory"),driveBackupConversation:e=>invoke("driveBackupConversation",{sessionId:e}),speechStatus:()=>invoke("speechStatus"),speechSet:e=>{const n=e||{},o={};return"boolean"==typeof n.enabled&&(o.enabled=n.enabled),"string"==typeof n.engine&&(o.engine="local"===n.engine?"local":"none"),"string"==typeof n.model&&(o.model=n.model),"string"==typeof n.language&&(o.language=n.language),null!=n.maxSeconds&&Number.isFinite(Number(n.maxSeconds))&&(o.maxSeconds=Number(n.maxSeconds)),invoke("speechSet",o)},speechTranscribe:e=>{const n=e||{};return invoke("speechTranscribe",{audio:n.audio,ext:null==n.ext?"webm":String(n.ext)})},skillsList:()=>invoke("skillsList"),skillsRead:e=>invoke("skillsRead",{name:String(null==e?"":e)}),skillsCreate:e=>{const n=e||{};return invoke("skillsCreate",{name:String(null==n.name?"":n.name),description:String(null==n.description?"":n.description),body:String(null==n.body?"":n.body),targetDir:String(null==n.targetDir?"":n.targetDir)})},skillsRemove:e=>invoke("skillsRemove",{name:String(null==e?"":e)}),skillsImport:e=>{const n=e||{};return invoke("skillsImport",{url:String(null==n.url?"":n.url),name:String(null==n.name?"":n.name),targetDir:String(null==n.targetDir?"":n.targetDir)})},onMenuNewChat:e=>{const n=()=>e();return ipcRenderer.on("aegis:menuNewChat",n),()=>ipcRenderer.removeListener("aegis:menuNewChat",n)},onMenuSearch:e=>{const n=()=>e();return ipcRenderer.on("aegis:menuSearch",n),()=>ipcRenderer.removeListener("aegis:menuSearch",n)},onMenuSearchMemory:e=>{const n=()=>e();return ipcRenderer.on("aegis:menuSearchMemory",n),()=>ipcRenderer.removeListener("aegis:menuSearchMemory",n)},onMenuCredits:e=>{const n=()=>e();return ipcRenderer.on("aegis:menuCredits",n),()=>ipcRenderer.removeListener("aegis:menuCredits",n)},credits:()=>invoke("credits"),onMenuPalette:e=>{const n=()=>e();return ipcRenderer.on("aegis:menuPalette",n),()=>ipcRenderer.removeListener("aegis:menuPalette",n)},onMenuToggleSidebar:e=>{const n=()=>e();return ipcRenderer.on("aegis:menuToggleSidebar",n),()=>ipcRenderer.removeListener("aegis:menuToggleSidebar",n)},onMenuFind:e=>{const n=()=>e();return ipcRenderer.on("aegis:menuFind",n),()=>ipcRenderer.removeListener("aegis:menuFind",n)},onMenuGoBack:e=>{const n=()=>e();return ipcRenderer.on("aegis:menuGoBack",n),()=>ipcRenderer.removeListener("aegis:menuGoBack",n)},onMenuGoForward:e=>{const n=()=>e();return ipcRenderer.on("aegis:menuGoForward",n),()=>ipcRenderer.removeListener("aegis:menuGoForward",n)},setNavState:e=>invoke("setNavState",e),onMenuExportMarkdown:e=>{const n=()=>e();return ipcRenderer.on("aegis:menuExportMarkdown",n),()=>ipcRenderer.removeListener("aegis:menuExportMarkdown",n)},onMenuFingerprint:e=>{const n=()=>e();return ipcRenderer.on("aegis:menuFingerprint",n),()=>ipcRenderer.removeListener("aegis:menuFingerprint",n)},onMenuGoogleDrive:e=>{const n=()=>e();return ipcRenderer.on("aegis:menuGoogleDrive",n),()=>ipcRenderer.removeListener("aegis:menuGoogleDrive",n)},onMenuExportJson:e=>{const n=()=>e();return ipcRenderer.on("aegis:menuExportJson",n),()=>ipcRenderer.removeListener("aegis:menuExportJson",n)},exportSession:(e,n)=>invoke("exportSession",{sessionId:e,format:n}),onDeepLink:e=>{const n=(n,o)=>e(o);return ipcRenderer.on("aegis:deepLink",n),()=>ipcRenderer.removeListener("aegis:deepLink",n)},onQuickLauncherPush:e=>{const n=(n,o)=>e(o);return ipcRenderer.on("aegis:quickLauncherPush",n),()=>ipcRenderer.removeListener("aegis:quickLauncherPush",n)}},models={listClasses:()=>invokeModel("listClasses"),listModels:e=>invokeModel("listModels",{class:e}),chat:(e,n)=>{const o=e||{};if("function"!=typeof n)return invokeModel("chat",o);const i=deltaListener(o.sessionId,n),r=()=>ipcRenderer.removeListener("aegis:chatDelta",i);return ipcRenderer.on("aegis:chatDelta",i),invokeModel("chat",o).then((e=>(r(),e)),(e=>{throw r(),e}))},settings:{get:()=>invokeModel("settings.get"),set:(e,n)=>invokeModel("settings.set",{provider:e,baseURL:n&&n.baseURL,key:n&&n.key}),remove:e=>invokeModel("settings.remove",{provider:e})},userModels:{get:()=>invokeModel("userModels.get"),add:(e,n)=>invokeModel("userModels.add",{provider:e,model:n}),remove:(e,n)=>invokeModel("userModels.remove",{provider:e,model:n}),discover:e=>invokeModel("userModels.discover",{provider:e}),addAll:(e,n)=>invokeModel("userModels.addAll",{provider:e,ids:n}),canDiscover:e=>invokeModel("userModels.canDiscover",{provider:e}),discoverable:()=>invokeModel("userModels.discoverable"),syncPlan:e=>invokeModel("userModels.syncPlan",{only:e}),syncApply:(e,n)=>invokeModel("userModels.syncApply",{plan:e,only:n}),syncStatus:()=>invokeModel("userModels.syncStatus"),syncNow:e=>invokeModel("userModels.syncNow",{only:e})},cancel:e=>invokeModel("cancel",{sessionId:e}),respondApproval:(e,n)=>invokeModel("respondApproval",{approvalId:e,decision:n}),respondRoundsAsk:(e,n)=>invokeModel("respondRoundsAsk",{roundsAskId:e,decision:n}),clearApprovals:e=>invokeModel("clearApprovals",{sessionId:e}),listUndoable:e=>invokeModel("listUndoable",{sessionId:e}),undoMutation:(e,n)=>invokeModel("undoMutation",{sessionId:e,id:n})},sync={listSessions:()=>invokeSync("listSessions"),searchSessions:(e,n)=>invokeSync("searchSessions",{query:e,limit:n}),open:e=>invokeSync("open",{sessionId:e}),save:e=>invokeSync("save",e||{}),nameSession:e=>invokeSync("nameSession",{sessionId:e&&e.sessionId,prompt:e&&e.prompt,class:e&&e.class,model:e&&e.model}),append:(e,n)=>invokeSync("append",{sessionId:e,message:n}),delete:e=>invokeSync("delete",{sessionId:e}),rename:(e,n)=>invokeSync("rename",{sessionId:e,title:n}),push:()=>invokeSync("push"),pull:()=>invokeSync("pull"),status:()=>invokeSync("status"),auto:()=>invokeSync("auto"),memoryPersistState:()=>invokeSync("memoryPersistState")},quickLauncher={status:()=>invokeQuick("status"),setConfig:e=>invokeQuick("setConfig",{enabled:e&&e.enabled,shortcut:e&&e.shortcut}),pushToMain:e=>invokeQuick("pushToMain",e||{})},queue={enqueue:e=>invokeQueue("enqueue",queueTaskFields(e)),list:()=>invokeQueue("list"),clear:e=>invokeQueue("clear",{all:Boolean(e)}),entitlement:e=>invokeQueue("entitlement",{force:Boolean(e)}),retry:e=>queueWithId("retry",e),remove:e=>queueWithId("remove",e),drain:()=>invokeQueue("drain",{}),proceed:()=>invokeQueue("proceed",{}),stop:e=>{const n=queueTaskId(e);return invokeQueue("stop",null==n?{}:{id:n})},onProgress:e=>{if("function"!=typeof e)return()=>{};const n=(n,o)=>e(o);return ipcRenderer.on(QUEUE_PROGRESS_CHANNEL,n),()=>ipcRenderer.removeListener(QUEUE_PROGRESS_CHANNEL,n)},onChanged:e=>{if("function"!=typeof e)return()=>{};const n=()=>e();return ipcRenderer.on(QUEUE_CHANGED_CHANNEL,n),()=>ipcRenderer.removeListener(QUEUE_CHANGED_CHANNEL,n)}},auto={status:()=>invokeAuto("autoStatus"),setDrain:e=>{const n=e||{},o={enabled:Boolean(n.enabled)};return null!=n.intervalMs&&Number.isFinite(Number(n.intervalMs))&&(o.intervalMs=Number(n.intervalMs)),invokeAuto("autoSetDrain",o)},setMint:e=>{const n=e||{};return invokeAuto("autoSetMint",{enabled:Boolean(n.enabled),publish:Boolean(n.publish)})},sealNow:e=>invokeAuto("autoSealNow",{publish:Boolean(e)})};function queueTaskId(e){const n=Number(e);return Number.isInteger(n)&&n>0?n:null}function queueWithId(e,n){const o=queueTaskId(n);return null==o?Promise.resolve({ok:!1,reason:`${e} needs a task id`}):invokeQueue(e,{id:o})}function queueTaskFields(e){const n=e||{};return{task:String(null==n.task?"":n.task),cwd:String(null==n.cwd?"":n.cwd),class:null==n.class?null:String(n.class),model:null==n.model?null:String(n.model),effort:null==n.effort?null:String(n.effort),workers:null==n.workers?null:Number(n.workers),maxRounds:null==n.maxRounds?null:Number(n.maxRounds),fanout:Boolean(n.fanout),commit:Boolean(n.commit)}}contextBridge.exposeInMainWorld("aegis",Object.freeze(api)),contextBridge.exposeInMainWorld("models",Object.freeze(models)),contextBridge.exposeInMainWorld("sync",Object.freeze(sync)),contextBridge.exposeInMainWorld("quickLauncher",Object.freeze(quickLauncher)),contextBridge.exposeInMainWorld("queue",Object.freeze(queue)),contextBridge.exposeInMainWorld("auto",Object.freeze(auto));