@wirecat/cli-core 0.675.0 → 0.676.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 (58) hide show
  1. package/CHANGELOG.md +88 -0
  2. package/dist/background/daily-archive-timer.d.ts +1 -1
  3. package/dist/calendar/mcp/index.d.ts +12 -12
  4. package/dist/cli/documents/words.d.ts +1 -1
  5. package/dist/cli/index.d.ts +1 -1
  6. package/dist/cli/list-query.d.ts +3 -2
  7. package/dist/cli/list-query.js +5 -2
  8. package/dist/cli/setup-command.js +9 -3
  9. package/dist/crm/cli/index.d.ts +7 -1
  10. package/dist/crm/cli/index.js +104 -20
  11. package/dist/crm/cli/pipeline-view.js +15 -1
  12. package/dist/crm/cli/records.js +11 -3
  13. package/dist/crm/cli/search-all.d.ts +5 -2
  14. package/dist/crm/cli/search-all.js +15 -3
  15. package/dist/crm/source.d.ts +3 -2
  16. package/dist/crm/stage-tasks.js +1 -1
  17. package/dist/crm/sync.js +13 -11
  18. package/dist/crm/testing/write-contract.js +5 -1
  19. package/dist/crm/viewer.d.ts +28 -0
  20. package/dist/crm/viewer.js +63 -0
  21. package/dist/crm/writer.d.ts +3 -0
  22. package/dist/crm/writes.d.ts +7 -2
  23. package/dist/crm/writes.js +24 -14
  24. package/dist/domain/crm.d.ts +9 -9
  25. package/dist/domain/moment.d.ts +2 -0
  26. package/dist/domain/moment.js +2 -0
  27. package/dist/entities/business-context.js +1 -1
  28. package/dist/entities/deal.d.ts +86 -39
  29. package/dist/entities/deal.js +45 -4
  30. package/dist/entities/index.d.ts +20 -32
  31. package/dist/errors/reasons.js +1 -0
  32. package/dist/meetings/mcp/index.d.ts +15 -15
  33. package/dist/services/search-all.d.ts +3 -1
  34. package/dist/services/search-all.js +1 -0
  35. package/dist/setup/define.d.ts +17 -2
  36. package/dist/store/exports.d.ts +1 -0
  37. package/dist/store/exports.js +1 -0
  38. package/dist/store/sqlite/copy-viewer.d.ts +16 -0
  39. package/dist/store/sqlite/copy-viewer.js +11 -0
  40. package/dist/store/sqlite/crm-activities.d.ts +7 -1
  41. package/dist/store/sqlite/crm-activities.js +32 -5
  42. package/dist/store/sqlite/crm-contacts.d.ts +5 -2
  43. package/dist/store/sqlite/crm-contacts.js +30 -14
  44. package/dist/store/sqlite/crm-rows.d.ts +7 -0
  45. package/dist/store/sqlite/crm-rows.js +37 -5
  46. package/dist/store/sqlite/crm-settings.d.ts +2 -1
  47. package/dist/store/sqlite/crm-settings.js +3 -2
  48. package/dist/store/sqlite/crm-stage-entries.d.ts +24 -4
  49. package/dist/store/sqlite/crm-stage-entries.js +77 -18
  50. package/dist/store/sqlite/crm.d.ts +14 -4
  51. package/dist/store/sqlite/crm.js +59 -7
  52. package/dist/store/sqlite/deals.d.ts +47 -29
  53. package/dist/store/sqlite/deals.js +64 -76
  54. package/dist/store/sqlite/pipeline-period.d.ts +85 -0
  55. package/dist/store/sqlite/pipeline-period.js +199 -0
  56. package/dist/store/sqlite/stage-amounts.d.ts +6 -2
  57. package/dist/store/sqlite/stage-amounts.js +8 -5
  58. package/package.json +3 -3
@@ -12,6 +12,13 @@ export interface DealActivity {
12
12
  created_at: string;
13
13
  updated_at: string;
14
14
  }
15
+ /** One stage a deal or lead entered: `exact` from the CRM's own history, else as a sync saw the copy change. */
16
+ export interface DealStageEntry {
17
+ from: string | null;
18
+ to: string;
19
+ at: string;
20
+ exact: boolean;
21
+ }
15
22
  /**
16
23
  * A deal (`deal:<id>`), the owner's own or a CRM's copy: one shape for memo and every CRM CLI. Money is a decimal
17
24
  * string in its currency, both `null` when no amount is expected.
@@ -89,6 +96,11 @@ export declare const deal: v.StrictObjectSchema<{
89
96
  readonly activities: v.OptionalSchema<v.ArraySchema<v.GenericSchema<DealActivity>, undefined>, undefined>;
90
97
  /** `show` of a CRM copy: the newest recorded meetings and calls of its people, in its account's scope. */
