@wirecat/cli-core 0.599.0 → 0.601.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 +70 -0
- package/dist/background/deliver.js +1 -1
- package/dist/background/schedules.d.ts +1 -1
- package/dist/calendar/cli/search-all.js +9 -2
- package/dist/cli/app-doctor-command.js +18 -10
- package/dist/cli/bot/api-input.js +8 -2
- package/dist/cli/context.d.ts +2 -0
- package/dist/cli/contract-templates.js +2 -1
- package/dist/cli/effects.d.ts +5 -0
- package/dist/cli/effects.js +5 -0
- package/dist/cli/index.d.ts +2 -1
- package/dist/cli/index.js +2 -1
- package/dist/cli/messenger/search-answers.d.ts +5 -1
- package/dist/cli/messenger/search-answers.js +4 -1
- package/dist/cli/new-file.d.ts +2 -0
- package/dist/cli/new-file.js +13 -0
- package/dist/cli/program.js +3 -0
- package/dist/cli/schedule/schedule-command.js +10 -8
- package/dist/cli/search-left-out.d.ts +27 -0
- package/dist/cli/search-left-out.js +31 -0
- package/dist/crm/cli/index.js +2 -7
- package/dist/crm/cli/search-all.js +17 -2
- package/dist/crm/index.d.ts +1 -1
- package/dist/crm/index.js +1 -1
- package/dist/crm/writes.d.ts +17 -0
- package/dist/crm/writes.js +31 -16
- package/dist/entities/index.d.ts +1 -1
- package/dist/entities/list-results.d.ts +1 -1
- package/dist/entities/list-results.js +1 -1
- package/dist/errors/reasons.js +15 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/meetings/cli/index.d.ts +14 -0
- package/dist/meetings/cli/index.js +18 -6
- package/dist/meetings/index.d.ts +1 -1
- package/dist/meetings/mcp/index.d.ts +15 -15
- package/dist/meetings/pull.d.ts +13 -1
- package/dist/meetings/pull.js +34 -8
- package/dist/meetings/source.d.ts +5 -0
- package/dist/resolve.d.ts +2 -2
- package/dist/resolve.js +4 -3
- package/dist/services/search-all.d.ts +3 -0
- package/dist/services/search-all.js +1 -0
- package/dist/speech/local.d.ts +2 -1
- package/dist/speech/local.js +12 -1
- package/dist/speech/recognize.d.ts +2 -0
- package/dist/speech/recognize.js +15 -0
- package/dist/store/decision-requests.d.ts +10 -0
- package/dist/store/decision-requests.js +16 -0
- package/dist/store/index.d.ts +2 -0
- package/dist/store/index.js +1 -0
- package/dist/store/sqlite/deals.d.ts +3 -1
- package/dist/store/sqlite/deals.js +2 -2
- package/dist/store/sqlite/decision-requests.d.ts +59 -0
- package/dist/store/sqlite/decision-requests.js +111 -0
- package/dist/store/sqlite/manifest.js +2 -0
- package/dist/store/sqlite/migrations.generated.js +12 -0
- package/dist/store/sqlite/schema/decision-requests.d.ts +233 -0
- package/dist/store/sqlite/schema/decision-requests.js +20 -0
- package/dist/store/sqlite/schema.d.ts +1 -0
- package/dist/store/sqlite/schema.js +1 -0
- package/dist/store/store.d.ts +3 -0
- package/dist/store/store.js +5 -0
- package/package.json +4 -4
- package/parity.json +14 -10
package/dist/crm/writes.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CliError, isCliError } from "@wirecat/cli-base";
|
|
2
|
+
import { foldName } from "../resolve.js";
|
|
2
3
|
import { guardFor } from "../sends/guard.js";
|
|
3
4
|
import { guardedWrite } from "../sends/guarded.js";
|
|
4
5
|
import { keyedGuard } from "../sends/keyed-guard.js";
|
|
@@ -120,19 +121,28 @@ const fieldsOf = (input, pipeline, currency) => {
|
|
|
120
121
|
}
|
|
121
122
|
return { fields, stage };
|
|
122
123
|
};
|
|
123
|
-
/**
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
124
|
+
/**
|
|
125
|
+
* A field's code, label or option as the lookup compares them: `foldName` (letter case, composed letters, ё as е),
|
|
126
|
+
* with spaces and underscores aside, so `lead_source` and `Lead source` are one name.
|
|
127
|
+
*/
|
|
128
|
+
export const foldFieldName = (name) => foldName(name.trim()).replace(/[\s_]+/gu, " ");
|
|
128
129
|
const named = ({ code, label }) => ({ code, label });
|
|
130
|
+
/** No field by that name: the fields whose code or label holds it, or is held in it, are its candidates. */
|
|
131
|
+
export const unknownField = (fields, name) => {
|
|
132
|
+
const want = foldFieldName(name);
|
|
133
|
+
const close = fields.filter((field) => [field.code, field.label ?? ""].some((one) => {
|
|
134
|
+
const other = foldFieldName(one);
|
|
135
|
+
return other !== "" && (other.includes(want) || want.includes(other));
|
|
136
|
+
}));
|
|
137
|
+
return new CliError("validation_error", `no custom field is named ${name}${close.length ? "; close ones are in candidates" : ""} — \`fields list\` lists them`, { reason: "field.unknown", param: "--field", candidates: close.map(named) });
|
|
138
|
+
};
|
|
129
139
|
/** A field by its code or its whole label; two with that label are refused with both, never guessed. */
|
|
130
|
-
const fieldNamed = (fields, name) => {
|
|
131
|
-
const want =
|
|
132
|
-
const byCode = fields.find((field) =>
|
|
140
|
+
export const fieldNamed = (fields, name) => {
|
|
141
|
+
const want = foldFieldName(name);
|
|
142
|
+
const byCode = fields.find((field) => foldFieldName(field.code) === want);
|
|
133
143
|
if (byCode)
|
|
134
144
|
return byCode;
|
|
135
|
-
const labelled = fields.filter((field) => field.label !== null &&
|
|
145
|
+
const labelled = fields.filter((field) => field.label !== null && foldFieldName(field.label) === want);
|
|
136
146
|
if (labelled.length === 1)
|
|
137
147
|
return labelled[0];
|
|
138
148
|
if (labelled.length > 1)
|
|
@@ -141,17 +151,15 @@ const fieldNamed = (fields, name) => {
|
|
|
141
151
|
param: "--field",
|
|
142
152
|
candidates: labelled.map(named),
|
|
143
153
|
});
|
|
144
|
-
|
|
145
|
-
const other = folded(one);
|
|
146
|
-
return other !== "" && (other.includes(want) || want.includes(other));
|
|
147
|
-
}));
|
|
148
|
-
throw new CliError("validation_error", `no custom field is named ${name}${close.length ? "; close ones are in candidates" : ""} — \`fields list\` lists them`, { reason: "field.unknown", param: "--field", candidates: close.map(named) });
|
|
154
|
+
throw unknownField(fields, name);
|
|
149
155
|
};
|
|
150
|
-
|
|
156
|
+
/** A list field's option id, by its id or its whole label; a field with no options takes the value as typed. */
|
|
157
|
+
export const optionOf = (field, value) => {
|
|
151
158
|
if (!field.options)
|
|
152
159
|
return value;
|
|
160
|
+
const want = foldFieldName(value);
|
|
153
161
|
const found = field.options.find((option) => option.id === value.trim()) ??
|
|
154
|
-
field.options.find((option) =>
|
|
162
|
+
field.options.find((option) => foldFieldName(option.label) === want);
|
|
155
163
|
if (!found)
|
|
156
164
|
throw new CliError("validation_error", `${field.label ?? field.code} has no option ${value}`, {
|
|
157
165
|
reason: "field.unknown-option",
|
|
@@ -161,6 +169,13 @@ const optionOf = (field, value) => {
|
|
|
161
169
|
});
|
|
162
170
|
return found.id;
|
|
163
171
|
};
|
|
172
|
+
/** `--field` pairs as typed, split at the first `=`; a pair with no key before it is refused. */
|
|
173
|
+
export const fieldPairsOf = (typed) => typed.map((one) => {
|
|
174
|
+
const at = one.indexOf("=");
|
|
175
|
+
if (at <= 0 || one.slice(0, at).trim() === "")
|
|
176
|
+
throw new CliError("validation_error", `--field takes <key>=<value>; got ${one}`, { param: "--field" });
|
|
177
|
+
return [one.slice(0, at), one.slice(at + 1)];
|
|
178
|
+
});
|
|
164
179
|
/**
|
|
165
180
|
* `--field` pairs by the synced field definitions: a label to its code, an option to its id, a multiple field's
|
|
166
181
|
* repeats into a list. A CRM whose definitions are not stored takes codes as typed.
|
package/dist/entities/index.d.ts
CHANGED
|
@@ -4124,7 +4124,7 @@ export declare const ENTITIES: {
|
|
|
4124
4124
|
readonly kind: v.PicklistSchema<["command", "agent"], undefined>;
|
|
4125
4125
|
readonly when: v.StringSchema<undefined>;
|
|
4126
4126
|
readonly notify: v.OptionalSchema<v.PicklistSchema<["always", "failures", "never"], undefined>, undefined>;
|
|
4127
|
-
readonly
|
|
4127
|
+
readonly deliver_to: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
4128
4128
|
readonly last: v.NullableSchema<v.StrictObjectSchema<{
|
|
4129
4129
|
readonly at: 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`">]>;
|
|
4130
4130
|
readonly exit_code: v.NumberSchema<undefined>;
|
|
@@ -51,7 +51,7 @@ export declare const scheduledJob: v.StrictObjectSchema<{
|
|
|
51
51
|
/** When a finished run shows a desktop notice: `always`, `failures` or `never`; the default is shown, not left out. */
|
|
52
52
|
readonly notify: v.OptionalSchema<v.PicklistSchema<["always", "failures", "never"], undefined>, undefined>;
|
|
53
53
|
/** Where a run's result is sent after it: `telegram-bot:<profile>/<chat>` or `email:<profile>/<address>`. */
|
|
54
|
-
readonly
|
|
54
|
+
readonly deliver_to: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
55
55
|
readonly last: v.NullableSchema<v.StrictObjectSchema<{
|
|
56
56
|
readonly at: 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`">]>;
|
|
57
57
|
readonly exit_code: v.NumberSchema<undefined>;
|
|
@@ -35,7 +35,7 @@ export const scheduledJob = v.strictObject({
|
|
|
35
35
|
/** When a finished run shows a desktop notice: `always`, `failures` or `never`; the default is shown, not left out. */
|
|
36
36
|
notify: v.optional(v.picklist(["always", "failures", "never"])),
|
|
37
37
|
/** Where a run's result is sent after it: `telegram-bot:<profile>/<chat>` or `email:<profile>/<address>`. */
|
|
38
|
-
|
|
38
|
+
deliver_to: v.optional(v.array(text)),
|
|
39
39
|
last: v.nullable(v.strictObject({
|
|
40
40
|
at: time,
|
|
41
41
|
exit_code: v.number(),
|
package/dist/errors/reasons.js
CHANGED
|
@@ -143,6 +143,7 @@ const OTHERS = [
|
|
|
143
143
|
validation("search.server-options", "search --backend server takes neither --exact, --cursor nor --newest"),
|
|
144
144
|
validation("search.one-backend", "search answers from one backend at a time: archive or server"),
|
|
145
145
|
["search.server-not-allowed", "permission_error", "the profile does not allow messages.server-search"],
|
|
146
|
+
["search.all-denied", "permission_error", "the profile denies every kind search all would read"],
|
|
146
147
|
validation("search.server-no-criteria", "the query has nothing the server can search, so only the store is read"),
|
|
147
148
|
["search.server-unsupported", "provider_error", "this source's server cannot search"],
|
|
148
149
|
["search.server-rate-limited", "rate_limited", "the server refused a search as too many requests"],
|
|
@@ -254,6 +255,20 @@ const OTHERS = [
|
|
|
254
255
|
validation("period.ambiguous", "the period can be read more than one way"),
|
|
255
256
|
validation("proposal.wrong-state", "the proposal is not in a state that allows this"),
|
|
256
257
|
validation("proposal.reason-required", "an agent deciding for the owner gives a reason"),
|
|
258
|
+
validation("decision.request-invalid", "a decision request needs its batch, message, owner and distinct known actions"),
|
|
259
|
+
["decision.token-unknown", "not_found", "no button has this token"],
|
|
260
|
+
["decision.token-used", "permission_error", "this button was already pressed"],
|
|
261
|
+
[
|
|
262
|
+
"decision.token-cancelled",
|
|
263
|
+
"permission_error",
|
|
264
|
+
"another button of the message was pressed, or the feature was turned off",
|
|
265
|
+
],
|
|
266
|
+
["decision.token-expired", "permission_error", "this button is older than 72 hours"],
|
|
267
|
+
[
|
|
268
|
+
"decision.token-mismatch",
|
|
269
|
+
"permission_error",
|
|
270
|
+
"the press came from another chat, message or user than the button was sent to",
|
|
271
|
+
],
|
|
257
272
|
validation("proposal.decider-required", "a decision names who decides: the owner or an agent with a reason"),
|
|
258
273
|
validation("proposal.ids", "the proposal ids cannot be read"),
|
|
259
274
|
["proposal.own", "permission_error", "an agent never decides its own proposal"],
|
package/dist/index.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ export type { GroupRules } from "./moderation/rules.js";
|
|
|
28
28
|
export { defaultRules, ModerationRules, moderationPathFor } from "./moderation/rules.js";
|
|
29
29
|
export { type OutputOptions, resolveOutput } from "./output.js";
|
|
30
30
|
export { pollLines, type RenderOptions, renderMessage, renderMessages } from "./render/messages.js";
|
|
31
|
-
export { isId, type PeopleLookup, pickChat, pickPerson } from "./resolve.js";
|
|
31
|
+
export { foldName, isId, type PeopleLookup, pickChat, pickPerson } from "./resolve.js";
|
|
32
32
|
export { atTerminal, type LoginQr, type LoginQrOptions, loginQr, PASTE_QR, } from "./terminal/login-qr.js";
|
|
33
33
|
export { readSecret, type SecretInput } from "./terminal/prompt.js";
|
|
34
34
|
export { plainQr, terminalQr } from "./terminal/qr.js";
|
package/dist/index.js
CHANGED
|
@@ -21,7 +21,7 @@ export { act, judge } from "./moderation/check.js";
|
|
|
21
21
|
export { defaultRules, ModerationRules, moderationPathFor } from "./moderation/rules.js";
|
|
22
22
|
export { resolveOutput } from "./output.js";
|
|
23
23
|
export { pollLines, renderMessage, renderMessages } from "./render/messages.js";
|
|
24
|
-
export { isId, pickChat, pickPerson } from "./resolve.js";
|
|
24
|
+
export { foldName, isId, pickChat, pickPerson } from "./resolve.js";
|
|
25
25
|
export { atTerminal, loginQr, PASTE_QR, } from "./terminal/login-qr.js";
|
|
26
26
|
export { readSecret } from "./terminal/prompt.js";
|
|
27
27
|
export { plainQr, terminalQr } from "./terminal/qr.js";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type Command } from "commander";
|
|
2
2
|
import { type ImportFile } from "../import.js";
|
|
3
|
+
import { type MeetingBudget } from "../pull.js";
|
|
3
4
|
import type { MeetingSource } from "../source.js";
|
|
4
5
|
import type { MeetingStore } from "../store.js";
|
|
5
6
|
export interface MeetingCommandDeps {
|
|
@@ -9,13 +10,26 @@ export interface MeetingCommandDeps {
|
|
|
9
10
|
readFiles?: (folder: string) => Promise<ImportFile[]>;
|
|
10
11
|
/** The host's file names and how it reads their time, shown in `meetings import --help`. */
|
|
11
12
|
importHelp?: string;
|
|
13
|
+
/** Writes `meetings export --output`; one that refuses a file that exists, such as `writeNewFile`. */
|
|
12
14
|
writeFile?: (path: string, content: string) => Promise<void>;
|
|
15
|
+
/**
|
|
16
|
+
* Marks `meetings export`, whose only write is the new file `--output` names: a read without it, over MCP, and
|
|
17
|
+
* under the read-only lock. `writesNewFileOnlyWith` from `@wirecat/cli-core/cli`; pass it with a `writeFile` that
|
|
18
|
+
* never writes over a file.
|
|
19
|
+
*/
|
|
20
|
+
newFileOutput?: (command: Command, option: string) => void;
|
|
13
21
|
write: (value: unknown, format: "json" | "jsonl" | "text") => void;
|
|
14
22
|
/**
|
|
15
23
|
* Runs a command that reaches the account inside cli-core's run, so it is recorded and ended by `--timeout`:
|
|
16
24
|
* `inCommandRun` from `@wirecat/cli-core/cli`. Required, since this module cannot reach the run itself.
|
|
17
25
|
*/
|
|
18
26
|
inRun: <T>(command: Command, body: () => Promise<T>) => Promise<T>;
|
|
27
|
+
/**
|
|
28
|
+
* The sync's budget from the run's deadline and stop signal: `runBudgetOf` from `@wirecat/cli-core/cli`. Given, the
|
|
29
|
+
* sync is cooperative: it stops between meetings, keeps what it saved and answers `stopped`. Without it the sync
|
|
30
|
+
* keeps the one-shot deadline.
|
|
31
|
+
*/
|
|
32
|
+
budgetOf?: (command: Command) => MeetingBudget;
|
|
19
33
|
now?: () => number;
|
|
20
34
|
}
|
|
21
35
|
export { addMeetingPassageCommand, createMeetingPassageCommand, type MeetingPassageFlags, meetingPassageRequest, } from "./passage.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { annotate, sharedCommand } from "@wirecat/cli-base/commands";
|
|
1
|
+
import { annotate, annotateOption, sharedCommand } from "@wirecat/cli-base/commands";
|
|
2
2
|
import { defineQuery, fieldsHelp, parseLucene, timezoneOf, validateQuery, zonedMoment } from "@wirecat/cli-base/query";
|
|
3
3
|
import { InvalidArgumentError, Option } from "commander";
|
|
4
4
|
import { EVENT_QUERY } from "../event-query.js";
|
|
@@ -76,12 +76,18 @@ const addMeetingCommandsDefinition = (program, deps) => {
|
|
|
76
76
|
.argument("<meeting>", "stored meeting id", integer)).action(async (id, _opts, command) => {
|
|
77
77
|
print(await meetingSummaryAnswer(deps.store, id, deps.accountId), command);
|
|
78
78
|
});
|
|
79
|
-
output(annotate(group.command("export"), { effects: LOCAL_WRITE, output: { entity: "meeting_export" } })
|
|
79
|
+
const exporter = output(annotate(group.command("export"), { effects: LOCAL_WRITE, output: { entity: "meeting_export" } })
|
|
80
80
|
.description("export a meeting as Markdown or one transcript as WebVTT")
|
|
81
81
|
.argument("<meeting>", "stored meeting id", integer)
|
|
82
82
|
.addOption(new Option("--format <format>", "export format").choices(["markdown", "vtt"]).default("markdown"))
|
|
83
83
|
.option("--transcript-id <id>", "export a specific transcript version", integer)
|
|
84
|
-
.
|
|
84
|
+
.addOption(
|
|
85
|
+
// Not over MCP: an agent would choose where on the owner's disk to write; it gets the content in the answer.
|
|
86
|
+
annotateOption(new Option("--output <file>", "write content to a new file through the host's writer"), {
|
|
87
|
+
mcp: false,
|
|
88
|
+
})));
|
|
89
|
+
deps.newFileOutput?.(exporter, "output");
|
|
90
|
+
exporter.action(async (id, opts, command) => {
|
|
85
91
|
if (opts.output !== undefined && !opts.output.trim())
|
|
86
92
|
throw new MeetingError("validation_error", "output path must not be empty");
|
|
87
93
|
if (opts.output !== undefined && !deps.writeFile)
|
|
@@ -117,9 +123,13 @@ const addMeetingCommandsDefinition = (program, deps) => {
|
|
|
117
123
|
effects: FETCH,
|
|
118
124
|
offline: false,
|
|
119
125
|
output: { entity: "meeting_ingestion" },
|
|
120
|
-
|
|
126
|
+
// Only a sync that stops itself at its budget may outlive the one-shot deadline.
|
|
127
|
+
...(deps.budgetOf ? { cooperative: true, partial: true } : {}),
|
|
128
|
+
}).description("bring the stored meetings up to date from the connected account, oldest first; a run that stops before its " +
|
|
129
|
+
"deadline keeps what it saved and the next one goes on from there"))
|
|
121
130
|
.option("--since-time <time>", "fetch meetings starting at or after this ISO 8601 date or time", date)
|
|
122
|
-
.option("--lookback-days <days>", "revisit recent occurrences for late transcripts (0–31)", lookbackDays
|
|
131
|
+
.option("--lookback-days <days>", "revisit recent occurrences for late transcripts (0–31)", lookbackDays)
|
|
132
|
+
.option("--rescan", "read the last 30 days again, not only what came after the last sync")
|
|
123
133
|
.action(async (opts, command) => {
|
|
124
134
|
const source = deps.source;
|
|
125
135
|
if (!source)
|
|
@@ -128,7 +138,9 @@ const addMeetingCommandsDefinition = (program, deps) => {
|
|
|
128
138
|
accountId: deps.accountId,
|
|
129
139
|
since: opts.sinceTime === undefined ? undefined : new Date(opts.sinceTime).toISOString(),
|
|
130
140
|
now: deps.now?.(),
|
|
131
|
-
lookbackMs: opts.lookbackDays * 86400000,
|
|
141
|
+
...(opts.lookbackDays === undefined ? {} : { lookbackMs: opts.lookbackDays * 86400000 }),
|
|
142
|
+
...(opts.rescan ? { rescan: true } : {}),
|
|
143
|
+
...(deps.budgetOf ? { budget: deps.budgetOf(command) } : {}),
|
|
132
144
|
}), command));
|
|
133
145
|
});
|
|
134
146
|
const importCommand = annotate(group.command("import"), {
|
package/dist/meetings/index.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ export { readMeetingProjectEvidence } from "./project-evidence.js";
|
|
|
31
31
|
export { type MeetingProjectEvidenceAnswer, type MeetingProjectEvidenceItem, meetingProjectEvidence, meetingProjectEvidenceAnswer, } from "./project-evidence-answer.js";
|
|
32
32
|
export { MEETING_PROJECT_EVIDENCE_QUERY, type MeetingProjectEvidenceRequest, prepareMeetingProjectEvidence, } from "./project-evidence-query.js";
|
|
33
33
|
export { type MeetingProviderScope, snapshotMeetingScope } from "./provider.js";
|
|
34
|
-
export { type PullOptions, pull, type RunReport } from "./pull.js";
|
|
34
|
+
export { type MeetingBudget, type MeetingBudgetStop, type PullOptions, pull, type RunReport } from "./pull.js";
|
|
35
35
|
export { event, eventItem, meetingCounts, meetingCountsItem, meetingLink, meetingLinkItem, meetingParticipants, meetingPassage, meetingReview, meetingReviewItem, meetingSpeaker, meetingSpeakerItem, meetingStats, meetingStatsItem, } from "./read-answers.js";
|
|
36
36
|
export type { MeetingContextReadCapabilities, MeetingReadBudget, MeetingReadCapabilities, MeetingReadScope, TranscriptContextInput, TranscriptContextPage, TranscriptPage, TranscriptReadScope, TranscriptRowPage, } from "./read-store.js";
|
|
37
37
|
export { listed, MeetingError, meetingDetailsAnswer, meetingPeople, meetingSummaryAnswer, meetingTranscriptAnswer, type TranscriptReadOptions, } from "./reads.js";
|
|
@@ -38,7 +38,6 @@ export declare const meetingTools: ({
|
|
|
38
38
|
max_read_bytes?: undefined;
|
|
39
39
|
cursor?: undefined;
|
|
40
40
|
} | {
|
|
41
|
-
limit?: undefined;
|
|
42
41
|
event_id?: undefined;
|
|
43
42
|
series_id?: undefined;
|
|
44
43
|
page?: undefined;
|
|
@@ -54,11 +53,11 @@ export declare const meetingTools: ({
|
|
|
54
53
|
format?: undefined;
|
|
55
54
|
transcript_id?: undefined;
|
|
56
55
|
query?: undefined;
|
|
56
|
+
limit?: undefined;
|
|
57
57
|
scan_limit?: undefined;
|
|
58
58
|
max_read_bytes?: undefined;
|
|
59
59
|
cursor?: undefined;
|
|
60
60
|
} | {
|
|
61
|
-
limit?: undefined;
|
|
62
61
|
event_id?: undefined;
|
|
63
62
|
series_id?: undefined;
|
|
64
63
|
page?: undefined;
|
|
@@ -76,11 +75,11 @@ export declare const meetingTools: ({
|
|
|
76
75
|
format?: undefined;
|
|
77
76
|
transcript_id?: undefined;
|
|
78
77
|
query?: undefined;
|
|
78
|
+
limit?: undefined;
|
|
79
79
|
scan_limit?: undefined;
|
|
80
80
|
max_read_bytes?: undefined;
|
|
81
81
|
cursor?: undefined;
|
|
82
82
|
} | {
|
|
83
|
-
limit?: undefined;
|
|
84
83
|
event_id?: undefined;
|
|
85
84
|
series_id?: undefined;
|
|
86
85
|
page?: undefined;
|
|
@@ -102,6 +101,7 @@ export declare const meetingTools: ({
|
|
|
102
101
|
minimum: number;
|
|
103
102
|
};
|
|
104
103
|
query?: undefined;
|
|
104
|
+
limit?: undefined;
|
|
105
105
|
scan_limit?: undefined;
|
|
106
106
|
max_read_bytes?: undefined;
|
|
107
107
|
cursor?: undefined;
|
|
@@ -188,7 +188,6 @@ export declare const meetingTools: ({
|
|
|
188
188
|
max_read_bytes?: undefined;
|
|
189
189
|
cursor?: undefined;
|
|
190
190
|
} | {
|
|
191
|
-
limit?: undefined;
|
|
192
191
|
event_id?: undefined;
|
|
193
192
|
series_id?: undefined;
|
|
194
193
|
page?: undefined;
|
|
@@ -204,11 +203,11 @@ export declare const meetingTools: ({
|
|
|
204
203
|
format?: undefined;
|
|
205
204
|
transcript_id?: undefined;
|
|
206
205
|
query?: undefined;
|
|
206
|
+
limit?: undefined;
|
|
207
207
|
scan_limit?: undefined;
|
|
208
208
|
max_read_bytes?: undefined;
|
|
209
209
|
cursor?: undefined;
|
|
210
210
|
} | {
|
|
211
|
-
limit?: undefined;
|
|
212
211
|
event_id?: undefined;
|
|
213
212
|
series_id?: undefined;
|
|
214
213
|
page?: undefined;
|
|
@@ -226,11 +225,11 @@ export declare const meetingTools: ({
|
|
|
226
225
|
format?: undefined;
|
|
227
226
|
transcript_id?: undefined;
|
|
228
227
|
query?: undefined;
|
|
228
|
+
limit?: undefined;
|
|
229
229
|
scan_limit?: undefined;
|
|
230
230
|
max_read_bytes?: undefined;
|
|
231
231
|
cursor?: undefined;
|
|
232
232
|
} | {
|
|
233
|
-
limit?: undefined;
|
|
234
233
|
event_id?: undefined;
|
|
235
234
|
series_id?: undefined;
|
|
236
235
|
page?: undefined;
|
|
@@ -252,6 +251,7 @@ export declare const meetingTools: ({
|
|
|
252
251
|
minimum: number;
|
|
253
252
|
};
|
|
254
253
|
query?: undefined;
|
|
254
|
+
limit?: undefined;
|
|
255
255
|
scan_limit?: undefined;
|
|
256
256
|
max_read_bytes?: undefined;
|
|
257
257
|
cursor?: undefined;
|
|
@@ -338,7 +338,6 @@ export declare const meetingTools: ({
|
|
|
338
338
|
max_read_bytes?: undefined;
|
|
339
339
|
cursor?: undefined;
|
|
340
340
|
} | {
|
|
341
|
-
limit?: undefined;
|
|
342
341
|
event_id?: undefined;
|
|
343
342
|
series_id?: undefined;
|
|
344
343
|
page?: undefined;
|
|
@@ -354,11 +353,11 @@ export declare const meetingTools: ({
|
|
|
354
353
|
format?: undefined;
|
|
355
354
|
transcript_id?: undefined;
|
|
356
355
|
query?: undefined;
|
|
356
|
+
limit?: undefined;
|
|
357
357
|
scan_limit?: undefined;
|
|
358
358
|
max_read_bytes?: undefined;
|
|
359
359
|
cursor?: undefined;
|
|
360
360
|
} | {
|
|
361
|
-
limit?: undefined;
|
|
362
361
|
event_id?: undefined;
|
|
363
362
|
series_id?: undefined;
|
|
364
363
|
page?: undefined;
|
|
@@ -376,11 +375,11 @@ export declare const meetingTools: ({
|
|
|
376
375
|
format?: undefined;
|
|
377
376
|
transcript_id?: undefined;
|
|
378
377
|
query?: undefined;
|
|
378
|
+
limit?: undefined;
|
|
379
379
|
scan_limit?: undefined;
|
|
380
380
|
max_read_bytes?: undefined;
|
|
381
381
|
cursor?: undefined;
|
|
382
382
|
} | {
|
|
383
|
-
limit?: undefined;
|
|
384
383
|
event_id?: undefined;
|
|
385
384
|
series_id?: undefined;
|
|
386
385
|
page?: undefined;
|
|
@@ -402,6 +401,7 @@ export declare const meetingTools: ({
|
|
|
402
401
|
minimum: number;
|
|
403
402
|
};
|
|
404
403
|
query?: undefined;
|
|
404
|
+
limit?: undefined;
|
|
405
405
|
scan_limit?: undefined;
|
|
406
406
|
max_read_bytes?: undefined;
|
|
407
407
|
cursor?: undefined;
|
|
@@ -488,7 +488,6 @@ export declare const meetingTools: ({
|
|
|
488
488
|
max_read_bytes?: undefined;
|
|
489
489
|
cursor?: undefined;
|
|
490
490
|
} | {
|
|
491
|
-
limit?: undefined;
|
|
492
491
|
event_id?: undefined;
|
|
493
492
|
series_id?: undefined;
|
|
494
493
|
page?: undefined;
|
|
@@ -504,11 +503,11 @@ export declare const meetingTools: ({
|
|
|
504
503
|
format?: undefined;
|
|
505
504
|
transcript_id?: undefined;
|
|
506
505
|
query?: undefined;
|
|
506
|
+
limit?: undefined;
|
|
507
507
|
scan_limit?: undefined;
|
|
508
508
|
max_read_bytes?: undefined;
|
|
509
509
|
cursor?: undefined;
|
|
510
510
|
} | {
|
|
511
|
-
limit?: undefined;
|
|
512
511
|
event_id?: undefined;
|
|
513
512
|
series_id?: undefined;
|
|
514
513
|
page?: undefined;
|
|
@@ -526,11 +525,11 @@ export declare const meetingTools: ({
|
|
|
526
525
|
format?: undefined;
|
|
527
526
|
transcript_id?: undefined;
|
|
528
527
|
query?: undefined;
|
|
528
|
+
limit?: undefined;
|
|
529
529
|
scan_limit?: undefined;
|
|
530
530
|
max_read_bytes?: undefined;
|
|
531
531
|
cursor?: undefined;
|
|
532
532
|
} | {
|
|
533
|
-
limit?: undefined;
|
|
534
533
|
event_id?: undefined;
|
|
535
534
|
series_id?: undefined;
|
|
536
535
|
page?: undefined;
|
|
@@ -552,6 +551,7 @@ export declare const meetingTools: ({
|
|
|
552
551
|
minimum: number;
|
|
553
552
|
};
|
|
554
553
|
query?: undefined;
|
|
554
|
+
limit?: undefined;
|
|
555
555
|
scan_limit?: undefined;
|
|
556
556
|
max_read_bytes?: undefined;
|
|
557
557
|
cursor?: undefined;
|
|
@@ -638,7 +638,6 @@ export declare const meetingTools: ({
|
|
|
638
638
|
max_read_bytes?: undefined;
|
|
639
639
|
cursor?: undefined;
|
|
640
640
|
} | {
|
|
641
|
-
limit?: undefined;
|
|
642
641
|
event_id?: undefined;
|
|
643
642
|
series_id?: undefined;
|
|
644
643
|
page?: undefined;
|
|
@@ -654,11 +653,11 @@ export declare const meetingTools: ({
|
|
|
654
653
|
format?: undefined;
|
|
655
654
|
transcript_id?: undefined;
|
|
656
655
|
query?: undefined;
|
|
656
|
+
limit?: undefined;
|
|
657
657
|
scan_limit?: undefined;
|
|
658
658
|
max_read_bytes?: undefined;
|
|
659
659
|
cursor?: undefined;
|
|
660
660
|
} | {
|
|
661
|
-
limit?: undefined;
|
|
662
661
|
event_id?: undefined;
|
|
663
662
|
series_id?: undefined;
|
|
664
663
|
page?: undefined;
|
|
@@ -676,11 +675,11 @@ export declare const meetingTools: ({
|
|
|
676
675
|
format?: undefined;
|
|
677
676
|
transcript_id?: undefined;
|
|
678
677
|
query?: undefined;
|
|
678
|
+
limit?: undefined;
|
|
679
679
|
scan_limit?: undefined;
|
|
680
680
|
max_read_bytes?: undefined;
|
|
681
681
|
cursor?: undefined;
|
|
682
682
|
} | {
|
|
683
|
-
limit?: undefined;
|
|
684
683
|
event_id?: undefined;
|
|
685
684
|
series_id?: undefined;
|
|
686
685
|
page?: undefined;
|
|
@@ -702,6 +701,7 @@ export declare const meetingTools: ({
|
|
|
702
701
|
minimum: number;
|
|
703
702
|
};
|
|
704
703
|
query?: undefined;
|
|
704
|
+
limit?: undefined;
|
|
705
705
|
scan_limit?: undefined;
|
|
706
706
|
max_read_bytes?: undefined;
|
|
707
707
|
cursor?: undefined;
|
package/dist/meetings/pull.d.ts
CHANGED
|
@@ -11,12 +11,24 @@ export interface RunReport {
|
|
|
11
11
|
}[];
|
|
12
12
|
/** An import whose files all read their start time in one zone names it; files carry no zone of their own. */
|
|
13
13
|
timezone?: string;
|
|
14
|
+
/** A pull stopped by its budget before every meeting it listed: why, and how many it did not reach. */
|
|
15
|
+
stopped?: MeetingBudgetStop;
|
|
16
|
+
remaining?: number;
|
|
17
|
+
}
|
|
18
|
+
export type MeetingBudgetStop = "requests" | "deadline" | "cancelled";
|
|
19
|
+
/** One meeting more, or why not: `runBudgetOf(command)` from `@wirecat/cli-core/cli` fits. */
|
|
20
|
+
export interface MeetingBudget {
|
|
21
|
+
take(): MeetingBudgetStop | null;
|
|
14
22
|
}
|
|
15
23
|
export interface PullOptions {
|
|
16
24
|
accountId: number;
|
|
17
25
|
since?: string;
|
|
18
26
|
now?: number;
|
|
19
|
-
/** Revisit recent occurrences; integer milliseconds from 0 through 31 days. Defaults to
|
|
27
|
+
/** Revisit recent occurrences; integer milliseconds from 0 through 31 days. Defaults to the source's `overlapMs`. */
|
|
20
28
|
lookbackMs?: number;
|
|
29
|
+
/** Start from 30 days back, not from the cursor. */
|
|
30
|
+
rescan?: boolean;
|
|
31
|
+
/** Asked before each meeting; a stop keeps what is saved and moves the cursor to the first meeting not reached. */
|
|
32
|
+
budget?: MeetingBudget;
|
|
21
33
|
}
|
|
22
34
|
export declare const pull: (source: MeetingSource, store: MeetingStore, options: PullOptions) => Promise<RunReport>;
|
package/dist/meetings/pull.js
CHANGED
|
@@ -16,25 +16,51 @@ const participantInput = (p, provider, occurrenceId, position, accountId) => {
|
|
|
16
16
|
},
|
|
17
17
|
};
|
|
18
18
|
};
|
|
19
|
+
/** A start that does not parse sorts last; its own save reports it. */
|
|
20
|
+
const startOf = (m) => {
|
|
21
|
+
const at = Date.parse(m.occurrence.startedAt);
|
|
22
|
+
return Number.isFinite(at) ? at : Number.POSITIVE_INFINITY;
|
|
23
|
+
};
|
|
19
24
|
export const pull = async (source, store, options) => {
|
|
20
25
|
const now = options.now ?? Date.now();
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
26
|
+
for (const [name, ms] of [
|
|
27
|
+
["lookbackMs", options.lookbackMs ?? 0],
|
|
28
|
+
["overlapMs", source.overlapMs ?? 0],
|
|
29
|
+
])
|
|
30
|
+
if (!Number.isSafeInteger(ms) || ms < 0 || ms > 31 * 86400000)
|
|
31
|
+
throw new Error(`${name} must be an integer from 0 through 31 days`);
|
|
32
|
+
const lookbackMs = Math.max(options.lookbackMs ?? 0, source.overlapMs ?? 0);
|
|
33
|
+
const cursor = options.rescan ? undefined : await store.cursor(options.accountId);
|
|
34
|
+
const since = options.since ?? cursor ?? new Date(now - 30 * 86400000).toISOString();
|
|
25
35
|
timestamp(since);
|
|
26
36
|
const report = { meetings: 0, participants: 0, transcriptRows: 0, summaries: 0, warnings: [] };
|
|
27
37
|
let failed = false;
|
|
38
|
+
/** The start of the first meeting that failed: the cursor of a stopped pull goes no further. */
|
|
39
|
+
let firstFailed;
|
|
28
40
|
const from = timestamp(since) - lookbackMs;
|
|
29
|
-
|
|
30
|
-
|
|
41
|
+
// Oldest first, so a stopped pull leaves everything before its cursor done.
|
|
42
|
+
const meetings = (await source.meetings(lookbackMs === 0 ? since : new Date(from).toISOString())).toSorted((a, b) => startOf(a) - startOf(b));
|
|
43
|
+
for (const [index, m] of meetings.entries()) {
|
|
44
|
+
const stop = options.budget?.take() ?? null;
|
|
45
|
+
if (stop) {
|
|
46
|
+
report.stopped = stop;
|
|
47
|
+
report.remaining = meetings.length - index;
|
|
48
|
+
const reached = Math.min(startOf(m), firstFailed ?? Number.POSITIVE_INFINITY);
|
|
49
|
+
if (Number.isFinite(reached) && reached > timestamp(since))
|
|
50
|
+
await store.setCursor(options.accountId, new Date(reached).toISOString(), now);
|
|
51
|
+
return report;
|
|
52
|
+
}
|
|
31
53
|
const id = m.occurrence.id;
|
|
54
|
+
const failedHere = () => {
|
|
55
|
+
failed = true;
|
|
56
|
+
firstFailed ??= startOf(m);
|
|
57
|
+
};
|
|
32
58
|
const read = async (part, call) => {
|
|
33
59
|
try {
|
|
34
60
|
return await call();
|
|
35
61
|
}
|
|
36
62
|
catch (error) {
|
|
37
|
-
|
|
63
|
+
failedHere();
|
|
38
64
|
const message = error instanceof Error ? error.message : "could not be read";
|
|
39
65
|
report.warnings.push({ externalId: id, message: `${part}: ${message}` });
|
|
40
66
|
return undefined;
|
|
@@ -138,7 +164,7 @@ export const pull = async (source, store, options) => {
|
|
|
138
164
|
report.summaries += summary ? 1 : 0;
|
|
139
165
|
}
|
|
140
166
|
catch (error) {
|
|
141
|
-
|
|
167
|
+
failedHere();
|
|
142
168
|
report.warnings.push({ externalId: id, message: error instanceof Error ? error.message : "Meeting pull failed" });
|
|
143
169
|
}
|
|
144
170
|
}
|
|
@@ -17,6 +17,11 @@ export interface MeetingSource {
|
|
|
17
17
|
readonly provider: string;
|
|
18
18
|
readonly name: string;
|
|
19
19
|
readonly transcriptFormat?: string;
|
|
20
|
+
/**
|
|
21
|
+
* How far back each sync looks before its cursor, in integer milliseconds up to 31 days: a provider that lists a
|
|
22
|
+
* meeting only once it has ended, or adds its recording later, sets it. 0 when absent; `--lookback-days` widens it.
|
|
23
|
+
*/
|
|
24
|
+
readonly overlapMs?: number;
|
|
20
25
|
meetings(since: string): Promise<SourceMeeting[]>;
|
|
21
26
|
participants(occurrenceId: string): Promise<SourceParticipant[] | null>;
|
|
22
27
|
transcript(occurrenceId: string): Promise<TranscriptLine[] | null>;
|
package/dist/resolve.d.ts
CHANGED
|
@@ -11,8 +11,8 @@ export interface PeopleLookup {
|
|
|
11
11
|
export declare const isId: (reference: string) => boolean;
|
|
12
12
|
/**
|
|
13
13
|
* A name as matching compares it. A copied emoji often carries a presentation mark (U+FE0F, U+FE0E) or a joiner
|
|
14
|
-
* (U+200D) the typed one lacks,
|
|
15
|
-
* name.
|
|
14
|
+
* (U+200D) the typed one lacks, a letter may come composed or as letter plus accent, and Russian is mostly typed with
|
|
15
|
+
* е for ё; none of that is a different name. Only ё is folded: stripping every mark would also merge й into и.
|
|
16
16
|
*/
|
|
17
17
|
export declare const foldName: (name: string) => string;
|
|
18
18
|
/**
|
package/dist/resolve.js
CHANGED
|
@@ -4,13 +4,14 @@ import { contactReferenceOf } from "./domain/ref-arguments.js";
|
|
|
4
4
|
export const isId = (reference) => /^-?\d+$/.test(reference.trim());
|
|
5
5
|
/**
|
|
6
6
|
* A name as matching compares it. A copied emoji often carries a presentation mark (U+FE0F, U+FE0E) or a joiner
|
|
7
|
-
* (U+200D) the typed one lacks,
|
|
8
|
-
* name.
|
|
7
|
+
* (U+200D) the typed one lacks, a letter may come composed or as letter plus accent, and Russian is mostly typed with
|
|
8
|
+
* е for ё; none of that is a different name. Only ё is folded: stripping every mark would also merge й into и.
|
|
9
9
|
*/
|
|
10
10
|
export const foldName = (name) => name
|
|
11
11
|
.normalize("NFC")
|
|
12
12
|
.replace(/[\uFE0E\uFE0F\u200D]/g, "")
|
|
13
|
-
.toLowerCase()
|
|
13
|
+
.toLowerCase()
|
|
14
|
+
.replaceAll("ё", "е");
|
|
14
15
|
/**
|
|
15
16
|
* A name matched as a fragment — and **an ambiguous one is an error, not a guess**: sending to the
|
|
16
17
|
* wrong conversation is not undoable, so the caller is shown the candidates and asked to be
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type ErrorCode } from "@wirecat/cli-base";
|
|
2
2
|
import { type HitFile } from "../domain/attachments.js";
|
|
3
|
+
import type { DealKind } from "../domain/deals.js";
|
|
3
4
|
import { type MailFields } from "../domain/models.js";
|
|
4
5
|
import type { MessengerTraits } from "../ports/traits.js";
|
|
5
6
|
import type { AccountKey, MessageStore } from "../store/store.js";
|
|
@@ -104,6 +105,8 @@ export interface SearchAllRequest {
|
|
|
104
105
|
signal?: AbortSignal;
|
|
105
106
|
/** The accounts `--source` chose, per kind; a kind left out reads every account of its own. */
|
|
106
107
|
scope?: Partial<Record<SearchedResource, AccountKey[]>>;
|
|
108
|
+
/** The CRM kinds `crm` reads; absent, deals and leads. */
|
|
109
|
+
crmKinds?: readonly DealKind[];
|
|
107
110
|
}
|
|
108
111
|
export type SearchAllMessenger = Partial<Pick<MessengerTraits, "savedChatId" | "app">> & {
|
|
109
112
|
/**
|
|
@@ -257,6 +257,7 @@ export const searchAll = async (store, account, request, messenger = {}, searchM
|
|
|
257
257
|
const found = await store.deals.find({
|
|
258
258
|
words,
|
|
259
259
|
anyWord: anyWord || discover,
|
|
260
|
+
...(request.crmKinds === undefined ? {} : { kinds: request.crmKinds }),
|
|
260
261
|
limit: Math.min(window + 1, 500),
|
|
261
262
|
...(chosen === undefined ? {} : { accounts: chosen }),
|
|
262
263
|
});
|