agentschat-mcp 0.23.0 → 0.24.0
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 +4 -2
- package/package.json +9 -2
- package/src/argcheck.ts +65 -0
- package/src/dedup.ts +41 -0
- package/src/mentions.ts +23 -0
- package/src/reconnect.ts +12 -0
- package/src/redact.ts +16 -0
- package/src/server.ts +482 -246
- package/src/timestamps.ts +39 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalize an ISO-8601 timestamp for lexical cursor comparison.
|
|
3
|
+
*
|
|
4
|
+
* The reconnect backfill compares timestamps as strings (`msgTs > afterTs`).
|
|
5
|
+
* For that to match chronological order, fractional seconds must be padded to a
|
|
6
|
+
* fixed 9 digits — AND whole-second timestamps (no fractional part) must also
|
|
7
|
+
* get a fraction, otherwise "…00.123000000Z" and "…00Z" of the same second sort
|
|
8
|
+
* wrong because '.' (0x2E) < 'Z' (0x5A), inverting the boundary comparison.
|
|
9
|
+
*
|
|
10
|
+
* mode "after" pads with 0 (floor of the second — for the strictly-after cursor);
|
|
11
|
+
* mode "before" pads with 9 (ceil of the second).
|
|
12
|
+
*
|
|
13
|
+
* Extracted from server.ts so it can be unit-tested without loading the
|
|
14
|
+
* side-effecting server entrypoint.
|
|
15
|
+
*/
|
|
16
|
+
export function normalizeTimestampForCursor(
|
|
17
|
+
ts: string | undefined,
|
|
18
|
+
mode: "before" | "after",
|
|
19
|
+
): string | undefined {
|
|
20
|
+
if (!ts || typeof ts !== "string") return ts;
|
|
21
|
+
const padChar = mode === "before" ? "9" : "0";
|
|
22
|
+
|
|
23
|
+
// Has a fractional part: pad it to 9 digits.
|
|
24
|
+
const withFrac = ts.match(/^(.*\.)(\d+)(Z)$/);
|
|
25
|
+
if (withFrac) {
|
|
26
|
+
const frac = withFrac[2];
|
|
27
|
+
if (frac.length >= 9) return ts;
|
|
28
|
+
return withFrac[1] + frac + padChar.repeat(9 - frac.length) + withFrac[3];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Whole-second timestamp: insert a 9-digit fraction so it sorts consistently
|
|
32
|
+
// against fractional timestamps of the same second.
|
|
33
|
+
const noFrac = ts.match(/^(.*\d)(Z)$/);
|
|
34
|
+
if (noFrac) {
|
|
35
|
+
return noFrac[1] + "." + padChar.repeat(9) + noFrac[2];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return ts;
|
|
39
|
+
}
|