@goodtiming/baton-sdk 0.6.1 → 0.6.3

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.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod';
2
2
 
3
- declare const SDK_VERSION = "ts-0.6.1";
3
+ declare const SDK_VERSION = "ts-0.6.3";
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
- * Two sinks ship, mirroring `sinks.py`'s core pair:
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 {
@@ -2154,9 +2246,14 @@ interface Sink {
2154
2246
  /** Wait for any buffered events to reach their destination (or be
2155
2247
  * dropped per the sink's policy). No-op for synchronous sinks. */
2156
2248
  flush(): Promise<void>;
2157
- /** Flush + release resources. After `aclose`, `write` rejects. */
2249
+ /** Flush + release resources. After `aclose`, `write` rejects with
2250
+ * `SinkClosedError`. */
2158
2251
  aclose(): Promise<void>;
2159
2252
  }
2253
+ /** `write` was called after `aclose`. */
2254
+ declare class SinkClosedError extends Error {
2255
+ name: string;
2256
+ }
2160
2257
  /** Fail-open wrapper around `sink.write`.
2161
2258
  *
2162
2259
  * The MCP tool wrapper sits BEFORE the vendor's tool handler runs. A reject
@@ -2179,6 +2276,31 @@ declare class StdoutSink implements Sink {
2179
2276
  flush(): Promise<void>;
2180
2277
  aclose(): Promise<void>;
2181
2278
  }
2279
+ /** Appends one JSON envelope per line to a file, opened on the first write so
2280
+ * an unused sink creates no file. Each line reaches the file before `write`
2281
+ * resolves, so `tail -f` sees it at once. */
2282
+ declare class FileSink implements Sink {
2283
+ private readonly path;
2284
+ private fd;
2285
+ private closed;
2286
+ constructor(path: string);
2287
+ write(event: Event): Promise<void>;
2288
+ flush(): Promise<void>;
2289
+ aclose(): Promise<void>;
2290
+ }
2291
+ /** Sends each event to every sink, e.g. `new MultiSink([new StdoutSink(),
2292
+ * new HttpSink(...)])` to watch what is shipped. Every sink is tried even when
2293
+ * one fails; one failure is rethrown as is, several as an `AggregateError`. */
2294
+ declare class MultiSink implements Sink {
2295
+ private readonly sinks;
2296
+ constructor(sinks: readonly Sink[]);
2297
+ write(event: Event): Promise<void>;
2298
+ flush(): Promise<void>;
2299
+ aclose(): Promise<void>;
2300
+ private flushWithin;
2301
+ private acloseWithin;
2302
+ private fanOut;
2303
+ }
2182
2304
  interface HttpSinkOptions {
2183
2305
  apiKey: string;
2184
2306
  bufferSize?: number;
@@ -2188,6 +2310,9 @@ interface HttpSinkOptions {
2188
2310
  backoffMaxMs?: number;
2189
2311
  circuitBreakerThreshold?: number;
2190
2312
  circuitBreakerResetMs?: number;
2313
+ /** How long the flush at process exit, or an explicit `flush()` or
2314
+ * `aclose()`, may take in total, in ms, at most 2^31 - 1. Default 3000. */
2315
+ shutdownFlushTimeoutMs?: number;
2191
2316
  /** Injectable for tests; defaults to the global `fetch`. */
2192
2317
  fetchImpl?: typeof fetch;
2193
2318
  }
@@ -2205,15 +2330,37 @@ declare class HttpSink implements Sink {
2205
2330
  private readonly apiKey;
2206
2331
  private readonly buffer;
2207
2332
  private readonly bufferSize;
2333
+ private readonly requestTimeoutMs;
2334
+ private readonly shutdownFlushTimeoutMs;
2335
+ /** Set when an exit pass ends; cleared once a normal drain empties the
2336
+ * buffer, which means the process went on. */
2337
+ private exitPassRan;
2338
+ /** Whether the exit pass warned about every event now buffered. */
2339
+ private unsentWarned;
2208
2340
  private readonly maxRetries;
2209
2341
  private readonly backoffBaseMs;
2210
2342
  private readonly backoffMaxMs;
2211
2343
  private readonly circuit;
2212
2344
  private readonly fetchImpl;
2213
2345
  private overflowWarned;
2214
- private closed;
2346
+ /** Per status, so a new kind of refusal, such as a 401 after a 422, still warns. */
2347
+ private readonly refusals;
2348
+ /** Aborted once `aclose()` returns: nothing Baton started may keep the
2349
+ * process alive after the vendor closed it. */
2350
+ private readonly closing;
2351
+ /** The drain chain's tail when a flush() or aclose() gave up waiting, until it settles. */
2352
+ private stalledDrain;
2353
+ private skipWarnedFor;
2354
+ private closeOnce;
2215
2355
  private drainChain;
2216
- private beforeExitHandler;
2356
+ private exitHooks;
2357
+ /** The least time between two of this sink's loss reports. */
2358
+ private static reportIntervalMs;
2359
+ /** Totals only grow, so their sum tells whether they changed. */
2360
+ private reportedSum;
2361
+ private lastReportAt;
2362
+ private reportsStopped;
2363
+ private reportInFlight;
2217
2364
  constructor(url: string, options: HttpSinkOptions);
2218
2365
  /**
2219
2366
  * What this sink shows when something prints it — never the bearer.
@@ -2221,17 +2368,28 @@ declare class HttpSink implements Sink {
2221
2368
  * ⚠ **A sink built from a DSN holds a key the vendor never typed**, and it
2222
2369
  * hangs off `BatonHandle.sink` and off the resolved config, so
2223
2370
  * `console.log(handle.sink)` or a structured logger serialising either one
2224
- * wrote a publishable key into the vendor's logs. Found by the S2 test that
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 —
2371
+ * would write a publishable key into the vendor's logs. Same treatment as the parsed DSN —
2227
2372
  * `toJSON` for serialisers, the inspect symbol for `console.log`, and
2228
2373
  * `Symbol.for` rather than importing `node:util`, since this package runs on
2229
2374
  * runtimes that have no such module.
2230
2375
  */
2231
2376
  toJSON(): Record<string, unknown>;
2377
+ private get closed();
2232
2378
  write(event: Event): Promise<void>;
2233
2379
  flush(): Promise<void>;
2380
+ /** A second call waits for the first (SPEC §11.2 rule 7). */
2234
2381
  aclose(): Promise<void>;
2382
+ private flushWithin;
2383
+ private acloseWithin;
2384
+ private close;
2385
+ /** SPEC §11.2 rule 7: an explicit flush or close returns within `ms` and
2386
+ * never rejects. While an earlier wait's drain is still stuck, a flush
2387
+ * returns at once, without queuing a pass, and a close gives it `ms`. The
2388
+ * drain is not cancelled here, so after `flush()` it goes on sending;
2389
+ * `aclose()` stops it. */
2390
+ private drainWithinBudget;
2391
+ /** A full buffer may already have pushed `event` out while it was being sent. */
2392
+ private dequeue;
2235
2393
  private enqueue;
2236
2394
  /** Serializes every call to `drainLocked` — from `write()`'s background
2237
2395
  * drain and from explicit `flush()` alike — onto one promise chain, so
@@ -2240,18 +2398,44 @@ declare class HttpSink implements Sink {
2240
2398
  * `shift()`. Mirrors Python's `asyncio.Lock` around `_drain_locked`. */
2241
2399
  private scheduleDrain;
2242
2400
  /** Best-effort flush when the process is about to exit without an
2243
- * explicit `aclose()`. Node re-runs `beforeExit` if new async work is
2244
- * scheduled during it, so an in-flight flush here can complete normally —
2245
- * unlike Python's synchronous `atexit`, no separate sync-client fallback
2246
- * is needed. Real residual gap, not fixable in-process: SIGKILL, or
2247
- * SIGTERM with no installed handler, skip `beforeExit` entirely. A vendor
2248
- * needing that guarantee must call `aclose()` from their own handler. */
2249
- private ensureBeforeExitRegistered;
2401
+ * explicit `aclose()`. SIGKILL, or SIGTERM with no installed handler, skip
2402
+ * both hooks: a vendor needing that guarantee must call `aclose()` from
2403
+ * their own handler. */
2404
+ private ensureExitHooksRegistered;
2405
+ /** One attempt per event, no retry, within `shutdownFlushTimeoutMs` in
2406
+ * total (SPEC §11.2); what is left is reported, not sent. */
2407
+ private exitPass;
2408
+ private unsentAtExit;
2250
2409
  private events_url;
2251
2410
  private authHeaders;
2252
2411
  private static classifyStatus;
2412
+ /** A refused event is otherwise dropped silently, which looks the same from
2413
+ * the vendor's process as an accepted one. The collector's own message is
2414
+ * logged because it names the field at fault; it is capped and escaped
2415
+ * because it is a remote server's text landing in the vendor's log. */
2416
+ private static logRefusal;
2417
+ private warnUnloggedRefusals;
2418
+ /** How many refusals with `status` went unlogged before this one, or `null`
2419
+ * when this one goes unlogged too. */
2420
+ private refusalToLog;
2421
+ /** Enough of the body for `REFUSAL_BODY_MAX_LEN` code points; the rest is
2422
+ * cancelled unread, so a large error page does not hold the drain. */
2423
+ private static readHead;
2253
2424
  private drainLocked;
2425
+ /** Starts a report of this process's loss totals (SPEC §11.4.7) beside the
2426
+ * drain and outside the buffer, so it never delays an event and is never
2427
+ * counted as one. */
2428
+ private maybeReport;
2429
+ private stopReports;
2430
+ private sendReport;
2254
2431
  private sendWithRetry;
2432
+ /** `null`, with a warning, for an event `JSON.stringify` rejects. */
2433
+ private encode;
2434
+ private sleepUnlessClosed;
2435
+ /** Aborted by the timeout or by `aclose()`. Built by hand: `AbortSignal.any`
2436
+ * is missing before Node 20.3, and on some later versions it keeps every
2437
+ * combined signal alive as long as the long-lived `closing` signal. */
2438
+ private postOnce;
2255
2439
  }
2256
2440
 
2257
2441
  /** Principal identity — what a vendor's resolver hands back, and how it goes
@@ -2510,10 +2694,8 @@ interface BatonConfig {
2510
2694
  *
2511
2695
  * **Requests are unaffected**: `params` are captured in both modes.
2512
2696
  *
2513
- * ⚠ The message of an error your handler THROWS is KEPT — it is your own code
2514
- * speaking about a call that never returned, so it is not result-derived
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.
2697
+ * The message of an error your handler THROWS is withheld too (SPEC
2698
+ * §11.4.3): the MCP SDK has no tool-error class to mark one public.
2517
2699
  *
2518
2700
  * Not a scrubber rule, deliberately (SPEC §7): a scrubber TRANSFORMS a value
2519
2701
  * that still crosses the network, this DECLARES that nothing crosses. Under
@@ -2563,9 +2745,9 @@ interface BatonConfig {
2563
2745
  declare class BatonHandle {
2564
2746
  readonly sink: Sink;
2565
2747
  readonly vendorId: string;
2566
- /** Process-lifetime fallback session id — the value events fall back to
2567
- * when no real per-call session id resolves. Not every event necessarily
2568
- * carries this id; see `withBaton`'s session-resolution order. */
2748
+ /** The install's own session id: what stdio and in-memory calls, and the
2749
+ * surface snapshot, carry when no session id resolves. A call over HTTP
2750
+ * with no session to read gets a per-request id instead (SPEC §3.4 rung 5). */
2569
2751
  readonly sessionId: string;
2570
2752
  /** The resolved annotation tool name: `BatonConfig.annotationToolName` if
2571
2753
  * set, else derived from the server's own name (`{slug}_annotate`), else
@@ -2577,9 +2759,10 @@ declare class BatonHandle {
2577
2759
  sessionId: string;
2578
2760
  annotationToolName: string;
2579
2761
  });
2580
- /** Flush any pending events held by the sink. */
2762
+ /** Flush any pending events held by the sink. Never rejects; returns within
2763
+ * the shutdown budget (SPEC §11.2 rule 7). */
2581
2764
  flush(): Promise<void>;
2582
- /** Flush and release sink resources. Subsequent writes reject. */
2765
+ /** Flush and release sink resources, on the same terms as `flush()`. */
2583
2766
  aclose(): Promise<void>;
2584
2767
  }
2585
2768
 
@@ -2737,6 +2920,16 @@ declare function principalFromOAuthSub(context: PrincipalResolutionContext): Pri
2737
2920
  * good enough is the vendor's call. */
2738
2921
  declare function principalFromOAuthEmail(context: PrincipalResolutionContext): Principal | null;
2739
2922
 
2923
+ /** The library's `listTools`: the tool list a vendor serving MCP itself hands
2924
+ * its agents, and the `surface_snapshot` of the list it started from (SPEC
2925
+ * §5.6, §11.4.2). */
2926
+ /** The vendor's own `initialize` values, as it serves them. */
2927
+ interface ListToolsOptions {
2928
+ serverInfo?: Record<string, unknown> | null;
2929
+ capabilities?: Record<string, unknown> | null;
2930
+ instructions?: string | null;
2931
+ }
2932
+
2740
2933
  /** The envelope's `client_observed` (SPEC §11.4): what the client said about
2741
2934
  * itself, sent uninterpreted. The consumer names the client; this SDK does
2742
2935
  * not, and sends `agent_runtime: "unknown"` on every event. */
@@ -2798,6 +2991,9 @@ interface SessionOptions {
2798
2991
  /** The vendor's own id for the user request these calls answer. Pass the
2799
2992
  * same value to every block that serves it, and those calls stay one turn. */
2800
2993
  turnId?: string;
2994
+ /** The request's MCP `_meta`, for a vendor serving MCP itself. It is sent
2995
+ * as `runtime_meta`, and a client declaration in it wins over `clientInfo`. */
2996
+ meta?: Record<string, unknown>;
2801
2997
  }
2802
2998
  interface TraceOptions {
2803
2999
  toolName: string;
@@ -2858,7 +3054,19 @@ declare class Client {
2858
3054
  annotate(options: AnnotateOptions & {
2859
3055
  consentToken?: string;
2860
3056
  }): Promise<void>;
2861
- /** Wait until every event so far has reached the sink and the sink has flushed. */
3057
+ /** `tools`, the vendor's own `tools/list` entries, with `user_goal` added
3058
+ * to each `inputSchema` as `withBaton` adds it, and a `surface_snapshot`
3059
+ * of `tools` as passed, sent once per distinct surface. For a vendor
3060
+ * serving MCP itself (SPEC §5.6).
3061
+ *
3062
+ * Pass the tools before anything of Baton's is added, so the snapshot
3063
+ * describes the vendor's own surface. `options` holds the vendor's own
3064
+ * `initialize` values. The input is not changed. Never rejects over the
3065
+ * tool list: one it cannot read is returned as it came. Does not wait for
3066
+ * the snapshot to be sent; `flush()` does. */
3067
+ listTools<T>(tools: readonly T[], options?: ListToolsOptions): Promise<T[]>;
3068
+ /** Wait for events so far to reach the sink, then flush it. Never rejects;
3069
+ * returns within the sink's shutdown budget plus 250 ms (SPEC §11.2 rule 7). */
2862
3070
  flush(): Promise<void>;
2863
3071
  /** Flush, then close the sink. Later events are dropped. */
2864
3072
  aclose(): Promise<void>;
@@ -2880,4 +3088,4 @@ interface IntentParam {
2880
3088
  }
2881
3089
  declare const INTENT_PARAMS: readonly IntentParam[];
2882
3090
 
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 };
3091
+ 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, SinkClosedError, 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 };