aegisone 1.0.38 → 1.0.40

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 (116) hide show
  1. package/LICENSING.md +186 -0
  2. package/README.md +2 -2
  3. package/bin/aegis.js +1 -1
  4. package/package.json +3 -2
  5. package/scripts/predist.mjs +1 -1
  6. package/src/child.js +1 -1
  7. package/src/permissions.js +1 -1
  8. package/vendor/cli/package.json +4 -2
  9. package/vendor/cli/src/app.js +1 -1
  10. package/vendor/cli/src/chatflow.js +1 -1
  11. package/vendor/cli/src/commands.js +3 -1
  12. package/vendor/cli/src/config.js +1 -1
  13. package/vendor/cli/src/engine.js +1 -1
  14. package/vendor/cli/src/history.js +1 -1
  15. package/vendor/cli/src/models.js +1 -1
  16. package/vendor/cli/src/overlays.js +1 -1
  17. package/vendor/cli/src/panels.js +1 -1
  18. package/vendor/cli/vendor/client/brain-catalog.js +1 -1
  19. package/vendor/cli/vendor/client/byok-catalog.js +1 -1
  20. package/vendor/cli/vendor/client/credits.js +45 -0
  21. package/vendor/cli/vendor/client/foreign-sessions.js +3 -0
  22. package/vendor/cli/vendor/client/naming.js +1 -1
  23. package/vendor/cli/vendor/client/prefs.js +1 -1
  24. package/vendor/cli/vendor/client/session-search.js +3 -0
  25. package/vendor/cli/vendor/desktop/lib/local/claude-pro.js +1 -1
  26. package/vendor/cli/vendor/desktop/lib/local/engine.js +1 -1
  27. package/vendor/cli/vendor/desktop/lib/local/integrity.js +42 -2
  28. package/vendor/cli/vendor/desktop/lib/local/perm-rules.js +206 -0
  29. package/vendor/cli/vendor/desktop/lib/local/perm-store.js +298 -0
  30. package/vendor/cli/vendor/desktop/lib/local/perm-write.js +199 -0
  31. package/vendor/cli/vendor/desktop/lib/local/pro-sessions.js +3 -0
  32. package/vendor/cli/vendor/desktop/lib/local/sandbox-appcontainer.js +242 -0
  33. package/vendor/cli/vendor/desktop/lib/local/sandbox-bwrap.js +316 -0
  34. package/vendor/cli/vendor/desktop/lib/local/sandbox-seatbelt.js +380 -0
  35. package/vendor/cli/vendor/desktop/lib/local/sandbox.js +493 -0
  36. package/vendor/cli/vendor/desktop/lib/local/shell.js +155 -20
  37. package/vendor/cli/vendor/desktop/lib/local/tools.js +29 -4
  38. package/vendor/cli/vendor/desktop/lib/settings.js +1 -1
  39. package/vendor/cli/vendor/desktop/main.js +774 -37
  40. package/vendor/cli/vendor/desktop/renderer/usage.js +1 -1
  41. package/vendor/cli/vendor/mcp/admission.js +3 -0
  42. package/vendor/cli/vendor/mcp/server.js +1 -1
  43. package/vendor/cli/vendor/one/src/child.js +1 -1
  44. package/vendor/cli/vendor/one/src/permissions.js +1 -1
  45. package/vendor/desktop/bin/aegis.js +1 -1
  46. package/vendor/desktop/lib/local/claude-pro.js +1 -1
  47. package/vendor/desktop/lib/local/engine.js +1 -1
  48. package/vendor/desktop/lib/local/integrity.js +42 -2
  49. package/vendor/desktop/lib/local/perm-rules.js +206 -0
  50. package/vendor/desktop/lib/local/perm-store.js +298 -0
  51. package/vendor/desktop/lib/local/perm-write.js +199 -0
  52. package/vendor/desktop/lib/local/pro-sessions.js +3 -0
  53. package/vendor/desktop/lib/local/sandbox-appcontainer.js +242 -0
  54. package/vendor/desktop/lib/local/sandbox-bwrap.js +316 -0
  55. package/vendor/desktop/lib/local/sandbox-seatbelt.js +380 -0
  56. package/vendor/desktop/lib/local/sandbox.js +493 -0
  57. package/vendor/desktop/lib/local/shell.js +155 -20
  58. package/vendor/desktop/lib/local/tools.js +29 -4
  59. package/vendor/desktop/lib/settings.js +1 -1
  60. package/vendor/desktop/lib/sync/memory-store.js +3 -0
  61. package/vendor/desktop/main.js +774 -37
  62. package/vendor/desktop/package.json +20 -7
  63. package/vendor/desktop/preload.js +1 -1
  64. package/vendor/desktop/renderer/app.js +5 -1
  65. package/vendor/desktop/renderer/index.html +221 -5
  66. package/vendor/desktop/renderer/provider-mark.js +1 -1
  67. package/vendor/desktop/renderer/provider-toolbar.js +1 -1
  68. package/vendor/desktop/renderer/providers.js +1 -1
  69. package/vendor/desktop/renderer/style.css +223 -6
  70. package/vendor/desktop/renderer/usage.js +1 -1
  71. package/vendor/desktop/vendor/brain-catalog.js +1 -1
  72. package/vendor/desktop/vendor/byok-catalog.js +1 -1
  73. package/vendor/desktop/vendor/credits.js +45 -0
  74. package/vendor/desktop/vendor/faces/cli/package.json +3 -2
  75. package/vendor/desktop/vendor/faces/cli/src/app.js +1 -1
  76. package/vendor/desktop/vendor/faces/cli/src/chatflow.js +1 -1
  77. package/vendor/desktop/vendor/faces/cli/src/commands.js +3 -1
  78. package/vendor/desktop/vendor/faces/cli/src/config.js +1 -1
  79. package/vendor/desktop/vendor/faces/cli/src/engine.js +1 -1
  80. package/vendor/desktop/vendor/faces/cli/src/history.js +1 -1
  81. package/vendor/desktop/vendor/faces/cli/src/models.js +1 -1
  82. package/vendor/desktop/vendor/faces/cli/src/overlays.js +1 -1
  83. package/vendor/desktop/vendor/faces/cli/src/panels.js +1 -1
  84. package/vendor/desktop/vendor/faces/cli/vendor/client/brain-catalog.js +1 -1
  85. package/vendor/desktop/vendor/faces/cli/vendor/client/byok-catalog.js +1 -1
  86. package/vendor/desktop/vendor/faces/cli/vendor/client/credits.js +45 -0
  87. package/vendor/desktop/vendor/faces/cli/vendor/client/foreign-sessions.js +3 -0
  88. package/vendor/desktop/vendor/faces/cli/vendor/client/naming.js +1 -1
  89. package/vendor/desktop/vendor/faces/cli/vendor/client/prefs.js +1 -1
  90. package/vendor/desktop/vendor/faces/cli/vendor/client/session-search.js +3 -0
  91. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/claude-pro.js +1 -1
  92. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/engine.js +1 -1
  93. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/integrity.js +1 -1
  94. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/perm-rules.js +3 -0
  95. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/perm-store.js +3 -0
  96. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/perm-write.js +3 -0
  97. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/pro-sessions.js +3 -0
  98. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/sandbox-appcontainer.js +3 -0
  99. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/sandbox-bwrap.js +3 -0
  100. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/sandbox-seatbelt.js +3 -0
  101. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/sandbox.js +3 -0
  102. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/shell.js +1 -1
  103. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/tools.js +1 -1
  104. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/settings.js +1 -1
  105. package/vendor/desktop/vendor/faces/cli/vendor/desktop/main.js +4 -2
  106. package/vendor/desktop/vendor/faces/cli/vendor/desktop/renderer/usage.js +1 -1
  107. package/vendor/desktop/vendor/faces/cli/vendor/mcp/admission.js +3 -0
  108. package/vendor/desktop/vendor/faces/cli/vendor/mcp/server.js +1 -1
  109. package/vendor/desktop/vendor/faces/cli/vendor/one/src/child.js +1 -1
  110. package/vendor/desktop/vendor/faces/cli/vendor/one/src/permissions.js +1 -1
  111. package/vendor/desktop/vendor/foreign-sessions.js +3 -0
  112. package/vendor/desktop/vendor/naming.js +1 -1
  113. package/vendor/desktop/vendor/prefs.js +1 -1
  114. package/vendor/desktop/vendor/sandbox/provenance.json +20 -0
  115. package/vendor/desktop/vendor/sandbox/x64-linux/bwrap +0 -0
  116. package/vendor/desktop/vendor/session-search.js +3 -0
