projectionlab-mcp 1.2.2 → 1.3.1

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 (119) hide show
  1. package/HOW-IT-WORKS.md +5 -4
  2. package/MANUAL-SETUP.md +8 -4
  3. package/README.md +1 -1
  4. package/REFERENCE.md +25 -9
  5. package/SETUP-FOR-AGENTS.md +4 -4
  6. package/dist/bootstrap.js +15 -3
  7. package/dist/bootstrap.js.map +1 -1
  8. package/dist/bridge.d.ts +29 -6
  9. package/dist/config.d.ts +0 -1
  10. package/dist/config.js +0 -2
  11. package/dist/config.js.map +1 -1
  12. package/dist/currentFinances.d.ts +60 -0
  13. package/dist/currentFinances.js +117 -2
  14. package/dist/currentFinances.js.map +1 -1
  15. package/dist/dataModel.d.ts +37 -8
  16. package/dist/dataModel.js +1138 -15
  17. package/dist/dataModel.js.map +1 -1
  18. package/dist/diff.d.ts +26 -10
  19. package/dist/diff.js +163 -23
  20. package/dist/diff.js.map +1 -1
  21. package/dist/editAccess.d.ts +15 -0
  22. package/dist/editAccess.js +29 -0
  23. package/dist/editAccess.js.map +1 -0
  24. package/dist/errors.d.ts +1 -1
  25. package/dist/errors.js.map +1 -1
  26. package/dist/extensionBridge.d.ts +44 -8
  27. package/dist/extensionBridge.js +179 -30
  28. package/dist/extensionBridge.js.map +1 -1
  29. package/dist/index.js +2 -3
  30. package/dist/index.js.map +1 -1
  31. package/dist/instructions.d.ts +1 -1
  32. package/dist/instructions.js +1 -1
  33. package/dist/layout.d.ts +68 -0
  34. package/dist/layout.js +122 -0
  35. package/dist/layout.js.map +1 -0
  36. package/dist/linkedFields.d.ts +77 -0
  37. package/dist/linkedFields.js +191 -0
  38. package/dist/linkedFields.js.map +1 -0
  39. package/dist/pathPatch.d.ts +41 -3
  40. package/dist/pathPatch.js +162 -14
  41. package/dist/pathPatch.js.map +1 -1
  42. package/dist/planSettings.d.ts +21 -2
  43. package/dist/planSettings.js +30 -6
  44. package/dist/planSettings.js.map +1 -1
  45. package/dist/planVersion.d.ts +7 -2
  46. package/dist/planVersion.js +27 -11
  47. package/dist/planVersion.js.map +1 -1
  48. package/dist/plans.d.ts +46 -6
  49. package/dist/plans.js +152 -15
  50. package/dist/plans.js.map +1 -1
  51. package/dist/realEstate.d.ts +20 -0
  52. package/dist/realEstate.js +57 -0
  53. package/dist/realEstate.js.map +1 -1
  54. package/dist/redact.d.ts +20 -0
  55. package/dist/redact.js +62 -0
  56. package/dist/redact.js.map +1 -1
  57. package/dist/resources/dataModel.d.ts +6 -2
  58. package/dist/resources/dataModel.js +96 -16
  59. package/dist/resources/dataModel.js.map +1 -1
  60. package/dist/resources/knowledge.d.ts +7 -1
  61. package/dist/resources/knowledge.js +262 -14
  62. package/dist/resources/knowledge.js.map +1 -1
  63. package/dist/resources/layoutResource.d.ts +19 -0
  64. package/dist/resources/layoutResource.js +43 -0
  65. package/dist/resources/layoutResource.js.map +1 -0
  66. package/dist/resources/planData.js +1 -1
  67. package/dist/resources/planData.js.map +1 -1
  68. package/dist/snapshot.d.ts +2 -1
  69. package/dist/snapshot.js +3 -1
  70. package/dist/snapshot.js.map +1 -1
  71. package/dist/summary.d.ts +39 -2
  72. package/dist/summary.js +148 -31
  73. package/dist/summary.js.map +1 -1
  74. package/dist/tools/bootstrap.js +2 -1
  75. package/dist/tools/bootstrap.js.map +1 -1
  76. package/dist/tools/clonePlan.js +10 -9
  77. package/dist/tools/clonePlan.js.map +1 -1
  78. package/dist/tools/connection.js +8 -8
  79. package/dist/tools/connection.js.map +1 -1
  80. package/dist/tools/deletePlan.js +9 -8
  81. package/dist/tools/deletePlan.js.map +1 -1
  82. package/dist/tools/diff.js +54 -15
  83. package/dist/tools/diff.js.map +1 -1
  84. package/dist/tools/export.js +5 -5
  85. package/dist/tools/export.js.map +1 -1
  86. package/dist/tools/getCurrentFinances.js +80 -24
  87. package/dist/tools/getCurrentFinances.js.map +1 -1
  88. package/dist/tools/getPlan.js +7 -1
  89. package/dist/tools/getPlan.js.map +1 -1
  90. package/dist/tools/getPlanSection.js +27 -4
  91. package/dist/tools/getPlanSection.js.map +1 -1
  92. package/dist/tools/getPlanSettings.js +16 -4
  93. package/dist/tools/getPlanSettings.js.map +1 -1
  94. package/dist/tools/restore.d.ts +4 -3
  95. package/dist/tools/restore.js +82 -42
  96. package/dist/tools/restore.js.map +1 -1
  97. package/dist/tools/schema.js +100 -22
  98. package/dist/tools/schema.js.map +1 -1
  99. package/dist/tools/snapshots.js +39 -19
  100. package/dist/tools/snapshots.js.map +1 -1
  101. package/dist/tools/summary.js +34 -1
  102. package/dist/tools/summary.js.map +1 -1
  103. package/dist/tools/updateAccount.js +69 -26
  104. package/dist/tools/updateAccount.js.map +1 -1
  105. package/dist/tools/updatePlanEvent.js +62 -27
  106. package/dist/tools/updatePlanEvent.js.map +1 -1
  107. package/dist/tools/updatePlanSection.js +59 -12
  108. package/dist/tools/updatePlanSection.js.map +1 -1
  109. package/dist/tools/updatePlanSettings.js +33 -13
  110. package/dist/tools/updatePlanSettings.js.map +1 -1
  111. package/dist/tools/writeGuard.d.ts +11 -0
  112. package/dist/tools/writeGuard.js +17 -0
  113. package/dist/tools/writeGuard.js.map +1 -0
  114. package/dist/types/projectionlab.d.ts +4 -0
  115. package/dist/types/wire.d.ts +57 -8
  116. package/dist/types/wire.js +16 -2
  117. package/dist/types/wire.js.map +1 -1
  118. package/package.json +1 -1
  119. package/skills/projectionlab/SKILL.md +234 -18
