@qvac/core 0.1.5 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/README.md +10 -5
  2. package/dist-lib/lib/api/chat-groups.d.ts +1 -1
  3. package/dist-lib/lib/api/chat-groups.js +6 -3
  4. package/dist-lib/lib/core/chat-group.d.ts +5 -0
  5. package/dist-lib/lib/core/chat-group.js +63 -1
  6. package/dist-lib/lib/core/chat.d.ts +10 -0
  7. package/dist-lib/lib/core/chat.js +75 -9
  8. package/dist-lib/lib/core/files/rag/retrieval/knowledge.js +1 -0
  9. package/dist-lib/lib/core/files/rag/retrieval/search.js +4 -1
  10. package/dist-lib/lib/core/files/rag/retrieval/selection.d.ts +1 -0
  11. package/dist-lib/lib/core/files/rag/retrieval/selection.js +31 -1
  12. package/dist-lib/lib/core/files/rag/retrieval/types.d.ts +1 -0
  13. package/dist-lib/lib/core/rank.d.ts +14 -0
  14. package/dist-lib/lib/core/rank.js +23 -0
  15. package/dist-lib/schema/engine.js +30 -0
  16. package/dist-lib/schema/field-order.js +3 -1
  17. package/dist-lib/schema/qvac.js +5 -2
  18. package/dist-lib/spec/bind.js +9 -0
  19. package/dist-lib/spec/calls.js +31 -28
  20. package/dist-lib/spec/capabilities.d.ts +6 -0
  21. package/dist-lib/spec/hrpc/hrpc.json +39 -0
  22. package/dist-lib/spec/hrpc/index.js +39 -3
  23. package/dist-lib/spec/hrpc/messages.js +63 -2
  24. package/dist-lib/spec/hyperschema/index.js +63 -2
  25. package/dist-lib/spec/hyperschema/schema.json +44 -1
  26. package/dist-lib/spec/hyperschema/types.d.ts +14 -1
  27. package/dist-lib/spec/mesh/hyperdb/messages.js +36 -14
  28. package/dist-lib/spec/mesh/hyperdispatch/messages.js +19 -8
  29. package/dist-lib/spec/mesh/hyperschema/index.js +19 -8
  30. package/dist-lib/spec/mesh/hyperschema/schema.json +16 -1
  31. package/dist-lib/spec/mesh/hyperschema/types.d.ts +4 -1
  32. package/package.json +2 -2
  33. package/tui/app.mjs +95 -23
  34. package/tui/lib/sidebar.mjs +3 -2
@@ -1,12 +1,12 @@
1
1
  // This file is autogenerated by the hyperschema compiler
2
- // Schema Version: 5
2
+ // Schema Version: 6
3
3
  /* eslint-disable camelcase */
4
4
  /* eslint-disable quotes */
5
5
  /* eslint-disable space-before-function-paren */
6
6
 
7
7
  import { c } from 'hyperschema/runtime'
8
8
 
9
- const VERSION = 5
9
+ const VERSION = 6
10
10
 
11
11
  // eslint-disable-next-line no-unused-vars
12
12
  let version = VERSION
@@ -2077,11 +2077,13 @@ const encoding45 = {
2077
2077
  c.string.preencode(state, m.agentId)
2078
2078
  c.string.preencode(state, m.title)
2079
2079
  c.uint.preencode(state, m.createdAt)
2080
- state.end++ // max flag is 16 so always one byte
2080
+ state.end++ // max flag is 64 so always one byte
2081
2081
 
2082
2082
  if (m.deletedAt) c.uint.preencode(state, m.deletedAt)
2083
2083
  if (m.updatedAt) c.uint.preencode(state, m.updatedAt)
2084
2084
  if (version >= 5 && m.groupId) c.string.preencode(state, m.groupId)
2085
+ if (version >= 6 && m.rank) c.float64.preencode(state, m.rank)
2086
+ if (version >= 6 && m.rankedAt) c.uint.preencode(state, m.rankedAt)
2085
2087
  },
