@seclai/sdk 1.2.0 → 1.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.
package/dist/index.cjs CHANGED
@@ -747,6 +747,22 @@ var Seclai = class {
747
747
  return await response.json();
748
748
  }
749
749
  // ═══════════════════════════════════════════════════════════════════════════
750
+ // Identity
751
+ // ═══════════════════════════════════════════════════════════════════════════
752
+ /**
753
+ * Get the authenticated user's identity.
754
+ *
755
+ * Returns the personal `account_id` plus every organization the user belongs
756
+ * to — each with its own `id`, display `name`, and `account_id`. Use it to
757
+ * discover the account IDs that can be passed as the client's `accountId`
758
+ * option (sent as the `X-Account-Id` header) to target an org context.
759
+ *
760
+ * @returns The current user's account ID and organization memberships.
761
+ */
762
+ async getMe() {
763
+ return await this.request("GET", "/me");
764
+ }
765
+ // ═══════════════════════════════════════════════════════════════════════════
750
766
  // Agents — CRUD
751
767
  // ═══════════════════════════════════════════════════════════════════════════
752
768
  /**
@@ -797,6 +813,48 @@ var Seclai = class {
797
813
  await this.request("DELETE", `/agents/${agentId}`);
798
814
  }
799
815
  // ═══════════════════════════════════════════════════════════════════════════
816
+ // Agents — Enable / Disable
817
+ // ═══════════════════════════════════════════════════════════════════════════
818
+ /**
819
+ * Pause (disable) an agent so it stops firing from every trigger path.
820
+ *
821
+ * API runs return HTTP 409, inbound email is turned away, and scheduled /
822
+ * content triggers are skipped.
823
+ *
824
+ * Fails with HTTP 409 when other live agents still call this one via a
825
+ * `call_agent` step — use {@link getAgentCallers} to list them, and disable
826
+ * those first.
827
+ *
828
+ * @param agentId - Agent identifier.
829
+ * @returns The updated agent summary.
830
+ */
831
+ async disableAgent(agentId) {
832
+ return await this.request("POST", `/agents/${agentId}/disable`);
833
+ }
834
+ /**
835
+ * Resume (enable) a paused agent.
836
+ *
837
+ * Clears the disable state whether the agent was paused manually or
838
+ * auto-paused by the inbound-email overload safeguard.
839
+ *
840
+ * @param agentId - Agent identifier.
841
+ * @returns The updated agent summary.
842
+ */
843
+ async enableAgent(agentId) {
844
+ return await this.request("POST", `/agents/${agentId}/enable`);
845
+ }
846
+ /**
847
+ * List the live agents that call this agent via a `call_agent` step.
848
+ *
849
+ * These must be disabled before this agent can be paused.
850
+ *
851
+ * @param agentId - Agent identifier.
852
+ * @returns The calling agents.
853
+ */
854
+ async getAgentCallers(agentId) {
855
+ return await this.request("GET", `/agents/${agentId}/callers`);
856
+ }
857
+ // ═══════════════════════════════════════════════════════════════════════════
800
858
  // Agent Export / Import
801
859
  // ═══════════════════════════════════════════════════════════════════════════
802
860
  /**
@@ -1211,6 +1269,37 @@ var Seclai = class {
1211
1269
  async getAgentInputUploadStatus(agentId, uploadId) {
1212
1270
  return await this.request("GET", `/agents/${agentId}/input-uploads/${uploadId}`);
1213
1271
  }
1272
+ /**
1273
+ * Get the static attachment-reference contract for an agent — what files (if
1274
+ * any) its definition expects on a run.
1275
+ *
1276
+ * Call this before staging uploads to learn whether the agent accepts files
1277
+ * at all (`requires_uploads`) and which specific filenames, indexes, or glob
1278
+ * patterns its templates reference. A run-time upload batch that doesn't
1279
+ * satisfy every declared selector is rejected with HTTP 400.
1280
+ *
1281
+ * @param agentId - Agent identifier.
1282
+ * @returns The agent's attachment-reference contract.
1283
+ */
1284
+ async getAgentAttachmentReferences(agentId) {
1285
+ return await this.request("GET", `/agents/${agentId}/attachment-references`);
1286
+ }
1287
+ /**
1288
+ * Download a file attachment emitted by a step in an agent run.
1289
+ *
1290
+ * Returns the raw `Response` so you can stream or save the binary data.
1291
+ *
1292
+ * @param runId - Run identifier.
1293
+ * @param attachmentId - URL-safe-base64-encoded `storage_key` of the attachment
1294
+ * (as surfaced in run output manifests and webhook/email payloads).
1295
+ * @param opts - Optional `downloadName` filename hint for the download disposition.
1296
+ * @returns Raw response with the attachment bytes.
1297
+ */
1298
+ async downloadAgentRunAttachment(runId, attachmentId, opts = {}) {
1299
+ return await this.requestRaw("GET", `/v2/agent-runs/${runId}/attachments/${attachmentId}`, {
1300
+ query: { download_name: opts.downloadName }
1301
+ });
1302
+ }
1214
1303
  // ═══════════════════════════════════════════════════════════════════════════
