@wirecat/cli-core 0.662.0 → 0.664.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/CHANGELOG.md +213 -0
- package/dist/calendar/cli/bodies.js +2 -1
- package/dist/calendar/cli/index.js +13 -10
- package/dist/calendar/mcp/index.d.ts +3 -1
- package/dist/calendar/mcp/index.js +4 -4
- package/dist/cli/call-stats-command.d.ts +18 -0
- package/dist/cli/call-stats-command.js +52 -0
- package/dist/cli/chat-sending-command.d.ts +14 -0
- package/dist/cli/chat-sending-command.js +64 -0
- package/dist/cli/context.d.ts +7 -0
- package/dist/cli/context.js +12 -4
- package/dist/cli/contract-templates.js +2 -0
- package/dist/cli/envelope.d.ts +0 -5
- package/dist/cli/envelope.js +25 -0
- package/dist/cli/index.d.ts +4 -1
- package/dist/cli/index.js +4 -1
- package/dist/cli/meeting-batch.d.ts +2 -1
- package/dist/cli/meeting-batch.js +7 -5
- package/dist/cli/meeting-meaning-command.d.ts +47 -0
- package/dist/cli/meeting-meaning-command.js +136 -0
- package/dist/cli/meeting-preparation-answer.d.ts +6 -0
- package/dist/cli/meeting-preparation-command.js +5 -5
- package/dist/cli/meeting-preparation-projects.d.ts +6 -0
- package/dist/cli/meeting-preparation-read.d.ts +11 -5
- package/dist/cli/meeting-preparation-read.js +13 -21
- package/dist/cli/meeting-series-inventory-command.js +2 -2
- package/dist/cli/meeting-series-inventory-read.d.ts +2 -2
- package/dist/cli/meeting-series-inventory-read.js +7 -15
- package/dist/cli/meeting-tags-command.d.ts +18 -0
- package/dist/cli/meeting-tags-command.js +74 -0
- package/dist/cli/messenger/admin-statistics-command.js +2 -2
- package/dist/cli/messenger/conversation-answers.d.ts +1 -1
- package/dist/cli/messenger/conversation-answers.js +1 -0
- package/dist/cli/messenger/conversations-command.js +38 -12
- package/dist/cli/messenger/counters-command.js +2 -2
- package/dist/cli/messenger/media-archive-command.js +5 -4
- package/dist/cli/messenger/media-archive-move-command.js +1 -1
- package/dist/cli/messenger/media-archive-timer-command.js +5 -4
- package/dist/cli/messenger/metadata-command.js +3 -3
- package/dist/cli/messenger/models-command.js +7 -0
- package/dist/cli/messenger/rankings-command.js +3 -3
- package/dist/cli/messenger/records-command.d.ts +4 -1
- package/dist/cli/messenger/records-command.js +6 -1
- package/dist/cli/messenger/tags-command.js +7 -2
- package/dist/cli/messenger/tasks-command.js +2 -2
- package/dist/cli/model-catalogue-command.js +2 -0
- package/dist/cli/paging.d.ts +10 -0
- package/dist/cli/paging.js +29 -0
- package/dist/cli/profile-token.d.ts +15 -1
- package/dist/cli/profile-token.js +103 -7
- package/dist/cli/program.js +2 -2
- package/dist/cli/runs/command.js +6 -4
- package/dist/cli/runs/search-command.js +9 -5
- package/dist/cli/schedule/schedule-command.js +1 -5
- package/dist/domain/links.d.ts +11 -0
- package/dist/domain/links.js +4 -0
- package/dist/domain/moment.d.ts +29 -0
- package/dist/domain/moment.js +58 -0
- package/dist/domain/providers.d.ts +6 -4
- package/dist/domain/providers.js +10 -5
- package/dist/domain/send-time.d.ts +3 -4
- package/dist/domain/send-time.js +10 -24
- package/dist/entities/chat-sending.d.ts +10 -0
- package/dist/entities/chat-sending.js +11 -0
- package/dist/entities/fields.d.ts +2 -2
- package/dist/entities/fields.js +2 -2
- package/dist/entities/index.d.ts +135 -2
- package/dist/entities/index.js +8 -3
- package/dist/entities/meeting-preparation.d.ts +6 -0
- package/dist/entities/meeting.d.ts +1 -1
- package/dist/entities/meeting.js +1 -1
- package/dist/errors/reasons.js +25 -2
- package/dist/mail/cli/index.js +4 -2
- package/dist/mail/facts.d.ts +5 -2
- package/dist/mail/facts.js +6 -3
- package/dist/mail/index.d.ts +1 -1
- package/dist/mail/meeting-notes.js +1 -1
- package/dist/mail/probe.d.ts +5 -2
- package/dist/mail/probe.js +9 -5
- package/dist/mail/server-search.js +1 -1
- package/dist/mail/sync.js +1 -1
- package/dist/mcp/meeting-preparation.d.ts +6 -0
- package/dist/mcp/meeting-preparation.js +1 -1
- package/dist/mcp/meeting-series-inventory.js +1 -1
- package/dist/mcp/prompts.js +6 -9
- package/dist/meetings/answers.d.ts +7 -0
- package/dist/meetings/answers.js +4 -0
- package/dist/meetings/call-answers.d.ts +106 -0
- package/dist/meetings/call-answers.js +171 -0
- package/dist/meetings/call-stats.d.ts +121 -0
- package/dist/meetings/call-stats.js +211 -0
- package/dist/meetings/calls.d.ts +76 -0
- package/dist/meetings/calls.js +78 -0
- package/dist/meetings/cli/index.d.ts +8 -0
- package/dist/meetings/cli/index.js +10 -22
- package/dist/meetings/cli/search.d.ts +9 -2
- package/dist/meetings/cli/search.js +16 -26
- package/dist/meetings/index.d.ts +4 -0
- package/dist/meetings/index.js +4 -0
- package/dist/meetings/mcp/index.d.ts +6 -3
- package/dist/meetings/mcp/index.js +2 -4
- package/dist/meetings/mcp/search.d.ts +12 -1
- package/dist/meetings/mcp/search.js +3 -3
- package/dist/meetings/project-evidence-answer.d.ts +6 -0
- package/dist/meetings/read-through.d.ts +2 -1
- package/dist/meetings/read-through.js +10 -1
- package/dist/meetings/stats.d.ts +3 -0
- package/dist/meetings/stats.js +3 -3
- package/dist/meetings/tag-answers.d.ts +43 -0
- package/dist/meetings/tag-answers.js +41 -0
- package/dist/meetings/testing/index.d.ts +1 -0
- package/dist/meetings/testing/index.js +1 -0
- package/dist/meetings/testing/paging.d.ts +6 -0
- package/dist/meetings/testing/paging.js +5 -0
- package/dist/models/chat-sending.d.ts +24 -0
- package/dist/models/chat-sending.js +40 -0
- package/dist/moderation/rules.d.ts +2 -0
- package/dist/moderation/rules.js +16 -2
- package/dist/runs/events.d.ts +1 -1
- package/dist/search/fusion.d.ts +17 -0
- package/dist/search/fusion.js +17 -0
- package/dist/search/lucene/resolved.d.ts +2 -0
- package/dist/search/question-plan.d.ts +4 -0
- package/dist/search/question-plan.js +7 -0
- package/dist/search/service-query.d.ts +6 -1
- package/dist/search/service-query.js +9 -1
- package/dist/search/task-similarity.d.ts +1 -0
- package/dist/search/task-similarity.js +1 -1
- package/dist/services/agenda-mail.js +2 -1
- package/dist/services/agenda.js +5 -3
- package/dist/services/attachments.js +4 -2
- package/dist/services/call-stats.d.ts +17 -0
- package/dist/services/call-stats.js +41 -0
- package/dist/services/chats.js +4 -2
- package/dist/services/conversations.js +4 -2
- package/dist/services/deps.d.ts +1 -1
- package/dist/services/document-source.d.ts +1 -1
- package/dist/services/document-source.js +4 -3
- package/dist/services/documents/ingestion.js +11 -40
- package/dist/services/documents/plan.d.ts +1 -1
- package/dist/services/documents/plan.js +30 -17
- package/dist/services/documents/ports.d.ts +5 -0
- package/dist/services/documents/sync.js +1 -1
- package/dist/services/embeddings-search.js +39 -9
- package/dist/services/embeddings.d.ts +4 -0
- package/dist/services/events-search.js +2 -1
- package/dist/services/index.d.ts +3 -0
- package/dist/services/index.js +3 -0
- package/dist/services/mail-search.d.ts +1 -1
- package/dist/services/mail-search.js +10 -11
- package/dist/services/media-archive-move.js +2 -4
- package/dist/services/media-archive.d.ts +0 -1
- package/dist/services/media-archive.js +2 -12
- package/dist/services/meeting-combined.js +1 -1
- package/dist/services/meeting-meaning.d.ts +47 -0
- package/dist/services/meeting-meaning.js +158 -0
- package/dist/services/meeting-tags.d.ts +27 -0
- package/dist/services/meeting-tags.js +81 -0
- package/dist/services/messages-combined.js +15 -4
- package/dist/services/messages-discovery.js +2 -2
- package/dist/services/moderation.js +10 -2
- package/dist/services/moment.d.ts +4 -10
- package/dist/services/moment.js +16 -44
- package/dist/services/notes-search.d.ts +0 -2
- package/dist/services/notes-search.js +1 -2
- package/dist/services/search-all.js +2 -1
- package/dist/services/tags.js +4 -2
- package/dist/services/task-stats.js +2 -2
- package/dist/services/tasks.js +2 -2
- package/dist/sftp/index.d.ts +1 -1
- package/dist/sftp/index.js +1 -1
- package/dist/sftp/session.d.ts +30 -4
- package/dist/sftp/session.js +195 -11
- package/dist/sftp/ssh2.d.ts +19 -4
- package/dist/sftp/ssh2.js +144 -17
- package/dist/speech/cloud.d.ts +47 -0
- package/dist/speech/cloud.js +73 -0
- package/dist/speech/decode.d.ts +36 -9
- package/dist/speech/decode.js +208 -61
- package/dist/speech/index.d.ts +2 -1
- package/dist/speech/index.js +2 -1
- package/dist/speech/openai.d.ts +4 -0
- package/dist/speech/openai.js +13 -12
- package/dist/sql/index.d.ts +1 -0
- package/dist/sql/index.js +1 -0
- package/dist/sql/reader.d.ts +95 -0
- package/dist/sql/reader.js +214 -0
- package/dist/store/accounts.js +2 -1
- package/dist/store/sqlite/account-purge.d.ts +3 -0
- package/dist/store/sqlite/account-purge.js +143 -0
- package/dist/store/sqlite/accounts.d.ts +0 -2
- package/dist/store/sqlite/accounts.js +2 -134
- package/dist/store/sqlite/calendar.d.ts +1 -0
- package/dist/store/sqlite/calendar.js +5 -5
- package/dist/store/sqlite/catalog.js +2 -16
- package/dist/store/sqlite/chats.js +2 -1
- package/dist/store/sqlite/context-document-source.d.ts +3 -3
- package/dist/store/sqlite/context-document-source.js +9 -7
- package/dist/store/sqlite/context-evidence.js +9 -3
- package/dist/store/sqlite/document-listing.js +2 -1
- package/dist/store/sqlite/drizzle/bun.js +4 -4
- package/dist/store/sqlite/drizzle/bun.js.map +1 -1
- package/dist/store/sqlite/drizzle/core.js +5 -5
- package/dist/store/sqlite/drizzle/core.js.map +1 -1
- package/dist/store/sqlite/drizzle/node.js +4 -4
- package/dist/store/sqlite/drizzle/node.js.map +1 -1
- package/dist/store/sqlite/drizzle/{shared-55XJMTPA.js → shared-5XR7K42U.js} +58 -58
- package/dist/store/sqlite/drizzle/{shared-55XJMTPA.js.map → shared-5XR7K42U.js.map} +1 -1
- package/dist/store/sqlite/events.js +2 -1
- package/dist/store/sqlite/file-note.d.ts +6 -0
- package/dist/store/sqlite/file-note.js +15 -0
- package/dist/store/sqlite/files.d.ts +3 -2
- package/dist/store/sqlite/files.js +5 -3
- package/dist/store/sqlite/identities.js +2 -1
- package/dist/store/sqlite/imported-documents.js +2 -2
- package/dist/store/sqlite/knowledge.d.ts +1 -1
- package/dist/store/sqlite/knowledge.js +27 -23
- package/dist/store/sqlite/labelled.d.ts +5 -0
- package/dist/store/sqlite/labelled.js +6 -0
- package/dist/store/sqlite/link-row.d.ts +1 -0
- package/dist/store/sqlite/link-row.js +2 -0
- package/dist/store/sqlite/lucene-fields.js +8 -12
- package/dist/store/sqlite/mail-rules.js +2 -1
- package/dist/store/sqlite/meeting-calls.d.ts +4 -0
- package/dist/store/sqlite/meeting-calls.js +66 -0
- package/dist/store/sqlite/meetings.d.ts +2 -2
- package/dist/store/sqlite/meetings.js +4 -1
- package/dist/store/sqlite/mention-sources.js +2 -1
- package/dist/store/sqlite/mentions.js +2 -2
- package/dist/store/sqlite/messages.js +6 -1
- package/dist/store/sqlite/note-search.js +8 -11
- package/dist/store/sqlite/notes.d.ts +3 -1
- package/dist/store/sqlite/notes.js +25 -14
- package/dist/store/sqlite/organizations.js +2 -2
- package/dist/store/sqlite/people-list.js +3 -3
- package/dist/store/sqlite/query-filter.d.ts +3 -3
- package/dist/store/sqlite/query-filter.js +3 -3
- package/dist/store/sqlite/reads.d.ts +4 -4
- package/dist/store/sqlite/reads.js +4 -4
- package/dist/store/sqlite/search.js +11 -7
- package/dist/store/sqlite/test-accounts.js +1 -1
- package/dist/store/sqlite/trigram-match.d.ts +9 -0
- package/dist/store/sqlite/trigram-match.js +28 -0
- package/dist/store/sqlite/work-tasks.js +1 -1
- package/package.json +18 -3
- package/parity.json +20 -1
- package/skills/link-conversations/SKILL.md +1 -1
|
@@ -10,28 +10,6 @@ export const documentIngestion = (store, options) => {
|
|
|
10
10
|
const found = (await store.notes.folders()).find((item) => item.name === name);
|
|
11
11
|
return found ?? (create ? await store.notes.addFolder({ name, format: "markdown" }) : undefined);
|
|
12
12
|
};
|
|
13
|
-
const documents = new Map();
|
|
14
|
-
const cached = async (principal) => {
|
|
15
|
-
const known = documents.get(principal);
|
|
16
|
-
if (known)
|
|
17
|
-
return known;
|
|
18
|
-
const notes = new Map();
|
|
19
|
-
const selected = await folder(principal, false);
|
|
20
|
-
if (selected) {
|
|
21
|
-
for (let offset = 0;; offset += 500) {
|
|
22
|
-
const page = await store.notes.notes({ folderId: selected.id, source: "file", limit: 500, offset });
|
|
23
|
-
for (const note of page.items)
|
|
24
|
-
if (note.path)
|
|
25
|
-
notes.set(note.path, note);
|
|
26
|
-
if (!page.hasMore)
|
|
27
|
-
break;
|
|
28
|
-
if (offset >= 10000)
|
|
29
|
-
throw new CliError("provider_error", "local document listing exceeded its bound");
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
documents.set(principal, notes);
|
|
33
|
-
return notes;
|
|
34
|
-
};
|
|
35
13
|
const stale = async (ref) => {
|
|
36
14
|
for (const status of ["proposed", "confirmed"]) {
|
|
37
15
|
for (let batch = 0;; batch++) {
|
|
@@ -48,23 +26,20 @@ export const documentIngestion = (store, options) => {
|
|
|
48
26
|
return {
|
|
49
27
|
catalog: {
|
|
50
28
|
import: async (principal, files) => {
|
|
51
|
-
if (files.length > 10000)
|
|
52
|
-
throw new CliError("validation_error", "catalog scope exceeds 10000 entries", {
|
|
53
|
-
reason: "catalog.scope-limit",
|
|
54
|
-
});
|
|
55
29
|
const selected = await folder(principal, true);
|
|
56
30
|
if (!selected)
|
|
57
31
|
throw new CliError("configuration_error", "catalog collection could not be registered");
|
|
58
32
|
for (let start = 0; start < files.length; start += 200) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
33
|
+
const chunk = files.slice(start, start + 200);
|
|
34
|
+
await store.catalog.upsert(selected.id, chunk.map(options.catalogInput));
|
|
35
|
+
if (options.observed)
|
|
36
|
+
for (const file of chunk) {
|
|
37
|
+
const entry = await store.catalog.get(selected.id, options.externalId(file.id));
|
|
38
|
+
if (entry)
|
|
39
|
+
await options.observed(principal, file, entry.ref.slice("document:".length));
|
|
40
|
+
}
|
|
65
41
|
}
|
|
66
42
|
const retired = await store.catalog.reconcile(selected.id, files.map((file) => options.externalId(file.id)));
|
|
67
|
-
documents.delete(principal);
|
|
68
43
|
return { entries: files.length, retired };
|
|
69
44
|
},
|
|
70
45
|
get: async (principal, id) => {
|
|
@@ -92,14 +67,13 @@ export const documentIngestion = (store, options) => {
|
|
|
92
67
|
const selected = await folder(principal, true);
|
|
93
68
|
if (!selected)
|
|
94
69
|
throw new Error("folder registration failed");
|
|
95
|
-
const notes = await cached(principal);
|
|
96
70
|
const path = options.externalId(content.metadata.id);
|
|
97
|
-
const before = notes.
|
|
71
|
+
const before = await store.notes.fileNote(selected.id, path);
|
|
98
72
|
if (before && before.contentHash !== hash)
|
|
99
73
|
await stale(before.ref);
|
|
100
74
|
const { note } = await store.notes.saveFileNote({
|
|
101
75
|
folderId: selected.id,
|
|
102
|
-
path
|
|
76
|
+
path,
|
|
103
77
|
title: content.metadata.name,
|
|
104
78
|
text: content.text,
|
|
105
79
|
contentHash: hash,
|
|
@@ -107,21 +81,18 @@ export const documentIngestion = (store, options) => {
|
|
|
107
81
|
});
|
|
108
82
|
await store.catalog.upsert(selected.id, [options.catalogInput(content.metadata)]);
|
|
109
83
|
await options.observed?.(principal, content.metadata, note.id);
|
|
110
|
-
notes.set(path, note);
|
|
111
84
|
return note.ref;
|
|
112
85
|
},
|
|
113
86
|
remove: async (principal, id) => {
|
|
114
87
|
const selected = await folder(principal, false);
|
|
115
88
|
if (selected) {
|
|
116
|
-
const notes = await cached(principal);
|
|
117
89
|
const path = options.externalId(id);
|
|
118
|
-
const note = notes.
|
|
90
|
+
const note = await store.notes.fileNote(selected.id, path);
|
|
119
91
|
const retired = note ? undefined : await store.catalog.get(selected.id, path, true);
|
|
120
92
|
const ref = note?.ref ?? retired?.ref;
|
|
121
93
|
if (ref)
|
|
122
94
|
await stale(ref);
|
|
123
95
|
await store.notes.deleteFileNotes(selected.id, [path]);
|
|
124
|
-
notes.delete(path);
|
|
125
96
|
}
|
|
126
97
|
},
|
|
127
98
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { DocumentSource, SourceFile, SourceState, SourceWalk } from "../../documents/model.js";
|
|
2
2
|
import { type SourceQuery } from "../../documents/scope.js";
|
|
3
3
|
import type { SyncOptions } from "./ports.js";
|
|
4
|
-
export declare const scopeHash: (roots: string[], query?: Pick<SourceQuery, "key" | "mode"
|
|
4
|
+
export declare const scopeHash: (roots: string[], query?: Pick<SourceQuery, "key" | "mode">, pages?: boolean) => string;
|
|
5
5
|
export declare const changedSince: (previous: SourceFile, file: SourceFile) => boolean;
|
|
6
6
|
interface WalkStore<M extends SourceFile> {
|
|
7
7
|
read: (scope: string) => SourceWalk<M> | undefined;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
2
|
import { CliError } from "@wirecat/cli-base";
|
|
3
3
|
import { inScope, within } from "../../documents/scope.js";
|
|
4
|
-
// Without a query the hash stays what it was, so a profile that never set
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
// Without a query or pages the hash stays what it was, so a profile that never set them keeps its checkpoint. Turning
|
|
5
|
+
// pages on changes it, so the next sync walks again and imports the pages an incremental one would never revisit.
|
|
6
|
+
export const scopeHash = (roots, query, pages = false) => createHash("sha256")
|
|
7
|
+
.update(JSON.stringify(query || pages ? [[...roots].sort(), query?.mode, query?.key, ...(pages ? ["pages"] : [])] : [...roots].sort()))
|
|
7
8
|
.digest("hex");
|
|
8
9
|
export const changedSince = (previous, file) => previous.version !== file.version ||
|
|
9
10
|
previous.modifiedAt !== file.modifiedAt ||
|
|
@@ -14,7 +15,7 @@ const SAVE_EVERY_MS = 2000;
|
|
|
14
15
|
export const planDocuments = async (options, source, state, roots, limit, pictures, abandoned = [], walks) => {
|
|
15
16
|
const { isFolder, skipReason, retryable, maxEntries: MAX_ENTRIES, errorOf, query } = options;
|
|
16
17
|
const tooManyEntries = () => options.limitError?.() ?? new CliError("validation_error", `selected folders exceed the ${MAX_ENTRIES} entry limit`);
|
|
17
|
-
const scope = scopeHash(roots, query);
|
|
18
|
+
const scope = scopeHash(roots, query, options.isDocument !== undefined);
|
|
18
19
|
if (!roots.length && query?.mode !== "include")
|
|
19
20
|
return {
|
|
20
21
|
scope,
|
|
@@ -38,6 +39,14 @@ export const planDocuments = async (options, source, state, roots, limit, pictur
|
|
|
38
39
|
for (const skipped of state.skipped)
|
|
39
40
|
if (skipped.file)
|
|
40
41
|
files.set(skipped.id, skipped.file);
|
|
42
|
+
const keep = (file) => {
|
|
43
|
+
files.set(file.id, file);
|
|
44
|
+
changed.add(file.id);
|
|
45
|
+
};
|
|
46
|
+
const container = (file) => {
|
|
47
|
+
if (options.isDocument?.(file))
|
|
48
|
+
keep(file);
|
|
49
|
+
};
|
|
41
50
|
const visited = new Set();
|
|
42
51
|
let discovered = 0;
|
|
43
52
|
const crawl = async (folder, ancestry = new Set()) => {
|
|
@@ -50,12 +59,12 @@ export const planDocuments = async (options, source, state, roots, limit, pictur
|
|
|
50
59
|
for (const file of await source.children(folder.id)) {
|
|
51
60
|
if (++discovered > MAX_ENTRIES)
|
|
52
61
|
throw tooManyEntries();
|
|
53
|
-
if (isFolder(file))
|
|
62
|
+
if (isFolder(file)) {
|
|
63
|
+
container(file);
|
|
54
64
|
await crawl(file, new Set([...ancestry, folder.id]));
|
|
55
|
-
else {
|
|
56
|
-
files.set(file.id, file);
|
|
57
|
-
changed.add(file.id);
|
|
58
65
|
}
|
|
66
|
+
else
|
|
67
|
+
keep(file);
|
|
59
68
|
}
|
|
60
69
|
};
|
|
61
70
|
let finalCursor = cursor;
|
|
@@ -94,6 +103,8 @@ export const planDocuments = async (options, source, state, roots, limit, pictur
|
|
|
94
103
|
const folder = step.folder ?? (await source.metadata(step.id));
|
|
95
104
|
if (!step.folder && (!isFolder(folder) || folder.trashed))
|
|
96
105
|
throw new CliError("validation_error", "configured root is not an accessible folder");
|
|
106
|
+
if (!step.folder)
|
|
107
|
+
container(folder);
|
|
97
108
|
const children = await source.children(folder.id);
|
|
98
109
|
if (discovered + children.length > MAX_ENTRIES)
|
|
99
110
|
throw tooManyEntries();
|
|
@@ -103,12 +114,12 @@ export const planDocuments = async (options, source, state, roots, limit, pictur
|
|
|
103
114
|
folders[folder.id] = folder;
|
|
104
115
|
const nested = [];
|
|
105
116
|
for (const file of children)
|
|
106
|
-
if (isFolder(file))
|
|
117
|
+
if (isFolder(file)) {
|
|
118
|
+
container(file);
|
|
107
119
|
nested.push({ id: file.id, ancestry: [...step.ancestry, folder.id], folder: file });
|
|
108
|
-
else {
|
|
109
|
-
files.set(file.id, file);
|
|
110
|
-
changed.add(file.id);
|
|
111
120
|
}
|
|
121
|
+
else
|
|
122
|
+
keep(file);
|
|
112
123
|
for (const entry of nested.reverse())
|
|
113
124
|
walk.stack.push(entry);
|
|
114
125
|
if ((options.now ?? Date.now)() - savedAt > SAVE_EVERY_MS)
|
|
@@ -135,11 +146,10 @@ export const planDocuments = async (options, source, state, roots, limit, pictur
|
|
|
135
146
|
else if (change.file && isFolder(change.file)) {
|
|
136
147
|
folders[change.id] = change.file;
|
|
137
148
|
entering.push(change.file);
|
|
149
|
+
container(change.file);
|
|
138
150
|
}
|
|
139
|
-
else if (change.file)
|
|
140
|
-
|
|
141
|
-
changed.add(change.id);
|
|
142
|
-
}
|
|
151
|
+
else if (change.file)
|
|
152
|
+
keep(change.file);
|
|
143
153
|
else if (state.documents[change.id] || folders[change.id])
|
|
144
154
|
throw new CliError("invalid_response", "known source changed without metadata; checkpoint preserved");
|
|
145
155
|
}
|
|
@@ -167,7 +177,10 @@ export const planDocuments = async (options, source, state, roots, limit, pictur
|
|
|
167
177
|
}
|
|
168
178
|
const matched = new Set();
|
|
169
179
|
for (const file of found) {
|
|
170
|
-
if (isFolder(file)
|
|
180
|
+
if ((isFolder(file) && !options.isDocument?.(file)) ||
|
|
181
|
+
file.trashed ||
|
|
182
|
+
!query?.matches(file) ||
|
|
183
|
+
matched.has(file.id))
|
|
171
184
|
continue;
|
|
172
185
|
if (!files.has(file.id) && ++discovered > MAX_ENTRIES)
|
|
173
186
|
throw tooManyEntries();
|
|
@@ -13,6 +13,11 @@ export interface SyncOptions<M extends SourceFile> {
|
|
|
13
13
|
maxEntries: number;
|
|
14
14
|
limitError?(): CliError;
|
|
15
15
|
isFolder(file: M): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* A folder that is a document too, such as a wiki page with sub-pages: walked for its children and imported
|
|
18
|
+
* itself. Left out, no folder is imported.
|
|
19
|
+
*/
|
|
20
|
+
isDocument?(file: M): boolean;
|
|
16
21
|
skipReason(file: M): string | undefined;
|
|
17
22
|
retryable(skip: SourceSkip<M>, limit: number): boolean;
|
|
18
23
|
errorOf(error: unknown): CliError;
|
|
@@ -43,7 +43,7 @@ export const syncDocuments = async (options) => {
|
|
|
43
43
|
const state = statePort.read();
|
|
44
44
|
if (state.principal !== principal)
|
|
45
45
|
throw new CliError("configuration_error", "sync state belongs to another source account");
|
|
46
|
-
const currentScope = scopeHash(profile.roots, query);
|
|
46
|
+
const currentScope = scopeHash(profile.roots, query, options.isDocument !== undefined);
|
|
47
47
|
const abandoned = state.pending && (state.pending.scope !== currentScope || rescan) ? state.pending.jobs.map((job) => job.id) : [];
|
|
48
48
|
if (state.pending?.scope !== currentScope || rescan)
|
|
49
49
|
delete state.pending;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { CliError } from "@wirecat/cli-base";
|
|
2
2
|
import { formatLocator, parseLocator } from "../domain/locator.js";
|
|
3
3
|
import { meaningFloor } from "../embeddings/models.js";
|
|
4
|
-
import {
|
|
4
|
+
import { fuseRanked } from "../search/fusion.js";
|
|
5
|
+
import { isQueryLimit, QUERY_LIMITS, searchError } from "../search/lucene/types.js";
|
|
6
|
+
import { STOP_WORDS } from "../search/task-similarity.js";
|
|
7
|
+
import { normalize } from "../store/normalize.js";
|
|
5
8
|
import { threadConversation } from "../store/store.js";
|
|
6
9
|
import { embeddingsMaintenance, embeddingTarget, isStale, notBuiltError, readinessOf, shaped, withEmbedder, } from "./embeddings-maintenance.js";
|
|
7
10
|
import { storedChatId } from "./message-resolution.js";
|
|
@@ -22,8 +25,11 @@ export const embeddingsSearch = (deps) => {
|
|
|
22
25
|
* Only whole words and their beginnings count: a corrected spelling or a piece of a word would pass a
|
|
23
26
|
* near-miss off as a match, which is what the meaning half is for.
|
|
24
27
|
*/
|
|
25
|
-
const byWords = async (query, prepared, conversations, since) => {
|
|
26
|
-
const
|
|
28
|
+
const byWords = async (query, prepared, conversations, since, timeLimitMs) => {
|
|
29
|
+
const all = [...new Set(query.toLowerCase().match(/[\p{L}\p{N}]+/gu) ?? [])];
|
|
30
|
+
// `что*` OR `какие*` reads most of a large store and runs out of time before the words that matter count.
|
|
31
|
+
const content = all.filter((word) => !STOP_WORDS.has(normalize(word)));
|
|
32
|
+
const words = content.length ? content : all;
|
|
27
33
|
const outside = new Map();
|
|
28
34
|
if (!words.length || !prepared.scopeAccounts.length)
|
|
29
35
|
return { hits: [], outside, sources: new Map() };
|
|
@@ -32,6 +38,7 @@ export const embeddingsSearch = (deps) => {
|
|
|
32
38
|
text: words.map((word) => (word.length >= 3 ? `${word}*` : `"${word}"`)).join(" OR "),
|
|
33
39
|
accounts: prepared.scopeAccounts,
|
|
34
40
|
limit: WORD_HITS,
|
|
41
|
+
...(timeLimitMs === undefined ? {} : { timeLimitMs }),
|
|
35
42
|
}, deps.messenger);
|
|
36
43
|
const { items } = await store.queries.matchQuery({
|
|
37
44
|
...lexical.execution,
|
|
@@ -59,9 +66,18 @@ export const embeddingsSearch = (deps) => {
|
|
|
59
66
|
});
|
|
60
67
|
outside.set(JSON.stringify(account), { account, chats });
|
|
61
68
|
}
|
|
62
|
-
|
|
69
|
+
let ranked = items.flatMap(({ id, score, timestamp }, index) => {
|
|
63
70
|
const summary = summaries.get(index);
|
|
64
|
-
return summary
|
|
71
|
+
return summary
|
|
72
|
+
? [
|
|
73
|
+
{
|
|
74
|
+
summary,
|
|
75
|
+
chunk: { firstMessageId: id, lastMessageId: id },
|
|
76
|
+
ranked: score !== null,
|
|
77
|
+
at: Date.parse(timestamp),
|
|
78
|
+
},
|
|
79
|
+
]
|
|
80
|
+
: [];
|
|
65
81
|
});
|
|
66
82
|
// Mail in its own tables has no conversations: each email answers as its thread, ranked with the messages.
|
|
67
83
|
const mailAccounts = prepared.scopeAccounts.filter(({ provider }) => provider === MAIL);
|
|
@@ -78,6 +94,7 @@ export const embeddingsSearch = (deps) => {
|
|
|
78
94
|
return { items: [] };
|
|
79
95
|
throw error;
|
|
80
96
|
});
|
|
97
|
+
const emails = [];
|
|
81
98
|
for (const account of mailAccounts) {
|
|
82
99
|
const found = mail.items.filter((hit) => {
|
|
83
100
|
const at = parseLocator(hit.locator);
|
|
@@ -93,10 +110,15 @@ export const embeddingsSearch = (deps) => {
|
|
|
93
110
|
continue;
|
|
94
111
|
const summary = threadConversation(place, Date.now());
|
|
95
112
|
sources.set(summary.id, account);
|
|
96
|
-
|
|
113
|
+
emails.push({
|
|
114
|
+
summary,
|
|
115
|
+
chunk: { firstMessageId: hit.id, lastMessageId: hit.id },
|
|
116
|
+
ranked: hit.score !== null,
|
|
117
|
+
at: Date.parse(hit.timestamp),
|
|
118
|
+
});
|
|
97
119
|
}
|
|
98
120
|
}
|
|
99
|
-
ranked
|
|
121
|
+
ranked = fuseRanked([ranked, emails], (one) => one);
|
|
100
122
|
}
|
|
101
123
|
const seen = new Set();
|
|
102
124
|
const hits = ranked.flatMap(({ summary, chunk }) => {
|
|
@@ -108,7 +130,7 @@ export const embeddingsSearch = (deps) => {
|
|
|
108
130
|
return { hits, outside, sources };
|
|
109
131
|
};
|
|
110
132
|
return {
|
|
111
|
-
search: async (query, { chat, model: choice, since, limit, filter, source, timezone, syncFirst, signal, refresh }) => {
|
|
133
|
+
search: async (query, { chat, model: choice, since, limit, filter, source, timezone, syncFirst, signal, refresh, timeLimitMs }) => {
|
|
112
134
|
if (!query.trim())
|
|
113
135
|
searchError("query.invalid-syntax", { start: 0, end: query.length }, "give words to search for");
|
|
114
136
|
if (new TextEncoder().encode(query).length > QUERY_LIMITS.bytes)
|
|
@@ -145,7 +167,14 @@ export const embeddingsSearch = (deps) => {
|
|
|
145
167
|
? { chatId: selected.chatId }
|
|
146
168
|
: null
|
|
147
169
|
: {};
|
|
148
|
-
|
|
170
|
+
// Out of time in words still leaves the meaning half, the one a sentence needs most.
|
|
171
|
+
let wordsOutOfTime = false;
|
|
172
|
+
const words = await byWords(query, prepared, eligibility?.conversations, since, timeLimitMs).catch((error) => {
|
|
173
|
+
if (!isQueryLimit(error))
|
|
174
|
+
throw error;
|
|
175
|
+
wordsOutOfTime = true;
|
|
176
|
+
return { hits: [], outside: new Map(), sources: new Map() };
|
|
177
|
+
});
|
|
149
178
|
const meaning = [];
|
|
150
179
|
const sources = words.sources;
|
|
151
180
|
if (target.installed && prepared.scopeAccounts.length && eligibility?.conversations.length !== 0) {
|
|
@@ -215,6 +244,7 @@ export const embeddingsSearch = (deps) => {
|
|
|
215
244
|
accounts: prepared.scopeAccounts,
|
|
216
245
|
model: target.id,
|
|
217
246
|
meaning: target.installed ? "searched" : "unavailable",
|
|
247
|
+
...(wordsOutOfTime ? { words: "out-of-time" } : {}),
|
|
218
248
|
hits: fused(meaning, words.hits, meaningFloor(target.key))
|
|
219
249
|
.slice(0, limit)
|
|
220
250
|
.map((hit) => {
|
|
@@ -66,6 +66,8 @@ export interface EmbeddingsService {
|
|
|
66
66
|
signal?: AbortSignal;
|
|
67
67
|
/** Local graph catch-up after any network refresh and before searching. */
|
|
68
68
|
refresh?: RefreshOptions;
|
|
69
|
+
/** The word half's budget, from an explicit `--timeout`; the default limit otherwise. */
|
|
70
|
+
timeLimitMs?: number;
|
|
69
71
|
}): Promise<FoundConversations>;
|
|
70
72
|
/**
|
|
71
73
|
* The conversations of every built chat nearest in meaning to the one `message` is in, best first, never that
|
|
@@ -135,6 +137,8 @@ export interface FoundConversations {
|
|
|
135
137
|
model: string;
|
|
136
138
|
/** `unavailable`: the local model is not downloaded, and only words were searched. */
|
|
137
139
|
meaning: "searched" | "unavailable";
|
|
140
|
+
/** `out-of-time`: the word half hit its time limit, so the hits are by meaning alone. */
|
|
141
|
+
words?: "out-of-time";
|
|
138
142
|
hits: FoundConversation[];
|
|
139
143
|
readiness: SearchReadiness;
|
|
140
144
|
/** Kept for callers of 0.141.0 and before; `readiness.wordsOnly` says more. */
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { CliError } from "@wirecat/cli-base";
|
|
2
2
|
import { holdsKind } from "../domain/providers.js";
|
|
3
3
|
import { meaningFloor } from "../embeddings/models.js";
|
|
4
|
+
import { RRF_K } from "../search/fusion.js";
|
|
4
5
|
import { plainQuery } from "../search/lucene/plain.js";
|
|
5
6
|
import { questionLookup, questionText } from "../search/question-plan.js";
|
|
6
7
|
import { excerpt } from "./excerpt.js";
|
|
7
8
|
import { meaningModel } from "./meaning-model.js";
|
|
8
|
-
import { localModel,
|
|
9
|
+
import { localModel, storeQuery, withLocal } from "./notes-search.js";
|
|
9
10
|
import { plainQueryWords } from "./notes-title-tier.js";
|
|
10
11
|
const MAX_EVENTS_OFFSET = 1000;
|
|
11
12
|
const iso = (at) => (at === null ? null : new Date(at).toISOString());
|
package/dist/services/index.d.ts
CHANGED
|
@@ -68,6 +68,7 @@ export type { AttachmentItem, AttachmentsService, AttachmentTextSet, ExtractItem
|
|
|
68
68
|
export { attachmentsService } from "./attachments.js";
|
|
69
69
|
export type { Category, Coverage, Related, RelationRole, Section } from "./business-context.js";
|
|
70
70
|
export { CATEGORIES, organizationCategories, SECTION_LIMIT } from "./business-context.js";
|
|
71
|
+
export { type CallStatsAnswer, type CallStatsRequest, readCallStats } from "./call-stats.js";
|
|
71
72
|
export type { ChatsService, MarkedRead, PageWindow } from "./chats.js";
|
|
72
73
|
export { chatsService, EVENTS_DAYS } from "./chats.js";
|
|
73
74
|
export type { Communications, Touch } from "./communications.js";
|
|
@@ -92,11 +93,13 @@ export { inboxService } from "./inbox.js";
|
|
|
92
93
|
export { readMail } from "./mail-search.js";
|
|
93
94
|
export { type MeetingHitSearchRequest, refreshMeetingIndex, searchMeetingHits } from "./meeting-hit-search.js";
|
|
94
95
|
export { type MeetingLink, type MeetingLinksRequest, readMeetingLinks } from "./meeting-links.js";
|
|
96
|
+
export { type MeetingEmbeddingOptions, type MeetingMeaning, type MeetingMeaningApi, type MeetingMeaningSearchOptions, type MeetingModelOptions, meetingMeaning, validateMeetingEmbeddings, validateMeetingMeaningSearch, validateMeetingModel, } from "./meeting-meaning.js";
|
|
95
97
|
export { createMeetingProjectCandidateReader } from "./meeting-project-candidates.js";
|
|
96
98
|
export { readMeetingProjectDiscovery } from "./meeting-project-discovery.js";
|
|
97
99
|
export { type MeetingReviewRequest, readMeetingReview } from "./meeting-review.js";
|
|
98
100
|
export { type MeetingSearchesService, type MeetingSearchParams, meetingSearchesService, type SavedMeetingSearch, } from "./meeting-searches.js";
|
|
99
101
|
export { type MeetingCountsRequest, type MeetingStatsRequest, readMeetingCounts, readMeetingStats, } from "./meeting-stats.js";
|
|
102
|
+
export { type MeetingTags, type MeetingTagTarget, meetingTags } from "./meeting-tags.js";
|
|
100
103
|
export { chatIdIn, storedChatId } from "./message-resolution.js";
|
|
101
104
|
export type { AroundWindow, FoundMessage, ListWindow, MessagesService, MessageTarget, Pinned, Reacted, SearchFound, SearchQuery, SendRequest, Starred, } from "./messages.js";
|
|
102
105
|
export { DELETE_AT_ONCE, messagesService } from "./messages.js";
|
package/dist/services/index.js
CHANGED
|
@@ -53,6 +53,7 @@ export { adminService } from "./admin.js";
|
|
|
53
53
|
export { archiveService } from "./archive.js";
|
|
54
54
|
export { attachmentsService } from "./attachments.js";
|
|
55
55
|
export { CATEGORIES, organizationCategories, SECTION_LIMIT } from "./business-context.js";
|
|
56
|
+
export { readCallStats } from "./call-stats.js";
|
|
56
57
|
export { chatsService, EVENTS_DAYS } from "./chats.js";
|
|
57
58
|
export { BATCH_SIZE, conversationsService } from "./conversations.js";
|
|
58
59
|
export { dealBrief, dealContext } from "./deal-context.js";
|
|
@@ -67,11 +68,13 @@ export { inboxService } from "./inbox.js";
|
|
|
67
68
|
export { readMail } from "./mail-search.js";
|
|
68
69
|
export { refreshMeetingIndex, searchMeetingHits } from "./meeting-hit-search.js";
|
|
69
70
|
export { readMeetingLinks } from "./meeting-links.js";
|
|
71
|
+
export { meetingMeaning, validateMeetingEmbeddings, validateMeetingMeaningSearch, validateMeetingModel, } from "./meeting-meaning.js";
|
|
70
72
|
export { createMeetingProjectCandidateReader } from "./meeting-project-candidates.js";
|
|
71
73
|
export { readMeetingProjectDiscovery } from "./meeting-project-discovery.js";
|
|
72
74
|
export { readMeetingReview } from "./meeting-review.js";
|
|
73
75
|
export { meetingSearchesService, } from "./meeting-searches.js";
|
|
74
76
|
export { readMeetingCounts, readMeetingStats, } from "./meeting-stats.js";
|
|
77
|
+
export { meetingTags } from "./meeting-tags.js";
|
|
75
78
|
export { chatIdIn, storedChatId } from "./message-resolution.js";
|
|
76
79
|
export { DELETE_AT_ONCE, messagesService } from "./messages.js";
|
|
77
80
|
export { searchStore } from "./messages-archive-search.js";
|
|
@@ -6,7 +6,7 @@ import type { MessageStore, ScoredHit, StoredHit } from "../store/store.js";
|
|
|
6
6
|
*/
|
|
7
7
|
export declare const withMailThreads: (store: MessageStore) => MessageStore;
|
|
8
8
|
/**
|
|
9
|
-
* One page from mail stored as messages and mail in its own tables,
|
|
9
|
+
* One page from mail stored as messages and mail in its own tables, two word indexes fused by rank (`fuseRanked`). An email
|
|
10
10
|
* imported again into the mail tables keeps its locator, so its older message copy is dropped.
|
|
11
11
|
*/
|
|
12
12
|
export declare const mergeMail: (messages: Page<ScoredHit>, mail: Page<ScoredHit>, limit: number, newest?: boolean) => Page<ScoredHit>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CliError } from "@wirecat/cli-base";
|
|
2
2
|
import { parseLocator } from "../domain/locator.js";
|
|
3
|
+
import { fuseRanked } from "../search/fusion.js";
|
|
3
4
|
import { messageOfEmail } from "../store/store.js";
|
|
4
5
|
const THREADS_PAGE = 500;
|
|
5
6
|
const threadsOf = async (store, key) => {
|
|
@@ -41,22 +42,20 @@ export const withMailThreads = (store) => {
|
|
|
41
42
|
get: (target, key, receiver) => (key === "chats" ? chats : Reflect.get(target, key, receiver)),
|
|
42
43
|
});
|
|
43
44
|
};
|
|
44
|
-
const before = (newest) => (a, b) => {
|
|
45
|
-
if (!newest) {
|
|
46
|
-
if ((a.exact ?? false) !== (b.exact ?? false))
|
|
47
|
-
return a.exact ? -1 : 1;
|
|
48
|
-
if (a.score !== b.score)
|
|
49
|
-
return a.score === null ? 1 : b.score === null ? -1 : b.score - a.score;
|
|
50
|
-
}
|
|
51
|
-
return b.timestamp.localeCompare(a.timestamp);
|
|
52
|
-
};
|
|
53
45
|
/**
|
|
54
|
-
* One page from mail stored as messages and mail in its own tables,
|
|
46
|
+
* One page from mail stored as messages and mail in its own tables, two word indexes fused by rank (`fuseRanked`). An email
|
|
55
47
|
* imported again into the mail tables keeps its locator, so its older message copy is dropped.
|
|
56
48
|
*/
|
|
57
49
|
export const mergeMail = (messages, mail, limit, newest = false) => {
|
|
58
50
|
const moved = new Set(mail.items.map(({ locator }) => locator));
|
|
59
|
-
const
|
|
51
|
+
const kept = messages.items.filter(({ locator }) => !moved.has(locator));
|
|
52
|
+
const items = newest
|
|
53
|
+
? [...kept, ...mail.items].sort((a, b) => b.timestamp.localeCompare(a.timestamp))
|
|
54
|
+
: fuseRanked([kept, mail.items], (hit) => ({
|
|
55
|
+
exact: hit.exact,
|
|
56
|
+
ranked: hit.score !== null,
|
|
57
|
+
at: Date.parse(hit.timestamp),
|
|
58
|
+
}));
|
|
60
59
|
return {
|
|
61
60
|
items: items.slice(0, limit),
|
|
62
61
|
hasMore: messages.hasMore || mail.hasMore || items.length > limit,
|
|
@@ -2,10 +2,10 @@ import { realpath, unlink } from "node:fs/promises";
|
|
|
2
2
|
import { basename, dirname, join, resolve } from "node:path";
|
|
3
3
|
import { CliError } from "@wirecat/cli-base";
|
|
4
4
|
import { openOrdinaryFile, sameOrdinaryFile, syncDirectory, writeFileAtomic } from "../files/index.js";
|
|
5
|
-
import { validateMediaSince } from "./media-archive.js";
|
|
6
5
|
import { archiveMediaFile } from "./media-archive-files.js";
|
|
7
6
|
import { withMediaArchiveLocks } from "./media-archive-locks.js";
|
|
8
7
|
import { mediaFingerprint, mediaKey, mediaManifestName, missingMediaFile, parseMediaEntry, readMediaManifests, sameMediaCopy, verifyMediaEntry, } from "./media-archive-manifest.js";
|
|
8
|
+
import { momentOf } from "./moment.js";
|
|
9
9
|
const canonicalDestination = async (directory) => {
|
|
10
10
|
const path = resolve(directory);
|
|
11
11
|
try {
|
|
@@ -48,9 +48,7 @@ const removeLocalCopy = async (root, entry, beforeWrite, signal) => {
|
|
|
48
48
|
};
|
|
49
49
|
/** The destination is durable before a source relocation record is published, then the verified local copy is removed. */
|
|
50
50
|
export const moveMediaArchive = async (options) => {
|
|
51
|
-
const cutoff =
|
|
52
|
-
if (cutoff === undefined)
|
|
53
|
-
throw new CliError("validation_error", "--before-time is required");
|
|
51
|
+
const cutoff = momentOf(options.beforeTime, "--before-time");
|
|
54
52
|
const target = await canonicalDestination(options.archiveDirectory);
|
|
55
53
|
const source = await realpath(options.directory);
|
|
56
54
|
if (source === target)
|
|
@@ -15,7 +15,6 @@ export interface MediaArchiveOptions {
|
|
|
15
15
|
signal?: AbortSignal;
|
|
16
16
|
onSaved?: (entry: MediaArchiveEntry) => void;
|
|
17
17
|
}
|
|
18
|
-
export declare const validateMediaSince: (value?: string, flag?: string) => number | undefined;
|
|
19
18
|
export declare const checkMediaArchive: (directory: string, signal?: AbortSignal) => Promise<{
|
|
20
19
|
valid: boolean;
|
|
21
20
|
checked: number;
|
|
@@ -4,17 +4,7 @@ import { matchDownloads, NOT_FILES } from "../domain/attachments.js";
|
|
|
4
4
|
import { archiveMediaFile } from "./media-archive-files.js";
|
|
5
5
|
import { withMediaArchiveLocks } from "./media-archive-locks.js";
|
|
6
6
|
import { mediaKey, readMediaManifests, verifyMediaEntry } from "./media-archive-manifest.js";
|
|
7
|
-
|
|
8
|
-
if (value === undefined)
|
|
9
|
-
return undefined;
|
|
10
|
-
if (!/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.\d{1,3})?(?:Z|[+-]\d\d:\d\d)$/.test(value) ||
|
|
11
|
-
!Number.isFinite(Date.parse(value)))
|
|
12
|
-
throw new CliError("validation_error", `${flag} needs an ISO timestamp with a time zone`);
|
|
13
|
-
const date = value.slice(0, 10);
|
|
14
|
-
if (new Date(`${date}T00:00:00Z`).toISOString().slice(0, 10) !== date)
|
|
15
|
-
throw new CliError("validation_error", `${flag} has an invalid calendar date`);
|
|
16
|
-
return Date.parse(value);
|
|
17
|
-
};
|
|
7
|
+
import { momentOf } from "./moment.js";
|
|
18
8
|
export const checkMediaArchive = (directory, signal) => withMediaArchiveLocks(directory, signal, async (root) => {
|
|
19
9
|
const entries = await readMediaManifests(root, signal);
|
|
20
10
|
if (!entries.length)
|
|
@@ -66,7 +56,7 @@ const saveMessage = async (root, account, message, ports, known, beforeWrite, op
|
|
|
66
56
|
return { saved, existing };
|
|
67
57
|
};
|
|
68
58
|
export const archiveMedia = async (ports, options) => {
|
|
69
|
-
const since =
|
|
59
|
+
const since = options.sinceTime === undefined ? undefined : momentOf(options.sinceTime, "--since-time");
|
|
70
60
|
const pageSize = options.pageSize ?? 100;
|
|
71
61
|
const pauseMs = options.pauseMs ?? 1000;
|
|
72
62
|
if (!Number.isSafeInteger(pageSize) ||
|
|
@@ -2,10 +2,10 @@ import { createHash } from "node:crypto";
|
|
|
2
2
|
import { CliError } from "@wirecat/cli-base";
|
|
3
3
|
import { meaningFloor } from "../embeddings/models.js";
|
|
4
4
|
import { formatMeetingReference, liftMeetingFields, parseMeetingReference, } from "../meetings/index.js";
|
|
5
|
+
import { RRF_K } from "../search/fusion.js";
|
|
5
6
|
import { questionTerms } from "../search/question-plan.js";
|
|
6
7
|
import { refreshMeetingIndex, resolveMeetingSelection } from "./meeting-hit-search.js";
|
|
7
8
|
import { validateVector } from "./meeting-semantic.js";
|
|
8
|
-
import { RRF_K } from "./notes-search.js";
|
|
9
9
|
/** How many hits each side ranks before they are merged; a page past it has nothing more to show. */
|
|
10
10
|
const DEPTH = 200;
|
|
11
11
|
const cursorOf = (value, key) => {
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { MeetingHitSearchRequest } from "../meetings/index.js";
|
|
2
|
+
import type { MessageStore } from "../store/store.js";
|
|
3
|
+
export interface MeetingModelOptions {
|
|
4
|
+
model: string;
|
|
5
|
+
baseUrl?: string;
|
|
6
|
+
dims?: number;
|
|
7
|
+
}
|
|
8
|
+
export interface MeetingMeaningSearchOptions extends MeetingModelOptions {
|
|
9
|
+
/** Split new transcripts and embed passages that have no vector first. */
|
|
10
|
+
buildMissing?: boolean;
|
|
11
|
+
limit?: number;
|
|
12
|
+
maxChunks?: number;
|
|
13
|
+
/** The meetings both searches read: the word search's own filters, names unresolved. */
|
|
14
|
+
selection?: Omit<MeetingHitSearchRequest, "accountId" | "limit" | "after" | "maxReadBytes" | "signal">;
|
|
15
|
+
/** The previous page's cursor. */
|
|
16
|
+
after?: string;
|
|
17
|
+
maxRows?: number;
|
|
18
|
+
maxTextBytes?: number;
|
|
19
|
+
signal?: AbortSignal;
|
|
20
|
+
}
|
|
21
|
+
export interface MeetingEmbeddingOptions extends MeetingModelOptions {
|
|
22
|
+
limit?: number;
|
|
23
|
+
maxRows?: number;
|
|
24
|
+
maxTextBytes?: number;
|
|
25
|
+
yes?: boolean;
|
|
26
|
+
signal?: AbortSignal;
|
|
27
|
+
}
|
|
28
|
+
type Combined = Awaited<ReturnType<typeof import("./meeting-combined.js").searchMeetingsCombined>>;
|
|
29
|
+
export interface MeetingMeaning {
|
|
30
|
+
search: (query: string, options: MeetingMeaningSearchOptions) => Promise<Combined>;
|
|
31
|
+
generate: (options: MeetingEmbeddingOptions) => Promise<Record<string, unknown>>;
|
|
32
|
+
}
|
|
33
|
+
export declare const validateMeetingModel: (options: MeetingModelOptions) => void;
|
|
34
|
+
export declare const validateMeetingMeaningSearch: (query: string, options: MeetingMeaningSearchOptions) => void;
|
|
35
|
+
export declare const validateMeetingEmbeddings: (options: MeetingEmbeddingOptions) => void;
|
|
36
|
+
export type MeetingMeaningApi = Pick<typeof import("./meeting-model.js"), "meetingEmbeddingModel" | "createMeetingRemoteModel" | "openMeetingEmbedder"> & Pick<typeof import("./meeting-combined.js"), "searchMeetingsCombined"> & Pick<typeof import("./meeting-semantic.js"), "proposeMeetingEmbedding" | "applyMeetingEmbedding">;
|
|
37
|
+
/**
|
|
38
|
+
* Search by meaning and the vectors it reads, over one account's stored meetings. A local model keeps the
|
|
39
|
+
* transcripts on this computer; `baseUrl` sends passages to that service and is only ever chosen by the caller.
|
|
40
|
+
*/
|
|
41
|
+
export declare const meetingMeaning: (store: Pick<MessageStore, "meetings" | "meetingVectors"> & {
|
|
42
|
+
knowledge?: MessageStore["knowledge"];
|
|
43
|
+
}, accountId: number, options?: {
|
|
44
|
+
env?: NodeJS.ProcessEnv;
|
|
45
|
+
load?: () => Promise<MeetingMeaningApi>;
|
|
46
|
+
}) => MeetingMeaning;
|
|
47
|
+
export {};
|