@wirecat/cli-core 1.3.0 → 2.0.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 (134) hide show
  1. package/CHANGELOG.md +145 -0
  2. package/dist/attachments/container.d.ts +1 -1
  3. package/dist/attachments/container.js +16 -7
  4. package/dist/attachments/limits.d.ts +10 -0
  5. package/dist/attachments/limits.js +30 -1
  6. package/dist/attachments/transfer.js +2 -2
  7. package/dist/cli/app-doctor-command.d.ts +61 -7
  8. package/dist/cli/app-doctor-command.js +24 -11
  9. package/dist/cli/documents/file-edit.js +6 -6
  10. package/dist/cli/documents/library.js +4 -2
  11. package/dist/cli/index.d.ts +6 -5
  12. package/dist/cli/index.js +2 -1
  13. package/dist/cli/messenger/context.d.ts +16 -0
  14. package/dist/cli/messenger/doctor-command.js +16 -1
  15. package/dist/cli/messenger/flooded.js +9 -1
  16. package/dist/cli/messenger/serve-relay.d.ts +2 -0
  17. package/dist/cli/oauth-session.d.ts +3 -2
  18. package/dist/cli/oauth-session.js +19 -3
  19. package/dist/cli/profile-store.d.ts +24 -10
  20. package/dist/cli/profile-store.js +43 -28
  21. package/dist/cli/shared-command-exports.d.ts +1 -1
  22. package/dist/cli/token-session.d.ts +21 -2
  23. package/dist/cli/token-session.js +27 -11
  24. package/dist/crm/cli/files.js +7 -7
  25. package/dist/documents.d.ts +1 -1
  26. package/dist/documents.js +1 -1
  27. package/dist/domain/person-kinds.d.ts +7 -3
  28. package/dist/domain/person-kinds.js +7 -3
  29. package/dist/domain/ref-summaries.js +1 -0
  30. package/dist/domain/references.d.ts +3 -2
  31. package/dist/domain/references.js +19 -10
  32. package/dist/entities/deal.d.ts +2 -2
  33. package/dist/entities/deal.js +1 -1
  34. package/dist/entities/fact.d.ts +2 -2
  35. package/dist/entities/fact.js +1 -1
  36. package/dist/entities/fields.d.ts +1 -1
  37. package/dist/entities/fields.js +1 -1
  38. package/dist/entities/index.d.ts +15 -15
  39. package/dist/entities/mail-findings.d.ts +2 -2
  40. package/dist/entities/mail-findings.js +1 -1
  41. package/dist/entities/meeting-findings.d.ts +2 -2
  42. package/dist/entities/meeting-findings.js +1 -1
  43. package/dist/entities/memory.d.ts +1 -1
  44. package/dist/entities/task-results.d.ts +5 -5
  45. package/dist/entities/task-results.js +1 -1
  46. package/dist/entities/task.d.ts +1 -1
  47. package/dist/entities/task.js +1 -1
  48. package/dist/errors/reasons.js +2 -1
  49. package/dist/fetch/page.js +1 -2
  50. package/dist/mail/headers.d.ts +4 -3
  51. package/dist/mail/headers.js +21 -3
  52. package/dist/mail/sort-rules.d.ts +13 -6
  53. package/dist/mail/sort-rules.js +20 -16
  54. package/dist/mail/sync.js +2 -0
  55. package/dist/mcp/tools/attachments.js +1 -1
  56. package/dist/office/zip.js +1 -1
  57. package/dist/ports/messenger.d.ts +31 -1
  58. package/dist/services/archive.js +61 -11
  59. package/dist/services/attachments.js +4 -4
  60. package/dist/services/documents/file-text.js +2 -2
  61. package/dist/services/metadata.d.ts +1 -1
  62. package/dist/services/proposals/kinds/shared.d.ts +1 -1
  63. package/dist/services/proposals/kinds/shared.js +2 -2
  64. package/dist/services/proposals/kinds/task-close.js +1 -1
  65. package/dist/store/areas.d.ts +2 -0
  66. package/dist/store/areas.js +1 -0
  67. package/dist/store/decisions.d.ts +1 -1
  68. package/dist/store/decisions.js +4 -4
  69. package/dist/store/evidence-findings.d.ts +2 -2
  70. package/dist/store/index.d.ts +3 -1
  71. package/dist/store/index.js +2 -1
  72. package/dist/store/mail-findings.d.ts +2 -2
  73. package/dist/store/meeting-findings.d.ts +2 -2
  74. package/dist/store/people.d.ts +4 -4
  75. package/dist/store/people.js +2 -1
  76. package/dist/store/project-transfer/manifest.js +3 -3
  77. package/dist/store/public.d.ts +1 -1
  78. package/dist/store/public.js +1 -1
  79. package/dist/store/sqlite/actors.d.ts +1 -1
  80. package/dist/store/sqlite/actors.js +6 -6
  81. package/dist/store/sqlite/agent-actions.js +2 -2
  82. package/dist/store/sqlite/agent-links.js +1 -1
  83. package/dist/store/sqlite/bot-sends.d.ts +19 -0
  84. package/dist/store/sqlite/bot-sends.js +36 -0
  85. package/dist/store/sqlite/business-contracts.js +1 -1
  86. package/dist/store/sqlite/deals.js +1 -1
  87. package/dist/store/sqlite/document-transfer/plan.js +1 -1
  88. package/dist/store/sqlite/document-transfer/snapshot.js +1 -1
  89. package/dist/store/sqlite/email-index.d.ts +11 -2
  90. package/dist/store/sqlite/email-index.js +56 -5
  91. package/dist/store/sqlite/email-types.d.ts +15 -3
  92. package/dist/store/sqlite/email-types.js +32 -1
  93. package/dist/store/sqlite/emails.d.ts +2 -1
  94. package/dist/store/sqlite/emails.js +6 -1
  95. package/dist/store/sqlite/entity-types.d.ts +1 -1
  96. package/dist/store/sqlite/entity-types.js +1 -1
  97. package/dist/store/sqlite/evidence-findings.js +1 -1
  98. package/dist/store/sqlite/facts.js +1 -1
  99. package/dist/store/sqlite/finance.js +2 -2
  100. package/dist/store/sqlite/knowledge.js +1 -0
  101. package/dist/store/sqlite/mail-findings.js +1 -1
  102. package/dist/store/sqlite/mail-sorting.d.ts +1 -1
  103. package/dist/store/sqlite/mail-sorting.js +96 -60
  104. package/dist/store/sqlite/mail-subscriptions.d.ts +70 -0
  105. package/dist/store/sqlite/mail-subscriptions.js +132 -0
  106. package/dist/store/sqlite/manifest.js +45 -0
  107. package/dist/store/sqlite/meeting-findings.js +1 -1
  108. package/dist/store/sqlite/memories.js +3 -3
  109. package/dist/store/sqlite/migrations.generated.js +80 -0
  110. package/dist/store/sqlite/money-transactions.js +1 -1
  111. package/dist/store/sqlite/note-index.d.ts +4 -1
  112. package/dist/store/sqlite/note-index.js +40 -17
  113. package/dist/store/sqlite/orders.js +1 -1
  114. package/dist/store/sqlite/payment-facts.js +2 -2
  115. package/dist/store/sqlite/products.js +1 -1
  116. package/dist/store/sqlite/project-transfer/sources.js +2 -2
  117. package/dist/store/sqlite/proposed-actions.js +3 -3
  118. package/dist/store/sqlite/record-projection.js +1 -1
  119. package/dist/store/sqlite/ref-summaries.js +2 -1
  120. package/dist/store/sqlite/relation-proposals.js +1 -1
  121. package/dist/store/sqlite/reviewed.d.ts +2 -2
  122. package/dist/store/sqlite/reviewed.js +1 -1
  123. package/dist/store/sqlite/sender-bots.d.ts +19 -4
  124. package/dist/store/sqlite/sender-bots.js +48 -4
  125. package/dist/store/sqlite/subscriptions.js +2 -2
  126. package/dist/store/sqlite/task-close.js +1 -1
  127. package/dist/store/sqlite/task-comments.js +1 -1
  128. package/dist/store/sqlite/things.js +1 -1
  129. package/dist/store/sqlite/transaction.d.ts +5 -0
  130. package/dist/store/sqlite/transaction.js +6 -1
  131. package/dist/store/sqlite/wallets.js +1 -1
  132. package/dist/store/sqlite/work-tasks.js +2 -2
  133. package/dist/tracker/tasks.js +4 -2
  134. package/package.json +7 -5
