@qvac/core 0.6.4 → 0.6.5

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 (90) hide show
  1. package/CHANGELOG.md +69 -1
  2. package/README.md +20 -4
  3. package/dist-lib/lib/api/chat-move.d.ts +3 -0
  4. package/dist-lib/lib/api/chat-move.js +7 -0
  5. package/dist-lib/lib/api/chat.d.ts +1 -1
  6. package/dist-lib/lib/api/chat.js +2 -1
  7. package/dist-lib/lib/api/chunk-delta.d.ts +7 -0
  8. package/dist-lib/lib/api/chunk-delta.js +33 -0
  9. package/dist-lib/lib/api/chunks.d.ts +1 -1
  10. package/dist-lib/lib/api/chunks.js +6 -3
  11. package/dist-lib/lib/api/index.d.ts +2 -0
  12. package/dist-lib/lib/api/index.js +2 -0
  13. package/dist-lib/lib/api/mesh.d.ts +2 -1
  14. package/dist-lib/lib/api/mesh.js +4 -0
  15. package/dist-lib/lib/assistant/harness.d.ts +8 -10
  16. package/dist-lib/lib/assistant.js +1 -1
  17. package/dist-lib/lib/constants.d.ts +1 -0
  18. package/dist-lib/lib/constants.js +1 -0
  19. package/dist-lib/lib/core/archived-mesh.js +3 -42
  20. package/dist-lib/lib/core/chat-activity.js +23 -10
  21. package/dist-lib/lib/core/chat-copy.d.ts +24 -0
  22. package/dist-lib/lib/core/chat-copy.js +115 -0
  23. package/dist-lib/lib/core/chat-move.d.ts +65 -0
  24. package/dist-lib/lib/core/chat-move.js +525 -0
  25. package/dist-lib/lib/core/chat.d.ts +6 -0
  26. package/dist-lib/lib/core/chat.js +11 -3
  27. package/dist-lib/lib/core/collections.d.ts +2 -0
  28. package/dist-lib/lib/core/collections.js +2 -0
  29. package/dist-lib/lib/core/contract/compute.d.ts +1 -1
  30. package/dist-lib/lib/core/contract/compute.js +2 -1
  31. package/dist-lib/lib/core/contract/index.js +2 -0
  32. package/dist-lib/lib/core/contract/invites.d.ts +1 -0
  33. package/dist-lib/lib/core/contract/invites.js +1 -1
  34. package/dist-lib/lib/core/contract/mesh-name.d.ts +3 -0
  35. package/dist-lib/lib/core/contract/mesh-name.js +26 -0
  36. package/dist-lib/lib/core/contract/writers.js +10 -3
  37. package/dist-lib/lib/core/files/index.d.ts +1 -1
  38. package/dist-lib/lib/core/files/index.js +1 -1
  39. package/dist-lib/lib/core/files/preview/index.js +4 -1
  40. package/dist-lib/lib/core/files/processing/source.js +4 -1
  41. package/dist-lib/lib/core/files/store/index.d.ts +2 -1
  42. package/dist-lib/lib/core/files/store/index.js +2 -1
  43. package/dist-lib/lib/core/files/store/reference.d.ts +3 -0
  44. package/dist-lib/lib/core/files/store/reference.js +8 -0
  45. package/dist-lib/lib/core/files/store/sweep.js +3 -1
  46. package/dist-lib/lib/core/local/index.d.ts +4 -1
  47. package/dist-lib/lib/core/local/index.js +14 -1
  48. package/dist-lib/lib/core/mesh-seed-handoff.d.ts +3 -1
  49. package/dist-lib/lib/core/mesh-seed-handoff.js +1 -0
  50. package/dist-lib/lib/core/mesh.d.ts +5 -1
  51. package/dist-lib/lib/core/mesh.js +16 -1
  52. package/dist-lib/lib/core/sync/index.js +9 -1
  53. package/dist-lib/lib/core.d.ts +9 -0
  54. package/dist-lib/lib/core.js +156 -30
  55. package/dist-lib/lib/custom-model-pusher.js +9 -5
  56. package/dist-lib/lib/mesh-scoped-engine.js +5 -0
  57. package/dist-lib/schema/config.d.ts +1 -1
  58. package/dist-lib/schema/config.js +1 -1
  59. package/dist-lib/schema/engine.js +80 -1
  60. package/dist-lib/schema/local.js +17 -0
  61. package/dist-lib/schema/qvac.d.ts +2 -0
  62. package/dist-lib/schema/qvac.js +16 -0
  63. package/dist-lib/spec/bind.js +25 -0
  64. package/dist-lib/spec/calls.js +5 -0
  65. package/dist-lib/spec/capabilities.d.ts +10 -0
  66. package/dist-lib/spec/config/hyperconf/index.js +1 -1
  67. package/dist-lib/spec/hrpc/hrpc.json +65 -0
  68. package/dist-lib/spec/hrpc/index.js +66 -4
  69. package/dist-lib/spec/hrpc/messages.js +1398 -1154
  70. package/dist-lib/spec/hyperschema/index.js +1398 -1154
  71. package/dist-lib/spec/hyperschema/schema.json +204 -0
  72. package/dist-lib/spec/hyperschema/types.d.ts +47 -0
  73. package/dist-lib/spec/local/hyperdb/db.json +17 -1
  74. package/dist-lib/spec/local/hyperdb/index.js +83 -2
  75. package/dist-lib/spec/local/hyperdb/messages.js +340 -136
  76. package/dist-lib/spec/local/hyperschema/index.js +107 -2
  77. package/dist-lib/spec/local/hyperschema/schema.json +78 -1
  78. package/dist-lib/spec/local/hyperschema/types.d.ts +18 -1
  79. package/dist-lib/spec/mesh/hyperdb/db.json +16 -1
  80. package/dist-lib/spec/mesh/hyperdb/index.js +71 -2
  81. package/dist-lib/spec/mesh/hyperdb/messages.js +454 -228
  82. package/dist-lib/spec/mesh/hyperdispatch/dispatch.json +7 -1
  83. package/dist-lib/spec/mesh/hyperdispatch/index.js +18 -1
  84. package/dist-lib/spec/mesh/hyperdispatch/messages.js +150 -2
  85. package/dist-lib/spec/mesh/hyperschema/index.js +150 -2
  86. package/dist-lib/spec/mesh/hyperschema/schema.json +76 -1
  87. package/dist-lib/spec/mesh/hyperschema/types.d.ts +21 -1
  88. package/package.json +5 -3
  89. package/tui/app.mjs +89 -3
  90. package/tui/lib/move-command.mjs +17 -0