package/LICENSING.md ADDED
@@ -0,0 +1,186 @@
1
+ # Licensing
2
+
3
+ **Aegiscode is licensed under the GNU Affero General Public License, version 3
4
+ or later (`AGPL-3.0-or-later`).** The verbatim licence text is in
5
+ [LICENSE](LICENSE). This document is the plain-language summary and the record
6
+ of the licence change; where it and `LICENSE` disagree, `LICENSE` governs.
7
+
8
+ Every manifest in this repo carries the same licence: `cli/package.json`
9
+ (the published `aegiscode` CLI), `desktop/package.json` (`aegis-desktop`) and
10
+ `online/package.json`. The first-party avatar packs under
11
+ `desktop/lib/avatar/packs/` carry it too. Vendored third-party code keeps its
12
+ own licence — see [desktop/renderer/vendor/NOTICE.md](desktop/renderer/vendor/NOTICE.md).
13
+
14
+ ## Notice to apply to the program
15
+
16
+ ```
17
+ Copyright (C) 2026 Niklas Borneklint
18
+
19
+ This program is free software: you can redistribute it and/or modify it under
20
+ the terms of the GNU Affero General Public License as published by the Free
21
+ Software Foundation, either version 3 of the License, or (at your option) any
22
+ later version.
23
+
24
+ This program is distributed in the hope that it will be useful, but WITHOUT ANY
25
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
26
+ PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
27
+
28
+ You should have received a copy of the GNU Affero General Public License along
29
+ with this program. If not, see <https://www.gnu.org/licenses/>.
30
+ ```
31
+
32
+ ## What you may do
33
+
34
+ Everything MIT let you do: run it, read and study the source, modify it,
35
+ redistribute it, bundle it into your own product, and **sell it** — the AGPL is
36
+ not a non-commercial licence. It adds an express patent grant that MIT never
37
+ had, which matters here for the transport, provider and tool-calling code.
38
+
39
+ ## The obligation MIT did not have
40
+
41
+ - **§5 — distributing a modified version.** Conveying a modified copy (an npm
42
+ tarball, a rebuilt AppImage or `.deb`, a published fork) means the recipients
43
+ get the corresponding source under this same licence. Private local
44
+ modification triggers nothing.
45
+ - **§13 — Remote Network Interaction.** Operating a modified version as a
46
+ network service means the users of that service must be offered the
47
+ corresponding source. This is what stops a third party from taking this code,
48
+ standing up a competing hosted drain, and publishing nothing.
49
+
50
+ The desktop app is where this is most visible in practice: the thin-shell guard
51
+ already keeps cloud routing and brain logic out of `desktop/`, and that boundary
52
+ is what makes it possible for this repo to be AGPL while the hosted service
53
+ behind it stays a separate, proprietary product.
54
+
55
+ ## Why this changed
56
+
57
+ Versions released before 2026-09-27 (npm `aegiscode` up to and including
58
+ `6.8.11`, `aegis-desktop` up to and including `0.8.12`) shipped under the MIT
59
+ License. MIT grants the right to "sublicense" and to "sell copies" and imposes
60
+ no obligation to give anything back: a third party could host a competing drain,
61
+ ship a closed fork, or resell the app, and owe this project nothing. AGPL keeps
62
+ the code public and free while making reuse carry a legal consequence.
63
+
64
+ This also keeps the SignPath Foundation signing grant eligible — that grant
65
+ requires an OSI-approved open-source licence against a public repo, which AGPL
66
+ is and a proprietary licence would not be. See
67
+ [desktop/SIGNING.md](desktop/SIGNING.md).
68
+
69
+ ## What this change does not reach
70
+
71
+ - **Already-published copies stay MIT, permanently.** The MIT grant is
72
+ irrevocable for what is already out there: npm tarballs published before this
73
+ change, installers attached to releases before this change, and forks made
74
+ from pre-change commits. Only releases published from this commit onward are
75
+ AGPL.
76
+ - **The desktop mirror moved to `aegiscloud-devs/aegiscode-plugin`, branch
77
+ `desktop`** (2026-10-01, `tools/sync-desktop-mirror.mjs`). That repo is the
78
+ private destination the standing push directive names, and the synced tree
79
+ takes this repo's `LICENSE` file verbatim — so the mirror now ships **AGPL**,
80
+ not MIT. It is a mirror of `desktop/` only; the monorepo's own code lives on
81
+ that repo's `main`.
82
+ - **`aegiscloud/aegiscode-desktop` (org) is the legacy mirror.** It is a
83
+ `git subtree split` of `desktop/` that still ships the MIT `LICENSE` and
84
+ **has not been converted, and is no longer synced** — it is frozen at v0.8.1.
85
+ It survives only as the history seed for the new branch. The "Source (MIT)"
86
+ line in the promo copy is true *of that frozen repo* and false *of this repo
87
+ and of the current mirror* — which is exactly why the promo copy and
88
+ [docs/launch-readiness.md](docs/launch-readiness.md) are annotated rather than
89
+ left as-is.
90
+ - **Third-party code keeps its own licence** — notably `marked`
91
+ (MIT / MPL-2.0 dual) under `desktop/renderer/vendor/`.
92
+
93
+ ## How the notice travels with the code
94
+
95
+ `LICENSE` is one file, and it is the first file a copy drops. So the notice is
96
+ also written into the source itself: every first-party file that ships — under
97
+ `cli/`, `client/`, `mcp/`, `desktop/` and `one/`, in `.js`, `.mjs`, `.cjs`,
98
+ `.sh`, `.ps1`, `.css` and `.html` — begins with the same five lines: the SPDX
99
+ identifier, the copyright holder, the product name, the source URL, and the §5/§13
100
+ sentence. `tools/provenance.mjs` writes them (`write`, idempotent), checks them
101
+ (`check`), and re-derives the list of shipped roots from each package's `files:`
102
+ list rather than from a list of its own. `test/provenance.test.mjs` runs the
103
+ sweep, plus a negative control.
104
+
105
+ The same command answers the other question a person holding an unfamiliar build
106
+ has — "is this still the program that was published?":
107
+
108
+ ```sh
109
+ aegiscode provenance # licence, source, and a self-check of the safety files
110
+ aegiscode provenance --json # for scripts; exit 1 when a safety file has moved
111
+ ```
112
+
113
+ It re-hashes the CLI files whose edit changes what the program **allows** — the
114
+ agent-key gate, the permission evaluator, the frozen approval classes, the
115
+ autonomous runner, the entry point that wires them, the silent interlock, and the
116
+ checker itself — against `cli/src/provenance.lock.json`, which ships in the
117
+ package.
118
+
119
+ Two deliberate details about what it says:
120
+
121
+ - **The manifest carries digests, not paths, and the runtime names units, not
122
+ files.** A report reading `src/gate.js: a1b2… → c3d4…` is a repair manual for
123
+ whoever neutered the gate: it names the file, the file's job, and the next move.
124
+ So `provenance.lock.json` keys its digests `p1…p7`, the runtime prints `p3:
125
+ digest moved`, and it does not print the remedy. The id-to-path table lives in
126
+ `cli/src/provenance.js`, where the code can resolve an id without ever showing
127
+ one, and in `tools/provenance.mjs`, which is a development tool and says
128
+ whatever a maintainer needs.
129
+ - **It is one of two gates.** This one speaks; the second one withholds. When the
130
+ sealed set does not verify as a *whole* (`cli/src/limits.js`), the build refuses
131
+ its own privileged subcommands — `gate`, `provenance`, `mcp` — so the half that
132
+ manages the agent key is unavailable to a build that failed the check, and it
133
+ says one bland line naming no file, no cause and no repair. The second gate has
134
+ **no environment variable and no flag**: anything that turns it off at runtime
135
+ would be documented right next to it, and a gate the manipulator can read about
136
+ is a gate the manipulator can open. Re-sealing is a deliberate act —
137
+ `node tools/provenance.mjs lock --write` re-seals the interlock and rewrites the
138
+ manifest in one command, so the two cannot drift apart.
139
+
140
+ A session prints the loud line to stderr when a digest has moved;
141
+ `AEGIS_NO_PROVENANCE_CHECK=1` silences *that* on a development tree and says so
142
+ when it does. It does not silence the interlock.
143
+
144
+ **What that is not.** It is not DRM and it does not measure "copying". Whoever
145
+ holds the bytes can edit a safety file *and* regenerate the manifest; there is no
146
+ key and no server, because a client that phones home to prove itself fails
147
+ offline. What it buys is that the manipulated build is no longer **silent** —
148
+ either it announces the divergence to its own user, or its author deleted a
149
+ check that `tools/invariant-lock.mjs` pins, which is a deliberate act with a
150
+ ledger entry. Removing the banner is likewise no longer a no-op: it is a
151
+ deletion in 160+ files, and `check` names every one.
152
+
153
+ ## Commercial licence
154
+
155
+ If the AGPL's obligations do not fit your use — shipping a closed product,
156
+ running a hosted service without publishing modifications, or needing contract
157
+ terms, an indemnity or a support SLA — a commercial licence that waives them is
158
+ available. Contact **licensing@aegiscloud.org**. Note what this does *not* buy:
159
+ the paid cloud drain is a service, and paying for it has never required a
160
+ commercial licence, only AGPL compliance for any modified code you distribute
161
+ or host.
162
+
163
+ ## Trademarks
164
+
165
+ The AGPL grants a copyright and a patent licence to the code. It grants **no**
166
+ right to the names *Aegiscode*, *AEGIS Code*, *Aegiscodex* or *Aegiscloud*, to
167
+ the logo, or to the npm package identities `aegiscode` / `aegis-desktop`. A fork
168
+ must use its own name and package name, and must not imply endorsement.
169
+ Nominative use — "a fork of Aegiscode" — is fine.
170
+
171
+ ## Contributions
172
+
173
+ Dual licensing only works if the maintainer holds enough rights to license every
174
+ contribution under both the AGPL and the commercial terms, so contributions are
175
+ accepted under a contributor agreement (CLA), not by inbound-equals-outbound
176
+ default. This replaces the earlier "no CLA, no contributor agreement to sign"
177
+ position in [docs/reddit-drafts.md](docs/reddit-drafts.md). Until a contribution
178
+ carries that grant, treat it as needing explicit written permission before it is
179
+ merged; a pull request alone is not that permission.
180
+
181
+ ## Scope note
182
+
183
+ This document records what the licence is and why. It is not legal advice. The
184
+ two places a lawyer's read matters most: the contribution/CLA paragraph above,
185
+ and whether the AGPL client and the proprietary `aegis1` backend are ever
186
+ distributed or operated together in a way §5 or §13 reaches.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # AEGISONE
2
2
 
3
- Product version: **1.0.38**
3
+ Product version: **1.0.40**
4
4
 
5
5
  One product, two faces: the terminal (`aegiscode`) and the window (`aegis-desktop`),
6
6
  reached through one command — `aegis` — and released as one version.
@@ -60,7 +60,7 @@ fails, and it never leaves you with "nothing happened". Afterwards: `aegis`
60
60
 
61
61
  ## Size, measured not claimed
62
62
 
63
- Measured size: **2.50 MB** (2,626,046 bytes) with Electron absent — both faces inside.
63
+ Measured size: **2.71 MB** (2,844,939 bytes) with Electron absent — both faces inside.
64
64
 
65
65
  The plan's "~2 MB" was a target, so it is measured here rather than published:
66
66
  `npm pack one/` on this tree, with Electron absent, produces that tarball, and it
package/bin/aegis.js CHANGED
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env node
2
2
  // SPDX-License-Identifier: AGPL-3.0-or-later
3
3
  // Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
