@goodtiming/baton-sdk 0.3.6 → 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/README.md +41 -160
- package/dist/index.cjs +202 -41
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +203 -47
- package/dist/index.d.ts +203 -47
- package/dist/index.js +197 -40
- 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,12 @@ 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>>>;
|
|
185
|
+
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
127
186
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
128
187
|
runtime_meta: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
129
188
|
}, z.core.$strict>;
|
|
@@ -144,7 +203,12 @@ declare const ToolCallEndEventSchema: z.ZodObject<{
|
|
|
144
203
|
consent_token: z.ZodString;
|
|
145
204
|
sdk_version: z.ZodDefault<z.ZodString>;
|
|
146
205
|
agent_runtime: z.ZodDefault<z.ZodString>;
|
|
147
|
-
|
|
206
|
+
principal: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
207
|
+
id: z.ZodString;
|
|
208
|
+
source: z.ZodString;
|
|
209
|
+
form: z.ZodString;
|
|
210
|
+
}, z.core.$strict>>>;
|
|
211
|
+
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
148
212
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
149
213
|
runtime_meta: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
150
214
|
}, z.core.$strict>;
|
|
@@ -156,6 +220,7 @@ declare const ToolCallErrorEventSchema: z.ZodObject<{
|
|
|
156
220
|
error_type: z.ZodString;
|
|
157
221
|
error_body: z.ZodString;
|
|
158
222
|
duration_ms: z.ZodDefault<z.ZodNullable<z.ZodNumber>>;
|
|
223
|
+
result: z.ZodOptional<z.ZodNullable<z.ZodUnknown>>;
|
|
159
224
|
}, z.core.$strict>;
|
|
160
225
|
event_id: z.ZodDefault<z.ZodUUID>;
|
|
161
226
|
tenant_id: z.ZodString;
|
|
@@ -166,7 +231,12 @@ declare const ToolCallErrorEventSchema: z.ZodObject<{
|
|
|
166
231
|
consent_token: z.ZodString;
|
|
167
232
|
sdk_version: z.ZodDefault<z.ZodString>;
|
|
168
233
|
agent_runtime: z.ZodDefault<z.ZodString>;
|
|
169
|
-
|
|
234
|
+
principal: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
235
|
+
id: z.ZodString;
|
|
236
|
+
source: z.ZodString;
|
|
237
|
+
form: z.ZodString;
|
|
238
|
+
}, z.core.$strict>>>;
|
|
239
|
+
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
170
240
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
171
241
|
runtime_meta: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
172
242
|
}, z.core.$strict>;
|
|
@@ -192,7 +262,12 @@ declare const AnnotationEventSchema: z.ZodObject<{
|
|
|
192
262
|
consent_token: z.ZodString;
|
|
193
263
|
sdk_version: z.ZodDefault<z.ZodString>;
|
|
194
264
|
agent_runtime: z.ZodDefault<z.ZodString>;
|
|
195
|
-
|
|
265
|
+
principal: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
266
|
+
id: z.ZodString;
|
|
267
|
+
source: z.ZodString;
|
|
268
|
+
form: z.ZodString;
|
|
269
|
+
}, z.core.$strict>>>;
|
|
270
|
+
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
196
271
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
197
272
|
runtime_meta: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
198
273
|
}, z.core.$strict>;
|
|
@@ -216,7 +291,12 @@ declare const SurfaceSnapshotEventSchema: z.ZodObject<{
|
|
|
216
291
|
consent_token: z.ZodString;
|
|
217
292
|
sdk_version: z.ZodDefault<z.ZodString>;
|
|
218
293
|
agent_runtime: z.ZodDefault<z.ZodString>;
|
|
219
|
-
|
|
294
|
+
principal: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
295
|
+
id: z.ZodString;
|
|
296
|
+
source: z.ZodString;
|
|
297
|
+
form: z.ZodString;
|
|
298
|
+
}, z.core.$strict>>>;
|
|
299
|
+
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
220
300
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
221
301
|
runtime_meta: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
222
302
|
}, z.core.$strict>;
|
|
@@ -240,7 +320,12 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
240
320
|
consent_token: z.ZodString;
|
|
241
321
|
sdk_version: z.ZodDefault<z.ZodString>;
|
|
242
322
|
agent_runtime: z.ZodDefault<z.ZodString>;
|
|
243
|
-
|
|
323
|
+
principal: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
324
|
+
id: z.ZodString;
|
|
325
|
+
source: z.ZodString;
|
|
326
|
+
form: z.ZodString;
|
|
327
|
+
}, z.core.$strict>>>;
|
|
328
|
+
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
244
329
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
245
330
|
runtime_meta: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
246
331
|
}, z.core.$strict>, z.ZodObject<{
|
|
@@ -259,7 +344,12 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
259
344
|
consent_token: z.ZodString;
|
|
260
345
|
sdk_version: z.ZodDefault<z.ZodString>;
|
|
261
346
|
agent_runtime: z.ZodDefault<z.ZodString>;
|
|
262
|
-
|
|
347
|
+
principal: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
348
|
+
id: z.ZodString;
|
|
349
|
+
source: z.ZodString;
|
|
350
|
+
form: z.ZodString;
|
|
351
|
+
}, z.core.$strict>>>;
|
|
352
|
+
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
263
353
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
264
354
|
runtime_meta: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
265
355
|
}, z.core.$strict>, z.ZodObject<{
|
|
@@ -269,6 +359,7 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
269
359
|
error_type: z.ZodString;
|
|
270
360
|
error_body: z.ZodString;
|
|
271
361
|
duration_ms: z.ZodDefault<z.ZodNullable<z.ZodNumber>>;
|
|
362
|
+
result: z.ZodOptional<z.ZodNullable<z.ZodUnknown>>;
|
|
272
363
|
}, z.core.$strict>;
|
|
273
364
|
event_id: z.ZodDefault<z.ZodUUID>;
|
|
274
365
|
tenant_id: z.ZodString;
|
|
@@ -279,7 +370,12 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
279
370
|
consent_token: z.ZodString;
|
|
280
371
|
sdk_version: z.ZodDefault<z.ZodString>;
|
|
281
372
|
agent_runtime: z.ZodDefault<z.ZodString>;
|
|
282
|
-
|
|
373
|
+
principal: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
374
|
+
id: z.ZodString;
|
|
375
|
+
source: z.ZodString;
|
|
376
|
+
form: z.ZodString;
|
|
377
|
+
}, z.core.$strict>>>;
|
|
378
|
+
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
283
379
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
284
380
|
runtime_meta: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
285
381
|
}, z.core.$strict>, z.ZodObject<{
|
|
@@ -303,7 +399,12 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
303
399
|
consent_token: z.ZodString;
|
|
304
400
|
sdk_version: z.ZodDefault<z.ZodString>;
|
|
305
401
|
agent_runtime: z.ZodDefault<z.ZodString>;
|
|
306
|
-
|
|
402
|
+
principal: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
403
|
+
id: z.ZodString;
|
|
404
|
+
source: z.ZodString;
|
|
405
|
+
form: z.ZodString;
|
|
406
|
+
}, z.core.$strict>>>;
|
|
407
|
+
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
307
408
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
308
409
|
runtime_meta: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
309
410
|
}, z.core.$strict>, z.ZodObject<{
|
|
@@ -325,7 +426,12 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
325
426
|
consent_token: z.ZodString;
|
|
326
427
|
sdk_version: z.ZodDefault<z.ZodString>;
|
|
327
428
|
agent_runtime: z.ZodDefault<z.ZodString>;
|
|
328
|
-
|
|
429
|
+
principal: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
430
|
+
id: z.ZodString;
|
|
431
|
+
source: z.ZodString;
|
|
432
|
+
form: z.ZodString;
|
|
433
|
+
}, z.core.$strict>>>;
|
|
434
|
+
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
329
435
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
330
436
|
runtime_meta: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
331
437
|
}, z.core.$strict>], "event_type">;
|
|
@@ -541,12 +647,47 @@ declare class HttpSink implements Sink {
|
|
|
541
647
|
private sendWithRetry;
|
|
542
648
|
}
|
|
543
649
|
|
|
544
|
-
/**
|
|
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).
|
|
545
656
|
*
|
|
546
|
-
*
|
|
547
|
-
*
|
|
548
|
-
*
|
|
549
|
-
|
|
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";
|
|
550
691
|
declare const PRINCIPAL_ID_MODE_HASHED = "hashed";
|
|
551
692
|
declare const PRINCIPAL_ID_MODE_RAW = "raw";
|
|
552
693
|
type PrincipalIdMode = typeof PRINCIPAL_ID_MODE_HASHED | typeof PRINCIPAL_ID_MODE_RAW;
|
|
@@ -562,17 +703,15 @@ interface Principal {
|
|
|
562
703
|
* to different people. */
|
|
563
704
|
issuer?: string | null | undefined;
|
|
564
705
|
}
|
|
565
|
-
/** 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`.
|
|
566
707
|
*
|
|
567
708
|
* `tenantId` is folded into the HMAC MESSAGE (not just the key) so the same
|
|
568
709
|
* principal under two tenants can never collide or be cross-tenant-correlated.
|
|
569
710
|
* Returns `"<scheme>:<hex>"`.
|
|
570
711
|
*
|
|
571
|
-
* `scheme`
|
|
572
|
-
*
|
|
573
|
-
*
|
|
574
|
-
* person reached by two provenances is meant to be recognisably the same hex
|
|
575
|
-
* 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`.
|
|
576
715
|
*
|
|
577
716
|
* ⚠ **`issuer` null/undefined MUST hash byte-identically to the pre-issuer
|
|
578
717
|
* form** — the append-only message layout is what guarantees it, and every
|
|
@@ -582,16 +721,18 @@ declare function hashPrincipalId(rawPrincipal: string, options: {
|
|
|
582
721
|
tenantId: string;
|
|
583
722
|
key: Uint8Array | string;
|
|
584
723
|
issuer?: string | null | undefined;
|
|
585
|
-
/**
|
|
586
|
-
*
|
|
587
|
-
*
|
|
588
|
-
*
|
|
589
|
-
*
|
|
590
|
-
*
|
|
591
|
-
*
|
|
592
|
-
*
|
|
593
|
-
*
|
|
594
|
-
|
|
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;
|
|
595
736
|
}): string;
|
|
596
737
|
|
|
597
738
|
/** `BatonConfig.resolvePrincipal` — the ASSERTED identity provenance.
|
|
@@ -601,7 +742,16 @@ declare function hashPrincipalId(rawPrincipal: string, options: {
|
|
|
601
742
|
* envelope since 0.3.0 and NOTHING could populate it, so a partition that
|
|
602
743
|
* works on one of two SDKs is not a partition.
|
|
603
744
|
*
|
|
604
|
-
* **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
|
+
*
|
|
605
755
|
* Python reads `claims["sub"]` off a verified access token; TypeScript's
|
|
606
756
|
* `AuthInfo` has no `claims` field at all (it is
|
|
607
757
|
* `{token, clientId, scopes, expiresAt?, resource?, extra?}`), so the nearest
|
|
@@ -753,7 +903,8 @@ interface BatonConfig {
|
|
|
753
903
|
* regardless of this setting (see `schemaCompat.injectGoalParams`). */
|
|
754
904
|
intentParamMode?: "optional" | "required" | "off";
|
|
755
905
|
/** Per-request principal identity — the ASSERTED provenance behind the
|
|
756
|
-
* envelope's `
|
|
906
|
+
* envelope's `principal` (SPEC §11.4 rung 0), which emits
|
|
907
|
+
* `source: "asserted"`. It is the only provenance this SDK has.
|
|
757
908
|
*
|
|
758
909
|
* Called on every captured tool call and on the annotation tool, with an
|
|
759
910
|
* adapter-neutral {@link PrincipalResolutionContext}: headers folded to ONE
|
|
@@ -770,17 +921,18 @@ interface BatonConfig {
|
|
|
770
921
|
* anonymous call. ⚠ It is awaited INLINE with no timeout — a blocking hook
|
|
771
922
|
* stalls its own request. */
|
|
772
923
|
resolvePrincipal?: ResolvePrincipalHook;
|
|
773
|
-
/** `"hashed"` (default) emits a
|
|
774
|
-
* 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"`.
|
|
775
926
|
*
|
|
776
|
-
* `"raw"` puts real identity in the collector's database and is the
|
|
777
|
-
*
|
|
778
|
-
*
|
|
779
|
-
|
|
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;
|
|
780
932
|
/** The HMAC secret for hashed mode. Resolved explicit →
|
|
781
933
|
* `BATON_PRINCIPAL_ID_HMAC_KEY` → unset.
|
|
782
934
|
*
|
|
783
|
-
* ⚠ **With none set, hashed mode DROPS
|
|
935
|
+
* ⚠ **With none set, hashed mode DROPS the principal rather than falling back to
|
|
784
936
|
* raw.** The fallback would be a residency breach that looks like success:
|
|
785
937
|
* the field present, populated, and carrying the subject verbatim. */
|
|
786
938
|
principalIdHmacKey?: string | Uint8Array;
|
|
@@ -840,14 +992,18 @@ declare class BatonHandle {
|
|
|
840
992
|
* ```
|
|
841
993
|
*
|
|
842
994
|
* Wraps every tool call to emit `tool_call_start` → call → `tool_call_end` /
|
|
843
|
-
* `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
|
|
844
1000
|
* the `<vendor>_annotate` tool (SPEC §5.1.1), injects `user_goal`/
|
|
845
1001
|
* `expected_result`/`overall_task` intent params on every wrapped tool's
|
|
846
1002
|
* schema (SPEC §11.4.1 `call_intent`/`call_expected`/`call_workflow`/
|
|
847
1003
|
* `intent_source`), and captures a `surface_snapshot`
|
|
848
1004
|
* of the vendor-true surface. Every payload leaving here runs through the
|
|
849
1005
|
* configured scrubber, which defaults to the shipped ruleset (`src/scrub.ts`)
|
|
850
|
-
* — see README "What
|
|
1006
|
+
* — see README "What is not here yet" for what's still not here (the low-level
|
|
851
1007
|
* `Server` adapter).
|
|
852
1008
|
*
|
|
853
1009
|
* Interception mechanism: `McpServer` has no middleware API (unlike the
|
|
@@ -908,4 +1064,4 @@ interface SupportedMcpServer {
|
|
|
908
1064
|
/** Install Baton into an `McpServer`. See module docstring for usage. */
|
|
909
1065
|
declare function withBaton(server: SupportedMcpServer, supplied?: BatonConfig): BatonHandle;
|
|
910
1066
|
|
|
911
|
-
export { type AnnotationEvent, AnnotationEventSchema, type AnnotationPayload, AnnotationPayloadSchema, type BatonConfig, BatonHandle, DEFAULT_CONSENT_TOKEN, DEPTH_LIMIT, type Event, EventSchema, type EventType, EventTypeSchema, HttpSink, type HttpSinkOptions, type Principal, type PrincipalIdMode, type PrincipalResolutionContext, type ResolvePrincipalHook, SDK_VERSION, Scrubber, type Sink, StdoutSink, type StdoutSinkOptions, type SupportedMcpServer, type SurfaceSnapshotEvent, SurfaceSnapshotEventSchema, type SurfaceSnapshotPayload, SurfaceSnapshotPayloadSchema, type ToolCallEndEvent, ToolCallEndEventSchema, type ToolCallEndPayload, ToolCallEndPayloadSchema, type ToolCallErrorEvent, ToolCallErrorEventSchema, type ToolCallErrorPayload, ToolCallErrorPayloadSchema, type ToolCallStartEvent, ToolCallStartEventSchema, type ToolCallStartPayload, ToolCallStartPayloadSchema,
|
|
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 };
|