@jbctechsolutions/mcp-office365 3.0.0 → 4.0.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.
- package/README.md +42 -65
- package/dist/approval/hash.d.ts +8 -8
- package/dist/approval/token-manager.d.ts +12 -6
- package/dist/approval/token-manager.d.ts.map +1 -1
- package/dist/approval/token-manager.js +11 -3
- package/dist/approval/token-manager.js.map +1 -1
- package/dist/approval/types.d.ts +7 -3
- package/dist/approval/types.d.ts.map +1 -1
- package/dist/cli.d.ts +4 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +18 -3
- package/dist/cli.js.map +1 -1
- package/dist/database/repository.d.ts +48 -48
- package/dist/database/repository.d.ts.map +1 -1
- package/dist/database/repository.js.map +1 -1
- package/dist/delta/mirror.d.ts +67 -0
- package/dist/delta/mirror.d.ts.map +1 -0
- package/dist/delta/mirror.js +183 -0
- package/dist/delta/mirror.js.map +1 -0
- package/dist/graph/auth/account-id.d.ts +19 -0
- package/dist/graph/auth/account-id.d.ts.map +1 -0
- package/dist/graph/auth/account-id.js +55 -0
- package/dist/graph/auth/account-id.js.map +1 -0
- package/dist/graph/auth/config.d.ts +1 -1
- package/dist/graph/auth/config.d.ts.map +1 -1
- package/dist/graph/auth/config.js +8 -0
- package/dist/graph/auth/config.js.map +1 -1
- package/dist/graph/auth/index.d.ts +1 -0
- package/dist/graph/auth/index.d.ts.map +1 -1
- package/dist/graph/auth/index.js +1 -0
- package/dist/graph/auth/index.js.map +1 -1
- package/dist/graph/client/graph-client.d.ts +105 -0
- package/dist/graph/client/graph-client.d.ts.map +1 -1
- package/dist/graph/client/graph-client.js +414 -18
- package/dist/graph/client/graph-client.js.map +1 -1
- package/dist/graph/client/immutable-id-middleware.d.ts +50 -0
- package/dist/graph/client/immutable-id-middleware.d.ts.map +1 -0
- package/dist/graph/client/immutable-id-middleware.js +137 -0
- package/dist/graph/client/immutable-id-middleware.js.map +1 -0
- package/dist/graph/content-readers.d.ts +0 -12
- package/dist/graph/content-readers.d.ts.map +1 -1
- package/dist/graph/content-readers.js +0 -21
- package/dist/graph/content-readers.js.map +1 -1
- package/dist/graph/index.d.ts +5 -6
- package/dist/graph/index.d.ts.map +1 -1
- package/dist/graph/index.js +5 -6
- package/dist/graph/index.js.map +1 -1
- package/dist/graph/mailbox-adapter.d.ts +15 -15
- package/dist/graph/mappers/contact-mapper.d.ts +4 -1
- package/dist/graph/mappers/contact-mapper.d.ts.map +1 -1
- package/dist/graph/mappers/contact-mapper.js +7 -3
- package/dist/graph/mappers/contact-mapper.js.map +1 -1
- package/dist/graph/mappers/email-mapper.d.ts.map +1 -1
- package/dist/graph/mappers/email-mapper.js +7 -4
- package/dist/graph/mappers/email-mapper.js.map +1 -1
- package/dist/graph/mappers/event-mapper.d.ts.map +1 -1
- package/dist/graph/mappers/event-mapper.js +6 -3
- package/dist/graph/mappers/event-mapper.js.map +1 -1
- package/dist/graph/mappers/folder-mapper.d.ts +0 -4
- package/dist/graph/mappers/folder-mapper.d.ts.map +1 -1
- package/dist/graph/mappers/folder-mapper.js +9 -19
- package/dist/graph/mappers/folder-mapper.js.map +1 -1
- package/dist/graph/mappers/index.d.ts +2 -2
- package/dist/graph/mappers/index.d.ts.map +1 -1
- package/dist/graph/mappers/index.js +2 -2
- package/dist/graph/mappers/index.js.map +1 -1
- package/dist/graph/mappers/task-mapper.d.ts +4 -2
- package/dist/graph/mappers/task-mapper.d.ts.map +1 -1
- package/dist/graph/mappers/task-mapper.js +7 -5
- package/dist/graph/mappers/task-mapper.js.map +1 -1
- package/dist/graph/mappers/utils.d.ts +0 -10
- package/dist/graph/mappers/utils.d.ts.map +1 -1
- package/dist/graph/mappers/utils.js +0 -19
- package/dist/graph/mappers/utils.js.map +1 -1
- package/dist/graph/repository.d.ts +400 -270
- package/dist/graph/repository.d.ts.map +1 -1
- package/dist/graph/repository.js +739 -1046
- package/dist/graph/repository.js.map +1 -1
- package/dist/ids/next-action.d.ts +29 -0
- package/dist/ids/next-action.d.ts.map +1 -0
- package/dist/ids/next-action.js +58 -0
- package/dist/ids/next-action.js.map +1 -0
- package/dist/ids/resolver.d.ts +2 -1
- package/dist/ids/resolver.d.ts.map +1 -1
- package/dist/ids/resolver.js +19 -4
- package/dist/ids/resolver.js.map +1 -1
- package/dist/ids/schema.d.ts +91 -0
- package/dist/ids/schema.d.ts.map +1 -0
- package/dist/ids/schema.js +131 -0
- package/dist/ids/schema.js.map +1 -0
- package/dist/ids/token.d.ts +7 -1
- package/dist/ids/token.d.ts.map +1 -1
- package/dist/ids/token.js +46 -7
- package/dist/ids/token.js.map +1 -1
- package/dist/index.d.ts +4 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +63 -100
- package/dist/index.js.map +1 -1
- package/dist/parsers/index.d.ts +0 -1
- package/dist/parsers/index.d.ts.map +1 -1
- package/dist/parsers/index.js +0 -1
- package/dist/parsers/index.js.map +1 -1
- package/dist/registry/all-tools.d.ts.map +1 -1
- package/dist/registry/all-tools.js +8 -4
- package/dist/registry/all-tools.js.map +1 -1
- package/dist/registry/context.d.ts +1 -7
- package/dist/registry/context.d.ts.map +1 -1
- package/dist/registry/context.js +0 -11
- package/dist/registry/context.js.map +1 -1
- package/dist/registry/elicit-links.d.ts +35 -0
- package/dist/registry/elicit-links.d.ts.map +1 -0
- package/dist/registry/elicit-links.js +102 -0
- package/dist/registry/elicit-links.js.map +1 -0
- package/dist/registry/elicitor.d.ts +24 -0
- package/dist/registry/elicitor.d.ts.map +1 -0
- package/dist/registry/elicitor.js +51 -0
- package/dist/registry/elicitor.js.map +1 -0
- package/dist/registry/index.d.ts +2 -2
- package/dist/registry/index.d.ts.map +1 -1
- package/dist/registry/index.js +1 -1
- package/dist/registry/index.js.map +1 -1
- package/dist/registry/registry.d.ts +11 -0
- package/dist/registry/registry.d.ts.map +1 -1
- package/dist/registry/registry.js +87 -0
- package/dist/registry/registry.js.map +1 -1
- package/dist/registry/types.d.ts +61 -13
- package/dist/registry/types.d.ts.map +1 -1
- package/dist/state/delta-store.d.ts +85 -0
- package/dist/state/delta-store.d.ts.map +1 -0
- package/dist/state/delta-store.js +124 -0
- package/dist/state/delta-store.js.map +1 -0
- package/dist/state/schema.d.ts +2 -3
- package/dist/state/schema.d.ts.map +1 -1
- package/dist/state/schema.js +26 -3
- package/dist/state/schema.js.map +1 -1
- package/dist/state/store.d.ts +3 -0
- package/dist/state/store.d.ts.map +1 -1
- package/dist/state/store.js +4 -0
- package/dist/state/store.js.map +1 -1
- package/dist/tools/calendar-graph.d.ts.map +1 -1
- package/dist/tools/calendar-graph.js +10 -9
- package/dist/tools/calendar-graph.js.map +1 -1
- package/dist/tools/calendar-permissions.d.ts +7 -7
- package/dist/tools/calendar-permissions.d.ts.map +1 -1
- package/dist/tools/calendar-permissions.js +7 -4
- package/dist/tools/calendar-permissions.js.map +1 -1
- package/dist/tools/calendar.d.ts +14 -114
- package/dist/tools/calendar.d.ts.map +1 -1
- package/dist/tools/calendar.js +41 -202
- package/dist/tools/calendar.js.map +1 -1
- package/dist/tools/categories.d.ts +4 -4
- package/dist/tools/categories.d.ts.map +1 -1
- package/dist/tools/categories.js +5 -2
- package/dist/tools/categories.js.map +1 -1
- package/dist/tools/checklist-items.d.ts +9 -9
- package/dist/tools/checklist-items.d.ts.map +1 -1
- package/dist/tools/checklist-items.js +8 -5
- package/dist/tools/checklist-items.js.map +1 -1
- package/dist/tools/contact-folders.d.ts +2 -2
- package/dist/tools/contact-folders.d.ts.map +1 -1
- package/dist/tools/contact-folders.js +5 -2
- package/dist/tools/contact-folders.js.map +1 -1
- package/dist/tools/contacts-graph.d.ts +1 -1
- package/dist/tools/contacts-graph.d.ts.map +1 -1
- package/dist/tools/contacts-graph.js +8 -6
- package/dist/tools/contacts-graph.js.map +1 -1
- package/dist/tools/contacts.d.ts +9 -44
- package/dist/tools/contacts.d.ts.map +1 -1
- package/dist/tools/contacts.js +23 -131
- package/dist/tools/contacts.js.map +1 -1
- package/dist/tools/excel.d.ts +10 -10
- package/dist/tools/excel.d.ts.map +1 -1
- package/dist/tools/excel.js +9 -6
- package/dist/tools/excel.js.map +1 -1
- package/dist/tools/focused-overrides.d.ts +4 -4
- package/dist/tools/focused-overrides.d.ts.map +1 -1
- package/dist/tools/focused-overrides.js +5 -2
- package/dist/tools/focused-overrides.js.map +1 -1
- package/dist/tools/index.d.ts +4 -5
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +4 -6
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/linked-resources.d.ts +7 -7
- package/dist/tools/linked-resources.d.ts.map +1 -1
- package/dist/tools/linked-resources.js +7 -4
- package/dist/tools/linked-resources.js.map +1 -1
- package/dist/tools/mail-graph.d.ts.map +1 -1
- package/dist/tools/mail-graph.js +21 -12
- package/dist/tools/mail-graph.js.map +1 -1
- package/dist/tools/mail-rules.d.ts +8 -8
- package/dist/tools/mail-rules.d.ts.map +1 -1
- package/dist/tools/mail-rules.js +7 -7
- package/dist/tools/mail-rules.js.map +1 -1
- package/dist/tools/mail-send.d.ts +27 -27
- package/dist/tools/mail-send.d.ts.map +1 -1
- package/dist/tools/mail-send.js +30 -19
- package/dist/tools/mail-send.js.map +1 -1
- package/dist/tools/mail.d.ts +22 -79
- package/dist/tools/mail.d.ts.map +1 -1
- package/dist/tools/mail.js +45 -293
- package/dist/tools/mail.js.map +1 -1
- package/dist/tools/mailbox-organization.d.ts +34 -37
- package/dist/tools/mailbox-organization.d.ts.map +1 -1
- package/dist/tools/mailbox-organization.js +72 -64
- package/dist/tools/mailbox-organization.js.map +1 -1
- package/dist/tools/meetings.d.ts +14 -14
- package/dist/tools/meetings.d.ts.map +1 -1
- package/dist/tools/meetings.js +8 -6
- package/dist/tools/meetings.js.map +1 -1
- package/dist/tools/onedrive.d.ts +16 -16
- package/dist/tools/onedrive.d.ts.map +1 -1
- package/dist/tools/onedrive.js +16 -11
- package/dist/tools/onedrive.js.map +1 -1
- package/dist/tools/onenote.d.ts +63 -0
- package/dist/tools/onenote.d.ts.map +1 -0
- package/dist/tools/onenote.js +221 -0
- package/dist/tools/onenote.js.map +1 -0
- package/dist/tools/planner-visualization.d.ts +5 -5
- package/dist/tools/planner-visualization.d.ts.map +1 -1
- package/dist/tools/planner-visualization.js +5 -4
- package/dist/tools/planner-visualization.js.map +1 -1
- package/dist/tools/planner.d.ts +59 -39
- package/dist/tools/planner.d.ts.map +1 -1
- package/dist/tools/planner.js +48 -23
- package/dist/tools/planner.js.map +1 -1
- package/dist/tools/shared-mailbox.d.ts +164 -0
- package/dist/tools/shared-mailbox.d.ts.map +1 -0
- package/dist/tools/shared-mailbox.js +318 -0
- package/dist/tools/shared-mailbox.js.map +1 -0
- package/dist/tools/sharepoint-lists.d.ts +131 -0
- package/dist/tools/sharepoint-lists.d.ts.map +1 -0
- package/dist/tools/sharepoint-lists.js +246 -0
- package/dist/tools/sharepoint-lists.js.map +1 -0
- package/dist/tools/sharepoint.d.ts +14 -14
- package/dist/tools/sharepoint.d.ts.map +1 -1
- package/dist/tools/sharepoint.js +11 -9
- package/dist/tools/sharepoint.js.map +1 -1
- package/dist/tools/task-attachments.d.ts +7 -7
- package/dist/tools/task-attachments.d.ts.map +1 -1
- package/dist/tools/task-attachments.js +7 -4
- package/dist/tools/task-attachments.js.map +1 -1
- package/dist/tools/task-lists.d.ts +3 -3
- package/dist/tools/task-lists.d.ts.map +1 -1
- package/dist/tools/task-lists.js +10 -6
- package/dist/tools/task-lists.js.map +1 -1
- package/dist/tools/tasks-graph.d.ts +2 -2
- package/dist/tools/tasks-graph.d.ts.map +1 -1
- package/dist/tools/tasks-graph.js +6 -4
- package/dist/tools/tasks-graph.js.map +1 -1
- package/dist/tools/tasks.d.ts +8 -43
- package/dist/tools/tasks.d.ts.map +1 -1
- package/dist/tools/tasks.js +19 -122
- package/dist/tools/tasks.js.map +1 -1
- package/dist/tools/teams.d.ts +46 -46
- package/dist/tools/teams.d.ts.map +1 -1
- package/dist/tools/teams.js +34 -26
- package/dist/tools/teams.js.map +1 -1
- package/dist/tools/what-changed.d.ts +48 -0
- package/dist/tools/what-changed.d.ts.map +1 -0
- package/dist/tools/what-changed.js +149 -0
- package/dist/tools/what-changed.js.map +1 -0
- package/dist/types/calendar.d.ts +1 -1
- package/dist/types/calendar.d.ts.map +1 -1
- package/dist/types/calendar.js.map +1 -1
- package/dist/types/contacts.d.ts +1 -1
- package/dist/types/contacts.d.ts.map +1 -1
- package/dist/types/contacts.js.map +1 -1
- package/dist/types/mail.d.ts +1 -1
- package/dist/types/mail.d.ts.map +1 -1
- package/dist/types/mail.js.map +1 -1
- package/dist/utils/errors.d.ts +15 -34
- package/dist/utils/errors.d.ts.map +1 -1
- package/dist/utils/errors.js +13 -49
- package/dist/utils/errors.js.map +1 -1
- package/dist/visualization/types.d.ts +4 -4
- package/package.json +3 -4
- package/dist/applescript/account-repository.d.ts +0 -30
- package/dist/applescript/account-repository.d.ts.map +0 -1
- package/dist/applescript/account-repository.js +0 -38
- package/dist/applescript/account-repository.js.map +0 -1
- package/dist/applescript/account-scripts.d.ts +0 -21
- package/dist/applescript/account-scripts.d.ts.map +0 -1
- package/dist/applescript/account-scripts.js +0 -180
- package/dist/applescript/account-scripts.js.map +0 -1
- package/dist/applescript/calendar-manager.d.ts +0 -44
- package/dist/applescript/calendar-manager.d.ts.map +0 -1
- package/dist/applescript/calendar-manager.js +0 -92
- package/dist/applescript/calendar-manager.js.map +0 -1
- package/dist/applescript/calendar-writer.d.ts +0 -36
- package/dist/applescript/calendar-writer.d.ts.map +0 -1
- package/dist/applescript/calendar-writer.js +0 -94
- package/dist/applescript/calendar-writer.js.map +0 -1
- package/dist/applescript/content-readers.d.ts +0 -114
- package/dist/applescript/content-readers.d.ts.map +0 -1
- package/dist/applescript/content-readers.js +0 -328
- package/dist/applescript/content-readers.js.map +0 -1
- package/dist/applescript/executor.d.ts +0 -60
- package/dist/applescript/executor.d.ts.map +0 -1
- package/dist/applescript/executor.js +0 -173
- package/dist/applescript/executor.js.map +0 -1
- package/dist/applescript/index.d.ts +0 -20
- package/dist/applescript/index.d.ts.map +0 -1
- package/dist/applescript/index.js +0 -29
- package/dist/applescript/index.js.map +0 -1
- package/dist/applescript/mail-sender.d.ts +0 -38
- package/dist/applescript/mail-sender.d.ts.map +0 -1
- package/dist/applescript/mail-sender.js +0 -67
- package/dist/applescript/mail-sender.js.map +0 -1
- package/dist/applescript/parser.d.ts +0 -235
- package/dist/applescript/parser.d.ts.map +0 -1
- package/dist/applescript/parser.js +0 -496
- package/dist/applescript/parser.js.map +0 -1
- package/dist/applescript/repository.d.ts +0 -64
- package/dist/applescript/repository.d.ts.map +0 -1
- package/dist/applescript/repository.js +0 -444
- package/dist/applescript/repository.js.map +0 -1
- package/dist/applescript/scripts.d.ts +0 -265
- package/dist/applescript/scripts.d.ts.map +0 -1
- package/dist/applescript/scripts.js +0 -1483
- package/dist/applescript/scripts.js.map +0 -1
- package/dist/parsers/olk15.d.ts +0 -87
- package/dist/parsers/olk15.d.ts.map +0 -1
- package/dist/parsers/olk15.js +0 -368
- package/dist/parsers/olk15.js.map +0 -1
- package/dist/tools/accounts.d.ts +0 -37
- package/dist/tools/accounts.d.ts.map +0 -1
- package/dist/tools/accounts.js +0 -68
- package/dist/tools/accounts.js.map +0 -1
- package/dist/tools/calendar-apple.d.ts +0 -39
- package/dist/tools/calendar-apple.d.ts.map +0 -1
- package/dist/tools/calendar-apple.js +0 -159
- package/dist/tools/calendar-apple.js.map +0 -1
- package/dist/tools/mail-apple.d.ts +0 -40
- package/dist/tools/mail-apple.d.ts.map +0 -1
- package/dist/tools/mail-apple.js +0 -146
- package/dist/tools/mail-apple.js.map +0 -1
- package/dist/tools/notes.d.ts +0 -86
- package/dist/tools/notes.d.ts.map +0 -1
- package/dist/tools/notes.js +0 -202
- package/dist/tools/notes.js.map +0 -1
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 JBC Tech Solutions, LLC
|
|
3
|
+
* Licensed under the MIT License. See LICENSE file in the project root.
|
|
4
|
+
*/
|
|
5
|
+
/** Parses a prepare tool's single-text-block JSON result, or {} on any failure. */
|
|
6
|
+
function parseResult(result) {
|
|
7
|
+
const text = result.content[0]?.text;
|
|
8
|
+
if (text == null)
|
|
9
|
+
return {};
|
|
10
|
+
try {
|
|
11
|
+
return JSON.parse(text);
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
return {};
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
/** The lone token a single-target prepare minted (`approval_token`/`token_id`). */
|
|
18
|
+
function singleToken(result) {
|
|
19
|
+
const parsed = parseResult(result);
|
|
20
|
+
const token = parsed['approval_token'] ?? parsed['token_id'];
|
|
21
|
+
return typeof token === 'string' && token.length > 0 ? token : null;
|
|
22
|
+
}
|
|
23
|
+
function singleTokenIds(result) {
|
|
24
|
+
const token = singleToken(result);
|
|
25
|
+
return token != null ? [token] : [];
|
|
26
|
+
}
|
|
27
|
+
/** Copies the named keys from prepare params into the confirm params. */
|
|
28
|
+
function pick(params, keys) {
|
|
29
|
+
const src = (params ?? {});
|
|
30
|
+
const out = {};
|
|
31
|
+
for (const key of keys) {
|
|
32
|
+
if (src[key] !== undefined)
|
|
33
|
+
out[key] = src[key];
|
|
34
|
+
}
|
|
35
|
+
return out;
|
|
36
|
+
}
|
|
37
|
+
/** Shape A: confirm tool takes a single `{ approval_token }`. */
|
|
38
|
+
export function approvalTokenLink(confirmTool) {
|
|
39
|
+
return {
|
|
40
|
+
confirmTool,
|
|
41
|
+
collectTokenIds: singleTokenIds,
|
|
42
|
+
buildParams: (_prepareParams, result) => ({ approval_token: singleToken(result) }),
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Shape B: confirm tool takes `{ token_id, ...copyFields }`, where each copied
|
|
47
|
+
* field is carried over verbatim from the prepare params (same field name).
|
|
48
|
+
*/
|
|
49
|
+
export function tokenIdLink(confirmTool, copyFields = []) {
|
|
50
|
+
return {
|
|
51
|
+
confirmTool,
|
|
52
|
+
collectTokenIds: singleTokenIds,
|
|
53
|
+
buildParams: (prepareParams, result) => ({
|
|
54
|
+
token_id: singleToken(result),
|
|
55
|
+
...pick(prepareParams, copyFields),
|
|
56
|
+
}),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Shape C: the batch confirm takes `{ tokens: [{ token_id, email_id }, …] }`,
|
|
61
|
+
* one pair per email. The batch prepare returns `{ tokens: [{ token_id, email:
|
|
62
|
+
* { id, … } }] }` where the token's target is `email.id`, so `email_id` is read
|
|
63
|
+
* from `email.id` (with a direct `email_id` fallback for robustness).
|
|
64
|
+
*
|
|
65
|
+
* `collectTokenIds` gathers EVERY minted `token_id` independently of the id
|
|
66
|
+
* mapping, so a decline invalidates all of them even if a pair is malformed.
|
|
67
|
+
*/
|
|
68
|
+
export function batchLink(confirmTool) {
|
|
69
|
+
return {
|
|
70
|
+
confirmTool,
|
|
71
|
+
collectTokenIds: (result) => batchTokenIds(result),
|
|
72
|
+
buildParams: (_prepareParams, result) => ({ tokens: batchPairs(result) }),
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/** Raw `tokens` array from a batch prepare result, or []. */
|
|
76
|
+
function batchEntries(result) {
|
|
77
|
+
const tokens = parseResult(result)['tokens'];
|
|
78
|
+
return Array.isArray(tokens) ? tokens : [];
|
|
79
|
+
}
|
|
80
|
+
/** Every minted token id in the batch result (authoritative for invalidation). */
|
|
81
|
+
function batchTokenIds(result) {
|
|
82
|
+
const ids = [];
|
|
83
|
+
for (const entry of batchEntries(result)) {
|
|
84
|
+
if (typeof entry['token_id'] === 'string')
|
|
85
|
+
ids.push(entry['token_id']);
|
|
86
|
+
}
|
|
87
|
+
return ids;
|
|
88
|
+
}
|
|
89
|
+
/** The `{ token_id, email_id }` pairs the batch confirm expects. */
|
|
90
|
+
function batchPairs(result) {
|
|
91
|
+
const pairs = [];
|
|
92
|
+
for (const entry of batchEntries(result)) {
|
|
93
|
+
const tokenId = entry['token_id'];
|
|
94
|
+
const email = entry['email'];
|
|
95
|
+
const emailId = email?.['id'] ?? entry['email_id'];
|
|
96
|
+
if (typeof tokenId === 'string' && typeof emailId === 'string') {
|
|
97
|
+
pairs.push({ token_id: tokenId, email_id: emailId });
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return pairs;
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=elicit-links.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"elicit-links.js","sourceRoot":"","sources":["../../src/registry/elicit-links.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAiBH,mFAAmF;AACnF,SAAS,WAAW,CAAC,MAAkB;IACrC,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC;IACrC,IAAI,IAAI,IAAI,IAAI;QAAE,OAAO,EAAE,CAAC;IAC5B,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAA4B,CAAC;IACrD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC;AAED,mFAAmF;AACnF,SAAS,WAAW,CAAC,MAAkB;IACrC,MAAM,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;IACnC,MAAM,KAAK,GAAG,MAAM,CAAC,gBAAgB,CAAC,IAAI,MAAM,CAAC,UAAU,CAAC,CAAC;IAC7D,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;AACtE,CAAC;AAED,SAAS,cAAc,CAAC,MAAkB;IACxC,MAAM,KAAK,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;IAClC,OAAO,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;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Licensed under the MIT License. See LICENSE file in the project root.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Inline confirmation via MCP elicitation (U11).
|
|
7
|
+
*
|
|
8
|
+
* Bridges the MCP `Server.elicitInput` request to the registry's backend-neutral
|
|
9
|
+
* {@link Elicitor} contract. Capability-gated and fail-open-to-degrade: if the
|
|
10
|
+
* client can't elicit, or the request times out or errors, the caller falls back
|
|
11
|
+
* to the durable two-phase token flow — an inline confirmation never blocks or
|
|
12
|
+
* fails a tool call.
|
|
13
|
+
*/
|
|
14
|
+
import type { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
15
|
+
import type { Elicitor } from './types.js';
|
|
16
|
+
/** How long to wait for the user's inline yes/no before degrading (U11). */
|
|
17
|
+
export declare const ELICIT_TIMEOUT_MS = 60000;
|
|
18
|
+
/**
|
|
19
|
+
* Builds an {@link Elicitor} bound to a live MCP server. Returns 'degrade' —
|
|
20
|
+
* never throws — when the client lacks the capability, cancels, or times out, so
|
|
21
|
+
* the dispatch interceptor can hand back the durable token unchanged.
|
|
22
|
+
*/
|
|
23
|
+
export declare function createServerElicitor(server: Server): Elicitor;
|
|
24
|
+
//# sourceMappingURL=elicitor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"elicitor.d.ts","sourceRoot":"","sources":["../../src/registry/elicitor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACxE,OAAO,KAAK,EAAE,QAAQ,EAAiB,MAAM,YAAY,CAAC;AAE1D,4EAA4E;AAC5E,eAAO,MAAM,iBAAiB,QAAS,CAAC;AAmBxC;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,QAAQ,CAwB7D"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 JBC Tech Solutions, LLC
|
|
3
|
+
* Licensed under the MIT License. See LICENSE file in the project root.
|
|
4
|
+
*/
|
|
5
|
+
/** How long to wait for the user's inline yes/no before degrading (U11). */
|
|
6
|
+
export const ELICIT_TIMEOUT_MS = 60_000;
|
|
7
|
+
/**
|
|
8
|
+
* A minimal confirmation form. We key the decision off the elicitation `action`
|
|
9
|
+
* ('accept' = yes), so the schema is a formality some clients render; a single
|
|
10
|
+
* optional boolean keeps it valid and unobtrusive.
|
|
11
|
+
*/
|
|
12
|
+
const CONFIRM_SCHEMA = {
|
|
13
|
+
type: 'object',
|
|
14
|
+
properties: {
|
|
15
|
+
confirm: {
|
|
16
|
+
type: 'boolean',
|
|
17
|
+
title: 'Confirm',
|
|
18
|
+
description: 'Approve this destructive action.',
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
required: [],
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Builds an {@link Elicitor} bound to a live MCP server. Returns 'degrade' —
|
|
25
|
+
* never throws — when the client lacks the capability, cancels, or times out, so
|
|
26
|
+
* the dispatch interceptor can hand back the durable token unchanged.
|
|
27
|
+
*/
|
|
28
|
+
export function createServerElicitor(server) {
|
|
29
|
+
return async ({ message }) => {
|
|
30
|
+
if (server.getClientCapabilities()?.elicitation == null) {
|
|
31
|
+
return 'degrade';
|
|
32
|
+
}
|
|
33
|
+
try {
|
|
34
|
+
const result = await server.elicitInput({ message, requestedSchema: CONFIRM_SCHEMA }, { timeout: ELICIT_TIMEOUT_MS });
|
|
35
|
+
switch (result.action) {
|
|
36
|
+
case 'accept':
|
|
37
|
+
return 'accept';
|
|
38
|
+
case 'decline':
|
|
39
|
+
return 'decline';
|
|
40
|
+
default:
|
|
41
|
+
// 'cancel' — the user dismissed without deciding; leave the token.
|
|
42
|
+
return 'degrade';
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
// Timeout or transport error → degrade (fail-open to the token flow).
|
|
47
|
+
return 'degrade';
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=elicitor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"elicitor.js","sourceRoot":"","sources":["../../src/registry/elicitor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAeH,4EAA4E;AAC5E,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC;AAExC;;;;GAIG;AACH,MAAM,cAAc,GAAG;IACrB,IAAI,EAAE,QAAiB;IACvB,UAAU,EAAE;QACV,OAAO,EAAE;YACP,IAAI,EAAE,SAAkB;YACxB,KAAK,EAAE,SAAS;YAChB,WAAW,EAAE,kCAAkC;SAChD;KACF;IACD,QAAQ,EAAE,EAAc;CACzB,CAAC;AAEF;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAc;IACjD,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,EAA0B,EAAE;QACnD,IAAI,MAAM,CAAC,qBAAqB,EAAE,EAAE,WAAW,IAAI,IAAI,EAAE,CAAC;YACxD,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,WAAW,CACrC,EAAE,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,EAC5C,EAAE,OAAO,EAAE,iBAAiB,EAAE,CAC/B,CAAC;YACF,QAAQ,MAAM,CAAC,MAAM,EAAE,CAAC;gBACtB,KAAK,QAAQ;oBACX,OAAO,QAAQ,CAAC;gBAClB,KAAK,SAAS;oBACZ,OAAO,SAAS,CAAC;gBACnB;oBACE,mEAAmE;oBACnE,OAAO,SAAS,CAAC;YACrB,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,sEAAsE;YACtE,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/registry/index.d.ts
CHANGED
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* Tool registry barrel.
|
|
7
7
|
*/
|
|
8
|
-
export type { Backend, Preset, ToolAnnotations, ToolResult, ToolContext, ToolDefinition, GraphToolsets,
|
|
8
|
+
export type { Backend, Preset, ToolAnnotations, ToolResult, ToolContext, ToolDefinition, GraphToolsets, ConfirmMode, ElicitOutcome, ElicitRequest, Elicitor, ElicitLink, } from './types.js';
|
|
9
9
|
export { ToolRegistry, toInputSchema } from './registry.js';
|
|
10
10
|
export type { SurfaceOptions } from './registry.js';
|
|
11
11
|
export { defineTool } from './define-tool.js';
|
|
12
|
-
export { requireGraphToolset
|
|
12
|
+
export { requireGraphToolset } from './context.js';
|
|
13
13
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/registry/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AAEH,YAAY,EACV,OAAO,EACP,MAAM,EACN,eAAe,EACf,UAAU,EACV,WAAW,EACX,cAAc,EACd,aAAa,EACb,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/registry/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AAEH,YAAY,EACV,OAAO,EACP,MAAM,EACN,eAAe,EACf,UAAU,EACV,WAAW,EACX,cAAc,EACd,aAAa,EACb,WAAW,EACX,aAAa,EACb,aAAa,EACb,QAAQ,EACR,UAAU,GACX,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC5D,YAAY,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/registry/index.js
CHANGED
|
@@ -4,5 +4,5 @@
|
|
|
4
4
|
*/
|
|
5
5
|
export { ToolRegistry, toInputSchema } from './registry.js';
|
|
6
6
|
export { defineTool } from './define-tool.js';
|
|
7
|
-
export { requireGraphToolset
|
|
7
|
+
export { requireGraphToolset } from './context.js';
|
|
8
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/registry/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/registry/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAoBH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE5D,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -56,6 +56,17 @@ export declare class ToolRegistry {
|
|
|
56
56
|
* can fall back to the legacy dispatch during the U2 migration window.
|
|
57
57
|
*/
|
|
58
58
|
dispatch(name: string, args: unknown, ctx: ToolContext, options: SurfaceOptions): Promise<ToolResult | undefined>;
|
|
59
|
+
/**
|
|
60
|
+
* Runs a prepare tool, asks the user inline, and resolves the outcome (U11):
|
|
61
|
+
* - accept → execute now via the linked confirm tool (its exact validation +
|
|
62
|
+
* execution is reused; the just-minted token is consumed there).
|
|
63
|
+
* - decline → invalidate the token (consume-without-execute) and report abort.
|
|
64
|
+
* - degrade → return the prepare token response unchanged (cancel / timeout /
|
|
65
|
+
* no capability / unparseable token) — the normal two-phase flow.
|
|
66
|
+
*
|
|
67
|
+
* Fail-closed: the destructive action runs only on an explicit accept.
|
|
68
|
+
*/
|
|
69
|
+
private dispatchWithElicitation;
|
|
59
70
|
private filtered;
|
|
60
71
|
private matches;
|
|
61
72
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/registry/registry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;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cAAc,GAAG,IAAI,EAAE;IAc1C,2DAA2D;IAC3D,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO;IAKzD;;;;OAIG;IACG,QAAQ,CACZ,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,OAAO,EACb,GAAG,EAAE,WAAW,EAChB,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC;IA6BlC;;;;;;;;;OASG;YACW,uBAAuB;IAkDrC,OAAO,CAAC,QAAQ;IAIhB,OAAO,CAAC,OAAO;CAahB"}
|
|
@@ -104,8 +104,64 @@ export class ToolRegistry {
|
|
|
104
104
|
// (e.g. list_mail_rules) parse cleanly, matching the codebase-wide
|
|
105
105
|
// `parse(args ?? {})` convention.
|
|
106
106
|
const params = def.input.parse(args ?? {});
|
|
107
|
+
// Inline-elicitation interceptor (U11): only for a prepare tool that opted in
|
|
108
|
+
// (onElicit), when the server is in elicit mode and the client can elicit.
|
|
109
|
+
// Everything else runs the handler directly — an unchanged fast path.
|
|
110
|
+
if (def.onElicit != null && ctx.confirmMode === 'elicit' && ctx.elicit != null) {
|
|
111
|
+
return this.dispatchWithElicitation(def, params, ctx, def.onElicit, ctx.elicit);
|
|
112
|
+
}
|
|
107
113
|
return def.handler(ctx, params);
|
|
108
114
|
}
|
|
115
|
+
/**
|
|
116
|
+
* Runs a prepare tool, asks the user inline, and resolves the outcome (U11):
|
|
117
|
+
* - accept → execute now via the linked confirm tool (its exact validation +
|
|
118
|
+
* execution is reused; the just-minted token is consumed there).
|
|
119
|
+
* - decline → invalidate the token (consume-without-execute) and report abort.
|
|
120
|
+
* - degrade → return the prepare token response unchanged (cancel / timeout /
|
|
121
|
+
* no capability / unparseable token) — the normal two-phase flow.
|
|
122
|
+
*
|
|
123
|
+
* Fail-closed: the destructive action runs only on an explicit accept.
|
|
124
|
+
*/
|
|
125
|
+
async dispatchWithElicitation(def, prepareParams, ctx, link, elicit) {
|
|
126
|
+
const prepareResult = await def.handler(ctx, prepareParams);
|
|
127
|
+
const tokenIds = link.collectTokenIds(prepareResult);
|
|
128
|
+
// No token in the prepare output → nothing to gate/execute; degrade.
|
|
129
|
+
if (tokenIds.length === 0) {
|
|
130
|
+
return prepareResult;
|
|
131
|
+
}
|
|
132
|
+
const message = link.message?.(prepareParams) ?? defaultConfirmMessage(ctx, tokenIds[0]);
|
|
133
|
+
const outcome = await elicit({ message });
|
|
134
|
+
if (outcome === 'accept') {
|
|
135
|
+
const confirmDef = this.definitions.get(link.confirmTool);
|
|
136
|
+
// A misconfigured link must not silently execute nor lose the approval —
|
|
137
|
+
// degrade to the token response so the two-phase path still works.
|
|
138
|
+
if (confirmDef == null) {
|
|
139
|
+
return prepareResult;
|
|
140
|
+
}
|
|
141
|
+
// Only the param mapping/validation is guarded: a bad buildParams must
|
|
142
|
+
// degrade (return the still-live token) rather than error out an accepted
|
|
143
|
+
// action. The confirm handler runs OUTSIDE the guard so a genuine
|
|
144
|
+
// execution error (e.g. a Graph failure) surfaces normally, not masked.
|
|
145
|
+
let confirmParams;
|
|
146
|
+
try {
|
|
147
|
+
confirmParams = confirmDef.input.parse(link.buildParams(prepareParams, prepareResult));
|
|
148
|
+
}
|
|
149
|
+
catch {
|
|
150
|
+
return prepareResult;
|
|
151
|
+
}
|
|
152
|
+
return confirmDef.handler(ctx, confirmParams);
|
|
153
|
+
}
|
|
154
|
+
if (outcome === 'decline') {
|
|
155
|
+
// Burn every token this prepare minted (batch mints one per item), so a
|
|
156
|
+
// declined action can't be redeemed via the confirm flow afterward.
|
|
157
|
+
for (const tokenId of tokenIds) {
|
|
158
|
+
invalidateToken(ctx, tokenId);
|
|
159
|
+
}
|
|
160
|
+
return declinedResult(def.name);
|
|
161
|
+
}
|
|
162
|
+
// 'degrade' — hand back the durable token exactly as the token flow would.
|
|
163
|
+
return prepareResult;
|
|
164
|
+
}
|
|
109
165
|
filtered(options) {
|
|
110
166
|
return [...this.definitions.values()].filter((def) => this.matches(def, options));
|
|
111
167
|
}
|
|
@@ -131,4 +187,35 @@ export class ToolRegistry {
|
|
|
131
187
|
function isReadOnly(def) {
|
|
132
188
|
return def.annotations.readOnlyHint === true;
|
|
133
189
|
}
|
|
190
|
+
/**
|
|
191
|
+
* Burns a token without executing its action, so a declined destructive request
|
|
192
|
+
* can't be redeemed via the confirm flow afterward. Uses the token's own
|
|
193
|
+
* operation/targetId (it was just minted, so this always validates), reusing the
|
|
194
|
+
* store's atomic single-use consume — no new persistence machinery.
|
|
195
|
+
*/
|
|
196
|
+
function invalidateToken(ctx, tokenId) {
|
|
197
|
+
const token = ctx.tokenManager.lookupToken(tokenId);
|
|
198
|
+
if (token != null) {
|
|
199
|
+
ctx.tokenManager.consumeToken(tokenId, token.operation, token.targetId);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
/** A generic confirmation prompt derived from the token's operation. */
|
|
203
|
+
function defaultConfirmMessage(ctx, tokenId) {
|
|
204
|
+
const op = tokenId != null ? ctx.tokenManager.lookupToken(tokenId)?.operation : undefined;
|
|
205
|
+
const action = op != null ? op.replace(/_/g, ' ') : 'this action';
|
|
206
|
+
return `Confirm: ${action}? This cannot be undone.`;
|
|
207
|
+
}
|
|
208
|
+
/** The result returned when a user declines an inline confirmation. */
|
|
209
|
+
function declinedResult(toolName) {
|
|
210
|
+
return {
|
|
211
|
+
content: [{
|
|
212
|
+
type: 'text',
|
|
213
|
+
text: JSON.stringify({
|
|
214
|
+
success: false,
|
|
215
|
+
declined: true,
|
|
216
|
+
message: `Action cancelled: you declined the confirmation for ${toolName}. The approval token has been invalidated.`,
|
|
217
|
+
}, null, 2),
|
|
218
|
+
}],
|
|
219
|
+
};
|
|
220
|
+
}
|
|
134
221
|
//# sourceMappingURL=registry.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/registry/registry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;GAMG;AAEH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CAAC,YAAY,CAAC,YAAY,CAAC,OAAO,EAAE,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC1E,CAAC;AACH,CAAC;AAED,wEAAwE;AACxE,SAAS,qBAAqB,CAAC,GAAgB,EAAE,OAA2B;IAC1E,MAAM,EAAE,GAAG,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,YAAY,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC;IAC1F,MAAM,MAAM,GAAG,EAAE,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC;IAClE,OAAO,YAAY,MAAM,0BAA0B,CAAC;AACtD,CAAC;AAED,uEAAuE;AACvE,SAAS,cAAc,CAAC,QAAgB;IACtC,OAAO;QACL,OAAO,EAAE,CAAC;gBACR,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;oBACnB,OAAO,EAAE,KAAK;oBACd,QAAQ,EAAE,IAAI;oBACd,OAAO,EAAE,uDAAuD,QAAQ,4CAA4C;iBACrH,EAAE,IAAI,EAAE,CAAC,CAAC;aACZ,CAAC;KACH,CAAC;AACJ,CAAC"}
|
package/dist/registry/types.d.ts
CHANGED
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
*/
|
|
15
15
|
import type { z } from 'zod';
|
|
16
16
|
import type { ApprovalTokenManager } from '../approval/index.js';
|
|
17
|
-
/** Which backend(s) expose a tool. */
|
|
18
|
-
export type Backend = 'graph'
|
|
17
|
+
/** Which backend(s) expose a tool. Graph is the only backend (AppleScript was removed). */
|
|
18
|
+
export type Backend = 'graph';
|
|
19
19
|
/** Preset groups a client can select with --preset to shrink the surface. */
|
|
20
|
-
export type Preset = 'mail' | 'calendar' | 'contacts' | 'tasks' | 'notes' | 'teams' | 'planner' | 'files' | 'sharepoint' | 'excel' | 'people' | 'meetings';
|
|
20
|
+
export type Preset = 'mail' | 'calendar' | 'contacts' | 'tasks' | 'notes' | 'teams' | 'planner' | 'files' | 'sharepoint' | 'excel' | 'people' | 'meetings' | 'shared';
|
|
21
21
|
/**
|
|
22
22
|
* MCP tool annotations (spec 2025-03-26+). Clients use these to auto-approve
|
|
23
23
|
* safe reads and gate destructive calls.
|
|
@@ -48,16 +48,23 @@ export interface ToolResult {
|
|
|
48
48
|
*/
|
|
49
49
|
export interface GraphToolsets {
|
|
50
50
|
}
|
|
51
|
-
/**
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
51
|
+
/** How a destructive `prepare_*` step seeks confirmation (U11). */
|
|
52
|
+
export type ConfirmMode = 'token' | 'elicit';
|
|
53
|
+
/** Outcome of an inline elicitation (U11). */
|
|
54
|
+
export type ElicitOutcome =
|
|
55
|
+
/** The user explicitly confirmed — execute now. */
|
|
56
|
+
'accept'
|
|
57
|
+
/** The user explicitly said no — abort AND invalidate the token. */
|
|
58
|
+
| 'decline'
|
|
59
|
+
/** Cancelled, timed out, or the client can't elicit — fall back to the token flow. */
|
|
60
|
+
| 'degrade';
|
|
61
|
+
/** A yes/no confirmation request sent to the client (U11). */
|
|
62
|
+
export interface ElicitRequest {
|
|
63
|
+
/** Human-readable description of the action being confirmed. */
|
|
64
|
+
readonly message: string;
|
|
60
65
|
}
|
|
66
|
+
/** Sends an inline confirmation to the client, resolving to its outcome (U11). */
|
|
67
|
+
export type Elicitor = (request: ElicitRequest) => Promise<ElicitOutcome>;
|
|
61
68
|
/**
|
|
62
69
|
* Runtime context passed to a tool handler. Built once per call after the
|
|
63
70
|
* backend is initialized; carries the live toolset instances so handlers no
|
|
@@ -67,7 +74,37 @@ export interface ToolContext {
|
|
|
67
74
|
readonly backend: Backend;
|
|
68
75
|
readonly tokenManager: ApprovalTokenManager;
|
|
69
76
|
readonly graph: GraphToolsets | null;
|
|
70
|
-
|
|
77
|
+
/** Confirmation mode for destructive prepares (default 'token' when absent). */
|
|
78
|
+
readonly confirmMode?: ConfirmMode;
|
|
79
|
+
/** Inline elicitor, present only when the client advertised the capability. */
|
|
80
|
+
readonly elicit?: Elicitor;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Links a `prepare_*` tool to its `confirm_*` counterpart so the dispatch-level
|
|
84
|
+
* elicitation interceptor (U11) can execute inline on an accepted confirmation.
|
|
85
|
+
* Declarative on purpose: no handler body changes, and the confirm tool's exact
|
|
86
|
+
* validation + execution is reused.
|
|
87
|
+
*
|
|
88
|
+
* @typeParam S - the prepare tool's Zod input schema.
|
|
89
|
+
*/
|
|
90
|
+
export interface ElicitLink<S extends z.ZodType = z.ZodType> {
|
|
91
|
+
/** Name of the paired confirm tool (e.g. 'confirm_delete_channel'). */
|
|
92
|
+
readonly confirmTool: string;
|
|
93
|
+
/**
|
|
94
|
+
* Builds the confirm tool's params from the prepare params + the prepare
|
|
95
|
+
* result (which carries the freshly minted token(s)). Handles heterogeneous
|
|
96
|
+
* confirm shapes: plain `approval_token`, `token_id` + target id, and the
|
|
97
|
+
* batch confirm that takes an array of `{ token_id, email_id }` pairs.
|
|
98
|
+
*/
|
|
99
|
+
readonly buildParams: (prepareParams: z.infer<S>, prepareResult: ToolResult) => unknown;
|
|
100
|
+
/**
|
|
101
|
+
* Token ids minted by this prepare, so a declined action can invalidate them.
|
|
102
|
+
* Empty means "no token in the result" — dispatch then degrades without
|
|
103
|
+
* eliciting.
|
|
104
|
+
*/
|
|
105
|
+
readonly collectTokenIds: (prepareResult: ToolResult) => string[];
|
|
106
|
+
/** Optional custom confirmation prompt; a generic one is derived when absent. */
|
|
107
|
+
readonly message?: (prepareParams: z.infer<S>) => string;
|
|
71
108
|
}
|
|
72
109
|
/**
|
|
73
110
|
* A single tool definition — static metadata plus a lazily-bound handler.
|
|
@@ -94,5 +131,16 @@ export interface ToolDefinition<S extends z.ZodType = z.ZodType> {
|
|
|
94
131
|
readonly backends: readonly Backend[];
|
|
95
132
|
/** Handler invoked with the runtime context and validated params. */
|
|
96
133
|
readonly handler: (ctx: ToolContext, params: z.infer<S>) => Promise<ToolResult> | ToolResult;
|
|
134
|
+
/**
|
|
135
|
+
* Present on `prepare_*` tools to opt into inline elicitation (U11). When the
|
|
136
|
+
* server runs with `--confirm elicit` and the client can elicit, dispatch
|
|
137
|
+
* runs the prepare, asks the user inline, and on accept executes the linked
|
|
138
|
+
* confirm tool — otherwise it degrades to the normal token response.
|
|
139
|
+
*
|
|
140
|
+
* `NoInfer` keeps this field out of `S` inference so the generic is fixed by
|
|
141
|
+
* `input` alone — otherwise a helper returning the default `ElicitLink` would
|
|
142
|
+
* widen `S` and collapse the handler's `params` to `unknown`.
|
|
143
|
+
*/
|
|
144
|
+
readonly onElicit?: ElicitLink<NoInfer<S>>;
|
|
97
145
|
}
|
|
98
146
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/registry/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAEjE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/registry/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAEjE,2FAA2F;AAC3F,MAAM,MAAM,OAAO,GAAG,OAAO,CAAC;AAE9B,6EAA6E;AAC7E,MAAM,MAAM,MAAM,GACd,MAAM,GACN,UAAU,GACV,UAAU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AAQ,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC;IAC7F;;;;;;;;;OASG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;CAC5C"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 JBC Tech Solutions, LLC
|
|
3
|
+
* Licensed under the MIT License. See LICENSE file in the project root.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Delta-sync mirror storage (U12). Persists, per account + resource:
|
|
7
|
+
* - a Graph `@odata.deltaLink` cursor (`delta_links`), and
|
|
8
|
+
* - a light snapshot of every item seen so far (`delta_items`).
|
|
9
|
+
*
|
|
10
|
+
* The item mirror is what lets a subsequent delta round classify a returned
|
|
11
|
+
* entry as *added* vs *updated*: Graph delta returns both as a plain `value`
|
|
12
|
+
* entry, distinguishable only by whether we have seen the id before. Deletes
|
|
13
|
+
* arrive as `@removed` entries and drop the mirror row.
|
|
14
|
+
*
|
|
15
|
+
* This is the storage layer only; the sync orchestration and change
|
|
16
|
+
* classification live in {@link ../delta/mirror.ts}. It is a thin companion to
|
|
17
|
+
* {@link StateStore} (sharing its single better-sqlite3 connection), kept in its
|
|
18
|
+
* own module so the mirror's SQL does not bloat the core store.
|
|
19
|
+
*/
|
|
20
|
+
import type Database from 'better-sqlite3';
|
|
21
|
+
type DB = Database.Database;
|
|
22
|
+
/** A mirrored item's stored snapshot. */
|
|
23
|
+
export interface MirrorItem {
|
|
24
|
+
graphId: string;
|
|
25
|
+
/** Durable self-encoding token (e.g. `em_`, `ev_`) for the item. */
|
|
26
|
+
token: string;
|
|
27
|
+
/** Short human label (subject / title); never null (defaults to ''). */
|
|
28
|
+
summary: string;
|
|
29
|
+
/** Optional JSON blob of light display fields. */
|
|
30
|
+
snapshot?: string | null;
|
|
31
|
+
}
|
|
32
|
+
/** A committed sync round for one resource. */
|
|
33
|
+
export interface DeltaCommit {
|
|
34
|
+
accountId: string;
|
|
35
|
+
resource: string;
|
|
36
|
+
/** New cursor to persist; when empty the cursor row is cleared (re-baseline). */
|
|
37
|
+
deltaLink: string;
|
|
38
|
+
syncedAt: number;
|
|
39
|
+
/** Items to insert or refresh in the mirror. */
|
|
40
|
+
upserts: readonly MirrorItem[];
|
|
41
|
+
/** Graph ids to drop from the mirror. */
|
|
42
|
+
deletes: readonly string[];
|
|
43
|
+
/**
|
|
44
|
+
* When true, the fetch was a full baseline: the mirror is replaced by
|
|
45
|
+
* `upserts` (existing rows for the resource are wiped first) so it exactly
|
|
46
|
+
* reflects current state and no stale rows survive. `deletes` is ignored.
|
|
47
|
+
*/
|
|
48
|
+
replaceMirror?: boolean;
|
|
49
|
+
}
|
|
50
|
+
/** A stored delta cursor with its last-sync timestamp. */
|
|
51
|
+
export interface DeltaCursor {
|
|
52
|
+
deltaLink: string;
|
|
53
|
+
syncedAt: number;
|
|
54
|
+
}
|
|
55
|
+
export declare class DeltaStore {
|
|
56
|
+
private readonly db;
|
|
57
|
+
private readonly now;
|
|
58
|
+
constructor(db: DB, now: () => number);
|
|
59
|
+
/** Returns the stored delta cursor for a resource, or null when un-synced. */
|
|
60
|
+
getDeltaLink(accountId: string, resource: string): string | null;
|
|
61
|
+
/** Returns the cursor plus its last-sync time (for age-based re-baseline), or null. */
|
|
62
|
+
getCursor(accountId: string, resource: string): DeltaCursor | null;
|
|
63
|
+
/** Returns the set of graph ids already mirrored for a resource. */
|
|
64
|
+
getSeenIds(accountId: string, resource: string): Set<string>;
|
|
65
|
+
/** Looks up a single mirrored item (for labelling a delete), or null. */
|
|
66
|
+
getItem(accountId: string, resource: string, graphId: string): MirrorItem | null;
|
|
67
|
+
/** Number of items mirrored for a resource (baseline / status reporting). */
|
|
68
|
+
countItems(accountId: string, resource: string): number;
|
|
69
|
+
/**
|
|
70
|
+
* Applies a completed sync round atomically: refresh the cursor and apply all
|
|
71
|
+
* upserts/deletes in one transaction, so a crash mid-write never leaves the
|
|
72
|
+
* mirror ahead of (or behind) its cursor. An empty `deltaLink` clears the
|
|
73
|
+
* cursor row, forcing the next call to re-baseline (used when Graph returns no
|
|
74
|
+
* usable deltaLink).
|
|
75
|
+
*/
|
|
76
|
+
commit(commit: DeltaCommit): void;
|
|
77
|
+
/**
|
|
78
|
+
* Clears the cursor and mirror for a resource (or every resource for the
|
|
79
|
+
* account when `resource` is omitted), forcing a fresh baseline on the next
|
|
80
|
+
* sync. Local-only; never touches the user's Graph data.
|
|
81
|
+
*/
|
|
82
|
+
reset(accountId: string, resource?: string): void;
|
|
83
|
+
}
|
|
84
|
+
export {};
|
|
85
|
+
//# sourceMappingURL=delta-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delta-store.d.ts","sourceRoot":"","sources":["../../src/state/delta-store.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAE3C,KAAK,EAAE,GAAG,QAAQ,CAAC,QAAQ,CAAC;AAE5B,yCAAyC;AACzC,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,oEAAoE;IACpE,KAAK,EAAE,MAAM,CAAC;IACd,wEAAwE;IACxE,OAAO,EAAE,MAAM,CAAC;IAChB,kDAAkD;IAClD,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED,+CAA+C;AAC/C,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,iFAAiF;IACjF,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,gDAAgD;IAChD,OAAO,EAAE,SAAS,UAAU,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