1215
1304
  // Agent AI Assistant (Steps Generation)
1216
1305
  // ═══════════════════════════════════════════════════════════════════════════
@@ -1388,6 +1477,145 @@ var Seclai = class {
1388
1477
  });
1389
1478
  }
1390
1479
  // ═══════════════════════════════════════════════════════════════════════════
1480
+ // Agent Email Triggers
1481
+ // ═══════════════════════════════════════════════════════════════════════════
1482
+ /**
1483
+ * Configure an agent's `EMAIL_RECEIVED` trigger and return its computed
1484
+ * email address(es).
1485
+ *
1486
+ * Sets the custom alias, the sender allowlist, and the inbound-handling flags
1487
+ * (`ignore_auto_generated`, `require_sender_auth`, `queue_on_quota`). Omitted
1488
+ * fields are left unchanged; passing `null` (or `""` for `alias`) clears them.
1489
+ *
1490
+ * @param agentId - Agent identifier.
1491
+ * @param triggerId - Trigger identifier.
1492
+ * @param body - The fields to set.
1493
+ * @returns The trigger's resolved addresses and config.
1494
+ */
1495
+ async setEmailTriggerConfig(agentId, triggerId, body) {
1496
+ return await this.request("PUT", `/agents/${agentId}/triggers/${triggerId}/email-config`, {
1497
+ json: body
1498
+ });
1499
+ }
1500
+ // ═══════════════════════════════════════════════════════════════════════════
1501
+ // Agent Email Governance
1502
+ // ═══════════════════════════════════════════════════════════════════════════
1503
+ /**
1504
+ * List recipients who have opted out of this account's agent emails.
1505
+ *
1506
+ * @param opts - Optional agent filter and `limit`/`offset` pagination.
1507
+ * @param opts.agentId - Filter to one agent (account-wide opt-outs still apply).
1508
+ * @param opts.limit - Page size (1-200, default 50).
1509
+ * @param opts.offset - Rows to skip (default 0).
1510
+ * @returns The page of opt-outs plus the total count.
1511
+ */
1512
+ async listAgentEmailOptOuts(opts = {}) {
1513
+ return await this.request("GET", "/agents/agent-email-optouts", {
1514
+ query: { agent_id: opts.agentId, limit: opts.limit, offset: opts.offset }
1515
+ });
1516
+ }
1517
+ /**
1518
+ * Revoke an opt-out, opting the recipient back in to agent emails.
1519
+ *
1520
+ * @param optoutId - Opt-out identifier.
1521
+ */
1522
+ async removeAgentEmailOptOut(optoutId) {
1523
+ await this.request("DELETE", `/agents/agent-email-optouts/${optoutId}`);
1524
+ }
1525
+ /**
1526
+ * List the account's blocked inbound email senders (newest first), plus the
1527
+ * governance `auto_block_mode`.
1528
+ *
1529
+ * @param opts - Optional `limit`/`offset` pagination.
1530
+ * @param opts.limit - Page size (1-200, default 50).
1531
+ * @param opts.offset - Rows to skip (default 0).
1532
+ */
1533
+ async listBlockedEmailSenders(opts = {}) {
1534
+ return await this.request("GET", "/agents/blocked-email-senders", {
1535
+ query: { limit: opts.limit, offset: opts.offset }
1536
+ });
1537
+ }
1538
+ /**
1539
+ * Add a sender address or a whole domain to the account blocklist.
1540
+ *
1541
+ * Idempotent. `match_type` is `"address"` (default) or `"domain"`.
1542
+ * Requires an account owner/admin.
1543
+ *
1544
+ * @param body - The sender or domain to block.
1545
+ * @returns The blocked-sender entry.
1546
+ */
1547
+ async blockEmailSender(body) {
1548
+ return await this.request("POST", "/agents/blocked-email-senders", {
1549
+ json: body
1550
+ });
1551
+ }
1552
+ /**
1553
+ * Remove a blocked sender by id. Requires an account owner/admin.
1554
+ *
1555
+ * @param blockedId - Blocked-sender identifier.
1556
+ */
1557
+ async unblockEmailSender(blockedId) {
1558
+ await this.request("DELETE", `/agents/blocked-email-senders/${blockedId}`);
1559
+ }
1560
+ /**
1561
+ * Set whether a governance BLOCK on an authenticated inbound sender
1562
+ * auto-adds them to the blocklist.
1563
+ *
1564
+ * `mode` is `"disabled"`, `"input"`, or `"input_and_output"`.
1565
+ * Requires an account owner/admin.
1566
+ *
1567
+ * @param body - The mode to set.
1568
+ * @returns The updated blocked-sender list.
1569
+ */
1570
+ async setAutoBlockMode(body) {
1571
+ return await this.request("PUT", "/agents/blocked-email-senders/mode", {
1572
+ json: body
1573
+ });
1574
+ }
1575
+ /**
1576
+ * List recent inbound emails that were quietly discarded before running an
1577
+ * agent (unauthorized sender, unknown alias, spam/virus, flood-shed).
1578
+ *
1579
+ * @param opts - Optional agent filter and result limit.
1580
+ * @param opts.agentId - Filter to a single agent's rejections.
1581
+ * @param opts.limit - Maximum results (1-200, default 50).
1582
+ */
1583
+ async listInboundEmailRejections(opts = {}) {
1584
+ return await this.request("GET", "/agents/inbound-email-rejections", {
1585
+ query: { agent_id: opts.agentId, limit: opts.limit }
1586
+ });
1587
+ }
1588
+ /**
1589
+ * Get the account's inbound-email overload status — whether the circuit
1590
+ * breaker has paused new inbound email, and the size of the QUEUED
1591
+ * (over-quota parked) run backlog.
1592
+ */
1593
+ async getInboundEmailStatus() {
1594
+ return await this.request("GET", "/agents/inbound-email-status");
1595
+ }
1596
+ /**
1597
+ * Fail all of the account's QUEUED (over-quota parked) inbound-email runs at
1598
+ * once.
1599
+ *
1600
+ * A queued run consumed no quota or credits at queue time, so this merely
1601
+ * fails them. Requires an account owner/admin.
1602
+ *
1603
+ * @returns The count cancelled.
1604
+ */
1605
+ async cancelQueuedEmailRuns() {
1606
+ return await this.request("POST", "/agents/inbound-email-status/cancel-queued");
1607
+ }
1608
+ /**
1609
+ * Manually lift the account-wide inbound-email pause.
1610
+ *
1611
+ * If the queued backlog is still above the ceiling the breaker re-arms on the
1612
+ * next evaluation — this is a one-shot override, not a permanent disable.
1613
+ * Requires an account owner/admin.
1614
+ */
1615
+ async resumeInboundEmail() {
1616
+ return await this.request("POST", "/agents/inbound-email-status/resume");
1617
+ }
1618
+ // ═══════════════════════════════════════════════════════════════════════════
1391
1619
  // Knowledge Bases
