mino-connector-wechat 0.1.0 → 0.1.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/hostdeps.mjs +30 -65
- package/package.json +2 -2
package/hostdeps.mjs
CHANGED
|
@@ -1,74 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* 本包只需要 defineTool 一个件。
|
|
6
|
-
*/
|
|
7
|
-
import { existsSync, readFileSync, readdirSync } from 'node:fs'
|
|
8
|
-
import { join, dirname } from 'node:path'
|
|
9
|
-
import { homedir } from 'node:os'
|
|
10
|
-
import { fileURLToPath, pathToFileURL } from 'node:url'
|
|
1
|
+
// Canonical host API loader. Generate packaged copies with scripts/sync-hostdeps.mjs.
|
|
2
|
+
import { createRequire } from 'node:module'
|
|
3
|
+
import { join, resolve } from 'node:path'
|
|
4
|
+
import { pathToFileURL } from 'node:url'
|
|
11
5
|
|
|
12
|
-
|
|
6
|
+
function resolverOrigins(name) {
|
|
7
|
+
const origins = []
|
|
8
|
+
// An explicit development host and the current Electron installation own these APIs.
|
|
9
|
+
if (process.env.DSH_HOST_MODULES) origins.push(join(process.env.DSH_HOST_MODULES, name, 'package.json'))
|
|
10
|
+
if (process.resourcesPath) origins.push(join(process.resourcesPath, 'app.asar', 'dsh', 'node_modules', '@deepseek-ai', name, 'package.json'))
|
|
11
|
+
if (process.argv[1]) origins.push(resolve(process.argv[1]))
|
|
12
|
+
origins.push(import.meta.url)
|
|
13
|
+
return [...new Set(origins)]
|
|
14
|
+
}
|
|
13
15
|
|
|
14
|
-
function
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
push(process.env.DSH_HOST_MODULES)
|
|
18
|
-
const appdata = process.env.APPDATA
|
|
19
|
-
if (appdata) {
|
|
20
|
-
const npm = join(appdata, 'npm', 'node_modules')
|
|
21
|
-
push(join(npm, '@deepseek-ai'))
|
|
16
|
+
async function loadLibrary(name, notes) {
|
|
17
|
+
const failures = []
|
|
18
|
+
for (const origin of resolverOrigins(name)) {
|
|
22
19
|
try {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
|
|
20
|
+
const entry = createRequire(origin).resolve(`@deepseek-ai/${name}`)
|
|
21
|
+
const module = await import(pathToFileURL(entry).href)
|
|
22
|
+
notes.push(`${name}: ${entry}`)
|
|
23
|
+
return module
|
|
24
|
+
} catch (error) { failures.push(error) }
|
|
27
25
|
}
|
|
28
|
-
|
|
29
|
-
const dshHome = process.env.DSH_HOME || join(homedir(), '.dsh')
|
|
30
|
-
for (const p of readdirSync(join(dshHome, 'profiles'))) {
|
|
31
|
-
push(join(dshHome, 'profiles', p, 'node_modules', '@deepseek-ai'))
|
|
32
|
-
}
|
|
33
|
-
} catch { /* 没有就算了 */ }
|
|
34
|
-
push(SELF_MODULES)
|
|
35
|
-
return out
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function entryUrlFor(root, name) {
|
|
39
|
-
try {
|
|
40
|
-
const dir = join(root, name)
|
|
41
|
-
const pkgFile = join(dir, 'package.json')
|
|
42
|
-
if (!existsSync(pkgFile)) return null
|
|
43
|
-
const pkg = JSON.parse(readFileSync(pkgFile, 'utf8'))
|
|
44
|
-
const dot = pkg.exports?.['.']
|
|
45
|
-
const rel = typeof dot === 'string' ? dot : (dot?.import || dot?.default || pkg.module || pkg.main)
|
|
46
|
-
if (!rel) return null
|
|
47
|
-
const file = join(dir, String(rel).replace(/^\.\//, ''))
|
|
48
|
-
return existsSync(file) ? pathToFileURL(file).href : null
|
|
49
|
-
} catch { return null }
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function localDefineTool(options) {
|
|
53
|
-
return options
|
|
26
|
+
throw new AggregateError(failures, `Host API @deepseek-ai/${name} is unavailable`)
|
|
54
27
|
}
|
|
55
28
|
|
|
56
29
|
export async function loadHostDeps() {
|
|
57
30
|
const notes = []
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
let
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
catch { /* try next root */ }
|
|
67
|
-
}
|
|
68
|
-
if (!dtMod) {
|
|
69
|
-
try { dtMod = await import('@deepseek-ai/dsh-tools'); log('dsh-tools:用自己依赖里那份') }
|
|
70
|
-
catch (e) { log(`dsh-tools 拿不到(${e?.code || ''})—— 用本地等价实现顶上`); dtMod = null }
|
|
71
|
-
}
|
|
72
|
-
defineTool = dtMod?.defineTool || ((options) => localDefineTool(options))
|
|
73
|
-
return { defineTool, notes }
|
|
31
|
+
const tools = await loadLibrary('dsh-tools', notes)
|
|
32
|
+
if (typeof tools.defineTool !== 'function') throw new Error('Required host API @deepseek-ai/dsh-tools.defineTool is unavailable')
|
|
33
|
+
let z = null
|
|
34
|
+
try {
|
|
35
|
+
const schema = await loadLibrary('schemastery', notes)
|
|
36
|
+
z = schema.default ?? schema
|
|
37
|
+
} catch (error) { notes.push(error.message) }
|
|
38
|
+
return { z, defineTool: tools.defineTool, notes }
|
|
74
39
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mino-connector-wechat",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "微信本地语料连接器:定位 WeChat 数据目录/进程,封装导出引擎(wechat-dump-rs/PyWxDump)做内存取钥+库解密,明文落 chat.db 检索。特区解封,用户自己的数据。",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dsh",
|
|
@@ -42,4 +42,4 @@
|
|
|
42
42
|
"bugs": {
|
|
43
43
|
"url": "https://github.com/694410194/mino-plugins/issues"
|
|
44
44
|
}
|
|
45
|
-
}
|
|
45
|
+
}
|