@lornatang/dsh-caveman 0.1.5 → 0.1.6
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 +6 -0
- package/package.json +5 -1
- package/scripts/caveman-cli.mjs +30 -30
- package/scripts/learn-binary.mjs +82 -82
- package/scripts/learn-checksums.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.6 - 2026-11-19
|
|
4
|
+
|
|
5
|
+
- Compare endpoint host names instead of URL substrings when detecting provider hosts, so a crafted URL cannot satisfy a provider check by embedding a domain in its path (clears the js/incomplete-url-substring-sanitization findings).
|
|
6
|
+
- Override undici to 8.12.4 and @modelcontextprotocol/client to 2.4.0, clearing six Dependabot advisories.
|
|
7
|
+
- Keep the verified analyzer binaries attached to this release under the new version.
|
|
8
|
+
|
|
3
9
|
## 0.1.5 - 2026-11-19
|
|
4
10
|
|
|
5
11
|
- Cache the verified local runtime identity for one second per endpoint, so a tool call performs one health check instead of two while a runtime restart still invalidates sessions.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lornatang/dsh-caveman",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "Caveman integration for DeepSeek Harness.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -81,6 +81,10 @@
|
|
|
81
81
|
"undici": "^8.12.4",
|
|
82
82
|
"yaml": "^2.8.1"
|
|
83
83
|
},
|
|
84
|
+
"overrides": {
|
|
85
|
+
"undici": "$undici",
|
|
86
|
+
"@modelcontextprotocol/client": "^2.4.0"
|
|
87
|
+
},
|
|
84
88
|
"peerDependencies": {
|
|
85
89
|
"@deepseek-ai/cordis": "~4.1.0",
|
|
86
90
|
"@deepseek-ai/dsh-llm": "*"
|
package/scripts/caveman-cli.mjs
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { spawn } from 'node:child_process'
|
|
3
|
-
import { constants } from 'node:os'
|
|
4
|
-
import { createRequire } from 'node:module'
|
|
5
|
-
import { dirname, join } from 'node:path'
|
|
6
|
-
|
|
7
|
-
const require = createRequire(import.meta.url)
|
|
8
|
-
const cli = join(dirname(require.resolve('@caveman-ai/cli/package.json')), 'dist', 'index.js')
|
|
9
|
-
const args = process.argv.slice(2)
|
|
10
|
-
let learnBinary
|
|
11
|
-
if (args[0] === 'learn' && !['--help', '-h', 'help'].includes(args[1])) {
|
|
12
|
-
try { learnBinary = await (await import('./learn-binary.mjs')).resolveLearnBinary() }
|
|
13
|
-
catch (error) { console.error(`dsh-caveman: ${error.message}`); process.exit(1) }
|
|
14
|
-
}
|
|
15
|
-
const direct = learnBinary && args[1] === 'locate'
|
|
16
|
-
const child = spawn(direct ? learnBinary : process.execPath, direct ? args : [cli, ...args], {
|
|
17
|
-
stdio: 'inherit', windowsHide: true,
|
|
18
|
-
env: learnBinary ? { ...process.env, CAVEMAN_PROXY_BIN: learnBinary } : process.env,
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
for (const signal of ['SIGINT', 'SIGTERM']) {
|
|
22
|
-
process.on(signal, () => { if (child.exitCode === null && child.signalCode === null) child.kill(signal) })
|
|
23
|
-
}
|
|
24
|
-
child.once('error', error => {
|
|
25
|
-
console.error(`dsh-caveman: could not start the CLI: ${error.message}`)
|
|
26
|
-
process.exitCode = 1
|
|
27
|
-
})
|
|
28
|
-
child.once('exit', (code, signal) => {
|
|
29
|
-
process.exitCode = code ?? (signal ? 128 + (constants.signals[signal] ?? 0) : 1)
|
|
30
|
-
})
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { spawn } from 'node:child_process'
|
|
3
|
+
import { constants } from 'node:os'
|
|
4
|
+
import { createRequire } from 'node:module'
|
|
5
|
+
import { dirname, join } from 'node:path'
|
|
6
|
+
|
|
7
|
+
const require = createRequire(import.meta.url)
|
|
8
|
+
const cli = join(dirname(require.resolve('@caveman-ai/cli/package.json')), 'dist', 'index.js')
|
|
9
|
+
const args = process.argv.slice(2)
|
|
10
|
+
let learnBinary
|
|
11
|
+
if (args[0] === 'learn' && !['--help', '-h', 'help'].includes(args[1])) {
|
|
12
|
+
try { learnBinary = await (await import('./learn-binary.mjs')).resolveLearnBinary() }
|
|
13
|
+
catch (error) { console.error(`dsh-caveman: ${error.message}`); process.exit(1) }
|
|
14
|
+
}
|
|
15
|
+
const direct = learnBinary && args[1] === 'locate'
|
|
16
|
+
const child = spawn(direct ? learnBinary : process.execPath, direct ? args : [cli, ...args], {
|
|
17
|
+
stdio: 'inherit', windowsHide: true,
|
|
18
|
+
env: learnBinary ? { ...process.env, CAVEMAN_PROXY_BIN: learnBinary } : process.env,
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
for (const signal of ['SIGINT', 'SIGTERM']) {
|
|
22
|
+
process.on(signal, () => { if (child.exitCode === null && child.signalCode === null) child.kill(signal) })
|
|
23
|
+
}
|
|
24
|
+
child.once('error', error => {
|
|
25
|
+
console.error(`dsh-caveman: could not start the CLI: ${error.message}`)
|
|
26
|
+
process.exitCode = 1
|
|
27
|
+
})
|
|
28
|
+
child.once('exit', (code, signal) => {
|
|
29
|
+
process.exitCode = code ?? (signal ? 128 + (constants.signals[signal] ?? 0) : 1)
|
|
30
|
+
})
|
package/scripts/learn-binary.mjs
CHANGED
|
@@ -1,82 +1,82 @@
|
|
|
1
|
-
import { createHash, randomBytes } from 'node:crypto'
|
|
2
|
-
import { createReadStream } from 'node:fs'
|
|
3
|
-
import { chmod, mkdir, open, readFile, rename, rm } from 'node:fs/promises'
|
|
4
|
-
import { homedir } from 'node:os'
|
|
5
|
-
import { join } from 'node:path'
|
|
6
|
-
|
|
7
|
-
const MAX_BINARY_BYTES = 120 * 1024 * 1024
|
|
8
|
-
const manifestUrl = new URL('./learn-checksums.json', import.meta.url)
|
|
9
|
-
const packageUrl = new URL('../package.json', import.meta.url)
|
|
10
|
-
|
|
11
|
-
async function fileDigest(path) {
|
|
12
|
-
try {
|
|
13
|
-
const hash = createHash('sha256')
|
|
14
|
-
for await (const chunk of createReadStream(path)) hash.update(chunk)
|
|
15
|
-
return hash.digest('hex')
|
|
16
|
-
} catch (error) {
|
|
17
|
-
if (error?.code === 'ENOENT') return undefined
|
|
18
|
-
throw error
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/** Download and verify the executable once for the current platform and version. */
|
|
23
|
-
export async function resolveLearnBinary(options = {}) {
|
|
24
|
-
const { env = process.env, platform = process.platform, arch = process.arch } = options
|
|
25
|
-
if (env.DSH_CAVEMAN_LEARN_BINARY) return env.DSH_CAVEMAN_LEARN_BINARY
|
|
26
|
-
const manifest = options.manifest ?? JSON.parse(await readFile(manifestUrl, 'utf8'))
|
|
27
|
-
const version = JSON.parse(await readFile(packageUrl, 'utf8')).version
|
|
28
|
-
if (manifest.version !== version || !/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/u.test(version)) throw new Error('Invalid analyzer version manifest')
|
|
29
|
-
const os = { linux: 'linux', darwin: 'darwin', win32: 'win32' }[platform]
|
|
30
|
-
const cpu = { x64: 'amd64', arm64: 'arm64' }[arch]
|
|
31
|
-
const entry = manifest.binaries?.[`${platform}-${arch}`]
|
|
32
|
-
const expectedName = os && cpu ? `dsh-caveman-learn_${os}_${cpu}` : undefined
|
|
33
|
-
if (!expectedName || entry?.name !== expectedName || !/^[a-f0-9]{64}$/u.test(entry.sha256 ?? '')) {
|
|
34
|
-
throw new Error(`No verified analyzer is available for ${platform}/${arch}`)
|
|
35
|
-
}
|
|
36
|
-
const directory = join(options.cacheRoot ?? join(homedir(), '.dsh', 'cache', 'dsh-caveman', 'learn'), version)
|
|
37
|
-
const target = join(directory, `${expectedName}${platform === 'win32' ? '.exe' : ''}`)
|
|
38
|
-
if (await fileDigest(target) === entry.sha256) return target
|
|
39
|
-
await mkdir(directory, { recursive: true, mode: 0o700 })
|
|
40
|
-
const temporary = join(directory, `.${expectedName}.${randomBytes(12).toString('hex')}.tmp`)
|
|
41
|
-
let handle
|
|
42
|
-
let dispatcher
|
|
43
|
-
try {
|
|
44
|
-
const url = `https://github.com/Lornatang/dsh-caveman/releases/download/v${version}/${expectedName}`
|
|
45
|
-
let fetcher = options.fetcher ?? fetch
|
|
46
|
-
if (!options.fetcher && (env.https_proxy || env.HTTPS_PROXY || env.http_proxy || env.HTTP_PROXY)) {
|
|
47
|
-
const { EnvHttpProxyAgent, fetch: proxyFetch } = await import('undici')
|
|
48
|
-
dispatcher = new EnvHttpProxyAgent({
|
|
49
|
-
httpProxy: env.http_proxy ?? env.HTTP_PROXY ?? '',
|
|
50
|
-
httpsProxy: env.https_proxy ?? env.HTTPS_PROXY ?? '',
|
|
51
|
-
noProxy: env.no_proxy ?? env.NO_PROXY ?? '',
|
|
52
|
-
})
|
|
53
|
-
fetcher = (input, init) => proxyFetch(input, { ...init, dispatcher })
|
|
54
|
-
}
|
|
55
|
-
const response = await fetcher(url, { signal: AbortSignal.timeout(120_000) })
|
|
56
|
-
if (!response.ok || !response.body) throw new Error(`Analyzer download failed (HTTP ${response.status})`)
|
|
57
|
-
const advertised = Number(response.headers.get('content-length'))
|
|
58
|
-
if (advertised > MAX_BINARY_BYTES) throw new Error('Analyzer download exceeds the size limit')
|
|
59
|
-
handle = await open(temporary, 'wx', 0o700)
|
|
60
|
-
const hash = createHash('sha256')
|
|
61
|
-
let size = 0
|
|
62
|
-
for await (const chunk of response.body) {
|
|
63
|
-
size += chunk.length
|
|
64
|
-
if (size > MAX_BINARY_BYTES) throw new Error('Analyzer download exceeds the size limit')
|
|
65
|
-
hash.update(chunk)
|
|
66
|
-
await handle.writeFile(chunk)
|
|
67
|
-
}
|
|
68
|
-
await handle.close()
|
|
69
|
-
handle = undefined
|
|
70
|
-
if (hash.digest('hex') !== entry.sha256) throw new Error('Analyzer checksum mismatch')
|
|
71
|
-
await chmod(temporary, 0o700)
|
|
72
|
-
try { await rename(temporary, target) } catch (error) {
|
|
73
|
-
// Another invocation may have finished the same verified download.
|
|
74
|
-
if (await fileDigest(target) !== entry.sha256) throw error
|
|
75
|
-
}
|
|
76
|
-
return target
|
|
77
|
-
} finally {
|
|
78
|
-
await handle?.close().catch(() => {})
|
|
79
|
-
await rm(temporary, { force: true }).catch(() => {})
|
|
80
|
-
await dispatcher?.destroy().catch(() => {})
|
|
81
|
-
}
|
|
82
|
-
}
|
|
1
|
+
import { createHash, randomBytes } from 'node:crypto'
|
|
2
|
+
import { createReadStream } from 'node:fs'
|
|
3
|
+
import { chmod, mkdir, open, readFile, rename, rm } from 'node:fs/promises'
|
|
4
|
+
import { homedir } from 'node:os'
|
|
5
|
+
import { join } from 'node:path'
|
|
6
|
+
|
|
7
|
+
const MAX_BINARY_BYTES = 120 * 1024 * 1024
|
|
8
|
+
const manifestUrl = new URL('./learn-checksums.json', import.meta.url)
|
|
9
|
+
const packageUrl = new URL('../package.json', import.meta.url)
|
|
10
|
+
|
|
11
|
+
async function fileDigest(path) {
|
|
12
|
+
try {
|
|
13
|
+
const hash = createHash('sha256')
|
|
14
|
+
for await (const chunk of createReadStream(path)) hash.update(chunk)
|
|
15
|
+
return hash.digest('hex')
|
|
16
|
+
} catch (error) {
|
|
17
|
+
if (error?.code === 'ENOENT') return undefined
|
|
18
|
+
throw error
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Download and verify the executable once for the current platform and version. */
|
|
23
|
+
export async function resolveLearnBinary(options = {}) {
|
|
24
|
+
const { env = process.env, platform = process.platform, arch = process.arch } = options
|
|
25
|
+
if (env.DSH_CAVEMAN_LEARN_BINARY) return env.DSH_CAVEMAN_LEARN_BINARY
|
|
26
|
+
const manifest = options.manifest ?? JSON.parse(await readFile(manifestUrl, 'utf8'))
|
|
27
|
+
const version = JSON.parse(await readFile(packageUrl, 'utf8')).version
|
|
28
|
+
if (manifest.version !== version || !/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/u.test(version)) throw new Error('Invalid analyzer version manifest')
|
|
29
|
+
const os = { linux: 'linux', darwin: 'darwin', win32: 'win32' }[platform]
|
|
30
|
+
const cpu = { x64: 'amd64', arm64: 'arm64' }[arch]
|
|
31
|
+
const entry = manifest.binaries?.[`${platform}-${arch}`]
|
|
32
|
+
const expectedName = os && cpu ? `dsh-caveman-learn_${os}_${cpu}` : undefined
|
|
33
|
+
if (!expectedName || entry?.name !== expectedName || !/^[a-f0-9]{64}$/u.test(entry.sha256 ?? '')) {
|
|
34
|
+
throw new Error(`No verified analyzer is available for ${platform}/${arch}`)
|
|
35
|
+
}
|
|
36
|
+
const directory = join(options.cacheRoot ?? join(homedir(), '.dsh', 'cache', 'dsh-caveman', 'learn'), version)
|
|
37
|
+
const target = join(directory, `${expectedName}${platform === 'win32' ? '.exe' : ''}`)
|
|
38
|
+
if (await fileDigest(target) === entry.sha256) return target
|
|
39
|
+
await mkdir(directory, { recursive: true, mode: 0o700 })
|
|
40
|
+
const temporary = join(directory, `.${expectedName}.${randomBytes(12).toString('hex')}.tmp`)
|
|
41
|
+
let handle
|
|
42
|
+
let dispatcher
|
|
43
|
+
try {
|
|
44
|
+
const url = `https://github.com/Lornatang/dsh-caveman/releases/download/v${version}/${expectedName}`
|
|
45
|
+
let fetcher = options.fetcher ?? fetch
|
|
46
|
+
if (!options.fetcher && (env.https_proxy || env.HTTPS_PROXY || env.http_proxy || env.HTTP_PROXY)) {
|
|
47
|
+
const { EnvHttpProxyAgent, fetch: proxyFetch } = await import('undici')
|
|
48
|
+
dispatcher = new EnvHttpProxyAgent({
|
|
49
|
+
httpProxy: env.http_proxy ?? env.HTTP_PROXY ?? '',
|
|
50
|
+
httpsProxy: env.https_proxy ?? env.HTTPS_PROXY ?? '',
|
|
51
|
+
noProxy: env.no_proxy ?? env.NO_PROXY ?? '',
|
|
52
|
+
})
|
|
53
|
+
fetcher = (input, init) => proxyFetch(input, { ...init, dispatcher })
|
|
54
|
+
}
|
|
55
|
+
const response = await fetcher(url, { signal: AbortSignal.timeout(120_000) })
|
|
56
|
+
if (!response.ok || !response.body) throw new Error(`Analyzer download failed (HTTP ${response.status})`)
|
|
57
|
+
const advertised = Number(response.headers.get('content-length'))
|
|
58
|
+
if (advertised > MAX_BINARY_BYTES) throw new Error('Analyzer download exceeds the size limit')
|
|
59
|
+
handle = await open(temporary, 'wx', 0o700)
|
|
60
|
+
const hash = createHash('sha256')
|
|
61
|
+
let size = 0
|
|
62
|
+
for await (const chunk of response.body) {
|
|
63
|
+
size += chunk.length
|
|
64
|
+
if (size > MAX_BINARY_BYTES) throw new Error('Analyzer download exceeds the size limit')
|
|
65
|
+
hash.update(chunk)
|
|
66
|
+
await handle.writeFile(chunk)
|
|
67
|
+
}
|
|
68
|
+
await handle.close()
|
|
69
|
+
handle = undefined
|
|
70
|
+
if (hash.digest('hex') !== entry.sha256) throw new Error('Analyzer checksum mismatch')
|
|
71
|
+
await chmod(temporary, 0o700)
|
|
72
|
+
try { await rename(temporary, target) } catch (error) {
|
|
73
|
+
// Another invocation may have finished the same verified download.
|
|
74
|
+
if (await fileDigest(target) !== entry.sha256) throw error
|
|
75
|
+
}
|
|
76
|
+
return target
|
|
77
|
+
} finally {
|
|
78
|
+
await handle?.close().catch(() => {})
|
|
79
|
+
await rm(temporary, { force: true }).catch(() => {})
|
|
80
|
+
await dispatcher?.destroy().catch(() => {})
|
|
81
|
+
}
|
|
82
|
+
}
|