@wirecat/cli-core 0.649.0 → 0.651.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.
Files changed (81) hide show
  1. package/CHANGELOG.md +117 -0
  2. package/dist/analysis/anthropic.js +2 -1
  3. package/dist/cli/account-remove.d.ts +2 -0
  4. package/dist/cli/account-remove.js +54 -13
  5. package/dist/cli/compact.d.ts +5 -0
  6. package/dist/cli/compact.js +7 -3
  7. package/dist/cli/doctor-reports-command.d.ts +11 -0
  8. package/dist/cli/doctor-reports-command.js +57 -5
  9. package/dist/cli/help/first-screen.js +5 -0
  10. package/dist/cli/messenger/messages-search-command.js +6 -1
  11. package/dist/cli/messenger/search-answers.d.ts +3 -1
  12. package/dist/cli/messenger/search-answers.js +3 -1
  13. package/dist/cli/program.js +3 -1
  14. package/dist/cli/schedule/schedule-command.js +9 -3
  15. package/dist/cli/steps.js +9 -0
  16. package/dist/cli/unknown-profile.d.ts +4 -3
  17. package/dist/cli/unknown-profile.js +14 -6
  18. package/dist/constants/index.d.ts +7 -0
  19. package/dist/constants/index.js +16 -0
  20. package/dist/crm/cli/index.js +30 -5
  21. package/dist/crm/source.d.ts +8 -1
  22. package/dist/crm/stage-tasks.d.ts +3 -1
  23. package/dist/crm/stage-tasks.js +8 -4
  24. package/dist/crm/sync.d.ts +1 -1
  25. package/dist/crm/sync.js +54 -0
  26. package/dist/domain/crm.d.ts +15 -0
  27. package/dist/domain/phones.d.ts +2 -0
  28. package/dist/domain/phones.js +3 -0
  29. package/dist/entities/contact-context.d.ts +6 -0
  30. package/dist/entities/contact-context.js +3 -0
  31. package/dist/entities/deal.d.ts +4 -0
  32. package/dist/entities/deal.js +3 -0
  33. package/dist/entities/index.d.ts +12 -0
  34. package/dist/entities/recorded-meeting.d.ts +17 -0
  35. package/dist/entities/recorded-meeting.js +15 -0
  36. package/dist/errors/reasons.js +9 -5
  37. package/dist/index.d.ts +1 -1
  38. package/dist/kit/own-catalogue.d.ts +1 -1
  39. package/dist/kit/own-catalogue.js +3 -3
  40. package/dist/meetings/answers.d.ts +5 -0
  41. package/dist/meetings/answers.js +3 -0
  42. package/dist/meetings/index.d.ts +1 -1
  43. package/dist/meetings/participant-search.d.ts +5 -0
  44. package/dist/meetings/pull.js +21 -1
  45. package/dist/meetings/read-answers.d.ts +4 -0
  46. package/dist/meetings/read-answers.js +1 -0
  47. package/dist/meetings/source.d.ts +5 -0
  48. package/dist/meetings/store.d.ts +12 -1
  49. package/dist/models/ai.js +2 -2
  50. package/dist/models/endpoint.d.ts +7 -0
  51. package/dist/models/endpoint.js +44 -0
  52. package/dist/models/index.js +2 -2
  53. package/dist/oauth/keeper.js +1 -1
  54. package/dist/sends/guard.js +8 -6
  55. package/dist/services/communications.d.ts +2 -2
  56. package/dist/services/communications.js +24 -2
  57. package/dist/services/meeting-model.js +2 -1
  58. package/dist/services/person-context.d.ts +3 -0
  59. package/dist/services/person-context.js +9 -1
  60. package/dist/services/person-meetings.d.ts +36 -0
  61. package/dist/services/person-meetings.js +57 -0
  62. package/dist/speech/openai.js +5 -2
  63. package/dist/store/path.d.ts +2 -0
  64. package/dist/store/path.js +1 -1
  65. package/dist/store/sqlite/crm-settings.d.ts +5 -1
  66. package/dist/store/sqlite/crm-settings.js +8 -0
  67. package/dist/store/sqlite/crm-stage-entries.d.ts +15 -0
  68. package/dist/store/sqlite/crm-stage-entries.js +74 -0
  69. package/dist/store/sqlite/crm.d.ts +8 -1
  70. package/dist/store/sqlite/crm.js +7 -1
  71. package/dist/store/sqlite/identities.js +3 -1
  72. package/dist/store/sqlite/involvements.d.ts +2 -0
  73. package/dist/store/sqlite/involvements.js +4 -1
  74. package/dist/store/sqlite/meeting-participant-search.js +9 -3
  75. package/dist/store/sqlite/meeting-projects.js +3 -3
  76. package/dist/store/sqlite/meetings.js +16 -2
  77. package/dist/store/sqlite/person-match-scan.d.ts +5 -0
  78. package/dist/store/sqlite/person-match-scan.js +60 -15
  79. package/dist/update/index.d.ts +1 -1
  80. package/dist/update/index.js +4 -2
  81. package/package.json +2 -2
