@qvac/core 0.7.0 → 0.7.1

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 (61) hide show
  1. package/CHANGELOG.md +67 -1
  2. package/dist-lib/lib/api/chat.d.ts +1 -1
  3. package/dist-lib/lib/api/chat.js +9 -0
  4. package/dist-lib/lib/api/index.d.ts +2 -1
  5. package/dist-lib/lib/api/index.js +2 -1
  6. package/dist-lib/lib/api/network.d.ts +8 -1
  7. package/dist-lib/lib/api/network.js +6 -0
  8. package/dist-lib/lib/assistant/harness.d.ts +2 -0
  9. package/dist-lib/lib/assistant.js +5 -0
  10. package/dist-lib/lib/core/agent.d.ts +2 -0
  11. package/dist-lib/lib/core/agent.js +16 -5
  12. package/dist-lib/lib/core/blind-peers.d.ts +4 -0
  13. package/dist-lib/lib/core/blind-peers.js +1 -0
  14. package/dist-lib/lib/core/chat-copy.d.ts +4 -0
  15. package/dist-lib/lib/core/chat-copy.js +1 -1
  16. package/dist-lib/lib/core/chat-fork.d.ts +21 -0
  17. package/dist-lib/lib/core/chat-fork.js +245 -0
  18. package/dist-lib/lib/core/chat-move.js +1 -4
  19. package/dist-lib/lib/core/chat.d.ts +1 -0
  20. package/dist-lib/lib/core/chat.js +1 -1
  21. package/dist-lib/lib/core/departures.d.ts +5 -1
  22. package/dist-lib/lib/core/departures.js +15 -1
  23. package/dist-lib/lib/core/fs-drives.d.ts +8 -1
  24. package/dist-lib/lib/core/fs-drives.js +47 -15
  25. package/dist-lib/lib/core/harness-loan.d.ts +4 -20
  26. package/dist-lib/lib/core/harness-loan.js +7 -184
  27. package/dist-lib/lib/core/id.d.ts +1 -0
  28. package/dist-lib/lib/core/id.js +3 -0
  29. package/dist-lib/lib/core/mesh.d.ts +3 -2
  30. package/dist-lib/lib/core/mesh.js +11 -1
  31. package/dist-lib/lib/core/migrations/agent-tools-scope.d.ts +2 -0
  32. package/dist-lib/lib/core/migrations/agent-tools-scope.js +24 -0
  33. package/dist-lib/lib/core/migrations/index.js +3 -1
  34. package/dist-lib/lib/core/peer-duplex.d.ts +32 -0
  35. package/dist-lib/lib/core/peer-duplex.js +207 -0
  36. package/dist-lib/lib/core.d.ts +17 -1
  37. package/dist-lib/lib/core.js +183 -10
  38. package/dist-lib/lib/doctor/checks.js +4 -1
  39. package/dist-lib/lib/mesh-scoped-engine.js +3 -0
  40. package/dist-lib/lib/model-download.d.ts +0 -9
  41. package/dist-lib/lib/model-download.js +1 -13
  42. package/dist-lib/schema/engine.js +45 -1
  43. package/dist-lib/schema/field-order.js +1 -1
  44. package/dist-lib/schema/qvac.js +10 -1
  45. package/dist-lib/spec/bind.js +14 -0
  46. package/dist-lib/spec/calls.js +3 -0
  47. package/dist-lib/spec/capabilities.d.ts +6 -0
  48. package/dist-lib/spec/hrpc/hrpc.json +39 -0
  49. package/dist-lib/spec/hrpc/index.js +41 -4
  50. package/dist-lib/spec/hrpc/messages.js +1420 -1289
  51. package/dist-lib/spec/hyperschema/index.js +1420 -1289
  52. package/dist-lib/spec/hyperschema/schema.json +102 -0
  53. package/dist-lib/spec/hyperschema/types.d.ts +29 -0
  54. package/dist-lib/spec/mesh/hyperdb/messages.js +295 -248
  55. package/dist-lib/spec/mesh/hyperdispatch/messages.js +45 -5
  56. package/dist-lib/spec/mesh/hyperschema/index.js +45 -5
  57. package/dist-lib/spec/mesh/hyperschema/schema.json +31 -1
  58. package/dist-lib/spec/mesh/hyperschema/types.d.ts +9 -1
  59. package/package.json +9 -6
  60. package/tui/app.mjs +121 -67
  61. package/tui/lib/fork-command.mjs +43 -0
@@ -171,7 +171,10 @@ function mesh(samples, frame) {
171
171
  out.push(check('Mesh', 'indexer', indexer));
172
172
  }
