@goodtiming/baton-sdk 0.5.0 → 0.5.2

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 CHANGED
@@ -49,6 +49,25 @@ Sending to your own collector instead, or trying the package before you have a k
49
49
 
50
50
  **The scrubber is not the only lever.** If some tool results cannot be recorded at all, `resultCaptureMode` below withholds them outright rather than transforming them.
51
51
 
52
+ ## Who is calling
53
+
54
+ **Nothing is captured about the person behind a call unless you say how to find them.** Pass `resolvePrincipal`: it receives the call's headers, `_meta`, tool name, arguments and validated `authInfo`, and returns a `Principal` or `null`. Two ready-made hooks cover OAuth:
55
+
56
+ ```typescript
57
+ import { withBaton, principalFromOAuthEmail } from "@goodtiming/baton-sdk";
58
+
59
+ withBaton(server, {
60
+ dsn: "https://baton_pk_...@baton.goodtiming.ai/ten_.../your-vendor",
61
+ resolvePrincipal: principalFromOAuthEmail, // or principalFromOAuthSub
62
+ });
63
+ ```
64
+
65
+ `principalFromOAuthEmail` keys on the token's `email` claim (the whole address); `principalFromOAuthSub` on its subject. Each returns `null` when the claim is missing, so they compose: `(ctx) => principalFromOAuthEmail(ctx) ?? principalFromOAuthSub(ctx)`. Set `displayName` on the returned `Principal` to choose what your dashboard shows for a person; it is sent as-is. The email hook sets it to the part before `@`.
66
+
67
+ ⚠ **They read the claims from `authInfo.extra`.** The MCP SDK's `AuthInfo` has no `claims` field, so these hooks expect your token verifier to put the decoded JWT claims (`sub`, `iss`, `email`) at the top level of `extra`. If yours keeps them elsewhere, write the three-line hook that reads them from there. A token exists only on HTTP with auth configured; on stdio, write a hook that names the user from whatever you authenticated them with.
68
+
69
+ The id is sent exactly as your hook returns it, so the hook decides what is safe to send. To send a pseudonym instead, hash the id inside your hook and return `form: "hashed"` with it.
70
+
52
71
  ## Not capturing responses at all
53
72
 
54
73
  `resultCaptureMode: "off"` and nothing **derived from what your tool returns** leaves your process — not the result, and not the reason text on a failure your handler returns rather than throws. Requests are unaffected: `params` are captured either way.
package/dist/index.cjs CHANGED
@@ -77,15 +77,16 @@ __export(index_exports, {
77
77
  ToolCallErrorPayloadSchema: () => ToolCallErrorPayloadSchema,
78
78
  ToolCallStartEventSchema: () => ToolCallStartEventSchema,
79
79
  ToolCallStartPayloadSchema: () => ToolCallStartPayloadSchema,
80
- hashPrincipalId: () => hashPrincipalId,
81
80
  identityScrub: () => identityScrub,
81
+ principalFromOAuthEmail: () => principalFromOAuthEmail,
82
+ principalFromOAuthSub: () => principalFromOAuthSub,
82
83
  safeWrite: () => safeWrite,
83
84
  withBaton: () => withBaton
84
85
  });
85
86
  module.exports = __toCommonJS(index_exports);
86
87
 
87
88
  // src/version.ts
88
- var SDK_VERSION = "ts-0.5.0";
89
+ var SDK_VERSION = "ts-0.5.2";
89
90
 
90
91
  // src/events.ts
91
92
  var import_zod = require("zod");
@@ -185,7 +186,8 @@ var DEFAULT_CONSENT_TOKEN = "customer-consented";
185
186
  var PrincipalWireSchema = import_zod.z.object({
186
187
  id: import_zod.z.string(),
187
188
  source: import_zod.z.string(),
188
- form: import_zod.z.string()
189
+ form: import_zod.z.string(),
190
+ display_name: import_zod.z.string().nullable().optional()
189
191
  }).strict();
