@ampersend_ai/ampersend-sdk 0.0.11 → 0.0.13

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.
Files changed (77) hide show
  1. package/dist/ampersend/approval.d.ts +52 -0
  2. package/dist/ampersend/approval.d.ts.map +1 -0
  3. package/dist/ampersend/approval.js +106 -0
  4. package/dist/ampersend/approval.js.map +1 -0
  5. package/dist/ampersend/index.d.ts +1 -0
  6. package/dist/ampersend/index.d.ts.map +1 -1
  7. package/dist/ampersend/index.js +1 -0
  8. package/dist/ampersend/index.js.map +1 -1
  9. package/dist/ampersend/management.d.ts +2 -2
  10. package/dist/ampersend/treasurer.d.ts +2 -1
  11. package/dist/ampersend/treasurer.d.ts.map +1 -1
  12. package/dist/ampersend/treasurer.js +16 -4
  13. package/dist/ampersend/treasurer.js.map +1 -1
  14. package/dist/ampersend/types.d.ts +207 -4
  15. package/dist/ampersend/types.d.ts.map +1 -1
  16. package/dist/ampersend/types.js +107 -2
  17. package/dist/ampersend/types.js.map +1 -1
  18. package/dist/cli/ampersend.js +2 -0
  19. package/dist/cli/ampersend.js.map +1 -1
  20. package/dist/cli/commands/config.d.ts +1 -1
  21. package/dist/cli/commands/config.d.ts.map +1 -1
  22. package/dist/cli/commands/config.js +41 -35
  23. package/dist/cli/commands/config.js.map +1 -1
  24. package/dist/cli/commands/fetch.js +6 -6
  25. package/dist/cli/commands/fetch.js.map +1 -1
  26. package/dist/cli/commands/setup.d.ts +18 -0
  27. package/dist/cli/commands/setup.d.ts.map +1 -0
  28. package/dist/cli/commands/setup.js +151 -0
  29. package/dist/cli/commands/setup.js.map +1 -0
  30. package/dist/cli/config.d.ts +62 -38
  31. package/dist/cli/config.d.ts.map +1 -1
  32. package/dist/cli/config.js +148 -110
  33. package/dist/cli/config.js.map +1 -1
  34. package/dist/smart-account/constants.d.ts +5 -0
  35. package/dist/smart-account/constants.d.ts.map +1 -1
  36. package/dist/smart-account/constants.js +5 -0
  37. package/dist/smart-account/constants.js.map +1 -1
  38. package/dist/smart-account/eip712-types.d.ts +27 -0
  39. package/dist/smart-account/eip712-types.d.ts.map +1 -0
  40. package/dist/smart-account/eip712-types.js +16 -0
  41. package/dist/smart-account/eip712-types.js.map +1 -0
  42. package/dist/smart-account/index.d.ts +2 -1
  43. package/dist/smart-account/index.d.ts.map +1 -1
  44. package/dist/smart-account/index.js +2 -1
  45. package/dist/smart-account/index.js.map +1 -1
  46. package/dist/smart-account/signing.d.ts.map +1 -1
  47. package/dist/smart-account/signing.js +2 -8
  48. package/dist/smart-account/signing.js.map +1 -1
  49. package/dist/version.d.ts +1 -1
  50. package/dist/version.js +1 -1
  51. package/dist/x402/index.d.ts +1 -0
  52. package/dist/x402/index.d.ts.map +1 -1
  53. package/dist/x402/index.js.map +1 -1
  54. package/dist/x402/types.d.ts +36 -0
  55. package/dist/x402/types.d.ts.map +1 -0
  56. package/dist/x402/types.js +9 -0
  57. package/dist/x402/types.js.map +1 -0
  58. package/dist/x402/wallet.d.ts +3 -1
  59. package/dist/x402/wallet.d.ts.map +1 -1
  60. package/dist/x402/wallet.js.map +1 -1
  61. package/dist/x402/wallets/account/wallet.d.ts +5 -3
  62. package/dist/x402/wallets/account/wallet.d.ts.map +1 -1
  63. package/dist/x402/wallets/account/wallet.js +2 -1
  64. package/dist/x402/wallets/account/wallet.js.map +1 -1
  65. package/dist/x402/wallets/index.d.ts +1 -0
  66. package/dist/x402/wallets/index.d.ts.map +1 -1
  67. package/dist/x402/wallets/index.js +1 -0
  68. package/dist/x402/wallets/index.js.map +1 -1
  69. package/dist/x402/wallets/smart-account/cosigned.d.ts +46 -0
  70. package/dist/x402/wallets/smart-account/cosigned.d.ts.map +1 -0
  71. package/dist/x402/wallets/smart-account/cosigned.js +90 -0
  72. package/dist/x402/wallets/smart-account/cosigned.js.map +1 -0
  73. package/dist/x402/wallets/smart-account/wallet.d.ts +8 -1
  74. package/dist/x402/wallets/smart-account/wallet.d.ts.map +1 -1
  75. package/dist/x402/wallets/smart-account/wallet.js +14 -3
  76. package/dist/x402/wallets/smart-account/wallet.js.map +1 -1
  77. package/package.json +1 -1