2086
2088
  encode(state, m) {
2087
2089
  const flags =
@@ -2089,7 +2091,9 @@ const encoding45 = {
2089
2091
  (m.ragEnabled ? 2 : 0) |
2090
2092
  (m.webSearchEnabled ? 4 : 0) |
2091
2093
  (m.updatedAt ? 8 : 0) |
2092
- ((version >= 5 && m.groupId) ? 16 : 0)
2094
+ ((version >= 5 && m.groupId) ? 16 : 0) |
2095
+ ((version >= 6 && m.rank) ? 32 : 0) |
2096
+ ((version >= 6 && m.rankedAt) ? 64 : 0)
2093
2097
 
2094
2098
  c.string.encode(state, m.id)
2095
2099
  c.string.encode(state, m.agentId)
@@ -2100,6 +2104,8 @@ const encoding45 = {
2100
2104
  if (m.deletedAt) c.uint.encode(state, m.deletedAt)
2101
2105
  if (m.updatedAt) c.uint.encode(state, m.updatedAt)
2102
2106
  if (version >= 5 && m.groupId) c.string.encode(state, m.groupId)
2107
+ if (version >= 6 && m.rank) c.float64.encode(state, m.rank)
2108
+ if (version >= 6 && m.rankedAt) c.uint.encode(state, m.rankedAt)
2103
2109
  },
2104
2110
  decode(state) {
2105
2111
  const v = c.uint.decode(state)
@@ -2119,7 +2125,9 @@ const encoding45 = {
2119
2125
  ragEnabled: (flags & 2) !== 0,
2120
2126
  webSearchEnabled: (flags & 4) !== 0,
2121
2127
  updatedAt: (flags & 8) !== 0 ? c.uint.decode(state) : 0,
2122
- groupId: (version >= 5 && (flags & 16) !== 0) ? c.string.decode(state) : null
2128
+ groupId: (version >= 5 && (flags & 16) !== 0) ? c.string.decode(state) : null,
2129
+ rank: (version >= 6 && (flags & 32) !== 0) ? c.float64.decode(state) : 0,
2130
+ rankedAt: (version >= 6 && (flags & 64) !== 0) ? c.uint.decode(state) : 0
2123
2131
  }
2124
2132
  }
2125
2133
  }
@@ -5226,12 +5234,13 @@ const encoding127 = {
5226
5234
  c.string.preencode(state, m.name)
5227
5235
  c.uint.preencode(state, m.createdAt)
5228
5236
  c.uint.preencode(state, m.updatedAt)
5229
- state.end++ // max flag is 1 so always one byte
5237
+ state.end++ // max flag is 2 so always one byte
5230
5238
 
5231
5239
  if (version >= 5 && m.deletedAt) c.uint.preencode(state, m.deletedAt)
5240
+ if (version >= 6 && m.rank) c.float64.preencode(state, m.rank)
5232
5241
  },
5233
5242
  encode(state, m) {
5234
- const flags = (version >= 5 && m.deletedAt) ? 1 : 0
5243
+ const flags = ((version >= 5 && m.deletedAt) ? 1 : 0) | ((version >= 6 && m.rank) ? 2 : 0)
5235
5244
 
5236
5245
  c.string.encode(state, m.id)
5237
5246
  c.string.encode(state, m.name)
@@ -5240,6 +5249,7 @@ const encoding127 = {
5240
5249
  c.uint.encode(state, flags)
5241
5250
 
5242
5251
  if (version >= 5 && m.deletedAt) c.uint.encode(state, m.deletedAt)
5252
+ if (version >= 6 && m.rank) c.float64.encode(state, m.rank)
5243
5253
  },
5244
5254
  decode(state) {
5245
5255
  const v = c.uint.decode(state)
@@ -5255,7 +5265,8 @@ const encoding127 = {
5255
5265
  name: r1,
5256
5266
  createdAt: r2,
5257
5267
  updatedAt: r3,
5258
- deletedAt: (version >= 5 && (flags & 1) !== 0) ? c.uint.decode(state) : 0
5268
+ deletedAt: (version >= 5 && (flags & 1) !== 0) ? c.uint.decode(state) : 0,
5269
+ rank: (version >= 6 && (flags & 2) !== 0) ? c.float64.decode(state) : 0
5259
5270
  }
5260
5271
  }
5261
5272
  }
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": 5,
2
+ "version": 6,
3
3
  "schema": [
4
4
  {
5
5
  "name": "chunk-type",
@@ -1333,6 +1333,16 @@
1333
1333
  "name": "groupId",
1334
1334
  "type": "string",
1335
1335
  "version": 5
1336
+ },
1337
+ {
1338
+ "name": "rank",
1339
+ "type": "float64",
1340
+ "version": 6
1341
+ },
1342
+ {
1343
+ "name": "rankedAt",
1344
+ "type": "uint",
1345
+ "version": 6
1336
1346
  }
1337
1347
  ]
1338
1348
  },
