pinokiod 8.3.13 → 8.3.15

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 (53) hide show
  1. package/kernel/agent_instructions.js +0 -1
  2. package/kernel/api/index.js +76 -12
  3. package/kernel/environment.js +1 -1
  4. package/kernel/index.js +15 -2
  5. package/kernel/plugin_sources.js +1 -1
  6. package/kernel/prototype.js +1 -1
  7. package/kernel/request_file.js +5 -14
  8. package/kernel/shell.js +12 -0
  9. package/kernel/shells.js +13 -1
  10. package/package.json +1 -1
  11. package/server/index.js +10 -5
  12. package/server/lib/agent_jobs.js +198 -0
  13. package/server/lib/agent_sessions.js +131 -0
  14. package/server/lib/brain.js +161 -91
  15. package/server/lib/content_validation.js +1 -1
  16. package/server/public/agent-bar-app.js +28 -6
  17. package/server/public/agent-bar-compose.css +675 -0
  18. package/server/public/agent-bar-compose.js +658 -0
  19. package/server/public/agent-bar-panel.css +2 -0
  20. package/server/public/agent-bar-panel.js +22 -7
  21. package/server/public/agent-bar-shell.css +38 -0
  22. package/server/public/agent-bar-shell.js +128 -34
  23. package/server/public/agent-bar.css +7 -1
  24. package/server/public/agent-bar.js +10 -1
  25. package/server/public/terminal_input_utils.js +4 -0
  26. package/server/views/app.ejs +5 -1
  27. package/server/views/partials/main_sidebar.ejs +2 -0
  28. package/system/plugin/antigravity-cli-auto/pinokio.js +44 -6
  29. package/system/plugin/claude/pinokio.js +43 -1
  30. package/system/plugin/claude-auto/pinokio.js +43 -1
  31. package/system/plugin/codex/pinokio.js +42 -1
  32. package/system/plugin/codex-auto/pinokio.js +42 -1
  33. package/system/plugin/grok/pinokio.js +1 -1
  34. package/system/plugin/grok-auto/pinokio.js +37 -10
  35. package/system/plugin/opencode/pinokio.js +24 -0
  36. package/system/plugin/opencode-auto/pinokio.js +82 -10
  37. package/test/agent-bar-compose.test.js +544 -0
  38. package/test/agent-bar-shell.test.js +149 -0
  39. package/test/agent-instructions.test.js +0 -2
  40. package/test/agent-jobs.test.js +534 -0
  41. package/test/agent-sessions.test.js +130 -0
  42. package/test/antigravity-cli-plugin.test.js +63 -18
  43. package/test/anywhere-api.test.js +1 -1
  44. package/test/anywhere-onboarding.test.js +1 -2
  45. package/test/brain.test.js +116 -69
  46. package/test/grok-plugin.test.js +2 -1
  47. package/test/opencode-plugin.test.js +7 -4
  48. package/test/plugin-action-functions.test.js +423 -0
  49. package/test/request-file.test.js +1 -12
  50. package/test/shell-log-path.test.js +64 -0
  51. package/test/shell-stop-while-starting.test.js +70 -0
  52. package/test/shells-live-error.test.js +66 -2
  53. package/test/terminal-mouse-input.test.js +12 -0
