aegisone 1.0.22 → 1.0.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (226) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +1 -1
  3. package/SOURCE-OFFER.txt +9 -0
  4. package/bin/aegis.js +1 -322
  5. package/package.json +4 -2
  6. package/scripts/bump.mjs +1 -211
  7. package/scripts/bundle.js +1 -129
  8. package/scripts/predist.mjs +1 -939
  9. package/src/child.js +1 -285
  10. package/src/dispatch.js +1 -269
  11. package/src/doctor.js +1 -639
  12. package/src/host.js +1 -111
  13. package/src/permissions.js +1 -369
  14. package/src/probes.js +1 -159
  15. package/src/release.js +1 -409
  16. package/vendor/cli/bin/aegiscode.js +2 -914
  17. package/vendor/cli/package.json +3 -2
  18. package/vendor/cli/scripts/check.mjs +1 -52
  19. package/vendor/cli/scripts/demo.mjs +1 -94
  20. package/vendor/cli/scripts/predist.mjs +1 -75
  21. package/vendor/cli/scripts/runtests.mjs +1 -56
  22. package/vendor/cli/scripts/seal-gate.mjs +1 -74
  23. package/vendor/cli/src/agents.js +1 -139
  24. package/vendor/cli/src/app.js +1 -2932
  25. package/vendor/cli/src/art.js +1 -289
  26. package/vendor/cli/src/autonomous.js +1 -515
  27. package/vendor/cli/src/caps.js +1 -879
  28. package/vendor/cli/src/chatflow.js +1 -3020
  29. package/vendor/cli/src/checkpoint.js +1 -90
  30. package/vendor/cli/src/clipboard.js +1 -424
  31. package/vendor/cli/src/cloudsync.js +1 -528
  32. package/vendor/cli/src/commands.js +1 -4003
  33. package/vendor/cli/src/config.js +1 -581
  34. package/vendor/cli/src/connect.js +1 -349
  35. package/vendor/cli/src/credentials.js +1 -33
  36. package/vendor/cli/src/deps.js +1 -232
  37. package/vendor/cli/src/devrun.js +1 -187
  38. package/vendor/cli/src/diff.js +1 -333
  39. package/vendor/cli/src/diffview.js +1 -296
  40. package/vendor/cli/src/engine.js +1 -297
  41. package/vendor/cli/src/entitlement.js +1 -355
  42. package/vendor/cli/src/events.js +1 -707
  43. package/vendor/cli/src/export.js +1 -67
  44. package/vendor/cli/src/fingerprint.js +1 -592
  45. package/vendor/cli/src/format.js +1 -259
  46. package/vendor/cli/src/fuzzy.js +1 -119
  47. package/vendor/cli/src/gate.js +1 -55
  48. package/vendor/cli/src/history.js +1 -401
  49. package/vendor/cli/src/init.js +1 -175
  50. package/vendor/cli/src/input.js +1 -139
  51. package/vendor/cli/src/keys.js +1 -183
  52. package/vendor/cli/src/limits.js +1 -190
  53. package/vendor/cli/src/markdown.js +1 -306
  54. package/vendor/cli/src/mcp.js +1 -694
  55. package/vendor/cli/src/models.js +1 -487
  56. package/vendor/cli/src/naming.js +1 -229
  57. package/vendor/cli/src/overlays.js +1 -461
  58. package/vendor/cli/src/panels.js +1 -1418
  59. package/vendor/cli/src/permissions.js +1 -290
  60. package/vendor/cli/src/ping.js +1 -226
  61. package/vendor/cli/src/presence.js +1 -238
  62. package/vendor/cli/src/provenance.js +2 -182
  63. package/vendor/cli/src/render.js +1 -515
  64. package/vendor/cli/src/screen.js +1 -518
  65. package/vendor/cli/src/screens.js +1 -896
  66. package/vendor/cli/src/secret.js +1 -59
  67. package/vendor/cli/src/securefs.js +1 -359
  68. package/vendor/cli/src/settings.js +1 -155
  69. package/vendor/cli/src/shared.js +1 -52
  70. package/vendor/cli/src/sharedpaths.js +1 -53
  71. package/vendor/cli/src/signup.js +1 -156
  72. package/vendor/cli/src/summarize.js +1 -95
  73. package/vendor/cli/src/sysdiag.js +1 -585
  74. package/vendor/cli/src/system.js +1 -40
  75. package/vendor/cli/src/theme.js +1 -570
  76. package/vendor/cli/src/title.js +1 -220
  77. package/vendor/cli/src/todos.js +1 -115
  78. package/vendor/cli/src/tokens.js +1 -263
  79. package/vendor/cli/src/topup.js +1 -210
  80. package/vendor/cli/src/update.js +1 -181
  81. package/vendor/cli/vendor/client/aegis.js +1 -2179
  82. package/vendor/cli/vendor/client/attest.js +1 -442
  83. package/vendor/cli/vendor/client/authorship-key.js +1 -410
  84. package/vendor/cli/vendor/client/auto-provision.js +1 -134
  85. package/vendor/cli/vendor/client/brain-catalog.js +1 -268
  86. package/vendor/cli/vendor/client/byok-catalog.js +1 -230
  87. package/vendor/cli/vendor/client/credentials.js +1 -494
  88. package/vendor/cli/vendor/client/device-fingerprint.js +1 -141
  89. package/vendor/cli/vendor/client/drive-connect.js +1 -110
  90. package/vendor/cli/vendor/client/drive-upload.js +1 -174
  91. package/vendor/cli/vendor/client/env-file.js +1 -1273
  92. package/vendor/cli/vendor/client/fingerprint.js +1 -1064
  93. package/vendor/cli/vendor/client/foreign-memory.js +1 -669
  94. package/vendor/cli/vendor/client/google-signin.js +1 -133
  95. package/vendor/cli/vendor/client/hooks.js +1 -430
  96. package/vendor/cli/vendor/client/model-discovery.js +1 -373
  97. package/vendor/cli/vendor/client/platform.js +1 -937
  98. package/vendor/cli/vendor/client/prefs.js +1 -351
  99. package/vendor/cli/vendor/client/presence-constants.js +1 -107
  100. package/vendor/cli/vendor/client/presence.js +1 -438
  101. package/vendor/cli/vendor/client/record-vault.js +3 -1055
  102. package/vendor/cli/vendor/client/session-store.js +1 -548
  103. package/vendor/cli/vendor/client/topup.js +1 -297
  104. package/vendor/cli/vendor/client/touch.js +1 -458
  105. package/vendor/cli/vendor/client/update.js +1 -704
  106. package/vendor/cli/vendor/client/user-models.js +1 -381
  107. package/vendor/cli/vendor/desktop/lib/local/agents.js +1 -105
  108. package/vendor/cli/vendor/desktop/lib/local/autonomous.js +1 -1045
  109. package/vendor/cli/vendor/desktop/lib/local/claude-pro.js +1 -993
  110. package/vendor/cli/vendor/desktop/lib/local/context.js +1 -95
  111. package/vendor/cli/vendor/desktop/lib/local/engine.js +1 -3301
  112. package/vendor/cli/vendor/desktop/lib/local/entitlement.js +1 -660
  113. package/vendor/cli/vendor/desktop/lib/local/git-scope.js +1 -228
  114. package/vendor/cli/vendor/desktop/lib/local/local.js +1 -2135
  115. package/vendor/cli/vendor/desktop/lib/local/prompt.js +1 -275
  116. package/vendor/cli/vendor/desktop/lib/local/queue.js +1 -560
  117. package/vendor/cli/vendor/desktop/lib/local/session-rounds.js +1 -208
  118. package/vendor/cli/vendor/desktop/lib/local/shell.js +1 -680
  119. package/vendor/cli/vendor/desktop/lib/local/tools.js +1 -1238
  120. package/vendor/cli/vendor/desktop/lib/local/turn-guard.js +1 -300
  121. package/vendor/cli/vendor/desktop/lib/local/worktree-lock.js +1 -235
  122. package/vendor/cli/vendor/desktop/lib/settings.js +1 -890
  123. package/vendor/cli/vendor/desktop/renderer/usage.js +1 -1239
  124. package/vendor/cli/vendor/hosts/install.js +1 -638
  125. package/vendor/cli/vendor/hosts/openai-shim.js +1 -515
  126. package/vendor/cli/vendor/hosts/spec.js +1 -164
  127. package/vendor/cli/vendor/hosts/targets.js +1 -346
  128. package/vendor/cli/vendor/mcp/server.js +1 -221
  129. package/vendor/cli/vendor/mcp/tools.js +1 -408
  130. package/vendor/cli/vendor/one/src/child.js +1 -285
  131. package/vendor/cli/vendor/one/src/permissions.js +1 -369
  132. package/vendor/desktop/bin/aegis.js +1 -32
  133. package/vendor/desktop/lib/account-key.js +1 -56
  134. package/vendor/desktop/lib/auto.js +1 -430
  135. package/vendor/desktop/lib/avatar/companion.js +1 -698
  136. package/vendor/desktop/lib/avatar/cosmetics.js +1 -532
  137. package/vendor/desktop/lib/avatar/events.js +1 -344
  138. package/vendor/desktop/lib/avatar/holder-turn.js +1 -350
  139. package/vendor/desktop/lib/avatar/holders.js +1 -612
  140. package/vendor/desktop/lib/avatar/identity.js +1 -641
  141. package/vendor/desktop/lib/avatar/level.js +1 -368
  142. package/vendor/desktop/lib/avatar/mirror.js +1 -524
  143. package/vendor/desktop/lib/avatar/persona.js +1 -388
  144. package/vendor/desktop/lib/avatar/profile.js +1 -977
  145. package/vendor/desktop/lib/avatar/register.js +1 -307
  146. package/vendor/desktop/lib/avatar/store.js +1 -472
  147. package/vendor/desktop/lib/avatar/tiers.js +1 -38
  148. package/vendor/desktop/lib/avatar/transfer.js +1 -415
  149. package/vendor/desktop/lib/avatar/turn.js +1 -216
  150. package/vendor/desktop/lib/avatar/voice.js +1 -328
  151. package/vendor/desktop/lib/avatar/xp.js +1 -404
  152. package/vendor/desktop/lib/deep-link.js +1 -120
  153. package/vendor/desktop/lib/fingerprint.js +2 -347
  154. package/vendor/desktop/lib/google-connect.js +1 -227
  155. package/vendor/desktop/lib/local/agents.js +1 -105
  156. package/vendor/desktop/lib/local/autonomous.js +1 -1045
  157. package/vendor/desktop/lib/local/claude-pro.js +1 -993
  158. package/vendor/desktop/lib/local/context.js +1 -95
  159. package/vendor/desktop/lib/local/engine.js +1 -3301
  160. package/vendor/desktop/lib/local/entitlement.js +1 -660
  161. package/vendor/desktop/lib/local/git-scope.js +1 -228
  162. package/vendor/desktop/lib/local/local.js +1 -2135
  163. package/vendor/desktop/lib/local/prompt.js +1 -275
  164. package/vendor/desktop/lib/local/queue.js +1 -560
  165. package/vendor/desktop/lib/local/session-rounds.js +1 -208
  166. package/vendor/desktop/lib/local/shell.js +1 -680
  167. package/vendor/desktop/lib/local/telemetry.js +1 -470
  168. package/vendor/desktop/lib/local/tools.js +1 -1238
  169. package/vendor/desktop/lib/local/turn-guard.js +1 -300
  170. package/vendor/desktop/lib/local/worktree-lock.js +1 -235
  171. package/vendor/desktop/lib/provider-key-mirror.js +1 -252
  172. package/vendor/desktop/lib/quick-launcher.js +1 -84
  173. package/vendor/desktop/lib/settings.js +1 -890
  174. package/vendor/desktop/lib/sync/memory-queue.js +1 -60
  175. package/vendor/desktop/lib/sync/persist-gate.js +1 -148
  176. package/vendor/desktop/lib/sync/sessions.js +1 -106
  177. package/vendor/desktop/lib/window-state.js +1 -66
  178. package/vendor/desktop/main.js +1 -4529
  179. package/vendor/desktop/package.json +3 -2
  180. package/vendor/desktop/preload.js +1 -636
  181. package/vendor/desktop/renderer/app.js +1 -6660
  182. package/vendor/desktop/renderer/avatar/assemble.js +1 -335
  183. package/vendor/desktop/renderer/avatar/avatar.js +1 -380
  184. package/vendor/desktop/renderer/avatar/cards.js +1 -141
  185. package/vendor/desktop/renderer/avatar/hud.js +1 -206
  186. package/vendor/desktop/renderer/avatar/machine.js +1 -213
  187. package/vendor/desktop/renderer/avatar/pane.js +1 -439
  188. package/vendor/desktop/renderer/avatar/parts.js +1 -437
  189. package/vendor/desktop/renderer/budget.js +1 -168
  190. package/vendor/desktop/renderer/companion.js +1 -223
  191. package/vendor/desktop/renderer/diff.js +1 -359
  192. package/vendor/desktop/renderer/diffview.js +1 -336
  193. package/vendor/desktop/renderer/fingerprint.js +3 -736
  194. package/vendor/desktop/renderer/markdown.js +1 -168
  195. package/vendor/desktop/renderer/provider-toolbar.js +1 -134
  196. package/vendor/desktop/renderer/providers.js +1 -259
  197. package/vendor/desktop/renderer/quick.js +1 -191
  198. package/vendor/desktop/renderer/stream-policy.js +1 -306
  199. package/vendor/desktop/renderer/transcript-view.js +1 -323
  200. package/vendor/desktop/renderer/usage.js +1 -1239
  201. package/vendor/desktop/vendor/aegis.js +1 -2179
  202. package/vendor/desktop/vendor/attest.js +1 -442
  203. package/vendor/desktop/vendor/authorship-key.js +1 -410
  204. package/vendor/desktop/vendor/auto-provision.js +1 -134
  205. package/vendor/desktop/vendor/brain-catalog.js +1 -268
  206. package/vendor/desktop/vendor/byok-catalog.js +1 -230
  207. package/vendor/desktop/vendor/credentials.js +1 -494
  208. package/vendor/desktop/vendor/device-fingerprint.js +1 -141
  209. package/vendor/desktop/vendor/drive-connect.js +1 -110
  210. package/vendor/desktop/vendor/drive-upload.js +1 -174
  211. package/vendor/desktop/vendor/env-file.js +1 -1273
  212. package/vendor/desktop/vendor/fingerprint.js +1 -1064
  213. package/vendor/desktop/vendor/foreign-memory.js +1 -669
  214. package/vendor/desktop/vendor/google-signin.js +1 -133
  215. package/vendor/desktop/vendor/hooks.js +1 -430
  216. package/vendor/desktop/vendor/model-discovery.js +1 -373
  217. package/vendor/desktop/vendor/platform.js +1 -937
  218. package/vendor/desktop/vendor/prefs.js +1 -351
  219. package/vendor/desktop/vendor/presence-constants.js +1 -107
  220. package/vendor/desktop/vendor/presence.js +1 -438
  221. package/vendor/desktop/vendor/record-vault.js +3 -1055
  222. package/vendor/desktop/vendor/session-store.js +1 -548
  223. package/vendor/desktop/vendor/topup.js +1 -297
  224. package/vendor/desktop/vendor/touch.js +1 -458
  225. package/vendor/desktop/vendor/update.js +1 -704
  226. package/vendor/desktop/vendor/user-models.js +1 -381
