adhdev 0.8.57 → 0.8.59
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/index.js +1884 -669
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +995 -424
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/vendor/session-host-daemon/index.d.mts +1 -0
- package/vendor/session-host-daemon/index.d.ts +1 -0
- package/vendor/session-host-daemon/index.js +10 -1
- package/vendor/session-host-daemon/index.js.map +1 -1
- package/vendor/session-host-daemon/index.mjs +10 -1
- package/vendor/session-host-daemon/index.mjs.map +1 -1
package/dist/index.js
CHANGED
|
@@ -44,9 +44,16 @@ __export(config_exports, {
|
|
|
44
44
|
loadConfig: () => loadConfig,
|
|
45
45
|
markSetupComplete: () => markSetupComplete,
|
|
46
46
|
resetConfig: () => resetConfig,
|
|
47
|
+
resolveProviderSourceMode: () => resolveProviderSourceMode,
|
|
47
48
|
saveConfig: () => saveConfig,
|
|
48
49
|
updateConfig: () => updateConfig
|
|
49
50
|
});
|
|
51
|
+
function resolveProviderSourceMode(providerSourceMode, legacyDisableUpstream) {
|
|
52
|
+
if (providerSourceMode === "normal" || providerSourceMode === "no-upstream") {
|
|
53
|
+
return providerSourceMode;
|
|
54
|
+
}
|
|
55
|
+
return legacyDisableUpstream === true ? "no-upstream" : "normal";
|
|
56
|
+
}
|
|
50
57
|
function isPlainObject(value) {
|
|
51
58
|
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
52
59
|
}
|
|
@@ -84,7 +91,7 @@ function normalizeConfig(raw) {
|
|
|
84
91
|
registeredMachineId: asOptionalString(parsed.registeredMachineId),
|
|
85
92
|
providerSettings: isPlainObject(parsed.providerSettings) ? parsed.providerSettings : {},
|
|
86
93
|
ideSettings: isPlainObject(parsed.ideSettings) ? parsed.ideSettings : {},
|
|
87
|
-
|
|
94
|
+
providerSourceMode: resolveProviderSourceMode(parsed.providerSourceMode, parsed.disableUpstream),
|
|
88
95
|
providerDir: asOptionalString(parsed.providerDir),
|
|
89
96
|
terminalSizingMode: parsed.terminalSizingMode === "fit" ? "fit" : "measured"
|
|
90
97
|
};
|
|
@@ -233,7 +240,7 @@ var init_config = __esm({
|
|
|
233
240
|
registeredMachineId: void 0,
|
|
234
241
|
providerSettings: {},
|
|
235
242
|
ideSettings: {},
|
|
236
|
-
|
|
243
|
+
providerSourceMode: "normal",
|
|
237
244
|
terminalSizingMode: "measured"
|
|
238
245
|
};
|
|
239
246
|
MACHINE_ID_PREFIX = "mach_";
|
|
@@ -412,6 +419,73 @@ var init_workspaces = __esm({
|
|
|
412
419
|
}
|
|
413
420
|
});
|
|
414
421
|
|
|
422
|
+
// ../../oss/packages/daemon-core/src/providers/summary-metadata.ts
|
|
423
|
+
function normalizeSummaryItem(item) {
|
|
424
|
+
if (!item || typeof item !== "object") return null;
|
|
425
|
+
const id = String(item.id || "").trim();
|
|
426
|
+
const value = String(item.value || "").trim();
|
|
427
|
+
if (!id || !value) return null;
|
|
428
|
+
const normalized = {
|
|
429
|
+
id,
|
|
430
|
+
value
|
|
431
|
+
};
|
|
432
|
+
if (typeof item.label === "string" && item.label.trim()) normalized.label = item.label.trim();
|
|
433
|
+
if (typeof item.shortValue === "string" && item.shortValue.trim()) normalized.shortValue = item.shortValue.trim();
|
|
434
|
+
if (typeof item.icon === "string" && item.icon.trim()) normalized.icon = item.icon.trim();
|
|
435
|
+
if (typeof item.order === "number" && Number.isFinite(item.order)) normalized.order = item.order;
|
|
436
|
+
return normalized;
|
|
437
|
+
}
|
|
438
|
+
function normalizeProviderSummaryMetadata(summary) {
|
|
439
|
+
if (!summary || !Array.isArray(summary.items)) return void 0;
|
|
440
|
+
const items = summary.items.map((item) => normalizeSummaryItem(item)).filter((item) => !!item).sort((left2, right2) => {
|
|
441
|
+
const orderDiff = (left2.order ?? Number.MAX_SAFE_INTEGER) - (right2.order ?? Number.MAX_SAFE_INTEGER);
|
|
442
|
+
if (orderDiff !== 0) return orderDiff;
|
|
443
|
+
return left2.id.localeCompare(right2.id);
|
|
444
|
+
});
|
|
445
|
+
return items.length > 0 ? { items } : void 0;
|
|
446
|
+
}
|
|
447
|
+
function buildProviderSummaryMetadata(items) {
|
|
448
|
+
return normalizeProviderSummaryMetadata({ items: items.filter(Boolean) });
|
|
449
|
+
}
|
|
450
|
+
function buildLegacyModelModeSummaryMetadata(params) {
|
|
451
|
+
return buildProviderSummaryMetadata([
|
|
452
|
+
params.model ? {
|
|
453
|
+
id: "model",
|
|
454
|
+
label: "Model",
|
|
455
|
+
value: String(params.modelLabel || params.model).trim(),
|
|
456
|
+
shortValue: String(params.model).trim(),
|
|
457
|
+
order: 10
|
|
458
|
+
} : null,
|
|
459
|
+
params.mode ? {
|
|
460
|
+
id: "mode",
|
|
461
|
+
label: "Mode",
|
|
462
|
+
value: String(params.modeLabel || params.mode).trim(),
|
|
463
|
+
shortValue: String(params.mode).trim(),
|
|
464
|
+
order: 20
|
|
465
|
+
} : null
|
|
466
|
+
]);
|
|
467
|
+
}
|
|
468
|
+
function resolveProviderStateSummaryMetadata(params) {
|
|
469
|
+
const explicit = normalizeProviderSummaryMetadata(params.summaryMetadata);
|
|
470
|
+
if (explicit) return explicit;
|
|
471
|
+
const model = typeof params.controlValues?.model === "string" ? params.controlValues.model : void 0;
|
|
472
|
+
const mode = typeof params.controlValues?.mode === "string" ? params.controlValues.mode : void 0;
|
|
473
|
+
return buildLegacyModelModeSummaryMetadata({
|
|
474
|
+
model,
|
|
475
|
+
mode,
|
|
476
|
+
modelLabel: params.modelLabel,
|
|
477
|
+
modeLabel: params.modeLabel
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
function normalizePersistedSummaryMetadata(params) {
|
|
481
|
+
return normalizeProviderSummaryMetadata(params.summaryMetadata);
|
|
482
|
+
}
|
|
483
|
+
var init_summary_metadata = __esm({
|
|
484
|
+
"../../oss/packages/daemon-core/src/providers/summary-metadata.ts"() {
|
|
485
|
+
"use strict";
|
|
486
|
+
}
|
|
487
|
+
});
|
|
488
|
+
|
|
415
489
|
// ../../oss/packages/daemon-core/src/config/recent-activity.ts
|
|
416
490
|
function normalizeWorkspace(workspace) {
|
|
417
491
|
if (!workspace) return "";
|
|
@@ -435,6 +509,9 @@ function appendRecentActivity(state, entry) {
|
|
|
435
509
|
const nextEntry = {
|
|
436
510
|
...entry,
|
|
437
511
|
workspace: entry.workspace ? normalizeWorkspace(entry.workspace) : void 0,
|
|
512
|
+
summaryMetadata: normalizePersistedSummaryMetadata({
|
|
513
|
+
summaryMetadata: entry.summaryMetadata
|
|
514
|
+
}),
|
|
438
515
|
id: buildRecentActivityKeyForEntry(entry),
|
|
439
516
|
lastUsedAt: entry.lastUsedAt || Date.now()
|
|
440
517
|
};
|
|
@@ -445,7 +522,12 @@ function appendRecentActivity(state, entry) {
|
|
|
445
522
|
};
|
|
446
523
|
}
|
|
447
524
|
function getRecentActivity(state, limit = 20) {
|
|
448
|
-
return [...state.recentActivity || []].
|
|
525
|
+
return [...state.recentActivity || []].map((entry) => ({
|
|
526
|
+
...entry,
|
|
527
|
+
summaryMetadata: normalizePersistedSummaryMetadata({
|
|
528
|
+
summaryMetadata: entry.summaryMetadata
|
|
529
|
+
})
|
|
530
|
+
})).sort((a, b) => b.lastUsedAt - a.lastUsedAt).slice(0, limit);
|
|
449
531
|
}
|
|
450
532
|
function getSessionSeenAt(state, sessionId) {
|
|
451
533
|
return state.sessionReads?.[sessionId] || 0;
|
|
@@ -476,6 +558,7 @@ var init_recent_activity = __esm({
|
|
|
476
558
|
"use strict";
|
|
477
559
|
path2 = __toESM(require("path"));
|
|
478
560
|
init_workspaces();
|
|
561
|
+
init_summary_metadata();
|
|
479
562
|
MAX_ACTIVITY = 30;
|
|
480
563
|
}
|
|
481
564
|
});
|
|
@@ -504,7 +587,9 @@ function upsertSavedProviderSession(state, entry) {
|
|
|
504
587
|
providerName: entry.providerName,
|
|
505
588
|
providerSessionId,
|
|
506
589
|
workspace: entry.workspace ? normalizeWorkspace2(entry.workspace) : void 0,
|
|
507
|
-
|
|
590
|
+
summaryMetadata: normalizePersistedSummaryMetadata({
|
|
591
|
+
summaryMetadata: entry.summaryMetadata
|
|
592
|
+
}),
|
|
508
593
|
title: entry.title,
|
|
509
594
|
createdAt: existing?.createdAt || entry.createdAt || Date.now(),
|
|
510
595
|
lastUsedAt: entry.lastUsedAt || Date.now()
|
|
@@ -520,7 +605,12 @@ function getSavedProviderSessions(state, filters) {
|
|
|
520
605
|
if (filters?.providerType && entry.providerType !== filters.providerType) return false;
|
|
521
606
|
if (filters?.kind && entry.kind !== filters.kind) return false;
|
|
522
607
|
return true;
|
|
523
|
-
}).
|
|
608
|
+
}).map((entry) => ({
|
|
609
|
+
...entry,
|
|
610
|
+
summaryMetadata: normalizePersistedSummaryMetadata({
|
|
611
|
+
summaryMetadata: entry.summaryMetadata
|
|
612
|
+
})
|
|
613
|
+
})).sort((a, b) => b.lastUsedAt - a.lastUsedAt);
|
|
524
614
|
}
|
|
525
615
|
var path3, MAX_SAVED_SESSIONS;
|
|
526
616
|
var init_saved_sessions = __esm({
|
|
@@ -528,6 +618,7 @@ var init_saved_sessions = __esm({
|
|
|
528
618
|
"use strict";
|
|
529
619
|
path3 = __toESM(require("path"));
|
|
530
620
|
init_workspaces();
|
|
621
|
+
init_summary_metadata();
|
|
531
622
|
MAX_SAVED_SESSIONS = 500;
|
|
532
623
|
}
|
|
533
624
|
});
|
|
@@ -733,15 +824,15 @@ function resolveCommandPath(command) {
|
|
|
733
824
|
return null;
|
|
734
825
|
}
|
|
735
826
|
function execAsync(cmd, timeoutMs = 5e3) {
|
|
736
|
-
return new Promise((
|
|
827
|
+
return new Promise((resolve15) => {
|
|
737
828
|
const child = (0, import_child_process2.exec)(cmd, { encoding: "utf-8", timeout: timeoutMs }, (err, stdout) => {
|
|
738
829
|
if (err || !stdout?.trim()) {
|
|
739
|
-
|
|
830
|
+
resolve15(null);
|
|
740
831
|
} else {
|
|
741
|
-
|
|
832
|
+
resolve15(stdout.trim());
|
|
742
833
|
}
|
|
743
834
|
});
|
|
744
|
-
child.on("error", () =>
|
|
835
|
+
child.on("error", () => resolve15(null));
|
|
745
836
|
});
|
|
746
837
|
}
|
|
747
838
|
async function detectCLIs(providerLoader, options) {
|
|
@@ -1187,7 +1278,7 @@ var init_manager = __esm({
|
|
|
1187
1278
|
* Returns multiple entries if multiple IDE windows are open on same port
|
|
1188
1279
|
*/
|
|
1189
1280
|
static listAllTargets(port) {
|
|
1190
|
-
return new Promise((
|
|
1281
|
+
return new Promise((resolve15) => {
|
|
1191
1282
|
const req = http.get(`http://127.0.0.1:${port}/json`, (res) => {
|
|
1192
1283
|
let data = "";
|
|
1193
1284
|
res.on("data", (chunk) => data += chunk.toString());
|
|
@@ -1203,16 +1294,16 @@ var init_manager = __esm({
|
|
|
1203
1294
|
(t) => !isNonMain(t.title || "") && t.url?.includes("workbench.html") && !t.url?.includes("agent")
|
|
1204
1295
|
);
|
|
1205
1296
|
const fallbackPages = pages.filter((t) => !isNonMain(t.title || ""));
|
|
1206
|
-
|
|
1297
|
+
resolve15(mainPages.length > 0 ? mainPages : fallbackPages);
|
|
1207
1298
|
} catch {
|
|
1208
|
-
|
|
1299
|
+
resolve15([]);
|
|
1209
1300
|
}
|
|
1210
1301
|
});
|
|
1211
1302
|
});
|
|
1212
|
-
req.on("error", () =>
|
|
1303
|
+
req.on("error", () => resolve15([]));
|
|
1213
1304
|
req.setTimeout(2e3, () => {
|
|
1214
1305
|
req.destroy();
|
|
1215
|
-
|
|
1306
|
+
resolve15([]);
|
|
1216
1307
|
});
|
|
1217
1308
|
});
|
|
1218
1309
|
}
|
|
@@ -1252,7 +1343,7 @@ var init_manager = __esm({
|
|
|
1252
1343
|
}
|
|
1253
1344
|
}
|
|
1254
1345
|
findTargetOnPort(port) {
|
|
1255
|
-
return new Promise((
|
|
1346
|
+
return new Promise((resolve15) => {
|
|
1256
1347
|
const req = http.get(`http://127.0.0.1:${port}/json`, (res) => {
|
|
1257
1348
|
let data = "";
|
|
1258
1349
|
res.on("data", (chunk) => data += chunk.toString());
|
|
@@ -1263,7 +1354,7 @@ var init_manager = __esm({
|
|
|
1263
1354
|
(t) => (t.type === "page" || t.type === "browser" || t.type === "Page") && t.webSocketDebuggerUrl
|
|
1264
1355
|
);
|
|
1265
1356
|
if (pages.length === 0) {
|
|
1266
|
-
|
|
1357
|
+
resolve15(targets.find((t) => t.webSocketDebuggerUrl) || null);
|
|
1267
1358
|
return;
|
|
1268
1359
|
}
|
|
1269
1360
|
const mainPages = pages.filter((t) => !this.isNonMainTitle(t.title || ""));
|
|
@@ -1273,24 +1364,24 @@ var init_manager = __esm({
|
|
|
1273
1364
|
const specific = list.find((t) => t.id === this._targetId);
|
|
1274
1365
|
if (specific) {
|
|
1275
1366
|
this._pageTitle = specific.title || "";
|
|
1276
|
-
|
|
1367
|
+
resolve15(specific);
|
|
1277
1368
|
} else {
|
|
1278
1369
|
this.log(`[CDP] Target ${this._targetId} not found in page list`);
|
|
1279
|
-
|
|
1370
|
+
resolve15(null);
|
|
1280
1371
|
}
|
|
1281
1372
|
return;
|
|
1282
1373
|
}
|
|
1283
1374
|
this._pageTitle = list[0]?.title || "";
|
|
1284
|
-
|
|
1375
|
+
resolve15(list[0]);
|
|
1285
1376
|
} catch {
|
|
1286
|
-
|
|
1377
|
+
resolve15(null);
|
|
1287
1378
|
}
|
|
1288
1379
|
});
|
|
1289
1380
|
});
|
|
1290
|
-
req.on("error", () =>
|
|
1381
|
+
req.on("error", () => resolve15(null));
|
|
1291
1382
|
req.setTimeout(2e3, () => {
|
|
1292
1383
|
req.destroy();
|
|
1293
|
-
|
|
1384
|
+
resolve15(null);
|
|
1294
1385
|
});
|
|
1295
1386
|
});
|
|
1296
1387
|
}
|
|
@@ -1301,7 +1392,7 @@ var init_manager = __esm({
|
|
|
1301
1392
|
this.extensionProviders = providers;
|
|
1302
1393
|
}
|
|
1303
1394
|
connectToTarget(wsUrl) {
|
|
1304
|
-
return new Promise((
|
|
1395
|
+
return new Promise((resolve15) => {
|
|
1305
1396
|
this.ws = new import_ws.default(wsUrl);
|
|
1306
1397
|
this.ws.on("open", async () => {
|
|
1307
1398
|
this._connected = true;
|
|
@@ -1311,17 +1402,17 @@ var init_manager = __esm({
|
|
|
1311
1402
|
}
|
|
1312
1403
|
this.connectBrowserWs().catch(() => {
|
|
1313
1404
|
});
|
|
1314
|
-
|
|
1405
|
+
resolve15(true);
|
|
1315
1406
|
});
|
|
1316
1407
|
this.ws.on("message", (data) => {
|
|
1317
1408
|
try {
|
|
1318
1409
|
const msg = JSON.parse(data.toString());
|
|
1319
1410
|
if (msg.id && this.pending.has(msg.id)) {
|
|
1320
|
-
const { resolve:
|
|
1411
|
+
const { resolve: resolve16, reject } = this.pending.get(msg.id);
|
|
1321
1412
|
this.pending.delete(msg.id);
|
|
1322
1413
|
this.failureCount = 0;
|
|
1323
1414
|
if (msg.error) reject(new Error(msg.error.message));
|
|
1324
|
-
else
|
|
1415
|
+
else resolve16(msg.result);
|
|
1325
1416
|
} else if (msg.method === "Runtime.executionContextCreated") {
|
|
1326
1417
|
this.contexts.add(msg.params.context.id);
|
|
1327
1418
|
} else if (msg.method === "Runtime.executionContextDestroyed") {
|
|
@@ -1344,7 +1435,7 @@ var init_manager = __esm({
|
|
|
1344
1435
|
this.ws.on("error", (err) => {
|
|
1345
1436
|
this.log(`[CDP] WebSocket error: ${err.message}`);
|
|
1346
1437
|
this._connected = false;
|
|
1347
|
-
|
|
1438
|
+
resolve15(false);
|
|
1348
1439
|
});
|
|
1349
1440
|
});
|
|
1350
1441
|
}
|
|
@@ -1358,7 +1449,7 @@ var init_manager = __esm({
|
|
|
1358
1449
|
return;
|
|
1359
1450
|
}
|
|
1360
1451
|
this.log(`[CDP] Connecting browser WS for target discovery...`);
|
|
1361
|
-
await new Promise((
|
|
1452
|
+
await new Promise((resolve15, reject) => {
|
|
1362
1453
|
this.browserWs = new import_ws.default(browserWsUrl);
|
|
1363
1454
|
this.browserWs.on("open", async () => {
|
|
1364
1455
|
this._browserConnected = true;
|
|
@@ -1368,16 +1459,16 @@ var init_manager = __esm({
|
|
|
1368
1459
|
} catch (e) {
|
|
1369
1460
|
this.log(`[CDP] setDiscoverTargets failed: ${e.message}`);
|
|
1370
1461
|
}
|
|
1371
|
-
|
|
1462
|
+
resolve15();
|
|
1372
1463
|
});
|
|
1373
1464
|
this.browserWs.on("message", (data) => {
|
|
1374
1465
|
try {
|
|
1375
1466
|
const msg = JSON.parse(data.toString());
|
|
1376
1467
|
if (msg.id && this.browserPending.has(msg.id)) {
|
|
1377
|
-
const { resolve:
|
|
1468
|
+
const { resolve: resolve16, reject: reject2 } = this.browserPending.get(msg.id);
|
|
1378
1469
|
this.browserPending.delete(msg.id);
|
|
1379
1470
|
if (msg.error) reject2(new Error(msg.error.message));
|
|
1380
|
-
else
|
|
1471
|
+
else resolve16(msg.result);
|
|
1381
1472
|
}
|
|
1382
1473
|
} catch {
|
|
1383
1474
|
}
|
|
@@ -1397,31 +1488,31 @@ var init_manager = __esm({
|
|
|
1397
1488
|
}
|
|
1398
1489
|
}
|
|
1399
1490
|
getBrowserWsUrl() {
|
|
1400
|
-
return new Promise((
|
|
1491
|
+
return new Promise((resolve15) => {
|
|
1401
1492
|
const req = http.get(`http://127.0.0.1:${this.port}/json/version`, (res) => {
|
|
1402
1493
|
let data = "";
|
|
1403
1494
|
res.on("data", (chunk) => data += chunk.toString());
|
|
1404
1495
|
res.on("end", () => {
|
|
1405
1496
|
try {
|
|
1406
1497
|
const info = JSON.parse(data);
|
|
1407
|
-
|
|
1498
|
+
resolve15(info.webSocketDebuggerUrl || null);
|
|
1408
1499
|
} catch {
|
|
1409
|
-
|
|
1500
|
+
resolve15(null);
|
|
1410
1501
|
}
|
|
1411
1502
|
});
|
|
1412
1503
|
});
|
|
1413
|
-
req.on("error", () =>
|
|
1504
|
+
req.on("error", () => resolve15(null));
|
|
1414
1505
|
req.setTimeout(3e3, () => {
|
|
1415
1506
|
req.destroy();
|
|
1416
|
-
|
|
1507
|
+
resolve15(null);
|
|
1417
1508
|
});
|
|
1418
1509
|
});
|
|
1419
1510
|
}
|
|
1420
1511
|
sendBrowser(method, params = {}, timeoutMs = 15e3) {
|
|
1421
|
-
return new Promise((
|
|
1512
|
+
return new Promise((resolve15, reject) => {
|
|
1422
1513
|
if (!this.browserWs || !this._browserConnected) return reject(new Error("Browser WS not connected"));
|
|
1423
1514
|
const id = this.browserMsgId++;
|
|
1424
|
-
this.browserPending.set(id, { resolve:
|
|
1515
|
+
this.browserPending.set(id, { resolve: resolve15, reject });
|
|
1425
1516
|
this.browserWs.send(JSON.stringify({ id, method, params }));
|
|
1426
1517
|
setTimeout(() => {
|
|
1427
1518
|
if (this.browserPending.has(id)) {
|
|
@@ -1461,11 +1552,11 @@ var init_manager = __esm({
|
|
|
1461
1552
|
}
|
|
1462
1553
|
// ─── CDP Protocol ────────────────────────────────────────
|
|
1463
1554
|
sendInternal(method, params = {}, timeoutMs = 15e3) {
|
|
1464
|
-
return new Promise((
|
|
1555
|
+
return new Promise((resolve15, reject) => {
|
|
1465
1556
|
if (!this.ws || !this._connected) return reject(new Error("CDP not connected"));
|
|
1466
1557
|
if (this.ws.readyState !== import_ws.default.OPEN) return reject(new Error("WebSocket not open"));
|
|
1467
1558
|
const id = this.msgId++;
|
|
1468
|
-
this.pending.set(id, { resolve:
|
|
1559
|
+
this.pending.set(id, { resolve: resolve15, reject });
|
|
1469
1560
|
this.ws.send(JSON.stringify({ id, method, params }));
|
|
1470
1561
|
setTimeout(() => {
|
|
1471
1562
|
if (this.pending.has(id)) {
|
|
@@ -1714,7 +1805,7 @@ var init_manager = __esm({
|
|
|
1714
1805
|
const browserWs = this.browserWs;
|
|
1715
1806
|
let msgId = this.browserMsgId;
|
|
1716
1807
|
const sendWs = (method, params = {}, sessionId) => {
|
|
1717
|
-
return new Promise((
|
|
1808
|
+
return new Promise((resolve15, reject) => {
|
|
1718
1809
|
const mid = msgId++;
|
|
1719
1810
|
this.browserMsgId = msgId;
|
|
1720
1811
|
const handler = (raw) => {
|
|
@@ -1723,7 +1814,7 @@ var init_manager = __esm({
|
|
|
1723
1814
|
if (msg.id === mid) {
|
|
1724
1815
|
browserWs.removeListener("message", handler);
|
|
1725
1816
|
if (msg.error) reject(new Error(msg.error.message || JSON.stringify(msg.error)));
|
|
1726
|
-
else
|
|
1817
|
+
else resolve15(msg.result);
|
|
1727
1818
|
}
|
|
1728
1819
|
} catch {
|
|
1729
1820
|
}
|
|
@@ -1924,14 +2015,14 @@ var init_manager = __esm({
|
|
|
1924
2015
|
if (!ws || ws.readyState !== import_ws.default.OPEN) {
|
|
1925
2016
|
throw new Error("CDP not connected");
|
|
1926
2017
|
}
|
|
1927
|
-
return new Promise((
|
|
2018
|
+
return new Promise((resolve15, reject) => {
|
|
1928
2019
|
const id = getNextId();
|
|
1929
2020
|
pendingMap.set(id, {
|
|
1930
2021
|
resolve: (result) => {
|
|
1931
2022
|
if (result?.result?.subtype === "error") {
|
|
1932
2023
|
reject(new Error(result.result.description));
|
|
1933
2024
|
} else {
|
|
1934
|
-
|
|
2025
|
+
resolve15(result?.result?.value);
|
|
1935
2026
|
}
|
|
1936
2027
|
},
|
|
1937
2028
|
reject
|
|
@@ -1963,10 +2054,10 @@ var init_manager = __esm({
|
|
|
1963
2054
|
throw new Error("CDP not connected");
|
|
1964
2055
|
}
|
|
1965
2056
|
const sendViaSession = (method, params = {}) => {
|
|
1966
|
-
return new Promise((
|
|
2057
|
+
return new Promise((resolve15, reject) => {
|
|
1967
2058
|
const pendingMap = this._browserConnected ? this.browserPending : this.pending;
|
|
1968
2059
|
const id = this._browserConnected ? this.browserMsgId++ : this.msgId++;
|
|
1969
|
-
pendingMap.set(id, { resolve:
|
|
2060
|
+
pendingMap.set(id, { resolve: resolve15, reject });
|
|
1970
2061
|
ws.send(JSON.stringify({ id, sessionId, method, params }));
|
|
1971
2062
|
setTimeout(() => {
|
|
1972
2063
|
if (pendingMap.has(id)) {
|
|
@@ -2540,8 +2631,6 @@ function extractProviderControlValues(controls, data) {
|
|
|
2540
2631
|
if (rawValue === void 0 || rawValue === null) continue;
|
|
2541
2632
|
values[ctrl.id] = normalizeControlValue(rawValue);
|
|
2542
2633
|
}
|
|
2543
|
-
if (data.model !== void 0 && values.model === void 0) values.model = normalizeControlValue(data.model);
|
|
2544
|
-
if (data.mode !== void 0 && values.mode === void 0) values.mode = normalizeControlValue(data.mode);
|
|
2545
2634
|
return Object.keys(values).length > 0 ? values : void 0;
|
|
2546
2635
|
}
|
|
2547
2636
|
function normalizeProviderEffects(data) {
|
|
@@ -2643,7 +2732,7 @@ function normalizeControlOption(option) {
|
|
|
2643
2732
|
}
|
|
2644
2733
|
if (!option || typeof option !== "object") return null;
|
|
2645
2734
|
const record2 = option;
|
|
2646
|
-
const value = typeof record2.value === "string" ? record2.value : typeof record2.id === "string" ? record2.id : null;
|
|
2735
|
+
const value = typeof record2.value === "string" ? record2.value : typeof record2.id === "string" ? record2.id : typeof record2.name === "string" ? record2.name : null;
|
|
2647
2736
|
if (!value) return null;
|
|
2648
2737
|
const label = typeof record2.label === "string" ? record2.label : typeof record2.name === "string" ? record2.name : value;
|
|
2649
2738
|
const normalized = { value, label };
|
|
@@ -2801,6 +2890,7 @@ function listSavedHistorySessions(agentType, options = {}) {
|
|
|
2801
2890
|
let lastMessageAt = 0;
|
|
2802
2891
|
let sessionTitle = "";
|
|
2803
2892
|
let preview = "";
|
|
2893
|
+
let workspace = "";
|
|
2804
2894
|
for (const file2 of files.sort()) {
|
|
2805
2895
|
const filePath = path7.join(dir, file2);
|
|
2806
2896
|
const content = fs3.readFileSync(filePath, "utf-8");
|
|
@@ -2813,6 +2903,10 @@ function listSavedHistorySessions(agentType, options = {}) {
|
|
|
2813
2903
|
parsed = null;
|
|
2814
2904
|
}
|
|
2815
2905
|
if (!parsed || parsed.historySessionId !== historySessionId) continue;
|
|
2906
|
+
if (parsed.kind === "session_start") {
|
|
2907
|
+
if (!workspace && parsed.workspace) workspace = parsed.workspace;
|
|
2908
|
+
continue;
|
|
2909
|
+
}
|
|
2816
2910
|
messageCount += 1;
|
|
2817
2911
|
if (!firstMessageAt || parsed.receivedAt < firstMessageAt) firstMessageAt = parsed.receivedAt;
|
|
2818
2912
|
if (!lastMessageAt || parsed.receivedAt > lastMessageAt) lastMessageAt = parsed.receivedAt;
|
|
@@ -2827,7 +2921,8 @@ function listSavedHistorySessions(agentType, options = {}) {
|
|
|
2827
2921
|
messageCount,
|
|
2828
2922
|
firstMessageAt,
|
|
2829
2923
|
lastMessageAt,
|
|
2830
|
-
preview: preview || void 0
|
|
2924
|
+
preview: preview || void 0,
|
|
2925
|
+
workspace: workspace || void 0
|
|
2831
2926
|
});
|
|
2832
2927
|
}
|
|
2833
2928
|
summaries.sort((a, b) => b.lastMessageAt - a.lastMessageAt);
|
|
@@ -3010,6 +3105,30 @@ var init_chat_history = __esm({
|
|
|
3010
3105
|
options.historySessionId
|
|
3011
3106
|
);
|
|
3012
3107
|
}
|
|
3108
|
+
writeSessionStart(agentType, historySessionId, workspace, instanceId) {
|
|
3109
|
+
const id = String(historySessionId || "").trim();
|
|
3110
|
+
const ws = String(workspace || "").trim();
|
|
3111
|
+
if (!id || !ws) return;
|
|
3112
|
+
try {
|
|
3113
|
+
const dir = path7.join(HISTORY_DIR, this.sanitize(agentType));
|
|
3114
|
+
fs3.mkdirSync(dir, { recursive: true });
|
|
3115
|
+
const date5 = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
3116
|
+
const filePath = path7.join(dir, `${this.sanitize(id)}_${date5}.jsonl`);
|
|
3117
|
+
const record2 = {
|
|
3118
|
+
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3119
|
+
receivedAt: Date.now(),
|
|
3120
|
+
role: "system",
|
|
3121
|
+
kind: "session_start",
|
|
3122
|
+
content: ws,
|
|
3123
|
+
agent: agentType,
|
|
3124
|
+
instanceId,
|
|
3125
|
+
historySessionId: id,
|
|
3126
|
+
workspace: ws
|
|
3127
|
+
};
|
|
3128
|
+
fs3.appendFileSync(filePath, JSON.stringify(record2) + "\n", "utf-8");
|
|
3129
|
+
} catch {
|
|
3130
|
+
}
|
|
3131
|
+
}
|
|
3013
3132
|
promoteHistorySession(agentType, previousHistorySessionId, nextHistorySessionId) {
|
|
3014
3133
|
const fromId = String(previousHistorySessionId || "").trim();
|
|
3015
3134
|
const toId = String(nextHistorySessionId || "").trim();
|
|
@@ -3159,6 +3278,68 @@ var init_chat_history = __esm({
|
|
|
3159
3278
|
}
|
|
3160
3279
|
});
|
|
3161
3280
|
|
|
3281
|
+
// ../../oss/packages/daemon-core/src/providers/provider-patch-state.ts
|
|
3282
|
+
function isControlValue(value) {
|
|
3283
|
+
return typeof value === "string" || typeof value === "number" || typeof value === "boolean";
|
|
3284
|
+
}
|
|
3285
|
+
function asControlValueMap(value) {
|
|
3286
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
|
|
3287
|
+
const result = {};
|
|
3288
|
+
for (const [entryKey, entryValue] of Object.entries(value)) {
|
|
3289
|
+
if (isControlValue(entryValue)) result[entryKey] = entryValue;
|
|
3290
|
+
}
|
|
3291
|
+
return Object.keys(result).length > 0 ? result : void 0;
|
|
3292
|
+
}
|
|
3293
|
+
function getLegacyModelModeValues(data) {
|
|
3294
|
+
if (!data || typeof data !== "object") return void 0;
|
|
3295
|
+
const legacy = {};
|
|
3296
|
+
if (typeof data.model === "string" && data.model.trim()) legacy.model = data.model.trim();
|
|
3297
|
+
if (typeof data.mode === "string" && data.mode.trim()) legacy.mode = data.mode.trim();
|
|
3298
|
+
return Object.keys(legacy).length > 0 ? legacy : void 0;
|
|
3299
|
+
}
|
|
3300
|
+
function mergeProviderPatchState(params) {
|
|
3301
|
+
const {
|
|
3302
|
+
providerControls,
|
|
3303
|
+
data,
|
|
3304
|
+
currentControlValues,
|
|
3305
|
+
currentSummaryMetadata,
|
|
3306
|
+
mergeWithCurrent = true
|
|
3307
|
+
} = params;
|
|
3308
|
+
const sources = [
|
|
3309
|
+
mergeWithCurrent ? asControlValueMap(currentControlValues) : void 0,
|
|
3310
|
+
asControlValueMap(data?.controlValues),
|
|
3311
|
+
asControlValueMap(extractProviderControlValues(providerControls, data)),
|
|
3312
|
+
getLegacyModelModeValues(data)
|
|
3313
|
+
];
|
|
3314
|
+
const controlValues = Object.assign({}, ...sources.filter(Boolean));
|
|
3315
|
+
return {
|
|
3316
|
+
controlValues,
|
|
3317
|
+
summaryMetadata: data?.summaryMetadata !== void 0 ? data.summaryMetadata : currentSummaryMetadata
|
|
3318
|
+
};
|
|
3319
|
+
}
|
|
3320
|
+
function normalizeProviderStateControlValues(controlValues) {
|
|
3321
|
+
return controlValues && Object.keys(controlValues).length > 0 ? controlValues : void 0;
|
|
3322
|
+
}
|
|
3323
|
+
function resolveProviderStateSurface(params) {
|
|
3324
|
+
const controlValues = normalizeProviderStateControlValues(params.controlValues);
|
|
3325
|
+
return {
|
|
3326
|
+
controlValues,
|
|
3327
|
+
summaryMetadata: resolveProviderStateSummaryMetadata({
|
|
3328
|
+
summaryMetadata: params.summaryMetadata,
|
|
3329
|
+
controlValues,
|
|
3330
|
+
modelLabel: params.modelLabel,
|
|
3331
|
+
modeLabel: params.modeLabel
|
|
3332
|
+
})
|
|
3333
|
+
};
|
|
3334
|
+
}
|
|
3335
|
+
var init_provider_patch_state = __esm({
|
|
3336
|
+
"../../oss/packages/daemon-core/src/providers/provider-patch-state.ts"() {
|
|
3337
|
+
"use strict";
|
|
3338
|
+
init_control_effects();
|
|
3339
|
+
init_summary_metadata();
|
|
3340
|
+
}
|
|
3341
|
+
});
|
|
3342
|
+
|
|
3162
3343
|
// ../../oss/packages/daemon-core/src/providers/extension-provider-instance.ts
|
|
3163
3344
|
var ExtensionProviderInstance;
|
|
3164
3345
|
var init_extension_provider_instance = __esm({
|
|
@@ -3167,6 +3348,7 @@ var init_extension_provider_instance = __esm({
|
|
|
3167
3348
|
init_status_monitor();
|
|
3168
3349
|
init_control_effects();
|
|
3169
3350
|
init_chat_history();
|
|
3351
|
+
init_provider_patch_state();
|
|
3170
3352
|
ExtensionProviderInstance = class {
|
|
3171
3353
|
type;
|
|
3172
3354
|
category = "extension";
|
|
@@ -3180,9 +3362,8 @@ var init_extension_provider_instance = __esm({
|
|
|
3180
3362
|
messages = [];
|
|
3181
3363
|
prevMessageHashes = /* @__PURE__ */ new Map();
|
|
3182
3364
|
activeModal = null;
|
|
3183
|
-
currentModel = "";
|
|
3184
|
-
currentMode = "";
|
|
3185
3365
|
controlValues = {};
|
|
3366
|
+
summaryMetadata = void 0;
|
|
3186
3367
|
appliedEffectKeys = /* @__PURE__ */ new Set();
|
|
3187
3368
|
runtimeMessages = [];
|
|
3188
3369
|
lastAgentStatus = "idle";
|
|
@@ -3217,6 +3398,10 @@ var init_extension_provider_instance = __esm({
|
|
|
3217
3398
|
if (!this.context?.cdp?.isConnected) return;
|
|
3218
3399
|
}
|
|
3219
3400
|
getState() {
|
|
3401
|
+
const surface = resolveProviderStateSurface({
|
|
3402
|
+
summaryMetadata: this.summaryMetadata,
|
|
3403
|
+
controlValues: this.controlValues
|
|
3404
|
+
});
|
|
3220
3405
|
return {
|
|
3221
3406
|
type: this.type,
|
|
3222
3407
|
name: this.provider.name,
|
|
@@ -3230,10 +3415,9 @@ var init_extension_provider_instance = __esm({
|
|
|
3230
3415
|
activeModal: this.activeModal,
|
|
3231
3416
|
inputContent: ""
|
|
3232
3417
|
} : null,
|
|
3233
|
-
|
|
3234
|
-
currentPlan: this.currentMode || void 0,
|
|
3235
|
-
controlValues: this.controlValues,
|
|
3418
|
+
controlValues: surface.controlValues,
|
|
3236
3419
|
providerControls: this.provider.controls,
|
|
3420
|
+
summaryMetadata: surface.summaryMetadata,
|
|
3237
3421
|
agentStreams: this.agentStreams,
|
|
3238
3422
|
instanceId: this.instanceId,
|
|
3239
3423
|
lastUpdated: Date.now(),
|
|
@@ -3246,10 +3430,14 @@ var init_extension_provider_instance = __esm({
|
|
|
3246
3430
|
if (data?.streams) this.agentStreams = data.streams;
|
|
3247
3431
|
if (data?.messages) this.messages = this.assignReceivedAt(data.messages);
|
|
3248
3432
|
if (data?.activeModal !== void 0) this.activeModal = data.activeModal;
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3433
|
+
const patchedState = mergeProviderPatchState({
|
|
3434
|
+
providerControls: this.provider.controls,
|
|
3435
|
+
data,
|
|
3436
|
+
currentControlValues: this.controlValues,
|
|
3437
|
+
currentSummaryMetadata: this.summaryMetadata
|
|
3438
|
+
});
|
|
3439
|
+
this.controlValues = patchedState.controlValues;
|
|
3440
|
+
this.summaryMetadata = patchedState.summaryMetadata;
|
|
3253
3441
|
if (typeof data?.sessionId === "string" && data.sessionId.trim()) this.chatId = data.sessionId;
|
|
3254
3442
|
if (typeof data?.title === "string" && data.title.trim()) this.chatTitle = data.title;
|
|
3255
3443
|
if (typeof data?.agentName === "string" && data.agentName.trim()) this.agentName = data.agentName;
|
|
@@ -3350,8 +3538,14 @@ var init_extension_provider_instance = __esm({
|
|
|
3350
3538
|
}
|
|
3351
3539
|
applyProviderResponse(data, options) {
|
|
3352
3540
|
if (!data || typeof data !== "object") return;
|
|
3353
|
-
const
|
|
3354
|
-
|
|
3541
|
+
const patchedState = mergeProviderPatchState({
|
|
3542
|
+
providerControls: this.provider.controls,
|
|
3543
|
+
data,
|
|
3544
|
+
currentControlValues: this.controlValues,
|
|
3545
|
+
currentSummaryMetadata: this.summaryMetadata
|
|
3546
|
+
});
|
|
3547
|
+
this.controlValues = patchedState.controlValues;
|
|
3548
|
+
this.summaryMetadata = patchedState.summaryMetadata;
|
|
3355
3549
|
const effects = normalizeProviderEffects(data);
|
|
3356
3550
|
for (const effect of effects) {
|
|
3357
3551
|
const effectWhen = effect.when || "immediate";
|
|
@@ -3501,8 +3695,6 @@ ${effect.notification.body || ""}`.trim();
|
|
|
3501
3695
|
this.messages = [];
|
|
3502
3696
|
this.prevMessageHashes.clear();
|
|
3503
3697
|
this.activeModal = null;
|
|
3504
|
-
this.currentModel = "";
|
|
3505
|
-
this.currentMode = "";
|
|
3506
3698
|
this.controlValues = {};
|
|
3507
3699
|
this.currentStatus = "idle";
|
|
3508
3700
|
this.chatId = null;
|
|
@@ -3582,6 +3774,7 @@ var init_ide_provider_instance = __esm({
|
|
|
3582
3774
|
init_logger();
|
|
3583
3775
|
init_control_effects();
|
|
3584
3776
|
init_approval_utils();
|
|
3777
|
+
init_provider_patch_state();
|
|
3585
3778
|
IdeProviderInstance = class {
|
|
3586
3779
|
type;
|
|
3587
3780
|
category = "ide";
|
|
@@ -3654,6 +3847,10 @@ var init_ide_provider_instance = __esm({
|
|
|
3654
3847
|
for (const ext of this.extensions.values()) {
|
|
3655
3848
|
extensionStates.push(ext.getState());
|
|
3656
3849
|
}
|
|
3850
|
+
const surface = resolveProviderStateSurface({
|
|
3851
|
+
summaryMetadata: this.cachedChat?.summaryMetadata,
|
|
3852
|
+
controlValues: this.cachedChat?.controlValues
|
|
3853
|
+
});
|
|
3657
3854
|
return {
|
|
3658
3855
|
type: this.type,
|
|
3659
3856
|
name: this.provider.name,
|
|
@@ -3670,11 +3867,9 @@ var init_ide_provider_instance = __esm({
|
|
|
3670
3867
|
workspace: this.workspace || null,
|
|
3671
3868
|
extensions: extensionStates,
|
|
3672
3869
|
cdpConnected: cdp?.isConnected || false,
|
|
3673
|
-
|
|
3674
|
-
currentPlan: this.cachedChat?.mode || void 0,
|
|
3675
|
-
currentAutoApprove: this.cachedChat?.autoApprove || void 0,
|
|
3676
|
-
controlValues: this.cachedChat?.controlValues || void 0,
|
|
3870
|
+
controlValues: surface.controlValues,
|
|
3677
3871
|
providerControls: this.provider.controls,
|
|
3872
|
+
summaryMetadata: surface.summaryMetadata,
|
|
3678
3873
|
instanceId: this.instanceId,
|
|
3679
3874
|
lastUpdated: Date.now(),
|
|
3680
3875
|
settings: this.settings,
|
|
@@ -3846,8 +4041,13 @@ var init_ide_provider_instance = __esm({
|
|
|
3846
4041
|
chat.messages = messages.filter((m) => !hiddenKinds.has(m.kind || ""));
|
|
3847
4042
|
}
|
|
3848
4043
|
}
|
|
3849
|
-
const
|
|
3850
|
-
|
|
4044
|
+
const patchedState = mergeProviderPatchState({
|
|
4045
|
+
providerControls: this.provider.controls,
|
|
4046
|
+
data: chat,
|
|
4047
|
+
mergeWithCurrent: false
|
|
4048
|
+
});
|
|
4049
|
+
chat.controlValues = Object.keys(patchedState.controlValues).length > 0 ? patchedState.controlValues : void 0;
|
|
4050
|
+
chat.summaryMetadata = patchedState.summaryMetadata;
|
|
3851
4051
|
this.cachedChat = { ...chat, activeModal };
|
|
3852
4052
|
this.detectAgentTransitions(chat, now);
|
|
3853
4053
|
const persistedMessages = chat.messages || messages;
|
|
@@ -3934,14 +4134,18 @@ var init_ide_provider_instance = __esm({
|
|
|
3934
4134
|
}
|
|
3935
4135
|
applyProviderResponse(data, options) {
|
|
3936
4136
|
if (!data || typeof data !== "object") return;
|
|
3937
|
-
const
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
|
|
3944
|
-
|
|
4137
|
+
const patchedState = mergeProviderPatchState({
|
|
4138
|
+
providerControls: this.provider.controls,
|
|
4139
|
+
data,
|
|
4140
|
+
currentControlValues: this.cachedChat?.controlValues,
|
|
4141
|
+
currentSummaryMetadata: this.cachedChat?.summaryMetadata
|
|
4142
|
+
});
|
|
4143
|
+
this.cachedChat = {
|
|
4144
|
+
...this.cachedChat || {},
|
|
4145
|
+
...data,
|
|
4146
|
+
controlValues: Object.keys(patchedState.controlValues).length > 0 ? patchedState.controlValues : void 0,
|
|
4147
|
+
summaryMetadata: patchedState.summaryMetadata
|
|
4148
|
+
};
|
|
3945
4149
|
const effects = normalizeProviderEffects(data);
|
|
3946
4150
|
for (const effect of effects) {
|
|
3947
4151
|
const effectWhen = effect.when || "immediate";
|
|
@@ -4714,6 +4918,8 @@ function isCdpConnected(cdpManagers, key) {
|
|
|
4714
4918
|
function buildIdeWorkspaceSession(state, cdpManagers, options) {
|
|
4715
4919
|
const profile = options.profile || "full";
|
|
4716
4920
|
const activeChat = normalizeActiveChatData(state.activeChat, getActiveChatOptions(profile));
|
|
4921
|
+
const summaryMetadata = normalizeProviderSummaryMetadata(state.summaryMetadata);
|
|
4922
|
+
const controlValues = normalizeProviderStateControlValues(state.controlValues);
|
|
4717
4923
|
const includeSessionMetadata = shouldIncludeSessionMetadata(profile);
|
|
4718
4924
|
const includeSessionControls = shouldIncludeSessionControls(profile);
|
|
4719
4925
|
const title = activeChat?.title || state.name;
|
|
@@ -4730,13 +4936,11 @@ function buildIdeWorkspaceSession(state, cdpManagers, options) {
|
|
|
4730
4936
|
title,
|
|
4731
4937
|
...includeSessionMetadata && { workspace: state.workspace || null },
|
|
4732
4938
|
activeChat,
|
|
4939
|
+
...summaryMetadata && { summaryMetadata },
|
|
4733
4940
|
...includeSessionMetadata && { capabilities: IDE_SESSION_CAPABILITIES },
|
|
4734
4941
|
cdpConnected: state.cdpConnected ?? isCdpConnected(cdpManagers, state.type),
|
|
4735
|
-
currentModel: state.currentModel,
|
|
4736
|
-
currentPlan: state.currentPlan,
|
|
4737
|
-
currentAutoApprove: state.currentAutoApprove,
|
|
4738
4942
|
...includeSessionControls && {
|
|
4739
|
-
controlValues
|
|
4943
|
+
...controlValues && { controlValues },
|
|
4740
4944
|
providerControls: state.providerControls
|
|
4741
4945
|
},
|
|
4742
4946
|
errorMessage: state.errorMessage,
|
|
@@ -4747,6 +4951,8 @@ function buildIdeWorkspaceSession(state, cdpManagers, options) {
|
|
|
4747
4951
|
function buildExtensionAgentSession(parent, ext, options) {
|
|
4748
4952
|
const profile = options.profile || "full";
|
|
4749
4953
|
const activeChat = normalizeActiveChatData(ext.activeChat, getActiveChatOptions(profile));
|
|
4954
|
+
const summaryMetadata = normalizeProviderSummaryMetadata(ext.summaryMetadata);
|
|
4955
|
+
const controlValues = normalizeProviderStateControlValues(ext.controlValues);
|
|
4750
4956
|
const includeSessionMetadata = shouldIncludeSessionMetadata(profile);
|
|
4751
4957
|
const includeSessionControls = shouldIncludeSessionControls(profile);
|
|
4752
4958
|
return {
|
|
@@ -4762,11 +4968,10 @@ function buildExtensionAgentSession(parent, ext, options) {
|
|
|
4762
4968
|
title: activeChat?.title || ext.name,
|
|
4763
4969
|
...includeSessionMetadata && { workspace: parent.workspace || null },
|
|
4764
4970
|
activeChat,
|
|
4971
|
+
...summaryMetadata && { summaryMetadata },
|
|
4765
4972
|
...includeSessionMetadata && { capabilities: EXTENSION_SESSION_CAPABILITIES },
|
|
4766
|
-
currentModel: ext.currentModel,
|
|
4767
|
-
currentPlan: ext.currentPlan,
|
|
4768
4973
|
...includeSessionControls && {
|
|
4769
|
-
controlValues
|
|
4974
|
+
...controlValues && { controlValues },
|
|
4770
4975
|
providerControls: ext.providerControls
|
|
4771
4976
|
},
|
|
4772
4977
|
errorMessage: ext.errorMessage,
|
|
@@ -4777,6 +4982,8 @@ function buildExtensionAgentSession(parent, ext, options) {
|
|
|
4777
4982
|
function buildCliSession(state, options) {
|
|
4778
4983
|
const profile = options.profile || "full";
|
|
4779
4984
|
const activeChat = normalizeActiveChatData(state.activeChat, getActiveChatOptions(profile));
|
|
4985
|
+
const summaryMetadata = normalizeProviderSummaryMetadata(state.summaryMetadata);
|
|
4986
|
+
const controlValues = normalizeProviderStateControlValues(state.controlValues);
|
|
4780
4987
|
const includeSessionMetadata = shouldIncludeSessionMetadata(profile);
|
|
4781
4988
|
const includeRuntimeMetadata = shouldIncludeRuntimeMetadata(profile);
|
|
4782
4989
|
const includeSessionControls = shouldIncludeSessionControls(profile);
|
|
@@ -4803,11 +5010,12 @@ function buildCliSession(state, options) {
|
|
|
4803
5010
|
mode: state.mode,
|
|
4804
5011
|
resume: state.resume,
|
|
4805
5012
|
activeChat,
|
|
5013
|
+
...summaryMetadata && { summaryMetadata },
|
|
4806
5014
|
...includeSessionMetadata && {
|
|
4807
5015
|
capabilities: state.mode === "terminal" ? PTY_SESSION_CAPABILITIES : CLI_CHAT_SESSION_CAPABILITIES
|
|
4808
5016
|
},
|
|
4809
5017
|
...includeSessionControls && {
|
|
4810
|
-
controlValues
|
|
5018
|
+
...controlValues && { controlValues },
|
|
4811
5019
|
providerControls: state.providerControls
|
|
4812
5020
|
},
|
|
4813
5021
|
errorMessage: state.errorMessage,
|
|
@@ -4818,6 +5026,8 @@ function buildCliSession(state, options) {
|
|
|
4818
5026
|
function buildAcpSession(state, options) {
|
|
4819
5027
|
const profile = options.profile || "full";
|
|
4820
5028
|
const activeChat = normalizeActiveChatData(state.activeChat, getActiveChatOptions(profile));
|
|
5029
|
+
const summaryMetadata = normalizeProviderSummaryMetadata(state.summaryMetadata);
|
|
5030
|
+
const controlValues = normalizeProviderStateControlValues(state.controlValues);
|
|
4821
5031
|
const includeSessionMetadata = shouldIncludeSessionMetadata(profile);
|
|
4822
5032
|
const includeSessionControls = shouldIncludeSessionControls(profile);
|
|
4823
5033
|
return {
|
|
@@ -4833,13 +5043,10 @@ function buildAcpSession(state, options) {
|
|
|
4833
5043
|
title: activeChat?.title || state.name,
|
|
4834
5044
|
...includeSessionMetadata && { workspace: state.workspace || null },
|
|
4835
5045
|
activeChat,
|
|
5046
|
+
...summaryMetadata && { summaryMetadata },
|
|
4836
5047
|
...includeSessionMetadata && { capabilities: ACP_SESSION_CAPABILITIES },
|
|
4837
|
-
currentModel: state.currentModel,
|
|
4838
|
-
currentPlan: state.currentPlan,
|
|
4839
5048
|
...includeSessionControls && {
|
|
4840
|
-
|
|
4841
|
-
acpModes: state.acpModes,
|
|
4842
|
-
controlValues: state.controlValues,
|
|
5049
|
+
...controlValues && { controlValues },
|
|
4843
5050
|
providerControls: state.providerControls
|
|
4844
5051
|
},
|
|
4845
5052
|
errorMessage: state.errorMessage,
|
|
@@ -4879,6 +5086,8 @@ var init_builders = __esm({
|
|
|
4879
5086
|
"../../oss/packages/daemon-core/src/status/builders.ts"() {
|
|
4880
5087
|
"use strict";
|
|
4881
5088
|
init_normalize();
|
|
5089
|
+
init_provider_patch_state();
|
|
5090
|
+
init_summary_metadata();
|
|
4882
5091
|
IDE_SESSION_CAPABILITIES = [
|
|
4883
5092
|
"read_chat",
|
|
4884
5093
|
"send_message",
|
|
@@ -5602,7 +5811,7 @@ function getStateLastSignature(state) {
|
|
|
5602
5811
|
async function getStableExtensionBaseline(h) {
|
|
5603
5812
|
const first = await readExtensionChatState(h);
|
|
5604
5813
|
if (getStateMessageCount(first) > 0 || getStateLastSignature(first)) return first;
|
|
5605
|
-
await new Promise((
|
|
5814
|
+
await new Promise((resolve15) => setTimeout(resolve15, 150));
|
|
5606
5815
|
const second = await readExtensionChatState(h);
|
|
5607
5816
|
return getStateMessageCount(second) >= getStateMessageCount(first) ? second : first;
|
|
5608
5817
|
}
|
|
@@ -5610,7 +5819,7 @@ async function verifyExtensionSendObserved(h, before) {
|
|
|
5610
5819
|
const beforeCount = getStateMessageCount(before);
|
|
5611
5820
|
const beforeSignature = getStateLastSignature(before);
|
|
5612
5821
|
for (let attempt = 0; attempt < 12; attempt += 1) {
|
|
5613
|
-
await new Promise((
|
|
5822
|
+
await new Promise((resolve15) => setTimeout(resolve15, 250));
|
|
5614
5823
|
const state = await readExtensionChatState(h);
|
|
5615
5824
|
if (state?.status === "waiting_approval") return true;
|
|
5616
5825
|
const afterCount = getStateMessageCount(state);
|
|
@@ -6820,6 +7029,32 @@ var init_cdp_commands = __esm({
|
|
|
6820
7029
|
}
|
|
6821
7030
|
});
|
|
6822
7031
|
|
|
7032
|
+
// ../../oss/packages/daemon-core/src/config/provider-source-config.ts
|
|
7033
|
+
function normalizeProviderDir(value) {
|
|
7034
|
+
if (typeof value !== "string") return void 0;
|
|
7035
|
+
const trimmed = value.trim();
|
|
7036
|
+
return trimmed ? trimmed : void 0;
|
|
7037
|
+
}
|
|
7038
|
+
function parseProviderSourceConfigUpdate(input) {
|
|
7039
|
+
const updates = {};
|
|
7040
|
+
if (Object.prototype.hasOwnProperty.call(input, "providerSourceMode")) {
|
|
7041
|
+
const { providerSourceMode } = input;
|
|
7042
|
+
if (providerSourceMode !== "normal" && providerSourceMode !== "no-upstream") {
|
|
7043
|
+
return { ok: false, error: "providerSourceMode must be 'normal' or 'no-upstream'" };
|
|
7044
|
+
}
|
|
7045
|
+
updates.providerSourceMode = providerSourceMode;
|
|
7046
|
+
}
|
|
7047
|
+
if (Object.prototype.hasOwnProperty.call(input, "providerDir")) {
|
|
7048
|
+
updates.providerDir = normalizeProviderDir(input.providerDir);
|
|
7049
|
+
}
|
|
7050
|
+
return { ok: true, updates };
|
|
7051
|
+
}
|
|
7052
|
+
var init_provider_source_config = __esm({
|
|
7053
|
+
"../../oss/packages/daemon-core/src/config/provider-source-config.ts"() {
|
|
7054
|
+
"use strict";
|
|
7055
|
+
}
|
|
7056
|
+
});
|
|
7057
|
+
|
|
6823
7058
|
// ../../oss/packages/daemon-core/src/providers/cli-script-results.ts
|
|
6824
7059
|
function parseCliScriptResult(result) {
|
|
6825
7060
|
if (typeof result === "string") {
|
|
@@ -6936,8 +7171,49 @@ async function handleSetProviderSetting(h, args) {
|
|
|
6936
7171
|
}
|
|
6937
7172
|
return { success: false, error: `Failed to set ${providerType}.${key} \u2014 invalid key, value, or not a public setting` };
|
|
6938
7173
|
}
|
|
6939
|
-
function
|
|
7174
|
+
function handleGetProviderSourceConfig(h, _args) {
|
|
7175
|
+
const loader = h.ctx.providerLoader;
|
|
7176
|
+
if (!loader) return { success: false, error: "providerLoader not available" };
|
|
7177
|
+
return { success: true, ...loader.getSourceConfig() };
|
|
7178
|
+
}
|
|
7179
|
+
async function handleSetProviderSourceConfig(h, args) {
|
|
7180
|
+
const loader = h.ctx.providerLoader;
|
|
7181
|
+
if (!loader) return { success: false, error: "providerLoader not available" };
|
|
7182
|
+
const parsed = parseProviderSourceConfigUpdate(args || {});
|
|
7183
|
+
if ("error" in parsed) {
|
|
7184
|
+
return { success: false, error: parsed.error };
|
|
7185
|
+
}
|
|
7186
|
+
const currentConfig2 = loadConfig();
|
|
7187
|
+
const nextConfig = {
|
|
7188
|
+
...currentConfig2,
|
|
7189
|
+
...parsed.updates.providerSourceMode ? { providerSourceMode: parsed.updates.providerSourceMode } : {},
|
|
7190
|
+
...Object.prototype.hasOwnProperty.call(parsed.updates, "providerDir") ? { providerDir: parsed.updates.providerDir } : {}
|
|
7191
|
+
};
|
|
7192
|
+
saveConfig(nextConfig);
|
|
7193
|
+
const sourceConfig = loader.applySourceConfig({
|
|
7194
|
+
sourceMode: nextConfig.providerSourceMode,
|
|
7195
|
+
userDir: Object.prototype.hasOwnProperty.call(parsed.updates, "providerDir") ? parsed.updates.providerDir : loader.getSourceConfig().explicitProviderDir || void 0
|
|
7196
|
+
});
|
|
7197
|
+
loader.reload();
|
|
7198
|
+
loader.registerToDetector();
|
|
7199
|
+
await h.ctx.onProviderSourceConfigChanged?.();
|
|
7200
|
+
LOG.info(
|
|
7201
|
+
"Command",
|
|
7202
|
+
`[set_provider_source_config] mode=${sourceConfig.sourceMode} explicitProviderDir=${sourceConfig.explicitProviderDir || "-"} userDir=${sourceConfig.userDir}`
|
|
7203
|
+
);
|
|
7204
|
+
return { success: true, reloaded: true, ...sourceConfig };
|
|
7205
|
+
}
|
|
7206
|
+
function normalizeProviderScriptArgs(args, scriptName) {
|
|
6940
7207
|
const normalizedArgs = { ...args || {} };
|
|
7208
|
+
const normalizedScriptName = String(scriptName || "").toLowerCase();
|
|
7209
|
+
if (Object.prototype.hasOwnProperty.call(normalizedArgs, "value")) {
|
|
7210
|
+
if (normalizedArgs.model === void 0 && (normalizedScriptName === "setmodel" || normalizedScriptName === "setmodelgui" || normalizedScriptName === "webviewsetmodel")) {
|
|
7211
|
+
normalizedArgs.model = normalizedArgs.value;
|
|
7212
|
+
}
|
|
7213
|
+
if (normalizedArgs.mode === void 0 && (normalizedScriptName === "setmode" || normalizedScriptName === "webviewsetmode")) {
|
|
7214
|
+
normalizedArgs.mode = normalizedArgs.value;
|
|
7215
|
+
}
|
|
7216
|
+
}
|
|
6941
7217
|
for (const key of ["mode", "model", "message", "action", "button", "text", "sessionId", "value"]) {
|
|
6942
7218
|
if (key in normalizedArgs && !(key.toUpperCase() in normalizedArgs)) {
|
|
6943
7219
|
normalizedArgs[key.toUpperCase()] = normalizedArgs[key];
|
|
@@ -6983,7 +7259,7 @@ async function executeProviderScript(h, args, scriptName) {
|
|
|
6983
7259
|
if (!provider.scripts?.[actualScriptName]) {
|
|
6984
7260
|
return { success: false, error: `Script '${actualScriptName}' not available for ${resolvedProviderType}` };
|
|
6985
7261
|
}
|
|
6986
|
-
const normalizedArgs = normalizeProviderScriptArgs(args);
|
|
7262
|
+
const normalizedArgs = normalizeProviderScriptArgs(args, actualScriptName);
|
|
6987
7263
|
if (provider.category === "cli") {
|
|
6988
7264
|
const adapter = h.getCliAdapter(args?.targetSessionId || resolvedProviderType);
|
|
6989
7265
|
if (!adapter?.invokeScript) {
|
|
@@ -7129,6 +7405,8 @@ function handleSetIdeExtension(h, args) {
|
|
|
7129
7405
|
var init_stream_commands = __esm({
|
|
7130
7406
|
"../../oss/packages/daemon-core/src/commands/stream-commands.ts"() {
|
|
7131
7407
|
"use strict";
|
|
7408
|
+
init_config();
|
|
7409
|
+
init_provider_source_config();
|
|
7132
7410
|
init_cli_script_results();
|
|
7133
7411
|
init_control_effects();
|
|
7134
7412
|
init_logger();
|
|
@@ -7656,6 +7934,10 @@ var init_handler = __esm({
|
|
|
7656
7934
|
return handleGetProviderSettings(this, args);
|
|
7657
7935
|
case "set_provider_setting":
|
|
7658
7936
|
return handleSetProviderSetting(this, args);
|
|
7937
|
+
case "get_provider_source_config":
|
|
7938
|
+
return handleGetProviderSourceConfig(this, args);
|
|
7939
|
+
case "set_provider_source_config":
|
|
7940
|
+
return handleSetProviderSourceConfig(this, args);
|
|
7659
7941
|
// ─── IDE Extension Settings (stream-commands.ts) ──────────
|
|
7660
7942
|
case "get_ide_extensions":
|
|
7661
7943
|
return handleGetIdeExtensions(this, args);
|
|
@@ -7695,7 +7977,7 @@ var init_handler = __esm({
|
|
|
7695
7977
|
try {
|
|
7696
7978
|
const http3 = await import("http");
|
|
7697
7979
|
const postData = JSON.stringify(body);
|
|
7698
|
-
const result = await new Promise((
|
|
7980
|
+
const result = await new Promise((resolve15, reject) => {
|
|
7699
7981
|
const req = http3.request({
|
|
7700
7982
|
hostname: "127.0.0.1",
|
|
7701
7983
|
port: 19280,
|
|
@@ -7707,9 +7989,9 @@ var init_handler = __esm({
|
|
|
7707
7989
|
res.on("data", (chunk) => data += chunk);
|
|
7708
7990
|
res.on("end", () => {
|
|
7709
7991
|
try {
|
|
7710
|
-
|
|
7992
|
+
resolve15(JSON.parse(data));
|
|
7711
7993
|
} catch {
|
|
7712
|
-
|
|
7994
|
+
resolve15({ raw: data });
|
|
7713
7995
|
}
|
|
7714
7996
|
});
|
|
7715
7997
|
});
|
|
@@ -7727,15 +8009,15 @@ var init_handler = __esm({
|
|
|
7727
8009
|
if (!providerType) return { success: false, error: "providerType required" };
|
|
7728
8010
|
try {
|
|
7729
8011
|
const http3 = await import("http");
|
|
7730
|
-
const result = await new Promise((
|
|
8012
|
+
const result = await new Promise((resolve15, reject) => {
|
|
7731
8013
|
http3.get(`http://127.0.0.1:19280/api/providers/${providerType}/${endpoint}`, (res) => {
|
|
7732
8014
|
let data = "";
|
|
7733
8015
|
res.on("data", (chunk) => data += chunk);
|
|
7734
8016
|
res.on("end", () => {
|
|
7735
8017
|
try {
|
|
7736
|
-
|
|
8018
|
+
resolve15(JSON.parse(data));
|
|
7737
8019
|
} catch {
|
|
7738
|
-
|
|
8020
|
+
resolve15({ raw: data });
|
|
7739
8021
|
}
|
|
7740
8022
|
});
|
|
7741
8023
|
}).on("error", reject);
|
|
@@ -7749,7 +8031,7 @@ var init_handler = __esm({
|
|
|
7749
8031
|
try {
|
|
7750
8032
|
const http3 = await import("http");
|
|
7751
8033
|
const postData = JSON.stringify(args || {});
|
|
7752
|
-
const result = await new Promise((
|
|
8034
|
+
const result = await new Promise((resolve15, reject) => {
|
|
7753
8035
|
const req = http3.request({
|
|
7754
8036
|
hostname: "127.0.0.1",
|
|
7755
8037
|
port: 19280,
|
|
@@ -7761,9 +8043,9 @@ var init_handler = __esm({
|
|
|
7761
8043
|
res.on("data", (chunk) => data += chunk);
|
|
7762
8044
|
res.on("end", () => {
|
|
7763
8045
|
try {
|
|
7764
|
-
|
|
8046
|
+
resolve15(JSON.parse(data));
|
|
7765
8047
|
} catch {
|
|
7766
|
-
|
|
8048
|
+
resolve15({ raw: data });
|
|
7767
8049
|
}
|
|
7768
8050
|
});
|
|
7769
8051
|
});
|
|
@@ -9947,7 +10229,7 @@ var init_provider_cli_adapter = __esm({
|
|
|
9947
10229
|
`[${this.cliType}] Waiting for interactive prompt: hasPrompt=${hasPrompt} stableMs=${stableMs} recentOutputMs=${recentlyOutput} status=${status} startup=${startupLikelyActive} screen=${JSON.stringify(summarizeCliTraceText(screenText, 220)).slice(0, 260)}`
|
|
9948
10230
|
);
|
|
9949
10231
|
}
|
|
9950
|
-
await new Promise((
|
|
10232
|
+
await new Promise((resolve15) => setTimeout(resolve15, 50));
|
|
9951
10233
|
}
|
|
9952
10234
|
const finalScreenText = this.terminalScreen.getText() || "";
|
|
9953
10235
|
LOG.warn(
|
|
@@ -10520,7 +10802,7 @@ ${data.message || ""}`.trim();
|
|
|
10520
10802
|
const deadline = Date.now() + 1e4;
|
|
10521
10803
|
while (this.startupParseGate && Date.now() < deadline) {
|
|
10522
10804
|
this.resolveStartupState("send_wait");
|
|
10523
|
-
await new Promise((
|
|
10805
|
+
await new Promise((resolve15) => setTimeout(resolve15, 50));
|
|
10524
10806
|
}
|
|
10525
10807
|
}
|
|
10526
10808
|
await this.waitForInteractivePrompt();
|
|
@@ -10590,12 +10872,12 @@ ${data.message || ""}`.trim();
|
|
|
10590
10872
|
if (this.isWaitingForResponse) this.finishResponse();
|
|
10591
10873
|
}, this.timeouts.maxResponse);
|
|
10592
10874
|
};
|
|
10593
|
-
await new Promise((
|
|
10875
|
+
await new Promise((resolve15) => {
|
|
10594
10876
|
let resolved = false;
|
|
10595
10877
|
const resolveOnce = () => {
|
|
10596
10878
|
if (resolved) return;
|
|
10597
10879
|
resolved = true;
|
|
10598
|
-
|
|
10880
|
+
resolve15();
|
|
10599
10881
|
};
|
|
10600
10882
|
const submit = () => {
|
|
10601
10883
|
if (!this.ptyProcess) {
|
|
@@ -10769,17 +11051,17 @@ ${data.message || ""}`.trim();
|
|
|
10769
11051
|
}
|
|
10770
11052
|
}
|
|
10771
11053
|
waitForStopped(timeoutMs) {
|
|
10772
|
-
return new Promise((
|
|
11054
|
+
return new Promise((resolve15) => {
|
|
10773
11055
|
const startedAt = Date.now();
|
|
10774
11056
|
const timer = setInterval(() => {
|
|
10775
11057
|
if (!this.ptyProcess || this.currentStatus === "stopped") {
|
|
10776
11058
|
clearInterval(timer);
|
|
10777
|
-
|
|
11059
|
+
resolve15(true);
|
|
10778
11060
|
return;
|
|
10779
11061
|
}
|
|
10780
11062
|
if (Date.now() - startedAt >= timeoutMs) {
|
|
10781
11063
|
clearInterval(timer);
|
|
10782
|
-
|
|
11064
|
+
resolve15(false);
|
|
10783
11065
|
}
|
|
10784
11066
|
}, 100);
|
|
10785
11067
|
});
|
|
@@ -11069,6 +11351,9 @@ function getForcedNewSessionScriptName(provider, launchMode) {
|
|
|
11069
11351
|
const controls = Array.isArray(provider.controls) ? provider.controls : [];
|
|
11070
11352
|
for (const control of controls) {
|
|
11071
11353
|
if (control?.type !== "action") continue;
|
|
11354
|
+
if (typeof control?.confirmTitle === "string" && control.confirmTitle.trim()) continue;
|
|
11355
|
+
if (typeof control?.confirmMessage === "string" && control.confirmMessage.trim()) continue;
|
|
11356
|
+
if (typeof control?.confirmLabel === "string" && control.confirmLabel.trim()) continue;
|
|
11072
11357
|
const invokeScript = typeof control?.invokeScript === "string" ? control.invokeScript.trim() : "";
|
|
11073
11358
|
if (!invokeScript) continue;
|
|
11074
11359
|
const controlId = typeof control?.id === "string" ? control.id.trim() : "";
|
|
@@ -11078,6 +11363,20 @@ function getForcedNewSessionScriptName(provider, launchMode) {
|
|
|
11078
11363
|
}
|
|
11079
11364
|
return null;
|
|
11080
11365
|
}
|
|
11366
|
+
async function waitForCliAdapterReady(adapter, options) {
|
|
11367
|
+
const timeoutMs = Math.max(100, options?.timeoutMs ?? 15e3);
|
|
11368
|
+
const pollMs = Math.max(10, options?.pollMs ?? 50);
|
|
11369
|
+
const deadline = Date.now() + timeoutMs;
|
|
11370
|
+
while (Date.now() < deadline) {
|
|
11371
|
+
if (adapter?.isReady?.()) return;
|
|
11372
|
+
const status = adapter?.getStatus?.()?.status;
|
|
11373
|
+
if (status === "stopped") {
|
|
11374
|
+
throw new Error("CLI runtime stopped before it became ready");
|
|
11375
|
+
}
|
|
11376
|
+
await new Promise((resolve15) => setTimeout(resolve15, pollMs));
|
|
11377
|
+
}
|
|
11378
|
+
throw new Error(`CLI runtime did not become ready within ${timeoutMs}ms`);
|
|
11379
|
+
}
|
|
11081
11380
|
var os13, path11, crypto3, fs5, import_node_module, CachedDatabaseSync, CliProviderInstance;
|
|
11082
11381
|
var init_cli_provider_instance = __esm({
|
|
11083
11382
|
"../../oss/packages/daemon-core/src/providers/cli-provider-instance.ts"() {
|
|
@@ -11095,6 +11394,7 @@ var init_cli_provider_instance = __esm({
|
|
|
11095
11394
|
init_control_effects();
|
|
11096
11395
|
init_approval_utils();
|
|
11097
11396
|
init_cli_script_results();
|
|
11397
|
+
init_provider_patch_state();
|
|
11098
11398
|
CachedDatabaseSync = null;
|
|
11099
11399
|
CliProviderInstance = class {
|
|
11100
11400
|
constructor(provider, workingDir, cliArgs = [], instanceId, transportFactory, options) {
|
|
@@ -11124,6 +11424,7 @@ var init_cli_provider_instance = __esm({
|
|
|
11124
11424
|
generatingDebouncePending = null;
|
|
11125
11425
|
lastApprovalEventAt = 0;
|
|
11126
11426
|
controlValues = {};
|
|
11427
|
+
summaryMetadata = void 0;
|
|
11127
11428
|
appliedEffectKeys = /* @__PURE__ */ new Set();
|
|
11128
11429
|
historyWriter;
|
|
11129
11430
|
runtimeMessages = [];
|
|
@@ -11266,13 +11567,7 @@ var init_cli_provider_instance = __esm({
|
|
|
11266
11567
|
if (historyMessageCount !== null) {
|
|
11267
11568
|
parsedMessages = historyMessageCount > 0 ? parsedMessages.slice(-historyMessageCount) : [];
|
|
11268
11569
|
}
|
|
11269
|
-
const controlValues = extractProviderControlValues(this.provider.controls, parsedStatus);
|
|
11270
|
-
if (controlValues) {
|
|
11271
|
-
this.controlValues = { ...this.controlValues, ...controlValues };
|
|
11272
|
-
}
|
|
11273
11570
|
const mergedMessages = this.mergeConversationMessages(parsedMessages);
|
|
11274
|
-
const currentModel = typeof parsedStatus?.model === "string" && parsedStatus.model.trim() ? parsedStatus.model.trim() : typeof this.controlValues.model === "string" && this.controlValues.model.trim() ? this.controlValues.model.trim() : void 0;
|
|
11275
|
-
const currentPlan = typeof parsedStatus?.mode === "string" && parsedStatus.mode.trim() ? parsedStatus.mode.trim() : typeof this.controlValues.mode === "string" && this.controlValues.mode.trim() ? this.controlValues.mode.trim() : void 0;
|
|
11276
11571
|
const dirName = this.workingDir.split("/").filter(Boolean).pop() || "session";
|
|
11277
11572
|
if (parsedMessages.length > 0) {
|
|
11278
11573
|
const shouldSkipReplayPersist = this.suppressIdleHistoryReplay && adapterStatus.status === "idle" && parsedStatus?.status === "idle";
|
|
@@ -11294,6 +11589,10 @@ var init_cli_provider_instance = __esm({
|
|
|
11294
11589
|
}
|
|
11295
11590
|
}
|
|
11296
11591
|
this.applyProviderResponse(parsedStatus, { phase: "immediate" });
|
|
11592
|
+
const surface = resolveProviderStateSurface({
|
|
11593
|
+
summaryMetadata: this.summaryMetadata,
|
|
11594
|
+
controlValues: this.controlValues
|
|
11595
|
+
});
|
|
11297
11596
|
return {
|
|
11298
11597
|
type: this.type,
|
|
11299
11598
|
name: this.provider.name,
|
|
@@ -11309,8 +11608,6 @@ var init_cli_provider_instance = __esm({
|
|
|
11309
11608
|
inputContent: ""
|
|
11310
11609
|
},
|
|
11311
11610
|
workspace: this.workingDir,
|
|
11312
|
-
currentModel,
|
|
11313
|
-
currentPlan,
|
|
11314
11611
|
instanceId: this.instanceId,
|
|
11315
11612
|
providerSessionId: this.providerSessionId,
|
|
11316
11613
|
lastUpdated: Date.now(),
|
|
@@ -11325,8 +11622,9 @@ var init_cli_provider_instance = __esm({
|
|
|
11325
11622
|
attachedClients: runtime.attachedClients || []
|
|
11326
11623
|
} : void 0,
|
|
11327
11624
|
resume: this.provider.resume,
|
|
11328
|
-
controlValues:
|
|
11329
|
-
providerControls: this.provider.controls
|
|
11625
|
+
controlValues: surface.controlValues,
|
|
11626
|
+
providerControls: this.provider.controls,
|
|
11627
|
+
summaryMetadata: surface.summaryMetadata
|
|
11330
11628
|
};
|
|
11331
11629
|
}
|
|
11332
11630
|
setPresentationMode(mode) {
|
|
@@ -11374,6 +11672,7 @@ var init_cli_provider_instance = __esm({
|
|
|
11374
11672
|
const scriptName = getForcedNewSessionScriptName(this.provider, this.launchMode);
|
|
11375
11673
|
if (!scriptName) return;
|
|
11376
11674
|
LOG.info("CLI", `[${this.type}] forcing fresh session launch via script: ${scriptName}`);
|
|
11675
|
+
await waitForCliAdapterReady(this.adapter);
|
|
11377
11676
|
const raw = await this.adapter.invokeScript(scriptName, {});
|
|
11378
11677
|
const parsed = parseCliScriptResult(raw);
|
|
11379
11678
|
if (!parsed.success) {
|
|
@@ -11529,10 +11828,14 @@ var init_cli_provider_instance = __esm({
|
|
|
11529
11828
|
this.suppressIdleHistoryReplay = false;
|
|
11530
11829
|
this.adapter.clearHistory();
|
|
11531
11830
|
}
|
|
11532
|
-
const
|
|
11533
|
-
|
|
11534
|
-
|
|
11535
|
-
|
|
11831
|
+
const patchedState = mergeProviderPatchState({
|
|
11832
|
+
providerControls: this.provider.controls,
|
|
11833
|
+
data,
|
|
11834
|
+
currentControlValues: this.controlValues,
|
|
11835
|
+
currentSummaryMetadata: this.summaryMetadata
|
|
11836
|
+
});
|
|
11837
|
+
this.controlValues = patchedState.controlValues;
|
|
11838
|
+
this.summaryMetadata = patchedState.summaryMetadata;
|
|
11536
11839
|
const effects = normalizeProviderEffects(data);
|
|
11537
11840
|
for (const effect of effects) {
|
|
11538
11841
|
const effectWhen = effect.when || "immediate";
|
|
@@ -11723,6 +12026,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
11723
12026
|
const previousProviderSessionId = this.providerSessionId;
|
|
11724
12027
|
this.providerSessionId = nextSessionId;
|
|
11725
12028
|
this.historyWriter.promoteHistorySession(this.type, previousHistorySessionId, nextSessionId);
|
|
12029
|
+
this.historyWriter.writeSessionStart(this.type, nextSessionId, this.workingDir, this.instanceId);
|
|
11726
12030
|
this.adapter.updateRuntimeMeta({ providerSessionId: nextSessionId });
|
|
11727
12031
|
this.onProviderSessionResolved?.({
|
|
11728
12032
|
instanceId: this.instanceId,
|
|
@@ -27826,8 +28130,8 @@ var init_acp = __esm({
|
|
|
27826
28130
|
this.#requestHandler = requestHandler;
|
|
27827
28131
|
this.#notificationHandler = notificationHandler;
|
|
27828
28132
|
this.#stream = stream;
|
|
27829
|
-
this.#closedPromise = new Promise((
|
|
27830
|
-
this.#abortController.signal.addEventListener("abort", () =>
|
|
28133
|
+
this.#closedPromise = new Promise((resolve15) => {
|
|
28134
|
+
this.#abortController.signal.addEventListener("abort", () => resolve15());
|
|
27831
28135
|
});
|
|
27832
28136
|
this.#receive();
|
|
27833
28137
|
}
|
|
@@ -27976,8 +28280,8 @@ var init_acp = __esm({
|
|
|
27976
28280
|
}
|
|
27977
28281
|
async sendRequest(method, params) {
|
|
27978
28282
|
const id = this.#nextRequestId++;
|
|
27979
|
-
const responsePromise = new Promise((
|
|
27980
|
-
this.#pendingResponses.set(id, { resolve:
|
|
28283
|
+
const responsePromise = new Promise((resolve15, reject) => {
|
|
28284
|
+
this.#pendingResponses.set(id, { resolve: resolve15, reject });
|
|
27981
28285
|
});
|
|
27982
28286
|
await this.#sendMessage({ jsonrpc: "2.0", id, method, params });
|
|
27983
28287
|
return responsePromise;
|
|
@@ -28178,6 +28482,7 @@ var init_acp_provider_instance = __esm({
|
|
|
28178
28482
|
init_acp();
|
|
28179
28483
|
init_contracts();
|
|
28180
28484
|
init_status_monitor();
|
|
28485
|
+
init_summary_metadata();
|
|
28181
28486
|
init_logger();
|
|
28182
28487
|
AcpProviderInstance = class {
|
|
28183
28488
|
constructor(provider, workingDir, cliArgs = []) {
|
|
@@ -28206,8 +28511,7 @@ var init_acp_provider_instance = __esm({
|
|
|
28206
28511
|
lastStatus = "starting";
|
|
28207
28512
|
generatingStartedAt = 0;
|
|
28208
28513
|
agentCapabilities = {};
|
|
28209
|
-
|
|
28210
|
-
currentMode;
|
|
28514
|
+
currentSelections = {};
|
|
28211
28515
|
activeToolCalls = [];
|
|
28212
28516
|
stopReason = null;
|
|
28213
28517
|
partialContent = "";
|
|
@@ -28287,8 +28591,6 @@ var init_acp_provider_instance = __esm({
|
|
|
28287
28591
|
inputContent: ""
|
|
28288
28592
|
},
|
|
28289
28593
|
workspace: this.workingDir,
|
|
28290
|
-
currentModel: this.currentModel,
|
|
28291
|
-
currentPlan: this.currentMode,
|
|
28292
28594
|
instanceId: this.instanceId,
|
|
28293
28595
|
lastUpdated: Date.now(),
|
|
28294
28596
|
settings: this.settings,
|
|
@@ -28299,11 +28601,9 @@ var init_acp_provider_instance = __esm({
|
|
|
28299
28601
|
// Error details for dashboard display
|
|
28300
28602
|
errorMessage: this.errorMessage || void 0,
|
|
28301
28603
|
errorReason: this.errorReason || void 0,
|
|
28302
|
-
controlValues:
|
|
28303
|
-
|
|
28304
|
-
|
|
28305
|
-
},
|
|
28306
|
-
providerControls: this.provider.controls
|
|
28604
|
+
controlValues: this.getSelectionControlValues(),
|
|
28605
|
+
providerControls: this.provider.controls,
|
|
28606
|
+
summaryMetadata: this.buildSelectionSummaryMetadata()
|
|
28307
28607
|
};
|
|
28308
28608
|
}
|
|
28309
28609
|
onEvent(event, data) {
|
|
@@ -28337,6 +28637,54 @@ var init_acp_provider_instance = __esm({
|
|
|
28337
28637
|
getInstanceId() {
|
|
28338
28638
|
return this.instanceId;
|
|
28339
28639
|
}
|
|
28640
|
+
resolveConfigOptionLabel(category, value) {
|
|
28641
|
+
if (!value) return void 0;
|
|
28642
|
+
const option = this.configOptions.find((entry) => entry.category === category);
|
|
28643
|
+
return option?.options.find((candidate) => candidate.value === value)?.name || value;
|
|
28644
|
+
}
|
|
28645
|
+
resolveModeLabel(modeId) {
|
|
28646
|
+
if (!modeId) return void 0;
|
|
28647
|
+
return this.availableModes.find((mode) => mode.id === modeId)?.name || modeId;
|
|
28648
|
+
}
|
|
28649
|
+
getCurrentSelection(category) {
|
|
28650
|
+
return this.currentSelections[category];
|
|
28651
|
+
}
|
|
28652
|
+
setCurrentSelection(category, value) {
|
|
28653
|
+
const normalized = typeof value === "string" ? value.trim() : "";
|
|
28654
|
+
if (normalized) {
|
|
28655
|
+
this.currentSelections[category] = normalized;
|
|
28656
|
+
return;
|
|
28657
|
+
}
|
|
28658
|
+
delete this.currentSelections[category];
|
|
28659
|
+
}
|
|
28660
|
+
getSelectionControlValues() {
|
|
28661
|
+
const model = this.getCurrentSelection("model");
|
|
28662
|
+
const mode = this.getCurrentSelection("mode");
|
|
28663
|
+
return {
|
|
28664
|
+
...model ? { model } : {},
|
|
28665
|
+
...mode ? { mode } : {}
|
|
28666
|
+
};
|
|
28667
|
+
}
|
|
28668
|
+
resolveSelectionLabel(category, value) {
|
|
28669
|
+
if (!value) return void 0;
|
|
28670
|
+
const configLabel = this.resolveConfigOptionLabel(category, value);
|
|
28671
|
+
if (configLabel && configLabel !== value) return configLabel;
|
|
28672
|
+
if (category === "mode") {
|
|
28673
|
+
const modeLabel = this.resolveModeLabel(value);
|
|
28674
|
+
if (modeLabel) return modeLabel;
|
|
28675
|
+
}
|
|
28676
|
+
return configLabel || value;
|
|
28677
|
+
}
|
|
28678
|
+
buildSelectionSummaryMetadata() {
|
|
28679
|
+
const model = this.getCurrentSelection("model");
|
|
28680
|
+
const mode = this.getCurrentSelection("mode");
|
|
28681
|
+
return buildLegacyModelModeSummaryMetadata({
|
|
28682
|
+
model,
|
|
28683
|
+
mode,
|
|
28684
|
+
modelLabel: this.resolveSelectionLabel("model", model),
|
|
28685
|
+
modeLabel: this.resolveSelectionLabel("mode", mode)
|
|
28686
|
+
});
|
|
28687
|
+
}
|
|
28340
28688
|
// ─── ACP Config Options & Modes ─────────────────────
|
|
28341
28689
|
parseConfigOptions(raw) {
|
|
28342
28690
|
if (!Array.isArray(raw)) return;
|
|
@@ -28368,12 +28716,14 @@ var init_acp_provider_instance = __esm({
|
|
|
28368
28716
|
}
|
|
28369
28717
|
}
|
|
28370
28718
|
this.configOptions.push({ category, configId, currentValue, options: flatOptions });
|
|
28371
|
-
if (category === "model"
|
|
28719
|
+
if (category === "model" || category === "mode") {
|
|
28720
|
+
this.setCurrentSelection(category, currentValue);
|
|
28721
|
+
}
|
|
28372
28722
|
}
|
|
28373
28723
|
}
|
|
28374
28724
|
parseModes(raw) {
|
|
28375
28725
|
if (!raw) return;
|
|
28376
|
-
|
|
28726
|
+
this.setCurrentSelection("mode", raw.currentModeId);
|
|
28377
28727
|
if (Array.isArray(raw.availableModes)) {
|
|
28378
28728
|
this.availableModes = raw.availableModes.map((m) => ({
|
|
28379
28729
|
id: m.id,
|
|
@@ -28392,8 +28742,7 @@ var init_acp_provider_instance = __esm({
|
|
|
28392
28742
|
if (this.useStaticConfig) {
|
|
28393
28743
|
opt.currentValue = value;
|
|
28394
28744
|
this.selectedConfig[opt.configId] = value;
|
|
28395
|
-
if (category === "model") this.
|
|
28396
|
-
if (category === "mode") this.currentMode = value;
|
|
28745
|
+
if (category === "model" || category === "mode") this.setCurrentSelection(category, value);
|
|
28397
28746
|
this.log.info(`[${this.type}] Static config ${category} set to: ${value} \u2014 restarting agent`);
|
|
28398
28747
|
await this.restartWithNewConfig();
|
|
28399
28748
|
return;
|
|
@@ -28411,7 +28760,7 @@ var init_acp_provider_instance = __esm({
|
|
|
28411
28760
|
value
|
|
28412
28761
|
});
|
|
28413
28762
|
opt.currentValue = value;
|
|
28414
|
-
if (category === "model") this.
|
|
28763
|
+
if (category === "model" || category === "mode") this.setCurrentSelection(category, value);
|
|
28415
28764
|
if (result?.configOptions) this.parseConfigOptions(result.configOptions);
|
|
28416
28765
|
this.log.info(`[${this.type}] Config ${category} set to: ${value} | response: ${JSON.stringify(result)?.slice(0, 300)}`);
|
|
28417
28766
|
} catch (e) {
|
|
@@ -28427,7 +28776,7 @@ var init_acp_provider_instance = __esm({
|
|
|
28427
28776
|
opt.currentValue = modeId;
|
|
28428
28777
|
this.selectedConfig[opt.configId] = modeId;
|
|
28429
28778
|
}
|
|
28430
|
-
this.
|
|
28779
|
+
this.setCurrentSelection("mode", modeId);
|
|
28431
28780
|
this.log.info(`[${this.type}] Static mode set to: ${modeId} \u2014 restarting agent`);
|
|
28432
28781
|
await this.restartWithNewConfig();
|
|
28433
28782
|
return;
|
|
@@ -28442,7 +28791,7 @@ var init_acp_provider_instance = __esm({
|
|
|
28442
28791
|
sessionId: this.sessionId,
|
|
28443
28792
|
modeId
|
|
28444
28793
|
});
|
|
28445
|
-
this.
|
|
28794
|
+
this.setCurrentSelection("mode", modeId);
|
|
28446
28795
|
this.log.info(`[${this.type}] Mode set to: ${modeId}`);
|
|
28447
28796
|
} catch (e) {
|
|
28448
28797
|
const message = e?.message || "Unknown ACP mode error";
|
|
@@ -28613,13 +28962,13 @@ var init_acp_provider_instance = __esm({
|
|
|
28613
28962
|
}
|
|
28614
28963
|
this.currentStatus = "waiting_approval";
|
|
28615
28964
|
this.detectStatusTransition();
|
|
28616
|
-
const approved = await new Promise((
|
|
28617
|
-
this.permissionResolvers.push(
|
|
28965
|
+
const approved = await new Promise((resolve15) => {
|
|
28966
|
+
this.permissionResolvers.push(resolve15);
|
|
28618
28967
|
setTimeout(() => {
|
|
28619
|
-
const idx = this.permissionResolvers.indexOf(
|
|
28968
|
+
const idx = this.permissionResolvers.indexOf(resolve15);
|
|
28620
28969
|
if (idx >= 0) {
|
|
28621
28970
|
this.permissionResolvers.splice(idx, 1);
|
|
28622
|
-
|
|
28971
|
+
resolve15(false);
|
|
28623
28972
|
}
|
|
28624
28973
|
}, 3e5);
|
|
28625
28974
|
});
|
|
@@ -28700,8 +29049,8 @@ var init_acp_provider_instance = __esm({
|
|
|
28700
29049
|
if (result?.modes) this.log.debug(`[${this.type}] modes: ${JSON.stringify(result.modes).slice(0, 300)}`);
|
|
28701
29050
|
this.parseConfigOptions(result?.configOptions);
|
|
28702
29051
|
this.parseModes(result?.modes);
|
|
28703
|
-
if (!this.
|
|
28704
|
-
this.
|
|
29052
|
+
if (!this.getCurrentSelection("model") && result?.models?.currentModelId) {
|
|
29053
|
+
this.setCurrentSelection("model", result.models.currentModelId);
|
|
28705
29054
|
}
|
|
28706
29055
|
if (this.configOptions.length === 0 && this.provider.staticConfigOptions?.length) {
|
|
28707
29056
|
this.useStaticConfig = true;
|
|
@@ -28715,13 +29064,16 @@ var init_acp_provider_instance = __esm({
|
|
|
28715
29064
|
});
|
|
28716
29065
|
if (defaultVal) {
|
|
28717
29066
|
this.selectedConfig[sc.configId] = defaultVal;
|
|
28718
|
-
if (sc.category === "model"
|
|
28719
|
-
|
|
29067
|
+
if (sc.category === "model" || sc.category === "mode") {
|
|
29068
|
+
this.setCurrentSelection(sc.category, defaultVal);
|
|
29069
|
+
}
|
|
28720
29070
|
}
|
|
28721
29071
|
}
|
|
28722
29072
|
this.log.info(`[${this.type}] Using static configOptions (${this.configOptions.length} options)`);
|
|
28723
29073
|
}
|
|
28724
|
-
|
|
29074
|
+
const currentModel = this.getCurrentSelection("model");
|
|
29075
|
+
const currentMode = this.getCurrentSelection("mode");
|
|
29076
|
+
this.log.info(`[${this.type}] Session created: ${this.sessionId}${currentModel ? ` (model: ${currentModel})` : ""}${currentMode ? ` (mode: ${currentMode})` : ""}`);
|
|
28725
29077
|
if (this.configOptions.length > 0) {
|
|
28726
29078
|
this.log.info(`[${this.type}] Config options: ${this.configOptions.map((c) => `${c.category}(${c.options.length})`).join(", ")}`);
|
|
28727
29079
|
}
|
|
@@ -28896,7 +29248,7 @@ var init_acp_provider_instance = __esm({
|
|
|
28896
29248
|
break;
|
|
28897
29249
|
}
|
|
28898
29250
|
case "current_mode_update": {
|
|
28899
|
-
this.
|
|
29251
|
+
this.setCurrentSelection("mode", update.currentModeId);
|
|
28900
29252
|
break;
|
|
28901
29253
|
}
|
|
28902
29254
|
case "config_option_update": {
|
|
@@ -28969,7 +29321,7 @@ var init_acp_provider_instance = __esm({
|
|
|
28969
29321
|
this.detectStatusTransition();
|
|
28970
29322
|
}
|
|
28971
29323
|
if (params.model) {
|
|
28972
|
-
this.
|
|
29324
|
+
this.setCurrentSelection("model", params.model);
|
|
28973
29325
|
}
|
|
28974
29326
|
}
|
|
28975
29327
|
/** Map SDK ToolCallStatus to internal status */
|
|
@@ -29251,6 +29603,7 @@ var init_cli_manager = __esm({
|
|
|
29251
29603
|
init_workspaces();
|
|
29252
29604
|
init_recent_activity();
|
|
29253
29605
|
init_saved_sessions();
|
|
29606
|
+
init_summary_metadata();
|
|
29254
29607
|
init_cli_provider_instance();
|
|
29255
29608
|
init_acp_provider_instance();
|
|
29256
29609
|
init_contracts();
|
|
@@ -29282,7 +29635,11 @@ var init_cli_manager = __esm({
|
|
|
29282
29635
|
}
|
|
29283
29636
|
persistRecentActivity(entry) {
|
|
29284
29637
|
try {
|
|
29285
|
-
|
|
29638
|
+
const summaryMetadata = normalizeProviderSummaryMetadata(entry.summaryMetadata);
|
|
29639
|
+
let nextState = appendRecentActivity(loadState(), {
|
|
29640
|
+
...entry,
|
|
29641
|
+
summaryMetadata
|
|
29642
|
+
});
|
|
29286
29643
|
if (entry.providerSessionId && (entry.kind === "cli" || entry.kind === "acp")) {
|
|
29287
29644
|
nextState = upsertSavedProviderSession(nextState, {
|
|
29288
29645
|
kind: entry.kind,
|
|
@@ -29290,7 +29647,7 @@ var init_cli_manager = __esm({
|
|
|
29290
29647
|
providerName: entry.providerName,
|
|
29291
29648
|
providerSessionId: entry.providerSessionId,
|
|
29292
29649
|
workspace: entry.workspace,
|
|
29293
|
-
|
|
29650
|
+
summaryMetadata,
|
|
29294
29651
|
title: entry.title
|
|
29295
29652
|
});
|
|
29296
29653
|
}
|
|
@@ -29480,7 +29837,7 @@ ${installInfo}`
|
|
|
29480
29837
|
providerType: normalizedType,
|
|
29481
29838
|
providerName: provider.displayName || provider.name || normalizedType,
|
|
29482
29839
|
workspace: resolvedDir,
|
|
29483
|
-
|
|
29840
|
+
summaryMetadata: buildLegacyModelModeSummaryMetadata({ model: initialModel }),
|
|
29484
29841
|
sessionId,
|
|
29485
29842
|
title: provider.displayName || provider.name || normalizedType
|
|
29486
29843
|
});
|
|
@@ -29582,7 +29939,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
29582
29939
|
providerName: provider?.displayName || provider?.name || normalizedType,
|
|
29583
29940
|
providerSessionId: sessionBinding.providerSessionId,
|
|
29584
29941
|
workspace: resolvedDir,
|
|
29585
|
-
|
|
29942
|
+
summaryMetadata: buildLegacyModelModeSummaryMetadata({ model: initialModel }),
|
|
29586
29943
|
sessionId: key,
|
|
29587
29944
|
title: provider?.displayName || provider?.name || normalizedType
|
|
29588
29945
|
});
|
|
@@ -30750,7 +31107,7 @@ var init_handler2 = __esm({
|
|
|
30750
31107
|
this._addToNodeFs(path30, initialAdd, wh, depth + 1);
|
|
30751
31108
|
}
|
|
30752
31109
|
}).on(EV.ERROR, this._boundHandleError);
|
|
30753
|
-
return new Promise((
|
|
31110
|
+
return new Promise((resolve15, reject) => {
|
|
30754
31111
|
if (!stream)
|
|
30755
31112
|
return reject();
|
|
30756
31113
|
stream.once(STR_END, () => {
|
|
@@ -30759,7 +31116,7 @@ var init_handler2 = __esm({
|
|
|
30759
31116
|
return;
|
|
30760
31117
|
}
|
|
30761
31118
|
const wasThrottled = throttler ? throttler.clear() : false;
|
|
30762
|
-
|
|
31119
|
+
resolve15(void 0);
|
|
30763
31120
|
previous.getChildren().filter((item) => {
|
|
30764
31121
|
return item !== directory && !current.has(item);
|
|
30765
31122
|
}).forEach((item) => {
|
|
@@ -31644,6 +32001,9 @@ function validateProviderDefinition(raw) {
|
|
|
31644
32001
|
warnings.push(`Unknown provider field: ${key}`);
|
|
31645
32002
|
}
|
|
31646
32003
|
}
|
|
32004
|
+
if (provider.disableUpstream !== void 0) {
|
|
32005
|
+
warnings.push("disableUpstream is deprecated in provider definitions; use machine-level provider source policy instead");
|
|
32006
|
+
}
|
|
31647
32007
|
const category = provider.category;
|
|
31648
32008
|
if (category === "cli" || category === "acp") {
|
|
31649
32009
|
const spawn6 = provider.spawn;
|
|
@@ -31773,8 +32133,11 @@ var init_provider_loader = __esm({
|
|
|
31773
32133
|
ProviderLoader = class _ProviderLoader {
|
|
31774
32134
|
providers = /* @__PURE__ */ new Map();
|
|
31775
32135
|
providerAvailability = /* @__PURE__ */ new Map();
|
|
32136
|
+
defaultProvidersDir;
|
|
32137
|
+
explicitProviderDir = null;
|
|
31776
32138
|
userDir;
|
|
31777
32139
|
upstreamDir;
|
|
32140
|
+
sourceMode = "normal";
|
|
31778
32141
|
disableUpstream;
|
|
31779
32142
|
watchers = [];
|
|
31780
32143
|
logFn;
|
|
@@ -31788,22 +32151,15 @@ var init_provider_loader = __esm({
|
|
|
31788
32151
|
static META_FILE = ".meta.json";
|
|
31789
32152
|
constructor(options) {
|
|
31790
32153
|
this.logFn = options?.logFn || LOG.forComponent("Provider").asLogFn();
|
|
31791
|
-
|
|
31792
|
-
|
|
31793
|
-
|
|
31794
|
-
|
|
31795
|
-
|
|
31796
|
-
|
|
31797
|
-
|
|
31798
|
-
|
|
31799
|
-
|
|
31800
|
-
} else {
|
|
31801
|
-
this.userDir = defaultProvidersDir;
|
|
31802
|
-
this.log(`Using default user providers directory: ${this.userDir}`);
|
|
31803
|
-
}
|
|
31804
|
-
}
|
|
31805
|
-
this.upstreamDir = path14.join(defaultProvidersDir, ".upstream");
|
|
31806
|
-
this.disableUpstream = options?.disableUpstream ?? false;
|
|
32154
|
+
this.defaultProvidersDir = path14.join(os15.homedir(), ".adhdev", "providers");
|
|
32155
|
+
this.userDir = this.defaultProvidersDir;
|
|
32156
|
+
this.upstreamDir = path14.join(this.defaultProvidersDir, ".upstream");
|
|
32157
|
+
this.disableUpstream = false;
|
|
32158
|
+
this.applySourceConfig({
|
|
32159
|
+
userDir: options?.userDir,
|
|
32160
|
+
sourceMode: options?.sourceMode,
|
|
32161
|
+
disableUpstream: options?.disableUpstream
|
|
32162
|
+
});
|
|
31807
32163
|
}
|
|
31808
32164
|
log(msg) {
|
|
31809
32165
|
this.logFn(`[ProviderLoader] ${msg}`);
|
|
@@ -31828,6 +32184,33 @@ var init_provider_loader = __esm({
|
|
|
31828
32184
|
getProviderRoots() {
|
|
31829
32185
|
return [this.userDir, this.upstreamDir];
|
|
31830
32186
|
}
|
|
32187
|
+
getSourceConfig() {
|
|
32188
|
+
return {
|
|
32189
|
+
sourceMode: this.sourceMode,
|
|
32190
|
+
disableUpstream: this.disableUpstream,
|
|
32191
|
+
explicitProviderDir: this.explicitProviderDir,
|
|
32192
|
+
userDir: this.userDir,
|
|
32193
|
+
upstreamDir: this.upstreamDir,
|
|
32194
|
+
providerRoots: this.getProviderRoots()
|
|
32195
|
+
};
|
|
32196
|
+
}
|
|
32197
|
+
applySourceConfig(options) {
|
|
32198
|
+
const nextSourceMode = options?.sourceMode === "no-upstream" ? "no-upstream" : options?.sourceMode === "normal" ? "normal" : options?.disableUpstream ? "no-upstream" : this.sourceMode || "normal";
|
|
32199
|
+
if (options && Object.prototype.hasOwnProperty.call(options, "userDir")) {
|
|
32200
|
+
this.explicitProviderDir = options.userDir?.trim() ? options.userDir : null;
|
|
32201
|
+
}
|
|
32202
|
+
this.sourceMode = nextSourceMode;
|
|
32203
|
+
this.userDir = this.explicitProviderDir || this.defaultProvidersDir;
|
|
32204
|
+
this.upstreamDir = path14.join(this.defaultProvidersDir, ".upstream");
|
|
32205
|
+
this.disableUpstream = this.sourceMode === "no-upstream";
|
|
32206
|
+
if (this.explicitProviderDir) {
|
|
32207
|
+
this.log(`Config 'providerDir' applied: ${this.userDir}`);
|
|
32208
|
+
} else {
|
|
32209
|
+
this.log(`Using default user providers directory: ${this.userDir}`);
|
|
32210
|
+
}
|
|
32211
|
+
this.log(`Provider source config: mode=${this.sourceMode} explicitProviderDir=${this.explicitProviderDir || "-"} userDir=${this.userDir} upstreamDir=${this.upstreamDir}`);
|
|
32212
|
+
return this.getSourceConfig();
|
|
32213
|
+
}
|
|
31831
32214
|
/**
|
|
31832
32215
|
* Canonical provider directory shape for a given root.
|
|
31833
32216
|
*/
|
|
@@ -31878,7 +32261,7 @@ var init_provider_loader = __esm({
|
|
|
31878
32261
|
this.log(`Loaded ${upstreamCount} upstream providers (auto-updated)`);
|
|
31879
32262
|
}
|
|
31880
32263
|
} else if (this.disableUpstream) {
|
|
31881
|
-
this.log("Upstream loading disabled (
|
|
32264
|
+
this.log("Upstream loading disabled (sourceMode=no-upstream)");
|
|
31882
32265
|
}
|
|
31883
32266
|
if (fs6.existsSync(this.userDir)) {
|
|
31884
32267
|
const userCount = this.loadDir(this.userDir, [".upstream"]);
|
|
@@ -32389,7 +32772,7 @@ var init_provider_loader = __esm({
|
|
|
32389
32772
|
*/
|
|
32390
32773
|
async fetchLatest() {
|
|
32391
32774
|
if (this.disableUpstream) {
|
|
32392
|
-
this.log("Upstream fetch skipped (
|
|
32775
|
+
this.log("Upstream fetch skipped (sourceMode=no-upstream)");
|
|
32393
32776
|
return { updated: false };
|
|
32394
32777
|
}
|
|
32395
32778
|
const https = require("https");
|
|
@@ -32411,7 +32794,7 @@ var init_provider_loader = __esm({
|
|
|
32411
32794
|
return { updated: false };
|
|
32412
32795
|
}
|
|
32413
32796
|
try {
|
|
32414
|
-
const etag = await new Promise((
|
|
32797
|
+
const etag = await new Promise((resolve15, reject) => {
|
|
32415
32798
|
const options = {
|
|
32416
32799
|
method: "HEAD",
|
|
32417
32800
|
hostname: "github.com",
|
|
@@ -32429,7 +32812,7 @@ var init_provider_loader = __esm({
|
|
|
32429
32812
|
headers: { "User-Agent": "adhdev-launcher" },
|
|
32430
32813
|
timeout: 1e4
|
|
32431
32814
|
}, (res2) => {
|
|
32432
|
-
|
|
32815
|
+
resolve15(res2.headers.etag || res2.headers["last-modified"] || "");
|
|
32433
32816
|
});
|
|
32434
32817
|
req2.on("error", reject);
|
|
32435
32818
|
req2.on("timeout", () => {
|
|
@@ -32438,7 +32821,7 @@ var init_provider_loader = __esm({
|
|
|
32438
32821
|
});
|
|
32439
32822
|
req2.end();
|
|
32440
32823
|
} else {
|
|
32441
|
-
|
|
32824
|
+
resolve15(res.headers.etag || res.headers["last-modified"] || "");
|
|
32442
32825
|
}
|
|
32443
32826
|
});
|
|
32444
32827
|
req.on("error", reject);
|
|
@@ -32502,7 +32885,7 @@ var init_provider_loader = __esm({
|
|
|
32502
32885
|
downloadFile(url2, destPath) {
|
|
32503
32886
|
const https = require("https");
|
|
32504
32887
|
const http3 = require("http");
|
|
32505
|
-
return new Promise((
|
|
32888
|
+
return new Promise((resolve15, reject) => {
|
|
32506
32889
|
const doRequest = (reqUrl, redirectCount = 0) => {
|
|
32507
32890
|
if (redirectCount > 5) {
|
|
32508
32891
|
reject(new Error("Too many redirects"));
|
|
@@ -32522,7 +32905,7 @@ var init_provider_loader = __esm({
|
|
|
32522
32905
|
res.pipe(ws);
|
|
32523
32906
|
ws.on("finish", () => {
|
|
32524
32907
|
ws.close();
|
|
32525
|
-
|
|
32908
|
+
resolve15();
|
|
32526
32909
|
});
|
|
32527
32910
|
ws.on("error", reject);
|
|
32528
32911
|
});
|
|
@@ -32998,17 +33381,17 @@ async function findFreePort(ports) {
|
|
|
32998
33381
|
throw new Error("No free port found");
|
|
32999
33382
|
}
|
|
33000
33383
|
function checkPortFree(port) {
|
|
33001
|
-
return new Promise((
|
|
33384
|
+
return new Promise((resolve15) => {
|
|
33002
33385
|
const server = net2.createServer();
|
|
33003
33386
|
server.unref();
|
|
33004
|
-
server.on("error", () =>
|
|
33387
|
+
server.on("error", () => resolve15(false));
|
|
33005
33388
|
server.listen(port, "127.0.0.1", () => {
|
|
33006
|
-
server.close(() =>
|
|
33389
|
+
server.close(() => resolve15(true));
|
|
33007
33390
|
});
|
|
33008
33391
|
});
|
|
33009
33392
|
}
|
|
33010
33393
|
async function isCdpActive(port) {
|
|
33011
|
-
return new Promise((
|
|
33394
|
+
return new Promise((resolve15) => {
|
|
33012
33395
|
const req = require("http").get(`http://127.0.0.1:${port}/json/version`, {
|
|
33013
33396
|
timeout: 2e3
|
|
33014
33397
|
}, (res) => {
|
|
@@ -33017,16 +33400,16 @@ async function isCdpActive(port) {
|
|
|
33017
33400
|
res.on("end", () => {
|
|
33018
33401
|
try {
|
|
33019
33402
|
const info = JSON.parse(data);
|
|
33020
|
-
|
|
33403
|
+
resolve15(!!info["WebKit-Version"] || !!info["Browser"]);
|
|
33021
33404
|
} catch {
|
|
33022
|
-
|
|
33405
|
+
resolve15(false);
|
|
33023
33406
|
}
|
|
33024
33407
|
});
|
|
33025
33408
|
});
|
|
33026
|
-
req.on("error", () =>
|
|
33409
|
+
req.on("error", () => resolve15(false));
|
|
33027
33410
|
req.on("timeout", () => {
|
|
33028
33411
|
req.destroy();
|
|
33029
|
-
|
|
33412
|
+
resolve15(false);
|
|
33030
33413
|
});
|
|
33031
33414
|
});
|
|
33032
33415
|
}
|
|
@@ -33489,7 +33872,90 @@ var init_command_log = __esm({
|
|
|
33489
33872
|
}
|
|
33490
33873
|
});
|
|
33491
33874
|
|
|
33875
|
+
// ../../oss/packages/daemon-core/src/session-host/runtime-surface.ts
|
|
33876
|
+
function isSessionHostLiveRuntime(record2) {
|
|
33877
|
+
const lifecycle = String(record2?.lifecycle || "").trim();
|
|
33878
|
+
return LIVE_LIFECYCLES.has(lifecycle);
|
|
33879
|
+
}
|
|
33880
|
+
function getSessionHostRecoveryLabel(meta3) {
|
|
33881
|
+
const recoveryState = typeof meta3?.runtimeRecoveryState === "string" ? String(meta3.runtimeRecoveryState).trim() : "";
|
|
33882
|
+
if (!recoveryState) return null;
|
|
33883
|
+
if (recoveryState === "auto_resumed") return "restored after restart";
|
|
33884
|
+
if (recoveryState === "resume_failed") return "restore failed";
|
|
33885
|
+
if (recoveryState === "host_restart_interrupted") return "host restart interrupted";
|
|
33886
|
+
if (recoveryState === "orphan_snapshot") return "snapshot recovered";
|
|
33887
|
+
return recoveryState.replace(/_/g, " ");
|
|
33888
|
+
}
|
|
33889
|
+
function isSessionHostRecoverySnapshot(record2) {
|
|
33890
|
+
if (!record2) return false;
|
|
33891
|
+
if (isSessionHostLiveRuntime(record2)) return false;
|
|
33892
|
+
const lifecycle = String(record2.lifecycle || "").trim();
|
|
33893
|
+
if (lifecycle && lifecycle !== "stopped" && lifecycle !== "failed") {
|
|
33894
|
+
return false;
|
|
33895
|
+
}
|
|
33896
|
+
const meta3 = record2.meta || void 0;
|
|
33897
|
+
if (meta3?.restoredFromStorage === true) return true;
|
|
33898
|
+
return getSessionHostRecoveryLabel(meta3) !== null;
|
|
33899
|
+
}
|
|
33900
|
+
function getSessionHostSurfaceKind(record2) {
|
|
33901
|
+
if (isSessionHostLiveRuntime(record2)) return "live_runtime";
|
|
33902
|
+
if (isSessionHostRecoverySnapshot(record2)) return "recovery_snapshot";
|
|
33903
|
+
return "inactive_record";
|
|
33904
|
+
}
|
|
33905
|
+
function partitionSessionHostRecords(records) {
|
|
33906
|
+
const liveRuntimes = [];
|
|
33907
|
+
const recoverySnapshots = [];
|
|
33908
|
+
const inactiveRecords = [];
|
|
33909
|
+
for (const record2 of records) {
|
|
33910
|
+
const kind = getSessionHostSurfaceKind(record2);
|
|
33911
|
+
if (kind === "live_runtime") {
|
|
33912
|
+
liveRuntimes.push(record2);
|
|
33913
|
+
} else if (kind === "recovery_snapshot") {
|
|
33914
|
+
recoverySnapshots.push(record2);
|
|
33915
|
+
} else {
|
|
33916
|
+
inactiveRecords.push(record2);
|
|
33917
|
+
}
|
|
33918
|
+
}
|
|
33919
|
+
return {
|
|
33920
|
+
liveRuntimes,
|
|
33921
|
+
recoverySnapshots,
|
|
33922
|
+
inactiveRecords
|
|
33923
|
+
};
|
|
33924
|
+
}
|
|
33925
|
+
function partitionSessionHostDiagnosticsSessions(records) {
|
|
33926
|
+
return partitionSessionHostRecords(records || []);
|
|
33927
|
+
}
|
|
33928
|
+
var LIVE_LIFECYCLES;
|
|
33929
|
+
var init_runtime_surface = __esm({
|
|
33930
|
+
"../../oss/packages/daemon-core/src/session-host/runtime-surface.ts"() {
|
|
33931
|
+
"use strict";
|
|
33932
|
+
LIVE_LIFECYCLES = /* @__PURE__ */ new Set(["starting", "running", "stopping", "interrupted"]);
|
|
33933
|
+
}
|
|
33934
|
+
});
|
|
33935
|
+
|
|
33492
33936
|
// ../../oss/packages/daemon-core/src/status/snapshot.ts
|
|
33937
|
+
function buildRecentReadDebugSignature(snapshot) {
|
|
33938
|
+
return [
|
|
33939
|
+
snapshot.providerType,
|
|
33940
|
+
snapshot.status,
|
|
33941
|
+
snapshot.inboxBucket,
|
|
33942
|
+
snapshot.unread ? "1" : "0",
|
|
33943
|
+
String(snapshot.lastSeenAt),
|
|
33944
|
+
snapshot.completionMarker,
|
|
33945
|
+
snapshot.seenCompletionMarker,
|
|
33946
|
+
String(snapshot.lastUpdated),
|
|
33947
|
+
String(snapshot.lastUsedAt),
|
|
33948
|
+
snapshot.lastRole,
|
|
33949
|
+
String(snapshot.messageUpdatedAt)
|
|
33950
|
+
].join("|");
|
|
33951
|
+
}
|
|
33952
|
+
function shouldEmitRecentReadDebugLog(cache, snapshot) {
|
|
33953
|
+
const nextSignature = buildRecentReadDebugSignature(snapshot);
|
|
33954
|
+
const previousSignature = cache.get(snapshot.sessionId);
|
|
33955
|
+
if (previousSignature === nextSignature) return false;
|
|
33956
|
+
cache.set(snapshot.sessionId, nextSignature);
|
|
33957
|
+
return true;
|
|
33958
|
+
}
|
|
33493
33959
|
function buildDetectedIdeInfos(detectedIdes, cdpManagers) {
|
|
33494
33960
|
return detectedIdes.filter((ide) => ide.installed !== false).map((ide) => ({
|
|
33495
33961
|
id: ide.id,
|
|
@@ -33641,7 +34107,7 @@ function buildRecentLaunches(recentActivity) {
|
|
|
33641
34107
|
providerSessionId: item.providerSessionId,
|
|
33642
34108
|
title: item.title || item.providerName,
|
|
33643
34109
|
workspace: item.workspace,
|
|
33644
|
-
|
|
34110
|
+
summaryMetadata: item.summaryMetadata,
|
|
33645
34111
|
lastLaunchedAt: item.lastUsedAt
|
|
33646
34112
|
})).sort((a, b) => b.lastLaunchedAt - a.lastLaunchedAt).slice(0, 12);
|
|
33647
34113
|
}
|
|
@@ -33682,9 +34148,24 @@ function buildStatusSnapshot(options) {
|
|
|
33682
34148
|
session.unread = unread;
|
|
33683
34149
|
session.inboxBucket = inboxBucket;
|
|
33684
34150
|
if (READ_DEBUG_ENABLED && (session.unread || session.inboxBucket !== "idle" || session.providerType.includes("codex"))) {
|
|
34151
|
+
const recentReadSnapshot = {
|
|
34152
|
+
sessionId: session.id,
|
|
34153
|
+
providerType: session.providerType,
|
|
34154
|
+
status: String(session.status || ""),
|
|
34155
|
+
inboxBucket,
|
|
34156
|
+
unread,
|
|
34157
|
+
lastSeenAt,
|
|
34158
|
+
completionMarker: completionMarker || "-",
|
|
34159
|
+
seenCompletionMarker: seenCompletionMarker || "-",
|
|
34160
|
+
lastUpdated: Number(session.lastUpdated || 0),
|
|
34161
|
+
lastUsedAt,
|
|
34162
|
+
lastRole: getLastMessageRole(sourceSession),
|
|
34163
|
+
messageUpdatedAt: getSessionMessageUpdatedAt(sourceSession)
|
|
34164
|
+
};
|
|
34165
|
+
if (!shouldEmitRecentReadDebugLog(recentReadDebugSignatureBySession, recentReadSnapshot)) continue;
|
|
33685
34166
|
LOG.info(
|
|
33686
34167
|
"RecentRead",
|
|
33687
|
-
`snapshot session id=${
|
|
34168
|
+
`snapshot session id=${recentReadSnapshot.sessionId} provider=${recentReadSnapshot.providerType} status=${recentReadSnapshot.status} bucket=${recentReadSnapshot.inboxBucket} unread=${String(recentReadSnapshot.unread)} lastSeenAt=${recentReadSnapshot.lastSeenAt} completionMarker=${recentReadSnapshot.completionMarker} seenMarker=${recentReadSnapshot.seenCompletionMarker} lastUpdated=${String(recentReadSnapshot.lastUpdated)} lastUsedAt=${recentReadSnapshot.lastUsedAt} lastRole=${recentReadSnapshot.lastRole} msgUpdatedAt=${recentReadSnapshot.messageUpdatedAt}`
|
|
33688
34169
|
);
|
|
33689
34170
|
}
|
|
33690
34171
|
const lastDisplayMessage = getLastDisplayMessage(sourceSession);
|
|
@@ -33717,7 +34198,7 @@ function buildStatusSnapshot(options) {
|
|
|
33717
34198
|
}
|
|
33718
34199
|
};
|
|
33719
34200
|
}
|
|
33720
|
-
var os18, READ_DEBUG_ENABLED;
|
|
34201
|
+
var os18, READ_DEBUG_ENABLED, recentReadDebugSignatureBySession;
|
|
33721
34202
|
var init_snapshot = __esm({
|
|
33722
34203
|
"../../oss/packages/daemon-core/src/status/snapshot.ts"() {
|
|
33723
34204
|
"use strict";
|
|
@@ -33731,6 +34212,7 @@ var init_snapshot = __esm({
|
|
|
33731
34212
|
init_logger();
|
|
33732
34213
|
init_builders();
|
|
33733
34214
|
READ_DEBUG_ENABLED = process.argv.includes("--dev") || process.env.ADHDEV_READ_DEBUG === "1";
|
|
34215
|
+
recentReadDebugSignatureBySession = /* @__PURE__ */ new Map();
|
|
33734
34216
|
}
|
|
33735
34217
|
});
|
|
33736
34218
|
|
|
@@ -33772,7 +34254,7 @@ async function waitForPidExit(pid, timeoutMs) {
|
|
|
33772
34254
|
while (Date.now() - start < timeoutMs) {
|
|
33773
34255
|
try {
|
|
33774
34256
|
process.kill(pid, 0);
|
|
33775
|
-
await new Promise((
|
|
34257
|
+
await new Promise((resolve15) => setTimeout(resolve15, 250));
|
|
33776
34258
|
} catch {
|
|
33777
34259
|
return;
|
|
33778
34260
|
}
|
|
@@ -33887,7 +34369,7 @@ async function runDaemonUpgradeHelper(payload) {
|
|
|
33887
34369
|
appendUpgradeLog(installOutput.trim());
|
|
33888
34370
|
}
|
|
33889
34371
|
if (process.platform === "win32") {
|
|
33890
|
-
await new Promise((
|
|
34372
|
+
await new Promise((resolve15) => setTimeout(resolve15, 500));
|
|
33891
34373
|
cleanupStaleGlobalInstallDirs(payload.packageName);
|
|
33892
34374
|
appendUpgradeLog("Post-install staging cleanup complete");
|
|
33893
34375
|
}
|
|
@@ -33972,6 +34454,49 @@ function toHostedCliRuntimeDescriptor(record2) {
|
|
|
33972
34454
|
providerSessionId: typeof record2.meta?.providerSessionId === "string" ? String(record2.meta.providerSessionId) : void 0
|
|
33973
34455
|
};
|
|
33974
34456
|
}
|
|
34457
|
+
function getWriteConflictOwnerClientId(error48) {
|
|
34458
|
+
const message = typeof error48 === "string" ? error48 : error48 instanceof Error ? error48.message : "";
|
|
34459
|
+
const match = /^Write owned by\s+(.+)$/.exec(message.trim());
|
|
34460
|
+
return match?.[1]?.trim() || void 0;
|
|
34461
|
+
}
|
|
34462
|
+
function summarizeSessionHostRecord(result) {
|
|
34463
|
+
if (!result || typeof result !== "object") return {};
|
|
34464
|
+
const record2 = result;
|
|
34465
|
+
return {
|
|
34466
|
+
runtimeKey: typeof record2.runtimeKey === "string" ? record2.runtimeKey : void 0,
|
|
34467
|
+
lifecycle: typeof record2.lifecycle === "string" ? record2.lifecycle : void 0,
|
|
34468
|
+
surfaceKind: getSessionHostSurfaceKind(record2),
|
|
34469
|
+
attachedClientCount: Array.isArray(record2.attachedClients) ? record2.attachedClients.length : void 0,
|
|
34470
|
+
hasWriteOwner: !!record2.writeOwner,
|
|
34471
|
+
writeOwnerClientId: typeof record2.writeOwner?.clientId === "string" ? record2.writeOwner.clientId : void 0
|
|
34472
|
+
};
|
|
34473
|
+
}
|
|
34474
|
+
function summarizeSessionHostRecords(result) {
|
|
34475
|
+
const records = Array.isArray(result) ? result : [];
|
|
34476
|
+
const groups = partitionSessionHostRecords(records);
|
|
34477
|
+
return {
|
|
34478
|
+
sessionCount: records.length,
|
|
34479
|
+
liveRuntimeCount: groups.liveRuntimes.length,
|
|
34480
|
+
recoverySnapshotCount: groups.recoverySnapshots.length,
|
|
34481
|
+
inactiveRecordCount: groups.inactiveRecords.length
|
|
34482
|
+
};
|
|
34483
|
+
}
|
|
34484
|
+
function summarizeSessionHostDiagnostics(result) {
|
|
34485
|
+
const diagnostics = result && typeof result === "object" ? result : {};
|
|
34486
|
+
const sessions = Array.isArray(diagnostics.sessions) ? diagnostics.sessions : [];
|
|
34487
|
+
return {
|
|
34488
|
+
runtimeCount: typeof diagnostics.runtimeCount === "number" ? diagnostics.runtimeCount : void 0,
|
|
34489
|
+
...summarizeSessionHostRecords(sessions)
|
|
34490
|
+
};
|
|
34491
|
+
}
|
|
34492
|
+
function summarizeSessionHostPruneResult(result) {
|
|
34493
|
+
const value = result && typeof result === "object" ? result : {};
|
|
34494
|
+
return {
|
|
34495
|
+
duplicateGroupCount: typeof value.duplicateGroupCount === "number" ? value.duplicateGroupCount : void 0,
|
|
34496
|
+
prunedCount: Array.isArray(value.prunedSessionIds) ? value.prunedSessionIds.length : void 0,
|
|
34497
|
+
keptCount: Array.isArray(value.keptSessionIds) ? value.keptSessionIds.length : void 0
|
|
34498
|
+
};
|
|
34499
|
+
}
|
|
33975
34500
|
var fs9, CHAT_COMMANDS, READ_DEBUG_ENABLED2, DaemonCommandRouter;
|
|
33976
34501
|
var init_router = __esm({
|
|
33977
34502
|
"../../oss/packages/daemon-core/src/commands/router.ts"() {
|
|
@@ -33991,6 +34516,7 @@ var init_router = __esm({
|
|
|
33991
34516
|
init_command_log();
|
|
33992
34517
|
init_logger();
|
|
33993
34518
|
init_debug_trace();
|
|
34519
|
+
init_runtime_surface();
|
|
33994
34520
|
init_builders();
|
|
33995
34521
|
init_snapshot();
|
|
33996
34522
|
init_snapshot();
|
|
@@ -34009,6 +34535,56 @@ var init_router = __esm({
|
|
|
34009
34535
|
constructor(deps) {
|
|
34010
34536
|
this.deps = deps;
|
|
34011
34537
|
}
|
|
34538
|
+
async traceSessionHostAction(action, args, run, summarizeResult) {
|
|
34539
|
+
const interactionId = typeof args?._interactionId === "string" ? args._interactionId : void 0;
|
|
34540
|
+
const sessionId = typeof args?.sessionId === "string" ? args.sessionId : void 0;
|
|
34541
|
+
const requestedPayload = { action };
|
|
34542
|
+
if (sessionId) requestedPayload.sessionId = sessionId;
|
|
34543
|
+
if (typeof args?.clientId === "string") requestedPayload.clientId = args.clientId;
|
|
34544
|
+
if (typeof args?.signal === "string") requestedPayload.signal = args.signal;
|
|
34545
|
+
if (typeof args?.providerType === "string") requestedPayload.providerType = args.providerType;
|
|
34546
|
+
if (typeof args?.workspace === "string") requestedPayload.workspace = args.workspace;
|
|
34547
|
+
if (typeof args?.dryRun === "boolean") requestedPayload.dryRun = args.dryRun;
|
|
34548
|
+
recordDebugTrace({
|
|
34549
|
+
interactionId,
|
|
34550
|
+
category: "session_host",
|
|
34551
|
+
stage: "action_requested",
|
|
34552
|
+
level: "info",
|
|
34553
|
+
sessionId,
|
|
34554
|
+
payload: requestedPayload
|
|
34555
|
+
});
|
|
34556
|
+
try {
|
|
34557
|
+
const result = await run();
|
|
34558
|
+
recordDebugTrace({
|
|
34559
|
+
interactionId,
|
|
34560
|
+
category: "session_host",
|
|
34561
|
+
stage: "action_result",
|
|
34562
|
+
level: "info",
|
|
34563
|
+
sessionId,
|
|
34564
|
+
payload: {
|
|
34565
|
+
...requestedPayload,
|
|
34566
|
+
success: true,
|
|
34567
|
+
...summarizeResult ? summarizeResult(result) : {}
|
|
34568
|
+
}
|
|
34569
|
+
});
|
|
34570
|
+
return result;
|
|
34571
|
+
} catch (error48) {
|
|
34572
|
+
recordDebugTrace({
|
|
34573
|
+
interactionId,
|
|
34574
|
+
category: "session_host",
|
|
34575
|
+
stage: "action_failed",
|
|
34576
|
+
level: "error",
|
|
34577
|
+
sessionId,
|
|
34578
|
+
payload: {
|
|
34579
|
+
...requestedPayload,
|
|
34580
|
+
error: error48?.message || String(error48),
|
|
34581
|
+
failureKind: getWriteConflictOwnerClientId(error48) ? "write_conflict" : "request_failed",
|
|
34582
|
+
conflictOwnerClientId: getWriteConflictOwnerClientId(error48)
|
|
34583
|
+
}
|
|
34584
|
+
});
|
|
34585
|
+
throw error48;
|
|
34586
|
+
}
|
|
34587
|
+
}
|
|
34012
34588
|
/**
|
|
34013
34589
|
* Unified command routing.
|
|
34014
34590
|
* Returns result for all commands:
|
|
@@ -34118,44 +34694,60 @@ var init_router = __esm({
|
|
|
34118
34694
|
}
|
|
34119
34695
|
case "session_host_get_diagnostics": {
|
|
34120
34696
|
if (!this.deps.sessionHostControl) return { success: false, error: "Session host control unavailable" };
|
|
34121
|
-
const diagnostics = await this.deps.sessionHostControl.getDiagnostics({
|
|
34697
|
+
const diagnostics = await this.traceSessionHostAction("session_host_get_diagnostics", args, () => this.deps.sessionHostControl.getDiagnostics({
|
|
34122
34698
|
includeSessions: args?.includeSessions !== false,
|
|
34123
34699
|
limit: Number(args?.limit) || void 0
|
|
34124
|
-
})
|
|
34700
|
+
}), (result) => ({
|
|
34701
|
+
includeSessions: args?.includeSessions !== false,
|
|
34702
|
+
limit: Number(args?.limit) || void 0,
|
|
34703
|
+
...summarizeSessionHostDiagnostics(result)
|
|
34704
|
+
}));
|
|
34125
34705
|
return { success: true, diagnostics };
|
|
34126
34706
|
}
|
|
34127
34707
|
case "session_host_list_sessions": {
|
|
34128
34708
|
if (!this.deps.sessionHostControl) return { success: false, error: "Session host control unavailable" };
|
|
34129
|
-
const sessions = await this.deps.sessionHostControl.listSessions();
|
|
34709
|
+
const sessions = await this.traceSessionHostAction("session_host_list_sessions", args, () => this.deps.sessionHostControl.listSessions(), (records) => summarizeSessionHostRecords(records));
|
|
34130
34710
|
return { success: true, sessions };
|
|
34131
34711
|
}
|
|
34132
34712
|
case "session_host_stop_session": {
|
|
34133
34713
|
if (!this.deps.sessionHostControl) return { success: false, error: "Session host control unavailable" };
|
|
34134
34714
|
const sessionId = typeof args?.sessionId === "string" ? args.sessionId : "";
|
|
34135
34715
|
if (!sessionId) return { success: false, error: "sessionId required" };
|
|
34136
|
-
const record2 = await this.deps.sessionHostControl.stopSession(sessionId);
|
|
34716
|
+
const record2 = await this.traceSessionHostAction("session_host_stop_session", args, () => this.deps.sessionHostControl.stopSession(sessionId), (result) => summarizeSessionHostRecord(result));
|
|
34137
34717
|
return { success: true, record: record2 };
|
|
34138
34718
|
}
|
|
34139
34719
|
case "session_host_resume_session": {
|
|
34140
34720
|
if (!this.deps.sessionHostControl) return { success: false, error: "Session host control unavailable" };
|
|
34141
34721
|
const sessionId = typeof args?.sessionId === "string" ? args.sessionId : "";
|
|
34142
34722
|
if (!sessionId) return { success: false, error: "sessionId required" };
|
|
34143
|
-
const record2 = await this.
|
|
34144
|
-
|
|
34145
|
-
|
|
34146
|
-
|
|
34147
|
-
|
|
34723
|
+
const record2 = await this.traceSessionHostAction("session_host_resume_session", args, async () => {
|
|
34724
|
+
const nextRecord = await this.deps.sessionHostControl.resumeSession(sessionId);
|
|
34725
|
+
const hosted = toHostedCliRuntimeDescriptor(nextRecord);
|
|
34726
|
+
if (hosted) {
|
|
34727
|
+
await this.deps.cliManager.restoreHostedSessions([hosted]);
|
|
34728
|
+
}
|
|
34729
|
+
return nextRecord;
|
|
34730
|
+
}, (result) => ({
|
|
34731
|
+
...summarizeSessionHostRecord(result),
|
|
34732
|
+
restoredHostedSession: !!toHostedCliRuntimeDescriptor(result)
|
|
34733
|
+
}));
|
|
34148
34734
|
return { success: true, record: record2 };
|
|
34149
34735
|
}
|
|
34150
34736
|
case "session_host_restart_session": {
|
|
34151
34737
|
if (!this.deps.sessionHostControl) return { success: false, error: "Session host control unavailable" };
|
|
34152
34738
|
const sessionId = typeof args?.sessionId === "string" ? args.sessionId : "";
|
|
34153
34739
|
if (!sessionId) return { success: false, error: "sessionId required" };
|
|
34154
|
-
const record2 = await this.
|
|
34155
|
-
|
|
34156
|
-
|
|
34157
|
-
|
|
34158
|
-
|
|
34740
|
+
const record2 = await this.traceSessionHostAction("session_host_restart_session", args, async () => {
|
|
34741
|
+
const nextRecord = await this.deps.sessionHostControl.restartSession(sessionId);
|
|
34742
|
+
const hosted = toHostedCliRuntimeDescriptor(nextRecord);
|
|
34743
|
+
if (hosted) {
|
|
34744
|
+
await this.deps.cliManager.restoreHostedSessions([hosted]);
|
|
34745
|
+
}
|
|
34746
|
+
return nextRecord;
|
|
34747
|
+
}, (result) => ({
|
|
34748
|
+
...summarizeSessionHostRecord(result),
|
|
34749
|
+
restoredHostedSession: !!toHostedCliRuntimeDescriptor(result)
|
|
34750
|
+
}));
|
|
34159
34751
|
return { success: true, record: record2 };
|
|
34160
34752
|
}
|
|
34161
34753
|
case "session_host_send_signal": {
|
|
@@ -34164,7 +34756,7 @@ var init_router = __esm({
|
|
|
34164
34756
|
const signal = typeof args?.signal === "string" ? args.signal : "";
|
|
34165
34757
|
if (!sessionId) return { success: false, error: "sessionId required" };
|
|
34166
34758
|
if (!signal) return { success: false, error: "signal required" };
|
|
34167
|
-
const record2 = await this.deps.sessionHostControl.sendSignal(sessionId, signal);
|
|
34759
|
+
const record2 = await this.traceSessionHostAction("session_host_send_signal", args, () => this.deps.sessionHostControl.sendSignal(sessionId, signal), (result) => summarizeSessionHostRecord(result));
|
|
34168
34760
|
return { success: true, record: record2 };
|
|
34169
34761
|
}
|
|
34170
34762
|
case "session_host_force_detach_client": {
|
|
@@ -34173,16 +34765,16 @@ var init_router = __esm({
|
|
|
34173
34765
|
const clientId = typeof args?.clientId === "string" ? args.clientId : "";
|
|
34174
34766
|
if (!sessionId) return { success: false, error: "sessionId required" };
|
|
34175
34767
|
if (!clientId) return { success: false, error: "clientId required" };
|
|
34176
|
-
const record2 = await this.deps.sessionHostControl.forceDetachClient(sessionId, clientId);
|
|
34768
|
+
const record2 = await this.traceSessionHostAction("session_host_force_detach_client", args, () => this.deps.sessionHostControl.forceDetachClient(sessionId, clientId), (result) => summarizeSessionHostRecord(result));
|
|
34177
34769
|
return { success: true, record: record2 };
|
|
34178
34770
|
}
|
|
34179
34771
|
case "session_host_prune_duplicate_sessions": {
|
|
34180
34772
|
if (!this.deps.sessionHostControl) return { success: false, error: "Session host control unavailable" };
|
|
34181
|
-
const result = await this.deps.sessionHostControl.pruneDuplicateSessions({
|
|
34773
|
+
const result = await this.traceSessionHostAction("session_host_prune_duplicate_sessions", args, () => this.deps.sessionHostControl.pruneDuplicateSessions({
|
|
34182
34774
|
providerType: typeof args?.providerType === "string" ? args.providerType : void 0,
|
|
34183
34775
|
workspace: typeof args?.workspace === "string" ? args.workspace : void 0,
|
|
34184
34776
|
dryRun: args?.dryRun === true
|
|
34185
|
-
});
|
|
34777
|
+
}), (value) => summarizeSessionHostPruneResult(value));
|
|
34186
34778
|
return { success: true, result };
|
|
34187
34779
|
}
|
|
34188
34780
|
case "session_host_acquire_write": {
|
|
@@ -34192,12 +34784,15 @@ var init_router = __esm({
|
|
|
34192
34784
|
const ownerType = args?.ownerType === "agent" ? "agent" : "user";
|
|
34193
34785
|
if (!sessionId) return { success: false, error: "sessionId required" };
|
|
34194
34786
|
if (!clientId) return { success: false, error: "clientId required" };
|
|
34195
|
-
const record2 = await this.deps.sessionHostControl.acquireWrite({
|
|
34787
|
+
const record2 = await this.traceSessionHostAction("session_host_acquire_write", args, () => this.deps.sessionHostControl.acquireWrite({
|
|
34196
34788
|
sessionId,
|
|
34197
34789
|
clientId,
|
|
34198
34790
|
ownerType,
|
|
34199
34791
|
force: args?.force !== false
|
|
34200
|
-
})
|
|
34792
|
+
}), (result) => ({
|
|
34793
|
+
...summarizeSessionHostRecord(result),
|
|
34794
|
+
ownerType
|
|
34795
|
+
}));
|
|
34201
34796
|
return { success: true, record: record2 };
|
|
34202
34797
|
}
|
|
34203
34798
|
case "session_host_release_write": {
|
|
@@ -34206,7 +34801,10 @@ var init_router = __esm({
|
|
|
34206
34801
|
const clientId = typeof args?.clientId === "string" ? args.clientId : "";
|
|
34207
34802
|
if (!sessionId) return { success: false, error: "sessionId required" };
|
|
34208
34803
|
if (!clientId) return { success: false, error: "clientId required" };
|
|
34209
|
-
const record2 = await this.deps.sessionHostControl.releaseWrite({
|
|
34804
|
+
const record2 = await this.traceSessionHostAction("session_host_release_write", args, () => this.deps.sessionHostControl.releaseWrite({
|
|
34805
|
+
sessionId,
|
|
34806
|
+
clientId
|
|
34807
|
+
}), (result) => summarizeSessionHostRecord(result));
|
|
34210
34808
|
return { success: true, record: record2 };
|
|
34211
34809
|
}
|
|
34212
34810
|
case "list_saved_sessions": {
|
|
@@ -34215,8 +34813,9 @@ var init_router = __esm({
|
|
|
34215
34813
|
if (!providerType) {
|
|
34216
34814
|
return { success: false, error: "providerType required" };
|
|
34217
34815
|
}
|
|
34218
|
-
const
|
|
34219
|
-
const
|
|
34816
|
+
const wantsAll = args?.all === true;
|
|
34817
|
+
const offset = wantsAll ? 0 : Math.max(0, Number(args?.offset) || 0);
|
|
34818
|
+
const limit = wantsAll ? Number.MAX_SAFE_INTEGER : Math.max(1, Math.min(100, Number(args?.limit) || 30));
|
|
34220
34819
|
const { sessions: historySessions, hasMore } = listSavedHistorySessions(providerType, { offset, limit });
|
|
34221
34820
|
const state = loadState();
|
|
34222
34821
|
const savedSessions = getSavedProviderSessions(state, { providerType, kind });
|
|
@@ -34237,13 +34836,13 @@ var init_router = __esm({
|
|
|
34237
34836
|
providerName: saved?.providerName || recent?.providerName || providerType,
|
|
34238
34837
|
kind: saved?.kind || recent?.kind || kind,
|
|
34239
34838
|
title: saved?.title || recent?.title || session.sessionTitle || session.preview || providerType,
|
|
34240
|
-
workspace: saved?.workspace || recent?.workspace,
|
|
34241
|
-
|
|
34839
|
+
workspace: saved?.workspace || recent?.workspace || session.workspace,
|
|
34840
|
+
summaryMetadata: saved?.summaryMetadata || recent?.summaryMetadata,
|
|
34242
34841
|
preview: session.preview,
|
|
34243
34842
|
messageCount: session.messageCount,
|
|
34244
34843
|
firstMessageAt: session.firstMessageAt,
|
|
34245
34844
|
lastMessageAt: session.lastMessageAt,
|
|
34246
|
-
canResume: !!(saved?.workspace || recent?.workspace) && canResumeById
|
|
34845
|
+
canResume: !!(saved?.workspace || recent?.workspace || session.workspace) && canResumeById
|
|
34247
34846
|
};
|
|
34248
34847
|
}),
|
|
34249
34848
|
hasMore
|
|
@@ -34685,7 +35284,7 @@ var init_reporter = __esm({
|
|
|
34685
35284
|
const ideSummary = ideStates.map((s) => {
|
|
34686
35285
|
const msgs = s.activeChat?.messages?.length || 0;
|
|
34687
35286
|
const exts = s.extensions.length;
|
|
34688
|
-
return `${s.type}(${s.status},${msgs}msg,${exts}ext
|
|
35287
|
+
return `${s.type}(${s.status},${msgs}msg,${exts}ext)`;
|
|
34689
35288
|
}).join(", ");
|
|
34690
35289
|
const cliSummary = cliStates.map((s) => `${s.type}(${s.status})`).join(", ");
|
|
34691
35290
|
const acpSummary = acpStates.map((s) => `${s.type}(${s.status})`).join(", ");
|
|
@@ -34747,9 +35346,7 @@ var init_reporter = __esm({
|
|
|
34747
35346
|
workspace: session.workspace ?? null,
|
|
34748
35347
|
title: session.title,
|
|
34749
35348
|
cdpConnected: session.cdpConnected,
|
|
34750
|
-
|
|
34751
|
-
currentPlan: session.currentPlan,
|
|
34752
|
-
currentAutoApprove: session.currentAutoApprove
|
|
35349
|
+
summaryMetadata: session.summaryMetadata
|
|
34753
35350
|
})),
|
|
34754
35351
|
p2p: payload.p2p,
|
|
34755
35352
|
timestamp: now
|
|
@@ -34814,6 +35411,7 @@ var init_provider_adapter = __esm({
|
|
|
34814
35411
|
"../../oss/packages/daemon-core/src/agent-stream/provider-adapter.ts"() {
|
|
34815
35412
|
"use strict";
|
|
34816
35413
|
init_control_effects();
|
|
35414
|
+
init_provider_patch_state();
|
|
34817
35415
|
ProviderStreamAdapter = class {
|
|
34818
35416
|
agentType;
|
|
34819
35417
|
agentName;
|
|
@@ -34878,7 +35476,7 @@ var init_provider_adapter = __esm({
|
|
|
34878
35476
|
const beforeCount = this.messageCount(before);
|
|
34879
35477
|
const beforeSignature = this.lastMessageSignature(before);
|
|
34880
35478
|
for (let attempt = 0; attempt < 12; attempt += 1) {
|
|
34881
|
-
await new Promise((
|
|
35479
|
+
await new Promise((resolve15) => setTimeout(resolve15, 250));
|
|
34882
35480
|
let state;
|
|
34883
35481
|
try {
|
|
34884
35482
|
state = await this.readChat(evaluate);
|
|
@@ -34900,7 +35498,7 @@ var init_provider_adapter = __esm({
|
|
|
34900
35498
|
if (this.messageCount(first) > 0 || this.lastMessageSignature(first)) {
|
|
34901
35499
|
return first;
|
|
34902
35500
|
}
|
|
34903
|
-
await new Promise((
|
|
35501
|
+
await new Promise((resolve15) => setTimeout(resolve15, 150));
|
|
34904
35502
|
const second = await this.readChat(evaluate);
|
|
34905
35503
|
return this.messageCount(second) >= this.messageCount(first) ? second : first;
|
|
34906
35504
|
}
|
|
@@ -34925,15 +35523,18 @@ var init_provider_adapter = __esm({
|
|
|
34925
35523
|
status: data.status || "idle",
|
|
34926
35524
|
messages: data.messages || [],
|
|
34927
35525
|
inputContent: data.inputContent || "",
|
|
34928
|
-
model: data.model,
|
|
34929
|
-
mode: data.mode,
|
|
34930
35526
|
activeModal: data.activeModal
|
|
34931
35527
|
};
|
|
34932
35528
|
if (typeof data.title === "string" && data.title.trim()) {
|
|
34933
35529
|
state.title = data.title.trim();
|
|
34934
35530
|
}
|
|
34935
35531
|
const controlValues = extractProviderControlValues(this.provider.controls, data);
|
|
34936
|
-
|
|
35532
|
+
const surface = resolveProviderStateSurface({
|
|
35533
|
+
controlValues,
|
|
35534
|
+
summaryMetadata: data.summaryMetadata
|
|
35535
|
+
});
|
|
35536
|
+
if (surface.controlValues) state.controlValues = surface.controlValues;
|
|
35537
|
+
if (surface.summaryMetadata) state.summaryMetadata = surface.summaryMetadata;
|
|
34937
35538
|
const effects = normalizeProviderEffects(data);
|
|
34938
35539
|
if (effects.length > 0) state.effects = effects;
|
|
34939
35540
|
if (state.messages.length > 0) {
|
|
@@ -35040,7 +35641,7 @@ var init_provider_adapter = __esm({
|
|
|
35040
35641
|
if (typeof data.error === "string" && data.error.trim()) return false;
|
|
35041
35642
|
}
|
|
35042
35643
|
for (let attempt = 0; attempt < 6; attempt += 1) {
|
|
35043
|
-
await new Promise((
|
|
35644
|
+
await new Promise((resolve15) => setTimeout(resolve15, 250));
|
|
35044
35645
|
const state = await this.readChat(evaluate);
|
|
35045
35646
|
const title = this.getStateTitle(state);
|
|
35046
35647
|
if (this.titlesMatch(title, sessionId)) return true;
|
|
@@ -35214,7 +35815,8 @@ var init_manager2 = __esm({
|
|
|
35214
35815
|
const evaluate = (expr, timeout) => cdp.evaluateInSessionFrame(agent.cdpSessionId, expr, timeout);
|
|
35215
35816
|
const state = await agent.adapter.readChat(evaluate);
|
|
35216
35817
|
const stateError = this.getStateError(state);
|
|
35217
|
-
|
|
35818
|
+
const selectedModelValue = typeof state.controlValues?.model === "string" ? state.controlValues.model : "";
|
|
35819
|
+
LOG.debug("AgentStream", `[AgentStream] readChat(${type}) result: status=${state.status} msgs=${state.messages?.length || 0} model=${selectedModelValue}${state.status === "error" ? " error=" + JSON.stringify(stateError) : ""}`);
|
|
35218
35820
|
if (state.status === "error" && this.isRecoverableSessionError(stateError)) {
|
|
35219
35821
|
throw new Error(stateError);
|
|
35220
35822
|
}
|
|
@@ -35591,9 +36193,8 @@ function forwardAgentStreamsToIdeInstance(instanceManager, ideType, streams) {
|
|
|
35591
36193
|
messages: stream.messages || [],
|
|
35592
36194
|
status: stream.status || "idle",
|
|
35593
36195
|
activeModal: stream.activeModal || null,
|
|
35594
|
-
model: stream.model || void 0,
|
|
35595
|
-
mode: stream.mode || void 0,
|
|
35596
36196
|
controlValues: stream.controlValues || void 0,
|
|
36197
|
+
summaryMetadata: stream.summaryMetadata || void 0,
|
|
35597
36198
|
effects: stream.effects || void 0,
|
|
35598
36199
|
sessionId: stream.sessionId || stream.instanceId || void 0,
|
|
35599
36200
|
title: stream.title || stream.agentName || void 0,
|
|
@@ -36140,7 +36741,11 @@ module.exports.setMode = (params) => {
|
|
|
36140
36741
|
* 5. Approval dialog detection (buttons, modal)
|
|
36141
36742
|
* 6. Input field selector
|
|
36142
36743
|
*
|
|
36143
|
-
*
|
|
36744
|
+
* Preferred live-state surface:
|
|
36745
|
+
* - controlValues: explicit current control selections (model/mode/etc.)
|
|
36746
|
+
* - summaryMetadata: compact always-visible metadata for dashboard/recent views
|
|
36747
|
+
* Legacy top-level model/mode output is no longer the preferred shape.
|
|
36748
|
+
* \u2192 { id, status, title, messages[], inputContent, activeModal, controlValues?, summaryMetadata? }
|
|
36144
36749
|
*/
|
|
36145
36750
|
(() => {
|
|
36146
36751
|
try {
|
|
@@ -36168,6 +36773,9 @@ module.exports.setMode = (params) => {
|
|
|
36168
36773
|
messages,
|
|
36169
36774
|
inputContent,
|
|
36170
36775
|
activeModal,
|
|
36776
|
+
// TODO: Return explicit selections when available, e.g.
|
|
36777
|
+
// controlValues: { model: selectedModel, mode: selectedMode },
|
|
36778
|
+
// summaryMetadata: { items: [{ id: 'model', value: selectedModelLabel || selectedModel, shortValue: selectedModel, order: 10 }] },
|
|
36171
36779
|
});
|
|
36172
36780
|
} catch(e) {
|
|
36173
36781
|
return JSON.stringify({ id: '', status: 'error', messages: [], error: e.message });
|
|
@@ -37552,7 +38160,7 @@ function getCliTargetBundle(ctx, type, instanceId) {
|
|
|
37552
38160
|
return { target, instance, adapter };
|
|
37553
38161
|
}
|
|
37554
38162
|
function sleep(ms) {
|
|
37555
|
-
return new Promise((
|
|
38163
|
+
return new Promise((resolve15) => setTimeout(resolve15, ms));
|
|
37556
38164
|
}
|
|
37557
38165
|
async function waitForCliReady(ctx, type, instanceId, timeoutMs) {
|
|
37558
38166
|
const startedAt = Date.now();
|
|
@@ -37914,7 +38522,6 @@ async function handleCliStatus(ctx, _req, res) {
|
|
|
37914
38522
|
lastMessage: s.activeChat?.messages?.slice(-1)[0] || null,
|
|
37915
38523
|
activeModal: s.activeChat?.activeModal || null,
|
|
37916
38524
|
pendingEvents: s.pendingEvents || [],
|
|
37917
|
-
currentModel: s.currentModel,
|
|
37918
38525
|
settings: s.settings
|
|
37919
38526
|
}));
|
|
37920
38527
|
ctx.json(res, 200, { instances: result, count: result.length });
|
|
@@ -38404,18 +39011,6 @@ function resolveAutoImplWritableProviderDir(ctx, category, type, requestedDir) {
|
|
|
38404
39011
|
if (!fs13.existsSync(providerJson)) {
|
|
38405
39012
|
return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
|
|
38406
39013
|
}
|
|
38407
|
-
try {
|
|
38408
|
-
const providerData = JSON.parse(fs13.readFileSync(providerJson, "utf-8"));
|
|
38409
|
-
if (providerData.disableUpstream !== true) {
|
|
38410
|
-
providerData.disableUpstream = true;
|
|
38411
|
-
fs13.writeFileSync(providerJson, JSON.stringify(providerData, null, 2));
|
|
38412
|
-
}
|
|
38413
|
-
} catch (error48) {
|
|
38414
|
-
return {
|
|
38415
|
-
dir: null,
|
|
38416
|
-
reason: `Failed to update provider.json in writable provider directory: ${error48.message}`
|
|
38417
|
-
};
|
|
38418
|
-
}
|
|
38419
39014
|
return { dir: desiredDir };
|
|
38420
39015
|
}
|
|
38421
39016
|
function loadAutoImplReferenceScripts(ctx, referenceType) {
|
|
@@ -39088,7 +39683,7 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
39088
39683
|
lines.push("## Required Return Format");
|
|
39089
39684
|
lines.push("| Function | Return JSON |");
|
|
39090
39685
|
lines.push("|---|---|");
|
|
39091
|
-
lines.push("| readChat | `{ id, status, title, messages: [{role, content, index, kind?, meta?}], inputContent, activeModal }` \u2014 optional `kind`: standard, thought, tool, terminal;
|
|
39686
|
+
lines.push("| readChat | `{ id, status, title, messages: [{role, content, index, kind?, meta?}], inputContent, activeModal, controlValues?, summaryMetadata? }` \u2014 optional `kind`: standard, thought, tool, terminal; prefer explicit `controlValues` for current selections and `summaryMetadata` for compact always-visible UI metadata |");
|
|
39092
39687
|
lines.push("| sendMessage | `{ sent: false, needsTypeAndSend: true, selector }` |");
|
|
39093
39688
|
lines.push("| resolveAction | `{ resolved: true/false, clicked? }` |");
|
|
39094
39689
|
lines.push("| listSessions | `{ sessions: [{ id, title, active, index }] }` |");
|
|
@@ -39714,6 +40309,8 @@ var init_dev_server = __esm({
|
|
|
39714
40309
|
fs14 = __toESM(require("fs"));
|
|
39715
40310
|
path23 = __toESM(require("path"));
|
|
39716
40311
|
init_provider_schema();
|
|
40312
|
+
init_config();
|
|
40313
|
+
init_provider_source_config();
|
|
39717
40314
|
init_scaffold_template();
|
|
39718
40315
|
init_version_archive();
|
|
39719
40316
|
init_logger();
|
|
@@ -39728,6 +40325,7 @@ var init_dev_server = __esm({
|
|
|
39728
40325
|
cdpManagers;
|
|
39729
40326
|
instanceManager;
|
|
39730
40327
|
cliManager;
|
|
40328
|
+
onProviderSourceConfigChanged;
|
|
39731
40329
|
logFn;
|
|
39732
40330
|
sseClients = [];
|
|
39733
40331
|
watchScriptPath = null;
|
|
@@ -39744,6 +40342,7 @@ var init_dev_server = __esm({
|
|
|
39744
40342
|
this.cdpManagers = options.cdpManagers;
|
|
39745
40343
|
this.instanceManager = options.instanceManager || null;
|
|
39746
40344
|
this.cliManager = options.cliManager || null;
|
|
40345
|
+
this.onProviderSourceConfigChanged = options.onProviderSourceConfigChanged || null;
|
|
39747
40346
|
this.logFn = options.logFn || LOG.forComponent("DevServer").asLogFn();
|
|
39748
40347
|
}
|
|
39749
40348
|
log(msg) {
|
|
@@ -39753,6 +40352,8 @@ var init_dev_server = __esm({
|
|
|
39753
40352
|
routes = [
|
|
39754
40353
|
// Static routes
|
|
39755
40354
|
{ method: "GET", pattern: "/api/providers", handler: (q, s) => this.handleListProviders(q, s) },
|
|
40355
|
+
{ method: "GET", pattern: "/api/providers/source-config", handler: (q, s) => this.handleGetProviderSourceConfig(q, s) },
|
|
40356
|
+
{ method: "POST", pattern: "/api/providers/source-config", handler: (q, s) => this.handleSetProviderSourceConfig(q, s) },
|
|
39756
40357
|
{ method: "GET", pattern: "/api/providers/versions", handler: (q, s) => this.handleDetectVersions(q, s) },
|
|
39757
40358
|
{ method: "POST", pattern: "/api/providers/reload", handler: (q, s) => this.handleReload(q, s) },
|
|
39758
40359
|
{ method: "POST", pattern: "/api/cdp/evaluate", handler: (q, s) => this.handleCdpEvaluate(q, s) },
|
|
@@ -39850,15 +40451,15 @@ var init_dev_server = __esm({
|
|
|
39850
40451
|
this.json(res, 500, { error: e.message });
|
|
39851
40452
|
}
|
|
39852
40453
|
});
|
|
39853
|
-
return new Promise((
|
|
40454
|
+
return new Promise((resolve15, reject) => {
|
|
39854
40455
|
this.server.listen(port, "127.0.0.1", () => {
|
|
39855
40456
|
this.log(`Dev server listening on http://127.0.0.1:${port}`);
|
|
39856
|
-
|
|
40457
|
+
resolve15();
|
|
39857
40458
|
});
|
|
39858
40459
|
this.server.on("error", (e) => {
|
|
39859
40460
|
if (e.code === "EADDRINUSE") {
|
|
39860
40461
|
this.log(`Port ${port} in use, skipping dev server`);
|
|
39861
|
-
|
|
40462
|
+
resolve15();
|
|
39862
40463
|
} else {
|
|
39863
40464
|
reject(e);
|
|
39864
40465
|
}
|
|
@@ -39872,7 +40473,33 @@ var init_dev_server = __esm({
|
|
|
39872
40473
|
// ─── Handlers ───
|
|
39873
40474
|
async handleListProviders(_req, res) {
|
|
39874
40475
|
const providers = this.providerLoader.getAll().map(toProviderListEntry);
|
|
39875
|
-
this.json(res, 200, { providers, count: providers.length });
|
|
40476
|
+
this.json(res, 200, { providers, count: providers.length, sourceConfig: this.providerLoader.getSourceConfig() });
|
|
40477
|
+
}
|
|
40478
|
+
async handleGetProviderSourceConfig(_req, res) {
|
|
40479
|
+
this.json(res, 200, { success: true, sourceConfig: this.providerLoader.getSourceConfig() });
|
|
40480
|
+
}
|
|
40481
|
+
async handleSetProviderSourceConfig(req, res) {
|
|
40482
|
+
const body = await this.readBody(req);
|
|
40483
|
+
const parsed = parseProviderSourceConfigUpdate(body || {});
|
|
40484
|
+
if (!parsed.ok) {
|
|
40485
|
+
this.json(res, 400, { success: false, error: parsed.error });
|
|
40486
|
+
return;
|
|
40487
|
+
}
|
|
40488
|
+
const currentConfig2 = loadConfig();
|
|
40489
|
+
const nextConfig = {
|
|
40490
|
+
...currentConfig2,
|
|
40491
|
+
...parsed.updates.providerSourceMode ? { providerSourceMode: parsed.updates.providerSourceMode } : {},
|
|
40492
|
+
...Object.prototype.hasOwnProperty.call(parsed.updates, "providerDir") ? { providerDir: parsed.updates.providerDir } : {}
|
|
40493
|
+
};
|
|
40494
|
+
saveConfig(nextConfig);
|
|
40495
|
+
const sourceConfig = this.providerLoader.applySourceConfig({
|
|
40496
|
+
sourceMode: nextConfig.providerSourceMode,
|
|
40497
|
+
userDir: Object.prototype.hasOwnProperty.call(parsed.updates, "providerDir") ? parsed.updates.providerDir : this.providerLoader.getSourceConfig().explicitProviderDir || void 0
|
|
40498
|
+
});
|
|
40499
|
+
this.providerLoader.reload();
|
|
40500
|
+
this.providerLoader.registerToDetector();
|
|
40501
|
+
await this.onProviderSourceConfigChanged?.();
|
|
40502
|
+
this.json(res, 200, { success: true, reloaded: true, sourceConfig });
|
|
39876
40503
|
}
|
|
39877
40504
|
async handleProviderConfig(type, _req, res) {
|
|
39878
40505
|
const provider = this.providerLoader.resolve(type);
|
|
@@ -39914,20 +40541,20 @@ var init_dev_server = __esm({
|
|
|
39914
40541
|
child.stderr?.on("data", (d) => {
|
|
39915
40542
|
stderr += d.toString().slice(0, 2e3);
|
|
39916
40543
|
});
|
|
39917
|
-
await new Promise((
|
|
40544
|
+
await new Promise((resolve15) => {
|
|
39918
40545
|
const timer = setTimeout(() => {
|
|
39919
40546
|
child.kill();
|
|
39920
|
-
|
|
40547
|
+
resolve15();
|
|
39921
40548
|
}, 3e3);
|
|
39922
40549
|
child.on("exit", () => {
|
|
39923
40550
|
clearTimeout(timer);
|
|
39924
|
-
|
|
40551
|
+
resolve15();
|
|
39925
40552
|
});
|
|
39926
40553
|
child.stdout?.once("data", () => {
|
|
39927
40554
|
setTimeout(() => {
|
|
39928
40555
|
child.kill();
|
|
39929
40556
|
clearTimeout(timer);
|
|
39930
|
-
|
|
40557
|
+
resolve15();
|
|
39931
40558
|
}, 500);
|
|
39932
40559
|
});
|
|
39933
40560
|
});
|
|
@@ -40423,14 +41050,14 @@ var init_dev_server = __esm({
|
|
|
40423
41050
|
child.stderr?.on("data", (d) => {
|
|
40424
41051
|
stderr += d.toString();
|
|
40425
41052
|
});
|
|
40426
|
-
await new Promise((
|
|
41053
|
+
await new Promise((resolve15) => {
|
|
40427
41054
|
const timer = setTimeout(() => {
|
|
40428
41055
|
child.kill();
|
|
40429
|
-
|
|
41056
|
+
resolve15();
|
|
40430
41057
|
}, timeout);
|
|
40431
41058
|
child.on("exit", () => {
|
|
40432
41059
|
clearTimeout(timer);
|
|
40433
|
-
|
|
41060
|
+
resolve15();
|
|
40434
41061
|
});
|
|
40435
41062
|
});
|
|
40436
41063
|
const elapsed = Date.now() - start;
|
|
@@ -40575,18 +41202,6 @@ var init_dev_server = __esm({
|
|
|
40575
41202
|
if (!fs14.existsSync(providerJson)) {
|
|
40576
41203
|
return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
|
|
40577
41204
|
}
|
|
40578
|
-
try {
|
|
40579
|
-
const providerData = JSON.parse(fs14.readFileSync(providerJson, "utf-8"));
|
|
40580
|
-
if (providerData.disableUpstream !== true) {
|
|
40581
|
-
providerData.disableUpstream = true;
|
|
40582
|
-
fs14.writeFileSync(providerJson, JSON.stringify(providerData, null, 2));
|
|
40583
|
-
}
|
|
40584
|
-
} catch (error48) {
|
|
40585
|
-
return {
|
|
40586
|
-
dir: null,
|
|
40587
|
-
reason: `Failed to update provider.json in writable provider directory: ${error48.message}`
|
|
40588
|
-
};
|
|
40589
|
-
}
|
|
40590
41205
|
return { dir: desiredDir };
|
|
40591
41206
|
}
|
|
40592
41207
|
async handleAutoImplement(type, req, res) {
|
|
@@ -40731,7 +41346,7 @@ var init_dev_server = __esm({
|
|
|
40731
41346
|
lines.push("## Required Return Format");
|
|
40732
41347
|
lines.push("| Function | Return JSON |");
|
|
40733
41348
|
lines.push("|---|---|");
|
|
40734
|
-
lines.push("| readChat | `{ id, status, title, messages: [{role, content, index, kind?, meta?}], inputContent, activeModal }` \u2014 optional `kind`: standard, thought, tool, terminal;
|
|
41349
|
+
lines.push("| readChat | `{ id, status, title, messages: [{role, content, index, kind?, meta?}], inputContent, activeModal, controlValues?, summaryMetadata? }` \u2014 optional `kind`: standard, thought, tool, terminal; prefer explicit `controlValues` for current selections and `summaryMetadata` for compact always-visible UI metadata |");
|
|
40735
41350
|
lines.push("| sendMessage | `{ sent: false, needsTypeAndSend: true, selector }` |");
|
|
40736
41351
|
lines.push("| resolveAction | `{ resolved: true/false, clicked? }` |");
|
|
40737
41352
|
lines.push("| listSessions | `{ sessions: [{ id, title, active, index }] }` |");
|
|
@@ -41112,14 +41727,14 @@ data: ${JSON.stringify(msg.data)}
|
|
|
41112
41727
|
res.end(JSON.stringify(data, null, 2));
|
|
41113
41728
|
}
|
|
41114
41729
|
async readBody(req) {
|
|
41115
|
-
return new Promise((
|
|
41730
|
+
return new Promise((resolve15) => {
|
|
41116
41731
|
let body = "";
|
|
41117
41732
|
req.on("data", (chunk) => body += chunk);
|
|
41118
41733
|
req.on("end", () => {
|
|
41119
41734
|
try {
|
|
41120
|
-
|
|
41735
|
+
resolve15(JSON.parse(body));
|
|
41121
41736
|
} catch {
|
|
41122
|
-
|
|
41737
|
+
resolve15({});
|
|
41123
41738
|
}
|
|
41124
41739
|
});
|
|
41125
41740
|
});
|
|
@@ -41604,7 +42219,7 @@ async function waitForReady(endpoint, timeoutMs = STARTUP_TIMEOUT_MS) {
|
|
|
41604
42219
|
const deadline = Date.now() + timeoutMs;
|
|
41605
42220
|
while (Date.now() < deadline) {
|
|
41606
42221
|
if (await canConnect(endpoint)) return;
|
|
41607
|
-
await new Promise((
|
|
42222
|
+
await new Promise((resolve15) => setTimeout(resolve15, STARTUP_POLL_MS));
|
|
41608
42223
|
}
|
|
41609
42224
|
throw new Error(`Session host did not become ready within ${timeoutMs}ms`);
|
|
41610
42225
|
}
|
|
@@ -41653,67 +42268,6 @@ var init_runtime_support = __esm({
|
|
|
41653
42268
|
}
|
|
41654
42269
|
});
|
|
41655
42270
|
|
|
41656
|
-
// ../../oss/packages/daemon-core/src/session-host/runtime-surface.ts
|
|
41657
|
-
function isSessionHostLiveRuntime(record2) {
|
|
41658
|
-
const lifecycle = String(record2?.lifecycle || "").trim();
|
|
41659
|
-
return LIVE_LIFECYCLES.has(lifecycle);
|
|
41660
|
-
}
|
|
41661
|
-
function getSessionHostRecoveryLabel(meta3) {
|
|
41662
|
-
const recoveryState = typeof meta3?.runtimeRecoveryState === "string" ? String(meta3.runtimeRecoveryState).trim() : "";
|
|
41663
|
-
if (!recoveryState) return null;
|
|
41664
|
-
if (recoveryState === "auto_resumed") return "restored after restart";
|
|
41665
|
-
if (recoveryState === "resume_failed") return "restore failed";
|
|
41666
|
-
if (recoveryState === "host_restart_interrupted") return "host restart interrupted";
|
|
41667
|
-
if (recoveryState === "orphan_snapshot") return "snapshot recovered";
|
|
41668
|
-
return recoveryState.replace(/_/g, " ");
|
|
41669
|
-
}
|
|
41670
|
-
function isSessionHostRecoverySnapshot(record2) {
|
|
41671
|
-
if (!record2) return false;
|
|
41672
|
-
if (isSessionHostLiveRuntime(record2)) return false;
|
|
41673
|
-
const lifecycle = String(record2.lifecycle || "").trim();
|
|
41674
|
-
if (lifecycle && lifecycle !== "stopped" && lifecycle !== "failed") {
|
|
41675
|
-
return false;
|
|
41676
|
-
}
|
|
41677
|
-
const meta3 = record2.meta || void 0;
|
|
41678
|
-
if (meta3?.restoredFromStorage === true) return true;
|
|
41679
|
-
return getSessionHostRecoveryLabel(meta3) !== null;
|
|
41680
|
-
}
|
|
41681
|
-
function getSessionHostSurfaceKind(record2) {
|
|
41682
|
-
if (isSessionHostLiveRuntime(record2)) return "live_runtime";
|
|
41683
|
-
if (isSessionHostRecoverySnapshot(record2)) return "recovery_snapshot";
|
|
41684
|
-
return "inactive_record";
|
|
41685
|
-
}
|
|
41686
|
-
function partitionSessionHostRecords(records) {
|
|
41687
|
-
const liveRuntimes = [];
|
|
41688
|
-
const recoverySnapshots = [];
|
|
41689
|
-
const inactiveRecords = [];
|
|
41690
|
-
for (const record2 of records) {
|
|
41691
|
-
const kind = getSessionHostSurfaceKind(record2);
|
|
41692
|
-
if (kind === "live_runtime") {
|
|
41693
|
-
liveRuntimes.push(record2);
|
|
41694
|
-
} else if (kind === "recovery_snapshot") {
|
|
41695
|
-
recoverySnapshots.push(record2);
|
|
41696
|
-
} else {
|
|
41697
|
-
inactiveRecords.push(record2);
|
|
41698
|
-
}
|
|
41699
|
-
}
|
|
41700
|
-
return {
|
|
41701
|
-
liveRuntimes,
|
|
41702
|
-
recoverySnapshots,
|
|
41703
|
-
inactiveRecords
|
|
41704
|
-
};
|
|
41705
|
-
}
|
|
41706
|
-
function partitionSessionHostDiagnosticsSessions(records) {
|
|
41707
|
-
return partitionSessionHostRecords(records || []);
|
|
41708
|
-
}
|
|
41709
|
-
var LIVE_LIFECYCLES;
|
|
41710
|
-
var init_runtime_surface = __esm({
|
|
41711
|
-
"../../oss/packages/daemon-core/src/session-host/runtime-surface.ts"() {
|
|
41712
|
-
"use strict";
|
|
41713
|
-
LIVE_LIFECYCLES = /* @__PURE__ */ new Set(["starting", "running", "stopping", "interrupted"]);
|
|
41714
|
-
}
|
|
41715
|
-
});
|
|
41716
|
-
|
|
41717
42271
|
// ../../oss/packages/daemon-core/src/session-host/startup-restore-policy.js
|
|
41718
42272
|
function shouldAutoRestoreHostedSessionsOnStartup(env3 = process.env) {
|
|
41719
42273
|
const raw = typeof env3.ADHDEV_RESTORE_HOSTED_SESSIONS_ON_STARTUP === "string" ? env3.ADHDEV_RESTORE_HOSTED_SESSIONS_ON_STARTUP.trim().toLowerCase() : "";
|
|
@@ -41768,10 +42322,10 @@ async function installExtension(ide, extension) {
|
|
|
41768
42322
|
const buffer = Buffer.from(await res.arrayBuffer());
|
|
41769
42323
|
const fs24 = await import("fs");
|
|
41770
42324
|
fs24.writeFileSync(vsixPath, buffer);
|
|
41771
|
-
return new Promise((
|
|
42325
|
+
return new Promise((resolve15) => {
|
|
41772
42326
|
const cmd = `"${ide.cliCommand}" --install-extension "${vsixPath}" --force`;
|
|
41773
42327
|
(0, import_child_process10.exec)(cmd, { timeout: 6e4 }, (error48, _stdout, stderr) => {
|
|
41774
|
-
|
|
42328
|
+
resolve15({
|
|
41775
42329
|
extensionId: extension.id,
|
|
41776
42330
|
marketplaceId: extension.marketplaceId,
|
|
41777
42331
|
success: !error48,
|
|
@@ -41784,11 +42338,11 @@ async function installExtension(ide, extension) {
|
|
|
41784
42338
|
} catch (e) {
|
|
41785
42339
|
}
|
|
41786
42340
|
}
|
|
41787
|
-
return new Promise((
|
|
42341
|
+
return new Promise((resolve15) => {
|
|
41788
42342
|
const cmd = `"${ide.cliCommand}" --install-extension ${extension.marketplaceId} --force`;
|
|
41789
42343
|
(0, import_child_process10.exec)(cmd, { timeout: 6e4 }, (error48, stdout, stderr) => {
|
|
41790
42344
|
if (error48) {
|
|
41791
|
-
|
|
42345
|
+
resolve15({
|
|
41792
42346
|
extensionId: extension.id,
|
|
41793
42347
|
marketplaceId: extension.marketplaceId,
|
|
41794
42348
|
success: false,
|
|
@@ -41796,7 +42350,7 @@ async function installExtension(ide, extension) {
|
|
|
41796
42350
|
error: stderr || error48.message
|
|
41797
42351
|
});
|
|
41798
42352
|
} else {
|
|
41799
|
-
|
|
42353
|
+
resolve15({
|
|
41800
42354
|
extensionId: extension.id,
|
|
41801
42355
|
marketplaceId: extension.marketplaceId,
|
|
41802
42356
|
success: true,
|
|
@@ -41990,10 +42544,11 @@ var init_registry = __esm({
|
|
|
41990
42544
|
async function initDaemonComponents(config2) {
|
|
41991
42545
|
installGlobalInterceptor();
|
|
41992
42546
|
const appConfig = loadConfig();
|
|
41993
|
-
const
|
|
42547
|
+
const providerSourceMode = appConfig.providerSourceMode || "normal";
|
|
42548
|
+
const disableUpstream = providerSourceMode === "no-upstream";
|
|
41994
42549
|
const providerLoader = new ProviderLoader({
|
|
41995
42550
|
logFn: config2.providerLogFn,
|
|
41996
|
-
|
|
42551
|
+
sourceMode: providerSourceMode,
|
|
41997
42552
|
userDir: appConfig.providerDir
|
|
41998
42553
|
});
|
|
41999
42554
|
if (!disableUpstream && !providerLoader.hasUpstream()) {
|
|
@@ -42098,6 +42653,10 @@ async function initDaemonComponents(config2) {
|
|
|
42098
42653
|
onProviderSettingChanged: async (providerType) => {
|
|
42099
42654
|
await refreshProviderAvailability(providerType);
|
|
42100
42655
|
config2.onStatusChange?.();
|
|
42656
|
+
},
|
|
42657
|
+
onProviderSourceConfigChanged: async () => {
|
|
42658
|
+
await refreshProviderAvailability();
|
|
42659
|
+
config2.onStatusChange?.();
|
|
42101
42660
|
}
|
|
42102
42661
|
});
|
|
42103
42662
|
agentStreamManager = new DaemonAgentStreamManager(
|
|
@@ -42147,7 +42706,8 @@ async function initDaemonComponents(config2) {
|
|
|
42147
42706
|
cdpInitializer,
|
|
42148
42707
|
cdpManagers,
|
|
42149
42708
|
sessionRegistry,
|
|
42150
|
-
detectedIdes: detectedIdesRef
|
|
42709
|
+
detectedIdes: detectedIdesRef,
|
|
42710
|
+
refreshProviderAvailability
|
|
42151
42711
|
};
|
|
42152
42712
|
}
|
|
42153
42713
|
async function startDaemonDevSupport(options) {
|
|
@@ -42156,7 +42716,10 @@ async function startDaemonDevSupport(options) {
|
|
|
42156
42716
|
cdpManagers: options.components.cdpManagers,
|
|
42157
42717
|
instanceManager: options.components.instanceManager,
|
|
42158
42718
|
cliManager: options.components.cliManager,
|
|
42159
|
-
logFn: options.logFn
|
|
42719
|
+
logFn: options.logFn,
|
|
42720
|
+
onProviderSourceConfigChanged: async () => {
|
|
42721
|
+
await options.components.refreshProviderAvailability();
|
|
42722
|
+
}
|
|
42160
42723
|
});
|
|
42161
42724
|
await devServer.start();
|
|
42162
42725
|
options.components.providerLoader.watch();
|
|
@@ -42306,6 +42869,7 @@ __export(src_exports, {
|
|
|
42306
42869
|
normalizeInputEnvelope: () => normalizeInputEnvelope,
|
|
42307
42870
|
normalizeManagedStatus: () => normalizeManagedStatus,
|
|
42308
42871
|
normalizeMessageParts: () => normalizeMessageParts,
|
|
42872
|
+
parseProviderSourceConfigUpdate: () => parseProviderSourceConfigUpdate,
|
|
42309
42873
|
partitionSessionHostDiagnosticsSessions: () => partitionSessionHostDiagnosticsSessions,
|
|
42310
42874
|
partitionSessionHostRecords: () => partitionSessionHostRecords,
|
|
42311
42875
|
probeCdpPort: () => probeCdpPort,
|
|
@@ -42369,6 +42933,7 @@ var init_src = __esm({
|
|
|
42369
42933
|
init_ide_provider_instance();
|
|
42370
42934
|
init_cli_provider_instance();
|
|
42371
42935
|
init_acp_provider_instance();
|
|
42936
|
+
init_provider_source_config();
|
|
42372
42937
|
init_io_contracts();
|
|
42373
42938
|
init_version_archive();
|
|
42374
42939
|
init_dev_server();
|
|
@@ -42808,7 +43373,7 @@ function routeDataChannelMessage(peerId, msg, peers, handlers) {
|
|
|
42808
43373
|
log(`pty_input: REJECTED \u2014 permission=${permission} peer=${peerId}`);
|
|
42809
43374
|
return;
|
|
42810
43375
|
}
|
|
42811
|
-
const sessionId = parsed.sessionId || parsed.cliId || parsed.cliType || "";
|
|
43376
|
+
const sessionId = parsed.sessionId || parsed.targetSessionId || parsed.cliId || parsed.cliType || "";
|
|
42812
43377
|
if (handlers.ptyInputHandler && parsed.data && sessionId) {
|
|
42813
43378
|
handlers.ptyInputHandler(sessionId, parsed.data);
|
|
42814
43379
|
}
|
|
@@ -42820,7 +43385,7 @@ function routeDataChannelMessage(peerId, msg, peers, handlers) {
|
|
|
42820
43385
|
log(`pty_resize: REJECTED \u2014 permission=${permission} peer=${peerId}`);
|
|
42821
43386
|
return;
|
|
42822
43387
|
}
|
|
42823
|
-
const sessionId = parsed.sessionId || parsed.cliId || parsed.cliType || "";
|
|
43388
|
+
const sessionId = parsed.sessionId || parsed.targetSessionId || parsed.cliId || parsed.cliType || "";
|
|
42824
43389
|
if (handlers.ptyResizeHandler && parsed.cols && parsed.rows && sessionId) {
|
|
42825
43390
|
handlers.ptyResizeHandler(sessionId, parsed.cols, parsed.rows);
|
|
42826
43391
|
}
|
|
@@ -43838,14 +44403,14 @@ var require_filesystem = __commonJS({
|
|
|
43838
44403
|
});
|
|
43839
44404
|
return buffer.subarray(0, bytesRead);
|
|
43840
44405
|
};
|
|
43841
|
-
var readFile = (path30) => new Promise((
|
|
44406
|
+
var readFile = (path30) => new Promise((resolve15, reject) => {
|
|
43842
44407
|
fs24.open(path30, "r", (err, fd) => {
|
|
43843
44408
|
if (err) {
|
|
43844
44409
|
reject(err);
|
|
43845
44410
|
} else {
|
|
43846
44411
|
const buffer = Buffer.alloc(MAX_LENGTH);
|
|
43847
44412
|
fs24.read(fd, buffer, 0, MAX_LENGTH, 0, (_2, bytesRead) => {
|
|
43848
|
-
|
|
44413
|
+
resolve15(buffer.subarray(0, bytesRead));
|
|
43849
44414
|
fs24.close(fd, () => {
|
|
43850
44415
|
});
|
|
43851
44416
|
});
|
|
@@ -43913,10 +44478,10 @@ var require_detect_libc = __commonJS({
|
|
|
43913
44478
|
var commandOut = "";
|
|
43914
44479
|
var safeCommand = () => {
|
|
43915
44480
|
if (!commandOut) {
|
|
43916
|
-
return new Promise((
|
|
44481
|
+
return new Promise((resolve15) => {
|
|
43917
44482
|
childProcess2.exec(command, (err, out) => {
|
|
43918
44483
|
commandOut = err ? " " : out;
|
|
43919
|
-
|
|
44484
|
+
resolve15(commandOut);
|
|
43920
44485
|
});
|
|
43921
44486
|
});
|
|
43922
44487
|
}
|
|
@@ -46596,14 +47161,14 @@ var require_input = __commonJS({
|
|
|
46596
47161
|
return this;
|
|
46597
47162
|
} else {
|
|
46598
47163
|
if (this._isStreamInput()) {
|
|
46599
|
-
return new Promise((
|
|
47164
|
+
return new Promise((resolve15, reject) => {
|
|
46600
47165
|
const finished = () => {
|
|
46601
47166
|
this._flattenBufferIn();
|
|
46602
47167
|
sharp.metadata(this.options, (err, metadata2) => {
|
|
46603
47168
|
if (err) {
|
|
46604
47169
|
reject(is.nativeError(err, stack));
|
|
46605
47170
|
} else {
|
|
46606
|
-
|
|
47171
|
+
resolve15(metadata2);
|
|
46607
47172
|
}
|
|
46608
47173
|
});
|
|
46609
47174
|
};
|
|
@@ -46614,12 +47179,12 @@ var require_input = __commonJS({
|
|
|
46614
47179
|
}
|
|
46615
47180
|
});
|
|
46616
47181
|
} else {
|
|
46617
|
-
return new Promise((
|
|
47182
|
+
return new Promise((resolve15, reject) => {
|
|
46618
47183
|
sharp.metadata(this.options, (err, metadata2) => {
|
|
46619
47184
|
if (err) {
|
|
46620
47185
|
reject(is.nativeError(err, stack));
|
|
46621
47186
|
} else {
|
|
46622
|
-
|
|
47187
|
+
resolve15(metadata2);
|
|
46623
47188
|
}
|
|
46624
47189
|
});
|
|
46625
47190
|
});
|
|
@@ -46652,25 +47217,25 @@ var require_input = __commonJS({
|
|
|
46652
47217
|
return this;
|
|
46653
47218
|
} else {
|
|
46654
47219
|
if (this._isStreamInput()) {
|
|
46655
|
-
return new Promise((
|
|
47220
|
+
return new Promise((resolve15, reject) => {
|
|
46656
47221
|
this.on("finish", function() {
|
|
46657
47222
|
this._flattenBufferIn();
|
|
46658
47223
|
sharp.stats(this.options, (err, stats2) => {
|
|
46659
47224
|
if (err) {
|
|
46660
47225
|
reject(is.nativeError(err, stack));
|
|
46661
47226
|
} else {
|
|
46662
|
-
|
|
47227
|
+
resolve15(stats2);
|
|
46663
47228
|
}
|
|
46664
47229
|
});
|
|
46665
47230
|
});
|
|
46666
47231
|
});
|
|
46667
47232
|
} else {
|
|
46668
|
-
return new Promise((
|
|
47233
|
+
return new Promise((resolve15, reject) => {
|
|
46669
47234
|
sharp.stats(this.options, (err, stats2) => {
|
|
46670
47235
|
if (err) {
|
|
46671
47236
|
reject(is.nativeError(err, stack));
|
|
46672
47237
|
} else {
|
|
46673
|
-
|
|
47238
|
+
resolve15(stats2);
|
|
46674
47239
|
}
|
|
46675
47240
|
});
|
|
46676
47241
|
});
|
|
@@ -50092,7 +50657,7 @@ var require_output = __commonJS({
|
|
|
50092
50657
|
return this;
|
|
50093
50658
|
} else {
|
|
50094
50659
|
if (this._isStreamInput()) {
|
|
50095
|
-
return new Promise((
|
|
50660
|
+
return new Promise((resolve15, reject) => {
|
|
50096
50661
|
this.once("finish", () => {
|
|
50097
50662
|
this._flattenBufferIn();
|
|
50098
50663
|
sharp.pipeline(this.options, (err, data, info) => {
|
|
@@ -50100,24 +50665,24 @@ var require_output = __commonJS({
|
|
|
50100
50665
|
reject(is.nativeError(err, stack));
|
|
50101
50666
|
} else {
|
|
50102
50667
|
if (this.options.resolveWithObject) {
|
|
50103
|
-
|
|
50668
|
+
resolve15({ data, info });
|
|
50104
50669
|
} else {
|
|
50105
|
-
|
|
50670
|
+
resolve15(data);
|
|
50106
50671
|
}
|
|
50107
50672
|
}
|
|
50108
50673
|
});
|
|
50109
50674
|
});
|
|
50110
50675
|
});
|
|
50111
50676
|
} else {
|
|
50112
|
-
return new Promise((
|
|
50677
|
+
return new Promise((resolve15, reject) => {
|
|
50113
50678
|
sharp.pipeline(this.options, (err, data, info) => {
|
|
50114
50679
|
if (err) {
|
|
50115
50680
|
reject(is.nativeError(err, stack));
|
|
50116
50681
|
} else {
|
|
50117
50682
|
if (this.options.resolveWithObject) {
|
|
50118
|
-
|
|
50683
|
+
resolve15({ data, info });
|
|
50119
50684
|
} else {
|
|
50120
|
-
|
|
50685
|
+
resolve15(data);
|
|
50121
50686
|
}
|
|
50122
50687
|
}
|
|
50123
50688
|
});
|
|
@@ -51677,7 +52242,7 @@ var init_adhdev_daemon = __esm({
|
|
|
51677
52242
|
import_ws3 = require("ws");
|
|
51678
52243
|
init_source2();
|
|
51679
52244
|
init_version();
|
|
51680
|
-
pkgVersion = resolvePackageVersion({ injectedVersion: "0.8.
|
|
52245
|
+
pkgVersion = resolvePackageVersion({ injectedVersion: "0.8.59" });
|
|
51681
52246
|
ACTIVE_CHAT_POLL_STATUSES = /* @__PURE__ */ new Set([
|
|
51682
52247
|
"generating",
|
|
51683
52248
|
"waiting_approval",
|
|
@@ -52185,6 +52750,8 @@ ${err?.stack || ""}`);
|
|
|
52185
52750
|
forwardAgentStreamsToIdeInstance(this.components.instanceManager, ideType, streams);
|
|
52186
52751
|
}
|
|
52187
52752
|
});
|
|
52753
|
+
const providerSourceConfig = this.components.providerLoader.getSourceConfig();
|
|
52754
|
+
LOG.info("Provider", `Source config: mode=${providerSourceConfig.sourceMode} explicitProviderDir=${providerSourceConfig.explicitProviderDir || "-"} userDir=${providerSourceConfig.userDir} upstreamDir=${providerSourceConfig.upstreamDir}`);
|
|
52188
52755
|
if (shouldAutoRestoreHostedSessionsOnStartup(process.env)) {
|
|
52189
52756
|
await this.components.cliManager.restoreHostedSessions();
|
|
52190
52757
|
}
|
|
@@ -52346,7 +52913,11 @@ ${err?.stack || ""}`);
|
|
|
52346
52913
|
providerLoader: this.components.providerLoader,
|
|
52347
52914
|
cdpManagers: this.components.cdpManagers,
|
|
52348
52915
|
instanceManager: this.components.instanceManager,
|
|
52349
|
-
cliManager: this.components.cliManager
|
|
52916
|
+
cliManager: this.components.cliManager,
|
|
52917
|
+
onProviderSourceConfigChanged: async () => {
|
|
52918
|
+
await this.components.refreshProviderAvailability();
|
|
52919
|
+
this.statusReporter?.onStatusChange();
|
|
52920
|
+
}
|
|
52350
52921
|
});
|
|
52351
52922
|
await devServer.start();
|
|
52352
52923
|
}
|
|
@@ -52543,7 +53114,7 @@ ${err?.stack || ""}`);
|
|
|
52543
53114
|
this.localWss.emit("connection", ws, req);
|
|
52544
53115
|
});
|
|
52545
53116
|
});
|
|
52546
|
-
await new Promise((
|
|
53117
|
+
await new Promise((resolve15, reject) => {
|
|
52547
53118
|
const cleanup = () => {
|
|
52548
53119
|
this.localHttpServer?.off("error", onError);
|
|
52549
53120
|
this.localHttpServer?.off("listening", onListening);
|
|
@@ -52554,7 +53125,7 @@ ${err?.stack || ""}`);
|
|
|
52554
53125
|
};
|
|
52555
53126
|
const onListening = () => {
|
|
52556
53127
|
cleanup();
|
|
52557
|
-
|
|
53128
|
+
resolve15();
|
|
52558
53129
|
};
|
|
52559
53130
|
this.localHttpServer.once("error", onError);
|
|
52560
53131
|
this.localHttpServer.once("listening", onListening);
|
|
@@ -52714,12 +53285,12 @@ ${err?.stack || ""}`);
|
|
|
52714
53285
|
this.localClients.clear();
|
|
52715
53286
|
this.localWss?.close();
|
|
52716
53287
|
this.localWss = null;
|
|
52717
|
-
await new Promise((
|
|
53288
|
+
await new Promise((resolve15) => {
|
|
52718
53289
|
if (!this.localHttpServer) {
|
|
52719
|
-
|
|
53290
|
+
resolve15();
|
|
52720
53291
|
return;
|
|
52721
53292
|
}
|
|
52722
|
-
this.localHttpServer.close(() =>
|
|
53293
|
+
this.localHttpServer.close(() => resolve15());
|
|
52723
53294
|
this.localHttpServer = null;
|
|
52724
53295
|
});
|
|
52725
53296
|
} catch {
|
|
@@ -53267,14 +53838,14 @@ var require_run_async = __commonJS({
|
|
|
53267
53838
|
return function() {
|
|
53268
53839
|
var args = arguments;
|
|
53269
53840
|
var originalThis = this;
|
|
53270
|
-
var promise2 = new Promise(function(
|
|
53841
|
+
var promise2 = new Promise(function(resolve15, reject) {
|
|
53271
53842
|
var resolved = false;
|
|
53272
53843
|
const wrappedResolve = function(value) {
|
|
53273
53844
|
if (resolved) {
|
|
53274
53845
|
console.warn("Run-async promise already resolved.");
|
|
53275
53846
|
}
|
|
53276
53847
|
resolved = true;
|
|
53277
|
-
|
|
53848
|
+
resolve15(value);
|
|
53278
53849
|
};
|
|
53279
53850
|
var rejected = false;
|
|
53280
53851
|
const wrappedReject = function(value) {
|
|
@@ -54065,7 +54636,7 @@ var require_Observable = __commonJS({
|
|
|
54065
54636
|
Observable2.prototype.forEach = function(next, promiseCtor) {
|
|
54066
54637
|
var _this = this;
|
|
54067
54638
|
promiseCtor = getPromiseCtor(promiseCtor);
|
|
54068
|
-
return new promiseCtor(function(
|
|
54639
|
+
return new promiseCtor(function(resolve15, reject) {
|
|
54069
54640
|
var subscriber = new Subscriber_1.SafeSubscriber({
|
|
54070
54641
|
next: function(value) {
|
|
54071
54642
|
try {
|
|
@@ -54076,7 +54647,7 @@ var require_Observable = __commonJS({
|
|
|
54076
54647
|
}
|
|
54077
54648
|
},
|
|
54078
54649
|
error: reject,
|
|
54079
|
-
complete:
|
|
54650
|
+
complete: resolve15
|
|
54080
54651
|
});
|
|
54081
54652
|
_this.subscribe(subscriber);
|
|
54082
54653
|
});
|
|
@@ -54098,14 +54669,14 @@ var require_Observable = __commonJS({
|
|
|
54098
54669
|
Observable2.prototype.toPromise = function(promiseCtor) {
|
|
54099
54670
|
var _this = this;
|
|
54100
54671
|
promiseCtor = getPromiseCtor(promiseCtor);
|
|
54101
|
-
return new promiseCtor(function(
|
|
54672
|
+
return new promiseCtor(function(resolve15, reject) {
|
|
54102
54673
|
var value;
|
|
54103
54674
|
_this.subscribe(function(x) {
|
|
54104
54675
|
return value = x;
|
|
54105
54676
|
}, function(err) {
|
|
54106
54677
|
return reject(err);
|
|
54107
54678
|
}, function() {
|
|
54108
|
-
return
|
|
54679
|
+
return resolve15(value);
|
|
54109
54680
|
});
|
|
54110
54681
|
});
|
|
54111
54682
|
};
|
|
@@ -56201,11 +56772,11 @@ var require_innerFrom = __commonJS({
|
|
|
56201
56772
|
"use strict";
|
|
56202
56773
|
var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
56203
56774
|
function adopt(value) {
|
|
56204
|
-
return value instanceof P ? value : new P(function(
|
|
56205
|
-
|
|
56775
|
+
return value instanceof P ? value : new P(function(resolve15) {
|
|
56776
|
+
resolve15(value);
|
|
56206
56777
|
});
|
|
56207
56778
|
}
|
|
56208
|
-
return new (P || (P = Promise))(function(
|
|
56779
|
+
return new (P || (P = Promise))(function(resolve15, reject) {
|
|
56209
56780
|
function fulfilled(value) {
|
|
56210
56781
|
try {
|
|
56211
56782
|
step(generator.next(value));
|
|
@@ -56221,7 +56792,7 @@ var require_innerFrom = __commonJS({
|
|
|
56221
56792
|
}
|
|
56222
56793
|
}
|
|
56223
56794
|
function step(result) {
|
|
56224
|
-
result.done ?
|
|
56795
|
+
result.done ? resolve15(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
56225
56796
|
}
|
|
56226
56797
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
56227
56798
|
});
|
|
@@ -56303,14 +56874,14 @@ var require_innerFrom = __commonJS({
|
|
|
56303
56874
|
}, i);
|
|
56304
56875
|
function verb(n) {
|
|
56305
56876
|
i[n] = o[n] && function(v) {
|
|
56306
|
-
return new Promise(function(
|
|
56307
|
-
v = o[n](v), settle(
|
|
56877
|
+
return new Promise(function(resolve15, reject) {
|
|
56878
|
+
v = o[n](v), settle(resolve15, reject, v.done, v.value);
|
|
56308
56879
|
});
|
|
56309
56880
|
};
|
|
56310
56881
|
}
|
|
56311
|
-
function settle(
|
|
56882
|
+
function settle(resolve15, reject, d, v) {
|
|
56312
56883
|
Promise.resolve(v).then(function(v2) {
|
|
56313
|
-
|
|
56884
|
+
resolve15({ value: v2, done: d });
|
|
56314
56885
|
}, reject);
|
|
56315
56886
|
}
|
|
56316
56887
|
};
|
|
@@ -56929,7 +57500,7 @@ var require_lastValueFrom = __commonJS({
|
|
|
56929
57500
|
var EmptyError_1 = require_EmptyError();
|
|
56930
57501
|
function lastValueFrom(source, config2) {
|
|
56931
57502
|
var hasConfig = typeof config2 === "object";
|
|
56932
|
-
return new Promise(function(
|
|
57503
|
+
return new Promise(function(resolve15, reject) {
|
|
56933
57504
|
var _hasValue = false;
|
|
56934
57505
|
var _value;
|
|
56935
57506
|
source.subscribe({
|
|
@@ -56940,9 +57511,9 @@ var require_lastValueFrom = __commonJS({
|
|
|
56940
57511
|
error: reject,
|
|
56941
57512
|
complete: function() {
|
|
56942
57513
|
if (_hasValue) {
|
|
56943
|
-
|
|
57514
|
+
resolve15(_value);
|
|
56944
57515
|
} else if (hasConfig) {
|
|
56945
|
-
|
|
57516
|
+
resolve15(config2.defaultValue);
|
|
56946
57517
|
} else {
|
|
56947
57518
|
reject(new EmptyError_1.EmptyError());
|
|
56948
57519
|
}
|
|
@@ -56964,16 +57535,16 @@ var require_firstValueFrom = __commonJS({
|
|
|
56964
57535
|
var Subscriber_1 = require_Subscriber();
|
|
56965
57536
|
function firstValueFrom(source, config2) {
|
|
56966
57537
|
var hasConfig = typeof config2 === "object";
|
|
56967
|
-
return new Promise(function(
|
|
57538
|
+
return new Promise(function(resolve15, reject) {
|
|
56968
57539
|
var subscriber = new Subscriber_1.SafeSubscriber({
|
|
56969
57540
|
next: function(value) {
|
|
56970
|
-
|
|
57541
|
+
resolve15(value);
|
|
56971
57542
|
subscriber.unsubscribe();
|
|
56972
57543
|
},
|
|
56973
57544
|
error: reject,
|
|
56974
57545
|
complete: function() {
|
|
56975
57546
|
if (hasConfig) {
|
|
56976
|
-
|
|
57547
|
+
resolve15(config2.defaultValue);
|
|
56977
57548
|
} else {
|
|
56978
57549
|
reject(new EmptyError_1.EmptyError());
|
|
56979
57550
|
}
|
|
@@ -68779,14 +69350,14 @@ var require_async_iterator = __commonJS({
|
|
|
68779
69350
|
};
|
|
68780
69351
|
}
|
|
68781
69352
|
function readAndResolve(iter) {
|
|
68782
|
-
var
|
|
68783
|
-
if (
|
|
69353
|
+
var resolve15 = iter[kLastResolve];
|
|
69354
|
+
if (resolve15 !== null) {
|
|
68784
69355
|
var data = iter[kStream].read();
|
|
68785
69356
|
if (data !== null) {
|
|
68786
69357
|
iter[kLastPromise] = null;
|
|
68787
69358
|
iter[kLastResolve] = null;
|
|
68788
69359
|
iter[kLastReject] = null;
|
|
68789
|
-
|
|
69360
|
+
resolve15(createIterResult(data, false));
|
|
68790
69361
|
}
|
|
68791
69362
|
}
|
|
68792
69363
|
}
|
|
@@ -68794,13 +69365,13 @@ var require_async_iterator = __commonJS({
|
|
|
68794
69365
|
process.nextTick(readAndResolve, iter);
|
|
68795
69366
|
}
|
|
68796
69367
|
function wrapForNext(lastPromise, iter) {
|
|
68797
|
-
return function(
|
|
69368
|
+
return function(resolve15, reject) {
|
|
68798
69369
|
lastPromise.then(function() {
|
|
68799
69370
|
if (iter[kEnded]) {
|
|
68800
|
-
|
|
69371
|
+
resolve15(createIterResult(void 0, true));
|
|
68801
69372
|
return;
|
|
68802
69373
|
}
|
|
68803
|
-
iter[kHandlePromise](
|
|
69374
|
+
iter[kHandlePromise](resolve15, reject);
|
|
68804
69375
|
}, reject);
|
|
68805
69376
|
};
|
|
68806
69377
|
}
|
|
@@ -68820,12 +69391,12 @@ var require_async_iterator = __commonJS({
|
|
|
68820
69391
|
return Promise.resolve(createIterResult(void 0, true));
|
|
68821
69392
|
}
|
|
68822
69393
|
if (this[kStream].destroyed) {
|
|
68823
|
-
return new Promise(function(
|
|
69394
|
+
return new Promise(function(resolve15, reject) {
|
|
68824
69395
|
process.nextTick(function() {
|
|
68825
69396
|
if (_this[kError]) {
|
|
68826
69397
|
reject(_this[kError]);
|
|
68827
69398
|
} else {
|
|
68828
|
-
|
|
69399
|
+
resolve15(createIterResult(void 0, true));
|
|
68829
69400
|
}
|
|
68830
69401
|
});
|
|
68831
69402
|
});
|
|
@@ -68848,13 +69419,13 @@ var require_async_iterator = __commonJS({
|
|
|
68848
69419
|
return this;
|
|
68849
69420
|
}), _defineProperty(_Object$setPrototypeO, "return", function _return() {
|
|
68850
69421
|
var _this2 = this;
|
|
68851
|
-
return new Promise(function(
|
|
69422
|
+
return new Promise(function(resolve15, reject) {
|
|
68852
69423
|
_this2[kStream].destroy(null, function(err) {
|
|
68853
69424
|
if (err) {
|
|
68854
69425
|
reject(err);
|
|
68855
69426
|
return;
|
|
68856
69427
|
}
|
|
68857
|
-
|
|
69428
|
+
resolve15(createIterResult(void 0, true));
|
|
68858
69429
|
});
|
|
68859
69430
|
});
|
|
68860
69431
|
}), _Object$setPrototypeO), AsyncIteratorPrototype);
|
|
@@ -68876,15 +69447,15 @@ var require_async_iterator = __commonJS({
|
|
|
68876
69447
|
value: stream._readableState.endEmitted,
|
|
68877
69448
|
writable: true
|
|
68878
69449
|
}), _defineProperty(_Object$create, kHandlePromise, {
|
|
68879
|
-
value: function value(
|
|
69450
|
+
value: function value(resolve15, reject) {
|
|
68880
69451
|
var data = iterator[kStream].read();
|
|
68881
69452
|
if (data) {
|
|
68882
69453
|
iterator[kLastPromise] = null;
|
|
68883
69454
|
iterator[kLastResolve] = null;
|
|
68884
69455
|
iterator[kLastReject] = null;
|
|
68885
|
-
|
|
69456
|
+
resolve15(createIterResult(data, false));
|
|
68886
69457
|
} else {
|
|
68887
|
-
iterator[kLastResolve] =
|
|
69458
|
+
iterator[kLastResolve] = resolve15;
|
|
68888
69459
|
iterator[kLastReject] = reject;
|
|
68889
69460
|
}
|
|
68890
69461
|
},
|
|
@@ -68903,12 +69474,12 @@ var require_async_iterator = __commonJS({
|
|
|
68903
69474
|
iterator[kError] = err;
|
|
68904
69475
|
return;
|
|
68905
69476
|
}
|
|
68906
|
-
var
|
|
68907
|
-
if (
|
|
69477
|
+
var resolve15 = iterator[kLastResolve];
|
|
69478
|
+
if (resolve15 !== null) {
|
|
68908
69479
|
iterator[kLastPromise] = null;
|
|
68909
69480
|
iterator[kLastResolve] = null;
|
|
68910
69481
|
iterator[kLastReject] = null;
|
|
68911
|
-
|
|
69482
|
+
resolve15(createIterResult(void 0, true));
|
|
68912
69483
|
}
|
|
68913
69484
|
iterator[kEnded] = true;
|
|
68914
69485
|
});
|
|
@@ -68923,7 +69494,7 @@ var require_async_iterator = __commonJS({
|
|
|
68923
69494
|
var require_from2 = __commonJS({
|
|
68924
69495
|
"../../node_modules/readable-stream/lib/internal/streams/from.js"(exports2, module2) {
|
|
68925
69496
|
"use strict";
|
|
68926
|
-
function asyncGeneratorStep(gen,
|
|
69497
|
+
function asyncGeneratorStep(gen, resolve15, reject, _next, _throw, key, arg) {
|
|
68927
69498
|
try {
|
|
68928
69499
|
var info = gen[key](arg);
|
|
68929
69500
|
var value = info.value;
|
|
@@ -68932,7 +69503,7 @@ var require_from2 = __commonJS({
|
|
|
68932
69503
|
return;
|
|
68933
69504
|
}
|
|
68934
69505
|
if (info.done) {
|
|
68935
|
-
|
|
69506
|
+
resolve15(value);
|
|
68936
69507
|
} else {
|
|
68937
69508
|
Promise.resolve(value).then(_next, _throw);
|
|
68938
69509
|
}
|
|
@@ -68940,13 +69511,13 @@ var require_from2 = __commonJS({
|
|
|
68940
69511
|
function _asyncToGenerator(fn) {
|
|
68941
69512
|
return function() {
|
|
68942
69513
|
var self2 = this, args = arguments;
|
|
68943
|
-
return new Promise(function(
|
|
69514
|
+
return new Promise(function(resolve15, reject) {
|
|
68944
69515
|
var gen = fn.apply(self2, args);
|
|
68945
69516
|
function _next(value) {
|
|
68946
|
-
asyncGeneratorStep(gen,
|
|
69517
|
+
asyncGeneratorStep(gen, resolve15, reject, _next, _throw, "next", value);
|
|
68947
69518
|
}
|
|
68948
69519
|
function _throw(err) {
|
|
68949
|
-
asyncGeneratorStep(gen,
|
|
69520
|
+
asyncGeneratorStep(gen, resolve15, reject, _next, _throw, "throw", err);
|
|
68950
69521
|
}
|
|
68951
69522
|
_next(void 0);
|
|
68952
69523
|
});
|
|
@@ -70885,9 +71456,9 @@ var init_base = __esm({
|
|
|
70885
71456
|
* @return {Promise}
|
|
70886
71457
|
*/
|
|
70887
71458
|
run() {
|
|
70888
|
-
return new Promise((
|
|
71459
|
+
return new Promise((resolve15, reject) => {
|
|
70889
71460
|
this._run(
|
|
70890
|
-
(value) =>
|
|
71461
|
+
(value) => resolve15(value),
|
|
70891
71462
|
(error48) => reject(error48)
|
|
70892
71463
|
);
|
|
70893
71464
|
});
|
|
@@ -77519,7 +78090,7 @@ var require_lib2 = __commonJS({
|
|
|
77519
78090
|
return matches;
|
|
77520
78091
|
};
|
|
77521
78092
|
exports2.analyse = analyse;
|
|
77522
|
-
var detectFile = (filepath, opts = {}) => new Promise((
|
|
78093
|
+
var detectFile = (filepath, opts = {}) => new Promise((resolve15, reject) => {
|
|
77523
78094
|
let fd;
|
|
77524
78095
|
const fs24 = (0, node_1.default)();
|
|
77525
78096
|
const handler = (err, buffer) => {
|
|
@@ -77529,7 +78100,7 @@ var require_lib2 = __commonJS({
|
|
|
77529
78100
|
if (err) {
|
|
77530
78101
|
reject(err);
|
|
77531
78102
|
} else if (buffer) {
|
|
77532
|
-
|
|
78103
|
+
resolve15((0, exports2.detect)(buffer));
|
|
77533
78104
|
} else {
|
|
77534
78105
|
reject(new Error("No error and no buffer received"));
|
|
77535
78106
|
}
|
|
@@ -83714,14 +84285,14 @@ var baseOpen = async (options) => {
|
|
|
83714
84285
|
}
|
|
83715
84286
|
const subprocess = import_node_child_process5.default.spawn(command, cliArguments, childProcessOptions);
|
|
83716
84287
|
if (options.wait) {
|
|
83717
|
-
return new Promise((
|
|
84288
|
+
return new Promise((resolve15, reject) => {
|
|
83718
84289
|
subprocess.once("error", reject);
|
|
83719
84290
|
subprocess.once("close", (exitCode) => {
|
|
83720
84291
|
if (!options.allowNonzeroExitCode && exitCode > 0) {
|
|
83721
84292
|
reject(new Error(`Exited with code ${exitCode}`));
|
|
83722
84293
|
return;
|
|
83723
84294
|
}
|
|
83724
|
-
|
|
84295
|
+
resolve15(subprocess);
|
|
83725
84296
|
});
|
|
83726
84297
|
});
|
|
83727
84298
|
}
|