@qvac/core 0.2.1 → 0.2.2
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 +9 -4
- package/.claude/skills/pr-create/SKILL.md +24 -3
- package/.claude/skills/pr-review/SKILL.md +248 -40
- package/CLAUDE.md +1 -3
- 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 -9
- 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 +8 -8
- package/dist-lib/lib/api/chunks.js +11 -11
- package/dist-lib/lib/api/config.js +1 -1
- 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 +9 -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 +33 -33
- package/dist-lib/lib/api/instrument.js +1 -1
- package/dist-lib/lib/api/knowledge.js +4 -4
- 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 +88 -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.js +1 -1
- package/dist-lib/lib/api/tool-activity.js +4 -4
- package/dist-lib/lib/api/tool-configs.js +5 -5
- package/dist-lib/lib/api/watchable.js +1 -1
- 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 +32 -0
- package/dist-lib/lib/assistant/history.js +232 -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 +25 -285
- package/dist-lib/lib/assistant.js +250 -637
- 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 +1 -1
- package/dist-lib/lib/core/chunk.js +4 -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 +16 -3
- 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 +75 -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 +41 -3
- package/dist-lib/lib/core.js +525 -90
- 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 +4 -2
- 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 +96 -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.js +6 -6
- 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/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 +3 -3
- package/dist-lib/lib/oauth/token-exchange.js +1 -1
- package/dist-lib/lib/oauth.client.js +2 -2
- package/dist-lib/lib/oauth.js +12 -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.js +15 -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 +15 -9
- package/tui/README.md +7 -0
- package/tui/app.mjs +311 -14
- package/tui/lib/busy-words.mjs +57 -5
- package/tui/lib/export.mjs +1 -0
- package/tui/lib/render.mjs +9 -2
- package/tui/main.mjs +5 -2
|
@@ -1,12 +1,24 @@
|
|
|
1
|
-
import { trackActivity } from
|
|
1
|
+
import { trackActivity } from './activity.js';
|
|
2
|
+
import { sealed } from './seal.js';
|
|
3
|
+
import { verifyWriterClaim } from '../device-attestation.js';
|
|
2
4
|
const DEVICES = '@qvac/devices';
|
|
3
5
|
export function registerDeviceRoutes(router) {
|
|
4
|
-
router.add('@qvac/register-device', trackActivity(async ({ device }, { tx, node, log }) => {
|
|
6
|
+
router.add('@qvac/register-device', trackActivity(async ({ device }, { tx, node, meshPublicKey, log }) => {
|
|
5
7
|
const existing = await tx.get(DEVICES, { id: device.id });
|
|
6
8
|
if (existing) {
|
|
7
9
|
log?.debug('contract', 'register-device dropped: device already registered');
|
|
8
10
|
return;
|
|
9
11
|
}
|
|
12
|
+
const signed = verifyWriterClaim(device.deviceSignature, {
|
|
13
|
+
meshPublicKey,
|
|
14
|
+
deviceId: device.id,
|
|
15
|
+
writerKey: node.key,
|
|
16
|
+
joinedAt: device.joinedAt
|
|
17
|
+
});
|
|
18
|
+
if (!signed && (await sealed(tx))) {
|
|
19
|
+
log?.warn('contract', 'register-device dropped: the device did not sign for this writer');
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
10
22
|
const registered = {
|
|
11
23
|
id: device.id,
|
|
12
24
|
name: device.name,
|
|
@@ -25,7 +37,8 @@ export function registerDeviceRoutes(router) {
|
|
|
25
37
|
appBuild: device.appBuild,
|
|
26
38
|
appChannel: device.appChannel,
|
|
27
39
|
platform: device.platform,
|
|
28
|
-
readySkillNames: device.readySkillNames
|
|
40
|
+
readySkillNames: device.readySkillNames,
|
|
41
|
+
deviceSignature: signed ? device.deviceSignature : undefined
|
|
29
42
|
};
|
|
30
43
|
await tx.insert(DEVICES, registered);
|
|
31
44
|
return registered;
|
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
import { registerAgentRoutes } from
|
|
2
|
-
import { registerApprovalRuleRoutes } from
|
|
3
|
-
import { registerAttestationRoutes } from
|
|
4
|
-
import { registerChatRoutes } from
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
|
|
1
|
+
import { registerAgentRoutes } from './agents.js';
|
|
2
|
+
import { registerApprovalRuleRoutes } from './approval-rules.js';
|
|
3
|
+
import { registerAttestationRoutes } from './attestations.js';
|
|
4
|
+
import { registerChatRoutes } from './chat.js';
|
|
5
|
+
import { registerComputeDrops } from './compute.js';
|
|
6
|
+
import { registerChatGroupRoutes } from './chat-group.js';
|
|
7
|
+
import { registerChunkRoutes } from './chunks.js';
|
|
8
|
+
import { registerDeviceRoutes } from './devices.js';
|
|
9
|
+
import { registerIndexingRoutes } from './indexing.js';
|
|
10
|
+
import { registerKnowledgeRoutes } from './knowledge.js';
|
|
11
|
+
import { registerJoinedMeshRoutes } from './joined-meshes.js';
|
|
12
|
+
import { registerMemberRoutes } from './members.js';
|
|
13
|
+
import { registerSeedDefaultsRoutes } from './seed-defaults.js';
|
|
14
|
+
import { registerToolActivityRoutes } from './tool-activity.js';
|
|
15
|
+
import { registerToolConfigsRoutes } from './tool-configs.js';
|
|
16
|
+
import { registerWriterRoutes } from './writers.js';
|
|
17
|
+
export function registerRoutes(router, { compute = false } = {}) {
|
|
17
18
|
registerWriterRoutes(router);
|
|
18
19
|
registerChunkRoutes(router);
|
|
19
20
|
registerAgentRoutes(router);
|
|
@@ -29,4 +30,6 @@ export function registerRoutes(router) {
|
|
|
29
30
|
registerAttestationRoutes(router);
|
|
30
31
|
registerJoinedMeshRoutes(router);
|
|
31
32
|
registerMemberRoutes(router);
|
|
33
|
+
if (compute)
|
|
34
|
+
registerComputeDrops(router);
|
|
32
35
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { trackActivity } from
|
|
2
|
-
import { claimSource } from
|
|
1
|
+
import { trackActivity } from './activity.js';
|
|
2
|
+
import { claimSource } from '../files/index.js';
|
|
3
3
|
const INDEXING_STATUS = '@qvac/indexing-status';
|
|
4
4
|
const KNOWLEDGE_ARTIFACTS = '@qvac/knowledge-artifacts';
|
|
5
5
|
export const INDEXING_CLAIM_TTL_MS = 10 * 60 * 1000;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { liveDeviceForWriter, trackActivity } from
|
|
1
|
+
import { liveDeviceForWriter, trackActivity } from './activity.js';
|
|
2
2
|
const JOINED_MESHES = '@qvac/joined-meshes';
|
|
3
3
|
export function registerJoinedMeshRoutes(router) {
|
|
4
4
|
router.add('@qvac/put-joined-mesh', trackActivity(async ({ room }, { tx, node, log }) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { trackActivity } from
|
|
2
|
-
import { assertArtifactOutput } from
|
|
1
|
+
import { trackActivity } from './activity.js';
|
|
2
|
+
import { assertArtifactOutput } from '../files/index.js';
|
|
3
3
|
const CHATS = '@qvac/chats';
|
|
4
4
|
const KNOWLEDGE = '@qvac/knowledge';
|
|
5
5
|
const KNOWLEDGE_ARTIFACTS = '@qvac/knowledge-artifacts';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { bareDeviceProof, claimAttestation, verifyDeviceProof, verifyMemberClaim } from
|
|
2
|
-
import { liveDeviceForWriter, trackActivity } from
|
|
1
|
+
import { bareDeviceProof, claimAttestation, verifyDeviceProof, verifyMemberClaim } from '../identity.js';
|
|
2
|
+
import { liveDeviceForWriter, trackActivity } from './activity.js';
|
|
3
3
|
const DEVICES = '@qvac/devices';
|
|
4
4
|
const MEMBERS = '@qvac/members';
|
|
5
5
|
function hex(buffer) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { capToolActivityArguments } from
|
|
1
|
+
import { capToolActivityArguments } from '../../../schema/qvac.js';
|
|
2
2
|
const TOOL_ACTIVITY = '@qvac/tool-activity';
|
|
3
3
|
const TOOL_ACTIVITY_COUNTERS = '@qvac/tool-activity-counter';
|
|
4
4
|
export function registerToolActivityRoutes(router) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { toolConfigsWithinBounds } from
|
|
2
|
-
import { toolConfigsCarrySecret } from
|
|
3
|
-
import { trackActivity } from
|
|
1
|
+
import { toolConfigsWithinBounds } from '../../../schema/qvac.js';
|
|
2
|
+
import { toolConfigsCarrySecret } from '../tool-configs.js';
|
|
3
|
+
import { trackActivity } from './activity.js';
|
|
4
4
|
const TOOL_CONFIGS = '@qvac/tool-configs';
|
|
5
5
|
const AGENTS = '@qvac/agents';
|
|
6
6
|
export function registerToolConfigsRoutes(router) {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import crypto from 'hypercore-crypto';
|
|
2
|
-
import { markWriterRevoked, trackActivity } from
|
|
3
|
-
import { verifyWriterClaim } from
|
|
2
|
+
import { markWriterRevoked, trackActivity } from './activity.js';
|
|
3
|
+
import { verifyWriterClaim } from '../device-attestation.js';
|
|
4
|
+
import { sealed } from './seal.js';
|
|
4
5
|
const DEVICES = '@qvac/devices';
|
|
5
|
-
async function admitDevice({ tx, meshPublicKey, log }, id, device, writerKey, claim) {
|
|
6
|
+
async function admitDevice({ tx, node, meshPublicKey, log }, id, device, writerKey, claim) {
|
|
6
7
|
const existing = await tx.get(DEVICES, { id });
|
|
7
8
|
if (!device) {
|
|
8
9
|
if (!existing)
|
|
@@ -10,25 +11,34 @@ async function admitDevice({ tx, meshPublicKey, log }, id, device, writerKey, cl
|
|
|
10
11
|
log?.debug('contract', 'admission refused: no profile to weigh against the existing row');
|
|
11
12
|
return 'refused';
|
|
12
13
|
}
|
|
14
|
+
const signed = verifyWriterClaim(claim?.deviceSignature, {
|
|
15
|
+
meshPublicKey,
|
|
16
|
+
deviceId: id,
|
|
17
|
+
writerKey,
|
|
18
|
+
joinedAt: device.joinedAt
|
|
19
|
+
});
|
|
20
|
+
const bound = existing?.writerKey ?? null;
|
|
21
|
+
const rebinding = bound !== null && !bound.equals(writerKey);
|
|
22
|
+
const alreadyAdmitted = bound !== null && !rebinding && !existing?.revoked;
|
|
23
|
+
const reclaims = signed && existing && !existing.deviceSignature;
|
|
13
24
|
if (existing &&
|
|
25
|
+
!reclaims &&
|
|
14
26
|
(existing.revoked ? device.joinedAt <= existing.joinedAt : device.joinedAt < existing.joinedAt)) {
|
|
15
27
|
log?.debug('contract', 'admission refused: claim is not newer than the device row');
|
|
16
28
|
return 'refused';
|
|
17
29
|
}
|
|
18
|
-
if (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
})) {
|
|
30
|
+
if (alreadyAdmitted && !node.key.equals(writerKey)) {
|
|
31
|
+
log?.warn('contract', 'admission refused: another writer may not rewrite a live device row', {
|
|
32
|
+
id: id.toString('hex').slice(0, 16)
|
|
33
|
+
});
|
|
34
|
+
return 'refused';
|
|
35
|
+
}
|
|
36
|
+
if (!signed && (rebinding || (await sealed(tx)))) {
|
|
26
37
|
log?.warn('contract', 'admission refused: the device did not sign for this writer key', {
|
|
27
38
|
id: id.toString('hex').slice(0, 16)
|
|
28
39
|
});
|
|
29
40
|
return 'refused';
|
|
30
41
|
}
|
|
31
|
-
const alreadyAdmitted = existing && !existing.revoked && existing.writerKey?.equals(writerKey) === true;
|
|
32
42
|
await tx.insert(DEVICES, {
|
|
33
43
|
...existing,
|
|
34
44
|
name: device.name,
|
|
@@ -44,6 +54,7 @@ async function admitDevice({ tx, meshPublicKey, log }, id, device, writerKey, cl
|
|
|
44
54
|
appBuild: device.appBuild ?? existing?.appBuild,
|
|
45
55
|
appChannel: device.appChannel ?? existing?.appChannel,
|
|
46
56
|
platform: device.platform ?? existing?.platform,
|
|
57
|
+
deviceSignature: signed ? claim.deviceSignature : existing?.deviceSignature,
|
|
47
58
|
claimedMemberId: claim?.claimedMemberId ?? existing?.claimedMemberId,
|
|
48
59
|
inviteToken: claim?.inviteToken ?? existing?.inviteToken,
|
|
49
60
|
id,
|
|
@@ -52,15 +63,43 @@ async function admitDevice({ tx, meshPublicKey, log }, id, device, writerKey, cl
|
|
|
52
63
|
revokedAt: 0,
|
|
53
64
|
revokedBy: null
|
|
54
65
|
});
|
|
55
|
-
if (
|
|
56
|
-
await markWriterRevoked(tx,
|
|
57
|
-
}
|
|
66
|
+
if (rebinding)
|
|
67
|
+
await markWriterRevoked(tx, bound, true);
|
|
58
68
|
await markWriterRevoked(tx, writerKey, false);
|
|
59
69
|
if (!alreadyAdmitted) {
|
|
60
70
|
log?.info('contract', 'device admitted', { id: id.toString('hex').slice(0, 16) });
|
|
61
71
|
}
|
|
62
72
|
return 'admitted';
|
|
63
73
|
}
|
|
74
|
+
async function revokeWriter(payload, context) {
|
|
75
|
+
await context.host.removeWriter(payload.writerKey);
|
|
76
|
+
const id = payload.deviceId;
|
|
77
|
+
if (!id)
|
|
78
|
+
return;
|
|
79
|
+
const existing = await context.tx.get(DEVICES, { id });
|
|
80
|
+
if (!existing) {
|
|
81
|
+
context.log?.debug('contract', 'remove-writer: no device row to revoke');
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
if (existing.writerKey && !existing.writerKey.equals(payload.writerKey)) {
|
|
85
|
+
context.log?.debug('contract', 'remove-writer dropped: writer key already superseded');
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
const revoked = {
|
|
89
|
+
...existing,
|
|
90
|
+
revoked: true,
|
|
91
|
+
revokedAt: payload.revokedAt ?? 0,
|
|
92
|
+
revokedBy: context.node.key
|
|
93
|
+
};
|
|
94
|
+
await context.tx.insert(DEVICES, revoked);
|
|
95
|
+
await markWriterRevoked(context.tx, payload.writerKey, true);
|
|
96
|
+
context.log?.info('contract', 'writer removed, device revoked', {
|
|
97
|
+
id: id.toString('hex').slice(0, 16)
|
|
98
|
+
});
|
|
99
|
+
if (context.node.key.equals(payload.writerKey))
|
|
100
|
+
return;
|
|
101
|
+
return revoked;
|
|
102
|
+
}
|
|
64
103
|
export function registerWriterRoutes(router) {
|
|
65
104
|
router.add('@qvac/add-writer', trackActivity(async (payload, context) => {
|
|
66
105
|
if (!payload.device) {
|
|
@@ -73,34 +112,19 @@ export function registerWriterRoutes(router) {
|
|
|
73
112
|
await context.host.addWriter(payload.writerKey);
|
|
74
113
|
return payload.device;
|
|
75
114
|
}));
|
|
76
|
-
router.add('@qvac/remove-writer', trackActivity(
|
|
77
|
-
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
return;
|
|
115
|
+
router.add('@qvac/remove-writer', trackActivity(revokeWriter));
|
|
116
|
+
router.add('@qvac/remove-member', trackActivity(async ({ memberId, revokedAt }, context) => {
|
|
117
|
+
const removals = [];
|
|
118
|
+
for await (const device of context.tx.find(DEVICES)) {
|
|
119
|
+
const claims = device.memberId ?? device.claimedMemberId;
|
|
120
|
+
if (device.revoked || !device.writerKey || !claims?.equals(memberId))
|
|
121
|
+
continue;
|
|
122
|
+
removals.push({ writerKey: device.writerKey, deviceId: device.id, revokedAt });
|
|
85
123
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
const revoked = {
|
|
91
|
-
...existing,
|
|
92
|
-
revoked: true,
|
|
93
|
-
revokedAt: payload.revokedAt ?? 0,
|
|
94
|
-
revokedBy: context.node.key
|
|
95
|
-
};
|
|
96
|
-
await context.tx.insert(DEVICES, revoked);
|
|
97
|
-
await markWriterRevoked(context.tx, payload.writerKey, true);
|
|
98
|
-
context.log?.info('contract', 'writer removed, device revoked', {
|
|
99
|
-
id: id.toString('hex').slice(0, 16)
|
|
100
|
-
});
|
|
101
|
-
if (context.node.key.equals(payload.writerKey))
|
|
102
|
-
return;
|
|
103
|
-
return revoked;
|
|
124
|
+
let removed;
|
|
125
|
+
for (const removal of removals)
|
|
126
|
+
removed = (await revokeWriter(removal, context)) ?? removed;
|
|
127
|
+
return removed;
|
|
104
128
|
}));
|
|
105
129
|
router.add('@qvac/join', trackActivity(async (payload, context) => {
|
|
106
130
|
let valid = false;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import crypto from 'hypercore-crypto';
|
|
2
2
|
import ScopeLock from 'scope-lock';
|
|
3
|
-
import { deviceInviteToken } from
|
|
3
|
+
import { deviceInviteToken } from './identity.js';
|
|
4
4
|
const NONCES_KEY = 'device-invite-nonces';
|
|
5
5
|
export function openDeviceInvites(store) {
|
|
6
6
|
const lock = new ScopeLock();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { isAudioAttachment } from
|
|
2
|
-
import { IMAGE_MIMES } from
|
|
1
|
+
import { isAudioAttachment } from './audio-attachment.js';
|
|
2
|
+
import { IMAGE_MIMES } from './image/normalize.js';
|
|
3
3
|
export function isDocumentAttachment(ref) {
|
|
4
4
|
if (IMAGE_MIMES.has(ref.mimeType.toLowerCase()))
|
|
5
5
|
return false;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { linkAttachment } from
|
|
2
|
-
import { getChunk, updateChunk } from
|
|
3
|
-
import { uploadFile } from
|
|
1
|
+
import { linkAttachment } from '../attachment-link.js';
|
|
2
|
+
import { getChunk, updateChunk } from '../chunk.js';
|
|
3
|
+
import { uploadFile } from './upload.js';
|
|
4
4
|
export const MAX_ATTACHMENT_BYTES = 100 * 1024 * 1024;
|
|
5
5
|
export function attachmentFiles(mesh, { maxBytes = MAX_ATTACHMENT_BYTES, deviceId = null, inactivityMs } = {}) {
|
|
6
6
|
return {
|
|
@@ -43,8 +43,8 @@ export declare class Files extends EventEmitter {
|
|
|
43
43
|
inline(bytes: Buffer, mimeType: string): string;
|
|
44
44
|
reference(id: Parameters<BlobStore['reference']>[0]): string;
|
|
45
45
|
clear(reference: string, id: string): Promise<void>;
|
|
46
|
-
attachments(options?: Parameters<typeof attachmentFiles>[1]): Pick<import("../../../spec/capabilities").CapabilityHandlers, "
|
|
47
|
-
knowledge(options?: Parameters<typeof knowledgeFiles>[1]): Pick<import("../../../spec/capabilities").CapabilityHandlers, "
|
|
46
|
+
attachments(options?: Parameters<typeof attachmentFiles>[1]): Pick<import("../../../spec/capabilities").CapabilityHandlers, "deleteAttachment" | "downloadAttachment" | "uploadAttachment">;
|
|
47
|
+
knowledge(options?: Parameters<typeof knowledgeFiles>[1]): Pick<import("../../../spec/capabilities").CapabilityHandlers, "downloadKnowledge" | "listIndexing" | "listKnowledge" | "removeKnowledge" | "uploadKnowledge">;
|
|
48
48
|
listKnowledge(chatId: string): Promise<QvacKnowledge[]>;
|
|
49
49
|
record(id: string): Promise<QvacKnowledge | null>;
|
|
50
50
|
resolve(request: {
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import b4a from 'b4a';
|
|
2
2
|
import { Buffer } from 'buffer';
|
|
3
3
|
import EventEmitter from 'bare-events';
|
|
4
|
-
import { attachmentFiles } from
|
|
5
|
-
import { isKnowledgeRoutedAttachment, getKnowledge, listKnowledge, getKnowledgeArtifact, listKnowledgeArtifactsByKnowledge, addKnowledgeArtifact, hasLiveSource, syncAttachmentChunk, syncKnowledgeTombstone, syncArtifactArrival, sweepTombstonedBlobs, referencedBlobs, scopedFile, attachmentRecord, isProcessorOutput, isProcessorArtifactId } from
|
|
6
|
-
import { knowledgeFiles } from
|
|
7
|
-
import { randomId } from
|
|
8
|
-
import { getChunk, listChunks } from
|
|
9
|
-
import { settleFiles, isClaimLive, listIndexingByChat, FileState, FileProcessing } from
|
|
10
|
-
import { DeadlineScheduler } from
|
|
11
|
-
import { liveDeviceForWriter } from
|
|
12
|
-
import { BlobStore, parseBlobReference } from
|
|
4
|
+
import { attachmentFiles } from './attachments.js';
|
|
5
|
+
import { isKnowledgeRoutedAttachment, getKnowledge, listKnowledge, getKnowledgeArtifact, listKnowledgeArtifactsByKnowledge, addKnowledgeArtifact, hasLiveSource, syncAttachmentChunk, syncKnowledgeTombstone, syncArtifactArrival, sweepTombstonedBlobs, referencedBlobs, scopedFile, attachmentRecord, isProcessorOutput, isProcessorArtifactId } from './records/index.js';
|
|
6
|
+
import { knowledgeFiles } from './knowledge.js';
|
|
7
|
+
import { randomId } from '../id.js';
|
|
8
|
+
import { getChunk, listChunks } from '../chunk.js';
|
|
9
|
+
import { settleFiles, isClaimLive, listIndexingByChat, FileState, FileProcessing } from './processing/index.js';
|
|
10
|
+
import { DeadlineScheduler } from '../../deadline.js';
|
|
11
|
+
import { liveDeviceForWriter } from '../contract/activity.js';
|
|
12
|
+
import { BlobStore, parseBlobReference } from './store/index.js';
|
|
13
13
|
import { AbortedError } from '@qvac/harness/race-abort';
|
|
14
|
-
import { RagProcessor } from
|
|
15
|
-
import { PreviewProcessor, PREVIEW_VERSION, previewId } from
|
|
16
|
-
export { fullTextBudgetChars, fullTextHits, retrieveRagKnowledge, searchRagChunks, referencesPendingFile } from
|
|
17
|
-
export { isKnowledgeRoutedAttachment } from
|
|
18
|
-
export { assertRemovableAt } from
|
|
19
|
-
export { assertArtifactOutput } from
|
|
20
|
-
export { claimSource } from
|
|
14
|
+
import { RagProcessor } from './rag/index.js';
|
|
15
|
+
import { PreviewProcessor, PREVIEW_VERSION, previewId } from './preview/index.js';
|
|
16
|
+
export { fullTextBudgetChars, fullTextHits, retrieveRagKnowledge, searchRagChunks, referencesPendingFile } from './rag/index.js';
|
|
17
|
+
export { isKnowledgeRoutedAttachment } from './records/index.js';
|
|
18
|
+
export { assertRemovableAt } from './records/index.js';
|
|
19
|
+
export { assertArtifactOutput } from './records/index.js';
|
|
20
|
+
export { claimSource } from './records/index.js';
|
|
21
21
|
export class Files extends EventEmitter {
|
|
22
22
|
_mesh;
|
|
23
23
|
_uploads = new Map();
|
|
@@ -580,6 +580,6 @@ export class Files extends EventEmitter {
|
|
|
580
580
|
await this._store.close();
|
|
581
581
|
}
|
|
582
582
|
}
|
|
583
|
-
export { MemoryVectorIndex, RAG_KNOWLEDGE_OFF_NOTICE, RAG_TRUNCATED_NOTICE, RAG_UNAVAILABLE_NOTICE, WEB_TOOLS, chooseRagNotice, citedByPhraseOverlap, createRagSourceTagFilter, formatFullDocumentContext, formatRagContext, isFullTextHit, isWholeDocumentQuery, referencedDocuments, isTruncatedFullTextHit, sourcesFromHits, webSourcesFromToolResult, withoutDataChannel } from
|
|
584
|
-
export { attachTurnDocumentIds, groupAttachmentsByMessage } from
|
|
585
|
-
export { CoreBlobServer, parseBlobReferenceCoreKey } from
|
|
583
|
+
export { MemoryVectorIndex, RAG_KNOWLEDGE_OFF_NOTICE, RAG_TRUNCATED_NOTICE, RAG_UNAVAILABLE_NOTICE, WEB_TOOLS, chooseRagNotice, citedByPhraseOverlap, createRagSourceTagFilter, formatFullDocumentContext, formatRagContext, isFullTextHit, isWholeDocumentQuery, referencedDocuments, isTruncatedFullTextHit, sourcesFromHits, webSourcesFromToolResult, withoutDataChannel } from './rag/index.js';
|
|
584
|
+
export { attachTurnDocumentIds, groupAttachmentsByMessage } from './records/index.js';
|
|
585
|
+
export { CoreBlobServer, parseBlobReferenceCoreKey } from './store/index.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { listKnowledge, removeKnowledge } from
|
|
2
|
-
import { MAX_KNOWLEDGE_BYTES } from
|
|
3
|
-
import { uploadFile } from
|
|
1
|
+
import { listKnowledge, removeKnowledge } from './records/index.js';
|
|
2
|
+
import { MAX_KNOWLEDGE_BYTES } from './rag/index.js';
|
|
3
|
+
import { uploadFile } from './upload.js';
|
|
4
4
|
export { MAX_KNOWLEDGE_BYTES };
|
|
5
5
|
export function knowledgeFiles(mesh, { maxBytes = MAX_KNOWLEDGE_BYTES, inactivityMs, deviceId } = {}) {
|
|
6
6
|
const list = async ({ chatId }) => ({
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import b4a from 'b4a';
|
|
2
2
|
import { Buffer } from 'buffer';
|
|
3
3
|
import crypto from 'hypercore-crypto';
|
|
4
|
-
import { processorArtifactId } from
|
|
5
|
-
import { parseBlobReference } from
|
|
6
|
-
import { IMAGE_MIMES } from
|
|
7
|
-
import { previewEncoder } from
|
|
4
|
+
import { processorArtifactId } from '../records/index.js';
|
|
5
|
+
import { parseBlobReference } from '../store/index.js';
|
|
6
|
+
import { IMAGE_MIMES } from '../../image/normalize.js';
|
|
7
|
+
import { previewEncoder } from './image.js';
|
|
8
8
|
import { AbortedError } from '@qvac/harness/race-abort';
|
|
9
|
-
import { getChat } from
|
|
10
|
-
export { previewEncoder } from
|
|
9
|
+
import { getChat } from '../../chat.js';
|
|
10
|
+
export { previewEncoder } from './image.js';
|
|
11
11
|
export const PREVIEW_VERSION = 'processor:preview:1';
|
|
12
12
|
const RETRY_MS = 30_000;
|
|
13
13
|
export class PreviewProcessor {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {} from
|
|
2
|
-
import { IndexingClaims } from
|
|
3
|
-
import { ArtifactOwnership } from
|
|
4
|
-
import { listIndexingByKnowledge, resolveIndexing } from
|
|
5
|
-
import { fileRecord } from
|
|
1
|
+
import {} from '../rag/index.js';
|
|
2
|
+
import { IndexingClaims } from './claims.js';
|
|
3
|
+
import { ArtifactOwnership } from './ownership.js';
|
|
4
|
+
import { listIndexingByKnowledge, resolveIndexing } from './protocol.js';
|
|
5
|
+
import { fileRecord } from '../records/index.js';
|
|
6
6
|
export class FileDocument {
|
|
7
7
|
_mesh;
|
|
8
8
|
record;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { AbortController } from 'bare-abort-controller';
|
|
2
|
-
import {} from
|
|
3
|
-
import { DeadlineScheduler } from
|
|
4
|
-
import { IndexingSource } from
|
|
5
|
-
import { fileIds, fileRecord } from
|
|
6
|
-
import { FileDocument } from
|
|
2
|
+
import {} from '../rag/index.js';
|
|
3
|
+
import { DeadlineScheduler } from '../../../deadline.js';
|
|
4
|
+
import { IndexingSource } from './source.js';
|
|
5
|
+
import { fileIds, fileRecord } from '../records/index.js';
|
|
6
|
+
import { FileDocument } from './document.js';
|
|
7
7
|
export class FileProcessing {
|
|
8
8
|
_mesh;
|
|
9
9
|
_processor;
|
|
@@ -290,6 +290,6 @@ export class FileProcessing {
|
|
|
290
290
|
void this.enqueue(ids);
|
|
291
291
|
}
|
|
292
292
|
}
|
|
293
|
-
export { isClaimLive, listIndexingByChat } from
|
|
294
|
-
export { FileState } from
|
|
295
|
-
export { settleFiles } from
|
|
293
|
+
export { isClaimLive, listIndexingByChat } from './protocol.js';
|
|
294
|
+
export { FileState } from './state.js';
|
|
295
|
+
export { settleFiles } from './settle.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { INDEXING_MAX_CLOCK_SKEW_MS } from
|
|
2
|
-
import { randomId } from
|
|
3
|
-
export { INDEXING_CLAIM_TTL_MS, INDEXING_MAX_CLOCK_SKEW_MS } from
|
|
1
|
+
import { INDEXING_MAX_CLOCK_SKEW_MS } from '../../contract/indexing.js';
|
|
2
|
+
import { randomId } from '../../id.js';
|
|
3
|
+
export { INDEXING_CLAIM_TTL_MS, INDEXING_MAX_CLOCK_SKEW_MS } from '../../contract/indexing.js';
|
|
4
4
|
export function isClaimLive(row, at) {
|
|
5
5
|
return (row.status === 'indexing' && row.expiresAt > at && row.at <= at + INDEXING_MAX_CLOCK_SKEW_MS);
|
|
6
6
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isInvalidBlobReferenceError, compareBlobReferences } from
|
|
1
|
+
import { isInvalidBlobReferenceError, compareBlobReferences } from '../store/index.js';
|
|
2
2
|
import { AbortController } from 'bare-abort-controller';
|
|
3
3
|
import { AbortedError } from '@qvac/harness/race-abort';
|
|
4
4
|
const BLOB_RETRY_MS = 30_000;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import b4a from 'b4a';
|
|
2
|
-
import { ARTIFACT_FORMAT_VERSION, assertRagArtifactPayload } from
|
|
2
|
+
import { ARTIFACT_FORMAT_VERSION, assertRagArtifactPayload } from './types.js';
|
|
3
3
|
const MAGIC = b4a.from(ARTIFACT_FORMAT_VERSION, 'ascii');
|
|
4
4
|
const HEADER_LENGTH_BYTES = 4;
|
|
5
5
|
export function encodeRagArtifact(payload) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import b4a from 'b4a';
|
|
2
|
-
import { CHUNKER_VERSION, EMBEDDER_CODE_VERSION, EXTRACTOR_VERSION } from
|
|
2
|
+
import { CHUNKER_VERSION, EMBEDDER_CODE_VERSION, EXTRACTOR_VERSION } from './types.js';
|
|
3
3
|
export function contentHash(bytes) {
|
|
4
4
|
return stableHashBytes(bytes);
|
|
5
5
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export declare const DOCUMENT_INDEX_ARTIFACT_STATUS: {
|
|
2
|
-
readonly pending:
|
|
3
|
-
readonly indexing:
|
|
4
|
-
readonly ready:
|
|
5
|
-
readonly failed:
|
|
2
|
+
readonly pending: 'pending';
|
|
3
|
+
readonly indexing: 'indexing';
|
|
4
|
+
readonly ready: 'ready';
|
|
5
|
+
readonly failed: 'failed';
|
|
6
6
|
};
|
|
7
7
|
export type DocumentIndexArtifactStatus = (typeof DOCUMENT_INDEX_ARTIFACT_STATUS)[keyof typeof DOCUMENT_INDEX_ARTIFACT_STATUS];
|
|
8
8
|
export declare const EXTRACTOR_VERSION = "document-extractor-v1";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { chunkRagDocuments } from
|
|
2
|
-
import { extractRagDocumentFromBytes } from
|
|
1
|
+
import { chunkRagDocuments } from './chunk/chunking.js';
|
|
2
|
+
import { extractRagDocumentFromBytes } from './extract/extract.js';
|
|
3
3
|
import { AbortedError } from '@qvac/harness/race-abort';
|
|
4
4
|
const EMBED_BATCH = 8;
|
|
5
5
|
export class EmbedderFailure extends Error {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { buildRagChunkMetadata } from
|
|
2
|
-
import { tokenizeForRag } from
|
|
1
|
+
import { buildRagChunkMetadata } from './metadata.js';
|
|
2
|
+
import { tokenizeForRag } from './tokenizer.js';
|
|
3
3
|
const DEFAULT_CHUNK_SIZE = 256;
|
|
4
4
|
const DEFAULT_CHUNK_OVERLAP = 50;
|
|
5
5
|
export function chunkRagDocuments(documents, options) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export declare const RAG_ACCEPT_EXTENSIONS: readonly [
|
|
2
|
-
export declare const EXEC_ATTACHABLE_EXTENSIONS: readonly [
|
|
3
|
-
export declare const EXEC_ATTACHABLE_MIME_TYPES: readonly [
|
|
1
|
+
export declare const RAG_ACCEPT_EXTENSIONS: readonly ['.pdf', '.txt', '.md', '.markdown', '.rtf', '.html', '.htm', '.xhtml', '.log', '.json', '.jsonl', '.csv', '.tsv', '.xml', '.yaml', '.yml'];
|
|
2
|
+
export declare const EXEC_ATTACHABLE_EXTENSIONS: readonly ['.docx', '.xlsx', '.pptx'];
|
|
3
|
+
export declare const EXEC_ATTACHABLE_MIME_TYPES: readonly ['application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/vnd.openxmlformats-officedocument.presentationml.presentation'];
|
|
4
4
|
export declare function isExecAttachableDocument(input: {
|
|
5
5
|
readonly fileName?: string;
|
|
6
6
|
readonly mimeType?: string;
|