190
192
  var envelopeShape = {
191
193
  event_id: import_zod.z.uuid().default(() => (0, import_uuid.v7)()),
@@ -724,10 +726,12 @@ function roundMetaCoordinates(meta) {
724
726
  return walk(meta, 0);
725
727
  }
726
728
 
727
- // src/identity.ts
728
- var import_node_crypto = require("crypto");
729
-
730
729
  // src/_text.ts
730
+ function exceedsCodePoints(value, max) {
731
+ if (value.length <= max) return false;
732
+ if (value.length > 2 * max) return true;
733
+ return [...value].length > max;
734
+ }
731
735
  function capCodePoints(value, max) {
732
736
  if (value.length <= max) return value;
733
737
  return [...value].slice(0, max).join("");
@@ -737,57 +741,52 @@ function capCodePoints(value, max) {
737
741
  var PRINCIPAL_SOURCE_ASSERTED = "asserted";
738
742
  var PRINCIPAL_FORM_HASHED = "hashed";
739
743
  var PRINCIPAL_FORM_RAW = "raw";
740
- var RAW_PRINCIPAL_ID_MAX_LEN = 128;
741
- var PRINCIPAL_ID_MODE_HASHED = "hashed";
742
- var PRINCIPAL_ID_MODE_RAW = "raw";
743
- var FORM_BY_MODE = {
744
- [PRINCIPAL_ID_MODE_HASHED]: PRINCIPAL_FORM_HASHED,
745
- [PRINCIPAL_ID_MODE_RAW]: PRINCIPAL_FORM_RAW
746
- };
747
- var PRINCIPAL_ID_MODES = Object.keys(
748
- FORM_BY_MODE
749
- );
744
+ var PRINCIPAL_ID_MAX_LEN = 128;
745
+ var DISPLAY_NAME_MAX_LEN = 128;
746
+ var ALL_WHITE_SPACE = /^\p{White_Space}*$/u;
747
+ function wireDisplayName(value) {
748
+ if (typeof value !== "string" || exceedsCodePoints(value, DISPLAY_NAME_MAX_LEN)) return null;
749
+ if (LONE_SURROGATE.test(value) || value.includes("\0") || ALL_WHITE_SPACE.test(value)) return null;
750
+ return value;
751
+ }
752
+ var PRINCIPAL_FORMS = /* @__PURE__ */ new Set([PRINCIPAL_FORM_RAW, PRINCIPAL_FORM_HASHED]);
750
753
  var PYTHON_WHITESPACE = "\\t\\n\\v\\f\\r\\x1c-\\x1f \\x85\\xa0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000";
751
754
  var PYTHON_STRIP = new RegExp(`^[${PYTHON_WHITESPACE}]+|[${PYTHON_WHITESPACE}]+$`, "gu");
752
755
  var LONE_SURROGATE = /\p{Surrogate}/u;
753
- function canonicalize(rawPrincipal) {
754
- return pythonStrip(rawPrincipal.normalize("NFC")).toLowerCase();
755
- }
756
756
  function pythonStrip(value) {
757
757
  return value.replace(PYTHON_STRIP, "");
758
758
  }
759
- function hashPrincipalId(rawPrincipal, options) {
760
- const { tenantId, key, issuer = null } = options;
761
- let message = `${tenantId}\0${canonicalize(rawPrincipal)}`;
762
- if (issuer !== null) {
763
- message += `\0${canonicalize(issuer)}`;
764
- }
765
- const keyBytes = typeof key === "string" ? Buffer.from(key, "utf8") : key;
766
- return (0, import_node_crypto.createHmac)("sha256", keyBytes).update(message, "utf8").digest("hex");
767
- }
768
759
  function normalizePrincipal(result) {
769
760
  if (result === null || typeof result !== "object") return null;
770
761
  const candidate = result;
771
762
  if (typeof candidate.principalId !== "string") return null;
772
763
  if (LONE_SURROGATE.test(candidate.principalId)) return null;
773
- if (canonicalize(candidate.principalId) === "") return null;
774
- const issuerRaw = typeof candidate.issuer === "string" && candidate.issuer ? candidate.issuer : null;
775
- const issuer = issuerRaw !== null && !LONE_SURROGATE.test(issuerRaw) ? issuerRaw : null;
776
- return { principalId: candidate.principalId, issuer };
777
- }
778
- function principalFor(principal, options) {
779
- let id;
780
- if (options.mode === PRINCIPAL_ID_MODE_RAW) {
781
- id = capCodePoints(principal.principalId, RAW_PRINCIPAL_ID_MAX_LEN);
782
- } else {
783
- if (options.key === null || options.key === void 0) return null;
784
- id = hashPrincipalId(principal.principalId, {
785
- tenantId: options.tenantId,
786
- key: options.key,
787
- issuer: principal.issuer ?? null
788
- });
764
+ if (candidate.principalId.includes("\0")) return null;
765
+ if (pythonStrip(candidate.principalId) === "") return null;
766
+ const principal = { principalId: candidate.principalId };
767
+ if (candidate.form !== void 0) principal.form = candidate.form;
768
+ if (typeof candidate.displayName === "string") principal.displayName = candidate.displayName;
769
+ return principal;
770
+ }
771
+ function principalFor(principal, onUnregisteredForm) {
772
+ let form = PRINCIPAL_FORM_RAW;
773
+ if (principal.form !== void 0) {
774
+ if (PRINCIPAL_FORMS.has(principal.form)) {
775
+ form = principal.form;
776
+ } else {
777
+ onUnregisteredForm?.(principal.form);
778
+ }
789
779
  }
790
- return { id, source: PRINCIPAL_SOURCE_ASSERTED, form: FORM_BY_MODE[options.mode] };
780
+ const wire = {
781
+ // `capCodePoints`, not `.slice()`: a plain slice counts UTF-16 units, so
782
+ // an astral id cut at the boundary would ship a lone surrogate.
783
+ id: capCodePoints(principal.principalId, PRINCIPAL_ID_MAX_LEN),
784
+ source: PRINCIPAL_SOURCE_ASSERTED,
785
+ form
786
+ };
787
+ const displayName = wireDisplayName(principal.displayName);
788
+ if (displayName !== null) wire.display_name = displayName;
789
+ return wire;
791
790
  }
792
791
 
793
792
  // src/integrations/mcp/llmText.ts
@@ -893,12 +892,18 @@ function slugServerName(serverName) {
893
892
  const collapsed = mapped.replace(/-+/g, "-").replace(/^-+|-+$/g, "");
894
893
  return collapsed.slice(0, SLUG_CAP).replace(/^-+|-+$/g, "") || void 0;
895
894
  }
895
+ function toolNameCandidate(serverName) {
896
+ const slug = slugServerName(serverName);
897
+ if (slug === void 0) return void 0;
898
+ const candidate = `${slug}${SUFFIX}`;
899
+ return TOOL_NAME_PATTERN.test(candidate) ? candidate : void 0;
900
+ }
896
901
  function displayNameFromServer(serverName, tool) {
897
902
  if (serverName === void 0) return void 0;
898
- const fallbackToolName = tool.annotationToolName || `${tool.vendorId}${SUFFIX}`;
899
- if (!fitsInstructionsCap({ vendorDisplayName: serverName, annotationToolName: fallbackToolName })) {
903
+ const proposed = tool.annotationToolName || toolNameCandidate(serverName) || `${tool.vendorId}${SUFFIX}`;
904
+ if (!fitsInstructionsCap({ vendorDisplayName: serverName, annotationToolName: proposed })) {
900
905
  warn(
901
- `baton: the server name (${serverName.length} chars) does not fit the server-instructions budget as the display name; keeping the DSN's server segment. Pass vendorDisplayName to choose a shorter one.`
906
+ `baton: the server name (${serverName.length} chars) does not fit the server-instructions budget as the display name beside the annotation tool ${JSON.stringify(proposed)}; keeping the DSN's server segment. Pass vendorDisplayName to name the server in fewer characters.`
902
907
  );
903
908
  return void 0;
904
909
  }
@@ -906,10 +911,8 @@ function displayNameFromServer(serverName, tool) {
906
911
  }
907
912
  function annotationToolNameFromServer(serverName, vendorDisplayName) {
908
913
  if (serverName === void 0) return void 0;
909
- const slug = slugServerName(serverName);
910
- if (slug === void 0) return void 0;
911
- const candidate = `${slug}${SUFFIX}`;
912
- if (!TOOL_NAME_PATTERN.test(candidate)) return void 0;
914
+ const candidate = toolNameCandidate(serverName);
915
+ if (candidate === void 0) return void 0;
913
916
  if (!fitsInstructionsCap({ vendorDisplayName, annotationToolName: candidate })) {
914
917
  warn(
915
918
  `baton: the server-derived annotation tool name ${JSON.stringify(candidate)} does not fit the server-instructions budget beside the display name (${vendorDisplayName.length} chars); keeping {vendorId}_annotate. A shorter display name gets the readable one.`
@@ -948,6 +951,10 @@ async function emit(sink, build) {
948
951
  }
949
952
 
950
953
  // src/integrations/mcp/mcpTypes.ts
954
+ function extraAuthInfo(extra) {
955
+ const found = extra.authInfo ?? extra.http?.authInfo;
956
+ return found !== null && typeof found === "object" ? found : null;
957
+ }
951
958
  function extraMeta(extra) {
952
959
  const direct = extra._meta;
953
960
  if (direct) return direct;
@@ -992,19 +999,10 @@ function buildPrincipalResolutionContext(extra, toolName, args) {
992
999
  headers: extraHeaders(extra),
993
1000
  meta: extraMeta(extra),
994
1001
  toolName,
995
- arguments: args
1002
+ arguments: args,
1003
+ authInfo: extraAuthInfo(extra)
996
1004
  };
997
1005
  }
998
- function warnIfIdentityCannotResolve(config) {
999
- if (config.resolvePrincipal === void 0) return;
1000
- if (config.principalIdMode !== PRINCIPAL_ID_MODE_HASHED) return;
1001
- if (config.principalIdHmacKey !== void 0) return;
1002
- if (typeof process === "undefined" || typeof process.emitWarning !== "function") return;
1003
- const renamed = process.env?.BATON_USER_ID_HMAC_KEY ? "BATON_USER_ID_HMAC_KEY is set, but it was renamed to BATON_PRINCIPAL_ID_HMAC_KEY in 0.3.5 and is no longer read. " : "";
1004
- process.emitWarning(
1005
- `baton: resolvePrincipal is configured but no principal HMAC key is set, so the principal is dropped from every event (events still emit). ${renamed}Set BATON_PRINCIPAL_ID_HMAC_KEY or BatonConfig.principalIdHmacKey, or pass principalIdMode: "raw" if you intend to emit the subject verbatim.`
1006
- );
1007
- }
1008
1006
  var warnedPreRenameShape = false;
1009
1007
  function warnIfPreRenameShape(result) {
1010
1008
  const userId = result?.userId;
@@ -1014,30 +1012,28 @@ function warnIfPreRenameShape(result) {
1014
1012
  "baton: resolvePrincipal returned { userId }, which was renamed to { principalId } in 0.3.5, so the principal is dropped from every event until the hook returns the new key."
1015
1013
  );
1016
1014
  }
1017
- async function resolveCallPrincipal(hook, call, options) {
1015
+ async function resolveCallPrincipal(hook, call) {
1018
1016
  if (hook === void 0) return null;
1019
- let result;
1020
1017
  try {
1021
1018
  const context = buildPrincipalResolutionContext(call.extra, call.toolName, call.arguments);
1022
- result = await hook(context);
1023
- } catch {
1024
- return null;
1025
- }
1026
- const principal = normalizePrincipal(result);
1027
- if (principal === null) {
1028
- warnIfPreRenameShape(result);
1029
- return null;
1030
- }
1031
- try {
1032
- return principalFor(principal, {
1033
- mode: options.mode,
1034
- tenantId: options.tenantId,
1035
- key: options.key
1019
+ const result = await hook(context);
1020
+ const principal = normalizePrincipal(result);
1021
+ if (principal === null) {
1022
+ warnIfPreRenameShape(result);
1023
+ return null;
1024
+ }
1025
+ return principalFor(principal, (form) => {
1026
+ warn(
1027
+ `baton: resolvePrincipal returned form ${describeForm(form)}, expected "raw" or "hashed" \u2014 sending it as "${PRINCIPAL_FORM_RAW}".`
1028
+ );
1036
1029
  });
1037
1030
  } catch {
1038
1031
  return null;
1039
1032
  }
1040
1033
  }
1034
+ function describeForm(form) {
1035
+ return typeof form === "string" ? JSON.stringify(form.slice(0, 32)) : `of type ${typeof form}`;
1036
+ }
1041
1037
 
1042
1038
  // src/integrations/mcp/safeScrub.ts
1043
1039
  var warned = /* @__PURE__ */ new Set();
@@ -1152,12 +1148,7 @@ function registerAnnotationTool(server, options) {
1152
1148
  }
1153
1149
  const principal = await resolveCallPrincipal(
1154
1150
  options.resolvePrincipal,
1155
- { extra, toolName: name, arguments: args },
1156
- {
1157
- mode: options.principalIdMode,
1158
- tenantId: options.tenantId,
1159
- key: options.principalIdHmacKey
1160
- }
1151
+ { extra, toolName: name, arguments: args }
1161
1152
  );
1162
1153
  await emit(
1163
1154
  options.sink,
@@ -1471,18 +1462,12 @@ function requestSideErrorFields(text, errorBody2) {
1471
1462
  // src/integrations/mcp/config.ts
1472
1463
  var INTENT_PARAM_MODES = /* @__PURE__ */ new Set(["optional", "required", "off"]);
1473
1464
  var RESULT_CAPTURE_MODE_SET = new Set(RESULT_CAPTURE_MODES);
1474
- var PRINCIPAL_ID_MODE_SET = new Set(PRINCIPAL_ID_MODES);
1475
1465
  function resolveTenantId(explicit, vendorId) {
1476
1466
  if (explicit) return explicit;
1477
1467
  const fromEnv = typeof process !== "undefined" ? process.env?.BATON_TENANT_ID : void 0;
1478
1468
  if (fromEnv) return fromEnv;
1479
1469
  return vendorId;
1480
1470
  }
1481
- function resolvePrincipalIdHmacKey(explicit) {
1482
- if (explicit !== void 0) return explicit;
1483
- const fromEnv = typeof process !== "undefined" ? process.env?.BATON_PRINCIPAL_ID_HMAC_KEY : void 0;
1484
- return fromEnv ? fromEnv : void 0;
1485
- }
1486
1471
  function resolveBatonConfig(config, serverName) {
1487
1472
  const dsnString = selectDsn(
1488
1473
  config.dsn,
@@ -1541,9 +1526,7 @@ function resolveBatonConfig(config, serverName) {
1541
1526
  };
1542
1527
  }
1543
1528
  var RENAMED_KEYS = {
1544
- resolveUser: "resolvePrincipal",
1545
- userIdMode: "principalIdMode",
1546
- userIdHmacKey: "principalIdHmacKey"
1529
+ resolveUser: "resolvePrincipal"
1547
1530
  };
1548
1531
  function validateBatonConfig(config) {
1549
1532
  for (const [was, now] of Object.entries(RENAMED_KEYS)) {
@@ -1592,14 +1575,6 @@ function validateBatonConfig(config) {
1592
1575
  if (config.resolvePrincipal !== void 0 && typeof config.resolvePrincipal !== "function") {
1593
1576
  throw new Error("BatonConfig.resolvePrincipal must be a function.");
1594
1577
  }
1595
- if (config.principalIdHmacKey !== void 0 && typeof config.principalIdHmacKey !== "string" && !(config.principalIdHmacKey instanceof Uint8Array)) {
1596
- throw new Error("BatonConfig.principalIdHmacKey must be a string or a Uint8Array.");
1597
- }
1598
- if (config.principalIdMode !== void 0 && !PRINCIPAL_ID_MODE_SET.has(config.principalIdMode)) {
1599
- throw new Error(
1600
- `BatonConfig.principalIdMode ${JSON.stringify(config.principalIdMode)} must be one of ${JSON.stringify([...PRINCIPAL_ID_MODE_SET].sort())}.`
1601
- );
1602
- }
1603
1578
  }
1604
1579
 
1605
1580
  // src/optout.ts
@@ -1844,10 +1819,10 @@ function toolInputJsonSchema(inputSchema) {
1844
1819
  }
1845
1820
 
1846
1821
  // src/integrations/mcp/surface.ts
1847
- var import_node_crypto2 = require("crypto");
1822
+ var import_node_crypto = require("crypto");
1848
1823
  function surfaceHash(surface) {
1849
1824
  const canonical = canonicalJson(surface);
1850
- const digest = (0, import_node_crypto2.createHash)("sha256").update(canonical, "utf-8").digest("hex");
1825
+ const digest = (0, import_node_crypto.createHash)("sha256").update(canonical, "utf-8").digest("hex");
1851
1826
  return `sha256:${digest}`;
1852
1827
  }
1853
1828
  function canonicalJson(value) {
@@ -1984,8 +1959,7 @@ async function openCall(ctx, toolName, extra, params, registered = true) {
1984
1959
  const callId = (0, import_uuid2.v7)();
1985
1960
  const principal = await resolveCallPrincipal(
1986
1961
  ctx.resolvePrincipal,
1987
- { extra, toolName, arguments: params },
1988
- { mode: ctx.principalIdMode, tenantId: ctx.tenantId, key: ctx.principalIdHmacKey }
1962
+ { extra, toolName, arguments: params }
1989
1963
  );
1990
1964
  const common = {
1991
1965
  tenant_id: ctx.tenantId,
@@ -2748,15 +2722,12 @@ function withBaton(server, supplied = {}) {
2748
2722
  resultCaptureMode: config.resultCaptureMode ?? "full",
2749
2723
  paramRegistry: /* @__PURE__ */ new Map(),
2750
2724
  resolvePrincipal: config.resolvePrincipal,
2751
- principalIdMode: config.principalIdMode ?? "hashed",
2752
- principalIdHmacKey: resolvePrincipalIdHmacKey(config.principalIdHmacKey),
2753
2725
  vendorToolJsonSchema,
2754
2726
  bustSchemaMemo,
2755
2727
  tracker,
2756
2728
  surfaceState,
2757
2729
  emitSurface
2758
2730
  };
2759
- warnIfIdentityCannotResolve(ctx);
2760
2731
  const instructions = buildServerInstructions({
2761
2732
  vendorDisplayName: config.vendorDisplayName,
2762
2733
  annotationToolName
@@ -2786,15 +2757,7 @@ function withBaton(server, supplied = {}) {
2786
2757
  vendorId: ctx.vendorId,
2787
2758
  vendorDisplayName: config.vendorDisplayName,
2788
2759
  consentToken: ctx.consentToken,
2789
- // Read off `ctx`, never re-resolved from `config`: the two paths must
2790
- // agree on the actor, and `principalIdMode`/`principalIdHmacKey` each have a
2791
- // default and an env fallback that a second resolution could take
2792
- // differently. Required (not optional) on the options type ON PURPOSE —
2793
- // the compiler then refuses a registration that forgets them, which is
2794
- // the mechanical version of "wiring two of four call sites".
2795
2760
  resolvePrincipal: ctx.resolvePrincipal,
2796
- principalIdMode: ctx.principalIdMode,
2797
- principalIdHmacKey: ctx.principalIdHmacKey,
2798
2761
  fallbackSessionId: ctx.fallbackSessionId,
2799
2762
  scrubber: ctx.scrubber,
2800
2763
  // The RESOLVED name, never `config.annotationToolName`: handing over the
@@ -2822,6 +2785,37 @@ function withBaton(server, supplied = {}) {
2822
2785
  annotationToolName: resolvedAnnotationToolName
2823
2786
  });
2824
2787
  }
2788
+
2789
+ // src/integrations/mcp/oauthHooks.ts
2790
+ function claimsOf(context) {
2791
+ try {
2792
+ const extra = context.authInfo?.extra;
2793
+ return extra !== null && typeof extra === "object" ? extra : null;
2794
+ } catch {
2795
+ return null;
2796
+ }
2797
+ }
2798
+ function stringClaim(claims, name) {
2799
+ const value = claims[name];
2800
+ return typeof value === "string" && pythonStrip(value) !== "" ? value : null;
2801
+ }
2802
+ function principalFromOAuthSub(context) {
2803
+ const claims = claimsOf(context);
2804
+ if (claims === null) return null;
2805
+ const sub = stringClaim(claims, "sub");
2806
+ return sub === null ? null : { principalId: sub };
2807
+ }
2808
+ function principalFromOAuthEmail(context) {
2809
+ const claims = claimsOf(context);
2810
+ if (claims === null) return null;
2811
+ const email = stringClaim(claims, "email");
2812
+ if (email === null) return null;
2813
+ const at = email.lastIndexOf("@");
2814
+ return {
2815
+ principalId: email,
2816
+ displayName: at > 0 ? email.slice(0, at) : null
2817
+ };
2818
+ }
2825
2819
  // Annotate the CommonJS export names for ESM import in node:
2826
2820
  0 && (module.exports = {
2827
2821
  AnnotationEventSchema,
@@ -2871,8 +2865,9 @@ function withBaton(server, supplied = {}) {
2871
2865
  ToolCallErrorPayloadSchema,
2872
2866
  ToolCallStartEventSchema,
2873
2867
  ToolCallStartPayloadSchema,
2874
- hashPrincipalId,
2875
2868
  identityScrub,
2869
+ principalFromOAuthEmail,
2870
+ principalFromOAuthSub,
2876
2871
  safeWrite,
2877
2872
  withBaton
2878
2873
  });