@savantoai/ai-sdk 2.1.0 → 3.1.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
@@ -1,10 +1,11 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1
2
 
2
3
  //#region src/generated/core/bodySerializer.gen.ts
3
4
  const jsonBodySerializer = { bodySerializer: (body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value) };
4
5
 
5
6
  //#endregion
6
7
  //#region src/generated/core/serverSentEvents.gen.ts
7
- const createSseClient = ({ onRequest, onSseError, onSseEvent, responseTransformer, responseValidator, sseDefaultRetryDelay, sseMaxRetryAttempts, sseMaxRetryDelay, sseSleepFn, url, ...options }) => {
8
+ function createSseClient({ onRequest, onSseError, onSseEvent, responseTransformer, responseValidator, sseDefaultRetryDelay, sseMaxRetryAttempts, sseMaxRetryDelay, sseSleepFn, url, ...options }) {
8
9
  let lastEventId;
9
10
  const sleep = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
10
11
  const createStream = async function* () {
@@ -42,7 +43,7 @@ const createSseClient = ({ onRequest, onSseError, onSseEvent, responseTransforme
42
43
  const { done, value } = await reader.read();
43
44
  if (done) break;
44
45
  buffer += value;
45
- buffer = buffer.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
46
+ buffer = buffer.replace(/\r\n?/g, "\n");
46
47
  const chunks = buffer.split("\n\n");
47
48
  buffer = chunks.pop() ?? "";
48
49
  for (const chunk of chunks) {
@@ -93,7 +94,7 @@ const createSseClient = ({ onRequest, onSseError, onSseEvent, responseTransforme
93
94
  }
94
95
  };
95
96
  return { stream: createStream() };
96
- };
97
+ }
97
98
 
98
99
  //#endregion
99
100
  //#region src/generated/core/pathSerializer.gen.ts
@@ -123,12 +124,12 @@ const separatorObjectExplode = (style) => {
123
124
  };
124
125
  const serializeArrayParam = ({ allowReserved, explode, name, style, value }) => {
125
126
  if (!explode) {
126
- const joinedValues$1 = (allowReserved ? value : value.map((v) => encodeURIComponent(v))).join(separatorArrayNoExplode(style));
127
+ const joinedValues = (allowReserved ? value : value.map((v) => encodeURIComponent(v))).join(separatorArrayNoExplode(style));
127
128
  switch (style) {
128
- case "label": return `.${joinedValues$1}`;
129
- case "matrix": return `;${name}=${joinedValues$1}`;
130
- case "simple": return joinedValues$1;
131
- default: return `${name}=${joinedValues$1}`;
129
+ case "label": return `.${joinedValues}`;
130
+ case "matrix": return `;${name}=${joinedValues}`;
131
+ case "simple": return joinedValues;
132
+ default: return `${name}=${joinedValues}`;
132
133
  }
133
134
  }
134
135
  const separator = separatorArrayExplode(style);
@@ -158,12 +159,12 @@ const serializeObjectParam = ({ allowReserved, explode, name, style, value, valu
158
159
  allowReserved ? v : encodeURIComponent(v)
159
160
  ];
160
161
  });
161
- const joinedValues$1 = values.join(",");
162
+ const joinedValues = values.join(",");
162
163
  switch (style) {
163
- case "form": return `${name}=${joinedValues$1}`;
164
- case "label": return `.${joinedValues$1}`;
165
- case "matrix": return `;${name}=${joinedValues$1}`;
166
- default: return joinedValues$1;
164
+ case "form": return `${name}=${joinedValues}`;
165
+ case "label": return `.${joinedValues}`;
166
+ case "matrix": return `;${name}=${joinedValues}`;
167
+ default: return joinedValues;
167
168
  }
168
169
  }
169
170
  const separator = separatorObjectExplode(style);
@@ -324,8 +325,8 @@ const checkForExistence = (options, name) => {
324
325
  if (options.headers.has(name) || options.query?.[name] || options.headers.get("Cookie")?.includes(`${name}=`)) return true;
325
326
  return false;
326
327
  };
327
- const setAuthParams = async ({ security, ...options }) => {
328
- for (const auth of security) {
328
+ async function setAuthParams(options) {
329
+ for (const auth of options.security ?? []) {
329
330
  if (checkForExistence(options, auth.name)) continue;
330
331
  const token = await getAuthToken(auth, options.auth);
331
332
  if (!token) continue;
@@ -338,13 +339,12 @@ const setAuthParams = async ({ security, ...options }) => {
338
339
  case "cookie":
339
340
  options.headers.append("Cookie", `${name}=${token}`);
340
341
  break;
341
- case "header":
342
342
  default:
343
343
  options.headers.set(name, token);
344
344
  break;
345
345
  }
346
346
  }
347
- };
347
+ }
348
348
  const buildUrl = (options) => getUrl({
349
349
  baseUrl: options.baseUrl,
350
350
  path: options.path,
@@ -441,8 +441,8 @@ const createConfig = (override = {}) => ({
441
441
  const createClient = (config = {}) => {
442
442
  let _config = mergeConfigs(createConfig(), config);
443
443
  const getConfig = () => ({ ..._config });
444
- const setConfig = (config$1) => {
445
- _config = mergeConfigs(_config, config$1);
444
+ const setConfig = (config) => {
445
+ _config = mergeConfigs(_config, config);
446
446
  return getConfig();
447
447
  };
448
448
  const interceptors = createInterceptors();
@@ -454,114 +454,106 @@ const createClient = (config = {}) => {
454
454
  headers: mergeHeaders(_config.headers, options.headers),
455
455
  serializedBody: void 0
456
456
  };
457
- if (opts.security) await setAuthParams({
458
- ...opts,
459
- security: opts.security
460
- });
457
+ if (opts.security) await setAuthParams(opts);
461
458
  if (opts.requestValidator) await opts.requestValidator(opts);
462
459
  if (opts.body !== void 0 && opts.bodySerializer) opts.serializedBody = opts.bodySerializer(opts.body);
463
460
  if (opts.body === void 0 || opts.serializedBody === "") opts.headers.delete("Content-Type");
461
+ const resolvedOpts = opts;
464
462
  return {
465
- opts,
466
- url: buildUrl(opts)
463
+ opts: resolvedOpts,
464
+ url: buildUrl(resolvedOpts)
467
465
  };
468
466
  };
469
467
  const request = async (options) => {
470
- const { opts, url } = await beforeRequest(options);
471
- const requestInit = {
472
- redirect: "follow",
473
- ...opts,
474
- body: getValidRequestBody(opts)
475
- };
476
- let request$1 = new Request(url, requestInit);
477
- for (const fn of interceptors.request.fns) if (fn) request$1 = await fn(request$1, opts);
478
- const _fetch = opts.fetch;
468
+ const throwOnError = options.throwOnError ?? _config.throwOnError;
469
+ const responseStyle = options.responseStyle ?? _config.responseStyle;
470
+ let request;
479
471
  let response;
480
472
  try {
481
- response = await _fetch(request$1);
482
- } catch (error$1) {
483
- let finalError$1 = error$1;
484
- for (const fn of interceptors.error.fns) if (fn) finalError$1 = await fn(error$1, void 0, request$1, opts);
485
- finalError$1 = finalError$1 || {};
486
- if (opts.throwOnError) throw finalError$1;
487
- return opts.responseStyle === "data" ? void 0 : {
488
- error: finalError$1,
489
- request: request$1,
490
- response: void 0
473
+ const { opts, url } = await beforeRequest(options);
474
+ const requestInit = {
475
+ redirect: "follow",
476
+ ...opts,
477
+ body: getValidRequestBody(opts)
491
478
  };
492
- }
493
- for (const fn of interceptors.response.fns) if (fn) response = await fn(response, request$1, opts);
494
- const result = {
495
- request: request$1,
496
- response
497
- };
498
- if (response.ok) {
499
- const parseAs = (opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
500
- if (response.status === 204 || response.headers.get("Content-Length") === "0") {
501
- let emptyData;
479
+ request = new Request(url, requestInit);
480
+ for (const fn of interceptors.request.fns) if (fn) request = await fn(request, opts);
481
+ const _fetch = opts.fetch;
482
+ response = await _fetch(request);
483
+ for (const fn of interceptors.response.fns) if (fn) response = await fn(response, request, opts);
484
+ const result = {
485
+ request,
486
+ response
487
+ };
488
+ if (response.ok) {
489
+ const parseAs = (opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
490
+ if (response.status === 204 || response.headers.get("Content-Length") === "0") {
491
+ let emptyData;
492
+ switch (parseAs) {
493
+ case "arrayBuffer":
494
+ case "blob":
495
+ case "text":
496
+ emptyData = await response[parseAs]();
497
+ break;
498
+ case "formData":
499
+ emptyData = new FormData();
500
+ break;
501
+ case "stream":
502
+ emptyData = response.body;
503
+ break;
504
+ default:
505
+ emptyData = {};
506
+ break;
507
+ }
508
+ return opts.responseStyle === "data" ? emptyData : {
509
+ data: emptyData,
510
+ ...result
511
+ };
512
+ }
513
+ let data;
502
514
  switch (parseAs) {
503
515
  case "arrayBuffer":
504
516
  case "blob":
505
- case "text":
506
- emptyData = await response[parseAs]();
507
- break;
508
517
  case "formData":
509
- emptyData = new FormData();
510
- break;
511
- case "stream":
512
- emptyData = response.body;
518
+ case "text":
519
+ data = await response[parseAs]();
513
520
  break;
514
- case "json":
515
- default:
516
- emptyData = {};
521
+ case "json": {
522
+ const text = await response.text();
523
+ data = text ? JSON.parse(text) : {};
517
524
  break;
525
+ }
526
+ case "stream": return opts.responseStyle === "data" ? response.body : {
527
+ data: response.body,
528
+ ...result
529
+ };
518
530
  }
519
- return opts.responseStyle === "data" ? emptyData : {
520
- data: emptyData,
521
- ...result
522
- };
523
- }
524
- let data;
525
- switch (parseAs) {
526
- case "arrayBuffer":
527
- case "blob":
528
- case "formData":
529
- case "text":
530
- data = await response[parseAs]();
531
- break;
532
- case "json": {
533
- const text = await response.text();
534
- data = text ? JSON.parse(text) : {};
535
- break;
531
+ if (parseAs === "json") {
532
+ if (opts.responseValidator) await opts.responseValidator(data);
533
+ if (opts.responseTransformer) data = await opts.responseTransformer(data);
536
534
  }
537
- case "stream": return opts.responseStyle === "data" ? response.body : {
538
- data: response.body,
535
+ return opts.responseStyle === "data" ? data : {
536
+ data,
539
537
  ...result
540
538
  };
541
539
  }
542
- if (parseAs === "json") {
543
- if (opts.responseValidator) await opts.responseValidator(data);
544
- if (opts.responseTransformer) data = await opts.responseTransformer(data);
545
- }
546
- return opts.responseStyle === "data" ? data : {
547
- data,
548
- ...result
540
+ const textError = await response.text();
541
+ let jsonError;
542
+ try {
543
+ jsonError = JSON.parse(textError);
544
+ } catch {}
545
+ throw jsonError ?? textError;
546
+ } catch (error) {
547
+ let finalError = error;
548
+ for (const fn of interceptors.error.fns) if (fn) finalError = await fn(finalError, response, request, options);
549
+ finalError = finalError || {};
550
+ if (throwOnError) throw finalError;
551
+ return responseStyle === "data" ? void 0 : {
552
+ error: finalError,
553
+ request,
554
+ response
549
555
  };
550
556
  }
551
- const textError = await response.text();
552
- let jsonError;
553
- try {
554
- jsonError = JSON.parse(textError);
555
- } catch {}
556
- const error = jsonError ?? textError;
557
- let finalError = error;
558
- for (const fn of interceptors.error.fns) if (fn) finalError = await fn(error, response, request$1, opts);
559
- finalError = finalError || {};
560
- if (opts.throwOnError) throw finalError;
561
- return opts.responseStyle === "data" ? void 0 : {
562
- error: finalError,
563
- ...result
564
- };
565
557
  };
566
558
  const makeMethodFn = (method) => (options) => request({
567
559
  ...options,
@@ -572,12 +564,11 @@ const createClient = (config = {}) => {
572
564
  return createSseClient({
573
565
  ...opts,
574
566
  body: opts.body,
575
- headers: opts.headers,
576
567
  method,
577
- onRequest: async (url$1, init) => {
578
- let request$1 = new Request(url$1, init);
579
- for (const fn of interceptors.request.fns) if (fn) request$1 = await fn(request$1, opts);
580
- return request$1;
568
+ onRequest: async (url, init) => {
569
+ let request = new Request(url, init);
570
+ for (const fn of interceptors.request.fns) if (fn) request = await fn(request, opts);
571
+ return request;
581
572
  },
582
573
  serializedBody: getValidRequestBody(opts),
583
574
  url
@@ -625,7 +616,7 @@ const client = createClient(createConfig({ baseUrl: "https://api.savanto.ai" }))
625
616
  /**
626
617
  * Send a chat message
627
618
  *
628
- * Send a message and receive AI response. Supports streaming via NDJSON.
619
+ * Send a visitor message through the full multi-agent pipeline: triage classifies intent, query agents retrieve grounded context from the product / post indexes (plus any custom domain agents), and response agents synthesise a grounded answer with product cards or cited content. The response is streamed as NDJSON when `stream: true` (each line is one of `{ type: "token", ... }`, `{ type: "product", ... }`, `{ type: "done" }`), or returned as a single JSON object when `stream: false`. Pass `threadId` to continue a conversation (memories and prior turns are loaded); omit it for a fresh one. Respects the workspace's active persona / system-prompt configuration.
629
620
  */
630
621
  const chat = (options) => (options?.client ?? client).post({
631
622
  security: [{
@@ -642,7 +633,7 @@ const chat = (options) => (options?.client ?? client).post({
642
633
  /**
643
634
  * Start a website crawl
644
635
  *
645
- * Initiate a crawl of a website URL. Pages are discovered and indexed into the knowledge base.
636
+ * Enqueue a crawl of the given root URL for the workspace in `X-Workspace-ID`. The crawler discovers pages via sitemap + link graph, classifies each page (product, product listing, or general content), and indexes products into `savanto-products` and content into `savanto-posts`. This call is asynchronous and returns immediately with a `crawlId`; poll `GET /crawl/{crawlId}/status` to track progress or subscribe to the email notification endpoint to be pinged when it completes. Starting a new crawl while one is already running for the same workspace will be rejected with 409 — cancel the running one first.
646
637
  */
647
638
  const startCrawl = (options) => (options?.client ?? client).post({
648
639
  security: [{
@@ -676,7 +667,7 @@ const scrapeSinglePage = (options) => (options?.client ?? client).post({
676
667
  /**
677
668
  * Get crawl configuration
678
669
  *
679
- * Retrieve the crawl configuration for a workspace.
670
+ * Return the persisted crawl configuration for the workspace (strategy, schedule, include / exclude URL patterns, max-pages budget, user-agent override). Use before a crawl to verify the active rules, or before an `update_crawl_config` call to preserve fields you are not changing.
680
671
  */
681
672
  const getCrawlConfig = (options) => (options?.client ?? client).get({
682
673
  security: [{
@@ -689,7 +680,7 @@ const getCrawlConfig = (options) => (options?.client ?? client).get({
689
680
  /**
690
681
  * Update crawl configuration
691
682
  *
692
- * Update the crawl configuration for a workspace including strategy, schedule, exclude patterns, etc.
683
+ * Replace the crawl configuration for the workspace. Common fields: `strategy` (`full` reindexes everything, `smart` skips pages whose content hash matches the previous crawl), `schedule` (cron-like), `includePatterns` / `excludePatterns` (glob URL filters), `maxPages` (safety cap). Omitted fields are set to their defaults — if you only want to tweak one setting, `GET /crawl/config` first and merge. Changes take effect on the next crawl run.
693
684
  */
694
685
  const updateCrawlConfig = (options) => (options?.client ?? client).put({
695
686
  security: [{
@@ -706,7 +697,7 @@ const updateCrawlConfig = (options) => (options?.client ?? client).put({
706
697
  /**
707
698
  * Get crawl history
708
699
  *
709
- * Retrieve recent crawl history for the tenant.
700
+ * Return a list of recent crawls for the tenant (or the workspace when `X-Workspace-ID` is set), newest first. Each entry has its final status (`completed`, `failed`, `cancelled`), page counts, duration, and any error summary — useful for diagnosing why a site's content is stale.
710
701
  */
711
702
  const getCrawlHistory = (options) => (options?.client ?? client).get({
712
703
  security: [{
@@ -719,7 +710,7 @@ const getCrawlHistory = (options) => (options?.client ?? client).get({
719
710
  /**
720
711
  * Get crawl status
721
712
  *
722
- * Check the progress and status of a running or completed crawl.
713
+ * Return live status for a specific crawl id: `status` (`running`, `completed`, `failed`, `cancelled`), pages discovered / indexed / skipped / failed, elapsed time, and the current URL being processed. Poll every 3–10 seconds while `running`; stop polling once status is terminal. Returns 404 if the crawl id does not belong to the caller's tenant.
723
714
  */
724
715
  const getCrawlStatus = (options) => (options.client ?? client).get({
725
716
  security: [{
@@ -743,6 +734,23 @@ const cancelCrawl = (options) => (options.client ?? client).post({
743
734
  ...options
744
735
  });
745
736
  /**
737
+ * Enroll for a crawl-complete email
738
+ *
739
+ * Requests an email notification when this crawl reaches a terminal state (completed or failed). Intended for the dashboard "continue onboarding, email me when done" CTA. Rejects crawls that have already finished. **Admin-only endpoint.** The `email` in the body is treated as opaque and persisted verbatim; the cloud API does NOT authenticate ownership of that address. Callers holding the admin bearer are trusted to have derived the recipient from an authoritative source (e.g. the signed-in user session on the Next.js proxy). Do NOT expose this route via license-key / public scopes.
740
+ */
741
+ const enrollCrawlNotification = (options) => (options.client ?? client).post({
742
+ security: [{
743
+ scheme: "bearer",
744
+ type: "http"
745
+ }],
746
+ url: "/crawl/{id}/notifications",
747
+ ...options,
748
+ headers: {
749
+ "Content-Type": "application/json",
750
+ ...options.headers
751
+ }
752
+ });
753
+ /**
746
754
  * Scrape or delete a single page
747
755
  *
748
756
  * Scrape a URL and index it into the knowledge base, or delete a previously scraped page.
@@ -775,7 +783,7 @@ const listProducts = (options) => (options?.client ?? client).get({
775
783
  /**
776
784
  * Upsert a product
777
785
  *
778
- * Create or update a product by external ID. Generates vector embeddings for semantic search.
786
+ * Create a new product or update the existing one whose `externalId` matches the body. Embeddings for the product's searchable text are generated and persisted as part of the call, so the product becomes searchable immediately after a successful response. Required fields: `externalId`, `name`. Optional: `description`, `price` (in cents), `priceMin` / `priceMax`, `stockStatus` (`in_stock` | `out_of_stock` | `limited`), `images` (array of URLs), `brand`, `category`, `attributes` (key/value). Workspaces with native Shopify / WooCommerce sync should normally rely on the plugin rather than calling this endpoint directly. Idempotent on `externalId`.
779
787
  */
780
788
  const upsertProduct = (options) => (options?.client ?? client).post({
781
789
  security: [{
@@ -826,7 +834,7 @@ const bulkUpsertProducts = (options) => (options?.client ?? client).post({
826
834
  /**
827
835
  * Search products
828
836
  *
829
- * Semantic search across products with optional filters and facets. Uses AI agent for query enhancement when beneficial.
837
+ * Hybrid (BM25 + k-NN vector) search across the workspace's product catalog. Pass a natural-language `query` — the backend expands and filters it with an agent when that improves recall. Optional `filters` support `priceMin` / `priceMax`, `stockStatus`, `brand`, `category`, and arbitrary `attributes` equality. Optional `facets` returns aggregate counts for the requested fields. Use for "find X" style requests; use the chat endpoint instead if you want a conversational answer that cites the products.
830
838
  */
831
839
  const searchProducts = (options) => (options?.client ?? client).post({
832
840
  security: [{
@@ -916,7 +924,7 @@ const patchProduct = (options) => (options.client ?? client).patch({
916
924
  /**
917
925
  * Upsert a post
918
926
  *
919
- * Create or update a post by external ID. Generates vector embeddings for semantic search.
927
+ * Create a new post / knowledge article or update the existing one whose `externalId` matches the body. Embeddings are generated synchronously so the post is immediately retrievable by chat and search. Required: `externalId`, `title`, `content` (markdown or plain text). Optional: `author`, `publishedAt` (ISO 8601), `url`, `tags`, `category`. Use this for help-center articles, FAQ entries, or arbitrary brand content that should be answerable via chat. For bulk backfills prefer `POST /posts/bulk`. Idempotent on `externalId`.
920
928
  */
921
929
  const upsertPost = (options) => (options?.client ?? client).post({
922
930
  security: [{
@@ -967,7 +975,7 @@ const bulkUpsertPosts = (options) => (options?.client ?? client).post({
967
975
  /**
968
976
  * Search posts
969
977
  *
970
- * Semantic search across posts with optional filters. Uses AI agent for query enhancement when beneficial.
978
+ * Hybrid semantic + lexical search across the workspace's indexed posts / knowledge articles. Pass a natural-language `query`; the response returns the top-matching posts with excerpts, scores, and URLs. Use when you need raw passages to feed another agent; use the chat endpoint when you want a cited, synthesised answer rather than a list of hits.
971
979
  */
972
980
  const searchPosts = (options) => (options?.client ?? client).post({
973
981
  security: [{
@@ -1697,6 +1705,19 @@ const getTenantStatus = (options) => (options?.client ?? client).get({
1697
1705
  ...options
1698
1706
  });
1699
1707
  /**
1708
+ * Identity probe (tenant, scopes, key type)
1709
+ *
1710
+ * Return the tenant ID, tier, API key ID, key type, and scope list for the current caller. Designed for agent / MCP bootstrapping so clients can decide which operations are available before issuing them. Does NOT return any secret material.
1711
+ */
1712
+ const getTenantWhoami = (options) => (options?.client ?? client).get({
1713
+ security: [{
1714
+ scheme: "bearer",
1715
+ type: "http"
1716
+ }],
1717
+ url: "/tenant/whoami",
1718
+ ...options
1719
+ });
1720
+ /**
1700
1721
  * Update tenant feature flags
1701
1722
  */
1702
1723
  const updateTenantFeatures = (options) => (options?.client ?? client).patch({
@@ -1713,6 +1734,8 @@ const updateTenantFeatures = (options) => (options?.client ?? client).patch({
1713
1734
  });
1714
1735
  /**
1715
1736
  * Get usage summary
1737
+ *
1738
+ * Return the authenticated tenant's current-period usage against plan limits: chat messages sent, products indexed, posts indexed, crawl pages processed, and the dates of the billing window. Use for quota-aware UX or to warn a user that the next operation would trip an overage.
1716
1739
  */
1717
1740
  const getTenantUsage = (options) => (options?.client ?? client).get({
1718
1741
  security: [{
@@ -1736,7 +1759,7 @@ const getTenantUsageHistory = (options) => (options?.client ?? client).get({
1736
1759
  /**
1737
1760
  * List workspaces
1738
1761
  *
1739
- * List all workspaces for the authenticated tenant.
1762
+ * Return every workspace owned by the authenticated tenant, with each workspace's id, name, platform (wordpress | shopify | custom | none), and domain. Use this before calling any workspace-scoped endpoint (crawl, products, posts, chat) to discover the correct `workspaceId` to pass via the `X-Workspace-ID` header. Always cheap and safe to call repeatedly.
1740
1763
  */
1741
1764
  const listTenantWorkspaces = (options) => (options?.client ?? client).get({
1742
1765
  security: [{
@@ -1749,7 +1772,7 @@ const listTenantWorkspaces = (options) => (options?.client ?? client).get({
1749
1772
  /**
1750
1773
  * Create a workspace
1751
1774
  *
1752
- * Create a new workspace under the authenticated tenant.
1775
+ * Create a new workspace (a distinct site / storefront) under the authenticated tenant. Returns the workspace id you will pass as `X-Workspace-ID` on every subsequent content, crawl, and chat request. Typical onboarding flow: create → (optionally set platform) → start crawl → ingest products/posts. Creation does NOT enqueue a crawl — call `POST /crawl` separately.
1753
1776
  */
1754
1777
  const createTenantWorkspace = (options) => (options?.client ?? client).post({
1755
1778
  security: [{
@@ -1765,6 +1788,8 @@ const createTenantWorkspace = (options) => (options?.client ?? client).post({
1765
1788
  });
1766
1789
  /**
1767
1790
  * Delete a workspace
1791
+ *
1792
+ * Permanently delete a workspace and every document indexed under it (products, posts, taxonomies, chat threads, crawl history). This is NOT recoverable — prefer `POST /workspaces` to create a new one rather than delete + recreate for routine cleanup. Returns 404 if the id does not belong to the caller's tenant.
1768
1793
  */
1769
1794
  const deleteWorkspace = (options) => (options.client ?? client).delete({
1770
1795
  security: [{
@@ -1776,6 +1801,8 @@ const deleteWorkspace = (options) => (options.client ?? client).delete({
1776
1801
  });
1777
1802
  /**
1778
1803
  * Update a workspace
1804
+ *
1805
+ * Patch name, platform, or metadata on an existing workspace. Accepts a partial body; omitted fields are left untouched. Changing `platform` from `none` to `wordpress` / `shopify` signals the ingestion pipeline to prefer native sync over crawl-derived content on subsequent operations.
1779
1806
  */
1780
1807
  const updateWorkspace = (options) => (options.client ?? client).put({
1781
1808
  security: [{
@@ -1873,7 +1900,7 @@ const getCredentialStatus = (options) => (options?.client ?? client).get({
1873
1900
  scheme: "bearer",
1874
1901
  type: "http"
1875
1902
  }],
1876
- url: "/tenant/credentials/status",
1903
+ url: "/tenant/live-agent/credentials/status",
1877
1904
  ...options
1878
1905
  });
1879
1906
  /**
@@ -1884,7 +1911,7 @@ const deleteCredentials = (options) => (options?.client ?? client).delete({
1884
1911
  scheme: "bearer",
1885
1912
  type: "http"
1886
1913
  }],
1887
- url: "/tenant/credentials",
1914
+ url: "/tenant/live-agent/credentials",
1888
1915
  ...options
1889
1916
  });
1890
1917
  /**
@@ -1895,7 +1922,7 @@ const storeCredentials = (options) => (options?.client ?? client).post({
1895
1922
  scheme: "bearer",
1896
1923
  type: "http"
1897
1924
  }],
1898
- url: "/tenant/credentials",
1925
+ url: "/tenant/live-agent/credentials",
1899
1926
  ...options,
1900
1927
  headers: {
1901
1928
  "Content-Type": "application/json",
@@ -1910,7 +1937,7 @@ const deleteLiveAgentSchedule = (options) => (options?.client ?? client).delete(
1910
1937
  scheme: "bearer",
1911
1938
  type: "http"
1912
1939
  }],
1913
- url: "/tenant/schedule",
1940
+ url: "/tenant/live-agent/schedule",
1914
1941
  ...options
1915
1942
  });
1916
1943
  /**
@@ -1921,7 +1948,7 @@ const getLiveAgentSchedule = (options) => (options?.client ?? client).get({
1921
1948
  scheme: "bearer",
1922
1949
  type: "http"
1923
1950
  }],
1924
- url: "/tenant/schedule",
1951
+ url: "/tenant/live-agent/schedule",
1925
1952
  ...options
1926
1953
  });
1927
1954
  /**
@@ -1932,7 +1959,7 @@ const updateLiveAgentSchedule = (options) => (options?.client ?? client).put({
1932
1959
  scheme: "bearer",
1933
1960
  type: "http"
1934
1961
  }],
1935
- url: "/tenant/schedule",
1962
+ url: "/tenant/live-agent/schedule",
1936
1963
  ...options,
1937
1964
  headers: {
1938
1965
  "Content-Type": "application/json",
@@ -2164,6 +2191,8 @@ const testDomainConnection = (options) => (options.client ?? client).post({
2164
2191
  });
2165
2192
  /**
2166
2193
  * Get workspace details
2194
+ *
2195
+ * Return the full configuration for a workspace: platform, domain, crawl config, widget settings, chat persona, live-agent handoff, custom domains, and document counts. Preferred read for agent bootstrap because it returns every knob in one call.
2167
2196
  */
2168
2197
  const getWorkspaceDetails = (options) => (options.client ?? client).get({
2169
2198
  security: [{
@@ -2460,6 +2489,40 @@ const adminResetCrawls = (options) => (options.client ?? client).post({
2460
2489
  url: "/admin/tenant/{tenantId}/crawls/reset",
2461
2490
  ...options
2462
2491
  });
2492
+ /**
2493
+ * Redact a customer across all stored PII
2494
+ *
2495
+ * Hard-deletes every thread document and memory document within the caller tenant that matches the supplied customer identifiers. Runs as async OpenSearch tasks; the response contains task IDs for reconciliation. Idempotent when `caller.externalId` is supplied.
2496
+ */
2497
+ const complianceCustomerRedact = (options) => (options?.client ?? client).post({
2498
+ security: [{
2499
+ scheme: "bearer",
2500
+ type: "http"
2501
+ }],
2502
+ url: "/compliance/customer-redact",
2503
+ ...options,
2504
+ headers: {
2505
+ "Content-Type": "application/json",
2506
+ ...options?.headers
2507
+ }
2508
+ });
2509
+ /**
2510
+ * Record a customer data-export request
2511
+ *
2512
+ * Queues a customer data-export request and notifies ops to fulfill it within Shopify's 30-day SLA. Idempotent when `caller.externalId` is supplied.
2513
+ */
2514
+ const complianceCustomerDataRequest = (options) => (options?.client ?? client).post({
2515
+ security: [{
2516
+ scheme: "bearer",
2517
+ type: "http"
2518
+ }],
2519
+ url: "/compliance/customer-data-request",
2520
+ ...options,
2521
+ headers: {
2522
+ "Content-Type": "application/json",
2523
+ ...options?.headers
2524
+ }
2525
+ });
2463
2526
 
2464
2527
  //#endregion
2465
2528
  //#region src/util.ts
@@ -2508,6 +2571,8 @@ exports.chat = chat;
2508
2571
  exports.clearDomainErrors = clearDomainErrors;
2509
2572
  exports.client = client;
2510
2573
  exports.commitSearch = commitSearch;
2574
+ exports.complianceCustomerDataRequest = complianceCustomerDataRequest;
2575
+ exports.complianceCustomerRedact = complianceCustomerRedact;
2511
2576
  exports.createApiKey = createApiKey;
2512
2577
  exports.createClient = createClient;
2513
2578
  exports.createConfig = createConfig;
@@ -2533,6 +2598,7 @@ exports.deleteWorkspace = deleteWorkspace;
2533
2598
  exports.deprovision = deprovision;
2534
2599
  exports.discoverTools = discoverTools;
2535
2600
  exports.endHandoff = endHandoff;
2601
+ exports.enrollCrawlNotification = enrollCrawlNotification;
2536
2602
  exports.exportThreads = exportThreads;
2537
2603
  exports.generateDomainConfig = generateDomainConfig;
2538
2604
  exports.getAnalyticsFeedback = getAnalyticsFeedback;
@@ -2560,6 +2626,7 @@ exports.getTaxonomy = getTaxonomy;
2560
2626
  exports.getTenantStatus = getTenantStatus;
2561
2627
  exports.getTenantUsage = getTenantUsage;
2562
2628
  exports.getTenantUsageHistory = getTenantUsageHistory;
2629
+ exports.getTenantWhoami = getTenantWhoami;
2563
2630
  exports.getThread = getThread;
2564
2631
  exports.getThreadAnalytics = getThreadAnalytics;
2565
2632
  exports.getThreadFeedback = getThreadFeedback;