advisers 0.1.0-preview.4 → 0.2.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/LICENSE +131 -21
- package/NOTICE +34 -0
- package/README-zh.md +40 -9
- package/README.md +53 -10
- package/THIRD-PARTY-NOTICES.md +277 -0
- package/bin/advisers.js +4230 -122
- package/index.js +1 -1
- package/lib/agent.js +414 -0
- package/lib/attachments.js +283 -0
- package/lib/capture.js +168 -0
- package/lib/context-window.js +123 -0
- package/lib/digest.js +27 -0
- package/lib/doc-review.js +30 -0
- package/lib/egress.js +27 -0
- package/lib/evidence.js +1995 -0
- package/lib/ical.js +542 -0
- package/lib/imap.js +181 -0
- package/lib/importers.js +1001 -0
- package/lib/learning.js +46 -0
- package/lib/mcp-server.js +869 -0
- package/lib/model.js +307 -0
- package/lib/notify.js +189 -0
- package/lib/nudge.js +10 -0
- package/lib/ocr.js +47 -0
- package/lib/pdf.js +105 -0
- package/lib/pet-brief-store.js +51 -0
- package/lib/pet-brief.js +644 -0
- package/lib/receipt-verify.js +624 -0
- package/lib/relative-date.js +393 -0
- package/lib/remind.js +690 -0
- package/lib/research.js +193 -0
- package/lib/review.js +88 -0
- package/lib/routine.js +22 -0
- package/lib/safety/classifier.js +392 -0
- package/lib/safety/explain.js +157 -0
- package/lib/safety/index.js +333 -0
- package/lib/safety/redact.js +212 -0
- package/lib/safety/rules.js +824 -0
- package/lib/scheduler.js +399 -0
- package/lib/source.js +294 -0
- package/lib/sqlite.js +1022 -0
- package/lib/sync.js +129 -0
- package/lib/timestamp.js +45 -0
- package/lib/tos/index.js +332 -0
- package/lib/tos/manifest.json +32 -0
- package/lib/tos/privacy.zh-CN.md +136 -0
- package/lib/tos/safety.zh-CN.md +101 -0
- package/lib/tos/summary.zh-CN.md +12 -0
- package/lib/tos/terms.zh-CN.md +439 -0
- package/lib/ui.js +49 -0
- package/lib/undo.js +83 -0
- package/lib/vault.js +51 -0
- package/package.json +26 -4
package/lib/learning.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
const CORRECTION_START = /^(不是|不对|错了|应该|以后|记住|每次|改成|改一下)/
|
|
2
|
+
const MAX_STATEMENT = 160
|
|
3
|
+
|
|
4
|
+
/** Extract a correction/preference statement from a short user message. */
|
|
5
|
+
export function correctionStatement(text) {
|
|
6
|
+
const raw = typeof text === 'string' ? text.trim() : ''
|
|
7
|
+
if (!raw || raw.length > MAX_STATEMENT || !CORRECTION_START.test(raw)) return null
|
|
8
|
+
const contrast = raw.match(/^不是(.+?)[,,]\s*(?:而)?是(.+)$/)
|
|
9
|
+
if (contrast) return contrast[2].trim()
|
|
10
|
+
const rewrite = raw.match(/^(?:改成|改一下|应该)\s*(.+)$/)
|
|
11
|
+
if (rewrite) return rewrite[1].trim()
|
|
12
|
+
return raw
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** Exponential decay per 30 days; deprecated below 0.3. */
|
|
16
|
+
export function applyPreferenceDecay(preferences, now = new Date(), days = 30) {
|
|
17
|
+
const changed = []
|
|
18
|
+
for (const pref of preferences) {
|
|
19
|
+
if (pref.status === 'deprecated') continue
|
|
20
|
+
if (pref.priority === 'hard') continue
|
|
21
|
+
const last = new Date(pref.lastConfirmed ?? pref.validFrom).getTime()
|
|
22
|
+
const ageDays = (now.getTime() - last) / 86_400_000
|
|
23
|
+
if (!Number.isFinite(ageDays) || ageDays < days) continue
|
|
24
|
+
const periods = Math.floor(ageDays / days)
|
|
25
|
+
pref.confidence = Math.max(0, pref.confidence * Math.pow(0.8, periods))
|
|
26
|
+
if (pref.confidence < 0.3) pref.status = 'deprecated'
|
|
27
|
+
changed.push(pref)
|
|
28
|
+
}
|
|
29
|
+
return changed
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** A successful multi-tool task becomes a draft routine, never auto-active. */
|
|
33
|
+
export function buildRoutineCandidate({ text, toolLog = [], artifacts = [] }) {
|
|
34
|
+
const tools = [...new Set(toolLog.map((t) => t.name).filter(Boolean))]
|
|
35
|
+
if (tools.length < 3 || artifacts.length === 0) return null
|
|
36
|
+
return {
|
|
37
|
+
name: text.replace(/\s+/g, ' ').slice(0, 60),
|
|
38
|
+
description: '从一次多工具任务沉淀的流程草稿',
|
|
39
|
+
trigger: [],
|
|
40
|
+
steps: tools,
|
|
41
|
+
preferences: [],
|
|
42
|
+
pitfalls: [],
|
|
43
|
+
verification: artifacts.map((file) => `file:${file}`),
|
|
44
|
+
createdBy: 'agent',
|
|
45
|
+
}
|
|
46
|
+
}
|