@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
@@ -1,20 +1,63 @@
1
1
  #!/usr/bin/env node
2
- import { Command } from "commander";
2
+ import { Command, CommanderError } from "commander";
3
3
  import { VERSION } from "../version.js";
4
+ import { registerAgentCommand } from "./commands/agent.js";
5
+ import { registerCardCommand } from "./commands/card.js";
4
6
  import { registerConfigCommand } from "./commands/config.js";
5
7
  import { registerFetchCommand } from "./commands/fetch.js";
8
+ import { registerFundCommand } from "./commands/fund.js";
6
9
  import { registerMarketplaceCommand } from "./commands/marketplace.js";
7
10
  import { registerSetupCommand } from "./commands/setup.js";
11
+ import { registerVersionCommand } from "./commands/version.js";
12
+ import { err } from "./envelope.js";
13
+ // Map Commander's internal error codes to envelope codes. Anything not listed
14
+ // here falls back to "CLI_USAGE_ERROR" so we never emit a raw stderr line that
15
+ // breaks the documented JSON-only output contract.
16
+ const COMMANDER_ERROR_CODES = {
17
+ "commander.unknownOption": "UNKNOWN_OPTION",
18
+ "commander.unknownCommand": "UNKNOWN_COMMAND",
19
+ "commander.missingArgument": "MISSING_ARGUMENT",
20
+ "commander.missingMandatoryOptionValue": "MISSING_OPTION",
21
+ "commander.optionMissingArgument": "MISSING_OPTION_ARGUMENT",
22
+ "commander.invalidArgument": "INVALID_ARGUMENT",
23
+ "commander.conflictingOption": "CONFLICTING_OPTION",
24
+ "commander.excessArguments": "EXCESS_ARGUMENTS",
25
+ };
8
26
  async function main() {
9
27
  const program = new Command().name("ampersend").description("Command-line interface for ampersend").version(VERSION);
28
+ // Without exitOverride, Commander prints "error: unknown option '--foo'" to
29
+ // stderr and exits — bypassing our JSON envelope. Catch its CommanderError
30
+ // and re-throw so main()'s catch can format it. Help and version are not
31
+ // failures; let them exit cleanly. configureOutput silences Commander's
32
+ // own stderr line so the envelope is the only thing on the wire.
33
+ program.exitOverride((commanderErr) => {
34
+ if (commanderErr.code === "commander.helpDisplayed" || commanderErr.code === "commander.version") {
35
+ process.exit(commanderErr.exitCode);
36
+ }
37
+ throw commanderErr;
38
+ });
39
+ program.configureOutput({
40
+ outputError: () => { },
41
+ });
10
42
  registerConfigCommand(program);
11
43
  registerSetupCommand(program);
12
44
  registerFetchCommand(program);
45
+ registerAgentCommand(program);
46
+ registerCardCommand(program);
47
+ registerFundCommand(program);
13
48
  registerMarketplaceCommand(program);
49
+ registerVersionCommand(program);
14
50
  await program.parseAsync();
15
51
  }
16
52
  main().catch((error) => {
17
- console.error(`Fatal: ${error instanceof Error ? error.message : String(error)}`);
53
+ if (error instanceof CommanderError) {
54
+ const code = COMMANDER_ERROR_CODES[error.code] ?? "CLI_USAGE_ERROR";
55
+ const message = error.message.replace(/^error:\s*/, "");
56
+ console.log(JSON.stringify(err(code, message), null, 2));
57
+ process.exit(error.exitCode || 1);
58
+ }
59
+ const message = error instanceof Error ? error.message : String(error);
60
+ console.log(JSON.stringify(err("CLI_FATAL", message), null, 2));
18
61
  process.exit(1);
19
62
  });
