@markupai/sidebar-adapter 2.2.0 → 2.4.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.
Files changed (35) hide show
  1. package/README.md +80 -6
  2. package/asyncapi.json +208 -49
  3. package/dist/adapters/index.d.ts +2 -2
  4. package/dist/adapters/pluginAdapter.d.ts +10 -2
  5. package/dist/adapters/pluginAdapter.d.ts.map +1 -1
  6. package/dist/adapters/sidebarAdapter.d.ts +2 -2
  7. package/dist/adapters/sidebarAdapter.d.ts.map +1 -1
  8. package/dist/errors.d.ts +38 -1
  9. package/dist/errors.d.ts.map +1 -1
  10. package/dist/ipc/call-signatures.d.ts +7 -2
  11. package/dist/ipc/call-signatures.d.ts.map +1 -1
  12. package/dist/ipc/deferred-promise.d.ts.map +1 -1
  13. package/dist/ipc/index.d.ts +8 -8
  14. package/dist/ipc/ipc-core.d.ts +2 -2
  15. package/dist/ipc/ipc-core.d.ts.map +1 -1
  16. package/dist/ipc/plugin-ipc-adapter.d.ts +11 -4
  17. package/dist/ipc/plugin-ipc-adapter.d.ts.map +1 -1
  18. package/dist/ipc/sidebar-build-info.d.ts +1 -1
  19. package/dist/ipc/sidebar-ipc-adapter.d.ts +4 -4
  20. package/dist/ipc/sidebar-ipc-adapter.d.ts.map +1 -1
  21. package/dist/load-overlay/loadOverlayStyles.d.ts.map +1 -1
  22. package/dist/load-overlay/sidebarLoadOverlay.d.ts.map +1 -1
  23. package/dist/main.js +190 -136
  24. package/dist/main.umd.cjs +6 -6
  25. package/dist/sidebar-host/createSidebarHost.d.ts +4 -4
  26. package/dist/types/common.d.ts +30 -0
  27. package/dist/types/common.d.ts.map +1 -1
  28. package/dist/types/errors.d.ts +47 -0
  29. package/dist/types/errors.d.ts.map +1 -0
  30. package/dist/types/index.d.ts +1 -0
  31. package/dist/types/index.d.ts.map +1 -1
  32. package/dist/types/integrationSettings.d.ts.map +1 -1
  33. package/dist/types/pluginInterface.d.ts +29 -1
  34. package/dist/types/pluginInterface.d.ts.map +1 -1
  35. package/package.json +2 -2
