dsh-hive-panel 0.1.6 → 0.2.0
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/CHANGELOG.md +38 -0
- package/README.md +70 -42
- package/README.zh-CN.md +56 -37
- package/SPEC.md +34 -3
- package/cordis.patch.yml +6 -4
- package/docs/DESIGN.md +94 -12
- package/lib/client.js +1183 -359
- package/lib/index.js +243 -11
- package/package.json +1 -1
- package/scripts/build-client.mjs +3 -0
- package/scripts/verify-host-exec.mjs +11 -5
- package/scripts/verify.mjs +230 -2
- package/src/client.template.js +51 -0
- package/src/panel.css +423 -93
- package/src/panel.js +1128 -358
- package/src/theme.css +1 -18
package/scripts/verify.mjs
CHANGED
|
@@ -22,6 +22,9 @@
|
|
|
22
22
|
* 11. An initialised repo auto-enters queen mode from op=snapshot (source
|
|
23
23
|
* "auto"), explicit off suppresses re-activation, queen-off is idempotent,
|
|
24
24
|
* and config autoQueen=false leaves activation to name=queen-on.
|
|
25
|
+
* 12. The default Hive bins stay PATH names; a missing one is retried once
|
|
26
|
+
* through npx with the declared package, an explicit absolute bin is never
|
|
27
|
+
* replaced, and a total miss carries an install hint.
|
|
25
28
|
*/
|
|
26
29
|
import assert from 'node:assert/strict'
|
|
27
30
|
import { spawnSync } from 'node:child_process'
|
|
@@ -81,6 +84,9 @@ assert.ok(clientSource.includes('hiveSessionId'), 'the tab body never receives t
|
|
|
81
84
|
assert.ok(clientSource.includes('messages: messages'), 'the inlined renderer does not expose its dictionaries')
|
|
82
85
|
assert.ok(clientSource.includes('ctx.locale.register('), 'the client half never registers locale dictionaries')
|
|
83
86
|
assert.ok(clientSource.includes('ctx.locale.bind('), 'the client half never binds the locale namespace')
|
|
87
|
+
assert.ok(clientSource.includes('uiWorkspace'), 'the client bundle never resolves workspace navigation')
|
|
88
|
+
assert.ok(clientSource.includes('hiveOpenSession'), 'the client bundle never forwards an open-session callback')
|
|
89
|
+
assert.ok(clientSource.includes('drawer.openChat'), 'the inlined renderer lost the Open agent chat copy')
|
|
84
90
|
assert.equal(clientSource.includes('/hive-panel/api'), false, 'the retired proxy prefix is still in the bundle')
|
|
85
91
|
assert.equal(clientSource.includes('7717'), false, 'the retired 7717 upstream is still in the bundle')
|
|
86
92
|
ok('client bundle uses /api/hive and forwards the Session id')
|
|
@@ -114,9 +120,23 @@ const locale = {
|
|
|
114
120
|
bind(ns) { localeBound.push(ns); return key => ({ 'view.label': 'Hive' })[key] ?? key },
|
|
115
121
|
subscribe() { return () => {} },
|
|
116
122
|
}
|
|
123
|
+
const openedSessions = []
|
|
124
|
+
const clientServices = {
|
|
125
|
+
sessions: {
|
|
126
|
+
subagentAddress(sessionId) {
|
|
127
|
+
return sessionId === 'child-1'
|
|
128
|
+
? { parentSessionId: 'parent-1', childSessionId: 'child-1', mode: 'one-shot' }
|
|
129
|
+
: undefined
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
uiWorkspace: {
|
|
133
|
+
openSession(target) { openedSessions.push(target) },
|
|
134
|
+
},
|
|
135
|
+
}
|
|
117
136
|
const clientEffects = []
|
|
118
137
|
client.apply({
|
|
119
138
|
effect(run) { const dispose = run(); clientEffects.push(dispose); return dispose },
|
|
139
|
+
get(name) { return clientServices[name] },
|
|
120
140
|
locale,
|
|
121
141
|
slots: {
|
|
122
142
|
inject(name, run) { assert.equal(name, 'conversation.view'); return run() },
|
|
@@ -134,14 +154,42 @@ const injected = slots[0].config.inject('session-42')
|
|
|
134
154
|
assert.equal(injected.hiveSessionId, 'session-42', 'the slot inject(sessionId) must reach the tab body')
|
|
135
155
|
assert.equal(typeof injected.hiveTranslate, 'function')
|
|
136
156
|
assert.equal(typeof injected.hiveLocaleSubscribe, 'function')
|
|
157
|
+
assert.equal(typeof injected.hiveOpenSession, 'function', 'a host with workspace navigation must receive the open-session callback')
|
|
158
|
+
injected.hiveOpenSession('child-1')
|
|
159
|
+
assert.deepEqual(openedSessions[0], {
|
|
160
|
+
parentSessionId: 'parent-1',
|
|
161
|
+
childSessionId: 'child-1',
|
|
162
|
+
mode: 'one-shot',
|
|
163
|
+
}, 'the callback forwards the catalog address when the client knows the child')
|
|
164
|
+
injected.hiveOpenSession('child-unknown')
|
|
165
|
+
assert.equal(openedSessions[1], 'child-unknown', 'an unknown-to-the-catalog child is opened by its bare Session id')
|
|
137
166
|
const bodySource = String(slots[0].component)
|
|
138
167
|
assert.ok(bodySource.includes('HIVE_PANEL.mount('), 'the tab body does not mount the shared renderer')
|
|
139
168
|
assert.ok(bodySource.includes('hiveSessionId'), 'the tab body does not read the injected Session id')
|
|
140
169
|
assert.ok(bodySource.includes('op=snapshot'), 'the tab body does not point at the native snapshot URL')
|
|
141
170
|
assert.ok(bodySource.includes('op=action&name={name}'), 'the tab body does not point at the native action URL')
|
|
171
|
+
assert.ok(bodySource.includes('hiveOpenSession'), 'the tab body does not read the injected open-session callback')
|
|
172
|
+
assert.ok(bodySource.includes('openSession:'), 'the tab body does not forward openSession to the renderer mount')
|
|
142
173
|
assert.deepEqual(Object.keys(localeRegistrations.map(entry => entry.dictionaries)[0]).sort(), ['en', 'zh'])
|
|
143
174
|
ok('apply() registers a conversation.view tab with Session-scoped inject()')
|
|
144
175
|
|
|
176
|
+
// A host without workspace navigation gets no callback, so the renderer never
|
|
177
|
+
// renders its chat button (no disabled placeholder).
|
|
178
|
+
const bareSlots = []
|
|
179
|
+
client.apply({
|
|
180
|
+
effect(run) { return run() },
|
|
181
|
+
get() { return undefined },
|
|
182
|
+
locale,
|
|
183
|
+
slots: {
|
|
184
|
+
inject(name, run) { assert.equal(name, 'conversation.view'); return run() },
|
|
185
|
+
register(config, component) { bareSlots.push({ config, component }); return () => {} },
|
|
186
|
+
},
|
|
187
|
+
})
|
|
188
|
+
const bareInjected = bareSlots[0].config.inject('session-42')
|
|
189
|
+
assert.equal(bareInjected.hiveSessionId, 'session-42')
|
|
190
|
+
assert.equal(Object.hasOwn(bareInjected, 'hiveOpenSession'), false, 'a host without uiWorkspace must not receive openSession')
|
|
191
|
+
ok('a host without ctx.uiWorkspace gets no openSession callback')
|
|
192
|
+
|
|
145
193
|
// ── 5. host surface: no proxy, one Connection Fetch route ───────────────────
|
|
146
194
|
const hostSource = await readFile(files.host, 'utf8')
|
|
147
195
|
for (const banned of ['webServer', '7717', 'node:http', 'node:https', 'createProxyHandler', 'resolveUpstream', 'buildUpstreamPath']) {
|
|
@@ -152,7 +200,7 @@ assert.equal(host.name, 'hive-panel')
|
|
|
152
200
|
assert.equal(host.FETCH_PATH, '/api/hive')
|
|
153
201
|
assert.deepEqual(host.inject, ['connection', 'sessions', 'workingDirectory', 'shell', 'agents', 'systemPrompt', 'commands'])
|
|
154
202
|
assert.equal(host.ACTION_NAMES.length, 18)
|
|
155
|
-
for (const name of ['init', 'add', 'plan', 'claim', 'done', 'fail', 'retry', '
|
|
203
|
+
for (const name of ['init', 'add', 'plan', 'claim', 'done', 'fail', 'retry', 'renew', 'mode', 'learn', 'recall', 'verdict', 'run', 'commit', 'doctor', 'roles-add', 'roles-remove', 'remove']) {
|
|
156
204
|
assert.ok(host.ACTION_NAMES.includes(name), 'the allowlist is missing ' + name)
|
|
157
205
|
}
|
|
158
206
|
ok('host half has no proxy code; exports the native route + action allowlist')
|
|
@@ -305,7 +353,7 @@ async function call(route, { method = 'GET', query = {}, body } = {}) {
|
|
|
305
353
|
assert.equal(outcome.body.writable, false)
|
|
306
354
|
assert.equal(outcome.body.mode.mode, 'free')
|
|
307
355
|
assert.deepEqual(outcome.body.board, [{ agent: 'w1', state: 'claimed', task: 'c1' }])
|
|
308
|
-
assert.deepEqual(outcome.body.tasks, [{ id: 'c1', title: 'card one', state: 'pending', role: 'coder' }])
|
|
356
|
+
assert.deepEqual(outcome.body.tasks, [{ id: 'c1', title: 'card one', state: 'pending', role: 'coder', lastRun: null }])
|
|
309
357
|
assert.equal(outcome.body.stats.total, 1)
|
|
310
358
|
assert.equal(outcome.body.events.length, 2)
|
|
311
359
|
assert.equal(outcome.body.events[0].kind, 'task_done', 'events must be newest-first')
|
|
@@ -359,6 +407,70 @@ async function call(route, { method = 'GET', query = {}, body } = {}) {
|
|
|
359
407
|
ok('an uninitialised repo returns the empty contract after only the refs probe')
|
|
360
408
|
}
|
|
361
409
|
|
|
410
|
+
// ── 6c. per-card lastRun from .hive/runs/<id>.json ─────────────────────────
|
|
411
|
+
{
|
|
412
|
+
const runsRepo = join(fixture, 'runs-repo')
|
|
413
|
+
mkdirSync(join(runsRepo, '.hive', 'runs'), { recursive: true })
|
|
414
|
+
const doneRecord = {
|
|
415
|
+
cardId: 'c1',
|
|
416
|
+
agent: 'dsh',
|
|
417
|
+
startedAt: '2026-12-04T00:00:00.000Z',
|
|
418
|
+
endedAt: '2026-12-04T00:05:00.000Z',
|
|
419
|
+
status: 'done',
|
|
420
|
+
exitCode: 0,
|
|
421
|
+
commit: 'abcdef1234567890',
|
|
422
|
+
sessionId: 'child-1',
|
|
423
|
+
agentName: 'lead/agent-1',
|
|
424
|
+
output: 'worker output\n',
|
|
425
|
+
}
|
|
426
|
+
// A pre-0.6.4 record has no worker identity; it must keep its exact shape.
|
|
427
|
+
const legacyRecord = {
|
|
428
|
+
cardId: 'c4',
|
|
429
|
+
agent: 'dsh',
|
|
430
|
+
startedAt: '2026-12-04T00:06:00.000Z',
|
|
431
|
+
endedAt: '2026-12-04T00:07:00.000Z',
|
|
432
|
+
status: 'failed',
|
|
433
|
+
exitCode: 1,
|
|
434
|
+
output: 'legacy output\n',
|
|
435
|
+
}
|
|
436
|
+
writeFileSync(join(runsRepo, '.hive', 'runs', 'c1.json'), JSON.stringify(doneRecord))
|
|
437
|
+
writeFileSync(join(runsRepo, '.hive', 'runs', 'c4.json'), JSON.stringify(legacyRecord))
|
|
438
|
+
writeFileSync(join(runsRepo, '.hive', 'runs', 'c2.json'), '{ not json')
|
|
439
|
+
const runShim = createCtx({
|
|
440
|
+
live: new Map([['s-runs', { id: 's-runs', header: { id: 's-runs', cwd: runsRepo } }]]),
|
|
441
|
+
shell: spec => {
|
|
442
|
+
const command = spec.command
|
|
443
|
+
if (command.includes("'list'") && !command.includes("'roles'")) {
|
|
444
|
+
return {
|
|
445
|
+
exitCode: 0,
|
|
446
|
+
stdout: JSON.stringify([
|
|
447
|
+
{ id: 'c1', title: 'ran once', state: 'done', role: 'coder' },
|
|
448
|
+
{ id: 'c2', title: 'corrupt record', state: 'failed', role: 'coder' },
|
|
449
|
+
{ id: 'c3', title: 'never ran', state: 'pending', role: 'coder' },
|
|
450
|
+
{ id: '../escape', title: 'traversal attempt', state: 'pending', role: 'coder' },
|
|
451
|
+
{ id: 'c4', title: 'legacy record', state: 'failed', role: 'coder' },
|
|
452
|
+
]),
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
return defaultShellResult(spec)
|
|
456
|
+
},
|
|
457
|
+
})
|
|
458
|
+
host.apply(runShim.ctx, {})
|
|
459
|
+
const outcome = await call(runShim.routes.get('/api/hive'), { query: { op: 'snapshot', sessionId: 's-runs' } })
|
|
460
|
+
assert.equal(outcome.status, 200)
|
|
461
|
+
const [ran, corrupt, never, unsafe, legacy] = outcome.body.tasks
|
|
462
|
+
assert.deepEqual(ran.lastRun, doneRecord, 'a valid record is attached verbatim under lastRun')
|
|
463
|
+
assert.equal(ran.lastRun.sessionId, 'child-1', 'the worker Session id must reach the panel snapshot')
|
|
464
|
+
assert.equal(ran.lastRun.agentName, 'lead/agent-1', 'the worker name must reach the panel snapshot')
|
|
465
|
+
assert.equal(corrupt.lastRun, null, 'a corrupt record degrades to null instead of failing the snapshot')
|
|
466
|
+
assert.equal(never.lastRun, null, 'a card without a record gets lastRun null')
|
|
467
|
+
assert.equal(unsafe.lastRun, null, 'a card id that is not a safe token never reads outside .hive/runs')
|
|
468
|
+
assert.deepEqual(legacy.lastRun, legacyRecord, 'a record without worker identity keeps its exact previous shape')
|
|
469
|
+
assert.equal(Object.hasOwn(legacy.lastRun, 'sessionId'), false, 'a legacy record must not gain a sessionId key')
|
|
470
|
+
assert.equal(host.RUNS_DIR, join('.hive', 'runs'))
|
|
471
|
+
ok('each snapshot card carries lastRun read from .hive/runs/<id>.json; worker sessionId/agentName pass through, corrupt/missing/unsafe ids degrade to null')
|
|
472
|
+
}
|
|
473
|
+
|
|
362
474
|
// ── 7. cold session + unknown session ───────────────────────────────────────
|
|
363
475
|
{
|
|
364
476
|
const shim = createCtx({
|
|
@@ -390,6 +502,7 @@ async function call(route, { method = 'GET', query = {}, body } = {}) {
|
|
|
390
502
|
assert.ok(catalog.body.actions.includes('queen-on'))
|
|
391
503
|
assert.ok(catalog.body.actions.includes('queen-off'))
|
|
392
504
|
assert.ok(catalog.body.actions.includes('roles-add'))
|
|
505
|
+
assert.ok(catalog.body.actions.includes('roles-remove'))
|
|
393
506
|
assert.ok(catalog.body.actions.includes('remove'))
|
|
394
507
|
assert.equal(catalog.body.actions.length, 20)
|
|
395
508
|
const unknown = await call(route, { query: { op: 'nope', sessionId: 's-live' } })
|
|
@@ -602,6 +715,63 @@ async function call(route, { method = 'GET', query = {}, body } = {}) {
|
|
|
602
715
|
ok('remove sends hive tasks rm through the router, validates the card id and passes stderr through')
|
|
603
716
|
}
|
|
604
717
|
|
|
718
|
+
// ── 10e. roles-remove action ───────────────────────────────────────────────
|
|
719
|
+
{
|
|
720
|
+
const shim = createCtx({
|
|
721
|
+
live,
|
|
722
|
+
cwdOf,
|
|
723
|
+
shell: spec => {
|
|
724
|
+
if (spec.command.includes("'roles'") && spec.command.includes("'rm'")) {
|
|
725
|
+
if (spec.command.includes("'ghost'")) {
|
|
726
|
+
return { exitCode: 2, stderr: 'hive roles: role "ghost" not found in .hive/roles.yaml\n' }
|
|
727
|
+
}
|
|
728
|
+
return { exitCode: 0, stdout: 'removed role reviewer from .hive/roles.yaml\nkept .hive/roles/reviewer.md (pass --keep-file to silence)\n' }
|
|
729
|
+
}
|
|
730
|
+
return defaultShellResult(spec)
|
|
731
|
+
},
|
|
732
|
+
})
|
|
733
|
+
host.apply(shim.ctx, { writable: true })
|
|
734
|
+
const route = shim.routes.get('/api/hive')
|
|
735
|
+
const removed = await call(route, { method: 'POST', query: { op: 'action', name: 'roles-remove', sessionId: 's-live' }, body: { name: 'reviewer' } })
|
|
736
|
+
assert.equal(removed.status, 200)
|
|
737
|
+
assert.deepEqual(removed.body, {
|
|
738
|
+
ok: true,
|
|
739
|
+
code: 0,
|
|
740
|
+
stdout: 'removed role reviewer from .hive/roles.yaml\nkept .hive/roles/reviewer.md (pass --keep-file to silence)\n',
|
|
741
|
+
stderr: '',
|
|
742
|
+
})
|
|
743
|
+
const execution = shim.executions.at(-1)
|
|
744
|
+
assert.equal(execution.command, "'hive' 'roles' 'rm' 'reviewer'", 'roles-remove must call hive roles rm')
|
|
745
|
+
assert.equal(execution.command.includes('--force'), false, 'roles-remove must never send --force')
|
|
746
|
+
assert.equal(execution.command.includes('--keep-file'), false, 'roles-remove must never send --keep-file')
|
|
747
|
+
assert.equal(execution.workdir, repo, 'roles-remove must run in the Session repository')
|
|
748
|
+
assert.deepEqual(execution.sandboxPolicy, { mode: 'workspace-write', workspaceRoot: repo, sessionId: 's-live' })
|
|
749
|
+
assert.equal(host.commandForAction('roles-remove', { name: 'reviewer' }), "'hive' 'roles' 'rm' 'reviewer'")
|
|
750
|
+
|
|
751
|
+
const before = shim.executions.length
|
|
752
|
+
for (const body of [{}, { name: 'Reviewer' }, { name: 'a' }, { name: 'x; rm -rf /' }, { name: 'a'.repeat(33) }]) {
|
|
753
|
+
const rejected = await call(route, { method: 'POST', query: { op: 'action', name: 'roles-remove', sessionId: 's-live' }, body })
|
|
754
|
+
assert.equal(rejected.status, 400, 'roles-remove must reject ' + JSON.stringify(body))
|
|
755
|
+
assert.equal(rejected.body.ok, false)
|
|
756
|
+
assert.equal(rejected.body.code, 2)
|
|
757
|
+
assert.match(rejected.body.stderr, /^hive\/invalid-argument: /)
|
|
758
|
+
}
|
|
759
|
+
assert.equal(shim.executions.length, before, 'a rejected roles-remove must not spawn anything')
|
|
760
|
+
|
|
761
|
+
// A missing role is a normal CLI refusal: exit 2 + stderr pass through unchanged.
|
|
762
|
+
const missing = await call(route, { method: 'POST', query: { op: 'action', name: 'roles-remove', sessionId: 's-live' }, body: { name: 'ghost' } })
|
|
763
|
+
assert.equal(missing.status, 400)
|
|
764
|
+
assert.deepEqual(missing.body, { ok: false, code: 2, stdout: '', stderr: 'hive roles: role "ghost" not found in .hive/roles.yaml\n' })
|
|
765
|
+
|
|
766
|
+
const readonly = createCtx({ live, cwdOf })
|
|
767
|
+
host.apply(readonly.ctx, {})
|
|
768
|
+
const denied = await call(readonly.routes.get('/api/hive'), { method: 'POST', query: { op: 'action', name: 'roles-remove', sessionId: 's-live' }, body: { name: 'reviewer' } })
|
|
769
|
+
assert.equal(denied.status, 403)
|
|
770
|
+
assert.deepEqual(denied.body, { ok: false, code: 2, stdout: '', stderr: 'read-only: hive-panel writable=false' })
|
|
771
|
+
assert.equal(readonly.executions.length, 0)
|
|
772
|
+
ok('roles-remove sends hive roles rm, rejects bad names, requires writable and passes CLI stderr through')
|
|
773
|
+
}
|
|
774
|
+
|
|
605
775
|
// ── 11. fail loud without ctx.shell ─────────────────────────────────────────
|
|
606
776
|
{
|
|
607
777
|
const shim = createCtx({ live, cwdOf, shell: null })
|
|
@@ -754,6 +924,64 @@ async function call(route, { method = 'GET', query = {}, body } = {}) {
|
|
|
754
924
|
ok('queen state is in-memory only (no custom session event is appended)')
|
|
755
925
|
}
|
|
756
926
|
|
|
927
|
+
// ── 14. PATH -> npx fallback for the default Hive binaries ─────────────────
|
|
928
|
+
{
|
|
929
|
+
assert.deepEqual(host.DEFAULT_BINS, { hive: 'hive', tasks: 'hive-tasks', run: 'hive-run', moc: 'moc' })
|
|
930
|
+
assert.deepEqual(
|
|
931
|
+
host.npxInvocation('tasks', ['list', '--json']),
|
|
932
|
+
['-y', '-p', 'hive-tasks', 'hive-tasks', 'list', '--json'],
|
|
933
|
+
)
|
|
934
|
+
assert.match(host.npxInvocation('hive', ['board', '--json']).join(' '), /-p @d86e\/hive -p hive-consensus/)
|
|
935
|
+
assert.equal(host.fallbackCommandForBin('tasks', ['list'], { tasks: '/abs/hive-tasks.js' }), null, 'an explicit absolute bin must never be replaced')
|
|
936
|
+
assert.equal(
|
|
937
|
+
host.fallbackCommandForBin('tasks', ['list', '--json']),
|
|
938
|
+
"'npx' '-y' '-p' 'hive-tasks' 'hive-tasks' 'list' '--json'",
|
|
939
|
+
)
|
|
940
|
+
ok('DEFAULT_BINS stay PATH names; only a bare name gets the npx fallback')
|
|
941
|
+
|
|
942
|
+
// A shell without hive-tasks/hive on PATH: every first attempt exits 127 and
|
|
943
|
+
// the host retries the same argv once through npx.
|
|
944
|
+
const shim = createCtx({
|
|
945
|
+
live,
|
|
946
|
+
cwdOf,
|
|
947
|
+
shell: spec => {
|
|
948
|
+
if (spec.command.startsWith("'npx'")) return defaultShellResult(spec)
|
|
949
|
+
if (spec.command.includes("'for-each-ref'")) return { exitCode: 0, stdout: 'refs/hive/v1/mode\n' }
|
|
950
|
+
if (spec.command.includes("'cat-file'")) return { exitCode: 0, stdout: '{"v":1,"mode":"free"}' }
|
|
951
|
+
return { exitCode: 127, stderr: 'bash: line 1: hive: command not found' }
|
|
952
|
+
},
|
|
953
|
+
})
|
|
954
|
+
host.apply(shim.ctx, {})
|
|
955
|
+
const route = shim.routes.get('/api/hive')
|
|
956
|
+
const outcome = await call(route, { query: { op: 'snapshot', sessionId: 's-live' } })
|
|
957
|
+
assert.equal(outcome.status, 200)
|
|
958
|
+
assert.equal(outcome.body.initialised, true)
|
|
959
|
+
const commands = shim.executions.map(entry => entry.command)
|
|
960
|
+
assert.ok(commands.includes("'npx' '-y' '-p' 'hive-tasks' 'hive-tasks' 'list' '--json'"), 'snapshot must retry hive-tasks through npx')
|
|
961
|
+
assert.ok(commands.includes("'hive' 'board' '--json'"), 'snapshot must try the PATH name first')
|
|
962
|
+
assert.ok(commands.some(command => command.startsWith("'npx' '-y' '-p' '@d86e/hive'")), 'snapshot must retry hive through npx')
|
|
963
|
+
ok('a missing PATH bin is retried once through npx -y -p <package>')
|
|
964
|
+
|
|
965
|
+
// An explicit absolute bin is the operator's choice: no npx substitution, and
|
|
966
|
+
// the failure carries the install hint instead.
|
|
967
|
+
const pinned = createCtx({
|
|
968
|
+
live,
|
|
969
|
+
cwdOf,
|
|
970
|
+
shell: spec => {
|
|
971
|
+
if (spec.command.includes("'for-each-ref'")) return { exitCode: 0, stdout: 'refs/hive/v1/mode\n' }
|
|
972
|
+
if (spec.command.includes("'cat-file'")) return { exitCode: 0, stdout: '{"v":1,"mode":"free"}' }
|
|
973
|
+
return { exitCode: 127, stderr: 'bash: /abs/hive: No such file or directory' }
|
|
974
|
+
},
|
|
975
|
+
})
|
|
976
|
+
host.apply(pinned.ctx, { bins: { hive: '/abs/hive', tasks: '/abs/hive-tasks' } })
|
|
977
|
+
const pinnedRoute = pinned.routes.get('/api/hive')
|
|
978
|
+
const pinnedSnapshot = await call(pinnedRoute, { query: { op: 'snapshot', sessionId: 's-live' } })
|
|
979
|
+
assert.equal(pinnedSnapshot.status, 200)
|
|
980
|
+
assert.equal(pinned.executions.some(entry => entry.command.startsWith("'npx'")), false, 'an absolute bin must not be replaced by npx')
|
|
981
|
+
assert.match(pinnedSnapshot.body.roles.error, /not found on the PATH of the DSH shell/)
|
|
982
|
+
ok('an explicit absolute bin is never replaced; its failure carries the install hint')
|
|
983
|
+
}
|
|
984
|
+
|
|
757
985
|
rmSync(fixture, { recursive: true, force: true })
|
|
758
986
|
|
|
759
987
|
console.log('\n' + String(results.length) + ' checks passed')
|
package/src/client.template.js
CHANGED
|
@@ -13,6 +13,12 @@
|
|
|
13
13
|
* Transport: same-origin, cookie-authenticated Connection Fetch route
|
|
14
14
|
* `/api/hive` (GET snapshot/actions, POST action). No separate service, no
|
|
15
15
|
* proxy port, no client-side cwd.
|
|
16
|
+
*
|
|
17
|
+
* Opening a worker's chat is a client navigation, not an HTTP route: the mount
|
|
18
|
+
* option `openSession(sessionId)` is implemented below with the same
|
|
19
|
+
* `ctx.uiWorkspace.openSession()` call the header's subagent catalog makes. A
|
|
20
|
+
* host without that service receives no callback, so the renderer renders no
|
|
21
|
+
* "Open agent chat" button.
|
|
16
22
|
*/
|
|
17
23
|
window.__ModuleLoader__.load({
|
|
18
24
|
id: 'dsh-hive-panel',
|
|
@@ -23,6 +29,46 @@ window.__ModuleLoader__.load({
|
|
|
23
29
|
const HIVE_API_PREFIX = '/api/hive'
|
|
24
30
|
const HIVE_NS = 'hive-panel'
|
|
25
31
|
|
|
32
|
+
/**
|
|
33
|
+
* Resolve one optional client service without hard-depending on it, so the
|
|
34
|
+
* panel still loads in profiles that do not mount workspace navigation.
|
|
35
|
+
*/
|
|
36
|
+
function clientService(ctx, name) {
|
|
37
|
+
return typeof ctx.get === 'function' ? ctx.get(name) : undefined;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Whether this host exposes the Workspace navigation API. */
|
|
41
|
+
function canOpenSession(ctx) {
|
|
42
|
+
const navigation = clientService(ctx, 'uiWorkspace');
|
|
43
|
+
return navigation !== undefined && typeof navigation.openSession === 'function';
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Open the Session a Hive worker ran in. This mirrors one click on a row of
|
|
48
|
+
* the conversation header's subagent catalog: the client selection changes
|
|
49
|
+
* through ctx.uiWorkspace.openSession(target); there is no /session/<id>
|
|
50
|
+
* route to push. A SubagentAddress carries the breadcrumb facts when the
|
|
51
|
+
* catalog or Session list already knows the child; a bare id is enough
|
|
52
|
+
* otherwise because the client resolves it against the host Session list.
|
|
53
|
+
*/
|
|
54
|
+
function openSession(ctx, sessionId) {
|
|
55
|
+
if (typeof sessionId !== 'string' || sessionId === '') return;
|
|
56
|
+
const navigation = clientService(ctx, 'uiWorkspace');
|
|
57
|
+
if (navigation === undefined || typeof navigation.openSession !== 'function') {
|
|
58
|
+
console.warn('[hive-panel] uiWorkspace.openSession is unavailable; cannot open the worker chat');
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
const sessions = clientService(ctx, 'sessions');
|
|
62
|
+
const address = typeof sessions?.subagentAddress === 'function'
|
|
63
|
+
? sessions.subagentAddress(sessionId)
|
|
64
|
+
: undefined;
|
|
65
|
+
try {
|
|
66
|
+
navigation.openSession(address === undefined ? sessionId : address);
|
|
67
|
+
} catch (error) {
|
|
68
|
+
console.warn('[hive-panel] opening the worker Session failed:', error);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
26
72
|
/* __HIVE_PANEL_MODULE__ */
|
|
27
73
|
|
|
28
74
|
// The slot config declares the dictionary namespace and passes the bound
|
|
@@ -42,6 +88,11 @@ window.__ModuleLoader__.load({
|
|
|
42
88
|
hiveSessionId: typeof sessionId === 'string' ? sessionId : '',
|
|
43
89
|
hiveTranslate: t,
|
|
44
90
|
hiveLocaleSubscribe: (listener) => ctx.locale.subscribe(listener),
|
|
91
|
+
// Only a host with client navigation receives the callback, so the
|
|
92
|
+
// renderer renders no chat button anywhere else (no disabled stub).
|
|
93
|
+
...(canOpenSession(ctx)
|
|
94
|
+
? { hiveOpenSession: (childSessionId) => { openSession(ctx, childSessionId) } }
|
|
95
|
+
: {}),
|
|
45
96
|
}),
|
|
46
97
|
}, HivePanelMount))
|
|
47
98
|
}
|