@qvac/core 0.7.5 → 0.8.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 +79 -1
- package/dist-lib/lib/assistant/skill-encode.d.ts +1 -0
- package/dist-lib/lib/assistant/skill-encode.js +1 -0
- package/dist-lib/lib/core/blind-peers.d.ts +0 -3
- package/dist-lib/lib/core/chunk.d.ts +4 -0
- package/dist-lib/lib/core/contract/seed-defaults.js +2 -2
- package/dist-lib/lib/core/contract/writers.js +1 -1
- package/dist-lib/lib/core/departures.d.ts +5 -7
- package/dist-lib/lib/core/departures.js +14 -12
- package/dist-lib/lib/core/files/records/reclaim.js +1 -1
- package/dist-lib/lib/core/fs-drives.d.ts +2 -6
- package/dist-lib/lib/core/fs-drives.js +7 -30
- package/dist-lib/lib/core/mesh.d.ts +20 -7
- package/dist-lib/lib/core/mesh.js +205 -39
- package/dist-lib/lib/core/sync/index.d.ts +1 -0
- package/dist-lib/lib/core/sync/index.js +136 -67
- package/dist-lib/lib/core.d.ts +5 -10
- package/dist-lib/lib/core.js +156 -156
- package/dist-lib/schema/engine.js +5 -2
- package/dist-lib/spec/hrpc/messages.js +22 -6
- package/dist-lib/spec/hyperschema/index.js +22 -6
- package/dist-lib/spec/hyperschema/schema.json +15 -0
- package/dist-lib/spec/hyperschema/types.d.ts +3 -0
- package/package.json +1 -1
- package/tui/README.md +17 -13
- package/tui/app.mjs +234 -52
- package/tui/main.mjs +10 -3
package/tui/app.mjs
CHANGED
|
@@ -202,9 +202,10 @@ const COMMANDS = [
|
|
|
202
202
|
]
|
|
203
203
|
},
|
|
204
204
|
{
|
|
205
|
-
name: '
|
|
206
|
-
desc: "the agent's
|
|
205
|
+
name: 'tools',
|
|
206
|
+
desc: "the agent's toolset switches and the tools in each; space toggles a set"
|
|
207
207
|
},
|
|
208
|
+
{ name: 'permissions', desc: "the agent's approval mode; space toggles" },
|
|
208
209
|
{ name: 'attach', desc: 'attach one or more local files to this chat by path', palette: true },
|
|
209
210
|
{
|
|
210
211
|
name: 'save',
|
|
@@ -424,6 +425,7 @@ export const fg = {
|
|
|
424
425
|
green: style().foreground('brightgreen'),
|
|
425
426
|
amber: style().foreground('brightyellow'),
|
|
426
427
|
magenta: style().foreground('brightmagenta').bold(true),
|
|
428
|
+
heading: style().foreground('brightcyan').bold(true),
|
|
427
429
|
err: style().foreground('brightred')
|
|
428
430
|
}
|
|
429
431
|
|
|
@@ -667,27 +669,111 @@ const MODE_HINT = {
|
|
|
667
669
|
'skip-all': '⚠ acts on this device without ever asking'
|
|
668
670
|
}
|
|
669
671
|
|
|
670
|
-
// /permissions overlay: the approval mode on the first row, then one row per toolset.
|
|
671
672
|
export function formatPermissions(sel) {
|
|
672
|
-
const {
|
|
673
|
-
const
|
|
674
|
-
const
|
|
675
|
-
|
|
676
|
-
)
|
|
677
|
-
const lines = rows.map((name, i) => {
|
|
678
|
-
const point = i === cursor ? fg.magenta.render('❯ ') : ' '
|
|
679
|
-
if (name === MODE_ROW) {
|
|
680
|
-
const paint = mode === 'skip-all' ? fg.err : fg.cyan
|
|
681
|
-
const hint =
|
|
682
|
-
mode === 'skip-all' ? fg.err.render(MODE_HINT[mode]) : fg.dim.render(MODE_HINT[mode])
|
|
673
|
+
const { mode } = sel
|
|
674
|
+
const header = fg.dim.render('How should QV.AC actions be approved? — space toggle · esc return')
|
|
675
|
+
const paint = mode === 'skip-all' ? fg.err : fg.cyan
|
|
676
|
+
const hint = mode === 'skip-all' ? fg.err.render(MODE_HINT[mode]) : fg.dim.render(MODE_HINT[mode])
|
|
683
677
|
|
|
684
|
-
|
|
685
|
-
|
|
678
|
+
return [header, '', `${fg.magenta.render('❯ ')}${paint.render(MODE_LABEL[mode])} ${hint}`]
|
|
679
|
+
}
|
|
686
680
|
|
|
687
|
-
|
|
681
|
+
const TOOL_SUMMARY_MAX = 72
|
|
682
|
+
|
|
683
|
+
// knowledge reaches the model by injection, so its switch gates retrieval rather than a tool
|
|
684
|
+
const NO_TOOL_NOTE = { knowledge: 'no tool — it gates the excerpts added to each prompt' }
|
|
688
685
|
|
|
689
|
-
|
|
686
|
+
// the catalog description is written for the model, so its opening sentence is the human part
|
|
687
|
+
function toolSummary(description) {
|
|
688
|
+
const first = description.split(/(?<=\.)\s/)[0].replace(/\.$/, '')
|
|
689
|
+
|
|
690
|
+
return first.length > TOOL_SUMMARY_MAX ? `${first.slice(0, TOOL_SUMMARY_MAX - 1)}…` : first
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
const branch = (i, count) => fg.dim.render(` ${i === count - 1 ? '└' : '├'} `)
|
|
694
|
+
|
|
695
|
+
// one column across every set, so the summaries line up down the whole overlay
|
|
696
|
+
function toolLines(tools, { on, nameWidth }) {
|
|
697
|
+
return tools.map((tool, i) => {
|
|
698
|
+
const name = tool.name.padEnd(nameWidth)
|
|
699
|
+
// another device advertises its tools without descriptions
|
|
700
|
+
const notes = [tool.description && toolSummary(tool.description)]
|
|
701
|
+
if (tool.skillGated) {
|
|
702
|
+
notes.push('once its skill loads')
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
return `${branch(i, tools.length)}${on ? fg.white.render(name) : fg.dim.render(name)} ${fg.dim.render(notes.filter(Boolean).join(' · '))}`
|
|
690
706
|
})
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
function toolsetBlock(sel, name, i) {
|
|
710
|
+
const { rows, enabled, cursor, catalog, deviceName } = sel
|
|
711
|
+
const nameWidth = Math.max(...rows.map((row) => row.length))
|
|
712
|
+
const on = enabled.has(name)
|
|
713
|
+
const point = i === cursor ? fg.magenta.render('❯ ') : ' '
|
|
714
|
+
const badge = on ? fg.cyan.render('● on ') : fg.dim.render('○ off')
|
|
715
|
+
const title = on
|
|
716
|
+
? fg.heading.render(name.padEnd(nameWidth))
|
|
717
|
+
: fg.dim.render(name.padEnd(nameWidth))
|
|
718
|
+
const head = `${point}${badge} ${title} ${fg.dim.render(TOOLSET_HINTS[name] ?? '')}`
|
|
719
|
+
if (!catalog) {
|
|
720
|
+
return [head]
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
const tools = catalog.filter((tool) => tool.toolset === name)
|
|
724
|
+
if (!tools.length) {
|
|
725
|
+
return [
|
|
726
|
+
head,
|
|
727
|
+
branch(0, 1) +
|
|
728
|
+
fg.dim.render(NO_TOOL_NOTE[name] ?? `no tools on ${deviceName ?? 'this device'}`)
|
|
729
|
+
]
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
return [head, ...toolLines(tools, { on, nameWidth: toolNameWidth(catalog) })]
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
const toolNameWidth = (catalog) => Math.max(...catalog.map((tool) => tool.name.length))
|
|
736
|
+
|
|
737
|
+
// the line the cursor's set starts on, since every set spends a row per tool beneath it
|
|
738
|
+
export function toolsCursorLine(sel) {
|
|
739
|
+
let line = 2
|
|
740
|
+
for (let i = 0; i < sel.cursor; i++) {
|
|
741
|
+
line += toolsetBlock(sel, sel.rows[i], i).length
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
return line
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
// the switches still work when the host's list cannot be read, so the reason replaces the rows
|
|
748
|
+
function missingTools(reason, deviceName) {
|
|
749
|
+
if (reason === 'not-ours') {
|
|
750
|
+
return "(this agent runs on another member's device, which does not share its tool list)"
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
return reason
|
|
754
|
+
? emptySelector('tools', reason, deviceName)
|
|
755
|
+
: "(the agent's device could not list its tools)"
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
// /tools overlay: one switch per toolset, each listing the tools it gates on the agent's device.
|
|
759
|
+
export function formatTools(sel) {
|
|
760
|
+
const { rows, catalog, reason, deviceName } = sel
|
|
761
|
+
const header = fg.dim.render(
|
|
762
|
+
`Tools on ${deviceName ?? 'this device'}, by toolset — ↑/↓ move · space toggle a set · esc return`
|
|
763
|
+
)
|
|
764
|
+
const lines = rows.flatMap((name, i) => toolsetBlock(sel, name, i))
|
|
765
|
+
const loose = (catalog ?? []).filter((tool) => !tool.toolset)
|
|
766
|
+
if (loose.length) {
|
|
767
|
+
lines.push(
|
|
768
|
+
'',
|
|
769
|
+
` ${fg.heading.render('no toolset')} ${fg.dim.render('no switch turns these off')}`
|
|
770
|
+
)
|
|
771
|
+
lines.push(...toolLines(loose, { on: true, nameWidth: toolNameWidth(catalog) }))
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
if (!catalog) {
|
|
775
|
+
lines.push('', fg.dim.render(` ${missingTools(reason, deviceName)}`))
|
|
776
|
+
}
|
|
691
777
|
|
|
692
778
|
return [header, '', ...lines]
|
|
693
779
|
}
|
|
@@ -813,6 +899,10 @@ export function formatSelector(sel) {
|
|
|
813
899
|
return formatPermissions(sel)
|
|
814
900
|
}
|
|
815
901
|
|
|
902
|
+
if (kind === 'tools') {
|
|
903
|
+
return formatTools(sel)
|
|
904
|
+
}
|
|
905
|
+
|
|
816
906
|
if (kind === 'ctx') {
|
|
817
907
|
return formatContextSizes(sel)
|
|
818
908
|
}
|
|
@@ -1567,6 +1657,7 @@ const AGENT_COMMANDS = new Set([
|
|
|
1567
1657
|
'models',
|
|
1568
1658
|
'activity',
|
|
1569
1659
|
'skills',
|
|
1660
|
+
'tools',
|
|
1570
1661
|
'permissions',
|
|
1571
1662
|
'skill',
|
|
1572
1663
|
'scope',
|
|
@@ -2246,7 +2337,12 @@ export class ChatApp {
|
|
|
2246
2337
|
}
|
|
2247
2338
|
|
|
2248
2339
|
if (this._selector) {
|
|
2249
|
-
|
|
2340
|
+
const line =
|
|
2341
|
+
this._selector.kind === 'tools'
|
|
2342
|
+
? toolsCursorLine(this._selector)
|
|
2343
|
+
: this._selector.cursor + 2
|
|
2344
|
+
this._setRows(formatSelector(this._selector), line)
|
|
2345
|
+
|
|
2250
2346
|
return
|
|
2251
2347
|
}
|
|
2252
2348
|
|
|
@@ -2349,7 +2445,8 @@ export class ChatApp {
|
|
|
2349
2445
|
' /ctx — pick the agent’s context size (the current one and the model’s maximum shown) · /ctx <tokens> (8192, 8k; k = 1,024) · /ctx auto — clear it so the device default applies',
|
|
2350
2446
|
' /skills — browse installed; ↑/↓ move, space toggles each on/off (sets scope=selected), enter sets up or reconfigures the skill, esc returns',
|
|
2351
2447
|
' /skill on|off <name> — toggle (sets scope=selected)',
|
|
2352
|
-
' /
|
|
2448
|
+
' /tools — the toolset switches, each listing the tools it gates; ↑/↓ move, space toggles a set',
|
|
2449
|
+
' /permissions — the approval mode; space toggles',
|
|
2353
2450
|
' /models delete <name> · /models download <name> — remove a model from this device, or fetch it now',
|
|
2354
2451
|
' /models load <model> · unload <model> · pause <name> · resume <name> — load or unload a model now, or hold its download',
|
|
2355
2452
|
' /models idle <never|minutes> · cap <percent> · settings — free loaded models after that long with no request, the share of memory they may fill, and both settings',
|
|
@@ -3003,6 +3100,10 @@ export class ChatApp {
|
|
|
3003
3100
|
return this._showSelector(cmd)
|
|
3004
3101
|
}
|
|
3005
3102
|
|
|
3103
|
+
if (cmd === 'tools') {
|
|
3104
|
+
return this._showTools()
|
|
3105
|
+
}
|
|
3106
|
+
|
|
3006
3107
|
if (cmd === 'permissions') {
|
|
3007
3108
|
return this._showPermissions()
|
|
3008
3109
|
}
|
|
@@ -4618,9 +4719,7 @@ export class ChatApp {
|
|
|
4618
4719
|
return { names: [], reason: 'no-provider' }
|
|
4619
4720
|
}
|
|
4620
4721
|
|
|
4621
|
-
|
|
4622
|
-
const own = this.originDeviceId ?? (await this.engine.deviceInfo({})).id
|
|
4623
|
-
if (own && b4a.equals(own, provider)) {
|
|
4722
|
+
if (await this._hostedHere(provider)) {
|
|
4624
4723
|
const names = await this._localCaps(detail)
|
|
4625
4724
|
if (names.length) {
|
|
4626
4725
|
return { names, reason: null }
|
|
@@ -4644,32 +4743,70 @@ export class ChatApp {
|
|
|
4644
4743
|
return skills.map((s) => s.name)
|
|
4645
4744
|
}
|
|
4646
4745
|
|
|
4647
|
-
|
|
4746
|
+
async _hostedHere(provider) {
|
|
4747
|
+
// originDeviceId is bound late, so an early selector must ask rather than guess
|
|
4748
|
+
const own = this.originDeviceId ?? (await this.engine.deviceInfo({})).id
|
|
4749
|
+
|
|
4750
|
+
return !!own && b4a.equals(own, provider)
|
|
4751
|
+
}
|
|
4752
|
+
|
|
4648
4753
|
async _rosterCaps(provider, emptyReason) {
|
|
4754
|
+
const { dev, reason, deviceName } = await this._rosterDevice(provider)
|
|
4755
|
+
if (!dev) {
|
|
4756
|
+
return { names: [], reason, deviceName }
|
|
4757
|
+
}
|
|
4758
|
+
|
|
4759
|
+
const names = dev.installedSkillNames ?? []
|
|
4760
|
+
|
|
4761
|
+
return { names, reason: names.length ? null : emptyReason, deviceName: dev.name }
|
|
4762
|
+
}
|
|
4763
|
+
|
|
4764
|
+
// the account may have been closed, so it is named and opened, never assumed
|
|
4765
|
+
async _rosterDevice(provider) {
|
|
4649
4766
|
const { meshes } = await this.engine.listMeshes({})
|
|
4650
4767
|
const account = (meshes ?? []).find((m) => m.account)?.meshId
|
|
4651
4768
|
if (!account) {
|
|
4652
|
-
return {
|
|
4769
|
+
return { reason: 'no-account' }
|
|
4653
4770
|
}
|
|
4654
4771
|
|
|
4655
4772
|
const listed = await this._accountDevices(account)
|
|
4656
4773
|
if (!listed) {
|
|
4657
|
-
return {
|
|
4774
|
+
return { reason: 'account-closed' }
|
|
4658
4775
|
}
|
|
4659
4776
|
|
|
4660
4777
|
const hex = b4a.toHex(provider)
|
|
4661
4778
|
const dev = listed.find((d) => b4a.toHex(d.id) === hex)
|
|
4662
4779
|
if (!dev) {
|
|
4663
|
-
return {
|
|
4780
|
+
return { reason: 'not-ours' }
|
|
4664
4781
|
}
|
|
4665
4782
|
|
|
4666
4783
|
if (dev.revoked) {
|
|
4667
|
-
return {
|
|
4784
|
+
return { reason: 'removed', deviceName: dev.name }
|
|
4668
4785
|
}
|
|
4669
4786
|
|
|
4670
|
-
|
|
4787
|
+
return { dev }
|
|
4788
|
+
}
|
|
4671
4789
|
|
|
4672
|
-
|
|
4790
|
+
// the host's own catalog, since the switches gate the tools of the device the agent runs on
|
|
4791
|
+
async _providerTools() {
|
|
4792
|
+
const provider = this.agent?.providerDeviceId
|
|
4793
|
+
if (!provider) {
|
|
4794
|
+
return { catalog: null, reason: 'no-provider' }
|
|
4795
|
+
}
|
|
4796
|
+
|
|
4797
|
+
if (await this._hostedHere(provider)) {
|
|
4798
|
+
return { catalog: (await this.engine.tools({})).tools, reason: null }
|
|
4799
|
+
}
|
|
4800
|
+
|
|
4801
|
+
const { dev, reason, deviceName } = await this._rosterDevice(provider)
|
|
4802
|
+
if (!dev) {
|
|
4803
|
+
return { catalog: null, reason, deviceName }
|
|
4804
|
+
}
|
|
4805
|
+
|
|
4806
|
+
// an older build publishes no catalog, which is not the same as having no tools
|
|
4807
|
+
const catalog = dev.toolCatalog ?? null
|
|
4808
|
+
|
|
4809
|
+
return { catalog, reason: catalog ? null : 'none-advertised', deviceName: dev.name }
|
|
4673
4810
|
}
|
|
4674
4811
|
|
|
4675
4812
|
// a close racing the read rejects here, and an unreadable account is a message, not a failure
|
|
@@ -4844,7 +4981,6 @@ export class ChatApp {
|
|
|
4844
4981
|
return this._setContextSize(size)
|
|
4845
4982
|
}
|
|
4846
4983
|
|
|
4847
|
-
// rows come from TOOLSETS so an uninstalled toolset can still be switched off ahead of time
|
|
4848
4984
|
_showPermissions() {
|
|
4849
4985
|
const { engine, agent } = this
|
|
4850
4986
|
return [
|
|
@@ -4854,8 +4990,7 @@ export class ChatApp {
|
|
|
4854
4990
|
const fresh = await engine.getAgent({ meshId: this.meshId, agentId: agent.id })
|
|
4855
4991
|
return {
|
|
4856
4992
|
type: 'permissions.result',
|
|
4857
|
-
mode: fresh.approvalMode === 'skip-all' ? 'skip-all' : 'ask'
|
|
4858
|
-
disabled: fresh.disabledToolsets ?? []
|
|
4993
|
+
mode: fresh.approvalMode === 'skip-all' ? 'skip-all' : 'ask'
|
|
4859
4994
|
}
|
|
4860
4995
|
} catch (error) {
|
|
4861
4996
|
return { type: 'permissions.result', error }
|
|
@@ -4864,6 +4999,26 @@ export class ChatApp {
|
|
|
4864
4999
|
]
|
|
4865
5000
|
}
|
|
4866
5001
|
|
|
5002
|
+
// rows come from TOOLSETS so an uninstalled toolset can still be switched off ahead of time
|
|
5003
|
+
_showTools() {
|
|
5004
|
+
const { engine, agent } = this
|
|
5005
|
+
return [
|
|
5006
|
+
this,
|
|
5007
|
+
async () => {
|
|
5008
|
+
try {
|
|
5009
|
+
const [fresh, host] = await Promise.all([
|
|
5010
|
+
engine.getAgent({ meshId: this.meshId, agentId: agent.id }),
|
|
5011
|
+
// the switches still work without the list, so a failed read only loses the tool rows
|
|
5012
|
+
this._providerTools().catch(() => ({ catalog: null, reason: null }))
|
|
5013
|
+
])
|
|
5014
|
+
return { type: 'tools.result', disabled: fresh.disabledToolsets ?? [], ...host }
|
|
5015
|
+
} catch (error) {
|
|
5016
|
+
return { type: 'tools.result', error }
|
|
5017
|
+
}
|
|
5018
|
+
}
|
|
5019
|
+
]
|
|
5020
|
+
}
|
|
5021
|
+
|
|
4867
5022
|
// ctrl+p / /menu: open the menu at its root, clearing any other overlay first.
|
|
4868
5023
|
_openMenu() {
|
|
4869
5024
|
this._models = null
|
|
@@ -4904,7 +5059,8 @@ export class ChatApp {
|
|
|
4904
5059
|
cursor: 0,
|
|
4905
5060
|
entries: [
|
|
4906
5061
|
{ label: 'Skills', hint: 'toggle skills on/off', overlay: 'skills' },
|
|
4907
|
-
{ label: '
|
|
5062
|
+
{ label: 'Tools', hint: 'toolset switches & their tools', overlay: 'tools' },
|
|
5063
|
+
{ label: 'Permissions', hint: 'approval mode', overlay: 'permissions' },
|
|
4908
5064
|
{ label: 'Model', hint: "pick the agent's model", overlay: 'models' },
|
|
4909
5065
|
{
|
|
4910
5066
|
label: 'Context size',
|
|
@@ -5190,6 +5346,10 @@ export class ChatApp {
|
|
|
5190
5346
|
return this._showModels(null)
|
|
5191
5347
|
}
|
|
5192
5348
|
|
|
5349
|
+
if (entry.overlay === 'tools') {
|
|
5350
|
+
return this._showTools()
|
|
5351
|
+
}
|
|
5352
|
+
|
|
5193
5353
|
if (entry.overlay === 'permissions') {
|
|
5194
5354
|
return this._showPermissions()
|
|
5195
5355
|
}
|
|
@@ -5435,7 +5595,11 @@ export class ChatApp {
|
|
|
5435
5595
|
}
|
|
5436
5596
|
|
|
5437
5597
|
if (s.kind === 'permissions') {
|
|
5438
|
-
return this.
|
|
5598
|
+
return this._toggleMode(s)
|
|
5599
|
+
}
|
|
5600
|
+
|
|
5601
|
+
if (s.kind === 'tools') {
|
|
5602
|
+
return this._toggleToolset(s, name)
|
|
5439
5603
|
}
|
|
5440
5604
|
|
|
5441
5605
|
if (s.enabled.has(name)) {
|
|
@@ -5704,26 +5868,27 @@ export class ChatApp {
|
|
|
5704
5868
|
return null
|
|
5705
5869
|
}
|
|
5706
5870
|
|
|
5707
|
-
|
|
5708
|
-
|
|
5709
|
-
|
|
5710
|
-
|
|
5711
|
-
|
|
5871
|
+
_toggleMode(s) {
|
|
5872
|
+
s.mode = s.mode === 'skip-all' ? 'ask' : 'skip-all'
|
|
5873
|
+
|
|
5874
|
+
return this._saveAgent({ approvalMode: s.mode })
|
|
5875
|
+
}
|
|
5876
|
+
|
|
5877
|
+
_toggleToolset(s, name) {
|
|
5878
|
+
if (s.enabled.has(name)) {
|
|
5712
5879
|
s.enabled.delete(name)
|
|
5713
5880
|
} else {
|
|
5714
5881
|
s.enabled.add(name)
|
|
5715
5882
|
}
|
|
5716
5883
|
|
|
5884
|
+
return this._saveAgent({
|
|
5885
|
+
disabledToolsets: [...TOOLSETS.filter((toolset) => !s.enabled.has(toolset)), ...s.unknown]
|
|
5886
|
+
})
|
|
5887
|
+
}
|
|
5888
|
+
|
|
5889
|
+
// optimistic, like the skills selector: the row moves now, the engine call follows
|
|
5890
|
+
_saveAgent(patch) {
|
|
5717
5891
|
this._render()
|
|
5718
|
-
const patch =
|
|
5719
|
-
name === MODE_ROW
|
|
5720
|
-
? { approvalMode: s.mode }
|
|
5721
|
-
: {
|
|
5722
|
-
disabledToolsets: [
|
|
5723
|
-
...TOOLSETS.filter((toolset) => !s.enabled.has(toolset)),
|
|
5724
|
-
...s.unknown
|
|
5725
|
-
]
|
|
5726
|
-
}
|
|
5727
5892
|
const { engine, agent } = this
|
|
5728
5893
|
|
|
5729
5894
|
return [
|
|
@@ -6563,17 +6728,34 @@ export class ChatApp {
|
|
|
6563
6728
|
if (msg.error) {
|
|
6564
6729
|
this._selector = null
|
|
6565
6730
|
this.overlay = [fg.err.render(`/permissions failed: ${msg.error.message}`)]
|
|
6731
|
+
} else {
|
|
6732
|
+
this._models = null
|
|
6733
|
+
this.overlay = null
|
|
6734
|
+
this._selector = { kind: 'permissions', rows: [MODE_ROW], mode: msg.mode, cursor: 0 }
|
|
6735
|
+
}
|
|
6736
|
+
|
|
6737
|
+
this._render()
|
|
6738
|
+
|
|
6739
|
+
return [this, null]
|
|
6740
|
+
}
|
|
6741
|
+
|
|
6742
|
+
if (msg.type === 'tools.result') {
|
|
6743
|
+
if (msg.error) {
|
|
6744
|
+
this._selector = null
|
|
6745
|
+
this.overlay = [fg.err.render(`/tools failed: ${msg.error.message}`)]
|
|
6566
6746
|
} else {
|
|
6567
6747
|
this._models = null
|
|
6568
6748
|
this.overlay = null
|
|
6569
6749
|
const off = new Set(msg.disabled)
|
|
6570
6750
|
this._selector = {
|
|
6571
|
-
kind: '
|
|
6572
|
-
rows: [
|
|
6751
|
+
kind: 'tools',
|
|
6752
|
+
rows: [...TOOLSETS],
|
|
6573
6753
|
enabled: new Set(TOOLSETS.filter((name) => !off.has(name))),
|
|
6574
6754
|
// unknown ids must survive the write, or an older device switches a newer build's toolset back on
|
|
6575
6755
|
unknown: msg.disabled.filter((name) => !TOOLSETS.includes(name)),
|
|
6576
|
-
|
|
6756
|
+
catalog: msg.catalog,
|
|
6757
|
+
reason: msg.reason,
|
|
6758
|
+
deviceName: msg.deviceName,
|
|
6577
6759
|
cursor: 0
|
|
6578
6760
|
}
|
|
6579
6761
|
}
|
package/tui/main.mjs
CHANGED
|
@@ -55,7 +55,8 @@ const CLIPBOARD_COMMANDS = {
|
|
|
55
55
|
win32: [['clip', []]],
|
|
56
56
|
linux: [
|
|
57
57
|
['wl-copy', []],
|
|
58
|
-
['xclip', ['-selection', 'clipboard']]
|
|
58
|
+
['xclip', ['-selection', 'clipboard']],
|
|
59
|
+
['xsel', ['--clipboard', '--input']]
|
|
59
60
|
]
|
|
60
61
|
}
|
|
61
62
|
|
|
@@ -87,13 +88,19 @@ function copyToClipboard(text) {
|
|
|
87
88
|
})
|
|
88
89
|
}
|
|
89
90
|
|
|
91
|
+
// no display (a container, ssh): ask the host terminal to set its clipboard instead
|
|
92
|
+
function copyViaTerminal(program, text) {
|
|
93
|
+
program.output.write(`\x1b]52;c;${b4a.toString(b4a.from(text), 'base64')}\x07`)
|
|
94
|
+
}
|
|
95
|
+
|
|
90
96
|
function readClipboard() {
|
|
91
97
|
const commands =
|
|
92
98
|
process.platform === 'darwin'
|
|
93
99
|
? [['pbpaste', []]]
|
|
94
100
|
: [
|
|
95
101
|
['wl-paste', ['--no-newline']],
|
|
96
|
-
['xclip', ['-o', '-selection', 'clipboard']]
|
|
102
|
+
['xclip', ['-o', '-selection', 'clipboard']],
|
|
103
|
+
['xsel', ['--clipboard', '--output']]
|
|
97
104
|
]
|
|
98
105
|
return new Promise((resolve, reject) => {
|
|
99
106
|
const attempt = (i) => {
|
|
@@ -235,7 +242,7 @@ async function run(args) {
|
|
|
235
242
|
const app = new ChatApp({
|
|
236
243
|
connect,
|
|
237
244
|
requestRepaint: () => requestRepaint(() => program),
|
|
238
|
-
copyToClipboard,
|
|
245
|
+
copyToClipboard: (text) => copyToClipboard(text).catch(() => copyViaTerminal(program, text)),
|
|
239
246
|
resolvePastedFile,
|
|
240
247
|
resolveFileAttachment
|
|
241
248
|
})
|