@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/CHANGELOG.md +206 -0
- package/README.md +17 -2
- package/dist/index.cjs +194 -127
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1672 -117
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +1672 -117
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +190 -128
- package/dist/index.mjs.map +1 -1
- package/package.json +11 -9
package/dist/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@ const jsonBodySerializer = { bodySerializer: (body) => JSON.stringify(body, (_ke
|
|
|
3
3
|
|
|
4
4
|
//#endregion
|
|
5
5
|
//#region src/generated/core/serverSentEvents.gen.ts
|
|
6
|
-
|
|
6
|
+
function createSseClient({ onRequest, onSseError, onSseEvent, responseTransformer, responseValidator, sseDefaultRetryDelay, sseMaxRetryAttempts, sseMaxRetryDelay, sseSleepFn, url, ...options }) {
|
|
7
7
|
let lastEventId;
|
|
8
8
|
const sleep = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
9
9
|
const createStream = async function* () {
|
|
@@ -41,7 +41,7 @@ const createSseClient = ({ onRequest, onSseError, onSseEvent, responseTransforme
|
|
|
41
41
|
const { done, value } = await reader.read();
|
|
42
42
|
if (done) break;
|
|
43
43
|
buffer += value;
|
|
44
|
-
buffer = buffer.replace(/\r\n
|
|
44
|
+
buffer = buffer.replace(/\r\n?/g, "\n");
|
|
45
45
|
const chunks = buffer.split("\n\n");
|
|
46
46
|
buffer = chunks.pop() ?? "";
|
|
47
47
|
for (const chunk of chunks) {
|
|
@@ -92,7 +92,7 @@ const createSseClient = ({ onRequest, onSseError, onSseEvent, responseTransforme
|
|
|
92
92
|
}
|
|
93
93
|
};
|
|
94
94
|
return { stream: createStream() };
|
|
95
|
-
}
|
|
95
|
+
}
|
|
96
96
|
|
|
97
97
|
//#endregion
|
|
98
98
|
//#region src/generated/core/pathSerializer.gen.ts
|
|
@@ -122,12 +122,12 @@ const separatorObjectExplode = (style) => {
|
|
|
122
122
|
};
|
|
123
123
|
const serializeArrayParam = ({ allowReserved, explode, name, style, value }) => {
|
|
124
124
|
if (!explode) {
|
|
125
|
-
const joinedValues
|
|
125
|
+
const joinedValues = (allowReserved ? value : value.map((v) => encodeURIComponent(v))).join(separatorArrayNoExplode(style));
|
|
126
126
|
switch (style) {
|
|
127
|
-
case "label": return `.${joinedValues
|
|
128
|
-
case "matrix": return `;${name}=${joinedValues
|
|
129
|
-
case "simple": return joinedValues
|
|
130
|
-
default: return `${name}=${joinedValues
|
|
127
|
+
case "label": return `.${joinedValues}`;
|
|
128
|
+
case "matrix": return `;${name}=${joinedValues}`;
|
|
129
|
+
case "simple": return joinedValues;
|
|
130
|
+
default: return `${name}=${joinedValues}`;
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
133
|
const separator = separatorArrayExplode(style);
|
|
@@ -157,12 +157,12 @@ const serializeObjectParam = ({ allowReserved, explode, name, style, value, valu
|
|
|
157
157
|
allowReserved ? v : encodeURIComponent(v)
|
|
158
158
|
];
|
|
159
159
|
});
|
|
160
|
-
const joinedValues
|
|
160
|
+
const joinedValues = values.join(",");
|
|
161
161
|
switch (style) {
|
|
162
|
-
case "form": return `${name}=${joinedValues
|
|
163
|
-
case "label": return `.${joinedValues
|
|
164
|
-
case "matrix": return `;${name}=${joinedValues
|
|
165
|
-
default: return joinedValues
|
|
162
|
+
case "form": return `${name}=${joinedValues}`;
|
|
163
|
+
case "label": return `.${joinedValues}`;
|
|
164
|
+
case "matrix": return `;${name}=${joinedValues}`;
|
|
165
|
+
default: return joinedValues;
|
|
166
166
|
}
|
|
167
167
|
}
|
|
168
168
|
const separator = separatorObjectExplode(style);
|
|
@@ -323,8 +323,8 @@ const checkForExistence = (options, name) => {
|
|
|
323
323
|
if (options.headers.has(name) || options.query?.[name] || options.headers.get("Cookie")?.includes(`${name}=`)) return true;
|
|
324
324
|
return false;
|
|
325
325
|
};
|
|
326
|
-
|
|
327
|
-
for (const auth of security) {
|
|
326
|
+
async function setAuthParams(options) {
|
|
327
|
+
for (const auth of options.security ?? []) {
|
|
328
328
|
if (checkForExistence(options, auth.name)) continue;
|
|
329
329
|
const token = await getAuthToken(auth, options.auth);
|
|
330
330
|
if (!token) continue;
|
|
@@ -337,13 +337,12 @@ const setAuthParams = async ({ security, ...options }) => {
|
|
|
337
337
|
case "cookie":
|
|
338
338
|
options.headers.append("Cookie", `${name}=${token}`);
|
|
339
339
|
break;
|
|
340
|
-
case "header":
|
|
341
340
|
default:
|
|
342
341
|
options.headers.set(name, token);
|
|
343
342
|
break;
|
|
344
343
|
}
|
|
345
344
|
}
|
|
346
|
-
}
|
|
345
|
+
}
|
|
347
346
|
const buildUrl = (options) => getUrl({
|
|
348
347
|
baseUrl: options.baseUrl,
|
|
349
348
|
path: options.path,
|
|
@@ -440,8 +439,8 @@ const createConfig = (override = {}) => ({
|
|
|
440
439
|
const createClient = (config = {}) => {
|
|
441
440
|
let _config = mergeConfigs(createConfig(), config);
|
|
442
441
|
const getConfig = () => ({ ..._config });
|
|
443
|
-
const setConfig = (config
|
|
444
|
-
_config = mergeConfigs(_config, config
|
|
442
|
+
const setConfig = (config) => {
|
|
443
|
+
_config = mergeConfigs(_config, config);
|
|
445
444
|
return getConfig();
|
|
446
445
|
};
|
|
447
446
|
const interceptors = createInterceptors();
|
|
@@ -453,114 +452,106 @@ const createClient = (config = {}) => {
|
|
|
453
452
|
headers: mergeHeaders(_config.headers, options.headers),
|
|
454
453
|
serializedBody: void 0
|
|
455
454
|
};
|
|
456
|
-
if (opts.security) await setAuthParams(
|
|
457
|
-
...opts,
|
|
458
|
-
security: opts.security
|
|
459
|
-
});
|
|
455
|
+
if (opts.security) await setAuthParams(opts);
|
|
460
456
|
if (opts.requestValidator) await opts.requestValidator(opts);
|
|
461
457
|
if (opts.body !== void 0 && opts.bodySerializer) opts.serializedBody = opts.bodySerializer(opts.body);
|
|
462
458
|
if (opts.body === void 0 || opts.serializedBody === "") opts.headers.delete("Content-Type");
|
|
459
|
+
const resolvedOpts = opts;
|
|
463
460
|
return {
|
|
464
|
-
opts,
|
|
465
|
-
url: buildUrl(
|
|
461
|
+
opts: resolvedOpts,
|
|
462
|
+
url: buildUrl(resolvedOpts)
|
|
466
463
|
};
|
|
467
464
|
};
|
|
468
465
|
const request = async (options) => {
|
|
469
|
-
const
|
|
470
|
-
const
|
|
471
|
-
|
|
472
|
-
...opts,
|
|
473
|
-
body: getValidRequestBody(opts)
|
|
474
|
-
};
|
|
475
|
-
let request$1 = new Request(url, requestInit);
|
|
476
|
-
for (const fn of interceptors.request.fns) if (fn) request$1 = await fn(request$1, opts);
|
|
477
|
-
const _fetch = opts.fetch;
|
|
466
|
+
const throwOnError = options.throwOnError ?? _config.throwOnError;
|
|
467
|
+
const responseStyle = options.responseStyle ?? _config.responseStyle;
|
|
468
|
+
let request;
|
|
478
469
|
let response;
|
|
479
470
|
try {
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
if (opts.throwOnError) throw finalError$1;
|
|
486
|
-
return opts.responseStyle === "data" ? void 0 : {
|
|
487
|
-
error: finalError$1,
|
|
488
|
-
request: request$1,
|
|
489
|
-
response: void 0
|
|
471
|
+
const { opts, url } = await beforeRequest(options);
|
|
472
|
+
const requestInit = {
|
|
473
|
+
redirect: "follow",
|
|
474
|
+
...opts,
|
|
475
|
+
body: getValidRequestBody(opts)
|
|
490
476
|
};
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
response
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
477
|
+
request = new Request(url, requestInit);
|
|
478
|
+
for (const fn of interceptors.request.fns) if (fn) request = await fn(request, opts);
|
|
479
|
+
const _fetch = opts.fetch;
|
|
480
|
+
response = await _fetch(request);
|
|
481
|
+
for (const fn of interceptors.response.fns) if (fn) response = await fn(response, request, opts);
|
|
482
|
+
const result = {
|
|
483
|
+
request,
|
|
484
|
+
response
|
|
485
|
+
};
|
|
486
|
+
if (response.ok) {
|
|
487
|
+
const parseAs = (opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
|
|
488
|
+
if (response.status === 204 || response.headers.get("Content-Length") === "0") {
|
|
489
|
+
let emptyData;
|
|
490
|
+
switch (parseAs) {
|
|
491
|
+
case "arrayBuffer":
|
|
492
|
+
case "blob":
|
|
493
|
+
case "text":
|
|
494
|
+
emptyData = await response[parseAs]();
|
|
495
|
+
break;
|
|
496
|
+
case "formData":
|
|
497
|
+
emptyData = new FormData();
|
|
498
|
+
break;
|
|
499
|
+
case "stream":
|
|
500
|
+
emptyData = response.body;
|
|
501
|
+
break;
|
|
502
|
+
default:
|
|
503
|
+
emptyData = {};
|
|
504
|
+
break;
|
|
505
|
+
}
|
|
506
|
+
return opts.responseStyle === "data" ? emptyData : {
|
|
507
|
+
data: emptyData,
|
|
508
|
+
...result
|
|
509
|
+
};
|
|
510
|
+
}
|
|
511
|
+
let data;
|
|
501
512
|
switch (parseAs) {
|
|
502
513
|
case "arrayBuffer":
|
|
503
514
|
case "blob":
|
|
504
|
-
case "text":
|
|
505
|
-
emptyData = await response[parseAs]();
|
|
506
|
-
break;
|
|
507
515
|
case "formData":
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
case "stream":
|
|
511
|
-
emptyData = response.body;
|
|
516
|
+
case "text":
|
|
517
|
+
data = await response[parseAs]();
|
|
512
518
|
break;
|
|
513
|
-
case "json":
|
|
514
|
-
|
|
515
|
-
|
|
519
|
+
case "json": {
|
|
520
|
+
const text = await response.text();
|
|
521
|
+
data = text ? JSON.parse(text) : {};
|
|
516
522
|
break;
|
|
523
|
+
}
|
|
524
|
+
case "stream": return opts.responseStyle === "data" ? response.body : {
|
|
525
|
+
data: response.body,
|
|
526
|
+
...result
|
|
527
|
+
};
|
|
517
528
|
}
|
|
518
|
-
|
|
519
|
-
data
|
|
520
|
-
|
|
521
|
-
};
|
|
522
|
-
}
|
|
523
|
-
let data;
|
|
524
|
-
switch (parseAs) {
|
|
525
|
-
case "arrayBuffer":
|
|
526
|
-
case "blob":
|
|
527
|
-
case "formData":
|
|
528
|
-
case "text":
|
|
529
|
-
data = await response[parseAs]();
|
|
530
|
-
break;
|
|
531
|
-
case "json": {
|
|
532
|
-
const text = await response.text();
|
|
533
|
-
data = text ? JSON.parse(text) : {};
|
|
534
|
-
break;
|
|
529
|
+
if (parseAs === "json") {
|
|
530
|
+
if (opts.responseValidator) await opts.responseValidator(data);
|
|
531
|
+
if (opts.responseTransformer) data = await opts.responseTransformer(data);
|
|
535
532
|
}
|
|
536
|
-
|
|
537
|
-
data
|
|
533
|
+
return opts.responseStyle === "data" ? data : {
|
|
534
|
+
data,
|
|
538
535
|
...result
|
|
539
536
|
};
|
|
540
537
|
}
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
538
|
+
const textError = await response.text();
|
|
539
|
+
let jsonError;
|
|
540
|
+
try {
|
|
541
|
+
jsonError = JSON.parse(textError);
|
|
542
|
+
} catch {}
|
|
543
|
+
throw jsonError ?? textError;
|
|
544
|
+
} catch (error) {
|
|
545
|
+
let finalError = error;
|
|
546
|
+
for (const fn of interceptors.error.fns) if (fn) finalError = await fn(finalError, response, request, options);
|
|
547
|
+
finalError = finalError || {};
|
|
548
|
+
if (throwOnError) throw finalError;
|
|
549
|
+
return responseStyle === "data" ? void 0 : {
|
|
550
|
+
error: finalError,
|
|
551
|
+
request,
|
|
552
|
+
response
|
|
548
553
|
};
|
|
549
554
|
}
|
|
550
|
-
const textError = await response.text();
|
|
551
|
-
let jsonError;
|
|
552
|
-
try {
|
|
553
|
-
jsonError = JSON.parse(textError);
|
|
554
|
-
} catch {}
|
|
555
|
-
const error = jsonError ?? textError;
|
|
556
|
-
let finalError = error;
|
|
557
|
-
for (const fn of interceptors.error.fns) if (fn) finalError = await fn(error, response, request$1, opts);
|
|
558
|
-
finalError = finalError || {};
|
|
559
|
-
if (opts.throwOnError) throw finalError;
|
|
560
|
-
return opts.responseStyle === "data" ? void 0 : {
|
|
561
|
-
error: finalError,
|
|
562
|
-
...result
|
|
563
|
-
};
|
|
564
555
|
};
|
|
565
556
|
const makeMethodFn = (method) => (options) => request({
|
|
566
557
|
...options,
|
|
@@ -571,12 +562,11 @@ const createClient = (config = {}) => {
|
|
|
571
562
|
return createSseClient({
|
|
572
563
|
...opts,
|
|
573
564
|
body: opts.body,
|
|
574
|
-
headers: opts.headers,
|
|
575
565
|
method,
|
|
576
|
-
onRequest: async (url
|
|
577
|
-
let request
|
|
578
|
-
for (const fn of interceptors.request.fns) if (fn) request
|
|
579
|
-
return request
|
|
566
|
+
onRequest: async (url, init) => {
|
|
567
|
+
let request = new Request(url, init);
|
|
568
|
+
for (const fn of interceptors.request.fns) if (fn) request = await fn(request, opts);
|
|
569
|
+
return request;
|
|
580
570
|
},
|
|
581
571
|
serializedBody: getValidRequestBody(opts),
|
|
582
572
|
url
|
|
@@ -624,7 +614,7 @@ const client = createClient(createConfig({ baseUrl: "https://api.savanto.ai" }))
|
|
|
624
614
|
/**
|
|
625
615
|
* Send a chat message
|
|
626
616
|
*
|
|
627
|
-
* Send a message and
|
|
617
|
+
* 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.
|
|
628
618
|
*/
|
|
629
619
|
const chat = (options) => (options?.client ?? client).post({
|
|
630
620
|
security: [{
|
|
@@ -641,7 +631,7 @@ const chat = (options) => (options?.client ?? client).post({
|
|
|
641
631
|
/**
|
|
642
632
|
* Start a website crawl
|
|
643
633
|
*
|
|
644
|
-
*
|
|
634
|
+
* 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.
|
|
645
635
|
*/
|
|
646
636
|
const startCrawl = (options) => (options?.client ?? client).post({
|
|
647
637
|
security: [{
|
|
@@ -675,7 +665,7 @@ const scrapeSinglePage = (options) => (options?.client ?? client).post({
|
|
|
675
665
|
/**
|
|
676
666
|
* Get crawl configuration
|
|
677
667
|
*
|
|
678
|
-
*
|
|
668
|
+
* 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.
|
|
679
669
|
*/
|
|
680
670
|
const getCrawlConfig = (options) => (options?.client ?? client).get({
|
|
681
671
|
security: [{
|
|
@@ -688,7 +678,7 @@ const getCrawlConfig = (options) => (options?.client ?? client).get({
|
|
|
688
678
|
/**
|
|
689
679
|
* Update crawl configuration
|
|
690
680
|
*
|
|
691
|
-
*
|
|
681
|
+
* 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.
|
|
692
682
|
*/
|
|
693
683
|
const updateCrawlConfig = (options) => (options?.client ?? client).put({
|
|
694
684
|
security: [{
|
|
@@ -705,7 +695,7 @@ const updateCrawlConfig = (options) => (options?.client ?? client).put({
|
|
|
705
695
|
/**
|
|
706
696
|
* Get crawl history
|
|
707
697
|
*
|
|
708
|
-
*
|
|
698
|
+
* 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.
|
|
709
699
|
*/
|
|
710
700
|
const getCrawlHistory = (options) => (options?.client ?? client).get({
|
|
711
701
|
security: [{
|
|
@@ -718,7 +708,7 @@ const getCrawlHistory = (options) => (options?.client ?? client).get({
|
|
|
718
708
|
/**
|
|
719
709
|
* Get crawl status
|
|
720
710
|
*
|
|
721
|
-
*
|
|
711
|
+
* 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.
|
|
722
712
|
*/
|
|
723
713
|
const getCrawlStatus = (options) => (options.client ?? client).get({
|
|
724
714
|
security: [{
|
|
@@ -742,6 +732,23 @@ const cancelCrawl = (options) => (options.client ?? client).post({
|
|
|
742
732
|
...options
|
|
743
733
|
});
|
|
744
734
|
/**
|
|
735
|
+
* Enroll for a crawl-complete email
|
|
736
|
+
*
|
|
737
|
+
* 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.
|
|
738
|
+
*/
|
|
739
|
+
const enrollCrawlNotification = (options) => (options.client ?? client).post({
|
|
740
|
+
security: [{
|
|
741
|
+
scheme: "bearer",
|
|
742
|
+
type: "http"
|
|
743
|
+
}],
|
|
744
|
+
url: "/crawl/{id}/notifications",
|
|
745
|
+
...options,
|
|
746
|
+
headers: {
|
|
747
|
+
"Content-Type": "application/json",
|
|
748
|
+
...options.headers
|
|
749
|
+
}
|
|
750
|
+
});
|
|
751
|
+
/**
|
|
745
752
|
* Scrape or delete a single page
|
|
746
753
|
*
|
|
747
754
|
* Scrape a URL and index it into the knowledge base, or delete a previously scraped page.
|
|
@@ -774,7 +781,7 @@ const listProducts = (options) => (options?.client ?? client).get({
|
|
|
774
781
|
/**
|
|
775
782
|
* Upsert a product
|
|
776
783
|
*
|
|
777
|
-
* Create or update
|
|
784
|
+
* 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`.
|
|
778
785
|
*/
|
|
779
786
|
const upsertProduct = (options) => (options?.client ?? client).post({
|
|
780
787
|
security: [{
|
|
@@ -825,7 +832,7 @@ const bulkUpsertProducts = (options) => (options?.client ?? client).post({
|
|
|
825
832
|
/**
|
|
826
833
|
* Search products
|
|
827
834
|
*
|
|
828
|
-
*
|
|
835
|
+
* 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.
|
|
829
836
|
*/
|
|
830
837
|
const searchProducts = (options) => (options?.client ?? client).post({
|
|
831
838
|
security: [{
|
|
@@ -915,7 +922,7 @@ const patchProduct = (options) => (options.client ?? client).patch({
|
|
|
915
922
|
/**
|
|
916
923
|
* Upsert a post
|
|
917
924
|
*
|
|
918
|
-
* Create or update
|
|
925
|
+
* 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`.
|
|
919
926
|
*/
|
|
920
927
|
const upsertPost = (options) => (options?.client ?? client).post({
|
|
921
928
|
security: [{
|
|
@@ -966,7 +973,7 @@ const bulkUpsertPosts = (options) => (options?.client ?? client).post({
|
|
|
966
973
|
/**
|
|
967
974
|
* Search posts
|
|
968
975
|
*
|
|
969
|
-
*
|
|
976
|
+
* 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.
|
|
970
977
|
*/
|
|
971
978
|
const searchPosts = (options) => (options?.client ?? client).post({
|
|
972
979
|
security: [{
|
|
@@ -1696,6 +1703,19 @@ const getTenantStatus = (options) => (options?.client ?? client).get({
|
|
|
1696
1703
|
...options
|
|
1697
1704
|
});
|
|
1698
1705
|
/**
|
|
1706
|
+
* Identity probe (tenant, scopes, key type)
|
|
1707
|
+
*
|
|
1708
|
+
* 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.
|
|
1709
|
+
*/
|
|
1710
|
+
const getTenantWhoami = (options) => (options?.client ?? client).get({
|
|
1711
|
+
security: [{
|
|
1712
|
+
scheme: "bearer",
|
|
1713
|
+
type: "http"
|
|
1714
|
+
}],
|
|
1715
|
+
url: "/tenant/whoami",
|
|
1716
|
+
...options
|
|
1717
|
+
});
|
|
1718
|
+
/**
|
|
1699
1719
|
* Update tenant feature flags
|
|
1700
1720
|
*/
|
|
1701
1721
|
const updateTenantFeatures = (options) => (options?.client ?? client).patch({
|
|
@@ -1712,6 +1732,8 @@ const updateTenantFeatures = (options) => (options?.client ?? client).patch({
|
|
|
1712
1732
|
});
|
|
1713
1733
|
/**
|
|
1714
1734
|
* Get usage summary
|
|
1735
|
+
*
|
|
1736
|
+
* 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.
|
|
1715
1737
|
*/
|
|
1716
1738
|
const getTenantUsage = (options) => (options?.client ?? client).get({
|
|
1717
1739
|
security: [{
|
|
@@ -1735,7 +1757,7 @@ const getTenantUsageHistory = (options) => (options?.client ?? client).get({
|
|
|
1735
1757
|
/**
|
|
1736
1758
|
* List workspaces
|
|
1737
1759
|
*
|
|
1738
|
-
*
|
|
1760
|
+
* 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.
|
|
1739
1761
|
*/
|
|
1740
1762
|
const listTenantWorkspaces = (options) => (options?.client ?? client).get({
|
|
1741
1763
|
security: [{
|
|
@@ -1748,7 +1770,7 @@ const listTenantWorkspaces = (options) => (options?.client ?? client).get({
|
|
|
1748
1770
|
/**
|
|
1749
1771
|
* Create a workspace
|
|
1750
1772
|
*
|
|
1751
|
-
* Create a new workspace under the authenticated tenant.
|
|
1773
|
+
* 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.
|
|
1752
1774
|
*/
|
|
1753
1775
|
const createTenantWorkspace = (options) => (options?.client ?? client).post({
|
|
1754
1776
|
security: [{
|
|
@@ -1764,6 +1786,8 @@ const createTenantWorkspace = (options) => (options?.client ?? client).post({
|
|
|
1764
1786
|
});
|
|
1765
1787
|
/**
|
|
1766
1788
|
* Delete a workspace
|
|
1789
|
+
*
|
|
1790
|
+
* 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.
|
|
1767
1791
|
*/
|
|
1768
1792
|
const deleteWorkspace = (options) => (options.client ?? client).delete({
|
|
1769
1793
|
security: [{
|
|
@@ -1775,6 +1799,8 @@ const deleteWorkspace = (options) => (options.client ?? client).delete({
|
|
|
1775
1799
|
});
|
|
1776
1800
|
/**
|
|
1777
1801
|
* Update a workspace
|
|
1802
|
+
*
|
|
1803
|
+
* 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.
|
|
1778
1804
|
*/
|
|
1779
1805
|
const updateWorkspace = (options) => (options.client ?? client).put({
|
|
1780
1806
|
security: [{
|
|
@@ -1872,7 +1898,7 @@ const getCredentialStatus = (options) => (options?.client ?? client).get({
|
|
|
1872
1898
|
scheme: "bearer",
|
|
1873
1899
|
type: "http"
|
|
1874
1900
|
}],
|
|
1875
|
-
url: "/tenant/credentials/status",
|
|
1901
|
+
url: "/tenant/live-agent/credentials/status",
|
|
1876
1902
|
...options
|
|
1877
1903
|
});
|
|
1878
1904
|
/**
|
|
@@ -1883,7 +1909,7 @@ const deleteCredentials = (options) => (options?.client ?? client).delete({
|
|
|
1883
1909
|
scheme: "bearer",
|
|
1884
1910
|
type: "http"
|
|
1885
1911
|
}],
|
|
1886
|
-
url: "/tenant/credentials",
|
|
1912
|
+
url: "/tenant/live-agent/credentials",
|
|
1887
1913
|
...options
|
|
1888
1914
|
});
|
|
1889
1915
|
/**
|
|
@@ -1894,7 +1920,7 @@ const storeCredentials = (options) => (options?.client ?? client).post({
|
|
|
1894
1920
|
scheme: "bearer",
|
|
1895
1921
|
type: "http"
|
|
1896
1922
|
}],
|
|
1897
|
-
url: "/tenant/credentials",
|
|
1923
|
+
url: "/tenant/live-agent/credentials",
|
|
1898
1924
|
...options,
|
|
1899
1925
|
headers: {
|
|
1900
1926
|
"Content-Type": "application/json",
|
|
@@ -1909,7 +1935,7 @@ const deleteLiveAgentSchedule = (options) => (options?.client ?? client).delete(
|
|
|
1909
1935
|
scheme: "bearer",
|
|
1910
1936
|
type: "http"
|
|
1911
1937
|
}],
|
|
1912
|
-
url: "/tenant/schedule",
|
|
1938
|
+
url: "/tenant/live-agent/schedule",
|
|
1913
1939
|
...options
|
|
1914
1940
|
});
|
|
1915
1941
|
/**
|
|
@@ -1920,7 +1946,7 @@ const getLiveAgentSchedule = (options) => (options?.client ?? client).get({
|
|
|
1920
1946
|
scheme: "bearer",
|
|
1921
1947
|
type: "http"
|
|
1922
1948
|
}],
|
|
1923
|
-
url: "/tenant/schedule",
|
|
1949
|
+
url: "/tenant/live-agent/schedule",
|
|
1924
1950
|
...options
|
|
1925
1951
|
});
|
|
1926
1952
|
/**
|
|
@@ -1931,7 +1957,7 @@ const updateLiveAgentSchedule = (options) => (options?.client ?? client).put({
|
|
|
1931
1957
|
scheme: "bearer",
|
|
1932
1958
|
type: "http"
|
|
1933
1959
|
}],
|
|
1934
|
-
url: "/tenant/schedule",
|
|
1960
|
+
url: "/tenant/live-agent/schedule",
|
|
1935
1961
|
...options,
|
|
1936
1962
|
headers: {
|
|
1937
1963
|
"Content-Type": "application/json",
|
|
@@ -2163,6 +2189,8 @@ const testDomainConnection = (options) => (options.client ?? client).post({
|
|
|
2163
2189
|
});
|
|
2164
2190
|
/**
|
|
2165
2191
|
* Get workspace details
|
|
2192
|
+
*
|
|
2193
|
+
* 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.
|
|
2166
2194
|
*/
|
|
2167
2195
|
const getWorkspaceDetails = (options) => (options.client ?? client).get({
|
|
2168
2196
|
security: [{
|
|
@@ -2459,6 +2487,40 @@ const adminResetCrawls = (options) => (options.client ?? client).post({
|
|
|
2459
2487
|
url: "/admin/tenant/{tenantId}/crawls/reset",
|
|
2460
2488
|
...options
|
|
2461
2489
|
});
|
|
2490
|
+
/**
|
|
2491
|
+
* Redact a customer across all stored PII
|
|
2492
|
+
*
|
|
2493
|
+
* 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.
|
|
2494
|
+
*/
|
|
2495
|
+
const complianceCustomerRedact = (options) => (options?.client ?? client).post({
|
|
2496
|
+
security: [{
|
|
2497
|
+
scheme: "bearer",
|
|
2498
|
+
type: "http"
|
|
2499
|
+
}],
|
|
2500
|
+
url: "/compliance/customer-redact",
|
|
2501
|
+
...options,
|
|
2502
|
+
headers: {
|
|
2503
|
+
"Content-Type": "application/json",
|
|
2504
|
+
...options?.headers
|
|
2505
|
+
}
|
|
2506
|
+
});
|
|
2507
|
+
/**
|
|
2508
|
+
* Record a customer data-export request
|
|
2509
|
+
*
|
|
2510
|
+
* Queues a customer data-export request and notifies ops to fulfill it within Shopify's 30-day SLA. Idempotent when `caller.externalId` is supplied.
|
|
2511
|
+
*/
|
|
2512
|
+
const complianceCustomerDataRequest = (options) => (options?.client ?? client).post({
|
|
2513
|
+
security: [{
|
|
2514
|
+
scheme: "bearer",
|
|
2515
|
+
type: "http"
|
|
2516
|
+
}],
|
|
2517
|
+
url: "/compliance/customer-data-request",
|
|
2518
|
+
...options,
|
|
2519
|
+
headers: {
|
|
2520
|
+
"Content-Type": "application/json",
|
|
2521
|
+
...options?.headers
|
|
2522
|
+
}
|
|
2523
|
+
});
|
|
2462
2524
|
|
|
2463
2525
|
//#endregion
|
|
2464
2526
|
//#region src/util.ts
|
|
@@ -2480,5 +2542,5 @@ function workspaceIdFromUrl(url) {
|
|
|
2480
2542
|
}
|
|
2481
2543
|
|
|
2482
2544
|
//#endregion
|
|
2483
|
-
export { adminClaimTenant, adminDeleteTenant, adminFindByEmail, adminFindByOwner, adminGetTenant, adminGetUsage, adminReactivateTenant, adminResetCrawls, adminUpdateOwnerEmail, adminUpdateSubscription, adminUpdateTier, adminUpdateUsage, bulkDeletePosts, bulkDeleteProducts, bulkDeletePrompts, bulkDeleteTaxonomies, bulkDeleteThreads, bulkUpdateWebhookStatus, bulkUpsertPosts, bulkUpsertProducts, bulkUpsertPrompts, bulkUpsertTaxonomies, cancelCrawl, chat, clearDomainErrors, client, commitSearch, createApiKey, createClient, createConfig, createCustomDomain, createTenantWorkspace, createWebhook, deleteCredentials, deleteCustomDomain, deleteFeedback, deleteLiveAgentSchedule, deleteMcpConfig, deletePost, deletePostsByQuery, deleteProduct, deleteProductsByQuery, deletePrompt, deleteTaxonomiesByQuery, deleteTaxonomy, deleteTenant, deleteThread, deleteWebhook, deleteWorkspace, deprovision, discoverTools, endHandoff, exportThreads, generateDomainConfig, getAnalyticsFeedback, getChatAnalytics, getChatWidgetConfig, getCrawlConfig, getCrawlHistory, getCrawlStatus, getCredentialStatus, getDomainErrorSummary, getDomainErrors, getDomainTemplates, getFeedbackAnalytics, getKnowledge, getLiveAgentSchedule, getLiveAgentStatus, getMcpConfig, getPost, getProduct, getProductRecommendations, getPrompt, getSearchAnalytics, getSearchWidgetConfig, getTaxonomy, getTenantStatus, getTenantUsage, getTenantUsageHistory, getThread, getThreadAnalytics, getThreadFeedback, getThreadMessages, getUploadUrl, getWebhook, getWebhookStats, getWorkspaceDetails, getWorkspaceSettings, listApiKeys, listCustomDomains, listFeedback, listPostIds, listProductIds, listProducts, listPrompts, listSlackChannels, listTaxonomies, listTaxonomyIds, listTenantWorkspaces, listWebhooks, patchPost, patchProduct, provisionShopify, revokeApiKey, rotateApiKey, scrapePage, scrapeSinglePage, searchKnowledge, searchPosts, searchProducts, searchPrompts, searchSearches, searchThreads, startCrawl, storeCredentials, submitFeedback, testDomainConnection, testWebhook, updateChatWidgetConfig, updateCrawlConfig, updateCustomDomain, updateLiveAgentSchedule, updateMcpConfig, updateSearchWidgetConfig, updateTenantFeatures, updateWebhook, updateWorkspace, updateWorkspaceSettings, upsertPost, upsertProduct, upsertPrompt, upsertTaxonomy, validateCustomDomain, workspaceIdFromUrl };
|
|
2545
|
+
export { adminClaimTenant, adminDeleteTenant, adminFindByEmail, adminFindByOwner, adminGetTenant, adminGetUsage, adminReactivateTenant, adminResetCrawls, adminUpdateOwnerEmail, adminUpdateSubscription, adminUpdateTier, adminUpdateUsage, bulkDeletePosts, bulkDeleteProducts, bulkDeletePrompts, bulkDeleteTaxonomies, bulkDeleteThreads, bulkUpdateWebhookStatus, bulkUpsertPosts, bulkUpsertProducts, bulkUpsertPrompts, bulkUpsertTaxonomies, cancelCrawl, chat, clearDomainErrors, client, commitSearch, complianceCustomerDataRequest, complianceCustomerRedact, createApiKey, createClient, createConfig, createCustomDomain, createTenantWorkspace, createWebhook, deleteCredentials, deleteCustomDomain, deleteFeedback, deleteLiveAgentSchedule, deleteMcpConfig, deletePost, deletePostsByQuery, deleteProduct, deleteProductsByQuery, deletePrompt, deleteTaxonomiesByQuery, deleteTaxonomy, deleteTenant, deleteThread, deleteWebhook, deleteWorkspace, deprovision, discoverTools, endHandoff, enrollCrawlNotification, exportThreads, generateDomainConfig, getAnalyticsFeedback, getChatAnalytics, getChatWidgetConfig, getCrawlConfig, getCrawlHistory, getCrawlStatus, getCredentialStatus, getDomainErrorSummary, getDomainErrors, getDomainTemplates, getFeedbackAnalytics, getKnowledge, getLiveAgentSchedule, getLiveAgentStatus, getMcpConfig, getPost, getProduct, getProductRecommendations, getPrompt, getSearchAnalytics, getSearchWidgetConfig, getTaxonomy, getTenantStatus, getTenantUsage, getTenantUsageHistory, getTenantWhoami, getThread, getThreadAnalytics, getThreadFeedback, getThreadMessages, getUploadUrl, getWebhook, getWebhookStats, getWorkspaceDetails, getWorkspaceSettings, listApiKeys, listCustomDomains, listFeedback, listPostIds, listProductIds, listProducts, listPrompts, listSlackChannels, listTaxonomies, listTaxonomyIds, listTenantWorkspaces, listWebhooks, patchPost, patchProduct, provisionShopify, revokeApiKey, rotateApiKey, scrapePage, scrapeSinglePage, searchKnowledge, searchPosts, searchProducts, searchPrompts, searchSearches, searchThreads, startCrawl, storeCredentials, submitFeedback, testDomainConnection, testWebhook, updateChatWidgetConfig, updateCrawlConfig, updateCustomDomain, updateLiveAgentSchedule, updateMcpConfig, updateSearchWidgetConfig, updateTenantFeatures, updateWebhook, updateWorkspace, updateWorkspaceSettings, upsertPost, upsertProduct, upsertPrompt, upsertTaxonomy, validateCustomDomain, workspaceIdFromUrl };
|
|
2484
2546
|
//# sourceMappingURL=index.mjs.map
|