91
98
  readonly meetings: v.OptionalSchema<v.ArraySchema<v.GenericSchema<import("./recorded-meeting.js").RecordedMeeting>, undefined>, undefined>;
99
+ /**
100
+ * `show` of a CRM copy: every stage it entered, oldest first. Once the CRM's own history names any, it alone is
101
+ * listed, from as far back as it was read; the copy's changes between syncs are left out.
102
+ */
103
+ readonly stage_history: v.OptionalSchema<v.ArraySchema<v.GenericSchema<DealStageEntry>, undefined>, undefined>;
92
104
  readonly untrusted: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
93
105
  }, undefined>;
94
106
  /** A lead (`lead:<id>`): a deal's shape, in a lead pipeline. */
@@ -165,8 +177,49 @@ export declare const lead: v.StrictObjectSchema<{
165
177
  readonly activities: v.OptionalSchema<v.ArraySchema<v.GenericSchema<DealActivity>, undefined>, undefined>;
166
178
  /** `show` of a CRM copy: the newest recorded meetings and calls of its people, in its account's scope. */
167
179
  readonly meetings: v.OptionalSchema<v.ArraySchema<v.GenericSchema<import("./recorded-meeting.js").RecordedMeeting>, undefined>, undefined>;
180
+ /**
181
+ * `show` of a CRM copy: every stage it entered, oldest first. Once the CRM's own history names any, it alone is
182
+ * listed, from as far back as it was read; the copy's changes between syncs are left out.
183
+ */
184
+ readonly stage_history: v.OptionalSchema<v.ArraySchema<v.GenericSchema<DealStageEntry>, undefined>, undefined>;
168
185
  readonly untrusted: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
169
186
  }, undefined>;
187
+ /** `pipelines show`: the rows made in the window, by their CRM assignee. */
188
+ export interface PipelineOwner {
189
+ assignee: string | null;
190
+ name: string | null;
191
+ open: number;
192
+ won: number;
193
+ lost: number;
194
+ win_rate: number | null;
195
+ }
196
+ export interface PipelineClosed {
197
+ won: number;
198
+ lost: number;
199
+ win_rate: number | null;
200
+ won_amounts: {
201
+ amount: string;
202
+ currency: string;
203
+ items: number;
204
+ }[];
205
+ }
206
+ /** One stage in a pipeline's answer, typed by name for the same reason as `activity`. */
207
+ export interface PipelineStageAnswer {
208
+ name: string;
209
+ position: number;
210
+ outcome: "open" | "won" | "lost";
211
+ external_id: string | null;
212
+ open: number;
213
+ reached?: number;
214
+ conversion?: number | null;
215
+ items?: number;
216
+ amounts?: {
217
+ amount: string;
218
+ currency: string;
219
+ items: number;
220
+ }[];
221
+ median_days?: number | null;
222
+ }
170
223
  /** A pipeline (`pipeline:<id>`) with its stages in order; `pipelines show` adds the funnel. */