@@ -0,0 +1,52 @@
1
+ import { ApprovalResponse, ApprovalStatus, type CreateAgentApprovalRequest } from "./types.js";
2
+ export interface ApprovalClientOptions {
3
+ apiUrl?: string;
4
+ timeout?: number;
5
+ }
6
+ /**
7
+ * Client for the approve-action flow.
8
+ *
9
+ * This client handles unauthenticated approval requests where an agent
10
+ * programmatically requests creation and waits for user approval via
11
+ * the Ampersend dashboard.
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * import { ApprovalClient } from "@ampersend_ai/ampersend-sdk/ampersend"
16
+ *
17
+ * const client = new ApprovalClient()
18
+ *
19
+ * // Request agent creation approval
20
+ * const response = await client.requestAgentCreation({
21
+ * name: "my-agent",
22
+ * agent_key_address: "0x...",
23
+ * })
24
+ *
25
+ * console.log("Have user visit:", response.user_approve_url)
26
+ *
27
+ * // Poll for status
28
+ * const status = await client.getApprovalStatus(response.token)
29
+ * if (status.status === "resolved" && "agent" in status) {
30
+ * console.log("Agent created at:", status.agent.address)
31
+ * }
32
+ * ```
33
+ */
34
+ export declare class ApprovalClient {
35
+ private baseUrl;
36
+ private timeout;
37
+ constructor(options?: ApprovalClientOptions);
38
+ /**
39
+ * Request approval to create a new agent.
40
+ *
41
+ * Returns URLs for the user to approve the action and to poll for status.
42
+ */
43
+ requestAgentCreation(request: typeof CreateAgentApprovalRequest.Encoded): Promise<ApprovalResponse>;
44
+ /**
45
+ * Get the current status of an approval request.
46
+ *
47
+ * @param token - The token from the approval response
48
+ */
49
+ getApprovalStatus(token: string): Promise<ApprovalStatus>;
50
+ private fetch;
51
+ }
52
+ //# sourceMappingURL=approval.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"approval.d.ts","sourceRoot":"","sources":["../../src/ampersend/approval.ts"],"names":[],"mappings":"AAEA,OAAO,EAAY,gBAAgB,EAAE,cAAc,EAAE,KAAK,0BAA0B,EAAE,MAAM,YAAY,CAAA;AAIxG,MAAM,WAAW,qBAAqB;IACpC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,OAAO,CAAQ;IACvB,OAAO,CAAC,OAAO,CAAQ;gBAEX,OAAO,GAAE,qBAA0B;IAK/C;;;;OAIG;IACG,oBAAoB,CAAC,OAAO,EAAE,OAAO,0BAA0B,CAAC,OAAO,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAYzG;;;;OAIG;IACG,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;YAIjD,KAAK;CA4CpB"}
@@ -0,0 +1,106 @@
1
+ import { Schema } from "effect";
2
+ import { ApiError, ApprovalResponse, ApprovalStatus } from "./types.js";
3
+ const DEFAULT_API_URL = "https://api.ampersend.ai";
4
+ /**
5
+ * Client for the approve-action flow.
6
+ *
7
+ * This client handles unauthenticated approval requests where an agent
8
+ * programmatically requests creation and waits for user approval via
9
+ * the Ampersend dashboard.
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * import { ApprovalClient } from "@ampersend_ai/ampersend-sdk/ampersend"
14
+ *
15
+ * const client = new ApprovalClient()
16
+ *
17
+ * // Request agent creation approval
18
+ * const response = await client.requestAgentCreation({
19
+ * name: "my-agent",
20
+ * agent_key_address: "0x...",
21
+ * })
22
+ *
23
+ * console.log("Have user visit:", response.user_approve_url)
24
+ *
25
+ * // Poll for status
26
+ * const status = await client.getApprovalStatus(response.token)
27
+ * if (status.status === "resolved" && "agent" in status) {
28
+ * console.log("Agent created at:", status.agent.address)
29
+ * }
30
+ * ```
31
+ */
32
+ export class ApprovalClient {
33
+ baseUrl;
34
+ timeout;
35
+ constructor(options = {}) {
36
+ this.baseUrl = (options.apiUrl ?? DEFAULT_API_URL).replace(/\/$/, "");
37
+ this.timeout = options.timeout ?? 30000;
38
+ }
39
+ /**
40
+ * Request approval to create a new agent.
41
+ *
42
+ * Returns URLs for the user to approve the action and to poll for status.
43
+ */
44
+ async requestAgentCreation(request) {
45
+ // Map SDK field names to API wire format
46
+ const payload = {
47
+ name: request.name,
48
+ session_key_address: request.agent_key_address,
49
+ };
50
+ if (request.spend_config !== undefined) {
51
+ payload.spend_config = request.spend_config;
52
+ }
53
+ return this.fetch("POST", "/api/v1/approve-action/agent", payload, ApprovalResponse);
54
+ }
55
+ /**
56
+ * Get the current status of an approval request.
57
+ *
58
+ * @param token - The token from the approval response
59
+ */
60
+ async getApprovalStatus(token) {
61
+ return this.fetch("GET", `/api/v1/approve-action/${token}/status`, undefined, ApprovalStatus);
62
+ }
63
+ async fetch(method, path, body, schema) {
64
+ const url = `${this.baseUrl}${path}`;
65
+ const headers = {};
66
+ if (body != null) {
67
+ headers["Content-Type"] = "application/json";
68
+ }
69
+ try {
70
+ const init = {
71
+ method,
72
+ headers,
73
+ signal: AbortSignal.timeout(this.timeout),
74
+ };
75
+ if (body != null) {
76
+ init.body = JSON.stringify(body);
77
+ }
78
+ const response = await globalThis.fetch(url, init);
79
+ if (!response.ok) {
80
+ let errorMessage = `HTTP ${response.status} ${response.statusText}`;
81
+ try {
82
+ const errorBody = await response.text();
83
+ if (errorBody) {
84
+ errorMessage += `: ${errorBody}`;
85
+ }
86
+ }
87
+ catch {
88
+ // Ignore error body parsing failures
89
+ }
90
+ throw new ApiError(errorMessage, response.status, response);
91
+ }
92
+ const data = await response.json();
93
+ return Schema.decodeUnknownSync(schema)(data);
94
+ }
95
+ catch (error) {
96
+ if (error instanceof ApiError) {
97
+ throw error;
98
+ }
99
+ if (error instanceof Error && error.name === "AbortError") {
100
+ throw new ApiError(`Request timeout after ${this.timeout}ms`);
101
+ }
102
+ throw new ApiError(`Request failed: ${error}`);
103
+ }
104
+ }
105
+ }
106
+ //# sourceMappingURL=approval.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"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AC;gBAC9B,MAAM,KAAK,CAAA;YACb,CAAC;YACD,IAAI,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;gBAC1D,MAAM,IAAI,QAAQ,CAAC,yBAAyB,IAAI,CAAC,OAAO,IAAI,CAAC,CAAA;YAC/D,CAAC;YACD,MAAM,IAAI,QAAQ,CAAC,mBAAmB,KAAK,EAAE,CAAC,CAAA;QAChD,CAAC;IACH,CAAC;CACF"}
@@ -1,5 +1,6 @@
1
1
  export * from "./types.ts";
