@jecpdev/cli 0.2.0 → 0.3.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/dist/cli.js
CHANGED
|
@@ -23,8 +23,8 @@ program.command("logout").description("Clear stored credentials").action(async (
|
|
|
23
23
|
const { logoutCmd } = await import("./login-2C7JY62W.js");
|
|
24
24
|
await logoutCmd();
|
|
25
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-
|
|
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)").option("--stream", "Stream the response as Server-Sent Events. Capability action must declare streaming: true.").action(async (capability, action, opts) => {
|
|
27
|
+
const { invokeCmd } = await import("./invoke-NILLA4U4.js");
|
|
28
28
|
await invokeCmd(capability, action, opts);
|
|
29
29
|
});
|
|
30
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) => {
|
|
@@ -37,6 +37,10 @@ async function invokeCmd(capability, action, opts) {
|
|
|
37
37
|
if (opts.requestId !== void 0) {
|
|
38
38
|
invokeOpts.requestId = opts.requestId;
|
|
39
39
|
}
|
|
40
|
+
if (opts.stream) {
|
|
41
|
+
await runStream(jecp, capability, action, input, invokeOpts);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
40
44
|
try {
|
|
41
45
|
const r = await jecp.invoke(capability, action, input, invokeOpts);
|
|
42
46
|
emit(
|
|
@@ -87,6 +91,60 @@ async function invokeCmd(capability, action, opts) {
|
|
|
87
91
|
throw e;
|
|
88
92
|
}
|
|
89
93
|
}
|
|
94
|
+
async function runStream(jecp, capability, action, input, invokeOpts) {
|
|
95
|
+
const stream = jecp.invokeStream(capability, action, input, invokeOpts);
|
|
96
|
+
let exitCode = 0;
|
|
97
|
+
try {
|
|
98
|
+
for await (const event of stream) {
|
|
99
|
+
switch (event.type) {
|
|
100
|
+
case "chunk":
|
|
101
|
+
process.stdout.write(event.delta);
|
|
102
|
+
break;
|
|
103
|
+
case "meter":
|
|
104
|
+
if (event.tokens !== void 0) {
|
|
105
|
+
process.stderr.write(dim(`
|
|
106
|
+
[meter] tokens=${event.tokens}
|
|
107
|
+
`));
|
|
108
|
+
}
|
|
109
|
+
break;
|
|
110
|
+
case "completed":
|
|
111
|
+
process.stdout.write("\n");
|
|
112
|
+
success("Stream completed.");
|
|
113
|
+
info(`${bold("Billing:")} ${event.billing && event.billing.charged ? `$${event.billing.amount_usdc} USDC (tx ${event.billing.transaction_id ?? "\u2014"})` : "not charged"}`);
|
|
114
|
+
break;
|
|
115
|
+
case "error": {
|
|
116
|
+
process.stdout.write("\n");
|
|
117
|
+
error(`${event.error.code}: ${event.error.message}`);
|
|
118
|
+
exitCode = 1;
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
case "cancelled":
|
|
122
|
+
process.stdout.write("\n");
|
|
123
|
+
warn(`Cancelled${event.reason ? `: ${event.reason}` : ""}`);
|
|
124
|
+
if (event.billing && event.billing.charged) {
|
|
125
|
+
info(`Partial bill: $${event.billing.amount_usdc} USDC`);
|
|
126
|
+
}
|
|
127
|
+
exitCode = 1;
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
} catch (e) {
|
|
132
|
+
if (e instanceof JecpError) {
|
|
133
|
+
error(`${e.code}: ${e.message}`);
|
|
134
|
+
if (e.nextAction) {
|
|
135
|
+
info("");
|
|
136
|
+
info(bold("Next action:"));
|
|
137
|
+
info(` type: ${e.nextAction.type}`);
|
|
138
|
+
if ("hint" in e.nextAction && e.nextAction.hint) {
|
|
139
|
+
info(` hint: ${e.nextAction.hint}`);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
process.exit(1);
|
|
143
|
+
}
|
|
144
|
+
throw e;
|
|
145
|
+
}
|
|
146
|
+
if (exitCode !== 0) process.exit(exitCode);
|
|
147
|
+
}
|
|
90
148
|
export {
|
|
91
149
|
invokeCmd
|
|
92
150
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jecpdev/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Command-line interface for JECP — register agents, invoke capabilities, manage Providers from your terminal.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"access": "public"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@jecpdev/sdk": "^0.
|
|
46
|
+
"@jecpdev/sdk": "^0.4.0",
|
|
47
47
|
"commander": "^13.0.0",
|
|
48
48
|
"kleur": "^4.1.5",
|
|
49
49
|
"prompts": "^2.4.2"
|