@opentabs-dev/opentabs-plugin-onenote 0.0.75 → 0.0.77

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 CHANGED
@@ -1,159 +1,67 @@
1
- # opentabs-plugin-onenote
1
+ # Microsoft OneNote
2
2
 
3
- OpenTabs plugin for Microsoft OneNote
3
+ OpenTabs plugin for Microsoft OneNote — gives AI agents access to Microsoft OneNote through your authenticated browser session.
4
4
 
5
- ## Project Structure
5
+ ## Install
6
6
 
7
+ ```bash
8
+ opentabs plugin install onenote
7
9
  ```
8
- onenote/
9
- ├── package.json # Plugin metadata (name, opentabs field, dependencies)
10
- ├── icon.svg # Optional custom icon (square SVG, max 8KB)
11
- ├── icon-inactive.svg # Optional manual inactive icon override
12
- ├── src/
13
- │ ├── index.ts # Plugin class (extends OpenTabsPlugin)
14
- │ └── tools/ # One file per tool (using defineTool)
15
- │ └── example.ts
16
- └── dist/ # Build output (generated)
17
- ├── adapter.iife.js # Bundled adapter injected into matching tabs
18
- └── tools.json # Tool schemas for MCP registration
19
- ```
20
-
21
- ## Configuration
22
-
23
- Plugin metadata is defined in `package.json` under the `opentabs` field:
24
-
25
- ```json
26
- {
27
- "name": "opentabs-plugin-onenote",
28
- "main": "dist/adapter.iife.js",
29
- "opentabs": {
30
- "displayName": "Microsoft OneNote",
31
- "description": "OpenTabs plugin for Microsoft OneNote",
32
- "urlPatterns": ["*://*.onenote.cloud.microsoft/*"]
33
- }
34
- }
35
- ```
36
-
37
- - **`main`** — entry point for the bundled adapter IIFE
38
- - **`opentabs.displayName`** — human-readable name shown in the side panel
39
- - **`opentabs.description`** — short description of what the plugin does
40
- - **`opentabs.urlPatterns`** — Chrome match patterns for tabs where the adapter is injected
41
-
42
- ## Custom Icons
43
-
44
- By default, the side panel shows a colored letter avatar for your plugin. To use a custom icon, place an `icon.svg` file in the plugin root (next to `package.json`):
45
-
46
- ```
47
- onenote/
48
- ├── package.json
49
- ├── icon.svg ← custom icon (optional)
50
- ├── icon-inactive.svg ← manual inactive override (optional, requires icon.svg)
51
- ├── src/
52
- │ └── ...
53
- ```
54
-
55
- **How it works:**
56
-
57
- - `opentabs-plugin build` reads `icon.svg`, validates it, auto-generates a grayscale inactive variant, and embeds both in `dist/tools.json`
58
- - To override the auto-generated inactive icon, provide `icon-inactive.svg` (must use only grayscale colors)
59
- - If no `icon.svg` is provided, the letter avatar is used automatically
60
-
61
- **Icon requirements:**
62
10
 
63
- - Square SVG with a `viewBox` attribute (e.g., `viewBox="0 0 32 32"`)
64
- - Maximum 8 KB file size
65
- - No embedded `<image>`, `<script>`, or event handler attributes (`onclick`, etc.)
66
- - Manual `icon-inactive.svg` must use only achromatic (grayscale) colors
67
-
68
- ## Development
11
+ Or install globally via npm:
69
12
 
70
13
  ```bash
