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
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read-only ledger snapshot loader for `advisers pet-brief`.
|
|
3
|
+
*
|
|
4
|
+
* Unlike `loadLedger()` in the CLI, this never creates, migrates, or writes
|
|
5
|
+
* the store: it opens SQLite with `readOnly: true`, or reads `state.json`
|
|
6
|
+
* as-is. Used only by the Pet Brief producer path.
|
|
7
|
+
*/
|
|
8
|
+
import { existsSync, readFileSync } from 'node:fs'
|
|
9
|
+
import { SqliteStore } from './sqlite.js'
|
|
10
|
+
|
|
11
|
+
export class PetBriefStoreError extends Error {
|
|
12
|
+
constructor(code, message) {
|
|
13
|
+
super(message)
|
|
14
|
+
this.name = 'PetBriefStoreError'
|
|
15
|
+
this.code = code
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @param {object} options
|
|
21
|
+
* @param {'sqlite'|'json'} [options.store] store backend (ADVISERS_STORE)
|
|
22
|
+
* @param {string} options.dbPath SQLite database path
|
|
23
|
+
* @param {string} options.statePath JSON ledger path
|
|
24
|
+
* @returns {object} LedgerSnapshot v1 (plain JSON object)
|
|
25
|
+
*/
|
|
26
|
+
export function readLedgerSnapshotReadOnly({ store = 'sqlite', dbPath, statePath } = {}) {
|
|
27
|
+
if (store === 'json') {
|
|
28
|
+
if (!statePath || !existsSync(statePath)) {
|
|
29
|
+
throw new PetBriefStoreError('E_STORE', `store not found: ${statePath ?? '(no state path)'}; run \`advisers init\``)
|
|
30
|
+
}
|
|
31
|
+
try {
|
|
32
|
+
return JSON.parse(readFileSync(statePath, 'utf8'))
|
|
33
|
+
} catch (error) {
|
|
34
|
+
throw new PetBriefStoreError('E_STORE', `cannot read JSON ledger ${statePath}: ${error.message}`)
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
if (!dbPath || !existsSync(dbPath)) {
|
|
38
|
+
throw new PetBriefStoreError('E_STORE', `store not found: ${dbPath ?? '(no database path)'}; run \`advisers init\``)
|
|
39
|
+
}
|
|
40
|
+
let database
|
|
41
|
+
try {
|
|
42
|
+
database = new SqliteStore(dbPath, { readOnly: true })
|
|
43
|
+
return database.load()
|
|
44
|
+
} catch (error) {
|
|
45
|
+
throw new PetBriefStoreError('E_STORE', `cannot read SQLite store ${dbPath} read-only: ${error.message}`)
|
|
46
|
+
} finally {
|
|
47
|
+
if (database) {
|
|
48
|
+
try { database.close() } catch {}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|