@t2000/sdk 10.16.1 → 10.17.1
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/README.md +1 -1
- package/dist/browser.cjs +0 -17
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.js +0 -17
- package/dist/browser.js.map +1 -1
- package/dist/index.cjs +2 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -19
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -9,7 +9,7 @@ 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.
|
|
12
|
+
declare const DEFAULT_API_BASE = "https://api.audric.ai/v1";
|
|
13
13
|
interface ChatMessage {
|
|
14
14
|
role: 'system' | 'user' | 'assistant';
|
|
15
15
|
content: string;
|
|
@@ -19,7 +19,7 @@ interface ChatParams {
|
|
|
19
19
|
messages: ChatMessage[];
|
|
20
20
|
/** Private Inference key (`sk-…`). Falls back to `T2000_API_KEY` env. */
|
|
21
21
|
apiKey?: string;
|
|
22
|
-
/** Override the API base (default `api.
|
|
22
|
+
/** Override the API base (default `api.audric.ai/v1`; e.g. for testing). */
|
|
23
23
|
apiBase?: string;
|
|
24
24
|
maxTokens?: number;
|
|
25
25
|
temperature?: number;
|
|
@@ -108,7 +108,7 @@ interface VerifyResult {
|
|
|
108
108
|
anchor?: VerifyAnchor;
|
|
109
109
|
}
|
|
110
110
|
interface VerifyOptions {
|
|
111
|
-
/** Override the API base (default `api.
|
|
111
|
+
/** Override the API base (default `api.audric.ai/v1`). */
|
|
112
112
|
apiBase?: string;
|
|
113
113
|
/** Sui network for the trustless anchor read (default `mainnet`). */
|
|
114
114
|
network?: 'mainnet' | 'testnet';
|
package/dist/index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ 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.
|
|
12
|
+
declare const DEFAULT_API_BASE = "https://api.audric.ai/v1";
|
|
13
13
|
interface ChatMessage {
|
|
14
14
|
role: 'system' | 'user' | 'assistant';
|
|
15
15
|
content: string;
|
|
@@ -19,7 +19,7 @@ interface ChatParams {
|
|
|
19
19
|
messages: ChatMessage[];
|
|
20
20
|
/** Private Inference key (`sk-…`). Falls back to `T2000_API_KEY` env. */
|
|
21
21
|
apiKey?: string;
|
|
22
|
-
/** Override the API base (default `api.
|
|
22
|
+
/** Override the API base (default `api.audric.ai/v1`; e.g. for testing). */
|
|
23
23
|
apiBase?: string;
|
|
24
24
|
maxTokens?: number;
|
|
25
25
|
temperature?: number;
|
|
@@ -108,7 +108,7 @@ interface VerifyResult {
|
|
|
108
108
|
anchor?: VerifyAnchor;
|
|
109
109
|
}
|
|
110
110
|
interface VerifyOptions {
|
|
111
|
-
/** Override the API base (default `api.
|
|
111
|
+
/** Override the API base (default `api.audric.ai/v1`). */
|
|
112
112
|
apiBase?: string;
|
|
113
113
|
/** Sui network for the trustless anchor read (default `mainnet`). */
|
|
114
114
|
network?: 'mainnet' | 'testnet';
|
package/dist/index.js
CHANGED
|
@@ -1163,7 +1163,6 @@ async function payWithMpp(args) {
|
|
|
1163
1163
|
}
|
|
1164
1164
|
assertNotSelfPayment(signer.getAddress(), requirements.payTo);
|
|
1165
1165
|
const result = await payViaX402({ signer, client, options, reqInit, requirements });
|
|
1166
|
-
await reportDirectPayment(result, options.url);
|
|
1167
1166
|
return result;
|
|
1168
1167
|
}
|
|
1169
1168
|
const headerChallenge = await parseMppSuiChallenge(probe);
|
|
@@ -1177,7 +1176,6 @@ async function payWithMpp(args) {
|
|
|
1177
1176
|
}
|
|
1178
1177
|
assertNotSelfPayment(signer.getAddress(), headerChallenge.recipient);
|
|
1179
1178
|
const result = await payViaMppHeader({ signer, client, options });
|
|
1180
|
-
await reportDirectPayment(result, options.url);
|
|
1181
1179
|
return result;
|
|
1182
1180
|
}
|
|
1183
1181
|
if (pick.kind === "incomplete") {
|
|
@@ -1192,21 +1190,6 @@ async function payWithMpp(args) {
|
|
|
1192
1190
|
`Endpoint returned 402 without an x402 'exact' / sui:${client.network} requirement in the body or an MPP 'sui' challenge in WWW-Authenticate. Nothing this SDK can pay.`
|
|
1193
1191
|
);
|
|
1194
1192
|
}
|
|
1195
|
-
var MPP_REPORT_URL = "https://mpp.t2000.ai/api/mpp/report";
|
|
1196
|
-
var REPORT_TIMEOUT_MS = 2e3;
|
|
1197
|
-
async function reportDirectPayment(result, url) {
|
|
1198
|
-
if (!result.paid || !result.receipt?.reference) return;
|
|
1199
|
-
try {
|
|
1200
|
-
if (new URL(url).origin === new URL(MPP_REPORT_URL).origin) return;
|
|
1201
|
-
await fetch(MPP_REPORT_URL, {
|
|
1202
|
-
method: "POST",
|
|
1203
|
-
headers: { "content-type": "application/json" },
|
|
1204
|
-
body: JSON.stringify({ digest: result.receipt.reference, url }),
|
|
1205
|
-
signal: AbortSignal.timeout(REPORT_TIMEOUT_MS)
|
|
1206
|
-
});
|
|
1207
|
-
} catch {
|
|
1208
|
-
}
|
|
1209
|
-
}
|
|
1210
1193
|
async function parseMppSuiChallenge(response) {
|
|
1211
1194
|
try {
|
|
1212
1195
|
const { Challenge } = await import('mppx');
|
|
@@ -2097,7 +2080,7 @@ init_errors();
|
|
|
2097
2080
|
|
|
2098
2081
|
// src/inference.ts
|
|
2099
2082
|
init_errors();
|
|
2100
|
-
var DEFAULT_API_BASE = "https://api.
|
|
2083
|
+
var DEFAULT_API_BASE = "https://api.audric.ai/v1";
|
|
2101
2084
|
function envApiKey() {
|
|
2102
2085
|
return typeof process !== "undefined" ? process.env?.T2000_API_KEY : void 0;
|
|
2103
2086
|
}
|
|
@@ -2106,7 +2089,7 @@ function resolveApiKey(apiKey) {
|
|
|
2106
2089
|
if (!key) {
|
|
2107
2090
|
throw new T2000Error(
|
|
2108
2091
|
"INVALID_KEY",
|
|
2109
|
-
"No Private Inference key. Pass `apiKey` or set T2000_API_KEY. Generate one at
|
|
2092
|
+
"No Private Inference key. Pass `apiKey` or set T2000_API_KEY. Generate one at audric.ai (minting requires $5 of credit)."
|
|
2110
2093
|
);
|
|
2111
2094
|
}
|
|
2112
2095
|
return key;
|