e-arveldaja-mcp 0.41.0 → 0.42.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 (59) hide show
  1. package/.claude/commands/month-end.md +2 -2
  2. package/CHANGELOG.md +9 -0
  3. package/CLAUDE.md +119 -11
  4. package/README.md +8 -4
  5. package/dist/accounting-rules.d.ts +90 -1
  6. package/dist/accounting-rules.d.ts.map +1 -1
  7. package/dist/accounting-rules.js +530 -6
  8. package/dist/accounting-rules.js.map +1 -1
  9. package/dist/api/readonly.api.d.ts +1 -0
  10. package/dist/api/readonly.api.d.ts.map +1 -1
  11. package/dist/api/readonly.api.js +3 -1
  12. package/dist/api/readonly.api.js.map +1 -1
  13. package/dist/api-health.d.ts +3 -0
  14. package/dist/api-health.d.ts.map +1 -1
  15. package/dist/api-health.js +10 -0
  16. package/dist/api-health.js.map +1 -1
  17. package/dist/company-identity.d.ts +98 -0
  18. package/dist/company-identity.d.ts.map +1 -0
  19. package/dist/company-identity.js +328 -0
  20. package/dist/company-identity.js.map +1 -0
  21. package/dist/config.d.ts +1 -1
  22. package/dist/connection-scoped-bundle-store.d.ts.map +1 -1
  23. package/dist/connection-scoped-bundle-store.js +2 -2
  24. package/dist/connection-scoped-bundle-store.js.map +1 -1
  25. package/dist/emta-kmkr.d.ts +11 -1
  26. package/dist/emta-kmkr.d.ts.map +1 -1
  27. package/dist/emta-kmkr.js +19 -3
  28. package/dist/emta-kmkr.js.map +1 -1
  29. package/dist/http-client.d.ts.map +1 -1
  30. package/dist/http-client.js +2 -1
  31. package/dist/http-client.js.map +1 -1
  32. package/dist/prompt-registry.js +1 -1
  33. package/dist/prompt-registry.js.map +1 -1
  34. package/dist/server/create-server.d.ts.map +1 -1
  35. package/dist/server/create-server.js +23 -1
  36. package/dist/server/create-server.js.map +1 -1
  37. package/dist/server/register-domain-tools.d.ts.map +1 -1
  38. package/dist/server/register-domain-tools.js +2 -0
  39. package/dist/server/register-domain-tools.js.map +1 -1
  40. package/dist/statement-balance-store.d.ts.map +1 -1
  41. package/dist/statement-balance-store.js +2 -2
  42. package/dist/statement-balance-store.js.map +1 -1
  43. package/dist/tool-catalog.js +4 -4
  44. package/dist/tool-catalog.js.map +1 -1
  45. package/dist/tools/accounting-data-transfer.d.ts +171 -0
  46. package/dist/tools/accounting-data-transfer.d.ts.map +1 -0
  47. package/dist/tools/accounting-data-transfer.js +721 -0
  48. package/dist/tools/accounting-data-transfer.js.map +1 -0
  49. package/dist/tools/accounting-inbox.d.ts +10 -0
  50. package/dist/tools/accounting-inbox.d.ts.map +1 -1
  51. package/dist/tools/accounting-inbox.js +11 -9
  52. package/dist/tools/accounting-inbox.js.map +1 -1
  53. package/dist/tools/annual-report.d.ts +9 -0
  54. package/dist/tools/annual-report.d.ts.map +1 -1
  55. package/dist/tools/annual-report.js +65 -6
  56. package/dist/tools/annual-report.js.map +1 -1
  57. package/package.json +1 -1
  58. package/server.json +2 -2
  59. package/workflows/month-end.md +1 -1
@@ -213,10 +213,10 @@ Status is HAS BLOCKERS when `ready_to_close` is false, OR `check.balanced` is fa
213
213
 
214
214
  If blockers exist, list specific actions needed. Offer to help fix them.
215
215
  <!-- E_ARVELDAJA_CAPABILITY_CONDITION_START:year-end -->
216
- Capability condition for `year-end`: inspect the connected MCP server's advertised tool list before this section. Run this section only when every named tool is advertised: `prepare_year_end_close`. Otherwise skip this section and continue with the surrounding workflow. Never call a missing tool to probe capability.
216
+ Capability condition for `year-end`: inspect the connected MCP server's advertised tool list before this section. Run this section only when every named tool is advertised: `prepare_year_end_close`, `save_annual_report_account_rule`. Otherwise skip this section and continue with the surrounding workflow. Never call a missing tool to probe capability.
217
217
 
218
218
 
219
219
  For December (the last month of a calendar fiscal year), offer the year-end close next: `prepare_year_end_close` with `year` and the proposed reserve/transfer options (RIK method; dry run). Show the proposed journals and review items. After explicit owner approval, pass the returned single-use `plan_handle`, the same year/options and `confirm: true` to `execute_year_end_close`. A `plan_drift` refusal requires a fresh preview and approval; created journals remain drafts for separate review and registration.
220
220
 
221
- If the annual report's cash flow lists `cash_flow_account_reviews` (a 24xx debt account), show the owner its `explanation` and journals and ask per account. Short version: **Põhitegevus** — tavaline ärivõlg (grupi-/sidusettevõtte arve, omaniku makstud kulud); võlg tekib arvest või kulust. **Finantseerimine** — laen (ka intressita omanikulaen); raha tuleb ilma arveta ja makstakse tagasi. **Segu** — eralda eri kontodele/dimensioonidele, muidu vali suurem osa ja kirjelda lisas. Then add the rule row from `action` and re-run the report.
221
+ If the annual report's cash flow lists `cash_flow_account_reviews` (a 24xx debt account), show the owner its `explanation` and journals and ask per account. Short version: **Põhitegevus** — tavaline ärivõlg (grupi-/sidusettevõtte arve, omaniku makstud kulud); võlg tekib arvest või kulust. **Finantseerimine** — laen (ka intressita omanikulaen); raha tuleb ilma arveta ja makstakse tagasi. **Segu** — eralda eri kontodele/dimensioonidele, muidu vali suurem osa ja kirjelda lisas. After the owner chooses, save it with `save_annual_report_account_rule` (`rule_type: "cash_flow_category"`, the `account_id`, `value: "operating"` or `"financing"`; an `updated` result shows the old → new value) and re-run `generate_annual_report_data`. Edit the rules file by hand only if that call is refused.
222
222
  <!-- E_ARVELDAJA_CAPABILITY_CONDITION_END:year-end -->
