pinokiod 7.4.3 → 7.5.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/kernel/bin/conda-meta.js +13 -13
- package/kernel/bin/conda-pins.js +9 -7
- package/kernel/bin/conda.js +142 -203
- package/kernel/bin/cuda.js +7 -7
- package/kernel/bin/index.js +8 -12
- package/kernel/connect/providers/huggingface/index.js +4 -4
- package/kernel/index.js +0 -7
- package/kernel/shell.js +5 -4
- package/kernel/sysinfo.js +1 -1
- package/kernel/util.js +2 -2
- package/package.json +1 -1
- package/server/index.js +3 -4
- package/system/plugin/claude/pinokio.js +2 -2
- package/system/plugin/claude-auto/pinokio.js +2 -2
- package/system/plugin/codex/pinokio.js +1 -1
- package/system/plugin/codex-auto/pinokio.js +1 -1
- package/test/conda-bin.test.js +254 -0
- package/kernel/legacy_cleanup/ffmpeg.js +0 -133
- package/kernel/legacy_cleanup/index.js +0 -47
- package/test/legacy-cleanup.test.js +0 -161
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
const fs = require('fs')
|
|
2
|
-
const path = require('path')
|
|
3
|
-
|
|
4
|
-
const LEGACY_FFMPEG_HOOK_NAMES = [
|
|
5
|
-
'zz_pinokio_ffmpeg.sh',
|
|
6
|
-
'zz_pinokio_ffmpeg.bat',
|
|
7
|
-
'zz_pinokio_ffmpeg.ps1',
|
|
8
|
-
]
|
|
9
|
-
|
|
10
|
-
const REMOVE_RETRY_COUNT = 5
|
|
11
|
-
const REMOVE_RETRY_DELAY_MS = 100
|
|
12
|
-
|
|
13
|
-
async function pathExists(target) {
|
|
14
|
-
return fs.promises.access(target).then(() => true).catch(() => false)
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function legacyFfmpegRuntimePaths(kernel) {
|
|
18
|
-
if (!kernel || !kernel.bin || typeof kernel.bin.path !== 'function') {
|
|
19
|
-
return []
|
|
20
|
-
}
|
|
21
|
-
return [
|
|
22
|
-
kernel.bin.path('ffmpeg-env'),
|
|
23
|
-
kernel.bin.path('ffmpeg-pkgs'),
|
|
24
|
-
kernel.bin.path('ffmpeg'),
|
|
25
|
-
kernel.bin.path('ffmpeg-tmp'),
|
|
26
|
-
]
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function legacyFfmpegHookFiles(kernel) {
|
|
30
|
-
if (!kernel || !kernel.bin || typeof kernel.bin.path !== 'function') {
|
|
31
|
-
return []
|
|
32
|
-
}
|
|
33
|
-
const dirs = [
|
|
34
|
-
kernel.bin.path('miniconda', 'etc', 'conda', 'activate.d'),
|
|
35
|
-
kernel.bin.path('miniconda', 'etc', 'conda', 'deactivate.d'),
|
|
36
|
-
]
|
|
37
|
-
return dirs.flatMap((dir) => LEGACY_FFMPEG_HOOK_NAMES.map((name) => path.resolve(dir, name)))
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function manualFfmpegHookCleanupMessage(failures) {
|
|
41
|
-
const files = failures.map((failure) => failure.target)
|
|
42
|
-
return [
|
|
43
|
-
'Pinokio could not remove old FFmpeg Conda activation hooks.',
|
|
44
|
-
'',
|
|
45
|
-
'These old hooks can break the base Conda environment by adding the removed ffmpeg-env runtime to PATH.',
|
|
46
|
-
'',
|
|
47
|
-
'Close all Pinokio windows and any terminals using Pinokio, then delete these files if they exist:',
|
|
48
|
-
...files.map((file) => `- ${file}`),
|
|
49
|
-
'',
|
|
50
|
-
'After deleting them, reopen Pinokio.',
|
|
51
|
-
].join('\n')
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
class LegacyFfmpegCleanupError extends Error {
|
|
55
|
-
constructor(failures) {
|
|
56
|
-
super(manualFfmpegHookCleanupMessage(failures))
|
|
57
|
-
this.name = 'LegacyFfmpegCleanupError'
|
|
58
|
-
this.failures = failures
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
async function hasAnyPath(paths) {
|
|
63
|
-
for (const target of paths) {
|
|
64
|
-
if (await pathExists(target)) {
|
|
65
|
-
return true
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
return false
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
async function hasCleanupTargets(kernel) {
|
|
72
|
-
return await hasAnyPath(legacyFfmpegHookFiles(kernel)) ||
|
|
73
|
-
await hasAnyPath(legacyFfmpegRuntimePaths(kernel))
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
async function removeLegacyPath(target, ondata) {
|
|
77
|
-
const existed = await pathExists(target)
|
|
78
|
-
if (!existed) {
|
|
79
|
-
return { target, found: false, removed: false }
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
try {
|
|
83
|
-
await fs.promises.rm(target, {
|
|
84
|
-
recursive: true,
|
|
85
|
-
force: true,
|
|
86
|
-
maxRetries: REMOVE_RETRY_COUNT,
|
|
87
|
-
retryDelay: REMOVE_RETRY_DELAY_MS,
|
|
88
|
-
})
|
|
89
|
-
} catch (error) {
|
|
90
|
-
if (ondata) {
|
|
91
|
-
const reason = error && (error.code || error.message) ? error.code || error.message : String(error)
|
|
92
|
-
ondata({ raw: `could not remove legacy path: ${target} (${reason})\r\n` })
|
|
93
|
-
}
|
|
94
|
-
return { target, found: true, removed: false, error }
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
if (ondata) {
|
|
98
|
-
ondata({ raw: `removed legacy path: ${target}\r\n` })
|
|
99
|
-
}
|
|
100
|
-
return { target, found: true, removed: true }
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
async function run(kernel, ondata) {
|
|
104
|
-
const results = []
|
|
105
|
-
const hookFailures = []
|
|
106
|
-
|
|
107
|
-
for (const target of legacyFfmpegHookFiles(kernel)) {
|
|
108
|
-
const result = await removeLegacyPath(target, ondata)
|
|
109
|
-
results.push(result)
|
|
110
|
-
if (result.found && !result.removed) {
|
|
111
|
-
hookFailures.push(result)
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
if (hookFailures.length > 0) {
|
|
116
|
-
throw new LegacyFfmpegCleanupError(hookFailures)
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
for (const target of legacyFfmpegRuntimePaths(kernel)) {
|
|
120
|
-
results.push(await removeLegacyPath(target, ondata))
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
return results
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
module.exports = {
|
|
127
|
-
LegacyFfmpegCleanupError,
|
|
128
|
-
hasCleanupTargets,
|
|
129
|
-
legacyFfmpegHookFiles,
|
|
130
|
-
legacyFfmpegRuntimePaths,
|
|
131
|
-
name: 'ffmpeg',
|
|
132
|
-
run,
|
|
133
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
const path = require('path')
|
|
2
|
-
const ffmpeg = require('./ffmpeg')
|
|
3
|
-
|
|
4
|
-
const CLEANUPS = [
|
|
5
|
-
ffmpeg,
|
|
6
|
-
]
|
|
7
|
-
|
|
8
|
-
class LegacyCleanup {
|
|
9
|
-
constructor(kernel) {
|
|
10
|
-
this.kernel = kernel
|
|
11
|
-
this.promises = new Map()
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
async runOnce(ondata) {
|
|
15
|
-
const home = this.kernel && this.kernel.homedir ? path.resolve(this.kernel.homedir) : ''
|
|
16
|
-
if (this.promises.has(home)) {
|
|
17
|
-
return this.promises.get(home)
|
|
18
|
-
}
|
|
19
|
-
const promise = this.run(ondata).catch((error) => {
|
|
20
|
-
this.promises.delete(home)
|
|
21
|
-
throw error
|
|
22
|
-
})
|
|
23
|
-
this.promises.set(home, promise)
|
|
24
|
-
return promise
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
async run(ondata) {
|
|
28
|
-
if (!this.kernel || !this.kernel.homedir) {
|
|
29
|
-
return { skipped: true, results: [] }
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const cleanupResults = []
|
|
33
|
-
for (const cleanup of CLEANUPS) {
|
|
34
|
-
if (await cleanup.hasCleanupTargets(this.kernel)) {
|
|
35
|
-
cleanupResults.push({
|
|
36
|
-
name: cleanup.name || 'legacy',
|
|
37
|
-
results: await cleanup.run(this.kernel, ondata),
|
|
38
|
-
})
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return { skipped: false, results: cleanupResults }
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
module.exports = LegacyCleanup
|
|
47
|
-
module.exports.ffmpeg = ffmpeg
|
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
const assert = require('node:assert/strict')
|
|
2
|
-
const fsSync = require('node:fs')
|
|
3
|
-
const fs = require('node:fs/promises')
|
|
4
|
-
const os = require('node:os')
|
|
5
|
-
const path = require('node:path')
|
|
6
|
-
const test = require('node:test')
|
|
7
|
-
|
|
8
|
-
const LegacyCleanup = require('../kernel/legacy_cleanup')
|
|
9
|
-
|
|
10
|
-
function createKernel(root) {
|
|
11
|
-
return {
|
|
12
|
-
homedir: root,
|
|
13
|
-
bin: {
|
|
14
|
-
path: (...parts) => path.join(root, 'bin', ...parts),
|
|
15
|
-
},
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
async function writeFixtureFile(filepath) {
|
|
20
|
-
await fs.mkdir(path.dirname(filepath), { recursive: true })
|
|
21
|
-
await fs.writeFile(filepath, 'legacy\n')
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
async function exists(filepath) {
|
|
25
|
-
try {
|
|
26
|
-
await fs.access(filepath)
|
|
27
|
-
return true
|
|
28
|
-
} catch (_) {
|
|
29
|
-
return false
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
async function createLegacyFfmpegState(root) {
|
|
34
|
-
const activate = path.join(root, 'bin', 'miniconda', 'etc', 'conda', 'activate.d')
|
|
35
|
-
const deactivate = path.join(root, 'bin', 'miniconda', 'etc', 'conda', 'deactivate.d')
|
|
36
|
-
const hooks = [
|
|
37
|
-
path.join(activate, 'zz_pinokio_ffmpeg.sh'),
|
|
38
|
-
path.join(activate, 'zz_pinokio_ffmpeg.bat'),
|
|
39
|
-
path.join(activate, 'zz_pinokio_ffmpeg.ps1'),
|
|
40
|
-
path.join(deactivate, 'zz_pinokio_ffmpeg.sh'),
|
|
41
|
-
path.join(deactivate, 'zz_pinokio_ffmpeg.bat'),
|
|
42
|
-
path.join(deactivate, 'zz_pinokio_ffmpeg.ps1'),
|
|
43
|
-
]
|
|
44
|
-
for (const hook of hooks) {
|
|
45
|
-
await writeFixtureFile(hook)
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const dirs = [
|
|
49
|
-
path.join(root, 'bin', 'ffmpeg-env'),
|
|
50
|
-
path.join(root, 'bin', 'ffmpeg-pkgs'),
|
|
51
|
-
path.join(root, 'bin', 'ffmpeg'),
|
|
52
|
-
path.join(root, 'bin', 'ffmpeg-tmp'),
|
|
53
|
-
]
|
|
54
|
-
for (const dir of dirs) {
|
|
55
|
-
await fs.mkdir(dir, { recursive: true })
|
|
56
|
-
await fs.writeFile(path.join(dir, 'marker.txt'), 'legacy\n')
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return { hooks, dirs }
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
test('LegacyCleanup removes stale FFmpeg Conda hooks and old runtime paths once at startup', async () => {
|
|
63
|
-
const root = await fs.mkdtemp(path.join(os.tmpdir(), 'pinokio-legacy-cleanup-'))
|
|
64
|
-
const { hooks, dirs } = await createLegacyFfmpegState(root)
|
|
65
|
-
const packets = []
|
|
66
|
-
const cleanup = new LegacyCleanup(createKernel(root))
|
|
67
|
-
|
|
68
|
-
const result = await cleanup.runOnce((packet) => packets.push(packet))
|
|
69
|
-
|
|
70
|
-
assert.equal(result.skipped, false)
|
|
71
|
-
assert.ok(result.results.some((cleanupResult) => {
|
|
72
|
-
return cleanupResult.name === 'ffmpeg' &&
|
|
73
|
-
cleanupResult.results.some((item) => item.found && item.removed)
|
|
74
|
-
}))
|
|
75
|
-
for (const hook of hooks) {
|
|
76
|
-
assert.equal(await exists(hook), false, `${hook} should be removed`)
|
|
77
|
-
}
|
|
78
|
-
for (const dir of dirs) {
|
|
79
|
-
assert.equal(await exists(dir), false, `${dir} should be removed`)
|
|
80
|
-
}
|
|
81
|
-
assert.ok(packets.some((packet) => /removed legacy path:/.test(packet.raw || '')))
|
|
82
|
-
})
|
|
83
|
-
|
|
84
|
-
test('LegacyCleanup runOnce does not repeat work in the same process', async () => {
|
|
85
|
-
const root = await fs.mkdtemp(path.join(os.tmpdir(), 'pinokio-legacy-once-'))
|
|
86
|
-
const kernel = createKernel(root)
|
|
87
|
-
const cleanup = new LegacyCleanup(kernel)
|
|
88
|
-
const first = await cleanup.runOnce(() => {})
|
|
89
|
-
|
|
90
|
-
const lateHook = path.join(root, 'bin', 'miniconda', 'etc', 'conda', 'activate.d', 'zz_pinokio_ffmpeg.bat')
|
|
91
|
-
await writeFixtureFile(lateHook)
|
|
92
|
-
const second = await cleanup.runOnce(() => {})
|
|
93
|
-
|
|
94
|
-
assert.strictEqual(second, first)
|
|
95
|
-
assert.equal(await exists(lateHook), true)
|
|
96
|
-
})
|
|
97
|
-
|
|
98
|
-
test('LegacyCleanup tells the user which stale FFmpeg hooks to delete when removal fails', async () => {
|
|
99
|
-
const root = await fs.mkdtemp(path.join(os.tmpdir(), 'pinokio-legacy-locked-'))
|
|
100
|
-
await createLegacyFfmpegState(root)
|
|
101
|
-
const kernel = createKernel(root)
|
|
102
|
-
const originalRm = fsSync.promises.rm
|
|
103
|
-
const lockedHook = path.join(root, 'bin', 'miniconda', 'etc', 'conda', 'activate.d', 'zz_pinokio_ffmpeg.bat')
|
|
104
|
-
const packets = []
|
|
105
|
-
|
|
106
|
-
fsSync.promises.rm = async (target, options) => {
|
|
107
|
-
if (target === lockedHook) {
|
|
108
|
-
const error = new Error('locked')
|
|
109
|
-
error.code = 'EPERM'
|
|
110
|
-
throw error
|
|
111
|
-
}
|
|
112
|
-
return originalRm(target, options)
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
try {
|
|
116
|
-
await assert.rejects(
|
|
117
|
-
new LegacyCleanup(kernel).runOnce((packet) => packets.push(packet)),
|
|
118
|
-
(error) => {
|
|
119
|
-
assert.equal(error.name, 'LegacyFfmpegCleanupError')
|
|
120
|
-
assert.match(error.message, /Close all Pinokio windows/)
|
|
121
|
-
assert.match(error.message, /delete these files/)
|
|
122
|
-
assert.match(error.message, /zz_pinokio_ffmpeg\.bat/)
|
|
123
|
-
assert.ok(error.failures.some((failure) => failure.target === lockedHook))
|
|
124
|
-
return true
|
|
125
|
-
}
|
|
126
|
-
)
|
|
127
|
-
assert.ok(packets.some((packet) => /could not remove legacy path:/.test(packet.raw || '')))
|
|
128
|
-
} finally {
|
|
129
|
-
fsSync.promises.rm = originalRm
|
|
130
|
-
}
|
|
131
|
-
})
|
|
132
|
-
|
|
133
|
-
test('LegacyCleanup does not block startup when only an old FFmpeg runtime directory is locked', async () => {
|
|
134
|
-
const root = await fs.mkdtemp(path.join(os.tmpdir(), 'pinokio-legacy-runtime-locked-'))
|
|
135
|
-
const runtimeDir = path.join(root, 'bin', 'ffmpeg-env')
|
|
136
|
-
await fs.mkdir(runtimeDir, { recursive: true })
|
|
137
|
-
await fs.writeFile(path.join(runtimeDir, 'marker.txt'), 'legacy\n')
|
|
138
|
-
const kernel = createKernel(root)
|
|
139
|
-
const originalRm = fsSync.promises.rm
|
|
140
|
-
const packets = []
|
|
141
|
-
|
|
142
|
-
fsSync.promises.rm = async (target, options) => {
|
|
143
|
-
if (target === runtimeDir) {
|
|
144
|
-
const error = new Error('locked')
|
|
145
|
-
error.code = 'EPERM'
|
|
146
|
-
throw error
|
|
147
|
-
}
|
|
148
|
-
return originalRm(target, options)
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
try {
|
|
152
|
-
const result = await new LegacyCleanup(kernel).runOnce((packet) => packets.push(packet))
|
|
153
|
-
assert.ok(result.results.some((cleanupResult) => {
|
|
154
|
-
return cleanupResult.name === 'ffmpeg' &&
|
|
155
|
-
cleanupResult.results.some((item) => item.target === runtimeDir && item.removed === false)
|
|
156
|
-
}))
|
|
157
|
-
assert.ok(packets.some((packet) => /could not remove legacy path:/.test(packet.raw || '')))
|
|
158
|
-
} finally {
|
|
159
|
-
fsSync.promises.rm = originalRm
|
|
160
|
-
}
|
|
161
|
-
})
|