@thingd/cli 0.47.0 → 0.47.2

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.
@@ -1 +1 @@
1
- {"version":3,"file":"interactive.d.ts","sourceRoot":"","sources":["../src/interactive.ts"],"names":[],"mappings":"AAyyDA,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,CA4CvD"}
1
+ {"version":3,"file":"interactive.d.ts","sourceRoot":"","sources":["../src/interactive.ts"],"names":[],"mappings":"AAy1DA,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,CA4CvD"}
@@ -6,6 +6,7 @@ import * as path from "node:path";
6
6
  import readline from "node:readline";
7
7
  import { ThingD } from "@thingd/sdk";
8
8
  import pc from "picocolors";
9
+ import { listInstances, listProjects } from "./lib/cloud-api.js";
9
10
  import { readCloudConfig } from "./lib/cloud-config.js";
10
11
  import { logoText } from "./logo.js";
11
12
  // ── Helpers ──────────────────────────────────────────────────────────
@@ -1562,38 +1563,80 @@ async function handleConnect(node) {
1562
1563
  return;
1563
1564
  }
1564
1565
  const selectedDriver = node.ref.driver;
1565
- // Cloud with saved credentials — skip form
1566
+ // Cloud with saved credentials — fetch projects/instances and connect
1566
1567
  if (selectedDriver === "cloud") {
1567
1568
  const cloudCfg = readCloudConfig();
1568
1569
  if (cloudCfg?.token && cloudCfg?.url) {
1569
1570
  try {
1570
- await connectToDriver("cloud", cloudCfg.url, cloudCfg.url, cloudCfg.token);
1571
+ const { projects } = await listProjects(cloudCfg);
1572
+ for (const project of projects) {
1573
+ try {
1574
+ const { instances } = await listInstances(cloudCfg, project.id);
1575
+ if (instances.length > 0) {
1576
+ const instance = instances[0];
1577
+ if (instance?.mcpUrl) {
1578
+ await connectToDriver("cloud", instance.mcpUrl, instance.mcpUrl, cloudCfg.token);
1579
+ return;
1580
+ }
1581
+ }
1582
+ }
1583
+ catch {
1584
+ // Try next project
1585
+ }
1586
+ }
1587
+ viewerLines = [
1588
+ pc.yellow("No cloud instances found."),
1589
+ pc.dim("Create one at https://thingd.cloud, or enter the MCP URL manually."),
1590
+ ];
1591
+ draw();
1571
1592
  }
1572
- catch (err) {
1573
- const errMsg = err instanceof Error ? err.message : String(err);
1574
- viewerLines = [pc.red(`Failed to connect: ${errMsg}`)];
1593
+ catch {
1594
+ viewerLines = [
1595
+ pc.yellow("Could not fetch cloud instances."),
1596
+ pc.dim("Enter the MCP URL manually."),
1597
+ ];
1575
1598
  draw();
1576
1599
  }
1577
- return;
1578
1600
  }
1579
1601
  }
1580
1602
  if (selectedDriver === "native" || selectedDriver === "cloud") {
1581
1603
  const cloudCfg = selectedDriver === "cloud" ? readCloudConfig() : null;
1604
+ const baseUrl = cloudCfg?.url ?? "https://api.thingd.cloud";
1605
+ const isCloudWithConfig = selectedDriver === "cloud" && cloudCfg?.token;
1582
1606
  openForm(`Connect to ${selectedDriver}`, [
1583
1607
  ...(selectedDriver === "cloud"
1584
- ? [
1585
- {
1586
- id: "url",
1587
- label: "Cloud URL",
1588
- value: cloudCfg?.url ?? "http://localhost:3000",
1589
- },
1590
- {
1591
- id: "token",
1592
- label: "Bearer Token (optional)",
1593
- isSecret: true,
1594
- value: cloudCfg?.token ?? "",
1595
- },
1596
- ]
1608
+ ? isCloudWithConfig
1609
+ ? [
1610
+ {
1611
+ id: "project",
1612
+ label: "Cloud Project (slug)",
1613
+ value: "",
1614
+ },
1615
+ {
1616
+ id: "instance",
1617
+ label: "Cloud Instance (slug)",
1618
+ value: "",
1619
+ },
1620
+ {
1621
+ id: "token",
1622
+ label: "Bearer Token (optional)",
1623
+ isSecret: true,
1624
+ value: cloudCfg?.token ?? "",
1625
+ },
1626
+ ]
1627
+ : [
1628
+ {
1629
+ id: "url",
1630
+ label: "MCP URL (from thingd.cloud dashboard)",
1631
+ value: "",
1632
+ },
1633
+ {
1634
+ id: "token",
1635
+ label: "Bearer Token (optional)",
1636
+ isSecret: true,
1637
+ value: cloudCfg?.token ?? "",
1638
+ },
1639
+ ]
1597
1640
  : [
1598
1641
  {
1599
1642
  id: "path",
@@ -1602,8 +1645,20 @@ async function handleConnect(node) {
1602
1645
  },
1603
1646
  ]),
1604
1647
  ], async (vals) => {
1605
- const resolvedPath = selectedDriver === "cloud" ? vals.url || "" : vals.path || "";
1606
- await connectToDriver(selectedDriver, resolvedPath, selectedDriver === "cloud" ? resolvedPath : undefined, vals.token);
1648
+ let mcpUrl;
1649
+ if (selectedDriver === "cloud") {
1650
+ if (isCloudWithConfig) {
1651
+ // Construct URL from project + instance slugs
1652
+ mcpUrl = `${baseUrl}/mcp/${encodeURIComponent(vals.project || "")}/${encodeURIComponent(vals.instance || "")}`;
1653
+ }
1654
+ else {
1655
+ mcpUrl = vals.url || "";
1656
+ }
1657
+ await connectToDriver(selectedDriver, mcpUrl, mcpUrl, vals.token);
1658
+ }
1659
+ else {
1660
+ await connectToDriver(selectedDriver, vals.path || "", undefined, undefined);
1661
+ }
1607
1662
  });
1608
1663
  }
1609
1664
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thingd/cli",
3
- "version": "0.47.0",
3
+ "version": "0.47.2",
4
4
  "description": "CLI, Interactive TUI Dashboard, and MCP server for thingd — a fast object-first data engine for applications and AI agents.",
5
5
  "type": "module",
6
6
  "homepage": "https://engine.thingd.cloud",
@@ -45,7 +45,7 @@
45
45
  "cli-table3": "^0.6.5",
46
46
  "picocolors": "^1.1.1",
47
47
  "zod": "^4.4.3",
48
- "@thingd/sdk": "0.47.0"
48
+ "@thingd/sdk": "0.47.2"
49
49
  },
50
50
  "engines": {
51
51
  "node": ">=24.0.0"