@qvac/core 1.0.0-rc.3 → 1.0.0-rc.6

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 (135) hide show
  1. package/CHANGELOG.md +147 -36
  2. package/README.md +55 -4
  3. package/dist-lib/index.d.ts +2 -1
  4. package/dist-lib/lib/api/agents.d.ts +2 -1
  5. package/dist-lib/lib/api/agents.js +5 -1
  6. package/dist-lib/lib/api/app-config.d.ts +3 -0
  7. package/dist-lib/lib/api/app-config.js +20 -0
  8. package/dist-lib/lib/api/approval-rules.d.ts +1 -1
  9. package/dist-lib/lib/api/approval-rules.js +5 -1
  10. package/dist-lib/lib/api/config.d.ts +6 -2
  11. package/dist-lib/lib/api/config.js +9 -5
  12. package/dist-lib/lib/api/device-routes.d.ts +1 -1
  13. package/dist-lib/lib/api/device-routes.js +3 -1
  14. package/dist-lib/lib/api/index.d.ts +12 -2
  15. package/dist-lib/lib/api/index.js +8 -2
  16. package/dist-lib/lib/api/projects.js +3 -4
  17. package/dist-lib/lib/api/rag.js +5 -5
  18. package/dist-lib/lib/api/served.d.ts +2 -2
  19. package/dist-lib/lib/api/served.js +24 -1
  20. package/dist-lib/lib/assistant/harness.d.ts +3 -0
  21. package/dist-lib/lib/assistant/history.js +14 -2
  22. package/dist-lib/lib/assistant/message.d.ts +1 -0
  23. package/dist-lib/lib/assistant/model-round.d.ts +3 -0
  24. package/dist-lib/lib/assistant/model-round.js +18 -4
  25. package/dist-lib/lib/assistant/round-host.d.ts +2 -0
  26. package/dist-lib/lib/assistant/round-host.js +8 -0
  27. package/dist-lib/lib/assistant-tree.d.ts +2 -0
  28. package/dist-lib/lib/assistant-tree.js +4 -2
  29. package/dist-lib/lib/assistant.d.ts +12 -1
  30. package/dist-lib/lib/assistant.js +131 -15
  31. package/dist-lib/lib/client.js +4 -1
  32. package/dist-lib/lib/core/agent-copies.js +9 -2
  33. package/dist-lib/lib/core/agent-hosting.js +9 -4
  34. package/dist-lib/lib/core/agent.js +3 -1
  35. package/dist-lib/lib/core/approval-rules.d.ts +5 -1
  36. package/dist-lib/lib/core/approval-rules.js +16 -1
  37. package/dist-lib/lib/core/chat-copy.d.ts +1 -0
  38. package/dist-lib/lib/core/chat-copy.js +13 -2
  39. package/dist-lib/lib/core/chat.d.ts +0 -1
  40. package/dist-lib/lib/core/chat.js +0 -3
  41. package/dist-lib/lib/core/chunk.js +4 -3
  42. package/dist-lib/lib/core/collections.d.ts +7 -7
  43. package/dist-lib/lib/core/collections.js +7 -7
  44. package/dist-lib/lib/core/config-value.d.ts +1 -0
  45. package/dist-lib/lib/core/config-value.js +1 -0
  46. package/dist-lib/lib/core/contract/project-device-keys.d.ts +4 -2
  47. package/dist-lib/lib/core/contract/project-device-keys.js +12 -12
  48. package/dist-lib/lib/core/contract/project-host-keys.d.ts +5 -3
  49. package/dist-lib/lib/core/contract/project-host-keys.js +22 -11
  50. package/dist-lib/lib/core/contract/projects.d.ts +4 -2
  51. package/dist-lib/lib/core/contract/projects.js +29 -17
  52. package/dist-lib/lib/core/contract/workspace.js +2 -2
  53. package/dist-lib/lib/core/deleted-agent-runs.d.ts +8 -0
  54. package/dist-lib/lib/core/deleted-agent-runs.js +57 -0
  55. package/dist-lib/lib/core/files/index.d.ts +1 -1
  56. package/dist-lib/lib/core/files/index.js +4 -2
  57. package/dist-lib/lib/core/helpers/index.d.ts +1 -1
  58. package/dist-lib/lib/core/helpers/index.js +2 -2
  59. package/dist-lib/lib/core/local/index.d.ts +6 -0
  60. package/dist-lib/lib/core/local/index.js +14 -0
  61. package/dist-lib/lib/core/mesh.d.ts +2 -1
  62. package/dist-lib/lib/core/mesh.js +7 -5
  63. package/dist-lib/lib/core/project-keys.d.ts +5 -2
  64. package/dist-lib/lib/core/project-keys.js +15 -6
  65. package/dist-lib/lib/core/skill-secrets.d.ts +3 -2
  66. package/dist-lib/lib/core/skill-secrets.js +4 -1
  67. package/dist-lib/lib/core/sync/index.js +18 -6
  68. package/dist-lib/lib/core/vault-managed-skills.d.ts +18 -0
  69. package/dist-lib/lib/core/vault-managed-skills.js +105 -0
  70. package/dist-lib/lib/core.d.ts +10 -1
  71. package/dist-lib/lib/core.js +165 -31
  72. package/dist-lib/lib/errors.d.ts +8 -0
  73. package/dist-lib/lib/errors.js +8 -0
  74. package/dist-lib/lib/kv-cache-ledger.d.ts +22 -0
  75. package/dist-lib/lib/kv-cache-ledger.js +72 -0
  76. package/dist-lib/lib/kv-cache-retention.d.ts +1 -0
  77. package/dist-lib/lib/kv-cache-retention.js +5 -2
  78. package/dist-lib/lib/mesh-scoped-engine.js +1 -0
  79. package/dist-lib/lib/model-memory-cap.d.ts +3 -0
  80. package/dist-lib/lib/model-memory-cap.js +15 -6
  81. package/dist-lib/lib/run-replay.d.ts +3 -2
  82. package/dist-lib/lib/run-replay.js +16 -5
  83. package/dist-lib/lib/run-transcript.js +1 -1
  84. package/dist-lib/schema/config.d.ts +1 -1
  85. package/dist-lib/schema/config.js +1 -1
  86. package/dist-lib/schema/engine.js +87 -2
  87. package/dist-lib/schema/qvac.js +66 -3
  88. package/dist-lib/spec/bind.js +15 -0
  89. package/dist-lib/spec/calls.js +5 -0
  90. package/dist-lib/spec/capabilities.d.ts +10 -0
  91. package/dist-lib/spec/config/hyperconf/index.js +1 -1
  92. package/dist-lib/spec/hrpc/hrpc.json +65 -0
  93. package/dist-lib/spec/hrpc/index.js +63 -3
  94. package/dist-lib/spec/hrpc/messages.js +1302 -993
  95. package/dist-lib/spec/hyperschema/index.js +1302 -993
  96. package/dist-lib/spec/hyperschema/schema.json +227 -0
  97. package/dist-lib/spec/hyperschema/types.d.ts +45 -0
  98. package/dist-lib/spec/mesh/hyperdb/db.json +110 -0
  99. package/dist-lib/spec/mesh/hyperdb/index.js +498 -2
  100. package/dist-lib/spec/mesh/hyperdb/messages.js +1385 -892
  101. package/dist-lib/spec/mesh/hyperdispatch/messages.js +561 -301
  102. package/dist-lib/spec/mesh/hyperschema/index.js +561 -301
  103. package/dist-lib/spec/mesh/hyperschema/schema.json +343 -178
  104. package/dist-lib/spec/mesh/hyperschema/types.d.ts +40 -1
  105. package/package.json +34 -18
  106. package/tui/README.md +190 -0
  107. package/tui/app.mjs +8247 -0
  108. package/tui/boot.mjs +159 -0
  109. package/tui/index.mjs +89 -0
  110. package/tui/lib/boot-timing.mjs +41 -0
  111. package/tui/lib/busy-words.mjs +116 -0
  112. package/tui/lib/connect-sheet.mjs +350 -0
  113. package/tui/lib/device-target.mjs +64 -0
  114. package/tui/lib/export.mjs +194 -0
  115. package/tui/lib/folders-command.mjs +84 -0
  116. package/tui/lib/fork-command.mjs +43 -0
  117. package/tui/lib/knowledge-command.mjs +190 -0
  118. package/tui/lib/knowledge-import.mjs +153 -0
  119. package/tui/lib/local-path.mjs +21 -0
  120. package/tui/lib/move-command.mjs +17 -0
  121. package/tui/lib/render.mjs +225 -0
  122. package/tui/lib/save-file.mjs +88 -0
  123. package/tui/lib/select.mjs +81 -0
  124. package/tui/lib/selection.mjs +18 -0
  125. package/tui/lib/setup.mjs +135 -0
  126. package/tui/lib/sidebar.mjs +63 -0
  127. package/tui/lib/skill-connect.mjs +145 -0
  128. package/tui/lib/splash-art.mjs +107 -0
  129. package/tui/lib/splash.mjs +18 -0
  130. package/tui/lib/upload-frames.mjs +9 -0
  131. package/tui/lib/usage.mjs +59 -0
  132. package/tui/lib/wrap.mjs +143 -0
  133. package/tui/main.mjs +279 -0
  134. package/tui/plugins.mjs +158 -0
  135. package/worker/assistant-sidecar.mjs +1 -0
