adhdev 0.9.33 → 0.9.35
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 +820 -518
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +458 -170
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/vendor/session-host-daemon/index.js +8 -1
- package/vendor/session-host-daemon/index.js.map +1 -1
- package/vendor/session-host-daemon/index.mjs +8 -1
- package/vendor/session-host-daemon/index.mjs.map +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -10474,7 +10474,14 @@ var init_handler = __esm({
|
|
|
10474
10474
|
await this._ctx.providerLoader.fetchLatest().catch(() => {
|
|
10475
10475
|
});
|
|
10476
10476
|
this._ctx.providerLoader.reload();
|
|
10477
|
-
|
|
10477
|
+
this._ctx.providerLoader.registerToDetector();
|
|
10478
|
+
const refreshedInstances = this._ctx.instanceManager ? this._ctx.instanceManager.refreshProviderDefinitions((providerType) => this._ctx.providerLoader.resolve(providerType)) : 0;
|
|
10479
|
+
const providers = this._ctx.providerLoader.getAll().map((provider) => ({
|
|
10480
|
+
type: provider.type,
|
|
10481
|
+
name: provider.name,
|
|
10482
|
+
category: provider.category
|
|
10483
|
+
}));
|
|
10484
|
+
return { success: true, refreshedInstances, providers };
|
|
10478
10485
|
}
|
|
10479
10486
|
return { success: false, error: "ProviderLoader not initialized" };
|
|
10480
10487
|
}
|
|
@@ -12369,13 +12376,14 @@ function sliceFromOffset(text, start) {
|
|
|
12369
12376
|
function hydrateCliParsedMessages(parsedMessages, options) {
|
|
12370
12377
|
const { committedMessages, scope, lastOutputAt } = options;
|
|
12371
12378
|
const referenceMessages = [...committedMessages];
|
|
12379
|
+
const referenceComparables = referenceMessages.map((message) => normalizeComparableMessageContent(message?.content || ""));
|
|
12372
12380
|
const usedReferenceIndexes = /* @__PURE__ */ new Set();
|
|
12373
12381
|
const now = options.now ?? Date.now();
|
|
12374
12382
|
const findReferenceTimestamp = (role, content, parsedIndex) => {
|
|
12375
12383
|
const normalizedContent = normalizeComparableMessageContent(content);
|
|
12376
12384
|
if (!normalizedContent) return void 0;
|
|
12377
12385
|
const sameIndex = referenceMessages[parsedIndex];
|
|
12378
|
-
if (sameIndex && !usedReferenceIndexes.has(parsedIndex) && sameIndex.role === role &&
|
|
12386
|
+
if (sameIndex && !usedReferenceIndexes.has(parsedIndex) && sameIndex.role === role && referenceComparables[parsedIndex] === normalizedContent && typeof sameIndex.timestamp === "number" && Number.isFinite(sameIndex.timestamp)) {
|
|
12379
12387
|
usedReferenceIndexes.add(parsedIndex);
|
|
12380
12388
|
return sameIndex.timestamp;
|
|
12381
12389
|
}
|
|
@@ -12383,7 +12391,7 @@ function hydrateCliParsedMessages(parsedMessages, options) {
|
|
|
12383
12391
|
if (usedReferenceIndexes.has(i)) continue;
|
|
12384
12392
|
const candidate = referenceMessages[i];
|
|
12385
12393
|
if (!candidate || candidate.role !== role) continue;
|
|
12386
|
-
const candidateContent =
|
|
12394
|
+
const candidateContent = referenceComparables[i];
|
|
12387
12395
|
if (!candidateContent) continue;
|
|
12388
12396
|
const exactMatch = candidateContent === normalizedContent;
|
|
12389
12397
|
const fuzzyMatch = candidateContent.includes(normalizedContent) || normalizedContent.includes(candidateContent);
|
|
@@ -12765,6 +12773,8 @@ var init_provider_cli_adapter = __esm({
|
|
|
12765
12773
|
messages = [];
|
|
12766
12774
|
committedMessages = [];
|
|
12767
12775
|
structuredMessages = [];
|
|
12776
|
+
committedMessagesActivitySignature = "";
|
|
12777
|
+
committedMessagesChangedAt = 0;
|
|
12768
12778
|
currentStatus = "starting";
|
|
12769
12779
|
onStatusChange = null;
|
|
12770
12780
|
responseBuffer = "";
|
|
@@ -12846,10 +12856,35 @@ var init_provider_cli_adapter = __esm({
|
|
|
12846
12856
|
providerResolutionMeta;
|
|
12847
12857
|
static FINISH_RETRY_DELAY_MS = 300;
|
|
12848
12858
|
static MAX_FINISH_RETRIES = 2;
|
|
12859
|
+
buildCommittedMessagesActivitySignature() {
|
|
12860
|
+
const last = this.committedMessages[this.committedMessages.length - 1];
|
|
12861
|
+
return [
|
|
12862
|
+
String(this.committedMessages.length),
|
|
12863
|
+
String(last?.role || ""),
|
|
12864
|
+
String(last?.kind || ""),
|
|
12865
|
+
String(last?.senderName || ""),
|
|
12866
|
+
String(last?.timestamp || ""),
|
|
12867
|
+
String(last?.receivedAt || ""),
|
|
12868
|
+
normalizeComparableMessageContent(last?.content || "").slice(-240)
|
|
12869
|
+
].join("|");
|
|
12870
|
+
}
|
|
12849
12871
|
syncMessageViews() {
|
|
12872
|
+
const signature = this.buildCommittedMessagesActivitySignature();
|
|
12873
|
+
if (signature !== this.committedMessagesActivitySignature) {
|
|
12874
|
+
this.committedMessagesActivitySignature = signature;
|
|
12875
|
+
this.committedMessagesChangedAt = Date.now();
|
|
12876
|
+
}
|
|
12850
12877
|
this.messages = [...this.committedMessages];
|
|
12851
12878
|
this.structuredMessages = [...this.committedMessages];
|
|
12852
12879
|
}
|
|
12880
|
+
getLastCommittedMessageActivityAt() {
|
|
12881
|
+
const last = this.committedMessages[this.committedMessages.length - 1];
|
|
12882
|
+
const messageTime = Math.max(
|
|
12883
|
+
typeof last?.receivedAt === "number" && Number.isFinite(last.receivedAt) ? last.receivedAt : 0,
|
|
12884
|
+
typeof last?.timestamp === "number" && Number.isFinite(last.timestamp) ? last.timestamp : 0
|
|
12885
|
+
);
|
|
12886
|
+
return Math.max(messageTime, this.committedMessagesChangedAt || 0);
|
|
12887
|
+
}
|
|
12853
12888
|
readTerminalScreenText(now = Date.now()) {
|
|
12854
12889
|
const screenText = this.terminalScreen.getText() || "";
|
|
12855
12890
|
this.lastScreenText = screenText;
|
|
@@ -12989,9 +13024,16 @@ var init_provider_cli_adapter = __esm({
|
|
|
12989
13024
|
/** Inject CLI scripts after construction (e.g. when resolved by ProviderLoader) */
|
|
12990
13025
|
setCliScripts(scripts) {
|
|
12991
13026
|
this.cliScripts = scripts;
|
|
13027
|
+
this.parsedStatusCache = null;
|
|
13028
|
+
this.parseErrorMessage = null;
|
|
12992
13029
|
const scriptNames = listCliScriptNames(scripts);
|
|
12993
13030
|
LOG.info("CLI", `[${this.cliType}] CLI scripts injected: [${scriptNames.join(", ")}]`);
|
|
12994
13031
|
}
|
|
13032
|
+
/** Refresh provider scripts/config used by this adapter without restarting the PTY runtime. */
|
|
13033
|
+
refreshProviderDefinition(provider) {
|
|
13034
|
+
this.provider = provider;
|
|
13035
|
+
this.setCliScripts(provider.scripts || {});
|
|
13036
|
+
}
|
|
12995
13037
|
updateRuntimeSettings(settings) {
|
|
12996
13038
|
this.runtimeSettings = { ...settings };
|
|
12997
13039
|
}
|
|
@@ -13475,7 +13517,7 @@ var init_provider_cli_adapter = __esm({
|
|
|
13475
13517
|
return;
|
|
13476
13518
|
}
|
|
13477
13519
|
if (this.currentTurnScope && !lastParsedAssistant) {
|
|
13478
|
-
LOG.
|
|
13520
|
+
LOG.debug(
|
|
13479
13521
|
"CLI",
|
|
13480
13522
|
`[${this.cliType}] Settled without assistant: prompt=${JSON.stringify(this.currentTurnScope.prompt).slice(0, 140)} responseBuffer=${JSON.stringify(summarizeCliTraceText(this.responseBuffer, 220)).slice(0, 260)} screen=${JSON.stringify(summarizeCliTraceText(screenText, 220)).slice(0, 260)} providerDir=${this.providerResolutionMeta.providerDir || "-"} scriptDir=${this.providerResolutionMeta.scriptDir || "-"}`
|
|
13481
13523
|
);
|
|
@@ -14291,9 +14333,43 @@ var init_provider_cli_adapter = __esm({
|
|
|
14291
14333
|
}
|
|
14292
14334
|
armResponseTimeout() {
|
|
14293
14335
|
if (this.responseTimeout) clearTimeout(this.responseTimeout);
|
|
14336
|
+
const timeoutMs = this.timeouts.maxResponse;
|
|
14337
|
+
if (!Number.isFinite(timeoutMs) || timeoutMs <= 0) {
|
|
14338
|
+
this.responseTimeout = null;
|
|
14339
|
+
return;
|
|
14340
|
+
}
|
|
14294
14341
|
this.responseTimeout = setTimeout(() => {
|
|
14295
|
-
|
|
14296
|
-
|
|
14342
|
+
this.responseTimeout = null;
|
|
14343
|
+
if (!this.isWaitingForResponse) return;
|
|
14344
|
+
const detectedStatusBeforeEval = this.runDetectStatus(this.recentOutputBuffer);
|
|
14345
|
+
this.recordTrace("response_timeout_check", {
|
|
14346
|
+
timeoutMs,
|
|
14347
|
+
detectedStatus: detectedStatusBeforeEval,
|
|
14348
|
+
currentStatus: this.currentStatus,
|
|
14349
|
+
isWaitingForResponse: this.isWaitingForResponse,
|
|
14350
|
+
hasActionableApproval: this.hasActionableApproval(),
|
|
14351
|
+
...buildCliTraceParseSnapshot({
|
|
14352
|
+
accumulatedBuffer: this.accumulatedBuffer,
|
|
14353
|
+
accumulatedRawBuffer: this.accumulatedRawBuffer,
|
|
14354
|
+
responseBuffer: this.responseBuffer,
|
|
14355
|
+
partialResponse: this.responseBuffer,
|
|
14356
|
+
scope: this.currentTurnScope
|
|
14357
|
+
})
|
|
14358
|
+
});
|
|
14359
|
+
this.settledBuffer = this.recentOutputBuffer;
|
|
14360
|
+
this.evaluateSettled();
|
|
14361
|
+
if (this.isWaitingForResponse && !this.hasActionableApproval()) {
|
|
14362
|
+
const detectedStatusAfterEval = this.runDetectStatus(this.recentOutputBuffer);
|
|
14363
|
+
this.recordTrace("response_timeout_kept_open", {
|
|
14364
|
+
timeoutMs,
|
|
14365
|
+
detectedStatusBeforeEval,
|
|
14366
|
+
detectedStatusAfterEval,
|
|
14367
|
+
currentStatus: this.currentStatus,
|
|
14368
|
+
isWaitingForResponse: this.isWaitingForResponse
|
|
14369
|
+
});
|
|
14370
|
+
this.armResponseTimeout();
|
|
14371
|
+
}
|
|
14372
|
+
}, timeoutMs);
|
|
14297
14373
|
}
|
|
14298
14374
|
writeSubmitKeyForRetry(mode) {
|
|
14299
14375
|
void this.writeToPty(this.sendKey).catch((error48) => {
|
|
@@ -14979,6 +15055,11 @@ var init_cli_provider_instance = __esm({
|
|
|
14979
15055
|
launchMode;
|
|
14980
15056
|
startedAt = Date.now();
|
|
14981
15057
|
onProviderSessionResolved;
|
|
15058
|
+
refreshProviderDefinition(provider) {
|
|
15059
|
+
if (provider.type !== this.type || provider.category !== "cli") return;
|
|
15060
|
+
this.provider = provider;
|
|
15061
|
+
this.adapter.refreshProviderDefinition(provider);
|
|
15062
|
+
}
|
|
14982
15063
|
// ─── Lifecycle ─────────────────────────────────
|
|
14983
15064
|
async init(context) {
|
|
14984
15065
|
this.context = context;
|
|
@@ -15184,6 +15265,22 @@ var init_cli_provider_instance = __esm({
|
|
|
15184
15265
|
getPresentationMode() {
|
|
15185
15266
|
return this.presentationMode;
|
|
15186
15267
|
}
|
|
15268
|
+
getHotChatSessionState() {
|
|
15269
|
+
const adapterStatus = this.adapter.getStatus();
|
|
15270
|
+
const autoApproveActive = adapterStatus.status === "waiting_approval" && this.shouldAutoApprove();
|
|
15271
|
+
const visibleStatus = autoApproveActive ? "generating" : adapterStatus.status;
|
|
15272
|
+
const runtime = this.adapter.getRuntimeMetadata();
|
|
15273
|
+
const lastCommittedMessageActivityAt = typeof this.adapter.getLastCommittedMessageActivityAt === "function" ? this.adapter.getLastCommittedMessageActivityAt() : 0;
|
|
15274
|
+
return {
|
|
15275
|
+
id: this.instanceId,
|
|
15276
|
+
status: visibleStatus,
|
|
15277
|
+
lastMessageAt: lastCommittedMessageActivityAt || void 0,
|
|
15278
|
+
runtimeLifecycle: runtime?.lifecycle ?? null,
|
|
15279
|
+
runtimeSurfaceKind: runtime?.surfaceKind,
|
|
15280
|
+
runtimeRestoredFromStorage: runtime?.restoredFromStorage === true,
|
|
15281
|
+
runtimeRecoveryState: runtime?.recoveryState ?? null
|
|
15282
|
+
};
|
|
15283
|
+
}
|
|
15187
15284
|
updateSettings(newSettings) {
|
|
15188
15285
|
this.settings = { ...newSettings };
|
|
15189
15286
|
this.adapter.updateRuntimeSettings?.(this.settings);
|
|
@@ -15339,6 +15436,15 @@ var init_cli_provider_instance = __esm({
|
|
|
15339
15436
|
this.completedDebouncePending = { chatTitle, duration: duration3, timestamp: now };
|
|
15340
15437
|
this.completedDebounceTimer = setTimeout(() => {
|
|
15341
15438
|
if (this.completedDebouncePending) {
|
|
15439
|
+
const latestStatus = this.adapter.getStatus();
|
|
15440
|
+
const latestAutoApproveActive = latestStatus.status === "waiting_approval" && this.shouldAutoApprove();
|
|
15441
|
+
const latestVisibleStatus = latestAutoApproveActive ? "generating" : latestStatus.status;
|
|
15442
|
+
if (latestVisibleStatus !== "idle") {
|
|
15443
|
+
LOG.info("CLI", `[${this.type}] cancelled pending completed (resumed ${latestVisibleStatus})`);
|
|
15444
|
+
this.completedDebouncePending = null;
|
|
15445
|
+
this.completedDebounceTimer = null;
|
|
15446
|
+
return;
|
|
15447
|
+
}
|
|
15342
15448
|
LOG.info("CLI", `[${this.type}] completed in ${this.completedDebouncePending.duration}s`);
|
|
15343
15449
|
this.pushEvent({ event: "agent:generating_completed", ...this.completedDebouncePending });
|
|
15344
15450
|
this.completedDebouncePending = null;
|
|
@@ -16001,10 +16107,10 @@ function mergeDefs(...defs) {
|
|
|
16001
16107
|
function cloneDef(schema) {
|
|
16002
16108
|
return mergeDefs(schema._zod.def);
|
|
16003
16109
|
}
|
|
16004
|
-
function getElementAtPath(obj,
|
|
16005
|
-
if (!
|
|
16110
|
+
function getElementAtPath(obj, path36) {
|
|
16111
|
+
if (!path36)
|
|
16006
16112
|
return obj;
|
|
16007
|
-
return
|
|
16113
|
+
return path36.reduce((acc, key) => acc?.[key], obj);
|
|
16008
16114
|
}
|
|
16009
16115
|
function promiseAllObject(promisesObj) {
|
|
16010
16116
|
const keys = Object.keys(promisesObj);
|
|
@@ -16316,11 +16422,11 @@ function aborted(x, startIndex = 0) {
|
|
|
16316
16422
|
}
|
|
16317
16423
|
return false;
|
|
16318
16424
|
}
|
|
16319
|
-
function prefixIssues(
|
|
16425
|
+
function prefixIssues(path36, issues) {
|
|
16320
16426
|
return issues.map((iss) => {
|
|
16321
16427
|
var _a2;
|
|
16322
16428
|
(_a2 = iss).path ?? (_a2.path = []);
|
|
16323
|
-
iss.path.unshift(
|
|
16429
|
+
iss.path.unshift(path36);
|
|
16324
16430
|
return iss;
|
|
16325
16431
|
});
|
|
16326
16432
|
}
|
|
@@ -16563,7 +16669,7 @@ function formatError(error48, mapper = (issue2) => issue2.message) {
|
|
|
16563
16669
|
}
|
|
16564
16670
|
function treeifyError(error48, mapper = (issue2) => issue2.message) {
|
|
16565
16671
|
const result = { errors: [] };
|
|
16566
|
-
const processError = (error49,
|
|
16672
|
+
const processError = (error49, path36 = []) => {
|
|
16567
16673
|
var _a2, _b;
|
|
16568
16674
|
for (const issue2 of error49.issues) {
|
|
16569
16675
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
@@ -16573,7 +16679,7 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
|
|
|
16573
16679
|
} else if (issue2.code === "invalid_element") {
|
|
16574
16680
|
processError({ issues: issue2.issues }, issue2.path);
|
|
16575
16681
|
} else {
|
|
16576
|
-
const fullpath = [...
|
|
16682
|
+
const fullpath = [...path36, ...issue2.path];
|
|
16577
16683
|
if (fullpath.length === 0) {
|
|
16578
16684
|
result.errors.push(mapper(issue2));
|
|
16579
16685
|
continue;
|
|
@@ -16605,8 +16711,8 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
|
|
|
16605
16711
|
}
|
|
16606
16712
|
function toDotPath(_path) {
|
|
16607
16713
|
const segs = [];
|
|
16608
|
-
const
|
|
16609
|
-
for (const seg of
|
|
16714
|
+
const path36 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
16715
|
+
for (const seg of path36) {
|
|
16610
16716
|
if (typeof seg === "number")
|
|
16611
16717
|
segs.push(`[${seg}]`);
|
|
16612
16718
|
else if (typeof seg === "symbol")
|
|
@@ -29370,13 +29476,13 @@ function resolveRef(ref, ctx) {
|
|
|
29370
29476
|
if (!ref.startsWith("#")) {
|
|
29371
29477
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
29372
29478
|
}
|
|
29373
|
-
const
|
|
29374
|
-
if (
|
|
29479
|
+
const path36 = ref.slice(1).split("/").filter(Boolean);
|
|
29480
|
+
if (path36.length === 0) {
|
|
29375
29481
|
return ctx.rootSchema;
|
|
29376
29482
|
}
|
|
29377
29483
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
29378
|
-
if (
|
|
29379
|
-
const key =
|
|
29484
|
+
if (path36[0] === defsKey) {
|
|
29485
|
+
const key = path36[1];
|
|
29380
29486
|
if (!key || !ctx.defs[key]) {
|
|
29381
29487
|
throw new Error(`Reference not found: ${ref}`);
|
|
29382
29488
|
}
|
|
@@ -34118,7 +34224,7 @@ var init_readdirp = __esm({
|
|
|
34118
34224
|
this._directoryFilter = normalizeFilter(opts.directoryFilter);
|
|
34119
34225
|
const statMethod = opts.lstat ? import_promises.lstat : import_promises.stat;
|
|
34120
34226
|
if (wantBigintFsStats) {
|
|
34121
|
-
this._stat = (
|
|
34227
|
+
this._stat = (path36) => statMethod(path36, { bigint: true });
|
|
34122
34228
|
} else {
|
|
34123
34229
|
this._stat = statMethod;
|
|
34124
34230
|
}
|
|
@@ -34143,8 +34249,8 @@ var init_readdirp = __esm({
|
|
|
34143
34249
|
const par = this.parent;
|
|
34144
34250
|
const fil = par && par.files;
|
|
34145
34251
|
if (fil && fil.length > 0) {
|
|
34146
|
-
const { path:
|
|
34147
|
-
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent,
|
|
34252
|
+
const { path: path36, depth } = par;
|
|
34253
|
+
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path36));
|
|
34148
34254
|
const awaited = await Promise.all(slice);
|
|
34149
34255
|
for (const entry of awaited) {
|
|
34150
34256
|
if (!entry)
|
|
@@ -34184,20 +34290,20 @@ var init_readdirp = __esm({
|
|
|
34184
34290
|
this.reading = false;
|
|
34185
34291
|
}
|
|
34186
34292
|
}
|
|
34187
|
-
async _exploreDir(
|
|
34293
|
+
async _exploreDir(path36, depth) {
|
|
34188
34294
|
let files;
|
|
34189
34295
|
try {
|
|
34190
|
-
files = await (0, import_promises.readdir)(
|
|
34296
|
+
files = await (0, import_promises.readdir)(path36, this._rdOptions);
|
|
34191
34297
|
} catch (error48) {
|
|
34192
34298
|
this._onError(error48);
|
|
34193
34299
|
}
|
|
34194
|
-
return { files, depth, path:
|
|
34300
|
+
return { files, depth, path: path36 };
|
|
34195
34301
|
}
|
|
34196
|
-
async _formatEntry(dirent,
|
|
34302
|
+
async _formatEntry(dirent, path36) {
|
|
34197
34303
|
let entry;
|
|
34198
34304
|
const basename10 = this._isDirent ? dirent.name : dirent;
|
|
34199
34305
|
try {
|
|
34200
|
-
const fullPath = (0, import_node_path.resolve)((0, import_node_path.join)(
|
|
34306
|
+
const fullPath = (0, import_node_path.resolve)((0, import_node_path.join)(path36, basename10));
|
|
34201
34307
|
entry = { path: (0, import_node_path.relative)(this._root, fullPath), fullPath, basename: basename10 };
|
|
34202
34308
|
entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
|
|
34203
34309
|
} catch (err) {
|
|
@@ -34254,16 +34360,16 @@ var init_readdirp = __esm({
|
|
|
34254
34360
|
});
|
|
34255
34361
|
|
|
34256
34362
|
// ../../oss/packages/daemon-core/node_modules/chokidar/handler.js
|
|
34257
|
-
function createFsWatchInstance(
|
|
34363
|
+
function createFsWatchInstance(path36, options, listener, errHandler, emitRaw) {
|
|
34258
34364
|
const handleEvent = (rawEvent, evPath) => {
|
|
34259
|
-
listener(
|
|
34260
|
-
emitRaw(rawEvent, evPath, { watchedPath:
|
|
34261
|
-
if (evPath &&
|
|
34262
|
-
fsWatchBroadcast(sp.resolve(
|
|
34365
|
+
listener(path36);
|
|
34366
|
+
emitRaw(rawEvent, evPath, { watchedPath: path36 });
|
|
34367
|
+
if (evPath && path36 !== evPath) {
|
|
34368
|
+
fsWatchBroadcast(sp.resolve(path36, evPath), KEY_LISTENERS, sp.join(path36, evPath));
|
|
34263
34369
|
}
|
|
34264
34370
|
};
|
|
34265
34371
|
try {
|
|
34266
|
-
return (0, import_node_fs.watch)(
|
|
34372
|
+
return (0, import_node_fs.watch)(path36, {
|
|
34267
34373
|
persistent: options.persistent
|
|
34268
34374
|
}, handleEvent);
|
|
34269
34375
|
} catch (error48) {
|
|
@@ -34612,12 +34718,12 @@ var init_handler2 = __esm({
|
|
|
34612
34718
|
listener(val1, val2, val3);
|
|
34613
34719
|
});
|
|
34614
34720
|
};
|
|
34615
|
-
setFsWatchListener = (
|
|
34721
|
+
setFsWatchListener = (path36, fullPath, options, handlers) => {
|
|
34616
34722
|
const { listener, errHandler, rawEmitter } = handlers;
|
|
34617
34723
|
let cont = FsWatchInstances.get(fullPath);
|
|
34618
34724
|
let watcher;
|
|
34619
34725
|
if (!options.persistent) {
|
|
34620
|
-
watcher = createFsWatchInstance(
|
|
34726
|
+
watcher = createFsWatchInstance(path36, options, listener, errHandler, rawEmitter);
|
|
34621
34727
|
if (!watcher)
|
|
34622
34728
|
return;
|
|
34623
34729
|
return watcher.close.bind(watcher);
|
|
@@ -34628,7 +34734,7 @@ var init_handler2 = __esm({
|
|
|
34628
34734
|
addAndConvert(cont, KEY_RAW, rawEmitter);
|
|
34629
34735
|
} else {
|
|
34630
34736
|
watcher = createFsWatchInstance(
|
|
34631
|
-
|
|
34737
|
+
path36,
|
|
34632
34738
|
options,
|
|
34633
34739
|
fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS),
|
|
34634
34740
|
errHandler,
|
|
@@ -34643,7 +34749,7 @@ var init_handler2 = __esm({
|
|
|
34643
34749
|
cont.watcherUnusable = true;
|
|
34644
34750
|
if (isWindows && error48.code === "EPERM") {
|
|
34645
34751
|
try {
|
|
34646
|
-
const fd = await (0, import_promises2.open)(
|
|
34752
|
+
const fd = await (0, import_promises2.open)(path36, "r");
|
|
34647
34753
|
await fd.close();
|
|
34648
34754
|
broadcastErr(error48);
|
|
34649
34755
|
} catch (err) {
|
|
@@ -34674,7 +34780,7 @@ var init_handler2 = __esm({
|
|
|
34674
34780
|
};
|
|
34675
34781
|
};
|
|
34676
34782
|
FsWatchFileInstances = /* @__PURE__ */ new Map();
|
|
34677
|
-
setFsWatchFileListener = (
|
|
34783
|
+
setFsWatchFileListener = (path36, fullPath, options, handlers) => {
|
|
34678
34784
|
const { listener, rawEmitter } = handlers;
|
|
34679
34785
|
let cont = FsWatchFileInstances.get(fullPath);
|
|
34680
34786
|
const copts = cont && cont.options;
|
|
@@ -34696,7 +34802,7 @@ var init_handler2 = __esm({
|
|
|
34696
34802
|
});
|
|
34697
34803
|
const currmtime = curr.mtimeMs;
|
|
34698
34804
|
if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) {
|
|
34699
|
-
foreach(cont.listeners, (listener2) => listener2(
|
|
34805
|
+
foreach(cont.listeners, (listener2) => listener2(path36, curr));
|
|
34700
34806
|
}
|
|
34701
34807
|
})
|
|
34702
34808
|
};
|
|
@@ -34726,13 +34832,13 @@ var init_handler2 = __esm({
|
|
|
34726
34832
|
* @param listener on fs change
|
|
34727
34833
|
* @returns closer for the watcher instance
|
|
34728
34834
|
*/
|
|
34729
|
-
_watchWithNodeFs(
|
|
34835
|
+
_watchWithNodeFs(path36, listener) {
|
|
34730
34836
|
const opts = this.fsw.options;
|
|
34731
|
-
const directory = sp.dirname(
|
|
34732
|
-
const basename10 = sp.basename(
|
|
34837
|
+
const directory = sp.dirname(path36);
|
|
34838
|
+
const basename10 = sp.basename(path36);
|
|
34733
34839
|
const parent = this.fsw._getWatchedDir(directory);
|
|
34734
34840
|
parent.add(basename10);
|
|
34735
|
-
const absolutePath = sp.resolve(
|
|
34841
|
+
const absolutePath = sp.resolve(path36);
|
|
34736
34842
|
const options = {
|
|
34737
34843
|
persistent: opts.persistent
|
|
34738
34844
|
};
|
|
@@ -34742,12 +34848,12 @@ var init_handler2 = __esm({
|
|
|
34742
34848
|
if (opts.usePolling) {
|
|
34743
34849
|
const enableBin = opts.interval !== opts.binaryInterval;
|
|
34744
34850
|
options.interval = enableBin && isBinaryPath(basename10) ? opts.binaryInterval : opts.interval;
|
|
34745
|
-
closer = setFsWatchFileListener(
|
|
34851
|
+
closer = setFsWatchFileListener(path36, absolutePath, options, {
|
|
34746
34852
|
listener,
|
|
34747
34853
|
rawEmitter: this.fsw._emitRaw
|
|
34748
34854
|
});
|
|
34749
34855
|
} else {
|
|
34750
|
-
closer = setFsWatchListener(
|
|
34856
|
+
closer = setFsWatchListener(path36, absolutePath, options, {
|
|
34751
34857
|
listener,
|
|
34752
34858
|
errHandler: this._boundHandleError,
|
|
34753
34859
|
rawEmitter: this.fsw._emitRaw
|
|
@@ -34769,7 +34875,7 @@ var init_handler2 = __esm({
|
|
|
34769
34875
|
let prevStats = stats;
|
|
34770
34876
|
if (parent.has(basename10))
|
|
34771
34877
|
return;
|
|
34772
|
-
const listener = async (
|
|
34878
|
+
const listener = async (path36, newStats) => {
|
|
34773
34879
|
if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file2, 5))
|
|
34774
34880
|
return;
|
|
34775
34881
|
if (!newStats || newStats.mtimeMs === 0) {
|
|
@@ -34783,11 +34889,11 @@ var init_handler2 = __esm({
|
|
|
34783
34889
|
this.fsw._emit(EV.CHANGE, file2, newStats2);
|
|
34784
34890
|
}
|
|
34785
34891
|
if ((isMacos || isLinux || isFreeBSD) && prevStats.ino !== newStats2.ino) {
|
|
34786
|
-
this.fsw._closeFile(
|
|
34892
|
+
this.fsw._closeFile(path36);
|
|
34787
34893
|
prevStats = newStats2;
|
|
34788
34894
|
const closer2 = this._watchWithNodeFs(file2, listener);
|
|
34789
34895
|
if (closer2)
|
|
34790
|
-
this.fsw._addPathCloser(
|
|
34896
|
+
this.fsw._addPathCloser(path36, closer2);
|
|
34791
34897
|
} else {
|
|
34792
34898
|
prevStats = newStats2;
|
|
34793
34899
|
}
|
|
@@ -34819,7 +34925,7 @@ var init_handler2 = __esm({
|
|
|
34819
34925
|
* @param item basename of this item
|
|
34820
34926
|
* @returns true if no more processing is needed for this entry.
|
|
34821
34927
|
*/
|
|
34822
|
-
async _handleSymlink(entry, directory,
|
|
34928
|
+
async _handleSymlink(entry, directory, path36, item) {
|
|
34823
34929
|
if (this.fsw.closed) {
|
|
34824
34930
|
return;
|
|
34825
34931
|
}
|
|
@@ -34829,7 +34935,7 @@ var init_handler2 = __esm({
|
|
|
34829
34935
|
this.fsw._incrReadyCount();
|
|
34830
34936
|
let linkPath;
|
|
34831
34937
|
try {
|
|
34832
|
-
linkPath = await (0, import_promises2.realpath)(
|
|
34938
|
+
linkPath = await (0, import_promises2.realpath)(path36);
|
|
34833
34939
|
} catch (e) {
|
|
34834
34940
|
this.fsw._emitReady();
|
|
34835
34941
|
return true;
|
|
@@ -34839,12 +34945,12 @@ var init_handler2 = __esm({
|
|
|
34839
34945
|
if (dir.has(item)) {
|
|
34840
34946
|
if (this.fsw._symlinkPaths.get(full) !== linkPath) {
|
|
34841
34947
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
34842
|
-
this.fsw._emit(EV.CHANGE,
|
|
34948
|
+
this.fsw._emit(EV.CHANGE, path36, entry.stats);
|
|
34843
34949
|
}
|
|
34844
34950
|
} else {
|
|
34845
34951
|
dir.add(item);
|
|
34846
34952
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
34847
|
-
this.fsw._emit(EV.ADD,
|
|
34953
|
+
this.fsw._emit(EV.ADD, path36, entry.stats);
|
|
34848
34954
|
}
|
|
34849
34955
|
this.fsw._emitReady();
|
|
34850
34956
|
return true;
|
|
@@ -34874,9 +34980,9 @@ var init_handler2 = __esm({
|
|
|
34874
34980
|
return;
|
|
34875
34981
|
}
|
|
34876
34982
|
const item = entry.path;
|
|
34877
|
-
let
|
|
34983
|
+
let path36 = sp.join(directory, item);
|
|
34878
34984
|
current.add(item);
|
|
34879
|
-
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory,
|
|
34985
|
+
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path36, item)) {
|
|
34880
34986
|
return;
|
|
34881
34987
|
}
|
|
34882
34988
|
if (this.fsw.closed) {
|
|
@@ -34885,8 +34991,8 @@ var init_handler2 = __esm({
|
|
|
34885
34991
|
}
|
|
34886
34992
|
if (item === target || !target && !previous.has(item)) {
|
|
34887
34993
|
this.fsw._incrReadyCount();
|
|
34888
|
-
|
|
34889
|
-
this._addToNodeFs(
|
|
34994
|
+
path36 = sp.join(dir, sp.relative(dir, path36));
|
|
34995
|
+
this._addToNodeFs(path36, initialAdd, wh, depth + 1);
|
|
34890
34996
|
}
|
|
34891
34997
|
}).on(EV.ERROR, this._boundHandleError);
|
|
34892
34998
|
return new Promise((resolve18, reject) => {
|
|
@@ -34955,13 +35061,13 @@ var init_handler2 = __esm({
|
|
|
34955
35061
|
* @param depth Child path actually targeted for watch
|
|
34956
35062
|
* @param target Child path actually targeted for watch
|
|
34957
35063
|
*/
|
|
34958
|
-
async _addToNodeFs(
|
|
35064
|
+
async _addToNodeFs(path36, initialAdd, priorWh, depth, target) {
|
|
34959
35065
|
const ready = this.fsw._emitReady;
|
|
34960
|
-
if (this.fsw._isIgnored(
|
|
35066
|
+
if (this.fsw._isIgnored(path36) || this.fsw.closed) {
|
|
34961
35067
|
ready();
|
|
34962
35068
|
return false;
|
|
34963
35069
|
}
|
|
34964
|
-
const wh = this.fsw._getWatchHelpers(
|
|
35070
|
+
const wh = this.fsw._getWatchHelpers(path36);
|
|
34965
35071
|
if (priorWh) {
|
|
34966
35072
|
wh.filterPath = (entry) => priorWh.filterPath(entry);
|
|
34967
35073
|
wh.filterDir = (entry) => priorWh.filterDir(entry);
|
|
@@ -34977,8 +35083,8 @@ var init_handler2 = __esm({
|
|
|
34977
35083
|
const follow = this.fsw.options.followSymlinks;
|
|
34978
35084
|
let closer;
|
|
34979
35085
|
if (stats.isDirectory()) {
|
|
34980
|
-
const absPath = sp.resolve(
|
|
34981
|
-
const targetPath = follow ? await (0, import_promises2.realpath)(
|
|
35086
|
+
const absPath = sp.resolve(path36);
|
|
35087
|
+
const targetPath = follow ? await (0, import_promises2.realpath)(path36) : path36;
|
|
34982
35088
|
if (this.fsw.closed)
|
|
34983
35089
|
return;
|
|
34984
35090
|
closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
|
|
@@ -34988,29 +35094,29 @@ var init_handler2 = __esm({
|
|
|
34988
35094
|
this.fsw._symlinkPaths.set(absPath, targetPath);
|
|
34989
35095
|
}
|
|
34990
35096
|
} else if (stats.isSymbolicLink()) {
|
|
34991
|
-
const targetPath = follow ? await (0, import_promises2.realpath)(
|
|
35097
|
+
const targetPath = follow ? await (0, import_promises2.realpath)(path36) : path36;
|
|
34992
35098
|
if (this.fsw.closed)
|
|
34993
35099
|
return;
|
|
34994
35100
|
const parent = sp.dirname(wh.watchPath);
|
|
34995
35101
|
this.fsw._getWatchedDir(parent).add(wh.watchPath);
|
|
34996
35102
|
this.fsw._emit(EV.ADD, wh.watchPath, stats);
|
|
34997
|
-
closer = await this._handleDir(parent, stats, initialAdd, depth,
|
|
35103
|
+
closer = await this._handleDir(parent, stats, initialAdd, depth, path36, wh, targetPath);
|
|
34998
35104
|
if (this.fsw.closed)
|
|
34999
35105
|
return;
|
|
35000
35106
|
if (targetPath !== void 0) {
|
|
35001
|
-
this.fsw._symlinkPaths.set(sp.resolve(
|
|
35107
|
+
this.fsw._symlinkPaths.set(sp.resolve(path36), targetPath);
|
|
35002
35108
|
}
|
|
35003
35109
|
} else {
|
|
35004
35110
|
closer = this._handleFile(wh.watchPath, stats, initialAdd);
|
|
35005
35111
|
}
|
|
35006
35112
|
ready();
|
|
35007
35113
|
if (closer)
|
|
35008
|
-
this.fsw._addPathCloser(
|
|
35114
|
+
this.fsw._addPathCloser(path36, closer);
|
|
35009
35115
|
return false;
|
|
35010
35116
|
} catch (error48) {
|
|
35011
35117
|
if (this.fsw._handleError(error48)) {
|
|
35012
35118
|
ready();
|
|
35013
|
-
return
|
|
35119
|
+
return path36;
|
|
35014
35120
|
}
|
|
35015
35121
|
}
|
|
35016
35122
|
}
|
|
@@ -35045,24 +35151,24 @@ function createPattern(matcher) {
|
|
|
35045
35151
|
}
|
|
35046
35152
|
return () => false;
|
|
35047
35153
|
}
|
|
35048
|
-
function normalizePath(
|
|
35049
|
-
if (typeof
|
|
35154
|
+
function normalizePath(path36) {
|
|
35155
|
+
if (typeof path36 !== "string")
|
|
35050
35156
|
throw new Error("string expected");
|
|
35051
|
-
|
|
35052
|
-
|
|
35157
|
+
path36 = sp2.normalize(path36);
|
|
35158
|
+
path36 = path36.replace(/\\/g, "/");
|
|
35053
35159
|
let prepend = false;
|
|
35054
|
-
if (
|
|
35160
|
+
if (path36.startsWith("//"))
|
|
35055
35161
|
prepend = true;
|
|
35056
|
-
|
|
35162
|
+
path36 = path36.replace(DOUBLE_SLASH_RE, "/");
|
|
35057
35163
|
if (prepend)
|
|
35058
|
-
|
|
35059
|
-
return
|
|
35164
|
+
path36 = "/" + path36;
|
|
35165
|
+
return path36;
|
|
35060
35166
|
}
|
|
35061
35167
|
function matchPatterns(patterns, testString, stats) {
|
|
35062
|
-
const
|
|
35168
|
+
const path36 = normalizePath(testString);
|
|
35063
35169
|
for (let index = 0; index < patterns.length; index++) {
|
|
35064
35170
|
const pattern = patterns[index];
|
|
35065
|
-
if (pattern(
|
|
35171
|
+
if (pattern(path36, stats)) {
|
|
35066
35172
|
return true;
|
|
35067
35173
|
}
|
|
35068
35174
|
}
|
|
@@ -35125,19 +35231,19 @@ var init_chokidar = __esm({
|
|
|
35125
35231
|
}
|
|
35126
35232
|
return str;
|
|
35127
35233
|
};
|
|
35128
|
-
normalizePathToUnix = (
|
|
35129
|
-
normalizeIgnored = (cwd = "") => (
|
|
35130
|
-
if (typeof
|
|
35131
|
-
return normalizePathToUnix(sp2.isAbsolute(
|
|
35234
|
+
normalizePathToUnix = (path36) => toUnix(sp2.normalize(toUnix(path36)));
|
|
35235
|
+
normalizeIgnored = (cwd = "") => (path36) => {
|
|
35236
|
+
if (typeof path36 === "string") {
|
|
35237
|
+
return normalizePathToUnix(sp2.isAbsolute(path36) ? path36 : sp2.join(cwd, path36));
|
|
35132
35238
|
} else {
|
|
35133
|
-
return
|
|
35239
|
+
return path36;
|
|
35134
35240
|
}
|
|
35135
35241
|
};
|
|
35136
|
-
getAbsolutePath = (
|
|
35137
|
-
if (sp2.isAbsolute(
|
|
35138
|
-
return
|
|
35242
|
+
getAbsolutePath = (path36, cwd) => {
|
|
35243
|
+
if (sp2.isAbsolute(path36)) {
|
|
35244
|
+
return path36;
|
|
35139
35245
|
}
|
|
35140
|
-
return sp2.join(cwd,
|
|
35246
|
+
return sp2.join(cwd, path36);
|
|
35141
35247
|
};
|
|
35142
35248
|
EMPTY_SET = Object.freeze(/* @__PURE__ */ new Set());
|
|
35143
35249
|
DirEntry = class {
|
|
@@ -35202,10 +35308,10 @@ var init_chokidar = __esm({
|
|
|
35202
35308
|
dirParts;
|
|
35203
35309
|
followSymlinks;
|
|
35204
35310
|
statMethod;
|
|
35205
|
-
constructor(
|
|
35311
|
+
constructor(path36, follow, fsw) {
|
|
35206
35312
|
this.fsw = fsw;
|
|
35207
|
-
const watchPath =
|
|
35208
|
-
this.path =
|
|
35313
|
+
const watchPath = path36;
|
|
35314
|
+
this.path = path36 = path36.replace(REPLACER_RE, "");
|
|
35209
35315
|
this.watchPath = watchPath;
|
|
35210
35316
|
this.fullWatchPath = sp2.resolve(watchPath);
|
|
35211
35317
|
this.dirParts = [];
|
|
@@ -35345,20 +35451,20 @@ var init_chokidar = __esm({
|
|
|
35345
35451
|
this._closePromise = void 0;
|
|
35346
35452
|
let paths = unifyPaths(paths_);
|
|
35347
35453
|
if (cwd) {
|
|
35348
|
-
paths = paths.map((
|
|
35349
|
-
const absPath = getAbsolutePath(
|
|
35454
|
+
paths = paths.map((path36) => {
|
|
35455
|
+
const absPath = getAbsolutePath(path36, cwd);
|
|
35350
35456
|
return absPath;
|
|
35351
35457
|
});
|
|
35352
35458
|
}
|
|
35353
|
-
paths.forEach((
|
|
35354
|
-
this._removeIgnoredPath(
|
|
35459
|
+
paths.forEach((path36) => {
|
|
35460
|
+
this._removeIgnoredPath(path36);
|
|
35355
35461
|
});
|
|
35356
35462
|
this._userIgnored = void 0;
|
|
35357
35463
|
if (!this._readyCount)
|
|
35358
35464
|
this._readyCount = 0;
|
|
35359
35465
|
this._readyCount += paths.length;
|
|
35360
|
-
Promise.all(paths.map(async (
|
|
35361
|
-
const res = await this._nodeFsHandler._addToNodeFs(
|
|
35466
|
+
Promise.all(paths.map(async (path36) => {
|
|
35467
|
+
const res = await this._nodeFsHandler._addToNodeFs(path36, !_internal, void 0, 0, _origAdd);
|
|
35362
35468
|
if (res)
|
|
35363
35469
|
this._emitReady();
|
|
35364
35470
|
return res;
|
|
@@ -35380,17 +35486,17 @@ var init_chokidar = __esm({
|
|
|
35380
35486
|
return this;
|
|
35381
35487
|
const paths = unifyPaths(paths_);
|
|
35382
35488
|
const { cwd } = this.options;
|
|
35383
|
-
paths.forEach((
|
|
35384
|
-
if (!sp2.isAbsolute(
|
|
35489
|
+
paths.forEach((path36) => {
|
|
35490
|
+
if (!sp2.isAbsolute(path36) && !this._closers.has(path36)) {
|
|
35385
35491
|
if (cwd)
|
|
35386
|
-
|
|
35387
|
-
|
|
35492
|
+
path36 = sp2.join(cwd, path36);
|
|
35493
|
+
path36 = sp2.resolve(path36);
|
|
35388
35494
|
}
|
|
35389
|
-
this._closePath(
|
|
35390
|
-
this._addIgnoredPath(
|
|
35391
|
-
if (this._watched.has(
|
|
35495
|
+
this._closePath(path36);
|
|
35496
|
+
this._addIgnoredPath(path36);
|
|
35497
|
+
if (this._watched.has(path36)) {
|
|
35392
35498
|
this._addIgnoredPath({
|
|
35393
|
-
path:
|
|
35499
|
+
path: path36,
|
|
35394
35500
|
recursive: true
|
|
35395
35501
|
});
|
|
35396
35502
|
}
|
|
@@ -35454,38 +35560,38 @@ var init_chokidar = __esm({
|
|
|
35454
35560
|
* @param stats arguments to be passed with event
|
|
35455
35561
|
* @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag
|
|
35456
35562
|
*/
|
|
35457
|
-
async _emit(event,
|
|
35563
|
+
async _emit(event, path36, stats) {
|
|
35458
35564
|
if (this.closed)
|
|
35459
35565
|
return;
|
|
35460
35566
|
const opts = this.options;
|
|
35461
35567
|
if (isWindows)
|
|
35462
|
-
|
|
35568
|
+
path36 = sp2.normalize(path36);
|
|
35463
35569
|
if (opts.cwd)
|
|
35464
|
-
|
|
35465
|
-
const args = [
|
|
35570
|
+
path36 = sp2.relative(opts.cwd, path36);
|
|
35571
|
+
const args = [path36];
|
|
35466
35572
|
if (stats != null)
|
|
35467
35573
|
args.push(stats);
|
|
35468
35574
|
const awf = opts.awaitWriteFinish;
|
|
35469
35575
|
let pw;
|
|
35470
|
-
if (awf && (pw = this._pendingWrites.get(
|
|
35576
|
+
if (awf && (pw = this._pendingWrites.get(path36))) {
|
|
35471
35577
|
pw.lastChange = /* @__PURE__ */ new Date();
|
|
35472
35578
|
return this;
|
|
35473
35579
|
}
|
|
35474
35580
|
if (opts.atomic) {
|
|
35475
35581
|
if (event === EVENTS.UNLINK) {
|
|
35476
|
-
this._pendingUnlinks.set(
|
|
35582
|
+
this._pendingUnlinks.set(path36, [event, ...args]);
|
|
35477
35583
|
setTimeout(() => {
|
|
35478
|
-
this._pendingUnlinks.forEach((entry,
|
|
35584
|
+
this._pendingUnlinks.forEach((entry, path37) => {
|
|
35479
35585
|
this.emit(...entry);
|
|
35480
35586
|
this.emit(EVENTS.ALL, ...entry);
|
|
35481
|
-
this._pendingUnlinks.delete(
|
|
35587
|
+
this._pendingUnlinks.delete(path37);
|
|
35482
35588
|
});
|
|
35483
35589
|
}, typeof opts.atomic === "number" ? opts.atomic : 100);
|
|
35484
35590
|
return this;
|
|
35485
35591
|
}
|
|
35486
|
-
if (event === EVENTS.ADD && this._pendingUnlinks.has(
|
|
35592
|
+
if (event === EVENTS.ADD && this._pendingUnlinks.has(path36)) {
|
|
35487
35593
|
event = EVENTS.CHANGE;
|
|
35488
|
-
this._pendingUnlinks.delete(
|
|
35594
|
+
this._pendingUnlinks.delete(path36);
|
|
35489
35595
|
}
|
|
35490
35596
|
}
|
|
35491
35597
|
if (awf && (event === EVENTS.ADD || event === EVENTS.CHANGE) && this._readyEmitted) {
|
|
@@ -35503,16 +35609,16 @@ var init_chokidar = __esm({
|
|
|
35503
35609
|
this.emitWithAll(event, args);
|
|
35504
35610
|
}
|
|
35505
35611
|
};
|
|
35506
|
-
this._awaitWriteFinish(
|
|
35612
|
+
this._awaitWriteFinish(path36, awf.stabilityThreshold, event, awfEmit);
|
|
35507
35613
|
return this;
|
|
35508
35614
|
}
|
|
35509
35615
|
if (event === EVENTS.CHANGE) {
|
|
35510
|
-
const isThrottled = !this._throttle(EVENTS.CHANGE,
|
|
35616
|
+
const isThrottled = !this._throttle(EVENTS.CHANGE, path36, 50);
|
|
35511
35617
|
if (isThrottled)
|
|
35512
35618
|
return this;
|
|
35513
35619
|
}
|
|
35514
35620
|
if (opts.alwaysStat && stats === void 0 && (event === EVENTS.ADD || event === EVENTS.ADD_DIR || event === EVENTS.CHANGE)) {
|
|
35515
|
-
const fullPath = opts.cwd ? sp2.join(opts.cwd,
|
|
35621
|
+
const fullPath = opts.cwd ? sp2.join(opts.cwd, path36) : path36;
|
|
35516
35622
|
let stats2;
|
|
35517
35623
|
try {
|
|
35518
35624
|
stats2 = await (0, import_promises3.stat)(fullPath);
|
|
@@ -35543,23 +35649,23 @@ var init_chokidar = __esm({
|
|
|
35543
35649
|
* @param timeout duration of time to suppress duplicate actions
|
|
35544
35650
|
* @returns tracking object or false if action should be suppressed
|
|
35545
35651
|
*/
|
|
35546
|
-
_throttle(actionType,
|
|
35652
|
+
_throttle(actionType, path36, timeout) {
|
|
35547
35653
|
if (!this._throttled.has(actionType)) {
|
|
35548
35654
|
this._throttled.set(actionType, /* @__PURE__ */ new Map());
|
|
35549
35655
|
}
|
|
35550
35656
|
const action = this._throttled.get(actionType);
|
|
35551
35657
|
if (!action)
|
|
35552
35658
|
throw new Error("invalid throttle");
|
|
35553
|
-
const actionPath = action.get(
|
|
35659
|
+
const actionPath = action.get(path36);
|
|
35554
35660
|
if (actionPath) {
|
|
35555
35661
|
actionPath.count++;
|
|
35556
35662
|
return false;
|
|
35557
35663
|
}
|
|
35558
35664
|
let timeoutObject;
|
|
35559
35665
|
const clear = () => {
|
|
35560
|
-
const item = action.get(
|
|
35666
|
+
const item = action.get(path36);
|
|
35561
35667
|
const count = item ? item.count : 0;
|
|
35562
|
-
action.delete(
|
|
35668
|
+
action.delete(path36);
|
|
35563
35669
|
clearTimeout(timeoutObject);
|
|
35564
35670
|
if (item)
|
|
35565
35671
|
clearTimeout(item.timeoutObject);
|
|
@@ -35567,7 +35673,7 @@ var init_chokidar = __esm({
|
|
|
35567
35673
|
};
|
|
35568
35674
|
timeoutObject = setTimeout(clear, timeout);
|
|
35569
35675
|
const thr = { timeoutObject, clear, count: 0 };
|
|
35570
|
-
action.set(
|
|
35676
|
+
action.set(path36, thr);
|
|
35571
35677
|
return thr;
|
|
35572
35678
|
}
|
|
35573
35679
|
_incrReadyCount() {
|
|
@@ -35581,44 +35687,44 @@ var init_chokidar = __esm({
|
|
|
35581
35687
|
* @param event
|
|
35582
35688
|
* @param awfEmit Callback to be called when ready for event to be emitted.
|
|
35583
35689
|
*/
|
|
35584
|
-
_awaitWriteFinish(
|
|
35690
|
+
_awaitWriteFinish(path36, threshold, event, awfEmit) {
|
|
35585
35691
|
const awf = this.options.awaitWriteFinish;
|
|
35586
35692
|
if (typeof awf !== "object")
|
|
35587
35693
|
return;
|
|
35588
35694
|
const pollInterval = awf.pollInterval;
|
|
35589
35695
|
let timeoutHandler;
|
|
35590
|
-
let fullPath =
|
|
35591
|
-
if (this.options.cwd && !sp2.isAbsolute(
|
|
35592
|
-
fullPath = sp2.join(this.options.cwd,
|
|
35696
|
+
let fullPath = path36;
|
|
35697
|
+
if (this.options.cwd && !sp2.isAbsolute(path36)) {
|
|
35698
|
+
fullPath = sp2.join(this.options.cwd, path36);
|
|
35593
35699
|
}
|
|
35594
35700
|
const now = /* @__PURE__ */ new Date();
|
|
35595
35701
|
const writes = this._pendingWrites;
|
|
35596
35702
|
function awaitWriteFinishFn(prevStat) {
|
|
35597
35703
|
(0, import_node_fs2.stat)(fullPath, (err, curStat) => {
|
|
35598
|
-
if (err || !writes.has(
|
|
35704
|
+
if (err || !writes.has(path36)) {
|
|
35599
35705
|
if (err && err.code !== "ENOENT")
|
|
35600
35706
|
awfEmit(err);
|
|
35601
35707
|
return;
|
|
35602
35708
|
}
|
|
35603
35709
|
const now2 = Number(/* @__PURE__ */ new Date());
|
|
35604
35710
|
if (prevStat && curStat.size !== prevStat.size) {
|
|
35605
|
-
writes.get(
|
|
35711
|
+
writes.get(path36).lastChange = now2;
|
|
35606
35712
|
}
|
|
35607
|
-
const pw = writes.get(
|
|
35713
|
+
const pw = writes.get(path36);
|
|
35608
35714
|
const df = now2 - pw.lastChange;
|
|
35609
35715
|
if (df >= threshold) {
|
|
35610
|
-
writes.delete(
|
|
35716
|
+
writes.delete(path36);
|
|
35611
35717
|
awfEmit(void 0, curStat);
|
|
35612
35718
|
} else {
|
|
35613
35719
|
timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval, curStat);
|
|
35614
35720
|
}
|
|
35615
35721
|
});
|
|
35616
35722
|
}
|
|
35617
|
-
if (!writes.has(
|
|
35618
|
-
writes.set(
|
|
35723
|
+
if (!writes.has(path36)) {
|
|
35724
|
+
writes.set(path36, {
|
|
35619
35725
|
lastChange: now,
|
|
35620
35726
|
cancelWait: () => {
|
|
35621
|
-
writes.delete(
|
|
35727
|
+
writes.delete(path36);
|
|
35622
35728
|
clearTimeout(timeoutHandler);
|
|
35623
35729
|
return event;
|
|
35624
35730
|
}
|
|
@@ -35629,8 +35735,8 @@ var init_chokidar = __esm({
|
|
|
35629
35735
|
/**
|
|
35630
35736
|
* Determines whether user has asked to ignore this path.
|
|
35631
35737
|
*/
|
|
35632
|
-
_isIgnored(
|
|
35633
|
-
if (this.options.atomic && DOT_RE.test(
|
|
35738
|
+
_isIgnored(path36, stats) {
|
|
35739
|
+
if (this.options.atomic && DOT_RE.test(path36))
|
|
35634
35740
|
return true;
|
|
35635
35741
|
if (!this._userIgnored) {
|
|
35636
35742
|
const { cwd } = this.options;
|
|
@@ -35640,17 +35746,17 @@ var init_chokidar = __esm({
|
|
|
35640
35746
|
const list = [...ignoredPaths.map(normalizeIgnored(cwd)), ...ignored];
|
|
35641
35747
|
this._userIgnored = anymatch(list, void 0);
|
|
35642
35748
|
}
|
|
35643
|
-
return this._userIgnored(
|
|
35749
|
+
return this._userIgnored(path36, stats);
|
|
35644
35750
|
}
|
|
35645
|
-
_isntIgnored(
|
|
35646
|
-
return !this._isIgnored(
|
|
35751
|
+
_isntIgnored(path36, stat4) {
|
|
35752
|
+
return !this._isIgnored(path36, stat4);
|
|
35647
35753
|
}
|
|
35648
35754
|
/**
|
|
35649
35755
|
* Provides a set of common helpers and properties relating to symlink handling.
|
|
35650
35756
|
* @param path file or directory pattern being watched
|
|
35651
35757
|
*/
|
|
35652
|
-
_getWatchHelpers(
|
|
35653
|
-
return new WatchHelper(
|
|
35758
|
+
_getWatchHelpers(path36) {
|
|
35759
|
+
return new WatchHelper(path36, this.options.followSymlinks, this);
|
|
35654
35760
|
}
|
|
35655
35761
|
// Directory helpers
|
|
35656
35762
|
// -----------------
|
|
@@ -35682,63 +35788,63 @@ var init_chokidar = __esm({
|
|
|
35682
35788
|
* @param item base path of item/directory
|
|
35683
35789
|
*/
|
|
35684
35790
|
_remove(directory, item, isDirectory) {
|
|
35685
|
-
const
|
|
35686
|
-
const fullPath = sp2.resolve(
|
|
35687
|
-
isDirectory = isDirectory != null ? isDirectory : this._watched.has(
|
|
35688
|
-
if (!this._throttle("remove",
|
|
35791
|
+
const path36 = sp2.join(directory, item);
|
|
35792
|
+
const fullPath = sp2.resolve(path36);
|
|
35793
|
+
isDirectory = isDirectory != null ? isDirectory : this._watched.has(path36) || this._watched.has(fullPath);
|
|
35794
|
+
if (!this._throttle("remove", path36, 100))
|
|
35689
35795
|
return;
|
|
35690
35796
|
if (!isDirectory && this._watched.size === 1) {
|
|
35691
35797
|
this.add(directory, item, true);
|
|
35692
35798
|
}
|
|
35693
|
-
const wp = this._getWatchedDir(
|
|
35799
|
+
const wp = this._getWatchedDir(path36);
|
|
35694
35800
|
const nestedDirectoryChildren = wp.getChildren();
|
|
35695
|
-
nestedDirectoryChildren.forEach((nested) => this._remove(
|
|
35801
|
+
nestedDirectoryChildren.forEach((nested) => this._remove(path36, nested));
|
|
35696
35802
|
const parent = this._getWatchedDir(directory);
|
|
35697
35803
|
const wasTracked = parent.has(item);
|
|
35698
35804
|
parent.remove(item);
|
|
35699
35805
|
if (this._symlinkPaths.has(fullPath)) {
|
|
35700
35806
|
this._symlinkPaths.delete(fullPath);
|
|
35701
35807
|
}
|
|
35702
|
-
let relPath =
|
|
35808
|
+
let relPath = path36;
|
|
35703
35809
|
if (this.options.cwd)
|
|
35704
|
-
relPath = sp2.relative(this.options.cwd,
|
|
35810
|
+
relPath = sp2.relative(this.options.cwd, path36);
|
|
35705
35811
|
if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
|
|
35706
35812
|
const event = this._pendingWrites.get(relPath).cancelWait();
|
|
35707
35813
|
if (event === EVENTS.ADD)
|
|
35708
35814
|
return;
|
|
35709
35815
|
}
|
|
35710
|
-
this._watched.delete(
|
|
35816
|
+
this._watched.delete(path36);
|
|
35711
35817
|
this._watched.delete(fullPath);
|
|
35712
35818
|
const eventName = isDirectory ? EVENTS.UNLINK_DIR : EVENTS.UNLINK;
|
|
35713
|
-
if (wasTracked && !this._isIgnored(
|
|
35714
|
-
this._emit(eventName,
|
|
35715
|
-
this._closePath(
|
|
35819
|
+
if (wasTracked && !this._isIgnored(path36))
|
|
35820
|
+
this._emit(eventName, path36);
|
|
35821
|
+
this._closePath(path36);
|
|
35716
35822
|
}
|
|
35717
35823
|
/**
|
|
35718
35824
|
* Closes all watchers for a path
|
|
35719
35825
|
*/
|
|
35720
|
-
_closePath(
|
|
35721
|
-
this._closeFile(
|
|
35722
|
-
const dir = sp2.dirname(
|
|
35723
|
-
this._getWatchedDir(dir).remove(sp2.basename(
|
|
35826
|
+
_closePath(path36) {
|
|
35827
|
+
this._closeFile(path36);
|
|
35828
|
+
const dir = sp2.dirname(path36);
|
|
35829
|
+
this._getWatchedDir(dir).remove(sp2.basename(path36));
|
|
35724
35830
|
}
|
|
35725
35831
|
/**
|
|
35726
35832
|
* Closes only file-specific watchers
|
|
35727
35833
|
*/
|
|
35728
|
-
_closeFile(
|
|
35729
|
-
const closers = this._closers.get(
|
|
35834
|
+
_closeFile(path36) {
|
|
35835
|
+
const closers = this._closers.get(path36);
|
|
35730
35836
|
if (!closers)
|
|
35731
35837
|
return;
|
|
35732
35838
|
closers.forEach((closer) => closer());
|
|
35733
|
-
this._closers.delete(
|
|
35839
|
+
this._closers.delete(path36);
|
|
35734
35840
|
}
|
|
35735
|
-
_addPathCloser(
|
|
35841
|
+
_addPathCloser(path36, closer) {
|
|
35736
35842
|
if (!closer)
|
|
35737
35843
|
return;
|
|
35738
|
-
let list = this._closers.get(
|
|
35844
|
+
let list = this._closers.get(path36);
|
|
35739
35845
|
if (!list) {
|
|
35740
35846
|
list = [];
|
|
35741
|
-
this._closers.set(
|
|
35847
|
+
this._closers.set(path36, list);
|
|
35742
35848
|
}
|
|
35743
35849
|
list.push(closer);
|
|
35744
35850
|
}
|
|
@@ -38458,6 +38564,51 @@ function killPid(pid) {
|
|
|
38458
38564
|
return false;
|
|
38459
38565
|
}
|
|
38460
38566
|
}
|
|
38567
|
+
function getWindowsProcessCommandLine(pid) {
|
|
38568
|
+
const pidFilter = `ProcessId=${pid}`;
|
|
38569
|
+
try {
|
|
38570
|
+
const psOut = (0, import_child_process8.execFileSync)("powershell.exe", [
|
|
38571
|
+
"-NoProfile",
|
|
38572
|
+
"-NonInteractive",
|
|
38573
|
+
"-ExecutionPolicy",
|
|
38574
|
+
"Bypass",
|
|
38575
|
+
"-Command",
|
|
38576
|
+
`(Get-CimInstance Win32_Process -Filter "${pidFilter}").CommandLine`
|
|
38577
|
+
], { encoding: "utf8", timeout: 5e3, stdio: ["ignore", "pipe", "ignore"] }).trim();
|
|
38578
|
+
if (psOut) return psOut;
|
|
38579
|
+
} catch {
|
|
38580
|
+
}
|
|
38581
|
+
try {
|
|
38582
|
+
const wmicOut = (0, import_child_process8.execFileSync)("wmic", [
|
|
38583
|
+
"process",
|
|
38584
|
+
"where",
|
|
38585
|
+
pidFilter,
|
|
38586
|
+
"get",
|
|
38587
|
+
"CommandLine"
|
|
38588
|
+
], { encoding: "utf8", timeout: 3e3, stdio: ["ignore", "pipe", "ignore"] }).trim();
|
|
38589
|
+
if (wmicOut) return wmicOut;
|
|
38590
|
+
} catch {
|
|
38591
|
+
}
|
|
38592
|
+
return null;
|
|
38593
|
+
}
|
|
38594
|
+
function getProcessCommandLine(pid) {
|
|
38595
|
+
if (!Number.isFinite(pid) || pid <= 0) return null;
|
|
38596
|
+
if (process.platform === "win32") return getWindowsProcessCommandLine(pid);
|
|
38597
|
+
try {
|
|
38598
|
+
const text = (0, import_child_process8.execFileSync)("ps", ["-o", "command=", "-p", String(pid)], {
|
|
38599
|
+
encoding: "utf8",
|
|
38600
|
+
timeout: 3e3,
|
|
38601
|
+
stdio: ["ignore", "pipe", "ignore"]
|
|
38602
|
+
}).trim();
|
|
38603
|
+
return text || null;
|
|
38604
|
+
} catch {
|
|
38605
|
+
return null;
|
|
38606
|
+
}
|
|
38607
|
+
}
|
|
38608
|
+
function isManagedSessionHostPid(pid) {
|
|
38609
|
+
const commandLine = getProcessCommandLine(pid);
|
|
38610
|
+
return !!commandLine && /session-host-daemon/i.test(commandLine);
|
|
38611
|
+
}
|
|
38461
38612
|
async function waitForPidExit(pid, timeoutMs) {
|
|
38462
38613
|
const start = Date.now();
|
|
38463
38614
|
while (Date.now() - start < timeoutMs) {
|
|
@@ -38474,7 +38625,7 @@ function stopSessionHostProcesses(appName) {
|
|
|
38474
38625
|
try {
|
|
38475
38626
|
if (fs8.existsSync(pidFile)) {
|
|
38476
38627
|
const pid = Number.parseInt(fs8.readFileSync(pidFile, "utf8").trim(), 10);
|
|
38477
|
-
if (Number.isFinite(pid)) {
|
|
38628
|
+
if (Number.isFinite(pid) && pid !== process.pid && isManagedSessionHostPid(pid)) {
|
|
38478
38629
|
killPid(pid);
|
|
38479
38630
|
}
|
|
38480
38631
|
}
|
|
@@ -38485,18 +38636,6 @@ function stopSessionHostProcesses(appName) {
|
|
|
38485
38636
|
} catch {
|
|
38486
38637
|
}
|
|
38487
38638
|
}
|
|
38488
|
-
if (process.platform !== "win32") {
|
|
38489
|
-
try {
|
|
38490
|
-
const raw = (0, import_child_process8.execFileSync)("pgrep", ["-f", "session-host-daemon"], { encoding: "utf8" }).trim();
|
|
38491
|
-
for (const line of raw.split("\n")) {
|
|
38492
|
-
const pid = Number.parseInt(line.trim(), 10);
|
|
38493
|
-
if (Number.isFinite(pid)) {
|
|
38494
|
-
killPid(pid);
|
|
38495
|
-
}
|
|
38496
|
-
}
|
|
38497
|
-
} catch {
|
|
38498
|
-
}
|
|
38499
|
-
}
|
|
38500
38639
|
}
|
|
38501
38640
|
function removeDaemonPidFile() {
|
|
38502
38641
|
const pidFile = path17.join(os20.homedir(), ".adhdev", "daemon.pid");
|
|
@@ -40838,6 +40977,23 @@ var init_forward = __esm({
|
|
|
40838
40977
|
});
|
|
40839
40978
|
|
|
40840
40979
|
// ../../oss/packages/daemon-core/src/providers/provider-instance-manager.ts
|
|
40980
|
+
function projectHotChatSessionStatesFromProviderState(state) {
|
|
40981
|
+
const project = (item) => ({
|
|
40982
|
+
id: item.instanceId,
|
|
40983
|
+
status: item.activeChat?.status || item.status,
|
|
40984
|
+
unread: item.unread,
|
|
40985
|
+
inboxBucket: item.inboxBucket,
|
|
40986
|
+
lastMessageAt: item.lastMessageAt ?? item.activeChat?.lastMessageAt,
|
|
40987
|
+
runtimeLifecycle: item.runtime?.lifecycle ?? null,
|
|
40988
|
+
runtimeSurfaceKind: item.runtime?.surfaceKind,
|
|
40989
|
+
runtimeRestoredFromStorage: item.runtime?.restoredFromStorage === true,
|
|
40990
|
+
runtimeRecoveryState: item.runtime?.recoveryState ?? null
|
|
40991
|
+
});
|
|
40992
|
+
if (state.category === "ide") {
|
|
40993
|
+
return [project(state), ...state.extensions.map(project)];
|
|
40994
|
+
}
|
|
40995
|
+
return [project(state)];
|
|
40996
|
+
}
|
|
40841
40997
|
var ProviderInstanceManager;
|
|
40842
40998
|
var init_provider_instance_manager = __esm({
|
|
40843
40999
|
"../../oss/packages/daemon-core/src/providers/provider-instance-manager.ts"() {
|
|
@@ -40938,6 +41094,27 @@ var init_provider_instance_manager = __esm({
|
|
|
40938
41094
|
}
|
|
40939
41095
|
return states;
|
|
40940
41096
|
}
|
|
41097
|
+
collectHotChatSessionStates() {
|
|
41098
|
+
const sessions = [];
|
|
41099
|
+
for (const [id, instance] of this.instances) {
|
|
41100
|
+
try {
|
|
41101
|
+
const projected = instance.getHotChatSessionState?.();
|
|
41102
|
+
if (Array.isArray(projected)) {
|
|
41103
|
+
sessions.push(...projected.filter((session) => !!session?.id));
|
|
41104
|
+
continue;
|
|
41105
|
+
}
|
|
41106
|
+
if (projected?.id) {
|
|
41107
|
+
sessions.push(projected);
|
|
41108
|
+
continue;
|
|
41109
|
+
}
|
|
41110
|
+
const state = instance.getState();
|
|
41111
|
+
sessions.push(...projectHotChatSessionStatesFromProviderState(state));
|
|
41112
|
+
} catch (e) {
|
|
41113
|
+
LOG.warn("InstanceMgr", `[InstanceManager] Failed to collect hot chat metadata from ${id}: ${e.message}`);
|
|
41114
|
+
}
|
|
41115
|
+
}
|
|
41116
|
+
return sessions;
|
|
41117
|
+
}
|
|
40941
41118
|
/**
|
|
40942
41119
|
* Per-category status collect
|
|
40943
41120
|
*/
|
|
@@ -41019,6 +41196,17 @@ var init_provider_instance_manager = __esm({
|
|
|
41019
41196
|
}
|
|
41020
41197
|
return updated;
|
|
41021
41198
|
}
|
|
41199
|
+
refreshProviderDefinitions(resolveProvider) {
|
|
41200
|
+
let refreshed = 0;
|
|
41201
|
+
for (const instance of this.instances.values()) {
|
|
41202
|
+
if (typeof instance.refreshProviderDefinition !== "function") continue;
|
|
41203
|
+
const provider = resolveProvider(instance.type);
|
|
41204
|
+
if (!provider || typeof provider !== "object") continue;
|
|
41205
|
+
instance.refreshProviderDefinition(provider);
|
|
41206
|
+
refreshed += 1;
|
|
41207
|
+
}
|
|
41208
|
+
return refreshed;
|
|
41209
|
+
}
|
|
41022
41210
|
// ─── cleanup ──────────────────────────────────────
|
|
41023
41211
|
/**
|
|
41024
41212
|
* All terminate
|
|
@@ -45031,8 +45219,8 @@ var init_dev_server = __esm({
|
|
|
45031
45219
|
}
|
|
45032
45220
|
getEndpointList() {
|
|
45033
45221
|
return this.routes.map((r) => {
|
|
45034
|
-
const
|
|
45035
|
-
return `${r.method.padEnd(5)} ${
|
|
45222
|
+
const path36 = typeof r.pattern === "string" ? r.pattern : r.pattern.source.replace(/\\\//g, "/").replace(/\(\[.*?\]\+\)/g, ":type").replace(/[\^$]/g, "");
|
|
45223
|
+
return `${r.method.padEnd(5)} ${path36}`;
|
|
45036
45224
|
});
|
|
45037
45225
|
}
|
|
45038
45226
|
async start(port = DEV_SERVER_PORT) {
|
|
@@ -45301,20 +45489,7 @@ var init_dev_server = __esm({
|
|
|
45301
45489
|
async handleReload(_req, res) {
|
|
45302
45490
|
try {
|
|
45303
45491
|
this.providerLoader.reload();
|
|
45304
|
-
|
|
45305
|
-
if (this.instanceManager) {
|
|
45306
|
-
for (const id of this.instanceManager.listInstanceIds()) {
|
|
45307
|
-
const instance = this.instanceManager.getInstance(id);
|
|
45308
|
-
const providerType = typeof instance?.type === "string" ? instance.type : "";
|
|
45309
|
-
if (!providerType) continue;
|
|
45310
|
-
const resolved = this.providerLoader.resolve(providerType);
|
|
45311
|
-
if (!resolved) continue;
|
|
45312
|
-
if (instance && typeof instance === "object" && "provider" in instance) {
|
|
45313
|
-
instance.provider = resolved;
|
|
45314
|
-
refreshedInstances += 1;
|
|
45315
|
-
}
|
|
45316
|
-
}
|
|
45317
|
-
}
|
|
45492
|
+
const refreshedInstances = this.instanceManager ? this.instanceManager.refreshProviderDefinitions((providerType) => this.providerLoader.resolve(providerType)) : 0;
|
|
45318
45493
|
const providers = this.providerLoader.getAll().map((p) => ({
|
|
45319
45494
|
type: p.type,
|
|
45320
45495
|
name: p.name,
|
|
@@ -59150,15 +59325,15 @@ var require_route = __commonJS({
|
|
|
59150
59325
|
};
|
|
59151
59326
|
}
|
|
59152
59327
|
function wrapConversion(toModel, graph) {
|
|
59153
|
-
const
|
|
59328
|
+
const path36 = [graph[toModel].parent, toModel];
|
|
59154
59329
|
let fn = conversions[graph[toModel].parent][toModel];
|
|
59155
59330
|
let cur = graph[toModel].parent;
|
|
59156
59331
|
while (graph[cur].parent) {
|
|
59157
|
-
|
|
59332
|
+
path36.unshift(graph[cur].parent);
|
|
59158
59333
|
fn = link(conversions[graph[cur].parent][cur], fn);
|
|
59159
59334
|
cur = graph[cur].parent;
|
|
59160
59335
|
}
|
|
59161
|
-
fn.conversion =
|
|
59336
|
+
fn.conversion = path36;
|
|
59162
59337
|
return fn;
|
|
59163
59338
|
}
|
|
59164
59339
|
module2.exports = function(fromModel) {
|
|
@@ -77028,9 +77203,9 @@ var init_prompt = __esm({
|
|
|
77028
77203
|
init_utils();
|
|
77029
77204
|
init_baseUI();
|
|
77030
77205
|
_ = {
|
|
77031
|
-
set: (obj,
|
|
77206
|
+
set: (obj, path36 = "", value) => {
|
|
77032
77207
|
let pointer = obj;
|
|
77033
|
-
|
|
77208
|
+
path36.split(".").forEach((key, index, arr) => {
|
|
77034
77209
|
if (key === "__proto__" || key === "constructor") return;
|
|
77035
77210
|
if (index === arr.length - 1) {
|
|
77036
77211
|
pointer[key] = value;
|
|
@@ -77040,8 +77215,8 @@ var init_prompt = __esm({
|
|
|
77040
77215
|
pointer = pointer[key];
|
|
77041
77216
|
});
|
|
77042
77217
|
},
|
|
77043
|
-
get: (obj,
|
|
77044
|
-
const travel = (regexp) => String.prototype.split.call(
|
|
77218
|
+
get: (obj, path36 = "", defaultValue) => {
|
|
77219
|
+
const travel = (regexp) => String.prototype.split.call(path36, regexp).filter(Boolean).reduce(
|
|
77045
77220
|
// @ts-expect-error implicit any on res[key]
|
|
77046
77221
|
(res, key) => res !== null && res !== void 0 ? res[key] : res,
|
|
77047
77222
|
obj
|
|
@@ -79678,19 +79853,20 @@ var init_screenshot_sender = __esm({
|
|
|
79678
79853
|
}
|
|
79679
79854
|
return sentAny;
|
|
79680
79855
|
}
|
|
79681
|
-
sendScreenshot(peers, base64Data) {
|
|
79856
|
+
sendScreenshot(peers, base64Data, targetSessionId) {
|
|
79682
79857
|
const buffer = Buffer.from(base64Data, "base64");
|
|
79683
|
-
return this.sendScreenshotBuffer(peers, buffer);
|
|
79858
|
+
return this.sendScreenshotBuffer(peers, buffer, targetSessionId);
|
|
79684
79859
|
}
|
|
79685
79860
|
/** Send screenshot as raw Buffer (no base64 conversion overhead) */
|
|
79686
|
-
sendScreenshotBuffer(peers, buffer) {
|
|
79861
|
+
sendScreenshotBuffer(peers, buffer, targetSessionId) {
|
|
79687
79862
|
let sentAny = false;
|
|
79688
79863
|
let debugOnce = !this._ssDebugDone;
|
|
79689
79864
|
for (const [pid, peer] of peers.entries()) {
|
|
79690
79865
|
if (debugOnce) {
|
|
79691
|
-
logDebug(`sendScreenshot peer=${pid}: state=${peer.state}, hasCh=${!!peer.dataChannel}, ssActive=${peer.screenshotActive}, chOpen=${peer.dataChannel?.isOpen?.() ?? "N/A"}, bufSize=${buffer.length}`);
|
|
79866
|
+
logDebug(`sendScreenshot peer=${pid}: state=${peer.state}, hasCh=${!!peer.dataChannel}, ssActive=${peer.screenshotActive}, target=${peer.screenshotTargetSessionId || "none"}, chOpen=${peer.dataChannel?.isOpen?.() ?? "N/A"}, bufSize=${buffer.length}`);
|
|
79692
79867
|
}
|
|
79693
79868
|
if (peer.state !== "connected" || !peer.dataChannel || !peer.screenshotActive) continue;
|
|
79869
|
+
if (targetSessionId && peer.screenshotTargetSessionId !== targetSessionId) continue;
|
|
79694
79870
|
try {
|
|
79695
79871
|
if (!peer.dataChannel.isOpen()) continue;
|
|
79696
79872
|
const header = Buffer.alloc(4);
|
|
@@ -79722,18 +79898,32 @@ async function initiateConnection(deps, peerId, sharePermission) {
|
|
|
79722
79898
|
log("Cannot initiate \u2014 node-datachannel not available");
|
|
79723
79899
|
return;
|
|
79724
79900
|
}
|
|
79901
|
+
const pid = peerId || `legacy_${Date.now()}`;
|
|
79902
|
+
const existing = deps.peers.get(pid);
|
|
79903
|
+
if (existing?.state === "connected") {
|
|
79904
|
+
log(`initiateconnection() ignored for peer ${pid} \u2014 already connected`);
|
|
79905
|
+
return;
|
|
79906
|
+
}
|
|
79907
|
+
if (existing?.state === "connecting") {
|
|
79908
|
+
log(`initiateconnection() ignored for peer ${pid} \u2014 connection already in progress`);
|
|
79909
|
+
return;
|
|
79910
|
+
}
|
|
79725
79911
|
const limits = deps.serverConn.getPlanLimits();
|
|
79726
79912
|
if (limits && limits.maxP2PConnections !== -1) {
|
|
79727
79913
|
let connectedCount = 0;
|
|
79914
|
+
let reservedCount = 0;
|
|
79728
79915
|
for (const peer of deps.peers.values()) {
|
|
79729
79916
|
if (peer.state === "connected") connectedCount++;
|
|
79917
|
+
if (peer.state === "connected" || peer.state === "connecting") reservedCount++;
|
|
79730
79918
|
}
|
|
79731
|
-
if (
|
|
79919
|
+
if (reservedCount >= limits.maxP2PConnections) {
|
|
79732
79920
|
let oldestPeer = null;
|
|
79733
|
-
|
|
79734
|
-
|
|
79735
|
-
if (
|
|
79736
|
-
oldestPeer
|
|
79921
|
+
if (connectedCount >= limits.maxP2PConnections) {
|
|
79922
|
+
for (const [peerKey, peer] of deps.peers) {
|
|
79923
|
+
if (peer.state === "connected") {
|
|
79924
|
+
if (!oldestPeer || peer.connectedAt < oldestPeer.at) {
|
|
79925
|
+
oldestPeer = { id: peerKey, at: peer.connectedAt };
|
|
79926
|
+
}
|
|
79737
79927
|
}
|
|
79738
79928
|
}
|
|
79739
79929
|
}
|
|
@@ -79751,19 +79941,12 @@ async function initiateConnection(deps, peerId, sharePermission) {
|
|
|
79751
79941
|
}
|
|
79752
79942
|
}
|
|
79753
79943
|
disconnectPeer(deps.peers, oldestPeer.id, deps.notifyStateChange);
|
|
79944
|
+
} else {
|
|
79945
|
+
log(`P2P limit reached (${reservedCount}/${limits.maxP2PConnections}) with reserved connecting slot(s). Rejecting peer ${pid.slice(0, 12)}\u2026`);
|
|
79946
|
+
return;
|
|
79754
79947
|
}
|
|
79755
79948
|
}
|
|
79756
79949
|
}
|
|
79757
|
-
const pid = peerId || `legacy_${Date.now()}`;
|
|
79758
|
-
const existing = deps.peers.get(pid);
|
|
79759
|
-
if (existing?.state === "connected") {
|
|
79760
|
-
log(`initiateconnection() ignored for peer ${pid} \u2014 already connected`);
|
|
79761
|
-
return;
|
|
79762
|
-
}
|
|
79763
|
-
if (existing?.state === "connecting") {
|
|
79764
|
-
log(`initiateconnection() ignored for peer ${pid} \u2014 connection already in progress`);
|
|
79765
|
-
return;
|
|
79766
|
-
}
|
|
79767
79950
|
log(`initiateconnection() for peer ${pid}...`);
|
|
79768
79951
|
const mod = deps.nodeDatachannel;
|
|
79769
79952
|
const PeerConnectionCtor = mod.PeerConnection || mod.default?.PeerConnection || mod.default || mod;
|
|
@@ -80122,14 +80305,19 @@ var init_daemon_p2p = __esm({
|
|
|
80122
80305
|
}
|
|
80123
80306
|
return false;
|
|
80124
80307
|
}
|
|
80125
|
-
/** Get
|
|
80126
|
-
get
|
|
80308
|
+
/** Get all target sessions for active screenshot requests */
|
|
80309
|
+
get screenshotTargetSessionIds() {
|
|
80310
|
+
const targets = /* @__PURE__ */ new Set();
|
|
80127
80311
|
for (const peer of this.peers.values()) {
|
|
80128
80312
|
if (peer.screenshotActive && peer.state === "connected" && peer.screenshotTargetSessionId) {
|
|
80129
|
-
|
|
80313
|
+
targets.add(peer.screenshotTargetSessionId);
|
|
80130
80314
|
}
|
|
80131
80315
|
}
|
|
80132
|
-
return
|
|
80316
|
+
return Array.from(targets);
|
|
80317
|
+
}
|
|
80318
|
+
/** Get the target session for the currently active screenshot request */
|
|
80319
|
+
get screenshotTargetSessionId() {
|
|
80320
|
+
return this.screenshotTargetSessionIds[0];
|
|
80133
80321
|
}
|
|
80134
80322
|
constructor(serverConn) {
|
|
80135
80323
|
this.serverConn = serverConn;
|
|
@@ -80238,6 +80426,14 @@ ${e?.stack || ""}`);
|
|
|
80238
80426
|
}
|
|
80239
80427
|
return false;
|
|
80240
80428
|
}
|
|
80429
|
+
hasAnyNeedingFirstFrameForTarget(targetSessionId) {
|
|
80430
|
+
for (const peer of this.peers.values()) {
|
|
80431
|
+
if (peer.needsFirstFrame && peer.screenshotActive && peer.state === "connected" && peer.screenshotTargetSessionId === targetSessionId) {
|
|
80432
|
+
return true;
|
|
80433
|
+
}
|
|
80434
|
+
}
|
|
80435
|
+
return false;
|
|
80436
|
+
}
|
|
80241
80437
|
onStateChange(listener) {
|
|
80242
80438
|
this.stateListeners.push(listener);
|
|
80243
80439
|
}
|
|
@@ -80301,11 +80497,14 @@ ${e?.stack || ""}`);
|
|
|
80301
80497
|
if (targetPeers.size === 0) return false;
|
|
80302
80498
|
return this.screenshotSender.broadcastSessionOutput(targetPeers, sessionId, data);
|
|
80303
80499
|
}
|
|
80304
|
-
sendScreenshot(base64Data) {
|
|
80305
|
-
return this.screenshotSender.sendScreenshot(this.peers, base64Data);
|
|
80500
|
+
sendScreenshot(base64Data, targetSessionId) {
|
|
80501
|
+
return this.screenshotSender.sendScreenshot(this.peers, base64Data, targetSessionId);
|
|
80502
|
+
}
|
|
80503
|
+
sendScreenshotBuffer(buffer, targetSessionId) {
|
|
80504
|
+
return this.screenshotSender.sendScreenshotBuffer(this.peers, buffer, targetSessionId);
|
|
80306
80505
|
}
|
|
80307
|
-
|
|
80308
|
-
return this.
|
|
80506
|
+
sendScreenshotBufferForTarget(targetSessionId, buffer) {
|
|
80507
|
+
return this.sendScreenshotBuffer(buffer, targetSessionId);
|
|
80309
80508
|
}
|
|
80310
80509
|
// ─── Handler registration (unchanged API) ───────
|
|
80311
80510
|
onFileRequest(handler) {
|
|
@@ -80535,16 +80734,16 @@ var require_filesystem = __commonJS({
|
|
|
80535
80734
|
var LDD_PATH = "/usr/bin/ldd";
|
|
80536
80735
|
var SELF_PATH = "/proc/self/exe";
|
|
80537
80736
|
var MAX_LENGTH = 2048;
|
|
80538
|
-
var readFileSync20 = (
|
|
80539
|
-
const fd = fs27.openSync(
|
|
80737
|
+
var readFileSync20 = (path36) => {
|
|
80738
|
+
const fd = fs27.openSync(path36, "r");
|
|
80540
80739
|
const buffer = Buffer.alloc(MAX_LENGTH);
|
|
80541
80740
|
const bytesRead = fs27.readSync(fd, buffer, 0, MAX_LENGTH, 0);
|
|
80542
80741
|
fs27.close(fd, () => {
|
|
80543
80742
|
});
|
|
80544
80743
|
return buffer.subarray(0, bytesRead);
|
|
80545
80744
|
};
|
|
80546
|
-
var readFile = (
|
|
80547
|
-
fs27.open(
|
|
80745
|
+
var readFile = (path36) => new Promise((resolve18, reject) => {
|
|
80746
|
+
fs27.open(path36, "r", (err, fd) => {
|
|
80548
80747
|
if (err) {
|
|
80549
80748
|
reject(err);
|
|
80550
80749
|
} else {
|
|
@@ -80663,11 +80862,11 @@ var require_detect_libc = __commonJS({
|
|
|
80663
80862
|
}
|
|
80664
80863
|
return null;
|
|
80665
80864
|
};
|
|
80666
|
-
var familyFromInterpreterPath = (
|
|
80667
|
-
if (
|
|
80668
|
-
if (
|
|
80865
|
+
var familyFromInterpreterPath = (path36) => {
|
|
80866
|
+
if (path36) {
|
|
80867
|
+
if (path36.includes("/ld-musl-")) {
|
|
80669
80868
|
return MUSL;
|
|
80670
|
-
} else if (
|
|
80869
|
+
} else if (path36.includes("/ld-linux-")) {
|
|
80671
80870
|
return GLIBC;
|
|
80672
80871
|
}
|
|
80673
80872
|
}
|
|
@@ -80714,8 +80913,8 @@ var require_detect_libc = __commonJS({
|
|
|
80714
80913
|
cachedFamilyInterpreter = null;
|
|
80715
80914
|
try {
|
|
80716
80915
|
const selfContent = await readFile(SELF_PATH);
|
|
80717
|
-
const
|
|
80718
|
-
cachedFamilyInterpreter = familyFromInterpreterPath(
|
|
80916
|
+
const path36 = interpreterPath(selfContent);
|
|
80917
|
+
cachedFamilyInterpreter = familyFromInterpreterPath(path36);
|
|
80719
80918
|
} catch (e) {
|
|
80720
80919
|
}
|
|
80721
80920
|
return cachedFamilyInterpreter;
|
|
@@ -80727,8 +80926,8 @@ var require_detect_libc = __commonJS({
|
|
|
80727
80926
|
cachedFamilyInterpreter = null;
|
|
80728
80927
|
try {
|
|
80729
80928
|
const selfContent = readFileSync20(SELF_PATH);
|
|
80730
|
-
const
|
|
80731
|
-
cachedFamilyInterpreter = familyFromInterpreterPath(
|
|
80929
|
+
const path36 = interpreterPath(selfContent);
|
|
80930
|
+
cachedFamilyInterpreter = familyFromInterpreterPath(path36);
|
|
80732
80931
|
} catch (e) {
|
|
80733
80932
|
}
|
|
80734
80933
|
return cachedFamilyInterpreter;
|
|
@@ -82447,18 +82646,18 @@ var require_sharp = __commonJS({
|
|
|
82447
82646
|
`@img/sharp-${runtimePlatform}/sharp.node`,
|
|
82448
82647
|
"@img/sharp-wasm32/sharp.node"
|
|
82449
82648
|
];
|
|
82450
|
-
var
|
|
82649
|
+
var path36;
|
|
82451
82650
|
var sharp;
|
|
82452
82651
|
var errors = [];
|
|
82453
|
-
for (
|
|
82652
|
+
for (path36 of paths) {
|
|
82454
82653
|
try {
|
|
82455
|
-
sharp = require(
|
|
82654
|
+
sharp = require(path36);
|
|
82456
82655
|
break;
|
|
82457
82656
|
} catch (err) {
|
|
82458
82657
|
errors.push(err);
|
|
82459
82658
|
}
|
|
82460
82659
|
}
|
|
82461
|
-
if (sharp &&
|
|
82660
|
+
if (sharp && path36.startsWith("@img/sharp-linux-x64") && !sharp._isUsingX64V2()) {
|
|
82462
82661
|
const err = new Error("Prebuilt binaries for linux-x64 require v2 microarchitecture");
|
|
82463
82662
|
err.code = "Unsupported CPU";
|
|
82464
82663
|
errors.push(err);
|
|
@@ -85367,15 +85566,15 @@ var require_color = __commonJS({
|
|
|
85367
85566
|
};
|
|
85368
85567
|
}
|
|
85369
85568
|
function wrapConversion(toModel, graph) {
|
|
85370
|
-
const
|
|
85569
|
+
const path36 = [graph[toModel].parent, toModel];
|
|
85371
85570
|
let fn = conversions_default[graph[toModel].parent][toModel];
|
|
85372
85571
|
let cur = graph[toModel].parent;
|
|
85373
85572
|
while (graph[cur].parent) {
|
|
85374
|
-
|
|
85573
|
+
path36.unshift(graph[cur].parent);
|
|
85375
85574
|
fn = link(conversions_default[graph[cur].parent][cur], fn);
|
|
85376
85575
|
cur = graph[cur].parent;
|
|
85377
85576
|
}
|
|
85378
|
-
fn.conversion =
|
|
85577
|
+
fn.conversion = path36;
|
|
85379
85578
|
return fn;
|
|
85380
85579
|
}
|
|
85381
85580
|
function route(fromModel) {
|
|
@@ -85992,7 +86191,7 @@ var require_channel = __commonJS({
|
|
|
85992
86191
|
var require_output = __commonJS({
|
|
85993
86192
|
"../../node_modules/sharp/lib/output.js"(exports2, module2) {
|
|
85994
86193
|
"use strict";
|
|
85995
|
-
var
|
|
86194
|
+
var path36 = require("path");
|
|
85996
86195
|
var is = require_is();
|
|
85997
86196
|
var sharp = require_sharp();
|
|
85998
86197
|
var formats = /* @__PURE__ */ new Map([
|
|
@@ -86023,9 +86222,9 @@ var require_output = __commonJS({
|
|
|
86023
86222
|
let err;
|
|
86024
86223
|
if (!is.string(fileOut)) {
|
|
86025
86224
|
err = new Error("Missing output file path");
|
|
86026
|
-
} else if (is.string(this.options.input.file) &&
|
|
86225
|
+
} else if (is.string(this.options.input.file) && path36.resolve(this.options.input.file) === path36.resolve(fileOut)) {
|
|
86027
86226
|
err = new Error("Cannot use same file for input and output");
|
|
86028
|
-
} else if (jp2Regex.test(
|
|
86227
|
+
} else if (jp2Regex.test(path36.extname(fileOut)) && !this.constructor.format.jp2k.output.file) {
|
|
86029
86228
|
err = errJp2Save();
|
|
86030
86229
|
}
|
|
86031
86230
|
if (err) {
|
|
@@ -87029,6 +87228,7 @@ var init_screenshot_controller = __esm({
|
|
|
87029
87228
|
lastSize = 0;
|
|
87030
87229
|
lastHash = 0;
|
|
87031
87230
|
staticFrameCount = 0;
|
|
87231
|
+
targetFrameState = /* @__PURE__ */ new Map();
|
|
87032
87232
|
currentInterval;
|
|
87033
87233
|
// Quality profiles
|
|
87034
87234
|
profileDirect;
|
|
@@ -87092,14 +87292,13 @@ var init_screenshot_controller = __esm({
|
|
|
87092
87292
|
async tick() {
|
|
87093
87293
|
if (!this.deps.isRunning()) return;
|
|
87094
87294
|
const active = this.deps.isScreenshotActive();
|
|
87095
|
-
const
|
|
87096
|
-
|
|
87295
|
+
const targetSessionIds = this.getActiveTargetSessionIds();
|
|
87296
|
+
const isRelay = this.deps.isUsingRelay();
|
|
87297
|
+
const profile = isRelay ? this.profileRelay : this.profileDirect;
|
|
87298
|
+
if (active && targetSessionIds.length === 0) {
|
|
87097
87299
|
this.timer = setTimeout(() => this.tick(), 500);
|
|
87098
87300
|
return;
|
|
87099
87301
|
}
|
|
87100
|
-
const cdp = targetSessionId ? this.deps.getCdp(targetSessionId) : null;
|
|
87101
|
-
const isRelay = this.deps.isUsingRelay();
|
|
87102
|
-
const profile = isRelay ? this.profileRelay : this.profileDirect;
|
|
87103
87302
|
this.checkBudgetReset();
|
|
87104
87303
|
if (this.dailyBudgetMs > 0) {
|
|
87105
87304
|
const now = Date.now();
|
|
@@ -87114,49 +87313,84 @@ var init_screenshot_controller = __esm({
|
|
|
87114
87313
|
}
|
|
87115
87314
|
}
|
|
87116
87315
|
const budgetBlocked = this.budgetExhausted && isRelay;
|
|
87117
|
-
if (!active ||
|
|
87316
|
+
if (!active || budgetBlocked) {
|
|
87118
87317
|
this.staticFrameCount = 0;
|
|
87318
|
+
this.targetFrameState.clear();
|
|
87119
87319
|
this.currentInterval = profile.maxInterval;
|
|
87120
87320
|
if (!active) this.lastActiveTimestamp = 0;
|
|
87121
87321
|
this.timer = setTimeout(() => this.tick(), budgetBlocked ? 3e4 : this.currentInterval);
|
|
87122
87322
|
return;
|
|
87123
87323
|
}
|
|
87124
87324
|
this.debugCount++;
|
|
87125
|
-
|
|
87126
|
-
|
|
87127
|
-
|
|
87325
|
+
let capturedAny = false;
|
|
87326
|
+
let sentAnyFrame = false;
|
|
87327
|
+
let anyFirstFrameAcrossTargets = false;
|
|
87328
|
+
for (const targetSessionId of targetSessionIds) {
|
|
87329
|
+
const cdp = this.deps.getCdp(targetSessionId);
|
|
87330
|
+
if (!cdp) continue;
|
|
87331
|
+
try {
|
|
87332
|
+
const buf = await cdp.captureScreenshot({ quality: profile.quality });
|
|
87333
|
+
if (!buf) {
|
|
87334
|
+
if (this.debugCount <= 5) LOG.debug("Screenshot", `captureScreenshot returned null for target=${targetSessionId}`);
|
|
87335
|
+
continue;
|
|
87336
|
+
}
|
|
87337
|
+
capturedAny = true;
|
|
87338
|
+
const state = this.getTargetFrameState(targetSessionId);
|
|
87128
87339
|
const hash2 = _ScreenshotController.fnvHash(buf);
|
|
87129
|
-
const sizeMatch = buf.length ===
|
|
87130
|
-
const hashMatch = hash2 ===
|
|
87131
|
-
const anyNeedsFirstFrame = this.deps.hasAnyNeedingFirstFrame();
|
|
87340
|
+
const sizeMatch = buf.length === state.lastSize;
|
|
87341
|
+
const hashMatch = hash2 === state.lastHash;
|
|
87342
|
+
const anyNeedsFirstFrame = this.deps.hasAnyNeedingFirstFrameForTarget?.(targetSessionId) ?? this.deps.hasAnyNeedingFirstFrame();
|
|
87132
87343
|
const resizeTarget = anyNeedsFirstFrame ? profile.firstFrameLongEdge : profile.maxLongEdge;
|
|
87344
|
+
anyFirstFrameAcrossTargets = anyFirstFrameAcrossTargets || anyNeedsFirstFrame;
|
|
87133
87345
|
if (sizeMatch && hashMatch && !anyNeedsFirstFrame) {
|
|
87134
|
-
|
|
87135
|
-
if (
|
|
87346
|
+
state.staticFrameCount++;
|
|
87347
|
+
if (state.staticFrameCount >= this.STATIC_THRESHOLD) {
|
|
87136
87348
|
this.currentInterval = Math.min(this.currentInterval + 200, profile.maxInterval);
|
|
87137
87349
|
}
|
|
87138
87350
|
if (this.debugCount <= 5 || this.debugCount % 50 === 0) {
|
|
87139
|
-
LOG.debug("Screenshot", `skip (unchanged, static=${
|
|
87140
|
-
}
|
|
87141
|
-
} else {
|
|
87142
|
-
const normalizedBuf = await this.normalizeBuffer(buf, resizeTarget, profile.quality);
|
|
87143
|
-
this.lastSize = buf.length;
|
|
87144
|
-
this.lastHash = hash2;
|
|
87145
|
-
this.staticFrameCount = 0;
|
|
87146
|
-
this.currentInterval = profile.minInterval;
|
|
87147
|
-
const sent = this.deps.sendScreenshotBuffer(normalizedBuf);
|
|
87148
|
-
if (this.debugCount <= 3 || anyNeedsFirstFrame) {
|
|
87149
|
-
LOG.debug("Screenshot", `sent: ${normalizedBuf.length} bytes, delivered=${sent}, interval=${this.currentInterval}ms, ${isRelay ? "RELAY" : "DIRECT"}${anyNeedsFirstFrame ? " (first-frame)" : ""}`);
|
|
87351
|
+
LOG.debug("Screenshot", `skip target=${targetSessionId} (unchanged, static=${state.staticFrameCount}, interval=${this.currentInterval}ms, ${isRelay ? "RELAY" : "DIRECT"})`);
|
|
87150
87352
|
}
|
|
87353
|
+
continue;
|
|
87151
87354
|
}
|
|
87152
|
-
|
|
87153
|
-
|
|
87355
|
+
const normalizedBuf = await this.normalizeBuffer(buf, resizeTarget, profile.quality);
|
|
87356
|
+
state.lastSize = buf.length;
|
|
87357
|
+
state.lastHash = hash2;
|
|
87358
|
+
state.staticFrameCount = 0;
|
|
87359
|
+
this.lastSize = buf.length;
|
|
87360
|
+
this.lastHash = hash2;
|
|
87361
|
+
this.staticFrameCount = 0;
|
|
87362
|
+
this.currentInterval = profile.minInterval;
|
|
87363
|
+
const sent = this.deps.sendScreenshotBufferForTarget ? this.deps.sendScreenshotBufferForTarget(targetSessionId, normalizedBuf) : this.deps.sendScreenshotBuffer(normalizedBuf);
|
|
87364
|
+
sentAnyFrame = sentAnyFrame || sent;
|
|
87365
|
+
if (this.debugCount <= 3 || anyNeedsFirstFrame) {
|
|
87366
|
+
LOG.debug("Screenshot", `sent target=${targetSessionId}: ${normalizedBuf.length} bytes, delivered=${sent}, interval=${this.currentInterval}ms, ${isRelay ? "RELAY" : "DIRECT"}${anyNeedsFirstFrame ? " (first-frame)" : ""}`);
|
|
87367
|
+
}
|
|
87368
|
+
} catch (e) {
|
|
87369
|
+
if (this.debugCount <= 5) LOG.warn("Screenshot", `error target=${targetSessionId}: ${e?.message}`);
|
|
87154
87370
|
}
|
|
87155
|
-
}
|
|
87156
|
-
|
|
87371
|
+
}
|
|
87372
|
+
if (!capturedAny) {
|
|
87373
|
+
this.currentInterval = profile.maxInterval;
|
|
87374
|
+
} else if (!sentAnyFrame && !anyFirstFrameAcrossTargets) {
|
|
87375
|
+
this.currentInterval = Math.min(this.currentInterval + 200, profile.maxInterval);
|
|
87157
87376
|
}
|
|
87158
87377
|
this.timer = setTimeout(() => this.tick(), this.currentInterval);
|
|
87159
87378
|
}
|
|
87379
|
+
getActiveTargetSessionIds() {
|
|
87380
|
+
const explicitTargets = this.deps.getScreenshotTargetSessionIds?.() || [];
|
|
87381
|
+
const normalized = explicitTargets.map((target) => typeof target === "string" ? target.trim() : "").filter((target) => target.length > 0);
|
|
87382
|
+
if (normalized.length > 0) return Array.from(new Set(normalized));
|
|
87383
|
+
const legacyTarget = this.deps.getScreenshotTargetSessionId();
|
|
87384
|
+
return legacyTarget ? [legacyTarget] : [];
|
|
87385
|
+
}
|
|
87386
|
+
getTargetFrameState(targetSessionId) {
|
|
87387
|
+
let state = this.targetFrameState.get(targetSessionId);
|
|
87388
|
+
if (!state) {
|
|
87389
|
+
state = { lastSize: 0, lastHash: 0, staticFrameCount: 0 };
|
|
87390
|
+
this.targetFrameState.set(targetSessionId, state);
|
|
87391
|
+
}
|
|
87392
|
+
return state;
|
|
87393
|
+
}
|
|
87160
87394
|
// ─── Budget ───────────────────────────────────
|
|
87161
87395
|
checkBudgetReset() {
|
|
87162
87396
|
const today = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
@@ -87373,7 +87607,7 @@ function killPid2(pid) {
|
|
|
87373
87607
|
return false;
|
|
87374
87608
|
}
|
|
87375
87609
|
}
|
|
87376
|
-
function
|
|
87610
|
+
function getWindowsProcessCommandLine2(pid) {
|
|
87377
87611
|
const pidFilter = `ProcessId=${pid}`;
|
|
87378
87612
|
try {
|
|
87379
87613
|
const psOut = (0, import_child_process13.execFileSync)("powershell.exe", [
|
|
@@ -87402,13 +87636,32 @@ function getWindowsProcessCommandLine(pid) {
|
|
|
87402
87636
|
}
|
|
87403
87637
|
return null;
|
|
87404
87638
|
}
|
|
87639
|
+
function getProcessCommandLine2(pid) {
|
|
87640
|
+
if (!Number.isFinite(pid) || pid <= 0) return null;
|
|
87641
|
+
if (process.platform === "win32") return getWindowsProcessCommandLine2(pid);
|
|
87642
|
+
try {
|
|
87643
|
+
const text = (0, import_child_process13.execFileSync)("ps", ["-o", "command=", "-p", String(pid)], {
|
|
87644
|
+
encoding: "utf8",
|
|
87645
|
+
timeout: 3e3,
|
|
87646
|
+
stdio: ["ignore", "pipe", "ignore"]
|
|
87647
|
+
}).trim();
|
|
87648
|
+
return text || null;
|
|
87649
|
+
} catch {
|
|
87650
|
+
return null;
|
|
87651
|
+
}
|
|
87652
|
+
}
|
|
87653
|
+
function isManagedSessionHostPid2(pid) {
|
|
87654
|
+
const commandLine = getProcessCommandLine2(pid);
|
|
87655
|
+
if (!commandLine) return false;
|
|
87656
|
+
return /session-host-daemon/i.test(commandLine);
|
|
87657
|
+
}
|
|
87405
87658
|
function stopManagedSessionHostProcess() {
|
|
87406
87659
|
let stopped = false;
|
|
87407
87660
|
const pidFile = getSessionHostPidFile();
|
|
87408
87661
|
try {
|
|
87409
87662
|
if (fs22.existsSync(pidFile)) {
|
|
87410
87663
|
const pid = Number.parseInt(fs22.readFileSync(pidFile, "utf8").trim(), 10);
|
|
87411
|
-
if (Number.isFinite(pid) && pid !== process.pid) {
|
|
87664
|
+
if (Number.isFinite(pid) && pid !== process.pid && isManagedSessionHostPid2(pid)) {
|
|
87412
87665
|
stopped = killPid2(pid) || stopped;
|
|
87413
87666
|
}
|
|
87414
87667
|
}
|
|
@@ -87422,40 +87675,7 @@ function stopManagedSessionHostProcess() {
|
|
|
87422
87675
|
return stopped;
|
|
87423
87676
|
}
|
|
87424
87677
|
function stopSessionHost() {
|
|
87425
|
-
|
|
87426
|
-
if (process.platform === "win32") {
|
|
87427
|
-
try {
|
|
87428
|
-
const raw = (0, import_child_process13.execFileSync)("tasklist", ["/FO", "CSV", "/NH", "/FI", "IMAGENAME eq node.exe"], {
|
|
87429
|
-
encoding: "utf8",
|
|
87430
|
-
timeout: 5e3,
|
|
87431
|
-
stdio: ["ignore", "pipe", "ignore"],
|
|
87432
|
-
windowsHide: true
|
|
87433
|
-
}).trim();
|
|
87434
|
-
for (const line of raw.split(/\r?\n/)) {
|
|
87435
|
-
const match = line.match(/^"node\.exe","(\d+)"/i);
|
|
87436
|
-
if (!match) continue;
|
|
87437
|
-
const candidatePid = Number.parseInt(match[1], 10);
|
|
87438
|
-
if (!Number.isFinite(candidatePid) || candidatePid === process.pid) continue;
|
|
87439
|
-
const commandLine = getWindowsProcessCommandLine(candidatePid);
|
|
87440
|
-
if (commandLine?.includes("session-host-daemon")) {
|
|
87441
|
-
stopped = killPid2(candidatePid) || stopped;
|
|
87442
|
-
}
|
|
87443
|
-
}
|
|
87444
|
-
} catch {
|
|
87445
|
-
}
|
|
87446
|
-
} else {
|
|
87447
|
-
try {
|
|
87448
|
-
const raw = (0, import_child_process13.execFileSync)("pgrep", ["-f", "session-host-daemon"], { encoding: "utf8" }).trim();
|
|
87449
|
-
for (const line of raw.split("\n")) {
|
|
87450
|
-
const pid = Number.parseInt(line.trim(), 10);
|
|
87451
|
-
if (Number.isFinite(pid) && pid !== process.pid && pid !== process.ppid) {
|
|
87452
|
-
stopped = killPid2(pid) || stopped;
|
|
87453
|
-
}
|
|
87454
|
-
}
|
|
87455
|
-
} catch {
|
|
87456
|
-
}
|
|
87457
|
-
}
|
|
87458
|
-
return stopped;
|
|
87678
|
+
return stopManagedSessionHostProcess();
|
|
87459
87679
|
}
|
|
87460
87680
|
async function ensureSessionHostReady2() {
|
|
87461
87681
|
const quarantine = quarantineLegacyStandaloneSessions({
|
|
@@ -87712,10 +87932,65 @@ var init_session_host_controller = __esm({
|
|
|
87712
87932
|
var adhdev_daemon_exports = {};
|
|
87713
87933
|
__export(adhdev_daemon_exports, {
|
|
87714
87934
|
AdhdevDaemon: () => AdhdevDaemon,
|
|
87935
|
+
buildMandatoryUpdateInfoFromServerPayload: () => buildMandatoryUpdateInfoFromServerPayload,
|
|
87936
|
+
buildMandatoryUpdateRequiredPayload: () => buildMandatoryUpdateRequiredPayload,
|
|
87715
87937
|
getDaemonPid: () => getDaemonPid,
|
|
87716
87938
|
isDaemonRunning: () => isDaemonRunning,
|
|
87717
|
-
stopDaemon: () => stopDaemon
|
|
87718
|
-
|
|
87939
|
+
stopDaemon: () => stopDaemon,
|
|
87940
|
+
validateMandatoryUpdateTarget: () => validateMandatoryUpdateTarget,
|
|
87941
|
+
verifyPublishedMandatoryUpdateTarget: () => verifyPublishedMandatoryUpdateTarget
|
|
87942
|
+
});
|
|
87943
|
+
function validateMandatoryUpdateTarget(targetVersion) {
|
|
87944
|
+
if (typeof targetVersion !== "string") return { valid: false, error: "target version is required" };
|
|
87945
|
+
if (targetVersion !== targetVersion.trim()) return { valid: false, error: "target version must not contain whitespace" };
|
|
87946
|
+
const version2 = targetVersion;
|
|
87947
|
+
if (!version2) return { valid: false, error: "target version is required" };
|
|
87948
|
+
if (!/^\d+\.\d+\.\d+(?:-[0-9A-Za-z]+(?:\.[0-9A-Za-z]+)*)?(?:\+[0-9A-Za-z]+(?:\.[0-9A-Za-z]+)*)?$/.test(version2)) {
|
|
87949
|
+
return { valid: false, error: `invalid semver target: ${version2}` };
|
|
87950
|
+
}
|
|
87951
|
+
return { valid: true };
|
|
87952
|
+
}
|
|
87953
|
+
function verifyPublishedMandatoryUpdateTarget(packageName, targetVersion, deps = {}) {
|
|
87954
|
+
if (!/^(?:adhdev|@adhdev\/daemon-standalone)$/.test(packageName)) {
|
|
87955
|
+
throw new Error(`invalid mandatory update package: ${packageName}`);
|
|
87956
|
+
}
|
|
87957
|
+
const validation = validateMandatoryUpdateTarget(targetVersion);
|
|
87958
|
+
if (!validation.valid) throw new Error(validation.error || "invalid mandatory update target");
|
|
87959
|
+
const run = deps.execFileSync || import_child_process14.execFileSync;
|
|
87960
|
+
const npmExecutable = deps.npmExecutable || resolveCurrentGlobalInstallSurface({ packageName }).npmExecutable;
|
|
87961
|
+
const published = String(run(npmExecutable, ["view", `${packageName}@${targetVersion}`, "version"], {
|
|
87962
|
+
encoding: "utf-8",
|
|
87963
|
+
timeout: 1e4,
|
|
87964
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
87965
|
+
...process.platform === "win32" ? { shell: true, windowsHide: true } : {}
|
|
87966
|
+
})).trim();
|
|
87967
|
+
if (published !== targetVersion) {
|
|
87968
|
+
throw new Error(`Published version mismatch: expected ${targetVersion}, got ${published || "unknown"}`);
|
|
87969
|
+
}
|
|
87970
|
+
return published;
|
|
87971
|
+
}
|
|
87972
|
+
function buildMandatoryUpdateInfoFromServerPayload(payload, fallbackVersion) {
|
|
87973
|
+
const targetVersion = typeof payload?.latest === "string" && payload.latest ? payload.latest : fallbackVersion;
|
|
87974
|
+
const validation = validateMandatoryUpdateTarget(targetVersion);
|
|
87975
|
+
if (!validation.valid) return { info: null, error: validation.error || targetVersion };
|
|
87976
|
+
return {
|
|
87977
|
+
info: {
|
|
87978
|
+
targetVersion,
|
|
87979
|
+
reason: typeof payload?.reason === "string" && payload.reason.trim() ? payload.reason.trim() : "major_minor_mismatch",
|
|
87980
|
+
minVersion: typeof payload?.minVersion === "string" && payload.minVersion.trim() ? payload.minVersion.trim() : void 0
|
|
87981
|
+
}
|
|
87982
|
+
};
|
|
87983
|
+
}
|
|
87984
|
+
function buildMandatoryUpdateRequiredPayload(pending, interactionId) {
|
|
87985
|
+
return {
|
|
87986
|
+
error: "A mandatory daemon update is pending. Finish current work and let the daemon update before starting a new session.",
|
|
87987
|
+
code: "DAEMON_UPDATE_REQUIRED",
|
|
87988
|
+
required: true,
|
|
87989
|
+
latest: pending.targetVersion,
|
|
87990
|
+
reason: pending.reason,
|
|
87991
|
+
interactionId
|
|
87992
|
+
};
|
|
87993
|
+
}
|
|
87719
87994
|
function resolveDaemonPort(ref = {}) {
|
|
87720
87995
|
return Number.isFinite(ref.port) && Number(ref.port) > 0 ? Number(ref.port) : DEFAULT_DAEMON_PORT;
|
|
87721
87996
|
}
|
|
@@ -87742,7 +88017,7 @@ function removeDaemonPid(ref = {}) {
|
|
|
87742
88017
|
function isDaemonRunning(ref = {}) {
|
|
87743
88018
|
const port = resolveDaemonPort(ref);
|
|
87744
88019
|
try {
|
|
87745
|
-
const { execFileSync:
|
|
88020
|
+
const { execFileSync: execFileSync7 } = require("child_process");
|
|
87746
88021
|
const probe = `
|
|
87747
88022
|
const http = require('http');
|
|
87748
88023
|
const req = http.get('http://127.0.0.1:${port}/health', { timeout: 1500 }, (res) => {
|
|
@@ -87752,7 +88027,7 @@ function isDaemonRunning(ref = {}) {
|
|
|
87752
88027
|
req.on('error', () => process.stdout.write('0'));
|
|
87753
88028
|
req.on('timeout', () => { req.destroy(); process.stdout.write('0'); });
|
|
87754
88029
|
`;
|
|
87755
|
-
const result =
|
|
88030
|
+
const result = execFileSync7(process.execPath, ["-e", probe], {
|
|
87756
88031
|
encoding: "utf-8",
|
|
87757
88032
|
timeout: 3e3,
|
|
87758
88033
|
stdio: ["ignore", "pipe", "ignore"]
|
|
@@ -87778,9 +88053,9 @@ function isDaemonRunning(ref = {}) {
|
|
|
87778
88053
|
function isAdhdevProcess(pid) {
|
|
87779
88054
|
try {
|
|
87780
88055
|
if (process.platform === "win32") {
|
|
87781
|
-
const { execFileSync:
|
|
88056
|
+
const { execFileSync: execFileSync7 } = require("child_process");
|
|
87782
88057
|
try {
|
|
87783
|
-
const psOut =
|
|
88058
|
+
const psOut = execFileSync7("powershell.exe", [
|
|
87784
88059
|
"-NoProfile",
|
|
87785
88060
|
"-NonInteractive",
|
|
87786
88061
|
"-ExecutionPolicy",
|
|
@@ -87793,8 +88068,8 @@ function isAdhdevProcess(pid) {
|
|
|
87793
88068
|
return true;
|
|
87794
88069
|
}
|
|
87795
88070
|
} else {
|
|
87796
|
-
const { execFileSync:
|
|
87797
|
-
const cmdline =
|
|
88071
|
+
const { execFileSync: execFileSync7 } = require("child_process");
|
|
88072
|
+
const cmdline = execFileSync7("ps", ["-o", "command=", "-p", String(pid)], {
|
|
87798
88073
|
encoding: "utf-8",
|
|
87799
88074
|
timeout: 2e3,
|
|
87800
88075
|
stdio: ["ignore", "pipe", "ignore"]
|
|
@@ -87808,7 +88083,7 @@ function isAdhdevProcess(pid) {
|
|
|
87808
88083
|
function getDaemonHealthPid(ref = {}) {
|
|
87809
88084
|
const port = resolveDaemonPort(ref);
|
|
87810
88085
|
try {
|
|
87811
|
-
const { execFileSync:
|
|
88086
|
+
const { execFileSync: execFileSync7 } = require("child_process");
|
|
87812
88087
|
const probe = `
|
|
87813
88088
|
const http = require('http');
|
|
87814
88089
|
const req = http.get('http://127.0.0.1:${port}/health', { timeout: 1500 }, (res) => {
|
|
@@ -87826,7 +88101,7 @@ function getDaemonHealthPid(ref = {}) {
|
|
|
87826
88101
|
req.on('error', () => {});
|
|
87827
88102
|
req.on('timeout', () => { req.destroy(); });
|
|
87828
88103
|
`;
|
|
87829
|
-
const result =
|
|
88104
|
+
const result = execFileSync7(process.execPath, ["-e", probe], {
|
|
87830
88105
|
encoding: "utf-8",
|
|
87831
88106
|
timeout: 3e3,
|
|
87832
88107
|
stdio: ["ignore", "pipe", "ignore"]
|
|
@@ -87872,7 +88147,7 @@ function stopDaemon(ref = {}) {
|
|
|
87872
88147
|
return false;
|
|
87873
88148
|
}
|
|
87874
88149
|
}
|
|
87875
|
-
var os28, fs23, path29, import_http, import_ws3, pkgVersion, AdhdevDaemon;
|
|
88150
|
+
var os28, fs23, path29, import_http, import_child_process14, import_ws3, pkgVersion, AdhdevDaemon;
|
|
87876
88151
|
var init_adhdev_daemon = __esm({
|
|
87877
88152
|
"src/adhdev-daemon.ts"() {
|
|
87878
88153
|
"use strict";
|
|
@@ -87888,12 +88163,13 @@ var init_adhdev_daemon = __esm({
|
|
|
87888
88163
|
fs23 = __toESM(require("fs"));
|
|
87889
88164
|
path29 = __toESM(require("path"));
|
|
87890
88165
|
import_http = require("http");
|
|
88166
|
+
import_child_process14 = require("child_process");
|
|
87891
88167
|
import_ws3 = require("ws");
|
|
87892
88168
|
init_source();
|
|
87893
88169
|
init_version();
|
|
87894
88170
|
init_src();
|
|
87895
88171
|
init_runtime_defaults();
|
|
87896
|
-
pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.
|
|
88172
|
+
pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.35" });
|
|
87897
88173
|
AdhdevDaemon = class _AdhdevDaemon {
|
|
87898
88174
|
localHttpServer = null;
|
|
87899
88175
|
localWss = null;
|
|
@@ -87986,6 +88262,10 @@ var init_adhdev_daemon = __esm({
|
|
|
87986
88262
|
getUpgradePackageName() {
|
|
87987
88263
|
return process.argv[1]?.includes("daemon-standalone") ? "@adhdev/daemon-standalone" : "adhdev";
|
|
87988
88264
|
}
|
|
88265
|
+
getMandatoryUpdateBlockPayload(cmd, interactionId) {
|
|
88266
|
+
if (!this.pendingMandatoryUpdate || !_AdhdevDaemon.MANDATORY_UPDATE_BLOCKED_COMMANDS.has(cmd)) return null;
|
|
88267
|
+
return buildMandatoryUpdateRequiredPayload(this.pendingMandatoryUpdate, interactionId);
|
|
88268
|
+
}
|
|
87989
88269
|
hasBlockingSessionsForMandatoryUpdate() {
|
|
87990
88270
|
if (!this.components) return false;
|
|
87991
88271
|
const blocking = /* @__PURE__ */ new Set(["generating", "waiting_approval", "starting"]);
|
|
@@ -88011,15 +88291,7 @@ var init_adhdev_daemon = __esm({
|
|
|
88011
88291
|
const pkgName = this.getUpgradePackageName();
|
|
88012
88292
|
this.mandatoryUpgradeInFlight = true;
|
|
88013
88293
|
try {
|
|
88014
|
-
|
|
88015
|
-
const published = execSync8(`npm view ${pkgName}@${pending.targetVersion} version`, {
|
|
88016
|
-
encoding: "utf-8",
|
|
88017
|
-
timeout: 1e4,
|
|
88018
|
-
stdio: ["pipe", "pipe", "pipe"]
|
|
88019
|
-
}).trim();
|
|
88020
|
-
if (published !== pending.targetVersion) {
|
|
88021
|
-
throw new Error(`Published version mismatch: expected ${pending.targetVersion}, got ${published || "unknown"}`);
|
|
88022
|
-
}
|
|
88294
|
+
verifyPublishedMandatoryUpdateTarget(pkgName, pending.targetVersion);
|
|
88023
88295
|
LOG.warn("Upgrade", `Applying mandatory daemon update (${pending.reason}) \u2192 v${pending.targetVersion}`);
|
|
88024
88296
|
spawnDetachedDaemonUpgradeHelper({
|
|
88025
88297
|
packageName: pkgName,
|
|
@@ -88121,7 +88393,7 @@ var init_adhdev_daemon = __esm({
|
|
|
88121
88393
|
const now = Date.now();
|
|
88122
88394
|
const cached2 = this.hotChatSnapshotCache;
|
|
88123
88395
|
const sessions = cached2 && now - cached2.builtAt < _AdhdevDaemon.HOT_CHAT_SNAPSHOT_CACHE_TTL_MS ? cached2.sessions : (() => {
|
|
88124
|
-
const built = this.
|
|
88396
|
+
const built = this.components.instanceManager.collectHotChatSessionStates();
|
|
88125
88397
|
this.hotChatSnapshotCache = { sessions: built, builtAt: now };
|
|
88126
88398
|
return built;
|
|
88127
88399
|
})();
|
|
@@ -88506,14 +88778,17 @@ ${err?.stack || ""}`);
|
|
|
88506
88778
|
isRunning: () => this.running,
|
|
88507
88779
|
isScreenshotActive: () => this.p2p?.screenshotActive ?? false,
|
|
88508
88780
|
getScreenshotTargetSessionId: () => this.p2p?.screenshotTargetSessionId,
|
|
88781
|
+
getScreenshotTargetSessionIds: () => this.p2p?.screenshotTargetSessionIds ?? [],
|
|
88509
88782
|
isUsingRelay: () => this.p2p?.isUsingRelay ?? false,
|
|
88510
88783
|
hasAnyNeedingFirstFrame: () => this.p2p?.hasAnyNeedingFirstFrame() ?? false,
|
|
88784
|
+
hasAnyNeedingFirstFrameForTarget: (targetSessionId) => this.p2p?.hasAnyNeedingFirstFrameForTarget(targetSessionId) ?? false,
|
|
88511
88785
|
getCdp: (targetSessionId) => {
|
|
88512
88786
|
if (targetSessionId) return this.getCdpFor(targetSessionId);
|
|
88513
88787
|
LOG.warn("P2P", "Screenshot requested without targetSessionId \u2014 cannot determine target session. Skipping frame.");
|
|
88514
88788
|
return null;
|
|
88515
88789
|
},
|
|
88516
|
-
sendScreenshotBuffer: (buf) => this.p2p.sendScreenshotBuffer(buf)
|
|
88790
|
+
sendScreenshotBuffer: (buf) => this.p2p.sendScreenshotBuffer(buf),
|
|
88791
|
+
sendScreenshotBufferForTarget: (targetSessionId, buf) => this.p2p.sendScreenshotBufferForTarget(targetSessionId, buf)
|
|
88517
88792
|
}, planLimits ?? void 0);
|
|
88518
88793
|
this.screenshotController.start();
|
|
88519
88794
|
this.p2p.onScreenshotStart(() => this.screenshotController?.triggerImmediate());
|
|
@@ -88542,11 +88817,12 @@ ${err?.stack || ""}`);
|
|
|
88542
88817
|
});
|
|
88543
88818
|
this.serverConn.on("force_update_required", (msg) => {
|
|
88544
88819
|
const payload = msg.payload;
|
|
88545
|
-
|
|
88546
|
-
|
|
88547
|
-
|
|
88548
|
-
|
|
88549
|
-
}
|
|
88820
|
+
const parsedUpdate = buildMandatoryUpdateInfoFromServerPayload(payload, pkgVersion);
|
|
88821
|
+
if (!parsedUpdate.info) {
|
|
88822
|
+
LOG.error("Upgrade", `Ignoring invalid mandatory daemon update target from server: ${parsedUpdate.error || "unknown"}`);
|
|
88823
|
+
return;
|
|
88824
|
+
}
|
|
88825
|
+
this.pendingMandatoryUpdate = parsedUpdate.info;
|
|
88550
88826
|
LOG.warn("Upgrade", `Mandatory daemon update required (${this.pendingMandatoryUpdate.reason})`);
|
|
88551
88827
|
void this.maybeApplyMandatoryUpdate("server-force-update");
|
|
88552
88828
|
});
|
|
@@ -88657,15 +88933,9 @@ ${err?.stack || ""}`);
|
|
|
88657
88933
|
const cmdStart = Date.now();
|
|
88658
88934
|
const source = msg.ipcWs ? "ext" : typeof msg.source === "string" && msg.source.trim() ? msg.source : "ws";
|
|
88659
88935
|
try {
|
|
88660
|
-
|
|
88661
|
-
|
|
88662
|
-
|
|
88663
|
-
code: "DAEMON_UPDATE_REQUIRED",
|
|
88664
|
-
required: true,
|
|
88665
|
-
latest: this.pendingMandatoryUpdate.targetVersion,
|
|
88666
|
-
reason: this.pendingMandatoryUpdate.reason,
|
|
88667
|
-
interactionId
|
|
88668
|
-
});
|
|
88936
|
+
const mandatoryUpdateBlock = this.getMandatoryUpdateBlockPayload(cmd, interactionId);
|
|
88937
|
+
if (mandatoryUpdateBlock) {
|
|
88938
|
+
this.sendResult(msg, false, mandatoryUpdateBlock);
|
|
88669
88939
|
return;
|
|
88670
88940
|
}
|
|
88671
88941
|
if (source === "api" && !loadConfig().allowServerApiProxy) {
|
|
@@ -88710,6 +88980,10 @@ ${err?.stack || ""}`);
|
|
|
88710
88980
|
const interactionId = String(normalizedData._interactionId);
|
|
88711
88981
|
const cmdStart = Date.now();
|
|
88712
88982
|
try {
|
|
88983
|
+
const mandatoryUpdateBlock = this.getMandatoryUpdateBlockPayload(cmdType, interactionId);
|
|
88984
|
+
if (mandatoryUpdateBlock) {
|
|
88985
|
+
return { success: false, ...mandatoryUpdateBlock };
|
|
88986
|
+
}
|
|
88713
88987
|
switch (cmdType) {
|
|
88714
88988
|
case "get_runtime_snapshot": {
|
|
88715
88989
|
const sessionId = typeof normalizedData.sessionId === "string" ? normalizedData.sessionId : "";
|
|
@@ -88888,8 +89162,22 @@ ${err?.stack || ""}`);
|
|
|
88888
89162
|
}));
|
|
88889
89163
|
return;
|
|
88890
89164
|
}
|
|
89165
|
+
const normalizedArgs = this.ensureInteractionContext(args);
|
|
89166
|
+
const interactionId = String(normalizedArgs._interactionId);
|
|
89167
|
+
const mandatoryUpdateBlock = this.getMandatoryUpdateBlockPayload(command, interactionId);
|
|
89168
|
+
if (mandatoryUpdateBlock) {
|
|
89169
|
+
ws.send(JSON.stringify({
|
|
89170
|
+
type: "ext:command_result",
|
|
89171
|
+
payload: {
|
|
89172
|
+
requestId,
|
|
89173
|
+
success: false,
|
|
89174
|
+
...mandatoryUpdateBlock
|
|
89175
|
+
}
|
|
89176
|
+
}));
|
|
89177
|
+
return;
|
|
89178
|
+
}
|
|
88891
89179
|
try {
|
|
88892
|
-
const result = await this.components.router.execute(command,
|
|
89180
|
+
const result = await this.components.router.execute(command, normalizedArgs, "ipc");
|
|
88893
89181
|
ws.send(JSON.stringify({
|
|
88894
89182
|
type: "ext:command_result",
|
|
88895
89183
|
payload: {
|
|
@@ -89059,9 +89347,9 @@ async function runWizard(options = {}) {
|
|
|
89059
89347
|
}
|
|
89060
89348
|
async function checkForUpdate() {
|
|
89061
89349
|
try {
|
|
89062
|
-
const { execFileSync:
|
|
89350
|
+
const { execFileSync: execFileSync7 } = await import("child_process");
|
|
89063
89351
|
const currentVersion = resolvePackageVersion();
|
|
89064
|
-
const latestVersion = readLatestPublishedCliVersion(
|
|
89352
|
+
const latestVersion = readLatestPublishedCliVersion(execFileSync7);
|
|
89065
89353
|
if (!latestVersion) return;
|
|
89066
89354
|
if (!currentVersion || !latestVersion || currentVersion === latestVersion) return;
|
|
89067
89355
|
console.log(source_default.yellow(` Update available: ${currentVersion} \u2192 ${latestVersion}`));
|
|
@@ -89078,7 +89366,7 @@ async function checkForUpdate() {
|
|
|
89078
89366
|
const spinner = (await Promise.resolve().then(() => (init_ora(), ora_exports))).default("Updating adhdev CLI...").start();
|
|
89079
89367
|
try {
|
|
89080
89368
|
const installCommand = buildPinnedGlobalInstallCommand({ packageName: "adhdev", targetVersion: "latest" });
|
|
89081
|
-
|
|
89369
|
+
execFileSync7(installCommand.command, installCommand.args, {
|
|
89082
89370
|
encoding: "utf-8",
|
|
89083
89371
|
timeout: 6e4,
|
|
89084
89372
|
stdio: ["pipe", "pipe", "pipe"]
|
|
@@ -90424,6 +90712,7 @@ init_source();
|
|
|
90424
90712
|
init_src();
|
|
90425
90713
|
|
|
90426
90714
|
// src/cli/setup-commands.ts
|
|
90715
|
+
var import_node_path4 = __toESM(require("path"));
|
|
90427
90716
|
init_source();
|
|
90428
90717
|
init_src();
|
|
90429
90718
|
|
|
@@ -90576,8 +90865,7 @@ function parsePositiveInteger(value, fallback2) {
|
|
|
90576
90865
|
return Number.isFinite(parsed) && parsed >= 0 ? parsed : fallback2;
|
|
90577
90866
|
}
|
|
90578
90867
|
function buildHistoryResumeLaunchPayload(cliType, session, overrideDir) {
|
|
90579
|
-
const
|
|
90580
|
-
const dir = typeof overrideDir === "string" && overrideDir.trim() ? path35.resolve(overrideDir.trim()) : typeof session.workspace === "string" && session.workspace.trim() ? path35.resolve(session.workspace.trim()) : "";
|
|
90868
|
+
const dir = typeof overrideDir === "string" && overrideDir.trim() ? import_node_path4.default.resolve(overrideDir.trim()) : typeof session.workspace === "string" && session.workspace.trim() ? import_node_path4.default.resolve(session.workspace.trim()) : "";
|
|
90581
90869
|
if (!dir) {
|
|
90582
90870
|
throw new Error(`Saved history ${session.providerSessionId} is missing workspace metadata. Pass --dir to resume it explicitly.`);
|
|
90583
90871
|
}
|
|
@@ -90667,12 +90955,13 @@ async function promptForSavedHistoryResumeSession(providerArg, sessions, options
|
|
|
90667
90955
|
}
|
|
90668
90956
|
return selected;
|
|
90669
90957
|
}
|
|
90670
|
-
function registerSetupCommands(program2,
|
|
90958
|
+
function registerSetupCommands(program2, getProviderLoader2) {
|
|
90671
90959
|
program2.command("setup").description("Run the interactive setup wizard (detect IDEs, login)").option("-f, --force", "Force re-run setup even if already configured").action(async (options) => {
|
|
90672
90960
|
const { runWizard: runWizard2 } = await Promise.resolve().then(() => (init_wizard(), wizard_exports));
|
|
90673
90961
|
await runWizard2({ force: options.force });
|
|
90674
90962
|
});
|
|
90675
90963
|
program2.command("launch [target]").description("Launch IDE with CDP or start CLI agent").option("-w, --workspace <path>", "Workspace directory to open").option("-n, --new-window", "Open in a new window").option("-d, --dir <path>", "Working directory for CLI agent", process.cwd()).action(async (targetArg, options) => {
|
|
90964
|
+
const providerLoader = await getProviderLoader2();
|
|
90676
90965
|
const {
|
|
90677
90966
|
detectIDEs: detectIDEs2,
|
|
90678
90967
|
detectCLIs: detectCLIs2,
|
|
@@ -90696,7 +90985,7 @@ function registerSetupCommands(program2, providerLoader) {
|
|
|
90696
90985
|
console.log(source_default.gray(" Then run: adhdev launch " + targetArg));
|
|
90697
90986
|
process.exit(1);
|
|
90698
90987
|
}
|
|
90699
|
-
const resolvedDir =
|
|
90988
|
+
const resolvedDir = import_node_path4.default.resolve(workingDir);
|
|
90700
90989
|
const result = await sendDaemonCommand("launch_cli", {
|
|
90701
90990
|
cliType,
|
|
90702
90991
|
dir: resolvedDir
|
|
@@ -90816,6 +91105,7 @@ function registerSetupCommands(program2, providerLoader) {
|
|
|
90816
91105
|
});
|
|
90817
91106
|
const history = program2.command("history").description("Browse and resume provider saved history");
|
|
90818
91107
|
history.command("list <provider>").description("List saved history for a CLI or ACP provider").option("--json", "Print raw JSON output").option("--limit <count>", "Maximum number of saved history entries to show", "30").option("--offset <count>", "Skip the first N saved history entries", "0").option("--resumable", "Show only saved history entries that can resume immediately").option("--text <text>", "Filter saved history by title or preview substring").option("--workspace <text>", "Filter saved history by workspace path substring").option("--model <text>", "Filter saved history by model substring").option("--sort <mode>", "Sort by recent, oldest, or messages", "recent").action(async (providerArg, options) => {
|
|
91108
|
+
const providerLoader = await getProviderLoader2();
|
|
90819
91109
|
const providerTarget = resolveLaunchableProviderTarget(providerLoader, providerArg);
|
|
90820
91110
|
if (!providerTarget) {
|
|
90821
91111
|
console.log(source_default.red(`
|
|
@@ -90888,6 +91178,7 @@ function registerSetupCommands(program2, providerLoader) {
|
|
|
90888
91178
|
printSavedHistorySessions(providerArg, providerTarget.resolvedType, sessions, hasMore);
|
|
90889
91179
|
});
|
|
90890
91180
|
history.command("resume <provider> [historySessionId]").description("Resume saved history for a CLI or ACP provider").option("-d, --dir <path>", "Override the saved workspace when resuming").option("--resumable", "When choosing interactively, hide entries that still need --dir").option("--text <text>", "When choosing interactively, filter by title or preview substring").option("--workspace <text>", "When choosing interactively, filter by workspace path substring").option("--model <text>", "When choosing interactively, filter by model substring").option("--sort <mode>", "When choosing interactively, sort by recent, oldest, or messages", "recent").action(async (providerArg, historySessionId, options) => {
|
|
91181
|
+
const providerLoader = await getProviderLoader2();
|
|
90891
91182
|
const providerTarget = resolveLaunchableProviderTarget(providerLoader, providerArg);
|
|
90892
91183
|
if (!providerTarget) {
|
|
90893
91184
|
console.log(source_default.red(`
|
|
@@ -90981,6 +91272,7 @@ function registerSetupCommands(program2, providerLoader) {
|
|
|
90981
91272
|
}
|
|
90982
91273
|
});
|
|
90983
91274
|
program2.command("status").description("Show current ADHDev setup status").action(async () => {
|
|
91275
|
+
const providerLoader = await getProviderLoader2();
|
|
90984
91276
|
const { loadConfig: loadConfig2, detectIDEs: detectIDEs2, detectCLIs: detectCLIs2 } = await Promise.resolve().then(() => (init_src(), src_exports));
|
|
90985
91277
|
const { isDaemonRunning: isDaemonRunning2, getDaemonPid: getDaemonPid2 } = await Promise.resolve().then(() => (init_adhdev_daemon(), adhdev_daemon_exports));
|
|
90986
91278
|
const { probeSessionHostStatus: probeSessionHostStatus2 } = await Promise.resolve().then(() => (init_session_host(), session_host_exports));
|
|
@@ -91064,6 +91356,7 @@ function registerSetupCommands(program2, providerLoader) {
|
|
|
91064
91356
|
console.log();
|
|
91065
91357
|
});
|
|
91066
91358
|
program2.command("detect").description("Detect installed IDEs, CLI agents, and ACP agents").action(async () => {
|
|
91359
|
+
const providerLoader = await getProviderLoader2();
|
|
91067
91360
|
const { detectIDEs: detectIDEs2, detectCLIs: detectCLIs2 } = await Promise.resolve().then(() => (init_src(), src_exports));
|
|
91068
91361
|
console.log(source_default.bold("\n\u{1F50D} Detecting installed IDEs...\n"));
|
|
91069
91362
|
const ides = await detectIDEs2();
|
|
@@ -91165,7 +91458,7 @@ function registerSetupCommands(program2, providerLoader) {
|
|
|
91165
91458
|
program2.command("uninstall").description("Completely wipe all setting, configuration, stop daemon and uninstall service").option("-f, --force", "Skip confirmation prompt").action(async (options) => {
|
|
91166
91459
|
const inquirer2 = await Promise.resolve().then(() => (init_lib(), lib_exports));
|
|
91167
91460
|
const fs27 = await import("fs");
|
|
91168
|
-
const
|
|
91461
|
+
const path36 = await import("path");
|
|
91169
91462
|
const os31 = await import("os");
|
|
91170
91463
|
const { spawnSync: spawnSync3 } = await import("child_process");
|
|
91171
91464
|
if (!options.force) {
|
|
@@ -91191,7 +91484,7 @@ function registerSetupCommands(program2, providerLoader) {
|
|
|
91191
91484
|
}
|
|
91192
91485
|
console.log(source_default.gray(" Removing OS background service..."));
|
|
91193
91486
|
spawnSync3(process.execPath, [process.argv[1], "service", "uninstall"], { stdio: "inherit" });
|
|
91194
|
-
const adhdevDir =
|
|
91487
|
+
const adhdevDir = path36.join(os31.homedir(), ".adhdev");
|
|
91195
91488
|
if (fs27.existsSync(adhdevDir)) {
|
|
91196
91489
|
console.log(source_default.gray(` Deleting ${adhdevDir}...`));
|
|
91197
91490
|
try {
|
|
@@ -91215,10 +91508,10 @@ init_src();
|
|
|
91215
91508
|
|
|
91216
91509
|
// src/cli/runtime-tools.ts
|
|
91217
91510
|
var fs24 = __toESM(require("fs"));
|
|
91218
|
-
var
|
|
91511
|
+
var path31 = __toESM(require("path"));
|
|
91219
91512
|
function defaultPackageRoot() {
|
|
91220
91513
|
const currentCliPath = process.argv[1] ? fs24.realpathSync.native(process.argv[1]) : process.cwd();
|
|
91221
|
-
return
|
|
91514
|
+
return path31.resolve(path31.dirname(currentCliPath), "../..");
|
|
91222
91515
|
}
|
|
91223
91516
|
function normalizePath2(value) {
|
|
91224
91517
|
return value.replace(/\\/g, "/").toLowerCase();
|
|
@@ -91227,19 +91520,19 @@ function shouldPreferSource(currentCliPath, packageRoot) {
|
|
|
91227
91520
|
const normalizedCliPath = normalizePath2(currentCliPath || "");
|
|
91228
91521
|
if (normalizedCliPath.includes("/src/cli/")) return true;
|
|
91229
91522
|
if (normalizedCliPath.includes("/dist/cli/")) return false;
|
|
91230
|
-
return fs24.existsSync(
|
|
91523
|
+
return fs24.existsSync(path31.join(packageRoot, "src", "cli", "index.ts"));
|
|
91231
91524
|
}
|
|
91232
91525
|
function getVendoredToolEntry(packageRoot, tool) {
|
|
91233
91526
|
if (tool === "session-host-daemon") {
|
|
91234
|
-
return
|
|
91527
|
+
return path31.join(packageRoot, "vendor", "session-host-daemon", "index.js");
|
|
91235
91528
|
}
|
|
91236
|
-
return
|
|
91529
|
+
return path31.join(packageRoot, "vendor", "terminal-mux-cli", "index.js");
|
|
91237
91530
|
}
|
|
91238
91531
|
function getSourceToolEntry(packageRoot, tool) {
|
|
91239
91532
|
if (tool === "session-host-daemon") {
|
|
91240
|
-
return
|
|
91533
|
+
return path31.resolve(packageRoot, "../../oss/packages/session-host-daemon/src/index.ts");
|
|
91241
91534
|
}
|
|
91242
|
-
return
|
|
91535
|
+
return path31.resolve(packageRoot, "../../oss/packages/terminal-mux-cli/src/index.ts");
|
|
91243
91536
|
}
|
|
91244
91537
|
function getGlobalToolCommand(tool) {
|
|
91245
91538
|
return tool === "session-host-daemon" ? "adhdev-sessiond" : "adhmux";
|
|
@@ -91319,6 +91612,25 @@ async function createConfiguredProviderLoader(options = {}) {
|
|
|
91319
91612
|
if (options.load) loader.loadAll();
|
|
91320
91613
|
return loader;
|
|
91321
91614
|
}
|
|
91615
|
+
var _sharedLoaderPromise = null;
|
|
91616
|
+
function getSharedCliProviderLoader() {
|
|
91617
|
+
if (!_sharedLoaderPromise) {
|
|
91618
|
+
_sharedLoaderPromise = (async () => {
|
|
91619
|
+
const { ProviderLoader: ProviderLoader2, loadConfig: loadConfig2 } = await Promise.resolve().then(() => (init_src(), src_exports));
|
|
91620
|
+
const config2 = loadConfig2();
|
|
91621
|
+
const loader = new ProviderLoader2({
|
|
91622
|
+
logFn: () => {
|
|
91623
|
+
},
|
|
91624
|
+
userDir: config2.providerDir,
|
|
91625
|
+
sourceMode: config2.providerSourceMode
|
|
91626
|
+
});
|
|
91627
|
+
loader.loadAll();
|
|
91628
|
+
loader.registerToDetector();
|
|
91629
|
+
return loader;
|
|
91630
|
+
})();
|
|
91631
|
+
}
|
|
91632
|
+
return _sharedLoaderPromise;
|
|
91633
|
+
}
|
|
91322
91634
|
|
|
91323
91635
|
// src/cli/debug-trace-cli.ts
|
|
91324
91636
|
function normalizeOptionalFilter(value) {
|
|
@@ -91395,9 +91707,6 @@ var DEFAULT_DAEMON_PORT_TEXT = String(DEFAULT_DAEMON_PORT);
|
|
|
91395
91707
|
var DEV_SERVER_PORT2 = 19280;
|
|
91396
91708
|
var DEV_SERVER_BASE_URL = `http://127.0.0.1:${DEV_SERVER_PORT2}`;
|
|
91397
91709
|
function hideCommand(command) {
|
|
91398
|
-
if (typeof command.hideHelp === "function") {
|
|
91399
|
-
command.hideHelp();
|
|
91400
|
-
}
|
|
91401
91710
|
command._hidden = true;
|
|
91402
91711
|
return command;
|
|
91403
91712
|
}
|
|
@@ -91700,12 +92009,118 @@ async function handleTraceCommand(options) {
|
|
|
91700
92009
|
console.log();
|
|
91701
92010
|
}
|
|
91702
92011
|
}
|
|
92012
|
+
async function runDaemonUpgrade(options, pkgVersion3) {
|
|
92013
|
+
const { isDaemonRunning: isDaemonRunning2, stopDaemon: stopDaemon2 } = await Promise.resolve().then(() => (init_adhdev_daemon(), adhdev_daemon_exports));
|
|
92014
|
+
const { stopManagedSessionHostProcess: stopManagedSessionHostProcess2 } = await Promise.resolve().then(() => (init_session_host(), session_host_exports));
|
|
92015
|
+
const { execSync: execSync8, spawn: spawn6 } = await import("child_process");
|
|
92016
|
+
const fsMod = await import("fs");
|
|
92017
|
+
const pathMod = await import("path");
|
|
92018
|
+
console.log(source_default.bold("\n \u{1F504} ADHDev Upgrade\n"));
|
|
92019
|
+
const adhdevPath = process.argv[1];
|
|
92020
|
+
const realPath = fsMod.realpathSync(adhdevPath);
|
|
92021
|
+
const isLinked = realPath.includes(".openclaw") || realPath.includes("/src/");
|
|
92022
|
+
const currentVersion = pkgVersion3;
|
|
92023
|
+
console.log(` ${source_default.bold("Current:")} v${currentVersion}`);
|
|
92024
|
+
console.log(` ${source_default.bold("Install:")} ${isLinked ? "npm link (dev)" : "npm global"}`);
|
|
92025
|
+
if (isLinked) {
|
|
92026
|
+
const projectRoot = pathMod.resolve(pathMod.dirname(realPath), "..");
|
|
92027
|
+
const launcherDir = pathMod.join(projectRoot);
|
|
92028
|
+
console.log(` ${source_default.bold("Path:")} ${launcherDir}`);
|
|
92029
|
+
console.log(source_default.cyan("\n Pulling latest..."));
|
|
92030
|
+
try {
|
|
92031
|
+
let gitRoot = launcherDir;
|
|
92032
|
+
while (!fsMod.existsSync(pathMod.join(gitRoot, ".git")) && gitRoot !== "/") {
|
|
92033
|
+
gitRoot = pathMod.dirname(gitRoot);
|
|
92034
|
+
}
|
|
92035
|
+
execSync8("git pull --rebase", { cwd: gitRoot, stdio: "inherit" });
|
|
92036
|
+
console.log(source_default.cyan("\n Building..."));
|
|
92037
|
+
execSync8("npm run build", { cwd: launcherDir, stdio: "inherit" });
|
|
92038
|
+
execSync8("npm link", { cwd: launcherDir, stdio: "inherit" });
|
|
92039
|
+
console.log(source_default.green("\n \u2713 Build complete"));
|
|
92040
|
+
} catch (e) {
|
|
92041
|
+
console.log(source_default.red(`
|
|
92042
|
+
\u2717 Build failed: ${e?.message}
|
|
92043
|
+
`));
|
|
92044
|
+
process.exit(1);
|
|
92045
|
+
}
|
|
92046
|
+
} else {
|
|
92047
|
+
console.log(source_default.cyan("\n Checking for updates..."));
|
|
92048
|
+
let latest;
|
|
92049
|
+
try {
|
|
92050
|
+
latest = execSync8("npm view adhdev version", { encoding: "utf-8" }).trim();
|
|
92051
|
+
} catch (e) {
|
|
92052
|
+
console.log(source_default.red(`
|
|
92053
|
+
\u2717 Failed to check latest version: ${e?.message}
|
|
92054
|
+
`));
|
|
92055
|
+
process.exit(1);
|
|
92056
|
+
return;
|
|
92057
|
+
}
|
|
92058
|
+
console.log(` ${source_default.bold("Latest:")} v${latest}`);
|
|
92059
|
+
if (latest === currentVersion) {
|
|
92060
|
+
console.log(source_default.green("\n \u2713 Already on latest version.\n"));
|
|
92061
|
+
if (!options.restart) return;
|
|
92062
|
+
} else {
|
|
92063
|
+
console.log(source_default.cyan(`
|
|
92064
|
+
Upgrading v${currentVersion} \u2192 v${latest}...`));
|
|
92065
|
+
const daemonWasRunning = options.restart !== false && isDaemonRunning2();
|
|
92066
|
+
if (daemonWasRunning) {
|
|
92067
|
+
stopDaemon2();
|
|
92068
|
+
await new Promise((r) => setTimeout(r, 1e3));
|
|
92069
|
+
stopManagedSessionHostProcess2();
|
|
92070
|
+
}
|
|
92071
|
+
const { spawnDetachedDaemonUpgradeHelper: spawnDetachedDaemonUpgradeHelper2 } = await Promise.resolve().then(() => (init_src(), src_exports));
|
|
92072
|
+
spawnDetachedDaemonUpgradeHelper2({
|
|
92073
|
+
packageName: "adhdev",
|
|
92074
|
+
targetVersion: latest,
|
|
92075
|
+
parentPid: process.pid,
|
|
92076
|
+
restartArgv: daemonWasRunning ? [process.argv[1], "daemon", "-p", DEFAULT_DAEMON_PORT_TEXT] : [],
|
|
92077
|
+
cwd: process.cwd()
|
|
92078
|
+
});
|
|
92079
|
+
if (daemonWasRunning) {
|
|
92080
|
+
console.log(source_default.cyan(" Upgrading and restarting daemon in background..."));
|
|
92081
|
+
} else {
|
|
92082
|
+
console.log(source_default.cyan(" Upgrading in background..."));
|
|
92083
|
+
console.log(source_default.gray(" Start daemon when ready: adhdev daemon"));
|
|
92084
|
+
}
|
|
92085
|
+
console.log(source_default.gray(` Progress: ~/.adhdev/daemon-upgrade.log
|
|
92086
|
+
`));
|
|
92087
|
+
process.exit(0);
|
|
92088
|
+
return;
|
|
92089
|
+
}
|
|
92090
|
+
}
|
|
92091
|
+
if (options.restart !== false && isDaemonRunning2()) {
|
|
92092
|
+
console.log(source_default.yellow("\n Restarting daemon..."));
|
|
92093
|
+
stopDaemon2();
|
|
92094
|
+
await new Promise((r) => setTimeout(r, 2e3));
|
|
92095
|
+
stopManagedSessionHostProcess2();
|
|
92096
|
+
await new Promise((r) => setTimeout(r, 500));
|
|
92097
|
+
const child = spawn6(process.execPath, [process.argv[1], "daemon", "-p", DEFAULT_DAEMON_PORT_TEXT], {
|
|
92098
|
+
detached: true,
|
|
92099
|
+
stdio: "ignore",
|
|
92100
|
+
windowsHide: true,
|
|
92101
|
+
env: { ...process.env }
|
|
92102
|
+
});
|
|
92103
|
+
child.unref();
|
|
92104
|
+
await new Promise((r) => setTimeout(r, 3e3));
|
|
92105
|
+
if (isDaemonRunning2()) {
|
|
92106
|
+
console.log(source_default.green(` \u2713 Daemon restarted with new version
|
|
92107
|
+
`));
|
|
92108
|
+
} else {
|
|
92109
|
+
console.log(source_default.yellow(` \u26A0 Daemon not detected. Start manually: adhdev daemon
|
|
92110
|
+
`));
|
|
92111
|
+
}
|
|
92112
|
+
} else if (options.restart !== false) {
|
|
92113
|
+
console.log(source_default.gray("\n Daemon was not running. Start with: adhdev daemon\n"));
|
|
92114
|
+
} else {
|
|
92115
|
+
console.log(source_default.green("\n \u2713 Upgrade complete (daemon not restarted)\n"));
|
|
92116
|
+
}
|
|
92117
|
+
}
|
|
91703
92118
|
function registerDaemonCommands(program2, pkgVersion3) {
|
|
91704
92119
|
program2.command("daemon").description("\u{1F680} Start ADHDev Daemon \u2014 unified hub for IDE monitoring, agent management, and remote control").option("-p, --port <port>", "Local WS server port", DEFAULT_DAEMON_PORT_TEXT).option("--server <url>", "Override server URL for testing").option("--dev", "Enable Dev Mode \u2014 HTTP API on :19280 for script debugging + structured trace collection").option("--log-level <level>", "Console log level (debug|info|warn|error)").option("--trace", "Enable structured debug trace collection").option("--trace-content", "Include richer content snapshots in debug traces").option("--trace-buffer-size <count>", "Structured trace ring buffer size").action(async (options) => {
|
|
91705
92120
|
const { AdhdevDaemon: AdhdevDaemon2 } = await Promise.resolve().then(() => (init_adhdev_daemon(), adhdev_daemon_exports));
|
|
91706
92121
|
const daemon = new AdhdevDaemon2();
|
|
91707
92122
|
await daemon.start({
|
|
91708
|
-
localPort: parseInt(options.port) || DEFAULT_DAEMON_PORT,
|
|
92123
|
+
localPort: parseInt(options.port, 10) || DEFAULT_DAEMON_PORT,
|
|
91709
92124
|
serverUrl: options.server,
|
|
91710
92125
|
foreground: true,
|
|
91711
92126
|
dev: options.dev || false,
|
|
@@ -91801,7 +92216,7 @@ function registerDaemonCommands(program2, pkgVersion3) {
|
|
|
91801
92216
|
const { probeSessionHostStatus: probeSessionHostStatus2 } = await Promise.resolve().then(() => (init_session_host(), session_host_exports));
|
|
91802
92217
|
const port = parseInt(options.port, 10) || DEFAULT_DAEMON_PORT;
|
|
91803
92218
|
const config2 = loadConfig2();
|
|
91804
|
-
const providerLoader = await
|
|
92219
|
+
const providerLoader = await getSharedCliProviderLoader();
|
|
91805
92220
|
if (isDaemonRunning2({ port })) {
|
|
91806
92221
|
console.log(source_default.green(`
|
|
91807
92222
|
\u2713 ADHDev Daemon is running.
|
|
@@ -92260,123 +92675,19 @@ function registerDaemonCommands(program2, pkgVersion3) {
|
|
|
92260
92675
|
}
|
|
92261
92676
|
}));
|
|
92262
92677
|
hideCommand(program2.command("daemon:upgrade").description("Upgrade ADHDev to latest version and restart daemon").option("--no-restart", "Upgrade only, skip daemon restart").action(async (options) => {
|
|
92263
|
-
|
|
92264
|
-
const { stopManagedSessionHostProcess: stopManagedSessionHostProcess2 } = await Promise.resolve().then(() => (init_session_host(), session_host_exports));
|
|
92265
|
-
const { execSync: execSync8, spawn: spawn6 } = await import("child_process");
|
|
92266
|
-
const fsMod = await import("fs");
|
|
92267
|
-
const pathMod = await import("path");
|
|
92268
|
-
console.log(source_default.bold("\n \u{1F504} ADHDev Upgrade\n"));
|
|
92269
|
-
const adhdevPath = process.argv[1];
|
|
92270
|
-
const realPath = fsMod.realpathSync(adhdevPath);
|
|
92271
|
-
const isLinked = realPath.includes(".openclaw") || realPath.includes("/src/");
|
|
92272
|
-
const currentVersion = pkgVersion3;
|
|
92273
|
-
console.log(` ${source_default.bold("Current:")} v${currentVersion}`);
|
|
92274
|
-
console.log(` ${source_default.bold("Install:")} ${isLinked ? "npm link (dev)" : "npm global"}`);
|
|
92275
|
-
if (isLinked) {
|
|
92276
|
-
const projectRoot = pathMod.resolve(pathMod.dirname(realPath), "..");
|
|
92277
|
-
const launcherDir = pathMod.join(projectRoot);
|
|
92278
|
-
console.log(` ${source_default.bold("Path:")} ${launcherDir}`);
|
|
92279
|
-
console.log(source_default.cyan("\n Pulling latest..."));
|
|
92280
|
-
try {
|
|
92281
|
-
let gitRoot = launcherDir;
|
|
92282
|
-
while (!fsMod.existsSync(pathMod.join(gitRoot, ".git")) && gitRoot !== "/") {
|
|
92283
|
-
gitRoot = pathMod.dirname(gitRoot);
|
|
92284
|
-
}
|
|
92285
|
-
execSync8("git pull --rebase", { cwd: gitRoot, stdio: "inherit" });
|
|
92286
|
-
console.log(source_default.cyan("\n Building..."));
|
|
92287
|
-
execSync8("npm run build", { cwd: launcherDir, stdio: "inherit" });
|
|
92288
|
-
execSync8("npm link", { cwd: launcherDir, stdio: "inherit" });
|
|
92289
|
-
console.log(source_default.green("\n \u2713 Build complete"));
|
|
92290
|
-
} catch (e) {
|
|
92291
|
-
console.log(source_default.red(`
|
|
92292
|
-
\u2717 Build failed: ${e?.message}
|
|
92293
|
-
`));
|
|
92294
|
-
process.exit(1);
|
|
92295
|
-
}
|
|
92296
|
-
} else {
|
|
92297
|
-
console.log(source_default.cyan("\n Checking for updates..."));
|
|
92298
|
-
let latest;
|
|
92299
|
-
try {
|
|
92300
|
-
latest = execSync8("npm view adhdev version", { encoding: "utf-8" }).trim();
|
|
92301
|
-
} catch (e) {
|
|
92302
|
-
console.log(source_default.red(`
|
|
92303
|
-
\u2717 Failed to check latest version: ${e?.message}
|
|
92304
|
-
`));
|
|
92305
|
-
process.exit(1);
|
|
92306
|
-
return;
|
|
92307
|
-
}
|
|
92308
|
-
console.log(` ${source_default.bold("Latest:")} v${latest}`);
|
|
92309
|
-
if (latest === currentVersion) {
|
|
92310
|
-
console.log(source_default.green("\n \u2713 Already on latest version.\n"));
|
|
92311
|
-
if (!options.restart) return;
|
|
92312
|
-
} else {
|
|
92313
|
-
console.log(source_default.cyan(`
|
|
92314
|
-
Upgrading v${currentVersion} \u2192 v${latest}...`));
|
|
92315
|
-
const daemonWasRunning = options.restart !== false && isDaemonRunning2();
|
|
92316
|
-
if (daemonWasRunning) {
|
|
92317
|
-
stopDaemon2();
|
|
92318
|
-
await new Promise((r) => setTimeout(r, 1e3));
|
|
92319
|
-
stopManagedSessionHostProcess2();
|
|
92320
|
-
}
|
|
92321
|
-
const { spawnDetachedDaemonUpgradeHelper: spawnDetachedDaemonUpgradeHelper2 } = await Promise.resolve().then(() => (init_src(), src_exports));
|
|
92322
|
-
spawnDetachedDaemonUpgradeHelper2({
|
|
92323
|
-
packageName: "adhdev",
|
|
92324
|
-
targetVersion: latest,
|
|
92325
|
-
parentPid: process.pid,
|
|
92326
|
-
restartArgv: daemonWasRunning ? [process.argv[1], "daemon", "-p", DEFAULT_DAEMON_PORT_TEXT] : [],
|
|
92327
|
-
cwd: process.cwd()
|
|
92328
|
-
});
|
|
92329
|
-
if (daemonWasRunning) {
|
|
92330
|
-
console.log(source_default.cyan(" Upgrading and restarting daemon in background..."));
|
|
92331
|
-
} else {
|
|
92332
|
-
console.log(source_default.cyan(" Upgrading in background..."));
|
|
92333
|
-
console.log(source_default.gray(" Start daemon when ready: adhdev daemon"));
|
|
92334
|
-
}
|
|
92335
|
-
console.log(source_default.gray(` Progress: ~/.adhdev/daemon-upgrade.log
|
|
92336
|
-
`));
|
|
92337
|
-
process.exit(0);
|
|
92338
|
-
return;
|
|
92339
|
-
}
|
|
92340
|
-
}
|
|
92341
|
-
if (options.restart !== false && isDaemonRunning2()) {
|
|
92342
|
-
console.log(source_default.yellow("\n Restarting daemon..."));
|
|
92343
|
-
stopDaemon2();
|
|
92344
|
-
await new Promise((r) => setTimeout(r, 2e3));
|
|
92345
|
-
stopManagedSessionHostProcess2();
|
|
92346
|
-
await new Promise((r) => setTimeout(r, 500));
|
|
92347
|
-
const child = spawn6(process.execPath, [process.argv[1], "daemon", "-p", DEFAULT_DAEMON_PORT_TEXT], {
|
|
92348
|
-
detached: true,
|
|
92349
|
-
stdio: "ignore",
|
|
92350
|
-
windowsHide: true,
|
|
92351
|
-
env: { ...process.env }
|
|
92352
|
-
});
|
|
92353
|
-
child.unref();
|
|
92354
|
-
await new Promise((r) => setTimeout(r, 3e3));
|
|
92355
|
-
if (isDaemonRunning2()) {
|
|
92356
|
-
console.log(source_default.green(` \u2713 Daemon restarted with new version
|
|
92357
|
-
`));
|
|
92358
|
-
} else {
|
|
92359
|
-
console.log(source_default.yellow(` \u26A0 Daemon not detected. Start manually: adhdev daemon
|
|
92360
|
-
`));
|
|
92361
|
-
}
|
|
92362
|
-
} else if (options.restart !== false) {
|
|
92363
|
-
console.log(source_default.gray("\n Daemon was not running. Start with: adhdev daemon\n"));
|
|
92364
|
-
} else {
|
|
92365
|
-
console.log(source_default.green("\n \u2713 Upgrade complete (daemon not restarted)\n"));
|
|
92366
|
-
}
|
|
92678
|
+
await runDaemonUpgrade(options, pkgVersion3);
|
|
92367
92679
|
}));
|
|
92368
92680
|
program2.command("update").description("\u{1F504} Update ADHDev to latest version and restart daemon (alias for daemon:upgrade)").option("--no-restart", "Upgrade only, skip daemon restart").action(async (options) => {
|
|
92369
|
-
|
|
92370
|
-
await program2.parseAsync(process.argv);
|
|
92681
|
+
await runDaemonUpgrade(options, pkgVersion3);
|
|
92371
92682
|
});
|
|
92372
92683
|
}
|
|
92373
92684
|
|
|
92374
92685
|
// src/cli/doctor-commands.ts
|
|
92375
92686
|
init_source();
|
|
92376
|
-
var
|
|
92687
|
+
var import_child_process15 = require("child_process");
|
|
92377
92688
|
var fs26 = __toESM(require("fs"));
|
|
92378
92689
|
var os30 = __toESM(require("os"));
|
|
92379
|
-
var
|
|
92690
|
+
var path34 = __toESM(require("path"));
|
|
92380
92691
|
init_src();
|
|
92381
92692
|
init_session_host();
|
|
92382
92693
|
|
|
@@ -92493,26 +92804,26 @@ function buildDoctorAdvice(input) {
|
|
|
92493
92804
|
|
|
92494
92805
|
// src/cli/service-commands.ts
|
|
92495
92806
|
var import_node_fs6 = __toESM(require("fs"));
|
|
92496
|
-
var
|
|
92807
|
+
var import_node_path5 = __toESM(require("path"));
|
|
92497
92808
|
var import_node_os6 = __toESM(require("os"));
|
|
92498
92809
|
var import_node_child_process6 = require("child_process");
|
|
92499
92810
|
init_source();
|
|
92500
92811
|
init_src();
|
|
92501
92812
|
var DEFAULT_LOCAL_DAEMON_HEALTH_TIMEOUT_MS3 = 1500;
|
|
92502
92813
|
var LAUNCHD_LABEL = "dev.adhf.daemon";
|
|
92503
|
-
var ADHDEV_DIR =
|
|
92504
|
-
var LOG_OUT =
|
|
92505
|
-
var LOG_ERR =
|
|
92814
|
+
var ADHDEV_DIR = import_node_path5.default.join(import_node_os6.default.homedir(), ".adhdev");
|
|
92815
|
+
var LOG_OUT = import_node_path5.default.join(ADHDEV_DIR, "daemon-launchd.out");
|
|
92816
|
+
var LOG_ERR = import_node_path5.default.join(ADHDEV_DIR, "daemon-launchd.err");
|
|
92506
92817
|
var MAX_LOG_SIZE2 = 10 * 1024 * 1024;
|
|
92507
92818
|
function getDarwinPlistPath() {
|
|
92508
|
-
return
|
|
92819
|
+
return import_node_path5.default.join(import_node_os6.default.homedir(), "Library", "LaunchAgents", `${LAUNCHD_LABEL}.plist`);
|
|
92509
92820
|
}
|
|
92510
92821
|
function getWindowsStartupDir() {
|
|
92511
|
-
const appData = process.env.APPDATA ||
|
|
92512
|
-
return
|
|
92822
|
+
const appData = process.env.APPDATA || import_node_path5.default.join(import_node_os6.default.homedir(), "AppData", "Roaming");
|
|
92823
|
+
return import_node_path5.default.join(appData, "Microsoft", "Windows", "Start Menu", "Programs", "Startup");
|
|
92513
92824
|
}
|
|
92514
92825
|
function getWindowsVbsPath() {
|
|
92515
|
-
return
|
|
92826
|
+
return import_node_path5.default.join(getWindowsStartupDir(), "adhdev-daemon.vbs");
|
|
92516
92827
|
}
|
|
92517
92828
|
function resolveCliPath() {
|
|
92518
92829
|
return import_node_fs6.default.realpathSync(process.argv[1]);
|
|
@@ -92578,7 +92889,7 @@ function rotateLogs() {
|
|
|
92578
92889
|
}
|
|
92579
92890
|
function buildPlist(nodeExe, cliExe) {
|
|
92580
92891
|
const brewPrefix = import_node_fs6.default.existsSync("/opt/homebrew/bin") ? "/opt/homebrew/bin" : "/usr/local/bin";
|
|
92581
|
-
const nodeDir =
|
|
92892
|
+
const nodeDir = import_node_path5.default.dirname(nodeExe);
|
|
92582
92893
|
const pathEntries = /* @__PURE__ */ new Set([nodeDir, brewPrefix, "/usr/local/bin", "/usr/bin", "/bin", "/usr/sbin", "/sbin"]);
|
|
92583
92894
|
const pathValue = Array.from(pathEntries).join(":");
|
|
92584
92895
|
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
@@ -92617,7 +92928,7 @@ function buildPlist(nodeExe, cliExe) {
|
|
|
92617
92928
|
function installDarwin(nodeExe, cliExe) {
|
|
92618
92929
|
const plistPath = getDarwinPlistPath();
|
|
92619
92930
|
ensureDir(ADHDEV_DIR);
|
|
92620
|
-
ensureDir(
|
|
92931
|
+
ensureDir(import_node_path5.default.dirname(plistPath));
|
|
92621
92932
|
import_node_fs6.default.writeFileSync(plistPath, buildPlist(nodeExe, cliExe), "utf-8");
|
|
92622
92933
|
console.log(source_default.gray(` Plist: ${plistPath}`));
|
|
92623
92934
|
try {
|
|
@@ -92650,7 +92961,7 @@ function isInstalledDarwin() {
|
|
|
92650
92961
|
return import_node_fs6.default.existsSync(getDarwinPlistPath());
|
|
92651
92962
|
}
|
|
92652
92963
|
function buildVbs(nodeExe, cliExe) {
|
|
92653
|
-
const logFile =
|
|
92964
|
+
const logFile = import_node_path5.default.join(ADHDEV_DIR, "daemon-service.log").replace(/\\/g, "\\\\");
|
|
92654
92965
|
const escapedNodeExe = nodeExe.replace(/\\/g, "\\\\");
|
|
92655
92966
|
const escapedCliExe = cliExe.replace(/\\/g, "\\\\");
|
|
92656
92967
|
return `' ADHDev Daemon Auto-Start (generated by adhdev service install)
|
|
@@ -92661,11 +92972,11 @@ WshShell.Run "cmd.exe /c """"${escapedNodeExe}"""" """"${escapedCliExe}"""" daem
|
|
|
92661
92972
|
function installWindows(nodeExe, cliExe) {
|
|
92662
92973
|
const vbsPath = getWindowsVbsPath();
|
|
92663
92974
|
ensureDir(ADHDEV_DIR);
|
|
92664
|
-
ensureDir(
|
|
92975
|
+
ensureDir(import_node_path5.default.dirname(vbsPath));
|
|
92665
92976
|
import_node_fs6.default.writeFileSync(vbsPath, buildVbs(nodeExe, cliExe), "utf-8");
|
|
92666
92977
|
console.log(source_default.gray(` Startup script: ${vbsPath}`));
|
|
92667
92978
|
console.log(source_default.green("\n \u2713 Registered in Startup folder \u2014 daemon will start on login (hidden)."));
|
|
92668
|
-
console.log(source_default.gray(` Logs: ${
|
|
92979
|
+
console.log(source_default.gray(` Logs: ${import_node_path5.default.join(ADHDEV_DIR, "daemon-service.log")}`));
|
|
92669
92980
|
console.log(source_default.gray(" To start now without rebooting, run: adhdev daemon"));
|
|
92670
92981
|
}
|
|
92671
92982
|
function uninstallWindows() {
|
|
@@ -92859,11 +93170,11 @@ function formatBytes(bytes) {
|
|
|
92859
93170
|
|
|
92860
93171
|
// src/cli/doctor-commands.ts
|
|
92861
93172
|
function resolvePackageRoot() {
|
|
92862
|
-
return
|
|
93173
|
+
return path34.resolve(__dirname, "..", "..");
|
|
92863
93174
|
}
|
|
92864
93175
|
function isLinkedInstall(packageRoot) {
|
|
92865
|
-
const normalized =
|
|
92866
|
-
return !normalized.includes(`${
|
|
93176
|
+
const normalized = path34.normalize(packageRoot);
|
|
93177
|
+
return !normalized.includes(`${path34.sep}node_modules${path34.sep}adhdev`);
|
|
92867
93178
|
}
|
|
92868
93179
|
function formatCheck(check2) {
|
|
92869
93180
|
const icon = check2.ok ? source_default.green("\u2713") : source_default.red("\u2717");
|
|
@@ -92947,8 +93258,8 @@ function probeSharpRuntime(packageRoot, nativeSharpPackage) {
|
|
|
92947
93258
|
}
|
|
92948
93259
|
}
|
|
92949
93260
|
function probeConfigAccess() {
|
|
92950
|
-
const configDir =
|
|
92951
|
-
const configPath =
|
|
93261
|
+
const configDir = path34.join(os30.homedir(), ".adhdev");
|
|
93262
|
+
const configPath = path34.join(configDir, "config.json");
|
|
92952
93263
|
const checks = [];
|
|
92953
93264
|
try {
|
|
92954
93265
|
fs26.mkdirSync(configDir, { recursive: true });
|
|
@@ -92988,7 +93299,7 @@ function probeConfigAccess() {
|
|
|
92988
93299
|
fatal: true
|
|
92989
93300
|
});
|
|
92990
93301
|
}
|
|
92991
|
-
const probePath =
|
|
93302
|
+
const probePath = path34.join(configDir, `.doctor-write-${process.pid}-${Date.now()}.tmp`);
|
|
92992
93303
|
try {
|
|
92993
93304
|
fs26.writeFileSync(probePath, "ok", "utf-8");
|
|
92994
93305
|
fs26.rmSync(probePath, { force: true });
|
|
@@ -93015,7 +93326,7 @@ function findCommandPaths(command) {
|
|
|
93015
93326
|
try {
|
|
93016
93327
|
const bin = process.platform === "win32" ? "where.exe" : "which";
|
|
93017
93328
|
const args = process.platform === "win32" ? [command] : ["-a", command];
|
|
93018
|
-
const output = (0,
|
|
93329
|
+
const output = (0, import_child_process15.execFileSync)(bin, args, {
|
|
93019
93330
|
encoding: "utf-8",
|
|
93020
93331
|
stdio: ["ignore", "pipe", "ignore"]
|
|
93021
93332
|
});
|
|
@@ -93030,7 +93341,7 @@ function probeCliBinary(commandPath, currentVersion) {
|
|
|
93030
93341
|
currentVersion
|
|
93031
93342
|
};
|
|
93032
93343
|
try {
|
|
93033
|
-
probe.version = (0,
|
|
93344
|
+
probe.version = (0, import_child_process15.execFileSync)(commandPath, ["--version"], {
|
|
93034
93345
|
encoding: "utf-8",
|
|
93035
93346
|
stdio: ["ignore", "pipe", "pipe"]
|
|
93036
93347
|
}).trim();
|
|
@@ -93038,7 +93349,7 @@ function probeCliBinary(commandPath, currentVersion) {
|
|
|
93038
93349
|
probe.versionError = error48?.stderr?.toString?.().trim() || error48?.message || "version probe failed";
|
|
93039
93350
|
}
|
|
93040
93351
|
try {
|
|
93041
|
-
probe.helpText = (0,
|
|
93352
|
+
probe.helpText = (0, import_child_process15.execFileSync)(commandPath, ["--help"], {
|
|
93042
93353
|
encoding: "utf-8",
|
|
93043
93354
|
stdio: ["ignore", "pipe", "pipe"]
|
|
93044
93355
|
});
|
|
@@ -93177,7 +93488,7 @@ function registerDoctorCommands(program2, pkgVersion3) {
|
|
|
93177
93488
|
});
|
|
93178
93489
|
}
|
|
93179
93490
|
if (process.platform === "darwin") {
|
|
93180
|
-
serviceDefinitionPath =
|
|
93491
|
+
serviceDefinitionPath = path34.join(os30.homedir(), "Library", "LaunchAgents", "dev.adhf.daemon.plist");
|
|
93181
93492
|
if (fs26.existsSync(serviceDefinitionPath)) {
|
|
93182
93493
|
serviceDefinitionCheck = evaluateServiceDefinitionDrift({
|
|
93183
93494
|
serviceKind: "launchd",
|
|
@@ -93225,7 +93536,7 @@ function registerDoctorCommands(program2, pkgVersion3) {
|
|
|
93225
93536
|
} catch {
|
|
93226
93537
|
}
|
|
93227
93538
|
try {
|
|
93228
|
-
const providerLoader = await
|
|
93539
|
+
const providerLoader = await getSharedCliProviderLoader();
|
|
93229
93540
|
const cliResults = await detectCLIs(providerLoader);
|
|
93230
93541
|
for (const cli of cliResults) {
|
|
93231
93542
|
checks.push({
|
|
@@ -93250,7 +93561,7 @@ function registerDoctorCommands(program2, pkgVersion3) {
|
|
|
93250
93561
|
serviceCheck: serviceDefinitionCheck || void 0,
|
|
93251
93562
|
sourceCliExample: "node --import tsx packages/daemon-cloud/src/cli/index.ts doctor"
|
|
93252
93563
|
});
|
|
93253
|
-
const sessionHostLogPath =
|
|
93564
|
+
const sessionHostLogPath = path34.join(os30.homedir(), ".adhdev", "logs", "session-host.log");
|
|
93254
93565
|
console.log(source_default.bold("\n\u{1FA7A} ADHDev Doctor\n"));
|
|
93255
93566
|
console.log(source_default.gray(` Version: ${pkgVersion3}`));
|
|
93256
93567
|
console.log(source_default.gray(` Platform: ${process.platform} ${process.arch}`));
|
|
@@ -93292,7 +93603,7 @@ function registerDoctorCommands(program2, pkgVersion3) {
|
|
|
93292
93603
|
|
|
93293
93604
|
// src/cli/provider-commands.ts
|
|
93294
93605
|
init_source();
|
|
93295
|
-
var
|
|
93606
|
+
var path35 = __toESM(require("path"));
|
|
93296
93607
|
init_cdp_utils();
|
|
93297
93608
|
var DEV_SERVER_PORT3 = 19280;
|
|
93298
93609
|
var IDE_AUTO_FIX_FUNCTIONS = [
|
|
@@ -93363,7 +93674,7 @@ function getCliAutoFixVerification(provider, providerDir) {
|
|
|
93363
93674
|
};
|
|
93364
93675
|
}
|
|
93365
93676
|
function hideCommand2(command) {
|
|
93366
|
-
command.
|
|
93677
|
+
command._hidden = true;
|
|
93367
93678
|
return command;
|
|
93368
93679
|
}
|
|
93369
93680
|
async function createConfiguredProviderLoader2() {
|
|
@@ -93375,7 +93686,7 @@ function getProviderSourceCandidatePaths(options) {
|
|
|
93375
93686
|
const results = [];
|
|
93376
93687
|
for (const root of roots) {
|
|
93377
93688
|
for (const name of relativeNames) {
|
|
93378
|
-
results.push(
|
|
93689
|
+
results.push(path35.join(root, options.category, options.type, name));
|
|
93379
93690
|
}
|
|
93380
93691
|
}
|
|
93381
93692
|
return results;
|
|
@@ -93511,7 +93822,7 @@ function registerProviderCommands(program2) {
|
|
|
93511
93822
|
let processNames = {};
|
|
93512
93823
|
if (category === "ide") {
|
|
93513
93824
|
const fs27 = await import("fs");
|
|
93514
|
-
const
|
|
93825
|
+
const path36 = await import("path");
|
|
93515
93826
|
const os31 = await import("os");
|
|
93516
93827
|
if (os31.platform() === "darwin") {
|
|
93517
93828
|
while (true) {
|
|
@@ -93524,7 +93835,7 @@ function registerProviderCommands(program2) {
|
|
|
93524
93835
|
}
|
|
93525
93836
|
console.log(source_default.green(` \u2713 Path verified: ${p}`));
|
|
93526
93837
|
osPaths["darwin"] = [p];
|
|
93527
|
-
processNames["darwin"] =
|
|
93838
|
+
processNames["darwin"] = path36.basename(p, ".app");
|
|
93528
93839
|
break;
|
|
93529
93840
|
}
|
|
93530
93841
|
} else if (os31.platform() === "win32") {
|
|
@@ -93538,7 +93849,7 @@ function registerProviderCommands(program2) {
|
|
|
93538
93849
|
}
|
|
93539
93850
|
console.log(source_default.green(` \u2713 Path verified: ${p}`));
|
|
93540
93851
|
osPaths["win32"] = [p];
|
|
93541
|
-
processNames["win32"] =
|
|
93852
|
+
processNames["win32"] = path36.basename(p, ".exe");
|
|
93542
93853
|
break;
|
|
93543
93854
|
}
|
|
93544
93855
|
}
|
|
@@ -94360,18 +94671,9 @@ if (process.platform === "win32") {
|
|
|
94360
94671
|
process.exit(1);
|
|
94361
94672
|
}
|
|
94362
94673
|
}
|
|
94363
|
-
var cliConfig = loadConfig();
|
|
94364
|
-
var _cliProviderLoader = new ProviderLoader({
|
|
94365
|
-
logFn: () => {
|
|
94366
|
-
},
|
|
94367
|
-
userDir: cliConfig.providerDir,
|
|
94368
|
-
sourceMode: cliConfig.providerSourceMode
|
|
94369
|
-
});
|
|
94370
|
-
_cliProviderLoader.loadAll();
|
|
94371
|
-
_cliProviderLoader.registerToDetector();
|
|
94372
94674
|
var program = new import_commander.Command();
|
|
94373
94675
|
program.name("adhdev").description("\u{1F9A6} ADHDev \u2014 Agent Dashboard Hub for Dev").version(pkgVersion2);
|
|
94374
|
-
registerSetupCommands(program,
|
|
94676
|
+
registerSetupCommands(program, getSharedCliProviderLoader);
|
|
94375
94677
|
registerDaemonCommands(program, pkgVersion2);
|
|
94376
94678
|
registerDoctorCommands(program, pkgVersion2);
|
|
94377
94679
|
registerProviderCommands(program);
|