starkbot-cli 0.3.0 → 0.3.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.
Files changed (2) hide show
  1. package/dist/index.js +47 -11
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -337,6 +337,11 @@ function isJwtExpired(creds) {
337
337
  return true;
338
338
  }
339
339
  }
340
+ function getInstanceUrl(creds) {
341
+ if (creds.instance_url) return creds.instance_url;
342
+ if (creds.instance_domain) return `https://${creds.instance_domain}`;
343
+ throw new Error("No instance URL configured. Run `starkbot login` or `starkbot connect` first.");
344
+ }
340
345
  function requireCredentials() {
341
346
  const creds = loadCredentials();
342
347
  if (!creds) {
@@ -562,7 +567,12 @@ async function externalLogin() {
562
567
  {
563
568
  type: "input",
564
569
  name: "instanceUrl",
565
- message: "Instance URL (e.g. https://mybot.example.com):",
570
+ message: "Instance URL (e.g. mybot.example.com):",
571
+ filter: (val) => {
572
+ const v = val.trim();
573
+ if (v && !/^https?:\/\//i.test(v)) return `http://${v}`;
574
+ return v;
575
+ },
566
576
  validate: (val) => {
567
577
  if (!val.trim()) return "Instance URL is required";
568
578
  try {
@@ -601,6 +611,7 @@ async function externalLogin() {
601
611
  tenant_id: "",
602
612
  gateway_token: token,
603
613
  instance_domain: domain,
614
+ instance_url: baseUrl,
604
615
  mode: "external"
605
616
  });
606
617
  printSuccess(`Connected to ${domain}`);
@@ -883,7 +894,7 @@ async function connectCommand(opts = {}) {
883
894
  const spin2 = spinner("Testing connection...");
884
895
  spin2.start();
885
896
  try {
886
- const gw = new GatewayClient(`https://${domain}`, opts.token);
897
+ const gw = new GatewayClient(creds.instance_url ?? `https://${domain}`, opts.token);
887
898
  const ok = await gw.ping();
888
899
  spin2.stop();
889
900
  if (ok) {
@@ -909,7 +920,7 @@ async function connectCommand(opts = {}) {
909
920
  instance_domain: domain
910
921
  });
911
922
  spin.text = "Testing connection...";
912
- const gw = new GatewayClient(`https://${domain}`, token);
923
+ const gw = new GatewayClient(creds.instance_url ?? `https://${domain}`, token);
913
924
  const ok = await gw.ping();
914
925
  spin.stop();
915
926
  if (ok) {
@@ -955,7 +966,7 @@ var init_connect = __esm({
955
966
  // src/lib/status.ts
956
967
  import ora2 from "ora";
957
968
  import chalk2 from "chalk";
958
- var subtypeColor, toolColor, subagentColor, dimText, StatusTracker;
969
+ var subtypeColor, toolColor, subagentColor, dimText, successMark, failMark, StatusTracker;
959
970
  var init_status2 = __esm({
960
971
  "src/lib/status.ts"() {
961
972
  "use strict";
@@ -963,6 +974,8 @@ var init_status2 = __esm({
963
974
  toolColor = chalk2.yellow;
964
975
  subagentColor = chalk2.cyan;
965
976
  dimText = chalk2.dim;
977
+ successMark = chalk2.green("\u2705");
978
+ failMark = chalk2.red("\u274C");
966
979
  StatusTracker = class {
967
980
  spinner;
968
981
  activeSubtype = "";
@@ -976,10 +989,12 @@ var init_status2 = __esm({
976
989
  handleEvent(event) {
977
990
  switch (event.type) {
978
991
  case "tool_call":
992
+ this.printToolCall(event);
979
993
  this.addTool(event.tool_name ?? "unknown");
980
994
  break;
981
995
  case "tool_result":
982
996
  this.removeTool(event.tool_name ?? "unknown");
997
+ this.printToolResult(event);
983
998
  break;
984
999
  case "subagent_spawned":
985
1000
  this.addSubagent(event.label ?? "?", event.agent_subtype);
@@ -1010,6 +1025,25 @@ var init_status2 = __esm({
1010
1025
  break;
1011
1026
  }
1012
1027
  }
1028
+ printToolCall(event) {
1029
+ const name = event.tool_name ?? "unknown";
1030
+ this.pauseForText();
1031
+ console.log(dimText(` \u{1F527} ${toolColor("Calling:")} ${chalk2.bold(name)}`));
1032
+ this.resumeAfterText();
1033
+ }
1034
+ printToolResult(event) {
1035
+ const name = event.tool_name ?? "unknown";
1036
+ const ok = event.success !== false;
1037
+ const mark = ok ? successMark : failMark;
1038
+ const durationStr = event.duration_ms != null ? ` ${dimText(`(${event.duration_ms}ms)`)}` : "";
1039
+ this.pauseForText();
1040
+ console.log(dimText(` ${mark} ${chalk2.bold(name)}${durationStr}`));
1041
+ if (!ok && event.content) {
1042
+ const snippet = event.content.length > 200 ? event.content.slice(0, 200) + "..." : event.content;
1043
+ console.log(dimText(` ${chalk2.red(snippet)}`));
1044
+ }
1045
+ this.resumeAfterText();
1046
+ }
1013
1047
  prefix() {
1014
1048
  if (this.activeSubtype) {
1015
1049
  return `${subtypeColor(`[${this.activeSubtype}]`)} `;
@@ -1054,7 +1088,7 @@ var init_status2 = __esm({
1054
1088
  }
1055
1089
  if (this.activeTools.length > 0) {
1056
1090
  const names = this.activeTools.map((t) => toolColor(t)).join(", ");
1057
- parts.push(`calling ${names}`);
1091
+ parts.push(`running ${names}`);
1058
1092
  }
1059
1093
  if (parts.length === 0) {
1060
1094
  if (this.spinner.isSpinning && !this.paused) {
@@ -1113,7 +1147,7 @@ function requireGateway() {
1113
1147
  );
1114
1148
  }
1115
1149
  return new GatewayClient(
1116
- `https://${creds.instance_domain}`,
1150
+ getInstanceUrl(creds),
1117
1151
  creds.gateway_token
1118
1152
  );
1119
1153
  }
@@ -1127,7 +1161,8 @@ async function tryRefreshToken() {
1127
1161
  const client = new FlashClient(creds.jwt);
1128
1162
  const { token, domain } = await client.getGatewayToken();
1129
1163
  updateCredentials({ gateway_token: token, instance_domain: domain });
1130
- const gw = new GatewayClient(`https://${domain}`, token);
1164
+ const url = creds.instance_url ?? `https://${domain}`;
1165
+ const gw = new GatewayClient(url, token);
1131
1166
  const ok = await gw.ping();
1132
1167
  if (ok) {
1133
1168
  printSuccess("Gateway token refreshed automatically.");
@@ -1243,7 +1278,8 @@ async function chatReplCommand() {
1243
1278
  const creds = requireCredentials();
1244
1279
  const domain = creds.instance_domain;
1245
1280
  updateCredentials({ gateway_token: newToken });
1246
- gw = new GatewayClient(`https://${domain}`, newToken);
1281
+ const url = creds.instance_url ?? `https://${domain}`;
1282
+ gw = new GatewayClient(url, newToken);
1247
1283
  const ok = await gw.ping();
1248
1284
  if (ok) {
1249
1285
  printSuccess(`Reconnected to ${domain}`);
@@ -1550,7 +1586,7 @@ async function sessionsCommand() {
1550
1586
  throw new Error("Gateway not configured. Run `starkbot connect` first.");
1551
1587
  }
1552
1588
  const gw = new GatewayClient(
1553
- `https://${creds.instance_domain}`,
1589
+ getInstanceUrl(creds),
1554
1590
  creds.gateway_token
1555
1591
  );
1556
1592
  const spin = spinner("Fetching sessions...");
@@ -1601,7 +1637,7 @@ async function historyCommand(sessionId) {
1601
1637
  process.exit(1);
1602
1638
  }
1603
1639
  const gw = new GatewayClient(
1604
- `https://${creds.instance_domain}`,
1640
+ getInstanceUrl(creds),
1605
1641
  creds.gateway_token
1606
1642
  );
1607
1643
  const spin = spinner("Fetching message history...");
@@ -1800,7 +1836,7 @@ var init_wizard = __esm({
1800
1836
  init_ui();
1801
1837
  import { Command } from "commander";
1802
1838
  var program = new Command();
1803
- program.name("starkbot").description("CLI for Starkbot \u2014 login, provision, and chat with your bot").version("0.1.0").addHelpCommand("help", "Show help for a command");
1839
+ program.name("starkbot").description("CLI for Starkbot \u2014 login, provision, and chat with your bot").version("0.3.1").addHelpCommand("help", "Show help for a command");
1804
1840
  program.command("login").description("Login with X or connect to an external instance").action(async () => {
1805
1841
  const { loginCommand: loginCommand2 } = await Promise.resolve().then(() => (init_login(), login_exports));
1806
1842
  await loginCommand2();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "starkbot-cli",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "CLI for Starkbot — login, provision, and chat with your bot from the terminal",
5
5
  "type": "module",
6
6
  "bin": {