@openape/apes 1.16.0 → 1.17.0
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/dist/cli.js
CHANGED
|
@@ -4163,9 +4163,15 @@ and try again.`
|
|
|
4163
4163
|
troop
|
|
4164
4164
|
});
|
|
4165
4165
|
writeFileSync4(scriptPath, script, { mode: 448 });
|
|
4166
|
-
|
|
4167
|
-
|
|
4168
|
-
|
|
4166
|
+
const alreadyRoot = process.getuid?.() === 0;
|
|
4167
|
+
if (alreadyRoot) {
|
|
4168
|
+
consola23.start("Running privileged setup directly (already root)\u2026");
|
|
4169
|
+
execFileSync6("bash", [scriptPath], { stdio: "inherit" });
|
|
4170
|
+
} else {
|
|
4171
|
+
consola23.start("Running privileged setup as root via `apes run --as root --wait`\u2026");
|
|
4172
|
+
consola23.info("You will be asked to approve the as=root grant in your DDISA inbox; this command blocks until you do.");
|
|
4173
|
+
execFileSync6(apes, ["run", "--as", "root", "--wait", "--", "bash", scriptPath], { stdio: "inherit" });
|
|
4174
|
+
}
|
|
4169
4175
|
try {
|
|
4170
4176
|
const uid = readMacOSUidOrNull(name);
|
|
4171
4177
|
upsertNestAgent({
|
|
@@ -5815,6 +5821,19 @@ async function runAudienceMode(audience, action, args) {
|
|
|
5815
5821
|
const grantsUrl = await getGrantsEndpoint(idp);
|
|
5816
5822
|
const command = action.split(" ");
|
|
5817
5823
|
const targetHost = args.host || hostname5();
|
|
5824
|
+
const runAs = args.as ?? void 0;
|
|
5825
|
+
const reusableId = await findReusableAudienceGrant({
|
|
5826
|
+
grantsUrl,
|
|
5827
|
+
requester: auth.email,
|
|
5828
|
+
audience,
|
|
5829
|
+
command,
|
|
5830
|
+
targetHost,
|
|
5831
|
+
runAs
|
|
5832
|
+
});
|
|
5833
|
+
if (reusableId) {
|
|
5834
|
+
const { authz_jwt: authz_jwt2 } = await apiFetch(`${grantsUrl}/${reusableId}/token`, { method: "POST" });
|
|
5835
|
+
return executeWithGrantToken({ audience, command, args, token: authz_jwt2 });
|
|
5836
|
+
}
|
|
5818
5837
|
consola36.info(`Requesting ${audience} grant on ${targetHost}: ${command.join(" ")}`);
|
|
5819
5838
|
const grant = await apiFetch(grantsUrl, {
|
|
5820
5839
|
method: "POST",
|
|
@@ -5825,7 +5844,7 @@ async function runAudienceMode(audience, action, args) {
|
|
|
5825
5844
|
grant_type: args.approval,
|
|
5826
5845
|
command,
|
|
5827
5846
|
reason: args.reason || command.join(" "),
|
|
5828
|
-
...
|
|
5847
|
+
...runAs ? { run_as: runAs } : {}
|
|
5829
5848
|
}
|
|
5830
5849
|
});
|
|
5831
5850
|
if (!shouldWaitForGrant(args)) {
|
|
@@ -5861,11 +5880,15 @@ async function runAudienceMode(audience, action, args) {
|
|
|
5861
5880
|
const { authz_jwt } = await apiFetch(`${grantsUrl}/${grant.id}/token`, {
|
|
5862
5881
|
method: "POST"
|
|
5863
5882
|
});
|
|
5883
|
+
return executeWithGrantToken({ audience, command, args, token: authz_jwt });
|
|
5884
|
+
}
|
|
5885
|
+
function executeWithGrantToken(opts) {
|
|
5886
|
+
const { audience, command, args, token } = opts;
|
|
5864
5887
|
if (audience === "escapes") {
|
|
5865
5888
|
consola36.info(`Executing: ${command.join(" ")}`);
|
|
5866
5889
|
try {
|
|
5867
5890
|
const { APES_SHELL_WRAPPER: _wrapperMarker, ...inheritedEnv } = process.env;
|
|
5868
|
-
execFileSync13(args["escapes-path"] || "escapes", ["--grant",
|
|
5891
|
+
execFileSync13(args["escapes-path"] || "escapes", ["--grant", token, "--", ...command], {
|
|
5869
5892
|
stdio: "inherit",
|
|
5870
5893
|
env: inheritedEnv
|
|
5871
5894
|
});
|
|
@@ -5874,7 +5897,28 @@ async function runAudienceMode(audience, action, args) {
|
|
|
5874
5897
|
throw new CliExit(exitCode);
|
|
5875
5898
|
}
|
|
5876
5899
|
} else {
|
|
5877
|
-
process.stdout.write(
|
|
5900
|
+
process.stdout.write(token);
|
|
5901
|
+
}
|
|
5902
|
+
}
|
|
5903
|
+
async function findReusableAudienceGrant(opts) {
|
|
5904
|
+
try {
|
|
5905
|
+
const grants = await apiFetch(`${opts.grantsUrl}?requester=${encodeURIComponent(opts.requester)}&status=approved&limit=50`);
|
|
5906
|
+
const now = Math.floor(Date.now() / 1e3);
|
|
5907
|
+
const match = grants.data.find((g) => {
|
|
5908
|
+
const r3 = g.request;
|
|
5909
|
+
if (r3.audience !== opts.audience) return false;
|
|
5910
|
+
if (r3.target_host !== opts.targetHost) return false;
|
|
5911
|
+
if (r3.grant_type === "once") return false;
|
|
5912
|
+
if (r3.grant_type === "timed" && g.expires_at && g.expires_at <= now) return false;
|
|
5913
|
+
const cmd = r3.command ?? [];
|
|
5914
|
+
if (cmd.length !== opts.command.length) return false;
|
|
5915
|
+
if (!cmd.every((c2, i) => c2 === opts.command[i])) return false;
|
|
5916
|
+
if ((r3.run_as ?? void 0) !== opts.runAs) return false;
|
|
5917
|
+
return true;
|
|
5918
|
+
});
|
|
5919
|
+
return match?.id ?? null;
|
|
5920
|
+
} catch {
|
|
5921
|
+
return null;
|
|
5878
5922
|
}
|
|
5879
5923
|
}
|
|
5880
5924
|
|
|
@@ -6367,7 +6411,7 @@ var mcpCommand = defineCommand48({
|
|
|
6367
6411
|
if (transport !== "stdio" && transport !== "sse") {
|
|
6368
6412
|
throw new Error('Transport must be "stdio" or "sse"');
|
|
6369
6413
|
}
|
|
6370
|
-
const { startMcpServer } = await import("./server-
|
|
6414
|
+
const { startMcpServer } = await import("./server-VPKUJDKY.js");
|
|
6371
6415
|
await startMcpServer(transport, port);
|
|
6372
6416
|
}
|
|
6373
6417
|
});
|
|
@@ -7005,7 +7049,7 @@ async function bestEffortGrantCount(idp) {
|
|
|
7005
7049
|
}
|
|
7006
7050
|
}
|
|
7007
7051
|
async function runHealth(args) {
|
|
7008
|
-
const version = true ? "1.
|
|
7052
|
+
const version = true ? "1.17.0" : "0.0.0";
|
|
7009
7053
|
const auth = loadAuth();
|
|
7010
7054
|
if (!auth) {
|
|
7011
7055
|
throw new CliError("Not logged in. Run `apes login` first.", 1);
|
|
@@ -7278,10 +7322,10 @@ if (shellRewrite) {
|
|
|
7278
7322
|
if (shellRewrite.action === "rewrite") {
|
|
7279
7323
|
process.argv = shellRewrite.argv;
|
|
7280
7324
|
} else if (shellRewrite.action === "version") {
|
|
7281
|
-
console.log(`ape-shell ${"1.
|
|
7325
|
+
console.log(`ape-shell ${"1.17.0"} (OpenApe DDISA shell wrapper)`);
|
|
7282
7326
|
process.exit(0);
|
|
7283
7327
|
} else if (shellRewrite.action === "help") {
|
|
7284
|
-
console.log(`ape-shell ${"1.
|
|
7328
|
+
console.log(`ape-shell ${"1.17.0"} \u2014 OpenApe DDISA shell wrapper`);
|
|
7285
7329
|
console.log("");
|
|
7286
7330
|
console.log("Usage:");
|
|
7287
7331
|
console.log(" ape-shell Start interactive grant-mediated REPL");
|
|
@@ -7339,7 +7383,7 @@ var configCommand = defineCommand60({
|
|
|
7339
7383
|
var main = defineCommand60({
|
|
7340
7384
|
meta: {
|
|
7341
7385
|
name: "apes",
|
|
7342
|
-
version: "1.
|
|
7386
|
+
version: "1.17.0",
|
|
7343
7387
|
description: "Unified CLI for OpenApe"
|
|
7344
7388
|
},
|
|
7345
7389
|
subCommands: {
|
|
@@ -7396,7 +7440,7 @@ async function maybeRefreshAuth() {
|
|
|
7396
7440
|
}
|
|
7397
7441
|
}
|
|
7398
7442
|
await maybeRefreshAuth();
|
|
7399
|
-
await maybeWarnStaleVersion("1.
|
|
7443
|
+
await maybeWarnStaleVersion("1.17.0").catch(() => {
|
|
7400
7444
|
});
|
|
7401
7445
|
runMain(main).catch((err) => {
|
|
7402
7446
|
if (err instanceof CliExit) {
|