@google/gemini-cli 0.36.0-preview.7 → 0.37.0-preview.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/bundle/{chunk-NYCY3Q2B.js → chunk-3TN4SOLW.js} +6652 -4181
- package/bundle/{chunk-S2IQOR7T.js → chunk-7UZ4Y32N.js} +214 -66
- package/bundle/{chunk-2RCLDWUX.js → chunk-A62NZYIK.js} +8052 -2969
- package/bundle/{chunk-VA3P26WZ.js → chunk-LEK5YYAR.js} +6296 -4095
- package/bundle/{chunk-MYI75E6G.js → chunk-R5X4CMUM.js} +233 -70
- package/bundle/{chunk-EHC7O4TG.js → chunk-TJ76C6AA.js} +16848 -9497
- package/bundle/chunk-U4FACSVX.js +30 -0
- package/bundle/{chunk-APAYS2LE.js → chunk-ULC3DHVX.js} +8052 -2969
- package/bundle/{chunk-YTGZ6CSI.js → chunk-XX7JYMTE.js} +8106 -3035
- package/bundle/{core-BHH4RB6L.js → core-5OME6LT4.js} +58 -4
- package/bundle/{dist-SWQPYLLV.js → core-CUCGSGCA.js} +58 -4
- package/bundle/{devtoolsService-STAWBGOY.js → devtoolsService-4FIYD6OW.js} +20 -3
- package/bundle/{devtoolsService-GJALET3B.js → devtoolsService-IDLWLZFQ.js} +21 -5
- package/bundle/{devtoolsService-4QGIZO5B.js → devtoolsService-TVWW3DBW.js} +20 -3
- package/bundle/{dist-YOBWJF52.js → dist-YWCADMDD.js} +58 -4
- package/bundle/docs/CONTRIBUTING.md +10 -7
- package/bundle/docs/assets/theme-tokyonight-dark.png +0 -0
- package/bundle/docs/changelogs/index.md +24 -0
- package/bundle/docs/changelogs/latest.md +366 -459
- package/bundle/docs/changelogs/preview.md +362 -356
- package/bundle/docs/cli/acp-mode.md +126 -0
- package/bundle/docs/cli/cli-reference.md +1 -1
- package/bundle/docs/cli/notifications.md +5 -5
- package/bundle/docs/cli/plan-mode.md +12 -8
- package/bundle/docs/cli/sandbox.md +1 -1
- package/bundle/docs/cli/settings.md +14 -13
- package/bundle/docs/cli/themes.md +5 -0
- package/bundle/docs/core/index.md +2 -2
- package/bundle/docs/core/subagents.md +134 -23
- package/bundle/docs/get-started/gemini-3.md +1 -1
- package/bundle/docs/get-started/index.md +127 -1
- package/bundle/docs/ide-integration/index.md +99 -24
- package/bundle/docs/index.md +0 -2
- package/bundle/docs/redirects.json +1 -0
- package/bundle/docs/reference/commands.md +1 -3
- package/bundle/docs/reference/configuration.md +183 -92
- package/bundle/docs/reference/keyboard-shortcuts.md +14 -6
- package/bundle/docs/reference/policy-engine.md +16 -30
- package/bundle/docs/reference/tools.md +56 -23
- package/bundle/docs/resources/quota-and-pricing.md +23 -9
- package/bundle/docs/sidebar.json +11 -4
- package/bundle/docs/tools/planning.md +6 -4
- package/bundle/events-CLX3JQHP.js +12 -0
- package/bundle/gemini.js +342 -52
- package/bundle/{interactiveCli-YJFA3P4G.js → interactiveCli-4WFWOVAQ.js} +5079 -4022
- package/bundle/{interactiveCli-MEBWWWE7.js → interactiveCli-4ZZ72DR3.js} +5079 -4022
- package/bundle/{interactiveCli-B6Y3UISW.js → interactiveCli-6SIGBRWS.js} +5292 -4252
- package/bundle/{memoryDiscovery-BQGYT4OD.js → memoryDiscovery-NS2EGHYH.js} +3 -1
- package/bundle/{memoryDiscovery-FCEPFZ3M.js → memoryDiscovery-VL3OH25S.js} +3 -1
- package/bundle/node_modules/@google/gemini-cli-devtools/dist/client/main.js +26 -19
- package/bundle/node_modules/@google/gemini-cli-devtools/dist/src/_client-assets.d.ts +1 -1
- package/bundle/node_modules/@google/gemini-cli-devtools/dist/src/_client-assets.js +1 -1
- package/bundle/node_modules/@google/gemini-cli-devtools/dist/src/_client-assets.js.map +1 -1
- package/bundle/node_modules/@google/gemini-cli-devtools/dist/src/index.js +35 -1
- package/bundle/node_modules/@google/gemini-cli-devtools/dist/src/index.js.map +1 -1
- package/bundle/node_modules/@google/gemini-cli-devtools/package.json +1 -1
- package/bundle/{oauth2-provider-TIKPJAVU.js → oauth2-provider-HGHECKPY.js} +2 -2
- package/bundle/{oauth2-provider-IGY3DL3D.js → oauth2-provider-TYBJKXSJ.js} +2 -2
- package/bundle/{oauth2-provider-DLPX23GY.js → oauth2-provider-YYRJ44X5.js} +73 -39
- package/bundle/policies/discovered.toml +7 -0
- package/bundle/policies/non-interactive.toml +7 -0
- package/bundle/policies/plan.toml +25 -0
- package/bundle/policies/read-only.toml +6 -0
- package/bundle/policies/sandbox-default.toml +3 -2
- package/bundle/policies/write.toml +21 -0
- package/bundle/policies/yolo.toml +1 -1
- package/package.json +1 -1
- package/bundle/chunk-GDBDMLKR.js +0 -354180
- package/bundle/chunk-QTVUHTZR.js +0 -93293
- package/bundle/devtoolsService-Q6LGZKTJ.js +0 -854
- package/bundle/dist-YHAAIIZP.js +0 -1886
- package/bundle/docs/get-started/examples.md +0 -141
- package/bundle/interactiveCli-HYY2W6AF.js +0 -49298
- package/bundle/oauth2-provider-MKUXMD5I.js +0 -237
|
@@ -1,854 +0,0 @@
|
|
|
1
|
-
const require = (await import('node:module')).createRequire(import.meta.url); const __chunk_filename = (await import('node:url')).fileURLToPath(import.meta.url); const __chunk_dirname = (await import('node:path')).dirname(__chunk_filename);
|
|
2
|
-
import "./chunk-GDBDMLKR.js";
|
|
3
|
-
import {
|
|
4
|
-
CoreEvent,
|
|
5
|
-
coreEvents,
|
|
6
|
-
debugLogger
|
|
7
|
-
} from "./chunk-S2IQOR7T.js";
|
|
8
|
-
import {
|
|
9
|
-
wrapper_default
|
|
10
|
-
} from "./chunk-664ZODQF.js";
|
|
11
|
-
import "./chunk-RJTRUG2J.js";
|
|
12
|
-
import "./chunk-IUUIT4SU.js";
|
|
13
|
-
import "./chunk-34MYV7JD.js";
|
|
14
|
-
|
|
15
|
-
// packages/cli/src/utils/activityLogger.ts
|
|
16
|
-
import http from "node:http";
|
|
17
|
-
import https from "node:https";
|
|
18
|
-
import zlib from "node:zlib";
|
|
19
|
-
import fs from "node:fs";
|
|
20
|
-
import path from "node:path";
|
|
21
|
-
import { EventEmitter } from "node:events";
|
|
22
|
-
var ACTIVITY_ID_HEADER = "x-activity-request-id";
|
|
23
|
-
var MAX_BUFFER_SIZE = 100;
|
|
24
|
-
function isHeaderRecord(h) {
|
|
25
|
-
return !Array.isArray(h);
|
|
26
|
-
}
|
|
27
|
-
function isRequestOptions(value) {
|
|
28
|
-
return typeof value === "object" && value !== null && !(value instanceof URL) && !Array.isArray(value);
|
|
29
|
-
}
|
|
30
|
-
function isIncomingMessageCallback(value) {
|
|
31
|
-
return typeof value === "function";
|
|
32
|
-
}
|
|
33
|
-
function callHttpRequest(originalFn, args) {
|
|
34
|
-
if (args.length === 0) {
|
|
35
|
-
return originalFn({});
|
|
36
|
-
}
|
|
37
|
-
if (args.length === 1) {
|
|
38
|
-
const first = args[0];
|
|
39
|
-
if (typeof first === "string" || first instanceof URL) {
|
|
40
|
-
return originalFn(first);
|
|
41
|
-
}
|
|
42
|
-
if (isRequestOptions(first)) {
|
|
43
|
-
return originalFn(first);
|
|
44
|
-
}
|
|
45
|
-
return originalFn({});
|
|
46
|
-
}
|
|
47
|
-
if (args.length === 2) {
|
|
48
|
-
const first = args[0];
|
|
49
|
-
const second = args[1];
|
|
50
|
-
if (typeof first === "string" || first instanceof URL) {
|
|
51
|
-
if (isIncomingMessageCallback(second)) {
|
|
52
|
-
return originalFn(first, second);
|
|
53
|
-
}
|
|
54
|
-
if (isRequestOptions(second)) {
|
|
55
|
-
return originalFn(first, second);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
if (isRequestOptions(first) && isIncomingMessageCallback(second)) {
|
|
59
|
-
return originalFn(first, second);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
if (args.length === 3) {
|
|
63
|
-
const first = args[0];
|
|
64
|
-
const second = args[1];
|
|
65
|
-
const third = args[2];
|
|
66
|
-
if ((typeof first === "string" || first instanceof URL) && isRequestOptions(second) && isIncomingMessageCallback(third)) {
|
|
67
|
-
return originalFn(first, second, third);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
return originalFn({});
|
|
71
|
-
}
|
|
72
|
-
var ActivityLogger = class _ActivityLogger extends EventEmitter {
|
|
73
|
-
static instance;
|
|
74
|
-
isInterceptionEnabled = false;
|
|
75
|
-
requestStartTimes = /* @__PURE__ */ new Map();
|
|
76
|
-
networkLoggingEnabled = false;
|
|
77
|
-
networkBufferMap = /* @__PURE__ */ new Map();
|
|
78
|
-
networkBufferIds = [];
|
|
79
|
-
consoleBuffer = [];
|
|
80
|
-
bufferLimit = 10;
|
|
81
|
-
static getInstance() {
|
|
82
|
-
if (!_ActivityLogger.instance) {
|
|
83
|
-
_ActivityLogger.instance = new _ActivityLogger();
|
|
84
|
-
}
|
|
85
|
-
return _ActivityLogger.instance;
|
|
86
|
-
}
|
|
87
|
-
enableNetworkLogging() {
|
|
88
|
-
this.networkLoggingEnabled = true;
|
|
89
|
-
this.emit("network-logging-enabled");
|
|
90
|
-
}
|
|
91
|
-
disableNetworkLogging() {
|
|
92
|
-
this.networkLoggingEnabled = false;
|
|
93
|
-
}
|
|
94
|
-
isNetworkLoggingEnabled() {
|
|
95
|
-
return this.networkLoggingEnabled;
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Atomically returns and clears all buffered logs.
|
|
99
|
-
* Prevents data loss from events emitted between get and clear.
|
|
100
|
-
*/
|
|
101
|
-
drainBufferedLogs() {
|
|
102
|
-
const network = [];
|
|
103
|
-
for (const id of this.networkBufferIds) {
|
|
104
|
-
const events = this.networkBufferMap.get(id);
|
|
105
|
-
if (events) network.push(...events);
|
|
106
|
-
}
|
|
107
|
-
const console = [...this.consoleBuffer];
|
|
108
|
-
this.networkBufferMap.clear();
|
|
109
|
-
this.networkBufferIds = [];
|
|
110
|
-
this.consoleBuffer = [];
|
|
111
|
-
return { network, console };
|
|
112
|
-
}
|
|
113
|
-
getBufferedLogs() {
|
|
114
|
-
const network = [];
|
|
115
|
-
for (const id of this.networkBufferIds) {
|
|
116
|
-
const events = this.networkBufferMap.get(id);
|
|
117
|
-
if (events) network.push(...events);
|
|
118
|
-
}
|
|
119
|
-
return {
|
|
120
|
-
network,
|
|
121
|
-
console: [...this.consoleBuffer]
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
clearBufferedLogs() {
|
|
125
|
-
this.networkBufferMap.clear();
|
|
126
|
-
this.networkBufferIds = [];
|
|
127
|
-
this.consoleBuffer = [];
|
|
128
|
-
}
|
|
129
|
-
stringifyHeaders(headers) {
|
|
130
|
-
const result = {};
|
|
131
|
-
if (!headers) return result;
|
|
132
|
-
if (headers instanceof Headers) {
|
|
133
|
-
headers.forEach((v, k) => {
|
|
134
|
-
result[k.toLowerCase()] = v;
|
|
135
|
-
});
|
|
136
|
-
} else if (typeof headers === "object" && headers !== null) {
|
|
137
|
-
for (const [key, val] of Object.entries(headers)) {
|
|
138
|
-
result[key.toLowerCase()] = Array.isArray(val) ? val.join(", ") : String(val);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
return result;
|
|
142
|
-
}
|
|
143
|
-
sanitizeNetworkLog(log) {
|
|
144
|
-
if (!log || typeof log !== "object") return log;
|
|
145
|
-
const sanitized = { ...log };
|
|
146
|
-
if ("headers" in sanitized && sanitized.headers) {
|
|
147
|
-
const headers = { ...sanitized.headers };
|
|
148
|
-
for (const key of Object.keys(headers)) {
|
|
149
|
-
if (["authorization", "cookie", "x-goog-api-key"].includes(
|
|
150
|
-
key.toLowerCase()
|
|
151
|
-
)) {
|
|
152
|
-
headers[key] = "[REDACTED]";
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
sanitized.headers = headers;
|
|
156
|
-
}
|
|
157
|
-
if ("response" in sanitized && sanitized.response?.headers) {
|
|
158
|
-
const resHeaders = { ...sanitized.response.headers };
|
|
159
|
-
for (const key of Object.keys(resHeaders)) {
|
|
160
|
-
if (["set-cookie"].includes(key.toLowerCase())) {
|
|
161
|
-
resHeaders[key] = "[REDACTED]";
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
sanitized.response = { ...sanitized.response, headers: resHeaders };
|
|
165
|
-
}
|
|
166
|
-
return sanitized;
|
|
167
|
-
}
|
|
168
|
-
/** @internal Emit a network event — public for testing only. */
|
|
169
|
-
emitNetworkEvent(payload) {
|
|
170
|
-
this.safeEmitNetwork(payload);
|
|
171
|
-
}
|
|
172
|
-
safeEmitNetwork(payload) {
|
|
173
|
-
const sanitized = this.sanitizeNetworkLog(payload);
|
|
174
|
-
const id = sanitized.id;
|
|
175
|
-
if (!this.networkBufferMap.has(id)) {
|
|
176
|
-
this.networkBufferIds.push(id);
|
|
177
|
-
this.networkBufferMap.set(id, []);
|
|
178
|
-
if (this.networkBufferIds.length > this.bufferLimit) {
|
|
179
|
-
const evictId = this.networkBufferIds.shift();
|
|
180
|
-
this.networkBufferMap.delete(evictId);
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
this.networkBufferMap.get(id).push(sanitized);
|
|
184
|
-
this.emit("network", sanitized);
|
|
185
|
-
}
|
|
186
|
-
enable() {
|
|
187
|
-
if (this.isInterceptionEnabled) return;
|
|
188
|
-
this.isInterceptionEnabled = true;
|
|
189
|
-
this.patchGlobalFetch();
|
|
190
|
-
this.patchNodeHttp();
|
|
191
|
-
}
|
|
192
|
-
patchGlobalFetch() {
|
|
193
|
-
if (!global.fetch) return;
|
|
194
|
-
const originalFetch = global.fetch;
|
|
195
|
-
global.fetch = async (input, init) => {
|
|
196
|
-
const url = typeof input === "string" ? input : input instanceof URL ? input.toString() : input.url;
|
|
197
|
-
if (url.includes("127.0.0.1") || url.includes("localhost"))
|
|
198
|
-
return originalFetch(input, init);
|
|
199
|
-
const id = Math.random().toString(36).substring(7);
|
|
200
|
-
const method = (init?.method || "GET").toUpperCase();
|
|
201
|
-
const newInit = { ...init };
|
|
202
|
-
const headers = new Headers(init?.headers || {});
|
|
203
|
-
headers.set(ACTIVITY_ID_HEADER, id);
|
|
204
|
-
newInit.headers = headers;
|
|
205
|
-
let reqBody = "";
|
|
206
|
-
if (init?.body) {
|
|
207
|
-
if (typeof init.body === "string") reqBody = init.body;
|
|
208
|
-
else if (init.body instanceof URLSearchParams)
|
|
209
|
-
reqBody = init.body.toString();
|
|
210
|
-
}
|
|
211
|
-
this.requestStartTimes.set(id, Date.now());
|
|
212
|
-
this.safeEmitNetwork({
|
|
213
|
-
id,
|
|
214
|
-
timestamp: Date.now(),
|
|
215
|
-
method,
|
|
216
|
-
url,
|
|
217
|
-
headers: this.stringifyHeaders(newInit.headers),
|
|
218
|
-
body: reqBody,
|
|
219
|
-
pending: true
|
|
220
|
-
});
|
|
221
|
-
try {
|
|
222
|
-
const response = await originalFetch(input, newInit);
|
|
223
|
-
const clonedRes = response.clone();
|
|
224
|
-
if (clonedRes.body) {
|
|
225
|
-
const reader = clonedRes.body.getReader();
|
|
226
|
-
const decoder = new TextDecoder();
|
|
227
|
-
const chunks = [];
|
|
228
|
-
let chunkIndex = 0;
|
|
229
|
-
const readStream = async () => {
|
|
230
|
-
try {
|
|
231
|
-
while (true) {
|
|
232
|
-
const { done, value } = await reader.read();
|
|
233
|
-
if (done) break;
|
|
234
|
-
const chunkData = decoder.decode(value, { stream: true });
|
|
235
|
-
chunks.push(chunkData);
|
|
236
|
-
this.safeEmitNetwork({
|
|
237
|
-
id,
|
|
238
|
-
pending: true,
|
|
239
|
-
chunk: {
|
|
240
|
-
index: chunkIndex++,
|
|
241
|
-
data: chunkData,
|
|
242
|
-
timestamp: Date.now()
|
|
243
|
-
}
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
const startTime = this.requestStartTimes.get(id);
|
|
247
|
-
const durationMs = startTime ? Date.now() - startTime : 0;
|
|
248
|
-
this.requestStartTimes.delete(id);
|
|
249
|
-
this.safeEmitNetwork({
|
|
250
|
-
id,
|
|
251
|
-
pending: false,
|
|
252
|
-
response: {
|
|
253
|
-
status: response.status,
|
|
254
|
-
headers: this.stringifyHeaders(response.headers),
|
|
255
|
-
body: chunks.join(""),
|
|
256
|
-
durationMs
|
|
257
|
-
}
|
|
258
|
-
});
|
|
259
|
-
} catch (err) {
|
|
260
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
261
|
-
this.safeEmitNetwork({
|
|
262
|
-
id,
|
|
263
|
-
pending: false,
|
|
264
|
-
error: `Failed to read response body: ${message}`
|
|
265
|
-
});
|
|
266
|
-
}
|
|
267
|
-
};
|
|
268
|
-
void readStream();
|
|
269
|
-
} else {
|
|
270
|
-
clonedRes.text().then((text) => {
|
|
271
|
-
const startTime = this.requestStartTimes.get(id);
|
|
272
|
-
const durationMs = startTime ? Date.now() - startTime : 0;
|
|
273
|
-
this.requestStartTimes.delete(id);
|
|
274
|
-
this.safeEmitNetwork({
|
|
275
|
-
id,
|
|
276
|
-
pending: false,
|
|
277
|
-
response: {
|
|
278
|
-
status: response.status,
|
|
279
|
-
headers: this.stringifyHeaders(response.headers),
|
|
280
|
-
body: text,
|
|
281
|
-
durationMs
|
|
282
|
-
}
|
|
283
|
-
});
|
|
284
|
-
}).catch((err) => {
|
|
285
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
286
|
-
this.safeEmitNetwork({
|
|
287
|
-
id,
|
|
288
|
-
pending: false,
|
|
289
|
-
error: `Failed to read response body: ${message}`
|
|
290
|
-
});
|
|
291
|
-
});
|
|
292
|
-
}
|
|
293
|
-
return response;
|
|
294
|
-
} catch (err) {
|
|
295
|
-
this.requestStartTimes.delete(id);
|
|
296
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
297
|
-
this.safeEmitNetwork({ id, pending: false, error: message });
|
|
298
|
-
throw err;
|
|
299
|
-
}
|
|
300
|
-
};
|
|
301
|
-
}
|
|
302
|
-
patchNodeHttp() {
|
|
303
|
-
const self = this;
|
|
304
|
-
const originalRequest = http.request;
|
|
305
|
-
const originalHttpsRequest = https.request;
|
|
306
|
-
const wrapRequest = (originalFn, args, protocol) => {
|
|
307
|
-
const firstArg = args[0];
|
|
308
|
-
let options;
|
|
309
|
-
if (typeof firstArg === "string") {
|
|
310
|
-
options = firstArg;
|
|
311
|
-
} else if (firstArg instanceof URL) {
|
|
312
|
-
options = firstArg;
|
|
313
|
-
} else if (firstArg && typeof firstArg === "object") {
|
|
314
|
-
options = isRequestOptions(firstArg) ? firstArg : {};
|
|
315
|
-
} else {
|
|
316
|
-
options = {};
|
|
317
|
-
}
|
|
318
|
-
let url = "";
|
|
319
|
-
if (typeof options === "string") {
|
|
320
|
-
url = options;
|
|
321
|
-
} else if (options instanceof URL) {
|
|
322
|
-
url = options.href;
|
|
323
|
-
} else {
|
|
324
|
-
const href = "href" in options && typeof options.href === "string" ? options.href : "";
|
|
325
|
-
url = href || `${protocol}//${options.hostname || options.host || "localhost"}${options.path || "/"}`;
|
|
326
|
-
}
|
|
327
|
-
if (url.includes("127.0.0.1") || url.includes("localhost")) {
|
|
328
|
-
return callHttpRequest(originalFn, args);
|
|
329
|
-
}
|
|
330
|
-
const rawHeaders = typeof options === "object" && options !== null && !(options instanceof URL) ? options.headers : void 0;
|
|
331
|
-
let headers = {};
|
|
332
|
-
if (rawHeaders && isHeaderRecord(rawHeaders)) {
|
|
333
|
-
headers = rawHeaders;
|
|
334
|
-
}
|
|
335
|
-
if (headers[ACTIVITY_ID_HEADER]) {
|
|
336
|
-
delete headers[ACTIVITY_ID_HEADER];
|
|
337
|
-
return callHttpRequest(originalFn, args);
|
|
338
|
-
}
|
|
339
|
-
const id = Math.random().toString(36).substring(7);
|
|
340
|
-
this.requestStartTimes.set(id, Date.now());
|
|
341
|
-
const req = callHttpRequest(originalFn, args);
|
|
342
|
-
const requestChunks = [];
|
|
343
|
-
const oldWrite = req.write;
|
|
344
|
-
const oldEnd = req.end;
|
|
345
|
-
req.write = function(chunk, ...etc) {
|
|
346
|
-
if (chunk) {
|
|
347
|
-
const arg0 = etc[0];
|
|
348
|
-
const encoding = typeof arg0 === "string" && Buffer.isEncoding(arg0) ? arg0 : void 0;
|
|
349
|
-
requestChunks.push(
|
|
350
|
-
Buffer.isBuffer(chunk) ? chunk : typeof chunk === "string" ? Buffer.from(chunk, encoding) : Buffer.from(
|
|
351
|
-
chunk instanceof Uint8Array ? chunk : String(chunk)
|
|
352
|
-
)
|
|
353
|
-
);
|
|
354
|
-
}
|
|
355
|
-
return oldWrite.apply(this, [chunk, ...etc]);
|
|
356
|
-
};
|
|
357
|
-
req.end = function(chunkOrCb, ...etc) {
|
|
358
|
-
const chunk = typeof chunkOrCb === "function" ? void 0 : chunkOrCb;
|
|
359
|
-
if (chunk) {
|
|
360
|
-
const arg0 = etc[0];
|
|
361
|
-
const encoding = typeof arg0 === "string" && Buffer.isEncoding(arg0) ? arg0 : void 0;
|
|
362
|
-
requestChunks.push(
|
|
363
|
-
Buffer.isBuffer(chunk) ? chunk : typeof chunk === "string" ? Buffer.from(chunk, encoding) : Buffer.from(
|
|
364
|
-
chunk instanceof Uint8Array ? chunk : String(chunk)
|
|
365
|
-
)
|
|
366
|
-
);
|
|
367
|
-
}
|
|
368
|
-
const body = Buffer.concat(requestChunks).toString("utf8");
|
|
369
|
-
self.safeEmitNetwork({
|
|
370
|
-
id,
|
|
371
|
-
timestamp: Date.now(),
|
|
372
|
-
method: req.method || "GET",
|
|
373
|
-
url,
|
|
374
|
-
headers: self.stringifyHeaders(req.getHeaders()),
|
|
375
|
-
body,
|
|
376
|
-
pending: true
|
|
377
|
-
});
|
|
378
|
-
return oldEnd.apply(this, [chunkOrCb, ...etc]);
|
|
379
|
-
};
|
|
380
|
-
req.on("response", (res) => {
|
|
381
|
-
const responseChunks = [];
|
|
382
|
-
let chunkIndex = 0;
|
|
383
|
-
res.on("data", (chunk) => {
|
|
384
|
-
const chunkBuffer = Buffer.from(chunk);
|
|
385
|
-
responseChunks.push(chunkBuffer);
|
|
386
|
-
self.safeEmitNetwork({
|
|
387
|
-
id,
|
|
388
|
-
pending: true,
|
|
389
|
-
chunk: {
|
|
390
|
-
index: chunkIndex++,
|
|
391
|
-
data: chunkBuffer.toString("utf8"),
|
|
392
|
-
timestamp: Date.now()
|
|
393
|
-
}
|
|
394
|
-
});
|
|
395
|
-
});
|
|
396
|
-
res.on("end", () => {
|
|
397
|
-
const buffer = Buffer.concat(responseChunks);
|
|
398
|
-
const encoding = res.headers["content-encoding"];
|
|
399
|
-
const processBuffer = (finalBuffer) => {
|
|
400
|
-
const resBody = finalBuffer.toString("utf8");
|
|
401
|
-
const startTime = self.requestStartTimes.get(id);
|
|
402
|
-
const durationMs = startTime ? Date.now() - startTime : 0;
|
|
403
|
-
self.requestStartTimes.delete(id);
|
|
404
|
-
self.safeEmitNetwork({
|
|
405
|
-
id,
|
|
406
|
-
pending: false,
|
|
407
|
-
response: {
|
|
408
|
-
status: res.statusCode || 0,
|
|
409
|
-
headers: self.stringifyHeaders(res.headers),
|
|
410
|
-
body: resBody,
|
|
411
|
-
durationMs
|
|
412
|
-
}
|
|
413
|
-
});
|
|
414
|
-
};
|
|
415
|
-
if (encoding === "gzip") {
|
|
416
|
-
zlib.gunzip(buffer, (err, decompressed) => {
|
|
417
|
-
processBuffer(err ? buffer : decompressed);
|
|
418
|
-
});
|
|
419
|
-
} else if (encoding === "deflate") {
|
|
420
|
-
zlib.inflate(buffer, (err, decompressed) => {
|
|
421
|
-
processBuffer(err ? buffer : decompressed);
|
|
422
|
-
});
|
|
423
|
-
} else {
|
|
424
|
-
processBuffer(buffer);
|
|
425
|
-
}
|
|
426
|
-
});
|
|
427
|
-
});
|
|
428
|
-
req.on("error", (err) => {
|
|
429
|
-
self.requestStartTimes.delete(id);
|
|
430
|
-
const message = err.message;
|
|
431
|
-
self.safeEmitNetwork({
|
|
432
|
-
id,
|
|
433
|
-
pending: false,
|
|
434
|
-
error: message
|
|
435
|
-
});
|
|
436
|
-
});
|
|
437
|
-
return req;
|
|
438
|
-
};
|
|
439
|
-
Object.defineProperty(http, "request", {
|
|
440
|
-
value: (url, options, callback) => {
|
|
441
|
-
const args = callback !== void 0 ? [url, options, callback] : options !== void 0 ? [url, options] : [url];
|
|
442
|
-
return wrapRequest(originalRequest, args, "http:");
|
|
443
|
-
},
|
|
444
|
-
writable: true,
|
|
445
|
-
configurable: true
|
|
446
|
-
});
|
|
447
|
-
Object.defineProperty(https, "request", {
|
|
448
|
-
value: (url, options, callback) => {
|
|
449
|
-
const args = callback !== void 0 ? [url, options, callback] : options !== void 0 ? [url, options] : [url];
|
|
450
|
-
return wrapRequest(
|
|
451
|
-
originalHttpsRequest,
|
|
452
|
-
args,
|
|
453
|
-
"https:"
|
|
454
|
-
);
|
|
455
|
-
},
|
|
456
|
-
writable: true,
|
|
457
|
-
configurable: true
|
|
458
|
-
});
|
|
459
|
-
}
|
|
460
|
-
logConsole(payload) {
|
|
461
|
-
const enriched = { ...payload, timestamp: Date.now() };
|
|
462
|
-
this.consoleBuffer.push(enriched);
|
|
463
|
-
if (this.consoleBuffer.length > this.bufferLimit) {
|
|
464
|
-
this.consoleBuffer.shift();
|
|
465
|
-
}
|
|
466
|
-
this.emit("console", enriched);
|
|
467
|
-
}
|
|
468
|
-
};
|
|
469
|
-
function setupFileLogging(capture, config, customPath) {
|
|
470
|
-
const logFile = customPath || (config.storage ? path.join(
|
|
471
|
-
config.storage.getProjectTempLogsDir(),
|
|
472
|
-
`session-${config.getSessionId()}.jsonl`
|
|
473
|
-
) : null);
|
|
474
|
-
if (!logFile) return;
|
|
475
|
-
const logsDir = path.dirname(logFile);
|
|
476
|
-
if (!fs.existsSync(logsDir)) {
|
|
477
|
-
fs.mkdirSync(logsDir, { recursive: true });
|
|
478
|
-
}
|
|
479
|
-
const writeToLog = (type, payload) => {
|
|
480
|
-
try {
|
|
481
|
-
const entry = JSON.stringify({
|
|
482
|
-
type,
|
|
483
|
-
payload,
|
|
484
|
-
sessionId: config.getSessionId(),
|
|
485
|
-
timestamp: Date.now()
|
|
486
|
-
}) + "\n";
|
|
487
|
-
fs.promises.appendFile(logFile, entry).catch((err) => {
|
|
488
|
-
debugLogger.error("Failed to write to activity log:", err);
|
|
489
|
-
});
|
|
490
|
-
} catch (err) {
|
|
491
|
-
debugLogger.error("Failed to prepare activity log entry:", err);
|
|
492
|
-
}
|
|
493
|
-
};
|
|
494
|
-
capture.on("console", (payload) => writeToLog("console", payload));
|
|
495
|
-
capture.on("network", (payload) => writeToLog("network", payload));
|
|
496
|
-
}
|
|
497
|
-
function setupNetworkLogging(capture, host, port, config, onReconnectFailed) {
|
|
498
|
-
const transportBuffer = [];
|
|
499
|
-
let ws = null;
|
|
500
|
-
let reconnectTimer = null;
|
|
501
|
-
let sessionId = null;
|
|
502
|
-
let pingInterval = null;
|
|
503
|
-
let reconnectAttempts = 0;
|
|
504
|
-
const MAX_RECONNECT_ATTEMPTS = 2;
|
|
505
|
-
const connect = () => {
|
|
506
|
-
try {
|
|
507
|
-
ws = new wrapper_default(`ws://${host}:${port}/ws`);
|
|
508
|
-
ws.on("open", () => {
|
|
509
|
-
debugLogger.debug(`WebSocket connected to ${host}:${port}`);
|
|
510
|
-
reconnectAttempts = 0;
|
|
511
|
-
sendMessage({
|
|
512
|
-
type: "register",
|
|
513
|
-
sessionId: config.getSessionId(),
|
|
514
|
-
timestamp: Date.now()
|
|
515
|
-
});
|
|
516
|
-
});
|
|
517
|
-
ws.on("message", (data) => {
|
|
518
|
-
try {
|
|
519
|
-
const parsed = JSON.parse(data.toString());
|
|
520
|
-
if (typeof parsed === "object" && parsed !== null && "type" in parsed && typeof parsed.type === "string") {
|
|
521
|
-
handleServerMessage({
|
|
522
|
-
type: parsed.type,
|
|
523
|
-
sessionId: "sessionId" in parsed && typeof parsed.sessionId === "string" ? parsed.sessionId : void 0
|
|
524
|
-
});
|
|
525
|
-
}
|
|
526
|
-
} catch (err) {
|
|
527
|
-
debugLogger.debug("Invalid WebSocket message:", err);
|
|
528
|
-
}
|
|
529
|
-
});
|
|
530
|
-
ws.on("close", () => {
|
|
531
|
-
debugLogger.debug(`WebSocket disconnected from ${host}:${port}`);
|
|
532
|
-
cleanup();
|
|
533
|
-
scheduleReconnect();
|
|
534
|
-
});
|
|
535
|
-
ws.on("error", (err) => {
|
|
536
|
-
debugLogger.debug(`WebSocket error:`, err);
|
|
537
|
-
});
|
|
538
|
-
} catch (err) {
|
|
539
|
-
debugLogger.debug(`Failed to connect WebSocket:`, err);
|
|
540
|
-
scheduleReconnect();
|
|
541
|
-
}
|
|
542
|
-
};
|
|
543
|
-
const handleServerMessage = (message) => {
|
|
544
|
-
switch (message.type) {
|
|
545
|
-
case "registered":
|
|
546
|
-
sessionId = message.sessionId || null;
|
|
547
|
-
debugLogger.debug(`WebSocket session registered: ${sessionId}`);
|
|
548
|
-
if (pingInterval) clearInterval(pingInterval);
|
|
549
|
-
pingInterval = setInterval(() => {
|
|
550
|
-
sendMessage({ type: "pong", timestamp: Date.now() });
|
|
551
|
-
}, 15e3);
|
|
552
|
-
flushBuffer();
|
|
553
|
-
break;
|
|
554
|
-
case "ping":
|
|
555
|
-
sendMessage({ type: "pong", timestamp: Date.now() });
|
|
556
|
-
break;
|
|
557
|
-
default:
|
|
558
|
-
break;
|
|
559
|
-
}
|
|
560
|
-
};
|
|
561
|
-
const sendMessage = (message) => {
|
|
562
|
-
if (ws && ws.readyState === wrapper_default.OPEN) {
|
|
563
|
-
ws.send(JSON.stringify(message));
|
|
564
|
-
}
|
|
565
|
-
};
|
|
566
|
-
const sendToNetwork = (type, payload) => {
|
|
567
|
-
const message = {
|
|
568
|
-
type,
|
|
569
|
-
payload,
|
|
570
|
-
sessionId: sessionId || config.getSessionId(),
|
|
571
|
-
timestamp: Date.now()
|
|
572
|
-
};
|
|
573
|
-
if (!ws || ws.readyState !== wrapper_default.OPEN || !capture.isNetworkLoggingEnabled()) {
|
|
574
|
-
transportBuffer.push(message);
|
|
575
|
-
if (transportBuffer.length > MAX_BUFFER_SIZE) transportBuffer.shift();
|
|
576
|
-
return;
|
|
577
|
-
}
|
|
578
|
-
sendMessage(message);
|
|
579
|
-
};
|
|
580
|
-
const flushBuffer = () => {
|
|
581
|
-
if (!ws || ws.readyState !== wrapper_default.OPEN || !capture.isNetworkLoggingEnabled()) {
|
|
582
|
-
return;
|
|
583
|
-
}
|
|
584
|
-
const { network, console: consoleLogs } = capture.drainBufferedLogs();
|
|
585
|
-
const allInitialLogs = [
|
|
586
|
-
...network.map((l) => ({
|
|
587
|
-
type: "network",
|
|
588
|
-
payload: l,
|
|
589
|
-
timestamp: "timestamp" in l && l.timestamp ? l.timestamp : Date.now()
|
|
590
|
-
})),
|
|
591
|
-
...consoleLogs.map((l) => ({
|
|
592
|
-
type: "console",
|
|
593
|
-
payload: l,
|
|
594
|
-
timestamp: l.timestamp
|
|
595
|
-
}))
|
|
596
|
-
].sort((a, b) => a.timestamp - b.timestamp);
|
|
597
|
-
debugLogger.debug(
|
|
598
|
-
`Flushing ${allInitialLogs.length} initial buffered logs and ${transportBuffer.length} transport buffered logs...`
|
|
599
|
-
);
|
|
600
|
-
for (const log of allInitialLogs) {
|
|
601
|
-
sendMessage({
|
|
602
|
-
type: log.type,
|
|
603
|
-
payload: log.payload,
|
|
604
|
-
sessionId: sessionId || config.getSessionId(),
|
|
605
|
-
timestamp: Date.now()
|
|
606
|
-
});
|
|
607
|
-
}
|
|
608
|
-
while (transportBuffer.length > 0) {
|
|
609
|
-
const message = transportBuffer.shift();
|
|
610
|
-
sendMessage(message);
|
|
611
|
-
}
|
|
612
|
-
};
|
|
613
|
-
const cleanup = () => {
|
|
614
|
-
if (pingInterval) {
|
|
615
|
-
clearInterval(pingInterval);
|
|
616
|
-
pingInterval = null;
|
|
617
|
-
}
|
|
618
|
-
ws = null;
|
|
619
|
-
};
|
|
620
|
-
const scheduleReconnect = () => {
|
|
621
|
-
if (reconnectTimer) return;
|
|
622
|
-
reconnectAttempts++;
|
|
623
|
-
if (reconnectAttempts > MAX_RECONNECT_ATTEMPTS && onReconnectFailed) {
|
|
624
|
-
debugLogger.debug(
|
|
625
|
-
`WebSocket reconnect failed after ${MAX_RECONNECT_ATTEMPTS} attempts, promoting to server...`
|
|
626
|
-
);
|
|
627
|
-
onReconnectFailed();
|
|
628
|
-
return;
|
|
629
|
-
}
|
|
630
|
-
reconnectTimer = setTimeout(() => {
|
|
631
|
-
reconnectTimer = null;
|
|
632
|
-
debugLogger.debug("Reconnecting WebSocket...");
|
|
633
|
-
connect();
|
|
634
|
-
}, 1e3);
|
|
635
|
-
};
|
|
636
|
-
connect();
|
|
637
|
-
capture.on("console", (payload) => sendToNetwork("console", payload));
|
|
638
|
-
capture.on("network", (payload) => sendToNetwork("network", payload));
|
|
639
|
-
capture.on("network-logging-enabled", () => {
|
|
640
|
-
debugLogger.debug("Network logging enabled, flushing buffer...");
|
|
641
|
-
flushBuffer();
|
|
642
|
-
});
|
|
643
|
-
process.on("exit", () => {
|
|
644
|
-
if (reconnectTimer) clearTimeout(reconnectTimer);
|
|
645
|
-
if (ws) ws.close();
|
|
646
|
-
cleanup();
|
|
647
|
-
});
|
|
648
|
-
}
|
|
649
|
-
var bridgeAttached = false;
|
|
650
|
-
function bridgeCoreEvents(capture) {
|
|
651
|
-
if (bridgeAttached) return;
|
|
652
|
-
bridgeAttached = true;
|
|
653
|
-
coreEvents.on(CoreEvent.ConsoleLog, (payload) => {
|
|
654
|
-
capture.logConsole(payload);
|
|
655
|
-
});
|
|
656
|
-
}
|
|
657
|
-
function initActivityLogger(config, options) {
|
|
658
|
-
const capture = ActivityLogger.getInstance();
|
|
659
|
-
capture.enable();
|
|
660
|
-
if (options.mode === "network") {
|
|
661
|
-
setupNetworkLogging(
|
|
662
|
-
capture,
|
|
663
|
-
options.host,
|
|
664
|
-
options.port,
|
|
665
|
-
config,
|
|
666
|
-
options.onReconnectFailed
|
|
667
|
-
);
|
|
668
|
-
capture.enableNetworkLogging();
|
|
669
|
-
} else if (options.mode === "file") {
|
|
670
|
-
setupFileLogging(capture, config, options.filePath);
|
|
671
|
-
}
|
|
672
|
-
bridgeCoreEvents(capture);
|
|
673
|
-
}
|
|
674
|
-
function addNetworkTransport(config, host, port, onReconnectFailed) {
|
|
675
|
-
const capture = ActivityLogger.getInstance();
|
|
676
|
-
setupNetworkLogging(capture, host, port, config, onReconnectFailed);
|
|
677
|
-
}
|
|
678
|
-
|
|
679
|
-
// packages/cli/src/utils/devtoolsService.ts
|
|
680
|
-
var DEFAULT_DEVTOOLS_PORT = 25417;
|
|
681
|
-
var DEFAULT_DEVTOOLS_HOST = "127.0.0.1";
|
|
682
|
-
var MAX_PROMOTION_ATTEMPTS = 3;
|
|
683
|
-
var promotionAttempts = 0;
|
|
684
|
-
var serverStartPromise = null;
|
|
685
|
-
var connectedUrl = null;
|
|
686
|
-
function probeDevTools(host, port) {
|
|
687
|
-
return new Promise((resolve) => {
|
|
688
|
-
const ws = new wrapper_default(`ws://${host}:${port}/ws`);
|
|
689
|
-
const timer = setTimeout(() => {
|
|
690
|
-
ws.close();
|
|
691
|
-
resolve(false);
|
|
692
|
-
}, 500);
|
|
693
|
-
ws.on("open", () => {
|
|
694
|
-
clearTimeout(timer);
|
|
695
|
-
ws.close();
|
|
696
|
-
resolve(true);
|
|
697
|
-
});
|
|
698
|
-
ws.on("error", () => {
|
|
699
|
-
clearTimeout(timer);
|
|
700
|
-
ws.close();
|
|
701
|
-
resolve(false);
|
|
702
|
-
});
|
|
703
|
-
});
|
|
704
|
-
}
|
|
705
|
-
async function startOrJoinDevTools(defaultHost, defaultPort) {
|
|
706
|
-
const mod = await import("@google/gemini-cli-devtools");
|
|
707
|
-
const devtools = mod.DevTools.getInstance();
|
|
708
|
-
const url = await devtools.start();
|
|
709
|
-
const actualPort = devtools.getPort();
|
|
710
|
-
if (actualPort === defaultPort) {
|
|
711
|
-
debugLogger.log(`DevTools available at: ${url}`);
|
|
712
|
-
return { host: defaultHost, port: actualPort };
|
|
713
|
-
}
|
|
714
|
-
const winnerAlive = await probeDevTools(defaultHost, defaultPort);
|
|
715
|
-
if (winnerAlive) {
|
|
716
|
-
await devtools.stop();
|
|
717
|
-
debugLogger.log(
|
|
718
|
-
`DevTools (existing) at: http://${defaultHost}:${defaultPort}`
|
|
719
|
-
);
|
|
720
|
-
return { host: defaultHost, port: defaultPort };
|
|
721
|
-
}
|
|
722
|
-
debugLogger.log(`DevTools available at: ${url}`);
|
|
723
|
-
return { host: defaultHost, port: actualPort };
|
|
724
|
-
}
|
|
725
|
-
async function handlePromotion(config) {
|
|
726
|
-
promotionAttempts++;
|
|
727
|
-
if (promotionAttempts > MAX_PROMOTION_ATTEMPTS) {
|
|
728
|
-
debugLogger.debug(
|
|
729
|
-
`Giving up on DevTools promotion after ${MAX_PROMOTION_ATTEMPTS} attempts`
|
|
730
|
-
);
|
|
731
|
-
return;
|
|
732
|
-
}
|
|
733
|
-
try {
|
|
734
|
-
const result = await startOrJoinDevTools(
|
|
735
|
-
DEFAULT_DEVTOOLS_HOST,
|
|
736
|
-
DEFAULT_DEVTOOLS_PORT
|
|
737
|
-
);
|
|
738
|
-
addNetworkTransport(
|
|
739
|
-
config,
|
|
740
|
-
result.host,
|
|
741
|
-
result.port,
|
|
742
|
-
() => handlePromotion(config)
|
|
743
|
-
);
|
|
744
|
-
} catch (err) {
|
|
745
|
-
debugLogger.debug("Failed to promote to DevTools server:", err);
|
|
746
|
-
}
|
|
747
|
-
}
|
|
748
|
-
async function setupInitialActivityLogger(config) {
|
|
749
|
-
const target = process.env["GEMINI_CLI_ACTIVITY_LOG_TARGET"];
|
|
750
|
-
if (target) {
|
|
751
|
-
if (!config.storage) return;
|
|
752
|
-
initActivityLogger(config, { mode: "file", filePath: target });
|
|
753
|
-
} else {
|
|
754
|
-
initActivityLogger(config, { mode: "buffer" });
|
|
755
|
-
try {
|
|
756
|
-
const existing = await probeDevTools(
|
|
757
|
-
DEFAULT_DEVTOOLS_HOST,
|
|
758
|
-
DEFAULT_DEVTOOLS_PORT
|
|
759
|
-
);
|
|
760
|
-
if (existing) {
|
|
761
|
-
const onReconnectFailed = () => handlePromotion(config);
|
|
762
|
-
addNetworkTransport(
|
|
763
|
-
config,
|
|
764
|
-
DEFAULT_DEVTOOLS_HOST,
|
|
765
|
-
DEFAULT_DEVTOOLS_PORT,
|
|
766
|
-
onReconnectFailed
|
|
767
|
-
);
|
|
768
|
-
ActivityLogger.getInstance().enableNetworkLogging();
|
|
769
|
-
connectedUrl = `http://localhost:${DEFAULT_DEVTOOLS_PORT}`;
|
|
770
|
-
debugLogger.log(`DevTools (existing) at startup: ${connectedUrl}`);
|
|
771
|
-
}
|
|
772
|
-
} catch {
|
|
773
|
-
}
|
|
774
|
-
}
|
|
775
|
-
}
|
|
776
|
-
function startDevToolsServer(config) {
|
|
777
|
-
if (connectedUrl) return Promise.resolve(connectedUrl);
|
|
778
|
-
if (serverStartPromise) return serverStartPromise;
|
|
779
|
-
serverStartPromise = startDevToolsServerImpl(config).catch((err) => {
|
|
780
|
-
serverStartPromise = null;
|
|
781
|
-
throw err;
|
|
782
|
-
});
|
|
783
|
-
return serverStartPromise;
|
|
784
|
-
}
|
|
785
|
-
async function startDevToolsServerImpl(config) {
|
|
786
|
-
const onReconnectFailed = () => handlePromotion(config);
|
|
787
|
-
const existing = await probeDevTools(
|
|
788
|
-
DEFAULT_DEVTOOLS_HOST,
|
|
789
|
-
DEFAULT_DEVTOOLS_PORT
|
|
790
|
-
);
|
|
791
|
-
let host = DEFAULT_DEVTOOLS_HOST;
|
|
792
|
-
let port = DEFAULT_DEVTOOLS_PORT;
|
|
793
|
-
if (existing) {
|
|
794
|
-
debugLogger.log(
|
|
795
|
-
`DevTools (existing) at: http://${DEFAULT_DEVTOOLS_HOST}:${DEFAULT_DEVTOOLS_PORT}`
|
|
796
|
-
);
|
|
797
|
-
} else {
|
|
798
|
-
try {
|
|
799
|
-
const result = await startOrJoinDevTools(
|
|
800
|
-
DEFAULT_DEVTOOLS_HOST,
|
|
801
|
-
DEFAULT_DEVTOOLS_PORT
|
|
802
|
-
);
|
|
803
|
-
host = result.host;
|
|
804
|
-
port = result.port;
|
|
805
|
-
} catch (err) {
|
|
806
|
-
debugLogger.debug("Failed to start DevTools:", err);
|
|
807
|
-
throw err;
|
|
808
|
-
}
|
|
809
|
-
}
|
|
810
|
-
addNetworkTransport(config, host, port, onReconnectFailed);
|
|
811
|
-
const capture = ActivityLogger.getInstance();
|
|
812
|
-
capture.enableNetworkLogging();
|
|
813
|
-
const url = `http://localhost:${port}`;
|
|
814
|
-
connectedUrl = url;
|
|
815
|
-
return url;
|
|
816
|
-
}
|
|
817
|
-
async function toggleDevToolsPanel(config, isOpen, toggle, setOpen) {
|
|
818
|
-
if (isOpen) {
|
|
819
|
-
toggle();
|
|
820
|
-
return;
|
|
821
|
-
}
|
|
822
|
-
try {
|
|
823
|
-
const { openBrowserSecurely, shouldLaunchBrowser } = await import("./dist-SWQPYLLV.js");
|
|
824
|
-
const url = await startDevToolsServer(config);
|
|
825
|
-
if (shouldLaunchBrowser()) {
|
|
826
|
-
try {
|
|
827
|
-
await openBrowserSecurely(url);
|
|
828
|
-
return;
|
|
829
|
-
} catch (e) {
|
|
830
|
-
debugLogger.warn("Failed to open browser securely:", e);
|
|
831
|
-
}
|
|
832
|
-
}
|
|
833
|
-
setOpen();
|
|
834
|
-
} catch (e) {
|
|
835
|
-
setOpen();
|
|
836
|
-
debugLogger.error("Failed to start DevTools server:", e);
|
|
837
|
-
}
|
|
838
|
-
}
|
|
839
|
-
function resetForTesting() {
|
|
840
|
-
promotionAttempts = 0;
|
|
841
|
-
serverStartPromise = null;
|
|
842
|
-
connectedUrl = null;
|
|
843
|
-
}
|
|
844
|
-
export {
|
|
845
|
-
resetForTesting,
|
|
846
|
-
setupInitialActivityLogger,
|
|
847
|
-
startDevToolsServer,
|
|
848
|
-
toggleDevToolsPanel
|
|
849
|
-
};
|
|
850
|
-
/**
|
|
851
|
-
* @license
|
|
852
|
-
* Copyright 2025 Google LLC
|
|
853
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
854
|
-
*/
|