20
63
  //# sourceMappingURL=ampersend.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ampersend.js","sourceRoot":"","sources":["../../src/cli/ampersend.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAA;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAC1D,OAAO,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAA;AACtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAE1D,KAAK,UAAU,IAAI;IACjB,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,WAAW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M,OAAO,CAAC,UAAU,EAAE,CAAA;AAC5B,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,IAAI,KAAK,YAAY,cAAc,EAAE,CAAC;QACpC,MAAM,IAAI,GAAG,qBAAqB,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,iBAAiB,CAAA;QACnE,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAA;QACvD,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAA;QACxD,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,IAAI,CAAC,CAAC,CAAA;IACnC,CAAC;IACD,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;IACtE,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,WAAW,EAAE,OAAO,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAA;IAC/D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC,CAAC,CAAA"}
@@ -0,0 +1,24 @@
1
+ import type { Command } from "commander";
2
+ import { AgentReadClient } from "../../ampersend/index.ts";
3
+ import { type ContextSelector } from "../config.ts";
4
+ interface BaseOptions {
5
+ raw: boolean;
6
+ context?: string;
7
+ }
8
+ /** Build an `AgentReadClient` from local config, or print an envelope-style error and exit. */
9
+ export declare function buildClient(opts?: ContextSelector): AgentReadClient;
10
+ /**
11
+ * Wrap a read call so success/failure both print the standard envelope.
12
+ * `--raw` mode prints the inner payload directly for scripting; the
13
+ * default JSON envelope is what the skill expects.
14
+ *
15
+ * BigInt is serialised as a decimal string — JSON has no native bigint
16
+ * and the DTOs decode wire strings into bigint values, so we have to
17
+ * project them back out when printing.
18
+ */
19
+ export declare function emit(label: string, options: BaseOptions, run: () => Promise<unknown>): Promise<void>;
20
+ export declare function parsePreset(value: string | undefined): "1d" | "30d" | "all" | undefined;
21
+ export declare function parseIntFlag(name: string, value: string | undefined, max?: number): number | undefined;
22
+ export declare function registerAgentCommand(program: Command): void;
23
+ export {};
24
+ //# sourceMappingURL=agent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAExC,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,EAAoC,KAAK,eAAe,EAAE,MAAM,cAAc,CAAA;AAGrF,UAAU,WAAW;IACnB,GAAG,EAAE,OAAO,CAAA;IACZ,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAOD,+FAA+F;AAC/F,wBAAgB,WAAW,CAAC,IAAI,GAAE,eAAoB,GAAG,eAAe,CAYvE;AAED;;;;;;;;GAQG;AACH,wBAAsB,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAc1G;AAMD,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,KAAK,GAAG,KAAK,GAAG,SAAS,CASvF;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CActG;AAID,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA8F3D"}
@@ -0,0 +1,166 @@
1
+ import { AgentReadClient } from "../../ampersend/index.js";
2
+ import { DEFAULT_API_URL, loadCredentials } from "../config.js";
3
+ import { err, ok } from "../envelope.js";
4
+ const VALID_PRESETS = new Set(["1d", "30d", "all"]);
5
+ /** `--context <name>` option, shared across the read subcommands. */
6
+ const CONTEXT_DESCRIPTION = "Run against a specific context instead of the active one";
7
+ /** Build an `AgentReadClient` from local config, or print an envelope-style error and exit. */
8
+ export function buildClient(opts = {}) {
9
+ const result = loadCredentials(opts);
10
+ if (!result.ok) {
11
+ console.log(JSON.stringify(result.error, null, 2));
12
+ process.exit(1);
13
+ }
14
+ const { agentAccount, agentKey, apiUrl } = result.credentials;
15
+ return new AgentReadClient({
16
+ baseUrl: apiUrl ?? DEFAULT_API_URL,
17
+ agentAddress: agentAccount,
18
+ sessionKeyPrivateKey: agentKey,
19
+ });
20
+ }
21
+ /**
22
+ * Wrap a read call so success/failure both print the standard envelope.
23
+ * `--raw` mode prints the inner payload directly for scripting; the
24
+ * default JSON envelope is what the skill expects.
25
+ *
26
+ * BigInt is serialised as a decimal string — JSON has no native bigint
27
+ * and the DTOs decode wire strings into bigint values, so we have to
28
+ * project them back out when printing.
29
+ */
30
+ export async function emit(label, options, run) {
31
+ try {
32
+ const data = await run();
33
+ const payload = options.raw ? data : ok(data);
34
+ console.log(JSON.stringify(payload, bigintReplacer, 2));
35
+ }
36
+ catch (error) {
37
+ const message = error instanceof Error ? error.message : String(error);
38
+ if (options.raw) {
39
+ console.error(`Error: ${message}`);
40
+ }
41
+ else {
42
+ console.log(JSON.stringify(err("AGENT_READ_ERROR", `${label}: ${message}`), null, 2));
43
+ }
44
+ process.exit(1);
45
+ }
46
+ }
47
+ function bigintReplacer(_key, value) {
48
+ return typeof value === "bigint" ? value.toString() : value;
49
+ }
50
+ export function parsePreset(value) {
51
+ if (value === undefined)
52
+ return undefined;
53
+ if (!VALID_PRESETS.has(value)) {
54
+ console.log(JSON.stringify(err("INVALID_PRESET", `Invalid --preset: ${value}. Must be one of: 1d, 30d, all`), null, 2));
55
+ process.exit(1);
56
+ }
57
+ return value;
58
+ }
59
+ export function parseIntFlag(name, value, max) {
60
+ if (value === undefined)
61
+ return undefined;
62
+ // Strict regex before parseInt: parseInt("1.5") === 1 silently drops the
63
+ // fraction, and parseInt(" 5 ") accepts whitespace.
64
+ if (!/^[1-9]\d*$/.test(value)) {
65
+ console.log(JSON.stringify(err("INVALID_FLAG", `--${name} must be a positive integer`), null, 2));
66
+ process.exit(1);
67
+ }
68
+ const n = Number.parseInt(value, 10);
69
+ if (max !== undefined && n > max) {
70
+ console.log(JSON.stringify(err("INVALID_FLAG", `--${name} must be ≤ ${max}`), null, 2));
71
+ process.exit(1);
72
+ }
73
+ return n;
74
+ }
75
+ const PRESET_DESCRIPTION = "Timerange: 1d (today), 30d (last 30 days), or all";
76
+ export function registerAgentCommand(program) {
77
+ // `agent` is both a runnable command (getSelf) and a parent of subcommands.
78
+ // When a flag like `--context` is declared on both the parent and a
79
+ // subcommand, Commander binds a post-subcommand flag to the parent, leaving
80
+ // the subcommand's own opts without it. `optsWithGlobals()` merges the
81
+ // parent's options down so the selector resolves wherever it was passed.
82
+ const merged = (options, command) => ({ ...options, ...command.optsWithGlobals() });
83
+ const agent = program
84
+ .command("agent")
85
+ .description("Read the calling agent's own state (server-authoritative)")
86
+ .option("--raw", "Print only the inner data, no JSON envelope", false)
87
+ .option("--context <name>", CONTEXT_DESCRIPTION)
88
+ .action(async (options, command) => {
89
+ const opts = merged(options, command);
90
+ await emit("getSelf", opts, () => buildClient(opts).getSelf());
91
+ });
92
+ agent
93
+ .command("spend-config")
94
+ .description("Show spending policy (per-tx, daily, monthly limits, auto-topup)")
95
+ .option("--raw", "Print only the inner data, no JSON envelope", false)
96
+ .option("--context <name>", CONTEXT_DESCRIPTION)
97
+ .action(async (options, command) => {
98
+ const opts = merged(options, command);
99
+ await emit("spend-config", opts, () => buildClient(opts).getSpendConfig());
100
+ });
101
+ agent
102
+ .command("auto-collect-config")
103
+ .description("Show auto-collect (earnings sweep) configuration")
104
+ .option("--raw", "Print only the inner data, no JSON envelope", false)
105
+ .option("--context <name>", CONTEXT_DESCRIPTION)
106
+ .action(async (options, command) => {
107
+ const opts = merged(options, command);
108
+ await emit("auto-collect-config", opts, () => buildClient(opts).getAutoCollectConfig());
109
+ });
110
+ agent
111
+ .command("authorized-sellers")
112
+ .description("Show the seller allowlist this agent is permitted to pay")
113
+ .option("--raw", "Print only the inner data, no JSON envelope", false)
114
+ .option("--context <name>", CONTEXT_DESCRIPTION)
115
+ .action(async (options, command) => {
116
+ const opts = merged(options, command);
117
+ await emit("authorized-sellers", opts, () => buildClient(opts).getAuthorizedSellers());
118
+ });
119
+ agent
120
+ .command("payments")
121
+ .description("Show outgoing payments")
122
+ .option("--raw", "Print only the inner data, no JSON envelope", false)
123
+ .option("--preset <preset>", PRESET_DESCRIPTION)
124
+ .option("--context <name>", CONTEXT_DESCRIPTION)
125
+ .action(async (options, command) => {
126
+ const opts = merged(options, command);
127
+ await emit("payments", opts, () => {
128
+ const preset = parsePreset(opts.preset);
129
+ return buildClient(opts).getPayments(preset ? { preset } : {});
130
+ });
131
+ });
132
+ agent
133
+ .command("activity")
134
+ .description("Show unified spend + earn activity, paginated")
135
+ .option("--raw", "Print only the inner data, no JSON envelope", false)
136
+ .option("--preset <preset>", PRESET_DESCRIPTION)
137
+ .option("--limit <n>", "Items per page (max 200, default 20)")
138
+ .option("--page <n>", "Page number (1-indexed, default 1)")
139
+ .option("--context <name>", CONTEXT_DESCRIPTION)
140
+ .action(async (options, command) => {
141
+ const opts = merged(options, command);
142
+ await emit("activity", opts, () => {
143
+ const params = {};
144
+ const preset = parsePreset(opts.preset);
145
+ if (preset !== undefined)
146
+ params.preset = preset;
147
+ const limit = parseIntFlag("limit", opts.limit, 200);
148
+ if (limit !== undefined)
149
+ params.limit = limit;
150
+ const page = parseIntFlag("page", opts.page);
151
+ if (page !== undefined)
152
+ params.page = page;
153
+ return buildClient(opts).getActivity(params);
154
+ });
155
+ });
156
+ agent
157
+ .command("owner")
158
+ .description("Show the owner's narrow projection ({ user_id, wallet_address })")
159
+ .option("--raw", "Print only the inner data, no JSON envelope", false)
160
+ .option("--context <name>", CONTEXT_DESCRIPTION)
161
+ .action(async (options, command) => {
162
+ const opts = merged(options, command);
163
+ await emit("owner", opts, () => buildClient(opts).getOwner());
164
+ });
165
+ }
166
+ //# sourceMappingURL=agent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent.js","sourceRoot":"","sources":["../../../src/cli/commands/agent.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,EAAE,eAAe,EAAE,eAAe,EAAwB,MAAM,cAAc,CAAA;AACrF,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAA;AAOxC,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAA;AAEnD,qEAAqE;AACrE,MAAM,mBAAmB,GAAG,0DAA0D,CAAA;AAEtF,+FAA+F;AAC/F,MAAM,UAAU,WAAW,CAAC,OAAwB,EAAE;IACpD,MAAM,MAAM,GAAG,eAAe,CAAC,IAAI,CAAC,CAAA;IACpC,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;QACf,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAA;QAClD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC;IACD,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC,WAAW,CAAA;IAC7D,OAAO,IAAI,eAAe,CAAC;QACzB,OAAO,EAAE,MAAM,IAAI,eAAe;QAClC,YAAY,EAAE,YAAY;QAC1B,oBAAoB,EAAE,QAAQ;KAC/B,CAAC,C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C,CAAC,WAAW,CAAC,MAAM,CAAC,CAAA;QAC9C,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IAEJ,KAAK;SACF,OAAO,CAAC,OAAO,CAAC;SAChB,WAAW,CAAC,kEAAkE,CAAC;SAC/E,MAAM,CAAC,OAAO,EAAE,6CAA6C,EAAE,KAAK,CAAC;SACrE,MAAM,CAAC,kBAAkB,EAAE,mBAAmB,CAAC;SAC/C,MAAM,CAAC,KAAK,EAAE,OAAoB,EAAE,OAAgB,EAAE,EAAE;QACvD,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;QACrC,MAAM,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAA;IAC/D,CAAC,CAAC,CAAA;AACN,CAAC"}
@@ -0,0 +1,128 @@
1
+ import type { Command } from "commander";
2
+ import { Schema } from "effect";
3
+ import { type JsonEnvelope } from "../envelope.ts";
4
+ /**
5
+ * One card as returned by `/get-card-data`. Secrets live under `card_details`
6
+ * and only once the card is ready; expiry is split into `exp_month`/`exp_year`.
7
+ * `available_balance` (vs `usd_amount`) tells you how much has been spent.
8
+ * Tolerant: we decode only the fields we surface and let Effect strip the rest.
9
+ */
10
+ declare const LasoCardData: Schema.Struct<{
11
+ readonly card_id: Schema.String;
12
+ readonly status: Schema.String;
13
+ readonly usd_amount: Schema.optional<Schema.Number>;
14
+ readonly timestamp: Schema.optional<Schema.Number>;
15
+ readonly card_type: Schema.optional<Schema.String>;
16
+ readonly card_details: Schema.optional<Schema.Struct<{
17
+ readonly card_number: Schema.optional<Schema.String>;
18
+ readonly exp_month: Schema.optional<Schema.String>;
19
+ readonly exp_year: Schema.optional<Schema.String>;
20
+ readonly cvv: Schema.optional<Schema.String>;
21
+ readonly available_balance: Schema.optional<Schema.Number>;
22
+ }>>;
23
+ readonly transactions: Schema.optional<Schema.$Array<Schema.Struct<{
24
+ readonly amount: Schema.optional<Schema.Union<readonly [Schema.Number, Schema.String]>>;
25
+ readonly date: Schema.optional<Schema.Union<readonly [Schema.String, Schema.Number]>>;
26
+ readonly description: Schema.optional<Schema.String>;
27
+ readonly is_credit: Schema.optional<Schema.Boolean>;
28
+ }>>>;
29
+ }>;
30
+ /** A decoded Laso card record (raw Laso field names). */
31
+ type LasoCard = typeof LasoCardData.Type;
32
+ interface IssueOptions {
33
+ amount?: string;
34
+ raw: boolean;
35
+ context?: string;
36
+ }
37
+ interface DetailsOptions {
38
+ pay: boolean;
39
+ reveal: boolean;
40
+ raw: boolean;
41
+ context?: string;
42
+ }
43
+ interface ListOptions {
44
+ pay: boolean;
45
+ raw: boolean;
46
+ context?: string;
47
+ }
48
+ /**
49
+ * Validate and normalize the `--amount` flag. Returns the trimmed USD string
50
+ * (Laso wants it verbatim in the query) or an error envelope. Rejects
51
+ * non-numeric, non-positive, and out-of-range values up front so we never
52
+ * spend on a request Laso would bounce.
53
+ */
54
+ declare function validateAmount(raw: string | undefined): JsonEnvelope<string>;
55
+ /** A transaction as surfaced to the agent (load, spends, refunds). Not masked. */
56
+ interface TransactionView {
57
+ amount?: number | string;
58
+ date?: string | number;
59
+ description?: string;
60
+ is_credit?: boolean;
61
+ }
62
+ /**
63
+ * A card as surfaced to the agent. A stable shape independent of Laso's wire
64
+ * format: `pan`/`cvv`/`expiry` regardless of how Laso nests them. Secrets are
65
+ * present only on a ready card, and masked unless `--reveal`.
66
+ *
67
+ * `amount` is the original load; `balance` is what's spendable now. Usage is
68
+ * read from the pair: unused when `balance === amount`, spent = `amount - balance`.
69
+ */
70
+ interface CardView {
71
+ card_id: string;
72
+ status: string;
73
+ amount?: number;
74
+ balance?: number;
75
+ ordered_at?: string;
76
+ card_type?: string;
77
+ pan?: string;
78
+ cvv?: string;
79
+ expiry?: string;
80
+ transactions?: ReadonlyArray<TransactionView>;
81
+ }
82
+ /**
83
+ * Normalize a decoded Laso card into the agent-facing view. Flattens the
84
+ * `card_details` nesting, composes `expiry` from `exp_month`/`exp_year`
85
+ * (e.g. "09" + "26" → "09/26"), surfaces `balance` (available_balance) next to
86
+ * `amount`, and converts the order `timestamp` (Unix ms) to an ISO string.
87
+ *
88
+ * `includeTransactions` is false for `list` (keep it compact) and true for
89
+ * `details`. Balance/secrets/transactions appear only on ready cards.
90
+ */
91
+ declare function toCardView(card: LasoCard, includeTransactions?: boolean): CardView;
92
+ /**
93
+ * Mask a PAN to its last four digits in groups of four: e.g. `4242424242424242`
94
+ * → `•••• •••• •••• 4242`. Tolerates spaces/dashes in the input and short
95
+ * inputs (fewer than four digits are shown as-is behind a single dot group).
96
+ */
97
+ declare function maskPan(pan: string): string;
98
+ /**
99
+ * Apply masking to an agent-facing card view unless `reveal` is set. Only the
100
+ * two secrets — PAN and CVV — are masked; everything else (including `expiry`,
101
+ * which isn't a secret on its own) passes through. Returns a copy.
102
+ */
103
+ declare function maskCard(card: CardView, reveal: boolean): CardView;
104
+ /** Compute a token's expiry ISO string from `/auth`'s `expires_in` (seconds). */
105
+ declare function tokenExpiry(expiresInSeconds: number | undefined): string;
106
+ /**
107
+ * `card issue --amount <usd>`: order a card. This is the stated-amount spend,
108
+ * so there is no --pay flag. Returns `{ card_id, status, payment }`; the agent
109
+ * polls `details <id>` until `status: "ready"`.
110
+ */
111
+ declare function executeIssue(options: IssueOptions): Promise<void>;
112
+ /**
113
+ * `card details <id> [--pay] [--reveal]`: fetch one card's status and (once
114
+ * ready) its data. A still-provisioning card returns `ok:true` with
115
+ * `status: "pending"` and no card data — not an error.
116
+ */
117
+ declare function executeDetails(id: string, options: DetailsOptions): Promise<void>;
118
+ /**
119
+ * `card list [--pay]`: all issued cards (always masked). Same token rules as
120
+ * `details`.
121
+ */
122
+ declare function executeList(options: ListOptions): Promise<void>;
123
+ /**
124
+ * Register the `card` subcommand on a Commander program.
125
+ */
126
+ export declare function registerCardCommand(program: Command): void;
127
+ export { executeDetails, executeIssue, executeList, maskCard, maskPan, toCardView, tokenExpiry, validateAmount };
128
+ //# sourceMappingURL=card.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"card.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/card.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAU/B,OAAO,EAAW,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAwE3D;;;;;GAKG;AACH,QAAA,MAAM,YAAY;;;;;;;;;;;;;;;;;;;EAgBhB,CAAA;AAYF,yDAAyD;AACzD,KAAK,QAAQ,GAAG,OAAO,YAAY,CAAC,IAAI,CAAA;AAKxC,UAAU,YAAY;IACpB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,GAAG,EAAE,OAAO,CAAA;IACZ,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,UAAU,cAAc;IACtB,GAAG,EAAE,OAAO,CAAA;IACZ,MAAM,EAAE,OAAO,CAAA;IACf,GAAG,EAAE,OAAO,CAAA;IACZ,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,UAAU,WAAW;IACnB,GAAG,EAAE,OAAO,CAAA;IACZ,GAAG,EAAE,OAAO,CAAA;IACZ,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAKD;;;;;GAKG;AACH,iBAAS,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,YAAY,CAAC,MAAM,CAAC,CAerE;AAED,kFAAkF;AAClF,UAAU,eAAe;IACvB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACxB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACtB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB;AAED;;;;;;;GAOG;AACH,UAAU,QAAQ;IAChB,OAAO,EAAE,MAAM,CAAA;IACf,M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