@goodtiming/baton-sdk 0.6.1 → 0.6.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 +13 -9
- package/dist/index.cjs +995 -340
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +232 -29
- package/dist/index.d.ts +232 -29
- package/dist/index.js +990 -340
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
|
|
3
|
-
declare const SDK_VERSION = "ts-0.6.
|
|
3
|
+
declare const SDK_VERSION = "ts-0.6.2";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Zod schemas + TS types for the Baton event stream per SPEC §11.4.
|
|
@@ -119,6 +119,12 @@ declare const SurfaceSnapshotPayloadSchema: z.ZodObject<{
|
|
|
119
119
|
seam_augmentations: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
120
120
|
}, z.core.$strict>;
|
|
121
121
|
type SurfaceSnapshotPayload = z.infer<typeof SurfaceSnapshotPayloadSchema>;
|
|
122
|
+
/** This process's lost-event counts by reason, as running totals (SPEC §11.4.7). */
|
|
123
|
+
declare const ClientReportPayloadSchema: z.ZodObject<{
|
|
124
|
+
instance_id: z.ZodUUID;
|
|
125
|
+
dropped: z.ZodRecord<z.ZodString, z.ZodNumber>;
|
|
126
|
+
}, z.core.$strict>;
|
|
127
|
+
type ClientReportPayload = z.infer<typeof ClientReportPayloadSchema>;
|
|
122
128
|
/**
|
|
123
129
|
* What the SDK puts in `consent_token` when the vendor names no other value.
|
|
124
130
|
* Byte-for-byte Python's `baton.events.DEFAULT_CONSENT_TOKEN`, and the two
|
|
@@ -161,6 +167,7 @@ declare const EventTypeSchema: z.ZodEnum<{
|
|
|
161
167
|
tool_call_error: "tool_call_error";
|
|
162
168
|
annotation: "annotation";
|
|
163
169
|
surface_snapshot: "surface_snapshot";
|
|
170
|
+
client_report: "client_report";
|
|
164
171
|
resource_list_start: "resource_list_start";
|
|
165
172
|
resource_list_end: "resource_list_end";
|
|
166
173
|
resource_list_error: "resource_list_error";
|
|
@@ -549,6 +556,49 @@ declare const SurfaceSnapshotEventSchema: z.ZodObject<{
|
|
|
549
556
|
runtime_meta: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
550
557
|
}, z.core.$strict>;
|
|
551
558
|
type SurfaceSnapshotEvent = z.infer<typeof SurfaceSnapshotEventSchema>;
|
|
559
|
+
declare const ClientReportEventSchema: z.ZodObject<{
|
|
560
|
+
event_type: z.ZodDefault<z.ZodLiteral<"client_report">>;
|
|
561
|
+
payload: z.ZodObject<{
|
|
562
|
+
instance_id: z.ZodUUID;
|
|
563
|
+
dropped: z.ZodRecord<z.ZodString, z.ZodNumber>;
|
|
564
|
+
}, z.core.$strict>;
|
|
565
|
+
event_id: z.ZodDefault<z.ZodUUID>;
|
|
566
|
+
tenant_id: z.ZodString;
|
|
567
|
+
vendor_id: z.ZodString;
|
|
568
|
+
session_id: z.ZodString;
|
|
569
|
+
sequence_number: z.ZodNumber;
|
|
570
|
+
captured_at: z.ZodString;
|
|
571
|
+
consent_token: z.ZodString;
|
|
572
|
+
sdk_version: z.ZodDefault<z.ZodString>;
|
|
573
|
+
agent_runtime: z.ZodDefault<z.ZodString>;
|
|
574
|
+
principal: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
575
|
+
id: z.ZodString;
|
|
576
|
+
source: z.ZodString;
|
|
577
|
+
form: z.ZodString;
|
|
578
|
+
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
579
|
+
}, z.core.$strict>>>;
|
|
580
|
+
organization: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
581
|
+
id: z.ZodString;
|
|
582
|
+
source: z.ZodString;
|
|
583
|
+
form: z.ZodString;
|
|
584
|
+
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
585
|
+
}, z.core.$strict>>>;
|
|
586
|
+
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
587
|
+
session_id_origin: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
588
|
+
client_observed: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
589
|
+
info: z.ZodOptional<z.ZodObject<{
|
|
590
|
+
name: z.ZodOptional<z.ZodString>;
|
|
591
|
+
version: z.ZodOptional<z.ZodString>;
|
|
592
|
+
}, z.core.$strict>>;
|
|
593
|
+
headers: z.ZodOptional<z.ZodObject<{
|
|
594
|
+
"user-agent": z.ZodOptional<z.ZodString>;
|
|
595
|
+
"x-anthropic-client": z.ZodOptional<z.ZodString>;
|
|
596
|
+
}, z.core.$strict>>;
|
|
597
|
+
}, z.core.$strict>>>;
|
|
598
|
+
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
599
|
+
runtime_meta: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
600
|
+
}, z.core.$strict>;
|
|
601
|
+
type ClientReportEvent = z.infer<typeof ClientReportEventSchema>;
|
|
552
602
|
declare const ResourceListStartEventSchema: z.ZodObject<{
|
|
553
603
|
event_type: z.ZodDefault<z.ZodLiteral<"resource_list_start">>;
|
|
554
604
|
payload: z.ZodObject<{}, z.core.$strict>;
|
|
@@ -1418,6 +1468,47 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
1418
1468
|
}, z.core.$strict>>>;
|
|
1419
1469
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1420
1470
|
runtime_meta: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
1471
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
1472
|
+
event_type: z.ZodDefault<z.ZodLiteral<"client_report">>;
|
|
1473
|
+
payload: z.ZodObject<{
|
|
1474
|
+
instance_id: z.ZodUUID;
|
|
1475
|
+
dropped: z.ZodRecord<z.ZodString, z.ZodNumber>;
|
|
1476
|
+
}, z.core.$strict>;
|
|
1477
|
+
event_id: z.ZodDefault<z.ZodUUID>;
|
|
1478
|
+
tenant_id: z.ZodString;
|
|
1479
|
+
vendor_id: z.ZodString;
|
|
1480
|
+
session_id: z.ZodString;
|
|
1481
|
+
sequence_number: z.ZodNumber;
|
|
1482
|
+
captured_at: z.ZodString;
|
|
1483
|
+
consent_token: z.ZodString;
|
|
1484
|
+
sdk_version: z.ZodDefault<z.ZodString>;
|
|
1485
|
+
agent_runtime: z.ZodDefault<z.ZodString>;
|
|
1486
|
+
principal: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
1487
|
+
id: z.ZodString;
|
|
1488
|
+
source: z.ZodString;
|
|
1489
|
+
form: z.ZodString;
|
|
1490
|
+
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1491
|
+
}, z.core.$strict>>>;
|
|
1492
|
+
organization: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
1493
|
+
id: z.ZodString;
|
|
1494
|
+
source: z.ZodString;
|
|
1495
|
+
form: z.ZodString;
|
|
1496
|
+
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1497
|
+
}, z.core.$strict>>>;
|
|
1498
|
+
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1499
|
+
session_id_origin: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1500
|
+
client_observed: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
1501
|
+
info: z.ZodOptional<z.ZodObject<{
|
|
1502
|
+
name: z.ZodOptional<z.ZodString>;
|
|
1503
|
+
version: z.ZodOptional<z.ZodString>;
|
|
1504
|
+
}, z.core.$strict>>;
|
|
1505
|
+
headers: z.ZodOptional<z.ZodObject<{
|
|
1506
|
+
"user-agent": z.ZodOptional<z.ZodString>;
|
|
1507
|
+
"x-anthropic-client": z.ZodOptional<z.ZodString>;
|
|
1508
|
+
}, z.core.$strict>>;
|
|
1509
|
+
}, z.core.$strict>>>;
|
|
1510
|
+
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1511
|
+
runtime_meta: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
1421
1512
|
}, z.core.$strict>, z.ZodObject<{
|
|
1422
1513
|
event_type: z.ZodDefault<z.ZodLiteral<"resource_list_start">>;
|
|
1423
1514
|
payload: z.ZodObject<{}, z.core.$strict>;
|
|
@@ -2093,6 +2184,7 @@ type Event = z.infer<typeof EventSchema>;
|
|
|
2093
2184
|
/** Cap on recursive walk depth. Matches LangSmith's default; protects
|
|
2094
2185
|
* against pathological inputs without truncating realistic MCP payloads. */
|
|
2095
2186
|
declare const DEPTH_LIMIT = 10;
|
|
2187
|
+
declare const DEPTH_MARKER = "[REDACTED:depth-limit]";
|
|
2096
2188
|
/**
|
|
2097
2189
|
* Stateful recursive scrubber with the default ruleset baked in.
|
|
2098
2190
|
*
|
|
@@ -2108,12 +2200,14 @@ declare const DEPTH_LIMIT = 10;
|
|
|
2108
2200
|
*/
|
|
2109
2201
|
declare class Scrubber {
|
|
2110
2202
|
readonly counts: Map<string, number>;
|
|
2203
|
+
private warnedDepth;
|
|
2111
2204
|
/** Bound so `new Scrubber().scrub` can be passed as a bare function
|
|
2112
2205
|
* reference — the closest TS gets to Python's `__call__`. */
|
|
2113
2206
|
readonly scrub: (value: unknown) => unknown;
|
|
2114
2207
|
/** Python's `Counter[category]` zero-default read. */
|
|
2115
2208
|
count(category: string): number;
|
|
2116
2209
|
private bump;
|
|
2210
|
+
private pastTheDepthLimit;
|
|
2117
2211
|
private walk;
|
|
2118
2212
|
private scrubString;
|
|
2119
2213
|
}
|
|
@@ -2132,18 +2226,16 @@ declare function identityScrub(value: unknown): unknown;
|
|
|
2132
2226
|
* A `Sink` is the egress side of the SDK; `withBaton` hands fully-formed
|
|
2133
2227
|
* `Event` envelopes to a sink and the sink decides what to do with them.
|
|
2134
2228
|
*
|
|
2135
|
-
*
|
|
2229
|
+
* The same four sinks as `sinks.py`:
|
|
2136
2230
|
*
|
|
2137
2231
|
* - `StdoutSink` — JSONL to a writable stream (default `process.stderr`,
|
|
2138
2232
|
* for the same reason as Python: MCP stdio transport reserves stdout for
|
|
2139
2233
|
* JSON-RPC framing).
|
|
2234
|
+
* - `FileSink` — JSONL appended to a file.
|
|
2140
2235
|
* - `HttpSink` — POST to any HTTP endpoint with bearer auth; bounded
|
|
2141
2236
|
* buffer, retry with backoff, circuit breaker. This is the contract a
|
|
2142
2237
|
* Console or any compatible collector consumes.
|
|
2143
|
-
*
|
|
2144
|
-
* `FileSink` / `MultiSink` are deferred per design-notes/typescript_sdk.md
|
|
2145
|
-
* ("HttpSink + StdoutSink covers all real use cases") — add them if a real
|
|
2146
|
-
* need shows up rather than porting them speculatively.
|
|
2238
|
+
* - `MultiSink` — every event to each of several sinks.
|
|
2147
2239
|
*/
|
|
2148
2240
|
|
|
2149
2241
|
interface Sink {
|
|
@@ -2179,6 +2271,31 @@ declare class StdoutSink implements Sink {
|
|
|
2179
2271
|
flush(): Promise<void>;
|
|
2180
2272
|
aclose(): Promise<void>;
|
|
2181
2273
|
}
|
|
2274
|
+
/** Appends one JSON envelope per line to a file, opened on the first write so
|
|
2275
|
+
* an unused sink creates no file. Each line reaches the file before `write`
|
|
2276
|
+
* resolves, so `tail -f` sees it at once. */
|
|
2277
|
+
declare class FileSink implements Sink {
|
|
2278
|
+
private readonly path;
|
|
2279
|
+
private fd;
|
|
2280
|
+
private closed;
|
|
2281
|
+
constructor(path: string);
|
|
2282
|
+
write(event: Event): Promise<void>;
|
|
2283
|
+
flush(): Promise<void>;
|
|
2284
|
+
aclose(): Promise<void>;
|
|
2285
|
+
}
|
|
2286
|
+
/** Sends each event to every sink, e.g. `new MultiSink([new StdoutSink(),
|
|
2287
|
+
* new HttpSink(...)])` to watch what is shipped. Every sink is tried even when
|
|
2288
|
+
* one fails; one failure is rethrown as is, several as an `AggregateError`. */
|
|
2289
|
+
declare class MultiSink implements Sink {
|
|
2290
|
+
private readonly sinks;
|
|
2291
|
+
constructor(sinks: readonly Sink[]);
|
|
2292
|
+
write(event: Event): Promise<void>;
|
|
2293
|
+
flush(): Promise<void>;
|
|
2294
|
+
aclose(): Promise<void>;
|
|
2295
|
+
private flushWithin;
|
|
2296
|
+
private acloseWithin;
|
|
2297
|
+
private fanOut;
|
|
2298
|
+
}
|
|
2182
2299
|
interface HttpSinkOptions {
|
|
2183
2300
|
apiKey: string;
|
|
2184
2301
|
bufferSize?: number;
|
|
@@ -2188,6 +2305,9 @@ interface HttpSinkOptions {
|
|
|
2188
2305
|
backoffMaxMs?: number;
|
|
2189
2306
|
circuitBreakerThreshold?: number;
|
|
2190
2307
|
circuitBreakerResetMs?: number;
|
|
2308
|
+
/** How long the flush at process exit, or an explicit `flush()` or
|
|
2309
|
+
* `aclose()`, may take in total, in ms, at most 2^31 - 1. Default 3000. */
|
|
2310
|
+
shutdownFlushTimeoutMs?: number;
|
|
2191
2311
|
/** Injectable for tests; defaults to the global `fetch`. */
|
|
2192
2312
|
fetchImpl?: typeof fetch;
|
|
2193
2313
|
}
|
|
@@ -2205,15 +2325,37 @@ declare class HttpSink implements Sink {
|
|
|
2205
2325
|
private readonly apiKey;
|
|
2206
2326
|
private readonly buffer;
|
|
2207
2327
|
private readonly bufferSize;
|
|
2328
|
+
private readonly requestTimeoutMs;
|
|
2329
|
+
private readonly shutdownFlushTimeoutMs;
|
|
2330
|
+
/** Set when an exit pass ends; cleared once a normal drain empties the
|
|
2331
|
+
* buffer, which means the process went on. */
|
|
2332
|
+
private exitPassRan;
|
|
2333
|
+
/** Whether the exit pass warned about every event now buffered. */
|
|
2334
|
+
private unsentWarned;
|
|
2208
2335
|
private readonly maxRetries;
|
|
2209
2336
|
private readonly backoffBaseMs;
|
|
2210
2337
|
private readonly backoffMaxMs;
|
|
2211
2338
|
private readonly circuit;
|
|
2212
2339
|
private readonly fetchImpl;
|
|
2213
2340
|
private overflowWarned;
|
|
2214
|
-
|
|
2341
|
+
/** Per status, so a new kind of refusal, such as a 401 after a 422, still warns. */
|
|
2342
|
+
private readonly refusals;
|
|
2343
|
+
/** Aborted once `aclose()` returns: nothing Baton started may keep the
|
|
2344
|
+
* process alive after the vendor closed it. */
|
|
2345
|
+
private readonly closing;
|
|
2346
|
+
/** The drain chain's tail when a flush() or aclose() gave up waiting, until it settles. */
|
|
2347
|
+
private stalledDrain;
|
|
2348
|
+
private skipWarnedFor;
|
|
2349
|
+
private closeOnce;
|
|
2215
2350
|
private drainChain;
|
|
2216
|
-
private
|
|
2351
|
+
private exitHooks;
|
|
2352
|
+
/** The least time between two of this sink's loss reports. */
|
|
2353
|
+
private static reportIntervalMs;
|
|
2354
|
+
/** Totals only grow, so their sum tells whether they changed. */
|
|
2355
|
+
private reportedSum;
|
|
2356
|
+
private lastReportAt;
|
|
2357
|
+
private reportsStopped;
|
|
2358
|
+
private reportInFlight;
|
|
2217
2359
|
constructor(url: string, options: HttpSinkOptions);
|
|
2218
2360
|
/**
|
|
2219
2361
|
* What this sink shows when something prints it — never the bearer.
|
|
@@ -2221,17 +2363,28 @@ declare class HttpSink implements Sink {
|
|
|
2221
2363
|
* ⚠ **A sink built from a DSN holds a key the vendor never typed**, and it
|
|
2222
2364
|
* hangs off `BatonHandle.sink` and off the resolved config, so
|
|
2223
2365
|
* `console.log(handle.sink)` or a structured logger serialising either one
|
|
2224
|
-
*
|
|
2225
|
-
* asserts the DSN's own string does not survive resolution: it does not, and
|
|
2226
|
-
* the key was one field further down. Same treatment as the parsed DSN —
|
|
2366
|
+
* would write a publishable key into the vendor's logs. Same treatment as the parsed DSN —
|
|
2227
2367
|
* `toJSON` for serialisers, the inspect symbol for `console.log`, and
|
|
2228
2368
|
* `Symbol.for` rather than importing `node:util`, since this package runs on
|
|
2229
2369
|
* runtimes that have no such module.
|
|
2230
2370
|
*/
|
|
2231
2371
|
toJSON(): Record<string, unknown>;
|
|
2372
|
+
private get closed();
|
|
2232
2373
|
write(event: Event): Promise<void>;
|
|
2233
2374
|
flush(): Promise<void>;
|
|
2375
|
+
/** A second call waits for the first (SPEC §11.2 rule 7). */
|
|
2234
2376
|
aclose(): Promise<void>;
|
|
2377
|
+
private flushWithin;
|
|
2378
|
+
private acloseWithin;
|
|
2379
|
+
private close;
|
|
2380
|
+
/** SPEC §11.2 rule 7: an explicit flush or close returns within `ms` and
|
|
2381
|
+
* never rejects. While an earlier wait's drain is still stuck, a flush
|
|
2382
|
+
* returns at once, without queuing a pass, and a close gives it `ms`. The
|
|
2383
|
+
* drain is not cancelled here, so after `flush()` it goes on sending;
|
|
2384
|
+
* `aclose()` stops it. */
|
|
2385
|
+
private drainWithinBudget;
|
|
2386
|
+
/** A full buffer may already have pushed `event` out while it was being sent. */
|
|
2387
|
+
private dequeue;
|
|
2235
2388
|
private enqueue;
|
|
2236
2389
|
/** Serializes every call to `drainLocked` — from `write()`'s background
|
|
2237
2390
|
* drain and from explicit `flush()` alike — onto one promise chain, so
|
|
@@ -2240,18 +2393,44 @@ declare class HttpSink implements Sink {
|
|
|
2240
2393
|
* `shift()`. Mirrors Python's `asyncio.Lock` around `_drain_locked`. */
|
|
2241
2394
|
private scheduleDrain;
|
|
2242
2395
|
/** Best-effort flush when the process is about to exit without an
|
|
2243
|
-
* explicit `aclose()`.
|
|
2244
|
-
*
|
|
2245
|
-
*
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
*
|
|
2249
|
-
private
|
|
2396
|
+
* explicit `aclose()`. SIGKILL, or SIGTERM with no installed handler, skip
|
|
2397
|
+
* both hooks: a vendor needing that guarantee must call `aclose()` from
|
|
2398
|
+
* their own handler. */
|
|
2399
|
+
private ensureExitHooksRegistered;
|
|
2400
|
+
/** One attempt per event, no retry, within `shutdownFlushTimeoutMs` in
|
|
2401
|
+
* total (SPEC §11.2); what is left is reported, not sent. */
|
|
2402
|
+
private exitPass;
|
|
2403
|
+
private unsentAtExit;
|
|
2250
2404
|
private events_url;
|
|
2251
2405
|
private authHeaders;
|
|
2252
2406
|
private static classifyStatus;
|
|
2407
|
+
/** A refused event is otherwise dropped silently, which looks the same from
|
|
2408
|
+
* the vendor's process as an accepted one. The collector's own message is
|
|
2409
|
+
* logged because it names the field at fault; it is capped and escaped
|
|
2410
|
+
* because it is a remote server's text landing in the vendor's log. */
|
|
2411
|
+
private static logRefusal;
|
|
2412
|
+
private warnUnloggedRefusals;
|
|
2413
|
+
/** How many refusals with `status` went unlogged before this one, or `null`
|
|
2414
|
+
* when this one goes unlogged too. */
|
|
2415
|
+
private refusalToLog;
|
|
2416
|
+
/** Enough of the body for `REFUSAL_BODY_MAX_LEN` code points; the rest is
|
|
2417
|
+
* cancelled unread, so a large error page does not hold the drain. */
|
|
2418
|
+
private static readHead;
|
|
2253
2419
|
private drainLocked;
|
|
2420
|
+
/** Starts a report of this process's loss totals (SPEC §11.4.7) beside the
|
|
2421
|
+
* drain and outside the buffer, so it never delays an event and is never
|
|
2422
|
+
* counted as one. */
|
|
2423
|
+
private maybeReport;
|
|
2424
|
+
private stopReports;
|
|
2425
|
+
private sendReport;
|
|
2254
2426
|
private sendWithRetry;
|
|
2427
|
+
/** `null`, with a warning, for an event `JSON.stringify` rejects. */
|
|
2428
|
+
private encode;
|
|
2429
|
+
private sleepUnlessClosed;
|
|
2430
|
+
/** Aborted by the timeout or by `aclose()`. Built by hand: `AbortSignal.any`
|
|
2431
|
+
* is missing before Node 20.3, and on some later versions it keeps every
|
|
2432
|
+
* combined signal alive as long as the long-lived `closing` signal. */
|
|
2433
|
+
private postOnce;
|
|
2255
2434
|
}
|
|
2256
2435
|
|
|
2257
2436
|
/** Principal identity — what a vendor's resolver hands back, and how it goes
|
|
@@ -2510,10 +2689,8 @@ interface BatonConfig {
|
|
|
2510
2689
|
*
|
|
2511
2690
|
* **Requests are unaffected**: `params` are captured in both modes.
|
|
2512
2691
|
*
|
|
2513
|
-
*
|
|
2514
|
-
*
|
|
2515
|
-
* (SPEC §11.4.3). Thrown messages are a classic leak channel; if that is also
|
|
2516
|
-
* a problem for you, say so and the mode grows a stricter value.
|
|
2692
|
+
* The message of an error your handler THROWS is withheld too (SPEC
|
|
2693
|
+
* §11.4.3): the MCP SDK has no tool-error class to mark one public.
|
|
2517
2694
|
*
|
|
2518
2695
|
* Not a scrubber rule, deliberately (SPEC §7): a scrubber TRANSFORMS a value
|
|
2519
2696
|
* that still crosses the network, this DECLARES that nothing crosses. Under
|
|
@@ -2563,9 +2740,9 @@ interface BatonConfig {
|
|
|
2563
2740
|
declare class BatonHandle {
|
|
2564
2741
|
readonly sink: Sink;
|
|
2565
2742
|
readonly vendorId: string;
|
|
2566
|
-
/**
|
|
2567
|
-
* when no
|
|
2568
|
-
*
|
|
2743
|
+
/** The install's own session id: what stdio and in-memory calls, and the
|
|
2744
|
+
* surface snapshot, carry when no session id resolves. A call over HTTP
|
|
2745
|
+
* with no session to read gets a per-request id instead (SPEC §3.4 rung 5). */
|
|
2569
2746
|
readonly sessionId: string;
|
|
2570
2747
|
/** The resolved annotation tool name: `BatonConfig.annotationToolName` if
|
|
2571
2748
|
* set, else derived from the server's own name (`{slug}_annotate`), else
|
|
@@ -2577,9 +2754,10 @@ declare class BatonHandle {
|
|
|
2577
2754
|
sessionId: string;
|
|
2578
2755
|
annotationToolName: string;
|
|
2579
2756
|
});
|
|
2580
|
-
/** Flush any pending events held by the sink.
|
|
2757
|
+
/** Flush any pending events held by the sink. Never rejects; returns within
|
|
2758
|
+
* the shutdown budget (SPEC §11.2 rule 7). */
|
|
2581
2759
|
flush(): Promise<void>;
|
|
2582
|
-
/** Flush and release sink resources
|
|
2760
|
+
/** Flush and release sink resources, on the same terms as `flush()`. */
|
|
2583
2761
|
aclose(): Promise<void>;
|
|
2584
2762
|
}
|
|
2585
2763
|
|
|
@@ -2737,6 +2915,16 @@ declare function principalFromOAuthSub(context: PrincipalResolutionContext): Pri
|
|
|
2737
2915
|
* good enough is the vendor's call. */
|
|
2738
2916
|
declare function principalFromOAuthEmail(context: PrincipalResolutionContext): Principal | null;
|
|
2739
2917
|
|
|
2918
|
+
/** The library's `listTools`: the tool list a vendor serving MCP itself hands
|
|
2919
|
+
* its agents, and the `surface_snapshot` of the list it started from (SPEC
|
|
2920
|
+
* §5.6, §11.4.2). */
|
|
2921
|
+
/** The vendor's own `initialize` values, as it serves them. */
|
|
2922
|
+
interface ListToolsOptions {
|
|
2923
|
+
serverInfo?: Record<string, unknown> | null;
|
|
2924
|
+
capabilities?: Record<string, unknown> | null;
|
|
2925
|
+
instructions?: string | null;
|
|
2926
|
+
}
|
|
2927
|
+
|
|
2740
2928
|
/** The envelope's `client_observed` (SPEC §11.4): what the client said about
|
|
2741
2929
|
* itself, sent uninterpreted. The consumer names the client; this SDK does
|
|
2742
2930
|
* not, and sends `agent_runtime: "unknown"` on every event. */
|
|
@@ -2798,6 +2986,9 @@ interface SessionOptions {
|
|
|
2798
2986
|
/** The vendor's own id for the user request these calls answer. Pass the
|
|
2799
2987
|
* same value to every block that serves it, and those calls stay one turn. */
|
|
2800
2988
|
turnId?: string;
|
|
2989
|
+
/** The request's MCP `_meta`, for a vendor serving MCP itself. It is sent
|
|
2990
|
+
* as `runtime_meta`, and a client declaration in it wins over `clientInfo`. */
|
|
2991
|
+
meta?: Record<string, unknown>;
|
|
2801
2992
|
}
|
|
2802
2993
|
interface TraceOptions {
|
|
2803
2994
|
toolName: string;
|
|
@@ -2858,7 +3049,19 @@ declare class Client {
|
|
|
2858
3049
|
annotate(options: AnnotateOptions & {
|
|
2859
3050
|
consentToken?: string;
|
|
2860
3051
|
}): Promise<void>;
|
|
2861
|
-
/**
|
|
3052
|
+
/** `tools`, the vendor's own `tools/list` entries, with `user_goal` added
|
|
3053
|
+
* to each `inputSchema` as `withBaton` adds it, and a `surface_snapshot`
|
|
3054
|
+
* of `tools` as passed, sent once per distinct surface. For a vendor
|
|
3055
|
+
* serving MCP itself (SPEC §5.6).
|
|
3056
|
+
*
|
|
3057
|
+
* Pass the tools before anything of Baton's is added, so the snapshot
|
|
3058
|
+
* describes the vendor's own surface. `options` holds the vendor's own
|
|
3059
|
+
* `initialize` values. The input is not changed. Never rejects over the
|
|
3060
|
+
* tool list: one it cannot read is returned as it came. Does not wait for
|
|
3061
|
+
* the snapshot to be sent; `flush()` does. */
|
|
3062
|
+
listTools<T>(tools: readonly T[], options?: ListToolsOptions): Promise<T[]>;
|
|
3063
|
+
/** Wait for events so far to reach the sink, then flush it. Never rejects;
|
|
3064
|
+
* returns within the sink's shutdown budget plus 250 ms (SPEC §11.2 rule 7). */
|
|
2862
3065
|
flush(): Promise<void>;
|
|
2863
3066
|
/** Flush, then close the sink. Later events are dropped. */
|
|
2864
3067
|
aclose(): Promise<void>;
|
|
@@ -2880,4 +3083,4 @@ interface IntentParam {
|
|
|
2880
3083
|
}
|
|
2881
3084
|
declare const INTENT_PARAMS: readonly IntentParam[];
|
|
2882
3085
|
|
|
2883
|
-
export { type AnnotateOptions, type AnnotationEvent, AnnotationEventSchema, type AnnotationPayload, AnnotationPayloadSchema, type AuthInfo, type Baton, type BatonConfig, BatonHandle, Client, type ClientOptions, DEFAULT_CONSENT_TOKEN, DEPTH_LIMIT, type Event, EventSchema, type EventType, EventTypeSchema, type HeaderInput, HttpSink, type HttpSinkOptions, INTENT_INSTRUCTIONS, INTENT_PARAMS, type IntentParam, type ObservedError, type Organization, PRINCIPAL_FORM_HASHED, PRINCIPAL_FORM_RAW, PRINCIPAL_SOURCE_ASSERTED, type Principal, type PrincipalForm, type PrincipalResolutionContext, PrincipalWireSchema, type PromptGetEndEvent, PromptGetEndEventSchema, type PromptGetEndPayload, PromptGetEndPayloadSchema, type PromptGetErrorEvent, PromptGetErrorEventSchema, type PromptGetErrorPayload, PromptGetErrorPayloadSchema, type PromptGetStartEvent, PromptGetStartEventSchema, type PromptGetStartPayload, PromptGetStartPayloadSchema, type PromptListEndEvent, PromptListEndEventSchema, type PromptListEndPayload, PromptListEndPayloadSchema, type PromptListErrorEvent, PromptListErrorEventSchema, type PromptListErrorPayload, PromptListErrorPayloadSchema, type PromptListStartEvent, PromptListStartEventSchema, type PromptListStartPayload, PromptListStartPayloadSchema, type ResolvePrincipalHook, type ResourceListEndEvent, ResourceListEndEventSchema, type ResourceListEndPayload, ResourceListEndPayloadSchema, type ResourceListErrorEvent, ResourceListErrorEventSchema, type ResourceListErrorPayload, ResourceListErrorPayloadSchema, type ResourceListStartEvent, ResourceListStartEventSchema, type ResourceListStartPayload, ResourceListStartPayloadSchema, type ResourceReadEndEvent, ResourceReadEndEventSchema, type ResourceReadEndPayload, ResourceReadEndPayloadSchema, type ResourceReadErrorEvent, ResourceReadErrorEventSchema, type ResourceReadErrorPayload, ResourceReadErrorPayloadSchema, type ResourceReadStartEvent, ResourceReadStartEventSchema, type ResourceReadStartPayload, ResourceReadStartPayloadSchema, type ResultCaptureMode, SDK_VERSION, Scrubber, type SessionOptions, type Sink, StdoutSink, type StdoutSinkOptions, type SupportedMcpServer, type SurfaceSnapshotEvent, SurfaceSnapshotEventSchema, type SurfaceSnapshotPayload, SurfaceSnapshotPayloadSchema, type ToolCallEndEvent, ToolCallEndEventSchema, type ToolCallEndPayload, ToolCallEndPayloadSchema, type ToolCallErrorEvent, ToolCallErrorEventSchema, type ToolCallErrorPayload, ToolCallErrorPayloadSchema, type ToolCallStartEvent, ToolCallStartEventSchema, type ToolCallStartPayload, ToolCallStartPayloadSchema, type ToolListEndEvent, ToolListEndEventSchema, type ToolListEndPayload, ToolListEndPayloadSchema, type ToolListErrorEvent, ToolListErrorEventSchema, type ToolListErrorPayload, ToolListErrorPayloadSchema, type ToolListStartEvent, ToolListStartEventSchema, type ToolListStartPayload, ToolListStartPayloadSchema, Trace, type TraceOptions, createBaton, identityScrub, principalFromOAuthEmail, principalFromOAuthSub, safeWrite, withBaton };
|
|
3086
|
+
export { type AnnotateOptions, type AnnotationEvent, AnnotationEventSchema, type AnnotationPayload, AnnotationPayloadSchema, type AuthInfo, type Baton, type BatonConfig, BatonHandle, Client, type ClientOptions, type ClientReportEvent, ClientReportEventSchema, type ClientReportPayload, ClientReportPayloadSchema, DEFAULT_CONSENT_TOKEN, DEPTH_LIMIT, DEPTH_MARKER, type Event, EventSchema, type EventType, EventTypeSchema, FileSink, type HeaderInput, HttpSink, type HttpSinkOptions, INTENT_INSTRUCTIONS, INTENT_PARAMS, type IntentParam, type ListToolsOptions, MultiSink, type ObservedError, type Organization, PRINCIPAL_FORM_HASHED, PRINCIPAL_FORM_RAW, PRINCIPAL_SOURCE_ASSERTED, type Principal, type PrincipalForm, type PrincipalResolutionContext, PrincipalWireSchema, type PromptGetEndEvent, PromptGetEndEventSchema, type PromptGetEndPayload, PromptGetEndPayloadSchema, type PromptGetErrorEvent, PromptGetErrorEventSchema, type PromptGetErrorPayload, PromptGetErrorPayloadSchema, type PromptGetStartEvent, PromptGetStartEventSchema, type PromptGetStartPayload, PromptGetStartPayloadSchema, type PromptListEndEvent, PromptListEndEventSchema, type PromptListEndPayload, PromptListEndPayloadSchema, type PromptListErrorEvent, PromptListErrorEventSchema, type PromptListErrorPayload, PromptListErrorPayloadSchema, type PromptListStartEvent, PromptListStartEventSchema, type PromptListStartPayload, PromptListStartPayloadSchema, type ResolvePrincipalHook, type ResourceListEndEvent, ResourceListEndEventSchema, type ResourceListEndPayload, ResourceListEndPayloadSchema, type ResourceListErrorEvent, ResourceListErrorEventSchema, type ResourceListErrorPayload, ResourceListErrorPayloadSchema, type ResourceListStartEvent, ResourceListStartEventSchema, type ResourceListStartPayload, ResourceListStartPayloadSchema, type ResourceReadEndEvent, ResourceReadEndEventSchema, type ResourceReadEndPayload, ResourceReadEndPayloadSchema, type ResourceReadErrorEvent, ResourceReadErrorEventSchema, type ResourceReadErrorPayload, ResourceReadErrorPayloadSchema, type ResourceReadStartEvent, ResourceReadStartEventSchema, type ResourceReadStartPayload, ResourceReadStartPayloadSchema, type ResultCaptureMode, SDK_VERSION, Scrubber, type SessionOptions, type Sink, StdoutSink, type StdoutSinkOptions, type SupportedMcpServer, type SurfaceSnapshotEvent, SurfaceSnapshotEventSchema, type SurfaceSnapshotPayload, SurfaceSnapshotPayloadSchema, type ToolCallEndEvent, ToolCallEndEventSchema, type ToolCallEndPayload, ToolCallEndPayloadSchema, type ToolCallErrorEvent, ToolCallErrorEventSchema, type ToolCallErrorPayload, ToolCallErrorPayloadSchema, type ToolCallStartEvent, ToolCallStartEventSchema, type ToolCallStartPayload, ToolCallStartPayloadSchema, type ToolListEndEvent, ToolListEndEventSchema, type ToolListEndPayload, ToolListEndPayloadSchema, type ToolListErrorEvent, ToolListErrorEventSchema, type ToolListErrorPayload, ToolListErrorPayloadSchema, type ToolListStartEvent, ToolListStartEventSchema, type ToolListStartPayload, ToolListStartPayloadSchema, Trace, type TraceOptions, createBaton, identityScrub, principalFromOAuthEmail, principalFromOAuthSub, safeWrite, withBaton };
|