@t2000/sdk 8.0.0 → 8.0.2
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.cjs +24 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +24 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -17,7 +17,7 @@ interface ChatMessage {
|
|
|
17
17
|
interface ChatParams {
|
|
18
18
|
model: string;
|
|
19
19
|
messages: ChatMessage[];
|
|
20
|
-
/** Private
|
|
20
|
+
/** Private Inference key (`sk-…`). Falls back to `T2000_API_KEY` env. */
|
|
21
21
|
apiKey?: string;
|
|
22
22
|
/** Override the API base (default `api.t2000.ai/v1`; e.g. for testing). */
|
|
23
23
|
apiBase?: string;
|
|
@@ -58,7 +58,7 @@ declare function chatCompletion(params: ChatParams): Promise<ChatResult>;
|
|
|
58
58
|
declare function chatCompletionStream(params: ChatParams): AsyncGenerator<string, {
|
|
59
59
|
receiptId?: string;
|
|
60
60
|
}, unknown>;
|
|
61
|
-
/** List
|
|
61
|
+
/** List Private Inference model catalog (`GET /v1/models`). The key is sent when
|
|
62
62
|
* available but not required (the catalog may be public). */
|
|
63
63
|
declare function listModels(opts?: {
|
|
64
64
|
apiKey?: string;
|
|
@@ -276,14 +276,14 @@ declare class T2000 extends EventEmitter<T2000Events> {
|
|
|
276
276
|
/** Transaction signer (works for both keypair and zkLogin). */
|
|
277
277
|
get signer(): TransactionSigner;
|
|
278
278
|
pay(options: PayOptions): Promise<PayResult>;
|
|
279
|
-
/** Non-streaming chat completion against
|
|
279
|
+
/** Non-streaming chat completion against Private Inference. */
|
|
280
280
|
chat(params: ChatParams): Promise<ChatResult>;
|
|
281
281
|
/** Streaming chat completion — async-iterate the assistant text deltas;
|
|
282
282
|
* the generator returns `{ receiptId }` (confidential attestation) at the end. */
|
|
283
283
|
chatStream(params: ChatParams): AsyncGenerator<string, {
|
|
284
284
|
receiptId?: string;
|
|
285
285
|
}, unknown>;
|
|
286
|
-
/** The Private
|
|
286
|
+
/** The Private Inference model catalog (`GET /v1/models`). */
|
|
287
287
|
models(opts?: {
|
|
288
288
|
apiKey?: string;
|
|
289
289
|
apiBase?: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ interface ChatMessage {
|
|
|
17
17
|
interface ChatParams {
|
|
18
18
|
model: string;
|
|
19
19
|
messages: ChatMessage[];
|
|
20
|
-
/** Private
|
|
20
|
+
/** Private Inference key (`sk-…`). Falls back to `T2000_API_KEY` env. */
|
|
21
21
|
apiKey?: string;
|
|
22
22
|
/** Override the API base (default `api.t2000.ai/v1`; e.g. for testing). */
|
|
23
23
|
apiBase?: string;
|
|
@@ -58,7 +58,7 @@ declare function chatCompletion(params: ChatParams): Promise<ChatResult>;
|
|
|
58
58
|
declare function chatCompletionStream(params: ChatParams): AsyncGenerator<string, {
|
|
59
59
|
receiptId?: string;
|
|
60
60
|
}, unknown>;
|
|
61
|
-
/** List
|
|
61
|
+
/** List Private Inference model catalog (`GET /v1/models`). The key is sent when
|
|
62
62
|
* available but not required (the catalog may be public). */
|
|
63
63
|
declare function listModels(opts?: {
|
|
64
64
|
apiKey?: string;
|
|
@@ -276,14 +276,14 @@ declare class T2000 extends EventEmitter<T2000Events> {
|
|
|
276
276
|
/** Transaction signer (works for both keypair and zkLogin). */
|
|
277
277
|
get signer(): TransactionSigner;
|
|
278
278
|
pay(options: PayOptions): Promise<PayResult>;
|
|
279
|
-
/** Non-streaming chat completion against
|
|
279
|
+
/** Non-streaming chat completion against Private Inference. */
|
|
280
280
|
chat(params: ChatParams): Promise<ChatResult>;
|
|
281
281
|
/** Streaming chat completion — async-iterate the assistant text deltas;
|
|
282
282
|
* the generator returns `{ receiptId }` (confidential attestation) at the end. */
|
|
283
283
|
chatStream(params: ChatParams): AsyncGenerator<string, {
|
|
284
284
|
receiptId?: string;
|
|
285
285
|
}, unknown>;
|
|
286
|
-
/** The Private
|
|
286
|
+
/** The Private Inference model catalog (`GET /v1/models`). */
|
|
287
287
|
models(opts?: {
|
|
288
288
|
apiKey?: string;
|
|
289
289
|
apiBase?: string;
|
package/dist/index.js
CHANGED
|
@@ -11,6 +11,7 @@ import { decodeSuiPrivateKey } from '@mysten/sui/cryptography';
|
|
|
11
11
|
import { access, mkdir, writeFile, readFile } from 'fs/promises';
|
|
12
12
|
import { join, dirname, resolve } from 'path';
|
|
13
13
|
import { homedir } from 'os';
|
|
14
|
+
import { ed25519 } from '@noble/curves/ed25519';
|
|
14
15
|
import { secp256k1 } from '@noble/curves/secp256k1';
|
|
15
16
|
import { sha256 } from '@noble/hashes/sha256';
|
|
16
17
|
import { hexToBytes, bytesToHex } from '@noble/hashes/utils';
|
|
@@ -1896,7 +1897,7 @@ function resolveApiKey(apiKey) {
|
|
|
1896
1897
|
if (!key) {
|
|
1897
1898
|
throw new T2000Error(
|
|
1898
1899
|
"INVALID_KEY",
|
|
1899
|
-
"No Private
|
|
1900
|
+
"No Private Inference key. Pass `apiKey` or set T2000_API_KEY. Generate one at agents.t2000.ai/manage."
|
|
1900
1901
|
);
|
|
1901
1902
|
}
|
|
1902
1903
|
return key;
|
|
@@ -2074,7 +2075,24 @@ function jcs(value) {
|
|
|
2074
2075
|
function verifyReceiptSignature(receipt, signingKeyHex) {
|
|
2075
2076
|
try {
|
|
2076
2077
|
const sig = receipt.signature;
|
|
2077
|
-
if (sig?.
|
|
2078
|
+
if (!sig?.value) {
|
|
2079
|
+
return false;
|
|
2080
|
+
}
|
|
2081
|
+
const endorsed = hexToBytes(signingKeyHex.replace(/^0x/, ""));
|
|
2082
|
+
const sigBytes = hexToBytes(sig.value);
|
|
2083
|
+
if (sig.algo === "ed25519") {
|
|
2084
|
+
if (sigBytes.length !== 64 || endorsed.length !== 32) {
|
|
2085
|
+
return false;
|
|
2086
|
+
}
|
|
2087
|
+
const { value: _omitted, ...sigRest } = sig;
|
|
2088
|
+
const canonical2 = {
|
|
2089
|
+
...receipt,
|
|
2090
|
+
signature: sigRest
|
|
2091
|
+
};
|
|
2092
|
+
const msg = new TextEncoder().encode(jcs(canonical2));
|
|
2093
|
+
return ed25519.verify(sigBytes, msg, endorsed);
|
|
2094
|
+
}
|
|
2095
|
+
if (sig.algo !== "ecdsa-secp256k1") {
|
|
2078
2096
|
return false;
|
|
2079
2097
|
}
|
|
2080
2098
|
const canonical = {
|
|
@@ -2090,7 +2108,6 @@ function verifyReceiptSignature(receipt, signingKeyHex) {
|
|
|
2090
2108
|
signature: { algo: sig.algo, key_id: sig.key_id ?? "" }
|
|
2091
2109
|
};
|
|
2092
2110
|
const prehash = sha256(new TextEncoder().encode(jcs(canonical)));
|
|
2093
|
-
const sigBytes = hexToBytes(sig.value);
|
|
2094
2111
|
if (sigBytes.length !== 65) {
|
|
2095
2112
|
return false;
|
|
2096
2113
|
}
|
|
@@ -2102,8 +2119,7 @@ function verifyReceiptSignature(receipt, signingKeyHex) {
|
|
|
2102
2119
|
return false;
|
|
2103
2120
|
}
|
|
2104
2121
|
const recovered = secp256k1.Signature.fromCompact(sigBytes.slice(0, 64)).addRecoveryBit(v).recoverPublicKey(prehash).toHex(false);
|
|
2105
|
-
|
|
2106
|
-
return recovered.toLowerCase() === endorsed.toLowerCase();
|
|
2122
|
+
return recovered.toLowerCase() === bytesToHex(endorsed).toLowerCase();
|
|
2107
2123
|
} catch {
|
|
2108
2124
|
return false;
|
|
2109
2125
|
}
|
|
@@ -2607,9 +2623,9 @@ var T2000 = class _T2000 extends EventEmitter {
|
|
|
2607
2623
|
//
|
|
2608
2624
|
// Inference as a wallet verb — the agent's brain + wallet in one package.
|
|
2609
2625
|
// Key-based today (`apiKey` / `T2000_API_KEY`); the x402 no-key pay-per-call
|
|
2610
|
-
// path is a later add. The model runs on
|
|
2626
|
+
// path is a later add. The model runs on t2000 Private Inference (ZDR; a
|
|
2611
2627
|
// `phala/*` confidential tier runs in a GPU-TEE).
|
|
2612
|
-
/** Non-streaming chat completion against
|
|
2628
|
+
/** Non-streaming chat completion against Private Inference. */
|
|
2613
2629
|
async chat(params) {
|
|
2614
2630
|
return chatCompletion(params);
|
|
2615
2631
|
}
|
|
@@ -2618,7 +2634,7 @@ var T2000 = class _T2000 extends EventEmitter {
|
|
|
2618
2634
|
chatStream(params) {
|
|
2619
2635
|
return chatCompletionStream(params);
|
|
2620
2636
|
}
|
|
2621
|
-
/** The Private
|
|
2637
|
+
/** The Private Inference model catalog (`GET /v1/models`). */
|
|
2622
2638
|
async models(opts) {
|
|
2623
2639
|
return listModels(opts);
|
|
2624
2640
|
}
|