sophos-central-mcp-server 0.12.2 → 0.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (180) hide show
  1. package/LICENSE +0 -0
  2. package/README.md +60 -6
  3. package/dist/auth/token-manager.d.ts +0 -0
  4. package/dist/auth/token-manager.d.ts.map +0 -0
  5. package/dist/auth/token-manager.js +0 -0
  6. package/dist/auth/token-manager.js.map +0 -0
  7. package/dist/client/fusion-client.d.ts +12 -1
  8. package/dist/client/fusion-client.d.ts.map +1 -1
  9. package/dist/client/fusion-client.js +36 -3
  10. package/dist/client/fusion-client.js.map +1 -1
  11. package/dist/client/sophos-client.d.ts +0 -0
  12. package/dist/client/sophos-client.d.ts.map +0 -0
  13. package/dist/client/sophos-client.js +0 -0
  14. package/dist/client/sophos-client.js.map +0 -0
  15. package/dist/client/tenant-resolver.d.ts +0 -0
  16. package/dist/client/tenant-resolver.d.ts.map +0 -0
  17. package/dist/client/tenant-resolver.js +0 -0
  18. package/dist/client/tenant-resolver.js.map +0 -0
  19. package/dist/config/config.d.ts +0 -0
  20. package/dist/config/config.d.ts.map +0 -0
  21. package/dist/config/config.js +0 -0
  22. package/dist/config/config.js.map +0 -0
  23. package/dist/fusion/ai-defense.d.ts +227 -0
  24. package/dist/fusion/ai-defense.d.ts.map +1 -0
  25. package/dist/fusion/ai-defense.js +329 -0
  26. package/dist/fusion/ai-defense.js.map +1 -0
  27. package/dist/fusion/queries/ai-defense-activity.d.ts +27 -0
  28. package/dist/fusion/queries/ai-defense-activity.d.ts.map +1 -0
  29. package/dist/fusion/queries/ai-defense-activity.js +105 -0
  30. package/dist/fusion/queries/ai-defense-activity.js.map +1 -0
  31. package/dist/fusion/queries/ai-defense-policy.d.ts +34 -0
  32. package/dist/fusion/queries/ai-defense-policy.d.ts.map +1 -0
  33. package/dist/fusion/queries/ai-defense-policy.js +188 -0
  34. package/dist/fusion/queries/ai-defense-policy.js.map +1 -0
  35. package/dist/fusion/types.d.ts +49 -0
  36. package/dist/fusion/types.d.ts.map +1 -1
  37. package/dist/index.d.ts +0 -0
  38. package/dist/index.d.ts.map +0 -0
  39. package/dist/index.js +4 -0
  40. package/dist/index.js.map +1 -1
  41. package/dist/tools/accounts.d.ts +0 -0
  42. package/dist/tools/accounts.d.ts.map +0 -0
  43. package/dist/tools/accounts.js +0 -0
  44. package/dist/tools/accounts.js.map +0 -0
  45. package/dist/tools/admin-management.d.ts +0 -0
  46. package/dist/tools/admin-management.d.ts.map +0 -0
  47. package/dist/tools/admin-management.js +0 -0
  48. package/dist/tools/admin-management.js.map +0 -0
  49. package/dist/tools/alerts.d.ts +0 -0
  50. package/dist/tools/alerts.d.ts.map +0 -0
  51. package/dist/tools/alerts.js +0 -0
  52. package/dist/tools/alerts.js.map +0 -0
  53. package/dist/tools/audit-events.d.ts +0 -0
  54. package/dist/tools/audit-events.d.ts.map +0 -0
  55. package/dist/tools/audit-events.js +0 -0
  56. package/dist/tools/audit-events.js.map +0 -0
  57. package/dist/tools/business-automation.d.ts +0 -0
  58. package/dist/tools/business-automation.d.ts.map +0 -0
  59. package/dist/tools/business-automation.js +0 -0
  60. package/dist/tools/business-automation.js.map +0 -0
  61. package/dist/tools/cases.d.ts +0 -0
  62. package/dist/tools/cases.d.ts.map +0 -0
  63. package/dist/tools/cases.js +0 -0
  64. package/dist/tools/cases.js.map +0 -0
  65. package/dist/tools/cloud-security.d.ts +0 -0
  66. package/dist/tools/cloud-security.d.ts.map +0 -0
  67. package/dist/tools/cloud-security.js +0 -0
  68. package/dist/tools/cloud-security.js.map +0 -0
  69. package/dist/tools/detections.d.ts +0 -0
  70. package/dist/tools/detections.d.ts.map +0 -0
  71. package/dist/tools/detections.js +0 -0
  72. package/dist/tools/detections.js.map +0 -0
  73. package/dist/tools/directory.d.ts +0 -0
  74. package/dist/tools/directory.d.ts.map +0 -0
  75. package/dist/tools/directory.js +0 -0
  76. package/dist/tools/directory.js.map +0 -0
  77. package/dist/tools/dns-protection.d.ts +0 -0
  78. package/dist/tools/dns-protection.d.ts.map +0 -0
  79. package/dist/tools/dns-protection.js +0 -0
  80. package/dist/tools/dns-protection.js.map +0 -0
  81. package/dist/tools/email.d.ts +0 -0
  82. package/dist/tools/email.d.ts.map +0 -0
  83. package/dist/tools/email.js +0 -0
  84. package/dist/tools/email.js.map +0 -0
  85. package/dist/tools/endpoint-migrations.d.ts +0 -0
  86. package/dist/tools/endpoint-migrations.d.ts.map +0 -0
  87. package/dist/tools/endpoint-migrations.js +0 -0
  88. package/dist/tools/endpoint-migrations.js.map +0 -0
  89. package/dist/tools/endpoint-settings.d.ts +0 -0
  90. package/dist/tools/endpoint-settings.d.ts.map +0 -0
  91. package/dist/tools/endpoint-settings.js +0 -0
  92. package/dist/tools/endpoint-settings.js.map +0 -0
  93. package/dist/tools/endpoints.d.ts +0 -0
  94. package/dist/tools/endpoints.d.ts.map +0 -0
  95. package/dist/tools/endpoints.js +0 -0
  96. package/dist/tools/endpoints.js.map +0 -0
  97. package/dist/tools/exclusions.d.ts +0 -0
  98. package/dist/tools/exclusions.d.ts.map +0 -0
  99. package/dist/tools/exclusions.js +0 -0
  100. package/dist/tools/exclusions.js.map +0 -0
  101. package/dist/tools/firewall.d.ts +0 -0
  102. package/dist/tools/firewall.d.ts.map +0 -0
  103. package/dist/tools/firewall.js +0 -0
  104. package/dist/tools/firewall.js.map +0 -0
  105. package/dist/tools/fusion-ai-defense-activity.d.ts +19 -0
  106. package/dist/tools/fusion-ai-defense-activity.d.ts.map +1 -0
  107. package/dist/tools/fusion-ai-defense-activity.js +474 -0
  108. package/dist/tools/fusion-ai-defense-activity.js.map +1 -0
  109. package/dist/tools/fusion-ai-defense-policies.d.ts +23 -0
  110. package/dist/tools/fusion-ai-defense-policies.d.ts.map +1 -0
  111. package/dist/tools/fusion-ai-defense-policies.js +875 -0
  112. package/dist/tools/fusion-ai-defense-policies.js.map +1 -0
  113. package/dist/tools/groups.d.ts +0 -0
  114. package/dist/tools/groups.d.ts.map +0 -0
  115. package/dist/tools/groups.js +0 -0
  116. package/dist/tools/groups.js.map +0 -0
  117. package/dist/tools/health.d.ts +0 -0
  118. package/dist/tools/health.d.ts.map +0 -0
  119. package/dist/tools/health.js +0 -0
  120. package/dist/tools/health.js.map +0 -0
  121. package/dist/tools/helpers.d.ts +0 -0
  122. package/dist/tools/helpers.d.ts.map +0 -0
  123. package/dist/tools/helpers.js +0 -0
  124. package/dist/tools/helpers.js.map +0 -0
  125. package/dist/tools/licensing.d.ts +0 -0
  126. package/dist/tools/licensing.d.ts.map +0 -0
  127. package/dist/tools/licensing.js +0 -0
  128. package/dist/tools/licensing.js.map +0 -0
  129. package/dist/tools/live-discover.d.ts +0 -0
  130. package/dist/tools/live-discover.d.ts.map +0 -0
  131. package/dist/tools/live-discover.js +0 -0
  132. package/dist/tools/live-discover.js.map +0 -0
  133. package/dist/tools/mobile.d.ts +0 -0
  134. package/dist/tools/mobile.d.ts.map +0 -0
  135. package/dist/tools/mobile.js +0 -0
  136. package/dist/tools/mobile.js.map +0 -0
  137. package/dist/tools/partner.d.ts +0 -0
  138. package/dist/tools/partner.d.ts.map +0 -0
  139. package/dist/tools/partner.js +0 -0
  140. package/dist/tools/partner.js.map +0 -0
  141. package/dist/tools/policies.d.ts +0 -0
  142. package/dist/tools/policies.d.ts.map +0 -0
  143. package/dist/tools/policies.js +0 -0
  144. package/dist/tools/policies.js.map +0 -0
  145. package/dist/tools/siem.d.ts +0 -0
  146. package/dist/tools/siem.d.ts.map +0 -0
  147. package/dist/tools/siem.js +0 -0
  148. package/dist/tools/siem.js.map +0 -0
  149. package/dist/tools/switch.d.ts +0 -0
  150. package/dist/tools/switch.d.ts.map +0 -0
  151. package/dist/tools/switch.js +0 -0
  152. package/dist/tools/switch.js.map +0 -0
  153. package/dist/tools/tenants.d.ts +0 -0
  154. package/dist/tools/tenants.d.ts.map +0 -0
  155. package/dist/tools/tenants.js +0 -0
  156. package/dist/tools/tenants.js.map +0 -0
  157. package/dist/tools/user-activity.d.ts +0 -0
  158. package/dist/tools/user-activity.d.ts.map +0 -0
  159. package/dist/tools/user-activity.js +0 -0
  160. package/dist/tools/user-activity.js.map +0 -0
  161. package/dist/tools/web-filtering.d.ts +0 -0
  162. package/dist/tools/web-filtering.d.ts.map +0 -0
  163. package/dist/tools/web-filtering.js +0 -0
  164. package/dist/tools/web-filtering.js.map +0 -0
  165. package/dist/tools/wifi.d.ts +0 -0
  166. package/dist/tools/wifi.d.ts.map +0 -0
  167. package/dist/tools/wifi.js +0 -0
  168. package/dist/tools/wifi.js.map +0 -0
  169. package/dist/tools/xdr.d.ts +0 -0
  170. package/dist/tools/xdr.d.ts.map +0 -0
  171. package/dist/tools/xdr.js +0 -0
  172. package/dist/tools/xdr.js.map +0 -0
  173. package/dist/types/sophos.d.ts +0 -0
  174. package/dist/types/sophos.d.ts.map +0 -0
  175. package/dist/types/sophos.js +0 -0
  176. package/dist/types/sophos.js.map +0 -0
  177. package/docs/screenshots/tenant-health-detail.png +0 -0
  178. package/docs/screenshots/tenant-health-overview.png +0 -0
  179. package/docs/screenshots/tenant-listing.png +0 -0
  180. package/package.json +1 -1