1392
1620
  // ═══════════════════════════════════════════════════════════════════════════
1393
1621
  /**
@@ -2152,7 +2380,11 @@ var Seclai = class {
2152
2380
  * @param body - Preference update.
2153
2381
  */
2154
2382
  async updateOrganizationAlertPreference(organizationId, alertType, body) {
2155
- return await this.request("PATCH", `/alerts/organization-preferences/${organizationId}/${alertType}`, { json: body });
2383
+ return await this.request(
2384
+ "PATCH",
2385
+ `/alerts/organization-preferences/${organizationId}/${alertType}`,
2386
+ { json: body }
2387
+ );
2156
2388
  }
2157
2389
  // ═══════════════════════════════════════════════════════════════════════════
2158
2390
  // Models & Model Alerts
@@ -2202,7 +2434,13 @@ var Seclai = class {
2202
2434
  */
2203
2435
  async listModels(opts = {}) {
2204
2436
  return await this.request("GET", "/models", {
2205
- query: { provider: opts.provider, supports_tool_use: opts.supportsToolUse, supports_thinking: opts.supportsThinking }
2437
+ query: {
2438
+ provider: opts.provider,
2439
+ supports_tool_use: opts.supportsToolUse,
2440
+ supports_thinking: opts.supportsThinking,
2441
+ supports_input_media: opts.supportsInputMedia,
2442
+ supports_output_media: opts.supportsOutputMedia
2443
+ }
2206
2444
  });
2207
2445
  }
2208
2446
  /**
@@ -2213,6 +2451,20 @@ var Seclai = class {
2213
2451
  async getModel(modelId) {
2214
2452
  return await this.request("GET", `/models/${modelId}/details`);
2215
2453
  }
2454
+ /**
2455
+ * List the media-generation quality tiers and the model + cost each resolves to.
2456
+ *
2457
+ * On a `prompt_call`'s `media_generation` tool — and the dedicated
2458
+ * `generate_*` steps via tier routing — the author/LLM picks a *tier*
2459
+ * (fast/balanced/thorough), never a model. This maps each
2460
+ * `(modality, tier)` to its concrete generator, raw `credits_per_unit`,
2461
+ * `unit_label`, and a human-readable scaled `price_label`.
2462
+ *
2463
+ * Global routing/pricing (the same for every account); read-only.
2464
+ */
2465
+ async getGenerationTiers() {
2466
+ return await this.request("GET", "/models/generation-tiers");
2467
+ }
2216
2468
  // ═══════════════════════════════════════════════════════════════════════════
2217
2469
  // Model Playground Experiments
2218
2470
  // ═══════════════════════════════════════════════════════════════════════════
@@ -2250,6 +2502,17 @@ var Seclai = class {
2250
2502
  async cancelExperiment(experimentId) {
2251
2503
  return await this.request("POST", `/models/playground/experiments/${experimentId}/cancel`);
2252
2504
  }
2505
+ /**
2506
+ * Soft-delete a model playground experiment.
2507
+ *
2508
+ * Removes the experiment from list/detail views while preserving audit
2509
+ * history. Returns HTTP 204 with no body.
2510
+ *
2511
+ * @param experimentId - Experiment identifier.
2512
+ */
2513
+ async deleteExperiment(experimentId) {
2514
+ await this.request("DELETE", `/models/playground/experiments/${experimentId}`);
2515
+ }
2253
2516
  // ═══════════════════════════════════════════════════════════════════════════
2254
2517
  // Search
2255
2518
  // ═══════════════════════════════════════════════════════════════════════════
@@ -2270,6 +2533,143 @@ var Seclai = class {
2270
2533
  query: { q: opts.query, limit: opts.limit, entity_type: opts.entityType }
2271
2534
  });
2272
2535
  }
