webfox 0.0.0-test.0 → 4.0.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/LICENSE +21 -0
- package/README.md +256 -3
- package/assets/webfox-lockup-dark.png +0 -0
- package/assets/webfox-lockup.png +0 -0
- package/dist/adapter-2YBFCBCZ.js +161 -0
- package/dist/adapter-67TIISDW.js +753 -0
- package/dist/adapter-AB7LKV7N.js +324 -0
- package/dist/adapter-AUYLTDPM.js +73 -0
- package/dist/adapter-HITGYUXN.js +494 -0
- package/dist/adapter-HPTMLH75.js +334 -0
- package/dist/adapter-I6OUKBZQ.js +492 -0
- package/dist/adapter-ISZQTZDP.js +166 -0
- package/dist/adapter-MAG7X663.js +230 -0
- package/dist/adapter-NEXSOHGT.js +232 -0
- package/dist/adapter-PADXKW43.js +162 -0
- package/dist/adapter-SDQX2533.js +123 -0
- package/dist/adapter-UAZNLDSS.js +237 -0
- package/dist/adapter-XBAQSK7I.js +282 -0
- package/dist/application-types.d.ts +34 -0
- package/dist/application.d.ts +2 -0
- package/dist/chunk-EF4VMDZL.js +85 -0
- package/dist/chunk-G2YAQEET.js +38 -0
- package/dist/chunk-GAWPRXAU.js +3051 -0
- package/dist/chunk-I2UIACY3.js +12 -0
- package/dist/chunk-MVCCEPDF.js +762 -0
- package/dist/chunk-QRHDXM2L.js +31 -0
- package/dist/chunk-U4BLULLV.js +52 -0
- package/dist/chunk-WCTOYZVB.js +85 -0
- package/dist/chunk-X6ZBIHZC.js +21 -0
- package/dist/chunk-YZXM4U2C.js +21 -0
- package/dist/chunk-ZVTVERW5.js +20 -0
- package/dist/cli.js +641 -0
- package/dist/config.schema.json +4270 -0
- package/dist/configuration/defaults.d.ts +3 -0
- package/dist/configuration/file.d.ts +17 -0
- package/dist/configuration/options-schema.d.ts +2 -0
- package/dist/configuration/planning.d.ts +10 -0
- package/dist/configuration/schema.d.ts +9 -0
- package/dist/configuration/types.d.ts +37 -0
- package/dist/contents.d.ts +19 -0
- package/dist/domain.d.ts +89 -0
- package/dist/errors.d.ts +17 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +38 -0
- package/dist/package-metadata.d.ts +3 -0
- package/dist/pi-keybindings.d.ts +1 -0
- package/dist/pi-params.d.ts +3 -0
- package/dist/pi-render.d.ts +50 -0
- package/dist/pi-search-render.d.ts +4 -0
- package/dist/pi-text.d.ts +4 -0
- package/dist/pi-validation.d.ts +4 -0
- package/dist/pi.d.ts +2 -0
- package/dist/pi.js +563 -0
- package/dist/providers/brave/adapter.d.ts +7 -0
- package/dist/providers/brave/definition.d.ts +1 -0
- package/dist/providers/brave/types.d.ts +4 -0
- package/dist/providers/cli-json.d.ts +9 -0
- package/dist/providers/cloudflare/adapter.d.ts +5 -0
- package/dist/providers/cloudflare/definition.d.ts +1 -0
- package/dist/providers/cloudflare/types.d.ts +4 -0
- package/dist/providers/contract.d.ts +88 -0
- package/dist/providers/custom/adapter.d.ts +9 -0
- package/dist/providers/custom/definition.d.ts +1 -0
- package/dist/providers/custom/types.d.ts +9 -0
- package/dist/providers/definition.d.ts +32 -0
- package/dist/providers/exa/adapter.d.ts +8 -0
- package/dist/providers/exa/definition.d.ts +1 -0
- package/dist/providers/exa/types.d.ts +4 -0
- package/dist/providers/firecrawl/adapter.d.ts +7 -0
- package/dist/providers/firecrawl/definition.d.ts +1 -0
- package/dist/providers/firecrawl/types.d.ts +4 -0
- package/dist/providers/gemini/adapter.d.ts +14 -0
- package/dist/providers/gemini/definition.d.ts +1 -0
- package/dist/providers/gemini/types.d.ts +3 -0
- package/dist/providers/linkup/adapter.d.ts +7 -0
- package/dist/providers/linkup/definition.d.ts +1 -0
- package/dist/providers/linkup/types.d.ts +4 -0
- package/dist/providers/metadata.d.ts +15 -0
- package/dist/providers/ollama/adapter.d.ts +6 -0
- package/dist/providers/ollama/definition.d.ts +1 -0
- package/dist/providers/ollama/types.d.ts +4 -0
- package/dist/providers/openai/adapter.d.ts +7 -0
- package/dist/providers/openai/definition.d.ts +1 -0
- package/dist/providers/openai/types.d.ts +28 -0
- package/dist/providers/parallel/adapter.d.ts +6 -0
- package/dist/providers/parallel/definition.d.ts +1 -0
- package/dist/providers/parallel/types.d.ts +4 -0
- package/dist/providers/perplexity/adapter.d.ts +7 -0
- package/dist/providers/perplexity/definition.d.ts +1 -0
- package/dist/providers/perplexity/types.d.ts +4 -0
- package/dist/providers/registry.d.ts +16 -0
- package/dist/providers/serper/adapter.d.ts +5 -0
- package/dist/providers/serper/definition.d.ts +1 -0
- package/dist/providers/serper/types.d.ts +21 -0
- package/dist/providers/shared.d.ts +4 -0
- package/dist/providers/tavily/adapter.d.ts +6 -0
- package/dist/providers/tavily/definition.d.ts +1 -0
- package/dist/providers/tavily/types.d.ts +4 -0
- package/dist/providers/valyu/adapter.d.ts +8 -0
- package/dist/providers/valyu/definition.d.ts +1 -0
- package/dist/providers/valyu/types.d.ts +4 -0
- package/dist/render.d.ts +5 -0
- package/dist/runtime/credentials.d.ts +15 -0
- package/dist/runtime/duration.d.ts +2 -0
- package/dist/runtime/execute.d.ts +20 -0
- package/dist/runtime/lifecycle.d.ts +8 -0
- package/dist/runtime/outward.d.ts +11 -0
- package/dist/runtime/polling.d.ts +13 -0
- package/dist/runtime/process.d.ts +4 -0
- package/docs/cli-experience.md +177 -0
- package/docs/provider.md +177 -0
- package/docs/reference.md +181 -0
- package/example-config.yaml +36 -0
- package/examples/custom/README.md +57 -0
- package/examples/custom/provider.mjs +54 -0
- package/examples/custom/webfox.json +18 -0
- package/package.json +122 -8
- package/index.js +0 -2
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
import {
|
|
2
|
+
executeAsyncResearch
|
|
3
|
+
} from "./chunk-EF4VMDZL.js";
|
|
4
|
+
import "./chunk-I2UIACY3.js";
|
|
5
|
+
import "./chunk-WCTOYZVB.js";
|
|
6
|
+
import {
|
|
7
|
+
formatJson,
|
|
8
|
+
trimSnippet
|
|
9
|
+
} from "./chunk-X6ZBIHZC.js";
|
|
10
|
+
import {
|
|
11
|
+
orderedContents
|
|
12
|
+
} from "./chunk-YZXM4U2C.js";
|
|
13
|
+
import {
|
|
14
|
+
asWebfoxError
|
|
15
|
+
} from "./chunk-U4BLULLV.js";
|
|
16
|
+
|
|
17
|
+
// src/providers/linkup/adapter.ts
|
|
18
|
+
import {
|
|
19
|
+
LinkupClient
|
|
20
|
+
} from "linkup-sdk";
|
|
21
|
+
var linkupImplementation = {
|
|
22
|
+
async search(query, maxResults, config, _context, options) {
|
|
23
|
+
const client = createClient(config);
|
|
24
|
+
const response = await client.search(
|
|
25
|
+
buildSearchParams(query, maxResults, {
|
|
26
|
+
...options ?? {}
|
|
27
|
+
})
|
|
28
|
+
);
|
|
29
|
+
return {
|
|
30
|
+
provider: "linkup",
|
|
31
|
+
results: (response.results ?? []).map(toSearchResult).filter((result) => result !== null).slice(0, maxResults)
|
|
32
|
+
};
|
|
33
|
+
},
|
|
34
|
+
async contents(urls, config, _context, options) {
|
|
35
|
+
const client = createClient(config);
|
|
36
|
+
return {
|
|
37
|
+
provider: "linkup",
|
|
38
|
+
answers: await Promise.all(
|
|
39
|
+
urls.map(async (url) => {
|
|
40
|
+
try {
|
|
41
|
+
const response = await client.fetch(
|
|
42
|
+
buildFetchParams(url, {
|
|
43
|
+
...options ?? {}
|
|
44
|
+
})
|
|
45
|
+
);
|
|
46
|
+
const metadata = Object.fromEntries(
|
|
47
|
+
Object.entries(response).filter(
|
|
48
|
+
([key, value]) => [
|
|
49
|
+
"rawContent",
|
|
50
|
+
"rawHtml",
|
|
51
|
+
"contentType",
|
|
52
|
+
"images",
|
|
53
|
+
"favicon"
|
|
54
|
+
].includes(key) && value !== void 0
|
|
55
|
+
)
|
|
56
|
+
);
|
|
57
|
+
return response.markdown ? {
|
|
58
|
+
url,
|
|
59
|
+
content: response.markdown,
|
|
60
|
+
...Object.keys(metadata).length ? { metadata } : {}
|
|
61
|
+
} : {
|
|
62
|
+
url,
|
|
63
|
+
error: "No content returned for this URL."
|
|
64
|
+
};
|
|
65
|
+
} catch (error) {
|
|
66
|
+
return {
|
|
67
|
+
url,
|
|
68
|
+
error: asWebfoxError(error).toJSON()
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
})
|
|
72
|
+
)
|
|
73
|
+
};
|
|
74
|
+
},
|
|
75
|
+
async research(input, config, context, options) {
|
|
76
|
+
return await executeAsyncResearch({
|
|
77
|
+
providerLabel: "Linkup",
|
|
78
|
+
providerId: "linkup",
|
|
79
|
+
context,
|
|
80
|
+
start: (researchContext) => linkupImplementation.startResearch(
|
|
81
|
+
input,
|
|
82
|
+
config,
|
|
83
|
+
researchContext,
|
|
84
|
+
options
|
|
85
|
+
),
|
|
86
|
+
poll: (id, researchContext) => linkupImplementation.pollResearch(id, config, researchContext)
|
|
87
|
+
});
|
|
88
|
+
},
|
|
89
|
+
async startResearch(input, config, _context, options) {
|
|
90
|
+
const client = createClient(config);
|
|
91
|
+
const task = await client.research(
|
|
92
|
+
buildResearchParams(input, {
|
|
93
|
+
...options ?? {}
|
|
94
|
+
})
|
|
95
|
+
);
|
|
96
|
+
return { id: task.id };
|
|
97
|
+
},
|
|
98
|
+
async pollResearch(id, config, _context) {
|
|
99
|
+
const client = createClient(config);
|
|
100
|
+
const task = await client.getResearch(id);
|
|
101
|
+
if (task.status === "completed") {
|
|
102
|
+
return {
|
|
103
|
+
status: "completed",
|
|
104
|
+
output: formatResearchTaskOutput(task)
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
if (task.status === "failed") {
|
|
108
|
+
return {
|
|
109
|
+
status: "failed",
|
|
110
|
+
error: task.error ?? "research failed"
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
return {
|
|
114
|
+
status: "in_progress",
|
|
115
|
+
statusText: task.status
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
function buildSearchParams(query, maxResults, options) {
|
|
120
|
+
const searchOptions = options;
|
|
121
|
+
if (searchOptions.query !== void 0) {
|
|
122
|
+
throw new Error("Linkup search options cannot override the managed query.");
|
|
123
|
+
}
|
|
124
|
+
if (searchOptions.maxResults !== void 0) {
|
|
125
|
+
throw new Error(
|
|
126
|
+
"Linkup search options cannot override the managed maxResults."
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
if (searchOptions.outputType !== void 0 && searchOptions.outputType !== "searchResults") {
|
|
130
|
+
throw new Error("Linkup search only supports outputType 'searchResults'.");
|
|
131
|
+
}
|
|
132
|
+
if (searchOptions.includeInlineCitations !== void 0 || searchOptions.includeSources !== void 0 || searchOptions.structuredOutputSchema !== void 0) {
|
|
133
|
+
throw new Error(
|
|
134
|
+
"Linkup search only supports search-results mode for managed web_search."
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
return {
|
|
138
|
+
query,
|
|
139
|
+
depth: searchOptions.depth ?? "standard",
|
|
140
|
+
outputType: "searchResults",
|
|
141
|
+
maxResults,
|
|
142
|
+
...searchOptions.includeImages !== void 0 ? { includeImages: searchOptions.includeImages } : {},
|
|
143
|
+
...searchOptions.includeDomains !== void 0 ? { includeDomains: searchOptions.includeDomains } : {},
|
|
144
|
+
...searchOptions.excludeDomains !== void 0 ? { excludeDomains: searchOptions.excludeDomains } : {},
|
|
145
|
+
...searchOptions.fromDate !== void 0 ? { fromDate: toDate(searchOptions.fromDate, "fromDate") } : {},
|
|
146
|
+
...searchOptions.toDate !== void 0 ? { toDate: toDate(searchOptions.toDate, "toDate") } : {}
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
function buildFetchParams(url, options) {
|
|
150
|
+
const fetchOptions = options;
|
|
151
|
+
if (fetchOptions.url !== void 0) {
|
|
152
|
+
throw new Error("Linkup fetch options cannot override the managed URL.");
|
|
153
|
+
}
|
|
154
|
+
return {
|
|
155
|
+
url,
|
|
156
|
+
...fetchOptions.mode !== void 0 ? { mode: fetchOptions.mode } : {},
|
|
157
|
+
...fetchOptions.includeRawContent !== void 0 ? { includeRawContent: fetchOptions.includeRawContent } : {},
|
|
158
|
+
...fetchOptions.renderJs !== void 0 ? { renderJs: fetchOptions.renderJs } : {},
|
|
159
|
+
...fetchOptions.includeRawHtml !== void 0 ? { includeRawHtml: fetchOptions.includeRawHtml } : {},
|
|
160
|
+
...fetchOptions.extractImages !== void 0 ? { extractImages: fetchOptions.extractImages } : {}
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
function buildResearchParams(input, options) {
|
|
164
|
+
const researchOptions = options;
|
|
165
|
+
if (researchOptions.q !== void 0 || researchOptions.query !== void 0 || researchOptions.input !== void 0) {
|
|
166
|
+
throw new Error(
|
|
167
|
+
"Linkup research options cannot override the managed input."
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
const outputType = researchOptions.outputType ?? (researchOptions.structuredOutputSchema !== void 0 ? "structured" : "sourcedAnswer");
|
|
171
|
+
if (outputType === "structured" && researchOptions.structuredOutputSchema === void 0) {
|
|
172
|
+
throw new Error(
|
|
173
|
+
"Linkup research outputType 'structured' requires structuredOutputSchema."
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
if (outputType === "sourcedAnswer" && researchOptions.structuredOutputSchema !== void 0) {
|
|
177
|
+
throw new Error(
|
|
178
|
+
"Linkup research structuredOutputSchema requires outputType 'structured'."
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
const commonParams = {
|
|
182
|
+
query: input,
|
|
183
|
+
...researchOptions.includeDomains !== void 0 ? { includeDomains: researchOptions.includeDomains } : {},
|
|
184
|
+
...researchOptions.excludeDomains !== void 0 ? { excludeDomains: researchOptions.excludeDomains } : {},
|
|
185
|
+
...researchOptions.fromDate !== void 0 ? { fromDate: toDate(researchOptions.fromDate, "fromDate") } : {},
|
|
186
|
+
...researchOptions.toDate !== void 0 ? { toDate: toDate(researchOptions.toDate, "toDate") } : {},
|
|
187
|
+
...researchOptions.mode !== void 0 ? { mode: researchOptions.mode } : {},
|
|
188
|
+
...researchOptions.reasoningDepth !== void 0 ? { reasoningDepth: researchOptions.reasoningDepth } : {}
|
|
189
|
+
};
|
|
190
|
+
if (outputType === "structured") {
|
|
191
|
+
return {
|
|
192
|
+
...commonParams,
|
|
193
|
+
outputType,
|
|
194
|
+
structuredOutputSchema: researchOptions.structuredOutputSchema
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
return {
|
|
198
|
+
...commonParams,
|
|
199
|
+
outputType
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
function createClient(config) {
|
|
203
|
+
const apiKey = config.credentials?.api;
|
|
204
|
+
if (!apiKey) {
|
|
205
|
+
throw new Error("is missing an API key");
|
|
206
|
+
}
|
|
207
|
+
return new LinkupClient({
|
|
208
|
+
apiKey,
|
|
209
|
+
baseUrl: config.baseUrl
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
function formatResearchTaskOutput(task) {
|
|
213
|
+
const output = task.output;
|
|
214
|
+
if (!output) {
|
|
215
|
+
return {
|
|
216
|
+
provider: "linkup",
|
|
217
|
+
text: "Linkup research completed without textual output."
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
const outputRecord = asRecord(output);
|
|
221
|
+
const inputRecord = asRecord(task.input);
|
|
222
|
+
const outputType = inputRecord ? readString(inputRecord.outputType) : void 0;
|
|
223
|
+
const answer = outputRecord ? readString(outputRecord.answer) : void 0;
|
|
224
|
+
const sources = outputRecord ? readSources(outputRecord.sources) : [];
|
|
225
|
+
if (outputType !== "structured" && answer !== void 0) {
|
|
226
|
+
const lines = [answer];
|
|
227
|
+
if (sources.length > 0) {
|
|
228
|
+
lines.push("");
|
|
229
|
+
lines.push("Sources:");
|
|
230
|
+
for (const [index, source] of sources.entries()) {
|
|
231
|
+
lines.push(`${index + 1}. ${source.title}`);
|
|
232
|
+
lines.push(` ${source.url}`);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
return {
|
|
236
|
+
provider: "linkup",
|
|
237
|
+
text: lines.join("\n").trimEnd(),
|
|
238
|
+
itemCount: sources.length
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
return {
|
|
242
|
+
provider: "linkup",
|
|
243
|
+
text: formatJson(output)
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
function toSearchResult(value) {
|
|
247
|
+
const entry = asRecord(value);
|
|
248
|
+
if (!entry) {
|
|
249
|
+
return null;
|
|
250
|
+
}
|
|
251
|
+
const url = readString(entry.url) ?? "";
|
|
252
|
+
const title = readString(entry.name) ?? (url || "Untitled");
|
|
253
|
+
const type = readString(entry.type);
|
|
254
|
+
const favicon = readString(entry.favicon);
|
|
255
|
+
const snippet = type === "text" ? trimSnippet(readString(entry.content) ?? "") : "";
|
|
256
|
+
const metadata = {
|
|
257
|
+
...type ? { type } : {},
|
|
258
|
+
...favicon ? { favicon } : {}
|
|
259
|
+
};
|
|
260
|
+
return {
|
|
261
|
+
title,
|
|
262
|
+
url,
|
|
263
|
+
snippet,
|
|
264
|
+
metadata: Object.keys(metadata).length > 0 ? metadata : void 0
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
function readSources(value) {
|
|
268
|
+
if (!Array.isArray(value)) {
|
|
269
|
+
return [];
|
|
270
|
+
}
|
|
271
|
+
return value.flatMap((entry) => {
|
|
272
|
+
const source = asRecord(entry);
|
|
273
|
+
if (!source) {
|
|
274
|
+
return [];
|
|
275
|
+
}
|
|
276
|
+
const url = readString(source.url);
|
|
277
|
+
if (!url) {
|
|
278
|
+
return [];
|
|
279
|
+
}
|
|
280
|
+
return [
|
|
281
|
+
{
|
|
282
|
+
title: readString(source.name) ?? url,
|
|
283
|
+
url
|
|
284
|
+
}
|
|
285
|
+
];
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
function asRecord(value) {
|
|
289
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
290
|
+
}
|
|
291
|
+
function readString(value) {
|
|
292
|
+
return typeof value === "string" ? value : void 0;
|
|
293
|
+
}
|
|
294
|
+
function toDate(value, name) {
|
|
295
|
+
const date = value instanceof Date ? value : new Date(value);
|
|
296
|
+
if (Number.isNaN(date.getTime())) {
|
|
297
|
+
throw new Error(
|
|
298
|
+
`Linkup option '${name}' must be a valid date string, timestamp, or Date.`
|
|
299
|
+
);
|
|
300
|
+
}
|
|
301
|
+
return date;
|
|
302
|
+
}
|
|
303
|
+
var adapter = {
|
|
304
|
+
async search(input, config, context) {
|
|
305
|
+
return await linkupImplementation.search(
|
|
306
|
+
input.query,
|
|
307
|
+
input.maxResults,
|
|
308
|
+
config,
|
|
309
|
+
context,
|
|
310
|
+
input.options
|
|
311
|
+
);
|
|
312
|
+
},
|
|
313
|
+
async contents(input, config, context) {
|
|
314
|
+
return orderedContents(
|
|
315
|
+
await linkupImplementation.contents(
|
|
316
|
+
input.urls,
|
|
317
|
+
config,
|
|
318
|
+
context,
|
|
319
|
+
input.options
|
|
320
|
+
)
|
|
321
|
+
);
|
|
322
|
+
},
|
|
323
|
+
async research(input, config, context) {
|
|
324
|
+
return await linkupImplementation.research(
|
|
325
|
+
input.input,
|
|
326
|
+
config,
|
|
327
|
+
context,
|
|
328
|
+
input.options
|
|
329
|
+
);
|
|
330
|
+
}
|
|
331
|
+
};
|
|
332
|
+
export {
|
|
333
|
+
adapter
|
|
334
|
+
};
|