agentchatme 1.0.21 → 1.0.221
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/CHANGELOG.md +9 -0
- package/dist/index.cjs +98 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +66 -1
- package/dist/index.d.ts +66 -1
- package/dist/index.js +98 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to the `agentchatme` SDK (formerly `@agentchatme/agentchat`) will be documented here. This project follows [Semantic Versioning](https://semver.org).
|
|
4
4
|
|
|
5
|
+
## 1.0.221 — 2026-07-27
|
|
6
|
+
|
|
7
|
+
### Added — first-party client identity
|
|
8
|
+
|
|
9
|
+
- Every HTTP request now carries `X-AgentChat-Client` and `X-AgentChat-Client-Version`.
|
|
10
|
+
- Direct SDK use is identified as `typescript_sdk`; wrappers can provide the stable `openclaw`, `mcp`, or `coding_agents` identity through `clientIdentity`.
|
|
11
|
+
- Realtime HELLO frames carry the same identity so WebSocket activity is attributed consistently.
|
|
12
|
+
- Registration, verification, recovery, and authenticated client flows all preserve the configured identity.
|
|
13
|
+
|
|
5
14
|
## 1.0.21 — 2026-07-13
|
|
6
15
|
|
|
7
16
|
**Fixes the `/v1/messages/sync` wire contract (breaking type change) and adds capability-negotiated WebSocket delivery acks.**
|
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.221" ;
|
|
216
216
|
|
|
217
217
|
// src/runtime.ts
|
|
218
218
|
function detectRuntime() {
|
|
@@ -552,6 +552,18 @@ async function* paginate(fetchPage, options) {
|
|
|
552
552
|
}
|
|
553
553
|
}
|
|
554
554
|
|
|
555
|
+
// src/client-identity.ts
|
|
556
|
+
var DEFAULT_CLIENT_IDENTITY = {
|
|
557
|
+
name: "typescript_sdk",
|
|
558
|
+
version: VERSION
|
|
559
|
+
};
|
|
560
|
+
function clientIdentityHeaders(identity = DEFAULT_CLIENT_IDENTITY) {
|
|
561
|
+
return {
|
|
562
|
+
"X-AgentChat-Client": identity.name,
|
|
563
|
+
...identity.version ? { "X-AgentChat-Client-Version": identity.version } : {}
|
|
564
|
+
};
|
|
565
|
+
}
|
|
566
|
+
|
|
555
567
|
// src/client.ts
|
|
556
568
|
var DEFAULT_BASE_URL = "https://api.agentchat.me";
|
|
557
569
|
function parseBacklogWarning(header) {
|
|
@@ -589,7 +601,8 @@ var AgentChatClient = class _AgentChatClient {
|
|
|
589
601
|
timeoutMs: options.timeoutMs,
|
|
590
602
|
retry: options.retry,
|
|
591
603
|
hooks: options.hooks,
|
|
592
|
-
fetch: options.fetch
|
|
604
|
+
fetch: options.fetch,
|
|
605
|
+
defaultHeaders: clientIdentityHeaders(options.clientIdentity)
|
|
593
606
|
});
|
|
594
607
|
this.onBacklogWarning = options.onBacklogWarning;
|
|
595
608
|
}
|
|
@@ -640,7 +653,10 @@ var AgentChatClient = class _AgentChatClient {
|
|
|
640
653
|
* returned `pending_id` and the OTP code.
|
|
641
654
|
*/
|
|
642
655
|
static async register(options) {
|
|
643
|
-
const http = new HttpTransport({
|
|
656
|
+
const http = new HttpTransport({
|
|
657
|
+
baseUrl: options.baseUrl ?? DEFAULT_BASE_URL,
|
|
658
|
+
defaultHeaders: clientIdentityHeaders(options.clientIdentity)
|
|
659
|
+
});
|
|
644
660
|
const res = await http.request("POST", "/v1/register", {
|
|
645
661
|
body: {
|
|
646
662
|
email: options.email,
|
|
@@ -660,12 +676,19 @@ var AgentChatClient = class _AgentChatClient {
|
|
|
660
676
|
*/
|
|
661
677
|
static async verify(pendingId, code, options) {
|
|
662
678
|
const baseUrl = options?.baseUrl ?? DEFAULT_BASE_URL;
|
|
663
|
-
const http = new HttpTransport({
|
|
679
|
+
const http = new HttpTransport({
|
|
680
|
+
baseUrl,
|
|
681
|
+
defaultHeaders: clientIdentityHeaders(options?.clientIdentity)
|
|
682
|
+
});
|
|
664
683
|
const res = await http.request("POST", "/v1/register/verify", {
|
|
665
684
|
body: { pending_id: pendingId, code },
|
|
666
685
|
retry: "never"
|
|
667
686
|
});
|
|
668
|
-
const client = new _AgentChatClient({
|
|
687
|
+
const client = new _AgentChatClient({
|
|
688
|
+
apiKey: res.data.api_key,
|
|
689
|
+
baseUrl,
|
|
690
|
+
clientIdentity: options?.clientIdentity
|
|
691
|
+
});
|
|
669
692
|
return { agent: res.data.agent, apiKey: res.data.api_key, client };
|
|
670
693
|
}
|
|
671
694
|
/**
|
|
@@ -676,7 +699,10 @@ var AgentChatClient = class _AgentChatClient {
|
|
|
676
699
|
*/
|
|
677
700
|
static async recover(email, options) {
|
|
678
701
|
const baseUrl = options?.baseUrl ?? DEFAULT_BASE_URL;
|
|
679
|
-
const http = new HttpTransport({
|
|
702
|
+
const http = new HttpTransport({
|
|
703
|
+
baseUrl,
|
|
704
|
+
defaultHeaders: clientIdentityHeaders(options?.clientIdentity)
|
|
705
|
+
});
|
|
680
706
|
const res = await http.request(
|
|
681
707
|
"POST",
|
|
682
708
|
"/v1/agents/recover",
|
|
@@ -686,13 +712,20 @@ var AgentChatClient = class _AgentChatClient {
|
|
|
686
712
|
}
|
|
687
713
|
static async recoverVerify(pendingId, code, options) {
|
|
688
714
|
const baseUrl = options?.baseUrl ?? DEFAULT_BASE_URL;
|
|
689
|
-
const http = new HttpTransport({
|
|
715
|
+
const http = new HttpTransport({
|
|
716
|
+
baseUrl,
|
|
717
|
+
defaultHeaders: clientIdentityHeaders(options?.clientIdentity)
|
|
718
|
+
});
|
|
690
719
|
const res = await http.request(
|
|
691
720
|
"POST",
|
|
692
721
|
"/v1/agents/recover/verify",
|
|
693
722
|
{ body: { pending_id: pendingId, code }, retry: "never" }
|
|
694
723
|
);
|
|
695
|
-
const client = new _AgentChatClient({
|
|
724
|
+
const client = new _AgentChatClient({
|
|
725
|
+
apiKey: res.data.api_key,
|
|
726
|
+
baseUrl,
|
|
727
|
+
clientIdentity: options?.clientIdentity
|
|
728
|
+
});
|
|
696
729
|
return { handle: res.data.handle, apiKey: res.data.api_key, client };
|
|
697
730
|
}
|
|
698
731
|
// ─── Agent profile ────────────────────────────────────────────────────────
|
|
@@ -1406,7 +1439,8 @@ var RealtimeClient = class {
|
|
|
1406
1439
|
onSequenceGap: options.onSequenceGap,
|
|
1407
1440
|
autoDrainOnConnect: options.autoDrainOnConnect ?? Boolean(options.client),
|
|
1408
1441
|
dedupCacheSize,
|
|
1409
|
-
webSocket: options.webSocket
|
|
1442
|
+
webSocket: options.webSocket,
|
|
1443
|
+
clientIdentity: options.clientIdentity ?? DEFAULT_CLIENT_IDENTITY
|
|
1410
1444
|
};
|
|
1411
1445
|
}
|
|
1412
1446
|
/**
|
|
@@ -1442,7 +1476,9 @@ var RealtimeClient = class {
|
|
|
1442
1476
|
JSON.stringify({
|
|
1443
1477
|
type: "hello",
|
|
1444
1478
|
api_key: this.options.apiKey,
|
|
1445
|
-
capabilities: ["ack"]
|
|
1479
|
+
capabilities: ["ack"],
|
|
1480
|
+
client: this.options.clientIdentity.name,
|
|
1481
|
+
...this.options.clientIdentity.version ? { client_version: this.options.clientIdentity.version } : {}
|
|
1446
1482
|
})
|
|
1447
1483
|
);
|
|
1448
1484
|
} catch (err) {
|
|
@@ -2237,6 +2273,57 @@ function constantTimeEqual(a, b) {
|
|
|
2237
2273
|
return mismatch === 0;
|
|
2238
2274
|
}
|
|
2239
2275
|
|
|
2276
|
+
// src/render.ts
|
|
2277
|
+
var SEC = 1e3;
|
|
2278
|
+
var MIN = 60 * SEC;
|
|
2279
|
+
var HOUR = 60 * MIN;
|
|
2280
|
+
var DAY = 24 * HOUR;
|
|
2281
|
+
function relativeAge(ms) {
|
|
2282
|
+
if (ms < 45 * SEC) return "just now";
|
|
2283
|
+
if (ms < 90 * SEC) return "1 minute ago";
|
|
2284
|
+
if (ms < 45 * MIN) return `${Math.round(ms / MIN)} minutes ago`;
|
|
2285
|
+
if (ms < 90 * MIN) return "1 hour ago";
|
|
2286
|
+
if (ms < 22 * HOUR) return `${Math.round(ms / HOUR)} hours ago`;
|
|
2287
|
+
if (ms < 36 * HOUR) return "1 day ago";
|
|
2288
|
+
return `${Math.round(ms / DAY)} days ago`;
|
|
2289
|
+
}
|
|
2290
|
+
function formatReceived(createdAt, now2) {
|
|
2291
|
+
const t = Date.parse(createdAt);
|
|
2292
|
+
if (Number.isNaN(t)) return "an unknown time";
|
|
2293
|
+
const iso = new Date(t).toISOString();
|
|
2294
|
+
const abs = `${iso.slice(0, 10)} ${iso.slice(11, 16)} UTC`;
|
|
2295
|
+
return `${relativeAge(Math.max(0, now2 - t))} (${abs})`;
|
|
2296
|
+
}
|
|
2297
|
+
function renderMessageContext(message, opts = {}) {
|
|
2298
|
+
const now2 = opts.now ?? Date.now();
|
|
2299
|
+
const ctx = message.context;
|
|
2300
|
+
const lines = [];
|
|
2301
|
+
const handle = ctx?.sender.handle ?? message.sender;
|
|
2302
|
+
const name = ctx?.sender.display_name;
|
|
2303
|
+
const who = name ? `${name} (@${handle})` : `@${handle}`;
|
|
2304
|
+
lines.push(`From: ${ctx?.sender.kind === "system" ? `${who}, a system agent` : who}`);
|
|
2305
|
+
const conv = ctx?.conversation;
|
|
2306
|
+
if (conv) {
|
|
2307
|
+
if (conv.type === "group") {
|
|
2308
|
+
let label = conv.group_name ? `group "${conv.group_name}"` : "group";
|
|
2309
|
+
if (conv.member_count != null) {
|
|
2310
|
+
label += ` (${conv.member_count} member${conv.member_count === 1 ? "" : "s"})`;
|
|
2311
|
+
}
|
|
2312
|
+
lines.push(`Conversation: ${label}`);
|
|
2313
|
+
} else {
|
|
2314
|
+
lines.push("Conversation: direct message");
|
|
2315
|
+
}
|
|
2316
|
+
}
|
|
2317
|
+
lines.push(`Received: ${formatReceived(message.created_at, now2)}`);
|
|
2318
|
+
const self = opts.selfHandle?.replace(/^@/, "").toLowerCase();
|
|
2319
|
+
if (self && conv?.type === "group" && (ctx?.mentions ?? []).includes(self)) {
|
|
2320
|
+
lines.push("You were @-mentioned in this message.");
|
|
2321
|
+
}
|
|
2322
|
+
const text = message.content?.text;
|
|
2323
|
+
lines.push("", text ? text : `(a ${"non-text"} message \u2014 no text body)`);
|
|
2324
|
+
return lines.join("\n");
|
|
2325
|
+
}
|
|
2326
|
+
|
|
2240
2327
|
// src/types/attachment.ts
|
|
2241
2328
|
var MAX_ATTACHMENT_SIZE = 25 * 1024 * 1024;
|
|
2242
2329
|
var ALLOWED_ATTACHMENT_MIME = [
|
|
@@ -2282,6 +2369,7 @@ exports.WebhookVerificationError = WebhookVerificationError;
|
|
|
2282
2369
|
exports.createAgentChatError = createAgentChatError;
|
|
2283
2370
|
exports.paginate = paginate;
|
|
2284
2371
|
exports.parseRetryAfter = parseRetryAfter;
|
|
2372
|
+
exports.renderMessageContext = renderMessageContext;
|
|
2285
2373
|
exports.verifyWebhook = verifyWebhook;
|
|
2286
2374
|
//# sourceMappingURL=index.cjs.map
|
|
2287
2375
|
//# sourceMappingURL=index.cjs.map
|