@indigoai-us/hq-cli 5.58.0 → 5.59.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.
@@ -0,0 +1,74 @@
1
+ import { describe, expect, it, beforeAll } from "vitest";
2
+ import chalk from "chalk";
3
+ import { describeChannel, formatChannelsList } from "./channels.js";
4
+ import type { ChannelSummary } from "./dm.js";
5
+
6
+ // Disable chalk's ANSI colouring so assertions read the plain rendered text
7
+ // (chalk is a singleton, so this also affects the module under test).
8
+ beforeAll(() => {
9
+ chalk.level = 0;
10
+ });
11
+
12
+ describe("describeChannel", () => {
13
+ it("shows a named channel with a `hq dm <slug>` hint", () => {
14
+ const c: ChannelSummary = {
15
+ channelId: "chn_v",
16
+ name: "VYG Dev",
17
+ slug: "vyg-dev",
18
+ scope: "company",
19
+ };
20
+ const out = describeChannel(c);
21
+ expect(out).toContain("VYG Dev");
22
+ expect(out).toContain("(company)");
23
+ expect(out).toContain('hq dm vyg-dev "…"');
24
+ });
25
+
26
+ it("identifies an unnamed group DM by its members", () => {
27
+ const c: ChannelSummary = {
28
+ channelId: "chn_grp",
29
+ scope: "group",
30
+ memberCount: 3,
31
+ members: [
32
+ { personUid: "prs_a", displayName: "Stefan" },
33
+ { personUid: "prs_b", displayName: "Hassaan" },
34
+ ],
35
+ };
36
+ const out = describeChannel(c);
37
+ expect(out).toContain("Stefan, Hassaan");
38
+ expect(out).toContain("(group DM)");
39
+ });
40
+
41
+ it("falls back to a member count when a group has no resolved names", () => {
42
+ const c: ChannelSummary = { channelId: "g", scope: "group", memberCount: 4 };
43
+ expect(describeChannel(c)).toContain("4-person group");
44
+ });
45
+ });
46
+
47
+ describe("formatChannelsList", () => {
48
+ it("renders an empty-state line when there are no channels", () => {
49
+ expect(formatChannelsList([])).toMatch(/No channels yet/);
50
+ });
51
+
52
+ it("headers with the count and lists each channel", () => {
53
+ const channels: ChannelSummary[] = [
54
+ { channelId: "chn_v", name: "VYG Dev", slug: "vyg-dev", scope: "company" },
55
+ {
56
+ channelId: "chn_grp",
57
+ scope: "group",
58
+ memberCount: 2,
59
+ members: [{ personUid: "prs_a", displayName: "Stefan" }],
60
+ },
61
+ ];
62
+ const out = formatChannelsList(channels);
63
+ expect(out).toMatch(/2 channels:/);
64
+ expect(out).toContain("VYG Dev");
65
+ expect(out).toContain("Stefan");
66
+ });
67
+
68
+ it("uses the singular 'channel' for one", () => {
69
+ const out = formatChannelsList([
70
+ { channelId: "chn_v", name: "VYG Dev", slug: "vyg-dev", scope: "company" },
71
+ ]);
72
+ expect(out).toMatch(/1 channel:/);
73
+ });
74
+ });
@@ -0,0 +1,88 @@
1
+ import { Command } from "commander";
2
+ import chalk from "chalk";
3
+ import { ensureCognitoToken } from "../utils/cognito-session.js";
4
+ import { vaultApiFetch } from "../utils/vault-api.js";
5
+ import { channelSlug, type ChannelSummary } from "./dm.js";
6
+
7
+ /**
8
+ * Human label for a channel row. Named channels (personal/company) show their
9
+ * name + a `hq dm <slug>` hint; unnamed group DMs are identified by their
10
+ * members (caller excluded), matching how HQ Sync renders them. Pure →
11
+ * unit-testable.
12
+ */
13
+ export function describeChannel(c: ChannelSummary): string {
14
+ if (c.scope === "group") {
15
+ const names = (c.members ?? [])
16
+ .map((m) => m.displayName)
17
+ .filter((n): n is string => !!n);
18
+ const who =
19
+ names.length > 0
20
+ ? names.join(", ")
21
+ : `${c.memberCount ?? "?"}-person group`;
22
+ return `${who} ${chalk.dim("(group DM)")}`;
23
+ }
24
+ const slug = c.slug ?? (c.name ? channelSlug(c.name) : "");
25
+ const scopeTag = c.scope ? chalk.dim(`(${c.scope})`) : "";
26
+ const hint = slug ? chalk.dim(`— hq dm ${slug} "…"`) : "";
27
+ return `${chalk.bold(c.name ?? slug ?? c.channelId)} ${scopeTag} ${hint}`.trim();
28
+ }
29
+
30
+ /**
31
+ * Render the caller's channels for `hq channels`. Pure (takes the already
32
+ * fetched list) so the formatting is unit-testable without network/auth.
33
+ */
34
+ export function formatChannelsList(channels: ChannelSummary[]): string {
35
+ if (channels.length === 0) {
36
+ return chalk.dim(
37
+ "No channels yet. Group DMs and named channels you're in will appear here.",
38
+ );
39
+ }
40
+ const lines = [
41
+ chalk.green(
42
+ `${channels.length} channel${channels.length === 1 ? "" : "s"}:`,
43
+ ),
44
+ ];
45
+ for (const c of channels) {
46
+ lines.push(` ${describeChannel(c)}`);
47
+ }
48
+ return lines.join("\n");
49
+ }
50
+
51
+ async function runChannelsList(): Promise<void> {
52
+ try {
53
+ const token = await ensureCognitoToken();
54
+ const res = await vaultApiFetch({ token, path: "/v1/notify/channels" });
55
+ if (!res.ok) {
56
+ if (res.status === 401) {
57
+ console.error(chalk.red("Not authenticated — run `hq login` and try again."));
58
+ } else {
59
+ const err = (await res.json().catch(() => ({}))) as Record<string, string>;
60
+ console.error(
61
+ chalk.red(`Could not list channels: ${err.error ?? err.message ?? res.statusText}`),
62
+ );
63
+ }
64
+ process.exit(1);
65
+ }
66
+ const data = (await res.json()) as { channels?: ChannelSummary[] };
67
+ console.log(formatChannelsList(data.channels ?? []));
68
+ } catch (err) {
69
+ console.error(
70
+ chalk.red("Error:"),
71
+ err instanceof Error ? err.message : String(err),
72
+ );
73
+ process.exit(1);
74
+ }
75
+ }
76
+
77
+ export function registerChannelsCommand(program: Command): void {
78
+ const channels = program
79
+ .command("channels")
80
+ .description("List the DM channels you're in (name them with `hq dm <name> \"…\"`).");
81
+
82
+ channels
83
+ .command("list", { isDefault: true })
84
+ .description("List your DM channels — named channels and group DMs.")
85
+ .action(async () => {
86
+ await runChannelsList();
87
+ });
88
+ }
@@ -26,7 +26,11 @@ import {
26
26
  matchRequest,
27
27
  buildConnectionActionBody,
28
28
  registerDmCommand,
29
+ channelSlug,
30
+ parseChannelName,
31
+ matchChannelsByName,
29
32
  type ConnectionRequest,
33
+ type ChannelSummary,
30
34
  } from "./dm.js";
