@withone/cli 1.12.5 → 1.12.7
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/index.js +109 -28
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/index.ts
|
|
4
|
-
import { createRequire } from "module";
|
|
4
|
+
import { createRequire as createRequire2 } from "module";
|
|
5
5
|
import { Command } from "commander";
|
|
6
6
|
|
|
7
7
|
// src/commands/init.ts
|
|
@@ -348,8 +348,16 @@ var OneApi = class {
|
|
|
348
348
|
}
|
|
349
349
|
}
|
|
350
350
|
async listConnections() {
|
|
351
|
-
const
|
|
352
|
-
|
|
351
|
+
const allConnections = [];
|
|
352
|
+
let page = 1;
|
|
353
|
+
let totalPages = 1;
|
|
354
|
+
do {
|
|
355
|
+
const response = await this.request(`/vault/connections?page=${page}&limit=100`);
|
|
356
|
+
allConnections.push(...response.rows || []);
|
|
357
|
+
totalPages = response.pages || 1;
|
|
358
|
+
page++;
|
|
359
|
+
} while (page <= totalPages);
|
|
360
|
+
return allConnections;
|
|
353
361
|
}
|
|
354
362
|
async listPlatforms() {
|
|
355
363
|
const allPlatforms = [];
|
|
@@ -1318,16 +1326,16 @@ ${pc3.cyan(getApiKeyUrl())}`, "API Key");
|
|
|
1318
1326
|
}
|
|
1319
1327
|
function printBanner() {
|
|
1320
1328
|
console.log();
|
|
1321
|
-
console.log(pc3.
|
|
1322
|
-
console.log(pc3.
|
|
1323
|
-
console.log(pc3.
|
|
1324
|
-
console.log(pc3.
|
|
1325
|
-
console.log(pc3.
|
|
1326
|
-
console.log(pc3.
|
|
1327
|
-
console.log(pc3.
|
|
1328
|
-
console.log(pc3.
|
|
1329
|
-
console.log(pc3.
|
|
1330
|
-
console.log(pc3.
|
|
1329
|
+
console.log(pc3.yellow(" \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588"));
|
|
1330
|
+
console.log(pc3.yellow(" \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588"));
|
|
1331
|
+
console.log(pc3.yellow(" \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 "));
|
|
1332
|
+
console.log(pc3.yellow(" \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 "));
|
|
1333
|
+
console.log(pc3.yellow(" \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 "));
|
|
1334
|
+
console.log(pc3.yellow(" \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 "));
|
|
1335
|
+
console.log(pc3.yellow(" \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 "));
|
|
1336
|
+
console.log(pc3.yellow(" \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 "));
|
|
1337
|
+
console.log(pc3.yellow(" \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588"));
|
|
1338
|
+
console.log(pc3.yellow(" \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588"));
|
|
1331
1339
|
console.log();
|
|
1332
1340
|
console.log(pc3.dim(" U N I V E R S A L I N T E G R A T I O N S F O R A I"));
|
|
1333
1341
|
console.log();
|
|
@@ -1581,7 +1589,7 @@ Try again with: ${pc4.cyan(`one connection add ${platform}`)}`,
|
|
|
1581
1589
|
process.exit(1);
|
|
1582
1590
|
}
|
|
1583
1591
|
}
|
|
1584
|
-
async function connectionListCommand() {
|
|
1592
|
+
async function connectionListCommand(options) {
|
|
1585
1593
|
const apiKey = getApiKey();
|
|
1586
1594
|
if (!apiKey) {
|
|
1587
1595
|
error("Not configured. Run `one init` first.");
|
|
@@ -1590,29 +1598,48 @@ async function connectionListCommand() {
|
|
|
1590
1598
|
const spinner5 = createSpinner();
|
|
1591
1599
|
spinner5.start("Loading connections...");
|
|
1592
1600
|
try {
|
|
1593
|
-
const
|
|
1601
|
+
const allConnections = await api.listConnections();
|
|
1602
|
+
const searchQuery = options?.search?.toLowerCase();
|
|
1603
|
+
const filtered = searchQuery ? allConnections.filter((conn) => conn.platform.toLowerCase().includes(searchQuery)) : allConnections;
|
|
1594
1604
|
if (isAgentMode()) {
|
|
1605
|
+
const limit = options?.limit ? parseInt(options.limit, 10) : 20;
|
|
1606
|
+
const limited = filtered.slice(0, limit);
|
|
1595
1607
|
json({
|
|
1596
|
-
|
|
1608
|
+
total: filtered.length,
|
|
1609
|
+
showing: limited.length,
|
|
1610
|
+
...searchQuery && { search: searchQuery },
|
|
1611
|
+
connections: limited.map((conn) => ({
|
|
1597
1612
|
platform: conn.platform,
|
|
1598
1613
|
state: conn.state,
|
|
1599
1614
|
key: conn.key
|
|
1600
|
-
}))
|
|
1615
|
+
})),
|
|
1616
|
+
...limited.length < filtered.length && {
|
|
1617
|
+
hint: `Showing ${limited.length} of ${filtered.length} connections. Use --search <query> to filter by platform or --limit <n> to see more.`
|
|
1618
|
+
}
|
|
1601
1619
|
});
|
|
1602
1620
|
return;
|
|
1603
1621
|
}
|
|
1604
|
-
spinner5.stop(`${
|
|
1605
|
-
if (
|
|
1606
|
-
|
|
1607
|
-
|
|
1622
|
+
spinner5.stop(`${filtered.length} connection${filtered.length === 1 ? "" : "s"} found`);
|
|
1623
|
+
if (filtered.length === 0) {
|
|
1624
|
+
if (searchQuery) {
|
|
1625
|
+
p4.note(
|
|
1626
|
+
`No connections matching "${searchQuery}".
|
|
1627
|
+
|
|
1628
|
+
Try: ${pc4.cyan("one connection list")} to see all connections.`,
|
|
1629
|
+
"No Results"
|
|
1630
|
+
);
|
|
1631
|
+
} else {
|
|
1632
|
+
p4.note(
|
|
1633
|
+
`No connections yet.
|
|
1608
1634
|
|
|
1609
1635
|
Add one with: ${pc4.cyan("one connection add gmail")}`,
|
|
1610
|
-
|
|
1611
|
-
|
|
1636
|
+
"No Connections"
|
|
1637
|
+
);
|
|
1638
|
+
}
|
|
1612
1639
|
return;
|
|
1613
1640
|
}
|
|
1614
1641
|
console.log();
|
|
1615
|
-
const rows =
|
|
1642
|
+
const rows = filtered.map((conn) => ({
|
|
1616
1643
|
status: getStatusIndicator(conn.state),
|
|
1617
1644
|
platform: conn.platform,
|
|
1618
1645
|
state: conn.state,
|
|
@@ -4376,9 +4403,60 @@ validation rules, and platform-specific details.
|
|
|
4376
4403
|
---`;
|
|
4377
4404
|
}
|
|
4378
4405
|
|
|
4379
|
-
// src/
|
|
4406
|
+
// src/commands/update.ts
|
|
4407
|
+
import { createRequire } from "module";
|
|
4408
|
+
import { spawn as spawn2 } from "child_process";
|
|
4380
4409
|
var require2 = createRequire(import.meta.url);
|
|
4381
|
-
var { version } = require2("../package.json");
|
|
4410
|
+
var { version: currentVersion } = require2("../package.json");
|
|
4411
|
+
async function updateCommand() {
|
|
4412
|
+
const s = createSpinner();
|
|
4413
|
+
s.start("Checking for updates...");
|
|
4414
|
+
let latestVersion;
|
|
4415
|
+
try {
|
|
4416
|
+
const res = await fetch("https://registry.npmjs.org/@withone/cli/latest");
|
|
4417
|
+
if (!res.ok) {
|
|
4418
|
+
s.stop("");
|
|
4419
|
+
error(`Failed to check for updates (HTTP ${res.status})`);
|
|
4420
|
+
}
|
|
4421
|
+
const data = await res.json();
|
|
4422
|
+
latestVersion = data.version;
|
|
4423
|
+
} catch (err) {
|
|
4424
|
+
s.stop("");
|
|
4425
|
+
error("Failed to check for updates \u2014 could not reach npm registry");
|
|
4426
|
+
}
|
|
4427
|
+
if (currentVersion === latestVersion) {
|
|
4428
|
+
s.stop("Already up to date");
|
|
4429
|
+
if (isAgentMode()) {
|
|
4430
|
+
json({ current: currentVersion, latest: latestVersion, updated: false, message: "Already up to date" });
|
|
4431
|
+
} else {
|
|
4432
|
+
console.log(`Already up to date (v${currentVersion})`);
|
|
4433
|
+
}
|
|
4434
|
+
return;
|
|
4435
|
+
}
|
|
4436
|
+
s.stop(`Update available: v${currentVersion} \u2192 v${latestVersion}`);
|
|
4437
|
+
console.log(`Updating @withone/cli: v${currentVersion} \u2192 v${latestVersion}...`);
|
|
4438
|
+
const code = await new Promise((resolve) => {
|
|
4439
|
+
const child = spawn2("npm", ["install", "-g", "@withone/cli@latest"], {
|
|
4440
|
+
stdio: isAgentMode() ? "pipe" : "inherit",
|
|
4441
|
+
shell: true
|
|
4442
|
+
});
|
|
4443
|
+
child.on("close", resolve);
|
|
4444
|
+
child.on("error", () => resolve(1));
|
|
4445
|
+
});
|
|
4446
|
+
if (code === 0) {
|
|
4447
|
+
if (isAgentMode()) {
|
|
4448
|
+
json({ current: currentVersion, latest: latestVersion, updated: true, message: "Updated successfully" });
|
|
4449
|
+
} else {
|
|
4450
|
+
console.log(`Successfully updated to v${latestVersion}`);
|
|
4451
|
+
}
|
|
4452
|
+
} else {
|
|
4453
|
+
error("Update failed \u2014 try running: npm install -g @withone/cli@latest");
|
|
4454
|
+
}
|
|
4455
|
+
}
|
|
4456
|
+
|
|
4457
|
+
// src/index.ts
|
|
4458
|
+
var require3 = createRequire2(import.meta.url);
|
|
4459
|
+
var { version } = require3("../package.json");
|
|
4382
4460
|
var program = new Command();
|
|
4383
4461
|
program.name("one").option("--agent", "Machine-readable JSON output (no colors, spinners, or prompts)").description(`One CLI \u2014 Connect AI agents to 200+ platforms through one interface.
|
|
4384
4462
|
|
|
@@ -4433,8 +4511,8 @@ var connection = program.command("connection").description("Manage connections")
|
|
|
4433
4511
|
connection.command("add [platform]").alias("a").description("Add a new connection").action(async (platform) => {
|
|
4434
4512
|
await connectionAddCommand(platform);
|
|
4435
4513
|
});
|
|
4436
|
-
connection.command("list").alias("ls").description("List your connections").action(async () => {
|
|
4437
|
-
await connectionListCommand();
|
|
4514
|
+
connection.command("list").alias("ls").description("List your connections").option("-s, --search <query>", "Filter connections by platform name").option("-l, --limit <n>", "Max connections to return (agent mode default: 20)").action(async (options) => {
|
|
4515
|
+
await connectionListCommand(options);
|
|
4438
4516
|
});
|
|
4439
4517
|
program.command("platforms").alias("p").description("List available platforms").option("-c, --category <category>", "Filter by category").option("--json", "Output as JSON").action(async (options) => {
|
|
4440
4518
|
await platformsCommand(options);
|
|
@@ -4482,6 +4560,9 @@ program.command("guide [topic]").description("Full CLI usage guide for agents (t
|
|
|
4482
4560
|
program.command("onboard").description("Agent onboarding \u2014 teaches your agent what the One CLI can do").action(async () => {
|
|
4483
4561
|
await onboardCommand();
|
|
4484
4562
|
});
|
|
4563
|
+
program.command("update").description("Update the One CLI to the latest version").action(async () => {
|
|
4564
|
+
await updateCommand();
|
|
4565
|
+
});
|
|
4485
4566
|
program.command("add [platform]").description("Shortcut for: connection add").action(async (platform) => {
|
|
4486
4567
|
await connectionAddCommand(platform);
|
|
4487
4568
|
});
|