@ampersend_ai/ampersend-sdk 0.0.22 → 0.0.26

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 (119) hide show
  1. package/dist/ampersend/agent-client.d.ts +81 -0
  2. package/dist/ampersend/agent-client.d.ts.map +1 -0
  3. package/dist/ampersend/agent-client.js +104 -0
  4. package/dist/ampersend/agent-client.js.map +1 -0
  5. package/dist/ampersend/agent.d.ts +118 -0
  6. package/dist/ampersend/agent.d.ts.map +1 -0
  7. package/dist/ampersend/agent.js +109 -0
  8. package/dist/ampersend/agent.js.map +1 -0
  9. package/dist/ampersend/approval.js.map +1 -1
  10. package/dist/ampersend/client.d.ts +32 -8
  11. package/dist/ampersend/client.d.ts.map +1 -1
  12. package/dist/ampersend/client.js +81 -3
  13. package/dist/ampersend/client.js.map +1 -1
  14. package/dist/ampersend/curated-agent.d.ts +94 -94
  15. package/dist/ampersend/curated-agent.d.ts.map +1 -1
  16. package/dist/ampersend/curated-agent.js +41 -41
  17. package/dist/ampersend/curated-agent.js.map +1 -1
  18. package/dist/ampersend/index.d.ts +2 -0
  19. package/dist/ampersend/index.d.ts.map +1 -1
  20. package/dist/ampersend/index.js +4 -0
  21. package/dist/ampersend/index.js.map +1 -1
  22. package/dist/ampersend/management.d.ts +23 -59
  23. package/dist/ampersend/management.d.ts.map +1 -1
  24. package/dist/ampersend/management.js +6 -8
  25. package/dist/ampersend/management.js.map +1 -1
  26. package/dist/ampersend/marketplace.d.ts +20 -14
  27. package/dist/ampersend/marketplace.d.ts.map +1 -1
  28. package/dist/ampersend/marketplace.js +23 -49
  29. package/dist/ampersend/marketplace.js.map +1 -1
  30. package/dist/ampersend/treasurer.d.ts +4 -0
  31. package/dist/ampersend/treasurer.d.ts.map +1 -1
  32. package/dist/ampersend/treasurer.js +2 -2
  33. package/dist/ampersend/treasurer.js.map +1 -1
  34. package/dist/ampersend/types.d.ts +215 -310
  35. package/dist/ampersend/types.d.ts.map +1 -1
  36. package/dist/ampersend/types.js +146 -119
  37. package/dist/ampersend/types.js.map +1 -1
  38. package/dist/ampersend/zod-bridge.d.ts +4 -5
  39. package/dist/ampersend/zod-bridge.d.ts.map +1 -1
  40. package/dist/ampersend/zod-bridge.js +35 -19
  41. package/dist/ampersend/zod-bridge.js.map +1 -1
  42. package/dist/cli/ampersend.js +45 -2
  43. package/dist/cli/ampersend.js.map +1 -1
  44. package/dist/cli/commands/agent.d.ts +24 -0
  45. package/dist/cli/commands/agent.d.ts.map +1 -0
  46. package/dist/cli/commands/agent.js +166 -0
  47. package/dist/cli/commands/agent.js.map +1 -0
  48. package/dist/cli/commands/card.d.ts +128 -0
  49. package/dist/cli/commands/card.d.ts.map +1 -0
  50. package/dist/cli/commands/card.js +404 -0
  51. package/dist/cli/commands/card.js.map +1 -0
  52. package/dist/cli/commands/config.d.ts +1 -1
  53. package/dist/cli/commands/config.d.ts.map +1 -1
  54. package/dist/cli/commands/config.js +31 -42
  55. package/dist/cli/commands/config.js.map +1 -1
  56. package/dist/cli/commands/fetch.d.ts +77 -2
  57. package/dist/cli/commands/fetch.d.ts.map +1 -1
  58. package/dist/cli/commands/fetch.js +210 -129
  59. package/dist/cli/commands/fetch.js.map +1 -1
  60. package/dist/cli/commands/fund.d.ts +3 -0
  61. package/dist/cli/commands/fund.d.ts.map +1 -0
  62. package/dist/cli/commands/fund.js +22 -0
  63. package/dist/cli/commands/fund.js.map +1 -0
  64. package/dist/cli/commands/marketplace.d.ts +6 -0
  65. package/dist/cli/commands/marketplace.d.ts.map +1 -1
  66. package/dist/cli/commands/marketplace.js +27 -8
  67. package/dist/cli/commands/marketplace.js.map +1 -1
  68. package/dist/cli/commands/setup.d.ts +4 -1
  69. package/dist/cli/commands/setup.d.ts.map +1 -1
  70. package/dist/cli/commands/setup.js +66 -41
  71. package/dist/cli/commands/setup.js.map +1 -1
  72. package/dist/cli/commands/version.d.ts +3 -0
  73. package/dist/cli/commands/version.d.ts.map +1 -0
  74. package/dist/cli/commands/version.js +12 -0
  75. package/dist/cli/commands/version.js.map +1 -0
  76. package/dist/cli/config.d.ts +225 -45
  77. package/dist/cli/config.d.ts.map +1 -1
  78. package/dist/cli/config.js +426 -115
  79. package/dist/cli/config.js.map +1 -1
  80. package/dist/index.d.ts +2 -0
  81. package/dist/index.d.ts.map +1 -1
  82. package/dist/index.js +1 -0
  83. package/dist/index.js.map +1 -1
  84. package/dist/mcp/proxy/cli.js +1 -0
  85. package/dist/mcp/proxy/cli.js.map +1 -1
  86. package/dist/mcp/proxy/factory.d.ts +2 -0
  87. package/dist/mcp/proxy/factory.d.ts.map +1 -1
  88. package/dist/mcp/proxy/factory.js +10 -1
  89. package/dist/mcp/proxy/factory.js.map +1 -1
  90. package/dist/mcp/proxy/server/init.js +1 -1
  91. package/dist/mcp/proxy/server/init.js.map +1 -1
  92. package/dist/mcp/proxy/server/server.d.ts +3 -1
  93. package/dist/mcp/proxy/server/server.d.ts.map +1 -1
  94. package/dist/mcp/proxy/server/server.js +5 -2
  95. package/dist/mcp/proxy/server/server.js.map +1 -1
  96. package/dist/mcp/proxy/types.d.ts +7 -0
  97. package/dist/mcp/proxy/types.d.ts.map +1 -1
  98. package/dist/mcp/proxy/types.js.map +1 -1
  99. package/dist/version.d.ts +3 -1
  100. package/dist/version.d.ts.map +1 -1
  101. package/dist/version.js +3 -1
  102. package/dist/version.js.map +1 -1
  103. package/dist/x402/http/factory.d.ts +2 -0
  104. package/dist/x402/http/factory.d.ts.map +1 -1
  105. package/dist/x402/http/factory.js +1 -0
  106. package/dist/x402/http/factory.js.map +1 -1
  107. package/dist/x402/index.d.ts +2 -0
  108. package/dist/x402/index.d.ts.map +1 -1
  109. package/dist/x402/index.js +2 -0
  110. package/dist/x402/index.js.map +1 -1
  111. package/dist/x402/siwx.d.ts +55 -0
  112. package/dist/x402/siwx.d.ts.map +1 -0
  113. package/dist/x402/siwx.js +122 -0
  114. package/dist/x402/siwx.js.map +1 -0
  115. package/dist/x402/wallets/smart-account/cosigned.d.ts +9 -2
  116. package/dist/x402/wallets/smart-account/cosigned.d.ts.map +1 -1
  117. package/dist/x402/wallets/smart-account/cosigned.js +13 -4
  118. package/dist/x402/wallets/smart-account/cosigned.js.map +1 -1
  119. package/package.json +3 -2