package/CHANGELOG.md CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [0.42.0] - 2026-11-08
6
+
7
+ ### Added
8
+
9
+ - **When the annual report asks whether a debt account is everyday business debt or a loan, your answer can now be saved straight from the conversation.** Before, the choice had to be typed by hand into the company's accounting-rules file. Now the assistant saves it for you after you choose, tells you if it replaced an earlier choice, and the next annual-report run uses it. The same works for marking a liability as short- or long-term. Details: new `save_annual_report_account_rule` tool (annual-report group, removed by `EARVELDAJA_DISABLE_ANNUAL_REPORT`; `standard` 128 → 129 tools, `full` 148 → 149, guided unchanged). `rule_type` `cash_flow_category` (`operating` | `investing` | `financing`, any Varad/Kohustused/Omakapital account) or `liability_classification` (`current` | `non_current`, Kohustused only), `account_id` = account number checked against the active company's chart, `remove: true` deletes the rule. It edits the same `account_id | category/classification` table the readers parse — `annual-report/cash-flow-category.md` / `liability-classification.md` in the bundle (under the bundle lock, logged in `log.md`), or the `## Cash Flow Category` / `## Liability Classification` section in single-file mode — keeping any notes around the table. Results: `inserted`, `updated` (with `previous_value`), `unchanged` (nothing written), `removed`, `not_found`; refusals (`account_not_found`, `account_type_mismatch`, `invalid_rule_value`, `value_with_remove`) write nothing. The `cash_flow_account_reviews` action and the month-end year-end guidance now name this tool first, with the file row as the manual alternative. Changing a row keeps its other columns (e.g. a hand-written note), a case-only difference counts as unchanged, a replaced unreadable value is reported as written, CRLF files keep CRLF, and a removal that finds nothing writes nothing (no legacy-file migration, no new bundle).
10
+ - **You can now copy a company's saved rules and local records to another computer, or keep them when you change the company's API key.** Before, the booking rules you saved and the server's own records (bank statement balances, receipts already attached, approved statement checks, the limited-VAT setting, the Lightyear USD pool) stayed on one computer and were tied to the API key, so a new computer or a new key started empty. Now you can save them to one file and load that file on the other side: you first see what would change, a file from another company is refused, nothing already there is overwritten unless you say so, and nothing is written before you approve. Details: new `accounting_data_transfer` tool (standard/full, workflow group, no opt-out flag; `standard` 129 → 130 tools, `full` 149 → 150, a lean all-disabled custom deployment 85 → 86, guided unchanged). `mode: "export"` + `file_path` writes one new `.json` file (allowed roots only, never overwrites: `output_exists`; 0600; no credentials): header `format: "e-arveldaja-mcp-company-data"`, `version: 1`, `exported_at`, `server`, `company` (`name`, `registry_code` with `registry_code_source` — from the public-register mapping below, else best effort from the company's own client record, `client_record` — `vat_number`, `tax_refnumber`), `source_identity`, `rule_scope`, then the active bundle's rule files and the five state stores (`statement-balances.json`, `receipt-attachment-digests.json`, `camt-review-acknowledgements.json`, `limited-vat.json`, `lightyear-usd-pool.json`) with only this connection's records. `mode: "import"` dry run lists every file as `new` / `identical` / `differs` (rule files with row-level changes, state stores with record counts) and returns a `plan_handle`; `execute: true` + the handle writes under the bundle lock. Refusals: `company_mismatch` (a registry code, tax reference number or VAT number differs, or the file cannot be attributed — equal registry code or tax reference number, else equal company name on the same server), `import_path_refused` (unknown or traversing path), `import_file_invalid`, `import_file_too_large` (16 MiB), `plan_drift` (the file, the lists or the local files changed since the dry run), `bundle_storage_required` (single-file mode). Holds: a differing rule file is written only when named in `apply_rule_files`, a state store that already has this company's records only when named in `replace_state_stores` (`rule_file_differs`, `state_store_exists`). Imported records are restamped to the active connection. `file_path` must be absolute in both modes (`file_path_not_absolute`; before, a relative path resolved differently for export and import).
11
+ - **Your saved rules and records now stay with the company when you change its API key.** Before, they were tied to the API key, so a new key for the same company started with an empty rules store. Now the server finds the company's registry code once from public registers and keeps everything in a folder for that company; your existing rules are copied there the first time, and the old folder is kept. If the code cannot be found for certain, nothing changes. Details: `src/company-identity.ts`. Source (a): with `/vat_info.vat_number`, EMTA's KMKR query, the "Isikukood/registrikood" cell of the one active row with a valid 8-digit check digit (`emta_kmkr`); (b) without a VAT number, the business register autocomplete by `/invoice_info.invoice_company_name`, accepted only for exactly one active (R/L/N) company with exactly that normalized name (`ariregister_name`); otherwise unresolved (per-key store kept, reason in the export notes). Mapping fingerprint → `{server, registry_code, source, resolved_at}` in `company-identity.json` in the global config dir (0600). The lookup runs at most once per connection per process (unresolved: retried after 1 h), only after a signed request of that key succeeded in this process, never on a rules read; once mapped it works offline. A name match is also refused when the company's own client record has another registry code or another mapped connection of that code has a VAT number or another name. A damaged mapping file is reported and never overwritten, and a company already in use is never dropped mid-process. Company store `accounting-rules/<sha256("company\0"+server+"\n"+regcode)>/` — plain 64-hex like a per-key folder, so released versions (≤ 0.41.x) started on the same config folder still use their per-key store instead of mistaking it for a shared rules folder. First use copies the most recently modified per-key store mapped to the company under both stores' locks into a staging folder that is renamed into place in one step (`migration.json` marker, `kind: "company"`); other per-key stores are never merged and are reported as `storage_notice` (save tools' `rule_scope` answer, export notes), as is a source store changed after the copy. Connection-scoped records: new ones are stamped `company:<key>`; records stamped by any key mapped to the same company are read; other companies' records stay refused. `EARVELDAJA_RULES_DIR` / `EARVELDAJA_RULES_FILE` / root bundles unchanged. The export header gains `registry_code_source`, and import compares by registry code first. Import also: holds the local records of an export from another e-arveldaja server (`state_store_server_mismatch`; rule files still import), warns when rules from a shared rules folder go into one company's store, refuses import files whose echoed header values are not plainly shaped (`import_file_invalid`), and says that an interrupted import is resumed by running the dry run again. New hidden requests per connection (once): `/vat_info`, then EMTA, or `ariregister.rik.ee` plus the clients list.
12
+ - **When you save a company rule, you are now told whether it applies only to this company or to every company the server works with.** Before, a rule saved while several companies shared one rules folder silently applied to all of them. Now the answer says so and explains how to keep companies separate; the rule is still saved. Details: `save_auto_booking_rule` and `save_annual_report_account_rule` return `rule_scope: "this_company"` (the default per-connection bundle) or `"shared"` (`EARVELDAJA_RULES_DIR`, `EARVELDAJA_RULES_FILE` or a kept-in-place project/global root bundle), and `rule_scope_warning` when the store is shared and the server has more than one connection (give each company its own `EARVELDAJA_RULES_DIR`, or unset it to use the per-company default).
13
+
5
14
  ## [0.41.0] - 2026-11-07
6
15
 
7
16
  ### Fixed
package/CLAUDE.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # e-arveldaja MCP Server
2
2
 
3
3
  TypeScript MCP server for the Estonian e-arveldaja (RIK e-Financials) REST API.
4
- 128 tools by default on the `standard` profile; opt-in `guided` / `guided-sales` expose 19 / 20 tools, and `full` exposes all 148. The prompt registry holds 16 workflow prompts (guided profiles register fewer — a prompt whose required tools are all absent is not registered) and there are 15 resources across 12 modules. Supports multiple companies/accounts.
4
+ 130 tools by default on the `standard` profile; opt-in `guided` / `guided-sales` expose 19 / 20 tools, and `full` exposes all 150. The prompt registry holds 16 workflow prompts (guided profiles register fewer — a prompt whose required tools are all absent is not registered) and there are 15 resources across 12 modules. Supports multiple companies/accounts.
5
5
 
6
6
  ## Quick Start
7
7
 
@@ -75,6 +75,109 @@ Set `EARVELDAJA_RULES_DIR` explicitly for a stable per-company path
75
75
  companies. Concurrent writes from multiple MCP clients sharing one bundle dir are
76
76
  serialized with an `O_EXCL` lock file at `<dir>.lock` (`withBundleLock()`).
77
77
 
78
+ Only the default per-connection hashed bundle is private to one company;
79
+ `EARVELDAJA_RULES_DIR`, `EARVELDAJA_RULES_FILE` and a kept-in-place project/global
80
+ root bundle are shared by every connection of the server. The rule-saving tools
81
+ (`save_auto_booking_rule`, `save_annual_report_account_rule`) say so at the point
82
+ of saving: `rule_scope: "this_company" | "shared"` (`describeAccountingRuleScope()`,
83
+ shared = not `isPerConnectionBundleStorage()`), plus a plain-language
84
+ `rule_scope_warning` when the store is shared and the server has more than one
85
+ connection. The save is never refused.
86
+
87
+ **Company-keyed default store** (`src/company-identity.ts`). The API has no
88
+ registry-code field, so the company's registry code comes from public registers:
89
+ (a) with `/vat_info.vat_number`: EMTA's KMKR query (the shared `src/emta-kmkr.ts`
90
+ lookup/cache) — the "Isikukood/registrikood" cell of the one active row, accepted
91
+ only with a valid 8-digit check digit (`isValidEstonianRegistryCode`, weights
92
+ 1..7 then 3..9, mod 11), source `emta_kmkr`; (b) no VAT number: the business
93
+ register autocomplete (`GET https://ariregister.rik.ee/est/api/autocomplete?q=<name>`,
94
+ 10 s, 256 KiB) by `/invoice_info.invoice_company_name` — accepted automatically
95
+ (official register, owner decision) only when exactly one ACTIVE company (status
96
+ R/L/N; K = deleted excluded; historical names do not count) has a name exactly
97
+ equal after `exactCompanyName` (NFC, whitespace collapsed, trimmed, lowercased),
98
+ source `ariregister_name`. A name match is also refused when the company's own
99
+ client record carries another registry code (`ariregister_client_record_mismatch`;
100
+ an unreadable clients list is `client_record_unavailable`) or another mapped
101
+ connection on the same server has that code with a VAT number or another name
102
+ (`ariregister_conflicting_mapping`). (c) Anything else (none, several, only
103
+ deleted, name null, network failure) is unresolved: the per-key store stays,
104
+ with a reason (`unresolvedCompanyReason`) shown in the export notes. Never guessed.
105
+ The mapping fingerprint → `{server, registry_code, source, resolved_at,
106
+ vat_number, company_name}` is persisted in `<globalConfigDir>/company-identity.json`
107
+ (0600), written under `withBundleLock(<file>)` after a fresh re-read. A damaged
108
+ file (bad JSON, unknown version, an invalid entry, > 1 MiB) is logged and never
109
+ overwritten: its valid entries are still used, new connections stay unresolved
110
+ (`company_identity_file_unreadable`). A company already adopted in this process
111
+ is never dropped or switched (stores never change mid-process). Resolution runs
112
+ lazily at the tool-invocation wrapper in `create-server.ts`, only once a signed
113
+ request of that key got a 2xx answer in this process (`hasAuthenticatedSuccess`,
114
+ `src/api-health.ts`; startup metadata does not count, so stale keys never send
115
+ it), once per connection per process (an unresolved one is retried after 1 h);
116
+ hidden requests are `/vat_info`, then EMTA, or the business register plus the
117
+ clients list, never again once mapped. Rules reads never touch the network: the
118
+ company is adopted from the mapping file (`adoptedCompany`) at tool-call start.
119
+ A resolved company uses `accounting-rules/<company key>/`, company key =
120
+ sha256("company\0" + server + "\n" + regcode): plain 64-hex like a per-key dir
121
+ (domain-separated), because released versions (≤ 0.41.x) treat any other child
122
+ of `accounting-rules/` as a shared root bundle; its lock/staging siblings
123
+ (`<key>.lock`, `<key>.migrating`) match their scoped-name patterns too (pinned by
124
+ a test that runs the released `chooseDefaultBundleStorage`,
125
+ `src/__fixtures__/released-rules-storage.ts`). Legacy file:
126
+ `<globalConfigDir>/<company key>/accounting-rules.md`. First use copies
127
+ (non-destructively, under the company dir's lock and the source store's lock,
128
+ symlinks skipped) the most recently modified per-key store of any fingerprint
129
+ mapped to the same company into `<key>.migrating`, stages its legacy file inside
130
+ (`legacy-accounting-rules.pending`), writes `migration.json` (`kind: "company"`,
131
+ `company_key`, `source_scope`, `migrated_at`, `not_merged`), renames the staging
132
+ dir into place, then moves the legacy file out (finished on the next use after a
133
+ crash; a leftover staging dir is redone). The other per-key stores are never
134
+ merged and are reported as `storage_notice` in the save tools' `rule_scope`
135
+ answer and the export notes; so are a per-key store that appears after the
136
+ company store exists and a source store modified after `migrated_at`. A failed
137
+ migration keeps the per-key store for the whole process. Record stamps: new
138
+ writes carry `company:<key>`; reads accept that stamp, the current fingerprint
139
+ and every fingerprint mapped to the same company (so records survive key
140
+ rotation); every other stamp is still refused. Read caches key on the sorted
141
+ accepted-stamp list (`bundleRecordIdentityCacheKey`). `RULES_DIR` / `RULES_FILE`
142
+ / kept-in-place root bundles are unchanged.
143
+
144
+ **Company data export / import** (`accounting_data_transfer`,
145
+ `src/tools/accounting-data-transfer.ts`; standard/full, workflow group, no
146
+ opt-out flag): `file_path` must be absolute in both modes
147
+ (`file_path_not_absolute`). `mode: "export"` writes one new `.json` file (`file_path` under
148
+ the allowed roots, `O_EXCL`, 0600; `output_exists` if present) with header
149
+ `{format: "e-arveldaja-mcp-company-data", version: 1, exported_at, server,
150
+ company: {name, registry_code, registry_code_source (`emta_kmkr` |
151
+ `ariregister_name` from the mapping, else `client_record` best effort), vat_number, tax_refnumber},
152
+ source_identity, rule_scope}` and `files`: every transferable rule file of the
153
+ active bundle (`isTransferableRuleFile`: index/log, `auto-booking/*.md`,
154
+ `owner-expense/policy.md`, `annual-report/{settings,liability-classification,cash-flow-category}.md`
155
+ — other connections' hashed subdirs are never included) plus the five state
156
+ stores (`statement-balances.json`, `receipt-attachment-digests.json`,
157
+ `camt-review-acknowledgements.json`, `limited-vat.json`,
158
+ `lightyear-usd-pool.json`) holding only this connection's records, unstamped.
159
+ `mode: "import"`: strict schema (echoed values strictly shaped: ISO `exported_at`,
160
+ `https://` `server`, 8-digit `registry_code`, plain VAT/tax numbers; the
161
+ `company_mismatch` reason is sandboxed), 16 MiB cap, known relative paths only
162
+ (`import_path_refused`), per-store record shape check; `compareCompanyIdentity`
163
+ refuses `company_mismatch` when any identifier both sides have differs or none
164
+ of equal registry code / equal tax reference number / equal name on the same
165
+ server holds. Dry run lists per file `new | identical | differs | skipped`
166
+ (index/log are regenerated/kept), row-level rule diffs (sandboxed) and state
167
+ record counts, issuing a `plan_handle` bound to the file digest, the args and a
168
+ digest of the touched local files; execute re-checks both under `withBundleLock`
169
+ (`plan_drift`). A differing rule file is replaced only when named in
170
+ `apply_rule_files`; a state store with existing records for this connection is
171
+ held (`state_store_exists`) unless named in `replace_state_stores`. Imported
172
+ state records are restamped to the active connection; other connections'
173
+ records stay. Single-file mode refuses (`bundle_storage_required`). An export
174
+ from another API server (demo vs live) has its state stores held
175
+ (`state_store_server_mismatch`, not lifted by `replace_state_stores`); its rule
176
+ files can still be imported. A `rule_scope: "shared"` export imported into a
177
+ company's own store gets a warning note listing the rule files. The import is
178
+ not atomic (files are written one by one); every import answer says to rerun the
179
+ dry run to see what is in place after an interruption.
180
+
78
181
  ### Opening balances (algbilanss)
79
182
 
80
183
  e-arveldaja's REST API exposes "Algbilansi kanded" as `operation_type=INITIAL`.
@@ -116,7 +219,12 @@ Liability working capital is 22xx (customer prepayments), 23xx and 25xx–27xx.
116
219
  enters both bridges) or `financing`; `isLiabilityWorkingCapitalAccount` is the
