@0xinsider/mcp 2.1.0 → 2.1.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.
Files changed (92) hide show
  1. package/README.md +25 -6
  2. package/dist/cli-lib.d.ts +1 -0
  3. package/dist/cli-lib.d.ts.map +1 -1
  4. package/dist/cli-lib.js +48 -8
  5. package/dist/cli-lib.js.map +1 -1
  6. package/dist/client.d.ts +33 -2
  7. package/dist/client.d.ts.map +1 -1
  8. package/dist/client.js +42 -4
  9. package/dist/client.js.map +1 -1
  10. package/dist/constants.d.ts +1 -1
  11. package/dist/constants.js +1 -1
  12. package/dist/product-cli/client.d.ts +3 -2
  13. package/dist/product-cli/client.d.ts.map +1 -1
  14. package/dist/product-cli/client.js.map +1 -1
  15. package/dist/sdk/client.d.ts +690 -133
  16. package/dist/sdk/client.d.ts.map +1 -1
  17. package/dist/sdk/client.js +699 -125
  18. package/dist/sdk/client.js.map +1 -1
  19. package/dist/sdk/errors.d.ts +42 -4
  20. package/dist/sdk/errors.d.ts.map +1 -1
  21. package/dist/sdk/errors.js +103 -2
  22. package/dist/sdk/errors.js.map +1 -1
  23. package/dist/sdk/index.d.ts +9 -8
  24. package/dist/sdk/index.d.ts.map +1 -1
  25. package/dist/sdk/index.js +6 -4
  26. package/dist/sdk/index.js.map +1 -1
  27. package/dist/sdk/pagination.d.ts +133 -15
  28. package/dist/sdk/pagination.d.ts.map +1 -1
  29. package/dist/sdk/pagination.js +132 -34
  30. package/dist/sdk/pagination.js.map +1 -1
  31. package/dist/sdk/retry.d.ts +68 -0
  32. package/dist/sdk/retry.d.ts.map +1 -0
  33. package/dist/sdk/retry.js +125 -0
  34. package/dist/sdk/retry.js.map +1 -0
  35. package/dist/sdk/schema.d.ts +1381 -439
  36. package/dist/sdk/schema.d.ts.map +1 -1
  37. package/dist/sdk/stream.d.ts +318 -8
  38. package/dist/sdk/stream.d.ts.map +1 -1
  39. package/dist/sdk/stream.js +503 -56
  40. package/dist/sdk/stream.js.map +1 -1
  41. package/dist/sdk/webhooks.d.ts +18 -3
  42. package/dist/sdk/webhooks.d.ts.map +1 -1
  43. package/dist/sdk/webhooks.js +13 -1
  44. package/dist/sdk/webhooks.js.map +1 -1
  45. package/dist/tools/explore-markets.d.ts.map +1 -1
  46. package/dist/tools/explore-markets.js +2 -5
  47. package/dist/tools/explore-markets.js.map +1 -1
  48. package/dist/tools/get-insider-radar.d.ts.map +1 -1
  49. package/dist/tools/get-insider-radar.js +3 -10
  50. package/dist/tools/get-insider-radar.js.map +1 -1
  51. package/dist/tools/get-large-positions.d.ts.map +1 -1
  52. package/dist/tools/get-large-positions.js +3 -10
  53. package/dist/tools/get-large-positions.js.map +1 -1
  54. package/dist/tools/get-leaderboard.d.ts.map +1 -1
  55. package/dist/tools/get-leaderboard.js +3 -10
  56. package/dist/tools/get-leaderboard.js.map +1 -1
  57. package/dist/tools/get-market-intel.d.ts.map +1 -1
  58. package/dist/tools/get-market-intel.js +3 -6
  59. package/dist/tools/get-market-intel.js.map +1 -1
  60. package/dist/tools/get-position-timeline.d.ts.map +1 -1
  61. package/dist/tools/get-position-timeline.js +3 -10
  62. package/dist/tools/get-position-timeline.js.map +1 -1
  63. package/dist/tools/get-positions.d.ts +2 -0
  64. package/dist/tools/get-positions.d.ts.map +1 -1
  65. package/dist/tools/get-positions.js +8 -11
  66. package/dist/tools/get-positions.js.map +1 -1
  67. package/dist/tools/get-trader-pnl.d.ts.map +1 -1
  68. package/dist/tools/get-trader-pnl.js +3 -6
  69. package/dist/tools/get-trader-pnl.js.map +1 -1
  70. package/dist/tools/get-trader.d.ts.map +1 -1
  71. package/dist/tools/get-trader.js +3 -6
  72. package/dist/tools/get-trader.js.map +1 -1
  73. package/dist/tools/get-trending-wallets.d.ts.map +1 -1
  74. package/dist/tools/get-trending-wallets.js +3 -10
  75. package/dist/tools/get-trending-wallets.js.map +1 -1
  76. package/dist/tools/get-whale-trades.d.ts.map +1 -1
  77. package/dist/tools/get-whale-trades.js +4 -11
  78. package/dist/tools/get-whale-trades.js.map +1 -1
  79. package/dist/tools/pick-of-the-day.d.ts.map +1 -1
  80. package/dist/tools/pick-of-the-day.js +5 -21
  81. package/dist/tools/pick-of-the-day.js.map +1 -1
  82. package/dist/tools/read-parity.d.ts.map +1 -1
  83. package/dist/tools/read-parity.js +36 -44
  84. package/dist/tools/read-parity.js.map +1 -1
  85. package/dist/tools/result.d.ts +31 -0
  86. package/dist/tools/result.d.ts.map +1 -0
  87. package/dist/tools/result.js +70 -0
  88. package/dist/tools/result.js.map +1 -0
  89. package/dist/tools/search-markets.d.ts.map +1 -1
  90. package/dist/tools/search-markets.js +16 -11
  91. package/dist/tools/search-markets.js.map +1 -1
  92. package/package.json +4 -4
@@ -19,7 +19,7 @@
19
19
  * - Extra typed convenience methods for list/candle/webhook-event/stream
20
20
  * surfaces and a typed `Grade` enum.
21
21
  */
22
- import type { OperationData, PickOfTheDay, PickOfTheDayArchive, PickOfTheDayLedger, ResponseMeta, SportsEdgeFunnelReport, SportsEdgeObservation, SportsEdgeSignal } from "./schema.js";
22
+ import type { OperationBody, OperationData, OperationPath, OperationQuery, OperationResponse, ResponseMeta } from "./schema.js";
23
23
  /**
24
24
  * The envelope `meta` as THIS client hands it to a caller: everything the
25
25
  * contract declares (`ResponseMeta`), plus `etag`.
@@ -34,21 +34,88 @@ import type { OperationData, PickOfTheDay, PickOfTheDayArchive, PickOfTheDayLedg
34
34
  export type ClientResponseMeta = ResponseMeta & {
35
35
  /** Lifted from the `ETag` response header by this client. */
36
36
  etag?: string;
37
+ /**
38
+ * `true` when the response carried `X-Oxi-Sandbox: true`, which every
39
+ * response of the sandbox server does and no production response does.
40
+ * Lifted from the header by this client (#16138); absent otherwise.
41
+ */
42
+ sandbox?: true;
43
+ /**
44
+ * HTTP status of the success response, set by this client (#16137).
45
+ * `201` on `registerAgent`, `202` on a `submitTraderExport` that queued a
46
+ * new job, `200` everywhere else.
47
+ */
48
+ status?: number;
49
+ /** Unknown query names reported by the server in compatibility mode. */
50
+ queryIgnored?: string;
51
+ /** Normalized query names and values the server actually applied. */
52
+ effectiveQuery?: string;
37
53
  };
38
54
  export type ApiClientMethod = "GET" | "POST" | "PATCH" | "DELETE";
39
55
  /** Whether an operation requires the `oxi_sk_*` Bearer key. */
40
56
  export type AuthMode = "none" | "bearer";
57
+ /**
58
+ * How an operation carries its success body, which decides the method that
59
+ * can read it (#16137). Before this, every row was assumed to answer the
60
+ * JSON envelope, so `call()` parsed Markdown as JSON and then rejected it as
61
+ * a bad 200.
62
+ *
63
+ * - `envelope` (the default, and every row that omits `kind`): a JSON
64
+ * `{ object, data, meta }` body -> `call()` and `list()`.
65
+ * - `text`: a `text/*` body -> `text()`. The two `context.md` reads.
66
+ * - `jsonrpc`: a JSON-RPC 2.0 response, or an empty `202` for a
67
+ * notification -> `mcp()`. `POST /api/v1/mcp`.
68
+ * - `sse`: an open-ended `text/event-stream` -> `streamFeed()` and the
69
+ * other consumers in `stream.ts`. Buffering one with `call()` or `text()`
70
+ * would never return, so both refuse it.
71
+ *
72
+ * `scripts/check-sdk-openapi-drift.mjs` derives the same kind from each
73
+ * operation's documented success media type and schema and fails on a row
74
+ * that disagrees, so a route that changes shape cannot keep a stale kind.
75
+ */
76
+ export type ResponseKind = "envelope" | "text" | "jsonrpc" | "sse";
41
77
  export interface ApiClientOperation {
42
78
  readonly method: ApiClientMethod;
43
79
  readonly path: string;
44
80
  readonly operationId: string;
45
81
  readonly auth: AuthMode;
82
+ /** How the success body is carried; absent means `"envelope"`. */
83
+ readonly kind?: ResponseKind;
46
84
  }
