@qvac/core 0.11.1 → 0.11.3
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 +88 -1
- package/README.md +19 -16
- package/dist-lib/lib/api/chunks.js +4 -2
- package/dist-lib/lib/api/rag.js +7 -5
- package/dist-lib/lib/assistant/history.d.ts +1 -0
- package/dist-lib/lib/assistant/history.js +1 -17
- package/dist-lib/lib/assistant/message.d.ts +4 -1
- package/dist-lib/lib/assistant/pdf-budget.d.ts +10 -2
- package/dist-lib/lib/assistant/pdf-budget.js +10 -11
- package/dist-lib/lib/assistant/pdf-pages.d.ts +18 -0
- package/dist-lib/lib/assistant/pdf-pages.js +75 -0
- package/dist-lib/lib/assistant-tree.d.ts +2 -0
- package/dist-lib/lib/assistant-tree.js +4 -2
- package/dist-lib/lib/assistant.d.ts +10 -6
- package/dist-lib/lib/assistant.js +205 -140
- package/dist-lib/lib/compaction.d.ts +2 -1
- package/dist-lib/lib/compaction.js +14 -4
- package/dist-lib/lib/constants.d.ts +3 -0
- package/dist-lib/lib/constants.js +3 -0
- package/dist-lib/lib/core/chat-activity.js +12 -15
- package/dist-lib/lib/core/chunk.d.ts +9 -1
- package/dist-lib/lib/core/chunk.js +42 -8
- package/dist-lib/lib/core/document-attachment.d.ts +6 -3
- package/dist-lib/lib/core/document-attachment.js +10 -5
- package/dist-lib/lib/core/files/attachments.js +3 -3
- package/dist-lib/lib/core/files/index.d.ts +1 -1
- package/dist-lib/lib/core/files/index.js +3 -2
- package/dist-lib/lib/core/files/processing/index.d.ts +1 -0
- package/dist-lib/lib/core/files/processing/index.js +8 -0
- package/dist-lib/lib/core/files/processing/settle.d.ts +1 -0
- package/dist-lib/lib/core/files/processing/settle.js +20 -13
- package/dist-lib/lib/core/files/rag/index.d.ts +1 -1
- package/dist-lib/lib/core/files/rag/index.js +1 -1
- package/dist-lib/lib/core/files/rag/retrieval/full-text.d.ts +1 -0
- package/dist-lib/lib/core/files/rag/retrieval/full-text.js +3 -0
- package/dist-lib/lib/core/hosted-agents.d.ts +3 -0
- package/dist-lib/lib/core/hosted-agents.js +19 -0
- package/dist-lib/lib/core/notification.js +16 -13
- package/dist-lib/lib/core/pdf/figure.d.ts +22 -0
- package/dist-lib/lib/core/pdf/figure.js +64 -0
- package/dist-lib/lib/core/pdf/rasterize.d.ts +10 -1
- package/dist-lib/lib/core/pdf/rasterize.js +72 -22
- package/dist-lib/lib/core.d.ts +6 -0
- package/dist-lib/lib/core.js +5 -0
- package/dist-lib/lib/credential-pusher.d.ts +11 -7
- package/dist-lib/lib/credential-pusher.js +40 -8
- package/dist-lib/lib/integrations/setup-routes.js +7 -5
- package/dist-lib/lib/kv-cache-retention.d.ts +34 -0
- package/dist-lib/lib/kv-cache-retention.js +98 -0
- package/dist-lib/schema/content.js +2 -1
- package/dist-lib/schema/qvac.js +4 -2
- package/dist-lib/spec/hrpc/messages.js +4 -10
- package/dist-lib/spec/hyperschema/index.js +4 -10
- package/dist-lib/spec/hyperschema/schema.json +2 -1
- package/dist-lib/spec/hyperschema/types.d.ts +1 -1
- package/dist-lib/spec/mesh/hyperdb/messages.js +34 -14
- package/dist-lib/spec/mesh/hyperdispatch/messages.js +18 -8
- package/dist-lib/spec/mesh/hyperschema/index.js +18 -8
- package/dist-lib/spec/mesh/hyperschema/schema.json +11 -1
- package/dist-lib/spec/mesh/hyperschema/types.d.ts +3 -1
- package/package.json +6 -3
- package/tui/app.mjs +743 -266
- package/tui/boot.mjs +2 -2
- package/tui/lib/connect-sheet.mjs +350 -0
- package/tui/lib/setup.mjs +59 -25
- package/tui/lib/skill-connect.mjs +145 -0
package/tui/app.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import { TOOLSETS } from '@qvac/harness/lib/tools/toolsets.ts'
|
|
|
6
6
|
import os from 'os'
|
|
7
7
|
import path from 'path'
|
|
8
8
|
import process from 'process'
|
|
9
|
-
import {
|
|
9
|
+
import { oauthRedirectUri } from '../dist-lib/lib/oauth/keys.js'
|
|
10
10
|
import {
|
|
11
11
|
MODEL_IDLE_UNLOAD_KEY,
|
|
12
12
|
MODEL_IDLE_UNLOAD_MINUTES,
|
|
@@ -15,8 +15,8 @@ import {
|
|
|
15
15
|
MODEL_MEMORY_CAP_MAX,
|
|
16
16
|
MODEL_MEMORY_CAP_MIN
|
|
17
17
|
} from '../dist-lib/lib/constants.js'
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
18
|
+
import { oauthSpecFor } from '../dist-lib/lib/oauth/registry.js'
|
|
19
|
+
import { OBSIDIAN_VAULT_PATH_CREDENTIAL_KEY } from '../dist-lib/lib/obsidian-key.js'
|
|
20
20
|
import { customModelTaskRefusal } from '../dist-lib/lib/custom-model-task.js'
|
|
21
21
|
import {
|
|
22
22
|
COMPACTION_MIN_CTX_SIZE,
|
|
@@ -52,13 +52,39 @@ import { compactionTriggerRatio } from '../dist-lib/lib/compaction.js'
|
|
|
52
52
|
import { rememberSelection } from './lib/selection.mjs'
|
|
53
53
|
import {
|
|
54
54
|
configureActions,
|
|
55
|
-
|
|
55
|
+
closestSkill,
|
|
56
|
+
declaredCredentials,
|
|
57
|
+
findSkill,
|
|
56
58
|
isReady,
|
|
57
59
|
setupAction,
|
|
58
60
|
setupActions,
|
|
59
61
|
setupPlan,
|
|
62
|
+
skillRoutes,
|
|
60
63
|
statusLabel
|
|
61
64
|
} from './lib/setup.mjs'
|
|
65
|
+
import {
|
|
66
|
+
backspace,
|
|
67
|
+
currentRoute,
|
|
68
|
+
enteredValues,
|
|
69
|
+
focusField,
|
|
70
|
+
focused,
|
|
71
|
+
formatSheet,
|
|
72
|
+
hasField,
|
|
73
|
+
moveFocus,
|
|
74
|
+
openSheet,
|
|
75
|
+
pickRoute,
|
|
76
|
+
routeFields,
|
|
77
|
+
sheetFields,
|
|
78
|
+
typeInto
|
|
79
|
+
} from './lib/connect-sheet.mjs'
|
|
80
|
+
import {
|
|
81
|
+
cancelOAuth,
|
|
82
|
+
connectSkill,
|
|
83
|
+
disconnect,
|
|
84
|
+
envClient,
|
|
85
|
+
saveFields,
|
|
86
|
+
savedClient
|
|
87
|
+
} from './lib/skill-connect.mjs'
|
|
62
88
|
import {
|
|
63
89
|
firstSelectable,
|
|
64
90
|
moveRows,
|
|
@@ -189,7 +215,7 @@ const COMMANDS = [
|
|
|
189
215
|
},
|
|
190
216
|
{
|
|
191
217
|
name: 'skill',
|
|
192
|
-
desc: '
|
|
218
|
+
desc: '<name> — set a skill up, or toggle one on/off',
|
|
193
219
|
sub: [
|
|
194
220
|
{ name: 'on', desc: '<name> — enable a skill for this agent (sets scope=selected)' },
|
|
195
221
|
{ name: 'off', desc: '<name> — disable a skill for this agent (sets scope=selected)' }
|
|
@@ -266,7 +292,6 @@ const COMMANDS = [
|
|
|
266
292
|
]
|
|
267
293
|
},
|
|
268
294
|
{ name: 'meshes', desc: 'list the meshes this device belongs to', palette: true },
|
|
269
|
-
{ name: 'cred', desc: 'set a credential value for this agent' },
|
|
270
295
|
{
|
|
271
296
|
name: 'folders',
|
|
272
297
|
desc: 'the folders on this device the agent may read or edit with its file tools',
|
|
@@ -276,7 +301,11 @@ const COMMANDS = [
|
|
|
276
301
|
{ name: 'remove', desc: '<path> — stop sharing a folder' }
|
|
277
302
|
]
|
|
278
303
|
},
|
|
279
|
-
{
|
|
304
|
+
{
|
|
305
|
+
name: 'connect',
|
|
306
|
+
desc: '<name> — set a skill up and sign in (same as /skill <name> connect)',
|
|
307
|
+
palette: true
|
|
308
|
+
},
|
|
280
309
|
{
|
|
281
310
|
name: 'my-device',
|
|
282
311
|
desc: 'CPU/GPU inventory for this device (manufacturer, cores, drivers, …)'
|
|
@@ -398,10 +427,6 @@ const MODEL_TYPE_ALIASES = {
|
|
|
398
427
|
image: 'diffusion'
|
|
399
428
|
}
|
|
400
429
|
|
|
401
|
-
export function credKey(agentId, key) {
|
|
402
|
-
return scopedKey(agentId, key)
|
|
403
|
-
}
|
|
404
|
-
|
|
405
430
|
function openInBrowser(url) {
|
|
406
431
|
const command = process.platform === 'darwin' ? 'open' : 'xdg-open'
|
|
407
432
|
try {
|
|
@@ -889,6 +914,65 @@ const SKILL_STATUS_PAINT = {
|
|
|
889
914
|
disabled: 'dim'
|
|
890
915
|
}
|
|
891
916
|
|
|
917
|
+
const SETUP_KINDS = {
|
|
918
|
+
oauth: 'sign in',
|
|
919
|
+
token: 'token',
|
|
920
|
+
picker: 'folder',
|
|
921
|
+
install: 'install',
|
|
922
|
+
instructions: 'steps'
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
// the states a setup can clear; an unsupported or too-small-model skill stays as it is
|
|
926
|
+
const SETUP_FIXES = new Set(['needs-setup', 'disconnected', 'failed'])
|
|
927
|
+
|
|
928
|
+
const SKILL_USAGE =
|
|
929
|
+
'usage: /skill <name> [connect | disconnect | set <field> [value]] · /skill on|off <name>'
|
|
930
|
+
|
|
931
|
+
const OAUTH_STAGES = {
|
|
932
|
+
'awaiting-callback': 'waiting for the browser — approve access there',
|
|
933
|
+
'exchanging-code': 'finishing sign-in…'
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
// a value typed after `set` is a secret more often than not, so it never reaches ↑ history
|
|
937
|
+
const SECRET_COMMAND = /^\/skill\s+\S+\s+set\s+\S+\s+\S/
|
|
938
|
+
|
|
939
|
+
function expandHome(folder) {
|
|
940
|
+
return folder === '~' || folder.startsWith('~/')
|
|
941
|
+
? path.join(os.homedir(), folder.slice(1))
|
|
942
|
+
: folder
|
|
943
|
+
}
|
|
944
|
+
|
|
945
|
+
// a key the skill declares stays settable where its authored setup gives it no field
|
|
946
|
+
function settableRoute(skill, field) {
|
|
947
|
+
const route = skillRoutes(skill).find((entry) => hasField(entry, field))
|
|
948
|
+
if (route || !declaredCredentials(skill).includes(field)) {
|
|
949
|
+
return route ?? null
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
return { kind: 'token', credentialKey: field }
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
// the harness reads a vault only with its `.obsidian` config folder; it does not export that check
|
|
956
|
+
function folderProblem(folder, route) {
|
|
957
|
+
if (!isDirectory(folder)) {
|
|
958
|
+
return `no folder at ${folder}`
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
const vault = route.credentialKey === OBSIDIAN_VAULT_PATH_CREDENTIAL_KEY
|
|
962
|
+
|
|
963
|
+
return vault && !isDirectory(path.join(folder, '.obsidian'))
|
|
964
|
+
? `${folder} is not an Obsidian vault: it has no .obsidian folder`
|
|
965
|
+
: null
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
function isDirectory(folder) {
|
|
969
|
+
try {
|
|
970
|
+
return fs.statSync(folder).isDirectory()
|
|
971
|
+
} catch {
|
|
972
|
+
return false
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
|
|
892
976
|
// which nothing this is: a shared mesh publishes no inventory, so "offline" is rarely the reason
|
|
893
977
|
function emptySelector(kind, reason, deviceName) {
|
|
894
978
|
const whose = deviceName ? `${deviceName}` : 'that device'
|
|
@@ -949,33 +1033,34 @@ export function formatSelector(sel) {
|
|
|
949
1033
|
const badge = enabled.has(name) ? fg.cyan.render('● on ') : fg.dim.render('○ off')
|
|
950
1034
|
const skill = detail?.get(name)
|
|
951
1035
|
const state = skill
|
|
952
|
-
? ` ${fg[SKILL_STATUS_PAINT[skill.status] ?? 'dim'].render(
|
|
1036
|
+
? ` ${fg[SKILL_STATUS_PAINT[skill.status] ?? 'dim'].render(skillState(skill))}`
|
|
953
1037
|
: ''
|
|
954
1038
|
|
|
955
1039
|
return `${point}${badge} ${fg.white.render(name.padEnd(nameWidth))}${state}`
|
|
956
1040
|
})
|
|
957
1041
|
|
|
958
|
-
|
|
1042
|
+
// a setup that just finished says so on the list it returned to, in the line kept blank otherwise
|
|
1043
|
+
const notice = sel.notice ? fg.green.render(sel.notice) : ''
|
|
1044
|
+
|
|
1045
|
+
return [header, notice, ...lines, ...formatSkillDetail(detail?.get(rows[cursor]))]
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
// a skill that needs setup says what kind, so it reads before the sheet is opened
|
|
1049
|
+
function skillState(skill) {
|
|
1050
|
+
const kind = isReady(skill) ? null : SETUP_KINDS[setupAction(skill)?.kind]
|
|
1051
|
+
return kind ? `${statusLabel(skill.status)} · ${kind}` : statusLabel(skill.status)
|
|
959
1052
|
}
|
|
960
1053
|
|
|
961
1054
|
function formatSkillDetail(skill) {
|
|
962
1055
|
if (!skill) return []
|
|
963
1056
|
const lines = ['', fg.white.render(`${skill.name} — ${skill.description}`)]
|
|
964
1057
|
const state = statusLabel(skill.status)
|
|
965
|
-
const runnables = configureActions(skill)
|
|
966
1058
|
if (isReady(skill)) {
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
lines.push(fg.dim.render(`${state} — enter to change it: ${first.label}`))
|
|
973
|
-
lines.push(fg.cyan.render(`enter → ${first.command ?? `${first.prefill}<value>`}`))
|
|
974
|
-
for (const other of rest) {
|
|
975
|
-
lines.push(fg.dim.render(`or ${other.label}${runnable(other)}`))
|
|
976
|
-
}
|
|
977
|
-
|
|
978
|
-
return lines
|
|
1059
|
+
const [first] = configureActions(skill)
|
|
1060
|
+
return [
|
|
1061
|
+
...lines,
|
|
1062
|
+
fg.dim.render(first ? `${state} — enter to change it: ${first.label}` : state)
|
|
1063
|
+
]
|
|
979
1064
|
}
|
|
980
1065
|
|
|
981
1066
|
const action = setupAction(skill)
|
|
@@ -984,25 +1069,7 @@ function formatSkillDetail(skill) {
|
|
|
984
1069
|
}
|
|
985
1070
|
|
|
986
1071
|
lines.push(fg.amber.render(`${state} — ${action.label}`))
|
|
987
|
-
|
|
988
|
-
lines.push(fg.cyan.render(`enter → ${action.command}`))
|
|
989
|
-
}
|
|
990
|
-
|
|
991
|
-
if (action.prefill) {
|
|
992
|
-
lines.push(fg.cyan.render(`enter → ${action.prefill}<value>`))
|
|
993
|
-
}
|
|
994
|
-
|
|
995
|
-
for (const step of action.steps) {
|
|
996
|
-
lines.push(fg.dim.render(` • ${step}`))
|
|
997
|
-
}
|
|
998
|
-
|
|
999
|
-
if (action.helpUrl) {
|
|
1000
|
-
lines.push(fg.dim.render(` ${action.helpUrl}`))
|
|
1001
|
-
}
|
|
1002
|
-
|
|
1003
|
-
for (const other of setupPlan(skill).others) {
|
|
1004
|
-
lines.push(fg.dim.render(`or ${other.label}${runnable(other)}`))
|
|
1005
|
-
}
|
|
1072
|
+
lines.push(fg.cyan.render(`enter → set it up (${action.command})`))
|
|
1006
1073
|
|
|
1007
1074
|
return lines
|
|
1008
1075
|
}
|
|
@@ -1553,11 +1620,6 @@ export function formatDiagnostics(stats) {
|
|
|
1553
1620
|
return [header, '', ...formatCpuLines(stats.cpu), '', ...formatGpuLines(stats.gpu)]
|
|
1554
1621
|
}
|
|
1555
1622
|
|
|
1556
|
-
function runnable(action) {
|
|
1557
|
-
if (action.command) return `: ${action.command}`
|
|
1558
|
-
return action.prefill ? `: ${action.prefill}<value>` : ''
|
|
1559
|
-
}
|
|
1560
|
-
|
|
1561
1623
|
// a non-ready skill appends its fix, so it is in the TUI rather than somewhere in the docs
|
|
1562
1624
|
export function renderSkill(s) {
|
|
1563
1625
|
const lines = [`${s.name}: ${s.status || 'unknown'} — ${s.description}`]
|
|
@@ -1571,7 +1633,7 @@ export function renderSkill(s) {
|
|
|
1571
1633
|
|
|
1572
1634
|
if (isReady(s)) {
|
|
1573
1635
|
for (const action of configureActions(s)) {
|
|
1574
|
-
lines.push(` change it: ${action.label}${
|
|
1636
|
+
lines.push(` change it: ${action.label}: ${action.command}`)
|
|
1575
1637
|
}
|
|
1576
1638
|
|
|
1577
1639
|
return lines.join('\n')
|
|
@@ -1583,26 +1645,11 @@ export function renderSkill(s) {
|
|
|
1583
1645
|
|
|
1584
1646
|
const { primary, others } = setupPlan(s)
|
|
1585
1647
|
if (primary) {
|
|
1586
|
-
lines.push(` ${primary.label}`)
|
|
1587
|
-
if (primary.command) {
|
|
1588
|
-
lines.push(` run: ${primary.command}`)
|
|
1589
|
-
}
|
|
1590
|
-
|
|
1591
|
-
if (primary.prefill) {
|
|
1592
|
-
lines.push(` run: ${primary.prefill}<value>`)
|
|
1593
|
-
}
|
|
1594
|
-
|
|
1595
|
-
for (const step of primary.steps) {
|
|
1596
|
-
lines.push(` - ${step}`)
|
|
1597
|
-
}
|
|
1598
|
-
|
|
1599
|
-
if (primary.helpUrl) {
|
|
1600
|
-
lines.push(` ${primary.helpUrl}`)
|
|
1601
|
-
}
|
|
1648
|
+
lines.push(` ${primary.label}`, ` run: ${primary.command}`)
|
|
1602
1649
|
}
|
|
1603
1650
|
|
|
1604
1651
|
for (const other of others) {
|
|
1605
|
-
lines.push(` or ${other.label}
|
|
1652
|
+
lines.push(` or ${other.label}`)
|
|
1606
1653
|
}
|
|
1607
1654
|
|
|
1608
1655
|
return lines.join('\n')
|
|
@@ -1690,7 +1737,6 @@ const AGENT_COMMANDS = new Set([
|
|
|
1690
1737
|
'skill',
|
|
1691
1738
|
'scope',
|
|
1692
1739
|
'connect',
|
|
1693
|
-
'cred',
|
|
1694
1740
|
'folders'
|
|
1695
1741
|
])
|
|
1696
1742
|
const NO_AGENT = 'no agent in this mesh · /agent new <name> or /agent use <name|id>'
|
|
@@ -1836,12 +1882,16 @@ export class ChatApp {
|
|
|
1836
1882
|
resolvePastedFile,
|
|
1837
1883
|
resolveFileAttachment,
|
|
1838
1884
|
saveDir,
|
|
1839
|
-
skills
|
|
1885
|
+
skills,
|
|
1886
|
+
openUrl
|
|
1840
1887
|
}) {
|
|
1841
1888
|
this.engine = engine
|
|
1842
1889
|
// Core holds no selection, so the mesh this window looks at is the client's choice
|
|
1843
1890
|
this.meshId = meshId || null
|
|
1844
1891
|
this._skills = skills || null
|
|
1892
|
+
// the form a skill is being set up through, drawn over everything else while open
|
|
1893
|
+
this._sheet = null
|
|
1894
|
+
this._openUrl = openUrl || openInBrowser
|
|
1845
1895
|
this.agent = agent
|
|
1846
1896
|
this.chatId = chatId
|
|
1847
1897
|
// the chat /mesh moved reports on when named none: its source row is purged once it lands
|
|
@@ -2370,6 +2420,13 @@ export class ChatApp {
|
|
|
2370
2420
|
}
|
|
2371
2421
|
|
|
2372
2422
|
_render() {
|
|
2423
|
+
if (this._sheet) {
|
|
2424
|
+
const { lines, at } = formatSheet(this._sheet, fg)
|
|
2425
|
+
this._setRows(lines, at)
|
|
2426
|
+
|
|
2427
|
+
return
|
|
2428
|
+
}
|
|
2429
|
+
|
|
2373
2430
|
if (this._models) {
|
|
2374
2431
|
const rows = formatModels(this._models.rows, this._models.filter, {
|
|
2375
2432
|
cursor: this._models.cursor,
|
|
@@ -2488,8 +2545,8 @@ export class ChatApp {
|
|
|
2488
2545
|
' /agents — pick from your agents to switch (interactive) · /agent — show current · /agent list · /agent new <name> · /agent rename <name> · /agent use <name|id> · /agent borrow [none] - borrow the model from the compute mesh, or stop',
|
|
2489
2546
|
" /activity — list the active agent's recent tool calls, each with its decision (allowed/denied/auto/skip-all/blocked)",
|
|
2490
2547
|
' /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',
|
|
2491
|
-
' /skills — browse installed; ↑/↓ move, space toggles each on/off (sets scope=selected), enter sets up or reconfigures the skill, esc returns',
|
|
2492
|
-
' /skill on|off <name> — toggle (sets scope=selected)',
|
|
2548
|
+
' /skills — browse installed; ↑/↓ move, space toggles each on/off (sets scope=selected; one that needs setup opens it first), enter sets up or reconfigures the skill, esc returns',
|
|
2549
|
+
' /skill on|off <name> — toggle (sets scope=selected); turning on one that needs setup opens its setup, and it turns on once that succeeds',
|
|
2493
2550
|
' /tools — the toolset switches, each listing the tools it gates; ↑/↓ move, space toggles a set',
|
|
2494
2551
|
' /permissions — the approval mode; space toggles',
|
|
2495
2552
|
' /models delete <name> · /models download <name> — remove a model from this device, or fetch it now',
|
|
@@ -2500,9 +2557,11 @@ export class ChatApp {
|
|
|
2500
2557
|
' /models custom · preview <src|n> [mmproj] · add <label> <src|n> [mmproj] [tools|vision|thinking] · use <name|label> · remove <name|label> — check a GGUF by url or local path, add it, and pick it; its context window caps /ctx',
|
|
2501
2558
|
' /image [model <choice> | steps <n> | size <WxH> | reset] — the agent’s image-generation defaults',
|
|
2502
2559
|
'',
|
|
2503
|
-
'Connections — a skill that needs an account
|
|
2504
|
-
' /
|
|
2505
|
-
'
|
|
2560
|
+
'Connections — a skill that needs an account, a token, a folder or an install (Menu ▸ Agent ▸ Connections lists them with their state)',
|
|
2561
|
+
' /skill <name> — set a skill up: what it needs, its fields (secrets masked, ctrl+r shows them), then sign in or save · /connect <name> is the same',
|
|
2562
|
+
' /skill <name> connect · disconnect — sign in again, or remove what the skill stored (an OAuth client app is kept)',
|
|
2563
|
+
' /skill <name> set <field> [value] — set one field from a script; without a value the sheet opens on that field so a secret stays off screen',
|
|
2564
|
+
' an OAuth skill with no client typed in uses <PROVIDER>_OAUTH_CLIENT_ID and <PROVIDER>_OAUTH_CLIENT_SECRET when both are set',
|
|
2506
2565
|
'',
|
|
2507
2566
|
'Voice',
|
|
2508
2567
|
' /speak <text> — synthesize speech (TTS) to a WAV file in the save dir',
|
|
@@ -2512,7 +2571,6 @@ export class ChatApp {
|
|
|
2512
2571
|
' /record [seconds] [device] — record from the mic via ffmpeg (macOS avfoundation) and transcribe',
|
|
2513
2572
|
'',
|
|
2514
2573
|
'Advanced',
|
|
2515
|
-
' /cred <key> <value> — set a credential by hand for this agent (e.g. /cred github_access_token ghp_…); /skills, enter on the skill, fills this in for you',
|
|
2516
2574
|
' /folders — the folders on this device the agent may use with its file tools · /folders add <path> [ro|rw] — share one, read-only unless rw · /folders remove <path>',
|
|
2517
2575
|
' /scope skills all|selected — switch scope',
|
|
2518
2576
|
' /join <qvac://device/… or qvac://workspace/…> — preview who you would join as (ctrl+y copies this mesh’s invite) · /join yes — confirm it (a device invite retires this device’s mesh, a member invite adds one beside it) · /join cancel — abort a join in progress',
|
|
@@ -3168,38 +3226,14 @@ export class ChatApp {
|
|
|
3168
3226
|
}
|
|
3169
3227
|
|
|
3170
3228
|
if (cmd === 'skill') {
|
|
3171
|
-
const [action, name] = rest
|
|
3172
|
-
if ((action
|
|
3173
|
-
return
|
|
3229
|
+
const [action = '', name] = rest
|
|
3230
|
+
if ((action === 'on' || action === 'off') && name) {
|
|
3231
|
+
return action === 'on'
|
|
3232
|
+
? this._skillOn(name)
|
|
3233
|
+
: run(() => this._toggleSkill(name, { on: false }))
|
|
3174
3234
|
}
|
|
3175
3235
|
|
|
3176
|
-
return
|
|
3177
|
-
const fresh = await engine.getAgent({ meshId: this.meshId, agentId: agent.id })
|
|
3178
|
-
const set = new Set(fresh.enabledSkills ?? [])
|
|
3179
|
-
if (action === 'on') {
|
|
3180
|
-
set.add(name)
|
|
3181
|
-
} else {
|
|
3182
|
-
set.delete(name)
|
|
3183
|
-
}
|
|
3184
|
-
|
|
3185
|
-
const updated = await engine.updateAgent({
|
|
3186
|
-
meshId: this.meshId,
|
|
3187
|
-
agentId: agent.id,
|
|
3188
|
-
config: { enabledSkills: [...set], skillsScope: 'selected' }
|
|
3189
|
-
})
|
|
3190
|
-
this.agent = updated
|
|
3191
|
-
const line = `skill ${name} ${action} · enabledSkills=[${[...set].join(', ')}] scope=selected`
|
|
3192
|
-
if (action !== 'on') {
|
|
3193
|
-
return line
|
|
3194
|
-
}
|
|
3195
|
-
|
|
3196
|
-
const skill = (await this._skillDetail())?.get(name)
|
|
3197
|
-
if (!skill || isReady(skill)) {
|
|
3198
|
-
return line
|
|
3199
|
-
}
|
|
3200
|
-
|
|
3201
|
-
return `${line}\n${renderSkill(skill)}`
|
|
3202
|
-
})
|
|
3236
|
+
return this._skillCommand(rawArgs) ?? notice(SKILL_USAGE)
|
|
3203
3237
|
}
|
|
3204
3238
|
|
|
3205
3239
|
if (cmd === 'scope') {
|
|
@@ -3500,115 +3534,10 @@ export class ChatApp {
|
|
|
3500
3534
|
)
|
|
3501
3535
|
}
|
|
3502
3536
|
|
|
3537
|
+
// the name it had before /skill took over; the sheet it opens is the same one
|
|
3503
3538
|
if (cmd === 'connect') {
|
|
3504
|
-
const [
|
|
3505
|
-
|
|
3506
|
-
return notice('usage: /connect <skill> — Menu ▸ Agent ▸ Connections lists them')
|
|
3507
|
-
}
|
|
3508
|
-
|
|
3509
|
-
return run(async () => {
|
|
3510
|
-
let skills
|
|
3511
|
-
try {
|
|
3512
|
-
skills = this._skills ? await this._skills(agent.id, agent.modelName, this.meshId) : []
|
|
3513
|
-
} catch (error) {
|
|
3514
|
-
return `could not read the skill catalog: ${error?.message ?? error}`
|
|
3515
|
-
}
|
|
3516
|
-
|
|
3517
|
-
const matches = oauthSpecs(skills ?? []).filter(
|
|
3518
|
-
(candidate) => connectSlug(candidate.credentialKey) === slug
|
|
3519
|
-
)
|
|
3520
|
-
if (matches.length === 0) {
|
|
3521
|
-
return `no connectable skill named ${slug} — Menu ▸ Agent ▸ Connections`
|
|
3522
|
-
}
|
|
3523
|
-
|
|
3524
|
-
if (matches.length > 1) {
|
|
3525
|
-
const keys = matches.map((m) => m.credentialKey).join(', ')
|
|
3526
|
-
return `${slug} is ambiguous — matches ${keys}, use the full credential key`
|
|
3527
|
-
}
|
|
3528
|
-
|
|
3529
|
-
const [spec] = matches
|
|
3530
|
-
// setup fields are stored per declaring skill, and a `secret` one in the credential namespace
|
|
3531
|
-
const owner = (skills ?? []).find((skill) =>
|
|
3532
|
-
(skill.setup?.routes ?? []).some((route) => route.credentialKey === spec.credentialKey)
|
|
3533
|
-
)
|
|
3534
|
-
const ownerRoute = (owner?.setup?.routes ?? []).find(
|
|
3535
|
-
(route) => route.credentialKey === spec.credentialKey
|
|
3536
|
-
)
|
|
3537
|
-
const storedField = async (name) => {
|
|
3538
|
-
const field = (ownerRoute?.fields ?? []).find((entry) => entry.key === name)
|
|
3539
|
-
if (!field || !owner) {
|
|
3540
|
-
return ''
|
|
3541
|
-
}
|
|
3542
|
-
|
|
3543
|
-
const key =
|
|
3544
|
-
field.secret === true
|
|
3545
|
-
? credKey(agent.id, field.key)
|
|
3546
|
-
: settingConfigKey(agent.id, owner.name, field.key)
|
|
3547
|
-
const { value } = await engine.configGet({ key })
|
|
3548
|
-
|
|
3549
|
-
return typeof value === 'string' ? value : ''
|
|
3550
|
-
}
|
|
3551
|
-
const env = spec.provider.toUpperCase().replaceAll('-', '_')
|
|
3552
|
-
const idVar = `${env}_OAUTH_CLIENT_ID`
|
|
3553
|
-
const secretVar = `${env}_OAUTH_CLIENT_SECRET`
|
|
3554
|
-
const needsSecret = spec.tokenAuth !== 'pkce-only'
|
|
3555
|
-
const clientId = (await storedField('clientId')) || process.env[idVar] || ''
|
|
3556
|
-
const clientSecret = (await storedField('clientSecret')) || process.env[secretVar] || ''
|
|
3557
|
-
// registrationEndpoint implies pkce-only, so a DCR skill never hits the secret check below
|
|
3558
|
-
if (!clientId && !spec.registrationEndpoint) {
|
|
3559
|
-
return needsSecret
|
|
3560
|
-
? `set ${idVar} and ${secretVar}, then retry`
|
|
3561
|
-
: `set ${idVar}, then retry`
|
|
3562
|
-
}
|
|
3563
|
-
|
|
3564
|
-
if (needsSecret && !clientSecret) {
|
|
3565
|
-
return `set ${idVar} and ${secretVar}, then retry`
|
|
3566
|
-
}
|
|
3567
|
-
|
|
3568
|
-
const { buildProviderConfig, runOAuthFlow } = await import('../dist-lib/lib/oauth.js')
|
|
3569
|
-
let registeredClientId = ''
|
|
3570
|
-
const tokens = await runOAuthFlow(
|
|
3571
|
-
buildProviderConfig(spec, {
|
|
3572
|
-
clientId,
|
|
3573
|
-
clientSecret: needsSecret ? clientSecret : undefined
|
|
3574
|
-
}),
|
|
3575
|
-
{
|
|
3576
|
-
openUrl: (url) => {
|
|
3577
|
-
this.status = fg.dim.render(`authorize in your browser: ${url}`)
|
|
3578
|
-
this._render()
|
|
3579
|
-
openInBrowser(url)
|
|
3580
|
-
},
|
|
3581
|
-
getClientId: async () => {
|
|
3582
|
-
// read back a client a prior run registered instead of registering anew every /connect
|
|
3583
|
-
const { value } = await engine.configGet({ key: credKey(agent.id, spec.stateKey) })
|
|
3584
|
-
try {
|
|
3585
|
-
const state = typeof value === 'string' ? JSON.parse(value) : null
|
|
3586
|
-
return state?.clientId || undefined
|
|
3587
|
-
} catch {
|
|
3588
|
-
return undefined
|
|
3589
|
-
}
|
|
3590
|
-
},
|
|
3591
|
-
saveClientId: async (id) => {
|
|
3592
|
-
registeredClientId = id
|
|
3593
|
-
}
|
|
3594
|
-
}
|
|
3595
|
-
)
|
|
3596
|
-
await engine.configSet({
|
|
3597
|
-
key: credKey(agent.id, spec.credentialKey),
|
|
3598
|
-
value: tokens.accessToken
|
|
3599
|
-
})
|
|
3600
|
-
await engine.configSet({
|
|
3601
|
-
key: credKey(agent.id, spec.stateKey),
|
|
3602
|
-
value: JSON.stringify({
|
|
3603
|
-
refreshToken: tokens.refreshToken,
|
|
3604
|
-
expiresAt: tokens.expiresAt,
|
|
3605
|
-
clientId: clientId || registeredClientId,
|
|
3606
|
-
clientSecret: needsSecret ? clientSecret : undefined
|
|
3607
|
-
})
|
|
3608
|
-
})
|
|
3609
|
-
|
|
3610
|
-
return `${slug} connected for agent ${agent.name} — token stored, auto-refreshes on use`
|
|
3611
|
-
})
|
|
3539
|
+
const [name] = rest
|
|
3540
|
+
return name ? this._skillSheet(name, { start: true }) : notice(SKILL_USAGE)
|
|
3612
3541
|
}
|
|
3613
3542
|
|
|
3614
3543
|
if (cmd === 'folders') {
|
|
@@ -3627,21 +3556,6 @@ export class ChatApp {
|
|
|
3627
3556
|
]
|
|
3628
3557
|
}
|
|
3629
3558
|
|
|
3630
|
-
if (cmd === 'cred') {
|
|
3631
|
-
const [key, ...valueParts] = rest
|
|
3632
|
-
const value = valueParts.join(' ')
|
|
3633
|
-
if (!key || !value) {
|
|
3634
|
-
return notice('usage: /cred <key> <value>')
|
|
3635
|
-
}
|
|
3636
|
-
|
|
3637
|
-
return run(async () => {
|
|
3638
|
-
const storageKey = credKey(agent.id, key)
|
|
3639
|
-
await engine.configSet({ key: storageKey, value })
|
|
3640
|
-
|
|
3641
|
-
return `set ${key} for agent ${agent.name} (${value.length} chars) — scoped, not shared`
|
|
3642
|
-
})
|
|
3643
|
-
}
|
|
3644
|
-
|
|
3645
3559
|
// sending blocks for the join: everything held goes stale once the window lands on the new mesh
|
|
3646
3560
|
if (cmd === 'join') {
|
|
3647
3561
|
const arg = rawArgs.trim()
|
|
@@ -4567,6 +4481,11 @@ export class ChatApp {
|
|
|
4567
4481
|
return
|
|
4568
4482
|
}
|
|
4569
4483
|
|
|
4484
|
+
if (this._sheet) {
|
|
4485
|
+
typeInto(this._sheet, text.trim())
|
|
4486
|
+
return
|
|
4487
|
+
}
|
|
4488
|
+
|
|
4570
4489
|
const lines = text.split('\n').length
|
|
4571
4490
|
if (lines === 1) {
|
|
4572
4491
|
return this._insertText(text)
|
|
@@ -4631,7 +4550,7 @@ export class ChatApp {
|
|
|
4631
4550
|
this._historyAt = null
|
|
4632
4551
|
this._historyDraft = ''
|
|
4633
4552
|
const value = line.trim()
|
|
4634
|
-
if (!value || this._history[this._history.length - 1] === value) {
|
|
4553
|
+
if (!value || SECRET_COMMAND.test(value) || this._history[this._history.length - 1] === value) {
|
|
4635
4554
|
return
|
|
4636
4555
|
}
|
|
4637
4556
|
|
|
@@ -4815,7 +4734,7 @@ export class ChatApp {
|
|
|
4815
4734
|
return [...detail.keys()]
|
|
4816
4735
|
}
|
|
4817
4736
|
|
|
4818
|
-
const skills = (await this.
|
|
4737
|
+
const skills = (await this._readSkills()) ?? []
|
|
4819
4738
|
|
|
4820
4739
|
return skills.map((s) => s.name)
|
|
4821
4740
|
}
|
|
@@ -4933,9 +4852,7 @@ export class ChatApp {
|
|
|
4933
4852
|
// null when a pre-upgrade provider cannot report it; the selector then renders as it always did
|
|
4934
4853
|
async _skillDetail() {
|
|
4935
4854
|
if (!this._skills) return null
|
|
4936
|
-
const skills = await this.
|
|
4937
|
-
noop
|
|
4938
|
-
)
|
|
4855
|
+
const skills = await this._readSkills().catch(noop)
|
|
4939
4856
|
|
|
4940
4857
|
return skills ? new Map(skills.map((skill) => [skill.name, skill])) : null
|
|
4941
4858
|
}
|
|
@@ -5171,33 +5088,25 @@ export class ChatApp {
|
|
|
5171
5088
|
return {
|
|
5172
5089
|
title: 'Connections',
|
|
5173
5090
|
cursor: 0,
|
|
5174
|
-
entries: [
|
|
5175
|
-
{ label: 'Connect a skill…', hint: '/connect <skill>', prefill: '/connect ' },
|
|
5176
|
-
{ label: 'Set a credential…', hint: '/cred <key> <value>', prefill: '/cred ' }
|
|
5177
|
-
]
|
|
5091
|
+
entries: [{ label: 'Set up a skill…', hint: '/skill <name>', prefill: '/skill ' }]
|
|
5178
5092
|
}
|
|
5179
5093
|
}
|
|
5180
5094
|
|
|
5181
|
-
//
|
|
5095
|
+
// one row per skill that takes setup; its sheet lists the ways in when there are several
|
|
5182
5096
|
_connectPage() {
|
|
5183
5097
|
return [
|
|
5184
5098
|
this,
|
|
5185
5099
|
async () => {
|
|
5186
5100
|
const detail = await this._skillDetail()
|
|
5187
|
-
const
|
|
5188
|
-
|
|
5189
|
-
.filter((action) => action.command || action.prefill)
|
|
5190
|
-
.map((action) => ({ skill, action }))
|
|
5191
|
-
)
|
|
5192
|
-
if (!rows.length) {
|
|
5101
|
+
const skills = [...(detail?.values() ?? [])].filter((skill) => setupActions(skill).length)
|
|
5102
|
+
if (!skills.length) {
|
|
5193
5103
|
return { type: 'menu.page', page: this._connectMenu() }
|
|
5194
5104
|
}
|
|
5195
5105
|
|
|
5196
|
-
const entries =
|
|
5197
|
-
label: `${isReady(skill) ? '●' : '○'} ${
|
|
5198
|
-
hint:
|
|
5199
|
-
command:
|
|
5200
|
-
prefill: action.prefill
|
|
5106
|
+
const entries = skills.map((skill) => ({
|
|
5107
|
+
label: `${isReady(skill) ? '●' : '○'} ${skill.name}`,
|
|
5108
|
+
hint: skillState(skill),
|
|
5109
|
+
command: `/skill ${skill.name}`
|
|
5201
5110
|
}))
|
|
5202
5111
|
|
|
5203
5112
|
return { type: 'menu.page', page: { title: 'Connections', cursor: 0, entries } }
|
|
@@ -5205,12 +5114,564 @@ export class ChatApp {
|
|
|
5205
5114
|
]
|
|
5206
5115
|
}
|
|
5207
5116
|
|
|
5117
|
+
// scoped to this agent on its own model, the way the harness gates a skill
|
|
5118
|
+
_readSkills({ refresh = false } = {}) {
|
|
5119
|
+
return this._skills?.(this.agent?.id, {
|
|
5120
|
+
modelName: this.agent?.modelName,
|
|
5121
|
+
meshId: this.meshId,
|
|
5122
|
+
refresh
|
|
5123
|
+
})
|
|
5124
|
+
}
|
|
5125
|
+
|
|
5126
|
+
// `/skill <name> [connect | disconnect | set <field> [value]]`; null is a usage error
|
|
5127
|
+
_skillCommand(args) {
|
|
5128
|
+
const [, name, verb = '', field, value] =
|
|
5129
|
+
args.match(/^(\S+)(?:\s+(\S+))?(?:\s+(\S+))?\s*(.*)$/) ?? []
|
|
5130
|
+
if (!name || name === 'on' || name === 'off') {
|
|
5131
|
+
return null
|
|
5132
|
+
}
|
|
5133
|
+
|
|
5134
|
+
if (!verb) {
|
|
5135
|
+
return this._skillSheet(name)
|
|
5136
|
+
}
|
|
5137
|
+
|
|
5138
|
+
if (verb === 'connect' || verb === 'disconnect') {
|
|
5139
|
+
return verb === 'connect'
|
|
5140
|
+
? this._skillSheet(name, { start: true })
|
|
5141
|
+
: this._skillDisconnect(name)
|
|
5142
|
+
}
|
|
5143
|
+
|
|
5144
|
+
if (verb !== 'set' || !field) {
|
|
5145
|
+
return null
|
|
5146
|
+
}
|
|
5147
|
+
|
|
5148
|
+
return value ? this._skillSet(name, field, value) : this._skillSheet(name, { field })
|
|
5149
|
+
}
|
|
5150
|
+
|
|
5151
|
+
// asked afresh each time, so a name resolves against what is installed now
|
|
5152
|
+
async _lookupSkill(name) {
|
|
5153
|
+
if (!this._skills) {
|
|
5154
|
+
return { missing: 'this provider does not report its skills' }
|
|
5155
|
+
}
|
|
5156
|
+
|
|
5157
|
+
const skills = (await this._readSkills()) ?? []
|
|
5158
|
+
const skill = findSkill(skills, name)
|
|
5159
|
+
if (skill) {
|
|
5160
|
+
return { skill }
|
|
5161
|
+
}
|
|
5162
|
+
|
|
5163
|
+
const near = closestSkill(skills, name)
|
|
5164
|
+
const hint = near ? ` — did you mean ${near}?` : ''
|
|
5165
|
+
|
|
5166
|
+
return { missing: `no skill named ${name}${hint} · /skills lists them` }
|
|
5167
|
+
}
|
|
5168
|
+
|
|
5169
|
+
async _skillRow(name) {
|
|
5170
|
+
const skills = await this._readSkills({ refresh: true })
|
|
5171
|
+
|
|
5172
|
+
return skills?.find((skill) => skill.name === name) ?? null
|
|
5173
|
+
}
|
|
5174
|
+
|
|
5175
|
+
// the same write as the /skills space bar, so either moves the agent to scope=selected
|
|
5176
|
+
async _toggleSkill(name, { on }) {
|
|
5177
|
+
const { engine, agent } = this
|
|
5178
|
+
const fresh = await engine.getAgent({ meshId: this.meshId, agentId: agent.id })
|
|
5179
|
+
const set = new Set(fresh.enabledSkills ?? [])
|
|
5180
|
+
if (on) {
|
|
5181
|
+
set.add(name)
|
|
5182
|
+
} else {
|
|
5183
|
+
set.delete(name)
|
|
5184
|
+
}
|
|
5185
|
+
|
|
5186
|
+
this.agent = await engine.updateAgent({
|
|
5187
|
+
meshId: this.meshId,
|
|
5188
|
+
agentId: agent.id,
|
|
5189
|
+
config: { enabledSkills: [...set], skillsScope: 'selected' }
|
|
5190
|
+
})
|
|
5191
|
+
|
|
5192
|
+
return `skill ${name} ${on ? 'on' : 'off'} · enabledSkills=[${[...set].join(', ')}] scope=selected`
|
|
5193
|
+
}
|
|
5194
|
+
|
|
5195
|
+
// a skill that cannot work yet is set up first, and turned on once it can
|
|
5196
|
+
_skillOn(name) {
|
|
5197
|
+
return [
|
|
5198
|
+
this,
|
|
5199
|
+
async () => {
|
|
5200
|
+
try {
|
|
5201
|
+
const { skill, missing } = this._skills ? await this._lookupSkill(name) : {}
|
|
5202
|
+
if (missing) {
|
|
5203
|
+
return { type: 'notice', text: missing }
|
|
5204
|
+
}
|
|
5205
|
+
|
|
5206
|
+
if (skill && SETUP_FIXES.has(skill.status) && setupAction(skill)) {
|
|
5207
|
+
return { type: 'sheet.open', skill, enable: true }
|
|
5208
|
+
}
|
|
5209
|
+
|
|
5210
|
+
return { type: 'notice', text: await this._toggleSkill(name, { on: true }) }
|
|
5211
|
+
} catch (error) {
|
|
5212
|
+
return { type: 'run.error', error }
|
|
5213
|
+
}
|
|
5214
|
+
}
|
|
5215
|
+
]
|
|
5216
|
+
}
|
|
5217
|
+
|
|
5218
|
+
_skillSheet(name, { start = false, field = null } = {}) {
|
|
5219
|
+
return this._withSkill(name, (skill) => {
|
|
5220
|
+
const routes = skillRoutes(skill)
|
|
5221
|
+
if (!routes.length) {
|
|
5222
|
+
return { type: 'notice', text: `${renderSkill(skill)}\n nothing to set up` }
|
|
5223
|
+
}
|
|
5224
|
+
|
|
5225
|
+
if (field && !routes.some((route) => hasField(route, field))) {
|
|
5226
|
+
const fields = routes.flatMap((route) => routeFields(route).map((entry) => entry.key))
|
|
5227
|
+
if (declaredCredentials(skill).includes(field)) {
|
|
5228
|
+
return {
|
|
5229
|
+
type: 'notice',
|
|
5230
|
+
text: `${field} has no field in ${skill.name}'s setup — /skill ${skill.name} set ${field} <value>`
|
|
5231
|
+
}
|
|
5232
|
+
}
|
|
5233
|
+
|
|
5234
|
+
return {
|
|
5235
|
+
type: 'notice',
|
|
5236
|
+
text: `${skill.name} has no field ${field} — it takes ${fields.join(', ')}`
|
|
5237
|
+
}
|
|
5238
|
+
}
|
|
5239
|
+
|
|
5240
|
+
return { type: 'sheet.open', skill, start, field }
|
|
5241
|
+
})
|
|
5242
|
+
}
|
|
5243
|
+
|
|
5244
|
+
// a value typed on the command line, for scripts; the sheet is where a secret stays off screen
|
|
5245
|
+
_skillSet(name, field, value) {
|
|
5246
|
+
return this._withSkill(name, async (skill) => {
|
|
5247
|
+
const route = settableRoute(skill, field)
|
|
5248
|
+
if (!route) {
|
|
5249
|
+
return {
|
|
5250
|
+
type: 'notice',
|
|
5251
|
+
text: `${skill.name} has no field ${field} · /skill ${skill.name} shows them`
|
|
5252
|
+
}
|
|
5253
|
+
}
|
|
5254
|
+
|
|
5255
|
+
const stored = route.kind === 'picker' ? expandHome(value) : value
|
|
5256
|
+
const { agent } = this
|
|
5257
|
+
await saveFields(this.engine, {
|
|
5258
|
+
agentId: agent.id,
|
|
5259
|
+
skillName: skill.name,
|
|
5260
|
+
route,
|
|
5261
|
+
values: { [field]: stored }
|
|
5262
|
+
})
|
|
5263
|
+
const secret = routeFields(route).find((entry) => entry.key === field)?.secret
|
|
5264
|
+
const shown = secret ? `(${stored.length} chars)` : `= ${stored}`
|
|
5265
|
+
const next = route.kind === 'oauth' ? ` · /skill ${skill.name} connect` : ''
|
|
5266
|
+
|
|
5267
|
+
return {
|
|
5268
|
+
type: 'notice',
|
|
5269
|
+
text: `${skill.name} ${field} ${shown} for agent ${agent.name}${next}`
|
|
5270
|
+
}
|
|
5271
|
+
})
|
|
5272
|
+
}
|
|
5273
|
+
|
|
5274
|
+
_skillDisconnect(name) {
|
|
5275
|
+
return this._withSkill(name, async (skill) => {
|
|
5276
|
+
const route = skillRoutes(skill).find((entry) => entry.credentialKey)
|
|
5277
|
+
if (!route) {
|
|
5278
|
+
return { type: 'notice', text: `${skill.name} stores nothing to disconnect` }
|
|
5279
|
+
}
|
|
5280
|
+
|
|
5281
|
+
await disconnect(this.engine, { agentId: this.agent.id, route })
|
|
5282
|
+
const kept = route.kind === 'oauth' ? ' — its client app is kept' : ''
|
|
5283
|
+
|
|
5284
|
+
return {
|
|
5285
|
+
type: 'notice',
|
|
5286
|
+
text: `${skill.name} disconnected for agent ${this.agent.name}${kept}`
|
|
5287
|
+
}
|
|
5288
|
+
})
|
|
5289
|
+
}
|
|
5290
|
+
|
|
5291
|
+
_withSkill(name, fn) {
|
|
5292
|
+
return [
|
|
5293
|
+
this,
|
|
5294
|
+
async () => {
|
|
5295
|
+
try {
|
|
5296
|
+
const { skill, missing } = await this._lookupSkill(name)
|
|
5297
|
+
return missing ? { type: 'notice', text: missing } : await fn(skill)
|
|
5298
|
+
} catch (error) {
|
|
5299
|
+
return { type: 'run.error', error }
|
|
5300
|
+
}
|
|
5301
|
+
}
|
|
5302
|
+
]
|
|
5303
|
+
}
|
|
5304
|
+
|
|
5305
|
+
// the sheet sits over whatever opened it, so closing it lands back on the /skills list
|
|
5306
|
+
_openSheet(skill, { enable = false, field = null, start = false } = {}) {
|
|
5307
|
+
this._sheet = openSheet(skill, { routes: skillRoutes(skill), enable, field })
|
|
5308
|
+
this._menu = null
|
|
5309
|
+
this.overlay = null
|
|
5310
|
+
this._render()
|
|
5311
|
+
|
|
5312
|
+
return [this, this._loadSheet(this._sheet, { start })]
|
|
5313
|
+
}
|
|
5314
|
+
|
|
5315
|
+
// what an OAuth route already has, so the form says what may be left blank
|
|
5316
|
+
_loadSheet(sheet, { start = false } = {}) {
|
|
5317
|
+
const route = currentRoute(sheet)
|
|
5318
|
+
if (route?.kind !== 'oauth') {
|
|
5319
|
+
return null
|
|
5320
|
+
}
|
|
5321
|
+
|
|
5322
|
+
const { engine, agent } = this
|
|
5323
|
+
|
|
5324
|
+
return async () => {
|
|
5325
|
+
const spec = oauthSpecFor([sheet.skill], route.credentialKey)
|
|
5326
|
+
if (!spec) {
|
|
5327
|
+
return { type: 'sheet.client', sheet, oauth: { spec: null } }
|
|
5328
|
+
}
|
|
5329
|
+
|
|
5330
|
+
const saved = await savedClient(engine, { agentId: agent.id, stateKey: spec.stateKey })
|
|
5331
|
+
const env = envClient(spec.provider)
|
|
5332
|
+
const needsSecret = spec.tokenAuth !== 'pkce-only'
|
|
5333
|
+
const builtIn =
|
|
5334
|
+
!!spec.registrationEndpoint || !!(env.clientId && (!needsSecret || env.clientSecret))
|
|
5335
|
+
const oauth = {
|
|
5336
|
+
spec,
|
|
5337
|
+
builtIn,
|
|
5338
|
+
redirectUri: spec.port ? oauthRedirectUri(spec.port) : null,
|
|
5339
|
+
savedClientId: saved.clientId,
|
|
5340
|
+
savedSecret: Boolean(saved.clientSecret)
|
|
5341
|
+
}
|
|
5342
|
+
|
|
5343
|
+
return { type: 'sheet.client', sheet, start, oauth }
|
|
5344
|
+
}
|
|
5345
|
+
}
|
|
5346
|
+
|
|
5347
|
+
_sheetClient(msg) {
|
|
5348
|
+
const { sheet, oauth } = msg
|
|
5349
|
+
if (sheet !== this._sheet) {
|
|
5350
|
+
return [this, null]
|
|
5351
|
+
}
|
|
5352
|
+
|
|
5353
|
+
sheet.oauth = oauth
|
|
5354
|
+
if (!oauth.spec) {
|
|
5355
|
+
sheet.error = `${sheet.skill.name}'s sign-in settings cannot be used from here`
|
|
5356
|
+
}
|
|
5357
|
+
|
|
5358
|
+
if (
|
|
5359
|
+
oauth.savedClientId &&
|
|
5360
|
+
!sheet.values.clientId &&
|
|
5361
|
+
hasField(currentRoute(sheet), 'clientId')
|
|
5362
|
+
) {
|
|
5363
|
+
sheet.values.clientId = oauth.savedClientId
|
|
5364
|
+
}
|
|
5365
|
+
|
|
5366
|
+
this._render()
|
|
5367
|
+
|
|
5368
|
+
return msg.start && oauth.spec ? this._sheetConnect(sheet) : [this, null]
|
|
5369
|
+
}
|
|
5370
|
+
|
|
5371
|
+
_sheetKey(msg) {
|
|
5372
|
+
const sheet = this._sheet
|
|
5373
|
+
const route = currentRoute(sheet)
|
|
5374
|
+
if (!route) {
|
|
5375
|
+
return this._routePickerKey(sheet, msg)
|
|
5376
|
+
}
|
|
5377
|
+
|
|
5378
|
+
if (sheet.phase === 'waiting') {
|
|
5379
|
+
if (key.matches(msg, 'escape', 'enter')) {
|
|
5380
|
+
return this._cancelSheet(sheet)
|
|
5381
|
+
}
|
|
5382
|
+
|
|
5383
|
+
return key.matches(msg, 'ctrl+y') ? this._copySheetText(sheet.url, 'link') : [this, null]
|
|
5384
|
+
}
|
|
5385
|
+
|
|
5386
|
+
if (key.matches(msg, 'escape')) {
|
|
5387
|
+
return this._sheetEscape(sheet)
|
|
5388
|
+
}
|
|
5389
|
+
|
|
5390
|
+
if (key.matches(msg, 'ctrl+y')) {
|
|
5391
|
+
return this._copySheetText(sheet.oauth?.redirectUri, 'redirect URI')
|
|
5392
|
+
}
|
|
5393
|
+
|
|
5394
|
+
const { button } = focused(sheet)
|
|
5395
|
+
if (button && key.matches(msg, 'enter')) {
|
|
5396
|
+
return this._sheetPress(sheet, button.id)
|
|
5397
|
+
}
|
|
5398
|
+
|
|
5399
|
+
this._sheetEdit(sheet, msg)
|
|
5400
|
+
this._render()
|
|
5401
|
+
|
|
5402
|
+
return [this, null]
|
|
5403
|
+
}
|
|
5404
|
+
|
|
5405
|
+
// several routes step back to the choice between them before the sheet closes
|
|
5406
|
+
_sheetEscape(sheet) {
|
|
5407
|
+
if (sheet.routes.length > 1 && sheet.phase === 'edit') {
|
|
5408
|
+
sheet.route = null
|
|
5409
|
+
this._render()
|
|
5410
|
+
|
|
5411
|
+
return [this, null]
|
|
5412
|
+
}
|
|
5413
|
+
|
|
5414
|
+
return this._closeSheet()
|
|
5415
|
+
}
|
|
5416
|
+
|
|
5417
|
+
_sheetEdit(sheet, msg) {
|
|
5418
|
+
if (key.matches(msg, 'enter', 'tab', 'down')) {
|
|
5419
|
+
moveFocus(sheet, 1)
|
|
5420
|
+
} else if (key.matches(msg, 'shift+tab', 'up')) {
|
|
5421
|
+
moveFocus(sheet, -1)
|
|
5422
|
+
} else if (key.matches(msg, 'ctrl+r')) {
|
|
5423
|
+
sheet.revealed = !sheet.revealed
|
|
5424
|
+
} else if (key.matches(msg, 'backspace')) {
|
|
5425
|
+
backspace(sheet)
|
|
5426
|
+
} else if (this._isTypingKey(msg)) {
|
|
5427
|
+
typeInto(sheet, msg.sequence)
|
|
5428
|
+
}
|
|
5429
|
+
}
|
|
5430
|
+
|
|
5431
|
+
_routePickerKey(sheet, msg) {
|
|
5432
|
+
if (key.matches(msg, 'escape')) {
|
|
5433
|
+
return this._closeSheet()
|
|
5434
|
+
}
|
|
5435
|
+
|
|
5436
|
+
if (key.matches(msg, 'up', 'down')) {
|
|
5437
|
+
const delta = key.matches(msg, 'up') ? -1 : 1
|
|
5438
|
+
sheet.cursor = Math.max(0, Math.min(sheet.routes.length - 1, sheet.cursor + delta))
|
|
5439
|
+
this._render()
|
|
5440
|
+
|
|
5441
|
+
return [this, null]
|
|
5442
|
+
}
|
|
5443
|
+
|
|
5444
|
+
if (!key.matches(msg, 'enter')) {
|
|
5445
|
+
return [this, null]
|
|
5446
|
+
}
|
|
5447
|
+
|
|
5448
|
+
pickRoute(sheet, sheet.cursor)
|
|
5449
|
+
this._render()
|
|
5450
|
+
|
|
5451
|
+
return [this, this._loadSheet(sheet)]
|
|
5452
|
+
}
|
|
5453
|
+
|
|
5454
|
+
_sheetPress(sheet, id) {
|
|
5455
|
+
if (id === 'cancel') {
|
|
5456
|
+
return this._closeSheet()
|
|
5457
|
+
}
|
|
5458
|
+
|
|
5459
|
+
if (id === 'connect') {
|
|
5460
|
+
return this._sheetConnect(sheet)
|
|
5461
|
+
}
|
|
5462
|
+
|
|
5463
|
+
if (id === 'save') {
|
|
5464
|
+
return this._sheetSave(sheet)
|
|
5465
|
+
}
|
|
5466
|
+
|
|
5467
|
+
const route = currentRoute(sheet)
|
|
5468
|
+
if (id === 'disconnect') {
|
|
5469
|
+
return this._sheetRun(sheet, (engine, agentId) => disconnect(engine, { agentId, route }), {
|
|
5470
|
+
text: `${sheet.skill.name} disconnected for agent ${this.agent.name}`,
|
|
5471
|
+
stay: true
|
|
5472
|
+
})
|
|
5473
|
+
}
|
|
5474
|
+
|
|
5475
|
+
return this._sheetRun(sheet, () => null, { text: `${sheet.skill.name} is ready`, verify: true })
|
|
5476
|
+
}
|
|
5477
|
+
|
|
5478
|
+
_sheetConnect(sheet) {
|
|
5479
|
+
const spec = sheet.oauth?.spec
|
|
5480
|
+
if (!spec) {
|
|
5481
|
+
sheet.error ??= 'still reading this skill — try again in a moment'
|
|
5482
|
+
this._render()
|
|
5483
|
+
|
|
5484
|
+
return [this, null]
|
|
5485
|
+
}
|
|
5486
|
+
|
|
5487
|
+
const entered = enteredValues(sheet)
|
|
5488
|
+
const openUrl = (url) => {
|
|
5489
|
+
sheet.url = url
|
|
5490
|
+
this._repaint()
|
|
5491
|
+
this._openUrl(url)
|
|
5492
|
+
}
|
|
5493
|
+
const onStage = (stage) => {
|
|
5494
|
+
sheet.stage = OAUTH_STAGES[stage] ?? sheet.stage
|
|
5495
|
+
this._repaint()
|
|
5496
|
+
}
|
|
5497
|
+
sheet.phase = 'waiting'
|
|
5498
|
+
sheet.stage = null
|
|
5499
|
+
sheet.url = null
|
|
5500
|
+
sheet.focus = sheetFields(sheet).length
|
|
5501
|
+
|
|
5502
|
+
return this._sheetRun(
|
|
5503
|
+
sheet,
|
|
5504
|
+
(engine, agentId) => connectSkill(engine, { agentId, spec, entered, openUrl, onStage }),
|
|
5505
|
+
{ text: `${sheet.skill.name} connected for agent ${this.agent.name} — auto-refreshes on use` }
|
|
5506
|
+
)
|
|
5507
|
+
}
|
|
5508
|
+
|
|
5509
|
+
_sheetSave(sheet) {
|
|
5510
|
+
const route = currentRoute(sheet)
|
|
5511
|
+
const values = enteredValues(sheet)
|
|
5512
|
+
const empty = routeFields(route).find((field) => !values[field.key])
|
|
5513
|
+
if (empty) {
|
|
5514
|
+
sheet.error = `${empty.label} is empty — type or paste it`
|
|
5515
|
+
focusField(sheet, empty.key)
|
|
5516
|
+
this._render()
|
|
5517
|
+
|
|
5518
|
+
return [this, null]
|
|
5519
|
+
}
|
|
5520
|
+
|
|
5521
|
+
if (route.kind === 'picker') {
|
|
5522
|
+
const folder = expandHome(values[route.credentialKey])
|
|
5523
|
+
const problem = folderProblem(folder, route)
|
|
5524
|
+
if (problem) {
|
|
5525
|
+
sheet.error = problem
|
|
5526
|
+
this._render()
|
|
5527
|
+
|
|
5528
|
+
return [this, null]
|
|
5529
|
+
}
|
|
5530
|
+
|
|
5531
|
+
values[route.credentialKey] = folder
|
|
5532
|
+
}
|
|
5533
|
+
|
|
5534
|
+
const skillName = sheet.skill.name
|
|
5535
|
+
|
|
5536
|
+
return this._sheetRun(
|
|
5537
|
+
sheet,
|
|
5538
|
+
(engine, agentId) => saveFields(engine, { agentId, skillName, route, values }),
|
|
5539
|
+
{ text: `${skillName} saved for agent ${this.agent.name}` }
|
|
5540
|
+
)
|
|
5541
|
+
}
|
|
5542
|
+
|
|
5543
|
+
// a write is done once stored; only a re-check has to wait for the skill to read ready
|
|
5544
|
+
_sheetRun(sheet, work, { text, stay = false, verify = false }) {
|
|
5545
|
+
const attempt = ++sheet.attempt
|
|
5546
|
+
sheet.error = null
|
|
5547
|
+
this._render()
|
|
5548
|
+
const { engine, agent } = this
|
|
5549
|
+
|
|
5550
|
+
return [
|
|
5551
|
+
this,
|
|
5552
|
+
async () => {
|
|
5553
|
+
try {
|
|
5554
|
+
const outcome = await work(engine, agent.id)
|
|
5555
|
+
if (outcome?.need) {
|
|
5556
|
+
return { type: 'sheet.result', sheet, attempt, need: outcome.need }
|
|
5557
|
+
}
|
|
5558
|
+
|
|
5559
|
+
const skill = (await this._skillRow(sheet.skill.name)) ?? sheet.skill
|
|
5560
|
+
const done = !stay && (!verify || isReady(skill))
|
|
5561
|
+
const on = sheet.enable && done ? await this._toggleSkill(skill.name, { on: true }) : null
|
|
5562
|
+
|
|
5563
|
+
return {
|
|
5564
|
+
type: 'sheet.result',
|
|
5565
|
+
sheet,
|
|
5566
|
+
attempt,
|
|
5567
|
+
skill,
|
|
5568
|
+
done,
|
|
5569
|
+
stay,
|
|
5570
|
+
text: on ? `${text} · ${on}` : text
|
|
5571
|
+
}
|
|
5572
|
+
} catch (error) {
|
|
5573
|
+
return { type: 'sheet.result', sheet, attempt, error }
|
|
5574
|
+
}
|
|
5575
|
+
}
|
|
5576
|
+
]
|
|
5577
|
+
}
|
|
5578
|
+
|
|
5579
|
+
_sheetResult(msg) {
|
|
5580
|
+
const { sheet } = msg
|
|
5581
|
+
if (sheet !== this._sheet || msg.attempt !== sheet.attempt) {
|
|
5582
|
+
return [this, null]
|
|
5583
|
+
}
|
|
5584
|
+
|
|
5585
|
+
sheet.phase = 'edit'
|
|
5586
|
+
if (msg.need) {
|
|
5587
|
+
const missing = msg.need.clientId ? 'clientId' : 'clientSecret'
|
|
5588
|
+
sheet.error = `${msg.need.clientId ? 'Client ID' : 'Client Secret'} is needed — paste it from your app`
|
|
5589
|
+
focusField(sheet, missing)
|
|
5590
|
+
} else if (msg.error) {
|
|
5591
|
+
sheet.error = msg.error.message ?? String(msg.error)
|
|
5592
|
+
} else {
|
|
5593
|
+
sheet.skill = msg.skill
|
|
5594
|
+
this._syncSelector(msg.skill)
|
|
5595
|
+
this.notice = msg.text
|
|
5596
|
+
sheet.focus = 0
|
|
5597
|
+
// a finished setup hands back to whatever opened it, the line above the input says how it went
|
|
5598
|
+
if (msg.done) {
|
|
5599
|
+
this._sheet = null
|
|
5600
|
+
if (this._selector?.kind === 'skills') {
|
|
5601
|
+
this._selector.notice = msg.text
|
|
5602
|
+
}
|
|
5603
|
+
} else if (!msg.stay) {
|
|
5604
|
+
sheet.error = `${msg.skill.name} still reads ${statusLabel(msg.skill.status)}`
|
|
5605
|
+
}
|
|
5606
|
+
}
|
|
5607
|
+
|
|
5608
|
+
this._render()
|
|
5609
|
+
|
|
5610
|
+
return [this, null]
|
|
5611
|
+
}
|
|
5612
|
+
|
|
5613
|
+
_syncSelector(skill) {
|
|
5614
|
+
const s = this._selector
|
|
5615
|
+
if (s?.kind !== 'skills') {
|
|
5616
|
+
return
|
|
5617
|
+
}
|
|
5618
|
+
|
|
5619
|
+
s.detail?.set(skill.name, skill)
|
|
5620
|
+
s.enabled = new Set(this.agent?.enabledSkills ?? [])
|
|
5621
|
+
}
|
|
5622
|
+
|
|
5623
|
+
// the loopback holds a port until its timeout, so a sheet that stops waiting releases it
|
|
5624
|
+
_cancelSheet(sheet) {
|
|
5625
|
+
sheet.attempt++
|
|
5626
|
+
sheet.phase = 'edit'
|
|
5627
|
+
sheet.error = 'sign-in cancelled'
|
|
5628
|
+
this._render()
|
|
5629
|
+
|
|
5630
|
+
return [this, () => cancelOAuth(sheet.oauth.spec).then(() => ({ type: 'sheet.cancelled' }))]
|
|
5631
|
+
}
|
|
5632
|
+
|
|
5633
|
+
_closeSheet() {
|
|
5634
|
+
const sheet = this._sheet
|
|
5635
|
+
this._sheet = null
|
|
5636
|
+
this._render()
|
|
5637
|
+
if (sheet.phase === 'waiting') {
|
|
5638
|
+
return [this, () => cancelOAuth(sheet.oauth.spec).then(() => ({ type: 'sheet.cancelled' }))]
|
|
5639
|
+
}
|
|
5640
|
+
|
|
5641
|
+
return [this, null]
|
|
5642
|
+
}
|
|
5643
|
+
|
|
5644
|
+
_copySheetText(text, what) {
|
|
5645
|
+
if (!text || !this._copyToClipboard) {
|
|
5646
|
+
return [this, null]
|
|
5647
|
+
}
|
|
5648
|
+
|
|
5649
|
+
const copy = this._copyToClipboard
|
|
5650
|
+
const token = ++this._statusToken
|
|
5651
|
+
|
|
5652
|
+
return [
|
|
5653
|
+
this,
|
|
5654
|
+
async () => {
|
|
5655
|
+
try {
|
|
5656
|
+
await copy(text)
|
|
5657
|
+
return { type: 'transient-status', token, text: `${what} copied ✓` }
|
|
5658
|
+
} catch (err) {
|
|
5659
|
+
return { type: 'transient-status', token, text: `copy failed: ${err.message}` }
|
|
5660
|
+
}
|
|
5661
|
+
}
|
|
5662
|
+
]
|
|
5663
|
+
}
|
|
5664
|
+
|
|
5665
|
+
_repaint() {
|
|
5666
|
+
this._render()
|
|
5667
|
+
this._requestRepaint()
|
|
5668
|
+
}
|
|
5669
|
+
|
|
5208
5670
|
_advancedMenu() {
|
|
5209
5671
|
return {
|
|
5210
5672
|
title: 'Advanced',
|
|
5211
5673
|
cursor: 0,
|
|
5212
5674
|
entries: [
|
|
5213
|
-
{ label: 'Set credential…', hint: '/cred <key> <value>', prefill: '/cred ' },
|
|
5214
5675
|
{ label: 'Skills scope…', hint: '/scope skills all|selected', prefill: '/scope skills ' }
|
|
5215
5676
|
]
|
|
5216
5677
|
}
|
|
@@ -5690,6 +6151,12 @@ export class ChatApp {
|
|
|
5690
6151
|
return this._toggleToolset(s, name)
|
|
5691
6152
|
}
|
|
5692
6153
|
|
|
6154
|
+
// turning on a skill that cannot work yet opens its setup; it turns on once that succeeds
|
|
6155
|
+
const skill = s.detail?.get(name)
|
|
6156
|
+
if (!s.enabled.has(name) && SETUP_FIXES.has(skill?.status) && setupAction(skill)) {
|
|
6157
|
+
return this._openSheet(skill, { enable: true })
|
|
6158
|
+
}
|
|
6159
|
+
|
|
5693
6160
|
if (s.enabled.has(name)) {
|
|
5694
6161
|
s.enabled.delete(name)
|
|
5695
6162
|
} else {
|
|
@@ -5718,7 +6185,7 @@ export class ChatApp {
|
|
|
5718
6185
|
]
|
|
5719
6186
|
}
|
|
5720
6187
|
|
|
5721
|
-
// the
|
|
6188
|
+
// the sheet opens over the list, so esc lands back on it with the row refreshed
|
|
5722
6189
|
_setupSelected() {
|
|
5723
6190
|
const s = this._selector
|
|
5724
6191
|
if (s.kind === 'ctx') {
|
|
@@ -5730,23 +6197,11 @@ export class ChatApp {
|
|
|
5730
6197
|
}
|
|
5731
6198
|
|
|
5732
6199
|
const skill = s.detail.get(s.rows[s.cursor])
|
|
5733
|
-
if (!skill) {
|
|
6200
|
+
if (!skill || !skillRoutes(skill).length) {
|
|
5734
6201
|
return [this, null]
|
|
5735
6202
|
}
|
|
5736
6203
|
|
|
5737
|
-
|
|
5738
|
-
this._selector = null
|
|
5739
|
-
if (action?.command) {
|
|
5740
|
-
return this._command(action.command)
|
|
5741
|
-
}
|
|
5742
|
-
|
|
5743
|
-
if (action?.prefill) {
|
|
5744
|
-
this._setInput(action.prefill)
|
|
5745
|
-
}
|
|
5746
|
-
|
|
5747
|
-
this._render()
|
|
5748
|
-
|
|
5749
|
-
return [this, async () => ({ type: 'notice', text: renderSkill(skill) })]
|
|
6204
|
+
return this._openSheet(skill)
|
|
5750
6205
|
}
|
|
5751
6206
|
|
|
5752
6207
|
// it draws from the chats watch, so it opens on what has replicated: no fetch, no flicker
|
|
@@ -6926,6 +7381,18 @@ export class ChatApp {
|
|
|
6926
7381
|
return [this, null]
|
|
6927
7382
|
} // completion arrives via the chunk stream itself
|
|
6928
7383
|
|
|
7384
|
+
if (msg.type === 'sheet.open') {
|
|
7385
|
+
return this._openSheet(msg.skill, msg)
|
|
7386
|
+
}
|
|
7387
|
+
|
|
7388
|
+
if (msg.type === 'sheet.client') {
|
|
7389
|
+
return this._sheetClient(msg)
|
|
7390
|
+
}
|
|
7391
|
+
|
|
7392
|
+
if (msg.type === 'sheet.result') {
|
|
7393
|
+
return this._sheetResult(msg)
|
|
7394
|
+
}
|
|
7395
|
+
|
|
6929
7396
|
if (msg.type === 'notice') {
|
|
6930
7397
|
// transcript, not the footer: any status tick overwrites the footer's one truncated line
|
|
6931
7398
|
this.notice = msg.text
|
|
@@ -7046,6 +7513,10 @@ export class ChatApp {
|
|
|
7046
7513
|
return [this, quit]
|
|
7047
7514
|
}
|
|
7048
7515
|
|
|
7516
|
+
if (this._sheet) {
|
|
7517
|
+
return this._sheetKey(msg)
|
|
7518
|
+
}
|
|
7519
|
+
|
|
7049
7520
|
// modifier keys never collide with typing or the y/n approval answers
|
|
7050
7521
|
if (key.matches(msg, 'ctrl+y')) {
|
|
7051
7522
|
return this._copyReport() ?? this._copyInvite()
|
|
@@ -7594,6 +8065,12 @@ export class ChatApp {
|
|
|
7594
8065
|
: '↑/↓: chat · shift+↑/↓: reorder · enter: open · m: move to group · esc: close · ctrl+c: quit'
|
|
7595
8066
|
}
|
|
7596
8067
|
|
|
8068
|
+
if (this._sheet) {
|
|
8069
|
+
return this._sheet.phase === 'waiting'
|
|
8070
|
+
? 'esc: cancel sign-in · ctrl+y: copy link · ctrl+c: quit'
|
|
8071
|
+
: 'tab/↑↓: move · enter: select · ctrl+r: show secrets · esc: back · ctrl+c: quit'
|
|
8072
|
+
}
|
|
8073
|
+
|
|
7597
8074
|
if (this._models) return '↑/↓: move · enter: use · esc: back · ctrl+c: quit'
|
|
7598
8075
|
if (this._selector) {
|
|
7599
8076
|
const setup = this._selector.detail ? ' · enter: configure' : ''
|