2
2
  export { ApiClient } from "./client.ts";
3
3
  export { AgentInitData, AgentResponse, AmpersendManagementClient, type SpendConfig, type CreateAgentOptions, } from "./management.ts";
4
+ export { ApprovalClient, type ApprovalClientOptions } from "./approval.ts";
4
5
  export { AmpersendTreasurer, createAmpersendTreasurer, type AmpersendTreasurerConfig, type SimpleAmpersendTreasurerConfig, type FullAmpersendTreasurerConfig, } from "./treasurer.ts";
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ampersend/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EACL,aAAa,EACb,aAAa,EACb,yBAAyB,EACzB,KAAK,WAAW,EAChB,KAAK,kBAAkB,GACxB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,kBAAkB,EAClB,wBAAwB,EACxB,KAAK,wBAAwB,EAC7B,KAAK,8BAA8B,EACnC,KAAK,4BAA4B,GAClC,MAAM,gBAAgB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ampersend/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EACL,aAAa,EACb,aAAa,EACb,yBAAyB,EACzB,KAAK,WAAW,EAChB,KAAK,kBAAkB,GACxB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,cAAc,EAAE,KAAK,qBAAqB,EAAE,MAAM,eAAe,CAAA;AAC1E,OAAO,EACL,kBAAkB,EAClB,wBAAwB,EACxB,KAAK,wBAAwB,EAC7B,KAAK,8BAA8B,EACnC,KAAK,4BAA4B,GAClC,MAAM,gBAAgB,CAAA"}
@@ -1,5 +1,6 @@
1
1
  export * from "./types.js";
