@indigoai-us/hq-cli 5.77.13 → 5.78.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.
Files changed (307) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/assets/scaffold/core/scripts/archive-old-threads.sh +86 -0
  3. package/assets/scaffold/core/scripts/backfill-company-skill-mirrors.sh +73 -0
  4. package/assets/scaffold/core/scripts/backfill-workspace-mirror.sh +51 -0
  5. package/assets/scaffold/core/scripts/codex-skill-bridge.sh +550 -0
  6. package/assets/scaffold/core/scripts/detect-stale-core-policy-mirror.sh +185 -0
  7. package/assets/scaffold/core/scripts/hq-status-summary.sh +187 -0
  8. package/assets/scaffold/core/scripts/ontology-readme-drift.sh +264 -0
  9. package/assets/scaffold/core/scripts/qmd-reindex-after-sync.sh +93 -0
  10. package/assets/scaffold/core/scripts/rebuild-all-indexes.sh +69 -0
  11. package/assets/scaffold/core/scripts/rebuild-companies-index.sh +206 -0
  12. package/assets/scaffold/core/scripts/rebuild-company-knowledge-index.sh +127 -0
  13. package/assets/scaffold/core/scripts/rebuild-orchestrator-index.sh +86 -0
  14. package/assets/scaffold/core/scripts/rebuild-projects-index.sh +105 -0
  15. package/assets/scaffold/core/scripts/rebuild-public-knowledge-index.sh +83 -0
  16. package/assets/scaffold/core/scripts/rebuild-reports-index.sh +114 -0
  17. package/assets/scaffold/core/scripts/rebuild-social-drafts-index.sh +135 -0
  18. package/assets/scaffold/core/scripts/rebuild-threads-index.sh +82 -0
  19. package/assets/scaffold/core/scripts/rebuild-workers-index.sh +97 -0
  20. package/assets/scaffold/core/scripts/resize-screenshot.sh +47 -0
  21. package/assets/scaffold/core/scripts/token-usage-report.sh +254 -0
  22. package/assets/scaffold/core/scripts/worktree.sh +136 -0
  23. package/dist/commands/agents.js +28 -12
  24. package/dist/commands/api-keys.js +100 -20
  25. package/dist/commands/core.d.ts +90 -0
  26. package/dist/commands/core.js +279 -0
  27. package/dist/commands/files-browse.d.ts +21 -0
  28. package/dist/commands/files-browse.js +145 -24
  29. package/dist/commands/files.js +33 -7
  30. package/dist/commands/members.js +16 -5
  31. package/dist/commands/pack-install.d.ts +14 -0
  32. package/dist/commands/pack-install.js +51 -2
  33. package/dist/commands/pkg-install.js +43 -0
  34. package/dist/commands/run.js +8 -0
  35. package/dist/commands/secrets.js +125 -65
  36. package/dist/main.js +6 -0
  37. package/dist/utils/api-key-command-gate.d.ts +45 -0
  38. package/dist/utils/api-key-command-gate.js +51 -0
  39. package/dist/utils/hq-roots.d.ts +91 -0
  40. package/dist/utils/hq-roots.js +212 -0
  41. package/dist/utils/resolve-vault-credential.d.ts +63 -3
  42. package/dist/utils/resolve-vault-credential.js +152 -6
  43. package/dist/utils/run-bundled-script.d.ts +66 -0
  44. package/dist/utils/run-bundled-script.js +80 -0
  45. package/dist/utils/vault-api.d.ts +21 -0
  46. package/dist/utils/vault-api.js +74 -3
  47. package/package.json +7 -1
  48. package/.claude/policies/hq-cli-interactive-reads-use-sts-vend.md +0 -49
  49. package/.github/workflows/ci.yml +0 -46
  50. package/.github/workflows/publish.yml +0 -36
  51. package/.github/workflows/scripts/smoke-test-pkg.sh +0 -97
  52. package/e2e/cli.test.ts +0 -128
  53. package/eslint.config.js +0 -37
  54. package/pnpm-workspace.yaml +0 -4
  55. package/scripts/chmod-bins.mjs +0 -49
  56. package/scripts/generate-dsn.mjs +0 -26
  57. package/scripts/generate-scan-packages-table.mjs +0 -113
  58. package/scripts/smoke-sources-signals.sh +0 -103
  59. package/src/bin/hq-auth-refresh.ts +0 -43
  60. package/src/cli-version.ts +0 -13
  61. package/src/commands/__fixtures__/make-tar.ts +0 -126
  62. package/src/commands/_patterns.ts +0 -10
  63. package/src/commands/add.ts +0 -75
  64. package/src/commands/agents.test.ts +0 -527
  65. package/src/commands/agents.ts +0 -923
  66. package/src/commands/api-keys.test.ts +0 -291
  67. package/src/commands/api-keys.ts +0 -382
  68. package/src/commands/artifact-verify.test.ts +0 -177
  69. package/src/commands/auth.test.ts +0 -82
  70. package/src/commands/auth.ts +0 -213
  71. package/src/commands/billing.test.ts +0 -158
  72. package/src/commands/billing.ts +0 -146
  73. package/src/commands/channels.test.ts +0 -74
  74. package/src/commands/channels.ts +0 -91
  75. package/src/commands/cloud-demote.test.ts +0 -401
  76. package/src/commands/cloud-demote.ts +0 -278
  77. package/src/commands/cloud-provision.test.ts +0 -1117
  78. package/src/commands/cloud-provision.ts +0 -942
  79. package/src/commands/cloud.pull-all.test.ts +0 -711
  80. package/src/commands/cloud.pull-per-company.test.ts +0 -188
  81. package/src/commands/cloud.push-all.test.ts +0 -485
  82. package/src/commands/cloud.scope-excluded-warning.test.ts +0 -22
  83. package/src/commands/cloud.selectors.test.ts +0 -208
  84. package/src/commands/cloud.status.test.ts +0 -160
  85. package/src/commands/cloud.test.ts +0 -41
  86. package/src/commands/cloud.ts +0 -2130
  87. package/src/commands/company.test.ts +0 -202
  88. package/src/commands/company.ts +0 -148
  89. package/src/commands/creators.test.ts +0 -60
  90. package/src/commands/creators.ts +0 -117
  91. package/src/commands/crm.test.ts +0 -179
  92. package/src/commands/crm.ts +0 -236
  93. package/src/commands/db-migrate.ts +0 -55
  94. package/src/commands/db-provision.ts +0 -114
  95. package/src/commands/db-sql.ts +0 -124
  96. package/src/commands/db-status.ts +0 -108
  97. package/src/commands/db.ts +0 -26
  98. package/src/commands/dm.test.ts +0 -748
  99. package/src/commands/dm.ts +0 -1226
  100. package/src/commands/feedback.test.ts +0 -413
  101. package/src/commands/feedback.ts +0 -169
  102. package/src/commands/files-browse.test.ts +0 -1249
  103. package/src/commands/files-browse.ts +0 -1506
  104. package/src/commands/files-delete.test.ts +0 -484
  105. package/src/commands/files-recovery.test.ts +0 -370
  106. package/src/commands/files.test.ts +0 -722
  107. package/src/commands/files.ts +0 -1446
  108. package/src/commands/group-grants.test.ts +0 -330
  109. package/src/commands/group-grants.ts +0 -455
  110. package/src/commands/groups.test.ts +0 -44
  111. package/src/commands/groups.ts +0 -368
  112. package/src/commands/integrations.test.ts +0 -633
  113. package/src/commands/integrations.ts +0 -507
  114. package/src/commands/list.ts +0 -85
  115. package/src/commands/login.ts +0 -52
  116. package/src/commands/logout.ts +0 -30
  117. package/src/commands/marketplace-install.test.ts +0 -543
  118. package/src/commands/marketplace-security.test.ts +0 -646
  119. package/src/commands/mcp-registration.test.ts +0 -2787
  120. package/src/commands/mcp-registration.ts +0 -2612
  121. package/src/commands/mcp-status.test.ts +0 -483
  122. package/src/commands/mcp-status.ts +0 -575
  123. package/src/commands/mcp-status.us011.test.ts +0 -243
  124. package/src/commands/meetings.test.ts +0 -522
  125. package/src/commands/meetings.ts +0 -789
  126. package/src/commands/members.test.ts +0 -1474
  127. package/src/commands/members.ts +0 -1181
  128. package/src/commands/onboard-identity-guard.test.ts +0 -99
  129. package/src/commands/onboard-identity-guard.ts +0 -103
  130. package/src/commands/onboard-join.test.ts +0 -96
  131. package/src/commands/onboard-join.ts +0 -101
  132. package/src/commands/onboard-warning.test.ts +0 -26
  133. package/src/commands/onboard-warning.ts +0 -12
  134. package/src/commands/onboard.ts +0 -267
  135. package/src/commands/outposts-heartbeat.test.ts +0 -299
  136. package/src/commands/outposts-heartbeat.ts +0 -310
  137. package/src/commands/outposts-replica-sync.test.ts +0 -272
  138. package/src/commands/outposts-self-deploy.test.ts +0 -243
  139. package/src/commands/outposts.test.ts +0 -1039
  140. package/src/commands/outposts.ts +0 -1935
  141. package/src/commands/pack-install-secret-authorization.test.ts +0 -115
  142. package/src/commands/pack-install.test.ts +0 -1469
  143. package/src/commands/pack-install.ts +0 -2247
  144. package/src/commands/pack-update-cache.test.ts +0 -149
  145. package/src/commands/packs.test.ts +0 -88
  146. package/src/commands/packs.ts +0 -622
  147. package/src/commands/people.test.ts +0 -807
  148. package/src/commands/people.ts +0 -422
  149. package/src/commands/pkg-install.dispatch.test.ts +0 -71
  150. package/src/commands/pkg-install.ts +0 -215
  151. package/src/commands/pkg-list.test.ts +0 -79
  152. package/src/commands/pkg-list.ts +0 -13
  153. package/src/commands/pkg-remove.ts +0 -71
  154. package/src/commands/pkg-update.ts +0 -189
  155. package/src/commands/publish.test.ts +0 -650
  156. package/src/commands/publish.ts +0 -580
  157. package/src/commands/reindex.test.ts +0 -259
  158. package/src/commands/reindex.ts +0 -274
  159. package/src/commands/rescue.test.ts +0 -39
  160. package/src/commands/rescue.ts +0 -210
  161. package/src/commands/run.env-local.test.ts +0 -88
  162. package/src/commands/run.test.ts +0 -45
  163. package/src/commands/run.ts +0 -184
  164. package/src/commands/safe-extract.test.ts +0 -459
  165. package/src/commands/safe-extract.ts +0 -444
  166. package/src/commands/secrets-scope.test.ts +0 -56
  167. package/src/commands/secrets-scope.ts +0 -32
  168. package/src/commands/secrets.parse-destination.test.ts +0 -38
  169. package/src/commands/secrets.test.ts +0 -2037
  170. package/src/commands/secrets.ts +0 -2240
  171. package/src/commands/signals.ts +0 -351
  172. package/src/commands/skill.test.ts +0 -770
  173. package/src/commands/skill.ts +0 -796
  174. package/src/commands/sources.ts +0 -362
  175. package/src/commands/sync-mode.test.ts +0 -366
  176. package/src/commands/sync-mode.ts +0 -387
  177. package/src/commands/sync-narrow.test.ts +0 -633
  178. package/src/commands/sync-narrow.ts +0 -555
  179. package/src/commands/sync.ts +0 -165
  180. package/src/commands/team-sync.ts +0 -628
  181. package/src/commands/update.ts +0 -71
  182. package/src/commands/whoami.ts +0 -83
  183. package/src/commands/workers.test.ts +0 -158
  184. package/src/commands/workers.ts +0 -301
  185. package/src/index.test.ts +0 -32
  186. package/src/index.ts +0 -20
  187. package/src/lib/db/control-plane.test.ts +0 -59
  188. package/src/lib/db/control-plane.ts +0 -113
  189. package/src/lib/db/local.test.ts +0 -81
  190. package/src/lib/db/local.ts +0 -148
  191. package/src/lib/db/migrate.test.ts +0 -133
  192. package/src/lib/db/migrate.ts +0 -137
  193. package/src/lib/db/paths.test.ts +0 -112
  194. package/src/lib/db/paths.ts +0 -128
  195. package/src/lib/db/remote-engine.test.ts +0 -44
  196. package/src/lib/db/remote-engine.ts +0 -148
  197. package/src/lib/db/remote-sql.test.ts +0 -32
  198. package/src/lib/db/remote-sql.ts +0 -62
  199. package/src/lib/db/sql.test.ts +0 -106
  200. package/src/lib/db/sql.ts +0 -192
  201. package/src/lib/hq-cloud-dep.smoke.test.ts +0 -75
  202. package/src/lib/local-tree-diff.test.ts +0 -301
  203. package/src/lib/local-tree-diff.ts +0 -362
  204. package/src/lib/narrow-hint-banner.test.ts +0 -235
  205. package/src/lib/narrow-hint-banner.ts +0 -212
  206. package/src/lib/plan-limit-nag.test.ts +0 -317
  207. package/src/lib/plan-limit-nag.ts +0 -264
  208. package/src/main.ts +0 -371
  209. package/src/node-preflight.test.ts +0 -60
  210. package/src/node-preflight.ts +0 -67
  211. package/src/outpost/session-heartbeat-bounds.test.ts +0 -195
  212. package/src/outpost/session-heartbeat-guard.test.ts +0 -105
  213. package/src/outpost/session-heartbeat-publisher.test.ts +0 -178
  214. package/src/outpost/session-heartbeat-publisher.ts +0 -186
  215. package/src/outpost/session-heartbeat-retain-guard.test.ts +0 -126
  216. package/src/outpost/session-heartbeat.test.ts +0 -459
  217. package/src/outpost/session-heartbeat.ts +0 -877
  218. package/src/packaging.test.ts +0 -109
  219. package/src/run/__fixtures__/discover-schemas/example.env.schema +0 -4
  220. package/src/run/discover-schemas.test.ts +0 -153
  221. package/src/run/discover-schemas.ts +0 -79
  222. package/src/run/hq-plugin.test.ts +0 -371
  223. package/src/run/hq-plugin.ts +0 -277
  224. package/src/run/varlock-shape.test.ts +0 -57
  225. package/src/schemas/hq-package.schema.json +0 -155
  226. package/src/sentry-before-send.test.ts +0 -359
  227. package/src/sentry-before-send.ts +0 -221
  228. package/src/sentry-epipe.test.ts +0 -37
  229. package/src/sentry-release.test.ts +0 -54
  230. package/src/sentry.test.ts +0 -24
  231. package/src/sentry.ts +0 -54
  232. package/src/strategies/link.ts +0 -62
  233. package/src/strategies/merge.ts +0 -142
  234. package/src/types.ts +0 -146
  235. package/src/utils/__fixtures__/scan-packages.generated-block.sh +0 -23
  236. package/src/utils/auth-error.test.ts +0 -40
  237. package/src/utils/auth-error.ts +0 -42
  238. package/src/utils/billing-gate.test.ts +0 -95
  239. package/src/utils/billing-gate.ts +0 -228
  240. package/src/utils/breadcrumb-buffer.ts +0 -18
  241. package/src/utils/cli-telemetry.test.ts +0 -153
  242. package/src/utils/cli-telemetry.ts +0 -61
  243. package/src/utils/cognito-session.machine.test.ts +0 -109
  244. package/src/utils/cognito-session.refresh.test.ts +0 -84
  245. package/src/utils/cognito-session.test.ts +0 -328
  246. package/src/utils/cognito-session.ts +0 -448
  247. package/src/utils/company-selection-error.test.ts +0 -42
  248. package/src/utils/company-selection-error.ts +0 -45
  249. package/src/utils/contribution-table.ts +0 -83
  250. package/src/utils/environmental-error.test.ts +0 -45
  251. package/src/utils/environmental-error.ts +0 -39
  252. package/src/utils/epipe.test.ts +0 -28
  253. package/src/utils/epipe.ts +0 -29
  254. package/src/utils/expected-cli-error.test.ts +0 -28
  255. package/src/utils/expected-cli-error.ts +0 -39
  256. package/src/utils/feedback-diagnostics.test.ts +0 -183
  257. package/src/utils/feedback-diagnostics.ts +0 -123
  258. package/src/utils/feedback-screenshots.test.ts +0 -134
  259. package/src/utils/feedback-screenshots.ts +0 -124
  260. package/src/utils/feedback-versions.test.ts +0 -98
  261. package/src/utils/feedback-versions.ts +0 -68
  262. package/src/utils/git.ts +0 -74
  263. package/src/utils/integrity.ts +0 -59
  264. package/src/utils/intercepted-process-exit.test.ts +0 -37
  265. package/src/utils/intercepted-process-exit.ts +0 -36
  266. package/src/utils/login-provider.test.ts +0 -42
  267. package/src/utils/login-provider.ts +0 -30
  268. package/src/utils/manifest.test.ts +0 -167
  269. package/src/utils/manifest.ts +0 -131
  270. package/src/utils/pack-contributions.test.ts +0 -603
  271. package/src/utils/pack-contributions.ts +0 -450
  272. package/src/utils/people.ts +0 -215
  273. package/src/utils/registry-client.ts +0 -204
  274. package/src/utils/registry.ts +0 -90
  275. package/src/utils/resolve-vault-credential.test.ts +0 -69
  276. package/src/utils/resolve-vault-credential.ts +0 -60
  277. package/src/utils/sandbox-runner-client.test.ts +0 -279
  278. package/src/utils/sandbox-runner-client.ts +0 -260
  279. package/src/utils/secrets-cache.ts +0 -183
  280. package/src/utils/sentry-identity.ts +0 -45
  281. package/src/utils/settle-with-timeout.test.ts +0 -21
  282. package/src/utils/settle-with-timeout.ts +0 -22
  283. package/src/utils/user-yaml-error.test.ts +0 -24
  284. package/src/utils/user-yaml-error.ts +0 -30
  285. package/src/utils/vault-api.test.ts +0 -536
  286. package/src/utils/vault-api.ts +0 -382
  287. package/src/utils/version-check.test.ts +0 -176
  288. package/src/utils/version-check.ts +0 -155
  289. package/src/utils/version-gate.test.ts +0 -1024
  290. package/src/utils/version-gate.ts +0 -702
  291. package/test/commands/db-tenant-isolation.test.ts +0 -94
  292. package/test/commands/db.test.ts +0 -85
  293. package/test/commands/signals.test.ts +0 -207
  294. package/test/commands/sources.test.ts +0 -231
  295. package/test/e2e/smoke-install-mcp.sh +0 -113
  296. package/test/fixtures/hq-pack-smoke-mcp/mcp/smoke-http.json +0 -1
  297. package/test/fixtures/hq-pack-smoke-mcp/package.yaml +0 -11
  298. package/test/fixtures/signals/action_item/sample.md +0 -16
  299. package/test/fixtures/signals/summary/sample.md +0 -12
  300. package/test/fixtures/sources/meetings/sample.md +0 -25
  301. package/test/helpers/cli-runner.ts +0 -150
  302. package/test/helpers/s3-list-mock.ts +0 -79
  303. package/test/helpers/vault-service-mock.ts +0 -295
  304. package/test/sources-signals/smoke.test.ts +0 -228
  305. package/tsconfig.json +0 -20
  306. package/vitest.config.ts +0 -11
  307. package/vitest.e2e.config.ts +0 -7
