@qvac/core 0.3.3 → 0.4.0

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 (169) hide show
  1. package/README.md +19 -17
  2. package/dist-lib/lib/abort-controller-node.d.ts +4 -0
  3. package/dist-lib/lib/abort-controller-node.js +1 -0
  4. package/dist-lib/lib/api/agents.d.ts +3 -3
  5. package/dist-lib/lib/api/agents.js +31 -20
  6. package/dist-lib/lib/api/approval-rules.d.ts +2 -2
  7. package/dist-lib/lib/api/approval-rules.js +2 -2
  8. package/dist-lib/lib/api/attachments.d.ts +2 -2
  9. package/dist-lib/lib/api/attachments.js +14 -25
  10. package/dist-lib/lib/api/chat-groups.d.ts +2 -2
  11. package/dist-lib/lib/api/chat-groups.js +9 -9
  12. package/dist-lib/lib/api/chat.d.ts +4 -2
  13. package/dist-lib/lib/api/chat.js +18 -18
  14. package/dist-lib/lib/api/chunks.d.ts +2 -2
  15. package/dist-lib/lib/api/chunks.js +27 -36
  16. package/dist-lib/lib/api/current-mesh.d.ts +7 -15
  17. package/dist-lib/lib/api/current-mesh.js +7 -22
  18. package/dist-lib/lib/api/devices.d.ts +4 -3
  19. package/dist-lib/lib/api/devices.js +18 -18
  20. package/dist-lib/lib/api/execution.d.ts +2 -2
  21. package/dist-lib/lib/api/execution.js +6 -6
  22. package/dist-lib/lib/api/files.d.ts +2 -2
  23. package/dist-lib/lib/api/files.js +4 -4
  24. package/dist-lib/lib/api/index.d.ts +12 -11
  25. package/dist-lib/lib/api/index.js +15 -13
  26. package/dist-lib/lib/api/inference-calls.d.ts +1 -1
  27. package/dist-lib/lib/api/inference-calls.js +2 -2
  28. package/dist-lib/lib/api/knowledge.d.ts +2 -2
  29. package/dist-lib/lib/api/knowledge.js +22 -11
  30. package/dist-lib/lib/api/local-files.d.ts +3 -0
  31. package/dist-lib/lib/api/local-files.js +23 -0
  32. package/dist-lib/lib/api/members.d.ts +6 -2
  33. package/dist-lib/lib/api/members.js +24 -17
  34. package/dist-lib/lib/api/mesh.d.ts +4 -5
  35. package/dist-lib/lib/api/mesh.js +7 -9
  36. package/dist-lib/lib/api/notifications.d.ts +2 -13
  37. package/dist-lib/lib/api/notifications.js +20 -52
  38. package/dist-lib/lib/api/rag.d.ts +2 -2
  39. package/dist-lib/lib/api/rag.js +4 -4
  40. package/dist-lib/lib/api/range.d.ts +11 -0
  41. package/dist-lib/lib/api/range.js +10 -0
  42. package/dist-lib/lib/api/sync.d.ts +2 -2
  43. package/dist-lib/lib/api/sync.js +3 -3
  44. package/dist-lib/lib/api/tool-activity.d.ts +2 -2
  45. package/dist-lib/lib/api/tool-activity.js +11 -10
  46. package/dist-lib/lib/api/tool-configs.d.ts +2 -2
  47. package/dist-lib/lib/api/tool-configs.js +6 -7
  48. package/dist-lib/lib/api/upload-frames.d.ts +9 -0
  49. package/dist-lib/lib/api/upload-frames.js +17 -0
  50. package/dist-lib/lib/api/watchable.d.ts +1 -6
  51. package/dist-lib/lib/api/watchable.js +4 -13
  52. package/dist-lib/lib/assistant/history.d.ts +3 -3
  53. package/dist-lib/lib/assistant-client.js +3 -2
  54. package/dist-lib/lib/assistant-tree.js +1 -1
  55. package/dist-lib/lib/assistant.d.ts +16 -14
  56. package/dist-lib/lib/assistant.js +166 -137
  57. package/dist-lib/lib/collabora/convert.js +1 -1
  58. package/dist-lib/lib/core/agent.d.ts +5 -7
  59. package/dist-lib/lib/core/agent.js +26 -6
  60. package/dist-lib/lib/core/archived-mesh.js +1 -0
  61. package/dist-lib/lib/core/chat-order.d.ts +20 -0
  62. package/dist-lib/lib/core/chat-order.js +96 -0
  63. package/dist-lib/lib/core/chat.d.ts +0 -5
  64. package/dist-lib/lib/core/chat.js +1 -3
  65. package/dist-lib/lib/core/chunk.d.ts +7 -14
  66. package/dist-lib/lib/core/chunk.js +17 -35
  67. package/dist-lib/lib/core/contract/agents.js +8 -0
  68. package/dist-lib/lib/core/contract/compute.d.ts +1 -1
  69. package/dist-lib/lib/core/contract/compute.js +1 -0
  70. package/dist-lib/lib/core/contract/joined-meshes.js +4 -3
  71. package/dist-lib/lib/core/contract/members.js +4 -3
  72. package/dist-lib/lib/core/contract/writers.js +5 -4
  73. package/dist-lib/lib/core/departures.js +5 -4
  74. package/dist-lib/lib/core/device-invites.js +2 -1
  75. package/dist-lib/lib/core/files/attachments.d.ts +8 -1
  76. package/dist-lib/lib/core/files/index.d.ts +4 -4
  77. package/dist-lib/lib/core/files/index.js +18 -8
  78. package/dist-lib/lib/core/files/local-index.d.ts +16 -0
  79. package/dist-lib/lib/core/files/local-index.js +38 -0
  80. package/dist-lib/lib/core/files/processing/document.js +2 -1
  81. package/dist-lib/lib/core/files/processing/ownership.js +6 -3
  82. package/dist-lib/lib/core/files/records/chunks.js +1 -0
  83. package/dist-lib/lib/core/files/records/reclaim.js +1 -0
  84. package/dist-lib/lib/core/files/records/routing.js +2 -1
  85. package/dist-lib/lib/core/files/store/blob.d.ts +1 -1
  86. package/dist-lib/lib/core/files/store/blob.js +6 -3
  87. package/dist-lib/lib/core/files/store/index.d.ts +1 -1
  88. package/dist-lib/lib/core/files/store/reference.js +4 -3
  89. package/dist-lib/lib/core/files/store/server.d.ts +8 -4
  90. package/dist-lib/lib/core/files/store/server.js +16 -12
  91. package/dist-lib/lib/core/files/store/sweep.js +2 -1
  92. package/dist-lib/lib/core/files/upload.d.ts +1 -1
  93. package/dist-lib/lib/core/hosted-agents.js +1 -1
  94. package/dist-lib/lib/core/image/cache-sweep.d.ts +1 -0
  95. package/dist-lib/lib/core/image/cache-sweep.js +7 -3
  96. package/dist-lib/lib/core/local/files.d.ts +24 -0
  97. package/dist-lib/lib/core/local/files.js +154 -0
  98. package/dist-lib/lib/core/local/index.d.ts +21 -5
  99. package/dist-lib/lib/core/local/index.js +75 -45
  100. package/dist-lib/lib/core/membership.d.ts +4 -1
  101. package/dist-lib/lib/core/membership.js +17 -2
  102. package/dist-lib/lib/core/mesh.d.ts +5 -0
  103. package/dist-lib/lib/core/mesh.js +11 -5
  104. package/dist-lib/lib/core/migrations/agent-indexes.d.ts +2 -0
  105. package/dist-lib/lib/core/migrations/agent-indexes.js +30 -0
  106. package/dist-lib/lib/core/migrations/file-index.d.ts +2 -0
  107. package/dist-lib/lib/core/migrations/file-index.js +27 -0
  108. package/dist-lib/lib/core/migrations/index.js +3 -1
  109. package/dist-lib/lib/core/notification.js +5 -5
  110. package/dist-lib/lib/core/range.d.ts +18 -0
  111. package/dist-lib/lib/core/range.js +17 -0
  112. package/dist-lib/lib/core/sync/index.js +39 -32
  113. package/dist-lib/lib/core/sync-status.js +3 -2
  114. package/dist-lib/lib/core/tool-activity.d.ts +2 -5
  115. package/dist-lib/lib/core/tool-activity.js +4 -7
  116. package/dist-lib/lib/core.d.ts +48 -29
  117. package/dist-lib/lib/core.js +465 -359
  118. package/dist-lib/lib/knowledge-search.d.ts +2 -2
  119. package/dist-lib/lib/kv-cache.js +1 -1
  120. package/dist-lib/lib/log.js +2 -3
  121. package/dist-lib/lib/mesh-scoped-engine.d.ts +8 -1
  122. package/dist-lib/lib/mesh-scoped-engine.js +62 -15
  123. package/dist-lib/lib/model-download.d.ts +14 -5
  124. package/dist-lib/lib/model-download.js +25 -17
  125. package/dist-lib/lib/oauth/token-exchange-core.js +1 -1
  126. package/dist-lib/lib/run-transcript.d.ts +2 -2
  127. package/dist-lib/lib/run-transcript.js +3 -2
  128. package/dist-lib/lib/task.d.ts +1 -0
  129. package/dist-lib/lib/task.js +3 -2
  130. package/dist-lib/schema/build.js +4 -10
  131. package/dist-lib/schema/engine.js +261 -91
  132. package/dist-lib/schema/helpers.d.ts +4 -0
  133. package/dist-lib/schema/helpers.js +20 -0
  134. package/dist-lib/schema/local.d.ts +1 -1
  135. package/dist-lib/schema/local.js +70 -2
  136. package/dist-lib/schema/qvac.js +30 -0
  137. package/dist-lib/spec/bind.js +20 -3
  138. package/dist-lib/spec/calls.js +19 -15
  139. package/dist-lib/spec/capabilities.d.ts +42 -34
  140. package/dist-lib/spec/hrpc/hrpc.json +82 -30
  141. package/dist-lib/spec/hrpc/index.js +106 -57
  142. package/dist-lib/spec/hrpc/messages.js +5420 -5019
  143. package/dist-lib/spec/hyperschema/index.js +5424 -5023
  144. package/dist-lib/spec/hyperschema/schema.json +3202 -2666
  145. package/dist-lib/spec/hyperschema/types.d.ts +455 -319
  146. package/dist-lib/spec/local/hyperdb/db.json +119 -1
  147. package/dist-lib/spec/local/hyperdb/index.js +414 -2
  148. package/dist-lib/spec/local/hyperdb/messages.js +505 -124
  149. package/dist-lib/spec/local/hyperschema/index.js +203 -5
  150. package/dist-lib/spec/local/hyperschema/schema.json +136 -1
  151. package/dist-lib/spec/local/hyperschema/types.d.ts +32 -1
  152. package/dist-lib/spec/mesh/hyperdb/db.json +55 -3
  153. package/dist-lib/spec/mesh/hyperdb/index.js +119 -3
  154. package/dist-lib/spec/mesh/hyperdb/messages.js +244 -172
  155. package/dist-lib/spec/mesh/hyperdispatch/dispatch.json +7 -1
  156. package/dist-lib/spec/mesh/hyperdispatch/index.js +18 -1
  157. package/dist-lib/spec/mesh/hyperdispatch/messages.js +74 -2
  158. package/dist-lib/spec/mesh/hyperschema/index.js +74 -2
  159. package/dist-lib/spec/mesh/hyperschema/schema.json +27 -1
  160. package/dist-lib/spec/mesh/hyperschema/types.d.ts +9 -1
  161. package/package.json +10 -6
  162. package/tui/app.mjs +376 -151
  163. package/tui/boot.mjs +2 -1
  164. package/tui/lib/busy-words.mjs +2 -1
  165. package/tui/lib/knowledge-command.mjs +11 -10
  166. package/tui/lib/knowledge-import.mjs +7 -5
  167. package/tui/lib/render.mjs +4 -3
  168. package/tui/lib/usage.mjs +2 -1
  169. package/tui/main.mjs +2 -1