package/tui/app.mjs CHANGED
@@ -31,6 +31,7 @@ import { paintSelection, selectionText } from './lib/select.mjs'
31
31
  import { center, splash } from './lib/splash.mjs'
32
32
  import { wrapBlock, wrapLine } from './lib/wrap.mjs'
33
33
  import { knowledgeCommand } from './lib/knowledge-command.mjs'
34
+ import { describeMove } from './lib/move-command.mjs'
34
35
  import { saveUniqueFile } from './lib/save-file.mjs'
35
36
  import { usageReport } from './lib/usage.mjs'
36
37
  import { compactionTriggerRatio } from '../dist-lib/lib/compaction.js'
@@ -235,12 +236,14 @@ const COMMANDS = [
235
236
  // before `meshes`, so a bare /mesh offers the verb first and the list second
236
237
  {
237
238
  name: 'mesh',
238
- desc: 'switch which mesh is the active one, open another, or name one',
239
+ desc: 'switch which mesh is the active one, open another, name one, or move a chat into one',
239
240
  palette: true,
240
241
  sub: [
241
242
  { name: 'use', desc: '<n|id> — make one of your meshes the active one' },
242
243
  { name: 'new', desc: '[compute] — open another shared mesh, or lend this device’s model' },
243
- { name: 'label', desc: '<n|id> <name> — name a mesh, privately to you' }
244
+ { name: 'label', desc: '<n|id> <name> — name a mesh, privately to you' },
245
+ { name: 'move', desc: '<n|id> [chat] — move this chat, or a named one, into another mesh' },
246
+ { name: 'moved', desc: '[chat] — how the last move from this window is going' }
244
247
  ]
245
248
  },
246
249
  { name: 'meshes', desc: 'list the meshes this device belongs to', palette: true },
@@ -1639,6 +1642,8 @@ export class ChatApp {
1639
1642
  this._skills = skills || null
1640
1643
  this.agent = agent
1641
1644
  this.chatId = chatId
1645
+ // the chat /mesh moved reports on when named none: its source row is purged once it lands
1646
+ this._lastMove = null
1642
1647
  // applied only if this device is the agent's provider; null on a joiner
1643
1648
  this._modelName = modelName || null
1644
1649
  // run as init()'s first command so the connection happens inside the TUI, not before render
@@ -2260,6 +2265,7 @@ export class ChatApp {
2260
2265
  ' /members — list mesh members with their devices grouped',
2261
2266
  ' /meshes - list the meshes this device belongs to, numbered, marking account / shared / active / open / writable',
2262
2267
  ' /mesh use <n|id> - make one of them active; its agent, chat and roster replace the ones on screen',
2268
+ ' /mesh move <n|id> [chat] - move this chat (or the named one) into another mesh, its files and running turn with it · /mesh moved [chat] - how that move is going',
2263
2269
  ' /my-device — dump this device\u2019s CPU/GPU inventory (manufacturer, cores, drivers, …)'
2264
2270
  ].join('\n')
2265
2271
 
@@ -3420,7 +3426,17 @@ export class ChatApp {
3420
3426
  })
3421
3427
  }
3422
3428
 
