@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.
- package/CHANGELOG.md +75 -0
- package/README.md +20 -13
- package/dist/atomic-file.d.ts +14 -0
- package/dist/atomic-file.js +27 -2
- package/dist/atomic-file.js.map +1 -1
- package/dist/cli-bin.d.ts +4 -0
- package/dist/cli-bin.js +62 -0
- package/dist/cli-bin.js.map +1 -0
- package/dist/cli-release.d.ts +10 -0
- package/dist/cli-release.js +75 -0
- package/dist/cli-release.js.map +1 -0
- package/dist/client.d.ts +1 -0
- package/dist/client.js +13 -3
- package/dist/client.js.map +1 -1
- package/dist/commands-auth.d.ts +6 -0
- package/dist/commands-auth.js +28 -3
- package/dist/commands-auth.js.map +1 -1
- package/dist/commands-config.js +22 -3
- package/dist/commands-config.js.map +1 -1
- package/dist/commands-core.d.ts +12 -0
- package/dist/commands-core.js +27 -3
- package/dist/commands-core.js.map +1 -1
- package/dist/commands-devices.d.ts +2 -1
- package/dist/commands-devices.js +20 -8
- package/dist/commands-devices.js.map +1 -1
- package/dist/commands-doctor.d.ts +1 -0
- package/dist/commands-doctor.js +85 -27
- package/dist/commands-doctor.js.map +1 -1
- package/dist/commands-guidance.d.ts +27 -0
- package/dist/commands-guidance.js +163 -0
- package/dist/commands-guidance.js.map +1 -0
- package/dist/commands-hooks.d.ts +16 -5
- package/dist/commands-hooks.js +433 -38
- package/dist/commands-hooks.js.map +1 -1
- package/dist/commands-init.d.ts +10 -18
- package/dist/commands-init.js +139 -54
- package/dist/commands-init.js.map +1 -1
- package/dist/commands-send-support.d.ts +17 -2
- package/dist/commands-send-support.js +66 -8
- package/dist/commands-send-support.js.map +1 -1
- package/dist/commands-send.d.ts +0 -1
- package/dist/commands-send.js +105 -39
- package/dist/commands-send.js.map +1 -1
- package/dist/commands-setup-proof.d.ts +8 -0
- package/dist/commands-setup-proof.js +31 -2
- package/dist/commands-setup-proof.js.map +1 -1
- package/dist/commands-skill.d.ts +11 -1
- package/dist/commands-skill.js +61 -11
- package/dist/commands-skill.js.map +1 -1
- package/dist/commands.d.ts +2 -1
- package/dist/commands.js +1 -0
- package/dist/commands.js.map +1 -1
- package/dist/config-schema.d.ts +1 -1
- package/dist/config-schema.js +30 -14
- package/dist/config-schema.js.map +1 -1
- package/dist/config.d.ts +24 -5
- package/dist/config.js +37 -8
- package/dist/config.js.map +1 -1
- package/dist/credentials.d.ts +10 -1
- package/dist/credentials.js +25 -12
- package/dist/credentials.js.map +1 -1
- package/dist/guidance-content.d.ts +50 -0
- package/dist/guidance-content.js +240 -0
- package/dist/guidance-content.js.map +1 -0
- package/dist/guidance.d.ts +69 -0
- package/dist/guidance.js +173 -0
- package/dist/guidance.js.map +1 -0
- package/dist/hook-adapter.js +37 -3
- package/dist/hook-adapter.js.map +1 -1
- package/dist/hooks.d.ts +68 -7
- package/dist/hooks.js +238 -92
- package/dist/hooks.js.map +1 -1
- package/dist/install-hooks.d.ts +10 -18
- package/dist/install-hooks.js +110 -23
- package/dist/install-hooks.js.map +1 -1
- package/dist/interactive.d.ts +1 -1
- package/dist/interactive.js +14 -9
- package/dist/interactive.js.map +1 -1
- package/dist/logging.d.ts +8 -1
- package/dist/logging.js +43 -2
- package/dist/logging.js.map +1 -1
- package/dist/main.js +5 -487
- package/dist/main.js.map +1 -1
- package/dist/native-skills.d.ts +19 -0
- package/dist/native-skills.js +30 -8
- package/dist/native-skills.js.map +1 -1
- package/dist/opencode-plugin.js +14 -1
- package/dist/opencode-plugin.js.map +1 -1
- package/dist/program.d.ts +49 -0
- package/dist/program.js +576 -0
- package/dist/program.js.map +1 -0
- package/dist/send.d.ts +12 -10
- package/dist/send.js +65 -29
- package/dist/send.js.map +1 -1
- package/dist/session-activation.d.ts +15 -0
- package/dist/session-activation.js +35 -0
- package/dist/session-activation.js.map +1 -0
- package/dist/session-labels.d.ts +9 -3
- package/dist/session-labels.js +38 -7
- package/dist/session-labels.js.map +1 -1
- package/dist/url-policy.d.ts +85 -0
- package/dist/url-policy.js +369 -0
- package/dist/url-policy.js.map +1 -0
- package/package.json +6 -4
- package/src/atomic-file.ts +36 -2
- package/src/cli-bin.test.ts +38 -0
- package/src/cli-bin.ts +67 -0
- package/src/cli-release.test.ts +46 -0
- package/src/cli-release.ts +78 -0
- package/src/client.test.ts +95 -0
- package/src/client.ts +16 -3
- package/src/commands-auth.ts +32 -3
- package/src/commands-config.ts +25 -2
- package/src/commands-core.ts +38 -3
- package/src/commands-devices.ts +28 -9
- package/src/commands-doctor.ts +116 -25
- package/src/commands-guidance.ts +216 -0
- package/src/commands-hooks.ts +513 -42
- package/src/commands-init.ts +170 -60
- package/src/commands-send-support.test.ts +156 -0
- package/src/commands-send-support.ts +72 -8
- package/src/commands-send.ts +123 -38
- package/src/commands-setup-proof.ts +36 -2
- package/src/commands-skill.ts +78 -15
- package/src/commands.test.ts +1490 -197
- package/src/commands.ts +6 -0
- package/src/config-schema.ts +32 -16
- package/src/config.test.ts +57 -2
- package/src/config.ts +49 -10
- package/src/credentials.test.ts +71 -3
- package/src/credentials.ts +29 -15
- package/src/guidance-content.ts +256 -0
- package/src/guidance.test.ts +299 -0
- package/src/guidance.ts +233 -0
- package/src/hook-adapter.test.ts +113 -1
- package/src/hook-adapter.ts +37 -3
- package/src/hooks.test.ts +783 -170
- package/src/hooks.ts +306 -131
- package/src/install-hooks.test.ts +135 -16
- package/src/install-hooks.ts +113 -25
- package/src/interactive.ts +14 -9
- package/src/logging.test.ts +66 -3
- package/src/logging.ts +45 -2
- package/src/main.ts +6 -614
- package/src/native-skills.test.ts +41 -1
- package/src/native-skills.ts +40 -6
- package/src/opencode-plugin.ts +14 -1
- package/src/program.test.ts +237 -0
- package/src/program.ts +751 -0
- package/src/send.test.ts +28 -0
- package/src/send.ts +81 -34
- package/src/session-activation.ts +45 -0
- package/src/session-labels.test.ts +120 -3
- package/src/session-labels.ts +38 -7
- package/src/skill.test.ts +153 -12
- package/src/trust-policy.test.ts +701 -0
- 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
|
|
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
|
-
|
|
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
|
}
|