@seclai/sdk 1.3.0 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,3 +1,14 @@
1
+ // src/versions.ts
2
+ var SeclaiApiVersion = {
3
+ V2026_07_01: "2026-07-01",
4
+ V2026_07_27: "2026-07-27",
5
+ /** Baseline applied to an unpinned, header-less caller. */
6
+ Default: "2026-07-01",
7
+ /** Newest version known to this SDK release. May lag the server. */
8
+ Latest: "2026-07-27"
9
+ };
10
+ var KNOWN_API_VERSIONS = Object.entries(SeclaiApiVersion).filter(([k]) => k.startsWith("V")).map(([, v]) => v);
11
+
1
12
  // src/errors.ts
2
13
  var SeclaiError = class extends Error {
3
14
  constructor(message) {
@@ -495,7 +506,23 @@ var Seclai = class {
495
506
  );
496
507
  }
497
508
  this.baseUrl = opts.baseUrl ?? getEnv2("SECLAI_API_URL") ?? SECLAI_API_URL;
498
- this.defaultHeaders = { ...opts.defaultHeaders ?? {} };
509
+ const merged = opts.apiVersion ? { "Seclai-Version": opts.apiVersion } : {};
510
+ let versionKey = opts.apiVersion ? "Seclai-Version" : void 0;
511
+ for (const [key, value] of Object.entries(opts.defaultHeaders ?? {})) {
512
+ for (const existing of Object.keys(merged)) {
513
+ if (existing.toLowerCase() === key.toLowerCase()) delete merged[existing];
514
+ }
515
+ merged[key] = value;
516
+ if (key.toLowerCase() === "seclai-version") versionKey = key;
517
+ }
518
+ const effectiveVersion = versionKey ? merged[versionKey] : void 0;
519
+ if (effectiveVersion && !opts.allowUnknownApiVersion && !KNOWN_API_VERSIONS.includes(effectiveVersion)) {
520
+ const via = versionKey === "Seclai-Version" && merged[versionKey] === opts.apiVersion ? "apiVersion" : `defaultHeaders['${versionKey}']`;
521
+ throw new SeclaiConfigurationError(
522
+ `Unknown API version '${effectiveVersion}' (via ${via}). This release was built against ${KNOWN_API_VERSIONS.join(", ")}. A newer API version can change response shapes, which this client would decode incorrectly rather than reject. Upgrade the package, or set allowUnknownApiVersion to proceed anyway.`
523
+ );
524
+ }
525
+ this.defaultHeaders = merged;
499
526
  this.fetcher = fetcher;
500
527
  const accessTokenProvider = typeof opts.accessToken === "function" ? opts.accessToken : void 0;
501
528
  const accessTokenStatic = typeof opts.accessToken === "string" ? opts.accessToken : void 0;
@@ -697,6 +724,50 @@ var Seclai = class {
697
724
  return await response.json();
698
725
  }
699
726
  // ═══════════════════════════════════════════════════════════════════════════
727
+ // Identity
728
+ // ═══════════════════════════════════════════════════════════════════════════
729
+ /**
730
+ * Get the authenticated user's identity.
731
+ *
732
+ * Returns the personal `account_id` plus every organization the user belongs
733
+ * to — each with its own `id`, display `name`, and `account_id`. Use it to
734
+ * discover the account IDs that can be passed as the client's `accountId`
735
+ * option (sent as the `X-Account-Id` header) to target an org context.
736
+ *
737
+ * @returns The current user's account ID and organization memberships.
738
+ */
739
+ async getMe() {
740
+ return await this.request("GET", "/me");
741
+ }
742
+ // ═══════════════════════════════════════════════════════════════════════════
743
+ // API Version
744
+ // ═══════════════════════════════════════════════════════════════════════════
745
+ /**
746
+ * Read the API version this request resolved to, and the versions available.
747
+ *
748
+ * Resolution order is the `Seclai-Version` header, then the account pin, then
749
+ * the default — so `effective_version` reflects the client's `apiVersion`
750
+ * option when that is set.
751
+ *
752
+ * @returns The pinned, effective, default and latest versions.
753
+ */
754
+ async getApiVersion() {
755
+ return await this.request("GET", "/version");
756
+ }
757
+ /**
758
+ * Pin the account to a dated API version, or clear the pin.
759
+ *
760
+ * Owner/admin only. The pin applies to later header-less requests; a
761
+ * `Seclai-Version` header still overrides it, so `effective_version` in the
762
+ * response describes this request rather than the pin just written.
763
+ *
764
+ * @param version - A `YYYY-MM-DD` date to pin to, or `null` to clear the pin.
765
+ * @returns The updated version state.
766
+ */
767
+ async updateApiVersion(version) {
768
+ return await this.request("PUT", "/version", { json: { version } });
769
+ }
770
+ // ═══════════════════════════════════════════════════════════════════════════
700
771
  // Agents — CRUD
701
772
  // ═══════════════════════════════════════════════════════════════════════════
702
773
  /**
@@ -747,6 +818,48 @@ var Seclai = class {
747
818
  await this.request("DELETE", `/agents/${agentId}`);
748
819
  }
749
820
  // ═══════════════════════════════════════════════════════════════════════════
821
+ // Agents — Enable / Disable
822
+ // ═══════════════════════════════════════════════════════════════════════════
823
+ /**
824
+ * Pause (disable) an agent so it stops firing from every trigger path.
825
+ *
826
+ * API runs return HTTP 409, inbound email is turned away, and scheduled /
827
+ * content triggers are skipped.
828
+ *
829
+ * Fails with HTTP 409 when other live agents still call this one via a
830
+ * `call_agent` step — use {@link getAgentCallers} to list them, and disable
831
+ * those first.
832
+ *
833
+ * @param agentId - Agent identifier.
834
+ * @returns The updated agent summary.
835
+ */
836
+ async disableAgent(agentId) {
837
+ return await this.request("POST", `/agents/${agentId}/disable`);
838
+ }
839
+ /**
840
+ * Resume (enable) a paused agent.
841
+ *
842
+ * Clears the disable state whether the agent was paused manually or
843
+ * auto-paused by the inbound-email overload safeguard.
844
+ *
845
+ * @param agentId - Agent identifier.
846
+ * @returns The updated agent summary.
847
+ */
848
+ async enableAgent(agentId) {
849
+ return await this.request("POST", `/agents/${agentId}/enable`);
850
+ }
851
+ /**
852
+ * List the live agents that call this agent via a `call_agent` step.
853
+ *
854
+ * These must be disabled before this agent can be paused.
855
+ *
856
+ * @param agentId - Agent identifier.
857
+ * @returns The calling agents.
858
+ */
859
+ async getAgentCallers(agentId) {
860
+ return await this.request("GET", `/agents/${agentId}/callers`);
861
+ }
862
+ // ═══════════════════════════════════════════════════════════════════════════
750
863
  // Agent Export / Import
751
864
  // ═══════════════════════════════════════════════════════════════════════════
752
865
  /**
@@ -851,21 +964,29 @@ var Seclai = class {
851
964
  } : void 0);
852
965
  }
853
966
  /**
854
- * Delete an agent run.
967
+ * Cancel an agent run.
968
+ *
969
+ * @deprecated This never deleted anything — the endpoint it calls is documented
970
+ * as "Cancel an agent run", and the API has no delete-a-run operation. It also
971
+ * discards the returned run state. Use {@link cancelAgentRun} instead.
855
972
  *
856
973
  * @param runId - Run identifier.
857
974
  */
858
975
  async deleteAgentRun(runId) {
859
- await this.request("DELETE", `/agents/runs/${runId}`);
976
+ await this.cancelAgentRun(runId);
860
977
  }
861
978
  /**
862
979
  * Cancel a running agent run.
863
980
  *
981
+ * Cancellation is `DELETE` on the run resource — the API exposes no
982
+ * `POST .../cancel` route, and no operation that deletes a run. Rejected when
983
+ * the run has already reached a terminal state.
984
+ *
864
985
  * @param runId - Run identifier.
865
986
  * @returns Updated run (with cancelled status).
866
987
  */
867
988
  async cancelAgentRun(runId) {
868
- return await this.request("POST", `/agents/runs/${runId}/cancel`);
989
+ return await this.request("DELETE", `/agents/runs/${runId}`);
869
990
  }
870
991
  // ═══════════════════════════════════════════════════════════════════════════
871
992
  // Agent Runs — Streaming
@@ -1131,9 +1252,10 @@ var Seclai = class {
1131
1252
  * @returns Paginated list of evaluation results.
1132
1253
  */
1133
1254
  async listRunEvaluationResults(agentId, runId, opts = {}) {
1134
- return await this.request("GET", `/agents/${agentId}/runs/${runId}/evaluation-results`, {
1255
+ const res = await this.request("GET", `/agents/${agentId}/runs/${runId}/evaluation-results`, {
1135
1256
  query: { page: opts.page, limit: opts.limit }
1136
1257
  });
1258
+ return Array.isArray(res) ? { data: res } : res;
1137
1259
  }
1138
1260
  // ═══════════════════════════════════════════════════════════════════════════
1139
1261
  // Agent Input Uploads
@@ -1221,8 +1343,20 @@ var Seclai = class {
1221
1343
  * @param agentId - Agent identifier.
1222
1344
  * @returns Conversation history.
1223
1345
  */
1224
- async getAgentAiConversationHistory(agentId) {
1225
- return await this.request("GET", `/agents/${agentId}/ai-assistant/conversations`);
1346
+ async getAgentAiConversationHistory(agentId, opts = {}) {
1347
+ if (!opts.stepType) {
1348
+ throw new SeclaiConfigurationError(
1349
+ 'getAgentAiConversationHistory requires opts.stepType; the API rejects the request without it. Pass e.g. { stepType: "llm" }.'
1350
+ );
1351
+ }
1352
+ return await this.request("GET", `/agents/${agentId}/ai-assistant/conversations`, {
1353
+ query: {
1354
+ step_type: opts.stepType,
1355
+ step_id: opts.stepId,
1356
+ limit: opts.limit,
1357
+ offset: opts.offset
1358
+ }
1359
+ });
1226
1360
  }
1227
1361
  /**
1228
1362
  * Mark an AI suggestion as accepted or rejected.
@@ -1244,9 +1378,25 @@ var Seclai = class {
1244
1378
  * @param opts - Pagination options.
1245
1379
  */
1246
1380
  async listEvaluationCriteria(agentId, opts = {}) {
1247
- return await this.request("GET", `/agents/${agentId}/evaluation-criteria`, {
1381
+ return (await this.listEvaluationCriteriaPage(agentId, opts)).data ?? [];
1382
+ }
1383
+ /**
1384
+ * List evaluation criteria for an agent, with pagination metadata.
1385
+ *
1386
+ * Accepts either wire shape. The endpoint answered with a bare array before
1387
+ * 2026-07 and with a paginated envelope after, so a client that decodes only
1388
+ * one breaks the day the other ships. `total`, `page` and `limit` are absent
1389
+ * when the endpoint answers with a bare array.
1390
+ *
1391
+ * @param agentId - Agent identifier.
1392
+ * @param opts - Pagination options.
1393
+ * @returns The criteria under `data`, plus the page metadata when present.
1394
+ */
1395
+ async listEvaluationCriteriaPage(agentId, opts = {}) {
1396
+ const res = await this.request("GET", `/agents/${agentId}/evaluation-criteria`, {
1248
1397
  query: { page: opts.page, limit: opts.limit }
1249
1398
  });
1399
+ return Array.isArray(res) ? { data: res } : res;
1250
1400
  }
1251
1401
  /**
1252
1402
  * Create evaluation criteria for an agent.
@@ -1369,6 +1519,145 @@ var Seclai = class {
1369
1519
  });
1370
1520
  }
1371
1521
  // ═══════════════════════════════════════════════════════════════════════════
1522
+ // Agent Email Triggers
1523
+ // ═══════════════════════════════════════════════════════════════════════════
1524
+ /**
1525
+ * Configure an agent's `EMAIL_RECEIVED` trigger and return its computed
1526
+ * email address(es).
1527
+ *
1528
+ * Sets the custom alias, the sender allowlist, and the inbound-handling flags
1529
+ * (`ignore_auto_generated`, `require_sender_auth`, `queue_on_quota`). Omitted
1530
+ * fields are left unchanged; passing `null` (or `""` for `alias`) clears them.
1531
+ *
1532
+ * @param agentId - Agent identifier.
1533
+ * @param triggerId - Trigger identifier.
1534
+ * @param body - The fields to set.
1535
+ * @returns The trigger's resolved addresses and config.
1536
+ */
1537
+ async setEmailTriggerConfig(agentId, triggerId, body) {
1538
+ return await this.request("PUT", `/agents/${agentId}/triggers/${triggerId}/email-config`, {
1539
+ json: body
1540
+ });
1541
+ }
1542
+ // ═══════════════════════════════════════════════════════════════════════════
1543
+ // Agent Email Governance
1544
+ // ═══════════════════════════════════════════════════════════════════════════
1545
+ /**
1546
+ * List recipients who have opted out of this account's agent emails.
1547
+ *
1548
+ * @param opts - Optional agent filter and `limit`/`offset` pagination.
1549
+ * @param opts.agentId - Filter to one agent (account-wide opt-outs still apply).
1550
+ * @param opts.limit - Page size (1-200, default 50).
1551
+ * @param opts.offset - Rows to skip (default 0).
1552
+ * @returns The page of opt-outs plus the total count.
1553
+ */
1554
+ async listAgentEmailOptOuts(opts = {}) {
1555
+ return await this.request("GET", "/agents/agent-email-optouts", {
1556
+ query: { agent_id: opts.agentId, limit: opts.limit, offset: opts.offset }
1557
+ });
1558
+ }
1559
+ /**
1560
+ * Revoke an opt-out, opting the recipient back in to agent emails.
1561
+ *
1562
+ * @param optoutId - Opt-out identifier.
1563
+ */
1564
+ async removeAgentEmailOptOut(optoutId) {
1565
+ await this.request("DELETE", `/agents/agent-email-optouts/${optoutId}`);
1566
+ }
1567
+ /**
1568
+ * List the account's blocked inbound email senders (newest first), plus the
1569
+ * governance `auto_block_mode`.
1570
+ *
1571
+ * @param opts - Optional `limit`/`offset` pagination.
1572
+ * @param opts.limit - Page size (1-200, default 50).
1573
+ * @param opts.offset - Rows to skip (default 0).
1574
+ */
1575
+ async listBlockedEmailSenders(opts = {}) {
1576
+ return await this.request("GET", "/agents/blocked-email-senders", {
1577
+ query: { limit: opts.limit, offset: opts.offset }
1578
+ });
1579
+ }
1580
+ /**
1581
+ * Add a sender address or a whole domain to the account blocklist.
1582
+ *
1583
+ * Idempotent. `match_type` is `"address"` (default) or `"domain"`.
1584
+ * Requires an account owner/admin.
1585
+ *
1586
+ * @param body - The sender or domain to block.
1587
+ * @returns The blocked-sender entry.
1588
+ */
1589
+ async blockEmailSender(body) {
1590
+ return await this.request("POST", "/agents/blocked-email-senders", {
1591
+ json: body
1592
+ });
1593
+ }
1594
+ /**
1595
+ * Remove a blocked sender by id. Requires an account owner/admin.
1596
+ *
1597
+ * @param blockedId - Blocked-sender identifier.
1598
+ */
1599
+ async unblockEmailSender(blockedId) {
1600
+ await this.request("DELETE", `/agents/blocked-email-senders/${blockedId}`);
1601
+ }
1602
+ /**
1603
+ * Set whether a governance BLOCK on an authenticated inbound sender
1604
+ * auto-adds them to the blocklist.
1605
+ *
1606
+ * `mode` is `"disabled"`, `"input"`, or `"input_and_output"`.
1607
+ * Requires an account owner/admin.
1608
+ *
1609
+ * @param body - The mode to set.
1610
+ * @returns The updated blocked-sender list.
1611
+ */
1612
+ async setAutoBlockMode(body) {
1613
+ return await this.request("PUT", "/agents/blocked-email-senders/mode", {
1614
+ json: body
1615
+ });
1616
+ }
1617
+ /**
1618
+ * List recent inbound emails that were quietly discarded before running an
1619
+ * agent (unauthorized sender, unknown alias, spam/virus, flood-shed).
1620
+ *
1621
+ * @param opts - Optional agent filter and result limit.
1622
+ * @param opts.agentId - Filter to a single agent's rejections.
1623
+ * @param opts.limit - Maximum results (1-200, default 50).
1624
+ */
1625
+ async listInboundEmailRejections(opts = {}) {
1626
+ return await this.request("GET", "/agents/inbound-email-rejections", {
1627
+ query: { agent_id: opts.agentId, limit: opts.limit }
1628
+ });
1629
+ }
1630
+ /**
1631
+ * Get the account's inbound-email overload status — whether the circuit
1632
+ * breaker has paused new inbound email, and the size of the QUEUED
1633
+ * (over-quota parked) run backlog.
1634
+ */
1635
+ async getInboundEmailStatus() {
1636
+ return await this.request("GET", "/agents/inbound-email-status");
1637
+ }
1638
+ /**
1639
+ * Fail all of the account's QUEUED (over-quota parked) inbound-email runs at
1640
+ * once.
1641
+ *
1642
+ * A queued run consumed no quota or credits at queue time, so this merely
1643
+ * fails them. Requires an account owner/admin.
1644
+ *
1645
+ * @returns The count cancelled.
1646
+ */
1647
+ async cancelQueuedEmailRuns() {
1648
+ return await this.request("POST", "/agents/inbound-email-status/cancel-queued");
1649
+ }
1650
+ /**
1651
+ * Manually lift the account-wide inbound-email pause.
1652
+ *
1653
+ * If the queued backlog is still above the ceiling the breaker re-arms on the
1654
+ * next evaluation — this is a one-shot override, not a permanent disable.
1655
+ * Requires an account owner/admin.
1656
+ */
1657
+ async resumeInboundEmail() {
1658
+ return await this.request("POST", "/agents/inbound-email-status/resume");
1659
+ }
1660
+ // ═══════════════════════════════════════════════════════════════════════════
1372
1661
  // Knowledge Bases
1373
1662
  // ═══════════════════════════════════════════════════════════════════════════
1374
1663
  /**
@@ -1561,7 +1850,7 @@ var Seclai = class {
1561
1850
  * @returns Paginated list of sources.
1562
1851
  */
1563
1852
  async listSources(opts = {}) {
1564
- return await this.request("GET", "/sources/", {
1853
+ return await this.request("GET", "/sources", {
1565
1854
  query: {
1566
1855
  page: opts.page,
1567
1856
  limit: opts.limit,
@@ -2024,7 +2313,7 @@ var Seclai = class {
2024
2313
  */
2025
2314
  async listAlerts(opts = {}) {
2026
2315
  return await this.request("GET", "/alerts", {
2027
- query: { page: opts.page, limit: opts.limit, status: opts.status, severity: opts.severity }
2316
+ query: { page: opts.page, limit: opts.limit, status: opts.status }
2028
2317
  });
2029
2318
  }
2030
2319
  /**
@@ -2077,6 +2366,12 @@ var Seclai = class {
2077
2366
  * @param opts - Pagination options.
2078
2367
  * @returns Paginated list of alert configs.
2079
2368
  */
2369
+ /**
2370
+ * The configurations arrive under `configs` alongside `total` by default.
2371
+ * Once the caller opts in with `apiVersion` 2026-07-27 or later the endpoint
2372
+ * returns the canonical `{data, pagination}` envelope instead, so the
2373
+ * top-level key changes.
2374
+ */
2080
2375
  async listAlertConfigs(opts = {}) {
2081
2376
  return await this.request("GET", "/alerts/configs", {
2082
2377
  query: { page: opts.page, limit: opts.limit }
@@ -2133,7 +2428,11 @@ var Seclai = class {
2133
2428
  * @param body - Preference update.
2134
2429
  */
2135
2430
  async updateOrganizationAlertPreference(organizationId, alertType, body) {
2136
- return await this.request("PATCH", `/alerts/organization-preferences/${organizationId}/${alertType}`, { json: body });
2431
+ return await this.request(
2432
+ "PATCH",
2433
+ `/alerts/organization-preferences/${organizationId}/${alertType}`,
2434
+ { json: body }
2435
+ );
2137
2436
  }
2138
2437
  // ═══════════════════════════════════════════════════════════════════════════
2139
2438
  // Models & Model Alerts
@@ -2144,8 +2443,10 @@ var Seclai = class {
2144
2443
  * @param opts - Pagination options.
2145
2444
  */
2146
2445
  async listModelAlerts(opts = {}) {
2446
+ const limit = opts.limit ?? 50;
2447
+ const offset = opts.page && opts.page > 1 ? (opts.page - 1) * limit : void 0;
2147
2448
  return await this.request("GET", "/models/alerts", {
2148
- query: { page: opts.page, limit: opts.limit }
2449
+ query: { offset, limit: opts.limit }
2149
2450
  });
2150
2451
  }
2151
2452
  /**
@@ -2183,7 +2484,13 @@ var Seclai = class {
2183
2484
  */
2184
2485
  async listModels(opts = {}) {
2185
2486
  return await this.request("GET", "/models", {
2186
- query: { provider: opts.provider, supports_tool_use: opts.supportsToolUse, supports_thinking: opts.supportsThinking }
2487
+ query: {
2488
+ provider: opts.provider,
2489
+ supports_tool_use: opts.supportsToolUse,
2490
+ supports_thinking: opts.supportsThinking,
2491
+ supports_input_media: opts.supportsInputMedia,
2492
+ supports_output_media: opts.supportsOutputMedia
2493
+ }
2187
2494
  });
2188
2495
  }
2189
2496
  /**
@@ -2194,6 +2501,20 @@ var Seclai = class {
2194
2501
  async getModel(modelId) {
2195
2502
  return await this.request("GET", `/models/${modelId}/details`);
2196
2503
  }
2504
+ /**
2505
+ * List the media-generation quality tiers and the model + cost each resolves to.
2506
+ *
2507
+ * On a `prompt_call`'s `media_generation` tool — and the dedicated
2508
+ * `generate_*` steps via tier routing — the author/LLM picks a *tier*
2509
+ * (fast/balanced/thorough), never a model. This maps each
2510
+ * `(modality, tier)` to its concrete generator, raw `credits_per_unit`,
2511
+ * `unit_label`, and a human-readable scaled `price_label`.
2512
+ *
2513
+ * Global routing/pricing (the same for every account); read-only.
2514
+ */
2515
+ async getGenerationTiers() {
2516
+ return await this.request("GET", "/models/generation-tiers");
2517
+ }
2197
2518
  // ═══════════════════════════════════════════════════════════════════════════
2198
2519
  // Model Playground Experiments
2199
2520
  // ═══════════════════════════════════════════════════════════════════════════
@@ -2262,6 +2583,143 @@ var Seclai = class {
2262
2583
  query: { q: opts.query, limit: opts.limit, entity_type: opts.entityType }
2263
2584
  });
2264
2585
  }
2586
+ /**
2587
+ * Search the Seclai documentation by content.
2588
+ *
2589
+ * `mode: "keyword"` matches page titles and summaries (fast, no AI cost);
2590
+ * `mode: "semantic"` matches page body content by meaning (uses an embedding).
2591
+ *
2592
+ * Each result carries a `doc_slug` and an optional section `anchor` for
2593
+ * building a `https://seclai.com/docs/<doc_slug>[#<anchor>]` link, a `score`
2594
+ * (not comparable across modes), and — in semantic mode — a `highlight`
2595
+ * (best matching verbatim sentence; `null` for keyword).
2596
+ *
2597
+ * Documentation is global, so results are not account-scoped.
2598
+ *
2599
+ * @param opts - Search options.
2600
+ * @param opts.query - Search query string (required, 1-200 chars).
2601
+ * @param opts.mode - Search strategy (default `"keyword"`).
2602
+ * @param opts.limit - Maximum results (1-20, default 8).
2603
+ */
2604
+ async searchDocs(opts) {
2605
+ return await this.request("GET", "/docs-search", {
2606
+ query: { q: opts.query, mode: opts.mode, limit: opts.limit }
2607
+ });
2608
+ }
2609
+ // ═══════════════════════════════════════════════════════════════════════════
2610
+ // Email Domains
2611
+ // ═══════════════════════════════════════════════════════════════════════════
2612
+ /**
2613
+ * List the account's vanity (`<slug>.seclai.com`) and custom
2614
+ * (`agent.mycompany.com`) agent-email domains.
2615
+ *
2616
+ * Includes each domain's verification status and the DNS records the customer
2617
+ * must publish, plus the plan capabilities (`can_add_vanity` /
2618
+ * `can_add_custom`) and whether one of each kind already exists
2619
+ * (`has_vanity` / `has_custom` — the per-kind limit is 1).
2620
+ *
2621
+ * Requires a user-bound credential; an account-only API key is refused with 403.
2622
+ */
2623
+ async listEmailDomains() {
2624
+ return await this.request("GET", "/email-domains");
2625
+ }
2626
+ /**
2627
+ * Add and provision a new agent-email domain.
2628
+ *
2629
+ * Pass `kind: "vanity"` with `value: "<slug>"`, or `kind: "custom"` with
2630
+ * `value: "agent.mycompany.com"` (optionally `delegated: true` to let Seclai
2631
+ * manage a dedicated Route53 zone). Stands up the SES identity + DNS and
2632
+ * returns the records the customer must publish. Requires an account
2633
+ * owner/admin.
2634
+ *
2635
+ * @param body - The domain to add. `delegated` defaults to `false` server-side.
2636
+ */
2637
+ async addEmailDomain(body) {
2638
+ return await this.request("POST", "/email-domains", { json: body });
2639
+ }
2640
+ /**
2641
+ * Remove a domain and tear down its SES identity + DNS / receipt-rule recipient.
2642
+ *
2643
+ * Returns a `cleanup_note` when the removed domain was Seclai-managed
2644
+ * (delegated), reminding you to delete the registrar NS delegation record
2645
+ * (dangling-delegation / subdomain-takeover guard). Requires an account
2646
+ * owner/admin.
2647
+ *
2648
+ * @param domainId - Domain identifier.
2649
+ */
2650
+ async removeEmailDomain(domainId) {
2651
+ return await this.request("DELETE", `/email-domains/${domainId}`);
2652
+ }
2653
+ /**
2654
+ * Run a verification check immediately ("Check now").
2655
+ *
2656
+ * Re-polls SES + DNS for this domain instead of waiting for the background
2657
+ * verification sweep, and returns its updated status + DNS-record check
2658
+ * results. Useful right after publishing the required records. Requires an
2659
+ * account owner/admin.
2660
+ *
2661
+ * @param domainId - Domain identifier.
2662
+ */
2663
+ async verifyEmailDomain(domainId) {
2664
+ return await this.request("POST", `/email-domains/${domainId}/verify`);
2665
+ }
2666
+ /**
2667
+ * Promote a verified domain to the account's primary domain.
2668
+ *
2669
+ * Agent email then sends FROM and receives ON this domain
2670
+ * (`<agentID>@<domain>`, `<alias>@<domain>`) instead of the shared
2671
+ * `agent.seclai.com`. The domain must be verified. Requires an account
2672
+ * owner/admin.
2673
+ *
2674
+ * @param domainId - Domain identifier.
2675
+ */
2676
+ async setPrimaryEmailDomain(domainId) {
2677
+ return await this.request("POST", `/email-domains/${domainId}/primary`);
2678
+ }
2679
+ /**
2680
+ * Revert to the shared `agent.seclai.com` sending/inbound domain.
2681
+ *
2682
+ * Clears the account's primary domain WITHOUT removing the configured
2683
+ * domain(s) — they stay verified and can be promoted again later. Requires an
2684
+ * account owner/admin.
2685
+ */
2686
+ async useSharedEmailDomain() {
2687
+ await this.request("POST", "/email-domains/use-shared-domain");
2688
+ }
2689
+ /**
2690
+ * Send a test message FROM a verified domain (`noreply@<domain>`) TO the
2691
+ * account owner's email.
2692
+ *
2693
+ * Confirms end-to-end that the domain actually sends (SES verified, DKIM/SPF
2694
+ * aligned). Never sends to any other address, so it can't be used as an open
2695
+ * relay. Requires an account owner/admin.
2696
+ *
2697
+ * @param domainId - Domain identifier.
2698
+ */
2699
+ async sendEmailDomainTestEmail(domainId) {
2700
+ return await this.request("POST", `/email-domains/${domainId}/test-email`);
2701
+ }
2702
+ /**
2703
+ * Get the DMARC aggregate-report summary for a domain.
2704
+ *
2705
+ * Pass rate, disposition breakdown (`none`/`quarantine`/`reject`), and top
2706
+ * failing source IPs from the DMARC `rua` reports over the last `days`
2707
+ * (clamped by the service).
2708
+ *
2709
+ * Populated for domains whose DNS zone Seclai controls (vanity + delegated
2710
+ * custom); a self-managed custom domain keeps its own DMARC reporting and
2711
+ * returns an all-zero summary.
2712
+ *
2713
+ * @param domainId - Domain identifier.
2714
+ * @param opts - Reporting window options.
2715
+ * @param opts.days - Window length in days (default 30).
2716
+ * @param opts.topSources - Number of top failing sources to return (default 10).
2717
+ */
2718
+ async getDmarcSummary(domainId, opts = {}) {
2719
+ return await this.request("GET", `/email-domains/${domainId}/dmarc`, {
2720
+ query: { days: opts.days, top_sources: opts.topSources }
2721
+ });
2722
+ }
2265
2723
  // ═══════════════════════════════════════════════════════════════════════════
2266
2724
  // Top-Level AI Assistant
2267
2725
  // ═══════════════════════════════════════════════════════════════════════════
@@ -2382,6 +2840,7 @@ export {
2382
2840
  Seclai,
2383
2841
  SeclaiAPIStatusError,
2384
2842
  SeclaiAPIValidationError,
2843
+ SeclaiApiVersion,
2385
2844
  SeclaiConfigurationError,
2386
2845
  SeclaiError,
2387
2846
  SeclaiStreamingError,