@openape/apes 0.7.2 → 0.8.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/{auth-lock-SRUFWJC3.js → auth-lock-6U2G75S6.js} +2 -2
- package/dist/{chunk-TBYYREL6.js → chunk-AZVY3X7Q.js} +13 -1
- package/dist/chunk-AZVY3X7Q.js.map +1 -0
- package/dist/{chunk-B32ZQP5K.js → chunk-HGCKOCJA.js} +13 -6
- package/dist/chunk-HGCKOCJA.js.map +1 -0
- package/dist/chunk-LSKHTHUY.js +50 -0
- package/dist/chunk-LSKHTHUY.js.map +1 -0
- package/dist/cli.js +152 -13
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +9 -0
- package/dist/index.js +2 -2
- package/dist/{orchestrator-JAMWD6DD.js → orchestrator-FTQW3ZRS.js} +135 -7
- package/dist/orchestrator-FTQW3ZRS.js.map +1 -0
- package/dist/{server-GPETT3ON.js → server-DPNFUTHG.js} +4 -4
- package/package.json +1 -1
- package/dist/chunk-B32ZQP5K.js.map +0 -1
- package/dist/chunk-TBYYREL6.js.map +0 -1
- package/dist/orchestrator-JAMWD6DD.js.map +0 -1
- /package/dist/{auth-lock-SRUFWJC3.js.map → auth-lock-6U2G75S6.js.map} +0 -0
- /package/dist/{server-GPETT3ON.js.map → server-DPNFUTHG.js.map} +0 -0
package/dist/cli.js
CHANGED
|
@@ -8,6 +8,9 @@ import {
|
|
|
8
8
|
loadEd25519PrivateKey,
|
|
9
9
|
readPublicKeyComment
|
|
10
10
|
} from "./chunk-ION3CWD5.js";
|
|
11
|
+
import {
|
|
12
|
+
notifyGrantPending
|
|
13
|
+
} from "./chunk-LSKHTHUY.js";
|
|
11
14
|
import {
|
|
12
15
|
ApiError,
|
|
13
16
|
apiFetch,
|
|
@@ -37,8 +40,10 @@ import {
|
|
|
37
40
|
searchAdapters,
|
|
38
41
|
verifyAndExecute,
|
|
39
42
|
waitForGrantStatus
|
|
40
|
-
} from "./chunk-
|
|
43
|
+
} from "./chunk-HGCKOCJA.js";
|
|
41
44
|
import {
|
|
45
|
+
AUTH_FILE,
|
|
46
|
+
CONFIG_DIR,
|
|
42
47
|
clearAuth,
|
|
43
48
|
getAuthToken,
|
|
44
49
|
getIdpUrl,
|
|
@@ -46,7 +51,7 @@ import {
|
|
|
46
51
|
loadConfig,
|
|
47
52
|
saveAuth,
|
|
48
53
|
saveConfig
|
|
49
|
-
} from "./chunk-
|
|
54
|
+
} from "./chunk-AZVY3X7Q.js";
|
|
50
55
|
|
|
51
56
|
// src/cli.ts
|
|
52
57
|
import consola26 from "consola";
|
|
@@ -79,7 +84,7 @@ function rewriteApeShellArgs(argv, argv0) {
|
|
|
79
84
|
}
|
|
80
85
|
|
|
81
86
|
// src/cli.ts
|
|
82
|
-
import { defineCommand as
|
|
87
|
+
import { defineCommand as defineCommand32, runMain } from "citty";
|
|
83
88
|
|
|
84
89
|
// src/commands/auth/login.ts
|
|
85
90
|
import { Buffer } from "buffer";
|
|
@@ -1929,6 +1934,13 @@ async function runShellMode(command, args) {
|
|
|
1929
1934
|
});
|
|
1930
1935
|
consola18.info(`Grant requested: ${grant.id}`);
|
|
1931
1936
|
consola18.info("Waiting for approval...");
|
|
1937
|
+
notifyGrantPending({
|
|
1938
|
+
grantId: grant.id,
|
|
1939
|
+
approveUrl: `${idp}/grant-approval?grant_id=${grant.id}`,
|
|
1940
|
+
command: command.join(" ").slice(0, 200),
|
|
1941
|
+
audience: "ape-shell",
|
|
1942
|
+
host: targetHost
|
|
1943
|
+
});
|
|
1932
1944
|
const maxWait = 3e5;
|
|
1933
1945
|
const interval = 3e3;
|
|
1934
1946
|
const start = Date.now();
|
|
@@ -1982,6 +1994,13 @@ async function tryAdapterModeFromShell(command, idp, args) {
|
|
|
1982
1994
|
consola18.info("");
|
|
1983
1995
|
consola18.info(` Similar grant(s) found (${n}). Your approver can extend an existing grant to cover this request.`);
|
|
1984
1996
|
}
|
|
1997
|
+
notifyGrantPending({
|
|
1998
|
+
grantId: grant.id,
|
|
1999
|
+
approveUrl: `${idp}/grant-approval?grant_id=${grant.id}`,
|
|
2000
|
+
command: resolved.detail?.display || parsed?.raw || "unknown",
|
|
2001
|
+
audience: resolved.adapter?.cli?.audience ?? "shapes",
|
|
2002
|
+
host: args.host || hostname3()
|
|
2003
|
+
});
|
|
1985
2004
|
const status = await waitForGrantStatus(idp, grant.id);
|
|
1986
2005
|
if (status !== "approved")
|
|
1987
2006
|
throw new CliError(`Grant ${status}`);
|
|
@@ -2385,7 +2404,7 @@ var mcpCommand = defineCommand25({
|
|
|
2385
2404
|
if (transport !== "stdio" && transport !== "sse") {
|
|
2386
2405
|
throw new Error('Transport must be "stdio" or "sse"');
|
|
2387
2406
|
}
|
|
2388
|
-
const { startMcpServer } = await import("./server-
|
|
2407
|
+
const { startMcpServer } = await import("./server-DPNFUTHG.js");
|
|
2389
2408
|
await startMcpServer(transport, port);
|
|
2390
2409
|
}
|
|
2391
2410
|
});
|
|
@@ -2838,8 +2857,127 @@ var dnsCheckCommand = defineCommand29({
|
|
|
2838
2857
|
}
|
|
2839
2858
|
});
|
|
2840
2859
|
|
|
2841
|
-
// src/commands/
|
|
2860
|
+
// src/commands/health.ts
|
|
2861
|
+
import { exec } from "child_process";
|
|
2862
|
+
import { promisify } from "util";
|
|
2842
2863
|
import { defineCommand as defineCommand30 } from "citty";
|
|
2864
|
+
var execAsync = promisify(exec);
|
|
2865
|
+
async function resolveApeShellPath() {
|
|
2866
|
+
try {
|
|
2867
|
+
const { stdout } = await execAsync("command -v ape-shell", { shell: "/bin/bash" });
|
|
2868
|
+
const trimmed = stdout.trim();
|
|
2869
|
+
return trimmed.length > 0 ? trimmed : null;
|
|
2870
|
+
} catch {
|
|
2871
|
+
return null;
|
|
2872
|
+
}
|
|
2873
|
+
}
|
|
2874
|
+
async function probeIdp(url) {
|
|
2875
|
+
const ctrl = new AbortController();
|
|
2876
|
+
const timeout = setTimeout(() => ctrl.abort(), 3e3);
|
|
2877
|
+
try {
|
|
2878
|
+
await fetch(url, { method: "GET", signal: ctrl.signal });
|
|
2879
|
+
return { reachable: true };
|
|
2880
|
+
} catch (err) {
|
|
2881
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
2882
|
+
return { reachable: false, error: message };
|
|
2883
|
+
} finally {
|
|
2884
|
+
clearTimeout(timeout);
|
|
2885
|
+
}
|
|
2886
|
+
}
|
|
2887
|
+
async function bestEffortGrantCount(idp) {
|
|
2888
|
+
try {
|
|
2889
|
+
const grantsUrl = await getGrantsEndpoint(idp);
|
|
2890
|
+
const res = await apiFetch(`${grantsUrl}?limit=1`);
|
|
2891
|
+
const count = Array.isArray(res?.data) ? res.data.length : 0;
|
|
2892
|
+
return { count };
|
|
2893
|
+
} catch (err) {
|
|
2894
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
2895
|
+
return { error: message };
|
|
2896
|
+
}
|
|
2897
|
+
}
|
|
2898
|
+
async function runHealth(args) {
|
|
2899
|
+
const version = true ? "0.8.0" : "0.0.0";
|
|
2900
|
+
const auth = loadAuth();
|
|
2901
|
+
if (!auth) {
|
|
2902
|
+
throw new CliError("Not logged in. Run `apes login` first.", 1);
|
|
2903
|
+
}
|
|
2904
|
+
const isAgent = auth.email.includes("agent+");
|
|
2905
|
+
const expiresDate = new Date(auth.expires_at * 1e3);
|
|
2906
|
+
const isExpired = Date.now() / 1e3 > auth.expires_at;
|
|
2907
|
+
if (isExpired) {
|
|
2908
|
+
throw new CliError(`Token expired at ${expiresDate.toISOString()}. Run \`apes login\`.`, 1);
|
|
2909
|
+
}
|
|
2910
|
+
const idpProbe = await probeIdp(auth.idp);
|
|
2911
|
+
const grantInfo = await bestEffortGrantCount(auth.idp);
|
|
2912
|
+
const apeShellPath = await resolveApeShellPath();
|
|
2913
|
+
const report = {
|
|
2914
|
+
version,
|
|
2915
|
+
config: { dir: CONFIG_DIR },
|
|
2916
|
+
auth: {
|
|
2917
|
+
file: AUTH_FILE,
|
|
2918
|
+
present: true,
|
|
2919
|
+
email: auth.email,
|
|
2920
|
+
type: isAgent ? "agent" : "human",
|
|
2921
|
+
idp: auth.idp,
|
|
2922
|
+
expires_at_iso: expiresDate.toISOString(),
|
|
2923
|
+
expires_at_local: expiresDate.toLocaleString(),
|
|
2924
|
+
expired: false
|
|
2925
|
+
},
|
|
2926
|
+
idp: {
|
|
2927
|
+
url: auth.idp,
|
|
2928
|
+
reachable: idpProbe.reachable,
|
|
2929
|
+
..."error" in idpProbe ? { error: idpProbe.error } : {}
|
|
2930
|
+
},
|
|
2931
|
+
grants: "count" in grantInfo ? { count: grantInfo.count } : { error: grantInfo.error },
|
|
2932
|
+
ape_shell_binary: apeShellPath,
|
|
2933
|
+
ok: idpProbe.reachable
|
|
2934
|
+
};
|
|
2935
|
+
if (args.json) {
|
|
2936
|
+
console.log(JSON.stringify(report, null, 2));
|
|
2937
|
+
} else {
|
|
2938
|
+
console.log(`apes ${version}`);
|
|
2939
|
+
console.log("");
|
|
2940
|
+
console.log(`Config: ${CONFIG_DIR}`);
|
|
2941
|
+
console.log(`Auth: ${AUTH_FILE}`);
|
|
2942
|
+
console.log(` ${auth.email} (${isAgent ? "agent" : "human"})`);
|
|
2943
|
+
console.log(` IdP: ${auth.idp}`);
|
|
2944
|
+
console.log(` Token: valid until ${expiresDate.toISOString()} (local: ${expiresDate.toLocaleString()})`);
|
|
2945
|
+
console.log("");
|
|
2946
|
+
if (idpProbe.reachable) {
|
|
2947
|
+
console.log("IdP: reachable");
|
|
2948
|
+
} else {
|
|
2949
|
+
console.log(`IdP: <unreachable: ${idpProbe.error}>`);
|
|
2950
|
+
}
|
|
2951
|
+
if ("count" in grantInfo) {
|
|
2952
|
+
console.log(`Grants: ${grantInfo.count}`);
|
|
2953
|
+
} else {
|
|
2954
|
+
console.log(`Grants: <unreachable: ${grantInfo.error}>`);
|
|
2955
|
+
}
|
|
2956
|
+
console.log(`ape-shell: ${apeShellPath ?? "(not on PATH)"}`);
|
|
2957
|
+
}
|
|
2958
|
+
if (!idpProbe.reachable) {
|
|
2959
|
+
throw new CliError(`IdP ${auth.idp} unreachable: ${idpProbe.error}`, 1);
|
|
2960
|
+
}
|
|
2961
|
+
}
|
|
2962
|
+
var healthCommand = defineCommand30({
|
|
2963
|
+
meta: {
|
|
2964
|
+
name: "health",
|
|
2965
|
+
description: "Report CLI diagnostic state (auth, IdP, grants, binaries)"
|
|
2966
|
+
},
|
|
2967
|
+
args: {
|
|
2968
|
+
json: {
|
|
2969
|
+
type: "boolean",
|
|
2970
|
+
description: "Emit a machine-readable JSON report",
|
|
2971
|
+
default: false
|
|
2972
|
+
}
|
|
2973
|
+
},
|
|
2974
|
+
async run({ args }) {
|
|
2975
|
+
await runHealth({ json: Boolean(args.json) });
|
|
2976
|
+
}
|
|
2977
|
+
});
|
|
2978
|
+
|
|
2979
|
+
// src/commands/workflows.ts
|
|
2980
|
+
import { defineCommand as defineCommand31 } from "citty";
|
|
2843
2981
|
import consola25 from "consola";
|
|
2844
2982
|
|
|
2845
2983
|
// src/guides/index.ts
|
|
@@ -2890,7 +3028,7 @@ var guides = [
|
|
|
2890
3028
|
];
|
|
2891
3029
|
|
|
2892
3030
|
// src/commands/workflows.ts
|
|
2893
|
-
var workflowsCommand =
|
|
3031
|
+
var workflowsCommand = defineCommand31({
|
|
2894
3032
|
meta: {
|
|
2895
3033
|
name: "workflows",
|
|
2896
3034
|
description: "Discover workflow guides"
|
|
@@ -2960,10 +3098,10 @@ if (shellRewrite) {
|
|
|
2960
3098
|
if (shellRewrite.action === "rewrite") {
|
|
2961
3099
|
process.argv = shellRewrite.argv;
|
|
2962
3100
|
} else if (shellRewrite.action === "version") {
|
|
2963
|
-
console.log(`ape-shell ${"0.
|
|
3101
|
+
console.log(`ape-shell ${"0.8.0"} (OpenApe DDISA shell wrapper)`);
|
|
2964
3102
|
process.exit(0);
|
|
2965
3103
|
} else if (shellRewrite.action === "help") {
|
|
2966
|
-
console.log(`ape-shell ${"0.
|
|
3104
|
+
console.log(`ape-shell ${"0.8.0"} \u2014 OpenApe DDISA shell wrapper`);
|
|
2967
3105
|
console.log("");
|
|
2968
3106
|
console.log("Usage:");
|
|
2969
3107
|
console.log(" ape-shell Start interactive grant-mediated REPL");
|
|
@@ -2978,7 +3116,7 @@ if (shellRewrite) {
|
|
|
2978
3116
|
console.log(" --help, -h Show this help message");
|
|
2979
3117
|
process.exit(0);
|
|
2980
3118
|
} else if (shellRewrite.action === "interactive") {
|
|
2981
|
-
const { runInteractiveShell } = await import("./orchestrator-
|
|
3119
|
+
const { runInteractiveShell } = await import("./orchestrator-FTQW3ZRS.js");
|
|
2982
3120
|
await runInteractiveShell();
|
|
2983
3121
|
process.exit(0);
|
|
2984
3122
|
} else {
|
|
@@ -2987,7 +3125,7 @@ if (shellRewrite) {
|
|
|
2987
3125
|
}
|
|
2988
3126
|
}
|
|
2989
3127
|
var debug = process.argv.includes("--debug");
|
|
2990
|
-
var grantsCommand =
|
|
3128
|
+
var grantsCommand = defineCommand32({
|
|
2991
3129
|
meta: {
|
|
2992
3130
|
name: "grants",
|
|
2993
3131
|
description: "Grant management"
|
|
@@ -3007,7 +3145,7 @@ var grantsCommand = defineCommand31({
|
|
|
3007
3145
|
"delegation-revoke": delegationRevokeCommand
|
|
3008
3146
|
}
|
|
3009
3147
|
});
|
|
3010
|
-
var configCommand =
|
|
3148
|
+
var configCommand = defineCommand32({
|
|
3011
3149
|
meta: {
|
|
3012
3150
|
name: "config",
|
|
3013
3151
|
description: "Configuration management"
|
|
@@ -3017,10 +3155,10 @@ var configCommand = defineCommand31({
|
|
|
3017
3155
|
set: configSetCommand
|
|
3018
3156
|
}
|
|
3019
3157
|
});
|
|
3020
|
-
var main =
|
|
3158
|
+
var main = defineCommand32({
|
|
3021
3159
|
meta: {
|
|
3022
3160
|
name: "apes",
|
|
3023
|
-
version: "0.
|
|
3161
|
+
version: "0.8.0",
|
|
3024
3162
|
description: "Unified CLI for OpenApe"
|
|
3025
3163
|
},
|
|
3026
3164
|
subCommands: {
|
|
@@ -3031,6 +3169,7 @@ var main = defineCommand31({
|
|
|
3031
3169
|
login: loginCommand,
|
|
3032
3170
|
logout: logoutCommand,
|
|
3033
3171
|
whoami: whoamiCommand,
|
|
3172
|
+
health: healthCommand,
|
|
3034
3173
|
grants: grantsCommand,
|
|
3035
3174
|
admin: adminCommand,
|
|
3036
3175
|
run: runCommand,
|