package/README.md CHANGED
@@ -18,8 +18,9 @@ You do **not** need prior knowledge of how the sidebar is built internally. As a
18
18
  10. [Sidebar load overlay (standalone)](#sidebarloadoverlay-editor-ui)
19
19
  11. [Agentic issue lifecycle](#agentic-issue-lifecycle) · [Document references](#document-references)
20
20
  12. [Multi-document hosts](#multi-document-hosts)
21
- 13. [Sidebar build reporting](#sidebar-build-reporting) (which sidebar build is running)
22
- 14. [API reference](#api-reference) · [Development](#development)
21
+ 13. [Comments](#comments) (anchoring an issue as a document comment)
22
+ 14. [Sidebar build reporting](#sidebar-build-reporting) (which sidebar build is running)
23
+ 15. [API reference](#api-reference) · [Development](#development)
23
24
 
24
25
  ## Features
25
26
 
@@ -29,7 +30,8 @@ You do **not** need prior knowledge of how the sidebar is built internally. As a
29
30
  - **createSidebarHost** — Optional one-shot setup: create/mount iframe, optional load-failed overlay, and `SidebarAdapter` (or iframe-only when your UI and document logic run in separate contexts)
30
31
  - **Host shell helpers** — `ensureSidebarHostShell` / `buildSidebarHostHtmlDocument` so you don’t duplicate container markup and layout CSS
31
32
  - **MIME helpers** — `MimeType` enum plus arbitrary MIME strings for `ContentInfo`
32
- - **Errors** — `TextLookupError` and guards for editor lookup failures
33
+ - **Errors** — `TextLookupError` / `ReplaceBatchError` and guards for editor lookup failures
34
+ - **Comments** — `SidebarConfig.supportComments` plus optional `PluginInterface.addComment` let users anchor an issue as a native document comment (see [Comments](#comments))
33
35
  - **Auth** — `SidebarConfig.auth` for declaring the Auth0 login strategy (`"mediation" | "popup"`) and optional `PluginInterface.openAuthUrl` for routing the authorize URL through a host-owned external-browser primitive (see [Authentication](#authentication-optional))
34
36
  - **Cleanup** — `destroy()` / teardown functions on adapters and hosts
35
37
 
@@ -51,6 +53,7 @@ The sidebar runs the **agentic** experience. Its optional `PluginInterface` hook
51
53
  - **Receive streaming results** — implement **`onAgenticAgentResults`** and **`onAgenticStreamComplete`** to get issues (each with its suggestions) as they stream plus a completion signal, so you can draw your own underlines or build a context menu (see [PluginInterface](#plugininterface)).
52
54
  - **Track issue state** — implement **`onAgenticIssueStatusChanged`**; the sidebar emits it after every Open / Resolved / Dismissed transition so you can keep annotations or other host UI in sync.
53
55
  - **Know when a document's check is discarded** — implement **`onAgenticIssuesCleared`**; the sidebar emits it when the user clears a document's data, so you can drop highlights instead of pointing at suggestions that no longer exist.
56
+ - **Add issues as document comments** — if your editor can anchor a comment on a span of text, implement **`addComment`** and set **`supportComments: true`**; issue cards then offer **Add as Comment** (see [Comments](#comments)).
54
57
  - **Drive the sidebar** — call **`activateAgenticIssue`** to expand and scroll to a card (e.g. when the user clicks an underline or picks the issue from a context menu), and **`markAgenticIssueResolved`** / **`restoreAgenticIssue`** / **`invalidateAgenticIssue`** to resolve / restore / dismiss a card — for example after applying a suggestion inline from your own context menu.
55
58
 
56
59
  See [Agentic issue lifecycle](#agentic-issue-lifecycle).
@@ -199,6 +202,9 @@ const pluginInterface: PluginInterface = {
199
202
  // agents actually offered are the intersection of this flag and the
200
203
  // organization's entitlement.
201
204
  multiAgent: false,
205
+ // Optional. Set true only when you implement addComment; issue cards then
206
+ // offer "Add as Comment". Defaults to false. See the "Comments" section.
207
+ supportComments: false,
202
208
  pluginOrigin: globalThis.location.origin,
203
209
  // Optional. Declare the Auth0 login strategy the sidebar should run.
204
210
  // Omit to let the sidebar pick heuristically (legacy behavior).
@@ -509,6 +515,10 @@ Optional (clipboard):
509
515
 
510
516
  - `copyToClipboard?(text: string): Promise<void>` — Write text to the system clipboard on the sidebar's behalf. Implement this in hosts where the sidebar iframe cannot use the async clipboard API itself — notably VS Code webviews, whose Electron permission handler denies `clipboard-write` to any frame that is not on the `vscode-webview://` origin (the VS Code extension calls `vscode.env.clipboard.writeText(text)` in the extension host). Reject to signal the write failed. When omitted, the sidebar detects the absence via the standard `"No receiver registered for: copyToClipboard"` IPC error and falls back to `navigator.clipboard.writeText`, then `document.execCommand("copy")`.
511
517
 
518
+ Optional (comments):
519
+
520
+ - `addComment?(comment: CommentRequest, documentReference?: string | null): Promise<void>` — Anchor a comment on `[comment.range.start, comment.range.end)` without changing the text. `comment.text` is a ready-to-post plain-text body; `comment.issue` is the structured `AgenticIssuePayload` for hosts that format their own. Same `documentReference` rule as `selectContent`. Throw `TextLookupError` when the range cannot be located, or an `Error` with a user-facing `message` when the host cannot comment there. Only called when your config sets `supportComments: true`; when the handler is absent the call rejects with `"No receiver registered for: addComment"`. See [Comments](#comments).
521
+
512
522
  #### Error control flows
513
523
 
514
524
  When implementing `selectContent` or `replaceContent`, throw `TextLookupError` from this package when text lookup (e.g. locating the selection or target range) fails. The sidebar will treat it as a selection failure and can invalidate the issue card with the error message.
@@ -539,7 +549,29 @@ try {
539
549
  }
540
550
  ```
541
551
 
542
- Note: We document thrown errors via JSDoc `@throws` on the plugin interface and export union types `SelectContentError` and `ReplaceContentError` for control-flow typing when catching.
552
+ For `replaceMultipleContents`, throw `ReplaceBatchError` when the batch could not be applied in full and you know which ranges landed. It extends `TextLookupError` and carries `applied` (`ContentRange[]`) and `failed` (`ReplaceBatchFailedRange[]`), the ranges as they were sent; a range in neither list was left untouched. The sidebar resolves the applied occurrences, invalidates the failed ones, and leaves the rest active. The error's `message` describes the batch, so it is shown only on the card the user applied from. Give a failed range its own `message` to explain that one occurrence on its card; without one, the sidebar shows its own "text could not be found" message. A host that verifies every range before editing throws it with an empty `applied`; a plain `TextLookupError` is still accepted and treated as a failure of the whole batch.
553
+
554
+ ```typescript
555
+ import { ReplaceBatchError } from "@markupai/sidebar-adapter";
556
+
557
+ // In replaceMultipleContents, after verifying every range against the document:
558
+ if (unverifiable.length > 0) {
559
+ throw new ReplaceBatchError(
560
+ `None of the ${replacements.length} occurrences were replaced because one of them could not be verified in the document.`,
561
+ {
562
+ applied: [],
563
+ failed: unverifiable.map((r) => ({
564
+ ...r.range,
565
+ message: "This text was edited since the last check.",
566
+ })),
567
+ },
568
+ );
569
+ }
570
+ ```
571
+
572
+ Non-JS ports serialize it as `{ name: "ReplaceBatchError", message, applied, failed }` — see `ReplaceBatchErrorPayload` in `asyncapi.json`.
573
+
574
+ Note: We document thrown errors via JSDoc `@throws` on the plugin interface and export union types `SelectContentError`, `ReplaceContentError` and `ReplaceMultipleContentsError` for control-flow typing when catching.
543
575
 
544
576
  ### Message Format
545
577
 
@@ -750,7 +782,7 @@ Once `multiDocument` is on, several calls in both directions carry an explicit `
750
782
 
751
783
  | Direction | Method | Why it needs to name a document |
752
784
  | -------------- | -------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
753
- | Sidebar → host | `selectContent`, `replaceContent` | The issue the user is acting on may belong to a document you checked earlier and the user has since switched away from — see below. |
785
+ | Sidebar → host | `selectContent`, `replaceContent`, `addComment` | The issue the user is acting on may belong to a document you checked earlier and the user has since switched away from — see below. |
754
786
  | Sidebar → host | `onAgenticAgentResults`, `onAgenticStreamComplete` | A check keeps streaming results in the background after the user switches to a different document; results must stay attributed to the document that was actually checked, not whichever one happens to be on screen when they arrive. |
755
787
  | Host → sidebar | `activateAgenticIssue` | The host may want to activate an issue belonging to a document that isn't the one the sidebar is currently displaying (e.g. a background check just finished elsewhere). |
756
788
 
@@ -790,7 +822,49 @@ This is the part that's on you: `documentReference` is an opaque string as far a
790
822
 
791
823
  ### Single-document hosts (the default)
792
824
 
793
- If you don't set `multiDocument`, none of the above applies: every `documentReference` argument on `selectContent`, `replaceContent`, and `activateAgenticIssue` is always `null`, and `onAgenticAgentResults`/`onAgenticStreamComplete` receive `null` too. You don't need a lookup — "the document" is implicit, exactly as it was before this feature existed. Most integrations should stay here unless they genuinely support multiple concurrently open documents.
825
+ If you don't set `multiDocument`, none of the above applies: every `documentReference` argument on `selectContent`, `replaceContent`, `addComment`, and `activateAgenticIssue` is always `null`, and `onAgenticAgentResults`/`onAgenticStreamComplete` receive `null` too. You don't need a lookup — "the document" is implicit, exactly as it was before this feature existed. Most integrations should stay here unless they genuinely support multiple concurrently open documents.
826
+
827
+ ## Comments
828
+
829
+ Hosts whose editor can anchor a comment on a span of text — Word's `Range.insertComment` or a VS Code comment controller — can let users keep an issue in the document as a comment instead of acting on it right away. When enabled, every open issue card offers **Add as Comment**.
830
+
831
+ ### Enabling it
832
+
833
+ Implement `addComment` **and** set `supportComments: true` in `getInitConfig`. The flag is what shows the action; set it only when the handler exists and the editor's comment API is actually available at runtime:
834
+
835
+ ```typescript
836
+ getInitConfig: async () => ({
837
+ integrationName: "My Word Add-in",
838
+ integrationVersion: "1.0.0",
839
+ integrationId: "my-word-addin",
840
+ supportComments: Office.context.requirements.isSetSupported("WordApi", "1.4"),
841
+ }),
842
+
843
+ addComment: async (comment, documentReference) => {
844
+ const range = await locateRange(comment.range, documentReference); // same mapping as selectContent
845
+ if (!range) {
846
+ throw new TextLookupError("Check text again to locate this issue.");
847
+ }
848
+ range.insertComment(comment.text);
849
+ },
850
+ ```
851
+
852
+ ### What the sidebar sends
853
+
854
+ `CommentRequest` carries:
855
+
856
+ - `text` — a plain-text body the sidebar composes: a `Markup AI ·` heading with the issue's category (or agent name), the explanation, and the first suggestion when there is one. Post it as-is, or ignore it and build your own body from `issue`.
857
+ - `range` — the issue's `[start, end)` offsets, with the same semantics as `selectContent`/`replaceContent`. Resolve it the same way you do for highlighting.
858
+ - `issue` — the structured `AgenticIssuePayload` (category, explanation, suggestions, severity, …).
859
+
860
+ The sidebar sends **no user information**. Attribute the comment however your editor normally does (Word, for example, stamps the signed-in Office user as author).
861
+
862
+ ### Rules and failure handling
863
+
864
+ - **Do not change the document text.** Adding a comment must leave content and offsets untouched.
865
+ - **Range gone** — throw `TextLookupError`. The sidebar shows the message on the card and invalidates the issue, the same as a failed highlight.
866
+ - **Cannot comment here** (protected document, locked content control, …) — throw an `Error` whose `message` is safe to show the user. The sidebar shows it on the card and leaves the issue open.
867
+ - **A successful comment resolves the issue.** Once your `addComment` resolves, the sidebar moves the issue to **Resolved** (restorable, like **Mark as Resolved**) and calls `onAgenticIssueStatusChanged(issueId, "resolved", "user")`. So resolve the promise only after the comment is actually in the document. A rejected `addComment` never changes the status.
794
868
 
795
869
  ## Integration settings
796
870
 
package/asyncapi.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "asyncapi": "3.0.0",
3
3
  "info": {
4
4
  "title": "Markup AI Sidebar IPC contract",
5
- "version": "2.2.0",
5
+ "version": "2.4.0",
6
6
  "description": "Bidirectional RPC-over-postMessage contract between the Markup AI sidebar and its host. Generated from the @markupai/sidebar-adapter TypeScript types — do not hand-edit."
7
7
  },
8
8
  "channels": {
@@ -58,6 +58,8 @@
58
58
  "openAuthUrl_response": { "$ref": "#/components/messages/openAuthUrl_response" },
59
59
  "copyToClipboard_call": { "$ref": "#/components/messages/copyToClipboard_call" },
60
60
  "copyToClipboard_response": { "$ref": "#/components/messages/copyToClipboard_response" },
61
+ "addComment_call": { "$ref": "#/components/messages/addComment_call" },
62
+ "addComment_response": { "$ref": "#/components/messages/addComment_response" },
61
63
  "onIntegrationSettingsChange_call": {
62
64
  "$ref": "#/components/messages/onIntegrationSettingsChange_call"
63
65
  },
@@ -300,6 +302,21 @@
300
302
  ]
301
303
  }
302
304
  },
305
+ "addComment": {
306
+ "action": "send",
307
+ "channel": { "$ref": "#/channels/sidebarToPlugin" },
308
+ "title": "addComment",
309
+ "description": "Ask the plugin to anchor a comment on [comment.range.start, comment.range.end) without changing the text. documentReference is the target document (null = active document). Rejects with TextLookupError when the range cannot be located. Only sent to hosts that set supportComments.",
310
+ "x-optional": false,
311
+ "messages": [{ "$ref": "#/channels/sidebarToPlugin/messages/addComment_call" }],
312
+ "reply": {
313
+ "channel": { "$ref": "#/channels/sidebarToPlugin" },
314
+ "messages": [
315
+ { "$ref": "#/channels/sidebarToPlugin/messages/addComment_response" },
316
+ { "$ref": "#/channels/sidebarToPlugin/messages/ipc_error" }
317
+ ]
318
+ }
319
+ },
303
320
  "onIntegrationSettingsChange": {
304
321
  "action": "send",
305
322
  "channel": { "$ref": "#/channels/sidebarToPlugin" },
@@ -454,7 +471,7 @@
454
471
  "name": { "type": "string" },
455
472
  "errorJSON": {
456
473
  "type": "string",
457
- "description": "JSON-stringified error: {message, name?}."
474
+ "description": "JSON-stringified error: {message, name?, ...own properties}. The receiver rebuilds a typed error from `name`; the payloads it recognises are TextLookupErrorPayload and ReplaceBatchErrorPayload (see components/schemas). Any other name arrives as a plain Error."
458
475
  }
459
476
  }
460
477
  }
@@ -935,6 +952,47 @@
935
952
  }
936
953
  }
937
954
  },
955
+ "addComment_call": {
956
+ "name": "addComment_call",
957
+ "title": "call addComment",
958
+ "payload": {
959
+ "title": "addComment_call",
960
+ "type": "object",
961
+ "additionalProperties": false,
962
+ "required": ["type", "id", "name", "data"],
963
+ "properties": {
964
+ "type": { "const": "call" },
965
+ "id": { "type": "integer" },
966
+ "name": { "const": "addComment" },
967
+ "data": {
968
+ "type": "array",
969
+ "prefixItems": [
970
+ { "$ref": "#/components/schemas/CommentRequest" },
971
+ { "type": ["string", "null"] }
972
+ ],
973
+ "minItems": 1,
974
+ "maxItems": 2,
975
+ "items": false
976
+ }
977
+ }
978
+ }
979
+ },
980
+ "addComment_response": {
981
+ "name": "addComment_response",
982
+ "title": "response addComment",
983
+ "payload": {
984
+ "title": "addComment_response",
985
+ "type": "object",
986
+ "additionalProperties": false,
987
+ "required": ["type", "id", "name", "data"],
988
+ "properties": {
989
+ "type": { "const": "response" },
990
+ "id": { "type": "integer" },
991
+ "name": { "const": "addComment" },
992
+ "data": { "type": "null" }
993
+ }
994
+ }
995
+ },
938
996
  "onIntegrationSettingsChange_call": {
939
997
  "name": "onIntegrationSettingsChange_call",
940
998
  "title": "call onIntegrationSettingsChange",
@@ -1318,6 +1376,74 @@
1318
1376
  "additionalProperties": false,
1319
1377
  "title": "ContentReplacement"
1320
1378
  },
1379
+ "CommentRequest": {
1380
+ "type": "object",
1381
+ "properties": {
1382
+ "text": {
1383
+ "type": "string",
1384
+ "description": "Ready-to-post plain-text comment body composed by the sidebar. Hosts can post it as-is or build their own body from {@link CommentRequest.issue } . It carries no author information — the host attributes the comment."
1385
+ },
1386
+ "range": {
1387
+ "$ref": "#/components/schemas/ContentRange",
1388
+ "description": "Half-open document span `[range.start, range.end)` to anchor the comment on — same offset semantics as `replaceContent` / `selectContent`."
1389
+ },
1390
+ "issue": {
1391
+ "$ref": "#/components/schemas/AgenticIssuePayload",
1392
+ "description": "The issue the comment is about, for hosts that format their own body."
1393
+ }
1394
+ },
1395
+ "required": ["text", "range"],
1396
+ "additionalProperties": false,
1397
+ "description": "A comment the sidebar asks the host to anchor on a span of the document (see {@link PluginInterface.addComment } ).",
1398
+ "title": "CommentRequest"
1399
+ },
1400
+ "AgenticIssuePayload": {
1401
+ "type": "object",
1402
+ "properties": {
1403
+ "id": { "type": "string" },
1404
+ "groupKey": { "type": "string" },
1405
+ "status": { "type": "string", "enum": ["active", "resolved", "dismissed"] },
1406
+ "original": { "type": "string" },
1407
+ "agent": { "type": "string" },
1408
+ "explanation": { "type": "string" },
1409
+ "severity": { "type": "string", "enum": ["low", "medium", "high", "critical"] },
1410
+ "confidence": { "type": "number" },
1411
+ "position": { "$ref": "#/components/schemas/AgenticIssuePosition" },
1412
+ "suggestion": { "type": "string" },
1413
+ "suggestions": { "type": "array", "items": { "type": "string" } },
1414
+ "category": { "type": "string" },
1415
+ "read_only": {
1416
+ "type": "boolean",
1417
+ "description": "When true, the host cannot apply replacements (e.g. issue points at a variable or hidden content)."
1418
+ }
1419
+ },
1420
+ "required": [
1421
+ "id",
1422
+ "groupKey",
1423
+ "status",
1424
+ "original",
1425
+ "agent",
1426
+ "explanation",
1427
+ "severity",
1428
+ "confidence",
1429
+ "position"
1430
+ ],
1431
+ "additionalProperties": false,
1432
+ "description": "Serializable payload for a single agentic issue sent over IPC (Sidebar → Plugin). Used when streaming agent results so the plugin can render underlines or other UI.",
1433
+ "title": "AgenticIssuePayload"
1434
+ },
1435
+ "AgenticIssuePosition": {
1436
+ "type": "object",
1437
+ "properties": {
1438
+ "start": { "type": "number" },
1439
+ "end": { "type": "number" },
1440
+ "text": { "type": "string" }
1441
+ },
1442
+ "required": ["start", "end", "text"],
1443
+ "additionalProperties": false,
1444
+ "description": "Character-offset span of an agentic issue within the document.",
1445
+ "title": "AgenticIssuePosition"
1446
+ },
1321
1447
  "ContentInfo": {
1322
1448
  "type": "object",
1323
1449
  "properties": {
@@ -1428,6 +1554,10 @@
1428
1554
  "type": "boolean",
1429
1555
  "description": "Whether to support selection-based check and rewrite functionality If true or undefined (default), the selection toggle UI will be shown and users can toggle between full content and selection modes If false, the selection toggle UI will be hidden and checkSelectionEnabled will be forced to false"
1430
1556
  },
1557
+ "supportComments": {
1558
+ "type": "boolean",
1559
+ "description": "Whether the host can anchor a comment on a span of the document via {@link PluginInterface.addComment } .\n\nWhen `true`, the sidebar offers an \"Add as Comment\" action on open issue cards. When `false` or omitted (the default), the action is hidden. Only set it when the host implements `addComment` — and, where the editor's comment API is version-gated (e.g. Word's `WordApi 1.4`), only when that API is actually available."
1560
+ },
1431
1561
  "multiAgent": {
1432
1562
  "type": "boolean",
1433
1563
  "description": "Whether the sidebar may run several agents concurrently in one check.\n\nWhen `false` or omitted (the default), only the Style agent is offered and run, and a check is dispatched as a single-agent run. When `true`, the sidebar offers every agent the organization is entitled to and fans the selected ones out through the parallel executor, streaming results per agent; each agent can then be cancelled independently of the others.\n\nThe host flag and the organization's entitlement **intersect**: enabling this never grants access to an agent the organization does not have, and an entitled agent is never offered while this is `false`."
@@ -1547,6 +1677,10 @@
1547
1677
  "type": "boolean",
1548
1678
  "description": "Whether to support selection-based check and rewrite functionality If true or undefined (default), the selection toggle UI will be shown and users can toggle between full content and selection modes If false, the selection toggle UI will be hidden and checkSelectionEnabled will be forced to false"
1549
1679
  },
1680
+ "supportComments": {
1681
+ "type": "boolean",
1682
+ "description": "Whether the host can anchor a comment on a span of the document via {@link PluginInterface.addComment } .\n\nWhen `true`, the sidebar offers an \"Add as Comment\" action on open issue cards. When `false` or omitted (the default), the action is hidden. Only set it when the host implements `addComment` — and, where the editor's comment API is version-gated (e.g. Word's `WordApi 1.4`), only when that API is actually available."
1683
+ },
1550
1684
  "multiAgent": {
1551
1685
  "type": "boolean",
1552
1686
  "description": "Whether the sidebar may run several agents concurrently in one check.\n\nWhen `false` or omitted (the default), only the Style agent is offered and run, and a check is dispatched as a single-agent run. When `true`, the sidebar offers every agent the organization is entitled to and fans the selected ones out through the parallel executor, streaming results per agent; each agent can then be cancelled independently of the others.\n\nThe host flag and the organization's entitlement **intersect**: enabling this never grants access to an agent the organization does not have, and an entitled agent is never offered while this is `false`."
@@ -1577,53 +1711,6 @@
1577
1711
  "description": "The `getInitConfig` reply as it crosses the IPC boundary: the integration's {@link SidebarConfig } plus the host adapter's own version stamp.\n\n`hostAdapterVersion` is written by the host-side adapter itself from its compiled-in {@link ADAPTER_VERSION } ; it always overwrites whatever the integration returned. Integrations never set it — their {@link PluginInterface.getInitConfig } keeps returning a plain `SidebarConfig`. The sidebar-side adapter strips it again before handing the config to the sidebar app and exposes it through `PluginAdapter.getHostAdapterVersion()`. Non-JS host ports set it themselves from their own version.",
1578
1712
  "title": "InitConfigResponse"
1579
1713
  },
1580
- "AgenticIssuePosition": {
1581
- "type": "object",
1582
- "properties": {
1583
- "start": { "type": "number" },
1584
- "end": { "type": "number" },
1585
- "text": { "type": "string" }
1586
- },
1587
- "required": ["start", "end", "text"],
1588
- "additionalProperties": false,
1589
- "description": "Character-offset span of an agentic issue within the document.",
1590
- "title": "AgenticIssuePosition"
1591
- },
1592
- "AgenticIssuePayload": {
1593
- "type": "object",
1594
- "properties": {
1595
- "id": { "type": "string" },
1596
- "groupKey": { "type": "string" },
1597
- "status": { "type": "string", "enum": ["active", "resolved", "dismissed"] },
1598
- "original": { "type": "string" },
1599
- "agent": { "type": "string" },
1600
- "explanation": { "type": "string" },
1601
- "severity": { "type": "string", "enum": ["low", "medium", "high", "critical"] },
1602
- "confidence": { "type": "number" },
1603
- "position": { "$ref": "#/components/schemas/AgenticIssuePosition" },
1604
- "suggestion": { "type": "string" },
1605
- "suggestions": { "type": "array", "items": { "type": "string" } },
1606
- "category": { "type": "string" },
1607
- "read_only": {
1608
- "type": "boolean",
1609
- "description": "When true, the host cannot apply replacements (e.g. issue points at a variable or hidden content)."
1610
- }
1611
- },
1612
- "required": [
1613
- "id",
1614
- "groupKey",
1615
- "status",
1616
- "original",
1617
- "agent",
1618
- "explanation",
1619
- "severity",
1620
- "confidence",
1621
- "position"
1622
- ],
1623
- "additionalProperties": false,
1624
- "description": "Serializable payload for a single agentic issue sent over IPC (Sidebar → Plugin). Used when streaming agent results so the plugin can render underlines or other UI.",
1625
- "title": "AgenticIssuePayload"
1626
- },
1627
1714
  "PluginInterface": {
1628
1715
  "type": "object",
1629
1716
  "properties": {
@@ -1789,6 +1876,22 @@
1789
1876
  },
1790
1877
  "description": "Write text to the system clipboard on the sidebar's behalf.\n\nOptional. When the host does not provide this, the sidebar copies with `navigator.clipboard.writeText` (falling back to `document.execCommand`). Those in-iframe paths are blocked in some embedded contexts — most notably VS Code webviews, whose Electron permission handler denies the async clipboard API to any frame that is not on the `vscode-webview://` origin, regardless of Permissions-Policy delegation.\n\nHosts with a privileged clipboard primitive should implement this with it — for example, the VS Code extension calls `vscode.env.clipboard.writeText(text)` in the extension host.\n\nThe returned promise resolves once the text has been written to the clipboard; reject to signal the write failed."
1791
1878
  },
1879
+ "addComment": {
1880
+ "$comment": "(comment: CommentRequest, documentReference?: string | null) => Promise<void>",
1881
+ "type": "object",
1882
+ "properties": {
1883
+ "namedArgs": {
1884
+ "type": "object",
1885
+ "properties": {
1886
+ "comment": { "$ref": "#/components/schemas/CommentRequest" },
1887
+ "documentReference": { "type": ["string", "null"] }
1888
+ },
1889
+ "required": ["comment"],
1890
+ "additionalProperties": false
1891
+ }
1892
+ },
1893
+ "description": "Anchor a comment on a span of the document — e.g. Word's `Range.insertComment`. The sidebar calls this when the user picks\n**Add as Comment** on an issue card.\n\nOptional. Implement it together with {@link SidebarConfig.supportComments } `: true`; the sidebar only offers the action when that flag is set. Without a handler, the call rejects with `No receiver registered for: addComment`.\n\nThe handler MUST NOT change the document text. Author attribution is the host's responsibility — the sidebar sends no user information, and editors typically attach the signed-in editor user themselves."
1894
+ },
1792
1895
  "onIntegrationSettingsChange": {
1793
1896
  "$comment": "(\n values: IntegrationSettingsValues,\n meta: IntegrationSettingsChangeMeta) => Promise<void>",
1794
1897
  "type": "object",
@@ -2047,6 +2150,62 @@
2047
2150
  }
2048
2151
  },
2049
2152
  "title": "isIntegrationSettingField"
2153
+ },
2154
+ "TextLookupErrorPayload": {
2155
+ "type": "object",
2156
+ "properties": {
2157
+ "name": { "type": "string", "const": "TextLookupError" },
2158
+ "message": { "type": "string" }
2159
+ },
2160
+ "required": ["name", "message"],
2161
+ "additionalProperties": false,
2162
+ "description": "Wire shape of the `errorJSON` payload for a `TextLookupError` thrown by a host's `selectContent` / `replaceContent` / `replaceMultipleContents`.\n\nThe receiving side rebuilds the typed error from `name` through the error registry (`ipcErrorReconstructors`), so a non-JS port must send exactly this `name` for the sidebar to recognise the failure.",
2163
+ "title": "TextLookupErrorPayload"
2164
+ },
2165
+ "ReplaceBatchFailedRange": {
2166
+ "type": "object",
2167
+ "properties": {
2168
+ "start": {
2169
+ "type": "number",
2170
+ "description": "The zero-based character offset from the beginning of the document where the content to replace starts. Must be a non-negative integer."
2171
+ },
2172
+ "end": {
2173
+ "type": "number",
2174
+ "description": "The zero-based exclusive end offset; the span replaced or selected is `[start, end)` in the document."
2175
+ },
2176
+ "message": {
2177
+ "type": "string",
2178
+ "description": "Why this occurrence failed, written for the author (e.g. \"This text was edited since the last check.\"). The sidebar shows it on that occurrence's card; when omitted it shows its own \"text could not be found\" message. The error's top-level `message` describes the batch and is shown only on the card the user applied from."
2179
+ }
2180
+ },
2181
+ "additionalProperties": false,
2182
+ "required": ["end", "start"],
2183
+ "description": "A range (as sent in the call) that the host could not apply, optionally with the reason for that one occurrence.",
2184
+ "title": "ReplaceBatchFailedRange"
2185
+ },
2186
+ "ReplaceBatchErrorPayload": {
2187
+ "type": "object",
2188
+ "properties": {
2189
+ "name": { "type": "string", "const": "ReplaceBatchError" },
2190
+ "message": { "type": "string" },
2191
+ "applied": { "type": "array", "items": { "$ref": "#/components/schemas/ContentRange" } },
2192
+ "failed": {
2193
+ "type": "array",
2194
+ "items": { "$ref": "#/components/schemas/ReplaceBatchFailedRange" }
2195
+ }
2196
+ },
2197
+ "required": ["name", "message", "applied", "failed"],
2198
+ "additionalProperties": false,
2199
+ "description": "Wire shape of the `errorJSON` payload for a `ReplaceBatchError`: a `replaceMultipleContents` batch that the host could not apply in full.\n\n`applied` lists the ranges (as sent in the call) whose replacement landed in the document; `failed` lists the ranges the host could not locate or verify, each with an optional per-occurrence `message`. A range in neither list was left untouched. A host that verifies the whole batch before editing sends every unverifiable range in `failed` and an empty `applied`.",
2200
+ "title": "ReplaceBatchErrorPayload"
2201
+ },
2202
+ "KnownIpcErrorPayload": {
2203
+ "anyOf": [
2204
+ { "$ref": "#/components/schemas/TextLookupErrorPayload" },
2205
+ { "$ref": "#/components/schemas/ReplaceBatchErrorPayload" }
2206
+ ],
2207
+ "description": "Every `errorJSON` payload the sidebar reconstructs into a typed error.",
2208
+ "title": "KnownIpcErrorPayload"
2050
2209
  }
2051
2210
  }
2052
2211
  }
@@ -1,3 +1,3 @@
1
- export { PluginAdapter } from "./pluginAdapter";
2
- export { SidebarAdapter, type SidebarAdapterOptions } from "./sidebarAdapter";
1
+ export { PluginAdapter } from "./pluginAdapter.js";
2
+ export { SidebarAdapter, type SidebarAdapterOptions } from "./sidebarAdapter.js";
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1,5 +1,5 @@
1
- import type { CallOptions, IPCConfig } from "../ipc/message-types";
2
- import type { ContentRange, ContentReplacement, ContentInfo, SidebarConfig, SidebarBuildInfo, SidebarInterface, AgenticIssuePayload, IntegrationSettingsValues, IntegrationSettingsChangeMeta } from "../types";
1
+ import type { CallOptions, IPCConfig } from "../ipc/message-types.js";
2
+ import type { CommentRequest, ContentRange, ContentReplacement, ContentInfo, SidebarConfig, SidebarBuildInfo, SidebarInterface, AgenticIssuePayload, IntegrationSettingsValues, IntegrationSettingsChangeMeta } from "../types/index.js";
3
3
  /**
4
4
  * PluginAdapter - Use in the Sidebar to communicate with the Plugin in the editor
5
5
  * This is a wrapper around PluginIPCAdapter for backwards compatibility and ease of use
@@ -89,6 +89,14 @@ export declare class PluginAdapter {
89
89
  * (`navigator.clipboard.writeText` / `document.execCommand("copy")`).
90
90
  */
91
91
  copyToClipboard(text: string): Promise<void>;
92
+ /**
93
+ * Ask the host plugin to anchor a comment on a span of the document.
94
+ * Only call it for hosts whose config sets `supportComments: true`. The
95
+ * returned promise rejects with `No receiver registered for: addComment`
96
+ * if the host has not implemented the handler, with `TextLookupError` when
97
+ * the range cannot be located, or with the host's own error otherwise.
98
+ */
99
+ addComment(comment: CommentRequest, documentReference?: string | null): Promise<void>;
92
100
  /**
93
101
  * Notify the host plugin that the user changed an integration-settings
94
102
  * value. Optional on the host side — the returned promise rejects if the
@@ -1 +1 @@
1
- {"version":3,"file":"pluginAdapter.d.ts","sourceRoot":"","sources":["../../src/adapters/pluginAdapter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,KAAK,EACV,YAAY,EACZ,kBAAkB,EAClB,WAAW,EACX,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EACnB,yBAAyB,EACzB,6BAA6B,EAC9B,MAAM,SAAS,CAAC;AAEjB;;;;;;;GAOG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAmB;gBAElC,OAAO,CAAC,EAAE,gBAAgB,EAAE,MAAM,CAAC,EAAE,SAAS,EAAE,YAAY,CAAC,EAAE,MAAM;IAKjF;;OAEG;IACI,OAAO,IAAI,IAAI;IAKtB;;;;;OAKG;IACU,aAAa,CAAC,g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,IAAI,CAAC,CAEf;IAED;;;;;OAKG;IACI,2BAA2B,CAChC,MAAM,EAAE,yBAAyB,EACjC,IAAI,EAAE,6BAA6B,GAClC,OAAO,CAAC,IAAI,CAAC,CAEf;IAED;;OAEG;IACI,SAAS,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAExC;IAED;;OAEG;IACI,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAEjD;IAED;;OAEG;IACI,eAAe,IAAI,MAAM,CAE/B;CACF"}
@@ -1,5 +1,5 @@
1
- import type { IPCConfig } from "../ipc/message-types";
2
- import type { IntegrationSettingsPatch, IntegrationSettingsSnapshot, PluginInterface, PluginStatusType, SidebarBuildInfo } from "../types";
1
+ import type { IPCConfig } from "../ipc/message-types.js";
2
+ import type { IntegrationSettingsPatch, IntegrationSettingsSnapshot, PluginInterface, PluginStatusType, SidebarBuildInfo } from "../types/index.js";
3
3
  /**
4
4
  * Options for SidebarAdapter constructor
5
5
  */
@@ -1 +1 @@
1
- {"version":3,"file":"sidebarAdapter.d.ts","sourceRoot":"","sources":["../../src/adapters/sidebarAdapter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EACV,wBAAwB,EACxB,2BAA2B,EAC3B,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,SAAS,CAAC;AAEjB;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,6DAA6D;IAC7D,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,iCAAiC;IACjC,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,+DAA+D;IAC/D,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;GAGG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAoB;gBAEnC,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,iBAAiB,EAAE,OAAO,CAAC,EAAE,qBAA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G;IACI,SAAS,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAExC;CACF"}
package/dist/errors.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import type { ContentRange } from "./types/common";
2
+ import type { ReplaceBatchFailedRange } from "./types/errors";
1
3
  /**
2
4
  * Error thrown by integration/plugin code when text lookup (e.g. selection or
3
5
  * positioning) fails. The sidebar treats this as a selection failure and can
@@ -7,9 +9,38 @@
7
9
  * replaceContent) when the requested text cannot be found or located.
8
10
  */
9
11
  export declare class TextLookupError extends Error {
10
- readonly name = "TextLookupError";
12
+ readonly name: string;
11
13
  constructor(message: string);
12
14
  }
15
+ /** Per-range outcome of a `replaceMultipleContents` batch the host could not apply in full. */
16
+ export interface ReplaceBatchOutcome {
17
+ /** Ranges (as sent in the call) whose replacement landed in the document. */
18
+ applied: ContentRange[];
19
+ /** Ranges the host could not locate or verify, each with an optional reason for that occurrence. */
20
+ failed: ReplaceBatchFailedRange[];
21
+ }
22
+ /**
23
+ * Error thrown by `replaceMultipleContents` when the batch could not be applied
24
+ * in full, carrying which ranges were `applied` and which `failed`. A range in
25
+ * neither list was left untouched.
26
+ *
27
+ * A `TextLookupError`, so a sidebar that predates this type still handles it
28
+ * as a batch failure; a sidebar that knows it resolves the applied
29
+ * occurrences, invalidates the failed ones and leaves the rest active. Throw
30
+ * it with an empty `applied` when the batch is verified before any edit.
31
+ */
32
+ export declare class ReplaceBatchError extends TextLookupError {
33
+ readonly name: string;
34
+ readonly applied: ContentRange[];
35
+ readonly failed: ReplaceBatchFailedRange[];
36
+ constructor(message: string, outcome: ReplaceBatchOutcome);
37
+ }
38
+ /**
39
+ * Type guard for ReplaceBatchError. Check it before `isTextLookupError` when
40
+ * catching from `replaceMultipleContents`: every ReplaceBatchError is also a
41
+ * TextLookupError.
42
+ */
43
+ export declare function isReplaceBatchError(error: unknown): error is ReplaceBatchError;
13
44
  /**
14
45
  * Type guard for TextLookupError. Use when catching errors from adapter methods
15
46
  * (e.g. selectContent, replaceContent) to narrow the type and handle text
@@ -26,6 +57,12 @@ export type SelectContentError = TextLookupError;
26
57
  * catching. Extend when adding new known errors for replaceContent.
27
58
  */
28
59
  export type ReplaceContentError = TextLookupError;
60
+ /**
61
+ * Union of errors that replaceMultipleContents may throw. A host that can say
62
+ * which ranges landed throws `ReplaceBatchError`; older hosts throw a plain
63
+ * `TextLookupError` for the whole batch.
64
+ */
65
+ export type ReplaceMultipleContentsError = TextLookupError | ReplaceBatchError;
29
66
  /**
30
67
  * Serialized shape of an error sent over IPC (name + message; extend for custom payloads).
31
68
  */
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,qBAAa,eAAgB,SAAQ,KAAK;IACxC,SAAkB,IAAI,qBAAqB;gBAE/B,OAAO,EAAE,MAAM;CAI5B;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,eAAe,CAE1E;AAED;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG,eAAe,CAAC;AAEjD;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAAG,eAAe,CAAC;AAElD;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,KAAK,KAAK,CAAC;AAErF;;;GAGG;AACH,eAAO,MAAM,sBAAsB,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAErE,CAAC;AAEF;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,eAAe,GAAG,KAAK,CAW/D"}
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/err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AM,MAAM,kBAAkB,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,KAAK,KAAK,CAAC;AAErF;;;GAGG;AACH,eAAO,MAAM,sBAAsB,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CASrE,CAAC;AAEF;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,eAAe,GAAG,KAAK,CAW/D"}
@@ -1,5 +1,5 @@
1
- import type { ContentRange, ContentReplacement, ContentInfo, InitConfigResponse, SidebarBuildInfo, AgenticIssuePayload, PluginStatusType } from "../types/common";
2
- import type { IntegrationSettingsValues, IntegrationSettingsChangeMeta, IntegrationSettingsPatch, IntegrationSettingsSnapshot } from "../types/integrationSettings";
1
+ import type { CommentRequest, ContentRange, ContentReplacement, ContentInfo, InitConfigResponse, SidebarBuildInfo, AgenticIssuePayload, PluginStatusType } from "../types/common.js";
2
+ import type { IntegrationSettingsValues, IntegrationSettingsChangeMeta, IntegrationSettingsPatch, IntegrationSettingsSnapshot } from "../types/integrationSettings.js";
3
3
  /**
4
4
  * Call signatures for all bidirectional IPC communication.
5
5
  * This interface maps method names to their parameter types and return types.
@@ -79,6 +79,11 @@ export interface CallSignatures {
79
79
  * See {@link PluginInterface.copyToClipboard}.
80
80
  */
81
81
  copyToClipboard(text: string): Promise<void>;
82
+ /**
83
+ * Ask the plugin to anchor a comment on a span of the document.
84
+ * See {@link PluginInterface.addComment}.
85
+ */
86
+ addComment(comment: CommentRequest, documentReference?: string | null): Promise<void>;
82
87
  /**
83
88
  * Notify plugin when the user changes a value in the integration-settings
84
89
  * form. Optional on the plugin side; absent handler is a no-op.