@raidiant/notifai 10.1.1 → 10.1.3

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 (168) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/dist/commands-core.d.ts +4 -1
  3. package/dist/commands-core.js.map +1 -1
  4. package/dist/commands-doctor.js +2 -7
  5. package/dist/commands-doctor.js.map +1 -1
  6. package/dist/commands-hooks.d.ts +12 -0
  7. package/dist/commands-hooks.js +15 -1
  8. package/dist/commands-hooks.js.map +1 -1
  9. package/dist/commands-init.js +9 -6
  10. package/dist/commands-init.js.map +1 -1
  11. package/dist/commands-send-support.js +10 -11
  12. package/dist/commands-send-support.js.map +1 -1
  13. package/dist/commands-skill.js +72 -54
  14. package/dist/commands-skill.js.map +1 -1
  15. package/dist/harness-session-title.d.ts +22 -0
  16. package/dist/harness-session-title.js +74 -0
  17. package/dist/harness-session-title.js.map +1 -0
  18. package/dist/invocation-context.d.ts +1 -0
  19. package/dist/invocation-context.js +15 -1
  20. package/dist/invocation-context.js.map +1 -1
  21. package/dist/native-skills.d.ts +13 -3
  22. package/dist/native-skills.js +51 -12
  23. package/dist/native-skills.js.map +1 -1
  24. package/dist/node-floor.d.ts +2 -1
  25. package/dist/node-floor.js +9 -5
  26. package/dist/node-floor.js.map +1 -1
  27. package/dist/orca-session-title.d.ts +5 -4
  28. package/dist/orca-session-title.js +32 -19
  29. package/dist/orca-session-title.js.map +1 -1
  30. package/dist/platform.d.ts +11 -17
  31. package/dist/platform.js +20 -23
  32. package/dist/platform.js.map +1 -1
  33. package/dist/release.d.ts +5 -5
  34. package/dist/release.js +5 -5
  35. package/dist/session-labels.d.ts +2 -0
  36. package/dist/session-labels.js +20 -9
  37. package/dist/session-labels.js.map +1 -1
  38. package/dist/setup-destinations.js +1 -1
  39. package/dist/setup-destinations.js.map +1 -1
  40. package/dist/skill-integrity.d.ts +49 -0
  41. package/dist/skill-integrity.js +154 -0
  42. package/dist/skill-integrity.js.map +1 -0
  43. package/dist/skill-source/manifest.json +16 -0
  44. package/dist/skill-source/notifai/SKILL.md +390 -0
  45. package/dist/skill-source/notifai/references/harness-setup.md +220 -0
  46. package/package.json +11 -14
  47. package/src/atomic-file.ts +0 -198
  48. package/src/claude-wake.test.ts +0 -321
  49. package/src/claude-wake.ts +0 -499
  50. package/src/cli-bin.test.ts +0 -176
  51. package/src/cli-bin.ts +0 -233
  52. package/src/cli-release.test.ts +0 -46
  53. package/src/cli-release.ts +0 -78
  54. package/src/cli-update-contract.ts +0 -9
  55. package/src/cli-update.test.ts +0 -125
  56. package/src/client.test.ts +0 -390
  57. package/src/client.ts +0 -352
  58. package/src/codex-wake.test.ts +0 -254
  59. package/src/codex-wake.ts +0 -301
  60. package/src/command-session.ts +0 -38
  61. package/src/commands-agent-sessions.ts +0 -72
  62. package/src/commands-auth.ts +0 -238
  63. package/src/commands-config.ts +0 -336
  64. package/src/commands-core.ts +0 -312
  65. package/src/commands-devices.ts +0 -180
  66. package/src/commands-doctor.ts +0 -1501
  67. package/src/commands-guidance.ts +0 -181
  68. package/src/commands-harness-context.ts +0 -207
  69. package/src/commands-hook-shape.ts +0 -69
  70. package/src/commands-hooks.ts +0 -2318
  71. package/src/commands-init.ts +0 -1055
  72. package/src/commands-io.ts +0 -108
  73. package/src/commands-logs.ts +0 -243
  74. package/src/commands-project.ts +0 -47
  75. package/src/commands-send-support.test.ts +0 -156
  76. package/src/commands-send-support.ts +0 -311
  77. package/src/commands-send.ts +0 -875
  78. package/src/commands-setup-proof.test.ts +0 -72
  79. package/src/commands-setup-proof.ts +0 -124
  80. package/src/commands-skill.test.ts +0 -44
  81. package/src/commands-skill.ts +0 -204
  82. package/src/commands-sounds.test.ts +0 -106
  83. package/src/commands-sounds.ts +0 -49
  84. package/src/commands-update.ts +0 -180
  85. package/src/commands.test.ts +0 -8297
  86. package/src/commands.ts +0 -77
  87. package/src/config-schema.test.ts +0 -153
  88. package/src/config-schema.ts +0 -349
  89. package/src/config.test.ts +0 -581
  90. package/src/config.ts +0 -475
  91. package/src/credentials.test.ts +0 -403
  92. package/src/credentials.ts +0 -403
  93. package/src/file-lock-process-worker.test.ts +0 -64
  94. package/src/file-lock.test.ts +0 -320
  95. package/src/file-lock.ts +0 -393
  96. package/src/fixtures/hermes-0.20.6-classic-cli-local.json +0 -50
  97. package/src/fixtures/openclaw-2026.7.1-2-agent-local.json +0 -57
  98. package/src/generated-session-label.ts +0 -155
  99. package/src/guidance-content.ts +0 -278
  100. package/src/guidance-render.ts +0 -56
  101. package/src/guidance.test.ts +0 -327
  102. package/src/guidance.ts +0 -233
  103. package/src/harness-integration.test.ts +0 -294
  104. package/src/harnesses.test.ts +0 -149
  105. package/src/harnesses.ts +0 -164
  106. package/src/hook-adapter.test.ts +0 -496
  107. package/src/hook-adapter.ts +0 -424
  108. package/src/hook-input.test.ts +0 -39
  109. package/src/hook-input.ts +0 -72
  110. package/src/hooks.test.ts +0 -5824
  111. package/src/hooks.ts +0 -4011
  112. package/src/install-hooks.test.ts +0 -1614
  113. package/src/install-hooks.ts +0 -1501
  114. package/src/interactive.test.ts +0 -387
  115. package/src/interactive.ts +0 -858
  116. package/src/invocation-context.test.ts +0 -352
  117. package/src/invocation-context.ts +0 -197
  118. package/src/logging-process-worker.test.ts +0 -45
  119. package/src/logging.test.ts +0 -544
  120. package/src/logging.ts +0 -698
  121. package/src/main-run.ts +0 -45
  122. package/src/main.ts +0 -12
  123. package/src/native-skills.test.ts +0 -115
  124. package/src/native-skills.ts +0 -162
  125. package/src/node-floor.test.ts +0 -27
  126. package/src/node-floor.ts +0 -37
  127. package/src/onboarding-docs.test.ts +0 -25
  128. package/src/openclaw-plugin.ts +0 -409
  129. package/src/opencode-plugin.ts +0 -298
  130. package/src/orca-session-title.test.ts +0 -54
  131. package/src/orca-session-title.ts +0 -103
  132. package/src/pack-feedback-slice.test.ts +0 -212
  133. package/src/pack-feedback-slice.ts +0 -187
  134. package/src/platform.test.ts +0 -152
  135. package/src/platform.ts +0 -173
  136. package/src/program.test.ts +0 -317
  137. package/src/program.ts +0 -842
  138. package/src/project-enablement.test.ts +0 -55
  139. package/src/project-enablement.ts +0 -99
  140. package/src/question-caps.test.ts +0 -49
  141. package/src/question-settlement-process.ts +0 -47
  142. package/src/question-timing.ts +0 -56
  143. package/src/readiness.test.ts +0 -25
  144. package/src/readiness.ts +0 -212
  145. package/src/release.ts +0 -51
  146. package/src/send-attempts.test.ts +0 -143
  147. package/src/send-attempts.ts +0 -188
  148. package/src/send.test.ts +0 -28
  149. package/src/send.ts +0 -436
  150. package/src/session-activation.ts +0 -61
  151. package/src/session-end-log-lock-worker.test.ts +0 -35
  152. package/src/session-labels.test.ts +0 -490
  153. package/src/session-labels.ts +0 -474
  154. package/src/setup-destinations.test.ts +0 -41
  155. package/src/setup-destinations.ts +0 -50
  156. package/src/skill.test.ts +0 -426
  157. package/src/sound-ref.test.ts +0 -31
  158. package/src/sound-ref.ts +0 -34
  159. package/src/trust-policy.test.ts +0 -701
  160. package/src/ui/banner.ts +0 -95
  161. package/src/ui/config-view.test.ts +0 -90
  162. package/src/ui/config-view.ts +0 -138
  163. package/src/ui/help.test.ts +0 -16
  164. package/src/ui/help.ts +0 -128
  165. package/src/ui/theme.test.ts +0 -92
  166. package/src/ui/theme.ts +0 -265
  167. package/src/url-policy.ts +0 -399
  168. package/tsconfig.json +0 -10
