pinokiod 8.3.34 → 8.3.36

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.
@@ -8378,8 +8378,12 @@ body.dark .pinokio-custom-terminal-header {
8378
8378
  <script src="/storage-sweep.js"></script>
8379
8379
  <script src="/agent-bar.js" data-agent-bar="true"></script>
8380
8380
  <script src="/agent-bar-app.js" data-agent-bar-app="true"></script>
8381
+ <link rel="stylesheet" href="/agent-bar-agents.css">
8382
+ <script src="/agent-bar-agents.js" data-agent-bar-agents="true"></script>
8381
8383
  <link rel="stylesheet" href="/agent-bar-files.css">
8382
8384
  <script src="/agent-bar-files.js" data-agent-bar-files="true"></script>
8385
+ <link rel="stylesheet" href="/agent-bar-launch.css">
8386
+ <script src="/agent-bar-launch.js" data-agent-bar-launch="true"></script>
8383
8387
  <link rel="stylesheet" href="/agent-bar-panel.css">
8384
8388
  <script src="/agent-bar-panel.js" data-agent-bar-panel="true" data-pinokio-home="<%= locals.pinokioHome || '' %>"></script>
8385
8389
  <link rel="stylesheet" href="/agent-bar-attach.css">
@@ -5,8 +5,12 @@
5
5
  <link rel="stylesheet" href="/sidebar-create.css">
6
6
  <script src="/storage-sweep.js"></script>
7
7
  <script src="/agent-bar.js" data-agent-bar="true"></script>
8
+ <link rel="stylesheet" href="/agent-bar-agents.css">
9
+ <script src="/agent-bar-agents.js" data-agent-bar-agents="true"></script>
8
10
  <link rel="stylesheet" href="/agent-bar-files.css">
9
11
  <script src="/agent-bar-files.js" data-agent-bar-files="true"></script>
12
+ <link rel="stylesheet" href="/agent-bar-launch.css">
13
+ <script src="/agent-bar-launch.js" data-agent-bar-launch="true"></script>
10
14
  <link rel="stylesheet" href="/agent-bar-panel.css">
11
15
  <script src="/agent-bar-panel.js" data-agent-bar-panel="true" data-pinokio-home="<%= locals.pinokioHome || '' %>"></script>
12
16
  <link rel="stylesheet" href="/agent-bar-attach.css">
@@ -102,7 +102,7 @@
102
102
  <div class="plugin-detail-action-card" data-plugin-action-card="open">
103
103
  <div class="plugin-detail-action-copy">
104
104
  <div class="plugin-detail-action-label">Open in</div>
105
- <div class="plugin-detail-action-meta">Choose a project and launch this plugin there.</div>
105
+ <div class="plugin-detail-action-meta">Choose a project and ask about it with this plugin.</div>
106
106
  </div>
107
107
  <button class="task-button primary" type="button" data-plugin-open>
108
108
  <i class="fa-solid fa-bolt" aria-hidden="true"></i>
@@ -1916,6 +1916,8 @@ document.addEventListener("DOMContentLoaded", async () => {
1916
1916
  this.eventPanelStopPending = false
1917
1917
  this.resizeSync.reset()
1918
1918
  this.socket.run(payload, async (packet) => {
1919
+ // what a page showing this one in a frame cannot see otherwise (agent-bar-launch.js)
1920
+ if (packet.type === "error" || packet.type === "notify" || packet.type === "process.wait.start") refreshParent({ type: "pinokio:session-step", step: packet.type, data: packet.data })
1919
1921
  if (packet.type === 'start') {
1920
1922
  refreshParent(packet)
1921
1923
  reloadMemory()
@@ -0,0 +1,297 @@
1
+ // The agent menu (server/public/agent-bar-agents.js): a search box, and two tabs
2
+ // (Terminal, Desktop) when both kinds of agent are installed.
3
+ //
4
+ // The real agent-bar.js (and agent-bar-app.js for the app page's bar) run here in
5
+ // a page that has only a top bar. This page lays nothing out, so nothing here is
6
+ // about sizes or scrolling.
7
+ const assert = require('node:assert/strict')
8
+ const fs = require('node:fs')
9
+ const path = require('node:path')
10
+ const test = require('node:test')
11
+ const { JSDOM } = require('jsdom')
12
+
13
+ const publicDir = path.resolve(__dirname, '../server/public')
14
+ const read = (name) => fs.readFileSync(path.join(publicDir, name), 'utf8')
15
+ const barScript = read('agent-bar.js')
16
+ const appScript = read('agent-bar-app.js')
17
+ const agentsScript = read('agent-bar-agents.js')
18
+
19
+ const TOOL_KEY = 'pinokio.universalLauncher.tool'
20
+ const HOME_PAGE = '<!doctype html><body><header class="navheader"><h1><div class="flexible"></div></h1></header><main id="page"></main></body>'
21
+ const APP_PAGE = '<!doctype html><body class="app-page"><header class="navheader"><h1>'
22
+ + '<div class="app-header-identity"><span class="app-header-identity-title">Demo App</span></div>'
23
+ + '<button id="ask-ai-tab" data-workspace-cwd="/home/api/demo"></button><div class="flexible"></div></h1></header>'
24
+ + '<div class="appcanvas"><aside id="app-sidebar"><div class="menu-scroller"></div></aside><main id="page"></main>'
25
+ + '<div class="mobile-bottom-nav"><div class="mobile-bottom-nav__identity"></div></div></div></body>'
26
+
27
+ const MENU = [
28
+ { href: '/run/plugin/opencode/pinokio.js', title: 'Opencode' },
29
+ { href: '/run/plugin/claude/pinokio.js', title: 'Claude Code', default: true },
30
+ { href: '/run/plugin/claude-auto/pinokio.js', title: 'Claude Code Auto' },
31
+ { href: '/run/plugin/Devin/pinokio.js', title: 'Devin CLI' },
32
+ { href: '/run/plugin/Devin.git/pinokio.js', title: 'Devin CLI' },
33
+ { href: '/run/plugin/vscode/pinokio.js', title: 'VS Code', category: 'ide' },
34
+ { href: '/run/plugin/claude-desktop/pinokio.js', title: 'Claude Desktop', category: 'ide' },
35
+ ]
36
+
37
+ async function settle(window) {
38
+ for (let i = 0; i < 4; i += 1) await new Promise((resolve) => window.setTimeout(resolve, 0))
39
+ }
40
+
41
+ async function page(t, options = {}) {
42
+ const media = new Set(options.media || [])
43
+ const dom = new JSDOM(options.app ? APP_PAGE : HOME_PAGE, {
44
+ url: `http://127.0.0.1:42000/${options.app ? 'p/demo' : 'home'}`,
45
+ runScripts: 'outside-only',
46
+ pretendToBeVisual: true,
47
+ beforeParse(window) {
48
+ window.matchMedia = (query) => ({ matches: media.has(query), addEventListener() {}, removeEventListener() {} })
49
+ window.fetch = async (url) => {
50
+ if (String(url) === '/info/shells') return { ok: true, json: async () => [] }
51
+ if (String(url).split('?')[0] === '/api/plugin/menu') {
52
+ return { ok: true, json: async () => ({ menu: options.menu || MENU }) }
53
+ }
54
+ return { ok: false, json: async () => ({ ok: false, error: 'not sent in this test' }) }
55
+ }
56
+ if (options.stored) window.localStorage.setItem(TOOL_KEY, options.stored)
57
+ }
58
+ })
59
+ t.after(() => dom.window.close())
60
+ const { window } = dom
61
+ const { document } = window
62
+ window.eval(barScript)
63
+ if (options.app) window.eval(appScript)
64
+ window.eval(agentsScript)
65
+ await window.PinokioAgentBar.ready
66
+ await settle(window)
67
+ const root = document.querySelector('.agent-bar')
68
+ const menu = root.querySelector('.agent-bar__menu')
69
+ const search = () => menu.querySelector('.agent-menu__input')
70
+ const p = {
71
+ window,
72
+ document,
73
+ root,
74
+ menu,
75
+ search,
76
+ tabs: () => menu.querySelector('.agent-menu__tabs'),
77
+ tab: (key) => menu.querySelector(`.agent-menu__tab[data-tab="${key}"]`),
78
+ selectedTab: () => menu.querySelector('.agent-menu__tab[aria-selected="true"]').dataset.tab,
79
+ count: (key) => p.tab(key).querySelector('.agent-menu__count').textContent,
80
+ labels: () => Array.from(menu.querySelectorAll('.agent-menu__list .agent-bar__row-label')).map((node) => node.textContent),
81
+ notes: () => Array.from(menu.querySelectorAll('.agent-menu__list .agent-bar__row'))
82
+ .map((row) => (row.querySelector('.agent-bar__row-note') || {}).textContent || ''),
83
+ titles: () => Array.from(menu.querySelectorAll('.agent-menu__list .agent-bar__menu-title')).map((node) => node.textContent),
84
+ lit: () => {
85
+ const row = menu.querySelector('.agent-menu__list .agent-bar__row.is-active')
86
+ return row ? row.querySelector('.agent-bar__row-label').textContent : null
87
+ },
88
+ checked: () => Array.from(menu.querySelectorAll('.agent-menu__list .agent-bar__row'))
89
+ .filter((row) => row.querySelector('.agent-bar__row-check'))
90
+ .map((row) => row.querySelector('.agent-bar__row-label').textContent),
91
+ async open() {
92
+ root.querySelector('.agent-bar__agent').click()
93
+ await settle(window)
94
+ },
95
+ async type(text) {
96
+ search().value = text
97
+ search().dispatchEvent(new window.Event('input', { bubbles: true }))
98
+ await settle(window)
99
+ },
100
+ async key(key) {
101
+ const event = new window.KeyboardEvent('keydown', { key, bubbles: true, cancelable: true })
102
+ document.activeElement.dispatchEvent(event)
103
+ await settle(window)
104
+ },
105
+ }
106
+ return p
107
+ }
108
+
109
+ test('the menu has a search box and two tabs with counts, and opens on Terminal', async (t) => {
110
+ const p = await page(t)
111
+ await p.open()
112
+ assert.equal(p.menu.hidden, false)
113
+ assert.equal(p.menu.dataset.menu, 'agent')
114
+ assert.ok(p.search(), 'there is a search box')
115
+ assert.equal(p.tabs().hidden, false)
116
+ assert.equal(p.count('terminal'), '5')
117
+ assert.equal(p.count('desktop'), '2')
118
+ assert.equal(p.selectedTab(), 'terminal')
119
+ assert.deepEqual(p.labels(), ['Claude Code', 'Claude Code Auto', 'Devin CLI', 'Devin CLI', 'Opencode'])
120
+ assert.deepEqual(p.checked(), ['Claude Code'], 'the default agent is marked')
121
+ assert.equal(p.document.activeElement, p.search(), 'the search box takes the cursor')
122
+ })
123
+
124
+ test('a tab shows its own agents', async (t) => {
125
+ const p = await page(t)
126
+ await p.open()
127
+ p.tab('desktop').click()
128
+ await settle(p.window)
129
+ assert.equal(p.selectedTab(), 'desktop')
130
+ assert.deepEqual(p.labels(), ['Claude Desktop', 'VS Code'])
131
+ assert.equal(p.menu.hidden, false, 'the menu stays open')
132
+ })
133
+
134
+ test('the menu opens on the tab that holds the chosen agent', async (t) => {
135
+ const p = await page(t, { stored: 'vscode' })
136
+ await p.open()
137
+ assert.equal(p.selectedTab(), 'desktop')
138
+ assert.deepEqual(p.checked(), ['VS Code'])
139
+ })
140
+
141
+ test('agents with the same name show their folder names', async (t) => {
142
+ const p = await page(t)
143
+ await p.open()
144
+ assert.deepEqual(p.notes(), ['', '', 'Devin', 'Devin.git', ''])
145
+ })
146
+
147
+ test('typing searches both tabs, by name and by folder name', async (t) => {
148
+ const p = await page(t)
149
+ await p.open()
150
+ await p.type('claude')
151
+ assert.equal(p.tabs().hidden, true, 'the tabs step aside')
152
+ assert.deepEqual(p.titles(), ['Terminal', 'Desktop'])
153
+ assert.deepEqual(p.labels(), ['Claude Code', 'Claude Code Auto', 'Claude Desktop'])
154
+ assert.equal(p.lit(), 'Claude Code', 'the first match is lit')
155
+
156
+ await p.type('devin.git')
157
+ assert.deepEqual(p.labels(), ['Devin CLI'])
158
+ assert.deepEqual(p.notes(), ['Devin.git'])
159
+
160
+ await p.type('code auto')
161
+ assert.deepEqual(p.labels(), ['Claude Code Auto'], 'every word has to match')
162
+
163
+ await p.type('zzz')
164
+ assert.deepEqual(p.labels(), [])
165
+ assert.match(p.menu.querySelector('.agent-menu__list').textContent, /No agents match “zzz”/)
166
+
167
+ await p.type('')
168
+ assert.equal(p.tabs().hidden, false, 'the tabs come back')
169
+ assert.equal(p.lit(), null)
170
+ })
171
+
172
+ test('Up and Down move the lit row and Enter picks it', async (t) => {
173
+ const p = await page(t)
174
+ await p.open()
175
+ await p.type('claude')
176
+ await p.key('ArrowDown')
177
+ assert.equal(p.lit(), 'Claude Code Auto')
178
+ await p.key('ArrowDown')
179
+ await p.key('ArrowDown')
180
+ assert.equal(p.lit(), 'Claude Desktop', 'it stops at the last row')
181
+ await p.key('ArrowUp')
182
+ assert.equal(p.lit(), 'Claude Code Auto')
183
+ await p.key('Enter')
184
+ assert.equal(p.menu.hidden, true, 'the menu closes')
185
+ assert.equal(p.window.localStorage.getItem(TOOL_KEY), 'claude-auto', 'the pick is remembered')
186
+ assert.equal(p.root.querySelector('.agent-bar__agent').title, 'Runs with Claude Code Auto')
187
+ })
188
+
189
+ test('a click on a row picks it', async (t) => {
190
+ const p = await page(t)
191
+ await p.open()
192
+ p.tab('desktop').click()
193
+ await settle(p.window)
194
+ p.menu.querySelectorAll('.agent-menu__list .agent-bar__row')[1].click()
195
+ await settle(p.window)
196
+ assert.equal(p.menu.hidden, true)
197
+ assert.equal(p.window.localStorage.getItem(TOOL_KEY), 'vscode')
198
+ })
199
+
200
+ test('Escape clears the text first, then closes the menu', async (t) => {
201
+ const p = await page(t)
202
+ await p.open()
203
+ await p.type('open')
204
+ await p.key('Escape')
205
+ assert.equal(p.menu.hidden, false, 'the menu stays')
206
+ assert.equal(p.search().value, '')
207
+ assert.equal(p.tabs().hidden, false)
208
+ await p.key('Escape')
209
+ assert.equal(p.menu.hidden, true)
210
+ })
211
+
212
+ test('a redraw of the bar keeps what was typed, the tab and the cursor', async (t) => {
213
+ const p = await page(t)
214
+ await p.open()
215
+ p.tab('desktop').click()
216
+ await settle(p.window)
217
+ p.search().focus()
218
+ p.window.PinokioAgentBar.refresh()
219
+ await settle(p.window)
220
+ assert.equal(p.selectedTab(), 'desktop')
221
+ assert.equal(p.document.activeElement, p.search())
222
+
223
+ await p.type('vs')
224
+ p.search().setSelectionRange(1, 1)
225
+ p.search().dispatchEvent(new p.window.KeyboardEvent('keyup', { key: 'ArrowLeft', bubbles: true }))
226
+ p.window.PinokioAgentBar.refresh()
227
+ p.window.PinokioAgentBar.refresh()
228
+ await settle(p.window)
229
+ assert.equal(p.search().value, 'vs')
230
+ assert.deepEqual(p.labels(), ['VS Code'])
231
+ assert.equal(p.document.activeElement, p.search())
232
+ assert.equal(p.search().selectionStart, 1, 'the cursor is where it was')
233
+ })
234
+
235
+ test('each opening starts over', async (t) => {
236
+ const p = await page(t)
237
+ await p.open()
238
+ p.tab('desktop').click()
239
+ await settle(p.window)
240
+ await p.type('vs')
241
+ await p.open()
242
+ assert.equal(p.menu.hidden, true)
243
+ await p.open()
244
+ assert.equal(p.search().value, '')
245
+ assert.equal(p.selectedTab(), 'terminal')
246
+ assert.equal(p.tabs().hidden, false)
247
+ })
248
+
249
+ test('the bar\'s other menus, which use the same box, keep their own look', async (t) => {
250
+ const p = await page(t)
251
+ await p.open()
252
+ assert.ok(p.menu.classList.contains('agent-menu'))
253
+ p.root.querySelector('.agent-bar__scope').click()
254
+ await settle(p.window)
255
+ assert.equal(p.menu.dataset.menu, 'mode')
256
+ assert.equal(p.menu.classList.contains('agent-menu'), false)
257
+ assert.equal(p.menu.querySelector('.agent-menu__head'), null)
258
+ assert.equal(p.menu.querySelectorAll('.agent-bar__row').length, 4, 'the four modes')
259
+ })
260
+
261
+ test('with only one kind of agent there are no tabs', async (t) => {
262
+ const p = await page(t, { menu: MENU.filter((plugin) => plugin.category !== 'ide') })
263
+ await p.open()
264
+ assert.equal(p.tabs().hidden, true)
265
+ assert.equal(p.labels().length, 5)
266
+ await p.type('code')
267
+ assert.deepEqual(p.titles(), [], 'no headings either')
268
+ assert.deepEqual(p.labels(), ['Claude Code', 'Claude Code Auto', 'Opencode'])
269
+ })
270
+
271
+ test('on a touch screen the search box does not take the cursor', async (t) => {
272
+ const p = await page(t, { media: ['(hover: none)'] })
273
+ await p.open()
274
+ assert.equal(p.menu.hidden, false)
275
+ assert.notEqual(p.document.activeElement, p.search())
276
+ })
277
+
278
+ test('a press on a tab leaves the cursor where it is', async (t) => {
279
+ const p = await page(t)
280
+ await p.open()
281
+ const press = new p.window.MouseEvent('pointerdown', { bubbles: true, cancelable: true })
282
+ p.tab('desktop').dispatchEvent(press)
283
+ assert.equal(press.defaultPrevented, true)
284
+ })
285
+
286
+ test('the app page\'s bar has the same menu', async (t) => {
287
+ const p = await page(t, { app: true })
288
+ await p.open()
289
+ assert.equal(p.menu.hidden, false)
290
+ assert.equal(p.tabs().hidden, false)
291
+ assert.equal(p.count('terminal'), '5')
292
+ await p.type('desktop')
293
+ assert.deepEqual(p.labels(), ['Claude Desktop'])
294
+ await p.key('Enter')
295
+ assert.equal(p.menu.hidden, true)
296
+ assert.equal(p.window.localStorage.getItem(TOOL_KEY), 'claude-desktop')
297
+ })