@qvac/core 0.2.1 → 0.3.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.
- package/.claude/skills/compaction/SKILL.md +15 -6
- package/.claude/skills/js-house-style/SKILL.md +1 -0
- package/.claude/skills/pr-create/SKILL.md +66 -3
- package/.claude/skills/pr-review/SKILL.md +252 -40
- package/.claude/skills/release/SKILL.md +122 -0
- package/CLAUDE.md +8 -5
- package/README.md +3 -1
- package/dist-lib/client.js +1 -1
- package/dist-lib/index.js +8 -8
- package/dist-lib/lib/api/agents.d.ts +1 -1
- package/dist-lib/lib/api/agents.js +10 -10
- package/dist-lib/lib/api/app-config.js +1 -1
- package/dist-lib/lib/api/approval-rules.js +9 -5
- package/dist-lib/lib/api/attachments.js +25 -3
- package/dist-lib/lib/api/chat-groups.d.ts +1 -1
- package/dist-lib/lib/api/chat-groups.js +5 -4
- package/dist-lib/lib/api/chat.js +10 -10
- package/dist-lib/lib/api/chunks.d.ts +1 -1
- package/dist-lib/lib/api/chunks.js +11 -21
- package/dist-lib/lib/api/config.js +1 -1
- package/dist-lib/lib/api/current-mesh.d.ts +16 -1
- package/dist-lib/lib/api/current-mesh.js +18 -0
- package/dist-lib/lib/api/custom-models.js +2 -2
- package/dist-lib/lib/api/devices.d.ts +1 -1
- package/dist-lib/lib/api/devices.js +12 -9
- package/dist-lib/lib/api/diagnostics.js +1 -1
- package/dist-lib/lib/api/effective-ctx-size.js +1 -1
- package/dist-lib/lib/api/execution.js +4 -4
- package/dist-lib/lib/api/files.js +2 -2
- package/dist-lib/lib/api/index.d.ts +1 -0
- package/dist-lib/lib/api/index.js +34 -34
- package/dist-lib/lib/api/instrument.js +1 -1
- package/dist-lib/lib/api/knowledge.js +13 -9
- package/dist-lib/lib/api/logs.js +1 -1
- package/dist-lib/lib/api/members.d.ts +4 -1
- package/dist-lib/lib/api/members.js +87 -18
- package/dist-lib/lib/api/mesh.d.ts +13 -3
- package/dist-lib/lib/api/mesh.js +25 -2
- package/dist-lib/lib/api/model-download.js +1 -1
- package/dist-lib/lib/api/network.js +1 -1
- package/dist-lib/lib/api/notifications.js +3 -3
- package/dist-lib/lib/api/rag.js +7 -7
- package/dist-lib/lib/api/sync.d.ts +1 -1
- package/dist-lib/lib/api/sync.js +3 -2
- package/dist-lib/lib/api/tool-activity.js +5 -5
- package/dist-lib/lib/api/tool-configs.js +5 -5
- package/dist-lib/lib/api/watchable.d.ts +6 -1
- package/dist-lib/lib/api/watchable.js +14 -3
- package/dist-lib/lib/assistant/fetch-body.d.ts +5 -0
- package/dist-lib/lib/assistant/fetch-body.js +36 -0
- package/dist-lib/lib/assistant/harness.d.ts +225 -0
- package/dist-lib/lib/assistant/harness.js +154 -0
- package/dist-lib/lib/assistant/history.d.ts +31 -0
- package/dist-lib/lib/assistant/history.js +226 -0
- package/dist-lib/lib/assistant/message.d.ts +45 -0
- package/dist-lib/lib/assistant/message.js +47 -0
- package/dist-lib/lib/assistant/skill-encode.d.ts +21 -0
- package/dist-lib/lib/assistant/skill-encode.js +71 -0
- package/dist-lib/lib/assistant-client.js +2 -2
- package/dist-lib/lib/assistant-tree.js +10 -4
- package/dist-lib/lib/assistant.d.ts +28 -292
- package/dist-lib/lib/assistant.js +284 -716
- package/dist-lib/lib/audio-format.js +2 -2
- package/dist-lib/lib/client.js +2 -2
- package/dist-lib/lib/collabora/convert.js +1 -1
- package/dist-lib/lib/collabora/entry.js +1 -1
- package/dist-lib/lib/collabora/worker.js +1 -1
- package/dist-lib/lib/compaction.d.ts +1 -2
- package/dist-lib/lib/compaction.js +8 -6
- package/dist-lib/lib/constants.js +1 -1
- package/dist-lib/lib/core/account-recovery.d.ts +19 -0
- package/dist-lib/lib/core/account-recovery.js +50 -0
- package/dist-lib/lib/core/agent.js +8 -4
- package/dist-lib/lib/core/app-build.d.ts +1 -1
- package/dist-lib/lib/core/approval-rules.d.ts +1 -0
- package/dist-lib/lib/core/approval-rules.js +3 -1
- package/dist-lib/lib/core/archived-mesh.d.ts +25 -0
- package/dist-lib/lib/core/archived-mesh.js +162 -0
- package/dist-lib/lib/core/chat-activity.js +1 -1
- package/dist-lib/lib/core/chat-group.d.ts +1 -0
- package/dist-lib/lib/core/chat-group.js +24 -4
- package/dist-lib/lib/core/chat-search.js +2 -2
- package/dist-lib/lib/core/chat.js +5 -5
- package/dist-lib/lib/core/chunk.d.ts +2 -1
- package/dist-lib/lib/core/chunk.js +31 -4
- package/dist-lib/lib/core/contract/agents.js +1 -1
- package/dist-lib/lib/core/contract/approval-rules.js +6 -4
- package/dist-lib/lib/core/contract/attestations.js +1 -1
- package/dist-lib/lib/core/contract/chat-group.js +1 -1
- package/dist-lib/lib/core/contract/chat.js +1 -1
- package/dist-lib/lib/core/contract/chunks.js +2 -2
- package/dist-lib/lib/core/contract/compute.d.ts +11 -0
- package/dist-lib/lib/core/contract/compute.js +45 -0
- package/dist-lib/lib/core/contract/devices.js +19 -5
- package/dist-lib/lib/core/contract/index.d.ts +3 -1
- package/dist-lib/lib/core/contract/index.js +19 -16
- package/dist-lib/lib/core/contract/indexing.js +2 -2
- package/dist-lib/lib/core/contract/joined-meshes.js +1 -1
- package/dist-lib/lib/core/contract/knowledge.js +2 -2
- package/dist-lib/lib/core/contract/members.js +2 -2
- package/dist-lib/lib/core/contract/seal.d.ts +2 -0
- package/dist-lib/lib/core/contract/seal.js +8 -0
- package/dist-lib/lib/core/contract/seed-defaults.js +1 -1
- package/dist-lib/lib/core/contract/tool-activity.js +1 -1
- package/dist-lib/lib/core/contract/tool-configs.js +3 -3
- package/dist-lib/lib/core/contract/writers.js +66 -42
- package/dist-lib/lib/core/departures.js +1 -1
- package/dist-lib/lib/core/device-invites.js +1 -1
- package/dist-lib/lib/core/document-attachment.js +2 -2
- package/dist-lib/lib/core/files/attachments.js +3 -3
- package/dist-lib/lib/core/files/index.d.ts +2 -2
- package/dist-lib/lib/core/files/index.js +19 -19
- package/dist-lib/lib/core/files/knowledge.js +3 -3
- package/dist-lib/lib/core/files/preview/image.js +1 -1
- package/dist-lib/lib/core/files/preview/index.js +6 -6
- package/dist-lib/lib/core/files/processing/claims.js +1 -1
- package/dist-lib/lib/core/files/processing/document.js +5 -5
- package/dist-lib/lib/core/files/processing/index.js +8 -8
- package/dist-lib/lib/core/files/processing/ownership.js +1 -1
- package/dist-lib/lib/core/files/processing/protocol.js +3 -3
- package/dist-lib/lib/core/files/processing/source.js +1 -1
- package/dist-lib/lib/core/files/rag/artifact/codec.js +1 -1
- package/dist-lib/lib/core/files/rag/artifact/id.js +1 -1
- package/dist-lib/lib/core/files/rag/artifact/types.d.ts +4 -4
- package/dist-lib/lib/core/files/rag/build.js +2 -2
- package/dist-lib/lib/core/files/rag/chunk/chunking.js +2 -2
- package/dist-lib/lib/core/files/rag/document-types.d.ts +3 -3
- package/dist-lib/lib/core/files/rag/extract/document-types.d.ts +9 -9
- package/dist-lib/lib/core/files/rag/extract/extract.js +7 -7
- package/dist-lib/lib/core/files/rag/extract/html-text.js +1 -1
- package/dist-lib/lib/core/files/rag/extract/office-collabora.js +2 -2
- package/dist-lib/lib/core/files/rag/extract/pdf-platform.js +1 -1
- package/dist-lib/lib/core/files/rag/extract/pdf-text.js +1 -1
- package/dist-lib/lib/core/files/rag/extract/text-decoding.js +1 -1
- package/dist-lib/lib/core/files/rag/extract/types.d.ts +2 -2
- package/dist-lib/lib/core/files/rag/index.js +22 -22
- package/dist-lib/lib/core/files/rag/load.js +5 -5
- package/dist-lib/lib/core/files/rag/policy.js +2 -2
- package/dist-lib/lib/core/files/rag/produce.js +5 -5
- package/dist-lib/lib/core/files/rag/retrieval/coverage.js +2 -2
- package/dist-lib/lib/core/files/rag/retrieval/diversity.js +1 -1
- package/dist-lib/lib/core/files/rag/retrieval/floor.js +2 -2
- package/dist-lib/lib/core/files/rag/retrieval/format.js +1 -1
- package/dist-lib/lib/core/files/rag/retrieval/full-text.js +18 -11
- package/dist-lib/lib/core/files/rag/retrieval/knowledge.js +5 -5
- package/dist-lib/lib/core/files/rag/retrieval/scoring.js +2 -2
- package/dist-lib/lib/core/files/rag/retrieval/search.js +4 -4
- package/dist-lib/lib/core/files/rag/retrieval/selection.js +2 -2
- package/dist-lib/lib/core/files/rag/retrieval/sources.js +2 -2
- package/dist-lib/lib/core/files/rag/retrieval/terms.js +1 -1
- package/dist-lib/lib/core/files/rag/retrieval/web-sources.js +1 -1
- package/dist-lib/lib/core/files/records/chunks.js +1 -1
- package/dist-lib/lib/core/files/records/index.js +8 -8
- package/dist-lib/lib/core/files/records/knowledge.js +2 -2
- package/dist-lib/lib/core/files/records/output.js +1 -1
- package/dist-lib/lib/core/files/records/reclaim.js +5 -5
- package/dist-lib/lib/core/files/records/routing.js +7 -7
- package/dist-lib/lib/core/files/store/blob.js +2 -2
- package/dist-lib/lib/core/files/store/index.js +7 -7
- package/dist-lib/lib/core/files/store/reference.js +2 -2
- package/dist-lib/lib/core/files/store/server.js +1 -1
- package/dist-lib/lib/core/files/store/sweep.js +1 -1
- package/dist-lib/lib/core/files/upload-input.js +2 -2
- package/dist-lib/lib/core/files/upload.d.ts +1 -1
- package/dist-lib/lib/core/files/upload.js +6 -6
- package/dist-lib/lib/core/harness-loan.d.ts +29 -0
- package/dist-lib/lib/core/harness-loan.js +187 -0
- package/dist-lib/lib/core/helpers/index.d.ts +2 -1
- package/dist-lib/lib/core/helpers/index.js +4 -4
- package/dist-lib/lib/core/hosted-agents.js +2 -2
- package/dist-lib/lib/core/identity.d.ts +2 -0
- package/dist-lib/lib/core/identity.js +4 -2
- package/dist-lib/lib/core/invite.d.ts +1 -0
- package/dist-lib/lib/core/invite.js +4 -2
- package/dist-lib/lib/core/local/index.d.ts +12 -3
- package/dist-lib/lib/core/local/index.js +81 -16
- package/dist-lib/lib/core/membership.d.ts +3 -0
- package/dist-lib/lib/core/membership.js +15 -1
- package/dist-lib/lib/core/mesh-seed-handoff.js +1 -1
- package/dist-lib/lib/core/mesh.d.ts +9 -3
- package/dist-lib/lib/core/mesh.js +41 -26
- package/dist-lib/lib/core/migrations/agent-catalog.js +1 -1
- package/dist-lib/lib/core/migrations/index.js +5 -3
- package/dist-lib/lib/core/migrations/membership.js +2 -2
- package/dist-lib/lib/core/migrations/seal.d.ts +3 -0
- package/dist-lib/lib/core/migrations/seal.js +30 -0
- package/dist-lib/lib/core/next-frame.js +1 -1
- package/dist-lib/lib/core/notification.js +1 -1
- package/dist-lib/lib/core/ota-config.js +1 -1
- package/dist-lib/lib/core/secret-handoff.js +1 -1
- package/dist-lib/lib/core/send.js +3 -3
- package/dist-lib/lib/core/skill-overlay-handoff.js +1 -1
- package/dist-lib/lib/core/skill-overlay-receiver.js +2 -2
- package/dist-lib/lib/core/skill-secrets.js +3 -3
- package/dist-lib/lib/core/sync/devices.js +1 -1
- package/dist-lib/lib/core/sync/index.js +8 -5
- package/dist-lib/lib/core/sync-status.js +1 -1
- package/dist-lib/lib/core/system-info.js +1 -1
- package/dist-lib/lib/core/tool-activity.js +2 -2
- package/dist-lib/lib/core/tool-configs.js +2 -2
- package/dist-lib/lib/core.d.ts +42 -3
- package/dist-lib/lib/core.js +543 -100
- package/dist-lib/lib/credential-pusher.js +4 -4
- package/dist-lib/lib/deadline.js +1 -1
- package/dist-lib/lib/fs-drive-bridge.js +5 -3
- package/dist-lib/lib/integrations/index.js +3 -3
- package/dist-lib/lib/integrations/oauth-providers.js +1 -1
- package/dist-lib/lib/integrations/setup-routes.d.ts +5 -5
- package/dist-lib/lib/integrations/setup-routes.js +3 -3
- package/dist-lib/lib/knowledge-search.js +1 -1
- package/dist-lib/lib/log.js +3 -3
- package/dist-lib/lib/mesh-scoped-engine.d.ts +3 -0
- package/dist-lib/lib/mesh-scoped-engine.js +101 -0
- package/dist-lib/lib/model-context.d.ts +2 -2
- package/dist-lib/lib/model-context.js +1 -1
- package/dist-lib/lib/model-download.d.ts +2 -0
- package/dist-lib/lib/model-download.js +26 -11
- package/dist-lib/lib/oauth/asana.js +3 -3
- package/dist-lib/lib/oauth/browser-connect.js +1 -1
- package/dist-lib/lib/oauth/client.js +2 -2
- package/dist-lib/lib/oauth/common.d.ts +1 -1
- package/dist-lib/lib/oauth/common.js +1 -1
- package/dist-lib/lib/oauth/flow-core.js +3 -3
- package/dist-lib/lib/oauth/flow.js +2 -2
- package/dist-lib/lib/oauth/google.js +4 -4
- package/dist-lib/lib/oauth/host.js +3 -3
- package/dist-lib/lib/oauth/keys.js +1 -0
- package/dist-lib/lib/oauth/loopback.js +1 -1
- package/dist-lib/lib/oauth/notion.js +3 -3
- package/dist-lib/lib/oauth/providers.js +1 -1
- package/dist-lib/lib/oauth/resolve.js +1 -1
- package/dist-lib/lib/oauth/spotify.js +4 -3
- package/dist-lib/lib/oauth/token-exchange.js +1 -1
- package/dist-lib/lib/oauth/verify.d.ts +8 -0
- package/dist-lib/lib/oauth/verify.js +58 -0
- package/dist-lib/lib/oauth.client.js +2 -2
- package/dist-lib/lib/oauth.d.ts +1 -0
- package/dist-lib/lib/oauth.js +13 -12
- package/dist-lib/lib/run-notices.d.ts +7 -7
- package/dist-lib/lib/run-transcript.js +1 -1
- package/dist-lib/schema/build.js +12 -6
- package/dist-lib/schema/content.d.ts +11 -11
- package/dist-lib/schema/engine.js +193 -30
- package/dist-lib/schema/field-order.js +2 -2
- package/dist-lib/schema/local.js +18 -4
- package/dist-lib/schema/qvac.d.ts +3 -0
- package/dist-lib/schema/qvac.js +22 -6
- package/dist-lib/spec/bind.js +41 -0
- package/dist-lib/spec/calls.js +12 -0
- package/dist-lib/spec/capabilities.d.ts +36 -12
- package/dist-lib/spec/hrpc/hrpc.json +161 -5
- package/dist-lib/spec/hrpc/index.js +154 -9
- package/dist-lib/spec/hrpc/messages.js +549 -129
- package/dist-lib/spec/hyperschema/index.js +549 -129
- package/dist-lib/spec/hyperschema/schema.json +370 -40
- package/dist-lib/spec/hyperschema/types.d.ts +85 -1
- package/dist-lib/spec/local/hyperdb/db.json +15 -0
- package/dist-lib/spec/local/hyperdb/index.js +70 -1
- package/dist-lib/spec/local/hyperdb/messages.js +300 -117
- package/dist-lib/spec/local/hyperschema/index.js +97 -4
- package/dist-lib/spec/local/hyperschema/schema.json +58 -1
- package/dist-lib/spec/local/hyperschema/types.d.ts +14 -0
- package/dist-lib/spec/mesh/hyperdb/messages.js +393 -288
- package/dist-lib/spec/mesh/hyperdispatch/dispatch.json +6 -0
- package/dist-lib/spec/mesh/hyperdispatch/index.js +18 -1
- package/dist-lib/spec/mesh/hyperdispatch/messages.js +176 -85
- package/dist-lib/spec/mesh/hyperschema/index.js +176 -85
- package/dist-lib/spec/mesh/hyperschema/schema.json +71 -21
- package/dist-lib/spec/mesh/hyperschema/types.d.ts +14 -1
- package/package.json +14 -8
- package/tui/README.md +7 -0
- package/tui/app.mjs +633 -55
- package/tui/lib/busy-words.mjs +57 -5
- package/tui/lib/export.mjs +1 -0
- package/tui/lib/render.mjs +25 -2
- package/tui/lib/selection.mjs +16 -0
- package/tui/lib/usage.mjs +54 -0
- package/tui/main.mjs +5 -2
|
@@ -6,18 +6,19 @@ import { ERRORS } from 'hyperdispatch/runtime';
|
|
|
6
6
|
import Hyperblobs from 'hyperblobs';
|
|
7
7
|
import crypto from 'hypercore-crypto';
|
|
8
8
|
import ReadyResource from 'ready-resource';
|
|
9
|
-
import { Files } from
|
|
9
|
+
import { Files } from './files/index.js';
|
|
10
10
|
import MeshDefinition from '../../spec/mesh/hyperdb/index.js';
|
|
11
11
|
import { Router, encode } from '../../spec/mesh/hyperdispatch/index.js';
|
|
12
|
-
import { syncChanges } from
|
|
13
|
-
import { buildDefaultSeed, isOwnKickedRow, isOwnRevokedRow } from
|
|
14
|
-
import { raceResource } from
|
|
15
|
-
import { signDeviceAttestation, signWriterClaim } from
|
|
16
|
-
import { deviceInviteToken } from
|
|
17
|
-
import { liveDeviceForWriter } from
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
12
|
+
import { syncChanges } from './sync/index.js';
|
|
13
|
+
import { DEFAULT_AGENT_NAME, buildDefaultSeed, isOwnKickedRow, isOwnRevokedRow } from './helpers/index.js';
|
|
14
|
+
import { raceResource } from '../race-resource.js';
|
|
15
|
+
import { signDeviceAttestation, signWriterClaim } from './device-attestation.js';
|
|
16
|
+
import { deviceInviteToken } from './identity.js';
|
|
17
|
+
import { liveDeviceForWriter } from './contract/activity.js';
|
|
18
|
+
import { assertComputeRoute } from './contract/compute.js';
|
|
19
|
+
import { registerRoutes } from './contract/index.js';
|
|
20
|
+
import { createSyncActivity } from './sync-status.js';
|
|
21
|
+
import { buildHealthAssistant } from './health-assistant.js';
|
|
21
22
|
const [MESH_KEYPAIR, MESH_ENCRYPTION, MESH_DEVICE] = crypto.namespace('qvac-assistant/mesh', 3);
|
|
22
23
|
const LIVE_WRITERS_BY_MOST_RECENT = '@qvac/live-writers-by-most-recent';
|
|
23
24
|
const WARMUP_COLLECTIONS = [
|
|
@@ -51,6 +52,7 @@ export class Mesh extends ReadyResource {
|
|
|
51
52
|
}
|
|
52
53
|
_store;
|
|
53
54
|
_seed;
|
|
55
|
+
_compute;
|
|
54
56
|
_key;
|
|
55
57
|
_writerSeed;
|
|
56
58
|
_log;
|
|
@@ -89,6 +91,9 @@ export class Mesh extends ReadyResource {
|
|
|
89
91
|
get key() {
|
|
90
92
|
return this.autobee.key;
|
|
91
93
|
}
|
|
94
|
+
get compute() {
|
|
95
|
+
return this._compute;
|
|
96
|
+
}
|
|
92
97
|
get encryptionKey() {
|
|
93
98
|
return this._encryptionKey;
|
|
94
99
|
}
|
|
@@ -167,6 +172,7 @@ export class Mesh extends ReadyResource {
|
|
|
167
172
|
super();
|
|
168
173
|
this._store = store;
|
|
169
174
|
this._seed = opts.seed ?? crypto.randomBytes(32);
|
|
175
|
+
this._compute = opts.compute ?? false;
|
|
170
176
|
this._key = opts.key ?? null;
|
|
171
177
|
this._writerSeed = opts.writerSeed;
|
|
172
178
|
this._log = opts.logger ?? null;
|
|
@@ -182,7 +188,7 @@ export class Mesh extends ReadyResource {
|
|
|
182
188
|
this._encryptionKey = crypto.hash([MESH_ENCRYPTION, this._seed]);
|
|
183
189
|
this.discoveryKey = crypto.discoveryKey(this._keyPair.publicKey);
|
|
184
190
|
this._scope = ['p2p', 'mesh', this._keyPair.publicKey.toString('hex').slice(0, 8)];
|
|
185
|
-
registerRoutes(this.router);
|
|
191
|
+
registerRoutes(this.router, { compute: this._compute });
|
|
186
192
|
}
|
|
187
193
|
async _open() {
|
|
188
194
|
this._log?.info(this._scope, 'opening');
|
|
@@ -292,6 +298,14 @@ export class Mesh extends ReadyResource {
|
|
|
292
298
|
get localWriterKey() {
|
|
293
299
|
return this.autobee.local.key;
|
|
294
300
|
}
|
|
301
|
+
signDeviceClaim(secretKey, deviceId, joinedAt) {
|
|
302
|
+
return signWriterClaim(secretKey, {
|
|
303
|
+
meshPublicKey: this.publicKey,
|
|
304
|
+
deviceId,
|
|
305
|
+
writerKey: this.localWriterKey,
|
|
306
|
+
joinedAt
|
|
307
|
+
});
|
|
308
|
+
}
|
|
295
309
|
get minted() {
|
|
296
310
|
return this.autobee.key.equals(this.autobee.local.key);
|
|
297
311
|
}
|
|
@@ -302,28 +316,33 @@ export class Mesh extends ReadyResource {
|
|
|
302
316
|
return this.autobee.local.length;
|
|
303
317
|
}
|
|
304
318
|
async dispatch(name, payload, opts) {
|
|
319
|
+
assertComputeRoute(this._compute, name);
|
|
305
320
|
await this.autobee.append(encode(`@qvac/${name}`, payload), opts);
|
|
306
321
|
}
|
|
307
322
|
batch() {
|
|
308
|
-
return new MeshBatch(this.autobee);
|
|
323
|
+
return new MeshBatch(this.autobee, { compute: this._compute });
|
|
309
324
|
}
|
|
310
|
-
async appendBirthOp(
|
|
325
|
+
async appendBirthOp(identity, device, member, claim, { room = false } = {}) {
|
|
311
326
|
if (this.autobee.local.length > 0)
|
|
312
327
|
return;
|
|
328
|
+
const { publicKey: deviceId, secretKey } = 'secretKey' in identity ? identity : { publicKey: identity, secretKey: null };
|
|
313
329
|
const localKey = this.autobee.local.key;
|
|
314
330
|
const row = device
|
|
315
331
|
? { id: deviceId, joinedAt: Date.now(), ...device }
|
|
316
332
|
: undefined;
|
|
333
|
+
const deviceSignature = secretKey && row ? this.signDeviceClaim(secretKey, deviceId, row.joinedAt) : undefined;
|
|
317
334
|
if (this._key === null) {
|
|
318
335
|
const birth = this.batch();
|
|
319
|
-
birth.dispatch('add-writer', { writerKey: localKey, device: row });
|
|
336
|
+
birth.dispatch('add-writer', { writerKey: localKey, device: row, deviceSignature });
|
|
320
337
|
if (row) {
|
|
321
338
|
birth.dispatch('attest-device', this.attestDevice(deviceId));
|
|
322
339
|
if (member)
|
|
323
340
|
birth.dispatch('mint-member', member);
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
341
|
+
if (!this._compute) {
|
|
342
|
+
birth.dispatch('seed-defaults', buildDefaultSeed(row, this._blindPeerKeys, room ? member.member.name : DEFAULT_AGENT_NAME));
|
|
343
|
+
if (!room)
|
|
344
|
+
birth.dispatch('put-agent', { agent: buildHealthAssistant(row) });
|
|
345
|
+
}
|
|
327
346
|
}
|
|
328
347
|
await birth.flush();
|
|
329
348
|
}
|
|
@@ -339,14 +358,7 @@ export class Mesh extends ReadyResource {
|
|
|
339
358
|
inviteToken: claim?.inviteNonce
|
|
340
359
|
? deviceInviteToken(claim.inviteNonce, deviceId)
|
|
341
360
|
: undefined,
|
|
342
|
-
deviceSignature
|
|
343
|
-
? signWriterClaim(claim.deviceKeyPair.secretKey, {
|
|
344
|
-
meshPublicKey: this.publicKey,
|
|
345
|
-
deviceId,
|
|
346
|
-
writerKey: localKey,
|
|
347
|
-
joinedAt: row.joinedAt
|
|
348
|
-
})
|
|
349
|
-
: undefined
|
|
361
|
+
deviceSignature
|
|
350
362
|
});
|
|
351
363
|
if (row)
|
|
352
364
|
join.dispatch('attest-device', this.attestDevice(deviceId));
|
|
@@ -525,14 +537,17 @@ export class Mesh extends ReadyResource {
|
|
|
525
537
|
}
|
|
526
538
|
export class MeshBatch {
|
|
527
539
|
_autobee;
|
|
540
|
+
_compute;
|
|
528
541
|
_ops = [];
|
|
529
|
-
constructor(autobee) {
|
|
542
|
+
constructor(autobee, opts = {}) {
|
|
530
543
|
this._autobee = autobee;
|
|
544
|
+
this._compute = opts.compute ?? false;
|
|
531
545
|
}
|
|
532
546
|
get size() {
|
|
533
547
|
return this._ops.length;
|
|
534
548
|
}
|
|
535
549
|
dispatch(name, payload) {
|
|
550
|
+
assertComputeRoute(this._compute, name);
|
|
536
551
|
this._ops.push(encode(`@qvac/${name}`, payload));
|
|
537
552
|
}
|
|
538
553
|
async flush(opts) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { buildHealthAssistant, HEALTH_ASSISTANT_ID } from
|
|
1
|
+
import { buildHealthAssistant, HEALTH_ASSISTANT_ID } from '../health-assistant.js';
|
|
2
2
|
const AGENTS = '@qvac/agents';
|
|
3
3
|
const MIGRATION_BASELINE_AT = 0;
|
|
4
4
|
export async function migrateAgentCatalog(mesh, { device }) {
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { migrateAgentCatalog } from
|
|
2
|
-
import { migrateMembership } from
|
|
1
|
+
import { migrateAgentCatalog } from './agent-catalog.js';
|
|
2
|
+
import { migrateMembership } from './membership.js';
|
|
3
|
+
import { sealDeviceRows } from './seal.js';
|
|
3
4
|
export async function runMigrations(mesh, context, { catalog = true } = {}) {
|
|
4
5
|
const membership = await migrateMembership(mesh, context);
|
|
5
6
|
const agents = catalog && (await migrateAgentCatalog(mesh, context));
|
|
6
|
-
|
|
7
|
+
const seal = await sealDeviceRows(mesh, context);
|
|
8
|
+
return membership || agents || seal;
|
|
7
9
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { attestDeviceProof } from
|
|
2
|
-
import { membershipView } from
|
|
1
|
+
import { attestDeviceProof } from '../identity.js';
|
|
2
|
+
import { membershipView } from '../membership.js';
|
|
3
3
|
export async function migrateMembership(mesh, { deviceKeyPair, deviceName, mintRoot, log }) {
|
|
4
4
|
const { members, own, unattested } = await membershipView(mesh, deviceKeyPair.publicKey);
|
|
5
5
|
if (!own)
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { MembershipMigrationContext } from './membership.ts';
|
|
2
|
+
import type { Mesh } from '../mesh.ts';
|
|
3
|
+
export declare function sealDeviceRows(mesh: Mesh, { deviceKeyPair, deviceName, log }: Pick<MembershipMigrationContext, 'deviceKeyPair' | 'deviceName' | 'log'>): Promise<boolean>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { claimableDevice } from '../mesh.js';
|
|
2
|
+
import { sealed } from '../contract/seal.js';
|
|
3
|
+
const DEVICES = '@qvac/devices';
|
|
4
|
+
export async function sealDeviceRows(mesh, { deviceKeyPair, deviceName, log }) {
|
|
5
|
+
if (!mesh.writable)
|
|
6
|
+
return false;
|
|
7
|
+
const own = await mesh.view.get(DEVICES, { id: deviceKeyPair.publicKey });
|
|
8
|
+
if (!own || (await sealed(mesh.view)))
|
|
9
|
+
return false;
|
|
10
|
+
const joinedAt = Date.now();
|
|
11
|
+
const { id, capabilityProfile, recommendedModelName } = own;
|
|
12
|
+
await mesh.dispatch('add-writer', {
|
|
13
|
+
writerKey: mesh.localWriterKey,
|
|
14
|
+
device: claimableDevice({
|
|
15
|
+
id,
|
|
16
|
+
joinedAt,
|
|
17
|
+
name: deviceName,
|
|
18
|
+
capabilityProfile,
|
|
19
|
+
recommendedModelName
|
|
20
|
+
}),
|
|
21
|
+
deviceSignature: mesh.signDeviceClaim(deviceKeyPair.secretKey, id, joinedAt)
|
|
22
|
+
});
|
|
23
|
+
const after = await mesh.view.get(DEVICES, { id });
|
|
24
|
+
if (!after?.deviceSignature) {
|
|
25
|
+
log?.warn(['p2p', 'mesh'], 'the re-admission that should have sealed this mesh was refused');
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
log?.info(['p2p', 'mesh'], 'migrated: sealed the device rows this mesh predates');
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AbortedError } from '@qvac/harness/race-abort';
|
|
2
|
-
import { unref } from
|
|
2
|
+
import { unref } from '../unref.js';
|
|
3
3
|
export const UPLOAD_INACTIVITY_MS = 30_000;
|
|
4
4
|
export function nextFrame(iterator, { signal, inactivityMs = UPLOAD_INACTIVITY_MS } = {}) {
|
|
5
5
|
if (signal?.aborted)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { diagramRepairLinks, isDiagramRepairPrompt } from '@qvac/harness/lib/diagram-repair.ts';
|
|
2
|
-
import { findChunksOfType } from
|
|
2
|
+
import { findChunksOfType } from './chunk.js';
|
|
3
3
|
const ACTIVE_CHATS = '@qvac/active-chats';
|
|
4
4
|
const AGENTS = '@qvac/agents';
|
|
5
5
|
const CHUNK_COUNTERS = '@qvac/chunk-counters';
|
|
@@ -3,7 +3,7 @@ import { Range } from 'bare-semver';
|
|
|
3
3
|
import c from 'compact-encoding';
|
|
4
4
|
import Hyperconf from 'hyperconf';
|
|
5
5
|
import HypercoreId from 'hypercore-id-encoding';
|
|
6
|
-
import { RELEASE_LANES } from
|
|
6
|
+
import { RELEASE_LANES } from './app-build.js';
|
|
7
7
|
import spec, {} from '../../spec/config/hyperconf/index.js';
|
|
8
8
|
const CONFIG_CORES = {
|
|
9
9
|
dev: { key: 'e5g337qdk4qachns5nsnu63wjp96twyc34ainucherhq1zodanmy', minLength: 1 },
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getStruct } from '../../spec/hyperschema/index.js';
|
|
2
|
-
import { ACK_TIMEOUT_MS, HandoffChannel, HOST_SILENT, HOST_UNREACHABLE } from
|
|
2
|
+
import { ACK_TIMEOUT_MS, HandoffChannel, HOST_SILENT, HOST_UNREACHABLE } from './handoff-channel.js';
|
|
3
3
|
const PROTOCOL = 'qvac/secret-handoff';
|
|
4
4
|
export { ACK_TIMEOUT_MS, HOST_SILENT, HOST_UNREACHABLE };
|
|
5
5
|
const handoff = getStruct('@assistant/skill-secret-handoff');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { buildChat, enrichChat, mustGetActiveChat } from
|
|
2
|
-
import { appendChunk, listChunks } from
|
|
3
|
-
import { randomId } from
|
|
1
|
+
import { buildChat, enrichChat, mustGetActiveChat } from './chat.js';
|
|
2
|
+
import { appendChunk, listChunks } from './chunk.js';
|
|
3
|
+
import { randomId } from './id.js';
|
|
4
4
|
export async function sendMessage(mesh, input) {
|
|
5
5
|
const existing = input.chatId ? await mustGetActiveChat(mesh, input.chatId) : null;
|
|
6
6
|
const agentId = input.agentId ?? existing?.agentId;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getStruct } from '../../spec/hyperschema/index.js';
|
|
2
|
-
import { ACK_TIMEOUT_MS, HandoffChannel, HOST_SILENT, HOST_UNREACHABLE } from
|
|
2
|
+
import { ACK_TIMEOUT_MS, HandoffChannel, HOST_SILENT, HOST_UNREACHABLE } from './handoff-channel.js';
|
|
3
3
|
const PROTOCOL = 'qvac/skill-overlay-handoff';
|
|
4
4
|
export { ACK_TIMEOUT_MS, HOST_SILENT, HOST_UNREACHABLE };
|
|
5
5
|
const handoff = getStruct('@assistant/skill-overlay-handoff');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import b4a from 'b4a';
|
|
2
|
-
import { getAgent } from
|
|
3
|
-
import { NO_SUCH_AGENT, NOT_THE_HOST, SENDER_REVOKED } from
|
|
2
|
+
import { getAgent } from './agent.js';
|
|
3
|
+
import { NO_SUCH_AGENT, NOT_THE_HOST, SENDER_REVOKED } from './skill-secrets.js';
|
|
4
4
|
const DEVICES = '@qvac/devices';
|
|
5
5
|
export function createSkillOverlayReceiver(opts) {
|
|
6
6
|
return async (op, fromDeviceId) => {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import b4a from 'b4a';
|
|
2
2
|
import { credentialSlots } from '@qvac/harness/lib/tools/skills/credential-slots.ts';
|
|
3
3
|
import { isDeviceSharedCredentialKey } from '@qvac/harness/lib/tools/skills/scope-key.ts';
|
|
4
|
-
import { oauthStateKey, settingConfigKey } from
|
|
5
|
-
import { scopedKey } from
|
|
6
|
-
import { getAgent } from
|
|
4
|
+
import { oauthStateKey, settingConfigKey } from '../credential-pusher.js';
|
|
5
|
+
import { scopedKey } from '../oauth/common.js';
|
|
6
|
+
import { getAgent } from './agent.js';
|
|
7
7
|
const DEVICES = '@qvac/devices';
|
|
8
8
|
export const NOT_THE_HOST = 'this device does not host that agent';
|
|
9
9
|
export const SENDER_REVOKED = 'the sending device is no longer in the mesh';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { FileChanges } from
|
|
2
|
-
import { syncDeviceRevocation, syncOwnMember } from
|
|
3
|
-
import { syncChatTombstone } from
|
|
4
|
-
import { syncNotificationChunk } from
|
|
1
|
+
import { FileChanges } from './files.js';
|
|
2
|
+
import { syncDeviceRevocation, syncOwnMember } from './devices.js';
|
|
3
|
+
import { syncChatTombstone } from './chats.js';
|
|
4
|
+
import { syncNotificationChunk } from './chunks.js';
|
|
5
5
|
export async function syncChanges(mesh, view, from) {
|
|
6
6
|
if (mesh.closing)
|
|
7
7
|
return;
|
|
@@ -60,8 +60,11 @@ export async function syncChanges(mesh, view, from) {
|
|
|
60
60
|
mesh.emit('indexing-dirty', indexingDirty);
|
|
61
61
|
if (unattestedDevice)
|
|
62
62
|
mesh.emit('unattested-device');
|
|
63
|
-
if (membershipMoved)
|
|
63
|
+
if (membershipMoved) {
|
|
64
64
|
await mesh.refreshMembership();
|
|
65
|
+
mesh.emit('membership-tallied');
|
|
66
|
+
mesh.emit('members-dirty');
|
|
67
|
+
}
|
|
65
68
|
if (agentsDirty)
|
|
66
69
|
mesh.emit('agents-dirty');
|
|
67
70
|
if (roomsChanged)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { capToolActivityArguments } from
|
|
2
|
-
import { randomId } from
|
|
1
|
+
import { capToolActivityArguments } from '../../schema/qvac.js';
|
|
2
|
+
import { randomId } from './id.js';
|
|
3
3
|
const TOOL_ACTIVITY_BY_AGENT = '@qvac/tool-activity-by-agent';
|
|
4
4
|
export async function recordToolActivity(store, input) {
|
|
5
5
|
const activity = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { MAX_TOOL_CONFIGS_BYTES, toolConfigsWithinBounds } from
|
|
2
|
-
import { mustGetAgent } from
|
|
1
|
+
import { MAX_TOOL_CONFIGS_BYTES, toolConfigsWithinBounds } from '../../schema/qvac.js';
|
|
2
|
+
import { mustGetAgent } from './agent.js';
|
|
3
3
|
const TOOL_CONFIGS = '@qvac/tool-configs';
|
|
4
4
|
const ACTIVE_TOOL_CONFIGS_BY_AGENT = '@qvac/active-tool-configs-by-agent';
|
|
5
5
|
function isPlainObject(value) {
|
package/dist-lib/lib/core.d.ts
CHANGED
|
@@ -4,12 +4,14 @@ import type { BootstrapNode } from 'hyperswarm';
|
|
|
4
4
|
import ReadyGuard from 'ready-guard';
|
|
5
5
|
import ReadyResource from 'ready-resource';
|
|
6
6
|
import type { Logger } from '../index.ts';
|
|
7
|
-
import type { AssistantCompactChatResponse, AssistantCopySkillResponse, AssistantDeleteModelRequest, AssistantDeleteModelResponse, AssistantDeleteSkillResponse, AssistantKvCacheDeletionResponse, AssistantListModelsRequest, AssistantManagedSkillsResponse, AssistantMeshList, AssistantModelCatalogRevision, AssistantModelInfoList, AssistantOkResponse, AssistantSkillCatalogResponse, AssistantSkillFileResponse, AssistantSpeakRequest, AssistantSpeakResponse, AssistantToolCatalogResponse, AssistantTranscribeRequest, AssistantTranscribeResponse } from '../spec/index.d.ts';
|
|
7
|
+
import type { AssistantArchivedMeshList, AssistantCompactChatResponse, AssistantCopySkillResponse, AssistantDeleteModelRequest, AssistantDeleteModelResponse, AssistantDeleteSkillResponse, AssistantKvCacheDeletionResponse, AssistantListModelsRequest, AssistantManagedSkillsResponse, AssistantMeshList, AssistantModelCatalogRevision, AssistantModelInfoList, AssistantOkResponse, AssistantSkillCatalogResponse, AssistantSkillFileResponse, AssistantSpeakRequest, AssistantSpeakResponse, AssistantToolCatalogResponse, AssistantTranscribeRequest, AssistantTranscribeResponse } from '../spec/index.d.ts';
|
|
8
8
|
import { type BlindPeeringOpts } from './core/blind-peers.ts';
|
|
9
9
|
import { type IndexingEmbedder, type RagExtractors, type VectorIndex } from './core/files/index.ts';
|
|
10
10
|
import { type DriveHost } from './core/fs-drives.ts';
|
|
11
11
|
import { type MeshInvite } from './core/invite.ts';
|
|
12
12
|
import { openLocalStore } from './core/local/index.ts';
|
|
13
|
+
import { type ArchivedMeshContents, type ArchivedMeshMigration } from './core/archived-mesh.ts';
|
|
14
|
+
import type { Duplex as LoanStreamDuplex } from 'streamx';
|
|
13
15
|
import { type SecretRequest } from './core/secret-handoff.ts';
|
|
14
16
|
import type { AppBuildMetadata } from './core/app-build.ts';
|
|
15
17
|
import { Mesh, type DeviceMetadata } from './core/mesh.ts';
|
|
@@ -100,6 +102,9 @@ export declare class Core extends ReadyResource {
|
|
|
100
102
|
private readonly _otaConfigCore;
|
|
101
103
|
private _otaConfig;
|
|
102
104
|
private _configPeering;
|
|
105
|
+
private _recoveryCore;
|
|
106
|
+
private _recoverySigner;
|
|
107
|
+
private _recoveryPeering;
|
|
103
108
|
private _localDevice;
|
|
104
109
|
private readonly _blindPeerKeys;
|
|
105
110
|
private readonly _blindPeeringOpts;
|
|
@@ -155,6 +160,8 @@ export declare class Core extends ReadyResource {
|
|
|
155
160
|
private _blobServer;
|
|
156
161
|
private readonly _wakeup;
|
|
157
162
|
private readonly _meshSeedHandoff;
|
|
163
|
+
private readonly _harnessLoan;
|
|
164
|
+
private _serveLoanedHarness;
|
|
158
165
|
private readonly _following;
|
|
159
166
|
private readonly _secretHandoff;
|
|
160
167
|
private readonly _skillOverlayHandoff;
|
|
@@ -207,6 +214,19 @@ export declare class Core extends ReadyResource {
|
|
|
207
214
|
private _openMesh;
|
|
208
215
|
private _openMeshSession;
|
|
209
216
|
private _mintBirthMember;
|
|
217
|
+
publishAccountRecovery(mnemonic: string): Promise<boolean>;
|
|
218
|
+
accountRecoverable(): Promise<boolean>;
|
|
219
|
+
private _publishRecovery;
|
|
220
|
+
private _markRecoverable;
|
|
221
|
+
private _openOwnRecoveryCore;
|
|
222
|
+
private _adoptRecoveryCore;
|
|
223
|
+
recoverAccount(mnemonic: string, { timeout }?: {
|
|
224
|
+
timeout?: number;
|
|
225
|
+
}): Promise<void>;
|
|
226
|
+
private _recoverAccount;
|
|
227
|
+
private _readRecovery;
|
|
228
|
+
private _peerRecoveryCore;
|
|
229
|
+
private _closeRecovery;
|
|
210
230
|
private _joinBirthMember;
|
|
211
231
|
private _holdIdentityPhrase;
|
|
212
232
|
private _pushIdentityPhrase;
|
|
@@ -215,6 +235,7 @@ export declare class Core extends ReadyResource {
|
|
|
215
235
|
private _advertiseDeviceProfile;
|
|
216
236
|
private _advertiseAppVersion;
|
|
217
237
|
private _settleMembership;
|
|
238
|
+
private _renameFoundedMember;
|
|
218
239
|
private _claimOwnMembership;
|
|
219
240
|
private _knownMember;
|
|
220
241
|
private _migrationContext;
|
|
@@ -277,11 +298,17 @@ export declare class Core extends ReadyResource {
|
|
|
277
298
|
private _homeMeshKey;
|
|
278
299
|
private _writableFallback;
|
|
279
300
|
listMeshes(): Promise<AssistantMeshList>;
|
|
280
|
-
|
|
301
|
+
listArchivedMeshes(): Promise<AssistantArchivedMeshList>;
|
|
302
|
+
archivedMeshContents(meshId: string): Promise<ArchivedMeshContents>;
|
|
303
|
+
migrateArchivedMesh(meshId: string): Promise<ArchivedMeshMigration>;
|
|
304
|
+
private _archivedRow;
|
|
305
|
+
private _withArchivedMesh;
|
|
306
|
+
private _ownRooms;
|
|
281
307
|
private _isOwnRoomIn;
|
|
282
308
|
setMeshLabel(meshId: string, label: string): Promise<void>;
|
|
283
|
-
createRoom({ shared }?: {
|
|
309
|
+
createRoom({ shared, compute }?: {
|
|
284
310
|
shared?: boolean;
|
|
311
|
+
compute?: boolean;
|
|
285
312
|
}): Promise<string>;
|
|
286
313
|
sharedRoom(): Promise<SharedRoom>;
|
|
287
314
|
private _occupancyNotice;
|
|
@@ -299,6 +326,9 @@ export declare class Core extends ReadyResource {
|
|
|
299
326
|
private _meshKeyOf;
|
|
300
327
|
removeDeviceWriter(writerKey: Buffer, deviceId: Buffer): Promise<void>;
|
|
301
328
|
renameLocalDevice(name: string): Promise<void>;
|
|
329
|
+
displayName(): Promise<string | null>;
|
|
330
|
+
private _accountMemberName;
|
|
331
|
+
setDisplayName(name: string): Promise<void>;
|
|
302
332
|
saveDeviceProfileLocal(capabilityProfile: DeviceMetadata['capabilityProfile'], recommendedModelName: string, platform?: string): Promise<void>;
|
|
303
333
|
waitForWritable(): Promise<void>;
|
|
304
334
|
private _assertRoomIsHere;
|
|
@@ -307,8 +337,16 @@ export declare class Core extends ReadyResource {
|
|
|
307
337
|
pushSkillSecret(request: SecretRequest): Promise<void>;
|
|
308
338
|
private _storeHandedOffSecret;
|
|
309
339
|
private _followJoinedRooms;
|
|
340
|
+
private _retireLeftRoom;
|
|
341
|
+
private _archiveLeftRoomRow;
|
|
310
342
|
private _openFollowedRoom;
|
|
311
343
|
private _requestRoomSeed;
|
|
344
|
+
registerLoanableHarness(serve: (stream: LoanStreamDuplex) => void): () => void;
|
|
345
|
+
borrowHarness(deviceId: string): LoanStreamDuplex;
|
|
346
|
+
private _lendHarness;
|
|
347
|
+
private _revalidateLoans;
|
|
348
|
+
private _computeLender;
|
|
349
|
+
private _sharesComputeMesh;
|
|
312
350
|
private _serveMeshSeed;
|
|
313
351
|
private _isJoinedRoomKey;
|
|
314
352
|
private _isOwnMemberDevice;
|
|
@@ -321,6 +359,7 @@ export declare class Core extends ReadyResource {
|
|
|
321
359
|
private _onConnection;
|
|
322
360
|
private _trackPeerConnection;
|
|
323
361
|
private _onPeerChange;
|
|
362
|
+
private _currentMeshAccessor;
|
|
324
363
|
private _meshStatusSource;
|
|
325
364
|
private _networkStatusSource;
|
|
326
365
|
private _networkSnapshot;
|