@@ -0,0 +1,81 @@
1
+ import { AgentActivityResponse, AgentAutoCollectConfigDTO, AgentFundingLinkDTO, AgentOwnerDTO, AgentSelfDTO, AgentSelfPaymentDTO, AgentSelfSpendConfigDTO } from "./agent.ts";
2
+ import { ApiClient } from "./client.ts";
3
+ import { Address, type ApiClientOptions } from "./types.ts";
4
+ export interface AgentReadClientOptions extends ApiClientOptions {
5
+ }
6
+ /**
7
+ * Read-only client for an agent's own state on the Ampersend service.
8
+ *
9
+ * Wraps the `/v1/agents/self/*` endpoints. Auth is the standard
10
+ * agent SIWE session token, reused from {@link ApiClient}; the session
11
+ * pins which agent the server will answer for, so none of these methods
12
+ * take an agent address.
13
+ *
14
+ * Each response is decoded against the canonical DTO from `./agent.ts`.
15
+ * The server imports those same DTOs, so there is no drift surface
16
+ * between client and server for the agent-led read endpoints.
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * const agent = new AgentReadClient({
21
+ * baseUrl: "https://api.ampersend.ai",
22
+ * agentAddress,
23
+ * sessionKeyPrivateKey,
24
+ * })
25
+ * const snapshot = await agent.getSelf()
26
+ * const limits = await agent.getSpendConfig()
27
+ * const payments = await agent.getPayments({ preset: "30d" })
28
+ * ```
29
+ */
30
+ export declare class AgentReadClient {
31
+ private api;
32
+ /**
33
+ * Construct from credentials (production path) or from an existing
34
+ * `ApiClient` (test path / sharing auth state with another SDK client).
35
+ * Discriminates on shape, not `instanceof` — test doubles never satisfy
36
+ * `instanceof ApiClient` but do expose `getAuthorized`.
37
+ */
38
+ constructor(input: AgentReadClientOptions | ApiClient);
39
+ /** Full snapshot: agent record + live USDC balance. */
40
+ getSelf(): Promise<AgentSelfDTO>;
41
+ /**
42
+ * Spend policy (per-tx / daily / monthly limits, auto-topup) plus live
43
+ * remaining budgets. Throws `ApiError` with `status === 404` when no
44
+ * spend policy exists for this agent.
45
+ */
46
+ getSpendConfig(): Promise<AgentSelfSpendConfigDTO>;
47
+ /**
48
+ * Auto-collect (earnings sweep) configuration. Throws `ApiError` with
49
+ * `status === 404` when no auto-collect configuration exists for this
50
+ * agent.
51
+ */
52
+ getAutoCollectConfig(): Promise<AgentAutoCollectConfigDTO>;
53
+ /** Seller allowlist this agent is permitted to pay. */
54
+ getAuthorizedSellers(): Promise<ReadonlyArray<Address>>;
55
+ /** Outgoing payments. `preset` selects the timerange (default: 30d). */
56
+ getPayments(params?: {
57
+ preset?: "1d" | "30d" | "all";
58
+ }): Promise<ReadonlyArray<AgentSelfPaymentDTO>>;
59
+ /** Unified spend + earn activity, paginated. */
60
+ getActivity(params?: {
61
+ preset?: string;
62
+ limit?: number;
63
+ page?: number;
64
+ }): Promise<AgentActivityResponse>;
65
+ /** Narrow owner projection: `{ user_id, wallet_address }`. */
66
+ getOwner(): Promise<AgentOwnerDTO>;
67
+ /**
68
+ * Build a dashboard `/fund` URL the user can open to add USDC. The server
69
+ * is a pure URL formatter — no DB row, no token, no side effects. The
70
+ * returned URL preselects the calling agent (`destination: "agent"`, default)
71
+ * or the owner's main account (`destination: "main"`).
72
+ *
73
+ * `amount` is a decimal USDC string, strictly validated server-side as
74
+ * positive, ≤6 fractional digits, no leading zeros.
75
+ */
76
+ getFundingLink(params?: {
77
+ amount?: string;
78
+ destination?: "agent" | "main";
79
+ }): Promise<AgentFundingLinkDTO>;
80
+ }
81
+ //# sourceMappingURL=agent-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-client.d.ts","sourceRoot":"","sources":["../../src/ampersend/agent-client.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,qBAAqB,EACrB,yBAAyB,EACzB,mBAAmB,EACnB,aAAa,EACb,YAAY,EACZ,mBAAmB,EACnB,uBAAuB,EACxB,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE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entFundingLinkDTO, AgentOwnerDTO, AgentSelfDTO, AgentSelfPaymentDTO, AgentSelfSpendConfigDTO, } from "./agent.js";
3
+ import { ApiClient } from "./client.js";
4
+ import { Address } from "./types.js";
5
+ /**
6
+ * Read-only client for an agent's own state on the Ampersend service.
7
+ *
8
+ * Wraps the `/v1/agents/self/*` endpoints. Auth is the standard
9
+ * agent SIWE session token, reused from {@link ApiClient}; the session
10
+ * pins which agent the server will answer for, so none of these methods
11
+ * take an agent address.
12
+ *
13
+ * Each response is decoded against the canonical DTO from `./agent.ts`.
14
+ * The server imports those same DTOs, so there is no drift surface
15
+ * between client and server for the agent-led read endpoints.
16
+ *
17
+ * @example
18
+ * ```ts
19
+ * const agent = new AgentReadClient({
20
+ * baseUrl: "https://api.ampersend.ai",
21
+ * agentAddress,
22
+ * sessionKeyPrivateKey,
23
+ * })
24
+ * const snapshot = await agent.getSelf()
25
+ * const limits = await agent.getSpendConfig()
26
+ * const payments = await agent.getPayments({ preset: "30d" })
27
+ * ```
28
+ */
29
+ export class AgentReadClient {
30
+ api;
31
+ /**
32
+ * Construct from credentials (production path) or from an existing
33
+ * `ApiClient` (test path / sharing auth state with another SDK client).
34
+ * Discriminates on shape, not `instanceof` — test doubles never satisfy
35
+ * `instanceof ApiClient` but do expose `getAuthorized`.
36
+ */
37
+ constructor(input) {
38
+ this.api = "getAuthorized" in input ? input : new ApiClient(input);
39
+ }
40
+ /** Full snapshot: agent record + live USDC balance. */
41
+ getSelf() {
42
+ return this.api.getAuthorized("/api/v1/agents/self", AgentSelfDTO);
43
+ }
44
+ /**
45
+ * Spend policy (per-tx / daily / monthly limits, auto-topup) plus live
46
+ * remaining budgets. Throws `ApiError` with `status === 404` when no
47
+ * spend policy exists for this agent.
48
+ */
49
+ getSpendConfig() {
50
+ return this.api.getAuthorized("/api/v1/agents/self/spend-config", AgentSelfSpendConfigDTO);
51
+ }
52
+ /**
53
+ * Auto-collect (earnings sweep) configuration. Throws `ApiError` with
54
+ * `status === 404` when no auto-collect configuration exists for this
55
+ * agent.
56
+ */
57
+ getAutoCollectConfig() {
58
+ return this.api.getAuthorized("/api/v1/agents/self/auto-collect-config", AgentAutoCollectConfigDTO);
59
+ }
60
+ /** Seller allowlist this agent is permitted to pay. */
61
+ getAuthorizedSellers() {
62
+ return this.api.getAuthorized("/api/v1/agents/self/authorized-sellers", Schema.Array(Address));
63
+ }
64
+ /** Outgoing payments. `preset` selects the timerange (default: 30d). */
65
+ getPayments(params = {}) {
66
+ const qs = params.preset ? `?preset=${params.preset}` : "";
67
+ return this.api.getAuthorized(`/api/v1/agents/self/payments${qs}`, Schema.Array(AgentSelfPaymentDTO));
68
+ }
69
+ /** Unified spend + earn activity, paginated. */
70
+ getActivity(params = {}) {
71
+ const qs = new URLSearchParams();
72
+ if (params.preset)
73
+ qs.set("preset", params.preset);
74
+ if (params.limit != null)
75
+ qs.set("limit", String(params.limit));
76
+ if (params.page != null)
77
+ qs.set("page", String(params.page));
78
+ const suffix = qs.toString();
79
+ return this.api.getAuthorized(`/api/v1/agents/self/activity${suffix ? `?${suffix}` : ""}`, AgentActivityResponse);
80
+ }
81
+ /** Narrow owner projection: `{ user_id, wallet_address }`. */
82
+ getOwner() {
83
+ return this.api.getAuthorized("/api/v1/agents/self/owner", AgentOwnerDTO);
84
+ }
85
+ /**
86
+ * Build a dashboard `/fund` URL the user can open to add USDC. The server
87
+ * is a pure URL formatter — no DB row, no token, no side effects. The
88
+ * returned URL preselects the calling agent (`destination: "agent"`, default)
89
+ * or the owner's main account (`destination: "main"`).
90
+ *
91
+ * `amount` is a decimal USDC string, strictly validated server-side as
92
+ * positive, ≤6 fractional digits, no leading zeros.
93
+ */
94
+ getFundingLink(params = {}) {
95
+ const qs = new URLSearchParams();
96
+ if (params.amount != null)
97
+ qs.set("amount", params.amount);
98
+ if (params.destination != null)
99
+ qs.set("destination", params.destination);
100
+ const suffix = qs.toString();
101
+ return this.api.getAuthorized(`/api/v1/agents/self/funding-link${suffix ? `?${suffix}` : ""}`, AgentFundingLinkDTO);
102
+ }
103
+ }
104
+ //# sourceMappingURL=agent-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-client.js","sourceRoot":"","sources":["../../src/ampersend/agent-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE/B,OAAO,EACL,qBAAqB,EACrB,yBAAyB,EACzB,mBAAmB,EACnB,aAAa,EACb,YAAY,EACZ,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,OAAO,EAAyB,MAAM,YAAY,CAAA;AAI3D;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,OAAO,eAAe;IAClB,GAAG,CAAW;IAEtB;;;;;OAKG;IACH,YAAY,KAAyC;QACnD,IAAI,CAAC,GAAG,GAAG,eAAe,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,SAAS,CAAC,KAAK,CAAC,CAAA;IACpE,CAAC;IAED,uDAAuD;IACvD,OAAO;QACL,OAAO,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,qBAAqB,EAAE,YAAY,CAAC,CAAA;IACpE,CAAC;IAED;;;;OAIG;IACH,cAAc;QACZ,OAAO,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,kCAAkC,EAAE,uBAAuB,CAAC,CAAA;IAC5F,CAAC;IAED;;;;OAIG;IACH,oBAAoB;QAClB,OAAO,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,yCAAyC,EAAE,yBAAyB,CAAC,CAAA;IACrG,CAAC;IAED,uDAAuD;IACvD,oBAAoB;QAClB,OAAO,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,wCAAwC,EAAE,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAA;IAChG,CAAC;IAED,wEAAwE;IACxE,WAAW,CAAC,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CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,CAAA;QAC1D,IAAI,MAAM,CAAC,WAAW,IAAI,IAAI;YAAE,EAAE,CAAC,GAAG,CAAC,aAAa,EAAE,MAAM,CAAC,WAAW,CAAC,CAAA;QACzE,MAAM,MAAM,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAA;QAC5B,OAAO,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,mCAAmC,MAAM,CAAC,CAAC,CAAC,IAAI,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,mBAAmB,CAAC,CAAA;IACrH,CAAC;CACF"}
@@ -0,0 +1,118 @@
1
+ import { Schema } from "effect";
2
+ /**
3
+ * Full agent snapshot with live USDC balance.
4
+ *
5
+ * All bigint amounts on `AgentSelf*` DTOs are micro-USDC (1 USDC = 10^6). The
6
+ * `_usdc_micro` suffix makes the unit explicit at the wire-format boundary.
7
+ * Note: parent DTOs shared with the dashboard (`AgentSpendConfigDTO`,
8
+ * `AgentAutoCollectConfigDTO`) keep their unsuffixed names to avoid breaking
9
+ * existing dashboard consumers; new agent-facing fields adopt the convention.
10
+ */
11
+ export declare const AgentSelfDTO: Schema.Struct<{
12
+ readonly address: Schema.NonEmptyString;
13
+ readonly name: Schema.NonEmptyString;
14
+ readonly slug: Schema.NullOr<Schema.NonEmptyString>;
15
+ readonly status: Schema.Literals<readonly ["deploying", "deployed", "failed"]>;
16
+ readonly published: Schema.Boolean;
17
+ readonly registry_id: Schema.NullOr<Schema.NonEmptyString>;
18
+ readonly registry_uri: Schema.NullOr<Schema.NonEmptyString>;
19
+ readonly balance_usdc_micro: Schema.BigIntFromString;
20
+ }>;
21
+ export type AgentSelfDTO = typeof AgentSelfDTO.Type;
22
+ /** Spend policy (per-tx / daily / monthly limits, auto-topup). */
23
+ export declare const AgentSpendConfigDTO: Schema.Struct<{
24
+ readonly agent_address: Schema.NonEmptyString;
25
+ readonly daily_limit: Schema.NullOr<Schema.BigIntFromString>;
26
+ readonly monthly_limit: Schema.NullOr<Schema.BigIntFromString>;
27
+ readonly per_transaction_limit: Schema.NullOr<Schema.BigIntFromString>;
28
+ readonly auto_topup_allowed: Schema.Boolean;
29
+ readonly created_at: Schema.Union<readonly [Schema.Int, Schema.compose<Schema.Int, Schema.NumberFromString>]>;
30
+ readonly updated_at: Schema.Union<readonly [Schema.Int, Schema.compose<Schema.Int, Schema.NumberFromString>]>;
31
+ }>;
32
+ export type AgentSpendConfigDTO = typeof AgentSpendConfigDTO.Type;
33
+ /**
34
+ * Spend policy plus live remaining-budget figures for the calling agent.
35
+ * `daily_remaining` / `monthly_remaining` are `null` when the corresponding
36
+ * `*_limit` isn't set (i.e. unlimited).
37
+ */
38
+ export declare const AgentSelfSpendConfigDTO: Schema.Struct<{
39
+ readonly agent_address: Schema.NonEmptyString;
40
+ readonly daily_limit: Schema.NullOr<Schema.BigIntFromString>;
41
+ readonly monthly_limit: Schema.NullOr<Schema.BigIntFromString>;
42
+ readonly per_transaction_limit: Schema.NullOr<Schema.BigIntFromString>;
43
+ readonly auto_topup_allowed: Schema.Boolean;
44
+ readonly created_at: Schema.Union<readonly [Schema.Int, Schema.compose<Schema.Int, Schema.NumberFromString>]>;
45
+ readonly updated_at: Schema.Union<readonly [Schema.Int, Schema.compose<Schema.Int, Schema.NumberFromString>]>;
46
+ readonly daily_remaining_usdc_micro: Schema.NullOr<Schema.BigIntFromString>;
47
+ readonly monthly_remaining_usdc_micro: Schema.NullOr<Schema.BigIntFromString>;
48
+ }>;
49
+ export type AgentSelfSpendConfigDTO = typeof AgentSelfSpendConfigDTO.Type;
50
+ /** Auto-collect (earnings sweep) configuration. */
51
+ export declare const AgentAutoCollectConfigDTO: Schema.Struct<{
52
+ readonly agent_address: Schema.NonEmptyString;
53
+ readonly enabled: Schema.Boolean;
54
+ readonly target_address: Schema.NullOr<Schema.NonEmptyString>;
55
+ readonly threshold: Schema.BigIntFromString;
56
+ readonly minimum_remaining: Schema.NullOr<Schema.BigIntFromString>;
57
+ readonly created_at: Schema.Union<readonly [Schema.Int, Schema.compose<Schema.Int, Schema.NumberFromString>]>;
58
+ readonly updated_at: Schema.Union<readonly [Schema.Int, Schema.compose<Schema.Int, Schema.NumberFromString>]>;
59
+ }>;
60
+ export type AgentAutoCollectConfigDTO = typeof AgentAutoCollectConfigDTO.Type;
61
+ /** Outgoing payment as exposed to the calling agent (excludes signature, EIP-3009 nonce, internal row id, signing-key details). */
62
+ export declare const AgentSelfPaymentDTO: Schema.Struct<{
63
+ readonly seller_address: Schema.NonEmptyString;
64
+ readonly amount_usdc_micro: Schema.BigIntFromString;
65
+ readonly scheme: Schema.NullOr<Schema.Literals<readonly ["exact", "deferred"]>>;
66
+ readonly status: Schema.Literals<readonly ["requested", "authorized", "denied", "settled", "expired", "unmanaged", "success", "failure", "pending"]>;
67
+ readonly tx_hash: Schema.NullOr<Schema.NonEmptyString>;
68
+ readonly chain_caip2id: Schema.NullOr<Schema.NonEmptyString>;
69
+ readonly created_at: Schema.Union<readonly [Schema.Int, Schema.compose<Schema.Int, Schema.NumberFromString>]>;
70
+ readonly expires_at: Schema.NullOr<Schema.Union<readonly [Schema.Int, Schema.compose<Schema.Int, Schema.NumberFromString>]>>;
71
+ }>;
72
+ export type AgentSelfPaymentDTO = typeof AgentSelfPaymentDTO.Type;
73
+ /** Single row in the unified spend + earn activity feed. */
74
+ export declare const UnifiedAgentActivityDTO: Schema.Struct<{
75
+ readonly type: Schema.Literals<readonly ["earn", "spend"]>;
76
+ readonly id: Schema.String;
77
+ readonly agent_address: Schema.NonEmptyString;
78
+ readonly receiver: Schema.NonEmptyString;
79
+ readonly amount: Schema.Union<readonly [Schema.Number, Schema.NumberFromString]>;
80
+ readonly status: Schema.Literals<readonly ["received", "settled", "authorized", "failed", "denied"]>;
81
+ readonly timestamp: Schema.BigIntFromString;
82
+ readonly tx_hash: Schema.NullOr<Schema.String>;
83
+ readonly chain_caip2id: Schema.NullOr<Schema.String>;
84
+ }>;
85
+ export type UnifiedAgentActivityDTO = typeof UnifiedAgentActivityDTO.Type;
86
+ /** Paginated unified spend + earn activity response. */
87
+ export declare const AgentActivityResponse: Schema.Struct<{
88
+ readonly activity: Schema.$Array<Schema.Struct<{
89
+ readonly type: Schema.Literals<readonly ["earn", "spend"]>;
90
+ readonly id: Schema.String;
91
+ readonly agent_address: Schema.NonEmptyString;
92
+ readonly receiver: Schema.NonEmptyString;
93
+ readonly amount: Schema.Union<readonly [Schema.Number, Schema.NumberFromString]>;
94
+ readonly status: Schema.Literals<readonly ["received", "settled", "authorized", "failed", "denied"]>;
95
+ readonly timestamp: Schema.BigIntFromString;
96
+ readonly tx_hash: Schema.NullOr<Schema.String>;
97
+ readonly chain_caip2id: Schema.NullOr<Schema.String>;
98
+ }>>;
99
+ readonly hasNextPage: Schema.Boolean;
100
+ readonly totalCount: Schema.Int;
101
+ }>;
102
+ export type AgentActivityResponse = typeof AgentActivityResponse.Type;
103
+ /** Narrow owner projection: `{ user_id, wallet_address }` — no email, sibling agents, or cross-agent aggregates. */
104
+ export declare const AgentOwnerDTO: Schema.Struct<{
105
+ readonly user_id: Schema.brand<Schema.String, "ID">;
106
+ readonly wallet_address: Schema.NonEmptyString;
107
+ }>;
108
+ export type AgentOwnerDTO = typeof AgentOwnerDTO.Type;
109
+ /**
110
+ * Funding link the agent can present to its owner. The URL points at the
111
+ * dashboard's `/fund` page, prefilled per the requested destination. Pure
112
+ * URL formatter on the server — no DB row, no token, no side effects.
113
+ */
114
+ export declare const AgentFundingLinkDTO: Schema.Struct<{
115
+ readonly url: Schema.String;
116
+ }>;
117
+ export type AgentFundingLinkDTO = typeof AgentFundingLinkDTO.Type;
118
+ //# sourceMappingURL=agent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/ampersend/agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAqB/B;;;;;;;;GAQG;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, } from "./types.js";
3
+ // Response DTOs for `/v1/agents/self/*`. These are the canonical wire shapes
4
+ // for the agent-led read surface: the closed-source server imports them from
5
+ // this file (via `@ampersend_ai/ampersend-sdk/ampersend`) rather than defining
6
+ // its own copies. Keep field sets stable — adding/removing a field here is a
7
+ // breaking change for both SDK consumers and server callers.
8
+ const DeploymentStatus = Schema.Literals(["deploying", "deployed", "failed"]);
9
+ /**
10
+ * Full agent snapshot with live USDC balance.
11
+ *
12
+ * All bigint amounts on `AgentSelf*` DTOs are micro-USDC (1 USDC = 10^6). The
13
+ * `_usdc_micro` suffix makes the unit explicit at the wire-format boundary.
14
+ * Note: parent DTOs shared with the dashboard (`AgentSpendConfigDTO`,
15
+ * `AgentAutoCollectConfigDTO`) keep their unsuffixed names to avoid breaking
16
+ * existing dashboard consumers; new agent-facing fields adopt the convention.
17
+ */
18
+ export const AgentSelfDTO = Schema.Struct({
19
+ address: Address,
20
+ name: NonEmptyTrimmedString,
21
+ slug: Schema.NullOr(NonEmptyTrimmedString),
22
+ status: DeploymentStatus,
23
+ published: Schema.Boolean,
24
+ registry_id: Schema.NullOr(NonEmptyTrimmedString),
25
+ registry_uri: Schema.NullOr(NonEmptyTrimmedString),
26
+ balance_usdc_micro: Schema.BigIntFromString,
27
+ });
28
+ /** Spend policy (per-tx / daily / monthly limits, auto-topup). */
29
+ export const AgentSpendConfigDTO = Schema.Struct({
30
+ agent_address: Address,
31
+ daily_limit: Schema.NullOr(Schema.BigIntFromString),
32
+ monthly_limit: Schema.NullOr(Schema.BigIntFromString),
33
+ per_transaction_limit: Schema.NullOr(Schema.BigIntFromString),
34
+ auto_topup_allowed: Schema.Boolean,
35
+ created_at: ConvertedTimestamp,
36
+ updated_at: ConvertedTimestamp,
37
+ });
38
+ /**
39
+ * Spend policy plus live remaining-budget figures for the calling agent.
40
+ * `daily_remaining` / `monthly_remaining` are `null` when the corresponding
41
+ * `*_limit` isn't set (i.e. unlimited).
42
+ */
43
+ export const AgentSelfSpendConfigDTO = AgentSpendConfigDTO.pipe(Schema.fieldsAssign({
44
+ daily_remaining_usdc_micro: Schema.NullOr(Schema.BigIntFromString),
45
+ monthly_remaining_usdc_micro: Schema.NullOr(Schema.BigIntFromString),
46
+ }));
47
+ /** Auto-collect (earnings sweep) configuration. */
48
+ export const AgentAutoCollectConfigDTO = Schema.Struct({
49
+ agent_address: Address,
50
+ enabled: Schema.Boolean,
51
+ target_address: Schema.NullOr(Address),
52
+ threshold: Schema.BigIntFromString,
53
+ minimum_remaining: Schema.NullOr(Schema.BigIntFromString),
54
+ created_at: ConvertedTimestamp,
55
+ updated_at: ConvertedTimestamp,
56
+ });
57
+ /** Outgoing payment as exposed to the calling agent (excludes signature, EIP-3009 nonce, internal row id, signing-key details). */
58
+ export const AgentSelfPaymentDTO = Schema.Struct({
59
+ seller_address: Address,
60
+ amount_usdc_micro: Schema.BigIntFromString,
61
+ scheme: Schema.NullOr(Scheme),
62
+ status: Schema.Literals([
63
+ "requested",
64
+ "authorized",
65
+ "denied",
66
+ "settled",
67
+ "expired",
68
+ "unmanaged",
69
+ "success",
70
+ "failure",
71
+ "pending",
72
+ ]),
73
+ tx_hash: Schema.NullOr(TxHash),
74
+ chain_caip2id: Schema.NullOr(Caip2ID),
75
+ created_at: ConvertedTimestamp,
76
+ expires_at: Schema.NullOr(ConvertedTimestamp),
77
+ });
78
+ /** Single row in the unified spend + earn activity feed. */
79
+ export const UnifiedAgentActivityDTO = Schema.Struct({
80
+ type: Schema.Literals(["earn", "spend"]),
81
+ id: Schema.String,
82
+ agent_address: Address,
83
+ receiver: Address,
84
+ amount: Schema.Union([Schema.Number, Schema.NumberFromString]),
85
+ status: Schema.Literals(["received", "settled", "authorized", "failed", "denied"]),
86
+ timestamp: Schema.BigIntFromString,
87
+ tx_hash: Schema.NullOr(Schema.String),
88
+ chain_caip2id: Schema.NullOr(Schema.String),
89
+ });
90
+ /** Paginated unified spend + earn activity response. */
91
+ export const AgentActivityResponse = Schema.Struct({
92
+ activity: Schema.Array(UnifiedAgentActivityDTO),
93
+ hasNextPage: Schema.Boolean,
94
+ totalCount: NonNegativeInt,
95
+ });
96
+ /** Narrow owner projection: `{ user_id, wallet_address }` — no email, sibling agents, or cross-agent aggregates. */
97
+ export const AgentOwnerDTO = Schema.Struct({
98
+ user_id: ID,
99
+ wallet_address: Address,
100
+ });
101
+ /**
102
+ * Funding link the agent can present to its owner. The URL points at the
103
+ * dashboard's `/fund` page, prefilled per the requested destination. Pure
104
+ * URL formatter on the server — no DB row, no token, no side effects.
105
+ */
106
+ export const AgentFundingLinkDTO = Schema.Struct({
107
+ url: Schema.String,
108
+ });
109
+ //# sourceMappingURL=agent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent.js","sourceRoot":"","sources":["../../src/ampersend/agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE/B,OAAO,EACL,OAAO,EACP,OAAO,EACP,kBAAkB,EAClB,EAAE,EACF,qBAAqB,EACrB,cAAc,EACd,MAAM,EACN,MAAM,GACP,MAAM,YAAY,CAAA;AAEnB,6EAA6E;AAC7E,6EAA6E;AAC7E,+EAA+E;AAC/E,6EAA6E;AAC7E,6DAA6D;AAE7D,MAAM,gBAAgB,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,WAAW,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC,CAAA;AAE7E;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC;IACxC,OAAO,EAAE,OAAO;IAChB,IAAI,EAAE,qBAAqB;IAC3B,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,qBAAqB,CAAC;IAC1C,MAAM,EAAE,gBAAgB;IACxB,SAAS,EAAE,MAAM,CAAC,OAAO;IACzB,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,qBAAqB,CAAC;IACjD,YAAY,EAAE,MAAM,CAAC,MAAM,CAAC,qBAAqB,CAAC;I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x402/envelopes.ts";
2
- import { AgentAuthorizeRequest, AgentAuthorizeResponse, AgentPaymentEventResponse, type Address, type ApiClientOptions, type PaymentEvent } from "./types.js";
3
+ import { AgentAuthorizeRequest, AgentAuthorizeResponse, AgentPaymentEventResponse, SignSiwxResponse, type Address, type ApiClientOptions, type PaymentEvent } from "./types.js";
3
4
  export * from "./types.js";
