@wirecat/cli-core 0.675.0 → 0.677.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 (74) hide show
  1. package/CHANGELOG.md +104 -0
  2. package/dist/calendar/mcp/index.d.ts +12 -12
  3. package/dist/cli/command-runs.d.ts +2 -0
  4. package/dist/cli/command-runs.js +2 -0
  5. package/dist/cli/documents/words.d.ts +1 -1
  6. package/dist/cli/index.d.ts +2 -2
  7. package/dist/cli/index.js +1 -1
  8. package/dist/cli/list-query.d.ts +3 -2
  9. package/dist/cli/list-query.js +5 -2
  10. package/dist/cli/setup-command.js +9 -3
  11. package/dist/crm/cli/index.d.ts +7 -1
  12. package/dist/crm/cli/index.js +104 -20
  13. package/dist/crm/cli/pipeline-view.js +15 -1
  14. package/dist/crm/cli/records.js +11 -3
  15. package/dist/crm/cli/search-all.d.ts +5 -2
  16. package/dist/crm/cli/search-all.js +15 -3
  17. package/dist/crm/source.d.ts +3 -2
  18. package/dist/crm/stage-tasks.js +1 -1
  19. package/dist/crm/sync.js +13 -11
  20. package/dist/crm/testing/write-contract.js +5 -1
  21. package/dist/crm/viewer.d.ts +28 -0
  22. package/dist/crm/viewer.js +63 -0
  23. package/dist/crm/writer.d.ts +3 -0
  24. package/dist/crm/writes.d.ts +7 -2
  25. package/dist/crm/writes.js +24 -14
  26. package/dist/domain/crm.d.ts +9 -9
  27. package/dist/domain/moment.d.ts +2 -0
  28. package/dist/domain/moment.js +2 -0
  29. package/dist/entities/business-context.js +1 -1
  30. package/dist/entities/deal.d.ts +86 -39
  31. package/dist/entities/deal.js +45 -4
  32. package/dist/entities/index.d.ts +20 -32
  33. package/dist/errors/reasons.js +2 -0
  34. package/dist/meetings/mcp/index.d.ts +15 -15
  35. package/dist/services/metadata.d.ts +1 -1
  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/identity-links.d.ts +73 -0
  42. package/dist/store/identity-links.js +14 -0
  43. package/dist/store/index.d.ts +1 -1
  44. package/dist/store/index.js +1 -1
  45. package/dist/store/people.d.ts +23 -1
  46. package/dist/store/people.js +12 -1
  47. package/dist/store/sqlite/agent-links.d.ts +34 -0
  48. package/dist/store/sqlite/agent-links.js +184 -0
  49. package/dist/store/sqlite/copy-viewer.d.ts +16 -0
  50. package/dist/store/sqlite/copy-viewer.js +11 -0
  51. package/dist/store/sqlite/crm-activities.d.ts +7 -1
  52. package/dist/store/sqlite/crm-activities.js +32 -5
  53. package/dist/store/sqlite/crm-contacts.d.ts +5 -2
  54. package/dist/store/sqlite/crm-contacts.js +30 -14
  55. package/dist/store/sqlite/crm-rows.d.ts +7 -0
  56. package/dist/store/sqlite/crm-rows.js +37 -5
  57. package/dist/store/sqlite/crm-settings.d.ts +2 -1
  58. package/dist/store/sqlite/crm-settings.js +3 -2
  59. package/dist/store/sqlite/crm-stage-entries.d.ts +24 -4
  60. package/dist/store/sqlite/crm-stage-entries.js +77 -18
  61. package/dist/store/sqlite/crm.d.ts +14 -4
  62. package/dist/store/sqlite/crm.js +59 -7
  63. package/dist/store/sqlite/deals.d.ts +47 -29
  64. package/dist/store/sqlite/deals.js +64 -76
  65. package/dist/store/sqlite/identity-proposals.d.ts +2 -0
  66. package/dist/store/sqlite/identity-proposals.js +2 -0
  67. package/dist/store/sqlite/person-match-scan.d.ts +29 -0
  68. package/dist/store/sqlite/person-match-scan.js +4 -4
  69. package/dist/store/sqlite/person-merges.d.ts +3 -0
  70. package/dist/store/sqlite/pipeline-period.d.ts +85 -0
  71. package/dist/store/sqlite/pipeline-period.js +199 -0
  72. package/dist/store/sqlite/stage-amounts.d.ts +6 -2
  73. package/dist/store/sqlite/stage-amounts.js +8 -5
  74. package/package.json +3 -3
