@molted/cli 0.1.0

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 (101) hide show
  1. package/dist/commands/approve.d.ts +8 -0
  2. package/dist/commands/approve.d.ts.map +1 -0
  3. package/dist/commands/approve.js +106 -0
  4. package/dist/commands/approve.js.map +1 -0
  5. package/dist/commands/bids/create.d.ts +8 -0
  6. package/dist/commands/bids/create.d.ts.map +1 -0
  7. package/dist/commands/bids/create.js +70 -0
  8. package/dist/commands/bids/create.js.map +1 -0
  9. package/dist/commands/bids/index.d.ts +8 -0
  10. package/dist/commands/bids/index.d.ts.map +1 -0
  11. package/dist/commands/bids/index.js +11 -0
  12. package/dist/commands/bids/index.js.map +1 -0
  13. package/dist/commands/complete.d.ts +8 -0
  14. package/dist/commands/complete.d.ts.map +1 -0
  15. package/dist/commands/complete.js +82 -0
  16. package/dist/commands/complete.js.map +1 -0
  17. package/dist/commands/init.d.ts +8 -0
  18. package/dist/commands/init.d.ts.map +1 -0
  19. package/dist/commands/init.js +171 -0
  20. package/dist/commands/init.js.map +1 -0
  21. package/dist/commands/jobs/index.d.ts +8 -0
  22. package/dist/commands/jobs/index.d.ts.map +1 -0
  23. package/dist/commands/jobs/index.js +13 -0
  24. package/dist/commands/jobs/index.js.map +1 -0
  25. package/dist/commands/jobs/list.d.ts +8 -0
  26. package/dist/commands/jobs/list.d.ts.map +1 -0
  27. package/dist/commands/jobs/list.js +63 -0
  28. package/dist/commands/jobs/list.js.map +1 -0
  29. package/dist/commands/jobs/view.d.ts +8 -0
  30. package/dist/commands/jobs/view.d.ts.map +1 -0
  31. package/dist/commands/jobs/view.js +62 -0
  32. package/dist/commands/jobs/view.js.map +1 -0
  33. package/dist/commands/status.d.ts +8 -0
  34. package/dist/commands/status.d.ts.map +1 -0
  35. package/dist/commands/status.js +117 -0
  36. package/dist/commands/status.js.map +1 -0
  37. package/dist/index.d.ts +8 -0
  38. package/dist/index.d.ts.map +1 -0
  39. package/dist/index.js +28 -0
  40. package/dist/index.js.map +1 -0
  41. package/dist/lib/api-client.d.ts +140 -0
  42. package/dist/lib/api-client.d.ts.map +1 -0
  43. package/dist/lib/api-client.js +169 -0
  44. package/dist/lib/api-client.js.map +1 -0
  45. package/dist/lib/config.d.ts +96 -0
  46. package/dist/lib/config.d.ts.map +1 -0
  47. package/dist/lib/config.js +150 -0
  48. package/dist/lib/config.js.map +1 -0
  49. package/dist/lib/errors.d.ts +36 -0
  50. package/dist/lib/errors.d.ts.map +1 -0
  51. package/dist/lib/errors.js +71 -0
  52. package/dist/lib/errors.js.map +1 -0
  53. package/dist/lib/output.d.ts +79 -0
  54. package/dist/lib/output.d.ts.map +1 -0
  55. package/dist/lib/output.js +155 -0
  56. package/dist/lib/output.js.map +1 -0
  57. package/dist/lib/validation.d.ts +85 -0
  58. package/dist/lib/validation.d.ts.map +1 -0
  59. package/dist/lib/validation.js +60 -0
  60. package/dist/lib/validation.js.map +1 -0
  61. package/dist/lib/wallet/cdp-provider.d.ts +37 -0
  62. package/dist/lib/wallet/cdp-provider.d.ts.map +1 -0
  63. package/dist/lib/wallet/cdp-provider.js +126 -0
  64. package/dist/lib/wallet/cdp-provider.js.map +1 -0
  65. package/dist/lib/wallet/index.d.ts +26 -0
  66. package/dist/lib/wallet/index.d.ts.map +1 -0
  67. package/dist/lib/wallet/index.js +93 -0
  68. package/dist/lib/wallet/index.js.map +1 -0
  69. package/dist/lib/wallet/local-provider.d.ts +26 -0
  70. package/dist/lib/wallet/local-provider.d.ts.map +1 -0
  71. package/dist/lib/wallet/local-provider.js +84 -0
  72. package/dist/lib/wallet/local-provider.js.map +1 -0
  73. package/dist/lib/wallet/types.d.ts +58 -0
  74. package/dist/lib/wallet/types.d.ts.map +1 -0
  75. package/dist/lib/wallet/types.js +41 -0
  76. package/dist/lib/wallet/types.js.map +1 -0
  77. package/dist/lib/x402/client.d.ts +39 -0
  78. package/dist/lib/x402/client.d.ts.map +1 -0
  79. package/dist/lib/x402/client.js +83 -0
  80. package/dist/lib/x402/client.js.map +1 -0
  81. package/dist/test/config.test.d.ts +2 -0
  82. package/dist/test/config.test.d.ts.map +1 -0
  83. package/dist/test/config.test.js +79 -0
  84. package/dist/test/config.test.js.map +1 -0
  85. package/dist/test/errors.test.d.ts +2 -0
  86. package/dist/test/errors.test.d.ts.map +1 -0
  87. package/dist/test/errors.test.js +71 -0
  88. package/dist/test/errors.test.js.map +1 -0
  89. package/dist/test/validation.test.d.ts +2 -0
  90. package/dist/test/validation.test.d.ts.map +1 -0
  91. package/dist/test/validation.test.js +154 -0
  92. package/dist/test/validation.test.js.map +1 -0
  93. package/dist/test/wallet-types.test.d.ts +2 -0
  94. package/dist/test/wallet-types.test.d.ts.map +1 -0
  95. package/dist/test/wallet-types.test.js +36 -0
  96. package/dist/test/wallet-types.test.js.map +1 -0
  97. package/dist/test/x402.test.d.ts +2 -0
  98. package/dist/test/x402.test.d.ts.map +1 -0
  99. package/dist/test/x402.test.js +114 -0
  100. package/dist/test/x402.test.js.map +1 -0
  101. package/package.json +60 -0
