@t2000/sdk 5.15.1 → 5.17.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
@@ -33,6 +33,9 @@ interface ChatResult {
33
33
  content: string;
34
34
  model: string;
35
35
  usage?: ChatUsage;
36
+ /** Confidential calls (`phala/*`) return a TEE attestation receipt id —
37
+ * fetch + verify it at `/v1/aci/receipts/{id}`. Absent for ZDR models. */
38
+ receiptId?: string;
36
39
  /** The verbatim OpenAI-shaped response body. */
37
40
  raw: unknown;
38
41
  }
@@ -49,7 +52,9 @@ interface ApiModel {
49
52
  declare function chatCompletion(params: ChatParams): Promise<ChatResult>;
50
53
  /** Streaming chat completion — yields assistant text deltas as they arrive
51
54
  * (parses the OpenAI SSE `data:` frames). */
52
- declare function chatCompletionStream(params: ChatParams): AsyncGenerator<string, void, unknown>;
55
+ declare function chatCompletionStream(params: ChatParams): AsyncGenerator<string, {
56
+ receiptId?: string;
57
+ }, unknown>;
53
58
  /** List the Private API model catalog (`GET /v1/models`). The key is sent when
54
59
  * available but not required (the catalog may be public). */
55
60
  declare function listModels(opts?: {
@@ -57,6 +62,49 @@ declare function listModels(opts?: {
57
62
  apiBase?: string;
58
63
  }): Promise<ApiModel[]>;
59
64
 
65
+ type CheckStatus = 'pass' | 'fail' | 'skip';
66
+ type TrustMode = 'trustless' | 'receipt-asserted' | 'roadmap';
67
+ interface VerifyCheck {
68
+ name: string;
69
+ status: CheckStatus;
70
+ detail: string;
71
+ trust: TrustMode;
72
+ }
73
+ interface VerifyAnchor {
74
+ txDigest: string;
75
+ anchoredAtMs?: string;
76
+ anchoredBy?: string;
77
+ explorer: string;
78
+ }
79
+ interface VerifyResult {
80
+ receiptId: string;
81
+ /** True iff the receipt resolved AND its on-chain Sui anchor matches. */
82
+ verified: boolean;
83
+ /** The trustless core: an on-chain ReceiptAnchored event matches the receipt. */
84
+ anchorVerified: boolean;
85
+ checks: VerifyCheck[];
86
+ wireHash?: string;
87
+ workloadId?: string;
88
+ upstream?: {
89
+ provider?: string;
90
+ result?: string;
91
+ tcbStatus?: string;
92
+ };
93
+ anchor?: VerifyAnchor;
94
+ }
95
+ interface VerifyOptions {
96
+ /** Override the API base (default `api.t2000.ai/v1`). */
97
+ apiBase?: string;
98
+ /** Sui network for the trustless anchor read (default `mainnet`). */
99
+ network?: 'mainnet' | 'testnet';
100
+ }
101
+ /**
102
+ * Verify a confidential response by its receipt id. Reads the signed receipt
103
+ * (public), its on-chain Sui anchor (trustless), and reports a per-check result
104
+ * that FAILS CLOSED on any forgery or mismatch.
105
+ */
106
+ declare function verifyReceipt(receiptId: string, opts?: VerifyOptions): Promise<VerifyResult>;
107
+
60
108
  interface LimitsConfig {
61
109
  /** Caps any single outbound write (send | swap | pay) by USD value. */
62
110
  perTxUsd?: number;
@@ -210,13 +258,19 @@ declare class T2000 extends EventEmitter<T2000Events> {
210
258
  pay(options: PayOptions): Promise<PayResult>;
211
259
  /** Non-streaming chat completion against the Private API. */
212
260
  chat(params: ChatParams): Promise<ChatResult>;
213
- /** Streaming chat completion — async-iterate the assistant text deltas. */
214
- chatStream(params: ChatParams): AsyncGenerator<string, void, unknown>;
261
+ /** Streaming chat completion — async-iterate the assistant text deltas;
262
+ * the generator returns `{ receiptId }` (confidential attestation) at the end. */
263
+ chatStream(params: ChatParams): AsyncGenerator<string, {
264
+ receiptId?: string;
265
+ }, unknown>;
215
266
  /** The Private API model catalog (`GET /v1/models`). */
216
267
  models(opts?: {
217
268
  apiKey?: string;
218
269
  apiBase?: string;
219
270
  }): Promise<ApiModel[]>;
271
+ /** Verify a confidential response by receipt id — checks the signed receipt
272
+ * + its trustless on-chain Sui anchor. Fails closed on any mismatch. */
273
+ verify(receiptId: string, opts?: VerifyOptions): Promise<VerifyResult>;
220
274
  swap(params: {
221
275
  from: string;
222
276
  to: string;
@@ -1013,4 +1067,4 @@ declare function fullHandle(label: string, parentName?: string): string;
1013
1067
  */
1014
1068
  declare function displayHandle(label: string, parentName?: string): string;
1015
1069
 
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 };
1070
+ 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 CheckStatus, 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, type TrustMode, type VerifyAnchor, type VerifyCheck, type VerifyOptions, type VerifyResult, 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, verifyReceipt, walletExists, writeLimitsFile };
package/dist/index.d.ts CHANGED
@@ -33,6 +33,9 @@ interface ChatResult {
33
33
  content: string;
34
34
  model: string;
35
35
  usage?: ChatUsage;
36
+ /** Confidential calls (`phala/*`) return a TEE attestation receipt id —
37
+ * fetch + verify it at `/v1/aci/receipts/{id}`. Absent for ZDR models. */
38
+ receiptId?: string;
36
39
  /** The verbatim OpenAI-shaped response body. */
37
40
  raw: unknown;
38
41
  }
@@ -49,7 +52,9 @@ interface ApiModel {
49
52
  declare function chatCompletion(params: ChatParams): Promise<ChatResult>;
50
53
  /** Streaming chat completion — yields assistant text deltas as they arrive
51
54
  * (parses the OpenAI SSE `data:` frames). */
52
- declare function chatCompletionStream(params: ChatParams): AsyncGenerator<string, void, unknown>;
55
+ declare function chatCompletionStream(params: ChatParams): AsyncGenerator<string, {
56
+ receiptId?: string;
57
+ }, unknown>;
53
58
  /** List the Private API model catalog (`GET /v1/models`). The key is sent when
54
59
  * available but not required (the catalog may be public). */
55
60
  declare function listModels(opts?: {
@@ -57,6 +62,49 @@ declare function listModels(opts?: {
57
62
  apiBase?: string;
58
63
  }): Promise<ApiModel[]>;
59
64
 
65
+ type CheckStatus = 'pass' | 'fail' | 'skip';
66
+ type TrustMode = 'trustless' | 'receipt-asserted' | 'roadmap';
67
+ interface VerifyCheck {
68
+ name: string;
69
+ status: CheckStatus;
70
+ detail: string;
71
+ trust: TrustMode;
72
+ }
73
+ interface VerifyAnchor {
74
+ txDigest: string;
75
+ anchoredAtMs?: string;
76
+ anchoredBy?: string;
77
+ explorer: string;
78
+ }
79
+ interface VerifyResult {
80
+ receiptId: string;
81
+ /** True iff the receipt resolved AND its on-chain Sui anchor matches. */
82
+ verified: boolean;
83
+ /** The trustless core: an on-chain ReceiptAnchored event matches the receipt. */
84
+ anchorVerified: boolean;
85
+ checks: VerifyCheck[];
86
+ wireHash?: string;
87
+ workloadId?: string;
88
+ upstream?: {
89
+ provider?: string;
90
+ result?: string;
91
+ tcbStatus?: string;
92
+ };
93
+ anchor?: VerifyAnchor;
94
+ }
95
+ interface VerifyOptions {
96
+ /** Override the API base (default `api.t2000.ai/v1`). */
97
+ apiBase?: string;
98
+ /** Sui network for the trustless anchor read (default `mainnet`). */
99
+ network?: 'mainnet' | 'testnet';
100
+ }
101
+ /**
102
+ * Verify a confidential response by its receipt id. Reads the signed receipt
103
+ * (public), its on-chain Sui anchor (trustless), and reports a per-check result
104
+ * that FAILS CLOSED on any forgery or mismatch.
105
+ */
106
+ declare function verifyReceipt(receiptId: string, opts?: VerifyOptions): Promise<VerifyResult>;
107
+
60
108
  interface LimitsConfig {
61
109
  /** Caps any single outbound write (send | swap | pay) by USD value. */
62
110
  perTxUsd?: number;
@@ -210,13 +258,19 @@ declare class T2000 extends EventEmitter<T2000Events> {
210
258
  pay(options: PayOptions): Promise<PayResult>;
211
259
  /** Non-streaming chat completion against the Private API. */
212
260
  chat(params: ChatParams): Promise<ChatResult>;
213
- /** Streaming chat completion — async-iterate the assistant text deltas. */
214
- chatStream(params: ChatParams): AsyncGenerator<string, void, unknown>;
261
+ /** Streaming chat completion — async-iterate the assistant text deltas;
262
+ * the generator returns `{ receiptId }` (confidential attestation) at the end. */
263
+ chatStream(params: ChatParams): AsyncGenerator<string, {
264
+ receiptId?: string;
265
+ }, unknown>;
215
266
  /** The Private API model catalog (`GET /v1/models`). */
216
267
  models(opts?: {
217
268
  apiKey?: string;
218
269
  apiBase?: string;
219
270
  }): Promise<ApiModel[]>;
271
+ /** Verify a confidential response by receipt id — checks the signed receipt
272
+ * + its trustless on-chain Sui anchor. Fails closed on any mismatch. */
273
+ verify(receiptId: string, opts?: VerifyOptions): Promise<VerifyResult>;
220
274
  swap(params: {
221
275
  from: string;
222
276
  to: string;
@@ -1013,4 +1067,4 @@ declare function fullHandle(label: string, parentName?: string): string;
1013
1067
  */
1014
1068
  declare function displayHandle(label: string, parentName?: string): string;
1015
1069
 
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 };
1070
+ 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 CheckStatus, 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, type TrustMode, type VerifyAnchor, type VerifyCheck, type VerifyOptions, type VerifyResult, 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, verifyReceipt, walletExists, writeLimitsFile };
package/dist/index.js CHANGED
@@ -1220,10 +1220,10 @@ async function finalize(response, opts) {
1220
1220
  return { status: response.status, body: body2, paid: opts.paid };
1221
1221
  }
1222
1222
  async function makeGrpcBuildClient(client) {
1223
- const { SuiGrpcClient: SuiGrpcClient2 } = await import('@mysten/sui/grpc');
1223
+ const { SuiGrpcClient: SuiGrpcClient3 } = await import('@mysten/sui/grpc');
1224
1224
  const network = client.network === "testnet" ? "testnet" : "mainnet";
1225
1225
  const baseUrl = network === "testnet" ? "https://fullnode.testnet.sui.io" : "https://fullnode.mainnet.sui.io";
1226
- return new SuiGrpcClient2({ baseUrl, network });
1226
+ return new SuiGrpcClient3({ baseUrl, network });
1227
1227
  }
1228
1228
  function atomicToHuman(raw, decimals) {
1229
1229
  return Number(raw) / 10 ** decimals;
@@ -1928,7 +1928,9 @@ function body(params, stream) {
1928
1928
  return JSON.stringify({
1929
1929
  model: params.model,
1930
1930
  messages: params.messages,
1931
- ...stream ? { stream: true } : {},
1931
+ // include_usage the final stream chunk carries usage + x_receipt_id
1932
+ // (the confidential attestation receipt) so we can surface it after a stream.
1933
+ ...stream ? { stream: true, stream_options: { include_usage: true } } : {},
1932
1934
  ...params.maxTokens != null ? { max_tokens: params.maxTokens } : {},
1933
1935
  ...params.temperature != null ? { temperature: params.temperature } : {}
1934
1936
  });
@@ -1944,12 +1946,14 @@ async function chatCompletion(params) {
1944
1946
  if (!res.ok) {
1945
1947
  await failBody(res);
1946
1948
  }
1949
+ const receiptId = res.headers.get("x-receipt-id") ?? void 0;
1947
1950
  const raw = await res.json();
1948
1951
  const content = raw?.choices?.[0]?.message?.content ?? "";
1949
1952
  return {
1950
1953
  content,
1951
1954
  model: raw?.model ?? params.model,
1952
1955
  usage: usageOf(raw),
1956
+ receiptId,
1953
1957
  raw
1954
1958
  };
1955
1959
  }
@@ -1963,11 +1967,12 @@ async function* chatCompletionStream(params) {
1963
1967
  });
1964
1968
  if (!(res.ok && res.body)) {
1965
1969
  await failBody(res);
1966
- return;
1970
+ return {};
1967
1971
  }
1968
1972
  const reader = res.body.getReader();
1969
1973
  const decoder = new TextDecoder();
1970
1974
  let buffer = "";
1975
+ let receiptId;
1971
1976
  while (true) {
1972
1977
  const { done, value } = await reader.read();
1973
1978
  if (done) {
@@ -1983,10 +1988,13 @@ async function* chatCompletionStream(params) {
1983
1988
  }
1984
1989
  const data = trimmed.slice(5).trim();
1985
1990
  if (data === "[DONE]") {
1986
- return;
1991
+ return { receiptId };
1987
1992
  }
1988
1993
  try {
1989
1994
  const json = JSON.parse(data);
1995
+ if (json.x_receipt_id) {
1996
+ receiptId = json.x_receipt_id;
1997
+ }
1990
1998
  const delta = json.choices?.[0]?.delta?.content;
1991
1999
  if (typeof delta === "string" && delta) {
1992
2000
  yield delta;
@@ -1995,6 +2003,7 @@ async function* chatCompletionStream(params) {
1995
2003
  }
1996
2004
  }
1997
2005
  }
2006
+ return { receiptId };
1998
2007
  }
1999
2008
  async function listModels(opts) {
2000
2009
  const base = opts?.apiBase ?? DEFAULT_API_BASE;
@@ -2015,6 +2024,124 @@ async function listModels(opts) {
2015
2024
  privacy: m.privacy ?? m.privacy_tier
2016
2025
  }));
2017
2026
  }
2027
+ var RECEIPT_ANCHORED_SUFFIX = "::anchor::ReceiptAnchored";
2028
+ function fullnodeUrl(network) {
2029
+ return network === "testnet" ? "https://fullnode.testnet.sui.io" : "https://fullnode.mainnet.sui.io";
2030
+ }
2031
+ async function verifyReceipt(receiptId, opts = {}) {
2032
+ const base = opts.apiBase ?? DEFAULT_API_BASE;
2033
+ const network = opts.network ?? "mainnet";
2034
+ const checks = [];
2035
+ let receipt = null;
2036
+ try {
2037
+ const res = await fetch(`${base}/aci/receipts/${encodeURIComponent(receiptId)}`);
2038
+ if (res.ok) {
2039
+ receipt = await res.json();
2040
+ }
2041
+ } catch {
2042
+ }
2043
+ if (!receipt?.event_log) {
2044
+ checks.push({
2045
+ name: "Receipt",
2046
+ status: "fail",
2047
+ detail: "receipt not found or malformed",
2048
+ trust: "receipt-asserted"
2049
+ });
2050
+ return { receiptId, verified: false, anchorVerified: false, checks };
2051
+ }
2052
+ const wireHash = receipt.event_log.find((e) => e.type === "response.returned")?.wire_hash;
2053
+ const workloadId = receipt.workload_id;
2054
+ checks.push({
2055
+ name: "Receipt",
2056
+ status: wireHash && workloadId ? "pass" : "fail",
2057
+ detail: wireHash ? `well-formed (${receipt.event_log.length} log entries, workload ${workloadId})` : "missing response wire_hash / workload_id",
2058
+ trust: "receipt-asserted"
2059
+ });
2060
+ const upstreamEv = receipt.event_log.find((e) => e.type === "upstream.verified");
2061
+ const upstreamOk = upstreamEv?.result === "verified";
2062
+ checks.push({
2063
+ name: "Confidential upstream",
2064
+ status: upstreamEv ? upstreamOk ? "pass" : "fail" : "skip",
2065
+ detail: upstreamEv ? `${upstreamEv.provider ?? upstreamEv.upstream_name ?? "upstream"}: ${upstreamEv.result ?? "unknown"}${upstreamEv.tcb_status ? ` (TCB ${upstreamEv.tcb_status})` : ""}` : "no upstream.verified event (routed/non-confidential?)",
2066
+ trust: "receipt-asserted"
2067
+ });
2068
+ let anchorVerified = false;
2069
+ let anchor;
2070
+ let digest;
2071
+ try {
2072
+ const res = await fetch(`${base}/aci/anchor/${encodeURIComponent(receiptId)}`);
2073
+ if (res.ok) {
2074
+ const j = await res.json();
2075
+ digest = j.txDigest;
2076
+ }
2077
+ } catch {
2078
+ }
2079
+ if (!digest) {
2080
+ checks.push({
2081
+ name: "Sui anchor",
2082
+ status: "fail",
2083
+ detail: `no anchor on record \u2014 POST ${base}/aci/anchor/${receiptId} to create one`,
2084
+ trust: "trustless"
2085
+ });
2086
+ } else {
2087
+ try {
2088
+ const client = new SuiGrpcClient({ baseUrl: fullnodeUrl(network), network });
2089
+ const tx = await client.core.getTransaction({
2090
+ digest,
2091
+ include: { events: true }
2092
+ });
2093
+ const txn = tx.$kind === "Transaction" ? tx.Transaction : tx.FailedTransaction;
2094
+ const ev = (txn.events ?? []).find(
2095
+ (e) => e.eventType.endsWith(RECEIPT_ANCHORED_SUFFIX)
2096
+ );
2097
+ const data = ev?.json ?? {};
2098
+ const onChainReceipt = String(data.receipt_id ?? "");
2099
+ const onChainWire = String(data.wire_hash ?? "");
2100
+ const onChainWorkload = String(data.workload_id ?? "");
2101
+ const matches = onChainReceipt === receiptId && onChainWire === wireHash && onChainWorkload === workloadId;
2102
+ anchorVerified = matches;
2103
+ anchor = {
2104
+ txDigest: digest,
2105
+ anchoredAtMs: data.anchored_at_ms ? String(data.anchored_at_ms) : void 0,
2106
+ anchoredBy: data.anchored_by ? String(data.anchored_by) : void 0,
2107
+ explorer: `https://suiscan.xyz/${network}/tx/${digest}`
2108
+ };
2109
+ checks.push({
2110
+ name: "Sui anchor",
2111
+ status: matches ? "pass" : "fail",
2112
+ detail: matches ? `on-chain ReceiptAnchored matches (wire_hash + workload_id), tx ${digest}` : `on-chain event does NOT match the receipt (wire ${onChainWire || "absent"})`,
2113
+ trust: "trustless"
2114
+ });
2115
+ } catch (e) {
2116
+ checks.push({
2117
+ name: "Sui anchor",
2118
+ status: "fail",
2119
+ detail: `could not read anchor tx ${digest}: ${e instanceof Error ? e.message : "error"}`,
2120
+ trust: "trustless"
2121
+ });
2122
+ }
2123
+ }
2124
+ checks.push({
2125
+ name: "Receipt signature",
2126
+ status: "skip",
2127
+ detail: receipt.signature ? "present (local recompute via RedPill keyset canonicalization = roadmap)" : "no signature on receipt",
2128
+ trust: "roadmap"
2129
+ });
2130
+ return {
2131
+ receiptId,
2132
+ verified: Boolean(wireHash && workloadId) && anchorVerified,
2133
+ anchorVerified,
2134
+ checks,
2135
+ wireHash,
2136
+ workloadId,
2137
+ upstream: upstreamEv ? {
2138
+ provider: upstreamEv.provider ?? upstreamEv.upstream_name,
2139
+ result: upstreamEv.result,
2140
+ tcbStatus: upstreamEv.tcb_status
2141
+ } : void 0,
2142
+ anchor
2143
+ };
2144
+ }
2018
2145
  var DEFAULT_CONFIG_DIR = join(homedir(), ".t2000");
2019
2146
  function resolveConfigPath(configDir) {
2020
2147
  return join(configDir ?? DEFAULT_CONFIG_DIR, "config.json");
@@ -2291,7 +2418,8 @@ var T2000 = class _T2000 extends EventEmitter {
2291
2418
  async chat(params) {
2292
2419
  return chatCompletion(params);
2293
2420
  }
2294
- /** Streaming chat completion — async-iterate the assistant text deltas. */
2421
+ /** Streaming chat completion — async-iterate the assistant text deltas;
2422
+ * the generator returns `{ receiptId }` (confidential attestation) at the end. */
2295
2423
  chatStream(params) {
2296
2424
  return chatCompletionStream(params);
2297
2425
  }
@@ -2299,6 +2427,11 @@ var T2000 = class _T2000 extends EventEmitter {
2299
2427
  async models(opts) {
2300
2428
  return listModels(opts);
2301
2429
  }
2430
+ /** Verify a confidential response by receipt id — checks the signed receipt
2431
+ * + its trustless on-chain Sui anchor. Fails closed on any mismatch. */
2432
+ async verify(receiptId, opts) {
2433
+ return verifyReceipt(receiptId, opts);
2434
+ }
2302
2435
  // -- Swap --
2303
2436
  async swap(params) {
2304
2437
  this.limits.assert({
@@ -3057,6 +3190,6 @@ function displayHandle(label, parentName = AUDRIC_PARENT_NAME) {
3057
3190
  // src/index.ts
3058
3191
  init_preflight();
3059
3192
 
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 };
3193
+ 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, verifyReceipt, walletExists, writeLimitsFile };
3061
3194
  //# sourceMappingURL=index.js.map
3062
3195
  //# sourceMappingURL=index.js.map