4
- "use strict";const fs=require("node:fs"),path=require("node:path"),{spawnSync:spawnSync,spawn:spawn}=require("node:child_process"),{decide:decide,FACE:FACE}=require("../src/dispatch.js"),WIN=require("../src/iface/window.js"),probes=require("../src/probes.js"),release=require("../src/release.js"),EXIT_USAGE=2,PRODUCT=require("../package.json");function faceManifestPaths(e,s){const r=s||__dirname;return[path.join(r,"..","vendor",e.dir,"package.json"),path.join(r,"..","..",e.dir,"package.json")]}function readFaceVersions(e){return release.FACE_LINES.map((s=>{for(const r of faceManifestPaths(s,e))try{return{package:s.package,version:JSON.parse(fs.readFileSync(r,"utf8")).version,source:r}}catch{}return{package:s.package,version:null,source:null}}))}function write(e,s){try{e.write(s.endsWith("\n")?s:s+"\n")}catch{}}function statusOf(e){return"number"==typeof e.status?e.status:"SIGINT"===e.signal?130:"SIGTERM"===e.signal?143:1}function run(e,s){const r=s||{},n=r.stderr||process.stderr,t=r.stdout||process.stdout,i=r.input||probes.collect({argv:e}),a=Array.isArray(e)?{...i,argv:e}:i,o=release.versionRequest(a.argv);if(o){const e=o.verbose?r.readFaceVersions?r.readFaceVersions():readFaceVersions(r.binDir):null;return write(t,release.renderVersion({product:{name:PRODUCT.name,version:PRODUCT.version},faces:e})),0}const c=(a.argv||[]).indexOf("doctor");if(-1!==c&&!(a.argv||[]).slice(0,c).some((e=>!e.startsWith("-")))){const e=(r.doctor||require("../src/doctor.js")).main((a.argv||[]).slice(c+1),Object.assign({env:a.env,stdout:t},r.doctorDeps||{}));return"number"==typeof e?e:EXIT_USAGE}const d=decide(a),u=r.permissions||require("../src/permissions.js"),p=(a.argv||[]).indexOf(u.SKIP_FLAG||"--dangerously-skip-permissions"),g=Boolean(a.tty&&a.tty.stdin&&a.tty.stdout),l=g?"interactive":"headless",f=r.stored||u.storedPermissionFacts(r.storedOpts||{}),w=u.resolvePosture({rules:void 0!==r.rules?r.rules:f.rules,gate:void 0!==r.gate?r.gate:f.confirmationsOn,flag:-1!==p,env:a.env,interactive:g,childKind:l});w.warning&&write(n,`aegis: ${w.warning}`),w.skip&&w.skipFromFlag&&write(n,u.skipReport(w));const h=-1===p?d.args:d.args.filter((e=>e!==(u.SKIP_FLAG||"--dangerously-skip-permissions"))),m=w.skipFromFlag?{AEGISONE_SKIP_PERMISSIONS:"1"}:{};if("1"===(a.env||{}).AEGISONE_PRINT_DECISION&&write(n,"aegis: decision "+JSON.stringify({face:d.face,kind:d.kind,reason:d.reason,args:h,skip:w.skip})),null===d.face)return write(n,`aegis: ${d.error}`),d.hint&&write(n,`aegis: ${d.hint}`),d.code||EXIT_USAGE;d.notice&&write(n,`aegis: ${d.notice} — running the terminal face.`);const v=r.spawnSync||spawnSync,E=r.spawn||spawn,I=Object.assign({},process.env,r.env||{});if(d.face===FACE.TUI){const e=a._cliBin||r.cliBin;return e?statusOf(v(process.execPath,[e,...h],{stdio:"inherit",env:Object.assign({},I,m),argv0:"aegiscode"})||{}):(write(n,"aegis: the terminal face is not installed beside aegisone."),write(n,"aegis: reinstall aegisone, or set AEGISONE_CLI_BIN to bin/aegiscode.js."),127)}const S=a._electron||r.electron,O=a._desktopMain||r.desktopMain,_=WIN.plan({decision:d,electron:Boolean(S),target:r.target||a.target});if(!_||!O)return write(n,"aegis: cannot open the window — Electron or the desktop entry point went missing after the check."),write(n,"aegis: Use --tui for the terminal face."),EXIT_USAGE;delete I.ELECTRON_RUN_AS_NODE;const k=WIN.open(_,{main:O,args:h,env:Object.assign({},I,m)},{openElectron:e=>E(process.execPath,[e.main,...e.args],{stdio:"inherit",env:e.env,detached:!1})});if(!k||!k.ok)return write(n,`aegis: cannot open the window — ${k&&k.msg||"no usable window plan"}.`),write(n,"aegis: Use --tui for the terminal face."),EXIT_USAGE;const y=k.handle;return new Promise((e=>{y.on("error",(s=>{write(n,`aegis: could not start the window: ${s&&s.message}`),e(1)})),y.on("exit",((s,r)=>e(statusOf({status:s,signal:r}))))}))}function main(e){const s=run(e);return"number"==typeof s?(process.exitCode=s,s):s.then((e=>(process.exitCode=e,e)))}if(module.exports={main:main,run:run,statusOf:statusOf,EXIT_USAGE:EXIT_USAGE},require.main===module){const e=main(process.argv.slice(2));e&&"function"==typeof e.then&&e.catch((e=>{write(process.stderr,`aegis: ${e&&e.stack||e}`),process.exitCode=1}))}
4
+ "use strict";const fs=require("node:fs"),path=require("node:path"),{spawnSync:spawnSync,spawn:spawn}=require("node:child_process"),{decide:decide,FACE:FACE}=require("../src/dispatch.js"),WIN=require("../src/iface/window.js"),probes=require("../src/probes.js"),release=require("../src/release.js"),EXIT_USAGE=2,PRODUCT=require("../package.json");function faceManifestPaths(e,s){const r=s||__dirname;return[path.join(r,"..","vendor",e.dir,"package.json"),path.join(r,"..","..",e.dir,"package.json")]}function readFaceVersions(e){return release.FACE_LINES.map((s=>{for(const r of faceManifestPaths(s,e))try{return{package:s.package,version:JSON.parse(fs.readFileSync(r,"utf8")).version,source:r}}catch{}return{package:s.package,version:null,source:null}}))}function write(e,s){try{e.write(s.endsWith("\n")?s:s+"\n")}catch{}}function statusOf(e){return"number"==typeof e.status?e.status:"SIGINT"===e.signal?130:"SIGTERM"===e.signal?143:1}function run(e,s){const r=s||{},n=r.stderr||process.stderr,t=r.stdout||process.stdout,i=r.input||probes.collect({argv:e}),o=Array.isArray(e)?{...i,argv:e}:i,a=release.versionRequest(o.argv);if(a){const e=a.verbose?r.readFaceVersions?r.readFaceVersions():readFaceVersions(r.binDir):null;return write(t,release.renderVersion({product:{name:PRODUCT.name,version:PRODUCT.version},faces:e})),0}const c=(o.argv||[]).indexOf("doctor");if(-1!==c&&!(o.argv||[]).slice(0,c).some((e=>!e.startsWith("-")))){const e=(r.doctor||require("../src/doctor.js")).main((o.argv||[]).slice(c+1),Object.assign({env:o.env,stdout:t},r.doctorDeps||{}));return"number"==typeof e?e:EXIT_USAGE}const d=decide(o),u=r.permissions||require("../src/permissions.js"),p=(o.argv||[]).indexOf(u.SKIP_FLAG||"--dangerously-skip-permissions"),g=Boolean(o.tty&&o.tty.stdin&&o.tty.stdout),l=g?"interactive":"headless",f=r.stored||u.storedPermissionFacts(r.storedOpts||{}),w=u.resolvePosture({rules:void 0!==r.rules?r.rules:f.rules,gate:void 0!==r.gate?r.gate:f.confirmationsOn,permissionMode:void 0!==r.permissionMode?r.permissionMode:f.permissionMode,flag:-1!==p,env:o.env,interactive:g,childKind:l});w.warning&&write(n,`aegis: ${w.warning}`),w.skip&&w.skipFromFlag&&write(n,u.skipReport(w));const m=-1===p?d.args:d.args.filter((e=>e!==(u.SKIP_FLAG||"--dangerously-skip-permissions"))),h=w.skipFromFlag?{AEGISONE_SKIP_PERMISSIONS:"1"}:{};if("1"===(o.env||{}).AEGISONE_PRINT_DECISION&&write(n,"aegis: decision "+JSON.stringify({face:d.face,kind:d.kind,reason:d.reason,args:m,skip:w.skip})),null===d.face)return write(n,`aegis: ${d.error}`),d.hint&&write(n,`aegis: ${d.hint}`),d.code||EXIT_USAGE;d.notice&&write(n,`aegis: ${d.notice} — running the terminal face.`);const v=r.spawnSync||spawnSync,E=r.spawn||spawn,I=Object.assign({},process.env,r.env||{});if(d.face===FACE.TUI){const e=o._cliBin||r.cliBin;return e?statusOf(v(process.execPath,[e,...m],{stdio:"inherit",env:Object.assign({},I,h),argv0:"aegiscode"})||{}):(write(n,"aegis: the terminal face is not installed beside aegisone."),write(n,"aegis: reinstall aegisone, or set AEGISONE_CLI_BIN to bin/aegiscode.js."),127)}const S=o._electron||r.electron,O=o._desktopMain||r.desktopMain,_=WIN.plan({decision:d,electron:Boolean(S),target:r.target||o.target});if(!_||!O)return write(n,"aegis: cannot open the window — Electron or the desktop entry point went missing after the check."),write(n,"aegis: Use --tui for the terminal face."),EXIT_USAGE;delete I.ELECTRON_RUN_AS_NODE;const k=WIN.open(_,{main:O,args:m,env:Object.assign({},I,h)},{openElectron:e=>E(process.execPath,[e.main,...e.args],{stdio:"inherit",env:e.env,detached:!1})});if(!k||!k.ok)return write(n,`aegis: cannot open the window — ${k&&k.msg||"no usable window plan"}.`),write(n,"aegis: Use --tui for the terminal face."),EXIT_USAGE;const y=k.handle;return new Promise((e=>{y.on("error",(s=>{write(n,`aegis: could not start the window: ${s&&s.message}`),e(1)})),y.on("exit",((s,r)=>e(statusOf({status:s,signal:r}))))}))}function main(e){const s=run(e);return"number"==typeof s?(process.exitCode=s,s):s.then((e=>(process.exitCode=e,e)))}if(module.exports={main:main,run:run,statusOf:statusOf,EXIT_USAGE:EXIT_USAGE},require.main===module){const e=main(process.argv.slice(2));e&&"function"==typeof e.then&&e.catch((e=>{write(process.stderr,`aegis: ${e&&e.stack||e}`),process.exitCode=1}))}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "aegisone",
3
3
  "productName": "AEGISONE",
4
- "version": "1.0.38",
4
+ "version": "1.0.40",
5
5
  "description": "AEGISONE — one product, two faces. `aegis` opens the window when there is nothing else to do and runs the terminal otherwise; `aegiscode` keeps behaving exactly as it always has.",
6
6
  "author": {
7
7
  "name": "AEGIS Code",
@@ -20,8 +20,9 @@
20
20
  "install.ps1",
21
21
  "vendor",
22
22
  "README.md",
23
+ "LICENSE",
23
24
  "SOURCE-OFFER.txt",
24
- "LICENSE"
25
+ "LICENSING.md"
25
26
  ],