@@ -3099,6 +3109,11 @@
3099
3109
  "name": "deletedAt",
3100
3110
  "type": "uint",
3101
3111
  "version": 5
3112
+ },
3113
+ {
3114
+ "name": "rank",
3115
+ "type": "float64",
3116
+ "version": 6
3102
3117
  }
3103
3118
  ]
3104
3119
  },
@@ -1,5 +1,5 @@
1
1
  // This file is autogenerated by hyperschema-ts
2
- // Schema version: 5
2
+ // Schema version: 6
3
3
  // Do not edit manually.
4
4
 
5
5
  export type QvacChunkType = "user-message" | "content" | "thinking" | "tool-call" | "tool-result" | "attachment" | "approval-request" | "run-status" | "run-request" | "sources" | "compaction"
@@ -244,6 +244,8 @@ export interface QvacChatV1 {
244
244
  webSearchEnabled?: boolean
245
245
  updatedAt?: number
246
246
  groupId?: string | null
247
+ rank?: number
248
+ rankedAt?: number
247
249
  }
248
250
 
249
251
  export type QvacChat = (QvacChatV1 & { version?: number })
@@ -609,6 +611,7 @@ export interface QvacChatGroupV1 {
609
611
  createdAt: number
610
612
  updatedAt: number
611
613
  deletedAt?: number
614
+ rank?: number
612
615
  }
613
616
 
614
617
  export type QvacChatGroup = (QvacChatGroupV1 & { version?: number })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qvac/core",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "type": "module",
5
5
  "description": "Peer-to-peer AI across your devices",
6
6
  "exports": {
@@ -216,7 +216,7 @@
216
216
  }
217
217
  },
