@hyav/pi-provider 0.1.2 → 0.1.4

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 (52) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/README.md +30 -4
  3. package/README.zh-CN.md +30 -4
  4. package/core/adapter-loader.ts +58 -12
  5. package/core/catalog-preflight.ts +130 -0
  6. package/core/credential-type.ts +13 -0
  7. package/core/host.ts +4 -3
  8. package/core/official-pricing.ts +2 -3
  9. package/core/preflight-manager.ts +13 -0
  10. package/core/public-adapters.ts +47 -0
  11. package/core/ratelimit-headers.ts +72 -0
  12. package/core/runtime-config.ts +92 -8
  13. package/core/runtime-entry.ts +26 -0
  14. package/core/runtime.ts +23 -10
  15. package/core/status-manager.ts +7 -1
  16. package/core/types.ts +12 -0
  17. package/index.ts +30 -6
  18. package/package.json +1 -1
  19. package/preflight/anthropic.ts +42 -0
  20. package/preflight/cerebras.ts +27 -0
  21. package/preflight/charm-hyper.ts +2 -4
  22. package/preflight/deepseek.ts +2 -4
  23. package/preflight/github-copilot.ts +74 -0
  24. package/preflight/google.ts +2 -4
  25. package/preflight/groq.ts +72 -0
  26. package/preflight/huggingface.ts +27 -0
  27. package/preflight/mistral.ts +27 -0
  28. package/preflight/moonshotai-cn.ts +27 -0
  29. package/preflight/moonshotai.ts +37 -0
  30. package/preflight/nvidia.ts +27 -0
  31. package/preflight/openai-codex.ts +2 -4
  32. package/preflight/openai.ts +27 -0
  33. package/preflight/opencode-go.ts +2 -3
  34. package/preflight/opencode.ts +2 -3
  35. package/preflight/openrouter.ts +111 -0
  36. package/preflight/vercel-ai-gateway.ts +86 -0
  37. package/preflight/xai.ts +70 -0
  38. package/providers/charm-hyper.ts +8 -5
  39. package/status/anthropic.ts +258 -0
  40. package/status/charm-hyper.ts +3 -5
  41. package/status/deepseek.ts +2 -4
  42. package/status/github-copilot.ts +176 -0
  43. package/status/groq.ts +88 -0
  44. package/status/huggingface.ts +94 -0
  45. package/status/moonshotai-cn.ts +26 -0
  46. package/status/moonshotai.ts +150 -0
  47. package/status/openai-codex.ts +2 -4
  48. package/status/opencode-go.ts +2 -4
  49. package/status/openrouter.ts +172 -0
  50. package/status/vercel-ai-gateway/constants.ts +3 -0
  51. package/status/vercel-ai-gateway.ts +94 -0
  52. package/status/xai.ts +73 -0
