@hightop/sdk 0.1.5 → 0.1.7
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/client.d.ts +2 -1
- package/dist/client.js +5 -1
- package/dist/generated/agent-api.d.ts +46 -2
- package/dist/generated/agent-api.js +18 -2
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type AgentApiAccountResponse, type AgentApiBalancesResponse, type AgentApiBorrowRepayRequest, type AgentApiBorrowResponse, type AgentApiCapabilitiesResponse, type AgentApiConversionExecuteRequest, type AgentApiConversionQuoteRequest, type AgentApiConversionQuoteResponse, type AgentApiDeleverageRequest, type AgentApiEndpointKey, type AgentApiError, type AgentApiHttpMethod, type AgentApiOperationDetailQuery, type AgentApiOperationResponse, type AgentApiOperationsQuery, type AgentApiOperationsResponse, type AgentApiPathParamValue, type AgentApiRequestFor, type AgentApiResponseFor, type AgentApiSelfResponse, type AgentApiSelfUsageResponse, type AgentApiSimulateRequest, type AgentApiSimulateResponse, type AgentApiWriteResponse, type AgentApiX402PurchaseRequest, type AgentApiX402PurchaseResponse, type AgentApiX402QuoteRequest, type AgentApiX402QuoteResponse, type AgentApiX402SignRequest, type AgentApiX402SignResponse } from './generated/agent-api.js';
|
|
1
|
+
import { type AgentApiAccountResponse, type AgentApiBalancesResponse, type AgentApiBorrowRepayRequest, type AgentApiBorrowResponse, type AgentApiCapabilitiesResponse, type AgentApiConversionExecuteRequest, type AgentApiConversionQuoteRequest, type AgentApiConversionQuoteResponse, type AgentApiDeleverageRequest, type AgentApiEndpointKey, type AgentApiError, type AgentApiHttpMethod, type AgentApiOperationDetailQuery, type AgentApiOperationResponse, type AgentApiOperationsQuery, type AgentApiOperationsResponse, type AgentApiPathParamValue, type AgentApiRequestFor, type AgentApiResponseFor, type AgentApiSelfLimitsResponse, type AgentApiSelfResponse, type AgentApiSelfUsageResponse, type AgentApiSimulateRequest, type AgentApiSimulateResponse, type AgentApiWriteResponse, type AgentApiX402PurchaseRequest, type AgentApiX402PurchaseResponse, type AgentApiX402QuoteRequest, type AgentApiX402QuoteResponse, type AgentApiX402SignRequest, type AgentApiX402SignResponse } from './generated/agent-api.js';
|
|
2
2
|
type FetchLike = typeof fetch;
|
|
3
3
|
export type HightopAgentClientConfig = {
|
|
4
4
|
baseUrl?: string;
|
|
@@ -47,6 +47,7 @@ export declare class HightopAgentClient {
|
|
|
47
47
|
constructor(config: HightopAgentClientConfig);
|
|
48
48
|
readonly self: {
|
|
49
49
|
get: (options?: HightopAgentRequestOptions) => Promise<AgentApiSelfResponse>;
|
|
50
|
+
limits: (options?: HightopAgentRequestOptions) => Promise<AgentApiSelfLimitsResponse>;
|
|
50
51
|
usage: (options?: HightopAgentRequestOptions) => Promise<AgentApiSelfUsageResponse>;
|
|
51
52
|
};
|
|
52
53
|
readonly capabilities: {
|
package/dist/client.js
CHANGED
|
@@ -159,6 +159,7 @@ export class HightopAgentClient {
|
|
|
159
159
|
}
|
|
160
160
|
self = {
|
|
161
161
|
get: (options) => this.requestEndpoint('GET /v1/agent/self', undefined, options),
|
|
162
|
+
limits: (options) => this.requestEndpoint('GET /v1/agent/self/limits', undefined, options),
|
|
162
163
|
usage: (options) => this.requestEndpoint('GET /v1/agent/self/usage', undefined, options),
|
|
163
164
|
};
|
|
164
165
|
capabilities = {
|
|
@@ -230,6 +231,7 @@ export class HightopAgentClient {
|
|
|
230
231
|
while (Date.now() <= deadline) {
|
|
231
232
|
const remainingMs = Math.max(1, deadline - Date.now());
|
|
232
233
|
const pollRequestTimeoutMs = Math.min(this.timeoutMs, remainingMs);
|
|
234
|
+
const pollBoundByWaitDeadline = pollRequestTimeoutMs === remainingMs;
|
|
233
235
|
let response;
|
|
234
236
|
try {
|
|
235
237
|
response = await this.operations.get(id, undefined, {
|
|
@@ -239,7 +241,9 @@ export class HightopAgentClient {
|
|
|
239
241
|
});
|
|
240
242
|
}
|
|
241
243
|
catch (error) {
|
|
242
|
-
if (
|
|
244
|
+
if (error instanceof HightopAgentSDKError &&
|
|
245
|
+
error.code === 'request_timeout' &&
|
|
246
|
+
(pollBoundByWaitDeadline || Date.now() >= deadline)) {
|
|
243
247
|
break;
|
|
244
248
|
}
|
|
245
249
|
throw error;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const AGENT_API_CONTRACT_VERSION = "1.
|
|
1
|
+
export declare const AGENT_API_CONTRACT_VERSION = "1.7.0";
|
|
2
2
|
export type EthAddress = `0x${string}`;
|
|
3
3
|
export type AgentErrorDetailsByCode = {
|
|
4
4
|
idempotency_request_in_progress: {
|
|
@@ -121,6 +121,32 @@ export type AgentApiSelfUsageResponse = {
|
|
|
121
121
|
operations_submitted_today?: number;
|
|
122
122
|
};
|
|
123
123
|
};
|
|
124
|
+
export type AgentApiSelfLimitsResponse = {
|
|
125
|
+
ok: true;
|
|
126
|
+
spend_limits: {
|
|
127
|
+
per_tx_usd: string | null;
|
|
128
|
+
per_period_usd: string | null;
|
|
129
|
+
lifetime_usd: string | null;
|
|
130
|
+
max_txs_per_period: number | null;
|
|
131
|
+
tx_cooldown_blocks: number | null;
|
|
132
|
+
fail_on_zero_price: boolean;
|
|
133
|
+
};
|
|
134
|
+
swap_limits: {
|
|
135
|
+
max_slippage_bps: number | null;
|
|
136
|
+
max_swaps_per_period: number | null;
|
|
137
|
+
};
|
|
138
|
+
permissions: {
|
|
139
|
+
operation_types: Array<'payment' | 'conversion' | 'earn.deposit' | 'earn.withdraw' | 'earn.move' | 'earn.rewards_claim' | 'debt.borrow' | 'debt.repay' | 'debt.deleverage' | 'collateral.add' | 'collateral.remove' | 'trusted_destination.confirm' | 'trusted_destination.cancel' | 'trusted_destination.remove' | 'withdrawal.bank' | 'withdrawal.crypto' | 'one_off_payment.create'>;
|
|
140
|
+
cannot: Array<'payment' | 'conversion' | 'earn.deposit' | 'earn.withdraw' | 'earn.move' | 'earn.rewards_claim' | 'debt.borrow' | 'debt.repay' | 'debt.deleverage' | 'collateral.add' | 'collateral.remove' | 'trusted_destination.confirm' | 'trusted_destination.cancel' | 'trusted_destination.remove' | 'withdrawal.bank' | 'withdrawal.crypto' | 'one_off_payment.create'>;
|
|
141
|
+
};
|
|
142
|
+
current_usage: {
|
|
143
|
+
txs_in_period: number;
|
|
144
|
+
spent_in_period_usd: string;
|
|
145
|
+
swaps_in_period: number;
|
|
146
|
+
total_txs: number;
|
|
147
|
+
total_spent_usd: string;
|
|
148
|
+
};
|
|
149
|
+
};
|
|
124
150
|
export type AgentApiCapabilitiesResponse = {
|
|
125
151
|
ok: true;
|
|
126
152
|
api_version: '1.0';
|
|
@@ -698,6 +724,7 @@ export type AgentApiSimulateRequest = {
|
|
|
698
724
|
method: 'POST' | 'PATCH' | 'DELETE';
|
|
699
725
|
path: string;
|
|
700
726
|
body: unknown;
|
|
727
|
+
depth?: 'static' | 'policy' | 'onchain';
|
|
701
728
|
};
|
|
702
729
|
export type AgentApiSimulateResponse = {
|
|
703
730
|
ok: true;
|
|
@@ -1044,6 +1071,21 @@ export declare const agentApiEndpoints: readonly [{
|
|
|
1044
1071
|
readonly idempotencyRequired: false;
|
|
1045
1072
|
readonly routeClass: "read";
|
|
1046
1073
|
readonly description: "Return current Agent API rate-limit and usage state.";
|
|
1074
|
+
}, {
|
|
1075
|
+
readonly key: "GET /v1/agent/self/limits";
|
|
1076
|
+
readonly method: "GET";
|
|
1077
|
+
readonly path: "/v1/agent/self/limits";
|
|
1078
|
+
readonly pathParams: readonly [];
|
|
1079
|
+
readonly queryParams: readonly [];
|
|
1080
|
+
readonly bodyParams: readonly [];
|
|
1081
|
+
readonly requestSchema: null;
|
|
1082
|
+
readonly bodySchema: null;
|
|
1083
|
+
readonly responseSchema: "agentApiSelfLimitsResponse";
|
|
1084
|
+
readonly requestType: null;
|
|
1085
|
+
readonly responseType: "AgentApiSelfLimitsResponse";
|
|
1086
|
+
readonly idempotencyRequired: false;
|
|
1087
|
+
readonly routeClass: "read";
|
|
1088
|
+
readonly description: "Return effective operation permissions, spend/swap limits, and current-period usage for the authenticated agent.";
|
|
1047
1089
|
}, {
|
|
1048
1090
|
readonly key: "GET /v1/agent/capabilities";
|
|
1049
1091
|
readonly method: "GET";
|
|
@@ -1830,7 +1872,7 @@ export declare const agentApiEndpoints: readonly [{
|
|
|
1830
1872
|
readonly path: "/v1/agent/simulate";
|
|
1831
1873
|
readonly pathParams: readonly [];
|
|
1832
1874
|
readonly queryParams: readonly [];
|
|
1833
|
-
readonly bodyParams: readonly ["method", "path", "body"];
|
|
1875
|
+
readonly bodyParams: readonly ["method", "path", "body", "depth"];
|
|
1834
1876
|
readonly requestSchema: "agentApiSimulateRequest";
|
|
1835
1877
|
readonly bodySchema: "agentApiSimulateRequest";
|
|
1836
1878
|
readonly responseSchema: "agentApiSimulateResponse";
|
|
@@ -2013,6 +2055,7 @@ export type AgentApiPathParams = Record<string, AgentApiPathParamValue>;
|
|
|
2013
2055
|
export type AgentApiEndpointRequestMap = {
|
|
2014
2056
|
readonly 'GET /v1/agent/self': undefined;
|
|
2015
2057
|
readonly 'GET /v1/agent/self/usage': undefined;
|
|
2058
|
+
readonly 'GET /v1/agent/self/limits': undefined;
|
|
2016
2059
|
readonly 'GET /v1/agent/capabilities': undefined;
|
|
2017
2060
|
readonly 'GET /v1/agent/capabilities.json': undefined;
|
|
2018
2061
|
readonly 'GET /v1/agent/account': undefined;
|
|
@@ -2117,6 +2160,7 @@ export type AgentApiEndpointRequestMap = {
|
|
|
2117
2160
|
export type AgentApiEndpointResponseMap = {
|
|
2118
2161
|
readonly 'GET /v1/agent/self': AgentApiSelfResponse;
|
|
2119
2162
|
readonly 'GET /v1/agent/self/usage': AgentApiSelfUsageResponse;
|
|
2163
|
+
readonly 'GET /v1/agent/self/limits': AgentApiSelfLimitsResponse;
|
|
2120
2164
|
readonly 'GET /v1/agent/capabilities': AgentApiCapabilitiesResponse;
|
|
2121
2165
|
readonly 'GET /v1/agent/capabilities.json': AgentApiCapabilitiesResponse;
|
|
2122
2166
|
readonly 'GET /v1/agent/account': AgentApiAccountResponse;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// Generated by scripts/generateAgentPackageSdk.ts
|
|
4
4
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
5
5
|
/* eslint-disable */
|
|
6
|
-
export const AGENT_API_CONTRACT_VERSION = '1.
|
|
6
|
+
export const AGENT_API_CONTRACT_VERSION = '1.7.0';
|
|
7
7
|
function isAgentSdkRecord(value) {
|
|
8
8
|
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
9
9
|
}
|
|
@@ -135,6 +135,22 @@ export const agentApiEndpoints = [
|
|
|
135
135
|
routeClass: 'read',
|
|
136
136
|
description: 'Return current Agent API rate-limit and usage state.',
|
|
137
137
|
},
|
|
138
|
+
{
|
|
139
|
+
key: 'GET /v1/agent/self/limits',
|
|
140
|
+
method: 'GET',
|
|
141
|
+
path: '/v1/agent/self/limits',
|
|
142
|
+
pathParams: [],
|
|
143
|
+
queryParams: [],
|
|
144
|
+
bodyParams: [],
|
|
145
|
+
requestSchema: null,
|
|
146
|
+
bodySchema: null,
|
|
147
|
+
responseSchema: 'agentApiSelfLimitsResponse',
|
|
148
|
+
requestType: null,
|
|
149
|
+
responseType: 'AgentApiSelfLimitsResponse',
|
|
150
|
+
idempotencyRequired: false,
|
|
151
|
+
routeClass: 'read',
|
|
152
|
+
description: 'Return effective operation permissions, spend/swap limits, and current-period usage for the authenticated agent.',
|
|
153
|
+
},
|
|
138
154
|
{
|
|
139
155
|
key: 'GET /v1/agent/capabilities',
|
|
140
156
|
method: 'GET',
|
|
@@ -988,7 +1004,7 @@ export const agentApiEndpoints = [
|
|
|
988
1004
|
path: '/v1/agent/simulate',
|
|
989
1005
|
pathParams: [],
|
|
990
1006
|
queryParams: [],
|
|
991
|
-
bodyParams: ['method', 'path', 'body'],
|
|
1007
|
+
bodyParams: ['method', 'path', 'body', 'depth'],
|
|
992
1008
|
requestSchema: 'agentApiSimulateRequest',
|
|
993
1009
|
bodySchema: 'agentApiSimulateRequest',
|
|
994
1010
|
responseSchema: 'agentApiSimulateResponse',
|