71
- npm install
72
- npm run build # tsc && opentabs-plugin build
73
- npm run dev # watch mode (tsc --watch + opentabs-plugin build --watch)
74
- npm run type-check # tsc --noEmit
75
- npm run lint # biome
14
+ npm install -g @opentabs-dev/opentabs-plugin-onenote
76
15
  ```
77
16
 
78
- ## Adding Tools
79
-
80
- Create a new file in `src/tools/` using `defineTool`:
81
-
82
- ```ts
83
- import { z } from 'zod';
84
- import { defineTool } from '@opentabs-dev/plugin-sdk';
85
-
86
- export const myTool = defineTool({
87
- name: 'my_tool',
88
- displayName: 'My Tool',
89
- description: 'What this tool does',
90
- icon: 'wrench',
91
- input: z.object({ /* ... */ }),
92
- output: z.object({ /* ... */ }),
93
- handle: async (params) => {
94
- // Tool implementation runs in the browser tab context
95
- return { /* ... */ };
96
- },
97
- });
98
- ```
17
+ ## Setup
99
18
 
100
- Then register it in `src/index.ts` by adding it to the `tools` array.
19
+ 1. Open [onenote.cloud.microsoft](https://onenote.cloud.microsoft/) in Chrome and log in
20
+ 2. Open the OpenTabs side panel — the Microsoft OneNote plugin should appear as **ready**
101
21
 
102
- ## Authentication
22
+ ## Tools (12)
103
23
 
104
- Plugin tools run in the browser tab context, so they can read auth tokens directly from the page. The SDK provides utilities for the most common patterns:
24
+ ### Notebooks (4)
105
25
 
106
- ```ts
107
- import { getLocalStorage, getCookie, getPageGlobal } from '@opentabs-dev/plugin-sdk';
26
+ | Tool | Description | Type |
27
+ |---|---|---|
28
+ | `list_notebooks` | List all OneNote notebooks | Read |
29
+ | `get_notebook` | Get a notebook by ID | Read |
30
+ | `create_notebook` | Create a new notebook | Write |
31
+ | `get_recent_notebooks` | Get recently accessed notebooks | Read |
108
32
 
109
- // localStorage — most common
110
- const token = getLocalStorage('token');
33
+ ### Sections (3)
111
34
 
112
- // Cookies session tokens, JWTs
113
- const session = getCookie('session_id');
35
+ | Tool | Description | Type |
36
+ |---|---|---|
37
+ | `list_sections` | List sections in a notebook or across all notebooks | Read |
38
+ | `get_section` | Get a section by ID | Read |
39
+ | `create_section` | Create a new section in a notebook | Write |
114
40
 
115
- // Page globals — SPA boot data (e.g., window.__APP_STATE__)
116
- const appState = getPageGlobal('__APP_STATE__');
117
- ```
41
+ ### Section Groups (3)
118
42
 
119
- **Iframe fallback:** Some apps (e.g., Discord) delete `window.localStorage` after boot. `getLocalStorage` automatically tries a hidden same-origin iframe fallback before returning `null`, so you don't need to handle this case manually.
43
+ | Tool | Description | Type |
44
+ |---|---|---|
45
+ | `list_section_groups` | List section groups in a notebook or across all notebooks | Read |
46
+ | `get_section_group` | Get a section group by ID | Read |
47
+ | `create_section_group` | Create a section group in a notebook | Write |
120
48
 
121
- **SPA hydration:** Auth tokens may not be available immediately on page load. Implement polling in `isReady()` to wait until the app has hydrated before your tools run. See the comments in `src/index.ts` for an example polling pattern.
49
+ ### Pages (1)
122
50
 
123
- ## Shared Schemas
51
+ | Tool | Description | Type |
52
+ |---|---|---|
53
+ | `create_page` | Create a new page in a section with HTML content | Write |
124
54
 
125
- When 3 or more tools share the same input or output shape, extract common Zod schemas into a shared file to avoid duplication:
55
+ ### Account (1)
126
56
 
127
- ```ts
128
- // src/schemas/channel.ts
129
- import { z } from 'zod';
57
+ | Tool | Description | Type |
58
+ |---|---|---|
59
+ | `get_current_user` | Get the current user profile | Read |
130
60
 
131
- export const channelSchema = z.object({
132
- id: z.string().describe('Channel ID'),
133
- name: z.string().describe('Channel name'),
134
- });
61
+ ## How It Works
135
62
 