@@ -75,3 +75,19 @@ export const microsoftApp = (options) => {
75
75
  export const oauthClientReport = (app, reason) => app?.source
76
76
  ? { client: app.source === "constants" ? "wirecat" : "own", source: app.source }
77
77
  : { client: null, source: null, ...(reason ? { reason } : {}) };
78
+ /**
79
+ * The hosts cli-core itself reaches in any tool: the default model providers, then cli-base's `SHARED_HOSTS` (npm for
80
+ * `upgrade`, the model downloads and the hosts they redirect to), which `cli-dev manifest` adds to every CLI's hosts.
81
+ * Typed out, not imported, so a CLI on an older cli-base still loads this module; a test keeps the two equal. A model
82
+ * endpoint or calendar feed the person configures belongs in `userHosts`.
83
+ */
84
+ export const CORE_HOSTS = [
85
+ "api.openai.com",
86
+ "api.anthropic.com",
87
+ "registry.npmjs.org",
88
+ "huggingface.co",
89
+ "*.huggingface.co",
90
+ "*.hf.co",
91
+ "github.com",
92
+ "*.githubusercontent.com",
93
+ ];
@@ -15,6 +15,8 @@ import { CRM_KINDS } from "../../domain/crm.js";
15
15
  import { DEAL_KINDS, DEAL_STATUSES } from "../../domain/deals.js";
16
16
  import { deal as dealEntity } from "../../entities/deal.js";
17
17
  import { count, text } from "../../entities/fields.js";
18
+ import { readableAccounts } from "../../services/person-context.js";
19
+ import { personMeetings } from "../../services/person-meetings.js";
18
20
  import { CRM_SCOPES, crmSettingKey } from "../../store/sqlite/crm-settings.js";
19
21
  import { openStageTasks } from "../stage-tasks.js";
20
22
  import { crmStatus, syncCrm } from "../sync.js";
@@ -63,6 +65,8 @@ const DEAL_UNTRUSTED = [
63
65
  ];
64
66
  /** `show` lists this many of a deal's activities: the open ones come first, so a long history does not hide them. */
65
67
  const SHOWN_ACTIVITIES = 20;
68
+ /** The newest recorded meetings and calls of the people on a deal or lead that `show` lists. */
69
+ const SHOWN_MEETINGS = 10;
66
70
  const PIPELINE_UNTRUSTED = ["name", "stages.name"];
67
71
  const STAGE_UNTRUSTED = ["name", "pipeline_name"];
68
72
  const crmContactsRemoved = v.strictObject({
@@ -201,13 +205,16 @@ const addCrmCommandsDefinition = (program, options) => {
201
205
  .action(async (opts, command) => {
202
206
  const { signal } = environmentOf(command);
203
207
  await within(command, async (run) => {
204
- const report = await syncCrm(run.source(), run.store, run.account, {
208
+ const source = run.source();
209
+ const report = await syncCrm(source, run.store, run.account, {
205
210
  now: now(),
206
211
  budget: runBudgetOf(command, opts.maxPages),
207
212
  ...(signal ? { signal } : {}),
208
213
  ...(opts.rescan ? { rescan: true } : {}),
209
214
  });
210
- const stageTasks = await openStageTasks(run.store, run.account, now());
215
+ const stageTasks = await openStageTasks(run.store, run.account, now(), {
216
+ history: source.stageHistory !== undefined,
217
+ });
211
218
  const failed = report.synced.filter((one) => one.error !== undefined);
212
219
  // A kind that failed on a setting fails the same way again until the owner changes it: no retry is offered.
213
220
  const retried = failed.filter((one) => one.setting === undefined);
@@ -327,8 +334,9 @@ const addCrmCommandsDefinition = (program, options) => {
327
334
  });
328
335
  });
329
336
  example(annotate(group.command("show"), { effects: LOCAL_READ, output: { entity: kind } })
330
- .description(`one ${kind} with its pipeline, stage, status, amount and the people on it; with the activities setting ` +
331
- "on, its activities and tasks too")
337
+ .description(`one ${kind} with its pipeline, stage, status, amount and the people on it, and the newest recorded ` +
338
+ "meetings and calls of those people in this account's scope; with the activities setting on, its " +
339
+ "activities and tasks too")
332
340
  .argument(`<${kind}>`, `${kind}:<id>, as a list shows it`), `${plural} show ${kind}:12`).action(async (reference, _opts, command) => {
333
341
  await within(command, async (run) => {
334
342
  const found = await ownCopy(run, kind, reference);
@@ -345,10 +353,27 @@ const addCrmCommandsDefinition = (program, options) => {
345
353
  updated_at: new Date(one.updatedAt).toISOString(),
346
354
  }))
347
355
  : undefined;
356
+ const recorded = await personMeetings(run.store, found.people.filter(({ owner }) => !owner).map(({ ref }) => ref.slice("person:".length)), await readableAccounts(run.store, run.account), { limit: SHOWN_MEETINGS });
357
+ const meetings = recorded.items.map((one) => ({
358
+ ref: one.ref,
359
+ meeting_id: one.meetingId,
360
+ account: one.account,
361
+ title: one.title,
362
+ started_at: one.startedAt,
363
+ duration_ms: one.durationMs,
364
+ has_transcript: one.hasTranscript,
365
+ event: one.event,
366
+ people: one.people,
367
+ }));
348
368
  return itemOf({
349
369
  ...dealKeys(found),
370
+ meetings,
350
371
  ...(activities ? { activities } : {}),
351
- untrusted: activities ? [...DEAL_UNTRUSTED, "activities.subject", "activities.body"] : DEAL_UNTRUSTED,
372
+ untrusted: [
373
+ ...DEAL_UNTRUSTED,
374
+ "meetings.title",
375
+ ...(activities ? ["activities.subject", "activities.body"] : []),
376
+ ],
352
377
  });
353
378
  });
354
379
  });
@@ -1,4 +1,4 @@
1
- import type { CrmActivity, CrmDepartment, CrmField, CrmKind, CrmPipeline, CrmRecords, CrmScope, CrmUser } from "../domain/crm.js";
1
+ import type { CrmActivity, CrmDepartment, CrmField, CrmKind, CrmPipeline, CrmRecords, CrmScope, CrmStageEntry, CrmUser } from "../domain/crm.js";
2
2
  import type { DealKind } from "../domain/deals.js";
3
3
  export interface CrmSourceTraits {
4
4
  /** What this CRM has: one without leads leaves `lead` out. Contacts and companies come before the items on them. */
@@ -102,4 +102,11 @@ export interface CrmSource {
102
102
  * them leaves it out. A list the sign-in may not read is a `gap`, and the others are still read.
103
103
  */
104
104
  activities?(since: number, page?: string, context?: CrmCallContext): Promise<CrmPage<CrmActivity>>;
105
+ /**
106
+ * The kind's entries into a stage that the CRM's own history recorded, oldest first, a page at a time: after the
107
+ * entry `after` (its `externalId`), or from `since` (epoch ms) without it; the last page's `cursor` is the last entry
108
+ * read, or `after` when none came. With it, stage tasks open on each stage entered, one passed between two syncs too.
109
+ * Read only while the account has `stage-tasks` rules for the kind.
110
+ */
111
+ stageHistory?(kind: DealKind, since: number, after?: string, context?: CrmCallContext): Promise<CrmPage<CrmStageEntry>>;
105
112
  }
@@ -5,4 +5,6 @@ import type { AccountKey } from "../store/types.js";
5
5
  * one per entry, so a dismissed task never comes back and a later entry into the same stage opens a new one.
6
6
  * Answers how many it opened.
7
7
  */
8
- export declare const openStageTasks: (store: MessageStore, account: AccountKey, now: number) => Promise<number>;
8
+ export declare const openStageTasks: (store: MessageStore, account: AccountKey, now: number, { history }?: {
9
+ history?: boolean;
10
+ }) => Promise<number>;
@@ -6,11 +6,13 @@ const DAY = 86_400_000;
6
6
  * one per entry, so a dismissed task never comes back and a later entry into the same stage opens a new one.
7
7
  * Answers how many it opened.
8
8
  */
9
- export const openStageTasks = async (store, account, now) => {
9
+ export const openStageTasks = async (store, account, now, { history = false } = {}) => {
10
10
  const rules = await store.crm.stageTasks(account);
11
11
  if (Object.keys(rules.deal).length + Object.keys(rules.lead).length === 0)
12
12
  return 0;
13
- const { moves, through } = await store.crm.stageMoves(account);
13
+ const changes = await store.crm.stageMoves(account);
14
+ // A CRM with a stage history names every stage entered; the copy's own changes miss one passed between two syncs.
15
+ const moves = history ? await store.crm.stageEntries(account) : changes.moves;
14
16
  // Every deal entering a stage gets the same title, so the duplicate review would pair tasks of different deals.
15
17
  const { reviewDuplicates: _review, ...tasks } = store.tasks;
16
18
  const service = createTaskService({ store: tasks, now: () => new Date(now) });
@@ -23,7 +25,7 @@ export const openStageTasks = async (store, account, now) => {
23
25
  const responsible = item.people.find((one) => one.role === "owner")?.name ??
24
26
  (item.assignee === null ? "nobody" : `CRM user ${item.assignee.split("/").at(-1)}`);
25
27
  const { created } = await service.add({
26
- source: `${move.ref}/move/${move.id}`,
28
+ source: move.source,
27
29
  sourceKind: move.kind,
28
30
  account: taskAccount(account),
29
31
  group: move.ref,
@@ -37,6 +39,8 @@ export const openStageTasks = async (store, account, now) => {
37
39
  if (created)
38
40
  opened += 1;
39
41
  }
40
- await store.crm.markStageMoves(account, through);
42
+ if (history)
43
+ await store.crm.handleStageEntries(moves.map(({ id }) => id));
44
+ await store.crm.markStageMoves(account, changes.through);
41
45
  return opened;
42
46
  };
@@ -50,7 +50,7 @@ export interface CrmSyncOptions {
50
50
  export interface CrmSyncIssue {
51
51
  /** `user`: the account's users and departments. */
52
52
  kind: CrmKind | "user";
53
- reason: CrmSkipped["reason"] | CrmRelationIssue["reason"] | "crm.unlisted-held" | "crm.narrowing-held" | "crm.unassigned-dropped" | "crm.not-reported" | "crm.pending-dropped" | "crm.activities-failed";
53
+ reason: CrmSkipped["reason"] | CrmRelationIssue["reason"] | "crm.unlisted-held" | "crm.narrowing-held" | "crm.unassigned-dropped" | "crm.not-reported" | "crm.pending-dropped" | "crm.activities-failed" | "crm.stage-history-failed";
54
54
  message: string;
55
55
  externalId?: string;
56
56
  }
package/dist/crm/sync.js CHANGED
@@ -214,6 +214,45 @@ const readActivities = async (run) => {
214
214
  return null;
215
215
  }
216
216
  };
217
+ const STAGE_HISTORY = "crm:stage-history:";
218
+ /**
219
+ * The CRM's own stage history of each kind with `stage-tasks` rules, after the last entry read: the first read goes
220
+ * from when stage tasks were last opened, so no entry is missed and none before the rules counts. Without rules the
221
+ * history is not read, and its place is dropped, so rules set again later start from then.
222
+ */
223
+ const readStageHistory = async (run) => {
224
+ const { source, store, account } = run;
225
+ if (!source.stageHistory)
226
+ return null;
227
+ const rules = await store.crm.stageTasks(account);
228
+ const since = await store.crm.stageTasksSince(account);
229
+ for (const kind of DEAL_KINDS) {
230
+ const key = `${STAGE_HISTORY}${kind}`;
231
+ if (since === null || Object.keys(rules[kind]).length === 0) {
232
+ await store.sync.clearSyncState(account, key);
233
+ continue;
234
+ }
235
+ let after = (await store.sync.syncState(account, key))?.value;
236
+ for (;;) {
237
+ const why = run.budget.take();
238
+ if (why)
239
+ return why;
240
+ const page = await source.stageHistory.call(source, kind, since, after, run.context);
241
+ await store.crm.saveStageEntries(account, page.items);
242
+ run.moved();
243
+ const next = page.hasMore ? page.nextCursor : (page.cursor ?? after);
244
+ if (next !== undefined && next !== null) {
245
+ after = next;
246
+ await store.sync.setSyncState(account, key, next);
247
+ }
248
+ if (!page.hasMore || page.nextCursor === undefined)
249
+ break;
250
+ if (run.signal?.aborted)
251
+ return "cancelled";
252
+ }
253
+ }
254
+ return null;
255
+ };
217
256
  /** Runs a step whose source call may spend the budget mid-way: a spent budget is a stop, not a failure. */
218
257
  const stopping = async (step) => {
219
258
  try {
@@ -601,6 +640,21 @@ export const syncCrm = async (source, store, account, options = {}) => {
601
640
  });
602
641
  }
603
642
  }
643
+ if (!stopped && kinds.some(isItemKind)) {
644
+ try {
645
+ stopped = await stopping(() => readStageHistory(run));
646
+ }
647
+ catch (error) {
648
+ if (options.signal?.aborted)
649
+ stopped = "cancelled";
650
+ else
651
+ report.issues.push({
652
+ kind: "deal",
653
+ reason: "crm.stage-history-failed",
654
+ message: isCliFailure(error) ? error.message : "the stage history could not be read",
655
+ });
656
+ }
657
+ }
604
658
  const narrowed = report.synced.some((one) => one.outOfScope > 0);
605
659
  const whole = report.synced.every((one) => one.state === "complete" && one.error === undefined && !one.held && one.pass !== "held");
606
660
  // Contacts have no scope of their own and no deletion check: they leave with the last deal or lead naming them.
@@ -206,3 +206,18 @@ export declare const isCrmUserId: (id: string) => boolean;
206
206
  /** One spelling per user id, so `015`, ` 15` and `15` are one user wherever they come from. */
207
207
  export declare const normalCrmUserId: (id: string) => string;
208
208
  export declare const isItemKind: (kind: CrmKind) => kind is DealKind;
209
+ /**
210
+ * One entry of a deal or lead into a stage, as the CRM's own history recorded it: also a stage passed between two
211
+ * syncs, which the copy never stood in. A row's first stage is no entry.
212
+ */
213
+ export interface CrmStageEntry {
214
+ /** The history row's id in the CRM, ascending within a kind: the next read goes on after the last one. */
215
+ externalId: string;
216
+ kind: DealKind;
217
+ /** The deal's or lead's own id. */
218
+ item: string;
219
+ pipeline: string;
220
+ stage: string;
221
+ /** When it entered the stage, epoch ms. */
222
+ at: number;
223
+ }
@@ -38,6 +38,8 @@ export declare const typedPhone: (typed: string, { phoneCountries }?: PhoneOptio
38
38
  * `phone_countries` setting reads `4155550100` as Russian, so it never decides an identifier.
39
39
  */
40
40
  export declare const e164Of: (phone: string, region: string | undefined) => string | null | undefined;
41
+ /** An E.164 number that some country's plan reads as a mobile: a person's own line, not an office's. */
42
+ export declare const isMobilePhone: (e164: string) => boolean;
41
43
  /** The messengers that keep a contact's number as bare international digits, the `+` left off. */
42
44
  export declare const BARE_INTERNATIONAL_PROVIDERS: readonly string[];
43
45
  /**
@@ -83,6 +83,9 @@ export const e164Of = (phone, region) => {
83
83
  const digits = phone.replace(/\(0\)/, "").replace(/\D/g, "");
84
84
  return nationalPhone(digits, [region], { anyType: true })?.value;
85
85
  };
86
+ /** An E.164 number that some country's plan reads as a mobile: a person's own line, not an office's. */
87
+ export const isMobilePhone = (e164) => /^\+\d+$/.test(e164) &&
88
+ PHONE_COUNTRIES.some((country) => nationalPhone(e164.slice(1), [country], { anyType: false })?.value === e164);
86
89
  /** The messengers that keep a contact's number as bare international digits, the `+` left off. */
87
90
  export const BARE_INTERNATIONAL_PROVIDERS = ["telegram", "max", "whatsapp"];
88
91
  /**
@@ -166,6 +166,8 @@ declare const context: v.StrictObjectSchema<{
166
166
  readonly status: v.NullableSchema<v.StringSchema<undefined>, undefined>;
167
167
  }, undefined>, undefined>;
168
168
  }, undefined>, undefined>;
169
+ /** Recorded meetings and calls they took part in, newest first. */
170
+ readonly meetings: v.OptionalSchema<v.ArraySchema<v.GenericSchema<import("./recorded-meeting.js").RecordedMeeting>, undefined>, undefined>;
169
171
  readonly limits: v.StrictObjectSchema<{
170
172
  readonly messages: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
171
173
  readonly bytes: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
@@ -961,6 +963,8 @@ export declare const contactContext: v.UnionSchema<[v.StrictObjectSchema<{
961
963
  readonly status: v.NullableSchema<v.StringSchema<undefined>, undefined>;
962
964
  }, undefined>, undefined>;
963
965
  }, undefined>, undefined>;
966
+ /** Recorded meetings and calls they took part in, newest first. */
967
+ readonly meetings: v.OptionalSchema<v.ArraySchema<v.GenericSchema<import("./recorded-meeting.js").RecordedMeeting>, undefined>, undefined>;
964
968
  readonly limits: v.StrictObjectSchema<{
965
969
  readonly messages: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
966
970
  readonly bytes: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
@@ -1767,6 +1771,8 @@ export declare const contactPreparation: v.StrictObjectSchema<{
1767
1771
  readonly status: v.NullableSchema<v.StringSchema<undefined>, undefined>;
1768
1772
  }, undefined>, undefined>;
1769
1773
  }, undefined>, undefined>;
1774
+ /** Recorded meetings and calls they took part in, newest first. */
1775
+ readonly meetings: v.OptionalSchema<v.ArraySchema<v.GenericSchema<import("./recorded-meeting.js").RecordedMeeting>, undefined>, undefined>;
1770
1776
  readonly limits: v.StrictObjectSchema<{
1771
1777
  readonly messages: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
1772
1778
  readonly bytes: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
@@ -3,6 +3,7 @@ import { chat } from "./chat.js";
3
3
  import { linkedPerson } from "./contact-activity.js";
4
4
  import { count, id, reference, text, time } from "./fields.js";
5
5
  import { message } from "./message.js";
6
+ import { recordedMeeting } from "./recorded-meeting.js";
6
7
  const contextPerson = v.strictObject({ ...linkedPerson.entries, provider: text, id });
7
8
  export const contextMessage = v.strictObject({
8
9
  locator: reference,
@@ -48,6 +49,8 @@ const context = v.strictObject({
48
49
  mentions: v.array(contextMessage),
49
50
  /** Calendar events they are invited to, one occurrence per series. */
50
51
  events: v.optional(v.strictObject({ upcoming: v.array(contextEvent), recent: v.array(contextEvent) })),
52
+ /** Recorded meetings and calls they took part in, newest first. */
53
+ meetings: v.optional(v.array(recordedMeeting)),
51
54
  limits: v.strictObject({ messages: count, bytes: count }),
52
55
  complete: v.boolean(),
53
56
  not_read: v.array(v.strictObject({
@@ -84,6 +84,8 @@ export declare const deal: v.StrictObjectSchema<{
84
84
  readonly updated_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`">]>;
85
85
  /** `show` of a CRM copy whose `activities` setting is on: its activities and tasks, open ones first. */
86
86
  readonly activities: v.OptionalSchema<v.ArraySchema<v.GenericSchema<DealActivity>, undefined>, undefined>;
87
+ /** `show` of a CRM copy: the newest recorded meetings and calls of its people, in its account's scope. */
88
+ readonly meetings: v.OptionalSchema<v.ArraySchema<v.GenericSchema<import("./recorded-meeting.js").RecordedMeeting>, undefined>, undefined>;
87
89
  readonly untrusted: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
88
90
  }, undefined>;
89
91
  /** A lead (`lead:<id>`): a deal's shape, in a lead pipeline. */
@@ -155,6 +157,8 @@ export declare const lead: v.StrictObjectSchema<{
155
157
  readonly updated_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`">]>;
156
158
  /** `show` of a CRM copy whose `activities` setting is on: its activities and tasks, open ones first. */
157
159
  readonly activities: v.OptionalSchema<v.ArraySchema<v.GenericSchema<DealActivity>, undefined>, undefined>;
160
+ /** `show` of a CRM copy: the newest recorded meetings and calls of its people, in its account's scope. */
161
+ readonly meetings: v.OptionalSchema<v.ArraySchema<v.GenericSchema<import("./recorded-meeting.js").RecordedMeeting>, undefined>, undefined>;
158
162
  readonly untrusted: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
159
163
  }, undefined>;
160
164
  /** A pipeline (`pipeline:<id>`) with its stages in order; `pipelines show` adds the funnel. */
@@ -2,6 +2,7 @@ import * as v from "valibot";
2
2
  import { CRM_ACTIVITY_KINDS } from "../domain/crm.js";
3
3
  import { DEAL_ROLES } from "../domain/deals.js";
4
4
  import { count, id, reference, text, time, untrusted } from "./fields.js";
5
+ import { recordedMeeting } from "./recorded-meeting.js";
5
6
  const nullableText = v.nullable(text);
6
7
  const party = v.strictObject({ ref: reference, name: nullableText, owner: v.boolean() });
7
8
  const outcome = v.picklist(["open", "won", "lost"]);
@@ -77,6 +78,8 @@ export const deal = v.strictObject({
77
78
  updated_at: time,
78
79
  /** `show` of a CRM copy whose `activities` setting is on: its activities and tasks, open ones first. */
79
80
  activities: v.optional(v.array(activity)),
81
+ /** `show` of a CRM copy: the newest recorded meetings and calls of its people, in its account's scope. */
82
+ meetings: v.optional(v.array(recordedMeeting)),
80
83
  untrusted,
81
84
  });
82
85
  /** A lead (`lead:<id>`): a deal's shape, in a lead pipeline. */
@@ -297,6 +297,7 @@ export declare const ENTITIES: {
297
297
  readonly created_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`">]>;
298
298
  readonly updated_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`">]>;
299
299
  readonly activities: v.OptionalSchema<v.ArraySchema<v.GenericSchema<import("./deal.js").DealActivity>, undefined>, undefined>;
300
+ readonly meetings: v.OptionalSchema<v.ArraySchema<v.GenericSchema<import("./recorded-meeting.js").RecordedMeeting>, undefined>, undefined>;
300
301
  readonly untrusted: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
301
302
  }, undefined>;
302
303
  readonly lead: v.StrictObjectSchema<{
@@ -359,6 +360,7 @@ export declare const ENTITIES: {
359
360
  readonly created_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`">]>;
360
361
  readonly updated_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`">]>;
361
362
  readonly activities: v.OptionalSchema<v.ArraySchema<v.GenericSchema<import("./deal.js").DealActivity>, undefined>, undefined>;
363
+ readonly meetings: v.OptionalSchema<v.ArraySchema<v.GenericSchema<import("./recorded-meeting.js").RecordedMeeting>, undefined>, undefined>;
362
364
  readonly untrusted: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
363
365
  }, undefined>;
364
366
  readonly pipeline: v.StrictObjectSchema<{
@@ -2856,6 +2858,7 @@ export declare const ENTITIES: {
2856
2858
  readonly status: v.NullableSchema<v.StringSchema<undefined>, undefined>;
2857
2859
  }, undefined>, undefined>;
2858
2860
  }, undefined>, undefined>;
2861
+ readonly meetings: v.OptionalSchema<v.ArraySchema<v.GenericSchema<import("./recorded-meeting.js").RecordedMeeting>, undefined>, undefined>;
2859
2862
  readonly limits: v.StrictObjectSchema<{
2860
2863
  readonly messages: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
2861
2864
  readonly bytes: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
@@ -3647,6 +3650,7 @@ export declare const ENTITIES: {
3647
3650
  readonly status: v.NullableSchema<v.StringSchema<undefined>, undefined>;
3648
3651
  }, undefined>, undefined>;
3649
3652
  }, undefined>, undefined>;
3653
+ readonly meetings: v.OptionalSchema<v.ArraySchema<v.GenericSchema<import("./recorded-meeting.js").RecordedMeeting>, undefined>, undefined>;
3650
3654
  readonly limits: v.StrictObjectSchema<{
3651
3655
  readonly messages: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
3652
3656
  readonly bytes: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
@@ -5450,6 +5454,10 @@ export declare const ENTITIES: {
5450
5454
  readonly name: v.NullableSchema<v.StringSchema<undefined>, undefined>;
5451
5455
  readonly email: v.NullableSchema<v.StringSchema<undefined>, undefined>;
5452
5456
  readonly role: v.NullableSchema<v.StringSchema<undefined>, undefined>;
5457
+ readonly person: v.NullableSchema<v.StrictObjectSchema<{
5458
+ readonly ref: v.StringSchema<undefined>;
5459
+ readonly name: v.NullableSchema<v.StringSchema<undefined>, undefined>;
5460
+ }, undefined>, undefined>;
5453
5461
  readonly joined_at: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, "an ISO 8601 time in UTC">, v.EndsWithAction<string, "Z", "an ISO 8601 time in UTC, ending in `Z`">]>, undefined>;
5454
5462
  readonly left_at: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, "an ISO 8601 time in UTC">, v.EndsWithAction<string, "Z", "an ISO 8601 time in UTC, ending in `Z`">]>, undefined>;
5455
5463
  readonly duration_ms: v.NullableSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
@@ -6646,6 +6654,10 @@ export declare const ENTITIES: {
6646
6654
  readonly identity_id: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 1, undefined>]>;
6647
6655
  readonly display_name: v.NullableSchema<v.StringSchema<undefined>, undefined>;
6648
6656
  readonly email: v.NullableSchema<v.StringSchema<undefined>, undefined>;
6657
+ readonly person: v.NullableSchema<v.StrictObjectSchema<{
6658
+ readonly ref: v.StringSchema<undefined>;
6659
+ readonly name: v.NullableSchema<v.StringSchema<undefined>, undefined>;
6660
+ }, undefined>, undefined>;
6649
6661
  }, undefined>, undefined>;
6650
6662
  readonly ambiguity: v.StrictObjectSchema<{
6651
6663
  readonly scope: v.LiteralSchema<"page", undefined>;
@@ -0,0 +1,17 @@
1
+ import * as v from "valibot";
2
+ export interface RecordedMeeting {
3
+ ref: string;
4
+ meeting_id: number;
5
+ account: {
6
+ provider: string;
7
+ account: string;
8
+ };
9
+ title: string | null;
10
+ started_at: string | null;
11
+ duration_ms: number | null;
12
+ has_transcript: boolean;
13
+ event: string | null;
14
+ people: string[];
15
+ }
16
+ /** A recorded meeting or call some of the people took part in: `meetings show <meeting_id>` of `account` opens it. */
17
+ export declare const recordedMeeting: v.GenericSchema<RecordedMeeting>;
@@ -0,0 +1,15 @@
1
+ import * as v from "valibot";
2
+ import { count, reference, text, time } from "./fields.js";
3
+ // Typed by name, as a deal's activity is: inferred, the entity maps that hold it grow too long for the compiler.
4
+ /** A recorded meeting or call some of the people took part in: `meetings show <meeting_id>` of `account` opens it. */
5
+ export const recordedMeeting = v.strictObject({
6
+ ref: reference,
7
+ meeting_id: count,
8
+ account: v.strictObject({ provider: text, account: text }),
9
+ title: v.nullable(text),
10
+ started_at: v.nullable(time),
11
+ duration_ms: v.nullable(count),
12
+ has_transcript: v.boolean(),
13
+ event: v.nullable(reference),
14
+ people: v.array(reference),
15
+ });
@@ -23,8 +23,7 @@ const SIGN_IN = [
23
23
  ["oauth.declined", "authentication_error", "the provider's consent was declined"],
24
24
  ["oauth.timeout", "timeout", "the sign-in was not finished in time"],
25
25
  ["oauth.mismatch", "authentication_error", "the pasted sign-in result belongs to another sign-in"],
26
- ["oauth.missing", "authentication_error", "this profile is not signed in to the provider"],
27
- ["session.missing", "authentication_error", "this profile has no API token saved"],
26
+ ["session.missing", "authentication_error", "this profile is not signed in: no saved sign-in or API token"],
28
27
  ["oauth.locked", "provider_unavailable", "another process holds this sign-in's lock"],
29
28
  ["oauth.no-response", "outcome_unknown", "the token request did not finish"],
30
29
  ["oauth.unavailable", "provider_unavailable", "the provider's token endpoint is unavailable"],
@@ -87,7 +86,12 @@ const OTHERS = [
87
86
  "invalid_response",
88
87
  "the model answered nothing; given a picture, it may not read pictures — choose a vision model",
89
88
  ],
90
- validation("model.address-refused", "the model address must be https, or http only on this computer"),
89
+ validation("model.address-refused", "the model address is refused: https, or plain http and Ollama only on this computer"),
90
+ [
91
+ "network.host-undeclared",
92
+ "configuration_error",
93
+ "the request went to a host the CLI does not declare, or not the model address's own; nothing was sent",
94
+ ],
91
95
  [
92
96
  "local-only.refused",
93
97
  "permission_error",
@@ -109,7 +113,6 @@ const OTHERS = [
109
113
  "only the owner chooses, unsets, checks or removes the AI model and its key, or revokes its consent",
110
114
  ],
111
115
  ["ai.setting-invalid", "configuration_error", "the ai section or the model given is not one WireCat can use"],
112
- validation("ai.address-refused", "the AI model setting names an address WireCat refuses: plain http to another computer, or Ollama off this computer"),
113
116
  ["ai.not-set", "configuration_error", "no AI model is chosen; models ai set chooses one"],
114
117
  ["ai.key-missing", "configuration_error", "no API key is stored for the AI model's address"],
115
118
  ["ai.ok", "invalid_response", "models ai check: the model answered (a result, never raised)"],
@@ -302,7 +305,7 @@ const OTHERS = [
302
305
  validation("input.empty", "a hidden prompt got an empty answer three times"),
303
306
  validation("input.required", "the command needs an answer and cannot ask for one"),
304
307
  validation("input.too-large", "the input is over its size limit"),
305
- ["meeting-project.stale", "configuration_error", "the meeting's project changed meanwhile"],
308
+ ["meeting-project.stale", "conflict", "the meeting's project changed meanwhile"],
306
309
  validation("fact.not-accepted", "only an accepted fact can be revoked"),
307
310
  validation("fact.owner-written", "the owner wrote this fact; it was never proposed, so it cannot be revoked"),
308
311
  validation("fact.payment-retired", "a payment is a payments row in store.finance, not a fact"),
@@ -392,6 +395,7 @@ const OTHERS = [
392
395
  validation("crm.reference-unknown", "a CRM row names a contact, company or user the store does not hold; that link was not made"),
393
396
  validation("crm.pending-dropped", "relationships waited too long for an end that never came; they were dropped"),
394
397
  validation("crm.activities-failed", "the activities and tasks could not be read; the deals and leads were synced"),
398
+ validation("crm.stage-history-failed", "the CRM's stage history could not be read; stage tasks wait for the next sync"),
395
399
  validation("crm.email-ambiguous", "a CRM contact's email belongs to more than one person; the owner decides"),
396
400
  validation("crm.own-unknown", "no own company of the CRM account is stored, so its users are no one's employees yet"),
397
401
  validation("relationship.reference-unknown", "a reported relationship names something the store does not hold"),
package/dist/index.d.ts CHANGED
@@ -3,7 +3,7 @@ export { CATALOG_KINDS, type CatalogKind, CONTRACT_KINDS, CONTRACT_STATUSES, typ
3
3
  export { bareCheck, type CheckWords, checkWords } from "./domain/checks.js";
4
4
  export type { CounterField, CounterObservation, CounterObservations, CounterState } from "./domain/counters.js";
5
5
  export { COUNTER_FIELDS, counterValue, observedCounters } from "./domain/counters.js";
6
- export { CRM_ACTIVITY_KINDS, CRM_KINDS, type CrmActivity, type CrmActivityKind, type CrmDepartment, type CrmField, type CrmItem, type CrmKind, type CrmOrganization, type CrmPerson, type CrmPipeline, type CrmRecords, type CrmScope, type CrmScopeSetting, type CrmStage, type CrmUser, type CrmValue, isCrmUserId, isItemKind, normalCrmUserId, } from "./domain/crm.js";
6
+ export { CRM_ACTIVITY_KINDS, CRM_KINDS, type CrmActivity, type CrmActivityKind, type CrmDepartment, type CrmField, type CrmItem, type CrmKind, type CrmOrganization, type CrmPerson, type CrmPipeline, type CrmRecords, type CrmScope, type CrmScopeSetting, type CrmStage, type CrmStageEntry, type CrmUser, type CrmValue, isCrmUserId, isItemKind, normalCrmUserId, } from "./domain/crm.js";
7
7
  export { DEAL_KINDS, DEAL_ROLES, DEAL_STATUSES, type DealKind, type DealRole, type DealStatus, STAGE_OUTCOMES, type StageOutcome, } from "./domain/deals.js";
8
8
  export { displayName, type NameFallbacks, nameKey } from "./domain/display-names.js";
9
9
  export { FINANCE_REVIEWS, type FinanceReview, INVOICE_DIRECTIONS, INVOICE_STATUSES, type InvoiceDirection, type InvoiceStatus, MONEY_DIRECTIONS, type MoneyDirection, } from "./domain/finance.js";
@@ -2,6 +2,6 @@ import type { Command } from "commander";
2
2
  import { type CatalogueOptions } from "../mcp/agent.js";
3
3
  /**
4
4
  * The MCP catalogue of a CLI's own commands, by path, as `read` or `write`: what cli-core mounted is left out, since
5
- * cli-core pins it. A CLI's contract test pins this and the few shared commands it changes on purpose.
5
+ * cli-core pins it. A generated command (a Bot API method) is the CLI's own, as `commands --json` marks it. A CLI's contract test pins this and the few shared commands it changes on purpose.
6
6
  */
7
7
  export declare const ownCatalogue: (program: Command, options?: CatalogueOptions) => Record<string, "read" | "write">;
@@ -1,9 +1,9 @@
1
- import { describeProgram, hasSharedContract } from "@wirecat/cli-base/commands";
1
+ import { describeProgram, hasSharedContract, metaOf } from "@wirecat/cli-base/commands";
2
2
  import { toolsFromCommands } from "../mcp/agent.js";
3
3
  const sharedPaths = (command, parents = [], into = new Set()) => {
4
4
  for (const child of command.commands) {
5
5
  const path = [...parents, child.name()];
6
- if (hasSharedContract(child))
6
+ if (hasSharedContract(child) && metaOf(child).origin !== "generated")
7
7
  into.add(path.join(" "));
8
8
  sharedPaths(child, path, into);
9
9
  }
@@ -11,7 +11,7 @@ const sharedPaths = (command, parents = [], into = new Set()) => {
11
11
  };
12
12
  /**
13
13
  * The MCP catalogue of a CLI's own commands, by path, as `read` or `write`: what cli-core mounted is left out, since
14
- * cli-core pins it. A CLI's contract test pins this and the few shared commands it changes on purpose.
14
+ * cli-core pins it. A generated command (a Bot API method) is the CLI's own, as `commands --json` marks it. A CLI's contract test pins this and the few shared commands it changes on purpose.
15
15
  */
16
16
  export const ownCatalogue = (program, options = {}) => {
17
17
  const shared = sharedPaths(program);
@@ -95,6 +95,11 @@ export declare const meetingDetails: v.StrictObjectSchema<{
95
95
  readonly name: v.NullableSchema<v.StringSchema<undefined>, undefined>;
96
96
  readonly email: v.NullableSchema<v.StringSchema<undefined>, undefined>;
97
97
  readonly role: v.NullableSchema<v.StringSchema<undefined>, undefined>;
98
+ /** Who they are across the owner's sources: `person:<uid>`, and that person's name once linked. */
99
+ readonly person: v.NullableSchema<v.StrictObjectSchema<{
100
+ readonly ref: v.StringSchema<undefined>;
101
+ readonly name: v.NullableSchema<v.StringSchema<undefined>, undefined>;
102
+ }, undefined>, undefined>;
98
103
  readonly joined_at: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, "an ISO 8601 time in UTC">, v.EndsWithAction<string, "Z", "an ISO 8601 time in UTC, ending in `Z`">]>, undefined>;
99
104
  readonly left_at: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, "an ISO 8601 time in UTC">, v.EndsWithAction<string, "Z", "an ISO 8601 time in UTC, ending in `Z`">]>, undefined>;
100
105
  readonly duration_ms: v.NullableSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
@@ -76,6 +76,8 @@ export const meetingDetails = v.strictObject({
76
76
  name: v.nullable(text),
77
77
  email: v.nullable(text),
78
78
  role: v.nullable(text),
79
+ /** Who they are across the owner's sources: `person:<uid>`, and that person's name once linked. */
80
+ person: v.nullable(v.strictObject({ ref: text, name: v.nullable(text) })),
79
81
  joined_at: v.nullable(isoTime),
80
82
  left_at: v.nullable(isoTime),
81
83
  duration_ms: v.nullable(count),
@@ -137,6 +139,7 @@ export const meetingDetailsItem = (details, owner) => {
137
139
  name: one.displayName,
138
140
  email: one.email,
139
141
  role: one.role,
142
+ person: one.person ? { ref: `person:${one.person.uid}`, name: one.person.name } : null,
140
143
  joined_at: iso(one.joinedAt),
141
144
  left_at: iso(one.leftAt),
142
145
  duration_ms: one.durationMs,
@@ -52,7 +52,7 @@ export type { MeetingSeriesCandidate, MeetingSeriesInventoryPage, MeetingSeriesI
52
52
  export { validateMeetingSeriesInventoryCursor } from "./series-inventory-validation.js";
53
53
  export type { MeetingSource, SourceParticipant } from "./source.js";
54
54
  export { aggregateMeetingCounts, aggregateMeetingStats, MEETING_COUNTS_GROUPINGS, type MeetingCounts, type MeetingCountsGrouping, type MeetingCountsInput, type MeetingCountsMeeting, type MeetingCountsRow, type MeetingSpeakerStats, type MeetingStats, type MeetingStatsInput, type MeetingStatsRow, type MeetingStatsSelection, type MeetingStatsStore, type MeetingWeekStats, NO_SERIES, } from "./stats.js";
55
- export type { ChatInput, ContractCase, EventCandidateFilter, IdentityInput, MeetingDetails, MeetingFilter, MeetingHitSource, MeetingInput, MeetingSave, MeetingStore, NewRecord, ParticipantInput, SearchHit, TranscriptInput, TranscriptLanguageFill, TranscriptRowInput, } from "./store.js";
55
+ export type { ChatInput, ContractCase, EventCandidateFilter, IdentityInput, MeetingDetails, MeetingFilter, MeetingHitSource, MeetingInput, MeetingParticipant, MeetingSave, MeetingStore, NewRecord, ParticipantInput, SearchHit, TranscriptInput, TranscriptLanguageFill, TranscriptRowInput, } from "./store.js";
56
56
  export { READ_BUDGET_EXCEEDED } from "./store.js";
57
57
  export { meetingTimestamp } from "./timestamp.js";
58
58
  export type { MeetingTranscriptReceiptStore, MeetingTranscriptStore, TranscriptAppend, TranscriptAppendReceipt, UnlinkedTranscriptInput, } from "./transcript-store.js";
@@ -11,6 +11,11 @@ export interface MeetingParticipantCandidate {
11
11
  identity_id: number;
12
12
  display_name: string | null;
13
13
  email: string | null;
14
+ /** The person their identity is linked to; a linked person's name is searched too. */
15
+ person: {
16
+ ref: string;
17
+ name: string | null;
18
+ } | null;
14
19
  }
15
20
  export interface MeetingParticipantPage {
16
21
  schema_version: 1;