4
5
  /**
5
6
  * TypeScript SDK for the API
@@ -8,10 +9,17 @@ export * from "./types.js";
8
9
  * including SIWE authentication and payment lifecycle management.
9
10
  */
10
11
  export declare class ApiClient {
11
- private baseUrl;
12
- private sessionKeyPrivateKey;
13
- private agentAddress;
14
- private timeout;
12
+ private readonly baseUrl;
13
+ private readonly sessionKeyPrivateKey;
14
+ private readonly agentAddress;
15
+ private readonly timeout;
16
+ /**
17
+ * `Ampersend-Client` header value sent on every authenticated request.
18
+ * Format: `<name>/<version>`. Used by the API for product-analytics
19
+ * client attribution. Defaults to `sdk-typescript/<VERSION>`; the
20
+ * `ampersend` CLI overrides `clientName` to `ampersend-cli`.
21
+ */
22
+ private clientHeader;
15
23
  private authMutex;
16
24
  private auth;
17
25
  constructor(options: ApiClientOptions);
@@ -20,15 +28,31 @@ export declare class ApiClient {
20
28
  */
21
29
  private performAuthentication;
22
30
  authorizePayment(paymentRequest: PaymentRequest, context?: AgentAuthorizeRequest["context"]): Promise<typeof AgentAuthorizeResponse.Type>;
31
+ /**
32
+ * Ask the Ampersend API to co-sign a Sign-In-With-X (CAIP-122 / EIP-4361)
33
+ * message. The service parses the message, verifies it claims this agent's
34
+ * smart account, and signs `hashMessage(message)` with the service key.
35
+ *
36
+ * The buyer concatenates this with its own session-key signature and wraps
37
+ * via CoSignerValidator for ERC-1271 verification.
38
+ */
39
+ signSiwxChallenge(message: string): Promise<typeof SignSiwxResponse.Type>;
23
40
  reportPaymentEvent(eventId: string, payment: PaymentAuthorization, event: PaymentEvent): Promise<AgentPaymentEventResponse>;
41
+ /**
42
+ * Authenticated GET against a path on the API. Performs SIWE auth first
43
+ * if needed, then decodes the response against `schema`. Use this from
44
+ * read-only clients that share auth with the rest of the SDK.
45
+ */
46
+ getAuthorized<A, I>(path: string, schema: Schema.Codec<A, I>): Promise<A>;
24
47
  /**
25
48
  * Clear the current authentication state
26
49
  */
27
50
  clearAuth(): void;
28
51
  /**
29
- * Get the configured agent address
52
+ * Get the configured agent address, or `undefined` if the client was
53
+ * constructed for unauthenticated reads only.
30
54
  */
31
- getAgentAddress(): Address;
55
+ getAgentAddress(): Address | undefined;
32
56
  /**
33
57
  * Check if currently authenticated and token is valid
34
58
  */
@@ -40,6 +64,6 @@ export declare class ApiClient {
40
64
  /**
41
65
  * Internal fetch wrapper with error handling and schema decoding
42
66
  */
43
- private fetch;
67
+ fetch<A, I>(path: string, init: RequestInit, schema: Schema.Codec<A, I>): Promise<A>;
44
68
  }
45
69
  //# sourceMappingURL=client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/ampersend/client.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAChF,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EAEtB,yBAAyB,EAIzB,KAAK,OAAO,EACZ,KAAK,gBAAgB,EAErB,KAAK,YAAY,EAElB,MAAM,YAAY,CAAA;AAEnB,cAAc,YAAY,CAAA;AAE1B;;;;;GAKG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,OAAO,CAAQ;IACvB,OAAO,CAAC,oBAAoB,CAA2B;IACvD,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,OAAO,CAAQ;IACvB,OAAO,CAAC,SAAS,CAAc;IAC/B,OAAO,CAAC,IAAI,CAGX;gBAEW,OAAO,EAAE,gBAAgB;IAOrC;;OAEG;YACW,qBAAqB;IAmE7B,gBAAgB,CACpB,cAAc,EAAE,cAAc,EAC9B,OAAO,CAAC,EAAE,qBAAqB,CAAC,SAA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