@adhdev/daemon-core 0.9.82-rc.491 → 0.9.82-rc.493
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-adapters/cli-state-engine.d.ts +26 -0
- package/dist/cli-adapters/provider-cli-adapter.d.ts +2 -0
- package/dist/index.js +134 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +134 -7
- package/dist/index.mjs.map +1 -1
- package/dist/providers/cli-provider-instance.d.ts +35 -0
- package/dist/repo-mesh-types.d.ts +3 -2
- package/package.json +3 -3
- package/src/cli-adapters/cli-state-engine.ts +97 -0
- package/src/cli-adapters/provider-cli-adapter.ts +11 -0
- package/src/providers/cli-provider-instance.ts +95 -2
- package/src/repo-mesh-types.ts +3 -2
package/dist/index.mjs
CHANGED
|
@@ -409,10 +409,10 @@ function readInjected(value) {
|
|
|
409
409
|
}
|
|
410
410
|
function getDaemonBuildInfo() {
|
|
411
411
|
if (cached) return cached;
|
|
412
|
-
const commit = readInjected(true ? "
|
|
413
|
-
const commitShort = readInjected(true ? "
|
|
414
|
-
const version = readInjected(true ? "0.9.82-rc.
|
|
415
|
-
const builtAt = readInjected(true ? "2026-07-
|
|
412
|
+
const commit = readInjected(true ? "6c86137f6a459cb312b1d69ebf81fcbc78936c24" : void 0) ?? "unknown";
|
|
413
|
+
const commitShort = readInjected(true ? "6c86137f" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
|
|
414
|
+
const version = readInjected(true ? "0.9.82-rc.493" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
|
|
415
|
+
const builtAt = readInjected(true ? "2026-07-10T08:50:14.562Z" : void 0);
|
|
416
416
|
cached = builtAt ? { commit, commitShort, version, builtAt } : { commit, commitShort, version };
|
|
417
417
|
return cached;
|
|
418
418
|
}
|
|
@@ -24502,7 +24502,7 @@ var init_provider_cli_parse = __esm({
|
|
|
24502
24502
|
});
|
|
24503
24503
|
|
|
24504
24504
|
// src/cli-adapters/cli-state-engine.ts
|
|
24505
|
-
var SCRIPT_STATUS_DEBOUNCE_MS, MAX_FINISH_RETRIES, FINISH_RETRY_DELAY_MS, MAX_TRACE_ENTRIES, APPROVAL_EXIT_TIMEOUT_MS, IDLE_CONFIRMATION_GRACE_MS, CliStateEngine;
|
|
24505
|
+
var SCRIPT_STATUS_DEBOUNCE_MS, MAX_FINISH_RETRIES, FINISH_RETRY_DELAY_MS, MAX_TRACE_ENTRIES, APPROVAL_EXIT_TIMEOUT_MS, IDLE_CONFIRMATION_GRACE_MS, APPROVAL_RESUME_IDLE_DEFER_CAP_MS, CliStateEngine;
|
|
24506
24506
|
var init_cli_state_engine = __esm({
|
|
24507
24507
|
"src/cli-adapters/cli-state-engine.ts"() {
|
|
24508
24508
|
"use strict";
|
|
@@ -24515,6 +24515,7 @@ var init_cli_state_engine = __esm({
|
|
|
24515
24515
|
MAX_TRACE_ENTRIES = 250;
|
|
24516
24516
|
APPROVAL_EXIT_TIMEOUT_MS = 6e4;
|
|
24517
24517
|
IDLE_CONFIRMATION_GRACE_MS = 2e3;
|
|
24518
|
+
APPROVAL_RESUME_IDLE_DEFER_CAP_MS = 18e3;
|
|
24518
24519
|
CliStateEngine = class {
|
|
24519
24520
|
constructor(provider, runner, transport, callbacks, timeouts) {
|
|
24520
24521
|
this.provider = provider;
|
|
@@ -24604,6 +24605,12 @@ var init_cli_state_engine = __esm({
|
|
|
24604
24605
|
pendingScriptStatusTimer = null;
|
|
24605
24606
|
// ── Idle candidate ───────────────────────────────
|
|
24606
24607
|
idleFinishCandidate = null;
|
|
24608
|
+
// FALSE-IDLE (Fix 2): wall-clock when the current post-approval resume-grace idle
|
|
24609
|
+
// defer began, scoped to a responseEpoch. Zero when not deferring. Bounds the defer
|
|
24610
|
+
// to APPROVAL_RESUME_IDLE_DEFER_CAP_MS so a turn that genuinely ended right after an
|
|
24611
|
+
// approval eventually finishes. Reset whenever a new turn/response starts or completes.
|
|
24612
|
+
approvalResumeDeferSince = 0;
|
|
24613
|
+
approvalResumeDeferEpoch = -1;
|
|
24607
24614
|
// ── Idle confirmation grace ──────────────────────
|
|
24608
24615
|
/**
|
|
24609
24616
|
* `finishResponse` produces the `generating → idle` transition that
|
|
@@ -24817,6 +24824,8 @@ var init_cli_state_engine = __esm({
|
|
|
24817
24824
|
this.activeModal = null;
|
|
24818
24825
|
this.pendingScriptStatus = null;
|
|
24819
24826
|
this.pendingScriptStatusSince = 0;
|
|
24827
|
+
this.approvalResumeDeferSince = 0;
|
|
24828
|
+
this.approvalResumeDeferEpoch = -1;
|
|
24820
24829
|
}
|
|
24821
24830
|
clearIdleFinishCandidate(reason) {
|
|
24822
24831
|
if (!this.idleFinishCandidate) return;
|
|
@@ -25238,6 +25247,14 @@ var init_cli_state_engine = __esm({
|
|
|
25238
25247
|
const idleReady = !modal && hasAssistantTurn && quietForMs >= idleQuietThresholdMs && screenStableMs >= idleFinishConfirmMs;
|
|
25239
25248
|
const candidate = this.idleFinishCandidate;
|
|
25240
25249
|
const candidateQuiet = !!candidate && candidate.responseEpoch === this.responseEpoch && candidate.lastOutputAt === snap.lastOutputAt && candidate.lastScreenChangeAt === snap.lastScreenChangeAt && assistantLength >= candidate.assistantLength && now - candidate.armedAt >= idleFinishConfirmMs;
|
|
25250
|
+
if (this.shouldDeferIdleForApprovalResume(now)) {
|
|
25251
|
+
this.clearIdleFinishCandidate("approval_resume_grace_defer");
|
|
25252
|
+
if (this.idleTimeout) clearTimeout(this.idleTimeout);
|
|
25253
|
+
this.idleTimeout = setTimeout(() => {
|
|
25254
|
+
if (this.isWaitingForResponse) this.evaluateSettled(this.transport.getSnapshot());
|
|
25255
|
+
}, this.timeouts.idleFinish);
|
|
25256
|
+
return;
|
|
25257
|
+
}
|
|
25241
25258
|
if (idleReady && candidateQuiet) {
|
|
25242
25259
|
this.clearIdleFinishCandidate("finish_response");
|
|
25243
25260
|
if (this.idleTimeout) clearTimeout(this.idleTimeout);
|
|
@@ -25255,6 +25272,12 @@ var init_cli_state_engine = __esm({
|
|
|
25255
25272
|
if (this.idleTimeout) clearTimeout(this.idleTimeout);
|
|
25256
25273
|
this.idleTimeout = setTimeout(() => {
|
|
25257
25274
|
if (this.isWaitingForResponse && !this.hasActionableApproval()) {
|
|
25275
|
+
if (this.shouldDeferIdleForApprovalResume(Date.now())) {
|
|
25276
|
+
this.idleTimeout = setTimeout(() => {
|
|
25277
|
+
if (this.isWaitingForResponse) this.evaluateSettled(this.transport.getSnapshot());
|
|
25278
|
+
}, this.timeouts.idleFinish);
|
|
25279
|
+
return;
|
|
25280
|
+
}
|
|
25258
25281
|
if (this.shouldDeferIdleTimeoutFinish()) return;
|
|
25259
25282
|
const parsed = this.runParseSession(this.transport.getSnapshot());
|
|
25260
25283
|
if (this.shouldDeferFinishForTranscript(parsed)) {
|
|
@@ -25266,6 +25289,47 @@ var init_cli_state_engine = __esm({
|
|
|
25266
25289
|
}
|
|
25267
25290
|
}, this.timeouts.idleFinish);
|
|
25268
25291
|
}
|
|
25292
|
+
/**
|
|
25293
|
+
* FALSE-IDLE (Fix 2): should applyIdle suppress the idle/finish for the current
|
|
25294
|
+
* turn because we are inside the post-approval resume grace?
|
|
25295
|
+
*
|
|
25296
|
+
* True only when: (a) the owning instance reports it is an autonomous auto-approving
|
|
25297
|
+
* mesh session that resolved a modal within the resume-grace window
|
|
25298
|
+
* (isInApprovalResumeGrace callback — the SAME judgment Fix 1 uses), AND (b) the defer
|
|
25299
|
+
* for THIS response epoch has not yet exceeded APPROVAL_RESUME_IDLE_DEFER_CAP_MS.
|
|
25300
|
+
* The cap guarantees no infinite defer: a turn that genuinely ended right after an
|
|
25301
|
+
* approval and stays silent past the cap stops being suppressed and finishes normally.
|
|
25302
|
+
* The per-epoch anchor means a fresh turn/response restarts the clock.
|
|
25303
|
+
*/
|
|
25304
|
+
shouldDeferIdleForApprovalResume(now) {
|
|
25305
|
+
if (typeof this.callbacks.isInApprovalResumeGrace !== "function") {
|
|
25306
|
+
this.clearApprovalResumeDefer();
|
|
25307
|
+
return false;
|
|
25308
|
+
}
|
|
25309
|
+
let inGrace = false;
|
|
25310
|
+
try {
|
|
25311
|
+
inGrace = this.callbacks.isInApprovalResumeGrace() === true;
|
|
25312
|
+
} catch {
|
|
25313
|
+
inGrace = false;
|
|
25314
|
+
}
|
|
25315
|
+
if (!inGrace) {
|
|
25316
|
+
this.clearApprovalResumeDefer();
|
|
25317
|
+
return false;
|
|
25318
|
+
}
|
|
25319
|
+
if (this.approvalResumeDeferEpoch !== this.responseEpoch || this.approvalResumeDeferSince === 0) {
|
|
25320
|
+
this.approvalResumeDeferEpoch = this.responseEpoch;
|
|
25321
|
+
this.approvalResumeDeferSince = now;
|
|
25322
|
+
return true;
|
|
25323
|
+
}
|
|
25324
|
+
if (now - this.approvalResumeDeferSince >= APPROVAL_RESUME_IDLE_DEFER_CAP_MS) {
|
|
25325
|
+
return false;
|
|
25326
|
+
}
|
|
25327
|
+
return true;
|
|
25328
|
+
}
|
|
25329
|
+
clearApprovalResumeDefer() {
|
|
25330
|
+
this.approvalResumeDeferSince = 0;
|
|
25331
|
+
this.approvalResumeDeferEpoch = -1;
|
|
25332
|
+
}
|
|
25269
25333
|
finishResponse() {
|
|
25270
25334
|
if (this.submitPendingUntil > Date.now()) return;
|
|
25271
25335
|
if (this.responseSettleIgnoreUntil > Date.now()) return;
|
|
@@ -25707,7 +25771,8 @@ var init_provider_cli_adapter = __esm({
|
|
|
25707
25771
|
},
|
|
25708
25772
|
onTurnCompleted: () => {
|
|
25709
25773
|
this.responseBuffer = "";
|
|
25710
|
-
}
|
|
25774
|
+
},
|
|
25775
|
+
isInApprovalResumeGrace: () => this.inApprovalResumeGraceProbe?.() === true
|
|
25711
25776
|
},
|
|
25712
25777
|
resolvedConfig.timeouts
|
|
25713
25778
|
);
|
|
@@ -25739,6 +25804,9 @@ var init_provider_cli_adapter = __esm({
|
|
|
25739
25804
|
ptyProcess = null;
|
|
25740
25805
|
transportFactory;
|
|
25741
25806
|
onStatusChange = null;
|
|
25807
|
+
// FALSE-IDLE (Fix 2): probe the owning instance for the post-approval resume grace.
|
|
25808
|
+
// Null until the instance registers it; the engine treats absence as "not in grace".
|
|
25809
|
+
inApprovalResumeGraceProbe = null;
|
|
25742
25810
|
// ─── State machine engine ─────────────────────────
|
|
25743
25811
|
engine;
|
|
25744
25812
|
responseBuffer = "";
|
|
@@ -25982,6 +26050,12 @@ ${lastSnapshot}`;
|
|
|
25982
26050
|
setOnStatusChange(callback) {
|
|
25983
26051
|
this.onStatusChange = callback;
|
|
25984
26052
|
}
|
|
26053
|
+
// FALSE-IDLE (Fix 2): the instance registers its inApprovalResumeGrace judgment so the
|
|
26054
|
+
// engine's applyIdle hysteresis can scope itself to autonomous auto-approving sessions
|
|
26055
|
+
// without the engine needing any mesh/auto-approve awareness of its own.
|
|
26056
|
+
setInApprovalResumeGraceProbe(probe) {
|
|
26057
|
+
this.inApprovalResumeGraceProbe = probe;
|
|
26058
|
+
}
|
|
25985
26059
|
setOnPtyData(callback) {
|
|
25986
26060
|
this.onPtyDataCallback = callback;
|
|
25987
26061
|
}
|
|
@@ -45198,6 +45272,28 @@ var CliProviderInstance = class _CliProviderInstance {
|
|
|
45198
45272
|
* the nudge was NOT deferred) and leaked to the coordinator.
|
|
45199
45273
|
*/
|
|
45200
45274
|
static AUTO_APPROVE_MASK_STALL_MS = 10500;
|
|
45275
|
+
/**
|
|
45276
|
+
* FALSE-IDLE (inter-approval quiet valley): grace window after an auto-approve
|
|
45277
|
+
* (or mesh_approve) RESOLVES a modal during which a subsequent generating→idle
|
|
45278
|
+
* quiet valley must NOT be treated as turn completion.
|
|
45279
|
+
*
|
|
45280
|
+
* The RCA: auto-approve resolves a modal → the agent resumes the same turn →
|
|
45281
|
+
* between resolving that approval and preparing the next tool/approval the agent
|
|
45282
|
+
* falls briefly silent. The FSM sees idle + a recorded mid-turn assistant bubble
|
|
45283
|
+
* and fires an early agent:generating_completed even though the turn is still in
|
|
45284
|
+
* flight. Live evidence showed the same session resuming waiting_approval ~13s
|
|
45285
|
+
* after a "clean" completion emit.
|
|
45286
|
+
*
|
|
45287
|
+
* The window must be comfortably larger than the observed resume gap (~13s) so
|
|
45288
|
+
* the valley is bridged, but not so large that a turn that genuinely ended right
|
|
45289
|
+
* after an approval is held for an annoying stretch. 18s clears 13s with margin
|
|
45290
|
+
* while capping the worst-case extra hold on a truly-finished turn at 18s (still
|
|
45291
|
+
* well under COMPLETED_FINALIZATION_MAX_WAIT_MS's 30s hard bound). The recency is
|
|
45292
|
+
* measured from the engine's lastApprovalResolvedAt, which is stamped ONLY by
|
|
45293
|
+
* resolveModal (auto-approve fire / dashboard / mesh_approve) — so a plain turn
|
|
45294
|
+
* with no approval never carries recency and is never held (no regression).
|
|
45295
|
+
*/
|
|
45296
|
+
static APPROVAL_RESUME_GRACE_MS = 18e3;
|
|
45201
45297
|
adapter;
|
|
45202
45298
|
context = null;
|
|
45203
45299
|
events = [];
|
|
@@ -45345,6 +45441,9 @@ var CliProviderInstance = class _CliProviderInstance {
|
|
|
45345
45441
|
this.adapter.setOnStatusChange(() => {
|
|
45346
45442
|
this.detectStatusTransition();
|
|
45347
45443
|
});
|
|
45444
|
+
if (typeof this.adapter.setInApprovalResumeGraceProbe === "function") {
|
|
45445
|
+
this.adapter.setInApprovalResumeGraceProbe(() => this.inApprovalResumeGrace());
|
|
45446
|
+
}
|
|
45348
45447
|
await this.adapter.spawn();
|
|
45349
45448
|
await this.enforceFreshSessionLaunchIfNeeded();
|
|
45350
45449
|
await this.applyInitialThinkingLevelViaControl();
|
|
@@ -46233,6 +46332,9 @@ var CliProviderInstance = class _CliProviderInstance {
|
|
|
46233
46332
|
if (adapterAny?.isWaitingForResponse === true) return { reason: "adapter_waiting_for_response", terminal: !approvalResolvedIdle };
|
|
46234
46333
|
if (adapterAny?.currentTurnScope) return { reason: "adapter_turn_scope_active", terminal: !approvalResolvedIdle };
|
|
46235
46334
|
if (this.hasAdapterPendingResponse()) return { reason: "adapter_pending_response", terminal: !approvalResolvedIdle };
|
|
46335
|
+
if (!approvalResolvedIdle && this.inApprovalResumeGrace()) {
|
|
46336
|
+
return { reason: "approval_resume_grace", terminal: false };
|
|
46337
|
+
}
|
|
46236
46338
|
const partial = typeof this.adapter.getPartialResponse === "function" ? this.adapter.getPartialResponse() : "";
|
|
46237
46339
|
if (typeof partial === "string" && partial.trim()) return { reason: "partial_response_pending", terminal: true };
|
|
46238
46340
|
let parsed;
|
|
@@ -46394,6 +46496,24 @@ var CliProviderInstance = class _CliProviderInstance {
|
|
|
46394
46496
|
isAutonomousMeshSession() {
|
|
46395
46497
|
return this.isMeshWorkerSession() || !!this.settings.meshCoordinatorFor;
|
|
46396
46498
|
}
|
|
46499
|
+
/**
|
|
46500
|
+
* FALSE-IDLE: are we inside the post-approval resume grace window? True when this
|
|
46501
|
+
* is an autonomous auto-approving mesh session AND the engine resolved a modal
|
|
46502
|
+
* (auto-approve / mesh_approve) within APPROVAL_RESUME_GRACE_MS. This is the single
|
|
46503
|
+
* "auto-approve recency" judgment shared by Fix 1 (the SETTLE-VALLEY completion
|
|
46504
|
+
* hold below) and Fix 2 (the FSM-level applyIdle hysteresis in cli-state-engine).
|
|
46505
|
+
*
|
|
46506
|
+
* Scoped to autonomous auto-approving sessions so a foreground/attended session,
|
|
46507
|
+
* or a session with auto-approve off (whose approvals a human answers), is never
|
|
46508
|
+
* held. The recency clock (adapter.lastApprovalResolvedAt) is 0 until the first
|
|
46509
|
+
* resolveModal, so a plain turn that never saw an approval always returns false.
|
|
46510
|
+
*/
|
|
46511
|
+
inApprovalResumeGrace(now = Date.now()) {
|
|
46512
|
+
if (!this.isAutonomousMeshSession() || !this.shouldAutoApprove()) return false;
|
|
46513
|
+
const resolvedAt = typeof this.adapter?.lastApprovalResolvedAt === "number" ? this.adapter.lastApprovalResolvedAt : 0;
|
|
46514
|
+
if (resolvedAt <= 0) return false;
|
|
46515
|
+
return now - resolvedAt < _CliProviderInstance.APPROVAL_RESUME_GRACE_MS;
|
|
46516
|
+
}
|
|
46397
46517
|
/**
|
|
46398
46518
|
* ARCH-REFACTOR R1: the taskId to attribute the CURRENTLY-completing turn to.
|
|
46399
46519
|
* Prefers the per-turn binding (engine.currentTurnTaskId, set when the turn was
|
|
@@ -46705,7 +46825,14 @@ var CliProviderInstance = class _CliProviderInstance {
|
|
|
46705
46825
|
this.autoApproveLastModalSeenAt = now;
|
|
46706
46826
|
const modalKind = typeof modal?.kind === "string" ? modal.kind : "approval";
|
|
46707
46827
|
if (modalKind !== "approval") {
|
|
46708
|
-
|
|
46828
|
+
const modalText = `${String(modal?.title || "")}
|
|
46829
|
+
${String(modal?.message || "")}
|
|
46830
|
+
${buttons.join("\n")}`;
|
|
46831
|
+
const looksLikeSelectionPicker = /Select (?:a |an )?(?:model|mode|option)\b|Switch between/i.test(modalText);
|
|
46832
|
+
const looksLikeConsent = looksLikeActiveApprovalPromptText(modalText) || /Do you want to (?:proceed|create|make|edit|apply|run|delete|modify|allow)\b|allow all edits\b|don'?t ask again\b/i.test(modalText) || hasNegativeApprovalOption(buttons) || hasReliableApprovalAffirmative(buttons);
|
|
46833
|
+
if (looksLikeSelectionPicker && !looksLikeConsent) {
|
|
46834
|
+
return autoApproveActive;
|
|
46835
|
+
}
|
|
46709
46836
|
}
|
|
46710
46837
|
const { index: buttonIndex, label: buttonLabel } = pickApprovalButton(buttons, this.provider);
|
|
46711
46838
|
const hasReliableConsentAnchor = hasNegativeApprovalOption(buttons) || hasReliableApprovalAffirmative(buttons);
|