aegisone 1.0.35 → 1.0.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/bin/aegis.js +1 -1
- package/package.json +1 -1
- package/scripts/predist.mjs +1 -1
- package/src/iface/paths.js +3 -0
- package/src/iface/pty.js +3 -0
- package/src/iface/update.js +3 -0
- package/src/iface/window.js +3 -0
- package/src/protocol.js +3 -0
- package/src/selfhost.js +3 -0
- package/vendor/cli/package.json +1 -1
- package/vendor/cli/vendor/desktop/lib/local/integrity.js +1 -1
- package/vendor/cli/vendor/desktop/main.js +67 -1
- package/vendor/cli/vendor/one/src/selfhost.js +3 -0
- package/vendor/desktop/lib/local/integrity.js +1 -1
- package/vendor/desktop/main.js +67 -1
- package/vendor/desktop/package.json +1 -1
- package/vendor/desktop/vendor/faces/cli/LICENSE +661 -0
- package/vendor/desktop/vendor/faces/cli/README.md +784 -0
- package/vendor/desktop/vendor/faces/cli/bin/aegiscode.js +20 -0
- package/vendor/desktop/vendor/faces/cli/package.json +44 -0
- package/vendor/desktop/vendor/faces/cli/scripts/check.mjs +4 -0
- package/vendor/desktop/vendor/faces/cli/scripts/demo.mjs +4 -0
- package/vendor/desktop/vendor/faces/cli/scripts/predist.mjs +4 -0
- package/vendor/desktop/vendor/faces/cli/scripts/runtests.mjs +4 -0
- package/vendor/desktop/vendor/faces/cli/scripts/seal-gate.mjs +3 -0
- package/vendor/desktop/vendor/faces/cli/src/agents.js +3 -0
- package/vendor/desktop/vendor/faces/cli/src/app.js +3 -0
- package/vendor/desktop/vendor/faces/cli/src/art.js +3 -0
- package/vendor/desktop/vendor/faces/cli/src/autonomous.js +3 -0
- package/vendor/desktop/vendor/faces/cli/src/caps.js +3 -0
- package/vendor/desktop/vendor/faces/cli/src/chatflow.js +3 -0
- package/vendor/desktop/vendor/faces/cli/src/checkpoint.js +3 -0
- package/vendor/desktop/vendor/faces/cli/src/clipboard.js +3 -0
- package/vendor/desktop/vendor/faces/cli/src/cloudsync.js +3 -0
- package/vendor/desktop/vendor/faces/cli/src/commands.js +3 -0
- package/vendor/desktop/vendor/faces/cli/src/config.js +3 -0
- package/vendor/desktop/vendor/faces/cli/src/connect.js +3 -0
- package/vendor/desktop/vendor/faces/cli/src/credentials.js +3 -0
- package/vendor/desktop/vendor/faces/cli/src/deps.js +3 -0
- package/vendor/desktop/vendor/faces/cli/src/devrun.js +3 -0
- package/vendor/desktop/vendor/faces/cli/src/diff.js +3 -0
- package/vendor/desktop/vendor/faces/cli/src/diffview.js +3 -0
- package/vendor/desktop/vendor/faces/cli/src/engine.js +3 -0
- package/vendor/desktop/vendor/faces/cli/src/entitlement.js +3 -0
- package/vendor/desktop/vendor/faces/cli/src/events.js +3 -0
- package/vendor/desktop/vendor/faces/cli/src/export.js +3 -0
- package/vendor/desktop/vendor/faces/cli/src/filepreview.js +3 -0
- package/vendor/desktop/vendor/faces/cli/src/fingerprint.js +3 -0
- package/vendor/desktop/vendor/faces/cli/src/format.js +3 -0
- package/vendor/desktop/vendor/faces/cli/src/fuzzy.js +3 -0
- package/vendor/desktop/vendor/faces/cli/src/gate.js +3 -0
- package/vendor/desktop/vendor/faces/cli/src/history.js +3 -0
- package/vendor/desktop/vendor/faces/cli/src/init.js +3 -0
- package/vendor/desktop/vendor/faces/cli/src/input.js +3 -0
- package/vendor/desktop/vendor/faces/cli/src/keys.js +3 -0
- package/vendor/desktop/vendor/faces/cli/src/limits.js +3 -0
- package/vendor/desktop/vendor/faces/cli/src/markdown.js +3 -0
- package/vendor/desktop/vendor/faces/cli/src/mcp.js +3 -0
- package/vendor/desktop/vendor/faces/cli/src/models.js +3 -0
- package/vendor/desktop/vendor/faces/cli/src/naming.js +3 -0
- package/vendor/desktop/vendor/faces/cli/src/overlays.js +3 -0
- package/vendor/desktop/vendor/faces/cli/src/panels.js +3 -0
- package/vendor/desktop/vendor/faces/cli/src/permissions.js +3 -0
- package/vendor/desktop/vendor/faces/cli/src/ping.js +3 -0
- package/vendor/desktop/vendor/faces/cli/src/presence.js +3 -0
- package/vendor/desktop/vendor/faces/cli/src/provenance.js +58 -0
- package/vendor/desktop/vendor/faces/cli/src/provenance.lock.json +36 -0
- package/vendor/desktop/vendor/faces/cli/src/render.js +3 -0
- package/vendor/desktop/vendor/faces/cli/src/screen.js +3 -0
- package/vendor/desktop/vendor/faces/cli/src/screens.js +3 -0
- package/vendor/desktop/vendor/faces/cli/src/secret.js +3 -0
- package/vendor/desktop/vendor/faces/cli/src/securefs.js +3 -0
- package/vendor/desktop/vendor/faces/cli/src/settings.js +3 -0
- package/vendor/desktop/vendor/faces/cli/src/shared.js +3 -0
- package/vendor/desktop/vendor/faces/cli/src/sharedpaths.js +3 -0
- package/vendor/desktop/vendor/faces/cli/src/signup.js +3 -0
- package/vendor/desktop/vendor/faces/cli/src/summarize.js +3 -0
- package/vendor/desktop/vendor/faces/cli/src/sysdiag.js +3 -0
- package/vendor/desktop/vendor/faces/cli/src/system.js +3 -0
- package/vendor/desktop/vendor/faces/cli/src/theme.js +3 -0
- package/vendor/desktop/vendor/faces/cli/src/title.js +3 -0
- package/vendor/desktop/vendor/faces/cli/src/todos.js +3 -0
- package/vendor/desktop/vendor/faces/cli/src/tokens.js +3 -0
- package/vendor/desktop/vendor/faces/cli/src/topup.js +3 -0
- package/vendor/desktop/vendor/faces/cli/src/update.js +3 -0
- package/vendor/desktop/vendor/faces/cli/vendor/client/aegis.js +4 -0
- package/vendor/desktop/vendor/faces/cli/vendor/client/attest.js +3 -0
- package/vendor/desktop/vendor/faces/cli/vendor/client/authorship-key.js +3 -0
- package/vendor/desktop/vendor/faces/cli/vendor/client/auto-provision.js +3 -0
- package/vendor/desktop/vendor/faces/cli/vendor/client/brain-catalog.js +3 -0
- package/vendor/desktop/vendor/faces/cli/vendor/client/byok-catalog.js +3 -0
- package/vendor/desktop/vendor/faces/cli/vendor/client/catalog-client.js +3 -0
- package/vendor/desktop/vendor/faces/cli/vendor/client/conversation-export.js +3 -0
- package/vendor/desktop/vendor/faces/cli/vendor/client/credentials.js +3 -0
- package/vendor/desktop/vendor/faces/cli/vendor/client/device-fingerprint.js +3 -0
- package/vendor/desktop/vendor/faces/cli/vendor/client/drive-connect.js +3 -0
- package/vendor/desktop/vendor/faces/cli/vendor/client/drive-upload.js +3 -0
- package/vendor/desktop/vendor/faces/cli/vendor/client/env-file.js +3 -0
- package/vendor/desktop/vendor/faces/cli/vendor/client/fingerprint.js +3 -0
- package/vendor/desktop/vendor/faces/cli/vendor/client/foreign-memory.js +3 -0
- package/vendor/desktop/vendor/faces/cli/vendor/client/google-signin.js +3 -0
- package/vendor/desktop/vendor/faces/cli/vendor/client/hooks.js +3 -0
- package/vendor/desktop/vendor/faces/cli/vendor/client/model-discovery.js +3 -0
- package/vendor/desktop/vendor/faces/cli/vendor/client/naming.js +3 -0
- package/vendor/desktop/vendor/faces/cli/vendor/client/platform.js +3 -0
- package/vendor/desktop/vendor/faces/cli/vendor/client/prefs.js +3 -0
- package/vendor/desktop/vendor/faces/cli/vendor/client/presence-constants.js +3 -0
- package/vendor/desktop/vendor/faces/cli/vendor/client/presence.js +3 -0
- package/vendor/desktop/vendor/faces/cli/vendor/client/record-vault.js +105 -0
- package/vendor/desktop/vendor/faces/cli/vendor/client/session-store.js +3 -0
- package/vendor/desktop/vendor/faces/cli/vendor/client/topup.js +3 -0
- package/vendor/desktop/vendor/faces/cli/vendor/client/touch.js +3 -0
- package/vendor/desktop/vendor/faces/cli/vendor/client/update.js +3 -0
- package/vendor/desktop/vendor/faces/cli/vendor/client/user-models.js +3 -0
- package/vendor/desktop/vendor/faces/cli/vendor/covenant/README.md +21 -0
- package/vendor/desktop/vendor/faces/cli/vendor/covenant/aegis.seal +177 -0
- package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/aegis-seal.mjs +241 -0
- package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/agents.js +3 -0
- package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/attachments.js +3 -0
- package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/autonomous.js +3 -0
- package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/claude-pro.js +3 -0
- package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/context.js +3 -0
- package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/covenant.js +567 -0
- package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/engine.js +3 -0
- package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/entitlement.js +3 -0
- package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/exec-plan.js +3 -0
- package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/git-scope.js +3 -0
- package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/integrity.js +3 -0
- package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/local.js +3 -0
- package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/prompt.js +3 -0
- package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/queue.js +3 -0
- package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/session-rounds.js +3 -0
- package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/shell.js +3 -0
- package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/spill.js +3 -0
- package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/tools.js +3 -0
- package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/turn-guard.js +3 -0
- package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/worktree-lock.js +3 -0
- package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/settings.js +3 -0
- package/vendor/desktop/vendor/faces/cli/vendor/desktop/main.js +4 -0
- package/vendor/desktop/vendor/faces/cli/vendor/desktop/renderer/usage.js +3 -0
- package/vendor/desktop/vendor/faces/cli/vendor/hosts/install.js +1 -0
- package/vendor/desktop/vendor/faces/cli/vendor/hosts/openai-shim.js +2 -0
- package/vendor/desktop/vendor/faces/cli/vendor/hosts/spec.js +1 -0
- package/vendor/desktop/vendor/faces/cli/vendor/hosts/targets.js +1 -0
- package/vendor/desktop/vendor/faces/cli/vendor/mcp/server.js +4 -0
- package/vendor/desktop/vendor/faces/cli/vendor/mcp/tools.js +3 -0
- package/vendor/desktop/vendor/faces/cli/vendor/one/src/child.js +3 -0
- package/vendor/desktop/vendor/faces/cli/vendor/one/src/permissions.js +3 -0
- package/vendor/desktop/vendor/faces/cli/vendor/one/src/selfhost.js +3 -0
- package/vendor/desktop/vendor/faces/cli/vendor/tools/agent-gate.mjs +1203 -0
- package/vendor/desktop/vendor/selfhost.js +3 -0
package/README.md
CHANGED
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"),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||{},
|
|
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}))}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aegisone",
|
|
3
3
|
"productName": "AEGISONE",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.37",
|
|
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",
|
package/scripts/predist.mjs
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
|
-
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"}];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 p=12e4,h=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 b(){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++,b;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()+p,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>h||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(p/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`))),b}function w(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,p=(i.stderr||process.stderr,Array.isArray(n.shapes)?n.shapes:[...SHAPES,"bundle"]),h=e=>p.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=w(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:w(entriesFor("nested"),null).length}),t("flat")){const e=w(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")),p=a(r.join(l,"install.js")),h=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=h.getTarget("vscode"),f=p.planTarget(m,"user",{ctx:p.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:h.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}return i}({want:h,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 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}))}();
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
2
|
+
// Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
|
|
3
|
+
"use strict";const path=require("node:path"),APP="aegiscode",CODE=Object.freeze({BAD_INPUT:"bad_input",UNSUPPORTED:"unsupported"});function homeFrom(t,o){const n=o||{};return String("win32"===t?n.USERPROFILE||n.HOME||"":n.HOME||"")}function bases(t){const o=t||{},n=String(o.platform||""),r=o.env||{};if(!n)return{ok:!1,code:CODE.BAD_INPUT,msg:"platform is required (pass host.hostPlatform())"};const a=String(o.home||homeFrom(n,r)),e=()=>a?null:{ok:!1,code:CODE.BAD_INPUT,msg:`no home directory for ${n}: neither HOME nor USERPROFILE is set`};if("win32"===n){const t=e();if(t)return t;const o=String(r.APPDATA||path.join(a,"AppData","Roaming")),n=String(r.LOCALAPPDATA||path.join(a,"AppData","Local"));return{ok:!0,config:o,state:n,cache:n}}if("darwin"===n){return e()||{ok:!0,config:String(r.XDG_CONFIG_HOME||path.join(a,"Library","Application Support")),state:String(r.XDG_STATE_HOME||path.join(a,"Library","Application Support")),cache:String(r.XDG_CACHE_HOME||path.join(a,"Library","Caches"))}}if("linux"===n){return e()||{ok:!0,config:String(r.XDG_CONFIG_HOME||path.join(a,".config")),state:String(r.XDG_STATE_HOME||path.join(a,".local","state")),cache:String(r.XDG_CACHE_HOME||path.join(a,".cache"))}}return{ok:!1,code:CODE.UNSUPPORTED,msg:`no directory layout for platform: ${n}`}}function plan(t){const o=bases(t);return o.ok?{ok:!0,config:path.join(o.config,APP),state:path.join(o.state,APP),cache:path.join(o.cache,APP)}:o}function at(t,o,n){if(!t||!t.ok)return{ok:!1,code:t&&t.code||CODE.BAD_INPUT,msg:t&&t.msg||"no usable directory plan"};if(!Object.prototype.hasOwnProperty.call(t,o)||"ok"===o)return{ok:!1,code:CODE.BAD_INPUT,msg:`unknown root: ${String(o)}`};const r=Array.isArray(n)?n.map(String):[];return{ok:!0,path:path.join(t[o],...r)}}module.exports={APP:APP,CODE:CODE,homeFrom:homeFrom,bases:bases,plan:plan,at:at};
|
package/src/iface/pty.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
2
|
+
// Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
|
|
3
|
+
"use strict";const path=require("node:path"),KIND=Object.freeze({PTY:"pty",PIPE:"pipe"}),CAP="pty",CODE=Object.freeze({UNSUPPORTED:"unsupported",NO_SPAWN:"no_spawn",BAD_DESC:"bad_desc"});function plan(n){const e=n||{};return"wasm"===e.target?{ok:!1,code:CODE.UNSUPPORTED,msg:"this target has no child processes: a WASM core cannot run exec"}:e.nativePty?{ok:!0,kind:KIND.PTY,cap:CAP,reason:"a PTY backend is available, so the child gets a real terminal"}:{ok:!0,kind:KIND.PIPE,cap:null,reason:"no PTY backend: stdio works, but resize, signals and line discipline do not"}}function caps(n){return n&&n.ok&&n.cap?[n.cap]:[]}function spawn(n,e,a){const s=a||{};if(!n||!n.ok)return{ok:!1,code:n&&n.code||CODE.UNSUPPORTED,msg:n&&n.msg||"no usable process plan"};const o=e||{},t=Array.isArray(o.argv)?o.argv.map(String):[];if(!t.length)return{ok:!1,code:CODE.BAD_DESC,msg:"exec needs a non-empty argv"};const c={cwd:o.cwd,env:o.env,cols:o.cols,rows:o.rows};return n.kind===KIND.PTY?"function"!=typeof s.spawnPty?{ok:!1,code:CODE.NO_SPAWN,msg:"pty was negotiated but no PTY spawner was injected"}:{ok:!0,kind:KIND.PTY,handle:s.spawnPty(t,c)}:"function"!=typeof s.spawnChild?{ok:!1,code:CODE.NO_SPAWN,msg:"no child-process spawner was injected"}:{ok:!0,kind:KIND.PIPE,handle:s.spawnChild(t,c)}}function sameCommand(n,e){return path.basename(String(n||""))===path.basename(String(e||""))}module.exports={KIND:KIND,CAP:CAP,CODE:CODE,plan:plan,caps:caps,spawn:spawn,sameCommand:sameCommand};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
2
|
+
// Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
|
|
3
|
+
"use strict";const CHANNEL=Object.freeze({NPM:"npm",APPIMAGE:"appimage",CHECKOUT:"checkout"}),CODE=Object.freeze({NO_CHANNEL:"no_channel",UNKNOWN_CHANNEL:"unknown_channel",NO_APPROACH:"no_approach",BAD_INPUT:"bad_input"});function plan(e){const n=e||{};return(n.env||{}).APPIMAGE?{ok:!0,channel:CHANNEL.APPIMAGE,selfUpdate:!0,reason:"running from an AppImage, which can replace its own file"}:n.packaged?{ok:!0,channel:CHANNEL.NPM,selfUpdate:!1,reason:"a packaged build is replaced by its installer; it only reports"}:{ok:!1,code:CODE.NO_CHANNEL,msg:"this copy is a source checkout: updating it means `git pull`, not a self-update"}}function check(e,n,o){if(!e||!e.ok)return{ok:!1,code:e&&e.code||CODE.BAD_INPUT,msg:e&&e.msg||"no usable update plan"};const t=o&&o.approach;if("function"!=typeof t)return{ok:!1,code:CODE.NO_APPROACH,msg:"no approach function was injected, so no update can be discovered"};const a=t(String(n||""));if(!a||!a.latest)return{ok:!1,code:CODE.NO_APPROACH,msg:"the approach step returned no version to compare against"};const c="function"==typeof(o&&o.compare)?o.compare:null;return{ok:!0,update:c?Boolean(c(String(n),String(a.latest))):null,current:String(n||""),latest:String(a.latest),url:String(a.url||"")}}function apply(e,n,o){if(!e||!e.ok)return{ok:!1,code:e&&e.code||CODE.BAD_INPUT,msg:e&&e.msg||"no usable update plan"};if(!e.selfUpdate)return{ok:!1,code:CODE.NO_CHANNEL,msg:`the ${e.channel} channel is not self-updating: ${e.reason}`};if(!n||!n.ok||!0!==n.update)return{ok:!1,code:CODE.BAD_INPUT,msg:"nothing to apply: no newer version was established"};const t=o&&o.replace;return"function"!=typeof t?{ok:!1,code:CODE.NO_APPROACH,msg:"no replace step was injected"}:(t(n),{ok:!0,applied:!0})}module.exports={CHANNEL:CHANNEL,CODE:CODE,plan:plan,check:check,apply:apply};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
2
|
+
// Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
|
|
3
|
+
"use strict";const KIND=Object.freeze({ELECTRON:"electron"}),CODE=Object.freeze({UNSUPPORTED:"unsupported",BAD_DECISION:"bad_decision"});function plan(n){const e=n||{};return e.decision&&"gui"===e.decision.face?"wasm"===e.target?null:e.electron?{ok:!0,kind:KIND.ELECTRON,cap:null,reason:"an Electron runtime is loadable, so it draws the window"}:null:null}function open(n,e,o){if(!n)return null;if(!n.ok)return{ok:!1,code:n.code||CODE.UNSUPPORTED,msg:n.msg||"no usable window plan"};if(n.kind!==KIND.ELECTRON)return{ok:!1,code:CODE.UNSUPPORTED,msg:`no adapter for kind: ${n.kind}`};const t=o&&o.openElectron;return"function"!=typeof t?{ok:!1,code:CODE.UNSUPPORTED,msg:"window plan needs an Electron opener, and none was injected"}:{ok:!0,kind:KIND.ELECTRON,handle:t(e||{})}}module.exports={KIND:KIND,CODE:CODE,plan:plan,open:open};
|
package/src/protocol.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
2
|
+
// Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
|
|
3
|
+
"use strict";const PROTO=1,METHODS=Object.freeze(["hello","exec","event","cancel"]),CAPS=Object.freeze({EXEC:"exec",EVENT:"event",CANCEL:"cancel",PTY:"pty"}),CODE=Object.freeze({BAD_JSON:"bad_json",BAD_FRAME:"bad_frame",UNKNOWN_METHOD:"unknown_method",PROTO_MISMATCH:"proto_mismatch",HELLO_REQUIRED:"hello_required",CAPABILITY_MISSING:"capability_missing",UNSUPPORTED:"unsupported"});function request(e,o,t){return{id:e,m:String(o),p:t&&"object"==typeof t?t:{}}}function ok(e,o){return{id:e,ok:!0,r:o&&"object"==typeof o?o:{}}}function err(e,o,t){return{id:e,ok:!1,e:{code:String(o||CODE.UNSUPPORTED),msg:String(t||"")}}}function isObject(e){return Boolean(e)&&"object"==typeof e&&!Array.isArray(e)}function validate(e){return isObject(e)?void 0===e.id||null===e.id?{ok:!1,code:CODE.BAD_FRAME,msg:"frame has no id"}:void 0!==e.ok?!0===e.ok?void 0!==e.e?{ok:!1,code:CODE.BAD_FRAME,msg:"reply carries both r and e"}:{ok:!0}:!1===e.ok?isObject(e.e)&&e.e.code?{ok:!0}:{ok:!1,code:CODE.BAD_FRAME,msg:"a failed reply must name a code"}:{ok:!1,code:CODE.BAD_FRAME,msg:"ok must be true or false"}:"string"==typeof e.m&&METHODS.includes(e.m)?void 0===e.p||isObject(e.p)?{ok:!0}:{ok:!1,code:CODE.BAD_FRAME,msg:"params must be an object"}:{ok:!1,code:CODE.UNKNOWN_METHOD,msg:`unknown method: ${String(e.m)}`}:{ok:!1,code:CODE.BAD_FRAME,msg:"frame must be an object"}}function negotiate(e,o){const t=o||{},r=validate(e);if(!r.ok)return{ok:!1,code:r.code,msg:r.msg};if("hello"!==e.m)return{ok:!1,code:CODE.HELLO_REQUIRED,msg:`the first frame must be hello, got ${String(e.m)}`};const n=e.p||{};if(1!==n.proto)return{ok:!1,code:CODE.PROTO_MISMATCH,msg:`peer speaks protocol ${String(n.proto)}, this build speaks 1`};const i=Array.isArray(n.caps)?n.caps.map(String):[],s=(Array.isArray(t.requireCaps)?t.requireCaps.map(String):[]).filter((e=>!i.includes(e)));return s.length?{ok:!1,code:CODE.CAPABILITY_MISSING,msg:`peer does not offer: ${s.join(", ")}`}:{ok:!0,proto:1,caps:i}}function hello(e){return request(void 0===e?0:e,"hello",{proto:1,caps:[CAPS.EXEC,CAPS.EVENT,CAPS.CANCEL]})}function encode(e){return`${JSON.stringify(e)}\n`}function decodeLine(e){const o=String(null==e?"":e).trim();if(!o)return{ok:!1,id:null,code:CODE.BAD_JSON,msg:"empty line"};let t;try{t=JSON.parse(o)}catch(e){return{ok:!1,id:null,code:CODE.BAD_JSON,msg:`not JSON: ${e.message}`}}const r=validate(t);return r.ok?{ok:!0,frame:t}:{ok:!1,id:isObject(t)&&void 0!==t.id?t.id:null,code:r.code,msg:r.msg}}function splitLines(e){const o=String(null==e?"":e).split("\n"),t=o.pop();return{lines:o.filter((e=>""!==e.trim())),rest:void 0===t?"":t}}module.exports={PROTO:1,METHODS:METHODS,CAPS:CAPS,CODE:CODE,request:request,ok:ok,err:err,hello:hello,validate:validate,negotiate:negotiate,encode:encode,decodeLine:decodeLine,splitLines:splitLines};
|
package/src/selfhost.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
2
|
+
// Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
|
|
3
|
+
"use strict";const path=require("node:path"),FACE=Object.freeze({TUI:"tui",GUI:"gui"}),RUN_AS_NODE="ELECTRON_RUN_AS_NODE",FORCE_TUI=["--tui","code"],COMPAT_BIN="aegiscode";function faceRoot(e,n){return path.join(e,"faces",n)}function cliEntry(e){return path.join(faceRoot(e,"cli"),"bin","aegiscode.js")}function binName(e){return path.basename(String(e||"aegis")).replace(/\.(exe|cmd|bat|AppImage)$/i,"").replace(/\.js$/,"")}function plan(e){const n=e||{};if(!n.packaged)return null;const t=n.execPath,a=n.resourcesPath,i=Array.isArray(n.argv)?n.argv.map(String):[];if(!t||!a)return null;const r=(e,n)=>({face:FACE.TUI,exec:t,args:[cliEntry(a),...e],env:{[RUN_AS_NODE]:"1"},reason:n});if(binName(n.invokedAs)===COMPAT_BIN)return r(i,"aegiscode is the compatibility bin");const c=i.find((e=>FORCE_TUI.includes(e)));return c?r(i.filter((e=>e!==c)),`${c} asks for the terminal face`):null}function spawnOptions(e,n){return e?{exec:e.exec,args:e.args,env:Object.assign({},n||{},e.env)}:null}module.exports={plan:plan,spawnOptions:spawnOptions,FACE:FACE,RUN_AS_NODE:RUN_AS_NODE,COMPAT_BIN:COMPAT_BIN,FORCE_TUI:FORCE_TUI,cliEntry:cliEntry,faceRoot:faceRoot,binName:binName};
|
package/vendor/cli/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aegiscode",
|
|
3
3
|
"productName": "AEGIS Code",
|
|
4
|
-
"version": "7.0.
|
|
4
|
+
"version": "7.0.29",
|
|
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",
|
|
@@ -94,7 +94,7 @@ const UNITS = Object.freeze([
|
|
|
94
94
|
* (`tools/desktop-seal.mjs` in the source tree, `tools/obfuscate-faces.mjs`
|
|
95
95
|
* after obfuscation), never by hand.
|
|
96
96
|
*/
|
|
97
|
-
const SEALED = '
|
|
97
|
+
const SEALED = '48fc29f73f029cb1da82fb44f24bef085525eba53a2c2dc913fefb005e6f3ebf';
|
|
98
98
|
|
|
99
99
|
/**
|
|
100
100
|
* Ask the question. Never throws — a check that can break the program it is
|
|
@@ -1486,7 +1486,10 @@ function registerQuickLauncherIpc(ipcMain, dispatch) {
|
|
|
1486
1486
|
/**
|
|
1487
1487
|
* Resolve the per-user data directory for settings + sessions. Electron gives
|
|
1488
1488
|
* us app.getPath('userData'); outside Electron (headless smoke tests) fall back
|
|
1489
|
-
* to
|
|
1489
|
+
* to the platform's own state root via `one/src/iface/paths.js`, so this host
|
|
1490
|
+
* does not keep a second, divergent answer to "where is this OS's data dir".
|
|
1491
|
+
* (It previously hard-coded `~/.aegiscode`, which is a POSIX answer written in
|
|
1492
|
+
* a file that also runs on Windows.)
|
|
1490
1493
|
*/
|
|
1491
1494
|
function resolveUserDataDir(app) {
|
|
1492
1495
|
if (app && typeof app.getPath === 'function') {
|
|
@@ -1496,6 +1499,13 @@ function resolveUserDataDir(app) {
|
|
|
1496
1499
|
/* fall through */
|
|
1497
1500
|
}
|
|
1498
1501
|
}
|
|
1502
|
+
try {
|
|
1503
|
+
const PATHS = require('../one/src/iface/paths.js');
|
|
1504
|
+
const planned = PATHS.plan({ platform: process.platform, env: process.env });
|
|
1505
|
+
if (planned && planned.ok) return planned.state;
|
|
1506
|
+
} catch {
|
|
1507
|
+
/* the one/ tree is not shipped beside a standalone desktop build */
|
|
1508
|
+
}
|
|
1499
1509
|
return path.join(os.homedir(), '.aegiscode');
|
|
1500
1510
|
}
|
|
1501
1511
|
|
|
@@ -3783,6 +3793,62 @@ function bootstrap() {
|
|
|
3783
3793
|
|
|
3784
3794
|
const { app, BrowserWindow, ipcMain, safeStorage, shell, Menu, Notification, screen, dialog, globalShortcut } = electron;
|
|
3785
3795
|
|
|
3796
|
+
// ── one artifact, two faces (one/src/selfhost.js) ────────────────────────
|
|
3797
|
+
//
|
|
3798
|
+
// A PACKAGED launch may have been asked for the terminal face: `aegiscode`,
|
|
3799
|
+
// `aegis --tui`, `aegis code`. The packaged app carries both faces in
|
|
3800
|
+
// `resources/faces/`, and Electron embeds Node — so re-entering ourselves with
|
|
3801
|
+
// ELECTRON_RUN_AS_NODE=1 runs the terminal face with no Node on the user's
|
|
3802
|
+
// PATH. That is the one case both installers currently have to apologise for.
|
|
3803
|
+
//
|
|
3804
|
+
// This runs BEFORE the GPU switches below, deliberately: a terminal session
|
|
3805
|
+
// must never initialise Chromium, let alone crash-loop its GPU process on a
|
|
3806
|
+
// headless box (the failure the block below exists to survive).
|
|
3807
|
+
//
|
|
3808
|
+
// `plan()` returns null for every other case — including every window request,
|
|
3809
|
+
// because in that case THIS process is the window and spawning a second one
|
|
3810
|
+
// would race the single-instance lock below. Null means "carry on", never
|
|
3811
|
+
// "do nothing".
|
|
3812
|
+
try {
|
|
3813
|
+
// Two layouts, same reason every other staged module has two: in a checkout
|
|
3814
|
+
// it is a sibling of `desktop/`, and packaged electron-builder cannot reach
|
|
3815
|
+
// outside the app dir, so predist stages it FLAT as `vendor/selfhost.js`
|
|
3816
|
+
// (one MANIFEST row, two shapes).
|
|
3817
|
+
let selfhost;
|
|
3818
|
+
try {
|
|
3819
|
+
selfhost = require('./vendor/selfhost.js');
|
|
3820
|
+
} catch {
|
|
3821
|
+
selfhost = require('../one/src/selfhost.js');
|
|
3822
|
+
}
|
|
3823
|
+
const planned = selfhost.plan({
|
|
3824
|
+
packaged: app.isPackaged,
|
|
3825
|
+
execPath: process.execPath,
|
|
3826
|
+
resourcesPath: process.resourcesPath,
|
|
3827
|
+
argv: process.argv.slice(1),
|
|
3828
|
+
invokedAs: path.basename(process.argv[1] || process.execPath),
|
|
3829
|
+
});
|
|
3830
|
+
if (planned) {
|
|
3831
|
+
// Synchronous on purpose: the terminal face owns the tty, and its exit
|
|
3832
|
+
// code IS ours — a detached `aegis code` that returns 0 while the child
|
|
3833
|
+
// failed tells a script nothing true.
|
|
3834
|
+
const opts = selfhost.spawnOptions(planned, process.env);
|
|
3835
|
+
const res = require('node:child_process').spawnSync(opts.exec, opts.args, {
|
|
3836
|
+
stdio: 'inherit',
|
|
3837
|
+
env: opts.env,
|
|
3838
|
+
});
|
|
3839
|
+
const code = typeof res.status === 'number' ? res.status : 1;
|
|
3840
|
+
app.exit(code);
|
|
3841
|
+
return;
|
|
3842
|
+
}
|
|
3843
|
+
} catch (err) {
|
|
3844
|
+
// A missing selfhost module is not fatal: it means this build predates the
|
|
3845
|
+
// packaged terminal face, and a window is still the right answer. Printed
|
|
3846
|
+
// rather than swallowed so a genuinely broken staging step is visible.
|
|
3847
|
+
if (app.isPackaged && !/MODULE_NOT_FOUND/.test(String(err && err.message))) {
|
|
3848
|
+
process.stderr.write(`aegis: terminal face hand-off failed: ${(err && err.message) || err}\n`);
|
|
3849
|
+
}
|
|
3850
|
+
}
|
|
3851
|
+
|
|
3786
3852
|
// A container/CI/headless server with no usable GPU crashes Chromium's GPU
|
|
3787
3853
|
// process in a retry loop that ends in a FATAL exit ("GPU process isn't
|
|
3788
3854
|
// usable. Goodbye.") — and that happens BEFORE app.whenReady() ever fires,
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
2
|
+
// Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
|
|
3
|
+
"use strict";const path=require("node:path"),FACE=Object.freeze({TUI:"tui",GUI:"gui"}),RUN_AS_NODE="ELECTRON_RUN_AS_NODE",FORCE_TUI=["--tui","code"],COMPAT_BIN="aegiscode";function faceRoot(e,n){return path.join(e,"faces",n)}function cliEntry(e){return path.join(faceRoot(e,"cli"),"bin","aegiscode.js")}function binName(e){return path.basename(String(e||"aegis")).replace(/\.(exe|cmd|bat|AppImage)$/i,"").replace(/\.js$/,"")}function plan(e){const n=e||{};if(!n.packaged)return null;const t=n.execPath,a=n.resourcesPath,i=Array.isArray(n.argv)?n.argv.map(String):[];if(!t||!a)return null;const r=(e,n)=>({face:FACE.TUI,exec:t,args:[cliEntry(a),...e],env:{[RUN_AS_NODE]:"1"},reason:n});if(binName(n.invokedAs)===COMPAT_BIN)return r(i,"aegiscode is the compatibility bin");const c=i.find((e=>FORCE_TUI.includes(e)));return c?r(i.filter((e=>e!==c)),`${c} asks for the terminal face`):null}function spawnOptions(e,n){return e?{exec:e.exec,args:e.args,env:Object.assign({},n||{},e.env)}:null}module.exports={plan:plan,spawnOptions:spawnOptions,FACE:FACE,RUN_AS_NODE:RUN_AS_NODE,COMPAT_BIN:COMPAT_BIN,FORCE_TUI:FORCE_TUI,cliEntry:cliEntry,faceRoot:faceRoot,binName:binName};
|
|
@@ -94,7 +94,7 @@ const UNITS = Object.freeze([
|
|
|
94
94
|
* (`tools/desktop-seal.mjs` in the source tree, `tools/obfuscate-faces.mjs`
|
|
95
95
|
* after obfuscation), never by hand.
|
|
96
96
|
*/
|
|
97
|
-
const SEALED = '
|
|
97
|
+
const SEALED = '48fc29f73f029cb1da82fb44f24bef085525eba53a2c2dc913fefb005e6f3ebf';
|
|
98
98
|
|
|
99
99
|
/**
|
|
100
100
|
* Ask the question. Never throws — a check that can break the program it is
|
package/vendor/desktop/main.js
CHANGED
|
@@ -1486,7 +1486,10 @@ function registerQuickLauncherIpc(ipcMain, dispatch) {
|
|
|
1486
1486
|
/**
|
|
1487
1487
|
* Resolve the per-user data directory for settings + sessions. Electron gives
|
|
1488
1488
|
* us app.getPath('userData'); outside Electron (headless smoke tests) fall back
|
|
1489
|
-
* to
|
|
1489
|
+
* to the platform's own state root via `one/src/iface/paths.js`, so this host
|
|
1490
|
+
* does not keep a second, divergent answer to "where is this OS's data dir".
|
|
1491
|
+
* (It previously hard-coded `~/.aegiscode`, which is a POSIX answer written in
|
|
1492
|
+
* a file that also runs on Windows.)
|
|
1490
1493
|
*/
|
|
1491
1494
|
function resolveUserDataDir(app) {
|
|
1492
1495
|
if (app && typeof app.getPath === 'function') {
|
|
@@ -1496,6 +1499,13 @@ function resolveUserDataDir(app) {
|
|
|
1496
1499
|
/* fall through */
|
|
1497
1500
|
}
|
|
1498
1501
|
}
|
|
1502
|
+
try {
|
|
1503
|
+
const PATHS = require('../one/src/iface/paths.js');
|
|
1504
|
+
const planned = PATHS.plan({ platform: process.platform, env: process.env });
|
|
1505
|
+
if (planned && planned.ok) return planned.state;
|
|
1506
|
+
} catch {
|
|
1507
|
+
/* the one/ tree is not shipped beside a standalone desktop build */
|
|
1508
|
+
}
|
|
1499
1509
|
return path.join(os.homedir(), '.aegiscode');
|
|
1500
1510
|
}
|
|
1501
1511
|
|
|
@@ -3783,6 +3793,62 @@ function bootstrap() {
|
|
|
3783
3793
|
|
|
3784
3794
|
const { app, BrowserWindow, ipcMain, safeStorage, shell, Menu, Notification, screen, dialog, globalShortcut } = electron;
|
|
3785
3795
|
|
|
3796
|
+
// ── one artifact, two faces (one/src/selfhost.js) ────────────────────────
|
|
3797
|
+
//
|
|
3798
|
+
// A PACKAGED launch may have been asked for the terminal face: `aegiscode`,
|
|
3799
|
+
// `aegis --tui`, `aegis code`. The packaged app carries both faces in
|
|
3800
|
+
// `resources/faces/`, and Electron embeds Node — so re-entering ourselves with
|
|
3801
|
+
// ELECTRON_RUN_AS_NODE=1 runs the terminal face with no Node on the user's
|
|
3802
|
+
// PATH. That is the one case both installers currently have to apologise for.
|
|
3803
|
+
//
|
|
3804
|
+
// This runs BEFORE the GPU switches below, deliberately: a terminal session
|
|
3805
|
+
// must never initialise Chromium, let alone crash-loop its GPU process on a
|
|
3806
|
+
// headless box (the failure the block below exists to survive).
|
|
3807
|
+
//
|
|
3808
|
+
// `plan()` returns null for every other case — including every window request,
|
|
3809
|
+
// because in that case THIS process is the window and spawning a second one
|
|
3810
|
+
// would race the single-instance lock below. Null means "carry on", never
|
|
3811
|
+
// "do nothing".
|
|
3812
|
+
try {
|
|
3813
|
+
// Two layouts, same reason every other staged module has two: in a checkout
|
|
3814
|
+
// it is a sibling of `desktop/`, and packaged electron-builder cannot reach
|
|
3815
|
+
// outside the app dir, so predist stages it FLAT as `vendor/selfhost.js`
|
|
3816
|
+
// (one MANIFEST row, two shapes).
|
|
3817
|
+
let selfhost;
|
|
3818
|
+
try {
|
|
3819
|
+
selfhost = require('./vendor/selfhost.js');
|
|
3820
|
+
} catch {
|
|
3821
|
+
selfhost = require('../one/src/selfhost.js');
|
|
3822
|
+
}
|
|
3823
|
+
const planned = selfhost.plan({
|
|
3824
|
+
packaged: app.isPackaged,
|
|
3825
|
+
execPath: process.execPath,
|
|
3826
|
+
resourcesPath: process.resourcesPath,
|
|
3827
|
+
argv: process.argv.slice(1),
|
|
3828
|
+
invokedAs: path.basename(process.argv[1] || process.execPath),
|
|
3829
|
+
});
|
|
3830
|
+
if (planned) {
|
|
3831
|
+
// Synchronous on purpose: the terminal face owns the tty, and its exit
|
|
3832
|
+
// code IS ours — a detached `aegis code` that returns 0 while the child
|
|
3833
|
+
// failed tells a script nothing true.
|
|
3834
|
+
const opts = selfhost.spawnOptions(planned, process.env);
|
|
3835
|
+
const res = require('node:child_process').spawnSync(opts.exec, opts.args, {
|
|
3836
|
+
stdio: 'inherit',
|
|
3837
|
+
env: opts.env,
|
|
3838
|
+
});
|
|
3839
|
+
const code = typeof res.status === 'number' ? res.status : 1;
|
|
3840
|
+
app.exit(code);
|
|
3841
|
+
return;
|
|
3842
|
+
}
|
|
3843
|
+
} catch (err) {
|
|
3844
|
+
// A missing selfhost module is not fatal: it means this build predates the
|
|
3845
|
+
// packaged terminal face, and a window is still the right answer. Printed
|
|
3846
|
+
// rather than swallowed so a genuinely broken staging step is visible.
|
|
3847
|
+
if (app.isPackaged && !/MODULE_NOT_FOUND/.test(String(err && err.message))) {
|
|
3848
|
+
process.stderr.write(`aegis: terminal face hand-off failed: ${(err && err.message) || err}\n`);
|
|
3849
|
+
}
|
|
3850
|
+
}
|
|
3851
|
+
|
|
3786
3852
|
// A container/CI/headless server with no usable GPU crashes Chromium's GPU
|
|
3787
3853
|
// process in a retry loop that ends in a FATAL exit ("GPU process isn't
|
|
3788
3854
|
// usable. Goodbye.") — and that happens BEFORE app.whenReady() ever fires,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "aegis-desktop",
|
|
3
3
|
"productName": "AEGIS Desktop",
|
|
4
4
|
"desktopName": "aegis-desktop",
|
|
5
|
-
"version": "1.0.
|
|
5
|
+
"version": "1.0.29",
|
|
6
6
|
"description": "Thin Electron host for AEGIS — a local chat UI over the shared client/aegis.js transport. Ships transport + UI only; engine logic stays server-side.",
|
|
7
7
|
"author": {
|
|
8
8
|
"name": "AEGIS Code",
|