@openape/apes 0.15.2 → 0.16.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
@@ -61,7 +61,7 @@ import {
61
61
  } from "./chunk-6GPSKAMU.js";
62
62
 
63
63
  // src/cli.ts
64
- import consola32 from "consola";
64
+ import consola33 from "consola";
65
65
 
66
66
  // src/ape-shell.ts
67
67
  import path from "path";
@@ -91,7 +91,7 @@ function rewriteApeShellArgs(argv, argv0) {
91
91
  }
92
92
 
93
93
  // src/cli.ts
94
- import { defineCommand as defineCommand39, runMain } from "citty";
94
+ import { defineCommand as defineCommand41, runMain } from "citty";
95
95
 
96
96
  // src/commands/auth/login.ts
97
97
  import { Buffer } from "buffer";
@@ -3651,7 +3651,7 @@ var mcpCommand = defineCommand32({
3651
3651
  if (transport !== "stdio" && transport !== "sse") {
3652
3652
  throw new Error('Transport must be "stdio" or "sse"');
3653
3653
  }
3654
- const { startMcpServer } = await import("./server-25QMTVUR.js");
3654
+ const { startMcpServer } = await import("./server-NZMLYPN4.js");
3655
3655
  await startMcpServer(transport, port);
3656
3656
  }
3657
3657
  });
@@ -4002,11 +4002,131 @@ var registerUserCommand = defineCommand35({
4002
4002
  }
4003
4003
  });
4004
4004
 
4005
- // src/commands/dns-check.ts
4005
+ // src/commands/utils/index.ts
4006
+ import { defineCommand as defineCommand37 } from "citty";
4007
+
4008
+ // src/commands/utils/dig.ts
4006
4009
  import { defineCommand as defineCommand36 } from "citty";
4007
4010
  import consola30 from "consola";
4008
4011
  import { resolveDDISA as resolveDDISA2 } from "@openape/core";