47
85
  /**
48
- * The full V1 operation table. One row per OpenAPI operation that returns a
49
- * `200`. Kept in lockstep with `web/public/api/v1/openapi.json` by
50
- * `scripts/check-sdk-openapi-drift.mjs`. Do not add a row without a matching
51
- * spec operation, and do not remove a spec operation without removing its row.
86
+ * A published operation whose success is a REDIRECT, so it has no success
87
+ * body and cannot go through `call()` (#16137). Declared here rather than
88
+ * omitted in silence: the drift check requires every redirect-only spec
89
+ * operation to appear in `REDIRECT_OPERATIONS` with the method that follows
90
+ * it, so "the SDK cannot do this" is never the same as "nobody noticed".
91
+ */
92
+ export interface ApiRedirectOperation {
93
+ readonly method: ApiClientMethod;
94
+ readonly path: string;
95
+ readonly operationId: string;
96
+ readonly auth: AuthMode;
97
+ /** The documented redirect status. */
98
+ readonly status: number;
99
+ /** How a caller reaches it through this package. */
100
+ readonly handledBy: string;
101
+ }
102
+ /** A published operation this client deliberately does not wrap. */
103
+ export interface ApiUnsupportedOperation {
104
+ readonly method: ApiClientMethod;
105
+ readonly path: string;
106
+ readonly operationId: string;
107
+ /** Why there is no method, and what to use instead. */
108
+ readonly reason: string;
109
+ }
110
+ /**
111
+ * The full V1 operation table. One row per OpenAPI operation with a
112
+ * documented 2xx, which since #16137 includes the `201`-only
113
+ * `registerAgent`; `kind` says which method reads its body. Kept in lockstep
114
+ * with `web/public/api/v1/openapi.json` by
115
+ * `scripts/check-sdk-openapi-drift.mjs`, which also checks every row's kind
116
+ * against the spec. Do not add a row without a matching spec operation, and
117
+ * do not remove a spec operation without removing its row. A redirect-only
118
+ * operation belongs in `REDIRECT_OPERATIONS` below, not here.
52
119
  */
