@absolutejs/search 0.1.0 → 0.2.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 CHANGED
@@ -6,6 +6,16 @@ This file is generated by `absolute-changelog` from the entries in
6
6
  `changelog/`. Edit an entry, not this file — and add new ones under
7
7
  `changelog/unreleased/`.
8
8
 
9
+ ## 0.2.0 — 2026-09-24
10
+
11
+ ### Added
12
+
13
+ - **Declare provider capabilities, reject unsupported filters before network calls, and provide a Brave configuration recipe and guarded search agent tool.**
14
+
15
+ ### Changed
16
+
17
+ - **SearchRequest accepts explicit optional filters, SearchProvider may declare capabilities, and the search manifest configures a Brave runtime.** (`SearchRequest`, `SearchProvider`, `manifest`)
18
+
9
19
  ## 0.1.0 — 2026-09-24
10
20
 
11
21
  ### Added
package/README.md CHANGED
@@ -11,3 +11,9 @@ const result = await search.search({ query: 'company partnership program', mode:
11
11
  Successful empty results, partial evidence, provider outages, quota failures and cancellation remain distinct. Every network attempt carries billing disposition; unknown cost remains null. A 200 response remains fulfilled if its body cannot be parsed. The host owns retry/admission, prices, credentials and accounting. No hidden model calls or fallback providers.
12
12
 
13
13
  Source excerpts are untrusted evidence. Publication and retrieval timestamps do not establish an event date. `sourceSupportsQuote` checks quotation presence, not entailment. `withSearchCache` requires an explicit scope, isolates provider/options/version, uses shorter empty-result retention, never caches failures, and optionally persists through a host store. Requests with caller-owned cancellation are not coalesced.
14
+
15
+ ## Capabilities and agent setup
16
+
17
+ Providers may declare `capabilities` with supported modes, filters and content views. `SearchRequest.filters` carries domain/date/category constraints. `assertSearchCapabilities` and `withSearchCapabilities` reject unsupported constraints before provider work. Brave advertises web/context excerpts and freshness/country/language; unsupported domain/date/category filters are rejected, never silently ignored. Existing providers without metadata remain compatible with existing request fields, but must declare support before accepting the new filters.
18
+
19
+ The manifest exports a guarded `search_web` agent tool and a Brave configuration recipe using `BRAVE_SEARCH_API_KEY`. Bind the configured provider and host enforcer through the existing manifest AI/MCP bridges. Search spending and tenant authorization remain host-controlled. For complete research, extraction, monitoring and framework flows, compose with `@absolutejs/rag/research`.
package/changelog.json CHANGED
@@ -2,6 +2,25 @@
2
2
  "contract": 1,
3
3
  "name": "@absolutejs/search",
4
4
  "releases": [
5
+ {
6
+ "changes": [
7
+ {
8
+ "kind": "added",
9
+ "summary": "Declare provider capabilities, reject unsupported filters before network calls, and provide a Brave configuration recipe and guarded search agent tool."
10
+ },
11
+ {
12
+ "kind": "changed",
13
+ "summary": "SearchRequest accepts explicit optional filters, SearchProvider may declare capabilities, and the search manifest configures a Brave runtime.",
14
+ "symbols": [
15
+ "SearchRequest",
16
+ "SearchProvider",
17
+ "manifest"
18
+ ]
19
+ }
20
+ ],
21
+ "date": "2026-09-24",
22
+ "version": "0.2.0"
23
+ },
5
24
  {
6
25
  "changes": [
7
26
  {
package/dist/brave.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { type SearchCapabilities } from "./capabilities";
1
2
  import type { SearchAttempt, SearchProvider } from "./types";
2
3
  export type BraveOptions = {
3
4
  apiKey: string;
@@ -8,4 +9,5 @@ export type BraveOptions = {
8
9
  /** Awaited before returning, including rejected and malformed responses. Does not expose credentials. */
9
10
  observe?: (attempt: SearchAttempt) => Promise<void> | void;
10
11
  };
12
+ export declare const braveSearchCapabilities: SearchCapabilities;
11
13
  export declare const createBraveSearch: (options: BraveOptions) => SearchProvider;
package/dist/brave.js CHANGED
@@ -1,4 +1,30 @@
1
1
  // @bun
2
+ // src/capabilities.ts
3
+ var assertSearchCapabilities = (provider, request) => {
4
+ const capabilities = provider.capabilities;
5
+ const requested = [
6
+ ...Object.entries(request.filters ?? {}).filter(([, value]) => value !== undefined).map(([key]) => key),
7
+ ...["freshness", "country", "language"].filter((key) => request[key] !== undefined)
8
+ ];
9
+ if (!capabilities) {
10
+ if (request.filters && Object.keys(request.filters).length)
11
+ throw new Error("Provider does not declare support for requested filters");
12
+ return;
13
+ }
14
+ if (!capabilities.modes.includes(request.mode ?? "context"))
15
+ throw new Error("Provider does not support requested search mode");
16
+ for (const filter of requested)
17
+ if (!capabilities.filters.includes(filter))
18
+ throw new Error(`Provider does not support search filter: ${filter}`);
19
+ };
20
+ var withSearchCapabilities = (provider) => ({
21
+ ...provider,
22
+ search: (request) => {
23
+ assertSearchCapabilities(provider, request);
24
+ return provider.search(request);
25
+ }
26
+ });
27
+
2
28
  // src/types.ts
3
29
  var searchCompleted = (result) => result.status === "ok" || result.status === "empty";
4
30
  var searchUsable = (result) => result.sources.length > 0 && (result.status === "ok" || result.status === "partial");
@@ -62,11 +88,17 @@ var numberIn = (value, fallback, min, max) => {
62
88
  throw new Error(`Search option must be an integer from ${min} through ${max}`);
63
89
  return n;
64
90
  };
91
+ var braveSearchCapabilities = {
92
+ modes: ["web", "context"],
93
+ filters: ["freshness", "country", "language"],
94
+ content: ["excerpts"]
95
+ };
65
96
  var createBraveSearch = (options) => {
66
97
  const now = options.now ?? Date.now;
67
98
  const version = options.apiVersion ?? "2026-07-31";
68
99
  return {
69
100
  name: "brave",
101
+ capabilities: braveSearchCapabilities,
70
102
  version,
71
103
  search: async (request) => {
72
104
  const started = now();
@@ -96,6 +128,7 @@ var createBraveSearch = (options) => {
96
128
  let response;
97
129
  try {
98
130
  request.signal?.throwIfAborted();
131
+ assertSearchCapabilities({ capabilities: braveSearchCapabilities }, request);
99
132
  const queries = boundedQueries(request.query);
100
133
  if (queries.length !== 1)
101
134
  throw new Error("Search requires one nonempty query within 600 characters and 75 words");
@@ -228,5 +261,6 @@ var createBraveSearch = (options) => {
228
261
  };
229
262
  };
230
263
  export {
264
+ braveSearchCapabilities,
231
265
  createBraveSearch
232
266
  };
@@ -0,0 +1,16 @@
1
+ import type { SearchProvider, SearchRequest } from "./types";
2
+ export type SearchCapabilities = {
3
+ modes: readonly ("web" | "context")[];
4
+ filters: readonly ("freshness" | "country" | "language" | "includeDomains" | "excludeDomains" | "publishedAfter" | "publishedBefore" | "category")[];
5
+ content: readonly ("excerpts" | "text")[];
6
+ };
7
+ export type SearchFilters = {
8
+ includeDomains?: string[];
9
+ excludeDomains?: string[];
10
+ publishedAfter?: string;
11
+ publishedBefore?: string;
12
+ category?: string;
13
+ };
14
+ /** Reject unsupported constraints before provider work; never silently broaden a query. */
15
+ export declare const assertSearchCapabilities: (provider: Pick<SearchProvider, "capabilities">, request: SearchRequest) => void;
16
+ export declare const withSearchCapabilities: (provider: SearchProvider) => SearchProvider;
package/dist/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from "./types";
2
2
  export * from "./cache";
3
+ export * from "./capabilities";
package/dist/index.js CHANGED
@@ -114,7 +114,33 @@ var withSearchCache = (provider, options) => {
114
114
  }
115
115
  };
116
116
  };
117
+ // src/capabilities.ts
118
+ var assertSearchCapabilities = (provider, request) => {
119
+ const capabilities = provider.capabilities;
120
+ const requested = [
121
+ ...Object.entries(request.filters ?? {}).filter(([, value]) => value !== undefined).map(([key]) => key),
122
+ ...["freshness", "country", "language"].filter((key) => request[key] !== undefined)
123
+ ];
124
+ if (!capabilities) {
125
+ if (request.filters && Object.keys(request.filters).length)
126
+ throw new Error("Provider does not declare support for requested filters");
127
+ return;
128
+ }
129
+ if (!capabilities.modes.includes(request.mode ?? "context"))
130
+ throw new Error("Provider does not support requested search mode");
131
+ for (const filter of requested)
132
+ if (!capabilities.filters.includes(filter))
133
+ throw new Error(`Provider does not support search filter: ${filter}`);
134
+ };
135
+ var withSearchCapabilities = (provider) => ({
136
+ ...provider,
137
+ search: (request) => {
138
+ assertSearchCapabilities(provider, request);
139
+ return provider.search(request);
140
+ }
141
+ });
117
142
  export {
143
+ assertSearchCapabilities,
118
144
  boundedQueries,
119
145
  evidenceText,
120
146
  searchCacheKey,
@@ -122,5 +148,6 @@ export {
122
148
  searchUsable,
123
149
  sourceSupportsQuote,
124
150
  unavailableSearch,
125
- withSearchCache
151
+ withSearchCache,
152
+ withSearchCapabilities
126
153
  };
@@ -1,9 +1,13 @@
1
- export declare const manifest: Omit<import("@absolutejs/manifest").PackageManifest<Record<string, never>, never>, "contract" | "settings" | "tools"> & (({
1
+ import type { SearchProvider } from "./types";
2
+ import type { BraveOptions } from "./brave";
3
+ export declare const manifest: Omit<import("@absolutejs/manifest").PackageManifest<BraveOptions, SearchProvider>, "contract" | "settings" | "tools"> & (({
2
4
  contract: 1;
3
- tools?: Record<string, import("@absolutejs/manifest").LegacyManifestTool<never>> | undefined;
5
+ tools?: Record<string, import("@absolutejs/manifest").LegacyManifestTool<SearchProvider>> | undefined;
4
6
  } | {
5
7
  contract: 2;
6
- tools?: Record<string, import("@absolutejs/manifest").AuthorizedManifestTool<never>> | undefined;
8
+ tools?: Record<string, import("@absolutejs/manifest").AuthorizedManifestTool<SearchProvider>> | undefined;
7
9
  }) & {
8
- settings: import("@sinclair/typebox").TObject<{}>;
10
+ settings: import("@sinclair/typebox").TObject<{
11
+ timeoutMs: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
12
+ }>;
9
13
  });
package/dist/manifest.js CHANGED
@@ -7,6 +7,15 @@ var defineManifest = () => (manifest) => manifest;
7
7
  var literal = (value) => value;
8
8
  var RUNTIME_KIND = literal("runtime");
9
9
  var WORKSPACE_KIND = literal("workspace");
10
+ var toolFactory = () => {
11
+ function runtime(definition) {
12
+ return { kind: RUNTIME_KIND, ...definition };
13
+ }
14
+ function workspace(definition) {
15
+ return { kind: WORKSPACE_KIND, ...definition };
16
+ }
17
+ return { runtime, workspace };
18
+ };
10
19
  var TOOL_NAME_PATTERN = /^[a-z][a-z0-9_]{0,63}$/;
11
20
  var envRequirement = Type.Object({
12
21
  description: Type.String(),
@@ -278,6 +287,7 @@ var manifestSchema = Type.Object({
278
287
 
279
288
  // src/manifest.ts
280
289
  import { Type as Type2 } from "@sinclair/typebox";
290
+ var tool = toolFactory();
281
291
  var manifest = defineManifest()({
282
292
  contract: 2,
283
293
  identity: {
@@ -288,8 +298,56 @@ var manifest = defineManifest()({
288
298
  tagline: "Replaceable search providers with explicit evidence and outcomes.",
289
299
  description: "Provider-neutral web and context search contracts, Brave adapter, bounded queries, source excerpts, per-attempt accounting hooks, cancellation and scoped caching. Credentials and spending policy belong to the host."
290
300
  },
291
- settings: Type2.Object({}),
292
- wiring: []
301
+ integration: { mode: "recipe" },
302
+ requires: {
303
+ env: [
304
+ {
305
+ key: "BRAVE_SEARCH_API_KEY",
306
+ secret: true,
307
+ description: "Brave Search API key"
308
+ }
309
+ ]
310
+ },
311
+ settings: Type2.Object({
312
+ timeoutMs: Type2.Optional(Type2.Integer({
313
+ minimum: 1,
314
+ maximum: 120000,
315
+ title: "Request timeout (ms)"
316
+ }))
317
+ }),
318
+ tools: {
319
+ search_web: tool.runtime({
320
+ annotations: { openWorldHint: true },
321
+ authorization: {
322
+ approval: "policy",
323
+ audience: "authenticated",
324
+ effects: ["read", "external-network"],
325
+ destinations: ["configured-search-provider"],
326
+ requiredScopes: ["search:read"],
327
+ reversible: false,
328
+ idempotency: { mode: "host" }
329
+ },
330
+ description: "Search using the configured provider; return evidence, limitations, and attempt accounting.",
331
+ input: Type2.Object({
332
+ query: Type2.String({ minLength: 1, maxLength: 600 }),
333
+ mode: Type2.Optional(Type2.Union([Type2.Literal("web"), Type2.Literal("context")]))
334
+ }),
335
+ handler: async (input, runtime) => JSON.stringify(await runtime.search(input))
336
+ })
337
+ },
338
+ wiring: [
339
+ {
340
+ id: "brave",
341
+ title: "Configure Brave search",
342
+ server: {
343
+ placement: "module-scope",
344
+ imports: [
345
+ { from: "@absolutejs/search/brave", names: ["createBraveSearch"] }
346
+ ],
347
+ code: "const search = createBraveSearch({ ...${settings}, apiKey: ${env.BRAVE_SEARCH_API_KEY} });"
348
+ }
349
+ }
350
+ ]
293
351
  });
294
352
  export {
295
353
  manifest
@@ -8,9 +8,97 @@
8
8
  "tagline": "Replaceable search providers with explicit evidence and outcomes.",
9
9
  "description": "Provider-neutral web and context search contracts, Brave adapter, bounded queries, source excerpts, per-attempt accounting hooks, cancellation and scoped caching. Credentials and spending policy belong to the host."
10
10
  },
11
+ "integration": {
12
+ "mode": "recipe"
13
+ },
14
+ "requires": {
15
+ "env": [
16
+ {
17
+ "key": "BRAVE_SEARCH_API_KEY",
18
+ "secret": true,
19
+ "description": "Brave Search API key"
20
+ }
21
+ ]
22
+ },
11
23
  "settings": {
12
24
  "type": "object",
13
- "properties": {}
25
+ "properties": {
26
+ "timeoutMs": {
27
+ "minimum": 1,
28
+ "maximum": 120000,
29
+ "title": "Request timeout (ms)",
30
+ "type": "integer"
31
+ }
32
+ }
14
33
  },
15
- "wiring": []
34
+ "wiring": [
35
+ {
36
+ "id": "brave",
37
+ "title": "Configure Brave search",
38
+ "server": {
39
+ "placement": "module-scope",
40
+ "imports": [
41
+ {
42
+ "from": "@absolutejs/search/brave",
43
+ "names": [
44
+ "createBraveSearch"
45
+ ]
46
+ }
47
+ ],
48
+ "code": "const search = createBraveSearch({ ...${settings}, apiKey: ${env.BRAVE_SEARCH_API_KEY} });"
49
+ }
50
+ }
51
+ ],
52
+ "tools": {
53
+ "search_web": {
54
+ "annotations": {
55
+ "openWorldHint": true
56
+ },
57
+ "authorization": {
58
+ "approval": "policy",
59
+ "audience": "authenticated",
60
+ "effects": [
61
+ "read",
62
+ "external-network"
63
+ ],
64
+ "destinations": [
65
+ "configured-search-provider"
66
+ ],
67
+ "requiredScopes": [
68
+ "search:read"
69
+ ],
70
+ "reversible": false,
71
+ "idempotency": {
72
+ "mode": "host"
73
+ }
74
+ },
75
+ "description": "Search using the configured provider; return evidence, limitations, and attempt accounting.",
76
+ "input": {
77
+ "type": "object",
78
+ "required": [
79
+ "query"
80
+ ],
81
+ "properties": {
82
+ "query": {
83
+ "minLength": 1,
84
+ "maxLength": 600,
85
+ "type": "string"
86
+ },
87
+ "mode": {
88
+ "anyOf": [
89
+ {
90
+ "const": "web",
91
+ "type": "string"
92
+ },
93
+ {
94
+ "const": "context",
95
+ "type": "string"
96
+ }
97
+ ]
98
+ }
99
+ }
100
+ },
101
+ "kind": "runtime"
102
+ }
103
+ }
16
104
  }
package/dist/types.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { SearchCapabilities, SearchFilters } from "./capabilities";
1
2
  export type SearchStatus = "ok" | "empty" | "partial" | "unavailable" | "rate_limited" | "quota_exceeded" | "cancelled" | "error";
2
3
  export type SearchSource = {
3
4
  id: string;
@@ -11,6 +12,7 @@ export type SearchSource = {
11
12
  metadata?: Record<string, unknown>;
12
13
  };
13
14
  export type SearchRequest = {
15
+ filters?: SearchFilters;
14
16
  query: string;
15
17
  mode?: "web" | "context";
16
18
  signal?: AbortSignal;
@@ -57,6 +59,7 @@ export type SearchResult = {
57
59
  };
58
60
  };
59
61
  export type SearchProvider = {
62
+ capabilities?: SearchCapabilities;
60
63
  name: string;
61
64
  version: string;
62
65
  search: (request: SearchRequest) => Promise<SearchResult>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@absolutejs/search",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "type": "module",
5
5
  "description": "Provider-neutral web search, grounded evidence, and replaceable search adapters",
6
6
  "license": "BSL-1.1",