@openape/apes 1.31.3 → 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";
@@ -148,11 +148,6 @@ async function resolveLoginInputs(flags) {
148
148
  consola.info(`Using email from ${keyPath}.pub comment: ${email}`);
149
149
  }
150
150
  }
151
- if (process.env.APES_IDP && process.env.GRAPES_IDP) {
152
- consola.warn(
153
- "Both APES_IDP and GRAPES_IDP are set \u2014 using APES_IDP. GRAPES_IDP is deprecated and will be removed in a future release."
154
- );
155
- }
156
151
  let idp;
157
152
  let idpSource;
158
153
  if (flags.idp) {
@@ -161,12 +156,6 @@ async function resolveLoginInputs(flags) {
161
156
  } else if (process.env.APES_IDP) {
162
157
  idp = process.env.APES_IDP;
163
158
  idpSource = "env";
164
- } else if (process.env.GRAPES_IDP) {
165
- idp = process.env.GRAPES_IDP;
166
- idpSource = "env";
167
- consola.warn(
168
- "GRAPES_IDP is deprecated, use APES_IDP instead. GRAPES_IDP support will be removed in a future release."
169
- );
170
159
  } else if (config.defaults?.idp) {
171
160
  idp = config.defaults.idp;
172
161
  idpSource = "config";
@@ -776,8 +765,8 @@ async function waitForApproval(grantsUrl, grantId) {
776
765
  import { hostname as hostname2 } from "os";
777
766
  import { defineCommand as defineCommand8 } from "citty";
778
767
  import consola8 from "consola";
779
- function parseCapabilityArgs(rawArgs) {
780
- const tokens = [...rawArgs];
768
+ function parseCapabilityArgs(rawArgs2) {
769
+ const tokens = [...rawArgs2];
781
770
  if (tokens[0] === "request-capability") {
782
771
  tokens.shift();
783
772
  }
@@ -949,12 +938,12 @@ var requestCapabilityCommand = defineCommand8({
949
938
  default: false
950
939
  }
951
940
  },
952
- async run({ rawArgs }) {
941
+ async run({ rawArgs: rawArgs2 }) {
953
942
  const auth = loadAuth();
954
943
  if (!auth) {
955
944
  throw new CliError("Not logged in. Run `apes login` first.");
956
945
  }
957
- const parsed = parseCapabilityArgs(rawArgs);
946
+ const parsed = parseCapabilityArgs(rawArgs2);
958
947
  const idp = getIdpUrl(parsed.idp);
959
948
  if (!idp) {
960
949
  throw new CliError("No IdP URL configured. Use --idp or log in first.");
@@ -1910,13 +1899,13 @@ function parseKeyValues(pairs) {
1910
1899
  function missingCapabilities(required, provided) {
1911
1900
  return required.filter((env) => !(env in provided));
1912
1901
  }
1913
- function collectFlag(rawArgs, name) {
1902
+ function collectFlag(rawArgs2, name) {
1914
1903
  const out = [];
1915
1904
  const long = `--${name}`;
1916
- for (let i = 0; i < rawArgs.length; i++) {
1917
- const a = rawArgs[i];
1905
+ for (let i = 0; i < rawArgs2.length; i++) {
1906
+ const a = rawArgs2[i];
1918
1907
  if (a === long) {
1919
- const v = rawArgs[i + 1];
1908
+ const v = rawArgs2[i + 1];
1920
1909
  if (v !== void 0 && !v.startsWith("--")) {
1921
1910
  out.push(v);
1922
1911
  i++;
@@ -1948,11 +1937,11 @@ var deployAgentCommand = defineCommand21({
1948
1937
  "host-id": { type: "string", description: "Target nest host_id (default: first connected)" },
1949
1938
  json: { type: "boolean", description: "Machine-readable output, no prompts" }
1950
1939
  },
1951
- async run({ args, rawArgs }) {
1940
+ async run({ args, rawArgs: rawArgs2 }) {
1952
1941
  const repoRef = args.repo;
1953
1942
  if (!repoRef) throw new CliError("usage: apes agent deploy <repo>@<ref> [--param k=v] [--secret ENV=val]");
1954
- const params = parseKeyValues(collectFlag(rawArgs, "param"));
1955
- const secrets = parseKeyValues(collectFlag(rawArgs, "secret"));
1943
+ const params = parseKeyValues(collectFlag(rawArgs2, "param"));
1944
+ const secrets = parseKeyValues(collectFlag(rawArgs2, "secret"));
1956
1945
  const json = !!args.json;
1957
1946
  const token = (await ensureFreshIdpAuth()).access_token;
1958
1947
  const troop = resolveTroopUrl();
@@ -2857,10 +2846,22 @@ fi
2857
2846
  // src/commands/agents/list.ts
2858
2847
  import { defineCommand as defineCommand27 } from "citty";
2859
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
+ }
2860
2861
  var listAgentsCommand = defineCommand27({
2861
2862
  meta: {
2862
2863
  name: "list",
2863
- description: "List agents owned by the current user, with local OS-user status"
2864
+ description: "List agents owned by the current user (from the IdP); annotated with local OS-user status on a nest host"
2864
2865
  },
2865
2866
  args: {
2866
2867
  json: {
@@ -2883,25 +2884,13 @@ var listAgentsCommand = defineCommand27({
2883
2884
  }
2884
2885
  const all = await apiFetch("/api/my-agents", { idp });
2885
2886
  const filtered = args["include-inactive"] ? all : all.filter((u) => u.isActive !== false);
2886
- const platform = getHostPlatform();
2887
- const osUsers = platform.listAgentUserNames();
2888
- const osStateOf = (agentName) => {
2889
- const u = platform.lookupAgentUser(agentName);
2890
- if (u) return { osUser: true, home: u.homeDir };
2891
- if (osUsers.has(platform.agentUsername(agentName)) || osUsers.has(agentName)) {
2892
- return { osUser: true, home: null };
2893
- }
2894
- return { osUser: false, home: null };
2895
- };
2887
+ const onNest = isLinux();
2888
+ const osStateOf = onNest ? buildOsStateResolver() : null;
2896
2889
  const rows = filtered.map((u) => {
2890
+ const base = { name: u.name, email: u.email, isActive: u.isActive !== false };
2891
+ if (!osStateOf) return base;
2897
2892
  const os = osStateOf(u.name);
2898
- return {
2899
- name: u.name,
2900
- email: u.email,
2901
- isActive: u.isActive !== false,
2902
- osUser: os.osUser,
2903
- home: os.home
2904
- };
2893
+ return { ...base, osUser: os.osUser, home: os.home };
2905
2894
  });
2906
2895
  if (args.json) {
2907
2896
  process.stdout.write(`${JSON.stringify(rows, null, 2)}
@@ -2914,14 +2903,23 @@ var listAgentsCommand = defineCommand27({
2914
2903
  }
2915
2904
  const nameW = Math.max(4, ...rows.map((r) => r.name.length));
2916
2905
  const emailW = Math.max(5, ...rows.map((r) => r.email.length));
2917
- const header = `${"NAME".padEnd(nameW)} ${"EMAIL".padEnd(emailW)} ACTIVE OS-USER HOME`;
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`;
2918
2919
  console.log(header);
2919
2920
  console.log("-".repeat(header.length));
2920
2921
  for (const r of rows) {
2921
- const active = r.isActive ? "\u2713" : "\u2717";
2922
- const os = r.osUser ? "\u2713" : "\u2717";
2923
- const homeCol = r.home ?? "(missing)";
2924
- 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"}`);
2925
2923
  }
2926
2924
  }
2927
2925
  });
@@ -4804,6 +4802,7 @@ function resolveRunAsTarget(runAs) {
4804
4802
  if (!runAs) return runAs;
4805
4803
  if (!AGENT_NAME_REGEX.test(runAs)) return runAs;
4806
4804
  if (runAs.startsWith("openape-agent-")) return runAs;
4805
+ if (!isLinux()) return runAs;
4807
4806
  const platform = getHostPlatform();
4808
4807
  const prefixed = platform.agentUsername(runAs);
4809
4808
  if (platform.readAgentUser(prefixed)) return prefixed;
@@ -4939,8 +4938,8 @@ var runCommand = defineCommand47({
4939
4938
  required: false
4940
4939
  }
4941
4940
  },
4942
- async run({ rawArgs, args }) {
4943
- const wrappedCommand = extractWrappedCommand(rawArgs ?? []);
4941
+ async run({ rawArgs: rawArgs2, args }) {
4942
+ const wrappedCommand = extractWrappedCommand(rawArgs2 ?? []);
4944
4943
  if (wrappedCommand.length > 0 && getUserMode() === "agent") {
4945
4944
  routeDiagnosticsToStderrForWrappedAgentRun();
4946
4945
  }
@@ -4949,9 +4948,9 @@ var runCommand = defineCommand47({
4949
4948
  return;
4950
4949
  }
4951
4950
  if (wrappedCommand.length > 0) {
4952
- await runAdapterMode(wrappedCommand, rawArgs ?? [], args);
4951
+ await runAdapterMode(wrappedCommand, rawArgs2 ?? [], args);
4953
4952
  } else {
4954
- const positionals = extractPositionals(rawArgs ?? []);
4953
+ const positionals = extractPositionals(rawArgs2 ?? []);
4955
4954
  if (positionals.length < 2)
4956
4955
  throw new Error("Usage: apes run -- <cli> <args...> OR apes run <audience> <action>");
4957
4956
  await runAudienceMode(positionals[0], positionals[1], args);
@@ -5104,10 +5103,10 @@ function execShellCommand(command) {
5104
5103
  throw new CliExit(exitCode);
5105
5104
  }
5106
5105
  }
5107
- function extractPositionals(rawArgs) {
5106
+ function extractPositionals(rawArgs2) {
5108
5107
  const positionals = [];
5109
- const delimiter = rawArgs.indexOf("--");
5110
- const args = delimiter >= 0 ? rawArgs.slice(0, delimiter) : rawArgs;
5108
+ const delimiter = rawArgs2.indexOf("--");
5109
+ const args = delimiter >= 0 ? rawArgs2.slice(0, delimiter) : rawArgs2;
5111
5110
  for (let i = 0; i < args.length; i++) {
5112
5111
  const arg = args[i];
5113
5112
  if (arg === "run")
@@ -5125,7 +5124,7 @@ function printGenericWarning(cliId) {
5125
5124
  `);
5126
5125
  process.stderr.write("Generic mode active \u2014 single-use grant will be required.\n");
5127
5126
  }
5128
- async function runAdapterMode(command, rawArgs, args) {
5127
+ async function runAdapterMode(command, rawArgs2, args) {
5129
5128
  const idp = getIdpUrl(args.idp);
5130
5129
  if (!idp)
5131
5130
  throw new Error("No IdP URL configured. Run `apes login` first or pass --idp.");
@@ -5133,7 +5132,7 @@ async function runAdapterMode(command, rawArgs, args) {
5133
5132
  await runAudienceMode("escapes", command.join(" "), args, command);
5134
5133
  return;
5135
5134
  }
5136
- const adapterOpt = extractOption(rawArgs, "adapter");
5135
+ const adapterOpt = extractOption(rawArgs2, "adapter");
5137
5136
  const cliId = command[0];
5138
5137
  let resolved;
5139
5138
  try {
@@ -5507,8 +5506,8 @@ var proxyCommand = defineCommand48({
5507
5506
  required: false
5508
5507
  }
5509
5508
  },
5510
- async run({ rawArgs }) {
5511
- const wrapped = extractWrappedCommand(rawArgs ?? []);
5509
+ async run({ rawArgs: rawArgs2 }) {
5510
+ const wrapped = extractWrappedCommand(rawArgs2 ?? []);
5512
5511
  if (wrapped.length === 0) {
5513
5512
  throw new CliError("Usage: apes proxy -- <cmd> [args...]");
5514
5513
  }
@@ -5613,11 +5612,11 @@ var explainCommand = defineCommand49({
5613
5612
  required: false
5614
5613
  }
5615
5614
  },
5616
- async run({ rawArgs }) {
5617
- const command = extractWrappedCommand(rawArgs ?? []);
5615
+ async run({ rawArgs: rawArgs2 }) {
5616
+ const command = extractWrappedCommand(rawArgs2 ?? []);
5618
5617
  if (command.length === 0)
5619
5618
  throw new Error("Missing wrapped command. Usage: apes explain [--adapter <file>] -- <cli> ...");
5620
- const adapterOpt = extractOption(rawArgs ?? [], "adapter");
5619
+ const adapterOpt = extractOption(rawArgs2 ?? [], "adapter");
5621
5620
  const loaded = loadAdapter(command[0], adapterOpt);
5622
5621
  const resolved = await resolveCommand(loaded, command);
5623
5622
  process.stdout.write(`${JSON.stringify({
@@ -5863,7 +5862,7 @@ var mcpCommand = defineCommand53({
5863
5862
  if (transport !== "stdio" && transport !== "sse") {
5864
5863
  throw new Error('Transport must be "stdio" or "sse"');
5865
5864
  }
5866
- const { startMcpServer } = await import("./server-CELKDGTK.js");
5865
+ const { startMcpServer } = await import("./server-EDPNSY35.js");
5867
5866
  await startMcpServer(transport, port);
5868
5867
  }
5869
5868
  });
@@ -6501,7 +6500,7 @@ async function bestEffortGrantCount(idp) {
6501
6500
  }
6502
6501
  }
6503
6502
  async function runHealth(args) {
6504
- const version = true ? "1.31.3" : "0.0.0";
6503
+ const version = true ? "1.31.5" : "0.0.0";
6505
6504
  const auth = loadAuth();
6506
6505
  if (!auth) {
6507
6506
  throw new CliError("Not logged in. Run `apes login` first.", 1);
@@ -6774,10 +6773,10 @@ if (shellRewrite) {
6774
6773
  if (shellRewrite.action === "rewrite") {
6775
6774
  process.argv = shellRewrite.argv;
6776
6775
  } else if (shellRewrite.action === "version") {
6777
- console.log(`ape-shell ${"1.31.3"} (OpenApe DDISA shell wrapper)`);
6776
+ console.log(`ape-shell ${"1.31.5"} (OpenApe DDISA shell wrapper)`);
6778
6777
  process.exit(0);
6779
6778
  } else if (shellRewrite.action === "help") {
6780
- console.log(`ape-shell ${"1.31.3"} \u2014 OpenApe DDISA shell wrapper`);
6779
+ console.log(`ape-shell ${"1.31.5"} \u2014 OpenApe DDISA shell wrapper`);
6781
6780
  console.log("");
6782
6781
  console.log("Usage:");
6783
6782
  console.log(" ape-shell Start interactive grant-mediated REPL");
@@ -6836,7 +6835,7 @@ var configCommand = defineCommand65({
6836
6835
  var main = defineCommand65({
6837
6836
  meta: {
6838
6837
  name: "apes",
6839
- version: "1.31.3",
6838
+ version: "1.31.5",
6840
6839
  description: "Unified CLI for OpenApe"
6841
6840
  },
6842
6841
  subCommands: {
@@ -6894,9 +6893,9 @@ async function maybeRefreshAuth() {
6894
6893
  }
6895
6894
  }
6896
6895
  await maybeRefreshAuth();
6897
- await maybeWarnStaleVersion("1.31.3").catch(() => {
6896
+ await maybeWarnStaleVersion("1.31.5").catch(() => {
6898
6897
  });
6899
- runMain(main).catch((err) => {
6898
+ function handleCliError(err) {
6900
6899
  if (err instanceof CliExit) {
6901
6900
  process.exit(err.exitCode);
6902
6901
  }
@@ -6910,5 +6909,21 @@ runMain(main).catch((err) => {
6910
6909
  consola54.error(err instanceof ApiError ? err.message : err instanceof Error ? err.message : String(err));
6911
6910
  }
6912
6911
  process.exit(1);
6913
- });
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
+ }
6914
6929
  //# sourceMappingURL=cli.js.map