@0xinsider/sdk 0.25.0 → 0.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/retry.d.ts CHANGED
@@ -55,6 +55,25 @@ export declare const RETRY_AFTER_CEILING_MS = 60000;
55
55
  export declare function parseRetryAfter(header: string | null | undefined, nowMs?: number): number | null;
56
56
  /** `parseRetryAfter` over a response's `Retry-After` header. */
57
57
  export declare function retryAfterSeconds(response: Response): number | null;
58
+ /**
59
+ * Parse a `Retry-After` header value by the RFC 9110 grammar alone into whole
60
+ * seconds, or `null` when it does not match.
61
+ *
62
+ * `parseRetryAfter` drives this module's own waits and keeps its documented
63
+ * extensions (a fractional delay, any date `Date.parse` reads). This one is
64
+ * for a caller that hands the seconds on as a validated fact rather than
65
+ * waiting on them: the stdio MCP server's `retry_after_seconds` field and its
66
+ * "Retry after Ns." text (#19729), which must agree and must never present a
67
+ * malformed header as an instruction.
68
+ *
69
+ * - delay-seconds: digits only (`"60"`). A sign, fraction, exponent, trailing
70
+ * text, or a value past `Number.MAX_SAFE_INTEGER` is `null`.
71
+ * - HTTP-date: IMF-fixdate, the obsolete RFC 850 form and asctime, with the
72
+ * calendar date and the weekday checked. The delay counts from `nowMs` and
73
+ * rounds up to a whole second; a date already past is `0`.
74
+ * - Anything else, an empty value included, is `null`.
75
+ */
76
+ export declare function parseRetryAfterStrict(header: string | null | undefined, nowMs?: number): number | null;
58
77
  /**
59
78
  * Resolve after `ms`, or reject with the signal's reason the moment it
60
79
  * aborts. A wait longer than `MAX_TIMER_DELAY_MS` runs as consecutive timers
@@ -1 +1 @@
1
- {"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../src/retry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,aAAgB,CAAC;AAEhD;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,QAAS,CAAC;AA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SAAS,GAC9B,OAAO,CAAC,IAAI,CAAC,CAaf;AAED,wEAAwE;AACxE,wBAAsB,iBAAiB,CACrC,EAAE,EAAE,MAAM,EACV,MAAM,EAAE,WAAW,GAAG,SAAS,GAC9B,OAAO,CAAC,OAAO,CAAC,CAQlB"}
package/dist/retry.js CHANGED
@@ -73,6 +73,117 @@ export function parseRetryAfter(header, nowMs = Date.now()) {
73
73
  export function retryAfterSeconds(response) {
74
74
  return parseRetryAfter(response.headers.get("retry-after"));
75
75
  }
76
+ /**
77
+ * Parse a `Retry-After` header value by the RFC 9110 grammar alone into whole
78
+ * seconds, or `null` when it does not match.
79
+ *
80
+ * `parseRetryAfter` drives this module's own waits and keeps its documented
81
+ * extensions (a fractional delay, any date `Date.parse` reads). This one is
82
+ * for a caller that hands the seconds on as a validated fact rather than
83
+ * waiting on them: the stdio MCP server's `retry_after_seconds` field and its
84
+ * "Retry after Ns." text (#19729), which must agree and must never present a
85
+ * malformed header as an instruction.
86
+ *
87
+ * - delay-seconds: digits only (`"60"`). A sign, fraction, exponent, trailing
88
+ * text, or a value past `Number.MAX_SAFE_INTEGER` is `null`.
89
+ * - HTTP-date: IMF-fixdate, the obsolete RFC 850 form and asctime, with the
90
+ * calendar date and the weekday checked. The delay counts from `nowMs` and
91
+ * rounds up to a whole second; a date already past is `0`.
92
+ * - Anything else, an empty value included, is `null`.
93
+ */
94
+ export function parseRetryAfterStrict(header, nowMs = Date.now()) {
95
+ if (header === null || header === undefined)
96
+ return null;
97
+ const value = header.trim();
98
+ if (/^\d+$/.test(value)) {
99
+ const seconds = Number(value);
100
+ return Number.isSafeInteger(seconds) ? seconds : null;
101
+ }
102
+ const dateMs = httpDateMs(value, nowMs);
103
+ if (dateMs === null)
104
+ return null;
105
+ const seconds = Math.max(0, Math.ceil((dateMs - nowMs) / 1000));
106
+ return Number.isSafeInteger(seconds) ? seconds : null;
107
+ }
108
+ /** RFC 9110 section 5.6.7: all three HTTP-date forms, with UTC calendar validation. */
109
+ function httpDateMs(value, nowMs) {
110
+ const shortDay = "(Mon|Tue|Wed|Thu|Fri|Sat|Sun)";
111
+ const month = "(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)";
112
+ const clock = "(\\d{2}):(\\d{2}):(\\d{2})";
113
+ let match = new RegExp(`^${shortDay}, (\\d{2}) ${month} (\\d{4}) ${clock} GMT$`).exec(value);
114
+ let obsoleteYear = false;
115
+ if (!match) {
116
+ match = new RegExp(`^(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (\\d{2})-${month}-(\\d{2}) ${clock} GMT$`).exec(value);
117
+ obsoleteYear = match !== null;
118
+ }
119
+ let captures;
120
+ if (!match) {
121
+ const asctime = new RegExp(`^${shortDay} ${month} (\\d{2}| \\d) ${clock} (\\d{4})$`).exec(value);
122
+ if (!asctime)
123
+ return null;
124
+ captures = [
125
+ asctime[1],
126
+ asctime[3],
127
+ asctime[2],
128
+ asctime[7],
129
+ asctime[4],
130
+ asctime[5],
131
+ asctime[6],
132
+ ];
133
+ }
134
+ else {
135
+ captures = match.slice(1);
136
+ }
137
+ const [weekday, dayText, monthText, yearText, hourText, minuteText, secondText] = captures;
138
+ if (weekday === undefined ||
139
+ dayText === undefined ||
140
+ monthText === undefined ||
141
+ yearText === undefined ||
142
+ hourText === undefined ||
143
+ minuteText === undefined ||
144
+ secondText === undefined)
145
+ return null;
146
+ const day = Number(dayText);
147
+ const monthIndex = [
148
+ "Jan",
149
+ "Feb",
150
+ "Mar",
151
+ "Apr",
152
+ "May",
153
+ "Jun",
154
+ "Jul",
155
+ "Aug",
156
+ "Sep",
157
+ "Oct",
158
+ "Nov",
159
+ "Dec",
160
+ ].indexOf(monthText);
161
+ let year = Number(yearText);
162
+ const hour = Number(hourText);
163
+ const minute = Number(minuteText);
164
+ const second = Number(secondText);
165
+ if (hour > 23 || minute > 59 || second > 60)
166
+ return null;
167
+ const date = new Date(0);
168
+ const future = new Date(nowMs);
169
+ future.setUTCFullYear(future.getUTCFullYear() + 50);
170
+ if (obsoleteYear)
171
+ year += Math.floor(future.getUTCFullYear() / 100) * 100;
172
+ date.setUTCFullYear(year, monthIndex, day);
173
+ date.setUTCHours(hour, minute, Math.min(second, 59), 0);
174
+ if (obsoleteYear && date.getTime() > future.getTime()) {
175
+ year -= 100;
176
+ date.setUTCFullYear(year, monthIndex, day);
177
+ }
178
+ if (date.getUTCFullYear() !== year ||
179
+ date.getUTCMonth() !== monthIndex ||
180
+ date.getUTCDate() !== day)
181
+ return null;
182
+ if (["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"][date.getUTCDay()] !==
183
+ weekday.slice(0, 3))
184
+ return null;
185
+ return date.getTime() + (second === 60 ? 1000 : 0);
186
+ }
76
187
  /**
77
188
  * Resolve after `ms`, or reject with the signal's reason the moment it
78
189
  * aborts. A wait longer than `MAX_TIMER_DELAY_MS` runs as consecutive timers
package/dist/retry.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"retry.js","sourceRoot":"","sources":["../src/retry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,aAAa,CAAC;AAEhD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC;AAE7C;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,eAAe,CAC7B,MAAiC,EACjC,KAAK,GAAW,IAAI,CAAC,GAAG,EAAE;IAE1B,IAAI,MAAM,KAAK,IAAI,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IACzD,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC;IAC3B,IAAI,IAAI,KAAK,EAAE;QAAE,OAAO,IAAI,CAAC;IAC7B,wEAAwE;IACxE,+DAA+D;IAC/D,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;IAC3B,IAAI,CAA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CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,IAAI,MAAM,EAAE,OAAO,EAAE,CAAC;YACpB,MAAM,MAAM,GAAY,MAAM,CAAC,MAAM,CAAC;YACtC,MAAM,CAAC,MAAM,CAAC,CAAC;YACf,OAAO;QACT,CAAC;QACD,MAAM,OAAO,GAAG,GAAG,EAAE;YACnB,YAAY,CAAC,KAAK,CAAC,CAAC;YACpB,MAAM,MAAM,GAAY,MAAM,EAAE,MAAM,CAAC;YACvC,MAAM,CAAC,MAAM,CAAC,CAAC;QACjB,CAAC,CAAC;QACF,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;YAC5B,MAAM,EAAE,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAC9C,OAAO,EAAE,CAAC;QACZ,CAAC,EAAE,EAAE,CAAC,CAAC;QACP,MAAM,EAAE,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7D,CAAC,CAAC,CAAC;AACL,CAAC"}
package/dist/schema.d.ts CHANGED
@@ -1046,7 +1046,7 @@ export type ExploreMarket = {
1046
1046
  no_change_pct_24h: number | null;
1047
1047
  /** Backend-owned deterministic market discovery score used by the hot sort. */
