cencori 1.5.0 → 1.6.1
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.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +29 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +29 -2
- package/dist/index.mjs.map +1 -1
- package/dist/web/index.d.mts +80 -2
- package/dist/web/index.d.ts +80 -2
- package/dist/web/index.js +28 -1
- package/dist/web/index.js.map +1 -1
- package/dist/web/index.mjs +28 -1
- package/dist/web/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1662,7 +1662,8 @@ var WEB_SEARCH_TOOL = {
|
|
|
1662
1662
|
query: { type: "string", description: "The web search query." },
|
|
1663
1663
|
limit: { type: "integer", minimum: 1, maximum: 50 },
|
|
1664
1664
|
domain: { type: "string", description: "Optional hostname to restrict results to." },
|
|
1665
|
-
freshness: { type: "string", description: "Optional ISO timestamp or duration such as 7d." }
|
|
1665
|
+
freshness: { type: "string", description: "Optional ISO timestamp or duration such as 7d." },
|
|
1666
|
+
language: { type: "string", description: "Optional BCP 47 language tag such as en." }
|
|
1666
1667
|
},
|
|
1667
1668
|
required: ["query"],
|
|
1668
1669
|
additionalProperties: false
|
|
@@ -1704,6 +1705,19 @@ var WebNamespace = class {
|
|
|
1704
1705
|
search(request) {
|
|
1705
1706
|
return this.post("/api/v1/web/search", request);
|
|
1706
1707
|
}
|
|
1708
|
+
/** Queue an isolated JavaScript browser exploration on Cencori-owned workers. */
|
|
1709
|
+
browse(request) {
|
|
1710
|
+
return this.post("/api/v1/web/browse", request);
|
|
1711
|
+
}
|
|
1712
|
+
/** Poll an isolated browser exploration until it completes or fails. */
|
|
1713
|
+
browserJob(id) {
|
|
1714
|
+
if (!id.trim()) throw new Error("Browser job id is required");
|
|
1715
|
+
return this.get(`/api/v1/web/browse/${encodeURIComponent(id)}`);
|
|
1716
|
+
}
|
|
1717
|
+
/** Submit a copyright, privacy, legal, robots, or other removal request. */
|
|
1718
|
+
requestTakedown(request) {
|
|
1719
|
+
return this.post("/api/v1/web/takedown", request);
|
|
1720
|
+
}
|
|
1707
1721
|
executeTool(name, args) {
|
|
1708
1722
|
if (name === "web_search") return this.search(args);
|
|
1709
1723
|
if (name === "web_fetch") return this.extract(args);
|
|
@@ -1731,6 +1745,19 @@ var WebNamespace = class {
|
|
|
1731
1745
|
}
|
|
1732
1746
|
return data;
|
|
1733
1747
|
}
|
|
1748
|
+
async get(path) {
|
|
1749
|
+
const response = await fetch(`${this.config.baseUrl}${path}`, {
|
|
1750
|
+
headers: { "CENCORI_API_KEY": this.config.apiKey, ...this.config.headers }
|
|
1751
|
+
});
|
|
1752
|
+
const data = await response.json();
|
|
1753
|
+
if (!response.ok) {
|
|
1754
|
+
const payload = data && typeof data === "object" ? data : {};
|
|
1755
|
+
const error = new Error(typeof payload.message === "string" ? payload.message : `Web request failed with status ${response.status}`);
|
|
1756
|
+
error.code = typeof payload.error === "string" ? payload.error : "request_failed";
|
|
1757
|
+
throw error;
|
|
1758
|
+
}
|
|
1759
|
+
return data;
|
|
1760
|
+
}
|
|
1734
1761
|
};
|
|
1735
1762
|
|
|
1736
1763
|
// src/utils.ts
|
|
@@ -1795,7 +1822,7 @@ var SafetyError = class _SafetyError extends CencoriError {
|
|
|
1795
1822
|
};
|
|
1796
1823
|
|
|
1797
1824
|
// src/cencori.ts
|
|
1798
|
-
var DEFAULT_BASE_URL = "https://
|
|
1825
|
+
var DEFAULT_BASE_URL = "https://cencori.com";
|
|
1799
1826
|
var Cencori = class {
|
|
1800
1827
|
/**
|
|
1801
1828
|
* Create a new Cencori client
|