@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.js CHANGED
@@ -697,6 +697,22 @@ var Seclai = class {
697
697
  return await response.json();
698
698
  }
699
699
  // ═══════════════════════════════════════════════════════════════════════════
700
+ // Identity
701
+ // ═══════════════════════════════════════════════════════════════════════════
702
+ /**
703
+ * Get the authenticated user's identity.
704
+ *
705
+ * Returns the personal `account_id` plus every organization the user belongs
706
+ * to — each with its own `id`, display `name`, and `account_id`. Use it to
707
+ * discover the account IDs that can be passed as the client's `accountId`
708
+ * option (sent as the `X-Account-Id` header) to target an org context.
709
+ *
710
+ * @returns The current user's account ID and organization memberships.
711
+ */
712
+ async getMe() {
713
+ return await this.request("GET", "/me");
714
+ }
715
+ // ═══════════════════════════════════════════════════════════════════════════
700
716
  // Agents — CRUD
701
717
  // ═══════════════════════════════════════════════════════════════════════════
702
718
  /**
@@ -747,6 +763,48 @@ var Seclai = class {
747
763
  await this.request("DELETE", `/agents/${agentId}`);
748
764
  }
749
765
  // ═══════════════════════════════════════════════════════════════════════════
766
+ // Agents — Enable / Disable
767
+ // ═══════════════════════════════════════════════════════════════════════════
768
+ /**
769
+ * Pause (disable) an agent so it stops firing from every trigger path.
770
+ *
771
+ * API runs return HTTP 409, inbound email is turned away, and scheduled /
772
+ * content triggers are skipped.
773
+ *
774
+ * Fails with HTTP 409 when other live agents still call this one via a
775
+ * `call_agent` step — use {@link getAgentCallers} to list them, and disable
776
+ * those first.
777
+ *
778
+ * @param agentId - Agent identifier.
779
+ * @returns The updated agent summary.
780
+ */
781
+ async disableAgent(agentId) {
782
+ return await this.request("POST", `/agents/${agentId}/disable`);
783
+ }
784
+ /**
785
+ * Resume (enable) a paused agent.
786
+ *
787
+ * Clears the disable state whether the agent was paused manually or
788
+ * auto-paused by the inbound-email overload safeguard.
789
+ *
790
+ * @param agentId - Agent identifier.
791
+ * @returns The updated agent summary.
792
+ */
793
+ async enableAgent(agentId) {
794
+ return await this.request("POST", `/agents/${agentId}/enable`);
795
+ }
796
+ /**
797
+ * List the live agents that call this agent via a `call_agent` step.
798
+ *
799
+ * These must be disabled before this agent can be paused.
800
+ *
801
+ * @param agentId - Agent identifier.
802
+ * @returns The calling agents.
803
+ */
804
+ async getAgentCallers(agentId) {
805
+ return await this.request("GET", `/agents/${agentId}/callers`);
806
+ }
807
+ // ═══════════════════════════════════════════════════════════════════════════
750
808
  // Agent Export / Import
751
809
  // ═══════════════════════════════════════════════════════════════════════════
752
810
  /**
@@ -1161,6 +1219,37 @@ var Seclai = class {
1161
1219
  async getAgentInputUploadStatus(agentId, uploadId) {
1162
1220
  return await this.request("GET", `/agents/${agentId}/input-uploads/${uploadId}`);
1163
1221
  }
1222
+ /**
1223
+ * Get the static attachment-reference contract for an agent — what files (if
1224
+ * any) its definition expects on a run.
1225
+ *
1226
+ * Call this before staging uploads to learn whether the agent accepts files
1227
+ * at all (`requires_uploads`) and which specific filenames, indexes, or glob
1228
+ * patterns its templates reference. A run-time upload batch that doesn't
1229
+ * satisfy every declared selector is rejected with HTTP 400.
1230
+ *
1231
+ * @param agentId - Agent identifier.
1232
+ * @returns The agent's attachment-reference contract.
1233
+ */
1234
+ async getAgentAttachmentReferences(agentId) {
1235
+ return await this.request("GET", `/agents/${agentId}/attachment-references`);
1236
+ }
1237
+ /**
1238
+ * Download a file attachment emitted by a step in an agent run.
1239
+ *
1240
+ * Returns the raw `Response` so you can stream or save the binary data.
1241
+ *
1242
+ * @param runId - Run identifier.
1243
+ * @param attachmentId - URL-safe-base64-encoded `storage_key` of the attachment
1244
+ * (as surfaced in run output manifests and webhook/email payloads).
1245
+ * @param opts - Optional `downloadName` filename hint for the download disposition.
1246
+ * @returns Raw response with the attachment bytes.
1247
+ */
1248
+ async downloadAgentRunAttachment(runId, attachmentId, opts = {}) {
1249
+ return await this.requestRaw("GET", `/v2/agent-runs/${runId}/attachments/${attachmentId}`, {
1250
+ query: { download_name: opts.downloadName }
1251
+ });
1252
+ }
1164
1253
  // ═══════════════════════════════════════════════════════════════════════════
