pinokiod 7.2.18 → 7.3.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.
Files changed (89) hide show
  1. package/Dockerfile +2 -0
  2. package/kernel/api/index.js +13 -179
  3. package/kernel/api/process/index.js +44 -99
  4. package/kernel/bin/conda-pins.js +53 -0
  5. package/kernel/bin/conda.js +35 -6
  6. package/kernel/bin/huggingface.js +1 -1
  7. package/kernel/bin/index.js +15 -2
  8. package/kernel/environment.js +11 -205
  9. package/kernel/git.js +13 -0
  10. package/kernel/index.js +1 -64
  11. package/kernel/plugin.js +58 -6
  12. package/kernel/prototype.js +0 -4
  13. package/kernel/shell.js +2 -23
  14. package/kernel/util.js +0 -60
  15. package/package.json +1 -1
  16. package/server/index.js +171 -229
  17. package/server/lib/content_validation.js +33 -47
  18. package/server/public/common.js +29 -103
  19. package/server/public/create-launcher.js +31 -4
  20. package/server/public/electron.css +6 -0
  21. package/server/public/style.css +0 -337
  22. package/server/public/task-launcher.css +3 -11
  23. package/server/public/task-launcher.js +32 -5
  24. package/server/public/universal-launcher.js +26 -3
  25. package/server/socket.js +11 -22
  26. package/server/views/app.ejs +30 -167
  27. package/server/views/d.ejs +35 -33
  28. package/server/views/editor.ejs +4 -25
  29. package/server/views/partials/main_sidebar.ejs +0 -1
  30. package/server/views/partials/menu.ejs +1 -1
  31. package/server/views/pre.ejs +1 -1
  32. package/server/views/shell.ejs +3 -11
  33. package/server/views/task_launch.ejs +10 -10
  34. package/server/views/terminal.ejs +5 -34
  35. package/spec/INSTRUCTION_SYNC.md +5 -5
  36. package/kernel/agent_instructions.js +0 -166
  37. package/kernel/api/shell_run_template.js +0 -273
  38. package/kernel/api/uri/index.js +0 -51
  39. package/kernel/plugin_sources.js +0 -289
  40. package/kernel/watch/context.js +0 -42
  41. package/kernel/watch/drivers/fs.js +0 -71
  42. package/kernel/watch/drivers/poll.js +0 -33
  43. package/kernel/watch/index.js +0 -185
  44. package/server/features/index.js +0 -13
  45. package/server/features/notes/index.js +0 -41
  46. package/server/features/notes/parser.js +0 -174
  47. package/server/features/notes/public/notes.css +0 -955
  48. package/server/features/notes/public/notes.js +0 -1149
  49. package/server/features/notes/registry_import.js +0 -412
  50. package/server/features/notes/routes.js +0 -156
  51. package/server/features/notes/service.js +0 -326
  52. package/server/features/notes/watcher.js +0 -74
  53. package/server/lib/workspace_catalog.js +0 -151
  54. package/server/lib/workspace_runtime.js +0 -390
  55. package/server/public/tasker.css +0 -336
  56. package/server/public/tasker.js +0 -407
  57. package/server/routes/workspaces.js +0 -44
  58. package/server/views/partials/workspace_row.ejs +0 -61
  59. package/server/views/tasker.ejs +0 -40
  60. package/server/views/workspaces.ejs +0 -813
  61. package/system/plugin/antigravity/antigravity.png +0 -0
  62. package/system/plugin/antigravity/pinokio.js +0 -35
  63. package/system/plugin/claude/claude.png +0 -0
  64. package/system/plugin/claude/pinokio.js +0 -61
  65. package/system/plugin/claude-auto/claude.png +0 -0
  66. package/system/plugin/claude-auto/pinokio.js +0 -72
  67. package/system/plugin/claude-desktop/icon.jpeg +0 -0
  68. package/system/plugin/claude-desktop/pinokio.js +0 -37
  69. package/system/plugin/codex/openai.webp +0 -0
  70. package/system/plugin/codex/pinokio.js +0 -56
  71. package/system/plugin/codex-auto/openai.webp +0 -0
  72. package/system/plugin/codex-auto/pinokio.js +0 -63
  73. package/system/plugin/codex-desktop/icon.png +0 -0
  74. package/system/plugin/codex-desktop/pinokio.js +0 -37
  75. package/system/plugin/crush/crush.png +0 -0
  76. package/system/plugin/crush/pinokio.js +0 -29
  77. package/system/plugin/cursor/cursor.jpeg +0 -0
  78. package/system/plugin/cursor/pinokio.js +0 -37
  79. package/system/plugin/gemini/gemini.jpeg +0 -0
  80. package/system/plugin/gemini/pinokio.js +0 -38
  81. package/system/plugin/gemini-auto/gemini.jpeg +0 -0
  82. package/system/plugin/gemini-auto/pinokio.js +0 -41
  83. package/system/plugin/qwen/pinokio.js +0 -48
  84. package/system/plugin/qwen/qwen.png +0 -0
  85. package/system/plugin/vscode/pinokio.js +0 -34
  86. package/system/plugin/vscode/vscode.png +0 -0
  87. package/system/plugin/windsurf/pinokio.js +0 -37
  88. package/system/plugin/windsurf/windsurf.png +0 -0
  89. package/test/plugin-sources.test.js +0 -45
