@pmate/cli 0.24.43 → 0.24.44
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 +20 -61
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -16179,8 +16179,7 @@ var CollectCommandHandler = class {
|
|
|
16179
16179
|
if (!thread) {
|
|
16180
16180
|
throw new Error(`Thread not found: ${args.thread}`);
|
|
16181
16181
|
}
|
|
16182
|
-
await this.
|
|
16183
|
-
await this.sendReplyText(targetPage, args.text);
|
|
16182
|
+
await this.sendReplyViaConversation(targetPage, thread, args.text);
|
|
16184
16183
|
ui.success("im1 reply sent", { source: target.sourceKey, thread: thread.name });
|
|
16185
16184
|
} catch (error) {
|
|
16186
16185
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -16413,47 +16412,14 @@ var CollectCommandHandler = class {
|
|
|
16413
16412
|
await session.detach().catch(() => void 0);
|
|
16414
16413
|
}
|
|
16415
16414
|
}
|
|
16416
|
-
async
|
|
16417
|
-
const
|
|
16415
|
+
async sendReplyViaConversation(page, thread, text) {
|
|
16416
|
+
const result = await this.evaluateInPage(
|
|
16418
16417
|
page,
|
|
16419
|
-
|
|
16420
|
-
)
|
|
16421
|
-
|
|
16422
|
-
|
|
16423
|
-
}));
|
|
16424
|
-
if (!opened.ok) {
|
|
16425
|
-
await page.getByText(thread.name, { exact: true }).first().click({ timeout: 5e3 });
|
|
16426
|
-
}
|
|
16427
|
-
await page.waitForTimeout(500);
|
|
16428
|
-
}
|
|
16429
|
-
async sendReplyText(page, text) {
|
|
16430
|
-
const selectors = [
|
|
16431
|
-
'[data-testid="CompositionInput"]',
|
|
16432
|
-
'[aria-label="Message"]',
|
|
16433
|
-
'[aria-label="Write a message"]',
|
|
16434
|
-
'[contenteditable="true"]',
|
|
16435
|
-
"textarea"
|
|
16436
|
-
];
|
|
16437
|
-
let focused = false;
|
|
16438
|
-
for (const selector of selectors) {
|
|
16439
|
-
const locator = page.locator(selector).last();
|
|
16440
|
-
if (await locator.count().catch(() => 0) === 0) {
|
|
16441
|
-
continue;
|
|
16442
|
-
}
|
|
16443
|
-
await locator.click({ timeout: 3e3 }).catch(() => void 0);
|
|
16444
|
-
focused = await locator.evaluate((element) => {
|
|
16445
|
-
const activeElement = element.ownerDocument?.activeElement;
|
|
16446
|
-
return activeElement === element || element.contains(activeElement);
|
|
16447
|
-
}).catch(() => false);
|
|
16448
|
-
if (focused) {
|
|
16449
|
-
break;
|
|
16450
|
-
}
|
|
16451
|
-
}
|
|
16452
|
-
if (!focused) {
|
|
16453
|
-
throw new Error("Cannot focus CC message composer.");
|
|
16418
|
+
buildSendMessageExpr(thread.conversationId, text)
|
|
16419
|
+
);
|
|
16420
|
+
if (!result?.ok) {
|
|
16421
|
+
throw new Error(result?.reason || "Send failed");
|
|
16454
16422
|
}
|
|
16455
|
-
await page.keyboard.insertText(text);
|
|
16456
|
-
await page.keyboard.press("Enter");
|
|
16457
16423
|
}
|
|
16458
16424
|
};
|
|
16459
16425
|
async function archiveMessageImages(rootDir, sourceKey, threadKey, messages2) {
|
|
@@ -16708,31 +16674,24 @@ function buildGetMessagesByConversationExpr(conversationId, limit) {
|
|
|
16708
16674
|
}
|
|
16709
16675
|
})()`;
|
|
16710
16676
|
}
|
|
16711
|
-
function
|
|
16677
|
+
function buildSendMessageExpr(conversationId, message) {
|
|
16712
16678
|
const escapedConversationId = escapeForJs(conversationId);
|
|
16679
|
+
const escapedMessage = escapeForJs(message);
|
|
16713
16680
|
return `(async function() {
|
|
16714
16681
|
try {
|
|
16715
|
-
var
|
|
16716
|
-
|
|
16717
|
-
|
|
16718
|
-
var conversation = controller && typeof controller.get === 'function' ? controller.get(conversationId) : null;
|
|
16719
|
-
if (!conversation) return { ok: false, reason: 'Conversation not found: ' + conversationId };
|
|
16720
|
-
if (runtime.reduxActions && runtime.reduxActions.conversations) {
|
|
16721
|
-
var actions = runtime.reduxActions.conversations;
|
|
16722
|
-
if (typeof actions.showConversation === 'function') {
|
|
16723
|
-
await actions.showConversation({ conversationId: conversationId });
|
|
16724
|
-
return { ok: true };
|
|
16725
|
-
}
|
|
16726
|
-
if (typeof actions.conversationOpened === 'function') {
|
|
16727
|
-
await actions.conversationOpened({ conversationId: conversationId });
|
|
16728
|
-
return { ok: true };
|
|
16729
|
-
}
|
|
16682
|
+
var controller = globalThis.ConversationController;
|
|
16683
|
+
if (!controller || typeof controller.get !== 'function') {
|
|
16684
|
+
return { ok: false, reason: 'ConversationController unavailable' };
|
|
16730
16685
|
}
|
|
16731
|
-
|
|
16732
|
-
|
|
16733
|
-
|
|
16686
|
+
var conversation = controller.get('${escapedConversationId}');
|
|
16687
|
+
if (!conversation) return { ok: false, reason: 'Conversation not found: ${escapedConversationId}' };
|
|
16688
|
+
if (typeof conversation.sendMessage !== 'function') {
|
|
16689
|
+
return { ok: false, reason: 'Conversation sendMessage unavailable' };
|
|
16734
16690
|
}
|
|
16735
|
-
|
|
16691
|
+
var type = conversation.get ? conversation.get('type') : null;
|
|
16692
|
+
var name = conversation.get ? (conversation.get('name') || conversation.get('id')) : '${escapedConversationId}';
|
|
16693
|
+
await conversation.sendMessage('${escapedMessage}', null, null, [], null, null, null, null, null, null);
|
|
16694
|
+
return { ok: true, name: name, type: type };
|
|
16736
16695
|
} catch(e) {
|
|
16737
16696
|
return { ok: false, reason: e && e.message ? e.message : String(e) };
|
|
16738
16697
|
}
|