@wirecat/cli-core 0.661.0 → 0.663.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 (201) hide show
  1. package/CHANGELOG.md +109 -0
  2. package/dist/background/daily-archive-timer.d.ts +1 -1
  3. package/dist/calendar/cli/bodies.js +2 -1
  4. package/dist/calendar/cli/index.js +13 -10
  5. package/dist/calendar/mcp/index.d.ts +3 -1
  6. package/dist/calendar/mcp/index.js +4 -4
  7. package/dist/cli/ai-model-command.js +3 -3
  8. package/dist/cli/call-stats-command.d.ts +18 -0
  9. package/dist/cli/call-stats-command.js +52 -0
  10. package/dist/cli/command-availability.d.ts +1 -1
  11. package/dist/cli/command-availability.js +4 -4
  12. package/dist/cli/contract-templates.js +2 -0
  13. package/dist/cli/dry-run-guard.js +7 -5
  14. package/dist/cli/early-refusal.d.ts +1 -1
  15. package/dist/cli/early-refusal.js +2 -2
  16. package/dist/cli/effects.d.ts +9 -2
  17. package/dist/cli/effects.js +16 -4
  18. package/dist/cli/envelope.d.ts +0 -5
  19. package/dist/cli/envelope.js +25 -0
  20. package/dist/cli/index.d.ts +3 -2
  21. package/dist/cli/index.js +3 -2
  22. package/dist/cli/meeting-batch.d.ts +2 -1
  23. package/dist/cli/meeting-batch.js +7 -5
  24. package/dist/cli/meeting-preparation-command.js +5 -5
  25. package/dist/cli/meeting-preparation-read.d.ts +5 -5
  26. package/dist/cli/meeting-preparation-read.js +13 -21
  27. package/dist/cli/meeting-series-inventory-command.js +2 -2
  28. package/dist/cli/meeting-series-inventory-read.d.ts +2 -2
  29. package/dist/cli/meeting-series-inventory-read.js +7 -15
  30. package/dist/cli/messenger/admin-moderation-command.js +2 -2
  31. package/dist/cli/messenger/admin-statistics-command.js +2 -2
  32. package/dist/cli/messenger/archive-commands.js +2 -2
  33. package/dist/cli/messenger/context.d.ts +2 -2
  34. package/dist/cli/messenger/context.js +5 -3
  35. package/dist/cli/messenger/counters-command.js +2 -2
  36. package/dist/cli/messenger/media-archive-command.js +5 -4
  37. package/dist/cli/messenger/media-archive-move-command.js +1 -1
  38. package/dist/cli/messenger/media-archive-timer-command.js +5 -4
  39. package/dist/cli/messenger/metadata-command.js +3 -3
  40. package/dist/cli/messenger/rankings-command.js +3 -3
  41. package/dist/cli/messenger/tags-command.js +7 -2
  42. package/dist/cli/messenger/tasks-command.js +4 -3
  43. package/dist/cli/paging.d.ts +10 -0
  44. package/dist/cli/paging.js +29 -0
  45. package/dist/cli/preview.js +3 -5
  46. package/dist/cli/program.js +2 -2
  47. package/dist/cli/runs/command.js +6 -4
  48. package/dist/cli/runs/search-command.js +9 -5
  49. package/dist/cli/schedule/schedule-command.js +1 -5
  50. package/dist/cli/shadowed-options.d.ts +7 -0
  51. package/dist/cli/shadowed-options.js +26 -0
  52. package/dist/crm/cli/index.js +4 -2
  53. package/dist/domain/moment.d.ts +29 -0
  54. package/dist/domain/moment.js +58 -0
  55. package/dist/domain/providers.d.ts +6 -4
  56. package/dist/domain/providers.js +10 -5
  57. package/dist/domain/send-time.d.ts +3 -4
  58. package/dist/domain/send-time.js +10 -24
  59. package/dist/entities/fields.d.ts +2 -2
  60. package/dist/entities/fields.js +2 -2
  61. package/dist/entities/index.d.ts +92 -1
  62. package/dist/entities/index.js +3 -2
  63. package/dist/entities/meeting.d.ts +1 -1
  64. package/dist/entities/meeting.js +1 -1
  65. package/dist/errors/reasons.js +0 -1
  66. package/dist/kit/sync-after-install.d.ts +10 -1
  67. package/dist/kit/sync-after-install.js +35 -11
  68. package/dist/mail/cli/index.js +4 -2
  69. package/dist/mail/facts.d.ts +5 -2
  70. package/dist/mail/facts.js +6 -3
  71. package/dist/mail/index.d.ts +1 -1
  72. package/dist/mail/meeting-notes.js +1 -1
  73. package/dist/mail/probe.d.ts +5 -2
  74. package/dist/mail/probe.js +9 -5
  75. package/dist/mail/server-search.js +4 -4
  76. package/dist/mail/sync.js +1 -1
  77. package/dist/mcp/meeting-preparation.js +1 -1
  78. package/dist/mcp/meeting-series-inventory.js +1 -1
  79. package/dist/mcp/prompts.js +6 -9
  80. package/dist/mcp/server.js +4 -4
  81. package/dist/mcp/tool.js +3 -3
  82. package/dist/meetings/call-answers.d.ts +106 -0
  83. package/dist/meetings/call-answers.js +171 -0
  84. package/dist/meetings/call-stats.d.ts +121 -0
  85. package/dist/meetings/call-stats.js +211 -0
  86. package/dist/meetings/calls.d.ts +76 -0
  87. package/dist/meetings/calls.js +78 -0
  88. package/dist/meetings/cli/index.d.ts +8 -0
  89. package/dist/meetings/cli/index.js +10 -22
  90. package/dist/meetings/cli/search.d.ts +9 -2
  91. package/dist/meetings/cli/search.js +16 -26
  92. package/dist/meetings/index.d.ts +3 -0
  93. package/dist/meetings/index.js +3 -0
  94. package/dist/meetings/mcp/index.d.ts +21 -18
  95. package/dist/meetings/mcp/index.js +2 -4
  96. package/dist/meetings/mcp/search.d.ts +6 -1
  97. package/dist/meetings/mcp/search.js +3 -3
  98. package/dist/meetings/read-through.d.ts +2 -1
  99. package/dist/meetings/read-through.js +10 -1
  100. package/dist/meetings/stats.d.ts +3 -0
  101. package/dist/meetings/stats.js +3 -3
  102. package/dist/meetings/testing/index.d.ts +1 -0
  103. package/dist/meetings/testing/index.js +1 -0
  104. package/dist/meetings/testing/paging.d.ts +6 -0
  105. package/dist/meetings/testing/paging.js +5 -0
  106. package/dist/moderation/rules.d.ts +2 -0
  107. package/dist/moderation/rules.js +16 -2
  108. package/dist/search/fusion.d.ts +17 -0
  109. package/dist/search/fusion.js +17 -0
  110. package/dist/search/lucene/resolved.d.ts +2 -0
  111. package/dist/search/question-plan.d.ts +2 -0
  112. package/dist/search/question-plan.js +5 -0
  113. package/dist/search/service-query.d.ts +6 -1
  114. package/dist/search/service-query.js +9 -1
  115. package/dist/sends/guard.js +4 -20
  116. package/dist/sends/keyed-guard.d.ts +1 -1
  117. package/dist/sends/keyed-guard.js +2 -1
  118. package/dist/sends/permissions.d.ts +14 -0
  119. package/dist/sends/permissions.js +32 -0
  120. package/dist/services/agenda-mail.js +2 -1
  121. package/dist/services/agenda.js +5 -3
  122. package/dist/services/attachments.js +4 -2
  123. package/dist/services/call-stats.d.ts +17 -0
  124. package/dist/services/call-stats.js +41 -0
  125. package/dist/services/chats.js +4 -2
  126. package/dist/services/conversations.js +4 -2
  127. package/dist/services/deps.d.ts +1 -1
  128. package/dist/services/document-source.d.ts +1 -1
  129. package/dist/services/document-source.js +4 -3
  130. package/dist/services/documents/ingestion.js +11 -40
  131. package/dist/services/documents/plan.d.ts +1 -1
  132. package/dist/services/documents/plan.js +30 -17
  133. package/dist/services/documents/ports.d.ts +5 -0
  134. package/dist/services/documents/sync.js +1 -1
  135. package/dist/services/embeddings-search.js +20 -4
  136. package/dist/services/events-search.js +2 -1
  137. package/dist/services/index.d.ts +1 -0
  138. package/dist/services/index.js +1 -0
  139. package/dist/services/mail-search.d.ts +1 -1
  140. package/dist/services/mail-search.js +10 -11
  141. package/dist/services/media-archive-move.js +2 -4
  142. package/dist/services/media-archive.d.ts +0 -1
  143. package/dist/services/media-archive.js +2 -12
  144. package/dist/services/meeting-combined.js +1 -1
  145. package/dist/services/messages-combined.js +15 -4
  146. package/dist/services/moderation.js +10 -2
  147. package/dist/services/moment.d.ts +4 -10
  148. package/dist/services/moment.js +16 -44
  149. package/dist/services/notes-search.d.ts +0 -2
  150. package/dist/services/notes-search.js +1 -2
  151. package/dist/services/search-all.js +2 -1
  152. package/dist/services/server-search.js +1 -1
  153. package/dist/services/tags.js +4 -2
  154. package/dist/services/task-stats.js +2 -2
  155. package/dist/services/tasks.js +2 -2
  156. package/dist/store/accounts.js +2 -1
  157. package/dist/store/sqlite/account-purge.d.ts +3 -0
  158. package/dist/store/sqlite/account-purge.js +143 -0
  159. package/dist/store/sqlite/accounts.d.ts +0 -2
  160. package/dist/store/sqlite/accounts.js +2 -134
  161. package/dist/store/sqlite/calendar.d.ts +1 -0
  162. package/dist/store/sqlite/calendar.js +5 -5
  163. package/dist/store/sqlite/catalog.js +2 -16
  164. package/dist/store/sqlite/chats.js +2 -1
  165. package/dist/store/sqlite/context-document-source.d.ts +3 -3
  166. package/dist/store/sqlite/context-document-source.js +9 -7
  167. package/dist/store/sqlite/context-evidence.js +9 -3
  168. package/dist/store/sqlite/document-listing.js +2 -1
  169. package/dist/store/sqlite/events.js +2 -1
  170. package/dist/store/sqlite/file-note.d.ts +6 -0
  171. package/dist/store/sqlite/file-note.js +15 -0
  172. package/dist/store/sqlite/files.d.ts +3 -2
  173. package/dist/store/sqlite/files.js +5 -3
  174. package/dist/store/sqlite/identities.js +2 -1
  175. package/dist/store/sqlite/imported-documents.js +2 -2
  176. package/dist/store/sqlite/knowledge.js +19 -19
  177. package/dist/store/sqlite/lucene-fields.js +8 -12
  178. package/dist/store/sqlite/mail-rules.js +2 -1
  179. package/dist/store/sqlite/meeting-calls.d.ts +4 -0
  180. package/dist/store/sqlite/meeting-calls.js +66 -0
  181. package/dist/store/sqlite/meetings.d.ts +2 -2
  182. package/dist/store/sqlite/meetings.js +4 -1
  183. package/dist/store/sqlite/mention-sources.js +2 -1
  184. package/dist/store/sqlite/mentions.js +2 -2
  185. package/dist/store/sqlite/messages.js +6 -1
  186. package/dist/store/sqlite/note-search.js +8 -11
  187. package/dist/store/sqlite/notes.d.ts +2 -0
  188. package/dist/store/sqlite/notes.js +24 -13
  189. package/dist/store/sqlite/organizations.js +2 -2
  190. package/dist/store/sqlite/people-list.js +3 -3
  191. package/dist/store/sqlite/query-filter.d.ts +3 -3
  192. package/dist/store/sqlite/query-filter.js +3 -3
  193. package/dist/store/sqlite/reads.d.ts +4 -4
  194. package/dist/store/sqlite/reads.js +4 -4
  195. package/dist/store/sqlite/search.js +11 -7
  196. package/dist/store/sqlite/test-accounts.js +1 -1
  197. package/dist/store/sqlite/trigram-match.d.ts +9 -0
  198. package/dist/store/sqlite/trigram-match.js +28 -0
  199. package/dist/store/sqlite/work-tasks.js +1 -1
  200. package/package.json +3 -3
  201. package/parity.json +2 -1
