aegisone 1.0.34 → 1.0.35

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 -5
  6. package/scripts/bump.mjs +1 -211
  7. package/scripts/bundle.js +1 -129
  8. package/scripts/predist.mjs +1 -976
  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 -383
  14. package/src/probes.js +1 -159
  15. package/src/release.js +1 -409
  16. package/vendor/cli/package.json +3 -7
  17. package/vendor/cli/scripts/check.mjs +1 -52
  18. package/vendor/cli/scripts/demo.mjs +1 -94
  19. package/vendor/cli/scripts/predist.mjs +1 -75
  20. package/vendor/cli/scripts/runtests.mjs +1 -56
  21. package/vendor/cli/scripts/seal-gate.mjs +1 -74
  22. package/vendor/cli/src/agents.js +1 -139
  23. package/vendor/cli/src/app.js +1 -2957
  24. package/vendor/cli/src/art.js +1 -289
  25. package/vendor/cli/src/chatflow.js +1 -3023
  26. package/vendor/cli/src/checkpoint.js +1 -90
  27. package/vendor/cli/src/clipboard.js +1 -424
  28. package/vendor/cli/src/cloudsync.js +1 -528
  29. package/vendor/cli/src/commands.js +1 -4089
  30. package/vendor/cli/src/config.js +1 -581
  31. package/vendor/cli/src/connect.js +1 -349
  32. package/vendor/cli/src/credentials.js +1 -33
  33. package/vendor/cli/src/deps.js +1 -232
  34. package/vendor/cli/src/devrun.js +1 -187
  35. package/vendor/cli/src/diff.js +1 -333
  36. package/vendor/cli/src/diffview.js +1 -296
  37. package/vendor/cli/src/engine.js +1 -297
  38. package/vendor/cli/src/entitlement.js +1 -355
  39. package/vendor/cli/src/events.js +1 -707
  40. package/vendor/cli/src/export.js +1 -67
  41. package/vendor/cli/src/filepreview.js +1 -153
  42. package/vendor/cli/src/fingerprint.js +1 -592
  43. package/vendor/cli/src/format.js +1 -259
  44. package/vendor/cli/src/fuzzy.js +1 -119
  45. package/vendor/cli/src/history.js +1 -423
  46. package/vendor/cli/src/init.js +1 -175
  47. package/vendor/cli/src/input.js +1 -139
  48. package/vendor/cli/src/keys.js +1 -183
  49. package/vendor/cli/src/markdown.js +1 -306
  50. package/vendor/cli/src/models.js +1 -507
  51. package/vendor/cli/src/naming.js +1 -57
  52. package/vendor/cli/src/overlays.js +1 -462
  53. package/vendor/cli/src/panels.js +1 -1418
  54. package/vendor/cli/src/ping.js +1 -226
  55. package/vendor/cli/src/presence.js +1 -238
  56. package/vendor/cli/src/render.js +1 -516
  57. package/vendor/cli/src/screen.js +1 -518
  58. package/vendor/cli/src/screens.js +1 -896
  59. package/vendor/cli/src/secret.js +1 -59
  60. package/vendor/cli/src/securefs.js +1 -359
  61. package/vendor/cli/src/settings.js +1 -155
  62. package/vendor/cli/src/shared.js +1 -52
  63. package/vendor/cli/src/sharedpaths.js +1 -53
  64. package/vendor/cli/src/signup.js +1 -156
  65. package/vendor/cli/src/summarize.js +1 -95
  66. package/vendor/cli/src/sysdiag.js +1 -585
  67. package/vendor/cli/src/system.js +1 -40
  68. package/vendor/cli/src/theme.js +1 -570
  69. package/vendor/cli/src/title.js +1 -220
  70. package/vendor/cli/src/todos.js +1 -115
  71. package/vendor/cli/src/tokens.js +1 -263
  72. package/vendor/cli/src/topup.js +1 -210
  73. package/vendor/cli/src/update.js +1 -191
  74. package/vendor/cli/vendor/client/aegis.js +1 -2441
  75. package/vendor/cli/vendor/client/attest.js +1 -518
  76. package/vendor/cli/vendor/client/authorship-key.js +1 -410
  77. package/vendor/cli/vendor/client/auto-provision.js +1 -134
  78. package/vendor/cli/vendor/client/brain-catalog.js +1 -268
  79. package/vendor/cli/vendor/client/byok-catalog.js +1 -199
  80. package/vendor/cli/vendor/client/catalog-client.js +1 -487
  81. package/vendor/cli/vendor/client/conversation-export.js +1 -177
  82. package/vendor/cli/vendor/client/credentials.js +1 -494
  83. package/vendor/cli/vendor/client/device-fingerprint.js +1 -141
  84. package/vendor/cli/vendor/client/drive-connect.js +1 -110
  85. package/vendor/cli/vendor/client/drive-upload.js +1 -234
  86. package/vendor/cli/vendor/client/env-file.js +1 -1273
  87. package/vendor/cli/vendor/client/fingerprint.js +1 -1064
  88. package/vendor/cli/vendor/client/foreign-memory.js +1 -669
  89. package/vendor/cli/vendor/client/google-signin.js +1 -133
  90. package/vendor/cli/vendor/client/hooks.js +1 -430
  91. package/vendor/cli/vendor/client/model-discovery.js +1 -373
  92. package/vendor/cli/vendor/client/naming.js +1 -283
  93. package/vendor/cli/vendor/client/platform.js +1 -937
  94. package/vendor/cli/vendor/client/prefs.js +1 -351
  95. package/vendor/cli/vendor/client/presence-constants.js +1 -107
  96. package/vendor/cli/vendor/client/presence.js +1 -438
  97. package/vendor/cli/vendor/client/record-vault.js +3 -1055
  98. package/vendor/cli/vendor/client/session-store.js +1 -575
  99. package/vendor/cli/vendor/client/topup.js +1 -297
  100. package/vendor/cli/vendor/client/touch.js +1 -458
  101. package/vendor/cli/vendor/client/update.js +1 -763
  102. package/vendor/cli/vendor/client/user-models.js +1 -381
  103. package/vendor/cli/vendor/desktop/lib/local/agents.js +1 -105
  104. package/vendor/cli/vendor/desktop/lib/local/attachments.js +1 -276
  105. package/vendor/cli/vendor/desktop/lib/local/autonomous.js +1 -1045
  106. package/vendor/cli/vendor/desktop/lib/local/claude-pro.js +1 -1028
  107. package/vendor/cli/vendor/desktop/lib/local/context.js +1 -125
  108. package/vendor/cli/vendor/desktop/lib/local/engine.js +1 -3666
  109. package/vendor/cli/vendor/desktop/lib/local/entitlement.js +1 -660
  110. package/vendor/cli/vendor/desktop/lib/local/git-scope.js +1 -228
  111. package/vendor/cli/vendor/desktop/lib/local/local.js +1 -2145
  112. package/vendor/cli/vendor/desktop/lib/local/prompt.js +1 -280
  113. package/vendor/cli/vendor/desktop/lib/local/queue.js +1 -560
  114. package/vendor/cli/vendor/desktop/lib/local/session-rounds.js +1 -238
  115. package/vendor/cli/vendor/desktop/lib/local/spill.js +1 -75
  116. package/vendor/cli/vendor/desktop/lib/local/turn-guard.js +1 -300
  117. package/vendor/cli/vendor/desktop/lib/local/worktree-lock.js +1 -235
  118. package/vendor/cli/vendor/desktop/lib/settings.js +1 -890
  119. package/vendor/cli/vendor/desktop/renderer/usage.js +1 -1239
  120. package/vendor/cli/vendor/hosts/install.js +1 -638
  121. package/vendor/cli/vendor/hosts/openai-shim.js +1 -515
  122. package/vendor/cli/vendor/hosts/spec.js +1 -164
  123. package/vendor/cli/vendor/hosts/targets.js +1 -346
  124. package/vendor/cli/vendor/mcp/server.js +1 -221
  125. package/vendor/cli/vendor/mcp/tools.js +1 -408
  126. package/vendor/cli/vendor/one/src/child.js +1 -285
  127. package/vendor/cli/vendor/one/src/permissions.js +1 -383
  128. package/vendor/desktop/bin/aegis.js +1 -32
  129. package/vendor/desktop/lib/account-key.js +1 -56
  130. package/vendor/desktop/lib/auto.js +1 -461
  131. package/vendor/desktop/lib/avatar/companion.js +1 -698
  132. package/vendor/desktop/lib/avatar/cosmetics.js +1 -532
  133. package/vendor/desktop/lib/avatar/events.js +1 -344
  134. package/vendor/desktop/lib/avatar/holder-turn.js +1 -350
  135. package/vendor/desktop/lib/avatar/holders.js +1 -612
  136. package/vendor/desktop/lib/avatar/identity.js +1 -641
  137. package/vendor/desktop/lib/avatar/level.js +1 -368
  138. package/vendor/desktop/lib/avatar/mirror.js +1 -524
  139. package/vendor/desktop/lib/avatar/persona.js +1 -388
  140. package/vendor/desktop/lib/avatar/profile.js +1 -977
  141. package/vendor/desktop/lib/avatar/register.js +1 -307
  142. package/vendor/desktop/lib/avatar/store.js +1 -472
  143. package/vendor/desktop/lib/avatar/tiers.js +1 -38
  144. package/vendor/desktop/lib/avatar/transfer.js +1 -415
  145. package/vendor/desktop/lib/avatar/turn.js +1 -216
  146. package/vendor/desktop/lib/avatar/voice.js +1 -328
  147. package/vendor/desktop/lib/avatar/xp.js +1 -404
  148. package/vendor/desktop/lib/deep-link.js +1 -120
  149. package/vendor/desktop/lib/fingerprint.js +2 -347
  150. package/vendor/desktop/lib/google-connect.js +1 -323
  151. package/vendor/desktop/lib/local/agents.js +1 -105
  152. package/vendor/desktop/lib/local/attachments.js +1 -276
  153. package/vendor/desktop/lib/local/autonomous.js +1 -1045
  154. package/vendor/desktop/lib/local/claude-pro.js +1 -1028
  155. package/vendor/desktop/lib/local/context.js +1 -125
  156. package/vendor/desktop/lib/local/engine.js +1 -3666
  157. package/vendor/desktop/lib/local/entitlement.js +1 -660
  158. package/vendor/desktop/lib/local/git-scope.js +1 -228
  159. package/vendor/desktop/lib/local/local.js +1 -2145
  160. package/vendor/desktop/lib/local/prompt.js +1 -280
  161. package/vendor/desktop/lib/local/queue.js +1 -560
  162. package/vendor/desktop/lib/local/session-rounds.js +1 -238
  163. package/vendor/desktop/lib/local/spill.js +1 -75
  164. package/vendor/desktop/lib/local/telemetry.js +1 -470
  165. package/vendor/desktop/lib/local/turn-guard.js +1 -300
  166. package/vendor/desktop/lib/local/worktree-lock.js +1 -235
  167. package/vendor/desktop/lib/provider-key-mirror.js +1 -252
  168. package/vendor/desktop/lib/quick-launcher.js +1 -84
  169. package/vendor/desktop/lib/settings.js +1 -890
  170. package/vendor/desktop/lib/sync/memory-queue.js +1 -60
  171. package/vendor/desktop/lib/sync/persist-gate.js +1 -148
  172. package/vendor/desktop/lib/sync/sessions.js +1 -106
  173. package/vendor/desktop/lib/window-state.js +1 -66
  174. package/vendor/desktop/package.json +2 -4
  175. package/vendor/desktop/preload.js +1 -679
  176. package/vendor/desktop/renderer/app.js +1 -7250
  177. package/vendor/desktop/renderer/avatar/assemble.js +1 -335
  178. package/vendor/desktop/renderer/avatar/avatar.js +1 -380
  179. package/vendor/desktop/renderer/avatar/cards.js +1 -141
  180. package/vendor/desktop/renderer/avatar/hud.js +1 -206
  181. package/vendor/desktop/renderer/avatar/machine.js +1 -213
  182. package/vendor/desktop/renderer/avatar/pane.js +1 -439
  183. package/vendor/desktop/renderer/avatar/parts.js +1 -437
  184. package/vendor/desktop/renderer/budget.js +1 -172
  185. package/vendor/desktop/renderer/companion.js +1 -223
  186. package/vendor/desktop/renderer/diff.js +1 -359
  187. package/vendor/desktop/renderer/diffview.js +1 -336
  188. package/vendor/desktop/renderer/filepreview.js +1 -211
  189. package/vendor/desktop/renderer/fingerprint.js +3 -789
  190. package/vendor/desktop/renderer/markdown.js +1 -168
  191. package/vendor/desktop/renderer/provider-mark.js +1 -311
  192. package/vendor/desktop/renderer/provider-toolbar.js +1 -134
  193. package/vendor/desktop/renderer/providers.js +1 -259
  194. package/vendor/desktop/renderer/quick.js +1 -285
  195. package/vendor/desktop/renderer/stream-policy.js +1 -387
  196. package/vendor/desktop/renderer/transcript-view.js +1 -323
  197. package/vendor/desktop/renderer/usage.js +1 -1239
  198. package/vendor/desktop/vendor/aegis.js +1 -2441
  199. package/vendor/desktop/vendor/attest.js +1 -518
  200. package/vendor/desktop/vendor/authorship-key.js +1 -410
  201. package/vendor/desktop/vendor/auto-provision.js +1 -134
  202. package/vendor/desktop/vendor/brain-catalog.js +1 -268
  203. package/vendor/desktop/vendor/byok-catalog.js +1 -199
  204. package/vendor/desktop/vendor/catalog-client.js +1 -487
  205. package/vendor/desktop/vendor/conversation-export.js +1 -177
  206. package/vendor/desktop/vendor/credentials.js +1 -494
  207. package/vendor/desktop/vendor/device-fingerprint.js +1 -141
  208. package/vendor/desktop/vendor/drive-connect.js +1 -110
  209. package/vendor/desktop/vendor/drive-upload.js +1 -234
  210. package/vendor/desktop/vendor/env-file.js +1 -1273
  211. package/vendor/desktop/vendor/fingerprint.js +1 -1064
  212. package/vendor/desktop/vendor/foreign-memory.js +1 -669
  213. package/vendor/desktop/vendor/google-signin.js +1 -133
  214. package/vendor/desktop/vendor/hooks.js +1 -430
  215. package/vendor/desktop/vendor/model-discovery.js +1 -373
  216. package/vendor/desktop/vendor/naming.js +1 -283
  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 -575
  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 -763
  226. package/vendor/desktop/vendor/user-models.js +1 -381
