@goodtiming/baton-sdk 0.3.7 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +140 -42
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +169 -48
- package/dist/index.d.ts +169 -48
- package/dist/index.js +136 -41
- 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
|
+
declare const SDK_VERSION = "ts-0.4.1";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Zod schemas + TS types for the Baton event stream per SPEC §11.4.
|
|
@@ -44,14 +44,47 @@ declare const ToolCallEndPayloadSchema: z.ZodObject<{
|
|
|
44
44
|
duration_ms: z.ZodDefault<z.ZodNullable<z.ZodNumber>>;
|
|
45
45
|
}, z.core.$strict>;
|
|
46
46
|
type ToolCallEndPayload = z.infer<typeof ToolCallEndPayloadSchema>;
|
|
47
|
-
/** Emitted when the
|
|
48
|
-
*
|
|
49
|
-
*
|
|
47
|
+
/** Emitted when the call FAILED, which MCP expresses two ways (SPEC §11.4.3):
|
|
48
|
+
* the vendor handler throws, or it returns a result carrying MCP's error flag
|
|
49
|
+
* on a 200. `error_type` is the error's constructor name for a throw and the
|
|
50
|
+
* registered value `"tool_error"` for a returned flag; `error_body` is the
|
|
51
|
+
* message or the unwrapped reason (PII-scrubbed, then capped — the limit and
|
|
52
|
+
* its unit live on `ERROR_BODY_MAX_CODE_POINTS` in
|
|
53
|
+
* `integrations/mcp/errorResult.ts`, which both failure legs cut with).
|
|
54
|
+
*
|
|
55
|
+
* ⚠ This schema ACCEPTED `result` one commit before this producer emitted
|
|
56
|
+
* it (`67453eb`), and the split was deliberate. Unlike `baton-console`'s
|
|
57
|
+
* ingest — which forbids unknown keys on the envelope only, leaving `payload`
|
|
58
|
+
* an opaque dict — this schema is `.strict()` down to the payload, and
|
|
59
|
+
* `test/conformance.test.ts` parses every `baton-spec` vector through it. So
|
|
60
|
+
* the `baton-spec` bump carrying the field would have reddened this suite on
|
|
61
|
+
* BOTH error vectors, the throw-shape one included, because it now carries
|
|
62
|
+
* `result: null`. Accepting first is what made that bump safe.
|
|
63
|
+
*
|
|
64
|
+
* `result` carries the full result envelope on the returned shape and is null
|
|
65
|
+
* on a throw, where no result object exists.
|
|
66
|
+
*
|
|
67
|
+
* ⚠ **THE shape claim for this field lives here; everywhere else points at
|
|
68
|
+
* this paragraph.** On THIS producer `tool_call_error.result` and
|
|
69
|
+
* `tool_call_end.result` are the SAME shape — the object the vendor's handler
|
|
70
|
+
* returned, `{content, isError?}`, which neither major converts. The sentence
|
|
71
|
+
* that stood here said `result` is "deliberately NOT unwrapped the way
|
|
72
|
+
* `tool_call_end.result` unwraps to the developer's return"; that is Python's
|
|
73
|
+
* contrast, carried over with the rest of the port, and it is FALSE here.
|
|
74
|
+
* SPEC §11.4.3's requirement still binds — whatever is recorded must keep the
|
|
75
|
+
* flag and the reason, which the literal does — but a consumer must not read
|
|
76
|
+
* a TS-sourced `tool_call_end.result` as the bare content array Python's
|
|
77
|
+
* vector shows.
|
|
78
|
+
*
|
|
79
|
+
* Enforced by `emitterConformance.test.ts`'s
|
|
80
|
+
* `PAYLOAD_ALLOWED_TO_DIFFER["tool_call_error.returned"]` and the two shape
|
|
81
|
+
* assertions beside it: the claim stops being true the day that test reds. */
|
|
50
82
|
declare const ToolCallErrorPayloadSchema: z.ZodObject<{
|
|
51
83
|
tool_name: z.ZodString;
|
|
52
84
|
error_type: z.ZodString;
|
|
53
85
|
error_body: z.ZodString;
|
|
54
86
|
duration_ms: z.ZodDefault<z.ZodNullable<z.ZodNumber>>;
|
|
87
|
+
result: z.ZodOptional<z.ZodNullable<z.ZodUnknown>>;
|
|
55
88
|
}, z.core.$strict>;
|
|
56
89
|
type ToolCallErrorPayload = z.infer<typeof ToolCallErrorPayloadSchema>;
|
|
57
90
|
/** Agent-supplied context. All fields nullable per SPEC §5.1.1 — the agent
|
|
@@ -96,6 +129,27 @@ type SurfaceSnapshotPayload = z.infer<typeof SurfaceSnapshotPayloadSchema>;
|
|
|
96
129
|
* threaded through an environment variable that reads to nobody.
|
|
97
130
|
*/
|
|
98
131
|
declare const DEFAULT_CONSENT_TOKEN = "customer-consented";
|
|
132
|
+
/** The principal as emitted — `{id, source, form}`, all three REQUIRED
|
|
133
|
+
* together (SPEC §11.4). The runtime shape of `identity.PrincipalWire`.
|
|
134
|
+
*
|
|
135
|
+
* `.strict()` mirrors Python's `extra="forbid"`: a member this producer does
|
|
136
|
+
* not know about is a malformed object, not a richer one.
|
|
137
|
+
*
|
|
138
|
+
* ⚠ **`source` and `form` are `z.string()`, not enums, on purpose** — the same
|
|
139
|
+
* decision `transport_observed` records and the collector's own columns make.
|
|
140
|
+
* A fourth `source` is already foreseen (alias-derived), and an enum would
|
|
141
|
+
* make this producer unable to emit a value SPEC registers later without a
|
|
142
|
+
* release. Worse, it would throw at the emit boundary — `emit()` catches that
|
|
143
|
+
* and DROPS the event, so the tool call survives and the capture does not,
|
|
144
|
+
* which is still the wrong trade for a value SPEC may register later. The
|
|
145
|
+
* safety lives in the consumer rules stated positively — trust only exactly
|
|
146
|
+
* `"attested"`, treat anything but exactly `"hashed"` as personal data — so an
|
|
147
|
+
* unregistered value fails safe without anything having to reject it. */
|
|
148
|
+
declare const PrincipalWireSchema: z.ZodObject<{
|
|
149
|
+
id: z.ZodString;
|
|
150
|
+
source: z.ZodString;
|
|
151
|
+
form: z.ZodString;
|
|
152
|
+
}, z.core.$strict>;
|
|
99
153
|
declare const EventTypeSchema: z.ZodEnum<{
|
|
100
154
|
tool_call_start: "tool_call_start";
|
|
101
155
|
tool_call_end: "tool_call_end";
|
|
@@ -123,7 +177,11 @@ declare const ToolCallStartEventSchema: z.ZodObject<{
|
|
|
123
177
|
consent_token: z.ZodString;
|
|
124
178
|
sdk_version: z.ZodDefault<z.ZodString>;
|
|
125
179
|
agent_runtime: z.ZodDefault<z.ZodString>;
|
|
126
|
-
|
|
180
|
+
principal: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
181
|
+
id: z.ZodString;
|
|
182
|
+
source: z.ZodString;
|
|
183
|
+
form: z.ZodString;
|
|
184
|
+
}, z.core.$strict>>>;
|
|
127
185
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
128
186
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
129
187
|
runtime_meta: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
@@ -145,7 +203,11 @@ declare const ToolCallEndEventSchema: z.ZodObject<{
|
|
|
145
203
|
consent_token: z.ZodString;
|
|
146
204
|
sdk_version: z.ZodDefault<z.ZodString>;
|
|
147
205
|
agent_runtime: z.ZodDefault<z.ZodString>;
|
|
148
|
-
|
|
206
|
+
principal: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
207
|
+
id: z.ZodString;
|
|
208
|
+
source: z.ZodString;
|
|
209
|
+
form: z.ZodString;
|
|
210
|
+
}, z.core.$strict>>>;
|
|
149
211
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
150
212
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
151
213
|
runtime_meta: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
@@ -158,6 +220,7 @@ declare const ToolCallErrorEventSchema: z.ZodObject<{
|
|
|
158
220
|
error_type: z.ZodString;
|
|
159
221
|
error_body: z.ZodString;
|
|
160
222
|
duration_ms: z.ZodDefault<z.ZodNullable<z.ZodNumber>>;
|
|
223
|
+
result: z.ZodOptional<z.ZodNullable<z.ZodUnknown>>;
|
|
161
224
|
}, z.core.$strict>;
|
|
162
225
|
event_id: z.ZodDefault<z.ZodUUID>;
|
|
163
226
|
tenant_id: z.ZodString;
|
|
@@ -168,7 +231,11 @@ declare const ToolCallErrorEventSchema: z.ZodObject<{
|
|
|
168
231
|
consent_token: z.ZodString;
|
|
169
232
|
sdk_version: z.ZodDefault<z.ZodString>;
|
|
170
233
|
agent_runtime: z.ZodDefault<z.ZodString>;
|
|
171
|
-
|
|
234
|
+
principal: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
235
|
+
id: z.ZodString;
|
|
236
|
+
source: z.ZodString;
|
|
237
|
+
form: z.ZodString;
|
|
238
|
+
}, z.core.$strict>>>;
|
|
172
239
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
173
240
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
174
241
|
runtime_meta: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
@@ -195,7 +262,11 @@ declare const AnnotationEventSchema: z.ZodObject<{
|
|
|
195
262
|
consent_token: z.ZodString;
|
|
196
263
|
sdk_version: z.ZodDefault<z.ZodString>;
|
|
197
264
|
agent_runtime: z.ZodDefault<z.ZodString>;
|
|
198
|
-
|
|
265
|
+
principal: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
266
|
+
id: z.ZodString;
|
|
267
|
+
source: z.ZodString;
|
|
268
|
+
form: z.ZodString;
|
|
269
|
+
}, z.core.$strict>>>;
|
|
199
270
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
200
271
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
201
272
|
runtime_meta: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
@@ -220,7 +291,11 @@ declare const SurfaceSnapshotEventSchema: z.ZodObject<{
|
|
|
220
291
|
consent_token: z.ZodString;
|
|
221
292
|
sdk_version: z.ZodDefault<z.ZodString>;
|
|
222
293
|
agent_runtime: z.ZodDefault<z.ZodString>;
|
|
223
|
-
|
|
294
|
+
principal: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
295
|
+
id: z.ZodString;
|
|
296
|
+
source: z.ZodString;
|
|
297
|
+
form: z.ZodString;
|
|
298
|
+
}, z.core.$strict>>>;
|
|
224
299
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
225
300
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
226
301
|
runtime_meta: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
@@ -245,7 +320,11 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
245
320
|
consent_token: z.ZodString;
|
|
246
321
|
sdk_version: z.ZodDefault<z.ZodString>;
|
|
247
322
|
agent_runtime: z.ZodDefault<z.ZodString>;
|
|
248
|
-
|
|
323
|
+
principal: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
324
|
+
id: z.ZodString;
|
|
325
|
+
source: z.ZodString;
|
|
326
|
+
form: z.ZodString;
|
|
327
|
+
}, z.core.$strict>>>;
|
|
249
328
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
250
329
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
251
330
|
runtime_meta: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
@@ -265,7 +344,11 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
265
344
|
consent_token: z.ZodString;
|
|
266
345
|
sdk_version: z.ZodDefault<z.ZodString>;
|
|
267
346
|
agent_runtime: z.ZodDefault<z.ZodString>;
|
|
268
|
-
|
|
347
|
+
principal: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
348
|
+
id: z.ZodString;
|
|
349
|
+
source: z.ZodString;
|
|
350
|
+
form: z.ZodString;
|
|
351
|
+
}, z.core.$strict>>>;
|
|
269
352
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
270
353
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
271
354
|
runtime_meta: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
@@ -276,6 +359,7 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
276
359
|
error_type: z.ZodString;
|
|
277
360
|
error_body: z.ZodString;
|
|
278
361
|
duration_ms: z.ZodDefault<z.ZodNullable<z.ZodNumber>>;
|
|
362
|
+
result: z.ZodOptional<z.ZodNullable<z.ZodUnknown>>;
|
|
279
363
|
}, z.core.$strict>;
|
|
280
364
|
event_id: z.ZodDefault<z.ZodUUID>;
|
|
281
365
|
tenant_id: z.ZodString;
|
|
@@ -286,7 +370,11 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
286
370
|
consent_token: z.ZodString;
|
|
287
371
|
sdk_version: z.ZodDefault<z.ZodString>;
|
|
288
372
|
agent_runtime: z.ZodDefault<z.ZodString>;
|
|
289
|
-
|
|
373
|
+
principal: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
374
|
+
id: z.ZodString;
|
|
375
|
+
source: z.ZodString;
|
|
376
|
+
form: z.ZodString;
|
|
377
|
+
}, z.core.$strict>>>;
|
|
290
378
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
291
379
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
292
380
|
runtime_meta: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
@@ -311,7 +399,11 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
311
399
|
consent_token: z.ZodString;
|
|
312
400
|
sdk_version: z.ZodDefault<z.ZodString>;
|
|
313
401
|
agent_runtime: z.ZodDefault<z.ZodString>;
|
|
314
|
-
|
|
402
|
+
principal: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
403
|
+
id: z.ZodString;
|
|
404
|
+
source: z.ZodString;
|
|
405
|
+
form: z.ZodString;
|
|
406
|
+
}, z.core.$strict>>>;
|
|
315
407
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
316
408
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
317
409
|
runtime_meta: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
@@ -334,7 +426,11 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
334
426
|
consent_token: z.ZodString;
|
|
335
427
|
sdk_version: z.ZodDefault<z.ZodString>;
|
|
336
428
|
agent_runtime: z.ZodDefault<z.ZodString>;
|
|
337
|
-
|
|
429
|
+
principal: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
430
|
+
id: z.ZodString;
|
|
431
|
+
source: z.ZodString;
|
|
432
|
+
form: z.ZodString;
|
|
433
|
+
}, z.core.$strict>>>;
|
|
338
434
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
339
435
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
340
436
|
runtime_meta: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
@@ -551,12 +647,34 @@ declare class HttpSink implements Sink {
|
|
|
551
647
|
private sendWithRetry;
|
|
552
648
|
}
|
|
553
649
|
|
|
554
|
-
/**
|
|
650
|
+
/** Principal identity — resolve a raw principal, hash it at the edge.
|
|
555
651
|
*
|
|
556
|
-
*
|
|
557
|
-
*
|
|
558
|
-
*
|
|
559
|
-
|
|
652
|
+
* The TypeScript half of Python's `baton/identity.py`. Baton attaches the
|
|
653
|
+
* resolved principal to every event so the Console can group by
|
|
654
|
+
* `(tenant_id, vendor_id, principal.id)`, at whatever grain the vendor
|
|
655
|
+
* resolved (SPEC §11.4).
|
|
656
|
+
*
|
|
657
|
+
* Residency contract: the Console DB is metadata-only and may only ever see
|
|
658
|
+
* the HASH — raw identity must never leave the capture edge. So hashing
|
|
659
|
+
* happens HERE, before an event reaches any console-bound sink.
|
|
660
|
+
*
|
|
661
|
+
* ⚠ **This file and Python's must produce byte-identical digests**, and that
|
|
662
|
+
* is asserted rather than believed: `test/identity.test.ts` runs a corpus
|
|
663
|
+
* GENERATED from Python (`test/identityVectors.json`, regenerated by
|
|
664
|
+
* `scripts/gen_identity_vectors.py`) and compares strings. Same discipline as
|
|
665
|
+
* `scrub.ts` — though NOT its method, which was a hand-mirrored matrix, not a
|
|
666
|
+
* generated corpus — for the same reason: one person reaching two SDKs must be one
|
|
667
|
+
* actor downstream, and nothing but a differential corpus can prove it.
|
|
668
|
+
*/
|
|
669
|
+
/** Where a principal came from. `"asserted"` is a vendor's own resolver,
|
|
670
|
+
* which nothing in the protocol checks, and is the only value this SDK
|
|
671
|
+
* emits — `integrations/mcp/principalResolution.ts` has the why, and the
|
|
672
|
+
* wording trap that comes with it. */
|
|
673
|
+
declare const PRINCIPAL_SOURCE_ASSERTED = "asserted";
|
|
674
|
+
/** What the emitted value IS — the privacy classification, and the only thing
|
|
675
|
+
* SPEC §11.4 lets a consumer classify on. */
|
|
676
|
+
declare const PRINCIPAL_FORM_HASHED = "hashed";
|
|
677
|
+
declare const PRINCIPAL_FORM_RAW = "raw";
|
|
560
678
|
declare const PRINCIPAL_ID_MODE_HASHED = "hashed";
|
|
561
679
|
declare const PRINCIPAL_ID_MODE_RAW = "raw";
|
|
562
680
|
type PrincipalIdMode = typeof PRINCIPAL_ID_MODE_HASHED | typeof PRINCIPAL_ID_MODE_RAW;
|
|
@@ -572,17 +690,13 @@ interface Principal {
|
|
|
572
690
|
* to different people. */
|
|
573
691
|
issuer?: string | null | undefined;
|
|
574
692
|
}
|
|
575
|
-
/** HMAC-SHA256 a raw principal into a console-safe, per-tenant `
|
|
693
|
+
/** HMAC-SHA256 a raw principal into a console-safe, per-tenant `principal.id`.
|
|
576
694
|
*
|
|
577
695
|
* `tenantId` is folded into the HMAC MESSAGE (not just the key) so the same
|
|
578
696
|
* principal under two tenants can never collide or be cross-tenant-correlated.
|
|
579
|
-
* Returns
|
|
580
|
-
*
|
|
581
|
-
*
|
|
582
|
-
* given `(tenantId, principal, issuer)` is identical under every scheme,
|
|
583
|
-
* because the tag is not part of the message. That is deliberate: the same
|
|
584
|
-
* person reached by two provenances is meant to be recognisably the same hex
|
|
585
|
-
* under two tags, not two unrelated values.
|
|
697
|
+
* Returns the BARE lowercase hex digest — no tag, no prefix, no scheme. It
|
|
698
|
+
* returned `"h1:<hex>"` until 0.4.1; the tag was never part of the HMAC
|
|
699
|
+
* message, so taking it off moved no digit of the digest.
|
|
586
700
|
*
|
|
587
701
|
* ⚠ **`issuer` null/undefined MUST hash byte-identically to the pre-issuer
|
|
588
702
|
* form** — the append-only message layout is what guarantees it, and every
|
|
@@ -592,16 +706,6 @@ declare function hashPrincipalId(rawPrincipal: string, options: {
|
|
|
592
706
|
tenantId: string;
|
|
593
707
|
key: Uint8Array | string;
|
|
594
708
|
issuer?: string | null | undefined;
|
|
595
|
-
/** ⚠ **REQUIRED, and deliberately NOT defaulted the way Python's is.**
|
|
596
|
-
* Python defaults to `HASH_SCHEME` (`h1:`), which is right there because
|
|
597
|
-
* that arm emits both provenances. This arm emits ONLY `v1:` — it has no
|
|
598
|
-
* attested rung — so an `h1:` default would hand the documented
|
|
599
|
-
* "recompute the pseudonym to join your own records against Console data"
|
|
600
|
-
* use a value matching nothing we ever wrote, forever, with an equality
|
|
601
|
-
* join silently returning zero rows. The hex halves are identical under
|
|
602
|
-
* both tags, so it fails in the most confusing way available. Naming the
|
|
603
|
-
* provenance is one word and removes the whole failure. */
|
|
604
|
-
scheme: string;
|
|
605
709
|
}): string;
|
|
606
710
|
|
|
607
711
|
/** `BatonConfig.resolvePrincipal` — the ASSERTED identity provenance.
|
|
@@ -611,7 +715,18 @@ declare function hashPrincipalId(rawPrincipal: string, options: {
|
|
|
611
715
|
* envelope since 0.3.0 and NOTHING could populate it, so a partition that
|
|
612
716
|
* works on one of two SDKs is not a partition.
|
|
613
717
|
*
|
|
614
|
-
* **Hook only — there is deliberately no
|
|
718
|
+
* **Hook only — there is deliberately no ATTESTED rung here yet**, so every
|
|
719
|
+
* principal this SDK emits carries `source: "asserted"`.
|
|
720
|
+
*
|
|
721
|
+
* ⚠ **The missing rung has no shape on the value, and never will again.** This
|
|
722
|
+
* note said "saying `no h1: rung` would be false, because this SDK does emit
|
|
723
|
+
* `h1:`" — true until 0.4.1, when the tag came off the value entirely (SPEC
|
|
724
|
+
* §11.4, §13 entry 0.8.11). A hashed principal is now the bare digest, so there
|
|
725
|
+
* is no prefix to be right or wrong about: the missing thing is the
|
|
726
|
+
* `source: "attested"` VALUE, and a consumer reads `source` to learn it. SPEC
|
|
727
|
+
* §11.4 forbids presenting an asserted principal as verified, and this arm has
|
|
728
|
+
* only asserted to present.
|
|
729
|
+
*
|
|
615
730
|
* Python reads `claims["sub"]` off a verified access token; TypeScript's
|
|
616
731
|
* `AuthInfo` has no `claims` field at all (it is
|
|
617
732
|
* `{token, clientId, scopes, expiresAt?, resource?, extra?}`), so the nearest
|
|
@@ -763,7 +878,8 @@ interface BatonConfig {
|
|
|
763
878
|
* regardless of this setting (see `schemaCompat.injectGoalParams`). */
|
|
764
879
|
intentParamMode?: "optional" | "required" | "off";
|
|
765
880
|
/** Per-request principal identity — the ASSERTED provenance behind the
|
|
766
|
-
* envelope's `
|
|
881
|
+
* envelope's `principal` (SPEC §11.4 rung 0), which emits
|
|
882
|
+
* `source: "asserted"`. It is the only provenance this SDK has.
|
|
767
883
|
*
|
|
768
884
|
* Called on every captured tool call and on the annotation tool, with an
|
|
769
885
|
* adapter-neutral {@link PrincipalResolutionContext}: headers folded to ONE
|
|
@@ -780,17 +896,18 @@ interface BatonConfig {
|
|
|
780
896
|
* anonymous call. ⚠ It is awaited INLINE with no timeout — a blocking hook
|
|
781
897
|
* stalls its own request. */
|
|
782
898
|
resolvePrincipal?: ResolvePrincipalHook;
|
|
783
|
-
/** `"hashed"` (default) emits a
|
|
784
|
-
* emits the subject VERBATIM
|
|
899
|
+
/** `"hashed"` (default) emits a per-tenant HMAC pseudonym and
|
|
900
|
+
* `form: "hashed"`; `"raw"` emits the subject VERBATIM and `form: "raw"`.
|
|
785
901
|
*
|
|
786
|
-
* `"raw"` puts real identity in the collector's database and is the
|
|
787
|
-
*
|
|
788
|
-
*
|
|
789
|
-
|
|
902
|
+
* `"raw"` puts real identity in the collector's database and is the vendor's
|
|
903
|
+
* deliberate choice. ⚠ A consumer classifies on `form`, never on this
|
|
904
|
+
* setting — `PrincipalWireSchema` carries the rule and why it is stated that
|
|
905
|
+
* way round. */
|
|
906
|
+
principalIdMode?: PrincipalIdMode;
|
|
790
907
|
/** The HMAC secret for hashed mode. Resolved explicit →
|
|
791
908
|
* `BATON_PRINCIPAL_ID_HMAC_KEY` → unset.
|
|
792
909
|
*
|
|
793
|
-
* ⚠ **With none set, hashed mode DROPS
|
|
910
|
+
* ⚠ **With none set, hashed mode DROPS the principal rather than falling back to
|
|
794
911
|
* raw.** The fallback would be a residency breach that looks like success:
|
|
795
912
|
* the field present, populated, and carrying the subject verbatim. */
|
|
796
913
|
principalIdHmacKey?: string | Uint8Array;
|
|
@@ -850,7 +967,11 @@ declare class BatonHandle {
|
|
|
850
967
|
* ```
|
|
851
968
|
*
|
|
852
969
|
* Wraps every tool call to emit `tool_call_start` → call → `tool_call_end` /
|
|
853
|
-
* `tool_call_error
|
|
970
|
+
* `tool_call_error` — the latter on FAILURE, which MCP expresses two ways
|
|
971
|
+
* (SPEC §11.4.3): the vendor handler throws, or it returns a result carrying
|
|
972
|
+
* MCP's error flag on a 200. Reading only the first is what this package did,
|
|
973
|
+
* and what §6.1's own wording told it to. Injects server `instructions`
|
|
974
|
+
* (SPEC §5.1.2), registers
|
|
854
975
|
* the `<vendor>_annotate` tool (SPEC §5.1.1), injects `user_goal`/
|
|
855
976
|
* `expected_result`/`overall_task` intent params on every wrapped tool's
|
|
856
977
|
* schema (SPEC §11.4.1 `call_intent`/`call_expected`/`call_workflow`/
|
|
@@ -918,4 +1039,4 @@ interface SupportedMcpServer {
|
|
|
918
1039
|
/** Install Baton into an `McpServer`. See module docstring for usage. */
|
|
919
1040
|
declare function withBaton(server: SupportedMcpServer, supplied?: BatonConfig): BatonHandle;
|
|
920
1041
|
|
|
921
|
-
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,
|
|
1042
|
+
export { type AnnotationEvent, AnnotationEventSchema, type AnnotationPayload, AnnotationPayloadSchema, type BatonConfig, BatonHandle, DEFAULT_CONSENT_TOKEN, DEPTH_LIMIT, type Event, EventSchema, type EventType, EventTypeSchema, HttpSink, type HttpSinkOptions, PRINCIPAL_FORM_HASHED, PRINCIPAL_FORM_RAW, PRINCIPAL_SOURCE_ASSERTED, type Principal, type PrincipalIdMode, type PrincipalResolutionContext, PrincipalWireSchema, 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, hashPrincipalId, identityScrub, safeWrite, withBaton };
|