package/LICENSE CHANGED
File without changes
package/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  > Sophos. It calls the public Sophos APIs using credentials you supply. Use it at your own
6
6
  > risk, and raise problems as issues on this repository rather than with Sophos support.
7
7
 
8
- MCP (Model Context Protocol) server for the Sophos Fusion and Sophos Central APIs. Supports partner, organisation, and single-tenant credential types with automatic region routing. **334 tools** covering 23 Sophos API namespaces: the Sophos Central REST APIs plus the Sophos Fusion GraphQL APIs (`sophos_fusion_*`). Install it as a Claude Desktop extension (`.mcpb`), run it with npx, or host it yourself over streamable HTTP.
8
+ MCP (Model Context Protocol) server for the Sophos Fusion and Sophos Central APIs. Supports partner, organisation, and single-tenant credential types with automatic region routing. **360 tools** covering 25 Sophos API namespaces: the Sophos Central REST APIs plus the Sophos Fusion GraphQL APIs (`sophos_fusion_*`). Install it as a Claude Desktop extension (`.mcpb`), run it with npx, or host it yourself over streamable HTTP.
9
9
 
10
10
  The npm package, the `.mcpb` bundle and the binaries keep the `sophos-central-mcp-server` name so existing installs update in place.
11
11
 
@@ -170,7 +170,7 @@ The script:
170
170
  npm test
