@raidiant/notifai 7.0.2 → 9.0.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 (157) hide show
  1. package/CHANGELOG.md +75 -0
  2. package/README.md +20 -13
  3. package/dist/atomic-file.d.ts +14 -0
  4. package/dist/atomic-file.js +27 -2
  5. package/dist/atomic-file.js.map +1 -1
  6. package/dist/cli-bin.d.ts +4 -0
  7. package/dist/cli-bin.js +62 -0
  8. package/dist/cli-bin.js.map +1 -0
  9. package/dist/cli-release.d.ts +10 -0
  10. package/dist/cli-release.js +75 -0
  11. package/dist/cli-release.js.map +1 -0
  12. package/dist/client.d.ts +1 -0
  13. package/dist/client.js +13 -3
  14. package/dist/client.js.map +1 -1
  15. package/dist/commands-auth.d.ts +6 -0
  16. package/dist/commands-auth.js +28 -3
  17. package/dist/commands-auth.js.map +1 -1
  18. package/dist/commands-config.js +22 -3
  19. package/dist/commands-config.js.map +1 -1
  20. package/dist/commands-core.d.ts +12 -0
  21. package/dist/commands-core.js +27 -3
  22. package/dist/commands-core.js.map +1 -1
  23. package/dist/commands-devices.d.ts +2 -1
  24. package/dist/commands-devices.js +20 -8
  25. package/dist/commands-devices.js.map +1 -1
  26. package/dist/commands-doctor.d.ts +1 -0
  27. package/dist/commands-doctor.js +85 -27
  28. package/dist/commands-doctor.js.map +1 -1
  29. package/dist/commands-guidance.d.ts +27 -0
  30. package/dist/commands-guidance.js +163 -0
  31. package/dist/commands-guidance.js.map +1 -0
  32. package/dist/commands-hooks.d.ts +16 -5
  33. package/dist/commands-hooks.js +433 -38
  34. package/dist/commands-hooks.js.map +1 -1
  35. package/dist/commands-init.d.ts +10 -18
  36. package/dist/commands-init.js +139 -54
  37. package/dist/commands-init.js.map +1 -1
  38. package/dist/commands-send-support.d.ts +17 -2
  39. package/dist/commands-send-support.js +66 -8
  40. package/dist/commands-send-support.js.map +1 -1
  41. package/dist/commands-send.d.ts +0 -1
  42. package/dist/commands-send.js +105 -39
  43. package/dist/commands-send.js.map +1 -1
  44. package/dist/commands-setup-proof.d.ts +8 -0
  45. package/dist/commands-setup-proof.js +31 -2
  46. package/dist/commands-setup-proof.js.map +1 -1
  47. package/dist/commands-skill.d.ts +11 -1
  48. package/dist/commands-skill.js +61 -11
  49. package/dist/commands-skill.js.map +1 -1
  50. package/dist/commands.d.ts +2 -1
  51. package/dist/commands.js +1 -0
  52. package/dist/commands.js.map +1 -1
  53. package/dist/config-schema.d.ts +1 -1
  54. package/dist/config-schema.js +30 -14
  55. package/dist/config-schema.js.map +1 -1
  56. package/dist/config.d.ts +24 -5
  57. package/dist/config.js +37 -8
  58. package/dist/config.js.map +1 -1
  59. package/dist/credentials.d.ts +10 -1
  60. package/dist/credentials.js +25 -12
  61. package/dist/credentials.js.map +1 -1
  62. package/dist/guidance-content.d.ts +50 -0
  63. package/dist/guidance-content.js +240 -0
  64. package/dist/guidance-content.js.map +1 -0
  65. package/dist/guidance.d.ts +69 -0
  66. package/dist/guidance.js +173 -0
  67. package/dist/guidance.js.map +1 -0
  68. package/dist/hook-adapter.js +37 -3
  69. package/dist/hook-adapter.js.map +1 -1
  70. package/dist/hooks.d.ts +68 -7
  71. package/dist/hooks.js +238 -92
  72. package/dist/hooks.js.map +1 -1
  73. package/dist/install-hooks.d.ts +10 -18
  74. package/dist/install-hooks.js +110 -23
  75. package/dist/install-hooks.js.map +1 -1
  76. package/dist/interactive.d.ts +1 -1
  77. package/dist/interactive.js +14 -9
  78. package/dist/interactive.js.map +1 -1
  79. package/dist/logging.d.ts +8 -1
  80. package/dist/logging.js +43 -2
  81. package/dist/logging.js.map +1 -1
  82. package/dist/main.js +5 -487
  83. package/dist/main.js.map +1 -1
  84. package/dist/native-skills.d.ts +19 -0
  85. package/dist/native-skills.js +30 -8
  86. package/dist/native-skills.js.map +1 -1
  87. package/dist/opencode-plugin.js +14 -1
  88. package/dist/opencode-plugin.js.map +1 -1
  89. package/dist/program.d.ts +49 -0
  90. package/dist/program.js +576 -0
  91. package/dist/program.js.map +1 -0
  92. package/dist/send.d.ts +12 -10
  93. package/dist/send.js +65 -29
  94. package/dist/send.js.map +1 -1
  95. package/dist/session-activation.d.ts +15 -0
  96. package/dist/session-activation.js +35 -0
  97. package/dist/session-activation.js.map +1 -0
  98. package/dist/session-labels.d.ts +9 -3
  99. package/dist/session-labels.js +38 -7
  100. package/dist/session-labels.js.map +1 -1
  101. package/dist/url-policy.d.ts +85 -0
  102. package/dist/url-policy.js +369 -0
  103. package/dist/url-policy.js.map +1 -0
  104. package/package.json +6 -4
  105. package/src/atomic-file.ts +36 -2
  106. package/src/cli-bin.test.ts +38 -0
  107. package/src/cli-bin.ts +67 -0
  108. package/src/cli-release.test.ts +46 -0
  109. package/src/cli-release.ts +78 -0
  110. package/src/client.test.ts +95 -0
  111. package/src/client.ts +16 -3
  112. package/src/commands-auth.ts +32 -3
  113. package/src/commands-config.ts +25 -2
  114. package/src/commands-core.ts +38 -3
  115. package/src/commands-devices.ts +28 -9
  116. package/src/commands-doctor.ts +116 -25
  117. package/src/commands-guidance.ts +216 -0
  118. package/src/commands-hooks.ts +513 -42
  119. package/src/commands-init.ts +170 -60
  120. package/src/commands-send-support.test.ts +156 -0
  121. package/src/commands-send-support.ts +72 -8
  122. package/src/commands-send.ts +123 -38
  123. package/src/commands-setup-proof.ts +36 -2
  124. package/src/commands-skill.ts +78 -15
  125. package/src/commands.test.ts +1490 -197
  126. package/src/commands.ts +6 -0
  127. package/src/config-schema.ts +32 -16
  128. package/src/config.test.ts +57 -2
  129. package/src/config.ts +49 -10
  130. package/src/credentials.test.ts +71 -3
  131. package/src/credentials.ts +29 -15
  132. package/src/guidance-content.ts +256 -0
  133. package/src/guidance.test.ts +299 -0
  134. package/src/guidance.ts +233 -0
  135. package/src/hook-adapter.test.ts +113 -1
  136. package/src/hook-adapter.ts +37 -3
  137. package/src/hooks.test.ts +783 -170
  138. package/src/hooks.ts +306 -131
  139. package/src/install-hooks.test.ts +135 -16
  140. package/src/install-hooks.ts +113 -25
  141. package/src/interactive.ts +14 -9
  142. package/src/logging.test.ts +66 -3
  143. package/src/logging.ts +45 -2
  144. package/src/main.ts +6 -614
  145. package/src/native-skills.test.ts +41 -1
  146. package/src/native-skills.ts +40 -6
  147. package/src/opencode-plugin.ts +14 -1
  148. package/src/program.test.ts +237 -0
  149. package/src/program.ts +751 -0
  150. package/src/send.test.ts +28 -0
  151. package/src/send.ts +81 -34
  152. package/src/session-activation.ts +45 -0
  153. package/src/session-labels.test.ts +120 -3
  154. package/src/session-labels.ts +38 -7
  155. package/src/skill.test.ts +153 -12
  156. package/src/trust-policy.test.ts +701 -0
  157. package/src/url-policy.ts +399 -0
