@adhdev/daemon-core 0.8.20 → 0.8.22
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 +26 -32
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +26 -32
- package/dist/index.mjs.map +1 -1
- package/node_modules/@adhdev/session-host-core/package.json +1 -1
- package/package.json +1 -1
- package/src/commands/chat-commands.ts +33 -12
package/dist/index.js
CHANGED
|
@@ -6255,6 +6255,24 @@ function isRecentDuplicateSend(key) {
|
|
|
6255
6255
|
recentSendByTarget.set(key, now);
|
|
6256
6256
|
return false;
|
|
6257
6257
|
}
|
|
6258
|
+
function parseMaybeJson(value) {
|
|
6259
|
+
if (typeof value !== "string") return value;
|
|
6260
|
+
try {
|
|
6261
|
+
return JSON.parse(value);
|
|
6262
|
+
} catch {
|
|
6263
|
+
return value;
|
|
6264
|
+
}
|
|
6265
|
+
}
|
|
6266
|
+
function didProviderConfirmSend(result) {
|
|
6267
|
+
const parsed = parseMaybeJson(result);
|
|
6268
|
+
if (parsed === true) return true;
|
|
6269
|
+
if (typeof parsed === "string") {
|
|
6270
|
+
const normalized = parsed.trim().toLowerCase();
|
|
6271
|
+
return normalized === "ok" || normalized === "sent" || normalized === "success" || normalized === "true";
|
|
6272
|
+
}
|
|
6273
|
+
if (!parsed || typeof parsed !== "object") return false;
|
|
6274
|
+
return parsed.sent === true || parsed.success === true || parsed.ok === true || parsed.submitted === true || parsed.dispatched === true;
|
|
6275
|
+
}
|
|
6258
6276
|
async function handleChatHistory(h, args) {
|
|
6259
6277
|
const { agentType, offset, limit } = args;
|
|
6260
6278
|
const historySessionId = getHistorySessionId(h, args);
|
|
@@ -6437,14 +6455,8 @@ async function handleSendChat(h, args) {
|
|
|
6437
6455
|
try {
|
|
6438
6456
|
const evalResult = await h.evaluateProviderScript("sendMessage", { MESSAGE: text }, 3e4);
|
|
6439
6457
|
if (evalResult?.result) {
|
|
6440
|
-
|
|
6441
|
-
if (
|
|
6442
|
-
try {
|
|
6443
|
-
parsed = JSON.parse(parsed);
|
|
6444
|
-
} catch {
|
|
6445
|
-
}
|
|
6446
|
-
}
|
|
6447
|
-
if (parsed?.sent) {
|
|
6458
|
+
const parsed = parseMaybeJson(evalResult.result);
|
|
6459
|
+
if (didProviderConfirmSend(parsed)) {
|
|
6448
6460
|
_log(`Extension script sent OK`);
|
|
6449
6461
|
return _logSendSuccess("extension-script");
|
|
6450
6462
|
}
|
|
@@ -6476,14 +6488,8 @@ async function handleSendChat(h, args) {
|
|
|
6476
6488
|
if (sendScript) {
|
|
6477
6489
|
try {
|
|
6478
6490
|
const result = await targetCdp.evaluate(sendScript, 3e4);
|
|
6479
|
-
|
|
6480
|
-
if (
|
|
6481
|
-
try {
|
|
6482
|
-
parsed = JSON.parse(result);
|
|
6483
|
-
} catch {
|
|
6484
|
-
}
|
|
6485
|
-
}
|
|
6486
|
-
if (parsed?.sent) {
|
|
6491
|
+
const parsed = parseMaybeJson(result);
|
|
6492
|
+
if (didProviderConfirmSend(parsed)) {
|
|
6487
6493
|
_log(`sendMessage script OK`);
|
|
6488
6494
|
return _logSendSuccess("script");
|
|
6489
6495
|
}
|
|
@@ -6528,14 +6534,8 @@ async function handleSendChat(h, args) {
|
|
|
6528
6534
|
const matchText = provider.webviewMatchText;
|
|
6529
6535
|
const matchFn = matchText ? (body) => body.includes(matchText) : void 0;
|
|
6530
6536
|
const wvResult = await targetCdp.evaluateInWebviewFrame(webviewScript, matchFn);
|
|
6531
|
-
|
|
6532
|
-
if (
|
|
6533
|
-
try {
|
|
6534
|
-
wvParsed = JSON.parse(wvResult);
|
|
6535
|
-
} catch {
|
|
6536
|
-
}
|
|
6537
|
-
}
|
|
6538
|
-
if (wvParsed?.sent) {
|
|
6537
|
+
const wvParsed = parseMaybeJson(wvResult);
|
|
6538
|
+
if (didProviderConfirmSend(wvParsed)) {
|
|
6539
6539
|
_log(`webviewSendMessage OK`);
|
|
6540
6540
|
return _logSendSuccess("webview-script");
|
|
6541
6541
|
}
|
|
@@ -6557,14 +6557,8 @@ async function handleSendChat(h, args) {
|
|
|
6557
6557
|
const matchText = provider.webviewMatchText;
|
|
6558
6558
|
const matchFn = matchText ? (body) => body.includes(matchText) : void 0;
|
|
6559
6559
|
const wvResult = await targetCdp.evaluateInWebviewFrame(webviewScript, matchFn);
|
|
6560
|
-
|
|
6561
|
-
if (
|
|
6562
|
-
try {
|
|
6563
|
-
wvParsed = JSON.parse(wvResult);
|
|
6564
|
-
} catch {
|
|
6565
|
-
}
|
|
6566
|
-
}
|
|
6567
|
-
if (wvParsed?.sent) {
|
|
6560
|
+
const wvParsed = parseMaybeJson(wvResult);
|
|
6561
|
+
if (didProviderConfirmSend(wvParsed)) {
|
|
6568
6562
|
_log(`webviewSendMessage OK`);
|
|
6569
6563
|
return _logSendSuccess("webview-script");
|
|
6570
6564
|
}
|