171
224
  export declare const pipeline: v.StrictObjectSchema<{
172
225
  readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
@@ -178,25 +231,9 @@ export declare const pipeline: v.StrictObjectSchema<{
178
231
  readonly account: v.StringSchema<undefined>;
179
232
  }, undefined>, undefined>;
180
233
  readonly external_id: v.NullableSchema<v.StringSchema<undefined>, undefined>;
181
- readonly stages: v.ArraySchema<v.StrictObjectSchema<{
182
- readonly name: v.StringSchema<undefined>;
183
- readonly position: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
184
- readonly outcome: v.PicklistSchema<["open", "won", "lost"], undefined>;
185
- readonly external_id: v.NullableSchema<v.StringSchema<undefined>, undefined>;
186
- /** Open deals or leads in it now. */
187
- readonly open: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
188
- /** With a funnel: rows that got this far, and the share of them that reached the next stage. */
189
- readonly reached: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
190
- readonly conversion: v.OptionalSchema<v.NullableSchema<v.NumberSchema<undefined>, undefined>, undefined>;
191
- /** With a funnel: rows standing in it now, and their sum per currency, never converted. */
192
- readonly items: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
193
- readonly amounts: v.OptionalSchema<v.ArraySchema<v.StrictObjectSchema<{
194
- readonly amount: v.StringSchema<undefined>;
195
- readonly currency: v.StringSchema<undefined>;
196
- readonly items: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
197
- }, undefined>, undefined>, undefined>;
198
- }, undefined>, undefined>;
234
+ readonly stages: v.ArraySchema<v.GenericSchema<PipelineStageAnswer>, undefined>;
199
235
  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`">]>;
236
+ /** `show`: the rows made in the window. */
200
237
  readonly totals: v.OptionalSchema<v.StrictObjectSchema<{
201
238
  readonly items: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
202
239
  readonly open: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
@@ -204,29 +241,39 @@ export declare const pipeline: v.StrictObjectSchema<{
204
241
  readonly lost: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
205
242
  readonly win_rate: v.NullableSchema<v.NumberSchema<undefined>, undefined>;
206
243
  }, undefined>, undefined>;
244
+ readonly window: v.OptionalSchema<v.StrictObjectSchema<{
245
+ readonly since: 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>;
246
+ readonly until: 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>;
247
+ }, undefined>, undefined>;
207
248
  readonly since: v.OptionalSchema<v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>, undefined>, undefined>;
208
- readonly untrusted: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
209
- }, undefined>;
210
- /** One stage of a pipeline, with the pipeline it is in: what `stages list` answers. */
211
- export declare const stage: v.StrictObjectSchema<{
212
- readonly name: v.StringSchema<undefined>;
213
- readonly position: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
214
- readonly outcome: v.PicklistSchema<["open", "won", "lost"], undefined>;
215
- readonly external_id: v.NullableSchema<v.StringSchema<undefined>, undefined>;
216
- /** Open deals or leads in it now. */
217
- readonly open: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
218
- /** With a funnel: rows that got this far, and the share of them that reached the next stage. */
219
- readonly reached: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
220
- readonly conversion: v.OptionalSchema<v.NullableSchema<v.NumberSchema<undefined>, undefined>, undefined>;
221
- /** With a funnel: rows standing in it now, and their sum per currency, never converted. */
222
- readonly items: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
223
- readonly amounts: v.OptionalSchema<v.ArraySchema<v.StrictObjectSchema<{
224
- readonly amount: v.StringSchema<undefined>;
225
- readonly currency: v.StringSchema<undefined>;
249
+ /** `show`: rows closed on a day in the window, in the owner's zone. */
250
+ readonly closed: v.OptionalSchema<v.GenericSchema<PipelineClosed>, undefined>;
251
+ /** `show`: days from made to won, of the rows won in the window. */
252
+ readonly cycle: v.OptionalSchema<v.StrictObjectSchema<{
253
+ readonly median_days: v.NullableSchema<v.NumberSchema<undefined>, undefined>;
254
+ readonly items: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
255
+ }, undefined>, undefined>;
256
+ readonly owners: v.OptionalSchema<v.ArraySchema<v.GenericSchema<PipelineOwner>, undefined>, undefined>;
257
+ readonly lost_reasons: v.OptionalSchema<v.ArraySchema<v.StrictObjectSchema<{
258
+ readonly reason: v.StringSchema<undefined>;
226
259
  readonly items: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
227
260
  }, undefined>, undefined>, undefined>;
228
- readonly pipeline: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
229
- readonly pipeline_name: v.StringSchema<undefined>;
230
- readonly kind: v.PicklistSchema<["deal", "lead"], undefined>;
261
+ /** `show`: rows whose stages came from the CRM's own history, and from the copy's diffs. */
262
+ readonly history: v.OptionalSchema<v.StrictObjectSchema<{
263
+ readonly exact: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
264
+ readonly copy: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
265
+ }, undefined>, undefined>;
231
266
  readonly untrusted: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
232
267
  }, undefined>;
268
+ /** One stage of a pipeline, with the pipeline it is in: what `stages list` answers. */
269
+ export interface StageAnswer extends PipelineStageAnswer {
270
+ pipeline: string;
271
+ pipeline_name: string;
272
+ kind: "deal" | "lead";
273
+ stage_task?: {
274
+ title: string;
275
+ due_days: number;
276
+ } | null;
277
+ untrusted?: string[];
278
+ }
279
+ export declare const stage: v.GenericSchema<StageAnswer>;
@@ -21,6 +21,12 @@ const activity = v.strictObject({
21
21
  created_at: time,
22
22
  updated_at: time,
23
23
  });
24
+ const stageEntry = v.strictObject({
25
+ from: nullableText,
26
+ to: text,
27
+ at: time,
28
+ exact: v.boolean(),
29
+ });
24
30
  /**
25
31
  * A deal (`deal:<id>`), the owner's own or a CRM's copy: one shape for memo and every CRM CLI. Money is a decimal
26
32
  * string in its currency, both `null` when no amount is expected.
@@ -83,10 +89,31 @@ export const deal = v.strictObject({
83
89
  activities: v.optional(v.array(activity)),
84
90
  /** `show` of a CRM copy: the newest recorded meetings and calls of its people, in its account's scope. */
85
91
  meetings: v.optional(v.array(recordedMeeting)),
92
+ /**
93
+ * `show` of a CRM copy: every stage it entered, oldest first. Once the CRM's own history names any, it alone is
94
+ * listed, from as far back as it was read; the copy's changes between syncs are left out.
95
+ */
96
+ stage_history: v.optional(v.array(stageEntry)),
86
97
  untrusted,
87
98
  });
88
99
  /** A lead (`lead:<id>`): a deal's shape, in a lead pipeline. */
89
100
  export const lead = deal;
101
+ const amount = v.strictObject({ amount: text, currency: text, items: count });
102
+ const winRate = v.nullable(v.number());
103
+ const pipelineOwner = v.strictObject({
104
+ assignee: nullableText,
105
+ name: nullableText,
106
+ open: count,
107
+ won: count,
108
+ lost: count,
109
+ win_rate: winRate,
110
+ });
111
+ const pipelineClosed = v.strictObject({
112
+ won: count,
113
+ lost: count,
114
+ win_rate: winRate,
115
+ won_amounts: v.array(amount),
116
+ });
90
117
  const pipelineStage = v.strictObject({
91
118
  name: text,
92
119
  position: count,
@@ -99,8 +126,11 @@ const pipelineStage = v.strictObject({
99
126
  conversion: v.optional(v.nullable(v.number())),
100
127
  /** With a funnel: rows standing in it now, and their sum per currency, never converted. */
101
128
  items: v.optional(count),
102
- amounts: v.optional(v.array(v.strictObject({ amount: text, currency: text, items: count }))),
129
+ amounts: v.optional(v.array(amount)),
130
+ /** With a funnel: the median days a row of the window stayed in it before it moved on. */
131
+ median_days: v.optional(v.nullable(v.number())),
103
132
  });
133
+ const pipelineStageAnswer = pipelineStage;
104
134
  /** A pipeline (`pipeline:<id>`) with its stages in order; `pipelines show` adds the funnel. */
105
135
  export const pipeline = v.strictObject({
106
136
  id,
@@ -109,17 +139,28 @@ export const pipeline = v.strictObject({
109
139
  kind: v.picklist(["deal", "lead"]),
110
140
  account: crmAccount,
111
141
  external_id: nullableText,
112
- stages: v.array(pipelineStage),
142
+ stages: v.array(pipelineStageAnswer),
113
143
  created_at: time,
114
- totals: v.optional(v.strictObject({ items: count, open: count, won: count, lost: count, win_rate: v.nullable(v.number()) })),
144
+ /** `show`: the rows made in the window. */
145
+ totals: v.optional(v.strictObject({ items: count, open: count, won: count, lost: count, win_rate: winRate })),
146
+ window: v.optional(v.strictObject({ since: v.nullable(time), until: v.nullable(time) })),
115
147
  since: v.optional(day),
148
+ /** `show`: rows closed on a day in the window, in the owner's zone. */
149
+ closed: v.optional(pipelineClosed),
150
+ /** `show`: days from made to won, of the rows won in the window. */
151
+ cycle: v.optional(v.strictObject({ median_days: v.nullable(v.number()), items: count })),
152
+ owners: v.optional(v.array(pipelineOwner)),
153
+ lost_reasons: v.optional(v.array(v.strictObject({ reason: text, items: count }))),
154
+ /** `show`: rows whose stages came from the CRM's own history, and from the copy's diffs. */
155
+ history: v.optional(v.strictObject({ exact: count, copy: count })),
116
156
  untrusted,
117
157
  });
118
- /** One stage of a pipeline, with the pipeline it is in: what `stages list` answers. */
119
158
  export const stage = v.strictObject({
120
159
  ...pipelineStage.entries,
121
160
  pipeline: reference,
122
161
  pipeline_name: text,
123
162
  kind: v.picklist(["deal", "lead"]),
163
+ /** A CRM's stage: the task its `stage-tasks` rule opens when a row enters it, or `null`. */
164
+ stage_task: v.optional(v.nullable(v.strictObject({ title: text, due_days: count }))),
124
165
  untrusted,
125
166
  });
@@ -333,6 +333,7 @@ export declare const ENTITIES: {
333
333
  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`">]>;
334
334
  readonly activities: v.OptionalSchema<v.ArraySchema<v.GenericSchema<import("./deal.js").DealActivity>, undefined>, undefined>;
335
335
  readonly meetings: v.OptionalSchema<v.ArraySchema<v.GenericSchema<import("./recorded-meeting.js").RecordedMeeting>, undefined>, undefined>;
336
+ readonly stage_history: v.OptionalSchema<v.ArraySchema<v.GenericSchema<import("./deal.js").DealStageEntry>, undefined>, undefined>;
336
337
  readonly untrusted: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
337
338
  }, undefined>;
