aegisone 1.0.21 → 1.0.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (226) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +1 -1
  3. package/SOURCE-OFFER.txt +9 -0
  4. package/bin/aegis.js +1 -322
  5. package/package.json +4 -2
  6. package/scripts/bump.mjs +1 -211
  7. package/scripts/bundle.js +1 -129
  8. package/scripts/predist.mjs +1 -939
  9. package/src/child.js +1 -285
  10. package/src/dispatch.js +1 -269
  11. package/src/doctor.js +1 -639
  12. package/src/host.js +1 -111
  13. package/src/permissions.js +1 -369
  14. package/src/probes.js +1 -159
  15. package/src/release.js +1 -409
  16. package/vendor/cli/bin/aegiscode.js +2 -914
  17. package/vendor/cli/package.json +3 -2
  18. package/vendor/cli/scripts/check.mjs +1 -52
  19. package/vendor/cli/scripts/demo.mjs +1 -94
  20. package/vendor/cli/scripts/predist.mjs +1 -75
  21. package/vendor/cli/scripts/runtests.mjs +1 -56
  22. package/vendor/cli/scripts/seal-gate.mjs +1 -74
  23. package/vendor/cli/src/agents.js +1 -139
  24. package/vendor/cli/src/app.js +1 -2932
  25. package/vendor/cli/src/art.js +1 -289
  26. package/vendor/cli/src/autonomous.js +1 -515
  27. package/vendor/cli/src/caps.js +1 -879
  28. package/vendor/cli/src/chatflow.js +1 -3008
  29. package/vendor/cli/src/checkpoint.js +1 -90
  30. package/vendor/cli/src/clipboard.js +1 -424
  31. package/vendor/cli/src/cloudsync.js +1 -528
  32. package/vendor/cli/src/commands.js +1 -3987
  33. package/vendor/cli/src/config.js +1 -581
  34. package/vendor/cli/src/connect.js +1 -349
  35. package/vendor/cli/src/credentials.js +1 -33
  36. package/vendor/cli/src/deps.js +1 -232
  37. package/vendor/cli/src/devrun.js +1 -187
  38. package/vendor/cli/src/diff.js +1 -333
  39. package/vendor/cli/src/diffview.js +1 -296
  40. package/vendor/cli/src/engine.js +1 -297
  41. package/vendor/cli/src/entitlement.js +1 -355
  42. package/vendor/cli/src/events.js +1 -707
  43. package/vendor/cli/src/export.js +1 -67
  44. package/vendor/cli/src/fingerprint.js +1 -592
  45. package/vendor/cli/src/format.js +1 -259
  46. package/vendor/cli/src/fuzzy.js +1 -119
  47. package/vendor/cli/src/gate.js +1 -55
  48. package/vendor/cli/src/history.js +1 -401
  49. package/vendor/cli/src/init.js +1 -175
  50. package/vendor/cli/src/input.js +1 -139
  51. package/vendor/cli/src/keys.js +1 -183
  52. package/vendor/cli/src/limits.js +1 -190
  53. package/vendor/cli/src/markdown.js +1 -306
  54. package/vendor/cli/src/mcp.js +1 -694
  55. package/vendor/cli/src/models.js +1 -487
  56. package/vendor/cli/src/naming.js +1 -229
  57. package/vendor/cli/src/overlays.js +1 -461
  58. package/vendor/cli/src/panels.js +1 -1418
  59. package/vendor/cli/src/permissions.js +1 -290
  60. package/vendor/cli/src/ping.js +1 -226
  61. package/vendor/cli/src/presence.js +1 -238
  62. package/vendor/cli/src/provenance.js +2 -182
  63. package/vendor/cli/src/render.js +1 -515
  64. package/vendor/cli/src/screen.js +1 -518
  65. package/vendor/cli/src/screens.js +1 -896
  66. package/vendor/cli/src/secret.js +1 -59
  67. package/vendor/cli/src/securefs.js +1 -359
  68. package/vendor/cli/src/settings.js +1 -155
  69. package/vendor/cli/src/shared.js +1 -52
  70. package/vendor/cli/src/sharedpaths.js +1 -53
  71. package/vendor/cli/src/signup.js +1 -156
  72. package/vendor/cli/src/summarize.js +1 -95
  73. package/vendor/cli/src/sysdiag.js +1 -585
  74. package/vendor/cli/src/system.js +1 -40
  75. package/vendor/cli/src/theme.js +1 -570
  76. package/vendor/cli/src/title.js +1 -220
  77. package/vendor/cli/src/todos.js +1 -115
  78. package/vendor/cli/src/tokens.js +1 -263
  79. package/vendor/cli/src/topup.js +1 -210
  80. package/vendor/cli/src/update.js +1 -181
  81. package/vendor/cli/vendor/client/aegis.js +1 -2054
  82. package/vendor/cli/vendor/client/attest.js +1 -442
  83. package/vendor/cli/vendor/client/authorship-key.js +1 -410
  84. package/vendor/cli/vendor/client/auto-provision.js +1 -134
  85. package/vendor/cli/vendor/client/brain-catalog.js +1 -268
  86. package/vendor/cli/vendor/client/byok-catalog.js +1 -230
  87. package/vendor/cli/vendor/client/credentials.js +1 -494
  88. package/vendor/cli/vendor/client/device-fingerprint.js +1 -141
  89. package/vendor/cli/vendor/client/drive-connect.js +1 -85
  90. package/vendor/cli/vendor/client/drive-upload.js +1 -174
  91. package/vendor/cli/vendor/client/env-file.js +1 -1273
  92. package/vendor/cli/vendor/client/fingerprint.js +1 -1064
  93. package/vendor/cli/vendor/client/foreign-memory.js +1 -669
  94. package/vendor/cli/vendor/client/google-signin.js +1 -125
  95. package/vendor/cli/vendor/client/hooks.js +1 -430
  96. package/vendor/cli/vendor/client/model-discovery.js +1 -330
  97. package/vendor/cli/vendor/client/platform.js +1 -937
  98. package/vendor/cli/vendor/client/prefs.js +1 -351
  99. package/vendor/cli/vendor/client/presence-constants.js +1 -107
  100. package/vendor/cli/vendor/client/presence.js +1 -438
  101. package/vendor/cli/vendor/client/record-vault.js +3 -1055
  102. package/vendor/cli/vendor/client/session-store.js +1 -548
  103. package/vendor/cli/vendor/client/topup.js +1 -297
  104. package/vendor/cli/vendor/client/touch.js +1 -458
  105. package/vendor/cli/vendor/client/update.js +1 -704
  106. package/vendor/cli/vendor/client/user-models.js +1 -381
  107. package/vendor/cli/vendor/desktop/lib/local/agents.js +1 -105
  108. package/vendor/cli/vendor/desktop/lib/local/autonomous.js +1 -1045
  109. package/vendor/cli/vendor/desktop/lib/local/claude-pro.js +1 -993
  110. package/vendor/cli/vendor/desktop/lib/local/context.js +1 -95
  111. package/vendor/cli/vendor/desktop/lib/local/engine.js +1 -3228
  112. package/vendor/cli/vendor/desktop/lib/local/entitlement.js +1 -654
  113. package/vendor/cli/vendor/desktop/lib/local/git-scope.js +1 -228
  114. package/vendor/cli/vendor/desktop/lib/local/local.js +1 -2135
  115. package/vendor/cli/vendor/desktop/lib/local/prompt.js +1 -275
  116. package/vendor/cli/vendor/desktop/lib/local/queue.js +1 -560
  117. package/vendor/cli/vendor/desktop/lib/local/session-rounds.js +1 -208
  118. package/vendor/cli/vendor/desktop/lib/local/shell.js +1 -680
  119. package/vendor/cli/vendor/desktop/lib/local/tools.js +1 -1238
  120. package/vendor/cli/vendor/desktop/lib/local/turn-guard.js +1 -300
  121. package/vendor/cli/vendor/desktop/lib/local/worktree-lock.js +1 -235
  122. package/vendor/cli/vendor/desktop/lib/settings.js +1 -890
  123. package/vendor/cli/vendor/desktop/renderer/usage.js +1 -1239
  124. package/vendor/cli/vendor/hosts/install.js +1 -638
  125. package/vendor/cli/vendor/hosts/openai-shim.js +1 -515
  126. package/vendor/cli/vendor/hosts/spec.js +1 -164
  127. package/vendor/cli/vendor/hosts/targets.js +1 -346
  128. package/vendor/cli/vendor/mcp/server.js +1 -221
  129. package/vendor/cli/vendor/mcp/tools.js +1 -408
  130. package/vendor/cli/vendor/one/src/child.js +1 -285
  131. package/vendor/cli/vendor/one/src/permissions.js +1 -369
  132. package/vendor/desktop/bin/aegis.js +1 -32
  133. package/vendor/desktop/lib/account-key.js +1 -56
  134. package/vendor/desktop/lib/auto.js +1 -430
  135. package/vendor/desktop/lib/avatar/companion.js +1 -698
  136. package/vendor/desktop/lib/avatar/cosmetics.js +1 -532
  137. package/vendor/desktop/lib/avatar/events.js +1 -344
  138. package/vendor/desktop/lib/avatar/holder-turn.js +1 -350
  139. package/vendor/desktop/lib/avatar/holders.js +1 -612
  140. package/vendor/desktop/lib/avatar/identity.js +1 -641
  141. package/vendor/desktop/lib/avatar/level.js +1 -368
  142. package/vendor/desktop/lib/avatar/mirror.js +1 -524
  143. package/vendor/desktop/lib/avatar/persona.js +1 -388
  144. package/vendor/desktop/lib/avatar/profile.js +1 -977
  145. package/vendor/desktop/lib/avatar/register.js +1 -307
  146. package/vendor/desktop/lib/avatar/store.js +1 -472
  147. package/vendor/desktop/lib/avatar/tiers.js +1 -38
  148. package/vendor/desktop/lib/avatar/transfer.js +1 -415
  149. package/vendor/desktop/lib/avatar/turn.js +1 -216
  150. package/vendor/desktop/lib/avatar/voice.js +1 -328
  151. package/vendor/desktop/lib/avatar/xp.js +1 -404
  152. package/vendor/desktop/lib/deep-link.js +1 -120
  153. package/vendor/desktop/lib/fingerprint.js +2 -347
  154. package/vendor/desktop/lib/google-connect.js +1 -169
  155. package/vendor/desktop/lib/local/agents.js +1 -105
  156. package/vendor/desktop/lib/local/autonomous.js +1 -1045
  157. package/vendor/desktop/lib/local/claude-pro.js +1 -993
  158. package/vendor/desktop/lib/local/context.js +1 -95
  159. package/vendor/desktop/lib/local/engine.js +1 -3228
  160. package/vendor/desktop/lib/local/entitlement.js +1 -654
  161. package/vendor/desktop/lib/local/git-scope.js +1 -228
  162. package/vendor/desktop/lib/local/local.js +1 -2135
  163. package/vendor/desktop/lib/local/prompt.js +1 -275
  164. package/vendor/desktop/lib/local/queue.js +1 -560
  165. package/vendor/desktop/lib/local/session-rounds.js +1 -208
  166. package/vendor/desktop/lib/local/shell.js +1 -680
  167. package/vendor/desktop/lib/local/telemetry.js +1 -470
  168. package/vendor/desktop/lib/local/tools.js +1 -1238
  169. package/vendor/desktop/lib/local/turn-guard.js +1 -300
  170. package/vendor/desktop/lib/local/worktree-lock.js +1 -235
  171. package/vendor/desktop/lib/provider-key-mirror.js +1 -252
  172. package/vendor/desktop/lib/quick-launcher.js +1 -84
  173. package/vendor/desktop/lib/settings.js +1 -890
  174. package/vendor/desktop/lib/sync/memory-queue.js +1 -60
  175. package/vendor/desktop/lib/sync/persist-gate.js +1 -148
  176. package/vendor/desktop/lib/sync/sessions.js +1 -106
  177. package/vendor/desktop/lib/window-state.js +1 -66
  178. package/vendor/desktop/main.js +1 -4390
  179. package/vendor/desktop/package.json +3 -5
  180. package/vendor/desktop/preload.js +1 -628
  181. package/vendor/desktop/renderer/app.js +1 -6560
  182. package/vendor/desktop/renderer/avatar/assemble.js +1 -335
  183. package/vendor/desktop/renderer/avatar/avatar.js +1 -380
  184. package/vendor/desktop/renderer/avatar/cards.js +1 -141
  185. package/vendor/desktop/renderer/avatar/hud.js +1 -206
  186. package/vendor/desktop/renderer/avatar/machine.js +1 -213
  187. package/vendor/desktop/renderer/avatar/pane.js +1 -439
  188. package/vendor/desktop/renderer/avatar/parts.js +1 -437
  189. package/vendor/desktop/renderer/budget.js +1 -168
  190. package/vendor/desktop/renderer/companion.js +1 -223
  191. package/vendor/desktop/renderer/diff.js +1 -359
  192. package/vendor/desktop/renderer/diffview.js +1 -336
  193. package/vendor/desktop/renderer/fingerprint.js +3 -720
  194. package/vendor/desktop/renderer/markdown.js +1 -168
  195. package/vendor/desktop/renderer/provider-toolbar.js +1 -134
  196. package/vendor/desktop/renderer/providers.js +1 -259
  197. package/vendor/desktop/renderer/quick.js +1 -191
  198. package/vendor/desktop/renderer/stream-policy.js +1 -306
  199. package/vendor/desktop/renderer/transcript-view.js +1 -323
  200. package/vendor/desktop/renderer/usage.js +1 -1239
  201. package/vendor/desktop/vendor/aegis.js +1 -2054
  202. package/vendor/desktop/vendor/attest.js +1 -442
  203. package/vendor/desktop/vendor/authorship-key.js +1 -410
  204. package/vendor/desktop/vendor/auto-provision.js +1 -134
  205. package/vendor/desktop/vendor/brain-catalog.js +1 -268
  206. package/vendor/desktop/vendor/byok-catalog.js +1 -230
  207. package/vendor/desktop/vendor/credentials.js +1 -494
  208. package/vendor/desktop/vendor/device-fingerprint.js +1 -141
  209. package/vendor/desktop/vendor/drive-connect.js +1 -85
  210. package/vendor/desktop/vendor/drive-upload.js +1 -174
  211. package/vendor/desktop/vendor/env-file.js +1 -1273
  212. package/vendor/desktop/vendor/fingerprint.js +1 -1064
  213. package/vendor/desktop/vendor/foreign-memory.js +1 -669
  214. package/vendor/desktop/vendor/google-signin.js +1 -125
  215. package/vendor/desktop/vendor/hooks.js +1 -430
  216. package/vendor/desktop/vendor/model-discovery.js +1 -330
  217. package/vendor/desktop/vendor/platform.js +1 -937
  218. package/vendor/desktop/vendor/prefs.js +1 -351
  219. package/vendor/desktop/vendor/presence-constants.js +1 -107
  220. package/vendor/desktop/vendor/presence.js +1 -438
  221. package/vendor/desktop/vendor/record-vault.js +3 -1055
  222. package/vendor/desktop/vendor/session-store.js +1 -548
  223. package/vendor/desktop/vendor/topup.js +1 -297
  224. package/vendor/desktop/vendor/touch.js +1 -458
  225. package/vendor/desktop/vendor/update.js +1 -704
  226. package/vendor/desktop/vendor/user-models.js +1 -381