@@ -38,12 +38,13 @@ import { persistentDir } from './persistent-dir.js';
38
38
  import { ModelCatalogRevisionHub } from './model-catalog-revision.js';
39
39
  import { agentRekeyFingerprint, agentSwitched, chatKvCacheKey, chatRepairKvCacheKey, disappearedChatIds } from './kv-cache-reclaim.js';
40
40
  import { KvCacheRetention } from './kv-cache-retention.js';
41
+ import { KvCacheLedger, orphanedChats } from './kv-cache-ledger.js';
41
42
  import { KV_CACHE_RETENTION_KEY } from './constants.js';
42
43
  import { buildCompactionPrompt, canCompact, foldReducesPrompt, COMPACTION_KEEP_TURNS, COMPACTION_TURN_PREFIX, isContextOverflowFailure, nearContextLimit, compactionBoundary, foldsThrough, lastCompactedThroughId, parseCompactionSummary } from './compaction.js';
43
44
  import { ModelDownloadReconciler, musicModelChoiceOf } from './model-download.js';
44
45
  import { AbortedError, raceAbort } from '@qvac/harness/race-abort';
45
46
  import { RunTranscript } from './run-transcript.js';
46
- import { OwnerRounds, listRoundChunks } from './assistant/model-round.js';
47
+ import { OwnerRounds, listRoundChunks, wholeImageId } from './assistant/model-round.js';
47
48
  import { RoundHost } from './assistant/round-host.js';
48
49
  import { searchKnowledge } from './knowledge-search.js';
49
50
  import { isLifecycleTeardown, knownAbortOutcome, RUN_ABORT_REASONS, RUN_FAILURE_REASONS, runFailureNotice } from './run-notices.js';
