advisers 0.4.0 → 0.4.1
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/README-zh.md +3 -3
- package/README.md +16 -11
- package/THIRD-PARTY-NOTICES.md +1 -1
- package/bin/advisers.js +135 -16
- package/index.js +1 -1
- package/lib/mail.js +2 -2
- package/package.json +4 -4
package/README-zh.md
CHANGED
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
## 安装
|
|
6
6
|
|
|
7
7
|
```sh
|
|
8
|
-
# 0.4.
|
|
8
|
+
# 0.4.1 已于 2026-11-21 发布;npm @latest 现为 0.4.1(稳定渠道 = 默认 `latest`):
|
|
9
9
|
# npm i -g --registry=https://registry.npmjs.org advisers@latest advisers-office@latest
|
|
10
10
|
# 从 checkout 运行:
|
|
11
11
|
# corepack pnpm install && corepack pnpm -r build
|
|
12
12
|
# ADVISERS_OFFICE_LOCAL=1 node packages/advisers/bin/advisers.js status
|
|
13
|
-
# `next` 渠道也指向 0.4.
|
|
13
|
+
# `next` 渠道也指向 0.4.1:
|
|
14
14
|
# npm i -g --registry=https://registry.npmjs.org advisers@next advisers-office@next
|
|
15
15
|
advisers soul init
|
|
16
16
|
advisers brief "做一份 Q4 预算 Excel,周五前给老板"
|
|
@@ -36,7 +36,7 @@ CLI 是**本地秘书运行时**:一个 REPL、用户账/承诺账/流程账
|
|
|
36
36
|
|
|
37
37
|
## 状态
|
|
38
38
|
|
|
39
|
-
`0.4.
|
|
39
|
+
`0.4.1` 已于 2026-11-21 发布(npm `latest` = `0.4.1`;`next` 也为 `0.4.1`)。0.4.1 是 0.4.0 功能发布之上的当日补丁:接线 KB/邮件审查链接(`kb link/unlink`、`mail link/dismiss`),为 `remind --deliver --notify` 增加运行时安静时段 + 按本地日去重 + `--force-notify`,新增 `kb`/`mail`/`policy` 三组确定性评测(30 cases / 277 checks)与 38 个 documented-additive CLI 命令。0.4.0 的功能面不变:本地知识库(schema v22)、TLS-only IMAP 邮件入口、交互式壳、可解释的主动式晨报、Policy/Evidence 2.0 子集、回款/对账与客户状态包 v2、MCP modern dual-era、Windows CI 与便携 ZIP,以及 v2026.11.4 法务修订。所有新命令都不需要模型调用,也没有后台常驻进程,`mail sync` 是唯一新增的显式网络路径(TLS-only、只读、用户主动触发)。**schema v22 是单向迁移**:升级前 CLI 会写 `state.db.before-migrate-v*` 备份,0.3.2 打开 v22 数据库会报 `E_SCHEMA_NEWER`,降级需要恢复该备份。`0.4.0`/`0.3.2`/`0.3.1`/`0.3.0` 仍可按版本号安装但已被取代。运行时基线仍是「可信交付」feature line:所有出网面逐 item secrecy clearance、本地审计尾锚、备份轮换/可验证恢复与 `doctor --repair`、200k 读路径、MCP 输出上限 + legacy 协议协商、DSH 只读账本门面、机器可读契约、无 key 的确定性评测套件与 SBOM 门禁。`0.4.1` tarball 由 GitHub Actions OIDC/Trusted Publishing 发布,带 SLSA provenance;可用 `scripts/verify-release.mjs --version 0.4.1 --tag latest --sbom artifacts/sbom.cdx.json --require-sbom` 校验(SBOM 由 `pnpm run sbom` 生成)。Release notes:<https://github.com/PerryLink/advisers/releases/tag/v0.4.1>。模型化 `kb compile`/`kb ask`、embedding、完整 PolicyGrant/exit 4–6 与 DSH 写账本仍属后续版本;未交付清单见仓库 CHANGELOG。
|
|
40
40
|
|
|
41
41
|
- SQLite 账本 `~/.advisers/state.db`(JSON fallback;schema v22 —— 0.4.0 一次迁移加入 KB/邮件/回款对象、无锁只读快照、增量写);
|
|
42
42
|
- soul 位于 `~/.advisers/soul.md`,人类独占;
|
package/README.md
CHANGED
|
@@ -7,12 +7,12 @@ routines.
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
9
9
|
```sh
|
|
10
|
-
# 0.4.
|
|
10
|
+
# 0.4.1 was published on 2026-11-21; npm @latest is now 0.4.1:
|
|
11
11
|
# npm i -g --registry=https://registry.npmjs.org advisers@latest advisers-office@latest
|
|
12
12
|
# From checkout:
|
|
13
13
|
# corepack pnpm install && corepack pnpm -r build
|
|
14
14
|
# ADVISERS_OFFICE_LOCAL=1 node packages/advisers/bin/advisers.js status
|
|
15
|
-
# The `next` channel also points at 0.4.
|
|
15
|
+
# The `next` channel also points at 0.4.1:
|
|
16
16
|
# npm i -g --registry=https://registry.npmjs.org advisers@next advisers-office@next
|
|
17
17
|
advisers soul init
|
|
18
18
|
advisers brief "做一份 Q4 预算 Excel,周五前给老板"
|
|
@@ -43,24 +43,29 @@ turn natural language into commitments or artifacts.
|
|
|
43
43
|
|
|
44
44
|
## Status
|
|
45
45
|
|
|
46
|
-
`0.4.
|
|
47
|
-
is the
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
`0.4.1` was published on 2026-11-21 (npm `latest` = `0.4.1`; `next` is also `0.4.1`). It
|
|
47
|
+
is a same-day follow-up patch on the 0.4.0 feature release: it wires the KB/mail review
|
|
48
|
+
links (`kb link/unlink`, `mail link/dismiss`), enforces runtime quiet hours + per-local-day
|
|
49
|
+
dedupe + `--force-notify` for `remind --deliver --notify`, and adds the
|
|
50
|
+
`kb`/`mail`/`policy` deterministic eval groups (30 cases / 277 checks) plus 38
|
|
51
|
+
documented-additive CLI commands. The 0.4.0 feature surface is unchanged: the local
|
|
52
|
+
knowledge base (schema v22), TLS-only IMAP mail entry, the interactive shell, proactive
|
|
53
|
+
urgent-first briefs, the policy/evidence 2.0 subset, receivables/payments with client
|
|
54
|
+
pack v2, MCP modern dual-era, Windows CI plus a portable ZIP, and the v2026.11.4 legal
|
|
55
|
+
revision. No new command requires a model call,
|
|
51
56
|
there is no background daemon, and `mail sync` is the one new explicit network path
|
|
52
57
|
(TLS-only, read-only, user-invoked). **Schema v22 is a one-way migration**: the CLI writes
|
|
53
58
|
`state.db.before-migrate-v*` before upgrading, a 0.3.2 binary opening a v22 database fails
|
|
54
|
-
with `E_SCHEMA_NEWER`, and downgrading means restoring that backup. `0.3.2`/`0.3.1`/`0.3.0`
|
|
59
|
+
with `E_SCHEMA_NEWER`, and downgrading means restoring that backup. `0.4.0`/`0.3.2`/`0.3.1`/`0.3.0`
|
|
55
60
|
remain installable by pinning but are superseded. The runtime baseline remains the
|
|
56
61
|
"trustworthy delivery" line: per-item secrecy clearance on every egress surface, a local
|
|
57
62
|
audit tail anchor, backup rotation/verified restore and `doctor --repair`, 200k-row read
|
|
58
63
|
paths, MCP output caps plus legacy protocol negotiation, a read-only ledger facade, machine
|
|
59
|
-
readable contracts, a deterministic no-key eval suite and an SBOM gate. The 0.4.
|
|
64
|
+
readable contracts, a deterministic no-key eval suite and an SBOM gate. The `0.4.1` tarballs
|
|
60
65
|
are published from GitHub Actions OIDC/Trusted Publishing with SLSA provenance; verify with
|
|
61
|
-
`scripts/verify-release.mjs --version 0.4.
|
|
66
|
+
`scripts/verify-release.mjs --version 0.4.1 --tag latest --sbom artifacts/sbom.cdx.json
|
|
62
67
|
--require-sbom` (the SBOM is generated by `pnpm run sbom`).
|
|
63
|
-
Release notes: <https://github.com/PerryLink/advisers/releases/tag/v0.4.
|
|
68
|
+
Release notes: <https://github.com/PerryLink/advisers/releases/tag/v0.4.1>. Model-backed KB
|
|
64
69
|
compile/ask, embeddings, the full PolicyGrant/exit 4–6 and DSH writes remain future work;
|
|
65
70
|
see the repository CHANGELOG for the full not-delivered list.
|
|
66
71
|
|
package/THIRD-PARTY-NOTICES.md
CHANGED
|
@@ -11,7 +11,7 @@ dependency closure of the published packages ("pnpm list --prod --depth 100";
|
|
|
11
11
|
devDependencies and workspace packages excluded). Do not edit by hand; CI runs
|
|
12
12
|
"node scripts/check-licenses.mjs".
|
|
13
13
|
|
|
14
|
-
This file is shipped with the advisers@0.4.
|
|
14
|
+
This file is shipped with the advisers@0.4.1 npm package and covers the third-party production dependencies of that package only. Each dependency keeps its own license.
|
|
15
15
|
|
|
16
16
|
Optional platform-specific binaries (for example the @napi-rs/canvas builds for
|
|
17
17
|
other operating systems and CPU architectures) are installed only on a matching
|
package/bin/advisers.js
CHANGED
|
@@ -1230,7 +1230,7 @@ Usage:
|
|
|
1230
1230
|
advisers compact ls|rollback summary versions
|
|
1231
1231
|
advisers today [--calendar] [--sources] [--json [--limit n]]
|
|
1232
1232
|
one-screen today/week/waiting view (+ local events)
|
|
1233
|
-
advisers remind [--json] [--ics [path]] [--deliver [--notify]] due reminders + ICS/VALARM export
|
|
1233
|
+
advisers remind [--json] [--ics [path]] [--deliver [--notify]] [--quiet-hours HH:MM-HH:MM] [--force-notify] due reminders + ICS/VALARM export
|
|
1234
1234
|
advisers remind install|uninstall|status [--apply] [--schedule "0 9 * * *"]
|
|
1235
1235
|
scheduler scripts + OS plan (dry-run by default; --apply executes)
|
|
1236
1236
|
--morning adds the second morning block (--morning-time 08:30, --morning-days 1-5)
|
|
@@ -1600,7 +1600,7 @@ function purgeMatter(id, confirmed) {
|
|
|
1600
1600
|
function parseFlags(args) {
|
|
1601
1601
|
const flags = {}
|
|
1602
1602
|
const positional = []
|
|
1603
|
-
const booleanFlags = new Set(['web', 'deep', 'all', 'yes', 'json', 'list', 'force', 'apply', 'quiet', 'help', 'content', 'ics', 'deliver', 'install', 'uninstall', 'status', 'calendar', 'sources', 'pack', 'receipt', 'from-imap', 'remove', 'force', 'notify', 'no-remind', 'dry-run', 'unclassified', 'no-calendar', 'include-done', 'record-delivery', 'include-global', 'archive', 'morning', 'include-deleted', 'all-new', 'local', 'model', 'full', 'pass-stdin'])
|
|
1603
|
+
const booleanFlags = new Set(['web', 'deep', 'all', 'yes', 'json', 'list', 'force', 'apply', 'quiet', 'help', 'content', 'ics', 'deliver', 'install', 'uninstall', 'status', 'calendar', 'sources', 'pack', 'receipt', 'from-imap', 'remove', 'force', 'notify', 'no-remind', 'dry-run', 'unclassified', 'no-calendar', 'include-done', 'record-delivery', 'include-global', 'archive', 'morning', 'include-deleted', 'all-new', 'local', 'model', 'full', 'pass-stdin', 'force-notify'])
|
|
1604
1604
|
for (let i = 0; i < args.length; i++) {
|
|
1605
1605
|
if (args[i].startsWith('--')) {
|
|
1606
1606
|
const key = args[i].slice(2)
|
|
@@ -6799,6 +6799,8 @@ const KB_USAGE = [
|
|
|
6799
6799
|
' advisers kb reindex [--rebuild] [--json]',
|
|
6800
6800
|
' advisers kb search <query> [--scope kb|pages|all] [--limit n] [--clearance 0-3] [--json]',
|
|
6801
6801
|
' advisers kb page ls|show|rebuild|diff ... [--json]',
|
|
6802
|
+
' advisers kb link <doc-id> --fact <fact-id> [--relation source|mentions] [--chunk id] [--json]',
|
|
6803
|
+
' advisers kb unlink <doc-id> --fact <fact-id> [--relation source|mentions] [--json]',
|
|
6802
6804
|
].join('\n')
|
|
6803
6805
|
|
|
6804
6806
|
function kbDocRowText(doc) {
|
|
@@ -7017,10 +7019,33 @@ async function kbCommand(rawArgs) {
|
|
|
7017
7019
|
if (sub === 'reindex') return await kbReindexCommand(rawArgs.slice(1))
|
|
7018
7020
|
if (sub === 'page') return await kbPageCommand(rawArgs.slice(1))
|
|
7019
7021
|
if (sub === 'search') return await kbSearchCommand(rawArgs.slice(1))
|
|
7022
|
+
if (sub === 'link') return await kbLinkCommand(rawArgs.slice(1), false)
|
|
7023
|
+
if (sub === 'unlink') return await kbLinkCommand(rawArgs.slice(1), true)
|
|
7020
7024
|
usageFail('unknown kb subcommand: ' + sub, KB_USAGE)
|
|
7021
7025
|
} catch (error) { reportFamilyFailure(error) }
|
|
7022
7026
|
}
|
|
7023
7027
|
|
|
7028
|
+
/** kb link/unlink: explicit fact <-> document provenance (0.4.x follow-up). */
|
|
7029
|
+
async function kbLinkCommand(rawArgs, unlink = false) {
|
|
7030
|
+
const usage = unlink
|
|
7031
|
+
? 'usage: advisers kb unlink <doc-id> --fact <fact-id> [--relation source|mentions] [--json]'
|
|
7032
|
+
: 'usage: advisers kb link <doc-id> --fact <fact-id> [--relation source|mentions] [--chunk id] [--json]'
|
|
7033
|
+
const parsed = familyFlags(rawArgs, { booleans: ['json'], values: ['fact', 'relation', 'chunk'] }, usage)
|
|
7034
|
+
if (!parsed) return
|
|
7035
|
+
const docId = parsed.positional[0]
|
|
7036
|
+
const factId = parsed.flags.fact
|
|
7037
|
+
if (!docId) { usageFail('missing document id', usage); return }
|
|
7038
|
+
if (!factId) { usageFail('--fact is required', usage); return }
|
|
7039
|
+
const kb = await loadKb()
|
|
7040
|
+
const store = familyStore({ write: true })
|
|
7041
|
+
const result = unlink
|
|
7042
|
+
? kb.kbUnlink(store, { docId, factId, relation: parsed.flags.relation })
|
|
7043
|
+
: kb.kbLink(store, { docId, factId, relation: parsed.flags.relation, chunkId: parsed.flags.chunk })
|
|
7044
|
+
if (parsed.flags.json) { console.log(JSON.stringify(result, null, 2)); return }
|
|
7045
|
+
if (unlink) console.log('unlinked ' + result.removed + ' link(s): ' + docId + ' x ' + factId)
|
|
7046
|
+
else console.log('linked ' + docId + ' -> ' + factId + ' (' + result.link.relation + ')')
|
|
7047
|
+
}
|
|
7048
|
+
|
|
7024
7049
|
const FACT_USAGE = [
|
|
7025
7050
|
'usage: advisers fact show <id> [--include-deleted] [--json]',
|
|
7026
7051
|
' advisers fact history <id> [--json]',
|
|
@@ -7211,6 +7236,8 @@ const MAIL_USAGE = [
|
|
|
7211
7236
|
' advisers mail extract [<id>...] [--all-new] [--local|--model] [--yes] [--matter id] [--limit n] [--dry-run] [--json]',
|
|
7212
7237
|
' advisers mail import <file|dir> [--limit n] [--dry-run] [--client id] [--project id] [--json]',
|
|
7213
7238
|
' advisers mail purge [--older-than 30d] [--dry-run|--yes] [--account a] [--json]',
|
|
7239
|
+
' advisers mail link <message> [--client id] [--project id] [--json]',
|
|
7240
|
+
' advisers mail dismiss <message> [--json]',
|
|
7214
7241
|
].join('\n')
|
|
7215
7242
|
|
|
7216
7243
|
function mailHumanRow(message) {
|
|
@@ -7541,10 +7568,32 @@ async function mailCommand(rawArgs) {
|
|
|
7541
7568
|
if (sub === 'extract') return await mailExtractCommand(rawArgs.slice(1))
|
|
7542
7569
|
if (sub === 'import') return await mailImportCommand(rawArgs.slice(1))
|
|
7543
7570
|
if (sub === 'purge') return await mailPurgeCommand(rawArgs.slice(1))
|
|
7571
|
+
if (sub === 'link') return await mailLinkCommand(rawArgs.slice(1), false)
|
|
7572
|
+
if (sub === 'dismiss') return await mailLinkCommand(rawArgs.slice(1), true)
|
|
7544
7573
|
usageFail('unknown mail subcommand: ' + sub, MAIL_USAGE)
|
|
7545
7574
|
} catch (error) { reportFamilyFailure(error) }
|
|
7546
7575
|
}
|
|
7547
7576
|
|
|
7577
|
+
/** mail link/dismiss: explicit review decisions on one imported message (0.4.x follow-up). */
|
|
7578
|
+
async function mailLinkCommand(rawArgs, dismiss = false) {
|
|
7579
|
+
const usage = dismiss
|
|
7580
|
+
? 'usage: advisers mail dismiss <message> [--json]'
|
|
7581
|
+
: 'usage: advisers mail link <message> [--client id] [--project id] [--json]'
|
|
7582
|
+
const parsed = familyFlags(rawArgs, { booleans: ['json'], values: ['client', 'project'] }, usage)
|
|
7583
|
+
if (!parsed) return
|
|
7584
|
+
const ref = parsed.positional[0]
|
|
7585
|
+
if (!ref) { usageFail('missing message id', usage); return }
|
|
7586
|
+
const mail = await loadMail()
|
|
7587
|
+
const store = familyStore({ write: true })
|
|
7588
|
+
const result = dismiss
|
|
7589
|
+
? mail.mailDismiss(store, ref, {})
|
|
7590
|
+
: mail.mailLink(store, ref, { clientId: parsed.flags.client, projectId: parsed.flags.project })
|
|
7591
|
+
if (parsed.flags.json) { console.log(JSON.stringify(result, null, 2)); return }
|
|
7592
|
+
const message = result.message
|
|
7593
|
+
console.log((dismiss ? 'dismissed ' : 'linked ') + message.id + ' [' + message.status + ']' + (message.clientId ? ' client=' + message.clientId : '') + (message.projectId ? ' project=' + message.projectId : ''))
|
|
7594
|
+
}
|
|
7595
|
+
|
|
7596
|
+
/* ------------------------- receivable / payment ------------------------- */
|
|
7548
7597
|
/* ------------------------- receivable / payment ------------------------- */
|
|
7549
7598
|
|
|
7550
7599
|
const RECEIVABLE_USAGE = [
|
|
@@ -10118,6 +10167,46 @@ function parseQuietHours(value) {
|
|
|
10118
10167
|
return { value: value }
|
|
10119
10168
|
}
|
|
10120
10169
|
|
|
10170
|
+
const QUIET_HOURS_PARTS_RE = /^([01]\d|2[0-3]):([0-5]\d)-([01]\d|2[0-3]):([0-5]\d)$/
|
|
10171
|
+
|
|
10172
|
+
/** Local minute-of-day in the agenda timezone (deterministic for --now tests). */
|
|
10173
|
+
function localMinuteOfDay(date) {
|
|
10174
|
+
const parts = new Intl.DateTimeFormat('en-GB', { timeZone: AGENDA_TIMEZONE, hour: '2-digit', minute: '2-digit', hour12: false }).formatToParts(date)
|
|
10175
|
+
const hour = Number(parts.find((part) => part.type === 'hour')?.value ?? 0) % 24
|
|
10176
|
+
const minute = Number(parts.find((part) => part.type === 'minute')?.value ?? 0)
|
|
10177
|
+
return hour * 60 + minute
|
|
10178
|
+
}
|
|
10179
|
+
|
|
10180
|
+
/** True when `date` falls inside a validated HH:MM-HH:MM quiet window (cross-midnight supported). */
|
|
10181
|
+
function isInsideQuietHours(spec, date) {
|
|
10182
|
+
const match = QUIET_HOURS_PARTS_RE.exec(String(spec ?? ''))
|
|
10183
|
+
if (!match) return false
|
|
10184
|
+
const start = Number(match[1]) * 60 + Number(match[2])
|
|
10185
|
+
const end = Number(match[3]) * 60 + Number(match[4])
|
|
10186
|
+
if (start === end) return false
|
|
10187
|
+
const minute = localMinuteOfDay(date)
|
|
10188
|
+
return start < end ? minute >= start && minute < end : minute >= start || minute < end
|
|
10189
|
+
}
|
|
10190
|
+
|
|
10191
|
+
/** Dedupe key for one reminder notification scoped to a local day. */
|
|
10192
|
+
function reminderNotifyDedupeKey(reminder, localDay) {
|
|
10193
|
+
return 'notify:dedupe:' + [reminder.commitmentId, reminder.bucket, reminder.ruleId, localDay].join('|')
|
|
10194
|
+
}
|
|
10195
|
+
|
|
10196
|
+
function localDayOfInstant(date) {
|
|
10197
|
+
return new Intl.DateTimeFormat('en-CA', { timeZone: AGENDA_TIMEZONE }).format(date)
|
|
10198
|
+
}
|
|
10199
|
+
|
|
10200
|
+
/** Drop dedupe keys older than 30 local days (bounded metadata growth). */
|
|
10201
|
+
function pruneNotifyDedupe(store, nowDate) {
|
|
10202
|
+
if (!store || typeof store.listMetaByPrefix !== 'function' || typeof store.deleteMeta !== 'function') return
|
|
10203
|
+
const cutoff = nowDate.getTime() - 30 * 86400_000
|
|
10204
|
+
for (const [key, value] of store.listMetaByPrefix('notify:dedupe:')) {
|
|
10205
|
+
const at = Date.parse(String(value ?? ''))
|
|
10206
|
+
if (Number.isFinite(at) && at < cutoff) store.deleteMeta(key)
|
|
10207
|
+
}
|
|
10208
|
+
}
|
|
10209
|
+
|
|
10121
10210
|
const HHMM_RE = /^([01]\d|2[0-3]):([0-5]\d)$/
|
|
10122
10211
|
function parseHhmm(value, flag) {
|
|
10123
10212
|
if (typeof value !== 'string' || !HHMM_RE.test(value)) return { error: flag + ' must be HH:MM' }
|
|
@@ -10314,7 +10403,11 @@ async function remind(args) {
|
|
|
10314
10403
|
// 0.4.0: --now pins planning and the echoed instant, so a fixed run is
|
|
10315
10404
|
// byte-reproducible (the same value is used by reminders/ICS/JSON/webhook).
|
|
10316
10405
|
const nowInfo = parseRemindNow(flags)
|
|
10317
|
-
if (nowInfo.error) { usageFail(nowInfo.error, 'usage: advisers remind [--json] [--now ISO] [--ics [path]] [--deliver [--notify]]'); return }
|
|
10406
|
+
if (nowInfo.error) { usageFail(nowInfo.error, 'usage: advisers remind [--json] [--now ISO] [--ics [path]] [--deliver [--notify]] [--quiet-hours HH:MM-HH:MM] [--force-notify]'); return }
|
|
10407
|
+
if (flags['quiet-hours'] !== undefined) {
|
|
10408
|
+
const quiet = parseQuietHours(flags['quiet-hours'])
|
|
10409
|
+
if (quiet.error) { usageFail(quiet.error, 'usage: advisers remind [--json] [--now ISO] [--ics [path]] [--deliver [--notify]] [--quiet-hours HH:MM-HH:MM] [--force-notify]'); return }
|
|
10410
|
+
}
|
|
10318
10411
|
const nowDate = nowInfo.date
|
|
10319
10412
|
// One prefix query instead of getMeta() per commitment (read-only store safe).
|
|
10320
10413
|
const snoozed = {}
|
|
@@ -10355,20 +10448,46 @@ async function remind(args) {
|
|
|
10355
10448
|
let channel = 'log'
|
|
10356
10449
|
if (flags.notify) {
|
|
10357
10450
|
const notify = await loadNotify()
|
|
10358
|
-
const
|
|
10359
|
-
|
|
10360
|
-
|
|
10361
|
-
|
|
10362
|
-
|
|
10363
|
-
//
|
|
10364
|
-
|
|
10365
|
-
|
|
10366
|
-
|
|
10367
|
-
|
|
10368
|
-
|
|
10369
|
-
|
|
10451
|
+
const forceNotify = flags['force-notify'] === true
|
|
10452
|
+
const quietSpec = typeof flags['quiet-hours'] === 'string' ? flags['quiet-hours'] : (typeof process.env.ADVISERS_QUIET_HOURS === 'string' ? process.env.ADVISERS_QUIET_HOURS : null)
|
|
10453
|
+
if (!forceNotify && quietSpec && isInsideQuietHours(quietSpec, nowDate)) {
|
|
10454
|
+
// Quiet hours are a delivery policy, not an error: the log line above is
|
|
10455
|
+
// still written, the channel is recorded as suppressed and the audit row
|
|
10456
|
+
// records why. --force-notify bypasses (for an explicit one-off).
|
|
10457
|
+
channel = 'quiet-suppressed'
|
|
10458
|
+
console.log('通知已静默:当前处于安静时段 ' + quietSpec + '(本地日志已记录;--force-notify 可强制发送)')
|
|
10459
|
+
} else {
|
|
10460
|
+
const localDay = localDayOfInstant(nowDate)
|
|
10461
|
+
let notifyList = reminders
|
|
10462
|
+
if (!forceNotify && store && typeof store.listMetaByPrefix === 'function') {
|
|
10463
|
+
const seen = new Set(store.listMetaByPrefix('notify:dedupe:').keys())
|
|
10464
|
+
notifyList = reminders.filter((reminder) => !seen.has(reminderNotifyDedupeKey(reminder, localDay)))
|
|
10465
|
+
if (!notifyList.length) {
|
|
10466
|
+
channel = 'deduped'
|
|
10467
|
+
console.log('通知已去重:本批提醒今天已经通知过(本地日志仍记录;--force-notify 可重发)')
|
|
10468
|
+
}
|
|
10370
10469
|
}
|
|
10371
|
-
|
|
10470
|
+
if (channel !== 'deduped') {
|
|
10471
|
+
const local = await notify.sendNotification({ title: 'Advisers · 到期提醒', body: notifyList.length + ' 条承诺到期或即将到期' })
|
|
10472
|
+
channel = local.sent ? local.channel : 'log-only'
|
|
10473
|
+
const webhook = await notify.sendWebhookNotification(notifyList, { now: nowDate })
|
|
10474
|
+
if (webhook.sent) {
|
|
10475
|
+
channel = channel === 'log-only' ? 'webhook' : channel + '+webhook'
|
|
10476
|
+
// 0.4.0: remember whether the delivery was signed, without changing the
|
|
10477
|
+
// payload bytes. A configured webhook with no secret still sends but says
|
|
10478
|
+
// so exactly once per process (sanitised, no secret material).
|
|
10479
|
+
if (typeof webhook.signing === 'string' && webhook.signing !== '') channel += '+signing:' + webhook.signing
|
|
10480
|
+
if (webhook.warning === 'missing-secret' && !webhookSecretWarned) {
|
|
10481
|
+
webhookSecretWarned = true
|
|
10482
|
+
console.error(sanitizeConsoleText('webhook 已配置但未设置 ADVISERS_NOTIFY_WEBHOOK_SECRET:本次按未签名发送(signing=none);建议设置 secret,否则接收端无法验证请求来源。', { max: 2000 }))
|
|
10483
|
+
}
|
|
10484
|
+
} else if (webhook.configured) { console.error(sanitizeConsoleText('webhook 未发送:' + (webhook.error ?? 'unknown') + (webhook.detail ? '(' + webhook.detail + ')' : ''), { max: 2000 })) }
|
|
10485
|
+
if (store && typeof store.setMeta === 'function') {
|
|
10486
|
+
for (const reminder of notifyList) store.setMeta(reminderNotifyDedupeKey(reminder, localDay), nowDate.toISOString())
|
|
10487
|
+
pruneNotifyDedupe(store, nowDate)
|
|
10488
|
+
}
|
|
10489
|
+
}
|
|
10490
|
+
}
|
|
10372
10491
|
}
|
|
10373
10492
|
store?.appendAudit({ actor: 'local', action: 'notify.delivered', allowed: true, reason: reminders.length + ' reminders channel=' + channel })
|
|
10374
10493
|
recordReminderRun(scheduler, { count: reminders.length, channel })
|
package/index.js
CHANGED
package/lib/mail.js
CHANGED
|
@@ -321,8 +321,8 @@ export function mailLink(store, ref, options = {}) {
|
|
|
321
321
|
mailDb.assertMailTables(store)
|
|
322
322
|
const now = asDate(options.now)
|
|
323
323
|
const message = mailDb.getMailMessage(store, ref)
|
|
324
|
-
const clientId = options.clientId == null ? message.clientId : String(options.clientId)
|
|
325
|
-
const projectId = options.projectId == null ? message.projectId : String(options.projectId)
|
|
324
|
+
const clientId = options.clientId == null ? (message.clientId ?? null) : String(options.clientId)
|
|
325
|
+
const projectId = options.projectId == null ? (message.projectId ?? null) : String(options.projectId)
|
|
326
326
|
const audit = { actor: options.actor ?? 'local', action: 'mail.link', allowed: true, reason: message.id }
|
|
327
327
|
const updated = store.mutate(() => mailDb.updateMailMessage(store, message.id, { clientId, projectId, status: 'linked' }, { now }), audit).result
|
|
328
328
|
return { ok: true, command: 'mail link', message: updated }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "advisers",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "A staff of AI advisers: a cordis-native personal secretary runtime with scoped memory, commitments, and reviewable routines.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cordis",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@pdf-lib/fontkit": "^1.1.1",
|
|
39
|
-
"advisers-core": "0.4.
|
|
40
|
-
"advisers-policy-strict": "0.4.
|
|
39
|
+
"advisers-core": "0.4.1",
|
|
40
|
+
"advisers-policy-strict": "0.4.1",
|
|
41
41
|
"jszip": "^3.10.2",
|
|
42
42
|
"pdf-lib": "^1.17.1",
|
|
43
43
|
"pdfjs-dist": "^6.5.438"
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"test": "node --experimental-strip-types --test test/*.test.js"
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
64
|
-
"advisers-office": "0.4.
|
|
64
|
+
"advisers-office": "0.4.1"
|
|
65
65
|
},
|
|
66
66
|
"peerDependenciesMeta": {
|
|
67
67
|
"advisers-office": {
|