pinokiod 3.9.27 → 3.9.29
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 +0 -24
- package/kernel/api/input/index.js +2 -1
- package/kernel/api/shell/index.js +1 -1
- package/kernel/bin/git.js +0 -2
- package/kernel/bin/index.js +0 -16
- package/kernel/index.js +26 -35
- package/kernel/loader.js +1 -0
- package/kernel/plugin.js +25 -21
- package/kernel/prototype.js +41 -34
- package/kernel/shells.js +6 -2
- package/package.json +1 -1
- package/server/index.js +153 -38
- package/server/public/fseditor.js +2 -9
- package/server/public/modalinput.js +28 -9
- package/server/public/opener.js +0 -1
- package/server/public/style.css +44 -5
- package/server/views/app.ejs +50 -40
- package/server/views/connect.ejs +96 -13
- package/server/views/network.ejs +4 -2
- package/server/views/partials/dynamic.ejs +3 -5
- package/server/views/partials/menu.ejs +1 -1
- package/server/views/prototype/index.ejs +967 -310
- package/server/views/prototype/old_index.ejs +646 -0
- package/server/views/prototype/show.ejs +11 -158
- package/server/views/settings.ejs +6 -3
package/kernel/api/index.js
CHANGED
|
@@ -173,8 +173,6 @@ class Api {
|
|
|
173
173
|
// 1. set the "stop" flag for the uri, so the next execution in the queue for the uri will NOT queue another task
|
|
174
174
|
// 2. stream a message closing the socket
|
|
175
175
|
|
|
176
|
-
console.log("STOP", req)
|
|
177
|
-
|
|
178
176
|
if (req.params.id) {
|
|
179
177
|
// /Users/x/pinokio/prototype/system/aicode/template/claude.json?cwd=/Users/x/pinokio/api/MMAudio.git
|
|
180
178
|
// take the first part only since the rest is the cwd
|
|
@@ -191,18 +189,12 @@ class Api {
|
|
|
191
189
|
}
|
|
192
190
|
// reset modules
|
|
193
191
|
let modpath = this.resolvePath(cwd, req.params.uri)
|
|
194
|
-
console.log("STOP modpath", modpath)
|
|
195
|
-
console.log("this.mods before", this.mods)
|
|
196
|
-
console.log("this.child_procs before", this.child_procs)
|
|
197
192
|
if (this.child_procs[modpath]) {
|
|
198
193
|
let child_procs = Array.from(this.child_procs[modpath])
|
|
199
194
|
for(let proc of child_procs) {
|
|
200
|
-
console.log("reset child proc", proc)
|
|
201
195
|
delete this.mods[proc]
|
|
202
196
|
}
|
|
203
197
|
delete this.child_procs[modpath]
|
|
204
|
-
console.log("this.mods after", this.mods)
|
|
205
|
-
console.log("this.child_procs after", this.child_procs)
|
|
206
198
|
}
|
|
207
199
|
|
|
208
200
|
|
|
@@ -225,10 +217,7 @@ class Api {
|
|
|
225
217
|
this.waiter[requestPath].reject()
|
|
226
218
|
delete this.waiter[requestPath]
|
|
227
219
|
}
|
|
228
|
-
|
|
229
|
-
console.log("Stop", { req, requestPath })
|
|
230
220
|
if (req.params.id) {
|
|
231
|
-
console.log("delete", req.params.id, this.running[req.params.id])
|
|
232
221
|
delete this.running[req.params.id]
|
|
233
222
|
delete this.kernel.memory.local[req.params.id]
|
|
234
223
|
} else {
|
|
@@ -496,15 +485,12 @@ class Api {
|
|
|
496
485
|
let method
|
|
497
486
|
let dirname
|
|
498
487
|
let mod
|
|
499
|
-
console.log(">> resolveMethod", { req, cwd })
|
|
500
488
|
if (req.method && typeof req.method === "function") {
|
|
501
|
-
console.log(">> 1")
|
|
502
489
|
modpath = null
|
|
503
490
|
method = req.method
|
|
504
491
|
dirname = __dirname
|
|
505
492
|
mod = null
|
|
506
493
|
} else if (req.uri) {
|
|
507
|
-
console.log(">> 2")
|
|
508
494
|
modpath = this.resolvePath(cwd, req.uri)
|
|
509
495
|
let m = (await this.loader.load(modpath))
|
|
510
496
|
const stats = await fs.promises.stat(modpath)
|
|
@@ -536,7 +522,6 @@ class Api {
|
|
|
536
522
|
}
|
|
537
523
|
mod = m.resolved
|
|
538
524
|
dirname = m.dirname
|
|
539
|
-
console.log({ m })
|
|
540
525
|
method = mod[req.method].bind(mod)
|
|
541
526
|
} else {
|
|
542
527
|
// KERNEL
|
|
@@ -551,11 +536,9 @@ class Api {
|
|
|
551
536
|
}
|
|
552
537
|
method = mod[methodName].bind(mod)
|
|
553
538
|
} else {
|
|
554
|
-
console.log(">> 3")
|
|
555
539
|
if (chunks.length === 1) {
|
|
556
540
|
let methodName = chunks[0]
|
|
557
541
|
modpath = path.resolve(__dirname, methodName)
|
|
558
|
-
console.log({ modpath })
|
|
559
542
|
mod = (await this.loader.load(modpath))
|
|
560
543
|
method = mod.resolved
|
|
561
544
|
dirname = mod.dirname
|
|
@@ -660,8 +643,6 @@ class Api {
|
|
|
660
643
|
cwd = request.cwd
|
|
661
644
|
}
|
|
662
645
|
|
|
663
|
-
console.log("STEP", { request, rawrpc, input, args })
|
|
664
|
-
|
|
665
646
|
let id = request.id || request.path
|
|
666
647
|
|
|
667
648
|
let memory = {
|
|
@@ -717,7 +698,6 @@ class Api {
|
|
|
717
698
|
}
|
|
718
699
|
// replace {{{ }}} with {{ }}
|
|
719
700
|
rpc = this.kernel.template.flatten(rpc)
|
|
720
|
-
console.log({ rpc })
|
|
721
701
|
|
|
722
702
|
// 6. rpc must have method names
|
|
723
703
|
if (rpc.method) {
|
|
@@ -732,8 +712,6 @@ class Api {
|
|
|
732
712
|
// 7. resolve the rpc
|
|
733
713
|
let resolved = await this.resolveMethod(rpc, cwd)
|
|
734
714
|
|
|
735
|
-
console.log({ resolved })
|
|
736
|
-
|
|
737
715
|
// 8. the endpoint must exist
|
|
738
716
|
if (!resolved.method) {
|
|
739
717
|
this.ondata({
|
|
@@ -1146,7 +1124,6 @@ class Api {
|
|
|
1146
1124
|
this.queues[queue_id] = fastq.promise(async ({ request, rawrpc, input, step, total, cwd, args }) => {
|
|
1147
1125
|
try {
|
|
1148
1126
|
let response = await this.step(request, rawrpc, input, step, total, args)
|
|
1149
|
-
console.log("Handle Response", { request, response })
|
|
1150
1127
|
if (response) {
|
|
1151
1128
|
if (response.rawrpc) {
|
|
1152
1129
|
this.queue(response.request, response.rawrpc, response.input, response.step, response.total, cwd, args)
|
|
@@ -1268,7 +1245,6 @@ class Api {
|
|
|
1268
1245
|
}
|
|
1269
1246
|
}
|
|
1270
1247
|
async process(request, done) {
|
|
1271
|
-
console.log("Process", request)
|
|
1272
1248
|
/**************************************************************
|
|
1273
1249
|
*
|
|
1274
1250
|
* req := { uri: <relative path>|<absolute path>|<url> }
|
|
@@ -2,6 +2,7 @@ module.exports = async (req, ondata, kernel) => {
|
|
|
2
2
|
// send "input" type event so the frontend triggers a modal
|
|
3
3
|
ondata(req.params, "input")
|
|
4
4
|
// then, wait until the frontend responds
|
|
5
|
-
let
|
|
5
|
+
let id = req.parent.id || req.parent.path
|
|
6
|
+
let response = await kernel.api.wait(id)
|
|
6
7
|
return response
|
|
7
8
|
}
|
|
@@ -129,7 +129,7 @@ class Shell {
|
|
|
129
129
|
req.params.cols = req.client.cols
|
|
130
130
|
}
|
|
131
131
|
let response = await kernel.shell.run(req.params, options, async (stream) => {
|
|
132
|
-
process.stdout.write(stream.raw)
|
|
132
|
+
// process.stdout.write(stream.raw)
|
|
133
133
|
ondata(stream)
|
|
134
134
|
})
|
|
135
135
|
return response
|
package/kernel/bin/git.js
CHANGED
|
@@ -42,11 +42,9 @@ class Git {
|
|
|
42
42
|
async installed() {
|
|
43
43
|
if (this.kernel.platform === "darwin") {
|
|
44
44
|
let gh_config_exists = await this.kernel.exists("config/gh")
|
|
45
|
-
console.log("conda installed", this.kernel.bin.installed.conda)
|
|
46
45
|
return this.kernel.bin.installed.conda && this.kernel.bin.installed.conda.has("git") && this.kernel.bin.installed.brew.has("gh") && gh_config_exists
|
|
47
46
|
} else {
|
|
48
47
|
let gh_config_exists = await this.kernel.exists("config/gh")
|
|
49
|
-
console.log("conda installed", this.kernel.bin.installed.conda)
|
|
50
48
|
return this.kernel.bin.installed.conda && this.kernel.bin.installed.conda.has("git") && this.kernel.bin.installed.conda.has("gh") && gh_config_exists
|
|
51
49
|
}
|
|
52
50
|
}
|
package/kernel/bin/index.js
CHANGED
|
@@ -39,20 +39,7 @@ class Bin {
|
|
|
39
39
|
this.platform = os.platform()
|
|
40
40
|
}
|
|
41
41
|
async shell_kill(params, ondata) {
|
|
42
|
-
console.log("shell_kill", params)
|
|
43
42
|
this.kernel.shell.kill(params.params)
|
|
44
|
-
|
|
45
|
-
// let id = params.params.id
|
|
46
|
-
// console.log("id", id)
|
|
47
|
-
// console.log("api.running", this.kernel.api.running)
|
|
48
|
-
// delete this.kernel.api.running[id]
|
|
49
|
-
// delete this.kernel.memory.local[id]
|
|
50
|
-
//
|
|
51
|
-
// ondata({
|
|
52
|
-
// id,
|
|
53
|
-
// type: "disconnect"
|
|
54
|
-
// })
|
|
55
|
-
// this.kernel.refresh(true)
|
|
56
43
|
}
|
|
57
44
|
async shell_start(params, ondata) {
|
|
58
45
|
params.path = params.path || this.path()
|
|
@@ -183,7 +170,6 @@ class Bin {
|
|
|
183
170
|
// return a single merged env object, constructed from all the modules
|
|
184
171
|
|
|
185
172
|
// 1. get the module envs
|
|
186
|
-
console.log("this.mods", this.mods)
|
|
187
173
|
let envs = this.mods.map((mod) => {
|
|
188
174
|
if (mod.name === "vs") {
|
|
189
175
|
// don't include vs now
|
|
@@ -255,8 +241,6 @@ class Bin {
|
|
|
255
241
|
return file.endsWith(".js") && file !== "index.js" && file !== "cmake.js"
|
|
256
242
|
})
|
|
257
243
|
|
|
258
|
-
console.log("BIN INIT")
|
|
259
|
-
|
|
260
244
|
for(let filename of modfiles) {
|
|
261
245
|
// 1. get all the modules in __dirname
|
|
262
246
|
// 2. load them
|
package/kernel/index.js
CHANGED
|
@@ -637,7 +637,6 @@ class Kernel {
|
|
|
637
637
|
this.shell.init().then(async () => {
|
|
638
638
|
// this.bin.check()
|
|
639
639
|
if (this.envs) {
|
|
640
|
-
console.log("template.update")
|
|
641
640
|
this.template.update({
|
|
642
641
|
env: this.envs,
|
|
643
642
|
envs: this.envs,
|
|
@@ -652,7 +651,6 @@ class Kernel {
|
|
|
652
651
|
return null
|
|
653
652
|
}
|
|
654
653
|
} catch (e) {
|
|
655
|
-
console.log(`>> which ${name}`, e)
|
|
656
654
|
return null
|
|
657
655
|
}
|
|
658
656
|
} else {
|
|
@@ -660,6 +658,23 @@ class Kernel {
|
|
|
660
658
|
}
|
|
661
659
|
}
|
|
662
660
|
})
|
|
661
|
+
if (this.bin.installed.conda.has("git")) {
|
|
662
|
+
await this.proto.init()
|
|
663
|
+
await this.plugin.init()
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
this.sys = new Sysinfo()
|
|
667
|
+
await this.sys.init(this)
|
|
668
|
+
let info = this.sys.info
|
|
669
|
+
|
|
670
|
+
this.sysinfo = info
|
|
671
|
+
|
|
672
|
+
await this.getInfo()
|
|
673
|
+
|
|
674
|
+
await fs.promises.mkdir(this.path("logs"), { recursive: true }).catch((e) => { })
|
|
675
|
+
await fs.promises.writeFile(this.path("logs/system.json"), JSON.stringify(this.i, null, 2))
|
|
676
|
+
let pwpath = this.bin.path("playwright/node_modules/playwright")
|
|
677
|
+
this.playwright = (await this.loader.load(pwpath)).resolved
|
|
663
678
|
|
|
664
679
|
// get env
|
|
665
680
|
if (!this.launch_complete) {
|
|
@@ -703,9 +718,7 @@ class Kernel {
|
|
|
703
718
|
|
|
704
719
|
//await this.shell.init()
|
|
705
720
|
|
|
706
|
-
console.log("********************************************", { homedir: this.homedir })
|
|
707
721
|
if (this.homedir) {
|
|
708
|
-
console.log("> 1")
|
|
709
722
|
await this.template.init({
|
|
710
723
|
kernel: this,
|
|
711
724
|
system,
|
|
@@ -715,30 +728,6 @@ class Kernel {
|
|
|
715
728
|
return this.api.get_proxy_url("/proxy", port)
|
|
716
729
|
},
|
|
717
730
|
})
|
|
718
|
-
console.log("> 2")
|
|
719
|
-
this.sys = new Sysinfo()
|
|
720
|
-
await this.sys.init(this)
|
|
721
|
-
console.log("> 3")
|
|
722
|
-
let info = this.sys.info
|
|
723
|
-
|
|
724
|
-
this.sysinfo = info
|
|
725
|
-
|
|
726
|
-
await this.getInfo()
|
|
727
|
-
console.log("> 4")
|
|
728
|
-
|
|
729
|
-
await fs.promises.mkdir(this.path("logs"), { recursive: true }).catch((e) => { })
|
|
730
|
-
console.log("> 5")
|
|
731
|
-
await fs.promises.writeFile(this.path("logs/system.json"), JSON.stringify(this.i, null, 2))
|
|
732
|
-
console.log("> 6")
|
|
733
|
-
let pwpath = this.bin.path("playwright/node_modules/playwright")
|
|
734
|
-
this.playwright = (await this.loader.load(pwpath)).resolved
|
|
735
|
-
|
|
736
|
-
console.log("> 7")
|
|
737
|
-
|
|
738
|
-
await this.proto.init()
|
|
739
|
-
console.log("> 8")
|
|
740
|
-
await this.plugin.init()
|
|
741
|
-
console.log("> 9")
|
|
742
731
|
|
|
743
732
|
// refresh every 5 second
|
|
744
733
|
if (this.refresh_interval) {
|
|
@@ -763,13 +752,15 @@ class Kernel {
|
|
|
763
752
|
}
|
|
764
753
|
async update_sysinfo() {
|
|
765
754
|
try {
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
755
|
+
if (this.sys) {
|
|
756
|
+
await this.sys.refresh()
|
|
757
|
+
let info = this.sys.info
|
|
758
|
+
this.template.update(info)
|
|
759
|
+
this.sysinfo = info
|
|
760
|
+
this.gpu = info.gpu
|
|
761
|
+
this.gpu_model = info.gpu_model
|
|
762
|
+
this.gpus = info.gpus
|
|
763
|
+
}
|
|
773
764
|
} catch (e) {
|
|
774
765
|
console.log("sysinfo error", e)
|
|
775
766
|
}
|
package/kernel/loader.js
CHANGED
package/kernel/plugin.js
CHANGED
|
@@ -4,30 +4,34 @@ class Plugin {
|
|
|
4
4
|
this.kernel = kernel
|
|
5
5
|
}
|
|
6
6
|
async init() {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
7
|
+
if (this.kernel.bin.installed.conda.has("git")) {
|
|
8
|
+
// if ~/pinokio/prototype doesn't exist, clone
|
|
9
|
+
let exists = await this.kernel.exists("plugin")
|
|
10
|
+
if (!exists) {
|
|
11
|
+
await this.kernel.exec({
|
|
12
|
+
message: "git clone https://github.com/peanutcocktail/plugin",
|
|
13
|
+
path: this.kernel.homedir
|
|
14
|
+
}, (e) => {
|
|
15
|
+
process.stdout.write(e.raw)
|
|
16
|
+
})
|
|
17
|
+
}
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
let plugin_dir = path.resolve(this.kernel.homedir, "plugin")
|
|
20
|
+
let pinokiojs = path.resolve(plugin_dir, "pinokio.js")
|
|
21
|
+
this.config = await this.kernel.require(pinokiojs)
|
|
22
|
+
}
|
|
21
23
|
}
|
|
22
24
|
async update() {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
if (this.kernel.bin.installed.conda.has("git")) {
|
|
26
|
+
let exists = await this.kernel.exists("plugin")
|
|
27
|
+
if (!exists) {
|
|
28
|
+
await this.kernel.exec({
|
|
29
|
+
message: "git pull",
|
|
30
|
+
path: this.kernel.path("plugin")
|
|
31
|
+
}, (e) => {
|
|
32
|
+
process.stdout.write(e.raw)
|
|
33
|
+
})
|
|
34
|
+
}
|
|
31
35
|
}
|
|
32
36
|
}
|
|
33
37
|
}
|
package/kernel/prototype.js
CHANGED
|
@@ -7,43 +7,50 @@ class Proto {
|
|
|
7
7
|
this.kernel = kernel
|
|
8
8
|
}
|
|
9
9
|
async init() {
|
|
10
|
-
|
|
11
|
-
// if ~/pinokio/prototype doesn't exist, clone
|
|
12
|
-
let exists = await this.kernel.exists("prototype")
|
|
13
|
-
if (!exists) {
|
|
14
|
-
console.log("prototype doesn't exist. cloning...")
|
|
15
|
-
await fs.promises.mkdir(this.kernel.path("prototype"), { recursive: true }).catch((e) => { })
|
|
16
|
-
await this.kernel.exec({
|
|
17
|
-
message: "git clone https://github.com/peanutcocktail/prototype system",
|
|
18
|
-
path: this.kernel.path("prototype")
|
|
19
|
-
}, (e) => {
|
|
20
|
-
process.stdout.write(e.raw)
|
|
21
|
-
})
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
let cwd = path.resolve(this.kernel.homedir, "prototype")
|
|
26
|
-
let prototype_paths = (await glob('**/pinokio.js', { cwd }))
|
|
27
|
-
let prototype_dir = path.resolve(this.kernel.homedir, "prototype")
|
|
28
10
|
this.items = []
|
|
29
11
|
this.kv = {}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
let
|
|
34
|
-
if (
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
this.items.push(c)
|
|
45
|
-
this.kv[proto] = c
|
|
12
|
+
if (this.kernel.bin.installed.conda.has("git")) {
|
|
13
|
+
|
|
14
|
+
// if ~/pinokio/prototype doesn't exist, clone
|
|
15
|
+
let exists = await this.kernel.exists("prototype")
|
|
16
|
+
if (!exists) {
|
|
17
|
+
console.log("prototype doesn't exist. cloning...")
|
|
18
|
+
await fs.promises.mkdir(this.kernel.path("prototype"), { recursive: true }).catch((e) => { })
|
|
19
|
+
await this.kernel.exec({
|
|
20
|
+
//message: "git clone https://github.com/peanutcocktail/prototype system",
|
|
21
|
+
message: "git clone https://github.com/cocktailpeanutlabs/proto system",
|
|
22
|
+
path: this.kernel.path("prototype")
|
|
23
|
+
}, (e) => {
|
|
24
|
+
process.stdout.write(e.raw)
|
|
25
|
+
})
|
|
46
26
|
}
|
|
27
|
+
|
|
28
|
+
let pinokiojs_path = this.kernel.path("prototype/system/pinokio.js")
|
|
29
|
+
let config = await this.kernel.require(pinokiojs_path)
|
|
30
|
+
this.config = config
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
//// let prototype_paths = (await glob('**/pinokio.js', { cwd }))
|
|
35
|
+
// let prototype_dir = path.resolve(this.kernel.homedir, "prototype")
|
|
36
|
+
// for(let prototype_path of prototype_paths) {
|
|
37
|
+
// let proto = path.dirname(prototype_path)
|
|
38
|
+
// let pinokiojs = path.resolve(prototype_dir, prototype_path)
|
|
39
|
+
// let config = await this.kernel.require(pinokiojs)
|
|
40
|
+
// if (config && config.run) {
|
|
41
|
+
// if (config.icon) {
|
|
42
|
+
// config.icon = "/prototype/" + proto + "/" + config.icon
|
|
43
|
+
// } else {
|
|
44
|
+
// config.icon === "/pinokio-black.png"
|
|
45
|
+
// }
|
|
46
|
+
// let c = {
|
|
47
|
+
// id: proto,
|
|
48
|
+
// ...config
|
|
49
|
+
// }
|
|
50
|
+
// this.items.push(c)
|
|
51
|
+
// this.kv[proto] = c
|
|
52
|
+
// }
|
|
53
|
+
// }
|
|
47
54
|
}
|
|
48
55
|
}
|
|
49
56
|
async readme(proto) {
|
package/kernel/shells.js
CHANGED
|
@@ -145,7 +145,9 @@ class Shells {
|
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
|
-
ondata
|
|
148
|
+
if (ondata) {
|
|
149
|
+
ondata(stream)
|
|
150
|
+
}
|
|
149
151
|
})
|
|
150
152
|
/*
|
|
151
153
|
{
|
|
@@ -284,7 +286,9 @@ class Shells {
|
|
|
284
286
|
// if the stream includes "prompt": true, don't emit the event since that event is only for
|
|
285
287
|
// handling listeners
|
|
286
288
|
if (!stream.prompt) {
|
|
287
|
-
ondata
|
|
289
|
+
if (ondata) {
|
|
290
|
+
ondata(stream)
|
|
291
|
+
}
|
|
288
292
|
}
|
|
289
293
|
if (params.on) {
|
|
290
294
|
for(let handler of params.on) {
|