@wirecat/cli-core 0.649.0 → 0.650.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 (67) hide show
  1. package/CHANGELOG.md +65 -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 +46 -10
  5. package/dist/cli/messenger/messages-search-command.js +6 -1
  6. package/dist/cli/messenger/search-answers.d.ts +3 -1
  7. package/dist/cli/messenger/search-answers.js +3 -1
  8. package/dist/cli/steps.js +9 -0
  9. package/dist/cli/unknown-profile.js +1 -0
  10. package/dist/constants/index.d.ts +6 -0
  11. package/dist/constants/index.js +14 -0
  12. package/dist/crm/cli/index.js +30 -5
  13. package/dist/crm/source.d.ts +8 -1
  14. package/dist/crm/stage-tasks.d.ts +3 -1
  15. package/dist/crm/stage-tasks.js +8 -4
  16. package/dist/crm/sync.d.ts +1 -1
  17. package/dist/crm/sync.js +54 -0
  18. package/dist/domain/crm.d.ts +15 -0
  19. package/dist/domain/phones.d.ts +2 -0
  20. package/dist/domain/phones.js +3 -0
  21. package/dist/entities/contact-context.d.ts +6 -0
  22. package/dist/entities/contact-context.js +3 -0
  23. package/dist/entities/deal.d.ts +4 -0
  24. package/dist/entities/deal.js +3 -0
  25. package/dist/entities/index.d.ts +12 -0
  26. package/dist/entities/recorded-meeting.d.ts +17 -0
  27. package/dist/entities/recorded-meeting.js +15 -0
  28. package/dist/errors/reasons.js +3 -4
  29. package/dist/index.d.ts +1 -1
  30. package/dist/meetings/answers.d.ts +5 -0
  31. package/dist/meetings/answers.js +3 -0
  32. package/dist/meetings/index.d.ts +1 -1
  33. package/dist/meetings/participant-search.d.ts +5 -0
  34. package/dist/meetings/pull.js +2 -1
  35. package/dist/meetings/read-answers.d.ts +4 -0
  36. package/dist/meetings/read-answers.js +1 -0
  37. package/dist/meetings/source.d.ts +5 -0
  38. package/dist/meetings/store.d.ts +10 -1
  39. package/dist/models/ai.js +2 -2
  40. package/dist/models/endpoint.d.ts +7 -0
  41. package/dist/models/endpoint.js +10 -0
  42. package/dist/models/index.js +2 -2
  43. package/dist/oauth/keeper.js +1 -1
  44. package/dist/sends/guard.js +8 -6
  45. package/dist/services/communications.d.ts +2 -2
  46. package/dist/services/communications.js +24 -2
  47. package/dist/services/meeting-model.js +2 -1
  48. package/dist/services/person-context.d.ts +3 -0
  49. package/dist/services/person-context.js +9 -1
  50. package/dist/services/person-meetings.d.ts +36 -0
  51. package/dist/services/person-meetings.js +57 -0
  52. package/dist/speech/openai.js +5 -2
  53. package/dist/store/sqlite/crm-settings.d.ts +5 -1
  54. package/dist/store/sqlite/crm-settings.js +8 -0
  55. package/dist/store/sqlite/crm-stage-entries.d.ts +15 -0
  56. package/dist/store/sqlite/crm-stage-entries.js +74 -0
  57. package/dist/store/sqlite/crm.d.ts +8 -1
  58. package/dist/store/sqlite/crm.js +7 -1
  59. package/dist/store/sqlite/identities.js +3 -1
  60. package/dist/store/sqlite/involvements.d.ts +2 -0
  61. package/dist/store/sqlite/involvements.js +4 -1
  62. package/dist/store/sqlite/meeting-participant-search.js +9 -3
  63. package/dist/store/sqlite/meetings.js +7 -2
  64. package/dist/store/sqlite/person-match-scan.js +39 -15
  65. package/dist/update/index.d.ts +1 -1
  66. package/dist/update/index.js +4 -2
  67. package/package.json +1 -1
