agentchatme 1.0.21 → 1.0.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.cjs +53 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +40 -1
- package/dist/index.d.ts +40 -1
- package/dist/index.js +53 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -212,7 +212,7 @@ function createAgentChatError(body, status, headers) {
|
|
|
212
212
|
}
|
|
213
213
|
|
|
214
214
|
// src/version.ts
|
|
215
|
-
var VERSION = "1.0.
|
|
215
|
+
var VERSION = "1.0.22" ;
|
|
216
216
|
|
|
217
217
|
// src/runtime.ts
|
|
218
218
|
function detectRuntime() {
|
|
@@ -2237,6 +2237,57 @@ function constantTimeEqual(a, b) {
|
|
|
2237
2237
|
return mismatch === 0;
|
|
2238
2238
|
}
|
|
2239
2239
|
|
|
2240
|
+
// src/render.ts
|
|
2241
|
+
var SEC = 1e3;
|
|
2242
|
+
var MIN = 60 * SEC;
|
|
2243
|
+
var HOUR = 60 * MIN;
|
|
2244
|
+
var DAY = 24 * HOUR;
|
|
2245
|
+
function relativeAge(ms) {
|
|
2246
|
+
if (ms < 45 * SEC) return "just now";
|
|
2247
|
+
if (ms < 90 * SEC) return "1 minute ago";
|
|
2248
|
+
if (ms < 45 * MIN) return `${Math.round(ms / MIN)} minutes ago`;
|
|
2249
|
+
if (ms < 90 * MIN) return "1 hour ago";
|
|
2250
|
+
if (ms < 22 * HOUR) return `${Math.round(ms / HOUR)} hours ago`;
|
|
2251
|
+
if (ms < 36 * HOUR) return "1 day ago";
|
|
2252
|
+
return `${Math.round(ms / DAY)} days ago`;
|
|
2253
|
+
}
|
|
2254
|
+
function formatReceived(createdAt, now2) {
|
|
2255
|
+
const t = Date.parse(createdAt);
|
|
2256
|
+
if (Number.isNaN(t)) return "an unknown time";
|
|
2257
|
+
const iso = new Date(t).toISOString();
|
|
2258
|
+
const abs = `${iso.slice(0, 10)} ${iso.slice(11, 16)} UTC`;
|
|
2259
|
+
return `${relativeAge(Math.max(0, now2 - t))} (${abs})`;
|
|
2260
|
+
}
|
|
2261
|
+
function renderMessageContext(message, opts = {}) {
|
|
2262
|
+
const now2 = opts.now ?? Date.now();
|
|
2263
|
+
const ctx = message.context;
|
|
2264
|
+
const lines = [];
|
|
2265
|
+
const handle = ctx?.sender.handle ?? message.sender;
|
|
2266
|
+
const name = ctx?.sender.display_name;
|
|
2267
|
+
const who = name ? `${name} (@${handle})` : `@${handle}`;
|
|
2268
|
+
lines.push(`From: ${ctx?.sender.kind === "system" ? `${who}, a system agent` : who}`);
|
|
2269
|
+
const conv = ctx?.conversation;
|
|
2270
|
+
if (conv) {
|
|
2271
|
+
if (conv.type === "group") {
|
|
2272
|
+
let label = conv.group_name ? `group "${conv.group_name}"` : "group";
|
|
2273
|
+
if (conv.member_count != null) {
|
|
2274
|
+
label += ` (${conv.member_count} member${conv.member_count === 1 ? "" : "s"})`;
|
|
2275
|
+
}
|
|
2276
|
+
lines.push(`Conversation: ${label}`);
|
|
2277
|
+
} else {
|
|
2278
|
+
lines.push("Conversation: direct message");
|
|
2279
|
+
}
|
|
2280
|
+
}
|
|
2281
|
+
lines.push(`Received: ${formatReceived(message.created_at, now2)}`);
|
|
2282
|
+
const self = opts.selfHandle?.replace(/^@/, "").toLowerCase();
|
|
2283
|
+
if (self && conv?.type === "group" && (ctx?.mentions ?? []).includes(self)) {
|
|
2284
|
+
lines.push("You were @-mentioned in this message.");
|
|
2285
|
+
}
|
|
2286
|
+
const text = message.content?.text;
|
|
2287
|
+
lines.push("", text ? text : `(a ${"non-text"} message \u2014 no text body)`);
|
|
2288
|
+
return lines.join("\n");
|
|
2289
|
+
}
|
|
2290
|
+
|
|
2240
2291
|
// src/types/attachment.ts
|
|
2241
2292
|
var MAX_ATTACHMENT_SIZE = 25 * 1024 * 1024;
|
|
2242
2293
|
var ALLOWED_ATTACHMENT_MIME = [
|
|
@@ -2282,6 +2333,7 @@ exports.WebhookVerificationError = WebhookVerificationError;
|
|
|
2282
2333
|
exports.createAgentChatError = createAgentChatError;
|
|
2283
2334
|
exports.paginate = paginate;
|
|
2284
2335
|
exports.parseRetryAfter = parseRetryAfter;
|
|
2336
|
+
exports.renderMessageContext = renderMessageContext;
|
|
2285
2337
|
exports.verifyWebhook = verifyWebhook;
|
|
2286
2338
|
//# sourceMappingURL=index.cjs.map
|
|
2287
2339
|
//# sourceMappingURL=index.cjs.map
|