aegisone 1.0.57 → 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.
- package/README.md +4 -2
- package/package.json +3 -2
- package/scripts/predist.mjs +1 -1
- package/src/doctor.js +1 -1
- package/vendor/cli/README.md +2 -2
- package/vendor/cli/package.json +1 -1
- package/vendor/cli/src/app.js +1 -1
- package/vendor/cli/src/commands.js +2 -2
- package/vendor/cli/src/config.js +1 -1
- package/vendor/cli/src/panels.js +1 -1
- package/vendor/cli/vendor/client/model-autosync.js +3 -0
- package/vendor/cli/vendor/client/model-sync.js +3 -0
- package/vendor/cli/vendor/client/prefs.js +1 -1
- package/vendor/cli/vendor/client/skills.js +3 -0
- package/vendor/cli/vendor/client/speech.js +3 -0
- package/vendor/cli/vendor/desktop/lib/local/engine.js +1 -1
- package/vendor/cli/vendor/desktop/lib/local/integrity.js +1 -1
- package/vendor/cli/vendor/desktop/lib/local/sandbox-appcontainer.js +6 -6
- package/vendor/cli/vendor/desktop/lib/local/sandbox-bwrap.js +7 -7
- package/vendor/cli/vendor/desktop/lib/local/sandbox.js +17 -11
- package/vendor/cli/vendor/desktop/main.js +406 -2
- package/vendor/cli/vendor/one/src/iface/pty.js +3 -0
- package/vendor/cli/vendor/one/src/protocol.js +3 -0
- package/vendor/desktop/lib/local/cli-face.js +1 -1
- package/vendor/desktop/lib/local/engine.js +1 -1
- package/vendor/desktop/lib/local/integrity.js +1 -1
- package/vendor/desktop/lib/local/pty-host.js +3 -0
- package/vendor/desktop/lib/local/sandbox-appcontainer.js +6 -6
- package/vendor/desktop/lib/local/sandbox-bwrap.js +7 -7
- package/vendor/desktop/lib/local/sandbox.js +17 -11
- package/vendor/desktop/lib/skills-host.js +3 -0
- package/vendor/desktop/lib/speech-host.js +3 -0
- package/vendor/desktop/lib/speech-resolve.js +3 -0
- package/vendor/desktop/main.js +406 -2
- package/vendor/desktop/package.json +4 -3
- package/vendor/desktop/preload.js +1 -1
- package/vendor/desktop/renderer/app.js +3 -3
- package/vendor/desktop/renderer/avatar/avatar.css +29 -1
- package/vendor/desktop/renderer/avatar/pane.js +1 -1
- package/vendor/desktop/renderer/dictation.js +3 -0
- package/vendor/desktop/renderer/index.html +200 -2
- package/vendor/desktop/renderer/pty-panel.js +3 -0
- package/vendor/desktop/renderer/settings-skills.js +3 -0
- package/vendor/desktop/renderer/style.css +230 -0
- package/vendor/desktop/renderer/vendor/NOTICE.md +10 -2
- package/vendor/desktop/renderer/vendor/xterm.css +285 -0
- package/vendor/desktop/renderer/vendor/xterm.js +1 -0
- package/vendor/desktop/vendor/faces/cli/README.md +2 -2
- package/vendor/desktop/vendor/faces/cli/package.json +1 -1
- package/vendor/desktop/vendor/faces/cli/src/app.js +1 -1
- package/vendor/desktop/vendor/faces/cli/src/commands.js +2 -2
- package/vendor/desktop/vendor/faces/cli/src/config.js +1 -1
- package/vendor/desktop/vendor/faces/cli/src/panels.js +1 -1
- package/vendor/desktop/vendor/faces/cli/vendor/client/model-autosync.js +3 -0
- package/vendor/desktop/vendor/faces/cli/vendor/client/model-sync.js +3 -0
- package/vendor/desktop/vendor/faces/cli/vendor/client/prefs.js +1 -1
- package/vendor/desktop/vendor/faces/cli/vendor/client/skills.js +3 -0
- package/vendor/desktop/vendor/faces/cli/vendor/client/speech.js +3 -0
- package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/engine.js +1 -1
- package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/integrity.js +1 -1
- package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/sandbox-appcontainer.js +1 -1
- package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/sandbox-bwrap.js +1 -1
- package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/sandbox.js +1 -1
- package/vendor/desktop/vendor/faces/cli/vendor/desktop/main.js +3 -3
- package/vendor/desktop/vendor/faces/cli/vendor/one/src/iface/pty.js +3 -0
- package/vendor/desktop/vendor/faces/cli/vendor/one/src/protocol.js +3 -0
- package/vendor/desktop/vendor/model-autosync.js +3 -0
- package/vendor/desktop/vendor/model-sync.js +3 -0
- package/vendor/desktop/vendor/prefs.js +1 -1
- package/vendor/desktop/vendor/protocol.js +3 -0
- package/vendor/desktop/vendor/pty.js +3 -0
- package/vendor/desktop/vendor/skills.js +3 -0
- package/vendor/desktop/vendor/speech.js +3 -0
package/vendor/desktop/main.js
CHANGED
|
@@ -214,6 +214,35 @@ const creditsLib = (() => {
|
|
|
214
214
|
return require('./vendor/credits.js');
|
|
215
215
|
}
|
|
216
216
|
})();
|
|
217
|
+
// Dictation (Settings → Dictation, and the composer's mic). `lib/speech-host.js`
|
|
218
|
+
// holds the three things that need a process (PATH probe, temp file, execFile);
|
|
219
|
+
// the decision itself is `client/speech.js`, shared with the terminal so the two
|
|
220
|
+
// faces cannot disagree about whether a microphone is on. Same two-layout
|
|
221
|
+
// resolution as every other shared module in this file.
|
|
222
|
+
const speechHost = require('./lib/speech-host.js');
|
|
223
|
+
// The skill registry (Settings → Skills). `client/skills.js` is the ONE scanner —
|
|
224
|
+
// `/skills` in the terminal reads the same module, so "what can this machine do"
|
|
225
|
+
// has one answer. `lib/skills-host.js` adds only the home/cwd pinning that a
|
|
226
|
+
// renderer must not be able to supply for itself.
|
|
227
|
+
const skillsHost = require('./lib/skills-host.js');
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Read the shared `speech` preference, or `{}` when nobody has chosen.
|
|
231
|
+
*
|
|
232
|
+
* An absent value means OFF — `client/speech.js` `resolve()` requires an
|
|
233
|
+
* explicit `enabled: true`, so a fresh install never opens a microphone because
|
|
234
|
+
* it was upgraded. Never throws: a corrupt prefs file must not take the window
|
|
235
|
+
* down at boot, it must simply read as "dictation is off".
|
|
236
|
+
*/
|
|
237
|
+
function readSpeechSettings(store) {
|
|
238
|
+
try {
|
|
239
|
+
if (!store || typeof store.getSharedPref !== 'function') return {};
|
|
240
|
+
const value = store.getSharedPref('speech');
|
|
241
|
+
return value && typeof value === 'object' && !Array.isArray(value) ? value : {};
|
|
242
|
+
} catch {
|
|
243
|
+
return {};
|
|
244
|
+
}
|
|
245
|
+
}
|
|
217
246
|
// The LOCAL memory index (~/plan/agent-safety-plan.md §5). Rebuildable from the
|
|
218
247
|
// cloud, never authoritative, and strictly best-effort: every call here is
|
|
219
248
|
// wrapped because a dead index must not fail a save the cloud already accepted.
|
|
@@ -323,6 +352,13 @@ const DESKTOP_CLASSES = Object.freeze(['aegis', 'byok', 'local']);
|
|
|
323
352
|
*/
|
|
324
353
|
const CHAT_DELTA_CHANNEL = `${IPC_PREFIX}chatDelta`;
|
|
325
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
|
+
|
|
326
362
|
/** Main -> renderer pushes for native menu accelerators (Cmd/Ctrl+N,
|
|
327
363
|
* Cmd/Ctrl+K) that have no Electron role to bind to — the renderer owns
|
|
328
364
|
* "new chat" and "open search" behaviour, so the menu just asks for it. */
|
|
@@ -1754,6 +1790,50 @@ function createDevModeDispatch(settings) {
|
|
|
1754
1790
|
};
|
|
1755
1791
|
}
|
|
1756
1792
|
|
|
1793
|
+
/**
|
|
1794
|
+
* Model auto-sync: `aegis:getModelAutoSync` / `aegis:setModelAutoSync`.
|
|
1795
|
+
*
|
|
1796
|
+
* The switch for `client/model-autosync.js`. Same shape as
|
|
1797
|
+
* createConfirmModeDispatch and the same refusal rule: an explicit boolean is
|
|
1798
|
+
* required to change anything, so a malformed payload cannot turn a background
|
|
1799
|
+
* writer of `models.json` ON by accident. Off is the default and remains off
|
|
1800
|
+
* unless someone says so.
|
|
1801
|
+
*
|
|
1802
|
+
* `setModelAutoSync` writes the SHARED preference (`client/prefs.js`
|
|
1803
|
+
* `modelAutoSync`), not a host-local one, because both hosts run the same
|
|
1804
|
+
* scheduler: a machine whose window syncs but whose terminal does not would be
|
|
1805
|
+
* the drift that key exists to prevent.
|
|
1806
|
+
*
|
|
1807
|
+
* `getModelAutoSync` also reports what the scheduler last DID — an on/off
|
|
1808
|
+
* switch with no outcome beside it makes a preference that silently does
|
|
1809
|
+
* nothing indistinguishable from one that works.
|
|
1810
|
+
*/
|
|
1811
|
+
function createModelAutoSyncDispatch(settings, engine) {
|
|
1812
|
+
if (!settings) throw new Error('createModelAutoSyncDispatch requires a settings store');
|
|
1813
|
+
return {
|
|
1814
|
+
getModelAutoSync: () => {
|
|
1815
|
+
const status = engine && typeof engine.modelAutoSyncStatus === 'function'
|
|
1816
|
+
? engine.modelAutoSyncStatus()
|
|
1817
|
+
: { enabled: false };
|
|
1818
|
+
return { enabled: Boolean(status && status.enabled), status };
|
|
1819
|
+
},
|
|
1820
|
+
setModelAutoSync: (payload) => {
|
|
1821
|
+
const enabled = payload && payload.enabled;
|
|
1822
|
+
if (typeof enabled !== 'boolean') {
|
|
1823
|
+
const status = engine && typeof engine.modelAutoSyncStatus === 'function'
|
|
1824
|
+
? engine.modelAutoSyncStatus()
|
|
1825
|
+
: { enabled: false };
|
|
1826
|
+
return { enabled: Boolean(status && status.enabled), status };
|
|
1827
|
+
}
|
|
1828
|
+
settings.setSharedPref('modelAutoSync', enabled);
|
|
1829
|
+
const status = engine && typeof engine.modelAutoSyncStatus === 'function'
|
|
1830
|
+
? engine.modelAutoSyncStatus()
|
|
1831
|
+
: { enabled };
|
|
1832
|
+
return { enabled, status };
|
|
1833
|
+
},
|
|
1834
|
+
};
|
|
1835
|
+
}
|
|
1836
|
+
|
|
1757
1837
|
/**
|
|
1758
1838
|
* Plan mode: `aegis:getPermissionMode` / `aegis:setPermissionMode`. Same shape
|
|
1759
1839
|
* as createConfirmModeDispatch, registered through the same generic
|
|
@@ -1976,6 +2056,66 @@ function createCliFaceDispatch(deps) {
|
|
|
1976
2056
|
};
|
|
1977
2057
|
}
|
|
1978
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
|
+
|
|
1979
2119
|
function createSandboxPolicyDispatch(settings, sandbox, opts) {
|
|
1980
2120
|
if (!settings) throw new Error('createSandboxPolicyDispatch requires a settings store');
|
|
1981
2121
|
const mod = sandbox || {};
|
|
@@ -2408,7 +2548,33 @@ function createEngine(aegis, { app, safeStorage, dir: dirOverride, sessionsDir:
|
|
|
2408
2548
|
// never as `off`. `strict` is the user's own choice and lives beside the
|
|
2409
2549
|
// policy; absent means degrade-loudly, because refusing every command on an
|
|
2410
2550
|
// AppArmor-restricted host would brick the product rather than protect it.
|
|
2411
|
-
|
|
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
|
+
},
|
|
2412
2578
|
// Stored /permissions rules (~/plan/agent-safety-plan.md §2). The rules live
|
|
2413
2579
|
// in the SHARED data dir (~/.aegiscode/permissions.json), which is the same
|
|
2414
2580
|
// file the terminal face writes via `/permissions allow|deny|ask`, so a rule
|
|
@@ -2831,6 +2997,26 @@ function createModelDispatch(engine, { env = process.env, settings } = {}) {
|
|
|
2831
2997
|
'userModels.canDiscover': (payload) =>
|
|
2832
2998
|
Boolean(engine.canDiscoverModels(payload && payload.provider)),
|
|
2833
2999
|
'userModels.discoverable': () => engine.discoverableProviders(),
|
|
3000
|
+
// The reconciliation between what the vendors ISSUE and what AEGIS
|
|
3001
|
+
// promotes. The plan is read-only and carries no ids of its own: it is the
|
|
3002
|
+
// diff between `listModels('byok')`'s three layers and each vendor's own
|
|
3003
|
+
// list, so a Settings row can say "4 ids this vendor issues are not offered
|
|
3004
|
+
// here" instead of making the user diff two panels by eye.
|
|
3005
|
+
//
|
|
3006
|
+
// Apply is a SEPARATE message, and the renderer sends the plan it was shown:
|
|
3007
|
+
// the write is never inferred from the read, so opening Settings cannot add
|
|
3008
|
+
// rows to `models.json` as a side effect.
|
|
3009
|
+
'userModels.syncPlan': (payload) => engine.modelSyncPlan(payload && payload.only),
|
|
3010
|
+
'userModels.syncApply': (payload) =>
|
|
3011
|
+
engine.modelSyncApply(payload && payload.plan, payload && payload.only),
|
|
3012
|
+
// The auto-sync switch and what it last did. `syncStatus` is read-only and
|
|
3013
|
+
// cheap (it re-reads the preference and reports the throttle state); the
|
|
3014
|
+
// run message exists so Settings' "Sync now" does not have to wait for the
|
|
3015
|
+
// background clock — it is the same `runIfDue`, so pressing it while the
|
|
3016
|
+
// cadence is fresh correctly answers "throttled" instead of double-asking
|
|
3017
|
+
// every vendor.
|
|
3018
|
+
'userModels.syncStatus': () => engine.modelAutoSyncStatus(),
|
|
3019
|
+
'userModels.syncNow': (payload) => engine.modelAutoSyncRun(payload && payload.only),
|
|
2834
3020
|
// Persisting memory ("sync finished turns to cloud memory automatically").
|
|
2835
3021
|
// Reserved namespace, so it is invisible to the provider CRUD above — but
|
|
2836
3022
|
// unlike a provider it IS reachable deliberately, through these two. The
|
|
@@ -3252,7 +3438,18 @@ function createSyncDispatch(sessions, dir, aegis, settingsDir, modelDispatch) {
|
|
|
3252
3438
|
if (!modelDispatch || typeof modelDispatch.chat !== 'function') return null;
|
|
3253
3439
|
try {
|
|
3254
3440
|
const data = await modelDispatch.chat({
|
|
3255
|
-
|
|
3441
|
+
// 'aegis', not a made-up sentinel: the engine's dispatch() only
|
|
3442
|
+
// knows 'aegis' | 'byok' | 'local' | 'pro' and THROWS on anything
|
|
3443
|
+
// else (lib/local/engine.js `dispatch`). `payload.class` is empty
|
|
3444
|
+
// whenever the renderer's class <select> has not finished loading
|
|
3445
|
+
// yet — it starts with zero <option>s and is populated by an async
|
|
3446
|
+
// IPC round trip (app.js `loadClasses`) — which is exactly the
|
|
3447
|
+
// first turn of a fresh session, i.e. exactly when naming fires.
|
|
3448
|
+
// That throw was caught here and swallowed, so the naming round
|
|
3449
|
+
// silently failed and every title fell through to the crude local
|
|
3450
|
+
// derivation, permanently. 'aegis' matches the same empty-select
|
|
3451
|
+
// fallback app.js itself uses elsewhere (see `classId` there).
|
|
3452
|
+
class: (payload && payload.class) || 'aegis',
|
|
3256
3453
|
model: payload && payload.model,
|
|
3257
3454
|
prompt: text,
|
|
3258
3455
|
system: opts.system,
|
|
@@ -5955,6 +6152,11 @@ function bootstrap() {
|
|
|
5955
6152
|
// logging backgroundLaneLogs() gates below, aegis:get/setAccountUsername
|
|
5956
6153
|
// persist the sign-in slug the panel checks to decide whether to show itself.
|
|
5957
6154
|
registerConfirmModeIpc(ipcMain, createDevModeDispatch(settings));
|
|
6155
|
+
// Model auto-sync (Settings › Models): aegis:getModelAutoSync /
|
|
6156
|
+
// setModelAutoSync. The switch the background clock below obeys — registered
|
|
6157
|
+
// here, beside the other shared preferences, because that is where the
|
|
6158
|
+
// settings store lands.
|
|
6159
|
+
registerConfirmModeIpc(ipcMain, createModelAutoSyncDispatch(settings, engine));
|
|
5958
6160
|
|
|
5959
6161
|
// Vault backend preference (Settings/the authorship panel → Google Drive /
|
|
5960
6162
|
// AE / No sync): aegis:getVaultBackend / aegis:setVaultBackend. Registered
|
|
@@ -6003,6 +6205,22 @@ function bootstrap() {
|
|
|
6003
6205
|
})
|
|
6004
6206
|
);
|
|
6005
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
|
+
|
|
6006
6224
|
// Funnel instrumentation (Phase 2 of docs/upgrade-conversion-plan.md):
|
|
6007
6225
|
// aegis:telemetryEvent / aegis:telemetryReport, backed by
|
|
6008
6226
|
// lib/local/telemetry.js.
|
|
@@ -6307,6 +6525,7 @@ function bootstrap() {
|
|
|
6307
6525
|
// hold the process open, but an explicit quit should still cancel them
|
|
6308
6526
|
// rather than let one land during teardown.
|
|
6309
6527
|
if (updateManager && typeof updateManager.stop === 'function') updateManager.stop();
|
|
6528
|
+
stopModelAutoSync();
|
|
6310
6529
|
});
|
|
6311
6530
|
|
|
6312
6531
|
// Unload any local model this app warmed (engine.js `unloadLocalModels` ->
|
|
@@ -6359,6 +6578,53 @@ function bootstrap() {
|
|
|
6359
6578
|
isPackaged: app.isPackaged,
|
|
6360
6579
|
onStatus: broadcastUpdateStatus,
|
|
6361
6580
|
});
|
|
6581
|
+
|
|
6582
|
+
// ── the model auto-sync clock ───────────────────────────────────────────
|
|
6583
|
+
//
|
|
6584
|
+
// `client/model-autosync.js` deliberately owns no timer: it decides WHEN a
|
|
6585
|
+
// sync is due, and the host supplies the clock. This is that clock.
|
|
6586
|
+
//
|
|
6587
|
+
// Design points that are deliberate, not incidental:
|
|
6588
|
+
//
|
|
6589
|
+
// · NOTHING runs until the preference is on. `runIfDue()` re-reads the
|
|
6590
|
+
// shared store on every call and answers `{ ran:false, reason:'off' }`
|
|
6591
|
+
// when nobody chose — so an upgrading machine makes zero vendor calls.
|
|
6592
|
+
// · The first attempt is delayed, not immediate: a launch should open a
|
|
6593
|
+
// window before it asks six vendors anything.
|
|
6594
|
+
// · The timer is unref'd, exactly like the update manager's, so a pending
|
|
6595
|
+
// tick can never be the reason the app refuses to quit.
|
|
6596
|
+
// · A sync that runs is broadcast to the window so a Settings panel can
|
|
6597
|
+
// show "2 models added" without polling.
|
|
6598
|
+
let modelAutoSyncTimer = null;
|
|
6599
|
+
function startModelAutoSync() {
|
|
6600
|
+
if (modelAutoSyncTimer) return;
|
|
6601
|
+
const tick = () => {
|
|
6602
|
+
Promise.resolve(engine.modelAutoSyncRun())
|
|
6603
|
+
.then((report) => {
|
|
6604
|
+
if (!report || !report.ran) return;
|
|
6605
|
+
if (report.added > 0 && typeof engine.refreshByokModels === 'function') {
|
|
6606
|
+
// The plan's writes land in `models.json`; the next turn reads that
|
|
6607
|
+
// file anyway, but the OPEN window's picker was built at load, so
|
|
6608
|
+
// it is told rather than left stale until a restart.
|
|
6609
|
+
try { engine.refreshByokModels(); } catch { /* the file is the truth */ }
|
|
6610
|
+
}
|
|
6611
|
+
for (const win of openWindows) {
|
|
6612
|
+
if (!win.isDestroyed()) win.webContents.send(`${IPC_PREFIX}modelSyncReport`, report);
|
|
6613
|
+
}
|
|
6614
|
+
})
|
|
6615
|
+
.catch(() => { /* the scheduler never rejects; this is belt and braces */ });
|
|
6616
|
+
};
|
|
6617
|
+
// Ten minutes after launch: long enough that a cold start is unaffected,
|
|
6618
|
+
// short enough that a long session still syncs the same day.
|
|
6619
|
+
const first = setTimeout(tick, 10 * 60 * 1000);
|
|
6620
|
+
if (typeof first.unref === 'function') first.unref();
|
|
6621
|
+
modelAutoSyncTimer = setInterval(tick, 6 * 60 * 60 * 1000);
|
|
6622
|
+
if (typeof modelAutoSyncTimer.unref === 'function') modelAutoSyncTimer.unref();
|
|
6623
|
+
}
|
|
6624
|
+
function stopModelAutoSync() {
|
|
6625
|
+
if (modelAutoSyncTimer) clearInterval(modelAutoSyncTimer);
|
|
6626
|
+
modelAutoSyncTimer = null;
|
|
6627
|
+
}
|
|
6362
6628
|
registerUpdateIpc(ipcMain, updateManager);
|
|
6363
6629
|
ipcMain.handle(`${IPC_PREFIX}accountStatus`, () => accountKey.status());
|
|
6364
6630
|
// The renderer's report of whether Back/Forward would move (see app.js
|
|
@@ -6390,6 +6656,71 @@ function bootstrap() {
|
|
|
6390
6656
|
// intentions and must never be one button that guesses.
|
|
6391
6657
|
ipcMain.handle(`${IPC_PREFIX}driveBackupConversation`, (_event, payload) =>
|
|
6392
6658
|
googleConnect.backupConversation({ sessionId: payload && payload.sessionId }));
|
|
6659
|
+
// ── Dictation (speech to text) ────────────────────────────────────────────
|
|
6660
|
+
// Four channels, all thin: the decision is client/speech.js and the work is
|
|
6661
|
+
// lib/speech-host.js. Nothing here holds a policy, and nothing here stores a
|
|
6662
|
+
// transcript or a recording.
|
|
6663
|
+
//
|
|
6664
|
+
// `speechStatus` is what the Settings card and the composer's mic button read.
|
|
6665
|
+
// It never throws: a machine with no whisper.cpp gets `{ enabled: false,
|
|
6666
|
+
// reason, install }`, which is the copy the card prints.
|
|
6667
|
+
ipcMain.handle(`${IPC_PREFIX}speechStatus`, () => {
|
|
6668
|
+
try {
|
|
6669
|
+
return speechHost.status({ settings: readSpeechSettings(settings) });
|
|
6670
|
+
} catch (e) {
|
|
6671
|
+
return { enabled: false, engine: 'none', reason: (e && e.message) || 'dictation status failed' };
|
|
6672
|
+
}
|
|
6673
|
+
});
|
|
6674
|
+
// `speechSet` writes the shared preference. The payload is picked apart field
|
|
6675
|
+
// by field rather than stored wholesale, so a renderer cannot drop extra keys
|
|
6676
|
+
// into the shared store — `client/prefs.js` refuses secrets, but shape is this
|
|
6677
|
+
// handler's job.
|
|
6678
|
+
ipcMain.handle(`${IPC_PREFIX}speechSet`, (_event, payload) => {
|
|
6679
|
+
try {
|
|
6680
|
+
const p = payload && typeof payload === 'object' ? payload : {};
|
|
6681
|
+
const current = readSpeechSettings(settings);
|
|
6682
|
+
const next = { ...current };
|
|
6683
|
+
if (typeof p.enabled === 'boolean') next.enabled = p.enabled;
|
|
6684
|
+
if (typeof p.engine === 'string') next.engine = p.engine === 'local' ? 'local' : 'none';
|
|
6685
|
+
if (typeof p.model === 'string') next.model = p.model.trim();
|
|
6686
|
+
if (typeof p.language === 'string') next.language = p.language.trim() || 'auto';
|
|
6687
|
+
if (p.maxSeconds != null && Number.isFinite(Number(p.maxSeconds))) {
|
|
6688
|
+
next.maxSeconds = Math.min(600, Math.max(5, Math.round(Number(p.maxSeconds))));
|
|
6689
|
+
}
|
|
6690
|
+
// Turning it on with no engine installed is refused here rather than in
|
|
6691
|
+
// the renderer: the card can be bypassed, and the invariant "enabled
|
|
6692
|
+
// implies a machine that can actually transcribe" is the one worth
|
|
6693
|
+
// holding. The user sees the same install hint either way.
|
|
6694
|
+
if (next.enabled === true) {
|
|
6695
|
+
const st = speechHost.status({ settings: { ...next, enabled: true } });
|
|
6696
|
+
if (!st.enabled) return { ok: false, ...st, settings: st.settings };
|
|
6697
|
+
}
|
|
6698
|
+
settings.setSharedPref('speech', next);
|
|
6699
|
+
return { ok: true, ...speechHost.status({ settings: next }) };
|
|
6700
|
+
} catch (e) {
|
|
6701
|
+
return { ok: false, error: (e && e.message) || 'could not save dictation settings' };
|
|
6702
|
+
}
|
|
6703
|
+
});
|
|
6704
|
+
// `speechTranscribe` takes the recorded bytes as a Buffer over the bridge and
|
|
6705
|
+
// answers `{ ok, text }` or `{ ok: false, reason }`. The temp file it needs is
|
|
6706
|
+
// created and removed inside lib/speech-host.js; the audio never leaves this
|
|
6707
|
+
// machine, which is asserted by client/speech.js's plan having no URL in it.
|
|
6708
|
+
ipcMain.handle(`${IPC_PREFIX}speechTranscribe`, (_event, payload) => {
|
|
6709
|
+
const p = payload && typeof payload === 'object' ? payload : {};
|
|
6710
|
+
return speechHost
|
|
6711
|
+
.transcribe(p.audio, { settings: readSpeechSettings(settings), ext: p.ext })
|
|
6712
|
+
.catch((e) => ({ ok: false, reason: (e && e.message) || 'transcription failed' }));
|
|
6713
|
+
});
|
|
6714
|
+
// ── Skills (Settings → Skills) ────────────────────────────────────────────
|
|
6715
|
+
// The window's list/create/remove. Same shared registry `/skills` reads, so a
|
|
6716
|
+
// skill made in the card appears in the terminal on the next scan and vice
|
|
6717
|
+
// versa. `home`/`cwd` are decided in lib/skills-host.js, never by the caller:
|
|
6718
|
+
// an IPC payload naming its own home would be an arbitrary-file-write.
|
|
6719
|
+
ipcMain.handle(`${IPC_PREFIX}skillsList`, () => skillsHost.list());
|
|
6720
|
+
ipcMain.handle(`${IPC_PREFIX}skillsRead`, (_event, payload) => skillsHost.read(payload || {}));
|
|
6721
|
+
ipcMain.handle(`${IPC_PREFIX}skillsCreate`, (_event, payload) => skillsHost.create(payload || {}));
|
|
6722
|
+
ipcMain.handle(`${IPC_PREFIX}skillsRemove`, (_event, payload) => skillsHost.remove(payload || {}));
|
|
6723
|
+
ipcMain.handle(`${IPC_PREFIX}skillsImport`, (_event, payload) => skillsHost.importFromUrl(payload || {}));
|
|
6393
6724
|
registerExportIpc(
|
|
6394
6725
|
ipcMain,
|
|
6395
6726
|
sessionStore,
|
|
@@ -6565,6 +6896,75 @@ function bootstrap() {
|
|
|
6565
6896
|
}
|
|
6566
6897
|
|
|
6567
6898
|
app.whenReady().then(async () => {
|
|
6899
|
+
// ── Microphone permission (Settings → Dictation) ──────────────────────
|
|
6900
|
+
//
|
|
6901
|
+
// Electron grants NO web permission by default, so `getUserMedia({ audio:
|
|
6902
|
+
// true })` in the renderer rejects with NotAllowedError before any system
|
|
6903
|
+
// prompt is ever shown. That is the reason dictation was unreachable even
|
|
6904
|
+
// for someone with whisper.cpp installed: the feature worked and could not
|
|
6905
|
+
// be started.
|
|
6906
|
+
//
|
|
6907
|
+
// The handler below is deliberately narrow, and it is a SECURITY boundary,
|
|
6908
|
+
// not a convenience:
|
|
6909
|
+
//
|
|
6910
|
+
// · Only `media` is ever granted, and only to this app's own file://
|
|
6911
|
+
// renderer. Camera (`media` without the audio detail) is not reachable
|
|
6912
|
+
// from this product and is denied.
|
|
6913
|
+
// · Only the MAIN window gets it. The quick launcher is a separate
|
|
6914
|
+
// frameless window with no composer; a dictation grant there would be a
|
|
6915
|
+
// microphone nobody asked for.
|
|
6916
|
+
// · The DECISION about whether dictation may run at all stays in
|
|
6917
|
+
// `client/speech.js` — this handler says "the OS may prompt", it never
|
|
6918
|
+
// turns the feature on. Both gates must pass.
|
|
6919
|
+
//
|
|
6920
|
+
// `setPermissionCheckHandler` is registered alongside because a packaged
|
|
6921
|
+
// Electron build otherwise reports `navigator.permissions.query({name:
|
|
6922
|
+
// 'microphone'})` as denied even after the request handler granted it, and
|
|
6923
|
+
// the renderer's feature detection reads that answer.
|
|
6924
|
+
const isOwnRenderer = (url) => {
|
|
6925
|
+
if (typeof url !== 'string' || !url) return false;
|
|
6926
|
+
try {
|
|
6927
|
+
const parsed = new URL(url);
|
|
6928
|
+
if (parsed.protocol === 'file:') return true;
|
|
6929
|
+
// Dev runs load over http://localhost (electron . with a dev server).
|
|
6930
|
+
return /^(localhost|127\.0\.0\.1)$/.test(parsed.hostname);
|
|
6931
|
+
} catch {
|
|
6932
|
+
return false;
|
|
6933
|
+
}
|
|
6934
|
+
};
|
|
6935
|
+
const isMainWindowUrl = (webContents) => {
|
|
6936
|
+
if (!webContents || typeof webContents.getURL !== 'function') return false;
|
|
6937
|
+
const url = webContents.getURL();
|
|
6938
|
+
if (!isOwnRenderer(url)) return false;
|
|
6939
|
+
// The quick launcher loads quick.html; nothing in it records audio.
|
|
6940
|
+
return !/quick\.html(?:[?#]|$)/.test(url);
|
|
6941
|
+
};
|
|
6942
|
+
try {
|
|
6943
|
+
// `session` comes from the electron handle resolved above, not a top-level
|
|
6944
|
+
// require — this file must stay importable in plain Node so its pure
|
|
6945
|
+
// exports can be unit-tested without an Electron binary.
|
|
6946
|
+
const session = electron.session;
|
|
6947
|
+
session.defaultSession.setPermissionRequestHandler((webContents, permission, callback, details) => {
|
|
6948
|
+
if (permission !== 'media') return callback(false);
|
|
6949
|
+
if (!isMainWindowUrl(webContents)) return callback(false);
|
|
6950
|
+
// `details.mediaTypes` names what was asked for: ['audio'] for dictation.
|
|
6951
|
+
const types = (details && details.mediaTypes) || [];
|
|
6952
|
+
if (Array.isArray(types) && types.length && !types.includes('audio')) return callback(false);
|
|
6953
|
+
// Video is never requested by this product.
|
|
6954
|
+
if (Array.isArray(types) && types.includes('video')) return callback(false);
|
|
6955
|
+
return callback(true);
|
|
6956
|
+
});
|
|
6957
|
+
session.defaultSession.setPermissionCheckHandler((webContents, permission, requestingOrigin) => {
|
|
6958
|
+
if (permission !== 'media') return false;
|
|
6959
|
+
if (!isMainWindowUrl(webContents)) return false;
|
|
6960
|
+
return isOwnRenderer(requestingOrigin);
|
|
6961
|
+
});
|
|
6962
|
+
} catch (e) {
|
|
6963
|
+
// Never fatal: without a grant dictation reports "permission was denied"
|
|
6964
|
+
// in the card, which is a true sentence, and every other feature works.
|
|
6965
|
+
console.warn(`aegis: could not install the microphone permission handler: ${e && e.message}`);
|
|
6966
|
+
}
|
|
6967
|
+
|
|
6568
6968
|
// Hydrate the client from the persisted key BEFORE the renderer issues any
|
|
6569
6969
|
// status/model call, so class/model dropdowns populate immediately when a
|
|
6570
6970
|
// key was saved in-app (safeStorage is usable only after app ready).
|
|
@@ -6696,6 +7096,7 @@ function bootstrap() {
|
|
|
6696
7096
|
// its global shortcut only — never by starting the app.
|
|
6697
7097
|
const win = createWindow();
|
|
6698
7098
|
updateManager.start();
|
|
7099
|
+
startModelAutoSync();
|
|
6699
7100
|
// Cold-launch deep link (Linux/Windows argv, or a pre-ready macOS
|
|
6700
7101
|
// 'open-url'): the window didn't exist when it was parsed above, so
|
|
6701
7102
|
// deliver it now that one does.
|
|
@@ -6763,6 +7164,8 @@ module.exports = {
|
|
|
6763
7164
|
TOPUP_POLL_MS,
|
|
6764
7165
|
TOPUP_POLL_TRIES,
|
|
6765
7166
|
CHAT_DELTA_CHANNEL,
|
|
7167
|
+
PTY_EVENT_CHANNEL,
|
|
7168
|
+
createPtyIpc,
|
|
6766
7169
|
MENU_NEW_CHAT_CHANNEL,
|
|
6767
7170
|
MENU_SEARCH_CHANNEL,
|
|
6768
7171
|
MENU_SEARCH_MEMORY_CHANNEL,
|
|
@@ -6813,6 +7216,7 @@ module.exports = {
|
|
|
6813
7216
|
registerQuickLauncherIpc,
|
|
6814
7217
|
createConfirmModeDispatch,
|
|
6815
7218
|
createDevModeDispatch,
|
|
7219
|
+
createModelAutoSyncDispatch,
|
|
6816
7220
|
createVaultBackendDispatch,
|
|
6817
7221
|
createPermRulesDispatch,
|
|
6818
7222
|
createSandboxPolicyDispatch,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "aegis-desktop",
|
|
3
3
|
"productName": "aegis one",
|
|
4
4
|
"desktopName": "aegis-desktop",
|
|
5
|
-
"version": "1.0.
|
|
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)}),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}),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")},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));
|