173
173
  const configured = num(node['blindPeerCount']) ?? 0;
174
- if (configured > 0) {
174
+ if (node['blindPeering'] === false) {
175
+ out.push(check('Mesh', 'blind peers', declared('switched off on this device', 'setBlindPeering({ enabled: true }) turns it back on')));
176
+ }
177
+ else if (configured > 0) {
175
178
  out.push(check('Mesh', 'blind peers', blindPeerVerdict(configured, list(node['blindPeers']))));
176
179
  }
177
180
  const sweep = sweepVerdict(record(node['orphanedBlobSweep']));
@@ -14,6 +14,7 @@ export const MESH_SCOPED = new Set([
14
14
  'markChatRead',
15
15
  'setChatAgent',
16
16
  'moveChatToMesh',
17
+ 'forkChat',
17
18
  'chatMoveWatch',
18
19
  'setChatRagEnabled',
19
20
  'setChatWebSearchEnabled',
@@ -124,6 +125,8 @@ const DEVICE_LOCAL = new Set([
124
125
  'diagnostics',
125
126
  'diagnosticsWatch',
126
127
  'networkWatch',
128
+ 'setBlindPeering',
129
+ 'blindPeeringWatch',
127
130
  'meshStatusWatch',
128
131
  'listMeshes',
129
132
  'meshesWatch',
@@ -53,14 +53,6 @@ interface DownloadEngine {
53
53
  agentsWatch(request: {
54
54
  meshId: string;
55
55
  }): AsyncIterable<unknown>;
56
- listDevices(request: {
57
- meshId: string;
58
- }): Promise<{
59
- devices?: ReadonlyArray<{
60
- id: Buffer;
61
- capabilityProfile: string;
62
- }> | null;
63
- }>;
64
56
  getAgent(request: {
65
57
  agentId: string;
66
58
  meshId: string;
@@ -154,7 +146,6 @@ export declare class ModelDownloadReconciler {
154
146
  private _musicChoice;
155
147
  private _preemptLlm;
156
148
  private _pausedLocalLlm;
157
- private _profile;
158
149
  private _capability;
159
150
  private readonly _handled;
160
151
  private readonly _demands;
@@ -43,7 +43,6 @@ export class ModelDownloadReconciler {
43
43
  _musicChoice = undefined;
44
44
  _preemptLlm = null;
45
45
  _pausedLocalLlm = null;
46
- _profile = null;
47
46
  _capability = null;
48
47
  _handled = new Set();
49
48
  _demands = new Map();
@@ -664,18 +663,7 @@ export class ModelDownloadReconciler {
664
663
  return { cached, totals, addons };
665
664
  }
666
665
  async _deviceProfile() {
667
- if (this._profile)
668
- return this._profile;
669
- const meshId = this._meshId();
670
- if (!meshId) {
671
- return this._profile ?? 'mid';
672
- }
673
- const { devices } = await this._engine.listDevices({ meshId }).catch(() => ({ devices: [] }));
674
- const self = (devices ?? []).find((device) => b4a.equals(device.id, this._deviceId));
675
- if (self) {
676
- this._profile = self.capabilityProfile;
677
- }
678
- return this._profile ?? 'mid';
666
+ return (await this._hostCapability())?.capabilityProfile ?? 'low';
679
667
  }
680
668
  async _hostCapability() {
681
669
  if (this._capability)
@@ -193,6 +193,14 @@ export function registerEngineTypes(ns) {
193
193
  { name: 'config', type: '@assistant/agent-update-config', required: true }
194
194
  ]
195
195
  });
196
+ ns.register({
197
+ name: 'chat-fork-source',
198
+ fields: [
199
+ { name: 'meshId', type: 'string', required: true },
200
+ { name: 'chatId', type: 'string', required: true },
201
+ { name: 'runId', type: 'string' }
202
+ ]
203
+ });
196
204
  ns.register({
197
205
  name: 'chat',
198
206
  fields: [
@@ -206,7 +214,8 @@ export function registerEngineTypes(ns) {
206
214
  { name: 'updatedAt', type: 'uint' },
207
215
  { name: 'lastActivityAt', type: 'uint' },
208
216
  { name: 'groupId', type: 'string' },
209
- { name: 'readThrough', type: 'uint' }
217
+ { name: 'readThrough', type: 'uint' },
218
+ { name: 'forkedFrom', type: '@assistant/chat-fork-source' }
210
219
  ]
211
220
  });
212
221
  ns.register({
@@ -353,6 +362,22 @@ export function registerEngineTypes(ns) {
353
362
  { name: 'failure', type: 'string' }
354
363
  ]
355
364
  });
365
+ ns.register({
366
+ name: 'fork-chat-config',
367
+ fields: [{ name: 'title', type: 'string' }]
368
+ });
369
+ ns.register({
370
+ name: 'fork-chat-request',
371
+ fields: [
372
+ { name: 'chatId', type: 'string', required: true },
373
+ { name: 'meshId', type: 'string', required: true },
374
+ { name: 'runId', type: 'string' },
375
+ { name: 'exclusive', type: 'bool' },
376
+ { name: 'targetMeshId', type: 'string' },
377
+ { name: 'agentId', type: 'string' },
378
+ { name: 'config', type: '@assistant/fork-chat-config' }
379
+ ]
380
+ });
356
381
  ns.register({
357
382
  name: 'set-chat-agent-request',
358
383
  fields: [
@@ -922,6 +947,10 @@ export function registerEngineTypes(ns) {
922
947
  { name: 'peerCount', type: 'uint', required: true }
923
948
  ]
924
949
  });
950
+ ns.register({
951
+ name: 'blind-peering',
952
+ fields: [{ name: 'enabled', type: 'bool', required: true }]
953
+ });
925
954
  ns.register({
926
955
  name: 'sync-status-state',
927
956
  enum: ['idle', 'syncing', 'synced'],
@@ -2886,4 +2915,19 @@ export function registerEngineApi(api) {
2886
2915
  request: { name: '@assistant/set-auto-download-models-request', stream: false },
2887
2916
  response: { name: '@assistant/app-config', stream: false }
2888
2917
  });
2918
+ api.register({
2919
+ name: 'fork-chat',
2920
+ request: { name: '@assistant/fork-chat-request', stream: false },
2921
+ response: { name: '@assistant/chat', stream: false }
2922
+ });
2923
+ api.register({
2924
+ name: 'set-blind-peering',
2925
+ request: { name: '@assistant/blind-peering', stream: false },
2926
+ response: { name: '@assistant/blind-peering', stream: false }
2927
+ });
2928
+ api.register({
2929
+ name: 'blind-peering-watch',
2930
+ request: { name: '@assistant/empty', stream: false },
2931
+ response: { name: '@assistant/blind-peering', stream: true }
2932
+ });
2889
2933
  }
@@ -1,7 +1,7 @@
1
1
  import fs from 'bare-fs';
2
2
  import { spawnSync } from 'bare-subprocess';
3
3
  const EXEMPT = {
4
- '@qvac/seed-defaults-operation-v1.chat': 'seedableChat (lib/core/helpers/index.ts) allowlists the seed chat and leaves readThrough off it'
4
+ '@qvac/seed-defaults-operation-v1.chat': 'seedableChat (lib/core/helpers/index.ts) allowlists the seed chat and leaves readThrough and forkedFrom off it'
5
5
  };
6
6
  export function assertFieldOrder(root, schemaFile, tags) {
7
7
  const current = index(JSON.parse(fs.readFileSync(schemaFile, 'utf8')).schema);
@@ -184,6 +184,14 @@ export function registerQvacTypes(ns) {
184
184
  { name: 'disabledToolsets', type: 'string', array: true },
185
185
  { name: 'lenderDeviceId', type: 'fixed32' }
186
186
  ]);
187
+ ns.register({
188
+ name: 'chat-fork-source',
189
+ fields: [
190
+ { name: 'meshId', type: 'string', required: true },
191
+ { name: 'chatId', type: 'string', required: true },
192
+ { name: 'runId', type: 'string' }
193
+ ]
194
+ });
187
195
  versioned('chat', [
188
196
  { name: 'id', type: 'string', required: true },
189
197
  { name: 'agentId', type: 'string', required: true },
@@ -196,7 +204,8 @@ export function registerQvacTypes(ns) {
196
204
  { name: 'groupId', type: 'string' },
197
205
  { name: 'rank', type: 'float64' },
198
206
  { name: 'rankedAt', type: 'uint' },
199
- { name: 'readThrough', type: 'uint' }
207
+ { name: 'readThrough', type: 'uint' },
208
+ { name: 'forkedFrom', type: '@qvac/chat-fork-source' }
200
209
  ]);
201
210
  ns.register({
202
211
  name: 'tool-report-entry',
@@ -676,4 +676,18 @@ export function bindApi(rpc, api) {
676
676
  if (api.setAutoDownloadModels) {
677
677
  rpc.onSetAutoDownloadModels((req) => api.setAutoDownloadModels(req));
678
678
  }
679
+ if (api.forkChat) {
680
+ rpc.onForkChat((req) => api.forkChat(req));
681
+ }
682
+ if (api.setBlindPeering) {
683
+ rpc.onSetBlindPeering((req) => api.setBlindPeering(req));
684
+ }
685
+ if (api.blindPeeringWatch) {
686
+ rpc.onBlindPeeringWatch((out) => {
687
+ const src = Readable.from(api.blindPeeringWatch(out.data));
688
+ src.on("error", (err) => out.writeStream?.destroy(err));
689
+ pipeline(src, out, noop);
690
+ out.writeStream?.on("close", () => src.destroy());
691
+ });
692
+ }
679
693
  }
@@ -168,5 +168,8 @@ export function engineClient(rpc) {
168
168
  chatMoveWatch: (input) => armed(rpc.chatMoveWatch(input)),
169
169
  chunksDeltaWatch: (input) => armed(rpc.chunksDeltaWatch(input)),
170
170
  setAutoDownloadModels: (input) => rpc.setAutoDownloadModels(input),
171
+ forkChat: (input) => rpc.forkChat(input),
172
+ setBlindPeering: (input) => rpc.setBlindPeering(input),
173
+ blindPeeringWatch: (input) => armed(rpc.blindPeeringWatch(input ?? {})),
171
174
  };
172
175
  }
@@ -186,6 +186,9 @@ export interface Capabilities {
186
186
  chatMoveWatch(input: T.AssistantChatId): WatchStream<T.AssistantChatMove>
187
187
  chunksDeltaWatch(input: T.AssistantChunksByChatRequest): WatchStream<T.AssistantChunkDelta>
188
188
  setAutoDownloadModels(input: T.AssistantSetAutoDownloadModelsRequest): Promise<T.AssistantAppConfig>
189
+ forkChat(input: T.AssistantForkChatRequest): Promise<T.AssistantChat>
190
+ setBlindPeering(input: T.AssistantBlindPeering): Promise<T.AssistantBlindPeering>
191
+ blindPeeringWatch(input?: T.AssistantEmpty): WatchStream<T.AssistantBlindPeering>
189
192
  }
190
193
 
191
194
  export interface CapabilityHandlers {
@@ -347,4 +350,7 @@ export interface CapabilityHandlers {
347
350
  chatMoveWatch(input: T.AssistantChatId): AsyncIterable<T.AssistantChatMove>
348
351
  chunksDeltaWatch(input: T.AssistantChunksByChatRequest): AsyncIterable<T.AssistantChunkDelta>
349
352
  setAutoDownloadModels(input: T.AssistantSetAutoDownloadModelsRequest): T.AssistantAppConfig | Promise<T.AssistantAppConfig>
353
+ forkChat(input: T.AssistantForkChatRequest): T.AssistantChat | Promise<T.AssistantChat>
354
+ setBlindPeering(input: T.AssistantBlindPeering): T.AssistantBlindPeering | Promise<T.AssistantBlindPeering>
355
+ blindPeeringWatch(input?: T.AssistantEmpty): AsyncIterable<T.AssistantBlindPeering>
350
356
  }
@@ -2054,6 +2054,45 @@
2054
2054
  "stream": false
2055
2055
  },
2056
2056
  "version": 1
2057
+ },
2058
+ {
2059
+ "id": 158,
2060
+ "name": "@assistant/fork-chat",
2061
+ "request": {
2062
+ "name": "@assistant/fork-chat-request",
2063
+ "stream": false
2064
+ },
2065
+ "response": {
2066
+ "name": "@assistant/chat",
2067
+ "stream": false
2068
+ },
2069
+ "version": 1
2070
+ },
2071
+ {
2072
+ "id": 159,
2073
+ "name": "@assistant/set-blind-peering",
2074
+ "request": {
2075
+ "name": "@assistant/blind-peering",
2076
+ "stream": false
2077
+ },
2078
+ "response": {
2079
+ "name": "@assistant/blind-peering",
2080
+ "stream": false
2081
+ },
2082
+ "version": 1
2083
+ },
2084
+ {
2085
+ "id": 160,
2086
+ "name": "@assistant/blind-peering-watch",
2087
+ "request": {
2088
+ "name": "@assistant/empty",
2089
+ "stream": false
2090
+ },
2091
+ "response": {
2092
+ "name": "@assistant/blind-peering",
2093
+ "stream": true
2094
+ },
2095
+ "version": 1
2057
2096
  }
2058
2097
  ]
2059
2098
  }
@@ -321,7 +321,13 @@ const methods = new Map([
321
321
  ['@assistant/chunks-delta-watch', 156],
322
322
  [156, '@assistant/chunks-delta-watch'],
323
323
  ['@assistant/set-auto-download-models', 157],
324
- [157, '@assistant/set-auto-download-models']
324
+ [157, '@assistant/set-auto-download-models'],
325
+ ['@assistant/fork-chat', 158],
326
+ [158, '@assistant/fork-chat'],
327
+ ['@assistant/set-blind-peering', 159],
328
+ [159, '@assistant/set-blind-peering'],
329
+ ['@assistant/blind-peering-watch', 160],
330
+ [160, '@assistant/blind-peering-watch']
325
331
  ])
326
332
 
327
333
  class HRPC {
@@ -486,7 +492,10 @@ class HRPC {
486
492
  ['@assistant/move-chat-to-mesh', getEncoding('@assistant/move-chat-to-mesh-request')],
487
493
  ['@assistant/chat-move-watch', getEncoding('@assistant/chat-id')],
488
494
  ['@assistant/chunks-delta-watch', getEncoding('@assistant/chunks-by-chat-request')],
489
- ['@assistant/set-auto-download-models', getEncoding('@assistant/set-auto-download-models-request')]
495
+ ['@assistant/set-auto-download-models', getEncoding('@assistant/set-auto-download-models-request')],
496
+ ['@assistant/fork-chat', getEncoding('@assistant/fork-chat-request')],
497
+ ['@assistant/set-blind-peering', getEncoding('@assistant/blind-peering')],
498
+ ['@assistant/blind-peering-watch', getEncoding('@assistant/empty')]
490
499
  ])
491
500
  this._responseEncodings = new Map([
492
501
  ['@assistant/config-get', getEncoding('@assistant/config-value')],
@@ -646,7 +655,10 @@ class HRPC {
646
655
  ['@assistant/move-chat-to-mesh', getEncoding('@assistant/chat-move')],
647
656
  ['@assistant/chat-move-watch', getEncoding('@assistant/chat-move')],
648
657
  ['@assistant/chunks-delta-watch', getEncoding('@assistant/chunk-delta')],
649
- ['@assistant/set-auto-download-models', getEncoding('@assistant/app-config')]
658
+ ['@assistant/set-auto-download-models', getEncoding('@assistant/app-config')],
659
+ ['@assistant/fork-chat', getEncoding('@assistant/chat')],
660
+ ['@assistant/set-blind-peering', getEncoding('@assistant/blind-peering')],
661
+ ['@assistant/blind-peering-watch', getEncoding('@assistant/blind-peering')]
650
662
  ])
651
663
  this._rpc = new RPC(stream, async (req) => {
652
664
  const command = methods.get(req.command)
@@ -1376,6 +1388,18 @@ class HRPC {
1376
1388
  return this._call('@assistant/set-auto-download-models', args)
1377
1389
  }
1378
1390
 
1391
+ async forkChat(args) {
1392
+ return this._call('@assistant/fork-chat', args)
1393
+ }
1394
+
1395
+ async setBlindPeering(args) {
1396
+ return this._call('@assistant/set-blind-peering', args)
1397
+ }
1398
+
1399
+ blindPeeringWatch(args) {
1400
+ return this._callSync('@assistant/blind-peering-watch', args)
1401
+ }
1402
+
1379
1403
  onConfigGet(responseFn) {
1380
1404
  this._handlers['@assistant/config-get'] = responseFn
1381
1405
  }
@@ -2008,6 +2032,18 @@ class HRPC {
2008
2032
  this._handlers['@assistant/set-auto-download-models'] = responseFn
2009
2033
  }
2010
2034
 
2035
+ onForkChat(responseFn) {
2036
+ this._handlers['@assistant/fork-chat'] = responseFn
2037
+ }
2038
+
2039
+ onSetBlindPeering(responseFn) {
2040
+ this._handlers['@assistant/set-blind-peering'] = responseFn
2041
+ }
2042
+
2043
+ onBlindPeeringWatch(responseFn) {
2044
+ this._handlers['@assistant/blind-peering-watch'] = responseFn
2045
+ }
2046
+
2011
2047
  _requestIsStream(command) {
2012
2048
  return [
2013
2049
  '@assistant/upload-attachment',
@@ -2052,7 +2088,8 @@ class HRPC {
2052
2088
  '@assistant/members-watch',
2053
2089
  '@assistant/models-watch',
2054
2090
  '@assistant/chat-move-watch',
2055
- '@assistant/chunks-delta-watch'
2091
+ '@assistant/chunks-delta-watch',
2092
+ '@assistant/blind-peering-watch'
2056
2093
  ].includes(command)
2057
2094
  }
2058
2095