1165
1254
  // Agent AI Assistant (Steps Generation)
1166
1255
  // ═══════════════════════════════════════════════════════════════════════════
@@ -1338,6 +1427,145 @@ var Seclai = class {
1338
1427
  });
1339
1428
  }
1340
1429
  // ═══════════════════════════════════════════════════════════════════════════
1430
+ // Agent Email Triggers
1431
+ // ═══════════════════════════════════════════════════════════════════════════
1432
+ /**
1433
+ * Configure an agent's `EMAIL_RECEIVED` trigger and return its computed
1434
+ * email address(es).
1435
+ *
1436
+ * Sets the custom alias, the sender allowlist, and the inbound-handling flags
1437
+ * (`ignore_auto_generated`, `require_sender_auth`, `queue_on_quota`). Omitted
1438
+ * fields are left unchanged; passing `null` (or `""` for `alias`) clears them.
1439
+ *
1440
+ * @param agentId - Agent identifier.
1441
+ * @param triggerId - Trigger identifier.
1442
+ * @param body - The fields to set.
1443
+ * @returns The trigger's resolved addresses and config.
1444
+ */
1445
+ async setEmailTriggerConfig(agentId, triggerId, body) {
1446
+ return await this.request("PUT", `/agents/${agentId}/triggers/${triggerId}/email-config`, {
1447
+ json: body
1448
+ });
1449
+ }
1450
+ // ═══════════════════════════════════════════════════════════════════════════
1451
+ // Agent Email Governance
1452
+ // ═══════════════════════════════════════════════════════════════════════════
1453
+ /**
1454
+ * List recipients who have opted out of this account's agent emails.
1455
+ *
1456
+ * @param opts - Optional agent filter and `limit`/`offset` pagination.
1457
+ * @param opts.agentId - Filter to one agent (account-wide opt-outs still apply).
1458
+ * @param opts.limit - Page size (1-200, default 50).
1459
+ * @param opts.offset - Rows to skip (default 0).
1460
+ * @returns The page of opt-outs plus the total count.
1461
+ */
1462
+ async listAgentEmailOptOuts(opts = {}) {
1463
+ return await this.request("GET", "/agents/agent-email-optouts", {
1464
+ query: { agent_id: opts.agentId, limit: opts.limit, offset: opts.offset }
1465
+ });
1466
+ }
1467
+ /**
1468
+ * Revoke an opt-out, opting the recipient back in to agent emails.
1469
+ *
1470
+ * @param optoutId - Opt-out identifier.
1471
+ */
1472
+ async removeAgentEmailOptOut(optoutId) {
1473
+ await this.request("DELETE", `/agents/agent-email-optouts/${optoutId}`);
1474
+ }
1475
+ /**
1476
+ * List the account's blocked inbound email senders (newest first), plus the
1477
+ * governance `auto_block_mode`.
1478
+ *
1479
+ * @param opts - Optional `limit`/`offset` pagination.
1480
+ * @param opts.limit - Page size (1-200, default 50).
1481
+ * @param opts.offset - Rows to skip (default 0).
1482
+ */
1483
+ async listBlockedEmailSenders(opts = {}) {
1484
+ return await this.request("GET", "/agents/blocked-email-senders", {
1485
+ query: { limit: opts.limit, offset: opts.offset }
1486
+ });
1487
+ }
1488
+ /**
1489
+ * Add a sender address or a whole domain to the account blocklist.
1490
+ *
1491
+ * Idempotent. `match_type` is `"address"` (default) or `"domain"`.
1492
+ * Requires an account owner/admin.
1493
+ *
1494
+ * @param body - The sender or domain to block.
1495
+ * @returns The blocked-sender entry.
1496
+ */
1497
+ async blockEmailSender(body) {
1498
+ return await this.request("POST", "/agents/blocked-email-senders", {
1499
+ json: body
1500
+ });
1501
+ }
1502
+ /**
1503
+ * Remove a blocked sender by id. Requires an account owner/admin.
1504
+ *
1505
+ * @param blockedId - Blocked-sender identifier.
1506
+ */
1507
+ async unblockEmailSender(blockedId) {
1508
+ await this.request("DELETE", `/agents/blocked-email-senders/${blockedId}`);
1509
+ }
1510
+ /**
1511
+ * Set whether a governance BLOCK on an authenticated inbound sender
1512
+ * auto-adds them to the blocklist.
1513
+ *
1514
+ * `mode` is `"disabled"`, `"input"`, or `"input_and_output"`.
1515
+ * Requires an account owner/admin.
1516
+ *
1517
+ * @param body - The mode to set.
1518
+ * @returns The updated blocked-sender list.
1519
+ */
1520
+ async setAutoBlockMode(body) {
1521
+ return await this.request("PUT", "/agents/blocked-email-senders/mode", {
1522
+ json: body
1523
+ });
1524
+ }
1525
+ /**
1526
+ * List recent inbound emails that were quietly discarded before running an
1527
+ * agent (unauthorized sender, unknown alias, spam/virus, flood-shed).
1528
+ *
1529
+ * @param opts - Optional agent filter and result limit.
1530
+ * @param opts.agentId - Filter to a single agent's rejections.
1531
+ * @param opts.limit - Maximum results (1-200, default 50).
1532
+ */
1533
+ async listInboundEmailRejections(opts = {}) {
1534
+ return await this.request("GET", "/agents/inbound-email-rejections", {
1535
+ query: { agent_id: opts.agentId, limit: opts.limit }
1536
+ });
1537
+ }
1538
+ /**
1539
+ * Get the account's inbound-email overload status — whether the circuit
1540
+ * breaker has paused new inbound email, and the size of the QUEUED
1541
+ * (over-quota parked) run backlog.
1542
+ */
1543
+ async getInboundEmailStatus() {
1544
+ return await this.request("GET", "/agents/inbound-email-status");
1545
+ }
1546
+ /**
1547
+ * Fail all of the account's QUEUED (over-quota parked) inbound-email runs at
1548
+ * once.
1549
+ *
1550
+ * A queued run consumed no quota or credits at queue time, so this merely
1551
+ * fails them. Requires an account owner/admin.
1552
+ *
1553
+ * @returns The count cancelled.
1554
+ */
1555
+ async cancelQueuedEmailRuns() {
1556
+ return await this.request("POST", "/agents/inbound-email-status/cancel-queued");
1557
+ }
1558
+ /**
1559
+ * Manually lift the account-wide inbound-email pause.
1560
+ *
1561
+ * If the queued backlog is still above the ceiling the breaker re-arms on the
1562
+ * next evaluation — this is a one-shot override, not a permanent disable.
1563
+ * Requires an account owner/admin.
1564
+ */
1565
+ async resumeInboundEmail() {
1566
+ return await this.request("POST", "/agents/inbound-email-status/resume");
1567
+ }
1568
+ // ═══════════════════════════════════════════════════════════════════════════
1341
1569
  // Knowledge Bases
