@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,7 +1,7 @@
1
1
  import type { AbortSignal } from 'bare-abort-controller';
2
- import type { Capabilities } from './api/index.ts';
2
+ import type { ScopedCapabilities } from './mesh-scoped-engine.ts';
3
3
  import type { AssistantRagSearchRequest } from '../spec/hyperschema/types.d.ts';
4
- export declare function searchKnowledge(engine: Pick<Capabilities, 'ragSearch' | 'fileStatusWatch'>, request: AssistantRagSearchRequest, options: {
4
+ export declare function searchKnowledge(engine: Pick<ScopedCapabilities, 'ragSearch' | 'fileStatusWatch'>, request: Omit<AssistantRagSearchRequest, 'meshId'>, options: {
5
5
  signal: AbortSignal;
6
6
  preparing: (active: boolean) => void;
7
7
  }): Promise<import("../spec/index").AssistantRagSearchResponse>;
@@ -4,7 +4,7 @@ export async function clearKvCache(client) {
4
4
  }
5
5
  export async function deleteChatKvCache(client, chatId) {
6
6
  const remove = client.deleteChatKvCache?.bind(client);
7
- return deleteWhenSupported(client, remove && (() => remove({ id: chatId })));
7
+ return deleteWhenSupported(client, remove && (() => remove({ chatId })));
8
8
  }
9
9
  async function deleteWhenSupported(client, deletion) {
10
10
  if (!client.deviceInfo || !deletion)
@@ -4,6 +4,7 @@ import FileLog from 'bare-file-logger';
4
4
  import SystemLog from 'bare-system-logger';
5
5
  import { LogBuffer } from './log-buffer.js';
6
6
  import { LEVELS } from './log-levels.js';
7
+ import b4a from 'b4a';
7
8
  export { LEVELS } from './log-levels.js';
8
9
  const SCOPE = 'qvac-app-core';
9
10
  const LOG_BUFFER_CAP = 1000;
@@ -114,9 +115,7 @@ export class Logger {
114
115
  function renderRecord(record) {
115
116
  const tags = [SCOPE, ...record.scope];
116
117
  if (record.origin === 'client') {
117
- tags.push(record.originDeviceId
118
- ? `client:${record.originDeviceId.toString('hex').slice(0, 8)}`
119
- : 'client');
118
+ tags.push(record.originDeviceId ? `client:${b4a.toHex(record.originDeviceId).slice(0, 8)}` : 'client');
120
119
  }
121
120
  return [`[${tags.join(':')}]`, new Date(record.at).toISOString(), '-', record.message];
122
121
  }
@@ -1,3 +1,10 @@
1
1
  import type { Capabilities } from './api/index.ts';
2
+ type Unscoped<T> = T extends (input: infer I, ...rest: infer R) => infer O ? I extends {
3
+ meshId: string;
4
+ } ? (input: Omit<I, 'meshId'>, ...rest: R) => O : T : T;
5
+ export type ScopedCapabilities = {
6
+ readonly [K in keyof Capabilities]: Unscoped<Capabilities[K]>;
7
+ };
2
8
  export declare const MESH_SCOPED: ReadonlySet<keyof Capabilities>;
3
- export declare function meshScoped(engine: Capabilities, meshId?: string | null): Capabilities;
9
+ export declare function meshScoped(engine: Capabilities, meshId: string): ScopedCapabilities;
10
+ export {};
@@ -1,33 +1,79 @@
1
1
  export const MESH_SCOPED = new Set([
2
+ 'inferenceCalls',
3
+ 'createAgent',
4
+ 'listAgents',
2
5
  'getAgent',
6
+ 'getDefaultAgent',
7
+ 'updateAgent',
8
+ 'deleteAgent',
3
9
  'agentsWatch',
10
+ 'createChat',
11
+ 'listChats',
4
12
  'getChat',
13
+ 'renameChat',
14
+ 'setChatRagEnabled',
15
+ 'setChatWebSearchEnabled',
16
+ 'deleteChat',
17
+ 'chatsWatch',
18
+ 'listChatActivity',
19
+ 'chatActivityWatch',
20
+ 'searchChats',
21
+ 'createChatGroup',
22
+ 'listChatGroups',
23
+ 'renameChatGroup',
24
+ 'deleteChatGroup',
25
+ 'setChatGroup',
26
+ 'moveChat',
27
+ 'moveChatGroup',
28
+ 'sortChatGroupsByName',
5
29
  'appendChunk',
6
30
  'updateChunk',
31
+ 'resolveApproval',
7
32
  'listChunks',
8
33
  'chunksWatch',
9
- 'resolveApproval',
10
- 'listApprovalRules',
11
- 'recordToolActivity',
12
- 'renameChat',
13
- 'listToolConfigs',
14
- 'ragSearch',
15
- 'fileStatusWatch',
34
+ 'listAttachmentsByKind',
35
+ 'runRequestsWatch',
36
+ 'uploadAttachment',
37
+ 'downloadAttachment',
38
+ 'deleteAttachment',
39
+ 'uploadKnowledge',
40
+ 'downloadKnowledge',
41
+ 'removeKnowledge',
16
42
  'listKnowledge',
17
43
  'knowledgeWatch',
18
44
  'listIndexing',
19
45
  'indexingWatch',
20
46
  'indexingProgressWatch',
47
+ 'fileStatusWatch',
21
48
  'fileRead',
49
+ 'filePreview',
50
+ 'fileRetry',
22
51
  'listDevices',
52
+ 'getDevice',
23
53
  'devicesWatch',
54
+ 'saveDeviceCapabilities',
55
+ 'removeDevice',
56
+ 'renameDevice',
57
+ 'saveDeviceProfile',
24
58
  'listMembers',
25
59
  'membersWatch',
26
- 'listChats',
27
- 'chatsWatch',
28
- 'listAgents',
29
- 'deleteChat',
30
- 'deleteAgent'
60
+ 'removeMember',
61
+ 'listApprovalRules',
62
+ 'ragSearch',
63
+ 'runAgent',
64
+ 'sendMessage',
65
+ 'stopRun',
66
+ 'setToolConfigs',
67
+ 'deleteToolConfigs',
68
+ 'listToolConfigs',
69
+ 'toolConfigsWatch',
70
+ 'listToolActivity',
71
+ 'toolActivityWatch',
72
+ 'recordToolActivity',
73
+ 'syncStatusWatch',
74
+ 'notificationsWatch',
75
+ 'ackNotification',
76
+ 'compactChat'
31
77
  ]);
32
78
  const DEVICE_LOCAL = new Set([
33
79
  'configGet',
@@ -68,8 +114,11 @@ const DEVICE_LOCAL = new Set([
68
114
  'meshStatusWatch',
69
115
  'listMeshes',
70
116
  'meshesWatch',
117
+ 'account',
118
+ 'accountWatch',
119
+ 'updateMember',
120
+ 'listLocalFiles',
71
121
  'openMesh',
72
- 'selectMesh',
73
122
  'closeMesh',
74
123
  'leaveMesh',
75
124
  'acknowledgeKicked',
@@ -80,8 +129,6 @@ const DEVICE_LOCAL = new Set([
80
129
  'createRoom'
81
130
  ]);
82
131
  export function meshScoped(engine, meshId) {
83
- if (!meshId)
84
- return engine;
85
132
  return new Proxy(engine, {
86
133
  get(target, prop) {
87
134
  const value = Reflect.get(target, prop, target);
@@ -38,15 +38,20 @@ interface DownloadHarness {
38
38
  }
39
39
  interface DownloadEngine {
40
40
  configWatchTyped(request: Record<string, never>): AsyncIterable<AssistantAppConfig>;
41
- agentsWatch(request: Record<string, never>): AsyncIterable<unknown>;
42
- listDevices(request: Record<string, never>): Promise<{
41
+ agentsWatch(request: {
42
+ meshId: string;
43
+ }): AsyncIterable<unknown>;
44
+ listDevices(request: {
45
+ meshId: string;
46
+ }): Promise<{
43
47
  devices?: ReadonlyArray<{
44
48
  id: Buffer;
45
49
  capabilityProfile: string;
46
50
  }> | null;
47
51
  }>;
48
52
  getAgent(request: {
49
- id: string;
53
+ agentId: string;
54
+ meshId: string;
50
55
  }): Promise<{
51
56
  modelName?: string | null;
52
57
  providerDeviceId?: Buffer | null;
@@ -57,6 +62,7 @@ interface DownloadEngine {
57
62
  } | null>;
58
63
  listToolConfigs(request: {
59
64
  agentId: string;
65
+ meshId: string;
60
66
  }): Promise<{
61
67
  configs?: ReadonlyArray<{
62
68
  toolName?: string | null;
@@ -65,6 +71,7 @@ interface DownloadEngine {
65
71
  }>;
66
72
  toolConfigsWatch(request: {
67
73
  agentId: string;
74
+ meshId: string;
68
75
  }): AsyncIterable<unknown>;
69
76
  modelDownloadsWatch(request: Record<string, never>): AsyncIterable<{
70
77
  downloads?: ReadonlyArray<{
@@ -94,6 +101,7 @@ interface ReconcilerOptions {
94
101
  engine: DownloadEngine;
95
102
  harness: DownloadHarness;
96
103
  deviceId: Buffer;
104
+ meshId: () => string | null;
97
105
  onCacheChanged: () => void;
98
106
  retryMs?: number;
99
107
  now?: () => number;
@@ -107,6 +115,7 @@ interface RetryScheduler {
107
115
  }
108
116
  export declare class ModelDownloadReconciler {
109
117
  private readonly _engine;
118
+ private readonly _meshId;
110
119
  private readonly _harness;
111
120
  private readonly _deviceId;
112
121
  private readonly _onCacheChanged;
@@ -147,12 +156,12 @@ export declare class ModelDownloadReconciler {
147
156
  private _toolConfigsStream;
148
157
  private _toolConfigsAgentId;
149
158
  private readonly _timers;
150
- constructor({ engine, harness, deviceId, onCacheChanged, retryMs, now, createScheduler, logger, mobileClass }: ReconcilerOptions);
159
+ constructor({ engine, harness, deviceId, meshId, onCacheChanged, retryMs, now, createScheduler, logger, mobileClass }: ReconcilerOptions);
151
160
  start(): void;
152
161
  private _reset;
153
162
  suspend(): Promise<void>;
154
163
  resume(): void;
155
- meshSelected(): void;
164
+ meshAdopted(): void;
156
165
  yieldToRuns(models: ReadonlyArray<string>): void;
157
166
  observeImageProgress(observation: ImageDownloadObservation): void;
158
167
  private _transfer;
@@ -3,7 +3,6 @@ import { skillModelsForAgent } from '@qvac/harness/lib/models/model-catalog.ts';
3
3
  import { GENERATE_MUSIC_TOOL, MUSIC_MODEL_CHOICES } from '@qvac/harness/music-catalog';
4
4
  import { DeadlineScheduler } from './deadline.js';
5
5
  import { DownloadSpeedSampler, progressBytes, transferProgress } from '@qvac/harness/model-progress';
6
- import { isMeshTransition } from './api/current-mesh.js';
7
6
  import { runnableModelName } from './model-clamp.js';
8
7
  import { ModelDownloadStatus } from './model-download-status.js';
9
8
  import { RetryBudget } from './retry-budget.js';
@@ -14,6 +13,7 @@ const LOCAL_PROGRESS_PERCENTAGE_STEP = 1;
14
13
  const MAX_DEMAND_FAILURES = 3;
15
14
  export class ModelDownloadReconciler {
16
15
  _engine;
16
+ _meshId;
17
17
  _harness;
18
18
  _deviceId;
19
19
  _onCacheChanged;
@@ -54,8 +54,9 @@ export class ModelDownloadReconciler {
54
54
  _toolConfigsStream = null;
55
55
  _toolConfigsAgentId = null;
56
56
  _timers = new Set();
57
- constructor({ engine, harness, deviceId, onCacheChanged, retryMs, now = Date.now, createScheduler = (onFire) => new DeadlineScheduler(onFire), logger = null, mobileClass = false }) {
57
+ constructor({ engine, harness, deviceId, meshId, onCacheChanged, retryMs, now = Date.now, createScheduler = (onFire) => new DeadlineScheduler(onFire), logger = null, mobileClass = false }) {
58
58
  this._engine = engine;
59
+ this._meshId = meshId;
59
60
  this._harness = harness;
60
61
  this._deviceId = deviceId;
61
62
  this._onCacheChanged = onCacheChanged;
@@ -103,7 +104,7 @@ export class ModelDownloadReconciler {
103
104
  this._paused = false;
104
105
  this._kick();
105
106
  }
106
- meshSelected() {
107
+ meshAdopted() {
107
108
  if (this._closed)
108
109
  return;
109
110
  const agents = this._agentsStream;
@@ -257,7 +258,7 @@ export class ModelDownloadReconciler {
257
258
  _swapToolConfigsWatch(agentId) {
258
259
  const previous = this._toolConfigsStream;
259
260
  this._toolConfigsStream = null;
260
- this._toolConfigsAgentId = null;
261
+ this._toolConfigsAgentId = agentId;
261
262
  if (previous?.return)
262
263
  void previous.return().catch(() => { });
263
264
  if (agentId)
@@ -266,10 +267,12 @@ export class ModelDownloadReconciler {
266
267
  _watchToolConfigs(agentId) {
267
268
  if (this._closed)
268
269
  return;
269
- this._toolConfigsAgentId = agentId;
270
+ const meshId = this._meshId();
271
+ if (!meshId)
272
+ return;
270
273
  let active = null;
271
274
  const run = async () => {
272
- const stream = this._engine.toolConfigsWatch({ agentId });
275
+ const stream = this._engine.toolConfigsWatch({ agentId, meshId });
273
276
  const iterator = stream[Symbol.asyncIterator]();
274
277
  active = iterator;
275
278
  this._toolConfigsStream = iterator;
@@ -292,8 +295,11 @@ export class ModelDownloadReconciler {
292
295
  _watchAgents() {
293
296
  if (this._closed)
294
297
  return;
298
+ const meshId = this._meshId();
299
+ if (!meshId)
300
+ return;
295
301
  const run = async () => {
296
- const stream = this._engine.agentsWatch({});
302
+ const stream = this._engine.agentsWatch({ meshId });
297
303
  this._agentsStream = stream[Symbol.asyncIterator]();
298
304
  while (true) {
299
305
  const { done } = await this._agentsStream.next();
@@ -307,12 +313,7 @@ export class ModelDownloadReconciler {
307
313
  _restartWatch(name, err, restart) {
308
314
  if (this._closed)
309
315
  return;
310
- if (isMeshTransition(err)) {
311
- this._log?.debug('model-download', `${name} watch reopens on the next mesh`);
312
- }
313
- else {
314
- this._log?.error('model-download', `${name} watch failed — restarting`, err);
315
- }
316
+ this._log?.error('model-download', `${name} watch failed — restarting`, err);
316
317
  this._scheduleRestart(restart);
317
318
  }
318
319
  _scheduleRestart(restart) {
@@ -556,7 +557,10 @@ export class ModelDownloadReconciler {
556
557
  async _deviceProfile() {
557
558
  if (this._profile)
558
559
  return this._profile;
559
- const { devices } = await this._engine.listDevices({}).catch(() => ({ devices: [] }));
560
+ const meshId = this._meshId();
561
+ if (!meshId)
562
+ return this._profile ?? 'mid';
563
+ const { devices } = await this._engine.listDevices({ meshId }).catch(() => ({ devices: [] }));
560
564
  const self = (devices ?? []).find((device) => device.id.equals(this._deviceId));
561
565
  if (self)
562
566
  this._profile = self.capabilityProfile;
@@ -579,9 +583,10 @@ export class ModelDownloadReconciler {
579
583
  }
580
584
  async _refreshLocalAgentModels() {
581
585
  const activeAgentId = this._config?.activeAgentId;
582
- if (!activeAgentId)
586
+ const meshId = this._meshId();
587
+ if (!activeAgentId || !meshId)
583
588
  return;
584
- const agent = await this._engine.getAgent({ id: activeAgentId }).catch(noop);
589
+ const agent = await this._engine.getAgent({ agentId: activeAgentId, meshId }).catch(noop);
585
590
  if (!agent?.modelName)
586
591
  return;
587
592
  if (!agent.providerDeviceId?.equals(this._deviceId))
@@ -604,8 +609,11 @@ export class ModelDownloadReconciler {
604
609
  this._localSkillModels = skillModelsForAgent({ ...agent, musicModelChoice: this._musicChoice });
605
610
  }
606
611
  async _musicModelChoice(agentId) {
612
+ const meshId = this._meshId();
613
+ if (!meshId)
614
+ return { ok: false };
607
615
  const configs = await this._engine
608
- .listToolConfigs({ agentId })
616
+ .listToolConfigs({ agentId, meshId })
609
617
  .then((result) => result.configs ?? [])
610
618
  .catch(noop);
611
619
  if (!configs)
@@ -1,4 +1,4 @@
1
- import { AbortController } from 'bare-abort-controller';
1
+ import { AbortController } from '#abort-controller';
2
2
  import * as z from 'zod';
3
3
  const TOKEN_REQUEST_TIMEOUT_MS = 30_000;
4
4
  const TokenResponseSchema = z.object({
@@ -1,5 +1,5 @@
1
1
  import type { AssistantAppendChunkRequest, AssistantChunkId, AssistantChunkContentRunStatus } from '../spec/hyperschema/types.d.ts';
2
- import type { Capabilities } from './api/index.ts';
2
+ import type { ScopedCapabilities } from './mesh-scoped-engine.ts';
3
3
  import type { Logger } from './log.ts';
4
4
  export type TranscriptChunk = Pick<AssistantAppendChunkRequest, 'type' | 'toolCall' | 'toolResult' | 'sources' | 'effect' | 'display' | 'rawCall'>;
5
5
  export interface RunTranscriptOptions {
@@ -20,7 +20,7 @@ export declare class RunTranscript {
20
20
  private readonly _ticker;
21
21
  private readonly _announced;
22
22
  private _buffered;
23
- constructor(engine: Capabilities, { chatId, runId, deviceId, model, log }: RunTranscriptOptions);
23
+ constructor(engine: ScopedCapabilities, opts: RunTranscriptOptions);
24
24
  text(type: 'content' | 'thinking', text: string): Promise<void>;
25
25
  chunk(chunk: TranscriptChunk): Promise<AssistantChunkId>;
26
26
  status(runStatus: AssistantChunkContentRunStatus): Promise<AssistantChunkId>;
@@ -15,7 +15,8 @@ export class RunTranscript {
15
15
  _ticker;
16
16
  _announced = new Set();
17
17
  _buffered = null;
18
- constructor(engine, { chatId, runId, deviceId, model, log }) {
18
+ constructor(engine, opts) {
19
+ const { chatId, runId, deviceId, model, log } = opts;
19
20
  this._engine = engine;
20
21
  this._chatId = chatId;
21
22
  this._runId = runId;
@@ -64,7 +65,7 @@ export class RunTranscript {
64
65
  }));
65
66
  }
66
67
  progress(id, runStatus) {
67
- return this._writes.run(TRANSCRIPT, 'update:run-status', () => this._engine.updateChunk({ id, runStatus: { ...runStatus, model: this._model } }));
68
+ return this._writes.run(TRANSCRIPT, 'update:run-status', () => this._engine.updateChunk({ chunkId: id, runStatus: { ...runStatus, model: this._model } }));
68
69
  }
69
70
  flush() {
70
71
  return this._writes.run(TRANSCRIPT, 'append:text', async () => {
@@ -3,6 +3,7 @@ import type { AssistantChunk, AssistantChunkContentAttachment, AssistantRagSourc
3
3
  export type TaskEngine = Pick<Capabilities, 'chunksWatch' | 'sendMessage'>;
4
4
  export interface TaskRequest {
5
5
  readonly agentId: string;
6
+ readonly meshId: string;
6
7
  readonly prompt: string;
7
8
  readonly chatId?: string;
8
9
  readonly skill?: string;
@@ -1,15 +1,16 @@
1
1
  const TERMINAL_STATES = new Set(['completed', 'failed', 'canceled']);
2
2
  const TITLE_CHARS = 60;
3
3
  export async function runTask(engine, request) {
4
- const { agentId, prompt, skill } = request;
4
+ const { agentId, meshId, prompt, skill } = request;
5
5
  const text = skill ? `@${skill} ${prompt}` : prompt;
6
6
  const { chatId, runId } = await engine.sendMessage({
7
7
  text,
8
8
  agentId,
9
+ meshId,
9
10
  chatId: request.chatId ?? null,
10
11
  title: request.chatId ? null : title(prompt)
11
12
  });
12
- for await (const frame of engine.chunksWatch({ chatId })) {
13
+ for await (const frame of engine.chunksWatch({ chatId, meshId })) {
13
14
  const chunks = frame.chunks ?? [];
14
15
  const state = terminalState(chunks, runId);
15
16
  if (state)
@@ -51,13 +51,7 @@ const baselines = rewindSpec(ROOT, BASELINE_DIRS, {
51
51
  carries: 'spec/mesh/hyperdb/db.json',
52
52
  keep: HAND_WRITTEN
53
53
  });
54
- const engineSchemaFile = path.join(SCHEMA_DIR, 'schema.json');
55
- const engineSchema = JSON.parse(fs.readFileSync(engineSchemaFile, 'utf8'));
56
- const chatEnvelope = engineSchema.schema.find((type) => type.name === 'notification');
57
- if (chatEnvelope?.fields?.some((field) => field.name === 'chatId' && field.required)) {
58
- engineSchema.schema = engineSchema.schema.filter((type) => !type.name.startsWith('notification'));
59
- fs.writeFileSync(engineSchemaFile, JSON.stringify(engineSchema, null, 2));
60
- }
54
+ fs.writeFileSync(path.join(SCHEMA_DIR, 'schema.json'), JSON.stringify({ version: 0, schema: [] }, null, 2));
61
55
  const schema = Hyperschema.from(SCHEMA_DIR);
62
56
  registerEngineTypes(schema.namespace('assistant'));
63
57
  Hyperschema.toDisk(schema, { esm: true });
@@ -70,8 +64,8 @@ writeBind(builder, path.join(SPEC_DIR, 'bind.js'));
70
64
  const callSites = {
71
65
  optionalRequests: new Set([
72
66
  '@assistant/empty',
73
- '@assistant/mesh-scope',
74
- '@assistant/create-room-request'
67
+ '@assistant/create-room-request',
68
+ '@assistant/local-files-request'
75
69
  ])
76
70
  };
77
71
  writeClient(builder, path.join(SPEC_DIR, 'calls.js'), callSites);
@@ -81,7 +75,7 @@ registerLocalTypes(localSchema.namespace('local'));
81
75
  Hyperschema.toDisk(localSchema, { esm: true });
82
76
  HyperschemaTS.toDisk(localSchema);
83
77
  const db = HyperDB.from(LOCAL_SCHEMA_DIR, LOCAL_DB_DIR);
84
- registerLocalCollections(db.namespace('local'));
78
+ registerLocalCollections(db.namespace('local'), path.join(dir, 'helpers.js'));
85
79
  HyperDB.toDisk(db, { esm: true });
86
80
  const meshSchema = Hyperschema.from(MESH_SCHEMA_DIR);
87
81
  registerQvacTypes(meshSchema.namespace('qvac'));