171
171
  ```
172
172
 
173
- Builds, then runs the `node:test` suites in `test/` with `fetch` stubbed: the Fusion GraphQL transport (including the HTTP 200 with `errors` case), the QL builder, the reference-data cache, and the path-keyed retry for the intermittent case-write fault, the migration guard, the policy assignment and web profile writes (body shapes, refusals, target lookups and read-back) against an in-memory policy store, the no-retry rule for a POST or mutation after a 5xx, the read-modify-write and PATCH update tools, the request shapes of the tools checked against the published specs, the request shapes of the October 2026 bulk endpoint, S/MIME and Search tools, the item and page totals the REST list tools report, the endpoint inventory's reduction to the latest snapshot and its stale flag, a registration check that lists all 334 tools over an in-memory transport and checks the descriptions for the measured warnings, the `SOPHOS_FUSION_GRAPHQL_URL` check, and the HTTP transport (Origin guard, bearer token, listen address, concurrent calls) run against an in-memory Sophos. Nothing in `npm test` reaches Sophos.
173
+ Builds, then runs the `node:test` suites in `test/` with `fetch` stubbed: the Fusion GraphQL transport (including the HTTP 200 with `errors` case), the QL builder, the reference-data cache, and the path-keyed retry for the intermittent case-write fault, the migration guard, the policy assignment and web profile writes (body shapes, refusals, target lookups and read-back) against an in-memory policy store, the no-retry rule for a POST or mutation after a 5xx, the read-modify-write and PATCH update tools, the request shapes of the tools checked against the published specs, the request shapes of the October 2026 bulk endpoint, S/MIME and Search tools, the item and page totals the REST list tools report, the endpoint inventory's reduction to the latest snapshot and its stale flag, the AI Defense tools (request shapes, the HTTP 200 with `errors` case, not-found and deleted policies, the stale version hint, and the input checks that refuse before any call), a registration check that lists all 360 tools over an in-memory transport and checks the descriptions for the measured warnings, the `SOPHOS_FUSION_GRAPHQL_URL` check, and the HTTP transport (Origin guard, bearer token, listen address, concurrent calls) run against an in-memory Sophos. Nothing in `npm test` reaches Sophos.
174
174
 
175
175
  To exercise the Fusion tools against a live tenant, put credentials in `.env` (or export them) and run:
176
176
 
@@ -179,10 +179,11 @@ node scripts/fusion-smoke.mjs # read-only, tenant credential
179
179
  node scripts/fusion-smoke.mjs <tenant-id> # read-only, partner or organisation credential
180
180
  node scripts/fusion-smoke.mjs --write # plus the Fusion write tools on one new case
181
181
  node scripts/fusion-smoke.mjs --write-classic # plus the Classic case tools on one new case
182
+ node scripts/fusion-smoke.mjs --write-ai-defense # plus the AI Defense policy writes on test policies
182
183
  node scripts/fusion-smoke.mjs --all # everything
183
184
  ```
184
185
 
185
- It spawns the built server over stdio and calls the tools through an MCP client, so what runs is what a host runs. Read-only mode covers the reference data, the case list with filter and cursor variants, the newest case by short ID, its evidence, summary, comments and files, the detection search, a small Data Lake search (start, poll, one page of results), the not-found and legacy-ID refusals, and the Classic side: on a migrated tenant the migration refusal, otherwise the six Classic read tools. `--write` creates one case titled `MCP smoke test <timestamp>` (managed_by CUSTOMER), exercises comment add, edit and delete with the mention read-back, link create, update and delete, tag merge and replace, evidence add and remove_all, file upload, list and soft delete, the verdict clear on reopen, the one way door on new and the closed-case freeze, then closes it with a verdict and archives it (Fusion has no delete). `--write-classic` creates, updates and deletes one Classic case; the Cases API requires an assignee and a detection that still exists, so set `SMOKE_CLASSIC_ASSIGNEE` (a tenant admin email) and, if needed, `SMOKE_CLASSIC_DETECTION_ID` (a recent detection ID). Every write is listed at the end. Existing cases are never modified.
186
+ It spawns the built server over stdio and calls the tools through an MCP client, so what runs is what a host runs. Read-only mode covers the reference data, the case list with filter and cursor variants, the newest case by short ID, its evidence, summary, comments and files, the detection search, a small Data Lake search (start, poll, one page of results), the not-found and legacy-ID refusals, the AI Defense reads (policies, previews, templates, activities, inventories, settings), and the Classic side: on a migrated tenant the migration refusal, otherwise the six Classic read tools. `--write` creates one case titled `MCP smoke test <timestamp>` (managed_by CUSTOMER), exercises comment add, edit and delete with the mention read-back, link create, update and delete, tag merge and replace, evidence add and remove_all, file upload, list and soft delete, the verdict clear on reopen, the one way door on new and the closed-case freeze, then closes it with a verdict and archives it (Fusion has no delete). `--write-ai-defense` creates policies named `ZZ Claude MCP test <timestamp> ...`, scoped to a made-up user so they enforce on nobody, then updates, enables, disables, clones and moves them (and reorders them when they are the only reorderable policies on the tenant), reads each write back and deletes them; it never writes the tenant settings. `--write-classic` creates, updates and deletes one Classic case; the Cases API requires an assignee and a detection that still exists, so set `SMOKE_CLASSIC_ASSIGNEE` (a tenant admin email) and, if needed, `SMOKE_CLASSIC_DETECTION_ID` (a recent detection ID). Every write is listed at the end. Existing cases are never modified.
186
187
 
187
188
  **Cutting a release:** bump `version` in `package.json`, run `npm run build:mcpb`, commit `package.json`, `package-lock.json`, and `manifest.json`, tag, and attach the `.mcpb` from `release/` to the GitHub release. Publish to npm as before so the Claude Code and self-hosted options pick up the same version.
188
189
 
@@ -198,7 +199,7 @@ It spawns the built server over stdio and calls the tools through an MCP client,
198
199
  - **One-click install**: Ships as a Claude Desktop extension (`.mcpb`) with credentials held in the OS secure store
199
200
  - **Two API generations**: the Sophos Central REST APIs and the Sophos Fusion GraphQL APIs on one credential, with `sophos_fusion_*` tools for the GraphQL side
200
201
  - **Migration aware**: the Classic case and detection tools refuse a tenant that has moved to Sophos Fusion and name the `sophos_fusion_*` tool to use instead; `sophos_fusion_list_case_reference_data` reports the tenant type
201
- - **Full API coverage**: 334 tools across endpoints, alerts, policies, firewalls, web filtering, licensing, audit events, email (including S/MIME), mobile, XDR, Data Lake search, cases, SIEM, and more
202
+ - **Full API coverage**: 360 tools across endpoints, alerts, policies, firewalls, web filtering, licensing, audit events, email (including S/MIME), mobile, XDR, Data Lake search, cases, AI Defense, SIEM, and more
202
203
 
203
204
  ## Screenshots
204
205
 
@@ -247,7 +248,7 @@ The server speaks to two Sophos API generations on one credential:
247
248
  - **Sophos Central REST APIs** (retained). Every tool without the `fusion` prefix. Regional hosts, discovered from `/whoami/v1`.
248
249
  - **Sophos Fusion GraphQL APIs** (new, 18/09/2026). The `sophos_fusion_*` tools. One endpoint, `https://api.taegis.sophos.com/graphql`, same token, same `X-Tenant-ID` header. Filters are written in Fusion Query Language (QL). Case types, statuses and verdicts are tenant reference data resolved to IDs at runtime, case severity is an integer (2 to 10), and assignees are Subject IDs, not email addresses. A GraphQL failure arrives as HTTP 200 with an `errors` array; the client treats that as an error, and a partial response (data plus errors) is returned with a `warnings` list rather than as a clean result.
249
250
 
