@jecpdev/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.
package/LICENSE ADDED
@@ -0,0 +1,190 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for describing the origin of the Work and
141
+ reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Support. While redistributing the Work or
166
+ Derivative Works thereof, You may choose to offer, and charge a
167
+ fee for, acceptance of support, warranty, indemnity, or other
168
+ liability obligations and/or rights consistent with this License.
169
+ However, in accepting such obligations, You may act only on Your
170
+ own behalf and on Your sole responsibility, not on behalf of any
171
+ other Contributor, and only if You agree to indemnify, defend,
172
+ and hold each Contributor harmless for any liability incurred by,
173
+ or claims asserted against, such Contributor by reason of your
174
+ accepting any such warranty or support.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ Copyright 2026 Tufe Company Inc.
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software
187
+ distributed under the License is distributed on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
+ See the License for the specific language governing permissions and
190
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,92 @@
1
+ # @jecpdev/cli
2
+
3
+ > Command-line interface for **JECP — Joint Execution & Commerce Protocol**.
4
+ > Register agents, invoke capabilities, manage Providers from your terminal.
5
+
6
+ [![npm](https://img.shields.io/npm/v/@jecpdev/cli.svg)](https://npmjs.com/package/@jecpdev/cli)
7
+ [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE)
8
+
9
+ ```bash
10
+ npm install -g @jecpdev/cli
11
+ # or one-shot
12
+ npx @jecpdev/cli --help
13
+ ```
14
+
15
+ ## Quickstart — agent in 30 seconds
16
+
17
+ ```bash
18
+ $ jecp register --name MyBot --type demo
19
+ ✓ Agent registered.
20
+
21
+ AGENT_ID: jdb_ag_a1b2c3...
22
+ API_KEY: jdb_ak_xxxxxxxxxxxx
23
+ Free calls: 100
24
+
25
+ ✓ Credentials saved to ~/.jecp/config.json (mode 0600)
26
+
27
+ $ jecp invoke jobdonebot/content-factory translate \
28
+ --input '{"text":"Hello","target_lang":"JA"}'
29
+ ✓ Invocation complete.
30
+
31
+ Output: {"translated":"こんにちは"}
32
+ Provider: jobdonebot/content-factory@1.0.0
33
+ Charged: $0.005 USDC
34
+ Balance: $0.995 USDC
35
+ ```
36
+
37
+ ## Commands
38
+
39
+ | Command | Description |
40
+ |---------|-------------|
41
+ | `jecp register` | Register a new agent (interactive or via flags) |
42
+ | `jecp login` | Save existing agent credentials |
43
+ | `jecp logout` | Clear stored credentials |
44
+ | `jecp invoke <cap> <action>` | Invoke a capability action |
45
+ | `jecp catalog` | List capabilities (paginated) |
46
+ | `jecp topup <amount>` | Top up wallet (5/20/100 USDC) |
47
+ | `jecp status` | Show health, balance, agent info |
48
+ | `jecp doctor` | Diagnose connectivity, config, SDK version |
49
+
50
+ Run `jecp <command> --help` for full options.
51
+
52
+ ## Global flags
53
+
54
+ - `--json` — machine-readable JSON output (for CI/scripting)
55
+ - `--base-url <url>` — override Hub URL (default `https://jecp.dev`)
56
+
57
+ ## Auth precedence
58
+
59
+ 1. `JECP_AGENT_ID` + `JECP_AGENT_KEY` env vars (CI mode)
60
+ 2. `~/.jecp/config.json` (saved by `register` or `login`)
61
+
62
+ ## Config file
63
+
64
+ Stored at `~/.jecp/config.json` with mode `0600`. Contains `agent_id`, `api_key`, `base_url`. Treat like a Stripe secret key.
65
+
66
+ ## Examples
67
+
68
+ ### Invoke with budget cap
69
+
70
+ ```bash
71
+ jecp invoke deepl/translate translate \
72
+ --input '{"text":"Hello","target_lang":"JA"}' \
73
+ --budget 1.00 \
74
+ --timeout 60000
75
+ ```
76
+
77
+ ### Discover capabilities
78
+
79
+ ```bash
80
+ jecp catalog --page-size 100 --namespace jobdonebot
81
+ ```
82
+
83
+ ### CI integration
84
+
85
+ ```bash
86
+ JECP_AGENT_ID=jdb_ag_... JECP_AGENT_KEY=jdb_ak_... \
87
+ jecp invoke a/b c --json | jq '.output'
88
+ ```
89
+
90
+ ## License
91
+
92
+ Apache 2.0 — Tufe Company Inc.
@@ -0,0 +1,49 @@
1
+ import {
2
+ getClient
3
+ } from "./chunk-FH4G7W5M.js";
4
+ import {
5
+ bold,
6
+ dim,
7
+ emit,
8
+ info
9
+ } from "./chunk-AHQEKKK7.js";
10
+ import "./chunk-DZLDBWTB.js";
11
+
12
+ // src/commands/catalog.ts
13
+ async function catalogCmd(opts) {
14
+ const jecp = getClient();
15
+ if (opts.all) {
16
+ const result2 = await jecp.catalogAll();
17
+ emit(result2, () => printCatalog(result2));
18
+ return;
19
+ }
20
+ const pageSize = opts.pageSize ? parseInt(opts.pageSize, 10) : 50;
21
+ const result = await jecp.catalog({
22
+ pageSize,
23
+ ...opts.namespace && { namespace: opts.namespace },
24
+ ...opts.tags && { tags: opts.tags.split(",") }
25
+ });
26
+ emit(result, () => printCatalog(result));
27
+ }
28
+ function printCatalog(c) {
29
+ const tp = c.third_party_capabilities ?? [];
30
+ if (tp.length === 0) {
31
+ info(dim("(no third-party capabilities yet)"));
32
+ } else {
33
+ info(bold(`Third-party capabilities (${tp.length}${c.has_more ? "+" : ""}):`));
34
+ info("");
35
+ for (const cap of tp) {
36
+ info(` ${bold(cap.id)} ${dim(`${cap.total_calls ?? 0} calls`)}`);
37
+ if (cap.description) info(` ${cap.description}`);
38
+ if (cap.tags && cap.tags.length > 0) info(` ${dim("tags: " + cap.tags.join(", "))}`);
39
+ info("");
40
+ }
41
+ }
42
+ info(dim(`Page size: ${c.page_size ?? "?"}, has_more: ${c.has_more ?? false}`));
43
+ if (c.has_more && c.next_cursor) {
44
+ info(dim(`Next page: jecp catalog --cursor ${c.next_cursor}`));
45
+ }
46
+ }
47
+ export {
48
+ catalogCmd
49
+ };
@@ -0,0 +1,52 @@
1
+ // src/output.ts
2
+ import kleur from "kleur";
3
+ var jsonMode = false;
4
+ function setJsonMode(on) {
5
+ jsonMode = on;
6
+ }
7
+ function info(msg) {
8
+ if (!jsonMode) console.log(msg);
9
+ }
10
+ function success(msg) {
11
+ if (!jsonMode) console.log(kleur.green("\u2713"), msg);
12
+ }
13
+ function warn(msg) {
14
+ if (!jsonMode) console.warn(kleur.yellow("\u26A0"), msg);
15
+ }
16
+ function error(msg) {
17
+ if (!jsonMode) console.error(kleur.red("\u2717"), msg);
18
+ }
19
+ function dim(msg) {
20
+ return jsonMode ? msg : kleur.dim(msg);
21
+ }
22
+ function bold(msg) {
23
+ return jsonMode ? msg : kleur.bold(msg);
24
+ }
25
+ function emit(payload, prettyFn) {
26
+ if (jsonMode) {
27
+ process.stdout.write(JSON.stringify(payload, null, 2) + "\n");
28
+ } else {
29
+ if (prettyFn) prettyFn(payload);
30
+ else console.log(payload);
31
+ }
32
+ }
33
+ function fail(msg, code = 1) {
34
+ if (jsonMode) {
35
+ process.stdout.write(JSON.stringify({ ok: false, error: msg }) + "\n");
36
+ } else {
37
+ error(msg);
38
+ }
39
+ process.exit(code);
40
+ }
41
+
42
+ export {
43
+ setJsonMode,
44
+ info,
45
+ success,
46
+ warn,
47
+ error,
48
+ dim,
49
+ bold,
50
+ emit,
51
+ fail
52
+ };
@@ -0,0 +1,39 @@
1
+ // src/config.ts
2
+ import { readFileSync, writeFileSync, mkdirSync, existsSync, chmodSync } from "fs";
3
+ import { homedir } from "os";
4
+ import { join } from "path";
5
+ var CONFIG_DIR = join(homedir(), ".jecp");
6
+ var CONFIG_FILE = join(CONFIG_DIR, "config.json");
7
+ function loadConfig() {
8
+ if (!existsSync(CONFIG_FILE)) return {};
9
+ try {
10
+ return JSON.parse(readFileSync(CONFIG_FILE, "utf-8"));
11
+ } catch {
12
+ return {};
13
+ }
14
+ }
15
+ function saveConfig(cfg) {
16
+ if (!existsSync(CONFIG_DIR)) {
17
+ mkdirSync(CONFIG_DIR, { recursive: true, mode: 448 });
18
+ }
19
+ writeFileSync(CONFIG_FILE, JSON.stringify(cfg, null, 2));
20
+ chmodSync(CONFIG_FILE, 384);
21
+ }
22
+ function resolveAuth() {
23
+ const cfg = loadConfig();
24
+ return {
25
+ agentId: process.env.JECP_AGENT_ID ?? cfg.agent_id,
26
+ apiKey: process.env.JECP_AGENT_KEY ?? cfg.api_key,
27
+ baseUrl: process.env.JECP_BASE_URL ?? cfg.base_url ?? "https://jecp.dev"
28
+ };
29
+ }
30
+ function configFilePath() {
31
+ return CONFIG_FILE;
32
+ }
33
+
34
+ export {
35
+ loadConfig,
36
+ saveConfig,
37
+ resolveAuth,
38
+ configFilePath
39
+ };
@@ -0,0 +1,28 @@
1
+ import {
2
+ fail
3
+ } from "./chunk-AHQEKKK7.js";
4
+ import {
5
+ resolveAuth
6
+ } from "./chunk-DZLDBWTB.js";
7
+
8
+ // src/sdk.ts
9
+ import { JecpClient } from "@jecpdev/sdk";
10
+ function getClient() {
11
+ const { agentId, apiKey, baseUrl } = resolveAuth();
12
+ if (!agentId || !apiKey) {
13
+ fail("Not logged in. Run `jecp login` or `jecp register`.");
14
+ }
15
+ return new JecpClient({
16
+ agentId,
17
+ apiKey,
18
+ ...baseUrl && { baseUrl }
19
+ });
20
+ }
21
+ function getBaseUrl() {
22
+ return resolveAuth().baseUrl ?? "https://jecp.dev";
23
+ }
24
+
25
+ export {
26
+ getClient,
27
+ getBaseUrl
28
+ };
package/dist/cli.d.ts ADDED
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node
package/dist/cli.js ADDED
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ fail,
4
+ setJsonMode
5
+ } from "./chunk-AHQEKKK7.js";
6
+
7
+ // src/cli.ts
8
+ import { Command } from "commander";
9
+ var program = new Command();
10
+ program.name("jecp").description("Command-line interface for JECP \u2014 Joint Execution & Commerce Protocol").version("0.1.0").option("--json", "Machine-readable JSON output").option("--base-url <url>", "Override Hub URL (default https://jecp.dev)").hook("preAction", (cmd) => {
11
+ if (cmd.opts().json) setJsonMode(true);
12
+ if (cmd.opts().baseUrl) process.env.JECP_BASE_URL = cmd.opts().baseUrl;
13
+ });
14
+ program.command("register").description("Register a new agent (interactive or with flags)").option("-n, --name <name>", "Agent name (display label)").option("-t, --type <type>", "Agent type (research, coder, demo, etc.)").option("-d, --description <description>", "Optional description").action(async (opts) => {
15
+ const { registerCmd } = await import("./register-XWWS42Z7.js");
16
+ await registerCmd(opts);
17
+ });
18
+ program.command("login").description("Save existing agent credentials to ~/.jecp/config.json").option("--agent-id <id>", "Agent ID").option("--api-key <key>", "API key").option("--base-url <url>", "Override Hub URL").action(async (opts) => {
19
+ const { loginCmd } = await import("./login-2C7JY62W.js");
20
+ await loginCmd(opts);
21
+ });
22
+ program.command("logout").description("Clear stored credentials").action(async () => {
23
+ const { logoutCmd } = await import("./login-2C7JY62W.js");
24
+ await logoutCmd();
25
+ });
26
+ program.command("invoke <capability> <action>").description("Invoke a capability action (capability format: namespace/capability)").option("-i, --input <json>", "Input as JSON string", "{}").option("-b, --budget <usdc>", "Mandate budget cap in USDC (e.g. 1.00)").option("-t, --timeout <ms>", "Request timeout in milliseconds").option("--request-id <id>", "Override idempotency key (default: auto UUID)").action(async (capability, action, opts) => {
27
+ const { invokeCmd } = await import("./invoke-NHTPS6NN.js");
28
+ await invokeCmd(capability, action, opts);
29
+ });
30
+ program.command("catalog").description("List capabilities (paginated by default)").option("--page-size <n>", "Items per page (1-200)", "50").option("--namespace <ns>", "Filter by Provider namespace").option("--tags <csv>", "Comma-separated tag filter").option("--all", "Fetch all in legacy mode (?paginated=false)").action(async (opts) => {
31
+ const { catalogCmd } = await import("./catalog-2S36KJ4V.js");
32
+ await catalogCmd(opts);
33
+ });
34
+ program.command("topup <amount>").description("Top up wallet via Stripe Checkout (amount: 5, 20, or 100)").option("--return-to <url>", "Redirect URL after payment").action(async (amount, opts) => {
35
+ const { topupCmd } = await import("./topup-5HW7VT42.js");
36
+ await topupCmd(amount, opts);
37
+ });
38
+ program.command("status").description("Show health, balance, agent info").action(async () => {
39
+ const { statusCmd } = await import("./status-PXIL5KZB.js");
40
+ await statusCmd();
41
+ });
42
+ program.command("doctor").description("Diagnose connectivity, config, and SDK version").action(async () => {
43
+ const { doctorCmd } = await import("./doctor-7Y7WBLQZ.js");
44
+ await doctorCmd();
45
+ });
46
+ program.parseAsync(process.argv).catch((e) => {
47
+ fail(e.message);
48
+ });
@@ -0,0 +1,78 @@
1
+ import {
2
+ bold,
3
+ emit,
4
+ error,
5
+ info,
6
+ success,
7
+ warn
8
+ } from "./chunk-AHQEKKK7.js";
9
+ import {
10
+ configFilePath,
11
+ resolveAuth
12
+ } from "./chunk-DZLDBWTB.js";
13
+
14
+ // src/commands/doctor.ts
15
+ import { existsSync } from "fs";
16
+ async function doctorCmd() {
17
+ info(bold("JECP CLI \u2014 Diagnostic Report"));
18
+ info("\u2500".repeat(50));
19
+ const auth = resolveAuth();
20
+ const baseUrl = auth.baseUrl ?? "https://jecp.dev";
21
+ const cfgPath = configFilePath();
22
+ const checks = [];
23
+ const start = Date.now();
24
+ let reachable = false;
25
+ try {
26
+ const res = await fetch(`${baseUrl}/health`);
27
+ const latency = Date.now() - start;
28
+ reachable = res.ok;
29
+ if (reachable) {
30
+ success(`${baseUrl} reachable (${latency}ms)`);
31
+ checks.push({ name: "reachable", ok: true, detail: `${latency}ms` });
32
+ } else {
33
+ error(`${baseUrl}/health returned ${res.status}`);
34
+ checks.push({ name: "reachable", ok: false, detail: `${res.status}` });
35
+ }
36
+ } catch (e) {
37
+ error(`Cannot reach ${baseUrl}: ${e.message}`);
38
+ checks.push({ name: "reachable", ok: false, detail: e.message });
39
+ }
40
+ if (existsSync(cfgPath)) {
41
+ success(`Config file exists at ${cfgPath}`);
42
+ checks.push({ name: "config_file", ok: true, detail: cfgPath });
43
+ } else {
44
+ warn(`Config file not yet created (will be on first login/register)`);
45
+ checks.push({ name: "config_file", ok: false });
46
+ }
47
+ if (auth.agentId && auth.apiKey) {
48
+ success(`Agent credentials configured (${auth.agentId})`);
49
+ checks.push({ name: "credentials", ok: true });
50
+ } else {
51
+ warn(`No credentials. Run \`jecp register\` or \`jecp login\`.`);
52
+ checks.push({ name: "credentials", ok: false });
53
+ }
54
+ try {
55
+ const { createRequire } = await import("module");
56
+ const req = createRequire(import.meta.url);
57
+ const pkgPath = req.resolve("@jecpdev/sdk/package.json");
58
+ const { readFileSync } = await import("fs");
59
+ const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
60
+ success(`SDK version: ${pkg.version}`);
61
+ checks.push({ name: "sdk_version", ok: true, detail: pkg.version });
62
+ } catch {
63
+ warn("Could not detect @jecpdev/sdk version");
64
+ checks.push({ name: "sdk_version", ok: false });
65
+ }
66
+ info("");
67
+ info("\u2500".repeat(50));
68
+ const allOk = checks.every((c) => c.ok);
69
+ if (allOk) {
70
+ success("All checks passed.");
71
+ } else {
72
+ warn("Some checks failed. See above.");
73
+ }
74
+ emit({ checks, all_ok: allOk });
75
+ }
76
+ export {
77
+ doctorCmd
78
+ };
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Persistent CLI config at ~/.jecp/config.json
3
+ */
4
+ interface CliConfig {
5
+ agent_id?: string;
6
+ api_key?: string;
7
+ base_url?: string;
8
+ default_namespace?: string;
9
+ }
10
+ declare function loadConfig(): CliConfig;
11
+ declare function saveConfig(cfg: CliConfig): void;
12
+ /** Resolve credentials with env-var priority over config file. */
13
+ declare function resolveAuth(): {
14
+ agentId?: string;
15
+ apiKey?: string;
16
+ baseUrl?: string;
17
+ };
18
+ declare function configFilePath(): string;
19
+
20
+ export { type CliConfig, configFilePath, loadConfig, resolveAuth, saveConfig };
package/dist/index.js ADDED
@@ -0,0 +1,12 @@
1
+ import {
2
+ configFilePath,
3
+ loadConfig,
4
+ resolveAuth,
5
+ saveConfig
6
+ } from "./chunk-DZLDBWTB.js";
7
+ export {
8
+ configFilePath,
9
+ loadConfig,
10
+ resolveAuth,
11
+ saveConfig
12
+ };
@@ -0,0 +1,92 @@
1
+ import {
2
+ getClient
3
+ } from "./chunk-FH4G7W5M.js";
4
+ import {
5
+ bold,
6
+ dim,
7
+ emit,
8
+ error,
9
+ fail,
10
+ info,
11
+ success,
12
+ warn
13
+ } from "./chunk-AHQEKKK7.js";
14
+ import "./chunk-DZLDBWTB.js";
15
+
16
+ // src/commands/invoke.ts
17
+ import { JecpError } from "@jecpdev/sdk";
18
+ async function invokeCmd(capability, action, opts) {
19
+ let input = {};
20
+ if (opts.input) {
21
+ try {
22
+ input = JSON.parse(opts.input);
23
+ } catch (e) {
24
+ fail(`--input must be valid JSON: ${e.message}`);
25
+ }
26
+ }
27
+ const jecp = getClient();
28
+ const invokeOpts = {};
29
+ if (opts.budget !== void 0) {
30
+ const b = parseFloat(opts.budget);
31
+ if (Number.isNaN(b) || b < 0) fail(`--budget must be a positive number, got "${opts.budget}"`);
32
+ invokeOpts.mandate = { budget_usdc: b };
33
+ }
34
+ if (opts.timeout !== void 0) {
35
+ invokeOpts.timeoutMs = parseInt(opts.timeout, 10);
36
+ }
37
+ if (opts.requestId !== void 0) {
38
+ invokeOpts.requestId = opts.requestId;
39
+ }
40
+ try {
41
+ const r = await jecp.invoke(capability, action, input, invokeOpts);
42
+ emit(
43
+ {
44
+ output: r.output,
45
+ billing: r.billing,
46
+ provider: r.provider,
47
+ wallet_balance_after: r.wallet_balance_after,
48
+ attempts: r.attempts,
49
+ request_id: r.request_id
50
+ },
51
+ () => {
52
+ success("Invocation complete.");
53
+ info("");
54
+ info(`${bold("Output:")} ${JSON.stringify(r.output)}`);
55
+ info(`${bold("Provider:")} ${r.provider.namespace}/${r.provider.capability}@${r.provider.version}`);
56
+ info(`${bold("Charged:")} ${r.billing.charged ? `$${r.billing.amount_usdc} USDC` : "no"}`);
57
+ if (r.wallet_balance_after !== void 0) {
58
+ info(`${bold("Balance:")} $${r.wallet_balance_after} USDC`);
59
+ }
60
+ if (r.billing.transaction_id) {
61
+ info(`${dim(`tx: ${r.billing.transaction_id}`)}`);
62
+ }
63
+ if (r.attempts > 0) {
64
+ warn(`Took ${r.attempts + 1} attempts (auto-retried)`);
65
+ }
66
+ }
67
+ );
68
+ } catch (e) {
69
+ if (e instanceof JecpError) {
70
+ error(`${e.code}: ${e.message}`);
71
+ if (e.nextAction) {
72
+ info("");
73
+ info(bold("Next action:"));
74
+ info(` type: ${e.nextAction.type}`);
75
+ if ("hint" in e.nextAction && e.nextAction.hint) {
76
+ info(` hint: ${e.nextAction.hint}`);
77
+ }
78
+ if ("api" in e.nextAction && e.nextAction.api) {
79
+ info(` api: ${e.nextAction.api}`);
80
+ }
81
+ if ("ui" in e.nextAction && e.nextAction.ui) {
82
+ info(` ui: ${e.nextAction.ui}`);
83
+ }
84
+ }
85
+ process.exit(1);
86
+ }
87
+ throw e;
88
+ }
89
+ }
90
+ export {
91
+ invokeCmd
92
+ };
@@ -0,0 +1,38 @@
1
+ import {
2
+ fail,
3
+ success
4
+ } from "./chunk-AHQEKKK7.js";
5
+ import {
6
+ configFilePath,
7
+ loadConfig,
8
+ saveConfig
9
+ } from "./chunk-DZLDBWTB.js";
10
+
11
+ // src/commands/login.ts
12
+ import prompts from "prompts";
13
+ async function loginCmd(opts) {
14
+ let { agentId, apiKey, baseUrl } = opts;
15
+ if (!agentId || !apiKey) {
16
+ const ans = await prompts([
17
+ { type: "text", name: "agentId", message: "Agent ID (jdb_ag_*)", initial: agentId },
18
+ { type: "password", name: "apiKey", message: "API key (jdb_ak_*)", initial: apiKey }
19
+ ]);
20
+ agentId = ans.agentId;
21
+ apiKey = ans.apiKey;
22
+ if (!agentId || !apiKey) fail("aborted");
23
+ }
24
+ const cfg = loadConfig();
25
+ cfg.agent_id = agentId;
26
+ cfg.api_key = apiKey;
27
+ if (baseUrl) cfg.base_url = baseUrl;
28
+ saveConfig(cfg);
29
+ success(`Saved to ${configFilePath()} (mode 0600)`);
30
+ }
31
+ async function logoutCmd() {
32
+ saveConfig({});
33
+ success(`Cleared credentials at ${configFilePath()}`);
34
+ }
35
+ export {
36
+ loginCmd,
37
+ logoutCmd
38
+ };
@@ -0,0 +1,62 @@
1
+ import {
2
+ bold,
3
+ emit,
4
+ fail,
5
+ info,
6
+ success
7
+ } from "./chunk-AHQEKKK7.js";
8
+ import {
9
+ loadConfig,
10
+ saveConfig
11
+ } from "./chunk-DZLDBWTB.js";
12
+
13
+ // src/commands/register.ts
14
+ import { JecpClient } from "@jecpdev/sdk";
15
+ import prompts from "prompts";
16
+ async function registerCmd(opts) {
17
+ let { name, type, description } = opts;
18
+ if (!name) {
19
+ const ans = await prompts([
20
+ { type: "text", name: "name", message: "Agent name (display label)", validate: (v) => v.length > 0 },
21
+ { type: "text", name: "type", message: "Agent type (e.g. research, coder, demo)", initial: "demo" },
22
+ { type: "text", name: "description", message: "Short description (optional)" }
23
+ ]);
24
+ if (!ans.name) fail("aborted");
25
+ name = ans.name;
26
+ type = ans.type;
27
+ description = ans.description;
28
+ }
29
+ info(`Registering agent ${bold(name)}...`);
30
+ const baseUrl = process.env.JECP_BASE_URL ?? "https://jecp.dev";
31
+ const reg = await JecpClient.register(
32
+ {
33
+ name,
34
+ ...type && { agent_type: type },
35
+ ...description && { description }
36
+ },
37
+ baseUrl
38
+ );
39
+ success(`Agent registered.`);
40
+ info("");
41
+ info(bold("Save these credentials \u2014 the api_key is shown only once:"));
42
+ info("");
43
+ info(` AGENT_ID: ${reg.agent_id}`);
44
+ info(` API_KEY: ${reg.api_key}`);
45
+ info(` Free calls: ${reg.free_calls_remaining}`);
46
+ info("");
47
+ const cfg = loadConfig();
48
+ cfg.agent_id = reg.agent_id;
49
+ cfg.api_key = reg.api_key;
50
+ if (baseUrl !== "https://jecp.dev") cfg.base_url = baseUrl;
51
+ saveConfig(cfg);
52
+ success(`Credentials saved to ~/.jecp/config.json (mode 0600)`);
53
+ emit({
54
+ agent_id: reg.agent_id,
55
+ api_key: reg.api_key,
56
+ name: reg.name,
57
+ free_calls_remaining: reg.free_calls_remaining
58
+ });
59
+ }
60
+ export {
61
+ registerCmd
62
+ };
@@ -0,0 +1,62 @@
1
+ import {
2
+ getBaseUrl,
3
+ getClient
4
+ } from "./chunk-FH4G7W5M.js";
5
+ import {
6
+ bold,
7
+ dim,
8
+ emit,
9
+ error,
10
+ info,
11
+ success
12
+ } from "./chunk-AHQEKKK7.js";
13
+ import {
14
+ resolveAuth
15
+ } from "./chunk-DZLDBWTB.js";
16
+
17
+ // src/commands/status.ts
18
+ async function statusCmd() {
19
+ const auth = resolveAuth();
20
+ const jecp = getClient();
21
+ const baseUrl = getBaseUrl();
22
+ const healthUrl = `${baseUrl}/health`;
23
+ let healthOk = false;
24
+ let healthLatency = 0;
25
+ try {
26
+ const start = Date.now();
27
+ const res = await fetch(healthUrl);
28
+ healthLatency = Date.now() - start;
29
+ healthOk = res.ok;
30
+ } catch {
31
+ healthOk = false;
32
+ }
33
+ let catalogCount;
34
+ try {
35
+ const cat = await jecp.catalog({ pageSize: 1 });
36
+ catalogCount = cat.third_party_count;
37
+ } catch {
38
+ }
39
+ const summary = {
40
+ base_url: baseUrl,
41
+ agent_id: auth.agentId,
42
+ health: { ok: healthOk, latency_ms: healthLatency },
43
+ third_party_capabilities: catalogCount
44
+ };
45
+ emit(summary, () => {
46
+ info(bold("JECP Status"));
47
+ info("\u2500".repeat(40));
48
+ info(`Hub URL: ${baseUrl}`);
49
+ info(`Agent ID: ${auth.agentId ?? dim("(not configured)")}`);
50
+ if (healthOk) {
51
+ success(`Health check: ok (${healthLatency}ms)`);
52
+ } else {
53
+ error(`Health check: FAILED (${healthUrl})`);
54
+ }
55
+ if (catalogCount !== void 0) {
56
+ success(`Catalog: ${catalogCount} third-party capabilities`);
57
+ }
58
+ });
59
+ }
60
+ export {
61
+ statusCmd
62
+ };
@@ -0,0 +1,29 @@
1
+ import {
2
+ getClient
3
+ } from "./chunk-FH4G7W5M.js";
4
+ import {
5
+ bold,
6
+ emit,
7
+ info,
8
+ success
9
+ } from "./chunk-AHQEKKK7.js";
10
+ import "./chunk-DZLDBWTB.js";
11
+
12
+ // src/commands/topup.ts
13
+ async function topupCmd(amount, opts) {
14
+ const n = parseInt(amount, 10);
15
+ if (![5, 20, 100].includes(n)) {
16
+ throw new Error("amount must be one of 5, 20, 100");
17
+ }
18
+ const jecp = getClient();
19
+ const r = await jecp.topup(n, { ...opts.returnTo && { returnTo: opts.returnTo } });
20
+ emit({ url: r.url, sessionId: r.sessionId }, () => {
21
+ success(`Top-up Stripe Checkout URL ready.`);
22
+ info("");
23
+ info(bold("Open this URL to pay:"));
24
+ info(` ${r.url}`);
25
+ });
26
+ }
27
+ export {
28
+ topupCmd
29
+ };
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "@jecpdev/cli",
3
+ "version": "0.1.0",
4
+ "description": "Command-line interface for JECP — register agents, invoke capabilities, manage Providers from your terminal.",
5
+ "type": "module",
6
+ "bin": {
7
+ "jecp": "./dist/cli.js"
8
+ },
9
+ "main": "./dist/index.js",
10
+ "types": "./dist/index.d.ts",
11
+ "files": ["dist", "README.md", "LICENSE"],
12
+ "engines": {
13
+ "node": ">=20"
14
+ },
15
+ "scripts": {
16
+ "build": "tsup src/cli.ts src/index.ts --format esm --dts --clean",
17
+ "test": "vitest run --passWithNoTests",
18
+ "lint": "tsc --noEmit",
19
+ "prepublishOnly": "npm run lint && npm run build"
20
+ },
21
+ "keywords": [
22
+ "jecp",
23
+ "cli",
24
+ "agent-commerce-protocol",
25
+ "ai-agent",
26
+ "developer-tool"
27
+ ],
28
+ "author": "Tufe Company Inc. <hello@jecp.dev>",
29
+ "license": "Apache-2.0",
30
+ "homepage": "https://jecp.dev",
31
+ "bugs": {
32
+ "url": "https://github.com/jecpdev/jecp-cli/issues"
33
+ },
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "https://github.com/jecpdev/jecp-cli.git"
37
+ },
38
+ "publishConfig": {
39
+ "access": "public"
40
+ },
41
+ "dependencies": {
42
+ "@jecpdev/sdk": "^0.2.0",
43
+ "commander": "^13.0.0",
44
+ "kleur": "^4.1.5",
45
+ "prompts": "^2.4.2"
46
+ },
47
+ "devDependencies": {
48
+ "@types/node": "^20.0.0",
49
+ "@types/prompts": "^2.4.9",
50
+ "tsup": "^8.0.0",
51
+ "typescript": "^5.4.0",
52
+ "vitest": "^1.6.0"
53
+ }
54
+ }