@robinmordasiewicz/f5xc-xcsh 6.43.0 → 6.44.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/index.js +152 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -45354,8 +45354,8 @@ function getLogoModeFromEnv(envPrefix) {
|
|
|
45354
45354
|
var CLI_NAME = "xcsh";
|
|
45355
45355
|
var CLI_FULL_NAME = "F5 Distributed Cloud Shell";
|
|
45356
45356
|
function getVersion() {
|
|
45357
|
-
if ("6.
|
|
45358
|
-
return "6.
|
|
45357
|
+
if ("6.44.0") {
|
|
45358
|
+
return "6.44.0";
|
|
45359
45359
|
}
|
|
45360
45360
|
if (process.env.XCSH_VERSION) {
|
|
45361
45361
|
return process.env.XCSH_VERSION;
|
|
@@ -46819,6 +46819,135 @@ function getCommandSpec(commandPath) {
|
|
|
46819
46819
|
return void 0;
|
|
46820
46820
|
}
|
|
46821
46821
|
|
|
46822
|
+
// src/debug/protocol.ts
|
|
46823
|
+
function getDebugFormat() {
|
|
46824
|
+
const envValue = process.env[`${ENV_PREFIX}_DEBUG_EVENTS`];
|
|
46825
|
+
if (envValue === "jsonl" || envValue === "human") {
|
|
46826
|
+
return envValue;
|
|
46827
|
+
}
|
|
46828
|
+
if (process.env[`${ENV_PREFIX}_DEBUG`] === "true") {
|
|
46829
|
+
return "human";
|
|
46830
|
+
}
|
|
46831
|
+
return "none";
|
|
46832
|
+
}
|
|
46833
|
+
var DebugProtocolImpl = class {
|
|
46834
|
+
format;
|
|
46835
|
+
events = [];
|
|
46836
|
+
startTime;
|
|
46837
|
+
constructor() {
|
|
46838
|
+
this.format = getDebugFormat();
|
|
46839
|
+
this.startTime = Date.now();
|
|
46840
|
+
}
|
|
46841
|
+
/**
|
|
46842
|
+
* Check if debug events are enabled
|
|
46843
|
+
*/
|
|
46844
|
+
isEnabled() {
|
|
46845
|
+
return this.format !== "none";
|
|
46846
|
+
}
|
|
46847
|
+
/**
|
|
46848
|
+
* Check if JSONL format is enabled
|
|
46849
|
+
*/
|
|
46850
|
+
isJsonl() {
|
|
46851
|
+
return this.format === "jsonl";
|
|
46852
|
+
}
|
|
46853
|
+
/**
|
|
46854
|
+
* Emit a debug event
|
|
46855
|
+
*/
|
|
46856
|
+
emit(type, event, data = {}) {
|
|
46857
|
+
if (!this.isEnabled()) return;
|
|
46858
|
+
const entry = {
|
|
46859
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
46860
|
+
type,
|
|
46861
|
+
event,
|
|
46862
|
+
data: {
|
|
46863
|
+
...data,
|
|
46864
|
+
elapsedMs: Date.now() - this.startTime
|
|
46865
|
+
}
|
|
46866
|
+
};
|
|
46867
|
+
this.events.push(entry);
|
|
46868
|
+
if (this.format === "jsonl") {
|
|
46869
|
+
console.error(JSON.stringify(entry));
|
|
46870
|
+
} else if (this.format === "human") {
|
|
46871
|
+
const prefix = `DEBUG [${type}:${event}]`;
|
|
46872
|
+
const dataStr = Object.keys(data).length > 0 ? ` ${JSON.stringify(data)}` : "";
|
|
46873
|
+
console.error(`${prefix}${dataStr}`);
|
|
46874
|
+
}
|
|
46875
|
+
}
|
|
46876
|
+
/**
|
|
46877
|
+
* Emit session-related event
|
|
46878
|
+
*/
|
|
46879
|
+
session(event, data = {}) {
|
|
46880
|
+
this.emit("session", event, data);
|
|
46881
|
+
}
|
|
46882
|
+
/**
|
|
46883
|
+
* Emit API-related event
|
|
46884
|
+
*/
|
|
46885
|
+
api(event, data = {}) {
|
|
46886
|
+
this.emit("api", event, data);
|
|
46887
|
+
}
|
|
46888
|
+
/**
|
|
46889
|
+
* Emit authentication-related event
|
|
46890
|
+
*/
|
|
46891
|
+
auth(event, data = {}) {
|
|
46892
|
+
this.emit("auth", event, data);
|
|
46893
|
+
}
|
|
46894
|
+
/**
|
|
46895
|
+
* Emit profile-related event
|
|
46896
|
+
*/
|
|
46897
|
+
profile(event, data = {}) {
|
|
46898
|
+
this.emit("profile", event, data);
|
|
46899
|
+
}
|
|
46900
|
+
/**
|
|
46901
|
+
* Emit UI-related event
|
|
46902
|
+
*/
|
|
46903
|
+
ui(event, data = {}) {
|
|
46904
|
+
this.emit("ui", event, data);
|
|
46905
|
+
}
|
|
46906
|
+
/**
|
|
46907
|
+
* Emit error event
|
|
46908
|
+
*/
|
|
46909
|
+
error(event, error, data = {}) {
|
|
46910
|
+
this.emit("error", event, {
|
|
46911
|
+
...data,
|
|
46912
|
+
error: error instanceof Error ? error.message : String(error),
|
|
46913
|
+
stack: error instanceof Error ? error.stack : void 0
|
|
46914
|
+
});
|
|
46915
|
+
}
|
|
46916
|
+
/**
|
|
46917
|
+
* Get all captured events
|
|
46918
|
+
*/
|
|
46919
|
+
getEvents() {
|
|
46920
|
+
return [...this.events];
|
|
46921
|
+
}
|
|
46922
|
+
/**
|
|
46923
|
+
* Dump session state on exit (for --dump-state-on-exit)
|
|
46924
|
+
*/
|
|
46925
|
+
dumpState(state) {
|
|
46926
|
+
if (!this.isEnabled()) return;
|
|
46927
|
+
console.error("\n=== Session State Dump ===");
|
|
46928
|
+
console.error(JSON.stringify(state, null, 2));
|
|
46929
|
+
console.error("=== End Session State ===\n");
|
|
46930
|
+
}
|
|
46931
|
+
};
|
|
46932
|
+
var debugProtocol = new DebugProtocolImpl();
|
|
46933
|
+
function emitSessionState(session) {
|
|
46934
|
+
debugProtocol.auth("session_state", {
|
|
46935
|
+
isAuthenticated: session.isAuthenticated(),
|
|
46936
|
+
isTokenValidated: session.isTokenValidated(),
|
|
46937
|
+
validationError: session.getValidationError(),
|
|
46938
|
+
serverUrl: session.getServerUrl(),
|
|
46939
|
+
activeProfile: session.getActiveProfileName(),
|
|
46940
|
+
hasApiClient: session.getAPIClient() !== null
|
|
46941
|
+
});
|
|
46942
|
+
const showsWarning = session.isAuthenticated() && !session.isTokenValidated() && session.getValidationError();
|
|
46943
|
+
debugProtocol.auth("warning_check", {
|
|
46944
|
+
shouldShowWarning: !!showsWarning,
|
|
46945
|
+
isAuthenticated: session.isAuthenticated(),
|
|
46946
|
+
isTokenValidated: session.isTokenValidated(),
|
|
46947
|
+
hasValidationError: !!session.getValidationError()
|
|
46948
|
+
});
|
|
46949
|
+
}
|
|
46950
|
+
|
|
46822
46951
|
// src/repl/session.ts
|
|
46823
46952
|
var NAMESPACE_CACHE_TTL = 5 * 60 * 1e3;
|
|
46824
46953
|
var REPLSession = class {
|
|
@@ -46877,9 +47006,19 @@ var REPLSession = class {
|
|
|
46877
47006
|
}
|
|
46878
47007
|
await this.loadActiveProfile();
|
|
46879
47008
|
if (this._apiClient?.isAuthenticated()) {
|
|
47009
|
+
debugProtocol.auth("token_validation_start", {
|
|
47010
|
+
serverUrl: this._serverUrl,
|
|
47011
|
+
hasApiClient: true
|
|
47012
|
+
});
|
|
46880
47013
|
const result = await this._apiClient.validateToken();
|
|
46881
47014
|
this._tokenValidated = result.valid;
|
|
46882
47015
|
this._validationError = result.error ?? null;
|
|
47016
|
+
debugProtocol.auth("token_validation_complete", {
|
|
47017
|
+
valid: result.valid,
|
|
47018
|
+
error: result.error,
|
|
47019
|
+
tokenValidated: this._tokenValidated,
|
|
47020
|
+
validationError: this._validationError
|
|
47021
|
+
});
|
|
46883
47022
|
if (result.valid) {
|
|
46884
47023
|
await this.fetchUserInfo();
|
|
46885
47024
|
}
|
|
@@ -46941,7 +47080,10 @@ var REPLSession = class {
|
|
|
46941
47080
|
}
|
|
46942
47081
|
}
|
|
46943
47082
|
}
|
|
46944
|
-
} catch {
|
|
47083
|
+
} catch (error) {
|
|
47084
|
+
debugProtocol.error("profile_load_failed", error, {
|
|
47085
|
+
activeProfile: this._activeProfileName
|
|
47086
|
+
});
|
|
46945
47087
|
}
|
|
46946
47088
|
}
|
|
46947
47089
|
/**
|
|
@@ -53201,6 +53343,8 @@ program2.name(CLI_NAME).description("F5 Distributed Cloud Shell - Interactive CL
|
|
|
53201
53343
|
process.stdout.write("Initializing...");
|
|
53202
53344
|
const session = new REPLSession();
|
|
53203
53345
|
await session.initialize();
|
|
53346
|
+
debugProtocol.session("init", { mode: "repl" });
|
|
53347
|
+
emitSessionState(session);
|
|
53204
53348
|
process.stdout.write("\r\x1B[K");
|
|
53205
53349
|
renderBanner(cliLogoMode, "startup");
|
|
53206
53350
|
if (session.isAuthenticated() && !session.isTokenValidated() && session.getValidationError()) {
|
|
@@ -53246,6 +53390,11 @@ program2.name(CLI_NAME).description("F5 Distributed Cloud Shell - Interactive CL
|
|
|
53246
53390
|
async function executeNonInteractive(args) {
|
|
53247
53391
|
const session = new REPLSession();
|
|
53248
53392
|
await session.initialize();
|
|
53393
|
+
debugProtocol.session("init", {
|
|
53394
|
+
mode: "non-interactive",
|
|
53395
|
+
command: args.join(" ")
|
|
53396
|
+
});
|
|
53397
|
+
emitSessionState(session);
|
|
53249
53398
|
if (session.isAuthenticated() && !session.isTokenValidated() && session.getValidationError()) {
|
|
53250
53399
|
console.error(
|
|
53251
53400
|
`${colors.yellow}Warning: ${session.getValidationError()}${colors.reset}`
|