package/CHANGELOG.md CHANGED
@@ -5,6 +5,110 @@ 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.677.0 — 16.11.2026
9
+
10
+ ### Added
11
+
12
+ - **An agent's link of two people merges at once on strong evidence** (`people.agentLink`). The store
13
+ decides, never the agent's word: one value only these two people hold, a mobile number or a personal address, from
14
+ two different sources, and for a phone at least one that keeps its user's own number (a messenger account or a
15
+ call's number). Anything weaker, the owner's own person, a pair the owner rejected, or `apply: false` opens a
16
+ proposal as before, whose payload now says why it is not strong (`strength`). The merge is recorded as an
17
+ `identity_link` the agent decided, with the evidence, the reason and the run, and `undoMerge` gives both people back.
18
+ - **`people.linkEvidence(pairs)`** answers what each pair of people shares and whether it is strong, reading the store
19
+ once; **`people.agentMerges()`** lists the agents' merges still in place; **`people.merges()`** names the agent, run,
20
+ reason and evidence of an agent's merge (`agent`).
21
+ - **`commandRunId()`** (`@wirecat/cli-core/cli`) gives the id `runs show` takes for the command under way, so a write
22
+ can name the run that made it.
23
+
24
+ ## 0.676.0 — 16.11.2026
25
+
26
+ ### Added
27
+
28
+ - **`pipelines show --since-time <time> --until-time <time>`** answers the funnel over the deals or leads made in the
29
+ window and, beside it, `window`, `closed` (won, lost, win rate and won amounts per currency of the rows closed on a
30
+ day in the window, in your time zone), `cycle` (the median days from made to won), `owners` (the window's rows by
31
+ their CRM assignee), `lost_reasons` (the ten most common) and `history` (how many rows had the CRM's own stage
32
+ history). Each stage gains `median_days`, the median stay before a row moved on. The terminal view adds the closed,
33
+ cycle and owner lines.
34
+ - **`deals list` and `leads list` take `updated:`, `created:`, `closed:` and `owner:`**: `updated:>=1d`,
35
+ `created:>=30d`, `closed:[2026-11-01 TO 2026-11-07]` (the day it was won or lost, in your time zone), `owner:me` (the
36
+ sign-in's user, the `self` setting; refused with `crm.owner-unknown` when the CRM names none), `owner:none` and
37
+ `owner:<user id>`. With a time term the answer's `meta` names the time zone and the window.
38
+ - **`deals show` answers `stage_history`**: every stage the deal entered, oldest first, `exact` when the CRM's own
39
+ history gave it.
40
+ - **`stages list` answers `stage_task`** per stage: the title and `due_days` of the task its `stage-tasks` rule
41
+ opens, or `null`.
42
+ - **`people create|update` and `organizations create|update` take `--email <address>` and `--phone <phone>`**, each
43
+ repeated for more, replacing the record's whole list; an empty value clears it. A phone is taken only in
44
+ international form (`+…`) and sent as E.164; anything else is refused with `crm.record-field`.
45
+ - **The copy keeps more of what the CRM says**: a contact's owner, times, page and custom values, a company's owner
46
+ and times, each change of a deal's or lead's owner, and when an activity was done.
47
+ - **An update that gives one of your contacts or companies to another CRM user removes it from the copy**, with its
48
+ phones, e-mails and the activities on it alone. The answer's `removed` says whether it went: `false` when one of
49
+ your deals still names the contact, or you decided about it.
50
+ - **`pipelines show` answers `meta.timezone`**, the zone of its closed days, and `meta.window` with a window.
51
+ `deals list` with two time terms names only the zone.
52
+ - **A setup flow's check can say what `apply` keeps.** The check's result may carry `keep: { secrets, account }`:
53
+ the value kept for a secret the answers gave (amo keeps its account address beside the token, as its
54
+ `session start` does) and the account the profile is. Left out, `apply` keeps the secrets as typed and the
55
+ profile's name, as before. `keep` is never printed.
56
+
57
+ ### Changed — may break callers
58
+
59
+ - **The CRM's stage history is read on every sync**, 90 days back at first, whatever the `stage-tasks` rules: the
60
+ funnel, `deals.stages` and `deals show` count it (`stageEntriesOf`: the CRM's entries for a row that has any, else the
61
+ 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
62
+ task opens for an entry made after the rules were first set (the mark beside the setting keeps that time) and in the
63
+ 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
64
+ for its older moves. A handled entry is marked in its fields; an entry no stored deal claimed for 90 days is marked
65
+ deleted.
66
+ - **The copy stores a `crm.person` record per contact and a `crm.owner-change` record per owner change**, and an
67
+ activity's record gains `done_at`. `store.crm.removeContact(key, id)` removes one contact by the CRM's id;
68
+ `CrmRecordWritten` gains `removed`.
69
+ - **`createCrmRecord` and `updateCrmRecord` refuse a phone without `+`** that they passed on before.
70
+ - **`pipelines list`, `stages list` and `pipelines show` leave out a stage the CRM removed** unless a row stands in
71
+ it: a caller that reads stages by position sees fewer.
72
+ - **`deal_context.stages[]` gains `exact`** in its strict schema.
73
+ - **`PipelineReport` gains `window`, `closed`, `cycle`, `owners`, `lost_reasons` and `history`**, and
74
+ `deals.pipeline(ref, options)` takes `since` and `until` as a `YYYY-MM-DD` day or an ISO time and `zone`
75
+ (`PipelineOptions`). `StageChange` gains `exact`; its `from` is `null` for the first entry the CRM's history names.
76
+ - **`CrmActivity.on` takes any `CrmKind`**: an activity on a contact or company the copy holds is stored.
77
+ - **`CrmOrganizationFields` has `emails` and `phones`**: a writer maps them; `crmWriteContract` checks a company's
78
+ phone and e-mail.
79
+ - **`queryTerms` takes the fields its caller reads with `nativeTerms`** as a fourth argument.
80
+ - **`CrmRun.user` is required**: the sign-in's own CRM user, read from its sign-in entry without the network (b24 and
81
+ amo: `signInOf(command).userId`), or `null` when the sign-in names none or the CRM limits nobody. Set it in the
82
+ change that bumps this version. With `null`, a CRM that limits its users shows the profile none of the copy's deals
83
+ and leads offline; a copy no sync of this version recorded shows only the profile's own until its next `sync`. Both
84
+ answers say why in a note and carry `complete: false`. A source with `self()` and no `isAdmin()` counts nobody as
85
+ the administrator: give it `isAdmin()` so its administrator reads the whole copy again.
86
+ - **`owner:me` in `deals list` and `leads list` is the profile's own user** (`CrmRun.user`), and the copy's `self`
87
+ setting only when the CLI passes none.
88
+
89
+ ### Fixed
90
+
91
+ - **The funnel counted a deal first synced already lost in no stage**: such a row now reached the first stage,
92
+ so a fresh copy of a CRM no longer overstates the first stage's conversion. A stage the CRM removed leaves pipelines
93
+ and the funnel unless a row stands in it.
94
+ - **A closed deal's `closed_date` moved with every later edit** when the CRM gives no closed day: the day first
95
+ 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,
96
+ not the UTC one.
97
+ - **A `YYYY-MM-DD` bound of `deals.pipeline` was a UTC day**: it is now the day in `zone`.
98
+ - **A sync whose activities or stage history stop on the run's budget still removes the contacts outside the scope.**
99
+
100
+ ### Security
101
+
102
+ - **A profile reads offline only its own part of another profile's copy.** The copy is kept per CRM account, so a
103
+ profile signed in as an ordinary user on the same account as the administrator read every deal the administrator
104
+ synced, and `search all` found them by their contacts' e-mails and phones. Now `deals list|show`, `leads list|show`,
105
+ `pipelines list|show`, `stages list` and `search all` show such a profile only the deals and leads assigned to its
106
+ user: another one's, or an unassigned one, is `not_found`, and the reports count only its own. `search all` of such a
107
+ profile reads no other CRM account's copy; anyone else's reads each other copy as that copy's owner may, and one with
108
+ no owner not at all. `store status` says its counts are the whole copy's. The CRM's administrator, as the last `sync`
109
+ of that sign-in found, and a CRM that limits nobody read the whole copy as before. See "Offline reads of the copy" in
110
+ `docs/dev/CRM.md`.
111
+
8
112
  ## 0.675.0 — 16.11.2026
9
113
 
10
114
  ### Fixed
@@ -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;
@@ -57,6 +57,8 @@ export interface CommandRuns {
57
57
  events(event: RequestEvent): void;
58
58
  }
59
59
  export declare const commandRuns: (options: CommandRunOptions) => CommandRuns;
60
+ /** The id `runs show` takes for the command under way, so a write can name the run that made it. */
61
+ export declare const commandRunId: () => string | undefined;
60
62
  /**
61
63
  * For a provider client far from the program: the event lands in the current command's run — a `startCli` command's,
62
64
  * or the run `run()` opened — or nowhere.
@@ -111,6 +111,8 @@ const tracker = (options, typed) => {
111
111
  };
112
112
  export const commandRuns = (options) => tracker(options);
113
113
  const parses = new AsyncLocalStorage();
114
+ /** The id `runs show` takes for the command under way, so a write can name the run that made it. */
115
+ export const commandRunId = () => parses.getStore()?.runs.runId();
114
116
  /**
115
117
  * For a provider client far from the program: the event lands in the current command's run — a `startCli` command's,
116
118
  * or the run `run()` opened — or nowhere.
@@ -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";
@@ -72,7 +72,7 @@ export { PressLog, UpdatesCursor } from "./bot/updates.js";
72
72
  export { addCallStatsCommand, type CallStatsCommandDeps, type CallStatsRead } from "./call-stats-command.js";
73
73
  export type { CommandAvailability, DiscoveredCommand } from "./command-availability.js";
74
74
  export { commandContract, type JsonSchema, SCHEMA_DIALECT } from "./command-contract.js";
75
- export { type CommandRunOptions, type CommandRuns, commandRuns, type ProviderAnswer, type ProviderCall, providerEvent, providerRequest, type RunSettings, recordRuns, runSettings, type SavedRunSettings, } from "./command-runs.js";
75
+ export { type CommandRunOptions, type CommandRuns, commandRunId, commandRuns, type ProviderAnswer, type ProviderCall, providerEvent, providerRequest, type RunSettings, recordRuns, runSettings, type SavedRunSettings, } from "./command-runs.js";
76
76
  export { CONTRACT } from "./commands-command.js";
77
77
  export { type CompactOptions, compactText, entityRows, GENERIC_ROW, type RowColumn, type RowShape, type RowsResolver, type RowTable, type RowValue, rowShapeOf, rowsOfEntity, SHARED_ROWS, } from "./compact.js";
78
78
  export type { AppCompletionOptions, CompletionRequest } from "./complete-command.js";
package/dist/cli/index.js CHANGED
@@ -64,7 +64,7 @@ export { BotTokenStore } from "./bot/token.js";
64
64
  export { PressLog, UpdatesCursor } from "./bot/updates.js";
65
65
  export { addCallStatsCommand } from "./call-stats-command.js";
66
66
  export { commandContract, SCHEMA_DIALECT } from "./command-contract.js";
67
- export { commandRuns, providerEvent, providerRequest, recordRuns, runSettings, } from "./command-runs.js";
67
+ export { commandRunId, commandRuns, providerEvent, providerRequest, recordRuns, runSettings, } from "./command-runs.js";
68
68
  export { CONTRACT } from "./commands-command.js";
69
69
  export { compactText, entityRows, GENERIC_ROW, rowShapeOf, rowsOfEntity, SHARED_ROWS, } from "./compact.js";
70
70
  export { refuseUnknownKey } from "./config-command.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,
@@ -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. */