Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.114.0"
".": "0.115.0"
}
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## [0.115.0](https://github.com/kernel/kernel-node-sdk/compare/v0.114.0...v0.115.0) (2026-09-30)


### Features

* Fetch content for selected results from retained searches ([kernel/kernel#3978](https://github.com/kernel/kernel/pull/3978))

## [0.114.0](https://github.com/kernel/kernel-node-sdk/compare/v0.113.0...v0.114.0) (2026-09-30)


Expand Down
2 changes: 1 addition & 1 deletion api.md
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ Types:

Methods:

- <code title="post /search/{id}/contents">client.search.contents.<a href="./src/resources/search/contents.ts">fetch</a>(id, { ...params }) -> void</code>
- <code title="post /search/{id}/contents">client.search.contents.<a href="./src/resources/search/contents.ts">fetch</a>(id, { ...params }) -> Response</code>

## Providers

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@onkernel/sdk",
"version": "0.114.0",
"version": "0.115.0",
"description": "The official TypeScript library for the Kernel API",
"author": "Kernel <>",
"types": "dist/index.d.ts",
Expand Down
148 changes: 86 additions & 62 deletions src/resources/search/contents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import { APIResource } from '../../core/resource';
import * as SearchAPI from './search';
import { APIPromise } from '../../core/api-promise';
import { buildHeaders } from '../../internal/headers';
import { RequestOptions } from '../../internal/request-options';
import { path } from '../../internal/utils/path';

Expand All @@ -12,21 +11,25 @@ import { path } from '../../internal/utils/path';
*/
export class Contents extends APIResource {
/**
* Deferred result-content retrieval is reserved but not available in this release.
* Requests return 404 until the retrieval implementation is shipped. X-Request-Id
* identifies this request separately from the search resource.
* Retrieves selected results from a retained search. Provide exactly one of
* result_ids or limit; the latter fetches the top results. Content defaults to
* source:auto. Responses preserve result_ids order. Unknown result IDs are
* rejected before retrieval starts. Missing, expired, or inaccessible searches
* return 404. Once retrieval begins, return one outcome per selected result,
* including timeout entries for work unfinished at the overall deadline. Browser
* retrievals run sequentially in result order, so later results may time out when
* earlier pages are slow. X-Request-Id identifies this request separately from the
* search resource.
*
* @example
* ```ts
* await client.search.contents.fetch('srch_abc123');
* const response = await client.search.contents.fetch(
* 'srch_abc123',
* );
* ```
*/
fetch(id: string, body: ContentFetchParams, options?: RequestOptions): APIPromise<void> {
return this._client.post(path`/search/${id}/contents`, {
body,
...options,
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
});
fetch(id: string, body: ContentFetchParams, options?: RequestOptions): APIPromise<Response> {
return this._client.post(path`/search/${id}/contents`, { body, ...options });
}
}

Expand Down Expand Up @@ -60,36 +63,37 @@ export namespace FetchRequest {
*/
export interface Content {
/**
* Invalid with source=provider. Supplying browser_id requires source=browser so
* the chosen identity is not bypassed.
* Requires source=auto or source=browser in deferred retrieval.
*/
browser?: Content.Browser;

format?: 'markdown' | 'text';

/**
* Maximum acceptable age of cached page content, measured from origin retrieval. 0
* forces a live fetch. Governs the Kernel content cache, which is scoped to the
* caller organization and project and separated by retrieval context; fetches
* through a caller-supplied browser_id bypass that cache. Mapped to the provider
* freshness control when source is provider and the provider supports one;
* otherwise provider content age is reported as unknown via fetched_at.
* For source=auto, maximum acceptable age of retained provider content, measured
* from when the search received it from the provider. A value of 0 disables reuse
* of retained content, so every result is fetched through a browser.
* source=provider reuses retained provider content without freshness validation.
* source=browser always fetches through a browser and does not use this age limit.
*/
max_age_hours?: number;

/**
* Per-result Unicode character limit after extraction.
* Per-result Unicode character limit after extraction. Retained provider content
* cannot exceed what was stored at search time; such results report truncated when
* the stored text was already truncated.
*/
max_chars?: number;

/**
* provider uses the search provider's native content retrieval; browser fetches
* each URL through a Kernel browser; auto prefers Kernel browser retrieval and
* falls back to provider-native content when browser retrieval is unavailable or
* unsuitable. Defaults to auto for both inline and deferred retrieval. Deferred
* provider retrieval requires post_hoc capability; an explicit provider source
* without it is a 400. Missing documents produce per-result unavailable outcomes,
* not request failures.
* auto uses retained provider content within max_age_hours; for deferred retrieval
* it falls back to a Kernel browser (caller-supplied or temporary) for results
* without it. Inline retrieval never uses a browser. provider reuses retained
* provider content when available, without freshness validation, and never
* provisions a browser. browser fetches each URL through a Kernel browser, either
* caller-supplied or temporary. No option makes a new provider request. Defaults
* to auto for both inline and deferred retrieval. Missing documents produce
* per-result unavailable outcomes, not request failures.
*/
source?: 'auto' | 'provider' | 'browser';

Expand All @@ -102,17 +106,22 @@ export namespace FetchRequest {

export namespace Content {
/**
* Invalid with source=provider. Supplying browser_id requires source=browser so
* the chosen identity is not bypassed.
* Requires source=auto or source=browser in deferred retrieval.
*/
export interface Browser {
/**
* Existing browser session ID authorized for the caller and selected project.
* Reuses its cookies, proxy, and browser configuration. Kernel does not delete a
* caller-supplied browser. Render mode uses a temporary tab; website activity may
* still change shared cookies and storage. When omitted, Kernel obtains isolated
* browser capacity in the caller's account and releases it after retrieval. That
* capacity is not retained for later interaction. Existing browser quotas apply.
* Reuses its cookies, proxy, and browser configuration; requests follow that
* browser's existing network access behavior, with no additional destination
* allowlist in this endpoint. Kernel does not delete a caller-supplied browser.
* Render mode uses a temporary tab; website activity may still change shared
* cookies and storage. When omitted and any result needs browser retrieval, Kernel
* creates one temporary browser for the request using the dashboard launch
* defaults (headful, stealth, default proxy), tags it with search_id, and deletes
* it when the request finishes. It is billed and counts toward browser concurrency
* like any other browser. A concurrency rejection returns 429 for source=browser;
* for source=auto, results with retained content are still returned and the rest
* report the rejection.
*/
browser_id?: string;

Expand Down Expand Up @@ -154,7 +163,9 @@ export namespace Response {
url: string;

/**
* Kernel cache outcome. Provider-internal cache behavior may be unknown.
* Kernel content cache outcome. Kernel has no content cache yet: responses report
* bypass or unknown, and hit and miss are reserved. Provider-internal cache
* behavior may be unknown.
*/
cache_status?: 'hit' | 'miss' | 'bypass' | 'unknown';

Expand All @@ -172,15 +183,21 @@ export namespace Response {
extractor_version?: string;

/**
* Origin retrieval time when known, not cache read time.
* When Kernel fetched the content, or received it from the provider for retained
* content.
*/
fetched_at?: string | null;

/**
* Final retrieval URL when known.
* Final retrieval URL after redirects when known. Curl mode follows up to 5
* redirects.
*/
final_url?: string;

/**
* Format of text. Plain-text and JSON pages are returned unchanged as text even
* when markdown was requested.
*/
format?: 'markdown' | 'text';

/**
Expand All @@ -189,7 +206,7 @@ export namespace Response {
http_status?: number;

/**
* Original retrieval method, including on cache hits.
* Original retrieval method.
*/
method?: 'provider' | 'browser_curl' | 'browser_render';

Expand All @@ -200,7 +217,8 @@ export namespace Response {
text?: string;

/**
* Whether max_chars truncated the extracted content.
* Whether the content was cut short, by max_chars or because the page exceeded the
* 1 MiB read limit.
*/
truncated?: boolean;
}
Expand Down Expand Up @@ -252,36 +270,37 @@ export namespace ContentFetchParams {
*/
export interface Content {
/**
* Invalid with source=provider. Supplying browser_id requires source=browser so
* the chosen identity is not bypassed.
* Requires source=auto or source=browser in deferred retrieval.
*/
browser?: Content.Browser;

format?: 'markdown' | 'text';

/**
* Maximum acceptable age of cached page content, measured from origin retrieval. 0
* forces a live fetch. Governs the Kernel content cache, which is scoped to the
* caller organization and project and separated by retrieval context; fetches
* through a caller-supplied browser_id bypass that cache. Mapped to the provider
* freshness control when source is provider and the provider supports one;
* otherwise provider content age is reported as unknown via fetched_at.
* For source=auto, maximum acceptable age of retained provider content, measured
* from when the search received it from the provider. A value of 0 disables reuse
* of retained content, so every result is fetched through a browser.
* source=provider reuses retained provider content without freshness validation.
* source=browser always fetches through a browser and does not use this age limit.
*/
max_age_hours?: number;

/**
* Per-result Unicode character limit after extraction.
* Per-result Unicode character limit after extraction. Retained provider content
* cannot exceed what was stored at search time; such results report truncated when
* the stored text was already truncated.
*/
max_chars?: number;

/**
* provider uses the search provider's native content retrieval; browser fetches
* each URL through a Kernel browser; auto prefers Kernel browser retrieval and
* falls back to provider-native content when browser retrieval is unavailable or
* unsuitable. Defaults to auto for both inline and deferred retrieval. Deferred
* provider retrieval requires post_hoc capability; an explicit provider source
* without it is a 400. Missing documents produce per-result unavailable outcomes,
* not request failures.
* auto uses retained provider content within max_age_hours; for deferred retrieval
* it falls back to a Kernel browser (caller-supplied or temporary) for results
* without it. Inline retrieval never uses a browser. provider reuses retained
* provider content when available, without freshness validation, and never
* provisions a browser. browser fetches each URL through a Kernel browser, either
* caller-supplied or temporary. No option makes a new provider request. Defaults
* to auto for both inline and deferred retrieval. Missing documents produce
* per-result unavailable outcomes, not request failures.
*/
source?: 'auto' | 'provider' | 'browser';

Expand All @@ -294,17 +313,22 @@ export namespace ContentFetchParams {

export namespace Content {
/**
* Invalid with source=provider. Supplying browser_id requires source=browser so
* the chosen identity is not bypassed.
* Requires source=auto or source=browser in deferred retrieval.
*/
export interface Browser {
/**
* Existing browser session ID authorized for the caller and selected project.
* Reuses its cookies, proxy, and browser configuration. Kernel does not delete a
* caller-supplied browser. Render mode uses a temporary tab; website activity may
* still change shared cookies and storage. When omitted, Kernel obtains isolated
* browser capacity in the caller's account and releases it after retrieval. That
* capacity is not retained for later interaction. Existing browser quotas apply.
* Reuses its cookies, proxy, and browser configuration; requests follow that
* browser's existing network access behavior, with no additional destination
* allowlist in this endpoint. Kernel does not delete a caller-supplied browser.
* Render mode uses a temporary tab; website activity may still change shared
* cookies and storage. When omitted and any result needs browser retrieval, Kernel
* creates one temporary browser for the request using the dashboard launch
* defaults (headful, stealth, default proxy), tags it with search_id, and deletes
* it when the request finishes. It is billed and counts toward browser concurrency
* like any other browser. A concurrency rejection returns 429 for source=browser;
* for source=auto, results with retained content are still returned and the rest
* report the rejection.
*/
browser_id?: string;

Expand Down
Loading
Loading