pinokiod 3.8.153 → 3.8.1532
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/api/index.js +27 -7
- package/kernel/api/web/index.js +6 -0
- package/kernel/bin/git.js +42 -15
- package/kernel/bin/index.js +3 -19
- package/kernel/peer.js +0 -2
- package/kernel/prototype.js +1 -1
- package/kernel/router/index.js +1 -1
- package/kernel/shell.js +5 -0
- package/package.json +1 -1
- package/server/index.js +345 -70
- package/server/public/fscreator.js +32 -15
- package/server/public/style.css +10 -3
- package/server/views/app.ejs +71 -6
- package/server/views/editor.ejs +37 -0
- package/server/views/file_explorer.ejs +1 -1
- package/server/views/github.ejs +179 -0
- package/server/views/index.ejs +20 -2
- package/server/views/{local_editor.ejs → keys.ejs} +47 -53
- package/server/views/network.ejs +54 -3
- package/server/views/partials/dynamic.ejs +6 -0
- package/server/views/prototype.ejs +299 -0
- package/server/views/settings.ejs +24 -1
- package/server/views/setup_home.ejs +1 -1
- package/server/views/shell.ejs +36 -4
- package/server/views/terminal.ejs +55 -10
- package/server/views/prototypes.ejs +0 -481
package/kernel/api/index.js
CHANGED
|
@@ -28,6 +28,21 @@ class Api {
|
|
|
28
28
|
this.child_procs = {}
|
|
29
29
|
this.lproxy = new Lproxy()
|
|
30
30
|
}
|
|
31
|
+
async meta(name) {
|
|
32
|
+
let p = this.kernel.path("api", name, "pinokio.js")
|
|
33
|
+
let pinokio = (await this.kernel.loader.load(p)).resolved
|
|
34
|
+
let p2 = this.kernel.path("api", name, "pinokio_meta.json")
|
|
35
|
+
let pinokio2 = (await this.kernel.loader.load(p2)).resolved
|
|
36
|
+
let p3 = this.kernel.path("api", name, "pinokio.json")
|
|
37
|
+
let pinokio3 = (await this.kernel.loader.load(p3)).resolved
|
|
38
|
+
let meta = Object.assign({}, pinokio, pinokio2, pinokio3)
|
|
39
|
+
meta.iconpath = meta.icon ? this.kernel.path("api", name, meta.icon) : null
|
|
40
|
+
meta.icon = meta.icon ? `/api/${name}/${meta.icon}?raw=true` : "/pinokio-black.png"
|
|
41
|
+
meta.path = this.kernel.path("api", name)
|
|
42
|
+
meta.name = meta.title
|
|
43
|
+
meta.link = `/pinokio/browser/${name}/browse#n1`
|
|
44
|
+
return meta
|
|
45
|
+
}
|
|
31
46
|
get_proxy_url(root, port) {
|
|
32
47
|
if (this.proxies) {
|
|
33
48
|
let proxies = this.proxies[root]
|
|
@@ -160,7 +175,6 @@ class Api {
|
|
|
160
175
|
|
|
161
176
|
await this.kernel.stopCloudflare({ path: requestPath })
|
|
162
177
|
|
|
163
|
-
|
|
164
178
|
// if there are any pending waiters, delete them
|
|
165
179
|
|
|
166
180
|
if (this.waiter[requestPath]) {
|
|
@@ -431,14 +445,18 @@ class Api {
|
|
|
431
445
|
let method
|
|
432
446
|
let dirname
|
|
433
447
|
let mod
|
|
434
|
-
if (req.
|
|
448
|
+
if (req.method && typeof req.method === "function") {
|
|
449
|
+
modpath = null
|
|
450
|
+
method = req.method
|
|
451
|
+
dirname = __dirname
|
|
452
|
+
mod = null
|
|
453
|
+
} else if (req.uri) {
|
|
435
454
|
modpath = this.resolvePath(cwd, req.uri)
|
|
436
455
|
let m = (await this.loader.load(modpath))
|
|
437
456
|
const stats = await fs.promises.stat(modpath)
|
|
438
457
|
if (!this.child_procs[req.parent.path]) {
|
|
439
458
|
this.child_procs[req.parent.path] = new Set()
|
|
440
459
|
}
|
|
441
|
-
console.log("SCRIPT RESOLVE METHOD", req)
|
|
442
460
|
if (this.mods[modpath]) {
|
|
443
461
|
// use the cached module if unchanged
|
|
444
462
|
if (String(stats.mtime) === String(this.mods[modpath].updated)) {
|
|
@@ -572,9 +590,7 @@ class Api {
|
|
|
572
590
|
|
|
573
591
|
}
|
|
574
592
|
async step (request, rawrpc, input, i, total, args) {
|
|
575
|
-
console.time("STEP INIT")
|
|
576
593
|
await Promise.all([this.init(), this.kernel.update_sysinfo()])
|
|
577
|
-
console.timeEnd("STEP INIT")
|
|
578
594
|
|
|
579
595
|
// clear global regular expression object RegExp.lastMatch (memory leak prevention)
|
|
580
596
|
let r = /\s*/g.exec("");
|
|
@@ -583,6 +599,10 @@ class Api {
|
|
|
583
599
|
|
|
584
600
|
let { cwd, script } = await this.resolveScript(request.path)
|
|
585
601
|
|
|
602
|
+
if (request.cwd) {
|
|
603
|
+
cwd = request.cwd
|
|
604
|
+
}
|
|
605
|
+
|
|
586
606
|
let memory = {
|
|
587
607
|
script: this.kernel.script,
|
|
588
608
|
input,
|
|
@@ -635,7 +655,6 @@ class Api {
|
|
|
635
655
|
break;
|
|
636
656
|
}
|
|
637
657
|
}
|
|
638
|
-
|
|
639
658
|
// replace {{{ }}} with {{ }}
|
|
640
659
|
rpc = this.kernel.template.flatten(rpc)
|
|
641
660
|
|
|
@@ -769,6 +788,7 @@ class Api {
|
|
|
769
788
|
uri: request.path
|
|
770
789
|
}
|
|
771
790
|
})
|
|
791
|
+
console.log(">>>>>> STOPPED", request)
|
|
772
792
|
}
|
|
773
793
|
return { request, input: null, step: rpc.next, total: script.run.length, args }
|
|
774
794
|
} else {
|
|
@@ -987,6 +1007,7 @@ class Api {
|
|
|
987
1007
|
uri: request.path
|
|
988
1008
|
}
|
|
989
1009
|
})
|
|
1010
|
+
console.log("<<<<<< STOPPED", request)
|
|
990
1011
|
return { request, input: result, step: rpc.next, total: script.run.length, args }
|
|
991
1012
|
}
|
|
992
1013
|
|
|
@@ -1232,7 +1253,6 @@ class Api {
|
|
|
1232
1253
|
} else {
|
|
1233
1254
|
console.log({ request })
|
|
1234
1255
|
let { cwd, script } = await this.resolveScript(request.path)
|
|
1235
|
-
request.cwd = cwd
|
|
1236
1256
|
|
|
1237
1257
|
if (!script) {
|
|
1238
1258
|
this.ondata({
|
package/kernel/api/web/index.js
CHANGED
|
@@ -21,5 +21,11 @@ class Web {
|
|
|
21
21
|
kernel.exposed[app] = req.params.uri
|
|
22
22
|
console.log("kernel.exposed", kernel.exposed)
|
|
23
23
|
}
|
|
24
|
+
async open(req, ondata, kernel) {
|
|
25
|
+
ondata(req.params, "browser.open")
|
|
26
|
+
}
|
|
27
|
+
async close(req, ondata, kernel) {
|
|
28
|
+
ondata(req.params, "browser.close")
|
|
29
|
+
}
|
|
24
30
|
}
|
|
25
31
|
module.exports = Web
|
package/kernel/bin/git.js
CHANGED
|
@@ -5,15 +5,27 @@ const { rimraf } = require('rimraf')
|
|
|
5
5
|
const path = require("path")
|
|
6
6
|
class Git {
|
|
7
7
|
cmd() {
|
|
8
|
-
|
|
8
|
+
if (this.kernel.platform === "darwin") {
|
|
9
|
+
return "git git-lfs"
|
|
10
|
+
} else {
|
|
11
|
+
return "git git-lfs gh"
|
|
12
|
+
}
|
|
9
13
|
}
|
|
10
14
|
async install(req, ondata) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
15
|
+
if (this.kernel.platform === "darwin") {
|
|
16
|
+
await this.kernel.bin.exec({
|
|
17
|
+
conda: { skip: true },
|
|
18
|
+
message: "brew install gh",
|
|
19
|
+
}, ondata)
|
|
20
|
+
} else {
|
|
21
|
+
await this.kernel.bin.exec({
|
|
22
|
+
message: [
|
|
23
|
+
"conda clean -y --all",
|
|
24
|
+
`conda install -y -c conda-forge ${this.cmd()}`
|
|
25
|
+
]
|
|
26
|
+
}, ondata)
|
|
27
|
+
}
|
|
28
|
+
await fs.promises.mkdir(this.kernel.path("config/gh"), { recursive: true }).catch((e) => { })
|
|
17
29
|
// if (this.kernel.platform === 'win32') {
|
|
18
30
|
// let gitconfig_path = path.resolve(this.kernel.homedir, "gitconfig")
|
|
19
31
|
// // check if gitconfig exists
|
|
@@ -28,18 +40,33 @@ class Git {
|
|
|
28
40
|
// }
|
|
29
41
|
}
|
|
30
42
|
async installed() {
|
|
31
|
-
|
|
43
|
+
if (this.kernel.platform === "darwin") {
|
|
44
|
+
let gh_config_exists = await this.kernel.exists("config/gh")
|
|
45
|
+
console.log("conda installed", this.kernel.bin.installed.conda)
|
|
46
|
+
return this.kernel.bin.installed.conda && this.kernel.bin.installed.conda.has("git") && this.kernel.bin.installed.brew.has("gh") && gh_config_exists
|
|
47
|
+
} else {
|
|
48
|
+
let gh_config_exists = await this.kernel.exists("config/gh")
|
|
49
|
+
console.log("conda installed", this.kernel.bin.installed.conda)
|
|
50
|
+
return this.kernel.bin.installed.conda && this.kernel.bin.installed.conda.has("git") && this.kernel.bin.installed.conda.has("gh") && gh_config_exists
|
|
51
|
+
}
|
|
32
52
|
}
|
|
33
53
|
async uninstall(req, ondata) {
|
|
34
|
-
|
|
54
|
+
if (this.kernel.platform === "darwin") {
|
|
55
|
+
await this.kernel.bin.exec({ message: "conda remove git" }, ondata)
|
|
56
|
+
await this.kernel.bin.exec({
|
|
57
|
+
conda: { skip: true },
|
|
58
|
+
message: "brew uninstall gh",
|
|
59
|
+
})
|
|
60
|
+
} else {
|
|
61
|
+
await this.kernel.bin.exec({ message: "conda remove git gh" }, ondata)
|
|
62
|
+
}
|
|
35
63
|
}
|
|
36
64
|
env() {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
// }
|
|
65
|
+
let gitconfig_path = path.resolve(this.kernel.homedir, "gitconfig")
|
|
66
|
+
return {
|
|
67
|
+
GIT_CONFIG_GLOBAL: gitconfig_path,
|
|
68
|
+
GH_CONFIG_DIR: this.kernel.path("config/gh")
|
|
69
|
+
}
|
|
43
70
|
}
|
|
44
71
|
async requires() {
|
|
45
72
|
return ["conda"]
|
package/kernel/bin/index.js
CHANGED
|
@@ -359,17 +359,12 @@ class Bin {
|
|
|
359
359
|
conda_versions[name] = version
|
|
360
360
|
if (name === "conda") {
|
|
361
361
|
conda_check.conda = true
|
|
362
|
-
// //if (String(version) === "24.11.1") {
|
|
363
|
-
// if (String(version) === "24.11.3") {
|
|
364
|
-
// conda_check.conda = true
|
|
365
|
-
// }
|
|
366
362
|
}
|
|
367
363
|
if (name === "conda-libmamba-solver") {
|
|
368
364
|
//if (String(version) === "24.7.0") {
|
|
369
365
|
let channel = chunks[3]
|
|
370
366
|
let coerced = semver.coerce(version)
|
|
371
367
|
let mamba_requirement = ">=24.11.1"
|
|
372
|
-
// console.log({ name, channel, version })
|
|
373
368
|
//if (semver.satisfies(coerced, mamba_requirement) && channel === "conda-forge") {
|
|
374
369
|
if (semver.satisfies(coerced, mamba_requirement)) {
|
|
375
370
|
conda_check.mamba = true
|
|
@@ -381,16 +376,6 @@ class Bin {
|
|
|
381
376
|
if (String(version) === "3.47.2") {
|
|
382
377
|
conda_check.sqlite = true
|
|
383
378
|
}
|
|
384
|
-
// let coerced = semver.coerce(version)
|
|
385
|
-
// let sqlite_requirement = ">=3.47.2"
|
|
386
|
-
// // console.log({ coerced, version, sqlite_requirement })
|
|
387
|
-
// if (semver.satisfies(coerced, sqlite_requirement)) {
|
|
388
|
-
// console.log("semver satisfied")
|
|
389
|
-
//
|
|
390
|
-
// conda_check.sqlite = true
|
|
391
|
-
// } else {
|
|
392
|
-
// console.log("semver NOT satisfied")
|
|
393
|
-
// }
|
|
394
379
|
}
|
|
395
380
|
}
|
|
396
381
|
} else {
|
|
@@ -442,15 +427,12 @@ class Bin {
|
|
|
442
427
|
|
|
443
428
|
let brew_path = path.resolve(this.kernel.homedir, "bin", "homebrew")
|
|
444
429
|
let brew_exists = await this.exists(brew_path)
|
|
445
|
-
// console.log({ brew_path, brew_exists })
|
|
446
430
|
|
|
447
431
|
let brew = []
|
|
448
432
|
if (brew_exists) {
|
|
449
433
|
start = false
|
|
450
434
|
res = await this.exec({ message: `brew list -1`, conda: { skip: true } }, (stream) => {
|
|
451
|
-
// console.log("brew list check", { stream })
|
|
452
435
|
})
|
|
453
|
-
// console.log("BREW", res.response)
|
|
454
436
|
lines = res.response.split(/[\r\n]+/).slice(0, -1) // ignore last line since it's the prompt
|
|
455
437
|
let end = false
|
|
456
438
|
for(let line of lines) {
|
|
@@ -474,7 +456,6 @@ class Bin {
|
|
|
474
456
|
|
|
475
457
|
|
|
476
458
|
// check brew_installed
|
|
477
|
-
// console.log("checking brew installed")
|
|
478
459
|
let e = await this.kernel.bin.exists("homebrew")
|
|
479
460
|
let { stdout }= await this.exec({ message: "xcode-select -p", conda: { skip: true } }, (stream) => { })
|
|
480
461
|
let e2 = /(.*Library.*Developer.*CommandLineTools.*|.*Xcode.*Developer.*)/gi.test(stdout)
|
|
@@ -665,6 +646,7 @@ class Bin {
|
|
|
665
646
|
this.client = null
|
|
666
647
|
}
|
|
667
648
|
let requirements = JSON.parse(req.params)
|
|
649
|
+
console.log({ requirements })
|
|
668
650
|
for(let x=0; x<10; x++) {
|
|
669
651
|
console.log(`## Install Attempt ${x}`)
|
|
670
652
|
let i = 0;
|
|
@@ -974,6 +956,8 @@ class Bin {
|
|
|
974
956
|
let dependencies
|
|
975
957
|
if (r.name === "conda") {
|
|
976
958
|
dependencies = config.bin.conda_requirements
|
|
959
|
+
console.log("check dependencies", dependencies)
|
|
960
|
+
requirements[i].dependencies = dependencies
|
|
977
961
|
}
|
|
978
962
|
let installed = await this.check_installed(r, dependencies)
|
|
979
963
|
requirements[i].installed = installed
|
package/kernel/peer.js
CHANGED
|
@@ -106,7 +106,6 @@ class PeerDiscovery {
|
|
|
106
106
|
}
|
|
107
107
|
// refresh peer info
|
|
108
108
|
async refresh(peers) {
|
|
109
|
-
console.log("*Refresh")
|
|
110
109
|
// if (this.active) {
|
|
111
110
|
this.refreshing = true
|
|
112
111
|
let refresh_peers
|
|
@@ -119,7 +118,6 @@ class PeerDiscovery {
|
|
|
119
118
|
let peer_info = await Promise.all(refresh_peers.map((host) => {
|
|
120
119
|
return this._refresh(host)
|
|
121
120
|
}))
|
|
122
|
-
console.log("*Peer.refresh", { peer_info })
|
|
123
121
|
for(let i=0; i<peer_info.length; i++) {
|
|
124
122
|
let peer = peer_info[i]
|
|
125
123
|
if (peer) {
|
package/kernel/prototype.js
CHANGED
|
@@ -30,7 +30,7 @@ class Proto {
|
|
|
30
30
|
let proto = path.dirname(prototype_path)
|
|
31
31
|
let pinokiojs = path.resolve(prototype_dir, prototype_path)
|
|
32
32
|
let config = await this.kernel.require(pinokiojs)
|
|
33
|
-
if (config && config.
|
|
33
|
+
if (config && config.run) {
|
|
34
34
|
if (config.icon) {
|
|
35
35
|
config.icon = "/prototype/" + proto + "/" + config.icon
|
|
36
36
|
} else {
|
package/kernel/router/index.js
CHANGED
|
@@ -214,7 +214,7 @@ class Router {
|
|
|
214
214
|
let response = await axios.post('http://127.0.0.1:2019/load', this.config, {
|
|
215
215
|
headers: { 'Content-Type': 'application/json' }
|
|
216
216
|
})
|
|
217
|
-
console.log("Caddy Response", { response })
|
|
217
|
+
// console.log("Caddy Response", { response })
|
|
218
218
|
this.old_config = this.config
|
|
219
219
|
} catch (e) {
|
|
220
220
|
console.log("EEEEEEEEEEEEE", e)
|
package/kernel/shell.js
CHANGED
|
@@ -95,6 +95,7 @@ class Shell {
|
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
+
// this.env.TCELL_MINIMIZE=1
|
|
98
99
|
this.env.CMAKE_OBJECT_PATH_MAX = 1024
|
|
99
100
|
this.env.PYTORCH_ENABLE_MPS_FALLBACK = 1
|
|
100
101
|
this.env.TORCH_FORCE_NO_WEIGHTS_ONLY_LOAD = 1
|
|
@@ -923,6 +924,7 @@ class Shell {
|
|
|
923
924
|
this.done = false
|
|
924
925
|
this.ptyProcess = pty.spawn(this.shell, this.args, config)
|
|
925
926
|
this.ptyProcess.onData((data) => {
|
|
927
|
+
console.log({ data, done: this.done })
|
|
926
928
|
if (!this.done) {
|
|
927
929
|
this.queue.push(data)
|
|
928
930
|
}
|
|
@@ -985,6 +987,7 @@ class Shell {
|
|
|
985
987
|
// automatically remove the shell from this.kernel.shells
|
|
986
988
|
this.kernel.shell.rm(this.id)
|
|
987
989
|
this.ondata({ raw: `\r\n\r\n██ Terminated Shell ${this.id}\r\n████\r\n` })
|
|
990
|
+
this.ondata({ raw: "", type: "shell.kill" })
|
|
988
991
|
console.log("before cb 1")
|
|
989
992
|
cb()
|
|
990
993
|
} else {
|
|
@@ -994,10 +997,12 @@ class Shell {
|
|
|
994
997
|
// automatically remove the shell from this.kernel.shells
|
|
995
998
|
this.kernel.shell.rm(this.id)
|
|
996
999
|
this.ondata({ raw: `\r\n\r\n██ Terminated Shell ${this.id}\r\n████\r\n` })
|
|
1000
|
+
this.ondata({ raw: "", type: "shell.kill" })
|
|
997
1001
|
}
|
|
998
1002
|
} else {
|
|
999
1003
|
this.kernel.shell.rm(this.id)
|
|
1000
1004
|
this.ondata({ raw: `\r\n\r\n██ Terminated Shell ${this.id}\r\n████\r\n` })
|
|
1005
|
+
this.ondata({ raw: "", type: "shell.kill" })
|
|
1001
1006
|
}
|
|
1002
1007
|
|
|
1003
1008
|
|