@t2000/sdk 5.14.2 → 5.15.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/index.d.cts CHANGED
@@ -1,14 +1,62 @@
1
1
  import { EventEmitter } from 'eventemitter3';
2
2
  import { SuiGrpcClient } from '@mysten/sui/grpc';
3
3
  import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
4
- import { T as T2000Error, aD as T2000Options, Q as TransactionSigner, l as PayOptions, m as PayResult, aE as SwapResult, aF as SwapQuoteResult, w as SupportedAsset, r as SendResult, B as BalanceResponse, J as TransactionRecord, e as DepositInfo, aG as PaymentRequest, $ as ZkLoginProof, aH as SuiCoreClient, j as OverlayFeeConfig, aI as SponsoredCoinMergeCache, x as SwapRouteResult, aJ as SendableAsset } from './send-D2nKpwJN.cjs';
5
- export { aK as CETUS_USDC_SUI_POOL, C as CLOCK_ID, a as COIN_REGISTRY, b as ClassifyBalanceChange, c as ClassifyResult, d as CoinMeta, aL as CoinPage, aM as DEFAULT_GRPC_URL, D as DEFAULT_NETWORK, E as ETH_TYPE, f as ExtractedTransfer, aN as GASLESS_MIN_STABLE_AMOUNT, aO as GASLESS_STABLE_TYPES, G as GAS_RESERVE_MIN, I as IKA_TYPE, K as KNOWN_TARGETS, g as KeypairSigner, L as LABEL_PATTERNS, h as LOFI_TYPE, M as MANIFEST_TYPE, i as MIST_PER_SUI, N as NAVX_TYPE, aP as OPERATION_ASSETS, O as OVERLAY_FEE_RATE, aQ as Operation, P as PREFLIGHT_MAX_AMOUNT, k as PREFLIGHT_OK, n as PreflightResult, aR as SENDABLE_ASSETS, S as STABLE_ASSETS, o as SUI_DECIMALS, p as SUI_TYPE, q as SUPPORTED_ASSETS, aS as SelectAndSplitResult, aT as SerializedCetusRoute, aU as SerializedCetusRoutePath, aV as SerializedRouterDataV3, s as SimulationResult, t as StableAsset, u as SuiHolding, v as SuiRpcTxBlock, y as T2000ErrorCode, z as T2000ErrorData, A as T2000_OVERLAY_FEE_WALLET, F as TOKEN_MAP, H as TransactionLeg, R as TxDirection, U as USDC_DECIMALS, V as USDC_TYPE, W as USDE_TYPE, X as USDSUI_TYPE, Y as USDT_TYPE, Z as WAL_TYPE, _ as WBTC_TYPE, a0 as ZkLoginSigner, aW as addSendToTx, aX as addSwapToTx, aY as assertAllowedAsset, a1 as buildSendTx, a2 as buildSwapTx, a3 as checkPositiveAmount, a4 as checkSuiAddress, a5 as classifyAction, a6 as classifyLabel, a7 as classifyTransaction, aZ as deserializeCetusRoute, a8 as executeTx, a9 as extractAllUserLegs, aa as extractTransferDetails, ab as extractTxCommands, ac as extractTxSender, ad as fallbackLabel, a_ as fetchAllCoins, ae as findSwapRoute, af as formatAssetAmount, ag as formatSui, ah as formatUsd, a$ as getCoinMeta, ai as getDecimals, aj as getDecimalsForCoinType, b0 as getSuiClient, b1 as getSuiGrpcClient, b2 as isAllowedAsset, b3 as isCetusRouteFresh, b4 as isInRegistry, ak as mapMoveAbortCode, al as mapWalletError, am as mistToSui, b5 as normalizeAsset, b6 as normalizeCoinType, an as parseSuiRpcTx, ao as payWithMpp, ap as preflightFail, aq as preflightPay, ar as preflightSend, as as preflightSwap, b7 as queryHistory, b8 as queryTransaction, at as rawToStable, au as rawToUsdc, av as refineLendingLabel, aw as resolveSymbol, ax as resolveTokenType, b9 as selectAndSplitCoin, ba as selectSuiCoin, bb as serializeCetusRoute, bc as simulateTransaction, ay as stableToRaw, az as suiToMist, bd as throwIfSimulationFailed, aA as truncateAddress, aB as usdcToRaw, aC as validateAddress, be as verifyCetusRouteCoinMatch } from './send-D2nKpwJN.cjs';
4
+ import { T as T2000Error, aD as T2000Options, Q as TransactionSigner, l as PayOptions, m as PayResult, aE as SwapResult, aF as SwapQuoteResult, w as SupportedAsset, r as SendResult, B as BalanceResponse, J as TransactionRecord, e as DepositInfo, aG as PaymentRequest, $ as ZkLoginProof, aH as SuiCoreClient, j as OverlayFeeConfig, aI as SponsoredCoinMergeCache, x as SwapRouteResult, aJ as SendableAsset } from './send-CUUOLK_H.cjs';
5
+ export { aK as CETUS_USDC_SUI_POOL, C as CLOCK_ID, a as COIN_REGISTRY, b as ClassifyBalanceChange, c as ClassifyResult, d as CoinMeta, aL as CoinPage, aM as DEFAULT_GRPC_URL, D as DEFAULT_NETWORK, E as ETH_TYPE, f as ExtractedTransfer, aN as GASLESS_MIN_STABLE_AMOUNT, aO as GASLESS_STABLE_TYPES, G as GAS_RESERVE_MIN, I as IKA_TYPE, K as KNOWN_TARGETS, g as KeypairSigner, L as LABEL_PATTERNS, h as LOFI_TYPE, M as MANIFEST_TYPE, i as MIST_PER_SUI, N as NAVX_TYPE, aP as OPERATION_ASSETS, O as OVERLAY_FEE_RATE, aQ as Operation, P as PREFLIGHT_MAX_AMOUNT, k as PREFLIGHT_OK, n as PreflightResult, aR as SENDABLE_ASSETS, S as STABLE_ASSETS, o as SUI_DECIMALS, p as SUI_TYPE, q as SUPPORTED_ASSETS, aS as SelectAndSplitResult, aT as SerializedCetusRoute, aU as SerializedCetusRoutePath, aV as SerializedRouterDataV3, s as SimulationResult, t as StableAsset, u as SuiHolding, v as SuiRpcTxBlock, y as T2000ErrorCode, z as T2000ErrorData, A as T2000_OVERLAY_FEE_WALLET, F as TOKEN_MAP, H as TransactionLeg, R as TxDirection, U as USDC_DECIMALS, V as USDC_TYPE, W as USDE_TYPE, X as USDSUI_TYPE, Y as USDT_TYPE, Z as WAL_TYPE, _ as WBTC_TYPE, a0 as ZkLoginSigner, aW as addSendToTx, aX as addSwapToTx, aY as assertAllowedAsset, a1 as buildSendTx, a2 as buildSwapTx, a3 as checkPositiveAmount, a4 as checkSuiAddress, a5 as classifyAction, a6 as classifyLabel, a7 as classifyTransaction, aZ as deserializeCetusRoute, a8 as executeTx, a9 as extractAllUserLegs, aa as extractTransferDetails, ab as extractTxCommands, ac as extractTxSender, ad as fallbackLabel, a_ as fetchAllCoins, ae as findSwapRoute, af as formatAssetAmount, ag as formatSui, ah as formatUsd, a$ as getCoinMeta, ai as getDecimals, aj as getDecimalsForCoinType, b0 as getSuiClient, b1 as getSuiGrpcClient, b2 as isAllowedAsset, b3 as isCetusRouteFresh, b4 as isInRegistry, ak as mapMoveAbortCode, al as mapWalletError, am as mistToSui, b5 as normalizeAsset, b6 as normalizeCoinType, an as parseSuiRpcTx, ao as payWithMpp, ap as preflightFail, aq as preflightPay, ar as preflightSend, as as preflightSwap, b7 as queryHistory, b8 as queryTransaction, at as rawToStable, au as rawToUsdc, av as refineLendingLabel, aw as resolveSymbol, ax as resolveTokenType, b9 as selectAndSplitCoin, ba as selectSuiCoin, bb as serializeCetusRoute, bc as simulateTransaction, ay as stableToRaw, az as suiToMist, bd as throwIfSimulationFailed, aA as truncateAddress, aB as usdcToRaw, aC as validateAddress, be as verifyCetusRouteCoinMatch } from './send-CUUOLK_H.cjs';
6
6
  import { TransactionObjectArgument, Transaction } from '@mysten/sui/transactions';