117
220
  single decision both bridges use. A rule-less 24xx account with cash movements
118
221
  gets a `cash_flow_account_reviews` entry (Estonian when-to-choose guidance and
119
- the rule row to add).
222
+ the `save_annual_report_account_rule` call to make, file row as fallback). That
223
+ tool (annual-report group, standard/full) writes `cash_flow_category` and
224
+ `liability_classification` rows into the same table the readers parse (bundle
225
+ concept file or single-file section), after checking the account against the
226
+ active chart (cash flow: Varad/Kohustused/Omakapital; liability: Kohustused).
227
+ Re-saving the same value is `unchanged`; a different value reports old → new.
120
228
  Exact invoice plus direct operating-account distributions are supported when
121
229
  their signed amounts and account/dimension slices cover the registered cash
122
230
  movement completely. Realized FX within an operating payment follows that
@@ -160,7 +268,7 @@ Opening balances are maintained in e-arveldaja. Statement-closing snapshots
160
268
  surface is a fixed per-session token cost. Eight env flags control optional
161
269
  parts of the surface (see `getToolExposureConfig()` in `src/config.ts`):
162
270
 
163
- `EARVELDAJA_PROFILE` provides one-choice surfaces: `guided` (19 merged daily-bookkeeping tools), `guided-sales` (those 19 plus the `manage_sale_invoice` sales façade — read plus the full prepare/execute mutation lifecycle: create/update/delete/confirm/invalidate/send/recurring and inline resolve-or-create customer, 20 total), `standard` (the absent-variable compatibility default, 128), or `full` (all 148, including granular/setup tools and the workflow-state paging tool `get_workflow_page`). Guided profiles are opt-in for this release. Any explicitly present legacy exposure flag forces the normalized profile to `custom` and preserves the flag combination below. Profile and catalog fingerprint are part of plan/file-reference scope: restart and obtain a fresh preview after changing them.
271
+ `EARVELDAJA_PROFILE` provides one-choice surfaces: `guided` (19 merged daily-bookkeeping tools), `guided-sales` (those 19 plus the `manage_sale_invoice` sales façade — read plus the full prepare/execute mutation lifecycle: create/update/delete/confirm/invalidate/send/recurring and inline resolve-or-create customer, 20 total), `standard` (the absent-variable compatibility default, 130), or `full` (all 150, including granular/setup tools and the workflow-state paging tool `get_workflow_page`). Guided profiles are opt-in for this release. Any explicitly present legacy exposure flag forces the normalized profile to `custom` and preserves the flag combination below. Profile and catalog fingerprint are part of plan/file-reference scope: restart and obtain a fresh preview after changing them.
164
272
 