package/src/logging.ts CHANGED
@@ -80,7 +80,7 @@ const LEVEL_RANK: Record<LogLevel, number> = { off: 0, error: 1, info: 2, debug:
80
80
  * existing one, and keep each event answering exactly one question.
81
81
  */
82
82
  export const LOG_EVENTS = [
83
- /** A CLI invocation began: which command, which arguments, which version. */
83
+ /** A CLI invocation began: which command, which flag names, which version. */
84
84
  'cli.start',
85
85
  /** It ended: exit code and how long it took. */
86
86
  'cli.end',
@@ -90,6 +90,8 @@ export const LOG_EVENTS = [
90
90
  'config.resolved',
91
91
  /** One HTTP call to the service: method, path, status, duration. */
92
92
  'http.call',
93
+ /** A send crossed its ambiguous network boundary with this retry identity. */
94
+ 'send.attempt',
93
95
  /** A notification was accepted by the service. */
94
96
  'send.submitted',
95
97
  /** What became of it per device. */
@@ -108,6 +110,8 @@ export const LOG_EVENTS = [
108
110
  'hook.gate',
109
111
  /** A question reached the user's devices. */
110
112
  'hook.pushed',
113
+ /** A retirement close was attempted, and whether the server proved it. */
114
+ 'hook.retirement',
111
115
  /** The hook handed an answer back to the agent. */
112
116
  'hook.answer',
113
117
  /** The hook finished, with or without a decision. */
@@ -155,6 +159,10 @@ const MAX_DEPTH = 4
155
159
  */
156
160
  const SECRET_KEY_PATTERN = /secret|token|password|authorization|credential|verifier|api[_-]?key/i
157
161
  const MACHINE_TOKEN_PATTERN = /nfm_[A-Za-z0-9._-]{6,}/g
162
+ /** Notification and question content: persist length, never the words. */
163
+ const CONTENT_STRING_KEYS = new Set(['title', 'subtitle', 'body', 'text', 'question'])
164
+ /** Choice labels, reply answers, and raw argv: persist counts, never values. */
165
+ const CONTENT_LIST_KEYS = new Set(['answers', 'choices', 'argv'])
158
166
 
159
167
  export const REDACTED = '[redacted]'
160
168
 
@@ -207,6 +215,22 @@ function redactString(value: string): string {
207
215
  return `${scrubbed.slice(0, MAX_STRING_CHARS)}…(+${scrubbed.length - MAX_STRING_CHARS} chars)`
208
216
  }
209
217
 
218
+ /**
219
+ * Flag names only — argv values are notification content and user text.
220
+ *
221
+ * `--title=SECRET` must become `--title`. Filtering on a `--` prefix is not
222
+ * enough: inline assignment would otherwise persist the value.
223
+ */
224
+ export function argvFlagNames(argv: readonly string[]): string[] {
225
+ const names: string[] = []
226
+ for (const token of argv) {
227
+ if (!token.startsWith('--') || token === '--') continue
228
+ const eq = token.indexOf('=')
229
+ names.push(eq === -1 ? token : token.slice(0, eq))
230
+ }
231
+ return names
232
+ }
233
+
210
234
  /**
211
235
  * Shape a value for the record: drop what must never be written, truncate what
212
236
  * would flood a reader, and refuse to recurse for ever into a cyclic object.
@@ -226,7 +250,26 @@ export function shape(value: unknown, depth = 0): unknown {
226
250
  const out: Record<string, unknown> = {}
227
251
  for (const [key, nested] of Object.entries(value as Record<string, unknown>)) {
228
252
  if (nested === undefined) continue
229
- out[key] = SECRET_KEY_PATTERN.test(key) ? REDACTED : shape(nested, depth + 1)
253
+ if (SECRET_KEY_PATTERN.test(key)) {
254
+ out[key] = REDACTED
255
+ continue
256
+ }
257
+ if (CONTENT_STRING_KEYS.has(key) && typeof nested === 'string') {
258
+ out[`${key}_chars`] = nested.length
259
+ continue
260
+ }
261
+ if (key === 'argv' && Array.isArray(nested)) {
262
+ out.flags = argvFlagNames(
263
+ nested.filter((token): token is string => typeof token === 'string'),
264
+ )
265
+ out.argv_count = nested.length
266
+ continue
267
+ }
268
+ if (CONTENT_LIST_KEYS.has(key) && Array.isArray(nested)) {
269
+ out[`${key}_count`] = nested.length
270
+ continue
271
+ }
272
+ out[key] = shape(nested, depth + 1)
230
273
  }
231
274
  return out
232
275
  }