@@ -1,62 +1,3 @@
1
1
  // SPDX-License-Identifier: AGPL-3.0-or-later
2
2
  // Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
3
- // AEGIS Code (aegiscode) — source: https://github.com/aegisinfo/aegiscode-plugin
4
- // Conveying a modified copy, or running one as a network service, owes the
5
- // corresponding source under this licence (§5/§13) — see LICENSING.md.
6
- 'use strict';
7
-
8
- /**
9
- * memory-queue.js — local retry queue for cloud memory saves (plan P3 §7).
10
- * When `aegis.memorySave()` fails (no key configured, offline), the entry is
11
- * appended to <dir>/memory-queue.json instead of being dropped, so a later
12
- * "Sync now" or heartbeat retry can flush it once the cloud is reachable.
13
- * Pure Node + injectable dir, mirrors desktop/lib/sync/sessions.js.
14
- */
15
-
16
- const fs = require('node:fs');
17
- const path = require('node:path');
18
-
19
- function queueFile(dir) {
20
- return path.join(dir, 'memory-queue.json');
21
- }
22
-
23
- function load(dir) {
24
- try {
25
- const data = JSON.parse(fs.readFileSync(queueFile(dir), 'utf8'));
26
- return Array.isArray(data) ? data : [];
27
- } catch {
28
- return [];
29
- }
30
- }
31
-
32
- function atomicWrite(file, data) {
33
- fs.mkdirSync(path.dirname(file), { recursive: true });
34
- const tmp = `${file}.tmp-${process.pid}`;
35
- fs.writeFileSync(tmp, JSON.stringify(data, null, 2));
36
- fs.renameSync(tmp, file);
37
- }
38
-
39
- function save(dir, entries) {
40
- atomicWrite(queueFile(dir), entries);
41
- }
42
-
43
- /** Queue a memory entry that a cloud save couldn't reach right now. */
44
- function enqueue(dir, entry) {
45
- const entries = load(dir);
46
- const queued = { ...entry, queuedAt: Date.now() };
47
- entries.push(queued);
48
- save(dir, entries);
49
- return queued;
50
- }
51
-
52
- function listQueued(dir) {
53
- return load(dir);
54
- }
55
-
56
- module.exports = {
57
- queueFile,
58
- load,
59
- save,
60
- enqueue,
61
- listQueued,
62
- };
3
+ "use strict";const fs=require("node:fs"),path=require("node:path");function queueFile(e){return path.join(e,"memory-queue.json")}function load(e){try{const u=JSON.parse(fs.readFileSync(queueFile(e),"utf8"));return Array.isArray(u)?u:[]}catch{return[]}}function atomicWrite(e,u){fs.mkdirSync(path.dirname(e),{recursive:!0});const n=`${e}.tmp-${process.pid}`;fs.writeFileSync(n,JSON.stringify(u,null,2)),fs.renameSync(n,e)}function save(e,u){atomicWrite(queueFile(e),u)}function enqueue(e,u){const n=load(e),t={...u,queuedAt:Date.now()};return n.push(t),save(e,n),t}function listQueued(e){return load(e)}module.exports={queueFile:queueFile,load:load,save:save,enqueue:enqueue,listQueued:listQueued};
@@ -1,150 +1,3 @@
1
1
  // SPDX-License-Identifier: AGPL-3.0-or-later