338
339
  readonly lead: v.StrictObjectSchema<{
@@ -396,6 +397,7 @@ export declare const ENTITIES: {
396
397
  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`">]>;
397
398
  readonly activities: v.OptionalSchema<v.ArraySchema<v.GenericSchema<import("./deal.js").DealActivity>, undefined>, undefined>;
398
399
  readonly meetings: v.OptionalSchema<v.ArraySchema<v.GenericSchema<import("./recorded-meeting.js").RecordedMeeting>, undefined>, undefined>;
400
+ readonly stage_history: v.OptionalSchema<v.ArraySchema<v.GenericSchema<import("./deal.js").DealStageEntry>, undefined>, undefined>;
399
401
  readonly untrusted: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
400
402
  }, undefined>;
401
403
  readonly pipeline: v.StrictObjectSchema<{
@@ -408,21 +410,7 @@ export declare const ENTITIES: {
408
410
  readonly account: v.StringSchema<undefined>;
409
411
  }, undefined>, undefined>;
410
412
  readonly external_id: v.NullableSchema<v.StringSchema<undefined>, undefined>;
411
- readonly stages: v.ArraySchema<v.StrictObjectSchema<{
412
- readonly name: v.StringSchema<undefined>;
413
- readonly position: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
414
- readonly outcome: v.PicklistSchema<["open", "won", "lost"], undefined>;
415
- readonly external_id: v.NullableSchema<v.StringSchema<undefined>, undefined>;
416
- readonly open: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
417
- readonly reached: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
418
- readonly conversion: v.OptionalSchema<v.NullableSchema<v.NumberSchema<undefined>, undefined>, undefined>;
419
- readonly items: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
420
- readonly amounts: v.OptionalSchema<v.ArraySchema<v.StrictObjectSchema<{
421
- readonly amount: v.StringSchema<undefined>;
422
- readonly currency: v.StringSchema<undefined>;
423
- readonly items: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
424
- }, undefined>, undefined>, undefined>;
425
- }, undefined>, undefined>;
413
+ readonly stages: v.ArraySchema<v.GenericSchema<import("./deal.js").PipelineStageAnswer>, undefined>;
426
414
  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`">]>;
427
415
  readonly totals: v.OptionalSchema<v.StrictObjectSchema<{
428
416
  readonly items: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
@@ -431,28 +419,28 @@ export declare const ENTITIES: {
431
419
  readonly lost: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
432
420
  readonly win_rate: v.NullableSchema<v.NumberSchema<undefined>, undefined>;
433
421
  }, undefined>, undefined>;
422
+ readonly window: v.OptionalSchema<v.StrictObjectSchema<{
423
+ readonly since: 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>;
424
+ readonly until: 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>;
425
+ }, undefined>, undefined>;
434
426
  readonly since: v.OptionalSchema<v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>, undefined>, undefined>;
435
- readonly untrusted: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
436
- }, undefined>;
437
- readonly stage: v.StrictObjectSchema<{
438
- readonly name: v.StringSchema<undefined>;
439
- readonly position: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
440
- readonly outcome: v.PicklistSchema<["open", "won", "lost"], undefined>;
441
- readonly external_id: v.NullableSchema<v.StringSchema<undefined>, undefined>;
442
- readonly open: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
443
- readonly reached: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
444
- readonly conversion: v.OptionalSchema<v.NullableSchema<v.NumberSchema<undefined>, undefined>, undefined>;
445
- readonly items: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
446
- readonly amounts: v.OptionalSchema<v.ArraySchema<v.StrictObjectSchema<{
447
- readonly amount: v.StringSchema<undefined>;
448
- readonly currency: v.StringSchema<undefined>;
427
+ readonly closed: v.OptionalSchema<v.GenericSchema<import("./deal.js").PipelineClosed>, undefined>;
428
+ readonly cycle: v.OptionalSchema<v.StrictObjectSchema<{
429
+ readonly median_days: v.NullableSchema<v.NumberSchema<undefined>, undefined>;
430
+ readonly items: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
431
+ }, undefined>, undefined>;
432
+ readonly owners: v.OptionalSchema<v.ArraySchema<v.GenericSchema<import("./deal.js").PipelineOwner>, undefined>, undefined>;
433
+ readonly lost_reasons: v.OptionalSchema<v.ArraySchema<v.StrictObjectSchema<{
434
+ readonly reason: v.StringSchema<undefined>;
449
435
  readonly items: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
450
436
  }, undefined>, undefined>, undefined>;
451
- readonly pipeline: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
452
- readonly pipeline_name: v.StringSchema<undefined>;
453
- readonly kind: v.PicklistSchema<["deal", "lead"], undefined>;
437
+ readonly history: v.OptionalSchema<v.StrictObjectSchema<{
438
+ readonly exact: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
439
+ readonly copy: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
440
+ }, undefined>, undefined>;
454
441
  readonly untrusted: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
455
442
  }, undefined>;
443
+ readonly stage: v.GenericSchema<import("./deal.js").StageAnswer>;
456
444
  readonly message: v.StrictObjectSchema<{
457
445
  readonly ref: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
458
446
  readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
@@ -461,6 +461,7 @@ const OTHERS = [
461
461
  validation("field.not-filterable", "the CRM cannot filter a list by that custom field"),
462
462
  validation("query.bad-value", "a term's value is not the kind its field takes, such as an id or a number"),
463
463
  validation("crm.record-field", "a contact's or company's field is not valid"),
464
+ validation("crm.owner-unknown", "owner: names no CRM user: me without a known sign-in user, or not a user id"),
464
465
  validation("crm.write-unsupported", "the CRM does not take this write, or does not recognise a repeated one"),
465
466
  validation("crm.unlisted-held", "a list of every id would mark most of a kind deleted; nothing was, until --rescan"),
466
467
  validation("crm.narrowing-held", "the default scope mine would mark most of a kind's stored rows deleted; none is, until the owner sets the scope"),
@@ -38,6 +38,7 @@ export declare const meetingTools: ({
38
38
  max_read_bytes?: undefined;
39
39
  cursor?: undefined;
40
40
  } | {
41
+ limit?: undefined;
41
42
  event_id?: undefined;
42
43
  series_id?: undefined;
43
44
  page?: undefined;
@@ -53,11 +54,11 @@ export declare const meetingTools: ({
53
54
  format?: undefined;
54
55
  transcript_id?: undefined;
55
56
  query?: undefined;
56
- limit?: undefined;
57
57
  scan_limit?: undefined;
58
58
  max_read_bytes?: undefined;
59
59
  cursor?: undefined;
60
60
  } | {
61
+ limit?: undefined;
61
62
  event_id?: undefined;
62
63
  series_id?: undefined;
63
64
  page?: undefined;
@@ -75,11 +76,11 @@ export declare const meetingTools: ({
75
76
  format?: undefined;
76
77
  transcript_id?: undefined;
77
78
  query?: undefined;
78
- limit?: undefined;
79
79
  scan_limit?: undefined;
80
80
  max_read_bytes?: undefined;
81
81
  cursor?: undefined;
82
82
  } | {
83
+ limit?: undefined;
83
84
  event_id?: undefined;
84
85
  series_id?: undefined;
85
86
  page?: undefined;
@@ -101,7 +102,6 @@ export declare const meetingTools: ({
101
102
  minimum: number;
102
103
  };
103
104
  query?: undefined;
104
- limit?: undefined;
105
105
  scan_limit?: undefined;
106
106
  max_read_bytes?: undefined;
107
107
  cursor?: undefined;
@@ -188,6 +188,7 @@ export declare const meetingTools: ({
188
188
  max_read_bytes?: undefined;
189
189
  cursor?: undefined;
190
190
  } | {
191
+ limit?: undefined;
191
192
  event_id?: undefined;
192
193
  series_id?: undefined;
193
194
  page?: undefined;
@@ -203,11 +204,11 @@ export declare const meetingTools: ({
203
204
  format?: undefined;
204
205
  transcript_id?: undefined;
205
206
  query?: undefined;
206
- limit?: undefined;
207
207
  scan_limit?: undefined;
208
208
  max_read_bytes?: undefined;
209
209
  cursor?: undefined;
210
210
  } | {
211
+ limit?: undefined;
211
212
  event_id?: undefined;
212
213
  series_id?: undefined;
213
214
  page?: undefined;
@@ -225,11 +226,11 @@ export declare const meetingTools: ({
225
226
  format?: undefined;
226
227
  transcript_id?: undefined;
227
228
  query?: undefined;
228
- limit?: undefined;
229
229
  scan_limit?: undefined;
230
230
  max_read_bytes?: undefined;
231
231
  cursor?: undefined;
232
232
  } | {
233
+ limit?: undefined;
233
234
  event_id?: undefined;
234
235
  series_id?: undefined;
235
236
  page?: undefined;
@@ -251,7 +252,6 @@ export declare const meetingTools: ({
251
252
  minimum: number;
252
253
  };
253
254
  query?: undefined;
254
- limit?: undefined;
255
255
  scan_limit?: undefined;
256
256
  max_read_bytes?: undefined;
257
257
  cursor?: undefined;
@@ -338,6 +338,7 @@ export declare const meetingTools: ({
338
338
  max_read_bytes?: undefined;
339
339
  cursor?: undefined;
340
340
  } | {
341
+ limit?: undefined;
341
342
  event_id?: undefined;
342
343
  series_id?: undefined;
343
344
  page?: undefined;
@@ -353,11 +354,11 @@ export declare const meetingTools: ({
353
354
  format?: undefined;
354
355
  transcript_id?: undefined;
355
356
  query?: undefined;
356
- limit?: undefined;
357
357
  scan_limit?: undefined;
358
358
  max_read_bytes?: undefined;
359
359
  cursor?: undefined;
360
360
  } | {
361
+ limit?: undefined;
361
362
  event_id?: undefined;
362
363
  series_id?: undefined;
363
364
  page?: undefined;
@@ -375,11 +376,11 @@ export declare const meetingTools: ({
375
376
  format?: undefined;
376
377
  transcript_id?: undefined;
377
378
  query?: undefined;
378
- limit?: undefined;
379
379
  scan_limit?: undefined;
380
380
  max_read_bytes?: undefined;
381
381
  cursor?: undefined;
382
382
  } | {
383
+ limit?: undefined;
383
384
  event_id?: undefined;
384
385
  series_id?: undefined;
385
386
  page?: undefined;
@@ -401,7 +402,6 @@ export declare const meetingTools: ({
401
402
  minimum: number;
402
403
  };
403
404
  query?: undefined;
404
- limit?: undefined;
405
405
  scan_limit?: undefined;
406
406
  max_read_bytes?: undefined;
407
407
  cursor?: undefined;
@@ -488,6 +488,7 @@ export declare const meetingTools: ({
488
488
  max_read_bytes?: undefined;
489
489
  cursor?: undefined;
490
490
  } | {
491
+ limit?: undefined;
491
492
  event_id?: undefined;
492
493
  series_id?: undefined;
493
494
  page?: undefined;
@@ -503,11 +504,11 @@ export declare const meetingTools: ({
503
504
  format?: undefined;
504
505
  transcript_id?: undefined;
505
506
  query?: undefined;
506
- limit?: undefined;
507
507
  scan_limit?: undefined;
508
508
  max_read_bytes?: undefined;
509
509
  cursor?: undefined;
510
510
  } | {
511
+ limit?: undefined;
511
512
  event_id?: undefined;
512
513
  series_id?: undefined;
513
514
  page?: undefined;
@@ -525,11 +526,11 @@ export declare const meetingTools: ({
525
526
  format?: undefined;
526
527
  transcript_id?: undefined;
527
528
  query?: undefined;
528
- limit?: undefined;
529
529
  scan_limit?: undefined;
530
530
  max_read_bytes?: undefined;
531
531
  cursor?: undefined;
532
532
  } | {
533
+ limit?: undefined;
533
534
  event_id?: undefined;
534
535
  series_id?: undefined;
535
536
  page?: undefined;
@@ -551,7 +552,6 @@ export declare const meetingTools: ({
551
552
  minimum: number;
552
553
  };
553
554
  query?: undefined;
554
- limit?: undefined;
555
555
  scan_limit?: undefined;
556
556
  max_read_bytes?: undefined;
557
557
  cursor?: undefined;
@@ -638,6 +638,7 @@ export declare const meetingTools: ({
638
638
  max_read_bytes?: undefined;
639
639
  cursor?: undefined;
640
640
  } | {
641
+ limit?: undefined;
641
642
  event_id?: undefined;
642
643
  series_id?: undefined;
643
644
  page?: undefined;
@@ -653,11 +654,11 @@ export declare const meetingTools: ({
653
654
  format?: undefined;
654
655
  transcript_id?: undefined;
655
656
  query?: undefined;
656
- limit?: undefined;
657
657
  scan_limit?: undefined;
658
658
  max_read_bytes?: undefined;
659
659
  cursor?: undefined;
660
660
  } | {
661
+ limit?: undefined;
661
662
  event_id?: undefined;
662
663
  series_id?: undefined;
663
664
  page?: undefined;
@@ -675,11 +676,11 @@ export declare const meetingTools: ({
675
676
  format?: undefined;
676
677
  transcript_id?: undefined;
677
678
  query?: undefined;
678
- limit?: undefined;
679
679
  scan_limit?: undefined;
680
680
  max_read_bytes?: undefined;
681
681
  cursor?: undefined;
682
682
  } | {
683
+ limit?: undefined;
683
684
  event_id?: undefined;
684
685
  series_id?: undefined;
685
686
  page?: undefined;
@@ -701,7 +702,6 @@ export declare const meetingTools: ({
701
702
  minimum: number;
702
703
  };
703
704
  query?: undefined;
704
- limit?: undefined;
705
705
  scan_limit?: undefined;
706
706
  max_read_bytes?: undefined;
707
707
  cursor?: undefined;
@@ -3,7 +3,7 @@ import { type HitFile } from "../domain/attachments.js";
3
3
  import type { DealKind } from "../domain/deals.js";
4
4
  import { type MailFields } from "../domain/models.js";
5
5
  import type { MessengerTraits } from "../ports/traits.js";
6
- import type { AccountKey, BusinessKind, BusinessSource, MessageStore, StoredAccount } from "../store/store.js";
6
+ import type { AccountKey, BusinessKind, BusinessSource, CopyViewer, MessageStore, StoredAccount } from "../store/store.js";
7
7
  import type { SearchFound, SearchQuery } from "./messages.js";
8
8
  import { type MeaningLane, type MeaningSkipped } from "./messages-discovery.js";
9
9
  import type { SearchCoverage } from "./messages-search.js";
@@ -150,6 +150,8 @@ export interface SearchAllRequest {
150
150
  meetingsAsked?: boolean;
151
151
  /** The CRM kinds `crm` reads; absent, deals and leads. */
152
152
  crmKinds?: readonly DealKind[];
153
+ /** The CRM accounts' copies a CRM CLI's profile may read only part of, each by its own rule (SEC-197). */
154
+ crmViewers?: CopyViewer[];
153
155
  /**
154
156
  * Search harder: a hosted model reorders the first 30 hits, only with the owner's consent and a key. Absent, nothing
155
157
  * is read of the consent or the key and nothing is sent.
@@ -331,6 +331,7 @@ export const searchAll = async (store, account, asked, messenger = {}, searchMes
331
331
  anyWord: anyWord || discover,
332
332
  ...(request.exact ? { exact: true } : {}),
333
333
  ...(request.crmKinds === undefined ? {} : { kinds: request.crmKinds }),
334
+ ...(request.crmViewers === undefined ? {} : { viewers: request.crmViewers }),
334
335
  limit: Math.min(depth, 500),
335
336
  ...(chosen === undefined ? {} : { accounts: chosen }),
336
337
  });
@@ -15,8 +15,23 @@ export interface SetupCheckInput {
15
15
  /** The sign-in events (`progress`, `needs`…) Desktop reads on stderr. */
16
16
  steps: SignInSteps;
17
17
  }
18
- /** The CLI's own proof that the answers work, as its `session start` checks. A throw saves nothing. */
19
- export type SetupCheck = (input: SetupCheckInput) => Promise<Record<string, unknown> | undefined>;
18
+ /**
19
+ * What `apply` keeps in place of its defaults, for a CLI whose `session start` keeps more than the typed secret (an
20
+ * account address beside a token) or knows the account the profile signs in to.
21
+ */
22
+ export interface SetupKeep {
23
+ /** By secret name, the value to keep instead of the one typed; a name the path gave no secret for is refused. */
24
+ secrets?: Readonly<Record<string, string>>;
25
+ /** The account the profile is, as `session start` remembers it; the profile's name when left out. */
26
+ account?: string;
27
+ }
28
+ /**
29
+ * The CLI's own proof that the answers work, as its `session start` checks. A throw saves nothing. `keep` is taken
30
+ * out of the result, never printed.
31
+ */
32
+ export type SetupCheck = (input: SetupCheckInput) => Promise<(Record<string, unknown> & {
33
+ keep?: SetupKeep;
34
+ }) | undefined>;
20
35
  export interface SetupDefinition {
21
36
  app: AppIdentity;
22
37
  configuration: Pick<Configuration, "allSettings" | "settingSchema" | "resolveSettings" | "changeSetting">;
@@ -26,6 +26,7 @@ export { CHAT_COLUMNS, TRACKED_CHAT_COLUMNS, titlePart } from "./sqlite/chats.js
26
26
  export { storeClients } from "./sqlite/clients.js";
27
27
  export { CHAT_LIST_KEY, type ChatCompleteness, type ChatCoverage, fetchedKey, historyStartKey, } from "./sqlite/completeness.js";
28
28
  export { CONVERSATION_COLUMNS } from "./sqlite/conversations.js";
29
+ export { type CopyViewer, seenBy } from "./sqlite/copy-viewer.js";
29
30
  export type { CounterTarget } from "./sqlite/counters.js";
30
31
  export { crmSettingsOf, parseCrmSetting, parseCrmSettingValue, saveCrmSetting } from "./sqlite/crm-settings.js";
31
32
  export { type EmailMarks, MAIL_AGENDA_COLUMNS, type MarkedEmail, type NewestEmail, type ThreadActivity, } from "./sqlite/email-activity.js";
@@ -8,6 +8,7 @@ export { CHAT_COLUMNS, TRACKED_CHAT_COLUMNS, titlePart } from "./sqlite/chats.js
8
8
  export { storeClients } from "./sqlite/clients.js";
9
9
  export { CHAT_LIST_KEY, fetchedKey, historyStartKey, } from "./sqlite/completeness.js";
10
10
  export { CONVERSATION_COLUMNS } from "./sqlite/conversations.js";
11
+ export { seenBy } from "./sqlite/copy-viewer.js";
11
12
  export { crmSettingsOf, parseCrmSetting, parseCrmSettingValue, saveCrmSetting } from "./sqlite/crm-settings.js";
12
13
  export { MAIL_AGENDA_COLUMNS, } from "./sqlite/email-activity.js";
13
14
  export { messageOfEmail, threadConversation } from "./sqlite/emails.js";