@@ -22,6 +22,10 @@ const VS = require("./vs")
22
22
  const Cuda = require("./cuda")
23
23
  const Torch = require("./torch")
24
24
  const { buildCondaListFromMeta } = require('./conda-meta')
25
+ const {
26
+ isExpectedSqlitePinned,
27
+ isWindowsPythonSslFixed,
28
+ } = require('./conda-pins')
25
29
  const { glob } = require('glob')
26
30
  const fakeUa = require('fake-useragent');
27
31
  const fse = require('fs-extra')
@@ -348,6 +352,8 @@ class Bin {
348
352
  let conda_check = {}
349
353
  let conda = new Set()
350
354
  let conda_versions = {}
355
+ let conda_builds = {}
356
+ this.correct_conda = false
351
357
 
352
358
  //////////////////////////////////////////////////////////////////
353
359
  // exception handling
@@ -386,8 +392,10 @@ class Bin {
386
392
  if (chunks.length > 2) {
387
393
  let name = chunks[0]
388
394
  let version = chunks[1]
395
+ let build = chunks[2]
389
396
  conda.add(name)
390
397
  conda_versions[name] = version
398
+ conda_builds[name] = build
391
399
  if (name === "conda") {
392
400
  conda_check.conda = true
393
401
  }
@@ -404,10 +412,13 @@ class Bin {
404
412
  // Use sqlite to check if `conda update -y --all` went through successfully
405
413
  // sometimes it just fails silently so need to check
406
414
  if (name === "sqlite") {
407
- if (String(version) === "3.47.2") {
415
+ if (isExpectedSqlitePinned(this.platform, version)) {
408
416
  conda_check.sqlite = true
409
417
  }
410
418
  }
419
+ if (name === "python") {
420
+ conda_check.python = this.platform !== "win32" || isWindowsPythonSslFixed(version, build)
421
+ }
411
422
  }
412
423
  } else {
413
424
  if (/.*name.*version.*build.*channel/i.test(line)) {
@@ -416,13 +427,14 @@ class Bin {
416
427
  }
417
428
  }
418
429
 
419
- if (conda_check.conda && conda_check.mamba && conda_check.sqlite) {
430
+ if (conda_check.conda && conda_check.mamba && conda_check.sqlite && (this.platform !== "win32" || conda_check.python)) {
420
431
  //if (conda_check.conda && conda_check.mamba) {
421
432
  this.correct_conda = true
422
433
  }
423
434
  }
424
435
  this.installed.conda = conda
425
436
  this.installed.conda_versions = conda_versions
437
+ this.installed.conda_builds = conda_builds
426
438
  }
427
439
  async refreshInstalled() {
428
440
 
@@ -430,6 +442,7 @@ class Bin {
430
442
 
431
443
  this.installed_initialized = false
432
444
  this.requirements_cache = {}
445
+ this.correct_conda = false
433
446
 
434
447
  //this.installed = {}
435
448
 
@@ -3,189 +3,7 @@ const portfinder = require('portfinder-cp')
3
3
  const os = require('os')
4
4
  const fs = require('fs')
5
5
  const Util = require('./util')
6
- const TEMP_ENV_KEYS = ["TMP", "TEMP", "TMPDIR", "PIP_TMPDIR"]
7
- const CACHE_ENV_KEYS = ["UV_CACHE_DIR", "PIP_CACHE_DIR"]
8
- const CACHE_PREFLIGHT_KEYS = TEMP_ENV_KEYS.concat(CACHE_ENV_KEYS)
9
-
10
- const formatCachePreflightError = (error) => {
11
- if (!error) {
12
- return ""
13
- }
14
- const parts = []
15
- if (error.code) {
16
- parts.push(`code=${error.code}`)
17
- }
18
- if (typeof error.errno !== "undefined") {
19
- parts.push(`errno=${error.errno}`)
20
- }
21
- if (error.syscall) {
22
- parts.push(`syscall=${error.syscall}`)
23
- }
24
- if (error.path) {
25
- parts.push(`path=${error.path}`)
26
- }
27
- if (error.dest) {
28
- parts.push(`dest=${error.dest}`)
29
- }
30
- if (error.message) {
31
- parts.push(`message=${error.message}`)
32
- }
33
- return parts.join(" ")
34
- }
35
-
36
- const logCachePreflight = (message) => {
37
- console.log(`[Pinokio cache preflight] ${message}`)
38
- }
39
-
40
- const probeCacheDir = async (dirPath) => {
41
- const probeDir = path.resolve(
42
- dirPath,
43
- `.pinokio-cache-probe-${process.pid}-${Date.now()}-${Math.random().toString(16).slice(2)}`
44
- )
45
- const probeFile = path.resolve(probeDir, "probe.tmp")
46
- const renamedFile = path.resolve(probeDir, "probe-renamed.tmp")
47
- const steps = [
48
- ["create probe directory", () => fs.promises.mkdir(probeDir, { recursive: false })],
49
- ["write probe file", () => fs.promises.writeFile(probeFile, "pinokio")],
50
- ["append probe file", () => fs.promises.appendFile(probeFile, "-cache-probe")],
51
- ["rename probe file", () => fs.promises.rename(probeFile, renamedFile)],
52
- ["delete probe file", () => fs.promises.unlink(renamedFile)],
53
- ["remove probe directory", () => fs.promises.rmdir(probeDir)]
54
- ]
55
-
56
- for (const [step, run] of steps) {
57
- try {
58
- await run()
59
- } catch (error) {
60
- await fs.promises.rm(probeDir, { recursive: true, force: true }).catch(() => {})
61
- return { ok: false, step, error }
62
- }
63
- }
64
- return { ok: true }
65
- }
66
-
67
- const managedCacheEnvDefaults = () => {
68
- const defaults = {}
69
- for (const key of CACHE_PREFLIGHT_KEYS) {
70
- defaults[key] = `./cache/${key}`
71
- }
72
- return defaults
73
- }
74
-
75
- const ensureCachePreflightDir = async (key, targetPath, options = {}) => {
76
- logCachePreflight(`${key}: target=${targetPath}`)
77
- try {
78
- await fs.promises.mkdir(targetPath, { recursive: true })
79
- logCachePreflight(`${key}: mkdir ok`)
80
- } catch (error) {
81
- logCachePreflight(`${key}: mkdir failed ${formatCachePreflightError(error)}`)
82
- }
83
-
84
- const firstProbe = await probeCacheDir(targetPath)
85
- if (firstProbe.ok) {
86
- logCachePreflight(`${key}: probe ok`)
87
- return { key, path: targetPath, repaired: false, ok: true }
88
- }
89
-
90
- logCachePreflight(`${key}: probe failed step="${firstProbe.step}" ${formatCachePreflightError(firstProbe.error)}`)
91
- logCachePreflight(`${key}: repair delete start path=${targetPath}`)
92
-
93
- try {
94
- await fs.promises.rm(targetPath, { recursive: true, force: true })
95
- logCachePreflight(`${key}: repair delete ok`)
96
- } catch (error) {
97
- logCachePreflight(`${key}: repair delete failed ${formatCachePreflightError(error)}`)
98
- if (typeof options.elevatedRepair !== "function") {
99
- return { key, path: targetPath, repaired: false, ok: false, step: "repair delete", error }
100
- }
101
- logCachePreflight(`${key}: elevated repair start path=${targetPath}`)
102
- let elevatedRepair
103
- try {
104
- elevatedRepair = await options.elevatedRepair(targetPath, logCachePreflight)
105
- } catch (repairError) {
106
- elevatedRepair = { ok: false, error: repairError }
107
- }
108
- if (!elevatedRepair || !elevatedRepair.ok) {
109
- return { key, path: targetPath, repaired: false, elevated: true, ok: false, step: "elevated repair", error: elevatedRepair && elevatedRepair.error ? elevatedRepair.error : error }
110
- }
111
- const elevatedProbe = await probeCacheDir(targetPath)
112
- if (elevatedProbe.ok) {
113
- logCachePreflight(`${key}: elevated repair probe ok`)
114
- return { key, path: targetPath, repaired: true, elevated: true, ok: true }
115
- }
116
- logCachePreflight(`${key}: elevated repair probe failed step="${elevatedProbe.step}" ${formatCachePreflightError(elevatedProbe.error)}`)
117
- return { key, path: targetPath, repaired: true, elevated: true, ok: false, step: elevatedProbe.step, error: elevatedProbe.error }
118
- }
119
-
120
- try {
121
- await fs.promises.mkdir(targetPath, { recursive: true })
122
- logCachePreflight(`${key}: repair mkdir ok`)
123
- } catch (error) {
124
- logCachePreflight(`${key}: repair mkdir failed ${formatCachePreflightError(error)}`)
125
- return { key, path: targetPath, repaired: true, ok: false, step: "repair mkdir", error }
126
- }
127
-
128
- const secondProbe = await probeCacheDir(targetPath)
129
- if (secondProbe.ok) {
130
- logCachePreflight(`${key}: repair probe ok`)
131
- return { key, path: targetPath, repaired: true, ok: true }
132
- }
133
-
134
- logCachePreflight(`${key}: repair probe failed step="${secondProbe.step}" ${formatCachePreflightError(secondProbe.error)}`)
135
- return { key, path: targetPath, repaired: true, ok: false, step: secondProbe.step, error: secondProbe.error }
136
- }
137
-
138
- const ensurePinokioCacheDirs = async (kernel, options = {}) => {
139
- if (!kernel || !kernel.homedir) {
140
- return {}
141
- }
142
- const throwOnFailure = !!options.throwOnFailure
143
- const root = path.resolve(kernel.homedir)
144
- const cacheRoot = path.resolve(root, "cache")
145
- const envPath = path.resolve(root, "ENVIRONMENT")
146
- const defaults = managedCacheEnvDefaults()
147
- logCachePreflight(`start root=${root}`)
148
- await Util.update_env(envPath, defaults)
149
- logCachePreflight(`ENVIRONMENT updated keys=${CACHE_PREFLIGHT_KEYS.join(",")}`)
150
- try {
151
- await fs.promises.mkdir(cacheRoot, { recursive: true })
152
- logCachePreflight(`cache root mkdir ok path=${cacheRoot}`)
153
- } catch (error) {
154
- logCachePreflight(`cache root mkdir failed path=${cacheRoot} ${formatCachePreflightError(error)}`)
155
- }
156
-
157
- if (process.platform === "darwin") await fs.promises.writeFile(path.resolve(root, ".metadata_never_index"), "", { flag: "a" }).catch(() => {})
158
-
159
- const errors = []
160
- const results = []
161
-
162
- for (const key of CACHE_PREFLIGHT_KEYS) {
163
- const targetPath = path.resolve(cacheRoot, key)
164
- const result = await ensureCachePreflightDir(key, targetPath, options)
165
- results.push(result)
166
- if (!result.ok) {
167
- errors.push(result)
168
- }
169
- }
170
-
171
- if (errors.length > 0) {
172
- kernel.cacheDirErrors = errors
173
- const message = errors
174
- .map((error) => `${error.key}: ${error.path} (${error.step || "unknown"} ${formatCachePreflightError(error.error)})`)
175
- .join(", ")
176
- logCachePreflight(`failed ${message}`)
177
- if (throwOnFailure) {
178
- throw new Error(`Pinokio could not create writable cache directories: ${message}`)
179
- }
180
- } else {
181
- kernel.cacheDirErrors = []
182
- logCachePreflight(`complete ok checked=${results.length} repaired=${results.filter((result) => result.repaired).length}`)
183
- }
184
-
185
- kernel.cacheDirPreflight = results
186
- const env = await get(root, kernel)
187
- return { env, errors, results }
188
- }
6
+ const platform = os.platform()
189
7
  const ENVS = async () => {
190
8
  // const primary_port = 80
191
9
  // const secondary_port = 42000
@@ -620,21 +438,18 @@ const requirements = async (script, cwd, kernel) => {
620
438
  let requires_instantiation = false
621
439
  if (script) {
622
440
  let pre
623
- if (Array.isArray(script.pre)) {
441
+ if (script.pre) {
624
442
  pre = script.pre
625
- } else if (Array.isArray(script.env)) {
443
+ } else if (script.env) {
626
444
  pre = script.env
627
445
  }
628
446
  if (pre) {
629
447
  let env = await get2(cwd, kernel)
630
448
  for(let item of pre) {
631
- if (!item || typeof item !== "object") {
632
- continue
633
- }
634
449
  let env_key
635
- if (typeof item.env === "string" && item.env) {
450
+ if (item.env) {
636
451
  env_key = item.env
637
- } else if (typeof item.key === "string" && item.key) {
452
+ } else if (item.key) {
638
453
  env_key = item.key
639
454
  item.env = item.key
640
455
  }
@@ -643,20 +458,11 @@ const requirements = async (script, cwd, kernel) => {
643
458
  if (!item.index) {
644
459
  item.index = 0
645
460
  }
646
- if (typeof item.host === "string" && item.host.trim()) {
647
- const host = item.host.trim()
648
- let parsedHost = ""
649
- try {
650
- const hasProtocol = /^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(host);
651
- const url = new URL(hasProtocol ? host : `https://${host}`);
652
- parsedHost = url.host
653
- } catch (e) {
654
- item.host = ""
655
- }
656
- if (parsedHost) {
657
- item.host = parsedHost
658
- item.val = await kernel.kv.get(item.host, item.index)
659
- }
461
+ if (item.host) {
462
+ const hasProtocol = /^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(item.host);
463
+ const url = new URL(hasProtocol ? item.host : `https://${item.host}`);
464
+ item.host = url.host
465
+ item.val = await kernel.kv.get(item.host, item.index)
660
466
  } else {
661
467
  item.host = ""
662
468
  }
@@ -1022,4 +828,4 @@ const init = async (options, kernel) => {
1022
828
  env_path: current
1023
829
  }
1024
830
  }
1025
- module.exports = { ENV, get, get2, init_folders, ensurePinokioCacheDirs, requirements, init, get_root }
831
+ module.exports = { ENV, get, get2, init_folders, requirements, init, get_root }
package/kernel/git.js CHANGED
@@ -1378,6 +1378,19 @@ class Git {
1378
1378
  const absoluteTarget = path.resolve(targetPath)
1379
1379
  const home = path.resolve(this.kernel.homedir)
1380
1380
  const managedTargets = [
1381
+ {
1382
+ kind: "plugin",
1383
+ root: path.resolve(home, "plugin/code"),
1384
+ matches: (root, target) => target === root || target.startsWith(`${root}${path.sep}`),
1385
+ bootstrap: async () => {
1386
+ await fs.promises.rm(path.resolve(home, "plugin/code"), { recursive: true, force: true })
1387
+ this.dirs.delete(path.resolve(home, "plugin/code"))
1388
+ if (this.kernel.plugin && typeof this.kernel.plugin.init === "function") {
1389
+ await this.kernel.plugin.init()
1390
+ }
1391
+ },
1392
+ exists: async () => this.kernel.exists("plugin/code")
1393
+ },
1381
1394
  {
1382
1395
  kind: "prototype",
1383
1396
  root: path.resolve(home, "prototype/system"),
package/kernel/index.js CHANGED
@@ -40,11 +40,9 @@ const Git = require('./git')
40
40
  const Connect = require('./connect')
41
41
  const Favicon = require('./favicon')
42
42
  const AppLauncher = require('./app_launcher')
43
- const WatchManager = require('./watch')
44
43
  const { DownloaderHelper } = require('node-downloader-helper');
45
44
  const { ProxyAgent } = require('proxy-agent');
46
45
  const fakeUa = require('fake-useragent');
47
- const sudo = process.platform === "win32" ? require("sudo-prompt-programfiles-x86") : null
48
46
  //const kill = require('./tree-kill');
49
47
  const kill = require('kill-sync')
50
48
  const ejs = require('ejs');
@@ -56,37 +54,9 @@ const VARS = {
56
54
  }
57
55
  }
58
56
 
59
- const powershellSingleQuote = (value) => {
60
- return `'${String(value).replace(/'/g, "''")}'`
61
- }
62
-
63
- const windowsCacheRepairCommand = (targetPath) => {
64
- const psPath = powershellSingleQuote(targetPath)
65
- return [
66
- "powershell.exe",
67
- "-NoProfile",
68
- "-ExecutionPolicy Bypass",
69
- "-Command",
70
- `"`,
71
- "$ErrorActionPreference = 'Stop';",
72
- `$p = ${psPath};`,
73
- "$account = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name;",
74
- "$grant = $account + ':(OI)(CI)F';",
75
- "if (Test-Path -LiteralPath $p) {",
76
- " & takeown.exe /F $p /R /D Y;",
77
- " & icacls.exe $p /reset /T /C;",
78
- " & icacls.exe $p /grant $grant /T /C;",
79
- " Remove-Item -LiteralPath $p -Recurse -Force;",
80
- "}",
81
- "New-Item -ItemType Directory -Force -Path $p | Out-Null;",
82
- "& icacls.exe $p /grant $grant /T /C;",
83
- `"`
84
- ].join(" ")
85
- }
86
-
87
57
  //const memwatch = require('@airbnb/node-memwatch');
88
58
  class Kernel {
89
- schema = "<=7.3.0"
59
+ schema = "<=7.0.0"
90
60
  constructor(store) {
91
61
  this.fetch = fetch
92
62
 
@@ -415,9 +385,6 @@ class Kernel {
415
385
  path(...args) {
416
386
  return path.resolve(this.homedir, ...args)
417
387
  }
418
- systemPath(...args) {
419
- return path.resolve(__dirname, "..", "system", ...args)
420
- }
421
388
  exists(...args) {
422
389
  if (args) {
423
390
  let abspath = this.path(...args)
@@ -497,30 +464,6 @@ class Kernel {
497
464
  return ''
498
465
  }
499
466
  }
500
- async elevatedCacheRepair(targetPath, log = console.log) {
501
- if (this.platform !== "win32" || !sudo) {
502
- return { ok: false, error: new Error("Elevated cache repair is only available on Windows") }
503
- }
504
- const command = windowsCacheRepairCommand(targetPath)
505
- log(`elevated repair command=${command}`)
506
- return new Promise((resolve) => {
507
- sudo.exec(command, { name: "Pinokio" }, (error, stdout, stderr) => {
508
- if (stdout && stdout.trim()) {
509
- log(`elevated repair stdout ${stdout.trim()}`)
510
- }
511
- if (stderr && stderr.trim()) {
512
- log(`elevated repair stderr ${stderr.trim()}`)
513
- }
514
- if (error) {
515
- log(`elevated repair failed ${error.message || error}`)
516
- resolve({ ok: false, error, stdout, stderr })
517
- } else {
518
- log(`elevated repair ok path=${targetPath}`)
519
- resolve({ ok: true, stdout, stderr })
520
- }
521
- })
522
- })
523
- }
524
467
  async ensureRouterMode() {
525
468
  const domain = await this.resolvePinokioDomain()
526
469
  const shouldUseCustom = domain.length > 0
@@ -1032,7 +975,6 @@ class Kernel {
1032
975
  this.loader = new Loader()
1033
976
  this.bin = new Bin(this)
1034
977
  this.api = new Api(this)
1035
- this.watch = new WatchManager(this)
1036
978
  this.python = new Python(this)
1037
979
  this.shell = new Shells(this)
1038
980
  this.appLauncher = new AppLauncher(this)
@@ -1063,7 +1005,6 @@ class Kernel {
1063
1005
  args: {},
1064
1006
  }
1065
1007
  this.procs = {}
1066
- this.activeProcessWaits = {}
1067
1008
  this.template = new Template()
1068
1009
  try {
1069
1010
  if (this.homedir) {
@@ -1110,10 +1051,6 @@ class Kernel {
1110
1051
 
1111
1052
  // 2. mkdir all the folders if not already created
1112
1053
  await Environment.init_folders(this.homedir, this)
1113
- await Environment.ensurePinokioCacheDirs(this, {
1114
- throwOnFailure: true,
1115
- elevatedRepair: this.elevatedCacheRepair.bind(this)
1116
- })
1117
1054
 
1118
1055
  // if key.json doesn't exist, create an empty json file
1119
1056
  let ee = await this.exists(this.homedir, "key.json")
package/kernel/plugin.js CHANGED
@@ -1,14 +1,39 @@
1
- const fs = require('fs')
2
- const PluginSources = require("./plugin_sources")
3
-
1
+ const path = require('path')
2
+ const { glob } = require('glob')
3
+ const Info = require("./info")
4
4
  class Plugin {
5
5
  constructor(kernel) {
6
6
  this.kernel = kernel
7
7
  }
8
8
  async setConfig() {
9
+ let plugin_dir = path.resolve(this.kernel.homedir, "plugin")
9
10
  this.cache = {}
10
11
 
11
- const plugins = await PluginSources.loadPluginMenu(this.kernel)
12
+ let plugin_paths = await glob('**/pinokio.js', { cwd: plugin_dir })
13
+
14
+ let plugins = []
15
+ for(let plugin_path of plugin_paths) {
16
+ let config = await this.kernel.require(path.resolve(plugin_dir, plugin_path))
17
+ if (config && config.run && Array.isArray(config.run)) {
18
+ let invalid
19
+ for(let key in config) {
20
+ if (typeof config[key] === "function") {
21
+ invalid = true
22
+ }
23
+ }
24
+ if (invalid) {
25
+ continue
26
+ }
27
+
28
+ let chunks = plugin_path.split(path.sep)
29
+ let cwd = chunks.slice(0, -1).join("/")
30
+ config.image = "/asset/plugin/" + cwd + "/" + config.icon
31
+ plugins.push({
32
+ href: "/run/plugin/" + chunks.join("/"),
33
+ ...config
34
+ })
35
+ }
36
+ }
12
37
 
13
38
  this.config = {
14
39
  menu: plugins.map((plugin) => {
@@ -23,10 +48,37 @@ class Plugin {
23
48
  if (!exists) {
24
49
  await fs.promises.mkdir(this.kernel.path("plugin"), { recursive: true }).catch((e) => {})
25
50
  }
26
- await this.setConfig()
51
+ let code_exists = await this.kernel.exists("plugin/code")
52
+ console.log({ code_exists })
53
+ if (!code_exists) {
54
+ if (this.kernel.bin.installed && this.kernel.bin.installed.conda && this.kernel.bin.installed.conda.has("git")) {
55
+ await this.kernel.exec({
56
+ //message: "git clone https://github.com/peanutcocktail/plugin",
57
+ //message: "git clone https://github.com/pinokiocomputer/plugin",
58
+ message: "git clone https://github.com/pinokiocomputer/code",
59
+ path: this.kernel.path("plugin")
60
+ }, (e) => {
61
+ process.stdout.write(e.raw)
62
+ })
63
+ await this.setConfig()
64
+ return
65
+ }
66
+ } else {
67
+ await this.setConfig()
68
+ }
27
69
  }
28
70
  async update() {
29
- await this.setConfig()
71
+ if (this.kernel.bin.installed && this.kernel.bin.installed.conda && this.kernel.bin.installed.conda.has("git")) {
72
+ let exists = await this.kernel.exists("plugin")
73
+ if (!exists) {
74
+ await this.kernel.exec({
75
+ message: "git pull",
76
+ path: this.kernel.path("plugin")
77
+ }, (e) => {
78
+ process.stdout.write(e.raw)
79
+ })
80
+ }
81
+ }
30
82
  }
31
83
  }
32
84
  module.exports = Plugin
@@ -3,7 +3,6 @@ const path = require('path')
3
3
  const { glob, sync, hasMagic } = require('glob-gitignore')
4
4
  const marked = require('marked')
5
5
  const matter = require('gray-matter');
6
- const PluginSources = require("./plugin_sources")
7
6
  class Proto {
8
7
  constructor(kernel) {
9
8
  this.kernel = kernel
@@ -149,9 +148,6 @@ class Proto {
149
148
 
150
149
 
151
150
  if (response) {
152
- if (response.success) {
153
- response.success = PluginSources.normalizeLauncherSuccessPlugin(response.success, req.params.tool)
154
- }
155
151
  return response
156
152
  } else {
157
153
  return { success: "/p/" + name + "/dev" }
package/kernel/shell.js CHANGED
@@ -20,7 +20,6 @@ const { applyWindowsNodePackageManagerEnv } = require('./windows_node_package_ma
20
20
  const ShellParser = require('./shell_parser')
21
21
  const AnsiStreamTracker = require('./ansi_stream_tracker')
22
22
  const ShellStateSync = require('./shell_state_sync')
23
- const ShellRunTemplate = require('./api/shell_run_template')
24
23
  const home = os.homedir()
25
24
 
26
25
  function normalizeComparablePath(filePath, platform) {
@@ -294,8 +293,6 @@ class Shell {
294
293
  }
295
294
  }
296
295
 
297
- setDefaultEnvValue(this.env, "HF_HUB_DISABLE_UPDATE_CHECK", "1")
298
-
299
296
  if (this.platform === "win32") {
300
297
  // Hugging Face file symlinks regularly fail on non-admin Windows setups.
301
298
  // Default to no-symlink cache mode unless the user/app explicitly overrides it.
@@ -311,7 +308,7 @@ class Shell {
311
308
  delete this.env[key]
312
309
  }
313
310
  let val = this.env[key]
314
- if (!ShellRunTemplate.isPinokioEnvArgKey(key) && /[\r\n]/.test(val)) {
311
+ if (/[\r\n]/.test(val)) {
315
312
  const replaced = val.replaceAll(/[\r\n]+/g, ' ');
316
313
  this.env[key] = replaced
317
314
  // delete this.env[key]
@@ -365,9 +362,6 @@ class Shell {
365
362
  }
366
363
  quoteArgForShell(value, shellName=this.shell) {
367
364
  const input = value == null ? "" : String(value)
368
- if (ShellRunTemplate.hasEnvArgMarker(input)) {
369
- return ShellRunTemplate.quoteEnvArgComposite(input, shellName)
370
- }
371
365
  if (this.isCmdShell(shellName)) {
372
366
  return `"${input.replace(/([()%!^"<>&|])/g, '^$1')}"`
373
367
  }
@@ -415,7 +409,6 @@ class Shell {
415
409
  this.userActive = false
416
410
  this.decsyncBuffer = ''
417
411
  this.stateSync.reset()
418
- this.envArgsPreviewed = false
419
412
 
420
413
  /*
421
414
  params := {
@@ -547,9 +540,6 @@ class Shell {
547
540
  //}
548
541
  }
549
542
  }
550
- if (params._pinokio_cmd_delayed_expansion && this.isCmdShell(this.shell) && !this.args.includes("/V:ON")) {
551
- this.args.push("/V:ON")
552
- }
553
543
 
554
544
  // 3. path => path can be http, relative, absolute
555
545
  this.path = params.path
@@ -767,16 +757,6 @@ class Shell {
767
757
  }
768
758
  this.stateSync.invalidate({ clearTail: true })
769
759
  }
770
- emitEnvArgsPreview(params) {
771
- if (!params || !Array.isArray(params._pinokio_env_args) || params._pinokio_env_args.length === 0 || this.envArgsPreviewed) {
772
- return
773
- }
774
- this.envArgsPreviewed = true
775
- const raw = ShellRunTemplate.formatEnvArgsPreview(params._pinokio_env_args)
776
- if (raw && this.ondata) {
777
- this.ondata({ raw })
778
- }
779
- }
780
760
  async run(params, cb) {
781
761
  let r = await this.request(params, cb)
782
762
  return r
@@ -1382,7 +1362,6 @@ class Shell {
1382
1362
  }
1383
1363
  async exec(params) {
1384
1364
  this.parser = new ShellParser()
1385
- this.emitEnvArgsPreview(params)
1386
1365
  params = await this.activate(params)
1387
1366
  this.cmd = this.build(params)
1388
1367
  let res = await new Promise((resolve, reject) => {
@@ -1750,7 +1729,7 @@ class Shell {
1750
1729
  cmd: this.cmd,
1751
1730
  index: this.index,
1752
1731
  group: this.group,
1753
- env: ShellRunTemplate.redactEnvArgs(this.env),
1732
+ env: this.env,
1754
1733
  done: this.done,
1755
1734
  ready: this.ready,
1756
1735
  id: this.id,