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
package/dist/pi.js
CHANGED
|
@@ -1,25 +1,27 @@
|
|
|
1
1
|
import {
|
|
2
|
+
DOCUMENT_SCHEMAS,
|
|
3
|
+
WEB_NAMESPACE,
|
|
4
|
+
createClientCache,
|
|
2
5
|
descriptions,
|
|
6
|
+
executeCapability,
|
|
7
|
+
formatToolOutput,
|
|
3
8
|
prepareToolArguments,
|
|
4
9
|
webToolParameters
|
|
5
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-V4SQCDI3.js";
|
|
6
11
|
import {
|
|
7
|
-
emptyResultText
|
|
8
|
-
renderTextDocument
|
|
12
|
+
emptyResultText
|
|
9
13
|
} from "./chunk-6RQGO727.js";
|
|
10
14
|
import {
|
|
11
|
-
createWebfox,
|
|
12
15
|
resolveConfigPath
|
|
13
|
-
} from "./chunk-
|
|
14
|
-
import "./chunk-
|
|
15
|
-
import "./chunk-
|
|
16
|
-
import "./chunk-
|
|
16
|
+
} from "./chunk-7NTO6AQX.js";
|
|
17
|
+
import "./chunk-6UC3ZBNK.js";
|
|
18
|
+
import "./chunk-VMIDLDYP.js";
|
|
19
|
+
import "./chunk-EBKQHHCO.js";
|
|
20
|
+
import "./chunk-HZVTFUBC.js";
|
|
17
21
|
import "./chunk-ZVTVERW5.js";
|
|
18
22
|
import {
|
|
19
|
-
CAPABILITIES
|
|
20
|
-
|
|
21
|
-
WEBFOX_ERROR_CODES
|
|
22
|
-
} from "./chunk-NENL6L6N.js";
|
|
23
|
+
CAPABILITIES
|
|
24
|
+
} from "./chunk-46OIVYHW.js";
|
|
23
25
|
import {
|
|
24
26
|
WebfoxError
|
|
25
27
|
} from "./chunk-U4BLULLV.js";
|
|
@@ -28,10 +30,25 @@ import {
|
|
|
28
30
|
import { mkdtemp, writeFile } from "node:fs/promises";
|
|
29
31
|
import { tmpdir } from "node:os";
|
|
30
32
|
import { join as join2 } from "node:path";
|
|
31
|
-
import {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
} from "
|
|
33
|
+
import { withFileMutationQueue } from "@earendil-works/pi-coding-agent";
|
|
34
|
+
|
|
35
|
+
// src/pi-diagnostics.ts
|
|
36
|
+
import { homedir } from "node:os";
|
|
37
|
+
import { sep } from "node:path";
|
|
38
|
+
function configurationDiagnostic(error) {
|
|
39
|
+
const diagnostic = error.options.configuration;
|
|
40
|
+
const source = diagnostic?.source ?? resolveConfigPath();
|
|
41
|
+
const home = homedir() + sep;
|
|
42
|
+
const path = source.startsWith(home) ? `~/${source.slice(home.length)}` : source;
|
|
43
|
+
const issues = diagnostic?.issues ?? [error.message];
|
|
44
|
+
return [
|
|
45
|
+
"Webfox disabled \u2014 invalid configuration",
|
|
46
|
+
` ${path}`,
|
|
47
|
+
...issues.map((issue) => ` ${issue}`),
|
|
48
|
+
"",
|
|
49
|
+
"Fix the configuration, then /reload."
|
|
50
|
+
].join("\n");
|
|
51
|
+
}
|
|
35
52
|
|
|
36
53
|
// src/pi-render.ts
|
|
37
54
|
import { stripVTControlCharacters as stripVTControlCharacters3 } from "node:util";
|
|
@@ -193,11 +210,11 @@ function link(url, theme) {
|
|
|
193
210
|
return label;
|
|
194
211
|
}
|
|
195
212
|
function renderSearchResult(details, fallback, theme) {
|
|
196
|
-
const
|
|
213
|
+
const document = isRecord2(details) && searchDocument(details.result) ? details.result : void 0;
|
|
197
214
|
return {
|
|
198
215
|
render(width) {
|
|
199
216
|
if (width <= 0) return [];
|
|
200
|
-
if (!
|
|
217
|
+
if (!document) {
|
|
201
218
|
const text = plainText(fallback).split("\n").map((line) => {
|
|
202
219
|
const urlLine = /^(\s*)(https?:\/\/\S+)(\s*)$/.exec(line);
|
|
203
220
|
return urlLine ? urlLine[1] + link(urlLine[2], theme) + urlLine[3] : theme.fg("toolOutput", line);
|
|
@@ -216,9 +233,9 @@ function renderSearchResult(details, fallback, theme) {
|
|
|
216
233
|
)
|
|
217
234
|
);
|
|
218
235
|
};
|
|
219
|
-
|
|
236
|
+
document.results.forEach((entry, index) => {
|
|
220
237
|
if (index) lines.push("");
|
|
221
|
-
if (
|
|
238
|
+
if (document.results.length > 1) {
|
|
222
239
|
append(
|
|
223
240
|
theme.fg(
|
|
224
241
|
"mdHeading",
|
|
@@ -289,10 +306,12 @@ var WebCall = class {
|
|
|
289
306
|
args = {};
|
|
290
307
|
theme;
|
|
291
308
|
expanded = false;
|
|
292
|
-
|
|
309
|
+
keyText;
|
|
310
|
+
update(args, theme, expanded, keyText2) {
|
|
293
311
|
this.args = args && typeof args === "object" ? args : {};
|
|
294
312
|
this.theme = theme;
|
|
295
313
|
this.expanded = expanded;
|
|
314
|
+
this.keyText = keyText2;
|
|
296
315
|
}
|
|
297
316
|
render(width) {
|
|
298
317
|
if (width <= 0) return [];
|
|
@@ -303,7 +322,7 @@ var WebCall = class {
|
|
|
303
322
|
if (parameters) text += theme.fg("dim", ` ${parameters}`);
|
|
304
323
|
if (this.expanded)
|
|
305
324
|
return visibleWidth2(text) <= width ? [text] : new Text2(text, 0, 0).render(width).map((line) => truncateLine(line, width));
|
|
306
|
-
const key = expansionKey();
|
|
325
|
+
const key = this.keyText ? this.keyText("app.tools.expand") : expansionKey();
|
|
307
326
|
const hint = key ? theme.fg("muted", " (") + theme.fg("dim", key) + theme.fg("muted", " to expand)") : "";
|
|
308
327
|
if (width >= visibleWidth2(title) + visibleWidth2(hint) + 3)
|
|
309
328
|
return [truncateLine(text, width - visibleWidth2(hint)) + hint];
|
|
@@ -315,8 +334,8 @@ var WebCall = class {
|
|
|
315
334
|
};
|
|
316
335
|
function renderWebResult(result, options, theme, isError, capability) {
|
|
317
336
|
const text = result.content.filter((part) => part.type === "text").map((part) => part.text ?? "").join("\n");
|
|
318
|
-
const
|
|
319
|
-
const isSearch = (capability ??
|
|
337
|
+
const metadata = result.details;
|
|
338
|
+
const isSearch = (capability ?? metadata?.capability ?? metadata?.result?.capability) === "search";
|
|
320
339
|
const body = () => isSearch ? renderSearchResult(result.details, text, theme) : new Markdown(text, 0, 0, getMarkdownTheme());
|
|
321
340
|
const rows = statusRows(result.details);
|
|
322
341
|
if (rows?.length) {
|
|
@@ -351,128 +370,9 @@ function renderWebResult(result, options, theme, isError, capability) {
|
|
|
351
370
|
};
|
|
352
371
|
}
|
|
353
372
|
|
|
354
|
-
// src/pi-diagnostics.ts
|
|
355
|
-
import { homedir } from "node:os";
|
|
356
|
-
import { sep } from "node:path";
|
|
357
|
-
function configurationDiagnostic(error) {
|
|
358
|
-
const diagnostic = error.options.configuration;
|
|
359
|
-
const source = diagnostic?.source ?? resolveConfigPath();
|
|
360
|
-
const home = homedir() + sep;
|
|
361
|
-
const path = source.startsWith(home) ? `~/${source.slice(home.length)}` : source;
|
|
362
|
-
const issues = diagnostic?.issues ?? [error.message];
|
|
363
|
-
return [
|
|
364
|
-
"Webfox disabled \u2014 invalid configuration",
|
|
365
|
-
` ${path}`,
|
|
366
|
-
...issues.map((issue) => ` ${issue}`),
|
|
367
|
-
"",
|
|
368
|
-
"Fix the configuration, then /reload."
|
|
369
|
-
].join("\n");
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
// src/document-schema.ts
|
|
373
|
-
import { Type } from "typebox";
|
|
374
|
-
var closed = { additionalProperties: false };
|
|
375
|
-
var metadata = Type.Record(Type.String(), Type.Unknown(), {
|
|
376
|
-
description: "Provider-specific fields."
|
|
377
|
-
});
|
|
378
|
-
var searchResult = Type.Object(
|
|
379
|
-
{
|
|
380
|
-
title: Type.Optional(Type.String({ minLength: 1 })),
|
|
381
|
-
url: Type.String(),
|
|
382
|
-
snippet: Type.String(),
|
|
383
|
-
score: Type.Optional(Type.Number()),
|
|
384
|
-
metadata: Type.Optional(metadata)
|
|
385
|
-
},
|
|
386
|
-
closed
|
|
387
|
-
);
|
|
388
|
-
var contentsAnswer = Type.Object(
|
|
389
|
-
{
|
|
390
|
-
url: Type.String({ description: "Final URL after redirects." }),
|
|
391
|
-
content: Type.Optional(Type.String()),
|
|
392
|
-
summary: Type.Optional(Type.Unknown()),
|
|
393
|
-
metadata: Type.Optional(metadata)
|
|
394
|
-
},
|
|
395
|
-
closed
|
|
396
|
-
);
|
|
397
|
-
var textAnswer = Type.Object(
|
|
398
|
-
{
|
|
399
|
-
text: Type.String(),
|
|
400
|
-
sources: Type.Optional(
|
|
401
|
-
Type.Array(
|
|
402
|
-
Type.Union([
|
|
403
|
-
Type.Object(
|
|
404
|
-
{
|
|
405
|
-
url: Type.String({ minLength: 1 }),
|
|
406
|
-
title: Type.Optional(Type.String({ minLength: 1 }))
|
|
407
|
-
},
|
|
408
|
-
closed
|
|
409
|
-
),
|
|
410
|
-
Type.Object({ title: Type.String({ minLength: 1 }) }, closed)
|
|
411
|
-
])
|
|
412
|
-
)
|
|
413
|
-
),
|
|
414
|
-
itemCount: Type.Optional(Type.Integer()),
|
|
415
|
-
metadata: Type.Optional(metadata)
|
|
416
|
-
},
|
|
417
|
-
closed
|
|
418
|
-
);
|
|
419
|
-
var serializedError = Type.Object(
|
|
420
|
-
{
|
|
421
|
-
code: Type.Enum(WEBFOX_ERROR_CODES),
|
|
422
|
-
message: Type.String(),
|
|
423
|
-
retryable: Type.Optional(Type.Boolean())
|
|
424
|
-
},
|
|
425
|
-
closed
|
|
426
|
-
);
|
|
427
|
-
function inputResult(value) {
|
|
428
|
-
const input = Type.String({
|
|
429
|
-
description: "The query, URL, or brief this entry answers."
|
|
430
|
-
});
|
|
431
|
-
return Type.Union([
|
|
432
|
-
Type.Object({ input, ok: Type.Literal(true), value }, closed),
|
|
433
|
-
Type.Object(
|
|
434
|
-
{ input, ok: Type.Literal(false), error: serializedError },
|
|
435
|
-
closed
|
|
436
|
-
)
|
|
437
|
-
]);
|
|
438
|
-
}
|
|
439
|
-
function document(capability, value) {
|
|
440
|
-
return Type.Object(
|
|
441
|
-
{
|
|
442
|
-
schemaVersion: Type.Literal(1),
|
|
443
|
-
capability: Type.Literal(capability),
|
|
444
|
-
provider: Type.Enum(PROVIDER_IDS),
|
|
445
|
-
status: Type.Enum(["ok", "partial"], {
|
|
446
|
-
description: "`partial` when at least one input failed."
|
|
447
|
-
}),
|
|
448
|
-
results: Type.Array(inputResult(value), {
|
|
449
|
-
description: "One entry per input, in input order."
|
|
450
|
-
})
|
|
451
|
-
},
|
|
452
|
-
closed
|
|
453
|
-
);
|
|
454
|
-
}
|
|
455
|
-
var DOCUMENT_SCHEMAS = {
|
|
456
|
-
search: document(
|
|
457
|
-
"search",
|
|
458
|
-
Type.Object({ results: Type.Array(searchResult) }, closed)
|
|
459
|
-
),
|
|
460
|
-
contents: document("contents", contentsAnswer),
|
|
461
|
-
answer: document("answer", textAnswer),
|
|
462
|
-
research: document("research", textAnswer)
|
|
463
|
-
};
|
|
464
|
-
|
|
465
373
|
// src/pi.ts
|
|
466
374
|
function webExtension(pi) {
|
|
467
|
-
const
|
|
468
|
-
const clientFor = (cwd) => {
|
|
469
|
-
let client = clients.get(cwd);
|
|
470
|
-
if (!client) {
|
|
471
|
-
client = createWebfox({ cwd });
|
|
472
|
-
clients.set(cwd, client);
|
|
473
|
-
}
|
|
474
|
-
return client;
|
|
475
|
-
};
|
|
375
|
+
const clientFor = createClientCache();
|
|
476
376
|
let selected;
|
|
477
377
|
try {
|
|
478
378
|
const initial = clientFor(process.cwd());
|
|
@@ -505,10 +405,7 @@ function webExtension(pi) {
|
|
|
505
405
|
const parameters = webToolParameters(inspection);
|
|
506
406
|
pi.registerTool({
|
|
507
407
|
name: `web_${capability}`,
|
|
508
|
-
namespace: {
|
|
509
|
-
name: "web",
|
|
510
|
-
description: "Search, extract pages, answer, and research the web."
|
|
511
|
-
},
|
|
408
|
+
namespace: { ...WEB_NAMESPACE },
|
|
512
409
|
label: `Web ${capability[0].toUpperCase()}${capability.slice(1)}`,
|
|
513
410
|
// Keep provider guidance with the tool schema, including with custom system prompts.
|
|
514
411
|
description: [
|
|
@@ -528,7 +425,12 @@ function webExtension(pi) {
|
|
|
528
425
|
},
|
|
529
426
|
renderCall(args, theme, context) {
|
|
530
427
|
const call = context.lastComponent instanceof WebCall ? context.lastComponent : new WebCall(capability);
|
|
531
|
-
call.update(
|
|
428
|
+
call.update(
|
|
429
|
+
args,
|
|
430
|
+
theme,
|
|
431
|
+
context.expanded,
|
|
432
|
+
typeof context.keyText === "function" ? (keybinding) => context.keyText(keybinding) : void 0
|
|
433
|
+
);
|
|
532
434
|
return call;
|
|
533
435
|
},
|
|
534
436
|
renderResult(result, options, theme, context) {
|
|
@@ -544,50 +446,44 @@ function webExtension(pi) {
|
|
|
544
446
|
const params = values;
|
|
545
447
|
const client = clientFor(ctx.cwd);
|
|
546
448
|
const inputStatuses = [];
|
|
547
|
-
const
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
inputStatuses[event.inputIndex] = {
|
|
554
|
-
input: event.input,
|
|
555
|
-
state: event.state
|
|
556
|
-
};
|
|
557
|
-
}
|
|
558
|
-
onUpdate?.({
|
|
559
|
-
content: [{ type: "text", text: event.message }],
|
|
560
|
-
details: {
|
|
561
|
-
webInputStatus: true,
|
|
562
|
-
capability,
|
|
563
|
-
inputs: inputStatuses.filter(Boolean).map((row) => ({ ...row }))
|
|
564
|
-
}
|
|
565
|
-
});
|
|
449
|
+
const onProgress = (event) => {
|
|
450
|
+
if (event.inputIndex !== void 0 && event.input !== void 0 && event.state) {
|
|
451
|
+
inputStatuses[event.inputIndex] = {
|
|
452
|
+
input: event.input,
|
|
453
|
+
state: event.state
|
|
454
|
+
};
|
|
566
455
|
}
|
|
456
|
+
onUpdate?.({
|
|
457
|
+
content: [{ type: "text", text: event.message }],
|
|
458
|
+
details: {
|
|
459
|
+
webInputStatus: true,
|
|
460
|
+
capability,
|
|
461
|
+
inputs: inputStatuses.filter(Boolean).map((row) => ({ ...row }))
|
|
462
|
+
}
|
|
463
|
+
});
|
|
567
464
|
};
|
|
568
|
-
const result =
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
}
|
|
465
|
+
const result = await executeCapability(
|
|
466
|
+
client,
|
|
467
|
+
capability,
|
|
468
|
+
provider,
|
|
469
|
+
params,
|
|
470
|
+
signal ?? ctx.signal,
|
|
471
|
+
onProgress
|
|
472
|
+
);
|
|
473
|
+
const { body, json, fullOutputPath } = await formatToolOutput(
|
|
474
|
+
result,
|
|
475
|
+
async (serialized) => {
|
|
476
|
+
const path = join2(
|
|
477
|
+
await mkdtemp(join2(tmpdir(), "web-")),
|
|
478
|
+
"result.json"
|
|
479
|
+
);
|
|
480
|
+
await withFileMutationQueue(
|
|
481
|
+
path,
|
|
482
|
+
() => writeFile(path, serialized, { mode: 384 })
|
|
483
|
+
);
|
|
484
|
+
return { path };
|
|
485
|
+
}
|
|
486
|
+
);
|
|
591
487
|
return {
|
|
592
488
|
content: [{ type: "text", text: body }],
|
|
593
489
|
// Pi keeps this out of the model's context and the session, so the
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type { ProviderContext, SearchResponse, ToolOutput } from "../contract.js";
|
|
2
|
-
import type { Brave } from "./types.js";
|
|
1
|
+
import type { HttpProvider as Brave, ProviderContext, ProviderRequest, SearchResponse, ToolOutput } from "../contract.js";
|
|
3
2
|
export declare const adapter: {
|
|
4
|
-
search(
|
|
5
|
-
answer(
|
|
6
|
-
research(
|
|
3
|
+
search(request: ProviderRequest<"search">, config: Brave, context: ProviderContext): Promise<SearchResponse>;
|
|
4
|
+
answer(request: ProviderRequest<"answer">, config: Brave, context: ProviderContext): Promise<ToolOutput>;
|
|
5
|
+
research(request: ProviderRequest<"research">, config: Brave, context: ProviderContext): Promise<ToolOutput>;
|
|
7
6
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ContentsAnswer } from "../../domain.js";
|
|
2
|
+
import type { ProviderContext, ProviderRequest } from "../contract.js";
|
|
2
3
|
import type { Cloudflare } from "./types.js";
|
|
3
4
|
export declare const adapter: {
|
|
4
|
-
contents(
|
|
5
|
+
contents(request: ProviderRequest<"contents">, config: Cloudflare, context: ProviderContext): Promise<ContentsAnswer>;
|
|
5
6
|
};
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import type { Capability as Tool, ProviderId, SearchResult } from "../domain.js";
|
|
2
|
-
import type { IndexedContentsResponse } from "../contents.js";
|
|
1
|
+
import type { Capability as Tool, ContentsAnswer, ProviderId, SearchResult } from "../domain.js";
|
|
3
2
|
export interface SearchResponse {
|
|
4
|
-
provider: ProviderId;
|
|
5
3
|
results: SearchResult[];
|
|
6
4
|
}
|
|
7
5
|
/** A provider citation; the runtime trims fields and drops blank entries. */
|
|
@@ -14,7 +12,6 @@ export interface SourceInput {
|
|
|
14
12
|
* empty, and its citations as `sources`; presentation belongs to the renderer.
|
|
15
13
|
*/
|
|
16
14
|
export interface ToolOutput {
|
|
17
|
-
provider: ProviderId;
|
|
18
15
|
text: string;
|
|
19
16
|
sources?: SourceInput[];
|
|
20
17
|
metadata?: Record<string, unknown>;
|
|
@@ -47,7 +44,7 @@ export interface SearchRequest {
|
|
|
47
44
|
}
|
|
48
45
|
export interface ContentsRequest {
|
|
49
46
|
capability: "contents";
|
|
50
|
-
|
|
47
|
+
url: string;
|
|
51
48
|
options?: Record<string, unknown>;
|
|
52
49
|
}
|
|
53
50
|
export interface AnswerRequest {
|
|
@@ -69,7 +66,7 @@ export interface ProviderRequestMap {
|
|
|
69
66
|
export type ProviderRequest<TTool extends Tool = Tool> = ProviderRequestMap[TTool];
|
|
70
67
|
export interface ProviderResultMap {
|
|
71
68
|
search: SearchResponse;
|
|
72
|
-
contents:
|
|
69
|
+
contents: ContentsAnswer;
|
|
73
70
|
answer: ToolOutput;
|
|
74
71
|
research: ToolOutput;
|
|
75
72
|
}
|
|
@@ -77,25 +74,29 @@ export type ProviderResult<TTool extends Tool = Tool> = ProviderResultMap[TTool]
|
|
|
77
74
|
export interface Provider {
|
|
78
75
|
credentials?: Record<string, string>;
|
|
79
76
|
}
|
|
77
|
+
export interface HttpProvider extends Provider {
|
|
78
|
+
baseUrl?: string;
|
|
79
|
+
}
|
|
80
80
|
export type { Capability as Tool, ProviderId, SearchResult, } from "../domain.js";
|
|
81
81
|
export interface ProviderConfigMap {
|
|
82
|
-
brave:
|
|
82
|
+
brave: HttpProvider;
|
|
83
83
|
cloudflare: import("./cloudflare/types.js").Cloudflare;
|
|
84
84
|
custom: import("./custom/types.js").Custom;
|
|
85
|
-
exa:
|
|
86
|
-
firecrawl:
|
|
87
|
-
gemini:
|
|
88
|
-
keenable:
|
|
89
|
-
linkup:
|
|
90
|
-
ollama:
|
|
85
|
+
exa: HttpProvider;
|
|
86
|
+
firecrawl: HttpProvider;
|
|
87
|
+
gemini: Provider;
|
|
88
|
+
keenable: HttpProvider;
|
|
89
|
+
linkup: HttpProvider;
|
|
90
|
+
ollama: HttpProvider;
|
|
91
91
|
openai: import("./openai/types.js").OpenAI;
|
|
92
|
-
parallel:
|
|
93
|
-
perplexity:
|
|
92
|
+
parallel: HttpProvider;
|
|
93
|
+
perplexity: HttpProvider;
|
|
94
94
|
serpbase: import("./serpbase/types.js").SerpBase;
|
|
95
95
|
serper: import("./serper/types.js").Serper;
|
|
96
|
-
sofya:
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
96
|
+
sofya: HttpProvider;
|
|
97
|
+
tapline: HttpProvider;
|
|
98
|
+
tavily: HttpProvider;
|
|
99
|
+
valyu: HttpProvider;
|
|
100
|
+
youcom: HttpProvider;
|
|
100
101
|
}
|
|
101
102
|
export type ProviderConfig<T extends ProviderId = ProviderId> = ProviderConfigMap[T];
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ContentsAnswer } from "../../domain.js";
|
|
2
2
|
import type { Custom } from "./types.js";
|
|
3
3
|
import type { ProviderContext, ProviderRequest, SearchResponse, ToolOutput } from "../contract.js";
|
|
4
4
|
export declare const adapter: {
|
|
5
5
|
search(request: ProviderRequest<"search">, config: Custom, context: ProviderContext): Promise<SearchResponse>;
|
|
6
|
-
contents(request: ProviderRequest<"contents">, config: Custom, context: ProviderContext): Promise<
|
|
6
|
+
contents(request: ProviderRequest<"contents">, config: Custom, context: ProviderContext): Promise<ContentsAnswer>;
|
|
7
7
|
answer(request: ProviderRequest<"answer">, config: Custom, context: ProviderContext): Promise<ToolOutput>;
|
|
8
8
|
research(request: ProviderRequest<"research">, config: Custom, context: ProviderContext): Promise<ToolOutput>;
|
|
9
9
|
};
|
|
@@ -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,7 +1,7 @@
|
|
|
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(
|
|
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
7
|
};
|
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
import type { ProviderContext, ResearchJob, ResearchPollResult, ToolOutput } from "../contract.js";
|
|
2
|
-
import type { Gemini } from "./types.js";
|
|
3
|
-
export declare const geminiImplementation: {
|
|
4
|
-
answer(query: string, config: Gemini, context: ProviderContext, options?: Record<string, unknown>): Promise<ToolOutput>;
|
|
5
|
-
research(input: string, config: Gemini, context: ProviderContext, options?: Record<string, unknown>): Promise<ToolOutput>;
|
|
6
|
-
startResearch(input: string, config: Gemini, context: ProviderContext, options?: Record<string, unknown>): Promise<ResearchJob>;
|
|
7
|
-
pollResearch(id: string, config: Gemini, context: ProviderContext, _options?: Record<string, unknown>): Promise<ResearchPollResult>;
|
|
8
|
-
};
|
|
1
|
+
import type { Provider as Gemini, ProviderContext, ProviderRequest, ResearchJob, ResearchPollResult, ToolOutput } from "../contract.js";
|
|
9
2
|
export declare const adapter: {
|
|
10
|
-
answer(
|
|
11
|
-
research(
|
|
3
|
+
answer(request: ProviderRequest<"answer">, config: Gemini, context: ProviderContext): Promise<ToolOutput>;
|
|
4
|
+
research(request: ProviderRequest<"research">, config: Gemini, context: ProviderContext): Promise<ToolOutput>;
|
|
12
5
|
};
|
|
6
|
+
export declare function startResearch(input: string, config: Gemini, context: ProviderContext, options?: Record<string, unknown>): Promise<ResearchJob>;
|
|
7
|
+
export declare function pollResearch(id: string, config: Gemini, context: ProviderContext): Promise<ResearchPollResult>;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { ProviderContext, ProviderRequest, SearchResponse } from "../contract.js";
|
|
2
|
-
import type { Keenable } from "./types.js";
|
|
1
|
+
import type { HttpProvider, ProviderContext, ProviderRequest, SearchResponse } from "../contract.js";
|
|
3
2
|
export declare const adapter: {
|
|
4
|
-
search(request: ProviderRequest<"search">, config:
|
|
3
|
+
search(request: ProviderRequest<"search">, config: HttpProvider, context: ProviderContext): Promise<SearchResponse>;
|
|
5
4
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
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
|
-
research(
|
|
4
|
+
search(request: ProviderRequest<"search">, config: HttpProvider, context: ProviderContext): Promise<SearchResponse>;
|
|
5
|
+
contents(request: ProviderRequest<"contents">, config: HttpProvider, context: ProviderContext): Promise<ContentsAnswer>;
|
|
6
|
+
research(request: ProviderRequest<"research">, config: HttpProvider, context: ProviderContext): Promise<ToolOutput>;
|
|
7
7
|
};
|
|
@@ -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,7 +1,7 @@
|
|
|
1
|
-
import type { ProviderContext, SearchResponse, ToolOutput } from "../contract.js";
|
|
1
|
+
import type { ProviderContext, ProviderRequest, SearchResponse, ToolOutput } from "../contract.js";
|
|
2
2
|
import type { OpenAI as OpenAIConfig } from "./types.js";
|
|
3
3
|
export declare const adapter: {
|
|
4
|
-
search(
|
|
5
|
-
answer(
|
|
6
|
-
research(
|
|
4
|
+
search(request: ProviderRequest<"search">, config: OpenAIConfig, context: ProviderContext): Promise<SearchResponse>;
|
|
5
|
+
answer(request: ProviderRequest<"answer">, config: OpenAIConfig, context: ProviderContext): Promise<ToolOutput>;
|
|
6
|
+
research(request: ProviderRequest<"research">, config: OpenAIConfig, context: ProviderContext): Promise<ToolOutput>;
|
|
7
7
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { HttpProvider } from "../contract.js";
|
|
2
2
|
export interface OpenAIWebSearchToolOptions {
|
|
3
3
|
externalWebAccess?: boolean;
|
|
4
4
|
searchContextSize?: "low" | "medium" | "high";
|
|
@@ -23,6 +23,4 @@ export interface OpenAIResearchOptions extends OpenAIWebSearchToolOptions {
|
|
|
23
23
|
instructions?: string;
|
|
24
24
|
max_tool_calls?: number;
|
|
25
25
|
}
|
|
26
|
-
export
|
|
27
|
-
baseUrl?: string;
|
|
28
|
-
}
|
|
26
|
+
export type OpenAI = HttpProvider;
|
|
@@ -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,7 +1,6 @@
|
|
|
1
|
-
import type { ProviderContext, SearchResponse, ToolOutput } from "../contract.js";
|
|
2
|
-
import type { Perplexity } from "./types.js";
|
|
1
|
+
import type { HttpProvider, ProviderContext, ProviderRequest, SearchResponse, ToolOutput } from "../contract.js";
|
|
3
2
|
export declare const adapter: {
|
|
4
|
-
search(
|
|
5
|
-
answer(
|
|
6
|
-
research(
|
|
3
|
+
search(request: ProviderRequest<"search">, config: HttpProvider, context: ProviderContext): Promise<SearchResponse>;
|
|
4
|
+
answer(request: ProviderRequest<"answer">, config: HttpProvider, context: ProviderContext): Promise<ToolOutput>;
|
|
5
|
+
research(request: ProviderRequest<"research">, config: HttpProvider, context: ProviderContext): Promise<ToolOutput>;
|
|
7
6
|
};
|
|
@@ -14,6 +14,7 @@ export declare const providers: {
|
|
|
14
14
|
readonly serpbase: import("./definition.js").ProviderDefinitionFor<"serpbase">;
|
|
15
15
|
readonly serper: import("./definition.js").ProviderDefinitionFor<"serper">;
|
|
16
16
|
readonly sofya: import("./definition.js").ProviderDefinitionFor<"sofya">;
|
|
17
|
+
readonly tapline: import("./definition.js").ProviderDefinitionFor<"tapline">;
|
|
17
18
|
readonly tavily: import("./definition.js").ProviderDefinitionFor<"tavily">;
|
|
18
19
|
readonly valyu: import("./definition.js").ProviderDefinitionFor<"valyu">;
|
|
19
20
|
readonly youcom: import("./definition.js").ProviderDefinitionFor<"youcom">;
|