package/HOW-IT-WORKS.md CHANGED
@@ -19,7 +19,8 @@ The server opens a WebSocket listener on `127.0.0.1:<PL_WS_PORT>`. A browser-sid
19
19
  `src/types/wire.ts` is the contract shared by the server and every executor:
20
20
 
21
21
  - The executor connects and sends a `hello` frame with a shared token, the protocol version, and an `instanceId` (a stable id for the installation: the extension persists one UUID, the snippet generates one per page load). The server validates the `Origin` header (extension or app origin only), checks the token, and replies `helloAck`, or closes with code `4001` (auth), `4002` (version), `4003` (a takeover replaced this executor), or `4004` (busy: another executor holds the connection, retry later). The server keeps one active executor and the incumbent keeps it: a second authenticated executor is refused with `4004`, retries on a slow schedule, and connects by itself when the active one goes away. It takes over only by sending `takeover: true` in the hello (the extension does that when the user presses Save on its options page) or by repeating the incumbent's `instanceId`, which lets an executor replace its own stale socket. Several server instances (one per host session) can share the port the same way: one holds it and the others retry the bind. A waiting instance with an operation to run connects to the port and sends a `yield` frame carrying the token instead of a `hello`; the holder finishes its queued operations, releases the port, closes its executor with `1012` (an ordinary close, so the executor reconnects within seconds rather than standing by), and closes the yield socket with `4005`. The waiting instance binds the port at once and waits for the executor to reconnect. When several instances wait, the one that loses the bind asks the new holder in turn. A yield from a socket with an `Origin` header is refused, since only another server sends one. The `helloAck` carries the server's release version in `serverVersion` so the extension can show a mismatch line; executors that ignore the field are unaffected, and servers older than the field simply omit it.