3423
- return notice('usage: /mesh use <n|id> · /mesh new [compute] · /mesh label <n|id> <name>')
3429
+ if (action === 'move' && target) {
3430
+ return run(() => this._moveChat(target, labelParts.join(' ')))
3431
+ }
3432
+
3433
+ if (action === 'moved') {
3434
+ return run(() => this._movedChat(target))
3435
+ }
3436
+
3437
+ return notice(
3438
+ 'usage: /mesh use <n|id> · /mesh new [compute] · /mesh label <n|id> <name> · /mesh move <n|id> [chat] · /mesh moved [chat]'
3439
+ )
3424
3440
  }
3425
3441
 
3426
3442
  // the same interactive pickers as the menu's Switch rows, rather than a list to /…use by id
@@ -6523,6 +6539,76 @@ export class ChatApp {
6523
6539
  ]
6524
6540
  }
6525
6541
 
6542
+ // the target's first agent answers it there; a mesh with none leaves the chat waiting for one
6543
+ async _moveChat(selector, chatNeedle) {
6544
+ const named = await this._resolveMesh(selector)
6545
+ if (named.error) {
6546
+ return named.error
6547
+ }
6548
+
6549
+ const chat = await this._chatToMove(chatNeedle)
6550
+ if (chat.miss) {
6551
+ return chat.miss
6552
+ }
6553
+
6554
+ const { agents } = await this.engine.listAgents({ meshId: named.meshId })
6555
+ const move = await this.engine.moveChatToMesh({
6556
+ meshId: this.meshId,
6557
+ chatId: chat.id,
6558
+ targetMeshId: named.meshId,
6559
+ agentId: agents?.[0]?.id
6560
+ })
6561
+ this._lastMove = { id: chat.id, title: chat.title }
6562
+
6563
+ return this._describeMove(move, chat.title)
6564
+ }
6565
+
6566
+ async _movedChat(chatNeedle) {
6567
+ const chat = chatNeedle ? await this._chatToMove(chatNeedle) : this._lastMove
6568
+ if (!chat || chat.miss) {
6569
+ return chat?.miss ?? 'no move from this window yet - /mesh move <n|id> [chat]'
6570
+ }
6571
+
6572
+ const frames = this.engine.chatMoveWatch({ meshId: this.meshId, chatId: chat.id })
6573
+ try {
6574
+ for await (const move of frames) {
6575
+ return this._describeMove(move, chat.title)
6576
+ }
6577
+ } finally {
6578
+ frames.destroy()
6579
+ }
6580
+
6581
+ return 'the move watch ended'
6582
+ }
6583
+
6584
+ async _describeMove(move, title) {
6585
+ const { meshes } = await this.engine.listMeshes({}).catch(() => ({ meshes: [] }))
6586
+ const index = (meshes ?? []).findIndex((mesh) => mesh.meshId === move.targetMeshId)
6587
+ const where = index < 0 ? '/meshes lists it' : `/mesh use ${index + 1} to open it`
6588
+
6589
+ return describeMove(move, { title, where })
6590
+ }
6591
+
6592
+ async _chatToMove(needle) {
6593
+ if (!needle) {
6594
+ if (!this.chatId) {
6595
+ return { miss: 'no chat is open' }
6596
+ }
6597
+
6598
+ const { chats } = await this.engine.listChats({ meshId: this.meshId })
6599
+ const open = (chats ?? []).find((c) => c.id === this.chatId)
6600
+
6601
+ return { id: this.chatId, title: open?.title || 'this chat' }
6602
+ }
6603
+
6604
+ const { chat, ambiguous } = await this._resolveChat(needle)
6605
+ if (ambiguous) {
6606
+ return { miss: `"${needle}" matches ${ambiguous} chats — be specific` }
6607
+ }
6608
+
6609
+ return chat ? { id: chat.id, title: chat.title } : { miss: `no chat matching "${needle}"` }
6610
+ }
6611
+
6526
6612
  // The same selector /mesh use takes, so a mesh is named by its list number as well as its id
6527
6613
  async _resolveMesh(selector) {
6528
6614
  const { meshes } = await this.engine.listMeshes({})
@@ -0,0 +1,17 @@
1
+ // what one chatMoveWatch frame tells the person who typed /mesh move
2
+ export function describeMove(move, { title, where }) {
3
+ const short = move.targetMeshId.slice(0, 8)
4
+ if (move.state === 'failed') {
5
+ return `move of "${title}" failed: ${move.failure}`
6
+ }
7
+
8
+ if (move.state === 'carrying') {
9
+ const files = move.waiting?.length ? move.waiting.join(', ') : `${move.files - move.carried}`
10
+ return `"${title}" is in ${short} - waiting on ${files}; the source stays until they arrive, /mesh moved shows progress`
11
+ }
12
+
13
+ const retried = move.restarted ? ' - its running turn is answered again there' : ''
14
+ const settled = move.state === 'complete' ? 'moved' : 'moving'
15
+
16
+ return `${settled} "${title}" to ${short}${retried} - ${where}`
17
+ }