@goodtiming/baton-sdk 0.3.4 → 0.3.5

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.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod';
2
2
 
3
- declare const SDK_VERSION = "ts-0.3.4";
3
+ declare const SDK_VERSION = "ts-0.3.5";
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
- user_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
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
- user_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
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
- user_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
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
- user_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
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
- user_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
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
- user_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
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
- user_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
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
- user_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
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
- user_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
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
- user_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
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 USER_ID_MODE_HASHED = "hashed";
551
- declare const USER_ID_MODE_RAW = "raw";
552
- type UserIdMode = typeof USER_ID_MODE_HASHED | typeof USER_ID_MODE_RAW;
553
- /** A raw, UNHASHED end-user principal, as a resolver produced it. */
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 per-person identifier from the vendor's own
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
- userId: string;
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 `user_id`.
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 hashUserId(rawPrincipal: string, options: {
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.resolveUser` — the ASSERTED identity provenance.
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` has been on this SDK's envelope since 0.3.0 and
601
- * NOTHING could populate it, so a partition that works on one of two SDKs is
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 `resolveUser` hook is handed.
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 UserResolutionContext {
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 ResolveUserHook = (context: UserResolutionContext) => Principal | null | Promise<Principal | null>;
645
+ type ResolvePrincipalHook = (context: PrincipalResolutionContext) => Principal | null | Promise<Principal | null>;
646
646
 
647
647
  /**
648
648
  * `BatonConfig` — vendor-side configuration for `withBaton`. A trimmed
@@ -750,38 +750,38 @@ interface BatonConfig {
750
750
  * nothing. A tool registered with no `inputSchema` at all is left alone
751
751
  * regardless of this setting (see `schemaCompat.injectGoalParams`). */
752
752
  intentParamMode?: "optional" | "required" | "off";
753
- /** Per-request end-user identity — the ASSERTED provenance behind the
754
- * envelope's `user_id` (SPEC §11.4 rung 0), tagged `v1:`.
753
+ /** Per-request principal identity — the ASSERTED provenance behind the
754
+ * envelope's `principal_id` (SPEC §11.4 rung 0), tagged `v1:`.
755
755
  *
756
756
  * Called on every captured tool call and on the annotation tool, with an
757
- * adapter-neutral {@link UserResolutionContext}: headers folded to ONE
757
+ * adapter-neutral {@link PrincipalResolutionContext}: headers folded to ONE
758
758
  * case-insensitive shape across both SDK majors, the call's `_meta`, the
759
759
  * tool name, and the arguments the vendor's own handler will see. Return a
760
760
  * `Principal`, or `null` for "no opinion about this caller".
761
761
  *
762
762
  * **This is the only identity mechanism on this arm.** MCP auth is HTTP
763
763
  * middleware, so a stdio server has no token at all; and unlike Python, no
764
- * attested rung is implemented here — see `userResolution.ts` for why
764
+ * attested rung is implemented here — see `principalResolution.ts` for why
765
765
  * (TypeScript's `AuthInfo` carries no `claims`).
766
766
  *
767
767
  * Never fails a tool call: a hook that throws or returns junk yields an
768
768
  * anonymous call. ⚠ It is awaited INLINE with no timeout — a blocking hook
769
769
  * stalls its own request. */
770
- resolveUser?: ResolveUserHook;
770
+ resolvePrincipal?: ResolvePrincipalHook;
771
771
  /** `"hashed"` (default) emits a `v1:` per-tenant HMAC pseudonym; `"raw"`
772
772
  * emits the subject VERBATIM.
773
773
  *
774
- * `"raw"` puts real end-user identity in the collector's database and is the
774
+ * `"raw"` puts real identity in the collector's database and is the
775
775
  * vendor's deliberate choice — which is why SPEC §11.4 tells a consumer
776
776
  * never to treat this field as anonymous. */
777
- userIdMode?: "hashed" | "raw";
777
+ principalIdMode?: "hashed" | "raw";
778
778
  /** The HMAC secret for hashed mode. Resolved explicit →
779
- * `BATON_USER_ID_HMAC_KEY` → unset.
779
+ * `BATON_PRINCIPAL_ID_HMAC_KEY` → unset.
780
780
  *
781
- * ⚠ **With none set, hashed mode DROPS `user_id` rather than falling back to
781
+ * ⚠ **With none set, hashed mode DROPS `principal_id` rather than falling back to
782
782
  * raw.** The fallback would be a residency breach that looks like success:
783
783
  * the field present, populated, and carrying the subject verbatim. */
784
- userIdHmacKey?: string | Uint8Array;
784
+ principalIdHmacKey?: string | Uint8Array;
785
785
  }
786
786
 
787
787
  /**
@@ -906,4 +906,4 @@ interface SupportedMcpServer {
906
906
  /** Install Baton into an `McpServer`. See module docstring for usage. */
907
907
  declare function withBaton(server: SupportedMcpServer, supplied?: BatonConfig): BatonHandle;
908
908
 
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 ResolveUserHook, 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, type UserIdMode, type UserResolutionContext, VENDOR_HASH_SCHEME, hashUserId, identityScrub, safeWrite, withBaton };
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 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.4";
3
+ declare const SDK_VERSION = "ts-0.3.5";
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
- user_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
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
- user_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
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
- user_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
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
- user_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
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
- user_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
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
- user_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
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
- user_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
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
- user_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
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
- user_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
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
- user_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
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 USER_ID_MODE_HASHED = "hashed";
551
- declare const USER_ID_MODE_RAW = "raw";
552
- type UserIdMode = typeof USER_ID_MODE_HASHED | typeof USER_ID_MODE_RAW;
553
- /** A raw, UNHASHED end-user principal, as a resolver produced it. */
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 per-person identifier from the vendor's own
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
- userId: string;
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 `user_id`.
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 hashUserId(rawPrincipal: string, options: {
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.resolveUser` — the ASSERTED identity provenance.
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` has been on this SDK's envelope since 0.3.0 and
601
- * NOTHING could populate it, so a partition that works on one of two SDKs is
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 `resolveUser` hook is handed.
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 UserResolutionContext {
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 ResolveUserHook = (context: UserResolutionContext) => Principal | null | Promise<Principal | null>;
645
+ type ResolvePrincipalHook = (context: PrincipalResolutionContext) => Principal | null | Promise<Principal | null>;
646
646
 
647
647
  /**
648
648
  * `BatonConfig` — vendor-side configuration for `withBaton`. A trimmed
@@ -750,38 +750,38 @@ interface BatonConfig {
750
750
  * nothing. A tool registered with no `inputSchema` at all is left alone
751
751
  * regardless of this setting (see `schemaCompat.injectGoalParams`). */
752
752
  intentParamMode?: "optional" | "required" | "off";
753
- /** Per-request end-user identity — the ASSERTED provenance behind the
754
- * envelope's `user_id` (SPEC §11.4 rung 0), tagged `v1:`.
753
+ /** Per-request principal identity — the ASSERTED provenance behind the
754
+ * envelope's `principal_id` (SPEC §11.4 rung 0), tagged `v1:`.
755
755
  *
756
756
  * Called on every captured tool call and on the annotation tool, with an
757
- * adapter-neutral {@link UserResolutionContext}: headers folded to ONE
757
+ * adapter-neutral {@link PrincipalResolutionContext}: headers folded to ONE
758
758
  * case-insensitive shape across both SDK majors, the call's `_meta`, the
759
759
  * tool name, and the arguments the vendor's own handler will see. Return a
760
760
  * `Principal`, or `null` for "no opinion about this caller".
761
761
  *
762
762
  * **This is the only identity mechanism on this arm.** MCP auth is HTTP
763
763
  * middleware, so a stdio server has no token at all; and unlike Python, no
764
- * attested rung is implemented here — see `userResolution.ts` for why
764
+ * attested rung is implemented here — see `principalResolution.ts` for why
765
765
  * (TypeScript's `AuthInfo` carries no `claims`).
766
766
  *
767
767
  * Never fails a tool call: a hook that throws or returns junk yields an
768
768
  * anonymous call. ⚠ It is awaited INLINE with no timeout — a blocking hook
769
769
  * stalls its own request. */
770
- resolveUser?: ResolveUserHook;
770
+ resolvePrincipal?: ResolvePrincipalHook;
771
771
  /** `"hashed"` (default) emits a `v1:` per-tenant HMAC pseudonym; `"raw"`
772
772
  * emits the subject VERBATIM.
773
773
  *
774
- * `"raw"` puts real end-user identity in the collector's database and is the
774
+ * `"raw"` puts real identity in the collector's database and is the
775
775
  * vendor's deliberate choice — which is why SPEC §11.4 tells a consumer
776
776
  * never to treat this field as anonymous. */
777
- userIdMode?: "hashed" | "raw";
777
+ principalIdMode?: "hashed" | "raw";
778
778
  /** The HMAC secret for hashed mode. Resolved explicit →
779
- * `BATON_USER_ID_HMAC_KEY` → unset.
779
+ * `BATON_PRINCIPAL_ID_HMAC_KEY` → unset.
780
780
  *
781
- * ⚠ **With none set, hashed mode DROPS `user_id` rather than falling back to
781
+ * ⚠ **With none set, hashed mode DROPS `principal_id` rather than falling back to
782
782
  * raw.** The fallback would be a residency breach that looks like success:
783
783
  * the field present, populated, and carrying the subject verbatim. */
784
- userIdHmacKey?: string | Uint8Array;
784
+ principalIdHmacKey?: string | Uint8Array;
785
785
  }
786
786
 
787
787
  /**
@@ -906,4 +906,4 @@ interface SupportedMcpServer {
906
906
  /** Install Baton into an `McpServer`. See module docstring for usage. */
907
907
  declare function withBaton(server: SupportedMcpServer, supplied?: BatonConfig): BatonHandle;
908
908
 
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 ResolveUserHook, 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, type UserIdMode, type UserResolutionContext, VENDOR_HASH_SCHEME, hashUserId, identityScrub, safeWrite, withBaton };
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 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 };