22
- - Requests are `{ id, method, params }`; responses are `{ id, ok, result | error }`. Methods map directly to Plugin API calls plus `describeApi`/`waitForApi`.
22
+ - Requests are `{ id, method, params }`; responses are `{ id, ok, result | error }`. Methods map directly to Plugin API calls plus `describeApi`, `waitForApi`, and `apiVersion` (the page's `projectionlabPluginAPI.version`, or `null` when it has none).
23
+ - Writes are checked against the Plugin API contract three times. Each write tool reads the contract before it previews or snapshots anything and refuses a write the contract does not support (`WRITE_NOT_SUPPORTED`). The bridge reads it again in the same operation as the write, and refuses with `CONTRACT_CHANGED` when the tool prepared the write from an export of the other layout (two tabs on different ProjectionLab builds); a plan write also checks the layout of the export it re-reads for its conflict check. An executor whose `hello` lists the `expectApiVersion` feature also gets that version on the write request as `expectApiVersion`, and calls the Plugin API only if the page still reports exactly that version, answering `CONTRACT_CHANGED` otherwise; the check and the call run in the same page turn, so a tab reloaded onto another ProjectionLab version in between is never written to. Every executor gets the write only on the socket the version was read from, so a browser that takes the connection over in between is not written to either.
23
24
  - A ~20 s `ping`/`pong` heartbeat keeps the connection healthy (and keeps a Manifest V3 service worker from being suspended).
24
25
 
25
26
  ### The browser extension
@@ -28,7 +29,7 @@ Manifest V3, in `extension/`. A background service worker owns the WebSocket, re
28
29
 
29
30
  ### The bootstrap snippet
30
31
 
31
- `src/bootstrap.ts` generates a self-contained snippet (returned by the `projectionlab_get_bootstrap` tool) that plays the same executor role from the page's console, with the same protocol and methods. It's the zero-install path and a handy debugging harness, but it lives only until the tab reloads.
32
+ `src/bootstrap.ts` generates a self-contained snippet (returned by the `projectionlab_get_bootstrap` tool) that plays the same executor role from the page's console, with the same protocol and methods. It's the zero-install path and a handy debugging harness, but it lives only until the tab reloads, and it can only read: it has no plan-edits switch.
32
33
 
33
34
  ## 3. Step-by-Step Execution Lifecycle
34
35
 
@@ -52,7 +53,7 @@ The Plugin API provides a targeted `updateAccount` operation for Current Finance
52
53
  3. **Auto-Snapshotting:** on `confirm: true`, the tool passes the affected current section to `SnapshotManager`, which writes a restore-safe local JSON snapshot with an ID and timestamp.
53
54
  4. **Conflict Check:** because `restorePlans` replaces every plan, a plan write re-reads the plans just before writing and refuses with `PLAN_CONFLICT` if any plan was added, removed, or saved in ProjectionLab since the tool read them (`restorePlansIfUnchanged` in `src/extensionBridge.ts`). The re-read and the write run as one operation on the bridge, so a port hand-over to another server instance cannot fall between them: of two instances writing plans at once, one write lands and the other is refused. `projectionlab_update_plan_section` also accepts the dry run's `planVersion` as `expectedPlanVersion` and refuses if the plan was saved after the preview.
54
55
  5. **Execution:** only then does the bridge call `updateAccount()` or the appropriate `restore*()` method.
55
- 6. **Verification:** the tool performs a fresh re-read and checks that the requested change landed. A verification failure is reported with the snapshot retained for recovery.
56
+ 6. **Verification:** the tool performs a fresh re-read and checks, by value, that every field the write sent is stored, so the key order ProjectionLab saves in and the defaults it fills in do not hide a change that landed. A failed check reports `verified: false` and names each path in `verificationIssues` with a reason of `absent`, `shape`, or `value`; the snapshot stays on disk for recovery.
56
57
 
57
58
  ### D. Rollbacks & Recovery
58
59
 
@@ -63,5 +64,5 @@ The Plugin API provides a targeted `updateAccount` operation for Current Finance
63
64
  - The Plugin API key is read only from the MCP host's `env` block, `~/.projectionlab-mcp/.env`, or a development `.env` (gitignored). It is never logged. It stays in the server process and is passed to the page only as an argument to Plugin API calls; the extension does not persist it.
64
65
  - The WebSocket binds to `127.0.0.1` only, accepts only the ProjectionLab app and browser-extension origins, and requires a shared token (`PL_WS_TOKEN`, or auto-generated at `~/.projectionlab-mcp/ws-token` with owner-only permissions), so neither other local processes nor arbitrary web pages can drive your data. Native clients without an `Origin` header still need the token.
65
66
  - Snapshots scrub the literal Plugin API key while preserving restore data. Exports, plan reads, and the `plan-data` resource additionally redact secret-named fields before they are returned or written to disk.
66
- - Read-only mode (the default; any `PL_READ_ONLY` other than `false`) rejects mutation tools before they read, snapshot, or write plan data.
67
+ - Writes are off unless the extension's **Enable agent plan edits** switch is on (options page, off by default). The switch is enforced in the browser, where an agent with access to the computer's files cannot change it: the extension refuses every wire method other than `exportData`, `getAccounts`, `validateApiKey`, `describeApi`, `waitForApi`, and `apiVersion` while it is off, reading the switch from extension storage for each request. The extension also reports the switch to the server (`allowEdits` in its hello, then a `settings` frame on every change), and the server refuses mutation tools before they read, snapshot, or write plan data unless the connected executor reports it on. An executor that does not report it, such as the bootstrap snippet, can only read.
67
68
  - The published npm package ships only `dist/`, the agent skill, and docs (the `files` allowlist in `package.json`), so source and `.env` files are never distributed.
package/MANUAL-SETUP.md CHANGED
@@ -58,13 +58,17 @@ the extension up to date.
58
58
  > extension ID, so enter the port and token into the new extension's options page.
59
59
 
60
60
  Then click the extension's toolbar icon to open its options page and enter
61
- port `8788` and the token from `~/.projectionlab-mcp/ws-token`.
61
+ port `8788` and the token from `~/.projectionlab-mcp/ws-token`. If your
62
+ ProjectionLab account is on v5 Early Access (the app opens at
63
+ `ea.projectionlab.com`), also press **Allow ea.projectionlab.com** on that
64
+ page and approve the browser's prompt.
62
65
 
63
66
  **6. Check the connection.** Open ProjectionLab in that browser and log in.
64
67
  Then ask your assistant to run `projectionlab_check_connection`. When every
65
68
  check passes, ask it about your plan.
66
69
 
67
- The server starts in read-only mode. To let the assistant make changes, add
68
- `PL_READ_ONLY=false` to `~/.projectionlab-mcp/.env` and restart your
69
- assistant. Every setting is listed in the
70
+ The assistant starts out able to read but not change anything. To let it make
71
+ changes, turn on **Enable agent plan edits** on the extension's options page.
72
+ It takes effect at once, with no restart, and turning it off stops changes just
73
+ as quickly. Every setting is listed in the
70
74
  [technical reference](REFERENCE.md#environment-variables).
package/README.md CHANGED
@@ -39,7 +39,7 @@ Prefer to set it up yourself? See **[Manual setup](https://github.com/Backroads4
39
39
 
40
40
  ## Safety
41
41
 
42
- - **Read-only by default.** The assistant can read your plan but not change it until you set `PL_READ_ONLY=false`.
42
+ - **Read-only by default.** The assistant can read your plan but not change it until you turn on **Enable agent plan edits** in the browser extension's options. Turning it off stops changes at once.
43
43
  - **Preview before saving.** Every change is a preview until the assistant explicitly confirms it, and the assistant is instructed to show you the preview and ask first.
44
44
  - **Undo.** Every confirmed change is backed up first, so it can be rolled back.
45
45
  - **No overwriting your edits.** If a plan was saved in ProjectionLab after the assistant read it, the change is refused rather than overwriting your edit.
package/REFERENCE.md CHANGED
@@ -83,11 +83,10 @@ The server starts without `PL_API_KEY` so it can tell the agent what is missing;
83
83
  | `PL_API_KEY` | Yes | - | ProjectionLab Plugin API key; tools that reach the plan fail until it is set |
84
84
  | `PL_WS_PORT` | No | `8788` | Localhost WebSocket port |
85
85
  | `PL_WS_TOKEN` | No | auto-generated | Shared auth token; if unset, generated and saved to `~/.projectionlab-mcp/ws-token` |
86
- | `PL_APP_URL` | No | `https://app.projectionlab.com` | ProjectionLab app URL |
86
+ | `PL_APP_URL` | No | `https://app.projectionlab.com` | An extra page origin allowed to connect the bootstrap snippet. `https://app.projectionlab.com` and `https://ea.projectionlab.com` are always allowed. The extension does not read it. |
87
87
  | `PL_API_READY_TIMEOUT_MS` | No | `30000` | Timeout waiting for Plugin API to attach |
88
88
  | `PL_EXPORT_CACHE_MS` | No | `90000` | How long a full export may be served from cache (writes always invalidate) |
89
89
  | `PL_PRETTY_JSON` | No | `false` | Pretty-print JSON output (uses ~25–40% more tokens) |
90
- | `PL_READ_ONLY` | No | `true` | Write/mutation tools are disabled unless this is exactly `false` |
91
90
  | `PL_SNAPSHOT_DIR` | No | `~/.projectionlab-mcp/snapshots` | Directory for pre-mutation snapshots |
92
91
  | `PL_UPDATE_CHECK` | No | `true` | One request to `registry.npmjs.org` per start to read the latest release number; off only when this is exactly `false` |
93
92
  | `LOG_LEVEL` | No | `info` | Log verbosity (`debug`, `info`, `warn`, `error`) |
@@ -114,10 +113,10 @@ The server starts without `PL_API_KEY` so it can tell the agent what is missing;
114
113
  | `projectionlab_delete_plan` | Delete a plan by exact ID; refuses the last plan (dry-run by default) | Yes |
115
114
  | `projectionlab_list_snapshots` | List saved pre-mutation snapshots | No |
116
115
  | `projectionlab_diff` | Field-level changes between a snapshot and another snapshot or the live data, or between two plans (`planA` and `planB`) | No |
117
- | `projectionlab_restore_current_finances` | Restore Current Finances from snapshot | Yes |
118
- | `projectionlab_restore_plans` | Restore Plans from snapshot | Yes |
119
- | `projectionlab_restore_progress` | Restore Progress from snapshot | Yes |
120
- | `projectionlab_restore_settings` | Restore Settings from snapshot | Yes |
116
+ | `projectionlab_restore_current_finances` | Replace Current Finances with the supplied data | Yes |
117
+ | `projectionlab_restore_plans` | Replace all plans with the supplied array; an empty array is refused | Yes |
118
+ | `projectionlab_restore_progress` | Replace Progress with the supplied data (ProjectionLab 4 only) | Yes |
119
+ | `projectionlab_restore_settings` | Replace Settings with the supplied data | Yes |
121
120
  | `projectionlab_rollback` | Roll back to a previous snapshot | Yes |
122
121
 
123
122
  ## Resources
@@ -127,7 +126,7 @@ The server starts without `PL_API_KEY` so it can tell the agent what is missing;
127
126
  | `projectionlab://plan-data` | Full export of all plans/finances/progress/settings (refreshed per access) |
128
127
  | `projectionlab://summary` | High-level snapshot: net worth, account breakdown, plan count |
129
128
  | `projectionlab://knowledge` | Curated ProjectionLab data-model + FIRE/tax reference (static) |
130
- | `projectionlab://data-model` | Field meanings, units, and allowed values for `listPaths` writes, version-stamped to ProjectionLab 4.6.0 (static) |
129
+ | `projectionlab://data-model` | Field meanings, units, and allowed values for path-addressable reads and writes, version-stamped to ProjectionLab 4.6.0 (v4) and 5.0.0 (v5); follows the connected ProjectionLab version once `projectionlab_check_connection` has run, and `?layout=v4` or `?layout=v5` chooses |
131
130
  | `projectionlab://guide` | Agent guide: setup walkthrough, tool selection, change workflow, privacy rules (static) |
132
131
 
133
132
  ## Prompts
@@ -141,14 +140,31 @@ The server starts without `PL_API_KEY` so it can tell the agent what is missing;
141
140
 
142
141
  ## Safety model
143
142
 
144
- Write operations (`update_*`, `restore_*`, `clone_plan`, `delete_plan`) default to **dry-run mode**. Pass `confirm: true` to execute. Before any confirmed mutation, the server automatically snapshots the affected data section to disk so you can roll back with `projectionlab_rollback`. Writes are disabled entirely unless `PL_READ_ONLY=false`.
143
+ Write operations (`update_*`, `restore_*`, `clone_plan`, `delete_plan`) default to **dry-run mode**. Pass `confirm: true` to execute. Before any confirmed mutation, the server automatically snapshots the affected data section to disk so you can roll back with `projectionlab_rollback`. Writes are disabled entirely unless the browser extension's **Enable agent plan edits** switch is on (its options page; off by default, takes effect at once). The extension refuses every write in the browser while the switch is off, and the server sends no write to an executor that does not report it on, so the console bootstrap snippet and extension releases without the switch can only read. `projectionlab_check_connection` reports the current state as `writesEnabled`.
145
144
 
146
145
  Every write that replaces the plans array re-reads the plans just before writing and refuses with `PLAN_CONFLICT` if any plan was added, removed, or saved in ProjectionLab since the tool read them, so an edit made in the ProjectionLab UI, or a write by another agent's server instance, is never silently overwritten. `projectionlab_update_plan_section` also returns a `planVersion` in its dry run; pass it back as `expectedPlanVersion` when confirming to refuse the write if the plan was saved after the preview.
147
146
 
148
- Plan reads hide secret values: a secret-named field (`apiKey`, `token`, `password`, …) comes back as `[REDACTED]`. A payload for `projectionlab_update_plan_section` or any `restore_*` tool that still holds that sentinel under a secret-named key is refused with `INVALID_INPUT`, dry runs included, naming the offending dot paths. Supply the real value, or change single fields with `projectionlab_update_plan_event` or `projectionlab_update_plan_settings`, which patch by path and never round-trip hidden values.
147
+ Plan reads hide secret values: a secret-named field (`apiKey`, `token`, `password`, …) comes back as `[REDACTED]`. A write payload that still holds that sentinel under a secret-named key is refused with `INVALID_INPUT`, dry runs included, naming the offending dot paths: `sectionData` for `projectionlab_update_plan_section`, the payload of `projectionlab_restore_plans`, `projectionlab_restore_current_finances` and `projectionlab_restore_progress`, and a whole-object value sent to `projectionlab_update_plan_event`, `projectionlab_update_plan_settings` or `projectionlab_update_account`. Supply the real value, or change the fields beside it one at a time by path with `projectionlab_update_plan_event` or `projectionlab_update_plan_settings`, which leaves the hidden value untouched. `projectionlab_restore_settings` is the exception: a secret field left as `[REDACTED]` keeps its stored value, and a payload that leaves a stored secret out is refused.
149
148
 
150
149
  `projectionlab_update_plan_section` also refuses `sectionData` that does not match the section's current container shape (array for milestones, `{ events: [...] }` for event sections, plain object for `variables`, `montecarlo` and `withdrawalStrategy`), so a wrong or omitted payload can never delete a section or change its type.
151
150
 
151
+ `projectionlab_update_plan_event`, `projectionlab_update_plan_settings` and
152
+ `projectionlab_update_account` refuse with `INVALID_INPUT` a write that sets a
153
+ field to a value outside the choices the app offers for it, and the refusal
154
+ lists those choices. `projectionlab_update_plan_section` and the `restore_*`
155
+ tools check the shape of what they write, not these choices. The
156
+ enforced fields are the ones `projectionlab://data-model` tags `observed`, in
157
+ the ProjectionLab 4 and the ProjectionLab 5 layout alike; a listing carries
158
+ `allowedValues` for other fields too, as a hint a write does not enforce. The
159
+ check reaches inside a whole-object write and applies to a leaf only when the
160
+ write changes it, so a value the plan already stores outside the list rides
161
+ through while the field beside it is written.
162
+
163
+ A confirmed write is checked against a fresh re-read. When a requested path is
164
+ missing, holds another JSON type, or holds other contents, the result reports
165
+ `verified: false` and names each failed path in `verificationIssues` with a
166
+ reason of `absent`, `shape`, or `value`.
167
+
152
168
  For a small assumptions or strategy change, first call
153
169
  `projectionlab_get_plan_settings` with the plan name. It returns the current
154
170
  `variables`, `montecarlo`, and `withdrawalStrategy` values as dot paths with
@@ -8,7 +8,7 @@ You are setting this up for a **non-technical user**. Explain each thing you nee
8
8
 
9
9
  **1. Get the user's Plugin API key.** Ask them to open ProjectionLab → Account Settings → Plugins, enable plugins, and copy their **Plugin API Key**. Do **not** invent one, and never print, log, or commit it.
10
10
 
11
- **2. Store the key.** Write it to `~/.projectionlab-mcp/.env` as the line `PL_API_KEY=...` and make the file readable only by the user (`chmod 600`). Every MCP host on the machine reads this file, so the key lives in one place. Do not repeat the key back to the user. Writes stay disabled by default; do not set `PL_READ_ONLY=false` until the user has seen the tool working and explicitly asks.
11
+ **2. Store the key.** Write it to `~/.projectionlab-mcp/.env` as the line `PL_API_KEY=...` and make the file readable only by the user (`chmod 600`). Every MCP host on the machine reads this file, so the key lives in one place. Do not repeat the key back to the user. Writes stay disabled until the user turns them on in the extension; never ask them to until they have seen the tool working and explicitly ask to make changes.
12
12
 
13
13
  **3. Register the server with the user's MCP host.** The server runs with `npx`, which needs Node.js 20 or newer:
14
14
  ```json
@@ -33,8 +33,8 @@ The config location varies by host; see [Adding the server to your MCP host](htt
33
33
  builds and are unverified, so steer the user to Chrome or Firefox when they
34
34
  have a choice, and treat a Brave or Edge report as unverified until reproduced.
35
35
 
36
- - **Quick alternative: no install.** Call the `projectionlab_get_bootstrap` tool, then have the user paste the returned snippet into their ProjectionLab tab's developer console (F12 → Console). It works the same way but must be re-pasted if they reload the page. Good for a first test drive.
36
+ - **Quick alternative: no install.** Call the `projectionlab_get_bootstrap` tool, then have the user paste the returned snippet into their ProjectionLab tab's developer console (F12 → Console). It reads the same way but cannot make changes, and must be re-pasted if they reload the page. Good for a first test drive.
37
37
 
38
- **5. Verify.** Have the user open [ProjectionLab](https://app.projectionlab.com), log in, and confirm plugins are enabled. Then call `projectionlab_check_connection`; it should report all checks passing. Do this before any other tool call.
38
+ **5. Verify.** Have the user open [ProjectionLab](https://app.projectionlab.com), log in, and confirm plugins are enabled. If ProjectionLab sends them to `ea.projectionlab.com` (v5 Early Access), they also press **Allow ea.projectionlab.com** on the extension's options page and approve the browser's prompt. Then call `projectionlab_check_connection`; it should report all checks passing. Do this before any other tool call.
39
39
 
40
- **6. Enabling changes (writes).** Leave everything read-only until the user explicitly asks to make changes. When they do: set `PL_READ_ONLY=false` in `~/.projectionlab-mcp/.env` or the host's `env` block, restart the host, and confirm with `projectionlab_check_connection` that `writesEnabled` is `true`. Every write tool still previews unless called with `confirm: true`: show the user each preview and confirm only the change they approve. Every confirmed change is snapshotted first so it can be rolled back. Tell the user this before the first change.
40
+ **6. Enabling changes (writes).** Leave everything read-only until the user explicitly asks to make changes. When they do: ask them to click the extension's toolbar icon and turn on **Enable agent plan edits** on its options page (it takes effect at once, with no restart; no file or setting on the computer enables writes), then confirm with `projectionlab_check_connection` that `writesEnabled` is `true`. The console bootstrap snippet has no such switch and can only read. Every write tool still previews unless called with `confirm: true`: show the user each preview and confirm only the change they approve. Every confirmed change is snapshotted first so it can be rolled back. Tell the user this before the first change.
package/dist/bootstrap.js CHANGED
@@ -1,10 +1,12 @@
1
1
  import { PROTOCOL_VERSION } from "./types/wire.js";
2
2
  import { VERSION } from "./version.js";
3
3
  /** The Plugin API calls the snippet will run; the meta-operations
4
- * `describeApi` and `waitForApi` are handled by the snippet itself. */
4
+ * `describeApi`, `waitForApi`, and `apiVersion` are handled by the snippet itself. */
5
5
  const PLUGIN_METHODS = [
6
6
  "exportData",
7
+ "getAccounts",
7
8
  "updateAccount",
9
+ "updateAccountValues",
8
10
  "restoreCurrentFinances",
9
11
  "restorePlans",
10
12
  "restoreProgress",
@@ -59,15 +61,24 @@ export function buildBootstrapSnippet(port, token) {
59
61
  }
60
62
  async function handle(frame, ws) {
61
63
  try {
62
- if (frame.method !== "waitForApi" && frame.method !== "describeApi" && !PLUGIN_METHODS.includes(frame.method)) {
64
+ if (frame.method !== "waitForApi" && frame.method !== "describeApi" && frame.method !== "apiVersion" && !PLUGIN_METHODS.includes(frame.method)) {
63
65
  throw new Error("Not a wire protocol method: " + frame.method);
64
66
  }
65
67
  const requested = frame.method === "waitForApi" ? Number((frame.params || [])[0]) : NaN;
66
68
  const api = await waitForApi(Number.isFinite(requested) && requested > 0 ? requested : 15000);
67
69
  let result;
68
70
  if (frame.method === "waitForApi") result = true;
71
+ else if (frame.method === "apiVersion") result = api.version === undefined ? null : api.version;
69
72
  else if (frame.method === "describeApi") result = describeApi(api);
70
73
  else {
74
+ if (Object.prototype.hasOwnProperty.call(frame, "expectApiVersion")) {
75
+ const actual = api.version === undefined ? null : api.version;
76
+ if (actual !== frame.expectApiVersion) {
77
+ const e = new Error("Plugin API version is " + JSON.stringify(actual) + ", not the " + JSON.stringify(frame.expectApiVersion) + " the server checked");
78
+ e.code = "CONTRACT_CHANGED";
79
+ throw e;
80
+ }
81
+ }
71
82
  const fn = api[frame.method];
72
83
  if (typeof fn !== "function") throw new Error("Plugin API method unavailable: " + frame.method);
73
84
  result = await fn.apply(api, frame.params);
@@ -76,6 +87,7 @@ export function buildBootstrapSnippet(port, token) {
76
87
  } catch (err) {
77
88
  const msg = err && err.message ? err.message : String(err);
78
89
  const code = err && err.code === "API_NOT_AVAILABLE" ? "API_NOT_AVAILABLE"
90
+ : err && err.code === "CONTRACT_CHANGED" ? "CONTRACT_CHANGED"
79
91
  : /api.?key|invalid key|unauthori[sz]ed|forbidden|\\b401\\b|\\b403\\b/i.test(msg) ? "API_KEY_INVALID" : "UNKNOWN";
80
92
  ws.send(JSON.stringify({ type: "response", id: frame.id, ok: false, error: { code, message: msg } }));
81
93
  }
@@ -83,7 +95,7 @@ export function buildBootstrapSnippet(port, token) {
83
95
  function connect() {
84
96
  if (stopped) return;
85
97
  const ws = new WebSocket("ws://127.0.0.1:" + cfg.port);
86
- ws.onopen = () => ws.send(JSON.stringify({ type: "hello", token: cfg.token, protocolVersion: cfg.protocolVersion, executor: cfg.executor, instanceId }));
98
+ ws.onopen = () => ws.send(JSON.stringify({ type: "hello", token: cfg.token, protocolVersion: cfg.protocolVersion, executor: cfg.executor, instanceId, features: ["expectApiVersion"] }));
87
99
  ws.onmessage = (ev) => {
88
100
  let frame;
89
101
  try { frame = JSON.parse(ev.data); } catch { return; }
@@ -1 +1 @@
1
- {"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../src/bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAmB,MAAM,iBAAiB,CAAC;AACpE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC;uEACuE;AACvE,MAAM,cAAc,GAAiE;IACnF,YAAY;IACZ,eAAe;IACf,wBAAwB;IACxB,cAAc;IACd,iBAAiB;IACjB,iBAAiB;IACjB,gBAAgB;CACjB,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,UAAU,qBAAqB,CAAC,IAAY,EAAE,KAAa;IAC/D,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC;QACzB,IAAI;QACJ,KAAK;QACL,eAAe,EAAE,gBAAgB;QACjC,QAAQ,EAAE,aAAa,OAAO,EAAE;KACjC,CAAC,CAAC;IACH,OAAO;gBACO,GAAG;2BACQ,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MA0EnD,CAAC;AACP,CAAC"}
1
+ {"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../src/bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAmB,MAAM,iBAAiB,CAAC;AACpE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC;sFACsF;AACtF,MAAM,cAAc,GAAgF;IAClG,YAAY;IACZ,aAAa;IACb,eAAe;IACf,qBAAqB;IACrB,wBAAwB;IACxB,cAAc;IACd,iBAAiB;IACjB,iBAAiB;IACjB,gBAAgB;CACjB,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,UAAU,qBAAqB,CAAC,IAAY,EAAE,KAAa;IAC/D,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC;QACzB,IAAI;QACJ,KAAK;QACL,eAAe,EAAE,gBAAgB;QACjC,QAAQ,EAAE,aAAa,OAAO,EAAE;KACjC,CAAC,CAAC;IACH,OAAO;gBACO,GAAG;2BACQ,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAoFnD,CAAC;AACP,CAAC"}
package/dist/bridge.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { ApiContract, ExportLayout } from "./layout.js";
1
2
  import type { ExportedData } from "./types/projectionlab.js";
2
3
  export interface ConnectionStatus {
3
4
  browser: boolean;
@@ -6,8 +7,20 @@ export interface ConnectionStatus {
6
7
  apiKeyValid: boolean;
7
8
  /** Connected executor's identity, "extension/<version>" or "bootstrap/<version>". */
8
9
  executor?: string;
10
+ /** Plugin API contract the page offers (src/layout.ts), once the API is available. */
11
+ apiContract?: ApiContract;
9
12
  errors: string[];
13
+ /** Whether the connected executor allows edits (see EditAccess). */
14
+ writesEnabled: boolean;
10
15
  }
16
+ /**
17
+ * Whether the connected executor allows writes: "enabled" while the
18
+ * extension's Enable agent plan edits switch is on, "disabled" while it is
19
+ * off, "unsupported" for an executor that has no switch (the console
20
+ * bootstrap snippet, extension releases without it). Only "enabled" allows a
21
+ * write; the extension also refuses writes in the browser while it is off.
22
+ */
23
+ export type EditAccess = "enabled" | "disabled" | "unsupported";
11
24
  /**
12
25
  * Surface for reaching window.projectionlabPluginAPI in a live ProjectionLab
13
26
  * page. Implemented by ExtensionBridge, which relays over a localhost
@@ -17,21 +30,31 @@ export interface ConnectionStatus {
17
30
  export interface Bridge {
18
31
  checkConnection(): Promise<ConnectionStatus>;
19
32
  describePluginApi(): Promise<Record<string, string>>;
33
+ /** The Plugin API contract the connected page offers, read fresh. */
34
+ apiContract(): Promise<ApiContract>;
35
+ /**
36
+ * The contract from the most recent successful contract read, without
37
+ * contacting the page; undefined before the first one. For choosing
38
+ * documentation only: writes read the contract fresh.
39
+ */
40
+ knownApiContract(): ApiContract | undefined;
41
+ /** The connected executor's edit access; connects to it first if needed. */
42
+ editAccess(): Promise<EditAccess>;
20
43
  /** Full export, served from a short-lived cache unless `fresh` is true. */
21
44
  exportData(opts?: {
22
45
  fresh?: boolean;
23
46
  }): Promise<ExportedData>;
24
- updateAccount(accountId: string, data: Record<string, unknown>, force?: boolean): Promise<void>;
25
- restoreCurrentFinances(state: unknown): Promise<void>;
26
- restorePlans(plans: unknown[]): Promise<void>;
47
+ updateAccount(accountId: string, data: Record<string, unknown>, force: boolean | undefined, layout: ExportLayout): Promise<void>;
48
+ restoreCurrentFinances(state: unknown, layout: ExportLayout): Promise<void>;
49
+ restorePlans(plans: unknown[], layout: ExportLayout): Promise<void>;
27
50
  /**
28
51
  * Writes `plans` unless a plan was added, removed, or saved since `read`
29
52
  * was taken, in which case it throws PLAN_CONFLICT and writes nothing. The
30
53
  * re-read and the write are atomic: no other operation runs between them.
31
54
  */
32
- restorePlansIfUnchanged(read: unknown[], plans: unknown[]): Promise<void>;
33
- restoreProgress(progress: unknown): Promise<void>;
34
- restoreSettings(settings: unknown): Promise<void>;
55
+ restorePlansIfUnchanged(read: unknown[], plans: unknown[], layout: ExportLayout): Promise<void>;
56
+ restoreProgress(progress: unknown, layout: ExportLayout): Promise<void>;
57
+ restoreSettings(settings: unknown, layout: ExportLayout): Promise<void>;
35
58
  invalidateCache(): void;
36
59
  close(): Promise<void>;
37
60
  }
package/dist/config.d.ts CHANGED
@@ -10,7 +10,6 @@ export declare const config: {
10
10
  readonly apiReadyTimeoutMs: number;
11
11
  readonly exportCacheMs: number;
12
12
  readonly prettyJson: boolean;
13
- readonly readOnly: boolean;
14
13
  readonly updateCheck: boolean;
15
14
  readonly snapshotDir: string;
16
15
  readonly logLevel: "error" | "warn" | "info" | "debug";
package/dist/config.js CHANGED
@@ -84,8 +84,6 @@ export const config = {
84
84
  exportCacheMs: optionalInt("PL_EXPORT_CACHE_MS", 90000),
85
85
  // Pretty-print JSON tool output (costs ~25-40% more tokens; off by default).
86
86
  prettyJson: optionalBoolean("PL_PRETTY_JSON") ?? false,
87
- // Writes stay disabled unless PL_READ_ONLY is exactly "false".
88
- readOnly: (process.env.PL_READ_ONLY ?? "").trim().toLowerCase() !== "false",
89
87
  // On unless PL_UPDATE_CHECK is exactly "false"; the only registry request
90
88
  // the server makes is the one this gates.
91
89
  updateCheck: (process.env.PL_UPDATE_CHECK ?? "").trim().toLowerCase() !== "false",
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAE1D,oEAAoE;AACpE,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,EAAE,EAAE,oBAAoB,EAAE,MAAM,CAAC,CAAC;AAE3E,yEAAyE;AACzE,oEAAoE;AACpE,yEAAyE;AACzE,UAAU,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC,CAAC;AACpC,UAAU,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,SAAS,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC;AAEpD,SAAS,QAAQ,CAAC,IAAY,EAAE,QAAgB;IAC9C,OAAO,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,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AC,GAAG,CAAC,UAAU,IAAI,SAAS;IAC3C,4EAA4E;IAC5E,0EAA0E;IAC1E,+DAA+D;IAC/D,yEAAyE;IACzE,4CAA4C;IAC5C,MAAM,EAAE,WAAW,CAAC,YAAY,EAAE,IAAI,CAAC;IACvC,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,IAAI,EAAE,IAAI,SAAS;IACrD,MAAM,EAAE,MAAM,EAAE;IAChB,iBAAiB,EAAE,WAAW,CAAC,yBAAyB,EAAE,KAAK,CAAC;IAChE,6EAA6E;IAC7E,4DAA4D;IAC5D,aAAa,EAAE,WAAW,CAAC,oBAAoB,EAAE,KAAK,CAAC;IACvD,6EAA6E;IAC7E,UAAU,EAAE,eAAe,CAAC,gBAAgB,CAAC,IAAI,KAAK;IACtD,0EAA0E;IAC1E,0CAA0C;IAC1C,WAAW,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,KAAK,OAAO;IACjF,WAAW,EAAE,UAAU,CAAC,QAAQ,CAAC,iBAAiB,EAAE,gCAAgC,CAAC,CAAC;IACtF,QAAQ,EAAE,QAAQ,EAAE;CACZ,CAAC"}
@@ -9,6 +9,66 @@ export interface CurrentFinanceEntry {
9
9
  export declare function listCurrentFinanceEntries(today: unknown): CurrentFinanceEntry[];
10
10
  export declare function findCurrentFinanceEntry(today: unknown, accountId: string): CurrentFinanceEntry | undefined;
11
11
  export declare function requireCurrentFinances(today: unknown): PlanObj;
12
+ /**
13
+ * A ProjectionLab 5 Current Finances account (`documents.currentFinances
14
+ * .accounts.<id>`). The `kind` field narrows the record: "account" carries
15
+ * `balance` and `costBasis`, "debt" carries `balance` and optionally
16
+ * `securedByAssetId`, "real-asset" carries `value` and `purchasePrice`.
17
+ * `archivedOn` is present only on archived accounts.
18
+ */
19
+ export interface V5AccountEntry {
20
+ /** The record's key in `accounts`. */
21
+ key: string;
22
+ /** The record's own `id`, falling back to its key. */
23
+ id: string;
24
+ name: string;
25
+ kind: string | undefined;
26
+ /** The v5 `type` string, as stored. */
27
+ type: string | undefined;
28
+ archived: boolean;
29
+ account: PlanObj;
30
+ }
31
+ /**
32
+ * Every account record of a v5 Current Finances document, archived ones
33
+ * included, in stored order. Empty for a v4 `today`, which keeps its accounts
34
+ * in per-type arrays and has no `accounts` object.
35
+ */
36
+ export declare function listV5Accounts(finances: unknown): V5AccountEntry[];
37
+ /** The v5 account with this exact id (or, failing that, key), archived or not. */
38
+ export declare function findV5Account(finances: unknown, accountId: string): V5AccountEntry | undefined;
39
+ /** A stored number, or 0 for an absent or non-numeric field. */
40
+ export declare function finiteNumber(value: unknown): number;
41
+ /**
42
+ * The size of a v5 account: `value` for a real asset, `balance` for an account
43
+ * and the magnitude of `balance` for a debt. Undefined for a kind this server
44
+ * does not recognize, so its money is reported instead of being silently
45
+ * dropped from totals.
46
+ */
47
+ export declare function v5AccountAmount(entry: V5AccountEntry): number | undefined;
48
+ /**
49
+ * What a v5 account adds to net worth: its balance for an account, its value
50
+ * for a real asset, minus its balance for a debt. Undefined for an
51
+ * unrecognized kind.
52
+ */
53
+ export declare function v5NetWorthContribution(entry: V5AccountEntry): number | undefined;
54
+ /** The stub that stands in for an archived account in a default listing. */
55
+ export declare function v5ArchivedStub(entry: V5AccountEntry): PlanObj;
56
+ /**
57
+ * Copy of a v5 Current Finances document without its archived accounts, which
58
+ * are listed under `archivedAccounts` instead. Records are only dropped,
59
+ * never mutated, so the cached export stays intact.
60
+ */
61
+ export declare function withoutArchivedAccounts(finances: PlanObj): PlanObj;
62
+ /**
63
+ * The stored ProjectionLab 5 accounts that restoring `submitted` keeps
64
+ * unchanged because the submission leaves them out. ProjectionLab 5's
65
+ * restoreCurrentFinances replaces each submitted account and never deletes
66
+ * one, so these survive the restore as they are. Empty for a v4 `today`.
67
+ */
68
+ export declare function v5AccountsKept(submitted: unknown, stored: unknown): {
69
+ id: string;
70
+ name: string;
71
+ }[];
12
72
  export declare function currentFinanceAccountNotFoundError(today: unknown, accountId: string): ProjectionLabError;
13
73
  /**
14
74
  * Problems for a Current Finances read taken before a write and one taken after
@@ -37,13 +37,125 @@ export function requireCurrentFinances(today) {
37
37
  }
38
38
  return today;
39
39
  }
40
+ const isPlainObject = (value) => Boolean(value) && typeof value === "object" && !Array.isArray(value);
41
+ const nonEmptyString = (value) => typeof value === "string" && value !== "" ? value : undefined;
42
+ /**
43
+ * Every account record of a v5 Current Finances document, archived ones
44
+ * included, in stored order. Empty for a v4 `today`, which keeps its accounts
45
+ * in per-type arrays and has no `accounts` object.
46
+ */
47
+ export function listV5Accounts(finances) {
48
+ const accounts = isPlainObject(finances) ? finances.accounts : undefined;
49
+ if (!isPlainObject(accounts))
50
+ return [];
51
+ const entries = [];
52
+ for (const [key, value] of Object.entries(accounts)) {
53
+ if (!isPlainObject(value))
54
+ continue;
55
+ entries.push({
56
+ key,
57
+ id: nonEmptyString(value.id) ?? key,
58
+ name: nonEmptyString(value.name) ?? "unknown",
59
+ kind: nonEmptyString(value.kind),
60
+ type: nonEmptyString(value.type),
61
+ archived: value.archivedOn !== undefined && value.archivedOn !== null,
62
+ account: value,
63
+ });
64
+ }
65
+ return entries;
66
+ }
67
+ /** The v5 account with this exact id (or, failing that, key), archived or not. */
68
+ export function findV5Account(finances, accountId) {
69
+ const entries = listV5Accounts(finances);
70
+ return (entries.find((entry) => entry.id === accountId) ??
71
+ entries.find((entry) => entry.key === accountId));
72
+ }
73
+ /** A stored number, or 0 for an absent or non-numeric field. */
74
+ export function finiteNumber(value) {
75
+ const n = typeof value === "number" ? value : Number(value ?? 0);
76
+ return Number.isFinite(n) ? n : 0;
77
+ }
78
+ /**
79
+ * The size of a v5 account: `value` for a real asset, `balance` for an account
80
+ * and the magnitude of `balance` for a debt. Undefined for a kind this server
81
+ * does not recognize, so its money is reported instead of being silently
82
+ * dropped from totals.
83
+ */
84
+ export function v5AccountAmount(entry) {
85
+ switch (entry.kind) {
86
+ case "account":
87
+ return finiteNumber(entry.account.balance);
88
+ case "debt":
89
+ return Math.abs(finiteNumber(entry.account.balance));
90
+ case "real-asset":
91
+ return finiteNumber(entry.account.value);
92
+ default:
93
+ return undefined;
94
+ }
95
+ }
96
+ /**
97
+ * What a v5 account adds to net worth: its balance for an account, its value
98
+ * for a real asset, minus its balance for a debt. Undefined for an
99
+ * unrecognized kind.
100
+ */
101
+ export function v5NetWorthContribution(entry) {
102
+ const amount = v5AccountAmount(entry);
103
+ if (amount === undefined)
104
+ return undefined;
105
+ return entry.kind === "debt" ? -amount : amount;
106
+ }
107
+ /** The stub that stands in for an archived account in a default listing. */
108
+ export function v5ArchivedStub(entry) {
109
+ return {
110
+ id: entry.id,
111
+ name: entry.name,
112
+ ...(entry.kind !== undefined ? { kind: entry.kind } : {}),
113
+ ...(entry.type !== undefined ? { type: entry.type } : {}),
114
+ archivedOn: entry.account.archivedOn,
115
+ };
116
+ }
117
+ /**
118
+ * Copy of a v5 Current Finances document without its archived accounts, which
119
+ * are listed under `archivedAccounts` instead. Records are only dropped,
120
+ * never mutated, so the cached export stays intact.
121
+ */
122
+ export function withoutArchivedAccounts(finances) {
123
+ const entries = listV5Accounts(finances);
124
+ const archivedKeys = new Set(entries.filter((entry) => entry.archived).map((entry) => entry.key));
125
+ const stored = isPlainObject(finances.accounts) ? finances.accounts : {};
126
+ const accounts = Object.fromEntries(Object.entries(stored).filter(([key]) => !archivedKeys.has(key)));
127
+ return {
128
+ ...finances,
129
+ accounts,
130
+ archivedAccounts: entries
131
+ .filter((entry) => entry.archived)
132
+ .map(v5ArchivedStub),
133
+ };
134
+ }
135
+ /**
136
+ * The stored ProjectionLab 5 accounts that restoring `submitted` keeps
137
+ * unchanged because the submission leaves them out. ProjectionLab 5's
138
+ * restoreCurrentFinances replaces each submitted account and never deletes
139
+ * one, so these survive the restore as they are. Empty for a v4 `today`.
140
+ */
141
+ export function v5AccountsKept(submitted, stored) {
142
+ const accounts = isPlainObject(submitted) && isPlainObject(submitted.accounts)
143
+ ? submitted.accounts
144
+ : {};
145
+ return listV5Accounts(stored)
146
+ .filter((entry) => !Object.prototype.hasOwnProperty.call(accounts, entry.key))
147
+ .map(({ id, name }) => ({ id, name }));
148
+ }
40
149
  export function currentFinanceAccountNotFoundError(today, accountId) {
41
- const count = listCurrentFinanceEntries(today).length;
150
+ const count = listCurrentFinanceEntries(today).length + listV5Accounts(today).length;
42
151
  return new ProjectionLabError("INVALID_INPUT", `No Current Finances account with ID "${accountId}" found`, `Call projectionlab_get_current_finances to inspect the ${count} available account record(s)`);
43
152
  }
44
153
  /** The money fields of a Current Finances account. */
45
154
  const BALANCE_FIELDS = ["balance", "amount", "value", "costBasis"];
46
- /** The id-bearing accounts of one read, keyed by collection and id. */
155
+ /**
156
+ * The id-bearing accounts of one read, keyed by collection and id. A v5
157
+ * account is keyed under the `accounts` collection, archived ones included.
158
+ */
47
159
  function accountsById(today) {
48
160
  const accounts = new Map();
49
161
  for (const entry of listCurrentFinanceEntries(today)) {
@@ -51,6 +163,9 @@ function accountsById(today) {
51
163
  if (id)
52
164
  accounts.set(`${entry.collection} ${id}`, entry.account);
53
165
  }
166
+ for (const entry of listV5Accounts(today)) {
167
+ accounts.set(`accounts ${entry.id}`, entry.account);
168
+ }
54
169
  return accounts;
55
170
  }
56
171
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"currentFinances.js","sourceRoot":"","sources":["../src/currentFinances.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,cAAc,EAAgB,MAAM,YAAY,CAAC;AAE1D,MAAM,CAAC,MAAM,2BAA2B,GAAG;IACzC,oBAAoB;IACpB,iBAAiB;IACjB,OAAO;IACP,QAAQ;CACA,CAAC;AAQX,MAAM,UAAU,yBAAyB,CACvC,KAAc;IAEd,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QA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