2
2
  // Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
3
- // AEGIS Code (aegiscode) — source: https://github.com/aegisinfo/aegiscode-plugin
4
- // Conveying a modified copy, or running one as a network service, owes the
5
- // corresponding source under this licence (§5/§13) — see LICENSING.md.
6
- 'use strict';
7
-
8
- /**
9
- * persist-gate.js — the desktop half of "persisting memory for every account".
10
- *
11
- * `cli/` stores the preference in the shared non-secret store as `memoryPersist`
12
- * (`cli/src/config.js`, migrated off the legacy `cloudSync` key). Since AEGIS
13
- * ONE D5 that store is `$AEGISCODE_HOME/preferences.json` (`client/prefs.js`),
14
- * which the shell and the window both write — so this gate reads the SAME value
15
- * the Settings pane writes, and there is no second copy to disagree with.
16
- *
17
- * Two reasons the gate is not taken from the renderer:
18
- *
19
- * 1. The decision has to be enforceable in the main process whatever the
20
- * renderer believes. A renderer-held flag is a suggestion; the process
21
- * that opens the socket decides.
22
- * 2. `createSyncDispatch()` / createAutoPush() are unit-tested in plain Node,
23
- * where no renderer and no Electron exist.
24
- *
25
- * Default is ON, matching cli/. `source` keeps "the user turned this off" and
26
- * "nobody has been asked yet" tellable apart — the whole point of shipping a
27
- * default is that the absence of a stored key is not the same as a stored no.
28
- *
29
- * A pre-D5 `<userData>/settings.json` `__memoryPersist` namespace is still read
30
- * as a FALLBACK (`readSettings` below, `source: 'config'`) so a gate that runs
31
- * before adoption lands cannot read "default" over a user's explicit `false`.
32
- * It is never written: the store retires it on the first write.
33
- */
34
-
35
- const fs = require('node:fs');
36
- const path = require('node:path');
37
-
38
- const { MEMORY_PERSIST_NAMESPACE, SETTINGS_FILE } = require('../settings.js');
39
-
40
- // The shared, non-secret preference store (D5), resolved the same two ways the
41
- // other cross-host modules are: in-repo `client/*.js`, packaged `vendor/*.js`.
42
- const prefs = (() => {
43
- try {
44
- return require('../../../client/prefs.js');
45
- } catch {
46
- return require('../../vendor/prefs.js');
47
- }
48
- })();
49
-
50
- /** The settings file the store writes (`createSettingsStore` uses the same
51
- * `path.join(dir, SETTINGS_FILE)`, so both agree on one source of truth).
52
- * A caller that already holds the file path may pass it directly. */
53
- function settingsFile(dir) {
54
- const p = dir || '';
55
- return p.endsWith(SETTINGS_FILE) ? p : path.join(p, SETTINGS_FILE);
56
- }
57
-
58
- function readSettings(dir) {
59
- try {
60
- const data = JSON.parse(fs.readFileSync(settingsFile(dir), 'utf8'));
61
- return data && typeof data === 'object' ? data : {};
62
- } catch {
63
- return {};
64
- }
65
- }
66
-
67
- /**
68
- * `{ enabled, source }`, read from the SHARED store the Settings pane writes.
69
- *
70
- * `source` is 'config' only when a file actually carries an explicit value — an
71
- * explicit `false` survives, an absent preference is ON. `dir` is the legacy
72
- * settings directory (Electron's `<userData>`), consulted only when the shared
73
- * store has no opinion; `opts.prefsDir`/`opts.env` locate the shared store for
74
- * callers that hold their own seam (tests).
75
- */
76
- function gateState(dir, opts) {
77
- const o = opts || {};
78
- const shared = prefs.load({ dir: o.prefsDir, env: o.env });
79
- if (typeof shared.memoryPersist === 'boolean') {
80
- return { enabled: shared.memoryPersist, source: 'config' };
81
- }
82
- const cfg = readSettings(dir)[MEMORY_PERSIST_NAMESPACE];
83
- if (!cfg || cfg.enabled === undefined) return { enabled: true, source: 'default' };
84
- return { enabled: Boolean(cfg.enabled), source: 'config' };
85
- }
86
-
87
- /**
88
- * The post-turn push, gated.
89
- *
90
- * `push` is `createSyncDispatch`'s own drain, so this inherits the queue
91
- * fallback for free: a push flushes `memory-queue.json` before it touches the
92
- * session list, which is exactly the "offline now, sync later" behaviour the
93
- * manual button had and the automatic path must not lose.
94
- *
95
- * Coalesced: a turn that ends while a drain is still in flight does not open a
96
- * second one. `push()` snapshots `sessions.listPending(dir)`, so a concurrent
97
- * call would race the same rows; the newest session instead goes out on the
98
- * next trigger (the following turn's auto push, or "Sync now"). One turn of
99
- * delay is the correct trade against two writers marking the same session
100
- * synced.
101
- */
102
- function createAutoPush({ push, dir, gate, prefsDir, env } = {}) {
103
- if (typeof push !== 'function') throw new Error('createAutoPush requires a push()');
104
- const readGate = typeof gate === 'function' ? gate : () => gateState(dir, { prefsDir, env });
105
- let inFlight = null;
106
-
107
- async function run() {
108
- const state = readGate();
109
- if (!state.enabled) {
110
- return {
111
- ok: true,
112
- skipped: true,
113
- gate: state,
114
- reason: 'persisting memory is off',
115
- };
116
- }
117
- try {
118
- const result = await push();
119
- return Object.assign({}, result, { skipped: false, gate: state });
120
- } catch (err) {
121
- // A chat turn must never fail because a background push did. `push()`
122
- // already resolves `{ ok:false, … }` for its expected failures; this
123
- // catches the unexpected so the caller's fire-and-forget cannot become
124
- // an unhandled rejection.
125
- return {
126
- ok: false,
127
- skipped: false,
128
- gate: state,
129
- reason: (err && err.message) || String(err),
130
- };
131
- }
132
- }
133
-
134
- function auto() {
135
- if (inFlight) return inFlight;
136
- inFlight = run().finally(() => {
137
- inFlight = null;
138
- });
139
- return inFlight;
140
- }
141
-
142
- return { auto, gate: () => readGate(), state: () => readGate() };
143
- }
144
-
145
- module.exports = {
146
- settingsFile,
147
- readSettings,
148
- gateState,
149
- createAutoPush,
150
- };
3
+ "use strict";const fs=require("node:fs"),path=require("node:path"),{MEMORY_PERSIST_NAMESPACE:MEMORY_PERSIST_NAMESPACE,SETTINGS_FILE:SETTINGS_FILE}=require("../settings.js"),prefs=(()=>{try{return require("../../../client/prefs.js")}catch{return require("../../vendor/prefs.js")}})();function settingsFile(e){const t=e||"";return t.endsWith(SETTINGS_FILE)?t:path.join(t,SETTINGS_FILE)}function readSettings(e){try{const t=JSON.parse(fs.readFileSync(settingsFile(e),"utf8"));return t&&"object"==typeof t?t:{}}catch{return{}}}function gateState(e,t){const r=t||{},n=prefs.load({dir:r.prefsDir,env:r.env});if("boolean"==typeof n.memoryPersist)return{enabled:n.memoryPersist,source:"config"};const s=readSettings(e)[MEMORY_PERSIST_NAMESPACE];return s&&void 0!==s.enabled?{enabled:Boolean(s.enabled),source:"config"}:{enabled:!0,source:"default"}}function createAutoPush({push:e,dir:t,gate:r,prefsDir:n,env:s}={}){if("function"!=typeof e)throw new Error("createAutoPush requires a push()");const i="function"==typeof r?r:()=>gateState(t,{prefsDir:n,env:s});let o=null;return{auto:function(){return o||(o=async function(){const t=i();if(!t.enabled)return{ok:!0,skipped:!0,gate:t,reason:"persisting memory is off"};try{const r=await e();return Object.assign({},r,{skipped:!1,gate:t})}catch(e){return{ok:!1,skipped:!1,gate:t,reason:e&&e.message||String(e)}}}().finally((()=>{o=null})),o)},gate:()=>i(),state:()=>i()}}module.exports={settingsFile:settingsFile,readSettings:readSettings,gateState:gateState,createAutoPush:createAutoPush};
@@ -1,108 +1,3 @@
1
1
  // SPDX-License-Identifier: AGPL-3.0-or-later
