@levitating/tensor-mcp 6.0.0 → 6.2.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.
- package/README.md +70 -18
- package/dist/index.js +89 -40
- package/package.json +1 -1
- package/skills/tensor/SKILL.md +9 -5
package/README.md
CHANGED
|
@@ -84,13 +84,15 @@ Set two environment variables:
|
|
|
84
84
|
| `TENSOR_BASE_URL` | Tensor instance URL, e.g. `https://tensor.levitating.org` (default: `http://localhost:5000`) |
|
|
85
85
|
| `TENSOR_MCP_READ_ONLY` | Optional. `1` lists only the tools that read (since 6.0.0) |
|
|
86
86
|
| `TENSOR_MCP_TOOLSETS` | Optional. A comma-separated subset of `ledger`, `work`, `files`, `web`: only those halves of Tensor are listed, plus the four tools that need no scope (since 6.0.0). Unknown names are ignored |
|
|
87
|
+
| `TENSOR_AGENT_NAME` | Optional. The name this agent goes by, when several agents share one key. Tensor records it beside the key on every write and prints it as a claim ("calls itself …"), never in place of the key's own name. Better still, give each agent its own key: a key's name must be unique among your live keys |
|
|
87
88
|
|
|
88
|
-
The
|
|
89
|
-
security boundary (the key's scopes are). The hosted endpoint
|
|
90
|
-
two as request headers, `X-Tensor-Read-Only: 1` and
|
|
91
|
-
`X-Tensor-Toolsets: ledger,work`,
|
|
92
|
-
|
|
93
|
-
the exact MCP URL it was issued
|
|
89
|
+
The two `TENSOR_MCP_*` variables narrow the list to save the agent's context;
|
|
90
|
+
they are not a security boundary (the key's scopes are). The hosted endpoint
|
|
91
|
+
takes the same two as request headers, `X-Tensor-Read-Only: 1` and
|
|
92
|
+
`X-Tensor-Toolsets: ledger,work`, and the agent's name as `X-Tensor-Agent`,
|
|
93
|
+
for a client that lets you set headers. They are headers rather than query
|
|
94
|
+
parameters because an OAuth token is bound to the exact MCP URL it was issued
|
|
95
|
+
for.
|
|
94
96
|
|
|
95
97
|
## Running standalone
|
|
96
98
|
|
|
@@ -185,11 +187,12 @@ immediate and unrecoverable.
|
|
|
185
187
|
The work surfaces are deliberately softer. `delete_file`, `delete_idea`,
|
|
186
188
|
`delete_todo`, `delete_bookmark` and `delete_tab_group` move a row to a
|
|
187
189
|
restorable Trash, every permanent purge is UI-only, and every Trash empties
|
|
188
|
-
itself 60 days after deletion on one shared window and one sweeper.
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
190
|
+
itself 60 days after deletion on one shared window and one sweeper. Not soft
|
|
191
|
+
on those surfaces: `delete_todo_tag` and `delete_tab` (one tab out of a live
|
|
192
|
+
group; the group is the recoverable unit, so a tab has no soft state of its
|
|
193
|
+
own) are permanent and take two calls, and `delete_todo_state` and
|
|
194
|
+
`delete_file_folder` are one call that refuses while anything uses the record.
|
|
195
|
+
Once through, there is no undo for any of the four.
|
|
193
196
|
|
|
194
197
|
### What a client can tell before it calls
|
|
195
198
|
|
|
@@ -245,8 +248,9 @@ connection's scopes.
|
|
|
245
248
|
**A permanent delete takes two calls** (since 5.8.0). `delete_position`,
|
|
246
249
|
`delete_entity`, `delete_account`, `delete_asset`, `delete_institution`,
|
|
247
250
|
`delete_entity_type`, `delete_role_type`, `delete_account_type`,
|
|
248
|
-
`delete_asset_class`, `delete_bookmark_folder`, `delete_todo_tag
|
|
249
|
-
`delete_entity_group` (since 5.10.0)
|
|
251
|
+
`delete_asset_class`, `delete_bookmark_folder`, `delete_todo_tag`,
|
|
252
|
+
`delete_entity_group` (since 5.10.0) and `delete_entity_relationship`,
|
|
253
|
+
`delete_position_relation` and `delete_tab` (since 6.2.0) destroy
|
|
250
254
|
rows no Trash brings back. The first call deletes nothing: it answers
|
|
251
255
|
`NOT DELETED.` with a preview of what would go (the record, the rows deleted
|
|
252
256
|
with it, the rows unhooked from it) and a one-time `confirmToken`. Show the
|
|
@@ -254,7 +258,10 @@ person the preview; only after they agree, call the same tool again with the
|
|
|
254
258
|
same `id` and that `confirmToken` (good for ten minutes, once). A record other
|
|
255
259
|
records still use is refused outright with what is using it. The soft deletes
|
|
256
260
|
(`delete_todo`, `delete_idea`, `delete_file`, `delete_bookmark`,
|
|
257
|
-
`delete_tab_group`, …) are one call, because Trash can undo them.
|
|
261
|
+
`delete_tab_group`, …) are one call, because Trash can undo them. So are
|
|
262
|
+
`delete_file_folder` and `delete_todo_state` (refused unless nothing uses the
|
|
263
|
+
record) and the `detach_*` tools (one edge between two records that both
|
|
264
|
+
stay).
|
|
258
265
|
|
|
259
266
|
**A list answers a page** (since 6.0.0). The paged `list_*` tools and
|
|
260
267
|
`browse_files` return `{ items, hasMore, nextOffset }`: 100 rows unless you pass
|
|
@@ -309,7 +316,7 @@ Changing any of these stays in Tensor's web app.
|
|
|
309
316
|
| `list_entity_relationships` | List entity relationships |
|
|
310
317
|
| `create_entity_relationship` | Link two entities |
|
|
311
318
|
| `update_entity_relationship` | Update a relationship |
|
|
312
|
-
| `delete_entity_relationship` | Remove a relationship |
|
|
319
|
+
| `delete_entity_relationship` | Remove a relationship; both entities stay. Permanent, two calls |
|
|
313
320
|
| `list_entity_groups` | Named sets of entities, with their member ids |
|
|
314
321
|
| `create_entity_group` | Create a group |
|
|
315
322
|
| `update_entity_group` | Rename it, or replace its members (`entityIds` is the whole list) |
|
|
@@ -335,7 +342,7 @@ Changing any of these stays in Tensor's web app.
|
|
|
335
342
|
| `sell_all_position` | Close/sell a position, keeping its history |
|
|
336
343
|
| `list_position_relations` | List position relations |
|
|
337
344
|
| `create_position_relation` | Link positions |
|
|
338
|
-
| `delete_position_relation` | Remove a relation |
|
|
345
|
+
| `delete_position_relation` | Remove a relation; both positions stay. Permanent, two calls |
|
|
339
346
|
| `list_position_events` | Valuation-event history for one position |
|
|
340
347
|
| `list_events` | Valuation-event history across all positions |
|
|
341
348
|
| `list_transactions` | List all transactions |
|
|
@@ -407,7 +414,7 @@ Bodies and comments are TipTap JSON, never HTML — the write tools take plain t
|
|
|
407
414
|
| `list_todos` | `tensor:todos:read` | List todos with server-side filters (state, category, assignee, priority, tag, parent, linked record, search, `trash`) and sort. `assigneeId` and `tagId` take one id or several |
|
|
408
415
|
| `get_todo` | `tensor:todos:read` | One todo: body, state, canonical tags, links, sub-task counts. Links to records your key cannot read are omitted |
|
|
409
416
|
| `get_todo_subtree` | `tensor:todos:read` | The branch under a todo — counts and depth, for naming what a delete or a re-parent takes with it |
|
|
410
|
-
| `get_todo_activity` | `tensor:todos:read` | Activity feed, folded from the mutation audit log — a rolling
|
|
417
|
+
| `get_todo_activity` | `tensor:todos:read` | Activity feed, folded from the mutation audit log — a rolling one-year window (past 90 days an entry says what changed, not to what), not permanent history |
|
|
411
418
|
| `create_todo` | `tensor:todos:write` + each `links` target's read scope | Create a todo (plain-text `body`, wrapped to TipTap JSON; `stateId` from `list_todo_states`). The optional `links` array takes the same target types as `attach_todo_link` — the six ledger records plus todo, idea and memo, never `file` — and a target your key cannot read fails the create with a `403` rather than being dropped |
|
|
412
419
|
| `update_todo` | `tensor:todos:write` | Partial update; optional stale-write guard via `expectedUpdatedAt` |
|
|
413
420
|
| `delete_todo` | `tensor:todos:write` | Move the todo **and its whole branch** to Trash, atomically. Soft; `restore_todo` undoes it, and Trash self-empties after 60 days |
|
|
@@ -447,6 +454,7 @@ The capture inbox. An idea's body is a TipTap document since 4.2.0 — plain tex
|
|
|
447
454
|
| `restore_idea` | `tensor:ideas:write` | Restore from Trash, on the side of the archive it was deleted from |
|
|
448
455
|
| `archive_idea` | `tensor:ideas:write` | Archive: off the active stream, kept for good (5.6.0). Idempotent; an idea in Trash is a `409` |
|
|
449
456
|
| `unarchive_idea` | `tensor:ideas:write` | Back into the active stream (5.6.0). Idempotent; an idea in Trash is a `409` |
|
|
457
|
+
| `get_idea_activity` | `tensor:ideas:read` | Activity feed, folded from the mutation audit log — who changed the idea, through which client and why; a rolling one-year window (past 90 days an entry says what changed, not to what), not permanent history |
|
|
450
458
|
| `list_idea_comments` | `tensor:ideas:read` | The comment thread |
|
|
451
459
|
| `create_idea_comment` | `tensor:ideas:write` | Comment (plain text, stored as TipTap JSON) |
|
|
452
460
|
| `update_idea_comment` | `tensor:ideas:write` | Edit your own comment — comments are never deletable here |
|
|
@@ -489,7 +497,7 @@ Tabs parked from the browser extension, kept together and in order. Scoped SEPAR
|
|
|
489
497
|
| `create_tab_group` | `tensor:tabs:write` | Park 1–500 tabs as one group. One call carries the whole group — the rate limit makes per-tab posting unworkable |
|
|
490
498
|
| `update_tab_group` | `tensor:tabs:write` | `name`, `locked`, `starred`; tabs arrive through `add_tabs_to_group` |
|
|
491
499
|
| `add_tabs_to_group` | `tensor:tabs:write` | Append 1–500 tabs to an existing group in one call. A trashed group is a `404` until restored |
|
|
492
|
-
| `delete_tab` | `tensor:tabs:write` | Remove one tab from a live group.
|
|
500
|
+
| `delete_tab` | `tensor:tabs:write` | Remove one tab from a live group. Permanent, two calls; the group is the recoverable unit |
|
|
493
501
|
| `delete_tab_group` | `tensor:tabs:write` | Move the whole group to Trash. Soft — restorable; the purge is UI-only |
|
|
494
502
|
| `restore_tab_group` | `tensor:tabs:write` | Restore the group, tabs and all |
|
|
495
503
|
|
|
@@ -526,6 +534,50 @@ The Tensor user who issued the key is the ceiling: a key can never do more than
|
|
|
526
534
|
|
|
527
535
|
Newest first. A tool rename or removal is a MAJOR bump; new tools and new optional inputs are MINOR (`docs/contract/MCP.md` §6).
|
|
528
536
|
|
|
537
|
+
### 6.2.0 — Three more permanent deletes ask the person first
|
|
538
|
+
No tool is renamed or removed and no scope changes. Three tools gain an
|
|
539
|
+
optional input.
|
|
540
|
+
|
|
541
|
+
- **`confirmToken` on `delete_entity_relationship`, `delete_position_relation`
|
|
542
|
+
and `delete_tab`.** Each destroys a row no Trash brings back, and each was a
|
|
543
|
+
single call because no list had it. Tensor now holds them for a key or a
|
|
544
|
+
third-party connection like the other permanent deletes (DEVELOPER_API.md
|
|
545
|
+
§5.5): the first call returns `NOT DELETED.`, a preview naming the record
|
|
546
|
+
(the two entities and the role, the two positions, the tab's title) and a
|
|
547
|
+
`confirmToken`; the second call, with that token, deletes.
|
|
548
|
+
- **What changes for an existing caller:** an older stdio package cannot pass a
|
|
549
|
+
`confirmToken`, so against a Tensor that holds these three deletes it cannot
|
|
550
|
+
complete one: update to 6.2.0. The hosted endpoint is always current.
|
|
551
|
+
- **A link is an http or https address.** `create_bookmark`,
|
|
552
|
+
`update_bookmark`, `create_idea`, `update_idea`, `create_tab_group` and
|
|
553
|
+
`add_tabs_to_group` are refused with 400 for any other scheme
|
|
554
|
+
(`javascript:`, `data:`, `file:`), which Tensor used to store. No input
|
|
555
|
+
changes.
|
|
556
|
+
|
|
557
|
+
### 6.1.0 — Saying why, and working beside other agents
|
|
558
|
+
New optional inputs only; no tool is renamed or removed and no scope changes.
|
|
559
|
+
|
|
560
|
+
- **Every write tool takes `reason`**: one sentence, at most 200 characters,
|
|
561
|
+
sent as `X-Tensor-Reason`. Tensor keeps it with the write for a year and
|
|
562
|
+
shows it, quoted, beside the change in Activity and the change log.
|
|
563
|
+
- **The agent's own name**: `TENSOR_AGENT_NAME` (stdio) or the
|
|
564
|
+
`X-Tensor-Agent` header (hosted) is sent on every call, for agents sharing
|
|
565
|
+
one key. Tensor prints it as a claim beside the key's name.
|
|
566
|
+
- **Stale writes refused**: `update_entity`, `update_account`, `update_asset`,
|
|
567
|
+
`update_institution`, `update_position` and `update_idea` take
|
|
568
|
+
`expectedUpdatedAt`, as `update_todo` did. A record that changed meanwhile
|
|
569
|
+
answers 409 `stale_write` with the current record and who changed it, and
|
|
570
|
+
the tool says what to do about it.
|
|
571
|
+
- **`list_changes` says who**: each change carries `via` (kind, name, door,
|
|
572
|
+
tool, the name the agent called itself, and the credential's `ref`) and
|
|
573
|
+
`reason`. New filters: `excludeSelf`, `via` (`agent`, `web`, `app`, `key`,
|
|
574
|
+
`oauth`, `system`) and `actor` (one credential's `ref`).
|
|
575
|
+
- A write's answer now names the client that made it in `changedVia`
|
|
576
|
+
(and `createdVia` on a create), instead of the one before.
|
|
577
|
+
- **One new read tool, `get_idea_activity`** (`tensor:ideas:read`): an idea's feed, the
|
|
578
|
+
twin of `get_todo_activity` — the latest 50 entries of who changed it,
|
|
579
|
+
through which client, and why.
|
|
580
|
+
|
|
529
581
|
### 6.0.0 — Shorter tool list, pages, and one call per question
|
|
530
582
|
**Breaking:** the paged list tools answer `{ items, hasMore, nextOffset }`
|
|
531
583
|
instead of a bare array, and ask for 100 rows by default (the REST default is
|
package/dist/index.js
CHANGED
|
@@ -25,6 +25,7 @@ How to work well here:
|
|
|
25
25
|
6. Lists answer {items, hasMore, nextOffset}: 100 rows unless you pass limit (at most 1000); pass nextOffset as offset for the next page. Filter on the server (filters combine with AND; a value Tensor cannot parse is ignored, which widens the answer) and catch up with list_changes(since) instead of re-reading everything. Times are epoch milliseconds.
|
|
26
26
|
7. A body you send (todos, ideas, comments) is plain text, one paragraph per line; Tensor stores a document and returns the text as body or bodyText. Sending body replaces the whole body. You can edit only your own comments, and none can be deleted.
|
|
27
27
|
8. A download or media URL is a bearer link to a private file and stays in this conversation: mint one only right before fetching, and never repost it. Each one is logged.
|
|
28
|
+
9. Other agents and people work here too, and every write records which client made it. Give a write a short reason when it is not obvious; the user sees it beside the change. Edit with the updatedAt you read as expectedUpdatedAt, so a change someone made meanwhile is refused (409 with the current record) instead of overwritten. list_changes(excludeSelf: true) shows what others did since you last looked.
|
|
28
29
|
|
|
29
30
|
Before an unfamiliar job, call get_guide with a topic: ledger, imports, work, files or safety.`;
|
|
30
31
|
var GUIDE_TOPICS = {
|
|
@@ -111,7 +112,7 @@ An idea that has been handled but is worth keeping is archived with archive_idea
|
|
|
111
112
|
Leaving folderId off files a bookmark as Unfiled, which is a normal resting place; do not invent a folder for it. Keep the order list_bookmarks and list_bookmark_folders return; the owner arranged it by hand. move_bookmark and move_bookmark_folder change a folder and a place in that order in one call. delete_bookmark is soft, delete_bookmark_folder is not (the bookmarks inside survive, the folder does not).
|
|
112
113
|
|
|
113
114
|
## Tab groups
|
|
114
|
-
Tab groups are personal: a connection sees only its own person's groups. Park a whole set of tabs in one create_tab_group call, and add more to the end with add_tabs_to_group. Only name, locked and starred are editable. delete_tab removes one tab for good; delete_tab_group is soft.
|
|
115
|
+
Tab groups are personal: a connection sees only its own person's groups. Park a whole set of tabs in one create_tab_group call, and add more to the end with add_tabs_to_group. Only name, locked and starred are editable. delete_tab removes one tab for good and takes two calls, a preview and then the confirmToken; delete_tab_group is soft.
|
|
115
116
|
|
|
116
117
|
## Links between records
|
|
117
118
|
attach_todo_link, attach_idea_link and attach_file_link join a record to any ledger record or to another work record; each list_ call returns linkIds for the matching detach_. A link to a record type your connection cannot read is refused when you write it and left out when you read, so an empty list means "none you can see". Links of kind "mention" come from @mentions in prose; remove the mention from the text rather than detaching the link.
|
|
@@ -120,7 +121,7 @@ attach_todo_link, attach_idea_link and attach_file_link join a record to any led
|
|
|
120
121
|
search_records is one ranked search over every type you can read. It resolves reference ids directly (TSK-12, IDEA-7, AS021). Types your scopes do not cover are left out silently. For market tickers use search_market_quotes instead.
|
|
121
122
|
|
|
122
123
|
## Keeping up to date
|
|
123
|
-
list_changes(since) returns creates, updates and deletes across everything your scopes can read, kept for
|
|
124
|
+
list_changes(since) returns creates, updates and deletes across everything your scopes can read, kept for a year, each with the client that made it (via) and the reason it gave. Resume from the until it returns. When coverage.complete is false, do a full read instead. excludeSelf: true leaves out your own writes; via: ["agent"] or actor (a change's via.ref) narrows it to other agents or to one.`
|
|
124
125
|
},
|
|
125
126
|
files: {
|
|
126
127
|
title: "Files: finding, uploading, attaching and downloading",
|
|
@@ -153,15 +154,18 @@ delete_file moves a file to Trash; restore_file brings it back for 60 days. Fold
|
|
|
153
154
|
## Ask the user before
|
|
154
155
|
- any create_transaction or sell_all_position (the ledger cannot be edited afterwards);
|
|
155
156
|
- data_apply (show the dry-run preview first);
|
|
156
|
-
- every permanent delete: delete_position (takes its whole ledger), delete_entity, delete_account, delete_asset, delete_institution and the other catalog deletes, delete_entity_group, delete_bookmark_folder, delete_tab, delete_todo_tag, delete_todo_state;
|
|
157
|
+
- every permanent delete: delete_position (takes its whole ledger), delete_entity, delete_account, delete_asset, delete_institution and the other catalog deletes, delete_entity_group, delete_entity_relationship, delete_position_relation, delete_bookmark_folder, delete_tab, delete_todo_tag, delete_todo_state;
|
|
157
158
|
- sync_prices over the whole catalog;
|
|
158
159
|
- minting download links for more than the file the user asked about.
|
|
159
|
-
Tensor enforces
|
|
160
|
+
Tensor enforces those deletes itself (all but delete_todo_state, which it refuses while a todo is in the state): the call answers NOT DELETED with what would go and a confirmToken. Show the user that preview in plain words and pass the token back only after they say yes; never confirm on your own. A refused delete names what still uses the record: tell the user, do not work around it.
|
|
160
161
|
Soft deletes (todos, ideas, files, bookmarks, tab groups) are recoverable for 60 days with the restore_ tools (list_trash finds them), but still say what you are moving to Trash, including a todo's sub-tasks. Trash empties itself after those 60 days; for an idea the user wants to keep but no longer see, archive_idea is the right verb, because Archive never expires.
|
|
161
162
|
|
|
162
163
|
## Retrying
|
|
163
164
|
Every write a retry could duplicate takes an optional idempotencyKey. Use a fresh unique value per intended write and the SAME value when you retry that write after a timeout or a network error; Tensor then returns the first result instead of writing again. Never reuse a key for a different write.
|
|
164
165
|
|
|
166
|
+
## Working beside other agents
|
|
167
|
+
Every write records which client made it: the key or the connection, never a name you choose. If you share a key with other agents, the user can give you a name for it (TENSOR_AGENT_NAME for the stdio package, or the X-Tensor-Agent header); Tensor shows it as the name you call yourself, beside the key's own. Each write tool takes an optional reason (one sentence, at most 200 characters); the user reads it beside the change in Activity, so write it for them and keep it factual. Before editing a record someone else may touch, read it and pass its updatedAt as expectedUpdatedAt: a 409 stale_write means it changed meanwhile, and the answer carries the current record and who changed it. Merge onto that and retry, or ask the user when the two changes disagree. Never retry the same edit blindly without it.
|
|
168
|
+
|
|
165
169
|
## What this connection can do
|
|
166
170
|
Each connection carries scopes (portfolio, reference, files, todos, ideas, bookmarks, tabs, each read or write, plus the data pipeline). Only the tools its scopes reach are listed, and a 403 names a missing scope. Some things no connection can do, by design: read memos or browsing history; change FX rates, loan terms or fund terms (they are read-only); empty a Trash or permanently purge; create API keys or change its own access. When you cannot do something, tell the user which scope or which part of the Tensor app it needs.
|
|
167
171
|
|
|
@@ -170,7 +174,7 @@ Each connection carries scopes (portfolio, reference, files, todos, ideas, bookm
|
|
|
170
174
|
- 401: the credential is revoked, expired or wrong. The user must reconnect Tensor.
|
|
171
175
|
- 403: a missing scope (named in the message) or something no connection may do. Do not retry.
|
|
172
176
|
- 404: no such record for this connection. Check the id with search_records or a list_ call.
|
|
173
|
-
- 409: a conflict with the record's current state (a cycle, a state still in use,
|
|
177
|
+
- 409: a conflict with the record's current state (a cycle, a state still in use), stale_write (it changed since the updatedAt you sent: read current, merge, retry), an idempotencyKey problem, or delete_blocked (other records still use this one). The message says which.
|
|
174
178
|
- 428: not an error. A permanent delete is waiting for the user's yes; see "Ask the user before".
|
|
175
179
|
- 429: rate limited (an API key allows 120 requests a minute). Wait as told, then continue. Batch work instead of looping single calls.
|
|
176
180
|
- 5xx: Tensor failed. One retry is fine; then report it with the errorId.
|
|
@@ -378,7 +382,7 @@ var TOOL_SCOPE_LISTS = {
|
|
|
378
382
|
"tensor:files:write": "create_file_upload_url confirm_file_upload update_file delete_file restore_file attach_file_link detach_file_link create_file_folder update_file_folder delete_file_folder",
|
|
379
383
|
"tensor:todos:read": "list_todos get_todo get_todo_subtree get_todo_activity list_todo_comments list_todo_states list_todo_tags list_todo_files list_todo_links",
|
|
380
384
|
"tensor:todos:write": "create_todo update_todo delete_todo restore_todo set_todo_parent reorder_todo set_todo_tags create_todo_comment update_todo_comment create_todo_state update_todo_state delete_todo_state create_todo_tag update_todo_tag delete_todo_tag attach_todo_file detach_todo_file attach_todo_link detach_todo_link",
|
|
381
|
-
"tensor:ideas:read": "list_ideas get_idea list_idea_comments list_idea_tags list_idea_sites get_idea_media_url list_idea_links list_idea_kinds",
|
|
385
|
+
"tensor:ideas:read": "list_ideas get_idea get_idea_activity list_idea_comments list_idea_tags list_idea_sites get_idea_media_url list_idea_links list_idea_kinds",
|
|
382
386
|
"tensor:ideas:write": "create_idea update_idea delete_idea restore_idea archive_idea unarchive_idea create_idea_comment update_idea_comment create_idea_upload_url attach_idea_link detach_idea_link",
|
|
383
387
|
"tensor:bookmarks:read": "list_bookmarks get_bookmark list_bookmark_folders",
|
|
384
388
|
"tensor:bookmarks:write": "create_bookmark update_bookmark delete_bookmark restore_bookmark create_bookmark_folder update_bookmark_folder delete_bookmark_folder move_bookmark move_bookmark_folder",
|
|
@@ -435,6 +439,9 @@ function isIdempotentTool(name) {
|
|
|
435
439
|
const a = toolAnnotations(name);
|
|
436
440
|
return a.readOnlyHint || a.idempotentHint === true;
|
|
437
441
|
}
|
|
442
|
+
function toolTakesReason(name) {
|
|
443
|
+
return !toolAnnotations(name).readOnlyHint;
|
|
444
|
+
}
|
|
438
445
|
function toolTakesIdempotencyKey(name) {
|
|
439
446
|
return !isIdempotentTool(name) && !name.startsWith("data_") && !NO_KEY_TOOLS.has(name);
|
|
440
447
|
}
|
|
@@ -490,8 +497,11 @@ async function unlessMissing(call) {
|
|
|
490
497
|
}
|
|
491
498
|
}
|
|
492
499
|
var IDEMPOTENCY_KEY_INPUT = z2.string().min(1).max(200).optional().describe("Send the same value on a retry and it is written once.");
|
|
500
|
+
var REASON_INPUT = z2.string().max(200).optional().describe("Why, in one sentence. Shown beside the change in Tensor.");
|
|
501
|
+
var EXPECTED_UPDATED_AT_INPUT = z2.number().optional().describe("The updatedAt you read. If the record changed since, the edit is refused (409) with the current record.");
|
|
493
502
|
var CALL_CLIENT = new AsyncLocalStorage();
|
|
494
503
|
var CALL_KEY = new AsyncLocalStorage();
|
|
504
|
+
var CALL_REASON = new AsyncLocalStorage();
|
|
495
505
|
var DEFINITIONS = null;
|
|
496
506
|
function toolDefinitions() {
|
|
497
507
|
if (DEFINITIONS) return DEFINITIONS;
|
|
@@ -503,24 +513,39 @@ function toolDefinitions() {
|
|
|
503
513
|
throw new Error(`MCP tool ${name} has no entry in TOOL_SCOPE_LISTS (mcp-server/tools.ts).`);
|
|
504
514
|
}
|
|
505
515
|
const takesKey = toolTakesIdempotencyKey(name);
|
|
516
|
+
const annotations = toolAnnotations(name);
|
|
517
|
+
const takesReason = toolTakesReason(name);
|
|
518
|
+
const keyed = takesKey ? (args, extra) => {
|
|
519
|
+
const { idempotencyKey, ...rest } = args ?? {};
|
|
520
|
+
if (typeof idempotencyKey !== "string" || !idempotencyKey) return handler(rest, extra);
|
|
521
|
+
return CALL_KEY.run({ base: idempotencyKey, writes: 0 }, () => handler(rest, extra));
|
|
522
|
+
} : handler;
|
|
506
523
|
definitions.push({
|
|
507
524
|
name,
|
|
508
525
|
scope,
|
|
509
526
|
description,
|
|
510
|
-
shape:
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
527
|
+
shape: {
|
|
528
|
+
...shape,
|
|
529
|
+
...takesKey ? { idempotencyKey: IDEMPOTENCY_KEY_INPUT } : {},
|
|
530
|
+
...takesReason ? { reason: REASON_INPUT } : {}
|
|
531
|
+
},
|
|
532
|
+
annotations,
|
|
533
|
+
handler: takesReason ? (args, extra) => {
|
|
534
|
+
const { reason, ...rest } = args ?? {};
|
|
535
|
+
if (typeof reason !== "string" || !reason.trim()) return keyed(rest, extra);
|
|
536
|
+
return CALL_REASON.run(reason, () => keyed(rest, extra));
|
|
537
|
+
} : keyed
|
|
517
538
|
});
|
|
518
539
|
}
|
|
519
540
|
};
|
|
520
541
|
const api2 = (method, path, body, options) => {
|
|
521
542
|
const client = CALL_CLIENT.getStore();
|
|
522
543
|
if (!client) throw new Error("A Tensor MCP tool ran without a client bound (registerAllTools binds one per call).");
|
|
523
|
-
return client(method, path, body, {
|
|
544
|
+
return client(method, path, body, {
|
|
545
|
+
...options,
|
|
546
|
+
idempotencyKey: idempotencyKeyFor(CALL_KEY, method),
|
|
547
|
+
reason: options?.reason ?? CALL_REASON.getStore()
|
|
548
|
+
});
|
|
524
549
|
};
|
|
525
550
|
defineTools(collector, api2);
|
|
526
551
|
for (const d of definitions) toolsetOf(d.scope);
|
|
@@ -574,6 +599,8 @@ function describeApiFailure(method, path, status, text, retryAfter) {
|
|
|
574
599
|
advice = "The first attempt is still running. Retry in a few seconds with the same idempotencyKey.";
|
|
575
600
|
} else if (status === 409 && parsed?.code === "idempotency_key_conflict") {
|
|
576
601
|
advice = "That idempotencyKey was already used with different arguments. Use a new key for a new write.";
|
|
602
|
+
} else if (status === 409 && parsed?.code === "stale_write") {
|
|
603
|
+
advice = "Someone changed this record since you read it (`changedBy` says who, `current` is the record now). Merge your change onto `current`, and retry with its updatedAt; ask the user if the two changes disagree.";
|
|
577
604
|
} else if (status === 409 && parsed?.code === "delete_blocked") {
|
|
578
605
|
advice = "Other records still use this one (preview.blockedBy). Tell the user what they are; it can be deleted only after those are moved or deleted.";
|
|
579
606
|
} else if (status === 428) {
|
|
@@ -687,6 +714,7 @@ function defineTools(server2, api2) {
|
|
|
687
714
|
"Edit an entity. Only the fields sent change.",
|
|
688
715
|
{
|
|
689
716
|
id: z2.number().describe("Entity ID to update"),
|
|
717
|
+
expectedUpdatedAt: EXPECTED_UPDATED_AT_INPUT,
|
|
690
718
|
name: z2.string().optional().describe("New entity name"),
|
|
691
719
|
type: z2.string().optional().describe("New entity type key"),
|
|
692
720
|
jurisdiction: z2.string().optional().describe("Legal jurisdiction"),
|
|
@@ -756,12 +784,9 @@ function defineTools(server2, api2) {
|
|
|
756
784
|
);
|
|
757
785
|
server2.tool(
|
|
758
786
|
"delete_entity_relationship",
|
|
759
|
-
"Delete
|
|
760
|
-
{ id: z2.number().describe("Relationship ID to delete") },
|
|
761
|
-
async ({ id }) => {
|
|
762
|
-
const data = await api2("DELETE", `/api/entity-relationships/${id}`);
|
|
763
|
-
return { content: [{ type: "text", text: JSON.stringify(data) }] };
|
|
764
|
-
}
|
|
787
|
+
"Delete a relationship between two entities, with its role, ownership percent, dates and notes. Both entities stay. Permanent. Two calls: the first deletes nothing and returns a preview and a confirmToken; repeat with it only after the user agrees.",
|
|
788
|
+
{ id: z2.number().describe("Relationship ID to delete"), confirmToken: CONFIRM_TOKEN_INPUT },
|
|
789
|
+
async ({ id, confirmToken }) => confirmable(() => api2("DELETE", `/api/entity-relationships/${id}`, void 0, { confirmToken }))
|
|
765
790
|
);
|
|
766
791
|
server2.tool(
|
|
767
792
|
"list_entity_groups",
|
|
@@ -846,6 +871,7 @@ function defineTools(server2, api2) {
|
|
|
846
871
|
"Edit an account. Only the fields sent change.",
|
|
847
872
|
{
|
|
848
873
|
id: z2.number().describe("Account ID to update"),
|
|
874
|
+
expectedUpdatedAt: EXPECTED_UPDATED_AT_INPUT,
|
|
849
875
|
name: z2.string().optional(),
|
|
850
876
|
entityId: z2.number().optional(),
|
|
851
877
|
accountType: z2.string().optional().describe("Account type key"),
|
|
@@ -921,6 +947,7 @@ function defineTools(server2, api2) {
|
|
|
921
947
|
"Edit an asset. Set tickerSymbol to link or relink it to a market quote.",
|
|
922
948
|
{
|
|
923
949
|
id: z2.number().describe("Asset ID to update"),
|
|
950
|
+
expectedUpdatedAt: EXPECTED_UPDATED_AT_INPUT,
|
|
924
951
|
name: z2.string().optional(),
|
|
925
952
|
assetClass: z2.string().optional(),
|
|
926
953
|
symbol: z2.string().optional().describe("Display ticker. Does not price the asset."),
|
|
@@ -1059,6 +1086,7 @@ function defineTools(server2, api2) {
|
|
|
1059
1086
|
"Edit a position. Changing quantity, averageCost, a cash balance (currentValue) or a capital account's costBasis also appends one `adjustment` ledger row recording the difference. Use it to restate totals; record a known trade with create_transaction.",
|
|
1060
1087
|
{
|
|
1061
1088
|
id: z2.number().describe("Position ID to update"),
|
|
1089
|
+
expectedUpdatedAt: z2.number().optional().describe("The updatedAt you read. If the position changed since (an edit, a price, a valuation or a transaction), the edit is refused (409) with the current position."),
|
|
1062
1090
|
entityId: z2.number().optional(),
|
|
1063
1091
|
accountId: z2.number().optional(),
|
|
1064
1092
|
assetId: z2.number().optional(),
|
|
@@ -1147,12 +1175,9 @@ function defineTools(server2, api2) {
|
|
|
1147
1175
|
);
|
|
1148
1176
|
server2.tool(
|
|
1149
1177
|
"delete_position_relation",
|
|
1150
|
-
"Remove a
|
|
1151
|
-
{ id: z2.number().describe("Position relation ID to delete") },
|
|
1152
|
-
async ({ id }) => {
|
|
1153
|
-
const data = await api2("DELETE", `/api/position-relations/${id}`);
|
|
1154
|
-
return { content: [{ type: "text", text: JSON.stringify(data) }] };
|
|
1155
|
-
}
|
|
1178
|
+
"Remove a relation between two positions. Both positions stay. Permanent. Two calls: the first deletes nothing and returns a preview and a confirmToken; repeat with it only after the user agrees.",
|
|
1179
|
+
{ id: z2.number().describe("Position relation ID to delete"), confirmToken: CONFIRM_TOKEN_INPUT },
|
|
1180
|
+
async ({ id, confirmToken }) => confirmable(() => api2("DELETE", `/api/position-relations/${id}`, void 0, { confirmToken }))
|
|
1156
1181
|
);
|
|
1157
1182
|
server2.tool(
|
|
1158
1183
|
"list_transactions",
|
|
@@ -1252,6 +1277,7 @@ function defineTools(server2, api2) {
|
|
|
1252
1277
|
"Edit an institution.",
|
|
1253
1278
|
{
|
|
1254
1279
|
id: z2.number().describe("Institution ID"),
|
|
1280
|
+
expectedUpdatedAt: EXPECTED_UPDATED_AT_INPUT,
|
|
1255
1281
|
name: z2.string().optional(),
|
|
1256
1282
|
notes: z2.string().optional()
|
|
1257
1283
|
},
|
|
@@ -1626,17 +1652,23 @@ function defineTools(server2, api2) {
|
|
|
1626
1652
|
);
|
|
1627
1653
|
server2.tool(
|
|
1628
1654
|
"list_changes",
|
|
1629
|
-
"Creates, updates and deletes since a time, to catch up instead of re-reading. Resume from the returned `until`. If `coverage.complete` is false the delta is untrustworthy: do a full read. Kept
|
|
1655
|
+
"Creates, updates and deletes since a time, to catch up instead of re-reading. Each change says which client made it (`via`) and why, if it said (`reason`). Resume from the returned `until`. If `coverage.complete` is false the delta is untrustworthy: do a full read. Kept a year. Only types your scopes read appear; memos, links, tags, terms, FX and settings never do.",
|
|
1630
1656
|
{
|
|
1631
1657
|
since: z2.number().optional().describe("Epoch-ms lower bound (exclusive). Omit or 0 for everything on record."),
|
|
1632
1658
|
limit: z2.number().optional().describe("Max changes per page. Default 500."),
|
|
1633
|
-
resourceType: z2.string().optional().describe("Only changes to this resource type, e.g. 'position', 'asset', 'entity'")
|
|
1659
|
+
resourceType: z2.string().optional().describe("Only changes to this resource type, e.g. 'position', 'asset', 'entity'"),
|
|
1660
|
+
excludeSelf: z2.boolean().optional().describe("Leave out this connection's own changes: what others did since."),
|
|
1661
|
+
via: z2.array(z2.enum(["agent", "web", "app", "key", "oauth", "system"])).optional().describe("Only changes from these kinds of client; agent = key or oauth."),
|
|
1662
|
+
actor: z2.string().optional().describe("Only changes by one credential: a change's via.ref, e.g. key:ak_\u2026")
|
|
1634
1663
|
},
|
|
1635
|
-
async ({ since, limit, resourceType }) => {
|
|
1664
|
+
async ({ since, limit, resourceType, excludeSelf, via, actor }) => {
|
|
1636
1665
|
const params = new URLSearchParams();
|
|
1637
1666
|
if (since) params.set("since", String(since));
|
|
1638
1667
|
if (limit) params.set("limit", String(limit));
|
|
1639
1668
|
if (resourceType) params.set("resourceType", resourceType);
|
|
1669
|
+
if (excludeSelf) params.set("excludeSelf", "true");
|
|
1670
|
+
if (via?.length) params.set("via", via.join(","));
|
|
1671
|
+
if (actor) params.set("actor", actor);
|
|
1640
1672
|
const qs = params.toString();
|
|
1641
1673
|
const data = await api2("GET", `/api/v1/changes${qs ? `?${qs}` : ""}`);
|
|
1642
1674
|
return { content: [{ type: "text", text: JSON.stringify(data) }] };
|
|
@@ -1961,7 +1993,7 @@ function defineTools(server2, api2) {
|
|
|
1961
1993
|
);
|
|
1962
1994
|
server2.tool(
|
|
1963
1995
|
"get_todo_activity",
|
|
1964
|
-
"A todo's latest 50 activity entries. Kept
|
|
1996
|
+
"A todo's latest 50 activity entries. Kept a year; past 90 days an entry says what changed, not to what.",
|
|
1965
1997
|
{ id: z2.number().describe("Todo ID") },
|
|
1966
1998
|
async ({ id }) => {
|
|
1967
1999
|
const data = await api2("GET", `/api/todos/${id}/activity`);
|
|
@@ -2009,7 +2041,7 @@ function defineTools(server2, api2) {
|
|
|
2009
2041
|
priority: z2.number().optional().describe("0 = none, 1 = urgent, 2 = high, 3 = medium, 4 = low"),
|
|
2010
2042
|
assigneeId: z2.number().nullable().optional().describe("User ID, or null to unassign"),
|
|
2011
2043
|
dueDate: z2.string().nullable().optional().describe("ISO YYYY-MM-DD, or null to clear"),
|
|
2012
|
-
expectedUpdatedAt:
|
|
2044
|
+
expectedUpdatedAt: EXPECTED_UPDATED_AT_INPUT
|
|
2013
2045
|
},
|
|
2014
2046
|
async ({ id, body, ...rest }) => {
|
|
2015
2047
|
const payload = { ...rest };
|
|
@@ -2354,6 +2386,7 @@ function defineTools(server2, api2) {
|
|
|
2354
2386
|
"Edit an idea. `tags` replaces the tag set; `media` appends. Sending body replaces the whole body document, inline images included (they stay in the gallery): read the idea first if you did not write it.",
|
|
2355
2387
|
{
|
|
2356
2388
|
id: z2.number().describe("Idea ID"),
|
|
2389
|
+
expectedUpdatedAt: EXPECTED_UPDATED_AT_INPUT,
|
|
2357
2390
|
kind: z2.enum(IDEA_KINDS).optional(),
|
|
2358
2391
|
title: z2.string().nullable().optional(),
|
|
2359
2392
|
url: z2.string().nullable().optional(),
|
|
@@ -2413,6 +2446,15 @@ function defineTools(server2, api2) {
|
|
|
2413
2446
|
return { content: [{ type: "text", text: JSON.stringify(data) }] };
|
|
2414
2447
|
}
|
|
2415
2448
|
);
|
|
2449
|
+
server2.tool(
|
|
2450
|
+
"get_idea_activity",
|
|
2451
|
+
"An idea's latest 50 activity entries: who changed it, through which client, and why. Kept a year; past 90 days an entry says what changed, not to what.",
|
|
2452
|
+
{ id: z2.number().describe("Idea ID") },
|
|
2453
|
+
async ({ id }) => {
|
|
2454
|
+
const data = await api2("GET", `/api/ideas/${id}/activity`);
|
|
2455
|
+
return { content: [{ type: "text", text: JSON.stringify(data) }] };
|
|
2456
|
+
}
|
|
2457
|
+
);
|
|
2416
2458
|
server2.tool(
|
|
2417
2459
|
"list_idea_comments",
|
|
2418
2460
|
"An idea's comments. Read bodyText.",
|
|
@@ -2763,15 +2805,13 @@ function defineTools(server2, api2) {
|
|
|
2763
2805
|
);
|
|
2764
2806
|
server2.tool(
|
|
2765
2807
|
"delete_tab",
|
|
2766
|
-
"Remove one tab from a group
|
|
2808
|
+
"Remove one tab from a group for good (only groups have Trash). Permanent. Two calls: the first deletes nothing and returns a preview and a confirmToken; repeat with the same id, itemId and that token only after the user agrees.",
|
|
2767
2809
|
{
|
|
2768
2810
|
id: z2.number().describe("Tab group ID"),
|
|
2769
|
-
itemId: z2.number().describe("The tab's own id, from the group's items")
|
|
2811
|
+
itemId: z2.number().describe("The tab's own id, from the group's items"),
|
|
2812
|
+
confirmToken: CONFIRM_TOKEN_INPUT
|
|
2770
2813
|
},
|
|
2771
|
-
async ({ id, itemId }) => {
|
|
2772
|
-
const data = await api2("DELETE", `/api/tabs/${id}/items/${itemId}`);
|
|
2773
|
-
return { content: [{ type: "text", text: JSON.stringify(data) }] };
|
|
2774
|
-
}
|
|
2814
|
+
async ({ id, itemId, confirmToken }) => confirmable(() => api2("DELETE", `/api/tabs/${id}/items/${itemId}`, void 0, { confirmToken }))
|
|
2775
2815
|
);
|
|
2776
2816
|
server2.tool(
|
|
2777
2817
|
"delete_tab_group",
|
|
@@ -2812,15 +2852,24 @@ function createApiClient(opts) {
|
|
|
2812
2852
|
const apiKey = opts.apiKey;
|
|
2813
2853
|
const extraHeaders = Object.fromEntries(
|
|
2814
2854
|
Object.entries(opts.headers ?? {}).filter(
|
|
2815
|
-
([name]) => !/^(authorization|accept|content-type|idempotency-key|tensor-confirm)$/i.test(name)
|
|
2855
|
+
([name]) => !/^(authorization|accept|content-type|idempotency-key|tensor-confirm|x-tensor-reason)$/i.test(name)
|
|
2816
2856
|
)
|
|
2817
2857
|
);
|
|
2858
|
+
const agentName = opts.agentName?.trim();
|
|
2859
|
+
if (agentName) {
|
|
2860
|
+
for (const name of Object.keys(extraHeaders)) if (/^x-tensor-agent$/i.test(name)) delete extraHeaders[name];
|
|
2861
|
+
extraHeaders["X-Tensor-Agent"] = encodeURIComponent(Array.from(agentName).slice(0, 120).join(""));
|
|
2862
|
+
}
|
|
2818
2863
|
return async (method, path, body, options) => {
|
|
2819
2864
|
const headers = {
|
|
2820
2865
|
...extraHeaders,
|
|
2821
2866
|
Authorization: `Bearer ${apiKey}`,
|
|
2822
2867
|
Accept: "application/json"
|
|
2823
2868
|
};
|
|
2869
|
+
const reason = options?.reason?.trim();
|
|
2870
|
+
if (reason && method !== "GET") {
|
|
2871
|
+
headers["X-Tensor-Reason"] = encodeURIComponent(reason.slice(0, 200));
|
|
2872
|
+
}
|
|
2824
2873
|
if (body !== void 0) {
|
|
2825
2874
|
headers["Content-Type"] = "application/json";
|
|
2826
2875
|
}
|
|
@@ -2869,7 +2918,7 @@ var SERVER_IDENTITY = {
|
|
|
2869
2918
|
// package.json
|
|
2870
2919
|
var package_default = {
|
|
2871
2920
|
name: "@levitating/tensor-mcp",
|
|
2872
|
-
version: "6.
|
|
2921
|
+
version: "6.2.0",
|
|
2873
2922
|
description: "Tensor MCP \u2014 Model Context Protocol server for the Tensor wealth management API. Exposes the Tensor API as tools for Claude, Cursor, Codex, and any MCP-aware client.",
|
|
2874
2923
|
type: "module",
|
|
2875
2924
|
main: "./dist/index.js",
|
|
@@ -2942,7 +2991,7 @@ var server = new McpServer({
|
|
|
2942
2991
|
// reasoning live in ./guide.ts; server/routes/mcp.ts passes the same constant.
|
|
2943
2992
|
instructions: SERVER_INSTRUCTIONS
|
|
2944
2993
|
});
|
|
2945
|
-
var api = createApiClient({ apiKey: API_KEY, baseUrl: BASE_URL });
|
|
2994
|
+
var api = createApiClient({ apiKey: API_KEY, baseUrl: BASE_URL, agentName: process.env.TENSOR_AGENT_NAME });
|
|
2946
2995
|
var SELECTION = {
|
|
2947
2996
|
readOnly: parseFlag(process.env.TENSOR_MCP_READ_ONLY),
|
|
2948
2997
|
toolsets: parseToolsets(process.env.TENSOR_MCP_TOOLSETS)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@levitating/tensor-mcp",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.2.0",
|
|
4
4
|
"description": "Tensor MCP — Model Context Protocol server for the Tensor wealth management API. Exposes the Tensor API as tools for Claude, Cursor, Codex, and any MCP-aware client.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
package/skills/tensor/SKILL.md
CHANGED
|
@@ -22,6 +22,7 @@ How to work well here:
|
|
|
22
22
|
6. Lists answer {items, hasMore, nextOffset}: 100 rows unless you pass limit (at most 1000); pass nextOffset as offset for the next page. Filter on the server (filters combine with AND; a value Tensor cannot parse is ignored, which widens the answer) and catch up with list_changes(since) instead of re-reading everything. Times are epoch milliseconds.
|
|
23
23
|
7. A body you send (todos, ideas, comments) is plain text, one paragraph per line; Tensor stores a document and returns the text as body or bodyText. Sending body replaces the whole body. You can edit only your own comments, and none can be deleted.
|
|
24
24
|
8. A download or media URL is a bearer link to a private file and stays in this conversation: mint one only right before fetching, and never repost it. Each one is logged.
|
|
25
|
+
9. Other agents and people work here too, and every write records which client made it. Give a write a short reason when it is not obvious; the user sees it beside the change. Edit with the updatedAt you read as expectedUpdatedAt, so a change someone made meanwhile is refused (409 with the current record) instead of overwritten. list_changes(excludeSelf: true) shows what others did since you last looked.
|
|
25
26
|
|
|
26
27
|
Before an unfamiliar job, call get_guide with a topic: ledger, imports, work, files or safety.
|
|
27
28
|
|
|
@@ -104,7 +105,7 @@ An idea that has been handled but is worth keeping is archived with archive_idea
|
|
|
104
105
|
Leaving folderId off files a bookmark as Unfiled, which is a normal resting place; do not invent a folder for it. Keep the order list_bookmarks and list_bookmark_folders return; the owner arranged it by hand. move_bookmark and move_bookmark_folder change a folder and a place in that order in one call. delete_bookmark is soft, delete_bookmark_folder is not (the bookmarks inside survive, the folder does not).
|
|
105
106
|
|
|
106
107
|
### Tab groups
|
|
107
|
-
Tab groups are personal: a connection sees only its own person's groups. Park a whole set of tabs in one create_tab_group call, and add more to the end with add_tabs_to_group. Only name, locked and starred are editable. delete_tab removes one tab for good; delete_tab_group is soft.
|
|
108
|
+
Tab groups are personal: a connection sees only its own person's groups. Park a whole set of tabs in one create_tab_group call, and add more to the end with add_tabs_to_group. Only name, locked and starred are editable. delete_tab removes one tab for good and takes two calls, a preview and then the confirmToken; delete_tab_group is soft.
|
|
108
109
|
|
|
109
110
|
### Links between records
|
|
110
111
|
attach_todo_link, attach_idea_link and attach_file_link join a record to any ledger record or to another work record; each list_ call returns linkIds for the matching detach_. A link to a record type your connection cannot read is refused when you write it and left out when you read, so an empty list means "none you can see". Links of kind "mention" come from @mentions in prose; remove the mention from the text rather than detaching the link.
|
|
@@ -113,7 +114,7 @@ attach_todo_link, attach_idea_link and attach_file_link join a record to any led
|
|
|
113
114
|
search_records is one ranked search over every type you can read. It resolves reference ids directly (TSK-12, IDEA-7, AS021). Types your scopes do not cover are left out silently. For market tickers use search_market_quotes instead.
|
|
114
115
|
|
|
115
116
|
### Keeping up to date
|
|
116
|
-
list_changes(since) returns creates, updates and deletes across everything your scopes can read, kept for
|
|
117
|
+
list_changes(since) returns creates, updates and deletes across everything your scopes can read, kept for a year, each with the client that made it (via) and the reason it gave. Resume from the until it returns. When coverage.complete is false, do a full read instead. excludeSelf: true leaves out your own writes; via: ["agent"] or actor (a change's via.ref) narrows it to other agents or to one.
|
|
117
118
|
|
|
118
119
|
## Files
|
|
119
120
|
|
|
@@ -140,15 +141,18 @@ delete_file moves a file to Trash; restore_file brings it back for 60 days. Fold
|
|
|
140
141
|
### Ask the user before
|
|
141
142
|
- any create_transaction or sell_all_position (the ledger cannot be edited afterwards);
|
|
142
143
|
- data_apply (show the dry-run preview first);
|
|
143
|
-
- every permanent delete: delete_position (takes its whole ledger), delete_entity, delete_account, delete_asset, delete_institution and the other catalog deletes, delete_entity_group, delete_bookmark_folder, delete_tab, delete_todo_tag, delete_todo_state;
|
|
144
|
+
- every permanent delete: delete_position (takes its whole ledger), delete_entity, delete_account, delete_asset, delete_institution and the other catalog deletes, delete_entity_group, delete_entity_relationship, delete_position_relation, delete_bookmark_folder, delete_tab, delete_todo_tag, delete_todo_state;
|
|
144
145
|
- sync_prices over the whole catalog;
|
|
145
146
|
- minting download links for more than the file the user asked about.
|
|
146
|
-
Tensor enforces
|
|
147
|
+
Tensor enforces those deletes itself (all but delete_todo_state, which it refuses while a todo is in the state): the call answers NOT DELETED with what would go and a confirmToken. Show the user that preview in plain words and pass the token back only after they say yes; never confirm on your own. A refused delete names what still uses the record: tell the user, do not work around it.
|
|
147
148
|
Soft deletes (todos, ideas, files, bookmarks, tab groups) are recoverable for 60 days with the restore_ tools (list_trash finds them), but still say what you are moving to Trash, including a todo's sub-tasks. Trash empties itself after those 60 days; for an idea the user wants to keep but no longer see, archive_idea is the right verb, because Archive never expires.
|
|
148
149
|
|
|
149
150
|
### Retrying
|
|
150
151
|
Every write a retry could duplicate takes an optional idempotencyKey. Use a fresh unique value per intended write and the SAME value when you retry that write after a timeout or a network error; Tensor then returns the first result instead of writing again. Never reuse a key for a different write.
|
|
151
152
|
|
|
153
|
+
### Working beside other agents
|
|
154
|
+
Every write records which client made it: the key or the connection, never a name you choose. If you share a key with other agents, the user can give you a name for it (TENSOR_AGENT_NAME for the stdio package, or the X-Tensor-Agent header); Tensor shows it as the name you call yourself, beside the key's own. Each write tool takes an optional reason (one sentence, at most 200 characters); the user reads it beside the change in Activity, so write it for them and keep it factual. Before editing a record someone else may touch, read it and pass its updatedAt as expectedUpdatedAt: a 409 stale_write means it changed meanwhile, and the answer carries the current record and who changed it. Merge onto that and retry, or ask the user when the two changes disagree. Never retry the same edit blindly without it.
|
|
155
|
+
|
|
152
156
|
### What this connection can do
|
|
153
157
|
Each connection carries scopes (portfolio, reference, files, todos, ideas, bookmarks, tabs, each read or write, plus the data pipeline). Only the tools its scopes reach are listed, and a 403 names a missing scope. Some things no connection can do, by design: read memos or browsing history; change FX rates, loan terms or fund terms (they are read-only); empty a Trash or permanently purge; create API keys or change its own access. When you cannot do something, tell the user which scope or which part of the Tensor app it needs.
|
|
154
158
|
|
|
@@ -157,7 +161,7 @@ Each connection carries scopes (portfolio, reference, files, todos, ideas, bookm
|
|
|
157
161
|
- 401: the credential is revoked, expired or wrong. The user must reconnect Tensor.
|
|
158
162
|
- 403: a missing scope (named in the message) or something no connection may do. Do not retry.
|
|
159
163
|
- 404: no such record for this connection. Check the id with search_records or a list_ call.
|
|
160
|
-
- 409: a conflict with the record's current state (a cycle, a state still in use,
|
|
164
|
+
- 409: a conflict with the record's current state (a cycle, a state still in use), stale_write (it changed since the updatedAt you sent: read current, merge, retry), an idempotencyKey problem, or delete_blocked (other records still use this one). The message says which.
|
|
161
165
|
- 428: not an error. A permanent delete is waiting for the user's yes; see "Ask the user before".
|
|
162
166
|
- 429: rate limited (an API key allows 120 requests a minute). Wait as told, then continue. Batch work instead of looping single calls.
|
|
163
167
|
- 5xx: Tensor failed. One retry is fine; then report it with the errorId.
|