package/src/program.ts DELETED
@@ -1,842 +0,0 @@
1
- import { readFileSync } from 'node:fs'
2
- import { Command } from 'commander'
3
- import {
4
- acknowledgeCommand,
5
- askCommand,
6
- accessStatusCommand,
7
- agentSessionRenameCommand,
8
- authStatusCommand,
9
- capabilitiesCommand,
10
- closeCommand,
11
- cliUpdateCommand,
12
- configExplainCommand,
13
- configSetCommand,
14
- configShowCommand,
15
- configUnsetCommand,
16
- devicesCommand,
17
- doctorCommand,
18
- guidanceSetCommand,
19
- guidanceShowCommand,
20
- guidanceUnsetCommand,
21
- hookDefersDiagnosticsUntilAfterCleanup,
22
- hookRunCommand,
23
- hooksInstallCommand,
24
- hooksUninstallCommand,
25
- initCommand,
26
- loginCommand,
27
- logoutCommand,
28
- projectDisableCommand,
29
- projectEnableCommand,
30
- projectStatusCommand,
31
- logsCommand,
32
- repliesCommand,
33
- reportAskFailure,
34
- sendCommand,
35
- soundsCommand,
36
- statusCommand,
37
- type CommandDeps,
38
- } from './commands.js'
39
- import { packageVersion } from './release.js'
40
- import { HOOK_INSTALLABLE_HARNESSES } from './harnesses.js'
41
- import type { Platform } from '@raidiant/notifai-protocol'
42
- import type { SkillScope } from './native-skills.js'
43
- import { GROUP, SEND_GROUP, helpConfiguration, rootHelpFooter } from './ui/help.js'
44
- import { readStdinWithTimeout } from './hook-input.js'
45
- import { argvFlagNames } from './logging.js'
46
- import { QUESTION_SETTLEMENT_INPUT_ENV } from './question-settlement-process.js'
47
-
48
- /**
49
- * One source of truth for the version: the manifest npm actually published.
50
- *
51
- * It was hardcoded here as well, and the first patch release proved why that
52
- * does not hold — `package.json` moved and `notifai --version` kept reporting
53
- * the old number, which is exactly the string someone pastes into a bug report
54
- * to say what they are running.
55
- *
56
- * `unknown` is the display form of "this build cannot tell"; the skill pin
57
- * derived from the same source refuses instead, because a wrong ref installs
58
- * the wrong thing while a wrong version string only misinforms.
59
- */
60
- function version(): string {
61
- return packageVersion() ?? 'unknown'
62
- }
63
-
64
- /**
65
- * The full command path, e.g. `config set`, so a filter on `cmd` distinguishes
66
- * subcommands that share a leaf name.
67
- */
68
- function commandPath(command: Command): string {
69
- const parts: string[] = []
70
- for (let node: Command | null = command; node?.parent != null; node = node.parent) {
71
- parts.unshift(node.name())
72
- }
73
- return parts.join(' ') || 'notifai'
74
- }
75
-
76
- /**
77
- * Every command implementation the tree dispatches to, injectable so a test
78
- * can parse real argv and assert the exact flags a command would receive —
79
- * the layer where `--no-wait` disentangling and collector defaults live, which
80
- * unit tests on the commands themselves can never see.
81
- */
82
- const defaultRunners = {
83
- init: initCommand,
84
- doctor: doctorCommand,
85
- update: cliUpdateCommand,
86
- login: loginCommand,
87
- logout: logoutCommand,
88
- authStatus: authStatusCommand,
89
- accessStatus: accessStatusCommand,
90
- devices: devicesCommand,
91
- sounds: soundsCommand,
92
- capabilities: capabilitiesCommand,
93
- projectEnable: projectEnableCommand,
94
- projectDisable: projectDisableCommand,
95
- projectStatus: projectStatusCommand,
96
- agentSessionRename: agentSessionRenameCommand,
97
- send: sendCommand,
98
- replies: repliesCommand,
99
- acknowledge: acknowledgeCommand,
100
- status: statusCommand,
101
- ask: askCommand,
102
- close: closeCommand,
103
- hookRun: hookRunCommand,
104
- hooksInstall: hooksInstallCommand,
105
- hooksUninstall: hooksUninstallCommand,
106
- logs: logsCommand,
107
- configShow: configShowCommand,
108
- configExplain: configExplainCommand,
109
- configSet: configSetCommand,
110
- configUnset: configUnsetCommand,
111
- guidanceShow: guidanceShowCommand,
112
- guidanceSet: guidanceSetCommand,
113
- guidanceUnset: guidanceUnsetCommand,
114
- /**
115
- * Dynamic so that the prompt library, the banner and the whole interactive
116
- * tree cost nothing to the paths that never draw them — `send`, `ask`, and
117
- * the hook that runs in front of every prompt the user types.
118
- */
119
- interactive: async (deps: CommandDeps, versionString: string): Promise<number> => {
120
- const { interactiveCommand } = await import('./interactive.js')
121
- return interactiveCommand(deps, versionString)
122
- },
123
- }
124
-
125
- export type ProgramRunners = typeof defaultRunners
126
-
127
- export interface BuildProgramOptions {
128
- /** Test seam; production ends the process with the command's exit code. */
129
- exit?: (code: number) => void
130
- runners?: Partial<ProgramRunners>
131
- }
132
-
133
- export function buildProgram(deps: CommandDeps, options: BuildProgramOptions = {}): Command {
134
- const exit = options.exit ?? ((code: number) => process.exit(code))
135
- const runners: ProgramRunners = { ...defaultRunners, ...options.runners }
136
- const logger = deps.logger
137
-
138
- const program = new Command('notifai')
139
- .description('Send native device notifications from agents and local programs')
140
- .version(version())
141
- .configureHelp(helpConfiguration)
142
- // Lazy on purpose. `addHelpText` also takes a string, but that builds the
143
- // footer on every invocation — including the hook that runs in front of
144
- // every prompt the user types, which never renders help at all.
145
- .addHelpText('after', () => rootHelpFooter())
146
- // Commander's default is to print the full help and exit 0 for an unknown
147
- // `help` topic, so `notifai help nonsense` looked like it had worked. A
148
- // reader who mistyped a command deserves to be told, and a script deserves
149
- // a nonzero code.
150
- .showSuggestionAfterError(true)
151
- // Commander drops the implicit `help [command]` as soon as the program
152
- // itself has an action handler — which the interactive default below gives
153
- // it. Without this, adding that default would silently break
154
- // `notifai help send` for everyone who reaches for it before `--help`.
155
- .helpCommand(true)
156
- .hook('preAction', (_program, actionCommand) => {
157
- logger?.bind({ cmd: commandPath(actionCommand) })
158
- // SessionEnd uses the hook policy shared with commands.ts: local cleanup
159
- // precedes every diagnostic that can wait on the shared log lock.
160
- const deferDiagnostics =
161
- actionCommand.name() === 'hook' &&
162
- hookDefersDiagnosticsUntilAfterCleanup(actionCommand.processedArgs[0])
163
- // Values only at `debug`; `cli.end` carries the flag names at every level.
164
- if (!deferDiagnostics) {
165
- logger?.debug('cli.start', {
166
- version: version(),
167
- flags: argvFlagNames(process.argv.slice(2)),
168
- cwd: process.cwd(),
169
- })
170
- }
171
- })
172
-
173
- /**
174
- * Commander exits 1 for every usage error it detects itself, which contradicts
175
- * the exit vocabulary this CLI documents and every hand-written usage error it
176
- * returns. A caller branching on exit codes should not have to know which layer
177
- * rejected it. Help and version stay successful.
178
- */
179
- program.exitOverride((err) => {
180
- exit(err.exitCode === 0 ? 0 : 2)
181
- })
182
-
183
- /**
184
- * Bare `notifai`.
185
- *
186
- * At a human terminal this opens the interactive app, which enters `init`
187
- * when the machine is not yet paired and otherwise offers daily actions.
188
- * Anywhere else it prints help exactly as before. The check is the same one
189
- * every other prompt in this CLI is gated on — stdin and stdout both TTYs,
190
- * not CI, `NOTIFAI_NO_INPUT` unset — because an agent that reaches a prompt
191
- * does not fail, it hangs for ever waiting on a stdin nobody is typing into.
192
- */
193
- /**
194
- * An unrecognised subcommand reaches the root as an excess argument, and
195
- * "expected 0 arguments but got 1" tells a caller nothing about what it typed
196
- * or what exists. Naming it — with the nearest real command when there is one —
197
- * turns a dead end into one more try.
198
- */
199
- program.usage('[options] [command]')
200
- program.argument('[command]').action(async (command?: string) => {
201
- if (command !== undefined) {
202
- const names = program.commands.map((cmd) => cmd.name())
203
- const near = names.filter(
204
- (name) =>
205
- name.startsWith(command.slice(0, 2)) ||
206
- command.startsWith(name.slice(0, 2)) ||
207
- name.includes(command) ||
208
- command.includes(name),
209
- )
210
- deps.io.err(
211
- `Unknown command "${command}".` +
212
- (near.length > 0 ? ` Did you mean: ${near.slice(0, 3).join(', ')}?` : '') +
213
- ' Run notifai --help for the full list.',
214
- )
215
- return exit(2)
216
- }
217
- if (deps.io.interactive !== true) {
218
- program.outputHelp()
219
- return
220
- }
221
- exit(await runners.interactive(deps, version()))
222
- })
223
-
224
- // Setup leads: `init` is the single entry command for first-run friendliness.
225
- program
226
- .command('init')
227
- .helpGroup(GROUP.start)
228
- .summary('Set this project up, step by step')
229
- .description(
230
- 'Set up Notifai here, idempotently: sign-in, project id, hooks, device readiness, live receipt proof. ' +
231
- 'Interactive at a human terminal; never prompts otherwise (agents: pass flags)',
232
- )
233
- .option('--project-id <id>', 'Project identifier slug (default: derived from the directory name)')
234
- .option('--json', 'machine-readable final readiness; never prompts')
235
- .option('--skills', 'install/update the agent skill from its pinned public release')
236
- .option('--no-skills', 'suppress the optional agent-skill status line')
237
- .option(
238
- '--setup-scope <scope>',
239
- 'unattended setup scope: project or global (skill, hooks, and config). The CLI binary is always a global install',
240
- )
241
- .option('--skills-scope <scope>', 'unattended skill scope; same values as --setup-scope')
242
- .option('--hooks', 'install harness hooks for registered-question routing')
243
- .option('--no-hooks', 'skip the hooks without being asked')
244
- .action(
245
- async (opts: {
246
- projectId?: string
247
- json?: boolean
248
- skills?: boolean
249
- setupScope?: SkillScope
250
- skillsScope?: SkillScope
251
- hooks?: boolean
252
- }) => {
253
- exit(await runners.init(deps, opts))
254
- },
255
- )
256
-
257
- program
258
- .command('doctor')
259
- .helpGroup(GROUP.daily)
260
- .summary('Check every part of the setup')
261
- .description('Audit config, credential, server, contract, device, hook, and saved receipt proof; exits nonzero when any line is FAIL (no live send)')
262
- .option('--json', 'machine-readable output')
263
- .action(async (opts: { json?: boolean }) => {
264
- exit(await runners.doctor(deps, opts))
265
- })
266
-
267
- program
268
- .command('update')
269
- .helpGroup(GROUP.start)
270
- .summary('Update the Notifai command this shell uses')
271
- .description('Update the effective global Notifai installation and keep Question Routing on it')
272
- .option('--json', 'machine-readable installation and adapter result')
273
- .action((opts: { json?: boolean }) => {
274
- exit(runners.update(deps, opts))
275
- })
276
-
277
- const project = program
278
- .command('project')
279
- .helpGroup(GROUP.daily)
280
- .summary('Control Notifai for this Project')
281
- .description('Inspect or change this Project\'s User-owned lifecycle enablement')
282
- project.command('enable').description('Enable lifecycle guidance for this Project').action(() => {
283
- exit(runners.projectEnable(deps))
284
- })
285
- project.command('disable').description('Disable lifecycle guidance for this Project').action(() => {
286
- exit(runners.projectDisable(deps))
287
- })
288
- project.command('status').description('Show lifecycle enablement for this Project').option('--json').action((opts: { json?: boolean }) => {
289
- exit(runners.projectStatus(deps, opts.json === true))
290
- })
291
-
292
- const session = program
293
- .command('session')
294
- .helpGroup(GROUP.agent)
295
- .summary('Inspect or rename the current Agent Session')
296
- .description('Operate on the exact Agent Session owned by the active harness')
297
- session
298
- .command('rename <label>')
299
- .description(
300
- 'Rename this exact Agent Session; agents use this only after its job changes completely enough that the old label would mislead',
301
- )
302
- .option('--json', 'machine-readable output')
303
- .action(async (label: string, opts: { json?: boolean }) => {
304
- exit(await runners.agentSessionRename(deps, label, opts))
305
- })
306
-
307
- program
308
- .command('login')
309
- .helpGroup(GROUP.advanced)
310
- .summary('Sign in and pair this machine')
311
- .description('Pair this machine with your Notifai account via browser approval')
312
- .option('--name <name>', 'machine name shown in the dashboard (default: hostname)')
313
- .option('--base-url <url>', 'pairing override for the service origin (also NOTIFAI_BASE_URL)')
314
- .option('--no-open', 'do not open the approval page in a browser')
315
- .action(async (opts: { name?: string; baseUrl?: string; open?: boolean }) => {
316
- exit(await runners.login(deps, opts))
317
- })
318
-
319
- program
320
- .command('logout')
321
- .helpGroup(GROUP.advanced)
322
- .summary('Remove the stored machine credential')
323
- .description('Remove the stored machine credential')
324
- .action(() => {
325
- exit(runners.logout(deps))
326
- })
327
-
328
- const auth = program
329
- .command('auth')
330
- .description('Authentication helpers')
331
- .summary('Machine identity and account plan')
332
- .helpGroup(GROUP.advanced)
333
- auth
334
- .command('status')
335
- .description('Show the stored machine identity')
336
- .option('--json', 'machine-readable output')
337
- .action((opts: { json?: boolean }) => {
338
- exit(runners.authStatus(deps, opts))
339
- })
340
- auth
341
- .command('access')
342
- .description('Show the account plan and access decision')
343
- .option('--json', 'machine-readable output')
344
- .action(async (opts: { json?: boolean }) => {
345
- exit(await runners.accessStatus(deps, opts))
346
- })
347
-
348
- program
349
- .command('devices')
350
- .helpGroup(GROUP.daily)
351
- .summary('List your devices and whether they can receive')
352
- .description('List registered devices and their delivery readiness')
353
- .option('--platform <platform>', 'show only devices on one supported platform')
354
- .option('--json', 'machine-readable output')
355
- .action(async (opts: { json?: boolean; platform?: string }) => {
356
- exit(await runners.devices(deps, opts))
357
- })
358
-
359
- program
360
- .command('sounds')
361
- .helpGroup(GROUP.daily)
362
- .summary('List shipped and Account custom sounds')
363
- .description(
364
- 'List the sounds --sound and the saved sound key accept: shipped names and this Account\'s custom sounds',
365
- )
366
- .option('--json', 'machine-readable output')
367
- .action(async (opts: { json?: boolean }) => {
368
- exit(await runners.sounds(deps, opts))
369
- })
370
-
371
- program
372
- .command('capabilities')
373
- .helpGroup(GROUP.advanced)
374
- .summary('Show what a platform can render')
375
- .description('Show a platform capability contract')
376
- .option('--platform <platform>', 'platform to describe (default: ios)')
377
- .option('--json', 'machine-readable output')
378
- .action(async (opts: { json?: boolean; platform?: Platform }) => {
379
- exit(await runners.capabilities(deps, opts))
380
- })
381
-
382
- const send = program
383
- .command('send')
384
- .helpGroup(GROUP.agent)
385
- .summary('Send a notification')
386
- .description('Send a notification')
387
- .optionsGroup(SEND_GROUP.content)
388
- .requiredOption('--title <title>', 'brief title whose substance is immediately understandable')
389
- .option('--body <markdown>', 'canonical Markdown body')
390
- .option('--body-file <path>', 'read the canonical Markdown body from a file (use - for stdin)')
391
- .option(
392
- '--literal-backslash-n',
393
- 'allow the two-character sequence \\n in --body instead of treating it as a mistaken escaped newline',
394
- )
395
- .option('--subtitle <subtitle>', 'a plain-text line between the title and body')
396
- .option(
397
- '--image <path|url|media_id>',
398
- 'upload or attach an image in collection order (repeatable, maximum 8)',
399
- (v: string, all: string[] = []) => [...all, v],
400
- )
401
- .option(
402
- '--image-alt <text>',
403
- 'alt text paired with --image occurrences by position (repeatable)',
404
- (v: string, all: string[] = []) => [...all, v],
405
- )
406
- .optionsGroup(SEND_GROUP.routing)
407
- .option('--kind <kind>', 'what this is (required): update | done | failed | blocked (no User reply would resume it) — question is set by --reply')
408
- .option('--project <id>', 'Project identifier override (otherwise configured or inferred)')
409
- .option('--projectless', 'deliberately omit Project identity for this notification')
410
- .option('--device <id>', 'target a device id (repeatable)', (v: string, all: string[] = []) => [...all, v])
411
- .option('--all', 'target all routable devices (overrides configured devices)')
412
- .option('--session-id <id>', 'low-level automation override for an opaque exact Agent Session (env: NOTIFAI_SESSION_ID)')
413
- .option(
414
- '--session-label <text>',
415
- 'human Agent Session name; safe to repeat, with the first accepted name frozen (env: NOTIFAI_SESSION_LABEL)',
416
- )
417
- .optionsGroup(SEND_GROUP.presentation)
418
- .option('--collapse-key <key>', 'replace earlier notifications with the same key')
419
- .option('--thread-id <id>', 'group related notifications')
420
- .option('--ttl <seconds>', 'delivery window in seconds', (v: string) => Number(v))
421
- .option('--platform <platform>', 'limit optional fields to one supported platform')
422
- .optionsGroup(SEND_GROUP.reply)
423
- .option('--reply', 'enable the inline reply action and block for the answer')
424
- .option('--reply-timeout <seconds>', 'how long to wait for a reply (default: 900)', (v: string) => Number(v))
425
- .option(
426
- '--reply-window <seconds>',
427
- 'how long an answer is still accepted, 60-259200 (default: reply_window_seconds, a day)',
428
- (v: string) => Number(v),
429
- )
430
- .option(
431
- '--choice <label>',
432
- 'with --reply, ask a closed question; repeat the flag once per answer (2-6)',
433
- (v: string, all: string[] = []) => [...all, v],
434
- )
435
- .option('--multi', 'with --choice, several answers may be selected')
436
- .optionsGroup(SEND_GROUP.advanced)
437
- .option(
438
- '--sound <sound>',
439
- 'override saved sound: default | done | attention | alert | none, or a custom name or id from notifai sounds',
440
- )
441
- .option(
442
- '--level <level>',
443
- 'Apple-only interruption level: passive | active | time_sensitive (unsupported with --platform android)',
444
- )
445
- .option('--wait <seconds>', 'how long to wait for provider outcomes', (v: string) => Number(v))
446
- .option('--no-wait', 'return immediately after acceptance')
447
- .option('--data <key=value>', 'custom data (repeatable)', (v: string, all: string[] = []) => [...all, v])
448
- .option('--idempotency-key <key>', 'safe-retry key (default: random)')
449
- .option('--retry', 'explicitly retry one unresolved exact semantic send using its opaque saved attempt')
450
- .option(
451
- '--base-url <url>',
452
- 'pairing override for the service origin; ignored when this machine is already paired (also NOTIFAI_BASE_URL)',
453
- )
454
- .option('--json', 'print the full submission receipt as JSON')
455
- .action(async (opts: Record<string, unknown>) => {
456
- // commander maps --no-wait onto the same "wait" flag; disentangle.
457
- const noWait = opts['wait'] === false
458
- const wait = typeof opts['wait'] === 'number' ? opts['wait'] : undefined
459
- const sendOpts = { ...opts }
460
- // Commander collectors default to []; an empty list means "not passed".
461
- for (const key of ['choice', 'image', 'imageAlt']) {
462
- if (Array.isArray(sendOpts[key]) && sendOpts[key].length === 0) delete sendOpts[key]
463
- }
464
- const bodyFile = sendOpts['bodyFile']
465
- delete sendOpts['bodyFile']
466
- if (typeof bodyFile === 'string') {
467
- if (sendOpts['body'] !== undefined) {
468
- deps.io.err('Pass either --body or --body-file, not both.')
469
- return exit(2)
470
- }
471
- try {
472
- sendOpts['body'] = readFileSync(bodyFile === '-' ? 0 : bodyFile, 'utf8')
473
- } catch (err) {
474
- deps.io.err(`Could not read ${bodyFile}: ${String(err)}`)
475
- return exit(2)
476
- }
477
- }
478
- const flags = { ...sendOpts, noWait } as Parameters<typeof sendCommand>[1]
479
- if (wait === undefined) delete (flags as { wait?: number }).wait
480
- else flags.wait = wait
481
- exit(await runners.send(deps, flags))
482
- })
483
-
484
- send.addHelpText(
485
- 'after',
486
- `\nKind is required, and it selects the sound the notification arrives with: done rings the completion chime, failed the most insistent tone, blocked and question a distinct attention tone, update Device default.\nAn explicit --sound or saved sound preference outranks that default. --sound accepts a shipped name, an Account custom sound name or id from \`notifai sounds\`, or none. --level is Apple-only; Android attention is owned by kind, product channels, and device settings.\n`,
487
- )
488
-
489
- program
490
- .command('replies [request_id]')
491
- .helpGroup(GROUP.agent)
492
- .summary('Retrieve replies to a question')
493
- .description('Retrieve replies for a notification request')
494
- .option('--pending', 'use the pushed question pending for this Project and Agent Session')
495
- .option('--wait <seconds>', 'how long to wait for a reply', (v: string) => Number(v))
496
- .option('--after <seq>', 'return replies after this sequence number', (v: string) => Number(v))
497
- .option('--json', 'machine-readable output')
498
- .action(async (requestId: string | undefined, opts: { wait?: number; after?: number; json?: boolean; pending?: boolean }) => {
499
- exit(await runners.replies(deps, requestId, opts))
500
- })
501
-
502
- program
503
- .command('acknowledge <request_id>')
504
- .helpGroup(GROUP.agent)
505
- .summary("Tell the user what you'll do because of their reply")
506
- .description(
507
- 'Record the required Agent Acknowledgement for a replied-to notification request; never prompts',
508
- )
509
- .option('--text <text>', 'concrete work you will do because of the reply')
510
- .option('--json', 'machine-readable output')
511
- .action(async (requestId: string, opts: { text?: string; json?: boolean }) => {
512
- exit(await runners.acknowledge(deps, requestId, opts))
513
- })
514
-
515
- program
516
- .command('status <question_or_request_id>')
517
- .helpGroup(GROUP.agent)
518
- .summary('Show question state or request evidence')
519
- .description('Show local question state and, once submitted, the notification request evidence trail')
520
- .option('--json', 'machine-readable output')
521
- .action(async (requestId: string, opts: { json?: boolean }) => {
522
- exit(await runners.status(deps, requestId, opts))
523
- })
524
-
525
- program
526
- .command('ask [question]')
527
- .helpGroup(GROUP.agent)
528
- .summary('Register a question, then end the turn')
529
- .description('Register a question for the turn-end hook to route to your devices, subject to your question-routing settings')
530
- .option(
531
- '--choice <label>',
532
- 'answers to offer instead of free text; repeat the flag once per answer (2-6)',
533
- (v: string, all: string[] = []) => [...all, v],
534
- )
535
- .option('--multi', 'with --choice, several answers may be selected')
536
- .option('--json', 'machine-readable output')
537
- .option('--body <markdown>', 'optional Markdown context appended after the question block')
538
- .option('--body-file <path>', 'read optional Markdown context from a file (use - for stdin)')
539
- .option(
540
- '--literal-backslash-n',
541
- 'allow the two-character sequence \\n in --body instead of treating it as a mistaken escaped newline',
542
- )
543
- .option('--form <path>', 'ask several questions as one form; JSON file (use - for stdin)')
544
- .option(
545
- '--image <path|url|media_id>',
546
- 'upload or attach an image in collection order (repeatable, maximum 8)',
547
- (v: string, all: string[] = []) => [...all, v],
548
- )
549
- .option(
550
- '--image-alt <text>',
551
- 'alt text paired with --image occurrences by position (repeatable)',
552
- (v: string, all: string[] = []) => [...all, v],
553
- )
554
- .option('--project <id>', 'Project identifier override (otherwise configured or inferred)')
555
- .option(
556
- '--session-label <text>',
557
- 'human Agent Session name; safe to repeat, with the first accepted name frozen (env: NOTIFAI_SESSION_LABEL)',
558
- )
559
- .action(async (question: string | undefined, opts: {
560
- choice?: string[]
561
- multi?: boolean
562
- json?: boolean
563
- body?: string
564
- bodyFile?: string
565
- literalBackslashN?: boolean
566
- form?: string
567
- image?: string[]
568
- imageAlt?: string[]
569
- project?: string
570
- sessionLabel?: string
571
- }) => {
572
- let body = opts.body
573
- if (typeof opts.bodyFile === 'string') {
574
- if (body !== undefined) {
575
- return exit(reportAskFailure(deps, opts, {
576
- code: 'invalid_input', check_id: 'body', exit_code: 2,
577
- remedy: 'pass either --body or --body-file, then retry',
578
- message: 'Pass either --body or --body-file, not both.',
579
- }))
580
- }
581
- try {
582
- body = readFileSync(opts.bodyFile === '-' ? 0 : opts.bodyFile, 'utf8')
583
- } catch (err) {
584
- return exit(reportAskFailure(deps, opts, {
585
- code: 'input_unreadable', check_id: 'body_file', exit_code: 2,
586
- remedy: 'fix the body-file path or permissions, then retry',
587
- message: `Could not read ${opts.bodyFile}: ${String(err)}`,
588
- }))
589
- }
590
- }
591
- let form: string | undefined
592
- if (typeof opts.form === 'string') {
593
- try {
594
- form = readFileSync(opts.form === '-' ? 0 : opts.form, 'utf8')
595
- } catch (err) {
596
- return exit(reportAskFailure(deps, opts, {
597
- code: 'input_unreadable', check_id: 'form_file', exit_code: 2,
598
- remedy: 'fix the form-file path or permissions, then retry',
599
- message: `Could not read ${opts.form}: ${String(err)}`,
600
- }))
601
- }
602
- }
603
- // Commander collectors default to []; an empty list means "not passed".
604
- const flags: Parameters<typeof askCommand>[2] = {
605
- ...(opts.choice?.length ? { choice: opts.choice } : {}),
606
- ...(opts.multi ? { multi: true } : {}),
607
- ...(body !== undefined ? { body } : {}),
608
- ...(form !== undefined ? { form } : {}),
609
- ...(opts.image?.length ? { image: opts.image } : {}),
610
- ...(opts.imageAlt?.length ? { imageAlt: opts.imageAlt } : {}),
611
- ...(opts.project !== undefined ? { project: opts.project } : {}),
612
- ...(opts.sessionLabel !== undefined ? { sessionLabel: opts.sessionLabel } : {}),
613
- ...(opts.json === true ? { json: true } : {}),
614
- ...(opts.literalBackslashN === true ? { literalBackslashN: true } : {}),
615
- }
616
- exit(await runners.ask(deps, question, flags))
617
- })
618
-
619
- program
620
- .command('close [request_id]')
621
- .helpGroup(GROUP.agent)
622
- .summary('Retire a question so late answers are rejected')
623
- .description(
624
- 'Retire a question so late answers are rejected rather than lost. Pass --pending to withdraw this Agent Session\'s outstanding registrations, including ones the turn-end hook has not pushed yet.',
625
- )
626
- .option('--pending', 'retire this Agent Session\'s outstanding questions, including ones not yet pushed')
627
- .option('--json', 'machine-readable output')
628
- .action(async (requestId: string | undefined, opts: { json?: boolean; pending?: boolean }) => {
629
- exit(await runners.close(deps, requestId, opts))
630
- })
631
-
632
- // Hidden, not removed. It is an entry point the hook installer writes into a
633
- // harness config file, never something a person types — and listing it beside
634
- // `send` invited exactly one reading, which is that you were supposed to.
635
- program
636
- .command('hook <event>', { hidden: true })
637
- .description('Internal: run a harness hook (reads hook JSON on stdin)')
638
- // Inert, and the point of it is that it is inert: the installed command line
639
- // carries a marker that says "Notifai wrote this" independently of which
640
- // checkout wrote it.
641
- .option('--owner <name>', 'internal ownership marker')
642
- .option('--harness <name>', 'internal harness output adapter')
643
- .action(async (event: string, opts: { harness?: string }) => {
644
- const harness = HOOK_INSTALLABLE_HARNESSES.find((candidate) => candidate === opts.harness)
645
- const settlementInput = deps.env[QUESTION_SETTLEMENT_INPUT_ENV]
646
- if (event === 'question-settlement') {
647
- delete deps.env[QUESTION_SETTLEMENT_INPUT_ENV]
648
- }
649
- exit(await runners.hookRun(
650
- deps,
651
- event,
652
- event === 'question-settlement' && settlementInput !== undefined
653
- ? async () => settlementInput
654
- : () => readStdinWithTimeout(),
655
- harness,
656
- ))
657
- })
658
-
659
- const hooks = program
660
- .command('hooks')
661
- .description('Install harness hooks for registered-question routing')
662
- .summary('Wire a harness to route questions to your devices')
663
- .helpGroup(GROUP.advanced)
664
- hooks
665
- .command('install')
666
- .description('Wire this harness to route registered questions to your devices')
667
- .option(
668
- '--harness <name>',
669
- 'claude-code | codex | cursor | opencode | openclaw (default: every detected harness)',
670
- )
671
- .option('--global', 'install for every project instead of just this one')
672
- .action((opts: { harness?: string; global?: boolean }) => {
673
- exit(runners.hooksInstall(deps, opts))
674
- })
675
- hooks
676
- .command('uninstall')
677
- .description('Remove the hooks this CLI installed')
678
- .option('--harness <name>', 'claude-code | codex | cursor | opencode | openclaw (default: detected)')
679
- .option('--global', 'remove the machine-wide install')
680
- .action((opts: { harness?: string; global?: boolean }) => {
681
- exit(runners.hooksUninstall(deps, opts))
682
- })
683
-
684
- program
685
- .command('logs')
686
- .helpGroup(GROUP.daily)
687
- .summary('Show what this machine recorded about what it did')
688
- .description(
689
- 'Read the local record of commands, notifications, and the question decisions harness hooks made. ' +
690
- 'Bounded and scoped to this project by default; never leaves this machine',
691
- )
692
- .option('-n, --limit <count>', 'how many records to show (default: 30)', (v: string) => Number(v))
693
- .option('--all', 'lift the default limit, up to a hard cap')
694
- .option('--since <when>', 'only records newer than this: 10m, 2h, 1d, or an ISO 8601 instant')
695
- .option('--level <level>', 'minimum severity: error | info | debug (error shows only failures)')
696
- .option('--event <name>', 'only this event; repeatable', (v: string, all: string[] = []) => [...all, v])
697
- .option('--run <id>', 'everything one command invocation did')
698
- .option('--request <id>', 'everything about one notification request')
699
- .option('--session <id>', 'only this Agent Session')
700
- .option('--project <id>', 'only this Project')
701
- .option('--all-projects', 'do not scope to the Project in this directory')
702
- .option('--grep <text>', 'only records containing this text')
703
- .option('--json', 'one JSON record per line on stdout')
704
- .option('--path', 'print the log file paths instead of the records')
705
- .option('--clear', 'delete the log files')
706
- .action((opts: Record<string, unknown>) => {
707
- const flags = { ...opts } as Parameters<typeof logsCommand>[1]
708
- if (Array.isArray(flags.event) && flags.event.length === 0) delete flags.event
709
- exit(runners.logs(deps, flags))
710
- })
711
-
712
- const config = program
713
- .command('config')
714
- .description('Show or change settings')
715
- .summary('Show or change settings')
716
- .helpGroup(GROUP.daily)
717
- config
718
- .command('show')
719
- .description('Show every setting, what it does, and where its value came from')
720
- .option('--explain', 'include advanced settings and the file each value came from')
721
- .option('--plain', 'the flat key = value form, even at a terminal')
722
- .option('--json', 'machine-readable output')
723
- .action((opts: { json?: boolean; explain?: boolean; plain?: boolean }) => {
724
- exit(runners.configShow(deps, opts))
725
- })
726
- config
727
- .command('explain <key>')
728
- .description('Explain one setting in full: what it does, what it accepts, what it is now')
729
- .option('--json', 'machine-readable output')
730
- .action((key: string, opts: { json?: boolean }) => {
731
- exit(runners.configExplain(deps, key, opts))
732
- })
733
- config
734
- .command('set <key> <value>')
735
- .description(
736
- 'Set a configuration value (choose a layer interactively; unattended defaults machine-global and requires --yes)',
737
- )
738
- .option('--project', 'write to the shared .notifai/config.toml instead')
739
- .option('--local', 'write a personal project preference on this machine (not in the repo)')
740
- .option('--session <id>', 'apply only to one Agent Session')
741
- .option('--yes', 'skip the confirmation gate')
742
- .action(
743
- async (
744
- key: string,
745
- value: string,
746
- opts: { project?: boolean; local?: boolean; session?: string; yes?: boolean },
747
- ) => {
748
- exit(await runners.configSet(deps, key, value, opts))
749
- },
750
- )
751
- config
752
- .command('unset <key>')
753
- .description(
754
- 'Remove a configuration value so the next layer or shipped default applies (choose a layer interactively; unattended defaults machine-global and requires --yes)',
755
- )
756
- .option('--project', 'remove from the shared .notifai/config.toml instead')
757
- .option('--local', 'remove a personal project preference stored on this machine')
758
- .option('--session <id>', 'remove from one Agent Session')
759
- .option('--yes', 'skip the confirmation gate')
760
- .action(
761
- async (
762
- key: string,
763
- opts: { project?: boolean; local?: boolean; session?: string; yes?: boolean },
764
- ) => {
765
- exit(await runners.configUnset(deps, key, opts))
766
- },
767
- )
768
-
769
- const guidance = program
770
- .command('guidance')
771
- .description('How notifications are written: the shipped guidance and your overrides, per topic')
772
- .summary('Show or change how notifications are written')
773
- .helpGroup(GROUP.daily)
774
- guidance
775
- .command('show', { isDefault: true })
776
- .description('Print the effective guidance, every topic under the layer that supplied it')
777
- .option('--json', 'machine-readable output')
778
- .action((opts: { json?: boolean }) => {
779
- exit(runners.guidanceShow(deps, opts))
780
- })
781
- guidance
782
- .command('set <topic> [text]')
783
- .description(
784
- 'Write one guidance topic in your words; it replaces the shipped topic of the same name for that scope ' +
785
- '(choose a layer interactively; unattended defaults machine-global and requires --yes)',
786
- )
787
- .option('--file <path>', 'read the guidance text from a file (use - for stdin)')
788
- .option('--project', 'write to the shared .notifai/guidance/ instead')
789
- .option('--local', 'write a personal project preference on this machine (not in the repo)')
790
- .option('--yes', 'skip the confirmation gate')
791
- .action(
792
- async (
793
- topic: string,
794
- text: string | undefined,
795
- opts: { file?: string; project?: boolean; local?: boolean; yes?: boolean },
796
- ) => {
797
- let content = text
798
- if (typeof opts.file === 'string') {
799
- if (content !== undefined) {
800
- deps.io.err('Pass either the text or --file, not both.')
801
- exit(2)
802
- return
803
- }
804
- try {
805
- content = readFileSync(opts.file === '-' ? 0 : opts.file, 'utf8')
806
- } catch (err) {
807
- deps.io.err(`Could not read ${opts.file}: ${String(err)}`)
808
- exit(2)
809
- return
810
- }
811
- }
812
- if (content === undefined) {
813
- deps.io.err('Pass the guidance text, or --file <path|-> to read it.')
814
- exit(2)
815
- return
816
- }
817
- exit(
818
- await runners.guidanceSet(deps, topic, content, {
819
- project: opts.project,
820
- local: opts.local,
821
- yes: opts.yes,
822
- }),
823
- )
824
- },
825
- )
826
- guidance
827
- .command('unset <topic>')
828
- .description(
829
- 'Remove a guidance override so the next layer or the shipped topic applies ' +
830
- '(choose a layer interactively; unattended defaults machine-global and requires --yes)',
831
- )
832
- .option('--project', 'remove from the shared .notifai/guidance/ instead')
833
- .option('--local', 'remove a personal project preference stored on this machine')
834
- .option('--yes', 'skip the confirmation gate')
835
- .action(
836
- async (topic: string, opts: { project?: boolean; local?: boolean; yes?: boolean }) => {
837
- exit(await runners.guidanceUnset(deps, topic, opts))
838
- },
839
- )
840
-
841
- return program
842
- }