136
- export type Channel = z.infer<typeof channelSchema>;
137
- ```
63
+ This plugin runs inside your Microsoft OneNote tab through the [OpenTabs](https://opentabs.dev) Chrome extension. It uses your existing browser session — no API tokens or OAuth apps required. All operations happen as you, with your permissions.
138
64
 
139
- Then import and reuse in your tools:
140
-
141
- ```ts
142
- // src/tools/list-channels.ts
143
- import { channelSchema } from '../schemas/channel.js';
144
-
145
- export const listChannels = defineTool({
146
- name: 'list_channels',
147
- displayName: 'List Channels',
148
- description: 'List all available channels',
149
- icon: 'list',
150
- input: z.object({}),
151
- output: z.object({ channels: z.array(channelSchema) }),
152
- handle: async () => {
153
- // ...
154
- return { channels: [] };
155
- },
156
- });
157
- ```
65
+ ## License
158
66
 
159
- This keeps your tool schemas DRY and makes it easy to evolve shared types in one place.
67
+ MIT
@@ -271,18 +271,19 @@
271
271
  }
272
272
  return null;
273
273
  };
274
- try {
275
- return search(localStorage);
276
- } catch {
277
- }
278
274
  let storage;
279
275
  try {
280
- storage = localStorage;
276
+ storage = window.localStorage;
281
277
  } catch {
282
278
  return null;
283
279
  }
284
- if (storage !== void 0)
285
- return null;
280
+ if (storage) {
281
+ try {
282
+ return search(storage);
283
+ } catch {
284
+ return null;
285
+ }
286
+ }
286
287
  try {
287
288
  const iframe = document.createElement("iframe");
288
289
  iframe.style.display = "none";
@@ -344,6 +345,8 @@
344
345
  * (e.g., 'https://github.com'), not a match pattern.
345
346
  */
346
347
  homepage;
348
+ /** Typed configuration schema — declares settings that users provide via config.json or the side panel. */
349
+ configSchema;
347
350
  };
348
351
 
349
352
  // src/onenote-api.ts
@@ -14657,21 +14660,21 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
14657
14660
  };
14658
14661
  var src_default = new OneNotePlugin();
14659
14662
 
14660
- // dist/_adapter_entry_c7dd6944-1437-4279-906e-671c0e48fdd2.ts
14663
+ // dist/_adapter_entry_ee2de03b-ac50-4c8b-8f07-804ca1421823.ts
14661
14664
  if (!globalThis.__openTabs) {
14662
14665
  globalThis.__openTabs = {};
14663
14666
  } else {
14664
14667
  const desc = Object.getOwnPropertyDescriptor(globalThis.__openTabs, "adapters");
14665
14668
  if (desc && !desc.writable) {
14666
- const ot2 = globalThis.__openTabs;
14669
+ const ot3 = globalThis.__openTabs;
14667
14670
  const newAdaptersObj = {};
14668
- if (ot2.adapters) {
14669
- for (const key of Object.keys(ot2.adapters)) {
14670
- const d = Object.getOwnPropertyDescriptor(ot2.adapters, key);
14671
+ if (ot3.adapters) {
14672
+ for (const key of Object.keys(ot3.adapters)) {
14673
+ const d = Object.getOwnPropertyDescriptor(ot3.adapters, key);
14671
14674
  if (d) Object.defineProperty(newAdaptersObj, key, d);
14672
14675
  }
14673
14676
  }
14674
- globalThis.__openTabs = Object.assign({}, ot2, { adapters: newAdaptersObj });
14677
+ globalThis.__openTabs = Object.assign({}, ot3, { adapters: newAdaptersObj });
14675
14678
  }
14676
14679
  }
14677
14680
  if (!globalThis.__openTabs.adapters) {
@@ -14709,6 +14712,16 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
14709
14712
  }
14710
14713
  };
14711
14714
  var restoreTransport = setLogTransport ? setLogTransport(logTransport) : void 0;
14715
+ var ot2 = globalThis.__openTabs;
14716
+ ot2._notifyReadinessChanged = () => {
14717
+ try {
14718
+ const nonce = globalThis.__openTabs?._readinessNonce;
14719
+ if (nonce) {
14720
+ window.postMessage({ type: "opentabs:readiness-changed", plugin: "onenote", nonce }, "*");
14721
+ }
14722
+ } catch {
14723
+ }
14724
+ };
14712
14725
  var existing = adapters["onenote"];
14713
14726
  if (existing) {
14714
14727
  if (typeof existing.teardown === "function") {
@@ -14720,7 +14733,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
14720
14733
  }
14721
14734
  }
14722
14735
  if (!Reflect.deleteProperty(adapters, "onenote")) {
14723
- const ot2 = globalThis.__openTabs;
14736
+ const ot3 = globalThis.__openTabs;
14724
14737
  const newAdapters = {};
14725
14738
  for (const key of Object.keys(adapters)) {
14726
14739
  if (key !== "onenote") {
@@ -14728,7 +14741,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
14728
14741
  if (desc) Object.defineProperty(newAdapters, key, desc);
14729
14742
  }
14730
14743
  }
14731
- globalThis.__openTabs = Object.assign({}, ot2, { adapters: newAdapters });
14744
+ globalThis.__openTabs = Object.assign({}, ot3, { adapters: newAdapters });
14732
14745
  }
14733
14746
  var hasLifecycleHooks = typeof src_default.onToolInvocationStart === "function" || typeof src_default.onToolInvocationEnd === "function";
14734
14747
  for (const tool of src_default.tools) {
@@ -14789,12 +14802,12 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
14789
14802
  }
14790
14803
  }
14791
14804
  };
14792
- const ot2 = globalThis.__openTabs;
14793
- if (!ot2._navigationInterceptor) {
14805
+ const ot3 = globalThis.__openTabs;
14806
+ if (!ot3._navigationInterceptor) {
14794
14807
  const origPushState = history.pushState.bind(history);
14795
14808
  const origReplaceState = history.replaceState.bind(history);
14796
14809
  const callbacks = /* @__PURE__ */ new Map();
14797
- ot2._navigationInterceptor = { callbacks, origPushState, origReplaceState };
14810
+ ot3._navigationInterceptor = { callbacks, origPushState, origReplaceState };
14798
14811
  history.pushState = function(...args) {
14799
14812
  origPushState(...args);
14800
14813
  for (const cb of callbacks.values()) {
@@ -14808,7 +14821,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
14808
14821
  }
14809
14822
  };
14810
14823
  }
14811
- const interceptor = ot2._navigationInterceptor;
14824
+ const interceptor = ot3._navigationInterceptor;
14812
14825
  interceptor.callbacks.set("onenote", checkUrl);
14813
14826
  window.addEventListener("popstate", checkUrl);
14814
14827
  window.addEventListener("hashchange", checkUrl);
@@ -14863,5 +14876,5 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
14863
14876
  };
14864
14877
  delete src_default.onDeactivate;
14865
14878
  }
14866
- })();(function(){var o=(globalThis).__openTabs;if(o&&o.adapters&&o.adapters["onenote"]){var a=o.adapters["onenote"];a.__adapterHash="160f77c038f41ea10e4cf848ffd17c58aca811bd8679b3edc15eba12f3bc6842";if(a.tools&&Array.isArray(a.tools)){for(var i=0;i<a.tools.length;i++){Object.freeze(a.tools[i]);}Object.freeze(a.tools);}Object.freeze(a);Object.defineProperty(o.adapters,"onenote",{value:a,writable:false,configurable:false,enumerable:true});Object.defineProperty(o,"adapters",{value:o.adapters,writable:false,configurable:false});}})();
14879
+ })();(function(){var o=(globalThis).__openTabs;if(o&&o.adapters&&o.adapters["onenote"]){var a=o.adapters["onenote"];a.__adapterHash="3acc1761b8f71793e48639ed5f2aae9e756a945e9fde88d88471fc1afce3d84c";if(a.tools&&Array.isArray(a.tools)){for(var i=0;i<a.tools.length;i++){Object.freeze(a.tools[i]);}Object.freeze(a.tools);}Object.freeze(a);Object.defineProperty(o.adapters,"onenote",{value:a,writable:false,configurable:false,enumerable:true});Object.defineProperty(o,"adapters",{value:o.adapters,writable:false,configurable:false});}})();
14867
14880
  //# sourceMappingURL=adapter.iife.js.map