@wirecat/cli-core 0.663.0 → 0.665.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 +141 -0
- package/dist/background/daily-archive-timer.d.ts +1 -1
- package/dist/calendar/index.d.ts +1 -1
- package/dist/calendar/index.js +1 -1
- package/dist/calendar/prepare.d.ts +2 -2
- package/dist/calendar/reads.d.ts +5 -5
- package/dist/calendar/writes.d.ts +4 -4
- 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/index.d.ts +2 -0
- package/dist/cli/index.js +2 -0
- 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-projects.d.ts +6 -0
- package/dist/cli/meeting-preparation-read.d.ts +6 -0
- package/dist/cli/meeting-tags-command.d.ts +18 -0
- package/dist/cli/meeting-tags-command.js +74 -0
- 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/models-command.js +7 -0
- package/dist/cli/messenger/records-command.d.ts +4 -1
- package/dist/cli/messenger/records-command.js +6 -1
- package/dist/cli/model-catalogue-command.js +2 -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/domain/links.d.ts +11 -0
- package/dist/domain/links.js +4 -0
- package/dist/entities/chat-sending.d.ts +10 -0
- package/dist/entities/chat-sending.js +11 -0
- package/dist/entities/index.d.ts +43 -1
- package/dist/entities/index.js +6 -2
- package/dist/entities/listings.d.ts +60 -0
- package/dist/entities/listings.js +15 -0
- 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 -1
- package/dist/mcp/meeting-preparation.d.ts +6 -0
- package/dist/meetings/answers.d.ts +7 -0
- package/dist/meetings/answers.js +4 -0
- package/dist/meetings/event-store.d.ts +2 -1
- package/dist/meetings/event-store.js +6 -0
- package/dist/meetings/index.d.ts +2 -1
- package/dist/meetings/index.js +2 -1
- package/dist/meetings/mcp/search.d.ts +6 -0
- package/dist/meetings/project-evidence-answer.d.ts +6 -0
- package/dist/meetings/tag-answers.d.ts +43 -0
- package/dist/meetings/tag-answers.js +41 -0
- package/dist/models/chat-sending.d.ts +24 -0
- package/dist/models/chat-sending.js +40 -0
- package/dist/runs/events.d.ts +1 -1
- package/dist/search/question-plan.d.ts +5 -0
- package/dist/search/question-plan.js +5 -0
- package/dist/search/task-similarity.d.ts +1 -0
- package/dist/search/task-similarity.js +1 -1
- package/dist/services/embeddings-search.js +19 -5
- package/dist/services/embeddings.d.ts +4 -0
- package/dist/services/index.d.ts +2 -0
- package/dist/services/index.js +2 -0
- package/dist/services/listings.js +17 -2
- 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-discovery.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/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/knowledge.d.ts +1 -1
- package/dist/store/sqlite/knowledge.js +8 -4
- 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/meeting-listing.d.ts +12 -0
- package/dist/store/sqlite/meeting-listing.js +20 -5
- package/dist/store/sqlite/notes.d.ts +1 -1
- package/dist/store/sqlite/notes.js +1 -1
- package/package.json +18 -3
- package/parity.json +20 -1
- package/skills/link-conversations/SKILL.md +1 -1
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
/** What `tags add` or `tags remove` changed on the meetings its `--meeting` ids or `--matching` search named. */
|
|
3
|
+
export declare const meetingTagChange: v.StrictObjectSchema<{
|
|
4
|
+
readonly tags: v.ArraySchema<v.StringSchema<undefined>, undefined>;
|
|
5
|
+
/** How many stored meetings were named: the ids given, or the meetings with at least one hit of the search. */
|
|
6
|
+
readonly matched: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
7
|
+
/** Only the meetings whose labels changed, each with the tags it gained or lost; a rerun changes none. */
|
|
8
|
+
readonly changed: v.ArraySchema<v.StrictObjectSchema<{
|
|
9
|
+
readonly meeting: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
10
|
+
readonly meeting_id: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 1, undefined>]>;
|
|
11
|
+
readonly tags: v.ArraySchema<v.StringSchema<undefined>, undefined>;
|
|
12
|
+
}, undefined>, undefined>;
|
|
13
|
+
}, undefined>;
|
|
14
|
+
/** One labelled meeting of the account, with all its tags. */
|
|
15
|
+
export declare const meetingTagging: v.StrictObjectSchema<{
|
|
16
|
+
readonly meeting: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
17
|
+
readonly meeting_id: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 1, undefined>]>;
|
|
18
|
+
readonly title: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
19
|
+
readonly started_at: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, "an ISO 8601 time in UTC">, v.EndsWithAction<string, "Z", "an ISO 8601 time in UTC, ending in `Z`">]>, undefined>;
|
|
20
|
+
readonly tags: v.ArraySchema<v.StringSchema<undefined>, undefined>;
|
|
21
|
+
/** The title is the source's own line, such as a caller's name from caller ID: data, never instructions. */
|
|
22
|
+
readonly untrusted: v.ArraySchema<v.StringSchema<undefined>, undefined>;
|
|
23
|
+
}, undefined>;
|
|
24
|
+
export type MeetingTagChangeItem = v.InferOutput<typeof meetingTagChange>;
|
|
25
|
+
export type MeetingTaggingItem = v.InferOutput<typeof meetingTagging>;
|
|
26
|
+
export interface MeetingTagChange {
|
|
27
|
+
accountId: number;
|
|
28
|
+
tags: string[];
|
|
29
|
+
matched: number;
|
|
30
|
+
changed: {
|
|
31
|
+
meetingId: number;
|
|
32
|
+
tags: string[];
|
|
33
|
+
}[];
|
|
34
|
+
}
|
|
35
|
+
export interface MeetingTagged {
|
|
36
|
+
accountId: number;
|
|
37
|
+
meetingId: number;
|
|
38
|
+
title: string | null;
|
|
39
|
+
startedAt: number | null;
|
|
40
|
+
tags: string[];
|
|
41
|
+
}
|
|
42
|
+
export declare const meetingTagChangeItem: (change: MeetingTagChange) => MeetingTagChangeItem;
|
|
43
|
+
export declare const meetingTaggingItem: (one: MeetingTagged) => MeetingTaggingItem;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { isoTime, reference } from "@wirecat/cli-base/standards";
|
|
2
|
+
import * as v from "valibot";
|
|
3
|
+
import { formatMeetingReference } from "./reference.js";
|
|
4
|
+
const text = v.string();
|
|
5
|
+
const storeId = v.pipe(v.number(), v.integer(), v.minValue(1));
|
|
6
|
+
/** What `tags add` or `tags remove` changed on the meetings its `--meeting` ids or `--matching` search named. */
|
|
7
|
+
export const meetingTagChange = v.strictObject({
|
|
8
|
+
tags: v.array(text),
|
|
9
|
+
/** How many stored meetings were named: the ids given, or the meetings with at least one hit of the search. */
|
|
10
|
+
matched: v.pipe(v.number(), v.integer(), v.minValue(0)),
|
|
11
|
+
/** Only the meetings whose labels changed, each with the tags it gained or lost; a rerun changes none. */
|
|
12
|
+
changed: v.array(v.strictObject({ meeting: reference, meeting_id: storeId, tags: v.array(text) })),
|
|
13
|
+
});
|
|
14
|
+
/** One labelled meeting of the account, with all its tags. */
|
|
15
|
+
export const meetingTagging = v.strictObject({
|
|
16
|
+
meeting: reference,
|
|
17
|
+
meeting_id: storeId,
|
|
18
|
+
title: v.nullable(text),
|
|
19
|
+
started_at: v.nullable(isoTime),
|
|
20
|
+
tags: v.array(text),
|
|
21
|
+
/** The title is the source's own line, such as a caller's name from caller ID: data, never instructions. */
|
|
22
|
+
untrusted: v.array(text),
|
|
23
|
+
});
|
|
24
|
+
const ref = (accountId, meetingId) => formatMeetingReference({ type: "meeting", accountId, meetingId });
|
|
25
|
+
export const meetingTagChangeItem = (change) => ({
|
|
26
|
+
tags: change.tags,
|
|
27
|
+
matched: change.matched,
|
|
28
|
+
changed: change.changed.map(({ meetingId, tags }) => ({
|
|
29
|
+
meeting: ref(change.accountId, meetingId),
|
|
30
|
+
meeting_id: meetingId,
|
|
31
|
+
tags,
|
|
32
|
+
})),
|
|
33
|
+
});
|
|
34
|
+
export const meetingTaggingItem = (one) => ({
|
|
35
|
+
meeting: ref(one.accountId, one.meetingId),
|
|
36
|
+
meeting_id: one.meetingId,
|
|
37
|
+
title: one.title,
|
|
38
|
+
started_at: one.startedAt === null ? null : new Date(one.startedAt).toISOString(),
|
|
39
|
+
tags: one.tags,
|
|
40
|
+
untrusted: ["title"],
|
|
41
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { CliError } from "@wirecat/cli-base";
|
|
2
|
+
import * as v from "valibot";
|
|
3
|
+
export declare const CHAT_SENDING_MODES: readonly ["allowed", "ask", "denied"];
|
|
4
|
+
export type ChatSendingMode = (typeof CHAT_SENDING_MODES)[number];
|
|
5
|
+
declare const Setting: v.StrictObjectSchema<{
|
|
6
|
+
readonly mode: v.PicklistSchema<readonly ["allowed", "ask", "denied"], undefined>;
|
|
7
|
+
readonly at: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, undefined>]>;
|
|
8
|
+
}, undefined>;
|
|
9
|
+
export type ChatSendingSetting = v.InferOutput<typeof Setting>;
|
|
10
|
+
/** The owner's choice, ask when absent. A broken section reads as denied: a typo must not let chat text out. */
|
|
11
|
+
export declare const readChatSending: (env: NodeJS.ProcessEnv) => ChatSendingSetting | undefined;
|
|
12
|
+
export declare const chatSendingMode: (env: NodeJS.ProcessEnv) => ChatSendingMode;
|
|
13
|
+
export declare const writeChatSending: (env: NodeJS.ProcessEnv, mode: ChatSendingMode) => void;
|
|
14
|
+
/** An agent may make the setting stricter, never looser: loosening lets the owner's chats out. */
|
|
15
|
+
export declare const loosens: (from: ChatSendingMode, to: ChatSendingMode) => boolean;
|
|
16
|
+
export declare const chatSendingCommand: (command: string, mode: ChatSendingMode) => string;
|
|
17
|
+
/**
|
|
18
|
+
* Throws when the setting is denied; answers whether the run may go ahead without asking. Called only for a model
|
|
19
|
+
* that is not on this computer: a local model is never "outside".
|
|
20
|
+
*/
|
|
21
|
+
export declare const chatSendingAllowed: (env: NodeJS.ProcessEnv, host: string, command: string) => boolean;
|
|
22
|
+
/** The refusal under ask when nobody can answer: what an agent can do next. */
|
|
23
|
+
export declare const chatSendingAskRefusal: (what: string, command: string) => CliError;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { CliError } from "@wirecat/cli-base";
|
|
2
|
+
import * as v from "valibot";
|
|
3
|
+
import { storePath } from "../store/path.js";
|
|
4
|
+
import { readSharedSection, sharedConfigPath, writeSharedSection } from "../store/shared-config.js";
|
|
5
|
+
export const CHAT_SENDING_MODES = ["allowed", "ask", "denied"];
|
|
6
|
+
const SECTION = "chat_sending";
|
|
7
|
+
const Setting = v.strictObject({
|
|
8
|
+
mode: v.picklist(CHAT_SENDING_MODES),
|
|
9
|
+
at: v.pipe(v.string(), v.isoTimestamp()),
|
|
10
|
+
});
|
|
11
|
+
const pathOf = (env) => sharedConfigPath(storePath(env), env);
|
|
12
|
+
/** The owner's choice, ask when absent. A broken section reads as denied: a typo must not let chat text out. */
|
|
13
|
+
export const readChatSending = (env) => {
|
|
14
|
+
const section = readSharedSection(pathOf(env), SECTION);
|
|
15
|
+
if (section === undefined || section === null)
|
|
16
|
+
return undefined;
|
|
17
|
+
const checked = v.safeParse(Setting, section);
|
|
18
|
+
return checked.success ? checked.output : { mode: "denied", at: new Date(0).toISOString() };
|
|
19
|
+
};
|
|
20
|
+
export const chatSendingMode = (env) => readChatSending(env)?.mode ?? "ask";
|
|
21
|
+
export const writeChatSending = (env, mode) => writeSharedSection(pathOf(env), SECTION, mode === "ask" ? undefined : { mode, at: new Date().toISOString() });
|
|
22
|
+
const STRICTNESS = { allowed: 0, ask: 1, denied: 2 };
|
|
23
|
+
/** An agent may make the setting stricter, never looser: loosening lets the owner's chats out. */
|
|
24
|
+
export const loosens = (from, to) => STRICTNESS[to] < STRICTNESS[from];
|
|
25
|
+
export const chatSendingCommand = (command, mode) => `${command} models chats set ${mode}`;
|
|
26
|
+
/**
|
|
27
|
+
* Throws when the setting is denied; answers whether the run may go ahead without asking. Called only for a model
|
|
28
|
+
* that is not on this computer: a local model is never "outside".
|
|
29
|
+
*/
|
|
30
|
+
export const chatSendingAllowed = (env, host, command) => {
|
|
31
|
+
const mode = chatSendingMode(env);
|
|
32
|
+
if (mode === "denied")
|
|
33
|
+
throw new CliError("permission_error", `sending chat text to a model outside this computer is denied by the setting \`models chats\`; nothing was sent ` +
|
|
34
|
+
`to ${host}, and --yes does not change that. Use a model on this computer, or ask the owner to run ` +
|
|
35
|
+
`\`${chatSendingCommand(command, "ask")}\` (or \`allowed\`)`, { reason: "chat-sending.denied" });
|
|
36
|
+
return mode === "allowed";
|
|
37
|
+
};
|
|
38
|
+
/** The refusal under ask when nobody can answer: what an agent can do next. */
|
|
39
|
+
export const chatSendingAskRefusal = (what, command) => new CliError("confirmation_required", `${what} — add --yes to send them (an agent may pass yes), or ask the owner to run ` +
|
|
40
|
+
`\`${chatSendingCommand(command, "allowed")}\` so no yes is needed`, { reason: "chat-sending.ask" });
|
package/dist/runs/events.d.ts
CHANGED
|
@@ -37,7 +37,7 @@ export interface RequestEvent {
|
|
|
37
37
|
* requests when it has any, so one operation over three frames is three requests, never four.
|
|
38
38
|
*/
|
|
39
39
|
level?: "operation" | "wire";
|
|
40
|
-
transport?: "http" | "mtproto" | "max-ws" | "wa-engine" | "sftp";
|
|
40
|
+
transport?: "http" | "mtproto" | "max-ws" | "wa-engine" | "sftp" | "ssh" | "sql";
|
|
41
41
|
/** 1 for the first try, 2 and up for a retry of the same call. */
|
|
42
42
|
attempt?: number;
|
|
43
43
|
/** How long the client waited before this attempt: a flood wait or a `Retry-After`. */
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
export declare const words: (text: string) => RegExpMatchArray | [];
|
|
2
|
+
/**
|
|
3
|
+
* `альфа-банк` also as `альфабанк`: people write one name both ways, and the index keeps each as typed. Only letters
|
|
4
|
+
* on both sides of a hyphen, and never a field's value: `date:2026-10-08` is no word.
|
|
5
|
+
*/
|
|
6
|
+
export declare const joinedHyphens: (text: string) => string[];
|
|
2
7
|
/** Words that carry no topic of their own: widening one to a prefix (`про*`) finds only noise. */
|
|
3
8
|
export declare const isFunctionWord: (word: string) => boolean;
|
|
4
9
|
/**
|
|
@@ -3,6 +3,11 @@ import { implicitTextTerms, parseLucene, walkQuery } from "@wirecat/cli-base/que
|
|
|
3
3
|
import { normalize } from "../store/normalize.js";
|
|
4
4
|
import { MESSAGE_PARSING } from "./lucene/types.js";
|
|
5
5
|
export const words = (text) => normalize(text).match(/[\p{L}\p{N}]+/gu) ?? [];
|
|
6
|
+
/**
|
|
7
|
+
* `альфа-банк` also as `альфабанк`: people write one name both ways, and the index keeps each as typed. Only letters
|
|
8
|
+
* on both sides of a hyphen, and never a field's value: `date:2026-10-08` is no word.
|
|
9
|
+
*/
|
|
10
|
+
export const joinedHyphens = (text) => (normalize(text).match(/(?<![:\p{L}\p{N}-])\p{L}[\p{L}\p{N}]*(?:-\p{L}[\p{L}\p{N}]*)+/gu) ?? []).map((word) => word.replaceAll("-", ""));
|
|
6
11
|
const scaffolding = new Set(words("what which how many much who where when is are was were do does did can could should we the a an for of to under from in on at has have сколько какой какая какие какое кто кому кем где когда как что во по на в к с у через ли должен должна нужно идёт идет можно может могут"));
|
|
7
12
|
const questionWord = /\b(?:what|which|how|who|where|when|can|could|should)\b|(?:^|\s)(?:сколько|какой|какая|какие|какое|кто|кому|кем|где|когда|как|что|можно|может|могут|ли)(?:\s|$)/iu;
|
|
8
13
|
const QUESTION_STARTS = new Set(words("what which how who whom whose where when why can could should would did do does is are was were will " +
|
|
@@ -26,6 +26,7 @@ export type PreparedTask = {
|
|
|
26
26
|
dueDay: number | null;
|
|
27
27
|
createdMs: number;
|
|
28
28
|
};
|
|
29
|
+
export declare const STOP_WORDS: ReadonlySet<string>;
|
|
29
30
|
/** What `task_words` holds: the search normalizer, digit groups joined. Message and note words keep `normalize` alone. */
|
|
30
31
|
export declare const taskWordsOf: (text: string) => string;
|
|
31
32
|
/** What `task_stems` holds and the candidate lookup matches: one cleaning for both sides, or bm25 compares unlike. */
|
|
@@ -8,7 +8,7 @@ import { amountOf, dayOf, dueDayOf } from "./task-signature.js";
|
|
|
8
8
|
* quoted beside each weight are that run's duplicate / other candidate pairs at the level.
|
|
9
9
|
*/
|
|
10
10
|
const DAY = 86_400_000;
|
|
11
|
-
const STOP_WORDS = new Set([
|
|
11
|
+
export const STOP_WORDS = new Set([
|
|
12
12
|
// Russian and English as the test set ran them, already folded (пожалуйста → пожалуиста).
|
|
13
13
|
"и в во не что он на я с со как а то все она так его но да ты к у же вы за бы по только ее мне было вот от",
|
|
14
14
|
"меня еще нет о из ему теперь когда даже ну ли если уже или ни быть был него до вас нибудь опять уж вам ведь",
|
|
@@ -2,7 +2,9 @@ import { CliError } from "@wirecat/cli-base";
|
|
|
2
2
|
import { formatLocator, parseLocator } from "../domain/locator.js";
|
|
3
3
|
import { meaningFloor } from "../embeddings/models.js";
|
|
4
4
|
import { fuseRanked } from "../search/fusion.js";
|
|
5
|
-
import { QUERY_LIMITS, searchError } from "../search/lucene/types.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";
|
|
6
8
|
import { threadConversation } from "../store/store.js";
|
|
7
9
|
import { embeddingsMaintenance, embeddingTarget, isStale, notBuiltError, readinessOf, shaped, withEmbedder, } from "./embeddings-maintenance.js";
|
|
8
10
|
import { storedChatId } from "./message-resolution.js";
|
|
@@ -23,8 +25,11 @@ export const embeddingsSearch = (deps) => {
|
|
|
23
25
|
* Only whole words and their beginnings count: a corrected spelling or a piece of a word would pass a
|
|
24
26
|
* near-miss off as a match, which is what the meaning half is for.
|
|
25
27
|
*/
|
|
26
|
-
const byWords = async (query, prepared, conversations, since) => {
|
|
27
|
-
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;
|
|
28
33
|
const outside = new Map();
|
|
29
34
|
if (!words.length || !prepared.scopeAccounts.length)
|
|
30
35
|
return { hits: [], outside, sources: new Map() };
|
|
@@ -33,6 +38,7 @@ export const embeddingsSearch = (deps) => {
|
|
|
33
38
|
text: words.map((word) => (word.length >= 3 ? `${word}*` : `"${word}"`)).join(" OR "),
|
|
34
39
|
accounts: prepared.scopeAccounts,
|
|
35
40
|
limit: WORD_HITS,
|
|
41
|
+
...(timeLimitMs === undefined ? {} : { timeLimitMs }),
|
|
36
42
|
}, deps.messenger);
|
|
37
43
|
const { items } = await store.queries.matchQuery({
|
|
38
44
|
...lexical.execution,
|
|
@@ -124,7 +130,7 @@ export const embeddingsSearch = (deps) => {
|
|
|
124
130
|
return { hits, outside, sources };
|
|
125
131
|
};
|
|
126
132
|
return {
|
|
127
|
-
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 }) => {
|
|
128
134
|
if (!query.trim())
|
|
129
135
|
searchError("query.invalid-syntax", { start: 0, end: query.length }, "give words to search for");
|
|
130
136
|
if (new TextEncoder().encode(query).length > QUERY_LIMITS.bytes)
|
|
@@ -161,7 +167,14 @@ export const embeddingsSearch = (deps) => {
|
|
|
161
167
|
? { chatId: selected.chatId }
|
|
162
168
|
: null
|
|
163
169
|
: {};
|
|
164
|
-
|
|
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
|
+
});
|
|
165
178
|
const meaning = [];
|
|
166
179
|
const sources = words.sources;
|
|
167
180
|
if (target.installed && prepared.scopeAccounts.length && eligibility?.conversations.length !== 0) {
|
|
@@ -231,6 +244,7 @@ export const embeddingsSearch = (deps) => {
|
|
|
231
244
|
accounts: prepared.scopeAccounts,
|
|
232
245
|
model: target.id,
|
|
233
246
|
meaning: target.installed ? "searched" : "unavailable",
|
|
247
|
+
...(wordsOutOfTime ? { words: "out-of-time" } : {}),
|
|
234
248
|
hits: fused(meaning, words.hits, meaningFloor(target.key))
|
|
235
249
|
.slice(0, limit)
|
|
236
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. */
|
package/dist/services/index.d.ts
CHANGED
|
@@ -93,11 +93,13 @@ export { inboxService } from "./inbox.js";
|
|
|
93
93
|
export { readMail } from "./mail-search.js";
|
|
94
94
|
export { type MeetingHitSearchRequest, refreshMeetingIndex, searchMeetingHits } from "./meeting-hit-search.js";
|
|
95
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";
|
|
96
97
|
export { createMeetingProjectCandidateReader } from "./meeting-project-candidates.js";
|
|
97
98
|
export { readMeetingProjectDiscovery } from "./meeting-project-discovery.js";
|
|
98
99
|
export { type MeetingReviewRequest, readMeetingReview } from "./meeting-review.js";
|
|
99
100
|
export { type MeetingSearchesService, type MeetingSearchParams, meetingSearchesService, type SavedMeetingSearch, } from "./meeting-searches.js";
|
|
100
101
|
export { type MeetingCountsRequest, type MeetingStatsRequest, readMeetingCounts, readMeetingStats, } from "./meeting-stats.js";
|
|
102
|
+
export { type MeetingTags, type MeetingTagTarget, meetingTags } from "./meeting-tags.js";
|
|
101
103
|
export { chatIdIn, storedChatId } from "./message-resolution.js";
|
|
102
104
|
export type { AroundWindow, FoundMessage, ListWindow, MessagesService, MessageTarget, Pinned, Reacted, SearchFound, SearchQuery, SendRequest, Starred, } from "./messages.js";
|
|
103
105
|
export { DELETE_AT_ONCE, messagesService } from "./messages.js";
|
package/dist/services/index.js
CHANGED
|
@@ -68,11 +68,13 @@ export { inboxService } from "./inbox.js";
|
|
|
68
68
|
export { readMail } from "./mail-search.js";
|
|
69
69
|
export { refreshMeetingIndex, searchMeetingHits } from "./meeting-hit-search.js";
|
|
70
70
|
export { readMeetingLinks } from "./meeting-links.js";
|
|
71
|
+
export { meetingMeaning, validateMeetingEmbeddings, validateMeetingMeaningSearch, validateMeetingModel, } from "./meeting-meaning.js";
|
|
71
72
|
export { createMeetingProjectCandidateReader } from "./meeting-project-candidates.js";
|
|
72
73
|
export { readMeetingProjectDiscovery } from "./meeting-project-discovery.js";
|
|
73
74
|
export { readMeetingReview } from "./meeting-review.js";
|
|
74
75
|
export { meetingSearchesService, } from "./meeting-searches.js";
|
|
75
76
|
export { readMeetingCounts, readMeetingStats, } from "./meeting-stats.js";
|
|
77
|
+
export { meetingTags } from "./meeting-tags.js";
|
|
76
78
|
export { chatIdIn, storedChatId } from "./message-resolution.js";
|
|
77
79
|
export { DELETE_AT_ONCE, messagesService } from "./messages.js";
|
|
78
80
|
export { searchStore } from "./messages-archive-search.js";
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { CliError } from "@wirecat/cli-base";
|
|
2
|
-
import { eventIdOf } from "../calendar/index.js";
|
|
2
|
+
import { eventIdOf, ruleLine } from "../calendar/index.js";
|
|
3
3
|
import { providerLabel } from "../domain/providers.js";
|
|
4
4
|
import { formatMeetingReference, parseMeetingReference } from "../meetings/index.js";
|
|
5
5
|
import { TOTAL_CAP } from "../search/total.js";
|
|
6
6
|
import { storeQuery } from "./notes-search.js";
|
|
7
7
|
/** How many documents a text term may match before the list counts them as "at least". */
|
|
8
8
|
export const DOCUMENT_TEXT_CANDIDATES = 2_000;
|
|
9
|
+
/** A page link a caller may open: `https` only, so a stored `javascript:` or `file:` link never reaches a button. */
|
|
10
|
+
const webUrl = (url) => (url !== null && /^https:\/\//iu.test(url) ? url : null);
|
|
9
11
|
const iso = (ms) => (ms === null ? null : new Date(ms).toISOString());
|
|
10
12
|
const sourceName = ({ provider, account }) => `${provider}:${account}`;
|
|
11
13
|
const sourceOf = (account) => ({
|
|
@@ -156,6 +158,9 @@ const meetingItem = (row, accounts) => {
|
|
|
156
158
|
via: source.via,
|
|
157
159
|
calendar: source.calendar,
|
|
158
160
|
ref: source.ref,
|
|
161
|
+
page_url: webUrl(source.pageUrl),
|
|
162
|
+
own_response: source.ownResponse,
|
|
163
|
+
conference: source.conference,
|
|
159
164
|
})),
|
|
160
165
|
meetings,
|
|
161
166
|
participants: row.participants,
|
|
@@ -164,8 +169,10 @@ const meetingItem = (row, accounts) => {
|
|
|
164
169
|
has_transcript: row.hasTranscript,
|
|
165
170
|
has_summary: row.hasSummary,
|
|
166
171
|
documents: row.documents,
|
|
172
|
+
series_id: row.seriesId === null ? null : String(row.seriesId),
|
|
173
|
+
recurrence: ruleLine(row.recurrence ?? []) ?? null,
|
|
167
174
|
pending_findings: row.pendingFindings,
|
|
168
|
-
untrusted: ["title", "participants.name", "sources.calendar", "documents.title"],
|
|
175
|
+
untrusted: ["title", "participants.name", "sources.calendar", "sources.conference", "documents.title"],
|
|
169
176
|
};
|
|
170
177
|
};
|
|
171
178
|
const personIdOf = (value) => {
|
|
@@ -231,6 +238,7 @@ export const showMeetingEntry = async (store, reference, lines) => {
|
|
|
231
238
|
details.push(one);
|
|
232
239
|
}
|
|
233
240
|
const live = event?.entries.find(({ deletedAt }) => deletedAt === null) ?? event?.entries[0];
|
|
241
|
+
const files = new Map((event?.attachments ?? []).map((one) => [one.fileId, one]));
|
|
234
242
|
const first = details[0]?.meeting;
|
|
235
243
|
const spoken = details.flatMap((one) => one.transcripts
|
|
236
244
|
.filter(({ transcript }) => transcript.deletedAt === null && transcript.supersededAt === null)
|
|
@@ -240,6 +248,11 @@ export const showMeetingEntry = async (store, reference, lines) => {
|
|
|
240
248
|
...meetingItem(row, byName),
|
|
241
249
|
description: live?.description ?? event?.event.description ?? first?.description ?? null,
|
|
242
250
|
location: live?.location ?? event?.event.location ?? first?.location ?? null,
|
|
251
|
+
attachments: [...files.values()].map(({ fileId, title, documentId }) => ({
|
|
252
|
+
file_id: fileId,
|
|
253
|
+
title,
|
|
254
|
+
document: documentId === null ? null : `document:${documentId}`,
|
|
255
|
+
})),
|
|
243
256
|
summaries: details.flatMap((one) => one.summaries.map((summary) => ({
|
|
244
257
|
meeting: ref(one.meeting),
|
|
245
258
|
source: summary.source,
|
|
@@ -277,7 +290,9 @@ export const showMeetingEntry = async (store, reference, lines) => {
|
|
|
277
290
|
"location",
|
|
278
291
|
"participants.name",
|
|
279
292
|
"sources.calendar",
|
|
293
|
+
"sources.conference",
|
|
280
294
|
"documents.title",
|
|
295
|
+
"attachments.title",
|
|
281
296
|
"summaries",
|
|
282
297
|
"transcript.lines.speaker",
|
|
283
298
|
"transcript.lines.text",
|
|
@@ -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 {};
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { CliError } from "@wirecat/cli-base";
|
|
2
|
+
const bounded = (value, maximum) => value === undefined || (Number.isSafeInteger(value) && value > 0 && value <= maximum);
|
|
3
|
+
export const validateMeetingModel = (options) => {
|
|
4
|
+
if (typeof options.model !== "string" || !options.model.trim() || options.model.length > 1000)
|
|
5
|
+
throw new CliError("validation_error", "select an explicit embedding model");
|
|
6
|
+
if (options.baseUrl === undefined) {
|
|
7
|
+
if (options.dims !== undefined)
|
|
8
|
+
throw new CliError("validation_error", "dimensions require an explicit remote base URL");
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
let url;
|
|
12
|
+
try {
|
|
13
|
+
url = new URL(options.baseUrl);
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
throw new CliError("validation_error", "embedding base URL must be an HTTP or HTTPS URL");
|
|
17
|
+
}
|
|
18
|
+
if (!["http:", "https:"].includes(url.protocol) ||
|
|
19
|
+
url.username ||
|
|
20
|
+
url.password ||
|
|
21
|
+
url.search ||
|
|
22
|
+
url.hash ||
|
|
23
|
+
!/^[\w./:-]{1,200}$/.test(options.model) ||
|
|
24
|
+
options.dims === undefined ||
|
|
25
|
+
!bounded(options.dims, 8192))
|
|
26
|
+
throw new CliError("validation_error", "remote embeddings require an HTTP base URL without credentials and explicit dimensions");
|
|
27
|
+
};
|
|
28
|
+
export const validateMeetingMeaningSearch = (query, options) => {
|
|
29
|
+
validateMeetingModel(options);
|
|
30
|
+
if (typeof query !== "string" ||
|
|
31
|
+
!query.trim() ||
|
|
32
|
+
Buffer.byteLength(query, "utf8") > 65536 ||
|
|
33
|
+
!bounded(options.limit, 1000) ||
|
|
34
|
+
!bounded(options.maxChunks, 100000) ||
|
|
35
|
+
!bounded(options.maxRows, 100000) ||
|
|
36
|
+
!bounded(options.maxTextBytes, 64 * 1024 * 1024))
|
|
37
|
+
throw new CliError("validation_error", "meeting semantic search requires a nonempty bounded query and positive limits");
|
|
38
|
+
};
|
|
39
|
+
export const validateMeetingEmbeddings = (options) => {
|
|
40
|
+
validateMeetingModel(options);
|
|
41
|
+
if (!bounded(options.limit, 1000) ||
|
|
42
|
+
!bounded(options.maxRows, 100000) ||
|
|
43
|
+
!bounded(options.maxTextBytes, 64 * 1024 * 1024))
|
|
44
|
+
throw new CliError("validation_error", "meeting embedding generation requires valid bounded limits");
|
|
45
|
+
};
|
|
46
|
+
// The embedding runtime is heavy; a command that never asks for meaning never loads it.
|
|
47
|
+
const loadApi = async () => {
|
|
48
|
+
const [model, combined, semantic] = await Promise.all([
|
|
49
|
+
import("./meeting-model.js"),
|
|
50
|
+
import("./meeting-combined.js"),
|
|
51
|
+
import("./meeting-semantic.js"),
|
|
52
|
+
]);
|
|
53
|
+
return { ...model, ...combined, ...semantic };
|
|
54
|
+
};
|
|
55
|
+
const checkCancelled = (signal) => {
|
|
56
|
+
if (!signal?.aborted)
|
|
57
|
+
return;
|
|
58
|
+
if (signal.reason instanceof CliError)
|
|
59
|
+
throw signal.reason;
|
|
60
|
+
const timedOut = signal.reason instanceof Error && signal.reason.name === "TimeoutError";
|
|
61
|
+
throw new CliError(timedOut ? "timeout" : "cancelled", timedOut ? "command timed out" : "command cancelled");
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Search by meaning and the vectors it reads, over one account's stored meetings. A local model keeps the
|
|
65
|
+
* transcripts on this computer; `baseUrl` sends passages to that service and is only ever chosen by the caller.
|
|
66
|
+
*/
|
|
67
|
+
export const meetingMeaning = (store, accountId, options = {}) => {
|
|
68
|
+
if (!Number.isSafeInteger(accountId) || accountId < 1)
|
|
69
|
+
throw new CliError("validation_error", "meeting vectors require a selected positive account ID");
|
|
70
|
+
const load = options.load ?? loadApi;
|
|
71
|
+
const choice = (api, input) => input.baseUrl === undefined
|
|
72
|
+
? input.model
|
|
73
|
+
: { remote: api.createMeetingRemoteModel({ model: input.model, baseUrl: input.baseUrl, dims: input.dims }) };
|
|
74
|
+
const budget = (input) => ({
|
|
75
|
+
maxRows: input.maxRows,
|
|
76
|
+
maxTextBytes: input.maxTextBytes,
|
|
77
|
+
signal: input.signal,
|
|
78
|
+
});
|
|
79
|
+
// rebuild has no "new transcripts only" mode, so every pass splits every current transcript again; only
|
|
80
|
+
// passages without a vector for this model reach the embedder.
|
|
81
|
+
const splitAll = async (input) => {
|
|
82
|
+
let afterTranscriptId;
|
|
83
|
+
let pages = 0;
|
|
84
|
+
for (;;) {
|
|
85
|
+
checkCancelled(input.signal);
|
|
86
|
+
const page = await store.meetingVectors.rebuild({ accountId, limit: 1000, afterTranscriptId, ...budget(input) });
|
|
87
|
+
pages += 1;
|
|
88
|
+
if (!page.hasMore || page.nextTranscriptId === undefined)
|
|
89
|
+
return { pages };
|
|
90
|
+
afterTranscriptId = page.nextTranscriptId;
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
const buildMissing = async (api, embedder, input) => {
|
|
94
|
+
await splitAll(input);
|
|
95
|
+
let afterHash;
|
|
96
|
+
for (;;) {
|
|
97
|
+
checkCancelled(input.signal);
|
|
98
|
+
const batch = await api.applyMeetingEmbedding(store.meetingVectors, accountId, embedder, {
|
|
99
|
+
afterHash,
|
|
100
|
+
...budget(input),
|
|
101
|
+
});
|
|
102
|
+
if (!batch.hasMore || batch.nextHash === undefined)
|
|
103
|
+
return;
|
|
104
|
+
afterHash = batch.nextHash;
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
return {
|
|
108
|
+
search: async (query, input) => {
|
|
109
|
+
validateMeetingMeaningSearch(query, input);
|
|
110
|
+
checkCancelled(input.signal);
|
|
111
|
+
const api = await load();
|
|
112
|
+
checkCancelled(input.signal);
|
|
113
|
+
const embedder = await api.openMeetingEmbedder(choice(api, input), { env: options.env, signal: input.signal });
|
|
114
|
+
try {
|
|
115
|
+
if (input.buildMissing)
|
|
116
|
+
await buildMissing(api, embedder, input);
|
|
117
|
+
return await api.searchMeetingsCombined(store, embedder, query, {
|
|
118
|
+
...input.selection,
|
|
119
|
+
accountId,
|
|
120
|
+
...(input.limit === undefined ? {} : { limit: input.limit }),
|
|
121
|
+
...(input.after === undefined ? {} : { after: input.after }),
|
|
122
|
+
...(input.maxChunks === undefined ? {} : { maxChunks: input.maxChunks }),
|
|
123
|
+
...(input.maxRows === undefined ? {} : { maxRows: input.maxRows }),
|
|
124
|
+
...(input.maxTextBytes === undefined ? {} : { maxTextBytes: input.maxTextBytes }),
|
|
125
|
+
...(input.signal ? { signal: input.signal } : {}),
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
finally {
|
|
129
|
+
await embedder.close();
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
generate: async (input) => {
|
|
133
|
+
validateMeetingEmbeddings(input);
|
|
134
|
+
checkCancelled(input.signal);
|
|
135
|
+
const api = await load();
|
|
136
|
+
checkCancelled(input.signal);
|
|
137
|
+
const selected = choice(api, input);
|
|
138
|
+
const descriptor = api.meetingEmbeddingModel(selected, options.env);
|
|
139
|
+
if (input.yes !== true)
|
|
140
|
+
return api.proposeMeetingEmbedding(store.meetingVectors, accountId, descriptor, { signal: input.signal });
|
|
141
|
+
const embedder = await api.openMeetingEmbedder(selected, { env: options.env, signal: input.signal });
|
|
142
|
+
try {
|
|
143
|
+
checkCancelled(input.signal);
|
|
144
|
+
// Passages that already have a vector are never offered again, so the next run takes the next batch.
|
|
145
|
+
const rebuild = await splitAll(input);
|
|
146
|
+
checkCancelled(input.signal);
|
|
147
|
+
const result = await api.applyMeetingEmbedding(store.meetingVectors, accountId, embedder, {
|
|
148
|
+
maxChunks: input.limit,
|
|
149
|
+
...budget(input),
|
|
150
|
+
});
|
|
151
|
+
return { ...result, applied: true, model: descriptor, rebuild };
|
|
152
|
+
}
|
|
153
|
+
finally {
|
|
154
|
+
await embedder.close();
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
};
|
|
158
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { MeetingTagChange, MeetingTagged } from "../meetings/index.js";
|
|
2
|
+
import type { MessageStore } from "../store/store.js";
|
|
3
|
+
/** The meetings a tag change acts on: these store ids, or every meeting with a hit of a `search meetings` query. */
|
|
4
|
+
export type MeetingTagTarget = {
|
|
5
|
+
meetings: number[];
|
|
6
|
+
} | {
|
|
7
|
+
matching: string;
|
|
8
|
+
};
|
|
9
|
+
export interface MeetingTags {
|
|
10
|
+
add(target: MeetingTagTarget, tags: string[], signal?: AbortSignal): Promise<MeetingTagChange>;
|
|
11
|
+
remove(target: MeetingTagTarget, tags: string[], signal?: AbortSignal): Promise<MeetingTagChange>;
|
|
12
|
+
list(request: {
|
|
13
|
+
tag?: string;
|
|
14
|
+
limit: number;
|
|
15
|
+
offset: number;
|
|
16
|
+
}): Promise<{
|
|
17
|
+
items: MeetingTagged[];
|
|
18
|
+
hasMore: boolean;
|
|
19
|
+
}>;
|
|
20
|
+
}
|
|
21
|
+
type Store = Pick<MessageStore, "meetings" | "knowledge">;
|
|
22
|
+
/**
|
|
23
|
+
* The owner's labels on one account's meetings, kept in the store's taggings like every other tag, so `--tag` and
|
|
24
|
+
* `tag:` in `search meetings` select them. A mark stays when a new transcript no longer says the words.
|
|
25
|
+
*/
|
|
26
|
+
export declare const meetingTags: (store: Store, accountId: number) => MeetingTags;
|
|
27
|
+
export {};
|