@agentchatme/cli 0.0.137 → 0.0.138
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 +53 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4401,6 +4401,19 @@ var SyncRowSchema = external_exports.object({
|
|
|
4401
4401
|
content: external_exports.record(external_exports.unknown()).optional(),
|
|
4402
4402
|
created_at: external_exports.string().optional()
|
|
4403
4403
|
}).passthrough();
|
|
4404
|
+
function contextOf(row) {
|
|
4405
|
+
const raw = row.context;
|
|
4406
|
+
const c = raw && typeof raw === "object" ? raw : {};
|
|
4407
|
+
const sender = c.sender && typeof c.sender === "object" ? c.sender : {};
|
|
4408
|
+
const conv = c.conversation && typeof c.conversation === "object" ? c.conversation : {};
|
|
4409
|
+
return {
|
|
4410
|
+
senderDisplayName: typeof sender.display_name === "string" ? sender.display_name : null,
|
|
4411
|
+
senderKind: sender.kind === "system" ? "system" : "agent",
|
|
4412
|
+
groupName: typeof conv.group_name === "string" ? conv.group_name : null,
|
|
4413
|
+
memberCount: typeof conv.member_count === "number" ? conv.member_count : null,
|
|
4414
|
+
mentions: Array.isArray(c.mentions) ? c.mentions.filter((m) => typeof m === "string").map((m) => m.toLowerCase()) : []
|
|
4415
|
+
};
|
|
4416
|
+
}
|
|
4404
4417
|
var DEFAULT_TIMEOUT_MS = 4e3;
|
|
4405
4418
|
async function request(cfg, method, pathname, body) {
|
|
4406
4419
|
const url = cfg.apiBase.replace(/\/+$/, "") + pathname;
|
|
@@ -4491,6 +4504,27 @@ function lastDeliveryId(rows) {
|
|
|
4491
4504
|
return null;
|
|
4492
4505
|
}
|
|
4493
4506
|
|
|
4507
|
+
// src/lib/when.ts
|
|
4508
|
+
var SEC = 1e3;
|
|
4509
|
+
var MIN = 60 * SEC;
|
|
4510
|
+
var HOUR = 60 * MIN;
|
|
4511
|
+
var DAY = 24 * HOUR;
|
|
4512
|
+
function relativeAge(ms) {
|
|
4513
|
+
if (ms < 45 * SEC) return "just now";
|
|
4514
|
+
if (ms < 90 * SEC) return "1 minute ago";
|
|
4515
|
+
if (ms < 45 * MIN) return `${Math.round(ms / MIN)} minutes ago`;
|
|
4516
|
+
if (ms < 90 * MIN) return "1 hour ago";
|
|
4517
|
+
if (ms < 22 * HOUR) return `${Math.round(ms / HOUR)} hours ago`;
|
|
4518
|
+
if (ms < 36 * HOUR) return "1 day ago";
|
|
4519
|
+
return `${Math.round(ms / DAY)} days ago`;
|
|
4520
|
+
}
|
|
4521
|
+
function relativeWhen(createdAt, now2 = Date.now()) {
|
|
4522
|
+
if (!createdAt) return "";
|
|
4523
|
+
const t = Date.parse(createdAt);
|
|
4524
|
+
if (Number.isNaN(t)) return "";
|
|
4525
|
+
return relativeAge(Math.max(0, now2 - t));
|
|
4526
|
+
}
|
|
4527
|
+
|
|
4494
4528
|
// src/lib/summary.ts
|
|
4495
4529
|
var SNIPPET_MAX = 140;
|
|
4496
4530
|
function snippetOf(row) {
|
|
@@ -4500,22 +4534,31 @@ function snippetOf(row) {
|
|
|
4500
4534
|
const oneLine = text.replace(/\s+/g, " ").trim();
|
|
4501
4535
|
return oneLine.length > SNIPPET_MAX ? `${oneLine.slice(0, SNIPPET_MAX - 1)}\u2026` : oneLine;
|
|
4502
4536
|
}
|
|
4503
|
-
function digestConversations(rows) {
|
|
4537
|
+
function digestConversations(rows, selfHandle = null) {
|
|
4538
|
+
const self = selfHandle?.replace(/^@/, "").toLowerCase() ?? null;
|
|
4504
4539
|
const byConversation = /* @__PURE__ */ new Map();
|
|
4505
4540
|
for (const row of rows) {
|
|
4506
4541
|
const sender = row.sender ?? row.sender_handle ?? "unknown";
|
|
4542
|
+
const ctx = contextOf(row);
|
|
4543
|
+
const mentionsSelf = self !== null && ctx.mentions.includes(self);
|
|
4507
4544
|
const existing = byConversation.get(row.conversation_id);
|
|
4508
4545
|
if (existing) {
|
|
4509
4546
|
existing.count += 1;
|
|
4510
4547
|
if (!existing.senders.includes(sender)) existing.senders.push(sender);
|
|
4511
4548
|
existing.latestSnippet = snippetOf(row);
|
|
4549
|
+
existing.latestCreatedAt = row.created_at ?? existing.latestCreatedAt;
|
|
4550
|
+
existing.groupName = ctx.groupName ?? existing.groupName;
|
|
4551
|
+
existing.mentionsYou = existing.mentionsYou || mentionsSelf;
|
|
4512
4552
|
} else {
|
|
4513
4553
|
byConversation.set(row.conversation_id, {
|
|
4514
4554
|
conversationId: row.conversation_id,
|
|
4515
4555
|
isGroup: row.conversation_id.startsWith("grp_"),
|
|
4516
4556
|
senders: [sender],
|
|
4517
4557
|
count: 1,
|
|
4518
|
-
latestSnippet: snippetOf(row)
|
|
4558
|
+
latestSnippet: snippetOf(row),
|
|
4559
|
+
latestCreatedAt: row.created_at,
|
|
4560
|
+
groupName: ctx.groupName,
|
|
4561
|
+
mentionsYou: mentionsSelf
|
|
4519
4562
|
});
|
|
4520
4563
|
}
|
|
4521
4564
|
}
|
|
@@ -4524,13 +4567,16 @@ function digestConversations(rows) {
|
|
|
4524
4567
|
function digestLines(digests) {
|
|
4525
4568
|
return digests.map((d, i) => {
|
|
4526
4569
|
const who = d.senders.map((s) => `@${s}`).join(", ");
|
|
4527
|
-
const kind = d.isGroup ? `group ${d.conversationId}` : d.conversationId;
|
|
4570
|
+
const kind = d.isGroup ? d.groupName ? `group "${d.groupName}"` : `group ${d.conversationId}` : d.conversationId;
|
|
4528
4571
|
const count = d.count === 1 ? "1 message" : `${d.count} messages`;
|
|
4529
|
-
|
|
4572
|
+
const age = relativeWhen(d.latestCreatedAt);
|
|
4573
|
+
const recency = age ? `, latest ${age}` : "";
|
|
4574
|
+
const mention = d.mentionsYou ? " \u2014 mentions you" : "";
|
|
4575
|
+
return `${i + 1}. ${who} (${count}, ${kind}${recency}${mention}): "${d.latestSnippet}"`;
|
|
4530
4576
|
});
|
|
4531
4577
|
}
|
|
4532
4578
|
function formatSessionStart(handle, rows) {
|
|
4533
|
-
const digests = digestConversations(rows);
|
|
4579
|
+
const digests = digestConversations(rows, handle);
|
|
4534
4580
|
const total = rows.length;
|
|
4535
4581
|
const identity = handle ? `You are @${handle} on AgentChat. ` : "AgentChat: ";
|
|
4536
4582
|
const header = identity + `${total} unread message${total === 1 ? "" : "s"} in ${digests.length} conversation${digests.length === 1 ? "" : "s"}:`;
|
|
@@ -4543,7 +4589,7 @@ function formatSessionStart(handle, rows) {
|
|
|
4543
4589
|
].join("\n");
|
|
4544
4590
|
}
|
|
4545
4591
|
function formatStopPickup(handle, rows) {
|
|
4546
|
-
const digests = digestConversations(rows);
|
|
4592
|
+
const digests = digestConversations(rows, handle);
|
|
4547
4593
|
const total = rows.length;
|
|
4548
4594
|
const addressee = handle ? ` for @${handle}` : "";
|
|
4549
4595
|
return [
|
|
@@ -7057,7 +7103,7 @@ import * as fs8 from "fs";
|
|
|
7057
7103
|
import * as path9 from "path";
|
|
7058
7104
|
|
|
7059
7105
|
// src/version.ts
|
|
7060
|
-
var VERSION2 = "0.0.
|
|
7106
|
+
var VERSION2 = "0.0.138";
|
|
7061
7107
|
|
|
7062
7108
|
// src/commands/doctor.ts
|
|
7063
7109
|
function fmt(check) {
|