@@ -1,789 +0,0 @@
1
- import { Command } from "commander";
2
- import chalk from "chalk";
3
- import { ensureCognitoToken } from "../utils/cognito-session.js";
4
- import { vaultApiFetch, getCompanyUid } from "../utils/vault-api.js";
5
-
6
- interface MeetingListItem {
7
- meetingId: string;
8
- sourceShape?: "markdown" | "json";
9
- title?: string | null;
10
- startTime?: string;
11
- endTime?: string;
12
- duration?: number;
13
- participantCount?: number;
14
- status?: string;
15
- hasTranscript?: boolean;
16
- hasNotes?: boolean;
17
- channel?: string;
18
- ingested_at?: string;
19
- hasSignals?: boolean;
20
- companyId?: string;
21
- attributed?: boolean;
22
- }
23
-
24
- interface MeetingDetail {
25
- meetingId: string;
26
- sourceShape?: "markdown" | "json";
27
- title?: string;
28
- startTime?: string;
29
- endTime?: string;
30
- duration?: number;
31
- participants?: Array<{ email: string; name: string | null; role: string }>;
32
- calendarEventId?: string | null;
33
- botProvider?: string;
34
- sourceApp?: string;
35
- companyId?: string;
36
- status?: string;
37
- recallBotId?: string | null;
38
- isShared?: boolean;
39
- createdAt?: string;
40
- updatedAt?: string;
41
- documentUrl?: string;
42
- hasTranscript?: boolean;
43
- hasNotes?: boolean;
44
- source?: MarkdownMeetingSource;
45
- signals?: Record<string, unknown>;
46
- }
47
-
48
- interface MarkdownMeetingFrontmatter {
49
- title?: string;
50
- channel?: string;
51
- origin?: string;
52
- company_id?: string;
53
- meeting_url?: string;
54
- meeting_platform?: string;
55
- calendar_event_id?: string | null;
56
- scheduled_start_time?: string;
57
- created_at?: string;
58
- updated_at?: string;
59
- ingested_at?: string;
60
- recall_bot_id?: string | null;
61
- bot_status?: string;
62
- auto_scheduled?: boolean;
63
- }
64
-
65
- interface MarkdownMeetingSource {
66
- path?: string;
67
- presigned_url?: string;
68
- frontmatter?: MarkdownMeetingFrontmatter;
69
- }
70
-
71
- interface TranscriptSegment {
72
- speaker: string;
73
- text: string;
74
- startTime: number;
75
- endTime: number;
76
- }
77
-
78
- interface MeetingNotes {
79
- summary: string;
80
- keyPoints: string[];
81
- decisions: string[];
82
- actionItems: Array<{ task: string; assignee: string | null }>;
83
- participantContributions: Array<{
84
- name: string;
85
- speakingTimePercent: number;
86
- topicsSummary: string;
87
- }>;
88
- model: string;
89
- generatedAt: string;
90
- }
91
-
92
- interface MeetingDocument {
93
- meetingId: string;
94
- title: string;
95
- startTime: string;
96
- endTime: string;
97
- duration: number;
98
- participants: Array<{ email: string; name: string | null; role: string }>;
99
- status: string;
100
- transcript: TranscriptSegment[] | null;
101
- notes: MeetingNotes | null;
102
- }
103
-
104
- interface MeetingBotInviteResponse {
105
- botId?: string;
106
- meetingUrl?: string;
107
- platform?: string;
108
- status?: string;
109
- }
110
-
111
- function formatDuration(seconds: number): string {
112
- const h = Math.floor(seconds / 3600);
113
- const m = Math.floor((seconds % 3600) / 60);
114
- const s = Math.floor(seconds % 60);
115
- if (h > 0) return `${h}h ${m}m`;
116
- if (m > 0) return `${m}m ${s}s`;
117
- return `${s}s`;
118
- }
119
-
120
- function safeFormatDuration(seconds: unknown): string {
121
- return typeof seconds === "number" && Number.isFinite(seconds) ? formatDuration(seconds) : "-";
122
- }
123
-
124
- function safeFormatDate(iso: unknown, options?: Intl.DateTimeFormatOptions): string {
125
- if (typeof iso !== "string" || iso.length === 0) return "-";
126
- const date = new Date(iso);
127
- if (Number.isNaN(date.getTime())) return "-";
128
- return options ? date.toLocaleString("en-US", options) : date.toLocaleString();
129
- }
130
-
131
- function formatTimestamp(ts: number): string {
132
- const m = Math.floor(ts / 60);
133
- const s = Math.floor(ts % 60);
134
- return `${String(m).padStart(2, "0")}:${String(s).padStart(2, "0")}`;
135
- }
136
-
137
- function statusBadge(status: string): string {
138
- switch (status) {
139
- case "completed":
140
- return chalk.green(status);
141
- case "recording":
142
- return chalk.red(status);
143
- case "processing":
144
- return chalk.yellow(status);
145
- case "failed":
146
- return chalk.red(status);
147
- default:
148
- return chalk.dim(status);
149
- }
150
- }
151
-
152
- function isMarkdownShape(x: unknown): x is MeetingDetail & {
153
- source: MarkdownMeetingSource;
154
- } {
155
- if (!x || typeof x !== "object") return false;
156
- const candidate = x as {
157
- sourceShape?: string;
158
- source?: { frontmatter?: unknown };
159
- };
160
- return candidate.sourceShape === "markdown" || Boolean(candidate.source?.frontmatter);
161
- }
162
-
163
- function hasSignals(signals: unknown): signals is Record<string, unknown> {
164
- return Boolean(
165
- signals &&
166
- typeof signals === "object" &&
167
- !Array.isArray(signals) &&
168
- Object.keys(signals).length > 0,
169
- );
170
- }
171
-
172
- function renderSignals(signals: Record<string, unknown>): void {
173
- console.log(chalk.bold("Signals"));
174
- for (const [key, value] of Object.entries(signals)) {
175
- if (value === null || value === undefined) {
176
- console.log(` ${key}: -`);
177
- } else if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
178
- console.log(` ${key}: ${String(value)}`);
179
- } else {
180
- const rendered = JSON.stringify(value, null, 2)
181
- .split("\n")
182
- .map((line) => ` ${line}`)
183
- .join("\n");
184
- console.log(` ${key}:`);
185
- console.log(rendered);
186
- }
187
- }
188
- console.log();
189
- }
190
-
191
- async function resolveShortId(
192
- token: string,
193
- prefix: string,
194
- query: Record<string, string>,
195
- ): Promise<string> {
196
- if (prefix.includes("-") && prefix.length > 8) return prefix;
197
- const res = await vaultApiFetch({
198
- token,
199
- path: "/v1/meetings",
200
- query: { ...query, limit: "500" },
201
- });
202
- if (!res.ok) {
203
- throw new Error(
204
- `Could not resolve meeting ID "${prefix}" — failed to list meetings (${res.status}). Pass the full meeting id.`,
205
- );
206
- }
207
- const data = (await res.json()) as { meetings: MeetingListItem[] };
208
- const matches = data.meetings.filter((m) => m.meetingId.startsWith(prefix));
209
- if (matches.length === 1) return matches[0].meetingId;
210
- if (matches.length > 1) {
211
- console.error(chalk.red(`Ambiguous ID prefix "${prefix}" — matches ${matches.length} meetings. Use a longer prefix.`));
212
- process.exit(1);
213
- }
214
- console.error(
215
- chalk.red(
216
- `No meeting matches ID "${prefix}". It may be older than the meetings shown by \`hq meetings list\`, still processing, or attributed to a different company. Pass the full meeting id, add --company <slug>, or widen the list with \`hq meetings list --limit <n>\`.`,
217
- ),
218
- );
219
- process.exit(1);
220
- }
221
-
222
- async function handleApiError(res: Response): Promise<never> {
223
- const body = (await res.json().catch(() => ({}))) as Record<string, string>;
224
- if (res.status === 401) {
225
- console.error(chalk.red("Not authenticated — run `hq login` first"));
226
- } else if (res.status === 403) {
227
- console.error(chalk.red(body.error ?? "Not authorized"));
228
- } else if (res.status === 404) {
229
- console.error(chalk.red(body.error ?? "Not found"));
230
- } else {
231
- console.error(chalk.red(`API error (${res.status}): ${body.error ?? res.statusText}`));
232
- }
233
- process.exit(1);
234
- }
235
-
236
- function printMeetingTable(meetings: MeetingListItem[]): void {
237
- if (meetings.length === 0) {
238
- console.log(chalk.dim(" No meetings found."));
239
- return;
240
- }
241
-
242
- // Titles can come back null/undefined from the API even though the type says
243
- // string; fall back to a placeholder so width calc + rendering never crash on
244
- // `undefined.length`.
245
- const displayTitle = (m: MeetingListItem): string => m.title ?? "(untitled)";
246
-
247
- const ID_W = 8;
248
- const TITLE_W = Math.min(40, Math.max(10, ...meetings.map((m) => displayTitle(m).length)));
249
- const DATE_W = 16;
250
- const DUR_W = 8;
251
- const STATUS_W = 12;
252
- const PARTS_W = 6;
253
- const FLAGS_W = 5;
254
-
255
- console.log(
256
- chalk.bold(
257
- [
258
- "ID".padEnd(ID_W),
259
- "TITLE".padEnd(TITLE_W),
260
- "DATE".padEnd(DATE_W),
261
- "DUR".padEnd(DUR_W),
262
- "STATUS".padEnd(STATUS_W),
263
- "PARTS".padEnd(PARTS_W),
264
- "FLAGS",
265
- ].join(" "),
266
- ),
267
- );
268
-
269
- for (const m of meetings) {
270
- const id = m.meetingId.slice(0, 8);
271
- const fullTitle = displayTitle(m);
272
- const title = fullTitle.length > TITLE_W ? fullTitle.slice(0, TITLE_W - 1) + "…" : fullTitle;
273
- const date = safeFormatDate(m.startTime, {
274
- month: "short",
275
- day: "numeric",
276
- hour: "2-digit",
277
- minute: "2-digit",
278
- });
279
- const dur = safeFormatDuration(m.duration);
280
- const status = m.status ? statusBadge(m.status) : chalk.dim("-");
281
- const parts = typeof m.participantCount === "number" ? String(m.participantCount) : "-";
282
- const flags = [
283
- m.hasTranscript ? "T" : "",
284
- m.hasNotes ? "N" : "",
285
- m.hasSignals ? "S" : "",
286
- ].filter(Boolean).join("") || "-";
287
-
288
- console.log(
289
- [
290
- chalk.cyan(id.padEnd(ID_W)),
291
- title.padEnd(TITLE_W),
292
- chalk.dim(date.padEnd(DATE_W)),
293
- dur.padEnd(DUR_W),
294
- status.padEnd(STATUS_W + 10), // chalk adds escape chars
295
- parts.padEnd(PARTS_W),
296
- flags.padEnd(FLAGS_W),
297
- ].join(" "),
298
- );
299
- }
300
- }
301
-
302
- export function registerMeetingsCommand(program: Command): void {
303
- const meetings = program
304
- .command("meetings")
305
- .description("View and search meeting recordings, transcripts, and notes")
306
- .option("--company <slug>", "Company slug (for multi-company users)")
307
- .option("--json", "Output raw JSON instead of formatted text");
308
-
309
- // ── hq meetings list ──────────────────────────────────────────────
310
-
311
- meetings
312
- .command("list")
313
- .description("List recorded meetings (newest first)")
314
- .option("--limit <n>", "Number of meetings to return (default: 20)")
315
- .option("--next <token>", "Pagination token from a previous response")
316
- .action(async (opts: { limit?: string; next?: string }) => {
317
- try {
318
- const token = await ensureCognitoToken();
319
- const query: Record<string, string> = {};
320
- const companySlug = meetings.opts().company as string | undefined;
321
-
322
- if (opts.limit) query.limit = opts.limit;
323
- if (opts.next) query.nextToken = opts.next;
324
- if (companySlug) query.companyId = await getCompanyUid(token, companySlug);
325
-
326
- const res = await vaultApiFetch({ token, path: "/v1/meetings", query });
327
- if (!res.ok) await handleApiError(res);
328
-
329
- const data = (await res.json()) as {
330
- meetings: MeetingListItem[];
331
- nextToken?: string;
332
- };
333
-
334
- if (meetings.opts().json) {
335
- console.log(JSON.stringify(data, null, 2));
336
- return;
337
- }
338
-
339
- console.log(chalk.bold(`\nMeetings (${data.meetings.length}):\n`));
340
- printMeetingTable(data.meetings);
341
-
342
- if (data.nextToken) {
343
- console.log(
344
- chalk.dim(`\n More results available. Run with --next ${data.nextToken}`),
345
- );
346
- }
347
- console.log();
348
- } catch (err) {
349
- console.error(chalk.red("Error:"), err instanceof Error ? err.message : String(err));
350
- process.exit(1);
351
- }
352
- });
353
-
354
- // ── hq meetings invite <meeting-url> ──────────────────────────────
355
-
356
- meetings
357
- .command("invite <meetingUrl>")
358
- .description("Invite the meeting bot to a Google Meet, Zoom, or Teams URL")
359
- .action(async (meetingUrl: string) => {
360
- try {
361
- const token = await ensureCognitoToken();
362
- const companySlug = meetings.opts().company as string | undefined;
363
- const query: Record<string, string> = {};
364
- if (companySlug) query.companyId = await getCompanyUid(token, companySlug);
365
-
366
- const res = await vaultApiFetch({
367
- token,
368
- method: "POST",
369
- path: "/v1/bot/invite",
370
- query,
371
- body: { meetingUrl },
372
- });
373
- if (!res.ok) await handleApiError(res);
374
- const data = (await res.json()) as MeetingBotInviteResponse;
375
-
376
- if (meetings.opts().json) {
377
- console.log(JSON.stringify(data, null, 2));
378
- return;
379
- }
380
-
381
- console.log(chalk.green(`\n✓ Meeting bot invited to ${chalk.cyan(data.meetingUrl ?? meetingUrl)}.`));
382
- if (data.botId) console.log(chalk.dim(` Bot: ${data.botId}`));
383
- if (data.status) console.log(chalk.dim(` Status: ${data.status}`));
384
- console.log();
385
- } catch (err) {
386
- console.error(chalk.red("Error:"), err instanceof Error ? err.message : String(err));
387
- process.exit(1);
388
- }
389
- });
390
-
391
- // ── hq meetings get <id> ──────────────────────────────────────────
392
-
393
- meetings
394
- .command("get <meetingId>")
395
- .description("Show meeting details")
396
- .action(async (rawId: string) => {
397
- try {
398
- const token = await ensureCognitoToken();
399
- const query: Record<string, string> = {};
400
- const companySlug = meetings.opts().company as string | undefined;
401
- if (companySlug) query.companyId = await getCompanyUid(token, companySlug);
402
-
403
- const meetingId = await resolveShortId(token, rawId, query);
404
- const res = await vaultApiFetch({
405
- token,
406
- path: `/v1/meetings/${encodeURIComponent(meetingId)}`,
407
- query,
408
- });
409
- if (!res.ok) await handleApiError(res);
410
-
411
- const detail = (await res.json()) as MeetingDetail;
412
-
413
- if (meetings.opts().json) {
414
- console.log(JSON.stringify(detail, null, 2));
415
- return;
416
- }
417
-
418
- if (isMarkdownShape(detail)) {
419
- const fm = detail.source.frontmatter ?? {};
420
- console.log(chalk.bold(`\n${fm.title || "(untitled)"}\n`));
421
- console.log(` ID: ${chalk.cyan(detail.meetingId)}`);
422
- console.log(` Status: ${fm.bot_status || "-"}`);
423
- console.log(` Date: ${safeFormatDate(fm.scheduled_start_time || fm.created_at)}`);
424
- console.log(` Platform: ${fm.meeting_platform || "-"}`);
425
- console.log(` Origin: ${fm.origin || "-"}`);
426
- console.log(` Company: ${fm.company_id || "-"}`);
427
- if (fm.meeting_url) console.log(` Meeting URL: ${fm.meeting_url}`);
428
- if (hasSignals(detail.signals)) {
429
- console.log(` Signals: ${Object.keys(detail.signals).length}`);
430
- }
431
- console.log(
432
- chalk.dim(
433
- `\n This meeting is stored as a markdown document. Use \`hq meetings transcript ${detail.meetingId.slice(0, 8)}\` to view the full document.`,
434
- ),
435
- );
436
- console.log();
437
- return;
438
- }
439
-
440
- console.log(chalk.bold(`\n${detail.title ?? "(untitled)"}\n`));
441
- console.log(` ID: ${chalk.cyan(detail.meetingId)}`);
442
- console.log(` Status: ${detail.status ? statusBadge(detail.status) : chalk.dim("-")}`);
443
- console.log(` Date: ${safeFormatDate(detail.startTime)}`);
444
- console.log(` Duration: ${safeFormatDuration(detail.duration)}`);
445
- console.log(` Source: ${detail.sourceApp ?? "-"} (${detail.botProvider ?? "-"})`);
446
- console.log(` Shared: ${detail.isShared ? "yes" : "no"}`);
447
-
448
- if ((detail.participants?.length ?? 0) > 0) {
449
- console.log(chalk.bold("\n Participants:"));
450
- for (const p of detail.participants ?? []) {
451
- const name = p.name ?? p.email;
452
- const role = p.role === "organizer" ? chalk.yellow(" (organizer)") : "";
453
- console.log(` - ${name}${role}`);
454
- }
455
- }
456
-
457
- const flags = [];
458
- if (detail.hasTranscript) flags.push("transcript");
459
- if (detail.hasNotes) flags.push("notes");
460
- if (flags.length > 0) {
461
- console.log(
462
- chalk.dim(`\n Available: ${flags.join(", ")}. Use \`hq meetings transcript ${detail.meetingId.slice(0, 8)}\` or \`hq meetings notes ${detail.meetingId.slice(0, 8)}\`.`),
463
- );
464
- }
465
- console.log();
466
- } catch (err) {
467
- console.error(chalk.red("Error:"), err instanceof Error ? err.message : String(err));
468
- process.exit(1);
469
- }
470
- });
471
-
472
- // ── hq meetings set-company <id> ──────────────────────────────────
473
-
474
- meetings
475
- .command("set-company <meetingId>")
476
- .description("Set or change the company a meeting is attributed to (use 'unknown' to clear)")
477
- .option("--company <slug>", "Target company slug, or 'unknown'/'personal' to clear attribution")
478
- .option("--no-series", "Apply only to this occurrence, not the whole recurring series")
479
- .action(async (rawId: string, cmdOpts: { company?: string; series?: boolean }) => {
480
- try {
481
- const token = await ensureCognitoToken();
482
- // `--company` is shared with the parent `meetings` command, so commander
483
- // may bind it to either level depending on position — accept both.
484
- const target = cmdOpts.company ?? (meetings.opts().company as string | undefined);
485
- if (!target) {
486
- console.error(
487
- chalk.red("Error:"),
488
- "a target company is required: --company <slug> (or 'unknown'/'personal' to clear)",
489
- );
490
- process.exit(1);
491
- }
492
-
493
- // The bot record is person-keyed, so no company scope is needed to
494
- // resolve the meeting id; pass an empty scope.
495
- const meetingId = await resolveShortId(token, rawId, {});
496
-
497
- const lc = target.toLowerCase();
498
- const companyId =
499
- lc === "unknown" || lc === "personal"
500
- ? "unknown"
501
- : await getCompanyUid(token, target);
502
-
503
- const applyToSeries = cmdOpts.series !== false;
504
-
505
- const res = await vaultApiFetch({
506
- token,
507
- method: "POST",
508
- path: `/v1/meetings/${encodeURIComponent(meetingId)}/company`,
509
- body: { companyId, applyToSeries },
510
- });
511
- if (!res.ok) await handleApiError(res);
512
- const data = (await res.json()) as {
513
- appliedToSeries?: boolean;
514
- occurrencesUpdated?: number;
515
- refiled?: boolean;
516
- refiledCount?: number;
517
- [key: string]: unknown;
518
- };
519
-
520
- if (meetings.opts().json) {
521
- console.log(JSON.stringify(data, null, 2));
522
- return;
523
- }
524
-
525
- const where = companyId === "unknown" ? "unattributed (personal)" : companyId;
526
- console.log(chalk.green(`\n✓ Meeting ${chalk.cyan(meetingId)} attributed to ${chalk.bold(where)}.`));
527
- if (typeof data.occurrencesUpdated === "number" && data.occurrencesUpdated > 1) {
528
- console.log(chalk.dim(` Applied to ${data.occurrencesUpdated} meetings in this recurring series (including past occurrences).`));
529
- } else if (data.appliedToSeries) {
530
- console.log(chalk.dim(" Future occurrences of this recurring series will inherit this attribution."));
531
- }
532
- if (typeof data.refiledCount === "number" && data.refiledCount > 0) {
533
- console.log(chalk.dim(` Refiled ${data.refiledCount} transcript${data.refiledCount === 1 ? "" : "s"} into the new company vault.`));
534
- }
535
- console.log();
536
- } catch (err) {
537
- console.error(chalk.red("Error:"), err instanceof Error ? err.message : String(err));
538
- process.exit(1);
539
- }
540
- });
541
-
542
- // ── hq meetings search <query> ─────────────────────────────────────
543
-
544
- meetings
545
- .command("search <query>")
546
- .description("Search meetings by title or participant name")
547
- .action(async (query: string) => {
548
- try {
549
- const token = await ensureCognitoToken();
550
- const params: Record<string, string> = { q: query };
551
- const companySlug = meetings.opts().company as string | undefined;
552
- if (companySlug) params.companyId = await getCompanyUid(token, companySlug);
553
-
554
- const res = await vaultApiFetch({
555
- token,
556
- path: "/v1/meetings/search",
557
- query: params,
558
- });
559
- if (!res.ok) await handleApiError(res);
560
-
561
- const data = (await res.json()) as {
562
- results: MeetingListItem[];
563
- query: string;
564
- };
565
-
566
- if (meetings.opts().json) {
567
- console.log(JSON.stringify(data, null, 2));
568
- return;
569
- }
570
-
571
- console.log(chalk.bold(`\nSearch results for "${data.query}" (${data.results.length}):\n`));
572
- printMeetingTable(data.results);
573
- console.log();
574
- } catch (err) {
575
- console.error(chalk.red("Error:"), err instanceof Error ? err.message : String(err));
576
- process.exit(1);
577
- }
578
- });
579
-
580
- // ── hq meetings transcript <id> ────────────────────────────────────
581
-
582
- meetings
583
- .command("transcript <meetingId>")
584
- .description("Print the meeting transcript")
585
- .action(async (rawId: string) => {
586
- try {
587
- const token = await ensureCognitoToken();
588
- const query: Record<string, string> = {};
589
- const companySlug = meetings.opts().company as string | undefined;
590
- if (companySlug) query.companyId = await getCompanyUid(token, companySlug);
591
-
592
- const meetingId = await resolveShortId(token, rawId, query);
593
- const res = await vaultApiFetch({
594
- token,
595
- path: `/v1/meetings/${encodeURIComponent(meetingId)}`,
596
- query,
597
- });
598
- if (!res.ok) await handleApiError(res);
599
-
600
- const detail = (await res.json()) as MeetingDetail;
601
-
602
- if (isMarkdownShape(detail)) {
603
- const documentUrl = detail.source.presigned_url;
604
- if (!documentUrl) {
605
- console.error(chalk.red("No document available for this meeting."));
606
- process.exit(1);
607
- }
608
-
609
- const docRes = await fetch(documentUrl);
610
- if (!docRes.ok) {
611
- console.error(chalk.red(`Failed to download meeting document (${docRes.status})`));
612
- process.exit(1);
613
- }
614
-
615
- const markdown = await docRes.text();
616
-
617
- if (meetings.opts().json) {
618
- console.log(JSON.stringify({ meetingId: detail.meetingId, sourceShape: "markdown", markdown }, null, 2));
619
- return;
620
- }
621
-
622
- console.log(chalk.bold(`\nTranscript: ${detail.source.frontmatter?.title || "(untitled)"}\n`));
623
- console.log(markdown);
624
- return;
625
- }
626
-
627
- if (!detail.documentUrl) {
628
- console.error(chalk.red("No document URL available for this meeting."));
629
- process.exit(1);
630
- }
631
-
632
- const docRes = await fetch(detail.documentUrl);
633
- if (!docRes.ok) {
634
- console.error(chalk.red(`Failed to download meeting document (${docRes.status})`));
635
- process.exit(1);
636
- }
637
-
638
- const doc = (await docRes.json()) as MeetingDocument;
639
-
640
- if (meetings.opts().json) {
641
- console.log(JSON.stringify(doc.transcript, null, 2));
642
- return;
643
- }
644
-
645
- if (!doc.transcript || doc.transcript.length === 0) {
646
- console.log(chalk.yellow("No transcript available for this meeting."));
647
- return;
648
- }
649
-
650
- console.log(chalk.bold(`\nTranscript: ${doc.title}\n`));
651
- for (const seg of doc.transcript) {
652
- const time = formatTimestamp(seg.startTime);
653
- console.log(`${chalk.dim(time)} ${chalk.cyan(seg.speaker)}`);
654
- console.log(` ${seg.text}\n`);
655
- }
656
- } catch (err) {
657
- console.error(chalk.red("Error:"), err instanceof Error ? err.message : String(err));
658
- process.exit(1);
659
- }
660
- });
661
-
662
- // ── hq meetings notes <id> ─────────────────────────────────────────
663
-
664
- meetings
665
- .command("notes <meetingId>")
666
- .description("Print AI-generated meeting notes")
667
- .action(async (rawId: string) => {
668
- try {
669
- const token = await ensureCognitoToken();
670
- const query: Record<string, string> = {};
671
- const companySlug = meetings.opts().company as string | undefined;
672
- if (companySlug) query.companyId = await getCompanyUid(token, companySlug);
673
-
674
- const meetingId = await resolveShortId(token, rawId, query);
675
- const res = await vaultApiFetch({
676
- token,
677
- path: `/v1/meetings/${encodeURIComponent(meetingId)}`,
678
- query,
679
- });
680
- if (!res.ok) await handleApiError(res);
681
-
682
- const detail = (await res.json()) as MeetingDetail;
683
-
684
- if (isMarkdownShape(detail)) {
685
- if (hasSignals(detail.signals)) {
686
- if (meetings.opts().json) {
687
- console.log(JSON.stringify(detail.signals, null, 2));
688
- return;
689
- }
690
- console.log(chalk.bold(`\nMeeting Notes: ${detail.source.frontmatter?.title || "(untitled)"}\n`));
691
- renderSignals(detail.signals);
692
- return;
693
- }
694
-
695
- const documentUrl = detail.source.presigned_url;
696
- if (!documentUrl) {
697
- console.log(chalk.yellow("No notes available for this meeting."));
698
- return;
699
- }
700
-
701
- const docRes = await fetch(documentUrl);
702
- if (!docRes.ok) {
703
- console.error(chalk.red(`Failed to download meeting document (${docRes.status})`));
704
- process.exit(1);
705
- }
706
-
707
- const markdown = await docRes.text();
708
-
709
- if (meetings.opts().json) {
710
- console.log(JSON.stringify({ meetingId: detail.meetingId, sourceShape: "markdown", markdown }, null, 2));
711
- return;
712
- }
713
-
714
- console.log(chalk.bold(`\nMeeting Notes: ${detail.source.frontmatter?.title || "(untitled)"}\n`));
715
- console.log(markdown);
716
- return;
717
- }
718
-
719
- if (!detail.documentUrl) {
720
- console.error(chalk.red("No document URL available for this meeting."));
721
- process.exit(1);
722
- }
723
-
724
- const docRes = await fetch(detail.documentUrl);
725
- if (!docRes.ok) {
726
- console.error(chalk.red(`Failed to download meeting document (${docRes.status})`));
727
- process.exit(1);
728
- }
729
-
730
- const doc = (await docRes.json()) as MeetingDocument;
731
-
732
- if (meetings.opts().json) {
733
- console.log(JSON.stringify(doc.notes, null, 2));
734
- return;
735
- }
736
-
737
- if (!doc.notes) {
738
- console.log(chalk.yellow("No notes available for this meeting."));
739
- return;
740
- }
741
-
742
- const notes = doc.notes;
743
- console.log(chalk.bold(`\nMeeting Notes: ${doc.title}\n`));
744
-
745
- console.log(chalk.bold("Summary"));
746
- console.log(` ${notes.summary}\n`);
747
-
748
- if (notes.keyPoints.length > 0) {
749
- console.log(chalk.bold("Key Points"));
750
- for (const point of notes.keyPoints) {
751
- console.log(` • ${point}`);
752
- }
753
- console.log();
754
- }
755
-
756
- if (notes.decisions.length > 0) {
757
- console.log(chalk.bold("Decisions"));
758
- for (const d of notes.decisions) {
759
- console.log(` ✓ ${d}`);
760
- }
761
- console.log();
762
- }
763
-
764
- if (notes.actionItems.length > 0) {
765
- console.log(chalk.bold("Action Items"));
766
- for (const item of notes.actionItems) {
767
- const assignee = item.assignee ? chalk.dim(` → ${item.assignee}`) : "";
768
- console.log(` □ ${item.task}${assignee}`);
769
- }
770
- console.log();
771
- }
772
-
773
- if (notes.participantContributions.length > 0) {
774
- console.log(chalk.bold("Participant Contributions"));
775
- for (const p of notes.participantContributions) {
776
- console.log(` ${p.name} (${p.speakingTimePercent}%)`);
777
- console.log(` ${chalk.dim(p.topicsSummary)}`);
778
- }
779
- console.log();
780
- }
781
-
782
- console.log(chalk.dim(`Generated by ${notes.model} at ${notes.generatedAt}`));
783
- console.log();
784
- } catch (err) {
785
- console.error(chalk.red("Error:"), err instanceof Error ? err.message : String(err));
786
- process.exit(1);
787
- }
788
- });
789
- }