@@ -0,0 +1,150 @@
1
+ import type { StatusAdapter, StatusEntry, StatusSnapshot } from "@hyav/pi-provider";
2
+ import { defineStatusExtension, ProviderDataError, parseRetryAfter } from "@hyav/pi-provider";
3
+
4
+ /**
5
+ * Moonshot (Kimi) balance checks. International and China platforms keep
6
+ * fully independent API keys; the same response shape is shared by both
7
+ * endpoints, so the adapter body is factored once.
8
+ */
9
+ export const MOONSHOT_BALANCE_URL = "https://api.moonshot.ai/v1/users/me/balance";
10
+ export const MOONSHOT_CN_BALANCE_URL = "https://api.moonshot.cn/v1/users/me/balance";
11
+
12
+ function isRecord(value: unknown): value is Record<string, unknown> {
13
+ return value !== null && typeof value === "object" && !Array.isArray(value);
14
+ }
15
+
16
+ function finiteNumber(value: unknown): number | undefined {
17
+ return typeof value === "number" && Number.isFinite(value) ? value : undefined;
18
+ }
19
+
20
+ export interface MoonshotBalance {
21
+ available: number;
22
+ voucher?: number;
23
+ cash?: number;
24
+ }
25
+
26
+ export function parseMoonshotBalance(payload: unknown): MoonshotBalance {
27
+ if (!isRecord(payload) || !isRecord(payload.data)) {
28
+ throw new ProviderDataError("Moonshot status returned an invalid balance response", "badjson");
29
+ }
30
+ const code = payload.code;
31
+ if (code !== 0 && code !== undefined) {
32
+ throw new ProviderDataError("Moonshot status returned an unsuccessful balance response", "provider");
33
+ }
34
+ const available = finiteNumber(payload.data.available_balance);
35
+ if (available === undefined) {
36
+ throw new ProviderDataError("Moonshot status returned an invalid balance response", "badjson");
37
+ }
38
+ const voucher = finiteNumber(payload.data.voucher_balance);
39
+ const cash = finiteNumber(payload.data.cash_balance);
40
+ // Voucher balances are documented as non-negative; cash may be negative.
41
+ if (voucher !== undefined && voucher < 0) {
42
+ throw new ProviderDataError("Moonshot status returned an invalid balance response", "badjson");
43
+ }
44
+ return {
45
+ available,
46
+ ...(voucher !== undefined ? { voucher } : {}),
47
+ ...(cash !== undefined ? { cash } : {}),
48
+ };
49
+ }
50
+
51
+ export interface MoonshotStatusConfig {
52
+ id: string;
53
+ providerId: string;
54
+ name: string;
55
+ balanceUrl: string;
56
+ /** Official docs: international balances are USD; China balances are CNY. */
57
+ unit: string;
58
+ }
59
+
60
+ export function createMoonshotStatusAdapter(config: MoonshotStatusConfig, requestTimeoutMs: number): StatusAdapter {
61
+ const unit = config.unit;
62
+ return {
63
+ id: config.id,
64
+ providerId: config.providerId,
65
+ name: config.name,
66
+ cacheTtlMs: 60_000,
67
+ requestTimeoutMs,
68
+ async fetch(context): Promise<StatusSnapshot> {
69
+ const key = await context.getApiKey();
70
+ if (!key || key === "proxy-managed") {
71
+ throw new ProviderDataError(`${config.name} status requires an API key`, "auth");
72
+ }
73
+ const response = await context.fetch(config.balanceUrl, {
74
+ headers: {
75
+ Accept: "application/json",
76
+ "Accept-Encoding": "identity",
77
+ Authorization: `Bearer ${key}`,
78
+ "User-Agent": "@hyav/pi-provider",
79
+ },
80
+ signal: context.signal,
81
+ });
82
+ if (!response.ok) {
83
+ throw new ProviderDataError(
84
+ `${config.name} status failed: HTTP ${response.status}`,
85
+ `http${response.status}`,
86
+ parseRetryAfter(response.headers.get("retry-after"), context.now()),
87
+ response.status,
88
+ );
89
+ }
90
+ let payload: unknown;
91
+ try {
92
+ payload = await response.json();
93
+ } catch {
94
+ throw new ProviderDataError(`${config.name} status returned invalid JSON`, "badjson");
95
+ }
96
+ const balance = parseMoonshotBalance(payload);
97
+ const entries: StatusEntry[] = [
98
+ {
99
+ kind: "amount",
100
+ id: "available-balance",
101
+ label: "Available balance",
102
+ value: balance.available,
103
+ unit,
104
+ },
105
+ ];
106
+ if (balance.voucher !== undefined) {
107
+ entries.push({
108
+ kind: "amount",
109
+ id: "voucher-balance",
110
+ label: "Voucher balance",
111
+ value: balance.voucher,
112
+ unit,
113
+ });
114
+ }
115
+ if (balance.cash !== undefined) {
116
+ entries.push({
117
+ kind: "amount",
118
+ id: "cash-balance",
119
+ label: "Cash balance",
120
+ value: balance.cash,
121
+ unit,
122
+ });
123
+ }
124
+ return { entries, updatedAt: context.now() };
125
+ },
126
+ };
127
+ }
128
+
129
+ export const moonshotaiStatusAdapter = createMoonshotStatusAdapter(
130
+ {
131
+ id: "moonshotai-status",
132
+ providerId: "moonshotai",
133
+ name: "Moonshot (Kimi)",
134
+ balanceUrl: MOONSHOT_BALANCE_URL,
135
+ unit: "USD",
136
+ },
137
+ 8_000,
138
+ );
139
+
140
+ export function createMoonshotaiStatusAdapter(requestTimeoutMs: number): StatusAdapter {
141
+ return { ...moonshotaiStatusAdapter, requestTimeoutMs };
142
+ }
143
+
144
+ const moonshotaiStatusExtension = defineStatusExtension({
145
+ id: "moonshotai-status",
146
+ providerId: "moonshotai",
147
+ create: ({ statusRequestTimeoutMs }) => createMoonshotaiStatusAdapter(statusRequestTimeoutMs),
148
+ });
149
+
150
+ export default moonshotaiStatusExtension;
@@ -1,7 +1,5 @@
1
- import { defineStatusExtension } from "../core/adapter-extensions.ts";
2
- import { ProviderDataError } from "../core/errors.ts";
3
- import { parseRetryAfter } from "../core/retry-after.ts";
4
- import type { StatusAdapter, StatusEntry, StatusSnapshot } from "../core/types.ts";
1
+ import type { StatusAdapter, StatusEntry, StatusSnapshot } from "@hyav/pi-provider";
2
+ import { defineStatusExtension, ProviderDataError, parseRetryAfter } from "@hyav/pi-provider";
5
3
 
