@indexnetwork/cli 0.9.4 → 0.9.5-rc.10.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.
Files changed (2) hide show
  1. package/dist/index.js +25 -9
  2. package/package.json +5 -5
package/dist/index.js CHANGED
@@ -477,11 +477,12 @@ async function handleLogin(apiUrl, appUrl, store, options = {}) {
477
477
  const timeoutMs = options.timeoutMs ?? 120000;
478
478
  const baseUrl = apiUrl.replace(/\/$/, "");
479
479
  const baseAppUrl = appUrl.replace(/\/$/, "");
480
+ const callbackHost = options.callbackHost ?? "127.0.0.1";
480
481
  let resolveCallback;
481
482
  const callbackPromise = new Promise((resolve) => {
482
483
  resolveCallback = resolve;
483
484
  });
484
- const server = createServer(async (req, res) => {
485
+ const server = (options.serverFactory ?? createServer)(async (req, res) => {
485
486
  const url = new URL(req.url ?? "/", `http://localhost`);
486
487
  if (url.pathname === "/callback") {
487
488
  const sessionToken = url.searchParams.get("session_token");
@@ -504,11 +505,11 @@ async function handleLogin(apiUrl, appUrl, store, options = {}) {
504
505
  res.end("Not Found");
505
506
  });
506
507
  await new Promise((resolve) => {
507
- server.listen(0, () => resolve());
508
+ server.listen(0, callbackHost, () => resolve());
508
509
  });
509
510
  const addr = server.address();
510
511
  const port = typeof addr === "object" && addr ? addr.port : 0;
511
- const callbackUrl = `http://localhost:${port}/callback`;
512
+ const callbackUrl = `http://${callbackHost}:${port}/callback`;
512
513
  const authUrl = `${baseAppUrl}/cli-auth?callback=${encodeURIComponent(callbackUrl)}`;
513
514
  const timeout = setTimeout(() => {
514
515
  resolveCallback({
@@ -688,7 +689,8 @@ function wordWrap(text, maxWidth) {
688
689
  return lines;
689
690
  }
690
691
  function confidenceBar(confidence) {
691
- const pct = Math.round(confidence);
692
+ const normalized = confidence <= 1 ? confidence * 100 : confidence;
693
+ const pct = Math.round(normalized);
692
694
  const filled = Math.round(pct / 10);
693
695
  const empty = 10 - filled;
694
696
  return `${GREEN}${"#".repeat(filled)}${GRAY}${"-".repeat(empty)}${RESET} ${GRAY}${pct}%`;
@@ -1803,7 +1805,8 @@ async function opportunityStatusUpdate(client, id, status2, json) {
1803
1805
  success(`Opportunity ${status2 === "accepted" ? "accepted" : "rejected"}.`);
1804
1806
  }
1805
1807
  async function discoverIntroduction(client, userA, userB, hint, json) {
1806
- info("Gathering data for introduction...");
1808
+ if (!json)
1809
+ info("Gathering data for introduction...");
1807
1810
  const [membershipsA, membershipsB] = await Promise.all([
1808
1811
  client.callTool("read_index_memberships", { userId: userA }),
1809
1812
  client.callTool("read_index_memberships", { userId: userB })
@@ -1831,13 +1834,24 @@ async function discoverIntroduction(client, userA, userB, hint, json) {
1831
1834
  return;
1832
1835
  }
1833
1836
  const sharedNetworkId = shared[0].networkId;
1834
- dim(` Found shared network: ${sharedNetworkId}`);
1837
+ if (!json)
1838
+ dim(` Found shared network: ${sharedNetworkId}`);
1835
1839
  const [profileA, profileB, intentsA, intentsB] = await Promise.all([
1836
1840
  client.callTool("read_user_profiles", { userId: userA }),
1837
1841
  client.callTool("read_user_profiles", { userId: userB }),
1838
1842
  client.callTool("read_intents", { userId: userA, networkId: sharedNetworkId }),
1839
1843
  client.callTool("read_intents", { userId: userB, networkId: sharedNetworkId })
1840
1844
  ]);
1845
+ const gatherError = profileA.error ?? profileB.error ?? intentsA.error ?? intentsB.error;
1846
+ if (!profileA.success || !profileB.success || !intentsA.success || !intentsB.success) {
1847
+ const err = gatherError ?? "Failed to gather profiles and intents for introduction.";
1848
+ if (json) {
1849
+ console.log(JSON.stringify({ success: false, error: err }));
1850
+ return;
1851
+ }
1852
+ error(err, 1);
1853
+ return;
1854
+ }
1841
1855
  const extractProfile = (result2) => {
1842
1856
  if (!result2.success || !result2.data)
1843
1857
  return;
@@ -1857,7 +1871,8 @@ async function discoverIntroduction(client, userA, userB, hint, json) {
1857
1871
  { userId: userA, profile: extractProfile(profileA), intents: extractIntents(intentsA), networkId: sharedNetworkId },
1858
1872
  { userId: userB, profile: extractProfile(profileB), intents: extractIntents(intentsB), networkId: sharedNetworkId }
1859
1873
  ];
1860
- dim(" Profiles and intents gathered. Creating introduction...");
1874
+ if (!json)
1875
+ dim(" Profiles and intents gathered. Creating introduction...");
1861
1876
  const result = await client.callTool("create_opportunities", {
1862
1877
  partyUserIds: [userA, userB],
1863
1878
  entities,
@@ -2569,7 +2584,8 @@ async function handleScrape(client, positionals, options) {
2569
2584
  error("Usage: index scrape <url> [--objective <text>]", 1);
2570
2585
  return;
2571
2586
  }
2572
- info(`Scraping ${url}...`);
2587
+ if (!options.json)
2588
+ info(`Scraping ${url}...`);
2573
2589
  const result = await client.callTool("scrape_url", { url, objective: options.objective });
2574
2590
  if (options.json) {
2575
2591
  console.log(JSON.stringify(result));
@@ -2648,7 +2664,7 @@ async function onboardingComplete(client, json) {
2648
2664
  // src/main.ts
2649
2665
  var DEFAULT_API_URL = "https://protocol.index.network";
2650
2666
  var DEFAULT_APP_URL = "https://index.network";
2651
- var VERSION = "0.9.2";
2667
+ var VERSION = "0.9.5";
2652
2668
  var HELP_TEXT = `
2653
2669
  Index CLI v${VERSION}
2654
2670
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@indexnetwork/cli",
3
- "version": "0.9.4",
3
+ "version": "0.9.5-rc.10.1",
4
4
  "description": "Command-line interface for Index Network",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -20,10 +20,10 @@
20
20
  "publish:all": "bun scripts/publish.ts"
21
21
  },
22
22
  "optionalDependencies": {
23
- "@indexnetwork/cli-linux-x64": "0.9.4",
24
- "@indexnetwork/cli-linux-arm64": "0.9.4",
25
- "@indexnetwork/cli-darwin-x64": "0.9.4",
26
- "@indexnetwork/cli-darwin-arm64": "0.9.4"
23
+ "@indexnetwork/cli-linux-x64": "0.9.5-rc.10.1",
24
+ "@indexnetwork/cli-linux-arm64": "0.9.5-rc.10.1",
25
+ "@indexnetwork/cli-darwin-x64": "0.9.5-rc.10.1",
26
+ "@indexnetwork/cli-darwin-arm64": "0.9.5-rc.10.1"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@types/bun": "latest"