@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
|
@@ -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
|
+
});
|
|
@@ -2,6 +2,7 @@ export { meetingStoreContract } from "./contract.js";
|
|
|
2
2
|
export { CONTRACT_NOW, type EventStoreFixture, eventStoreContract } from "./event-store-contract.js";
|
|
3
3
|
export { type MeetingManagementContractFixture, meetingManagementContract } from "./management-contract.js";
|
|
4
4
|
export { memoryMeetingStore } from "./memory.js";
|
|
5
|
+
export { flagPaging } from "./paging.js";
|
|
5
6
|
export { type RecordingSyncCheckpointFixture, recordingSyncCheckpointStoreContract, } from "./recording-sync-contract.js";
|
|
6
7
|
export { memoryRecordingSyncCheckpointStore } from "./recording-sync-memory.js";
|
|
7
8
|
export { type RecordingTransferStorageFixture, recordingTransferStorageContract, } from "./recording-transfer-contract.js";
|
|
@@ -2,6 +2,7 @@ export { meetingStoreContract } from "./contract.js";
|
|
|
2
2
|
export { CONTRACT_NOW, eventStoreContract } from "./event-store-contract.js";
|
|
3
3
|
export { meetingManagementContract } from "./management-contract.js";
|
|
4
4
|
export { memoryMeetingStore } from "./memory.js";
|
|
5
|
+
export { flagPaging } from "./paging.js";
|
|
5
6
|
export { recordingSyncCheckpointStoreContract, } from "./recording-sync-contract.js";
|
|
6
7
|
export { memoryRecordingSyncCheckpointStore } from "./recording-sync-memory.js";
|
|
7
8
|
export { recordingTransferStorageContract, } from "./recording-transfer-contract.js";
|
|
@@ -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" });
|
|
@@ -83,6 +83,8 @@ export type GroupRules = v.InferOutput<typeof groupRules>;
|
|
|
83
83
|
export declare const defaultRules: (title: string | null) => GroupRules;
|
|
84
84
|
export declare const RULE_KEYS: string[];
|
|
85
85
|
export declare const moderationPathFor: (app: AppIdentity, profile: string, env?: NodeJS.ProcessEnv) => string;
|
|
86
|
+
/** The choices when a caller named no profile: those logged in to here, and those that keep moderation rules. */
|
|
87
|
+
export declare const moderationProfiles: (app: AppIdentity, env?: NodeJS.ProcessEnv) => string[];
|
|
86
88
|
/**
|
|
87
89
|
* The rules of each group this profile moderates, one file per profile beside the recipient list —
|
|
88
90
|
* the path max-cli used, so its rules carry over. May be edited by hand; a file that does not check
|
package/dist/moderation/rules.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
1
|
+
import { existsSync, readdirSync, readFileSync } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { CliError, resolvePaths, writeSecurely } from "@wirecat/cli-base";
|
|
4
4
|
import * as v from "valibot";
|
|
@@ -80,7 +80,21 @@ const KEYS = {
|
|
|
80
80
|
"consent.remove": { help: LEVELS.join("|"), parse: String },
|
|
81
81
|
};
|
|
82
82
|
export const RULE_KEYS = Object.keys(KEYS);
|
|
83
|
-
|
|
83
|
+
const stateFolder = (app, env, folder) => join(resolvePaths({ appName: app.appName, prefix: app.envPrefix, env }).state, folder);
|
|
84
|
+
const profilesFolder = (app, env) => stateFolder(app, env, "profiles");
|
|
85
|
+
export const moderationPathFor = (app, profile, env = process.env) => join(profilesFolder(app, env), `${profile}.moderation.json`);
|
|
86
|
+
const namesIn = (folder, suffix) => existsSync(folder)
|
|
87
|
+
? readdirSync(folder)
|
|
88
|
+
.filter((name) => name.endsWith(suffix))
|
|
89
|
+
.map((name) => name.slice(0, -suffix.length))
|
|
90
|
+
: [];
|
|
91
|
+
/** The choices when a caller named no profile: those logged in to here, and those that keep moderation rules. */
|
|
92
|
+
export const moderationProfiles = (app, env = process.env) => [
|
|
93
|
+
...new Set([
|
|
94
|
+
...namesIn(stateFolder(app, env, "accounts"), ".json"),
|
|
95
|
+
...namesIn(profilesFolder(app, env), ".moderation.json"),
|
|
96
|
+
]),
|
|
97
|
+
].sort();
|
|
84
98
|
/**
|
|
85
99
|
* The rules of each group this profile moderates, one file per profile beside the recipient list —
|
|
86
100
|
* the path max-cli used, so its rules carry over. May be edited by hand; a file that does not check
|
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`. */
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Reciprocal rank fusion's usual constant, as conversations use. */
|
|
2
|
+
export declare const RRF_K = 60;
|
|
3
|
+
export interface FusedFacts {
|
|
4
|
+
/** The hit holds the exact forms of the words, when the search was stemmed. */
|
|
5
|
+
exact?: boolean | undefined;
|
|
6
|
+
/** Its index ranked it by relevance; an unranked hit came by a field, a transcript or a file. */
|
|
7
|
+
ranked: boolean;
|
|
8
|
+
/** Milliseconds: what breaks a tie, newest first. */
|
|
9
|
+
at: number;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Lists, each best first from its own index, as one list best first. Raw scores of two word indexes never compare
|
|
13
|
+
* (each BM25 depends on its own corpus), so a hit's place in its own list votes instead, by reciprocal rank fusion;
|
|
14
|
+
* that place also carries the transcript and file tiers the list was sorted by. Exact hits stay first and ranked
|
|
15
|
+
* ones before unranked, as within one list. With nothing ranked, newest first.
|
|
16
|
+
*/
|
|
17
|
+
export declare const fuseRanked: <T>(lists: readonly (readonly T[])[], facts: (item: T) => FusedFacts) => T[];
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Reciprocal rank fusion's usual constant, as conversations use. */
|
|
2
|
+
export const RRF_K = 60;
|
|
3
|
+
/**
|
|
4
|
+
* Lists, each best first from its own index, as one list best first. Raw scores of two word indexes never compare
|
|
5
|
+
* (each BM25 depends on its own corpus), so a hit's place in its own list votes instead, by reciprocal rank fusion;
|
|
6
|
+
* that place also carries the transcript and file tiers the list was sorted by. Exact hits stay first and ranked
|
|
7
|
+
* ones before unranked, as within one list. With nothing ranked, newest first.
|
|
8
|
+
*/
|
|
9
|
+
export const fuseRanked = (lists, facts) => {
|
|
10
|
+
const rows = lists.flatMap((list) => list.map((item, rank) => ({ item, vote: 1 / (RRF_K + rank + 1), ...facts(item) })));
|
|
11
|
+
const ranking = rows.some(({ ranked }) => ranked);
|
|
12
|
+
return rows
|
|
13
|
+
.sort((a, b) => Number(b.exact === true) - Number(a.exact === true) ||
|
|
14
|
+
(ranking ? Number(b.ranked) - Number(a.ranked) || b.vote - a.vote : 0) ||
|
|
15
|
+
b.at - a.at)
|
|
16
|
+
.map(({ item }) => item);
|
|
17
|
+
};
|
|
@@ -2,6 +2,8 @@ import type { DateRange, Occur, Predicate, QueryNode, Span } from "@wirecat/cli-
|
|
|
2
2
|
import type { AccountKey } from "../../store/store.js";
|
|
3
3
|
import type { Stemmer } from "../stem.js";
|
|
4
4
|
export type ResolvedPredicate = Predicate & {
|
|
5
|
+
/** A prefix the search made of a word typed whole: past the expansions budget it reads as that word instead. */
|
|
6
|
+
widened?: true;
|
|
5
7
|
resolution?: {
|
|
6
8
|
chat?: {
|
|
7
9
|
account: AccountKey;
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
export declare const words: (text: string) => RegExpMatchArray | [];
|
|
2
|
+
/** `альфа-банк` also as `альфабанк`: people write one name both ways, and the index keeps each as typed. */
|
|
3
|
+
export declare const joinedHyphens: (text: string) => string[];
|
|
4
|
+
/** Words that carry no topic of their own: widening one to a prefix (`про*`) finds only noise. */
|
|
5
|
+
export declare const isFunctionWord: (word: string) => boolean;
|
|
2
6
|
/**
|
|
3
7
|
* A question's content words — «что решили по цене?» → решили, цене — or null when the text is not a question: it
|
|
4
8
|
* ends with «?» or starts with a question word.
|
|
@@ -3,12 +3,19 @@ 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
|
+
/** `альфа-банк` also as `альфабанк`: people write one name both ways, and the index keeps each as typed. */
|
|
7
|
+
export const joinedHyphens = (text) => (normalize(text).match(/[\p{L}\p{N}]+(?:-[\p{L}\p{N}]+)+/gu) ?? []).map((word) => word.replaceAll("-", ""));
|
|
6
8
|
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
9
|
const questionWord = /\b(?:what|which|how|who|where|when|can|could|should)\b|(?:^|\s)(?:сколько|какой|какая|какие|какое|кто|кому|кем|где|когда|как|что|можно|может|могут|ли)(?:\s|$)/iu;
|
|
8
10
|
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 " +
|
|
9
11
|
"что кто кого кому кем где когда как какой какая какое какие какую каким какого каких почему зачем откуда " +
|
|
10
12
|
"куда сколько ли можно разве чей чья чьё чьи"));
|
|
11
13
|
const QUESTION_FILLER = new Set(words("about any did does why whom whose would will это мы вы я они он она о об про ли"));
|
|
14
|
+
const LINKING = new Set(words("and or but not nor with without this that these those there their they them you your our its his her all any " +
|
|
15
|
+
"and for into onto over then than also just and при для без над под или либо его её их все всё уже ещё так " +
|
|
16
|
+
"тоже также был была были было будет это эта этот эти там тут"));
|
|
17
|
+
/** Words that carry no topic of their own: widening one to a prefix (`про*`) finds only noise. */
|
|
18
|
+
export const isFunctionWord = (word) => scaffolding.has(word) || QUESTION_STARTS.has(word) || QUESTION_FILLER.has(word) || LINKING.has(word);
|
|
12
19
|
/**
|
|
13
20
|
* A question's content words — «что решили по цене?» → решили, цене — or null when the text is not a question: it
|
|
14
21
|
* ends with «?» or starts with a question word.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type DateRange, type Occur, type Predicate, type Span } from "@wirecat/cli-base/query";
|
|
1
|
+
import { type DateRange, type Occur, type Predicate, type QueryAst, type Span } from "@wirecat/cli-base/query";
|
|
2
2
|
/**
|
|
3
3
|
* Where a read looks, the one vocabulary of messages, mail, calendar and meetings: the store (`archive`), the
|
|
4
4
|
* service's own search (`server`), or both, with what the service returns kept in the store.
|
|
@@ -61,3 +61,8 @@ export declare const windowOf: ({ lower, upper, lower_inclusive, upper_inclusive
|
|
|
61
61
|
from?: number;
|
|
62
62
|
to?: number;
|
|
63
63
|
};
|
|
64
|
+
/**
|
|
65
|
+
* Whether a query reads one of `times` in a zone — a date, `today`, a time without an offset — so the answer names
|
|
66
|
+
* that zone in `meta.timezone`. A time counted back from now or carrying its offset needs none.
|
|
67
|
+
*/
|
|
68
|
+
export declare const readsZone: (ast: QueryAst, times: ReadonlySet<string>) => boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { dateRange } from "@wirecat/cli-base/query";
|
|
1
|
+
import { dateRange, walkQuery, } from "@wirecat/cli-base/query";
|
|
2
2
|
/**
|
|
3
3
|
* Where a read looks, the one vocabulary of messages, mail, calendar and meetings: the store (`archive`), the
|
|
4
4
|
* service's own search (`server`), or both, with what the service returns kept in the store.
|
|
@@ -55,3 +55,11 @@ export const windowOf = ({ lower, upper, lower_inclusive, upper_inclusive, }) =>
|
|
|
55
55
|
...(lower === undefined ? {} : { from: lower_inclusive ? lower : lower + 1 }),
|
|
56
56
|
...(upper === undefined ? {} : { to: upper_inclusive ? upper : upper - 1 }),
|
|
57
57
|
});
|
|
58
|
+
const RELATIVE_TIME = /^\d+[mhd]$/i;
|
|
59
|
+
const OFFSET = /(?:Z|[+-]\d{2}:?\d{2})$/i;
|
|
60
|
+
/**
|
|
61
|
+
* Whether a query reads one of `times` in a zone — a date, `today`, a time without an offset — so the answer names
|
|
62
|
+
* that zone in `meta.timezone`. A time counted back from now or carrying its offset needs none.
|
|
63
|
+
*/
|
|
64
|
+
export const readsZone = (ast, times) => walkQuery(ast.root).some((term) => times.has(term.field) &&
|
|
65
|
+
[term.value, term.upper].some((value) => value !== undefined && value !== "*" && !RELATIVE_TIME.test(value) && !OFFSET.test(value)));
|
|
@@ -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
|
"меня еще нет о из ему теперь когда даже ну ли если уже или ни быть был него до вас нибудь опять уж вам ведь",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CliError } from "@wirecat/cli-base";
|
|
2
|
+
import { timezoneOf } from "@wirecat/cli-base/query";
|
|
2
3
|
import { mailTurn } from "../mail/owed.js";
|
|
3
4
|
import { MAIL_AGENDA_COLUMNS, queryFilter, } from "../store/store.js";
|
|
4
5
|
const absent = (error) => {
|
|
@@ -15,7 +16,7 @@ export const mailActivity = async (store, account, since, chats) => {
|
|
|
15
16
|
if (!stored)
|
|
16
17
|
return { chats: [], storedAt: null, coverage: () => [] };
|
|
17
18
|
const where = chats
|
|
18
|
-
? queryFilter(chats, MAIL_AGENDA_COLUMNS, { command: "tasks agenda" })
|
|
19
|
+
? queryFilter(chats, MAIL_AGENDA_COLUMNS, { command: "tasks agenda", zone: timezoneOf() })
|
|
19
20
|
: undefined;
|
|
20
21
|
const threads = await store.mail.threadActivity(stored.id, since, where);
|
|
21
22
|
const synced = await store.sync.syncState(account, "mail_coverage");
|
package/dist/services/agenda.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { queryError, queryFieldsOf, walkQuery, } from "@wirecat/cli-base/query";
|
|
1
|
+
import { queryError, queryFieldsOf, timezoneOf, walkQuery, } from "@wirecat/cli-base/query";
|
|
2
2
|
import { formatLocator, isLocator, parseLocator } from "../domain/locator.js";
|
|
3
3
|
import { formatReference } from "../domain/references.js";
|
|
4
4
|
import { agenda } from "../entities/agenda.js";
|
|
@@ -65,7 +65,7 @@ export const agendaService = (deps, now = Date.now) => ({
|
|
|
65
65
|
const open = await find();
|
|
66
66
|
const tags = await taskTagFilters(store, parts.tasks);
|
|
67
67
|
const listed = parts.tasks
|
|
68
|
-
? await find(queryFilter(parts.tasks, taskColumns(holder, at, tags), { command: "tasks agenda" }))
|
|
68
|
+
? await find(queryFilter(parts.tasks, taskColumns(holder, at, tags), { command: "tasks agenda", zone: timezoneOf() }))
|
|
69
69
|
: open;
|
|
70
70
|
const tasks = listed
|
|
71
71
|
.map((task) => ({ task, reasons: reasonsOf(task, at, dueWithin) }))
|
|
@@ -106,7 +106,9 @@ export const agendaService = (deps, now = Date.now) => ({
|
|
|
106
106
|
}));
|
|
107
107
|
const mail = account.provider === "email" ? await mailActivity(store, account, at - within, parts.chats) : undefined;
|
|
108
108
|
const activity = mail ??
|
|
109
|
-
(await store.chats.chatActivity(account, at - within, parts.chats
|
|
109
|
+
(await store.chats.chatActivity(account, at - within, parts.chats
|
|
110
|
+
? queryFilter(parts.chats, AGENDA_COLUMNS, { command: "tasks agenda", zone: timezoneOf() })
|
|
111
|
+
: undefined));
|
|
110
112
|
const turnOf = (chat) => "turn" in chat ? chat.turn : chat.lastFromOwner === null ? null : chat.lastFromOwner ? "waiting" : "owed";
|
|
111
113
|
const chats = activity.chats.map(({ lastMessageId, ...chat }) => ({
|
|
112
114
|
turn: turnOf({ lastMessageId, ...chat }),
|
|
@@ -2,7 +2,7 @@ import { createHash } from "node:crypto";
|
|
|
2
2
|
import { constants, mkdirSync } from "node:fs";
|
|
3
3
|
import { lstat, open, readFile, stat } from "node:fs/promises";
|
|
4
4
|
import { CliError } from "@wirecat/cli-base";
|
|
5
|
-
import { queryFieldsOf, walkQuery } from "@wirecat/cli-base/query";
|
|
5
|
+
import { queryFieldsOf, timezoneOf, walkQuery } from "@wirecat/cli-base/query";
|
|
6
6
|
import { directoryPaths } from "../attachments/directory.js";
|
|
7
7
|
import { documentExtractor, documentKind } from "../attachments/documents.js";
|
|
8
8
|
import { classify, engineMissing, extractText, importEngine, MAX_TEXT_CHARS, } from "../attachments/extract.js";
|
|
@@ -367,7 +367,9 @@ export const attachmentsService = (deps) => ({
|
|
|
367
367
|
for (const node of walkQuery(query.root))
|
|
368
368
|
if (node.field === "chat" && node.operator !== "wildcard" && !chats.has(node.value))
|
|
369
369
|
chats.set(node.value, await chatIdIn(deps.messenger, node.value, store, { includeLeft: true }));
|
|
370
|
-
const where = query
|
|
370
|
+
const where = query
|
|
371
|
+
? queryFilter(query, attachmentColumns(chats), { command: "attachments list", zone: timezoneOf() })
|
|
372
|
+
: undefined;
|
|
371
373
|
const views = await store.attachments.attachments({ ...(where ? { where } : {}), offset, limit: limit + 1 });
|
|
372
374
|
return { items: views.slice(0, limit).map((view) => itemOf(account, view)), hasMore: views.length > limit };
|
|
373
375
|
},
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type CallStats, type MeetingCallsInput } from "../meetings/index.js";
|
|
2
|
+
import type { MessageStore } from "../store/store.js";
|
|
3
|
+
export type CallStatsRequest = MeetingCallsInput & {
|
|
4
|
+
timeZone?: string;
|
|
5
|
+
callbackWithinMs?: number;
|
|
6
|
+
missedLimit?: number;
|
|
7
|
+
};
|
|
8
|
+
export type CallStatsAnswer = CallStats & {
|
|
9
|
+
accountId: number;
|
|
10
|
+
/** Selected meetings that are not calls: no direction or outcome a phone system writes, and no client. */
|
|
11
|
+
notCalls: number;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* The call numbers of one account over the selected meetings. A callback may come after `until` or from an employee
|
|
15
|
+
* the selection leaves out, so the account's calls up to `callbackWithinMs` after the selection are read too.
|
|
16
|
+
*/
|
|
17
|
+
export declare const readCallStats: (store: Pick<MessageStore, "meetings">, request: CallStatsRequest) => Promise<CallStatsAnswer>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { aggregateCallStats, CALLBACK_WITHIN_MS, callOf, } from "../meetings/index.js";
|
|
2
|
+
const callsOf = (stored) => stored.map(callOf).filter((one) => one !== null);
|
|
3
|
+
/**
|
|
4
|
+
* The call numbers of one account over the selected meetings. A callback may come after `until` or from an employee
|
|
5
|
+
* the selection leaves out, so the account's calls up to `callbackWithinMs` after the selection are read too.
|
|
6
|
+
*/
|
|
7
|
+
export const readCallStats = async (store, request) => {
|
|
8
|
+
const { timeZone, callbackWithinMs, missedLimit, ...selection } = request;
|
|
9
|
+
const within = callbackWithinMs ?? CALLBACK_WITHIN_MS;
|
|
10
|
+
const stored = await store.meetings.meetingCalls(selection);
|
|
11
|
+
const calls = callsOf(stored);
|
|
12
|
+
const narrowed = Object.keys(selection).some((key) => !["accountId", "since", "until", "maxRows", "signal"].includes(key));
|
|
13
|
+
const end = selection.until === undefined ? undefined : selection.until + within;
|
|
14
|
+
// Narrowed to a person, a colleague's callback is outside the selection; otherwise only the time after it is.
|
|
15
|
+
const window = narrowed
|
|
16
|
+
? {
|
|
17
|
+
...(selection.since === undefined ? {} : { since: selection.since }),
|
|
18
|
+
...(end === undefined ? {} : { until: end }),
|
|
19
|
+
}
|
|
20
|
+
: selection.until === undefined
|
|
21
|
+
? null
|
|
22
|
+
: { since: selection.until + 1, until: end };
|
|
23
|
+
const later = calls.length > 0 && window !== null && Number.isSafeInteger(within)
|
|
24
|
+
? callsOf(await store.meetings.meetingCalls({
|
|
25
|
+
accountId: selection.accountId,
|
|
26
|
+
...window,
|
|
27
|
+
...(selection.maxRows === undefined ? {} : { maxRows: selection.maxRows }),
|
|
28
|
+
...(selection.signal ? { signal: selection.signal } : {}),
|
|
29
|
+
}))
|
|
30
|
+
: [];
|
|
31
|
+
return {
|
|
32
|
+
...aggregateCallStats(calls, {
|
|
33
|
+
...(timeZone === undefined ? {} : { timeZone }),
|
|
34
|
+
callbackWithinMs: within,
|
|
35
|
+
...(missedLimit === undefined ? {} : { missedLimit }),
|
|
36
|
+
later,
|
|
37
|
+
}),
|
|
38
|
+
accountId: selection.accountId,
|
|
39
|
+
notCalls: stored.length - calls.length,
|
|
40
|
+
};
|
|
41
|
+
};
|
package/dist/services/chats.js
CHANGED
|
@@ -54,7 +54,7 @@ const deepChecks = async (deps, items, deep, pauseMs, registry) => {
|
|
|
54
54
|
export const chatsService = (deps) => ({
|
|
55
55
|
list: async (window, query) => {
|
|
56
56
|
if (fromStore(deps)) {
|
|
57
|
-
const where = query ? queryFilter(query, CHAT_COLUMNS, { command: "chats list" }) : undefined;
|
|
57
|
+
const where = query ? queryFilter(query, CHAT_COLUMNS, { command: "chats list", zone: timezoneOf() }) : undefined;
|
|
58
58
|
return (await accountStore(deps)).chats.chats({ ...window, ...(where ? { where } : {}) });
|
|
59
59
|
}
|
|
60
60
|
const [term] = query ? walkQuery(query.root) : [];
|
|
@@ -211,7 +211,9 @@ export const chatsService = (deps) => ({
|
|
|
211
211
|
return { chatId, read: members.length, participants, complete, more, ...change, tracked };
|
|
212
212
|
},
|
|
213
213
|
tracked: async (query) => {
|
|
214
|
-
const where = query
|
|
214
|
+
const where = query
|
|
215
|
+
? queryFilter(query, TRACKED_CHAT_COLUMNS, { command: "chats tracking list", zone: timezoneOf() })
|
|
216
|
+
: undefined;
|
|
215
217
|
return (await accountStore(deps)).roster.trackedChats(where ? { where } : {});
|
|
216
218
|
},
|
|
217
219
|
memberHistory: async (chat, { since }) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CliError } from "@wirecat/cli-base";
|
|
2
|
-
import { queryFieldsOf } from "@wirecat/cli-base/query";
|
|
2
|
+
import { queryFieldsOf, timezoneOf } from "@wirecat/cli-base/query";
|
|
3
3
|
import { cutChunks } from "../conversations/chunks.js";
|
|
4
4
|
import { linkMessages, RULES_VERSION } from "../conversations/link.js";
|
|
5
5
|
import { formatLocator } from "../domain/locator.js";
|
|
@@ -92,7 +92,9 @@ export const conversationsService = (deps) => {
|
|
|
92
92
|
const { store, chatId } = await found(chat);
|
|
93
93
|
if (!(await store.conversations.conversationState(chatId))?.builtAt)
|
|
94
94
|
throw notBuilt(chatId);
|
|
95
|
-
const where = query
|
|
95
|
+
const where = query
|
|
96
|
+
? queryFilter(query, CONVERSATION_COLUMNS, { command: "conversations list", zone: timezoneOf() })
|
|
97
|
+
: undefined;
|
|
96
98
|
const page = await store.conversations.conversations(chatId, { limit, offset, ...(where ? { where } : {}) });
|
|
97
99
|
const account = await deps.account();
|
|
98
100
|
return { items: page.items.map((one) => conversationItem(account, one)), hasMore: page.hasMore };
|
package/dist/services/deps.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ export interface ServiceDeps {
|
|
|
32
32
|
*/
|
|
33
33
|
store: () => Promise<MessageStore>;
|
|
34
34
|
guard: SendGuard;
|
|
35
|
-
/** For the profile's own files — a group's moderation rules
|
|
35
|
+
/** For the profile's own files — a group's moderation rules, which refuse to guess one when unset. */
|
|
36
36
|
profile?: string;
|
|
37
37
|
env?: NodeJS.ProcessEnv;
|
|
38
38
|
/** A long-running process's open models, so a search does not load one each time. */
|
|
@@ -2,7 +2,7 @@ import type { Profiles } from "../search/account-list.js";
|
|
|
2
2
|
import type { Note, StoredAccount, StoredFile } from "../store/index.js";
|
|
3
3
|
/**
|
|
4
4
|
* Where a hit came from. The document's preferred file says it: its account's provider and its link.
|
|
5
|
-
* A
|
|
5
|
+
* A documents provider's document under a notes folder is still known by its front matter's `source`.
|
|
6
6
|
* The hit's time is the store search's: the one `date:` reads.
|
|
7
7
|
*/
|
|
8
8
|
export declare const documentSource: (note: Note, accounts: readonly StoredAccount[], profiles: Profiles, file?: StoredFile) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { isFolderProvider, isImportedProvider
|
|
1
|
+
import { isDocumentAccountProvider, isFolderProvider, isImportedProvider } from "../domain/providers.js";
|
|
2
2
|
/**
|
|
3
3
|
* Where a hit came from. The document's preferred file says it: its account's provider and its link.
|
|
4
|
-
* A
|
|
4
|
+
* A documents provider's document under a notes folder is still known by its front matter's `source`.
|
|
5
5
|
* The hit's time is the store search's: the one `date:` reads.
|
|
6
6
|
*/
|
|
7
7
|
export const documentSource = (note, accounts, profiles, file) => {
|
|
@@ -16,7 +16,8 @@ export const documentSource = (note, accounts, profiles, file) => {
|
|
|
16
16
|
...(file?.url ? { url: file.url } : {}),
|
|
17
17
|
};
|
|
18
18
|
const remote = note.source === "file" &&
|
|
19
|
-
((account !== undefined &&
|
|
19
|
+
((account !== undefined && isDocumentAccountProvider(account.provider)) ||
|
|
20
|
+
isDocumentAccountProvider(metadata?.source));
|
|
20
21
|
const profile = remote && account
|
|
21
22
|
? Object.entries(profiles)
|
|
22
23
|
.flatMap(([command, named]) => Object.entries(named).map(([name, key]) => ({ command, name, key })))
|