@openape/apes 1.31.4 → 1.31.5
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
|
@@ -98,7 +98,7 @@ function rewriteApeShellArgs(argv, argv0) {
|
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
// src/cli.ts
|
|
101
|
-
import { defineCommand as defineCommand65, runMain } from "citty";
|
|
101
|
+
import { defineCommand as defineCommand65, runCommand as runCittyCommand, runMain } from "citty";
|
|
102
102
|
|
|
103
103
|
// src/commands/auth/login.ts
|
|
104
104
|
import { Buffer } from "buffer";
|
|
@@ -765,8 +765,8 @@ async function waitForApproval(grantsUrl, grantId) {
|
|
|
765
765
|
import { hostname as hostname2 } from "os";
|
|
766
766
|
import { defineCommand as defineCommand8 } from "citty";
|
|
767
767
|
import consola8 from "consola";
|
|
768
|
-
function parseCapabilityArgs(
|
|
769
|
-
const tokens = [...
|
|
768
|
+
function parseCapabilityArgs(rawArgs2) {
|
|
769
|
+
const tokens = [...rawArgs2];
|
|
770
770
|
if (tokens[0] === "request-capability") {
|
|
771
771
|
tokens.shift();
|
|
772
772
|
}
|
|
@@ -938,12 +938,12 @@ var requestCapabilityCommand = defineCommand8({
|
|
|
938
938
|
default: false
|
|
939
939
|
}
|
|
940
940
|
},
|
|
941
|
-
async run({ rawArgs }) {
|
|
941
|
+
async run({ rawArgs: rawArgs2 }) {
|
|
942
942
|
const auth = loadAuth();
|
|
943
943
|
if (!auth) {
|
|
944
944
|
throw new CliError("Not logged in. Run `apes login` first.");
|
|
945
945
|
}
|
|
946
|
-
const parsed = parseCapabilityArgs(
|
|
946
|
+
const parsed = parseCapabilityArgs(rawArgs2);
|
|
947
947
|
const idp = getIdpUrl(parsed.idp);
|
|
948
948
|
if (!idp) {
|
|
949
949
|
throw new CliError("No IdP URL configured. Use --idp or log in first.");
|
|
@@ -1899,13 +1899,13 @@ function parseKeyValues(pairs) {
|
|
|
1899
1899
|
function missingCapabilities(required, provided) {
|
|
1900
1900
|
return required.filter((env) => !(env in provided));
|
|
1901
1901
|
}
|
|
1902
|
-
function collectFlag(
|
|
1902
|
+
function collectFlag(rawArgs2, name) {
|
|
1903
1903
|
const out = [];
|
|
1904
1904
|
const long = `--${name}`;
|
|
1905
|
-
for (let i = 0; i <
|
|
1906
|
-
const a =
|
|
1905
|
+
for (let i = 0; i < rawArgs2.length; i++) {
|
|
1906
|
+
const a = rawArgs2[i];
|
|
1907
1907
|
if (a === long) {
|
|
1908
|
-
const v =
|
|
1908
|
+
const v = rawArgs2[i + 1];
|
|
1909
1909
|
if (v !== void 0 && !v.startsWith("--")) {
|
|
1910
1910
|
out.push(v);
|
|
1911
1911
|
i++;
|
|
@@ -1937,11 +1937,11 @@ var deployAgentCommand = defineCommand21({
|
|
|
1937
1937
|
"host-id": { type: "string", description: "Target nest host_id (default: first connected)" },
|
|
1938
1938
|
json: { type: "boolean", description: "Machine-readable output, no prompts" }
|
|
1939
1939
|
},
|
|
1940
|
-
async run({ args, rawArgs }) {
|
|
1940
|
+
async run({ args, rawArgs: rawArgs2 }) {
|
|
1941
1941
|
const repoRef = args.repo;
|
|
1942
1942
|
if (!repoRef) throw new CliError("usage: apes agent deploy <repo>@<ref> [--param k=v] [--secret ENV=val]");
|
|
1943
|
-
const params = parseKeyValues(collectFlag(
|
|
1944
|
-
const secrets = parseKeyValues(collectFlag(
|
|
1943
|
+
const params = parseKeyValues(collectFlag(rawArgs2, "param"));
|
|
1944
|
+
const secrets = parseKeyValues(collectFlag(rawArgs2, "secret"));
|
|
1945
1945
|
const json = !!args.json;
|
|
1946
1946
|
const token = (await ensureFreshIdpAuth()).access_token;
|
|
1947
1947
|
const troop = resolveTroopUrl();
|
|
@@ -2846,10 +2846,22 @@ fi
|
|
|
2846
2846
|
// src/commands/agents/list.ts
|
|
2847
2847
|
import { defineCommand as defineCommand27 } from "citty";
|
|
2848
2848
|
import consola24 from "consola";
|
|
2849
|
+
function buildOsStateResolver() {
|
|
2850
|
+
const platform = getHostPlatform();
|
|
2851
|
+
const osUsers = platform.listAgentUserNames();
|
|
2852
|
+
return (agentName) => {
|
|
2853
|
+
const u = platform.lookupAgentUser(agentName);
|
|
2854
|
+
if (u) return { osUser: true, home: u.homeDir };
|
|
2855
|
+
if (osUsers.has(platform.agentUsername(agentName)) || osUsers.has(agentName)) {
|
|
2856
|
+
return { osUser: true, home: null };
|
|
2857
|
+
}
|
|
2858
|
+
return { osUser: false, home: null };
|
|
2859
|
+
};
|
|
2860
|
+
}
|
|
2849
2861
|
var listAgentsCommand = defineCommand27({
|
|
2850
2862
|
meta: {
|
|
2851
2863
|
name: "list",
|
|
2852
|
-
description: "List agents owned by the current user
|
|
2864
|
+
description: "List agents owned by the current user (from the IdP); annotated with local OS-user status on a nest host"
|
|
2853
2865
|
},
|
|
2854
2866
|
args: {
|
|
2855
2867
|
json: {
|
|
@@ -2872,25 +2884,13 @@ var listAgentsCommand = defineCommand27({
|
|
|
2872
2884
|
}
|
|
2873
2885
|
const all = await apiFetch("/api/my-agents", { idp });
|
|
2874
2886
|
const filtered = args["include-inactive"] ? all : all.filter((u) => u.isActive !== false);
|
|
2875
|
-
const
|
|
2876
|
-
const
|
|
2877
|
-
const osStateOf = (agentName) => {
|
|
2878
|
-
const u = platform.lookupAgentUser(agentName);
|
|
2879
|
-
if (u) return { osUser: true, home: u.homeDir };
|
|
2880
|
-
if (osUsers.has(platform.agentUsername(agentName)) || osUsers.has(agentName)) {
|
|
2881
|
-
return { osUser: true, home: null };
|
|
2882
|
-
}
|
|
2883
|
-
return { osUser: false, home: null };
|
|
2884
|
-
};
|
|
2887
|
+
const onNest = isLinux();
|
|
2888
|
+
const osStateOf = onNest ? buildOsStateResolver() : null;
|
|
2885
2889
|
const rows = filtered.map((u) => {
|
|
2890
|
+
const base = { name: u.name, email: u.email, isActive: u.isActive !== false };
|
|
2891
|
+
if (!osStateOf) return base;
|
|
2886
2892
|
const os = osStateOf(u.name);
|
|
2887
|
-
return {
|
|
2888
|
-
name: u.name,
|
|
2889
|
-
email: u.email,
|
|
2890
|
-
isActive: u.isActive !== false,
|
|
2891
|
-
osUser: os.osUser,
|
|
2892
|
-
home: os.home
|
|
2893
|
-
};
|
|
2893
|
+
return { ...base, osUser: os.osUser, home: os.home };
|
|
2894
2894
|
});
|
|
2895
2895
|
if (args.json) {
|
|
2896
2896
|
process.stdout.write(`${JSON.stringify(rows, null, 2)}
|
|
@@ -2903,14 +2903,23 @@ var listAgentsCommand = defineCommand27({
|
|
|
2903
2903
|
}
|
|
2904
2904
|
const nameW = Math.max(4, ...rows.map((r) => r.name.length));
|
|
2905
2905
|
const emailW = Math.max(5, ...rows.map((r) => r.email.length));
|
|
2906
|
-
|
|
2906
|
+
if (onNest) {
|
|
2907
|
+
const header2 = `${"NAME".padEnd(nameW)} ${"EMAIL".padEnd(emailW)} ACTIVE OS-USER HOME`;
|
|
2908
|
+
console.log(header2);
|
|
2909
|
+
console.log("-".repeat(header2.length));
|
|
2910
|
+
for (const r of rows) {
|
|
2911
|
+
const active = r.isActive ? "\u2713" : "\u2717";
|
|
2912
|
+
const os = r.osUser ? "\u2713" : "\u2717";
|
|
2913
|
+
const homeCol = r.home ?? "(missing)";
|
|
2914
|
+
console.log(`${r.name.padEnd(nameW)} ${r.email.padEnd(emailW)} ${active.padEnd(6)} ${os.padEnd(7)} ${homeCol}`);
|
|
2915
|
+
}
|
|
2916
|
+
return;
|
|
2917
|
+
}
|
|
2918
|
+
const header = `${"NAME".padEnd(nameW)} ${"EMAIL".padEnd(emailW)} ACTIVE`;
|
|
2907
2919
|
console.log(header);
|
|
2908
2920
|
console.log("-".repeat(header.length));
|
|
2909
2921
|
for (const r of rows) {
|
|
2910
|
-
|
|
2911
|
-
const os = r.osUser ? "\u2713" : "\u2717";
|
|
2912
|
-
const homeCol = r.home ?? "(missing)";
|
|
2913
|
-
console.log(`${r.name.padEnd(nameW)} ${r.email.padEnd(emailW)} ${active.padEnd(6)} ${os.padEnd(7)} ${homeCol}`);
|
|
2922
|
+
console.log(`${r.name.padEnd(nameW)} ${r.email.padEnd(emailW)} ${r.isActive ? "\u2713" : "\u2717"}`);
|
|
2914
2923
|
}
|
|
2915
2924
|
}
|
|
2916
2925
|
});
|
|
@@ -4929,8 +4938,8 @@ var runCommand = defineCommand47({
|
|
|
4929
4938
|
required: false
|
|
4930
4939
|
}
|
|
4931
4940
|
},
|
|
4932
|
-
async run({ rawArgs, args }) {
|
|
4933
|
-
const wrappedCommand = extractWrappedCommand(
|
|
4941
|
+
async run({ rawArgs: rawArgs2, args }) {
|
|
4942
|
+
const wrappedCommand = extractWrappedCommand(rawArgs2 ?? []);
|
|
4934
4943
|
if (wrappedCommand.length > 0 && getUserMode() === "agent") {
|
|
4935
4944
|
routeDiagnosticsToStderrForWrappedAgentRun();
|
|
4936
4945
|
}
|
|
@@ -4939,9 +4948,9 @@ var runCommand = defineCommand47({
|
|
|
4939
4948
|
return;
|
|
4940
4949
|
}
|
|
4941
4950
|
if (wrappedCommand.length > 0) {
|
|
4942
|
-
await runAdapterMode(wrappedCommand,
|
|
4951
|
+
await runAdapterMode(wrappedCommand, rawArgs2 ?? [], args);
|
|
4943
4952
|
} else {
|
|
4944
|
-
const positionals = extractPositionals(
|
|
4953
|
+
const positionals = extractPositionals(rawArgs2 ?? []);
|
|
4945
4954
|
if (positionals.length < 2)
|
|
4946
4955
|
throw new Error("Usage: apes run -- <cli> <args...> OR apes run <audience> <action>");
|
|
4947
4956
|
await runAudienceMode(positionals[0], positionals[1], args);
|
|
@@ -5094,10 +5103,10 @@ function execShellCommand(command) {
|
|
|
5094
5103
|
throw new CliExit(exitCode);
|
|
5095
5104
|
}
|
|
5096
5105
|
}
|
|
5097
|
-
function extractPositionals(
|
|
5106
|
+
function extractPositionals(rawArgs2) {
|
|
5098
5107
|
const positionals = [];
|
|
5099
|
-
const delimiter =
|
|
5100
|
-
const args = delimiter >= 0 ?
|
|
5108
|
+
const delimiter = rawArgs2.indexOf("--");
|
|
5109
|
+
const args = delimiter >= 0 ? rawArgs2.slice(0, delimiter) : rawArgs2;
|
|
5101
5110
|
for (let i = 0; i < args.length; i++) {
|
|
5102
5111
|
const arg = args[i];
|
|
5103
5112
|
if (arg === "run")
|
|
@@ -5115,7 +5124,7 @@ function printGenericWarning(cliId) {
|
|
|
5115
5124
|
`);
|
|
5116
5125
|
process.stderr.write("Generic mode active \u2014 single-use grant will be required.\n");
|
|
5117
5126
|
}
|
|
5118
|
-
async function runAdapterMode(command,
|
|
5127
|
+
async function runAdapterMode(command, rawArgs2, args) {
|
|
5119
5128
|
const idp = getIdpUrl(args.idp);
|
|
5120
5129
|
if (!idp)
|
|
5121
5130
|
throw new Error("No IdP URL configured. Run `apes login` first or pass --idp.");
|
|
@@ -5123,7 +5132,7 @@ async function runAdapterMode(command, rawArgs, args) {
|
|
|
5123
5132
|
await runAudienceMode("escapes", command.join(" "), args, command);
|
|
5124
5133
|
return;
|
|
5125
5134
|
}
|
|
5126
|
-
const adapterOpt = extractOption(
|
|
5135
|
+
const adapterOpt = extractOption(rawArgs2, "adapter");
|
|
5127
5136
|
const cliId = command[0];
|
|
5128
5137
|
let resolved;
|
|
5129
5138
|
try {
|
|
@@ -5497,8 +5506,8 @@ var proxyCommand = defineCommand48({
|
|
|
5497
5506
|
required: false
|
|
5498
5507
|
}
|
|
5499
5508
|
},
|
|
5500
|
-
async run({ rawArgs }) {
|
|
5501
|
-
const wrapped = extractWrappedCommand(
|
|
5509
|
+
async run({ rawArgs: rawArgs2 }) {
|
|
5510
|
+
const wrapped = extractWrappedCommand(rawArgs2 ?? []);
|
|
5502
5511
|
if (wrapped.length === 0) {
|
|
5503
5512
|
throw new CliError("Usage: apes proxy -- <cmd> [args...]");
|
|
5504
5513
|
}
|
|
@@ -5603,11 +5612,11 @@ var explainCommand = defineCommand49({
|
|
|
5603
5612
|
required: false
|
|
5604
5613
|
}
|
|
5605
5614
|
},
|
|
5606
|
-
async run({ rawArgs }) {
|
|
5607
|
-
const command = extractWrappedCommand(
|
|
5615
|
+
async run({ rawArgs: rawArgs2 }) {
|
|
5616
|
+
const command = extractWrappedCommand(rawArgs2 ?? []);
|
|
5608
5617
|
if (command.length === 0)
|
|
5609
5618
|
throw new Error("Missing wrapped command. Usage: apes explain [--adapter <file>] -- <cli> ...");
|
|
5610
|
-
const adapterOpt = extractOption(
|
|
5619
|
+
const adapterOpt = extractOption(rawArgs2 ?? [], "adapter");
|
|
5611
5620
|
const loaded = loadAdapter(command[0], adapterOpt);
|
|
5612
5621
|
const resolved = await resolveCommand(loaded, command);
|
|
5613
5622
|
process.stdout.write(`${JSON.stringify({
|
|
@@ -5853,7 +5862,7 @@ var mcpCommand = defineCommand53({
|
|
|
5853
5862
|
if (transport !== "stdio" && transport !== "sse") {
|
|
5854
5863
|
throw new Error('Transport must be "stdio" or "sse"');
|
|
5855
5864
|
}
|
|
5856
|
-
const { startMcpServer } = await import("./server-
|
|
5865
|
+
const { startMcpServer } = await import("./server-EDPNSY35.js");
|
|
5857
5866
|
await startMcpServer(transport, port);
|
|
5858
5867
|
}
|
|
5859
5868
|
});
|
|
@@ -6491,7 +6500,7 @@ async function bestEffortGrantCount(idp) {
|
|
|
6491
6500
|
}
|
|
6492
6501
|
}
|
|
6493
6502
|
async function runHealth(args) {
|
|
6494
|
-
const version = true ? "1.31.
|
|
6503
|
+
const version = true ? "1.31.5" : "0.0.0";
|
|
6495
6504
|
const auth = loadAuth();
|
|
6496
6505
|
if (!auth) {
|
|
6497
6506
|
throw new CliError("Not logged in. Run `apes login` first.", 1);
|
|
@@ -6764,10 +6773,10 @@ if (shellRewrite) {
|
|
|
6764
6773
|
if (shellRewrite.action === "rewrite") {
|
|
6765
6774
|
process.argv = shellRewrite.argv;
|
|
6766
6775
|
} else if (shellRewrite.action === "version") {
|
|
6767
|
-
console.log(`ape-shell ${"1.31.
|
|
6776
|
+
console.log(`ape-shell ${"1.31.5"} (OpenApe DDISA shell wrapper)`);
|
|
6768
6777
|
process.exit(0);
|
|
6769
6778
|
} else if (shellRewrite.action === "help") {
|
|
6770
|
-
console.log(`ape-shell ${"1.31.
|
|
6779
|
+
console.log(`ape-shell ${"1.31.5"} \u2014 OpenApe DDISA shell wrapper`);
|
|
6771
6780
|
console.log("");
|
|
6772
6781
|
console.log("Usage:");
|
|
6773
6782
|
console.log(" ape-shell Start interactive grant-mediated REPL");
|
|
@@ -6826,7 +6835,7 @@ var configCommand = defineCommand65({
|
|
|
6826
6835
|
var main = defineCommand65({
|
|
6827
6836
|
meta: {
|
|
6828
6837
|
name: "apes",
|
|
6829
|
-
version: "1.31.
|
|
6838
|
+
version: "1.31.5",
|
|
6830
6839
|
description: "Unified CLI for OpenApe"
|
|
6831
6840
|
},
|
|
6832
6841
|
subCommands: {
|
|
@@ -6884,9 +6893,9 @@ async function maybeRefreshAuth() {
|
|
|
6884
6893
|
}
|
|
6885
6894
|
}
|
|
6886
6895
|
await maybeRefreshAuth();
|
|
6887
|
-
await maybeWarnStaleVersion("1.31.
|
|
6896
|
+
await maybeWarnStaleVersion("1.31.5").catch(() => {
|
|
6888
6897
|
});
|
|
6889
|
-
|
|
6898
|
+
function handleCliError(err) {
|
|
6890
6899
|
if (err instanceof CliExit) {
|
|
6891
6900
|
process.exit(err.exitCode);
|
|
6892
6901
|
}
|
|
@@ -6900,5 +6909,21 @@ runMain(main).catch((err) => {
|
|
|
6900
6909
|
consola54.error(err instanceof ApiError ? err.message : err instanceof Error ? err.message : String(err));
|
|
6901
6910
|
}
|
|
6902
6911
|
process.exit(1);
|
|
6903
|
-
}
|
|
6912
|
+
}
|
|
6913
|
+
var rawArgs = process.argv.slice(2);
|
|
6914
|
+
var dashDash = rawArgs.indexOf("--");
|
|
6915
|
+
var flagScan = dashDash === -1 ? rawArgs : rawArgs.slice(0, dashDash);
|
|
6916
|
+
var wantsBuiltin = rawArgs.length === 0 || flagScan.some((a) => a === "-h" || a === "--help" || a === "-v" || a === "--version");
|
|
6917
|
+
if (wantsBuiltin) {
|
|
6918
|
+
runMain(main).catch(handleCliError);
|
|
6919
|
+
} else {
|
|
6920
|
+
runCittyCommand(main, { rawArgs }).catch((err) => {
|
|
6921
|
+
const code = err?.code;
|
|
6922
|
+
if (typeof code === "string" && code.startsWith("E_")) {
|
|
6923
|
+
runMain(main).catch(handleCliError);
|
|
6924
|
+
return;
|
|
6925
|
+
}
|
|
6926
|
+
handleCliError(err);
|
|
6927
|
+
});
|
|
6928
|
+
}
|
|
6904
6929
|
//# sourceMappingURL=cli.js.map
|