webfox 4.11.0 → 4.13.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/README.md +5 -2
- package/dist/adapter-2HWVV4H7.js +144 -0
- package/dist/{adapter-QQZFHUOP.js → adapter-2V73476L.js} +69 -131
- package/dist/{adapter-SZMVKAMC.js → adapter-3V4OZDZZ.js} +10 -14
- package/dist/adapter-64462GL3.js +247 -0
- package/dist/{adapter-WXEVTCM3.js → adapter-BCZ4UE7S.js} +38 -81
- package/dist/{adapter-YVZ4YBK5.js → adapter-BHDA6JOK.js} +40 -56
- package/dist/adapter-EQ3LZTZ4.js +152 -0
- package/dist/adapter-EQSFB26L.js +58 -0
- package/dist/{adapter-ODDFBGJG.js → adapter-EXDS6465.js} +36 -57
- package/dist/adapter-IWGMWJ5A.js +121 -0
- package/dist/{adapter-XSQX3GAI.js → adapter-JQNYUBYZ.js} +33 -23
- package/dist/{adapter-VXT4C6RZ.js → adapter-OTMS6OEU.js} +81 -102
- package/dist/{adapter-MZ7USB6Q.js → adapter-PW4UL2DR.js} +12 -32
- package/dist/adapter-RBSOVQCV.js +84 -0
- package/dist/{adapter-GFXYSHKP.js → adapter-RJ334ZU5.js} +28 -76
- package/dist/{adapter-XU2APKPC.js → adapter-T6UEERC7.js} +19 -24
- package/dist/{adapter-BZO5UEI6.js → adapter-VVWNAGWI.js} +118 -142
- package/dist/{adapter-GJOUFE2U.js → adapter-XMEXVEMQ.js} +7 -10
- package/dist/adapter-ZLS55DG2.js +341 -0
- package/dist/{chunk-NENL6L6N.js → chunk-46OIVYHW.js} +1 -0
- package/dist/{chunk-WCTOYZVB.js → chunk-6UC3ZBNK.js} +15 -5
- package/dist/{chunk-YILOS4E7.js → chunk-7NTO6AQX.js} +110 -72
- package/dist/{chunk-PVNWACMT.js → chunk-EBKQHHCO.js} +199 -20
- package/dist/chunk-HZVTFUBC.js +139 -0
- package/dist/{chunk-LDVDVA4Z.js → chunk-I4HLGP7F.js} +3 -7
- package/dist/chunk-U4I3X7IN.js +267 -0
- package/dist/chunk-V4SQCDI3.js +336 -0
- package/dist/chunk-VMIDLDYP.js +111 -0
- package/dist/cli.js +9 -9
- package/dist/config.schema.json +222 -1
- package/dist/document-schema.d.ts +4 -4
- package/dist/domain.d.ts +1 -1
- package/dist/durable.js +73 -65
- package/dist/index.js +8 -7
- package/dist/pi-render.d.ts +3 -2
- package/dist/pi-shared.d.ts +39 -0
- package/dist/pi.js +87 -191
- package/dist/providers/brave/adapter.d.ts +4 -5
- package/dist/providers/cloudflare/adapter.d.ts +3 -2
- package/dist/providers/contract.d.ts +20 -19
- package/dist/providers/custom/adapter.d.ts +2 -2
- package/dist/providers/exa/adapter.d.ts +6 -6
- package/dist/providers/firecrawl/adapter.d.ts +5 -5
- package/dist/providers/gemini/adapter.d.ts +5 -10
- package/dist/providers/keenable/adapter.d.ts +2 -3
- package/dist/providers/linkup/adapter.d.ts +5 -5
- package/dist/providers/ollama/adapter.d.ts +4 -4
- package/dist/providers/openai/adapter.d.ts +4 -4
- package/dist/providers/openai/types.d.ts +2 -4
- package/dist/providers/parallel/adapter.d.ts +4 -4
- package/dist/providers/perplexity/adapter.d.ts +4 -5
- package/dist/providers/registry.d.ts +1 -0
- package/dist/providers/serpbase/types.d.ts +2 -4
- package/dist/providers/serper/adapter.d.ts +2 -2
- package/dist/providers/serper/types.d.ts +2 -4
- package/dist/providers/shared.d.ts +50 -0
- package/dist/providers/sofya/adapter.d.ts +6 -6
- package/dist/providers/tapline/adapter.d.ts +4 -0
- package/dist/providers/tapline/definition.d.ts +1 -0
- package/dist/providers/tavily/adapter.d.ts +4 -4
- package/dist/providers/valyu/adapter.d.ts +6 -6
- package/dist/providers/youcom/adapter.d.ts +2 -3
- package/dist/runtime/duration.d.ts +2 -0
- package/dist/runtime/execute.d.ts +3 -1
- package/dist/runtime/lifecycle.d.ts +0 -1
- package/dist/runtime/outward.d.ts +6 -1
- package/dist/runtime/polling.d.ts +2 -3
- package/docs/provider.md +29 -0
- package/package.json +14 -20
- package/dist/adapter-44ZBIK47.js +0 -121
- package/dist/adapter-57MELLYI.js +0 -160
- package/dist/adapter-D4EXZEDL.js +0 -213
- package/dist/adapter-DJCTEEOA.js +0 -159
- package/dist/adapter-DLNMW34W.js +0 -214
- package/dist/adapter-RR55EZAW.js +0 -73
- package/dist/chunk-FSTCLBSF.js +0 -76
- package/dist/chunk-I2UIACY3.js +0 -12
- package/dist/chunk-KMUCUJVN.js +0 -251
- package/dist/chunk-TYJ6RHKB.js +0 -31
- package/dist/chunk-VVOQKYOP.js +0 -112
- package/dist/contents.d.ts +0 -24
- package/dist/providers/brave/types.d.ts +0 -4
- package/dist/providers/exa/types.d.ts +0 -4
- package/dist/providers/firecrawl/types.d.ts +0 -4
- package/dist/providers/gemini/types.d.ts +0 -3
- package/dist/providers/keenable/types.d.ts +0 -4
- package/dist/providers/linkup/types.d.ts +0 -4
- package/dist/providers/ollama/types.d.ts +0 -4
- package/dist/providers/parallel/types.d.ts +0 -4
- package/dist/providers/perplexity/types.d.ts +0 -4
- package/dist/providers/sofya/types.d.ts +0 -4
- package/dist/providers/tavily/types.d.ts +0 -4
- package/dist/providers/valyu/types.d.ts +0 -4
- package/dist/providers/youcom/types.d.ts +0 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { HttpProvider } from "../contract.js";
|
|
2
2
|
export declare const SERPBASE_MODES: {
|
|
3
3
|
readonly search: {
|
|
4
4
|
readonly path: "search";
|
|
@@ -32,6 +32,4 @@ export declare const SERPBASE_MODES: {
|
|
|
32
32
|
};
|
|
33
33
|
};
|
|
34
34
|
export type SerpBaseMode = keyof typeof SERPBASE_MODES;
|
|
35
|
-
export
|
|
36
|
-
baseUrl?: string;
|
|
37
|
-
}
|
|
35
|
+
export type SerpBase = HttpProvider;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ProviderContext, SearchResponse } from "../contract.js";
|
|
1
|
+
import type { ProviderContext, ProviderRequest, SearchResponse } from "../contract.js";
|
|
2
2
|
import type { Serper } from "./types.js";
|
|
3
3
|
export declare const adapter: {
|
|
4
|
-
search(
|
|
4
|
+
search(request: ProviderRequest<"search">, config: Serper, context: ProviderContext): Promise<SearchResponse>;
|
|
5
5
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { HttpProvider } from "../contract.js";
|
|
2
2
|
export declare const SERPER_SEARCH_MODE_VALUES: {
|
|
3
3
|
readonly search: "search";
|
|
4
4
|
readonly images: "images";
|
|
@@ -16,6 +16,4 @@ export declare const SERPER_SEARCH_MODE_VALUES: {
|
|
|
16
16
|
readonly webpage: "webpage";
|
|
17
17
|
};
|
|
18
18
|
export type SerperSearchMode = (typeof SERPER_SEARCH_MODE_VALUES)[keyof typeof SERPER_SEARCH_MODE_VALUES];
|
|
19
|
-
export
|
|
20
|
-
baseUrl?: string;
|
|
21
|
-
}
|
|
19
|
+
export type Serper = HttpProvider;
|
|
@@ -1,3 +1,35 @@
|
|
|
1
|
+
import { WebfoxError } from "../errors.js";
|
|
2
|
+
import type { Provider } from "./contract.js";
|
|
3
|
+
export declare function asRecord(value: unknown): Record<string, unknown> | undefined;
|
|
4
|
+
export declare function readString(value: unknown): string | undefined;
|
|
5
|
+
export declare function readNonEmptyString(value: unknown): string | undefined;
|
|
6
|
+
export declare function readInteger(value: unknown): number | undefined;
|
|
7
|
+
export declare function readPositiveInteger(value: unknown): number | undefined;
|
|
8
|
+
export declare function readStringArray(value: unknown): string[] | undefined;
|
|
9
|
+
export declare function readStringUnion<const TValue extends string>(value: unknown, values: readonly TValue[]): TValue | undefined;
|
|
10
|
+
export declare function requireApiKey(config: Provider, key?: string, label?: string): string;
|
|
11
|
+
export declare function omittedContentsError(): WebfoxError;
|
|
12
|
+
export declare function ambiguousContentsError(): WebfoxError;
|
|
13
|
+
/**
|
|
14
|
+
* Resolve a single requested URL against a batch-shaped extraction response.
|
|
15
|
+
* Prefers an exact result match, then an exact error match, then a sole
|
|
16
|
+
* candidate (for redirects), and rejects ambiguous multi-item payloads.
|
|
17
|
+
*/
|
|
18
|
+
export declare function pickSingleUrlOutcome<TResult extends {
|
|
19
|
+
url?: string;
|
|
20
|
+
}, TError extends {
|
|
21
|
+
url?: string;
|
|
22
|
+
} = never>(url: string, results: readonly TResult[], errors?: readonly TError[]): {
|
|
23
|
+
kind: "result";
|
|
24
|
+
value: TResult;
|
|
25
|
+
} | {
|
|
26
|
+
kind: "error";
|
|
27
|
+
value: TError;
|
|
28
|
+
} | {
|
|
29
|
+
kind: "omitted";
|
|
30
|
+
} | {
|
|
31
|
+
kind: "ambiguous";
|
|
32
|
+
};
|
|
1
33
|
export declare function trimSnippet(input: string | undefined, maxLength?: number): string;
|
|
2
34
|
export declare function normalizeContentText(input: string | undefined): string;
|
|
3
35
|
export declare function asJsonObject(value: Record<string, unknown> | undefined): Record<string, unknown>;
|
|
@@ -7,6 +39,24 @@ export declare function joinUrl(baseUrl: string, path: string): string;
|
|
|
7
39
|
export declare function readResponseBody(response: Response): Promise<unknown>;
|
|
8
40
|
/** Reject successful responses whose body is empty or not JSON. */
|
|
9
41
|
export declare function expectJsonBody(payload: unknown, response: Response): unknown;
|
|
42
|
+
/**
|
|
43
|
+
* Merge header maps with case-insensitive override precedence so later layers
|
|
44
|
+
* replace earlier values without producing comma-joined duplicate headers.
|
|
45
|
+
*/
|
|
46
|
+
export declare function mergeHeaders(...layers: Array<Record<string, string> | undefined>): Record<string, string>;
|
|
47
|
+
export interface SseJsonEvent {
|
|
48
|
+
event?: string;
|
|
49
|
+
data: unknown;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Read JSON events from a Server-Sent Events response stream.
|
|
53
|
+
* Buffers multi-line `data:` payloads per SSE event, preserves `event:` names,
|
|
54
|
+
* terminates immediately on `[DONE]`, surfaces malformed JSON as a provider
|
|
55
|
+
* error, and lets handler errors propagate.
|
|
56
|
+
*/
|
|
57
|
+
export declare function readSseJson(response: Response, onEvent: (event: SseJsonEvent) => void): Promise<void>;
|
|
58
|
+
/** Extract a concise error message from common JSON or plain-text API error bodies. */
|
|
59
|
+
export declare function describeHttpError(label: string, payload: unknown, response: Response): string;
|
|
10
60
|
/**
|
|
11
61
|
* Send one JSON request without retries; the runtime owns retry policy.
|
|
12
62
|
* Non-2xx responses become classified provider errors with the message that
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { ContentsAnswer } from "../../domain.js";
|
|
2
|
+
import type { HttpProvider, ProviderContext, ProviderRequest, SearchResponse, ToolOutput } from "../contract.js";
|
|
3
3
|
export declare const adapter: {
|
|
4
|
-
search(request: ProviderRequest<"search">, config:
|
|
5
|
-
contents(request: ProviderRequest<"contents">, config:
|
|
6
|
-
answer(request: ProviderRequest<"answer">, config:
|
|
7
|
-
research(request: ProviderRequest<"research">, config:
|
|
4
|
+
search(request: ProviderRequest<"search">, config: HttpProvider, context: ProviderContext): Promise<SearchResponse>;
|
|
5
|
+
contents(request: ProviderRequest<"contents">, config: HttpProvider, context: ProviderContext): Promise<ContentsAnswer>;
|
|
6
|
+
answer(request: ProviderRequest<"answer">, config: HttpProvider, context: ProviderContext): Promise<ToolOutput>;
|
|
7
|
+
research(request: ProviderRequest<"research">, config: HttpProvider, context: ProviderContext): Promise<ToolOutput>;
|
|
8
8
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const taplineProvider: import("../definition.js").ProviderDefinitionFor<"tapline">;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { ContentsAnswer } from "../../domain.js";
|
|
2
|
+
import type { HttpProvider, ProviderContext, ProviderRequest, SearchResponse } from "../contract.js";
|
|
3
3
|
export declare const adapter: {
|
|
4
|
-
search(
|
|
5
|
-
contents(
|
|
4
|
+
search(request: ProviderRequest<"search">, config: HttpProvider, context: ProviderContext): Promise<SearchResponse>;
|
|
5
|
+
contents(request: ProviderRequest<"contents">, config: HttpProvider, context: ProviderContext): Promise<ContentsAnswer>;
|
|
6
6
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { ContentsAnswer } from "../../domain.js";
|
|
2
|
+
import type { HttpProvider, ProviderContext, ProviderRequest, SearchResponse, ToolOutput } from "../contract.js";
|
|
3
3
|
export declare const adapter: {
|
|
4
|
-
search(
|
|
5
|
-
contents(
|
|
6
|
-
answer(
|
|
7
|
-
research(
|
|
4
|
+
search(request: ProviderRequest<"search">, config: HttpProvider, context: ProviderContext): Promise<SearchResponse>;
|
|
5
|
+
contents(request: ProviderRequest<"contents">, config: HttpProvider, context: ProviderContext): Promise<ContentsAnswer>;
|
|
6
|
+
answer(request: ProviderRequest<"answer">, config: HttpProvider, context: ProviderContext): Promise<ToolOutput>;
|
|
7
|
+
research(request: ProviderRequest<"research">, config: HttpProvider, context: ProviderContext): Promise<ToolOutput>;
|
|
8
8
|
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { ProviderContext, SearchResponse } from "../contract.js";
|
|
2
|
-
import type { Youcom } from "./types.js";
|
|
1
|
+
import type { HttpProvider, ProviderContext, ProviderRequest, SearchResponse } from "../contract.js";
|
|
3
2
|
export declare const adapter: {
|
|
4
|
-
search(request:
|
|
3
|
+
search(request: ProviderRequest<"search">, config: HttpProvider, context: ProviderContext): Promise<SearchResponse>;
|
|
5
4
|
};
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
/** Compact elapsed time for human-facing progress and completion messages. */
|
|
2
2
|
export declare function formatDuration(milliseconds: number): string;
|
|
3
|
+
/** Exact deadline duration for timeout messages (for example `250ms`, `30s`, `20m`). */
|
|
4
|
+
export declare function formatDeadline(ms: number): string;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Capability, CapabilityDocument, CapabilityValues, RequestOptions } from "../domain.js";
|
|
2
2
|
import type { ExecutionConfig, ProviderConfiguration } from "../configuration/types.js";
|
|
3
3
|
import type { ProviderDefinition } from "../providers/definition.js";
|
|
4
|
+
import { OutwardBoundary } from "./outward.js";
|
|
4
5
|
export interface ExecutionPlan<C extends Capability> {
|
|
5
6
|
capability: C;
|
|
6
7
|
definition: ProviderDefinition;
|
|
@@ -13,8 +14,9 @@ export interface ExecutionPlan<C extends Capability> {
|
|
|
13
14
|
export declare class ExecutionRuntime {
|
|
14
15
|
private readonly cwd;
|
|
15
16
|
private readonly env;
|
|
17
|
+
private readonly outward;
|
|
16
18
|
private readonly credentials;
|
|
17
|
-
constructor(cwd: string, env: Record<string, string | undefined
|
|
19
|
+
constructor(cwd: string, env: Record<string, string | undefined>, outward?: OutwardBoundary);
|
|
18
20
|
execute<C extends Capability>(plan: ExecutionPlan<C>, request: RequestOptions): Promise<CapabilityDocument<CapabilityValues[C], C>>;
|
|
19
21
|
private run;
|
|
20
22
|
}
|
|
@@ -2,7 +2,6 @@ export declare function deadline(timeoutMs: number, parent?: AbortSignal): {
|
|
|
2
2
|
signal: AbortSignal;
|
|
3
3
|
dispose(): void;
|
|
4
4
|
};
|
|
5
|
-
export declare function formatDuration(ms: number): string;
|
|
6
5
|
export declare function withSignal<T>(promise: Promise<T>, signal?: AbortSignal): Promise<T>;
|
|
7
6
|
export declare function sleep(ms: number, signal?: AbortSignal): Promise<void>;
|
|
8
7
|
export declare function orderedMap<T, R>(items: T[], concurrency: number, work: (item: T, index: number) => Promise<R>): Promise<R[]>;
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import { WebfoxError } from "../errors.js";
|
|
2
|
-
import type { SerializedError } from "../domain.js";
|
|
2
|
+
import type { Capability, CapabilityDocument, ProgressEvent, SerializedError } from "../domain.js";
|
|
3
3
|
/** The only boundary through which internal provider data reaches a caller. */
|
|
4
4
|
export declare class OutwardBoundary {
|
|
5
5
|
private readonly secrets;
|
|
6
6
|
addSecret(secret: string): void;
|
|
7
7
|
text(value: string): string;
|
|
8
8
|
value<T>(value: T): T;
|
|
9
|
+
/** Redact a document without ever renaming fixed response-envelope keys. */
|
|
10
|
+
document<T, C extends Capability>(doc: CapabilityDocument<T, C>): CapabilityDocument<T, C>;
|
|
11
|
+
progress(event: ProgressEvent): ProgressEvent;
|
|
9
12
|
error(error: unknown): SerializedError;
|
|
10
13
|
exception(error: unknown): WebfoxError;
|
|
14
|
+
private redactSerializedError;
|
|
15
|
+
private redactResultValue;
|
|
11
16
|
}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import type { ProviderContext,
|
|
1
|
+
import type { ProviderContext, ResearchJob, ResearchPollResult, ToolOutput } from "../providers/contract.js";
|
|
2
2
|
export { sleep } from "./lifecycle.js";
|
|
3
3
|
/** Shared provider polling mechanics. The runtime supplies the overall signal.
|
|
4
4
|
* Job creation is performed exactly once; only transient polling is repeated.
|
|
5
5
|
*/
|
|
6
|
-
export declare function executeAsyncResearch({ providerLabel,
|
|
6
|
+
export declare function executeAsyncResearch({ providerLabel, context, pollIntervalMs, start, poll, }: {
|
|
7
7
|
providerLabel: string;
|
|
8
|
-
providerId: ProviderId;
|
|
9
8
|
context: ProviderContext;
|
|
10
9
|
pollIntervalMs?: number;
|
|
11
10
|
start: (context: ProviderContext) => Promise<ResearchJob>;
|
package/docs/provider.md
CHANGED
|
@@ -367,6 +367,32 @@ Sofya calls can take up to 60 seconds, so search, contents, and answers have a
|
|
|
367
367
|
90-second overall deadline by default. An explicit CLI `--timeout`, library
|
|
368
368
|
`timeoutMs`, or YAML `execution.timeoutMs` takes precedence.
|
|
369
369
|
|
|
370
|
+
## Tapline
|
|
371
|
+
|
|
372
|
+
Supports search. Set `TAPLINE_API_KEY`, or configure
|
|
373
|
+
`providers.tapline.credentials.api` with a credential source. No defaults change
|
|
374
|
+
unless you select Tapline.
|
|
375
|
+
|
|
376
|
+
```sh
|
|
377
|
+
web search "Node.js release notes" --provider tapline --freshness past_month
|
|
378
|
+
web config default search tapline
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
Search returns [Brave](https://search.brave.com) web results through
|
|
382
|
+
[Tapline](https://tapline.sh) and caps `maxResults` at 20, one Tapline page.
|
|
383
|
+
Native options include `country` (a lowercase country code such as `us` or
|
|
384
|
+
`de`), `search_language`, `safe_search` (`strict`, `moderate`, or `off`),
|
|
385
|
+
`freshness` (`any`, `past_day`, `past_week`, `past_month`, or `past_year`), a
|
|
386
|
+
published-date range with `date_from` and `date_to` (`YYYY-MM-DD`, set both),
|
|
387
|
+
`goggle_url` to re-rank results with a [Brave Goggle](https://search.brave.com/goggles),
|
|
388
|
+
and `spellcheck`. Each search spends Tapline credits; the
|
|
389
|
+
[API reference](https://tapline.sh/docs/brave-search) lists the costs.
|
|
390
|
+
|
|
391
|
+
```sh
|
|
392
|
+
web search "WebAssembly runtimes" --provider tapline \
|
|
393
|
+
--date-from 2026-01-01 --date-to 2026-03-31
|
|
394
|
+
```
|
|
395
|
+
|
|
370
396
|
## You.com
|
|
371
397
|
|
|
372
398
|
Supports search. Set `YDC_API_KEY`; the library, CLI, and Pi extension use the
|
|
@@ -457,6 +483,9 @@ web contents https://example.com --provider tavily
|
|
|
457
483
|
|
|
458
484
|
Supports search, page extraction, answers, and research. Set `VALYU_API_KEY`.
|
|
459
485
|
|
|
486
|
+
Valyu deprecated its Answer API (retires 2026-12-17); prefer `research` with
|
|
487
|
+
`--mode instant` or `search` for new workflows.
|
|
488
|
+
|
|
460
489
|
```sh
|
|
461
490
|
web search "Node.js release notes" --provider valyu
|
|
462
491
|
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webfox",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.13.0",
|
|
4
4
|
"description": "Search the web, extract pages, get grounded answers, and run deep research with the web CLI, a TypeScript library, and a pi extension. Bring your own providers and API keys.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"url": "git+https://github.com/mavam/webfox.git"
|
|
50
50
|
},
|
|
51
51
|
"engines": {
|
|
52
|
-
"node": ">=22.
|
|
52
|
+
"node": ">=22.12.0"
|
|
53
53
|
},
|
|
54
54
|
"publishConfig": {
|
|
55
55
|
"access": "public"
|
|
@@ -92,30 +92,24 @@
|
|
|
92
92
|
"test:watch": "vitest"
|
|
93
93
|
},
|
|
94
94
|
"dependencies": {
|
|
95
|
-
"
|
|
96
|
-
"@tavily/core": "^0.7.14",
|
|
97
|
-
"cloudflare": "^7.3.0",
|
|
98
|
-
"commander": "^14.0.3",
|
|
99
|
-
"openai": "^7.47.0",
|
|
100
|
-
"parallel-web": "^1.3.7",
|
|
95
|
+
"commander": "^15.1.0",
|
|
101
96
|
"picocolors": "^1.1.1",
|
|
102
|
-
"
|
|
103
|
-
"yaml": "^2.9.0"
|
|
97
|
+
"yaml": "^2.9.1"
|
|
104
98
|
},
|
|
105
99
|
"devDependencies": {
|
|
106
|
-
"@biomejs/biome": "^2.
|
|
107
|
-
"@earendil-works/chord": "^1.
|
|
108
|
-
"@earendil-works/pi-ai": "^1.
|
|
109
|
-
"@earendil-works/pi-coding-agent": "^1.
|
|
110
|
-
"@earendil-works/pi-durable": "^1.
|
|
111
|
-
"@earendil-works/pi-tui": "^1.
|
|
112
|
-
"@types/node": "^26.
|
|
113
|
-
"esbuild": "^0.28.
|
|
100
|
+
"@biomejs/biome": "^2.6.10",
|
|
101
|
+
"@earendil-works/chord": "^1.8.0",
|
|
102
|
+
"@earendil-works/pi-ai": "^1.8.0",
|
|
103
|
+
"@earendil-works/pi-coding-agent": "^1.8.0",
|
|
104
|
+
"@earendil-works/pi-durable": "^1.8.0",
|
|
105
|
+
"@earendil-works/pi-tui": "^1.8.0",
|
|
106
|
+
"@types/node": "^26.6.11",
|
|
107
|
+
"esbuild": "^0.28.2",
|
|
114
108
|
"typescript": "^7.0.2",
|
|
115
|
-
"vitest": "^
|
|
109
|
+
"vitest": "^5.1.2"
|
|
116
110
|
},
|
|
117
111
|
"peerDependencies": {
|
|
118
|
-
"@earendil-works/pi-durable": "^1.
|
|
112
|
+
"@earendil-works/pi-durable": "^1.6.0",
|
|
119
113
|
"@earendil-works/pi-coding-agent": "*",
|
|
120
114
|
"@earendil-works/pi-tui": "*",
|
|
121
115
|
"typebox": "*"
|
package/dist/adapter-44ZBIK47.js
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
trimSnippet
|
|
3
|
-
} from "./chunk-FSTCLBSF.js";
|
|
4
|
-
import {
|
|
5
|
-
omittedContents,
|
|
6
|
-
orderedContents
|
|
7
|
-
} from "./chunk-TYJ6RHKB.js";
|
|
8
|
-
import "./chunk-U4BLULLV.js";
|
|
9
|
-
|
|
10
|
-
// src/providers/tavily/adapter.ts
|
|
11
|
-
import {
|
|
12
|
-
tavily
|
|
13
|
-
} from "@tavily/core";
|
|
14
|
-
var tavilyImplementation = {
|
|
15
|
-
async search(query, maxResults, config, _context, options) {
|
|
16
|
-
const client = createClient(config);
|
|
17
|
-
const response = await client.search(query, {
|
|
18
|
-
...options ?? {},
|
|
19
|
-
maxResults
|
|
20
|
-
});
|
|
21
|
-
return {
|
|
22
|
-
provider: "tavily",
|
|
23
|
-
results: response.results.slice(0, maxResults).map((result) => ({
|
|
24
|
-
title: result.title,
|
|
25
|
-
url: result.url || "",
|
|
26
|
-
snippet: trimSnippet(result.content ?? result.rawContent),
|
|
27
|
-
score: typeof result.score === "number" ? result.score : void 0,
|
|
28
|
-
metadata: buildSearchMetadata(response, result)
|
|
29
|
-
}))
|
|
30
|
-
};
|
|
31
|
-
},
|
|
32
|
-
async contents(urls, config, _context, options) {
|
|
33
|
-
const client = createClient(config);
|
|
34
|
-
const response = await client.extract(urls, {
|
|
35
|
-
...options ?? {}
|
|
36
|
-
});
|
|
37
|
-
const resultsByUrl = new Map(
|
|
38
|
-
response.results.map((result) => [result.url, result])
|
|
39
|
-
);
|
|
40
|
-
const failedResultsByUrl = new Map(
|
|
41
|
-
response.failedResults.map((result) => [result.url, result])
|
|
42
|
-
);
|
|
43
|
-
return {
|
|
44
|
-
provider: "tavily",
|
|
45
|
-
answers: urls.map((url) => {
|
|
46
|
-
const result = resultsByUrl.get(url) ?? (urls.length === 1 && response.results.length === 1 ? response.results[0] : void 0);
|
|
47
|
-
if (result) {
|
|
48
|
-
return {
|
|
49
|
-
url: result.url,
|
|
50
|
-
...typeof result.rawContent === "string" ? { content: result.rawContent } : {},
|
|
51
|
-
metadata: buildExtractMetadata(response, result)
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
const failedResult = failedResultsByUrl.get(url) ?? (urls.length === 1 && response.failedResults.length === 1 ? response.failedResults[0] : void 0);
|
|
55
|
-
if (failedResult) {
|
|
56
|
-
return {
|
|
57
|
-
url,
|
|
58
|
-
error: failedResult.error || "Content extraction failed."
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
return omittedContents(url);
|
|
62
|
-
})
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
function createClient(config) {
|
|
67
|
-
const apiKey = config.credentials?.api;
|
|
68
|
-
if (!apiKey) {
|
|
69
|
-
throw new Error("is missing an API key");
|
|
70
|
-
}
|
|
71
|
-
return tavily({
|
|
72
|
-
apiKey,
|
|
73
|
-
apiBaseURL: config.baseUrl
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
function buildSearchMetadata(response, result) {
|
|
77
|
-
const metadata = {
|
|
78
|
-
...response.answer ? { answer: response.answer } : {},
|
|
79
|
-
...response.images?.length ? { images: response.images } : {},
|
|
80
|
-
...result.publishedDate ? { publishedDate: result.publishedDate } : {},
|
|
81
|
-
...result.favicon ? { favicon: result.favicon } : {},
|
|
82
|
-
...result.rawContent ? { rawContent: result.rawContent } : {},
|
|
83
|
-
...response.requestId ? { requestId: response.requestId } : {},
|
|
84
|
-
...typeof response.responseTime === "number" ? { responseTime: response.responseTime } : {}
|
|
85
|
-
};
|
|
86
|
-
return Object.keys(metadata).length > 0 ? metadata : void 0;
|
|
87
|
-
}
|
|
88
|
-
function buildExtractMetadata(response, result) {
|
|
89
|
-
const metadata = {
|
|
90
|
-
...result.title ? { title: result.title } : {},
|
|
91
|
-
...Array.isArray(result.images) ? { images: result.images } : {},
|
|
92
|
-
...result.favicon ? { favicon: result.favicon } : {},
|
|
93
|
-
...response.requestId ? { requestId: response.requestId } : {},
|
|
94
|
-
...typeof response.responseTime === "number" ? { responseTime: response.responseTime } : {}
|
|
95
|
-
};
|
|
96
|
-
return Object.keys(metadata).length > 0 ? metadata : void 0;
|
|
97
|
-
}
|
|
98
|
-
var adapter = {
|
|
99
|
-
async search(input, config, context) {
|
|
100
|
-
return await tavilyImplementation.search(
|
|
101
|
-
input.query,
|
|
102
|
-
input.maxResults,
|
|
103
|
-
config,
|
|
104
|
-
context,
|
|
105
|
-
input.options
|
|
106
|
-
);
|
|
107
|
-
},
|
|
108
|
-
async contents(input, config, context) {
|
|
109
|
-
return orderedContents(
|
|
110
|
-
await tavilyImplementation.contents(
|
|
111
|
-
input.urls,
|
|
112
|
-
config,
|
|
113
|
-
context,
|
|
114
|
-
input.options
|
|
115
|
-
)
|
|
116
|
-
);
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
export {
|
|
120
|
-
adapter
|
|
121
|
-
};
|
package/dist/adapter-57MELLYI.js
DELETED
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
normalizeContentText,
|
|
3
|
-
trimSnippet
|
|
4
|
-
} from "./chunk-FSTCLBSF.js";
|
|
5
|
-
import {
|
|
6
|
-
orderedContents
|
|
7
|
-
} from "./chunk-TYJ6RHKB.js";
|
|
8
|
-
import {
|
|
9
|
-
asWebfoxError,
|
|
10
|
-
httpError
|
|
11
|
-
} from "./chunk-U4BLULLV.js";
|
|
12
|
-
|
|
13
|
-
// src/providers/ollama/adapter.ts
|
|
14
|
-
var DEFAULT_BASE_URL = "https://ollama.com";
|
|
15
|
-
var WEB_SEARCH_PATH = "/api/web_search";
|
|
16
|
-
var WEB_FETCH_PATH = "/api/web_fetch";
|
|
17
|
-
async function searchOllama(query, maxResults, config, context) {
|
|
18
|
-
const apiKey = resolveApiKey(config);
|
|
19
|
-
const response = await fetch(
|
|
20
|
-
resolveEndpoint(config.baseUrl, WEB_SEARCH_PATH),
|
|
21
|
-
{
|
|
22
|
-
method: "POST",
|
|
23
|
-
headers: buildHeaders(apiKey),
|
|
24
|
-
body: JSON.stringify({
|
|
25
|
-
query,
|
|
26
|
-
max_results: clampMaxResults(maxResults)
|
|
27
|
-
}),
|
|
28
|
-
signal: context.signal
|
|
29
|
-
}
|
|
30
|
-
);
|
|
31
|
-
if (!response.ok) {
|
|
32
|
-
throw httpError(response, await buildHttpError(response));
|
|
33
|
-
}
|
|
34
|
-
const data = await response.json();
|
|
35
|
-
const results = Array.isArray(data.results) ? data.results : [];
|
|
36
|
-
return {
|
|
37
|
-
provider: "ollama",
|
|
38
|
-
results: results.slice(0, clampMaxResults(maxResults)).map((result) => ({
|
|
39
|
-
title: result.title,
|
|
40
|
-
url: result.url ?? "",
|
|
41
|
-
snippet: trimSnippet(result.content)
|
|
42
|
-
}))
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
async function fetchOllamaContents(urls, config, context) {
|
|
46
|
-
const apiKey = resolveApiKey(config);
|
|
47
|
-
const endpoint = resolveEndpoint(config.baseUrl, WEB_FETCH_PATH);
|
|
48
|
-
return {
|
|
49
|
-
provider: "ollama",
|
|
50
|
-
answers: await Promise.all(
|
|
51
|
-
urls.map(async (url) => {
|
|
52
|
-
try {
|
|
53
|
-
const response = await fetch(endpoint, {
|
|
54
|
-
method: "POST",
|
|
55
|
-
headers: buildHeaders(apiKey),
|
|
56
|
-
body: JSON.stringify({
|
|
57
|
-
url
|
|
58
|
-
}),
|
|
59
|
-
signal: context.signal
|
|
60
|
-
});
|
|
61
|
-
if (!response.ok) {
|
|
62
|
-
return {
|
|
63
|
-
url,
|
|
64
|
-
error: httpError(
|
|
65
|
-
response,
|
|
66
|
-
await buildHttpError(response)
|
|
67
|
-
).toJSON()
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
const data = await response.json();
|
|
71
|
-
const content = normalizeContentText(data.content);
|
|
72
|
-
const metadata = buildFetchMetadata(data);
|
|
73
|
-
return {
|
|
74
|
-
url,
|
|
75
|
-
content,
|
|
76
|
-
...metadata ? { metadata } : {}
|
|
77
|
-
};
|
|
78
|
-
} catch (error) {
|
|
79
|
-
return {
|
|
80
|
-
url,
|
|
81
|
-
error: asWebfoxError(error).toJSON()
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
})
|
|
85
|
-
)
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
function resolveApiKey(config) {
|
|
89
|
-
const apiKey = config.credentials?.api;
|
|
90
|
-
if (!apiKey) {
|
|
91
|
-
throw new Error("is missing an API key");
|
|
92
|
-
}
|
|
93
|
-
return apiKey;
|
|
94
|
-
}
|
|
95
|
-
function buildHeaders(apiKey) {
|
|
96
|
-
return {
|
|
97
|
-
authorization: `Bearer ${apiKey}`,
|
|
98
|
-
"content-type": "application/json"
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
function resolveEndpoint(baseUrlReference, endpointPath) {
|
|
102
|
-
const baseUrl = baseUrlReference ?? DEFAULT_BASE_URL;
|
|
103
|
-
const base = baseUrl.replace(/\/+$/, "");
|
|
104
|
-
const apiPath = endpointPath.replace(/^\/api\//, "");
|
|
105
|
-
if (base.endsWith(endpointPath)) {
|
|
106
|
-
return base;
|
|
107
|
-
}
|
|
108
|
-
if (base.endsWith("/api")) {
|
|
109
|
-
return `${base}/${apiPath}`;
|
|
110
|
-
}
|
|
111
|
-
return `${base}${endpointPath}`;
|
|
112
|
-
}
|
|
113
|
-
function clampMaxResults(value) {
|
|
114
|
-
return Math.max(1, Math.min(10, Math.trunc(value || 0)));
|
|
115
|
-
}
|
|
116
|
-
async function buildHttpError(response) {
|
|
117
|
-
const detail = await readErrorDetail(response);
|
|
118
|
-
const status = `${response.status}${response.statusText ? ` ${response.statusText}` : ""}`;
|
|
119
|
-
return detail ? `Ollama API request failed (${status}): ${detail}` : `Ollama API request failed (${status}).`;
|
|
120
|
-
}
|
|
121
|
-
async function readErrorDetail(response) {
|
|
122
|
-
const text = (await response.text()).trim();
|
|
123
|
-
if (!text) {
|
|
124
|
-
return void 0;
|
|
125
|
-
}
|
|
126
|
-
try {
|
|
127
|
-
const parsed = JSON.parse(text);
|
|
128
|
-
for (const key of ["message", "error", "detail"]) {
|
|
129
|
-
if (typeof parsed[key] === "string" && parsed[key].trim()) {
|
|
130
|
-
return parsed[key];
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
return JSON.stringify(parsed);
|
|
134
|
-
} catch {
|
|
135
|
-
return text;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
function buildFetchMetadata(data) {
|
|
139
|
-
const metadata = {};
|
|
140
|
-
if (data.title) {
|
|
141
|
-
metadata.title = data.title;
|
|
142
|
-
}
|
|
143
|
-
if (data.links?.length) {
|
|
144
|
-
metadata.links = data.links;
|
|
145
|
-
}
|
|
146
|
-
return Object.keys(metadata).length > 0 ? metadata : void 0;
|
|
147
|
-
}
|
|
148
|
-
var adapter = {
|
|
149
|
-
async search(input, config, context) {
|
|
150
|
-
return await searchOllama(input.query, input.maxResults, config, context);
|
|
151
|
-
},
|
|
152
|
-
async contents(input, config, context) {
|
|
153
|
-
return orderedContents(
|
|
154
|
-
await fetchOllamaContents(input.urls, config, context)
|
|
155
|
-
);
|
|
156
|
-
}
|
|
157
|
-
};
|
|
158
|
-
export {
|
|
159
|
-
adapter
|
|
160
|
-
};
|