@adhdev/daemon-standalone 1.0.28-rc.21 → 1.0.28-rc.23
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/index.js +114 -11
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -33311,10 +33311,10 @@ var require_dist3 = __commonJS({
|
|
|
33311
33311
|
}
|
|
33312
33312
|
function getDaemonBuildInfo() {
|
|
33313
33313
|
if (cached2) return cached2;
|
|
33314
|
-
const commit = readInjected(true ? "
|
|
33315
|
-
const commitShort = readInjected(true ? "
|
|
33316
|
-
const version2 = readInjected(true ? "1.0.28-rc.
|
|
33317
|
-
const builtAt = readInjected(true ? "2026-07-
|
|
33314
|
+
const commit = readInjected(true ? "f130ad6e97683f23cd08e4296336ac70774146cf" : void 0) ?? "unknown";
|
|
33315
|
+
const commitShort = readInjected(true ? "f130ad6e" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
|
|
33316
|
+
const version2 = readInjected(true ? "1.0.28-rc.23" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
|
|
33317
|
+
const builtAt = readInjected(true ? "2026-07-29T03:34:37.130Z" : void 0);
|
|
33318
33318
|
cached2 = builtAt ? { commit, commitShort, version: version2, builtAt } : { commit, commitShort, version: version2 };
|
|
33319
33319
|
return cached2;
|
|
33320
33320
|
}
|
|
@@ -37556,6 +37556,21 @@ ${error48.message || ""}`;
|
|
|
37556
37556
|
}
|
|
37557
37557
|
return { attemptId: attempt.attemptId, stage: attempt.stage, applied: false, staleAttempt: false };
|
|
37558
37558
|
}
|
|
37559
|
+
if (args.sessionId && attempt.sessionId && !sessionIdsEquivalent(args.sessionId, attempt.sessionId)) {
|
|
37560
|
+
metrics.staleAttemptEvents += 1;
|
|
37561
|
+
store.insertTurnEvent({
|
|
37562
|
+
eventId: (0, import_crypto5.randomUUID)(),
|
|
37563
|
+
meshId: args.meshId,
|
|
37564
|
+
attemptId: attempt.attemptId,
|
|
37565
|
+
taskId: args.taskId,
|
|
37566
|
+
kind: `stale_${args.stage}`,
|
|
37567
|
+
dedupeKey: args.sessionId,
|
|
37568
|
+
occurredAtMs: args.occurredAtMs ?? nowMs,
|
|
37569
|
+
recordedAt: nowIso
|
|
37570
|
+
});
|
|
37571
|
+
LOG2.info("TurnLedger", `Ignored ${args.stage} for task ${args.taskId} attempt ${attempt.attemptId}: event session ${args.sessionId} \u2260 attempt session ${attempt.sessionId} \u2014 no state change`);
|
|
37572
|
+
return { attemptId: attempt.attemptId, stage: attempt.stage, applied: false, staleAttempt: true };
|
|
37573
|
+
}
|
|
37559
37574
|
const inserted = store.insertTurnEvent({
|
|
37560
37575
|
eventId: (0, import_crypto5.randomUUID)(),
|
|
37561
37576
|
meshId: args.meshId,
|
|
@@ -49992,6 +50007,15 @@ ${rendered}`, "utf-8");
|
|
|
49992
50007
|
const via = readString6(payload.via);
|
|
49993
50008
|
return Boolean(via && DIRECT_DISPATCH_VIA.has(via) && payload.source !== "queue");
|
|
49994
50009
|
}
|
|
50010
|
+
function hasTerminalLedgerAuthorityForTask(ledgerEntries, taskId) {
|
|
50011
|
+
for (const entry of ledgerEntries || []) {
|
|
50012
|
+
if (entry.kind !== "task_completed" && entry.kind !== "task_failed") continue;
|
|
50013
|
+
if (readString6(entry.payload?.taskId) !== taskId) continue;
|
|
50014
|
+
if (entry.kind === "task_completed" && isWeakCompletionEvidence(entry.payload || {})) continue;
|
|
50015
|
+
return true;
|
|
50016
|
+
}
|
|
50017
|
+
return false;
|
|
50018
|
+
}
|
|
49995
50019
|
function directDispatchTaskId(entry) {
|
|
49996
50020
|
return readString6(entry.payload?.taskId) || entry.id;
|
|
49997
50021
|
}
|
|
@@ -50129,7 +50153,8 @@ ${rendered}`, "utf-8");
|
|
|
50129
50153
|
const queueNodeId = task.assignedNodeId || task.targetNodeId;
|
|
50130
50154
|
const queueSessionId = task.assignedSessionId || task.targetSessionId;
|
|
50131
50155
|
const queueLive = task.status === "assigned" ? sessionStatusFromNodes(opts.nodes, queueNodeId ?? void 0, queueSessionId ?? void 0) : {};
|
|
50132
|
-
|
|
50156
|
+
const queueTerminalAuthority = task.status === "assigned" && hasTerminalLedgerAuthorityForTask(opts.ledgerEntries, task.id);
|
|
50157
|
+
let queueStatus = !queueTerminalAuthority && (queueLive.status === "awaiting_approval" || queueLive.status === "awaiting_choice" || queueLive.status === "generating") ? queueLive.status : task.status;
|
|
50133
50158
|
const turnOverlay = task.status === "assigned" ? turnProjectionActiveWorkStatus(opts.meshId, task.id) : null;
|
|
50134
50159
|
if (turnOverlay) queueStatus = turnOverlay.status;
|
|
50135
50160
|
records.push({
|
|
@@ -50156,7 +50181,9 @@ ${rendered}`, "utf-8");
|
|
|
50156
50181
|
const dbStatus = dispatch.status;
|
|
50157
50182
|
const isTerminal = dbStatus === "completed" || dbStatus === "failed" || dbStatus === "stale";
|
|
50158
50183
|
const turnOverlay = isTerminal ? null : turnProjectionActiveWorkStatus(opts.meshId, dispatch.taskId);
|
|
50159
|
-
const
|
|
50184
|
+
const directTerminalAuthority = !isTerminal && hasTerminalLedgerAuthorityForTask(opts.ledgerEntries, dispatch.taskId);
|
|
50185
|
+
const liveStatus = directTerminalAuthority ? void 0 : live.status;
|
|
50186
|
+
const status = isTerminal ? dbStatus === "completed" ? "idle" : "failed" : turnOverlay?.status || liveStatus || (dbStatus === "acked" ? "generating" : "assigned");
|
|
50160
50187
|
const { ledgerOnlyStaleReason, isFreshUnacknowledged } = classifyDirectDispatch({
|
|
50161
50188
|
status,
|
|
50162
50189
|
isTerminalRow: isTerminal,
|
|
@@ -50358,6 +50385,7 @@ ${rendered}`, "utf-8");
|
|
|
50358
50385
|
init_mesh_work_queue();
|
|
50359
50386
|
init_dist();
|
|
50360
50387
|
init_mesh_turn_presentation();
|
|
50388
|
+
init_mesh_events_utils();
|
|
50361
50389
|
DIRECT_DISPATCH_VIA = /* @__PURE__ */ new Set(["p2p_direct", "local_direct", "mesh_send_task"]);
|
|
50362
50390
|
TERMINAL_LEDGER_KINDS = /* @__PURE__ */ new Set(["task_completed", "task_failed", "task_stalled"]);
|
|
50363
50391
|
LEDGER_ONLY_STALE_REASON = "direct task dispatch has no provider acknowledgement, transcript append, or active runtime transition";
|
|
@@ -57760,6 +57788,24 @@ ${cleanBody}`;
|
|
|
57760
57788
|
}, `${row.requeueReason} ${Math.round((Date.now() - requeuedAtMs) / 1e3)}s \u2192 ${outcome}`);
|
|
57761
57789
|
return true;
|
|
57762
57790
|
}
|
|
57791
|
+
function hasTerminalAuthorityForTask(meshId, taskId) {
|
|
57792
|
+
try {
|
|
57793
|
+
const row = resolveTurnAttemptRow({ meshId, taskId });
|
|
57794
|
+
if (row && (row.terminalOutcome || isTerminalTurnStage(row.stage))) return true;
|
|
57795
|
+
} catch {
|
|
57796
|
+
}
|
|
57797
|
+
try {
|
|
57798
|
+
const entry = MeshRuntimeStore.getInstance().findQueueEntryById(meshId, taskId);
|
|
57799
|
+
if (entry && (entry.status === "completed" || entry.status === "failed" || entry.status === "cancelled")) return true;
|
|
57800
|
+
} catch {
|
|
57801
|
+
}
|
|
57802
|
+
try {
|
|
57803
|
+
const evidence = findTerminalLedgerEvidenceForTask({ meshId, taskId });
|
|
57804
|
+
if (evidence && evidence.kind !== "task_stalled") return true;
|
|
57805
|
+
} catch {
|
|
57806
|
+
}
|
|
57807
|
+
return false;
|
|
57808
|
+
}
|
|
57763
57809
|
function injectMeshSystemMessage(components, args) {
|
|
57764
57810
|
const eventSessionId = resolveEventSessionId(args.metadataEvent, args.sourceInstanceId);
|
|
57765
57811
|
const eventNodeId = readNonEmptyString(args.nodeId) || readNonEmptyString(args.metadataEvent.meshNodeId);
|
|
@@ -57770,6 +57816,14 @@ ${cleanBody}`;
|
|
|
57770
57816
|
meshId: args.meshId,
|
|
57771
57817
|
event: args.event
|
|
57772
57818
|
};
|
|
57819
|
+
if ((args.event === "agent:waiting_approval" || args.event === "agent:waiting_choice") && eventSessionId) {
|
|
57820
|
+
const approvalTaskId = readNonEmptyString(args.metadataEvent.taskId);
|
|
57821
|
+
if (approvalTaskId && hasTerminalAuthorityForTask(args.meshId, approvalTaskId)) {
|
|
57822
|
+
LOG2.info("MeshEvents", `Suppressed ${args.event} for session ${eventSessionId} (mesh ${args.meshId}, task ${approvalTaskId}) \u2014 terminal authority already exists for the task; the approval/choice is stale (no current actionable modal)`);
|
|
57823
|
+
traceMeshEventDrop("stale_approval_after_terminal", traceCtx);
|
|
57824
|
+
return { success: true, forwarded: 0, suppressed: true, staleApprovalAfterTerminal: true };
|
|
57825
|
+
}
|
|
57826
|
+
}
|
|
57773
57827
|
const sourceSession = args.sourceInstanceId ? components.instanceManager.getInstance(args.sourceInstanceId) : void 0;
|
|
57774
57828
|
const workerCoordinatorDaemonId = readNonEmptyString(
|
|
57775
57829
|
sourceSession?.getState()?.settings?.meshCoordinatorDaemonId
|
|
@@ -58737,6 +58791,7 @@ ${cleanBody}`;
|
|
|
58737
58791
|
init_mesh_events_utils();
|
|
58738
58792
|
init_mesh_event_classify();
|
|
58739
58793
|
init_mesh_turn_ledger();
|
|
58794
|
+
init_mesh_turn_presentation();
|
|
58740
58795
|
init_mesh_queue_assignment();
|
|
58741
58796
|
REMOTE_IDLE_SESSION_TTL_MS = 5 * 60 * 1e3;
|
|
58742
58797
|
meshByWorkspaceCache = /* @__PURE__ */ new Map();
|
|
@@ -73104,8 +73159,23 @@ ${effect.notification.body || ""}`.trim();
|
|
|
73104
73159
|
function stripTrailingSlashes(url2) {
|
|
73105
73160
|
return url2.replace(/\/+$/, "");
|
|
73106
73161
|
}
|
|
73107
|
-
|
|
73108
|
-
|
|
73162
|
+
var REGISTRY_API_PATH = "/api/v1/registry";
|
|
73163
|
+
function deriveRegistryBaseUrlFromServerUrl(serverUrl) {
|
|
73164
|
+
const cleaned = cleanString(serverUrl);
|
|
73165
|
+
if (!cleaned) return void 0;
|
|
73166
|
+
const stripped = stripTrailingSlashes(cleaned);
|
|
73167
|
+
let parsed;
|
|
73168
|
+
try {
|
|
73169
|
+
parsed = new URL(stripped);
|
|
73170
|
+
} catch {
|
|
73171
|
+
return void 0;
|
|
73172
|
+
}
|
|
73173
|
+
if (parsed.protocol !== "https:" && parsed.protocol !== "http:") return void 0;
|
|
73174
|
+
if (stripped.endsWith(REGISTRY_API_PATH)) return stripped;
|
|
73175
|
+
return `${stripped}${REGISTRY_API_PATH}`;
|
|
73176
|
+
}
|
|
73177
|
+
function resolveRegistryBaseUrl(configuredUrl, env2 = process.env, serverUrl) {
|
|
73178
|
+
const resolved = cleanString(configuredUrl) ?? cleanString(env2[REGISTRY_URL_ENV_VAR]) ?? deriveRegistryBaseUrlFromServerUrl(serverUrl) ?? DEFAULT_REGISTRY_BASE_URL;
|
|
73109
73179
|
return stripTrailingSlashes(resolved);
|
|
73110
73180
|
}
|
|
73111
73181
|
function resolveProviderTarballUrl(configuredUrl, env2 = process.env) {
|
|
@@ -78172,7 +78242,8 @@ ${effect.notification.body || ""}`.trim();
|
|
|
78172
78242
|
const https = require("https");
|
|
78173
78243
|
const fs47 = require("fs");
|
|
78174
78244
|
const path50 = require("path");
|
|
78175
|
-
const
|
|
78245
|
+
const cfg = loadConfig2();
|
|
78246
|
+
const REGISTRY = resolveRegistryBaseUrl(cfg.registryUrl, process.env, cfg.serverUrl);
|
|
78176
78247
|
function fetchText(url2, timeoutMs) {
|
|
78177
78248
|
return new Promise((resolve28, reject) => {
|
|
78178
78249
|
const req = https.get(url2, { headers: { "User-Agent": "adhdev-daemon", "Accept": "application/json" }, timeout: timeoutMs }, (res) => {
|
|
@@ -78542,7 +78613,8 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
78542
78613
|
const installed = this.handleListInstalledProviders({});
|
|
78543
78614
|
if (!installed.success) return installed;
|
|
78544
78615
|
const https = require("https");
|
|
78545
|
-
const
|
|
78616
|
+
const cfg = loadConfig2();
|
|
78617
|
+
const REGISTRY = resolveRegistryBaseUrl(cfg.registryUrl, process.env, cfg.serverUrl);
|
|
78546
78618
|
function fetchJson(url2) {
|
|
78547
78619
|
return new Promise((resolve28, reject) => {
|
|
78548
78620
|
const req = https.get(url2, { headers: { "User-Agent": "adhdev-daemon", "Accept": "application/json" }, timeout: 1e4 }, (res) => {
|
|
@@ -88505,6 +88577,20 @@ ${body}
|
|
|
88505
88577
|
* window, and scoped to autonomous mesh sessions (a foreground/attended or non-mesh
|
|
88506
88578
|
* session, where a human answers the prompt, is returned untouched).
|
|
88507
88579
|
*/
|
|
88580
|
+
/**
|
|
88581
|
+
* TERMINAL-STALE-APPROVAL (provider side): true once a GENUINE (non-weak) completion
|
|
88582
|
+
* has been emitted for the CURRENT busy epoch — the turn is over and no new generating
|
|
88583
|
+
* phase has opened since the emit (busyEpoch has not advanced past the latch). A stale
|
|
88584
|
+
* cached/sticky modal frame must not re-synthesize waiting_approval for such an
|
|
88585
|
+
* already-completed turn. A weak/false-idle emit does NOT count (the turn may
|
|
88586
|
+
* genuinely still be in flight), and any new busy phase (busyEpoch advanced past the
|
|
88587
|
+
* emit) re-enables approval surfacing for the new turn.
|
|
88588
|
+
*/
|
|
88589
|
+
hasEmittedGenuineCompletionForCurrentEpoch() {
|
|
88590
|
+
const latch = this.lastEmittedCompletion;
|
|
88591
|
+
if (!latch || latch.weak) return false;
|
|
88592
|
+
return this.busyEpoch <= latch.emittedAtEpoch;
|
|
88593
|
+
}
|
|
88508
88594
|
stabilizeFlappingApprovalStatus(adapterStatus, now = Date.now()) {
|
|
88509
88595
|
if (!this.isAutonomousMeshSession() || !this.shouldUsePtyAutoApprove()) return adapterStatus;
|
|
88510
88596
|
const rawStatus = adapterStatus?.status;
|
|
@@ -88517,6 +88603,11 @@ ${body}
|
|
|
88517
88603
|
}
|
|
88518
88604
|
return adapterStatus;
|
|
88519
88605
|
}
|
|
88606
|
+
if (this.approvalStickyLastConcreteAt > 0 && this.hasEmittedGenuineCompletionForCurrentEpoch()) {
|
|
88607
|
+
this.approvalStickyLastConcreteAt = 0;
|
|
88608
|
+
this.approvalStickyModal = null;
|
|
88609
|
+
this.approvalStickyEntrySeq = 0;
|
|
88610
|
+
}
|
|
88520
88611
|
if (this.approvalStickyLastConcreteAt > 0 && this.approvalStickyModal) {
|
|
88521
88612
|
const withinWindow = now - this.approvalStickyLastConcreteAt < _CliProviderInstance.APPROVAL_STICKY_FLAP_MS;
|
|
88522
88613
|
const resolvedSinceAnchor = resolvedAt >= this.approvalStickyLastConcreteAt;
|
|
@@ -94914,6 +95005,15 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
94914
95005
|
`channel metadata for "${channel}" has an unexpected shape (missing providers array)`
|
|
94915
95006
|
);
|
|
94916
95007
|
}
|
|
95008
|
+
if (channel === "preview") {
|
|
95009
|
+
const echo = typeof body.channel === "string" ? body.channel.trim().toLowerCase() : "";
|
|
95010
|
+
if (echo !== channel) {
|
|
95011
|
+
throw new ProviderChannelError(
|
|
95012
|
+
"CHANNEL_METADATA_MISMATCH",
|
|
95013
|
+
`registry response for channel "preview" ${typeof body.channel === "string" ? `echoes channel "${body.channel}"` : "omits the top-level channel echo"} \u2014 the registry does not honor the channel contract (legacy/stable payload); refusing to treat its rows as preview, last-known-good preserved`
|
|
95014
|
+
);
|
|
95015
|
+
}
|
|
95016
|
+
}
|
|
94917
95017
|
const entries = [];
|
|
94918
95018
|
for (const raw of body.providers) {
|
|
94919
95019
|
if (!raw || typeof raw.type !== "string" || typeof raw.version !== "string" || typeof raw.category !== "string") {
|
|
@@ -95366,7 +95466,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
95366
95466
|
constructor(options) {
|
|
95367
95467
|
this.logFn = options?.logFn || LOG2.forComponent("Provider").asLogFn();
|
|
95368
95468
|
this.probeStarts = options?.probeStarts ?? [process.cwd(), __dirname];
|
|
95369
|
-
this.registryBaseUrl = resolveRegistryBaseUrl(options?.registryUrl);
|
|
95469
|
+
this.registryBaseUrl = resolveRegistryBaseUrl(options?.registryUrl, process.env, options?.serverUrl);
|
|
95370
95470
|
this.providerTarballUrl = resolveProviderTarballUrl(options?.providerTarballUrl);
|
|
95371
95471
|
this.channel = resolveProviderChannel(options?.channel, process.env, options?.updateChannel);
|
|
95372
95472
|
this.allowUnverifiedTarball = options?.allowUnverifiedTarball === true || process.env[_ProviderLoader.UNVERIFIED_TARBALL_ENV_VAR] === "1";
|
|
@@ -97340,6 +97440,8 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
97340
97440
|
logFn: () => {
|
|
97341
97441
|
},
|
|
97342
97442
|
// Suppress logs during launch
|
|
97443
|
+
registryUrl: appConfig.registryUrl,
|
|
97444
|
+
serverUrl: appConfig.serverUrl,
|
|
97343
97445
|
channel: appConfig.providerChannel,
|
|
97344
97446
|
updateChannel: appConfig.updateChannel
|
|
97345
97447
|
});
|
|
@@ -114042,6 +114144,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
114042
114144
|
sourceMode: providerSourceMode,
|
|
114043
114145
|
userDir: appConfig.providerDir,
|
|
114044
114146
|
registryUrl: appConfig.registryUrl,
|
|
114147
|
+
serverUrl: appConfig.serverUrl,
|
|
114045
114148
|
providerTarballUrl: appConfig.providerTarballUrl,
|
|
114046
114149
|
channel: appConfig.providerChannel,
|
|
114047
114150
|
updateChannel: appConfig.updateChannel,
|