@getdial/cli 0.15.3 → 0.17.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
@@ -96,12 +96,14 @@ number
96
96
  })));
97
97
  number
98
98
  .command("set <number>")
99
- .description("Update a number's inbound instruction. PATCH /api/v1/numbers/<id>.")
100
- .requiredOption("--inbound-instruction <text>", "new system prompt for inbound calls to this number")
99
+ .description("Update a number's properties (at least one flag). PATCH /api/v1/numbers/<id>.")
100
+ .option("--inbound-instruction <text>", "new system prompt for inbound calls to this number")
101
+ .option("--nickname <text>", 'human-readable label for the number, e.g. "Support line"; pass "" to clear')
101
102
  .option("--json", "machine-readable output")
102
103
  .action(async (numberArg, opts) => process.exit(await runNumberSet({
103
104
  number: numberArg,
104
105
  inboundInstruction: opts.inboundInstruction,
106
+ nickname: opts.nickname,
105
107
  json: !!opts.json,
106
108
  })));
107
109
  const message = program
@@ -14,7 +14,8 @@ export async function runNumberList(opts) {
14
14
  }
15
15
  for (const n of numbers) {
16
16
  const tag = n.id === defaultNumberId ? " (default)" : "";
17
- console.log(`${n.number} id=${n.id} ${n.country}${tag}`);
17
+ const nickname = n.nickname ? ` "${n.nickname}"` : "";
18
+ console.log(`${n.number} id=${n.id} ${n.country}${nickname}${tag}`);
18
19
  }
19
20
  return 0;
20
21
  }
@@ -3,7 +3,11 @@ import { isDialError } from "../../lib/ops/errors.js";
3
3
  import { printDialError } from "../../lib/cli-error.js";
4
4
  export async function runNumberSet(opts) {
5
5
  try {
6
- const n = await setNumberProperties({ number: opts.number, inboundInstruction: opts.inboundInstruction });
6
+ const n = await setNumberProperties({
7
+ number: opts.number,
8
+ inboundInstruction: opts.inboundInstruction,
9
+ ...(opts.nickname !== undefined ? { nickname: opts.nickname } : {}),
10
+ });
7
11
  if (opts.json) {
8
12
  console.log(JSON.stringify({ ok: true, number: n }));
9
13
  }
@@ -11,6 +15,7 @@ export async function runNumberSet(opts) {
11
15
  console.log(`updated.`);
12
16
  console.log(` number: ${n.number}`);
13
17
  console.log(` id: ${n.id}`);
18
+ console.log(` nickname: ${n.nickname ?? ""}`);
14
19
  console.log(` inbound instruction: ${n.inboundInstruction ?? ""}`);
15
20
  }
16
21
  return 0;
@@ -6,6 +6,7 @@ const EXIT_1_CODES = new Set([
6
6
  "number_not_found",
7
7
  "not_found",
8
8
  "no_pending_signup",
9
+ "bad_request",
9
10
  ]);
10
11
  /**
11
12
  * Print a DialError the way the generic REST commands always have — `--json` emits
@@ -21,12 +21,15 @@ export function matches(obj, spec) {
21
21
  const record = obj;
22
22
  if (record.type !== spec.eventType)
23
23
  return false;
24
+ // Field/regex filters address the event's `data` payload by name, e.g.
25
+ // `-f channel=sms` matches event.data.channel.
26
+ const data = (record.data ?? {});
24
27
  for (const f of spec.fields) {
25
- if (String(record[f.name] ?? "") !== f.value)
28
+ if (String(data[f.name] ?? "") !== f.value)
26
29
  return false;
27
30
  }
28
31
  for (const r of spec.regexes) {
29
- if (!r.regex.test(String(record[r.name] ?? "")))
32
+ if (!r.regex.test(String(data[r.name] ?? "")))
30
33
  return false;
31
34
  }
32
35
  return true;
@@ -21,6 +21,14 @@ export async function purchaseNumber(opts) {
21
21
  return res.data.number;
22
22
  }
23
23
  export async function setNumberProperties(opts) {
24
+ const body = {};
25
+ if (opts.inboundInstruction !== undefined)
26
+ body.inboundInstruction = opts.inboundInstruction;
27
+ if (opts.nickname !== undefined)
28
+ body.nickname = opts.nickname;
29
+ if (Object.keys(body).length === 0) {
30
+ throw new DialError("bad_request", "Provide at least one property to update (inboundInstruction or nickname).");
31
+ }
24
32
  const auth = requireAuth();
25
33
  // The REST API keys numbers by id; the CLI/tool takes the E.164 number for ergonomics,
26
34
  // so resolve it to its id first.
@@ -32,7 +40,7 @@ export async function setNumberProperties(opts) {
32
40
  const known = list.data.numbers.map((n) => n.number).join(", ") || "(none)";
33
41
  throw new DialError("number_not_found", `No phone number ${opts.number} on your account. Yours: ${known}.`);
34
42
  }
35
- const res = await apiPatch(`/api/v1/numbers/${match.id}`, { inboundInstruction: opts.inboundInstruction }, auth.apiKey);
43
+ const res = await apiPatch(`/api/v1/numbers/${match.id}`, body, auth.apiKey);
36
44
  if (!res.ok)
37
45
  throw new DialError("update_failed", res.error, res.status);
38
46
  return res.data.number;
@@ -22,6 +22,7 @@ export const phoneNumberSchema = z
22
22
  .object({
23
23
  id: z.string().describe("Phone number id (pn_…)"),
24
24
  number: z.string().describe("E.164 phone number"),
25
+ nickname: z.string().nullable().optional().describe("Human-readable label for the number"),
25
26
  country: z.string().optional(),
26
27
  inboundInstruction: z.string().nullable().optional(),
27
28
  })
@@ -4,13 +4,14 @@ import { setNumberProperties } from "../../lib/ops/numbers.js";
4
4
  import { phoneNumberSchema } from "../schemas.js";
5
5
  const inputSchema = {
6
6
  number: z.string().min(7).describe("The E.164 phone number to update (e.g. +14155550123)"),
7
- inboundInstruction: z.string().min(1).describe("New system prompt for inbound calls to this number"),
7
+ inboundInstruction: z.string().min(1).optional().describe("New system prompt for inbound calls to this number"),
8
+ nickname: z.string().max(100).optional().describe('Human-readable label for the number, e.g. "Support line". Pass an empty string to clear it.'),
8
9
  };
9
10
  export const setNumberPropertiesTool = {
10
11
  name: "set_number_properties",
11
12
  config: {
12
13
  title: "Set Number Properties",
13
- description: "Update a phone number's inbound instruction (the system prompt for inbound calls).",
14
+ description: "Update a phone number's properties: its inbound instruction (the system prompt for inbound calls) and/or its nickname. Provide at least one.",
14
15
  inputSchema,
15
16
  outputSchema: { number: phoneNumberSchema },
16
17
  annotations: { openWorldHint: true },
@@ -19,6 +20,7 @@ export const setNumberPropertiesTool = {
19
20
  number: await setNumberProperties({
20
21
  number: args.number,
21
22
  inboundInstruction: args.inboundInstruction,
23
+ ...(args.nickname !== undefined ? { nickname: args.nickname } : {}),
22
24
  }),
23
25
  }),
24
26
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getdial/cli",
3
- "version": "0.15.3",
3
+ "version": "0.17.0",
4
4
  "description": "Dial CLI — install, sign up, and run the local listen service.",
5
5
  "license": "MIT",
6
6
  "repository": {
package/skills.tar.gz CHANGED
Binary file