@ranger-testing/ranger-cli 2.0.5 → 2.0.7
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/build/cli.js +1 -914
- package/build/commands/addEnv.js +1 -1
- package/build/commands/authEncrypt.js +1 -36
- package/build/commands/clean.js +1 -1
- package/build/commands/config.js +1 -93
- package/build/commands/env.js +1 -98
- package/build/commands/feature.js +1 -653
- package/build/commands/hook.js +1 -33
- package/build/commands/hooks/autoPrompt.js +1 -32
- package/build/commands/hooks/disable.js +1 -33
- package/build/commands/hooks/enable.js +1 -58
- package/build/commands/hooks/exitPlanMode.js +1 -35
- package/build/commands/hooks/index.js +1 -12
- package/build/commands/hooks/output.js +1 -71
- package/build/commands/hooks/planReminder.js +1 -46
- package/build/commands/hooks/planStart.js +1 -30
- package/build/commands/hooks/postEdit.js +1 -43
- package/build/commands/hooks/preCompact.js +1 -30
- package/build/commands/hooks/sessionEnd.js +1 -25
- package/build/commands/hooks/sessionStart.js +1 -93
- package/build/commands/hooks/stopHook.js +1 -155
- package/build/commands/index.js +1 -12
- package/build/commands/login.js +1 -26
- package/build/commands/setupCi.js +1 -189
- package/build/commands/skillup.js +1 -80
- package/build/commands/start.js +1 -1
- package/build/commands/status.js +1 -198
- package/build/commands/update.js +1 -182
- package/build/commands/updateEnv.js +1 -1
- package/build/commands/useEnv.js +1 -1
- package/build/commands/utils/activeProfile.js +1 -76
- package/build/commands/utils/browserSessionsApi.js +1 -1
- package/build/commands/utils/claudeConfig.js +1 -73
- package/build/commands/utils/claudePlugin.js +1 -85
- package/build/commands/utils/crypto.js +1 -42
- package/build/commands/utils/desirePathLog.js +1 -139
- package/build/commands/utils/deviceAuth.js +1 -232
- package/build/commands/utils/environment.js +1 -65
- package/build/commands/utils/featureApi.js +1 -371
- package/build/commands/utils/featureReportGenerator.js +1 -204
- package/build/commands/utils/fixWebmDuration.js +1 -0
- package/build/commands/utils/git.js +1 -44
- package/build/commands/utils/keychain.js +1 -1
- package/build/commands/utils/localAgentInstallationsApi.js +1 -1
- package/build/commands/utils/profileMessages.js +1 -8
- package/build/commands/utils/profileSetupBanner.js +1 -167
- package/build/commands/utils/rangerRoot.js +1 -60
- package/build/commands/utils/reportGenerator.js +1 -130
- package/build/commands/utils/retry.js +1 -25
- package/build/commands/utils/sessionCache.js +1 -299
- package/build/commands/utils/settings.js +1 -313
- package/build/commands/utils/skillContent.js +1 -28
- package/build/commands/utils/skills.js +1 -1
- package/build/commands/utils/telemetry.js +1 -254
- package/build/commands/utils/userApi.js +1 -32
- package/build/commands/utils/version.js +1 -62
- package/build/commands/verifyFeature.js +1 -1343
- package/build/commands/verifyInBrowser.js +1 -1
- package/package.json +4 -1
- package/build/cli.js.map +0 -1
- package/build/commands/addEnv.js.map +0 -1
- package/build/commands/authEncrypt.js.map +0 -1
- package/build/commands/clean.js.map +0 -1
- package/build/commands/config.js.map +0 -1
- package/build/commands/env.js.map +0 -1
- package/build/commands/feature.js.map +0 -1
- package/build/commands/hook.js.map +0 -1
- package/build/commands/hooks/autoPrompt.js.map +0 -1
- package/build/commands/hooks/disable.js.map +0 -1
- package/build/commands/hooks/enable.js.map +0 -1
- package/build/commands/hooks/exitPlanMode.js.map +0 -1
- package/build/commands/hooks/index.js.map +0 -1
- package/build/commands/hooks/output.js.map +0 -1
- package/build/commands/hooks/planReminder.js.map +0 -1
- package/build/commands/hooks/planStart.js.map +0 -1
- package/build/commands/hooks/postEdit.js.map +0 -1
- package/build/commands/hooks/preCompact.js.map +0 -1
- package/build/commands/hooks/sessionEnd.js.map +0 -1
- package/build/commands/hooks/sessionStart.js.map +0 -1
- package/build/commands/hooks/stopHook.js.map +0 -1
- package/build/commands/index.js.map +0 -1
- package/build/commands/login.js.map +0 -1
- package/build/commands/setupCi.js.map +0 -1
- package/build/commands/skillup.js.map +0 -1
- package/build/commands/start.js.map +0 -1
- package/build/commands/status.js.map +0 -1
- package/build/commands/update.js.map +0 -1
- package/build/commands/updateEnv.js.map +0 -1
- package/build/commands/useEnv.js.map +0 -1
- package/build/commands/utils/activeProfile.js.map +0 -1
- package/build/commands/utils/browserSessionsApi.js.map +0 -1
- package/build/commands/utils/claudeConfig.js.map +0 -1
- package/build/commands/utils/claudePlugin.js.map +0 -1
- package/build/commands/utils/crypto.js.map +0 -1
- package/build/commands/utils/desirePathLog.js.map +0 -1
- package/build/commands/utils/deviceAuth.js.map +0 -1
- package/build/commands/utils/environment.js.map +0 -1
- package/build/commands/utils/featureApi.js.map +0 -1
- package/build/commands/utils/featureReportGenerator.js.map +0 -1
- package/build/commands/utils/git.js.map +0 -1
- package/build/commands/utils/keychain.js.map +0 -1
- package/build/commands/utils/localAgentInstallationsApi.js.map +0 -1
- package/build/commands/utils/profileMessages.js.map +0 -1
- package/build/commands/utils/profileSetupBanner.js.map +0 -1
- package/build/commands/utils/rangerRoot.js.map +0 -1
- package/build/commands/utils/reportGenerator.js.map +0 -1
- package/build/commands/utils/retry.js.map +0 -1
- package/build/commands/utils/sessionCache.js.map +0 -1
- package/build/commands/utils/settings.js.map +0 -1
- package/build/commands/utils/skillContent.js.map +0 -1
- package/build/commands/utils/skills.js.map +0 -1
- package/build/commands/utils/telemetry.js.map +0 -1
- package/build/commands/utils/userApi.js.map +0 -1
- package/build/commands/utils/version.js.map +0 -1
- package/build/commands/verifyFeature.js.map +0 -1
- package/build/commands/verifyInBrowser.js.map +0 -1
|
@@ -1,254 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { getToken } from './keychain.js';
|
|
3
|
-
import { getApiBaseUrl } from './environment.js';
|
|
4
|
-
import { getCurrentVersion } from './version.js';
|
|
5
|
-
// ---------- TelemetryCollector ----------
|
|
6
|
-
export class TelemetryCollector {
|
|
7
|
-
buffer = [];
|
|
8
|
-
commandId;
|
|
9
|
-
command;
|
|
10
|
-
commandStartTime;
|
|
11
|
-
phaseCounter = 0;
|
|
12
|
-
phaseStartTimes = new Map();
|
|
13
|
-
flushing = null;
|
|
14
|
-
// Shared enrichment fields (computed once)
|
|
15
|
-
cliVersion;
|
|
16
|
-
nodeVersion;
|
|
17
|
-
platform;
|
|
18
|
-
isTty;
|
|
19
|
-
isCI;
|
|
20
|
-
// Context set during command execution
|
|
21
|
-
featureId;
|
|
22
|
-
checklistItemId;
|
|
23
|
-
browserSessionId;
|
|
24
|
-
constructor(command) {
|
|
25
|
-
this.commandId = randomUUID();
|
|
26
|
-
this.command = command;
|
|
27
|
-
this.commandStartTime = Date.now();
|
|
28
|
-
this.cliVersion = getCurrentVersion();
|
|
29
|
-
this.nodeVersion = process.version;
|
|
30
|
-
this.platform = process.platform;
|
|
31
|
-
this.isTty = process.stdout.isTTY ?? false;
|
|
32
|
-
this.isCI = !!(process.env.CI || process.env.GITHUB_ACTIONS);
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Set context IDs that will be attached to all subsequent events.
|
|
36
|
-
*/
|
|
37
|
-
setContext(ctx) {
|
|
38
|
-
if (ctx.featureId)
|
|
39
|
-
this.featureId = ctx.featureId;
|
|
40
|
-
if (ctx.checklistItemId)
|
|
41
|
-
this.checklistItemId = ctx.checklistItemId;
|
|
42
|
-
if (ctx.browserSessionId)
|
|
43
|
-
this.browserSessionId = ctx.browserSessionId;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Track command start. Fires immediately for fault tolerance.
|
|
47
|
-
*/
|
|
48
|
-
async trackCommandStart(metadata) {
|
|
49
|
-
const event = this.buildEvent({
|
|
50
|
-
eventType: 'command_start',
|
|
51
|
-
metadata,
|
|
52
|
-
});
|
|
53
|
-
await this.sendImmediate(event);
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Track command end. Fires immediately + flushes buffer.
|
|
57
|
-
*/
|
|
58
|
-
async trackCommandEnd(outcome, metadata) {
|
|
59
|
-
const event = this.buildEvent({
|
|
60
|
-
eventType: 'command_end',
|
|
61
|
-
outcome,
|
|
62
|
-
durationMs: Date.now() - this.commandStartTime,
|
|
63
|
-
metadata,
|
|
64
|
-
});
|
|
65
|
-
await this.sendImmediate(event);
|
|
66
|
-
await this.flush();
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Track command error. Fires immediately + flushes buffer.
|
|
70
|
-
*/
|
|
71
|
-
async trackCommandError(error, metadata) {
|
|
72
|
-
const event = this.buildEvent({
|
|
73
|
-
eventType: 'command_error',
|
|
74
|
-
errorMessage: truncate(error instanceof Error ? error.message : String(error), 500),
|
|
75
|
-
errorType: error instanceof Error ? error.constructor.name : 'Unknown',
|
|
76
|
-
durationMs: Date.now() - this.commandStartTime,
|
|
77
|
-
metadata,
|
|
78
|
-
});
|
|
79
|
-
await this.sendImmediate(event);
|
|
80
|
-
await this.flush();
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Track phase start. Buffered.
|
|
84
|
-
*/
|
|
85
|
-
trackPhaseStart(phase, metadata) {
|
|
86
|
-
this.phaseCounter++;
|
|
87
|
-
this.phaseStartTimes.set(phase, Date.now());
|
|
88
|
-
const event = this.buildEvent({
|
|
89
|
-
eventType: 'phase_start',
|
|
90
|
-
phase,
|
|
91
|
-
phaseIndex: this.phaseCounter,
|
|
92
|
-
metadata,
|
|
93
|
-
});
|
|
94
|
-
this.buffer.push(event);
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Track phase end. Buffered, auto-flushes at 10 events.
|
|
98
|
-
*/
|
|
99
|
-
trackPhaseEnd(phase, metadata) {
|
|
100
|
-
const startTime = this.phaseStartTimes.get(phase);
|
|
101
|
-
const durationMs = startTime ? Date.now() - startTime : undefined;
|
|
102
|
-
this.phaseStartTimes.delete(phase);
|
|
103
|
-
const event = this.buildEvent({
|
|
104
|
-
eventType: 'phase_end',
|
|
105
|
-
phase,
|
|
106
|
-
durationMs,
|
|
107
|
-
metadata,
|
|
108
|
-
});
|
|
109
|
-
this.buffer.push(event);
|
|
110
|
-
if (this.buffer.length >= 10) {
|
|
111
|
-
this.flushAsync();
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Track phase error. Fires immediately (phase errors often precede exit).
|
|
116
|
-
*/
|
|
117
|
-
async trackPhaseError(phase, error, metadata) {
|
|
118
|
-
const startTime = this.phaseStartTimes.get(phase);
|
|
119
|
-
const durationMs = startTime ? Date.now() - startTime : undefined;
|
|
120
|
-
this.phaseStartTimes.delete(phase);
|
|
121
|
-
const event = this.buildEvent({
|
|
122
|
-
eventType: 'phase_error',
|
|
123
|
-
phase,
|
|
124
|
-
durationMs,
|
|
125
|
-
errorMessage: truncate(error instanceof Error ? error.message : String(error), 500),
|
|
126
|
-
errorType: error instanceof Error ? error.constructor.name : 'Unknown',
|
|
127
|
-
metadata,
|
|
128
|
-
});
|
|
129
|
-
await this.sendImmediate(event);
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Flush all buffered events to the server.
|
|
133
|
-
*/
|
|
134
|
-
async flush() {
|
|
135
|
-
if (this.buffer.length === 0)
|
|
136
|
-
return;
|
|
137
|
-
const events = this.buffer.splice(0);
|
|
138
|
-
try {
|
|
139
|
-
await this.sendBatch(events);
|
|
140
|
-
}
|
|
141
|
-
catch {
|
|
142
|
-
// Swallow — telemetry must never throw
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
// ---------- Private ----------
|
|
146
|
-
buildEvent(partial) {
|
|
147
|
-
return {
|
|
148
|
-
eventType: partial.eventType,
|
|
149
|
-
command: this.command,
|
|
150
|
-
commandId: this.commandId,
|
|
151
|
-
timestamp: new Date().toISOString(),
|
|
152
|
-
durationMs: partial.durationMs,
|
|
153
|
-
phase: partial.phase,
|
|
154
|
-
phaseIndex: partial.phaseIndex,
|
|
155
|
-
outcome: partial.outcome,
|
|
156
|
-
errorMessage: partial.errorMessage,
|
|
157
|
-
errorType: partial.errorType,
|
|
158
|
-
featureId: this.featureId,
|
|
159
|
-
checklistItemId: this.checklistItemId,
|
|
160
|
-
browserSessionId: this.browserSessionId,
|
|
161
|
-
evaluation: partial.evaluation,
|
|
162
|
-
cliVersion: this.cliVersion,
|
|
163
|
-
nodeVersion: this.nodeVersion,
|
|
164
|
-
platform: this.platform,
|
|
165
|
-
isTty: this.isTty,
|
|
166
|
-
isCI: this.isCI,
|
|
167
|
-
metadata: partial.metadata,
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
async sendImmediate(event) {
|
|
171
|
-
try {
|
|
172
|
-
await this.sendBatch([event]);
|
|
173
|
-
}
|
|
174
|
-
catch {
|
|
175
|
-
// Swallow — telemetry must never throw
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
flushAsync() {
|
|
179
|
-
if (this.flushing)
|
|
180
|
-
return;
|
|
181
|
-
this.flushing = this.flush().finally(() => {
|
|
182
|
-
this.flushing = null;
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
async sendBatch(events) {
|
|
186
|
-
const token = await getToken().catch(() => null);
|
|
187
|
-
const baseUrl = getApiBaseUrl();
|
|
188
|
-
const headers = {
|
|
189
|
-
'Content-Type': 'application/json',
|
|
190
|
-
};
|
|
191
|
-
if (token) {
|
|
192
|
-
headers['Authorization'] = `Bearer ${token}`;
|
|
193
|
-
}
|
|
194
|
-
const payload = { events };
|
|
195
|
-
if (process.env.DEBUG) {
|
|
196
|
-
console.error(`[telemetry] Sending ${events.length} event(s) to ${baseUrl}/api/v1/mcp/cli-telemetry`);
|
|
197
|
-
}
|
|
198
|
-
const controller = new AbortController();
|
|
199
|
-
const timeout = setTimeout(() => controller.abort(), 5000);
|
|
200
|
-
try {
|
|
201
|
-
await fetch(`${baseUrl}/api/v1/mcp/cli-telemetry`, {
|
|
202
|
-
method: 'POST',
|
|
203
|
-
headers,
|
|
204
|
-
body: JSON.stringify(payload),
|
|
205
|
-
signal: controller.signal,
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
finally {
|
|
209
|
-
clearTimeout(timeout);
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
// ---------- Module-level API ----------
|
|
214
|
-
let currentCollector = null;
|
|
215
|
-
/**
|
|
216
|
-
* Create a telemetry collector for a command invocation.
|
|
217
|
-
* Call this at the start of each command handler.
|
|
218
|
-
*/
|
|
219
|
-
export function createTelemetryCollector(command) {
|
|
220
|
-
currentCollector = new TelemetryCollector(command);
|
|
221
|
-
return currentCollector;
|
|
222
|
-
}
|
|
223
|
-
/**
|
|
224
|
-
* Get the current collector (if any).
|
|
225
|
-
* Useful for the yargs fail() handler to report errors.
|
|
226
|
-
*/
|
|
227
|
-
export function getCurrentCollector() {
|
|
228
|
-
return currentCollector;
|
|
229
|
-
}
|
|
230
|
-
/**
|
|
231
|
-
* Wrap a CLI command handler with telemetry.
|
|
232
|
-
* Handles collector creation, command start/end/error tracking, and flush.
|
|
233
|
-
* Pass the telemetry collector to the callback for phase-level tracking.
|
|
234
|
-
*/
|
|
235
|
-
export async function withTelemetry(command, fn, metadata) {
|
|
236
|
-
const telemetry = createTelemetryCollector(command);
|
|
237
|
-
await telemetry.trackCommandStart(metadata);
|
|
238
|
-
try {
|
|
239
|
-
const result = await fn(telemetry);
|
|
240
|
-
await telemetry.trackCommandEnd('success');
|
|
241
|
-
return result;
|
|
242
|
-
}
|
|
243
|
-
catch (error) {
|
|
244
|
-
await telemetry.trackCommandError(error);
|
|
245
|
-
throw error;
|
|
246
|
-
}
|
|
247
|
-
finally {
|
|
248
|
-
await telemetry.flush();
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
function truncate(str, maxLen) {
|
|
252
|
-
return str.length > maxLen ? str.slice(0, maxLen) + '...' : str;
|
|
253
|
-
}
|
|
254
|
-
//# sourceMappingURL=telemetry.js.map
|
|
1
|
+
const _0x2b1e7d=_0xad06;(function(_0xaaadcd,_0x5f5253){const _0x4acf54=_0xad06,_0xf1ee73=_0xaaadcd();while(!![]){try{const _0x4741e3=parseInt(_0x4acf54(0x1fa))/0x1*(-parseInt(_0x4acf54(0x21d))/0x2)+parseInt(_0x4acf54(0x1e4))/0x3+parseInt(_0x4acf54(0x1f9))/0x4+parseInt(_0x4acf54(0x1ef))/0x5+-parseInt(_0x4acf54(0x1db))/0x6*(parseInt(_0x4acf54(0x20f))/0x7)+parseInt(_0x4acf54(0x206))/0x8*(parseInt(_0x4acf54(0x21b))/0x9)+-parseInt(_0x4acf54(0x20d))/0xa;if(_0x4741e3===_0x5f5253)break;else _0xf1ee73['push'](_0xf1ee73['shift']());}catch(_0x3dde6c){_0xf1ee73['push'](_0xf1ee73['shift']());}}}(_0x2688,0x1f667));import{randomUUID}from'crypto';import{getToken}from'./keychain.js';function _0xad06(_0x39834,_0x1d1a9f){_0x39834=_0x39834-0x1da;const _0x268880=_0x2688();let _0xad0633=_0x268880[_0x39834];return _0xad0633;}function _0x2688(){const _0x8370b9=['slice','buffer','31725kwfuNy','phaseCounter','115006PaYDwA','RJYWc','6UNWWLr','delete','kkNbW','platform','PAeyi','sendImmediate','length','success','\x20event(s)\x20to\x20','711627uqNpZQ','name','KJEqc','browserSessionId','Authorization','env','flushAsync','buildEvent','now','commandStartTime','phaseStartTimes','1130985MgtlbF','setContext','commandId','WDlEQ','sendBatch','/api/v1/mcp/cli-telemetry','command_error','...','trackPhaseEnd','cliVersion','740848fmkSJe','1WEkmPj','DEBUG','isTty','phase_start','uNAkG','GITHUB_ACTIONS','version','push','nodeVersion','featureId','stdout','flushing','536WDoYFA','phase','trackCommandStart','catch','set','flush','splice','6170580AwahNk','eventType','571319FdtCaU','cikDe','constructor','signal','trackCommandError','message','jHazI','command','isCI','metadata'];_0x2688=function(){return _0x8370b9;};return _0x2688();}import{getApiBaseUrl}from'./environment.js';import{getCurrentVersion}from'./version.js';export class TelemetryCollector{[_0x2b1e7d(0x21a)]=[];['commandId'];['command'];[_0x2b1e7d(0x1ed)];['phaseCounter']=0x0;[_0x2b1e7d(0x1ee)]=new Map();['flushing']=null;[_0x2b1e7d(0x1f8)];[_0x2b1e7d(0x202)];['platform'];['isTty'];[_0x2b1e7d(0x217)];['featureId'];['checklistItemId'];[_0x2b1e7d(0x1e7)];constructor(_0x229a20){const _0x171e54=_0x2b1e7d,_0x2ac216={'rSUYR':function(_0x4f8094){return _0x4f8094();}};this['commandId']=randomUUID(),this[_0x171e54(0x216)]=_0x229a20,this['commandStartTime']=Date['now'](),this['cliVersion']=_0x2ac216['rSUYR'](getCurrentVersion),this['nodeVersion']=process[_0x171e54(0x200)],this['platform']=process[_0x171e54(0x1de)],this[_0x171e54(0x1fc)]=process[_0x171e54(0x204)]['isTTY']??![],this['isCI']=!!(process[_0x171e54(0x1e9)]['CI']||process[_0x171e54(0x1e9)][_0x171e54(0x1ff)]);}[_0x2b1e7d(0x1f0)](_0x242ae5){const _0x5b32fb=_0x2b1e7d;if(_0x242ae5[_0x5b32fb(0x203)])this[_0x5b32fb(0x203)]=_0x242ae5['featureId'];if(_0x242ae5['checklistItemId'])this['checklistItemId']=_0x242ae5['checklistItemId'];if(_0x242ae5[_0x5b32fb(0x1e7)])this['browserSessionId']=_0x242ae5['browserSessionId'];}async[_0x2b1e7d(0x208)](_0x58bdf4){const _0x22738e=_0x2b1e7d,_0x528784=this[_0x22738e(0x1eb)]({'eventType':'command_start','metadata':_0x58bdf4});await this['sendImmediate'](_0x528784);}async['trackCommandEnd'](_0x5ac211,_0x407f17){const _0x584610=_0x2b1e7d,_0x6de8dc={'jEhfP':'command_end'},_0xd06efe=this[_0x584610(0x1eb)]({'eventType':_0x6de8dc['jEhfP'],'outcome':_0x5ac211,'durationMs':Date['now']()-this['commandStartTime'],'metadata':_0x407f17});await this[_0x584610(0x1e0)](_0xd06efe),await this[_0x584610(0x20b)]();}async['trackCommandError'](_0x32bb79,_0x22fcda){const _0x24b53d=_0x2b1e7d,_0x758b3={'lIzIr':_0x24b53d(0x1f5),'RJYWc':function(_0x50a109,_0x19827d,_0x436c9f){return _0x50a109(_0x19827d,_0x436c9f);},'WDlEQ':function(_0x32a1ab,_0x1102fb){return _0x32a1ab instanceof _0x1102fb;},'RfeRn':function(_0xbe2fe9,_0x418845){return _0xbe2fe9 instanceof _0x418845;},'KJEqc':function(_0x16392e,_0x220814){return _0x16392e-_0x220814;}},_0x10b919=this[_0x24b53d(0x1eb)]({'eventType':_0x758b3['lIzIr'],'errorMessage':_0x758b3[_0x24b53d(0x1da)](truncate,_0x758b3[_0x24b53d(0x1f2)](_0x32bb79,Error)?_0x32bb79[_0x24b53d(0x214)]:String(_0x32bb79),0x1f4),'errorType':_0x758b3['RfeRn'](_0x32bb79,Error)?_0x32bb79[_0x24b53d(0x211)][_0x24b53d(0x1e5)]:'Unknown','durationMs':_0x758b3[_0x24b53d(0x1e6)](Date[_0x24b53d(0x1ec)](),this['commandStartTime']),'metadata':_0x22fcda});await this[_0x24b53d(0x1e0)](_0x10b919),await this['flush']();}['trackPhaseStart'](_0x1faca3,_0x1224e8){const _0x4bcb6c=_0x2b1e7d,_0x444ff8={'jHazI':_0x4bcb6c(0x1fd)};this[_0x4bcb6c(0x21c)]++,this['phaseStartTimes'][_0x4bcb6c(0x20a)](_0x1faca3,Date['now']());const _0x2460e9=this['buildEvent']({'eventType':_0x444ff8[_0x4bcb6c(0x215)],'phase':_0x1faca3,'phaseIndex':this['phaseCounter'],'metadata':_0x1224e8});this['buffer']['push'](_0x2460e9);}[_0x2b1e7d(0x1f7)](_0x8565b7,_0x2168e6){const _0x3638ce=_0x2b1e7d,_0x90c895={'sUIVi':function(_0x16f188,_0x351710){return _0x16f188-_0x351710;},'JfFbt':'phase_end'},_0x28d870=this['phaseStartTimes']['get'](_0x8565b7),_0x27213e=_0x28d870?_0x90c895['sUIVi'](Date['now'](),_0x28d870):undefined;this['phaseStartTimes'][_0x3638ce(0x1dc)](_0x8565b7);const _0x3b3eab=this[_0x3638ce(0x1eb)]({'eventType':_0x90c895['JfFbt'],'phase':_0x8565b7,'durationMs':_0x27213e,'metadata':_0x2168e6});this['buffer'][_0x3638ce(0x201)](_0x3b3eab),this[_0x3638ce(0x21a)]['length']>=0xa&&this[_0x3638ce(0x1ea)]();}async['trackPhaseError'](_0x5a1d60,_0x258600,_0x3a0976){const _0x118cd4=_0x2b1e7d,_0x1c5659={'HfjBk':'phase_error','cikDe':function(_0xb86b60,_0x432bd5,_0x52f392){return _0xb86b60(_0x432bd5,_0x52f392);},'cZrph':function(_0x7e64cb,_0x31dbac){return _0x7e64cb instanceof _0x31dbac;},'SoHYt':'Unknown'},_0x4a0058=this[_0x118cd4(0x1ee)]['get'](_0x5a1d60),_0xd27462=_0x4a0058?Date[_0x118cd4(0x1ec)]()-_0x4a0058:undefined;this[_0x118cd4(0x1ee)][_0x118cd4(0x1dc)](_0x5a1d60);const _0xb96db9=this['buildEvent']({'eventType':_0x1c5659['HfjBk'],'phase':_0x5a1d60,'durationMs':_0xd27462,'errorMessage':_0x1c5659[_0x118cd4(0x210)](truncate,_0x1c5659['cZrph'](_0x258600,Error)?_0x258600[_0x118cd4(0x214)]:String(_0x258600),0x1f4),'errorType':_0x258600 instanceof Error?_0x258600['constructor'][_0x118cd4(0x1e5)]:_0x1c5659['SoHYt'],'metadata':_0x3a0976});await this['sendImmediate'](_0xb96db9);}async[_0x2b1e7d(0x20b)](){const _0x30a22a=_0x2b1e7d,_0x4ab989={'xPBlZ':function(_0x2710f,_0x4bce82){return _0x2710f===_0x4bce82;}};if(_0x4ab989['xPBlZ'](this['buffer']['length'],0x0))return;const _0x4fae02=this[_0x30a22a(0x21a)][_0x30a22a(0x20c)](0x0);try{await this['sendBatch'](_0x4fae02);}catch{}}['buildEvent'](_0x529dc2){const _0xc9ad3b=_0x2b1e7d;return{'eventType':_0x529dc2[_0xc9ad3b(0x20e)],'command':this['command'],'commandId':this[_0xc9ad3b(0x1f1)],'timestamp':new Date()['toISOString'](),'durationMs':_0x529dc2['durationMs'],'phase':_0x529dc2[_0xc9ad3b(0x207)],'phaseIndex':_0x529dc2['phaseIndex'],'outcome':_0x529dc2['outcome'],'errorMessage':_0x529dc2['errorMessage'],'errorType':_0x529dc2['errorType'],'featureId':this['featureId'],'checklistItemId':this['checklistItemId'],'browserSessionId':this[_0xc9ad3b(0x1e7)],'evaluation':_0x529dc2['evaluation'],'cliVersion':this[_0xc9ad3b(0x1f8)],'nodeVersion':this['nodeVersion'],'platform':this[_0xc9ad3b(0x1de)],'isTty':this['isTty'],'isCI':this[_0xc9ad3b(0x217)],'metadata':_0x529dc2[_0xc9ad3b(0x218)]};}async['sendImmediate'](_0x3958a8){const _0x89bb40=_0x2b1e7d;try{await this[_0x89bb40(0x1f3)]([_0x3958a8]);}catch{}}[_0x2b1e7d(0x1ea)](){const _0x130956=_0x2b1e7d;if(this[_0x130956(0x205)])return;this['flushing']=this[_0x130956(0x20b)]()['finally'](()=>{this['flushing']=null;});}async['sendBatch'](_0x1f1052){const _0x351bf0=_0x2b1e7d,_0x3f6981={'BZmiV':function(_0xd30dcb){return _0xd30dcb();},'ukiry':function(_0x1d31c9){return _0x1d31c9();},'PAeyi':function(_0x4e6619,_0x5e4c73,_0x1e6778){return _0x4e6619(_0x5e4c73,_0x1e6778);},'GbzNT':'POST'},_0x4c5f27=await _0x3f6981['BZmiV'](getToken)[_0x351bf0(0x209)](()=>null),_0x1cc50c=_0x3f6981['ukiry'](getApiBaseUrl),_0xddff80={'Content-Type':'application/json'};_0x4c5f27&&(_0xddff80[_0x351bf0(0x1e8)]='Bearer\x20'+_0x4c5f27);const _0x2bcfcd={'events':_0x1f1052};process[_0x351bf0(0x1e9)][_0x351bf0(0x1fb)]&&console['error']('[telemetry]\x20Sending\x20'+_0x1f1052[_0x351bf0(0x1e1)]+_0x351bf0(0x1e3)+_0x1cc50c+_0x351bf0(0x1f4));const _0x3d5081=new AbortController(),_0x52d1e4=_0x3f6981[_0x351bf0(0x1df)](setTimeout,()=>_0x3d5081['abort'](),0x1388);try{await _0x3f6981['PAeyi'](fetch,_0x1cc50c+'/api/v1/mcp/cli-telemetry',{'method':_0x3f6981['GbzNT'],'headers':_0xddff80,'body':JSON['stringify'](_0x2bcfcd),'signal':_0x3d5081[_0x351bf0(0x212)]});}finally{clearTimeout(_0x52d1e4);}}}let currentCollector=null;export function createTelemetryCollector(_0x2ad445){return currentCollector=new TelemetryCollector(_0x2ad445),currentCollector;}export function getCurrentCollector(){return currentCollector;}export async function withTelemetry(_0x4670e1,_0x1756bf,_0x10ac23){const _0x46a5b6=_0x2b1e7d,_0x472641={'uNAkG':function(_0x34e0a9,_0x52f65e){return _0x34e0a9(_0x52f65e);},'kkNbW':_0x46a5b6(0x1e2)},_0x19f3eb=_0x472641[_0x46a5b6(0x1fe)](createTelemetryCollector,_0x4670e1);await _0x19f3eb[_0x46a5b6(0x208)](_0x10ac23);try{const _0x367e19=await _0x1756bf(_0x19f3eb);return await _0x19f3eb['trackCommandEnd'](_0x472641[_0x46a5b6(0x1dd)]),_0x367e19;}catch(_0x304caf){await _0x19f3eb[_0x46a5b6(0x213)](_0x304caf);throw _0x304caf;}finally{await _0x19f3eb[_0x46a5b6(0x20b)]();}}function truncate(_0x31b04d,_0x5df6a7){const _0xb987c6=_0x2b1e7d,_0x361bfe={'QWyEJ':function(_0x564a8e,_0x4b4ee9){return _0x564a8e>_0x4b4ee9;}};return _0x361bfe['QWyEJ'](_0x31b04d['length'],_0x5df6a7)?_0x31b04d[_0xb987c6(0x219)](0x0,_0x5df6a7)+_0xb987c6(0x1f6):_0x31b04d;}
|
|
@@ -1,32 +1 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Get current user info from the /api/v1/mcp/me endpoint.
|
|
4
|
-
* Returns user info on success, or an error object on failure.
|
|
5
|
-
*/
|
|
6
|
-
export async function getCurrentUser(token) {
|
|
7
|
-
const apiBaseUrl = getApiBaseUrl();
|
|
8
|
-
try {
|
|
9
|
-
const response = await fetch(`${apiBaseUrl}/api/v1/mcp/me`, {
|
|
10
|
-
method: 'GET',
|
|
11
|
-
headers: {
|
|
12
|
-
Authorization: `Bearer ${token}`,
|
|
13
|
-
},
|
|
14
|
-
});
|
|
15
|
-
if (!response.ok) {
|
|
16
|
-
return {
|
|
17
|
-
success: false,
|
|
18
|
-
error: `${response.status} ${response.statusText}`,
|
|
19
|
-
status: response.status,
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
const user = await response.json();
|
|
23
|
-
return { success: true, user };
|
|
24
|
-
}
|
|
25
|
-
catch (error) {
|
|
26
|
-
return {
|
|
27
|
-
success: false,
|
|
28
|
-
error: error instanceof Error ? error.message : String(error),
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
//# sourceMappingURL=userApi.js.map
|
|
1
|
+
(function(_0x3ca0a9,_0x22d929){const _0x3b311f=_0x226b,_0x5d6734=_0x3ca0a9();while(!![]){try{const _0x25edef=-parseInt(_0x3b311f(0xdb))/0x1+-parseInt(_0x3b311f(0xd7))/0x2*(parseInt(_0x3b311f(0xd0))/0x3)+-parseInt(_0x3b311f(0xcc))/0x4+parseInt(_0x3b311f(0xcd))/0x5+-parseInt(_0x3b311f(0xd3))/0x6+parseInt(_0x3b311f(0xcf))/0x7*(-parseInt(_0x3b311f(0xda))/0x8)+parseInt(_0x3b311f(0xd9))/0x9*(parseInt(_0x3b311f(0xd4))/0xa);if(_0x25edef===_0x22d929)break;else _0x5d6734['push'](_0x5d6734['shift']());}catch(_0x41a8a7){_0x5d6734['push'](_0x5d6734['shift']());}}}(_0x491a,0xdd342));function _0x491a(){const _0xbb7d48=['5490590CZKrCk','status','228277YLqCYG','3eKWZkc','GET','MZiWj','5215650RpAVlF','11824230tBClKe','statusText','json','429366qMKkMZ','Bearer\x20','36SOGBwW','368gZnZmn','567610qYMRzk','7080344hvEmxB'];_0x491a=function(){return _0xbb7d48;};return _0x491a();}function _0x226b(_0x69a873,_0x4f2cd5){_0x69a873=_0x69a873-0xcc;const _0x491a4a=_0x491a();let _0x226b3b=_0x491a4a[_0x69a873];return _0x226b3b;}import{getApiBaseUrl}from'./environment.js';export async function getCurrentUser(_0x2dd023){const _0x13a402=_0x226b,_0x19ef6c={'MZiWj':function(_0x252c37){return _0x252c37();},'NoJSo':function(_0x32974a,_0x25e781,_0x2d5602){return _0x32974a(_0x25e781,_0x2d5602);},'tWAYw':_0x13a402(0xd1),'NAEHt':function(_0x28b624,_0x2518f1){return _0x28b624(_0x2518f1);}},_0x30c459=_0x19ef6c[_0x13a402(0xd2)](getApiBaseUrl);try{const _0x3a1368=await _0x19ef6c['NoJSo'](fetch,_0x30c459+'/api/v1/mcp/me',{'method':_0x19ef6c['tWAYw'],'headers':{'Authorization':_0x13a402(0xd8)+_0x2dd023}});if(!_0x3a1368['ok'])return{'success':![],'error':_0x3a1368['status']+'\x20'+_0x3a1368[_0x13a402(0xd5)],'status':_0x3a1368[_0x13a402(0xce)]};const _0x39f596=await _0x3a1368[_0x13a402(0xd6)]();return{'success':!![],'user':_0x39f596};}catch(_0x21ce27){return{'success':![],'error':_0x21ce27 instanceof Error?_0x21ce27['message']:_0x19ef6c['NAEHt'](String,_0x21ce27)};}}
|
|
@@ -1,62 +1 @@
|
|
|
1
|
-
import { readFileSync }
|
|
2
|
-
import { existsSync } from 'fs';
|
|
3
|
-
import { execSync } from 'child_process';
|
|
4
|
-
import { fileURLToPath } from 'url';
|
|
5
|
-
import { dirname, join } from 'path';
|
|
6
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
7
|
-
const __dirname = dirname(__filename);
|
|
8
|
-
export const PACKAGE_NAME = '@ranger-testing/ranger-cli';
|
|
9
|
-
/**
|
|
10
|
-
* Get the current CLI version from package.json
|
|
11
|
-
*/
|
|
12
|
-
export function getCurrentVersion() {
|
|
13
|
-
const possiblePaths = [
|
|
14
|
-
join(__dirname, '..', '..', 'package.json'),
|
|
15
|
-
join(__dirname, '..', '..', '..', 'package.json'),
|
|
16
|
-
];
|
|
17
|
-
for (const p of possiblePaths) {
|
|
18
|
-
if (existsSync(p)) {
|
|
19
|
-
try {
|
|
20
|
-
const packageJson = JSON.parse(readFileSync(p, 'utf-8'));
|
|
21
|
-
return packageJson.version || 'unknown';
|
|
22
|
-
}
|
|
23
|
-
catch {
|
|
24
|
-
continue;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
return 'unknown';
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Get the latest version from npm registry
|
|
32
|
-
*/
|
|
33
|
-
export function getLatestVersion() {
|
|
34
|
-
try {
|
|
35
|
-
const result = execSync(`npm view ${PACKAGE_NAME} version 2>/dev/null`, {
|
|
36
|
-
encoding: 'utf-8',
|
|
37
|
-
timeout: 5000,
|
|
38
|
-
});
|
|
39
|
-
return result.trim();
|
|
40
|
-
}
|
|
41
|
-
catch {
|
|
42
|
-
return null;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Compare two semver versions
|
|
47
|
-
* Returns: 1 if latest > current, -1 if latest < current, 0 if equal
|
|
48
|
-
*/
|
|
49
|
-
export function compareVersions(current, latest) {
|
|
50
|
-
const currentParts = current.split('.').map(Number);
|
|
51
|
-
const latestParts = latest.split('.').map(Number);
|
|
52
|
-
for (let i = 0; i < 3; i++) {
|
|
53
|
-
const c = currentParts[i] || 0;
|
|
54
|
-
const l = latestParts[i] || 0;
|
|
55
|
-
if (l > c)
|
|
56
|
-
return 1;
|
|
57
|
-
if (l < c)
|
|
58
|
-
return -1;
|
|
59
|
-
}
|
|
60
|
-
return 0;
|
|
61
|
-
}
|
|
62
|
-
//# sourceMappingURL=version.js.map
|
|
1
|
+
(function(_0x49c0d2,_0x1e935a){const _0x1cd30f=_0x2349,_0x53c36a=_0x49c0d2();while(!![]){try{const _0x2f021f=-parseInt(_0x1cd30f(0xf1))/0x1+-parseInt(_0x1cd30f(0xe9))/0x2+-parseInt(_0x1cd30f(0xf0))/0x3*(parseInt(_0x1cd30f(0xe5))/0x4)+-parseInt(_0x1cd30f(0xe8))/0x5*(-parseInt(_0x1cd30f(0xeb))/0x6)+-parseInt(_0x1cd30f(0xf2))/0x7+parseInt(_0x1cd30f(0xee))/0x8+-parseInt(_0x1cd30f(0xf8))/0x9*(-parseInt(_0x1cd30f(0xe7))/0xa);if(_0x2f021f===_0x1e935a)break;else _0x53c36a['push'](_0x53c36a['shift']());}catch(_0x3449d8){_0x53c36a['push'](_0x53c36a['shift']());}}}(_0x2475,0x55823));import{readFileSync}from'fs';import{existsSync}from'fs';import{execSync}from'child_process';import{fileURLToPath}from'url';import{dirname,join}from'path';const __filename=fileURLToPath(import.meta.url),__dirname=dirname(__filename);export const PACKAGE_NAME='@ranger-testing/ranger-cli';function _0x2475(){const _0x227846=['nXwKY','3063720AjAAHD','package.json','1907877kZLCny','381360mziPqU','2414433jQoQQm','parse','RYKWO','split','version','unknown','106731ttYubN','4RGZLpT','txLmE','1410bpZFZo','5005WRuudX','689210cYwxMm','map','12pLUQGS','slSlo'];_0x2475=function(){return _0x227846;};return _0x2475();}function _0x2349(_0x57905f,_0x4f7464){_0x57905f=_0x57905f-0xe5;const _0x247523=_0x2475();let _0x234980=_0x247523[_0x57905f];return _0x234980;}export function getCurrentVersion(){const _0x4deff0=_0x2349,_0x15e3cb={'nXwKY':function(_0x846b00,_0x28f988,_0x2c611f,_0x1a4a5c,_0x1f7fcc){return _0x846b00(_0x28f988,_0x2c611f,_0x1a4a5c,_0x1f7fcc);},'slSlo':'package.json','NcRXV':function(_0x353104,_0x70cc7b,_0x245af4){return _0x353104(_0x70cc7b,_0x245af4);},'utrPv':'utf-8','XAfxb':_0x4deff0(0xf7)},_0x43b43e=[_0x15e3cb[_0x4deff0(0xed)](join,__dirname,'..','..',_0x15e3cb[_0x4deff0(0xec)]),join(__dirname,'..','..','..',_0x4deff0(0xef))];for(const _0xad931f of _0x43b43e){if(existsSync(_0xad931f))try{const _0x5df989=JSON[_0x4deff0(0xf3)](_0x15e3cb['NcRXV'](readFileSync,_0xad931f,_0x15e3cb['utrPv']));return _0x5df989[_0x4deff0(0xf6)]||_0x4deff0(0xf7);}catch{continue;}}return _0x15e3cb['XAfxb'];}export function getLatestVersion(){const _0x161962=_0x2349,_0x10ce2b={'RYKWO':function(_0x11cd78,_0x5a228f,_0x2cff68){return _0x11cd78(_0x5a228f,_0x2cff68);},'GUSuV':'utf-8'};try{const _0x304a7b=_0x10ce2b[_0x161962(0xf4)](execSync,'npm\x20view\x20'+PACKAGE_NAME+'\x20version\x202>/dev/null',{'encoding':_0x10ce2b['GUSuV'],'timeout':0x1388});return _0x304a7b['trim']();}catch{return null;}}export function compareVersions(_0x4be58c,_0x25a084){const _0x23f84e=_0x2349,_0x492a7d={'txLmE':function(_0x4768d,_0x1dd320){return _0x4768d<_0x1dd320;}},_0x5898f4=_0x4be58c['split']('.')['map'](Number),_0xad3815=_0x25a084[_0x23f84e(0xf5)]('.')[_0x23f84e(0xea)](Number);for(let _0x91ce5e=0x0;_0x492a7d[_0x23f84e(0xe6)](_0x91ce5e,0x3);_0x91ce5e++){const _0x17fe16=_0x5898f4[_0x91ce5e]||0x0,_0x3cfab9=_0xad3815[_0x91ce5e]||0x0;if(_0x3cfab9>_0x17fe16)return 0x1;if(_0x492a7d[_0x23f84e(0xe6)](_0x3cfab9,_0x17fe16))return-0x1;}return 0x0;}
|