@wirecat/cli-core 0.687.0 → 0.689.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 +96 -0
- package/dist/background/daily-archive-timer.d.ts +1 -1
- package/dist/cli/documents/index.d.ts +1 -0
- package/dist/cli/documents/index.js +1 -0
- package/dist/cli/documents/library.d.ts +107 -0
- package/dist/cli/documents/library.js +514 -0
- package/dist/cli/documents/testing/source-contract.d.ts +11 -6
- package/dist/cli/documents/testing/source-contract.js +54 -23
- package/dist/cli/documents/testing/source.d.ts +11 -3
- package/dist/cli/documents/testing/source.js +15 -10
- package/dist/cli/documents/words.d.ts +1 -1
- package/dist/cli/envelope.js +2 -3
- package/dist/cli/meeting-batch.js +5 -1
- package/dist/cli/meeting-passage-text.d.ts +1 -1
- package/dist/cli/meeting-passage-text.js +3 -5
- package/dist/cli/messenger/conversations-command.js +4 -0
- package/dist/cli/messenger/messages-search-command.js +6 -1
- package/dist/cli/messenger/search-answers.js +2 -0
- package/dist/cli/search-left-out.d.ts +3 -0
- package/dist/cli/search-left-out.js +12 -0
- package/dist/cli/store-settings.js +23 -4
- package/dist/cli/untrusted-marks.d.ts +2 -0
- package/dist/cli/untrusted-marks.js +6 -0
- package/dist/crm/cli/files.d.ts +68 -0
- package/dist/crm/cli/files.js +616 -0
- package/dist/crm/cli/index.d.ts +1 -0
- package/dist/crm/cli/index.js +3 -0
- package/dist/crm/cli/search-all.js +3 -2
- package/dist/crm/file-fetch.d.ts +15 -0
- package/dist/crm/file-fetch.js +61 -0
- package/dist/crm/index.d.ts +1 -0
- package/dist/crm/index.js +1 -0
- package/dist/crm/testing/files-contract.d.ts +17 -0
- package/dist/crm/testing/files-contract.js +142 -0
- package/dist/crm/testing/index.d.ts +1 -0
- package/dist/crm/testing/index.js +1 -0
- package/dist/crm/testing/source.d.ts +5 -0
- package/dist/crm/testing/source.js +3 -1
- package/dist/documents/index.d.ts +3 -1
- package/dist/documents/index.js +2 -0
- package/dist/documents/model.d.ts +20 -6
- package/dist/documents/model.js +2 -1
- package/dist/entities/hit.d.ts +3 -3
- package/dist/entities/hit.js +14 -3
- package/dist/entities/index.d.ts +1 -1
- package/dist/errors/reasons.d.ts +1 -1
- package/dist/errors/reasons.js +23 -1
- package/dist/files/safe-name.d.ts +2 -1
- package/dist/files/safe-name.js +21 -3
- package/dist/meetings/mcp/passage.d.ts +6 -2
- package/dist/meetings/mcp/passage.js +7 -3
- package/dist/resolve.d.ts +1 -1
- package/dist/resolve.js +1 -1
- package/dist/search/account-list.d.ts +2 -0
- package/dist/search/account-list.js +32 -4
- package/dist/search/respell.d.ts +10 -0
- package/dist/search/respell.js +63 -0
- package/dist/search/stem.d.ts +16 -3
- package/dist/search/stem.js +32 -4
- package/dist/services/documents/file-text.d.ts +13 -0
- package/dist/services/documents/file-text.js +33 -0
- package/dist/services/documents/plan.d.ts +3 -2
- package/dist/services/documents/plan.js +50 -16
- package/dist/services/documents/ports.d.ts +2 -2
- package/dist/services/documents/sync.js +2 -2
- package/dist/services/embeddings-search.js +169 -141
- package/dist/services/embeddings.d.ts +8 -0
- package/dist/services/message-resolution.d.ts +1 -1
- package/dist/services/message-resolution.js +1 -1
- package/dist/services/messages-archive-search.js +55 -3
- package/dist/services/messages-search.d.ts +2 -1
- package/dist/services/messages-search.js +19 -7
- package/dist/services/messages.d.ts +8 -0
- package/dist/services/metadata.d.ts +1 -1
- package/dist/services/named-chat.d.ts +20 -0
- package/dist/services/named-chat.js +63 -0
- package/dist/services/search-all.d.ts +7 -2
- package/dist/services/search-all.js +35 -1
- package/dist/store/exports.d.ts +1 -1
- package/dist/store/exports.js +1 -1
- package/dist/store/search-index.d.ts +2 -0
- package/dist/store/search-index.js +1 -0
- package/dist/store/sqlite/crm-files.d.ts +3 -0
- package/dist/store/sqlite/crm-files.js +2 -0
- package/dist/store/sqlite/crm-settings.d.ts +42 -1
- package/dist/store/sqlite/crm-settings.js +46 -2
- package/dist/store/sqlite/lucene-fields.d.ts +2 -0
- package/dist/store/sqlite/lucene-fields.js +6 -2
- package/dist/store/sqlite/lucene.js +2 -2
- package/dist/store/sqlite/manifest.js +2 -0
- package/dist/store/sqlite/migrations.generated.js +20 -0
- package/dist/store/sqlite/schema.d.ts +169 -0
- package/dist/store/sqlite/schema.js +18 -0
- package/dist/store/sqlite/stems.d.ts +2 -0
- package/dist/store/sqlite/stems.js +5 -0
- package/dist/store/sqlite/vectors.d.ts +26 -1
- package/dist/store/sqlite/vectors.js +72 -15
- package/dist/store/vectors.js +6 -2
- package/package.json +2 -2
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type FetchLike } from "@wirecat/cli-base/http";
|
|
2
|
+
export interface CrmFileFetchOptions {
|
|
3
|
+
/** The account's own hosts, such as the Bitrix24 portal or amoCRM's `drive_url` host: the only ones asked. */
|
|
4
|
+
hosts: readonly string[];
|
|
5
|
+
/** Sent only to those hosts, such as a Bearer token. */
|
|
6
|
+
headers?: Record<string, string>;
|
|
7
|
+
signal?: AbortSignal;
|
|
8
|
+
fetch?: FetchLike;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* A file's bytes behind a CRM link, for an adapter's `CrmOpenableFile.open`. https only, the account's own hosts only,
|
|
12
|
+
* redirects followed only on them, so the credentials go nowhere else. An HTML page is a CRM's answer to a link that is
|
|
13
|
+
* not a server link: refused. No error carries the link, which holds a token.
|
|
14
|
+
*/
|
|
15
|
+
export declare const fetchCrmFile: (link: string, options: CrmFileFetchOptions) => Promise<ReadableStream<Uint8Array>>;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { CliError } from "@wirecat/cli-base";
|
|
2
|
+
import { hostFetch } from "@wirecat/cli-base/http";
|
|
3
|
+
/** A large file on a slow line; the command's own deadline and `--timeout` stop it sooner. */
|
|
4
|
+
const EXCHANGE_MS = 60 * 60 * 1000;
|
|
5
|
+
const MOST_REDIRECTS = 5;
|
|
6
|
+
/**
|
|
7
|
+
* A file's bytes behind a CRM link, for an adapter's `CrmOpenableFile.open`. https only, the account's own hosts only,
|
|
8
|
+
* redirects followed only on them, so the credentials go nowhere else. An HTML page is a CRM's answer to a link that is
|
|
9
|
+
* not a server link: refused. No error carries the link, which holds a token.
|
|
10
|
+
*/
|
|
11
|
+
export const fetchCrmFile = async (link, options) => {
|
|
12
|
+
const send = options.fetch ?? hostFetch({ hosts: options.hosts, timeoutMs: EXCHANGE_MS });
|
|
13
|
+
const refused = (why) => new CliError("provider_error", `the CRM's file link was refused: ${why}`, { reason: "crm.file-unavailable" });
|
|
14
|
+
let at = link;
|
|
15
|
+
for (let hop = 0; hop <= MOST_REDIRECTS; hop += 1) {
|
|
16
|
+
let url;
|
|
17
|
+
try {
|
|
18
|
+
url = new URL(at);
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
throw refused("it is not a link");
|
|
22
|
+
}
|
|
23
|
+
if (url.protocol !== "https:")
|
|
24
|
+
throw refused("it is not https");
|
|
25
|
+
if (!options.hosts.includes(url.hostname.toLowerCase()))
|
|
26
|
+
throw refused("it points to another host than the account's");
|
|
27
|
+
let answer;
|
|
28
|
+
try {
|
|
29
|
+
answer = await send(url, {
|
|
30
|
+
redirect: "manual",
|
|
31
|
+
...(options.headers ? { headers: options.headers } : {}),
|
|
32
|
+
...(options.signal ? { signal: options.signal } : {}),
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
if (options.signal?.aborted)
|
|
37
|
+
throw new CliError("cancelled", "the file download was stopped");
|
|
38
|
+
throw new CliError("network_error", "the CRM's file server could not be reached", {
|
|
39
|
+
reason: "crm.file-unavailable",
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
const next = answer.headers.get("location");
|
|
43
|
+
if (answer.status >= 300 && answer.status < 400 && next) {
|
|
44
|
+
await answer.body?.cancel().catch(() => { });
|
|
45
|
+
at = new URL(next, url).href;
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
if (!answer.ok || !answer.body) {
|
|
49
|
+
await answer.body?.cancel().catch(() => { });
|
|
50
|
+
throw new CliError("provider_error", `the CRM's file server answered ${answer.status}`, {
|
|
51
|
+
reason: "crm.file-unavailable",
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
if ((answer.headers.get("content-type") ?? "").toLowerCase().startsWith("text/html")) {
|
|
55
|
+
await answer.body.cancel().catch(() => { });
|
|
56
|
+
throw refused("the CRM answered a web page, not the file");
|
|
57
|
+
}
|
|
58
|
+
return answer.body;
|
|
59
|
+
}
|
|
60
|
+
throw refused("too many redirects");
|
|
61
|
+
};
|
package/dist/crm/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { type CrmFileFetchOptions, fetchCrmFile } from "./file-fetch.js";
|
|
1
2
|
export { crmFileId, LINK_REMOVED, parseCrmFileId, withoutFileLinks } from "./files.js";
|
|
2
3
|
export { DAILY_FOREIGN_CONTACTS, type ForeignContacts, foreignContacts, foreignContactsPathFor, refuseForeignClientReads, } from "./foreign-contacts.js";
|
|
3
4
|
export { type ProviderCallOptions, providerCall } from "./provider-call.js";
|
package/dist/crm/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { fetchCrmFile } from "./file-fetch.js";
|
|
1
2
|
export { crmFileId, LINK_REMOVED, parseCrmFileId, withoutFileLinks } from "./files.js";
|
|
2
3
|
export { DAILY_FOREIGN_CONTACTS, foreignContacts, foreignContactsPathFor, refuseForeignClientReads, } from "./foreign-contacts.js";
|
|
3
4
|
export { providerCall } from "./provider-call.js";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ContractCase } from "../../meetings/index.js";
|
|
2
|
+
import { type CrmFileOwner, type CrmSource } from "../source.js";
|
|
3
|
+
/** One adapter with `files`, over recorded or faked responses, fresh for each case. */
|
|
4
|
+
export interface CrmFilesFixture {
|
|
5
|
+
source: CrmSource;
|
|
6
|
+
/** A record of the sign-in's own with at least one file whose text holds `word`. */
|
|
7
|
+
own: CrmFileOwner;
|
|
8
|
+
word: string;
|
|
9
|
+
/** A colleague's record with a file; needed when the source has `isAdmin`. */
|
|
10
|
+
foreign?: CrmFileOwner;
|
|
11
|
+
/** What every file link the fixture serves carries, such as its token: it must reach no answer, file or error. */
|
|
12
|
+
token: string;
|
|
13
|
+
/** Ids of files whose download the adapter must refuse: a link to another host, a web page instead of the file. */
|
|
14
|
+
refused?: readonly string[];
|
|
15
|
+
}
|
|
16
|
+
/** What every CRM adapter's `files` answers, whatever the CRM: run each case in the adapter's tests. */
|
|
17
|
+
export declare const crmFilesContract: (make: () => CrmFilesFixture | Promise<CrmFilesFixture>) => ContractCase[];
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { existsSync, mkdtempSync, readdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { isCliError } from "@wirecat/cli-base";
|
|
6
|
+
import { openStore } from "../../store/store.js";
|
|
7
|
+
import { downloadCrmFile } from "../cli/files.js";
|
|
8
|
+
import { parseCrmFileId } from "../files.js";
|
|
9
|
+
import { DAILY_FOREIGN_CONTACTS, foreignContacts } from "../foreign-contacts.js";
|
|
10
|
+
import { CRM_FILE_SOURCES } from "../source.js";
|
|
11
|
+
const APP = {
|
|
12
|
+
command: "crm",
|
|
13
|
+
appName: "crm-files-contract",
|
|
14
|
+
envPrefix: "CRMFILES",
|
|
15
|
+
description: "contract",
|
|
16
|
+
version: "0.0.0",
|
|
17
|
+
};
|
|
18
|
+
const ACCOUNT = { provider: "contract-crm", account: "portal" };
|
|
19
|
+
const without = (token, what, value) => assert.ok(!JSON.stringify(value ?? null).includes(token) && !String(value?.message ?? "").includes(token), `${what} holds the file link's token`);
|
|
20
|
+
const filesOf = (root) => existsSync(root)
|
|
21
|
+
? readdirSync(root, { recursive: true, withFileTypes: true })
|
|
22
|
+
.filter((entry) => entry.isFile())
|
|
23
|
+
.map((entry) => join(entry.parentPath, entry.name))
|
|
24
|
+
: [];
|
|
25
|
+
/** A store and a state folder of their own, and a run over the fixture's source. */
|
|
26
|
+
const runOver = async (source) => {
|
|
27
|
+
const home = mkdtempSync(join(tmpdir(), "crm-files-contract-"));
|
|
28
|
+
const path = join(home, "store.db");
|
|
29
|
+
const store = await openStore({ path });
|
|
30
|
+
const user = source.self ? String(await source.self()) : null;
|
|
31
|
+
const run = {
|
|
32
|
+
profile: "contract",
|
|
33
|
+
user,
|
|
34
|
+
account: ACCOUNT,
|
|
35
|
+
store,
|
|
36
|
+
source: () => source,
|
|
37
|
+
env: { HOME: home, XDG_STATE_HOME: home, CRMFILES_STATE_DIR: join(home, "state") },
|
|
38
|
+
};
|
|
39
|
+
return { run, store, path, state: join(home, "state"), context: { app: APP, run, now: () => Date.now() } };
|
|
40
|
+
};
|
|
41
|
+
/** What every CRM adapter's `files` answers, whatever the CRM: run each case in the adapter's tests. */
|
|
42
|
+
export const crmFilesContract = (make) => [
|
|
43
|
+
{
|
|
44
|
+
name: "files: one record's files, each with an id naming that record, a known source and no link anywhere",
|
|
45
|
+
async run() {
|
|
46
|
+
const { source, own, token } = await make();
|
|
47
|
+
assert.ok(source.files, "the source has files");
|
|
48
|
+
const found = await source.files(own);
|
|
49
|
+
assert.ok(found && found.files.length > 0, "the own record lists a file");
|
|
50
|
+
for (const file of found.files) {
|
|
51
|
+
const { owner, source: kind } = parseCrmFileId(file.id);
|
|
52
|
+
assert.deepEqual(owner, own, `${file.id} names its record`);
|
|
53
|
+
assert.equal(kind, file.source);
|
|
54
|
+
assert.ok(CRM_FILE_SOURCES.includes(file.source));
|
|
55
|
+
assert.ok(file.name.length > 0, "a file has a name");
|
|
56
|
+
assert.ok(file.size === null || file.size >= 0);
|
|
57
|
+
const { open: _open, ...listed } = file;
|
|
58
|
+
without(token, `the listed ${file.id}`, { id: listed.id, name: listed.name, owner: listed.owner });
|
|
59
|
+
}
|
|
60
|
+
assert.equal(await source.files({ kind: own.kind, id: "999999999" }), null, "a record the CRM lacks is null");
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: "files: a download is saved 600 in 700 folders, its text stored and found, and its token kept nowhere",
|
|
65
|
+
async run() {
|
|
66
|
+
const { source, own, word, token, refused = [] } = await make();
|
|
67
|
+
const { run, store, path, state, context } = await runOver(source);
|
|
68
|
+
try {
|
|
69
|
+
const found = await source.files?.(own);
|
|
70
|
+
assert.ok(found);
|
|
71
|
+
const rows = [];
|
|
72
|
+
for (const file of found.files.filter((one) => !refused.includes(one.id)))
|
|
73
|
+
rows.push(await downloadCrmFile(context, file, found.assignee, {
|
|
74
|
+
capBytes: 100 * 1024 * 1024,
|
|
75
|
+
capMb: 100,
|
|
76
|
+
flag: false,
|
|
77
|
+
limits: await store.crmFiles.limits(ACCOUNT),
|
|
78
|
+
}));
|
|
79
|
+
assert.ok(rows.some((one) => one.row.text?.toLowerCase().includes(word.toLowerCase())), `a file's text holds ${word}`);
|
|
80
|
+
for (const saved of filesOf(state)) {
|
|
81
|
+
assert.equal(statSync(saved).mode & 0o777, 0o600, `${saved} is the OS user's alone`);
|
|
82
|
+
without(token, saved, readFileSync(saved, "latin1"));
|
|
83
|
+
}
|
|
84
|
+
assert.equal(statSync(join(state, "crm", "files")).mode & 0o777, 0o700);
|
|
85
|
+
const hits = await store.crmFiles.find({ words: [word] });
|
|
86
|
+
assert.ok(hits.items.length > 0, "search finds the text");
|
|
87
|
+
if (found.assignee !== null && run.user !== null) {
|
|
88
|
+
const other = { account: ACCOUNT, assignee: `${ACCOUNT.account}/user/0` };
|
|
89
|
+
assert.equal((await store.crmFiles.find({ words: [word], viewers: [other] })).items.length, 0);
|
|
90
|
+
}
|
|
91
|
+
await store.close();
|
|
92
|
+
assert.ok(!readFileSync(path, "latin1").includes(token), "the store file holds the token");
|
|
93
|
+
}
|
|
94
|
+
finally {
|
|
95
|
+
await store.close().catch(() => { });
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
name: "files: a refused link (another host, a web page) fails without its token and leaves no part",
|
|
101
|
+
async run() {
|
|
102
|
+
const { source, token, refused = [] } = await make();
|
|
103
|
+
if (!refused.length)
|
|
104
|
+
return;
|
|
105
|
+
const { store, state, context } = await runOver(source);
|
|
106
|
+
try {
|
|
107
|
+
for (const id of refused) {
|
|
108
|
+
const { owner } = parseCrmFileId(id);
|
|
109
|
+
const found = await source.files?.(owner);
|
|
110
|
+
const file = found?.files.find((one) => one.id === id);
|
|
111
|
+
assert.ok(file, `${id} is listed for ${owner.kind} ${owner.id}`);
|
|
112
|
+
const error = await downloadCrmFile(context, file, found?.assignee ?? null, {
|
|
113
|
+
capBytes: 1024 * 1024,
|
|
114
|
+
capMb: 1,
|
|
115
|
+
flag: false,
|
|
116
|
+
limits: await store.crmFiles.limits(ACCOUNT),
|
|
117
|
+
}).then(() => undefined, (caught) => caught);
|
|
118
|
+
assert.ok(isCliError(error), `${id} is refused`);
|
|
119
|
+
without(token, `the refusal of ${id}`, error);
|
|
120
|
+
}
|
|
121
|
+
assert.deepEqual(filesOf(state), [], "a refused download keeps no file");
|
|
122
|
+
}
|
|
123
|
+
finally {
|
|
124
|
+
await store.close();
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
name: "files: a colleague's record costs one of the day's slots, and the 101st is refused",
|
|
130
|
+
async run() {
|
|
131
|
+
const { source, foreign } = await make();
|
|
132
|
+
if (!source.isAdmin || !foreign || (await source.isAdmin()))
|
|
133
|
+
return;
|
|
134
|
+
const found = await source.files?.(foreign);
|
|
135
|
+
assert.ok(found, "the colleague's record lists its files");
|
|
136
|
+
const file = join(mkdtempSync(join(tmpdir(), "crm-files-quota-")), "count.json");
|
|
137
|
+
const day = new Date().toISOString().slice(0, 10);
|
|
138
|
+
writeFileSync(file, JSON.stringify({ day, seen: Array.from({ length: DAILY_FOREIGN_CONTACTS }, (_, at) => `x:${at}`) }));
|
|
139
|
+
await assert.rejects(foreignContacts(source, () => file).spend(foreign.kind, { externalId: foreign.id, assignee: found.assignee }), (error) => isCliError(error) && error.details.reason === "crm.foreign-contacts-spent");
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { ACME_CALENDAR, ACME_MAIL, ACME_NOW, ACME_OPENED, ACME_PORTAL, ACME_TELEGRAM, type AcmeScenario, acmeScenario, } from "./acme-scenario.js";
|
|
2
|
+
export { type CrmFilesFixture, crmFilesContract } from "./files-contract.js";
|
|
2
3
|
export { exampleDeal, exampleLead, exampleOrganization, examplePerson, FAKE_CRM_ALIASES, FAKE_FILE_TOKEN, type FakeCrmFile, type FakeCrmSource, type FakeCrmSourceOptions, type FakeCrmWrite, fakeCrmSource, LEAD_PIPELINE, SALES_PIPELINE, SOURCE_FIELD, } from "./source.js";
|
|
3
4
|
export { type CrmSourceFaults, type CrmSourceFixture, crmSourceContract } from "./source-contract.js";
|
|
4
5
|
export { CRM_TRAIT_COMBINATIONS, type CrmSyncFixture, crmSyncContract } from "./sync-contract.js";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { ACME_CALENDAR, ACME_MAIL, ACME_NOW, ACME_OPENED, ACME_PORTAL, ACME_TELEGRAM, acmeScenario, } from "./acme-scenario.js";
|
|
2
|
+
export { crmFilesContract } from "./files-contract.js";
|
|
2
3
|
export { exampleDeal, exampleLead, exampleOrganization, examplePerson, FAKE_CRM_ALIASES, FAKE_FILE_TOKEN, fakeCrmSource, LEAD_PIPELINE, SALES_PIPELINE, SOURCE_FIELD, } from "./source.js";
|
|
3
4
|
export { crmSourceContract } from "./source-contract.js";
|
|
4
5
|
export { CRM_TRAIT_COMBINATIONS, crmSyncContract } from "./sync-contract.js";
|
|
@@ -23,6 +23,11 @@ export interface FakeCrmSourceOptions {
|
|
|
23
23
|
* `FAKE_FILE_TOKEN`, as a careless adapter's might, so a test sees whether the token gets out.
|
|
24
24
|
*/
|
|
25
25
|
files?: FakeCrmFile[];
|
|
26
|
+
/** Kinds of file the sign-in may not read: each `files()` reports them as a gap naming the scope. */
|
|
27
|
+
fileGaps?: {
|
|
28
|
+
scope: string;
|
|
29
|
+
message: string;
|
|
30
|
+
}[];
|
|
26
31
|
}
|
|
27
32
|
/** The token in every fake file link: it must reach no output, store, file or error. */
|
|
28
33
|
export declare const FAKE_FILE_TOKEN = "fake-file-token-5f2a9c";
|
|
@@ -272,8 +272,10 @@ export const fakeCrmSource = (options = {}) => {
|
|
|
272
272
|
...(options.files === undefined
|
|
273
273
|
? {}
|
|
274
274
|
: {
|
|
275
|
-
files: async (owner) => {
|
|
275
|
+
files: async (owner, context) => {
|
|
276
276
|
calls.files += 1;
|
|
277
|
+
for (const gap of options.fileGaps ?? [])
|
|
278
|
+
context?.gap({ kind: owner.kind, ...gap });
|
|
277
279
|
const record = of(owner.kind).get(owner.id);
|
|
278
280
|
if (!record || record.deleted)
|
|
279
281
|
return null;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { type BlockConflict, type BlockHunk, diffBlocks, type Merged, mergeBlocks, } from "../services/documents/block-diff.js";
|
|
2
2
|
export { type Complete, extractMemories } from "../services/documents/extraction.js";
|
|
3
|
+
export { fileText, readableFile } from "../services/documents/file-text.js";
|
|
3
4
|
export { documentIngestion, type IngestionOptions } from "../services/documents/ingestion.js";
|
|
4
5
|
export { type DocumentKnowledge, documentKnowledge } from "../services/documents/knowledge.js";
|
|
5
6
|
export { blocksMarkdown, inlineMarkdown, spliceMarkdown } from "../services/documents/markdown-splice.js";
|
|
@@ -12,6 +13,7 @@ export { type SyncResult, syncDocuments } from "../services/documents/sync.js";
|
|
|
12
13
|
export { type Block, blockKey, blockShape, type Inline, type ListKind, normalizeInlines } from "./blocks.js";
|
|
13
14
|
export { catalogFiles } from "./catalog.js";
|
|
14
15
|
export { markdownBlocks, type PlacedBlock, placedMarkdownBlocks } from "./markdown-blocks.js";
|
|
15
|
-
export type { DocumentSource, IndexedSource, PictureWriter, SourceChange, SourceContent, SourceFile, SourceIndex, SourceSkip, SourceState, SourceStatePort, SourceWalk, SourceWork, TabText, } from "./model.js";
|
|
16
|
+
export type { DocumentSource, FeedlessDocumentSource, IndexedSource, PictureWriter, SourceChange, SourceContent, SourceFile, SourceIndex, SourceSkip, SourceState, SourceStatePort, SourceWalk, SourceWork, TabText, } from "./model.js";
|
|
17
|
+
export { feedOf } from "./model.js";
|
|
16
18
|
export type { ConflictPart, DocumentTarget, Keep, LocalDocument, Prepared, PushEntry, Pushed, PushPlan, PushState, PushStatePort, RemoteChange, } from "./push-model.js";
|
|
17
19
|
export { inScope, type SourceQuery, within } from "./scope.js";
|
package/dist/documents/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { diffBlocks, mergeBlocks, } from "../services/documents/block-diff.js";
|
|
2
2
|
export { extractMemories } from "../services/documents/extraction.js";
|
|
3
|
+
export { fileText, readableFile } from "../services/documents/file-text.js";
|
|
3
4
|
export { documentIngestion } from "../services/documents/ingestion.js";
|
|
4
5
|
export { documentKnowledge } from "../services/documents/knowledge.js";
|
|
5
6
|
export { blocksMarkdown, inlineMarkdown, spliceMarkdown } from "../services/documents/markdown-splice.js";
|
|
@@ -11,4 +12,5 @@ export { syncDocuments } from "../services/documents/sync.js";
|
|
|
11
12
|
export { blockKey, blockShape, normalizeInlines } from "./blocks.js";
|
|
12
13
|
export { catalogFiles } from "./catalog.js";
|
|
13
14
|
export { markdownBlocks, placedMarkdownBlocks } from "./markdown-blocks.js";
|
|
15
|
+
export { feedOf } from "./model.js";
|
|
14
16
|
export { inScope, within } from "./scope.js";
|
|
@@ -31,28 +31,42 @@ export interface SourceChange<M extends SourceFile = SourceFile> {
|
|
|
31
31
|
removed: boolean;
|
|
32
32
|
file?: M;
|
|
33
33
|
}
|
|
34
|
-
|
|
34
|
+
/**
|
|
35
|
+
* A provider without a change feed (Yandex Disk, WebDAV, S3): every sync walks the selected folders in full, saves only
|
|
36
|
+
* what changed since the last pass, and removes what the finished pass no longer found. A `DocumentSource` is one too.
|
|
37
|
+
*/
|
|
38
|
+
export interface FeedlessDocumentSource<M extends SourceFile = SourceFile> {
|
|
35
39
|
identity(): Promise<string>;
|
|
36
|
-
|
|
37
|
-
|
|
40
|
+
/**
|
|
41
|
+
* The file `known` is the one the sync last listed under this id, when it has one: a provider that addresses files
|
|
42
|
+
* by path, not by id (Yandex Disk, WebDAV), reads its path from there. The same holds for `children`,
|
|
43
|
+
* `childrenPage`, `content` and `bytes`.
|
|
44
|
+
*/
|
|
45
|
+
metadata(id: string, known?: M): Promise<M>;
|
|
46
|
+
children(id: string, folder?: M): Promise<M[]>;
|
|
38
47
|
/**
|
|
39
48
|
* One page of a folder's children, for a provider whose folder can be too big for one step of a sync (a Notion
|
|
40
49
|
* database of 12,000 rows). A sync with it lists one page per step and saves the cursor between calls. A cursor
|
|
41
50
|
* the provider no longer accepts must fail as `not_found` (through `errorOf`): the sync then lists the folder again
|
|
42
51
|
* from its first page, where any other error fails every later sync on that page until a `--rescan`.
|
|
43
52
|
*/
|
|
44
|
-
childrenPage?(id: string, cursor?: string): Promise<{
|
|
53
|
+
childrenPage?(id: string, cursor?: string, folder?: M): Promise<{
|
|
45
54
|
files: M[];
|
|
46
55
|
cursor?: string;
|
|
47
56
|
}>;
|
|
57
|
+
content(id: string, maxChars?: number, file?: M): Promise<SourceContent<M>>;
|
|
58
|
+
bytes(id: string, file?: M): Promise<Uint8Array>;
|
|
59
|
+
}
|
|
60
|
+
/** A provider with a change feed: after the first walk, a sync reads only what the feed names. */
|
|
61
|
+
export interface DocumentSource<M extends SourceFile = SourceFile> extends FeedlessDocumentSource<M> {
|
|
48
62
|
startToken(): Promise<string>;
|
|
49
63
|
changes(token: string): Promise<{
|
|
50
64
|
items: SourceChange<M>[];
|
|
51
65
|
cursor: string;
|
|
52
66
|
}>;
|
|
53
|
-
content(id: string, maxChars?: number): Promise<SourceContent<M>>;
|
|
54
|
-
bytes(id: string): Promise<Uint8Array>;
|
|
55
67
|
}
|
|
68
|
+
/** The feed of a source that has one. */
|
|
69
|
+
export declare const feedOf: <M extends SourceFile>(source: FeedlessDocumentSource<M>) => DocumentSource<M> | undefined;
|
|
56
70
|
export interface IndexedSource<M extends SourceFile = SourceFile> {
|
|
57
71
|
metadata: M;
|
|
58
72
|
hash: string;
|
package/dist/documents/model.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
/** The feed of a source that has one. */
|
|
2
|
+
export const feedOf = (source) => "changes" in source && typeof source.changes === "function" ? source : undefined;
|
package/dist/entities/hit.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
2
|
/**
|
|
3
|
-
* One result of `search all`: a message, a mail, a note, a calendar event, a meeting passage, a deal, a lead,
|
|
4
|
-
* invoice, payment, order, contract, subscription, product or wallet.
|
|
3
|
+
* One result of `search all`: a message, a mail, a note, a calendar event, a meeting passage, a deal, a lead, the text
|
|
4
|
+
* of a downloaded CRM file, or an invoice, payment, order, contract, subscription, product or wallet.
|
|
5
5
|
*/
|
|
6
6
|
export declare const hit: v.StrictObjectSchema<{
|
|
7
|
-
readonly kind: v.PicklistSchema<["message", "mail", "note", "document", "event", "meeting", "deal", "lead", "invoice", "payment", "order", "contract", "subscription", "product", "wallet"], undefined>;
|
|
7
|
+
readonly kind: v.PicklistSchema<["message", "mail", "note", "document", "event", "meeting", "deal", "lead", "crm_file", "invoice", "payment", "order", "contract", "subscription", "product", "wallet"], undefined>;
|
|
8
8
|
readonly ref: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
9
9
|
readonly provider: v.StringSchema<undefined>;
|
|
10
10
|
readonly url: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
package/dist/entities/hit.js
CHANGED
|
@@ -3,11 +3,22 @@ import { BUSINESS_KINDS } from "../domain/business.js";
|
|
|
3
3
|
import { hitFile } from "./attachment.js";
|
|
4
4
|
import { count, reference, text, time, untrusted } from "./fields.js";
|
|
5
5
|
/**
|
|
6
|
-
* One result of `search all`: a message, a mail, a note, a calendar event, a meeting passage, a deal, a lead,
|
|
7
|
-
* invoice, payment, order, contract, subscription, product or wallet.
|
|
6
|
+
* One result of `search all`: a message, a mail, a note, a calendar event, a meeting passage, a deal, a lead, the text
|
|
7
|
+
* of a downloaded CRM file, or an invoice, payment, order, contract, subscription, product or wallet.
|
|
8
8
|
*/
|
|
9
9
|
export const hit = v.strictObject({
|
|
10
|
-
kind: v.picklist([
|
|
10
|
+
kind: v.picklist([
|
|
11
|
+
"message",
|
|
12
|
+
"mail",
|
|
13
|
+
"note",
|
|
14
|
+
"document",
|
|
15
|
+
"event",
|
|
16
|
+
"meeting",
|
|
17
|
+
"deal",
|
|
18
|
+
"lead",
|
|
19
|
+
"crm_file",
|
|
20
|
+
...BUSINESS_KINDS,
|
|
21
|
+
]),
|
|
11
22
|
ref: reference,
|
|
12
23
|
provider: text,
|
|
13
24
|
url: v.optional(text),
|
package/dist/entities/index.d.ts
CHANGED
|
@@ -4371,7 +4371,7 @@ export declare const ENTITIES: {
|
|
|
4371
4371
|
readonly untrusted: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
4372
4372
|
}, undefined>;
|
|
4373
4373
|
readonly hit: v.StrictObjectSchema<{
|
|
4374
|
-
readonly kind: v.PicklistSchema<["message", "mail", "note", "document", "event", "meeting", "deal", "lead", "invoice", "payment", "order", "contract", "subscription", "product", "wallet"], undefined>;
|
|
4374
|
+
readonly kind: v.PicklistSchema<["message", "mail", "note", "document", "event", "meeting", "deal", "lead", "crm_file", "invoice", "payment", "order", "contract", "subscription", "product", "wallet"], undefined>;
|
|
4375
4375
|
readonly ref: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
4376
4376
|
readonly provider: v.StringSchema<undefined>;
|
|
4377
4377
|
readonly url: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
package/dist/errors/reasons.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export declare const REASONS: ErrorReason[];
|
|
|
7
7
|
* Detail keys an error from this package may carry, until each is registered on its own reason. Not `cause`:
|
|
8
8
|
* that can hold a provider's or SQLite's raw text.
|
|
9
9
|
*/
|
|
10
|
-
export declare const DETAILS: readonly ["contracts", "calendars", "allowed", "alternative", "arguments", "at", "available", "batch", "budget", "built", "candidates", "chat", "chat_id", "cli", "column", "complete", "emitted_bytes", "exact", "file", "forum", "guide", "hint", "id", "index", "kind", "limit", "limit_source", "line", "max_bytes", "model", "name", "operation_id", "operation_ids", "text_limit", "store_refused_in", "partial_output", "parent", "path", "permission", "person_ids", "previous_chat_id", "profiles", "provider_error", "provider", "recovery", "reference", "remembered", "retry_at", "retry_after_ms", "runtime", "saved", "scheduled_for", "script", "sent", "sent_count", "settlement_failed", "span", "sqlite", "stage", "standing", "state", "stderr", "term", "total", "upgraded", "wanted"];
|
|
10
|
+
export declare const DETAILS: readonly ["holders", "profile", "contracts", "calendars", "allowed", "alternative", "arguments", "at", "available", "batch", "budget", "built", "candidates", "chat", "chat_id", "cli", "column", "complete", "emitted_bytes", "exact", "file", "forum", "guide", "hint", "id", "index", "kind", "limit", "limit_source", "line", "max_bytes", "model", "name", "operation_id", "operation_ids", "text_limit", "store_refused_in", "partial_output", "parent", "path", "permission", "person_ids", "previous_chat_id", "profiles", "provider_error", "provider", "recovery", "reference", "remembered", "retry_at", "retry_after_ms", "runtime", "saved", "scheduled_for", "script", "sent", "sent_count", "settlement_failed", "span", "sqlite", "stage", "standing", "state", "stderr", "term", "total", "upgraded", "wanted"];
|
|
11
11
|
/** What a CLI adds to the shared registry: its own reasons, and the detail keys its adapters raise. */
|
|
12
12
|
export interface AppErrors {
|
|
13
13
|
reasons?: readonly ErrorReason[];
|
package/dist/errors/reasons.js
CHANGED
|
@@ -187,6 +187,15 @@ const OTHERS = [
|
|
|
187
187
|
validation("document.changed", "the document changed while it was read; nothing was saved"),
|
|
188
188
|
["document.not-imported", "not_found", "the document is not imported in this source account"],
|
|
189
189
|
["document.not-found", "not_found", "no listed document has that reference"],
|
|
190
|
+
["state.unreadable", "configuration_error", "a sync state file cannot be read; move it away and sync again"],
|
|
191
|
+
["profile.busy", "provider_unavailable", "another sync or write holds this profile's local copy"],
|
|
192
|
+
["profile.account-taken", "conflict", "another profile here already uses this provider account"],
|
|
193
|
+
["profile.other-account", "conflict", "this profile's copy was synced from another provider account"],
|
|
194
|
+
["profile.not-synced", "not_found", "the profile has no local copy yet; sync it first"],
|
|
195
|
+
["provider.failed", "provider_error", "a read from the provider failed"],
|
|
196
|
+
["identity.none", "not_found", "the provider shows no accounts on a document"],
|
|
197
|
+
validation("folder.not-a-folder", "what was named is not a folder the account can read"),
|
|
198
|
+
["folder.not-chosen", "not_found", "the folder is not among the chosen folders"],
|
|
190
199
|
["meeting.not-found", "not_found", "no meeting row has that event or meeting reference"],
|
|
191
200
|
["listing.too-large", "provider_error", "the listing is over its bound; the checkpoint was kept"],
|
|
192
201
|
["listing.source-not-found", "not_found", "a source: term names no account holding what is listed"],
|
|
@@ -453,8 +462,19 @@ const OTHERS = [
|
|
|
453
462
|
[
|
|
454
463
|
"crm.foreign-contacts-spent",
|
|
455
464
|
"permission_error",
|
|
456
|
-
"the day's
|
|
465
|
+
"the day's reads of records that are not yours (contacts, companies, other people's files) are spent",
|
|
457
466
|
],
|
|
467
|
+
validation("crm.files-limit-range", "a files setting takes a whole number within its range; it is never clamped"),
|
|
468
|
+
validation("crm.file-too-large", "the file is larger than the download may take; --max-size raises it up to 2048 MB"),
|
|
469
|
+
validation("crm.files-disk-full", "the account's files folder is at its files.max_total_mb even after dropping"),
|
|
470
|
+
["crm.file-unavailable", "provider_error", "the CRM did not give the file; its link is never shown"],
|
|
471
|
+
["crm.files-denied", "permission_error", "the profile's files.download level stops downloading files"],
|
|
472
|
+
[
|
|
473
|
+
"crm.file-exists",
|
|
474
|
+
"conflict",
|
|
475
|
+
"the --dir folder already holds a file of that name, which a download never overwrites",
|
|
476
|
+
],
|
|
477
|
+
["crm.scope-missing", "permission_error", "the CRM sign-in lacks a scope one kind of a record's files needs"],
|
|
458
478
|
[
|
|
459
479
|
"crm.client-reads-admin-only",
|
|
460
480
|
"permission_error",
|
|
@@ -687,6 +707,8 @@ export const REASONS = defineReasons([
|
|
|
687
707
|
* that can hold a provider's or SQLite's raw text.
|
|
688
708
|
*/
|
|
689
709
|
export const DETAILS = [
|
|
710
|
+
"holders",
|
|
711
|
+
"profile",
|
|
690
712
|
"contracts",
|
|
691
713
|
"calendars",
|
|
692
714
|
"allowed",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* A name another person chose cannot climb out of the folder, cannot be a dot file we would then
|
|
3
|
-
* hide,
|
|
3
|
+
* hide, carries no control or direction character to rewrite the terminal or disguise its extension, and is at most
|
|
4
|
+
* 200 bytes, its extension kept.
|
|
4
5
|
*/
|
|
5
6
|
export declare const safeName: (name: string | undefined, platform?: NodeJS.Platform) => string | undefined;
|
package/dist/files/safe-name.js
CHANGED
|
@@ -1,7 +1,25 @@
|
|
|
1
|
-
import { basename } from "node:path";
|
|
1
|
+
import { basename, extname } from "node:path";
|
|
2
|
+
/** Below the 255 bytes most file systems allow a name, leaving room for a prefix such as a provider id. */
|
|
3
|
+
const MOST_NAME_BYTES = 200;
|
|
4
|
+
const bytesOf = (text) => Buffer.byteLength(text, "utf8");
|
|
5
|
+
/** A name cut to `most` bytes at a whole character, its extension kept. */
|
|
6
|
+
const shortened = (name, most) => {
|
|
7
|
+
if (bytesOf(name) <= most)
|
|
8
|
+
return name;
|
|
9
|
+
const extension = extname(name);
|
|
10
|
+
const kept = bytesOf(extension) <= 32 ? extension : "";
|
|
11
|
+
let stem = "";
|
|
12
|
+
for (const character of name.slice(0, name.length - kept.length)) {
|
|
13
|
+
if (bytesOf(stem + character) + bytesOf(kept) > most)
|
|
14
|
+
break;
|
|
15
|
+
stem += character;
|
|
16
|
+
}
|
|
17
|
+
return stem + kept;
|
|
18
|
+
};
|
|
2
19
|
/**
|
|
3
20
|
* A name another person chose cannot climb out of the folder, cannot be a dot file we would then
|
|
4
|
-
* hide,
|
|
21
|
+
* hide, carries no control or direction character to rewrite the terminal or disguise its extension, and is at most
|
|
22
|
+
* 200 bytes, its extension kept.
|
|
5
23
|
*/
|
|
6
24
|
export const safeName = (name, platform = process.platform) => {
|
|
7
25
|
let plain = name === undefined
|
|
@@ -14,5 +32,5 @@ export const safeName = (name, platform = process.platform) => {
|
|
|
14
32
|
if (/^(con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\.|$)/i.test(plain))
|
|
15
33
|
return undefined;
|
|
16
34
|
}
|
|
17
|
-
return plain === "" ? undefined : plain;
|
|
35
|
+
return plain === "" ? undefined : shortened(plain, MOST_NAME_BYTES);
|
|
18
36
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type FailureContext } from "@wirecat/cli-base";
|
|
2
|
-
import { type MeetingPassageReader } from "../passage.js";
|
|
2
|
+
import { type MeetingPassageOutputFormat, type MeetingPassageReader, type MeetingPassageResult } from "../passage.js";
|
|
3
3
|
export declare const meetingPassageTool: {
|
|
4
4
|
name: string;
|
|
5
5
|
description: string;
|
|
@@ -50,7 +50,11 @@ export declare const meetingPassageTool: {
|
|
|
50
50
|
additionalProperties: boolean;
|
|
51
51
|
};
|
|
52
52
|
};
|
|
53
|
-
|
|
53
|
+
/**
|
|
54
|
+
* `forRun` is how the host prints the passage in this run: `passageForRun` from `@wirecat/cli-core/cli`, which marks
|
|
55
|
+
* the cues in a scheduled agent's run. This module cannot read the run's mark.
|
|
56
|
+
*/
|
|
57
|
+
export declare const callMeetingPassageTool: (read: MeetingPassageReader, input: unknown, signal?: AbortSignal, failure?: FailureContext, forRun?: (result: MeetingPassageResult, format: MeetingPassageOutputFormat) => MeetingPassageResult) => Promise<({
|
|
54
58
|
content: {
|
|
55
59
|
type: "text";
|
|
56
60
|
text: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CliError, errorObjectOf, isCliError, mcpErrorResult } from "@wirecat/cli-base";
|
|
2
|
-
import { markedPassage, validateMeetingPassage } from "../passage.js";
|
|
2
|
+
import { markedPassage, validateMeetingPassage, } from "../passage.js";
|
|
3
3
|
import { agentResult, UNTRUSTED_NEUTRAL } from "./agent-text.js";
|
|
4
4
|
const count = { type: "integer", minimum: 0, maximum: 999 };
|
|
5
5
|
export const meetingPassageTool = {
|
|
@@ -21,7 +21,11 @@ export const meetingPassageTool = {
|
|
|
21
21
|
additionalProperties: false,
|
|
22
22
|
},
|
|
23
23
|
};
|
|
24
|
-
|
|
24
|
+
/**
|
|
25
|
+
* `forRun` is how the host prints the passage in this run: `passageForRun` from `@wirecat/cli-core/cli`, which marks
|
|
26
|
+
* the cues in a scheduled agent's run. This module cannot read the run's mark.
|
|
27
|
+
*/
|
|
28
|
+
export const callMeetingPassageTool = async (read, input, signal, failure = {}, forRun = (result) => result) => {
|
|
25
29
|
try {
|
|
26
30
|
if (!input || typeof input !== "object" || Array.isArray(input))
|
|
27
31
|
throw new CliError("validation_error", "expected passage arguments");
|
|
@@ -40,7 +44,7 @@ export const callMeetingPassageTool = async (read, input, signal, failure = {})
|
|
|
40
44
|
const reference = args.reference;
|
|
41
45
|
validateMeetingPassage(reference, options);
|
|
42
46
|
signal?.throwIfAborted();
|
|
43
|
-
const result = markedPassage(await read(reference, options));
|
|
47
|
+
const result = forRun(markedPassage(await read(reference, options)), options.format);
|
|
44
48
|
signal?.throwIfAborted();
|
|
45
49
|
return agentResult({ content: [{ type: "text", text: result.content }], structuredContent: result.packet });
|
|
46
50
|
}
|
package/dist/resolve.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ export declare const pickChat: (reference: string, chats: Chat[]) => Chat;
|
|
|
27
27
|
* `lower()` folds ASCII only, and most of these names are Cyrillic.
|
|
28
28
|
*/
|
|
29
29
|
export declare const pickPerson: (reference: string, people: PeopleLookup) => Contact;
|
|
30
|
-
/** Everyone a name pattern such as
|
|
30
|
+
/** Everyone a name pattern such as `Станислав*` or `*Соколов*` fits by their alias, name or @username. */
|
|
31
31
|
export declare const peopleMatching: (pattern: string, people: Contact[], { byAddress }?: {
|
|
32
32
|
byAddress?: boolean | undefined;
|
|
33
33
|
}) => Contact[];
|
package/dist/resolve.js
CHANGED
|
@@ -70,7 +70,7 @@ const namePattern = (pattern) => {
|
|
|
70
70
|
const automaton = compileAutomaton(wildcardPattern(foldName(pattern.trim().replace(/^@/, ""))));
|
|
71
71
|
return (names) => names.some((one) => automaton.test(one));
|
|
72
72
|
};
|
|
73
|
-
/** Everyone a name pattern such as
|
|
73
|
+
/** Everyone a name pattern such as `Станислав*` or `*Соколов*` fits by their alias, name or @username. */
|
|
74
74
|
export const peopleMatching = (pattern, people, { byAddress = false } = {}) => {
|
|
75
75
|
const fits = namePattern(pattern);
|
|
76
76
|
return people.filter((person) => fits(namesOf(person, byAddress)));
|
|
@@ -42,6 +42,8 @@ export declare const listedHolds: (account: Pick<ListedAccount, "kind" | "kinds"
|
|
|
42
42
|
export interface ListedEntry {
|
|
43
43
|
entry: string;
|
|
44
44
|
accounts: ListedAccount[];
|
|
45
|
+
/** For a bare word that names no account: the words that name something in the store. */
|
|
46
|
+
holds?: string;
|
|
45
47
|
}
|
|
46
48
|
export declare const keyOf: ({ provider, account }: AccountKey) => string;
|
|
47
49
|
export declare const sourceOf: ({ provider, account }: AccountKey) => string;
|