@jbctechsolutions/mcp-office365 2.5.1 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +66 -57
- package/dist/approval/hash.d.ts +8 -8
- package/dist/approval/token-manager.d.ts +37 -19
- package/dist/approval/token-manager.d.ts.map +1 -1
- package/dist/approval/token-manager.js +133 -37
- 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 +21 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +100 -2
- 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 +13 -1
- package/dist/graph/auth/config.js.map +1 -1
- package/dist/graph/auth/device-code-flow.d.ts +3 -1
- package/dist/graph/auth/device-code-flow.d.ts.map +1 -1
- package/dist/graph/auth/device-code-flow.js +42 -14
- package/dist/graph/auth/device-code-flow.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/auth/token-cache.js +2 -2
- package/dist/graph/auth/token-cache.js.map +1 -1
- package/dist/graph/client/graph-client.d.ts +141 -8
- package/dist/graph/client/graph-client.d.ts.map +1 -1
- package/dist/graph/client/graph-client.js +536 -48
- 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 +409 -276
- package/dist/graph/repository.d.ts.map +1 -1
- package/dist/graph/repository.js +772 -1082
- package/dist/graph/repository.js.map +1 -1
- package/dist/ids/mint.d.ts +31 -0
- package/dist/ids/mint.d.ts.map +1 -0
- package/dist/ids/mint.js +36 -0
- package/dist/ids/mint.js.map +1 -0
- 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 +31 -0
- package/dist/ids/resolver.d.ts.map +1 -0
- package/dist/ids/resolver.js +52 -0
- package/dist/ids/resolver.js.map +1 -0
- 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 +62 -0
- package/dist/ids/token.d.ts.map +1 -0
- package/dist/ids/token.js +225 -0
- package/dist/ids/token.js.map +1 -0
- package/dist/index.d.ts +10 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +255 -5925
- 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 +14 -0
- package/dist/registry/all-tools.d.ts.map +1 -0
- package/dist/registry/all-tools.js +68 -0
- package/dist/registry/all-tools.js.map +1 -0
- package/dist/registry/context.d.ts +19 -0
- package/dist/registry/context.d.ts.map +1 -0
- package/dist/registry/context.js +20 -0
- package/dist/registry/context.js.map +1 -0
- package/dist/registry/define-tool.d.ts +15 -0
- package/dist/registry/define-tool.d.ts.map +1 -0
- package/dist/registry/define-tool.js +8 -0
- package/dist/registry/define-tool.js.map +1 -0
- 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 +13 -0
- package/dist/registry/index.d.ts.map +1 -0
- package/dist/registry/index.js +8 -0
- package/dist/registry/index.js.map +1 -0
- package/dist/registry/registry.d.ts +73 -0
- package/dist/registry/registry.d.ts.map +1 -0
- package/dist/registry/registry.js +221 -0
- package/dist/registry/registry.js.map +1 -0
- package/dist/registry/types.d.ts +146 -0
- package/dist/registry/types.d.ts.map +1 -0
- package/dist/registry/types.js +6 -0
- package/dist/registry/types.js.map +1 -0
- package/dist/search/compiler.d.ts +49 -0
- package/dist/search/compiler.d.ts.map +1 -0
- package/dist/search/compiler.js +168 -0
- package/dist/search/compiler.js.map +1 -0
- package/dist/signature.js +2 -2
- package/dist/signature.js.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/migrate.d.ts +23 -0
- package/dist/state/migrate.d.ts.map +1 -0
- package/dist/state/migrate.js +81 -0
- package/dist/state/migrate.js.map +1 -0
- package/dist/state/schema.d.ts +26 -0
- package/dist/state/schema.d.ts.map +1 -0
- package/dist/state/schema.js +77 -0
- package/dist/state/schema.js.map +1 -0
- package/dist/state/store.d.ts +155 -0
- package/dist/state/store.d.ts.map +1 -0
- package/dist/state/store.js +321 -0
- package/dist/state/store.js.map +1 -0
- package/dist/tools/calendar-graph.d.ts +41 -0
- package/dist/tools/calendar-graph.d.ts.map +1 -0
- package/dist/tools/calendar-graph.js +299 -0
- package/dist/tools/calendar-graph.js.map +1 -0
- package/dist/tools/calendar-permissions.d.ts +17 -7
- package/dist/tools/calendar-permissions.d.ts.map +1 -1
- package/dist/tools/calendar-permissions.js +60 -4
- package/dist/tools/calendar-permissions.js.map +1 -1
- package/dist/tools/calendar.d.ts +133 -82
- package/dist/tools/calendar.d.ts.map +1 -1
- package/dist/tools/calendar.js +249 -136
- package/dist/tools/calendar.js.map +1 -1
- package/dist/tools/categories.d.ts +14 -4
- package/dist/tools/categories.d.ts.map +1 -1
- package/dist/tools/categories.js +59 -2
- package/dist/tools/categories.js.map +1 -1
- package/dist/tools/checklist-items.d.ts +19 -9
- package/dist/tools/checklist-items.d.ts.map +1 -1
- package/dist/tools/checklist-items.js +71 -5
- package/dist/tools/checklist-items.js.map +1 -1
- package/dist/tools/contact-folders.d.ts +50 -0
- package/dist/tools/contact-folders.d.ts.map +1 -0
- package/dist/tools/contact-folders.js +136 -0
- package/dist/tools/contact-folders.js.map +1 -0
- package/dist/tools/contacts-graph.d.ts +45 -0
- package/dist/tools/contacts-graph.d.ts.map +1 -0
- package/dist/tools/contacts-graph.js +174 -0
- package/dist/tools/contacts-graph.js.map +1 -0
- package/dist/tools/contacts.d.ts +61 -30
- package/dist/tools/contacts.d.ts.map +1 -1
- package/dist/tools/contacts.js +150 -93
- package/dist/tools/contacts.js.map +1 -1
- package/dist/tools/excel.d.ts +20 -10
- package/dist/tools/excel.d.ts.map +1 -1
- package/dist/tools/excel.js +82 -6
- package/dist/tools/excel.js.map +1 -1
- package/dist/tools/focused-overrides.d.ts +14 -4
- package/dist/tools/focused-overrides.d.ts.map +1 -1
- package/dist/tools/focused-overrides.js +59 -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 +17 -7
- package/dist/tools/linked-resources.d.ts.map +1 -1
- package/dist/tools/linked-resources.js +60 -4
- package/dist/tools/linked-resources.js.map +1 -1
- package/dist/tools/mail-graph.d.ts +38 -0
- package/dist/tools/mail-graph.d.ts.map +1 -0
- package/dist/tools/mail-graph.js +187 -0
- package/dist/tools/mail-graph.js.map +1 -0
- package/dist/tools/mail-rules.d.ts +20 -8
- package/dist/tools/mail-rules.d.ts.map +1 -1
- package/dist/tools/mail-rules.js +63 -7
- package/dist/tools/mail-rules.js.map +1 -1
- package/dist/tools/mail-send.d.ts +39 -27
- package/dist/tools/mail-send.d.ts.map +1 -1
- package/dist/tools/mail-send.js +249 -24
- package/dist/tools/mail-send.js.map +1 -1
- package/dist/tools/mail.d.ts +91 -68
- package/dist/tools/mail.d.ts.map +1 -1
- package/dist/tools/mail.js +232 -243
- package/dist/tools/mail.js.map +1 -1
- package/dist/tools/mailbox-organization.d.ts +51 -34
- package/dist/tools/mailbox-organization.d.ts.map +1 -1
- package/dist/tools/mailbox-organization.js +318 -35
- package/dist/tools/mailbox-organization.js.map +1 -1
- package/dist/tools/mailbox-settings.d.ts +59 -0
- package/dist/tools/mailbox-settings.d.ts.map +1 -0
- package/dist/tools/mailbox-settings.js +136 -0
- package/dist/tools/mailbox-settings.js.map +1 -0
- package/dist/tools/meetings.d.ts +24 -14
- package/dist/tools/meetings.d.ts.map +1 -1
- package/dist/tools/meetings.js +82 -6
- package/dist/tools/meetings.js.map +1 -1
- package/dist/tools/onedrive.d.ts +26 -16
- package/dist/tools/onedrive.d.ts.map +1 -1
- package/dist/tools/onedrive.js +140 -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/people.d.ts +10 -0
- package/dist/tools/people.d.ts.map +1 -1
- package/dist/tools/people.js +94 -0
- package/dist/tools/people.js.map +1 -1
- package/dist/tools/planner-visualization.d.ts +15 -5
- package/dist/tools/planner-visualization.d.ts.map +1 -1
- package/dist/tools/planner-visualization.js +58 -4
- package/dist/tools/planner-visualization.js.map +1 -1
- package/dist/tools/planner.d.ts +69 -39
- package/dist/tools/planner.d.ts.map +1 -1
- package/dist/tools/planner.js +231 -23
- package/dist/tools/planner.js.map +1 -1
- package/dist/tools/scheduling.d.ts +12 -0
- package/dist/tools/scheduling.d.ts.map +1 -1
- package/dist/tools/scheduling.js +38 -0
- package/dist/tools/scheduling.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 +24 -14
- package/dist/tools/sharepoint.d.ts.map +1 -1
- package/dist/tools/sharepoint.js +85 -9
- package/dist/tools/sharepoint.js.map +1 -1
- package/dist/tools/task-attachments.d.ts +17 -7
- package/dist/tools/task-attachments.d.ts.map +1 -1
- package/dist/tools/task-attachments.js +60 -4
- package/dist/tools/task-attachments.js.map +1 -1
- package/dist/tools/task-lists.d.ts +56 -0
- package/dist/tools/task-lists.d.ts.map +1 -0
- package/dist/tools/task-lists.js +155 -0
- package/dist/tools/task-lists.js.map +1 -0
- package/dist/tools/tasks-graph.d.ts +49 -0
- package/dist/tools/tasks-graph.d.ts.map +1 -0
- package/dist/tools/tasks-graph.js +193 -0
- package/dist/tools/tasks-graph.js.map +1 -0
- package/dist/tools/tasks.d.ts +121 -29
- package/dist/tools/tasks.d.ts.map +1 -1
- package/dist/tools/tasks.js +136 -84
- package/dist/tools/tasks.js.map +1 -1
- package/dist/tools/teams.d.ts +57 -46
- package/dist/tools/teams.d.ts.map +1 -1
- package/dist/tools/teams.js +288 -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 +110 -38
- package/dist/utils/errors.d.ts.map +1 -1
- package/dist/utils/errors.js +239 -56
- package/dist/utils/errors.js.map +1 -1
- package/dist/visualization/types.d.ts +4 -4
- package/package.json +2 -3
- 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/notes.d.ts +0 -74
- package/dist/tools/notes.d.ts.map +0 -1
- package/dist/tools/notes.js +0 -136
- package/dist/tools/notes.js.map +0 -1
|
@@ -0,0 +1,321 @@
|
|
|
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
|
+
* Durable state store (U4) — a better-sqlite3-backed store at
|
|
7
|
+
* `~/.mcp-office365/state.db` holding durable-ID aliases and two-phase approval
|
|
8
|
+
* tokens. Provides the concurrency (WAL + busy_timeout + atomic consume, D7),
|
|
9
|
+
* at-rest (0700/0600 permissions, D18), account-stamping (D7), and
|
|
10
|
+
* degradation (in-memory fallback, D15) semantics the rest of v3 builds on.
|
|
11
|
+
*
|
|
12
|
+
* This unit is the storage layer only; wiring into the ID resolver (U5) and the
|
|
13
|
+
* approval manager (U9) lands in those units.
|
|
14
|
+
*/
|
|
15
|
+
import Database from 'better-sqlite3';
|
|
16
|
+
import { chmodSync, existsSync, mkdirSync } from 'node:fs';
|
|
17
|
+
import { homedir } from 'node:os';
|
|
18
|
+
import { join } from 'node:path';
|
|
19
|
+
import { runMigrations, migrateLegacyTokens } from './migrate.js';
|
|
20
|
+
import { APPROVAL_RETENTION_MS } from './schema.js';
|
|
21
|
+
import { DeltaStore } from './delta-store.js';
|
|
22
|
+
const DEFAULT_DIR = join(homedir(), '.mcp-office365');
|
|
23
|
+
const LEGACY_DIR = join(homedir(), '.outlook-mcp');
|
|
24
|
+
const DB_FILENAME = 'state.db';
|
|
25
|
+
export class StateStore {
|
|
26
|
+
/** True when running from an in-memory fallback (durability degraded). */
|
|
27
|
+
degraded;
|
|
28
|
+
/** The db path, or ':memory:' when degraded. */
|
|
29
|
+
path;
|
|
30
|
+
/** Effective `journal_mode` pragma (e.g. 'wal'). */
|
|
31
|
+
journalMode;
|
|
32
|
+
/** Effective `busy_timeout` pragma in ms. */
|
|
33
|
+
busyTimeout;
|
|
34
|
+
/** Delta-sync mirror storage (U12), sharing this store's connection. */
|
|
35
|
+
delta;
|
|
36
|
+
db;
|
|
37
|
+
now;
|
|
38
|
+
constructor(db, path, degraded, now) {
|
|
39
|
+
this.db = db;
|
|
40
|
+
this.path = path;
|
|
41
|
+
this.degraded = degraded;
|
|
42
|
+
this.now = now;
|
|
43
|
+
this.journalMode = String(db.pragma('journal_mode', { simple: true }));
|
|
44
|
+
this.busyTimeout = Number(db.pragma('busy_timeout', { simple: true }));
|
|
45
|
+
this.delta = new DeltaStore(db, now);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Opens (creating if needed) the durable store. On any failure to use the
|
|
49
|
+
* on-disk db (corrupt/locked file, unwritable dir) it degrades to an in-memory
|
|
50
|
+
* store, emits a stderr warning, and reports `degraded = true` — the server
|
|
51
|
+
* stays usable, only durability is lost for the run.
|
|
52
|
+
*/
|
|
53
|
+
static open(options = {}) {
|
|
54
|
+
const dir = options.dir ?? DEFAULT_DIR;
|
|
55
|
+
const legacyDir = options.legacyDir ?? LEGACY_DIR;
|
|
56
|
+
const now = options.now ?? (() => Date.now());
|
|
57
|
+
const warn = options.warn ?? ((msg) => void process.stderr.write(`${msg}\n`));
|
|
58
|
+
let fileDb;
|
|
59
|
+
try {
|
|
60
|
+
// Directory: create 0700, or repair perms if it already exists (D18).
|
|
61
|
+
if (!existsSync(dir)) {
|
|
62
|
+
mkdirSync(dir, { recursive: true, mode: 0o700 });
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
safeChmod(dir, 0o700, warn);
|
|
66
|
+
}
|
|
67
|
+
const dbPath = join(dir, DB_FILENAME);
|
|
68
|
+
fileDb = new Database(dbPath);
|
|
69
|
+
configurePragmas(fileDb);
|
|
70
|
+
runMigrations(fileDb); // executes DDL — surfaces a corrupt/newer file here
|
|
71
|
+
// The file (and its -wal/-shm sidecars) may have just been created;
|
|
72
|
+
// enforce 0600 across all three (and repair a loose one).
|
|
73
|
+
safeChmod(dbPath, 0o600, warn);
|
|
74
|
+
safeChmod(`${dbPath}-wal`, 0o600, warn);
|
|
75
|
+
safeChmod(`${dbPath}-shm`, 0o600, warn);
|
|
76
|
+
const store = new StateStore(fileDb, dbPath, false, now);
|
|
77
|
+
// The legacy token copy and boot purge are conveniences — a failure in
|
|
78
|
+
// either must NOT discard an otherwise-healthy on-disk store, so they run
|
|
79
|
+
// outside the degrade-governing path (warn-and-continue).
|
|
80
|
+
try {
|
|
81
|
+
migrateLegacyTokens(fileDb, dir, legacyDir);
|
|
82
|
+
}
|
|
83
|
+
catch (e) {
|
|
84
|
+
warn(`[mcp-office365] legacy token migration skipped (${e instanceof Error ? e.message : String(e)}).`);
|
|
85
|
+
}
|
|
86
|
+
try {
|
|
87
|
+
store.purgeExpired(now());
|
|
88
|
+
}
|
|
89
|
+
catch (e) {
|
|
90
|
+
warn(`[mcp-office365] boot purge skipped (${e instanceof Error ? e.message : String(e)}).`);
|
|
91
|
+
}
|
|
92
|
+
return store;
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
// Release the on-disk handle (and its WAL lock) before degrading, so a
|
|
96
|
+
// failed open does not leak a file descriptor / lock for the process.
|
|
97
|
+
if (fileDb !== undefined) {
|
|
98
|
+
try {
|
|
99
|
+
fileDb.close();
|
|
100
|
+
}
|
|
101
|
+
catch {
|
|
102
|
+
/* best-effort */
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
106
|
+
warn(`[mcp-office365] state store unavailable (${reason}); running in-memory (durability degraded).`);
|
|
107
|
+
const mem = new Database(':memory:');
|
|
108
|
+
configurePragmas(mem);
|
|
109
|
+
runMigrations(mem);
|
|
110
|
+
return new StateStore(mem, ':memory:', true, now);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
// ---- Aliases (D3) --------------------------------------------------------
|
|
114
|
+
/** Inserts or replaces a durable-ID alias. */
|
|
115
|
+
putAlias(input) {
|
|
116
|
+
this.db
|
|
117
|
+
.prepare(`INSERT INTO aliases (token, graph_id, entity_type, account_id, mutable, created_at)
|
|
118
|
+
VALUES (@token, @graphId, @entityType, @accountId, @mutable, @createdAt)
|
|
119
|
+
ON CONFLICT(token) DO UPDATE SET
|
|
120
|
+
graph_id = excluded.graph_id,
|
|
121
|
+
entity_type = excluded.entity_type,
|
|
122
|
+
account_id = excluded.account_id,
|
|
123
|
+
mutable = excluded.mutable`)
|
|
124
|
+
.run({
|
|
125
|
+
token: input.token,
|
|
126
|
+
graphId: input.graphId,
|
|
127
|
+
entityType: input.entityType,
|
|
128
|
+
accountId: input.accountId,
|
|
129
|
+
mutable: input.mutable === true ? 1 : 0,
|
|
130
|
+
createdAt: input.createdAt ?? this.now(),
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Resolves an alias token, scoped to `accountId` (D7 account stamping). The
|
|
135
|
+
* account is a mandatory, fail-closed argument: a row minted under a different
|
|
136
|
+
* account is invisible, so no caller can accidentally resolve a foreign
|
|
137
|
+
* account's durable ID into a live Graph ID by omitting the scope.
|
|
138
|
+
*/
|
|
139
|
+
getAlias(token, accountId) {
|
|
140
|
+
const raw = this.db
|
|
141
|
+
.prepare('SELECT * FROM aliases WHERE token = ? AND account_id = ?')
|
|
142
|
+
.get(token, accountId);
|
|
143
|
+
if (raw === undefined) {
|
|
144
|
+
return null;
|
|
145
|
+
}
|
|
146
|
+
return {
|
|
147
|
+
token: raw.token,
|
|
148
|
+
graphId: raw.graph_id,
|
|
149
|
+
entityType: raw.entity_type,
|
|
150
|
+
accountId: raw.account_id,
|
|
151
|
+
mutable: raw.mutable !== 0,
|
|
152
|
+
createdAt: raw.created_at,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Atomically registers an alias with D1a collision enforcement, in a single
|
|
157
|
+
* IMMEDIATE transaction so the check-and-write is not a read-then-write race:
|
|
158
|
+
* two concurrent immutable registrations of the same token cannot both pass
|
|
159
|
+
* the check and then clobber each other. Returns `'collision'` when a
|
|
160
|
+
* *different* Graph ID already occupies the token for an immutable entity
|
|
161
|
+
* (neither the stored nor the new row is mutable); otherwise upserts and
|
|
162
|
+
* returns `'ok'`.
|
|
163
|
+
*/
|
|
164
|
+
registerAlias(input) {
|
|
165
|
+
const run = this.db.transaction(() => {
|
|
166
|
+
const existing = this.getAliasUnscoped(input.token);
|
|
167
|
+
if (existing !== null &&
|
|
168
|
+
existing.graphId !== input.graphId &&
|
|
169
|
+
!existing.mutable &&
|
|
170
|
+
input.mutable !== true) {
|
|
171
|
+
return 'collision';
|
|
172
|
+
}
|
|
173
|
+
this.putAlias(input);
|
|
174
|
+
return 'ok';
|
|
175
|
+
});
|
|
176
|
+
return run.immediate();
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Returns an alias row regardless of account, or null. Reserved for two
|
|
180
|
+
* internal uses that must see across accounts: foreign-account disambiguation
|
|
181
|
+
* during resolution, and collision detection at mint time (D1a). It is NOT a
|
|
182
|
+
* resolution path — {@link getAlias} (account-scoped) is the only one of those.
|
|
183
|
+
*/
|
|
184
|
+
getAliasUnscoped(token) {
|
|
185
|
+
const raw = this.db.prepare('SELECT * FROM aliases WHERE token = ?').get(token);
|
|
186
|
+
if (raw === undefined) {
|
|
187
|
+
return null;
|
|
188
|
+
}
|
|
189
|
+
return {
|
|
190
|
+
token: raw.token,
|
|
191
|
+
graphId: raw.graph_id,
|
|
192
|
+
entityType: raw.entity_type,
|
|
193
|
+
accountId: raw.account_id,
|
|
194
|
+
mutable: raw.mutable !== 0,
|
|
195
|
+
createdAt: raw.created_at,
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Returns the account a token was minted under (any account), or null when the
|
|
200
|
+
* token is unknown. Distinguishes "foreign account" from "unknown" during
|
|
201
|
+
* resolution so a foreign token yields a typed ID_FOREIGN_ACCOUNT.
|
|
202
|
+
*/
|
|
203
|
+
getAliasAccount(token) {
|
|
204
|
+
return this.getAliasUnscoped(token)?.accountId ?? null;
|
|
205
|
+
}
|
|
206
|
+
// ---- Approval tokens (D7/D8) --------------------------------------------
|
|
207
|
+
/**
|
|
208
|
+
* Reads an approval token scoped to `accountId` (or null). A read view for
|
|
209
|
+
* validation/preview; redemption still goes through {@link consumeApprovalToken}
|
|
210
|
+
* so the atomic guard is never bypassed.
|
|
211
|
+
*/
|
|
212
|
+
getApprovalToken(token, accountId) {
|
|
213
|
+
const raw = this.db
|
|
214
|
+
.prepare('SELECT token, action, target_json, content_hash, expires_at, redeemed_at, receipt_json, created_at FROM approval_tokens WHERE token = ? AND account_id = ?')
|
|
215
|
+
.get(token, accountId);
|
|
216
|
+
if (raw === undefined) {
|
|
217
|
+
return null;
|
|
218
|
+
}
|
|
219
|
+
return {
|
|
220
|
+
token: raw.token,
|
|
221
|
+
action: raw.action,
|
|
222
|
+
targetJson: raw.target_json,
|
|
223
|
+
contentHash: raw.content_hash,
|
|
224
|
+
expiresAt: raw.expires_at,
|
|
225
|
+
redeemedAt: raw.redeemed_at,
|
|
226
|
+
receiptJson: raw.receipt_json,
|
|
227
|
+
createdAt: raw.created_at,
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
/** Stages a two-phase approval token. */
|
|
231
|
+
putApprovalToken(input) {
|
|
232
|
+
this.db
|
|
233
|
+
.prepare(`INSERT INTO approval_tokens
|
|
234
|
+
(token, operation_key, action, target_json, content_hash, account_id, expires_at, created_at)
|
|
235
|
+
VALUES (@token, @operationKey, @action, @targetJson, @contentHash, @accountId, @expiresAt, @createdAt)`)
|
|
236
|
+
.run({
|
|
237
|
+
token: input.token,
|
|
238
|
+
operationKey: input.operationKey ?? null,
|
|
239
|
+
action: input.action,
|
|
240
|
+
targetJson: input.targetJson,
|
|
241
|
+
contentHash: input.contentHash ?? null,
|
|
242
|
+
accountId: input.accountId,
|
|
243
|
+
expiresAt: input.expiresAt,
|
|
244
|
+
createdAt: input.createdAt ?? this.now(),
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Atomically consumes an approval token (D8). The guarded `UPDATE … WHERE
|
|
249
|
+
* redeemed_at IS NULL AND expires_at > now RETURNING` means only one caller —
|
|
250
|
+
* across processes sharing the db — can win the redemption; the loser sees
|
|
251
|
+
* `already_redeemed` and can return the stored receipt. Expiry is enforced
|
|
252
|
+
* here at the trust boundary (not left to callers): an expired token that
|
|
253
|
+
* still authorizes a send/delete would defeat the whole point of a time-boxed
|
|
254
|
+
* two-phase approval. Foreign-account tokens are refused.
|
|
255
|
+
*/
|
|
256
|
+
consumeApprovalToken(args) {
|
|
257
|
+
const now = args.now ?? this.now();
|
|
258
|
+
const updated = this.db
|
|
259
|
+
.prepare(`UPDATE approval_tokens
|
|
260
|
+
SET redeemed_at = ?, receipt_json = ?
|
|
261
|
+
WHERE token = ? AND account_id = ? AND redeemed_at IS NULL AND expires_at > ?
|
|
262
|
+
RETURNING receipt_json`)
|
|
263
|
+
.get(now, args.receiptJson ?? null, args.token, args.accountId, now);
|
|
264
|
+
if (updated !== undefined) {
|
|
265
|
+
return { status: 'consumed', receiptJson: updated.receipt_json };
|
|
266
|
+
}
|
|
267
|
+
// Classify why the guarded update matched nothing.
|
|
268
|
+
const row = this.db
|
|
269
|
+
.prepare('SELECT account_id, redeemed_at, receipt_json, expires_at FROM approval_tokens WHERE token = ?')
|
|
270
|
+
.get(args.token);
|
|
271
|
+
if (row === undefined) {
|
|
272
|
+
return { status: 'not_found' };
|
|
273
|
+
}
|
|
274
|
+
if (row.account_id !== args.accountId) {
|
|
275
|
+
return { status: 'foreign_account' };
|
|
276
|
+
}
|
|
277
|
+
// Redemption takes precedence over expiry so an idempotent re-consume of an
|
|
278
|
+
// already-redeemed token still returns its receipt.
|
|
279
|
+
if (row.redeemed_at !== null) {
|
|
280
|
+
return { status: 'already_redeemed', receiptJson: row.receipt_json };
|
|
281
|
+
}
|
|
282
|
+
return { status: 'expired' };
|
|
283
|
+
}
|
|
284
|
+
// ---- Maintenance ---------------------------------------------------------
|
|
285
|
+
/**
|
|
286
|
+
* Deletes approval tokens whose expiry is older than the retention window
|
|
287
|
+
* (D8, 90 days). Recently-expired receipts linger so idempotent redemption
|
|
288
|
+
* still returns them. Returns the number of rows purged.
|
|
289
|
+
*/
|
|
290
|
+
purgeExpired(now) {
|
|
291
|
+
const cutoff = now - APPROVAL_RETENTION_MS;
|
|
292
|
+
const result = this.db.prepare('DELETE FROM approval_tokens WHERE expires_at < ?').run(cutoff);
|
|
293
|
+
return result.changes;
|
|
294
|
+
}
|
|
295
|
+
close() {
|
|
296
|
+
this.db.close();
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
function configurePragmas(db) {
|
|
300
|
+
db.pragma('journal_mode = WAL');
|
|
301
|
+
db.pragma('busy_timeout = 5000');
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* chmod that never throws. Windows/filesystems without POSIX modes fail benignly
|
|
305
|
+
* and are ignored; a genuine failure on a POSIX host (e.g. EPERM) means the file
|
|
306
|
+
* may sit with looser-than-intended permissions, so we surface it via `warn`
|
|
307
|
+
* rather than swallow silently — the at-rest exposure should be observable.
|
|
308
|
+
* A missing sidecar (-wal/-shm not yet created) is not a failure worth noting.
|
|
309
|
+
*/
|
|
310
|
+
function safeChmod(target, mode, warn) {
|
|
311
|
+
try {
|
|
312
|
+
chmodSync(target, mode);
|
|
313
|
+
}
|
|
314
|
+
catch (error) {
|
|
315
|
+
const code = error.code;
|
|
316
|
+
if (process.platform !== 'win32' && code !== 'ENOENT' && warn != null) {
|
|
317
|
+
warn(`[mcp-office365] could not set permissions on ${target} (${code ?? 'error'}); it may be readable by other local users.`);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
//# sourceMappingURL=store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.js","sourceRoot":"","sources":["../../src/state/store.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;GASG;AAEH,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAClE,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAI9C,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,EAAE,EAAE,gBAAgB,CAAC,CAAC;AACtD,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,EAAE,EAAE,cAAc,CAAC,CAAC;AACnD,MAAM,WAAW,GAAG,UAAU,CAAC;AA2E/B,MAAM,OAAO,UAAU;IACrB,0EAA0E;IACjE,QAAQ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
/**
|
|
2
|
+
* Copyright (c) 2026 JBC Tech Solutions, LLC
|
|
3
|
+
* Licensed under the MIT License. See LICENSE file in the project root.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Graph-backend calendar tools (v3 registry-driven architecture, U2 — dual
|
|
7
|
+
* backend). Holds the calendar logic that previously lived inline in the
|
|
8
|
+
* `handleGraphToolCall` switch, so the registry handlers stay thin and branch
|
|
9
|
+
* on `ctx.backend`.
|
|
10
|
+
*/
|
|
11
|
+
import type { GraphRepository } from '../graph/repository.js';
|
|
12
|
+
import type { GraphContentReaders } from '../graph/content-readers.js';
|
|
13
|
+
import { type ApprovalTokenManager } from '../approval/index.js';
|
|
14
|
+
import type { ToolResult } from '../registry/types.js';
|
|
15
|
+
import type { ListEventsParams, GetEventParams, SearchEventsParams, CreateEventGraphParams, UpdateEventParams, DeleteEventParams, RespondToEventParams, ListEventInstancesParams, PrepareDeleteEventParams, ConfirmDeleteEventParams, CreateCalendarGroupParams, ListRoomsParams } from './calendar.js';
|
|
16
|
+
/**
|
|
17
|
+
* Graph calendar tools. Each method mirrors the extracted inline graph case
|
|
18
|
+
* body and returns an MCP `ToolResult`.
|
|
19
|
+
*/
|
|
20
|
+
export declare class GraphCalendarTools {
|
|
21
|
+
private readonly repository;
|
|
22
|
+
private readonly contentReaders;
|
|
23
|
+
private readonly tokenManager;
|
|
24
|
+
constructor(repository: GraphRepository, contentReaders: GraphContentReaders, tokenManager: ApprovalTokenManager);
|
|
25
|
+
listCalendars(): Promise<ToolResult>;
|
|
26
|
+
listEvents(params: ListEventsParams): Promise<ToolResult>;
|
|
27
|
+
getEvent(params: GetEventParams): Promise<ToolResult>;
|
|
28
|
+
searchEvents(params: SearchEventsParams): Promise<ToolResult>;
|
|
29
|
+
createEvent(params: CreateEventGraphParams): Promise<ToolResult>;
|
|
30
|
+
updateEvent(params: UpdateEventParams): Promise<ToolResult>;
|
|
31
|
+
respondToEvent(params: RespondToEventParams): Promise<ToolResult>;
|
|
32
|
+
deleteEvent(params: DeleteEventParams): Promise<ToolResult>;
|
|
33
|
+
listEventInstances(params: ListEventInstancesParams): Promise<ToolResult>;
|
|
34
|
+
prepareDeleteEvent(params: PrepareDeleteEventParams): Promise<ToolResult>;
|
|
35
|
+
confirmDeleteEvent(params: ConfirmDeleteEventParams): Promise<ToolResult>;
|
|
36
|
+
listCalendarGroups(): Promise<ToolResult>;
|
|
37
|
+
createCalendarGroup(params: CreateCalendarGroupParams): Promise<ToolResult>;
|
|
38
|
+
listRoomLists(): Promise<ToolResult>;
|
|
39
|
+
listRooms(params: ListRoomsParams): Promise<ToolResult>;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=calendar-graph.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calendar-graph.d.ts","sourceRoot":"","sources":["../../src/tools/calendar-graph.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE9D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAGvE,OAAO,EAAwB,KAAK,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACvF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,KAAK,EAEV,gBAAgB,EAChB,cAAc,EACd,kBAAkB,EAClB,sBAAsB,EACtB,iBAAiB,EACjB,iBAAiB,EACjB,oBAAoB,EACpB,wBAAwB,EACxB,wBAAwB,EACxB,wBAAwB,EACxB,yBAAyB,EACzB,eAAe,EAChB,MAAM,eAAe,CAAC;AA4DvB;;;GAGG;AACH,qBAAa,kBAAkB;IAE3B,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,cAAc;IAC/B,OAAO,CAAC,QAAQ,CAAC,YAAY;gBAFZ,UAAU,EAAE,eAAe,EAC3B,cAAc,EAAE,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