218
218
  "dependencies": {
219
- "@qvac/harness": "^0.2.4",
219
+ "@qvac/harness": "^0.2.7",
220
220
  "@qvac/skills": "^0.1.3",
221
221
  "asenion": "^0.1.0",
222
222
  "autobee": "2.6.0",
package/tui/app.mjs CHANGED
@@ -1273,15 +1273,16 @@ export class ChatApp {
1273
1273
  const HELP = [
1274
1274
  'Chat',
1275
1275
  ' /menu — open the navigable menu (Agent, Chat, Models, Voice, …); also ctrl+p, arrows + enter to browse',
1276
- ' ctrl+b — the chats sidebar: ↑/↓ walks it, enter opens a chat, m moves one to a group, esc closes',
1276
+ ' ctrl+b — the chats sidebar: ↑/↓ walks it, enter opens a chat, m moves one to a group, shift+↑/↓ reorders it, esc closes',
1277
1277
  ' esc — stop the run in flight, or clear the last command’s output',
1278
1278
  ' ctrl+o — expand the tool call/result previews (a click on a preview’s marker does the same)',
1279
1279
  ' /new-chat — create and switch to a new chat (shortcut for /chat new)',
1280
1280
  ' /chats — pick from your chats to switch (interactive) · /chat — show current',
1281
1281
  ' /chat new [title] · /chat use <title|id> · /chat rename <title> · /chat del <title|id> · /chat websearch on|off · /chat rag on|off',
1282
- ' /group — the sidebar as core orders it (groups, then ungrouped, each most-recently-active first)',
1282
+ ' /group — the sidebar as core orders it (groups, then ungrouped; a chat sits where it was dragged until it gets a message, then on top)',
1283
1283
  ' /group new <name> · /group rename <group> <name> · /group del <group> — quote any name containing spaces',
1284
- ' /group move <group> [chat] — move a chat into a group; the chat defaults to the active one, and - as the group ungroups it',
1284
+ ' /group move <group> [chat] [after <chat>|first] — move a chat into a group, optionally to a place in it; the chat defaults to the active one, and - as the group ungroups it',
1285
+ ' /group order <group> after <group>|first — reorder the groups themselves',
1285
1286
  ' /knowledge [list] · /knowledge add <file> · /knowledge add-dir <directory> · /knowledge download <n|id> · /knowledge remove <n|id>',
1286
1287
  ' /files — show upload progress, local readiness, and failures for this chat',
1287
1288
  ' /attach <path> [<path> …] — attach local files to this chat (quote paths that contain spaces)',
@@ -1960,12 +1961,18 @@ export class ChatApp {
1960
1961
  })
1961
1962
  }
1962
1963
  if (action === 'move') {
1963
- // group first, chat optional, so the one-argument form is a strict prefix of the two;
1964
- // tokenized rather than joined, which is why a name with a space has to be quoted
1965
- const [groupNeedle, chatNeedle, ...extra] = splitPaths(argParts.join(' '))
1966
- if (!groupNeedle || extra.length > 0) {
1964
+ // group first, chat optional, quoted names intact. A trailing `after <chat>|first` also
1965
+ // places the chat (moveChat); without it recency places it (setChatGroup)
1966
+ const tokens = splitPaths(argParts.join(' '))
1967
+ const afterAt = tokens.indexOf('after', 1)
1968
+ const [groupNeedle, chatNeedle, ...extra] =
1969
+ afterAt === -1 ? tokens : tokens.slice(0, afterAt)
1970
+ const anchorNeedle = afterAt === -1 ? null : tokens[afterAt + 1]
1971
+ const malformed =
1972
+ !groupNeedle || extra.length > 0 || (afterAt !== -1 && tokens.length !== afterAt + 2)
1973
+ if (malformed) {
1967
1974
  return notice(
1968
- 'usage: /group move <group>|- [chat] (defaults to this chat; quote a name with spaces)'
1975
+ 'usage: /group move <group>|- [chat] [after <chat>|first] (defaults to this chat; quote a name with spaces)'
1969
1976
  )
1970
1977
  }
1971
1978
  // a miss comes back as text, not a throw, so it renders as a notice like every other miss
@@ -1976,19 +1983,48 @@ export class ChatApp {
1976
1983
  if (!chat) return { miss: `no chat matching "${chatNeedle}"` }
1977
1984
  return { id: chat.id, what: `"${chat.title}"` }
1978
1985
  }
1979
- if (groupNeedle === '-') {
1980
- return run(async () => {
1981
- const { id, what, miss } = await target()
1982
- if (miss) return miss
1983
- await engine.setChatGroup({ id })
1984
- return `${what} is ungrouped`
1985
- })
1986
+ const anchor = async () => {
1987
+ if (anchorNeedle === null) return { placed: '' }
1988
+ if (anchorNeedle === 'first') return { afterId: undefined, placed: ', first' }
1989
+ const { chat, ambiguous } = await this._resolveChat(anchorNeedle)
1990
+ if (ambiguous) {
1991
+ return { miss: `"${anchorNeedle}" matches ${ambiguous} chats — be specific` }
1992
+ }
1993
+ if (!chat) return { miss: `no chat matching "${anchorNeedle}"` }
1994
+ return { afterId: chat.id, placed: `, after "${chat.title}"` }
1986
1995
  }
1987
- return withGroup(groupNeedle, async (group) => {
1996
+ const place = async (groupId, into) => {
1988
1997
  const { id, what, miss } = await target()
1989
1998
  if (miss) return miss
1990
- await engine.setChatGroup({ id, groupId: group.id })
1991
- return `moved ${what} to "${group.name}"`
1999
+ const at = await anchor()
2000
+ if (at.miss) return at.miss
2001
+ if (anchorNeedle === null) {
2002
+ await engine.setChatGroup({ id, groupId })
2003
+ return groupId ? `moved ${what} to ${into}` : `${what} is ungrouped`
2004
+ }
2005
+ await engine.moveChat({ id, groupId, afterId: at.afterId })
2006
+ return `moved ${what} to ${into}${at.placed}`
2007
+ }
2008
+ if (groupNeedle === '-') return run(() => place(undefined, 'the ungrouped list'))
2009
+ return withGroup(groupNeedle, (group) => place(group.id, `"${group.name}"`))
2010
+ }
2011
+ if (action === 'order') {
2012
+ const [needle, keyword, anchorNeedle, ...extra] = splitPaths(argParts.join(' '))
2013
+ if (!needle || keyword !== 'after' || !anchorNeedle || extra.length > 0) {
2014
+ return notice(
2015
+ 'usage: /group order <group> after <group>|first (quote a name with spaces)'
2016
+ )
2017
+ }
2018
+ return withGroup(needle, async (group) => {
2019
+ if (anchorNeedle === 'first') {
2020
+ await engine.moveChatGroup({ id: group.id })
2021
+ return `moved "${group.name}" first`
2022
+ }
2023
+ const { group: anchor, ambiguous } = await this._resolveGroup(anchorNeedle)
2024
+ if (ambiguous) return `"${anchorNeedle}" matches ${ambiguous} groups — be specific`
2025
+ if (!anchor) return `no group matching "${anchorNeedle}"`
2026
+ await engine.moveChatGroup({ id: group.id, afterId: anchor.id })
2027
+ return `moved "${group.name}" after "${anchor.name}"`
1992
2028
  })
1993
2029
  }
1994
2030
  if (action === 'rename') {
@@ -2013,7 +2049,9 @@ export class ChatApp {
2013
2049
  return `deleted "${group.name}" — its chats are now ungrouped`
2014
2050
  })
2015
2051
  }
2016
- return notice('usage: /group [new <name>|rename <group> <name>|del <group>|move <group>|-]')
2052
+ return notice(
2053
+ 'usage: /group [new <name>|rename <group> <name>|del <group>|move <group>|- [chat] [after <chat>|first]|order <group> after <group>|first]'
2054
+ )
2017
2055
  }
2018
2056
 
2019
2057
  return notice(`unknown command: /${cmd}\n${HELP}`)
@@ -2052,8 +2090,7 @@ export class ChatApp {
2052
2090
  return { group: matches[0] ?? null }
2053
2091
  }
2054
2092
 
2055
- // core hands chats back oldest-activity first (app-runtime reverses to render); this does the
2056
- // same so the listing reads newest-first, and groups already arrive in presentation order
2093
+ // core hands chats back bottom-of-sidebar first; reversed so the listing reads top-down
2057
2094
  _groupOverview() {
2058
2095
  const { engine } = this
2059
2096
  return [
@@ -2080,7 +2117,7 @@ export class ChatApp {
2080
2117
  return {
2081
2118
  type: 'notice',
2082
2119
  text: lines.length
2083
- ? `chats by group — most recently active first\n${lines.join('\n')}`
2120
+ ? `chats by group — in sidebar order\n${lines.join('\n')}`
2084
2121
  : 'no chats yet'
2085
2122
  }
2086
2123
  } catch (error) {
@@ -2932,6 +2969,38 @@ export class ChatApp {
2932
2969
  return [this, null]
2933
2970
  }
2934
2971
 
2972
+ // shift+↑/↓ on a chat row: drop it one place up or down inside its container
2973
+ _nudgeChat(delta) {
2974
+ const rows = this._sidebarRows()
2975
+ const row = rows[this._sidebarCursor(rows)]
2976
+ if (row?.kind !== 'chat') return [this, null]
2977
+ const chat = this._chats.find((c) => c.id === row.chatId)
2978
+ if (!chat) return [this, null]
2979
+ const groupId = chat.groupId || undefined
2980
+ const siblings = [...this._chats]
2981
+ .reverse()
2982
+ .filter((c) => !c.deletedAt && (c.groupId || undefined) === groupId)
2983
+ .map((c) => c.id)
2984
+ const at = siblings.indexOf(chat.id)
2985
+ const to = at + delta
2986
+ if (to < 0 || to >= siblings.length) return [this, null]
2987
+ // up: under the chat two above (none = top); down: under the chat just below
2988
+ const afterId = delta < 0 ? siblings[to - 1] : siblings[to]
2989
+ const { engine } = this
2990
+ const token = ++this._statusToken
2991
+ return [
2992
+ this,
2993
+ async () => {
2994
+ try {
2995
+ await engine.moveChat({ id: chat.id, groupId, afterId })
2996
+ return { type: 'transient-status', token, text: `moved ${delta < 0 ? 'up' : 'down'}` }
2997
+ } catch (error) {
2998
+ return { type: 'run.error', error }
2999
+ }
3000
+ }
3001
+ ]
3002
+ }
3003
+
2935
3004
  _sidebarActivate() {
2936
3005
  const s = this._sidebar
2937
3006
  const rows = this._sidebarRows()
@@ -2967,6 +3036,9 @@ export class ChatApp {
2967
3036
  // just hands focus back.
2968
3037
  _sidebarKey(msg) {
2969
3038
  const s = this._sidebar
3039
+ // shift first: the plain arrow also matches a shifted one
3040
+ if (!s.moving && key.matches(msg, 'shift+up')) return this._nudgeChat(-1)
3041
+ if (!s.moving && key.matches(msg, 'shift+down')) return this._nudgeChat(1)
2970
3042
  if (key.matches(msg, 'up')) return this._moveSidebar(-1)
2971
3043
  if (key.matches(msg, 'down')) return this._moveSidebar(1)
2972
3044
  if (key.matches(msg, 'enter')) return this._sidebarActivate()
@@ -3986,7 +4058,7 @@ export class ChatApp {
3986
4058
  if (this._sidebar?.focus) {
3987
4059
  return this._sidebar.moving
3988
4060
  ? '↑/↓: group · enter: move here · esc: cancel · ctrl+c: quit'
3989
- : '↑/↓: chat · enter: open · m: move to group · esc: close · ctrl+c: quit'
4061
+ : '↑/↓: chat · shift+↑/↓: reorder · enter: open · m: move to group · esc: close · ctrl+c: quit'
3990
4062
  }
3991
4063
  if (this._models) return '↑/↓: move · enter: use · esc: back · ctrl+c: quit'
3992
4064
  if (this._selector) {
@@ -1,6 +1,7 @@
1
1
  // The chat sidebar's row model: chats under their groups, in the order core
2
- // presents them (groups first, each chat newest-activity first). Rows are what
3
- // the pane draws and what its cursor walks; only `chat` rows are selectable.
2
+ // presents them (groups first, each chat where it was dragged or else
3
+ // newest-activity first). Rows are what the pane draws and what its cursor
4
+ // walks; only `chat` rows are selectable.
4
5
 
5
6
  export const SIDEBAR_COLS = 26
6
7