250
- Sophos is moving tenants to Fusion over the coming months (the [upgrade centre](https://community.sophos.com/sophos-xdr/sophos-xdr-mdr-expansion/upgrade-center) announces each account's slot). This is a point in time change, not a fallback: once a tenant has moved, the Classic Cases and Detections REST APIs reference the pre-migration Sophos Central objects, so their answers are wrong rather than stale. The Classic tools therefore check which world a tenant is in before every call, using the tenant record's `xdrOwnership` from the Fusion GraphQL endpoint (`sophos` means not yet upgraded, `securityOperations` means upgraded; case types don't decide it, because a tenant not yet upgraded can list them too; a tenant Fusion does not hold at all gets a 503 "not found or not accessible", which reads as not moved; each answer is held for 15 minutes, and when `xdrOwnership` can't be read, an empty case type list still means not moved and anything else runs the Classic tool with a warning), and refuse a migrated tenant with a message naming the `sophos_fusion_*` tool to use. For a tenant that has not moved they stay correct and carry no deprecation label. Fusion holds a separate case set (a UUID plus a `CSE#####` short ID) and neither ID form resolves in the other API. Live Discover and XDR Query are unaffected. Data Lake search over GraphQL shipped on 12/10/2026 as the Search GraphQL API (`sophos_fusion_create_search` and friends); the SQL XDR Query API stays available, and `sophos_run_xdr_query` stays on it. Fusion tools for events, threat timeline and live endpoint search are planned.
251
+ Sophos is moving tenants to Fusion over the coming months (the [upgrade centre](https://community.sophos.com/sophos-xdr/sophos-xdr-mdr-expansion/upgrade-center) announces each account's slot). This is a point in time change, not a fallback: once a tenant has moved, the Classic Cases and Detections REST APIs reference the pre-migration Sophos Central objects, so their answers are wrong rather than stale. The Classic tools therefore check which world a tenant is in before every call, using the tenant record's `xdrOwnership` from the Fusion GraphQL endpoint (`sophos` means not yet upgraded, `securityOperations` means upgraded; case types don't decide it, because a tenant not yet upgraded can list them too; a tenant Fusion does not hold at all gets a 503 "not found or not accessible", which reads as not moved; each answer is held for 15 minutes, and when `xdrOwnership` can't be read, an empty case type list still means not moved and anything else runs the Classic tool with a warning), and refuse a migrated tenant with a message naming the `sophos_fusion_*` tool to use. For a tenant that has not moved they stay correct and carry no deprecation label. Fusion holds a separate case set (a UUID plus a `CSE#####` short ID) and neither ID form resolves in the other API. Live Discover and XDR Query are unaffected. Data Lake search over GraphQL shipped on 12/10/2026 as the Search GraphQL API (`sophos_fusion_create_search` and friends); the SQL XDR Query API stays available, and `sophos_run_xdr_query` stays on it. The AI Defense Policy and Activity GraphQL APIs shipped on 15/10/2026 and run on the same endpoint (`sophos_fusion_ai_defense_*`). Fusion tools for events, threat timeline and live endpoint search are planned.
251
252
 
252
253
  Two Fusion case writes, `createCase` and `addEvidenceToCase`, fail 74% of the time with `not allowed` on `partnerPreferences` from `investigations-v2`. It is an intermittent downstream fault, not authorisation: the identical call succeeds on retry, and `updateCase` does not carry the fault at all. Measured on a live tenant 22/09/2026: 111 faults in 150 calls, drifting from 60% to 85% across four samples six minutes apart. The client retries a call whose first error path is `partnerPreferences`, and only that, up to 20 times with a short backoff, which leaves about 1 call in 410 failing at the measured rate and about 1 in 26 at the worst rate observed; an error naming the operation in its path is a real input or permission error and surfaces at once.
253
254
 
@@ -517,6 +518,54 @@ Filter by `endpoint_id`, `hostname`, `software_name` (softwareinfo) or `kb` (pat
517
518
  |------|-------------|
518
519
  | `sophos_fusion_endpoint_inventory` | Latest inventory snapshot per device, with stale, fresh and unmatched counts |
519
520
 
521
+ ### AI Defense Policies (18 tools)
522
+
523
+ Sophos AI Defense Policy GraphQL API v1 (15/10/2026), on the Fusion GraphQL endpoint with the same credential. Policies run in priority order (rank 1 first) and rules run top to bottom within a policy; the first matching rule wins. One base policy (kind `TENANT_BASE`) sits last as the catch-all. Rules, sensors and the base rule keep the API's own field names, so you can read a policy with `sophos_fusion_ai_defense_get_policy`, edit it and send it back. A rule targets the app catalog with conditions such as `{ dimension: "risk_level", operator: "IN", values: ["critical"] }`. A misspelled dimension matches nothing and raises no error, so preview a rule before you save it.
524
+
525
+ Measured on live tenants (07/11/2026): at least one sensor must be enabled. An empty Endpoint scope means everyone, which only the base policy may use, so enabling a policy with one is refused. Tag values must be strings. A new policy or clone lands at rank 1, disabled unless created enabled. Every write raises the policy's `version`, enable and disable included, and an update that sends a stale version is refused. On update, `rules` replaces the whole list and `tags` the whole map, but an empty `tags` map or null is ignored (08/11/2026), so tags can't be cleared through the API and the tool refuses an empty map. `sophos_fusion_ai_defense_reorder_policies` needs every reorderable policy ID. Deletion can't be undone. The base policy can't be disabled, deleted, cloned or moved, so creating one needs `confirm_base_policy`.
526
+
527
+ A policy write Sophos answers with no result (an `enablePolicy` once answered HTTP 200 with an empty body) is not sent again: the tool reads the policy back and reports `status: "unclear"`, `took_effect` (true, false, or null when the read can't tell), what it found and the state it read. The result is an error unless the change reads back in place. Create and clone have no ID to read, so their read-back looks for a policy with the expected name created since the request.
528
+
529
+ | Tool | Description |
530
+ |------|-------------|
531
+ | `sophos_fusion_ai_defense_list_policies` | Policies in priority order with rules, sensors and scope; filter by state, origin, kind or name |
532
+ | `sophos_fusion_ai_defense_get_policy` | One policy, optionally with the applications each rule matches |
533
+ | `sophos_fusion_ai_defense_get_app_sanctioning` | Approved, blocked, warned or not covered, per app and per enforcement target |
534
+ | `sophos_fusion_ai_defense_preview_rule_target` | The catalog apps one rule matches (up to 500) and the domains and apps it enforces |
535
+ | `sophos_fusion_ai_defense_preview_rule_targets` | An ordered rule list, with what each rule acts on after the rules above it |
536
+ | `sophos_fusion_ai_defense_preview_impact` | Blocked, warned and allowed counts for a rule list against the catalog |
537
+ | `sophos_fusion_ai_defense_list_templates` | The starter templates Sophos ships, optionally with their impact |
538
+ | `sophos_fusion_ai_defense_get_template` | One starter template with its impact |
539
+ | `sophos_fusion_ai_defense_list_mechanisms` | The enforcement mechanisms (web control and app control) |
540
+ | `sophos_fusion_ai_defense_get_policy_activity` | Which enabled policies matched activity in a window, and which blocked the most |
541
+ | `sophos_fusion_ai_defense_create_policy` | Create a policy, optionally from a starter template |
542
+ | `sophos_fusion_ai_defense_update_policy` | Change name, description, rules, base rule, sensors or tags (needs the current version) |
543
+ | `sophos_fusion_ai_defense_delete_policy` | Delete a policy (no restore) |
544
+ | `sophos_fusion_ai_defense_enable_policy` | Enable a policy and distribute it to its sensors |
545
+ | `sophos_fusion_ai_defense_disable_policy` | Disable a policy and remove its enforcement |
546
+ | `sophos_fusion_ai_defense_move_policy` | Move one policy to the top or straight after another |
547
+ | `sophos_fusion_ai_defense_reorder_policies` | Set the whole priority order |
548
+ | `sophos_fusion_ai_defense_clone_policy` | Copy a policy into a new disabled one |
549
+
550
+ ### AI Defense Activity (8 tools)
551
+
552
+ Sophos AI Defense Activity GraphQL API v1 (15/10/2026): the AI activity AI Defense observes, the app and user inventory built from it, and the tenant's AI Defense settings. The window defaults to since 00:00 UTC today. Set a relative `time_range` (such as `SINCE_BEGINNING_OF_MONTH` or `LAST_MONTH`) or `start_time` and `end_time`, not both. Activities page by cursor and the inventories by offset, up to 100 a page. A year of data took up to 22 seconds on a busy tenant, so the server waits up to 90 seconds for these reads.
553
+
554
+ The live API differs from the published reference in two places (07/11/2026). It does not serve the per-app training, compliance and category fields the reference lists on the app inventory, so the tool leaves them out; filter on them instead, or read them on an activity. The activities list returns `additionalData` as null where the reference says empty, and that fails the whole page, so source IP addresses come only from `sophos_fusion_ai_defense_get_activity`.
555
+
556
+ `sophos_fusion_ai_defense_update_settings` replaces the onboarding selections as a whole, and an update with no selections clears them as well, so the tool requires them. Read the settings first and send back what you keep.
557
+
558
+ | Tool | Description |
559
+ |------|-------------|
560
+ | `sophos_fusion_ai_defense_list_activities` | AI activity with action, policy, risk, user, app, model and device; filter by any of them |
561
+ | `sophos_fusion_ai_defense_get_activity` | One activity with its source IP addresses |
562
+ | `sophos_fusion_ai_defense_list_app_inventory` | AI apps seen, with risk, usage, users, last seen and unsanctioned use |
563
+ | `sophos_fusion_ai_defense_list_user_inventory` | Users seen, with worst risk, apps used, violations and top app |
564
+ | `sophos_fusion_ai_defense_list_user_apps` | The apps one user used |
565
+ | `sophos_fusion_ai_defense_inventory_summary` | App and user counts by risk level |
566
+ | `sophos_fusion_ai_defense_get_settings` | Onboarding status and selections, and the AI Defense license state |
567
+ | `sophos_fusion_ai_defense_update_settings` | Set the onboarding status and selections |
568
+
520
569
  ### Detections (6 tools)
521
570
 
522
571
  Sophos Central Detections REST API, async: start a query, poll for completion, then fetch results. Refused for a tenant that has moved to Fusion, with a pointer to `sophos_fusion_search_detections`.
@@ -843,6 +892,9 @@ src/
843
892
  │ ├── queries/cases.ts # Cases v2 GraphQL documents
844
893
  │ ├── queries/detections.ts # Detections v2 documents: the case summary lookup and the QL search
845
894
  │ ├── queries/search.ts # Search v1 documents: create, get-or-create, status, results
895
+ │ ├── queries/ai-defense-policy.ts # AI Defense Policy v1 documents
896
+ │ ├── queries/ai-defense-activity.ts # AI Defense Activity v1 documents
897
+ │ ├── ai-defense.ts # AI Defense input schemas, time window, error translation
846
898
  │ ├── inventory.ts # Inventory QL, latest snapshot per device, stale flag
847
899
  │ ├── case-reference-data.ts # Per-tenant cache of case types, statuses, verdicts
848
900
  │ ├── cases-ql.ts # QL builder for the cases search
@@ -855,6 +907,8 @@ src/
855
907
  │ ├── fusion-detections.ts # Sophos Fusion detection search (GraphQL)
856
908
  │ ├── fusion-search.ts # Sophos Fusion Data Lake search (GraphQL)
857
909
  │ ├── fusion-inventory.ts # Sophos Fusion endpoint inventory with last seen
910
+ │ ├── fusion-ai-defense-policies.ts # Sophos AI Defense policies, previews, templates (GraphQL)
911
+ │ ├── fusion-ai-defense-activity.ts # Sophos AI Defense activity, inventory, settings (GraphQL)
858
912
  │ ├── tenants.ts # Tenant listing (partner/org only)
859
913
  │ ├── partner.ts # Partner admin, roles, billing (partner/org only)
860
914
  │ ├── alerts.ts # Alert list, get, acknowledge, search
@@ -883,7 +937,7 @@ src/
883
937
  └── types/sophos.ts # Sophos API response types
884
938
  ```
885
939
 
886
- Packaging files at the repo root: `manifest.json` (MCPB manifest, regenerated by the build), `scripts/build-mcpb.mjs` (bundle builder), and `.mcpbignore` (extra exclusions applied when packing). `schemas/fusion/` holds the six Fusion GraphQL schemas as downloaded from `https://developer.sophos.com/assets/graphql/<api>.graphql` (five on 21/09/2026, `search-v1` on 29/10/2026), unmodified, for reference and for diffing when Sophos changes them. `test/` holds the `node:test` suites and `scripts/fusion-smoke.mjs` the live check.
940
+ Packaging files at the repo root: `manifest.json` (MCPB manifest, regenerated by the build), `scripts/build-mcpb.mjs` (bundle builder), and `.mcpbignore` (extra exclusions applied when packing). `schemas/fusion/` holds the eight Fusion GraphQL schemas as downloaded from `https://developer.sophos.com/assets/graphql/<api>.graphql` (five on 21/09/2026, `search-v1` on 29/10/2026, the two AI Defense schemas on 07/11/2026), unmodified, for reference and for diffing when Sophos changes them. `test/` holds the `node:test` suites and `scripts/fusion-smoke.mjs` the live check.
887
941
 
888
942
  ## Security
889
943
 
File without changes
File without changes
File without changes
File without changes
@@ -104,6 +104,16 @@ export declare class FusionTenantNotOnFusionError extends Error {
104
104
  readonly tenantId: string;
105
105
  constructor(message: string, tenantId: string);
106
106
  }
107
+ /**
108
+ * Thrown for a mutation answered HTTP 200 with no result: an empty or
109
+ * unreadable body, or a body with neither data nor errors. An AI Defense
110
+ * enablePolicy answered 200 with an empty body (live, 08/11/2026). The
111
+ * mutation may have taken effect, so it is never sent again; read the state
112
+ * back instead.
113
+ */
114
+ export declare class FusionNoResultError extends Error {
115
+ constructor(message: string);
116
+ }
107
117
  export declare class FusionClient {
108
118
  private tokenManager;
109
119
  private readonly url;
@@ -120,7 +130,8 @@ export declare class FusionClient {
120
130
  *
121
131
  * Returns the `data` object plus any partial-response warnings. Throws
122
132
  * FusionGraphQLError when the response carries errors and no usable data,
123
- * and a plain Error for transport failures. The transient partnerPreferences
133
+ * FusionNoResultError when a mutation is answered 200 with no result, and
134
+ * a plain Error for transport failures. The transient partnerPreferences
124
135
  * fault is retried up to transientAttempts times; every other GraphQL-layer
125
136
  * error surfaces at once. options.timeoutMs replaces the per-attempt timeout
126
137
  * for this call, for an operation known to run longer (a Search results page).
@@ -1 +1 @@
1
- {"version":3,"file":"fusion-client.d.ts","sourceRoot":"","sources":["../../src/client/fusion-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAK7D,sDAAsD;AACtD,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;IAC9B,SAAS,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACpD,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACtC;AAED,UAAU,mBAAmB,CAAC,CAAC;IAC7B,IAAI,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC;IAChB,MAAM,CAAC,EAAE,iBAAiB,EAAE,CAAC;CAC9B;AAED,MAAM,WAAW,iBAAiB,CAAC,CAAC;IAClC,qFAAqF;IACrF,IAAI,EAAE,CAAC,CAAC;IACR;;;;OAIG;IACH,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,MAAM,WAAW,mBAAmB;IAClC,+DAA+D;IAC/D,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,gEAAgE;IAChE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kFAAkF;IAClF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,qEAAqE;IACrE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;;;;;;OASG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,oGAAoG;IACpG,kBAAkB,C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O,CAAC,QAAQ,CAAC,kBAAkB,CAAS;gBAGlC,YAAY,EAAE,YAAY,EAClC,OAAO,GAAE,mBAAwB;IAUnC,yCAAyC;IACzC,IAAI,QAAQ,IAAI,MAAM,CAErB;IAED;;;;;;;;;;OAUG;IACG,KAAK,CAAC,CAAC,SAAS,MAAM,EAC1B,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,SAAS,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,EACvC,OAAO,GAAE,kBAAuB,GAC/B,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC;IA2ChC;;;;;;OAMG;IACG,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA6BrF;;;;;OAKG;YACW,gBAAgB;IAyH9B,OAAO,CAAC,KAAK;CAGd;AAED;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,MAAM,EACnD,IAAI,EAAE,mBAAmB,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,SAAS,GAC9C,iBAAiB,CAAC,CAAC,CAAC,CAqBtB;AASD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,CAUnE;AAED,mFAAmF;AACnF,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAEpD"}
@@ -68,6 +68,20 @@ export class FusionTenantNotOnFusionError extends Error {
68
68
  this.name = "FusionTenantNotOnFusionError";
69
69
  }
70
70
  }
71
+ /**
72
+ * Thrown for a mutation answered HTTP 200 with no result: an empty or
73
+ * unreadable body, or a body with neither data nor errors. An AI Defense
74
+ * enablePolicy answered 200 with an empty body (live, 08/11/2026). The
75
+ * mutation may have taken effect, so it is never sent again; read the state
76
+ * back instead.
77
+ */
78
+ export class FusionNoResultError extends Error {
79
+ constructor(message) {
80
+ super(message);
81
+ this.name = "FusionNoResultError";
82
+ }
83
+ }
84
+ const MUTATION_NOT_RETRIED = "Not retried: the mutation may already have taken effect, so check whether it did before repeating it.";
71
85
  const TENANT_NOT_ON_FUSION = /\btenant (\S+) not found or not accessible\b/i;
72
86
  export class FusionClient {
73
87
  tokenManager;
@@ -95,7 +109,8 @@ export class FusionClient {
95
109
  *
96
110
  * Returns the `data` object plus any partial-response warnings. Throws
97
111
  * FusionGraphQLError when the response carries errors and no usable data,
98
- * and a plain Error for transport failures. The transient partnerPreferences
112
+ * FusionNoResultError when a mutation is answered 200 with no result, and
113
+ * a plain Error for transport failures. The transient partnerPreferences
99
114
  * fault is retried up to transientAttempts times; every other GraphQL-layer
100
115
  * error surfaces at once. options.timeoutMs replaces the per-attempt timeout
101
116
  * for this call, for an operation known to run longer (a Search results page).
@@ -116,6 +131,9 @@ export class FusionClient {
116
131
  const mutation = isMutation(document);
117
132
  for (let attempt = 1;; attempt++) {
118
133
  const body = await this.executeWithRetry(fetchOptions, mutation, timeoutMs);
134
+ if (mutation && hasNeitherDataNorErrors(body)) {
135
+ throw new FusionNoResultError(`Sophos Fusion API returned neither data nor errors. ${MUTATION_NOT_RETRIED}`);
136
+ }
119
137
  try {
120
138
  return interpretGraphQLBody(body);
121
139
  }
@@ -228,7 +246,12 @@ export class FusionClient {
228
246
  return JSON.parse(text);
229
247
  }
230
248
  catch {
231
- throw new Error(`Sophos Fusion API returned a non-JSON body with status ${response.status}: ${text.slice(0, 200)}`);
249
+ const reason = text.trim() === ""
250
+ ? `Sophos Fusion API returned an empty body with status ${response.status}`
251
+ : `Sophos Fusion API returned a non-JSON body with status ${response.status}: ${text.slice(0, 200)}`;
252
+ if (mutation)
253
+ throw new FusionNoResultError(`${reason}. ${MUTATION_NOT_RETRIED}`);
254
+ throw new Error(reason);
232
255
  }
233
256
  }
234
257
  catch (error) {
@@ -250,8 +273,12 @@ export class FusionClient {
250
273
  if (lastError instanceof SophosRedirectError) {
251
274
  throw lastError;
252
275
  }
276
+ // A 200 with no result: already says the mutation may have taken effect
277
+ if (lastError instanceof FusionNoResultError) {
278
+ throw lastError;
279
+ }
253
280
  if (mutation) {
254
- throw new Error(`${lastError.message}. Not retried: the mutation may already have taken effect, so check whether it did before repeating it.`);
281
+ throw new Error(`${lastError.message}. ${MUTATION_NOT_RETRIED}`);
255
282
  }
256
283
  if (attempt < this.retries) {
257
284
  // Full-jitter exponential backoff, as the Sophos rate-limit guidance recommends
@@ -293,6 +320,12 @@ export function interpretGraphQLBody(body) {
293
320
  }
294
321
  return { data, warnings: errors.map(formatGraphQLError) };
295
322
  }
323
+ /** True for a body interpretGraphQLBody rejects as holding neither data nor errors. */
324
+ function hasNeitherDataNorErrors(body) {
325
+ const errors = Array.isArray(body?.errors) ? body.errors : [];
326
+ const data = body?.data;
327
+ return errors.length === 0 && (data === null || data === undefined || typeof data !== "object");
328
+ }
296
329
  export function formatGraphQLError(error) {
297
330
  const parts = [error.message || "Unknown GraphQL error"];
298
331
  if (error.path && error.path.length > 0) {
@@ -1 +1 @@
1
- {"version":3,"file":"fusion-client.js","sourceRoot":"","sources":["../../src/client/fusion-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAGhE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAwDpE,MAAM,wBAAwB,GAAG,IAAI,CAAC;AAEtC,uEAAuE;AACvE,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAGhC;IAFX,YACE,OAAe,EACN,MAA2B;QAEpC,KAAK,CAAC,OAAO,CAAC,CAAC;QAFN,WAAM,GAAN,MAAM,CAAqB;QAGpC,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;IAED;;;;OAIG;IACH,IAAI,QAAQ;QACV,OAAO,CACL,IAAI,CAAC,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CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACxC,KAAK,CAAC,IAAI,CAAC,UAAU,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAChD,CAAC;IACD,MAAM,IAAI,GAAG,KAAK,CAAC,UAAU,EAAE,IAAI,CAAC;IACpC,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,EAAE,CAAC;QACrC,KAAK,CAAC,IAAI,CAAC,IAAI,IAAI,GAAG,CAAC,CAAC;IAC1B,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACzB,CAAC;AAED,mFAAmF;AACnF,MAAM,UAAU,UAAU,CAAC,QAAgB;IACzC,OAAO,8BAA8B,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AACvD,CAAC"}
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,227 @@
1
+ /**
2
+ * Shared input schemas, input builders and error translation for the Sophos
3
+ * AI Defense tools (AI Defense Policy and Activity GraphQL APIs v1, on the
4
+ * Sophos Fusion GraphQL endpoint).
5
+ *
6
+ * Nested policy inputs (rules, sensors, baseRule, onboarding selections) keep
7
+ * the API's own field names, because a policy read returns them that way and
8
+ * the usual edit is read, change, send back. Fields a read returns but an
9
+ * input does not take (a rule's position and previews) are accepted and
10
+ * dropped; anything else unknown is refused rather than ignored.
11
+ *
12
+ * Measured on live tenants 07/11/2026 (see CLAUDE.md for the full list).
13
+ */
14
+ import { z } from "zod";
15
+ import { type FusionClient } from "../client/fusion-client.js";
16
+ import type { AiDefensePolicy } from "./types.js";
17
+ export declare const RELATIVE_TIME_RANGES: readonly ["SINCE_BEGINNING_OF_DAY", "SINCE_BEGINNING_OF_WEEK_SUNDAY", "SINCE_BEGINNING_OF_WEEK_MONDAY", "SINCE_BEGINNING_OF_MONTH", "SINCE_BEGINNING_OF_QUARTER", "SINCE_BEGINNING_OF_YEAR", "LAST_MONTH", "LAST_QUARTER", "LAST_YEAR"];
18
+ export declare const POLICY_ACTIONS: readonly ["BLOCK", "WARN", "ALLOW"];
19
+ export declare const ENFORCEMENT_MECHANISMS: readonly ["WEB_CONTROL", "APP_CONTROL"];
20
+ export declare const RISK_LEVELS: readonly ["UNKNOWN", "INFO", "LOW", "MEDIUM", "HIGH", "CRITICAL", "ERROR"];
21
+ export declare const SORT_ORDERS: readonly ["ASC", "DESC"];
22
+ /** Page sizes: policies and activities take up to 100; the inventories cap a larger limit to 100 silently. */
23
+ export declare const AI_DEFENSE_MAX_PAGE = 100;
24
+ export declare const tenantIdField: z.ZodOptional<z.ZodString>;
25
+ export declare const policyIdField: z.ZodString;
26
+ /** time_range, start_time and end_time: a relative preset or absolute bounds, not both. */
27
+ export declare const timeRangeFields: {
28
+ time_range: z.ZodOptional<z.ZodEnum<{
29
+ SINCE_BEGINNING_OF_DAY: "SINCE_BEGINNING_OF_DAY";
30
+ SINCE_BEGINNING_OF_WEEK_SUNDAY: "SINCE_BEGINNING_OF_WEEK_SUNDAY";
31
+ SINCE_BEGINNING_OF_WEEK_MONDAY: "SINCE_BEGINNING_OF_WEEK_MONDAY";
32
+ SINCE_BEGINNING_OF_MONTH: "SINCE_BEGINNING_OF_MONTH";
33
+ SINCE_BEGINNING_OF_QUARTER: "SINCE_BEGINNING_OF_QUARTER";
34
+ SINCE_BEGINNING_OF_YEAR: "SINCE_BEGINNING_OF_YEAR";
35
+ LAST_MONTH: "LAST_MONTH";
36
+ LAST_QUARTER: "LAST_QUARTER";
37
+ LAST_YEAR: "LAST_YEAR";
38
+ }>>;
39
+ start_time: z.ZodOptional<z.ZodString>;
40
+ end_time: z.ZodOptional<z.ZodString>;
41
+ };
42
+ export interface TimeRangeArgs {
43
+ time_range?: (typeof RELATIVE_TIME_RANGES)[number];
44
+ start_time?: string;
45
+ end_time?: string;
46
+ }
47
+ /**
48
+ * The SecureAITimeRange to send, or undefined for the API's default. Both
49
+ * forms together is refused here: the API rejects the pair with only
50
+ * "input: failed to retrieve activities" (measured 07/11/2026).
51
+ */
52
+ export declare function buildTimeRange(args: TimeRangeArgs): Record<string, string> | undefined;
53
+ export declare const conditionSchema: z.ZodObject<{
54
+ dimension: z.ZodString;
55
+ operator: z.ZodEnum<{
56
+ IN: "IN";
57
+ MISSING_ANY: "MISSING_ANY";
58
+ }>;
59
+ values: z.ZodArray<z.ZodString>;
60
+ }, z.core.$strict>;
61
+ export declare const ruleSchema: z.ZodObject<{
62
+ target: z.ZodObject<{
63
+ conditions: z.ZodArray<z.ZodObject<{
64
+ dimension: z.ZodString;
65
+ operator: z.ZodEnum<{
66
+ IN: "IN";
67
+ MISSING_ANY: "MISSING_ANY";
68
+ }>;
69
+ values: z.ZodArray<z.ZodString>;
70
+ }, z.core.$strict>>;
71
+ }, z.core.$strict>;
72
+ action: z.ZodEnum<{
73
+ BLOCK: "BLOCK";
74
+ WARN: "WARN";
75
+ ALLOW: "ALLOW";
76
+ }>;
77
+ enforcementMechanismOverride: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodEnum<{
78
+ WEB_CONTROL: "WEB_CONTROL";
79
+ APP_CONTROL: "APP_CONTROL";
80
+ }>>>>;
81
+ note: z.ZodOptional<z.ZodNullable<z.ZodString>>;
82
+ dataControls: z.ZodOptional<z.ZodNullable<z.ZodObject<{
83
+ clipboardCopy: z.ZodEnum<{
84
+ warn: "warn";
85
+ allow: "allow";
86
+ block: "block";
87
+ }>;
88
+ clipboardPaste: z.ZodEnum<{
89
+ warn: "warn";
90
+ allow: "allow";
91
+ block: "block";
92
+ }>;
93
+ upload: z.ZodEnum<{
94
+ warn: "warn";
95
+ allow: "allow";
96
+ block: "block";
97
+ }>;
98
+ download: z.ZodEnum<{
99
+ warn: "warn";
100
+ allow: "allow";
101
+ block: "block";
102
+ }>;
103
+ }, z.core.$strict>>>;
104
+ position: z.ZodOptional<z.ZodUnknown>;
105
+ targetPreview: z.ZodOptional<z.ZodUnknown>;
106
+ targetPreviewV2: z.ZodOptional<z.ZodUnknown>;
107
+ }, z.core.$strict>;
108
+ export type RuleArg = z.infer<typeof ruleSchema>;
109
+ /** The PolicyRuleInput for a rule, without the read-only fields. */
110
+ export declare function toRuleInput(rule: RuleArg): Record<string, unknown>;
111
+ export declare const sensorsSchema: z.ZodObject<{
112
+ endpoint: z.ZodOptional<z.ZodNullable<z.ZodObject<{
113
+ enabled: z.ZodBoolean;
114
+ scope: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
115
+ }, z.core.$strict>>>;
116
+ firewall: z.ZodOptional<z.ZodNullable<z.ZodObject<{
117
+ enabled: z.ZodBoolean;
118
+ scope: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
119
+ }, z.core.$strict>>>;
120
+ dns: z.ZodOptional<z.ZodNullable<z.ZodObject<{
121
+ enabled: z.ZodBoolean;
122
+ scope: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
123
+ }, z.core.$strict>>>;
124
+ browser: z.ZodOptional<z.ZodNullable<z.ZodObject<{
125
+ enabled: z.ZodBoolean;
126
+ scope: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
127
+ }, z.core.$strict>>>;
128
+ }, z.core.$strict>;
129
+ export declare const baseRuleSchema: z.ZodObject<{
130
+ generativeAiCategoryAction: z.ZodOptional<z.ZodEnum<{
131
+ BLOCK: "BLOCK";
132
+ WARN: "WARN";
133
+ ALLOW: "ALLOW";
134
+ }>>;
135
+ appControlCategoryAction: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
136
+ BLOCK: "BLOCK";
137
+ WARN: "WARN";
138
+ ALLOW: "ALLOW";
139
+ }>>>;
140
+ }, z.core.$strict>;
141
+ export declare const tagsSchema: z.ZodRecord<z.ZodString, z.ZodString>;
142
+ /**
143
+ * On update, a tags map with at least one key replaces the stored map, while
144
+ * an empty map or null is ignored (and still raises the version), so tags
145
+ * can't be cleared through the API (live, 08/11/2026). The reference documents
146
+ * no other way.
147
+ */
148
+ export declare const TAGS_NOTE = "tags replaces the whole map when it has at least one key. An empty map or null is ignored by the API, so tags can't be cleared through it: to drop some tags, send the ones to keep.";
149
+ /**
150
+ * Translates the policy service's errors into actionable ones. An unknown ID
151
+ * is "policy not found" (code NOT_FOUND on a read, DOWNSTREAM_SERVICE_ERROR on
152
+ * a write); a deleted one carries code GONE and its deletedAt. A stale version
153
+ * is "version conflict: policy has been modified".
154
+ */
155
+ export declare function rethrowPolicyError(policyId: string): (error: unknown) => never;
156
+ /** activity(id) answers an ID it does not hold with "input: failed to retrieve activity" (measured 07/11/2026). */
157
+ export declare function rethrowActivityError(activityId: string): (error: unknown) => never;
158
+ /** Tests shorten the waits. */
159
+ export declare function setUnclearReadBackDelays(ms: number[]): void;
160
+ /** A policy write's answer: its result, or why the answer does not say whether the write took effect. */
161
+ export type PolicyWriteAnswer<T> = {
162
+ unclear: false;
163
+ value: T;
164
+ warnings: string[];
165
+ } | {
166
+ unclear: true;
167
+ reason: string;
168
+ warnings: string[];
169
+ };
170
+ /**
171
+ * Sends one AI Defense policy mutation and returns its result field. The
172
+ * answer is unclear when the client throws FusionNoResultError (HTTP 200 with
173
+ * an empty or unreadable body, or with neither data nor errors: enablePolicy
174
+ * answered 200 with an empty body on 08/11/2026), or when the field is null,
175
+ * missing or an empty list with no error. The write may still have been made,
176
+ * so the tool reads the state back instead of reporting success. A GraphQL
177
+ * error is a clear refusal and goes to rethrow.
178
+ */
179
+ export declare function sendPolicyWrite<T>(client: FusionClient, tenantId: string, document: string, field: string, variables: Record<string, unknown>, rethrow?: (error: unknown) => never): Promise<PolicyWriteAnswer<T>>;
180
+ /** One read of a policy: found, gone (deleted, with its time, or never there), or the read failed. */
181
+ export type PolicyRead = {
182
+ kind: "found";
183
+ policy: AiDefensePolicy;
184
+ } | {
185
+ kind: "gone";
186
+ deletedAt: string | null;
187
+ } | {
188
+ kind: "failed";
189
+ error: string;
190
+ };
191
+ export declare function readPolicy(client: FusionClient, tenantId: string, policyId: string): Promise<PolicyRead>;
192
+ /** Every policy the filter matches, in rank order, or why the list could not be read. */
193
+ export declare function readPolicyList(client: FusionClient, tenantId: string, filter: Record<string, unknown>): Promise<{
194
+ policies: AiDefensePolicy[];
195
+ } | {
196
+ error: string;
197
+ }>;
198
+ /**
199
+ * Reads until settled() accepts a read, waiting before each one, and returns
200
+ * the last read and how many were made. A read that fails or disagrees is
201
+ * read again, since one read proves nothing either way.
202
+ */
203
+ export declare function readBackUntil<R>(read: () => Promise<R>, settled: (value: R) => boolean): Promise<{
204
+ last: R;
205
+ reads: number;
206
+ }>;
207
+ /** About how long the read-back reads span, for the result's wording. */
208
+ export declare function readBackSpan(reads: number): string;
209
+ export declare const READ_ONLY: {
210
+ readonly readOnlyHint: true;
211
+ readonly destructiveHint: false;
212
+ readonly idempotentHint: true;
213
+ readonly openWorldHint: true;
214
+ };
215
+ export declare const WRITE: {
216
+ readonly readOnlyHint: false;
217
+ readonly destructiveHint: false;
218
+ readonly idempotentHint: false;
219
+ readonly openWorldHint: true;
220
+ };
221
+ export declare const DESTRUCTIVE: {
222
+ readonly readOnlyHint: false;
223
+ readonly destructiveHint: true;
224
+ readonly idempotentHint: false;
225
+ readonly openWorldHint: true;
226
+ };
227
+ //# sourceMappingURL=ai-defense.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai-defense.d.ts","sourceRoot":"","sources":["../../src/fusion/ai-defense.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAA2C,KAAK,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAExG,OAAO,KAAK,EAA6B,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7E,eAAO,MAAM,oBAAoB,yOAUvB,CAAC;AAEX,eAAO,MAAM,cAAc,qCAAsC,C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