@@ -1,61 +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
- * Read a secret from the terminal without echoing it.
10
- *
11
- * Extracted from app.js so the non-interactive entry point can use the same
12
- * prompt as the in-session commands: `aegiscode login` asks for the account key
13
- * on the same terms `/key` does, and a second copy of this loop would be a
14
- * second place for a key to end up echoed to the screen or in a shell history.
15
- *
16
- * Raw mode when the stream supports it; a stream that cannot mask (no TTY, no
17
- * setRawMode) resolves to '' rather than silently reading an echoed secret —
18
- * every caller treats '' as "nothing given" and says so.
19
- */
20
-
21
- const MASK = '\u2022'; // •
22
-
23
- function readSecret(promptText, o = {}) {
24
- const stdin = o.stdin || process.stdin;
25
- const stdout = o.stdout || process.stdout;
26
- const canMask = !!stdin.isTTY && typeof stdin.setRawMode === 'function';
27
- if (!canMask) return Promise.resolve('');
28
- return new Promise((resolve) => {
29
- stdout.write(promptText);
30
- let buf = '';
31
- const done = (value) => {
32
- try {
33
- stdin.setRawMode(false);
34
- } catch {}
35
- stdin.removeListener('data', onData);
36
- stdout.write('\n');
37
- resolve(value);
38
- };
39
- const onData = (chunk) => {
40
- // Drop terminal escape sequences whole: skipping only the ESC leaves the
41
- // CSI tail ([A, [3~, …) to be appended to the key.
42
- const text = String(chunk).replace(/\x1b\[[0-9;?]*[A-Za-z~]/g, '').replace(/\x1b./g, '');
43
- for (const ch of text) {
44
- if (ch === '\r' || ch === '\n') return done(buf);
45
- if (ch === '\x03' || ch === '\x04') return done(''); // ctrl+c / ctrl+d
46
- if (ch === '\u007f' || ch === '\b') {
47
- buf = buf.slice(0, -1);
48
- stdout.write('\b \b');
49
- continue;
50
- }
51
- buf += ch;
52
- stdout.write(MASK);
53
- }
54
- };
55
- stdin.setRawMode(true);
56
- stdin.resume();
57
- stdin.on('data', onData);
58
- });
59
- }
60
-
61
- module.exports = { readSecret, MASK };
3
+ "use strict";const MASK="•";function readSecret(e,t={}){const r=t.stdin||process.stdin,s=t.stdout||process.stdout;return r.isTTY&&"function"==typeof r.setRawMode?new Promise((t=>{s.write(e);let o="";const n=e=>{try{r.setRawMode(!1)}catch{}r.removeListener("data",c),s.write("\n"),t(e)},c=e=>{const t=String(e).replace(/\x1b\[[0-9;?]*[A-Za-z~]/g,"").replace(/\x1b./g,"");for(const e of t){if("\r"===e||"\n"===e)return n(o);if(""===e||""===e)return n("");""!==e&&"\b"!==e?(o+=e,s.write("•")):(o=o.slice(0,-1),s.write("\b \b"))}};r.setRawMode(!0),r.resume(),r.on("data",c)})):Promise.resolve("")}module.exports={readSecret:readSecret,MASK:"•"};
@@ -1,361 +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
- * Private files in the data dir (~/.aegiscode) — hardening against a local
10
- * info-stealer, which is the threat the CLI's own store actually invites.
11
- *
12
- * What was wrong: every writer in this CLI used `fs.writeFileSync(p, data)`
13
- * with no `mode`, and `fs.mkdirSync(dir, { recursive: true })` with no `mode`.
14
- * Both therefore inherited the process umask, which on a default desktop Linux
15
- * is 0002 — so the data dir landed at 0775 and every file in it at 0664. On a
16
- * single-user box that looks harmless. It is not:
17
- *
18
- * - 0664 is world-READABLE. history.jsonl is every prompt and every reply the
19
- * user has ever sent, checkpoints/ is the same in full, and clipboard.txt is
20
- * verbatim whatever the user last marked and copied. Any other local account
21
- * — or any process running as one — reads all of it with plain `cat`.
22
- * - 0664 is group-WRITABLE, and so was the 0775 directory. config.json holds
23
- * `provider` and `baseURL`, so a second account in the group could repoint
24
- * the CLI's endpoint at a host it controls and collect the prompts, the
25
- * completions, and the credentials relayed through it. A writable data dir
26
- * also lets anyone drop a `permissions.json` that pre-approves the tools
27
- * they want the next session to run unprompted.
28
- *
29
- * Two properties matter beyond the mode bits:
30
- *
31
- * - `O_NOFOLLOW` on create. `writeFileSync` follows symlinks, so a symlink
32
- * planted at `~/.aegiscode/clipboard.txt` pointing at `~/.bashrc` turned a
33
- * copy gesture into an arbitrary file overwrite. Creating with
34
- * `O_CREAT|O_EXCL|O_NOFOLLOW` — after unlinking any leftover — fails instead
35
- * of following, and `O_EXCL` closes the window between the unlink and the
36
- * open: a symlink raced into place makes the open fail with EEXIST rather
37
- * than being followed.
38
- * - `rename`, not truncate, for the atomic path. `renameSync` replaces a
39
- * planted symlink instead of writing through it, so the atomic writers
40
- * (config, permissions) are safe even without the O_EXCL dance.
41
- *
42
- * Ownership is checked before every chmod and never chmod'ed through a symlink,
43
- * so a data dir that is deliberately shared (or root-owned) is left alone rather
44
- * than having its permissions silently rewritten by us. Every helper is
45
- * best-effort in the same spirit as the rest of this CLI: a hardening step that
46
- * cannot be applied must not be the reason a session cannot save.
47
- *
48
- * Deliberately dependency-free — no `shared.js`, no engine — so it can be
49
- * required from anything without a cycle, and unit-tested in isolation.
50
- */
51
-
52
- const fs = require('node:fs');
53
- const path = require('node:path');
54
-
55
- // O_NOFOLLOW is POSIX; on Windows the constant is absent, leaving the mode and
56
- // rename protections (which do not depend on it) in place.
57
- const NOFOLLOW = fs.constants.O_NOFOLLOW || 0;
58
-
59
- /**
60
- * Do `fs.stat().mode` permission bits mean anything on this host?
61
- *
62
- * Windows: no. libuv has no NTFS ACL to report, so it synthesises the mode from
63
- * the read-only attribute and returns 0o666 for every writable file and
64
- * directory. `exposedBits()` below is therefore ALWAYS true there, which made
65
- * `/doctor` report the entire data directory as group/world-accessible and
66
- * `/doctor fix` report it as still exposed after "repairing" it — a permanent
67
- * false alarm with no action that could clear it. The boundary on Windows is the
68
- * profile directory's ACL (see client/authorship-key.js, which has always
69
- * skipped its own mode assert there).
70
- *
71
- * Duplicated from client/platform.js `hasPosixModes()` rather than imported
72
- * because this module is deliberately dependency-free (see the header) so it can
73
- * be required from anything without a cycle. Injectable, so both branches are
74
- * exercised on one host.
75
- */
76
- function hasPosixModes(platform = process.platform) {
77
- return platform !== 'win32';
78
- }
79
-
80
- /** True when `st` is owned by the current user (always true where getuid is absent). */
81
- function ownedByUs(st) {
82
- if (typeof process.getuid !== 'function') return true;
83
- try { return st.uid === process.getuid(); } catch { return false; }
84
- }
85
-
86
- /**
87
- * Force `p` to `mode`, but only when it is a real file we own.
88
- * Never follows a symlink (chmod through a link would modify its target) and
89
- * never returns false for a file that is already correct.
90
- */
91
- function chmodPrivate(p, mode = 0o600) {
92
- try {
93
- const st = fs.lstatSync(p);
94
- if (st.isSymbolicLink()) return false;
95
- if (!ownedByUs(st)) return false;
96
- if ((st.mode & 0o777) === mode) return true;
97
- fs.chmodSync(p, mode);
98
- return true;
99
- } catch {
100
- return false;
101
- }
102
- }
103
-
104
- /**
105
- * `mkdir -p` at 0700, and tighten a directory that already exists.
106
- * `mkdirSync` ignores `mode` for a directory that is already there, so an
107
- * install that predates this module keeps its 0775 without the explicit chmod.
108
- */
109
- function ensurePrivateDir(dir) {
110
- try {
111
- fs.mkdirSync(dir, { recursive: true, mode: 0o700 });
112
- } catch {
113
- return false;
114
- }
115
- try {
116
- const st = fs.lstatSync(dir);
117
- if (st.isSymbolicLink() || !st.isDirectory()) return false;
118
- // Guarded on hasPosixModes: on Windows the test is always true, so this
119
- // chmod'ed the data directory on literally every write and never changed it.
120
- if (hasPosixModes() && ownedByUs(st) && (st.mode & 0o077) !== 0) fs.chmodSync(dir, 0o700);
121
- return true;
122
- } catch {
123
- return false;
124
- }
125
- }
126
-
127
- /**
128
- * Write `data` to `file` with mode 0600, creating the parent dir at 0700.
129
- *
130
- * atomic (default) writes `file.tmp` and renames over the target, so a crash
131
- * cannot truncate a live config and a planted symlink is replaced rather than
132
- * followed. `{ atomic: false }` truncates in place instead, which is the right
133
- * shape for a scratch file that is never read concurrently — it still refuses
134
- * to follow a symlink at `file`.
135
- *
136
- * Throws on failure; callers already treat a failed save as non-fatal.
137
- */
138
- function writePrivateFile(file, data, opts = {}) {
139
- const dir = path.dirname(file);
140
- ensurePrivateDir(dir);
141
-
142
- const common = fs.constants.O_WRONLY | fs.constants.O_CREAT | fs.constants.O_EXCL | NOFOLLOW;
143
-
144
- if (opts.atomic === false) {
145
- try { fs.unlinkSync(file); } catch {} // drop a leftover or a planted symlink
146
- const fd = fs.openSync(file, common, 0o600);
147
- try {
148
- fs.fchmodSync(fd, 0o600);
149
- fs.writeFileSync(fd, data);
150
- } finally {
151
- fs.closeSync(fd);
152
- }
153
- return true;
154
- }
155
-
156
- const tmp = file + '.tmp';
157
- try { fs.unlinkSync(tmp); } catch {}
158
- const fd = fs.openSync(tmp, common, 0o600);
159
- try {
160
- fs.fchmodSync(fd, 0o600);
161
- fs.writeFileSync(fd, data);
162
- } finally {
163
- fs.closeSync(fd);
164
- }
165
- fs.renameSync(tmp, file); // replaces a planted symlink instead of writing through it
166
- chmodPrivate(file, 0o600);
167
- return true;
168
- }
169
-
170
- /**
171
- * ---------------------------------------------------------------------------
172
- * Retroactive repair.
173
- * ---------------------------------------------------------------------------
174
- *
175
- * `writePrivateFile` hardens a path only at the moment it is written, so an
176
- * install that predates this module keeps its 0664/0775 indefinitely: each
177
- * writer fixes a file the next time that file happens to change, and nothing
178
- * ever revisits the rest. On the real store that left `~/.aegiscode` at 0775
179
- * with config.json, permissions.json, history.jsonl, clipboard.txt and every
180
- * file under checkpoints/ and indexes/ at 0664 — months of transcripts, plus a
181
- * group-writable endpoint — readable by any other local account.
182
- *
183
- * `repairExposure` walks the data dir once and forces it private. Three details
184
- * are load-bearing rather than incidental:
185
- *
186
- * - The exec bit is PRESERVED, not stripped. This directory is not purely
187
- * data: `oauth-proxy.js` (0775) and `bin/aegis-cli` (0755) are run from
188
- * here, so the obvious implementation — a blanket `chmod 0600` — would
189
- * silently break both. The rule is therefore mode-relative: a directory, or
190
- * a file the owner may execute, becomes 0700; anything else becomes 0600.
191
- * Nothing loses a permission it needed; everything loses the ones it did
192
- * not.
193
- * - Symlinks are never entered and never chmod'ed through, for the same reason
194
- * `chmodPrivate` refuses them: a planted link would otherwise make the
195
- * repair itself the write primitive.
196
- * - The root directory is the high-value step. At 0700 no other account can
197
- * traverse into it at all, which covers every file inside — including the
198
- * executables above whose own modes stay permissive. The per-file pass is
199
- * defence in depth for the case where the directory is later re-shared,
200
- * restored from a backup, or a file is copied out of it.
201
- *
202
- * The read-only (`auditExposure`) and writing (`repairExposure`) entry points
203
- * are deliberately separate so `/doctor` can report exposure without changing
204
- * anything, and only act on an explicit `/doctor fix`.
205
- */
206
-
207
- /** Longest path (below the data dir) the repair walk will descend. */
208
- const MAX_WALK_DEPTH = 4;
209
-
210
- /** `0775`-style rendering of the permission bits of a `stat`. */
211
- function fmtMode(mode) {
212
- return '0' + (mode & 0o777).toString(8).padStart(3, '0');
213
- }
214
-
215
- /**
216
- * The mode a path should hold: 0700 when the owner needs to traverse or execute
217
- * it (a directory, or a file carrying an owner-exec bit), 0600 otherwise.
218
- */
219
- function targetMode(st) {
220
- if (st.isDirectory()) return 0o700;
221
- return st.mode & 0o100 ? 0o700 : 0o600;
222
- }
223
-
224
- /**
225
- * Every non-symlink entry under `root`, depth-first, with its lstat.
226
- * Unreadable directories are skipped rather than thrown on: a repair that
227
- * cannot see a subtree must still fix the rest of it.
228
- */
229
- function scanTree(root) {
230
- const out = [];
231
- const walk = (dir, rel, depth) => {
232
- if (depth > MAX_WALK_DEPTH) return;
233
- let entries;
234
- try {
235
- entries = fs.readdirSync(dir, { withFileTypes: true });
236
- } catch {
237
- return;
238
- }
239
- for (const e of entries) {
240
- if (e.isSymbolicLink()) continue; // never followed, never chmod'ed through
241
- const full = path.join(dir, e.name);
242
- const childRel = rel ? `${rel}/${e.name}` : e.name;
243
- let st;
244
- try {
245
- st = fs.lstatSync(full);
246
- } catch {
247
- continue;
248
- }
249
- out.push({ rel: childRel, full, st });
250
- if (st.isDirectory()) walk(full, childRel, depth + 1);
251
- }
252
- };
253
- walk(root, '', 0);
254
- return out;
255
- }
256
-
257
- /** Does `mode` grant anything to group or other? */
258
- function exposedBits(mode) {
259
- return (mode & 0o077) !== 0;
260
- }
261
-
262
- /**
263
- * Report every path in the data dir that is reachable by group or other.
264
- *
265
- * Read-only. Returns `{ root, exists, rootMode, exposed, total }` where each
266
- * entry of `exposed` is `{ rel, mode, kind }` — `rel` is `.` for the root
267
- * itself, and `kind` is `'dir'` or `'file'`.
268
- */
269
- function auditExposure(root, options = {}) {
270
- const platform = options.platform || process.platform;
271
- const modesMeaningful = hasPosixModes(platform);
272
- const report = { root, exists: false, rootMode: null, exposed: [], total: 0, modesMeaningful };
273
- let rst;
274
- try {
275
- rst = fs.lstatSync(root);
276
- } catch {
277
- return report;
278
- }
279
- if (rst.isSymbolicLink() || !rst.isDirectory()) return report;
280
- report.exists = true;
281
- report.rootMode = fmtMode(rst.mode);
282
- // Where the mode is synthesised there is nothing to audit: every path would be
283
- // listed, none of it true. `modesMeaningful: false` is the honest answer and
284
- // the caller renders it as "not applicable", never as "all clear".
285
- if (!modesMeaningful) {
286
- report.total = scanTree(root).length;
287
- return report;
288
- }
289
- if (exposedBits(rst.mode)) report.exposed.push({ rel: '.', mode: report.rootMode, kind: 'dir' });
290
-
291
- const items = scanTree(root);
292
- report.total = items.length;
293
- for (const it of items) {
294
- if (!exposedBits(it.st.mode)) continue;
295
- report.exposed.push({
296
- rel: it.rel,
297
- mode: fmtMode(it.st.mode),
298
- kind: it.st.isDirectory() ? 'dir' : 'file',
299
- });
300
- }
301
- return report;
302
- }
303
-
304
- /**
305
- * Force every group/world-accessible path in the data dir back to 0700/0600,
306
- * preserving the owner-exec bit (see the block comment above).
307
- *
308
- * Best-effort and idempotent: a path that is already private is left untouched,
309
- * a path we do not own is reported rather than fought over, and a second run
310
- * fixes nothing. Returns `{ root, exists, fixed, failed, remaining }`, where
311
- * `remaining` is the exposure audit taken after the pass — non-empty only when
312
- * something could not be repaired.
313
- */
314
- function repairExposure(root, options = {}) {
315
- const platform = options.platform || process.platform;
316
- const modesMeaningful = hasPosixModes(platform);
317
- const report = { root, exists: false, fixed: [], failed: [], remaining: [], modesMeaningful };
318
- let rst;
319
- try {
320
- rst = fs.lstatSync(root);
321
- } catch {
322
- return report;
323
- }
324
- if (rst.isSymbolicLink() || !rst.isDirectory()) return report;
325
- report.exists = true;
326
- // A chmod here cannot change what stat reports, so the old code "fixed" every
327
- // path and then re-audited it as still exposed, forever. Report a clean no-op.
328
- if (!modesMeaningful) return report;
329
-
330
- const tighten = (full, st, rel) => {
331
- if (!ownedByUs(st)) {
332
- report.failed.push({ rel, reason: 'not owned by this user' });
333
- return;
334
- }
335
- const want = targetMode(st);
336
- try {
337
- fs.chmodSync(full, want);
338
- report.fixed.push({ rel, from: fmtMode(st.mode), to: fmtMode(want) });
339
- } catch (err) {
340
- report.failed.push({ rel, reason: err.code || String(err) });
341
- }
342
- };
343
-
344
- if (exposedBits(rst.mode)) tighten(root, rst, '.');
345
- for (const it of scanTree(root)) {
346
- if (!exposedBits(it.st.mode)) continue;
347
- tighten(it.full, it.st, it.rel);
348
- }
349
-
350
- report.remaining = auditExposure(root, { platform }).exposed;
351
- return report;
352
- }
353
-
354
- module.exports = {
355
- ensurePrivateDir,
356
- writePrivateFile,
357
- chmodPrivate,
358
- auditExposure,
359
- repairExposure,
360
- fmtMode,
361
- };
3
+ "use strict";const fs=require("node:fs"),path=require("node:path"),NOFOLLOW=fs.constants.O_NOFOLLOW||0;function hasPosixModes(e=process.platform){return"win32"!==e}function ownedByUs(e){if("function"!=typeof process.getuid)return!0;try{return e.uid===process.getuid()}catch{return!1}}function chmodPrivate(e,t=384){try{const r=fs.lstatSync(e);return!r.isSymbolicLink()&&!!ownedByUs(r)&&((511&r.mode)===t||fs.chmodSync(e,t),!0)}catch{return!1}}function ensurePrivateDir(e){try{fs.mkdirSync(e,{recursive:!0,mode:448})}catch{return!1}try{const t=fs.lstatSync(e);return!(t.isSymbolicLink()||!t.isDirectory()||(hasPosixModes()&&ownedByUs(t)&&0!=(63&t.mode)&&fs.chmodSync(e,448),0))}catch{return!1}}function writePrivateFile(e,t,r={}){ensurePrivateDir(path.dirname(e));const o=fs.constants.O_WRONLY|fs.constants.O_CREAT|fs.constants.O_EXCL|NOFOLLOW;if(!1===r.atomic){try{fs.unlinkSync(e)}catch{}const r=fs.openSync(e,o,384);try{fs.fchmodSync(r,384),fs.writeFileSync(r,t)}finally{fs.closeSync(r)}return!0}const s=e+".tmp";try{fs.unlinkSync(s)}catch{}const n=fs.openSync(s,o,384);try{fs.fchmodSync(n,384),fs.writeFileSync(n,t)}finally{fs.closeSync(n)}return fs.renameSync(s,e),chmodPrivate(e,384),!0}const MAX_WALK_DEPTH=4;function fmtMode(e){return"0"+(511&e).toString(8).padStart(3,"0")}function targetMode(e){return e.isDirectory()||64&e.mode?448:384}function scanTree(e){const t=[],r=(e,o,s)=>{if(s>MAX_WALK_DEPTH)return;let n;try{n=fs.readdirSync(e,{withFileTypes:!0})}catch{return}for(const i of n){if(i.isSymbolicLink())continue;const n=path.join(e,i.name),c=o?`${o}/${i.name}`:i.name;let f;try{f=fs.lstatSync(n)}catch{continue}t.push({rel:c,full:n,st:f}),f.isDirectory()&&r(n,c,s+1)}};return r(e,"",0),t}function exposedBits(e){return 0!=(63&e)}function auditExposure(e,t={}){const r=hasPosixModes(t.platform||process.platform),o={root:e,exists:!1,rootMode:null,exposed:[],total:0,modesMeaningful:r};let s;try{s=fs.lstatSync(e)}catch{return o}if(s.isSymbolicLink()||!s.isDirectory())return o;if(o.exists=!0,o.rootMode=fmtMode(s.mode),!r)return o.total=scanTree(e).length,o;exposedBits(s.mode)&&o.exposed.push({rel:".",mode:o.rootMode,kind:"dir"});const n=scanTree(e);o.total=n.length;for(const e of n)exposedBits(e.st.mode)&&o.exposed.push({rel:e.rel,mode:fmtMode(e.st.mode),kind:e.st.isDirectory()?"dir":"file"});return o}function repairExposure(e,t={}){const r=t.platform||process.platform,o=hasPosixModes(r),s={root:e,exists:!1,fixed:[],failed:[],remaining:[],modesMeaningful:o};let n;try{n=fs.lstatSync(e)}catch{return s}if(n.isSymbolicLink()||!n.isDirectory())return s;if(s.exists=!0,!o)return s;const i=(e,t,r)=>{if(!ownedByUs(t))return void s.failed.push({rel:r,reason:"not owned by this user"});const o=targetMode(t);try{fs.chmodSync(e,o),s.fixed.push({rel:r,from:fmtMode(t.mode),to:fmtMode(o)})}catch(e){s.failed.push({rel:r,reason:e.code||String(e)})}};exposedBits(n.mode)&&i(e,n,".");for(const t of scanTree(e))exposedBits(t.st.mode)&&i(t.full,t.st,t.rel);return s.remaining=auditExposure(e,{platform:r}).exposed,s}module.exports={ensurePrivateDir:ensurePrivateDir,writePrivateFile:writePrivateFile,chmodPrivate:chmodPrivate,auditExposure:auditExposure,repairExposure:repairExposure,fmtMode:fmtMode};
@@ -1,157 +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
- * /config — read and write every setting from the prompt, over the split store.
10
- *
11
- * The upstream engine's version of this (`src/session.js`, `parseConfigValue` /
12
- * `configRows` / `setConfigValue`) sits on a single config file, so it can list
13
- * `Object.keys(cfg)` and write whatever it is given. This host cannot: since
14
- * AEGISONE D5, `cli/src/config.js` keeps host-local keys in `config.json` and
15
- * *preferences* in the shared `preferences.json` the desktop's settings window
16
- * writes too (`SHARED_PREF_KEYS`, mirrored in `client/prefs.js`). A `/config`
17
- * that showed one flat list and wrote it back blind would reintroduce exactly
18
- * the drift ON8/D8 rule 1 just closed — two stores holding two answers to one
19
- * question. So the two things this module adds over the port:
20
- *
21
- * 1. Every row says which store holds the key, and the write goes through
22
- * `updateConfig()`, which routes each key to the store that owns it. There
23
- * is no path here that writes a file directly.
24
- * 2. Values are SUMMARIZED for the list. `models` is a several-hundred-line
25
- * model table and `updateCheck` is an object; dumping them is how `/config`
26
- * becomes unreadable. `/config <key>` still shows one in full, on demand.
27
- *
28
- * Typed parsing is the upstream's, unchanged and deliberately narrow: `true` /
29
- * `false` / `null`, integers, floats, JSON arrays and objects, everything else a
30
- * string. An unknown key is refused rather than created — a typo that silently
31
- * grows the config file is a config file nobody can reason about later.
32
- */
33
-
34
- const { loadConfig, updateConfig, DEFAULT_CONFIG } = require('./config.js');
35
- // The one list of keys that live in the shared store. Imported rather than
36
- // re-listed: a second copy here is how the two hosts drift back apart.
37
- const { prefs } = require('./shared.js');
38
-
39
- const SHARED_KEYS = new Set(prefs.SHARED_PREF_KEYS);
40
-
41
- /** Where a key lives: the store both hosts read, or this host's own file. */
42
- function configStore(key) {
43
- return SHARED_KEYS.has(key) ? 'shared' : 'host';
44
- }
45
-
46
- /** Coerce a prompt-ish string into the JSON type the config key wants. */
47
- function parseConfigValue(raw) {
48
- const s = String(raw == null ? '' : raw).trim();
49
- if (s === '') return '';
50
- if (s === 'true') return true;
51
- if (s === 'false') return false;
52
- if (s === 'null') return null;
53
- if (/^-?\d+$/.test(s)) return Number.parseInt(s, 10);
54
- if (/^-?\d*\.\d+$/.test(s)) return Number.parseFloat(s);
55
- if (s.startsWith('[') || s.startsWith('{')) {
56
- try { return JSON.parse(s); } catch { return s; }
57
- }
58
- return s;
59
- }
60
-
61
- /**
62
- * One line for the list. Smaller values print as the value the user would have
63
- * typed (so `/config <key> <value>` round-trips); anything structured is
64
- * counted. `''` is shown as `""` because an empty row and a missing row must
65
- * not look alike.
66
- */
67
- function summarizeValue(value, max = 48) {
68
- if (value === null) return 'null';
69
- if (value === undefined) return '(unset)';
70
- if (Array.isArray(value)) return `[${value.length} item${value.length === 1 ? '' : 's'}]`;
71
- if (typeof value === 'object') {
72
- const n = Object.keys(value).length;
73
- return `{${n} key${n === 1 ? '' : 's'}}`;
74
- }
75
- if (typeof value === 'string') {
76
- if (value === '') return '""';
77
- return value.length > max ? `${value.slice(0, max - 1)}…` : value;
78
- }
79
- return String(value);
80
- }
81
-
82
- /** Render a value for `/config <key>` — pretty JSON when it is structured. */
83
- function fullValue(value) {
84
- if (value && typeof value === 'object') return JSON.stringify(value, null, 2);
85
- if (value === '') return '""';
86
- return String(value);
87
- }
88
-
89
- /**
90
- * Every key, with its current (defaulted) value and the store that owns it.
91
- * `defaulted` marks a key still at its shipped value, so "I never changed this"
92
- * is visible rather than inferred.
93
- */
94
- function configRows(cfg = loadConfig()) {
95
- return Object.keys(cfg).sort().map((key) => ({
96
- key,
97
- value: cfg[key],
98
- store: configStore(key),
99
- defaulted: Object.prototype.hasOwnProperty.call(DEFAULT_CONFIG, key)
100
- && JSON.stringify(cfg[key]) === JSON.stringify(DEFAULT_CONFIG[key]),
101
- }));
102
- }
103
-
104
- /** Panel lines: `key = value [store]`. */
105
- function formatConfigRows(rows = configRows()) {
106
- if (!rows.length) return [' No config keys.'];
107
- const width = Math.max(...rows.map((r) => r.key.length));
108
- return rows.map((r) => ` ${r.key.padEnd(width)} ${summarizeValue(r.value).padEnd(26)} ${r.store}${r.defaulted ? ' (default)' : ''}`);
109
- }
110
-
111
- /**
112
- * Set one key. Returns `{ key, value, store }` on success or `{ error }`.
113
- * The known-key check reads the *merged* config, which is the set of keys a
114
- * later `loadConfig()` will actually return — so a write can never land on a
115
- * key the read side would not report.
116
- */
117
- function setConfigValue(key, rawValue) {
118
- const k = String(key || '').trim();
119
- if (!k) return { error: 'usage: /config <key> <value>' };
120
- const cfg = loadConfig();
121
- if (!Object.prototype.hasOwnProperty.call(cfg, k)) {
122
- return { error: `unknown config key "${k}" — run /config to list the keys` };
123
- }
124
- const value = parseConfigValue(rawValue);
125
- updateConfig({ [k]: value });
126
- return { key: k, value, store: configStore(k) };
127
- }
128
-
129
- /**
130
- * Put one key back to its shipped value. Returns `{ error }` for an unknown key
131
- * or for a key this host has no default for (a host-local extra is deleted
132
- * rather than set to `undefined`, which is not a JSON value).
133
- */
134
- function resetConfigValue(key) {
135
- const k = String(key || '').trim();
136
- if (!k) return { error: 'usage: /config reset <key>' };
137
- if (!Object.prototype.hasOwnProperty.call(loadConfig(), k)) {
138
- return { error: `unknown config key "${k}" — run /config to list the keys` };
139
- }
140
- if (!Object.prototype.hasOwnProperty.call(DEFAULT_CONFIG, k)) {
141
- return { error: `"${k}" has no shipped default to reset to — /config ${k} <value> sets it directly` };
142
- }
143
- updateConfig({ [k]: DEFAULT_CONFIG[k] });
144
- return { key: k, value: DEFAULT_CONFIG[k], store: configStore(k) };
145
- }
146
-
147
- module.exports = {
148
- SHARED_KEYS,
149
- configStore,
150
- parseConfigValue,
151
- summarizeValue,
152
- fullValue,
153
- configRows,
154
- formatConfigRows,
155
- setConfigValue,
156
- resetConfigValue,
157
- };
3
+ "use strict";const{loadConfig:loadConfig,updateConfig:updateConfig,DEFAULT_CONFIG:DEFAULT_CONFIG}=require("./config.js"),{prefs:prefs}=require("./shared.js"),SHARED_KEYS=new Set(prefs.SHARED_PREF_KEYS);function configStore(e){return SHARED_KEYS.has(e)?"shared":"host"}function parseConfigValue(e){const t=String(null==e?"":e).trim();if(""===t)return"";if("true"===t)return!0;if("false"===t)return!1;if("null"===t)return null;if(/^-?\d+$/.test(t))return Number.parseInt(t,10);if(/^-?\d*\.\d+$/.test(t))return Number.parseFloat(t);if(t.startsWith("[")||t.startsWith("{"))try{return JSON.parse(t)}catch{return t}return t}function summarizeValue(e,t=48){if(null===e)return"null";if(void 0===e)return"(unset)";if(Array.isArray(e))return`[${e.length} item${1===e.length?"":"s"}]`;if("object"==typeof e){const t=Object.keys(e).length;return`{${t} key${1===t?"":"s"}}`}return"string"==typeof e?""===e?'""':e.length>t?`${e.slice(0,t-1)}…`:e:String(e)}function fullValue(e){return e&&"object"==typeof e?JSON.stringify(e,null,2):""===e?'""':String(e)}function configRows(e=loadConfig()){return Object.keys(e).sort().map((t=>({key:t,value:e[t],store:configStore(t),defaulted:Object.prototype.hasOwnProperty.call(DEFAULT_CONFIG,t)&&JSON.stringify(e[t])===JSON.stringify(DEFAULT_CONFIG[t])})))}function formatConfigRows(e=configRows()){if(!e.length)return[" No config keys."];const t=Math.max(...e.map((e=>e.key.length)));return e.map((e=>` ${e.key.padEnd(t)} ${summarizeValue(e.value).padEnd(26)} ${e.store}${e.defaulted?" (default)":""}`))}function setConfigValue(e,t){const r=String(e||"").trim();if(!r)return{error:"usage: /config <key> <value>"};const n=loadConfig();if(!Object.prototype.hasOwnProperty.call(n,r))return{error:`unknown config key "${r}" — run /config to list the keys`};const o=parseConfigValue(t);return updateConfig({[r]:o}),{key:r,value:o,store:configStore(r)}}function resetConfigValue(e){const t=String(e||"").trim();return t?Object.prototype.hasOwnProperty.call(loadConfig(),t)?Object.prototype.hasOwnProperty.call(DEFAULT_CONFIG,t)?(updateConfig({[t]:DEFAULT_CONFIG[t]}),{key:t,value:DEFAULT_CONFIG[t],store:configStore(t)}):{error:`"${t}" has no shipped default to reset to — /config ${t} <value> sets it directly`}:{error:`unknown config key "${t}" — run /config to list the keys`}:{error:"usage: /config reset <key>"}}module.exports={SHARED_KEYS:SHARED_KEYS,configStore:configStore,parseConfigValue:parseConfigValue,summarizeValue:summarizeValue,fullValue:fullValue,configRows:configRows,formatConfigRows:formatConfigRows,setConfigValue:setConfigValue,resetConfigValue:resetConfigValue};
@@ -1,54 +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
- * Where the CLI finds the modules it shares with the other hosts.
10
- *
11
- * `src/deps.js` does this for the transport/engine/registry trio, but it pulls
12
- * the whole agent loop in at require time — far too heavy for `config.js` and
13
- * `history.js`, which every command and every launch touches. This module
14
- * resolves the two *pure* shared modules those files need, with the same
15
- * two-layout rule and the same by-existence lookup:
16
- *
17
- * in-repo <repo>/cli/src/shared.js -> <repo>/client/*.js
18
- * npm <pkg>/src/shared.js -> <pkg>/vendor/client/*.js
19
- *
20
- * A missing module is a loud error rather than a silent fallback to a second
21
- * copy: a duplicate credential store or session store is exactly the drift this
22
- * whole arrangement exists to prevent.
23
- */
24
-
25
- const fs = require('node:fs');
26
- const path = require('node:path');
27
-
28
- function candidates(name) {
29
- return [
30
- path.join(__dirname, '..', '..', 'client', name), // repo checkout
31
- path.join(__dirname, '..', 'vendor', 'client', name), // staged package
32
- ];
33
- }
34
-
35
- function resolveClientModule(name) {
36
- const tried = candidates(name);
37
- for (const candidate of tried) {
38
- if (fs.existsSync(candidate)) return candidate;
39
- }
40
- throw new Error(
41
- `aegiscode: cannot find client/${name}. Expected it beside cli/ (in the repo) ` +
42
- 'or under cli/vendor/client/ (installed package). Reinstall the package, or ' +
43
- 'run `node scripts/predist.mjs` from cli/ if this is a source checkout.'
44
- );
45
- }
46
-
47
- const credentials = require(resolveClientModule('credentials.js'));
48
- const sessionStore = require(resolveClientModule('session-store.js'));
49
- // The one shared non-secret preference store (AEGISONE D5). `config.js` reads
50
- // and writes it, and the desktop's settings store writes the same file — so it
51
- // belongs here, resolved by existence, rather than as a second path guess.
52
- const prefs = require(resolveClientModule('prefs.js'));
53
-
54
- module.exports = { credentials, sessionStore, prefs, resolveClientModule };
3
+ "use strict";const fs=require("node:fs"),path=require("node:path");function candidates(e){return[path.join(__dirname,"..","..","client",e),path.join(__dirname,"..","vendor","client",e)]}function resolveClientModule(e){const s=candidates(e);for(const e of s)if(fs.existsSync(e))return e;throw new Error(`aegiscode: cannot find client/${e}. Expected it beside cli/ (in the repo) or under cli/vendor/client/ (installed package). Reinstall the package, or run \`node scripts/predist.mjs\` from cli/ if this is a source checkout.`)}const credentials=require(resolveClientModule("credentials.js")),sessionStore=require(resolveClientModule("session-store.js")),prefs=require(resolveClientModule("prefs.js"));module.exports={credentials:credentials,sessionStore:sessionStore,prefs:prefs,resolveClientModule:resolveClientModule};