exa-js 2.23.0 → 2.24.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.d.mts +20 -2
- package/dist/index.d.ts +20 -2
- package/dist/index.js +28 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +27 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import fetch2, { Headers } from "cross-fetch";
|
|
|
4
4
|
// package.json
|
|
5
5
|
var package_default = {
|
|
6
6
|
name: "exa-js",
|
|
7
|
-
version: "2.
|
|
7
|
+
version: "2.24.0",
|
|
8
8
|
description: "Exa SDK for Node.js and the browser",
|
|
9
9
|
publishConfig: {
|
|
10
10
|
access: "public"
|
|
@@ -2331,6 +2331,8 @@ var WebsetsClient = class extends WebsetsBaseClient {
|
|
|
2331
2331
|
import { z } from "zod";
|
|
2332
2332
|
var DEFAULT_WEB_SEARCH_TOOL_DESCRIPTION = "Search the web for up-to-date, relevant information. Describe the ideal page rather than listing keywords.";
|
|
2333
2333
|
var DEFAULT_GET_CONTENTS_TOOL_DESCRIPTION = "Read the full contents of web pages you already have URLs for, such as pages returned by a search or mentioned by the user.";
|
|
2334
|
+
var SEARCH_OBJECTIVE_TOOL_DESCRIPTION = "Goal for this search turn; say which documents should rank first, which should be excluded, and what specific facts or figures to pull from them.";
|
|
2335
|
+
var MAX_OBJECTIVE_LENGTH = 4096;
|
|
2334
2336
|
function formatResults(response, emptyMessage) {
|
|
2335
2337
|
const formatted = response.results.map((result) => {
|
|
2336
2338
|
const lines = [
|
|
@@ -2384,6 +2386,17 @@ function createTool(registry, params) {
|
|
|
2384
2386
|
};
|
|
2385
2387
|
return registerTool(registry, tool);
|
|
2386
2388
|
}
|
|
2389
|
+
var AdvertisedRequiredOptional = class extends z.ZodOptional {
|
|
2390
|
+
isOptional() {
|
|
2391
|
+
return false;
|
|
2392
|
+
}
|
|
2393
|
+
};
|
|
2394
|
+
function advertisedRequired(inner) {
|
|
2395
|
+
return new AdvertisedRequiredOptional({
|
|
2396
|
+
innerType: inner,
|
|
2397
|
+
typeName: z.ZodFirstPartyTypeKind.ZodOptional
|
|
2398
|
+
});
|
|
2399
|
+
}
|
|
2387
2400
|
function createWebSearchTool(exa, registry, config = {}) {
|
|
2388
2401
|
const {
|
|
2389
2402
|
name = "web_search",
|
|
@@ -2393,7 +2406,15 @@ function createWebSearchTool(exa, registry, config = {}) {
|
|
|
2393
2406
|
const inputSchema = z.object({
|
|
2394
2407
|
query: z.string().describe(
|
|
2395
2408
|
"Natural language search query. Should be a semantically rich description of the ideal page, not just keywords."
|
|
2396
|
-
)
|
|
2409
|
+
),
|
|
2410
|
+
// Length limits are validated but not advertised: strict tool use on some
|
|
2411
|
+
// providers rejects `minLength`/`maxLength` in the schema.
|
|
2412
|
+
objective: advertisedRequired(
|
|
2413
|
+
z.string().trim().refine((value) => value.length > 0, "objective must not be empty").refine(
|
|
2414
|
+
(value) => value.length <= MAX_OBJECTIVE_LENGTH,
|
|
2415
|
+
`objective must be at most ${MAX_OBJECTIVE_LENGTH} characters`
|
|
2416
|
+
)
|
|
2417
|
+
).describe(SEARCH_OBJECTIVE_TOOL_DESCRIPTION)
|
|
2397
2418
|
});
|
|
2398
2419
|
const jsonSchema = zodToJsonSchema(inputSchema);
|
|
2399
2420
|
delete jsonSchema.$schema;
|
|
@@ -2407,12 +2428,13 @@ function createWebSearchTool(exa, registry, config = {}) {
|
|
|
2407
2428
|
description,
|
|
2408
2429
|
parameters: jsonSchema
|
|
2409
2430
|
},
|
|
2410
|
-
execute: ({ query }) => {
|
|
2431
|
+
execute: ({ query, objective }) => {
|
|
2411
2432
|
const options = {
|
|
2412
2433
|
type: "auto",
|
|
2413
2434
|
numResults: 10,
|
|
2414
2435
|
contents: { highlights: true },
|
|
2415
|
-
...searchOptions
|
|
2436
|
+
...searchOptions,
|
|
2437
|
+
...objective !== void 0 && { objective }
|
|
2416
2438
|
};
|
|
2417
2439
|
return exa.search(query, options);
|
|
2418
2440
|
},
|
|
@@ -3335,6 +3357,7 @@ export {
|
|
|
3335
3357
|
MonitorStatus,
|
|
3336
3358
|
OpenAIResponsesTools,
|
|
3337
3359
|
OpenAITools,
|
|
3360
|
+
SEARCH_OBJECTIVE_TOOL_DESCRIPTION,
|
|
3338
3361
|
SearchMonitorRunsClient,
|
|
3339
3362
|
SearchMonitorsClient,
|
|
3340
3363
|
ToolRegistry,
|