@@ -289,6 +290,7 @@ export class QvacAssistant extends ReadyResource {
289
290
  _reconciling;
290
291
  _onlineBoot = new ReadyGuard();
291
292
  _accountSeen = Promise.withResolvers();
293
+ _meshesSeen = Promise.withResolvers();
292
294
  _capability;
293
295
  _downloads;
294
296
  _state;
@@ -315,6 +317,8 @@ export class QvacAssistant extends ReadyResource {
315
317
  _runReplay;
316
318
  _roundHost;
317
319
  _kvRetention;
320
+ _kvLedger;
321
+ _orphanSweep = Promise.resolve();
318
322
  _lifecycle;
319
323
  _suggesting = new Map();
320
324
  _audioTranscripts;
@@ -329,7 +333,7 @@ export class QvacAssistant extends ReadyResource {
329
333
  _modelCatalog = new ModelCatalogRevisionHub();
330
334
  _onHarnessStatus;
331
335
  _onModelCatalogEvent;
332
- constructor(engine, harness, { logger = null, imageCacheDir, inferenceCallsDir, runReplayDir, imageCacheMaxBytes, imageCacheMaxAgeMs, kvCacheRetentionMs, downloadRetryMs, platform = os.platform(), preloadCurrentAgentModel = true, drives, blobReadTimeoutMs = BLOB_READ_TIMEOUT_MS, runIdleTimeoutMs = RUN_IDLE_TIMEOUT_MS, modelReloadDelayMs = MODEL_RELOAD_DELAY_MS, pdfRasterizer: pdfRasterizerOption } = {}) {
336
+ constructor(engine, harness, { logger = null, imageCacheDir, inferenceCallsDir, runReplayDir, kvCacheChatsDir, imageCacheMaxBytes, imageCacheMaxAgeMs, kvCacheRetentionMs, downloadRetryMs, platform = os.platform(), preloadCurrentAgentModel = true, drives, blobReadTimeoutMs = BLOB_READ_TIMEOUT_MS, runIdleTimeoutMs = RUN_IDLE_TIMEOUT_MS, modelReloadDelayMs = MODEL_RELOAD_DELAY_MS, pdfRasterizer: pdfRasterizerOption } = {}) {
333
337
  super();
334
338
  this._engine = engine;
335
339
  this._harness = harness;
@@ -356,6 +360,7 @@ export class QvacAssistant extends ReadyResource {
356
360
  resolve: (sources, served) => this._servedMedia(sources, served),
357
361
  release: (id) => this._runImageCacheNames.delete(`round:${id}`)
358
362
  },
363
+ built: (meshId, chatId) => this._recordKvCache(meshId, chatId),
359
364
  log: logger
360
365
  })
361
366
  : null;
@@ -382,9 +387,10 @@ export class QvacAssistant extends ReadyResource {
382
387
  this._backgroundReplays = new Set();
383
388
  this._inferenceCalls = new InferenceCallStore(inferenceCallsDir ?? persistentDir('inspector'));
384
389
  this._runReplay = new RunReplayStore(runReplayDir ?? persistentDir('run-replay'));
390
+ this._kvLedger = new KvCacheLedger(kvCacheChatsDir ?? persistentDir('kv-cache-chats'));
385
391
  this._kvRetention = new KvCacheRetention(engine, {
386
392
  active: () => !this.closing && !this.suspended,
387
- running: (chatId) => [...this._runs.values()].some((run) => run.chatId === chatId),
393
+ running: (chatId) => this._kvCacheInUse(chatId),
388
394
  deleteChatKvCache: (chatId) => this._deleteChatKvCache(chatId, 'idle past retention'),
389
395
  defaultMs: kvCacheRetentionMs,
390
396
  logger
@@ -542,6 +548,8 @@ export class QvacAssistant extends ReadyResource {
542
548
  finally {
543
549
  this._onlineBoot.exit();
544
550
  }
551
+ await this._meshesSeen.promise;
552
+ await this._reclaimOrphanedKvCaches();
545
553
  }
546
554
  async onlineReady() {
547
555
  if (!this.opened)
@@ -1108,6 +1116,11 @@ export class QvacAssistant extends ReadyResource {
1108
1116
  }));
1109
1117
  return perAgent.flat();
1110
1118
  }
1119
+ async _runModel(agent, deviceId) {
1120
+ if (!b4a.equals(agent.providerDeviceId, deviceId))
1121
+ return agent.modelName;
1122
+ return runnableModelName(agent.modelName, await this._runnableHost());
1123
+ }
1111
1124
  async _runnableHost() {
1112
1125
  const capability = await this._ensureCapability();
1113
1126
  return capability && { ...capability, mobile: this._mobileClass };
@@ -1348,6 +1361,7 @@ export class QvacAssistant extends ReadyResource {
1348
1361
  };
1349
1362
  if (result.status === 'success') {
1350
1363
  await this._runReplay.forget(chatId, { holder: LOCAL_HOLDER, reason });
1364
+ await this._kvLedger.forget(chatId);
1351
1365
  }
1352
1366
  return result;
1353
1367
  }
@@ -1355,9 +1369,65 @@ export class QvacAssistant extends ReadyResource {
1355
1369
  const result = await harnessClearKvCache(this._harness)();
1356
1370
  if (result.status === 'success') {
1357
1371
  await this._runReplay.clear(LOCAL_HOLDER);
1372
+ await this._kvLedger.clear();
1358
1373
  }
1359
1374
  return result;
1360
1375
  }
1376
+ _recordKvCache(meshId, chatId) {
1377
+ const served = this._listed.some((mesh) => mesh.meshId === meshId && mesh.served);
1378
+ void this._kvLedger
1379
+ .record({ meshId, chatId, served })
1380
+ .catch((err) => this._log?.warn('assistant', 'kv-cache chat not recorded', { chatId, err }));
1381
+ }
1382
+ _reclaimOrphanedKvCaches(gone = new Set()) {
1383
+ this._orphanSweep = this._orphanSweep
1384
+ .then(() => this._sweepOrphanedKvCaches(gone))
1385
+ .catch((err) => this._log?.warn('assistant', 'orphaned kv-cache sweep failed', { err }));
1386
+ return this._orphanSweep;
1387
+ }
1388
+ async _sweepOrphanedKvCaches(gone) {
1389
+ if (this.closing || this.suspended)
1390
+ return;
1391
+ if ((await this._kvRetention.retentionMs()) === null)
1392
+ return;
1393
+ const entries = await this._kvLedger.entries();
1394
+ if (entries.length === 0) {
1395
+ return;
1396
+ }
1397
+ for (const chatId of orphanedChats(entries, { ...(await this._knownChats()), gone })) {
1398
+ if (this.closing || this.suspended)
1399
+ return;
1400
+ if (!this._kvCacheInUse(chatId)) {
1401
+ await this._deleteChatKvCache(chatId, 'no mesh lists the chat');
1402
+ }
1403
+ }
1404
+ }
1405
+ async _knownChats() {
1406
+ const live = new Set();
1407
+ const read = new Set();
1408
+ const closed = new Set();
1409
+ for (const mesh of this._listed) {
1410
+ if (mesh.meshId === this._ownWorkspace)
1411
+ continue;
1412
+ if (!mesh.open) {
1413
+ closed.add(mesh.meshId);
1414
+ continue;
1415
+ }
1416
+ const { chats } = await this._engine.listChats({ meshId: mesh.meshId });
1417
+ read.add(mesh.meshId);
1418
+ for (const chat of chats ?? []) {
1419
+ live.add(chat.id);
1420
+ }
1421
+ }
1422
+ return { live, read, closed };
1423
+ }
1424
+ _kvCacheInUse(chatId) {
1425
+ for (const run of this._runs.values()) {
1426
+ if (run.chatId === chatId)
1427
+ return true;
1428
+ }
1429
+ return this._roundHost?.holds(chatId) ?? false;
1430
+ }
1361
1431
  async _clearPreReplayCaches() {
1362
1432
  if (await this._runReplay.started())
1363
1433
  return;
@@ -1448,10 +1518,22 @@ export class QvacAssistant extends ReadyResource {
1448
1518
  }
1449
1519
  async _watchMeshList() {
1450
1520
  this._meshList = this._engine.meshesWatch({});
1451
- for await (const { meshes } of this._meshList) {
1452
- if (this.closing || this.suspended)
1453
- return;
1454
- this._syncMeshConsumers(meshes ?? []);
1521
+ try {
1522
+ for await (const { meshes } of this._meshList) {
1523
+ if (this.closing || this.suspended)
1524
+ return;
1525
+ const before = this._listed;
1526
+ this._syncMeshConsumers(meshes ?? []);
1527
+ this._meshesSeen.resolve();
1528
+ const listed = new Set(this._listed.map((mesh) => mesh.meshId));
1529
+ const gone = new Set(before.filter((mesh) => !listed.has(mesh.meshId)).map((mesh) => mesh.meshId));
1530
+ if (gone.size > 0) {
1531
+ void this._reclaimOrphanedKvCaches(gone);
1532
+ }
1533
+ }
1534
+ }
1535
+ finally {
1536
+ this._meshesSeen.resolve();
1455
1537
  }
1456
1538
  }
1457
1539
  async _watchAccount() {
@@ -1882,7 +1964,8 @@ export class QvacAssistant extends ReadyResource {
1882
1964
  await this._deleteChatKvCache(chatId, 'superseding run');
1883
1965
  }
1884
1966
  }
1885
- const model = runnableModelName(agent.modelName, await this._runnableHost());
1967
+ const servedElsewhere = !b4a.equals(agent.providerDeviceId, deviceId);
1968
+ const model = await this._runModel(agent, deviceId);
1886
1969
  if (model !== agent.modelName) {
1887
1970
  this._log?.warn('runs', 'model clamped to what this device can run', {
1888
1971
  runId,
@@ -1920,6 +2003,7 @@ export class QvacAssistant extends ReadyResource {
1920
2003
  media: (file) => this._mediaRefs.get(path.basename(file)),
1921
2004
  inspect: (call) => void this._inspectRound(chatId, { runId, at: Date.now(), call })
1922
2005
  });
2006
+ await rounds.retire();
1923
2007
  const folded = !resumed &&
1924
2008
  (await this._compactIfNearFull({
1925
2009
  chatId,
@@ -2024,11 +2108,13 @@ export class QvacAssistant extends ReadyResource {
2024
2108
  held.status.then(({ id }) => transcript.progress(id, runStatus)).catch(noop);
2025
2109
  };
2026
2110
  try {
2027
- await this._downloads?.waitUntilCached(model, controller.signal, {
2028
- onHold: () => showWait({ phase: 'awaiting-download', model }),
2029
- onProgress: (percentage) => showWait(downloadingProgress(model, percentage)),
2030
- onStall: () => showWait(null)
2031
- });
2111
+ if (!servedElsewhere) {
2112
+ await this._downloads?.waitUntilCached(model, controller.signal, {
2113
+ onHold: () => showWait({ phase: 'awaiting-download', model }),
2114
+ onProgress: (percentage) => showWait(downloadingProgress(model, percentage)),
2115
+ onStall: () => showWait(null)
2116
+ });
2117
+ }
2032
2118
  }
2033
2119
  catch (err) {
2034
2120
  readinessError = err instanceof Error ? err : new Error(String(err));
@@ -2317,7 +2403,10 @@ export class QvacAssistant extends ReadyResource {
2317
2403
  const cacheKey = diagramRepair || stale.runIds.size > 0
2318
2404
  ? undefined
2319
2405
  : chatRepairKvCacheKey(chatId, acceptedRepairs);
2320
- sentRun = trackSentRun(cacheKey);
2406
+ sentRun = trackSentRun(cacheKey, (file) => wholeImageId(this._mediaRefs.get(path.basename(file))));
2407
+ if (cacheKey) {
2408
+ this._recordKvCache(meshId, chatId);
2409
+ }
2321
2410
  const unloading = this._unloading.get(model);
2322
2411
  if (unloading) {
2323
2412
  await raceAbort(unloading.catch(noop), controller.signal);
@@ -2368,6 +2457,7 @@ export class QvacAssistant extends ReadyResource {
2368
2457
  approve: idle.parks(approvals.approve),
2369
2458
  attach: (input) => this._uploadGenerated(input, { meshId, chatId, runId, deviceId }),
2370
2459
  fetchAttachment: (query) => this._fetchAttachment(engine, chatId, query),
2460
+ showImage: ({ attachmentId }) => this._showImage(engine, { chatId, runId, model, signal: controller.signal }, attachmentId),
2371
2461
  progress: (update) => {
2372
2462
  idle.touch();
2373
2463
  modelWatch.image(update);
@@ -3133,6 +3223,31 @@ export class QvacAssistant extends ReadyResource {
3133
3223
  }
3134
3224
  return unreadable;
3135
3225
  }
3226
+ async _showImage(engine, { chatId, runId, model, signal }, attachmentId) {
3227
+ const { chunks } = await engine.listChunks({ chatId, type: 'attachment' });
3228
+ const image = (chunks ?? []).find((chunk) => !chunk.sourceId && chunk.attachment?.id === attachmentId)?.attachment;
3229
+ if (!image || image.deletedAt || !IMAGE_MIMES.has(image.mimeType.toLowerCase())) {
3230
+ return null;
3231
+ }
3232
+ if (!(await this._seesImages(model))) {
3233
+ return null;
3234
+ }
3235
+ const pinned = this._runImageCacheNames.get(runId) ?? new Set();
3236
+ this._runImageCacheNames.set(runId, pinned);
3237
+ pinned.add(imageCacheName(image));
3238
+ const dir = this._imageCacheDir;
3239
+ await fs.promises.mkdir(dir, { recursive: true, mode: 0o700 });
3240
+ try {
3241
+ return await this._hydrateImage(dir, image, signal);
3242
+ }
3243
+ catch (err) {
3244
+ if (signal.aborted) {
3245
+ throw err;
3246
+ }
3247
+ this._log?.error('assistant', `image hydration failed — not shown ${image.fileName}`, err);
3248
+ return null;
3249
+ }
3250
+ }
3136
3251
  async _hydrateTurnImages(turn, { dir, signal }) {
3137
3252
  const dropped = [];
3138
3253
  for (const image of turn.images ?? []) {
@@ -3482,7 +3597,7 @@ export class QvacAssistant extends ReadyResource {
3482
3597
  if (!agent || !(options.run || b4a.equals(agent.providerDeviceId, deviceId))) {
3483
3598
  return { compacted: false, reason: 'not the provider device' };
3484
3599
  }
3485
- const model = runnableModelName(agent.modelName, await this._runnableHost());
3600
+ const model = await this._runModel(agent, deviceId);
3486
3601
  const config = await engine.getConfig({}).catch(noop);
3487
3602
  const ctxSize = agent.ctxSize || config?.ctxSize || undefined;
3488
3603
  if (ctxSize !== undefined && !canCompact(ctxSize)) {
@@ -3861,6 +3976,7 @@ export class QvacAssistant extends ReadyResource {
3861
3976
  toolName: call.name,
3862
3977
  resource: call.resource,
3863
3978
  agentId,
3979
+ chatId,
3864
3980
  memberId: ourMemberId
3865
3981
  });
3866
3982
  if (rule) {
@@ -23,7 +23,10 @@ export class Client extends ReadyResource {
23
23
  this._stream = await this._transport();
24
24
  const { bindApi, engineClient, HRPC } = await this._spec();
25
25
  const rpc = settleOnClose(new HRPC(this._stream));
26
- const declined = { storeIdentityPhrase: () => ({ ok: false }) };
26
+ const declined = {
27
+ storeIdentityPhrase: () => ({ ok: false }),
28
+ skillOauth: () => ({ phase: 'unavailable' })
29
+ };
27
30
  bindApi(rpc, { ...declined, ...this._handlers });
28
31
  const capabilities = engineClient(rpc);
29
32
  const modelDownloadsWatch = this._reconnecting(capabilities.modelDownloadsWatch, 'model-download');
@@ -1,4 +1,5 @@
1
- import { cancelRunsForAgent, softDeleteChatsForAgent } from './chat.js';
1
+ import { softDeleteChatsForAgent } from './chat.js';
2
+ import { cancelRunsForAgent } from './deleted-agent-runs.js';
2
3
  import { stripped } from './chat-copy.js';
3
4
  import { AGENTS } from './collections.js';
4
5
  async function putNewer(account, into, { id, copy }) {
@@ -23,9 +24,15 @@ export async function followAgentCopies(account, into, { deviceId, agentId }) {
23
24
  if (!copy || into.closing)
24
25
  continue;
25
26
  const agent = await putNewer(account, into, { id: copy.id, copy });
26
- if (agent?.deletedAt && !copy.deletedAt) {
27
+ if (!agent?.deletedAt || copy.deletedAt) {
28
+ continue;
29
+ }
30
+ if (agent.chatRetention === 'delete') {
27
31
  await softDeleteChatsForAgent(into, deviceId, agent.id);
28
32
  }
33
+ else if (deviceId) {
34
+ await cancelRunsForAgent(into, deviceId, agent.id);
35
+ }
29
36
  }
30
37
  }
31
38
  export async function keepCopyChats(into, agent, deviceId) {
@@ -1,10 +1,11 @@
1
1
  import b4a from 'b4a';
2
2
  import crypto from 'hypercore-crypto';
3
- import { readProjectHostKey } from './contract/project-host-keys.js';
3
+ import { projectHostKeys } from './contract/project-host-keys.js';
4
4
  import { listedProject, readProject } from './contract/projects.js';
5
5
  import { liveAgentsOn, readPublicSeed } from './contract/public-seeds.js';
6
6
  import { signWriterClaim } from './device-attestation.js';
7
7
  import { openSealedToDevice } from './device-seal.js';
8
+ import { seedOpens } from './project-keys.js';
8
9
  import { isRecord } from '../guards.js';
9
10
  import { AGENT_HOSTS, AGENT_USERS, AGENTS } from './collections.js';
10
11
  export function agentJoin(mesh, { device, writerKey, agentId, at }) {
@@ -25,9 +26,13 @@ async function targetOf(workspace, { userId, project }, device) {
25
26
  if (!row || row.deletedAt || (ours && listedProject(row, ours))) {
26
27
  return null;
27
28
  }
28
- const sealed = await readProjectHostKey(workspace.view, row.id, device.publicKey);
29
- const seed = sealed && openSealedToDevice(sealed.sealedSeed, device);
30
- return seed && { meshKey: row.id, seed, role: 'project' };
29
+ for (const sealed of await projectHostKeys(workspace.view, row.id, device.publicKey)) {
30
+ const seed = openSealedToDevice(sealed.sealedSeed, device);
31
+ if (seed && seedOpens(row, seed)) {
32
+ return { meshKey: row.id, seed, role: 'project' };
33
+ }
34
+ }
35
+ return null;
31
36
  }
32
37
  if (!ours || b4a.equals(userId, ours)) {
33
38
  return null;
@@ -1,4 +1,5 @@
1
- import { cancelRunsForAgent, softDeleteChatsForAgent } from './chat.js';
1
+ import { softDeleteChatsForAgent } from './chat.js';
2
+ import { cancelRunsForAgent } from './deleted-agent-runs.js';
2
3
  import { randomId } from './id.js';
3
4
  import { softDeleteToolConfigsForAgent } from './tool-configs.js';
4
5
  import b4a from 'b4a';
@@ -212,6 +213,7 @@ export async function deleteAgent(store, deviceId, { id, keepChats, keepCopies }
212
213
  const updated = {
213
214
  ...current,
214
215
  deletedAt,
216
+ chatRetention: keepChats ? 'retain' : 'delete',
215
217
  updatedAt: Math.max(deletedAt, current.updatedAt + 1)
216
218
  };
217
219
  if (keepChats) {
@@ -4,13 +4,17 @@ export interface ResourceDescriptor {
4
4
  kind: string;
5
5
  label: string;
6
6
  }
7
- type PutApprovalRuleInput = Pick<QvacApprovalRule, 'toolName' | 'resourceKind' | 'resourcePattern' | 'decision' | 'expiresAt' | 'agentId' | 'effect'>;
7
+ type PutApprovalRuleInput = Pick<QvacApprovalRule, 'toolName' | 'resourceKind' | 'resourcePattern' | 'decision' | 'expiresAt' | 'agentId' | 'effect' | 'chatId'> & {
8
+ readonly id?: string;
9
+ };
8
10
  export declare function listApprovalRules(store: Mesh): Promise<QvacApprovalRule[]>;
9
11
  export declare function putApprovalRule(store: Mesh, input: PutApprovalRuleInput): Promise<QvacApprovalRule>;
12
+ export declare function removeApprovalRule(store: Mesh, id: string): Promise<void>;
10
13
  export interface ApprovalRuleQuery {
11
14
  readonly toolName: string;
12
15
  readonly resource?: ResourceDescriptor | null;
13
16
  readonly agentId?: string;
17
+ readonly chatId?: string;
14
18
  readonly memberId?: Buffer | null;
15
19
  }
16
20
  export declare function matchApprovalRule(rules: ReadonlyArray<QvacApprovalRule>, input: ApprovalRuleQuery, now?: number): QvacApprovalRule | null;
@@ -1,6 +1,7 @@
1
1
  import { randomId } from './id.js';
2
2
  import b4a from 'b4a';
3
3
  import { APPROVAL_RULES } from './collections.js';
4
+ import { CoreError } from '../errors.js';
4
5
  export async function listApprovalRules(store) {
5
6
  const snap = store.view.snapshot();
6
7
  try {
@@ -13,10 +14,21 @@ export async function listApprovalRules(store) {
13
14
  }
14
15
  export async function putApprovalRule(store, input) {
15
16
  const now = Date.now();
16
- const rule = { ...input, id: randomId(), createdAt: now, updatedAt: now };
17
+ const rule = { id: randomId(), ...input, createdAt: now, updatedAt: now };
17
18
  await store.dispatch('put-approval-rule', { rule });
18
19
  return rule;
19
20
  }
21
+ export async function removeApprovalRule(store, id) {
22
+ const rule = await store.view.get(APPROVAL_RULES, { id });
23
+ const ours = !!rule?.memberId && !!store.ourMemberId && b4a.equals(rule.memberId, store.ourMemberId);
24
+ if (!rule || !ours) {
25
+ throw new CoreError('APPROVAL_RULE_NOT_FOUND', [id]);
26
+ }
27
+ const now = Date.now();
28
+ await store.dispatch('put-approval-rule', {
29
+ rule: { ...rule, expiresAt: now, updatedAt: Math.max(now, rule.updatedAt + 1) }
30
+ });
31
+ }
20
32
  export function matchApprovalRule(rules, input, now = Date.now()) {
21
33
  for (const rule of rules) {
22
34
  if (!input.memberId || !rule.memberId || !b4a.equals(rule.memberId, input.memberId)) {
@@ -30,6 +42,9 @@ export function matchApprovalRule(rules, input, now = Date.now()) {
30
42
  if (rule.agentId && rule.agentId !== input.agentId) {
31
43
  continue;
32
44
  }
45
+ if (rule.chatId && rule.chatId !== input.chatId) {
46
+ continue;
47
+ }
33
48
  if (!matchesResource(rule, input.resource ?? null)) {
34
49
  continue;
35
50
  }
@@ -36,6 +36,7 @@ export interface ContentCopy extends MeshCopy {
36
36
  readonly deviceId: Buffer;
37
37
  readonly chats?: ReadonlySet<string>;
38
38
  readonly unlinkProjects?: boolean;
39
+ readonly endsOpenRuns?: boolean;
39
40
  }
40
41
  export declare function copyContent(copy: ContentCopy): Promise<void>;
41
42
  export declare const UPGRADED_RUN_REASON = "the app was updated before this was answered, send it again";
@@ -266,7 +266,7 @@ async function copyChatChunks(snap, chatId, copy) {
266
266
  const { into } = copy;
267
267
  const batch = into.batch();
268
268
  const chunks = await chunksOf(snap, chatId);
269
- const open = copy.chats ? runsOf(chunks).open : new Set();
269
+ const open = copy.endsOpenRuns ? runsOf(chunks).open : new Set();
270
270
  for (const chunk of chunks) {
271
271
  const held = await into.view.get(CHUNKS, { id: chunk.id });
272
272
  if (held) {
@@ -275,7 +275,8 @@ async function copyChatChunks(snap, chatId, copy) {
275
275
  continue;
276
276
  }
277
277
  const { seq, updatedAt, attachment, runnerDeviceId, ...rest } = stripped(chunk);
278
- const op = copy.chats ? { ...rest, senderMemberId: await senderOf(snap, chunk) } : rest;
278
+ const sent = copy.chats ? { ...rest, senderMemberId: await senderOf(snap, chunk) } : rest;
279
+ const op = deniedWhileOpen(sent, open);
279
280
  if (!attachment) {
280
281
  batch.dispatch('append-chunk', op);
281
282
  if (chunk.type === 'run-request' && chunk.runId && open.has(chunk.runId)) {
@@ -295,6 +296,16 @@ async function copyChatChunks(snap, chatId, copy) {
295
296
  }
296
297
  await batch.flush();
297
298
  }
299
+ function deniedWhileOpen(op, open) {
300
+ const ask = op.approvalRequest;
301
+ if (op.type !== 'approval-request' ||
302
+ ask?.status !== 'pending' ||
303
+ !op.runId ||
304
+ !open.has(op.runId)) {
305
+ return op;
306
+ }
307
+ return { ...op, approvalRequest: { ...ask, status: 'denied' } };
308
+ }
298
309
  export const UPGRADED_RUN_REASON = 'the app was updated before this was answered, send it again';
299
310
  async function endUpgradedRun(request, copy, batch) {
300
311
  await appendChunk(copy.into, {
@@ -75,4 +75,3 @@ export declare function removeChatAttachments(store: Mesh, chatId: string, { dev
75
75
  export declare function deleteChat(store: Mesh, deviceId: Buffer | null, id: string): Promise<ChatListing>;
76
76
  export declare function softDeleteChatsForAgent(store: Mesh, deviceId: Buffer | null, agentId: string): Promise<void>;
77
77
  export declare const AGENT_DELETED = "agent-deleted";
78
- export declare function cancelRunsForAgent(store: Mesh, deviceId: Buffer, agentId: string): Promise<void>;
@@ -358,9 +358,6 @@ export function softDeleteChatsForAgent(store, deviceId, agentId) {
358
358
  return eachChatOfAgent(store, agentId, (chatId) => deleteChat(store, deviceId, chatId));
359
359
  }
360
360
  export const AGENT_DELETED = 'agent-deleted';
361
- export function cancelRunsForAgent(store, deviceId, agentId) {
362
- return eachChatOfAgent(store, agentId, (chatId) => cancelActiveRuns(store, chatId, { deviceId, agentId, reason: AGENT_DELETED }));
363
- }
364
361
  async function eachChatOfAgent(store, agentId, fn) {
365
362
  const snap = store.view.snapshot();
366
363
  try {
@@ -388,7 +388,6 @@ export function updateOp(chunk, { id, runStatus, attachment }) {
388
388
  'a run-status edits runStatus, an attachment edits attachment'
389
389
  ]);
390
390
  }
391
- const DEFAULT_APPROVAL_RULE_TTL_MS = 60 * 60 * 1000;
392
391
  export async function othersApproval(store, id) {
393
392
  const ask = await getChunk(store, id);
394
393
  return !!ask && (await projectRun(store)) && !(await ownedByUs(store, ask));
@@ -402,13 +401,15 @@ export async function resolveApproval(store, { id, approved, scope, expiresAt, a
402
401
  const ask = resolved.approvalRequest;
403
402
  if (ask && (ask.status === 'approved' || ask.status === 'denied')) {
404
403
  await putApprovalRule(rules, {
404
+ id,
405
405
  toolName: ask.name,
406
406
  resourceKind: ask.resource?.kind ?? undefined,
407
407
  resourcePattern: ask.resource?.label ?? undefined,
408
408
  decision: ask.status === 'approved' ? 'allow' : 'deny',
409
- expiresAt: expiresAt ?? Date.now() + DEFAULT_APPROVAL_RULE_TTL_MS,
409
+ expiresAt,
410
410
  agentId: ask.agentId ?? agentId,
411
- effect: resolved.effect ?? undefined
411
+ effect: resolved.effect ?? undefined,
412
+ chatId: resolved.chatId
412
413
  });
413
414
  }
414
415
  }
@@ -74,11 +74,11 @@ export declare const DEVICES_BY_MEMBER = "@qvac/devices-by-member";
74
74
  export declare const AGENT_HOSTS_BY_AGENT = "@qvac/agent-hosts-by-agent";
75
75
  export declare const AGENT_HOSTS_BY_DEVICE = "@qvac/agent-hosts-by-device";
76
76
  export declare const PUBLIC_SEEDS_BY_DEVICE = "@qvac/public-seeds-by-device";
77
- export declare const PROJECT_HOST_KEYS_BY_DEVICE = "@qvac/project-host-keys-by-device";
78
- export declare const PROJECT_DEVICE_KEYS_BY_DEVICE = "@qvac/project-device-keys-by-device";
79
- export declare const PROJECT_DEVICE_KEYS_BY_MEMBER = "@qvac/project-device-keys-by-member";
77
+ export declare const PROJECT_HOST_SEALS_BY_DEVICE = "@qvac/project-host-seals-by-device";
78
+ export declare const PROJECT_DEVICE_SEALS_BY_DEVICE = "@qvac/project-device-seals-by-device";
79
+ export declare const PROJECT_DEVICE_SEALS_BY_MEMBER = "@qvac/project-device-seals-by-member";
80
80
  export declare const AGENT_USERS_BY_USER = "@qvac/agent-users-by-user";
81
- export declare const PROJECT_KEYS_BY_MEMBER = "@qvac/project-keys-by-member";
81
+ export declare const PROJECT_MEMBER_SEALS_BY_MEMBER = "@qvac/project-member-seals-by-member";
82
82
  export declare const TERMINAL_RUN_STATUSES = "@qvac/terminal-run-statuses";
83
83
  export declare const MEMBER_REMOVALS = "@qvac/member-removals";
84
84
  export declare const INVITE_SEQUENCES = "@qvac/invite-sequences";
@@ -103,7 +103,7 @@ export declare const LIVE_MODEL_REQUESTS = "@qvac/live-model-requests";
103
103
  export declare const AGENT_HOSTS = "@qvac/agent-hosts";
104
104
  export declare const AGENT_USERS = "@qvac/agent-users";
105
105
  export declare const MEMBER_KEYS = "@qvac/member-keys";
106
- export declare const PROJECT_KEYS = "@qvac/project-keys";
107
- export declare const PROJECT_HOST_KEYS = "@qvac/project-host-keys";
108
- export declare const PROJECT_DEVICE_KEYS = "@qvac/project-device-keys";
106
+ export declare const PROJECT_MEMBER_SEALS = "@qvac/project-member-seals";
107
+ export declare const PROJECT_HOST_SEALS = "@qvac/project-host-seals";
108
+ export declare const PROJECT_DEVICE_SEALS = "@qvac/project-device-seals";
109
109
  export declare const SKILL_SECRETS = "@qvac/skill-secrets";
@@ -74,11 +74,11 @@ export const DEVICES_BY_MEMBER = '@qvac/devices-by-member';
74
74
  export const AGENT_HOSTS_BY_AGENT = '@qvac/agent-hosts-by-agent';
75
75
  export const AGENT_HOSTS_BY_DEVICE = '@qvac/agent-hosts-by-device';
76
76
  export const PUBLIC_SEEDS_BY_DEVICE = '@qvac/public-seeds-by-device';
77
- export const PROJECT_HOST_KEYS_BY_DEVICE = '@qvac/project-host-keys-by-device';
78
- export const PROJECT_DEVICE_KEYS_BY_DEVICE = '@qvac/project-device-keys-by-device';
79
- export const PROJECT_DEVICE_KEYS_BY_MEMBER = '@qvac/project-device-keys-by-member';
77
+ export const PROJECT_HOST_SEALS_BY_DEVICE = '@qvac/project-host-seals-by-device';
78
+ export const PROJECT_DEVICE_SEALS_BY_DEVICE = '@qvac/project-device-seals-by-device';
79
+ export const PROJECT_DEVICE_SEALS_BY_MEMBER = '@qvac/project-device-seals-by-member';
80
80
  export const AGENT_USERS_BY_USER = '@qvac/agent-users-by-user';
81
- export const PROJECT_KEYS_BY_MEMBER = '@qvac/project-keys-by-member';
81
+ export const PROJECT_MEMBER_SEALS_BY_MEMBER = '@qvac/project-member-seals-by-member';
82
82
  export const TERMINAL_RUN_STATUSES = '@qvac/terminal-run-statuses';
83
83
  export const MEMBER_REMOVALS = '@qvac/member-removals';
84
84
  export const INVITE_SEQUENCES = '@qvac/invite-sequences';
@@ -103,7 +103,7 @@ export const LIVE_MODEL_REQUESTS = '@qvac/live-model-requests';
103
103
  export const AGENT_HOSTS = '@qvac/agent-hosts';
104
104
  export const AGENT_USERS = '@qvac/agent-users';
105
105
  export const MEMBER_KEYS = '@qvac/member-keys';
106
- export const PROJECT_KEYS = '@qvac/project-keys';
107
- export const PROJECT_HOST_KEYS = '@qvac/project-host-keys';
108
- export const PROJECT_DEVICE_KEYS = '@qvac/project-device-keys';
106
+ export const PROJECT_MEMBER_SEALS = '@qvac/project-member-seals';
107
+ export const PROJECT_HOST_SEALS = '@qvac/project-host-seals';
108
+ export const PROJECT_DEVICE_SEALS = '@qvac/project-device-seals';
109
109
  export const SKILL_SECRETS = '@qvac/skill-secrets';
@@ -1,3 +1,4 @@
1
+ export declare const QUARANTINE_PREFIX = "quarantine.";
1
2
  export interface StoredConfigValue {
2
3
  readonly value?: unknown;
3
4
  readonly falsyValue?: string | null;
@@ -1,3 +1,4 @@
1
+ export const QUARANTINE_PREFIX = 'quarantine.';
1
2
  const FALSY_VALUES = new Map([
2
3
  ['false', false],
3
4
  ['0', 0],
@@ -1,6 +1,8 @@
1
1
  import type HyperDB from 'hyperdb';
2
- import type { QvacProjectDeviceKey } from '../../../spec/mesh/hyperschema/types.d.ts';
3
- export declare function readProjectDeviceKey(tx: HyperDB, projectId: Buffer, deviceId: Buffer): Promise<QvacProjectDeviceKey | null>;
2
+ import type { QvacProjectDeviceSeal } from '../../../spec/mesh/hyperschema/types.d.ts';
3
+ export type DeviceSealSlot = Pick<QvacProjectDeviceSeal, 'projectId' | 'deviceId' | 'sealedBy'>;
4
+ export declare function readProjectDeviceKey(tx: HyperDB, { projectId, deviceId, sealedBy }: DeviceSealSlot): Promise<QvacProjectDeviceSeal | null>;
5
+ export declare function projectDeviceKeys(tx: HyperDB, projectId: Buffer, deviceId?: Buffer): Promise<QvacProjectDeviceSeal[]>;
4
6
  export declare function dropProjectDeviceKeys(tx: HyperDB, projectId: Buffer): Promise<void>;
5
7
  export declare function dropListingDeviceKeys(tx: HyperDB, projectId: Buffer, memberId: Buffer): Promise<void>;
6
8
  export declare function dropMemberDeviceKeys(tx: HyperDB, memberId: Buffer): Promise<void>;
@@ -1,26 +1,26 @@
1
1
  import b4a from 'b4a';
2
- import { PROJECT_DEVICE_KEYS, PROJECT_DEVICE_KEYS_BY_DEVICE, PROJECT_DEVICE_KEYS_BY_MEMBER } from '../collections.js';
3
- export function readProjectDeviceKey(tx, projectId, deviceId) {
4
- return tx.get(PROJECT_DEVICE_KEYS, { projectId, deviceId });
2
+ import { PROJECT_DEVICE_SEALS, PROJECT_DEVICE_SEALS_BY_DEVICE, PROJECT_DEVICE_SEALS_BY_MEMBER } from '../collections.js';
3
+ export function readProjectDeviceKey(tx, { projectId, deviceId, sealedBy }) {
4
+ return tx.get(PROJECT_DEVICE_SEALS, { projectId, deviceId, sealedBy });
5
5
  }
6
- function deviceKeysOf(tx, projectId) {
7
- const range = { gte: { projectId }, lte: { projectId } };
8
- return tx.find(PROJECT_DEVICE_KEYS, range).toArray();
6
+ export function projectDeviceKeys(tx, projectId, deviceId) {
7
+ const key = deviceId ? { projectId, deviceId } : { projectId };
8
+ return tx.find(PROJECT_DEVICE_SEALS, { gte: key, lte: key }).toArray();
9
9
  }
10
10
  async function drop(tx, rows, match) {
11
- for (const row of rows.filter(match)) {
12
- await tx.delete(PROJECT_DEVICE_KEYS, { projectId: row.projectId, deviceId: row.deviceId });
11
+ for (const { projectId, deviceId, sealedBy } of rows.filter(match)) {
12
+ await tx.delete(PROJECT_DEVICE_SEALS, { projectId, deviceId, sealedBy });
13
13
  }
14
14
  }
15
15
  export async function dropProjectDeviceKeys(tx, projectId) {
16
- await drop(tx, await deviceKeysOf(tx, projectId), () => true);
16
+ await drop(tx, await projectDeviceKeys(tx, projectId), () => true);
17
17
  }
18
18
  export async function dropListingDeviceKeys(tx, projectId, memberId) {
19
- await drop(tx, await deviceKeysOf(tx, projectId), (row) => b4a.equals(row.memberId, memberId));
19
+ await drop(tx, await projectDeviceKeys(tx, projectId), (row) => [row.memberId, row.sealedBy].some((id) => b4a.equals(id, memberId)));
20
20
  }
21
21
  export async function dropMemberDeviceKeys(tx, memberId) {
22
22
  const rows = await tx
23
- .find(PROJECT_DEVICE_KEYS_BY_MEMBER, {
23
+ .find(PROJECT_DEVICE_SEALS_BY_MEMBER, {
24
24
  gte: { memberId },
25
25
  lte: { memberId }
26
26
  })
@@ -29,7 +29,7 @@ export async function dropMemberDeviceKeys(tx, memberId) {
29
29
  }
30
30
  export async function dropDeviceKeysOf(tx, deviceId) {
31
31
  const rows = await tx
32
- .find(PROJECT_DEVICE_KEYS_BY_DEVICE, {
32
+ .find(PROJECT_DEVICE_SEALS_BY_DEVICE, {
33
33
  gte: { deviceId },
34
34
  lte: { deviceId }
35
35
  })