4009
- var dnsCheckCommand = defineCommand36({
4012
+ var digCommand = defineCommand36({
4013
+ meta: {
4014
+ name: "dig",
4015
+ description: "Resolve DDISA IdP for a domain or email (admin/diag tool)"
4016
+ },
4017
+ args: {
4018
+ target: {
4019
+ type: "positional",
4020
+ description: "Domain (example.com) or email (alice@example.com)",
4021
+ required: true
4022
+ },
4023
+ json: {
4024
+ type: "boolean",
4025
+ description: "Machine-readable JSON output"
4026
+ }
4027
+ },
4028
+ async run({ args }) {
4029
+ const raw = String(args.target).trim();
4030
+ const at = raw.indexOf("@");
4031
+ const domain = at >= 0 ? raw.slice(at + 1) : raw;
4032
+ const localPart = at >= 0 ? raw.slice(0, at) : null;
4033
+ if (!domain || !/^[a-z0-9.-]+\.[a-z]{2,}$/i.test(domain)) {
4034
+ throw new CliError(`Invalid domain: ${domain}`);
4035
+ }
4036
+ const result = {
4037
+ input: raw,
4038
+ domain,
4039
+ localPart,
4040
+ ddisa: { found: false }
4041
+ };
4042
+ const ddisa = await resolveDDISA2(domain);
4043
+ if (ddisa) {
4044
+ result.ddisa = {
4045
+ found: true,
4046
+ idp: ddisa.idp,
4047
+ version: ddisa.version,
4048
+ mode: ddisa.mode,
4049
+ priority: ddisa.priority
4050
+ };
4051
+ try {
4052
+ const resp = await fetch(`${ddisa.idp}/.well-known/openid-configuration`);
4053
+ if (resp.ok) {
4054
+ const disco = await resp.json();
4055
+ result.idpDiscovery = {
4056
+ ok: true,
4057
+ status: resp.status,
4058
+ issuer: typeof disco.issuer === "string" ? disco.issuer : void 0,
4059
+ ddisaVersion: typeof disco.ddisa_version === "string" ? disco.ddisa_version : void 0,
4060
+ authMethods: Array.isArray(disco.ddisa_auth_methods_supported) ? disco.ddisa_auth_methods_supported : void 0,
4061
+ grantTypes: Array.isArray(disco.openape_grant_types_supported) ? disco.openape_grant_types_supported : void 0
4062
+ };
4063
+ } else {
4064
+ result.idpDiscovery = { ok: false, status: resp.status };
4065
+ }
4066
+ } catch (err) {
4067
+ result.idpDiscovery = { ok: false };
4068
+ result.hint = `IdP at ${ddisa.idp} unreachable: ${err instanceof Error ? err.message : String(err)}`;
4069
+ }
4070
+ } else {
4071
+ result.hint = `No DDISA record. Add a TXT record:
4072
+ _ddisa.${domain} TXT "v=ddisa1 idp=https://id.${domain}; mode=open"`;
4073
+ }
4074
+ if (args.json) {
4075
+ process.stdout.write(`${JSON.stringify(result, null, 2)}
4076
+ `);
4077
+ if (!result.ddisa.found || result.idpDiscovery?.ok === false) process.exit(1);
4078
+ return;
4079
+ }
4080
+ console.log(`Target: ${raw}`);
4081
+ if (localPart) console.log(` user: ${localPart}`);
4082
+ console.log(` domain: ${domain}`);
4083
+ console.log("");
4084
+ if (!result.ddisa.found) {
4085
+ consola30.warn(`No DDISA record at _ddisa.${domain}`);
4086
+ if (result.hint) console.log(`
4087
+ ${result.hint}`);
4088
+ throw new CliError(`No DDISA record found for ${domain}`);
4089
+ }
4090
+ consola30.success(`_ddisa.${domain} \u2192 ${result.ddisa.idp}`);
4091
+ console.log(` Version: ${result.ddisa.version || "ddisa1"}`);
4092
+ console.log(` IdP URL: ${result.ddisa.idp}`);
4093
+ if (result.ddisa.mode) console.log(` Mode: ${result.ddisa.mode}`);
4094
+ if (result.ddisa.priority !== void 0) console.log(` Priority: ${result.ddisa.priority}`);
4095
+ console.log("");
4096
+ if (!result.idpDiscovery) {
4097
+ return;
4098
+ }
4099
+ if (result.idpDiscovery.ok) {
4100
+ consola30.success(`IdP reachable (${result.idpDiscovery.status ?? 200})`);
4101
+ if (result.idpDiscovery.issuer) console.log(` Issuer: ${result.idpDiscovery.issuer}`);
4102
+ if (result.idpDiscovery.ddisaVersion) console.log(` DDISA: v${result.idpDiscovery.ddisaVersion}`);
4103
+ if (result.idpDiscovery.authMethods?.length) console.log(` Auth: ${result.idpDiscovery.authMethods.join(", ")}`);
4104
+ if (result.idpDiscovery.grantTypes?.length) console.log(` Grants: ${result.idpDiscovery.grantTypes.join(", ")}`);
4105
+ } else {
4106
+ consola30.warn(`IdP discovery failed${result.idpDiscovery.status ? ` (HTTP ${result.idpDiscovery.status})` : ""}`);
4107
+ if (result.hint) console.log(`
4108
+ ${result.hint}`);
4109
+ throw new CliError(`IdP at ${result.ddisa.idp} not reachable`);
4110
+ }
4111
+ }
4112
+ });
4113
+
4114
+ // src/commands/utils/index.ts
4115
+ var utilsCommand = defineCommand37({
4116
+ meta: {
4117
+ name: "utils",
4118
+ description: "Admin/diagnostic utilities (dig, \u2026)"
4119
+ },
4120
+ subCommands: {
4121
+ dig: digCommand
4122
+ }
4123
+ });
4124
+
4125
+ // src/commands/dns-check.ts
4126
+ import { defineCommand as defineCommand38 } from "citty";
4127
+ import consola31 from "consola";
4128
+ import { resolveDDISA as resolveDDISA3 } from "@openape/core";
4129
+ var dnsCheckCommand = defineCommand38({
4010
4130
  meta: {
4011
4131
  name: "dns-check",
4012
4132
  description: "Validate DDISA DNS TXT records for a domain"
@@ -4020,16 +4140,16 @@ var dnsCheckCommand = defineCommand36({
4020
4140
  },
4021
4141
  async run({ args }) {
4022
4142
  const domain = args.domain;
4023
- consola30.start(`Checking _ddisa.${domain}...`);
4143
+ consola31.start(`Checking _ddisa.${domain}...`);
4024
4144
  try {
4025
- const result = await resolveDDISA2(domain);
4145
+ const result = await resolveDDISA3(domain);
4026
4146
  if (!result) {
4027
4147
  console.log("");
4028
4148
  console.log("To set up DDISA, add a DNS TXT record:");
4029
4149
  console.log(` _ddisa.${domain} TXT "v=ddisa1 idp=https://id.${domain}"`);
4030
4150
  throw new CliError(`No DDISA record found for ${domain}`);
4031
4151
  }
4032
- consola30.success(`_ddisa.${domain} \u2192 ${result.idp}`);
4152
+ consola31.success(`_ddisa.${domain} \u2192 ${result.idp}`);
4033
4153
  console.log("");
4034
4154
  console.log(` Version: ${result.version || "ddisa1"}`);
4035
4155
  console.log(` IdP URL: ${result.idp}`);
@@ -4038,14 +4158,14 @@ var dnsCheckCommand = defineCommand36({
4038
4158
  if (result.priority !== void 0)
4039
4159
  console.log(` Priority: ${result.priority}`);
4040
4160
  console.log("");
4041
- consola30.start(`Verifying IdP at ${result.idp}...`);
4161
+ consola31.start(`Verifying IdP at ${result.idp}...`);
4042
4162
  const discoResp = await fetch(`${result.idp}/.well-known/openid-configuration`);
4043
4163
  if (!discoResp.ok) {
4044
- consola30.warn(`IdP discovery failed (${discoResp.status}). Is the IdP running at ${result.idp}?`);
4164
+ consola31.warn(`IdP discovery failed (${discoResp.status}). Is the IdP running at ${result.idp}?`);
4045
4165
  return;
4046
4166
  }
4047
4167
  const disco = await discoResp.json();
4048
- consola30.success(`IdP is reachable`);
4168
+ consola31.success(`IdP is reachable`);
4049
4169
  console.log(` Issuer: ${disco.issuer}`);
4050
4170
  console.log(` DDISA: v${disco.ddisa_version || "?"}`);
4051
4171
  if (disco.ddisa_auth_methods_supported) {
@@ -4063,7 +4183,7 @@ var dnsCheckCommand = defineCommand36({
4063
4183
  // src/commands/health.ts
4064
4184
  import { exec } from "child_process";
4065
4185
  import { promisify } from "util";
4066
- import { defineCommand as defineCommand37 } from "citty";
4186
+ import { defineCommand as defineCommand39 } from "citty";
4067
4187
  var execAsync = promisify(exec);
4068
4188
  async function resolveApeShellPath() {
4069
4189
  try {
@@ -4099,7 +4219,7 @@ async function bestEffortGrantCount(idp) {
4099
4219
  }
4100
4220
  }
4101
4221
  async function runHealth(args) {
4102
- const version = true ? "0.15.2" : "0.0.0";
4222
+ const version = true ? "0.16.0" : "0.0.0";
4103
4223
  const auth = loadAuth();
4104
4224
  if (!auth) {
4105
4225
  throw new CliError("Not logged in. Run `apes login` first.", 1);
@@ -4162,7 +4282,7 @@ async function runHealth(args) {
4162
4282
  throw new CliError(`IdP ${auth.idp} unreachable: ${idpProbe.error}`, 1);
4163
4283
  }
4164
4284
  }
4165
- var healthCommand = defineCommand37({
4285
+ var healthCommand = defineCommand39({
4166
4286
  meta: {
4167
4287
  name: "health",
4168
4288
  description: "Report CLI diagnostic state (auth, IdP, grants, binaries)"
@@ -4180,8 +4300,8 @@ var healthCommand = defineCommand37({
4180
4300
  });
4181
4301
 
4182
4302
  // src/commands/workflows.ts
4183
- import { defineCommand as defineCommand38 } from "citty";
4184
- import consola31 from "consola";
4303
+ import { defineCommand as defineCommand40 } from "citty";
4304
+ import consola32 from "consola";
4185
4305
 
4186
4306
  // src/guides/index.ts
4187
4307
  var guides = [
@@ -4231,7 +4351,7 @@ var guides = [
4231
4351
  ];
4232
4352
 
4233
4353
  // src/commands/workflows.ts
4234
- var workflowsCommand = defineCommand38({
4354
+ var workflowsCommand = defineCommand40({
4235
4355
  meta: {
4236
4356
  name: "workflows",
4237
4357
  description: "Discover workflow guides"
@@ -4252,7 +4372,7 @@ var workflowsCommand = defineCommand38({
4252
4372
  if (args.id) {
4253
4373
  const guide = guides.find((g) => g.id === String(args.id));
4254
4374
  if (!guide) {
4255
- consola31.info(`Available: ${guides.map((g) => g.id).join(", ")}`);
4375
+ consola32.info(`Available: ${guides.map((g) => g.id).join(", ")}`);
4256
4376
  throw new CliError(`Guide not found: ${args.id}`);
4257
4377
  }
4258
4378
  if (args.json) {
@@ -4301,10 +4421,10 @@ if (shellRewrite) {
4301
4421
  if (shellRewrite.action === "rewrite") {
4302
4422
  process.argv = shellRewrite.argv;
4303
4423
  } else if (shellRewrite.action === "version") {
4304
- console.log(`ape-shell ${"0.15.2"} (OpenApe DDISA shell wrapper)`);
4424
+ console.log(`ape-shell ${"0.16.0"} (OpenApe DDISA shell wrapper)`);
4305
4425
  process.exit(0);
4306
4426
  } else if (shellRewrite.action === "help") {
4307
- console.log(`ape-shell ${"0.15.2"} \u2014 OpenApe DDISA shell wrapper`);
4427
+ console.log(`ape-shell ${"0.16.0"} \u2014 OpenApe DDISA shell wrapper`);
4308
4428
  console.log("");
4309
4429
  console.log("Usage:");
4310
4430
  console.log(" ape-shell Start interactive grant-mediated REPL");
@@ -4328,7 +4448,7 @@ if (shellRewrite) {
4328
4448
  }
4329
4449
  }
4330
4450
  var debug = process.argv.includes("--debug");
4331
- var grantsCommand = defineCommand39({
4451
+ var grantsCommand = defineCommand41({
4332
4452
  meta: {
4333
4453
  name: "grants",
4334
4454
  description: "Grant management"
@@ -4349,7 +4469,7 @@ var grantsCommand = defineCommand39({
4349
4469
  "delegation-revoke": delegationRevokeCommand
4350
4470
  }
4351
4471
  });
4352
- var configCommand = defineCommand39({
4472
+ var configCommand = defineCommand41({
4353
4473
  meta: {
4354
4474
  name: "config",
4355
4475
  description: "Configuration management"
@@ -4359,10 +4479,10 @@ var configCommand = defineCommand39({
4359
4479
  set: configSetCommand
4360
4480
  }
4361
4481
  });
4362
- var main = defineCommand39({
4482
+ var main = defineCommand41({
4363
4483
  meta: {
4364
4484
  name: "apes",
4365
- version: "0.15.2",
4485
+ version: "0.16.0",
4366
4486
  description: "Unified CLI for OpenApe"
4367
4487
  },
4368
4488
  subCommands: {
@@ -4370,6 +4490,7 @@ var main = defineCommand39({
4370
4490
  enroll: enrollCommand,
4371
4491
  "register-user": registerUserCommand,
4372
4492
  "dns-check": dnsCheckCommand,
4493
+ utils: utilsCommand,
4373
4494
  login: loginCommand,
4374
4495
  logout: logoutCommand,
4375
4496
  whoami: whoamiCommand,
@@ -4392,13 +4513,13 @@ runMain(main).catch((err) => {
4392
4513
  process.exit(err.exitCode);
4393
4514
  }
4394
4515
  if (err instanceof CliError) {
4395
- consola32.error(err.message);
4516
+ consola33.error(err.message);
4396
4517
  process.exit(err.exitCode);
4397
4518
  }
4398
4519
  if (debug) {
4399
- consola32.error(err);
4520
+ consola33.error(err);
4400
4521
  } else {
4401
- consola32.error(err instanceof ApiError ? err.message : err instanceof Error ? err.message : String(err));
4522
+ consola33.error(err instanceof ApiError ? err.message : err instanceof Error ? err.message : String(err));
4402
4523
  }
4403
4524
  process.exit(1);
4404
4525
  });