@goodtiming/baton-sdk 0.3.7 → 0.4.0
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 +142 -40
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +192 -46
- package/dist/index.d.ts +192 -46
- package/dist/index.js +137 -39
- 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.0";
|
|
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,47 @@ 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.
|
|
651
|
+
*
|
|
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).
|
|
555
656
|
*
|
|
556
|
-
*
|
|
557
|
-
*
|
|
558
|
-
*
|
|
559
|
-
|
|
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
|
+
/** The HMAC KEY GENERATION, and nothing else.
|
|
670
|
+
*
|
|
671
|
+
* It is not a provenance marker and not a privacy classifier. Provenance is
|
|
672
|
+
* `PrincipalWire.source` and the classification is `PrincipalWire.form`, and
|
|
673
|
+
* both ride every mode — including `"raw"`, where no tag exists at all, which
|
|
674
|
+
* is the gap a tag can structurally never close. `h2:` is reserved for a key
|
|
675
|
+
* rotation. SPEC §11.4 and the §13 entry carry the full derivation.
|
|
676
|
+
*
|
|
677
|
+
* ⚠ **This value is a WIRE CONSTANT.** `test/identity.test.ts` pins it against
|
|
678
|
+
* Python's generated corpus by literal, not through this name — an assertion
|
|
679
|
+
* written as ``startsWith(`${HASH_SCHEME}:`)`` is self-referential and cannot
|
|
680
|
+
* see this constant change. */
|
|
681
|
+
declare const HASH_SCHEME = "h1";
|
|
682
|
+
/** Where a principal came from. `"asserted"` is a vendor's own resolver,
|
|
683
|
+
* which nothing in the protocol checks, and is the only value this SDK
|
|
684
|
+
* emits — `integrations/mcp/principalResolution.ts` has the why, and the
|
|
685
|
+
* wording trap that comes with it. */
|
|
686
|
+
declare const PRINCIPAL_SOURCE_ASSERTED = "asserted";
|
|
687
|
+
/** What the emitted value IS — the privacy classification, and the only thing
|
|
688
|
+
* SPEC §11.4 lets a consumer classify on. */
|
|
689
|
+
declare const PRINCIPAL_FORM_HASHED = "hashed";
|
|
690
|
+
declare const PRINCIPAL_FORM_RAW = "raw";
|
|
560
691
|
declare const PRINCIPAL_ID_MODE_HASHED = "hashed";
|
|
561
692
|
declare const PRINCIPAL_ID_MODE_RAW = "raw";
|
|
562
693
|
type PrincipalIdMode = typeof PRINCIPAL_ID_MODE_HASHED | typeof PRINCIPAL_ID_MODE_RAW;
|
|
@@ -572,17 +703,15 @@ interface Principal {
|
|
|
572
703
|
* to different people. */
|
|
573
704
|
issuer?: string | null | undefined;
|
|
574
705
|
}
|
|
575
|
-
/** HMAC-SHA256 a raw principal into a console-safe, per-tenant `
|
|
706
|
+
/** HMAC-SHA256 a raw principal into a console-safe, per-tenant `principal.id`.
|
|
576
707
|
*
|
|
577
708
|
* `tenantId` is folded into the HMAC MESSAGE (not just the key) so the same
|
|
578
709
|
* principal under two tenants can never collide or be cross-tenant-correlated.
|
|
579
710
|
* Returns `"<scheme>:<hex>"`.
|
|
580
711
|
*
|
|
581
|
-
* `scheme`
|
|
582
|
-
*
|
|
583
|
-
*
|
|
584
|
-
* person reached by two provenances is meant to be recognisably the same hex
|
|
585
|
-
* under two tags, not two unrelated values.
|
|
712
|
+
* `scheme` is NOT part of the HMAC message: the digest for a given
|
|
713
|
+
* `(tenantId, principal, issuer)` is identical under every scheme and only the
|
|
714
|
+
* prefix moves. What that buys is in `HASH_SCHEME`.
|
|
586
715
|
*
|
|
587
716
|
* ⚠ **`issuer` null/undefined MUST hash byte-identically to the pre-issuer
|
|
588
717
|
* form** — the append-only message layout is what guarantees it, and every
|
|
@@ -592,16 +721,18 @@ declare function hashPrincipalId(rawPrincipal: string, options: {
|
|
|
592
721
|
tenantId: string;
|
|
593
722
|
key: Uint8Array | string;
|
|
594
723
|
issuer?: string | null | undefined;
|
|
595
|
-
/**
|
|
596
|
-
*
|
|
597
|
-
*
|
|
598
|
-
*
|
|
599
|
-
*
|
|
600
|
-
*
|
|
601
|
-
*
|
|
602
|
-
*
|
|
603
|
-
*
|
|
604
|
-
|
|
724
|
+
/** The key generation, defaulting to the current one exactly as Python's
|
|
725
|
+
* does. A caller passes this only to reproduce a digest under a
|
|
726
|
+
* superseded key.
|
|
727
|
+
*
|
|
728
|
+
* `| undefined` explicitly, for the same `exactOptionalPropertyTypes`
|
|
729
|
+
* reason `issuer` carries above — and it bites HARDER here, because this
|
|
730
|
+
* option exists precisely to be omittable. Without it the natural vendor
|
|
731
|
+
* shape, forwarding an optional off their own config
|
|
732
|
+
* (`scheme: cfg.scheme` where `cfg.scheme: string | undefined`), is a
|
|
733
|
+
* compile error on the published types. No in-repo caller can see that:
|
|
734
|
+
* they either omit it or pass a concrete string from the corpus. */
|
|
735
|
+
scheme?: string | undefined;
|
|
605
736
|
}): string;
|
|
606
737
|
|
|
607
738
|
/** `BatonConfig.resolvePrincipal` — the ASSERTED identity provenance.
|
|
@@ -611,7 +742,16 @@ declare function hashPrincipalId(rawPrincipal: string, options: {
|
|
|
611
742
|
* envelope since 0.3.0 and NOTHING could populate it, so a partition that
|
|
612
743
|
* works on one of two SDKs is not a partition.
|
|
613
744
|
*
|
|
614
|
-
* **Hook only — there is deliberately no
|
|
745
|
+
* **Hook only — there is deliberately no ATTESTED rung here yet**, so every
|
|
746
|
+
* principal this SDK emits carries `source: "asserted"`.
|
|
747
|
+
*
|
|
748
|
+
* ⚠ **The missing rung is not named by the tag, and saying "no `h1:` rung"
|
|
749
|
+
* would now be false.** This SDK does emit `h1:` — that prefix is the HMAC KEY
|
|
750
|
+
* GENERATION and is the same on both provenances. What is missing is the
|
|
751
|
+
* `source: "attested"` value, and a consumer must read `source` to learn that,
|
|
752
|
+
* never the prefix. SPEC §11.4 forbids presenting an asserted principal as
|
|
753
|
+
* verified, and this arm has only asserted to present.
|
|
754
|
+
*
|
|
615
755
|
* Python reads `claims["sub"]` off a verified access token; TypeScript's
|
|
616
756
|
* `AuthInfo` has no `claims` field at all (it is
|
|
617
757
|
* `{token, clientId, scopes, expiresAt?, resource?, extra?}`), so the nearest
|
|
@@ -763,7 +903,8 @@ interface BatonConfig {
|
|
|
763
903
|
* regardless of this setting (see `schemaCompat.injectGoalParams`). */
|
|
764
904
|
intentParamMode?: "optional" | "required" | "off";
|
|
765
905
|
/** Per-request principal identity — the ASSERTED provenance behind the
|
|
766
|
-
* envelope's `
|
|
906
|
+
* envelope's `principal` (SPEC §11.4 rung 0), which emits
|
|
907
|
+
* `source: "asserted"`. It is the only provenance this SDK has.
|
|
767
908
|
*
|
|
768
909
|
* Called on every captured tool call and on the annotation tool, with an
|
|
769
910
|
* adapter-neutral {@link PrincipalResolutionContext}: headers folded to ONE
|
|
@@ -780,17 +921,18 @@ interface BatonConfig {
|
|
|
780
921
|
* anonymous call. ⚠ It is awaited INLINE with no timeout — a blocking hook
|
|
781
922
|
* stalls its own request. */
|
|
782
923
|
resolvePrincipal?: ResolvePrincipalHook;
|
|
783
|
-
/** `"hashed"` (default) emits a
|
|
784
|
-
* emits the subject VERBATIM
|
|
924
|
+
/** `"hashed"` (default) emits a per-tenant HMAC pseudonym and
|
|
925
|
+
* `form: "hashed"`; `"raw"` emits the subject VERBATIM and `form: "raw"`.
|
|
785
926
|
*
|
|
786
|
-
* `"raw"` puts real identity in the collector's database and is the
|
|
787
|
-
*
|
|
788
|
-
*
|
|
789
|
-
|
|
927
|
+
* `"raw"` puts real identity in the collector's database and is the vendor's
|
|
928
|
+
* deliberate choice. ⚠ A consumer classifies on `form`, never on this
|
|
929
|
+
* setting — `PrincipalWireSchema` carries the rule and why it is stated that
|
|
930
|
+
* way round. */
|
|
931
|
+
principalIdMode?: PrincipalIdMode;
|
|
790
932
|
/** The HMAC secret for hashed mode. Resolved explicit →
|
|
791
933
|
* `BATON_PRINCIPAL_ID_HMAC_KEY` → unset.
|
|
792
934
|
*
|
|
793
|
-
* ⚠ **With none set, hashed mode DROPS
|
|
935
|
+
* ⚠ **With none set, hashed mode DROPS the principal rather than falling back to
|
|
794
936
|
* raw.** The fallback would be a residency breach that looks like success:
|
|
795
937
|
* the field present, populated, and carrying the subject verbatim. */
|
|
796
938
|
principalIdHmacKey?: string | Uint8Array;
|
|
@@ -850,7 +992,11 @@ declare class BatonHandle {
|
|
|
850
992
|
* ```
|
|
851
993
|
*
|
|
852
994
|
* Wraps every tool call to emit `tool_call_start` → call → `tool_call_end` /
|
|
853
|
-
* `tool_call_error
|
|
995
|
+
* `tool_call_error` — the latter on FAILURE, which MCP expresses two ways
|
|
996
|
+
* (SPEC §11.4.3): the vendor handler throws, or it returns a result carrying
|
|
997
|
+
* MCP's error flag on a 200. Reading only the first is what this package did,
|
|
998
|
+
* and what §6.1's own wording told it to. Injects server `instructions`
|
|
999
|
+
* (SPEC §5.1.2), registers
|
|
854
1000
|
* the `<vendor>_annotate` tool (SPEC §5.1.1), injects `user_goal`/
|
|
855
1001
|
* `expected_result`/`overall_task` intent params on every wrapped tool's
|
|
856
1002
|
* schema (SPEC §11.4.1 `call_intent`/`call_expected`/`call_workflow`/
|
|
@@ -918,4 +1064,4 @@ interface SupportedMcpServer {
|
|
|
918
1064
|
/** Install Baton into an `McpServer`. See module docstring for usage. */
|
|
919
1065
|
declare function withBaton(server: SupportedMcpServer, supplied?: BatonConfig): BatonHandle;
|
|
920
1066
|
|
|
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,
|
|
1067
|
+
export { type AnnotationEvent, AnnotationEventSchema, type AnnotationPayload, AnnotationPayloadSchema, type BatonConfig, BatonHandle, DEFAULT_CONSENT_TOKEN, DEPTH_LIMIT, type Event, EventSchema, type EventType, EventTypeSchema, HASH_SCHEME, 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 };
|