7
7
  import { SuinsClient } from '@mysten/suins';
8
8
  import '@mysten/sui/client';
9
9
  import '@cetusprotocol/aggregator-sdk';
10
10
  import '@mysten/sui/jsonRpc';
11
11
 
12
+ declare const DEFAULT_API_BASE = "https://api.t2000.ai/v1";
13
+ interface ChatMessage {
14
+ role: 'system' | 'user' | 'assistant';
15
+ content: string;
16
+ }
17
+ interface ChatParams {
18
+ model: string;
19
+ messages: ChatMessage[];
20
+ /** Private API key (`sk-…`). Falls back to `T2000_API_KEY` env. */
21
+ apiKey?: string;
22
+ /** Override the API base (default `api.t2000.ai/v1`; e.g. for testing). */
23
+ apiBase?: string;
24
+ maxTokens?: number;
25
+ temperature?: number;
26
+ }
27
+ interface ChatUsage {
28
+ promptTokens?: number;
29
+ completionTokens?: number;
30
+ totalTokens?: number;
31
+ }
32
+ interface ChatResult {
33
+ content: string;
34
+ model: string;
35
+ usage?: ChatUsage;
36
+ /** The verbatim OpenAI-shaped response body. */
37
+ raw: unknown;
38
+ }
39
+ interface ApiModel {
40
+ id: string;
41
+ contextWindow?: number;
42
+ inputPer1M?: number;
43
+ outputPer1M?: number;
44
+ /** Privacy tier surfaced by the API (e.g. `zdr`, `confidential`). */
45
+ privacy?: string;
46
+ }
47
+ /** Non-streaming chat completion. Returns the assistant text + usage + the
48
+ * verbatim OpenAI response body. */
49
+ declare function chatCompletion(params: ChatParams): Promise<ChatResult>;
50
+ /** Streaming chat completion — yields assistant text deltas as they arrive
51
+ * (parses the OpenAI SSE `data:` frames). */
52
+ declare function chatCompletionStream(params: ChatParams): AsyncGenerator<string, void, unknown>;
53
+ /** List the Private API model catalog (`GET /v1/models`). The key is sent when
54
+ * available but not required (the catalog may be public). */
55
+ declare function listModels(opts?: {
56
+ apiKey?: string;
57
+ apiBase?: string;
58
+ }): Promise<ApiModel[]>;
59
+
12
60
  interface LimitsConfig {
13
61
  /** Caps any single outbound write (send | swap | pay) by USD value. */
14
62
  perTxUsd?: number;
@@ -160,6 +208,15 @@ declare class T2000 extends EventEmitter<T2000Events> {
160
208
  /** Transaction signer (works for both keypair and zkLogin). */
161
209
  get signer(): TransactionSigner;
162
210
  pay(options: PayOptions): Promise<PayResult>;
211
+ /** Non-streaming chat completion against the Private API. */
212
+ chat(params: ChatParams): Promise<ChatResult>;
213
+ /** Streaming chat completion — async-iterate the assistant text deltas. */
214
+ chatStream(params: ChatParams): AsyncGenerator<string, void, unknown>;
215
+ /** The Private API model catalog (`GET /v1/models`). */
216
+ models(opts?: {
217
+ apiKey?: string;
218
+ apiBase?: string;
219
+ }): Promise<ApiModel[]>;
163
220
  swap(params: {
164
221
  from: string;
165
222
  to: string;
@@ -956,4 +1013,4 @@ declare function fullHandle(label: string, parentName?: string): string;
956
1013
  */
957
1014
  declare function displayHandle(label: string, parentName?: string): string;
958
1015
 
959
- export { AGENT_ID_PARENT, AGENT_ID_PARENT_NAME, AGENT_ID_PARENT_NFT_ID, AUDRIC_PARENT, AUDRIC_PARENT_NAME, AUDRIC_PARENT_NFT_ID, type AppenderContext, BalanceResponse, type BuildAddLeafParams, type BuildRevokeLeafParams, type ComposeTxOptions, type ComposeTxResult, type DailySpend, DepositInfo, InvalidAddressError, type LabelValidationResult, type LimitAssertInput, LimitEnforcer, LimitExceededError, type LimitKind, type LimitOperation, type LimitsConfig, type LimitsFile, type NormalizedAddress, OverlayFeeConfig, PayOptions, PayResult, PaymentRequest, SPONSORED_PYTH_DEPENDENT_PROVIDERS, SUINS_NAME_REGEX, SUI_ADDRESS_REGEX, SUI_ADDRESS_STRICT_REGEX, SendResult, type SendTransferInput, SendableAsset, type StepPreview, SuinsNotRegisteredError, type SuinsParent, SuinsRpcError, SupportedAsset, type SwapExecuteInput, SwapQuoteResult, SwapResult, SwapRouteResult, T2000, T2000Error, T2000Options, TransactionRecord, TransactionSigner, WRITE_APPENDER_REGISTRY, type WriteStep, type WriteToolName, ZkLoginProof, approxUsdValue, assertLimitConfig, buildAddLeafTx, buildRevokeLeafTx, clearLimits, composeTx, dailySpentToday, deriveAllowedAddressesFromPtb, displayHandle, exportPrivateKey, fullHandle, generateKeypair, getAddress, getLimits, getSponsoredSwapProviders, getSwapQuote, hasLimits, keypairFromPrivateKey, loadKey, looksLikeSuiNs, normalizeAddressInput, queryBalance, readLimitsFile, recordDailySpend, resolveAddressToSuinsViaRpc, resolveSuinsViaRpc, saveBech32, saveKey, setLimits, validateLabel, walletExists, writeLimitsFile };
1016
+ export { AGENT_ID_PARENT, AGENT_ID_PARENT_NAME, AGENT_ID_PARENT_NFT_ID, AUDRIC_PARENT, AUDRIC_PARENT_NAME, AUDRIC_PARENT_NFT_ID, type ApiModel, type AppenderContext, BalanceResponse, type BuildAddLeafParams, type BuildRevokeLeafParams, type ChatMessage, type ChatParams, type ChatResult, type ChatUsage, type ComposeTxOptions, type ComposeTxResult, DEFAULT_API_BASE, type DailySpend, DepositInfo, InvalidAddressError, type LabelValidationResult, type LimitAssertInput, LimitEnforcer, LimitExceededError, type LimitKind, type LimitOperation, type LimitsConfig, type LimitsFile, type NormalizedAddress, OverlayFeeConfig, PayOptions, PayResult, PaymentRequest, SPONSORED_PYTH_DEPENDENT_PROVIDERS, SUINS_NAME_REGEX, SUI_ADDRESS_REGEX, SUI_ADDRESS_STRICT_REGEX, SendResult, type SendTransferInput, SendableAsset, type StepPreview, SuinsNotRegisteredError, type SuinsParent, SuinsRpcError, SupportedAsset, type SwapExecuteInput, SwapQuoteResult, SwapResult, SwapRouteResult, T2000, T2000Error, T2000Options, TransactionRecord, TransactionSigner, WRITE_APPENDER_REGISTRY, type WriteStep, type WriteToolName, ZkLoginProof, approxUsdValue, assertLimitConfig, buildAddLeafTx, buildRevokeLeafTx, chatCompletion, chatCompletionStream, clearLimits, composeTx, dailySpentToday, deriveAllowedAddressesFromPtb, displayHandle, exportPrivateKey, fullHandle, generateKeypair, getAddress, getLimits, getSponsoredSwapProviders, getSwapQuote, hasLimits, keypairFromPrivateKey, listModels, loadKey, looksLikeSuiNs, normalizeAddressInput, queryBalance, readLimitsFile, recordDailySpend, resolveAddressToSuinsViaRpc, resolveSuinsViaRpc, saveBech32, saveKey, setLimits, validateLabel, walletExists, writeLimitsFile };
package/dist/index.d.ts CHANGED
@@ -1,14 +1,62 @@
1
1
  import { EventEmitter } from 'eventemitter3';
2
2
  import { SuiGrpcClient } from '@mysten/sui/grpc';
3
3
  import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
4
- import { T as T2000Error, aD as T2000Options, Q as TransactionSigner, l as PayOptions, m as PayResult, aE as SwapResult, aF as SwapQuoteResult, w as SupportedAsset, r as SendResult, B as BalanceResponse, J as TransactionRecord, e as DepositInfo, aG as PaymentRequest, $ as ZkLoginProof, aH as SuiCoreClient, j as OverlayFeeConfig, aI as SponsoredCoinMergeCache, x as SwapRouteResult, aJ as SendableAsset } from './send-D2nKpwJN.js';
5
- export { aK as CETUS_USDC_SUI_POOL, C as CLOCK_ID, a as COIN_REGISTRY, b as ClassifyBalanceChange, c as ClassifyResult, d as CoinMeta, aL as CoinPage, aM as DEFAULT_GRPC_URL, D as DEFAULT_NETWORK, E as ETH_TYPE, f as ExtractedTransfer, aN as GASLESS_MIN_STABLE_AMOUNT, aO as GASLESS_STABLE_TYPES, G as GAS_RESERVE_MIN, I as IKA_TYPE, K as KNOWN_TARGETS, g as KeypairSigner, L as LABEL_PATTERNS, h as LOFI_TYPE, M as MANIFEST_TYPE, i as MIST_PER_SUI, N as NAVX_TYPE, aP as OPERATION_ASSETS, O as OVERLAY_FEE_RATE, aQ as Operation, P as PREFLIGHT_MAX_AMOUNT, k as PREFLIGHT_OK, n as PreflightResult, aR as SENDABLE_ASSETS, S as STABLE_ASSETS, o as SUI_DECIMALS, p as SUI_TYPE, q as SUPPORTED_ASSETS, aS as SelectAndSplitResult, aT as SerializedCetusRoute, aU as SerializedCetusRoutePath, aV as SerializedRouterDataV3, s as SimulationResult, t as StableAsset, u as SuiHolding, v as SuiRpcTxBlock, y as T2000ErrorCode, z as T2000ErrorData, A as T2000_OVERLAY_FEE_WALLET, F as TOKEN_MAP, H as TransactionLeg, R as TxDirection, U as USDC_DECIMALS, V as USDC_TYPE, W as USDE_TYPE, X as USDSUI_TYPE, Y as USDT_TYPE, Z as WAL_TYPE, _ as WBTC_TYPE, a0 as ZkLoginSigner, aW as addSendToTx, aX as addSwapToTx, aY as assertAllowedAsset, a1 as buildSendTx, a2 as buildSwapTx, a3 as checkPositiveAmount, a4 as checkSuiAddress, a5 as classifyAction, a6 as classifyLabel, a7 as classifyTransaction, aZ as deserializeCetusRoute, a8 as executeTx, a9 as extractAllUserLegs, aa as extractTransferDetails, ab as extractTxCommands, ac as extractTxSender, ad as fallbackLabel, a_ as fetchAllCoins, ae as findSwapRoute, af as formatAssetAmount, ag as formatSui, ah as formatUsd, a$ as getCoinMeta, ai as getDecimals, aj as getDecimalsForCoinType, b0 as getSuiClient, b1 as getSuiGrpcClient, b2 as isAllowedAsset, b3 as isCetusRouteFresh, b4 as isInRegistry, ak as mapMoveAbortCode, al as mapWalletError, am as mistToSui, b5 as normalizeAsset, b6 as normalizeCoinType, an as parseSuiRpcTx, ao as payWithMpp, ap as preflightFail, aq as preflightPay, ar as preflightSend, as as preflightSwap, b7 as queryHistory, b8 as queryTransaction, at as rawToStable, au as rawToUsdc, av as refineLendingLabel, aw as resolveSymbol, ax as resolveTokenType, b9 as selectAndSplitCoin, ba as selectSuiCoin, bb as serializeCetusRoute, bc as simulateTransaction, ay as stableToRaw, az as suiToMist, bd as throwIfSimulationFailed, aA as truncateAddress, aB as usdcToRaw, aC as validateAddress, be as verifyCetusRouteCoinMatch } from './send-D2nKpwJN.js';
4
+ import { T as T2000Error, aD as T2000Options, Q as TransactionSigner, l as PayOptions, m as PayResult, aE as SwapResult, aF as SwapQuoteResult, w as SupportedAsset, r as SendResult, B as BalanceResponse, J as TransactionRecord, e as DepositInfo, aG as PaymentRequest, $ as ZkLoginProof, aH as SuiCoreClient, j as OverlayFeeConfig, aI as SponsoredCoinMergeCache, x as SwapRouteResult, aJ as SendableAsset } from './send-CUUOLK_H.js';
5
+ export { aK as CETUS_USDC_SUI_POOL, C as CLOCK_ID, a as COIN_REGISTRY, b as ClassifyBalanceChange, c as ClassifyResult, d as CoinMeta, aL as CoinPage, aM as DEFAULT_GRPC_URL, D as DEFAULT_NETWORK, E as ETH_TYPE, f as ExtractedTransfer, aN as GASLESS_MIN_STABLE_AMOUNT, aO as GASLESS_STABLE_TYPES, G as GAS_RESERVE_MIN, I as IKA_TYPE, K as KNOWN_TARGETS, g as KeypairSigner, L as LABEL_PATTERNS, h as LOFI_TYPE, M as MANIFEST_TYPE, i as MIST_PER_SUI, N as NAVX_TYPE, aP as OPERATION_ASSETS, O as OVERLAY_FEE_RATE, aQ as Operation, P as PREFLIGHT_MAX_AMOUNT, k as PREFLIGHT_OK, n as PreflightResult, aR as SENDABLE_ASSETS, S as STABLE_ASSETS, o as SUI_DECIMALS, p as SUI_TYPE, q as SUPPORTED_ASSETS, aS as SelectAndSplitResult, aT as SerializedCetusRoute, aU as SerializedCetusRoutePath, aV as SerializedRouterDataV3, s as SimulationResult, t as StableAsset, u as SuiHolding, v as SuiRpcTxBlock, y as T2000ErrorCode, z as T2000ErrorData, A as T2000_OVERLAY_FEE_WALLET, F as TOKEN_MAP, H as TransactionLeg, R as TxDirection, U as USDC_DECIMALS, V as USDC_TYPE, W as USDE_TYPE, X as USDSUI_TYPE, Y as USDT_TYPE, Z as WAL_TYPE, _ as WBTC_TYPE, a0 as ZkLoginSigner, aW as addSendToTx, aX as addSwapToTx, aY as assertAllowedAsset, a1 as buildSendTx, a2 as buildSwapTx, a3 as checkPositiveAmount, a4 as checkSuiAddress, a5 as classifyAction, a6 as classifyLabel, a7 as classifyTransaction, aZ as deserializeCetusRoute, a8 as executeTx, a9 as extractAllUserLegs, aa as extractTransferDetails, ab as extractTxCommands, ac as extractTxSender, ad as fallbackLabel, a_ as fetchAllCoins, ae as findSwapRoute, af as formatAssetAmount, ag as formatSui, ah as formatUsd, a$ as getCoinMeta, ai as getDecimals, aj as getDecimalsForCoinType, b0 as getSuiClient, b1 as getSuiGrpcClient, b2 as isAllowedAsset, b3 as isCetusRouteFresh, b4 as isInRegistry, ak as mapMoveAbortCode, al as mapWalletError, am as mistToSui, b5 as normalizeAsset, b6 as normalizeCoinType, an as parseSuiRpcTx, ao as payWithMpp, ap as preflightFail, aq as preflightPay, ar as preflightSend, as as preflightSwap, b7 as queryHistory, b8 as queryTransaction, at as rawToStable, au as rawToUsdc, av as refineLendingLabel, aw as resolveSymbol, ax as resolveTokenType, b9 as selectAndSplitCoin, ba as selectSuiCoin, bb as serializeCetusRoute, bc as simulateTransaction, ay as stableToRaw, az as suiToMist, bd as throwIfSimulationFailed, aA as truncateAddress, aB as usdcToRaw, aC as validateAddress, be as verifyCetusRouteCoinMatch } from './send-CUUOLK_H.js';
6
6
  import { TransactionObjectArgument, Transaction } from '@mysten/sui/transactions';
7
7
  import { SuinsClient } from '@mysten/suins';
8
8
  import '@mysten/sui/client';
9
9
  import '@cetusprotocol/aggregator-sdk';
10
10
  import '@mysten/sui/jsonRpc';
11
11
 
12
+ declare const DEFAULT_API_BASE = "https://api.t2000.ai/v1";
13
+ interface ChatMessage {
14
+ role: 'system' | 'user' | 'assistant';
15
+ content: string;
16
+ }
17
+ interface ChatParams {
18
+ model: string;
19
+ messages: ChatMessage[];
20
+ /** Private API key (`sk-…`). Falls back to `T2000_API_KEY` env. */
21
+ apiKey?: string;
22
+ /** Override the API base (default `api.t2000.ai/v1`; e.g. for testing). */
23
+ apiBase?: string;
24
+ maxTokens?: number;
25
+ temperature?: number;
26
+ }
27
+ interface ChatUsage {
28
+ promptTokens?: number;
29
+ completionTokens?: number;
30
+ totalTokens?: number;
31
+ }
32
+ interface ChatResult {
33
+ content: string;
34
+ model: string;
35
+ usage?: ChatUsage;
36
+ /** The verbatim OpenAI-shaped response body. */
37
+ raw: unknown;
38
+ }
39
+ interface ApiModel {
40
+ id: string;
41
+ contextWindow?: number;
42
+ inputPer1M?: number;
43
+ outputPer1M?: number;
44
+ /** Privacy tier surfaced by the API (e.g. `zdr`, `confidential`). */
45
+ privacy?: string;
46
+ }
47
+ /** Non-streaming chat completion. Returns the assistant text + usage + the
48
+ * verbatim OpenAI response body. */
49
+ declare function chatCompletion(params: ChatParams): Promise<ChatResult>;
50
+ /** Streaming chat completion — yields assistant text deltas as they arrive
51
+ * (parses the OpenAI SSE `data:` frames). */
52
+ declare function chatCompletionStream(params: ChatParams): AsyncGenerator<string, void, unknown>;
53
+ /** List the Private API model catalog (`GET /v1/models`). The key is sent when
54
+ * available but not required (the catalog may be public). */
55
+ declare function listModels(opts?: {
56
+ apiKey?: string;
57
+ apiBase?: string;
58
+ }): Promise<ApiModel[]>;
59
+
12
60
  interface LimitsConfig {
13
61
  /** Caps any single outbound write (send | swap | pay) by USD value. */
14
62
  perTxUsd?: number;
@@ -160,6 +208,15 @@ declare class T2000 extends EventEmitter<T2000Events> {
160
208
  /** Transaction signer (works for both keypair and zkLogin). */
161
209
  get signer(): TransactionSigner;
162
210
  pay(options: PayOptions): Promise<PayResult>;
211
+ /** Non-streaming chat completion against the Private API. */
212
+ chat(params: ChatParams): Promise<ChatResult>;
213
+ /** Streaming chat completion — async-iterate the assistant text deltas. */
214
+ chatStream(params: ChatParams): AsyncGenerator<string, void, unknown>;
215
+ /** The Private API model catalog (`GET /v1/models`). */
216
+ models(opts?: {
217
+ apiKey?: string;
218
+ apiBase?: string;
219
+ }): Promise<ApiModel[]>;
163
220
  swap(params: {
164
221
  from: string;
165
222
  to: string;
@@ -956,4 +1013,4 @@ declare function fullHandle(label: string, parentName?: string): string;
956
1013
  */
957
1014
  declare function displayHandle(label: string, parentName?: string): string;
958
1015
 
959
- export { AGENT_ID_PARENT, AGENT_ID_PARENT_NAME, AGENT_ID_PARENT_NFT_ID, AUDRIC_PARENT, AUDRIC_PARENT_NAME, AUDRIC_PARENT_NFT_ID, type AppenderContext, BalanceResponse, type BuildAddLeafParams, type BuildRevokeLeafParams, type ComposeTxOptions, type ComposeTxResult, type DailySpend, DepositInfo, InvalidAddressError, type LabelValidationResult, type LimitAssertInput, LimitEnforcer, LimitExceededError, type LimitKind, type LimitOperation, type LimitsConfig, type LimitsFile, type NormalizedAddress, OverlayFeeConfig, PayOptions, PayResult, PaymentRequest, SPONSORED_PYTH_DEPENDENT_PROVIDERS, SUINS_NAME_REGEX, SUI_ADDRESS_REGEX, SUI_ADDRESS_STRICT_REGEX, SendResult, type SendTransferInput, SendableAsset, type StepPreview, SuinsNotRegisteredError, type SuinsParent, SuinsRpcError, SupportedAsset, type SwapExecuteInput, SwapQuoteResult, SwapResult, SwapRouteResult, T2000, T2000Error, T2000Options, TransactionRecord, TransactionSigner, WRITE_APPENDER_REGISTRY, type WriteStep, type WriteToolName, ZkLoginProof, approxUsdValue, assertLimitConfig, buildAddLeafTx, buildRevokeLeafTx, clearLimits, composeTx, dailySpentToday, deriveAllowedAddressesFromPtb, displayHandle, exportPrivateKey, fullHandle, generateKeypair, getAddress, getLimits, getSponsoredSwapProviders, getSwapQuote, hasLimits, keypairFromPrivateKey, loadKey, looksLikeSuiNs, normalizeAddressInput, queryBalance, readLimitsFile, recordDailySpend, resolveAddressToSuinsViaRpc, resolveSuinsViaRpc, saveBech32, saveKey, setLimits, validateLabel, walletExists, writeLimitsFile };
1016
+ export { AGENT_ID_PARENT, AGENT_ID_PARENT_NAME, AGENT_ID_PARENT_NFT_ID, AUDRIC_PARENT, AUDRIC_PARENT_NAME, AUDRIC_PARENT_NFT_ID, type ApiModel, type AppenderContext, BalanceResponse, type BuildAddLeafParams, type BuildRevokeLeafParams, type ChatMessage, type ChatParams, type ChatResult, type ChatUsage, type ComposeTxOptions, type ComposeTxResult, DEFAULT_API_BASE, type DailySpend, DepositInfo, InvalidAddressError, type LabelValidationResult, type LimitAssertInput, LimitEnforcer, LimitExceededError, type LimitKind, type LimitOperation, type LimitsConfig, type LimitsFile, type NormalizedAddress, OverlayFeeConfig, PayOptions, PayResult, PaymentRequest, SPONSORED_PYTH_DEPENDENT_PROVIDERS, SUINS_NAME_REGEX, SUI_ADDRESS_REGEX, SUI_ADDRESS_STRICT_REGEX, SendResult, type SendTransferInput, SendableAsset, type StepPreview, SuinsNotRegisteredError, type SuinsParent, SuinsRpcError, SupportedAsset, type SwapExecuteInput, SwapQuoteResult, SwapResult, SwapRouteResult, T2000, T2000Error, T2000Options, TransactionRecord, TransactionSigner, WRITE_APPENDER_REGISTRY, type WriteStep, type WriteToolName, ZkLoginProof, approxUsdValue, assertLimitConfig, buildAddLeafTx, buildRevokeLeafTx, chatCompletion, chatCompletionStream, clearLimits, composeTx, dailySpentToday, deriveAllowedAddressesFromPtb, displayHandle, exportPrivateKey, fullHandle, generateKeypair, getAddress, getLimits, getSponsoredSwapProviders, getSwapQuote, hasLimits, keypairFromPrivateKey, listModels, loadKey, looksLikeSuiNs, normalizeAddressInput, queryBalance, readLimitsFile, recordDailySpend, resolveAddressToSuinsViaRpc, resolveSuinsViaRpc, saveBech32, saveKey, setLimits, validateLabel, walletExists, writeLimitsFile };
package/dist/index.js CHANGED
@@ -1130,9 +1130,9 @@ async function payWithMpp(args) {
1130
1130
  }
1131
1131
  async function pickSuiExactRequirements(response, network) {
1132
1132
  try {
1133
- const body = await response.clone().json();
1133
+ const body2 = await response.clone().json();
1134
1134
  const want = `sui:${network === "testnet" ? "testnet" : "mainnet"}`;
1135
- return body.accepts?.find((a) => a.scheme === "exact" && a.network === want);
1135
+ return body2.accepts?.find((a) => a.scheme === "exact" && a.network === want);
1136
1136
  } catch {
1137
1137
  return void 0;
1138
1138
  }
@@ -1211,13 +1211,13 @@ async function ensureAddressBalanceCovers(args) {
1211
1211
  }
1212
1212
  async function finalize(response, opts) {
1213
1213
  const contentType = response.headers.get("content-type") ?? "";
1214
- let body;
1214
+ let body2;
1215
1215
  try {
1216
- body = contentType.includes("application/json") ? await response.json() : await response.text();
1216
+ body2 = contentType.includes("application/json") ? await response.json() : await response.text();
1217
1217
  } catch {
1218
- body = null;
1218
+ body2 = null;
1219
1219
  }
1220
- return { status: response.status, body, paid: opts.paid };
1220
+ return { status: response.status, body: body2, paid: opts.paid };
1221
1221
  }
1222
1222
  async function makeGrpcBuildClient(client) {
1223
1223
  const { SuiGrpcClient: SuiGrpcClient2 } = await import('@mysten/sui/grpc');
@@ -1881,6 +1881,140 @@ async function normalizeAddressInput(value, ctx = {}) {
1881
1881
 
1882
1882
  // src/t2000.ts
1883
1883
  init_errors();
1884
+
1885
+ // src/inference.ts
1886
+ init_errors();
1887
+ var DEFAULT_API_BASE = "https://api.t2000.ai/v1";
1888
+ function envApiKey() {
1889
+ return typeof process !== "undefined" ? process.env?.T2000_API_KEY : void 0;
1890
+ }
1891
+ function resolveApiKey(apiKey) {
1892
+ const key = apiKey ?? envApiKey();
1893
+ if (!key) {
1894
+ throw new T2000Error(
1895
+ "INVALID_KEY",
1896
+ "No Private API key. Pass `apiKey` or set T2000_API_KEY. Generate one at platform.t2000.ai (Pro/Max)."
1897
+ );
1898
+ }
1899
+ return key;
1900
+ }
1901
+ async function failBody(res) {
1902
+ const text = await res.text().catch(() => "");
1903
+ let msg = text.slice(0, 300);
1904
+ try {
1905
+ const j = JSON.parse(text);
1906
+ msg = (typeof j.error === "object" ? j.error?.message : j.error) ?? msg;
1907
+ } catch {
1908
+ }
1909
+ throw new T2000Error(
1910
+ "INFERENCE_FAILED",
1911
+ `Inference request failed (${res.status}): ${msg}`,
1912
+ { status: res.status },
1913
+ res.status >= 500
1914
+ );
1915
+ }
1916
+ function usageOf(raw) {
1917
+ const u = raw?.usage;
1918
+ if (!u) {
1919
+ return;
1920
+ }
1921
+ return {
1922
+ promptTokens: u.prompt_tokens,
1923
+ completionTokens: u.completion_tokens,
1924
+ totalTokens: u.total_tokens
1925
+ };
1926
+ }
1927
+ function body(params, stream) {
1928
+ return JSON.stringify({
1929
+ model: params.model,
1930
+ messages: params.messages,
1931
+ ...stream ? { stream: true } : {},
1932
+ ...params.maxTokens != null ? { max_tokens: params.maxTokens } : {},
1933
+ ...params.temperature != null ? { temperature: params.temperature } : {}
1934
+ });
1935
+ }
1936
+ async function chatCompletion(params) {
1937
+ const key = resolveApiKey(params.apiKey);
1938
+ const base = params.apiBase ?? DEFAULT_API_BASE;
1939
+ const res = await fetch(`${base}/chat/completions`, {
1940
+ method: "POST",
1941
+ headers: { "content-type": "application/json", authorization: `Bearer ${key}` },
1942
+ body: body(params, false)
1943
+ });
1944
+ if (!res.ok) {
1945
+ await failBody(res);
1946
+ }
1947
+ const raw = await res.json();
1948
+ const content = raw?.choices?.[0]?.message?.content ?? "";
1949
+ return {
1950
+ content,
1951
+ model: raw?.model ?? params.model,
1952
+ usage: usageOf(raw),
1953
+ raw
1954
+ };
1955
+ }
1956
+ async function* chatCompletionStream(params) {
1957
+ const key = resolveApiKey(params.apiKey);
1958
+ const base = params.apiBase ?? DEFAULT_API_BASE;
1959
+ const res = await fetch(`${base}/chat/completions`, {
1960
+ method: "POST",
1961
+ headers: { "content-type": "application/json", authorization: `Bearer ${key}` },
1962
+ body: body(params, true)
1963
+ });
1964
+ if (!(res.ok && res.body)) {
1965
+ await failBody(res);
1966
+ return;
1967
+ }
1968
+ const reader = res.body.getReader();
1969
+ const decoder = new TextDecoder();
1970
+ let buffer = "";
1971
+ while (true) {
1972
+ const { done, value } = await reader.read();
1973
+ if (done) {
1974
+ break;
1975
+ }
1976
+ buffer += decoder.decode(value, { stream: true });
1977
+ const lines = buffer.split("\n");
1978
+ buffer = lines.pop() ?? "";
1979
+ for (const line of lines) {
1980
+ const trimmed = line.trim();
1981
+ if (!trimmed.startsWith("data:")) {
1982
+ continue;
1983
+ }
1984
+ const data = trimmed.slice(5).trim();
1985
+ if (data === "[DONE]") {
1986
+ return;
1987
+ }
1988
+ try {
1989
+ const json = JSON.parse(data);
1990
+ const delta = json.choices?.[0]?.delta?.content;
1991
+ if (typeof delta === "string" && delta) {
1992
+ yield delta;
1993
+ }
1994
+ } catch {
1995
+ }
1996
+ }
1997
+ }
1998
+ }
1999
+ async function listModels(opts) {
2000
+ const base = opts?.apiBase ?? DEFAULT_API_BASE;
2001
+ const key = opts?.apiKey ?? envApiKey();
2002
+ const res = await fetch(`${base}/models`, {
2003
+ headers: key ? { authorization: `Bearer ${key}` } : {}
2004
+ });
2005
+ if (!res.ok) {
2006
+ await failBody(res);
2007
+ }
2008
+ const json = await res.json();
2009
+ const data = Array.isArray(json.data) ? json.data : [];
2010
+ return data.map((m) => ({
2011
+ id: m.id,
2012
+ contextWindow: m.context_window ?? m.context_length,
2013
+ inputPer1M: m.pricing?.input_per_1m ?? m.pricing?.prompt,
2014
+ outputPer1M: m.pricing?.output_per_1m ?? m.pricing?.completion,
2015
+ privacy: m.privacy ?? m.privacy_tier
2016
+ }));
2017
+ }
1884
2018
  var DEFAULT_CONFIG_DIR = join(homedir(), ".t2000");
1885
2019
  function resolveConfigPath(configDir) {
1886
2020
  return join(configDir ?? DEFAULT_CONFIG_DIR, "config.json");
@@ -2147,6 +2281,24 @@ var T2000 = class _T2000 extends EventEmitter {
2147
2281
  // but there is no longer any way to MINT or REDEEM vSUI through t2000.
2148
2282
  // History: see spec/archive/v07e/AUDIT_V07E_EARNS_ITS_KEEP_2026-05-23.md
2149
2283
  // and the S.323 build-tracker entry.
2284
+ // -- Private Inference API (SPEC_AUDRIC_API, S.575) --
2285
+ //
2286
+ // Inference as a wallet verb — the agent's brain + wallet in one package.
2287
+ // Key-based today (`apiKey` / `T2000_API_KEY`); the x402 no-key pay-per-call
2288
+ // path is a later add. The model runs on the t2000 Private API (ZDR; a
2289
+ // `phala/*` confidential tier runs in a GPU-TEE).
2290
+ /** Non-streaming chat completion against the Private API. */
2291
+ async chat(params) {
2292
+ return chatCompletion(params);
2293
+ }
2294
+ /** Streaming chat completion — async-iterate the assistant text deltas. */
2295
+ chatStream(params) {
2296
+ return chatCompletionStream(params);
2297
+ }
2298
+ /** The Private API model catalog (`GET /v1/models`). */
2299
+ async models(opts) {
2300
+ return listModels(opts);
2301
+ }
2150
2302
  // -- Swap --
2151
2303
  async swap(params) {
2152
2304
  this.limits.assert({
@@ -2905,6 +3057,6 @@ function displayHandle(label, parentName = AUDRIC_PARENT_NAME) {
2905
3057
  // src/index.ts
2906
3058
  init_preflight();
2907
3059
 
2908
- export { AGENT_ID_PARENT, AGENT_ID_PARENT_NAME, AGENT_ID_PARENT_NFT_ID, AUDRIC_PARENT, AUDRIC_PARENT_NAME, AUDRIC_PARENT_NFT_ID, CETUS_USDC_SUI_POOL, CLOCK_ID, COIN_REGISTRY, DEFAULT_GRPC_URL, DEFAULT_NETWORK, ETH_TYPE, GASLESS_MIN_STABLE_AMOUNT, GASLESS_STABLE_TYPES, GAS_RESERVE_MIN, IKA_TYPE, InvalidAddressError, KNOWN_TARGETS, KeypairSigner, LABEL_PATTERNS, LOFI_TYPE, LimitEnforcer, LimitExceededError, MANIFEST_TYPE, MIST_PER_SUI, NAVX_TYPE, OPERATION_ASSETS, OVERLAY_FEE_RATE, PREFLIGHT_MAX_AMOUNT, PREFLIGHT_OK, SENDABLE_ASSETS, SPONSORED_PYTH_DEPENDENT_PROVIDERS, STABLE_ASSETS, SUINS_NAME_REGEX, SUI_ADDRESS_REGEX, SUI_ADDRESS_STRICT_REGEX, SUI_DECIMALS, SUI_TYPE, SUPPORTED_ASSETS, SuinsNotRegisteredError, SuinsRpcError, T2000, T2000Error, T2000_OVERLAY_FEE_WALLET, TOKEN_MAP, USDC_DECIMALS, USDC_TYPE, USDE_TYPE, USDSUI_TYPE, USDT_TYPE, WAL_TYPE, WBTC_TYPE, WRITE_APPENDER_REGISTRY, ZkLoginSigner, addSendToTx, addSwapToTx, approxUsdValue, assertAllowedAsset, assertLimitConfig, buildAddLeafTx, buildRevokeLeafTx, buildSendTx, buildSwapTx, checkPositiveAmount, checkSuiAddress, classifyAction, classifyLabel, classifyTransaction, clearLimits, composeTx, dailySpentToday, deriveAllowedAddressesFromPtb, deserializeCetusRoute, displayHandle, executeTx, exportPrivateKey, extractAllUserLegs, extractTransferDetails, extractTxCommands, extractTxSender, fallbackLabel, fetchAllCoins, findSwapRoute, formatAssetAmount, formatSui, formatUsd, fullHandle, generateKeypair, getAddress, getCoinMeta, getDecimals, getDecimalsForCoinType, getLimits, getSponsoredSwapProviders, getSuiClient, getSuiGrpcClient, getSwapQuote, hasLimits, isAllowedAsset, isCetusRouteFresh, isInRegistry, keypairFromPrivateKey, loadKey, looksLikeSuiNs, mapMoveAbortCode, mapWalletError, mistToSui, normalizeAddressInput, normalizeAsset, normalizeCoinType, parseSuiRpcTx, payWithMpp, preflightFail, preflightPay, preflightSend, preflightSwap, queryBalance, queryHistory, queryTransaction, rawToStable, rawToUsdc, readLimitsFile, recordDailySpend, refineLendingLabel, resolveAddressToSuinsViaRpc, resolveSuinsViaRpc, resolveSymbol, resolveTokenType, saveBech32, saveKey, selectAndSplitCoin, selectSuiCoin, serializeCetusRoute, setLimits, simulateTransaction, stableToRaw, suiToMist, throwIfSimulationFailed, truncateAddress, usdcToRaw, validateAddress, validateLabel, verifyCetusRouteCoinMatch, walletExists, writeLimitsFile };
3060
+ export { AGENT_ID_PARENT, AGENT_ID_PARENT_NAME, AGENT_ID_PARENT_NFT_ID, AUDRIC_PARENT, AUDRIC_PARENT_NAME, AUDRIC_PARENT_NFT_ID, CETUS_USDC_SUI_POOL, CLOCK_ID, COIN_REGISTRY, DEFAULT_API_BASE, DEFAULT_GRPC_URL, DEFAULT_NETWORK, ETH_TYPE, GASLESS_MIN_STABLE_AMOUNT, GASLESS_STABLE_TYPES, GAS_RESERVE_MIN, IKA_TYPE, InvalidAddressError, KNOWN_TARGETS, KeypairSigner, LABEL_PATTERNS, LOFI_TYPE, LimitEnforcer, LimitExceededError, MANIFEST_TYPE, MIST_PER_SUI, NAVX_TYPE, OPERATION_ASSETS, OVERLAY_FEE_RATE, PREFLIGHT_MAX_AMOUNT, PREFLIGHT_OK, SENDABLE_ASSETS, SPONSORED_PYTH_DEPENDENT_PROVIDERS, STABLE_ASSETS, SUINS_NAME_REGEX, SUI_ADDRESS_REGEX, SUI_ADDRESS_STRICT_REGEX, SUI_DECIMALS, SUI_TYPE, SUPPORTED_ASSETS, SuinsNotRegisteredError, SuinsRpcError, T2000, T2000Error, T2000_OVERLAY_FEE_WALLET, TOKEN_MAP, USDC_DECIMALS, USDC_TYPE, USDE_TYPE, USDSUI_TYPE, USDT_TYPE, WAL_TYPE, WBTC_TYPE, WRITE_APPENDER_REGISTRY, ZkLoginSigner, addSendToTx, addSwapToTx, approxUsdValue, assertAllowedAsset, assertLimitConfig, buildAddLeafTx, buildRevokeLeafTx, buildSendTx, buildSwapTx, chatCompletion, chatCompletionStream, checkPositiveAmount, checkSuiAddress, classifyAction, classifyLabel, classifyTransaction, clearLimits, composeTx, dailySpentToday, deriveAllowedAddressesFromPtb, deserializeCetusRoute, displayHandle, executeTx, exportPrivateKey, extractAllUserLegs, extractTransferDetails, extractTxCommands, extractTxSender, fallbackLabel, fetchAllCoins, findSwapRoute, formatAssetAmount, formatSui, formatUsd, fullHandle, generateKeypair, getAddress, getCoinMeta, getDecimals, getDecimalsForCoinType, getLimits, getSponsoredSwapProviders, getSuiClient, getSuiGrpcClient, getSwapQuote, hasLimits, isAllowedAsset, isCetusRouteFresh, isInRegistry, keypairFromPrivateKey, listModels, loadKey, looksLikeSuiNs, mapMoveAbortCode, mapWalletError, mistToSui, normalizeAddressInput, normalizeAsset, normalizeCoinType, parseSuiRpcTx, payWithMpp, preflightFail, preflightPay, preflightSend, preflightSwap, queryBalance, queryHistory, queryTransaction, rawToStable, rawToUsdc, readLimitsFile, recordDailySpend, refineLendingLabel, resolveAddressToSuinsViaRpc, resolveSuinsViaRpc, resolveSymbol, resolveTokenType, saveBech32, saveKey, selectAndSplitCoin, selectSuiCoin, serializeCetusRoute, setLimits, simulateTransaction, stableToRaw, suiToMist, throwIfSimulationFailed, truncateAddress, usdcToRaw, validateAddress, validateLabel, verifyCetusRouteCoinMatch, walletExists, writeLimitsFile };
2909
3061
  //# sourceMappingURL=index.js.map
2910
3062
  //# sourceMappingURL=index.js.map