aegisone 1.0.22 → 1.0.24
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/LICENSE +661 -0
- package/README.md +1 -1
- package/SOURCE-OFFER.txt +9 -0
- package/bin/aegis.js +1 -322
- package/package.json +4 -5
- package/scripts/bump.mjs +1 -211
- package/scripts/bundle.js +1 -129
- package/scripts/predist.mjs +1 -939
- package/src/child.js +1 -285
- package/src/dispatch.js +1 -269
- package/src/doctor.js +1 -639
- package/src/host.js +1 -111
- package/src/permissions.js +1 -369
- package/src/probes.js +1 -159
- package/src/release.js +1 -409
- package/vendor/cli/bin/aegiscode.js +2 -914
- package/vendor/cli/package.json +3 -7
- package/vendor/cli/scripts/check.mjs +1 -52
- package/vendor/cli/scripts/demo.mjs +1 -94
- package/vendor/cli/scripts/predist.mjs +1 -75
- package/vendor/cli/scripts/runtests.mjs +1 -56
- package/vendor/cli/scripts/seal-gate.mjs +1 -74
- package/vendor/cli/src/agents.js +1 -139
- package/vendor/cli/src/app.js +1 -2932
- package/vendor/cli/src/art.js +1 -289
- package/vendor/cli/src/autonomous.js +1 -515
- package/vendor/cli/src/caps.js +1 -879
- package/vendor/cli/src/chatflow.js +1 -3020
- package/vendor/cli/src/checkpoint.js +1 -90
- package/vendor/cli/src/clipboard.js +1 -424
- package/vendor/cli/src/cloudsync.js +1 -528
- package/vendor/cli/src/commands.js +1 -4003
- package/vendor/cli/src/config.js +1 -581
- package/vendor/cli/src/connect.js +1 -349
- package/vendor/cli/src/credentials.js +1 -33
- package/vendor/cli/src/deps.js +1 -232
- package/vendor/cli/src/devrun.js +1 -187
- package/vendor/cli/src/diff.js +1 -333
- package/vendor/cli/src/diffview.js +1 -296
- package/vendor/cli/src/engine.js +1 -297
- package/vendor/cli/src/entitlement.js +1 -355
- package/vendor/cli/src/events.js +1 -707
- package/vendor/cli/src/export.js +1 -67
- package/vendor/cli/src/fingerprint.js +1 -592
- package/vendor/cli/src/format.js +1 -259
- package/vendor/cli/src/fuzzy.js +1 -119
- package/vendor/cli/src/gate.js +1 -55
- package/vendor/cli/src/history.js +1 -401
- package/vendor/cli/src/init.js +1 -175
- package/vendor/cli/src/input.js +1 -139
- package/vendor/cli/src/keys.js +1 -183
- package/vendor/cli/src/limits.js +1 -190
- package/vendor/cli/src/markdown.js +1 -306
- package/vendor/cli/src/mcp.js +1 -694
- package/vendor/cli/src/models.js +1 -487
- package/vendor/cli/src/naming.js +1 -229
- package/vendor/cli/src/overlays.js +1 -461
- package/vendor/cli/src/panels.js +1 -1418
- package/vendor/cli/src/permissions.js +1 -290
- package/vendor/cli/src/ping.js +1 -226
- package/vendor/cli/src/presence.js +1 -238
- package/vendor/cli/src/provenance.js +2 -182
- package/vendor/cli/src/render.js +1 -515
- package/vendor/cli/src/screen.js +1 -518
- package/vendor/cli/src/screens.js +1 -896
- package/vendor/cli/src/secret.js +1 -59
- package/vendor/cli/src/securefs.js +1 -359
- package/vendor/cli/src/settings.js +1 -155
- package/vendor/cli/src/shared.js +1 -52
- package/vendor/cli/src/sharedpaths.js +1 -53
- package/vendor/cli/src/signup.js +1 -156
- package/vendor/cli/src/summarize.js +1 -95
- package/vendor/cli/src/sysdiag.js +1 -585
- package/vendor/cli/src/system.js +1 -40
- package/vendor/cli/src/theme.js +1 -570
- package/vendor/cli/src/title.js +1 -220
- package/vendor/cli/src/todos.js +1 -115
- package/vendor/cli/src/tokens.js +1 -263
- package/vendor/cli/src/topup.js +1 -210
- package/vendor/cli/src/update.js +1 -181
- package/vendor/cli/vendor/client/aegis.js +1 -2179
- package/vendor/cli/vendor/client/attest.js +1 -442
- package/vendor/cli/vendor/client/authorship-key.js +1 -410
- package/vendor/cli/vendor/client/auto-provision.js +1 -134
- package/vendor/cli/vendor/client/brain-catalog.js +1 -268
- package/vendor/cli/vendor/client/byok-catalog.js +1 -230
- package/vendor/cli/vendor/client/credentials.js +1 -494
- package/vendor/cli/vendor/client/device-fingerprint.js +1 -141
- package/vendor/cli/vendor/client/drive-connect.js +1 -110
- package/vendor/cli/vendor/client/drive-upload.js +1 -174
- package/vendor/cli/vendor/client/env-file.js +1 -1273
- package/vendor/cli/vendor/client/fingerprint.js +1 -1064
- package/vendor/cli/vendor/client/foreign-memory.js +1 -669
- package/vendor/cli/vendor/client/google-signin.js +1 -133
- package/vendor/cli/vendor/client/hooks.js +1 -430
- package/vendor/cli/vendor/client/model-discovery.js +1 -373
- package/vendor/cli/vendor/client/platform.js +1 -937
- package/vendor/cli/vendor/client/prefs.js +1 -351
- package/vendor/cli/vendor/client/presence-constants.js +1 -107
- package/vendor/cli/vendor/client/presence.js +1 -438
- package/vendor/cli/vendor/client/record-vault.js +3 -1055
- package/vendor/cli/vendor/client/session-store.js +1 -548
- package/vendor/cli/vendor/client/topup.js +1 -297
- package/vendor/cli/vendor/client/touch.js +1 -458
- package/vendor/cli/vendor/client/update.js +1 -704
- package/vendor/cli/vendor/client/user-models.js +1 -381
- package/vendor/cli/vendor/desktop/lib/local/agents.js +1 -105
- package/vendor/cli/vendor/desktop/lib/local/autonomous.js +1 -1045
- package/vendor/cli/vendor/desktop/lib/local/claude-pro.js +1 -993
- package/vendor/cli/vendor/desktop/lib/local/context.js +1 -95
- package/vendor/cli/vendor/desktop/lib/local/engine.js +1 -3301
- package/vendor/cli/vendor/desktop/lib/local/entitlement.js +1 -660
- package/vendor/cli/vendor/desktop/lib/local/git-scope.js +1 -228
- package/vendor/cli/vendor/desktop/lib/local/local.js +1 -2135
- package/vendor/cli/vendor/desktop/lib/local/prompt.js +1 -275
- package/vendor/cli/vendor/desktop/lib/local/queue.js +1 -560
- package/vendor/cli/vendor/desktop/lib/local/session-rounds.js +1 -208
- package/vendor/cli/vendor/desktop/lib/local/shell.js +1 -680
- package/vendor/cli/vendor/desktop/lib/local/tools.js +1 -1238
- package/vendor/cli/vendor/desktop/lib/local/turn-guard.js +1 -300
- package/vendor/cli/vendor/desktop/lib/local/worktree-lock.js +1 -235
- package/vendor/cli/vendor/desktop/lib/settings.js +1 -890
- package/vendor/cli/vendor/desktop/renderer/usage.js +1 -1239
- package/vendor/cli/vendor/hosts/install.js +1 -638
- package/vendor/cli/vendor/hosts/openai-shim.js +1 -515
- package/vendor/cli/vendor/hosts/spec.js +1 -164
- package/vendor/cli/vendor/hosts/targets.js +1 -346
- package/vendor/cli/vendor/mcp/server.js +1 -221
- package/vendor/cli/vendor/mcp/tools.js +1 -408
- package/vendor/cli/vendor/one/src/child.js +1 -285
- package/vendor/cli/vendor/one/src/permissions.js +1 -369
- package/vendor/desktop/bin/aegis.js +1 -32
- package/vendor/desktop/lib/account-key.js +1 -56
- package/vendor/desktop/lib/auto.js +1 -430
- package/vendor/desktop/lib/avatar/companion.js +1 -698
- package/vendor/desktop/lib/avatar/cosmetics.js +1 -532
- package/vendor/desktop/lib/avatar/events.js +1 -344
- package/vendor/desktop/lib/avatar/holder-turn.js +1 -350
- package/vendor/desktop/lib/avatar/holders.js +1 -612
- package/vendor/desktop/lib/avatar/identity.js +1 -641
- package/vendor/desktop/lib/avatar/level.js +1 -368
- package/vendor/desktop/lib/avatar/mirror.js +1 -524
- package/vendor/desktop/lib/avatar/persona.js +1 -388
- package/vendor/desktop/lib/avatar/profile.js +1 -977
- package/vendor/desktop/lib/avatar/register.js +1 -307
- package/vendor/desktop/lib/avatar/store.js +1 -472
- package/vendor/desktop/lib/avatar/tiers.js +1 -38
- package/vendor/desktop/lib/avatar/transfer.js +1 -415
- package/vendor/desktop/lib/avatar/turn.js +1 -216
- package/vendor/desktop/lib/avatar/voice.js +1 -328
- package/vendor/desktop/lib/avatar/xp.js +1 -404
- package/vendor/desktop/lib/deep-link.js +1 -120
- package/vendor/desktop/lib/fingerprint.js +2 -347
- package/vendor/desktop/lib/google-connect.js +1 -227
- package/vendor/desktop/lib/local/agents.js +1 -105
- package/vendor/desktop/lib/local/autonomous.js +1 -1045
- package/vendor/desktop/lib/local/claude-pro.js +1 -993
- package/vendor/desktop/lib/local/context.js +1 -95
- package/vendor/desktop/lib/local/engine.js +1 -3301
- package/vendor/desktop/lib/local/entitlement.js +1 -660
- package/vendor/desktop/lib/local/git-scope.js +1 -228
- package/vendor/desktop/lib/local/local.js +1 -2135
- package/vendor/desktop/lib/local/prompt.js +1 -275
- package/vendor/desktop/lib/local/queue.js +1 -560
- package/vendor/desktop/lib/local/session-rounds.js +1 -208
- package/vendor/desktop/lib/local/shell.js +1 -680
- package/vendor/desktop/lib/local/telemetry.js +1 -470
- package/vendor/desktop/lib/local/tools.js +1 -1238
- package/vendor/desktop/lib/local/turn-guard.js +1 -300
- package/vendor/desktop/lib/local/worktree-lock.js +1 -235
- package/vendor/desktop/lib/provider-key-mirror.js +1 -252
- package/vendor/desktop/lib/quick-launcher.js +1 -84
- package/vendor/desktop/lib/settings.js +1 -890
- package/vendor/desktop/lib/sync/memory-queue.js +1 -60
- package/vendor/desktop/lib/sync/persist-gate.js +1 -148
- package/vendor/desktop/lib/sync/sessions.js +1 -106
- package/vendor/desktop/lib/window-state.js +1 -66
- package/vendor/desktop/main.js +1 -4529
- package/vendor/desktop/package.json +3 -5
- package/vendor/desktop/preload.js +1 -636
- package/vendor/desktop/renderer/app.js +1 -6660
- package/vendor/desktop/renderer/avatar/assemble.js +1 -335
- package/vendor/desktop/renderer/avatar/avatar.js +1 -380
- package/vendor/desktop/renderer/avatar/cards.js +1 -141
- package/vendor/desktop/renderer/avatar/hud.js +1 -206
- package/vendor/desktop/renderer/avatar/machine.js +1 -213
- package/vendor/desktop/renderer/avatar/pane.js +1 -439
- package/vendor/desktop/renderer/avatar/parts.js +1 -437
- package/vendor/desktop/renderer/budget.js +1 -168
- package/vendor/desktop/renderer/companion.js +1 -223
- package/vendor/desktop/renderer/diff.js +1 -359
- package/vendor/desktop/renderer/diffview.js +1 -336
- package/vendor/desktop/renderer/fingerprint.js +3 -736
- package/vendor/desktop/renderer/markdown.js +1 -168
- package/vendor/desktop/renderer/provider-toolbar.js +1 -134
- package/vendor/desktop/renderer/providers.js +1 -259
- package/vendor/desktop/renderer/quick.js +1 -191
- package/vendor/desktop/renderer/stream-policy.js +1 -306
- package/vendor/desktop/renderer/transcript-view.js +1 -323
- package/vendor/desktop/renderer/usage.js +1 -1239
- package/vendor/desktop/vendor/aegis.js +1 -2179
- package/vendor/desktop/vendor/attest.js +1 -442
- package/vendor/desktop/vendor/authorship-key.js +1 -410
- package/vendor/desktop/vendor/auto-provision.js +1 -134
- package/vendor/desktop/vendor/brain-catalog.js +1 -268
- package/vendor/desktop/vendor/byok-catalog.js +1 -230
- package/vendor/desktop/vendor/credentials.js +1 -494
- package/vendor/desktop/vendor/device-fingerprint.js +1 -141
- package/vendor/desktop/vendor/drive-connect.js +1 -110
- package/vendor/desktop/vendor/drive-upload.js +1 -174
- package/vendor/desktop/vendor/env-file.js +1 -1273
- package/vendor/desktop/vendor/fingerprint.js +1 -1064
- package/vendor/desktop/vendor/foreign-memory.js +1 -669
- package/vendor/desktop/vendor/google-signin.js +1 -133
- package/vendor/desktop/vendor/hooks.js +1 -430
- package/vendor/desktop/vendor/model-discovery.js +1 -373
- package/vendor/desktop/vendor/platform.js +1 -937
- package/vendor/desktop/vendor/prefs.js +1 -351
- package/vendor/desktop/vendor/presence-constants.js +1 -107
- package/vendor/desktop/vendor/presence.js +1 -438
- package/vendor/desktop/vendor/record-vault.js +3 -1055
- package/vendor/desktop/vendor/session-store.js +1 -548
- package/vendor/desktop/vendor/topup.js +1 -297
- package/vendor/desktop/vendor/touch.js +1 -458
- package/vendor/desktop/vendor/update.js +1 -704
- package/vendor/desktop/vendor/user-models.js +1 -381
package/vendor/cli/src/input.js
CHANGED
|
@@ -1,141 +1,3 @@
|
|
|
1
1
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
2
2
|
// Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
|
|
3
|
-
|
|
4
|
-
// Conveying a modified copy, or running one as a network service, owes the
|
|
5
|
-
// corresponding source under this licence (§5/§13) — see LICENSING.md.
|
|
6
|
-
'use strict';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Line editor with history — the input line's buffer, cursor and recall.
|
|
10
|
-
*
|
|
11
|
-
* Ported from the upstream engine reference. The one thing worth knowing before
|
|
12
|
-
* touching it: `cursor` is a **codepoint** index, not a UTF-16 index. Slicing
|
|
13
|
-
* `buf` directly corrupts a surrogate pair the moment one has been inserted
|
|
14
|
-
* (the next insert's slice lands mid-pair and leaves a lone surrogate, which
|
|
15
|
-
* renders as U+FFFD), so every mutation splices on `[...buf]` instead.
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
class LineEditor {
|
|
19
|
-
constructor() {
|
|
20
|
-
this.buf = '';
|
|
21
|
-
this.cursor = 0;
|
|
22
|
-
this.history = [];
|
|
23
|
-
this.hi = -1;
|
|
24
|
-
this.draft = '';
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
reset() {
|
|
28
|
-
this.buf = '';
|
|
29
|
-
this.cursor = 0;
|
|
30
|
-
this.hi = -1;
|
|
31
|
-
this.draft = '';
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
insert(ch) {
|
|
35
|
-
const arr = [...this.buf];
|
|
36
|
-
arr.splice(this.cursor, 0, ...ch);
|
|
37
|
-
this.buf = arr.join('');
|
|
38
|
-
this.cursor += [...ch].length;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
left() {
|
|
42
|
-
if (this.cursor > 0) this.cursor--;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
right() {
|
|
46
|
-
if (this.cursor < [...this.buf].length) this.cursor++;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
home() {
|
|
50
|
-
this.cursor = 0;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
end() {
|
|
54
|
-
this.cursor = [...this.buf].length;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
backspace() {
|
|
58
|
-
if (this.cursor === 0) return;
|
|
59
|
-
const arr = [...this.buf];
|
|
60
|
-
arr.splice(this.cursor - 1, 1);
|
|
61
|
-
this.buf = arr.join('');
|
|
62
|
-
this.cursor--;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
delete() {
|
|
66
|
-
if (this.cursor >= [...this.buf].length) return;
|
|
67
|
-
const arr = [...this.buf];
|
|
68
|
-
arr.splice(this.cursor, 1);
|
|
69
|
-
this.buf = arr.join('');
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/** vim `s` — delete the char under the cursor (caller switches to insert). */
|
|
73
|
-
substChar() {
|
|
74
|
-
if (this.cursor >= [...this.buf].length) return false;
|
|
75
|
-
this.delete();
|
|
76
|
-
return true;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/** vim `S` — clear the whole line (caller switches to insert). */
|
|
80
|
-
substLine() {
|
|
81
|
-
const had = this.buf.length > 0;
|
|
82
|
-
this.buf = '';
|
|
83
|
-
this.cursor = 0;
|
|
84
|
-
return had;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
killToEnd() {
|
|
88
|
-
this.buf = [...this.buf].slice(0, this.cursor).join('');
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
wordBack() {
|
|
92
|
-
const arr = [...this.buf];
|
|
93
|
-
let i = this.cursor;
|
|
94
|
-
while (i > 0 && arr[i - 1] === ' ') i--;
|
|
95
|
-
while (i > 0 && arr[i - 1] !== ' ') i--;
|
|
96
|
-
this.cursor = i;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
wordDelete() {
|
|
100
|
-
const arr = [...this.buf];
|
|
101
|
-
let i = this.cursor;
|
|
102
|
-
while (i < arr.length && arr[i] === ' ') i++;
|
|
103
|
-
while (i < arr.length && arr[i] !== ' ') i++;
|
|
104
|
-
this.buf = arr.slice(0, this.cursor).join('') + arr.slice(i).join('');
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
historyUp() {
|
|
108
|
-
if (!this.history.length) return;
|
|
109
|
-
if (this.hi === -1) {
|
|
110
|
-
this.draft = this.buf;
|
|
111
|
-
this.hi = this.history.length - 1;
|
|
112
|
-
} else if (this.hi > 0) this.hi--;
|
|
113
|
-
this.buf = this.history[this.hi];
|
|
114
|
-
this.end();
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
historyDown() {
|
|
118
|
-
if (this.hi === -1) return;
|
|
119
|
-
if (this.hi < this.history.length - 1) {
|
|
120
|
-
this.hi++;
|
|
121
|
-
this.buf = this.history[this.hi];
|
|
122
|
-
} else {
|
|
123
|
-
this.hi = -1;
|
|
124
|
-
this.buf = this.draft;
|
|
125
|
-
}
|
|
126
|
-
this.end();
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/** Commit the buffer. Returns the trimmed text and clears the line, or null
|
|
130
|
-
* when there was nothing to submit (a bare Enter must not become a turn). */
|
|
131
|
-
submit() {
|
|
132
|
-
const text = this.buf.trim();
|
|
133
|
-
if (!text) return null;
|
|
134
|
-
this.history.push(text);
|
|
135
|
-
if (this.history.length > 500) this.history.shift();
|
|
136
|
-
this.reset();
|
|
137
|
-
return text;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
module.exports = { LineEditor };
|
|
3
|
+
"use strict";class LineEditor{constructor(){this.buf="",this.cursor=0,this.history=[],this.hi=-1,this.draft=""}reset(){this.buf="",this.cursor=0,this.hi=-1,this.draft=""}insert(s){const t=[...this.buf];t.splice(this.cursor,0,...s),this.buf=t.join(""),this.cursor+=[...s].length}left(){this.cursor>0&&this.cursor--}right(){this.cursor<[...this.buf].length&&this.cursor++}home(){this.cursor=0}end(){this.cursor=[...this.buf].length}backspace(){if(0===this.cursor)return;const s=[...this.buf];s.splice(this.cursor-1,1),this.buf=s.join(""),this.cursor--}delete(){if(this.cursor>=[...this.buf].length)return;const s=[...this.buf];s.splice(this.cursor,1),this.buf=s.join("")}substChar(){return!(this.cursor>=[...this.buf].length||(this.delete(),0))}substLine(){const s=this.buf.length>0;return this.buf="",this.cursor=0,s}killToEnd(){this.buf=[...this.buf].slice(0,this.cursor).join("")}wordBack(){const s=[...this.buf];let t=this.cursor;for(;t>0&&" "===s[t-1];)t--;for(;t>0&&" "!==s[t-1];)t--;this.cursor=t}wordDelete(){const s=[...this.buf];let t=this.cursor;for(;t<s.length&&" "===s[t];)t++;for(;t<s.length&&" "!==s[t];)t++;this.buf=s.slice(0,this.cursor).join("")+s.slice(t).join("")}historyUp(){this.history.length&&(-1===this.hi?(this.draft=this.buf,this.hi=this.history.length-1):this.hi>0&&this.hi--,this.buf=this.history[this.hi],this.end())}historyDown(){-1!==this.hi&&(this.hi<this.history.length-1?(this.hi++,this.buf=this.history[this.hi]):(this.hi=-1,this.buf=this.draft),this.end())}submit(){const s=this.buf.trim();return s?(this.history.push(s),this.history.length>500&&this.history.shift(),this.reset(),s):null}}module.exports={LineEditor:LineEditor};
|
package/vendor/cli/src/keys.js
CHANGED
|
@@ -1,185 +1,3 @@
|
|
|
1
1
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
2
2
|
// Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
|
|
3
|
-
|
|
4
|
-
// Conveying a modified copy, or running one as a network service, owes the
|
|
5
|
-
// corresponding source under this licence (§5/§13) — see LICENSING.md.
|
|
6
|
-
'use strict';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Raw key decoding for the terminal (raw-mode stdin).
|
|
10
|
-
*
|
|
11
|
-
* Ported from the upstream engine reference so the aegiscode CLI and the
|
|
12
|
-
* reference client decode the same bytes into the same key names — the
|
|
13
|
-
* chatflow's key handling (history recall, vim motions, Esc-to-interrupt) is
|
|
14
|
-
* only correct if the decoder agrees with it.
|
|
15
|
-
*
|
|
16
|
-
* Two entry points:
|
|
17
|
-
* decodePlain(c) one character with no ESC prefix
|
|
18
|
-
* decodeEscSequence(s) a complete CSI (\x1b[…X) or SS3 (\x1bOX) sequence
|
|
19
|
-
*
|
|
20
|
-
* Both return either `null` (nothing to do) or a key object `{name, ch?}`.
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
const KEY = Object.freeze({
|
|
24
|
-
UP: 'up',
|
|
25
|
-
DOWN: 'down',
|
|
26
|
-
LEFT: 'left',
|
|
27
|
-
RIGHT: 'right',
|
|
28
|
-
ENTER: 'enter',
|
|
29
|
-
TAB: 'tab',
|
|
30
|
-
ESC: 'esc',
|
|
31
|
-
BACKSPACE: 'backspace',
|
|
32
|
-
DELETE: 'delete',
|
|
33
|
-
HOME: 'home',
|
|
34
|
-
END: 'end',
|
|
35
|
-
PAGE_UP: 'pageup',
|
|
36
|
-
PAGE_DOWN: 'pagedown',
|
|
37
|
-
CTRL_C: 'ctrl-c',
|
|
38
|
-
CTRL_D: 'ctrl-d',
|
|
39
|
-
CTRL_L: 'ctrl-l',
|
|
40
|
-
CTRL_R: 'ctrl-r',
|
|
41
|
-
CTRL_U: 'ctrl-u',
|
|
42
|
-
CTRL_A: 'ctrl-a',
|
|
43
|
-
CTRL_E: 'ctrl-e',
|
|
44
|
-
CTRL_K: 'ctrl-k',
|
|
45
|
-
CTRL_W: 'ctrl-w',
|
|
46
|
-
CTRL_T: 'ctrl-t',
|
|
47
|
-
CTRL_N: 'ctrl-n',
|
|
48
|
-
CTRL_P: 'ctrl-p',
|
|
49
|
-
CTRL_O: 'ctrl-o',
|
|
50
|
-
CTRL_V: 'ctrl-v',
|
|
51
|
-
CTRL_B: 'ctrl-b',
|
|
52
|
-
CTRL_LEFT: 'ctrl-left',
|
|
53
|
-
CTRL_RIGHT: 'ctrl-right',
|
|
54
|
-
// Shift is a MODIFIER here, not a duplicate of the bare key: the pickers bind
|
|
55
|
-
// shift+arrow to "move the highlight and commit it", so decoding mod 2 as the
|
|
56
|
-
// plain arrow (which is what this decoder did) would make shift silently
|
|
57
|
-
// identical to an unmodified arrow — the chord the status line advertises
|
|
58
|
-
// would do nothing the arrow does not. `SHIFT_ENTER` is here for the palettes
|
|
59
|
-
// that want a non-Enter commit; it arrives in two spellings (see
|
|
60
|
-
// decodeEscSequence) because terminals disagree about which one to send.
|
|
61
|
-
SHIFT_UP: 'shift-up',
|
|
62
|
-
SHIFT_DOWN: 'shift-down',
|
|
63
|
-
SHIFT_ENTER: 'shift-enter',
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
/** Decode a bare character (no escape prefix) into a key object. */
|
|
67
|
-
function decodePlain(chunk) {
|
|
68
|
-
switch (chunk) {
|
|
69
|
-
case '\r':
|
|
70
|
-
case '\n':
|
|
71
|
-
return { name: KEY.ENTER };
|
|
72
|
-
case '\t':
|
|
73
|
-
return { name: KEY.TAB };
|
|
74
|
-
case '\x03':
|
|
75
|
-
return { name: KEY.CTRL_C };
|
|
76
|
-
case '\x04':
|
|
77
|
-
return { name: KEY.CTRL_D };
|
|
78
|
-
case '\x0c':
|
|
79
|
-
return { name: KEY.CTRL_L };
|
|
80
|
-
case '\x12':
|
|
81
|
-
return { name: KEY.CTRL_R };
|
|
82
|
-
case '\x15':
|
|
83
|
-
return { name: KEY.CTRL_U };
|
|
84
|
-
case '\x01':
|
|
85
|
-
return { name: KEY.CTRL_A };
|
|
86
|
-
case '\x05':
|
|
87
|
-
return { name: KEY.CTRL_E };
|
|
88
|
-
case '\x0b':
|
|
89
|
-
return { name: KEY.CTRL_K };
|
|
90
|
-
case '\x17':
|
|
91
|
-
return { name: KEY.CTRL_W };
|
|
92
|
-
case '\x14':
|
|
93
|
-
return { name: KEY.CTRL_T };
|
|
94
|
-
case '\x0e':
|
|
95
|
-
return { name: KEY.CTRL_N };
|
|
96
|
-
case '\x10':
|
|
97
|
-
return { name: KEY.CTRL_P };
|
|
98
|
-
case '\x0f':
|
|
99
|
-
return { name: KEY.CTRL_O };
|
|
100
|
-
// Ctrl+V pastes the clipboard (image → a saved path, else its text) and
|
|
101
|
-
// Ctrl+B copies the whole conversation. Both were dead letters here: `\x16`
|
|
102
|
-
// and `\x02` fell into the "any other control char" branch below and
|
|
103
|
-
// decoded as ESC — so Ctrl+V did nothing on every platform, and Ctrl+B
|
|
104
|
-
// aborted a running turn. The upstream engine names both keys; this host
|
|
105
|
-
// now does too.
|
|
106
|
-
case '\x16':
|
|
107
|
-
return { name: KEY.CTRL_V };
|
|
108
|
-
case '\x02':
|
|
109
|
-
return { name: KEY.CTRL_B };
|
|
110
|
-
case '\x7f':
|
|
111
|
-
case '\x08':
|
|
112
|
-
return { name: KEY.BACKSPACE };
|
|
113
|
-
default: {
|
|
114
|
-
// Any other control char is meaningless here; printable is a char.
|
|
115
|
-
const code = chunk.charCodeAt(0);
|
|
116
|
-
if (code < 32 || code === 127) return { name: KEY.ESC };
|
|
117
|
-
return { name: 'char', ch: chunk };
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/** Decode a complete CSI/SS3 escape sequence into a key object (or null). */
|
|
123
|
-
function decodeEscSequence(seq) {
|
|
124
|
-
if (seq.startsWith('\x1b[')) {
|
|
125
|
-
const body = seq.slice(2);
|
|
126
|
-
// CSI with modifier params, e.g. 1;5C = ctrl+right.
|
|
127
|
-
const m = body.match(/^([0-9;]*)([A-Za-z~])$/);
|
|
128
|
-
if (m) {
|
|
129
|
-
const params = m[1] ? m[1].split(';') : [];
|
|
130
|
-
const mod = params.length > 1 ? parseInt(params[1], 10) : 0;
|
|
131
|
-
switch (m[2]) {
|
|
132
|
-
// Modifier 2 is shift (`1;2A` = shift+up). It has to be named, not
|
|
133
|
-
// folded into the bare arrow: the /model picker binds shift+arrow to
|
|
134
|
-
// "move the highlight and pin it", so decoding it as a plain arrow is
|
|
135
|
-
// what made the advertised chord indistinguishable from the arrow.
|
|
136
|
-
case 'A':
|
|
137
|
-
return { name: mod === 2 ? KEY.SHIFT_UP : KEY.UP };
|
|
138
|
-
case 'B':
|
|
139
|
-
return { name: mod === 2 ? KEY.SHIFT_DOWN : KEY.DOWN };
|
|
140
|
-
case 'C':
|
|
141
|
-
return mod === 5 ? { name: KEY.CTRL_RIGHT } : { name: KEY.RIGHT };
|
|
142
|
-
case 'D':
|
|
143
|
-
return mod === 5 ? { name: KEY.CTRL_LEFT } : { name: KEY.LEFT };
|
|
144
|
-
case 'H':
|
|
145
|
-
return { name: KEY.HOME };
|
|
146
|
-
case 'F':
|
|
147
|
-
return { name: KEY.END };
|
|
148
|
-
case 'u': {
|
|
149
|
-
// Kitty/modifyOtherKeys spelling: `CSI <codepoint> ; <modifier> u`.
|
|
150
|
-
// A terminal in that mode sends shift+enter as `\x1b[13;2u` rather
|
|
151
|
-
// than the legacy `\x1b\r`, and both have to land on the same key
|
|
152
|
-
// name or the chord works on one terminal and not the next.
|
|
153
|
-
const code = parseInt(params[0] || '0', 10);
|
|
154
|
-
if (code === 13 && mod === 2) return { name: KEY.SHIFT_ENTER };
|
|
155
|
-
return null;
|
|
156
|
-
}
|
|
157
|
-
case '~': {
|
|
158
|
-
const n = parseInt(params[0] || '0', 10);
|
|
159
|
-
if (n === 3) return { name: KEY.DELETE };
|
|
160
|
-
if (n === 5) return { name: KEY.PAGE_UP };
|
|
161
|
-
if (n === 6) return { name: KEY.PAGE_DOWN };
|
|
162
|
-
if (n === 1 || n === 7) return { name: KEY.HOME };
|
|
163
|
-
if (n === 4 || n === 8) return { name: KEY.END };
|
|
164
|
-
return null;
|
|
165
|
-
}
|
|
166
|
-
default:
|
|
167
|
-
return null;
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
return null;
|
|
171
|
-
}
|
|
172
|
-
if (seq.startsWith('\x1bO')) {
|
|
173
|
-
const c = seq[2];
|
|
174
|
-
if (c === 'H') return { name: KEY.HOME };
|
|
175
|
-
if (c === 'F') return { name: KEY.END };
|
|
176
|
-
return null;
|
|
177
|
-
}
|
|
178
|
-
// The legacy spelling of shift+enter, for terminals that never send the CSI
|
|
179
|
-
// `u` form above. `\x1b\r` is only ever shift+enter (a bare `\r` is ENTER and
|
|
180
|
-
// arrives without the ESC), so it cannot be confused with anything else.
|
|
181
|
-
if (seq === '\x1b\r' || seq === '\x1b\n') return { name: KEY.SHIFT_ENTER };
|
|
182
|
-
return { name: KEY.ESC };
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
module.exports = { KEY, decodePlain, decodeEscSequence };
|
|
3
|
+
"use strict";const KEY=Object.freeze({UP:"up",DOWN:"down",LEFT:"left",RIGHT:"right",ENTER:"enter",TAB:"tab",ESC:"esc",BACKSPACE:"backspace",DELETE:"delete",HOME:"home",END:"end",PAGE_UP:"pageup",PAGE_DOWN:"pagedown",CTRL_C:"ctrl-c",CTRL_D:"ctrl-d",CTRL_L:"ctrl-l",CTRL_R:"ctrl-r",CTRL_U:"ctrl-u",CTRL_A:"ctrl-a",CTRL_E:"ctrl-e",CTRL_K:"ctrl-k",CTRL_W:"ctrl-w",CTRL_T:"ctrl-t",CTRL_N:"ctrl-n",CTRL_P:"ctrl-p",CTRL_O:"ctrl-o",CTRL_V:"ctrl-v",CTRL_B:"ctrl-b",CTRL_LEFT:"ctrl-left",CTRL_RIGHT:"ctrl-right",SHIFT_UP:"shift-up",SHIFT_DOWN:"shift-down",SHIFT_ENTER:"shift-enter"});function decodePlain(e){switch(e){case"\r":case"\n":return{name:KEY.ENTER};case"\t":return{name:KEY.TAB};case"":return{name:KEY.CTRL_C};case"":return{name:KEY.CTRL_D};case"\f":return{name:KEY.CTRL_L};case"":return{name:KEY.CTRL_R};case"":return{name:KEY.CTRL_U};case"":return{name:KEY.CTRL_A};case"":return{name:KEY.CTRL_E};case"\v":return{name:KEY.CTRL_K};case"":return{name:KEY.CTRL_W};case"":return{name:KEY.CTRL_T};case"":return{name:KEY.CTRL_N};case"":return{name:KEY.CTRL_P};case"":return{name:KEY.CTRL_O};case"":return{name:KEY.CTRL_V};case"":return{name:KEY.CTRL_B};case"":case"\b":return{name:KEY.BACKSPACE};default:{const n=e.charCodeAt(0);return n<32||127===n?{name:KEY.ESC}:{name:"char",ch:e}}}}function decodeEscSequence(e){if(e.startsWith("[")){const n=e.slice(2).match(/^([0-9;]*)([A-Za-z~])$/);if(n){const e=n[1]?n[1].split(";"):[],r=e.length>1?parseInt(e[1],10):0;switch(n[2]){case"A":return{name:2===r?KEY.SHIFT_UP:KEY.UP};case"B":return{name:2===r?KEY.SHIFT_DOWN:KEY.DOWN};case"C":return 5===r?{name:KEY.CTRL_RIGHT}:{name:KEY.RIGHT};case"D":return 5===r?{name:KEY.CTRL_LEFT}:{name:KEY.LEFT};case"H":return{name:KEY.HOME};case"F":return{name:KEY.END};case"u":return 13===parseInt(e[0]||"0",10)&&2===r?{name:KEY.SHIFT_ENTER}:null;case"~":{const n=parseInt(e[0]||"0",10);return 3===n?{name:KEY.DELETE}:5===n?{name:KEY.PAGE_UP}:6===n?{name:KEY.PAGE_DOWN}:1===n||7===n?{name:KEY.HOME}:4===n||8===n?{name:KEY.END}:null}default:return null}}return null}if(e.startsWith("O")){const n=e[2];return"H"===n?{name:KEY.HOME}:"F"===n?{name:KEY.END}:null}return"\r"===e||"\n"===e?{name:KEY.SHIFT_ENTER}:{name:KEY.ESC}}module.exports={KEY:KEY,decodePlain:decodePlain,decodeEscSequence:decodeEscSequence};
|
package/vendor/cli/src/limits.js
CHANGED
|
@@ -1,192 +1,3 @@
|
|
|
1
1
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
2
2
|
// Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
|
|
3
|
-
|
|
4
|
-
// Conveying a modified copy, or running one as a network service, owes the
|
|
5
|
-
// corresponding source under this licence (§5/§13) — see LICENSING.md.
|
|
6
|
-
'use strict';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* limits — the second gate. This is the one that does not explain itself.
|
|
10
|
-
*
|
|
11
|
-
* `src/provenance.js` is the gate that speaks: it compares this install to a
|
|
12
|
-
* manifest and tells you, by name, when the two disagree. Anyone assembling a
|
|
13
|
-
* modified build reads that output once and knows exactly which file to edit
|
|
14
|
-
* next. Speaking is the defect.
|
|
15
|
-
*
|
|
16
|
-
* This module is the same question asked with nothing to read. It derives a
|
|
17
|
-
* single digest from the safety files *as one closed set* — changing any one of
|
|
18
|
-
* them changes the whole — and compares that to a value sealed into this file.
|
|
19
|
-
* When it does not match:
|
|
20
|
-
*
|
|
21
|
-
* - it prints one bland line naming no file, no category and no remedy, and
|
|
22
|
-
* - it refuses the privileged subcommands outright (`gate`, `provenance`,
|
|
23
|
-
* `mcp`), so the gate's own key management is unavailable to the build that
|
|
24
|
-
* failed the check, and
|
|
25
|
-
* - it marks the process `AEGIS_REDUCED_MODE=1` for modules that opt in.
|
|
26
|
-
*
|
|
27
|
-
* Nothing in the package maps ids back to paths. The paths here are base64 and
|
|
28
|
-
* the sealed digest is XORed with a derived pad. That is obfuscation, not
|
|
29
|
-
* cryptography, and this file does not pretend otherwise: whoever holds the
|
|
30
|
-
* bytes can read it. The cost being raised is the cost of *noticing* — there is
|
|
31
|
-
* no runtime switch to disable it, no manifest telling you what is covered, and
|
|
32
|
-
* no self-describing failure to imitate. The map lives only in
|
|
33
|
-
* `tools/provenance.mjs`, which is a development tool and is not what ships.
|
|
34
|
-
*
|
|
35
|
-
* ## Why `armed()` exists, and why it is called from four files
|
|
36
|
-
*
|
|
37
|
-
* A check that is invoked from exactly one place is removed by deleting one
|
|
38
|
-
* line, and the entry point that invoked it is the file a manipulator is
|
|
39
|
-
* already editing. So the question is not asked only from `bin/aegiscode.js`:
|
|
40
|
-
* every module that OWNS one of the privileges this set protects asks it for
|
|
41
|
-
* itself — `gate.js` before it loads the gate, `mcp.js` before it touches a
|
|
42
|
-
* host's configuration, `autonomous.js` before it runs a queue with nobody
|
|
43
|
-
* watching, `permissions.js` before it resolves a skip. Deleting the call from
|
|
44
|
-
* the entry point stops the earliest refusal and leaves four behind, each of
|
|
45
|
-
* which lives in a file the digest above covers — so silencing them is not one
|
|
46
|
-
* edit but five, across five files, any one of which the other four notice.
|
|
47
|
-
*
|
|
48
|
-
* That is a real cost imposed on a careless patch and no obstacle at all to a
|
|
49
|
-
* deliberate one, and the difference is stated here rather than implied.
|
|
50
|
-
*
|
|
51
|
-
* A tree that is mid-edit trips this on purpose. Re-sealing is deliberate and
|
|
52
|
-
* manual: `node tools/provenance.mjs seal --write`. There is no environment
|
|
53
|
-
* variable that turns this off, because a gate with a documented off switch is
|
|
54
|
-
* a gate the manipulator reads about in the same file as the gate.
|
|
55
|
-
*/
|
|
56
|
-
|
|
57
|
-
const { createHash } = require('node:crypto');
|
|
58
|
-
const { existsSync, readFileSync } = require('node:fs');
|
|
59
|
-
const path = require('node:path');
|
|
60
|
-
|
|
61
|
-
const PACKAGE_ROOT = path.join(__dirname, '..');
|
|
62
|
-
|
|
63
|
-
/** Domain separator, so this digest cannot be confused with the manifest's. */
|
|
64
|
-
const SALT = 'aegiscode-interlock-v1';
|
|
65
|
-
/** Pad derivation, so the sealed value is not a plain digest of the set. */
|
|
66
|
-
const PAD = 'aegis-interlock-pad-v1';
|
|
67
|
-
|
|
68
|
-
const sha256 = (data) => createHash('sha256').update(data).digest('hex');
|
|
69
|
-
const PAD_HEX = sha256(PAD);
|
|
70
|
-
|
|
71
|
-
/** Nibble-wise XOR against the derived pad; self-inverse. */
|
|
72
|
-
function unmask(sealed) {
|
|
73
|
-
let out = '';
|
|
74
|
-
for (let i = 0; i < sealed.length; i++) {
|
|
75
|
-
const a = parseInt(sealed[i], 16);
|
|
76
|
-
const b = parseInt(PAD_HEX[i % PAD_HEX.length], 16);
|
|
77
|
-
if (Number.isNaN(a) || Number.isNaN(b)) return null;
|
|
78
|
-
out += (a ^ b).toString(16);
|
|
79
|
-
}
|
|
80
|
-
return out;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* The sealed set, base64 so a `cat` of this file is not a table of contents.
|
|
85
|
-
* Order is part of the digest: reordering is as detectable as editing.
|
|
86
|
-
* This file is deliberately NOT in its own set — the seal lives here, so
|
|
87
|
-
* including it would make the digest self-referential and unstable. It is
|
|
88
|
-
* covered by the published manifest instead (see src/provenance.js).
|
|
89
|
-
*/
|
|
90
|
-
const UNITS = Object.freeze([
|
|
91
|
-
{ id: 'p1', rel: Buffer.from('YmluL2FlZ2lzY29kZS5qcw==', 'base64').toString('utf8') },
|
|
92
|
-
{ id: 'p2', rel: Buffer.from('c3JjL3Byb3ZlbmFuY2UuanM=', 'base64').toString('utf8') },
|
|
93
|
-
{ id: 'p3', rel: Buffer.from('c3JjL2dhdGUuanM=', 'base64').toString('utf8') },
|
|
94
|
-
{ id: 'p4', rel: Buffer.from('c3JjL3Blcm1pc3Npb25zLmpz', 'base64').toString('utf8') },
|
|
95
|
-
{ id: 'p5', rel: Buffer.from('c3JjL2NhcHMuanM=', 'base64').toString('utf8') },
|
|
96
|
-
{ id: 'p6', rel: Buffer.from('c3JjL2F1dG9ub21vdXMuanM=', 'base64').toString('utf8') },
|
|
97
|
-
{ id: 'p8', rel: Buffer.from('c3JjL21jcC5qcw==', 'base64').toString('utf8') },
|
|
98
|
-
]);
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* The masked digest of the sealed set. Rewritten ONLY by
|
|
102
|
-
* `node tools/provenance.mjs seal --write`, never by hand.
|
|
103
|
-
*/
|
|
104
|
-
const SEALED = '5125d89e9e3488b276cecb70e0107daa55c1c96424641b985fc7321c63518884';
|
|
105
|
-
|
|
106
|
-
/** Subcommands that a build failing this check does not get to run. */
|
|
107
|
-
const PRIVILEGED = Object.freeze(['gate', 'provenance', 'mcp']);
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Ask the question. Never throws — a check that can break the program it is
|
|
111
|
-
* checking is a check an attacker would rather have present.
|
|
112
|
-
*
|
|
113
|
-
* @returns {{ tripped: boolean, code: string|null, units: number }}
|
|
114
|
-
*/
|
|
115
|
-
function check() {
|
|
116
|
-
const parts = [];
|
|
117
|
-
for (const unit of UNITS) {
|
|
118
|
-
const abs = path.join(PACKAGE_ROOT, unit.rel);
|
|
119
|
-
if (!existsSync(abs)) return { tripped: true, code: 'p1', units: UNITS.length };
|
|
120
|
-
try {
|
|
121
|
-
parts.push(sha256(readFileSync(abs)));
|
|
122
|
-
} catch {
|
|
123
|
-
return { tripped: true, code: 'p1', units: UNITS.length };
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
const combined = sha256(`${SALT}\n${parts.join('\n')}`);
|
|
127
|
-
const sealed = typeof SEALED === 'string' ? SEALED.trim() : '';
|
|
128
|
-
if (sealed.length !== 64) return { tripped: true, code: 'p2', units: UNITS.length };
|
|
129
|
-
const expected = unmask(sealed);
|
|
130
|
-
if (expected !== combined) return { tripped: true, code: 'p3', units: UNITS.length };
|
|
131
|
-
return { tripped: false, code: null, units: UNITS.length };
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
/** The only sentence a failing build says about itself. Blunt, not a manual. */
|
|
135
|
-
function line(state) {
|
|
136
|
-
if (!state || !state.tripped) return null;
|
|
137
|
-
return `aegiscode: reduced mode (${state.code}) — this build is not the one that was published.\n`;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Ask once, remember the answer, and print the one bland line on the way.
|
|
142
|
-
*
|
|
143
|
-
* This is the entry point the modules that OWN a privilege call for themselves
|
|
144
|
-
* (see the header): `gate.js`, `mcp.js`, `autonomous.js`, `permissions.js`. It
|
|
145
|
-
* exists so the question is asked at each privilege rather than only once, at
|
|
146
|
-
* the top, in the file a manipulator is already editing.
|
|
147
|
-
*
|
|
148
|
-
* The answer is memoised for one process, and only so that four callers produce
|
|
149
|
-
* one sentence instead of four. It is NOT a cache an attacker can prime: the
|
|
150
|
-
* first caller computes it from the bytes on disk, and every later caller gets
|
|
151
|
-
* that verdict.
|
|
152
|
-
*
|
|
153
|
-
* It cannot throw — a gate that can break the program it guards is a gate an
|
|
154
|
-
* attacker would rather have present (see `check`).
|
|
155
|
-
*
|
|
156
|
-
* @returns {boolean} true when this build is not the published one.
|
|
157
|
-
*/
|
|
158
|
-
let ARMED = null;
|
|
159
|
-
function armed() {
|
|
160
|
-
if (ARMED !== null) return ARMED;
|
|
161
|
-
let state;
|
|
162
|
-
try {
|
|
163
|
-
state = check();
|
|
164
|
-
} catch {
|
|
165
|
-
state = { tripped: true, code: 'p2', units: UNITS.length };
|
|
166
|
-
}
|
|
167
|
-
ARMED = Boolean(state.tripped);
|
|
168
|
-
if (ARMED) {
|
|
169
|
-
// The mark is the mechanism; the line is only its announcement.
|
|
170
|
-
process.env.AEGIS_REDUCED_MODE = '1';
|
|
171
|
-
const said = line(state);
|
|
172
|
-
if (said) process.stderr.write(said);
|
|
173
|
-
}
|
|
174
|
-
return ARMED;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
function isPrivileged(command) {
|
|
178
|
-
return PRIVILEGED.includes(command);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
/** A refused subcommand exits non-zero and says nothing further. */
|
|
182
|
-
function refuse() {
|
|
183
|
-
return 1;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
/** The seal writer's half of the contract; the tool owns the mapping. */
|
|
187
|
-
function sealOf(files) {
|
|
188
|
-
const parts = files.map((abs) => sha256(readFileSync(abs)));
|
|
189
|
-
return sha256(`${SALT}\n${parts.join('\n')}`);
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
module.exports = { UNITS, PRIVILEGED, SALT, PAD, check, armed, line, isPrivileged, refuse, sealOf, mask: (hex) => unmask(hex) };
|
|
3
|
+
"use strict";const{createHash:createHash}=require("node:crypto"),{existsSync:existsSync,readFileSync:readFileSync}=require("node:fs"),path=require("node:path"),PACKAGE_ROOT=path.join(__dirname,".."),SALT="aegiscode-interlock-v1",PAD="aegis-interlock-pad-v1",sha256=e=>createHash("sha256").update(e).digest("hex"),PAD_HEX=sha256(PAD);function unmask(e){let t="";for(let r=0;r<e.length;r++){const n=parseInt(e[r],16),i=parseInt(PAD_HEX[r%PAD_HEX.length],16);if(Number.isNaN(n)||Number.isNaN(i))return null;t+=(n^i).toString(16)}return t}const UNITS=Object.freeze([{id:"p1",rel:Buffer.from("YmluL2FlZ2lzY29kZS5qcw==","base64").toString("utf8")},{id:"p2",rel:Buffer.from("c3JjL3Byb3ZlbmFuY2UuanM=","base64").toString("utf8")},{id:"p3",rel:Buffer.from("c3JjL2dhdGUuanM=","base64").toString("utf8")},{id:"p4",rel:Buffer.from("c3JjL3Blcm1pc3Npb25zLmpz","base64").toString("utf8")},{id:"p5",rel:Buffer.from("c3JjL2NhcHMuanM=","base64").toString("utf8")},{id:"p6",rel:Buffer.from("c3JjL2F1dG9ub21vdXMuanM=","base64").toString("utf8")},{id:"p8",rel:Buffer.from("c3JjL21jcC5qcw==","base64").toString("utf8")}]),SEALED="5125d89e9e3488b276cecb70e0107daa55c1c96424641b985fc7321c63518884",PRIVILEGED=Object.freeze(["gate","provenance","mcp"]);function check(){const e=[];for(const t of UNITS){const r=path.join(PACKAGE_ROOT,t.rel);if(!existsSync(r))return{tripped:!0,code:"p1",units:UNITS.length};try{e.push(sha256(readFileSync(r)))}catch{return{tripped:!0,code:"p1",units:UNITS.length}}}const t=sha256(`${SALT}\n${e.join("\n")}`),r="string"==typeof SEALED?SEALED.trim():"";return 64!==r.length?{tripped:!0,code:"p2",units:UNITS.length}:unmask(r)!==t?{tripped:!0,code:"p3",units:UNITS.length}:{tripped:!1,code:null,units:UNITS.length}}function line(e){return e&&e.tripped?`aegiscode: reduced mode (${e.code}) — this build is not the one that was published.\n`:null}let ARMED=null;function armed(){if(null!==ARMED)return ARMED;let e;try{e=check()}catch{e={tripped:!0,code:"p2",units:UNITS.length}}if(ARMED=Boolean(e.tripped),ARMED){process.env.AEGIS_REDUCED_MODE="1";const t=line(e);t&&process.stderr.write(t)}return ARMED}function isPrivileged(e){return PRIVILEGED.includes(e)}function refuse(){return 1}function sealOf(e){const t=e.map((e=>sha256(readFileSync(e))));return sha256(`${SALT}\n${t.join("\n")}`)}module.exports={UNITS:UNITS,PRIVILEGED:PRIVILEGED,SALT:SALT,PAD:PAD,check:check,armed:armed,line:line,isPrivileged:isPrivileged,refuse:refuse,sealOf:sealOf,mask:e=>unmask(e)};
|