@adhdev/daemon-core 0.8.21 → 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.mjs
CHANGED
|
@@ -6170,6 +6170,24 @@ function isRecentDuplicateSend(key) {
|
|
|
6170
6170
|
recentSendByTarget.set(key, now);
|
|
6171
6171
|
return false;
|
|
6172
6172
|
}
|
|
6173
|
+
function parseMaybeJson(value) {
|
|
6174
|
+
if (typeof value !== "string") return value;
|
|
6175
|
+
try {
|
|
6176
|
+
return JSON.parse(value);
|
|
6177
|
+
} catch {
|
|
6178
|
+
return value;
|
|
6179
|
+
}
|
|
6180
|
+
}
|
|
6181
|
+
function didProviderConfirmSend(result) {
|
|
6182
|
+
const parsed = parseMaybeJson(result);
|
|
6183
|
+
if (parsed === true) return true;
|
|
6184
|
+
if (typeof parsed === "string") {
|
|
6185
|
+
const normalized = parsed.trim().toLowerCase();
|
|
6186
|
+
return normalized === "ok" || normalized === "sent" || normalized === "success" || normalized === "true";
|
|
6187
|
+
}
|
|
6188
|
+
if (!parsed || typeof parsed !== "object") return false;
|
|
6189
|
+
return parsed.sent === true || parsed.success === true || parsed.ok === true || parsed.submitted === true || parsed.dispatched === true;
|
|
6190
|
+
}
|
|
6173
6191
|
async function handleChatHistory(h, args) {
|
|
6174
6192
|
const { agentType, offset, limit } = args;
|
|
6175
6193
|
const historySessionId = getHistorySessionId(h, args);
|
|
@@ -6352,14 +6370,8 @@ async function handleSendChat(h, args) {
|
|
|
6352
6370
|
try {
|
|
6353
6371
|
const evalResult = await h.evaluateProviderScript("sendMessage", { MESSAGE: text }, 3e4);
|
|
6354
6372
|
if (evalResult?.result) {
|
|
6355
|
-
|
|
6356
|
-
if (
|
|
6357
|
-
try {
|
|
6358
|
-
parsed = JSON.parse(parsed);
|
|
6359
|
-
} catch {
|
|
6360
|
-
}
|
|
6361
|
-
}
|
|
6362
|
-
if (parsed?.sent) {
|
|
6373
|
+
const parsed = parseMaybeJson(evalResult.result);
|
|
6374
|
+
if (didProviderConfirmSend(parsed)) {
|
|
6363
6375
|
_log(`Extension script sent OK`);
|
|
6364
6376
|
return _logSendSuccess("extension-script");
|
|
6365
6377
|
}
|
|
@@ -6391,14 +6403,8 @@ async function handleSendChat(h, args) {
|
|
|
6391
6403
|
if (sendScript) {
|
|
6392
6404
|
try {
|
|
6393
6405
|
const result = await targetCdp.evaluate(sendScript, 3e4);
|
|
6394
|
-
|
|
6395
|
-
if (
|
|
6396
|
-
try {
|
|
6397
|
-
parsed = JSON.parse(result);
|
|
6398
|
-
} catch {
|
|
6399
|
-
}
|
|
6400
|
-
}
|
|
6401
|
-
if (parsed?.sent) {
|
|
6406
|
+
const parsed = parseMaybeJson(result);
|
|
6407
|
+
if (didProviderConfirmSend(parsed)) {
|
|
6402
6408
|
_log(`sendMessage script OK`);
|
|
6403
6409
|
return _logSendSuccess("script");
|
|
6404
6410
|
}
|
|
@@ -6443,14 +6449,8 @@ async function handleSendChat(h, args) {
|
|
|
6443
6449
|
const matchText = provider.webviewMatchText;
|
|
6444
6450
|
const matchFn = matchText ? (body) => body.includes(matchText) : void 0;
|
|
6445
6451
|
const wvResult = await targetCdp.evaluateInWebviewFrame(webviewScript, matchFn);
|
|
6446
|
-
|
|
6447
|
-
if (
|
|
6448
|
-
try {
|
|
6449
|
-
wvParsed = JSON.parse(wvResult);
|
|
6450
|
-
} catch {
|
|
6451
|
-
}
|
|
6452
|
-
}
|
|
6453
|
-
if (wvParsed?.sent) {
|
|
6452
|
+
const wvParsed = parseMaybeJson(wvResult);
|
|
6453
|
+
if (didProviderConfirmSend(wvParsed)) {
|
|
6454
6454
|
_log(`webviewSendMessage OK`);
|
|
6455
6455
|
return _logSendSuccess("webview-script");
|
|
6456
6456
|
}
|
|
@@ -6472,14 +6472,8 @@ async function handleSendChat(h, args) {
|
|
|
6472
6472
|
const matchText = provider.webviewMatchText;
|
|
6473
6473
|
const matchFn = matchText ? (body) => body.includes(matchText) : void 0;
|
|
6474
6474
|
const wvResult = await targetCdp.evaluateInWebviewFrame(webviewScript, matchFn);
|
|
6475
|
-
|
|
6476
|
-
if (
|
|
6477
|
-
try {
|
|
6478
|
-
wvParsed = JSON.parse(wvResult);
|
|
6479
|
-
} catch {
|
|
6480
|
-
}
|
|
6481
|
-
}
|
|
6482
|
-
if (wvParsed?.sent) {
|
|
6475
|
+
const wvParsed = parseMaybeJson(wvResult);
|
|
6476
|
+
if (didProviderConfirmSend(wvParsed)) {
|
|
6483
6477
|
_log(`webviewSendMessage OK`);
|
|
6484
6478
|
return _logSendSuccess("webview-script");
|
|
6485
6479
|
}
|