2
2
  // Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
3
- // AEGIS Code (aegiscode) — source: https://github.com/aegisinfo/aegiscode-plugin
4
- // Conveying a modified copy, or running one as a network service, owes the
5
- // corresponding source under this licence (§5/§13) — see LICENSING.md.
6
- 'use strict';
7
-
8
- /**
9
- * sessions.js — the desktop's session store, now a thin binding over the
10
- * SHARED store in `client/session-store.js`.
11
- *
12
- * This file used to be the implementation. It was the desktop's private
13
- * `sessions.json`, while the terminal host kept `~/.aegiscode/history.jsonl`
14
- * and the MCP plugin could see neither — three hosts, one account, three
15
- * disjoint views of the conversation. The implementation now lives in
16
- * `client/session-store.js`, which is the tree every host already bundles,
17
- * and every call here forwards to it.
18
- *
19
- * Two things that matter are deliberately unchanged:
20
- *
21
- * * the public API and its argument order (`(dir, …)` first) — `main.js`, the
22
- * sync dispatch and `test/sync-sessions.test.mjs` call it by those names;
23
- * * the record shape — `pending`, `seq`, `updatedAt`, `remoteId`,
24
- * `lastSyncedAt`, `__seq` all keep their meaning, because cloud sync and
25
- * the renderer's session list read them.
26
- *
27
- * The only real change is *where* `dir` points: main.js now passes the shared
28
- * data dir (see `resolveStoreDir`), so a session typed in the terminal appears
29
- * in the desktop's list without a network round trip.
30
- *
31
- * Resolution mirrors main.js's own pattern for the shared client: `client/` in
32
- * a source checkout, `vendor/` in the packaged app (electron-builder cannot
33
- * reach outside the app dir, so predist.mjs stages the file).
34
- */
35
-
36
- const shared = (() => {
37
- try {
38
- return require('../../../client/session-store.js');
39
- } catch {
40
- return require('../../vendor/session-store.js');
41
- }
42
- })();
43
-
44
- const credentials = (() => {
45
- try {
46
- return require('../../../client/credentials.js');
47
- } catch {
48
- return require('../../vendor/credentials.js');
49
- }
50
- })();
51
-
52
- /**
53
- * The directory the shared store lives in: `$AEGISCODE_HOME` or `~/.aegiscode`.
54
- * `legacyDir` (Electron's userData) is only used to adopt a pre-unification
55
- * store, never to read sessions from afterwards.
56
- */
57
- function resolveStoreDir(legacyDir) {
58
- const dir = credentials.aegisHome();
59
- if (legacyDir && legacyDir !== dir) adopt(dir, legacyDir);
60
- return dir;
61
- }
62
-
63
- const {
64
- storeFile,
65
- load,
66
- save,
67
- upsertSession,
68
- appendMessage,
69
- recordExchange,
70
- listSessions,
71
- getSession,
72
- deleteSession,
73
- markSynced,
74
- markPending,
75
- listPending,
76
- mergeRemoteSessions,
77
- listSummaries,
78
- readTranscript,
79
- adopt,
80
- toMarkdown,
81
- toJson,
82
- } = shared;
83
-
84
- /** Kept under its old name — main.js and the tests call `sessionsFile`. */
85
- const sessionsFile = storeFile;
86
-
87
- module.exports = {
88
- sessionsFile,
89
- storeFile,
90
- resolveStoreDir,
91
- load,
92
- save,
93
- upsertSession,
94
- appendMessage,
95
- recordExchange,
96
- listSessions,
97
- getSession,
98
- deleteSession,
99
- markSynced,
100
- markPending,
101
- listPending,
102
- mergeRemoteSessions,
103
- listSummaries,
104
- readTranscript,
105
- adopt,
106
- toMarkdown,
107
- toJson,
108
- };
3
+ "use strict";const shared=(()=>{try{return require("../../../client/session-store.js")}catch{return require("../../vendor/session-store.js")}})(),credentials=(()=>{try{return require("../../../client/credentials.js")}catch{return require("../../vendor/credentials.js")}})();function resolveStoreDir(e){const s=credentials.aegisHome();return e&&e!==s&&adopt(s,e),s}const{storeFile:storeFile,load:load,save:save,upsertSession:upsertSession,appendMessage:appendMessage,recordExchange:recordExchange,listSessions:listSessions,getSession:getSession,deleteSession:deleteSession,markSynced:markSynced,markPending:markPending,listPending:listPending,mergeRemoteSessions:mergeRemoteSessions,listSummaries:listSummaries,readTranscript:readTranscript,adopt:adopt,toMarkdown:toMarkdown,toJson:toJson}=shared,sessionsFile=storeFile;module.exports={sessionsFile:sessionsFile,storeFile:storeFile,resolveStoreDir:resolveStoreDir,load:load,save:save,upsertSession:upsertSession,appendMessage:appendMessage,recordExchange:recordExchange,listSessions:listSessions,getSession:getSession,deleteSession:deleteSession,markSynced:markSynced,markPending:markPending,listPending:listPending,mergeRemoteSessions:mergeRemoteSessions,listSummaries:listSummaries,readTranscript:readTranscript,adopt:adopt,toMarkdown:toMarkdown,toJson:toJson};
@@ -1,68 +1,3 @@
1
1
  // SPDX-License-Identifier: AGPL-3.0-or-later