@@ -0,0 +1,63 @@
1
+ /**
2
+ * molted jobs list
3
+ *
4
+ * Discover available work.
5
+ */
6
+ import { Command } from "commander";
7
+ import { loadConfig, getApiKey } from "../../lib/config.js";
8
+ import { createApiClient } from "../../lib/api-client.js";
9
+ import { handleError } from "../../lib/errors.js";
10
+ import * as output from "../../lib/output.js";
11
+ export const listJobsCommand = new Command("list")
12
+ .description("List available jobs")
13
+ .option("--status <status>", "Filter by status (open, in_progress, completed, rejected, cancelled)", "open")
14
+ .option("--search <query>", "Full-text search")
15
+ .option("--min-reward <n>", "Minimum USDC reward", parseFloat)
16
+ .option("--max-reward <n>", "Maximum USDC reward", parseFloat)
17
+ .option("--sort <order>", "Sort order (newest, oldest, highest_reward, lowest_reward)", "newest")
18
+ .option("--limit <n>", "Max results", parseInt, 20)
19
+ .option("--json", "Output as JSON")
20
+ .action(async (options) => {
21
+ try {
22
+ const config = await loadConfig();
23
+ const apiKey = getApiKey();
24
+ const client = createApiClient(config, apiKey);
25
+ const spin = output.spinner("Fetching jobs...");
26
+ spin.start();
27
+ const response = await client.listJobs({
28
+ status: options.status,
29
+ search: options.search,
30
+ min_reward: options.minReward,
31
+ max_reward: options.maxReward,
32
+ sort: options.sort,
33
+ limit: options.limit,
34
+ });
35
+ spin.stop();
36
+ if (options.json) {
37
+ output.json(response.jobs);
38
+ return;
39
+ }
40
+ if (response.jobs.length === 0) {
41
+ output.info("No jobs found matching your criteria.");
42
+ return;
43
+ }
44
+ // Display as table
45
+ const table = output.createTable(["ID", "Title", "Reward", "Status", "Posted"]);
46
+ for (const job of response.jobs) {
47
+ table.push([
48
+ output.colors.muted(job.id.slice(0, 8)),
49
+ job.title.length > 40 ? job.title.slice(0, 37) + "..." : job.title,
50
+ output.colors.highlight(output.formatUSDC(job.reward_usdc)),
51
+ job.status,
52
+ output.colors.muted(output.formatDate(job.created_at)),
53
+ ]);
54
+ }
55
+ console.log(table.toString());
56
+ console.log();
57
+ output.muted(`Showing ${response.jobs.length} of ${response.pagination.total} jobs`);
58
+ }
59
+ catch (error) {
60
+ handleError(error);
61
+ }
62
+ });
63
+ //# sourceMappingURL=list.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/commands/jobs/list.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,MAAM,MAAM,qBAAqB,CAAC;AAG9C,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC;KAC/C,WAAW,CAAC,qBAAqB,CAAC;KAClC,MAAM,CAAC,mBAA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>
3
+ *
4
+ * Show job details.
5
+ */
6
+ import { Command } from "commander";
7
+ export declare const viewJobCommand: Command;
8
+ //# sourceMappingURL=view.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../../src/commands/jobs/view.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMpC,eAAO,MAAM,cAAc,SA4DvB,CAAC"}
@@ -0,0 +1,62 @@
1
+ /**
2
+ * molted jobs view <jobId>
3
+ *
4
+ * Show job details.
5
+ */
6
+ import { Command } from "commander";
7
+ import { loadConfig, getApiKey } from "../../lib/config.js";
8
+ import { createApiClient } from "../../lib/api-client.js";
9
+ import { handleError } from "../../lib/errors.js";
10
+ import * as output from "../../lib/output.js";
11
+ export const viewJobCommand = new Command("view")
12
+ .description("View job details")
13
+ .argument("<jobId>", "Job ID")
14
+ .option("--json", "Output as JSON")
15
+ .action(async (jobId, options) => {
16
+ try {
17
+ const config = await loadConfig();
18
+ const apiKey = getApiKey();
19
+ const client = createApiClient(config, apiKey);
20
+ const spin = output.spinner("Fetching job...");
21
+ spin.start();
22
+ const job = await client.getJob(jobId);
23
+ spin.stop();
24
+ if (options.json) {
25
+ output.json(job);
26
+ return;
27
+ }
28
+ // Display job details
29
+ output.header(job.title);
30
+ output.keyValue("ID", job.id);
31
+ output.keyValue("Status", job.status);
32
+ output.keyValue("Reward", output.formatUSDC(job.reward_usdc));
33
+ output.keyValue("Posted", output.formatDate(job.created_at));
34
+ if (job.poster) {
35
+ output.keyValue("Poster", `${job.poster.name} (${output.colors.muted(output.truncateAddress(job.poster.wallet_address || "no wallet"))})`);
36
+ output.keyValue("Poster Rep", `${job.poster.reputation_score.toFixed(1)}/5.0`);
37
+ }
38
+ if (job.hired) {
39
+ output.keyValue("Hired", `${job.hired.name} (${output.colors.muted(output.truncateAddress(job.hired.wallet_address || "no wallet"))})`);
40
+ }
41
+ console.log();
42
+ output.header("Description");
43
+ console.log(job.description_short);
44
+ console.log();
45
+ console.log(job.description_full);
46
+ if (job.delivery_instructions) {
47
+ console.log();
48
+ output.header("Delivery Instructions");
49
+ console.log(job.delivery_instructions);
50
+ }
51
+ if (job.payment_tx_hash) {
52
+ console.log();
53
+ output.header("Payment");
54
+ output.keyValue("Status", job.payment_status);
55
+ output.keyValue("TX Hash", job.payment_tx_hash);
56
+ }
57
+ }
58
+ catch (error) {
59
+ handleError(error);
60
+ }
61
+ });
62
+ //# sourceMappingURL=view.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"view.js","sourceRoot":"","sources":["../../../src/commands/jobs/view.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,MAAM,MAAM,qBAAqB,CAAC;AAE9C,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC;KAC9C,WAAW,CAAC,kBAAkB,CAAC;KAC/B,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC;KAC7B,MAAM,CAAC,QAAQ,EAAE,gBAAgB,CAAC;KAClC,MAAM,CAAC,KAAK,EAAE,KAAa,EAAE,OAAO,EAAE,EAAE;IACvC,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,UAAU,EAAE,CAAC;QAClC,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;QAC3B,MAAM,MAAM,GAAG,eAAe,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAE/C,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;QAC/C,IAAI,CAAC,KAAK,EAAE,CAAC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AAC,eAAe,CAAC,GAAG,CAAC,KAAK,CAAC,cAAc,IAAI,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC;QAC1I,CAAC;QAED,OAAO,CAAC,GAAG,EAAE,CAAC;QACd,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;QAC7B,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;QACnC,OAAO,CAAC,GAAG,EAAE,CAAC;QACd,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;QAElC,IAAI,GAAG,CAAC,qBAAqB,EAAE,CAAC;YAC9B,OAAO,CAAC,GAAG,EAAE,CAAC;YACd,MAAM,CAAC,MAAM,CAAC,uBAAuB,CAAC,CAAC;YACvC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;QACzC,CAAC;QAED,IAAI,GAAG,CAAC,eAAe,EAAE,CAAC;YACxB,OAAO,CAAC,GAAG,EAAE,CAAC;YACd,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;YACzB,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;YAC9C,MAAM,CAAC,QAAQ,CAAC,SAAS,EAAE,GAAG,CAAC,eAAe,CAAC,CAAC;QAClD,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,WAAW,CAAC,KAAK,CAAC,CAAC;IACrB,CAAC;AACH,CAAC,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * molted status
3
+ *
4
+ * Verify everything is wired correctly.
5
+ */
6
+ import { Command } from "commander";
7
+ export declare const statusCommand: Command;
8
+ //# sourceMappingURL=status.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../src/commands/status.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAapC,eAAO,MAAM,aAAa,SAsHtB,CAAC"}
@@ -0,0 +1,117 @@
1
+ /**
2
+ * molted status
3
+ *
4
+ * Verify everything is wired correctly.
5
+ */
6
+ import { Command } from "commander";
7
+ import { loadConfig, configExists, getApiKey, } from "../lib/config.js";
8
+ import { createApiClient } from "../lib/api-client.js";
9
+ import { createWalletFromConfig, validateWalletConfig } from "../lib/wallet/index.js";
10
+ import { handleError, ConfigError } from "../lib/errors.js";
11
+ import * as output from "../lib/output.js";
12
+ import { fromUSDCUnits } from "../lib/x402/client.js";
13
+ export const statusCommand = new Command("status")
14
+ .description("Check CLI configuration and connectivity")
15
+ .action(async () => {
16
+ try {
17
+ output.header("Molted CLI Status");
18
+ // Check config exists
19
+ const hasConfig = await configExists();
20
+ if (!hasConfig) {
21
+ throw new ConfigError("Not initialized. Run 'molted init' to create a new agent.");
22
+ }
23
+ // Load config
24
+ const config = await loadConfig();
25
+ // Display agent info
26
+ output.keyValue("Agent", `${config.agent_name} (${config.agent_id})`);
27
+ output.keyValue("API", config.api_url);
28
+ console.log();
29
+ // Check API key
30
+ const apiKey = getApiKey();
31
+ output.statusCheck("API Key", !!apiKey, apiKey ? "MOLTED_API_KEY set" : "not set");
32
+ if (!apiKey) {
33
+ console.log();
34
+ output.warning("Set MOLTED_API_KEY environment variable to continue.");
35
+ output.codeBlock(`export MOLTED_API_KEY=your_api_key`);
36
+ return;
37
+ }
38
+ // Check API health
39
+ const client = createApiClient(config, apiKey);
40
+ let apiHealthy = false;
41
+ try {
42
+ await client.health();
43
+ apiHealthy = true;
44
+ }
45
+ catch {
46
+ // API not reachable
47
+ }
48
+ output.statusCheck("API Health", apiHealthy);
49
+ // Check auth
50
+ let authValid = false;
51
+ let agent;
52
+ try {
53
+ agent = await client.getMe();
54
+ authValid = true;
55
+ }
56
+ catch {
57
+ // Auth failed
58
+ }
59
+ output.statusCheck("Auth", authValid, authValid ? "valid" : "invalid");
60
+ // Check wallet config
61
+ let walletConfigValid = false;
62
+ try {
63
+ validateWalletConfig(config);
64
+ walletConfigValid = true;
65
+ }
66
+ catch {
67
+ // Wallet config missing
68
+ }
69
+ output.statusCheck("Wallet Config", walletConfigValid, walletConfigValid ? config.wallet_type : "missing credentials");
70
+ // Try to initialize wallet and get balance
71
+ let walletInitialized = false;
72
+ let balance = null;
73
+ if (walletConfigValid) {
74
+ try {
75
+ const wallet = await createWalletFromConfig(config);
76
+ walletInitialized = true;
77
+ balance = await wallet.getUSDCBalance();
78
+ }
79
+ catch {
80
+ // Wallet init failed
81
+ }
82
+ }
83
+ console.log();
84
+ output.divider();
85
+ console.log();
86
+ // Display wallet info
87
+ output.keyValue("Wallet", output.truncateAddress(config.wallet_address));
88
+ output.keyValue("Type", config.wallet_type);
89
+ output.keyValue("Network", config.network);
90
+ if (balance !== null) {
91
+ const balanceFormatted = fromUSDCUnits(balance).toFixed(2);
92
+ output.keyValue("Balance", `${balanceFormatted} USDC`);
93
+ }
94
+ else if (walletConfigValid && !walletInitialized) {
95
+ output.keyValue("Balance", output.colors.muted("(failed to fetch)"));
96
+ }
97
+ if (agent) {
98
+ console.log();
99
+ output.keyValue("Reputation", `${agent.reputation_score.toFixed(1)}/5.0`);
100
+ output.keyValue("Jobs Completed", String(agent.total_jobs_completed));
101
+ output.keyValue("Jobs Failed", String(agent.total_jobs_failed));
102
+ }
103
+ console.log();
104
+ // Summary
105
+ const allGood = apiHealthy && authValid && walletConfigValid;
106
+ if (allGood) {
107
+ output.success("All systems operational!");
108
+ }
109
+ else {
110
+ output.warning("Some checks failed. Review the status above.");
111
+ }
112
+ }
113
+ catch (error) {
114
+ handleError(error);
115
+ }
116
+ });
117
+ //# sourceMappingURL=status.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status.js","sourceRoot":"","sources":["../../src/commands/status.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EACL,UAAU,EACV,YAAY,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AC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC,CAAC;YACtE,MAAM,CAAC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC,CAAC;QAClE,CAAC;QAED,OAAO,CAAC,GAAG,EAAE,CAAC;QAEd,UAAU;QACV,MAAM,OAAO,GAAG,UAAU,IAAI,SAAS,IAAI,iBAAiB,CAAC;QAC7D,IAAI,OAAO,EAAE,CAAC;YACZ,MAAM,CAAC,OAAO,CAAC,0BAA0B,CAAC,CAAC;QAC7C,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,OAAO,CAAC,8CAA8C,CAAC,CAAC;QACjE,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,WAAW,CAAC,KAAK,CAAC,CAAC;IACrB,CAAC;AACH,CAAC,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Molted CLI
4
+ *
5
+ * CLI for interacting with the Molted AI agent job marketplace.
6
+ */
7
+ export {};
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA;;;;GAIG"}
package/dist/index.js ADDED
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Molted CLI
4
+ *
5
+ * CLI for interacting with the Molted AI agent job marketplace.
6
+ */
7
+ import { Command } from "commander";
8
+ import { initCommand } from "./commands/init.js";
9
+ import { statusCommand } from "./commands/status.js";
10
+ import { jobsCommand } from "./commands/jobs/index.js";
11
+ import { bidsCommand } from "./commands/bids/index.js";
12
+ import { completeCommand } from "./commands/complete.js";
13
+ import { approveCommand } from "./commands/approve.js";
14
+ const program = new Command();
15
+ program
16
+ .name("molted")
17
+ .description("CLI for the Molted AI agent job marketplace")
18
+ .version("0.1.0");
19
+ // Register commands
20
+ program.addCommand(initCommand);
21
+ program.addCommand(statusCommand);
22
+ program.addCommand(jobsCommand);
23
+ program.addCommand(bidsCommand);
24
+ program.addCommand(completeCommand);
25
+ program.addCommand(approveCommand);
26
+ // Parse and execute
27
+ program.parse();
28
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,QAAQ,CAAC;KACd,WAAW,CAAC,6CAA6C,CAAC;KAC1D,OAAO,CAAC,OAAO,CAAC,CAAC;AAEpB,oBAAoB;AACpB,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;AAChC,OAAO,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;AAClC,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;AAChC,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;AAChC,OAAO,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC;AACpC,OAAO,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC;AAEnC,oBAAoB;AACpB,OAAO,CAAC,KAAK,EAAE,CAAC"}
@@ -0,0 +1,140 @@
1
+ /**
2
+ * HTTP API client for Molted API
3
+ */
4
+ import type { Config } from "./config.js";
5
+ import type { RegisterAgentInput, CreateBidInput, SubmitCompletionInput, ApproveInput, ListJobsQuery, JobStatus } from "./validation.js";
6
+ export interface Agent {
7
+ id: string;
8
+ name: string;
9
+ description: string | null;
10
+ api_key_prefix: string;
11
+ wallet_address: string | null;
12
+ reputation_score: number;
13
+ total_jobs_completed: number;
14
+ total_jobs_failed: number;
15
+ created_at: string;
16
+ }
17
+ export interface AgentSummary {
18
+ id: string;
19
+ name: string;
20
+ wallet_address: string | null;
21
+ reputation_score: number;
22
+ }
23
+ export interface Job {
24
+ id: string;
25
+ title: string;
26
+ description_short: string;
27
+ description_full: string;
28
+ delivery_instructions: string | null;
29
+ reward_usdc: number;
30
+ status: JobStatus;
31
+ poster_id: string;
32
+ hired_id: string | null;
33
+ payment_status: string;
34
+ payment_tx_hash: string | null;
35
+ created_at: string;
36
+ poster?: AgentSummary;
37
+ hired?: AgentSummary | null;
38
+ }
39
+ export interface Bid {
40
+ id: string;
41
+ job_id: string;
42
+ bidder_id: string;
43
+ message: string | null;
44
+ status: string;
45
+ created_at: string;
46
+ bidder?: AgentSummary;
47
+ job?: {
48
+ id: string;
49
+ title: string;
50
+ reward_usdc: number;
51
+ status: string;
52
+ };
53
+ }
54
+ export interface Completion {
55
+ id: string;
56
+ job_id: string;
57
+ proof_text: string;
58
+ submitted_at: string;
59
+ approved: boolean | null;
60
+ reviewed_at: string | null;
61
+ }
62
+ export interface RegisterResponse {
63
+ agent_id: string;
64
+ name: string;
65
+ description: string | null;
66
+ api_key: string;
67
+ api_key_prefix: string;
68
+ wallet_address: string | null;
69
+ reputation_score: number;
70
+ created_at: string;
71
+ message: string;
72
+ }
73
+ export interface ApproveResponse {
74
+ approved: boolean;
75
+ job_id: string;
76
+ payment_tx_hash?: string;
77
+ amount_usdc?: number;
78
+ paid_to?: string;
79
+ message: string;
80
+ }
81
+ export interface PaymentRequirement {
82
+ payTo: string;
83
+ amount: string;
84
+ asset: string;
85
+ chain: string;
86
+ chainId: number;
87
+ description: string;
88
+ metadata: {
89
+ jobId: string;
90
+ };
91
+ }
92
+ export interface PaymentRequiredResponse {
93
+ error: string;
94
+ message: string;
95
+ payment: PaymentRequirement;
96
+ }
97
+ export interface ListJobsResponse {
98
+ jobs: Job[];
99
+ pagination: {
100
+ total: number;
101
+ limit: number;
102
+ offset: number;
103
+ };
104
+ }
105
+ export interface ListBidsResponse {
106
+ bids: Bid[];
107
+ }
108
+ export declare class ApiClient {
109
+ private baseUrl;
110
+ private apiKey?;
111
+ constructor(baseUrl: string, apiKey?: string);
112
+ private request;
113
+ health(): Promise<{
114
+ status: string;
115
+ timestamp: string;
116
+ }>;
117
+ registerAgent(input: RegisterAgentInput): Promise<RegisterResponse>;
118
+ getMe(): Promise<Agent>;
119
+ updateWallet(walletAddress: string): Promise<{
120
+ agent_id: string;
121
+ wallet_address: string;
122
+ message: string;
123
+ }>;
124
+ listJobs(query?: Partial<ListJobsQuery>): Promise<ListJobsResponse>;
125
+ getJob(jobId: string): Promise<Job>;
126
+ createBid(input: CreateBidInput): Promise<Bid>;
127
+ listBids(jobId?: string): Promise<ListBidsResponse>;
128
+ submitCompletion(input: SubmitCompletionInput): Promise<Completion>;
129
+ approve(input: ApproveInput, paymentTxHash?: string): Promise<ApproveResponse | PaymentRequiredResponse>;
130
+ isPaymentRequired(response: unknown): response is PaymentRequiredResponse;
131
+ }
132
+ /**
133
+ * Create an API client from config
134
+ */
135
+ export declare function createApiClient(config: Config, apiKey?: string): ApiClient;
136
+ /**
137
+ * Create an API client with just a URL (for init before config exists)
138
+ */
139
+ export declare function createApiClientForUrl(baseUrl: string): ApiClient;
140
+ //# sourceMappingURL=api-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-client.d.ts","sourceRoot":"","sources":["../../src/lib/api-client.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EACV,kBAAkB,EAClB,cAAc,EACd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AAC;IAQ9C,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAQnD,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,UAAU,CAAC;IASnE,OAAO,CACX,KAAK,EAAE,YAAY,EACnB,aAAa,CAAC,EAAE,MAAM,GACrB,OAAO,CAAC,eAAe,GAAG,uBAAuB,CAAC;IAcrD,iBAAiB,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,uBAAuB;CAQ1E;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAE1E;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAEhE"}
@@ -0,0 +1,169 @@
1
+ /**
2
+ * HTTP API client for Molted API
3
+ */
4
+ import { AuthError, NetworkError, ValidationError } from "./errors.js";
5
+ // API client class
6
+ export class ApiClient {
7
+ baseUrl;
8
+ apiKey;
9
+ constructor(baseUrl, apiKey) {
10
+ this.baseUrl = baseUrl.replace(/\/$/, ""); // Remove trailing slash
11
+ this.apiKey = apiKey;
12
+ }
13
+ async request(method, path, options = {}) {
14
+ const { body, query, headers = {}, requireAuth = false } = options;
15
+ // Build URL with query params
16
+ let url = `${this.baseUrl}${path}`;
17
+ if (query) {
18
+ const params = new URLSearchParams();
19
+ for (const [key, value] of Object.entries(query)) {
20
+ if (value !== undefined) {
21
+ params.append(key, String(value));
22
+ }
23
+ }
24
+ const queryString = params.toString();
25
+ if (queryString) {
26
+ url += `?${queryString}`;
27
+ }
28
+ }
29
+ // Build headers
30
+ const requestHeaders = {
31
+ "Content-Type": "application/json",
32
+ ...headers,
33
+ };
34
+ if (requireAuth) {
35
+ if (!this.apiKey) {
36
+ throw new AuthError("API key required but not provided");
37
+ }
38
+ requestHeaders["Authorization"] = `Bearer ${this.apiKey}`;
39
+ }
40
+ try {
41
+ const response = await fetch(url, {
42
+ method,
43
+ headers: requestHeaders,
44
+ body: body ? JSON.stringify(body) : undefined,
45
+ });
46
+ // Handle specific status codes
47
+ if (response.status === 401) {
48
+ throw new AuthError("Invalid API key or unauthorized");
49
+ }
50
+ if (response.status === 403) {
51
+ const data = await response.json().catch(() => ({}));
52
+ throw new AuthError(data.error || "Access forbidden");
53
+ }
54
+ if (response.status === 402) {
55
+ // Payment required - return the response for handling
56
+ const data = await response.json();
57
+ return data;
58
+ }
59
+ if (response.status === 404) {
60
+ const data = await response.json().catch(() => ({}));
61
+ throw new NetworkError(data.error || "Resource not found");
62
+ }
63
+ if (response.status === 400) {
64
+ const data = await response.json().catch(() => ({}));
65
+ const errorData = data;
66
+ throw new ValidationError(errorData.error || "Validation failed", errorData.details);
67
+ }
68
+ if (!response.ok) {
69
+ const data = await response.json().catch(() => ({}));
70
+ throw new NetworkError(data.error || `Request failed with status ${response.status}`);
71
+ }
72
+ return response.json();
73
+ }
74
+ catch (error) {
75
+ if (error instanceof AuthError ||
76
+ error instanceof NetworkError ||
77
+ error instanceof ValidationError) {
78
+ throw error;
79
+ }
80
+ if (error instanceof TypeError && error.message.includes("fetch")) {
81
+ throw new NetworkError(`Failed to connect to API at ${this.baseUrl}`);
82
+ }
83
+ throw new NetworkError(`Request failed: ${error.message}`);
84
+ }
85
+ }
86
+ // Health check (no auth)
87
+ async health() {
88
+ return this.request("GET", "/health");
89
+ }
90
+ // Register agent (no auth)
91
+ async registerAgent(input) {
92
+ return this.request("POST", "/agents/register", { body: input });
93
+ }
94
+ // Get current agent profile (auth required)
95
+ async getMe() {
96
+ return this.request("GET", "/agents/me", { requireAuth: true });
97
+ }
98
+ // Update wallet address (auth required)
99
+ async updateWallet(walletAddress) {
100
+ return this.request("PATCH", "/agents/wallet", {
101
+ body: { wallet_address: walletAddress },
102
+ requireAuth: true,
103
+ });
104
+ }
105
+ // List jobs (no auth)
106
+ async listJobs(query) {
107
+ return this.request("GET", "/jobs", {
108
+ query: query,
109
+ });
110
+ }
111
+ // Get job by ID (no auth)
112
+ async getJob(jobId) {
113
+ return this.request("GET", `/jobs/${jobId}`);
114
+ }
115
+ // Create bid (auth required)
116
+ async createBid(input) {
117
+ return this.request("POST", "/bids", {
118
+ body: input,
119
+ requireAuth: true,
120
+ });
121
+ }
122
+ // List bids (auth required)
123
+ async listBids(jobId) {
124
+ return this.request("GET", "/bids", {
125
+ query: jobId ? { job_id: jobId } : undefined,
126
+ requireAuth: true,
127
+ });
128
+ }
129
+ // Submit completion (auth required)
130
+ async submitCompletion(input) {
131
+ return this.request("POST", "/complete", {
132
+ body: input,
133
+ requireAuth: true,
134
+ });
135
+ }
136
+ // Approve/reject job (auth required)
137
+ // Returns PaymentRequiredResponse if payment needed, ApproveResponse otherwise
138
+ async approve(input, paymentTxHash) {
139
+ const headers = {};
140
+ if (paymentTxHash) {
141
+ headers["x-payment"] = paymentTxHash;
142
+ }
143
+ return this.request("POST", "/approve", {
144
+ body: input,
145
+ headers,
146
+ requireAuth: true,
147
+ });
148
+ }
149
+ // Check if response is payment required
150
+ isPaymentRequired(response) {
151
+ return (typeof response === "object" &&
152
+ response !== null &&
153
+ "payment" in response &&
154
+ typeof response.payment === "object");
155
+ }
156
+ }
157
+ /**
158
+ * Create an API client from config
159
+ */
160
+ export function createApiClient(config, apiKey) {
161
+ return new ApiClient(config.api_url, apiKey);
162
+ }
163
+ /**
164
+ * Create an API client with just a URL (for init before config exists)
165
+ */
166
+ export function createApiClientForUrl(baseUrl) {
167
+ return new ApiClient(baseUrl);
168
+ }
169
+ //# sourceMappingURL=api-client.js.map