2536
+ /**
2537
+ * Search the Seclai documentation by content.
2538
+ *
2539
+ * `mode: "keyword"` matches page titles and summaries (fast, no AI cost);
2540
+ * `mode: "semantic"` matches page body content by meaning (uses an embedding).
2541
+ *
2542
+ * Each result carries a `doc_slug` and an optional section `anchor` for
2543
+ * building a `https://seclai.com/docs/<doc_slug>[#<anchor>]` link, a `score`
2544
+ * (not comparable across modes), and — in semantic mode — a `highlight`
2545
+ * (best matching verbatim sentence; `null` for keyword).
2546
+ *
2547
+ * Documentation is global, so results are not account-scoped.
2548
+ *
2549
+ * @param opts - Search options.
2550
+ * @param opts.query - Search query string (required, 1-200 chars).
2551
+ * @param opts.mode - Search strategy (default `"keyword"`).
2552
+ * @param opts.limit - Maximum results (1-20, default 8).
2553
+ */
2554
+ async searchDocs(opts) {
2555
+ return await this.request("GET", "/docs-search", {
2556
+ query: { q: opts.query, mode: opts.mode, limit: opts.limit }
2557
+ });
2558
+ }
2559
+ // ═══════════════════════════════════════════════════════════════════════════
2560
+ // Email Domains
2561
+ // ═══════════════════════════════════════════════════════════════════════════
2562
+ /**
2563
+ * List the account's vanity (`<slug>.seclai.com`) and custom
2564
+ * (`agent.mycompany.com`) agent-email domains.
2565
+ *
2566
+ * Includes each domain's verification status and the DNS records the customer
2567
+ * must publish, plus the plan capabilities (`can_add_vanity` /
2568
+ * `can_add_custom`) and whether one of each kind already exists
2569
+ * (`has_vanity` / `has_custom` — the per-kind limit is 1).
2570
+ *
2571
+ * Requires a user-bound credential; an account-only API key is refused with 403.
2572
+ */
2573
+ async listEmailDomains() {
2574
+ return await this.request("GET", "/email-domains");
2575
+ }
2576
+ /**
2577
+ * Add and provision a new agent-email domain.
2578
+ *
2579
+ * Pass `kind: "vanity"` with `value: "<slug>"`, or `kind: "custom"` with
2580
+ * `value: "agent.mycompany.com"` (optionally `delegated: true` to let Seclai
2581
+ * manage a dedicated Route53 zone). Stands up the SES identity + DNS and
2582
+ * returns the records the customer must publish. Requires an account
2583
+ * owner/admin.
2584
+ *
2585
+ * @param body - The domain to add. `delegated` defaults to `false` server-side.
2586
+ */
2587
+ async addEmailDomain(body) {
2588
+ return await this.request("POST", "/email-domains", { json: body });
2589
+ }
2590
+ /**
2591
+ * Remove a domain and tear down its SES identity + DNS / receipt-rule recipient.
2592
+ *
2593
+ * Returns a `cleanup_note` when the removed domain was Seclai-managed
2594
+ * (delegated), reminding you to delete the registrar NS delegation record
2595
+ * (dangling-delegation / subdomain-takeover guard). Requires an account
2596
+ * owner/admin.
2597
+ *
2598
+ * @param domainId - Domain identifier.
2599
+ */
2600
+ async removeEmailDomain(domainId) {
2601
+ return await this.request("DELETE", `/email-domains/${domainId}`);
2602
+ }
2603
+ /**
2604
+ * Run a verification check immediately ("Check now").
2605
+ *
2606
+ * Re-polls SES + DNS for this domain instead of waiting for the background
2607
+ * verification sweep, and returns its updated status + DNS-record check
2608
+ * results. Useful right after publishing the required records. Requires an
2609
+ * account owner/admin.
2610
+ *
2611
+ * @param domainId - Domain identifier.
2612
+ */
2613
+ async verifyEmailDomain(domainId) {
2614
+ return await this.request("POST", `/email-domains/${domainId}/verify`);
2615
+ }
2616
+ /**
2617
+ * Promote a verified domain to the account's primary domain.
2618
+ *
2619
+ * Agent email then sends FROM and receives ON this domain
2620
+ * (`<agentID>@<domain>`, `<alias>@<domain>`) instead of the shared
2621
+ * `agent.seclai.com`. The domain must be verified. Requires an account
2622
+ * owner/admin.
2623
+ *
2624
+ * @param domainId - Domain identifier.
2625
+ */
2626
+ async setPrimaryEmailDomain(domainId) {
2627
+ return await this.request("POST", `/email-domains/${domainId}/primary`);
2628
+ }
2629
+ /**
2630
+ * Revert to the shared `agent.seclai.com` sending/inbound domain.
2631
+ *
2632
+ * Clears the account's primary domain WITHOUT removing the configured
2633
+ * domain(s) — they stay verified and can be promoted again later. Requires an
2634
+ * account owner/admin.
2635
+ */
2636
+ async useSharedEmailDomain() {
2637
+ await this.request("POST", "/email-domains/use-shared-domain");
2638
+ }
2639
+ /**
2640
+ * Send a test message FROM a verified domain (`noreply@<domain>`) TO the
2641
+ * account owner's email.
2642
+ *
2643
+ * Confirms end-to-end that the domain actually sends (SES verified, DKIM/SPF
2644
+ * aligned). Never sends to any other address, so it can't be used as an open
2645
+ * relay. Requires an account owner/admin.
2646
+ *
2647
+ * @param domainId - Domain identifier.
2648
+ */
2649
+ async sendEmailDomainTestEmail(domainId) {
2650
+ return await this.request("POST", `/email-domains/${domainId}/test-email`);
2651
+ }
2652
+ /**
2653
+ * Get the DMARC aggregate-report summary for a domain.
2654
+ *
2655
+ * Pass rate, disposition breakdown (`none`/`quarantine`/`reject`), and top
2656
+ * failing source IPs from the DMARC `rua` reports over the last `days`
2657
+ * (clamped by the service).
2658
+ *
2659
+ * Populated for domains whose DNS zone Seclai controls (vanity + delegated
2660
+ * custom); a self-managed custom domain keeps its own DMARC reporting and
2661
+ * returns an all-zero summary.
2662
+ *
2663
+ * @param domainId - Domain identifier.
2664
+ * @param opts - Reporting window options.
2665
+ * @param opts.days - Window length in days (default 30).
2666
+ * @param opts.topSources - Number of top failing sources to return (default 10).
2667
+ */
2668
+ async getDmarcSummary(domainId, opts = {}) {
2669
+ return await this.request("GET", `/email-domains/${domainId}/dmarc`, {
2670
+ query: { days: opts.days, top_sources: opts.topSources }
2671
+ });
2672
+ }
2273
2673
  // ═══════════════════════════════════════════════════════════════════════════
2274
2674
  // Top-Level AI Assistant
2275
2675
  // ═══════════════════════════════════════════════════════════════════════════