agent-afk 5.115.4 → 5.117.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/agent/auth/credential-resolver.d.ts +4 -1
- package/dist/agent/auth/model-availability.d.ts +1 -1
- package/dist/agent/providers/index.d.ts +2 -1
- package/dist/agent/providers/openai-compatible/index.d.ts +6 -0
- package/dist/agent/providers/openai-compatible/oneshot.d.ts +2 -0
- package/dist/agent/providers/openai-compatible/query.d.ts +2 -0
- package/dist/agent/providers/xai/auth-store.d.ts +22 -0
- package/dist/agent/providers/xai/auth.d.ts +26 -0
- package/dist/agent/providers/xai/endpoints.d.ts +15 -0
- package/dist/agent/providers/xai/force-mode.d.ts +4 -0
- package/dist/agent/providers/xai/headers.d.ts +7 -0
- package/dist/agent/providers/xai/index.d.ts +38 -0
- package/dist/agent/providers/xai/oauth-constants.d.ts +10 -0
- package/dist/agent/providers/xai/oauth-device.d.ts +32 -0
- package/dist/agent/providers/xai/oauth-http.d.ts +20 -0
- package/dist/agent/providers/xai/oauth-pkce.d.ts +23 -0
- package/dist/agent/providers/xai/oauth.d.ts +14 -0
- package/dist/agent/providers/xai/pricing.d.ts +8 -0
- package/dist/agent/providers/xai/query-bootstrap.d.ts +11 -0
- package/dist/agent/providers/xai/query-helpers.d.ts +5 -0
- package/dist/agent/session/model-slots.d.ts +1 -1
- package/dist/agent/session/slot-credentials.d.ts +3 -0
- package/dist/agent/tools/child-credential.d.ts +1 -0
- package/dist/agent/types/config-types.d.ts +3 -0
- package/dist/cli/commands/doctor-checks.d.ts +1 -0
- package/dist/cli/commands/interactive/bootstrap-session-builder.d.ts +2 -0
- package/dist/cli/commands/provider-xai-login.d.ts +16 -0
- package/dist/cli/commands/provider.d.ts +8 -0
- package/dist/cli/shared-helpers.d.ts +3 -1
- package/dist/cli.mjs +625 -624
- package/dist/config/env.d.ts +3 -0
- package/dist/index.mjs +208 -207
- package/dist/telegram/credentials.d.ts +7 -0
- package/dist/telegram/handlers/commands.model-validate.d.ts +2 -0
- package/dist/telegram/push.d.ts +1 -0
- package/dist/telegram/session-xai.d.ts +5 -0
- package/dist/telegram.mjs +293 -292
- package/package.json +1 -1
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { type ProviderRouteHints } from '../providers/index.js';
|
|
1
2
|
export declare function loadAnthropicCredential(): string | undefined;
|
|
2
3
|
export declare function loadOpenAICredential(): string | undefined;
|
|
3
|
-
export declare function
|
|
4
|
+
export declare function loadXaiApiKey(): string | undefined;
|
|
5
|
+
export declare function loadXaiCredential(): string | undefined;
|
|
6
|
+
export declare function resolveCredentialForModel(model: string | undefined, hints?: ProviderRouteHints): string | undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ModelSlots } from '../session/model-slots.js';
|
|
2
|
-
export type AvailabilityNeed = 'anthropic' | 'openai' | 'chatgpt-oauth' | 'local' | 'unknown';
|
|
2
|
+
export type AvailabilityNeed = 'anthropic' | 'openai' | 'chatgpt-oauth' | 'xai' | 'xai-oauth' | 'local' | 'unknown';
|
|
3
3
|
export interface ModelAvailability {
|
|
4
4
|
available: boolean;
|
|
5
5
|
needs: AvailabilityNeed;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ModelProvider } from '../provider.js';
|
|
2
2
|
import { anthropicDirectProvider } from './anthropic-direct/index.js';
|
|
3
3
|
import { type ModelSlots } from '../session/model-slots.js';
|
|
4
|
-
export type BundledProviderName = 'anthropic' | 'anthropic-direct' | 'openai-compatible' | 'openai-codex';
|
|
4
|
+
export type BundledProviderName = 'anthropic' | 'anthropic-direct' | 'openai-compatible' | 'openai-codex' | 'xai' | 'xai-oauth';
|
|
5
5
|
export interface ProviderRouteHints {
|
|
6
6
|
explicit?: string;
|
|
7
7
|
openaiBaseUrl?: string;
|
|
@@ -15,3 +15,4 @@ export declare function resolveProvider(model: string | undefined, hints?: Provi
|
|
|
15
15
|
export { anthropicDirectProvider };
|
|
16
16
|
export { AnthropicDirectProvider } from './anthropic-direct/index.js';
|
|
17
17
|
export { OpenAICompatibleProvider, openaiCompatibleProvider } from './openai-compatible/index.js';
|
|
18
|
+
export { XaiProvider } from './xai/index.js';
|
|
@@ -9,6 +9,7 @@ import type { ToolDispatcher } from '../anthropic-direct/tool-dispatcher.js';
|
|
|
9
9
|
import { MemoryStore } from '../../memory/index.js';
|
|
10
10
|
export interface OpenAICompatibleProviderOptions {
|
|
11
11
|
baseURL?: string;
|
|
12
|
+
defaultHeaders?: Record<string, string>;
|
|
12
13
|
hookRegistry?: HookRegistry;
|
|
13
14
|
permissions?: ToolPermissionConfig;
|
|
14
15
|
canUseTool?: CanUseTool;
|
|
@@ -28,6 +29,7 @@ export declare class OpenAICompatibleProvider implements ModelProvider {
|
|
|
28
29
|
private readonly providerOpts;
|
|
29
30
|
private readonly memoryStore;
|
|
30
31
|
private readonly schemas;
|
|
32
|
+
private _defaultHeaders;
|
|
31
33
|
private _sharedReadRoots;
|
|
32
34
|
private _sharedWriteRoots;
|
|
33
35
|
private _currentPermissionMode;
|
|
@@ -35,6 +37,10 @@ export declare class OpenAICompatibleProvider implements ModelProvider {
|
|
|
35
37
|
private _presenceSessionId;
|
|
36
38
|
private _mintedSessionId;
|
|
37
39
|
constructor(opts?: OpenAICompatibleProviderOptions);
|
|
40
|
+
setEndpointDefaults(defaults: {
|
|
41
|
+
baseURL?: string;
|
|
42
|
+
defaultHeaders?: Record<string, string>;
|
|
43
|
+
}): void;
|
|
38
44
|
query(args: ProviderQueryArgs): ProviderQuery;
|
|
39
45
|
private buildDispatcher;
|
|
40
46
|
private ensureSharedRoots;
|
|
@@ -6,11 +6,13 @@ export declare class ResponsesSummaryIncompleteError extends Error {
|
|
|
6
6
|
export type OneShotOpenAIClientFactory = (opts: {
|
|
7
7
|
apiKey: string;
|
|
8
8
|
baseURL?: string;
|
|
9
|
+
defaultHeaders?: Record<string, string>;
|
|
9
10
|
}) => OpenAI;
|
|
10
11
|
export declare function __setOpenAIOneShotClientFactory(factory: OneShotOpenAIClientFactory | null): void;
|
|
11
12
|
export interface OpenAIOneShotInput {
|
|
12
13
|
apiKey?: string;
|
|
13
14
|
baseURL?: string;
|
|
15
|
+
defaultHeaders?: Record<string, string>;
|
|
14
16
|
model: string;
|
|
15
17
|
system: string;
|
|
16
18
|
user: string;
|
|
@@ -12,6 +12,7 @@ export { resolveReasoningEffort };
|
|
|
12
12
|
export interface OpenAICompatibleQueryOptions {
|
|
13
13
|
auth: OpenAIAuthResolution;
|
|
14
14
|
baseURL?: string;
|
|
15
|
+
defaultHeaders?: Record<string, string>;
|
|
15
16
|
model: string;
|
|
16
17
|
synthesizedSessionId: string;
|
|
17
18
|
promptStream: AsyncIterable<ProviderUserTurn>;
|
|
@@ -71,6 +72,7 @@ export declare class OpenAICompatibleQuery implements ProviderQuery {
|
|
|
71
72
|
}
|
|
72
73
|
export declare function buildQueryFromConfig(config: AgentConfig, promptStream: AsyncIterable<ProviderUserTurn>, options?: {
|
|
73
74
|
baseURL?: string;
|
|
75
|
+
defaultHeaders?: Record<string, string>;
|
|
74
76
|
toolDispatcher?: ToolDispatcher;
|
|
75
77
|
onPermissionMode?: (mode: string) => void;
|
|
76
78
|
onCwdChange?: (cwd: string) => void;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export declare function getXaiAuthPath(): string;
|
|
2
|
+
export interface XaiTokenBundle {
|
|
3
|
+
access_token: string;
|
|
4
|
+
refresh_token: string;
|
|
5
|
+
expires_at: number;
|
|
6
|
+
token_type?: string;
|
|
7
|
+
scope?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface XaiAuthStoreDeps {
|
|
10
|
+
authPath?: () => string;
|
|
11
|
+
readFile?: (path: string) => string | null;
|
|
12
|
+
writeFile?: (path: string, data: string, mode: number) => void;
|
|
13
|
+
chmod?: (path: string, mode: number) => void;
|
|
14
|
+
mkdir?: (dir: string) => void;
|
|
15
|
+
unlink?: (path: string) => void;
|
|
16
|
+
exists?: (path: string) => boolean;
|
|
17
|
+
}
|
|
18
|
+
export declare function parseXaiTokenBundle(raw: string): XaiTokenBundle | null;
|
|
19
|
+
export declare function readXaiTokens(deps?: XaiAuthStoreDeps): XaiTokenBundle | null;
|
|
20
|
+
export declare function writeXaiTokens(bundle: XaiTokenBundle, deps?: XaiAuthStoreDeps): void;
|
|
21
|
+
export declare function clearXaiTokens(deps?: XaiAuthStoreDeps): void;
|
|
22
|
+
export declare function last4OfToken(token: string): string;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type XaiAuthStoreDeps } from './auth-store.js';
|
|
2
|
+
import type { XaiAuthMode } from './endpoints.js';
|
|
3
|
+
export type XaiAuthSource = 'config' | 'env' | 'xai-oauth' | 'no-usable-auth' | 'no-usable-auth-forced-xai-oauth' | 'no-usable-auth-forced-xai-apikey' | 'ambiguous-auth';
|
|
4
|
+
export interface XaiAuthResolution {
|
|
5
|
+
apiKey: string | null;
|
|
6
|
+
source: XaiAuthSource;
|
|
7
|
+
mode?: XaiAuthMode;
|
|
8
|
+
last4?: string;
|
|
9
|
+
expiresAt?: number;
|
|
10
|
+
envVar?: 'XAI_API_KEY';
|
|
11
|
+
}
|
|
12
|
+
export interface XaiAuthResolverDeps {
|
|
13
|
+
readEnv?: (key: string) => string | undefined;
|
|
14
|
+
store?: XaiAuthStoreDeps;
|
|
15
|
+
nowSeconds?: () => number;
|
|
16
|
+
}
|
|
17
|
+
export type XaiAuthForceMode = 'apikey' | 'oauth' | undefined;
|
|
18
|
+
export declare function resolveXaiAuth(explicitConfigKey: string | undefined, forceMode?: XaiAuthForceMode, deps?: XaiAuthResolverDeps): XaiAuthResolution;
|
|
19
|
+
export declare function formatXaiAuthDiagnostic(resolution: XaiAuthResolution, deps?: {
|
|
20
|
+
nowSeconds?: () => number;
|
|
21
|
+
}): string;
|
|
22
|
+
export declare function formatXaiHttpAuthError(status: number, opts: {
|
|
23
|
+
mode: XaiAuthMode;
|
|
24
|
+
baseURL?: string;
|
|
25
|
+
bodySnippet?: string;
|
|
26
|
+
}): string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type XaiAuthMode = 'apikey' | 'oauth';
|
|
2
|
+
export declare const DEFAULT_XAI_API_BASE_URL = "https://api.x.ai/v1";
|
|
3
|
+
export declare const DEFAULT_XAI_OAUTH_BASE_URL = "https://cli-chat-proxy.grok.com/v1";
|
|
4
|
+
export interface XaiEndpointResolution {
|
|
5
|
+
baseURL: string;
|
|
6
|
+
defaultHeaders: Record<string, string>;
|
|
7
|
+
mode: XaiAuthMode;
|
|
8
|
+
proxyHeadersApplied: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface XaiEndpointDeps {
|
|
11
|
+
readEnv?: (key: string) => string | undefined;
|
|
12
|
+
clientVersion?: string;
|
|
13
|
+
baseUrlOverride?: string;
|
|
14
|
+
}
|
|
15
|
+
export declare function resolveXaiEndpoint(mode: XaiAuthMode, deps?: XaiEndpointDeps): XaiEndpointResolution;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { XaiAuthForceMode } from './auth.js';
|
|
2
|
+
export declare function resolveXaiForceMode(constructionMode: XaiAuthForceMode, forceXaiOAuth: boolean | undefined, forceXaiApiKey?: boolean | undefined): XaiAuthForceMode;
|
|
3
|
+
export declare function resolveCompleteForceMode(constructionMode: XaiAuthForceMode, lastResolvedMode: 'apikey' | 'oauth' | undefined): XaiAuthForceMode;
|
|
4
|
+
export declare function resolveXaiConstructionAuthMode(effective: 'xai' | 'xai-oauth', wasExplicitProvider: boolean): XaiAuthForceMode;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const CLI_CHAT_PROXY_HOST = "cli-chat-proxy.grok.com";
|
|
2
|
+
export interface GrokCliHeaderOptions {
|
|
3
|
+
clientVersion?: string;
|
|
4
|
+
clientIdentifier?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function isCliChatProxyBaseUrl(baseURL: string): boolean;
|
|
7
|
+
export declare function resolveGrokCliIdentityHeaders(opts?: GrokCliHeaderOptions): Record<string, string>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { ModelProvider, ProviderQuery, ProviderQueryArgs, ProviderCompleteArgs } from '../../provider.js';
|
|
2
|
+
import type { OpenAICompatibleProviderOptions } from '../openai-compatible/index.js';
|
|
3
|
+
import { type XaiAuthForceMode, type XaiAuthResolverDeps } from './auth.js';
|
|
4
|
+
export { resolveXaiForceMode, resolveCompleteForceMode } from './force-mode.js';
|
|
5
|
+
export interface XaiProviderOptions extends OpenAICompatibleProviderOptions {
|
|
6
|
+
authMode?: XaiAuthForceMode;
|
|
7
|
+
authDeps?: XaiAuthResolverDeps;
|
|
8
|
+
}
|
|
9
|
+
export declare class XaiProvider implements ModelProvider {
|
|
10
|
+
readonly name = "xai";
|
|
11
|
+
private readonly inner;
|
|
12
|
+
private readonly authMode;
|
|
13
|
+
private readonly authDeps;
|
|
14
|
+
private lastMode;
|
|
15
|
+
private lastResolvedMode;
|
|
16
|
+
private lastXaiBaseUrl;
|
|
17
|
+
constructor(opts?: XaiProviderOptions);
|
|
18
|
+
query(args: ProviderQueryArgs): ProviderQuery;
|
|
19
|
+
private querySync;
|
|
20
|
+
private delegateToInner;
|
|
21
|
+
private rememberResolved;
|
|
22
|
+
addReadRoot(absPath: string, source?: 'slash' | 'tool', sessionId?: string): void;
|
|
23
|
+
addWriteRoot(absPath: string, source?: 'slash' | 'tool', sessionId?: string): void;
|
|
24
|
+
revokeRoot(absPath: string, source?: 'slash' | 'tool', sessionId?: string): void;
|
|
25
|
+
getGrants(): {
|
|
26
|
+
resolveBase: string | undefined;
|
|
27
|
+
readRoots: string[];
|
|
28
|
+
writeRoots: string[];
|
|
29
|
+
allowAll: boolean;
|
|
30
|
+
};
|
|
31
|
+
close(): void;
|
|
32
|
+
complete(args: ProviderCompleteArgs): Promise<string>;
|
|
33
|
+
}
|
|
34
|
+
export { resolveXaiAuth, formatXaiAuthDiagnostic, formatXaiHttpAuthError, type XaiAuthResolution, type XaiAuthSource, } from './auth.js';
|
|
35
|
+
export { resolveXaiEndpoint, DEFAULT_XAI_API_BASE_URL, DEFAULT_XAI_OAUTH_BASE_URL, type XaiAuthMode, } from './endpoints.js';
|
|
36
|
+
export { readXaiTokens, writeXaiTokens, clearXaiTokens, getXaiAuthPath, } from './auth-store.js';
|
|
37
|
+
export { startDeviceCodeFlow, pollDeviceCodeToken, buildPkceAuthorizeUrl, exchangeAuthorizationCode, generateCodeVerifier, generateOAuthState, refreshXaiTokens, ensureFreshAccessToken, discoverXaiOidc, } from './oauth.js';
|
|
38
|
+
export { deriveXaiCallCostUsd, isGrokModelId, XAI_MODEL_PRICING, } from './pricing.js';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const XAI_OAUTH_ISSUER = "https://auth.x.ai";
|
|
2
|
+
export declare const XAI_OAUTH_CLIENT_ID = "b1a00492-073a-47ea-816f-4c329264a828";
|
|
3
|
+
export declare const XAI_OAUTH_SCOPES_BASE = "openid profile email offline_access grok-cli:access api:access";
|
|
4
|
+
export declare const XAI_OAUTH_SCOPES_EXTENDED = "openid profile email offline_access grok-cli:access api:access conversations:read conversations:write";
|
|
5
|
+
export declare const XAI_OAUTH_SCOPES = "openid profile email offline_access grok-cli:access api:access";
|
|
6
|
+
export declare const XAI_OAUTH_LOOPBACK_PORT = 56121;
|
|
7
|
+
export declare const XAI_OAUTH_REDIRECT_URI = "http://127.0.0.1:56121/callback";
|
|
8
|
+
export declare const XAI_OAUTH_AUTHORIZE_PLAN = "generic";
|
|
9
|
+
export declare const XAI_OAUTH_AUTHORIZE_REFERRER = "https://grok.com";
|
|
10
|
+
export declare const XAI_REFRESH_SKEW_SECONDS: number;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { XaiTokenBundle } from './auth-store.js';
|
|
2
|
+
import { type OAuthHttpDeps, type XaiOidcDiscovery } from './oauth-http.js';
|
|
3
|
+
export interface DeviceCodeStart {
|
|
4
|
+
device_code: string;
|
|
5
|
+
user_code: string;
|
|
6
|
+
verification_uri: string;
|
|
7
|
+
verification_uri_complete?: string;
|
|
8
|
+
expires_in: number;
|
|
9
|
+
interval: number;
|
|
10
|
+
}
|
|
11
|
+
export type DevicePollResult = {
|
|
12
|
+
status: 'pending';
|
|
13
|
+
} | {
|
|
14
|
+
status: 'slow_down';
|
|
15
|
+
interval: number;
|
|
16
|
+
} | {
|
|
17
|
+
status: 'expired';
|
|
18
|
+
} | {
|
|
19
|
+
status: 'denied';
|
|
20
|
+
} | {
|
|
21
|
+
status: 'success';
|
|
22
|
+
tokens: XaiTokenBundle;
|
|
23
|
+
} | {
|
|
24
|
+
status: 'error';
|
|
25
|
+
message: string;
|
|
26
|
+
};
|
|
27
|
+
export declare function positiveSeconds(value: unknown, defaultSeconds: number): number;
|
|
28
|
+
export declare function startDeviceCodeFlow(deps?: OAuthHttpDeps): Promise<{
|
|
29
|
+
discovery: XaiOidcDiscovery;
|
|
30
|
+
device: DeviceCodeStart;
|
|
31
|
+
}>;
|
|
32
|
+
export declare function pollDeviceCodeToken(discovery: XaiOidcDiscovery, deviceCode: string, deps?: OAuthHttpDeps): Promise<DevicePollResult>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { XaiTokenBundle } from './auth-store.js';
|
|
2
|
+
export type FetchFn = typeof fetch;
|
|
3
|
+
export interface XaiOidcDiscovery {
|
|
4
|
+
issuer: string;
|
|
5
|
+
authorization_endpoint: string;
|
|
6
|
+
token_endpoint: string;
|
|
7
|
+
device_authorization_endpoint?: string;
|
|
8
|
+
userinfo_endpoint?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface OAuthHttpDeps {
|
|
11
|
+
fetchFn?: FetchFn;
|
|
12
|
+
issuer?: string;
|
|
13
|
+
clientId?: string;
|
|
14
|
+
scopes?: string;
|
|
15
|
+
nowSeconds?: () => number;
|
|
16
|
+
}
|
|
17
|
+
export declare function asNonEmptyString(v: unknown): string | undefined;
|
|
18
|
+
export declare function safeText(res: Response): Promise<string>;
|
|
19
|
+
export declare function discoverXaiOidc(deps?: OAuthHttpDeps): Promise<XaiOidcDiscovery>;
|
|
20
|
+
export declare function tokenResponseToBundle(json: Record<string, unknown>, nowSeconds?: () => number, fallbackRefresh?: string): XaiTokenBundle | null;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { XaiTokenBundle } from './auth-store.js';
|
|
2
|
+
import { type OAuthHttpDeps, type XaiOidcDiscovery } from './oauth-http.js';
|
|
3
|
+
export interface PkceAuthorizeParams {
|
|
4
|
+
authorizationUrl: string;
|
|
5
|
+
codeVerifier: string;
|
|
6
|
+
state: string;
|
|
7
|
+
redirectUri: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function generateCodeVerifier(): string;
|
|
10
|
+
export declare function codeChallengeS256(verifier: string): string;
|
|
11
|
+
export declare function generateOAuthState(): string;
|
|
12
|
+
export declare function buildPkceAuthorizeUrl(discovery: XaiOidcDiscovery, opts: {
|
|
13
|
+
codeVerifier: string;
|
|
14
|
+
state: string;
|
|
15
|
+
redirectUri?: string;
|
|
16
|
+
clientId?: string;
|
|
17
|
+
scopes?: string;
|
|
18
|
+
}): PkceAuthorizeParams;
|
|
19
|
+
export declare function exchangeAuthorizationCode(discovery: XaiOidcDiscovery, params: {
|
|
20
|
+
code: string;
|
|
21
|
+
codeVerifier: string;
|
|
22
|
+
redirectUri?: string;
|
|
23
|
+
}, deps?: OAuthHttpDeps): Promise<XaiTokenBundle>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type XaiAuthStoreDeps, type XaiTokenBundle } from './auth-store.js';
|
|
2
|
+
import { type OAuthHttpDeps } from './oauth-http.js';
|
|
3
|
+
export type { FetchFn, OAuthHttpDeps, XaiOidcDiscovery } from './oauth-http.js';
|
|
4
|
+
export { discoverXaiOidc, tokenResponseToBundle } from './oauth-http.js';
|
|
5
|
+
export { startDeviceCodeFlow, pollDeviceCodeToken, type DeviceCodeStart, type DevicePollResult, } from './oauth-device.js';
|
|
6
|
+
export { buildPkceAuthorizeUrl, codeChallengeS256, exchangeAuthorizationCode, generateCodeVerifier, generateOAuthState, type PkceAuthorizeParams, } from './oauth-pkce.js';
|
|
7
|
+
export declare function refreshXaiTokens(refreshToken: string, deps?: OAuthHttpDeps & {
|
|
8
|
+
store?: XaiAuthStoreDeps;
|
|
9
|
+
persist?: boolean;
|
|
10
|
+
}): Promise<XaiTokenBundle>;
|
|
11
|
+
export declare function ensureFreshAccessToken(deps?: OAuthHttpDeps & {
|
|
12
|
+
store?: XaiAuthStoreDeps;
|
|
13
|
+
skewSeconds?: number;
|
|
14
|
+
}): Promise<XaiTokenBundle | null>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface XaiModelPricing {
|
|
2
|
+
inputPerMTok: number;
|
|
3
|
+
outputPerMTok: number;
|
|
4
|
+
cachedInputPerMTok?: number;
|
|
5
|
+
}
|
|
6
|
+
export declare const XAI_MODEL_PRICING: ReadonlyMap<string, XaiModelPricing>;
|
|
7
|
+
export declare function isGrokModelId(model: string): boolean;
|
|
8
|
+
export declare function deriveXaiCallCostUsd(model: string, inputTokens: number, outputTokens: number, cachedInputTokens?: number): number | undefined;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ProviderQuery, ProviderQueryArgs } from '../../provider.js';
|
|
2
|
+
import { type XaiAuthForceMode, type XaiAuthResolverDeps } from './auth.js';
|
|
3
|
+
import type { XaiAuthMode } from './endpoints.js';
|
|
4
|
+
export interface XaiQueryBootstrapArgs {
|
|
5
|
+
args: ProviderQueryArgs;
|
|
6
|
+
forceMode: XaiAuthForceMode;
|
|
7
|
+
authDeps: XaiAuthResolverDeps;
|
|
8
|
+
getLastMode: () => XaiAuthMode;
|
|
9
|
+
delegate: (args: ProviderQueryArgs, apiKey: string, mode: XaiAuthMode) => ProviderQuery;
|
|
10
|
+
}
|
|
11
|
+
export declare function buildOAuthRefreshQuery(opts: XaiQueryBootstrapArgs): ProviderQuery;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ProviderQuery } from '../../provider.js';
|
|
2
|
+
import { type XaiAuthMode } from './endpoints.js';
|
|
3
|
+
export declare function isAccessTokenExpired(expiresAt: number | undefined): boolean;
|
|
4
|
+
export declare function rewriteXaiHttpError(error: unknown, mode: XaiAuthMode): Error;
|
|
5
|
+
export declare function errorOnlyQuery(message: string): ProviderQuery;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export type SlotName = 'local' | 'small' | 'medium' | 'large';
|
|
2
2
|
export declare const SLOT_NAMES: readonly SlotName[];
|
|
3
|
-
export type SlotProvider = 'anthropic' | 'openai' | 'chatgpt-oauth';
|
|
3
|
+
export type SlotProvider = 'anthropic' | 'openai' | 'chatgpt-oauth' | 'xai' | 'xai-oauth';
|
|
4
4
|
export interface ModelSlotBinding {
|
|
5
5
|
id: string;
|
|
6
6
|
name?: string;
|
|
@@ -5,5 +5,8 @@ export interface SlotCredentialTarget {
|
|
|
5
5
|
baseUrl?: string;
|
|
6
6
|
openaiBaseUrl?: string;
|
|
7
7
|
forceChatgptOAuth?: boolean;
|
|
8
|
+
forceXaiOAuth?: boolean;
|
|
9
|
+
forceXaiApiKey?: boolean;
|
|
10
|
+
xaiBaseUrl?: string;
|
|
8
11
|
}
|
|
9
12
|
export declare function applySlotCredentials(config: SlotCredentialTarget, bindings?: ModelSlots): void;
|
|
@@ -11,3 +11,4 @@ export declare function applyManagerApiKeyFallback(args: {
|
|
|
11
11
|
parentApiKey: string | undefined;
|
|
12
12
|
parentProvider?: BundledProviderName | undefined;
|
|
13
13
|
}): string | undefined;
|
|
14
|
+
export declare function sameCredentialFamily(a: BundledProviderName, b: BundledProviderName): boolean;
|
|
@@ -26,6 +26,9 @@ export interface AgentConfig {
|
|
|
26
26
|
baseUrl?: string;
|
|
27
27
|
openaiBaseUrl?: string;
|
|
28
28
|
forceChatgptOAuth?: boolean;
|
|
29
|
+
forceXaiOAuth?: boolean;
|
|
30
|
+
forceXaiApiKey?: boolean;
|
|
31
|
+
xaiBaseUrl?: string;
|
|
29
32
|
maxTurns?: number;
|
|
30
33
|
maxToolUseIterations?: number;
|
|
31
34
|
softDeadlineMs?: number;
|
|
@@ -7,6 +7,7 @@ export interface Check {
|
|
|
7
7
|
}
|
|
8
8
|
export declare function checkAnthropicKey(): Promise<Check>;
|
|
9
9
|
export declare function checkCodexKey(): Promise<Check>;
|
|
10
|
+
export declare function checkXaiAuth(): Promise<Check>;
|
|
10
11
|
export declare function checkNpmBinOnPath(): Promise<Check>;
|
|
11
12
|
export declare function checkDirWritable(name: string, getDir: () => string): Promise<Check>;
|
|
12
13
|
export declare function checkConfigFile(): Promise<Check>;
|
|
@@ -24,6 +24,7 @@ export interface BuildAgentSessionDeps {
|
|
|
24
24
|
autoResumeOnUsageLimit: boolean | undefined;
|
|
25
25
|
permissionMode?: PermissionMode;
|
|
26
26
|
baseUrl?: string;
|
|
27
|
+
explicitProvider?: string;
|
|
27
28
|
}
|
|
28
29
|
export declare function buildAgentSession(deps: BuildAgentSessionDeps): AgentSession;
|
|
29
30
|
export declare function buildSharedDeps(a: {
|
|
@@ -43,4 +44,5 @@ export declare function buildSharedDeps(a: {
|
|
|
43
44
|
effectiveCwd: string | undefined;
|
|
44
45
|
maxTurns: string;
|
|
45
46
|
initialPermissionMode: PermissionMode | undefined;
|
|
47
|
+
explicitProvider?: string;
|
|
46
48
|
}): BuildAgentSessionDeps;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface XaiLoginResult {
|
|
2
|
+
ok: boolean;
|
|
3
|
+
message: string;
|
|
4
|
+
last4?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function runXaiDeviceCodeLogin(opts: {
|
|
7
|
+
onStatus?: (line: string) => void;
|
|
8
|
+
timeoutMs?: number;
|
|
9
|
+
sleep?: (ms: number) => Promise<void>;
|
|
10
|
+
}): Promise<XaiLoginResult>;
|
|
11
|
+
export declare function runXaiBrowserLogin(opts: {
|
|
12
|
+
onStatus?: (line: string) => void;
|
|
13
|
+
openBrowser?: (url: string) => void;
|
|
14
|
+
timeoutMs?: number;
|
|
15
|
+
}): Promise<XaiLoginResult>;
|
|
16
|
+
export declare function runXaiLogout(): XaiLoginResult;
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import { type OpenAIAuthSource, type AuthResolverDeps } from '../../agent/providers/openai-compatible/auth.js';
|
|
3
|
+
import { type XaiAuthSource, type XaiAuthResolverDeps } from '../../agent/providers/xai/auth.js';
|
|
3
4
|
export declare function buildProviderAuthDiagnose(explicitConfigKey: string | undefined, deps?: AuthResolverDeps): {
|
|
4
5
|
source: OpenAIAuthSource;
|
|
5
6
|
message: string;
|
|
6
7
|
exitCode: number;
|
|
7
8
|
last4?: string;
|
|
8
9
|
};
|
|
10
|
+
export declare function buildXaiAuthDiagnose(explicitConfigKey: string | undefined, forceMode?: 'apikey' | 'oauth', deps?: XaiAuthResolverDeps): {
|
|
11
|
+
source: XaiAuthSource;
|
|
12
|
+
message: string;
|
|
13
|
+
exitCode: number;
|
|
14
|
+
last4?: string;
|
|
15
|
+
mode?: string;
|
|
16
|
+
};
|
|
9
17
|
export declare function registerProviderCommand(program: Command): void;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type ProviderRouteHints } from '../agent/providers/index.js';
|
|
1
2
|
import type { AgentModelInput, ThinkingConfig, EffortLevel } from '../agent/types.js';
|
|
2
3
|
import type { GrantManager } from './slash/commands/allow-dir.js';
|
|
3
4
|
export { composeSystemPrompt, loadConfigSystemPrompt, loadSystemPrompt, OPERATOR_CONFIG_HEADER, resolveBaseSystemPrompt, } from './system-prompt.js';
|
|
@@ -5,7 +6,8 @@ export { parseProvider } from './provider-parser.js';
|
|
|
5
6
|
export type { ParseProviderOptions } from './provider-parser.js';
|
|
6
7
|
export declare function getApiKey(): string | undefined;
|
|
7
8
|
export declare function getCodexApiKey(): string | undefined;
|
|
8
|
-
export declare function getApiKeyForModel(model: string | undefined): string | undefined;
|
|
9
|
+
export declare function getApiKeyForModel(model: string | undefined, hints?: ProviderRouteHints): string | undefined;
|
|
10
|
+
export declare function explicitProviderHints(provider: string | undefined): ProviderRouteHints | undefined;
|
|
9
11
|
export declare function getModel(): AgentModelInput;
|
|
10
12
|
export declare function getDefaultSubagentModel(parentModel?: AgentModelInput): AgentModelInput;
|
|
11
13
|
export declare function parseThinking(raw: string | undefined): ThinkingConfig | undefined;
|