1342
1570
  // ═══════════════════════════════════════════════════════════════════════════
1343
1571
  /**
@@ -2102,7 +2330,11 @@ var Seclai = class {
2102
2330
  * @param body - Preference update.
2103
2331
  */
2104
2332
  async updateOrganizationAlertPreference(organizationId, alertType, body) {
2105
- return await this.request("PATCH", `/alerts/organization-preferences/${organizationId}/${alertType}`, { json: body });
2333
+ return await this.request(
2334
+ "PATCH",
2335
+ `/alerts/organization-preferences/${organizationId}/${alertType}`,
2336
+ { json: body }
2337
+ );
2106
2338
  }
2107
2339
  // ═══════════════════════════════════════════════════════════════════════════
2108
2340
  // Models & Model Alerts
@@ -2152,7 +2384,13 @@ var Seclai = class {
2152
2384
  */
2153
2385
  async listModels(opts = {}) {
2154
2386
  return await this.request("GET", "/models", {
2155
- query: { provider: opts.provider, supports_tool_use: opts.supportsToolUse, supports_thinking: opts.supportsThinking }
2387
+ query: {
2388
+ provider: opts.provider,
2389
+ supports_tool_use: opts.supportsToolUse,
2390
+ supports_thinking: opts.supportsThinking,
2391
+ supports_input_media: opts.supportsInputMedia,
2392
+ supports_output_media: opts.supportsOutputMedia
2393
+ }
2156
2394
  });
2157
2395
  }
2158
2396
  /**
@@ -2163,6 +2401,20 @@ var Seclai = class {
2163
2401
  async getModel(modelId) {
2164
2402
  return await this.request("GET", `/models/${modelId}/details`);
2165
2403
  }
2404
+ /**
2405
+ * List the media-generation quality tiers and the model + cost each resolves to.
2406
+ *
2407
+ * On a `prompt_call`'s `media_generation` tool — and the dedicated
2408
+ * `generate_*` steps via tier routing — the author/LLM picks a *tier*
2409
+ * (fast/balanced/thorough), never a model. This maps each
2410
+ * `(modality, tier)` to its concrete generator, raw `credits_per_unit`,
2411
+ * `unit_label`, and a human-readable scaled `price_label`.
2412
+ *
2413
+ * Global routing/pricing (the same for every account); read-only.
2414
+ */
2415
+ async getGenerationTiers() {
2416
+ return await this.request("GET", "/models/generation-tiers");
2417
+ }
2166
2418
  // ═══════════════════════════════════════════════════════════════════════════
2167
2419
  // Model Playground Experiments
2168
2420
  // ═══════════════════════════════════════════════════════════════════════════
@@ -2200,6 +2452,17 @@ var Seclai = class {
2200
2452
  async cancelExperiment(experimentId) {
2201
2453
  return await this.request("POST", `/models/playground/experiments/${experimentId}/cancel`);
2202
2454
  }
2455
+ /**
2456
+ * Soft-delete a model playground experiment.
2457
+ *
2458
+ * Removes the experiment from list/detail views while preserving audit
2459
+ * history. Returns HTTP 204 with no body.
2460
+ *
2461
+ * @param experimentId - Experiment identifier.
2462
+ */
2463
+ async deleteExperiment(experimentId) {
2464
+ await this.request("DELETE", `/models/playground/experiments/${experimentId}`);
2465
+ }
2203
2466
  // ═══════════════════════════════════════════════════════════════════════════
2204
2467
  // Search
2205
2468
  // ═══════════════════════════════════════════════════════════════════════════
@@ -2220,6 +2483,143 @@ var Seclai = class {
2220
2483
  query: { q: opts.query, limit: opts.limit, entity_type: opts.entityType }
2221
2484
  });
2222
2485
  }
