@wirecat/cli-core 0.674.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 (62) hide show
  1. package/CHANGELOG.md +101 -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/messenger/search-command.js +3 -1
  9. package/dist/cli/option-hints.d.ts +2 -0
  10. package/dist/cli/option-hints.js +4 -2
  11. package/dist/cli/setup-command.js +9 -3
  12. package/dist/crm/cli/index.d.ts +7 -1
  13. package/dist/crm/cli/index.js +104 -20
  14. package/dist/crm/cli/pipeline-view.js +15 -1
  15. package/dist/crm/cli/records.js +11 -3
  16. package/dist/crm/cli/search-all.d.ts +5 -2
  17. package/dist/crm/cli/search-all.js +15 -3
  18. package/dist/crm/source.d.ts +3 -2
  19. package/dist/crm/stage-tasks.js +1 -1
  20. package/dist/crm/sync.js +13 -11
  21. package/dist/crm/testing/write-contract.js +5 -1
  22. package/dist/crm/viewer.d.ts +28 -0
  23. package/dist/crm/viewer.js +63 -0
  24. package/dist/crm/writer.d.ts +3 -0
  25. package/dist/crm/writes.d.ts +7 -2
  26. package/dist/crm/writes.js +24 -14
  27. package/dist/domain/crm.d.ts +9 -9
  28. package/dist/domain/moment.d.ts +2 -0
  29. package/dist/domain/moment.js +2 -0
  30. package/dist/entities/business-context.js +1 -1
  31. package/dist/entities/deal.d.ts +86 -39
  32. package/dist/entities/deal.js +45 -4
  33. package/dist/entities/index.d.ts +20 -32
  34. package/dist/errors/reasons.js +1 -0
  35. package/dist/meetings/mcp/index.d.ts +15 -15
  36. package/dist/services/search-all.d.ts +3 -1
  37. package/dist/services/search-all.js +1 -0
  38. package/dist/setup/define.d.ts +17 -2
  39. package/dist/store/exports.d.ts +1 -0
  40. package/dist/store/exports.js +1 -0
  41. package/dist/store/sqlite/copy-viewer.d.ts +16 -0
  42. package/dist/store/sqlite/copy-viewer.js +11 -0
  43. package/dist/store/sqlite/crm-activities.d.ts +7 -1
  44. package/dist/store/sqlite/crm-activities.js +32 -5
  45. package/dist/store/sqlite/crm-contacts.d.ts +5 -2
  46. package/dist/store/sqlite/crm-contacts.js +30 -14
  47. package/dist/store/sqlite/crm-rows.d.ts +7 -0
  48. package/dist/store/sqlite/crm-rows.js +37 -5
  49. package/dist/store/sqlite/crm-settings.d.ts +2 -1
  50. package/dist/store/sqlite/crm-settings.js +3 -2
  51. package/dist/store/sqlite/crm-stage-entries.d.ts +24 -4
  52. package/dist/store/sqlite/crm-stage-entries.js +77 -18
  53. package/dist/store/sqlite/crm.d.ts +14 -4
  54. package/dist/store/sqlite/crm.js +59 -7
  55. package/dist/store/sqlite/deals.d.ts +47 -29
  56. package/dist/store/sqlite/deals.js +64 -76
  57. package/dist/store/sqlite/pipeline-period.d.ts +85 -0
  58. package/dist/store/sqlite/pipeline-period.js +199 -0
  59. package/dist/store/sqlite/stage-amounts.d.ts +6 -2
  60. package/dist/store/sqlite/stage-amounts.js +8 -5
  61. package/dist/store/sqlite/vectors.js +5 -3
  62. package/package.json +3 -3
