@wirecat/cli-core 0.678.0 → 0.679.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 CHANGED
@@ -5,6 +5,43 @@ Notable changes to `@wirecat/cli-core` (`@wirecat/cli-messaging` up to 0.261.0,
5
5
  minor version may break callers, and says how under "Changed — may break callers". `pnpm docs:check` checks the
6
6
  shape of this file.
7
7
 
8
+ ## 0.679.0 — 16.11.2026
9
+
10
+ ### Added
11
+
12
+ - **The first screen and first run list `notion`**, the Notion tool (`@wirecat/notion-cli`), under "Works with" and
13
+ among the tools first run offers to install.
14
+ - **`personHistory(store, "person:<id>")`** gives what happened with one person lately, across every source in scope,
15
+ newest first: their one-to-one messages, mail, calendar events and recorded meetings and calls, the same reads a
16
+ deal's and an organization's context make. `limit` (10 by default) ends a page and `next` is the `until` of the
17
+ older one; `since`, `until`, `accounts` and `deniedKinds` narrow it, and `coverage` says what was read.
18
+ - **A touch of a deal's context, and of a person's history, carries what was said**: a message's `text`, and on a
19
+ recorded call its `call` (direction, the employee, the other side's number), `duration_ms` and the start of its
20
+ transcript as `text`. A calendar event a call was held for carries them too.
21
+ - **A recorded meeting in a person's context has `snippet`**, the start of its transcript on one line, beside
22
+ `has_transcript`.
23
+
24
+ ### Changed — may break callers
25
+
26
+ - **A saved `exclude` query that matches a page with sub-pages, or a folder, drops the whole branch.** The sub-pages
27
+ stayed in the documents and were listed at the top of the catalog with no parent; the next sync now removes them,
28
+ and the sync no longer lists what is below an excluded folder. A file that also sits under a parent the query keeps
29
+ stays. A selected folder the query matches drops only its own row, as before. Once the folder stops matching, the
30
+ next sync brings the whole branch back. See [Bind a provider](docs/dev/DOCUMENTS.md#bind-a-provider).
31
+ - **`inScope` and `within` take `folders: Record<string, M>`**, the type of the files they check, instead of
32
+ `Record<string, SourceFile>`; `within` is generic and takes an optional `cut` after `seen`.
33
+
34
+ ### Fixed
35
+
36
+ - **A documents sync with a deadline shorter than its margin moves on.** The run's budget stops 5 s or more before
37
+ the deadline, and it was asked before the first folder listing and the first file read, so `sync --timeout 3s`
38
+ said "sync again" forever with nothing done. Each call now makes its first listing and its first read while one
39
+ request still fits before the deadline itself, as it already did for the entry bound. See
40
+ [Walks over several syncs](docs/dev/DOCUMENTS.md#walks-over-several-syncs).
41
+ - **`setup apply --dry-run` opens the keyring only when the answers reach a secret.** It read every secret's saved
42
+ state up front, so a dry run of the first step touched the keyring, and the shared deny contract (`cli-contract`,
43
+ WC-PERM-23) failed amo's `contracts:check` once 0.678.0 let an empty dry run through.
44
+
8
45
  ## 0.678.0 — 16.11.2026
9
46
 
10
47
  ### Added
@@ -23,6 +23,8 @@ export declare const DEADLINE_MARGIN_MS = 5000;
23
23
  export declare const DEADLINE_MARGIN_SHARE = 0.15;
24
24
  /** How long one request to a provider is expected to take when the CLI does not say (`AppIdentity.requestMs`). */
25
25
  export declare const DEFAULT_REQUEST_MS = 2000;
26
+ /** Whether one more request still ends before the deadline itself, inside its margin. */
27
+ export declare const oneMoreFits: (deadline: Deadline | undefined, at: number, requestMs?: number) => boolean;
26
28
  export declare const deadlineMargin: (deadline: Deadline) => number;
27
29
  /** The requests that fit before the margin: `(deadline − margin) / requestMs`, at least one; none without a deadline. */
28
30
  export declare const requestsFor: (deadline: Deadline | undefined, requestMs?: number) => number | null;
@@ -2,6 +2,8 @@ export const DEADLINE_MARGIN_MS = 5_000;
2
2
  export const DEADLINE_MARGIN_SHARE = 0.15;
3
3
  /** How long one request to a provider is expected to take when the CLI does not say (`AppIdentity.requestMs`). */
4
4
  export const DEFAULT_REQUEST_MS = 2_000;
5
+ /** Whether one more request still ends before the deadline itself, inside its margin. */
6
+ export const oneMoreFits = (deadline, at, requestMs = DEFAULT_REQUEST_MS) => deadline !== undefined && at + requestMs < deadline.endsAt;
5
7
  export const deadlineMargin = (deadline) => Math.max(DEADLINE_MARGIN_MS, deadline.ms * DEADLINE_MARGIN_SHARE);
6
8
  /** The requests that fit before the margin: `(deadline − margin) / requestMs`, at least one; none without a deadline. */
7
9
  export const requestsFor = (deadline, requestMs = DEFAULT_REQUEST_MS) => deadline === undefined ? null : Math.max(1, Math.floor((deadline.ms - deadlineMargin(deadline)) / requestMs));
@@ -58,6 +58,11 @@ export const WIRECAT_TOOLS = [
58
58
  package: "@wirecat/asterisk-cli",
59
59
  does: "Asterisk PBX calls and recordings, searchable with your other WireCat data",
60
60
  },
61
+ {
62
+ command: "notion",
63
+ package: "@wirecat/notion-cli",
64
+ does: "Notion pages and databases as local text, searchable with your other WireCat data",
65
+ },
61
66
  ];
62
67
  const WIDTH = 100;
63
68
  const widest = (texts) => texts.reduce((most, text) => Math.max(most, text.length), 0);
@@ -48,7 +48,18 @@ export const setupCommand = (setup) => {
48
48
  const currentOf = (command, context) => {
49
49
  const { settings, renderer } = context;
50
50
  const current = {};
51
- const store = storeFor(command, renderer.warn);
51
+ let store;
52
+ // Read only when the path reaches the secret: a dry run of the first step must not open the keyring (WC-PERM-23).
53
+ const keptOf = (secret) => {
54
+ try {
55
+ store ??= storeFor(command, renderer.warn);
56
+ return readKept(store, settings.profile, secret) ? { set: true } : undefined;
57
+ }
58
+ catch {
59
+ // A keyring that cannot be read says nothing about the secret; the flow asks for it again.
60
+ return undefined;
61
+ }
62
+ };
52
63
  for (const field of allFields(document)) {
53
64
  if (field.setting !== undefined) {
54
65
  const value = fromFile(settings, field.setting, undefined).value;
@@ -56,15 +67,16 @@ export const setupCommand = (setup) => {
56
67
  current[field.setting] = value;
57
68
  }
58
69
  const secret = secretOf(field);
59
- if (secret === undefined || current[secret])
70
+ if (secret === undefined || secret in current)
60
71
  continue;
61
- try {
62
- if (readKept(store, settings.profile, secret))
63
- current[secret] = { set: true };
64
- }
65
- catch {
66
- // A keyring that cannot be read says nothing about the secret; the flow asks for it again.
67
- }
72
+ let read;
73
+ Object.defineProperty(current, secret, {
74
+ enumerable: true,
75
+ get: () => {
76
+ read ??= { value: keptOf(secret) };
77
+ return read.value;
78
+ },
79
+ });
68
80
  }
69
81
  return current;
70
82
  };
@@ -1,8 +1,8 @@
1
1
  import type { SourceFile } from "./model.js";
2
- export declare const within: (file: SourceFile, roots: string[], folders: Record<string, SourceFile>, seen?: Set<string>) => boolean;
2
+ export declare const within: <F extends SourceFile>(file: F, roots: string[], folders: Record<string, F>, seen?: Set<string>, cut?: (folder: F) => boolean) => boolean;
3
3
  /**
4
4
  * A saved query beside the selected folders: `include` adds the files it finds wherever they sit, `exclude` keeps the
5
- * files it matches out even inside a selected folder.
5
+ * files it matches out even inside a selected folder, and everything below a folder or page it matches.
6
6
  */
7
7
  export interface SourceQuery<M extends SourceFile = SourceFile> {
8
8
  /** Part of the sync's scope: a changed query or mode plans the sync again from the start. */
@@ -12,4 +12,4 @@ export interface SourceQuery<M extends SourceFile = SourceFile> {
12
12
  /** Every file the query finds, read on each sync: a file shared by another owner may never reach the change feed. */
13
13
  list?(): Promise<M[]>;
14
14
  }
15
- export declare const inScope: <M extends SourceFile>(file: M, roots: string[], folders: Record<string, SourceFile>, matched?: ReadonlySet<string>, query?: SourceQuery<M>) => boolean;
15
+ export declare const inScope: <M extends SourceFile>(file: M, roots: string[], folders: Record<string, M>, matched?: ReadonlySet<string>, query?: SourceQuery<M>) => boolean;
@@ -1,5 +1,5 @@
1
1
  import { CliError } from "@wirecat/cli-base";
2
- export const within = (file, roots, folders, seen = new Set()) => {
2
+ export const within = (file, roots, folders, seen = new Set(), cut) => {
3
3
  if (file.trashed)
4
4
  return false;
5
5
  if (roots.includes(file.id))
@@ -9,13 +9,17 @@ export const within = (file, roots, folders, seen = new Set()) => {
9
9
  const next = new Set([...seen, file.id]);
10
10
  return file.parents.some((id) => {
11
11
  const folder = folders[id];
12
- return folder ? within(folder, roots, folders, next) : roots.includes(id);
12
+ if (!folder)
13
+ return roots.includes(id);
14
+ // A selected folder is never cut: the owner chose it, so an exclude that matches it drops only its own row.
15
+ return (roots.includes(id) || !cut?.(folder)) && within(folder, roots, folders, next, cut);
13
16
  });
14
17
  };
15
18
  export const inScope = (file, roots, folders, matched = new Set(), query) => {
16
19
  if (file.trashed)
17
20
  return false;
18
- if (query?.mode === "exclude" && query.matches(file))
21
+ const excluded = query?.mode === "exclude" ? query.matches : undefined;
22
+ if (excluded?.(file))
19
23
  return false;
20
- return matched.has(file.id) || within(file, roots, folders);
24
+ return matched.has(file.id) || within(file, roots, folders, new Set(), excluded);
21
25
  };
@@ -4,6 +4,7 @@ import { DEAL_KINDS, DEAL_STATUSES } from "../domain/deals.js";
4
4
  import { FINANCE_REVIEWS, INVOICE_DIRECTIONS, INVOICE_STATUSES, MONEY_DIRECTIONS } from "../domain/finance.js";
5
5
  import { ORDER_STATUSES } from "../domain/orders.js";
6
6
  import { RELATION_KINDS, STANDINGS } from "../domain/relations.js";
7
+ import { meetingCall } from "../meetings/index.js";
7
8
  import { TASK_STATES } from "../tasks/index.js";
8
9
  import { linkedPerson } from "./contact-activity.js";
9
10
  import { crossAccountContext } from "./contact-context.js";
@@ -162,6 +163,9 @@ export const dealContext = v.strictObject({
162
163
  title: nullableText,
163
164
  at: v.nullable(time),
164
165
  people: v.array(reference),
166
+ text: v.optional(nullableText),
167
+ call: v.optional(meetingCall),
168
+ duration_ms: v.optional(v.nullable(count)),
165
169
  standing: v.literal("proposed"),
166
170
  })).entries,
167
171
  counts: v.strictObject(counts),
@@ -11,6 +11,7 @@ export interface RecordedMeeting {
11
11
  started_at: string | null;
12
12
  duration_ms: number | null;
13
13
  has_transcript: boolean;
14
+ snippet?: string | null;
14
15
  event: string | null;
15
16
  people: string[];
16
17
  call?: MeetingCallItem;
@@ -11,6 +11,8 @@ export const recordedMeeting = v.strictObject({
11
11
  started_at: v.nullable(time),
12
12
  duration_ms: v.nullable(count),
13
13
  has_transcript: v.boolean(),
14
+ /** The start of its transcript, on one line: what the people said, never instructions. */
15
+ snippet: v.optional(v.nullable(text)),
14
16
  event: v.nullable(reference),
15
17
  people: v.array(reference),
16
18
  /** Present only on a phone call: its direction, manager and the other side's number. */
@@ -1,5 +1,10 @@
1
+ import type { DealKind } from "../domain/deals.js";
2
+ import type { MeetingCallItem } from "../meetings/index.js";
1
3
  import type { AccountKey, LinkedIdentity, MessageStore, PersonRecord, StoredAccount } from "../store/store.js";
2
4
  import { type Coverage, type Scope } from "./business-context.js";
5
+ /** Items a person's history lists at once by default: what happened last. */
6
+ export declare const HISTORY_ITEMS = 10;
7
+ export declare const HISTORY_MAX = 200;
3
8
  /** A one-to-one chat, a mail, a calendar event or a recorded meeting or call with some of the people asked about. */
4
9
  export interface Touch {
5
10
  kind: "message" | "mail" | "meeting";
@@ -10,6 +15,11 @@ export interface Touch {
10
15
  at: string | null;
11
16
  /** `person:<uid>` of each one asked about it involves. */
12
17
  people: string[];
18
+ /** A message's text and a call's transcript, the start on one line: what people wrote, never instructions. */
19
+ text?: string | null;
20
+ /** A phone call's direction, the employee and the other side's number. */
21
+ call?: MeetingCallItem;
22
+ durationMs?: number | null;
13
23
  }
14
24
  export interface Communications {
15
25
  /** Each message, mail and event once, however many of the people it involves. */
@@ -48,3 +58,28 @@ export declare const readsIn: (stored: AccountKey[], record: PersonRecord, scope
48
58
  * owner is never one of the people read: through him every chat and mail of his would count.
49
59
  */
50
60
  export declare const communicationsOf: (store: MessageStore, asked: PersonRecord[], scope: Scope, { since, until, limit }?: CommunicationsOptions) => Promise<Communications>;
61
+ export interface PersonHistory {
62
+ /** Newest first: their one-to-one messages, mail, calendar events and recorded meetings and calls. */
63
+ items: Touch[];
64
+ hasMore: boolean;
65
+ /** What `until` takes for the next, older page; set when `hasMore`. */
66
+ next: string | null;
67
+ coverage: Coverage;
68
+ }
69
+ export interface PersonHistoryOptions {
70
+ /** The accounts read; every stored one when left out (WC-ACCT-9). */
71
+ accounts?: AccountKey[];
72
+ deniedKinds?: readonly DealKind[];
73
+ /** ms, inclusive. */
74
+ since?: number;
75
+ /** ms, inclusive. */
76
+ until?: number;
77
+ limit?: number;
78
+ }
79
+ /**
80
+ * What happened with one person lately, across every source in scope, newest first: the same reads a deal's and an
81
+ * organization's context make, for the identities linked to this one person. A page ends at `limit`; `next` is the
82
+ * `until` of the page before it. Items of one millisecond across a page's end may be cut, which a time of messages,
83
+ * mail and calls from separate sources almost never shares.
84
+ */
85
+ export declare const personHistory: (store: MessageStore, reference: string, { accounts, deniedKinds, since, until, limit }?: PersonHistoryOptions) => Promise<PersonHistory>;
@@ -1,6 +1,8 @@
1
+ import { CliError } from "@wirecat/cli-base";
1
2
  import { formatLocator } from "../domain/locator.js";
2
3
  import { kindIn } from "../domain/providers.js";
3
- import { keyOf, newestFirst } from "./business-context.js";
4
+ import { keyOf, newestFirst, scopeOf } from "./business-context.js";
5
+ import { excerpt } from "./excerpt.js";
4
6
  import { eventsOnce } from "./person-context.js";
5
7
  import { personMeetings } from "./person-meetings.js";
6
8
  /** Mail read per address when counting: past it the count says `hasMore`. */
@@ -8,6 +10,11 @@ const MAIL_ROWS = 500;
8
10
  const EVENT_ROWS = 1000;
9
11
  /** Recorded meetings and calls listed: past it the count still counts each, and the read says `hasMore`. */
10
12
  const RECORDED_ROWS = 100;
13
+ /** Characters of a message's text in a touch: enough to know what it was about. */
14
+ const TEXT = 200;
15
+ /** Items a person's history lists at once by default: what happened last. */
16
+ export const HISTORY_ITEMS = 10;
17
+ export const HISTORY_MAX = 200;
11
18
  /** The stored accounts that hold a calendar: what a person's events are read from. */
12
19
  export const calendarsOf = async (store, stored) => {
13
20
  const held = [];
@@ -112,6 +119,7 @@ export const communicationsOf = async (store, asked, scope, { since, until, limi
112
119
  ref: formatLocator({ ...key, chat: chat.id, message: message.id }),
113
120
  title: chat.title,
114
121
  at: message.timestamp,
122
+ text: message.text ? excerpt(message.text, "", TEXT) : null,
115
123
  }, person.uid);
116
124
  }
117
125
  }
@@ -141,7 +149,14 @@ export const communicationsOf = async (store, asked, scope, { since, until, limi
141
149
  for (const meeting of recorded.items) {
142
150
  read.add(keyOf(meeting.account));
143
151
  const event = meeting.event === null ? undefined : Number(meeting.event.slice("event:".length));
144
- if (event !== undefined && meetings.has(event)) {
152
+ const recording = {
153
+ text: meeting.snippet,
154
+ durationMs: meeting.durationMs,
155
+ ...(meeting.call ? { call: meeting.call } : {}),
156
+ };
157
+ const calendar = event === undefined ? undefined : meetings.get(event);
158
+ if (calendar) {
159
+ Object.assign(calendar, recording);
145
160
  held++;
146
161
  continue;
147
162
  }
@@ -151,6 +166,7 @@ export const communicationsOf = async (store, asked, scope, { since, until, limi
151
166
  title: meeting.title,
152
167
  at: meeting.startedAt,
153
168
  people: meeting.people,
169
+ ...recording,
154
170
  });
155
171
  }
156
172
  return {
@@ -160,3 +176,37 @@ export const communicationsOf = async (store, asked, scope, { since, until, limi
160
176
  coverage: coverageOf(people, read, calendars.length > 0),
161
177
  };
162
178
  };
179
+ /**
180
+ * What happened with one person lately, across every source in scope, newest first: the same reads a deal's and an
181
+ * organization's context make, for the identities linked to this one person. A page ends at `limit`; `next` is the
182
+ * `until` of the page before it. Items of one millisecond across a page's end may be cut, which a time of messages,
183
+ * mail and calls from separate sources almost never shares.
184
+ */
185
+ export const personHistory = async (store, reference, { accounts, deniedKinds, since, until, limit = HISTORY_ITEMS } = {}) => {
186
+ if (!Number.isSafeInteger(limit) || limit < 1 || limit > HISTORY_MAX)
187
+ throw new CliError("validation_error", `the history's limit takes 1–${HISTORY_MAX}`);
188
+ if (since !== undefined && until !== undefined && since > until)
189
+ throw new CliError("validation_error", "the start of the range is after its end");
190
+ const uid = /^person:(\d+)$/.exec(reference.trim())?.[1];
191
+ if (uid === undefined)
192
+ throw new CliError("validation_error", "a person is person:<id>");
193
+ const record = await store.people.personByUid(uid);
194
+ if (!record)
195
+ throw new CliError("not_found", `no person:${uid} in the store`);
196
+ const talks = await communicationsOf(store, [record], scopeOf(accounts, deniedKinds), {
197
+ ...(since === undefined ? {} : { since }),
198
+ ...(until === undefined ? {} : { until }),
199
+ // One past the page per chat: a dialog alone may hold the next page's first message.
200
+ limit: limit + 1,
201
+ });
202
+ const dated = talks.items.filter((item) => item.at !== null);
203
+ const items = dated.slice(0, limit);
204
+ const last = items.at(-1);
205
+ const hasMore = dated.length > limit;
206
+ return {
207
+ items,
208
+ hasMore,
209
+ next: hasMore && last?.at ? new Date(Date.parse(last.at) - 1).toISOString() : null,
210
+ coverage: talks.coverage,
211
+ };
212
+ };
@@ -1,5 +1,6 @@
1
1
  import { createHash } from "node:crypto";
2
2
  import { CliError } from "@wirecat/cli-base";
3
+ import { oneMoreFits } from "../../background/budget.js";
3
4
  import { inScope, within } from "../../documents/scope.js";
4
5
  // Without a query or pages the hash stays what it was, so a profile that never set them keeps its checkpoint. Turning
5
6
  // pages on changes it, so the next sync walks again and imports the pages an incremental one would never revisit.
@@ -17,6 +18,20 @@ const SAVE_EVERY_MS = 2000;
17
18
  const changesScope = (scope, cursor) => `${scope}:changes:${cursor}`;
18
19
  export const planDocuments = async (options, source, state, roots, limit, pictures, walks) => {
19
20
  const { isFolder, skipReason, retryable, maxEntries, errorOf, query, budget } = options;
21
+ const answers = new Map();
22
+ // Asked once per node, as every file below a folder asks about it again on its way up.
23
+ const cut = query?.mode === "exclude"
24
+ ? (file) => {
25
+ const known = answers.get(file.id);
26
+ if (known !== undefined)
27
+ return known;
28
+ const found = query.matches(file);
29
+ answers.set(file.id, found);
30
+ return found;
31
+ }
32
+ : undefined;
33
+ const scoped = cut && query ? { ...query, matches: cut } : query;
34
+ const excluded = (folder) => !roots.includes(folder.id) && cut?.(folder) === true;
20
35
  const scope = scopeHash(roots, query, options.isDocument !== undefined);
21
36
  if (!roots.length && query?.mode !== "include")
22
37
  return {
@@ -116,7 +131,7 @@ export const planDocuments = async (options, source, state, roots, limit, pictur
116
131
  }
117
132
  }
118
133
  const stack = entering
119
- .filter((folder) => within(folder, roots, folders))
134
+ .filter((folder) => !excluded(folder) && within(folder, roots, folders, new Set(), cut))
120
135
  .reverse()
121
136
  .map((folder) => ({ id: folder.id, ancestry: [], folder }));
122
137
  if (stack.length)
@@ -171,11 +186,15 @@ export const planDocuments = async (options, source, state, roots, limit, pictur
171
186
  }
172
187
  // One listing at least per call, so a folder with more children than the bound still moves on.
173
188
  // The run's own signal too: a cooperative sync is not cut from outside, and a CLI may pass no budget.
174
- stopped = options.signal?.aborted
189
+ // The time budget keeps a margin of 5 s or more, so a short run would never list a folder: its first listing
190
+ // goes ahead while one request still fits before the deadline itself.
191
+ const taken = options.signal?.aborted
175
192
  ? "cancelled"
176
193
  : listed > 0 && spent >= maxEntries
177
194
  ? "entries"
178
- : (budget?.take() ?? null);
195
+ : budget?.take();
196
+ const first = taken === "deadline" && listed === 0 && oneMoreFits(options.deadline, now());
197
+ stopped = first ? null : (taken ?? null);
179
198
  if (stopped)
180
199
  break;
181
200
  const folder = step.folder ?? (await source.metadata(step.id));
@@ -223,6 +242,8 @@ export const planDocuments = async (options, source, state, roots, limit, pictur
223
242
  for (const file of children)
224
243
  if (isFolder(file)) {
225
244
  container(file);
245
+ if (excluded(file))
246
+ continue;
226
247
  if (walked(file.id))
227
248
  folders[file.id] = file;
228
249
  else
@@ -278,7 +299,7 @@ export const planDocuments = async (options, source, state, roots, limit, pictur
278
299
  if (folders[root]?.trashed)
279
300
  skipped.push({ id: root, reason: "selected folder is unavailable" });
280
301
  for (const [id, file] of files) {
281
- if (!inScope(file, roots, folders, matched, query))
302
+ if (!inScope(file, roots, folders, matched, scoped))
282
303
  continue;
283
304
  const previousSkip = state.skipped.find((item) => item.id === id);
284
305
  const reason = skipReason(file);
@@ -302,11 +323,11 @@ export const planDocuments = async (options, source, state, roots, limit, pictur
302
323
  }
303
324
  for (const id of Object.keys(state.documents)) {
304
325
  const file = files.get(id);
305
- if (!file || !inScope(file, roots, folders, matched, query))
326
+ if (!file || !inScope(file, roots, folders, matched, scoped))
306
327
  jobs.push({ id, kind: "remove" });
307
328
  }
308
329
  // Only retain metadata for selected ancestry; the account-wide feed includes unrelated folders.
309
- const scopedFolders = Object.fromEntries(Object.entries(folders).filter(([, file]) => within(file, roots, folders) || roots.includes(file.id)));
330
+ const scopedFolders = Object.fromEntries(Object.entries(folders).filter(([, file]) => roots.includes(file.id) || (!excluded(file) && within(file, roots, folders, new Set(), cut))));
310
331
  return {
311
332
  pending: {
312
333
  scope,
@@ -1,6 +1,6 @@
1
1
  import { createHash } from "node:crypto";
2
2
  import { CliError, isCliError } from "@wirecat/cli-base";
3
- import { deadlineMargin } from "../../background/budget.js";
3
+ import { deadlineMargin, oneMoreFits } from "../../background/budget.js";
4
4
  import { catalogFiles } from "../../documents/catalog.js";
5
5
  import { inScope } from "../../documents/scope.js";
6
6
  import { changedSince, planDocuments, scopeHash } from "./plan.js";
@@ -148,6 +148,7 @@ export const syncDocuments = async (options) => {
148
148
  flush?.();
149
149
  };
150
150
  const jobs = [...pending.jobs].slice(0, max);
151
+ let read = 0;
151
152
  for (const job of jobs) {
152
153
  if (signal?.aborted)
153
154
  throw new CliError("cancelled", "sync was cancelled; pending operations are retained");
@@ -166,11 +167,14 @@ export const syncDocuments = async (options) => {
166
167
  else {
167
168
  if (!source)
168
169
  throw new CliError("configuration_error", "a pending save requires source sign-in");
169
- const stop = options.budget?.take();
170
+ const taken = options.budget?.take();
171
+ // The first read of a call goes ahead as the walk's first listing does, or a short run never saves one.
172
+ const stop = taken === "deadline" && read === 0 && oneMoreFits(options.deadline, now()) ? null : taken;
170
173
  if (stop) {
171
174
  result.stopped = stop;
172
175
  break;
173
176
  }
177
+ read++;
174
178
  const content = await source.content(job.id, limit);
175
179
  const listed = query?.mode === "include" && (pending.matched?.includes(job.id) ?? query.matches(content.metadata));
176
180
  if (!listed && !inScope(content.metadata, profile.roots, pending.folders, new Set(), query)) {
@@ -71,7 +71,8 @@ export { CATEGORIES, organizationCategories, SECTION_LIMIT } from "./business-co
71
71
  export { type CallStatsAnswer, type CallStatsRequest, readCallStats } from "./call-stats.js";
72
72
  export type { ChatsService, MarkedRead, PageWindow } from "./chats.js";
73
73
  export { chatsService, EVENTS_DAYS } from "./chats.js";
74
- export type { Communications, Touch } from "./communications.js";
74
+ export type { Communications, PersonHistory, PersonHistoryOptions, Touch } from "./communications.js";
75
+ export { HISTORY_ITEMS, HISTORY_MAX, personHistory } from "./communications.js";
75
76
  export type { BatchStatus, Built, ConversationsService, MessageLinks } from "./conversations.js";
76
77
  export { BATCH_SIZE, conversationsService } from "./conversations.js";
77
78
  export type { DealBrief, DealContext, DealContextOptions, DealTouch } from "./deal-context.js";
@@ -55,6 +55,7 @@ export { attachmentsService } from "./attachments.js";
55
55
  export { CATEGORIES, organizationCategories, SECTION_LIMIT } from "./business-context.js";
56
56
  export { readCallStats } from "./call-stats.js";
57
57
  export { chatsService, EVENTS_DAYS } from "./chats.js";
58
+ export { HISTORY_ITEMS, HISTORY_MAX, personHistory } from "./communications.js";
58
59
  export { BATCH_SIZE, conversationsService } from "./conversations.js";
59
60
  export { dealBrief, dealContext } from "./deal-context.js";
60
61
  export { accountStore, crossAccount, OFFLINE, onlineDeps, storedDeps, storeOnlyDeps } from "./deps.js";
@@ -15,6 +15,8 @@ export interface PersonMeeting {
15
15
  startedAt: string | null;
16
16
  durationMs: number | null;
17
17
  hasTranscript: boolean;
18
+ /** The start of the newest transcript, on one line: what the people said, never instructions. */
19
+ snippet: string | null;
18
20
  /** `event:<id>` of the calendar event it was held for, when the store knows it. */
19
21
  event: string | null;
20
22
  /** `person:<uid>` of each one asked about who took part. */
@@ -1,5 +1,9 @@
1
1
  import { formatMeetingReference, meetingCallItem } from "../meetings/index.js";
2
+ import { excerpt } from "./excerpt.js";
2
3
  const SCAN = 1000;
4
+ /** Enough of what was said to tell one call from another; `meetings transcript` reads the rest. */
5
+ const SNIPPET = 200;
6
+ const SNIPPET_ROWS = 6;
3
7
  /**
4
8
  * The newest recorded meetings of these people in `accounts`, each once, newest first, and how many there are;
5
9
  * `hasMore` when there are more than `limit`, or a person took part in more than `SCAN`. A meeting reaches
@@ -40,6 +44,16 @@ export const personMeetings = async (store, people, accounts, { limit = 10, sinc
40
44
  if (meeting === undefined || meeting.deletedAt !== null)
41
45
  continue;
42
46
  const transcripts = await store.meetings.transcripts({ accountId, meetingId, limit: 1 });
47
+ const [transcript] = transcripts.items;
48
+ const rows = transcript === undefined
49
+ ? []
50
+ : (await store.meetings.transcriptRows({
51
+ accountId,
52
+ meetingId,
53
+ transcriptId: transcript.id,
54
+ limit: SNIPPET_ROWS,
55
+ })).rows;
56
+ const said = rows.map(({ text }) => text).join(" ");
43
57
  const account = byId.get(accountId);
44
58
  const call = meetingCallItem(meeting);
45
59
  items.push({
@@ -49,7 +63,8 @@ export const personMeetings = async (store, people, accounts, { limit = 10, sinc
49
63
  title: meeting.title,
50
64
  startedAt: meeting.startedAt === null ? null : new Date(meeting.startedAt).toISOString(),
51
65
  durationMs: meeting.durationMs,
52
- hasTranscript: transcripts.items.length > 0,
66
+ hasTranscript: transcript !== undefined,
67
+ snippet: said.trim() ? excerpt(said, "", SNIPPET) : null,
53
68
  event: meeting.eventId === null ? null : `event:${meeting.eventId}`,
54
69
  people: who,
55
70
  ...(call ? { call } : {}),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wirecat/cli-core",
3
- "version": "0.678.0",
3
+ "version": "0.679.0",
4
4
  "description": "The messenger-neutral half of a messaging CLI: domain model, message locators, rendering, name resolution, the SQLite seam, the command skeleton and shared read commands, the send guard, run records and the message store",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Viacheslav Ptsarev",