165
273
  The guided surface is sized for routing clarity, not token cost (per-tool measurement shows no cost cliff at 20). The **≤ 20** figure is a target, not a hard wall: 21–24 is a deliberate-exception band (allowed only with a recorded `CHANGELOG` rationale when no existing tool can absorb the capability), and 24 is the hard backstop above which the surface must be redesigned by merging tools rather than adding. Before adding any guided tool, apply the add/don't-add criteria in [`docs/guided-tool-policy.md`](docs/guided-tool-policy.md) — prefer a new `mode` on an existing façade, a `continue_accounting_workflow` continuation, or `standard`/`full` placement (as with `get_server_status`) over growing the daily surface.
166
274
 
@@ -228,8 +336,8 @@ without changing the default:
228
336
  up and managed in the e-arveldaja UI. Saves ≈1.7k tokens.
229
337
  - **`EARVELDAJA_DISABLE_ANNUAL_REPORT=1`** — do not register the annual-report /
230
338
  year-end tools (`prepare_year_end_close`, `generate_annual_report_data`,
231
- `execute_year_end_close`). Use for the bulk of the year; re-enable at closing
232
- time. Saves ≈0.4k tokens.
339
+ `execute_year_end_close`, `save_annual_report_account_rule`). Use for the bulk of the year; re-enable at closing
340
+ time. Saves ≈0.8k tokens.
233
341
  - **`EARVELDAJA_DISABLE_SALES=1`** — do not register the sales-invoicing side:
234
342
  the 11 sale-invoice tools (`list/get/create/update/delete/confirm/invalidate_sale_invoice`,
235
343
  `get_sale_invoice_delivery_options`, `send_sale_invoice`,
@@ -244,13 +352,13 @@ without changing the default:
244
352
  `DISABLE_SALES` deployment usually sets this too — but the flags are
245
353
  independent. Saves ≈1.3k tokens (7 tools).
246
354
 
247
- The standard surface is 128 tools; `DISABLE_LIGHTYEAR` in a custom profile drops it to 122.
355
+ The standard surface is 130 tools; `DISABLE_LIGHTYEAR` in a custom profile drops it to 124.
248
356
  `EXPOSE_GRANULAR_TOOLS` adds the 10 granular tools, `EXPOSE_SETUP_TOOLS` the 3
249
- credential tools; enabling both (with `full`'s `get_workflow_page`) raises it to the full 148. The five opt-out
357
+ credential tools; enabling both (with `full`'s `get_workflow_page`) raises it to the full 150. The five opt-out
250
358
  group flags trim the default further — `DISABLE_TAX_TOOLS` (−5),
251
- `DISABLE_REFERENCE_ADMIN` (−9), `DISABLE_ANNUAL_REPORT` (−3), `DISABLE_SALES`
359
+ `DISABLE_REFERENCE_ADMIN` (−9), `DISABLE_ANNUAL_REPORT` (−4), `DISABLE_SALES`
252
360
  (−13), `DISABLE_PRODUCTS` (−7) — so a lean purchase-side-only deployment with
253
- every disable flag set (incl. Lightyear) lands at 85 tools. (The former
361
+ every disable flag set (incl. Lightyear) lands at 86 tools. (The former
254
362
  `prepare_accounting_inbox` / `run_accounting_inbox_dry_runs` tools were
255
363
  exact aliases of `accounting_inbox` `mode="scan"` / `mode="dry_run"` and have
256
364
  been removed — use `accounting_inbox` with the matching `mode`.)
@@ -771,7 +879,7 @@ context.
771
879
  - MCP resources in `src/resources/accounting-knowledge-resources.ts`
772
880
  (`earveldaja://accounting_knowledge` and `…/{path}`) expose the OKF
773
881
  accounting-rules bundle. This is operator-curated configuration entering
774
- only through the approval-gated `save_auto_booking_rule` path, so it is
882
+ only through the approval-gated `save_auto_booking_rule` / `save_annual_report_account_rule` paths, so it is
775
883
  treated as trusted and emitted unwrapped, same as static reference data.
776
884
  Concept reads are path-traversal-guarded (resolved/realpath must stay
777
885
  inside the bundle, `.md` only).
@@ -858,5 +966,5 @@ import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js"
858
966
  const transport = new StdioClientTransport({ command: "node", args: ["dist/index.js"] });
859
967
  const client = new Client({ name: "test", version: "1.0.0" });
860
968
  await client.connect(transport);
861
- const { tools } = await client.listTools(); // 128 tools (standard profile)
969
+ const { tools } = await client.listTools(); // 130 tools (standard profile)
862
970
  ```
package/README.md CHANGED
@@ -2,7 +2,9 @@
2
2
 
3
3
  [![npm](https://img.shields.io/npm/v/e-arveldaja-mcp)](https://www.npmjs.com/package/e-arveldaja-mcp)
4
4
 
5
- MCP server for the Estonian e-arveldaja (RIK e-Financials) REST API. 128 tools on the standard profile, 16 workflow prompts, 15 resources. Works with any MCP client — Claude Code, Codex CLI, Gemini CLI, Cursor, Windsurf, Cline, and others.
5
+ MCP server for the Estonian e-arveldaja (RIK e-Financials) REST API. 130 tools on the standard profile, 16 workflow prompts, 15 resources. Works with any MCP client — Claude Code, Codex CLI, Gemini CLI, Cursor, Windsurf, Cline, and others.
6
+
7
+ > **Rules and company state follow the company; export and import (0.42.0).** Your booking rules and saved state (statement balances, receipt checks, limited-VAT records, Lightyear USD pool) are now kept per company, identified by its registry code from the EMTA VAT register or the business register, so they survive an API key change; existing folders are copied over once, the old ones are kept. The new `accounting_data_transfer` tool exports a company's rules and state to one file and imports it on another computer after a preview and your approval. `save_annual_report_account_rule` saves a cash-flow (operating/investing/financing) or liability (current/non-current) account choice from the conversation, and rule saves now say whether the rule applies to this company only or to every company sharing the rules folder. See the [changelog](CHANGELOG.md) for details.
6
8
 
7
9
  > **Cash-flow 24xx accounts, USD pool recovery, limited-VAT journal takeover (0.41.0, behaviour change).** The annual cash-flow statement now bridges customer prepayments (22xx) as operating working capital, while a 24xx account (group, related-party or other short-term debt) with cash movements needs one owner decision — operating or financing — shown in a per-account review with an explanation and the rule to add. A blocked Lightyear USD pool now says truthfully how to recover, and the pool opening can be replaced, with approval, only while the pool is blocked. `limited_vat` can take over a monthly VAT journal you booked by hand, so later invoices become corrections. The inbox receipt preview no longer stops when your company name cannot be read. See the [changelog](CHANGELOG.md) for details.
8
10
 
@@ -121,6 +123,8 @@ By default these rules are stored as an [Open Knowledge Format](https://github.c
121
123
 
122
124
  The bundle is also browsable as MCP resources under `earveldaja://accounting_knowledge`. When several MCP clients share one bundle directory, concurrent rule writes are serialized with a lock file so the index never drifts out of sync with the concepts.
123
125
 
126
+ To move a company's saved rules and local state (statement balances, receipt digests, CAMT acknowledgements, limited-VAT settings, Lightyear USD pool) to another machine, use `accounting_data_transfer` (`file_path` must be an absolute path): `mode: "export"` writes one JSON file (no credentials); `mode: "import"` on the target shows a dry run, refuses another company's file, never overwrites existing state unless you name it, and writes only after your approval. The default rules store follows the company, not the API key: the server finds the company's registry code once from public registers (EMTA's VAT-number query, or the business register by the exact company name when there is no VAT number) and keeps rules and records in a per-company folder, so a new API key for the same company keeps them. When the code cannot be found for certain, the store stays tied to the key.
127
+
124
128
  ### 4. Opening balances (algbilanss)
125
129
 
126
130
  Opening balances come directly from e-arveldaja as `operation_type=INITIAL`. Account balances, statements, annual reports and dividend checks include registered, non-deleted opening postings with their original dates, clients and dimensions. If no INITIAL exists, calculations use the remaining API journals normally. Annual cash flow excludes the opening position.
@@ -129,7 +133,7 @@ The former `import_opening_balances` tool and local opening-register support hav
129
133
 
130
134
  ### Trimming the tool surface
131
135
 
132
- Choose one explicit surface with `EARVELDAJA_PROFILE`: `guided` is the opt-in 19-tool daily-bookkeeping surface; `guided-sales` adds the `manage_sale_invoice` sales façade (20 tools) — reads invoices and runs the full sale-invoice lifecycle (create/update/delete/confirm/invalidate/send/recurring, plus inline resolve-or-create customer) behind the two-call prepare/execute approval gate; `standard` is the absent-variable compatibility default (128 tools); and `full` exposes all 148 tools, including granular and configured-mode credential administration. Every non-guided surface also carries `get_server_status`, a compact read-only report of the running version, active profile, and any active point-of-use release notices.
136
+ Choose one explicit surface with `EARVELDAJA_PROFILE`: `guided` is the opt-in 19-tool daily-bookkeeping surface; `guided-sales` adds the `manage_sale_invoice` sales façade (20 tools) — reads invoices and runs the full sale-invoice lifecycle (create/update/delete/confirm/invalidate/send/recurring, plus inline resolve-or-create customer) behind the two-call prepare/execute approval gate; `standard` is the absent-variable compatibility default (130 tools); and `full` exposes all 150 tools, including granular and configured-mode credential administration. Every non-guided surface also carries `get_server_status`, a compact read-only report of the running version, active profile, and any active point-of-use release notices.
133
137
 
134
138
  The setup choices map exactly: **Daily bookkeeping** → `guided`; **Daily bookkeeping plus sales invoices** → `guided-sales`; **Bookkeeping plus investments** → `standard` with Lightyear enabled; **Full advanced toolset** → `full`. Guided profiles are opt-in in this release, not the recommended/default daily surface. After changing profiles, restart and run fresh previews; an old proposal or plan handle is never approval under the new profile.
135
139
 
@@ -140,11 +144,11 @@ The tool list is sent into the model's context on every session, so it is a fixe
140
144
  - `EARVELDAJA_DISABLE_LIGHTYEAR=1` — drops the Lightyear investment tools (`book_lightyear_*`, `parse_lightyear_*`, `lightyear_portfolio_summary`) and the `lightyear-booking` prompt. Use it when the company does not track investments.
141
145
  - `EARVELDAJA_DISABLE_TAX_TOOLS=1` — drops the Estonian tax helpers (`check_vat_registration_threshold`, `prepare_dividend_package`, `create_owner_expense_reimbursement`, `check_tax_free_limits`, `limited_vat`) and the VAT-threshold prompt. The statutory tax-rules advice behind `suggest_booking` is unaffected. Use it when you never run VAT-threshold/dividend/reimbursement/tax-free-limit workflows.
142
146
  - `EARVELDAJA_DISABLE_REFERENCE_ADMIN=1` — drops the reference-data admin tools that create/update/delete bank accounts and invoice series and update invoice settings (plus the single-record `get_bank_account`/`get_invoice_series` reads). The `list_*`/`get_invoice_info`/`get_vat_info` reads stay. Use it when the chart of accounts, bank accounts, and invoice series are already set up and managed in the e-arveldaja UI.
143
- - `EARVELDAJA_DISABLE_ANNUAL_REPORT=1` — drops the year-end tools (`prepare_year_end_close`, `generate_annual_report_data`, `execute_year_end_close`). Use it for the bulk of the year; re-enable at closing time.
147
+ - `EARVELDAJA_DISABLE_ANNUAL_REPORT=1` — drops the year-end tools (`prepare_year_end_close`, `generate_annual_report_data`, `execute_year_end_close`, `save_annual_report_account_rule`). Use it for the bulk of the year; re-enable at closing time.
144
148
  - `EARVELDAJA_DISABLE_SALES=1` — drops the sales-invoicing side: the 11 sale-invoice tools, `create_recurring_sale_invoices`, and receivables aging (`compute_receivables_aging`). Payables aging and all purchase-invoice tools stay. Use it for purchase-side-only bookkeeping.
145
149
  - `EARVELDAJA_DISABLE_PRODUCTS=1` — drops the product-catalog tools (`list/get/create/update/deactivate/reactivate/delete_product`). Products are chiefly the sale-invoice line-item catalog (purchase items key on `cl_purchase_articles_id`, though they can also carry an optional `products_id`), so a `DISABLE_SALES` deployment usually sets this too. It only removes catalog management — creating either invoice type still works — so the flags stay independent.
146
150
 
147
- A lean purchase-side-only custom deployment with every disable flag set (incl. Lightyear) has 85 tools instead of the standard 128. Conversely, `EARVELDAJA_PROFILE=full` exposes the complete 148-tool catalog.
151
+ A lean purchase-side-only custom deployment with every disable flag set (incl. Lightyear) has 86 tools instead of the standard 130. Conversely, `EARVELDAJA_PROFILE=full` exposes the complete 150-tool catalog.
148
152
 
149
153
  `EARVELDAJA_DOCUMENT_READING=1` (opt-in, off by default) lets your assistant read a single invoice itself: `process_accounting_document` gains `mode='read'` and `mode='verify'`, every value is checked against the printed text, and only the questions the server cannot settle are put to you before the draft is created. It adds no tool, so the tool counts above do not change.
150
154
 
@@ -58,11 +58,22 @@ export interface SaveAutoBookingRuleInput {
58
58
  reversed_vat_id?: number;
59
59
  reason?: string;
60
60
  }
61
+ /**
62
+ * The company a connection resolved to from a public register (registry
63
+ * code): `key` = sha256(server + registry code); `fingerprints` = every
64
+ * connection fingerprint the mapping file ties to that company (key rotation).
65
+ */
66
+ export interface AccountingRulesCompany {
67
+ key: string;
68
+ fingerprints: readonly string[];
69
+ }
61
70
  interface AccountingRulesConnection {
62
71
  name: string;
63
72
  stableIdentity: string;
64
73
  /** How many connections this server has configured (legacy-record gating). */
65
74
  connectionCount?: number;
75
+ /** Present when the connection's company is resolved; absent = today's fingerprint scope. */
76
+ company?: AccountingRulesCompany;
66
77
  }
67
78
  declare const AUTO_BOOKING_RULE_ACTION_FIELDS: readonly ["purchase_article_id", "purchase_account_id", "purchase_account_dimensions_id", "liability_account_id", "vat_rate_dropdown", "reversed_vat_id"];
68
79
  export declare function initAccountingRulesConnection(getter: () => AccountingRulesConnection): void;
@@ -77,7 +88,16 @@ export declare function initAccountingRulesConnection(getter: () => AccountingRu
77
88
  export declare function getBundleRecordIdentity(): {
78
89
  stableIdentity: string;
79
90
  connectionCount: number;
91
+ acceptedIdentities: readonly string[];
80
92
  };
93
+ /**
94
+ * Cache key for records read under the active identity: the stamp new records
95
+ * get plus every stamp accepted on read (a newly mapped key of the company
96
+ * changes what is visible).
97
+ */
98
+ export declare function bundleRecordIdentityCacheKey(): string;
99
+ /** The record stamp of a resolved company. */
100
+ export declare function companyRecordStamp(companyKey: string): string;
81
101
  export type BundleRecordIdentityVerdict = {
82
102
  accept: true;
83
103
  warning?: undefined;
@@ -85,6 +105,20 @@ export type BundleRecordIdentityVerdict = {
85
105
  accept: false;
86
106
  warning: string;
87
107
  };
108
+ export interface AccountingRuleScope {
109
+ rule_scope: "this_company" | "shared";
110
+ rule_scope_warning?: string;
111
+ /** Set when other per-key stores of this company exist that were not merged into its store. */
112
+ storage_notice?: string;
113
+ }
114
+ /**
115
+ * Where a saved company rule applies: `this_company` for the default
116
+ * per-connection bundle, `shared` otherwise (EARVELDAJA_RULES_DIR /
117
+ * EARVELDAJA_RULES_FILE / a kept-in-place root bundle). A shared store on a
118
+ * server with several connections gets a plain-language warning; the save is
119
+ * never refused.
120
+ */
121
+ export declare function describeAccountingRuleScope(): AccountingRuleScope;
88
122
  /**
89
123
  * Decide whether a bundle record stamped with `recordIdentity` belongs to the
90
124
  * active connection. A record from another connection is refused. A legacy
@@ -115,11 +149,16 @@ export declare function buildAccountingRulesConnectionScope(_name: string, stabl
115
149
  * Pure with respect to its inputs (only existence checks on derived paths), so
116
150
  * the decision can be unit-tested without touching the real home directory.
117
151
  */
118
- export declare function chooseDefaultBundleStorage(projectRoot: string, globalConfigDir: string, connectionName?: string, stableIdentity?: string): {
152
+ export declare function chooseDefaultBundleStorage(projectRoot: string, globalConfigDir: string, connectionName?: string, stableIdentity?: string, company?: AccountingRulesCompany): {
119
153
  mode: "bundle";
120
154
  dir: string;
121
155
  legacyFile: string;
122
156
  };
157
+ export declare function companyBundleDir(globalConfigDir: string, companyKey: string): string;
158
+ /** Test seam: forget which company stores were checked in this process. */
159
+ export declare function resetCompanyBundleMigrationState(): void;
160
+ /** The active company's notice about per-key stores that were not merged, if any. */
161
+ export declare function getCompanyStorageNotice(): string | undefined;
123
162
  /** Whether the process that owns a lock token (`"<pid>:<uuid>"`) is still alive. */
124
163
  export declare function lockHolderAlive(token: string): boolean;
125
164
  export declare function withBundleLock<T>(dir: string, fn: () => T): T;
@@ -146,6 +185,30 @@ export declare function saveAutoBookingRule(rawInput: SaveAutoBookingRuleInput):
146
185
  export declare function findAutoBookingRule(normalizedCounterparty: string, category?: z.infer<typeof transactionCategorySchema>): AccountingAutoBookingRule | undefined;
147
186
  export declare function getLiabilityClassificationRule(accountId: number): LiabilityClassificationRule | undefined;
148
187
  export declare function getCashFlowCategoryRule(accountId: number): CashFlowCategoryRule | undefined;
188
+ export type AnnualReportAccountRuleType = "cash_flow_category" | "liability_classification";
189
+ export declare const ANNUAL_REPORT_ACCOUNT_RULE_VALUES: Readonly<Record<AnnualReportAccountRuleType, readonly string[]>>;
190
+ export interface SaveAnnualReportAccountRuleInput {
191
+ rule_type: AnnualReportAccountRuleType;
192
+ account_id: number;
193
+ /** Required unless `remove` is true. */
194
+ value?: string;
195
+ remove?: boolean;
196
+ }
197
+ export interface SaveAnnualReportAccountRuleResult {
198
+ path: string;
199
+ action: "inserted" | "updated" | "unchanged" | "removed" | "not_found";
200
+ previous_value?: string;
201
+ value?: string;
202
+ }
203
+ /**
204
+ * Save, update or remove one account-level annual-report rule
205
+ * (`cash_flow_category` / `liability_classification`) in the same table the
206
+ * readers parse: the bundle concept file `annual-report/<…>.md`, or the
207
+ * `## Cash Flow Category` / `## Liability Classification` section of the
208
+ * single-file rules. Prose and the edited row's other columns are preserved;
209
+ * a removal that finds no rule writes nothing (no migration, no scaffold).
210
+ */
211
+ export declare function saveAnnualReportAccountRule(input: SaveAnnualReportAccountRuleInput): SaveAnnualReportAccountRuleResult;
149
212
  export declare function getCurrentYearProfitAccountRule(): number | undefined;
150
213
  export declare function getDefaultOwnerExpenseVatDeductionMode(): OwnerExpenseVatDeductionModeRule | undefined;
151
214
  export declare function getDefaultOwnerExpenseVatDeductionRatio(): number | undefined;
@@ -203,5 +266,31 @@ export declare function readAccountingKnowledgeConcept(rel: string): {
203
266
  rel: string;
204
267
  text: string;
205
268
  } | undefined;
269
+ export declare function isTransferableRuleFile(rel: string): boolean;
270
+ /** The active bundle (dir + sibling legacy file); null in single-file EARVELDAJA_RULES_FILE mode. */
271
+ export declare function resolveActiveRulesBundle(): {
272
+ dir: string;
273
+ legacyFile: string;
274
+ } | null;
275
+ /** Transferable rule files of a bundle dir, "/"-separated and sorted; [] when the dir is absent. */
276
+ export declare function listTransferableRuleFiles(dir: string): string[];
277
+ /** Frontmatter fields and table rows of a rule file, for row-level import diffs. */
278
+ export declare function parseRuleFileContent(content: string): {
279
+ frontmatter: Record<string, string>;
280
+ rows: Array<Record<string, string>>;
281
+ };
282
+ /**
283
+ * Write imported rule files into the bundle. The caller holds the bundle lock.
284
+ * A legacy single file is migrated first (never lost), each file is written
285
+ * atomically 0600 (never through a symlink), then the log gets one entry per
286
+ * message and index.md is regenerated.
287
+ */
288
+ export declare function writeImportedRuleFiles(bundle: {
289
+ dir: string;
290
+ legacyFile: string;
291
+ }, files: ReadonlyArray<{
292
+ rel: string;
293
+ content: string;
294
+ }>, messages: string[]): void;
206
295
  export {};
207
296
  //# sourceMappingURL=accounting-rules.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"accounting-rules.d.ts","sourceRoot":"","sources":["../src/accounting-rules.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAOxB,QAAA,MAAM,6BAA6B;;;EAAqC,CAAC;AACzE,QAAA,MAAM,sBAAsB;;;;EAAkD,CAAC;AAC/E,QAAA,MAAM,sBAAsB;;;;EAAsC,CAAC;AAEnE,QAAA,MAAM,yBAAyB;;;;;;;;;EAS7B,CAAC;AAcH,QAAA,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;iBAQzB,CAAC;AA+BH,MAAM,MAAM,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,6BAA6B,CAAC,CAAC;AACxF,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAC1E,MAAM,MAAM,gCAAgC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AACtF,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAI9E,MAAM,WAAW,wBAAwB;IACvC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;IACrD,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,8BAA8B,CAAC,EAAE,MAAM,CAAC;IACxC,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAID,UAAU,yBAAyB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE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