@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
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { requireMesh } from
|
|
2
|
-
import { watchable } from
|
|
3
|
-
export { MAX_KNOWLEDGE_BYTES } from
|
|
1
|
+
import { requireMesh, selectionPin } from './current-mesh.js';
|
|
2
|
+
import { watchable } from './watchable.js';
|
|
3
|
+
export { MAX_KNOWLEDGE_BYTES } from '../core/files/knowledge.js';
|
|
4
4
|
export function createKnowledgeApi(current, options = {}) {
|
|
5
5
|
return {
|
|
6
6
|
async *uploadKnowledge(frames) {
|
|
@@ -13,14 +13,18 @@ export function createKnowledgeApi(current, options = {}) {
|
|
|
13
13
|
return (await requireMesh(current)).files.knowledge(options).removeKnowledge(request);
|
|
14
14
|
},
|
|
15
15
|
async listKnowledge(request) {
|
|
16
|
-
return (await requireMesh(current)).files
|
|
16
|
+
return (await requireMesh(current, request?.meshId)).files
|
|
17
|
+
.knowledge(options)
|
|
18
|
+
.listKnowledge(request);
|
|
17
19
|
},
|
|
18
20
|
async listIndexing(request) {
|
|
19
|
-
return (await requireMesh(current)).files
|
|
21
|
+
return (await requireMesh(current, request?.meshId)).files
|
|
22
|
+
.knowledge(options)
|
|
23
|
+
.listIndexing(request);
|
|
20
24
|
},
|
|
21
|
-
knowledgeWatch: watchable('knowledgeWatch', () => requireMesh(current), async (request, mesh) => mesh.files.knowledge(options).listKnowledge(request)),
|
|
22
|
-
indexingWatch: watchable('indexingWatch', async () => (await requireMesh(current)).files, ({ chatId }, files) => files.listIndexing(chatId)),
|
|
23
|
-
fileStatusWatch: watchable('fileStatusWatch', async () => (await requireMesh(current)).files, ({ chatId }, files) => files.status(chatId)),
|
|
24
|
-
indexingProgressWatch: watchable('indexingProgressWatch', async () => (await requireMesh(current)).files, ({ chatId }, files) => Promise.resolve({ entries: files.progress(chatId) }))
|
|
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))
|
|
25
29
|
};
|
|
26
30
|
}
|
package/dist-lib/lib/api/logs.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import type { openLocalStore } from '../core/local/index.ts';
|
|
1
2
|
import { type CurrentMesh } from './current-mesh.ts';
|
|
2
3
|
import type { CapabilityHandlers } from '../../spec/capabilities.d.ts';
|
|
3
|
-
|
|
4
|
+
type LocalStore = Awaited<ReturnType<typeof openLocalStore>>;
|
|
5
|
+
export declare function createMembersApi(current: CurrentMesh, state?: LocalStore | null): Pick<CapabilityHandlers, 'listMembers' | 'membersWatch' | 'updateMember' | 'removeMember'>;
|
|
6
|
+
export {};
|
|
@@ -1,23 +1,92 @@
|
|
|
1
|
-
import { requireMesh } from
|
|
1
|
+
import { meshWatchable, requireMesh } from './current-mesh.js';
|
|
2
2
|
const MEMBERS = '@qvac/members';
|
|
3
|
-
|
|
3
|
+
const DEVICES = '@qvac/devices';
|
|
4
|
+
const RESOLVE_MEMBER_MS = 10_000;
|
|
5
|
+
async function resolveOurMember(mesh) {
|
|
6
|
+
let timer = null;
|
|
7
|
+
try {
|
|
8
|
+
await Promise.race([
|
|
9
|
+
mesh.refreshOurMember(),
|
|
10
|
+
new Promise((_, reject) => {
|
|
11
|
+
timer = setTimeout(() => reject(new Error('resolving our member in this mesh timed out')), RESOLVE_MEMBER_MS);
|
|
12
|
+
})
|
|
13
|
+
]);
|
|
14
|
+
}
|
|
15
|
+
finally {
|
|
16
|
+
if (timer)
|
|
17
|
+
clearTimeout(timer);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function toEngineMember(member, removed) {
|
|
21
|
+
return { id: member.id, name: member.name, joinedAt: member.joinedAt, removed };
|
|
22
|
+
}
|
|
23
|
+
async function liveMemberIds(snap) {
|
|
24
|
+
const live = new Set();
|
|
25
|
+
for await (const device of snap.find(DEVICES)) {
|
|
26
|
+
const owner = device.revoked ? null : (device.memberId ?? device.claimedMemberId);
|
|
27
|
+
if (owner)
|
|
28
|
+
live.add(owner.toString('hex'));
|
|
29
|
+
}
|
|
30
|
+
return live;
|
|
31
|
+
}
|
|
32
|
+
export function createMembersApi(current, state = null) {
|
|
33
|
+
const mustGetMember = async (reader, id) => {
|
|
34
|
+
const member = await reader.get(MEMBERS, { id });
|
|
35
|
+
if (!member)
|
|
36
|
+
throw new Error(`member not found: ${id.toString('hex')}`);
|
|
37
|
+
return member;
|
|
38
|
+
};
|
|
39
|
+
const list = async (mesh) => {
|
|
40
|
+
const snap = mesh.view.snapshot();
|
|
41
|
+
try {
|
|
42
|
+
const live = await liveMemberIds(snap);
|
|
43
|
+
const members = await snap.find(MEMBERS).toArray();
|
|
44
|
+
return {
|
|
45
|
+
members: members.map((member) => toEngineMember(member, !live.has(member.id.toString('hex'))))
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
finally {
|
|
49
|
+
await snap.close();
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
const readMember = async (mesh, id) => {
|
|
53
|
+
const snap = mesh.view.snapshot();
|
|
54
|
+
try {
|
|
55
|
+
const member = await mustGetMember(snap, id);
|
|
56
|
+
return toEngineMember(member, !(await liveMemberIds(snap)).has(id.toString('hex')));
|
|
57
|
+
}
|
|
58
|
+
finally {
|
|
59
|
+
await snap.close();
|
|
60
|
+
}
|
|
61
|
+
};
|
|
4
62
|
return {
|
|
5
|
-
listMembers: async () =>
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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();
|
|
68
|
+
if (!trimmed)
|
|
69
|
+
throw new Error('member name must not be empty');
|
|
70
|
+
const member = await mustGetMember(mesh.view, id);
|
|
71
|
+
if (!mesh.ourMemberId)
|
|
72
|
+
await mesh.refreshOurMember();
|
|
73
|
+
if (mesh.ourMemberId?.equals(id))
|
|
74
|
+
await state?.saveDisplayName(trimmed);
|
|
75
|
+
await mesh.dispatch('update-member', {
|
|
76
|
+
member: { ...member, name: trimmed, updatedAt: Date.now() }
|
|
77
|
+
});
|
|
78
|
+
return readMember(mesh, id);
|
|
79
|
+
},
|
|
80
|
+
removeMember: async ({ id, meshId }) => {
|
|
81
|
+
const mesh = await requireMesh(current, meshId);
|
|
82
|
+
if (!mesh.ourMemberId)
|
|
83
|
+
await resolveOurMember(mesh);
|
|
84
|
+
if (!mesh.ourMemberId)
|
|
85
|
+
throw new Error('this device is in no member of this mesh');
|
|
86
|
+
if (mesh.ourMemberId.equals(id))
|
|
87
|
+
throw new Error('cannot remove own member, use leaveMesh');
|
|
88
|
+
await mesh.dispatch('remove-member', { memberId: id, revokedAt: Date.now() });
|
|
89
|
+
return { ok: true };
|
|
21
90
|
}
|
|
22
91
|
};
|
|
23
92
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AssistantMeshList, AssistantMeshStatus } from '../../spec/hyperschema/types.d.ts';
|
|
1
|
+
import type { 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;
|
|
@@ -19,6 +19,16 @@ export interface MeshStatusSource {
|
|
|
19
19
|
select(meshId: string): Promise<void>;
|
|
20
20
|
close(meshId: string): Promise<void>;
|
|
21
21
|
label(meshId: string, label: string): Promise<void>;
|
|
22
|
-
createRoom(
|
|
22
|
+
createRoom(opts?: {
|
|
23
|
+
compute?: boolean;
|
|
24
|
+
}): Promise<string>;
|
|
25
|
+
listArchived(): Promise<AssistantArchivedMeshList>;
|
|
26
|
+
archivedContents(meshId: string): Promise<AssistantArchivedMeshContents>;
|
|
27
|
+
migrateArchived(meshId: string): Promise<AssistantArchivedMeshMigration>;
|
|
28
|
+
recoverable(): Promise<boolean>;
|
|
29
|
+
publishRecovery(phrase: string): Promise<void>;
|
|
30
|
+
recover(phrase: string, timeout?: number): Promise<void>;
|
|
31
|
+
displayName(): Promise<string | null>;
|
|
32
|
+
setDisplayName(name: string): Promise<void>;
|
|
23
33
|
}
|
|
24
|
-
export declare function createMeshApi(status: MeshStatusSource): Pick<CapabilityHandlers, 'meshStatusWatch' | 'listMeshes' | 'meshesWatch' | 'openMesh' | 'selectMesh' | 'closeMesh' | 'leaveMesh' | 'acknowledgeKicked' | 'joinMesh' | 'cancelMeshJoin' | 'meshInvite' | 'setMeshLabel' | 'createRoom'>;
|
|
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'>;
|
package/dist-lib/lib/api/mesh.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { watchable } from
|
|
1
|
+
import { watchable } from './watchable.js';
|
|
2
2
|
export function createMeshApi(status) {
|
|
3
3
|
return {
|
|
4
4
|
meshStatusWatch: watchable('meshStatusWatch', () => status, async () => status.snapshot()),
|
|
@@ -37,6 +37,29 @@ export function createMeshApi(status) {
|
|
|
37
37
|
await status.label(meshId, label ?? '');
|
|
38
38
|
return { ok: true };
|
|
39
39
|
},
|
|
40
|
-
createRoom: async () => ({
|
|
40
|
+
createRoom: async (request) => ({
|
|
41
|
+
meshId: await status.createRoom({ compute: request?.compute })
|
|
42
|
+
}),
|
|
43
|
+
listArchivedMeshes: () => status.listArchived(),
|
|
44
|
+
archivedMeshContents: ({ meshId }) => status.archivedContents(meshId),
|
|
45
|
+
migrateArchivedMesh: ({ meshId }) => status.migrateArchived(meshId),
|
|
46
|
+
accountRecoverable: async () => ({
|
|
47
|
+
recoverable: await status.recoverable()
|
|
48
|
+
}),
|
|
49
|
+
recoveryPublish: async ({ phrase }) => {
|
|
50
|
+
await status.publishRecovery(phrase);
|
|
51
|
+
return { recoverable: await status.recoverable() };
|
|
52
|
+
},
|
|
53
|
+
recoverAccount: async ({ phrase, timeout }) => {
|
|
54
|
+
await status.recover(phrase, timeout || undefined);
|
|
55
|
+
return { ok: true };
|
|
56
|
+
},
|
|
57
|
+
displayName: async () => ({
|
|
58
|
+
name: await status.displayName()
|
|
59
|
+
}),
|
|
60
|
+
setDisplayName: async ({ name }) => {
|
|
61
|
+
await status.setDisplayName(name ?? '');
|
|
62
|
+
return { ok: true };
|
|
63
|
+
}
|
|
41
64
|
};
|
|
42
65
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { deriveNotifications } from
|
|
2
|
-
import { requireMesh } from
|
|
3
|
-
import { watchable } from
|
|
1
|
+
import { deriveNotifications } from '../core/notification.js';
|
|
2
|
+
import { requireMesh } from './current-mesh.js';
|
|
3
|
+
import { watchable } from './watchable.js';
|
|
4
4
|
export function createNotificationsApi(current, local, options = {}) {
|
|
5
5
|
return {
|
|
6
6
|
notificationsWatch: watchable('notificationsWatch', () => notificationSource(current, local, options), (request) => notificationSnapshot(current, local, request?.limit, options.deviceId)),
|
package/dist-lib/lib/api/rag.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import '../logger.js';
|
|
2
2
|
import { toolsetEnabled } from '@qvac/harness/lib/tools/toolsets.ts';
|
|
3
|
-
import { getAgent } from
|
|
4
|
-
import { getChat } from
|
|
5
|
-
import { isKnowledgeRoutedAttachment, fullTextBudgetChars, fullTextHits, retrieveRagKnowledge, searchRagChunks, referencesPendingFile, referencedDocuments } from
|
|
6
|
-
import { requireMesh } from
|
|
3
|
+
import { getAgent } from '../core/agent.js';
|
|
4
|
+
import { getChat } from '../core/chat.js';
|
|
5
|
+
import { isKnowledgeRoutedAttachment, fullTextBudgetChars, fullTextHits, retrieveRagKnowledge, searchRagChunks, referencesPendingFile, referencedDocuments } from '../core/files/index.js';
|
|
6
|
+
import { requireMesh } from './current-mesh.js';
|
|
7
7
|
export const MAX_RAG_SEARCH_LIMIT = 20;
|
|
8
8
|
const DEFAULT_RAG_SEARCH_LIMIT = 5;
|
|
9
9
|
function clampLimit(limit) {
|
|
@@ -13,10 +13,10 @@ function clampLimit(limit) {
|
|
|
13
13
|
}
|
|
14
14
|
export function createRagApi(current, index, embedder, effectiveCtxSize = null) {
|
|
15
15
|
return {
|
|
16
|
-
ragSearch: async ({ chatId, query, mode, limit, attachmentIds }) => {
|
|
16
|
+
ragSearch: async ({ chatId, query, mode, limit, attachmentIds, meshId }) => {
|
|
17
17
|
let pendingFiles = [];
|
|
18
18
|
const respond = (overrides) => response({ pendingFiles, ...overrides });
|
|
19
|
-
const mesh = await requireMesh(current);
|
|
19
|
+
const mesh = await requireMesh(current, meshId);
|
|
20
20
|
const chat = await getChat(mesh, chatId);
|
|
21
21
|
const toolMode = mode === 'tool';
|
|
22
22
|
if (!chat)
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { CapabilityHandlers } from '../../spec/capabilities.d.ts';
|
|
2
|
-
import type
|
|
2
|
+
import { type CurrentMesh } from './current-mesh.ts';
|
|
3
3
|
export declare function createSyncApi(current: CurrentMesh): Pick<CapabilityHandlers, 'syncStatusWatch'>;
|
package/dist-lib/lib/api/sync.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { selectionPin } from './current-mesh.js';
|
|
2
|
+
import { watchable } from './watchable.js';
|
|
2
3
|
export function createSyncApi(current) {
|
|
3
4
|
return {
|
|
4
|
-
syncStatusWatch: watchable('syncStatusWatch', async () => (await current())?.syncActivity ?? null, (_request, activity) => activity.snapshot())
|
|
5
|
+
syncStatusWatch: watchable('syncStatusWatch', async () => (await current())?.syncActivity ?? null, (_request, activity) => activity.snapshot(), () => selectionPin(current))
|
|
5
6
|
};
|
|
6
7
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { listToolActivity, recordToolActivity } from
|
|
2
|
-
import { requireMesh } from
|
|
3
|
-
import { watchable } from
|
|
1
|
+
import { listToolActivity, recordToolActivity } from '../core/tool-activity.js';
|
|
2
|
+
import { requireMesh, selectionPin } from './current-mesh.js';
|
|
3
|
+
import { watchable } from './watchable.js';
|
|
4
4
|
const DEFAULT_LIMIT = 200;
|
|
5
5
|
const MAX_LIMIT = 1000;
|
|
6
6
|
const DECISIONS = new Set(['auto', 'allowed', 'denied', 'skip-all', 'blocked']);
|
|
@@ -32,11 +32,11 @@ export function createToolActivityApi(current, deviceId) {
|
|
|
32
32
|
});
|
|
33
33
|
return {
|
|
34
34
|
listToolActivity: async (request) => query(request, await requireMesh(current)),
|
|
35
|
-
toolActivityWatch: watchable('toolActivityWatch', () => requireMesh(current), query),
|
|
35
|
+
toolActivityWatch: watchable('toolActivityWatch', () => requireMesh(current), query, () => selectionPin(current)),
|
|
36
36
|
recordToolActivity: async (request) => {
|
|
37
37
|
if (!deviceId)
|
|
38
38
|
throw new Error('cannot record tool activity without a device id');
|
|
39
|
-
return recordToolActivity(await requireMesh(current), {
|
|
39
|
+
return recordToolActivity(await requireMesh(current, request.meshId), {
|
|
40
40
|
agentId: request.agentId,
|
|
41
41
|
originDeviceId: deviceId,
|
|
42
42
|
toolName: request.toolName,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { deleteToolConfigs, getToolConfigs, listToolConfigs, setToolConfigs } from
|
|
2
|
-
import { requireMesh } from
|
|
3
|
-
import { watchable } from
|
|
1
|
+
import { deleteToolConfigs, getToolConfigs, listToolConfigs, setToolConfigs } from '../core/tool-configs.js';
|
|
2
|
+
import { requireMesh, selectionPin } from './current-mesh.js';
|
|
3
|
+
import { watchable } from './watchable.js';
|
|
4
4
|
function isRecord(value) {
|
|
5
5
|
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
6
6
|
}
|
|
@@ -20,8 +20,8 @@ export function createToolConfigsApi(current) {
|
|
|
20
20
|
settings: ensureSettingsPayload(settings)
|
|
21
21
|
}),
|
|
22
22
|
deleteToolConfigs: async ({ agentId, toolName }) => deleteToolConfigs(await requireMesh(current), agentId, toolName),
|
|
23
|
-
listToolConfigs: async (request) => query(request, await requireMesh(current)),
|
|
24
|
-
toolConfigsWatch: watchable('toolConfigsWatch', () => requireMesh(current), query)
|
|
23
|
+
listToolConfigs: async (request) => query(request, await requireMesh(current, request.meshId)),
|
|
24
|
+
toolConfigsWatch: watchable('toolConfigsWatch', (request) => requireMesh(current, request?.meshId), query, (request) => selectionPin(current, request?.meshId))
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
27
|
export { getToolConfigs };
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { Readable } from 'streamx';
|
|
2
2
|
import '../logger.ts';
|
|
3
|
+
export interface WatchPin {
|
|
4
|
+
stale(): boolean;
|
|
5
|
+
watch(listener: () => void): void;
|
|
6
|
+
unwatch(listener: () => void): void;
|
|
7
|
+
}
|
|
3
8
|
interface WatchableStore {
|
|
4
9
|
watch(listener: () => void): void;
|
|
5
10
|
unwatch(listener: () => void): void;
|
|
@@ -8,5 +13,5 @@ interface WatchableStore {
|
|
|
8
13
|
closing?: unknown;
|
|
9
14
|
closed?: boolean;
|
|
10
15
|
}
|
|
11
|
-
export declare function watchable<TRequest, TResult, TStore extends WatchableStore = WatchableStore>(name: string, storeOf: (request: TRequest) => TStore | null | Promise<TStore | null>, query: (request: TRequest, store: TStore) => Promise<TResult
|
|
16
|
+
export declare function watchable<TRequest, TResult, TStore extends WatchableStore = WatchableStore>(name: string, storeOf: (request: TRequest) => TStore | null | Promise<TStore | null>, query: (request: TRequest, store: TStore) => Promise<TResult>, pinOf?: (request: TRequest) => WatchPin | null): (request: TRequest) => Readable & AsyncIterable<TResult>;
|
|
12
17
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import b4a from 'b4a';
|
|
2
2
|
import { Readable } from 'streamx';
|
|
3
|
-
import
|
|
3
|
+
import '../logger.js';
|
|
4
4
|
const SCOPE = ['api', 'watch'];
|
|
5
5
|
const CHURN_WINDOW_MS = 1000;
|
|
6
6
|
function snapshotEquals(a, b) {
|
|
@@ -24,8 +24,9 @@ function snapshotEquals(a, b) {
|
|
|
24
24
|
function isRecord(value) {
|
|
25
25
|
return typeof value === 'object' && value !== null;
|
|
26
26
|
}
|
|
27
|
-
export function watchable(name, storeOf, query) {
|
|
27
|
+
export function watchable(name, storeOf, query, pinOf) {
|
|
28
28
|
return (request) => {
|
|
29
|
+
const pin = pinOf?.(request) ?? null;
|
|
29
30
|
const resolved = storeOf(request);
|
|
30
31
|
const pending = resolved instanceof Promise ? resolved.catch(noop) : null;
|
|
31
32
|
let store = resolved instanceof Promise ? null : resolved;
|
|
@@ -56,13 +57,22 @@ export function watchable(name, storeOf, query) {
|
|
|
56
57
|
wake?.resolve();
|
|
57
58
|
wake = null;
|
|
58
59
|
};
|
|
59
|
-
const
|
|
60
|
+
const onPinMove = () => {
|
|
61
|
+
if (pin?.stale())
|
|
62
|
+
onStoreClose();
|
|
63
|
+
};
|
|
64
|
+
const storeGone = () => store === null ||
|
|
65
|
+
ended ||
|
|
66
|
+
Boolean(store.closed) ||
|
|
67
|
+
Boolean(store.closing) ||
|
|
68
|
+
Boolean(pin?.stale());
|
|
60
69
|
const stream = new Readable({
|
|
61
70
|
async open(cb) {
|
|
62
71
|
if (pending)
|
|
63
72
|
store = (await pending) ?? null;
|
|
64
73
|
store?.watch(onChange);
|
|
65
74
|
store?.once?.('close', onStoreClose);
|
|
75
|
+
pin?.watch(onPinMove);
|
|
66
76
|
cb(null);
|
|
67
77
|
},
|
|
68
78
|
async read(cb) {
|
|
@@ -112,6 +122,7 @@ export function watchable(name, storeOf, query) {
|
|
|
112
122
|
reportChurn(true);
|
|
113
123
|
store?.unwatch(onChange);
|
|
114
124
|
store?.off?.('close', onStoreClose);
|
|
125
|
+
pin?.unwatch(onPinMove);
|
|
115
126
|
cb(null);
|
|
116
127
|
}
|
|
117
128
|
});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import defaultFetch from '#fetch';
|
|
2
|
+
import { type AbortSignal } from 'bare-abort-controller';
|
|
3
|
+
export type FetchBody = Awaited<ReturnType<typeof defaultFetch>>['body'];
|
|
4
|
+
export declare function raceInactivity<T>(promise: Promise<T>, signal: AbortSignal | undefined, timeoutMs: number): Promise<T>;
|
|
5
|
+
export declare function drainBody(body: FetchBody, signal: AbortSignal | undefined, timeoutMs: number): Promise<Uint8Array | null>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import defaultFetch from '#fetch';
|
|
2
|
+
import b4a from 'b4a';
|
|
3
|
+
import {} from 'bare-abort-controller';
|
|
4
|
+
import { raceAbort } from '@qvac/harness/race-abort';
|
|
5
|
+
export async function raceInactivity(promise, signal, timeoutMs) {
|
|
6
|
+
let timer = null;
|
|
7
|
+
const expired = new Promise((_, reject) => {
|
|
8
|
+
timer = setTimeout(() => reject(new Error('blob read timed out')), timeoutMs);
|
|
9
|
+
});
|
|
10
|
+
try {
|
|
11
|
+
return await raceAbort(Promise.race([promise, expired]), signal);
|
|
12
|
+
}
|
|
13
|
+
finally {
|
|
14
|
+
if (timer !== null)
|
|
15
|
+
clearTimeout(timer);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export async function drainBody(body, signal, timeoutMs) {
|
|
19
|
+
if (!body)
|
|
20
|
+
return null;
|
|
21
|
+
const reader = body.getReader();
|
|
22
|
+
const parts = [];
|
|
23
|
+
try {
|
|
24
|
+
for (;;) {
|
|
25
|
+
const read = await raceInactivity(reader.read(), signal, timeoutMs);
|
|
26
|
+
if (read.done)
|
|
27
|
+
break;
|
|
28
|
+
parts.push(b4a.from(read.value));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
await reader.cancel();
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
return b4a.concat(parts);
|
|
36
|
+
}
|