26
27
  "engines": {
27
28
  "node": ">=22.0.0"
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env node
2
2
  // SPDX-License-Identifier: AGPL-3.0-or-later
3
3
  // Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
4
- import e from"node:fs";import r from"node:path";import{spawnSync as s}from"node:child_process";import{fileURLToPath as t,pathToFileURL as o}from"node:url";import{createRequire as n}from"node:module";const i=r.dirname(t(import.meta.url)),a=n(import.meta.url);export const ONE_DIR=r.join(i,"..");export const REPO_DIR=r.join(ONE_DIR,"..");export const CLI_DIR=r.join(REPO_DIR,"cli");export const DESKTOP_DIR=r.join(REPO_DIR,"desktop");export const CLI_VENDOR=r.join(CLI_DIR,"vendor");export const DESKTOP_VENDOR=r.join(DESKTOP_DIR,"vendor");export const ONE_VENDOR=r.join(ONE_DIR,"vendor");export const MANIFEST=[{src:"client/aegis.js",shapes:["mirror","flat"],note:"the thin transport — the one implementation of the wire format"},{src:"client/update.js",shapes:["mirror","flat"],note:"the npm update checker (the desktop own update path)"},{src:"client/foreign-memory.js",shapes:["mirror","flat"],note:"required by mcp/tools.js as ../client/foreign-memory.js"},{src:"client/credentials.js",shapes:["mirror","flat"],note:"the account credential store, shared by all three hosts"},{src:"client/session-store.js",shapes:["mirror","flat"],note:"the unified session store — one list in every host"},{src:"client/naming.js",shapes:["mirror","flat"],note:"the conversation-naming ladder — ONE implementation for the terminal and the window (cli/src/naming.js re-exports it)"},{src:"client/prefs.js",shapes:["mirror","flat"],note:"the shared non-secret preference store (D5) — the CLI and the desktop store both read/write it"},{src:"client/env-file.js",shapes:["mirror","flat"],note:"the shared ~/.aegiscode/.env loader, resolved before any key is read"},{src:"client/auto-provision.js",shapes:["mirror","flat"],note:"free device key on first launch; requires ./device-fingerprint.js"},{src:"client/device-fingerprint.js",shapes:["mirror","flat"],note:"the machine identity auto-provision.js and presence.js require"},{src:"client/presence.js",shapes:["mirror","flat"],note:"the heartbeat beacon; requires ./presence-constants.js and ./device-fingerprint.js"},{src:"client/presence-constants.js",shapes:["mirror","flat"],note:"the beacon constants — a package without them loses the beacon silently"},{src:"client/touch.js",shapes:["mirror","flat"],note:"phi(alpha): the digest module fingerprint.js requires as ./touch.js"},{src:"client/fingerprint.js",shapes:["mirror","flat"],note:"phi(alpha): the sealed session record, resolved by src/fingerprint.js"},{src:"client/authorship-key.js",shapes:["mirror","flat"],note:"phi(alpha): the authorship key, required by ./attest.js and ./record-vault.js"},{src:"client/attest.js",shapes:["mirror","flat"],note:"phi(alpha): attestation, requires ./fingerprint.js and ./authorship-key.js"},{src:"client/record-vault.js",shapes:["mirror","flat"],note:"the vault, and its refusal to copy the key with the record"},{src:"client/brain-catalog.js",shapes:["mirror","flat"],note:"the pooled-brain rule, required at load time by the engine and src/models.js"},{src:"client/byok-catalog.js",shapes:["mirror","flat"],note:"the BYOK model additions the server catalog does not name"},{src:"client/catalog-client.js",shapes:["mirror","flat"],note:"the server's cached catalog, layered between the shipped additions and the user's own models"},{src:"client/user-models.js",shapes:["mirror","flat"],note:"the models the USER declares, in one file both hosts read (requires ./credentials.js)"},{src:"client/model-discovery.js",shapes:["mirror","flat"],note:"asks the vendor what it serves, so adding a new model is not a memory test (requires ./user-models.js)"},{src:"client/hooks.js",shapes:["mirror","flat"],note:"the shared hook layer behind /hooks and the repo guard installer"},{src:"client/platform.js",shapes:["mirror","flat"],note:"the ONE place that decides which OS this is (Phase 30.1)"},{src:"client/topup.js",shapes:["mirror","flat"],note:"the token-bank top-up: amount bounds, the balance reading, and the credit watch every host drives"},{src:"client/google-signin.js",shapes:["mirror","flat"],note:"the localhost half of aegis1's desktop Google OAuth round-trip; `connect --google` drives it"},{src:"client/drive-connect.js",shapes:["mirror","flat"],note:"the desktop half of aegis1's Drive OAuth (/connect/drive, /api/drive/token); requires ./aegis.js only via the caller"},{src:"client/drive-upload.js",shapes:["mirror","flat"],note:"the Drive v3 REST wrapper that uploads the memory backup and one conversation per save"},{src:"client/conversation-export.js",shapes:["mirror","flat"],note:"the authorship stamp at the top of every uploaded file, and the two backup scope names"},{src:"mcp/tools.js",shapes:["mirror"],note:"the shared tool registry; requires ../client/foreign-memory.js"},{src:"mcp/server.js",shapes:["mirror"],note:"the stdio MCP server every installed editor config names (compiled, never required)"},{src:"hosts/spec.js",shapes:["mirror"],note:"the canonical server spec, staged under its own directory so it finds vendor/mcp/server.js"},{src:"hosts/targets.js",shapes:["mirror"],note:"the editor target registry"},{src:"hosts/install.js",shapes:["mirror"],note:"the merge-only installer behind aegiscode mcp install"},{src:"hosts/openai-shim.js",shapes:["mirror"],note:"the loopback OpenAI-compatible shim"},{src:"desktop/renderer/usage.js",shapes:["mirror"],note:"the pure usage mapping shared by the window and the terminal"},{src:"desktop/lib/local/engine.js",shapes:["mirror"],note:"the agent loop, reused as-is (one loop, not a second one drifting)"},{src:"desktop/lib/local/claude-pro.js",shapes:["mirror"],note:"the Claude Code Pro transport; requires ./../../one/src/child.js at call time"},{src:"one/src/child.js",shapes:["mirror"],note:"the ONE claude-child argv builder (rule 4); resolved by claude-pro.js at call time"},{src:"one/src/permissions.js",shapes:["mirror"],note:"resolvePosture() — the permission half of the argv, resolved at call time"},{src:"desktop/lib/local/local.js",shapes:["mirror"],note:"the local model transport and its fail-closed base-URL check"},{src:"desktop/lib/local/context.js",shapes:["mirror"],note:"the token-budget trimmer local.js requires at load"},{src:"desktop/lib/local/attachments.js",shapes:["mirror"],note:"content-part builder for dropped files; required at load by engine.js and local.js"},{src:"desktop/lib/local/session-rounds.js",shapes:["mirror"],note:"interrupted-turn bookkeeping; required at load by engine.js"},{src:"desktop/lib/local/tools.js",shapes:["mirror"],note:"the tool implementations (persistent shell, editFile, grep, exec)"},{src:"desktop/lib/local/shell.js",shapes:["mirror"],note:"the persistent shell, required by tools.js"},{src:"desktop/lib/local/integrity.js",shapes:["mirror"],note:"the desktop second gate; required at load by shell.js and tools.js, and the seal over its own four units"},{src:"desktop/main.js",shapes:["mirror"],bytesOnly:!0,note:"seal unit d1 — hashed by integrity.js as BYTES and never required from the mirror, so its own requires (the whole Electron main-process closure) are not staged behind it"},{src:"desktop/lib/local/spill.js",shapes:["mirror"],note:"oversized-output spill, required at load by tools.js and shell.js"},{src:"desktop/lib/local/exec-plan.js",shapes:["mirror"],note:"exec one-shot eligibility classifier, required at load by engine.js"},{src:"desktop/lib/local/agents.js",shapes:["mirror"],note:"Task subagents"},{src:"desktop/lib/local/prompt.js",shapes:["mirror"],note:"the system prompt builder"},{src:"desktop/lib/settings.js",shapes:["mirror"],note:"the provider-config store (base URL + key per provider)"},{src:"desktop/lib/local/turn-guard.js",shapes:["mirror"],note:"engine.js requires it at load; it requires ./git-scope.js"},{src:"desktop/lib/local/worktree-lock.js",shapes:["mirror"],note:"engine.js requires it at load"},{src:"desktop/lib/local/git-scope.js",shapes:["mirror"],note:"the write-scope rule turn-guard.js and the queues share"},{src:"desktop/lib/local/queue.js",shapes:["mirror"],note:"the autonomous work queue"},{src:"desktop/lib/local/autonomous.js",shapes:["mirror"],note:"the unattended worker; requires ./queue.js and ./git-scope.js"},{src:"desktop/lib/local/entitlement.js",shapes:["mirror"],note:"the shared Pro gate (account probe injected by the caller)"},{src:"desktop/lib/local/covenant.js",shapes:["mirror"],note:"the pre-action gate engine.js requires unconditionally at load"},{src:"desktop/lib/local/aegis-seal.mjs",shapes:["mirror"],note:"the codec covenant.js requires the first time it decodes"},{src:"covenant/aegis.seal",shapes:["mirror","nested"],note:"the sealed covenant (AES/1 container) — path shape is load-bearing"},{src:"covenant/README.md",shapes:["mirror","nested"],note:"the decode notice shipped beside the artifact"},{src:"tools/agent-gate.mjs",shapes:["mirror","flat"],note:"the in-process half of the lock; without it a packaged app had NO gate"},{src:"one/src/selfhost.js",shapes:["mirror","flat"],note:"the packaged launcher decision — which face this artifact was asked for"}];export function entriesFor(e){const s=[];for(const t of MANIFEST){if(!t.shapes.includes(e))continue;let o;if("mirror"===e)o=r.join(CLI_VENDOR,t.src);else if("flat"===e)o=r.join(DESKTOP_VENDOR,r.basename(t.src));else{if("nested"!==e)throw new Error(`predist: unknown shape ${e}`);o=r.join(DESKTOP_VENDOR,t.src)}s.push({src:t.src,dest:o,from:r.join(REPO_DIR,t.src)})}return s}export const SHAPES=["mirror","flat","nested"];const c=[["cli",CLI_DIR,["bin","src","vendor","scripts","package.json","README.md","LICENSE"]],["desktop",DESKTOP_DIR,["main.js","preload.js","lib","renderer","bin","vendor","package.json","README.md"]]],l=new Set(["node_modules","release",".git",".cache","out"]);function d(s,t){const o=e=>l.has(e)||e.endsWith(".log"),n=(s,t)=>{if(e.mkdirSync(r.dirname(t),{recursive:!0}),e.copyFileSync(s,t),!e.readFileSync(s).equals(e.readFileSync(t)))throw new Error(`predist: bundle copy differs from source: ${r.relative(REPO_DIR,s)}`)},i=(s,a)=>{const c=e.lstatSync(s);if(!c.isSymbolicLink())if(c.isFile())n(s,r.join(t,a));else for(const t of e.readdirSync(s))o(t)||i(r.join(s,t),a?r.join(a,t):t)};e.lstatSync(s).isFile()?n(s,t):i(s,"")}const h=12e4,p=6e5,u=50,m="AEGISONE_PREDIST_LOCK_TOKEN";let f=null,g=!1,j=0;function y(e){try{return process.kill(e,0),!0}catch(e){return Boolean(e)&&"EPERM"===e.code}}const v=e=>new Promise((r=>setTimeout(r,e)));function w(){if(j>0)return void j--;const r=f,s=g,t=process.env[m];if(f=null,g=!1,r&&s){t&&delete process.env[m];try{e.unlinkSync(r)}catch{}}}export async function acquireStageLock(s){if(f)return j++,w;const t=s&&s.stdout||process.stdout;return await async function(s){const t=function(){const s=r.join(REPO_DIR,".git");let t=s;try{if(!e.lstatSync(s).isDirectory()){const o=/^gitdir:\s*(.+)$/m.exec(e.readFileSync(s,"utf8"));o&&(t=r.resolve(REPO_DIR,o[1].trim()))}}catch{t=s}return r.join(t,"aegisone-predist.lock")}(),o=Date.now()+h,n=process.env[m]||null;let i=null,a=!1;for(;;){if(n)try{const r=String(e.readFileSync(t,"utf8")).split("\n")[1];if(r&&r.trim()===n)return f=t,void(g=!1)}catch{}try{i=`${Date.now().toString(36)}-${process.pid}-${Math.random().toString(36).slice(2,10)}`;const r=e.openSync(t,"wx");return e.writeSync(r,`${process.pid}\n${i}\n`),e.closeSync(r),f=t,g=!0,void(process.env[m]=i)}catch(e){if(!e||"EEXIST"!==e.code)throw e}let r=null,c=0;try{r=e.statSync(t),c=Number(String(e.readFileSync(t,"utf8")).split("\n")[0].trim())}catch{continue}if(Date.now()-r.mtimeMs>p||Number.isFinite(c)&&c>0&&!y(c)){s(`predist: breaking an abandoned staging lock (pid ${c||"unknown"})`);try{e.unlinkSync(t)}catch{}}else{if(Date.now()>o)throw new Error(`predist: another stager (pid ${c||"unknown"}) has held ${t} for over ${Math.round(h/1e3)}s. Staging is destructive — it removes and rewrites cli/vendor, desktop/vendor and one/vendor — so it will not run concurrently with a peer. Wait for it, or delete the lock if that process is gone.`);a||(a=!0,s(`predist: another stager (pid ${c||"unknown"}) is running — waiting for it (concurrent staging would read a vendor tree the peer is rewriting)`)),await v(u+Math.floor(Math.random()*u))}}}((e=>t.write(`${e}\n`))),w}function b(s,t){t&&e.rmSync(t,{recursive:!0,force:!0});const o=[];for(const t of s){if(!e.existsSync(t.from))throw new Error(`predist: missing shared module: ${t.src} (expected at ${t.from})`);if(e.mkdirSync(r.dirname(t.dest),{recursive:!0}),e.copyFileSync(t.from,t.dest),!e.readFileSync(t.from).equals(e.readFileSync(t.dest)))throw new Error(`predist: staged copy differs from source: ${t.src}`);o.push(t)}return o}export async function stage(t){const n=t||{},i=n.io||{},l=i.stdout||process.stdout,h=(i.stderr||process.stderr,Array.isArray(n.shapes)?n.shapes:[...SHAPES,"bundle"]),p=e=>h.includes(e),u=e=>l.write(`${e}\n`),m=await acquireStageLock(i);try{return await async function({want:t,log:n}){const i={mirror:null,flat:null,nested:null,bundle:null};if(t("mirror")){const e=b(entriesFor("mirror"),CLI_VENDOR);n(`predist: staged ${e.length} shared modules into cli/vendor/`);for(const r of e)n(` ${r.src} -> vendor/${r.src}`);i.mirror={staged:e.length}}if(t("nested")&&(i.nested={staged:b(entriesFor("nested"),null).length}),t("flat")){const e=b(entriesFor("flat"),null);for(const r of e)n(`staged ${r.dest}`);i.flat={staged:e.length}}if(t("mirror")&&t("flat"))for(const s of MANIFEST){if(!s.shapes.includes("mirror")||!s.shapes.includes("flat"))continue;const t=r.join(CLI_VENDOR,s.src),o=r.join(DESKTOP_VENDOR,r.basename(s.src));if(!e.readFileSync(t).equals(e.readFileSync(o)))throw new Error(`predist: the two shapes disagree for ${s.src}`)}if(t("mirror")){const s=function(s){const t=r.join(CLI_VENDOR,"mcp","tools.js");delete a.cache[a.resolve(t)];const{createTools:o}=a(t),n=o({apiBase:"http://127.0.0.1",apiKey:"predist-probe",randomUUID:()=>"id"}).toolList().length;if(0===n)throw new Error("predist: staged registry exposes no tools");const i=a("node:vm"),c=r.join(CLI_VENDOR,"mcp","server.js");new i.Script(e.readFileSync(c,"utf8"),{filename:c});const l=r.join(CLI_VENDOR,"hosts"),d=a(r.join(l,"spec.js")),h=a(r.join(l,"install.js")),p=a(r.join(l,"targets.js")),u=d.resolveServer({AEGIS_MCP_SERVER:""});if(!u.exists||u.path!==c)throw new Error(`predist: staged hosts/spec.js resolves the server as ${u.path} (exists: ${u.exists}), expected ${c}. An installed aegiscode would write editor configs pointing at a file the package never shipped. Candidates were:\n ${u.candidates.join("\n ")}`);const m=p.getTarget("vscode"),f=h.planTarget(m,"user",{ctx:h.hostCtx({home:r.join(CLI_VENDOR,".predist-home"),env:{},cwd:REPO_DIR}),specOpts:{env:{AEGIS_MCP_SERVER:""}}}),g=JSON.stringify(f.after||"");if(f.error||!f.changed||!g.includes(JSON.stringify(c).slice(1,-1)))throw new Error(`predist: a planned vscode install does not name the staged server (error: ${f.error&&f.error.message}, changed: ${f.changed})`);if("function"!=typeof a(r.join(l,"openai-shim.js")).createShimServer)throw new Error("predist: staged hosts/openai-shim.js exposes no createShimServer");return{count:n,targets:p.targetIds().length,staged:s.length}}(entriesFor("mirror"));n(`predist: staged registry loads standalone (${s.count} tools)`),n(`predist: editor layer verified (${s.targets} host targets, server resolves to vendor/mcp/server.js, shim loads)`);const t=await async function(){const e=r.join(CLI_VENDOR,"tools","agent-gate.mjs");if("function"!=typeof(await import(o(e).href)).run)throw new Error("predist: staged tools/agent-gate.mjs exposes no run()");return e}();n(`predist: ${r.relative(REPO_DIR,t)} loads standalone and exposes run()`),i.mirror.proof=s}if(t("flat")){const s=function(s){const t=new Set(s.map((e=>r.basename(e.dest))));for(const o of s){const s=e.readFileSync(o.dest,"utf8").replace(/\/\*[\s\S]*?\*\//g,"").replace(/(^|[^:])\/\/.*$/gm,"$1");for(const e of s.matchAll(/require\(\s*'((?:\.\.?\/)[^']+)'\s*\)/g)){const s=e[1];if(r.basename(s).replace(/\.[cm]?js$/,""),s.replace(/^\.\//,"").startsWith("../"))throw new Error(`predist: flat-staged ${r.basename(o.dest)} requires '${s}', which escapes vendor/ — flattening only works for same-directory requires (add the target to the manifest, or stop staging this file flat)`);const n=s.replace(/^\.\//,"");if(!t.has(n))throw new Error(`predist: flat-staged ${r.basename(o.dest)} requires '${s}', which is not staged into desktop/vendor/ — the packaged app would throw MODULE_NOT_FOUND before the window could open`)}}const o=a(r.join(DESKTOP_VENDOR,"aegis.js"));if(!o||0===Object.keys(o).length)throw new Error("predist: staged desktop/vendor/aegis.js loads but exports nothing");return{files:s.length,exports:Object.keys(o).length}}(entriesFor("flat"));n(`predist: flattened tree is self-contained (${s.files} files, ${s.exports} transport exports) — no staged module escapes vendor/`),i.flat.proof=s}if(t("bundle")){for(const[s,t,o]of c){const i=r.join(ONE_VENDOR,s);e.rmSync(i,{recursive:!0,force:!0});for(const s of o){const o=r.join(t,s);if(!e.existsSync(o)){if("LICENSE"===s||"README.md"===s)continue;throw new Error(`predist: bundle source missing: ${r.relative(REPO_DIR,o)}`)}d(o,r.join(i,s))}n(`staged the ${s} face into one/vendor/${s}/`)}const t=function(){const t=r.join(ONE_VENDOR,"cli"),o=r.join(t,"src","deps.js"),n=s(process.execPath,["-e","const d=require(process.argv[1]);console.log(JSON.stringify(d.paths))",o],{cwd:t,encoding:"utf8"});if(0!==n.status)throw new Error(`predist: the bundled CLI does not load: ${n.stderr||n.stdout}`);const i=JSON.parse(n.stdout),a=[];let l=0;for(const[e,s]of Object.entries(i)){const t=r.relative(ONE_VENDOR,s);t.startsWith("..")||r.isAbsolute(t)?a.push(`${e} -> ${s}`):"cli"!==t.split(r.sep)[0]&&l++}if(a.length)throw new Error(`predist: the bundled CLI resolves these shared modules OUTSIDE the bundle (${ONE_VENDOR}) — the product tarball would depend on a repo checkout:\n `+a.join("\n "));if(!e.existsSync(r.join(t,"bin","aegiscode.js")))throw new Error("predist: the bundle has no cli/bin/aegiscode.js");const d=[];for(const[s,t,o]of c)for(const n of o){const o=r.join(ONE_VENDOR,s,n);let i=null,a=null;try{i=e.lstatSync(r.join(t,n))}catch{continue}try{a=e.lstatSync(o)}catch{d.push(`${s}/${n} -> missing`);continue}i.isFile()&&!a.isFile()&&d.push(`${s}/${n} -> not a regular file`),i.isDirectory()&&!a.isDirectory()&&d.push(`${s}/${n} -> not a directory`)}if(d.length)throw new Error(`predist: the bundle staged these in the wrong shape:\n ${d.join("\n ")}`);return{modules:Object.keys(i).length,inSiblingFace:l}}();n(`predist: the bundled CLI resolves ${t.modules} shared modules from inside one/vendor/ (${t.inSiblingFace} through the bundled desktop face) — no repo checkout needed`),i.bundle=t;const o=r.join(DESKTOP_VENDOR,"faces");e.rmSync(o,{recursive:!0,force:!0}),d(r.join(ONE_VENDOR,"cli"),r.join(o,"cli"));const a=r.join(o,"cli","bin","aegiscode.js");if(!e.existsSync(a))throw new Error(`predist: the packaged terminal face has no entry point at ${r.relative(REPO_DIR,a)} — the artifact would open a window for every \`aegiscode\`/\`--tui\` invocation`);n(`staged the terminal face into desktop/vendor/faces/cli/ (${r.basename(a)})`),i.faces={entry:r.relative(REPO_DIR,a)}}return i}({want:p,log:u})}finally{m()}}export async function main(e,r){const s=r||{},t=Array.isArray(e)?e:[],o=t.includes("--quiet")?{write:()=>!0}:s.stdout||process.stdout,n=s.stderr||process.stderr;let i;t.includes("--mirror-only")?i=["mirror"]:t.includes("--flat-only")?i=["flat","nested"]:t.includes("--bundle-only")&&(i=["bundle"]);try{return await stage({shapes:i,io:{stdout:o,stderr:n}}),0}catch(e){return n.write(`${e&&e.message}\n`),1}}!function(){const e=process.argv[1];let s=!1;if(e)try{s=r.resolve(e)===t(import.meta.url)}catch{s=!1}s&&main(process.argv.slice(2)).then((e=>{process.exitCode=e}))}();
4
+ import e from"node:fs";import s from"node:path";import{spawnSync as r}from"node:child_process";import{fileURLToPath as t,pathToFileURL as o}from"node:url";import{createRequire as n}from"node:module";const i=s.dirname(t(import.meta.url)),a=n(import.meta.url);export const ONE_DIR=s.join(i,"..");export const REPO_DIR=s.join(ONE_DIR,"..");export const CLI_DIR=s.join(REPO_DIR,"cli");export const DESKTOP_DIR=s.join(REPO_DIR,"desktop");export const CLI_VENDOR=s.join(CLI_DIR,"vendor");export const DESKTOP_VENDOR=s.join(DESKTOP_DIR,"vendor");export const ONE_VENDOR=s.join(ONE_DIR,"vendor");export const MANIFEST=[{src:"client/aegis.js",shapes:["mirror","flat"],note:"the thin transport — the one implementation of the wire format"},{src:"client/update.js",shapes:["mirror","flat"],note:"the npm update checker (the desktop own update path)"},{src:"client/foreign-memory.js",shapes:["mirror","flat"],note:"required by mcp/tools.js as ../client/foreign-memory.js"},{src:"client/foreign-sessions.js",shapes:["mirror","flat"],note:"required by desktop/main.js as ./vendor/foreign-sessions.js"},{src:"client/credentials.js",shapes:["mirror","flat"],note:"the account credential store, shared by all three hosts"},{src:"client/session-store.js",shapes:["mirror","flat"],note:"the unified session store — one list in every host"},{src:"client/session-search.js",shapes:["mirror","flat"],note:"the SESSION search ranking: the desktop sheet (Cmd/Ctrl+K) and the terminal /resume picker filter with this one module, pure and fs-free"},{src:"client/credits.js",shapes:["mirror","flat"],note:"the licence/attribution payload: parses LICENSING.md and the two NOTICE files for Help > Credits & licence and /license + /credits"},{src:"client/naming.js",shapes:["mirror","flat"],note:"the conversation-naming ladder — ONE implementation for the terminal and the window (cli/src/naming.js re-exports it)"},{src:"client/prefs.js",shapes:["mirror","flat"],note:"the shared non-secret preference store (D5) — the CLI and the desktop store both read/write it"},{src:"client/env-file.js",shapes:["mirror","flat"],note:"the shared ~/.aegiscode/.env loader, resolved before any key is read"},{src:"client/auto-provision.js",shapes:["mirror","flat"],note:"free device key on first launch; requires ./device-fingerprint.js"},{src:"client/device-fingerprint.js",shapes:["mirror","flat"],note:"the machine identity auto-provision.js and presence.js require"},{src:"client/presence.js",shapes:["mirror","flat"],note:"the heartbeat beacon; requires ./presence-constants.js and ./device-fingerprint.js"},{src:"client/presence-constants.js",shapes:["mirror","flat"],note:"the beacon constants — a package without them loses the beacon silently"},{src:"client/touch.js",shapes:["mirror","flat"],note:"phi(alpha): the digest module fingerprint.js requires as ./touch.js"},{src:"client/fingerprint.js",shapes:["mirror","flat"],note:"phi(alpha): the sealed session record, resolved by src/fingerprint.js"},{src:"client/authorship-key.js",shapes:["mirror","flat"],note:"phi(alpha): the authorship key, required by ./attest.js and ./record-vault.js"},{src:"client/attest.js",shapes:["mirror","flat"],note:"phi(alpha): attestation, requires ./fingerprint.js and ./authorship-key.js"},{src:"client/record-vault.js",shapes:["mirror","flat"],note:"the vault, and its refusal to copy the key with the record"},{src:"client/brain-catalog.js",shapes:["mirror","flat"],note:"the pooled-brain rule, required at load time by the engine and src/models.js"},{src:"client/byok-catalog.js",shapes:["mirror","flat"],note:"the BYOK model additions the server catalog does not name"},{src:"client/catalog-client.js",shapes:["mirror","flat"],note:"the server's cached catalog, layered between the shipped additions and the user's own models"},{src:"client/user-models.js",shapes:["mirror","flat"],note:"the models the USER declares, in one file both hosts read (requires ./credentials.js)"},{src:"client/model-discovery.js",shapes:["mirror","flat"],note:"asks the vendor what it serves, so adding a new model is not a memory test (requires ./user-models.js)"},{src:"client/hooks.js",shapes:["mirror","flat"],note:"the shared hook layer behind /hooks and the repo guard installer"},{src:"client/platform.js",shapes:["mirror","flat"],note:"the ONE place that decides which OS this is (Phase 30.1)"},{src:"client/topup.js",shapes:["mirror","flat"],note:"the token-bank top-up: amount bounds, the balance reading, and the credit watch every host drives"},{src:"client/google-signin.js",shapes:["mirror","flat"],note:"the localhost half of aegis1's desktop Google OAuth round-trip; `connect --google` drives it"},{src:"client/drive-connect.js",shapes:["mirror","flat"],note:"the desktop half of aegis1's Drive OAuth (/connect/drive, /api/drive/token); requires ./aegis.js only via the caller"},{src:"client/drive-upload.js",shapes:["mirror","flat"],note:"the Drive v3 REST wrapper that uploads the memory backup and one conversation per save"},{src:"client/conversation-export.js",shapes:["mirror","flat"],note:"the authorship stamp at the top of every uploaded file, and the two backup scope names"},{src:"mcp/tools.js",shapes:["mirror"],note:"the shared tool registry; requires ../client/foreign-memory.js"},{src:"mcp/server.js",shapes:["mirror"],note:"the stdio MCP server every installed editor config names (compiled, never required)"},{src:"mcp/admission.js",shapes:["mirror"],note:"the admission gate server.js requires at load (`./admission.js`): which harness may call the bridge, and what it may run — omitted from the manifest when 2066f82 added it, so both staged trees shipped a server that could not load"},{src:"hosts/spec.js",shapes:["mirror"],note:"the canonical server spec, staged under its own directory so it finds vendor/mcp/server.js"},{src:"hosts/targets.js",shapes:["mirror"],note:"the editor target registry"},{src:"hosts/install.js",shapes:["mirror"],note:"the merge-only installer behind aegiscode mcp install"},{src:"hosts/openai-shim.js",shapes:["mirror"],note:"the loopback OpenAI-compatible shim"},{src:"desktop/renderer/usage.js",shapes:["mirror"],note:"the pure usage mapping shared by the window and the terminal"},{src:"desktop/lib/local/engine.js",shapes:["mirror"],note:"the agent loop, reused as-is (one loop, not a second one drifting)"},{src:"desktop/lib/local/claude-pro.js",shapes:["mirror"],note:"the Claude Code Pro transport; requires ./../../one/src/child.js at call time"},{src:"one/src/child.js",shapes:["mirror"],note:"the ONE claude-child argv builder (rule 4); resolved by claude-pro.js at call time"},{src:"one/src/permissions.js",shapes:["mirror"],note:"resolvePosture() — the permission half of the argv, resolved at call time"},{src:"desktop/lib/local/local.js",shapes:["mirror"],note:"the local model transport and its fail-closed base-URL check"},{src:"desktop/lib/local/context.js",shapes:["mirror"],note:"the token-budget trimmer local.js requires at load"},{src:"desktop/lib/local/attachments.js",shapes:["mirror"],note:"content-part builder for dropped files; required at load by engine.js and local.js"},{src:"desktop/lib/local/session-rounds.js",shapes:["mirror"],note:"interrupted-turn bookkeeping; required at load by engine.js"},{src:"desktop/lib/local/pro-sessions.js",shapes:["mirror"],note:"durable Claude-Pro conversation session ids; required at load by engine.js"},{src:"desktop/lib/local/tools.js",shapes:["mirror"],note:"the tool implementations (persistent shell, editFile, grep, exec)"},{src:"desktop/lib/local/shell.js",shapes:["mirror"],note:"the persistent shell, required by tools.js"},{src:"desktop/lib/local/sandbox.js",shapes:["mirror"],note:"the outcome bound (agent-safety-plan §1b), required by shell.js + tools.js"},{src:"desktop/lib/local/sandbox-bwrap.js",shapes:["mirror"],note:"bubblewrap mechanism behind sandbox.js (agent-safety-plan §1d)"},{src:"desktop/lib/local/sandbox-seatbelt.js",shapes:["mirror"],note:"Seatbelt mechanism behind sandbox.js (agent-safety-plan §1d)"},{src:"desktop/lib/local/sandbox-appcontainer.js",shapes:["mirror"],note:"AppContainer mechanism behind sandbox.js (agent-safety-plan §1e)"},{src:"desktop/lib/local/perm-rules.js",shapes:["mirror"],note:"stored /permissions rules for the desktop gate (agent-safety-plan §2), required by engine.js"},{src:"desktop/lib/local/perm-write.js",shapes:["mirror"],note:'the durable "always allow this command" answer (agent-safety-plan §3), required by main.js'},{src:"desktop/lib/local/perm-store.js",shapes:["mirror"],note:"the Settings rules editor (agent-safety-plan §4), required by main.js"},{src:"desktop/lib/local/integrity.js",shapes:["mirror"],note:"the desktop second gate; required at load by shell.js and tools.js, and the seal over its own four units"},{src:"desktop/main.js",shapes:["mirror"],bytesOnly:!0,note:"seal unit d1 — hashed by integrity.js as BYTES and never required from the mirror, so its own requires (the whole Electron main-process closure) are not staged behind it"},{src:"desktop/lib/local/spill.js",shapes:["mirror"],note:"oversized-output spill, required at load by tools.js and shell.js"},{src:"desktop/lib/local/exec-plan.js",shapes:["mirror"],note:"exec one-shot eligibility classifier, required at load by engine.js"},{src:"desktop/lib/local/agents.js",shapes:["mirror"],note:"Task subagents"},{src:"desktop/lib/local/prompt.js",shapes:["mirror"],note:"the system prompt builder"},{src:"desktop/lib/settings.js",shapes:["mirror"],note:"the provider-config store (base URL + key per provider)"},{src:"desktop/lib/local/turn-guard.js",shapes:["mirror"],note:"engine.js requires it at load; it requires ./git-scope.js"},{src:"desktop/lib/local/worktree-lock.js",shapes:["mirror"],note:"engine.js requires it at load"},{src:"desktop/lib/local/git-scope.js",shapes:["mirror"],note:"the write-scope rule turn-guard.js and the queues share"},{src:"desktop/lib/local/queue.js",shapes:["mirror"],note:"the autonomous work queue"},{src:"desktop/lib/local/autonomous.js",shapes:["mirror"],note:"the unattended worker; requires ./queue.js and ./git-scope.js"},{src:"desktop/lib/local/entitlement.js",shapes:["mirror"],note:"the shared Pro gate (account probe injected by the caller)"},{src:"desktop/lib/local/covenant.js",shapes:["mirror"],note:"the pre-action gate engine.js requires unconditionally at load"},{src:"desktop/lib/local/aegis-seal.mjs",shapes:["mirror"],note:"the codec covenant.js requires the first time it decodes"},{src:"covenant/aegis.seal",shapes:["mirror","nested"],note:"the sealed covenant (AES/1 container) — path shape is load-bearing"},{src:"covenant/README.md",shapes:["mirror","nested"],note:"the decode notice shipped beside the artifact"},{src:"tools/agent-gate.mjs",shapes:["mirror","flat"],note:"the in-process half of the lock; without it a packaged app had NO gate"},{src:"one/src/selfhost.js",shapes:["mirror","flat"],note:"the packaged launcher decision — which face this artifact was asked for"}];export function entriesFor(e){const r=[];for(const t of MANIFEST){if(!t.shapes.includes(e))continue;let o;if("mirror"===e)o=s.join(CLI_VENDOR,t.src);else if("flat"===e)o=s.join(DESKTOP_VENDOR,s.basename(t.src));else{if("nested"!==e)throw new Error(`predist: unknown shape ${e}`);o=s.join(DESKTOP_VENDOR,t.src)}r.push({src:t.src,dest:o,from:s.join(REPO_DIR,t.src)})}return r}export const SHAPES=["mirror","flat","nested"];const c=[["cli",CLI_DIR,["bin","src","vendor","scripts","package.json","README.md","LICENSE"]],["desktop",DESKTOP_DIR,["main.js","preload.js","lib","renderer","bin","vendor","package.json","README.md"]]],l=new Set(["node_modules","release",".git",".cache","out"]),d=new Map([["desktop/vendor",new Set(["faces","sandbox"])]]);function p(r,t,o){const n=o||new Set,i=(e,s)=>l.has(e)||e.endsWith(".log")||n.has(s),a=(r,t)=>{if(e.mkdirSync(s.dirname(t),{recursive:!0}),e.copyFileSync(r,t),!e.readFileSync(r).equals(e.readFileSync(t)))throw new Error(`predist: bundle copy differs from source: ${s.relative(REPO_DIR,r)}`)},c=(r,o)=>{const n=e.lstatSync(r);if(!n.isSymbolicLink())if(n.isFile())a(r,s.join(t,o));else for(const t of e.readdirSync(r)){const e=o?s.join(o,t):t;i(t,e)||c(s.join(r,t),e)}};e.lstatSync(r).isFile()?a(r,t):c(r,"")}const h=12e4,u=6e5,m=50,f="AEGISONE_PREDIST_LOCK_TOKEN";let g=null,j=!1,y=0;function b(e){try{return process.kill(e,0),!0}catch(e){return Boolean(e)&&"EPERM"===e.code}}const w=e=>new Promise((s=>setTimeout(s,e)));function v(){if(y>0)return void y--;const s=g,r=j,t=process.env[f];if(g=null,j=!1,s&&r){t&&delete process.env[f];try{e.unlinkSync(s)}catch{}}}export async function acquireStageLock(r){if(g)return y++,v;const t=r&&r.stdout||process.stdout;return await async function(r){const t=function(){const r=s.join(REPO_DIR,".git");let t=r;try{if(!e.lstatSync(r).isDirectory()){const o=/^gitdir:\s*(.+)$/m.exec(e.readFileSync(r,"utf8"));o&&(t=s.resolve(REPO_DIR,o[1].trim()))}}catch{t=r}return s.join(t,"aegisone-predist.lock")}(),o=Date.now()+h,n=process.env[f]||null;let i=null,a=!1;for(;;){if(n)try{const s=String(e.readFileSync(t,"utf8")).split("\n")[1];if(s&&s.trim()===n)return g=t,void(j=!1)}catch{}try{i=`${Date.now().toString(36)}-${process.pid}-${Math.random().toString(36).slice(2,10)}`;const s=e.openSync(t,"wx");return e.writeSync(s,`${process.pid}\n${i}\n`),e.closeSync(s),g=t,j=!0,void(process.env[f]=i)}catch(e){if(!e||"EEXIST"!==e.code)throw e}let s=null,c=0;try{s=e.statSync(t),c=Number(String(e.readFileSync(t,"utf8")).split("\n")[0].trim())}catch{continue}if(Date.now()-s.mtimeMs>u||Number.isFinite(c)&&c>0&&!b(c)){r(`predist: breaking an abandoned staging lock (pid ${c||"unknown"})`);try{e.unlinkSync(t)}catch{}}else{if(Date.now()>o)throw new Error(`predist: another stager (pid ${c||"unknown"}) has held ${t} for over ${Math.round(h/1e3)}s. Staging is destructive — it removes and rewrites cli/vendor, desktop/vendor and one/vendor — so it will not run concurrently with a peer. Wait for it, or delete the lock if that process is gone.`);a||(a=!0,r(`predist: another stager (pid ${c||"unknown"}) is running — waiting for it (concurrent staging would read a vendor tree the peer is rewriting)`)),await w(m+Math.floor(Math.random()*m))}}}((e=>t.write(`${e}\n`))),v}function E(r,t){t&&e.rmSync(t,{recursive:!0,force:!0});const o=[];for(const t of r){if(!e.existsSync(t.from))throw new Error(`predist: missing shared module: ${t.src} (expected at ${t.from})`);if(e.mkdirSync(s.dirname(t.dest),{recursive:!0}),e.copyFileSync(t.from,t.dest),!e.readFileSync(t.from).equals(e.readFileSync(t.dest)))throw new Error(`predist: staged copy differs from source: ${t.src}`);o.push(t)}return o}export async function stage(t){const n=t||{},i=n.io||{},l=i.stdout||process.stdout,h=(i.stderr||process.stderr,Array.isArray(n.shapes)?n.shapes:[...SHAPES,"bundle"]),u=e=>h.includes(e),m=e=>l.write(`${e}\n`),f=await acquireStageLock(i);try{return await async function({want:t,log:n}){const i={mirror:null,flat:null,nested:null,bundle:null};if(t("mirror")){const e=E(entriesFor("mirror"),CLI_VENDOR);n(`predist: staged ${e.length} shared modules into cli/vendor/`);for(const s of e)n(` ${s.src} -> vendor/${s.src}`);i.mirror={staged:e.length}}if(t("nested")&&(i.nested={staged:E(entriesFor("nested"),null).length}),t("flat")){const e=E(entriesFor("flat"),null);for(const s of e)n(`staged ${s.dest}`);i.flat={staged:e.length}}if(t("mirror")&&t("flat"))for(const r of MANIFEST){if(!r.shapes.includes("mirror")||!r.shapes.includes("flat"))continue;const t=s.join(CLI_VENDOR,r.src),o=s.join(DESKTOP_VENDOR,s.basename(r.src));if(!e.readFileSync(t).equals(e.readFileSync(o)))throw new Error(`predist: the two shapes disagree for ${r.src}`)}if(t("mirror")){const r=function(r){const t=s.join(CLI_VENDOR,"mcp","tools.js");delete a.cache[a.resolve(t)];const{createTools:o}=a(t),n=o({apiBase:"http://127.0.0.1",apiKey:"predist-probe",randomUUID:()=>"id"}).toolList().length;if(0===n)throw new Error("predist: staged registry exposes no tools");const i=a("node:vm"),c=s.join(CLI_VENDOR,"mcp","server.js");new i.Script(e.readFileSync(c,"utf8"),{filename:c});const l=s.join(CLI_VENDOR,"hosts"),d=a(s.join(l,"spec.js")),p=a(s.join(l,"install.js")),h=a(s.join(l,"targets.js")),u=d.resolveServer({AEGIS_MCP_SERVER:""});if(!u.exists||u.path!==c)throw new Error(`predist: staged hosts/spec.js resolves the server as ${u.path} (exists: ${u.exists}), expected ${c}. An installed aegiscode would write editor configs pointing at a file the package never shipped. Candidates were:\n ${u.candidates.join("\n ")}`);const m=h.getTarget("vscode"),f=p.planTarget(m,"user",{ctx:p.hostCtx({home:s.join(CLI_VENDOR,".predist-home"),env:{},cwd:REPO_DIR}),specOpts:{env:{AEGIS_MCP_SERVER:""}}}),g=JSON.stringify(f.after||"");if(f.error||!f.changed||!g.includes(JSON.stringify(c).slice(1,-1)))throw new Error(`predist: a planned vscode install does not name the staged server (error: ${f.error&&f.error.message}, changed: ${f.changed})`);if("function"!=typeof a(s.join(l,"openai-shim.js")).createShimServer)throw new Error("predist: staged hosts/openai-shim.js exposes no createShimServer");return{count:n,targets:h.targetIds().length,staged:r.length}}(entriesFor("mirror"));n(`predist: staged registry loads standalone (${r.count} tools)`),n(`predist: editor layer verified (${r.targets} host targets, server resolves to vendor/mcp/server.js, shim loads)`);const t=await async function(){const e=s.join(CLI_VENDOR,"tools","agent-gate.mjs");if("function"!=typeof(await import(o(e).href)).run)throw new Error("predist: staged tools/agent-gate.mjs exposes no run()");return e}();n(`predist: ${s.relative(REPO_DIR,t)} loads standalone and exposes run()`),i.mirror.proof=r}if(t("flat")){const r=function(r){const t=new Set(r.map((e=>s.basename(e.dest))));for(const o of r){const r=e.readFileSync(o.dest,"utf8").replace(/\/\*[\s\S]*?\*\//g,"").replace(/(^|[^:])\/\/.*$/gm,"$1");for(const e of r.matchAll(/require\(\s*'((?:\.\.?\/)[^']+)'\s*\)/g)){const r=e[1];if(s.basename(r).replace(/\.[cm]?js$/,""),r.replace(/^\.\//,"").startsWith("../"))throw new Error(`predist: flat-staged ${s.basename(o.dest)} requires '${r}', which escapes vendor/ — flattening only works for same-directory requires (add the target to the manifest, or stop staging this file flat)`);const n=r.replace(/^\.\//,"");if(!t.has(n))throw new Error(`predist: flat-staged ${s.basename(o.dest)} requires '${r}', which is not staged into desktop/vendor/ — the packaged app would throw MODULE_NOT_FOUND before the window could open`)}}const o=a(s.join(DESKTOP_VENDOR,"aegis.js"));if(!o||0===Object.keys(o).length)throw new Error("predist: staged desktop/vendor/aegis.js loads but exports nothing");return{files:r.length,exports:Object.keys(o).length}}(entriesFor("flat"));n(`predist: flattened tree is self-contained (${r.files} files, ${r.exports} transport exports) — no staged module escapes vendor/`),i.flat.proof=r}if(t("bundle")){for(const[r,t,o]of c){const i=s.join(ONE_VENDOR,r);e.rmSync(i,{recursive:!0,force:!0});for(const n of o){const o=s.join(t,n);if(!e.existsSync(o)){if("LICENSE"===n||"README.md"===n)continue;throw new Error(`predist: bundle source missing: ${s.relative(REPO_DIR,o)}`)}p(o,s.join(i,n),d.get(`${r}/${n}`))}n(`staged the ${r} face into one/vendor/${r}/`)}const t=function(){const t=s.join(ONE_VENDOR,"cli"),o=s.join(t,"src","deps.js"),n=r(process.execPath,["-e","const d=require(process.argv[1]);console.log(JSON.stringify(d.paths))",o],{cwd:t,encoding:"utf8"});if(0!==n.status)throw new Error(`predist: the bundled CLI does not load: ${n.stderr||n.stdout}`);const i=JSON.parse(n.stdout),a=[];let l=0;for(const[e,r]of Object.entries(i)){const t=s.relative(ONE_VENDOR,r);t.startsWith("..")||s.isAbsolute(t)?a.push(`${e} -> ${r}`):"cli"!==t.split(s.sep)[0]&&l++}if(a.length)throw new Error(`predist: the bundled CLI resolves these shared modules OUTSIDE the bundle (${ONE_VENDOR}) — the product tarball would depend on a repo checkout:\n `+a.join("\n "));if(!e.existsSync(s.join(t,"bin","aegiscode.js")))throw new Error("predist: the bundle has no cli/bin/aegiscode.js");const d=[];for(const[r,t,o]of c)for(const n of o){const o=s.join(ONE_VENDOR,r,n);let i=null,a=null;try{i=e.lstatSync(s.join(t,n))}catch{continue}try{a=e.lstatSync(o)}catch{d.push(`${r}/${n} -> missing`);continue}i.isFile()&&!a.isFile()&&d.push(`${r}/${n} -> not a regular file`),i.isDirectory()&&!a.isDirectory()&&d.push(`${r}/${n} -> not a directory`)}if(d.length)throw new Error(`predist: the bundle staged these in the wrong shape:\n ${d.join("\n ")}`);return{modules:Object.keys(i).length,inSiblingFace:l}}();n(`predist: the bundled CLI resolves ${t.modules} shared modules from inside one/vendor/ (${t.inSiblingFace} through the bundled desktop face) — no repo checkout needed`),i.bundle=t;const o=s.join(DESKTOP_VENDOR,"faces");e.rmSync(o,{recursive:!0,force:!0}),p(s.join(ONE_VENDOR,"cli"),s.join(o,"cli"));const a=s.join(o,"cli","bin","aegiscode.js");if(!e.existsSync(a))throw new Error(`predist: the packaged terminal face has no entry point at ${s.relative(REPO_DIR,a)} — the artifact would open a window for every \`aegiscode\`/\`--tui\` invocation`);n(`staged the terminal face into desktop/vendor/faces/cli/ (${s.basename(a)})`),i.faces={entry:s.relative(REPO_DIR,a)}}return i}({want:u,log:m})}finally{f()}}export async function main(e,s){const r=s||{},t=Array.isArray(e)?e:[],o=t.includes("--quiet")?{write:()=>!0}:r.stdout||process.stdout,n=r.stderr||process.stderr;let i;t.includes("--mirror-only")?i=["mirror"]:t.includes("--flat-only")?i=["flat","nested"]:t.includes("--bundle-only")&&(i=["bundle"]);try{return await stage({shapes:i,io:{stdout:o,stderr:n}}),0}catch(e){return n.write(`${e&&e.message}\n`),1}}!function(){const e=process.argv[1];let r=!1;if(e)try{r=s.resolve(e)===t(import.meta.url)}catch{r=!1}r&&main(process.argv.slice(2)).then((e=>{process.exitCode=e}))}();
package/src/child.js CHANGED
@@ -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 FLAGS=Object.freeze({headlessSkip:"--dangerously-skip-permissions",interactiveSkip:"--allow-dangerously-skip-permissions",permissionMode:"--permission-mode",allowedTools:"--allowedTools",disallowedTools:"--disallowedTools",print:"-p",outputFormat:"--output-format",model:"--model",sessionId:"--session-id",resume:"--resume",addDir:"--add-dir"});function addDirArgs(e){const s=[];for(const o of unique(e))s.push(`${FLAGS.addDir}=${o}`);return s}const UUID_RE=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,DEFAULT_OUTPUT_FORMAT="stream-json";function unique(e){const s=new Set,o=[];for(const i of Array.isArray(e)?e:[]){const e=String(i).trim();e&&!s.has(e)&&(s.add(e),o.push(e))}return o}function claudeArgv(e={}){const s=e.posture;if(!s||"object"!=typeof s)throw new Error("claudeArgv requires a resolved posture record (one/src/permissions.js resolvePosture)");const o=s.childKind,i="interactive"!==o,{PERMISSION_MODES:r}=require("./permissions.js"),n=void 0!==e.permissionMode&&null!==e.permissionMode,d=n?String(e.permissionMode):null;if(n&&!r.includes(d))throw new Error(`--permission-mode ${JSON.stringify(d)} is not one of ${r.join("|")} — refusing to pass (or to silently drop) a mode the child does not accept.`);const t=s.rules||{},l=unique(t.allow),a=unique(t.deny),u=unique(t.ask),p=e.resumeSessionId?String(e.resumeSessionId).trim():"",c=e.sessionId?String(e.sessionId).trim():"",m=p||null,h=!m&&c?c:null;for(const[e,s]of[["resumeSessionId",m],["sessionId",h]])if(s&&!UUID_RE.test(s))throw new Error(`${e} ${JSON.stringify(s)} is not a UUID — refusing to pass it to --resume/--session-id, which the child rejects after the spawn (turning a continuity bug into an opaque failed turn).`);const f=[];i&&f.push(FLAGS.print,FLAGS.outputFormat,String(e.outputFormat||"stream-json")),e.model&&f.push(FLAGS.model,String(e.model));const g=addDirArgs(e.addDir);f.push(...g),l.length&&f.push(FLAGS.allowedTools,l.join(",")),a.length&&f.push(FLAGS.disallowedTools,a.join(",")),n&&f.push(FLAGS.permissionMode,d),s.child&&s.child.flag&&f.push(s.child.flag),m?f.push(FLAGS.resume,m):h&&f.push(FLAGS.sessionId,h),Array.isArray(e.extra)&&f.push(...e.extra.map(String)),void 0!==e.prompt&&null!==e.prompt&&f.push(String(e.prompt));const S=Object.freeze({kind:o,permissionMode:d,permissionModePassed:n,skip:Boolean(s.child&&s.child.skip),skipFlag:s.child&&s.child.flag||null,allowedTools:Object.freeze(l),disallowedTools:Object.freeze(a),unmappedAsk:Object.freeze(u),addDir:Object.freeze(g.map((e=>e.slice(FLAGS.addDir.length+1)))),resumeSessionId:m,sessionId:h,argv:Object.freeze(f.slice())});return{argv:S.argv,record:S}}function childRecordLine(e){if(!e||"object"!=typeof e)return null;const s=e.permissionModePassed?`${FLAGS.permissionMode}=${e.permissionMode}`:"no --permission-mode (none was set)";return`aegis: claude child [${e.kind}] ${e.skipFlag||"no permission flag"} · ${s} · allowedTools=[${e.allowedTools.join(", ")}] disallowedTools=[${e.disallowedTools.join(", ")}]`+(e.unmappedAsk.length?` (ask rules recorded, unmapped: ${e.unmappedAsk.join(", ")})`:"")+(e.addDir&&e.addDir.length?` · addDir=[${e.addDir.join(", ")}]`:"")+(e.resumeSessionId?` · resumed session ${e.resumeSessionId}`:e.sessionId?` · new session ${e.sessionId}`:" · no session id (each turn is a new conversation)")}module.exports={FLAGS:FLAGS,DEFAULT_OUTPUT_FORMAT:"stream-json",claudeArgv:claudeArgv,addDirArgs:addDirArgs,childRecordLine:childRecordLine};
3
+ "use strict";const FLAGS=Object.freeze({headlessSkip:"--dangerously-skip-permissions",interactiveSkip:"--allow-dangerously-skip-permissions",permissionMode:"--permission-mode",allowedTools:"--allowedTools",disallowedTools:"--disallowedTools",print:"-p",outputFormat:"--output-format",model:"--model",sessionId:"--session-id",resume:"--resume",inputFormat:"--input-format",permissionPromptTool:"--permission-prompt-tool",addDir:"--add-dir"});function addDirArgs(e){const s=[];for(const o of unique(e))s.push(`${FLAGS.addDir}=${o}`);return s}const UUID_RE=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,DEFAULT_OUTPUT_FORMAT="stream-json";function unique(e){const s=new Set,o=[];for(const i of Array.isArray(e)?e:[]){const e=String(i).trim();e&&!s.has(e)&&(s.add(e),o.push(e))}return o}function claudeArgv(e={}){const s=e.posture;if(!s||"object"!=typeof s)throw new Error("claudeArgv requires a resolved posture record (one/src/permissions.js resolvePosture)");const o=s.childKind,i="interactive"!==o,{PERMISSION_MODES:r}=require("./permissions.js"),n=s.child&&"string"==typeof s.child.permissionMode?s.child.permissionMode:null,d=void 0!==e.permissionMode&&null!==e.permissionMode?String(e.permissionMode):null,t=null!==d||null!==n,l=null!==d?d:n;if(t&&!r.includes(l))throw new Error(`--permission-mode ${JSON.stringify(l)} is not one of ${r.join("|")} — refusing to pass (or to silently drop) a mode the child does not accept.`);const a=s.rules||{},p=unique(a.allow),u=unique(a.deny),c=unique(a.ask),m=e.resumeSessionId?String(e.resumeSessionId).trim():"",h=e.sessionId?String(e.sessionId).trim():"",g=m||null,f=!g&&h?h:null;for(const[e,s]of[["resumeSessionId",g],["sessionId",f]])if(s&&!UUID_RE.test(s))throw new Error(`${e} ${JSON.stringify(s)} is not a UUID — refusing to pass it to --resume/--session-id, which the child rejects after the spawn (turning a continuity bug into an opaque failed turn).`);const S=!0===e.askBridge&&!(s.child&&s.child.skip),A=[];i&&A.push(FLAGS.print,FLAGS.outputFormat,String(e.outputFormat||"stream-json")),e.model&&A.push(FLAGS.model,String(e.model));const F=addDirArgs(e.addDir);A.push(...F),p.length&&A.push(FLAGS.allowedTools,p.join(",")),u.length&&A.push(FLAGS.disallowedTools,u.join(",")),t&&A.push(FLAGS.permissionMode,l),s.child&&s.child.flag&&A.push(s.child.flag),S&&A.push(FLAGS.inputFormat,"stream-json",FLAGS.permissionPromptTool,"stdio"),g?A.push(FLAGS.resume,g):f&&A.push(FLAGS.sessionId,f),Array.isArray(e.extra)&&A.push(...e.extra.map(String)),S||void 0===e.prompt||null===e.prompt||A.push(String(e.prompt));const w=Object.freeze({kind:o,permissionMode:l,permissionModePassed:t,permissionModeSource:t?null!==d?"descriptor":"posture":null,permissionModeDropped:s&&s.permissionModeDropped||null,skip:Boolean(s.child&&s.child.skip),skipFlag:s.child&&s.child.flag||null,allowedTools:Object.freeze(p),disallowedTools:Object.freeze(u),unmappedAsk:Object.freeze(c),addDir:Object.freeze(F.map((e=>e.slice(FLAGS.addDir.length+1)))),resumeSessionId:g,sessionId:f,askBridge:S,argv:Object.freeze(A.slice())});return{argv:w.argv,record:w}}function childRecordLine(e){if(!e||"object"!=typeof e)return null;const s=e.permissionModePassed?`${FLAGS.permissionMode}=${e.permissionMode}`:e.permissionModeDropped?`no --permission-mode (asked for one, dropped: ${e.permissionModeDropped})`:"no --permission-mode (none was set)";return`aegis: claude child [${e.kind}] ${e.skipFlag||"no permission flag"} · ${s} · allowedTools=[${e.allowedTools.join(", ")}] disallowedTools=[${e.disallowedTools.join(", ")}]`+(e.unmappedAsk.length?` (ask rules recorded, unmapped: ${e.unmappedAsk.join(", ")})`:"")+(e.addDir&&e.addDir.length?` · addDir=[${e.addDir.join(", ")}]`:"")+(e.resumeSessionId?` · resumed session ${e.resumeSessionId}`:e.sessionId?` · new session ${e.sessionId}`:" · no session id (each turn is a new conversation)")+(e.askBridge?" · ask bridge (the child can raise approval cards)":" · no ask bridge (headless: unapproved tools auto-deny)")}module.exports={FLAGS:FLAGS,DEFAULT_OUTPUT_FORMAT:"stream-json",claudeArgv:claudeArgv,addDirArgs:addDirArgs,childRecordLine:childRecordLine};
@@ -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 path=require("node:path"),CHILD_KINDS=Object.freeze({HEADLESS:"headless",INTERACTIVE:"interactive"}),CONFIGURABLE_CLASSES=Object.freeze(["exec","writeFile","editFile"]),SKIP_FLAG="--dangerously-skip-permissions",FROZEN_CLASSES=Object.freeze(["write","shell","network","offDevice"]),PERMISSION_MODES=Object.freeze(["acceptEdits","auto","bypassPermissions","manual","dontAsk","plan"]);let cachedEvaluator=null,cachedConfig=null;function loadEvaluator(e){if(e)return e;if(cachedEvaluator)return cachedEvaluator;const o=[path.join(__dirname,"..","..","cli","src","permissions.js"),path.join(__dirname,"..","vendor","cli","src","permissions.js"),path.join(__dirname,"..","..","..","src","permissions.js")];for(const e of o)try{const o=require(e);if(o&&"function"==typeof o.evalPermission&&"function"==typeof o.resolveSkip)return cachedEvaluator=o,o}catch{}throw new Error("aegis: the one rule evaluator (cli/src/permissions.js) is missing from this install — refusing to resolve a permission posture from a second, unshared rule engine.")}function loadConfigStore(e){if(e)return e;if(cachedConfig)return cachedConfig;const o=[path.join(__dirname,"..","..","cli","src","config.js"),path.join(__dirname,"..","vendor","cli","src","config.js"),path.join(__dirname,"..","..","..","src","config.js")];for(const e of o)try{const o=require(e);if(o&&"function"==typeof o.confirmPosture)return cachedConfig=o,o}catch{}return null}function storedPermissionFacts(e={}){const o=loadConfigStore(e.config);if(!o)return{confirmationsOn:void 0,rules:void 0,source:"unavailable"};try{const e=o.confirmPosture();let r;try{r=o.loadPermissions()}catch{r=void 0}return{confirmationsOn:e&&"boolean"==typeof e.enabled?e.enabled:void 0,rules:r,source:e&&e.source||"unavailable"}}catch{return{confirmationsOn:void 0,rules:void 0,source:"unavailable"}}}function normalizeRules(e){const o=e&&"object"==typeof e?e:{},r=e=>Array.isArray(e)?e.map(String):[];return Object.freeze({defaultMode:"allow"===o.defaultMode||"deny"===o.defaultMode?o.defaultMode:"ask",allow:Object.freeze(r(o.allow)),deny:Object.freeze(r(o.deny)),ask:Object.freeze(r(o.ask)),explicitAsk:!0===o.explicitAsk||"ask"===o.defaultMode})}function resolvePosture(e={},o={}){const r=loadEvaluator(o.evaluator),s=normalizeRules(e.rules),i=!0===e.interactive,n=e.childKind===CHILD_KINDS.INTERACTIVE?CHILD_KINDS.INTERACTIVE:CHILD_KINDS.HEADLESS,a=r.resolveSkip({flag:!0===e.flag,env:e.env,interactive:i}),t=!1===e.gate,l=a.skip||t,c=a.skip?a.source:t?"posture":a.source,u=n===CHILD_KINDS.INTERACTIVE;return Object.freeze({version:1,rules:s,interactive:i,childKind:n,skip:l,skipSource:c,skipFromFlag:a.skip,envVarSet:a.envSet,storedGate:void 0===e.gate||null===e.gate?null:Boolean(e.gate),warned:a.warned,warning:a.warning||null,skipped:Object.freeze(l?CONFIGURABLE_CLASSES:[]),frozen:FROZEN_CLASSES,child:Object.freeze({kind:n,skip:l,flag:l?u?"--allow-dangerously-skip-permissions":"--dangerously-skip-permissions":null,why:l?u?"the interactive variant offers the bypass as an option (the child still asks; a human is there)":"the headless variant takes the bypass as a default, because no one can answer the child's prompt":"no skip was asked for, so no permission flag is passed to the child"})})}function gateFor(e,o,r,s={}){const i=loadEvaluator(s.evaluator),n=e&&e.rules?e.rules:normalizeRules({}),a=i.evalPermission(o,r,n);return"deny"===a?"deny":"allow"===a||e&&e.skip?"allow":"ask"}function skipReport(e){if(!e||!e.skip)return null;const o=e.child.flag?`; the ${e.child.kind} Claude child is passed ${e.child.flag}`:"";return`aegis: ${"posture"===e.skipSource?"automode (the stored confirmation posture both faces share)":"--dangerously-skip-permissions"} (via ${e.skipSource}) — skipping the configurable confirmation gates (${CONFIGURABLE_CLASSES.join(", ")})${o}. NOT skipped, and not reachable by any setting, flag or env var: the ÆGIS covenant pre-action assert and the ${FROZEN_CLASSES.join("|")} approvals (always 'ask'), plus any explicit deny rule.`}module.exports={CHILD_KINDS:CHILD_KINDS,CONFIGURABLE_CLASSES:CONFIGURABLE_CLASSES,FROZEN_CLASSES:FROZEN_CLASSES,PERMISSION_MODES:PERMISSION_MODES,SKIP_FLAG:SKIP_FLAG,loadEvaluator:loadEvaluator,loadConfigStore:loadConfigStore,storedPermissionFacts:storedPermissionFacts,normalizeRules:normalizeRules,resolvePosture:resolvePosture,gateFor:gateFor,skipReport:skipReport};
3
+ "use strict";const path=require("node:path"),CHILD_KINDS=Object.freeze({HEADLESS:"headless",INTERACTIVE:"interactive"}),CONFIGURABLE_CLASSES=Object.freeze(["exec","writeFile","editFile"]),SKIP_FLAG="--dangerously-skip-permissions",FROZEN_CLASSES=Object.freeze(["write","shell","network","offDevice"]),PERMISSION_MODES=Object.freeze(["acceptEdits","auto","bypassPermissions","manual","dontAsk","plan"]);let cachedEvaluator=null,cachedConfig=null;function loadEvaluator(e){if(e)return e;if(cachedEvaluator)return cachedEvaluator;const o=[path.join(__dirname,"..","..","cli","src","permissions.js"),path.join(__dirname,"..","vendor","cli","src","permissions.js"),path.join(__dirname,"..","..","..","src","permissions.js")];for(const e of o)try{const o=require(e);if(o&&"function"==typeof o.evalPermission&&"function"==typeof o.resolveSkip)return cachedEvaluator=o,o}catch{}throw new Error("aegis: the one rule evaluator (cli/src/permissions.js) is missing from this install — refusing to resolve a permission posture from a second, unshared rule engine.")}function loadConfigStore(e){if(e)return e;if(cachedConfig)return cachedConfig;const o=[path.join(__dirname,"..","..","cli","src","config.js"),path.join(__dirname,"..","vendor","cli","src","config.js"),path.join(__dirname,"..","..","..","src","config.js")];for(const e of o)try{const o=require(e);if(o&&"function"==typeof o.confirmPosture)return cachedConfig=o,o}catch{}return null}function storedPermissionFacts(e={}){const o=loadConfigStore(e.config);if(!o)return{confirmationsOn:void 0,rules:void 0,permissionMode:null,source:"unavailable"};try{const e=o.confirmPosture();let s;try{s=o.loadPermissions()}catch{s=void 0}let i=null;try{if("function"==typeof o.permissionMode){const e=o.permissionMode();"string"==typeof e&&PERMISSION_MODES.includes(e)&&(i=e)}}catch{i=null}return{confirmationsOn:e&&"boolean"==typeof e.enabled?e.enabled:void 0,rules:s,permissionMode:i,source:e&&e.source||"unavailable"}}catch{return{confirmationsOn:void 0,rules:void 0,permissionMode:null,source:"unavailable"}}}function normalizeRules(e){const o=e&&"object"==typeof e?e:{},s=e=>Array.isArray(e)?e.map(String):[];return Object.freeze({defaultMode:"allow"===o.defaultMode||"deny"===o.defaultMode?o.defaultMode:"ask",allow:Object.freeze(s(o.allow)),deny:Object.freeze(s(o.deny)),ask:Object.freeze(s(o.ask)),explicitAsk:!0===o.explicitAsk||"ask"===o.defaultMode})}function resolvePosture(e={},o={}){const s=loadEvaluator(o.evaluator),i=normalizeRules(e.rules),n=!0===e.interactive,r=e.childKind===CHILD_KINDS.INTERACTIVE?CHILD_KINDS.INTERACTIVE:CHILD_KINDS.HEADLESS,t=s.resolveSkip({flag:!0===e.flag,env:e.env,interactive:n}),a=!1===e.gate,l=t.skip||a,c=t.skip?t.source:a?"posture":t.source,u="string"==typeof e.permissionMode?e.permissionMode:null,d=null!==u&&PERMISSION_MODES.includes(u),p=d&&!l?u:null,f=null!==u&&!p,S=r===CHILD_KINDS.INTERACTIVE;return Object.freeze({version:1,rules:i,interactive:n,childKind:r,skip:l,skipSource:c,skipFromFlag:t.skip,envVarSet:t.envSet,storedGate:void 0===e.gate||null===e.gate?null:Boolean(e.gate),permissionMode:p,permissionModeAsked:d?u:null,permissionModeDropped:f?l?"a skip is in effect (--dangerously-skip-permissions or the stored posture), and the child may not be given two permission policies":"not one of "+PERMISSION_MODES.join("|"):null,warned:t.warned,warning:t.warning||null,skipped:Object.freeze(l?CONFIGURABLE_CLASSES:[]),frozen:FROZEN_CLASSES,child:Object.freeze({kind:r,skip:l,permissionMode:p,flag:l?S?"--allow-dangerously-skip-permissions":"--dangerously-skip-permissions":null,why:l?S?"the interactive variant offers the bypass as an option (the child still asks; a human is there)":"the headless variant takes the bypass as a default, because no one can answer the child's prompt":"no skip was asked for, so no permission flag is passed to the child"})})}function gateFor(e,o,s,i={}){const n=loadEvaluator(i.evaluator),r=e&&e.rules?e.rules:normalizeRules({}),t=n.evalPermission(o,s,r);return"deny"===t?"deny":"allow"===t||e&&e.skip?"allow":"ask"}function skipReport(e){if(!e||!e.skip)return null;const o=e.child.flag?`; the ${e.child.kind} Claude child is passed ${e.child.flag}`:"";return`aegis: ${"posture"===e.skipSource?"automode (the stored confirmation posture both faces share)":"--dangerously-skip-permissions"} (via ${e.skipSource}) — skipping the configurable confirmation gates (${CONFIGURABLE_CLASSES.join(", ")})${o}. NOT skipped, and not reachable by any setting, flag or env var: the ÆGIS covenant pre-action assert and the ${FROZEN_CLASSES.join("|")} approvals (always 'ask'), plus any explicit deny rule.`}module.exports={CHILD_KINDS:CHILD_KINDS,CONFIGURABLE_CLASSES:CONFIGURABLE_CLASSES,FROZEN_CLASSES:FROZEN_CLASSES,PERMISSION_MODES:PERMISSION_MODES,SKIP_FLAG:SKIP_FLAG,loadEvaluator:loadEvaluator,loadConfigStore:loadConfigStore,storedPermissionFacts:storedPermissionFacts,normalizeRules:normalizeRules,resolvePosture:resolvePosture,gateFor:gateFor,skipReport:skipReport};
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "aegiscode",
3
3
  "productName": "AEGIS Code",
4
- "version": "7.0.30",
4
+ "version": "7.0.32",
5
5
  "description": "aegiscode — the command-line version of AEGIS Desktop. The shared tool surface in your shell, over the same thin transport and tool registry as the MCP plugin and the desktop app. Ships transport + UI only; no brain.",
6
6
  "author": {
7
7
  "name": "AEGIS Code",
@@ -19,7 +19,9 @@
19
19
  "scripts",
20
20
  "vendor",
21
21
  "README.md",
22
- "SOURCE-OFFER.txt"
22
+ "LICENSE",
23
+ "SOURCE-OFFER.txt",
24
+ "LICENSING.md"
23
25
  ],
24
26
  "engines": {
25
27
  "node": ">=22.0.0"