aegiscode 7.0.14 → 7.0.16
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/SOURCE-OFFER.txt +9 -0
- package/package.json +4 -7
- package/scripts/check.mjs +1 -52
- package/scripts/demo.mjs +1 -94
- package/scripts/predist.mjs +1 -75
- package/scripts/runtests.mjs +1 -56
- package/scripts/seal-gate.mjs +1 -74
- package/src/agents.js +1 -139
- package/src/app.js +1 -2932
- package/src/art.js +1 -289
- package/src/chatflow.js +1 -3020
- package/src/checkpoint.js +1 -90
- package/src/clipboard.js +1 -424
- package/src/cloudsync.js +1 -528
- package/src/commands.js +1 -4003
- package/src/config.js +1 -581
- package/src/connect.js +1 -349
- package/src/credentials.js +1 -33
- package/src/deps.js +1 -232
- package/src/devrun.js +1 -187
- package/src/diff.js +1 -333
- package/src/diffview.js +1 -296
- package/src/engine.js +1 -297
- package/src/entitlement.js +1 -355
- package/src/events.js +1 -707
- package/src/export.js +1 -67
- package/src/fingerprint.js +1 -592
- package/src/format.js +1 -259
- package/src/fuzzy.js +1 -119
- package/src/history.js +1 -401
- package/src/init.js +1 -175
- package/src/input.js +1 -139
- package/src/keys.js +1 -183
- package/src/markdown.js +1 -306
- package/src/models.js +1 -487
- package/src/naming.js +1 -229
- package/src/overlays.js +1 -461
- package/src/panels.js +1 -1418
- package/src/ping.js +1 -226
- package/src/presence.js +1 -238
- package/src/render.js +1 -515
- package/src/screen.js +1 -518
- package/src/screens.js +1 -896
- package/src/secret.js +1 -59
- package/src/securefs.js +1 -359
- package/src/settings.js +1 -155
- package/src/shared.js +1 -52
- package/src/sharedpaths.js +1 -53
- package/src/signup.js +1 -156
- package/src/summarize.js +1 -95
- package/src/sysdiag.js +1 -585
- package/src/system.js +1 -40
- package/src/theme.js +1 -570
- package/src/title.js +1 -220
- package/src/todos.js +1 -115
- package/src/tokens.js +1 -263
- package/src/topup.js +1 -210
- package/src/update.js +1 -181
- package/vendor/client/aegis.js +1 -2179
- package/vendor/client/attest.js +1 -442
- package/vendor/client/authorship-key.js +1 -410
- package/vendor/client/auto-provision.js +1 -134
- package/vendor/client/brain-catalog.js +1 -268
- package/vendor/client/byok-catalog.js +1 -230
- package/vendor/client/credentials.js +1 -494
- package/vendor/client/device-fingerprint.js +1 -141
- package/vendor/client/drive-connect.js +1 -110
- package/vendor/client/drive-upload.js +1 -174
- package/vendor/client/env-file.js +1 -1273
- package/vendor/client/fingerprint.js +1 -1064
- package/vendor/client/foreign-memory.js +1 -669
- package/vendor/client/google-signin.js +1 -133
- package/vendor/client/hooks.js +1 -430
- package/vendor/client/model-discovery.js +1 -373
- package/vendor/client/platform.js +1 -937
- package/vendor/client/prefs.js +1 -351
- package/vendor/client/presence-constants.js +1 -107
- package/vendor/client/presence.js +1 -438
- package/vendor/client/record-vault.js +3 -1055
- package/vendor/client/session-store.js +1 -548
- package/vendor/client/topup.js +1 -297
- package/vendor/client/touch.js +1 -458
- package/vendor/client/update.js +1 -704
- package/vendor/client/user-models.js +1 -381
- 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/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/settings.js +1 -890
- package/vendor/desktop/renderer/usage.js +1 -1239
- package/vendor/hosts/install.js +1 -638
- package/vendor/hosts/openai-shim.js +1 -515
- package/vendor/hosts/spec.js +1 -164
- package/vendor/hosts/targets.js +1 -346
- package/vendor/mcp/server.js +1 -221
- package/vendor/mcp/tools.js +1 -408
- package/vendor/one/src/child.js +1 -285
- package/vendor/one/src/permissions.js +1 -369
|
@@ -1,371 +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
|
-
* permissions.js — ONE permission posture (AEGISONE, decision D8).
|
|
10
|
-
*
|
|
11
|
-
* Four permission surfaces used to live in this tree and none of them
|
|
12
|
-
* negotiated (see the plan's D8 table): the CLI's rule file + `evalPermission`,
|
|
13
|
-
* the desktop's `confirmModeEnabled()` gate, the avatar's level gate, and — out
|
|
14
|
-
* of process — the Claude Code child, which runs its own permission system
|
|
15
|
-
* whose prompts land on *its* stdin where neither a GUI card nor the CLI's
|
|
16
|
-
* prompt loop can answer them. In `-p` mode an unanswered prompt is not a
|
|
17
|
-
* refusal, it is a hang.
|
|
18
|
-
*
|
|
19
|
-
* This module is the product's half of the fix: it resolves the posture ONCE,
|
|
20
|
-
* from the facts a caller already has, into a FROZEN decision record that
|
|
21
|
-
* everything downstream reads instead of re-deciding for itself.
|
|
22
|
-
*
|
|
23
|
-
* ## What it is not
|
|
24
|
-
*
|
|
25
|
-
* * It is not a second rule engine. Rule matching is `evalPermission()`,
|
|
26
|
-
* imported from `cli/src/permissions.js` (D8 rule 1: "evalPermission()
|
|
27
|
-
* stays the only rule engine"). `loadEvaluator()` below resolves that
|
|
28
|
-
* module in both layouts — a checkout and the published bundle — and a
|
|
29
|
-
* missing evaluator is a thrown error, never a local re-implementation:
|
|
30
|
-
* a rules engine that can silently become a *different* rules engine is the
|
|
31
|
-
* drift this phase exists to remove.
|
|
32
|
-
* * It is not a switch that reaches the two floors of D8 rule 2. The ÆGIS
|
|
33
|
-
* covenant's `preActionAssert` and the avatar's `LEVEL_INDEPENDENT_
|
|
34
|
-
* APPROVALS` (`write`/`shell`/`network`/`offDevice`, always `'ask'`) are not
|
|
35
|
-
* represented here as skippable at all — `FROZEN_CLASSES` is exported so a
|
|
36
|
-
* test can assert it is the SAME set the avatar freezes, and `gateFor()`
|
|
37
|
-
* only ever downgrades an `'ask'` verdict, never an explicit `'deny'`.
|
|
38
|
-
* * It reads no `process.*` at module scope, and nothing at all in its
|
|
39
|
-
* functions: `env`, `interactive`, `skip` and `rules` all arrive as
|
|
40
|
-
* arguments. That is the standing seam rule for `one/`, and it is why the
|
|
41
|
-
* rule-5 case below can be asserted rather than hoped for.
|
|
42
|
-
*
|
|
43
|
-
* ## The record
|
|
44
|
-
*
|
|
45
|
-
* `resolvePosture({ rules, skip, interactive, childKind, env, flag })` returns
|
|
46
|
-
* an object that is frozen at every level. Frozen matters: the record is
|
|
47
|
-
* produced once per invocation and consumed by (a) this product's gate report,
|
|
48
|
-
* (b) the Claude child's argv builder, and (c) the run log. A record a later
|
|
49
|
-
* stage can mutate is a second decision, which is the bug D8 names.
|
|
50
|
-
*
|
|
51
|
-
* ## Rule 3's report
|
|
52
|
-
*
|
|
53
|
-
* `skipReport(record)` is the one stderr line rule 3 demands — "a flag whose
|
|
54
|
-
* blast radius is invisible is how a footgun ships" — and it names both what
|
|
55
|
-
* was skipped and, in as many words, what was not.
|
|
56
|
-
*/
|
|
57
|
-
|
|
58
|
-
const path = require('node:path');
|
|
59
|
-
|
|
60
|
-
/** The two children D8 rule 4 distinguishes. */
|
|
61
|
-
const CHILD_KINDS = Object.freeze({ HEADLESS: 'headless', INTERACTIVE: 'interactive' });
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* What `--dangerously-skip-permissions` skips in THIS product: the configurable
|
|
65
|
-
* confirmation gates, i.e. the desktop card / CLI ask for the mutating tools.
|
|
66
|
-
* The classes are named the way the gate and the tool registry name them, so
|
|
67
|
-
* the report line says exactly which calls stop asking.
|
|
68
|
-
*/
|
|
69
|
-
const CONFIGURABLE_CLASSES = Object.freeze(['exec', 'writeFile', 'editFile']);
|
|
70
|
-
|
|
71
|
-
/** The product flag's spelling (D8 rule 3), named once for both the bin and tests. */
|
|
72
|
-
const SKIP_FLAG = '--dangerously-skip-permissions';
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* The four classes no setting, flag or env var may auto-approve (D8 rule 2).
|
|
76
|
-
* The values are the avatar's, and `test/permissions.test.mjs` asserts this set
|
|
77
|
-
* is identical to `LEVEL_INDEPENDENT_APPROVALS`'s keys — so a phase that adds a
|
|
78
|
-
* fifth frozen class cannot land here silently.
|
|
79
|
-
*/
|
|
80
|
-
const FROZEN_CLASSES = Object.freeze(['write', 'shell', 'network', 'offDevice']);
|
|
81
|
-
|
|
82
|
-
/** D8 rule 4's explicit passthrough values — recorded, never inferred. */
|
|
83
|
-
const PERMISSION_MODES = Object.freeze([
|
|
84
|
-
'acceptEdits',
|
|
85
|
-
'auto',
|
|
86
|
-
'bypassPermissions',
|
|
87
|
-
'manual',
|
|
88
|
-
'dontAsk',
|
|
89
|
-
'plan',
|
|
90
|
-
]);
|
|
91
|
-
|
|
92
|
-
let cachedEvaluator = null;
|
|
93
|
-
let cachedConfig = null;
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* The ONE rule engine, resolved in both layouts:
|
|
97
|
-
*
|
|
98
|
-
* 1. `one/src/…` in a checkout → `../../cli/src/permissions.js`
|
|
99
|
-
* 2. `one/vendor/cli/src/…` in the published product → `../vendor/cli/src/…`
|
|
100
|
-
*
|
|
101
|
-
* @returns {{evalPermission: Function, resolveSkip: Function, SKIP: object}}
|
|
102
|
-
*/
|
|
103
|
-
function loadEvaluator(injected) {
|
|
104
|
-
if (injected) return injected;
|
|
105
|
-
if (cachedEvaluator) return cachedEvaluator;
|
|
106
|
-
const candidates = [
|
|
107
|
-
path.join(__dirname, '..', '..', 'cli', 'src', 'permissions.js'),
|
|
108
|
-
path.join(__dirname, '..', 'vendor', 'cli', 'src', 'permissions.js'),
|
|
109
|
-
];
|
|
110
|
-
for (const candidate of candidates) {
|
|
111
|
-
try {
|
|
112
|
-
const mod = require(candidate);
|
|
113
|
-
if (mod && typeof mod.evalPermission === 'function' && typeof mod.resolveSkip === 'function') {
|
|
114
|
-
cachedEvaluator = mod;
|
|
115
|
-
return mod;
|
|
116
|
-
}
|
|
117
|
-
} catch {
|
|
118
|
-
/* try the next layout */
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
throw new Error(
|
|
122
|
-
'aegis: the one rule evaluator (cli/src/permissions.js) is missing from this install — ' +
|
|
123
|
-
'refusing to resolve a permission posture from a second, unshared rule engine.'
|
|
124
|
-
);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* The faces' OWN posture module, resolved in both layouts, exactly as the
|
|
129
|
-
* evaluator above is:
|
|
130
|
-
*
|
|
131
|
-
* 1. `one/src/…` in a checkout → `../../cli/src/config.js`
|
|
132
|
-
* 2. `one/vendor/cli/src/…` in the published product → `../vendor/cli/src/…`
|
|
133
|
-
*
|
|
134
|
-
* This is deliberately the CLI's module and not a new reader. `confirmPosture()`
|
|
135
|
-
* in there is the ONE read of the shared `confirmMode` key both faces write —
|
|
136
|
-
* the desktop's *Confirm before running tools* switch and the shell's
|
|
137
|
-
* `/automode` (alias `/yolo`) — and reading the store here a second way would
|
|
138
|
-
* be the split brain ON8 removed. NotFound is `null`, never a throw: a store
|
|
139
|
-
* that cannot be read must leave the gate UP, not blow up a launch.
|
|
140
|
-
*
|
|
141
|
-
* @returns {object|null}
|
|
142
|
-
*/
|
|
143
|
-
function loadConfigStore(injected) {
|
|
144
|
-
if (injected) return injected;
|
|
145
|
-
if (cachedConfig) return cachedConfig;
|
|
146
|
-
const candidates = [
|
|
147
|
-
path.join(__dirname, '..', '..', 'cli', 'src', 'config.js'),
|
|
148
|
-
path.join(__dirname, '..', 'vendor', 'cli', 'src', 'config.js'),
|
|
149
|
-
];
|
|
150
|
-
for (const candidate of candidates) {
|
|
151
|
-
try {
|
|
152
|
-
const mod = require(candidate);
|
|
153
|
-
if (mod && typeof mod.confirmPosture === 'function') {
|
|
154
|
-
cachedConfig = mod;
|
|
155
|
-
return mod;
|
|
156
|
-
}
|
|
157
|
-
} catch {
|
|
158
|
-
/* try the next layout */
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
return null;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* What the SHARED stores say — the same two facts `one/bin/aegis.js` used to
|
|
166
|
-
* pass as `undefined`.
|
|
167
|
-
*
|
|
168
|
-
* `confirmationsOn` is `confirmPosture().enabled`, i.e. the store's own answer
|
|
169
|
-
* with its polarity already resolved (true = the gate is UP, the user is asked
|
|
170
|
-
* before mutating tools). `rules` is the CLI's rule set verbatim, which is what
|
|
171
|
-
* rule 4's `--allowedTools`/`--disallowedTools` were always meant to be built
|
|
172
|
-
* from — the seam shipped with `rules: d.rules`, and nothing ever set `d.rules`
|
|
173
|
-
* in production, so the child was handed our rules by nobody.
|
|
174
|
-
*
|
|
175
|
-
* An unreadable store answers `undefined` for both, never a guess: "no stored
|
|
176
|
-
* posture" must mean "exactly as before", not "confirmations off".
|
|
177
|
-
*
|
|
178
|
-
* @returns {{confirmationsOn: boolean|undefined, rules: object|undefined, source: string}}
|
|
179
|
-
*/
|
|
180
|
-
function storedPermissionFacts(opts = {}) {
|
|
181
|
-
const config = loadConfigStore(opts.config);
|
|
182
|
-
if (!config) return { confirmationsOn: undefined, rules: undefined, source: 'unavailable' };
|
|
183
|
-
try {
|
|
184
|
-
const gate = config.confirmPosture();
|
|
185
|
-
let rules;
|
|
186
|
-
try {
|
|
187
|
-
rules = config.loadPermissions();
|
|
188
|
-
} catch {
|
|
189
|
-
rules = undefined;
|
|
190
|
-
}
|
|
191
|
-
return {
|
|
192
|
-
confirmationsOn: gate && typeof gate.enabled === 'boolean' ? gate.enabled : undefined,
|
|
193
|
-
rules,
|
|
194
|
-
source: (gate && gate.source) || 'unavailable',
|
|
195
|
-
};
|
|
196
|
-
} catch {
|
|
197
|
-
return { confirmationsOn: undefined, rules: undefined, source: 'unavailable' };
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
/** The CLI's rule shape, verbatim (D8 rule 1: not a new schema). */
|
|
202
|
-
function normalizeRules(rules) {
|
|
203
|
-
const r = rules && typeof rules === 'object' ? rules : {};
|
|
204
|
-
const list = (v) => (Array.isArray(v) ? v.map(String) : []);
|
|
205
|
-
return Object.freeze({
|
|
206
|
-
defaultMode: r.defaultMode === 'allow' || r.defaultMode === 'deny' ? r.defaultMode : 'ask',
|
|
207
|
-
allow: Object.freeze(list(r.allow)),
|
|
208
|
-
deny: Object.freeze(list(r.deny)),
|
|
209
|
-
ask: Object.freeze(list(r.ask)),
|
|
210
|
-
// Only an explicitly written `defaultMode: 'ask'` prompts on the residual;
|
|
211
|
-
// the file-free default must not (cli/src/permissions.js's scope note).
|
|
212
|
-
explicitAsk: r.explicitAsk === true || r.defaultMode === 'ask',
|
|
213
|
-
});
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
/**
|
|
217
|
-
* Resolve the posture ONCE.
|
|
218
|
-
*
|
|
219
|
-
* @param {object} [input]
|
|
220
|
-
* @param {object} [input.rules] the shared rule set (CLI shape)
|
|
221
|
-
* @param {boolean} [input.flag] `--dangerously-skip-permissions` was passed
|
|
222
|
-
* @param {object} [input.env] environment (read, never mutated)
|
|
223
|
-
* @param {boolean} [input.interactive] both stdio ends are a terminal
|
|
224
|
-
* @param {string} [input.childKind] 'headless' | 'interactive'
|
|
225
|
-
* @param {boolean} [input.gate] the STORE's confirmation posture:
|
|
226
|
-
* `false` means the user already turned
|
|
227
|
-
* the gates off (`/automode`, or the
|
|
228
|
-
* desktop switch). Resolved by the caller
|
|
229
|
-
* (`storedPermissionFacts()`), never read
|
|
230
|
-
* from `process.*` here — the standing
|
|
231
|
-
* seam rule for `one/`.
|
|
232
|
-
* @param {object} [opts]
|
|
233
|
-
* @param {object} [opts.evaluator] injectable, for tests only
|
|
234
|
-
* @returns frozen decision record
|
|
235
|
-
*/
|
|
236
|
-
function resolvePosture(input = {}, opts = {}) {
|
|
237
|
-
const evaluator = loadEvaluator(opts.evaluator);
|
|
238
|
-
const rules = normalizeRules(input.rules);
|
|
239
|
-
const interactive = input.interactive === true;
|
|
240
|
-
const childKind = input.childKind === CHILD_KINDS.INTERACTIVE ? CHILD_KINDS.INTERACTIVE : CHILD_KINDS.HEADLESS;
|
|
241
|
-
const skip = evaluator.resolveSkip({ flag: input.flag === true, env: input.env, interactive });
|
|
242
|
-
// ── the second, already-resolved answer ──────────────────────────────────
|
|
243
|
-
//
|
|
244
|
-
// `--dangerously-skip-permissions` is not the only way this product can be
|
|
245
|
-
// running with the gates down. Since ON8 there is a stored posture, written
|
|
246
|
-
// by `/automode` (alias `/yolo`), by `/confirm`, by `/multiyolo` and by the
|
|
247
|
-
// desktop's switch, that the faces read on every tool round. This resolver
|
|
248
|
-
// read the flag and the environment and nothing else, so a session whose user
|
|
249
|
-
// had already said "stop asking" handed the Claude child NO permission flag:
|
|
250
|
-
// headless, the child then asked a question nobody could answer — the hang
|
|
251
|
-
// rule 4 exists to prevent — while the terminal face beside it ran ungated.
|
|
252
|
-
// Two faces, one posture, one of them still asking is precisely the drift D8
|
|
253
|
-
// names, so the stored answer is folded in HERE, at the one place that
|
|
254
|
-
// produces the record, and never re-derived downstream.
|
|
255
|
-
//
|
|
256
|
-
// It cannot reach either floor. `skip` only ever downgrades an `'ask'`
|
|
257
|
-
// verdict in `gateFor()`, an explicit `deny` still wins, and the covenant's
|
|
258
|
-
// `preActionAssert` plus the avatar's `LEVEL_INDEPENDENT_APPROVALS`
|
|
259
|
-
// (`write`/`shell`/`network`/`offDevice`) are the same frozen four as before:
|
|
260
|
-
// the store is the *configurable* half of rule 2 by definition — it is what
|
|
261
|
-
// the confirmation gate itself reads — so honoring it here widens nothing.
|
|
262
|
-
const storedOff = input.gate === false;
|
|
263
|
-
const effectiveSkip = skip.skip || storedOff;
|
|
264
|
-
const skipSource = skip.skip ? skip.source : storedOff ? 'posture' : skip.source;
|
|
265
|
-
|
|
266
|
-
const isInteractiveChild = childKind === CHILD_KINDS.INTERACTIVE;
|
|
267
|
-
return Object.freeze({
|
|
268
|
-
version: 1,
|
|
269
|
-
rules,
|
|
270
|
-
interactive,
|
|
271
|
-
childKind,
|
|
272
|
-
// Rule 5 already applied: `skip` is the product's answer, not the raw env.
|
|
273
|
-
skip: effectiveSkip,
|
|
274
|
-
skipSource,
|
|
275
|
-
// Which of the two produced it. The run-log line and the rule-3 report are
|
|
276
|
-
// silent for a stored posture on purpose: the report exists because "a flag
|
|
277
|
-
// whose blast radius is invisible is how a footgun ships", and a flag typed
|
|
278
|
-
// for one run is that. A posture is a setting the user can see in both
|
|
279
|
-
// faces' own UI and turn back, and printing a skip banner on every launch
|
|
280
|
-
// of a deliberately-ungated install is noise that teaches scrolling — but
|
|
281
|
-
// the child's argv is still recorded by `childRecordLine`, so the decision
|
|
282
|
-
// remains accountable.
|
|
283
|
-
skipFromFlag: skip.skip,
|
|
284
|
-
envVarSet: skip.envSet,
|
|
285
|
-
// The store's answer, recorded rather than inferred (three states: true,
|
|
286
|
-
// false, and `null` for "there was no stored posture to read").
|
|
287
|
-
storedGate: input.gate === undefined || input.gate === null ? null : Boolean(input.gate),
|
|
288
|
-
warned: skip.warned,
|
|
289
|
-
warning: skip.warning || null,
|
|
290
|
-
// What a skip covers, and what it cannot touch. Both are frozen lists so a
|
|
291
|
-
// caller cannot widen either one in place.
|
|
292
|
-
skipped: Object.freeze(effectiveSkip ? CONFIGURABLE_CLASSES : []),
|
|
293
|
-
frozen: FROZEN_CLASSES,
|
|
294
|
-
// The child's variant, derived here so no spawn site re-derives it (rule 4).
|
|
295
|
-
child: Object.freeze({
|
|
296
|
-
kind: childKind,
|
|
297
|
-
skip: effectiveSkip,
|
|
298
|
-
flag: !effectiveSkip
|
|
299
|
-
? null
|
|
300
|
-
: isInteractiveChild
|
|
301
|
-
? '--allow-dangerously-skip-permissions'
|
|
302
|
-
: '--dangerously-skip-permissions',
|
|
303
|
-
why: !effectiveSkip
|
|
304
|
-
? 'no skip was asked for, so no permission flag is passed to the child'
|
|
305
|
-
: isInteractiveChild
|
|
306
|
-
? 'the interactive variant offers the bypass as an option (the child still asks; a human is there)'
|
|
307
|
-
: 'the headless variant takes the bypass as a default, because no one can answer the child\'s prompt',
|
|
308
|
-
}),
|
|
309
|
-
});
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
/**
|
|
313
|
-
* The verdict for one tool call, from the ONE evaluator.
|
|
314
|
-
*
|
|
315
|
-
* Precedence, and each step is load-bearing:
|
|
316
|
-
*
|
|
317
|
-
* 1. `'deny'` stays `'deny'` — an explicit deny rule is a rule, not a
|
|
318
|
-
* confirmation gate, so a skip must not be able to turn it into an allow.
|
|
319
|
-
* 2. `'allow'` stays `'allow'`.
|
|
320
|
-
* 3. `'ask'` becomes `'allow'` only when the posture says skip. That is
|
|
321
|
-
* exactly "this product's confirmation gates", the configurable half.
|
|
322
|
-
*
|
|
323
|
-
* The frozen four never reach a different answer through this function: their
|
|
324
|
-
* floors are the covenant assert and the avatar caps, which read neither this
|
|
325
|
-
* record nor the store.
|
|
326
|
-
*/
|
|
327
|
-
function gateFor(posture, tool, args, opts = {}) {
|
|
328
|
-
const evaluator = loadEvaluator(opts.evaluator);
|
|
329
|
-
const rules = posture && posture.rules ? posture.rules : normalizeRules({});
|
|
330
|
-
const verdict = evaluator.evalPermission(tool, args, rules);
|
|
331
|
-
if (verdict === 'deny') return 'deny';
|
|
332
|
-
if (verdict === 'allow') return 'allow';
|
|
333
|
-
return posture && posture.skip ? 'allow' : 'ask';
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
/** The one-line "what was skipped" report (D8 rule 3). */
|
|
337
|
-
function skipReport(posture) {
|
|
338
|
-
if (!posture || !posture.skip) return null;
|
|
339
|
-
const childClause = posture.child.flag
|
|
340
|
-
? `; the ${posture.child.kind} Claude child is passed ${posture.child.flag}`
|
|
341
|
-
: '';
|
|
342
|
-
// Named by its actual source, never as a flag the user did not type: a stored
|
|
343
|
-
// posture (`/automode`, the desktop switch) is reported for what it is, since
|
|
344
|
-
// printing `--dangerously-skip-permissions` for a setting would be the same
|
|
345
|
-
// kind of small lie as eating the flag.
|
|
346
|
-
const what =
|
|
347
|
-
posture.skipSource === 'posture'
|
|
348
|
-
? 'automode (the stored confirmation posture both faces share)'
|
|
349
|
-
: '--dangerously-skip-permissions';
|
|
350
|
-
return (
|
|
351
|
-
`aegis: ${what} (via ${posture.skipSource}) — skipping the configurable ` +
|
|
352
|
-
`confirmation gates (${CONFIGURABLE_CLASSES.join(', ')})${childClause}. NOT skipped, and not ` +
|
|
353
|
-
`reachable by any setting, flag or env var: the ÆGIS covenant pre-action assert and the ` +
|
|
354
|
-
`${FROZEN_CLASSES.join('|')} approvals (always 'ask'), plus any explicit deny rule.`
|
|
355
|
-
);
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
module.exports = {
|
|
359
|
-
CHILD_KINDS,
|
|
360
|
-
CONFIGURABLE_CLASSES,
|
|
361
|
-
FROZEN_CLASSES,
|
|
362
|
-
PERMISSION_MODES,
|
|
363
|
-
SKIP_FLAG,
|
|
364
|
-
loadEvaluator,
|
|
365
|
-
loadConfigStore,
|
|
366
|
-
storedPermissionFacts,
|
|
367
|
-
normalizeRules,
|
|
368
|
-
resolvePosture,
|
|
369
|
-
gateFor,
|
|
370
|
-
skipReport,
|
|
371
|
-
};
|
|
3
|
+
"use strict";const path=require("node:path"),CHILD_KINDS=Object.freeze({HEADLESS:"headless",INTERACTIVE:"interactive"}),CONFIGURABLE_CLASSES=Object.freeze(["exec","writeFile","editFile"]),SKIP_FLAG="--dangerously-skip-permissions",FROZEN_CLASSES=Object.freeze(["write","shell","network","offDevice"]),PERMISSION_MODES=Object.freeze(["acceptEdits","auto","bypassPermissions","manual","dontAsk","plan"]);let cachedEvaluator=null,cachedConfig=null;function loadEvaluator(e){if(e)return e;if(cachedEvaluator)return cachedEvaluator;const o=[path.join(__dirname,"..","..","cli","src","permissions.js"),path.join(__dirname,"..","vendor","cli","src","permissions.js")];for(const e of o)try{const o=require(e);if(o&&"function"==typeof o.evalPermission&&"function"==typeof o.resolveSkip)return cachedEvaluator=o,o}catch{}throw new Error("aegis: the one rule evaluator (cli/src/permissions.js) is missing from this install — refusing to resolve a permission posture from a second, unshared rule engine.")}function loadConfigStore(e){if(e)return e;if(cachedConfig)return cachedConfig;const o=[path.join(__dirname,"..","..","cli","src","config.js"),path.join(__dirname,"..","vendor","cli","src","config.js")];for(const e of o)try{const o=require(e);if(o&&"function"==typeof o.confirmPosture)return cachedConfig=o,o}catch{}return null}function storedPermissionFacts(e={}){const o=loadConfigStore(e.config);if(!o)return{confirmationsOn:void 0,rules:void 0,source:"unavailable"};try{const e=o.confirmPosture();let r;try{r=o.loadPermissions()}catch{r=void 0}return{confirmationsOn:e&&"boolean"==typeof e.enabled?e.enabled:void 0,rules:r,source:e&&e.source||"unavailable"}}catch{return{confirmationsOn:void 0,rules:void 0,source:"unavailable"}}}function normalizeRules(e){const o=e&&"object"==typeof e?e:{},r=e=>Array.isArray(e)?e.map(String):[];return Object.freeze({defaultMode:"allow"===o.defaultMode||"deny"===o.defaultMode?o.defaultMode:"ask",allow:Object.freeze(r(o.allow)),deny:Object.freeze(r(o.deny)),ask:Object.freeze(r(o.ask)),explicitAsk:!0===o.explicitAsk||"ask"===o.defaultMode})}function resolvePosture(e={},o={}){const r=loadEvaluator(o.evaluator),s=normalizeRules(e.rules),i=!0===e.interactive,a=e.childKind===CHILD_KINDS.INTERACTIVE?CHILD_KINDS.INTERACTIVE:CHILD_KINDS.HEADLESS,n=r.resolveSkip({flag:!0===e.flag,env:e.env,interactive:i}),t=!1===e.gate,l=n.skip||t,c=n.skip?n.source:t?"posture":n.source,u=a===CHILD_KINDS.INTERACTIVE;return Object.freeze({version:1,rules:s,interactive:i,childKind:a,skip:l,skipSource:c,skipFromFlag:n.skip,envVarSet:n.envSet,storedGate:void 0===e.gate||null===e.gate?null:Boolean(e.gate),warned:n.warned,warning:n.warning||null,skipped:Object.freeze(l?CONFIGURABLE_CLASSES:[]),frozen:FROZEN_CLASSES,child:Object.freeze({kind:a,skip:l,flag:l?u?"--allow-dangerously-skip-permissions":"--dangerously-skip-permissions":null,why:l?u?"the interactive variant offers the bypass as an option (the child still asks; a human is there)":"the headless variant takes the bypass as a default, because no one can answer the child's prompt":"no skip was asked for, so no permission flag is passed to the child"})})}function gateFor(e,o,r,s={}){const i=loadEvaluator(s.evaluator),a=e&&e.rules?e.rules:normalizeRules({}),n=i.evalPermission(o,r,a);return"deny"===n?"deny":"allow"===n||e&&e.skip?"allow":"ask"}function skipReport(e){if(!e||!e.skip)return null;const o=e.child.flag?`; the ${e.child.kind} Claude child is passed ${e.child.flag}`:"";return`aegis: ${"posture"===e.skipSource?"automode (the stored confirmation posture both faces share)":"--dangerously-skip-permissions"} (via ${e.skipSource}) — skipping the configurable confirmation gates (${CONFIGURABLE_CLASSES.join(", ")})${o}. NOT skipped, and not reachable by any setting, flag or env var: the ÆGIS covenant pre-action assert and the ${FROZEN_CLASSES.join("|")} approvals (always 'ask'), plus any explicit deny rule.`}module.exports={CHILD_KINDS:CHILD_KINDS,CONFIGURABLE_CLASSES:CONFIGURABLE_CLASSES,FROZEN_CLASSES:FROZEN_CLASSES,PERMISSION_MODES:PERMISSION_MODES,SKIP_FLAG:SKIP_FLAG,loadEvaluator:loadEvaluator,loadConfigStore:loadConfigStore,storedPermissionFacts:storedPermissionFacts,normalizeRules:normalizeRules,resolvePosture:resolvePosture,gateFor:gateFor,skipReport:skipReport};
|