53
120
  export declare const API_CLIENT_OPERATIONS: readonly [{
54
121
  readonly method: "GET";
@@ -95,6 +162,11 @@ export declare const API_CLIENT_OPERATIONS: readonly [{
95
162
  readonly path: "/api/v1/trader/{address}/pnl";
96
163
  readonly operationId: "getTraderPnl";
97
164
  readonly auth: "bearer";
165
+ }, {
166
+ readonly method: "GET";
167
+ readonly path: "/api/v1/trader/{address}/categories";
168
+ readonly operationId: "getTraderCategoryRecords";
169
+ readonly auth: "bearer";
98
170
  }, {
99
171
  readonly method: "GET";
100
172
  readonly path: "/api/v1/trader/{address}/context";
@@ -105,6 +177,7 @@ export declare const API_CLIENT_OPERATIONS: readonly [{
105
177
  readonly path: "/api/v1/trader/{address}/context.md";
106
178
  readonly operationId: "getTraderContextMarkdown";
107
179
  readonly auth: "bearer";
180
+ readonly kind: "text";
108
181
  }, {
109
182
  readonly method: "POST";
110
183
  readonly path: "/api/v1/trader/{address}/export";
@@ -190,6 +263,11 @@ export declare const API_CLIENT_OPERATIONS: readonly [{
190
263
  readonly path: "/api/v1/platforms";
191
264
  readonly operationId: "getPlatforms";
192
265
  readonly auth: "none";
266
+ }, {
267
+ readonly method: "GET";
268
+ readonly path: "/api/v1/market/{condition_id}/holders";
269
+ readonly operationId: "getMarketHolders";
270
+ readonly auth: "bearer";
193
271
  }, {
194
272
  readonly method: "GET";
195
273
  readonly path: "/api/v1/market/{condition_id}/intel";
@@ -210,6 +288,7 @@ export declare const API_CLIENT_OPERATIONS: readonly [{
210
288
  readonly path: "/api/v1/market/{condition_id}/context.md";
211
289
  readonly operationId: "getMarketContextMarkdown";
212
290
  readonly auth: "bearer";
291
+ readonly kind: "text";
213
292
  }, {
214
293
  readonly method: "GET";
215
294
  readonly path: "/api/v1/market/{condition_id}/candles";
@@ -235,6 +314,7 @@ export declare const API_CLIENT_OPERATIONS: readonly [{
235
314
  readonly path: "/api/v1/stream";
236
315
  readonly operationId: "getStream";
237
316
  readonly auth: "bearer";
317
+ readonly kind: "sse";
238
318
  }, {
239
319
  readonly method: "GET";
240
320
  readonly path: "/api/v1/webhooks";
@@ -270,6 +350,21 @@ export declare const API_CLIENT_OPERATIONS: readonly [{
270
350
  readonly path: "/api/v1/webhooks/{id}/rotate-secret";
271
351
  readonly operationId: "rotateWebhookSecret";
272
352
  readonly auth: "bearer";
353
+ }, {
354
+ readonly method: "POST";
355
+ readonly path: "/api/v1/webhooks/{id}/rotate-secret/prepare";
356
+ readonly operationId: "prepareWebhookSecret";
357
+ readonly auth: "bearer";
358
+ }, {
359
+ readonly method: "POST";
360
+ readonly path: "/api/v1/webhooks/{id}/rotate-secret/activate";
361
+ readonly operationId: "activateWebhookSecret";
362
+ readonly auth: "bearer";
363
+ }, {
364
+ readonly method: "POST";
365
+ readonly path: "/api/v1/webhooks/{id}/rotate-secret/retire";
366
+ readonly operationId: "retireWebhookSecret";
367
+ readonly auth: "bearer";
273
368
  }, {
274
369
  readonly method: "GET";
275
370
  readonly path: "/api/v1/webhooks/events";
@@ -295,11 +390,7 @@ export declare const API_CLIENT_OPERATIONS: readonly [{
295
390
  readonly path: "/api/v1/mcp";
296
391
  readonly operationId: "createMcpJsonRpcResponse";
297
392
  readonly auth: "bearer";
298
- }, {
299
- readonly method: "GET";
300
- readonly path: "/api/v1/mcp";
301
- readonly operationId: "openMcpEventStream";
302
- readonly auth: "bearer";
393
+ readonly kind: "jsonrpc";
303
394
  }, {
304
395
  readonly method: "GET";
305
396
  readonly path: "/api/v1/reports";
@@ -344,9 +435,94 @@ export declare const API_CLIENT_OPERATIONS: readonly [{
344
435
  readonly method: "GET";
345
436
  readonly path: "/api/v1/pick-of-the-day/ledger";
346
437
  readonly operationId: "getPickOfTheDayLedger";
347
- readonly auth: "bearer";
438
+ readonly auth: "none";
439
+ }, {
440
+ readonly method: "POST";
441
+ readonly path: "/api/v1/agents/register";
442
+ readonly operationId: "registerAgent";
443
+ readonly auth: "none";
348
444
  }];
349
445
  export type ApiOperationId = (typeof API_CLIENT_OPERATIONS)[number]["operationId"];
446
+ /** Operations whose success body is a `text/*` document; read with `text()`. */
447
+ export type TextOperationId = Extract<(typeof API_CLIENT_OPERATIONS)[number], {
448
+ kind: "text";
449
+ }>["operationId"];
450
+ /** Operations whose success body is JSON-RPC 2.0; read with `mcp()`. */
451
+ export type JsonRpcOperationId = Extract<(typeof API_CLIENT_OPERATIONS)[number], {
452
+ kind: "jsonrpc";
453
+ }>["operationId"];
454
+ /** Operations whose success body is an open SSE stream; read through `stream.ts`. */
455
+ export type SseOperationId = Extract<(typeof API_CLIENT_OPERATIONS)[number], {
456
+ kind: "sse";
457
+ }>["operationId"];
458
+ /**
459
+ * Published operations whose success is a redirect, with the method that
460
+ * follows it (#16137). These have no 2xx body, so they are absent from
461
+ * `API_CLIENT_OPERATIONS` and from the generated `schema.ts`;
462
+ * `scripts/check-sdk-openapi-drift.mjs` requires every redirect-only spec
463
+ * operation to be declared here, so one cannot go missing in silence again.
464
+ */
465
+ export declare const REDIRECT_OPERATIONS: readonly [{
466
+ readonly method: "GET";
467
+ readonly path: "/api/v1/trader/{address}/export/download";
468
+ readonly operationId: "downloadTraderExport";
469
+ readonly auth: "bearer";
470
+ readonly status: 302;
471
+ readonly handledBy: "getTraderExportDownloadUrl() resolves the Location; downloadTraderExport() then fetches the object with no Authorization header.";
472
+ }, {
473
+ readonly method: "GET";
474
+ readonly path: "/api/v1/openapi.json";
475
+ readonly operationId: "redirectApiOpenapiSpec";
476
+ readonly auth: "none";
477
+ readonly status: 307;
478
+ readonly handledBy: "No method: the document is public and static, so fetch the URL directly and let your runtime follow the redirect. This package ships the same contract as generated types in schema.ts.";
479
+ }];
480
+ /**
481
+ * Published operations this client deliberately does not wrap, with the
482
+ * reason. The drift check requires every remaining spec operation to be
483
+ * accounted for here, so "unsupported" is always a stated decision.
484
+ */
485
+ export declare const UNSUPPORTED_OPERATIONS: readonly [{
486
+ readonly method: "GET";
487
+ readonly path: "/api/v1/mcp";
488
+ readonly operationId: "openMcpEventStream";
489
+ readonly reason: "The MCP endpoint offers no server-to-client stream: GET answers 405 by design, so a client that reconnects to it would loop (#16354). Post JSON-RPC with mcp() instead.";
490
+ }];
491
+ /**
492
+ * The writes the API replays under `Idempotency-Key`: a second request with
493
+ * the same key and the same body returns the first result instead of
494
+ * repeating the write. Source of truth: the operations declaring the
495
+ * `Idempotency-Key` header parameter in `web/public/api/v1/openapi.json`,
496
+ * pinned by `scripts/check-sdk-openapi-drift.mjs` (#16182). Only these are
497
+ * retried on a transport or 5xx failure, and only when a key is set; a key on
498
+ * any other operation is refused before the request, since the server would
499
+ * ignore it and a retry could repeat the side effect (`verifyWebhook` sends
500
+ * a challenge to your URL each time; `submitTraderExport` starts a job).
501
+ */
502
+ export declare const IDEMPOTENT_WRITE_OPERATIONS: readonly ["createWebhook", "updateWebhook", "deleteWebhook", "rotateWebhookSecret", "prepareWebhookSecret", "activateWebhookSecret", "retireWebhookSecret", "redeliverWebhookDelivery"];
503
+ export type IdempotentWriteOperationId = (typeof IDEMPOTENT_WRITE_OPERATIONS)[number];
504
+ /**
505
+ * POST operations that read and never write (#16182): the batch lookups.
506
+ * `POST /api/v1/traders/batch` and `POST /api/v1/markets/intel/batch` resolve
507
+ * their inputs and store nothing (`backend/src/api_v1/handlers/batch.rs`), so
508
+ * a repeat cannot duplicate a side effect. Each attempt is one request
509
+ * against the account's quota and one reservation of batch item units, which
510
+ * is exactly what a retried GET costs, so they are retried like a GET. Every
511
+ * other POST, PATCH or DELETE is retried only as a keyed write above.
512
+ */
513
+ export declare const READ_ONLY_POST_OPERATIONS: readonly ["batchGetTraders", "batchGetMarketIntel"];
514
+ /**
515
+ * How `call()` may repeat an operation that failed with 429, 502, 503, 504 or
516
+ * a network error before any response (#16182):
517
+ * - `"read"`: a GET or a read-only POST, repeated without conditions.
518
+ * - `"keyed"`: an `IDEMPOTENT_WRITE_OPERATIONS` member, repeated only when
519
+ * the request carries an `Idempotency-Key`, with the same key and the same
520
+ * bytes on every attempt.
521
+ * - `"never"`: any other write; the first failure is thrown.
522
+ */
523
+ export type RetryEligibility = "read" | "keyed" | "never";
524
+ /** The retry class of an operation; see `RetryEligibility`. */
525
+ export declare function retryEligibility(operation: Pick<ApiClientOperation, "method" | "operationId">): RetryEligibility;
350
526
  /**
351
527
  * Trader skill grade. Source of truth:
352
528
  * `components.schemas.Trader.properties.grade.enum` (S highest, F lowest).
@@ -359,6 +535,8 @@ export interface ApiRequestOptions {
359
535
  query?: Record<string, ApiQueryValue>;
360
536
  body?: unknown;
361
537
  headers?: Record<string, string>;
538
+ /** Reject query names the operation does not publish before it runs. */
539
+ strictQuery?: boolean;
362
540
  /** Cooperative cancellation; composed with the request deadline. */
363
541
  signal?: AbortSignal;
364
542
  /**
@@ -373,22 +551,46 @@ export interface ApiRequestOptions {
373
551
  */
374
552
  maxRetries?: number;
375
553
  /**
376
- * Sent as the `Idempotency-Key` header. The API honours it on `createWebhook`,
377
- * `updateWebhook`, `deleteWebhook`, `rotateWebhookSecret` and
378
- * `redeliverWebhookDelivery`: a replay with the same key and body returns the
379
- * first result instead of repeating the write.
380
- * A write carrying a key is also the only non-GET request the SDK retries.
381
- * On `IdempotencyInProgressError`, retry with the SAME key and body.
554
+ * Sent as the `Idempotency-Key` header. Accepted only on the
555
+ * `IDEMPOTENT_WRITE_OPERATIONS` (`createWebhook`, `updateWebhook`,
556
+ * `deleteWebhook`, `rotateWebhookSecret`, `prepareWebhookSecret`,
557
+ * `activateWebhookSecret`, `retireWebhookSecret`, `redeliverWebhookDelivery`),
558
+ * where a replay with the same key and body returns the first result
559
+ * instead of repeating the write; on any other operation `call()` throws
560
+ * before sending, since the server would ignore the key (#16182). A keyed
561
+ * write is the only non-read request the SDK retries, always with the
562
+ * same key and the same body bytes. On `IdempotencyInProgressError`, or
563
+ * when the outcome is unknown after a timeout or exhausted retries, send
564
+ * the SAME key and body again to learn what happened; never mint a new key
565
+ * for the same intent.
382
566
  */
383
567
  idempotencyKey?: string;
384
568
  }
385
569
  export interface ApiClientOptions {
386
570
  /**
387
- * API base, e.g. `https://api.0xinsider.com`. Trailing slashes are trimmed.
571
+ * The server URL, one of the `servers` in the OpenAPI document:
572
+ * `https://api.0xinsider.com` (the default) or
573
+ * `https://0xinsider.com/sandbox`. A path on it is kept, so every operation
574
+ * path (`/api/v1/...`) is appended after it (#16138: the path used to be
575
+ * discarded, which sent a sandbox client to the live host). Trailing slashes
576
+ * are trimmed, and a trailing `/api/v1` is removed once, since the operation
577
+ * paths carry it.
388
578
  */
389
579
  baseUrl?: string;
390
- /** The `oxi_sk_live_*` secret API key. */
580
+ /**
581
+ * The `oxi_sk_live_*` secret API key, or a sandbox key (`oxi_sk_test_*`)
582
+ * when `sandbox` is set.
583
+ */
391
584
  apiKey?: string;
585
+ /**
586
+ * Explicit sandbox mode (#16138). `baseUrl` defaults to
587
+ * `SANDBOX_BASE_URL` (`https://0xinsider.com/sandbox`), every operation is
588
+ * allowed without a key, since the sandbox needs no credential, and a live
589
+ * key (`oxi_sk_live_*`) is refused by the constructor so it is never sent
590
+ * there. A sandbox key from `POST /api/v1/agents/register` is optional and
591
+ * is sent when given. `OxinsiderApiClient.sandbox()` builds one.
592
+ */
593
+ sandbox?: boolean;
392
594
  /** Override the global `fetch` (e.g. for testing or a proxy agent). */
393
595
  fetch?: typeof fetch;
394
596
  /**
@@ -402,13 +604,18 @@ export interface ApiClientOptions {
402
604
  * How many times a failed idempotent request is retried (#14281). Default
403
605
  * `DEFAULT_MAX_RETRIES` (2); `0` disables retries.
404
606
  *
405
- * Retried: a GET, or a write carrying an `Idempotency-Key`, that failed with
406
- * 429, 502, 503, 504, or a network error before any response. The wait is the
407
- * response's `Retry-After` plus up to 250 ms of jitter when present, otherwise
408
- * a jittered exponential backoff from 500 ms capped at 8 s. A `Retry-After`
409
- * longer than 60 s is not waited out; the error is thrown so the caller can
410
- * schedule it. Never retried: 400, 401, 402, 403, 404, 409, 500, a write
411
- * without a key, a timeout, or a caller abort. A retry never starts unless it
607
+ * Retried: a GET, a read-only POST (`READ_ONLY_POST_OPERATIONS`), or an
608
+ * `IDEMPOTENT_WRITE_OPERATIONS` write carrying an `Idempotency-Key`, that
609
+ * failed with 408, 429, 502, 503, 504, or a network error before any
610
+ * response (`retryEligibility`, #16182). A 408 is the server's own timeout
611
+ * (`request_timeout`, #16146): it carries `Retry-After` on a GET, and a
612
+ * keyed write replays safely. The wait is the
613
+ * response's `Retry-After` (delta-seconds or an HTTP-date, `parseRetryAfter`)
614
+ * plus up to 250 ms of jitter when present, otherwise a jittered exponential
615
+ * backoff from 500 ms capped at 8 s. A `Retry-After` longer than
616
+ * `RETRY_AFTER_CEILING_MS` (60 s) is not waited out; the error is thrown so
617
+ * the caller can schedule it from `retryAfterSeconds` or `retryAt`. Never retried: 400, 401, 402, 403, 404, 409, 500, a write
618
+ * without a key, this client's own timeout, or a caller abort. A retry never starts unless it
412
619
  * can finish inside `timeoutMs`, and a caller `AbortSignal` ends a backoff at
413
620
  * once.
414
621
  */
@@ -416,6 +623,14 @@ export interface ApiClientOptions {
416
623
  }
417
624
  /** Default production API base used when `baseUrl` is omitted. */
418
625
  export declare const DEFAULT_BASE_URL = "https://api.0xinsider.com";
626
+ /**
627
+ * The sandbox server, the second `servers` entry of the OpenAPI document: no
628
+ * credential, no production data, every documented operation answered with
629
+ * its example or a deterministic sample, `?sandbox_status=<code>` for a
630
+ * documented error, and `X-Oxi-Sandbox: true` on every response. Streams and
631
+ * file downloads are not simulated there and answer 400.
632
+ */
633
+ export declare const SANDBOX_BASE_URL = "https://0xinsider.com/sandbox";
419
634
  /** Default per-request deadline; see `ApiClientOptions.timeoutMs`. */
420
635
  export declare const DEFAULT_TIMEOUT_MS = 15000;
421
636
  /** Default retry budget; see `ApiClientOptions.maxRetries`. */
@@ -427,6 +642,14 @@ export declare const DEFAULT_MAX_RETRIES = 2;
427
642
  * else throws from the constructor, before any request is sent (#11115).
428
643
  */
429
644
  export declare function assertTrustedBaseUrl(baseUrl: string): URL;
645
+ /**
646
+ * Join an `/api/v1/...` path onto the server URL, keeping the server's own
647
+ * path (`/sandbox`) exactly once. REST (`buildUrl`) and the SSE stream
648
+ * (`stream.ts`) both resolve through this, so the two cannot disagree about
649
+ * where a path-bearing base points (#16138: `new URL("/api/v1/...", base)`
650
+ * resolved against the origin and dropped `/sandbox`).
651
+ */
652
+ export declare function resolveApiUrl(baseUrl: string, path: string): URL;
430
653
  /**
431
654
  * One signal that aborts on the deadline OR when the caller's signal aborts.
432
655
  * Uses native composition where available. The manual fallback removes both
@@ -469,11 +692,7 @@ export interface CategorySkillStatusCounts {
469
692
  unknown: number;
470
693
  degraded: number;
471
694
  }
472
- export interface SportsEdgeSignalsParams extends ListParams {
473
- category?: string;
474
- horizon_hours?: number;
475
- min_grade?: "S" | "A" | "B";
476
- }
695
+ export type SportsEdgeSignalsParams = OperationQuery["listSportsEdgeSignals"];
477
696
  /** Observation cohorts exposed by `listSportsEdgeObservations`. */
478
697
  export type SportsEdgeObservationCohort = "wider_holder" | "in_play" | "emerging_pile";
479
698
  /** Source of the provider holder snapshot used to build an observation. */
@@ -494,23 +713,14 @@ export type SportsEdgeObservationOutcomeIndex = 0 | 1;
494
713
  export type SportsEdgeObservationTopGrade = "S" | "A" | "B";
495
714
  /** Canonical sports emitted by observation responses. */
496
715
  export type SportsEdgeObservationSport = "Basketball" | "Football" | "Baseball" | "Hockey" | "MMA" | "Boxing" | "Soccer" | "Cricket" | "Golf" | "Tennis" | "Esports" | "Racing" | "Table Tennis" | "Pickleball";
497
- /** Full list response, including the observation snapshot and accountable funnel. */
498
- export interface SportsEdgeObservationsResponse extends ApiListEnvelope<SportsEdgeObservation> {
499
- next_cursor: string | null;
500
- snapshot_as_of: string;
501
- /**
502
- * Snapshot-wide operational/unknown-completeness verdict. True means treat
503
- * the evidence as partial; fully accounted `capacity_limited` rows alone do
504
- * not set it.
505
- */
506
- degraded: boolean;
507
- funnel: SportsEdgeFunnelReport;
508
- meta: ClientResponseMeta;
509
- }
510
- export interface SportsEdgeObservationsParams extends ListParams {
511
- cohort: SportsEdgeObservationCohort;
512
- category?: string;
513
- }
716
+ /**
717
+ * Full list response, including the observation snapshot and accountable
718
+ * funnel: the operation's own envelope (#16136). `degraded` is the
719
+ * snapshot-wide verdict; fully accounted `capacity_limited` rows alone do
720
+ * not set it.
721
+ */
722
+ export type SportsEdgeObservationsResponse = OperationEnvelope<"listSportsEdgeObservations">;
723
+ export type SportsEdgeObservationsParams = OperationQuery["listSportsEdgeObservations"];
514
724
  /**
515
725
  * One qualifying category expert on a Pick of the Day's backed side.
516
726
  *
@@ -606,10 +816,151 @@ export interface ApiNotModifiedResponse {
606
816
  status: 304;
607
817
  etag?: string;
608
818
  request_id?: string;
819
+ queryIgnored?: string;
820
+ effectiveQuery?: string;
609
821
  [key: string]: unknown;
610
822
  };
611
823
  }
612
824
  export type ApiClientResponse<T> = ApiEnvelope<T> | ApiNotModifiedResponse;
825
+ /** `etag`, `sandbox` and `status`, lifted by this client onto whichever `meta` the operation declares. */
826
+ export type ClientMeta<M> = M & {
827
+ /** Lifted from the `ETag` response header by this client. */
828
+ etag?: string;
829
+ /** `true` when the response carried `X-Oxi-Sandbox: true` (#16138). */
830
+ sandbox?: true;
831
+ /**
832
+ * The HTTP status of the success response, set by this client (#16137).
833
+ *
834
+ * Not every operation answers `200`, and the difference is the answer:
835
+ * `registerAgent` answers `201`, and `submitTraderExport` answers `202`
836
+ * when it queued a new job and `200` when it returned one that already
837
+ * existed. The envelope body is the same shape either way, so without this
838
+ * a caller could not tell a fresh job from a replayed one.
839
+ */
840
+ status?: number;
841
+ };
842
+ /** Operations whose 200 is the JSON envelope (`object`, `data`, `meta`); the two text bodies and the JSON-RPC post are not. */
843
+ export type EnvelopeOperationId = {
844
+ [K in ApiOperationId]: OperationResponse[K] extends {
845
+ object: string;
846
+ data: unknown;
847
+ meta: unknown;
848
+ } ? K : never;
849
+ }[ApiOperationId];
850
+ /** Envelope operations that page: `data` is an array and `has_more` is declared. */
851
+ export type ListOperationId = {
852
+ [K in EnvelopeOperationId]: OperationResponse[K] extends {
853
+ has_more: boolean;
854
+ data: readonly unknown[];
855
+ } ? K : never;
856
+ }[EnvelopeOperationId];
857
+ /** The operation's documented `meta` type. */
858
+ export type OperationMeta<K extends ApiOperationId> = OperationResponse[K] extends {
859
+ meta: infer M;
860
+ } ? M : never;
861
+ /**
862
+ * What a 200 resolves to: the operation's own envelope (`object` literal,
863
+ * `data`, every top-level field such as `has_more` or a list's `totals`) with
864
+ * its own `meta` type (`BatchResponseMeta` on a batch, `EventReplayMeta` on
865
+ * the replay, `ResponseMeta` elsewhere) plus this client's lifted `etag` and
866
+ * `sandbox`.
867
+ */
868
+ export type OperationEnvelope<K extends EnvelopeOperationId> = Omit<OperationResponse[K], "meta"> & {
869
+ meta: ClientMeta<OperationMeta<K>>;
870
+ };
871
+ /** A `call()` result: the envelope, or the typed 304 when `If-None-Match` matched. */
872
+ export type OperationResult<K extends EnvelopeOperationId> = OperationEnvelope<K> | ApiNotModifiedResponse;
873
+ /** One item of a list operation's `data`. */
874
+ export type OperationItem<K extends ListOperationId> = OperationData[K] extends readonly (infer I)[] ? I : never;
875
+ /**
876
+ * `call()` options bound to one operation: `path` is required exactly when
877
+ * the route has path parameters, `query` is the documented query, `body` is
878
+ * required exactly when the operation declares a request body, and the
879
+ * transport options (`signal`, `timeoutMs`, `maxRetries`, `headers`,
880
+ * `idempotencyKey`) are the shared ones.
881
+ */
882
+ export type OperationRequestOptions<K extends ApiOperationId> = Omit<ApiRequestOptions, "path" | "query" | "body"> & (OperationPath[K] extends Record<string, never> ? {
883
+ path?: OperationPath[K];
884
+ } : {
885
+ path: OperationPath[K];
886
+ }) & {
887
+ query?: OperationQuery[K];
888
+ } & ([
889
+ OperationBody[K]
890
+ ] extends [never] ? {
891
+ body?: never;
892
+ } : {
893
+ body: OperationBody[K];
894
+ });
895
+ /** The transport options a convenience method forwards: everything but the parts it fills itself. */
896
+ export type ConvenienceOptions = Omit<ApiRequestOptions, "path" | "query" | "body">;
897
+ /** The MCP methods `POST /api/v1/mcp` accepts, from the operation's request body. */
898
+ export declare const MCP_METHODS: readonly ["initialize", "notifications/initialized", "notifications/cancelled", "ping", "tools/list", "tools/call"];
899
+ export type McpMethod = (typeof MCP_METHODS)[number];
900
+ /**
901
+ * One JSON-RPC 2.0 message for `POST /api/v1/mcp`. `jsonrpc` defaults to
902
+ * `"2.0"`. Omit `id` for a notification, which answers an empty `202`.
903
+ */
904
+ export interface McpJsonRpcRequest {
905
+ jsonrpc?: "2.0";
906
+ /** Echoed exactly in the response. Omit it on a notification. */
907
+ id?: string | number | null;
908
+ method: McpMethod;
909
+ params?: Record<string, unknown>;
910
+ }
911
+ /** The JSON-RPC 2.0 response body, as the operation declares it. */
912
+ export type McpJsonRpcResponse = OperationResponse["createMcpJsonRpcResponse"];
913
+ /** Options for `mcp()`: the shared transport options plus the two MCP headers. */
914
+ export interface McpOptions extends ConvenienceOptions {
915
+ /** Sent as `Mcp-Session-Id`; use the value a previous response returned. */
916
+ sessionId?: string;
917
+ /**
918
+ * Sent as `MCP-Protocol-Version`. Omit it and the server serves
919
+ * `2025-03-26`; an unsupported revision is a `400`.
920
+ */
921
+ protocolVersion?: string;
922
+ }
923
+ /** What `mcp()` returns: the JSON-RPC response, or the accepted notification. */
924
+ export interface McpResult {
925
+ /** `200` for a JSON-RPC response, `202` for an accepted notification. */
926
+ status: 200 | 202;
927
+ /** The JSON-RPC body, or `null` for the empty `202` a notification receives. */
928
+ response: McpJsonRpcResponse | null;
929
+ /** `Mcp-Session-Id`, when the server issued or echoed one. */
930
+ sessionId?: string;
931
+ }
932
+ /** Where a finished export actually lives, from the `302`'s `Location`. */
933
+ export interface TraderExportDownloadTarget {
934
+ /**
935
+ * The presigned object URL. It authorizes itself, so treat it as a
936
+ * credential: never log it and never share it.
937
+ */
938
+ url: string;
939
+ /**
940
+ * When the link stops working, read from the URL's own SigV4
941
+ * `X-Amz-Date` and `X-Amz-Expires`. Absent when the URL does not carry
942
+ * them; the API signs a one-hour link today.
943
+ */
944
+ expiresAt?: string;
945
+ }
946
+ /** The object response, with what its headers said about the file. */
947
+ export interface TraderExportDownload extends TraderExportDownloadTarget {
948
+ /** Not buffered: read `response.body` as a stream. */
949
+ response: Response;
950
+ /** `Content-Length` of the object, or `null` when the store sent none. */
951
+ contentLength: number | null;
952
+ contentType: string | null;
953
+ /** The filename from `Content-Disposition`, or `null`. */
954
+ filename: string | null;
955
+ }
956
+ export interface TraderExportDownloadOptions extends ConvenienceOptions {
957
+ /**
958
+ * A deadline in ms for the OBJECT fetch, which has none by default: an
959
+ * export can be far larger than a REST read and the 15-second default
960
+ * would cut it off mid-file. `timeoutMs` still bounds the redirect.
961
+ */
962
+ downloadTimeoutMs?: number | null;
963
+ }
613
964
  /** Shared paging params accepted by Stripe-style list endpoints. */
614
965
  export interface ListParams {
615
966
  limit?: number;
@@ -620,77 +971,228 @@ export interface ListParams {
620
971
  export declare const LEADERBOARD_STRATEGIES: readonly ["accumulator", "algo_trader", "arbitrageur", "directional", "event_driven", "market_maker", "momentum", "scalper", "speculator", "swing_trader"];
621
972
  export type LeaderboardStrategy = (typeof LEADERBOARD_STRATEGIES)[number];
622
973
  /**
623
- * Query parameters for `GET /api/v1/leaderboard`. The board has no `min_grade`:
624
- * it only holds S, A, and B traders, and the backend drops an unknown query key
625
- * instead of rejecting it (#10642).
974
+ * Query parameters for `GET /api/v1/leaderboard`, from the operation
975
+ * (#16136). The board has no `min_grade`: it only holds S, A, and B traders,
976
+ * and the backend drops an unknown query key instead of rejecting it
977
+ * (#10642), which is why the type now refuses one.
626
978
  */
627
- export interface LeaderboardListParams extends ListParams {
628
- category?: string;
629
- strategy?: LeaderboardStrategy;
630
- }
979
+ export type LeaderboardListParams = OperationQuery["listLeaderboard"];
631
980
  /** Query parameters for `GET /api/v1/leaderboard/trending`. */
632
- export interface TrendingWalletsParams extends ListParams {
633
- window?: "7d" | "30d";
634
- }
635
- /** Query parameters shared by the V1 whale-trade list and history reads. */
636
- export interface WhaleTradeListParams extends ListParams {
637
- min_size?: number;
638
- category?: string;
639
- min_grade?: Grade;
640
- /** Keep only rows with persisted suspicion_score >= 60. */
641
- suspicious_only?: boolean;
642
- }
643
- /** Query parameters for the V1 historical whale-trade replay. */
644
- export interface WhaleTradeHistoryParams extends WhaleTradeListParams {
645
- condition_id?: string;
646
- trader?: string;
647
- from?: string;
648
- to?: string;
649
- platform?: "polymarket" | "all";
981
+ export type TrendingWalletsParams = OperationQuery["listTrendingWallets"];
982
+ /** Query parameters of the V1 whale-trade list. */
983
+ export type WhaleTradeListParams = OperationQuery["listWhaleTrades"];
984
+ /** Query parameters of the V1 historical whale-trade replay. */
985
+ export type WhaleTradeHistoryParams = OperationQuery["listWhaleTradeHistory"];
986
+ /** Query parameters of `GET /api/v1/positions`. */
987
+ export type PositionsListParams = OperationQuery["listPositions"];
988
+ /** Query parameters of `GET /api/v1/large-positions`. */
989
+ export type LargePositionsListParams = OperationQuery["listLargePositions"];
990
+ /** Query parameters of the sharp-money flows read and its legacy alias. */
991
+ export type SharpMoneyFlowsParams = OperationQuery["listSharpMoneyFlows"];
992
+ /** Query parameters of `GET /api/v1/insider-radar`: `min_suspicion` and `severity`, not a grade. */
993
+ export type InsiderRadarListParams = OperationQuery["listInsiderRadar"];
994
+ /** Query parameters of `GET /api/v1/markets/explore`. */
995
+ export type ExploreMarketsParams = OperationQuery["exploreMarkets"];
996
+ /**
997
+ * Body-level `expand` values of `POST /api/v1/traders/batch`. The type is the
998
+ * operation's own body (`OperationBody["batchGetTraders"]["expand"]`); the
999
+ * const is the same list as a runtime value for a caller that iterates it.
1000
+ */
1001
+ export declare const BATCH_TRADER_EXPANSIONS: readonly ["strategy", "categories", "quant_metrics", "trust"];
1002
+ export type BatchTraderExpand = NonNullable<OperationBody["batchGetTraders"]["expand"]>[number];
1003
+ /**
1004
+ * Options for `batchGetTraders`. The body is built from the positional
1005
+ * `traders` array and `expand`, so `body` is not accepted here.
1006
+ */
1007
+ export interface BatchGetTradersOptions extends ConvenienceOptions {
1008
+ /** Shared expand flags applied to every trader item; sent as the body's `expand`. */
1009
+ expand?: OperationBody["batchGetTraders"]["expand"];
650
1010
  }
651
1011
  export declare class OxinsiderApiClient {
652
1012
  private readonly baseUrl;
653
1013
  private readonly apiKey?;
1014
+ private readonly sandbox;
654
1015
  private readonly fetchImpl;
655
1016
  private readonly timeoutMs;
656
1017
  private readonly maxRetries;
1018
+ /**
1019
+ * A client for the sandbox server (#16138): `SANDBOX_BASE_URL`, no
1020
+ * credential needed, example data only, never production data. The same
1021
+ * as `new OxinsiderApiClient({ ...options, sandbox: true })`; pass a
1022
+ * sandbox key (`oxi_sk_test_*`) as `apiKey` to have it checked.
1023
+ *
1024
+ * @example
1025
+ * const sandbox = OxinsiderApiClient.sandbox();
1026
+ * const board = await sandbox.listLeaderboard({ limit: 5 }); // no key
1027
+ * board.meta?.sandbox; // true
1028
+ */
1029
+ static sandbox(options?: Omit<ApiClientOptions, "sandbox">): OxinsiderApiClient;
657
1030
  constructor(options?: ApiClientOptions);
658
1031
  /**
659
- * Execute any operation by id. Throws the matching `OxinsiderApiError`
660
- * subclass on a non-2xx response, returns a typed `not_modified` result for a
661
- * 304, and otherwise returns the parsed `{ object, data, meta }` envelope.
662
- */
663
- call<T>(operationId: ApiOperationId, options?: ApiRequestOptions): Promise<ApiClientResponse<T>>;
664
- /**
665
- * Execute a Stripe-style list operation and return the list envelope.
666
- * Use `paginate()` (in `pagination.ts`) to auto-follow `next_cursor`.
667
- */
668
- list<T>(operationId: ApiOperationId, options?: ApiRequestOptions): Promise<ApiListEnvelope<T>>;
669
- getTrader<T = OperationData["getTrader"]>(address: string, options?: Omit<ApiRequestOptions, "path">): Promise<ApiClientResponse<T>>;
670
- getTraderPnl<T = OperationData["getTraderPnl"]>(address: string, options?: Omit<ApiRequestOptions, "path">): Promise<ApiClientResponse<T>>;
671
- batchGetTraders<T = OperationData["batchGetTraders"]>(identifiers: readonly string[], options?: Omit<ApiRequestOptions, "body">): Promise<ApiClientResponse<T>>;
672
- listLeaderboard<T = OperationData["listLeaderboard"][number]>(params?: LeaderboardListParams): Promise<ApiListEnvelope<T>>;
673
- listTrendingWallets<T = OperationData["listTrendingWallets"][number]>(params?: TrendingWalletsParams): Promise<ApiListEnvelope<T>>;
674
- listWhaleTrades<T = OperationData["listWhaleTrades"][number]>(params?: WhaleTradeListParams): Promise<ApiListEnvelope<T>>;
675
- listWhaleTradeHistory<T = OperationData["listWhaleTradeHistory"][number]>(params?: WhaleTradeHistoryParams): Promise<ApiListEnvelope<T>>;
676
- listPositions<T = OperationData["listPositions"][number]>(params?: ListParams & {
677
- min_grade?: Grade;
678
- }): Promise<ApiListEnvelope<T>>;
679
- listLargePositions<T = OperationData["listLargePositions"][number]>(params?: ListParams & {
680
- min_grade?: Grade;
681
- }): Promise<ApiListEnvelope<T>>;
682
- listSmartMoneyFlows<T = OperationData["listSmartMoneyFlows"][number]>(params?: ListParams & {
683
- min_grade?: Grade;
684
- }): Promise<ApiListEnvelope<T>>;
1032
+ * Execute an envelope operation by id. Throws the matching
1033
+ * `OxinsiderApiError` subclass on a non-2xx response, returns a typed
1034
+ * `not_modified` result for a 304, and otherwise returns the operation's
1035
+ * own `{ object, data, meta, ... }` envelope (#16136): `path` is required
1036
+ * exactly when the route has path parameters, `query` and `body` are the
1037
+ * documented ones, and `data` and `meta` are the operation's types.
1038
+ *
1039
+ * @example
1040
+ * const trader = await client.call("getTrader", { path: { address } });
1041
+ * if (trader.object === "trader") trader.data.grade; // typed
1042
+ */
1043
+ call<K extends EnvelopeOperationId>(operationId: K, options?: OperationRequestOptions<K>): Promise<OperationResult<K>>;
1044
+ /**
1045
+ * The untyped form, for an operation chosen at runtime or a caller that
1046
+ * asserts the shape itself with `T`: loose `path`, `query` and `body`, and
1047
+ * the generic `{ object, data, meta? }` envelope back. Every convenience
1048
+ * method uses the typed form above; reach for this one only when the
1049
+ * operation id is not a literal.
1050
+ */
1051
+ call<T = unknown>(operationId: ApiOperationId, options?: ApiRequestOptions): Promise<ApiClientResponse<T>>;
1052
+ /**
1053
+ * Read a `text/*` operation's body as a string (#16137).
1054
+ *
1055
+ * `getTraderContextMarkdown` and `getMarketContextMarkdown` answer
1056
+ * `text/markdown`, which `call()` used to parse as JSON and then reject as
1057
+ * an invalid 200. Authentication, the request deadline, retries and the
1058
+ * typed error hierarchy are the same as `call()`; only the body differs.
1059
+ *
1060
+ * @example
1061
+ * const md = await client.text("getTraderContextMarkdown", { path: { address } });
1062
+ */
1063
+ text<K extends TextOperationId>(operationId: K, options?: OperationRequestOptions<K>): Promise<string>;
1064
+ /** The untyped form, for an operation id chosen at runtime. */
1065
+ text(operationId: ApiOperationId, options?: ApiRequestOptions): Promise<string>;
1066
+ /**
1067
+ * Post one MCP JSON-RPC 2.0 message to `POST /api/v1/mcp` (#16137).
1068
+ *
1069
+ * The endpoint answers a JSON-RPC envelope, not the `{ object, data, meta }`
1070
+ * envelope every other operation uses, so `call()` refuses it. A request
1071
+ * (one carrying `id`) comes back as `status: 200` with `response` set; a
1072
+ * supported notification (no `id`) comes back as `status: 202` with
1073
+ * `response: null`, which is the empty body the server sends. A JSON-RPC
1074
+ * `error` member is a protocol-level failure and is RETURNED, not thrown:
1075
+ * only a non-2xx HTTP status throws, because an unknown tool is an answer
1076
+ * and a revoked credential is not.
1077
+ *
1078
+ * The request is never retried: `tools/call` can have an effect, and the
1079
+ * endpoint honours no `Idempotency-Key`.
1080
+ *
1081
+ * @example
1082
+ * const listed = await client.mcp({ method: "tools/list", id: 1 });
1083
+ * listed.response?.result;
1084
+ */
1085
+ mcp(request: McpJsonRpcRequest, options?: McpOptions): Promise<McpResult>;
1086
+ /**
1087
+ * Resolve the presigned object URL behind `GET /api/v1/trader/{address}/export/download`
1088
+ * without downloading anything (#16137).
1089
+ *
1090
+ * The route answers `302` with a `Location`, which `call()` treats as an
1091
+ * error. This reads the redirect target and stops there, so a caller can
1092
+ * hand the URL to a download manager or a browser. The returned URL is a
1093
+ * bearer credential in itself: anyone holding it can read the file until it
1094
+ * expires, so do not log it.
1095
+ *
1096
+ * Browser caveat: `fetch` with `redirect: "manual"` yields an opaque
1097
+ * redirect whose `Location` no script can read. The method says so rather
1098
+ * than guessing a URL; run the download from a server runtime.
1099
+ */
1100
+ getTraderExportDownloadUrl(address: OperationPath["getTraderExportStatus"]["address"], jobId: OperationQuery["getTraderExportStatus"]["job_id"], options?: ConvenienceOptions): Promise<TraderExportDownloadTarget>;
1101
+ /**
1102
+ * Download a finished export (#16137): resolve the `302`, then fetch the
1103
+ * object store directly.
1104
+ *
1105
+ * The second request carries NO headers at all, so the live API key never
1106
+ * reaches the object store; the presigned URL is its own credential. The
1107
+ * body is not buffered -- read `response.body` as a stream and write it
1108
+ * where it belongs.
1109
+ *
1110
+ * There is no default deadline on the object fetch, the way `streamFeed`
1111
+ * has none: a multi-gigabyte export would fail the 15-second REST default
1112
+ * halfway through. Pass `signal` to cancel it, or `downloadTimeoutMs` for
1113
+ * a deadline of your own. `timeoutMs` still bounds the redirect request.
1114
+ *
1115
+ * @example
1116
+ * const { response, filename } = await client.downloadTraderExport(address, jobId);
1117
+ * await pipeline(Readable.fromWeb(response.body), createWriteStream(filename ?? "export.json"));
1118
+ */
1119
+ downloadTraderExport(address: OperationPath["getTraderExportStatus"]["address"], jobId: OperationQuery["getTraderExportStatus"]["job_id"], options?: TraderExportDownloadOptions): Promise<TraderExportDownload>;
1120
+ /**
1121
+ * Look up an operation and refuse it when the caller reached for the wrong
1122
+ * reader (#16137): `call()` on a Markdown route used to fail as a bad 200.
1123
+ */
1124
+ private resolveOperation;
1125
+ /**
1126
+ * One request pipeline for every transport: URL and headers, the retry
1127
+ * policy, one deadline shared by every attempt, the typed error hierarchy,
1128
+ * and cancellation held live through body consumption. `consume` runs
1129
+ * inside that window, so a slow body is still covered by the deadline and
1130
+ * by the caller's `signal`.
1131
+ */
1132
+ private request;
1133
+ /**
1134
+ * Execute a Stripe-style list operation and return its own list envelope
1135
+ * (`data`, `has_more`, `next_cursor`, and the route's extra fields such as
1136
+ * `facets` or `totals`). Use `paginate()` (in `pagination.ts`) to
1137
+ * auto-follow `next_cursor`.
1138
+ */
1139
+ list<K extends ListOperationId>(operationId: K, options?: OperationRequestOptions<K>): Promise<OperationEnvelope<K>>;
1140
+ /** The untyped form; see the second `call` signature. */
1141
+ list<T = unknown>(operationId: ApiOperationId, options?: ApiRequestOptions): Promise<ApiListEnvelope<T>>;
1142
+ getTrader(address: OperationPath["getTrader"]["address"], options?: Omit<OperationRequestOptions<"getTrader">, "path">): Promise<OperationResult<"getTrader">>;
1143
+ getTraderPnl(address: OperationPath["getTraderPnl"]["address"], options?: Omit<OperationRequestOptions<"getTraderPnl">, "path">): Promise<OperationResult<"getTraderPnl">>;
1144
+ /**
1145
+ * Fetch one wallet's win record per canonical category.
1146
+ *
1147
+ * Counts every settled market at any position size, so it can differ from
1148
+ * `category_strengths` on `getTrader`, which reads the floored calibration
1149
+ * sample. A category under `min_decided_for_win_rate` keeps its `wins` and
1150
+ * `decided` with `win_rate: null` and `status: "not_enough_data"`; a category
1151
+ * the wallet has no settled market in is absent, which means no record rather
1152
+ * than a 0% record. The `Esports` record carries `games`: the wallet's record
1153
+ * per esports title (`LoL`, `CS2`, `Dota 2`, ...) under the same rule, named
1154
+ * as the holder chips name them in `category_win_rate_game`. Pass
1155
+ * `params.category` to filter to one bucket; a filter that reaches Esports
1156
+ * returns its games too.
1157
+ */
1158
+ getTraderCategoryRecords(address: OperationPath["getTraderCategoryRecords"]["address"], params?: OperationQuery["getTraderCategoryRecords"], options?: ConvenienceOptions): Promise<OperationResult<"getTraderCategoryRecords">>;
1159
+ /**
1160
+ * Resolve 1 to 25 traders in one request (`POST /api/v1/traders/batch`).
1161
+ *
1162
+ * `traders` is sent as the request body's `traders` array, the field the
1163
+ * route requires: wallet addresses, usernames, `trd_` ids or integer trader
1164
+ * ids, resolved in input order. Until #16135 this method sent the array as
1165
+ * `identifiers`, a field the route does not declare, so every call was
1166
+ * refused for a missing `traders`. `options.expand` is sent as the body's
1167
+ * `expand` array and applies to every item.
1168
+ *
1169
+ * The response `data` keeps request order and one row per input, duplicates
1170
+ * included; a row is `status: "ok"` with `data`, or `status: "error"` with
1171
+ * the item's own `error` (an unknown identity is a per-item `not_found`, not
1172
+ * a request failure). `meta` is the batch's `BatchResponseMeta`:
1173
+ * `request_cost` and `rate_limit` follow the batch item quota, not the
1174
+ * per-request one.
1175
+ */
1176
+ batchGetTraders(traders: OperationBody["batchGetTraders"]["traders"], options?: BatchGetTradersOptions): Promise<OperationResult<"batchGetTraders">>;
1177
+ /**
1178
+ * Resolve up to 25 markets' intel in one request
1179
+ * (`POST /api/v1/markets/intel/batch`); `meta` is the batch's own.
1180
+ */
1181
+ batchGetMarketIntel(body: OperationBody["batchGetMarketIntel"], options?: ConvenienceOptions): Promise<OperationResult<"batchGetMarketIntel">>;
1182
+ listLeaderboard(params?: LeaderboardListParams, options?: ConvenienceOptions): Promise<OperationEnvelope<"listLeaderboard">>;
1183
+ listTrendingWallets(params?: TrendingWalletsParams, options?: ConvenienceOptions): Promise<OperationEnvelope<"listTrendingWallets">>;
1184
+ listWhaleTrades(params?: WhaleTradeListParams, options?: ConvenienceOptions): Promise<OperationEnvelope<"listWhaleTrades">>;
1185
+ listWhaleTradeHistory(params?: WhaleTradeHistoryParams, options?: ConvenienceOptions): Promise<OperationEnvelope<"listWhaleTradeHistory">>;
1186
+ listPositions(params?: PositionsListParams, options?: ConvenienceOptions): Promise<OperationEnvelope<"listPositions">>;
1187
+ listLargePositions(params?: LargePositionsListParams, options?: ConvenienceOptions): Promise<OperationEnvelope<"listLargePositions">>;
1188
+ listSmartMoneyFlows(params?: OperationQuery["listSmartMoneyFlows"], options?: ConvenienceOptions): Promise<OperationEnvelope<"listSmartMoneyFlows">>;
685
1189
  /** Canonical alias of {@link listSmartMoneyFlows} (epic #6912). */
686
- listSharpMoneyFlows<T = OperationData["listSharpMoneyFlows"][number]>(params?: ListParams & {
687
- min_grade?: Grade;
688
- }): Promise<ApiListEnvelope<T>>;
1190
+ listSharpMoneyFlows(params?: SharpMoneyFlowsParams, options?: ConvenienceOptions): Promise<OperationEnvelope<"listSharpMoneyFlows">>;
689
1191
  /**
690
1192
  * List the funded-primary sports signals with additive, shadow-only category
691
1193
  * evidence. `category_skill` never changes membership, ordering, or sizing.
692
1194
  */
693
- listSportsEdgeSignals(params?: SportsEdgeSignalsParams): Promise<ApiListEnvelope<SportsEdgeSignal>>;
1195
+ listSportsEdgeSignals(params?: SportsEdgeSignalsParams, options?: ConvenienceOptions): Promise<OperationEnvelope<"listSportsEdgeSignals">>;
694
1196
  /**
695
1197
  * Read an explicitly observation-only sports cohort and its accountable
696
1198
  * per-sport funnel. This surface is isolated from the funded signals route.
@@ -700,7 +1202,7 @@ export declare class OxinsiderApiClient {
700
1202
  * additive wider-holder projection, not an arrival-history or independent
701
1203
  * denominator view.
702
1204
  */
703
- listSportsEdgeObservations(params: SportsEdgeObservationsParams, options?: Omit<ApiRequestOptions, "query">): Promise<SportsEdgeObservationsResponse>;
1205
+ listSportsEdgeObservations(params: SportsEdgeObservationsParams, options?: ConvenienceOptions): Promise<SportsEdgeObservationsResponse>;
704
1206
  /**
705
1207
  * Typed conditional-read variant of {@link listSportsEdgeObservations}.
706
1208
  * Returns the full observation response on 200 or a typed `not_modified`
@@ -710,29 +1212,48 @@ export declare class OxinsiderApiClient {
710
1212
  * projection cutoff inside `next_cursor` is excluded while its stable page
711
1213
  * position remains covered.
712
1214
  */
713
- listSportsEdgeObservationsConditional(params: SportsEdgeObservationsParams, options?: Omit<ApiRequestOptions, "query">): Promise<SportsEdgeObservationsResponse | ApiNotModifiedResponse>;
714
- searchMarkets<T = OperationData["searchMarkets"]>(q: string, options?: ApiRequestOptions): Promise<ApiClientResponse<T>>;
715
- exploreMarkets<T = OperationData["getMarketIntel"]>(params?: ListParams): Promise<ApiListEnvelope<T>>;
716
- getMarketIntel<T = OperationData["getMarketIntel"]>(conditionId: string, options?: Omit<ApiRequestOptions, "path">): Promise<ApiClientResponse<T>>;
717
- getMarketSnapshot<T = OperationData["getMarketSnapshot"]>(conditionId: string, options?: Omit<ApiRequestOptions, "path">): Promise<ApiClientResponse<T>>;
1215
+ listSportsEdgeObservationsConditional(params: SportsEdgeObservationsParams, options?: ConvenienceOptions): Promise<SportsEdgeObservationsResponse | ApiNotModifiedResponse>;
1216
+ searchMarkets(q: OperationQuery["searchMarkets"]["q"], options?: ConvenienceOptions & {
1217
+ query?: Omit<OperationQuery["searchMarkets"], "q">;
1218
+ }): Promise<OperationEnvelope<"searchMarkets">>;
1219
+ searchContent(q: OperationQuery["searchContent"]["q"], options?: ConvenienceOptions & {
1220
+ query?: Omit<OperationQuery["searchContent"], "q">;
1221
+ }): Promise<OperationEnvelope<"searchContent">>;
1222
+ exploreMarkets(params?: ExploreMarketsParams, options?: ConvenienceOptions): Promise<OperationEnvelope<"exploreMarkets">>;
1223
+ getMarketIntel(conditionId: OperationPath["getMarketIntel"]["condition_id"], options?: Omit<OperationRequestOptions<"getMarketIntel">, "path">): Promise<OperationResult<"getMarketIntel">>;
1224
+ getMarketSnapshot(conditionId: OperationPath["getMarketSnapshot"]["condition_id"], options?: Omit<OperationRequestOptions<"getMarketSnapshot">, "path">): Promise<OperationResult<"getMarketSnapshot">>;
1225
+ /**
1226
+ * One page of a market's graded (S/A/B) holder roster from a complete
1227
+ * provider holder scan: the list a Pick of the Day shows, for any market.
1228
+ * `params.outcome` (`yes` | `no` | `all`), `params.min_grade` (`S` | `A` |
1229
+ * `B`), `params.limit` and `params.cursor` (`mh_` prefix). The page carries
1230
+ * the `market`, `scan` and roster `totals` beside `data`; `total` is the
1231
+ * count matching the filters across every page.
1232
+ */
1233
+ getMarketHolders(conditionId: OperationPath["getMarketHolders"]["condition_id"], params?: OperationQuery["getMarketHolders"], options?: ConvenienceOptions): Promise<OperationEnvelope<"getMarketHolders">>;
718
1234
  /**
719
1235
  * Fetch bucketed OHLC candles for a market's outcome tokens.
720
- * Resolution defaults to the server default; pass `query.resolution` as
721
- * `"1d"` or `"1w"` to override.
1236
+ * Resolution defaults to the server default; pass `params.resolution` as
1237
+ * `"1d"` or `"1w"` to override. `params.from` is exclusive and `params.to`
1238
+ * is inclusive; when both are present, `from` must be less than or equal to
1239
+ * `to`.
722
1240
  */
723
- getMarketCandles<T = OperationData["getMarketCandles"]>(conditionId: string, options?: Omit<ApiRequestOptions, "path">): Promise<ApiClientResponse<T>>;
724
- getInsiderRadarFlag<T = OperationData["getInsiderRadarFlag"]>(id: string, options?: Omit<ApiRequestOptions, "path">): Promise<ApiClientResponse<T>>;
725
- listInsiderRadar<T = OperationData["listWebhooks"]>(params?: ListParams & {
726
- min_grade?: Grade;
727
- }): Promise<ApiListEnvelope<T>>;
728
- listWebhooks<T = OperationData["listWebhooks"]>(options?: ApiRequestOptions): Promise<ApiClientResponse<T>>;
1241
+ getMarketCandles(conditionId: OperationPath["getMarketCandles"]["condition_id"], params?: OperationQuery["getMarketCandles"], options?: ConvenienceOptions): Promise<OperationResult<"getMarketCandles">>;
1242
+ getInsiderRadarFlag(id: OperationPath["getInsiderRadarFlag"]["id"], options?: ConvenienceOptions): Promise<OperationResult<"getInsiderRadarFlag">>;
1243
+ listInsiderRadar(params?: InsiderRadarListParams, options?: ConvenienceOptions): Promise<OperationEnvelope<"listInsiderRadar">>;
1244
+ getWhaleTrade(id: OperationPath["getWhaleTrade"]["id"], options?: ConvenienceOptions): Promise<OperationResult<"getWhaleTrade">>;
1245
+ listWebhooks(options?: ConvenienceOptions): Promise<OperationEnvelope<"listWebhooks">>;
1246
+ getWebhook(id: OperationPath["getWebhook"]["id"], options?: ConvenienceOptions): Promise<OperationResult<"getWebhook">>;
1247
+ createWebhook(body: OperationBody["createWebhook"], options?: ConvenienceOptions): Promise<OperationResult<"createWebhook">>;
1248
+ updateWebhook(id: OperationPath["updateWebhook"]["id"], body: OperationBody["updateWebhook"], options?: ConvenienceOptions): Promise<OperationResult<"updateWebhook">>;
1249
+ deleteWebhook(id: OperationPath["deleteWebhook"]["id"], options?: ConvenienceOptions): Promise<OperationResult<"deleteWebhook">>;
729
1250
  /**
730
1251
  * Fetch the self-describing webhook event catalog (each entry's `id`,
731
1252
  * description, payload shape, and active/dormant status).
732
1253
  */
733
- listWebhookEvents<T = OperationData["listWebhookEvents"]>(options?: ApiRequestOptions): Promise<ApiClientResponse<T>>;
1254
+ listWebhookEvents(options?: ConvenienceOptions): Promise<OperationEnvelope<"listWebhookEvents">>;
734
1255
  /** List delivery attempts for one webhook endpoint (Stripe-style list). */
735
- listWebhookDeliveries<T = OperationData["redeliverWebhookDelivery"]>(webhookId: string | number, params?: ListParams): Promise<ApiListEnvelope<T>>;
1256
+ listWebhookDeliveries(webhookId: OperationPath["listWebhookDeliveries"]["id"], params?: OperationQuery["listWebhookDeliveries"], options?: ConvenienceOptions): Promise<OperationEnvelope<"listWebhookDeliveries">>;
736
1257
  /**
737
1258
  * Requeue one `dead_letter` delivery with a fresh attempt budget and return
738
1259
  * the delivery row. Re-enabling a disabled endpoint resends nothing, so this
@@ -741,20 +1262,39 @@ export declare class OxinsiderApiClient {
741
1262
  * disabled, unverified, or no longer subscribed to the delivery's event type;
742
1263
  * the error message names the fix. Pass `idempotencyKey` to make a retry safe.
743
1264
  */
744
- redeliverWebhookDelivery<T = OperationData["redeliverWebhookDelivery"]>(webhookId: string | number, deliveryId: string | number, options?: Omit<ApiRequestOptions, "path" | "body">): Promise<ApiClientResponse<T>>;
745
- getHealth<T = OperationData["getHealth"]>(options?: ApiRequestOptions): Promise<ApiClientResponse<T>>;
746
- getApiDiscovery<T = OperationData["getApiDiscovery"]>(options?: ApiRequestOptions): Promise<ApiClientResponse<T>>;
747
- getAccountIdentity(options?: ApiRequestOptions): Promise<ApiClientResponse<{
748
- user_id: number;
749
- credential_id: number;
750
- credential_kind: "api_key" | "oauth_grant";
751
- scopes: string[] | null;
752
- }>>;
753
- getUsage<T = OperationData["getUsage"]>(options?: ApiRequestOptions): Promise<ApiClientResponse<T>>;
1265
+ redeliverWebhookDelivery(webhookId: OperationPath["redeliverWebhookDelivery"]["id"], deliveryId: OperationPath["redeliverWebhookDelivery"]["delivery_id"], options?: ConvenienceOptions): Promise<OperationResult<"redeliverWebhookDelivery">>;
1266
+ getHealth(options?: ConvenienceOptions): Promise<OperationResult<"getHealth">>;
1267
+ getApiDiscovery(options?: ConvenienceOptions): Promise<OperationResult<"getApiDiscovery">>;
1268
+ getPlatforms(options?: ConvenienceOptions): Promise<OperationResult<"getPlatforms">>;
1269
+ getAccountIdentity(options?: ConvenienceOptions): Promise<OperationResult<"getAccountIdentity">>;
1270
+ /**
1271
+ * One wallet's context as Markdown, ready to paste into a model prompt
1272
+ * (`GET /api/v1/trader/{address}/context.md`). The JSON form of the same
1273
+ * read is `getTraderContext`.
1274
+ */
1275
+ getTraderContextMarkdown(address: OperationPath["getTraderContextMarkdown"]["address"], options?: Omit<OperationRequestOptions<"getTraderContextMarkdown">, "path">): Promise<string>;
1276
+ /**
1277
+ * One market's context as Markdown
1278
+ * (`GET /api/v1/market/{condition_id}/context.md`). The JSON form is
1279
+ * `getMarketIntel`.
1280
+ */
1281
+ getMarketContextMarkdown(conditionId: OperationPath["getMarketContextMarkdown"]["condition_id"], options?: Omit<OperationRequestOptions<"getMarketContextMarkdown">, "path">): Promise<string>;
1282
+ /**
1283
+ * Mint a sandbox key (`POST /api/v1/agents/register`), the one write that
1284
+ * needs no credential. Answers `201`, which is why the SDK had no method
1285
+ * for it until #16137: the drift gate counted only operations with a
1286
+ * documented `200`. `meta.status` is `201`; `data.api_key` is the
1287
+ * `oxi_sk_test_*` key to pass to `OxinsiderApiClient.sandbox()`.
1288
+ *
1289
+ * Nothing is stored: the key cannot be listed or revoked and does not
1290
+ * expire. Register again for another one.
1291
+ */
1292
+ registerAgent(options?: ConvenienceOptions): Promise<OperationResult<"registerAgent">>;
1293
+ getUsage(options?: ConvenienceOptions): Promise<OperationResult<"getUsage">>;
754
1294
  /** Fetch today's editorial Pick of the Day (single-object envelope). */
755
- getPickOfTheDay<T = PickOfTheDay>(options?: ApiRequestOptions): Promise<ApiClientResponse<T>>;
1295
+ getPickOfTheDay(options?: ConvenienceOptions): Promise<OperationResult<"getPickOfTheDay">>;
756
1296
  /** Fetch the Pick of the Day archive with hit-rate (single-object envelope). */
757
- getPickOfTheDayArchive<T = PickOfTheDayArchive>(options?: ApiRequestOptions): Promise<ApiClientResponse<T>>;
1297
+ getPickOfTheDayArchive(options?: ConvenienceOptions): Promise<OperationResult<"getPickOfTheDayArchive">>;
758
1298
  /**
759
1299
  * Fetch the Pick of the Day commitment ledger (single-object envelope).
760
1300
  *
@@ -766,17 +1306,34 @@ export declare class OxinsiderApiClient {
766
1306
  * received and hashing with sha256; do not reserialize the payload, since it
767
1307
  * is served byte for byte as it was hashed.
768
1308
  */
769
- getPickOfTheDayLedger<T = PickOfTheDayLedger>(options?: ApiRequestOptions): Promise<ApiClientResponse<T>>;
1309
+ getPickOfTheDayLedger(options?: ConvenienceOptions): Promise<OperationResult<"getPickOfTheDayLedger">>;
770
1310
  /** Resolve the base URL (used by the SSE stream consumer). */
771
1311
  getBaseUrl(): string;
772
1312
  /** The configured API key, if any (used by the SSE stream consumer). */
773
1313
  getApiKey(): string | undefined;
1314
+ /** Whether this client was built in sandbox mode (#16138). */
1315
+ isSandbox(): boolean;
774
1316
  /** The resolved fetch implementation (used by the SSE stream consumer). */
775
1317
  getFetch(): typeof fetch;
776
1318
  buildUrl(operation: ApiClientOperation, options: ApiRequestOptions): string;
777
1319
  private buildHeaders;
778
1320
  }
779
- export declare function isApiNotModifiedResponse(response: ApiClientResponse<unknown>): response is ApiNotModifiedResponse;
1321
+ /**
1322
+ * Narrow a `call()` result to the typed 304. Takes any envelope-shaped
1323
+ * value, so it works on an `OperationResult<K>` (whose `meta` is the
1324
+ * operation's own type) as well as the loose `ApiClientResponse<T>`
1325
+ * (#16136).
1326
+ */
1327
+ export declare function isApiNotModifiedResponse<R extends {
1328
+ object: string;
1329
+ }>(response: R): response is Extract<R, ApiNotModifiedResponse>;
780
1330
  export declare function interpolatePath(path: string, params: Partial<Record<string, string | number>>): string;
1331
+ /**
1332
+ * Whether `body` is a list envelope whose control fields the walker can act
1333
+ * on: `object: "list"`, an array `data`, a BOOLEAN `has_more`, and a
1334
+ * `next_cursor` that is a string, `null` or absent (#16246: the check used to
1335
+ * accept any `has_more` that was merely present, so a malformed value could
1336
+ * be coerced into "no more pages" or "more pages" by truthiness).
1337
+ */
781
1338
  export declare function isListEnvelope<T>(body: unknown): body is ApiListEnvelope<T>;
782
1339
  //# sourceMappingURL=client.d.ts.map