@@ -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,7 @@ 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"),
91
90
  [
92
91
  "local-only.refused",
93
92
  "permission_error",
@@ -109,7 +108,6 @@ const OTHERS = [
109
108
  "only the owner chooses, unsets, checks or removes the AI model and its key, or revokes its consent",
110
109
  ],
111
110
  ["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
111
  ["ai.not-set", "configuration_error", "no AI model is chosen; models ai set chooses one"],
114
112
  ["ai.key-missing", "configuration_error", "no API key is stored for the AI model's address"],
115
113
  ["ai.ok", "invalid_response", "models ai check: the model answered (a result, never raised)"],
@@ -392,6 +390,7 @@ const OTHERS = [
392
390
  validation("crm.reference-unknown", "a CRM row names a contact, company or user the store does not hold; that link was not made"),
393
391
  validation("crm.pending-dropped", "relationships waited too long for an end that never came; they were dropped"),
394
392
  validation("crm.activities-failed", "the activities and tasks could not be read; the deals and leads were synced"),
393
+ validation("crm.stage-history-failed", "the CRM's stage history could not be read; stage tasks wait for the next sync"),
395
394
  validation("crm.email-ambiguous", "a CRM contact's email belongs to more than one person; the owner decides"),
396
395
  validation("crm.own-unknown", "no own company of the CRM account is stored, so its users are no one's employees yet"),
397
396
  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";
@@ -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;
@@ -1,7 +1,7 @@
1
1
  import { linkEvent } from "./events.js";
2
2
  import { speakerPosition, timestamp, transcriptInput } from "./ingest.js";
3
3
  const participantInput = (p, provider, occurrenceId, position, accountId) => {
4
- const { identityExternalId, ...fields } = p;
4
+ const { identityExternalId, phone, ...fields } = p;
5
5
  const externalId = identityExternalId ??
6
6
  (p.email ? `email:${p.email.toLowerCase()}` : p.externalId) ??
7
7
  `name:${p.displayName ?? "unknown"}@${accountId}/${occurrenceId}:${position}`;
@@ -11,6 +11,7 @@ const participantInput = (p, provider, occurrenceId, position, accountId) => {
11
11
  provider,
12
12
  externalId,
13
13
  name: p.displayName,
14
+ ...(phone?.trim() ? { phone } : {}),
14
15
  metadata: p.metadata,
15
16
  associatePerson: Boolean(identityExternalId?.trim() || p.email?.trim() || p.externalId?.trim()),
16
17
  },
@@ -124,6 +124,10 @@ export declare const meetingParticipants: v.StrictObjectSchema<{
124
124
  readonly identity_id: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 1, undefined>]>;
125
125
  readonly display_name: v.NullableSchema<v.StringSchema<undefined>, undefined>;
126
126
  readonly email: v.NullableSchema<v.StringSchema<undefined>, undefined>;
127
+ readonly person: v.NullableSchema<v.StrictObjectSchema<{
128
+ readonly ref: v.StringSchema<undefined>;
129
+ readonly name: v.NullableSchema<v.StringSchema<undefined>, undefined>;
130
+ }, undefined>, undefined>;
127
131
  }, undefined>, undefined>;
128
132
  /** Several identities on one page are observations, never speaker attribution or person links. */
129
133
  readonly ambiguity: v.StrictObjectSchema<{
@@ -164,6 +164,7 @@ export const meetingParticipants = v.strictObject({
164
164
  identity_id: id,
165
165
  display_name: v.nullable(text),
166
166
  email: v.nullable(text),
167
+ person: v.nullable(v.strictObject({ ref: text, name: v.nullable(text) })),
167
168
  })),
168
169
  /** Several identities on one page are observations, never speaker attribution or person links. */
169
170
  ambiguity: v.strictObject({ scope: v.literal("page"), multiple_identities: v.boolean(), identity_ids: v.array(id) }),
@@ -3,6 +3,11 @@ import type { MeetingSave } from "./store.js";
3
3
  export interface SourceParticipant {
4
4
  identityExternalId: string | null;
5
5
  email: string | null;
6
+ /**
7
+ * The number the participant called from or was called on, as the phone network gave it: what links a call's
8
+ * client to the CRM contact with that number. E.164, or written with `+`; anything else is left out.
9
+ */
10
+ phone?: string | null;
6
11
  displayName: string | null;
7
12
  externalId: string | null;
8
13
  role: string | null;
@@ -9,6 +9,8 @@ export interface IdentityInput {
9
9
  provider: string;
10
10
  externalId: string;
11
11
  name: string | null;
12
+ /** As the source gave it; the store keeps it only when it reads as E.164. */
13
+ phone?: string | null;
12
14
  metadata: Metadata;
13
15
  }
14
16
  export interface ParticipantInput extends Omit<NewRecord<Participant>, "meetingId" | "identityId"> {
@@ -44,10 +46,17 @@ export interface MeetingSave {
44
46
  */
45
47
  fromFile?: boolean;
46
48
  }
49
+ /** A participant with the person their identity is linked to, when the store knows people. */
50
+ export interface MeetingParticipant extends Participant {
51
+ person?: {
52
+ uid: string;
53
+ name: string | null;
54
+ };
55
+ }
47
56
  export interface MeetingDetails {
48
57
  meeting: Meeting;
49
58
  series: MeetingSeries | null;
50
- participants: Participant[];
59
+ participants: MeetingParticipant[];
51
60
  transcripts: {
52
61
  transcript: Transcript;
53
62
  rows: TranscriptRow[];
package/dist/models/ai.js CHANGED
@@ -54,10 +54,10 @@ export const aiSettingOf = (given) => {
54
54
  ? `the provider is one of ${AI_PROVIDERS.join(", ")}`
55
55
  : field === "base_url"
56
56
  ? "this address is not allowed: use https, or http only on this computer"
57
- : "name the model, 1 to 200 characters", { reason: field === "base_url" ? "ai.address-refused" : "ai.setting-invalid" });
57
+ : "name the model, 1 to 200 characters", { reason: field === "base_url" ? "model.address-refused" : "ai.setting-invalid" });
58
58
  }
59
59
  if (checked.output.provider === "ollama" && !onThisComputer(aiBaseUrl(checked.output)))
60
- throw new CliError("validation_error", "Ollama is read only on this computer", { reason: "ai.address-refused" });
60
+ throw new CliError("validation_error", "Ollama is read only on this computer", { reason: "model.address-refused" });
61
61
  return given.allowImages
62
62
  ? {
63
63
  ...checked.output,
@@ -1,6 +1,13 @@
1
+ import { type FetchLike } from "@wirecat/cli-base/http";
1
2
  export declare const endpoint: (value: string) => boolean;
2
3
  /** An address on this computer: localhost, 127.x.x.x or [::1]. */
3
4
  export declare const onThisComputer: (value: string) => boolean;
4
5
  /** https anywhere; plain http only to this computer, so neither the text nor the key crosses a network unencrypted. */
5
6
  export declare const modelAddressAllowed: (value: string) => boolean;
6
7
  export declare const PLAIN_HTTP_REFUSED = "this address is not allowed: use https, or http only on this computer";
8
+ /**
9
+ * `fetch` that reaches only the host of this model address, through `hostFetch`. The address was checked when it was
10
+ * saved; its host is the one the person configured. `[::1]` is not a name `hostFetch` takes, and the loopback cannot
11
+ * leave this computer, so it goes through the plain `fetch`.
12
+ */
13
+ export declare const endpointFetch: (address: string, timeoutMs: number) => FetchLike;
@@ -1,3 +1,4 @@
1
+ import { hostFetch } from "@wirecat/cli-base/http";
1
2
  export const endpoint = (value) => {
2
3
  try {
3
4
  const url = new URL(value);
@@ -20,3 +21,12 @@ export const onThisComputer = (value) => {
20
21
  /** https anywhere; plain http only to this computer, so neither the text nor the key crosses a network unencrypted. */
21
22
  export const modelAddressAllowed = (value) => endpoint(value) && (new URL(value).protocol === "https:" || onThisComputer(value));
22
23
  export const PLAIN_HTTP_REFUSED = "this address is not allowed: use https, or http only on this computer";
24
+ /**
25
+ * `fetch` that reaches only the host of this model address, through `hostFetch`. The address was checked when it was
26
+ * saved; its host is the one the person configured. `[::1]` is not a name `hostFetch` takes, and the loopback cannot
27
+ * leave this computer, so it goes through the plain `fetch`.
28
+ */
29
+ export const endpointFetch = (address, timeoutMs) => {
30
+ const { hostname } = new URL(address);
31
+ return hostname === "[::1]" ? fetch : hostFetch({ hosts: [hostname], timeoutMs });
32
+ };
@@ -1,5 +1,5 @@
1
1
  import { CliError } from "@wirecat/cli-base";
2
- import { endpoint, modelAddressAllowed, PLAIN_HTTP_REFUSED } from "./endpoint.js";
2
+ import { endpoint, endpointFetch, modelAddressAllowed, PLAIN_HTTP_REFUSED } from "./endpoint.js";
3
3
  import { refuseOffComputer } from "./local-only.js";
4
4
  import { openai } from "./openai.js";
5
5
  import { EmptyAnswer, validateImages, } from "./types.js";
@@ -42,7 +42,7 @@ export const modelGateway = (deps) => ({
42
42
  const apiKey = await deps.key?.(target.provider, target);
43
43
  if (deps.signal?.aborted)
44
44
  throw new CliError("cancelled", "model request cancelled");
45
- const fetcher = deps.fetch ?? fetch;
45
+ const fetcher = deps.fetch ?? endpointFetch(baseUrl, 120_000);
46
46
  let limited = false;
47
47
  let unreachable = false;
48
48
  let refused = false;
@@ -31,7 +31,7 @@ export const tokenKeeper = (options) => {
31
31
  });
32
32
  const exchange = (params, ctx) => provider.exchange ? provider.exchange(params, ctx) : requestTokens(provider, params, ctx);
33
33
  const notSignedIn = () => new CliError("authentication_error", `not signed in to ${provider.name}; run ${options.signInCommand}`, {
34
- reason: "oauth.missing",
34
+ reason: "session.missing",
35
35
  });
36
36
  const busy = (error) => isCliError(error) && error.details.reason === "file.locked";
37
37
  const acquire = async () => {
@@ -8,9 +8,9 @@ import { RecipientList, recipientsPathFor } from "./recipients.js";
8
8
  const HOUR_MS = 60 * 60 * 1000;
9
9
  /**
10
10
  * Asked of the guard for their permission level, yet they only read from the messenger or work here: reads go on
11
- * during a hold.
11
+ * during a hold and under the read-only lock, which promises reads and syncs.
12
12
  */
13
- const READS_UNDER_HOLD = new Set([
13
+ const READS = new Set([
14
14
  "attachments.extract",
15
15
  "conversations.embeddings",
16
16
  "conversations.links",
@@ -67,13 +67,15 @@ export const sendGuard = ({ profile, recipients, command = recipients.command, r
67
67
  const currentPermissions = () => (typeof permissions === "function" ? permissions() : permissions);
68
68
  let reservation;
69
69
  const answered = new WeakSet();
70
- const refuseReadOnly = () => {
70
+ const refuseReadOnly = ({ key }) => {
71
+ if (key !== undefined && READS.has(key))
72
+ return;
71
73
  if (readOnlyLock)
72
74
  throw readOnlyRefusal(readOnlyLock, MESSENGER_CHANGE_REFUSAL);
73
75
  };
74
76
  // Every write, counted or not: a reaction or a read receipt sent through a ban is what makes the ban stick.
75
77
  const refuseHeld = ({ key }) => {
76
- if (key !== undefined && READS_UNDER_HOLD.has(key))
78
+ if (key !== undefined && READS.has(key))
77
79
  return;
78
80
  const block = flood?.sendBlock();
79
81
  if (!block)
@@ -84,7 +86,7 @@ export const sendGuard = ({ profile, recipients, command = recipients.command, r
84
86
  };
85
87
  const permitted = (request) => {
86
88
  const { chatId, kind = "message", action, personIds } = request;
87
- refuseReadOnly();
89
+ refuseReadOnly(request);
88
90
  const levels = currentPermissions();
89
91
  if (levels !== undefined) {
90
92
  const key = request.key ?? keyForWrite(kind, action);
@@ -201,7 +203,7 @@ export const sendGuard = ({ profile, recipients, command = recipients.command, r
201
203
  };
202
204
  return {
203
205
  ask: async (request) => {
204
- refuseReadOnly();
206
+ refuseReadOnly(request);
205
207
  const levels = currentPermissions();
206
208
  if (levels === undefined)
207
209
  return;
@@ -1,9 +1,9 @@
1
1
  import type { AccountKey, LinkedIdentity, MessageStore, PersonRecord, StoredAccount } from "../store/store.js";
2
2
  import { type Coverage, type Scope } from "./business-context.js";
3
- /** A one-to-one chat, a mail or a calendar event with some of the people asked about. */
3
+ /** A one-to-one chat, a mail, a calendar event or a recorded meeting or call with some of the people asked about. */
4
4
  export interface Touch {
5
5
  kind: "message" | "mail" | "meeting";
6
- /** A message's or mail's locator, an `event:<id>`. */
6
+ /** A message's or mail's locator, an `event:<id>`, or a recorded meeting's `meeting:<account>/<id>`. */
7
7
  ref: string;
8
8
  /** The chat's title, the mail's subject, the event's title. */
9
9
  title: string | null;
@@ -2,9 +2,12 @@ import { formatLocator } from "../domain/locator.js";
2
2
  import { kindIn } from "../domain/providers.js";
3
3
  import { keyOf, newestFirst } from "./business-context.js";
4
4
  import { eventsOnce } from "./person-context.js";
5
+ import { personMeetings } from "./person-meetings.js";
5
6
  /** Mail read per address when counting: past it the count says `hasMore`. */
6
7
  const MAIL_ROWS = 500;
7
8
  const EVENT_ROWS = 1000;
9
+ /** Recorded meetings and calls listed: past it the count still counts each, and the read says `hasMore`. */
10
+ const RECORDED_ROWS = 100;
8
11
  /** The stored accounts that hold a calendar: what a person's events are read from. */
9
12
  export const calendarsOf = async (store, stored) => {
10
13
  const held = [];
@@ -45,6 +48,7 @@ export const communicationsOf = async (store, asked, scope, { since, until, limi
45
48
  const messages = new Map();
46
49
  const mail = new Map();
47
50
  const meetings = new Map();
51
+ const recordedTouches = [];
48
52
  let messageCount = 0;
49
53
  let cut = false;
50
54
  const sinceIso = since === undefined ? undefined : new Date(since).toISOString();
@@ -131,9 +135,27 @@ export const communicationsOf = async (store, asked, scope, { since, until, limi
131
135
  }
132
136
  for (const key of calendars)
133
137
  read.add(keyOf(key));
138
+ const recorded = await personMeetings(store, people.map(({ uid }) => uid), stored.filter((one) => scope.has(one)), { limit: RECORDED_ROWS, ...(since === undefined ? {} : { since }), ...(until === undefined ? {} : { until }) });
139
+ cut ||= recorded.hasMore;
140
+ let held = 0;
141
+ for (const meeting of recorded.items) {
142
+ read.add(keyOf(meeting.account));
143
+ const event = meeting.event === null ? undefined : Number(meeting.event.slice("event:".length));
144
+ if (event !== undefined && meetings.has(event)) {
145
+ held++;
146
+ continue;
147
+ }
148
+ recordedTouches.push({
149
+ kind: "meeting",
150
+ ref: meeting.ref,
151
+ title: meeting.title,
152
+ at: meeting.startedAt,
153
+ people: meeting.people,
154
+ });
155
+ }
134
156
  return {
135
- counts: { messages: messageCount, mail: mail.size, meetings: meetings.size },
136
- items: [...messages.values(), ...mail.values(), ...meetings.values()].sort(newestFirst),
157
+ counts: { messages: messageCount, mail: mail.size, meetings: meetings.size + recorded.total - held },
158
+ items: [...messages.values(), ...mail.values(), ...meetings.values(), ...recordedTouches].sort(newestFirst),
137
159
  hasMore: cut,
138
160
  coverage: coverageOf(people, read, calendars.length > 0),
139
161
  };
@@ -2,6 +2,7 @@ import { CliError } from "@wirecat/cli-base";
2
2
  import { isTextModelInstalled, openEmbedder, textModelsDirectory, } from "../embeddings/embed.js";
3
3
  import { textModel, vectorModelKey } from "../embeddings/models.js";
4
4
  import { OPENAI_URL, openRemote, remoteKey, remoteModel } from "../embeddings/remote.js";
5
+ import { endpointFetch } from "../models/endpoint.js";
5
6
  const integer = (value, name, max) => {
6
7
  if (!Number.isSafeInteger(value) || value < 1 || value > max)
7
8
  throw new CliError("validation_error", `Invalid ${name}`);
@@ -128,7 +129,7 @@ export const openMeetingEmbedder = async (choice, options = {}) => {
128
129
  const key = choice.apiKey ?? (remote.provider === "openai" ? (options.env ?? process.env).OPENAI_API_KEY : undefined);
129
130
  if (remote.provider === "openai" && !key)
130
131
  throw new CliError("authentication_error", "The explicit remote embedding model requires an API key");
131
- const post = options.fetch ?? fetch;
132
+ const post = options.fetch ?? endpointFetch(remote.baseUrl, 120_000);
132
133
  const guarded = async (url, init) => {
133
134
  try {
134
135
  cancelled(signal);
@@ -1,6 +1,7 @@
1
1
  import type { ChatKind, Id, Message, Provider } from "../domain/models.js";
2
2
  import type { Event, EventFilter } from "../meetings/index.js";
3
3
  import type { AccountKey, IdentityRef, LinkedIdentity, MessageStore, PersonRecord, StoredAccount } from "../store/store.js";
4
+ import { type PersonMeeting } from "./person-meetings.js";
4
5
  export declare const CONTEXT_MESSAGES = 10;
5
6
  export declare const CONTEXT_BYTES: number;
6
7
  export interface ContextMessage {
@@ -65,6 +66,8 @@ export interface PersonContext {
65
66
  upcoming: ContextEvent[];
66
67
  recent: ContextEvent[];
67
68
  };
69
+ /** Recorded meetings and calls they took part in, newest first, in the accounts read. */
70
+ meetings: PersonMeeting[];
68
71
  limits: {
69
72
  messages: number;
70
73
  bytes: number;
@@ -2,6 +2,7 @@ import { CliError } from "@wirecat/cli-base";
2
2
  import { formatLocator } from "../domain/locator.js";
3
3
  import { pickPerson } from "../resolve.js";
4
4
  import { messageOfEmail } from "../store/store.js";
5
+ import { personMeetings } from "./person-meetings.js";
5
6
  export const CONTEXT_MESSAGES = 10;
6
7
  export const CONTEXT_BYTES = 64 * 1024;
7
8
  export const toContext = (key, message, chatTitle) => ({
@@ -212,6 +213,11 @@ export const recordContext = async (store, record, reads, readable, { messages =
212
213
  ? await eventsOnce(store, { personId, accountIds, to: now, newest: true, ...(since === undefined ? {} : { from: since }) }, messages)
213
214
  : nothing;
214
215
  cut ||= upcoming.cut || past.cut;
216
+ const recorded = await personMeetings(store, [record.uid], readable, {
217
+ limit: messages,
218
+ ...(since === undefined ? {} : { since }),
219
+ });
220
+ cut ||= recorded.hasMore;
215
221
  direct.sort(newestFirst);
216
222
  const each = [...direct, ...beyond].sort(newestFirst);
217
223
  theirs.sort(newestFirst);
@@ -229,7 +235,8 @@ export const recordContext = async (store, record, reads, readable, { messages =
229
235
  const read = [
230
236
  ...reads.map(({ key, scope }) => ({ ...key, scope })),
231
237
  ...calendars.map(({ provider, account, scope }) => ({ provider, account, scope })),
232
- ];
238
+ ...recorded.items.flatMap(({ account }) => readable.filter((one) => nameOf(one) === nameOf(account))),
239
+ ].map(({ provider, account, scope }) => ({ provider, account, scope }));
233
240
  const accounts = [...new Map(read.map((one) => [nameOf(one), one])).values()].sort((a, b) => nameOf(a).localeCompare(nameOf(b)));
234
241
  return {
235
242
  accounts,
@@ -245,6 +252,7 @@ export const recordContext = async (store, record, reads, readable, { messages =
245
252
  upcoming: upcoming.items.map(contextEvent),
246
253
  recent: past.items.filter(({ id }) => !upcomingIds.has(id)).map(contextEvent),
247
254
  },
255
+ meetings: recorded.items,
248
256
  limits: { messages, bytes },
249
257
  hasMore: cut || kept.cut,
250
258
  complete: notRead.length === 0,
@@ -0,0 +1,36 @@
1
+ import type { MessageStore, StoredAccount } from "../store/store.js";
2
+ /** A recorded meeting or call some of the people took part in, as the meeting source stored it. */
3
+ export interface PersonMeeting {
4
+ /** `meeting:<account>/<meeting>`: `meetings show <meeting>` and `meetings transcript <meeting>` of `account` open it. */
5
+ ref: string;
6
+ /** The stored meeting id those commands take. */
7
+ meetingId: number;
8
+ /** The account that holds it: its tool's profile opens it. */
9
+ account: {
10
+ provider: string;
11
+ account: string;
12
+ };
13
+ title: string | null;
14
+ startedAt: string | null;
15
+ durationMs: number | null;
16
+ hasTranscript: boolean;
17
+ /** `event:<id>` of the calendar event it was held for, when the store knows it. */
18
+ event: string | null;
19
+ /** `person:<uid>` of each one asked about who took part. */
20
+ people: string[];
21
+ }
22
+ /**
23
+ * The newest recorded meetings of these people in `accounts`, each once, newest first, and how many there are;
24
+ * `hasMore` when there are more than `limit`, or a person took part in more than `SCAN`. A meeting reaches
25
+ * a person through the identity it was saved under, and through every identity linked to them since, such as a
26
+ * call's number matched to a CRM contact.
27
+ */
28
+ export declare const personMeetings: (store: Pick<MessageStore, "involvements" | "meetings">, people: readonly string[], accounts: readonly StoredAccount[], { limit, since, until }?: {
29
+ limit?: number;
30
+ since?: number;
31
+ until?: number;
32
+ }) => Promise<{
33
+ items: PersonMeeting[];
34
+ total: number;
35
+ hasMore: boolean;
36
+ }>;