2486
+ /**
2487
+ * Search the Seclai documentation by content.
2488
+ *
2489
+ * `mode: "keyword"` matches page titles and summaries (fast, no AI cost);
2490
+ * `mode: "semantic"` matches page body content by meaning (uses an embedding).
2491
+ *
2492
+ * Each result carries a `doc_slug` and an optional section `anchor` for
2493
+ * building a `https://seclai.com/docs/<doc_slug>[#<anchor>]` link, a `score`
2494
+ * (not comparable across modes), and — in semantic mode — a `highlight`
2495
+ * (best matching verbatim sentence; `null` for keyword).
2496
+ *
2497
+ * Documentation is global, so results are not account-scoped.
2498
+ *
2499
+ * @param opts - Search options.
2500
+ * @param opts.query - Search query string (required, 1-200 chars).
2501
+ * @param opts.mode - Search strategy (default `"keyword"`).
2502
+ * @param opts.limit - Maximum results (1-20, default 8).
2503
+ */
2504
+ async searchDocs(opts) {
2505
+ return await this.request("GET", "/docs-search", {
2506
+ query: { q: opts.query, mode: opts.mode, limit: opts.limit }
2507
+ });
2508
+ }
2509
+ // ═══════════════════════════════════════════════════════════════════════════
2510
+ // Email Domains
2511
+ // ═══════════════════════════════════════════════════════════════════════════
2512
+ /**
2513
+ * List the account's vanity (`<slug>.seclai.com`) and custom
2514
+ * (`agent.mycompany.com`) agent-email domains.
2515
+ *
2516
+ * Includes each domain's verification status and the DNS records the customer
2517
+ * must publish, plus the plan capabilities (`can_add_vanity` /
2518
+ * `can_add_custom`) and whether one of each kind already exists
2519
+ * (`has_vanity` / `has_custom` — the per-kind limit is 1).
2520
+ *
2521
+ * Requires a user-bound credential; an account-only API key is refused with 403.
2522
+ */
2523
+ async listEmailDomains() {
2524
+ return await this.request("GET", "/email-domains");
2525
+ }
2526
+ /**
2527
+ * Add and provision a new agent-email domain.
2528
+ *
2529
+ * Pass `kind: "vanity"` with `value: "<slug>"`, or `kind: "custom"` with
2530
+ * `value: "agent.mycompany.com"` (optionally `delegated: true` to let Seclai
2531
+ * manage a dedicated Route53 zone). Stands up the SES identity + DNS and
2532
+ * returns the records the customer must publish. Requires an account
2533
+ * owner/admin.
2534
+ *
2535
+ * @param body - The domain to add. `delegated` defaults to `false` server-side.
2536
+ */
2537
+ async addEmailDomain(body) {
2538
+ return await this.request("POST", "/email-domains", { json: body });
2539
+ }
2540
+ /**
2541
+ * Remove a domain and tear down its SES identity + DNS / receipt-rule recipient.
2542
+ *
2543
+ * Returns a `cleanup_note` when the removed domain was Seclai-managed
2544
+ * (delegated), reminding you to delete the registrar NS delegation record
2545
+ * (dangling-delegation / subdomain-takeover guard). Requires an account
2546
+ * owner/admin.
2547
+ *
2548
+ * @param domainId - Domain identifier.
2549
+ */
2550
+ async removeEmailDomain(domainId) {
2551
+ return await this.request("DELETE", `/email-domains/${domainId}`);
2552
+ }
2553
+ /**
2554
+ * Run a verification check immediately ("Check now").
2555
+ *
2556
+ * Re-polls SES + DNS for this domain instead of waiting for the background
2557
+ * verification sweep, and returns its updated status + DNS-record check
2558
+ * results. Useful right after publishing the required records. Requires an
2559
+ * account owner/admin.
2560
+ *
2561
+ * @param domainId - Domain identifier.
2562
+ */
2563
+ async verifyEmailDomain(domainId) {
2564
+ return await this.request("POST", `/email-domains/${domainId}/verify`);
2565
+ }
2566
+ /**
2567
+ * Promote a verified domain to the account's primary domain.
2568
+ *
2569
+ * Agent email then sends FROM and receives ON this domain
2570
+ * (`<agentID>@<domain>`, `<alias>@<domain>`) instead of the shared
2571
+ * `agent.seclai.com`. The domain must be verified. Requires an account
2572
+ * owner/admin.
2573
+ *
2574
+ * @param domainId - Domain identifier.
2575
+ */
2576
+ async setPrimaryEmailDomain(domainId) {
2577
+ return await this.request("POST", `/email-domains/${domainId}/primary`);
2578
+ }
2579
+ /**
2580
+ * Revert to the shared `agent.seclai.com` sending/inbound domain.
2581
+ *
2582
+ * Clears the account's primary domain WITHOUT removing the configured
2583
+ * domain(s) — they stay verified and can be promoted again later. Requires an
2584
+ * account owner/admin.
2585
+ */
2586
+ async useSharedEmailDomain() {
2587
+ await this.request("POST", "/email-domains/use-shared-domain");
2588
+ }
2589
+ /**
2590
+ * Send a test message FROM a verified domain (`noreply@<domain>`) TO the
2591
+ * account owner's email.
2592
+ *
2593
+ * Confirms end-to-end that the domain actually sends (SES verified, DKIM/SPF
2594
+ * aligned). Never sends to any other address, so it can't be used as an open
2595
+ * relay. Requires an account owner/admin.
2596
+ *
2597
+ * @param domainId - Domain identifier.
2598
+ */
2599
+ async sendEmailDomainTestEmail(domainId) {
2600
+ return await this.request("POST", `/email-domains/${domainId}/test-email`);
2601
+ }
2602
+ /**
2603
+ * Get the DMARC aggregate-report summary for a domain.
2604
+ *
2605
+ * Pass rate, disposition breakdown (`none`/`quarantine`/`reject`), and top
2606
+ * failing source IPs from the DMARC `rua` reports over the last `days`
2607
+ * (clamped by the service).
2608
+ *
2609
+ * Populated for domains whose DNS zone Seclai controls (vanity + delegated
2610
+ * custom); a self-managed custom domain keeps its own DMARC reporting and
2611
+ * returns an all-zero summary.
2612
+ *
2613
+ * @param domainId - Domain identifier.
2614
+ * @param opts - Reporting window options.
2615
+ * @param opts.days - Window length in days (default 30).
2616
+ * @param opts.topSources - Number of top failing sources to return (default 10).
2617
+ */
2618
+ async getDmarcSummary(domainId, opts = {}) {
2619
+ return await this.request("GET", `/email-domains/${domainId}/dmarc`, {
2620
+ query: { days: opts.days, top_sources: opts.topSources }
2621
+ });
2622
+ }
2223
2623
  // ═══════════════════════════════════════════════════════════════════════════
2224
2624
  // Top-Level AI Assistant
2225
2625
  // ═══════════════════════════════════════════════════════════════════════════