@getdial/cli 0.2.0 → 0.3.0

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/cli.js CHANGED
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { Command } from "commander";
3
+ import { VERSION } from "./lib/version.js";
3
4
  import { runDoctor } from "./commands/doctor.js";
4
5
  import { runSignup } from "./commands/signup.js";
5
6
  import { runOnboard } from "./commands/onboard.js";
@@ -15,7 +16,7 @@ const program = new Command();
15
16
  program
16
17
  .name("dial")
17
18
  .description("Dial CLI — set up your account and run the listen service.")
18
- .version("0.1.0");
19
+ .version(VERSION);
19
20
  program
20
21
  .command("doctor")
21
22
  .description("Report state and what to do next.")
@@ -2,6 +2,7 @@ import { readPendingSignup, readAuth } from "../lib/state.js";
2
2
  import { apiGet, baseUrl, pingBackend } from "../lib/api.js";
3
3
  import { supervisorStatus, lastEventAtFromLog } from "../lib/supervisor/index.js";
4
4
  import { paths } from "../lib/paths.js";
5
+ import { VERSION } from "../lib/version.js";
5
6
  const OTP_EXPIRY_MS = 10 * 60 * 1000;
6
7
  async function buildReport() {
7
8
  const ping = await pingBackend();
@@ -45,7 +46,7 @@ async function buildReport() {
45
46
  nextStep = "ready";
46
47
  }
47
48
  return {
48
- cli: { version: "0.1.0", node: process.versions.node },
49
+ cli: { version: VERSION, node: process.versions.node },
49
50
  backend: { url: baseUrl(), reachable: ping.reachable, latency_ms: ping.latencyMs },
50
51
  auth: {
51
52
  signed_in: Boolean(auth),
@@ -1,5 +1,14 @@
1
1
  import { readPendingSignup, clearPendingSignup, writeAuth } from "../lib/state.js";
2
2
  import { apiPost } from "../lib/api.js";
3
+ import { paths } from "../lib/paths.js";
4
+ function maskApiKey(key) {
5
+ return key.length >= 4 ? `sk_live_***${key.slice(-4)}` : "sk_live_***";
6
+ }
7
+ const LISTEN_QUESTION = "Install the background notification listening service?";
8
+ const LISTEN_RATIONALE = "The background notification listening service runs on this machine and listens for notifications from Dial — SMS arrivals (2FA codes, replies) and call-ended notifications — so the agent on this machine learns about them in real time. " +
9
+ "Without it the agent is send-only: it can place outbound calls and send messages, but it has no way to know when something arrives at your Dial number. " +
10
+ "It can always be installed later with `dial listen install`.";
11
+ const PRESENTATION_HINT = "When you ask the user, describe it as \"the background notification listening service.\" Don't expose technical details (launchd, plists, daemons, systemd units) — that's not how to talk about it to a non-technical user.";
3
12
  export async function runOnboard(opts) {
4
13
  let verificationId = opts.verificationId;
5
14
  let email = null;
@@ -39,39 +48,48 @@ export async function runOnboard(opts) {
39
48
  phone_number_id: res.data.phone_number_id ?? null,
40
49
  });
41
50
  clearPendingSignup();
42
- let listenStatus = { installed: false, warnings: [], error: null };
43
- try {
44
- const { installSupervised } = await import("../lib/supervisor/index.js");
45
- const dialPath = process.env.DIAL_BIN_OVERRIDE ?? process.argv[1] ?? "dial";
46
- const result = installSupervised(dialPath);
47
- listenStatus = { installed: true, warnings: result.warnings, error: null };
48
- }
49
- catch (err) {
50
- listenStatus = { installed: false, warnings: [], error: err instanceof Error ? err.message : String(err) };
51
- }
51
+ const authFile = paths().authFile;
52
+ const masked = maskApiKey(apiKey);
52
53
  if (opts.json) {
53
54
  console.log(JSON.stringify({
54
55
  ok: true,
55
- api_key: apiKey,
56
+ api_key_fingerprint: apiKey.slice(-4),
57
+ api_key_masked: masked,
58
+ api_key_path: authFile,
56
59
  account_id: res.data.account_id,
57
60
  phone_number: res.data.phone_number ?? null,
58
61
  phone_number_id: res.data.phone_number_id ?? null,
59
- listen: listenStatus,
62
+ listen: { installed: false, auto_installed: false },
63
+ agent_hint: {
64
+ action: "ask_user",
65
+ question: LISTEN_QUESTION,
66
+ rationale: LISTEN_RATIONALE,
67
+ presentation: PRESENTATION_HINT,
68
+ use_structured_tool_if_available: true,
69
+ on_yes: "dial listen install",
70
+ on_no: null,
71
+ },
60
72
  }));
61
73
  }
62
74
  else {
63
75
  console.log("onboarded.");
64
- console.log(` api key: ${apiKey} (save this — shown once)`);
76
+ console.log(` api key: ${masked} (saved to ${authFile})`);
65
77
  if (res.data.phone_number)
66
78
  console.log(` phone number: ${res.data.phone_number}`);
67
- if (listenStatus.installed) {
68
- console.log(` listen: installed and running (logs: ~/.local/state/dial/listen.log)`);
69
- for (const w of listenStatus.warnings)
70
- console.log(` ! ${w}`);
71
- }
72
- else {
73
- console.log(` listen: NOT installed (${listenStatus.error}). Run \`dial listen install\` manually.`);
74
- }
79
+ console.log(``);
80
+ console.log(`The background notification listening service is not running yet.`);
81
+ console.log(`${LISTEN_RATIONALE}`);
82
+ console.log(``);
83
+ console.log(`If you are an agent, ask the user now:`);
84
+ console.log(``);
85
+ console.log(` "${LISTEN_QUESTION}"`);
86
+ console.log(``);
87
+ console.log(PRESENTATION_HINT);
88
+ console.log(``);
89
+ console.log(`Use your ask-user / clarification tool if you have one; otherwise just ask in your regular reply and wait for the answer.`);
90
+ console.log(``);
91
+ console.log(`If yes: run \`dial listen install\``);
92
+ console.log(`If no: leave it off — install later with \`dial listen install\``);
75
93
  }
76
94
  return 0;
77
95
  }
@@ -0,0 +1,8 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { fileURLToPath } from "node:url";
3
+ import { dirname, join } from "node:path";
4
+ // Resolves the published package.json regardless of where the compiled
5
+ // module lands (dist/lib/version.js → ../../package.json at the package root).
6
+ const pkgPath = join(dirname(fileURLToPath(import.meta.url)), "..", "..", "package.json");
7
+ const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
8
+ export const VERSION = pkg.version;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getdial/cli",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Dial CLI — install, sign up, and run the local listen service.",
5
5
  "license": "MIT",
6
6
  "bin": {