@adhdev/daemon-core 0.9.82-rc.128 → 0.9.82-rc.129
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 +86 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +88 -12
- package/dist/index.mjs.map +1 -1
- package/dist/providers/cli-provider-instance.d.ts +1 -0
- package/package.json +1 -1
- package/src/commands/chat-commands.ts +71 -5
- package/src/providers/cli-provider-instance.ts +46 -5
package/dist/index.mjs
CHANGED
|
@@ -16867,6 +16867,34 @@ function coerceUnsafeNativeFallbackStatus(status, activeModal) {
|
|
|
16867
16867
|
if (status === "waiting_approval" && activeModal) return status;
|
|
16868
16868
|
return "idle";
|
|
16869
16869
|
}
|
|
16870
|
+
function isRuntimeInputAckMessage(message) {
|
|
16871
|
+
if (!message || typeof message !== "object") return false;
|
|
16872
|
+
const role = String(message.role || "").trim().toLowerCase();
|
|
16873
|
+
if (role !== "user" && role !== "human") return false;
|
|
16874
|
+
const meta = message.meta;
|
|
16875
|
+
return !!meta && typeof meta === "object" && !Array.isArray(meta) && meta.runtimeInputAck === true;
|
|
16876
|
+
}
|
|
16877
|
+
function selectRuntimeInputAckMessages(messages) {
|
|
16878
|
+
return messages.filter((message) => isRuntimeInputAckMessage(message));
|
|
16879
|
+
}
|
|
16880
|
+
function readExactRuntimeMirrorMessages(args) {
|
|
16881
|
+
const targetSessionId = String(args.targetSessionId || "").trim();
|
|
16882
|
+
const currentSessionId = String(args.currentSessionId || "").trim();
|
|
16883
|
+
if (!targetSessionId || targetSessionId !== currentSessionId) return [];
|
|
16884
|
+
const history = readChatHistory(
|
|
16885
|
+
args.providerType,
|
|
16886
|
+
0,
|
|
16887
|
+
Math.max(args.tailLimit || 0, 200),
|
|
16888
|
+
targetSessionId,
|
|
16889
|
+
0,
|
|
16890
|
+
args.historyBehavior
|
|
16891
|
+
);
|
|
16892
|
+
return normalizeChatMessages(history.messages || []).filter((message) => {
|
|
16893
|
+
const historySessionId = String(message.historySessionId || "").trim();
|
|
16894
|
+
const instanceId = String(message.instanceId || "").trim();
|
|
16895
|
+
return historySessionId === targetSessionId || instanceId === targetSessionId;
|
|
16896
|
+
});
|
|
16897
|
+
}
|
|
16870
16898
|
function supportsCliNativeTranscript(providerType, provider) {
|
|
16871
16899
|
if (CLI_NATIVE_TRANSCRIPT_PROVIDERS.has(providerType)) return true;
|
|
16872
16900
|
return provider?.category === "cli" && isNativeSourceCanonicalHistory(provider?.canonicalHistory);
|
|
@@ -17715,10 +17743,19 @@ async function handleReadChat(h, args) {
|
|
|
17715
17743
|
freshEnough
|
|
17716
17744
|
});
|
|
17717
17745
|
const unsafeNativeFallback = adapter.cliType === "codex-cli" && isUnsafeNativeTranscriptFallback(fallbackReason);
|
|
17746
|
+
const safeRuntimeAckMessages = unsafeNativeFallback ? selectRuntimeInputAckMessages(returnedMessages) : [];
|
|
17747
|
+
const exactRuntimeMirrorMessages = unsafeNativeFallback && safeRuntimeAckMessages.length === 0 ? readExactRuntimeMirrorMessages({
|
|
17748
|
+
providerType,
|
|
17749
|
+
targetSessionId: typeof args?.targetSessionId === "string" ? args.targetSessionId : void 0,
|
|
17750
|
+
currentSessionId: typeof h.currentSession?.sessionId === "string" ? h.currentSession.sessionId : void 0,
|
|
17751
|
+
tailLimit: nativeHistoryLimit,
|
|
17752
|
+
historyBehavior: provider?.historyBehavior
|
|
17753
|
+
}) : [];
|
|
17754
|
+
const safeDaemonMessages = safeRuntimeAckMessages.length > 0 ? safeRuntimeAckMessages : exactRuntimeMirrorMessages;
|
|
17718
17755
|
if (unsafeNativeFallback) {
|
|
17719
|
-
selectedMessages =
|
|
17720
|
-
selectedTranscriptAuthority = void 0;
|
|
17721
|
-
selectedCoverage = void 0;
|
|
17756
|
+
selectedMessages = safeDaemonMessages;
|
|
17757
|
+
selectedTranscriptAuthority = safeDaemonMessages.length > 0 ? "daemon" : void 0;
|
|
17758
|
+
selectedCoverage = safeDaemonMessages.length > 0 ? "tail" : void 0;
|
|
17722
17759
|
selectedStatus = coerceUnsafeNativeFallbackStatus(returnedStatus, activeModal);
|
|
17723
17760
|
}
|
|
17724
17761
|
messageSource = buildCliMessageSourceProvenance({
|
|
@@ -17737,11 +17774,15 @@ async function handleReadChat(h, args) {
|
|
|
17737
17774
|
unavailableReason,
|
|
17738
17775
|
nativeMessages,
|
|
17739
17776
|
ptyMessages: returnedMessages,
|
|
17740
|
-
returnedMessages: unsafeNativeFallback ?
|
|
17777
|
+
returnedMessages: unsafeNativeFallback ? safeDaemonMessages : returnedMessages,
|
|
17741
17778
|
safeMapping,
|
|
17742
17779
|
freshEnough,
|
|
17743
17780
|
ptyStatusApprovalOnly: unsafeNativeFallback
|
|
17744
17781
|
});
|
|
17782
|
+
if (unsafeNativeFallback && exactRuntimeMirrorMessages.length > 0) {
|
|
17783
|
+
messageSource.selectedDaemonSource = "exact-runtime-mirror";
|
|
17784
|
+
messageSource.transcriptAuthority = "daemon";
|
|
17785
|
+
}
|
|
17745
17786
|
}
|
|
17746
17787
|
}
|
|
17747
17788
|
}
|
|
@@ -18076,14 +18117,14 @@ async function handleSendChat(h, args) {
|
|
|
18076
18117
|
try {
|
|
18077
18118
|
const hasStructuredParts = input.parts.some((part) => part.type !== "text");
|
|
18078
18119
|
if (hasStructuredParts) {
|
|
18079
|
-
const
|
|
18080
|
-
if (!
|
|
18120
|
+
const target2 = getTargetInstance(h, args);
|
|
18121
|
+
if (!target2 || target2.category !== "cli") {
|
|
18081
18122
|
return { success: false, error: `CLI instance not found for ${provider?.type || args?.agentType || "unknown"}` };
|
|
18082
18123
|
}
|
|
18083
18124
|
assertProviderSupportsDeclaredInput(provider, input);
|
|
18084
18125
|
await waitOnceForFreshHermesCliStart(adapter, _log);
|
|
18085
|
-
|
|
18086
|
-
return _logSendSuccess(`${transport}-instance`,
|
|
18126
|
+
target2.onEvent("send_message", { input });
|
|
18127
|
+
return _logSendSuccess(`${transport}-instance`, target2.type);
|
|
18087
18128
|
}
|
|
18088
18129
|
assertTextOnlyInput(provider, input);
|
|
18089
18130
|
if (!text) return { success: false, error: "text required for PTY send" };
|
|
@@ -18096,6 +18137,10 @@ async function handleSendChat(h, args) {
|
|
|
18096
18137
|
} else {
|
|
18097
18138
|
await adapter.sendMessage(text);
|
|
18098
18139
|
}
|
|
18140
|
+
const target = getTargetInstance(h, args);
|
|
18141
|
+
if (target?.category === "cli" && target.type === adapter.cliType && typeof target.recordAcknowledgedUserInput === "function") {
|
|
18142
|
+
target.recordAcknowledgedUserInput(input);
|
|
18143
|
+
}
|
|
18099
18144
|
return {
|
|
18100
18145
|
..._logSendSuccess(`${transport}-adapter`, adapter.cliType),
|
|
18101
18146
|
...forceSend ? { forceSent: true } : {}
|
|
@@ -20765,6 +20810,26 @@ var CliProviderInstance = class {
|
|
|
20765
20810
|
this.applyProviderResponse(data, { phase: "immediate" });
|
|
20766
20811
|
}
|
|
20767
20812
|
}
|
|
20813
|
+
recordAcknowledgedUserInput(input) {
|
|
20814
|
+
const content = typeof input === "string" ? input.trim() : buildCliStructuredInputPrompt(input).trim();
|
|
20815
|
+
if (!content) return;
|
|
20816
|
+
const receivedAt = Date.now();
|
|
20817
|
+
const dedupKey = `user_input_ack:${crypto3.createHash("sha256").update(`${this.instanceId}:${content}:${receivedAt}`).digest("hex").slice(0, 24)}`;
|
|
20818
|
+
this.appendRuntimeMessage(buildChatMessage({
|
|
20819
|
+
role: "user",
|
|
20820
|
+
senderName: "User",
|
|
20821
|
+
kind: "standard",
|
|
20822
|
+
content,
|
|
20823
|
+
receivedAt,
|
|
20824
|
+
timestamp: receivedAt,
|
|
20825
|
+
source: "runtime_input_ack",
|
|
20826
|
+
meta: {
|
|
20827
|
+
runtimeInputAck: true,
|
|
20828
|
+
provider: this.type,
|
|
20829
|
+
workspace: this.workingDir
|
|
20830
|
+
}
|
|
20831
|
+
}), dedupKey);
|
|
20832
|
+
}
|
|
20768
20833
|
dispose() {
|
|
20769
20834
|
this.adapter.shutdown();
|
|
20770
20835
|
this.monitor.reset();
|
|
@@ -21374,17 +21439,28 @@ ${effect.notification.body || ""}`.trim();
|
|
|
21374
21439
|
index,
|
|
21375
21440
|
source: "parsed"
|
|
21376
21441
|
}));
|
|
21442
|
+
const getRole = (message) => typeof message.role === "string" ? message.role.trim().toLowerCase() : "";
|
|
21377
21443
|
const runtimeEntries = this.runtimeMessages.map((entry, index) => ({
|
|
21378
21444
|
message: entry.message,
|
|
21379
21445
|
index: parsedMessages.length + index,
|
|
21380
21446
|
source: "runtime",
|
|
21381
21447
|
runtimeKey: entry.key
|
|
21382
|
-
}))
|
|
21448
|
+
})).filter((entry) => {
|
|
21449
|
+
const meta = entry.message.meta && typeof entry.message.meta === "object" && !Array.isArray(entry.message.meta) ? entry.message.meta : {};
|
|
21450
|
+
if (meta.runtimeInputAck !== true) return true;
|
|
21451
|
+
const runtimeText = flattenContent(entry.message.content).replace(/\s+/g, " ").trim();
|
|
21452
|
+
if (!runtimeText) return false;
|
|
21453
|
+
return !parsedEntries.some((parsedEntry) => {
|
|
21454
|
+
const parsedRole = getRole(parsedEntry.message);
|
|
21455
|
+
if (parsedRole !== "user" && parsedRole !== "human") return false;
|
|
21456
|
+
const parsedText = flattenContent(parsedEntry.message.content).replace(/\s+/g, " ").trim();
|
|
21457
|
+
return parsedText === runtimeText;
|
|
21458
|
+
});
|
|
21459
|
+
});
|
|
21383
21460
|
const getTime = (message) => {
|
|
21384
21461
|
const value = typeof message.receivedAt === "number" ? message.receivedAt : typeof message.timestamp === "number" ? message.timestamp : 0;
|
|
21385
21462
|
return Number.isFinite(value) && value > 0 ? value : 0;
|
|
21386
21463
|
};
|
|
21387
|
-
const getRole = (message) => typeof message.role === "string" ? message.role.trim().toLowerCase() : "";
|
|
21388
21464
|
const isRuntimeOverlay = (entry) => {
|
|
21389
21465
|
if (entry.source !== "runtime") return false;
|
|
21390
21466
|
const key = typeof entry.runtimeKey === "string" ? entry.runtimeKey.trim().toLowerCase() : "";
|
|
@@ -26245,7 +26321,7 @@ init_logger();
|
|
|
26245
26321
|
import * as yaml3 from "js-yaml";
|
|
26246
26322
|
|
|
26247
26323
|
// src/commands/mesh-coordinator.ts
|
|
26248
|
-
import { createHash as
|
|
26324
|
+
import { createHash as createHash4 } from "crypto";
|
|
26249
26325
|
import * as os17 from "os";
|
|
26250
26326
|
import { isAbsolute as isAbsolute11, join as join23, resolve as resolve13 } from "path";
|
|
26251
26327
|
var DEFAULT_SERVER_NAME = "adhdev-mesh";
|
|
@@ -26388,7 +26464,7 @@ function renderMeshCoordinatorTemplate(template, values) {
|
|
|
26388
26464
|
function resolveHermesCoordinatorHome(meshId, workspace) {
|
|
26389
26465
|
const key = `${meshId || "mesh"}
|
|
26390
26466
|
${resolve13(workspace || os17.tmpdir())}`;
|
|
26391
|
-
const hash =
|
|
26467
|
+
const hash = createHash4("sha256").update(key).digest("hex").slice(0, 16);
|
|
26392
26468
|
return join23(os17.tmpdir(), `adhdev-hermes-mesh-coordinator-${hash}`);
|
|
26393
26469
|
}
|
|
26394
26470
|
function resolveMcpConfigPath(configPath, workspace) {
|