danube-cli 0.2.0 → 0.2.1
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/danube.mjs +76 -51
- package/package.json +1 -1
package/dist/danube.mjs
CHANGED
|
@@ -159,7 +159,7 @@ var package_default;
|
|
|
159
159
|
var init_package = __esm(() => {
|
|
160
160
|
package_default = {
|
|
161
161
|
name: "danube-cli",
|
|
162
|
-
version: "0.2.
|
|
162
|
+
version: "0.2.1",
|
|
163
163
|
description: "Danube CLI — agent-first tool infrastructure for AI agents",
|
|
164
164
|
type: "module",
|
|
165
165
|
license: "MIT",
|
|
@@ -521,12 +521,45 @@ var init_api = __esm(() => {
|
|
|
521
521
|
init_version();
|
|
522
522
|
});
|
|
523
523
|
|
|
524
|
+
// src/lib/compat.ts
|
|
525
|
+
import { execFile } from "node:child_process";
|
|
526
|
+
import { readFileSync, existsSync } from "node:fs";
|
|
527
|
+
function sleep(ms) {
|
|
528
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
529
|
+
}
|
|
530
|
+
function openUrl(url) {
|
|
531
|
+
try {
|
|
532
|
+
if (process.platform === "darwin") {
|
|
533
|
+
execFile("open", [url]);
|
|
534
|
+
} else if (process.platform === "linux") {
|
|
535
|
+
execFile("xdg-open", [url]);
|
|
536
|
+
} else {
|
|
537
|
+
execFile("cmd", ["/c", "start", url]);
|
|
538
|
+
}
|
|
539
|
+
} catch {}
|
|
540
|
+
}
|
|
541
|
+
function fileExists(filepath) {
|
|
542
|
+
return existsSync(filepath);
|
|
543
|
+
}
|
|
544
|
+
function readFile(filepath) {
|
|
545
|
+
return readFileSync(filepath, "utf-8");
|
|
546
|
+
}
|
|
547
|
+
async function readStdin() {
|
|
548
|
+
const chunks = [];
|
|
549
|
+
for await (const chunk of process.stdin) {
|
|
550
|
+
chunks.push(chunk);
|
|
551
|
+
}
|
|
552
|
+
return Buffer.concat(chunks).toString("utf-8");
|
|
553
|
+
}
|
|
554
|
+
var init_compat = () => {};
|
|
555
|
+
|
|
524
556
|
// src/commands/auth.ts
|
|
525
557
|
var exports_auth = {};
|
|
526
558
|
__export(exports_auth, {
|
|
527
559
|
register: () => register
|
|
528
560
|
});
|
|
529
561
|
import chalk2 from "chalk";
|
|
562
|
+
import { createInterface } from "node:readline";
|
|
530
563
|
function register(program) {
|
|
531
564
|
program.command("login").description("Log in to Danube via device code (opens browser)").action(handleErrors(async () => {
|
|
532
565
|
const baseUrl = getBaseUrl(ctx.profile);
|
|
@@ -549,28 +582,25 @@ function register(program) {
|
|
|
549
582
|
expires_in: data.expires_in
|
|
550
583
|
});
|
|
551
584
|
}
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
if (humanMode) {
|
|
566
|
-
console.log(chalk2.dim(` Open ${data.verification_url} in your browser`));
|
|
567
|
-
}
|
|
585
|
+
const url = `${data.verification_url}?code=${data.user_code}`;
|
|
586
|
+
if (humanMode) {
|
|
587
|
+
const rl = createInterface({ input: process.stdin, output: process.stderr });
|
|
588
|
+
await new Promise((resolve) => {
|
|
589
|
+
rl.question(chalk2.dim(" Press Enter to open browser..."), () => {
|
|
590
|
+
rl.close();
|
|
591
|
+
resolve();
|
|
592
|
+
});
|
|
593
|
+
});
|
|
594
|
+
openUrl(url);
|
|
595
|
+
console.log(chalk2.dim(" Waiting for authorization..."));
|
|
596
|
+
} else {
|
|
597
|
+
openUrl(url);
|
|
568
598
|
}
|
|
569
599
|
const start = Date.now();
|
|
570
600
|
const expiresMs = data.expires_in * 1000;
|
|
571
601
|
const intervalMs = data.interval * 1000;
|
|
572
602
|
while (Date.now() - start < expiresMs) {
|
|
573
|
-
await
|
|
603
|
+
await sleep(intervalMs);
|
|
574
604
|
try {
|
|
575
605
|
const tokenData = await client.publicPost("/v1/auth/device/token", { device_code: data.device_code });
|
|
576
606
|
saveApiKey(tokenData.api_key, ctx.profile);
|
|
@@ -639,10 +669,10 @@ ${chalk2.green("✓")} Authenticated successfully!`);
|
|
|
639
669
|
var init_auth = __esm(() => {
|
|
640
670
|
init_src();
|
|
641
671
|
init_api();
|
|
672
|
+
init_compat();
|
|
642
673
|
init_config();
|
|
643
674
|
init_errors();
|
|
644
675
|
init_output();
|
|
645
|
-
init_api();
|
|
646
676
|
});
|
|
647
677
|
|
|
648
678
|
// src/commands/search.ts
|
|
@@ -682,7 +712,7 @@ async function parseData(data) {
|
|
|
682
712
|
return {};
|
|
683
713
|
data = data.trim();
|
|
684
714
|
if (data === "-") {
|
|
685
|
-
const raw = await
|
|
715
|
+
const raw = await readStdin();
|
|
686
716
|
if (!raw.trim())
|
|
687
717
|
return {};
|
|
688
718
|
try {
|
|
@@ -694,13 +724,12 @@ async function parseData(data) {
|
|
|
694
724
|
}
|
|
695
725
|
if (data.startsWith("@")) {
|
|
696
726
|
const filepath = data.slice(1);
|
|
697
|
-
|
|
698
|
-
if (!await file.exists()) {
|
|
727
|
+
if (!fileExists(filepath)) {
|
|
699
728
|
outputError("file_not_found", `File not found: ${filepath}`);
|
|
700
729
|
process.exit(1);
|
|
701
730
|
}
|
|
702
731
|
try {
|
|
703
|
-
return JSON.parse(
|
|
732
|
+
return JSON.parse(readFile(filepath));
|
|
704
733
|
} catch (e) {
|
|
705
734
|
outputError("invalid_input", `Invalid JSON in ${filepath}: ${e instanceof Error ? e.message : String(e)}`);
|
|
706
735
|
process.exit(1);
|
|
@@ -714,6 +743,7 @@ async function parseData(data) {
|
|
|
714
743
|
}
|
|
715
744
|
}
|
|
716
745
|
var init_data_input = __esm(() => {
|
|
746
|
+
init_compat();
|
|
717
747
|
init_output();
|
|
718
748
|
});
|
|
719
749
|
|
|
@@ -806,9 +836,9 @@ __export(exports_connect, {
|
|
|
806
836
|
register: () => register4
|
|
807
837
|
});
|
|
808
838
|
import chalk3 from "chalk";
|
|
809
|
-
import { createInterface } from "node:readline";
|
|
839
|
+
import { createInterface as createInterface2 } from "node:readline";
|
|
810
840
|
async function promptSecret(prompt) {
|
|
811
|
-
const rl =
|
|
841
|
+
const rl = createInterface2({ input: process.stdin, output: process.stderr });
|
|
812
842
|
return new Promise((resolve) => {
|
|
813
843
|
process.stderr.write(prompt);
|
|
814
844
|
rl.question("", (answer) => {
|
|
@@ -846,7 +876,7 @@ Connecting to ${chalk3.bold(target.name)}...`);
|
|
|
846
876
|
if (humanMode) {
|
|
847
877
|
apiKeyValue = await promptSecret(" Enter API key: ");
|
|
848
878
|
} else {
|
|
849
|
-
apiKeyValue = (await
|
|
879
|
+
apiKeyValue = (await readStdin()).trim();
|
|
850
880
|
if (!apiKeyValue) {
|
|
851
881
|
outputError("invalid_input", "No credential provided on stdin");
|
|
852
882
|
process.exit(1);
|
|
@@ -866,6 +896,7 @@ Connecting to ${chalk3.bold(target.name)}...`);
|
|
|
866
896
|
var init_connect = __esm(() => {
|
|
867
897
|
init_src();
|
|
868
898
|
init_api();
|
|
899
|
+
init_compat();
|
|
869
900
|
init_errors();
|
|
870
901
|
init_output();
|
|
871
902
|
});
|
|
@@ -1075,14 +1106,13 @@ function register6(program) {
|
|
|
1075
1106
|
]);
|
|
1076
1107
|
}));
|
|
1077
1108
|
tools.command("batch <file>").description("Batch execute up to 10 tools from a JSON file").action(handleErrors(async (file) => {
|
|
1078
|
-
|
|
1079
|
-
if (!await f.exists()) {
|
|
1109
|
+
if (!fileExists(file)) {
|
|
1080
1110
|
outputError("file_not_found", `File not found: ${file}`);
|
|
1081
1111
|
process.exit(1);
|
|
1082
1112
|
}
|
|
1083
1113
|
let calls;
|
|
1084
1114
|
try {
|
|
1085
|
-
const parsed = JSON.parse(
|
|
1115
|
+
const parsed = JSON.parse(readFile(file));
|
|
1086
1116
|
if (!Array.isArray(parsed)) {
|
|
1087
1117
|
outputError("invalid_input", "Batch file must contain a JSON array");
|
|
1088
1118
|
process.exit(1);
|
|
@@ -1162,6 +1192,7 @@ function register6(program) {
|
|
|
1162
1192
|
var init_tools = __esm(() => {
|
|
1163
1193
|
init_src();
|
|
1164
1194
|
init_api();
|
|
1195
|
+
init_compat();
|
|
1165
1196
|
init_errors();
|
|
1166
1197
|
init_output();
|
|
1167
1198
|
init_resolve();
|
|
@@ -1250,14 +1281,13 @@ function register8(program) {
|
|
|
1250
1281
|
outputDetail(execution, `Execution ${execution.id}`);
|
|
1251
1282
|
}));
|
|
1252
1283
|
workflows.command("create <file>").description("Create a workflow from a JSON spec file").action(handleErrors(async (file) => {
|
|
1253
|
-
|
|
1254
|
-
if (!await f.exists()) {
|
|
1284
|
+
if (!fileExists(file)) {
|
|
1255
1285
|
outputError("file_not_found", `File not found: ${file}`);
|
|
1256
1286
|
process.exit(1);
|
|
1257
1287
|
}
|
|
1258
1288
|
let spec;
|
|
1259
1289
|
try {
|
|
1260
|
-
spec = JSON.parse(
|
|
1290
|
+
spec = JSON.parse(readFile(file));
|
|
1261
1291
|
} catch (e) {
|
|
1262
1292
|
outputError("invalid_input", `Invalid JSON: ${e instanceof Error ? e.message : String(e)}`);
|
|
1263
1293
|
process.exit(1);
|
|
@@ -1273,14 +1303,13 @@ function register8(program) {
|
|
|
1273
1303
|
outputDetail(workflow, `Created: ${workflow.name}`);
|
|
1274
1304
|
}));
|
|
1275
1305
|
workflows.command("update <workflowId> <file>").description("Update a workflow from a JSON spec file").action(handleErrors(async (workflowId, file) => {
|
|
1276
|
-
|
|
1277
|
-
if (!await f.exists()) {
|
|
1306
|
+
if (!fileExists(file)) {
|
|
1278
1307
|
outputError("file_not_found", `File not found: ${file}`);
|
|
1279
1308
|
process.exit(1);
|
|
1280
1309
|
}
|
|
1281
1310
|
let spec;
|
|
1282
1311
|
try {
|
|
1283
|
-
spec = JSON.parse(
|
|
1312
|
+
spec = JSON.parse(readFile(file));
|
|
1284
1313
|
} catch (e) {
|
|
1285
1314
|
outputError("invalid_input", `Invalid JSON: ${e instanceof Error ? e.message : String(e)}`);
|
|
1286
1315
|
process.exit(1);
|
|
@@ -1298,6 +1327,7 @@ function register8(program) {
|
|
|
1298
1327
|
var init_workflows = __esm(() => {
|
|
1299
1328
|
init_src();
|
|
1300
1329
|
init_api();
|
|
1330
|
+
init_compat();
|
|
1301
1331
|
init_data_input();
|
|
1302
1332
|
init_errors();
|
|
1303
1333
|
init_output();
|
|
@@ -1346,14 +1376,13 @@ ${chalk4.bold(skill.name)}`);
|
|
|
1346
1376
|
}
|
|
1347
1377
|
}));
|
|
1348
1378
|
skills.command("create <file>").description("Create a skill from a JSON spec file").option("--visibility <vis>", "Visibility: private or public", "private").action(handleErrors(async (file, opts) => {
|
|
1349
|
-
|
|
1350
|
-
if (!await f.exists()) {
|
|
1379
|
+
if (!fileExists(file)) {
|
|
1351
1380
|
outputError("file_not_found", `File not found: ${file}`);
|
|
1352
1381
|
process.exit(1);
|
|
1353
1382
|
}
|
|
1354
1383
|
let spec;
|
|
1355
1384
|
try {
|
|
1356
|
-
spec = JSON.parse(
|
|
1385
|
+
spec = JSON.parse(readFile(file));
|
|
1357
1386
|
} catch (e) {
|
|
1358
1387
|
outputError("invalid_input", `Invalid JSON: ${e instanceof Error ? e.message : String(e)}`);
|
|
1359
1388
|
process.exit(1);
|
|
@@ -1372,14 +1401,13 @@ ${chalk4.bold(skill.name)}`);
|
|
|
1372
1401
|
outputDetail(skill, `Created: ${skill.name}`);
|
|
1373
1402
|
}));
|
|
1374
1403
|
skills.command("update <skillId> <file>").description("Update a skill from a JSON spec file").action(handleErrors(async (skillId, file) => {
|
|
1375
|
-
|
|
1376
|
-
if (!await f.exists()) {
|
|
1404
|
+
if (!fileExists(file)) {
|
|
1377
1405
|
outputError("file_not_found", `File not found: ${file}`);
|
|
1378
1406
|
process.exit(1);
|
|
1379
1407
|
}
|
|
1380
1408
|
let spec;
|
|
1381
1409
|
try {
|
|
1382
|
-
spec = JSON.parse(
|
|
1410
|
+
spec = JSON.parse(readFile(file));
|
|
1383
1411
|
} catch (e) {
|
|
1384
1412
|
outputError("invalid_input", `Invalid JSON: ${e instanceof Error ? e.message : String(e)}`);
|
|
1385
1413
|
process.exit(1);
|
|
@@ -1397,6 +1425,7 @@ ${chalk4.bold(skill.name)}`);
|
|
|
1397
1425
|
var init_skills = __esm(() => {
|
|
1398
1426
|
init_src();
|
|
1399
1427
|
init_api();
|
|
1428
|
+
init_compat();
|
|
1400
1429
|
init_errors();
|
|
1401
1430
|
init_output();
|
|
1402
1431
|
});
|
|
@@ -1473,13 +1502,13 @@ var exports_credentials = {};
|
|
|
1473
1502
|
__export(exports_credentials, {
|
|
1474
1503
|
register: () => register11
|
|
1475
1504
|
});
|
|
1476
|
-
import { createInterface as
|
|
1505
|
+
import { createInterface as createInterface3 } from "node:readline";
|
|
1477
1506
|
function register11(program) {
|
|
1478
1507
|
const credentials = program.command("credentials").description("Store service credentials.");
|
|
1479
1508
|
credentials.command("store <serviceId>").description("Store a credential for a service").option("--type <type>", "Credential type: api_key, bearer, oauth", "api_key").action(handleErrors(async (serviceId, opts) => {
|
|
1480
1509
|
let credentialValue;
|
|
1481
1510
|
if (humanMode) {
|
|
1482
|
-
const rl =
|
|
1511
|
+
const rl = createInterface3({ input: process.stdin, output: process.stderr });
|
|
1483
1512
|
credentialValue = await new Promise((resolve) => {
|
|
1484
1513
|
process.stderr.write(" Enter credential value: ");
|
|
1485
1514
|
rl.question("", (answer) => {
|
|
@@ -1488,7 +1517,7 @@ function register11(program) {
|
|
|
1488
1517
|
});
|
|
1489
1518
|
});
|
|
1490
1519
|
} else {
|
|
1491
|
-
credentialValue = (await
|
|
1520
|
+
credentialValue = (await readStdin()).trim();
|
|
1492
1521
|
if (!credentialValue) {
|
|
1493
1522
|
outputError("invalid_input", "No credential provided on stdin");
|
|
1494
1523
|
process.exit(1);
|
|
@@ -1509,6 +1538,7 @@ function register11(program) {
|
|
|
1509
1538
|
var init_credentials = __esm(() => {
|
|
1510
1539
|
init_src();
|
|
1511
1540
|
init_api();
|
|
1541
|
+
init_compat();
|
|
1512
1542
|
init_errors();
|
|
1513
1543
|
init_output();
|
|
1514
1544
|
});
|
|
@@ -1653,13 +1683,7 @@ ${chalk6.green("✓")} Agent registered!`);
|
|
|
1653
1683
|
console.log(`
|
|
1654
1684
|
${chalk6.green("✓")} Checkout created`);
|
|
1655
1685
|
console.log(` ${chalk6.cyan("Open:")} ${result.checkout_url}`);
|
|
1656
|
-
|
|
1657
|
-
if (process.platform === "darwin") {
|
|
1658
|
-
Bun.spawn(["open", result.checkout_url]);
|
|
1659
|
-
} else if (process.platform === "linux") {
|
|
1660
|
-
Bun.spawn(["xdg-open", result.checkout_url]);
|
|
1661
|
-
}
|
|
1662
|
-
} catch {}
|
|
1686
|
+
openUrl(result.checkout_url);
|
|
1663
1687
|
console.log();
|
|
1664
1688
|
} else if (humanMode && result.deposit_address) {
|
|
1665
1689
|
console.log(`
|
|
@@ -1676,6 +1700,7 @@ ${chalk6.green("✓")} Send USDC to:`);
|
|
|
1676
1700
|
var init_agent = __esm(() => {
|
|
1677
1701
|
init_src();
|
|
1678
1702
|
init_api();
|
|
1703
|
+
init_compat();
|
|
1679
1704
|
init_config();
|
|
1680
1705
|
init_errors();
|
|
1681
1706
|
init_output();
|