2
2
  // Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
3
- // AEGIS Code (aegiscode) — source: https://github.com/aegisinfo/aegiscode-plugin
4
- // Conveying a modified copy, or running one as a network service, owes the
5
- // corresponding source under this licence (§5/§13) — see LICENSING.md.
6
- 'use strict';
7
-
8
- /**
9
- * window-state.js — persisted BrowserWindow bounds (native desktop plumbing).
10
- * Pure Node + injectable dir, mirrors desktop/lib/sync/memory-queue.js: reads
11
- * and writes <dir>/window-state.json, no Electron import, so it unit-tests
12
- * without the Electron binary.
13
- */
14
-
15
- const fs = require('node:fs');
16
- const path = require('node:path');
17
-
18
- function stateFile(dir) {
19
- return path.join(dir, 'window-state.json');
20
- }
21
-
22
- function load(dir) {
23
- try {
24
- const data = JSON.parse(fs.readFileSync(stateFile(dir), 'utf8'));
25
- return data && typeof data === 'object' ? data : null;
26
- } catch {
27
- return null;
28
- }
29
- }
30
-
31
- function save(dir, state) {
32
- const file = stateFile(dir);
33
- fs.mkdirSync(path.dirname(file), { recursive: true });
34
- const tmp = `${file}.tmp-${process.pid}`;
35
- fs.writeFileSync(tmp, JSON.stringify(state, null, 2));
36
- fs.renameSync(tmp, file);
37
- }
38
-
39
- /**
40
- * Clamp a saved rectangle so it always intersects at least one connected
41
- * display's work area. A saved position from a monitor that has since been
42
- * unplugged, or from a resolution that shrank, would otherwise place the
43
- * window off every visible screen — it "opens" but is unreachable. `displays`
44
- * takes plain `{ workArea: {x,y,width,height} }` objects (electron.screen's
45
- * shape) so this stays pure and Electron-free for testing.
46
- */
47
- function clampToDisplay(bounds, displays, fallback) {
48
- if (!bounds || typeof bounds !== 'object') return { ...fallback };
49
- const { x, y, width, height } = bounds;
50
- if (![x, y, width, height].every((n) => Number.isFinite(n))) return { ...fallback };
51
-
52
- const w = Math.max(1, width);
53
- const h = Math.max(1, height);
54
- const list = Array.isArray(displays) ? displays : [];
55
-
56
- const visible = list.some((d) => {
57
- const wa = d && d.workArea;
58
- if (!wa) return false;
59
- return x < wa.x + wa.width && x + w > wa.x && y < wa.y + wa.height && y + h > wa.y;
60
- });
61
-
62
- if (visible) return { x, y, width: w, height: h };
63
- // Position is off every screen: keep the saved size but drop x/y so the
64
- // caller's default centering (no x/y passed to BrowserWindow) takes over.
65
- return { ...fallback, width: w, height: h };
66
- }
67
-
68
- module.exports = { stateFile, load, save, clampToDisplay };
3
+ "use strict";const fs=require("node:fs"),path=require("node:path");function stateFile(t){return path.join(t,"window-state.json")}function load(t){try{const e=JSON.parse(fs.readFileSync(stateFile(t),"utf8"));return e&&"object"==typeof e?e:null}catch{return null}}function save(t,e){const i=stateFile(t);fs.mkdirSync(path.dirname(i),{recursive:!0});const r=`${i}.tmp-${process.pid}`;fs.writeFileSync(r,JSON.stringify(e,null,2)),fs.renameSync(r,i)}function clampToDisplay(t,e,i){if(!t||"object"!=typeof t)return{...i};const{x:r,y:n,width:s,height:a}=t;if(![r,n,s,a].every((t=>Number.isFinite(t))))return{...i};const o=Math.max(1,s),c=Math.max(1,a);return(Array.isArray(e)?e:[]).some((t=>{const e=t&&t.workArea;return!!e&&r<e.x+e.width&&r+o>e.x&&n<e.y+e.height&&n+c>e.y}))?{x:r,y:n,width:o,height:c}:{...i,width:o,height:c}}module.exports={stateFile:stateFile,load:load,save:save,clampToDisplay:clampToDisplay};