adhdev 0.5.61 → 0.5.63
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 +94 -67
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +94 -67
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -18555,29 +18555,18 @@ var require_dist = __commonJS({
|
|
|
18555
18555
|
return this.instanceId;
|
|
18556
18556
|
}
|
|
18557
18557
|
// ─── status transition detect ──────────────────────────────
|
|
18558
|
-
|
|
18558
|
+
// NOTE: Extension transitions are TRACKED but NOT emitted as events.
|
|
18559
|
+
// The parent IdeProviderInstance already emits identical events
|
|
18560
|
+
// (generating_started, generating_completed, waiting_approval)
|
|
18561
|
+
// via its own detectAgentTransitions(). Emitting here would cause
|
|
18562
|
+
// duplicate toasts with slightly different content.
|
|
18563
|
+
detectTransition(newStatus, _data) {
|
|
18559
18564
|
const now = Date.now();
|
|
18560
18565
|
const agentStatus = newStatus === "streaming" || newStatus === "generating" ? "generating" : newStatus === "waiting_approval" ? "waiting_approval" : "idle";
|
|
18561
18566
|
if (agentStatus !== this.lastAgentStatus) {
|
|
18562
|
-
const chatTitle = this.provider.name;
|
|
18563
18567
|
if (this.lastAgentStatus === "idle" && agentStatus === "generating") {
|
|
18564
18568
|
this.generatingStartedAt = now;
|
|
18565
|
-
this.pushEvent({ event: "agent:generating_started", chatTitle, timestamp: now });
|
|
18566
|
-
} else if (agentStatus === "waiting_approval") {
|
|
18567
|
-
if (!this.generatingStartedAt) this.generatingStartedAt = now;
|
|
18568
|
-
const msg = data?.activeModal?.message || data?.modalMessage;
|
|
18569
|
-
this.pushEvent({
|
|
18570
|
-
event: "agent:waiting_approval",
|
|
18571
|
-
chatTitle,
|
|
18572
|
-
timestamp: now,
|
|
18573
|
-
ideType: this.ideType,
|
|
18574
|
-
agentType: this.type,
|
|
18575
|
-
modalMessage: msg,
|
|
18576
|
-
modalButtons: data?.activeModal?.buttons || data?.modalButtons
|
|
18577
|
-
});
|
|
18578
18569
|
} else if (agentStatus === "idle" && (this.lastAgentStatus === "generating" || this.lastAgentStatus === "waiting_approval")) {
|
|
18579
|
-
const duration3 = this.generatingStartedAt ? Math.round((now - this.generatingStartedAt) / 1e3) : 0;
|
|
18580
|
-
this.pushEvent({ event: "agent:generating_completed", chatTitle, duration: duration3, timestamp: now });
|
|
18581
18570
|
this.generatingStartedAt = 0;
|
|
18582
18571
|
}
|
|
18583
18572
|
this.lastAgentStatus = agentStatus;
|
|
@@ -23316,7 +23305,8 @@ var require_dist = __commonJS({
|
|
|
23316
23305
|
generatingIdle: t.generatingIdle ?? 6e3,
|
|
23317
23306
|
idleFinish: t.idleFinish ?? 5e3,
|
|
23318
23307
|
maxResponse: t.maxResponse ?? 3e5,
|
|
23319
|
-
shutdownGrace: t.shutdownGrace ?? 1e3
|
|
23308
|
+
shutdownGrace: t.shutdownGrace ?? 1e3,
|
|
23309
|
+
outputSettle: t.outputSettle ?? 300
|
|
23320
23310
|
};
|
|
23321
23311
|
const rawKeys = provider.approvalKeys;
|
|
23322
23312
|
this.approvalKeys = rawKeys && typeof rawKeys === "object" ? rawKeys : {};
|
|
@@ -23349,6 +23339,10 @@ var require_dist = __commonJS({
|
|
|
23349
23339
|
// Approval state machine
|
|
23350
23340
|
approvalTransitionBuffer = "";
|
|
23351
23341
|
approvalExitTimeout = null;
|
|
23342
|
+
// Output settle debounce — fires after PTY output goes quiet
|
|
23343
|
+
settleTimer = null;
|
|
23344
|
+
settledBuffer = "";
|
|
23345
|
+
// snapshot of recentOutputBuffer at settle time
|
|
23352
23346
|
// Resize redraw suppression
|
|
23353
23347
|
resizeSuppressUntil = 0;
|
|
23354
23348
|
// Debug: status transition history
|
|
@@ -23490,39 +23484,57 @@ var require_dist = __commonJS({
|
|
|
23490
23484
|
if (cleanData.trim().length > 5) {
|
|
23491
23485
|
LOG5.debug("CLI", `[${this.cliType}] output chunk (${cleanData.length}): ${cleanData.slice(0, 300).replace(/\n/g, "\\n")}`);
|
|
23492
23486
|
}
|
|
23493
|
-
|
|
23494
|
-
|
|
23495
|
-
|
|
23496
|
-
|
|
23497
|
-
|
|
23487
|
+
if (!this.isWaitingForResponse) {
|
|
23488
|
+
if (patterns.generating.some((p) => p.test(cleanData))) {
|
|
23489
|
+
if (this.settleTimer) {
|
|
23490
|
+
clearTimeout(this.settleTimer);
|
|
23491
|
+
this.settleTimer = null;
|
|
23492
|
+
}
|
|
23498
23493
|
this.isWaitingForResponse = true;
|
|
23499
|
-
this.
|
|
23500
|
-
this.
|
|
23501
|
-
this.
|
|
23502
|
-
|
|
23503
|
-
|
|
23504
|
-
|
|
23505
|
-
|
|
23506
|
-
|
|
23507
|
-
|
|
23508
|
-
this.
|
|
23509
|
-
|
|
23510
|
-
|
|
23511
|
-
|
|
23512
|
-
this.lastApprovalResolvedAt = Date.now();
|
|
23513
|
-
this.recentOutputBuffer = "";
|
|
23514
|
-
this.approvalTransitionBuffer = "";
|
|
23515
|
-
this.approvalExitTimeout = null;
|
|
23516
|
-
this.setStatus(this.isWaitingForResponse ? "generating" : "idle", "approval_cleared");
|
|
23517
|
-
this.onStatusChange?.();
|
|
23518
|
-
}
|
|
23519
|
-
}, 6e4);
|
|
23494
|
+
this.responseBuffer = "";
|
|
23495
|
+
this.setStatus("generating", "autonomous_gen");
|
|
23496
|
+
this.onStatusChange?.();
|
|
23497
|
+
}
|
|
23498
|
+
}
|
|
23499
|
+
if (this.isWaitingForResponse) {
|
|
23500
|
+
this.responseBuffer += cleanData;
|
|
23501
|
+
if (this.idleTimeout) clearTimeout(this.idleTimeout);
|
|
23502
|
+
if (patterns.generating.some((p) => p.test(cleanData))) {
|
|
23503
|
+
this.setStatus("generating", "still_generating");
|
|
23504
|
+
this.idleTimeout = setTimeout(() => {
|
|
23505
|
+
if (this.isWaitingForResponse) this.finishResponse();
|
|
23506
|
+
}, this.timeouts.generatingIdle);
|
|
23520
23507
|
this.onStatusChange?.();
|
|
23508
|
+
if (this.settleTimer) {
|
|
23509
|
+
clearTimeout(this.settleTimer);
|
|
23510
|
+
this.settleTimer = null;
|
|
23511
|
+
}
|
|
23521
23512
|
return;
|
|
23522
23513
|
}
|
|
23523
23514
|
}
|
|
23524
23515
|
if (this.currentStatus === "waiting_approval") {
|
|
23525
23516
|
this.approvalTransitionBuffer = (this.approvalTransitionBuffer + cleanData).slice(-500);
|
|
23517
|
+
this.scheduleSettle();
|
|
23518
|
+
return;
|
|
23519
|
+
}
|
|
23520
|
+
this.scheduleSettle();
|
|
23521
|
+
}
|
|
23522
|
+
/**
|
|
23523
|
+
* Fired after output goes quiet for outputSettle ms.
|
|
23524
|
+
* Evaluates the stabilised buffer for approval, prompt (idle), or timeout.
|
|
23525
|
+
*/
|
|
23526
|
+
scheduleSettle() {
|
|
23527
|
+
if (this.settleTimer) clearTimeout(this.settleTimer);
|
|
23528
|
+
this.settleTimer = setTimeout(() => {
|
|
23529
|
+
this.settleTimer = null;
|
|
23530
|
+
this.settledBuffer = this.recentOutputBuffer;
|
|
23531
|
+
this.evaluateSettled();
|
|
23532
|
+
}, this.timeouts.outputSettle);
|
|
23533
|
+
}
|
|
23534
|
+
evaluateSettled() {
|
|
23535
|
+
const { patterns } = this.provider;
|
|
23536
|
+
const buf = this.settledBuffer;
|
|
23537
|
+
if (this.currentStatus === "waiting_approval") {
|
|
23526
23538
|
const genResume = patterns.generating.some((p) => p.test(this.approvalTransitionBuffer));
|
|
23527
23539
|
const promptResume = patterns.prompt.some((p) => p.test(this.approvalTransitionBuffer));
|
|
23528
23540
|
if (genResume) {
|
|
@@ -23549,33 +23561,43 @@ var require_dist = __commonJS({
|
|
|
23549
23561
|
}
|
|
23550
23562
|
return;
|
|
23551
23563
|
}
|
|
23552
|
-
|
|
23553
|
-
|
|
23564
|
+
const hasApproval = patterns.approval.some((p) => p.test(buf));
|
|
23565
|
+
if (hasApproval) {
|
|
23566
|
+
const inCooldown = this.lastApprovalResolvedAt && Date.now() - this.lastApprovalResolvedAt < this.timeouts.approvalCooldown;
|
|
23567
|
+
if (!inCooldown) {
|
|
23568
|
+
const ctxLines = buf.split("\n").map((l) => l.trim()).filter((l) => l && !/^[─═╭╮╰╯│]+$/.test(l));
|
|
23554
23569
|
this.isWaitingForResponse = true;
|
|
23555
|
-
this.
|
|
23556
|
-
this.
|
|
23570
|
+
this.setStatus("waiting_approval", "approval_pattern");
|
|
23571
|
+
this.recentOutputBuffer = "";
|
|
23572
|
+
this.approvalTransitionBuffer = "";
|
|
23573
|
+
this.activeModal = {
|
|
23574
|
+
message: ctxLines.slice(-5).join(" ").slice(0, 200) || "Approval required",
|
|
23575
|
+
buttons: this.cliType === "claude-cli" ? ["Yes (y)", "Always allow (a)", "Deny (Esc)"] : ["Allow once", "Always allow", "Deny"]
|
|
23576
|
+
};
|
|
23577
|
+
if (this.idleTimeout) clearTimeout(this.idleTimeout);
|
|
23578
|
+
if (this.approvalExitTimeout) clearTimeout(this.approvalExitTimeout);
|
|
23579
|
+
this.approvalExitTimeout = setTimeout(() => {
|
|
23580
|
+
if (this.currentStatus === "waiting_approval") {
|
|
23581
|
+
LOG5.warn("CLI", `[${this.cliType}] Approval timeout \u2014 auto-exiting waiting_approval`);
|
|
23582
|
+
this.activeModal = null;
|
|
23583
|
+
this.lastApprovalResolvedAt = Date.now();
|
|
23584
|
+
this.recentOutputBuffer = "";
|
|
23585
|
+
this.approvalTransitionBuffer = "";
|
|
23586
|
+
this.approvalExitTimeout = null;
|
|
23587
|
+
this.setStatus(this.isWaitingForResponse ? "generating" : "idle", "approval_cleared");
|
|
23588
|
+
this.onStatusChange?.();
|
|
23589
|
+
}
|
|
23590
|
+
}, 6e4);
|
|
23557
23591
|
this.onStatusChange?.();
|
|
23592
|
+
return;
|
|
23558
23593
|
}
|
|
23559
23594
|
}
|
|
23560
23595
|
if (this.isWaitingForResponse) {
|
|
23561
|
-
|
|
23562
|
-
if (
|
|
23563
|
-
|
|
23564
|
-
if (
|
|
23565
|
-
this.
|
|
23566
|
-
this.idleTimeout = setTimeout(() => {
|
|
23567
|
-
if (this.isWaitingForResponse) this.finishResponse();
|
|
23568
|
-
}, this.timeouts.generatingIdle);
|
|
23569
|
-
this.onStatusChange?.();
|
|
23570
|
-
return;
|
|
23571
|
-
}
|
|
23572
|
-
const trailingLines = cleanData.split("\n").slice(-2).join("\n");
|
|
23573
|
-
if (patterns.prompt.some((p) => p.test(trailingLines))) {
|
|
23574
|
-
const hasApprovalHere = patterns.approval.some((p) => p.test(this.recentOutputBuffer));
|
|
23575
|
-
if (!hasApprovalHere) {
|
|
23576
|
-
this.finishResponse();
|
|
23577
|
-
}
|
|
23578
|
-
} else {
|
|
23596
|
+
const trailingLines = buf.split("\n").slice(-3).join("\n");
|
|
23597
|
+
if (patterns.prompt.some((p) => p.test(trailingLines)) && !hasApproval) {
|
|
23598
|
+
this.finishResponse();
|
|
23599
|
+
} else if (!patterns.generating.some((p) => p.test(buf))) {
|
|
23600
|
+
if (this.idleTimeout) clearTimeout(this.idleTimeout);
|
|
23579
23601
|
this.idleTimeout = setTimeout(() => {
|
|
23580
23602
|
if (this.isWaitingForResponse && this.responseBuffer.trim()) {
|
|
23581
23603
|
this.finishResponse();
|
|
@@ -23647,6 +23669,10 @@ var require_dist = __commonJS({
|
|
|
23647
23669
|
this.shutdown();
|
|
23648
23670
|
}
|
|
23649
23671
|
shutdown() {
|
|
23672
|
+
if (this.settleTimer) {
|
|
23673
|
+
clearTimeout(this.settleTimer);
|
|
23674
|
+
this.settleTimer = null;
|
|
23675
|
+
}
|
|
23650
23676
|
if (this.approvalExitTimeout) {
|
|
23651
23677
|
clearTimeout(this.approvalExitTimeout);
|
|
23652
23678
|
this.approvalExitTimeout = null;
|
|
@@ -23718,6 +23744,7 @@ var require_dist = __commonJS({
|
|
|
23718
23744
|
// Buffers
|
|
23719
23745
|
startupBuffer: this.startupBuffer.slice(-500),
|
|
23720
23746
|
recentOutputBuffer: this.recentOutputBuffer.slice(-500),
|
|
23747
|
+
settledBuffer: this.settledBuffer.slice(-500),
|
|
23721
23748
|
responseBuffer: this.responseBuffer.slice(-500),
|
|
23722
23749
|
approvalTransitionBuffer: this.approvalTransitionBuffer.slice(-500),
|
|
23723
23750
|
// State
|
|
@@ -30497,7 +30524,7 @@ var init_adhdev_daemon = __esm({
|
|
|
30497
30524
|
fs2 = __toESM(require("fs"));
|
|
30498
30525
|
path2 = __toESM(require("path"));
|
|
30499
30526
|
import_chalk = __toESM(require("chalk"));
|
|
30500
|
-
pkgVersion = "0.5.
|
|
30527
|
+
pkgVersion = "0.5.63";
|
|
30501
30528
|
if (pkgVersion === "unknown") {
|
|
30502
30529
|
try {
|
|
30503
30530
|
const possiblePaths = [
|