1048
1048
  discover_score: number | null;
1049
- score_components?: {
1049
+ score_components: {
1050
1050
  volume_signal: number | null;
1051
1051
  /** Canonical key since #16304; whale_signal is its deprecated spelling, emitted beside it with the same value. */
1052
1052
  large_trade_signal: number | null;
@@ -1063,7 +1063,7 @@ export type ExploreMarket = {
1063
1063
  price_move_signal: number | null;
1064
1064
  missing_price_penalty: number;
1065
1065
  };
1066
- freshness?: {
1066
+ freshness: {
1067
1067
  enrichment_status: "available" | "unavailable";
1068
1068
  price_status: "available" | "unavailable";
1069
1069
  };
@@ -1298,19 +1298,19 @@ export type LargeExportPolicy = {
1298
1298
  /** Programmatic API-key-gated export routes (submit/status/download/cancel) and supported formats (json, ndjson, csv). */
1299
1299
  v1_async: {
1300
1300
  /** POST route template to submit an export job. fresh=true asks for a snapshot read after the submit instead of reusing a finished one. */
1301
- submit_route?: string;
1301
+ submit_route: string;
1302
1302
  /** GET route template to poll job status. */
1303
- status_route?: string;
1303
+ status_route: string;
1304
1304
  /** GET route template that 302-redirects to the file. */
1305
- download_route?: string;
1305
+ download_route: string;
1306
1306
  /** POST route template to cancel a queued or running job. */
1307
- cancel_route?: string;
1307
+ cancel_route: string;
1308
1308
  /** Supported ?format= values. */
1309
- formats?: ("json" | "ndjson" | "csv")[];
1309
+ formats: ("json" | "ndjson" | "csv")[];
1310
1310
  /** Possible job status values. */
1311
- status_values?: ("queued" | "running" | "ready" | "failed" | "reconcile_required" | "expired" | "cancel_requested" | "cancelled")[];
1311
+ status_values: ("queued" | "running" | "ready" | "failed" | "reconcile_required" | "expired" | "cancel_requested" | "cancelled")[];
1312
1312
  /** How long a finished export is retained before expiry. */
1313
- retention?: string;
1313
+ retention: string;
1314
1314
  };
1315
1315
  direct_streaming: Record<string, unknown>;
1316
1316
  async_job: Record<string, unknown>;
@@ -1520,7 +1520,7 @@ export type MarketFlow = {
1520
1520
  /** The Polymarket CLOB token id (ERC1155 asset id, decimal string) for the net-flow direction outcome; null when unavailable (e.g. unsynced markets). */
1521
1521
  token_id: string | null;
1522
1522
  /** Canonical key since #16304 (Polymarket's noun is large trade); whale_trade_count is its deprecated spelling, emitted beside it with the same value. */
1523
- large_trade_count?: number;
1523
+ large_trade_count: number;
1524
1524
  whale_trade_count: number;
1525
1525
  buy_volume_usd: number;
1526
1526
  sell_volume_usd: number;
@@ -1547,7 +1547,7 @@ export type MarketFlow = {
1547
1547
  /** The Polymarket CLOB token id (ERC1155 asset id, decimal string) for the net-flow direction outcome; null when unavailable (e.g. unsynced markets). */
1548
1548
  token_id: string | null;
1549
1549
  /** Canonical key since #16304 (Polymarket's noun is large trade); whale_trade_count is its deprecated spelling, emitted beside it with the same value. */
1550
- large_trade_count?: number;
1550
+ large_trade_count: number;
1551
1551
  whale_trade_count: number;
1552
1552
  buy_volume_usd: number;
1553
1553
  sell_volume_usd: number;
@@ -1706,6 +1706,7 @@ export type MarketSnapshot = {
1706
1706
  side: "yes" | "no";
1707
1707
  label: string;
1708
1708
  token_id?: string;
1709
+ /** The outcome's display price, the probability Polymarket shows for it: the midpoint of the cached top of book when the spread is at most 0.10, otherwise the token's last trade price. Omitted when neither is known, including a book wider than 0.10 with no last trade on record; top_of_book still carries that book's best_bid and best_ask. expand=trust explains a missing value in trust.current_price. */
1709
1710
  current_price?: number;
1710
1711
  top_of_book: MarketSnapshotTopOfBook;
1711
1712
  })[];
@@ -1766,7 +1767,7 @@ export type MarketSnapshotTrust = {
1766
1767
  };
1767
1768
  export type McpJsonRpcError = {
1768
1769
  jsonrpc: "2.0";
1769
- id?: string | number | null;
1770
+ id: string | number | null;
1770
1771
  error: {
1771
1772
  code: number;
1772
1773
  message: string;
@@ -2048,7 +2049,7 @@ export type PickOfTheDayArchiveEntry = {
2048
2049
  * Deprecated compatibility daily release slot; use pick_id for identity and publication_order for scheduling.
2049
2050
  * @deprecated
2050
2051
  */
2051
- pick_rank?: number;
2052
+ pick_rank: number;
2052
2053
  /** When this selection was published, as RFC3339 UTC. Use this instant for publication feeds and timelines; pick_date is the America/New_York product day, not a publication timestamp. Automatic picks publish from 03:00 America/New_York on pick_date. Absent only for historical rows whose publication instant is unknown. */
2053
2054
  published_at?: string;
2054
2055
  /** Human-readable matchup (e.g. "Portugal vs. Uzbekistan"). */
@@ -2170,7 +2171,7 @@ export type PickOfTheDayHitRate = {
2170
2171
  /** Number of picks still pending resolution (excluded from the hit rate). */
2171
2172
  pending: number;
2172
2173
  /** The flat stake every money figure here assumes, in USD: 1000 since 2026-09-22 (100 before). Always present. */
2173
- stake_usd?: number;
2174
+ stake_usd: number;
2174
2175
  /** Cumulative profit (USD) of a stake_usd-per-pick strategy over visible valued decided picks: a priced win pays stake_usd/backed_price - stake_usd, every visible loss pays -stake_usd independent of price, and a void pays 0. An unpriced visible win and a current non-Insider row whose price is gated remain in wins/losses but are excluded from price-derived totals. */
2175
2176
  net_profit_usd: number;
2176
2177
  /** Total staked (USD) = stake_usd * count of visible valued decided picks: every visible loss plus every priced win. Void, unpriced wins, and current non-Insider rows whose price is gated are excluded. */
@@ -2222,7 +2223,7 @@ export type PickOfTheDayHitRate = {
2222
2223
  /** Measured public rows where close exactly equals entry. */
2223
2224
  clv_ties: number;
2224
2225
  /** Cumulative track-record series, one point per decided (win/loss) pick in ascending pick_date order (void and pending add no point). A non-valued decided row carries cumulative profit forward while advancing hit rate. The last point's net_profit_usd and hit_rate_pct equal the headline net_profit_usd and pct by construction. Empty when nothing is decided. */
2225
- series?: {
2226
+ series: {
2226
2227
  /** The decided pick's publish date (YYYY-MM-DD). */
2227
2228
  date: string;
2228
2229
  /** Running cumulative stake_usd-per-pick profit (USD) through this pick; valued losses and priced wins are booked, while a non-valued decided row carries profit forward unchanged. */
@@ -2813,7 +2814,7 @@ export type SmartMoneyFlowMarket = {
2813
2814
  /** The Polymarket CLOB token id (ERC1155 asset id, decimal string) for the net-flow direction outcome; null when unavailable (e.g. unsynced markets). */
2814
2815
  token_id: string | null;
2815
2816
  /** Canonical key since #16304 (Polymarket's noun is large trade); whale_trade_count is its deprecated spelling, emitted beside it with the same value. */
2816
- large_trade_count?: number;
2817
+ large_trade_count: number;
2817
2818
  whale_trade_count: number;
2818
2819
  buy_volume_usd: number;
2819
2820
  sell_volume_usd: number;
@@ -2828,7 +2829,7 @@ export type SmartMoneyFlowMarket = {
2828
2829
  /** The Polymarket CLOB token id (ERC1155 asset id, decimal string) for the net-flow direction outcome; null when unavailable (e.g. unsynced markets). */
2829
2830
  token_id: string | null;
2830
2831
  /** Canonical key since #16304 (Polymarket's noun is large trade); whale_trade_count is its deprecated spelling, emitted beside it with the same value. */
2831
- large_trade_count?: number;
2832
+ large_trade_count: number;
2832
2833
  whale_trade_count: number;
2833
2834
  buy_volume_usd: number;
2834
2835
  sell_volume_usd: number;
@@ -2841,7 +2842,7 @@ export type SnapshotCompleteness = {
2841
2842
  reason: string;
2842
2843
  expected_days: number;
2843
2844
  /** Canonical key since #16304; covered_days_with_whale_activity is its deprecated spelling, emitted beside it with the same value. */
2844
- covered_days_with_large_trade_activity?: number;
2845
+ covered_days_with_large_trade_activity: number;
2845
2846
  covered_days_with_whale_activity: number;
2846
2847
  };
2847
2848
  export type SnapshotState = {
@@ -2973,7 +2974,7 @@ export type Trader = {
2973
2974
  };
2974
2975
  strategy?: {
2975
2976
  /** Observed trading style identifier. New rows use two_sided, category_focused, high_activity, diversified, mixed, or unclassified. Historical identifiers remain readable during normal reclassification; style does not predict skill or intent. */
2976
- strategy_type?: string;
2977
+ strategy_type: string;
2977
2978
  description?: string;
2978
2979
  confidence?: number;
2979
2980
  };
@@ -3501,8 +3502,6 @@ export type Usage = {
3501
3502
  pay_as_you_go: boolean;
3502
3503
  /** The most requests this account is admitted in a UTC calendar month once enforcement has begun: limit, or four times limit with pay as you go on (2,000,000 for Pro). null for an admin account, which no number stops. Additive since 2026-09-22. */
3503
3504
  ceiling: number | null;
3504
- /** A historical usage price has not been reconciled to this plan allowance. Pay as you go remains unavailable until billing reconciliation. */
3505
- unavailable_reason?: "usage_price_reconciliation_required" | null;
3506
3505
  } | null;
3507
3506
  };
3508
3507
  meta: ResponseMeta;
@@ -3853,6 +3852,8 @@ export interface OperationData {
3853
3852
  error?: {
3854
3853
  code: number;
3855
3854
  message: string;
3855
+ /** Optional JSON-serializable error data. */
3856
+ data?: Record<string, unknown> | unknown[] | string | number | boolean | null;
3856
3857
  };
3857
3858
  };
3858
3859
  createWebhook: WebhookEndpoint;
@@ -3882,10 +3883,10 @@ export interface OperationData {
3882
3883
  getEventReplaySince: EventReplayEvent[];
3883
3884
  getGame: Game;
3884
3885
  getHealth: {
3885
- status?: "ok" | "degraded" | "down" | "maintenance";
3886
- db?: boolean;
3887
- cache?: boolean;
3888
- subsystems?: {
3886
+ status: "ok" | "degraded" | "down" | "maintenance";
3887
+ db: boolean;
3888
+ cache: boolean;
3889
+ subsystems: {
3889
3890
  /** Whether the webhook outbox schema validated on this probe. false lowers status to degraded. true during a maintenance window, when nothing is probed. */
3890
3891
  webhook_compatibility: boolean;
3891
3892
  /** Public-safe aggregate status for expected background job successful-completion heartbeats. Does not expose Redis keys, job names, raw errors, provider payloads, wallet addresses, or condition IDs. */
@@ -4011,8 +4012,6 @@ export interface OperationData {
4011
4012
  pay_as_you_go: boolean;
4012
4013
  /** The most requests this account is admitted in a UTC calendar month once enforcement has begun: limit, or four times limit with pay as you go on (2,000,000 for Pro). null for an admin account, which no number stops. Additive since 2026-09-22. */
4013
4014
  ceiling: number | null;
4014
- /** A historical usage price has not been reconciled to this plan allowance. Pay as you go remains unavailable until billing reconciliation. */
4015
- unavailable_reason?: "usage_price_reconciliation_required" | null;
4016
4015
  } | null;
4017
4016
  };
4018
4017
  getWebhook: WebhookEndpoint;
@@ -5118,6 +5117,8 @@ export interface OperationResponse {
5118
5117
  error?: {
5119
5118
  code: number;
5120
5119
  message: string;
5120
+ /** Optional JSON-serializable error data. */
5121
+ data?: Record<string, unknown> | unknown[] | string | number | boolean | null;
5121
5122
  };
5122
5123
  };
5123
5124
  createWebhook: {