package/CHANGELOG.md CHANGED
@@ -5,6 +5,115 @@ 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.663.0 — 14.11.2026
9
+
10
+ ### Added
11
+
12
+ - **`stats calls show` reports a business's phone calls as one JSON answer (`call_stats`).** A CLI whose meetings are
13
+ calls (pbx, beeline) mounts it with `addCallStatsCommand` from `@wirecat/cli-core/cli`. It counts calls by
14
+ direction and outcome; per employee the calls placed, answered and rung but not answered, with talk and wait time;
15
+ calls by hour and by day in `--timezone`; missed incoming calls and whether the client was called back within
16
+ `--within` (default 1d), even when the callback falls after `--until-time`; and answered calls shorter than 30
17
+ seconds. A number the phone system does not record, such as Beeline's outcome and wait, is left out and
18
+ counted under `known`, never shown as zero. The parts are separate: `callOf` reads a meeting as a call, `aggregateCallStats` is
19
+ the arithmetic, `meetingCalls` on the store reads the selection, and `readCallStats` joins them.
20
+ - **A synced node can be a folder and a document at once.** `syncDocuments` takes an optional
21
+ `isDocument(file)`: a folder it answers yes for, such as a Notion or Confluence page with sub-pages, is walked
22
+ for its children and imported itself, a selected root page included. Without it nothing changes: Drive's
23
+ folders are still only walked. See [DOCUMENTS.md, "Bind a provider"](docs/dev/DOCUMENTS.md#bind-a-provider).
24
+ - **Any documents provider gets documents accounts, not only Google Drive.** A CLI whose provider entry has
25
+ kind `documents` (and is not `imported`) can call `notes.documentsAccount` and `documentIngestion({ provider })`
26
+ for its own principals, and `documentsAccounts()` lists them beside Drive's. A document whose front matter names
27
+ such a provider in `source` is kept as Drive's are: placed by its catalog parents, never joined by content to a
28
+ copy in a notes folder, and its `sourceUrl` and `modifiedAt` stand in when no file row gives them. `google-drive`
29
+ is now in the provider seed, so Drive behaves the same before drive has written its entry. See
30
+ [DOCUMENTS.md, "Bind a provider"](docs/dev/DOCUMENTS.md#bind-a-provider).
31
+
32
+ ### Changed — may break callers
33
+
34
+ - **The store has no ceiling of 10 000 entries on a documents account any more** (owner's ruling, 2026-11-14). `catalog.list`
35
+ no longer refuses an account over 10 000 entries or 32 MB of metadata, `catalog.reconcile` takes any number of
36
+ ids, and `documentIngestion`'s catalog import takes any number of files, written 200 at a time. A sync no longer
37
+ reads every document of the account into memory before its first save: each save and removal looks up its one
38
+ document with the new `notes.fileNote(folderId, path)`. One catalog write still takes at most 200 entries and one
39
+ list page at most 1000, and a sync still walks at most the `maxEntries` its CLI passes (drive passes 10 000), so
40
+ a CLI raises that to sync more. Speed and memory at 10 000, 50 000 and 100 000 entries are measured in
41
+ [cli-testing](https://github.com/WireCatLabs/cli-testing/tree/main/performance/documents/catalog-scale).
42
+ A store that implements `NotesStore` itself must add `fileNote`. The `catalog.scope-limit` reason is gone;
43
+ nothing raised it any more. The `observed` callback is the only reason the import reads its entries back, so an
44
+ import without one no longer does.
45
+ - **`meetings` commands take the program's `--json [fields]` and `--jsonl`,** not their own on/off flags, so
46
+ `meetings list --json id,title` keeps those fields and `--json --jsonl` together is no longer refused.
47
+ - **Lists without `--limit` show the configured `defaults.limit`** (20 unless set), capped at the command's maximum,
48
+ not their own number: `meetings list`, `events list`, `search events`, `search meetings` (also inside
49
+ `meetings batch`), `runs list`, `search runs`, admin reports, rankings evidence, `stats messages counters`,
50
+ `metadata sync` and `tags rebuild` (these two drop from 50 to 20). The MCP tools `meetings_list`, `events_list` and
51
+ `search_meetings` page by the host's configured limit, not 100.
52
+ - **Hosts pass `pagingOf`** (exported from `@wirecat/cli-core/cli`) to `addMeetingCommands` and
53
+ `addMeetingSearchCommand`. Changed signatures: `meetingHitSearchRequest(query, flags, limit, signal?)`,
54
+ `prepareMeetingBatch(input, reader, meta, limit)`, `callMeetingTool(store, name, input, { limit, failure? })`,
55
+ `callCalendarTool(…, { accountIds, limit, … })`, `callMeetingSearchTool(search, input, { limit, signal?,
56
+ failure? })`. `flagPaging` in `@wirecat/cli-core/meetings/testing` pages bare test roots.
57
+ - **`search events --cursor 0` is refused;** a cursor comes from `page.next_cursor`.
58
+ - **`zonedTime` is `typedTime`** and no longer demands a zone.
59
+ - **Moderation needs a named profile** and never falls back to `default`; a missing one lists the profiles to name.
60
+ - **`factsOf` (mail) is async** and takes a required "written to" lookup.
61
+ - **`find` also matches words shorter than three letters,** so `find AI bot` returns fewer, more exact hits.
62
+ - **Time errors read** `--x takes an ISO 8601 time, today, yesterday, or 30m, 2h, 1d ago — not "…"` (and `… from
63
+ now` for future times).
64
+ - **Needs `@wirecat/cli-base` 0.100.0,** whose query dates take a time without seconds or without an offset.
65
+ - **`store clear --allow-dangerous` and `admin moderate --allow-dangerous` are the owner's alone.** Their MCP tools
66
+ no longer take `allow_dangerous`, as with every other delete that cannot be undone: an agent previews with
67
+ `dry_run`, and the owner runs the command in a terminal.
68
+
69
+ ### Fixed
70
+
71
+ - **Every time flag takes one grammar:** ISO with or without seconds and zone, a space for `T`, a date alone,
72
+ `today`, `yesterday`, `30m`/`2h`/`7d`. This now holds for `meetings sync`, `search meetings`, `meetings prepare`,
73
+ `meetings scheduled` (CLI and MCP), the media archive (`download`, `jobs install --since-time`,
74
+ `move --before-time`) and `schedule --at-time`. One parser reads every future time.
75
+ - **A list query's dates read the computer's zone** for every list (`created_at>"2026-11-14 23:00"` too), and the
76
+ answer names it in `meta.timezone`.
77
+ - **The MCP review and catch-up prompts pass `since` as a full instant,** so `2026-11-13T18:00+01:00` and `2h` work.
78
+ - **Mail presets count a correspondent from stored outgoing mail too,** so a resumed sync, or an account synced
79
+ without Sent, no longer skips their new mail.
80
+ - **`--discover` never fails with "use a longer prefix"** on words the user typed whole, and `search all` keeps its
81
+ messages part.
82
+ - **Trigram searches treat ё and е as one letter** (`find`, `chats list title:`, people and contacts search).
83
+ - **Mail beside messages, and files beside written notes, are ordered by rank in each source,** not by raw scores
84
+ from different indexes; conversations search too.
85
+ - **`changes` reports a message a later fetch brought back after its deletion** as new.
86
+ - **Removing an account clears its calendars, mail rules, reminders and proposed actions** instead of failing on a
87
+ foreign key.
88
+ - **A command's own `--yes` or `--timeout` gets its value.** The root program declares both, and the value went to
89
+ the root alone, so `meetings repair --yes` only previewed, `models consents set --yes` and
90
+ `models search-consents set --yes` changed nothing, and `search-consents set --timeout 2m` stored no wait. Every
91
+ option a command shares with the root now gets the value too, through the command's own parser. A CLI that copied
92
+ the root's values itself can drop that copy.
93
+ - **`tasks scan` and the CRM kit's `store apply` take `yes` over MCP.** Both read the root's `--yes`, which a tool
94
+ call cannot pass, so an agent could only preview them.
95
+
96
+ ## 0.662.0 — 14.11.2026
97
+
98
+ ### Added
99
+
100
+ - **`writesOwnerFiles(command)`** marks a command that writes the owner's files outside the store through a folder it
101
+ does not take as an option, such as a saved job's folder. It stays a write that `readonly` stops.
102
+ - **`syncAfterInstallCases` takes `profileLevels`** (`{ variable, keys }`): for each key, the sync must run with the
103
+ profile's own level at `readonly` and be refused at `deny`.
104
+
105
+ ### Changed — may break callers
106
+
107
+ - **A `readonly` level no longer stops a sync.** A command that only fetches from the service into the local store
108
+ (`fetchesOnly`: `sync`, `messages sync`, `contacts sync`, `metadata sync`, `store gaps repair`,
109
+ `stats messages counters sync`) runs under any `readonly` level: the profile's own key, a group key such as
110
+ `messages`, or setup's "read only" answer. This holds on the command line, in `--dry-run` previews, in help and
111
+ over MCP. `--sync-first` and a server search run at `readonly` too. `deny` still refuses them. A profile that
112
+ relied on `readonly` to stop syncing now syncs; set the key to `deny` to stop it.
113
+ - **An MCP server no longer offers a sign-in through its read tool.** A command marked `logsInOrOut` that fetches
114
+ (`session start`) counts as a write over MCP. On the command line nothing changes.
115
+ - **`models ai check` is marked as reaching another service**, so `readonly` stops its paid request.
116
+
8
117
  ## 0.661.0 — 14.11.2026
9
118
 
10
119
  ### 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;
@@ -1,5 +1,6 @@
1
1
  import { CliError } from "@wirecat/cli-base";
2
2
  import { itemOf, listOf, snakeKeys } from "../../cli/envelope.js";
3
+ import { pagingOf } from "../../cli/paging.js";
3
4
  /** The command's words below the program, as `page.next` and `sync`'s next step rerun it. */
4
5
  export const pathOf = (command) => command.parent?.parent ? [...pathOf(command.parent), command.name()] : [command.name()];
5
6
  const snakeMeta = (meta) => meta === undefined ? undefined : snakeKeys(meta);
@@ -29,7 +30,7 @@ export const hitsBody = (command, value) => {
29
30
  const untrusted = (value.untrusted ?? []).filter((field) => field.startsWith("hits.")).map((f) => f.slice(5));
30
31
  const { next, ...list } = listOf(pathOf(command).join(" "), {
31
32
  items: value.hits.map((hit) => snakeKeys({ ...hit, untrusted })),
32
- limit: opts.limit,
33
+ limit: pagingOf(command).limit,
33
34
  has_more: value.has_more === true,
34
35
  paging: "cursor",
35
36
  ...(typeof value.next_offset === "number" ? { cursor: String(value.next_offset) } : {}),
@@ -9,6 +9,7 @@ import { changesStore, ownerOnlyOption, writesFileOnlyWith } from "../../cli/eff
9
9
  import { renderAnswer } from "../../cli/envelope.js";
10
10
  import { queryTerms, withQuery } from "../../cli/list-query.js";
11
11
  import { terminalAsker } from "../../cli/messenger/ask.js";
12
+ import { pagingOf } from "../../cli/paging.js";
12
13
  import { lineOf } from "../../cli/steps.js";
13
14
  import { secretInput } from "../../runs/run-context.js";
14
15
  import { searchEvents } from "../../services/events-search.js";
@@ -280,11 +281,12 @@ const addCalendarCommandsDefinition = (program, options) => {
280
281
  };
281
282
  const events = annotate(program.command("events").description("the account's stored events"), { effects: GROUP });
282
283
  example(withQuery(annotate(events.command("list"), { effects: LOCAL_READ, partial: true }).description("list stored events, earliest first; --source reads several accounts as one list"), EVENTS_QUERY).addHelpText("after", EVENTS_QUERY_NOTE), "events list 'starts_at:[2026-11-02 TO 2026-11-07}' --json", "events list ends_at>=today person:ana@example.com", "events list overlapping:true --source all")
283
- .option("--limit <n>", "events per page, 1–1000", integer, 100)
284
- .option("--page <n>", "which page, starting at 1", integer, 1)
284
+ .option("--limit <n>", "events per page, 1–1000; the profile's defaults.limit when absent", upTo(1000))
285
+ .option("--page <n>", "which page, starting at 1", integer)
285
286
  .option("--source <accounts>", "calendar accounts held in the store to read as one list: all, a provider, or a list such as " +
286
287
  `${options.app.command}:work,${options.app.command}:personal or group:<name>; the profile's account when absent`)
287
288
  .action(async (words, opts, command) => {
289
+ const { limit, page } = pagingOf(command);
288
290
  await within(command, async (run) => {
289
291
  const own = { id: run.accountId, key: run.account };
290
292
  const { accounts, skipped } = opts.source === undefined
@@ -300,7 +302,7 @@ const addCalendarCommandsDefinition = (program, options) => {
300
302
  now: now(),
301
303
  personOf: personId(run),
302
304
  });
303
- return listBody(command, eachMarked(await eventsAnswer(run.store, filter && { ...filter, limit: opts.limit }, opts.page), EVENT_ITEM_UNTRUSTED), { ...(await accountsMeta(run.store, accounts, skipped, now())), ...clockMeta(now(), zone()) });
305
+ return listBody(command, eachMarked(await eventsAnswer(run.store, filter && { ...filter, limit }, page), EVENT_ITEM_UNTRUSTED), { ...(await accountsMeta(run.store, accounts, skipped, now())), ...clockMeta(now(), zone()) });
304
306
  });
305
307
  });
306
308
  const exporter = example(withQuery(annotate(events.command("export"), { effects: LOCAL_WRITE }).description(`write stored events as iCalendar (.ics), at most ${EXPORT_MAX}: one with id:<id>, or those the query ` +
@@ -374,8 +376,8 @@ const addCalendarCommandsDefinition = (program, options) => {
374
376
  .argument("<query...>", "what to find in titles, descriptions, places and attendees"), "search events roadmap planning --json", ...(options.serverSearch
375
377
  ? ["search events --backend server quarterly review", "search events --backend both quarterly review"]
376
378
  : []))
377
- .option("--limit <n>", "events per page", integer, 20)
378
- .option("--cursor <cursor>", "go on from where the last page stopped; page.next gives it", (text) => (text === "0" ? 0 : integer(text)), 0)
379
+ .option("--limit <n>", "events per page; the profile's defaults.limit when absent", integer)
380
+ .option("--cursor <cursor>", "go on from the previous page's page.next_cursor, with the same query", integer)
379
381
  .option("--exact", "every word as written, no word stems")
380
382
  .option("--newest", "latest start first instead of best first");
381
383
  if (options.serverSearch)
@@ -385,6 +387,7 @@ const addCalendarCommandsDefinition = (program, options) => {
385
387
  .choices(["archive", "server", "both"])
386
388
  .default("archive"));
387
389
  search.action(async (words, opts, command) => {
390
+ const { limit } = pagingOf(command);
388
391
  const flag = `search events --backend ${opts.backend}`;
389
392
  const server = opts.backend === "server" || opts.backend === "both";
390
393
  if (server) {
@@ -396,14 +399,14 @@ const addCalendarCommandsDefinition = (program, options) => {
396
399
  throw new CliError("validation_error", `${flag} takes no --exact: the provider matches words its own way`, {
397
400
  reason: "search.server-options",
398
401
  });
399
- if (opts.cursor || opts.newest)
402
+ if (opts.cursor !== undefined || opts.newest)
400
403
  throw new CliError("validation_error", `${flag} takes neither --cursor nor --newest: the provider ranks and pages its own hits`, { reason: "search.server-options" });
401
404
  }
402
405
  await within(command, async (run) => {
403
406
  const archived = () => searchEvents(messagesOf(run, "search"), words.join(" "), {
404
407
  accounts: [run.account],
405
- limit: opts.limit,
406
- offset: opts.cursor,
408
+ limit,
409
+ offset: opts.cursor ?? 0,
407
410
  timezone: zone(),
408
411
  command: options.app.command,
409
412
  ...(opts.exact ? { exact: true } : {}),
@@ -423,12 +426,12 @@ const addCalendarCommandsDefinition = (program, options) => {
423
426
  accountId: run.accountId,
424
427
  account: run.account,
425
428
  query: words.join(" "),
426
- limit: opts.limit,
429
+ limit,
427
430
  });
428
431
  if (opts.backend === "server")
429
432
  return hitsBody(command, { ...served, untrusted: SERVER_SEARCH_UNTRUSTED });
430
433
  return hitsBody(command, {
431
- ...(await bothSearchAnswer(run.store, run.accountId, await archived(), served, opts.limit)),
434
+ ...(await bothSearchAnswer(run.store, run.accountId, await archived(), served, limit)),
432
435
  untrusted: SEARCH_UNTRUSTED,
433
436
  });
434
437
  });
@@ -1464,8 +1464,10 @@ export declare const calendarWriteTools: ({
1464
1464
  * Runs one calendar tool over the accounts the host serves. Without `account_id` a tool reads every one of them and
1465
1465
  * names them in `accounts`; with one it must be among them.
1466
1466
  */
1467
- export declare const callCalendarTool: (store: EventStore, name: string, input: unknown, { accountIds, failure, now, writes, profileOf, }: {
1467
+ export declare const callCalendarTool: (store: EventStore, name: string, input: unknown, { accountIds, limit, failure, now, writes, profileOf, }: {
1468
1468
  accountIds: readonly number[];
1469
+ /** `events_list`'s page without `limit`: the profile's `defaults.limit`, as the messenger MCP lists take it. */
1470
+ limit: number;
1469
1471
  /** What `status` calls each account's sync. */
1470
1472
  profileOf?: (accountId: number) => string;
1471
1473
  failure?: FailureContext;
@@ -215,7 +215,7 @@ const argumentsOf = (name, input) => {
215
215
  * Runs one calendar tool over the accounts the host serves. Without `account_id` a tool reads every one of them and
216
216
  * names them in `accounts`; with one it must be among them.
217
217
  */
218
- export const callCalendarTool = async (store, name, input, { accountIds, failure = {}, now = Date.now(), writes, profileOf = (accountId) => `account ${accountId}`, }) => {
218
+ export const callCalendarTool = async (store, name, input, { accountIds, limit, failure = {}, now = Date.now(), writes, profileOf = (accountId) => `account ${accountId}`, }) => {
219
219
  const writing = WRITES.has(name);
220
220
  try {
221
221
  const args = argumentsOf(name, input);
@@ -247,7 +247,7 @@ export const callCalendarTool = async (store, name, input, { accountIds, failure
247
247
  answer = listed((await Promise.all(accounts.map((id) => calendarStatus(store, id, { profile: profileOf(id), now }).then(({ items }) => items)))).flat());
248
248
  break;
249
249
  case "events_list":
250
- answer = await eventsList(store, args, accounts, now);
250
+ answer = await eventsList(store, args, accounts, now, limit);
251
251
  break;
252
252
  case "event_show": {
253
253
  const { accountId, details } = await eventIn();
@@ -283,8 +283,8 @@ const EVENTS_READ = 1000;
283
283
  * One page of events across the accounts. Page n of several accounts is not each account's page n, so each one is
284
284
  * read from its first event up to the page's end and the merge is cut there.
285
285
  */
286
- const eventsList = async (store, args, accounts, now) => {
287
- const limit = args.limit ?? 100;
286
+ const eventsList = async (store, args, accounts, now, configured) => {
287
+ const limit = args.limit ?? configured;
288
288
  const page = args.page ?? 1;
289
289
  const end = page * limit;
290
290
  const merging = accounts.length > 1;
@@ -6,7 +6,7 @@ import { localOnly, localOnlyRefusal } from "../models/local-only.js";
6
6
  import { agentOf } from "../runs/run-context.js";
7
7
  import { readSecret } from "../terminal/prompt.js";
8
8
  import { environmentOf } from "./context.js";
9
- import { FETCH, grantsAuthority, LOCAL_READ, LOCAL_WRITE, NO_EFFECTS } from "./effects.js";
9
+ import { FETCH, grantsAuthority, LOCAL_READ, LOCAL_WRITE, NO_EFFECTS, reachesOtherService } from "./effects.js";
10
10
  import { itemOf } from "./envelope.js";
11
11
  const imagesNote = (setting) => `images you add to memory are sent to ${new URL(aiBaseUrl(setting)).host} to be read${setting.provider === "ollama" ? " (on this computer)" : ", so they leave this computer"}`;
12
12
  const view = (app, options, setting) => {
@@ -175,12 +175,12 @@ export const aiModelCommand = (app, options) => {
175
175
  writeAiSetting(path, kept);
176
176
  options.output(itemOf({ ...view(app, options, kept), changed: images !== undefined }), this);
177
177
  });
178
- annotate(ai.command("check"), {
178
+ reachesOtherService(annotate(ai.command("check"), {
179
179
  effects: FETCH,
180
180
  mcp: false,
181
181
  output: { entity: "ai_model_check" },
182
182
  examples: [`${app.command} models ai check`],
183
- })
183
+ }))
184
184
  .summary("send one short paid request and say what is wrong")
185
185
  .description("send one short request (billed by the provider, usually under a cent) and say what is wrong")
186
186
  .option("--from-app", "you did this in WireCat Desktop")
@@ -0,0 +1,18 @@
1
+ import { type Command } from "commander";
2
+ import type { CallStatsAnswer, CallStatsRequest } from "../services/call-stats.js";
3
+ import { type Body } from "./envelope.js";
4
+ export type CallStatsRead = (request: Omit<CallStatsRequest, "accountId">) => Promise<CallStatsAnswer>;
5
+ export interface CallStatsCommandDeps {
6
+ /** The calls of the profile's own account; opened when the command runs. */
7
+ read: () => Promise<CallStatsRead>;
8
+ signal?: () => AbortSignal | undefined;
9
+ /** Prints the answer; cli-core's renderer when not given. A host that closes its store first passes its own. */
10
+ output?: (body: Body, command: Command) => void;
11
+ /** One to three examples that run as written, with the host's command and a profile. */
12
+ examples: string[];
13
+ }
14
+ /**
15
+ * `stats calls show`, for a host whose meetings are phone calls: it mounts the command, so a host of video meetings
16
+ * never shows it. Numbers over the stored calls only; nothing is read from the phone system.
17
+ */
18
+ export declare const addCallStatsCommand: (program: Command, deps: CallStatsCommandDeps) => void;
@@ -0,0 +1,52 @@
1
+ import { annotate } from "@wirecat/cli-base/commands";
2
+ import { timezoneOf } from "@wirecat/cli-base/query";
3
+ import { InvalidArgumentError } from "commander";
4
+ import { parseDuration } from "../domain/duration.js";
5
+ import { callStatsItem } from "../meetings/index.js";
6
+ import { dateWindow } from "../services/moment.js";
7
+ import { outputFor } from "./context.js";
8
+ import { LOCAL_READ, NO_EFFECTS } from "./effects.js";
9
+ import { itemOf, renderAnswer } from "./envelope.js";
10
+ const positive = (value) => {
11
+ if (!/^[1-9]\d*$/.test(value) || !Number.isSafeInteger(Number(value)))
12
+ throw new InvalidArgumentError("expected a positive integer");
13
+ return Number(value);
14
+ };
15
+ /**
16
+ * `stats calls show`, for a host whose meetings are phone calls: it mounts the command, so a host of video meetings
17
+ * never shows it. Numbers over the stored calls only; nothing is read from the phone system.
18
+ */
19
+ export const addCallStatsCommand = (program, deps) => {
20
+ const stats = program.commands.find((command) => command.name() === "stats") ??
21
+ annotate(program.command("stats"), { effects: NO_EFFECTS }).description("statistics");
22
+ const calls = annotate(stats.command("calls"), { effects: NO_EFFECTS }).description("numbers about the stored phone calls");
23
+ annotate(calls.command("show"), { effects: LOCAL_READ, output: { entity: "call_stats" }, examples: deps.examples })
24
+ .summary("calls by direction, outcome, employee, hour and day; missed calls and callbacks")
25
+ .description("calls by direction and outcome, per employee, by hour and by day; missed incoming calls and whether the " +
26
+ "client was called back; short calls. What the phone system does not record is counted as unknown")
27
+ .option("--since-time <time>", "calls starting at or after this date or time (ISO 8601, or 30d ago)")
28
+ .option("--until-time <time>", "calls starting at or before this date or time; a date alone is that whole day")
29
+ .option("--timezone <zone>", "the IANA zone hours and days are read in (default: this computer's)")
30
+ .option("--person-id <id>", "only calls this stored person took part in; a phone system that keeps no one who only rang misses those", positive)
31
+ .option("--within <duration>", "how long after a missed call a callback counts (default 1d)", (value) => parseDuration(value, "--within"))
32
+ .option("--limit <n>", "most missed calls listed one by one, newest first (default 100); all are counted", positive)
33
+ .action(async (flags, command) => {
34
+ const zone = timezoneOf(flags.timezone);
35
+ const window = dateWindow({ sinceTime: flags.sinceTime, untilTime: flags.untilTime, zone });
36
+ const signal = deps.signal?.();
37
+ const found = await (await deps.read())({
38
+ ...(window.since === undefined ? {} : { since: window.since }),
39
+ ...(window.until === undefined ? {} : { until: window.until }),
40
+ ...(flags.personId === undefined ? {} : { personId: flags.personId }),
41
+ ...(flags.within === undefined ? {} : { callbackWithinMs: flags.within }),
42
+ ...(flags.limit === undefined ? {} : { missedLimit: flags.limit }),
43
+ ...(signal ? { signal } : {}),
44
+ timeZone: zone,
45
+ });
46
+ const body = itemOf(callStatsItem(found), { meta: { ...window.meta, timezone: zone } });
47
+ if (deps.output)
48
+ deps.output(body, command);
49
+ else
50
+ renderAnswer(command, outputFor(command), body);
51
+ });
52
+ };
@@ -16,5 +16,5 @@ export interface CommandAvailability {
16
16
  }
17
17
  /** Discovery and execution use the same permission decision. */
18
18
  export declare const commandAvailability: (info: AvailabilityCommand, levels: Readonly<Record<PermissionKey, Level>>, keyOf?: (path: readonly string[]) => PermissionKey | null | undefined, authority?: (path: readonly string[]) => boolean, readOnly?: boolean, mcp?: boolean, declared?: CommandPermissions,
19
- /** Whether a command only fetches into the store (`fetchesOnlyAt`): setup's "read only" answer lets it run. */
19
+ /** Whether a command only fetches into the store (`fetchesOnlyAt`): a `readonly` level lets it run. */
20
20
  fetches?: (path: readonly string[]) => boolean) => CommandAvailability;
@@ -1,13 +1,13 @@
1
1
  import { writes } from "@wirecat/cli-base/standards";
2
- import { AUTHORITY_KEY, authorityAllowed, BOT_API_KEY, botApiAllowed, CEILING_KEY, isBotApi, keyForCommand, levelFor, readKeysForCommand, } from "../sends/permissions.js";
2
+ import { AUTHORITY_KEY, authorityAllowed, BOT_API_KEY, botApiAllowed, isBotApi, keyForCommand, levelFor, readKeysForCommand, } from "../sends/permissions.js";
3
3
  import { changesMessenger } from "./effects.js";
4
4
  /** Discovery and execution use the same permission decision. */
5
5
  export const commandAvailability = (info, levels, keyOf, authority, readOnly = false, mcp = true, declared,
6
- /** Whether a command only fetches into the store (`fetchesOnlyAt`): setup's "read only" answer lets it run. */
6
+ /** Whether a command only fetches into the store (`fetchesOnlyAt`): a `readonly` level lets it run. */
7
7
  fetches) => {
8
8
  const declaredKey = declared?.keyOf(info.path);
9
9
  const key = declared ? declaredKey : (keyOf?.(info.path) ?? keyForCommand(info.path));
10
- const { level, key: named } = key ? levelFor(levels, key, declared?.defaults) : { level: "allow", key: null };
10
+ const { level } = key ? levelFor(levels, key, declared?.defaults) : { level: "allow" };
11
11
  const judged = { ...(key ? { permission: key } : {}), level };
12
12
  const blocked = (reason, permission) => ({
13
13
  available: false,
@@ -27,7 +27,7 @@ fetches) => {
27
27
  return blocked(`the profile requires ${BOT_API_KEY}: allow`, BOT_API_KEY);
28
28
  if (level === "deny")
29
29
  return blocked(`the profile denies ${key}`);
30
- if (level === "readonly" && writes(info.effects) && !(named === CEILING_KEY && fetches?.(info.path) === true))
30
+ if (level === "readonly" && writes(info.effects) && fetches?.(info.path) !== true)
31
31
  return blocked(`${key} is readonly in this profile`);
32
32
  const denied = (declared ? [] : readKeysForCommand(info.path)).find((read) => levelFor(levels, read).level === "deny");
33
33
  return denied ? blocked(`the profile denies ${denied}`, denied) : { available: true, ...judged };
@@ -9,6 +9,7 @@ import { unfilteredQuery, withQuery } from "./list-query.js";
9
9
  import { doctorCommand } from "./messenger/doctor-command.js";
10
10
  import { mcpCommand } from "./messenger/mcp-command.js";
11
11
  import { searchCommand } from "./messenger/search-command.js";
12
+ import { pagingOf } from "./paging.js";
12
13
  import { settingsFor } from "./settings.js";
13
14
  /**
14
15
  * `search all` as it was before meetings became one of its sources: cli-memo, zoom-cli and drive-cli review their
@@ -68,6 +69,7 @@ export const sharedCommandTemplate = (app, name) => {
68
69
  get store() {
69
70
  return unavailable();
70
71
  },
72
+ pagingOf,
71
73
  accountId: 0,
72
74
  write: unavailable,
73
75
  inRun: unavailable,
@@ -5,6 +5,7 @@ import { outputFor } from "./context.js";
5
5
  import { changesAuthority } from "./effects.js";
6
6
  import { itemOf, renderAnswer, snakeKeys } from "./envelope.js";
7
7
  import { previewBody } from "./preview.js";
8
+ import { shareShadowedOptions } from "./shadowed-options.js";
8
9
  const descendants = (command, into = new Set()) => {
9
10
  into.add(command);
10
11
  for (const child of command.commands)
@@ -18,13 +19,14 @@ const descendants = (command, into = new Set()) => {
18
19
  */
19
20
  const previewWrites = (messenger) => (hooked, action) => {
20
21
  // Each command carries its own hook, so one a CLI moves under its own group keeps it.
21
- if (hooked !== action || action.optsWithGlobals().dryRun !== true)
22
+ if (hooked !== action)
22
23
  return;
23
- // `run` hands the global flag to a command's own --dry-run; another host's program does not.
24
- if (action.options.some((option) => option.long === "--dry-run")) {
25
- action.setOptionValue("dryRun", true);
24
+ // `run` hands a global flag to the command's own option of that name; another host's program does not.
25
+ shareShadowedOptions(action);
26
+ if (action.optsWithGlobals().dryRun !== true)
27
+ return;
28
+ if (action.options.some((option) => option.long === "--dry-run"))
26
29
  return;
27
- }
28
30
  if (!writes(metaOf(action).effects) && !changesAuthority(action))
29
31
  return;
30
32
  // Commander reads the handler after the hooks, so swapping it here stops the write; each run builds its program anew.
@@ -30,7 +30,7 @@ export declare const refuseWriteBeforeConnecting: (action: Command, { app, env,
30
30
  }) => void;
31
31
  /**
32
32
  * A command of a CLI that declares its own keys (`commandPermissions`), refused by its key before anything connects:
33
- * `deny` stops it, `readonly` stops a write (setup's "read only" answer still lets a fetch into the store run), and
33
+ * `deny` stops it, `readonly` stops a write but lets a fetch into the store run, whichever key set it, and
34
34
  * the read-only lock stops a write to the service; a command that declares no effects counts as both. `ask` is left to the write
35
35
  * guard, which can put the question. A saved or `--permission` key that names no command stops every keyed command;
36
36
  * housekeeping still runs, so `config unset` can remove it. Under the lock a non-messenger CLI still previews a
@@ -96,7 +96,7 @@ export const refuseWriteBeforeConnecting = (action, { app, env, dryRun, resolve
96
96
  };
97
97
  /**
98
98
  * A command of a CLI that declares its own keys (`commandPermissions`), refused by its key before anything connects:
99
- * `deny` stops it, `readonly` stops a write (setup's "read only" answer still lets a fetch into the store run), and
99
+ * `deny` stops it, `readonly` stops a write but lets a fetch into the store run, whichever key set it, and
100
100
  * the read-only lock stops a write to the service; a command that declares no effects counts as both. `ask` is left to the write
101
101
  * guard, which can put the question. A saved or `--permission` key that names no command stops every keyed command;
102
102
  * housekeeping still runs, so `config unset` can remove it. Under the lock a non-messenger CLI still previews a
@@ -126,7 +126,7 @@ export const refuseByCommandPermissions = (action, permissions, { app, env, dryR
126
126
  throw new CliError("permission_error", `profile ${settings.profile} denies ${key} (permissions.${named} is deny, from the ` +
127
127
  `${settings.permissionSources[named ?? ""] ?? "default"})`, { permission: key });
128
128
  }
129
- if (level === "readonly" && writes(effects) && !(named === CEILING_KEY && fetchesOnly(action)))
129
+ if (level === "readonly" && writes(effects) && !fetchesOnly(action))
130
130
  throw levelRefusal({
131
131
  profile: settings.profile,
132
132
  command: app.command,
@@ -61,11 +61,18 @@ export declare const narrowsUnderLock: <T extends Command>(command: T) => T;
61
61
  export declare const admittedUnderLock: (command: Command) => boolean;
62
62
  /** A local edit remains an edit even when it first fetches metadata from the messenger. */
63
63
  export declare const changesStore: <T extends Command>(command: T) => T;
64
+ /**
65
+ * Marks a command that writes the owner's files outside the store through a folder it does not take as an option, a
66
+ * saved job's folder say: it stays a write, which a `readonly` level stops.
67
+ */
68
+ export declare const writesOwnerFiles: <T extends Command>(command: T) => T;
64
69
  /**
65
70
  * Reads the provider and only keeps what it read in the owner's store — a sync, a list that refreshes it. An MCP server
66
71
  * offers it through the read tool (owner ruling, 2026-10-27; WC-CMD-17): it changes nothing at the provider or for
67
- * other people. A local edit (`changesStore`), an authority change, a call to another service (`reachesOtherService`,
68
- * a model download) and a command that saves files (a download, a folder to write into) stay writes.
72
+ * other people. A local edit (`changesStore`), an authority change, a call to another service
73
+ * (`reachesOtherService`, a model download) and a command that saves files (a download, a folder to write into,
74
+ * `writesOwnerFiles`) stay writes. A sign-in (`logsInOrOut`) counts as a fetch, so a `readonly` level lets the owner
75
+ * sign in, but no MCP server runs one through its read tool.
69
76
  */
70
77
  export declare const fetchesOnly: (command: Command) => boolean;
71
78
  /** `fetchesOnly` by command path under `root`, as an MCP catalogue asks it; an unknown path is not one. */
@@ -104,16 +104,28 @@ export const changesStore = (command) => {
104
104
  STORE_WRITES.add(command);
105
105
  return command;
106
106
  };
107
+ const OWNER_FILES = new WeakSet();
108
+ /**
109
+ * Marks a command that writes the owner's files outside the store through a folder it does not take as an option, a
110
+ * saved job's folder say: it stays a write, which a `readonly` level stops.
111
+ */
112
+ export const writesOwnerFiles = (command) => {
113
+ OWNER_FILES.add(command);
114
+ return command;
115
+ };
107
116
  /** A download or a folder to write into: files outside the store, which the owner places, not an agent. */
108
- const savesFiles = (command) => command.name() === "download" ||
117
+ const savesFiles = (command) => OWNER_FILES.has(command) ||
118
+ command.name() === "download" ||
109
119
  [...command.options.map((option) => option.attributeName()), ...command.registeredArguments.map((one) => one.name())]
110
120
  .map((name) => name.toLowerCase())
111
121
  .some((name) => name === "dir" || name.endsWith("dir") || name === "output");
112
122
  /**
113
123
  * Reads the provider and only keeps what it read in the owner's store — a sync, a list that refreshes it. An MCP server
114
124
  * offers it through the read tool (owner ruling, 2026-10-27; WC-CMD-17): it changes nothing at the provider or for
115
- * other people. A local edit (`changesStore`), an authority change, a call to another service (`reachesOtherService`,
116
- * a model download) and a command that saves files (a download, a folder to write into) stay writes.
125
+ * other people. A local edit (`changesStore`), an authority change, a call to another service
126
+ * (`reachesOtherService`, a model download) and a command that saves files (a download, a folder to write into,
127
+ * `writesOwnerFiles`) stay writes. A sign-in (`logsInOrOut`) counts as a fetch, so a `readonly` level lets the owner
128
+ * sign in, but no MCP server runs one through its read tool.
117
129
  */
118
130
  export const fetchesOnly = (command) => {
119
131
  const effects = metaOf(command).effects;
@@ -160,7 +172,7 @@ const writesFileNow = (command) => {
160
172
  * What an MCP server runs through `read`: a command that only fetches into the store (`fetchesOnly`), and one whose
161
173
  * only write is a file the tool cannot name (`writesFileOnlyWith`).
162
174
  */
163
- export const readsOverMcp = (command) => fetchesOnly(command) || FILE_OPTION.has(command);
175
+ export const readsOverMcp = (command) => (fetchesOnly(command) && !LOGIN.has(command)) || FILE_OPTION.has(command);
164
176
  /** `readsOverMcp` by command path under `root`, as an MCP catalogue asks it; an unknown path is not one. */
165
177
  export const readsOverMcpAt = (root) => (path) => {
166
178
  let at = root;
@@ -228,11 +228,6 @@ export interface AnswerOutput {
228
228
  }
229
229
  /** An answer as JSON-lines records, for a writer that streams objects: one per item, then the end record. */
230
230
  export declare const jsonlRecords: <T>(body: Body<T>) => object[];
231
- /**
232
- * Prints an answer. Machine output gets the whole envelope (`--jsonl` the items and an end line); a person gets
233
- * the items — `view` draws them — and each next step this CLI has, as a line on stderr. A partial answer the
234
- * command does not declare `partial` exits with its first issue's code, after printing what was read.
235
- */
236
231
  export declare const renderAnswer: <T>(command: Command, { renderer, format, streams, compact, full }: AnswerOutput, body: Body<T>, view?: (body: Body<T>) => string) => void;
237
232
  /**
238
233
  * A document that is not an answer about the owner's data — the command registry, a `--dry-run` preview of what a
@@ -1,8 +1,10 @@
1
1
  import { exitCodeOfAnswer } from "@wirecat/cli-base";
2
2
  import { metaOf } from "@wirecat/cli-base/commands";
3
+ import { parseLucene, timezoneOf } from "@wirecat/cli-base/query";
3
4
  import { COMPACT_FLAG, itemEnvelopeSchema, jsonlOf, listEnvelopeSchema, MAX_NEXT_STEPS, } from "@wirecat/cli-base/standards";
4
5
  import * as v from "valibot";
5
6
  import { currentRun } from "../runs/scope.js";
7
+ import { readsZone } from "../search/service-query.js";
6
8
  import { compactText, entityRows, rowShapeOf, rowsOfEntity, TEXT_CHARS } from "./compact.js";
7
9
  import { environmentOf, setExitCode } from "./context.js";
8
10
  import { largeAnswerSteps, SOFT_OUTPUT_BYTES } from "./output-budget.js";
@@ -154,9 +156,32 @@ export const jsonlRecords = (body) => linesOf(sealed(body))
154
156
  * the items — `view` draws them — and each next step this CLI has, as a line on stderr. A partial answer the
155
157
  * command does not declare `partial` exits with its first issue's code, after printing what was read.
156
158
  */
159
+ /**
160
+ * The zone a list's `[query...]` read its dates in, for `meta.timezone` as search and the inbox give it: every store
161
+ * list compiles its query in the computer's zone, or in `--timezone` where the list takes one.
162
+ */
163
+ const listZone = (command) => {
164
+ const registry = metaOf(command).query;
165
+ const words = command.processedArgs.at(-1);
166
+ const text = Array.isArray(words) ? words.join(" ") : typeof words === "string" ? words : "";
167
+ const times = new Set(registry?.fields.filter(({ type }) => type === "time").map(({ name }) => name));
168
+ if (times.size === 0 || text.trim() === "")
169
+ return undefined;
170
+ try {
171
+ if (!readsZone(parseLucene(text, { defaultField: "none" }), times))
172
+ return undefined;
173
+ }
174
+ catch {
175
+ return undefined;
176
+ }
177
+ return timezoneOf(command.optsWithGlobals().timezone);
178
+ };
157
179
  export const renderAnswer = (command, { renderer, format, streams, compact, full }, body, view) => {
158
180
  if (!isBody(body))
159
181
  refuse(body);
182
+ const zone = "items" in body && body.meta?.timezone === undefined ? listZone(command) : undefined;
183
+ if (zone)
184
+ body = { ...body, meta: { ...body.meta, timezone: zone } };
160
185
  const root = rootOf(command);
161
186
  const runnableSteps = runnable(root, body.next);
162
187
  const next = environmentOf(command).agent ? runnableSteps : withLines(root, runnableSteps);