6
4
  export const CODEX_USAGE_URL = "https://chatgpt.com/backend-api/wham/usage";
7
5
  const ACCOUNT_ID_CLAIM = "https://api.openai.com/auth";
@@ -1,7 +1,5 @@
1
- import { defineStatusExtension } from "../core/adapter-extensions.ts";
2
- import { ProviderDataError } from "../core/errors.ts";
3
- import { parseRetryAfter } from "../core/retry-after.ts";
4
- import type { StatusAdapter, StatusEntry, StatusSnapshot } from "../core/types.ts";
1
+ import type { StatusAdapter, StatusEntry, StatusSnapshot } from "@hyav/pi-provider";
2
+ import { defineStatusExtension, ProviderDataError, parseRetryAfter } from "@hyav/pi-provider";
5
3
 
6
4
  export const OPENCODE_GO_USAGE_URL = "https://opencode.ai/zen/go/v1/usage";
7
5
 
@@ -0,0 +1,172 @@
1
+ import type { StatusAdapter, StatusEntry, StatusSnapshot } from "@hyav/pi-provider";
2
+ import { defineStatusExtension, ProviderDataError, parseRetryAfter } from "@hyav/pi-provider";
3
+
4
+ export const OPENROUTER_KEY_URL = "https://openrouter.ai/api/v1/auth/key";
5
+ export const OPENROUTER_CREDITS_URL = "https://openrouter.ai/api/v1/credits";
6
+
7
+ function isRecord(value: unknown): value is Record<string, unknown> {
8
+ return value !== null && typeof value === "object" && !Array.isArray(value);
9
+ }
10
+
11
+ function safeNumber(value: unknown): number | undefined {
12
+ return typeof value === "number" && Number.isFinite(value) ? value : undefined;
13
+ }
14
+
15
+ function isErrorPayload(value: Record<string, unknown>): boolean {
16
+ return isRecord(value.error) && (typeof value.error.code === "number" || typeof value.error.message === "string");
17
+ }
18
+
19
+ interface OpenRouterKey {
20
+ label: string;
21
+ usage: number;
22
+ limit: number | null;
23
+ isFreeTier: boolean;
24
+ }
25
+
26
+ function parseKeyPayload(value: unknown): OpenRouterKey {
27
+ if (!isRecord(value) || !isRecord(value.data)) {
28
+ throw new ProviderDataError("OpenRouter status returned an invalid key response", "badjson");
29
+ }
30
+ const data = value.data;
31
+ const usage = safeNumber(data.usage);
32
+ if (
33
+ typeof data.label !== "string" ||
34
+ typeof data.is_free_tier !== "boolean" ||
35
+ usage === undefined ||
36
+ (data.limit !== null && safeNumber(data.limit) === undefined)
37
+ ) {
38
+ throw new ProviderDataError("OpenRouter status returned an invalid key response", "badjson");
39
+ }
40
+ return {
41
+ label: data.label.replace(/[\u0000-\u001f\u007f]/g, "").trim() || "API key",
42
+ usage,
43
+ limit: data.limit === null ? null : (safeNumber(data.limit) as number),
44
+ isFreeTier: data.is_free_tier,
45
+ };
46
+ }
47
+
48
+ async function readJson(response: Response, providerName: string): Promise<unknown> {
49
+ let payload: unknown;
50
+ try {
51
+ payload = await response.json();
52
+ } catch {
53
+ throw new ProviderDataError(`${providerName} status returned invalid JSON`, "badjson");
54
+ }
55
+ return payload;
56
+ }
57
+
58
+ async function fetchWithAuth(
59
+ context: Parameters<StatusAdapter["fetch"]>[0],
60
+ key: string,
61
+ url: string,
62
+ providerName: string,
63
+ ): Promise<{ response: Response; payload: unknown }> {
64
+ const response = await context.fetch(url, {
65
+ headers: {
66
+ Accept: "application/json",
67
+ "Accept-Encoding": "identity",
68
+ Authorization: `Bearer ${key}`,
69
+ "User-Agent": "@hyav/pi-provider",
70
+ },
71
+ signal: context.signal,
72
+ });
73
+ if (!response.ok) {
74
+ throw new ProviderDataError(
75
+ `${providerName} status failed: HTTP ${response.status}`,
76
+ `http${response.status}`,
77
+ parseRetryAfter(response.headers.get("retry-after"), context.now()),
78
+ response.status,
79
+ );
80
+ }
81
+ return { response, payload: await readJson(response, providerName) };
82
+ }
83
+
84
+ function keyEntries(
85
+ key: OpenRouterKey,
86
+ limitEntry: StatusEntry | undefined,
87
+ freeTierEntry: StatusEntry,
88
+ ): StatusEntry[] {
89
+ const usageEntry: StatusEntry = {
90
+ kind: "amount",
91
+ id: "credits-used",
92
+ label: "Credits used",
93
+ value: key.usage,
94
+ unit: "USD",
95
+ };
96
+ const entries: StatusEntry[] = [{ kind: "text", id: "key", label: "Key", value: key.label }, usageEntry];
97
+ if (limitEntry) entries.push(limitEntry);
98
+ entries.push(freeTierEntry);
99
+ return entries;
100
+ }
101
+
102
+ function freeTierEntry(value: boolean): StatusEntry {
103
+ return { kind: "text", id: "account-tier", label: "Account", value: value ? "Free tier" : "Paid" };
104
+ }
105
+
106
+ export const openRouterStatusAdapter: StatusAdapter = {
107
+ id: "openrouter-status",
108
+ providerId: "openrouter",
109
+ name: "OpenRouter",
110
+ cacheTtlMs: 60_000,
111
+ requestTimeoutMs: 8_000,
112
+ async fetch(context): Promise<StatusSnapshot> {
113
+ const key = await context.getApiKey();
114
+ if (!key || key === "proxy-managed") {
115
+ throw new ProviderDataError("OpenRouter status requires an API key", "auth");
116
+ }
117
+ const keyResult = await fetchWithAuth(context, key, OPENROUTER_KEY_URL, "OpenRouter");
118
+ const keyPayload = keyResult.payload;
119
+ if (isRecord(keyPayload) && isErrorPayload(keyPayload)) {
120
+ throw new ProviderDataError(
121
+ "OpenRouter status failed: invalid API key response",
122
+ "auth",
123
+ undefined,
124
+ keyResult.response.status,
125
+ );
126
+ }
127
+ const openRouterKey = parseKeyPayload(keyPayload);
128
+
129
+ // /credits requires a management key; only show the limit when resolved.
130
+ let limitEntry: StatusEntry | undefined;
131
+ try {
132
+ const creditsResult = await fetchWithAuth(context, key, OPENROUTER_CREDITS_URL, "OpenRouter");
133
+ const payload = creditsResult.payload;
134
+ if (!isRecord(payload) || !isRecord(payload.data)) {
135
+ throw new ProviderDataError("OpenRouter status returned an invalid credits response", "badjson");
136
+ }
137
+ const totalCredits = safeNumber(payload.data.total_credits);
138
+ const totalUsage = safeNumber(payload.data.total_usage);
139
+ if (totalCredits === undefined || totalUsage === undefined) {
140
+ throw new ProviderDataError("OpenRouter status returned an invalid credits response", "badjson");
141
+ }
142
+ const remaining = Math.max(0, totalCredits - totalUsage);
143
+ limitEntry = {
144
+ kind: "amount",
145
+ id: "credits-remaining",
146
+ label: "Credits remaining",
147
+ value: remaining,
148
+ unit: "USD",
149
+ };
150
+ } catch (error) {
151
+ // Safe fallback: key credits, free-tier, and key-level limit still display.
152
+ if (!(error instanceof ProviderDataError)) throw error;
153
+ }
154
+
155
+ return {
156
+ entries: keyEntries(openRouterKey, limitEntry, freeTierEntry(openRouterKey.isFreeTier)),
157
+ updatedAt: context.now(),
158
+ };
159
+ },
160
+ };
161
+
162
+ export function createOpenRouterStatusAdapter(requestTimeoutMs: number): StatusAdapter {
163
+ return { ...openRouterStatusAdapter, requestTimeoutMs };
164
+ }
165
+
166
+ const openRouterStatusExtension = defineStatusExtension({
167
+ id: "openrouter-status",
168
+ providerId: "openrouter",
169
+ create: ({ statusRequestTimeoutMs }) => createOpenRouterStatusAdapter(statusRequestTimeoutMs),
170
+ });
171
+
172
+ export default openRouterStatusExtension;
@@ -0,0 +1,3 @@
1
+ /** Shared identity constants for Vercel AI Gateway adapters. */
2
+
3
+ export const VERCEL_PROVIDER_ID = "vercel-ai-gateway";
@@ -0,0 +1,94 @@
1
+ import type { StatusAdapter, StatusSnapshot } from "@hyav/pi-provider";
2
+ import { defineStatusExtension, ProviderDataError, parseRetryAfter } from "@hyav/pi-provider";
3
+ import { VERCEL_PROVIDER_ID } from "./vercel-ai-gateway/constants.ts";
4
+
5
+ export const VERCEL_CREDITS_URL = "https://ai-gateway.vercel.sh/v1/credits";
6
+
7
+ interface VercelCredits {
8
+ balance: number;
9
+ totalUsed: number;
10
+ }
11
+
12
+ function isRecord(value: unknown): value is Record<string, unknown> {
13
+ return value !== null && typeof value === "object" && !Array.isArray(value);
14
+ }
15
+
16
+ function parseFiniteAmount(value: unknown): number | undefined {
17
+ if (typeof value === "number") return Number.isFinite(value) ? value : undefined;
18
+ if (typeof value !== "string" || value.trim() === "") return undefined;
19
+ const parsed = Number(value);
20
+ return Number.isFinite(parsed) ? parsed : undefined;
21
+ }
22
+
23
+ export function parseVercelCredits(payload: unknown): VercelCredits {
24
+ if (!isRecord(payload)) {
25
+ throw new ProviderDataError("Vercel AI Gateway status returned an invalid credits response", "badjson");
26
+ }
27
+
28
+ const balance = parseFiniteAmount(payload.balance);
29
+ const totalUsed = parseFiniteAmount(payload.total_used);
30
+ if (balance === undefined || totalUsed === undefined) {
31
+ throw new ProviderDataError("Vercel AI Gateway status returned an invalid credits response", "badjson");
32
+ }
33
+
34
+ return { balance, totalUsed };
35
+ }
36
+
37
+ export function createVercelAIGatewayStatusAdapter(requestTimeoutMs: number): StatusAdapter {
38
+ return {
39
+ id: "vercel-ai-gateway-status",
40
+ providerId: VERCEL_PROVIDER_ID,
41
+ name: "Vercel AI Gateway",
42
+ cacheTtlMs: 30_000,
43
+ requestTimeoutMs,
44
+ async fetch(context): Promise<StatusSnapshot> {
45
+ const key = await context.getApiKey();
46
+ if (!key || key === "proxy-managed") {
47
+ throw new ProviderDataError("Vercel AI Gateway status requires an API key", "auth");
48
+ }
49
+
50
+ const response = await context.fetch(VERCEL_CREDITS_URL, {
51
+ headers: {
52
+ Accept: "application/json",
53
+ "Accept-Encoding": "identity",
54
+ Authorization: `Bearer ${key}`,
55
+ },
56
+ signal: context.signal,
57
+ });
58
+ if (!response.ok) {
59
+ throw new ProviderDataError(
60
+ `Vercel AI Gateway status failed: HTTP ${response.status}`,
61
+ response.status === 401 ? "auth" : `http${response.status}`,
62
+ parseRetryAfter(response.headers.get("retry-after"), context.now()),
63
+ response.status,
64
+ );
65
+ }
66
+
67
+ let payload: unknown;
68
+ try {
69
+ payload = await response.json();
70
+ } catch {
71
+ throw new ProviderDataError("Vercel AI Gateway status returned invalid JSON", "badjson");
72
+ }
73
+
74
+ const credits = parseVercelCredits(payload);
75
+ return {
76
+ entries: [
77
+ { kind: "amount", id: "balance", label: "Balance", value: credits.balance, unit: "USD" },
78
+ { kind: "amount", id: "total-used", label: "Total Used", value: credits.totalUsed, unit: "USD" },
79
+ ],
80
+ updatedAt: context.now(),
81
+ };
82
+ },
83
+ };
84
+ }
85
+
86
+ export const vercelAIGatewayStatusAdapter = createVercelAIGatewayStatusAdapter(8_000);
87
+
88
+ const vercelAIGatewayStatusExtension = defineStatusExtension({
89
+ id: "vercel-ai-gateway-status",
90
+ providerId: VERCEL_PROVIDER_ID,
91
+ create: ({ statusRequestTimeoutMs }) => createVercelAIGatewayStatusAdapter(statusRequestTimeoutMs),
92
+ });
93
+
94
+ export default vercelAIGatewayStatusExtension;
package/status/xai.ts ADDED
@@ -0,0 +1,73 @@
1
+ import type { StatusAdapter, StatusEntry, StatusSnapshot } from "@hyav/pi-provider";
2
+ import { defineStatusExtension, ProviderDataError, parseRetryAfter } from "@hyav/pi-provider";
3
+ import { parseRateLimitWindows } from "../core/ratelimit-headers.ts";
4
+
5
+ export const XAI_MODELS_URL = "https://api.x.ai/v1/models";
6
+
7
+ function windowEntry(id: string, label: string, limit: number, remaining: number, resetAt?: number): StatusEntry {
8
+ const percent = (remaining / limit) * 100;
9
+ return {
10
+ kind: "window",
11
+ id,
12
+ label,
13
+ remainingPercent: Math.max(0, Math.min(100, percent)),
14
+ ...(resetAt !== undefined ? { resetAt } : {}),
15
+ };
16
+ }
17
+
18
+ export const xaiStatusAdapter: StatusAdapter = {
19
+ id: "xai-status",
20
+ providerId: "xai",
21
+ name: "xAI",
22
+ cacheTtlMs: 60_000,
23
+ requestTimeoutMs: 8_000,
24
+ async fetch(context): Promise<StatusSnapshot> {
25
+ const key = await context.getApiKey();
26
+ if (!key || key === "proxy-managed") {
27
+ throw new ProviderDataError("xAI status requires Grok OAuth or an API key", "auth");
28
+ }
29
+ const response = await context.fetch(XAI_MODELS_URL, {
30
+ headers: {
31
+ Accept: "application/json",
32
+ "Accept-Encoding": "identity",
33
+ Authorization: `Bearer ${key}`,
34
+ "User-Agent": "@hyav/pi-provider",
35
+ },
36
+ signal: context.signal,
37
+ });
38
+ if (!response.ok) {
39
+ throw new ProviderDataError(
40
+ `xAI status failed: HTTP ${response.status}`,
41
+ `http${response.status}`,
42
+ parseRetryAfter(response.headers.get("retry-after"), context.now()),
43
+ response.status,
44
+ );
45
+ }
46
+
47
+ const now = context.now();
48
+ const { requests, tokens } = parseRateLimitWindows(response.headers, now);
49
+ const entries: StatusEntry[] = [];
50
+ if (requests) {
51
+ entries.push(windowEntry("requests-window", "Requests", requests.limit, requests.remaining, requests.resetAt));
52
+ }
53
+ if (tokens) {
54
+ entries.push(windowEntry("tokens-window", "Tokens", tokens.limit, tokens.remaining, tokens.resetAt));
55
+ }
56
+ if (entries.length === 0) {
57
+ entries.push({ kind: "text", id: "limits", label: "Limits", value: "not available" });
58
+ }
59
+ return { entries, updatedAt: now };
60
+ },
61
+ };
62
+
63
+ export function createXaiStatusAdapter(requestTimeoutMs: number): StatusAdapter {
64
+ return { ...xaiStatusAdapter, requestTimeoutMs };
65
+ }
66
+
67
+ const xaiStatusExtension = defineStatusExtension({
68
+ id: "xai-status",
69
+ providerId: "xai",
70
+ create: ({ statusRequestTimeoutMs }) => createXaiStatusAdapter(statusRequestTimeoutMs),
71
+ });
72
+
73
+ export default xaiStatusExtension;