package/CHANGELOG.md CHANGED
@@ -5,6 +5,151 @@ 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
+ ## 2.0.0 — 27.11.2026
9
+
10
+ ### Added
11
+
12
+ - **Subscriptions: `store.mail.subscriptions`** (experimental). Broadcast mail grouped by `List-Id`, else by its
13
+ sender (`bot:<id>`, `person:<id>` or `address:<address>`), newest group first, grouped, counted and paged in
14
+ SQL (`limit`, default 100, and `offset`; `accountIds`, `since`, `until` and `types` narrow it). Each group gives its
15
+ `key`, `listId`, `name`, the `sender` ref and `address` of its newest email, its mail count, that `newest` email and
16
+ `unsubscribe`: the `https` and `mailto` targets and `oneClick` from its newest email that names one, or `null`.
17
+ Nothing is unsubscribed. A store opened read-only works types out in memory, as the type filters do.
18
+ - **List-Unsubscribe targets are kept.** Mail stored in full keeps `list-unsubscribe-https` and
19
+ `list-unsubscribe-mailto` in `emails.headers`, only when the From domain's DKIM signature that Gmail passed covers
20
+ `List-Unsubscribe`. `list-unsubscribe` stays `true` whenever the field is present, and `list-unsubscribe-post` is
21
+ kept as before. Mail stored earlier has no target until it is read again. No store version.
22
+ - **`people.listBots` filters by what a bot sends:** `sends` takes `alerts` (`security`, `system_alert`,
23
+ `account_notice`), `receipts` (`order`, `bill`, `shipping`), `newsletters`, `marketing` (`promotion`) and
24
+ `messenger` (a bot with an account in a messenger), any of them, in SQL. `BOT_SENDS` and `BotSends` are exported
25
+ from `@wirecat/cli-core/store` and `@wirecat/cli-core/store/areas` (experimental), so memo and Desktop read one map.
26
+ An unknown name is refused with `sender-bot.unknown-sends`.
27
+ - **A messenger CLI can add its own notes and `--online` checks to the shared `doctor`** (experimental). `doctorNotes`
28
+ turns the CLI's `diagnose` block into notes printed under the answer, never in the JSON. `doctorOnline` runs checks
29
+ after the login and answers them under `online.checks` as `{ name, ok, detail }`. A failed or thrown check is a
30
+ field, as a failed login is, and the exit code stays 0. max-cli needs both to drop its own `doctor` (stale web
31
+ client, moved keyring, paused login, bot and PATH hints; the bot's `getMyInfo` and the MCP handshake).
32
+ - **`readWhole()` reads a file past 2 GiB into one buffer**, where `readFile` stops with `ERR_FS_FILE_TOO_LARGE`.
33
+ - **`asBytes()` gives `readWhole`'s buffer as a plain `Uint8Array` without a copy.**
34
+ - **`sizeText()` says a byte budget as people read it**: `10 GiB`, `250 MiB`.
35
+ - **`oauthSessionCommand` hands `verify` the scopes the service granted**, as a fourth argument, in `session start`
36
+ and in `session status --check`. An account may untick a scope on the consent screen and still sign in, so a CLI
37
+ can now refuse such a sign-in before it is kept (gcal refuses one without read access to Calendar, or without a
38
+ grant it asked for). A `verify` that takes three arguments works as before.
39
+ - **`openProfileStore` for a phone system's calls**, exported from `@wirecat/cli-core/cli` with `ProfileStore` and
40
+ `ProfileStoreOptions`, so asterisk-cli and beeline-cli drop their own copies.
41
+ - It also answers `accountId`, the store's id for the account, which `store.meetings({ accountId })` takes.
42
+ - `account` is optional. Without it the account is the profile itself (`{ provider, account: profile }`), and a
43
+ read finds an account an older build saved with no profile row, under `<PREFIX>_READ_ONLY` too.
44
+ - `saves: false` never saves the account. A profile no run saved, or no store at all, reads an empty store in a
45
+ temporary folder, so a mistyped profile saves nothing. A store that needs a migration is still migrated.
46
+ - `name` is the name a new account is saved with. It was always `null`.
47
+ - A CRM's and a content CLI's calls (`openCrmStore`, `openContentStore`) work as before.
48
+ - **`messages sync` picks the threads to read again, for a messenger with `ThreadRefresh`** (experimental). A
49
+ messenger whose history leaves thread replies out, as Slack's does, no longer decides itself which threads to read.
50
+ It answers three questions, with all three methods or none: which messages on a history page are roots
51
+ (`threadRootsIn`, from the page alone and not paced), which roots it lists cheaply that may have new replies however
52
+ old the root, such as those sent in the last days (`recentThreadRoots`), and one root's replies after a time
53
+ (`rootReplies`). The sync reads every root it saw on the chat's first read. After that it reads a root from an older
54
+ history page whole, and any other root only from the last read on, when the root's `lastReplyAt` is later. The last
55
+ read's time is taken before the history pages and a minute early, so a reply sent while they are read, or while the
56
+ two clocks differ, is not lost. Each thread is saved as it comes, and a stopped sync reads from the same point
57
+ again. A messenger with `ThreadReplies` alone works as before.
58
+ - **`tokenSessionCommand` takes `entry`, for a profile that keeps more than its token.** `entry.write` makes the
59
+ stored value from the token and `verify`'s answer, and `entry.read` gets the token back with the account. `session
60
+ status --check` hands `verify` the token alone, and `session status` and `session list` show the account as
61
+ `account`. An entry `read` cannot make sense of (reason `session.unreadable`) is listed as `state: "unknown"` and
62
+ hides no other profile. Unset, the entry is the token alone, as before. hubspot moves to the shared command with it
63
+ and keeps its sign-ins as they are, so nobody signs in again. Not with `site`. `TokenEntry` is exported from
64
+ `@wirecat/cli-core/cli`.
65
+ - **`store.mail.catchUp(until?)`** (experimental). Indexes and types every email still waiting for its words, pieces
66
+ or type, a short write at a time, until `until` answers true. `syncMail` calls it once it has saved, so a store
67
+ upgraded to version 76 has its mail typed by its next sync, not by its first search.
68
+ - **`appDoctorCommand` for a CLI with no profiles.** memo has its own config file and no accounts, so it kept a copy of
69
+ the shared doctor. `configuration` may now be `null`, with `config(env, command)` giving the config's `path`, `found`
70
+ and `issues`, and `profiles` is then `null`. `local` receives the command, may be async, and returns `failing: true`
71
+ to make doctor exit 1. `view(item)` gives the text a person reads. The CLI's `local` fields win over the shared ones
72
+ of the same name, and a note the shared check and the CLI both print is printed once.
73
+ - **`setExitCode` is exported from `@wirecat/cli-core/cli`.** A command that answers and still fails (a sync with
74
+ failed sources) sets this run's exit code, also under `commands --serve`, where several requests share one process.
75
+
76
+ ### Changed — may break callers
77
+
78
+ - **cli-core 2.0: agents are `agent`, sender bots are `bot:` (store version 78, `minCompatible` 78).** The owner's
79
+ rulings of 25.11.2026 and 26.11.2026 (contact-kinds plan, open question 7). Until now `bot:<id>` and the pointer
80
+ type `bot` named an agent of the `bots` table, and a sender bot was `sender-bot:<id>`. Now an agent is `agent:<id>`
81
+ and `agent`, and a sender bot is `bot:<id>`.
82
+ - **What breaks for callers:**
83
+ - The JSON output: the `type` of `author`, `created_by`, `confirmed_by` and `decided_by` (tasks, deals, facts, mail
84
+ and meeting findings) and of every actor pair says `"agent"` where it said `"bot"`.
85
+ - `Proposer` (stable): `{ type: "agent", id, name, kind, verified? }` replaces `{ type: "bot", … }`.
86
+ - `parseReference`: `agent:<number>` gives `{ type: "agent" }`; `bot:<id>` gives `{ type: "bot" }`, a sender bot.
87
+ `agent:` takes a number only, so an author's name such as `agent:claude` stays a name and `looksLikeReference`
88
+ says no.
89
+ - `SENDER_BOT_PREFIX` is `"bot:"`. Sender bot refs in output (`moveToBot`, `showBot`, `store.mail.subscriptions`
90
+ `sender`, sorting rule effects) say `bot:<id>`.
91
+ - Still read, never written: `sender-bot:<id>` parses as `bot:<id>`, and `moveToBot`, `moveToPerson`, `showBot`
92
+ and the sorting rules take it. The `sender-bot.*` error reasons keep their names.
93
+ - **Every WireCat CLI must move to cli-core 2.0 together.** All of them pin an exact cli-core version and share one
94
+ store file. The first 2.0 build that opens the store runs version 78, which rewrites the stored values: every
95
+ `*_type` pair in the 36 tables that have one, `links.target_text` and `links.metadata.gone`, `record_relations`
96
+ refs, `proposed_actions.payload` (`from`, `to`, `ref`), `document_annotation_transfers.reference_map`, and
97
+ `mail_sort_effects` (`sender-bot:` to `bot:`). After that, a 1.x build refuses the store with "the message store
98
+ was written by a newer version (schema 78, needs at least 78 …)" (`configuration_error`), because it would read a
99
+ sender bot's `bot:` as an agent and would keep writing agents as `bot`. So upgrade every installed CLI and WireCat
100
+ Desktop the same day, and migrate with `serve`, `mcp` and syncs stopped. The migration writes a rollback copy
101
+ first; without one it refuses, as since version 73.
102
+ - **Migration for API users:**
103
+ - Match `type === "agent"` where you matched `type === "bot"` for an agent (actors, `Proposer`, output schemas).
104
+ - Build a sender bot ref from `SENDER_BOT_PREFIX` (`bot:`) instead of the literal `sender-bot:`.
105
+ - Pass a ref you read from older files or user input through `senderBotRef` (from `@wirecat/cli-core/store`): it
106
+ turns `sender-bot:<id>` into `bot:<id>` and leaves any other text as it is. `OLD_SENDER_BOT_PREFIX` names the old
107
+ form.
108
+ - Unchanged: an author or decider `{ bot: name }` still holds an agent's name; `identity_links.method = 'bot'`,
109
+ `identities.bot` and keyring `bot:<profile>` entries of a messenger's bot account are not agent refs.
110
+ - **A file is read for its text up to 10 GiB by default, not 50 MiB.** The 50 MiB default refused large PDFs and
111
+ documents from Drive, Yandex Disk, CRM files and attachments. `MAX_FILE_BYTES` and `attachmentMaxBytes()` are now
112
+ 10 GiB, and `MESSAGING_ATTACHMENT_MAX_MIB` still sets another budget
113
+ ([attachments](docs/attachments.md#configure-pdf-previews-and-larger-files)). The same budget now covers editing
114
+ an Office file in place (it was 64 MiB) and what a DOCX, XLSX or EPUB unpacks to, so pictures inside one no longer
115
+ make it unreadable. The text parts are still read up to 50 MiB unpacked, the guard against a zip bomb. A file
116
+ within the budget is held whole in memory, once, so a caller that used `MAX_FILE_BYTES` as a memory bound now
117
+ allows 200 times more. A caller that reads the constant gets 10 GiB, not the setting: read the budget with
118
+ `attachmentMaxBytes()`.
119
+ - **`AppDoctorOptions.local` has a wider type:** `(env, command) => AppDoctorLocal | Promise<AppDoctorLocal>`. A
120
+ `local` written for the old type still compiles and runs as before. Code that calls `options.local` itself must now
121
+ pass the command and await the answer.
122
+
123
+ ### Fixed
124
+
125
+ - **A release makes its GitHub release again.** The release workflow pushed only the tag, so GitHub's releases page
126
+ stopped at the last release made by hand. The `tag` job now creates the release from the version's changelog
127
+ section, as the CLIs' release workflows do. 1.x was backfilled by hand.
128
+ - **Parity checks drive, gcal, bitrix24, wordpress and cli-template again.** The first four released on cli-core 1.0
129
+ on 26.11.2026 (drive 0.78.0, gcal 0.36.0, bitrix24 0.28.0, wordpress 0.4.0), and cli-template adopted 1.3.0, so
130
+ their entries for #3338 and #3365 are off the known-broken list. bitrix24 keeps its entry for #3258.
131
+ - **Parity checks bitrix24 again.** Its entry for #3258 is off the known-broken list: bitrix24 main no longer pins
132
+ `schedule exec` among the MCP schedule commands (bitrix24-cli #162, released in 0.28.0).
133
+ - **A documents sync reads a file an earlier version kept by name for its size** (`file is larger than …`) once the
134
+ budget allows it. Before, such a file stayed kept by name until it changed.
135
+ - **`session list` warns once when the keyring cannot be reached**, not once per profile, as 1.1.0 described. The
136
+ warning was counted by its text, and cli-base's text names the profile.
137
+ - **Parity checks bitrix24, tg, max and whatsapp again.** The 1.3.0 release run passed their tests. tg, max and
138
+ whatsapp adopted `session list` and `session status` (tg-cli#923, max-cli#992, whatsapp-cli#423), and bitrix24's
139
+ `src/mcp.test.ts` no longer pins `schedule exec`.
140
+ - **`session end` ends a sign-in kept in the file where no keyring answers**, in every CLI built on
141
+ `oauthSessionCommand`. It removed the sign-in, then failed with `keyring.unreachable` when it read again to check
142
+ that nothing was left. On a server without a desktop, where the sign-in falls back to the file, it now answers
143
+ `ended: true` and `removed: ["file"]`.
144
+ - **The first mail search after a large save is fast.** `saveThreads` and `saveThread` now index the words and
145
+ pieces of the mail they save and work out its type and reach inside the same write, plus up to 500 emails and 50
146
+ threads left from before. On 100,000 synthetic emails the first plain search took 87 ms instead of 12.1 s, and the
147
+ first `type:` search on a read-only open 74 ms instead of 2.8 s. A sync slice of 50 threads spends about 14 ms
148
+ more CPU. The word drain that a search or `catchUp` still runs keeps taking batches of 200 in one write for up to
149
+ 250 ms, instead of committing every 200 emails. No store version.
150
+ - **A mail search on a read-only open no longer fails with "attempt to write a readonly database"** when saved mail
151
+ is still waiting for its words: the drain tried to queue the threads of that mail first.
152
+
8
153
  ## 1.3.0 — 26.11.2026
9
154
 
10
155
  ### Changed — experimental
@@ -1,6 +1,6 @@
1
1
  import { type Document, type Element, type Node } from "@xmldom/xmldom";
2
2
  export declare class ReaderLimit extends Error {
3
3
  }
4
- export declare const readContainer: (bytes: Uint8Array, signal?: AbortSignal) => Promise<Map<string, Uint8Array>>;
4
+ export declare const readContainer: (bytes: Uint8Array, signal?: AbortSignal, maxExpanded?: number) => Promise<Map<string, Uint8Array>>;
5
5
  export declare const xmlPart: (archive: Map<string, Uint8Array>, path: string) => Document;
6
6
  export declare const elements: (node: Node, name: string, namespace: string) => Element[];
@@ -4,7 +4,9 @@ import { CliError } from "@wirecat/cli-base";
4
4
  import { DOMParser } from "@xmldom/xmldom";
5
5
  import { Unzip, UnzipInflate } from "fflate";
6
6
  import { decodeXml } from "./encoding.js";
7
- import { MAX_FILE_BYTES as MAX_EXPANDED } from "./limits.js";
7
+ import { attachmentMaxBytes } from "./limits.js";
8
+ // The text parts are held in memory; pictures and media are only checksummed, so they count against the file budget.
9
+ const MAX_KEPT = 50 * 1024 * 1024;
8
10
  const MAX_PART = 10 * 1024 * 1024;
9
11
  const MAX_ENTRIES = 1000;
10
12
  const decoder = new TextDecoder("utf-8", { fatal: true });
@@ -19,7 +21,8 @@ const safeName = (name) => name.length > 0 &&
19
21
  !/^[\\/]|\\/.test(name) &&
20
22
  ![...name].some((character) => character.charCodeAt(0) < 32) &&
21
23
  !name.split("/").includes("..");
22
- const directory = (bytes) => {
24
+ const KEPT = (name) => /\.(xml|rels|opf|xhtml|html)$/i.test(name) || name === "mimetype";
25
+ const directory = (bytes, maxExpanded) => {
23
26
  const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
24
27
  let end = -1;
25
28
  for (let index = bytes.length - 22; index >= Math.max(0, bytes.length - 65_557); index--) {
@@ -40,6 +43,7 @@ const directory = (bytes) => {
40
43
  throw new Error("invalid_zip");
41
44
  let offset = view.getUint32(end + 16, true);
42
45
  let expanded = 0;
46
+ let kept = 0;
43
47
  const entries = new Map();
44
48
  for (let index = 0; index < count; index++) {
45
49
  if (offset + 46 > stop || view.getUint32(offset, true) !== 0x02014b50)
@@ -58,7 +62,9 @@ const directory = (bytes) => {
58
62
  if (((view.getUint32(offset + 38, true) >>> 16) & 0xf000) === 0xa000)
59
63
  throw new Error("invalid_zip");
60
64
  expanded += size;
61
- if (expanded > MAX_EXPANDED)
65
+ if (KEPT(name))
66
+ kept += size;
67
+ if (expanded > maxExpanded || kept > MAX_KEPT)
62
68
  throw new ReaderLimit();
63
69
  const local = view.getUint32(offset + 42, true);
64
70
  if (local + 30 > offset || view.getUint32(local, true) !== 0x04034b50)
@@ -82,19 +88,20 @@ const directory = (bytes) => {
82
88
  throw new Error("invalid_zip");
83
89
  return entries;
84
90
  };
85
- export const readContainer = async (bytes, signal) => {
91
+ export const readContainer = async (bytes, signal, maxExpanded = attachmentMaxBytes()) => {
86
92
  cancelled(signal);
87
- const entries = directory(bytes);
93
+ const entries = directory(bytes, maxExpanded);
88
94
  const result = new Map();
89
95
  const seen = new Set();
90
96
  const done = new Set();
91
97
  let expanded = 0;
98
+ let kept = 0;
92
99
  const archive = new Unzip((file) => {
93
100
  const expected = entries.get(file.name);
94
101
  if (!expected || seen.has(file.name))
95
102
  throw new Error("invalid_zip");
96
103
  seen.add(file.name);
97
- const keep = /\.(xml|rels|opf|xhtml|html)$/i.test(file.name) || file.name === "mimetype";
104
+ const keep = KEPT(file.name);
98
105
  let size = 0;
99
106
  let checksum = 0;
100
107
  const parts = [];
@@ -103,7 +110,9 @@ export const readContainer = async (bytes, signal) => {
103
110
  throw error;
104
111
  size += data.length;
105
112
  expanded += data.length;
106
- if (expanded > MAX_EXPANDED || (keep && size > MAX_PART))
113
+ if (keep)
114
+ kept += data.length;
115
+ if (expanded > maxExpanded || kept > MAX_KEPT || (keep && size > MAX_PART))
107
116
  throw new ReaderLimit();
108
117
  checksum = crc32(data, checksum);
109
118
  if (keep)
@@ -1,7 +1,17 @@
1
+ import { type FileHandle } from "node:fs/promises";
1
2
  export declare const MAX_FILE_BYTES: number;
2
3
  export declare const MAX_TEXT_CHARS = 2000000;
3
4
  export declare const ATTACHMENT_LIMIT_ENV: readonly ["MESSAGING_BATCH_MAX_ERROR_PERCENT", "MESSAGING_ATTACHMENT_MAX_MIB", "MESSAGING_PDF_PREVIEW_MAX_PIXELS", "MESSAGING_PDF_PREVIEW_MAX_MIB"];
4
5
  export declare const attachmentMaxBytes: (env?: NodeJS.ProcessEnv) => number;
6
+ /**
7
+ * `readFile` stops at 2 GiB and the file budget goes past it, so the file is read in chunks into one buffer. The buffer
8
+ * is its own, never a slice of Node's pool, so a caller keeps it without a copy.
9
+ */
10
+ export declare const readWhole: (file: string | FileHandle, signal?: AbortSignal) => Promise<Buffer>;
11
+ /** The same bytes as a plain `Uint8Array`, whose `slice` copies as callers expect, without copying them. */
12
+ export declare const asBytes: (buffer: Buffer) => Uint8Array;
13
+ /** A byte budget as people read it: `10 GiB`, `250 MiB`. */
14
+ export declare const sizeText: (bytes: number) => string;
5
15
  export declare const pdfPreviewLimits: (env?: NodeJS.ProcessEnv) => {
6
16
  pixels: number;
7
17
  bytes: number;
@@ -1,5 +1,6 @@
1
+ import { open } from "node:fs/promises";
1
2
  import { CliError } from "@wirecat/cli-base";
2
- export const MAX_FILE_BYTES = 50 * 1024 * 1024;
3
+ export const MAX_FILE_BYTES = 10 * 1024 ** 3;
3
4
  export const MAX_TEXT_CHARS = 2_000_000;
4
5
  export const ATTACHMENT_LIMIT_ENV = [
5
6
  "MESSAGING_BATCH_MAX_ERROR_PERCENT",
@@ -17,6 +18,34 @@ const positive = (env, name, fallback, factor = 1) => {
17
18
  return value * factor;
18
19
  };
19
20
  export const attachmentMaxBytes = (env = process.env) => positive(env, "MESSAGING_ATTACHMENT_MAX_MIB", MAX_FILE_BYTES, 1024 * 1024);
21
+ /**
22
+ * `readFile` stops at 2 GiB and the file budget goes past it, so the file is read in chunks into one buffer. The buffer
23
+ * is its own, never a slice of Node's pool, so a caller keeps it without a copy.
24
+ */
25
+ export const readWhole = async (file, signal) => {
26
+ const handle = typeof file === "string" ? await open(file, "r") : file;
27
+ try {
28
+ const { size } = await handle.stat();
29
+ const bytes = Buffer.allocUnsafeSlow(size);
30
+ let offset = 0;
31
+ while (offset < size) {
32
+ signal?.throwIfAborted();
33
+ const { bytesRead } = await handle.read(bytes, offset, Math.min(size - offset, 64 * 1024 * 1024), offset);
34
+ if (bytesRead === 0)
35
+ break;
36
+ offset += bytesRead;
37
+ }
38
+ return offset === size ? bytes : bytes.subarray(0, offset);
39
+ }
40
+ finally {
41
+ if (typeof file === "string")
42
+ await handle.close();
43
+ }
44
+ };
45
+ /** The same bytes as a plain `Uint8Array`, whose `slice` copies as callers expect, without copying them. */
46
+ export const asBytes = (buffer) => new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength);
47
+ /** A byte budget as people read it: `10 GiB`, `250 MiB`. */
48
+ export const sizeText = (bytes) => bytes % 1024 ** 3 === 0 ? `${bytes / 1024 ** 3} GiB` : `${Math.round(bytes / 1024 ** 2)} MiB`;
20
49
  export const pdfPreviewLimits = (env = process.env) => {
21
50
  const pixels = positive(env, "MESSAGING_PDF_PREVIEW_MAX_PIXELS", 4000);
22
51
  if (!Number.isSafeInteger(pixels * pixels))
@@ -2,7 +2,7 @@ import { createHash } from "node:crypto";
2
2
  import { constants } from "node:fs";
3
3
  import { lstat, open } from "node:fs/promises";
4
4
  import { CliError } from "@wirecat/cli-base";
5
- import { attachmentMaxBytes } from "./limits.js";
5
+ import { attachmentMaxBytes, sizeText } from "./limits.js";
6
6
  export const MAX_CHUNK_BYTES = 1024 * 1024;
7
7
  export const validateWindow = ({ offsetBytes = 0, chunkBytes = 524288, ifSha256 }) => {
8
8
  if (!Number.isSafeInteger(offsetBytes) ||
@@ -28,7 +28,7 @@ export const retainedBytes = async (path, options, captureFile = false, env = pr
28
28
  if (!before.isFile() || before.isSymbolicLink())
29
29
  throw new CliError("validation_error", "the retained attachment must be a regular file");
30
30
  if (before.size > maxBytes)
31
- throw new CliError("validation_error", `the retained attachment exceeds ${maxBytes / 1024 / 1024} MiB; configure MESSAGING_ATTACHMENT_MAX_MIB`);
31
+ throw new CliError("validation_error", `the retained attachment exceeds ${sizeText(maxBytes)}; configure MESSAGING_ATTACHMENT_MAX_MIB`);
32
32
  if (offsetBytes > before.size)
33
33
  throw new CliError("validation_error", "the byte offset is past the end of this attachment");
34
34
  const handle = await open(path, constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0) | (constants.O_NONBLOCK ?? 0));
@@ -1,6 +1,7 @@
1
1
  import { Command } from "commander";
2
2
  import type { OAuthClientReport } from "../constants/index.js";
3
3
  import { type AppIdentity } from "../ports/app.js";
4
+ import type { ConfigIssue } from "./config-issues.js";
4
5
  import type { Configuration } from "./settings.js";
5
6
  export interface AppDoctorOptions {
6
7
  /**
@@ -20,12 +21,26 @@ export interface AppDoctorOptions {
20
21
  } & Record<string, unknown>>;
21
22
  /**
22
23
  * What the CLI reads of its own state from disk, with no call out: a run left half done, a deadline near. `fields`
23
- * join the answer; each of `notes` goes to stderr, as a fix does. A throw is reported as `local.error`.
24
+ * join the answer, and win over the shared ones of the same name; each of `notes` goes to stderr, as a fix does.
25
+ * `failing` makes doctor exit 1. A throw is reported as `local.error`.
24
26
  */
25
- local?: (env: NodeJS.ProcessEnv) => {
26
- fields: Record<string, unknown>;
27
- notes?: string[];
27
+ local?: (env: NodeJS.ProcessEnv, command: Command) => AppDoctorLocal | Promise<AppDoctorLocal>;
28
+ /**
29
+ * A CLI with no profiles keeps its own config file: its path, whether it exists and its problems, read here in place
30
+ * of the `configuration`'s, which is then `null`. A `CliError` it throws is reported as `settings.error`.
31
+ */
32
+ config?: (env: NodeJS.ProcessEnv, command: Command) => {
33
+ path: string;
34
+ found: boolean;
35
+ issues: ConfigIssue[];
28
36
  };
37
+ /** The answer as a person reads it; cli-core's item view without it. */
38
+ view?: (item: Record<string, unknown>) => string;
39
+ }
40
+ export interface AppDoctorLocal {
41
+ fields: Record<string, unknown>;
42
+ notes?: string[];
43
+ failing?: boolean;
29
44
  }
30
45
  /**
31
46
  * Run when everything else is broken, so a problem in the config file or the OAuth setting is a field, never a throw.
@@ -33,7 +48,46 @@ export interface AppDoctorOptions {
33
48
  * that make the config private; they go to stderr, not into the answer.
34
49
  * @experimental
35
50
  */
36
- export declare const appDoctorReport: (app: AppIdentity, configuration: Configuration, env: NodeJS.ProcessEnv, command: Command, options?: AppDoctorOptions) => {
51
+ export declare const appDoctorReport: (app: AppIdentity, configuration: Configuration | null, env: NodeJS.ProcessEnv, command: Command, options?: AppDoctorOptions) => {
52
+ report: {
53
+ version: string;
54
+ runtime: {
55
+ node: string;
56
+ platform: NodeJS.Platform;
57
+ };
58
+ paths: {
59
+ config: string;
60
+ state: string;
61
+ cache: string;
62
+ };
63
+ store: {
64
+ path: string;
65
+ exists: boolean;
66
+ };
67
+ oauth_client?: OAuthClientReport | undefined;
68
+ read_only: string | null;
69
+ profile_lock: string | null;
70
+ config: {
71
+ path: string;
72
+ found: boolean;
73
+ issues: ConfigIssue[];
74
+ };
75
+ profiles: null;
76
+ files: {
77
+ checked: false;
78
+ reason: string;
79
+ } | {
80
+ checked: true;
81
+ ok: boolean;
82
+ problems: {
83
+ path: string;
84
+ mode: string;
85
+ want: string;
86
+ }[];
87
+ };
88
+ };
89
+ fixes: string[] | never[];
90
+ } | {
37
91
  report: {
38
92
  version: string;
39
93
  runtime: {
@@ -55,7 +109,7 @@ export declare const appDoctorReport: (app: AppIdentity, configuration: Configur
55
109
  config: {
56
110
  path: string;
57
111
  found: boolean;
58
- issues: import("./config-issues.js").ConfigIssue[];
112
+ issues: ConfigIssue[];
59
113
  };
60
114
  profiles: string[];
61
115
  files: {
@@ -120,4 +174,4 @@ export declare const appDoctorReport: (app: AppIdentity, configuration: Configur
120
174
  * say the same thing: the state from disk, and only with `--online` a call out. Here that call is `options.online`
121
175
  * and, with `options.packageName`, whether npm has a newer version.
122
176
  */
123
- export declare const appDoctorCommand: (app: AppIdentity, configuration: Configuration, options?: AppDoctorOptions) => Command;
177
+ export declare const appDoctorCommand: (app: AppIdentity, configuration: Configuration | null, options?: AppDoctorOptions) => Command;
@@ -9,7 +9,7 @@ import { isNewer, latestVersion } from "@wirecat/cli-base/update";
9
9
  import { Command } from "commander";
10
10
  import { envName, readOnlyLockOf } from "../ports/app.js";
11
11
  import { storePath } from "../store/path.js";
12
- import { environmentOf, inCommandRun, outputFor } from "./context.js";
12
+ import { environmentOf, inCommandRun, outputFor, setExitCode } from "./context.js";
13
13
  import { doctorReportsCommand } from "./doctor-reports-command.js";
14
14
  import { DOCTOR_ONLINE_OPTION, DOCTOR_SUMMARY } from "./doctor-text.js";
15
15
  import { REMOTE_READ } from "./effects.js";
@@ -17,15 +17,19 @@ import { itemOf, renderAnswer } from "./envelope.js";
17
17
  import { privateFiles } from "./messenger/private-files.js";
18
18
  import { unknownPermissionIssues } from "./permission-keys.js";
19
19
  import { profileFree } from "./profile.js";
20
- const localCheck = (env, options) => {
20
+ const localCheck = async (env, command, options) => {
21
21
  if (!options.local)
22
- return { fields: {}, notes: [] };
22
+ return { fields: {}, notes: [], failing: false };
23
23
  try {
24
- const { fields, notes = [] } = options.local(env);
25
- return { fields, notes };
24
+ const { fields, notes = [], failing = false } = await options.local(env, command);
25
+ return { fields, notes, failing };
26
26
  }
27
27
  catch (error) {
28
- return { fields: { local: { error: error instanceof Error ? error.message : String(error) } }, notes: [] };
28
+ return {
29
+ fields: { local: { error: error instanceof Error ? error.message : String(error) } },
30
+ notes: [],
31
+ failing: false,
32
+ };
29
33
  }
30
34
  };
31
35
  const onlineCheck = async (app, env, fetcher, options) => {
@@ -100,6 +104,15 @@ export const appDoctorReport = (app, configuration, env, command, options = {})
100
104
  profile_lock: env[envName(app, "PROFILE_LOCK")]?.trim() || null,
101
105
  };
102
106
  try {
107
+ if (configuration === null) {
108
+ const config = options.config?.(env, command) ?? {
109
+ path: configFilePath(paths.config),
110
+ found: existsSync(configFilePath(paths.config)),
111
+ issues: [],
112
+ };
113
+ const { files, fixes } = configFiles(config.path);
114
+ return { report: { ...common, config, profiles: null, files }, fixes };
115
+ }
103
116
  const settings = configuration.resolveSettings({}, { env, readOnly: true, needsProfile: false, withIssues: true });
104
117
  const { files, fixes } = configFiles(settings.configPath);
105
118
  return {
@@ -149,17 +162,17 @@ export const appDoctorCommand = (app, configuration, options = {}) => profileFre
149
162
  const environment = environmentOf(this);
150
163
  const env = environment.env ?? process.env;
151
164
  const { report, fixes } = appDoctorReport(app, configuration, env, this, options);
152
- const local = localCheck(env, options);
165
+ const local = await localCheck(env, this, options);
153
166
  const answer = async () => {
154
167
  const online = this.opts().online
155
168
  ? await onlineCheck(app, env, environment.fetch ?? hostFetch({ hosts: ["registry.npmjs.org"] }), options)
156
169
  : undefined;
157
170
  const output = outputFor(this);
158
- renderAnswer(this, output, itemOf({ ...report, ...local.fields, ...(online ? { online } : {}) }, { meta: clockMeta(Date.now(), timezoneOf()) }));
159
- for (const fix of fixes)
160
- output.renderer.note(`to make it private: ${fix}`);
161
- for (const note of local.notes)
171
+ renderAnswer(this, output, itemOf({ ...report, ...local.fields, ...(online ? { online } : {}) }, { meta: clockMeta(Date.now(), timezoneOf()) }), options.view && ((body) => options.view?.(body.item) ?? ""));
172
+ for (const note of new Set([...fixes.map((fix) => `to make it private: ${fix}`), ...local.notes]))
162
173
  output.renderer.note(note);
174
+ if (local.failing)
175
+ setExitCode(this, 1);
163
176
  };
164
177
  // A call out is recorded and ended by `--timeout` as any other command's; a config that will not load opens no
165
178
  // run, and doctor still answers.
@@ -1,10 +1,11 @@
1
1
  import { createHash } from "node:crypto";
2
- import { mkdtemp, readFile, rm, stat, writeFile } from "node:fs/promises";
2
+ import { mkdtemp, rm, stat, writeFile } from "node:fs/promises";
3
3
  import { tmpdir } from "node:os";
4
4
  import { join } from "node:path";
5
5
  import { CliError, isCliError } from "@wirecat/cli-base";
6
6
  import { annotate, sharedCommand } from "@wirecat/cli-base/commands";
7
7
  import * as v from "valibot";
8
+ import { asBytes, attachmentMaxBytes, readWhole, sizeText } from "../../attachments/limits.js";
8
9
  import { createDocx, createXlsx, editDocxParagraphs, editXlsxCells, NEW_PARAGRAPH_STYLES, readDocxParagraphs, readXlsxCells, } from "../../office/index.js";
9
10
  import { guardedFileWrite, remoteChanged } from "../../services/files/guarded-write.js";
10
11
  import { honoursDryRun } from "../dry-run-guard.js";
@@ -14,8 +15,6 @@ import { notLocalPaths } from "../path-options.js";
14
15
  import { marksUntrusted } from "../untrusted-marks.js";
15
16
  import { addFileUpdateCommand, replacedOf, sha256Of, } from "./file-update.js";
16
17
  import { examples, wordsOf } from "./words.js";
17
- /** The whole file is held in memory to edit it. */
18
- const MAX_OFFICE_BYTES = 64 * 1024 * 1024;
19
18
  const sha256 = (bytes) => createHash("sha256").update(bytes).digest("hex");
20
19
  const inTemp = async (act) => {
21
20
  const folder = await mkdtemp(join(tmpdir(), "wirecat-office-"));
@@ -30,11 +29,12 @@ const downloaded = ({ target, signal }, path) => inTemp(async (folder) => {
30
29
  const into = join(folder, "file");
31
30
  await target.download(path, into, signal);
32
31
  const { size } = await stat(into);
33
- if (size > MAX_OFFICE_BYTES)
34
- throw new CliError("validation_error", `${path} is ${size} bytes; an Office file is read up to 64 MiB`, {
32
+ const max = attachmentMaxBytes();
33
+ if (size > max)
34
+ throw new CliError("validation_error", `${path} is ${size} bytes; an Office file is read up to ${sizeText(max)}`, {
35
35
  reason: "file.too-large",
36
36
  });
37
- const bytes = new Uint8Array(await readFile(into));
37
+ const bytes = asBytes(await readWhole(into));
38
38
  return { bytes, sha256: sha256(bytes) };
39
39
  });
40
40
  const jsonOf = (input, flag, schema, shape) => {
@@ -389,9 +389,11 @@ const libraryOf = (options, withSync) => {
389
389
  isFolder: options.isFolder,
390
390
  ...(options.isDocument ? { isDocument: options.isDocument } : {}),
391
391
  skipReason: (file) => scanSkipReason(scans, file, skipReason(file)),
392
- // A file an older version kept by name for its type is read once a newer one reads that type; the
392
+ // A file an older version kept by name for its type or size is read once a newer one reads it; the
393
393
  // planner asks only when `skipReason` no longer gives a reason. The words are the CLIs' own.
394
- retryable: (skip) => skip.reason.startsWith("unsupported type: ") || scanRetry(scans, skip.reason),
394
+ retryable: (skip) => skip.reason.startsWith("unsupported type: ") ||
395
+ skip.reason.startsWith("file is larger than ") ||
396
+ scanRetry(scans, skip.reason),
395
397
  ...(scans ? { scans } : {}),
396
398
  errorOf,
397
399
  assertHeld,
@@ -23,7 +23,7 @@ export { registerLinkConversationsPrompt } from "../mcp/prompts.js";
23
23
  export { agentBody, agentJson, agentResult, UNTRUSTED, UNTRUSTED_INSTRUCTION, UNTRUSTED_NEUTRAL } from "../mcp/text.js";
24
24
  export { MEETING_RESULT_ENTITIES } from "../meetings/index.js";
25
25
  export { type AppIdentity, envName, readOnlyLockOf, readOnlyRefusal } from "../ports/app.js";
26
- export type { AccountEditing, AccountHealth, AccountRecords, AccountSettings, AccountStanding, AccountTools, After, BotChats, ChannelComments, ChatDeletion, ChatFolders, ChatReading, ContactBook, Download, ForumControl, ForumState, GroupAdmin, GroupModeration, HistoryBatch, HistoryBatchHandler, HistoryChatEvent, HistoryReaction, HistoryStar, HistoryVote, InviteLinks, JoinRequests, LiveUpdates, MessageButtons, MessageEditing, MessageMedia, MessagePermalinks, MessagePins, MessagePolls, MessageReactions, MessageSearch, MessageStars, MessengerAdapter, MessengerCore, NewPoll, OfficialStats, PassiveUpdates, PersonProfiles, ProfileChange, ProfilePhotos, PushedHistory, ReadState, RemoteFile, ScheduledChanges, ScheduledMessages, SenderIdentities, SenderSearch, SendOptions, Sent, ServerQuery, ServerReads, ThreadAddressing, TopicEditing, TopicHistory, TopicReadState, Transcript, } from "../ports/messenger.js";
26
+ export type { AccountEditing, AccountHealth, AccountRecords, AccountSettings, AccountStanding, AccountTools, After, BotChats, ChannelComments, ChatDeletion, ChatFolders, ChatReading, ContactBook, Download, ForumControl, ForumState, GroupAdmin, GroupModeration, HistoryBatch, HistoryBatchHandler, HistoryChatEvent, HistoryReaction, HistoryStar, HistoryVote, InviteLinks, JoinRequests, LiveUpdates, MessageButtons, MessageEditing, MessageMedia, MessagePermalinks, MessagePins, MessagePolls, MessageReactions, MessageSearch, MessageStars, MessengerAdapter, MessengerCore, NewPoll, OfficialStats, PassiveUpdates, PersonProfiles, ProfileChange, ProfilePhotos, PushedHistory, ReadState, RemoteFile, ScheduledChanges, ScheduledMessages, SenderIdentities, SenderSearch, SendOptions, Sent, ServerQuery, ServerReads, ThreadAddressing, ThreadRefresh, ThreadRoot, TopicEditing, TopicHistory, TopicReadState, Transcript, } from "../ports/messenger.js";
27
27
  export type { Fetching, MediaOption, MessengerTraits } from "../ports/traits.js";
28
28
  export { senderFacts } from "../replies/dry-run.js";
29
29
  export { type ReplyRender, replyRenderer } from "../replies/rendering.js";
@@ -56,7 +56,7 @@ export { type AccountRenameOptions, type AccountRenaming, accountRenameCommand }
56
56
  export { liftOptionsAfterDashes } from "./after-dashes.js";
57
57
  export { type AgentPolicy, type AgentTask, type EvaluationResult, evaluateAgent, type Observation, } from "./agent-evaluation.js";
58
58
  export { answerEntity } from "./answer-entity.js";
59
- export { type AppDoctorOptions, appDoctorReport } from "./app-doctor-command.js";
59
+ export { type AppDoctorLocal, type AppDoctorOptions, appDoctorReport } from "./app-doctor-command.js";
60
60
  export type { AppMcpOptions } from "./app-mcp-command.js";
61
61
  export { openAppStore } from "./app-store.js";
62
62
  export { askBeforeWrite } from "./ask-before-write.js";
@@ -83,7 +83,7 @@ export type { AppCompletionOptions, CompletionRequest } from "./complete-command
83
83
  export { refuseUnknownKey } from "./config-command.js";
84
84
  export { type ConfigIssue, type ConfigIssueKind, checkConfigText, issueMessage, readConfigFile, readConfigText, settingPathOf, withoutSetting, } from "./config-issues.js";
85
85
  export { loadSnakeCaseConfig } from "./config-keys.js";
86
- export { type AgentRun, type BaseContext, type BaseEnvironment, baseContext, environmentOf, inCommandRun, outputFor, provide, runBudgetOf, secretInputOf, withAgentLevels, withoutOwnPaging, } from "./context.js";
86
+ export { type AgentRun, type BaseContext, type BaseEnvironment, baseContext, environmentOf, inCommandRun, outputFor, provide, runBudgetOf, secretInputOf, setExitCode, withAgentLevels, withoutOwnPaging, } from "./context.js";
87
87
  export { addContractInfo, type ContractEvidenceOptions, contractEvidence } from "./contract-evidence.js";
88
88
  export { sharedCommandTemplate } from "./contract-templates.js";
89
89
  export { csvCell, csvRecords, writeCsv } from "./csv.js";
@@ -124,7 +124,7 @@ export { addMeetingTagsCommand, type MeetingTagsCommandDeps } from "./meeting-ta
124
124
  export { accountFileFor, profilesHere, recalledAccount, rememberAccount, } from "./messenger/accounts.js";
125
125
  export { terminalAsker } from "./messenger/ask.js";
126
126
  export type { CompletionOptions } from "./messenger/complete-command.js";
127
- export { type ConnectOptions, connectFor, type Messenger, type MessengerContext, messengerContext, type ProfileState, type ReadConnection, type StoredMessages, } from "./messenger/context.js";
127
+ export { type ConnectOptions, connectFor, type DoctorCheck, type Messenger, type MessengerContext, messengerContext, type ProfileState, type ReadConnection, type StoredMessages, } from "./messenger/context.js";
128
128
  export { DOCTOR_DEEP_OPTION, damageNotes } from "./messenger/doctor-command.js";
129
129
  export { COMMAND_NEEDS } from "./messenger/lacks.js";
130
130
  export { httpTokenFile, type McpEnvironment, type McpHost, serverEntry } from "./messenger/mcp-command.js";
@@ -148,6 +148,7 @@ export { pagingOf, positiveCount, window, withPaging } from "./paging.js";
148
148
  export { notLocalPaths } from "./path-options.js";
149
149
  export { type CommandPermissions, type ConditionalKey, commandPathKey, commandPermissions, knownBeside, knownPermissionKeys, type PermissionKeyOf, type PermissionKeySource, refuseUnknownPermissionKeys, unknownPermissionIssues, unknownPermissionKeys, } from "./permission-keys.js";
150
150
  export { asFirstWord, commandWords, liftProfile, profileFree, refuseCommandName, rootOf, runGroup, takesProfile, usableProfileName, } from "./profile.js";
151
+ export { openProfileStore, type ProfileStore, type ProfileStoreOptions } from "./profile-store.js";
151
152
  export { ProfileTokenStore, type ProfileTokenStoreOptions, type TokenStorage } from "./profile-token.js";
152
153
  export { createProgram, type ProgramDefinition, type ProgramOptions, type RunOptions, run } from "./program.js";
153
154
  export { type ProjectTextHints, projectAnswerParts, projectCutoffTime, projectEvidenceText, projectWindowOf, withSyncCommands, } from "./project-evidence.js";
@@ -171,5 +172,5 @@ export { type StoreInfo, sharedStoreCommand, storeInfo, storeInfoCommand } from
171
172
  export { type RecoveryCheck, type RecoveryRun, recoveryNotes, storeRecoverCommand, storeRecoveryCheck, storeRecoveryRun, } from "./store-recover.js";
172
173
  export { changeStoreSetting, isStoreSetting, STORE_SETTINGS, storeSettings } from "./store-settings.js";
173
174
  export type { TemplatesOptions } from "./templates-command.js";
174
- export { type ManifestVerifyOptions, manifestVerify, signedInSite, storageOf, type TokenSessionOptions, tokenSessionCommand, } from "./token-session.js";
175
+ export { type ManifestVerifyOptions, manifestVerify, signedInSite, storageOf, type TokenEntry, type TokenSessionOptions, tokenSessionCommand, } from "./token-session.js";
175
176
  export { restartServers, type UpgradeContext } from "./upgrade-command.js";
package/dist/cli/index.js CHANGED
@@ -74,7 +74,7 @@ export { compactText, entityRows, GENERIC_ROW, rowShapeOf, rowsOfEntity, SHARED_
74
74
  export { refuseUnknownKey } from "./config-command.js";
75
75
  export { checkConfigText, issueMessage, readConfigFile, readConfigText, settingPathOf, withoutSetting, } from "./config-issues.js";
76
76
  export { loadSnakeCaseConfig } from "./config-keys.js";
77
- export { baseContext, environmentOf, inCommandRun, outputFor, provide, runBudgetOf, secretInputOf, withAgentLevels, withoutOwnPaging, } from "./context.js";
77
+ export { baseContext, environmentOf, inCommandRun, outputFor, provide, runBudgetOf, secretInputOf, setExitCode, withAgentLevels, withoutOwnPaging, } from "./context.js";
78
78
  export { addContractInfo, contractEvidence } from "./contract-evidence.js";
79
79
  export { sharedCommandTemplate } from "./contract-templates.js";
80
80
  export { csvCell, csvRecords, writeCsv } from "./csv.js";
@@ -137,6 +137,7 @@ export { pagingOf, positiveCount, window, withPaging } from "./paging.js";
137
137
  export { notLocalPaths } from "./path-options.js";
138
138
  export { commandPathKey, commandPermissions, knownBeside, knownPermissionKeys, refuseUnknownPermissionKeys, unknownPermissionIssues, unknownPermissionKeys, } from "./permission-keys.js";
139
139
  export { asFirstWord, commandWords, liftProfile, profileFree, refuseCommandName, rootOf, runGroup, takesProfile, usableProfileName, } from "./profile.js";
140
+ export { openProfileStore } from "./profile-store.js";
140
141
  export { ProfileTokenStore } from "./profile-token.js";
141
142
  export { createProgram, run } from "./program.js";
142
143
  export { projectAnswerParts, projectCutoffTime, projectEvidenceText, projectWindowOf, withSyncCommands, } from "./project-evidence.js";