@@ -1,6 +1,7 @@
1
1
  import { MAX_DEVICE_NAME_CHARS, deviceNameWithinBounds } from '../../schema/qvac.js';
2
2
  import { saveDeviceCapabilities } from '../core/devices.js';
3
3
  import { meshWatchable, requireMesh } from './current-mesh.js';
4
+ import b4a from 'b4a';
4
5
  const DEVICES = '@qvac/devices';
5
6
  function toEngineDevice(device, overrides = {}) {
6
7
  return {
@@ -24,13 +25,13 @@ function toEngineDevice(device, overrides = {}) {
24
25
  ...overrides
25
26
  };
26
27
  }
27
- export function createDevicesApi(current, deviceId, removeWriter, renameLocal, saveProfileLocal, readLocalProfile, computeLender = null) {
28
+ export function createDevicesApi(pool, deviceId, removeWriter, renameLocal, saveProfileLocal, readLocalProfile, computeLender = null) {
28
29
  const mustGetDevice = async (mesh, id) => {
29
30
  const snap = mesh.view.snapshot();
30
31
  try {
31
32
  const device = await snap.get(DEVICES, { id });
32
33
  if (!device)
33
- throw new Error(`device not found: ${id.toString('hex')}`);
34
+ throw new Error(`device not found: ${b4a.toHex(id)}`);
34
35
  return device;
35
36
  }
36
37
  finally {
@@ -48,15 +49,16 @@ export function createDevicesApi(current, deviceId, removeWriter, renameLocal, s
48
49
  }
49
50
  };
50
51
  return {
51
- listDevices: async (request) => list(await requireMesh(current, request?.meshId)),
52
- devicesWatch: meshWatchable('devicesWatch', current, (_request, mesh) => list(mesh)),
52
+ listDevices: async (request) => list(await requireMesh(pool, request.meshId)),
53
+ getDevice: async ({ deviceId: id, meshId }) => toEngineDevice(await mustGetDevice(await requireMesh(pool, meshId), id)),
54
+ devicesWatch: meshWatchable('devicesWatch', pool, (_request, mesh) => list(mesh)),
53
55
  deviceInfo: async () => {
54
56
  logger.info(['api', 'devices'], 'deviceInfo handler reached');
55
57
  const computeLenderId = (await computeLender?.()) ?? undefined;
56
58
  return { id: deviceId, supportsKvCacheDeletion: true, computeLenderId };
57
59
  },
58
60
  saveDeviceCapabilities: async (input) => {
59
- await saveDeviceCapabilities(await requireMesh(current), {
61
+ await saveDeviceCapabilities(await requireMesh(pool, input.meshId), {
60
62
  deviceId,
61
63
  installedToolNames: input.installedToolNames ?? [],
62
64
  installedSkillNames: input.installedSkillNames ?? [],
@@ -67,29 +69,27 @@ export function createDevicesApi(current, deviceId, removeWriter, renameLocal, s
67
69
  });
68
70
  return { ok: true };
69
71
  },
70
- removeDevice: async ({ id }) => {
71
- if (id.equals(deviceId))
72
+ removeDevice: async ({ deviceId: target, meshId }) => {
73
+ if (target.equals(deviceId))
72
74
  throw new Error('cannot remove own device, use leaveMesh');
73
- const device = await mustGetDevice(await requireMesh(current), id);
75
+ const mesh = await requireMesh(pool, meshId);
76
+ const device = await mustGetDevice(mesh, target);
74
77
  if (device.revoked)
75
78
  return { ok: true };
76
79
  if (!device.writerKey)
77
80
  throw new Error('device has no writer key, cannot remove');
78
- await removeWriter(device.writerKey, id);
81
+ await removeWriter(device.writerKey, target, mesh);
79
82
  return { ok: true };
80
83
  },
81
- renameDevice: async ({ id, name }) => {
82
- if (!id.equals(deviceId)) {
83
- throw new Error('can only rename this device, a device owns its row');
84
- }
85
- const trimmed = name.trim();
84
+ renameDevice: async ({ meshId, config }) => {
85
+ const trimmed = config.name.trim();
86
86
  if (!trimmed)
87
87
  throw new Error('device name must not be empty');
88
88
  if (!deviceNameWithinBounds(trimmed)) {
89
89
  throw new Error(`device name must be at most ${MAX_DEVICE_NAME_CHARS} characters`);
90
90
  }
91
- const mesh = await requireMesh(current);
92
- const device = await mustGetDevice(mesh, id);
91
+ const mesh = await requireMesh(pool, meshId);
92
+ const device = await mustGetDevice(mesh, deviceId);
93
93
  await renameLocal(trimmed);
94
94
  try {
95
95
  await mesh.dispatch('update-device', { device: { ...device, name: trimmed } });
@@ -100,8 +100,8 @@ export function createDevicesApi(current, deviceId, removeWriter, renameLocal, s
100
100
  }
101
101
  return toEngineDevice(device, { name: trimmed });
102
102
  },
103
- saveDeviceProfile: async ({ capabilityProfile, recommendedModelName, platform }) => {
104
- const mesh = await requireMesh(current);
103
+ saveDeviceProfile: async ({ capabilityProfile, recommendedModelName, platform, meshId }) => {
104
+ const mesh = await requireMesh(pool, meshId);
105
105
  const prior = readLocalProfile();
106
106
  await saveProfileLocal(capabilityProfile, recommendedModelName, platform ?? undefined);
107
107
  try {
@@ -1,3 +1,3 @@
1
- import { type CurrentMesh } from './current-mesh.ts';
1
+ import { type MeshPool } from './current-mesh.ts';
2
2
  import type { CapabilityHandlers } from '../../spec/capabilities.d.ts';
3
- export declare function createExecutionApi(current: CurrentMesh, deviceId: Buffer): Pick<CapabilityHandlers, 'sendMessage' | 'runAgent' | 'stopRun'>;
3
+ export declare function createExecutionApi(pool: MeshPool, deviceId: Buffer): Pick<CapabilityHandlers, 'sendMessage' | 'runAgent' | 'stopRun'>;
@@ -3,9 +3,9 @@ import { randomId } from '../core/id.js';
3
3
  import { parentRequestId, sendMessage } from '../core/send.js';
4
4
  import { requireMesh } from './current-mesh.js';
5
5
  const TERMINAL_STATES = new Set(['completed', 'failed', 'canceled']);
6
- export function createExecutionApi(current, deviceId) {
6
+ export function createExecutionApi(pool, deviceId) {
7
7
  return {
8
- sendMessage: async (input) => sendMessage(await requireMesh(current), {
8
+ sendMessage: async (input) => sendMessage(await requireMesh(pool, input.meshId), {
9
9
  text: input.text,
10
10
  chatId: input.chatId ?? undefined,
11
11
  agentId: input.agentId ?? undefined,
@@ -13,8 +13,8 @@ export function createExecutionApi(current, deviceId) {
13
13
  parentRunId: input.parentRunId ?? undefined,
14
14
  originDeviceId: deviceId
15
15
  }),
16
- runAgent: async ({ chatId, agentId, parentRunId }) => {
17
- const mesh = await requireMesh(current);
16
+ runAgent: async ({ chatId, agentId, parentRunId, meshId }) => {
17
+ const mesh = await requireMesh(pool, meshId);
18
18
  const parentId = parentRunId ? await parentRequestId(mesh, chatId, parentRunId) : undefined;
19
19
  await appendChunk(mesh, {
20
20
  chatId,
@@ -26,8 +26,8 @@ export function createExecutionApi(current, deviceId) {
26
26
  });
27
27
  return { ok: true };
28
28
  },
29
- stopRun: async ({ chatId, runId }) => {
30
- const mesh = await requireMesh(current);
29
+ stopRun: async ({ chatId, runId, meshId }) => {
30
+ const mesh = await requireMesh(pool, meshId);
31
31
  const statuses = await listChunks(mesh, { chatId, type: 'run-status' });
32
32
  const settled = statuses.some((c) => c.runId === runId && TERMINAL_STATES.has(c.runStatus?.state ?? ''));
33
33
  if (settled)
@@ -1,3 +1,3 @@
1
1
  import type { CapabilityHandlers } from '../../spec/capabilities.d.ts';
2
- import { type CurrentMesh } from './current-mesh.ts';
3
- export declare function createFilesApi(current: CurrentMesh): Pick<CapabilityHandlers, 'fileRead' | 'filePreview' | 'fileRetry'>;
2
+ import { type MeshPool } from './current-mesh.ts';
3
+ export declare function createFilesApi(pool: MeshPool): Pick<CapabilityHandlers, 'fileRead' | 'filePreview' | 'fileRetry'>;
@@ -1,19 +1,19 @@
1
1
  import { AbortController } from 'bare-abort-controller';
2
2
  import { Readable } from 'streamx';
3
3
  import { requireMesh } from './current-mesh.js';
4
- export function createFilesApi(current) {
4
+ export function createFilesApi(pool) {
5
5
  return {
6
6
  async filePreview(request) {
7
- return (await requireMesh(current)).files.preview(request);
7
+ return (await requireMesh(pool, request.meshId)).files.preview(request);
8
8
  },
9
9
  async fileRetry(request) {
10
- await (await requireMesh(current)).files.retry(request);
10
+ await (await requireMesh(pool, request.meshId)).files.retry(request);
11
11
  return { ok: true };
12
12
  },
13
13
  fileRead(request) {
14
14
  const abort = new AbortController();
15
15
  async function* read() {
16
- const mesh = await requireMesh(current, request.meshId);
16
+ const mesh = await requireMesh(pool, request.meshId);
17
17
  const close = () => stream.destroy();
18
18
  mesh.files.once('close', close);
19
19
  try {
@@ -1,18 +1,17 @@
1
1
  import type { CapabilityHandlers } from '../../spec/capabilities.d.ts';
2
2
  import type { AssistantCapabilityProfile, AssistantClearModelDownloadRequest, AssistantDeleteModelRequest, AssistantDeleteModelResponse, AssistantCompactChatResponse, AssistantKvCacheDeletionResponse, AssistantListModelsRequest, AssistantModelCatalogRevision, AssistantCopySkillResponse, AssistantDeleteSkillResponse, AssistantManagedSkillsResponse, AssistantModelInfoList, AssistantOkResponse, AssistantPushSkillSecretRequest, AssistantSkillCatalogResponse, AssistantSkillFileResponse, AssistantSpeakRequest, AssistantSpeakResponse, AssistantToolCatalogResponse, AssistantTranscribeRequest, AssistantTranscribeResponse } from '../../spec/hyperschema/types.d.ts';
3
3
  import type { openLocalStore } from '../core/local/index.ts';
4
- import type { CurrentMesh } from './current-mesh.ts';
4
+ import type { Mesh } from '../core/mesh.ts';
5
+ import type { MeshPool } from './current-mesh.ts';
5
6
  import { type DiagnosticsSource } from './diagnostics.ts';
6
7
  import { type InferenceCallReader } from './inference-calls.ts';
7
8
  import { type LogSource } from './logs.ts';
8
9
  import { type MeshStatusSource } from './mesh.ts';
9
10
  import { type NetworkSource } from './network.ts';
10
- import { type NotificationLifetime } from './notifications.ts';
11
11
  import type { IndexingEmbedder, VectorIndex } from '../core/files/index.ts';
12
12
  interface ApiDeps {
13
13
  state?: Awaited<ReturnType<typeof openLocalStore>> | null;
14
- notificationLifetime?: NotificationLifetime;
15
- mesh?: CurrentMesh | null;
14
+ mesh?: MeshPool | null;
16
15
  meshStatus?: MeshStatusSource | null;
17
16
  network?: NetworkSource | null;
18
17
  diagnostics?: DiagnosticsSource | null;
@@ -27,14 +26,14 @@ interface ApiDeps {
27
26
  deleteModel?: ((options: AssistantDeleteModelRequest) => Promise<AssistantDeleteModelResponse>) | null;
28
27
  clearKvCache?: (() => Promise<AssistantKvCacheDeletionResponse>) | null;
29
28
  deleteChatKvCache?: ((chatId: string) => Promise<AssistantKvCacheDeletionResponse>) | null;
30
- compactChat?: ((chatId: string) => Promise<AssistantCompactChatResponse>) | null;
29
+ compactChat?: ((chatId: string, meshId: string) => Promise<AssistantCompactChatResponse>) | null;
31
30
  modelCatalogWatch?: (() => AsyncIterable<AssistantModelCatalogRevision>) | null;
32
31
  retryModelDownload?: ((request: AssistantClearModelDownloadRequest) => Promise<void>) | null;
33
32
  transcribe?: ((request: AssistantTranscribeRequest) => Promise<AssistantTranscribeResponse>) | null;
34
33
  speak?: ((request: AssistantSpeakRequest) => Promise<AssistantSpeakResponse>) | null;
35
34
  speakStream?: ((text: AsyncIterable<string>) => AsyncIterable<AssistantSpeakResponse>) | null;
36
35
  deviceHost?: {
37
- removeWriter: (writerKey: Buffer, deviceId: Buffer) => Promise<void>;
36
+ removeWriter: (writerKey: Buffer, deviceId: Buffer, mesh: Mesh) => Promise<void>;
38
37
  renameLocal: (name: string) => Promise<void>;
39
38
  saveProfileLocal: (capabilityProfile: AssistantCapabilityProfile, recommendedModelName: string, platform?: string) => Promise<void>;
40
39
  readLocalProfile: () => {
@@ -43,14 +42,12 @@ interface ApiDeps {
43
42
  platform?: string;
44
43
  } | null;
45
44
  } | null;
46
- ragIndex?: (() => VectorIndex | null) | null;
47
- ragEmbed?: (() => IndexingEmbedder | null) | null;
45
+ ragIndex?: ((meshId: string) => VectorIndex | null) | null;
46
+ ragEmbed?: ((meshId: string) => IndexingEmbedder | null) | null;
48
47
  platform?: (() => string | null) | null;
49
48
  computeLender?: (() => Promise<Buffer | null>) | null;
50
49
  pushSkillSecret?: ((request: AssistantPushSkillSecretRequest) => Promise<void>) | null;
51
- skills?: ((agentId?: string | null, modelName?: string | null, options?: {
52
- readonly refresh?: boolean;
53
- }) => Promise<unknown>) | null;
50
+ skills?: ((agentId?: string | null, modelName?: string | null, options?: SkillOptions) => Promise<unknown>) | null;
54
51
  skillCatalog?: ((agentId?: string | null, modelName?: string | null, options?: {
55
52
  readonly refresh?: boolean;
56
53
  }) => Promise<AssistantSkillCatalogResponse>) | null;
@@ -62,4 +59,8 @@ interface ApiDeps {
62
59
  deleteOverlaySkill?: ((name: string, agentId?: string | null) => Promise<AssistantDeleteSkillResponse>) | null;
63
60
  }
64
61
  export type { Capabilities, WatchStream } from '../../spec/capabilities.d.ts';
62
+ export interface SkillOptions {
63
+ readonly refresh?: boolean;
64
+ readonly meshId?: string;
65
+ }
65
66
  export declare function createApi(deps?: ApiDeps): Partial<CapabilityHandlers>;
@@ -15,6 +15,7 @@ import { createInferenceCallsApi } from './inference-calls.js';
15
15
  import { createExecutionApi } from './execution.js';
16
16
  import { createKnowledgeApi } from './knowledge.js';
17
17
  import { createFilesApi } from './files.js';
18
+ import { createLocalFilesApi } from './local-files.js';
18
19
  import { createLogsApi } from './logs.js';
19
20
  import { instrument } from './instrument.js';
20
21
  import { watchable } from './watchable.js';
@@ -33,13 +34,16 @@ export function createApi(deps = {}) {
33
34
  const mesh = deps.mesh ?? null;
34
35
  const retryModelDownload = deps.retryModelDownload;
35
36
  const state = deps.state ?? null;
37
+ const members = mesh && deps.meshStatus ? createMembersApi(mesh, deps.meshStatus, state) : null;
36
38
  return instrument({
37
39
  ...(state ? createConfigApi(state) : null),
38
40
  ...(state ? createAppConfigApi(state) : null),
39
41
  ...(state ? createModelDownloadApi(state) : null),
40
42
  ...(state ? createCustomModelApi(state) : null),
41
43
  ...(mesh ? createAgentsApi(mesh, deps.deviceId ?? null, deps.computeLender ?? null) : null),
42
- ...(mesh ? createChatApi(mesh, deps.deviceId ?? null, deps.inferenceCalls ?? null) : null),
44
+ ...(mesh && state
45
+ ? createChatApi(mesh, deps.deviceId ?? null, state, deps.inferenceCalls ?? null)
46
+ : null),
43
47
  ...(mesh ? createChatGroupsApi(mesh) : null),
44
48
  ...(mesh ? createApprovalRulesApi(mesh) : null),
45
49
  ...(mesh ? createChunksApi(mesh, deps.deviceId ?? null) : null),
@@ -49,6 +53,7 @@ export function createApi(deps = {}) {
49
53
  ...(mesh ? createAttachmentsApi(mesh, { deviceId: deps.deviceId }) : null),
50
54
  ...(mesh ? createKnowledgeApi(mesh, { deviceId: deps.deviceId }) : null),
51
55
  ...(mesh ? createFilesApi(mesh) : null),
56
+ ...(state ? createLocalFilesApi(state.files) : null),
52
57
  ...(mesh
53
58
  ? createRagApi(mesh, deps.ragIndex ?? (() => null), deps.ragEmbed ?? (() => null), state
54
59
  ? async (agent) => effectiveCtxSize(agent, (await state.getAppConfigRow())?.ctxSize ?? 0, deps.platform?.() ?? null)
@@ -58,15 +63,9 @@ export function createApi(deps = {}) {
58
63
  ...(mesh ? createSyncApi(mesh) : null),
59
64
  ...(mesh ? createToolConfigsApi(mesh) : null),
60
65
  ...(mesh ? createToolActivityApi(mesh, deps.deviceId ?? null) : null),
61
- ...(mesh && state
62
- ? createNotificationsApi(mesh, state, {
63
- deviceId: deps.deviceId,
64
- lifetime: deps.notificationLifetime,
65
- changes: deps.meshStatus ?? undefined
66
- })
67
- : null),
68
- ...(deps.meshStatus ? createMeshApi(deps.meshStatus) : null),
69
- ...(mesh ? createMembersApi(mesh, state) : null),
66
+ ...(mesh && state ? createNotificationsApi(mesh, state, { deviceId: deps.deviceId }) : null),
67
+ ...members,
68
+ ...(deps.meshStatus && members ? createMeshApi(deps.meshStatus, members.updateMember) : null),
70
69
  ...(deps.network ? createNetworkApi(deps.network) : null),
71
70
  ...(deps.diagnostics ? createDiagnosticsApi(deps.diagnostics) : null),
72
71
  ...(deps.inferenceCalls ? createInferenceCallsApi(deps.inferenceCalls) : null),
@@ -88,10 +87,12 @@ export function createApi(deps = {}) {
88
87
  ...(deps.deleteModel ? { deleteModel: deps.deleteModel } : null),
89
88
  ...(deps.clearKvCache ? { clearKvCache: deps.clearKvCache } : null),
90
89
  ...(deps.deleteChatKvCache
91
- ? { deleteChatKvCache: ({ id }) => deps.deleteChatKvCache(id) }
90
+ ? {
91
+ deleteChatKvCache: ({ chatId }) => deps.deleteChatKvCache(chatId)
92
+ }
92
93
  : null),
93
94
  ...(deps.compactChat
94
- ? { compactChat: ({ id }) => deps.compactChat(id) }
95
+ ? { compactChat: ({ chatId, meshId }) => deps.compactChat(chatId, meshId) }
95
96
  : null),
96
97
  ...(deps.modelCatalogWatch ? { modelCatalogWatch: deps.modelCatalogWatch } : null),
97
98
  ...(retryModelDownload
@@ -128,7 +129,8 @@ export function createApi(deps = {}) {
128
129
  ? {
129
130
  skills: async (req) => ({
130
131
  skills: await deps.skills?.(req?.agentId, req?.modelName, {
131
- refresh: req?.refresh === true
132
+ refresh: req?.refresh === true,
133
+ meshId: req?.meshId || undefined
132
134
  })
133
135
  })
134
136
  }
@@ -12,7 +12,7 @@ export interface InferenceCallAnswer {
12
12
  truncated: boolean;
13
13
  }
14
14
  export interface InferenceCallReader {
15
- list(chatId: string): Promise<InferenceCallAnswer>;
15
+ list(meshId: string, chatId: string): Promise<InferenceCallAnswer>;
16
16
  forget(chatId: string): Promise<void>;
17
17
  }
18
18
  export declare function createInferenceCallsApi(reader: InferenceCallReader): Pick<CapabilityHandlers, 'inferenceCalls'>;
@@ -1,7 +1,7 @@
1
1
  export function createInferenceCallsApi(reader) {
2
2
  return {
3
- inferenceCalls: async ({ chatId }) => {
4
- const answer = await reader.list(chatId);
3
+ inferenceCalls: async ({ chatId, meshId }) => {
4
+ const answer = await reader.list(meshId, chatId);
5
5
  return {
6
6
  calls: answer.calls.map((entry) => ({
7
7
  runId: entry.runId,
@@ -1,7 +1,7 @@
1
1
  import type { CapabilityHandlers } from '../../spec/capabilities.d.ts';
2
- import { type CurrentMesh } from './current-mesh.ts';
2
+ import { type MeshPool } from './current-mesh.ts';
3
3
  export { MAX_KNOWLEDGE_BYTES } from '../core/files/knowledge.ts';
4
- export declare function createKnowledgeApi(current: CurrentMesh, options?: {
4
+ export declare function createKnowledgeApi(pool: MeshPool, options?: {
5
5
  maxBytes?: number;
6
6
  inactivityMs?: number;
7
7
  deviceId?: Buffer | null;
@@ -1,30 +1,41 @@
1
- import { requireMesh, selectionPin } from './current-mesh.js';
1
+ import { meshWatchable, requireMesh } from './current-mesh.js';
2
2
  import { watchable } from './watchable.js';
3
+ import { openUpload, UPLOAD_NAMES_NO_MESH } from './upload-frames.js';
3
4
  export { MAX_KNOWLEDGE_BYTES } from '../core/files/knowledge.js';
4
- export function createKnowledgeApi(current, options = {}) {
5
+ export function createKnowledgeApi(pool, options = {}) {
5
6
  return {
6
7
  async *uploadKnowledge(frames) {
7
- yield* (await requireMesh(current)).files.knowledge(options).uploadKnowledge(frames);
8
+ const upload = await openUpload(frames);
9
+ if (!upload)
10
+ return;
11
+ if (!upload.first.meshId)
12
+ throw new Error(UPLOAD_NAMES_NO_MESH);
13
+ const mesh = await requireMesh(pool, upload.first.meshId);
14
+ yield* mesh.files.knowledge(options).uploadKnowledge(upload.rest);
8
15
  },
9
16
  async *downloadKnowledge(request) {
10
- yield* (await requireMesh(current)).files.knowledge(options).downloadKnowledge(request);
17
+ yield* (await requireMesh(pool, request.meshId)).files
18
+ .knowledge(options)
19
+ .downloadKnowledge(request);
11
20
  },
12
21
  async removeKnowledge(request) {
13
- return (await requireMesh(current)).files.knowledge(options).removeKnowledge(request);
22
+ return (await requireMesh(pool, request.meshId)).files
23
+ .knowledge(options)
24
+ .removeKnowledge(request);
14
25
  },
15
26
  async listKnowledge(request) {
16
- return (await requireMesh(current, request?.meshId)).files
27
+ return (await requireMesh(pool, request.meshId)).files
17
28
  .knowledge(options)
18
29
  .listKnowledge(request);
19
30
  },
20
31
  async listIndexing(request) {
21
- return (await requireMesh(current, request?.meshId)).files
32
+ return (await requireMesh(pool, request.meshId)).files
22
33
  .knowledge(options)
23
34
  .listIndexing(request);
24
35
  },
25
- knowledgeWatch: watchable('knowledgeWatch', (request) => requireMesh(current, request?.meshId), async (request, mesh) => mesh.files.knowledge(options).listKnowledge(request), (request) => selectionPin(current, request?.meshId)),
26
- indexingWatch: watchable('indexingWatch', async (request) => (await requireMesh(current, request?.meshId)).files, ({ chatId }, files) => files.listIndexing(chatId), (request) => selectionPin(current, request?.meshId)),
27
- fileStatusWatch: watchable('fileStatusWatch', async (request) => (await requireMesh(current, request?.meshId)).files, ({ chatId }, files) => files.status(chatId), (request) => selectionPin(current, request?.meshId)),
28
- indexingProgressWatch: watchable('indexingProgressWatch', async (request) => (await requireMesh(current, request?.meshId)).files, ({ chatId }, files) => Promise.resolve({ entries: files.progress(chatId) }), (request) => selectionPin(current, request?.meshId))
36
+ knowledgeWatch: meshWatchable('knowledgeWatch', pool, async (request, mesh) => mesh.files.knowledge(options).listKnowledge(request)),
37
+ indexingWatch: watchable('indexingWatch', async (request) => (await requireMesh(pool, request.meshId)).files, ({ chatId }, files) => files.listIndexing(chatId)),
38
+ fileStatusWatch: watchable('fileStatusWatch', async (request) => (await requireMesh(pool, request.meshId)).files, ({ chatId }, files) => files.status(chatId)),
39
+ indexingProgressWatch: watchable('indexingProgressWatch', async (request) => (await requireMesh(pool, request.meshId)).files, ({ chatId }, files) => Promise.resolve({ entries: files.progress(chatId) }))
29
40
  };
30
41
  }
@@ -0,0 +1,3 @@
1
+ import type { CapabilityHandlers } from '../../spec/capabilities.d.ts';
2
+ import type { LocalFiles } from '../core/local/files.ts';
3
+ export declare function createLocalFilesApi(files: LocalFiles): Pick<CapabilityHandlers, 'listLocalFiles'>;
@@ -0,0 +1,23 @@
1
+ import b4a from 'b4a';
2
+ export function createLocalFilesApi(files) {
3
+ return {
4
+ listLocalFiles: async (request) => {
5
+ const meshKey = request?.meshId ? Buffer.from(request.meshId, 'hex') : undefined;
6
+ return { files: (await files.live(meshKey)).map(toEngineFile) };
7
+ }
8
+ };
9
+ }
10
+ function toEngineFile(file) {
11
+ return {
12
+ meshId: b4a.toHex(file.meshKey),
13
+ chatId: file.chatId,
14
+ attachmentId: file.attachmentId,
15
+ blobId: file.blobId,
16
+ fileName: file.fileName,
17
+ mimeType: file.mimeType,
18
+ byteLength: file.byteLength,
19
+ own: file.own,
20
+ lastAccessed: file.lastAccessed,
21
+ cleared: file.cleared
22
+ };
23
+ }
@@ -1,6 +1,10 @@
1
+ import type { AssistantAccount } from '../../spec/hyperschema/types.d.ts';
1
2
  import type { openLocalStore } from '../core/local/index.ts';
2
- import { type CurrentMesh } from './current-mesh.ts';
3
+ import { type MeshPool } from './current-mesh.ts';
3
4
  import type { CapabilityHandlers } from '../../spec/capabilities.d.ts';
4
5
  type LocalStore = Awaited<ReturnType<typeof openLocalStore>>;
5
- export declare function createMembersApi(current: CurrentMesh, state?: LocalStore | null): Pick<CapabilityHandlers, 'listMembers' | 'membersWatch' | 'updateMember' | 'removeMember'>;
6
+ export interface OwnMember {
7
+ account(): Promise<AssistantAccount>;
8
+ }
9
+ export declare function createMembersApi(pool: MeshPool, self: OwnMember, state?: LocalStore | null): Pick<CapabilityHandlers, 'listMembers' | 'membersWatch' | 'updateMember' | 'removeMember'>;
6
10
  export {};
@@ -1,4 +1,5 @@
1
1
  import { meshWatchable, requireMesh } from './current-mesh.js';
2
+ import b4a from 'b4a';
2
3
  const MEMBERS = '@qvac/members';
3
4
  const DEVICES = '@qvac/devices';
4
5
  const RESOLVE_MEMBER_MS = 10_000;
@@ -25,15 +26,15 @@ async function liveMemberIds(snap) {
25
26
  for await (const device of snap.find(DEVICES)) {
26
27
  const owner = device.revoked ? null : (device.memberId ?? device.claimedMemberId);
27
28
  if (owner)
28
- live.add(owner.toString('hex'));
29
+ live.add(b4a.toHex(owner));
29
30
  }
30
31
  return live;
31
32
  }
32
- export function createMembersApi(current, state = null) {
33
+ export function createMembersApi(pool, self, state = null) {
33
34
  const mustGetMember = async (reader, id) => {
34
35
  const member = await reader.get(MEMBERS, { id });
35
36
  if (!member)
36
- throw new Error(`member not found: ${id.toString('hex')}`);
37
+ throw new Error(`member not found: ${b4a.toHex(id)}`);
37
38
  return member;
38
39
  };
39
40
  const list = async (mesh) => {
@@ -42,7 +43,7 @@ export function createMembersApi(current, state = null) {
42
43
  const live = await liveMemberIds(snap);
43
44
  const members = await snap.find(MEMBERS).toArray();
44
45
  return {
45
- members: members.map((member) => toEngineMember(member, !live.has(member.id.toString('hex'))))
46
+ members: members.map((member) => toEngineMember(member, !live.has(b4a.toHex(member.id))))
46
47
  };
47
48
  }
48
49
  finally {
@@ -53,32 +54,38 @@ export function createMembersApi(current, state = null) {
53
54
  const snap = mesh.view.snapshot();
54
55
  try {
55
56
  const member = await mustGetMember(snap, id);
56
- return toEngineMember(member, !(await liveMemberIds(snap)).has(id.toString('hex')));
57
+ return toEngineMember(member, !(await liveMemberIds(snap)).has(b4a.toHex(id)));
57
58
  }
58
59
  finally {
59
60
  await snap.close();
60
61
  }
61
62
  };
62
63
  return {
63
- listMembers: async (request) => list(await requireMesh(current, request?.meshId)),
64
- membersWatch: meshWatchable('membersWatch', current, (_request, mesh) => list(mesh)),
65
- updateMember: async ({ id, name, meshId }) => {
66
- const mesh = await requireMesh(current, meshId);
67
- const trimmed = name.trim();
64
+ listMembers: async (request) => list(await requireMesh(pool, request.meshId)),
65
+ membersWatch: meshWatchable('membersWatch', pool, (_request, mesh) => list(mesh)),
66
+ updateMember: async ({ config }) => {
67
+ const trimmed = config.name.trim();
68
68
  if (!trimmed)
69
69
  throw new Error('member name must not be empty');
70
- const member = await mustGetMember(mesh.view, id);
70
+ const { meshId } = await self.account();
71
+ if (!meshId)
72
+ throw new Error('no account to rename the member in');
73
+ const mesh = await requireMesh(pool, meshId);
71
74
  if (!mesh.ourMemberId)
72
- await mesh.refreshOurMember();
73
- if (mesh.ourMemberId?.equals(id))
74
- await state?.saveDisplayName(trimmed);
75
+ await resolveOurMember(mesh);
76
+ const id = mesh.ourMemberId;
77
+ if (!id)
78
+ throw new Error('this device is in no member of its account');
79
+ const member = await mustGetMember(mesh.view, id);
80
+ const namedAt = Math.max(Date.now(), member.updatedAt + 1);
81
+ await state?.saveDisplayName(trimmed, namedAt);
75
82
  await mesh.dispatch('update-member', {
76
- member: { ...member, name: trimmed, updatedAt: Date.now() }
83
+ member: { ...member, name: trimmed, updatedAt: namedAt }
77
84
  });
78
85
  return readMember(mesh, id);
79
86
  },
80
- removeMember: async ({ id, meshId }) => {
81
- const mesh = await requireMesh(current, meshId);
87
+ removeMember: async ({ memberId: id, meshId }) => {
88
+ const mesh = await requireMesh(pool, meshId);
82
89
  if (!mesh.ourMemberId)
83
90
  await resolveOurMember(mesh);
84
91
  if (!mesh.ourMemberId)
@@ -1,4 +1,4 @@
1
- import type { AssistantArchivedMeshContents, AssistantArchivedMeshList, AssistantArchivedMeshMigration, AssistantMeshList, AssistantMeshStatus } from '../../spec/hyperschema/types.d.ts';
1
+ import type { AssistantAccount, AssistantArchivedMeshContents, AssistantArchivedMeshList, AssistantArchivedMeshMigration, AssistantMeshList, AssistantMeshStatus } from '../../spec/hyperschema/types.d.ts';
2
2
  import type { CapabilityHandlers } from '../../spec/capabilities.d.ts';
3
3
  export interface MeshInviteResult {
4
4
  readonly invite?: string;
@@ -9,14 +9,14 @@ export interface MeshStatusSource {
9
9
  watch(listener: () => void): void;
10
10
  unwatch(listener: () => void): void;
11
11
  snapshot(): AssistantMeshStatus;
12
- leave(): Promise<void>;
12
+ leave(meshId: string): Promise<void>;
13
13
  acknowledgeKicked(): void;
14
14
  join(invite: string): Promise<void>;
15
15
  cancelJoin(): void;
16
16
  invite(member?: boolean, meshId?: string): Promise<MeshInviteResult>;
17
17
  list(): Promise<AssistantMeshList>;
18
+ account(): Promise<AssistantAccount>;
18
19
  open(meshId: string): Promise<void>;
19
- select(meshId: string): Promise<void>;
20
20
  close(meshId: string): Promise<void>;
21
21
  label(meshId: string, label: string): Promise<void>;
22
22
  createRoom(opts?: {
@@ -29,6 +29,5 @@ export interface MeshStatusSource {
29
29
  publishRecovery(phrase: string): Promise<void>;
30
30
  recover(phrase: string, timeout?: number): Promise<void>;
31
31
  displayName(): Promise<string | null>;
32
- setDisplayName(name: string): Promise<void>;
33
32
  }
34
- export declare function createMeshApi(status: MeshStatusSource): Pick<CapabilityHandlers, 'meshStatusWatch' | 'listMeshes' | 'meshesWatch' | 'openMesh' | 'selectMesh' | 'closeMesh' | 'leaveMesh' | 'acknowledgeKicked' | 'joinMesh' | 'cancelMeshJoin' | 'meshInvite' | 'setMeshLabel' | 'createRoom' | 'listArchivedMeshes' | 'archivedMeshContents' | 'migrateArchivedMesh' | 'accountRecoverable' | 'recoveryPublish' | 'recoverAccount' | 'displayName' | 'setDisplayName'>;
33
+ export declare function createMeshApi(status: MeshStatusSource, updateMember: CapabilityHandlers['updateMember']): Pick<CapabilityHandlers, 'meshStatusWatch' | 'listMeshes' | 'meshesWatch' | 'account' | 'accountWatch' | 'openMesh' | 'closeMesh' | 'leaveMesh' | 'acknowledgeKicked' | 'joinMesh' | 'cancelMeshJoin' | 'meshInvite' | 'setMeshLabel' | 'createRoom' | 'listArchivedMeshes' | 'archivedMeshContents' | 'migrateArchivedMesh' | 'accountRecoverable' | 'recoveryPublish' | 'recoverAccount' | 'displayName' | 'setDisplayName'>;
@@ -1,23 +1,21 @@
1
1
  import { watchable } from './watchable.js';
2
- export function createMeshApi(status) {
2
+ export function createMeshApi(status, updateMember) {
3
3
  return {
4
4
  meshStatusWatch: watchable('meshStatusWatch', () => status, async () => status.snapshot()),
5
5
  listMeshes: () => status.list(),
6
6
  meshesWatch: watchable('meshesWatch', () => status, () => status.list()),
7
+ account: () => status.account(),
8
+ accountWatch: watchable('accountWatch', () => status, () => status.account()),
7
9
  openMesh: async ({ meshId }) => {
8
10
  await status.open(meshId);
9
11
  return { ok: true };
10
12
  },
11
- selectMesh: async ({ meshId }) => {
12
- await status.select(meshId);
13
- return { ok: true };
14
- },
15
13
  closeMesh: async ({ meshId }) => {
16
14
  await status.close(meshId);
17
15
  return { ok: true };
18
16
  },
19
- leaveMesh: async () => {
20
- await status.leave();
17
+ leaveMesh: async ({ meshId }) => {
18
+ await status.leave(meshId);
21
19
  return { ok: true };
22
20
  },
23
21
  acknowledgeKicked: async () => {
@@ -38,7 +36,7 @@ export function createMeshApi(status) {
38
36
  return { ok: true };
39
37
  },
40
38
  createRoom: async (request) => ({
41
- meshId: await status.createRoom({ compute: request?.compute })
39
+ meshId: await status.createRoom({ compute: request?.config?.compute })
42
40
  }),
43
41
  listArchivedMeshes: () => status.listArchived(),
44
42
  archivedMeshContents: ({ meshId }) => status.archivedContents(meshId),
@@ -58,7 +56,7 @@ export function createMeshApi(status) {
58
56
  name: await status.displayName()
59
57
  }),
60
58
  setDisplayName: async ({ name }) => {
61
- await status.setDisplayName(name ?? '');
59
+ await updateMember({ config: { name: name ?? '' } });
62
60
  return { ok: true };
63
61
  }
64
62
  };
@@ -1,21 +1,10 @@
1
1
  import type { CapabilityHandlers } from '../../spec/capabilities.d.ts';
2
2
  import type { openLocalStore } from '../core/local/index.ts';
3
- import { type CurrentMesh } from './current-mesh.ts';
3
+ import { type MeshPool } from './current-mesh.ts';
4
4
  type LocalStore = Awaited<ReturnType<typeof openLocalStore>>;
5
5
  type NotificationCapabilities = Pick<CapabilityHandlers, 'notificationsWatch' | 'ackNotification'>;
6
- export interface NotificationLifetime {
7
- once(event: 'close', listener: () => void): unknown;
8
- off(event: 'close', listener: () => void): unknown;
9
- readonly closing: unknown;
10
- readonly closed: boolean;
11
- }
12
6
  interface NotificationOptions {
13
7
  readonly deviceId?: Buffer | null;
14
- readonly lifetime?: NotificationLifetime;
15
- readonly changes?: {
16
- watch(listener: () => void): void;
17
- unwatch(listener: () => void): void;
18
- };
19
8
  }
20
- export declare function createNotificationsApi(current: CurrentMesh, local: LocalStore, options?: NotificationOptions): NotificationCapabilities;
9
+ export declare function createNotificationsApi(pool: MeshPool, local: LocalStore, options?: NotificationOptions): NotificationCapabilities;
21
10
  export {};