@@ -1,340 +1,7 @@
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
- // AEGIS Code (aegiscode) — source: https://github.com/aegisinfo/aegiscode-plugin
5
- // Conveying a modified copy, or running one as a network service, owes the
6
- // corresponding source under this licence (§5/§13) — see LICENSING.md.
7
- 'use strict';
8
-
9
- /**
10
- * `aegiscode` — the AEGIS terminal host.
11
- *
12
- * Third host over the same two shared pieces the other two use: the thin
13
- * transport (client/aegis.js) and the tool registry (mcp/tools.js). The MCP
14
- * host answers a coding agent's tool calls; the desktop is a window; this is
15
- * the shell. None of them owns a brain — routing, tiers, memory and billing all
16
- * stay behind aegiscloud.org.
17
- *
18
- * This file is argument parsing and process lifecycle only. Everything
19
- * testable lives in ../src/app.js.
20
- */
21
-
22
- const path = require('node:path');
23
-
24
- // A closed pipe is not a failure. `aegiscode --terminal | head`, PowerShell's
25
- // `| Select-Object -First 5`, and a pager the user quits all close the read end
26
- // while we still have lines to write, and the default unhandled `error` event
27
- // on stdout turns that into a stack trace over the answer. Every line of output
28
- // this host produces is disposable, so the first EPIPE ends the process cleanly.
29
- for (const stream of [process.stdout, process.stderr]) {
30
- stream.on('error', (e) => {
31
- if (e && (e.code === 'EPIPE' || e.code === 'ERR_STREAM_DESTROYED')) process.exit(0);
32
- throw e;
33
- });
34
- }
35
-
36
- const HELP = `aegiscode — AEGIS in your shell.
37
-
38
- Usage:
39
- aegiscode interactive session
40
- aegiscode "question" one-shot, then exit
41
- aegiscode -p "question" same, explicit
42
- echo "q" | aegiscode -p - read the prompt from stdin
43
-
44
- Account:
45
- aegiscode connect sign this machine in — registers a device account
46
- if it has none (idempotent per machine), and that
47
- key is what cloud memory and the record vault use
48
- aegiscode connect --status is this machine connected? (--json; exit 1 if not)
49
- aegiscode connect --logout sign out (forget the saved key here)
50
- aegiscode login [<key>] save your AEGIS API key (prompts, no echo, if omitted)
51
- aegiscode logout remove the saved key
52
- aegiscode key status show which key is in use and where it came from
53
- aegiscode topup [EUR] add credit to the token bank (2..1000, default 10):
54
- opens the payment page, then confirms the credit
55
- here — the account this machine auto-provisions
56
- has no browser session, so the page cannot show it
57
-
58
- Automation:
59
- aegiscode autonomous help run queued tasks with no terminal at all
60
- aegiscode mcp install put AEGIS inside VS Code / Cursor / Zed /
61
- Cline / Windsurf / … ('mcp list' shows them)
62
- aegiscode mcp status which editors are configured, and do they work
63
- aegiscode mcp shim OpenAI-compatible endpoint for clients that
64
- take a base URL but speak no MCP
65
- aegiscode mcp help all subcommands and their flags
66
-
67
- Attestation (φ(α) — a sealed record of what a session was):
68
- aegiscode fingerprint status which authorship key is in use, and where
69
- aegiscode fingerprint keygen mint a private key (0600, never printed)
70
- aegiscode fingerprint mint seal the last session as a record
71
- aegiscode fingerprint verify <file> recompute a record's attestation
72
- aegiscode fingerprint backup --to DIR copy the key somewhere safe
73
- aegiscode fingerprint publish [<file>] publish a record, link the copy
74
- aegiscode fingerprint anchor <file> is the published copy still ours?
75
- aegiscode fingerprint vault --audit what is in the vault, and is a key in it
76
- aegiscode fingerprint help all subcommands and their flags
77
-
78
- Code protection (the agent-key gate on aegiscodex-dev / aegiscode-plugin):
79
- aegiscode gate status can THIS machine edit a gated tree?
80
- aegiscode gate import-key [PATH] adopt a key dropped at PATH
81
- (default ~/Downloads/agent.key),
82
- then delete PATH
83
- aegiscode gate bind-machine trust this machine in the manifest
84
- aegiscode gate rotate mint a fresh key, burn the old one
85
- aegiscode gate add-key add another key (from stdin)
86
- aegiscode gate lock-status the server-side half of the lock
87
- aegiscode gate help all subcommands and their flags
88
-
89
- Provenance (this binary, and whether it is still the published one):
90
- aegiscode provenance licence, source, and a self-check of
91
- this build against the published seal
92
- (--json for scripts; exit 1 if a
93
- sealed unit has moved)
94
-
95
- Options:
96
- -m, --model <id> pin a model id (see /models; default: server choice)
97
- --class <name> run this turn on aegis|byok|local|pro. The one-shot
98
- path had no way to state a class, so '-p' always ran
99
- the pooled route (DEFAULT_CLASS) no matter what was
100
- pinned — a headless turn could not use a BYOK key at
101
- all. '--class byok' needs '--model <provider>:<model>'.
102
- --base <url> API base (default $AEGIS_API_BASE or aegiscloud.org)
103
- --key <key> API key for THIS RUN only — it is not saved. Use
104
- "aegiscode login" to store one for good.
105
- --json with -p: emit JSON instead of text
106
- --no-stream buffer the answer instead of streaming it
107
- --max-tokens <n> output ceiling hint
108
- --light light theme
109
- --width <cols> force a render width (useful for piping/logs)
110
- --automode skip tool-approval prompts (exec/writeFile/editFile
111
- run without asking) — same as the in-session /automode
112
- --yolo alias of --automode (the pre-rename spelling)
113
- --ascii draw with the ASCII mark and glyph set (no Unicode).
114
- Same as AEGIS_ART=ascii; /terminal ascii toggles it
115
- mid-session.
116
- --no-color no colour at all (same as NO_COLOR=1)
117
- --terminal print the resolved terminal capabilities and exit —
118
- one report shape on every platform, so pasting it
119
- from PowerShell (or into a bug report) reads the same
120
- as pasting it from zsh
121
- -c, --continue skip onboarding and resume the most recent session
122
- -h, --help this text
123
- -v, --version print the version
124
-
125
- In-session: type /help for commands, /quit to exit, esc/ctrl+c to interrupt a
126
- running call. Plain text is a prompt (identical to /ask) — a question that
127
- needs a file read, a shell command, or an edit is handled the same turn.
128
- `;
129
-
130
- function parseArgs(argv) {
131
- const opts = {
132
- model: null,
133
- base: null,
134
- key: null,
135
- json: false,
136
- // No `--class` flag given: `null` (not DEFAULT_CLASS) so the stored config
137
- // pin still wins, exactly as it does for a launch with no `--model`.
138
- class: null,
139
- stream: true,
140
- maxTokens: undefined,
141
- light: false,
142
- width: null,
143
- yolo: false,
144
- // Three-state, like `color`: `null` means "no art flag was given, let the
145
- // capability probe decide". It must NOT default to `false`, because `false`
146
- // is how `--unicode` is spelled — a default of `false` sets
147
- // `AEGIS_ART=unicode` on every run and silently out-ranks the legacy-console
148
- // ASCII downgrade, so a plain `aegiscode` on an old Windows console would
149
- // draw Unicode blocks it cannot render.
150
- ascii: null,
151
- color: null,
152
- terminal: false,
153
- continue: false,
154
- prompt: null,
155
- help: false,
156
- version: false,
157
- command: null,
158
- commandArg: null,
159
- // `autonomous` owns the rest of the line verbatim (its flags are the
160
- // subcommand's, not this parser's) — see the `head === 'autonomous'` branch.
161
- commandArgv: null,
162
- };
163
- const rest = [];
164
-
165
- // An account subcommand is `argv[0]` and nothing else — position 0 only, so
166
- // `aegiscode -p "key"` (a one-shot prompt whose text happens to be one of
167
- // these words) is never hijacked into an account operation.
168
- const head = argv[0];
169
- if (head && !head.startsWith('-') && ACCOUNT_COMMANDS.has(head)) {
170
- const arg = argv[1];
171
- opts.command = head;
172
- opts.commandArg = arg && !arg.startsWith('-') ? arg : null;
173
- argv = argv.slice(opts.commandArg ? 2 : 1);
174
- } else if (head === 'autonomous') {
175
- // Same position-0 rule, one difference: a queue subcommand owns the REST of
176
- // the line (including flags, which are the subcommand's, not the session
177
- // parser's), so the tail is handed over verbatim instead of parsed here.
178
- // `aegiscode autonomous "write a file"` is not a thing — `add` is — so a
179
- // bare `autonomous` is help, not a prompt.
180
- const sub = argv[1] && !argv[1].startsWith('-') ? argv[1] : 'help';
181
- opts.command = 'autonomous';
182
- opts.commandArg = sub;
183
- opts.commandArgv = argv.slice(argv[1] && !argv[1].startsWith('-') ? 2 : 1);
184
- argv = [];
185
- } else if (head === 'mcp') {
186
- // The editor-integration surface, wired exactly like `autonomous` and for
187
- // the same reason: everything after `mcp <sub>` is the subcommand's argv
188
- // (`--target cursor,zed` is not this parser's flag), so the tail is handed
189
- // over untouched. A bare `mcp` is the status report — the question a user
190
- // actually has ("is AEGIS in my editors?") — not a prompt and not an error.
191
- const sub = argv[1] && !argv[1].startsWith('-') ? argv[1] : 'status';
192
- opts.command = 'mcp';
193
- opts.commandArg = sub;
194
- opts.commandArgv = argv.slice(argv[1] && !argv[1].startsWith('-') ? 2 : 1);
195
- argv = [];
196
- } else if (head === 'fingerprint') {
197
- // Same position-0 rule and the same reason as `mcp`/`autonomous`: the tail
198
- // belongs to the subcommand (`--secret-file`, `--code-root`, `--force` are
199
- // not this parser's flags), so it is handed over verbatim. A bare
200
- // `fingerprint` is the status report — "is a key configured here?" is the
201
- // question a user has — not a prompt and not an error.
202
- const sub = argv[1] && !argv[1].startsWith('-') ? argv[1] : 'status';
203
- opts.command = 'fingerprint';
204
- opts.commandArg = sub;
205
- opts.commandArgv = argv.slice(argv[1] && !argv[1].startsWith('-') ? 2 : 1);
206
- argv = [];
207
- } else if (head === 'gate') {
208
- // Same position-0 rule and the same reason as `fingerprint`/`mcp`: the
209
- // tail belongs to the subcommand (`--cwd`, `--paths a b c`, `--keep` are
210
- // agent-gate.mjs's flags, not this parser's), so it is handed over
211
- // verbatim. A bare `gate` is the status report — "can this machine edit
212
- // here?" — not a prompt.
213
- const sub = argv[1] && !argv[1].startsWith('-') ? argv[1] : 'status';
214
- opts.command = 'gate';
215
- opts.commandArg = sub;
216
- opts.commandArgv = argv.slice(argv[1] && !argv[1].startsWith('-') ? 2 : 1);
217
- argv = [];
218
- } else if (head === 'connect') {
219
- // Same position-0 rule and the same passthrough as `gate`/`fingerprint`:
220
- // everything after `connect` is the subcommand's (`--status`, `--logout`,
221
- // `--app`, `--base`), so the tail is handed over verbatim — and a bare
222
- // `connect` means "sign this machine in", which is the thing a new user
223
- // actually needs, not a help page.
224
- opts.command = 'connect';
225
- opts.commandArg = null;
226
- opts.commandArgv = argv.slice(1);
227
- argv = [];
228
- } else if (head === 'provenance') {
229
- // Same position-0 rule and the same reason as `gate`: it is a one-shot
230
- // question about THIS BINARY, not a prompt that happens to start with the
231
- // word. Unlike `gate` the tail needs no passthrough — the only flag it
232
- // takes is `--json`, which this parser already owns.
233
- opts.command = 'provenance';
234
- argv = argv.slice(1);
235
- } else if (head === 'topup') {
236
- // Same position-0 rule and the same reason as `gate`: the one argument is
237
- // the amount (`aegiscode topup 20`), never a prompt whose text happens to
238
- // be "topup". A bare `aegiscode topup` means the default 10 EUR — the
239
- // server's own default — rather than usage text, because "fund this
240
- // account" is a complete intent.
241
- const amount = argv[1] && !argv[1].startsWith('-') ? argv[1] : null;
242
- opts.command = 'topup';
243
- opts.commandArg = amount;
244
- argv = amount ? argv.slice(2) : argv.slice(1);
245
- }
246
-
247
- for (let i = 0; i < argv.length; i++) {
248
- const a = argv[i];
249
- const next = () => {
250
- const v = argv[++i];
251
- if (v === undefined) throw new Error(`${a} needs a value`);
252
- return v;
253
- };
254
- switch (a) {
255
- case '-h':
256
- case '--help':
257
- opts.help = true;
258
- break;
259
- case '-v':
260
- case '--version':
261
- opts.version = true;
262
- break;
263
- case '-p':
264
- case '--print':
265
- // `-p` takes an optional prompt; a bare `-p` means "read stdin".
266
- opts.prompt = argv[i + 1] && !argv[i + 1].startsWith('-') ? next() : '-';
267
- break;
268
- case '-m':
269
- case '--model':
270
- opts.model = next();
271
- break;
272
- case '--class':
273
- opts.class = next();
274
- break;
275
- case '--base':
276
- opts.base = next();
277
- break;
278
- case '--key':
279
- opts.key = next();
280
- break;
281
- case '--json':
282
- opts.json = true;
283
- break;
284
- case '--no-stream':
285
- opts.stream = false;
286
- break;
287
- case '--stream':
288
- opts.stream = true;
289
- break;
290
- case '--max-tokens':
291
- opts.maxTokens = Number(next());
292
- break;
293
- case '--light':
294
- opts.light = true;
295
- break;
296
- case '--automode':
297
- case '--yolo':
298
- opts.yolo = true;
299
- break;
300
- case '-c':
301
- case '--continue':
302
- opts.continue = true;
303
- break;
304
- case '--width':
305
- opts.width = Number(next());
306
- break;
307
- case '--ascii':
308
- // The same switch as AEGIS_ART=ascii, spelled as a flag because it is
309
- // the one thing a user has to do to fix a mangled welcome mark, and
310
- // asking them to export a variable and restart the shell first is how
311
- // the mark stayed broken.
312
- opts.ascii = true;
313
- break;
314
- case '--unicode':
315
- opts.ascii = false;
316
- break;
317
- case '--no-color':
318
- case '--no-colour':
319
- opts.color = false;
320
- break;
321
- case '--color':
322
- case '--colour':
323
- opts.color = true;
324
- break;
325
- case '--terminal':
326
- case '--caps':
327
- opts.terminal = true;
328
- break;
329
- default:
330
- if (a.startsWith('-') && a !== '-') throw new Error(`unknown option: ${a}`);
331
- rest.push(a);
332
- }
333
- }
334
- if (!opts.prompt && rest.length) opts.prompt = rest.join(' ');
335
- return opts;
336
- }
337
-
4
+ "use strict";const path=require("node:path");for(const e of[process.stdout,process.stderr])e.on("error",(e=>{throw!e||"EPIPE"!==e.code&&"ERR_STREAM_DESTROYED"!==e.code||process.exit(0),e}));const HELP="aegiscode — AEGIS in your shell.\n\nUsage:\n aegiscode interactive session\n aegiscode \"question\" one-shot, then exit\n aegiscode -p \"question\" same, explicit\n echo \"q\" | aegiscode -p - read the prompt from stdin\n\nAccount:\n aegiscode connect sign this machine in — registers a device account\n if it has none (idempotent per machine), and that\n key is what cloud memory and the record vault use\n aegiscode connect --status is this machine connected? (--json; exit 1 if not)\n aegiscode connect --logout sign out (forget the saved key here)\n aegiscode login [<key>] save your AEGIS API key (prompts, no echo, if omitted)\n aegiscode logout remove the saved key\n aegiscode key status show which key is in use and where it came from\n aegiscode topup [EUR] add credit to the token bank (2..1000, default 10):\n opens the payment page, then confirms the credit\n here — the account this machine auto-provisions\n has no browser session, so the page cannot show it\n\nAutomation:\n aegiscode autonomous help run queued tasks with no terminal at all\n aegiscode mcp install put AEGIS inside VS Code / Cursor / Zed /\n Cline / Windsurf / … ('mcp list' shows them)\n aegiscode mcp status which editors are configured, and do they work\n aegiscode mcp shim OpenAI-compatible endpoint for clients that\n take a base URL but speak no MCP\n aegiscode mcp help all subcommands and their flags\n\nAttestation (φ(α) — a sealed record of what a session was):\n aegiscode fingerprint status which authorship key is in use, and where\n aegiscode fingerprint keygen mint a private key (0600, never printed)\n aegiscode fingerprint mint seal the last session as a record\n aegiscode fingerprint verify <file> recompute a record's attestation\n aegiscode fingerprint backup --to DIR copy the key somewhere safe\n aegiscode fingerprint publish [<file>] publish a record, link the copy\n aegiscode fingerprint anchor <file> is the published copy still ours?\n aegiscode fingerprint vault --audit what is in the vault, and is a key in it\n aegiscode fingerprint help all subcommands and their flags\n\nCode protection (the agent-key gate on aegiscodex-dev / aegiscode-plugin):\n aegiscode gate status can THIS machine edit a gated tree?\n aegiscode gate import-key [PATH] adopt a key dropped at PATH\n (default ~/Downloads/agent.key),\n then delete PATH\n aegiscode gate bind-machine trust this machine in the manifest\n aegiscode gate rotate mint a fresh key, burn the old one\n aegiscode gate add-key add another key (from stdin)\n aegiscode gate lock-status the server-side half of the lock\n aegiscode gate help all subcommands and their flags\n\nProvenance (this binary, and whether it is still the published one):\n aegiscode provenance licence, source, and a self-check of\n this build against the published seal\n (--json for scripts; exit 1 if a\n sealed unit has moved)\n\nOptions:\n -m, --model <id> pin a model id (see /models; default: server choice)\n --class <name> run this turn on aegis|byok|local|pro. The one-shot\n path had no way to state a class, so '-p' always ran\n the pooled route (DEFAULT_CLASS) no matter what was\n pinned — a headless turn could not use a BYOK key at\n all. '--class byok' needs '--model <provider>:<model>'.\n --base <url> API base (default $AEGIS_API_BASE or aegiscloud.org)\n --key <key> API key for THIS RUN only — it is not saved. Use\n \"aegiscode login\" to store one for good.\n --json with -p: emit JSON instead of text\n --no-stream buffer the answer instead of streaming it\n --max-tokens <n> output ceiling hint\n --light light theme\n --width <cols> force a render width (useful for piping/logs)\n --automode skip tool-approval prompts (exec/writeFile/editFile\n run without asking) — same as the in-session /automode\n --yolo alias of --automode (the pre-rename spelling)\n --ascii draw with the ASCII mark and glyph set (no Unicode).\n Same as AEGIS_ART=ascii; /terminal ascii toggles it\n mid-session.\n --no-color no colour at all (same as NO_COLOR=1)\n --terminal print the resolved terminal capabilities and exit —\n one report shape on every platform, so pasting it\n from PowerShell (or into a bug report) reads the same\n as pasting it from zsh\n -c, --continue skip onboarding and resume the most recent session\n -h, --help this text\n -v, --version print the version\n\nIn-session: type /help for commands, /quit to exit, esc/ctrl+c to interrupt a\nrunning call. Plain text is a prompt (identical to /ask) — a question that\nneeds a file read, a shell command, or an edit is handled the same turn.\n";function parseArgs(e){const s={model:null,base:null,key:null,json:!1,class:null,stream:!0,maxTokens:void 0,light:!1,width:null,yolo:!1,ascii:null,color:null,terminal:!1,continue:!1,prompt:null,help:!1,version:!1,command:null,commandArg:null,commandArgv:null},t=[],n=e[0];if(n&&!n.startsWith("-")&&ACCOUNT_COMMANDS.has(n)){const t=e[1];s.command=n,s.commandArg=t&&!t.startsWith("-")?t:null,e=e.slice(s.commandArg?2:1)}else if("autonomous"===n){const t=e[1]&&!e[1].startsWith("-")?e[1]:"help";s.command="autonomous",s.commandArg=t,s.commandArgv=e.slice(e[1]&&!e[1].startsWith("-")?2:1),e=[]}else if("mcp"===n){const t=e[1]&&!e[1].startsWith("-")?e[1]:"status";s.command="mcp",s.commandArg=t,s.commandArgv=e.slice(e[1]&&!e[1].startsWith("-")?2:1),e=[]}else if("fingerprint"===n){const t=e[1]&&!e[1].startsWith("-")?e[1]:"status";s.command="fingerprint",s.commandArg=t,s.commandArgv=e.slice(e[1]&&!e[1].startsWith("-")?2:1),e=[]}else if("gate"===n){const t=e[1]&&!e[1].startsWith("-")?e[1]:"status";s.command="gate",s.commandArg=t,s.commandArgv=e.slice(e[1]&&!e[1].startsWith("-")?2:1),e=[]}else if("connect"===n)s.command="connect",s.commandArg=null,s.commandArgv=e.slice(1),e=[];else if("provenance"===n)s.command="provenance",e=e.slice(1);else if("topup"===n){const t=e[1]&&!e[1].startsWith("-")?e[1]:null;s.command="topup",s.commandArg=t,e=t?e.slice(2):e.slice(1)}for(let n=0;n<e.length;n++){const o=e[n],r=()=>{const s=e[++n];if(void 0===s)throw new Error(`${o} needs a value`);return s};switch(o){case"-h":case"--help":s.help=!0;break;case"-v":case"--version":s.version=!0;break;case"-p":case"--print":s.prompt=e[n+1]&&!e[n+1].startsWith("-")?r():"-";break;case"-m":case"--model":s.model=r();break;case"--class":s.class=r();break;case"--base":s.base=r();break;case"--key":s.key=r();break;case"--json":s.json=!0;break;case"--no-stream":s.stream=!1;break;case"--stream":s.stream=!0;break;case"--max-tokens":s.maxTokens=Number(r());break;case"--light":s.light=!0;break;case"--automode":case"--yolo":s.yolo=!0;break;case"-c":case"--continue":s.continue=!0;break;case"--width":s.width=Number(r());break;case"--ascii":s.ascii=!0;break;case"--unicode":s.ascii=!1;break;case"--no-color":case"--no-colour":s.color=!1;break;case"--color":case"--colour":s.color=!0;break;case"--terminal":case"--caps":s.terminal=!0;break;default:if(o.startsWith("-")&&"-"!==o)throw new Error(`unknown option: ${o}`);t.push(o)}}return!s.prompt&&t.length&&(s.prompt=t.join(" ")),s}
338
5
  /**
339
6
  * `aegiscode provenance` — what this binary is, and whether its safety files are
340
7
  * the ones that were published.
@@ -350,583 +17,4 @@ function parseArgs(argv) {
350
17
  * cheap attack must be the loud one). A fork that has deliberately rebuilt is
351
18
  * expected to regenerate the manifest and exit 0 naming itself; one that has
352
19
  * not now says so instead of staying silent.
353
- */
354
- function runProvenance(opts = {}) {
355
- const pkg = require(path.join(__dirname, '..', 'package.json'));
356
- const provenance = require('../src/provenance.js');
357
- const described = provenance.describe({ version: pkg.version });
358
- if (opts.json) {
359
- process.stdout.write(
360
- JSON.stringify(
361
- {
362
- product: provenance.IDENTITY.product,
363
- bin: provenance.IDENTITY.bin,
364
- version: pkg.version,
365
- license: provenance.IDENTITY.license,
366
- source: provenance.IDENTITY.source,
367
- homepage: provenance.IDENTITY.homepage,
368
- copyright: provenance.IDENTITY.copyright,
369
- safety: {
370
- ok: described.report.ok,
371
- checked: described.report.checked,
372
- problems: described.report.problems,
373
- },
374
- },
375
- null,
376
- 2
377
- ) + '\n'
378
- );
379
- return described.ok ? 0 : 1;
380
- }
381
- process.stdout.write(described.text);
382
- return described.ok ? 0 : 1;
383
- }
384
-
385
- /**
386
- * Account subcommands: the in-band way to give this host a key.
387
- *
388
- * They exist because an `AEGIS_API_KEY` export was previously the *only* way
389
- * in, and an export does not survive a new terminal. `--key` remains purely
390
- * per-run (CI, a rotation test) so there is exactly one thing a user has to
391
- * remember: `aegiscode login` saves it, `aegiscode logout` removes it.
392
- */
393
- const ACCOUNT_COMMANDS = new Set(['login', 'logout', 'key']);
394
-
395
- /**
396
- * Run `login` / `logout` / `key` and return a process exit code.
397
- *
398
- * Exit codes are meaningful because these are the commands a script calls:
399
- * 0 = done, 1 = the server refused the credential, 2 = no credential and no
400
- * way to ask for one (no TTY).
401
- */
402
- async function runAccountCommand(command, arg, io = {}) {
403
- const stdout = io.stdout || process.stdout;
404
- const stderr = io.stderr || process.stderr;
405
- const stdin = io.stdin || process.stdin;
406
- const { credentials, readSecret, maskKey } = loadAccountDeps();
407
-
408
- const where = () => credentials.credentialsPath();
409
-
410
- if (command === 'logout' || (command === 'key' && ['clear', 'remove', 'rm'].includes(String(arg || '').toLowerCase()))) {
411
- const res = credentials.clearApiKey();
412
- stdout.write(
413
- res.cleared
414
- ? `aegiscode: key removed from ${res.path}\n`
415
- : 'aegiscode: no saved key to remove\n'
416
- );
417
- if (credentials.legacyKeyOnDisk()) {
418
- stdout.write(
419
- 'aegiscode: note — a plaintext copy is also in config.json, written by an older ' +
420
- 'AEGIS CLI; delete its "aegiscloud" block as well to finish removing it\n'
421
- );
422
- }
423
- return 0;
424
- }
425
-
426
- if (command === 'key' && ['status', 'show', ''].includes(String(arg || '').toLowerCase())) {
427
- const st = credentials.keyStatus();
428
- if (io.json) {
429
- stdout.write(
430
- JSON.stringify(
431
- {
432
- configured: st.configured,
433
- source: st.source,
434
- source_label: credentials.sourceLabel(st.source),
435
- path: st.path,
436
- file_mode: st.fileMode,
437
- masked: st.configured ? maskKey(st.key) : null,
438
- memory_token: st.memoryToken,
439
- verified_at: st.verifiedAt,
440
- plaintext_copy_in_config: st.legacyPlaintext,
441
- },
442
- null,
443
- 2
444
- ) + '\n'
445
- );
446
- return st.configured ? 0 : 1;
447
- }
448
- stdout.write(
449
- [
450
- `key: ${st.configured ? maskKey(st.key) : 'not set'}`,
451
- `source: ${credentials.sourceLabel(st.source)}`,
452
- `file: ${st.path}${st.fileMode ? ` (${st.fileMode})` : ''}`,
453
- `memory: ${st.memoryToken ? 'token held (cloud sync ready)' : 'no token'}`,
454
- st.verifiedAt ? `verified: ${st.verifiedAt}` : null,
455
- st.legacyPlaintext
456
- ? `note: a plaintext copy also sits in config.json — re-save with \`aegiscode login\` to move it`
457
- : null,
458
- ]
459
- .filter(Boolean)
460
- .join('\n') + '\n'
461
- );
462
- return st.configured ? 0 : 1;
463
- }
464
-
465
- // `login [<key>]` and `key <api_key>`: take the key inline or ask for it.
466
- let key = arg && arg !== 'status' ? String(arg).trim() : '';
467
- if (!key) {
468
- if (!stdin.isTTY) {
469
- stderr.write(
470
- 'aegiscode: no terminal to prompt on — pass the key: `aegiscode login <api_key>`\n' +
471
- ' (or set AEGIS_API_KEY for a single run)\n'
472
- );
473
- return 2;
474
- }
475
- key = await readSecret('AEGIS API key (kept off screen, Enter to cancel): ', { stdin, stdout });
476
- }
477
- if (!key) {
478
- stderr.write('aegiscode: no key given — nothing saved\n');
479
- return 2;
480
- }
481
-
482
- const { createApp } = require('../src/app.js');
483
- const app = createApp({ interactive: false });
484
- const res = await app.setApiKey(key);
485
- if (!res.ok) {
486
- stderr.write(`aegiscode: ${res.message || 'that key could not be saved'}\n`);
487
- return 2;
488
- }
489
- const who = res.account && (res.account.email || res.account.plan);
490
- stdout.write(`aegiscode: key saved to ${res.path}${who ? ` — ${who}` : ''}\n`);
491
- if (res.error) {
492
- const status = res.error.status;
493
- stderr.write(`aegiscode: the account check failed: ${res.error.message}\n`);
494
- if (status === 401 || status === 403) {
495
- stderr.write('aegiscode: the key is stored but the server refused it — re-run with a fresh key\n');
496
- return 1;
497
- }
498
- stderr.write('aegiscode: (stored anyway — the server could not be reached to confirm it)\n');
499
- return 0;
500
- }
501
- stdout.write('aegiscode: verified — run `aegiscode` to start a session\n');
502
- return 0;
503
- }
504
-
505
- /** Lazily required so `--version`/`--help` stay dependency-free and instant. */
506
- function loadAccountDeps() {
507
- const credentials = require('../src/credentials.js');
508
- const { readSecret } = require('../src/secret.js');
509
- const { maskKey } = require('../src/format.js');
510
- return { credentials, readSecret, maskKey };
511
- }
512
-
513
- function readStdin() {
514
- return new Promise((resolve) => {
515
- let buf = '';
516
- process.stdin.setEncoding('utf8');
517
- process.stdin.on('data', (c) => {
518
- buf += c;
519
- });
520
- process.stdin.on('end', () => resolve(buf.trim()));
521
- });
522
- }
523
-
524
- async function main(argv = process.argv.slice(2)) {
525
- let opts;
526
- try {
527
- opts = parseArgs(argv);
528
- } catch (e) {
529
- process.stderr.write(`aegiscode: ${e.message}\n\n${HELP}`);
530
- return 2;
531
- }
532
-
533
- if (opts.help) {
534
- process.stdout.write(HELP);
535
- return 0;
536
- }
537
-
538
- const pkg = require(path.join(__dirname, '..', 'package.json'));
539
- if (opts.version) {
540
- process.stdout.write(pkg.version + '\n');
541
- return 0;
542
- }
543
-
544
- // ── interlock (see src/limits.js) ────────────────────────────────────────
545
- //
546
- // The second gate, and it runs before every subcommand dispatch below — gate,
547
- // mcp, autonomous, provenance, the session — because a check that ran after
548
- // the dispatch it is supposed to stop is a check that reports instead of
549
- // gating.
550
- //
551
- // It asks whether the safety files are still the sealed set *as a whole*, and
552
- // when they are not it says exactly one bland thing — naming no file, no cause
553
- // and no remedy — and refuses the privileged subcommands (`gate`,
554
- // `provenance`, `mcp`), so the build that failed the check cannot use the
555
- // gate's own key management or report on itself. Sessions still start, marked
556
- // `AEGIS_REDUCED_MODE=1` for modules that opt-in.
557
- //
558
- // Deliberately NOT switchable by environment variable: a gate with a
559
- // documented off switch is a gate the manipulator reads about in the same file
560
- // as the gate. Re-sealing is a manual act —
561
- // `node tools/provenance.mjs lock --write` — and a tree that is mid-edit trips
562
- // this on purpose.
563
- //
564
- // This call site is the EARLIEST refusal, not the only one. `armed()` is
565
- // asked again, independently, by each module that owns one of these
566
- // privileges — src/gate.js, src/mcp.js, src/autonomous.js,
567
- // src/permissions.js — because a check invoked from exactly one place is
568
- // removed by deleting one line, and this is the file a manipulator is already
569
- // editing. Deleting the block below leaves four refusals behind, in four files
570
- // the sealed set covers.
571
- let interlockFired = false;
572
- try {
573
- const limits = require('../src/limits.js');
574
- interlockFired = limits.armed();
575
- if (interlockFired && limits.isPrivileged(opts.command)) return limits.refuse();
576
- } catch {
577
- /* a gate must never be the reason the program fails to start */
578
- }
579
-
580
- // ── the shared env file, before any credential is resolved ───────────────
581
- //
582
- // `~/.aegiscode/.env` read into process.env once. This is what makes key
583
- // setup ONE instruction in every host — "put it in ~/.aegiscode/.env" —
584
- // instead of a `login` plus a `/byok-key <provider>` prompt per provider:
585
- // both resolution paths already read AEGIS_API_KEY and <PROVIDER>_API_KEY
586
- // out of the environment (src/credentials.js, the byok class in the shared
587
- // engine), they simply had nothing filling it. A variable already exported
588
- // in the launching shell always wins. Placed AFTER the help/version
589
- // early-exits so those stay instant, and before caps because everything
590
- // below this point may resolve a credential.
591
- try {
592
- const { resolveClientModule } = require('../src/shared.js');
593
- const envResult = require(resolveClientModule('env-file.js')).loadEnvFile();
594
- if (envResult.loose) {
595
- process.stderr.write(
596
- `aegiscode: ${envResult.file} is readable by other accounts ` +
597
- `(mode ${envResult.mode.toString(8)}) — consider \`chmod 600\` on it.\n`
598
- );
599
- }
600
- } catch (e) {
601
- process.stderr.write(`aegiscode: could not read ~/.aegiscode/.env: ${e && e.message}\n`);
602
- }
603
-
604
- // ── terminal capabilities, resolved before anything else is loaded ────────
605
- //
606
- // Ordering is the whole point. `theme.js` materialises its palettes and its
607
- // glyph table at load time and `art.js` picks its stencil at load time, and
608
- // `app.js` pulls in both. Resolving caps first means the welcome screen is
609
- // drawn for the terminal actually in use — PowerShell with VT enabled gets
610
- // the same mark as zsh, a legacy console gets the ASCII pass — instead of
611
- // whatever the first probe guessed being frozen into a module that is never
612
- // re-evaluated.
613
- const { setCaps, describe } = require('../src/caps.js');
614
- const capEnv = { ...process.env };
615
- if (opts.ascii === true) capEnv.AEGIS_ART = 'ascii';
616
- if (opts.ascii === false) capEnv.AEGIS_ART = 'unicode';
617
- if (opts.color === false) capEnv.NO_COLOR = '1';
618
- if (opts.color === true) {
619
- // An explicit --color has to beat an inherited NO_COLOR, and NO_COLOR is
620
- // checked first, so it is removed rather than out-ranked.
621
- delete capEnv.NO_COLOR;
622
- capEnv.FORCE_COLOR = '3';
623
- }
624
- if (opts.width) capEnv.AEGIS_WIDTH = String(opts.width);
625
- setCaps(null, capEnv);
626
-
627
- // `--terminal` answers "why does it look like that here?" in one shape on
628
- // every platform, so a paste from PowerShell reads like one from zsh. It
629
- // prints the resolved values and exits before a session, a config read or a
630
- // network call can colour the answer.
631
- if (opts.terminal) {
632
- const rows = describe();
633
- const key = rows.reduce((m, [k]) => Math.max(m, k.length), 0);
634
- process.stdout.write(`aegiscode ${pkg.version} — terminal capabilities\n\n`);
635
- for (const [k, v] of rows) process.stdout.write(` ${k.padEnd(key)} ${v}\n`);
636
- process.stdout.write('\nOverride with --ascii / --color / --light / --width, or AEGIS_ART,\nAEGIS_STAR, AEGIS_COLOR, AEGIS_BACKGROUND, AEGIS_BACKGROUND_PROBE, AEGIS_VT,\nAEGIS_WIDTH (see README).\n');
637
- return 0;
638
- }
639
-
640
- // Apply the flags that the shared client reads from the environment, before
641
- // anything constructs it.
642
- if (opts.base) process.env.AEGIS_API_BASE = opts.base;
643
- if (opts.key) process.env.AEGIS_API_KEY = opts.key;
644
-
645
- // Account subcommands run before a session is built: they are one-shot,
646
- // non-interactive, and must work in a script (`aegiscode login "$KEY"`) as
647
- // well as at a prompt.
648
- // φ(α): the authorship key and the sealed session records. Dispatched here
649
- // rather than in the account set because its subcommands own their flags —
650
- // and before a session is built, because `fingerprint mint` must work with no
651
- // terminal at all (a CI job sealing what it just ran), exactly like the queue.
652
- if (opts.command === 'fingerprint') {
653
- const { runFingerprint } = require('../src/fingerprint.js');
654
- return runFingerprint(opts.commandArg || 'status', opts.commandArgv || [], {
655
- json: opts.json,
656
- stdout: process.stdout,
657
- stderr: process.stderr,
658
- });
659
- }
660
-
661
- // Signing this machine in (and registering it, on a fresh install). Before a
662
- // session is built, for the same reason `fingerprint` is: it is a one-shot
663
- // question with a scriptable answer, and it must work with no terminal at all
664
- // — the first-run prompt, CI, and `aegiscode connect --status` in a health
665
- // check all need it without a TUI.
666
- if (opts.command === 'connect') {
667
- const { runConnect } = require('../src/connect.js');
668
- return runConnect(opts.commandArgv || [], {
669
- json: opts.json,
670
- stdout: process.stdout,
671
- stderr: process.stderr,
672
- });
673
- }
674
-
675
- // The agent-key gate on aegiscodex-dev / aegiscode-plugin. Dispatched here,
676
- // before a session is built, for the same reason `fingerprint` is: it is a
677
- // one-shot administrative question ("can this machine edit that tree?"),
678
- // not a prompt, and it must work with no terminal at all (a fresh npm
679
- // install with no git clone is exactly the case this exists for).
680
- if (opts.command === 'gate') {
681
- const { runGate } = require('../src/gate.js');
682
- return runGate(opts.commandArg || 'status', opts.commandArgv || []);
683
- }
684
-
685
- // Funding the account, dispatched here rather than among the account commands
686
- // because it is interactive in a different way: it opens a browser and then
687
- // BLOCKS on the balance endpoint until the Stripe webhook lands the credit
688
- // (see src/topup.js for why blocking is right here and wrong in the desktop).
689
- // The one failure this fixes is the account auto-provision creates — a device
690
- // key whose owner can never sign in to `/topup`, the session-gated page every
691
- // old link pointed at.
692
- if (opts.command === 'topup') {
693
- const { runTopupCommand } = require('../src/topup.js');
694
- return runTopupCommand(opts.commandArg, {
695
- json: opts.json,
696
- stdin: process.stdin,
697
- stdout: process.stdout,
698
- stderr: process.stderr,
699
- });
700
- }
701
-
702
- if (ACCOUNT_COMMANDS.has(opts.command)) {
703
- return runAccountCommand(opts.command, opts.commandArg, {
704
- json: opts.json,
705
- stdin: process.stdin,
706
- stdout: process.stdout,
707
- stderr: process.stderr,
708
- });
709
- }
710
-
711
- // The work queue. Parsed at position 0 like the account subcommands (see
712
- // parseArgs), but dispatched here rather than there because it is the one
713
- // surface that must work with NO terminal at all: a systemd timer runs
714
- // `aegiscode autonomous proceed` from a unit with stdin on /dev/null, and a
715
- // cron job reads the exit status to decide whether to page somebody. So the
716
- // subcommand's own argv is handed over untouched, the process's real streams
717
- // are passed through, and the subcommand's exit code is what the shell sees
718
- // (0 done, 1 a task failed / another drain holds the lock, 2 usage or no
719
- // credential) — never the interactive chat path's "no terminal and no prompt".
720
- if (opts.command === 'autonomous') {
721
- // A drain IS the thing the presence panel exists to show: a machine working
722
- // through a queue with no terminal open. So this path beacons too — with
723
- // `autonomous: true` and the live pending depth — and it beacons BEFORE the
724
- // lock is taken, so a drain that exits immediately because another process
725
- // holds the lock still registers as "this machine is here".
726
- const presence = require('../src/presence.js');
727
- const credentials = require('../src/credentials.js');
728
- presence.start({
729
- credentials,
730
- autonomous: true,
731
- queueDepth: presence.queueDepthReader(),
732
- });
733
- // The beacon's timer is unref'd, so nothing here holds the process open;
734
- // this just cancels a scheduled beat that would otherwise fire mid-teardown.
735
- process.once('exit', () => presence.stop());
736
-
737
- const { runQueueCommand } = require('../src/autonomous.js');
738
- return runQueueCommand(opts.commandArg, opts.commandArgv || [], {
739
- json: opts.json,
740
- stdin: process.stdin,
741
- stdout: process.stdout,
742
- stderr: process.stderr,
743
- });
744
- }
745
-
746
- // The editor-integration surface. Dispatched here rather than among the
747
- // account commands because it is not about THIS run: `mcp install` edits files
748
- // other programs read, and `mcp serve` / `mcp shim` are long-running
749
- // processes that must not be wrapped in a session (they are what an editor
750
- // spawns behind a session of its own). Loaded lazily so `--help`,
751
- // `--version` and an ordinary prompt never pay for the host registry.
752
- if (opts.command === 'mcp') {
753
- const { runMcpCommand } = require('../src/mcp.js');
754
- return runMcpCommand(opts.commandArg, opts.commandArgv || [], {
755
- json: opts.json,
756
- stdin: process.stdin,
757
- stdout: process.stdout,
758
- stderr: process.stderr,
759
- });
760
- }
761
-
762
- // What this binary is, and whether its safety files are the published ones.
763
- // Dispatched before a session is built, like `gate`/`fingerprint`: it is a
764
- // question about this install, it must work with no terminal at all (an audit
765
- // script), and it must not depend on a credential being configured. It is NOT
766
- // part of the startup path — the runtime self-check that warns on stderr is in
767
- // src/provenance.js and runs below, for sessions.
768
- //
769
- // The interlock below runs first and can make `provenance` unavailable, which
770
- // is not an oversight: a build that fails the silent gate does not get to
771
- // report on itself.
772
- if (opts.command === 'provenance' && !interlockFired) {
773
- return runProvenance({ json: opts.json });
774
- }
775
-
776
- const { createApp } = require('../src/app.js');
777
-
778
- // ── provenance self-check (one stderr line, never fatal) ─────────────────
779
- //
780
- // A build whose gate, permission evaluator, approval classes or runner were
781
- // edited announces it, once, before the session starts — instead of importing
782
- // the neutered file and saying nothing. Never throws and never blocks: a
783
- // diagnostic that can stop the program it reports on is worse than none (see
784
- // src/provenance.js, which also records why a MISSING manifest is a failure
785
- // rather than a pass). A development tree silences it with
786
- // AEGIS_NO_PROVENANCE_CHECK=1 — and the silence is printed at the time, so it
787
- // is a fact on the record rather than a quiet default.
788
- //
789
- // Skipped when the interlock has already fired: that path emits exactly one
790
- // bland line, and following it with a more descriptive one would hand back
791
- // everything the bland line withheld.
792
- if (!interlockFired) try {
793
- const provenance = require('../src/provenance.js');
794
- const line = provenance.warning(provenance.selfCheck());
795
- if (line) process.stderr.write(line);
796
- } catch {
797
- /* a diagnostic must never be the reason a session fails to start */
798
- }
799
-
800
- // ── presence beacon (aegis1 /api/v1/heartbeat) ───────────────────────────
801
- //
802
- // "Who is running aegiscode right now" — the admin panel's presence card.
803
- // Started for every SESSION, not for the account/lifecycle subcommands above
804
- // (`login`, `key status`, `--version`, `mcp install` are things a user does
805
- // once, not a machine being present).
806
- //
807
- // Keyed on the credential store's own resolution (env → credentials.json →
808
- // config.json) so the beacon carries the key this session will actually use,
809
- // and on the machine fingerprint (client/presence.js) so one laptop is one
810
- // machine in the panel rather than one row per launch. No key ⇒ presence.js
811
- // returns an inert store: no timer, no request, no 401 loop.
812
- //
813
- // Never fatal: `start()` swallows a load failure and returns an inert store,
814
- // because a beacon is diagnostic and a session is not.
815
- const presence = require('../src/presence.js');
816
- presence.start({
817
- credentials: require('../src/credentials.js'),
818
- queueDepth: presence.queueDepthReader(),
819
- });
820
- // Every return path below ends the process, and the beacon's timer is
821
- // unref'd, so this is tidiness rather than a requirement — but it means a
822
- // quit never races a beat.
823
- process.once('exit', () => presence.stop());
824
-
825
- let prompt = opts.prompt;
826
- if (prompt === '-') {
827
- if (process.stdin.isTTY) {
828
- process.stderr.write('aegiscode: -p - expects a prompt on stdin\n');
829
- return 2;
830
- }
831
- prompt = await readStdin();
832
- if (!prompt) {
833
- process.stderr.write('aegiscode: empty stdin\n');
834
- return 2;
835
- }
836
- }
837
-
838
- const app = createApp({
839
- model: opts.model,
840
- class: opts.class,
841
- stream: opts.stream,
842
- light: opts.light,
843
- maxTokens: opts.maxTokens,
844
- width: opts.width ? () => opts.width : undefined,
845
- interactive: !prompt && Boolean(process.stdin.isTTY),
846
- // ONLY a flag states an answer here. This line used to read `!opts.yolo`,
847
- // which is a boolean on every launch — and `app.js`'s gate returns a pinned
848
- // `options.confirmMode` the moment it is not `undefined`, so that one `true`
849
- // short-circuited the store read the whole ON8 posture is built on: an
850
- // automode the user had turned on (`/automode`, the window's switch, both of
851
- // which persist) was overruled by the absence of a launch flag, and the CLI
852
- // kept asking for exactly as long as the process lived. `undefined` hands
853
- // the question to the one read — `resolveSkip()`, then `confirmPosture()` —
854
- // which is where the flag/env and the shared store are resolved, live, on
855
- // every tool round.
856
- confirmMode: opts.yolo ? false : undefined,
857
- continue: opts.continue,
858
- });
859
-
860
- if (prompt) return app.runOnce(prompt, { json: opts.json });
861
-
862
- if (!process.stdin.isTTY) {
863
- process.stderr.write(
864
- 'aegiscode: no terminal and no prompt. Use `aegiscode -p "question"` or pipe a prompt in.\n'
865
- );
866
- return 2;
867
- }
868
- // The reference leaves a resume hint on exit; without one there is no way to
869
- // discover that a session was persisted at all (`/resume` lists them, but a
870
- // user who just quit is not looking at a command list).
871
- //
872
- // It is written from two places on purpose, and latched so it can only ever
873
- // be written once. It used to be a single write after the await below, which
874
- // made the hint depend on the session promise settling: when the key pump
875
- // ended and the loop drained instead — the same failure that ate the alt
876
- // screen teardown — the process exited before this line ran, and the frames
877
- // differed by exactly these 81 bytes. That is what the parity suite was
878
- // reporting, and it was load-dependent: measured 3 of 4 runs losing the hint
879
- // while four pty runs competed for the cpu, 0 of 12 when they did not. The
880
- // teardown is guaranteed the same way (see chatflow.js); the hint now is too,
881
- // so the bytes no longer depend on which of the two paths ended the process.
882
- // The hint is handed to the screen module instead of being scheduled here.
883
- // It is emitted *by* `leaveAltScreen()`, i.e. by the restore itself, because
884
- // position cannot be guaranteed by ordering where three paths can reach the
885
- // teardown (the loop's `finally`, the session's `exit` handler, this file's
886
- // `exit` handler) and their relative order is timing-dependent. That race put
887
- // the same 81 bytes in two different positions from run to run — the parity
888
- // suite saw linux/darwin/win32 diverge and then converge, at random, with
889
- // platform swapped out for luck. See `queueExitNotice` in src/screen.js.
890
- const screen = require('../src/screen.js');
891
- screen.queueExitNotice('\nResume this session with:\n aegiscode --continue (or /resume for the list)\n');
892
- // A queued notice is consumed exactly once, by the first restore to run; the
893
- // flush covers the paths that never leave an alternate screen (a crash before
894
- // the screen was taken, a host that drives the loop with its own stdin), so
895
- // the hint cannot be lost by the very mechanism that guarantees its position.
896
- const leaveHint = () => {
897
- try {
898
- if (screen.isAltScreen()) screen.leaveAltScreen();
899
- screen.flushExitNotice();
900
- } catch { /* the terminal is already gone; nothing to say it to */ }
901
- };
902
- const running = app.runInteractive();
903
- process.once('exit', leaveHint);
904
- const code = await running;
905
- leaveHint();
906
- return code;
907
- }
908
-
909
- if (require.main === module) {
910
- main()
911
- .then(async (code) => {
912
- // Before this process exits, let an in-flight presence beat finish. A
913
- // one-shot run reaches this line in tens of milliseconds, and
914
- // `process.exit()` would otherwise kill the beacon's first request
915
- // mid-flight — the machine would run a whole command and still never
916
- // appear in the admin panel. Bounded (1.5 s) so the beacon can never be
917
- // the reason a CLI hangs; `flush()` is a no-op when nothing is in flight
918
- // or when the beacon is off.
919
- try {
920
- await require('../src/presence.js').flush();
921
- } catch {
922
- /* a beacon must never affect the exit code */
923
- }
924
- process.exit(code || 0);
925
- })
926
- .catch((e) => {
927
- process.stderr.write(`aegiscode: ${e && e.message ? e.message : e}\n`);
928
- process.exit(1);
929
- });
930
- }
931
-
932
- module.exports = { main, parseArgs, HELP, ACCOUNT_COMMANDS, runAccountCommand };
20
+ */function runProvenance(e={}){const s=require(path.join(__dirname,"..","package.json")),t=require("../src/provenance.js"),n=t.describe({version:s.version});return e.json?(process.stdout.write(JSON.stringify({product:t.IDENTITY.product,bin:t.IDENTITY.bin,version:s.version,license:t.IDENTITY.license,source:t.IDENTITY.source,homepage:t.IDENTITY.homepage,copyright:t.IDENTITY.copyright,safety:{ok:n.report.ok,checked:n.report.checked,problems:n.report.problems}},null,2)+"\n"),n.ok?0:1):(process.stdout.write(n.text),n.ok?0:1)}const ACCOUNT_COMMANDS=new Set(["login","logout","key"]);async function runAccountCommand(e,s,t={}){const n=t.stdout||process.stdout,o=t.stderr||process.stderr,r=t.stdin||process.stdin,{credentials:i,readSecret:a,maskKey:c}=loadAccountDeps();if("logout"===e||"key"===e&&["clear","remove","rm"].includes(String(s||"").toLowerCase())){const e=i.clearApiKey();return n.write(e.cleared?`aegiscode: key removed from ${e.path}\n`:"aegiscode: no saved key to remove\n"),i.legacyKeyOnDisk()&&n.write('aegiscode: note — a plaintext copy is also in config.json, written by an older AEGIS CLI; delete its "aegiscloud" block as well to finish removing it\n'),0}if("key"===e&&["status","show",""].includes(String(s||"").toLowerCase())){const e=i.keyStatus();return t.json?(n.write(JSON.stringify({configured:e.configured,source:e.source,source_label:i.sourceLabel(e.source),path:e.path,file_mode:e.fileMode,masked:e.configured?c(e.key):null,memory_token:e.memoryToken,verified_at:e.verifiedAt,plaintext_copy_in_config:e.legacyPlaintext},null,2)+"\n"),e.configured?0:1):(n.write([`key: ${e.configured?c(e.key):"not set"}`,`source: ${i.sourceLabel(e.source)}`,`file: ${e.path}${e.fileMode?` (${e.fileMode})`:""}`,"memory: "+(e.memoryToken?"token held (cloud sync ready)":"no token"),e.verifiedAt?`verified: ${e.verifiedAt}`:null,e.legacyPlaintext?"note: a plaintext copy also sits in config.json — re-save with `aegiscode login` to move it":null].filter(Boolean).join("\n")+"\n"),e.configured?0:1)}let d=s&&"status"!==s?String(s).trim():"";if(!d){if(!r.isTTY)return o.write("aegiscode: no terminal to prompt on — pass the key: `aegiscode login <api_key>`\n (or set AEGIS_API_KEY for a single run)\n"),2;d=await a("AEGIS API key (kept off screen, Enter to cancel): ",{stdin:r,stdout:n})}if(!d)return o.write("aegiscode: no key given — nothing saved\n"),2;const{createApp:l}=require("../src/app.js"),u=l({interactive:!1}),m=await u.setApiKey(d);if(!m.ok)return o.write(`aegiscode: ${m.message||"that key could not be saved"}\n`),2;const p=m.account&&(m.account.email||m.account.plan);if(n.write(`aegiscode: key saved to ${m.path}${p?` — ${p}`:""}\n`),m.error){const e=m.error.status;return o.write(`aegiscode: the account check failed: ${m.error.message}\n`),401===e||403===e?(o.write("aegiscode: the key is stored but the server refused it — re-run with a fresh key\n"),1):(o.write("aegiscode: (stored anyway — the server could not be reached to confirm it)\n"),0)}return n.write("aegiscode: verified — run `aegiscode` to start a session\n"),0}function loadAccountDeps(){const e=require("../src/credentials.js"),{readSecret:s}=require("../src/secret.js"),{maskKey:t}=require("../src/format.js");return{credentials:e,readSecret:s,maskKey:t}}function readStdin(){return new Promise((e=>{let s="";process.stdin.setEncoding("utf8"),process.stdin.on("data",(e=>{s+=e})),process.stdin.on("end",(()=>e(s.trim())))}))}async function main(e=process.argv.slice(2)){let s;try{s=parseArgs(e)}catch(e){return process.stderr.write(`aegiscode: ${e.message}\n\n${HELP}`),2}if(s.help)return process.stdout.write(HELP),0;const t=require(path.join(__dirname,"..","package.json"));if(s.version)return process.stdout.write(t.version+"\n"),0;let n=!1;try{const e=require("../src/limits.js");if(n=e.armed(),n&&e.isPrivileged(s.command))return e.refuse()}catch{}try{const{resolveClientModule:e}=require("../src/shared.js"),s=require(e("env-file.js")).loadEnvFile();s.loose&&process.stderr.write(`aegiscode: ${s.file} is readable by other accounts (mode ${s.mode.toString(8)}) — consider \`chmod 600\` on it.\n`)}catch(e){process.stderr.write(`aegiscode: could not read ~/.aegiscode/.env: ${e&&e.message}\n`)}const{setCaps:o,describe:r}=require("../src/caps.js"),i={...process.env};if(!0===s.ascii&&(i.AEGIS_ART="ascii"),!1===s.ascii&&(i.AEGIS_ART="unicode"),!1===s.color&&(i.NO_COLOR="1"),!0===s.color&&(delete i.NO_COLOR,i.FORCE_COLOR="3"),s.width&&(i.AEGIS_WIDTH=String(s.width)),o(null,i),s.terminal){const e=r(),s=e.reduce(((e,[s])=>Math.max(e,s.length)),0);process.stdout.write(`aegiscode ${t.version} — terminal capabilities\n\n`);for(const[t,n]of e)process.stdout.write(` ${t.padEnd(s)} ${n}\n`);return process.stdout.write("\nOverride with --ascii / --color / --light / --width, or AEGIS_ART,\nAEGIS_STAR, AEGIS_COLOR, AEGIS_BACKGROUND, AEGIS_BACKGROUND_PROBE, AEGIS_VT,\nAEGIS_WIDTH (see README).\n"),0}if(s.base&&(process.env.AEGIS_API_BASE=s.base),s.key&&(process.env.AEGIS_API_KEY=s.key),"fingerprint"===s.command){const{runFingerprint:e}=require("../src/fingerprint.js");return e(s.commandArg||"status",s.commandArgv||[],{json:s.json,stdout:process.stdout,stderr:process.stderr})}if("connect"===s.command){const{runConnect:e}=require("../src/connect.js");return e(s.commandArgv||[],{json:s.json,stdout:process.stdout,stderr:process.stderr})}if("gate"===s.command){const{runGate:e}=require("../src/gate.js");return e(s.commandArg||"status",s.commandArgv||[])}if("topup"===s.command){const{runTopupCommand:e}=require("../src/topup.js");return e(s.commandArg,{json:s.json,stdin:process.stdin,stdout:process.stdout,stderr:process.stderr})}if(ACCOUNT_COMMANDS.has(s.command))return runAccountCommand(s.command,s.commandArg,{json:s.json,stdin:process.stdin,stdout:process.stdout,stderr:process.stderr});if("autonomous"===s.command){const e=require("../src/presence.js"),t=require("../src/credentials.js");e.start({credentials:t,autonomous:!0,queueDepth:e.queueDepthReader()}),process.once("exit",(()=>e.stop()));const{runQueueCommand:n}=require("../src/autonomous.js");return n(s.commandArg,s.commandArgv||[],{json:s.json,stdin:process.stdin,stdout:process.stdout,stderr:process.stderr})}if("mcp"===s.command){const{runMcpCommand:e}=require("../src/mcp.js");return e(s.commandArg,s.commandArgv||[],{json:s.json,stdin:process.stdin,stdout:process.stdout,stderr:process.stderr})}if("provenance"===s.command&&!n)return runProvenance({json:s.json});const{createApp:a}=require("../src/app.js");if(!n)try{const e=require("../src/provenance.js"),s=e.warning(e.selfCheck());s&&process.stderr.write(s)}catch{}const c=require("../src/presence.js");c.start({credentials:require("../src/credentials.js"),queueDepth:c.queueDepthReader()}),process.once("exit",(()=>c.stop()));let d=s.prompt;if("-"===d){if(process.stdin.isTTY)return process.stderr.write("aegiscode: -p - expects a prompt on stdin\n"),2;if(d=await readStdin(),!d)return process.stderr.write("aegiscode: empty stdin\n"),2}const l=a({model:s.model,class:s.class,stream:s.stream,light:s.light,maxTokens:s.maxTokens,width:s.width?()=>s.width:void 0,interactive:!d&&Boolean(process.stdin.isTTY),confirmMode:!s.yolo&&void 0,continue:s.continue});if(d)return l.runOnce(d,{json:s.json});if(!process.stdin.isTTY)return process.stderr.write('aegiscode: no terminal and no prompt. Use `aegiscode -p "question"` or pipe a prompt in.\n'),2;const u=require("../src/screen.js");u.queueExitNotice("\nResume this session with:\n aegiscode --continue (or /resume for the list)\n");const m=()=>{try{u.isAltScreen()&&u.leaveAltScreen(),u.flushExitNotice()}catch{}},p=l.runInteractive();process.once("exit",m);const h=await p;return m(),h}require.main===module&&main().then((async e=>{try{await require("../src/presence.js").flush()}catch{}process.exit(e||0)})).catch((e=>{process.stderr.write(`aegiscode: ${e&&e.message?e.message:e}\n`),process.exit(1)})),module.exports={main:main,parseArgs:parseArgs,HELP:HELP,ACCOUNT_COMMANDS:ACCOUNT_COMMANDS,runAccountCommand:runAccountCommand};