@goodtiming/baton-sdk 0.6.5 → 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/README.md +2 -0
- package/dist/index.cjs +28 -19
- 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 +28 -19
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -171,6 +171,8 @@ Each affected event says so, in its own field (`result_capture: "off"`), rather
|
|
|
171
171
|
|
|
172
172
|
**What is still captured, and it is deliberate:** the tool name, the duration, and whether the call failed — so failure detection, pairing and timing all keep working. The message of an error your handler **throws** is withheld too: thrown messages often echo the data a call was handling.
|
|
173
173
|
|
|
174
|
+
**What it does not withhold:** the message of a failed resource or prompt request. `resource_list_error`, `resource_read_error`, `prompt_list_error` and `prompt_get_error` keep it under `"off"`, so `withBaton` and `createBaton` print a warning saying so when you set the mode (see [Resources and prompts](#resources-and-prompts)).
|
|
175
|
+
|
|
174
176
|
**What it costs you:** anything that needs to read a response body. A call that returns `200` with a useless body can no longer be detected, and those calls sit outside the denominator of body-level analysis rather than counting as passes or failures.
|
|
175
177
|
|
|
176
178
|
## Failures your handler never saw
|
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
|
|
|
@@ -3377,10 +3382,9 @@ function installLifecycleSeam(lowLevel, ctx, spec) {
|
|
|
3377
3382
|
} catch (err) {
|
|
3378
3383
|
await fire(spec.schemas.error, {
|
|
3379
3384
|
error_type: errorTypeOf(err),
|
|
3380
|
-
// KEPT under every capture mode
|
|
3381
|
-
//
|
|
3382
|
-
//
|
|
3383
|
-
// are `scrubLifecyclePayload`'s, in that order.
|
|
3385
|
+
// KEPT under every capture mode (SPEC §11.4.4), though it can quote what
|
|
3386
|
+
// the handler fetched, so `"off"` warns instead: `warnAboutSettings`.
|
|
3387
|
+
// The scrub and the cap are `scrubLifecyclePayload`'s, in that order.
|
|
3384
3388
|
error_body: messageOf(err),
|
|
3385
3389
|
duration_ms: elapsed()
|
|
3386
3390
|
});
|
|
@@ -3717,9 +3721,9 @@ function withBaton(server, supplied = {}) {
|
|
|
3717
3721
|
return inertHandle(supplied.sink ?? new DisabledSink(), "baton-disabled");
|
|
3718
3722
|
}
|
|
3719
3723
|
const { resolved, unconfigured } = resolveInstallConfig(supplied);
|
|
3720
|
-
if (!unconfigured) warnUnusedReportSettings(resolved);
|
|
3721
3724
|
const handle = install(server, supplied, resolved, newBatonState(resolved), unconfigured);
|
|
3722
3725
|
if (unconfigured) logUnconfigured("withBaton");
|
|
3726
|
+
else warnAboutSettings(resolved);
|
|
3723
3727
|
return handle;
|
|
3724
3728
|
}
|
|
3725
3729
|
function createBaton(supplied = {}) {
|
|
@@ -3737,7 +3741,7 @@ function createBaton(supplied = {}) {
|
|
|
3737
3741
|
const { resolved, unconfigured } = resolveInstallConfig(supplied);
|
|
3738
3742
|
if (resolved.reportMode === "on") deriveAnnotationToolName(resolved.vendorId, supplied.annotationToolName);
|
|
3739
3743
|
if (unconfigured) logUnconfigured("createBaton");
|
|
3740
|
-
else
|
|
3744
|
+
else warnAboutSettings(resolved);
|
|
3741
3745
|
const sink = unconfigured ? new DisabledSink() : resolved.sink ?? new StdoutSink();
|
|
3742
3746
|
const config = {
|
|
3743
3747
|
...resolved,
|
|
@@ -3798,7 +3802,7 @@ function install(server, supplied, resolved, { sentSurfaces, warned: warned3, co
|
|
|
3798
3802
|
session_id: sessionId,
|
|
3799
3803
|
session_id_origin: "minted",
|
|
3800
3804
|
consent_token: config.consentToken,
|
|
3801
|
-
sequence_number: counter2.next(sessionId),
|
|
3805
|
+
sequence_number: counter2.next(sessionId, false),
|
|
3802
3806
|
captured_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3803
3807
|
payload: {
|
|
3804
3808
|
surface_hash: digest,
|
|
@@ -3943,13 +3947,18 @@ function reportsFor(config) {
|
|
|
3943
3947
|
if (config.reportMode !== "on") return void 0;
|
|
3944
3948
|
return { vendorDisplayName: config.vendorDisplayName ?? "" };
|
|
3945
3949
|
}
|
|
3946
|
-
function
|
|
3950
|
+
function warnAboutSettings(config) {
|
|
3947
3951
|
if (config.reportMode !== "on" && config.annotationToolName !== void 0) {
|
|
3948
3952
|
process.stderr.write(
|
|
3949
3953
|
`baton: annotationToolName=${JSON.stringify(config.annotationToolName)} has no effect with reportMode: "off", because no annotation tool is registered
|
|
3950
3954
|
`
|
|
3951
3955
|
);
|
|
3952
3956
|
}
|
|
3957
|
+
if (config.resultCaptureMode === WITHHELD) {
|
|
3958
|
+
warn(
|
|
3959
|
+
'baton: resultCaptureMode "off" does not withhold the message of a failed resource or prompt request. resource_list_error, resource_read_error, prompt_list_error and prompt_get_error carry that message, which can quote what your handler fetched. Throw a message that names the resource or prompt, not its contents.'
|
|
3960
|
+
);
|
|
3961
|
+
}
|
|
3953
3962
|
}
|
|
3954
3963
|
|
|
3955
3964
|
// src/integrations/mcp/oauthHooks.ts
|