31
35
 
32
36
  describe("parseGroupRecipients", () => {
@@ -42,6 +46,59 @@ describe("parseGroupRecipients", () => {
42
46
  });
43
47
  });
44
48
 
49
+ describe("channelSlug", () => {
50
+ it("mirrors the server: lowercases, hyphenates, trims", () => {
51
+ expect(channelSlug("vyg-dev")).toBe("vyg-dev");
52
+ expect(channelSlug("VYG Dev!!")).toBe("vyg-dev");
53
+ expect(channelSlug(" --Team Room-- ")).toBe("team-room");
54
+ });
55
+ });
56
+
57
+ describe("parseChannelName", () => {
58
+ it("treats a bare non-email/uid token as a channel name", () => {
59
+ expect(parseChannelName("vyg-dev")).toBe("vyg-dev");
60
+ expect(parseChannelName(" design ")).toBe("design");
61
+ });
62
+ it("strips a leading # (hash-channel form)", () => {
63
+ expect(parseChannelName("#vyg-dev")).toBe("vyg-dev");
64
+ expect(parseChannelName("#")).toBeNull();
65
+ });
66
+ it("returns null for person paths and group lists", () => {
67
+ expect(parseChannelName("a@b.com")).toBeNull();
68
+ expect(parseChannelName("prs_01ABC")).toBeNull();
69
+ expect(parseChannelName("agt_01ABC")).toBeNull();
70
+ expect(parseChannelName("a@x.com,b@y.com")).toBeNull();
71
+ expect(parseChannelName("")).toBeNull();
72
+ });
73
+ });
74
+
75
+ describe("matchChannelsByName", () => {
76
+ const channels: ChannelSummary[] = [
77
+ { channelId: "chn_1", name: "VYG Dev", slug: "vyg-dev", scope: "company" },
78
+ { channelId: "chn_2", name: "Design", slug: "design", scope: "personal" },
79
+ { channelId: "chn_grp", scope: "group", memberCount: 2 },
80
+ ];
81
+ it("matches a named channel by slug (case/punctuation-insensitive)", () => {
82
+ expect(matchChannelsByName(channels, "vyg-dev").map((c) => c.channelId)).toEqual([
83
+ "chn_1",
84
+ ]);
85
+ expect(matchChannelsByName(channels, "VYG Dev").map((c) => c.channelId)).toEqual([
86
+ "chn_1",
87
+ ]);
88
+ });
89
+ it("never matches an unnamed group DM", () => {
90
+ expect(matchChannelsByName(channels, "chn_grp")).toEqual([]);
91
+ expect(matchChannelsByName(channels, "")).toEqual([]);
92
+ });
93
+ it("returns every match so an ambiguous name can be detected", () => {
94
+ const dup: ChannelSummary[] = [
95
+ { channelId: "a", name: "ops", slug: "ops", scope: "personal" },
96
+ { channelId: "b", name: "Ops", slug: "ops", scope: "company" },
97
+ ];
98
+ expect(matchChannelsByName(dup, "ops").map((c) => c.channelId)).toEqual(["a", "b"]);
99
+ });
100
+ });
101
+
45
102
  describe("detectRecipient", () => {
46
103
  it("classifies an email", () => {
47
104
  expect(detectRecipient("Stefan@Getindigo.ai")).toEqual({
@@ -277,6 +334,78 @@ describe("dm command actions", () => {
277
334
  expect(String(fetchSpy.mock.calls[0][0])).toContain("/v1/notify/dm");
278
335
  });
279
336
 
337
+ const channelsPayload = {
338
+ channels: [
339
+ { channelId: "chn_v", name: "VYG Dev", slug: "vyg-dev", scope: "company" },
340
+ { channelId: "chn_grp", scope: "group", memberCount: 2 },
341
+ ],
342
+ };
343
+
344
+ it("channel send (bare name): resolves the channel then posts the message", async () => {
345
+ fetchSpy
346
+ .mockResolvedValueOnce(jsonResponse(200, channelsPayload)) // GET channels
347
+ .mockResolvedValueOnce(jsonResponse(200, { eventId: "evt_c" })); // POST message
348
+ await program.parseAsync(["dm", "vyg-dev", "hello channel"], { from: "user" });
349
+ // 1st call lists the caller's channels...
350
+ expect(String(fetchSpy.mock.calls[0][0])).toContain("/v1/notify/channels");
351
+ // ...2nd posts into the resolved channel id.
352
+ const sendCall = fetchSpy.mock.calls[1];
353
+ expect(String(sendCall[0])).toContain("/v1/notify/channels/chn_v/messages");
354
+ expect(JSON.parse((sendCall[1]?.body as string) ?? "{}").body).toBe("hello channel");
355
+ expect(logged()).toMatch(/Message posted to #VYG Dev\./);
356
+ expect(errSpy).not.toHaveBeenCalled();
357
+ });
358
+
359
+ it("channel send (#hash form) resolves the same channel", async () => {
360
+ fetchSpy
361
+ .mockResolvedValueOnce(jsonResponse(200, channelsPayload))
362
+ .mockResolvedValueOnce(jsonResponse(200, { eventId: "evt_c" }));
363
+ await program.parseAsync(["dm", "#vyg-dev", "yo"], { from: "user" });
364
+ expect(String(fetchSpy.mock.calls[1][0])).toContain("/v1/notify/channels/chn_v/messages");
365
+ expect(errSpy).not.toHaveBeenCalled();
366
+ });
367
+
368
+ it("channel send (--channel flag) takes the message from the positional", async () => {
369
+ fetchSpy
370
+ .mockResolvedValueOnce(jsonResponse(200, channelsPayload))
371
+ .mockResolvedValueOnce(jsonResponse(200, { eventId: "evt_c" }));
372
+ await program.parseAsync(["dm", "--channel", "vyg-dev", "flagged hello"], {
373
+ from: "user",
374
+ });
375
+ const sendCall = fetchSpy.mock.calls[1];
376
+ expect(String(sendCall[0])).toContain("/v1/notify/channels/chn_v/messages");
377
+ expect(JSON.parse((sendCall[1]?.body as string) ?? "{}").body).toBe("flagged hello");
378
+ expect(errSpy).not.toHaveBeenCalled();
379
+ });
380
+
381
+ it("channel send: unknown name errors and never posts", async () => {
382
+ fetchSpy.mockResolvedValueOnce(jsonResponse(200, channelsPayload));
383
+ await program
384
+ .parseAsync(["dm", "nope-channel", "hi"], { from: "user" })
385
+ .catch(() => undefined); // process.exit is mocked to throw
386
+ expect(errSpy.mock.calls.map((c) => String(c[1] ?? c[0])).join("\n")).toMatch(
387
+ /No channel named 'nope-channel'/,
388
+ );
389
+ // Only the GET happened — no message POST.
390
+ expect(fetchSpy.mock.calls).toHaveLength(1);
391
+ });
392
+
393
+ it("channel send: an ambiguous name errors and never posts", async () => {
394
+ fetchSpy.mockResolvedValueOnce(
395
+ jsonResponse(200, {
396
+ channels: [
397
+ { channelId: "a", name: "ops", slug: "ops", scope: "personal" },
398
+ { channelId: "b", name: "Ops", slug: "ops", scope: "company" },
399
+ ],
400
+ }),
401
+ );
402
+ await program
403
+ .parseAsync(["dm", "ops", "hi"], { from: "user" })
404
+ .catch(() => undefined);
405
+ expect(errSpy.mock.calls.map((c) => String(c[0])).join("\n")).toMatch(/ambiguous/);
406
+ expect(fetchSpy.mock.calls).toHaveLength(1);
407
+ });
408
+
280
409
  it("send: prints pending request on 202 connection_requested (not an error)", async () => {
281
410
  fetchSpy.mockResolvedValueOnce(
282
411
  jsonResponse(202, { state: "connection_requested" }),
@@ -42,6 +42,80 @@ export function parseGroupRecipients(recipient: string): string[] | null {
42
42
  return [...new Set(parts)];
43
43
  }
44
44
 
45
+ /**
46
+ * Normalize a channel name into a stable slug for name matching. MIRRORS the
47
+ * server's `channelSlug` (hq-pro src/vault-service/lib/channels.ts): lowercase,
48
+ * collapse runs of non-alphanumerics to single hyphens, trim leading/trailing
49
+ * hyphens. Keep in lockstep with the server so `hq dm vyg-dev` matches the
50
+ * channel the server stored as slug `vyg-dev`. Pure → unit-testable.
51
+ */
52
+ export function channelSlug(name: string): string {
53
+ return name
54
+ .trim()
55
+ .toLowerCase()
56
+ .replace(/[^a-z0-9]+/g, "-")
57
+ .replace(/^-+|-+$/g, "");
58
+ }
59
+
60
+ /**
61
+ * Decide whether a positional recipient token addresses a DM CHANNEL by name
62
+ * (rather than a person/agent or a group). Returns the bare channel name to
63
+ * resolve, or null when the token is a person path (email / prs_ / agt_ uid) or
64
+ * a comma group. Pure → unit-testable.
65
+ *
66
+ * "#vyg-dev" → "vyg-dev" (explicit hash form)
67
+ * "vyg-dev" → "vyg-dev" (bare name — not an email/uid/group)
68
+ * "a@b.com" → null (person)
69
+ * "prs_…" → null (person) "agt_…" → null (agent)
70
+ * "a@x,b@y" → null (group DM)
71
+ */
72
+ export function parseChannelName(recipient: string): string | null {
73
+ const r = recipient.trim();
74
+ if (!r) return null;
75
+ if (r.startsWith("#")) {
76
+ const name = r.slice(1).trim();
77
+ return name || null;
78
+ }
79
+ // A comma is the group-DM signal; emails and prs_/agt_ uids are person paths.
80
+ if (r.includes(",")) return null;
81
+ if (EMAIL_PATTERN.test(r)) return null;
82
+ if (RECIPIENT_UID_PATTERN.test(r)) return null;
83
+ return r;
84
+ }
85
+
86
+ /** Minimal channel shape the CLI reads back from GET /v1/notify/channels. */
87
+ export interface ChannelSummary {
88
+ channelId: string;
89
+ name?: string;
90
+ slug?: string;
91
+ scope?: string;
92
+ memberCount?: number;
93
+ members?: { personUid: string; displayName?: string }[];
94
+ }
95
+
96
+ /**
97
+ * Find the caller's channel(s) whose name matches `name`, by slug or
98
+ * case-insensitive display name. Group DMs are unnamed (participant-keyed), so
99
+ * they never match a name. Returns ALL matches so the caller can detect an
100
+ * ambiguous name (same slug across personal + company scope). Pure →
101
+ * unit-testable.
102
+ */
103
+ export function matchChannelsByName(
104
+ channels: ChannelSummary[],
105
+ name: string,
106
+ ): ChannelSummary[] {
107
+ const targetSlug = channelSlug(name);
108
+ const targetName = name.trim().toLowerCase();
109
+ if (!targetSlug && !targetName) return [];
110
+ return channels.filter((c) => {
111
+ if (c.scope === "group") return false;
112
+ const slug = c.slug ?? (c.name ? channelSlug(c.name) : "");
113
+ if (slug && slug === targetSlug) return true;
114
+ if (c.name && c.name.trim().toLowerCase() === targetName) return true;
115
+ return false;
116
+ });
117
+ }
118
+
45
119
  /**
46
120
  * Parse a relative duration like `30s`, `10m`, `2h`, `1d` into milliseconds.
47
121
  * Returns null on anything that doesn't match. Pure → unit-testable.
@@ -265,6 +339,7 @@ interface DmSendOpts {
265
339
  detailsFile?: string;
266
340
  at?: string;
267
341
  in?: string;
342
+ channel?: string;
268
343
  }
269
344
 
270
345
  /**
@@ -384,17 +459,136 @@ async function runGroupSend(
384
459
  }
385
460
  }
386
461
 
462
+ /** Fetch the caller's channels (GET /v1/notify/channels). */
463
+ async function fetchChannels(token: string): Promise<ChannelSummary[]> {
464
+ const res = await vaultApiFetch({ token, path: "/v1/notify/channels" });
465
+ if (!res.ok) {
466
+ const err = (await res.json().catch(() => ({}))) as Record<string, string>;
467
+ throw new Error(
468
+ friendlyDmError(res.status, err.code, err.error ?? err.message ?? res.statusText),
469
+ );
470
+ }
471
+ const data = (await res.json()) as { channels?: ChannelSummary[] };
472
+ return data.channels ?? [];
473
+ }
474
+
475
+ /**
476
+ * Channel DM path: `hq dm vyg-dev "msg"`, `hq dm '#vyg-dev' "msg"`, or
477
+ * `hq dm --channel vyg-dev "msg"`. Resolves the caller's channel by name via
478
+ * GET /v1/notify/channels, then posts the message into it. Scheduling /
479
+ * prompt / details are 1:1-DM features and are rejected here rather than
480
+ * silently dropped.
481
+ */
482
+ async function runChannelSend(
483
+ channelName: string,
484
+ message: string | undefined,
485
+ opts: DmSendOpts,
486
+ ): Promise<void> {
487
+ try {
488
+ const body = (message ?? "").trim();
489
+ if (!body) {
490
+ console.error(
491
+ chalk.red(
492
+ `A message body is required: hq dm ${channelName} "<message>" (or hq dm --channel ${channelName} "<message>").`,
493
+ ),
494
+ );
495
+ process.exit(1);
496
+ }
497
+ const unsupported = [
498
+ opts.prompt || opts.promptFile ? "--prompt/--prompt-file" : null,
499
+ opts.details || opts.detailsFile ? "--details/--details-file" : null,
500
+ opts.at ? "--at" : null,
501
+ opts.in ? "--in" : null,
502
+ ].filter(Boolean);
503
+ if (unsupported.length > 0) {
504
+ console.error(
505
+ chalk.red(
506
+ `${unsupported.join(", ")} ${
507
+ unsupported.length === 1 ? "is" : "are"
508
+ } only supported for 1:1 DMs, not channel messages.`,
509
+ ),
510
+ );
511
+ process.exit(1);
512
+ }
513
+
514
+ const token = await ensureCognitoToken();
515
+ const channels = await fetchChannels(token);
516
+ const matches = matchChannelsByName(channels, channelName);
517
+
518
+ if (matches.length === 0) {
519
+ console.error(
520
+ chalk.red(`No channel named '${channelName}' — run \`hq channels\` to see your channels.`),
521
+ );
522
+ process.exit(1);
523
+ }
524
+ if (matches.length > 1) {
525
+ const scopes = matches.map((m) => m.scope ?? "?").join(", ");
526
+ console.error(
527
+ chalk.red(
528
+ `'${channelName}' matches ${matches.length} channels (${scopes}) — this is ambiguous. Open the channel in HQ Sync to post, or rename one.`,
529
+ ),
530
+ );
531
+ process.exit(1);
532
+ }
533
+
534
+ const channel = matches[0];
535
+ const sendRes = await vaultApiFetch({
536
+ token,
537
+ path: `/v1/notify/channels/${encodeURIComponent(channel.channelId)}/messages`,
538
+ method: "POST",
539
+ body: { body },
540
+ });
541
+ if (!sendRes.ok) {
542
+ const err = (await sendRes.json().catch(() => ({}))) as Record<string, string>;
543
+ console.error(
544
+ chalk.red(
545
+ friendlyDmError(sendRes.status, err.code, err.error ?? err.message ?? sendRes.statusText),
546
+ ),
547
+ );
548
+ process.exit(1);
549
+ }
550
+ console.log(chalk.green(`Message posted to #${channel.name ?? channelName}.`));
551
+ } catch (err) {
552
+ console.error(
553
+ chalk.red("Error:"),
554
+ err instanceof Error ? err.message : String(err),
555
+ );
556
+ process.exit(1);
557
+ }
558
+ }
559
+
387
560
  async function runDmSend(
388
- recipient: string,
561
+ recipient: string | undefined,
389
562
  message: string | undefined,
390
563
  opts: DmSendOpts,
391
564
  ): Promise<void> {
565
+ // --channel <name> is an explicit channel target; the positional carries the
566
+ // message (recipient slot), e.g. `hq dm --channel vyg-dev "hello"`.
567
+ if (opts.channel !== undefined) {
568
+ await runChannelSend(opts.channel, message ?? recipient, opts);
569
+ return;
570
+ }
571
+ if (recipient === undefined) {
572
+ console.error(
573
+ chalk.red(
574
+ 'A recipient is required: hq dm <email|personUid|#channel> "<message>" (or --channel <name>).',
575
+ ),
576
+ );
577
+ process.exit(1);
578
+ return;
579
+ }
392
580
  // A comma in the recipient means a group DM — fan into the channel path.
393
581
  const group = parseGroupRecipients(recipient);
394
582
  if (group) {
395
583
  await runGroupSend(group, message);
396
584
  return;
397
585
  }
586
+ // A bare name or #hash addresses a named DM channel.
587
+ const channelName = parseChannelName(recipient);
588
+ if (channelName !== null) {
589
+ await runChannelSend(channelName, message, opts);
590
+ return;
591
+ }
398
592
  try {
399
593
  // Resolve prompt/details from inline text or a file.
400
594
  let prompt = opts.prompt;
@@ -516,31 +710,35 @@ export function registerDmCommand(program: Command): void {
516
710
  );
517
711
 
518
712
  dm
519
- .command("send <recipient> [message]", { isDefault: true, hidden: true })
713
+ .command("send [recipient] [message]", { isDefault: true, hidden: true })
520
714
  .description(
521
- 'Send a direct message to someone (email, personUid, or agentUid). A person receives it as an HQ Sync notification; an agent receives it in its durable box inbox and replies by DM. If you aren\'t connected yet, it sends a connection request that holds your message. For a GROUP DM, pass a comma-separated recipient: hq dm send "a@x.com,b@y.com" "hi".',
715
+ 'Send a direct message. RECIPIENT can be a person (email, personUid, or agentUid), a GROUP DM (comma-separated: "a@x.com,b@y.com"), or one of your DM CHANNELS by name — bare (hq dm vyg-dev "hi"), hash form (hq dm "#vyg-dev" "hi"), or via --channel (hq dm --channel vyg-dev "hi"). A person receives a DM as an HQ Sync notification; an agent receives it in its durable box inbox. If you aren\'t connected yet, it sends a connection request that holds your message. See your channels with `hq channels`.',
716
+ )
717
+ .option(
718
+ "--channel <name>",
719
+ "Post the message to one of your DM channels by name (e.g. --channel vyg-dev)",
522
720
  )
523
721
  .option(
524
722
  "--prompt <text>",
525
- "Agent-context prompt the recipient can one-click copy into their agent",
723
+ "Agent-context prompt the recipient can one-click copy into their agent (1:1 DMs only)",
526
724
  )
527
- .option("--prompt-file <path>", "Read the agent prompt from a file")
725
+ .option("--prompt-file <path>", "Read the agent prompt from a file (1:1 DMs only)")
528
726
  .option(
529
727
  "--details <text>",
530
- "Longer detail shown in the recipient's DM detail window",
728
+ "Longer detail shown in the recipient's DM detail window (1:1 DMs only)",
531
729
  )
532
- .option("--details-file <path>", "Read the details from a file")
730
+ .option("--details-file <path>", "Read the details from a file (1:1 DMs only)")
533
731
  .option(
534
732
  "--at <iso>",
535
- "Schedule delivery at an ISO8601 time (store-and-forward; delivered within ~60s of the time)",
733
+ "Schedule delivery at an ISO8601 time (store-and-forward; delivered within ~60s of the time; 1:1 DMs only)",
536
734
  )
537
735
  .option(
538
736
  "--in <duration>",
539
- "Schedule delivery after a relative delay: 30s, 10m, 2h, 1d",
737
+ "Schedule delivery after a relative delay: 30s, 10m, 2h, 1d (1:1 DMs only)",
540
738
  )
541
739
  .action(
542
740
  async (
543
- recipient: string,
741
+ recipient: string | undefined,
544
742
  message: string | undefined,
545
743
  opts: DmSendOpts,
546
744
  ) => {