@indexnetwork/cli 0.14.0-rc.63.1 → 0.15.0-rc.64.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 +11 -315
  2. package/package.json +5 -5
package/dist/index.js CHANGED
@@ -19,7 +19,7 @@ import { spawn } from "node:child_process";
19
19
  // package.json
20
20
  var package_default = {
21
21
  name: "@indexnetwork/cli",
22
- version: "0.14.0",
22
+ version: "0.15.0",
23
23
  description: "Command-line interface for Index Network",
24
24
  license: "MIT",
25
25
  type: "module",
@@ -39,10 +39,10 @@ var package_default = {
39
39
  "publish:all": "bun scripts/publish.ts"
40
40
  },
41
41
  optionalDependencies: {
42
- "@indexnetwork/cli-linux-x64": "0.14.0",
43
- "@indexnetwork/cli-linux-arm64": "0.14.0",
44
- "@indexnetwork/cli-darwin-x64": "0.14.0",
45
- "@indexnetwork/cli-darwin-arm64": "0.14.0"
42
+ "@indexnetwork/cli-linux-x64": "0.15.0",
43
+ "@indexnetwork/cli-linux-arm64": "0.15.0",
44
+ "@indexnetwork/cli-darwin-x64": "0.15.0",
45
+ "@indexnetwork/cli-darwin-arm64": "0.15.0"
46
46
  },
47
47
  devDependencies: {
48
48
  "@types/bun": "1.3.14"
@@ -54,7 +54,7 @@ var KNOWN_COMMANDS = new Set(["login", "logout", "profile", "intent", "opportuni
54
54
  var OPPORTUNITY_SUBCOMMANDS = new Set(["list", "show", "accept", "reject"]);
55
55
  var NEGOTIATION_SUBCOMMANDS = new Set(["list", "show"]);
56
56
  var NETWORK_SUBCOMMANDS = new Set(["list", "create", "show", "join", "leave", "invite", "update", "delete"]);
57
- var CONVERSATION_SUBCOMMANDS = new Set(["list", "with", "show", "send", "stream", "sessions", "help"]);
57
+ var CONVERSATION_SUBCOMMANDS = new Set(["list", "with", "show", "send", "stream", "help"]);
58
58
  function parseArgs(args) {
59
59
  const result = {
60
60
  command: "help",
@@ -101,7 +101,6 @@ function parseArgs(args) {
101
101
  result.list = true;
102
102
  i++;
103
103
  } else if (arg === "--session" || arg === "-s") {
104
- result.sessionId = args[i + 1];
105
104
  i += 2;
106
105
  } else if (arg === "--api-url") {
107
106
  result.apiUrl = args[i + 1];
@@ -236,8 +235,6 @@ function parseArgs(args) {
236
235
  if (positionals.length > 0 && CONVERSATION_SUBCOMMANDS.has(positionals[0])) {
237
236
  result.subcommand = positionals[0];
238
237
  result.positionals = positionals.slice(1);
239
- } else if (positionals.length > 0) {
240
- result.message = positionals.join(" ");
241
238
  }
242
239
  }
243
240
  return result;
@@ -345,11 +342,6 @@ class ApiClient {
345
342
  authHeaders() {
346
343
  return { "x-api-key": this.token };
347
344
  }
348
- async listSessions() {
349
- const res = await this.get("/api/chat/sessions");
350
- const body = await res.json();
351
- return body.sessions;
352
- }
353
345
  async revokeApiKey(keyId, targetKey = this.token) {
354
346
  const res = await this.post("/api/auth/cli-credential/revoke", { keyId, targetKey });
355
347
  const body = await res.json();
@@ -390,23 +382,6 @@ class ApiClient {
390
382
  });
391
383
  return await res.json();
392
384
  }
393
- async streamChat(params) {
394
- const res = await fetch(`${this.baseUrl}/api/chat/stream`, {
395
- method: "POST",
396
- headers: {
397
- "Content-Type": "application/json",
398
- ...this.authHeaders()
399
- },
400
- body: JSON.stringify({
401
- message: params.message,
402
- ...params.sessionId ? { sessionId: params.sessionId } : {}
403
- })
404
- });
405
- if (!res.ok) {
406
- await this.handleError(res);
407
- }
408
- return res;
409
- }
410
385
  async listIntents(options = {}) {
411
386
  const body = {};
412
387
  if (options.limit !== undefined)
@@ -879,7 +854,6 @@ __export(exports_output, {
879
854
  success: () => success,
880
855
  stripAnsi: () => stripAnsi,
881
856
  status: () => status,
882
- sessionTable: () => sessionTable,
883
857
  raw: () => raw,
884
858
  profileCard: () => profileCard,
885
859
  padTo: () => padTo,
@@ -1313,28 +1287,6 @@ function contactTable(contacts) {
1313
1287
  console.log(` ${c.name.padEnd(nameWidth)} ${c.email}${ghost}`);
1314
1288
  }
1315
1289
  }
1316
- function sessionTable(sessions) {
1317
- if (sessions.length === 0) {
1318
- dim(" No chat sessions found.");
1319
- return;
1320
- }
1321
- const idWidth = 36;
1322
- const titleWidth = 40;
1323
- const dateWidth = 20;
1324
- console.log(` ${BOLD}${"ID".padEnd(idWidth)} ${"Title".padEnd(titleWidth)} ${"Created".padEnd(dateWidth)}${RESET}`);
1325
- console.log(` ${GRAY}${"-".repeat(idWidth)} ${"-".repeat(titleWidth)} ${"-".repeat(dateWidth)}${RESET}`);
1326
- for (const s of sessions) {
1327
- const title = (s.title ?? "(untitled)").slice(0, titleWidth);
1328
- const date = new Date(s.createdAt).toLocaleDateString("en-US", {
1329
- year: "numeric",
1330
- month: "short",
1331
- day: "numeric",
1332
- hour: "2-digit",
1333
- minute: "2-digit"
1334
- });
1335
- console.log(` ${GRAY}${s.id.padEnd(idWidth)}${RESET} ${title.padEnd(titleWidth)} ${GRAY}${date}${RESET}`);
1336
- }
1337
- }
1338
1290
  function intentTable(intents) {
1339
1291
  if (intents.length === 0) {
1340
1292
  dim(" No signals found.");
@@ -2440,122 +2392,9 @@ async function networkInvite(client, id, email, json) {
2440
2392
  }
2441
2393
 
2442
2394
  // src/conversation.command.ts
2443
- import { createInterface } from "node:readline/promises";
2444
- async function renderSSEStream(response, callbacks) {
2445
- const { onToken, onStatus, onToolActivity, onResponseReset } = callbacks;
2446
- const result = {};
2447
- if (!response.body) {
2448
- result.error = "No response body";
2449
- return result;
2450
- }
2451
- const reader = response.body.getReader();
2452
- const decoder = new TextDecoder;
2453
- let buffer = "";
2454
- let insideToolCall = false;
2455
- const toolDescriptions = new Map;
2456
- try {
2457
- while (true) {
2458
- const { done, value } = await reader.read();
2459
- if (done)
2460
- break;
2461
- buffer += decoder.decode(value, { stream: true });
2462
- while (buffer.includes(`
2463
-
2464
- `)) {
2465
- const idx = buffer.indexOf(`
2466
-
2467
- `);
2468
- const raw2 = buffer.slice(0, idx);
2469
- buffer = buffer.slice(idx + 2);
2470
- for (const line of raw2.split(`
2471
- `)) {
2472
- if (!line.startsWith("data:"))
2473
- continue;
2474
- const jsonStr = line.slice("data:".length).trim();
2475
- if (!jsonStr)
2476
- continue;
2477
- try {
2478
- const event = JSON.parse(jsonStr);
2479
- const type = event.type;
2480
- switch (type) {
2481
- case "token": {
2482
- if (typeof event.content !== "string")
2483
- break;
2484
- if (insideToolCall)
2485
- break;
2486
- onToken(event.content);
2487
- break;
2488
- }
2489
- case "status":
2490
- if (onStatus && typeof event.message === "string") {
2491
- onStatus(event.message);
2492
- }
2493
- break;
2494
- case "tool_activity": {
2495
- const phase = event.phase;
2496
- const toolName = typeof event.toolName === "string" ? event.toolName : "";
2497
- const desc = typeof event.description === "string" ? event.description : undefined;
2498
- if (phase === "start") {
2499
- insideToolCall = true;
2500
- if (desc && toolName) {
2501
- toolDescriptions.set(toolName, desc);
2502
- }
2503
- if (onToolActivity && desc) {
2504
- onToolActivity(desc, "start");
2505
- }
2506
- } else if (phase === "end") {
2507
- insideToolCall = false;
2508
- const startDesc = toolName ? toolDescriptions.get(toolName) : undefined;
2509
- if (onToolActivity) {
2510
- onToolActivity(startDesc ?? desc ?? toolName, "end", event.success !== false);
2511
- }
2512
- if (toolName)
2513
- toolDescriptions.delete(toolName);
2514
- }
2515
- break;
2516
- }
2517
- case "tool_start":
2518
- insideToolCall = true;
2519
- break;
2520
- case "tool_end":
2521
- insideToolCall = false;
2522
- break;
2523
- case "llm_start":
2524
- insideToolCall = false;
2525
- break;
2526
- case "response_reset":
2527
- result.response = undefined;
2528
- if (onResponseReset) {
2529
- onResponseReset(typeof event.reason === "string" ? event.reason : undefined);
2530
- }
2531
- break;
2532
- case "done":
2533
- result.sessionId = typeof event.sessionId === "string" ? event.sessionId : undefined;
2534
- result.response = typeof event.response === "string" ? event.response : undefined;
2535
- result.title = typeof event.title === "string" ? event.title : undefined;
2536
- break;
2537
- case "error":
2538
- result.error = typeof event.message === "string" ? event.message : "Unknown stream error";
2539
- break;
2540
- default:
2541
- break;
2542
- }
2543
- } catch {}
2544
- }
2545
- }
2546
- }
2547
- } finally {
2548
- reader.releaseLock();
2549
- }
2550
- return result;
2551
- }
2552
2395
  var CONVERSATION_HELP = `
2553
2396
  Conversation Commands:
2554
- index conversation Start an interactive AI chat (REPL)
2555
- index conversation "message" One-shot message to the AI agent
2556
- index conversation --session <id> Resume a specific chat session
2557
- index conversation sessions List AI chat sessions
2558
- index conversation list List all conversations (H2A + H2H)
2397
+ index conversation list List all conversations
2559
2398
  index conversation with <user-id|key> Open or resume a DM with a user
2560
2399
  index conversation show <id> Show messages (accepts short ID)
2561
2400
  index conversation show <id> --limit <n> Limit number of messages
@@ -2564,21 +2403,10 @@ Conversation Commands:
2564
2403
  `;
2565
2404
  async function handleConversation(client, subcommand, positionals, options) {
2566
2405
  if (!subcommand) {
2567
- if (options?.json) {
2568
- error("`--json` requires an explicit conversation subcommand.", 1);
2569
- return;
2570
- }
2571
- if (options?.message) {
2572
- await chatOneShot(client, options.message, options.sessionId);
2573
- } else {
2574
- await chatRepl(client, options?.sessionId);
2575
- }
2406
+ error("Agent chat is no longer available from the CLI. Use `index conversation list` " + "for your conversations, or chat in the Index app.", 1);
2576
2407
  return;
2577
2408
  }
2578
2409
  switch (subcommand) {
2579
- case "sessions":
2580
- await chatSessionsList(client, options?.json);
2581
- return;
2582
2410
  case "list":
2583
2411
  await conversationList(client, options?.json);
2584
2412
  return;
@@ -2704,132 +2532,6 @@ async function conversationStream(client) {
2704
2532
  reader.releaseLock();
2705
2533
  }
2706
2534
  }
2707
- async function chatSessionsList(client, json) {
2708
- const sessions = await client.listSessions();
2709
- if (json) {
2710
- console.log(JSON.stringify(sessions));
2711
- return;
2712
- }
2713
- heading("Chat Sessions");
2714
- sessionTable(sessions);
2715
- console.log();
2716
- }
2717
- async function chatOneShot(client, message, sessionId) {
2718
- const response = await client.streamChat({ message, sessionId });
2719
- if (!response.ok) {
2720
- handleStreamError(response);
2721
- return;
2722
- }
2723
- const result = await streamToTerminal(response);
2724
- if (result.error) {
2725
- error(result.error, 1);
2726
- return;
2727
- }
2728
- if (result.sessionId) {
2729
- dim(`
2730
- Session: ${result.sessionId}`);
2731
- }
2732
- }
2733
- async function chatRepl(client, sessionId) {
2734
- let currentSessionId = sessionId;
2735
- chatHeader();
2736
- const PROMPT_STR2 = PROMPT_STR;
2737
- const rl = createInterface({
2738
- input: process.stdin,
2739
- output: process.stderr,
2740
- terminal: true
2741
- });
2742
- rl.setPrompt(PROMPT_STR2);
2743
- rl.prompt();
2744
- try {
2745
- for await (const line of rl) {
2746
- const input = line.trim();
2747
- if (!input) {
2748
- rl.prompt();
2749
- continue;
2750
- }
2751
- if (input === "exit" || input === "quit")
2752
- break;
2753
- const response = await client.streamChat({
2754
- message: input,
2755
- sessionId: currentSessionId
2756
- });
2757
- if (!response.ok) {
2758
- if (response.status === 401) {
2759
- error("Session expired. Run `index login` to re-authenticate.", 1);
2760
- return;
2761
- }
2762
- const body = await response.json().catch(() => ({}));
2763
- error(body.error ?? `HTTP ${response.status}`);
2764
- rl.prompt();
2765
- continue;
2766
- }
2767
- const result = await streamToTerminal(response);
2768
- if (result.error) {
2769
- error(result.error);
2770
- }
2771
- if (result.sessionId) {
2772
- currentSessionId = result.sessionId;
2773
- }
2774
- process.stderr.write(`
2775
- `);
2776
- rl.prompt();
2777
- }
2778
- } finally {
2779
- rl.close();
2780
- }
2781
- process.stderr.write(`
2782
- `);
2783
- dim("Goodbye!");
2784
- }
2785
- async function streamToTerminal(response) {
2786
- let hasTokens = false;
2787
- const md = new MarkdownRenderer;
2788
- let lastToolDesc = "";
2789
- const result = await renderSSEStream(response, {
2790
- onToken(text) {
2791
- if (!hasTokens) {
2792
- clearStatus();
2793
- hasTokens = true;
2794
- }
2795
- md.write(text);
2796
- lastToolDesc = "";
2797
- },
2798
- onStatus(msg) {
2799
- if (!hasTokens) {
2800
- status(msg);
2801
- }
2802
- },
2803
- onToolActivity(description, phase) {
2804
- if (phase === "start") {
2805
- const friendly = humanizeToolName(description);
2806
- if (friendly === lastToolDesc)
2807
- return;
2808
- lastToolDesc = friendly;
2809
- md.finalize();
2810
- hasTokens = false;
2811
- toolActivity(friendly);
2812
- }
2813
- },
2814
- onResponseReset(reason) {
2815
- md.reset(reason);
2816
- hasTokens = false;
2817
- }
2818
- });
2819
- md.finalize();
2820
- clearStatus();
2821
- if (hasTokens) {
2822
- console.log();
2823
- }
2824
- return result;
2825
- }
2826
- async function handleStreamError(response) {
2827
- if (response.status === 401) {
2828
- error("Session expired or invalid. Run `index login` to re-authenticate.", 1);
2829
- }
2830
- const body = await response.json().catch(() => ({}));
2831
- error(body.error ?? `HTTP ${response.status}`, 1);
2832
- }
2833
2535
 
2834
2536
  // src/contact.command.ts
2835
2537
  var CONTACT_HELP = `
@@ -3072,8 +2774,7 @@ function renderHelp() {
3072
2774
  ];
3073
2775
  const gsLW = Math.max(...gsLefts.map((s) => s.length));
3074
2776
  const formsLefts = [
3075
- 'index conversation "message"',
3076
- "index conversation --session <id>",
2777
+ "index conversation list",
3077
2778
  "index sync --json",
3078
2779
  "index profile create",
3079
2780
  "index profile update",
@@ -3100,7 +2801,6 @@ function renderHelp() {
3100
2801
  const optLefts = [
3101
2802
  "--api-url <url>",
3102
2803
  "--app-url <url>",
3103
- "--session <id>",
3104
2804
  "--archived",
3105
2805
  "--status <status>",
3106
2806
  "--limit <n>",
@@ -3130,8 +2830,7 @@ function renderHelp() {
3130
2830
  helpRowCmd(gsLW, "index opportunity list", "see what was found for you")
3131
2831
  ]);
3132
2832
  panel("common forms", [
3133
- helpRowCmd(formsLW, 'index conversation "message"', "send a one-shot agent message"),
3134
- helpRowCmd(formsLW, "index conversation --session <id>", "resume an agent chat session"),
2833
+ helpRowCmd(formsLW, "index conversation list", "list your conversations"),
3135
2834
  helpRowCmd(formsLW, "index sync --json", "print synced context as JSON"),
3136
2835
  "",
3137
2836
  helpRowCmd(formsLW, "index profile create", "use social URL flags"),
@@ -3149,7 +2848,7 @@ function renderHelp() {
3149
2848
  helpRowCmd(cmdLW, "negotiation", "list · show"),
3150
2849
  "",
3151
2850
  helpRowCmd(cmdLW, "profile", "show · sync · search · create · update"),
3152
- helpRowCmd(cmdLW, "conversation", "sessions · list · with · show · send · stream"),
2851
+ helpRowCmd(cmdLW, "conversation", "list · with · show · send · stream"),
3153
2852
  helpRowCmd(cmdLW, "network", "list · create · show · update · delete"),
3154
2853
  helpRowCont(cmdLW, "join · leave · invite"),
3155
2854
  helpRowCmd(cmdLW, "contact", "list · add · remove · import"),
@@ -3161,7 +2860,6 @@ function renderHelp() {
3161
2860
  panel("options", [
3162
2861
  helpRowDim(optLW, "--api-url <url>", "override API server URL"),
3163
2862
  helpRowDim(optLW, "--app-url <url>", "override app URL for login"),
3164
- helpRowDim(optLW, "--session <id>", "resume a chat session"),
3165
2863
  helpRowDim(optLW, "--archived", "include archived signals"),
3166
2864
  helpRowDim(optLW, "--status <status>", "filter opportunities by status"),
3167
2865
  helpRowDim(optLW, "--limit <n>", "limit number of results"),
@@ -3313,8 +3011,6 @@ async function main() {
3313
3011
  case "conversation":
3314
3012
  await handleConversation(client, args.subcommand, args.positionals ?? [], {
3315
3013
  limit: args.limit,
3316
- sessionId: args.sessionId,
3317
- message: args.message,
3318
3014
  json: args.json
3319
3015
  });
3320
3016
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@indexnetwork/cli",
3
- "version": "0.14.0-rc.63.1",
3
+ "version": "0.15.0-rc.64.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.14.0-rc.63.1",
24
- "@indexnetwork/cli-linux-arm64": "0.14.0-rc.63.1",
25
- "@indexnetwork/cli-darwin-x64": "0.14.0-rc.63.1",
26
- "@indexnetwork/cli-darwin-arm64": "0.14.0-rc.63.1"
23
+ "@indexnetwork/cli-linux-x64": "0.15.0-rc.64.1",
24
+ "@indexnetwork/cli-linux-arm64": "0.15.0-rc.64.1",
25
+ "@indexnetwork/cli-darwin-x64": "0.15.0-rc.64.1",
26
+ "@indexnetwork/cli-darwin-arm64": "0.15.0-rc.64.1"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@types/bun": "1.3.14"