@intentlayer/sdk 0.1.0 → 0.1.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/dist/index.d.ts CHANGED
@@ -242,15 +242,33 @@ interface AgentConstraints {
242
242
  */
243
243
  presetType?: string;
244
244
  /**
245
- * Maximum USD value per day (uses oracle for conversion).
246
- * This sets FLAG_CAP | FLAG_PERIOD with PERIOD_DAILY in V2 leaf.
245
+ * Maximum token amount per period (human-readable, e.g. 1000 = 1000 USDC).
246
+ * This sets FLAG_CAP | FLAG_PERIOD in V2 leaf.
247
+ * The period is determined by `periodCode` (defaults to PERIOD_DAILY).
248
+ */
249
+ capPerPeriod?: number;
250
+ /**
251
+ * Maximum token amount per transaction (human-readable, e.g. 500 = 500 USDC).
252
+ * This sets FLAG_CAP only in V2 leaf (no period tracking).
253
+ */
254
+ capPerTx?: number;
255
+ /**
256
+ * @deprecated Use `capPerPeriod` instead. This field name is misleading —
257
+ * caps are token-amount-based, not USD-based.
247
258
  */
248
259
  maxDailyUsd?: number;
249
260
  /**
250
- * Maximum USD value per transaction (without period).
251
- * This sets FLAG_CAP only in V2 leaf.
261
+ * @deprecated Use `capPerTx` instead. This field name is misleading —
262
+ * caps are token-amount-based, not USD-based.
252
263
  */
253
264
  maxPerTxUsd?: number;
265
+ /**
266
+ * Token decimals map for cap conversion.
267
+ * Maps lowercase token address → decimals (e.g., USDC = 6, ETH = 18).
268
+ * Used by the constraint builder to convert human-readable cap values to raw wei.
269
+ * If not provided, defaults to 18 decimals (ETH-like).
270
+ */
271
+ tokenDecimals?: Record<string, number>;
254
272
  /**
255
273
  * Allowed recipient addresses for transfers.
256
274
  * This sets FLAG_RECIPIENT in V2 leaf.
@@ -932,8 +950,10 @@ declare const SELECTORS: {
932
950
  * Configuration for a trading agent preset.
933
951
  */
934
952
  interface TradingAgentPreset {
935
- /** Maximum USD value per day */
936
- maxDailyUsd: number;
953
+ /** Human-readable token amount cap per period */
954
+ capPerPeriod?: number;
955
+ /** @deprecated Use capPerPeriod */
956
+ maxDailyUsd?: number;
937
957
  /** Swap contract address (e.g., MockSwap, Uniswap Router) */
938
958
  swapContract: Hex;
939
959
  /** Swap function selectors (defaults to common swap selectors) */
@@ -980,8 +1000,10 @@ declare function tradingAgent(config: TradingAgentPreset): AgentConstraints;
980
1000
  interface PaymentAgentPreset {
981
1001
  /** Allowed vendor addresses */
982
1002
  vendors: Hex[];
983
- /** Maximum USD value per day across all vendors */
984
- maxDailyUsd: number;
1003
+ /** Human-readable token amount cap per period */
1004
+ capPerPeriod?: number;
1005
+ /** @deprecated Use capPerPeriod */
1006
+ maxDailyUsd?: number;
985
1007
  /** Token contract for ERC20 payments (optional, for ETH-only omit this) */
986
1008
  tokenContract?: Hex;
987
1009
  }
@@ -1017,8 +1039,10 @@ declare function paymentAgent(config: PaymentAgentPreset): AgentConstraints;
1017
1039
  * Configuration for a treasury operations preset.
1018
1040
  */
1019
1041
  interface TreasuryOpsPreset {
1020
- /** Maximum USD value per day */
1021
- maxDailyUsd: number;
1042
+ /** Human-readable token amount cap per period */
1043
+ capPerPeriod?: number;
1044
+ /** @deprecated Use capPerPeriod */
1045
+ maxDailyUsd?: number;
1022
1046
  /** Allowed protocol contracts for treasury operations */
1023
1047
  protocolContracts: Hex[];
1024
1048
  /** Allowed function selectors for protocols */
@@ -1058,8 +1082,10 @@ declare function treasuryOps(config: TreasuryOpsPreset): AgentConstraints;
1058
1082
  * Configuration for a lending operations preset (Aave, Compound, etc.).
1059
1083
  */
1060
1084
  interface LendingOpsPreset {
1061
- /** Maximum USD value per day */
1062
- maxDailyUsd: number;
1085
+ /** Human-readable token amount cap per period */
1086
+ capPerPeriod?: number;
1087
+ /** @deprecated Use capPerPeriod */
1088
+ maxDailyUsd?: number;
1063
1089
  /** Lending pool contract address (e.g., Aave Pool, Compound Comptroller) */
1064
1090
  lendingPool: Hex;
1065
1091
  /**
@@ -1108,8 +1134,10 @@ declare function lendingOps(config: LendingOpsPreset): AgentConstraints;
1108
1134
  * Configuration for a stablecoin transfer preset.
1109
1135
  */
1110
1136
  interface StablecoinTransferPreset {
1111
- /** Maximum USD value per day */
1112
- maxDailyUsd: number;
1137
+ /** Human-readable token amount cap per period */
1138
+ capPerPeriod?: number;
1139
+ /** @deprecated Use capPerPeriod */
1140
+ maxDailyUsd?: number;
1113
1141
  /** Allowed recipient addresses */
1114
1142
  recipients: Hex[];
1115
1143
  /** Stablecoin contract addresses (USDC, USDT, DAI, etc.) */
@@ -1145,8 +1173,10 @@ declare function stablecoinTransfer(config: StablecoinTransferPreset): AgentCons
1145
1173
  interface PayrollPreset {
1146
1174
  /** Employee wallet addresses */
1147
1175
  employees: Hex[];
1148
- /** Maximum monthly USD total budget */
1149
- maxMonthlyUsd: number;
1176
+ /** Human-readable token amount cap per period (monthly) */
1177
+ capPerPeriod?: number;
1178
+ /** @deprecated Use capPerPeriod */
1179
+ maxMonthlyUsd?: number;
1150
1180
  /** Token contract for salary payments (optional, for ETH-only omit) */
1151
1181
  tokenContract?: Hex;
1152
1182
  /**
@@ -1197,8 +1227,10 @@ declare function payroll(config: PayrollPreset): AgentConstraints;
1197
1227
  * Configuration for a simple transfer-only preset.
1198
1228
  */
1199
1229
  interface TransferOnlyPreset {
1200
- /** Maximum USD value per day */
1201
- maxDailyUsd: number;
1230
+ /** Human-readable token amount cap per period */
1231
+ capPerPeriod?: number;
1232
+ /** @deprecated Use capPerPeriod */
1233
+ maxDailyUsd?: number;
1202
1234
  /** Allowed recipient addresses */
1203
1235
  recipients: Hex[];
1204
1236
  /** Token contract for ERC20 transfers (optional, for ETH-only omit) */
@@ -1254,8 +1286,10 @@ declare function transferOnly(config: TransferOnlyPreset): AgentConstraints;
1254
1286
  interface MarketingBucketPreset {
1255
1287
  /** Marketing recipient addresses (e.g., Google Ads, Meta Ads) */
1256
1288
  recipients: Hex[];
1257
- /** Maximum monthly USD budget shared across ALL recipients */
1258
- maxMonthlyUsd: number;
1289
+ /** Human-readable token amount cap per period (monthly) */
1290
+ capPerPeriod?: number;
1291
+ /** @deprecated Use capPerPeriod */
1292
+ maxMonthlyUsd?: number;
1259
1293
  /**
1260
1294
  * Bucket identifier for shared cap tracking.
1261
1295
  * Can be a string (will be hashed) or a 32-byte hex value.
@@ -1301,8 +1335,10 @@ interface VendorCardPreset {
1301
1335
  * updated on-chain without modifying the policy.
1302
1336
  */
1303
1337
  vendorGroupId: bigint | Hex;
1304
- /** Maximum daily USD spending limit */
1305
- maxDailyUsd: number;
1338
+ /** Human-readable token amount cap per period */
1339
+ capPerPeriod?: number;
1340
+ /** @deprecated Use capPerPeriod */
1341
+ maxDailyUsd?: number;
1306
1342
  /** Token contract for payments (optional, for ETH-only omit) */
1307
1343
  tokenContract?: Hex;
1308
1344
  /**
@@ -5307,7 +5343,7 @@ declare class RelayerRuntime {
5307
5343
  *
5308
5344
  * @example
5309
5345
  * ```ts
5310
- * import { GLOBAL_FLAG_NO_BRIDGE } from '@iel/sdk';
5346
+ * import { GLOBAL_FLAG_NO_BRIDGE } from '@intentlayer/sdk';
5311
5347
  *
5312
5348
  * // Enable bridge blocking (invalidates pending intents)
5313
5349
  * const { headerVersion, txHash } = await runtime.updatePolicyGlobalFlags(
@@ -5796,6 +5832,136 @@ interface ListScheduleExecutionsResponse {
5796
5832
  limit: number;
5797
5833
  offset: number;
5798
5834
  }
5835
+ type RequestType = "policy" | "agent_wallet" | "fund";
5836
+ type RequestStatus = "pending" | "approved" | "denied" | "executed";
5837
+ interface CreateRequestBody {
5838
+ type: RequestType;
5839
+ chainId: number;
5840
+ walletId?: string;
5841
+ params: Record<string, unknown>;
5842
+ reason?: string;
5843
+ expiresAt?: string;
5844
+ }
5845
+ interface RequestResponse {
5846
+ id: string;
5847
+ tenantId: string;
5848
+ walletId: string | null;
5849
+ chainId: number;
5850
+ type: RequestType;
5851
+ status: RequestStatus;
5852
+ params: Record<string, unknown>;
5853
+ reason: string | null;
5854
+ createdByType: string;
5855
+ createdById: string;
5856
+ rowVersion: number;
5857
+ expiresAt: string | null;
5858
+ resolvedAt: string | null;
5859
+ denyReason: string | null;
5860
+ executionTxHash: string | null;
5861
+ executionId: string | null;
5862
+ executionError: string | null;
5863
+ createdAt: string;
5864
+ }
5865
+ interface ApproveRequestResponse {
5866
+ requestId: string;
5867
+ status: "approved";
5868
+ rowVersion: number;
5869
+ action: {
5870
+ type: string;
5871
+ intent: Record<string, unknown>;
5872
+ eip712TypedData: Record<string, unknown>;
5873
+ };
5874
+ }
5875
+ interface ExecuteRequestResponse {
5876
+ requestId: string;
5877
+ status: "executed";
5878
+ executionTxHash: string;
5879
+ executionId?: string;
5880
+ policyId?: string;
5881
+ snapshotId?: string;
5882
+ }
5883
+ interface ListRequestsResponse {
5884
+ requests: RequestResponse[];
5885
+ total: number;
5886
+ }
5887
+ interface RequestSummary {
5888
+ id: string;
5889
+ type: RequestType;
5890
+ status: RequestStatus;
5891
+ title: string;
5892
+ description: string;
5893
+ details: Array<{
5894
+ label: string;
5895
+ value: string;
5896
+ }>;
5897
+ expiresAt: string | null;
5898
+ createdAt: string;
5899
+ }
5900
+ /**
5901
+ * Suggested constraints from agent (input to policy request).
5902
+ * These are advisory - subject to preset caps enforced in compilePolicyConstraints().
5903
+ */
5904
+ interface SuggestedConstraints {
5905
+ /** Recipient addresses to include in policy allowlist */
5906
+ allowedRecipients?: string[];
5907
+ /** Asset addresses to include in policy allowlist (or "NATIVE") */
5908
+ allowedAssets?: string[];
5909
+ /** Maximum USD per day budget */
5910
+ maxDailyUsd?: number;
5911
+ /** Maximum USD per transaction */
5912
+ maxPerTxUsd?: number;
5913
+ }
5914
+ /**
5915
+ * Warning generated during constraint compilation.
5916
+ * Shows what was clamped, excluded, or invalid - never silently dropped.
5917
+ */
5918
+ interface CompileWarning {
5919
+ type: "clamped" | "excluded" | "invalid";
5920
+ field: string;
5921
+ message: string;
5922
+ original?: unknown;
5923
+ final?: unknown;
5924
+ }
5925
+ /**
5926
+ * Diff showing what was requested vs what was included/excluded.
5927
+ */
5928
+ interface CompiledPolicyDiff {
5929
+ recipients: {
5930
+ requested: string[];
5931
+ added: string[];
5932
+ excluded: string[];
5933
+ finalCount: number;
5934
+ };
5935
+ assets: {
5936
+ requested: string[];
5937
+ added: string[];
5938
+ excluded: string[];
5939
+ finalCount: number;
5940
+ };
5941
+ dailyBudget: {
5942
+ requested: number | null;
5943
+ final: number | null;
5944
+ changed: boolean;
5945
+ };
5946
+ perTxBudget: {
5947
+ requested: number | null;
5948
+ final: number | null;
5949
+ changed: boolean;
5950
+ };
5951
+ }
5952
+ /**
5953
+ * Response from compile-policy endpoint.
5954
+ * Shows final constraints that will be bootstrapped after owner approval.
5955
+ */
5956
+ interface CompiledPolicyResponse {
5957
+ preset: string;
5958
+ baselineConstraints: Record<string, unknown>;
5959
+ suggestedConstraints: SuggestedConstraints | null;
5960
+ finalConstraints: Record<string, unknown>;
5961
+ warnings: CompileWarning[];
5962
+ diff: CompiledPolicyDiff;
5963
+ compilerVersion: string;
5964
+ }
5799
5965
 
5800
5966
  /**
5801
5967
  * Cloud API Error
@@ -5981,6 +6147,56 @@ declare class IELCloudClient {
5981
6147
  limit?: number;
5982
6148
  offset?: number;
5983
6149
  }): Promise<ListScheduleExecutionsResponse>;
6150
+ /**
6151
+ * Create a request (policy, agent_wallet, or fund).
6152
+ * Agents use this to request new permissions from the wallet owner.
6153
+ */
6154
+ createRequest(body: CreateRequestBody, idempotencyKey?: string): Promise<RequestResponse>;
6155
+ /**
6156
+ * List requests with optional filters.
6157
+ */
6158
+ listRequests(options?: {
6159
+ status?: string;
6160
+ type?: string;
6161
+ walletId?: string;
6162
+ limit?: number;
6163
+ offset?: number;
6164
+ }): Promise<ListRequestsResponse>;
6165
+ /**
6166
+ * Get a request by ID.
6167
+ */
6168
+ getRequest(requestId: string): Promise<RequestResponse>;
6169
+ /**
6170
+ * Get a human-readable summary of a request.
6171
+ */
6172
+ getRequestSummary(requestId: string): Promise<RequestSummary>;
6173
+ /**
6174
+ * Approve a request. Returns the EIP-712 typed data for the owner to sign.
6175
+ * Only callable by owner (API key holder).
6176
+ */
6177
+ approveRequest(requestId: string): Promise<ApproveRequestResponse>;
6178
+ /**
6179
+ * Deny a request with an optional reason.
6180
+ * Only callable by owner (API key holder).
6181
+ */
6182
+ denyRequest(requestId: string, reason?: string): Promise<RequestResponse>;
6183
+ /**
6184
+ * Execute an approved request by submitting the owner's EIP-712 signature.
6185
+ * Triggers on-chain execution via the bootstrap pipeline.
6186
+ * Only callable by owner (API key holder).
6187
+ */
6188
+ executeRequest(requestId: string, signature: string, txHash?: string, policyId?: string, walletAddress?: string): Promise<ExecuteRequestResponse>;
6189
+ /**
6190
+ * Compile policy constraints for a policy request.
6191
+ * Returns the final constraints that will be bootstrapped after approval,
6192
+ * along with any warnings about clamped/excluded items.
6193
+ *
6194
+ * Use this to show users exactly what they're approving before signing.
6195
+ *
6196
+ * @param requestId - Policy request ID
6197
+ * @returns Compiled policy with finalConstraints, warnings, and diff
6198
+ */
6199
+ compilePolicyRequest(requestId: string): Promise<CompiledPolicyResponse>;
5984
6200
  /**
5985
6201
  * Get wallet by name and return a CloudWallet instance
5986
6202
  */
@@ -7030,6 +7246,8 @@ interface V2ConstraintBuildResult {
7030
7246
  root: Hex;
7031
7247
  /** Per-recipient leaf map for multi-recipient policies */
7032
7248
  recipientLeaves?: Record<string, Hex>;
7249
+ /** Policy-level daily cap in wei (set when both capPerTx and capPerPeriod are present) */
7250
+ dailyCapWei?: bigint;
7033
7251
  }
7034
7252
  /**
7035
7253
  * Build V2 constraints from high-level AgentConstraints.
@@ -7916,7 +8134,7 @@ declare function createV3OnlyPolicy(params: {
7916
8134
  *
7917
8135
  * @example
7918
8136
  * ```ts
7919
- * import { createMultiLeafPolicyBuilder } from '@iel/sdk/policy';
8137
+ * import { createMultiLeafPolicyBuilder } from '@intentlayer/sdk/policy';
7920
8138
  *
7921
8139
  * const builder = createMultiLeafPolicyBuilder();
7922
8140
  *
@@ -8063,7 +8281,7 @@ declare function createMultiLeafPolicyBuilder(): MultiLeafPolicyBuilder;
8063
8281
  * ## Usage
8064
8282
  *
8065
8283
  * ```ts
8066
- * import { policy } from '@iel/sdk';
8284
+ * import { policy } from '@intentlayer/sdk';
8067
8285
  *
8068
8286
  * // Create hybrid policy
8069
8287
  * const result = await policy.createHybridPolicy({