2
2
  export { ApiClient } from "./client.js";
3
3
  export { AgentInitData, AgentResponse, AmpersendManagementClient, } from "./management.js";
4
+ export { ApprovalClient } from "./approval.js";
4
5
  export { AmpersendTreasurer, createAmpersendTreasurer, } from "./treasurer.js";
5
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ampersend/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EACL,aAAa,EACb,aAAa,EACb,yBAAyB,GAG1B,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,kBAAkB,EAClB,wBAAwB,GAIzB,MAAM,gBAAgB,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ampersend/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EACL,aAAa,EACb,aAAa,EACb,yBAAyB,GAG1B,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,cAAc,EAA8B,MAAM,eAAe,CAAA;AAC1E,OAAO,EACL,kBAAkB,EAClB,wBAAwB,GAIzB,MAAM,gBAAgB,CAAA"}
@@ -41,10 +41,10 @@ declare const AgentResponse_base: Schema.Class<AgentResponse, {
41
41
  updatedAt: typeof Schema.Number;
42
42
  }>, never, {
43
43
  readonly nonce: string;
44
- } & {
45
- readonly address: string;
46
44
  } & {
47
45
  readonly name: string;
46
+ } & {
47
+ readonly address: string;
48
48
  } & {
49
49
  readonly userId: string;
50
50
  } & {
@@ -1,4 +1,5 @@
1
1
  import type { Address, Hex } from "viem";
2
+ import type { PaymentRequirements } from "x402/types";
2
3
  import { type Authorization, type PaymentContext, type PaymentStatus, type WalletConfig, type X402Treasurer, type X402Wallet } from "../x402/index.ts";
3
4
  import { ApiClient } from "./client.ts";
4
5
  /**
@@ -71,7 +72,7 @@ export declare class AmpersendTreasurer implements X402Treasurer {
71
72
  * Requests payment authorization from API before creating payment.
72
73
  * Only creates payment if API authorizes it.
73
74
  */
74
- onPaymentRequired(requirements: Array<any>, context?: PaymentContext): Promise<Authorization | null>;
75
+ onPaymentRequired(requirements: ReadonlyArray<PaymentRequirements>, context?: PaymentContext): Promise<Authorization | null>;
75
76
  /**
76
77
  * Reports payment status updates back to API for tracking.
77
78
  * Logs errors but doesn't fail on tracking errors.
@@ -1 +1 @@
1
- {"version":3,"file":"treasurer.d.ts","sourceRoot":"","sources":["../../src/ampersend/treasurer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAA;AAKxC,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,aAAa,EAElB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,UAAU,EAChB,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAQvC;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,8BAA8B;IAC7C,4BAA4B;IAC5B,mBAAmB,EAAE,OAAO,CAAA;IAC5B,0CAA0C;IAC1C,oBAAoB,EAAE,GAAG,CAAA;IACzB,iDAAiD;IACjD,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,+CAA+C;IAC/C,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED;;;GAGG;AACH,MAAM,WAA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;;;;;;;;;;GA2BG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,wBAAwB,GAAG,aAAa,CA+CxF"}
@@ -44,6 +44,8 @@ export class AmpersendTreasurer {
44
44
  async onPaymentRequired(requirements, context) {
45
45
  try {
46
46
  // Authorize payment with API
47
+ // Cast needed: x402 PaymentRequirements (zod) → ampersend PaymentRequirements (Effect Schema)
48
+ // Structurally compatible at runtime, different type systems
47
49
  const response = await this.apiClient.authorizePayment(requirements, context);
48
50
  // Check if any requirements were authorized
49
51
  if (response.authorized.requirements.length === 0) {
@@ -58,10 +60,20 @@ export class AmpersendTreasurer {
58
60
  if (!authorizedReq) {
59
61
  throw new Error("Recommended requirement index out of bounds");
60
62
  }
61
- // Create payment with wallet using the authorized requirement
62
- // Note: Type assertion needed because ampersend PaymentRequirements uses string for network,
63
- // while x402 PaymentRequirements uses specific network literals. Runtime compatible.
64
- const payment = await this.wallet.createPayment(authorizedReq.requirement);
63
+ // Check if server provided co-signature (for co-signed keys)
64
+ let payment;
65
+ if (response.payment) {
66
+ // Co-signed path: use server-provided authorization data and signature
67
+ const serverAuth = {
68
+ authorizationData: response.payment.authorizationData,
69
+ serverSignature: response.payment.serverSignature,
70
+ };
71
+ payment = await this.wallet.createPayment(response.payment.requirement, serverAuth);
72
+ }
73
+ else {
74
+ // Full-access path: sign independently
75
+ payment = await this.wallet.createPayment(authorizedReq.requirement);
76
+ }
65
77
  return {
66
78
  payment,
67
79
  authorizationId: crypto.randomUUID(),
@@ -1 +1 @@
1
- {"version":3,"file":"treasurer.js","sourceRoot":"","sources":["../../src/ampersend/treasurer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AAGnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,EACL,sBAAsB,GAQvB,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAEvC,gCAAg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,OAAO,CAAA;IAE1D,oBAAoB;IACpB,MAAM,SAAS,GAAG,IAAI,SAAS,CAAC;QAC9B,OAAO,EAAE,MAAM;QACf,oBAAoB,EAAE,cAAc;QACpC,YAAY;QACZ,OAAO,EAAE,KAAK;QACd,GAAG,UAAU;KACd,CAAC,CAAA;IAEF,mCAAmC;IACnC,MAAM,MAAM,GAAG,sBAAsB,CAAC,YAAY,CAAC,CAAA;IAEnD,OAAO,IAAI,kBAAkB,CAAC,SAAS,EAAE,MAAM,CAAC,CAAA;AAClD,CAAC"}
@@ -64,7 +64,7 @@ declare const PaymentRequirements_base: Schema.Class<PaymentRequirements, {
64
64
  maxAmountRequired: Schema.refine<string, typeof Schema.Trimmed>;
65
65
  resource: Schema.refine<string, typeof Schema.Trimmed>;
66
66
  description: Schema.refine<string, typeof Schema.Trimmed>;
67
- mimeType: Schema.refine<string, typeof Schema.Trimmed>;
67
+ mimeType: Schema.SchemaClass<string, string, never>;
68
68
  payTo: Schema.refine<string, typeof Schema.NonEmptyTrimmedString>;
69
69
  maxTimeoutSeconds: Schema.SchemaClass<number, number, never>;
70
70
  asset: Schema.refine<string, typeof Schema.NonEmptyTrimmedString>;
@@ -75,7 +75,7 @@ declare const PaymentRequirements_base: Schema.Class<PaymentRequirements, {
75
75
  maxAmountRequired: Schema.refine<string, typeof Schema.Trimmed>;
76
76
  resource: Schema.refine<string, typeof Schema.Trimmed>;
77
77
  description: Schema.refine<string, typeof Schema.Trimmed>;
78
- mimeType: Schema.refine<string, typeof Schema.Trimmed>;
78
+ mimeType: Schema.SchemaClass<string, string, never>;
79
79
  payTo: Schema.refine<string, typeof Schema.NonEmptyTrimmedString>;
80
80
  maxTimeoutSeconds: Schema.SchemaClass<number, number, never>;
81
81
  asset: Schema.refine<string, typeof Schema.NonEmptyTrimmedString>;
@@ -105,6 +105,62 @@ declare const PaymentRequirements_base: Schema.Class<PaymentRequirements, {
105
105
  }, {}, {}>;
106
106
  export declare class PaymentRequirements extends PaymentRequirements_base {
107
107
  }
108
+ declare const ERC3009AuthorizationData_base: Schema.Class<ERC3009AuthorizationData, {
109
+ from: Schema.refine<string, typeof Schema.NonEmptyTrimmedString>;
110
+ to: Schema.refine<string, typeof Schema.NonEmptyTrimmedString>;
111
+ value: Schema.SchemaClass<string, string, never>;
112
+ validAfter: Schema.SchemaClass<string, string, never>;
113
+ validBefore: Schema.SchemaClass<string, string, never>;
114
+ nonce: Schema.SchemaClass<string, string, never>;
115
+ }, Schema.Struct.Encoded<{
116
+ from: Schema.refine<string, typeof Schema.NonEmptyTrimmedString>;
117
+ to: Schema.refine<string, typeof Schema.NonEmptyTrimmedString>;
118
+ value: Schema.SchemaClass<string, string, never>;
119
+ validAfter: Schema.SchemaClass<string, string, never>;
120
+ validBefore: Schema.SchemaClass<string, string, never>;
121
+ nonce: Schema.SchemaClass<string, string, never>;
122
+ }>, never, {
123
+ readonly nonce: string;
124
+ } & {
125
+ readonly from: string;
126
+ } & {
127
+ readonly to: string;
128
+ } & {
129
+ readonly value: string;
130
+ } & {
131
+ readonly validAfter: string;
132
+ } & {
133
+ readonly validBefore: string;
134
+ }, {}, {}>;
135
+ export declare class ERC3009AuthorizationData extends ERC3009AuthorizationData_base {
136
+ }
137
+ declare const ServerAuthorizationData_base: Schema.Class<ServerAuthorizationData, {
138
+ authorizationData: Schema.SchemaClass<ERC3009AuthorizationData, {
139
+ readonly nonce: string;
140
+ readonly from: string;
141
+ readonly to: string;
142
+ readonly value: string;
143
+ readonly validAfter: string;
144
+ readonly validBefore: string;
145
+ }, never>;
146
+ serverSignature: Schema.SchemaClass<string, string, never>;
147
+ }, Schema.Struct.Encoded<{
148
+ authorizationData: Schema.SchemaClass<ERC3009AuthorizationData, {
149
+ readonly nonce: string;
150
+ readonly from: string;
151
+ readonly to: string;
152
+ readonly value: string;
153
+ readonly validAfter: string;
154
+ readonly validBefore: string;
155
+ }, never>;
156
+ serverSignature: Schema.SchemaClass<string, string, never>;
157
+ }>, never, {
158
+ readonly authorizationData: ERC3009AuthorizationData;
159
+ } & {
160
+ readonly serverSignature: string;
161
+ }, {}, {}>;
162
+ export declare class ServerAuthorizationData extends ServerAuthorizationData_base {
163
+ }
108
164
  declare const AgentPaymentAuthRequest_base: Schema.Class<AgentPaymentAuthRequest, {
109
165
  requirements: Schema.NonEmptyArray<typeof PaymentRequirements>;
110
166
  context: Schema.optional<Schema.Struct<{
@@ -171,6 +227,31 @@ declare const AgentPaymentAuthResponse_base: Schema.Class<AgentPaymentAuthRespon
171
227
  }, never>;
172
228
  reason: Schema.refine<string, typeof Schema.Trimmed>;
173
229
  }>>;
230
+ payment: Schema.NullOr<Schema.Struct<{
231
+ authorizationData: Schema.SchemaClass<ERC3009AuthorizationData, {
232
+ readonly nonce: string;
233
+ readonly from: string;
234
+ readonly to: string;
235
+ readonly value: string;
236
+ readonly validAfter: string;
237
+ readonly validBefore: string;
238
+ }, never>;
239
+ serverSignature: Schema.SchemaClass<string, string, never>;
240
+ requirement: Schema.SchemaClass<PaymentRequirements, {
241
+ readonly description: string;
242
+ readonly scheme: "exact";
243
+ readonly network: string;
244
+ readonly maxAmountRequired: string;
245
+ readonly resource: string;
246
+ readonly mimeType: string;
247
+ readonly payTo: string;
248
+ readonly maxTimeoutSeconds: number;
249
+ readonly asset: string;
250
+ readonly extra?: {
251
+ readonly [x: string]: unknown;
252
+ } | undefined;
253
+ }, never>;
254
+ }>>;
174
255
  }, Schema.Struct.Encoded<{
175
256
  authorized: Schema.Struct<{
176
257
  recommended: Schema.NullOr<Schema.refine<number, typeof Schema.NonNegative>>;
@@ -212,6 +293,31 @@ declare const AgentPaymentAuthResponse_base: Schema.Class<AgentPaymentAuthRespon
212
293
  }, never>;
213
294
  reason: Schema.refine<string, typeof Schema.Trimmed>;
214
295
  }>>;
296
+ payment: Schema.NullOr<Schema.Struct<{
297
+ authorizationData: Schema.SchemaClass<ERC3009AuthorizationData, {
298
+ readonly nonce: string;
299
+ readonly from: string;
300
+ readonly to: string;
301
+ readonly value: string;
302
+ readonly validAfter: string;
303
+ readonly validBefore: string;
304
+ }, never>;
305
+ serverSignature: Schema.SchemaClass<string, string, never>;
306
+ requirement: Schema.SchemaClass<PaymentRequirements, {
307
+ readonly description: string;
308
+ readonly scheme: "exact";
309
+ readonly network: string;
310
+ readonly maxAmountRequired: string;
311
+ readonly resource: string;
312
+ readonly mimeType: string;
313
+ readonly payTo: string;
314
+ readonly maxTimeoutSeconds: number;
315
+ readonly asset: string;
316
+ readonly extra?: {
317
+ readonly [x: string]: unknown;
318
+ } | undefined;
319
+ }, never>;
320
+ }>>;
215
321
  }>, never, {
216
322
  readonly authorized: {
217
323
  readonly requirements: readonly {
@@ -228,6 +334,12 @@ declare const AgentPaymentAuthResponse_base: Schema.Class<AgentPaymentAuthRespon
228
334
  readonly requirement: PaymentRequirements;
229
335
  readonly reason: string;
230
336
  }[];
337
+ } & {
338
+ readonly payment: {
339
+ readonly authorizationData: ERC3009AuthorizationData;
340
+ readonly serverSignature: string;
341
+ readonly requirement: PaymentRequirements;
342
+ } | null;
231
343
  }, {}, {}>;
232
344
  export declare class AgentPaymentAuthResponse extends AgentPaymentAuthResponse_base {
233
345
  }
@@ -359,9 +471,9 @@ declare const AgentPaymentEventReport_base: Schema.Class<AgentPaymentEventReport
359
471
  reason: Schema.refine<string, typeof Schema.Trimmed>;
360
472
  }>]>;
361
473
  }>, never, {
362
- readonly id: string;
363
- } & {
364
474
  readonly payment: PaymentPayload;
475
+ } & {
476
+ readonly id: string;
365
477
  } & {
366
478
  readonly event: {
367
479
  readonly type: "sending";
@@ -406,5 +518,96 @@ export declare class ApiError extends Error {
406
518
  constructor(message: string, status?: number | undefined, response?: Response | undefined);
407
519
  }
408
520
  export type PaymentEvent = PaymentEventType;
521
+ export declare const SpendConfigInput: Schema.Struct<{
522
+ auto_topup_allowed: Schema.SchemaClass<boolean, boolean, never>;
523
+ daily_limit: Schema.NullOr<typeof Schema.String>;
524
+ monthly_limit: Schema.NullOr<typeof Schema.String>;
525
+ per_transaction_limit: Schema.NullOr<typeof Schema.String>;
526
+ }>;
527
+ declare const CreateAgentApprovalRequest_base: Schema.Class<CreateAgentApprovalRequest, {
528
+ name: Schema.NullOr<typeof Schema.String>;
529
+ agent_key_address: Schema.refine<string, typeof Schema.NonEmptyTrimmedString>;
530
+ spend_config: Schema.optional<Schema.NullOr<Schema.Struct<{
531
+ auto_topup_allowed: Schema.SchemaClass<boolean, boolean, never>;
532
+ daily_limit: Schema.NullOr<typeof Schema.String>;
533
+ monthly_limit: Schema.NullOr<typeof Schema.String>;
534
+ per_transaction_limit: Schema.NullOr<typeof Schema.String>;
535
+ }>>>;
536
+ }, Schema.Struct.Encoded<{
537
+ name: Schema.NullOr<typeof Schema.String>;
538
+ agent_key_address: Schema.refine<string, typeof Schema.NonEmptyTrimmedString>;
539
+ spend_config: Schema.optional<Schema.NullOr<Schema.Struct<{
540
+ auto_topup_allowed: Schema.SchemaClass<boolean, boolean, never>;
541
+ daily_limit: Schema.NullOr<typeof Schema.String>;
542
+ monthly_limit: Schema.NullOr<typeof Schema.String>;
543
+ per_transaction_limit: Schema.NullOr<typeof Schema.String>;
544
+ }>>>;
545
+ }>, never, {
546
+ readonly name: string | null;
547
+ } & {
548
+ readonly agent_key_address: string;
549
+ } & {
550
+ readonly spend_config?: {
551
+ readonly auto_topup_allowed: boolean;
552
+ readonly daily_limit: string | null;
553
+ readonly monthly_limit: string | null;
554
+ readonly per_transaction_limit: string | null;
555
+ } | null | undefined;
556
+ }, {}, {}>;
557
+ export declare class CreateAgentApprovalRequest extends CreateAgentApprovalRequest_base {
558
+ }
559
+ declare const ApprovalResponse_base: Schema.Class<ApprovalResponse, {
560
+ token: Schema.refine<string, typeof Schema.Trimmed>;
561
+ status_url: Schema.refine<string, typeof Schema.Trimmed>;
562
+ user_approve_url: Schema.refine<string, typeof Schema.Trimmed>;
563
+ }, Schema.Struct.Encoded<{
564
+ token: Schema.refine<string, typeof Schema.Trimmed>;
565
+ status_url: Schema.refine<string, typeof Schema.Trimmed>;
566
+ user_approve_url: Schema.refine<string, typeof Schema.Trimmed>;
567
+ }>, never, {
568
+ readonly token: string;
569
+ } & {
570
+ readonly status_url: string;
571
+ } & {
572
+ readonly user_approve_url: string;
573
+ }, {}, {}>;
574
+ export declare class ApprovalResponse extends ApprovalResponse_base {
575
+ }
576
+ export declare const ApprovalStatusPending: Schema.Struct<{
577
+ status: Schema.Literal<["pending"]>;
578
+ }>;
579
+ export declare const ApprovalStatusResolved: Schema.Struct<{
580
+ status: Schema.Literal<["resolved"]>;
581
+ agent: Schema.optional<Schema.Struct<{
582
+ address: Schema.refine<string, typeof Schema.NonEmptyTrimmedString>;
583
+ agent_key_address: Schema.optional<Schema.refine<string, typeof Schema.NonEmptyTrimmedString>>;
584
+ }>>;
585
+ resolved_at: Schema.SchemaClass<string, string, never>;
586
+ }>;
587
+ export declare const ApprovalStatusRejected: Schema.Struct<{
588
+ status: Schema.Literal<["rejected"]>;
589
+ resolved_at: Schema.SchemaClass<string, string, never>;
590
+ }>;
591
+ export declare const ApprovalStatusBlocked: Schema.Struct<{
592
+ status: Schema.Literal<["blocked"]>;
593
+ resolved_at: Schema.SchemaClass<string, string, never>;
594
+ }>;
595
+ export declare const ApprovalStatus: Schema.Union<[Schema.Struct<{
596
+ status: Schema.Literal<["pending"]>;
597
+ }>, Schema.Struct<{
598
+ status: Schema.Literal<["resolved"]>;
599
+ agent: Schema.optional<Schema.Struct<{
600
+ address: Schema.refine<string, typeof Schema.NonEmptyTrimmedString>;
601
+ agent_key_address: Schema.optional<Schema.refine<string, typeof Schema.NonEmptyTrimmedString>>;
602
+ }>>;
603
+ resolved_at: Schema.SchemaClass<string, string, never>;
604
+ }>, Schema.Struct<{
605
+ status: Schema.Literal<["rejected"]>;
606
+ resolved_at: Schema.SchemaClass<string, string, never>;
607
+ }>, Schema.Struct<{
608
+ status: Schema.Literal<["blocked"]>;
609
+ resolved_at: Schema.SchemaClass<string, string, never>;
610
+ }>]>;
611
+ export type ApprovalStatus = typeof ApprovalStat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