@goodtiming/baton-sdk 0.3.4 → 0.3.6
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 -2
- package/dist/index.cjs +146 -62
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +43 -41
- package/dist/index.d.ts +43 -41
- package/dist/index.js +145 -61
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
|
|
3
|
-
declare const SDK_VERSION = "ts-0.3.
|
|
3
|
+
declare const SDK_VERSION = "ts-0.3.6";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Zod schemas + TS types for the Baton event stream per SPEC §11.4.
|
|
@@ -123,7 +123,7 @@ declare const ToolCallStartEventSchema: z.ZodObject<{
|
|
|
123
123
|
consent_token: z.ZodString;
|
|
124
124
|
sdk_version: z.ZodDefault<z.ZodString>;
|
|
125
125
|
agent_runtime: z.ZodDefault<z.ZodString>;
|
|
126
|
-
|
|
126
|
+
principal_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
127
127
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
128
128
|
runtime_meta: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
129
129
|
}, z.core.$strict>;
|
|
@@ -144,7 +144,7 @@ declare const ToolCallEndEventSchema: z.ZodObject<{
|
|
|
144
144
|
consent_token: z.ZodString;
|
|
145
145
|
sdk_version: z.ZodDefault<z.ZodString>;
|
|
146
146
|
agent_runtime: z.ZodDefault<z.ZodString>;
|
|
147
|
-
|
|
147
|
+
principal_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
148
148
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
149
149
|
runtime_meta: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
150
150
|
}, z.core.$strict>;
|
|
@@ -166,7 +166,7 @@ declare const ToolCallErrorEventSchema: z.ZodObject<{
|
|
|
166
166
|
consent_token: z.ZodString;
|
|
167
167
|
sdk_version: z.ZodDefault<z.ZodString>;
|
|
168
168
|
agent_runtime: z.ZodDefault<z.ZodString>;
|
|
169
|
-
|
|
169
|
+
principal_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
170
170
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
171
171
|
runtime_meta: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
172
172
|
}, z.core.$strict>;
|
|
@@ -192,7 +192,7 @@ declare const AnnotationEventSchema: z.ZodObject<{
|
|
|
192
192
|
consent_token: z.ZodString;
|
|
193
193
|
sdk_version: z.ZodDefault<z.ZodString>;
|
|
194
194
|
agent_runtime: z.ZodDefault<z.ZodString>;
|
|
195
|
-
|
|
195
|
+
principal_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
196
196
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
197
197
|
runtime_meta: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
198
198
|
}, z.core.$strict>;
|
|
@@ -216,7 +216,7 @@ declare const SurfaceSnapshotEventSchema: z.ZodObject<{
|
|
|
216
216
|
consent_token: z.ZodString;
|
|
217
217
|
sdk_version: z.ZodDefault<z.ZodString>;
|
|
218
218
|
agent_runtime: z.ZodDefault<z.ZodString>;
|
|
219
|
-
|
|
219
|
+
principal_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
220
220
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
221
221
|
runtime_meta: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
222
222
|
}, z.core.$strict>;
|
|
@@ -240,7 +240,7 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
240
240
|
consent_token: z.ZodString;
|
|
241
241
|
sdk_version: z.ZodDefault<z.ZodString>;
|
|
242
242
|
agent_runtime: z.ZodDefault<z.ZodString>;
|
|
243
|
-
|
|
243
|
+
principal_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
244
244
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
245
245
|
runtime_meta: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
246
246
|
}, z.core.$strict>, z.ZodObject<{
|
|
@@ -259,7 +259,7 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
259
259
|
consent_token: z.ZodString;
|
|
260
260
|
sdk_version: z.ZodDefault<z.ZodString>;
|
|
261
261
|
agent_runtime: z.ZodDefault<z.ZodString>;
|
|
262
|
-
|
|
262
|
+
principal_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
263
263
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
264
264
|
runtime_meta: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
265
265
|
}, z.core.$strict>, z.ZodObject<{
|
|
@@ -279,7 +279,7 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
279
279
|
consent_token: z.ZodString;
|
|
280
280
|
sdk_version: z.ZodDefault<z.ZodString>;
|
|
281
281
|
agent_runtime: z.ZodDefault<z.ZodString>;
|
|
282
|
-
|
|
282
|
+
principal_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
283
283
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
284
284
|
runtime_meta: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
285
285
|
}, z.core.$strict>, z.ZodObject<{
|
|
@@ -303,7 +303,7 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
303
303
|
consent_token: z.ZodString;
|
|
304
304
|
sdk_version: z.ZodDefault<z.ZodString>;
|
|
305
305
|
agent_runtime: z.ZodDefault<z.ZodString>;
|
|
306
|
-
|
|
306
|
+
principal_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
307
307
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
308
308
|
runtime_meta: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
309
309
|
}, z.core.$strict>, z.ZodObject<{
|
|
@@ -325,7 +325,7 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
325
325
|
consent_token: z.ZodString;
|
|
326
326
|
sdk_version: z.ZodDefault<z.ZodString>;
|
|
327
327
|
agent_runtime: z.ZodDefault<z.ZodString>;
|
|
328
|
-
|
|
328
|
+
principal_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
329
329
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
330
330
|
runtime_meta: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
331
331
|
}, z.core.$strict>], "event_type">;
|
|
@@ -547,22 +547,22 @@ declare class HttpSink implements Sink {
|
|
|
547
547
|
* rotation, so a vendor assertion must never be mistakable for an
|
|
548
548
|
* attestation (SPEC §11.4's registered-set rule). */
|
|
549
549
|
declare const VENDOR_HASH_SCHEME = "v1";
|
|
550
|
-
declare const
|
|
551
|
-
declare const
|
|
552
|
-
type
|
|
553
|
-
/** A raw, UNHASHED
|
|
550
|
+
declare const PRINCIPAL_ID_MODE_HASHED = "hashed";
|
|
551
|
+
declare const PRINCIPAL_ID_MODE_RAW = "raw";
|
|
552
|
+
type PrincipalIdMode = typeof PRINCIPAL_ID_MODE_HASHED | typeof PRINCIPAL_ID_MODE_RAW;
|
|
553
|
+
/** A raw, UNHASHED principal, as a resolver produced it. */
|
|
554
554
|
interface Principal {
|
|
555
|
-
/** The subject — a stable
|
|
555
|
+
/** The subject — a stable identifier from the vendor's own
|
|
556
556
|
* system. Never an application id: that names the app and is identical for
|
|
557
557
|
* every one of its users, which merges them into one actor. */
|
|
558
|
-
|
|
558
|
+
principalId: string;
|
|
559
559
|
/** The issuing authority, where one exists (the OIDC `iss`). Folded into
|
|
560
560
|
* the hash because a subject is unique only within the provider that minted
|
|
561
561
|
* it, so two identity providers behind one vendor can hand the same subject
|
|
562
562
|
* to different people. */
|
|
563
563
|
issuer?: string | null | undefined;
|
|
564
564
|
}
|
|
565
|
-
/** HMAC-SHA256 a raw principal into a console-safe, per-tenant `
|
|
565
|
+
/** HMAC-SHA256 a raw principal into a console-safe, per-tenant `principal_id`.
|
|
566
566
|
*
|
|
567
567
|
* `tenantId` is folded into the HMAC MESSAGE (not just the key) so the same
|
|
568
568
|
* principal under two tenants can never collide or be cross-tenant-correlated.
|
|
@@ -578,7 +578,7 @@ interface Principal {
|
|
|
578
578
|
* form** — the append-only message layout is what guarantees it, and every
|
|
579
579
|
* hash baton-proxy and baton-extmcp have produced since 0.5.0 was issuer-less.
|
|
580
580
|
*/
|
|
581
|
-
declare function
|
|
581
|
+
declare function hashPrincipalId(rawPrincipal: string, options: {
|
|
582
582
|
tenantId: string;
|
|
583
583
|
key: Uint8Array | string;
|
|
584
584
|
issuer?: string | null | undefined;
|
|
@@ -594,12 +594,12 @@ declare function hashUserId(rawPrincipal: string, options: {
|
|
|
594
594
|
scheme: string;
|
|
595
595
|
}): string;
|
|
596
596
|
|
|
597
|
-
/** `BatonConfig.
|
|
597
|
+
/** `BatonConfig.resolvePrincipal` — the ASSERTED identity provenance.
|
|
598
598
|
*
|
|
599
599
|
* The TypeScript half of Python's `integrations/identity_adapter.py`, built to
|
|
600
|
-
* close register D6: `user_id`
|
|
601
|
-
* NOTHING could populate it, so a partition that
|
|
602
|
-
* not a partition.
|
|
600
|
+
* close register D6: the field (`user_id` until 0.3.5) had been on this SDK's
|
|
601
|
+
* envelope since 0.3.0 and NOTHING could populate it, so a partition that
|
|
602
|
+
* works on one of two SDKs is not a partition.
|
|
603
603
|
*
|
|
604
604
|
* **Hook only — there is deliberately no attested (`h1:`) rung here yet.**
|
|
605
605
|
* Python reads `claims["sub"]` off a verified access token; TypeScript's
|
|
@@ -611,7 +611,7 @@ declare function hashUserId(rawPrincipal: string, options: {
|
|
|
611
611
|
* as a divergence rather than filled with a guess.
|
|
612
612
|
*/
|
|
613
613
|
|
|
614
|
-
/** What a vendor's `
|
|
614
|
+
/** What a vendor's `resolvePrincipal` hook is handed.
|
|
615
615
|
*
|
|
616
616
|
* Adapter-neutral BY CONSTRUCTION rather than by convention — the peers' own
|
|
617
617
|
* handler-context objects differ in shape between the two majors, and this
|
|
@@ -622,7 +622,7 @@ declare function hashUserId(rawPrincipal: string, options: {
|
|
|
622
622
|
* That is the divergence handed to the vendor as `any`; this is the divergence
|
|
623
623
|
* absorbed by us.
|
|
624
624
|
*/
|
|
625
|
-
interface
|
|
625
|
+
interface PrincipalResolutionContext {
|
|
626
626
|
/** The call's HTTP headers, case-insensitive on BOTH majors — see
|
|
627
627
|
* `extraHeaders` for the two shapes it reconciles.
|
|
628
628
|
*
|
|
@@ -642,7 +642,7 @@ interface UserResolutionContext {
|
|
|
642
642
|
}
|
|
643
643
|
/** A vendor's per-request identity resolver. Sync or async; returning `null`
|
|
644
644
|
* means "no opinion about this caller", which is not an error. */
|
|
645
|
-
type
|
|
645
|
+
type ResolvePrincipalHook = (context: PrincipalResolutionContext) => Principal | null | Promise<Principal | null>;
|
|
646
646
|
|
|
647
647
|
/**
|
|
648
648
|
* `BatonConfig` — vendor-side configuration for `withBaton`. A trimmed
|
|
@@ -740,48 +740,50 @@ interface BatonConfig {
|
|
|
740
740
|
* written into documentation, a prompt or a script. */
|
|
741
741
|
annotationToolName?: string;
|
|
742
742
|
/** Per-tool intent-param injection (mirrors baton-extmcp's vendor-neutral
|
|
743
|
-
* naming). `"
|
|
744
|
-
* string params on every wrapped tool's advertised schema
|
|
745
|
-
*
|
|
746
|
-
*
|
|
743
|
+
* naming). `"required"` (default) injects `user_goal`/`expected_result`/
|
|
744
|
+
* `overall_task` string params on every wrapped tool's advertised schema
|
|
745
|
+
* and ADVERTISES `user_goal` as required in `tools/list`, without enforcing
|
|
746
|
+
* it: a call that omits it still reaches your handler, and its event simply
|
|
747
|
+
* carries no intent. `"optional"` injects the same params and advertises
|
|
748
|
+
* none of them as required. `"off"` disables injection. The params are
|
|
747
749
|
* stripped before the vendor handler runs, so the tool never sees them.
|
|
748
750
|
* This is what captures intent on runtimes that drop `instructions`
|
|
749
751
|
* (notably Claude Desktop) — where the annotation tool alone yields
|
|
750
752
|
* nothing. A tool registered with no `inputSchema` at all is left alone
|
|
751
753
|
* regardless of this setting (see `schemaCompat.injectGoalParams`). */
|
|
752
754
|
intentParamMode?: "optional" | "required" | "off";
|
|
753
|
-
/** Per-request
|
|
754
|
-
* envelope's `
|
|
755
|
+
/** Per-request principal identity — the ASSERTED provenance behind the
|
|
756
|
+
* envelope's `principal_id` (SPEC §11.4 rung 0), tagged `v1:`.
|
|
755
757
|
*
|
|
756
758
|
* Called on every captured tool call and on the annotation tool, with an
|
|
757
|
-
* adapter-neutral {@link
|
|
759
|
+
* adapter-neutral {@link PrincipalResolutionContext}: headers folded to ONE
|
|
758
760
|
* case-insensitive shape across both SDK majors, the call's `_meta`, the
|
|
759
761
|
* tool name, and the arguments the vendor's own handler will see. Return a
|
|
760
762
|
* `Principal`, or `null` for "no opinion about this caller".
|
|
761
763
|
*
|
|
762
764
|
* **This is the only identity mechanism on this arm.** MCP auth is HTTP
|
|
763
765
|
* middleware, so a stdio server has no token at all; and unlike Python, no
|
|
764
|
-
* attested rung is implemented here — see `
|
|
766
|
+
* attested rung is implemented here — see `principalResolution.ts` for why
|
|
765
767
|
* (TypeScript's `AuthInfo` carries no `claims`).
|
|
766
768
|
*
|
|
767
769
|
* Never fails a tool call: a hook that throws or returns junk yields an
|
|
768
770
|
* anonymous call. ⚠ It is awaited INLINE with no timeout — a blocking hook
|
|
769
771
|
* stalls its own request. */
|
|
770
|
-
|
|
772
|
+
resolvePrincipal?: ResolvePrincipalHook;
|
|
771
773
|
/** `"hashed"` (default) emits a `v1:` per-tenant HMAC pseudonym; `"raw"`
|
|
772
774
|
* emits the subject VERBATIM.
|
|
773
775
|
*
|
|
774
|
-
* `"raw"` puts real
|
|
776
|
+
* `"raw"` puts real identity in the collector's database and is the
|
|
775
777
|
* vendor's deliberate choice — which is why SPEC §11.4 tells a consumer
|
|
776
778
|
* never to treat this field as anonymous. */
|
|
777
|
-
|
|
779
|
+
principalIdMode?: "hashed" | "raw";
|
|
778
780
|
/** The HMAC secret for hashed mode. Resolved explicit →
|
|
779
|
-
* `
|
|
781
|
+
* `BATON_PRINCIPAL_ID_HMAC_KEY` → unset.
|
|
780
782
|
*
|
|
781
|
-
* ⚠ **With none set, hashed mode DROPS `
|
|
783
|
+
* ⚠ **With none set, hashed mode DROPS `principal_id` rather than falling back to
|
|
782
784
|
* raw.** The fallback would be a residency breach that looks like success:
|
|
783
785
|
* the field present, populated, and carrying the subject verbatim. */
|
|
784
|
-
|
|
786
|
+
principalIdHmacKey?: string | Uint8Array;
|
|
785
787
|
}
|
|
786
788
|
|
|
787
789
|
/**
|
|
@@ -906,4 +908,4 @@ interface SupportedMcpServer {
|
|
|
906
908
|
/** Install Baton into an `McpServer`. See module docstring for usage. */
|
|
907
909
|
declare function withBaton(server: SupportedMcpServer, supplied?: BatonConfig): BatonHandle;
|
|
908
910
|
|
|
909
|
-
export { type AnnotationEvent, AnnotationEventSchema, type AnnotationPayload, AnnotationPayloadSchema, type BatonConfig, BatonHandle, DEFAULT_CONSENT_TOKEN, DEPTH_LIMIT, type Event, EventSchema, type EventType, EventTypeSchema, HttpSink, type HttpSinkOptions, type Principal, type
|
|
911
|
+
export { type AnnotationEvent, AnnotationEventSchema, type AnnotationPayload, AnnotationPayloadSchema, type BatonConfig, BatonHandle, DEFAULT_CONSENT_TOKEN, DEPTH_LIMIT, type Event, EventSchema, type EventType, EventTypeSchema, HttpSink, type HttpSinkOptions, type Principal, type PrincipalIdMode, type PrincipalResolutionContext, type ResolvePrincipalHook, SDK_VERSION, Scrubber, type Sink, StdoutSink, type StdoutSinkOptions, type SupportedMcpServer, type SurfaceSnapshotEvent, SurfaceSnapshotEventSchema, type SurfaceSnapshotPayload, SurfaceSnapshotPayloadSchema, type ToolCallEndEvent, ToolCallEndEventSchema, type ToolCallEndPayload, ToolCallEndPayloadSchema, type ToolCallErrorEvent, ToolCallErrorEventSchema, type ToolCallErrorPayload, ToolCallErrorPayloadSchema, type ToolCallStartEvent, ToolCallStartEventSchema, type ToolCallStartPayload, ToolCallStartPayloadSchema, VENDOR_HASH_SCHEME, hashPrincipalId, identityScrub, safeWrite, withBaton };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
|
|
3
|
-
declare const SDK_VERSION = "ts-0.3.
|
|
3
|
+
declare const SDK_VERSION = "ts-0.3.6";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Zod schemas + TS types for the Baton event stream per SPEC §11.4.
|
|
@@ -123,7 +123,7 @@ declare const ToolCallStartEventSchema: z.ZodObject<{
|
|
|
123
123
|
consent_token: z.ZodString;
|
|
124
124
|
sdk_version: z.ZodDefault<z.ZodString>;
|
|
125
125
|
agent_runtime: z.ZodDefault<z.ZodString>;
|
|
126
|
-
|
|
126
|
+
principal_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
127
127
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
128
128
|
runtime_meta: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
129
129
|
}, z.core.$strict>;
|
|
@@ -144,7 +144,7 @@ declare const ToolCallEndEventSchema: z.ZodObject<{
|
|
|
144
144
|
consent_token: z.ZodString;
|
|
145
145
|
sdk_version: z.ZodDefault<z.ZodString>;
|
|
146
146
|
agent_runtime: z.ZodDefault<z.ZodString>;
|
|
147
|
-
|
|
147
|
+
principal_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
148
148
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
149
149
|
runtime_meta: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
150
150
|
}, z.core.$strict>;
|
|
@@ -166,7 +166,7 @@ declare const ToolCallErrorEventSchema: z.ZodObject<{
|
|
|
166
166
|
consent_token: z.ZodString;
|
|
167
167
|
sdk_version: z.ZodDefault<z.ZodString>;
|
|
168
168
|
agent_runtime: z.ZodDefault<z.ZodString>;
|
|
169
|
-
|
|
169
|
+
principal_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
170
170
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
171
171
|
runtime_meta: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
172
172
|
}, z.core.$strict>;
|
|
@@ -192,7 +192,7 @@ declare const AnnotationEventSchema: z.ZodObject<{
|
|
|
192
192
|
consent_token: z.ZodString;
|
|
193
193
|
sdk_version: z.ZodDefault<z.ZodString>;
|
|
194
194
|
agent_runtime: z.ZodDefault<z.ZodString>;
|
|
195
|
-
|
|
195
|
+
principal_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
196
196
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
197
197
|
runtime_meta: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
198
198
|
}, z.core.$strict>;
|
|
@@ -216,7 +216,7 @@ declare const SurfaceSnapshotEventSchema: z.ZodObject<{
|
|
|
216
216
|
consent_token: z.ZodString;
|
|
217
217
|
sdk_version: z.ZodDefault<z.ZodString>;
|
|
218
218
|
agent_runtime: z.ZodDefault<z.ZodString>;
|
|
219
|
-
|
|
219
|
+
principal_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
220
220
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
221
221
|
runtime_meta: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
222
222
|
}, z.core.$strict>;
|
|
@@ -240,7 +240,7 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
240
240
|
consent_token: z.ZodString;
|
|
241
241
|
sdk_version: z.ZodDefault<z.ZodString>;
|
|
242
242
|
agent_runtime: z.ZodDefault<z.ZodString>;
|
|
243
|
-
|
|
243
|
+
principal_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
244
244
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
245
245
|
runtime_meta: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
246
246
|
}, z.core.$strict>, z.ZodObject<{
|
|
@@ -259,7 +259,7 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
259
259
|
consent_token: z.ZodString;
|
|
260
260
|
sdk_version: z.ZodDefault<z.ZodString>;
|
|
261
261
|
agent_runtime: z.ZodDefault<z.ZodString>;
|
|
262
|
-
|
|
262
|
+
principal_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
263
263
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
264
264
|
runtime_meta: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
265
265
|
}, z.core.$strict>, z.ZodObject<{
|
|
@@ -279,7 +279,7 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
279
279
|
consent_token: z.ZodString;
|
|
280
280
|
sdk_version: z.ZodDefault<z.ZodString>;
|
|
281
281
|
agent_runtime: z.ZodDefault<z.ZodString>;
|
|
282
|
-
|
|
282
|
+
principal_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
283
283
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
284
284
|
runtime_meta: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
285
285
|
}, z.core.$strict>, z.ZodObject<{
|
|
@@ -303,7 +303,7 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
303
303
|
consent_token: z.ZodString;
|
|
304
304
|
sdk_version: z.ZodDefault<z.ZodString>;
|
|
305
305
|
agent_runtime: z.ZodDefault<z.ZodString>;
|
|
306
|
-
|
|
306
|
+
principal_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
307
307
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
308
308
|
runtime_meta: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
309
309
|
}, z.core.$strict>, z.ZodObject<{
|
|
@@ -325,7 +325,7 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
325
325
|
consent_token: z.ZodString;
|
|
326
326
|
sdk_version: z.ZodDefault<z.ZodString>;
|
|
327
327
|
agent_runtime: z.ZodDefault<z.ZodString>;
|
|
328
|
-
|
|
328
|
+
principal_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
329
329
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
330
330
|
runtime_meta: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
331
331
|
}, z.core.$strict>], "event_type">;
|
|
@@ -547,22 +547,22 @@ declare class HttpSink implements Sink {
|
|
|
547
547
|
* rotation, so a vendor assertion must never be mistakable for an
|
|
548
548
|
* attestation (SPEC §11.4's registered-set rule). */
|
|
549
549
|
declare const VENDOR_HASH_SCHEME = "v1";
|
|
550
|
-
declare const
|
|
551
|
-
declare const
|
|
552
|
-
type
|
|
553
|
-
/** A raw, UNHASHED
|
|
550
|
+
declare const PRINCIPAL_ID_MODE_HASHED = "hashed";
|
|
551
|
+
declare const PRINCIPAL_ID_MODE_RAW = "raw";
|
|
552
|
+
type PrincipalIdMode = typeof PRINCIPAL_ID_MODE_HASHED | typeof PRINCIPAL_ID_MODE_RAW;
|
|
553
|
+
/** A raw, UNHASHED principal, as a resolver produced it. */
|
|
554
554
|
interface Principal {
|
|
555
|
-
/** The subject — a stable
|
|
555
|
+
/** The subject — a stable identifier from the vendor's own
|
|
556
556
|
* system. Never an application id: that names the app and is identical for
|
|
557
557
|
* every one of its users, which merges them into one actor. */
|
|
558
|
-
|
|
558
|
+
principalId: string;
|
|
559
559
|
/** The issuing authority, where one exists (the OIDC `iss`). Folded into
|
|
560
560
|
* the hash because a subject is unique only within the provider that minted
|
|
561
561
|
* it, so two identity providers behind one vendor can hand the same subject
|
|
562
562
|
* to different people. */
|
|
563
563
|
issuer?: string | null | undefined;
|
|
564
564
|
}
|
|
565
|
-
/** HMAC-SHA256 a raw principal into a console-safe, per-tenant `
|
|
565
|
+
/** HMAC-SHA256 a raw principal into a console-safe, per-tenant `principal_id`.
|
|
566
566
|
*
|
|
567
567
|
* `tenantId` is folded into the HMAC MESSAGE (not just the key) so the same
|
|
568
568
|
* principal under two tenants can never collide or be cross-tenant-correlated.
|
|
@@ -578,7 +578,7 @@ interface Principal {
|
|
|
578
578
|
* form** — the append-only message layout is what guarantees it, and every
|
|
579
579
|
* hash baton-proxy and baton-extmcp have produced since 0.5.0 was issuer-less.
|
|
580
580
|
*/
|
|
581
|
-
declare function
|
|
581
|
+
declare function hashPrincipalId(rawPrincipal: string, options: {
|
|
582
582
|
tenantId: string;
|
|
583
583
|
key: Uint8Array | string;
|
|
584
584
|
issuer?: string | null | undefined;
|
|
@@ -594,12 +594,12 @@ declare function hashUserId(rawPrincipal: string, options: {
|
|
|
594
594
|
scheme: string;
|
|
595
595
|
}): string;
|
|
596
596
|
|
|
597
|
-
/** `BatonConfig.
|
|
597
|
+
/** `BatonConfig.resolvePrincipal` — the ASSERTED identity provenance.
|
|
598
598
|
*
|
|
599
599
|
* The TypeScript half of Python's `integrations/identity_adapter.py`, built to
|
|
600
|
-
* close register D6: `user_id`
|
|
601
|
-
* NOTHING could populate it, so a partition that
|
|
602
|
-
* not a partition.
|
|
600
|
+
* close register D6: the field (`user_id` until 0.3.5) had been on this SDK's
|
|
601
|
+
* envelope since 0.3.0 and NOTHING could populate it, so a partition that
|
|
602
|
+
* works on one of two SDKs is not a partition.
|
|
603
603
|
*
|
|
604
604
|
* **Hook only — there is deliberately no attested (`h1:`) rung here yet.**
|
|
605
605
|
* Python reads `claims["sub"]` off a verified access token; TypeScript's
|
|
@@ -611,7 +611,7 @@ declare function hashUserId(rawPrincipal: string, options: {
|
|
|
611
611
|
* as a divergence rather than filled with a guess.
|
|
612
612
|
*/
|
|
613
613
|
|
|
614
|
-
/** What a vendor's `
|
|
614
|
+
/** What a vendor's `resolvePrincipal` hook is handed.
|
|
615
615
|
*
|
|
616
616
|
* Adapter-neutral BY CONSTRUCTION rather than by convention — the peers' own
|
|
617
617
|
* handler-context objects differ in shape between the two majors, and this
|
|
@@ -622,7 +622,7 @@ declare function hashUserId(rawPrincipal: string, options: {
|
|
|
622
622
|
* That is the divergence handed to the vendor as `any`; this is the divergence
|
|
623
623
|
* absorbed by us.
|
|
624
624
|
*/
|
|
625
|
-
interface
|
|
625
|
+
interface PrincipalResolutionContext {
|
|
626
626
|
/** The call's HTTP headers, case-insensitive on BOTH majors — see
|
|
627
627
|
* `extraHeaders` for the two shapes it reconciles.
|
|
628
628
|
*
|
|
@@ -642,7 +642,7 @@ interface UserResolutionContext {
|
|
|
642
642
|
}
|
|
643
643
|
/** A vendor's per-request identity resolver. Sync or async; returning `null`
|
|
644
644
|
* means "no opinion about this caller", which is not an error. */
|
|
645
|
-
type
|
|
645
|
+
type ResolvePrincipalHook = (context: PrincipalResolutionContext) => Principal | null | Promise<Principal | null>;
|
|
646
646
|
|
|
647
647
|
/**
|
|
648
648
|
* `BatonConfig` — vendor-side configuration for `withBaton`. A trimmed
|
|
@@ -740,48 +740,50 @@ interface BatonConfig {
|
|
|
740
740
|
* written into documentation, a prompt or a script. */
|
|
741
741
|
annotationToolName?: string;
|
|
742
742
|
/** Per-tool intent-param injection (mirrors baton-extmcp's vendor-neutral
|
|
743
|
-
* naming). `"
|
|
744
|
-
* string params on every wrapped tool's advertised schema
|
|
745
|
-
*
|
|
746
|
-
*
|
|
743
|
+
* naming). `"required"` (default) injects `user_goal`/`expected_result`/
|
|
744
|
+
* `overall_task` string params on every wrapped tool's advertised schema
|
|
745
|
+
* and ADVERTISES `user_goal` as required in `tools/list`, without enforcing
|
|
746
|
+
* it: a call that omits it still reaches your handler, and its event simply
|
|
747
|
+
* carries no intent. `"optional"` injects the same params and advertises
|
|
748
|
+
* none of them as required. `"off"` disables injection. The params are
|
|
747
749
|
* stripped before the vendor handler runs, so the tool never sees them.
|
|
748
750
|
* This is what captures intent on runtimes that drop `instructions`
|
|
749
751
|
* (notably Claude Desktop) — where the annotation tool alone yields
|
|
750
752
|
* nothing. A tool registered with no `inputSchema` at all is left alone
|
|
751
753
|
* regardless of this setting (see `schemaCompat.injectGoalParams`). */
|
|
752
754
|
intentParamMode?: "optional" | "required" | "off";
|
|
753
|
-
/** Per-request
|
|
754
|
-
* envelope's `
|
|
755
|
+
/** Per-request principal identity — the ASSERTED provenance behind the
|
|
756
|
+
* envelope's `principal_id` (SPEC §11.4 rung 0), tagged `v1:`.
|
|
755
757
|
*
|
|
756
758
|
* Called on every captured tool call and on the annotation tool, with an
|
|
757
|
-
* adapter-neutral {@link
|
|
759
|
+
* adapter-neutral {@link PrincipalResolutionContext}: headers folded to ONE
|
|
758
760
|
* case-insensitive shape across both SDK majors, the call's `_meta`, the
|
|
759
761
|
* tool name, and the arguments the vendor's own handler will see. Return a
|
|
760
762
|
* `Principal`, or `null` for "no opinion about this caller".
|
|
761
763
|
*
|
|
762
764
|
* **This is the only identity mechanism on this arm.** MCP auth is HTTP
|
|
763
765
|
* middleware, so a stdio server has no token at all; and unlike Python, no
|
|
764
|
-
* attested rung is implemented here — see `
|
|
766
|
+
* attested rung is implemented here — see `principalResolution.ts` for why
|
|
765
767
|
* (TypeScript's `AuthInfo` carries no `claims`).
|
|
766
768
|
*
|
|
767
769
|
* Never fails a tool call: a hook that throws or returns junk yields an
|
|
768
770
|
* anonymous call. ⚠ It is awaited INLINE with no timeout — a blocking hook
|
|
769
771
|
* stalls its own request. */
|
|
770
|
-
|
|
772
|
+
resolvePrincipal?: ResolvePrincipalHook;
|
|
771
773
|
/** `"hashed"` (default) emits a `v1:` per-tenant HMAC pseudonym; `"raw"`
|
|
772
774
|
* emits the subject VERBATIM.
|
|
773
775
|
*
|
|
774
|
-
* `"raw"` puts real
|
|
776
|
+
* `"raw"` puts real identity in the collector's database and is the
|
|
775
777
|
* vendor's deliberate choice — which is why SPEC §11.4 tells a consumer
|
|
776
778
|
* never to treat this field as anonymous. */
|
|
777
|
-
|
|
779
|
+
principalIdMode?: "hashed" | "raw";
|
|
778
780
|
/** The HMAC secret for hashed mode. Resolved explicit →
|
|
779
|
-
* `
|
|
781
|
+
* `BATON_PRINCIPAL_ID_HMAC_KEY` → unset.
|
|
780
782
|
*
|
|
781
|
-
* ⚠ **With none set, hashed mode DROPS `
|
|
783
|
+
* ⚠ **With none set, hashed mode DROPS `principal_id` rather than falling back to
|
|
782
784
|
* raw.** The fallback would be a residency breach that looks like success:
|
|
783
785
|
* the field present, populated, and carrying the subject verbatim. */
|
|
784
|
-
|
|
786
|
+
principalIdHmacKey?: string | Uint8Array;
|
|
785
787
|
}
|
|
786
788
|
|
|
787
789
|
/**
|
|
@@ -906,4 +908,4 @@ interface SupportedMcpServer {
|
|
|
906
908
|
/** Install Baton into an `McpServer`. See module docstring for usage. */
|
|
907
909
|
declare function withBaton(server: SupportedMcpServer, supplied?: BatonConfig): BatonHandle;
|
|
908
910
|
|
|
909
|
-
export { type AnnotationEvent, AnnotationEventSchema, type AnnotationPayload, AnnotationPayloadSchema, type BatonConfig, BatonHandle, DEFAULT_CONSENT_TOKEN, DEPTH_LIMIT, type Event, EventSchema, type EventType, EventTypeSchema, HttpSink, type HttpSinkOptions, type Principal, type
|
|
911
|
+
export { type AnnotationEvent, AnnotationEventSchema, type AnnotationPayload, AnnotationPayloadSchema, type BatonConfig, BatonHandle, DEFAULT_CONSENT_TOKEN, DEPTH_LIMIT, type Event, EventSchema, type EventType, EventTypeSchema, HttpSink, type HttpSinkOptions, type Principal, type PrincipalIdMode, type PrincipalResolutionContext, type ResolvePrincipalHook, SDK_VERSION, Scrubber, type Sink, StdoutSink, type StdoutSinkOptions, type SupportedMcpServer, type SurfaceSnapshotEvent, SurfaceSnapshotEventSchema, type SurfaceSnapshotPayload, SurfaceSnapshotPayloadSchema, type ToolCallEndEvent, ToolCallEndEventSchema, type ToolCallEndPayload, ToolCallEndPayloadSchema, type ToolCallErrorEvent, ToolCallErrorEventSchema, type ToolCallErrorPayload, ToolCallErrorPayloadSchema, type ToolCallStartEvent, ToolCallStartEventSchema, type ToolCallStartPayload, ToolCallStartPayloadSchema, VENDOR_HASH_SCHEME, hashPrincipalId, identityScrub, safeWrite, withBaton };
|