aegiscode 7.0.26 → 7.0.28
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 -2957
- package/src/art.js +1 -289
- package/src/chatflow.js +1 -3023
- package/src/checkpoint.js +1 -90
- package/src/clipboard.js +1 -424
- package/src/cloudsync.js +1 -528
- package/src/commands.js +1 -4089
- 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/filepreview.js +1 -153
- package/src/fingerprint.js +1 -592
- package/src/format.js +1 -259
- package/src/fuzzy.js +1 -119
- package/src/history.js +1 -423
- 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 -507
- package/src/naming.js +1 -57
- package/src/overlays.js +1 -462
- package/src/panels.js +1 -1418
- package/src/ping.js +1 -226
- package/src/presence.js +1 -238
- package/src/render.js +1 -516
- 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 -191
- package/vendor/client/aegis.js +1 -2441
- package/vendor/client/attest.js +1 -518
- 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 -199
- package/vendor/client/catalog-client.js +1 -487
- package/vendor/client/conversation-export.js +1 -177
- 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 -234
- 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/naming.js +1 -283
- 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 -575
- package/vendor/client/topup.js +1 -297
- package/vendor/client/touch.js +1 -458
- package/vendor/client/update.js +1 -763
- package/vendor/client/user-models.js +1 -381
- package/vendor/desktop/lib/local/agents.js +1 -105
- package/vendor/desktop/lib/local/attachments.js +1 -276
- package/vendor/desktop/lib/local/autonomous.js +1 -1045
- package/vendor/desktop/lib/local/claude-pro.js +1 -1028
- package/vendor/desktop/lib/local/context.js +1 -125
- package/vendor/desktop/lib/local/engine.js +1 -3666
- package/vendor/desktop/lib/local/entitlement.js +1 -660
- package/vendor/desktop/lib/local/exec-plan.js +1 -269
- package/vendor/desktop/lib/local/git-scope.js +1 -228
- package/vendor/desktop/lib/local/integrity.js +1 -163
- package/vendor/desktop/lib/local/local.js +1 -2145
- package/vendor/desktop/lib/local/prompt.js +1 -280
- package/vendor/desktop/lib/local/queue.js +1 -560
- package/vendor/desktop/lib/local/session-rounds.js +1 -238
- package/vendor/desktop/lib/local/shell.js +1 -712
- package/vendor/desktop/lib/local/spill.js +1 -75
- package/vendor/desktop/lib/local/tools.js +1 -1328
- 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/main.js +1 -4890
- 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 -383
package/vendor/one/src/child.js
CHANGED
|
@@ -1,287 +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
|
-
* child.js — the Claude child's argv, DERIVED (AEGISONE, decision D8 rule 4).
|
|
10
|
-
*
|
|
11
|
-
* AEGISONE spawns `claude` for the Claude-Pro/BYOK path. That process runs its
|
|
12
|
-
* own permission system, and its prompts land on *its* stdin — which neither a
|
|
13
|
-
* GUI approval card nor the CLI's prompt loop can answer. The repo already ran
|
|
14
|
-
* this invocation for real (`benchmarks/frozen-run-final-noaider.json`):
|
|
15
|
-
*
|
|
16
|
-
* -p --output-format stream-json --dangerously-skip-permissions
|
|
17
|
-
* (ANTHROPIC_BASE_URL=api.deepseek.com/anthropic)
|
|
18
|
-
*
|
|
19
|
-
* Two bugs that shape every choice below:
|
|
20
|
-
*
|
|
21
|
-
* 1. **A hand-typed argv is a second decision.** If the spawn site writes its
|
|
22
|
-
* own flags, the child's policy and ours drift the moment either changes —
|
|
23
|
-
* and the child's is the one nobody can answer. So the argv is built here,
|
|
24
|
-
* from the posture record `one/src/permissions.js` already resolved, and
|
|
25
|
-
* the exact array is asserted by test (argv EQUALITY, not "a flag was
|
|
26
|
-
* passed"), for both child kinds.
|
|
27
|
-
* 2. **`-p` with an unanswered prompt is a HANG, not a refusal.** For a
|
|
28
|
-
* headless child the bypass is the derived skip; without it the child asks
|
|
29
|
-
* a question nobody can answer. The negative control for that lives with
|
|
30
|
-
* the runner (the "no one to answer it" path), and this module's half of it
|
|
31
|
-
* is that the headless argv carries NO permission flag when the posture
|
|
32
|
-
* says no skip — so the run fails fast instead of parking.
|
|
33
|
-
*
|
|
34
|
-
* ## Rule 4, in full
|
|
35
|
-
*
|
|
36
|
-
* headless `--dangerously-skip-permissions` iff our posture says skip;
|
|
37
|
-
* otherwise nothing at all (never a "harmless" default).
|
|
38
|
-
* interactive `--allow-dangerously-skip-permissions` instead — the same
|
|
39
|
-
* capability offered as an option rather than made the default,
|
|
40
|
-
* which is the narrowest thing that works and the variant
|
|
41
|
-
* Claude's own help describes as "without it being enabled by
|
|
42
|
-
* default".
|
|
43
|
-
* both `--allowedTools` / `--disallowedTools` from the SAME rule set
|
|
44
|
-
* (`allow` → allowed, `deny` → disallowed), so the child's policy
|
|
45
|
-
* tracks ours; `--permission-mode` only when it was explicitly
|
|
46
|
-
* given, validated against the CLI's own list, and ALWAYS
|
|
47
|
-
* recorded — recorded, never inferred.
|
|
48
|
-
*
|
|
49
|
-
* No `process.*` anywhere, module scope or not: the argv is a pure function of
|
|
50
|
-
* its descriptor, which is what makes the equality assertions above possible.
|
|
51
|
-
*/
|
|
52
|
-
|
|
53
|
-
/** Rule 4's own flag spellings (verified against claude 2.1.228's --help). */
|
|
54
|
-
const FLAGS = Object.freeze({
|
|
55
|
-
headlessSkip: '--dangerously-skip-permissions',
|
|
56
|
-
interactiveSkip: '--allow-dangerously-skip-permissions',
|
|
57
|
-
permissionMode: '--permission-mode',
|
|
58
|
-
allowedTools: '--allowedTools',
|
|
59
|
-
disallowedTools: '--disallowedTools',
|
|
60
|
-
print: '-p',
|
|
61
|
-
outputFormat: '--output-format',
|
|
62
|
-
model: '--model',
|
|
63
|
-
// Conversation continuity for the Pro child (see `sessionId` below). Both
|
|
64
|
-
// spellings are the CLI's own (claude 2.1.228 --help): `--session-id <uuid>`
|
|
65
|
-
// names the session a NEW conversation runs in, `--resume <id>` reattaches to
|
|
66
|
-
// an existing one, which is what carries the prior turns' context across
|
|
67
|
-
// separate child processes.
|
|
68
|
-
sessionId: '--session-id',
|
|
69
|
-
resume: '--resume',
|
|
70
|
-
// The extra working directories the child may touch (claude 2.1.228 --help:
|
|
71
|
-
// "Additional directories to allow tool …"). See addDirArgs() — the spelling
|
|
72
|
-
// here is deliberately the EQUALS form and that is not cosmetic.
|
|
73
|
-
addDir: '--add-dir',
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* `--add-dir` is the child's own sandbox boundary: by default a headless child
|
|
78
|
-
* resolves every relative path and every tool's root against the directory it
|
|
79
|
-
* was spawned in, so a turn started in `repo/cli/` cannot read, run or even
|
|
80
|
-
* SEE `repo/test/` — the exact "outside the sandboxed directory" wall a real
|
|
81
|
-
* session reported from this product.
|
|
82
|
-
*
|
|
83
|
-
* ── why the EQUALS form, and why one flag per directory ─────────────────────
|
|
84
|
-
*
|
|
85
|
-
* `--add-dir` is VARIADIC: the child keeps consuming the words after it as
|
|
86
|
-
* directories. So the obvious `['--add-dir', dir, prompt]` is not merely
|
|
87
|
-
* fragile, it is broken — and this was measured against the installed binary
|
|
88
|
-
* (2.1.228), not reasoned about:
|
|
89
|
-
*
|
|
90
|
-
* claude -p --add-dir /tmp "do the thing" → Error: Input must be provided
|
|
91
|
-
* either through stdin or as a
|
|
92
|
-
* prompt argument when using --print
|
|
93
|
-
* claude -p --add-dir=/tmp "do the thing" → runs
|
|
94
|
-
*
|
|
95
|
-
* The prompt is the LAST item of the argv (rule 4 keeps it there, because the
|
|
96
|
-
* child reads it as the initial message). A space-form `--add-dir` immediately
|
|
97
|
-
* before it therefore swallows the user's prompt into the directory list, and
|
|
98
|
-
* the turn dies as an empty-input error before the model is ever reached.
|
|
99
|
-
* Attaching the value to the flag with `=` terminates the variadic run, so the
|
|
100
|
-
* prompt survives, and one flag per directory keeps a directory whose name
|
|
101
|
-
* begins with `-` from being re-read as another option. Empty and duplicate
|
|
102
|
-
* entries are dropped here rather than passed on: the list reaches the child's
|
|
103
|
-
* sandbox, so what it contains is a decision, not a formality.
|
|
104
|
-
*/
|
|
105
|
-
function addDirArgs(dirs) {
|
|
106
|
-
const out = [];
|
|
107
|
-
for (const dir of unique(dirs)) out.push(`${FLAGS.addDir}=${dir}`);
|
|
108
|
-
return out;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* A UUID, as `--session-id` requires. The CLI rejects anything else, and it
|
|
113
|
-
* rejects it AFTER the spawn — an argv that cannot work must not be built, so
|
|
114
|
-
* this returns null and the caller throws rather than typing a value the child
|
|
115
|
-
* will refuse while the turn looks as if it started.
|
|
116
|
-
*/
|
|
117
|
-
const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
118
|
-
|
|
119
|
-
const DEFAULT_OUTPUT_FORMAT = 'stream-json';
|
|
120
|
-
|
|
121
|
-
/** Dedupe while keeping the user's own rule order (rules are read top-down). */
|
|
122
|
-
function unique(list) {
|
|
123
|
-
const seen = new Set();
|
|
124
|
-
const out = [];
|
|
125
|
-
for (const item of Array.isArray(list) ? list : []) {
|
|
126
|
-
const v = String(item).trim();
|
|
127
|
-
if (!v || seen.has(v)) continue;
|
|
128
|
-
seen.add(v);
|
|
129
|
-
out.push(v);
|
|
130
|
-
}
|
|
131
|
-
return out;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* Build the Claude child's argv from the resolved posture.
|
|
136
|
-
*
|
|
137
|
-
* @param {object} [descriptor]
|
|
138
|
-
* @param {object} [descriptor.posture] a record from resolvePosture()
|
|
139
|
-
* @param {string} [descriptor.prompt] initial prompt (both kinds accept one)
|
|
140
|
-
* @param {string} [descriptor.model] explicit model id, if any
|
|
141
|
-
* @param {string} [descriptor.outputFormat] headless only; defaults to stream-json
|
|
142
|
-
* @param {string} [descriptor.permissionMode] explicit passthrough, one of
|
|
143
|
-
* PERMISSION_MODES (else throw)
|
|
144
|
-
* @param {string} [descriptor.resumeSessionId] reattach to an existing child
|
|
145
|
-
* session → `--resume <uuid>`
|
|
146
|
-
* @param {string} [descriptor.sessionId] name a NEW child session, so a
|
|
147
|
-
* LATER turn can `--resume` it
|
|
148
|
-
* @param {string[]} [descriptor.addDir] extra directories the child may
|
|
149
|
-
* work in → `--add-dir=<dir>` each
|
|
150
|
-
* @param {string[]} [descriptor.extra] extra argv items, appended last
|
|
151
|
-
* @returns {{argv: string[], record: object}} both frozen
|
|
152
|
-
* @throws when `permissionMode` is set to something Claude does not accept —
|
|
153
|
-
* a mode we cannot name is a mode we must not silently drop, because
|
|
154
|
-
* the run log would then record "no passthrough" for a run that asked
|
|
155
|
-
* for one.
|
|
156
|
-
* @throws when a session id is given that is not a UUID. Same reason, harder:
|
|
157
|
-
* `claude` refuses a malformed `--session-id` itself, after the spawn,
|
|
158
|
-
* so passing one through would turn a continuity bug into an opaque
|
|
159
|
-
* failed turn.
|
|
160
|
-
*/
|
|
161
|
-
function claudeArgv(descriptor = {}) {
|
|
162
|
-
const posture = descriptor.posture;
|
|
163
|
-
if (!posture || typeof posture !== 'object') {
|
|
164
|
-
throw new Error('claudeArgv requires a resolved posture record (one/src/permissions.js resolvePosture)');
|
|
165
|
-
}
|
|
166
|
-
const kind = posture.childKind;
|
|
167
|
-
const headless = kind !== 'interactive';
|
|
168
|
-
|
|
169
|
-
// Imported lazily to keep this module free of a load-time dependency on the
|
|
170
|
-
// evaluator, and to keep the enum's single definition in one place.
|
|
171
|
-
const { PERMISSION_MODES } = require('./permissions.js');
|
|
172
|
-
|
|
173
|
-
const modeGiven = descriptor.permissionMode !== undefined && descriptor.permissionMode !== null;
|
|
174
|
-
const mode = modeGiven ? String(descriptor.permissionMode) : null;
|
|
175
|
-
if (modeGiven && !PERMISSION_MODES.includes(mode)) {
|
|
176
|
-
throw new Error(
|
|
177
|
-
`--permission-mode ${JSON.stringify(mode)} is not one of ${PERMISSION_MODES.join('|')} — ` +
|
|
178
|
-
'refusing to pass (or to silently drop) a mode the child does not accept.'
|
|
179
|
-
);
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
const rules = posture.rules || {};
|
|
183
|
-
const allowedTools = unique(rules.allow);
|
|
184
|
-
const disallowedTools = unique(rules.deny);
|
|
185
|
-
// Ask rules have no `--allowedTools`/`--disallowedTools` spelling: they are
|
|
186
|
-
// recorded rather than approximated, because approximating "ask" as "deny"
|
|
187
|
-
// would be a refusal the user never asked for.
|
|
188
|
-
const unmappedAsk = unique(rules.ask);
|
|
189
|
-
|
|
190
|
-
// ── conversation continuity ───────────────────────────────────────────────
|
|
191
|
-
//
|
|
192
|
-
// The Pro child runs its own agent loop, so the engine does not replay the
|
|
193
|
-
// transcript into it (engine.js's `pro` branch). Continuity therefore has to
|
|
194
|
-
// come from the CLI's own session store, or every turn is a new conversation
|
|
195
|
-
// with no memory of the last one — which is exactly what it was.
|
|
196
|
-
//
|
|
197
|
-
// `resumeSessionId` wins over `sessionId`: a reattach to a session we already
|
|
198
|
-
// had is the same conversation, and naming a NEW id while resuming would
|
|
199
|
-
// start a second thread beside the live one. Both are validated as UUIDs
|
|
200
|
-
// before they reach argv, because the CLI's own rejection lands after the
|
|
201
|
-
// spawn.
|
|
202
|
-
const wantedResumeId = descriptor.resumeSessionId ? String(descriptor.resumeSessionId).trim() : '';
|
|
203
|
-
const wantedNewId = descriptor.sessionId ? String(descriptor.sessionId).trim() : '';
|
|
204
|
-
const resumeId = wantedResumeId || null;
|
|
205
|
-
const newId = !resumeId && wantedNewId ? wantedNewId : null;
|
|
206
|
-
for (const [label, value] of [['resumeSessionId', resumeId], ['sessionId', newId]]) {
|
|
207
|
-
if (value && !UUID_RE.test(value)) {
|
|
208
|
-
throw new Error(
|
|
209
|
-
`${label} ${JSON.stringify(value)} is not a UUID — refusing to pass it to ` +
|
|
210
|
-
'--resume/--session-id, which the child rejects after the spawn (turning a ' +
|
|
211
|
-
'continuity bug into an opaque failed turn).'
|
|
212
|
-
);
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
const argv = [];
|
|
217
|
-
if (headless) {
|
|
218
|
-
argv.push(FLAGS.print, FLAGS.outputFormat, String(descriptor.outputFormat || DEFAULT_OUTPUT_FORMAT));
|
|
219
|
-
}
|
|
220
|
-
if (descriptor.model) argv.push(FLAGS.model, String(descriptor.model));
|
|
221
|
-
// The widened sandbox, before the permission flags: what the child may reach
|
|
222
|
-
// is decided here, and the prompt stays last (see addDirArgs).
|
|
223
|
-
const addDir = addDirArgs(descriptor.addDir);
|
|
224
|
-
argv.push(...addDir);
|
|
225
|
-
if (allowedTools.length) argv.push(FLAGS.allowedTools, allowedTools.join(','));
|
|
226
|
-
if (disallowedTools.length) argv.push(FLAGS.disallowedTools, disallowedTools.join(','));
|
|
227
|
-
if (modeGiven) argv.push(FLAGS.permissionMode, mode);
|
|
228
|
-
if (posture.child && posture.child.flag) argv.push(posture.child.flag);
|
|
229
|
-
// Before `extra` (the transport's own flags) and before the prompt, which
|
|
230
|
-
// must stay last so the child reads it as the initial message.
|
|
231
|
-
if (resumeId) argv.push(FLAGS.resume, resumeId);
|
|
232
|
-
else if (newId) argv.push(FLAGS.sessionId, newId);
|
|
233
|
-
if (Array.isArray(descriptor.extra)) argv.push(...descriptor.extra.map(String));
|
|
234
|
-
if (descriptor.prompt !== undefined && descriptor.prompt !== null) argv.push(String(descriptor.prompt));
|
|
235
|
-
|
|
236
|
-
const record = Object.freeze({
|
|
237
|
-
kind,
|
|
238
|
-
// "always recorded" (rule 4): the mode is in the record whether or not it
|
|
239
|
-
// was passed, and `passThrough` says which of the two happened.
|
|
240
|
-
permissionMode: mode,
|
|
241
|
-
permissionModePassed: modeGiven,
|
|
242
|
-
skip: Boolean(posture.child && posture.child.skip),
|
|
243
|
-
skipFlag: (posture.child && posture.child.flag) || null,
|
|
244
|
-
allowedTools: Object.freeze(allowedTools),
|
|
245
|
-
disallowedTools: Object.freeze(disallowedTools),
|
|
246
|
-
unmappedAsk: Object.freeze(unmappedAsk),
|
|
247
|
-
// Recorded, not inferred, exactly like the argv: an install that WIDENED its
|
|
248
|
-
// sandbox for the child is the one thing a later reader of the run log must
|
|
249
|
-
// not have to reconstruct from the argv's shape.
|
|
250
|
-
addDir: Object.freeze(addDir.map((a) => a.slice(FLAGS.addDir.length + 1))),
|
|
251
|
-
// Continuity, recorded the same way the mode is: which of the two happened
|
|
252
|
-
// (reattached vs. named a new session) is part of what this turn asked for,
|
|
253
|
-
// and a caller reading only the argv would have to infer it from position.
|
|
254
|
-
resumeSessionId: resumeId,
|
|
255
|
-
sessionId: newId,
|
|
256
|
-
argv: Object.freeze(argv.slice()),
|
|
257
|
-
});
|
|
258
|
-
|
|
259
|
-
return { argv: record.argv, record };
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
/** The run-log line for a child argv (rule 4: recorded, never inferred). */
|
|
263
|
-
function childRecordLine(record) {
|
|
264
|
-
if (!record || typeof record !== 'object') return null;
|
|
265
|
-
const mode = record.permissionModePassed
|
|
266
|
-
? `${FLAGS.permissionMode}=${record.permissionMode}`
|
|
267
|
-
: 'no --permission-mode (none was set)';
|
|
268
|
-
return (
|
|
269
|
-
`aegis: claude child [${record.kind}] ${record.skipFlag || 'no permission flag'} · ${mode} · ` +
|
|
270
|
-
`allowedTools=[${record.allowedTools.join(', ')}] disallowedTools=[${record.disallowedTools.join(', ')}]` +
|
|
271
|
-
(record.unmappedAsk.length ? ` (ask rules recorded, unmapped: ${record.unmappedAsk.join(', ')})` : '') +
|
|
272
|
-
// The widened sandbox, named for the same reason the mode is: "the child
|
|
273
|
-
// could only see its own directory" is otherwise indistinguishable, in a
|
|
274
|
-
// transcript, from "the model chose not to look".
|
|
275
|
-
(record.addDir && record.addDir.length ? ` · addDir=[${record.addDir.join(', ')}]` : '') +
|
|
276
|
-
// The continuity half, named rather than left to be read off the argv:
|
|
277
|
-
// "resumed" and "new id" are the two things a turn can mean here, and a
|
|
278
|
-
// turn that silently did neither is the bug this line makes visible.
|
|
279
|
-
(record.resumeSessionId
|
|
280
|
-
? ` · resumed session ${record.resumeSessionId}`
|
|
281
|
-
: record.sessionId
|
|
282
|
-
? ` · new session ${record.sessionId}`
|
|
283
|
-
: ' · no session id (each turn is a new conversation)')
|
|
284
|
-
);
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
module.exports = { FLAGS, DEFAULT_OUTPUT_FORMAT, claudeArgv, addDirArgs, childRecordLine };
|
|
3
|
+
"use strict";const FLAGS=Object.freeze({headlessSkip:"--dangerously-skip-permissions",interactiveSkip:"--allow-dangerously-skip-permissions",permissionMode:"--permission-mode",allowedTools:"--allowedTools",disallowedTools:"--disallowedTools",print:"-p",outputFormat:"--output-format",model:"--model",sessionId:"--session-id",resume:"--resume",addDir:"--add-dir"});function addDirArgs(e){const s=[];for(const o of unique(e))s.push(`${FLAGS.addDir}=${o}`);return s}const UUID_RE=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,DEFAULT_OUTPUT_FORMAT="stream-json";function unique(e){const s=new Set,o=[];for(const i of Array.isArray(e)?e:[]){const e=String(i).trim();e&&!s.has(e)&&(s.add(e),o.push(e))}return o}function claudeArgv(e={}){const s=e.posture;if(!s||"object"!=typeof s)throw new Error("claudeArgv requires a resolved posture record (one/src/permissions.js resolvePosture)");const o=s.childKind,i="interactive"!==o,{PERMISSION_MODES:r}=require("./permissions.js"),n=void 0!==e.permissionMode&&null!==e.permissionMode,d=n?String(e.permissionMode):null;if(n&&!r.includes(d))throw new Error(`--permission-mode ${JSON.stringify(d)} is not one of ${r.join("|")} — refusing to pass (or to silently drop) a mode the child does not accept.`);const t=s.rules||{},l=unique(t.allow),a=unique(t.deny),u=unique(t.ask),p=e.resumeSessionId?String(e.resumeSessionId).trim():"",c=e.sessionId?String(e.sessionId).trim():"",m=p||null,h=!m&&c?c:null;for(const[e,s]of[["resumeSessionId",m],["sessionId",h]])if(s&&!UUID_RE.test(s))throw new Error(`${e} ${JSON.stringify(s)} is not a UUID — refusing to pass it to --resume/--session-id, which the child rejects after the spawn (turning a continuity bug into an opaque failed turn).`);const f=[];i&&f.push(FLAGS.print,FLAGS.outputFormat,String(e.outputFormat||"stream-json")),e.model&&f.push(FLAGS.model,String(e.model));const g=addDirArgs(e.addDir);f.push(...g),l.length&&f.push(FLAGS.allowedTools,l.join(",")),a.length&&f.push(FLAGS.disallowedTools,a.join(",")),n&&f.push(FLAGS.permissionMode,d),s.child&&s.child.flag&&f.push(s.child.flag),m?f.push(FLAGS.resume,m):h&&f.push(FLAGS.sessionId,h),Array.isArray(e.extra)&&f.push(...e.extra.map(String)),void 0!==e.prompt&&null!==e.prompt&&f.push(String(e.prompt));const S=Object.freeze({kind:o,permissionMode:d,permissionModePassed:n,skip:Boolean(s.child&&s.child.skip),skipFlag:s.child&&s.child.flag||null,allowedTools:Object.freeze(l),disallowedTools:Object.freeze(a),unmappedAsk:Object.freeze(u),addDir:Object.freeze(g.map((e=>e.slice(FLAGS.addDir.length+1)))),resumeSessionId:m,sessionId:h,argv:Object.freeze(f.slice())});return{argv:S.argv,record:S}}function childRecordLine(e){if(!e||"object"!=typeof e)return null;const s=e.permissionModePassed?`${FLAGS.permissionMode}=${e.permissionMode}`:"no --permission-mode (none was set)";return`aegis: claude child [${e.kind}] ${e.skipFlag||"no permission flag"} · ${s} · allowedTools=[${e.allowedTools.join(", ")}] disallowedTools=[${e.disallowedTools.join(", ")}]`+(e.unmappedAsk.length?` (ask rules recorded, unmapped: ${e.unmappedAsk.join(", ")})`:"")+(e.addDir&&e.addDir.length?` · addDir=[${e.addDir.join(", ")}]`:"")+(e.resumeSessionId?` · resumed session ${e.resumeSessionId}`:e.sessionId?` · new session ${e.sessionId}`:" · no session id (each turn is a new conversation)")}module.exports={FLAGS:FLAGS,DEFAULT_OUTPUT_FORMAT:"stream-json",claudeArgv:claudeArgv,addDirArgs:addDirArgs,childRecordLine:childRecordLine};
|