@@ -0,0 +1,149 @@
1
+ // The shell button of an app page (server/public/agent-bar-shell.js): the
2
+ // button in the top bar and, for the page's phone layout, the "Open a shell" row
3
+ // at the end of the slide-in menu's list. Both show the same list and open a
4
+ // shell the same way.
5
+ //
6
+ // The real script runs here in a page that has only what it looks for. Layout
7
+ // is not covered: this page lays nothing out.
8
+ const assert = require('node:assert/strict')
9
+ const fs = require('node:fs')
10
+ const path = require('node:path')
11
+ const test = require('node:test')
12
+ const { JSDOM } = require('jsdom')
13
+
14
+ const script = fs.readFileSync(path.resolve(__dirname, '../server/public/agent-bar-shell.js'), 'utf8')
15
+
16
+ // Run mode has the Ask AI button (it carries the app's folder); Dev has the
17
+ // folder on the app card's disk figure.
18
+ const appPage = (run) => '<!doctype html><body class="app-page">'
19
+ + '<header class="navheader"><h1>'
20
+ + (run ? '<button id="ask-ai-tab" data-workspace-cwd="/home/api/demo"></button>' : '<span class="disk-usage" data-filepath="/home/api/demo"></span>')
21
+ + '<div class="home-server-popover"></div></h1></header>'
22
+ + '<div class="appcanvas"><aside id="app-sidebar"><div class="menu-container"><div class="menu-scroller">'
23
+ + '<div class="workspace-mode-switch"></div><div class="m h menu"><a class="btn header-item frame-link" id="settings-tab"></a></div><div class="m s temp-menu"></div>'
24
+ + '</div></div></aside></div>'
25
+ + '<button class="mobile-menu-backdrop" data-mobile-menu-backdrop></button></body>'
26
+
27
+ const SHELLS = {
28
+ projectShell: {
29
+ items: [
30
+ { title: 'Shell', subtitle: 'Open a plain Bash shell', href: '/shell/demo_dev.bash.plain?path=%2Fhome%2Fapi%2Fdemo&session=running-one' },
31
+ { title: 'Python', href: '/shell/demo_dev.python?path=%2Fhome%2Fapi%2Fdemo' }
32
+ ]
33
+ }
34
+ }
35
+
36
+ async function page(t, options = {}) {
37
+ const reads = []
38
+ const opened = []
39
+ const posted = []
40
+ let failing = options.fail === true
41
+ const dom = new JSDOM(appPage(options.dev !== true), {
42
+ url: 'http://127.0.0.1:42000/p/demo',
43
+ runScripts: 'outside-only',
44
+ pretendToBeVisual: true,
45
+ beforeParse(window) {
46
+ window.fetch = async (url) => {
47
+ reads.push(String(url))
48
+ if (failing) return { ok: false, json: async () => ({}) }
49
+ return { ok: true, json: async () => SHELLS }
50
+ }
51
+ }
52
+ })
53
+ t.after(() => dom.window.close())
54
+ const { window } = dom
55
+ window.PinokioAgentDock = { openShellTool: (shell) => { opened.push(shell) } }
56
+ window.addEventListener('message', (event) => posted.push(event.data))
57
+ window.eval(script)
58
+ const { document } = window
59
+ // the row is put in once the page has been read to its end
60
+ if (document.readyState === 'loading') await new Promise((resolve) => document.addEventListener('DOMContentLoaded', resolve, { once: true }))
61
+ const row = document.querySelector('.agent-bar-shell-row')
62
+ return {
63
+ window,
64
+ document,
65
+ reads,
66
+ opened,
67
+ posted,
68
+ row,
69
+ toggle: row.querySelector('.agent-bar-shell-row__toggle'),
70
+ list: row.querySelector('.agent-bar-shell-row__list'),
71
+ items: () => Array.from(row.querySelectorAll('.agent-bar-shell-row__list .agent-bar-shell-row__item')),
72
+ recover() { failing = false },
73
+ settle: async () => { for (let i = 0; i < 4; i += 1) await new Promise((resolve) => window.setTimeout(resolve, 0)) }
74
+ }
75
+ }
76
+
77
+ test('the row is the last thing in the menu\'s list, after the rows the page redraws', async (t) => {
78
+ const p = await page(t)
79
+ const scroller = p.document.querySelector('.menu-scroller')
80
+ assert.equal(scroller.lastElementChild, p.row)
81
+ assert.equal(p.row.closest('.menu'), null, 'not inside the part the page replaces')
82
+ assert.equal(p.toggle.querySelector('.display').textContent, 'Open a shell')
83
+ assert.equal(p.list.hidden, true)
84
+ assert.equal(p.reads.length, 0, 'nothing is read until it is asked for')
85
+ })
86
+
87
+ test('a tap shows the app\'s shells under the row; another tap puts them away', async (t) => {
88
+ const p = await page(t)
89
+ p.toggle.click()
90
+ await p.settle()
91
+ assert.equal(p.list.hidden, false)
92
+ assert.equal(p.toggle.getAttribute('aria-expanded'), 'true')
93
+ assert.deepEqual(p.items().map((item) => item.querySelector('.display').textContent), ['Shell', 'Python'])
94
+ assert.equal(p.items()[0].querySelector('.agent-bar-shell-row__note').textContent, 'Open a plain Bash shell')
95
+ p.toggle.click()
96
+ assert.equal(p.list.hidden, true)
97
+ })
98
+
99
+ test('picking a shell closes the open menu and opens a new shell in the dock', async (t) => {
100
+ const p = await page(t)
101
+ let backdropPressed = 0
102
+ p.document.querySelector('[data-mobile-menu-backdrop]').addEventListener('click', () => { backdropPressed += 1 })
103
+ p.document.body.classList.add('mobile-menu-open')
104
+ p.toggle.click()
105
+ await p.settle()
106
+ p.items()[0].click()
107
+ await p.settle()
108
+ assert.equal(p.opened.length, 1)
109
+ assert.equal(p.opened[0].label, 'Shell')
110
+ // a new shell, not the one that is already running
111
+ assert.equal(p.opened[0].href, '/shell/demo_dev.bash.plain?path=%2Fhome%2Fapi%2Fdemo')
112
+ assert.equal(backdropPressed, 1)
113
+ assert.equal(p.list.hidden, true)
114
+ })
115
+
116
+ test('the row and the top bar\'s button read the list once between them', async (t) => {
117
+ const p = await page(t)
118
+ p.toggle.click()
119
+ await p.settle()
120
+ p.document.querySelector('.agent-bar-shell__trigger').click()
121
+ await p.settle()
122
+ assert.equal(p.reads.length, 1)
123
+ assert.equal(p.document.querySelectorAll('.agent-bar-shell__menu .agent-bar-shell__row').length, 2)
124
+ })
125
+
126
+ test('a list that cannot be read says so, and is read again on the next tap', async (t) => {
127
+ const p = await page(t, { fail: true })
128
+ p.toggle.click()
129
+ await p.settle()
130
+ assert.equal(p.list.textContent, "Couldn't read this app's shells.")
131
+ p.toggle.click()
132
+ p.recover()
133
+ p.toggle.click()
134
+ await p.settle()
135
+ assert.equal(p.items().length, 2)
136
+ assert.equal(p.reads.length, 2)
137
+ })
138
+
139
+ test('in Dev the pick is sent to the page as the Plugins page sends it', async (t) => {
140
+ const p = await page(t, { dev: true })
141
+ p.toggle.click()
142
+ await p.settle()
143
+ p.items()[1].click()
144
+ await p.settle()
145
+ assert.equal(p.opened.length, 0)
146
+ assert.equal(p.posted.length, 1)
147
+ assert.equal(p.posted[0].launch.label, 'Python')
148
+ assert.match(p.posted[0].launch.href, /^\/shell\/demo_dev\.python\?path=%2Fhome%2Fapi%2Fdemo&session=.+/)
149
+ })
@@ -6,8 +6,6 @@ const test = require("node:test")
6
6
 
7
7
  const AgentInstructions = require("../kernel/agent_instructions")
8
8
 
9
- // spec/requirements/instruction-sync.md, section 3
10
-
11
9
  const guide = "# Development Guide for Pinokio Projects\n\nthe guide for <%= app_root %>\n"
12
10
  const newHome = () => {
13
11
  const home = fs.mkdtempSync(path.join(os.tmpdir(), "pinokio-guide-"))