package/CHANGELOG.md CHANGED
@@ -5,6 +5,107 @@ Notable changes to `@wirecat/cli-core` (`@wirecat/cli-messaging` up to 0.261.0,
5
5
  minor version may break callers, and says how under "Changed — may break callers". `pnpm docs:check` checks the
6
6
  shape of this file.
7
7
 
8
+ ## 0.676.0 — 16.11.2026
9
+
10
+ ### Added
11
+
12
+ - **`pipelines show --since-time <time> --until-time <time>`** answers the funnel over the deals or leads made in the
13
+ window and, beside it, `window`, `closed` (won, lost, win rate and won amounts per currency of the rows closed on a
14
+ day in the window, in your time zone), `cycle` (the median days from made to won), `owners` (the window's rows by
15
+ their CRM assignee), `lost_reasons` (the ten most common) and `history` (how many rows had the CRM's own stage
16
+ history). Each stage gains `median_days`, the median stay before a row moved on. The terminal view adds the closed,
17
+ cycle and owner lines.
18
+ - **`deals list` and `leads list` take `updated:`, `created:`, `closed:` and `owner:`**: `updated:>=1d`,
19
+ `created:>=30d`, `closed:[2026-11-01 TO 2026-11-07]` (the day it was won or lost, in your time zone), `owner:me` (the
20
+ sign-in's user, the `self` setting; refused with `crm.owner-unknown` when the CRM names none), `owner:none` and
21
+ `owner:<user id>`. With a time term the answer's `meta` names the time zone and the window.
22
+ - **`deals show` answers `stage_history`**: every stage the deal entered, oldest first, `exact` when the CRM's own
23
+ history gave it.
24
+ - **`stages list` answers `stage_task`** per stage: the title and `due_days` of the task its `stage-tasks` rule
25
+ opens, or `null`.
26
+ - **`people create|update` and `organizations create|update` take `--email <address>` and `--phone <phone>`**, each
27
+ repeated for more, replacing the record's whole list; an empty value clears it. A phone is taken only in
28
+ international form (`+…`) and sent as E.164; anything else is refused with `crm.record-field`.
29
+ - **The copy keeps more of what the CRM says**: a contact's owner, times, page and custom values, a company's owner
30
+ and times, each change of a deal's or lead's owner, and when an activity was done.
31
+ - **An update that gives one of your contacts or companies to another CRM user removes it from the copy**, with its
32
+ phones, e-mails and the activities on it alone. The answer's `removed` says whether it went: `false` when one of
33
+ your deals still names the contact, or you decided about it.
34
+ - **`pipelines show` answers `meta.timezone`**, the zone of its closed days, and `meta.window` with a window.
35
+ `deals list` with two time terms names only the zone.
36
+ - **A setup flow's check can say what `apply` keeps.** The check's result may carry `keep: { secrets, account }`:
37
+ the value kept for a secret the answers gave (amo keeps its account address beside the token, as its
38
+ `session start` does) and the account the profile is. Left out, `apply` keeps the secrets as typed and the
39
+ profile's name, as before. `keep` is never printed.
40
+
41
+ ### Changed — may break callers
42
+
43
+ - **The CRM's stage history is read on every sync**, 90 days back at first, whatever the `stage-tasks` rules: the
44
+ funnel, `deals.stages` and `deals show` count it (`stageEntriesOf`: the CRM's entries for a row that has any, else the
45
+ copy's own changes). An entry on a deal the copy does not hold yet is kept and counts once the deal arrives. A stage
46
+ task opens for an entry made after the rules were first set (the mark beside the setting keeps that time) and in the
47
+ last 7 days, so a deal the copy missed for a sync still gets its task, and one that joins the copy later opens none
48
+ for its older moves. A handled entry is marked in its fields; an entry no stored deal claimed for 90 days is marked
49
+ deleted.
50
+ - **The copy stores a `crm.person` record per contact and a `crm.owner-change` record per owner change**, and an
51
+ activity's record gains `done_at`. `store.crm.removeContact(key, id)` removes one contact by the CRM's id;
52
+ `CrmRecordWritten` gains `removed`.
53
+ - **`createCrmRecord` and `updateCrmRecord` refuse a phone without `+`** that they passed on before.
54
+ - **`pipelines list`, `stages list` and `pipelines show` leave out a stage the CRM removed** unless a row stands in
55
+ it: a caller that reads stages by position sees fewer.
56
+ - **`deal_context.stages[]` gains `exact`** in its strict schema.
57
+ - **`PipelineReport` gains `window`, `closed`, `cycle`, `owners`, `lost_reasons` and `history`**, and
58
+ `deals.pipeline(ref, options)` takes `since` and `until` as a `YYYY-MM-DD` day or an ISO time and `zone`
59
+ (`PipelineOptions`). `StageChange` gains `exact`; its `from` is `null` for the first entry the CRM's history names.
60
+ - **`CrmActivity.on` takes any `CrmKind`**: an activity on a contact or company the copy holds is stored.
61
+ - **`CrmOrganizationFields` has `emails` and `phones`**: a writer maps them; `crmWriteContract` checks a company's
62
+ phone and e-mail.
63
+ - **`queryTerms` takes the fields its caller reads with `nativeTerms`** as a fourth argument.
64
+ - **`CrmRun.user` is required**: the sign-in's own CRM user, read from its sign-in entry without the network (b24 and
65
+ amo: `signInOf(command).userId`), or `null` when the sign-in names none or the CRM limits nobody. Set it in the
66
+ change that bumps this version. With `null`, a CRM that limits its users shows the profile none of the copy's deals
67
+ and leads offline; a copy no sync of this version recorded shows only the profile's own until its next `sync`. Both
68
+ answers say why in a note and carry `complete: false`. A source with `self()` and no `isAdmin()` counts nobody as
69
+ the administrator: give it `isAdmin()` so its administrator reads the whole copy again.
70
+ - **`owner:me` in `deals list` and `leads list` is the profile's own user** (`CrmRun.user`), and the copy's `self`
71
+ setting only when the CLI passes none.
72
+
73
+ ### Fixed
74
+
75
+ - **The funnel counted a deal first synced already lost in no stage**: such a row now reached the first stage,
76
+ so a fresh copy of a CRM no longer overstates the first stage's conversion. A stage the CRM removed leaves pipelines
77
+ and the funnel unless a row stands in it.
78
+ - **A closed deal's `closed_date` moved with every later edit** when the CRM gives no closed day: the day first
79
+ stored stays, until the deal turns from won to lost or back. A first closed day is your day of the CRM's last edit,
80
+ not the UTC one.
81
+ - **A `YYYY-MM-DD` bound of `deals.pipeline` was a UTC day**: it is now the day in `zone`.
82
+ - **A sync whose activities or stage history stop on the run's budget still removes the contacts outside the scope.**
83
+
84
+ ### Security
85
+
86
+ - **A profile reads offline only its own part of another profile's copy.** The copy is kept per CRM account, so a
87
+ profile signed in as an ordinary user on the same account as the administrator read every deal the administrator
88
+ synced, and `search all` found them by their contacts' e-mails and phones. Now `deals list|show`, `leads list|show`,
89
+ `pipelines list|show`, `stages list` and `search all` show such a profile only the deals and leads assigned to its
90
+ user: another one's, or an unassigned one, is `not_found`, and the reports count only its own. `search all` of such a
91
+ profile reads no other CRM account's copy; anyone else's reads each other copy as that copy's owner may, and one with
92
+ no owner not at all. `store status` says its counts are the whole copy's. The CRM's administrator, as the last `sync`
93
+ of that sign-in found, and a CRM that limits nobody read the whole copy as before. See "Offline reads of the copy" in
94
+ `docs/dev/CRM.md`.
95
+
96
+ ## 0.675.0 — 16.11.2026
97
+
98
+ ### Fixed
99
+
100
+ - **`--from` on a search names the sender, not a date.** `search all`, `search messages` and `search conversations`
101
+ answer `--from`, `--sender` and `--author` with `from:<sender>` in the query (in `--filter` for conversations),
102
+ as `from:me` finds what the owner wrote. 0.672.0 answered `--from` with where the dates go.
103
+ - **`search conversations` no longer spends seconds working out which chats are behind.** The check behind the
104
+ "changed since the last build" hint read every chunk of the store once per built chat, because SQLite chose the
105
+ wrong table to start from. It now reads only the chat's own conversations. On a store with about 950,000 messages a
106
+ warm search went from about 12 s to about 3 s. `conversations status` and `conversations embed` use the same query
107
+ and are faster too.
108
+
8
109
  ## 0.674.0 — 16.11.2026
9
110
 
10
111
  ### Added
@@ -24,12 +24,12 @@ export interface DailyArchiveTimerInput {
24
24
  }
25
25
  export declare const dailyArchiveTimer: (input: DailyArchiveTimerInput) => DailyArchiveTimer;
26
26
  export declare const manageDailyArchiveTimer: (plan: DailyArchiveTimer, action: "install" | "start" | "stop" | "status" | "uninstall", system: Pick<ServerSystem, "platform" | "run">, env: NodeJS.ProcessEnv, signal?: AbortSignal) => Promise<{
27
+ action?: undefined;
27
28
  name: string;
28
29
  installed: boolean;
29
30
  active: boolean;
30
31
  servicePath: string;
31
32
  timerPath: string;
32
- action?: undefined;
33
33
  } | {
34
34
  active?: undefined;
35
35
  name: string;
@@ -10,13 +10,13 @@ export declare const calendarTools: ({
10
10
  inputSchema: {
11
11
  type: string;
12
12
  properties: {
13
- limit?: undefined;
14
13
  account_id: {
15
14
  type: string;
16
15
  minimum: number;
17
16
  };
18
17
  query?: undefined;
19
18
  timezone?: undefined;
19
+ limit?: undefined;
20
20
  page?: undefined;
21
21
  event?: undefined;
22
22
  } | {
@@ -45,9 +45,9 @@ export declare const calendarTools: ({
45
45
  };
46
46
  event?: undefined;
47
47
  } | {
48
- limit?: undefined;
49
48
  query?: undefined;
50
49
  timezone?: undefined;
50
+ limit?: undefined;
51
51
  page?: undefined;
52
52
  event: {
53
53
  type: string;
@@ -58,9 +58,9 @@ export declare const calendarTools: ({
58
58
  minimum: number;
59
59
  };
60
60
  } | {
61
- limit?: undefined;
62
61
  query?: undefined;
63
62
  timezone?: undefined;
63
+ limit?: undefined;
64
64
  page?: undefined;
65
65
  event?: undefined;
66
66
  account_id?: undefined;
@@ -80,13 +80,13 @@ export declare const calendarTools: ({
80
80
  inputSchema: {
81
81
  type: string;
82
82
  properties: {
83
- limit?: undefined;
84
83
  account_id: {
85
84
  type: string;
86
85
  minimum: number;
87
86
  };
88
87
  query?: undefined;
89
88
  timezone?: undefined;
89
+ limit?: undefined;
90
90
  page?: undefined;
91
91
  event?: undefined;
92
92
  } | {
@@ -115,9 +115,9 @@ export declare const calendarTools: ({
115
115
  };
116
116
  event?: undefined;
117
117
  } | {
118
- limit?: undefined;
119
118
  query?: undefined;
120
119
  timezone?: undefined;
120
+ limit?: undefined;
121
121
  page?: undefined;
122
122
  event: {
123
123
  type: string;
@@ -128,9 +128,9 @@ export declare const calendarTools: ({
128
128
  minimum: number;
129
129
  };
130
130
  } | {
131
- limit?: undefined;
132
131
  query?: undefined;
133
132
  timezone?: undefined;
133
+ limit?: undefined;
134
134
  page?: undefined;
135
135
  event?: undefined;
136
136
  account_id?: undefined;
@@ -150,13 +150,13 @@ export declare const calendarTools: ({
150
150
  inputSchema: {
151
151
  type: string;
152
152
  properties: {
153
- limit?: undefined;
154
153
  account_id: {
155
154
  type: string;
156
155
  minimum: number;
157
156
  };
158
157
  query?: undefined;
159
158
  timezone?: undefined;
159
+ limit?: undefined;
160
160
  page?: undefined;
161
161
  event?: undefined;
162
162
  } | {
@@ -185,9 +185,9 @@ export declare const calendarTools: ({
185
185
  };
186
186
  event?: undefined;
187
187
  } | {
188
- limit?: undefined;
189
188
  query?: undefined;
190
189
  timezone?: undefined;
190
+ limit?: undefined;
191
191
  page?: undefined;
192
192
  event: {
193
193
  type: string;
@@ -198,9 +198,9 @@ export declare const calendarTools: ({
198
198
  minimum: number;
199
199
  };
200
200
  } | {
201
- limit?: undefined;
202
201
  query?: undefined;
203
202
  timezone?: undefined;
203
+ limit?: undefined;
204
204
  page?: undefined;
205
205
  event?: undefined;
206
206
  account_id?: undefined;
@@ -220,13 +220,13 @@ export declare const calendarTools: ({
220
220
  inputSchema: {
221
221
  type: string;
222
222
  properties: {
223
- limit?: undefined;
224
223
  account_id: {
225
224
  type: string;
226
225
  minimum: number;
227
226
  };
228
227
  query?: undefined;
229
228
  timezone?: undefined;
229
+ limit?: undefined;
230
230
  page?: undefined;
231
231
  event?: undefined;
232
232
  } | {
@@ -255,9 +255,9 @@ export declare const calendarTools: ({
255
255
  };
256
256
  event?: undefined;
257
257
  } | {
258
- limit?: undefined;
259
258
  query?: undefined;
260
259
  timezone?: undefined;
260
+ limit?: undefined;
261
261
  page?: undefined;
262
262
  event: {
263
263
  type: string;
@@ -268,9 +268,9 @@ export declare const calendarTools: ({
268
268
  minimum: number;
269
269
  };
270
270
  } | {
271
- limit?: undefined;
272
271
  query?: undefined;
273
272
  timezone?: undefined;
273
+ limit?: undefined;
274
274
  page?: undefined;
275
275
  event?: undefined;
276
276
  account_id?: undefined;
@@ -56,9 +56,9 @@ export interface CopyAge {
56
56
  }
57
57
  export declare const ageOf: (lastSync: string | undefined, now?: number) => CopyAge;
58
58
  export declare const staleCopy: (provider: string, lastSync: string | undefined, now?: number) => {
59
+ next?: undefined;
59
60
  readonly missing?: undefined;
60
61
  meta?: undefined;
61
- next?: undefined;
62
62
  } | {
63
63
  missing: {
64
64
  field: string;
@@ -45,7 +45,7 @@ export { withoutPhone } from "../services/people.js";
45
45
  export { unanswered } from "../services/questions.js";
46
46
  export { openRequestTask } from "../services/task-rules.js";
47
47
  export { TASK_PAIR_QUERY, TASK_QUERY } from "../services/tasks.js";
48
- export { defineSetup, type Setup, type SetupCheck, type SetupCheckInput, type SetupDefinition, setupProblems, } from "../setup/define.js";
48
+ export { defineSetup, type Setup, type SetupCheck, type SetupCheckInput, type SetupDefinition, type SetupKeep, setupProblems, } from "../setup/define.js";
49
49
  export { type Asset as SetupAsset, BLOCK_ROLES, BLOCK_TYPES, type Block as SetupBlock, BUILT_IN_ACTIONS, type Condition as SetupCondition, DISPLAY_CLASSES, INPUT_KINDS, SETUP_FORMAT, SETUP_LIMITS, SETUP_PATTERNS, SETUP_VERSION, type SetupDocument, type Step as SetupStep, setupDocumentSchema, setupJsonSchema, } from "../setup/document.js";
50
50
  export { answerStdinOption, type Need, type SignInSteps, type SignInStepsOptions, signInSteps, } from "../terminal/sign-in-steps.js";
51
51
  export { type AccountRemoval, type AccountRemovalContext, type AccountRemoveOptions, type AccountSecrets, accountRemoveCommand, mayRevoke, type SignedOut, } from "./account-remove.js";
@@ -51,9 +51,10 @@ export declare const nativeTerms: (ast: QueryAst | undefined, command: string) =
51
51
  export declare const nativeTermLists: (ast: QueryAst | undefined, command: string, repeatable?: readonly string[], negatable?: readonly string[]) => Map<string, Predicate[]>;
52
52
  /**
53
53
  * A store that compares whole values: each field's `field:value` or `field:"two words"`, enum values lowercased
54
- * as validation already accepts them. A range or wildcard is refused rather than read as a value.
54
+ * as validation already accepts them. A range or wildcard is refused rather than read as a value. `ranged` are fields
55
+ * the caller reads itself, with `nativeTerms`: they are left out.
55
56
  */
56
- export declare const queryTerms: (words: QueryWords, registry: QueryRegistry, command: string) => Map<string, string>;
57
+ export declare const queryTerms: (words: QueryWords, registry: QueryRegistry, command: string, ranged?: readonly string[]) => Map<string, string>;
57
58
  /**
58
59
  * A `time` term as epoch ms bounds: `time>=7d`, `time:[2026-10-01 TO 2026-10-07]`, `time:today`, and the `meta`
59
60
  * an answer reports them by: the zone calendar words and bare dates were read in, and the bounds in UTC.
@@ -147,11 +147,14 @@ export const nativeTermLists = (ast, command, repeatable = [], negatable = []) =
147
147
  };
148
148
  /**
149
149
  * A store that compares whole values: each field's `field:value` or `field:"two words"`, enum values lowercased
150
- * as validation already accepts them. A range or wildcard is refused rather than read as a value.
150
+ * as validation already accepts them. A range or wildcard is refused rather than read as a value. `ranged` are fields
151
+ * the caller reads itself, with `nativeTerms`: they are left out.
151
152
  */
152
- export const queryTerms = (words, registry, command) => {
153
+ export const queryTerms = (words, registry, command, ranged = []) => {
153
154
  const terms = new Map();
154
155
  for (const [field, node] of nativeTerms(listQuery(typedQuery(words), registry, command), command)) {
156
+ if (ranged.includes(field))
157
+ continue;
155
158
  if (node.operator !== "term" && node.operator !== "phrase")
156
159
  queryError("query.unsupported-placement", node.span, `${field} takes one whole value here`, {
157
160
  command,
@@ -5,7 +5,7 @@ import { SAVE_HELP } from "../../meetings/index.js";
5
5
  import { searchNotesOf } from "../../services/notes-search.js";
6
6
  import { LOCAL_READ, REMOTE_READ } from "../effects.js";
7
7
  import { renderAnswer } from "../envelope.js";
8
- import { AROUND_HINT, END_FLAGS, hintsFor, START_FLAGS, withOptionHints } from "../option-hints.js";
8
+ import { AROUND_HINT, END_FLAGS, hintsFor, SENDER_FLAGS, START_FLAGS, withOptionHints } from "../option-hints.js";
9
9
  import { positiveCount } from "../paging.js";
10
10
  import { runsSearchCommand } from "../runs/search-command.js";
11
11
  import { commandAt } from "../steps.js";
@@ -198,6 +198,7 @@ export const searchCommand = (messenger, { topics = false } = {}) => {
198
198
  : {
199
199
  "--chat": `search in one chat with chat:<chat> in the query: search ${path} 'chat:<chat> words'`,
200
200
  "--around": AROUND_HINT,
201
+ ...hintsFor(SENDER_FLAGS, `the sender goes in the query: search ${path} 'from:<sender> words' (from:me for you)`),
201
202
  }),
202
203
  ...(path === "all" ? {} : { "--only": ONLY_HINT }),
203
204
  });
@@ -209,6 +210,7 @@ export const searchCommand = (messenger, { topics = false } = {}) => {
209
210
  ...hintsFor(END_FLAGS, "put the end in the filter: --filter 'date<2026-10-20'"),
210
211
  "--around": AROUND_HINT,
211
212
  "--only": ONLY_HINT,
213
+ ...hintsFor(SENDER_FLAGS, "the sender goes in the filter: --filter 'from:<sender>' (from:me for you)"),
212
214
  });
213
215
  return search;
214
216
  };
@@ -9,4 +9,6 @@ export declare const hintsFor: (flags: readonly string[], hint: string) => Recor
9
9
  /** Date flags agents guess; commander would suggest an unrelated near name (`--since` → `--source`). */
10
10
  export declare const START_FLAGS: string[];
11
11
  export declare const END_FLAGS: string[];
12
+ /** In a message search `--from` means the sender, as `from:` does in the query, never a date. */
13
+ export declare const SENDER_FLAGS: string[];
12
14
  export declare const AROUND_HINT: string;
@@ -16,7 +16,9 @@ export const withOptionHints = (command, hints) => {
16
16
  /** The same hint for each of these flags. */
17
17
  export const hintsFor = (flags, hint) => Object.fromEntries(flags.map((flag) => [flag, hint]));
18
18
  /** Date flags agents guess; commander would suggest an unrelated near name (`--since` → `--source`). */
19
- export const START_FLAGS = ["--since", "--after", "--from", "--since-date", "--after-date", "--start"];
20
- export const END_FLAGS = ["--until", "--before", "--to", "--until-date", "--before-date", "--end"];
19
+ export const START_FLAGS = ["--since", "--after", "--since-date", "--after-date", "--start"];
20
+ export const END_FLAGS = ["--until", "--before", "--until-date", "--before-date", "--end"];
21
+ /** In a message search `--from` means the sender, as `from:` does in the query, never a date. */
22
+ export const SENDER_FLAGS = ["--from", "--sender", "--author"];
21
23
  export const AROUND_HINT = "read the messages either side of one: messages context <hit ref> --before-n 5 --after-n 5 " +
22
24
  "(or messages context <chat> <message>)";
@@ -134,7 +134,7 @@ export const setupCommand = (setup) => {
134
134
  for (const [setting, value] of Object.entries(path.settings))
135
135
  refuseGuardedKey(setting, String(value), ownerOnly);
136
136
  steps.progress("check", `checking ${profile}'s settings`);
137
- const checked = (await check?.({
137
+ const { keep = {}, ...checked } = (await check?.({
138
138
  command,
139
139
  profile,
140
140
  settings: { ...settings, configured: { ...settings.configured, ...path.settings } },
@@ -142,11 +142,17 @@ export const setupCommand = (setup) => {
142
142
  answers: path.kept,
143
143
  steps,
144
144
  })) ?? {};
145
+ const secrets = { ...path.secrets };
146
+ for (const [name, secret] of Object.entries(keep.secrets ?? {})) {
147
+ if (!(name in secrets))
148
+ throw new Error(`the flow's check keeps secret ${name}, which the answers did not give`);
149
+ secrets[name] = secret;
150
+ }
145
151
  for (const [setting, value] of Object.entries(path.settings))
146
152
  configuration.changeSetting(settings.configPath, { profile, setting, value: JSON.stringify(value) });
147
153
  const store = storeFor(command, context.renderer.warn);
148
- const kept = Object.entries(path.secrets).map(([name, secret]) => name === "token" ? store.write(profile, secret) : store.writeSecret(profile, name, secret));
149
- rememberAccount(app, profile, profile, env);
154
+ const kept = Object.entries(secrets).map(([name, secret]) => name === "token" ? store.write(profile, secret) : store.writeSecret(profile, name, secret));
155
+ rememberAccount(app, profile, keep.account ?? profile, env);
150
156
  return {
151
157
  outcome: "ok",
152
158
  ...told,
@@ -1,7 +1,7 @@
1
1
  import { type Command } from "commander";
2
2
  import { type Body } from "../../cli/envelope.js";
3
3
  import type { AppIdentity } from "../../ports/app.js";
4
- import type { MessageStore } from "../../store/store.js";
4
+ import { type MessageStore } from "../../store/store.js";
5
5
  import type { AccountKey } from "../../store/types.js";
6
6
  import type { CrmSource } from "../source.js";
7
7
  import type { CrmWriteCapabilities } from "../writer.js";
@@ -22,6 +22,12 @@ export interface CrmRun {
22
22
  store: MessageStore;
23
23
  /** The CRM, built on first use: a command that only reads the store never reads the sign-in. */
24
24
  source: () => CrmSource;
25
+ /**
26
+ * The sign-in's own user id in the CRM, as the sign-in entry keeps it, read without the network. The copy's deals
27
+ * and leads read offline are only this user's unless a sync found it the CRM's administrator; `null`, a CRM that
28
+ * limits its users shows none of them (SEC-197). A CRM that limits nobody passes `null`.
29
+ */
30
+ user: string | null;
25
31
  /** A profile lock pins the process (WC-ACCT-5): `search all` then reads only this account's deals. */
26
32
  locked?: boolean;
27
33
  /** The CRM's writer and the profile's levels, built on first use; needed by every write command. */