@goodtiming/baton-sdk 0.6.6 → 0.6.7
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 +17 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +17 -12
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -103,7 +103,7 @@ __export(index_exports, {
|
|
|
103
103
|
module.exports = __toCommonJS(index_exports);
|
|
104
104
|
|
|
105
105
|
// src/version.ts
|
|
106
|
-
var SDK_VERSION = "ts-0.6.
|
|
106
|
+
var SDK_VERSION = "ts-0.6.7";
|
|
107
107
|
|
|
108
108
|
// src/events.ts
|
|
109
109
|
var import_zod = require("zod");
|
|
@@ -703,9 +703,11 @@ var PROCESS_DROPS = new DropCounts();
|
|
|
703
703
|
|
|
704
704
|
// src/sequence.ts
|
|
705
705
|
var lastSequence = 0;
|
|
706
|
+
function nowMicros() {
|
|
707
|
+
return Math.floor((performance.timeOrigin + performance.now()) * 1e3);
|
|
708
|
+
}
|
|
706
709
|
function nextClockSequence() {
|
|
707
|
-
|
|
708
|
-
lastSequence = Math.max(lastSequence + 1, nowMicros);
|
|
710
|
+
lastSequence = Math.max(lastSequence + 1, nowMicros());
|
|
709
711
|
return lastSequence;
|
|
710
712
|
}
|
|
711
713
|
|
|
@@ -2678,17 +2680,20 @@ var BatonHandle = class {
|
|
|
2678
2680
|
};
|
|
2679
2681
|
|
|
2680
2682
|
// src/integrations/mcp/sessionCounter.ts
|
|
2683
|
+
var SESSION_CAP = 4096;
|
|
2681
2684
|
var SessionCounter = class {
|
|
2682
2685
|
counters = /* @__PURE__ */ new Map();
|
|
2683
|
-
/** A per-call session is numbered by the clock: a counter would
|
|
2684
|
-
*
|
|
2686
|
+
/** A per-call session is numbered by the clock: a counter would fill with
|
|
2687
|
+
* sessions that never come back and push out live ones. */
|
|
2685
2688
|
nextFor(session) {
|
|
2686
|
-
return session.perCall ? nextClockSequence() : this.next(session.sessionId);
|
|
2689
|
+
return session.perCall ? nextClockSequence() : this.next(session.sessionId, session.origin === "observed");
|
|
2687
2690
|
}
|
|
2688
|
-
next(sessionId) {
|
|
2689
|
-
const
|
|
2690
|
-
const next =
|
|
2691
|
+
next(sessionId, observed) {
|
|
2692
|
+
const previous = this.counters.get(sessionId) ?? 0;
|
|
2693
|
+
const next = observed ? Math.max(previous + 1, nowMicros()) : previous + 1;
|
|
2694
|
+
this.counters.delete(sessionId);
|
|
2691
2695
|
this.counters.set(sessionId, next);
|
|
2696
|
+
if (this.counters.size > SESSION_CAP) this.counters.delete(this.counters.keys().next().value);
|
|
2692
2697
|
return next;
|
|
2693
2698
|
}
|
|
2694
2699
|
};
|
|
@@ -2701,8 +2706,8 @@ var ServerCounter = class extends SessionCounter {
|
|
|
2701
2706
|
shared;
|
|
2702
2707
|
ownSessionId;
|
|
2703
2708
|
ownSequence = 0;
|
|
2704
|
-
next(sessionId) {
|
|
2705
|
-
return sessionId === this.ownSessionId ? ++this.ownSequence : this.shared.next(sessionId);
|
|
2709
|
+
next(sessionId, observed) {
|
|
2710
|
+
return sessionId === this.ownSessionId ? ++this.ownSequence : this.shared.next(sessionId, observed);
|
|
2706
2711
|
}
|
|
2707
2712
|
};
|
|
2708
2713
|
|
|
@@ -3797,7 +3802,7 @@ function install(server, supplied, resolved, { sentSurfaces, warned: warned3, co
|
|
|
3797
3802
|
session_id: sessionId,
|
|
3798
3803
|
session_id_origin: "minted",
|
|
3799
3804
|
consent_token: config.consentToken,
|
|
3800
|
-
sequence_number: counter2.next(sessionId),
|
|
3805
|
+
sequence_number: counter2.next(sessionId, false),
|
|
3801
3806
|
captured_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3802
3807
|
payload: {
|
|
3803
3808
|
surface_hash: digest,
|