@pmate/cli 0.28.3 → 0.28.5
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/README.md +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +109 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -52,6 +52,7 @@ pmate im1 health
|
|
|
52
52
|
pmate im1 threads --limit 20
|
|
53
53
|
pmate im1 threads --search "titlte" --limit 5
|
|
54
54
|
pmate im1 messages --thread "<conversationId-or-thread-name>" --limit 50
|
|
55
|
+
pmate im1 pending-mentions --hours 24 --context 10
|
|
55
56
|
pmate im1 reply --thread "<conversationId-or-thread-name>" --text "hello"
|
|
56
57
|
```
|
|
57
58
|
|
package/dist/index.d.ts
CHANGED
|
@@ -628,6 +628,16 @@ type CollectCommandArgs = {
|
|
|
628
628
|
thread: string;
|
|
629
629
|
limit?: number;
|
|
630
630
|
json?: boolean;
|
|
631
|
+
} | {
|
|
632
|
+
type: Command.Collect;
|
|
633
|
+
action: "pending-mentions";
|
|
634
|
+
me: string;
|
|
635
|
+
from?: string;
|
|
636
|
+
to?: string;
|
|
637
|
+
hours: number;
|
|
638
|
+
context: number;
|
|
639
|
+
limit?: number;
|
|
640
|
+
json?: boolean;
|
|
631
641
|
} | {
|
|
632
642
|
type: Command.Collect;
|
|
633
643
|
action: "reply";
|
package/dist/index.js
CHANGED
|
@@ -12554,6 +12554,7 @@ var DevCommandHandler = class {
|
|
|
12554
12554
|
// src/commands/OssCommandHandler.ts
|
|
12555
12555
|
var import_node_fs6 = require("fs");
|
|
12556
12556
|
var import_node_path10 = __toESM(require("path"));
|
|
12557
|
+
var PARROT_STATIC_PUBLIC_BASE_URL = "https://parrot-static.pmate.chat";
|
|
12557
12558
|
var OssCommandHandler = class _OssCommandHandler {
|
|
12558
12559
|
static {
|
|
12559
12560
|
this.DEFAULT_BUCKET = "parrot-static";
|
|
@@ -12575,6 +12576,10 @@ var OssCommandHandler = class _OssCommandHandler {
|
|
|
12575
12576
|
const objectKey = this.normalizeObjectKey(args.objectKey);
|
|
12576
12577
|
const bucket = this.resolveBucket(args.bucket);
|
|
12577
12578
|
await AliyunService.uploadFile(resolvedFile, bucket, objectKey);
|
|
12579
|
+
const publicUrl = buildOssPublicUrl(bucket, objectKey);
|
|
12580
|
+
if (publicUrl) {
|
|
12581
|
+
ui.plain(publicUrl);
|
|
12582
|
+
}
|
|
12578
12583
|
}
|
|
12579
12584
|
assertFile(filePath) {
|
|
12580
12585
|
if (!(0, import_node_fs6.existsSync)(filePath)) {
|
|
@@ -12600,6 +12605,11 @@ var OssCommandHandler = class _OssCommandHandler {
|
|
|
12600
12605
|
return _OssCommandHandler.DEFAULT_BUCKET;
|
|
12601
12606
|
}
|
|
12602
12607
|
};
|
|
12608
|
+
function buildOssPublicUrl(bucket, objectKey) {
|
|
12609
|
+
if (bucket !== "parrot-static") return null;
|
|
12610
|
+
const encodedKey = objectKey.split("/").map((segment) => encodeURIComponent(segment)).join("/");
|
|
12611
|
+
return `${PARROT_STATIC_PUBLIC_BASE_URL}/${encodedKey}`;
|
|
12612
|
+
}
|
|
12603
12613
|
|
|
12604
12614
|
// src/commands/EnvCommandHandler.ts
|
|
12605
12615
|
var import_node_path11 = __toESM(require("path"));
|
|
@@ -16859,6 +16869,16 @@ var Im1BotClient = class {
|
|
|
16859
16869
|
);
|
|
16860
16870
|
return json.messages ?? [];
|
|
16861
16871
|
}
|
|
16872
|
+
async listPendingMentions(input) {
|
|
16873
|
+
const params = new URLSearchParams({
|
|
16874
|
+
me: input.me,
|
|
16875
|
+
from: input.from,
|
|
16876
|
+
to: input.to,
|
|
16877
|
+
context: String(input.context)
|
|
16878
|
+
});
|
|
16879
|
+
if (input.limit) params.set("limit", String(input.limit));
|
|
16880
|
+
return this.request(`/mentions/pending?${params.toString()}`);
|
|
16881
|
+
}
|
|
16862
16882
|
async sendMessage(input) {
|
|
16863
16883
|
return this.request("/messages/send", {
|
|
16864
16884
|
method: "POST",
|
|
@@ -17095,6 +17115,10 @@ var CollectCommandHandler = class {
|
|
|
17095
17115
|
await this.handleBotMessages(args);
|
|
17096
17116
|
return;
|
|
17097
17117
|
}
|
|
17118
|
+
if (args.action === "pending-mentions") {
|
|
17119
|
+
await this.handleBotPendingMentions(args);
|
|
17120
|
+
return;
|
|
17121
|
+
}
|
|
17098
17122
|
if (args.action === "reply") {
|
|
17099
17123
|
await this.handleBotReply(args);
|
|
17100
17124
|
return;
|
|
@@ -17138,6 +17162,32 @@ var CollectCommandHandler = class {
|
|
|
17138
17162
|
ui.plain(formatBotMessage(message));
|
|
17139
17163
|
}
|
|
17140
17164
|
}
|
|
17165
|
+
async handleBotPendingMentions(args) {
|
|
17166
|
+
const to = args.to ? new Date(args.to) : /* @__PURE__ */ new Date();
|
|
17167
|
+
const from = args.from ? new Date(args.from) : new Date(to.getTime() - args.hours * 60 * 60 * 1e3);
|
|
17168
|
+
if (from >= to) throw new Error("Expected --from to be earlier than --to");
|
|
17169
|
+
const result = await new Im1BotClient().listPendingMentions({
|
|
17170
|
+
me: args.me,
|
|
17171
|
+
from: from.toISOString(),
|
|
17172
|
+
to: to.toISOString(),
|
|
17173
|
+
context: args.context,
|
|
17174
|
+
limit: args.limit
|
|
17175
|
+
});
|
|
17176
|
+
if (args.json !== false) {
|
|
17177
|
+
ui.plain(JSON.stringify(result, null, 2));
|
|
17178
|
+
return;
|
|
17179
|
+
}
|
|
17180
|
+
if (result.mentions.length === 0) {
|
|
17181
|
+
ui.plain("No pending mentions found.");
|
|
17182
|
+
return;
|
|
17183
|
+
}
|
|
17184
|
+
for (const mention of result.mentions) {
|
|
17185
|
+
ui.plain(`${mention.sentAt} ${mention.thread?.name ?? mention.conversationId} ${mention.sender ?? "unknown"}: ${mention.body}`);
|
|
17186
|
+
for (const message of mention.context) {
|
|
17187
|
+
ui.plain(` ${message.sentAt} ${message.sender ?? "unknown"}: ${message.body}`);
|
|
17188
|
+
}
|
|
17189
|
+
}
|
|
17190
|
+
}
|
|
17141
17191
|
async handleBotReply(args) {
|
|
17142
17192
|
const client = new Im1BotClient();
|
|
17143
17193
|
const attachment = args.file ? await readOutgoingAttachment(args.file) : void 0;
|
|
@@ -27600,6 +27650,9 @@ function parseIm1Args(tokens) {
|
|
|
27600
27650
|
if (action === "messages") {
|
|
27601
27651
|
return parseIm1MessagesArgs(rest);
|
|
27602
27652
|
}
|
|
27653
|
+
if (action === "pending-mentions") {
|
|
27654
|
+
return parseIm1PendingMentionsArgs(rest);
|
|
27655
|
+
}
|
|
27603
27656
|
if (action === "reply") {
|
|
27604
27657
|
return parseIm1ReplyArgs(rest);
|
|
27605
27658
|
}
|
|
@@ -27608,6 +27661,51 @@ function parseIm1Args(tokens) {
|
|
|
27608
27661
|
}
|
|
27609
27662
|
throw new Error(`Unknown im1 action: ${action}`);
|
|
27610
27663
|
}
|
|
27664
|
+
function parseIm1PendingMentionsArgs(tokens) {
|
|
27665
|
+
const rest = [...tokens];
|
|
27666
|
+
let me = "Chef Ryan";
|
|
27667
|
+
let from;
|
|
27668
|
+
let to;
|
|
27669
|
+
let hours = 24;
|
|
27670
|
+
let context = 10;
|
|
27671
|
+
let limit;
|
|
27672
|
+
let json = true;
|
|
27673
|
+
while (rest.length > 0) {
|
|
27674
|
+
const token = rest.shift();
|
|
27675
|
+
switch (token) {
|
|
27676
|
+
case "--me":
|
|
27677
|
+
me = requireValue12(rest, token);
|
|
27678
|
+
break;
|
|
27679
|
+
case "--from":
|
|
27680
|
+
from = parseIsoDate(requireValue12(rest, token), token);
|
|
27681
|
+
break;
|
|
27682
|
+
case "--to":
|
|
27683
|
+
to = parseIsoDate(requireValue12(rest, token), token);
|
|
27684
|
+
break;
|
|
27685
|
+
case "--hours":
|
|
27686
|
+
hours = parsePositiveInt2(requireValue12(rest, token), token);
|
|
27687
|
+
break;
|
|
27688
|
+
case "--context":
|
|
27689
|
+
context = parseBoundedPositiveInt(requireValue12(rest, token), token, 50);
|
|
27690
|
+
break;
|
|
27691
|
+
case "--limit":
|
|
27692
|
+
limit = parseBoundedPositiveInt(requireValue12(rest, token), token, 500);
|
|
27693
|
+
break;
|
|
27694
|
+
case "--json":
|
|
27695
|
+
json = true;
|
|
27696
|
+
break;
|
|
27697
|
+
case "--text":
|
|
27698
|
+
json = false;
|
|
27699
|
+
break;
|
|
27700
|
+
default:
|
|
27701
|
+
throw new Error(`Unknown im1 pending-mentions option: ${token}`);
|
|
27702
|
+
}
|
|
27703
|
+
}
|
|
27704
|
+
if (from && !to || !from && to) {
|
|
27705
|
+
throw new Error("Use --from and --to together");
|
|
27706
|
+
}
|
|
27707
|
+
return { type: "collect" /* Collect */, action: "pending-mentions", me, from, to, hours, context, limit, json };
|
|
27708
|
+
}
|
|
27611
27709
|
function parseIm1HealthArgs(tokens) {
|
|
27612
27710
|
const rest = [...tokens];
|
|
27613
27711
|
let json = false;
|
|
@@ -27772,6 +27870,16 @@ function parsePositiveInt2(value, optionName) {
|
|
|
27772
27870
|
}
|
|
27773
27871
|
return parsed;
|
|
27774
27872
|
}
|
|
27873
|
+
function parseBoundedPositiveInt(value, optionName, max) {
|
|
27874
|
+
const parsed = parsePositiveInt2(value, optionName);
|
|
27875
|
+
if (parsed > max) throw new Error(`Invalid value for ${optionName}: ${value} (max ${max})`);
|
|
27876
|
+
return parsed;
|
|
27877
|
+
}
|
|
27878
|
+
function parseIsoDate(value, optionName) {
|
|
27879
|
+
const date = new Date(value);
|
|
27880
|
+
if (!Number.isFinite(date.getTime())) throw new Error(`Invalid value for ${optionName}: ${value}`);
|
|
27881
|
+
return date.toISOString();
|
|
27882
|
+
}
|
|
27775
27883
|
|
|
27776
27884
|
// src/chatRoomCommandParser.ts
|
|
27777
27885
|
function parseChatRoomArgs(tokens) {
|
|
@@ -27997,6 +28105,7 @@ var HELP_TEXT = [
|
|
|
27997
28105
|
` ${import_chalk4.default.gray(" health [--json]")}`,
|
|
27998
28106
|
` ${import_chalk4.default.gray(" threads [--q <keyword>] [--search <title>] [--limit <n>] [--json|--text]")}`,
|
|
27999
28107
|
` ${import_chalk4.default.gray(" messages --thread <name|conversation-id> [--limit <n>] [--json|--text]")}`,
|
|
28108
|
+
` ${import_chalk4.default.gray(" pending-mentions [--me <name>] [--hours <n>|--from <iso> --to <iso>] [--context <1-50>] [--limit <1-500>] [--json|--text]")}`,
|
|
28000
28109
|
` ${import_chalk4.default.gray(" reply --thread <name|conversation-id> [--text <text>] [--file|--image <path>] [--dryrun]")}`,
|
|
28001
28110
|
` ${import_chalk4.default.gray(" react --thread <name|conversation-id> --emoji <emoji> [--message <id|timestamp>] [--remove] [--dryrun]")}`,
|
|
28002
28111
|
` ${import_chalk4.default.cyan("collect")} Legacy alias for CC/yelling collection`,
|