@oh-my-pi/pi-coding-agent 15.3.2 → 15.4.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/CHANGELOG.md +104 -0
- package/dist/types/cli/file-processor.d.ts +1 -1
- package/dist/types/config/settings-schema.d.ts +45 -3
- package/dist/types/config/settings.d.ts +1 -1
- package/dist/types/debug/raw-sse.d.ts +2 -0
- package/dist/types/edit/file-read-cache.d.ts +15 -4
- package/dist/types/edit/index.d.ts +3 -8
- package/dist/types/edit/renderer.d.ts +1 -2
- package/dist/types/eval/__tests__/shared-executors.test.d.ts +1 -0
- package/dist/types/eval/js/shared/local-module-loader.d.ts +16 -0
- package/dist/types/eval/js/shared/rewrite-imports.d.ts +4 -0
- package/dist/types/eval/js/shared/runtime.d.ts +14 -8
- package/dist/types/eval/py/executor.d.ts +1 -2
- package/dist/types/eval/py/kernel.d.ts +6 -0
- package/dist/types/eval/py/tool-bridge.d.ts +1 -5
- package/dist/types/eval/session-id.d.ts +3 -0
- package/dist/types/extensibility/extensions/types.d.ts +1 -3
- package/dist/types/hashline/anchors.d.ts +15 -9
- package/dist/types/hashline/constants.d.ts +0 -2
- package/dist/types/hashline/diff.d.ts +1 -2
- package/dist/types/hashline/executor.d.ts +52 -0
- package/dist/types/hashline/hash.d.ts +44 -93
- package/dist/types/hashline/index.d.ts +2 -1
- package/dist/types/hashline/input.d.ts +2 -9
- package/dist/types/hashline/recovery.d.ts +3 -9
- package/dist/types/hashline/tokenizer.d.ts +91 -0
- package/dist/types/hashline/types.d.ts +5 -7
- package/dist/types/modes/components/extensions/types.d.ts +0 -4
- package/dist/types/modes/types.d.ts +1 -0
- package/dist/types/modes/utils/ui-helpers.d.ts +1 -0
- package/dist/types/sdk.d.ts +2 -0
- package/dist/types/session/agent-session.d.ts +11 -15
- package/dist/types/session/agent-storage.d.ts +11 -10
- package/dist/types/slash-commands/acp-builtins.d.ts +3 -3
- package/dist/types/slash-commands/types.d.ts +0 -5
- package/dist/types/task/executor.d.ts +2 -0
- package/dist/types/tool-discovery/tool-index.d.ts +0 -50
- package/dist/types/tools/index.d.ts +2 -8
- package/dist/types/tools/match-line-format.d.ts +4 -4
- package/dist/types/tools/output-schema-validator.d.ts +64 -0
- package/dist/types/tools/review.d.ts +13 -0
- package/dist/types/tools/search-tool-bm25.d.ts +1 -1
- package/dist/types/tools/search.d.ts +4 -3
- package/dist/types/utils/edit-mode.d.ts +1 -1
- package/dist/types/web/kagi.d.ts +4 -2
- package/dist/types/web/parallel.d.ts +4 -3
- package/dist/types/web/scrapers/types.d.ts +2 -1
- package/dist/types/web/search/index.d.ts +12 -4
- package/dist/types/web/search/provider.d.ts +2 -1
- package/dist/types/web/search/providers/anthropic.d.ts +9 -4
- package/dist/types/web/search/providers/base.d.ts +34 -2
- package/dist/types/web/search/providers/brave.d.ts +8 -1
- package/dist/types/web/search/providers/codex.d.ts +13 -9
- package/dist/types/web/search/providers/exa.d.ts +10 -1
- package/dist/types/web/search/providers/gemini.d.ts +20 -23
- package/dist/types/web/search/providers/jina.d.ts +2 -1
- package/dist/types/web/search/providers/kagi.d.ts +4 -1
- package/dist/types/web/search/providers/kimi.d.ts +10 -1
- package/dist/types/web/search/providers/parallel.d.ts +3 -2
- package/dist/types/web/search/providers/perplexity.d.ts +5 -2
- package/dist/types/web/search/providers/searxng.d.ts +2 -1
- package/dist/types/web/search/providers/synthetic.d.ts +5 -8
- package/dist/types/web/search/providers/tavily.d.ts +11 -4
- package/dist/types/web/search/providers/utils.d.ts +8 -6
- package/dist/types/web/search/providers/zai.d.ts +12 -3
- package/package.json +7 -7
- package/src/cli/file-processor.ts +12 -2
- package/src/cli.ts +0 -8
- package/src/commands/commit.ts +8 -8
- package/src/config/prompt-templates.ts +6 -6
- package/src/config/settings-schema.ts +47 -3
- package/src/config/settings.ts +5 -5
- package/src/debug/raw-sse.ts +68 -3
- package/src/edit/file-read-cache.ts +68 -25
- package/src/edit/index.ts +6 -37
- package/src/edit/renderer.ts +9 -47
- package/src/edit/streaming.ts +43 -56
- package/src/eval/__tests__/shared-executors.test.ts +520 -0
- package/src/eval/js/context-manager.ts +64 -53
- package/src/eval/js/shared/local-module-loader.ts +265 -0
- package/src/eval/js/shared/prelude.txt +4 -0
- package/src/eval/js/shared/rewrite-imports.ts +85 -0
- package/src/eval/js/shared/runtime.ts +129 -86
- package/src/eval/js/worker-core.ts +23 -38
- package/src/eval/py/executor.ts +155 -84
- package/src/eval/py/kernel.ts +10 -1
- package/src/eval/py/prelude.py +22 -24
- package/src/eval/py/runner.py +203 -85
- package/src/eval/py/tool-bridge.ts +17 -10
- package/src/eval/session-id.ts +8 -0
- package/src/exec/bash-executor.ts +27 -16
- package/src/extensibility/extensions/runner.ts +0 -1
- package/src/extensibility/extensions/types.ts +1 -3
- package/src/hashline/anchors.ts +56 -65
- package/src/hashline/apply.ts +29 -31
- package/src/hashline/constants.ts +0 -3
- package/src/hashline/diff-preview.ts +4 -5
- package/src/hashline/diff.ts +30 -4
- package/src/hashline/execute.ts +91 -26
- package/src/hashline/executor.ts +239 -0
- package/src/hashline/grammar.lark +12 -10
- package/src/hashline/hash.ts +69 -114
- package/src/hashline/index.ts +2 -1
- package/src/hashline/input.ts +48 -41
- package/src/hashline/prefixes.ts +21 -11
- package/src/hashline/recovery.ts +63 -71
- package/src/hashline/stream.ts +2 -2
- package/src/hashline/tokenizer.ts +467 -0
- package/src/hashline/types.ts +6 -8
- package/src/internal-urls/docs-index.generated.ts +7 -7
- package/src/modes/components/extensions/types.ts +0 -5
- package/src/modes/components/session-observer-overlay.ts +11 -2
- package/src/modes/components/tree-selector.ts +10 -2
- package/src/modes/controllers/command-controller.ts +1 -3
- package/src/modes/controllers/extension-ui-controller.ts +10 -11
- package/src/modes/controllers/selector-controller.ts +5 -5
- package/src/modes/types.ts +4 -1
- package/src/modes/utils/ui-helpers.ts +4 -0
- package/src/prompts/agents/explore.md +1 -1
- package/src/prompts/tools/ast-edit.md +1 -1
- package/src/prompts/tools/ast-grep.md +1 -1
- package/src/prompts/tools/eval.md +1 -1
- package/src/prompts/tools/hashline.md +73 -94
- package/src/prompts/tools/read.md +4 -4
- package/src/prompts/tools/search.md +3 -3
- package/src/sdk.ts +17 -23
- package/src/session/agent-session.ts +59 -66
- package/src/session/agent-storage.ts +13 -14
- package/src/slash-commands/acp-builtins.ts +3 -3
- package/src/slash-commands/types.ts +0 -6
- package/src/task/executor.ts +26 -57
- package/src/task/index.ts +8 -4
- package/src/tool-discovery/tool-index.ts +0 -134
- package/src/tools/ast-edit.ts +36 -13
- package/src/tools/ast-grep.ts +45 -4
- package/src/tools/browser/tab-worker.ts +3 -2
- package/src/tools/eval.ts +2 -1
- package/src/tools/fetch.ts +23 -14
- package/src/tools/index.ts +2 -8
- package/src/tools/irc.ts +59 -5
- package/src/tools/match-line-format.ts +5 -7
- package/src/tools/output-schema-validator.ts +132 -0
- package/src/tools/read.ts +142 -31
- package/src/tools/review.ts +23 -0
- package/src/tools/search-tool-bm25.ts +3 -30
- package/src/tools/search.ts +48 -16
- package/src/tools/write.ts +3 -3
- package/src/tools/yield.ts +32 -41
- package/src/utils/edit-mode.ts +1 -2
- package/src/utils/file-mentions.ts +2 -2
- package/src/web/kagi.ts +15 -6
- package/src/web/parallel.ts +9 -6
- package/src/web/scrapers/types.ts +7 -1
- package/src/web/scrapers/youtube.ts +13 -7
- package/src/web/search/index.ts +37 -11
- package/src/web/search/provider.ts +5 -3
- package/src/web/search/providers/anthropic.ts +30 -21
- package/src/web/search/providers/base.ts +35 -2
- package/src/web/search/providers/brave.ts +4 -4
- package/src/web/search/providers/codex.ts +118 -89
- package/src/web/search/providers/exa.ts +3 -2
- package/src/web/search/providers/gemini.ts +58 -155
- package/src/web/search/providers/jina.ts +4 -4
- package/src/web/search/providers/kagi.ts +17 -11
- package/src/web/search/providers/kimi.ts +29 -13
- package/src/web/search/providers/parallel.ts +171 -23
- package/src/web/search/providers/perplexity.ts +38 -37
- package/src/web/search/providers/searxng.ts +3 -1
- package/src/web/search/providers/synthetic.ts +16 -19
- package/src/web/search/providers/tavily.ts +23 -18
- package/src/web/search/providers/utils.ts +11 -17
- package/src/web/search/providers/zai.ts +16 -8
- package/dist/types/hashline/parser.d.ts +0 -7
- package/dist/types/mcp/discoverable-tool-metadata.d.ts +0 -7
- package/dist/types/tools/vim.d.ts +0 -58
- package/dist/types/vim/buffer.d.ts +0 -41
- package/dist/types/vim/commands.d.ts +0 -6
- package/dist/types/vim/engine.d.ts +0 -47
- package/dist/types/vim/parser.d.ts +0 -3
- package/dist/types/vim/render.d.ts +0 -25
- package/dist/types/vim/types.d.ts +0 -182
- package/src/hashline/parser.ts +0 -246
- package/src/mcp/discoverable-tool-metadata.ts +0 -24
- package/src/prompts/tools/vim.md +0 -98
- package/src/tools/vim.ts +0 -949
- package/src/vim/buffer.ts +0 -309
- package/src/vim/commands.ts +0 -382
- package/src/vim/engine.ts +0 -2409
- package/src/vim/parser.ts +0 -134
- package/src/vim/render.ts +0 -252
- package/src/vim/types.ts +0 -197
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared output-schema validation for subagent yield + executor finalization.
|
|
3
|
+
*
|
|
4
|
+
* Both the in-process `yield` tool (subagent side) and the executor's post-mortem
|
|
5
|
+
* finalize path (parent side) need to validate yield payloads against the agent's
|
|
6
|
+
* declared output schema. This module is the single source of truth for that
|
|
7
|
+
* pipeline — keeping the two callsites in lockstep so a schema accepted in-tool
|
|
8
|
+
* cannot be rejected post-mortem (or vice versa).
|
|
9
|
+
*/
|
|
10
|
+
import { type JsonSchemaValidationIssue, type JsonSchemaValidationResult } from "@oh-my-pi/pi-ai/utils/schema";
|
|
11
|
+
/** A validator bound to a specific output schema. */
|
|
12
|
+
export interface OutputValidator {
|
|
13
|
+
/** Run JSON Schema validation; returns the raw `success`/`issues` shape so callers may inspect every failure. */
|
|
14
|
+
validate(value: unknown): JsonSchemaValidationResult;
|
|
15
|
+
/** Top-level required property names. Empty if the schema has no `required` array at root. */
|
|
16
|
+
readonly requiredFields: readonly string[];
|
|
17
|
+
}
|
|
18
|
+
export interface BuildOutputValidatorResult {
|
|
19
|
+
/** Present when the schema produced a usable validator (i.e. constraining schemas). Absent for missing/unconstrained schemas. */
|
|
20
|
+
validator?: OutputValidator;
|
|
21
|
+
/** Raw JSON Schema produced by `jtdToJsonSchema`. Available alongside the validator so callers can derive related artifacts (strict-mode probe, dereference, hint text). */
|
|
22
|
+
jsonSchema?: Record<string, unknown>;
|
|
23
|
+
/**
|
|
24
|
+
* Normalized schema (post-`normalizeSchema`). Surfaced so callers can distinguish
|
|
25
|
+
* "no schema provided" (`undefined`) from "intentionally unconstrained" (`true`)
|
|
26
|
+
* when both produce no validator.
|
|
27
|
+
*/
|
|
28
|
+
normalized?: unknown;
|
|
29
|
+
/** Set when the schema cannot be used. Callers should treat this as a "no validation" case (loose acceptance) and surface the message in diagnostics. */
|
|
30
|
+
error?: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Build the canonical validator for a JTD-or-JSON-Schema output declaration.
|
|
34
|
+
*
|
|
35
|
+
* Returns:
|
|
36
|
+
* - `{ validator, jsonSchema, normalized }` for constraining schemas — both callers use this path.
|
|
37
|
+
* - `{ normalized: true }` for an intentionally unconstrained schema (the JSON Schema literal `true`).
|
|
38
|
+
* No validator, but distinguishable from "no schema provided".
|
|
39
|
+
* - `{}` for an absent schema (`undefined`).
|
|
40
|
+
* - `{ error, normalized? }` when the schema cannot be honored (invalid syntax, `false`, malformed JTD).
|
|
41
|
+
*/
|
|
42
|
+
export declare function buildOutputValidator(schema: unknown): BuildOutputValidatorResult;
|
|
43
|
+
/** Produce the executor's headline+missing-required summary from a failed validation. */
|
|
44
|
+
export declare function summarizeValidationFailure(result: JsonSchemaValidationResult, value: unknown, requiredFields: readonly string[]): {
|
|
45
|
+
message: string;
|
|
46
|
+
missingRequired: string[];
|
|
47
|
+
};
|
|
48
|
+
export declare function extractRequiredFields(jsonSchema: unknown): string[];
|
|
49
|
+
export declare function computeMissingRequired(required: readonly string[], value: unknown): string[];
|
|
50
|
+
/**
|
|
51
|
+
* Format a single validation issue as `path.with.dots: message`.
|
|
52
|
+
*
|
|
53
|
+
* Used by the executor's post-mortem `schema_violation` headline — one line, dot-separated path,
|
|
54
|
+
* since the executor's error format already lists missing-required fields separately.
|
|
55
|
+
*/
|
|
56
|
+
export declare function formatValidationIssueHeadline(issue: JsonSchemaValidationIssue | undefined): string | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* Format every validation issue as `path/with/slashes: message; ...`.
|
|
59
|
+
*
|
|
60
|
+
* Used by the yield tool's model-facing retry feedback — the model gets every problem at once so it
|
|
61
|
+
* can fix the entire output in one retry instead of iterating issue-by-issue. The slash separator
|
|
62
|
+
* mirrors JSON Pointer convention and disambiguates against fields whose names contain dots.
|
|
63
|
+
*/
|
|
64
|
+
export declare function formatAllValidationIssues(issues: ReadonlyArray<JsonSchemaValidationIssue> | undefined): string;
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
import type { AgentTool } from "@oh-my-pi/pi-agent-core";
|
|
9
9
|
import * as z from "zod/v4";
|
|
10
10
|
import type { Theme, ThemeColor } from "../modes/theme/theme";
|
|
11
|
+
import type { ReviewFinding } from "../task/types";
|
|
11
12
|
export type FindingPriority = "P0" | "P1" | "P2" | "P3";
|
|
12
13
|
export interface FindingPriorityInfo {
|
|
13
14
|
ord: 0 | 1 | 2 | 3;
|
|
@@ -48,3 +49,15 @@ export interface SubmitReviewDetails {
|
|
|
48
49
|
confidence: number;
|
|
49
50
|
}
|
|
50
51
|
export type { ReportFindingDetails };
|
|
52
|
+
/**
|
|
53
|
+
* Coerce a tool-side `ReportFindingDetails` into the cross-boundary
|
|
54
|
+
* `ReviewFinding` shape consumed by the reviewer agent's JTD output schema.
|
|
55
|
+
*
|
|
56
|
+
* The `report_finding` tool exposes `priority` as a string enum (`"P0".."P3"`)
|
|
57
|
+
* for ergonomics, but the bundled reviewer schema (and every custom review
|
|
58
|
+
* agent that mirrors it) declares `priority: number`. Without this coercion
|
|
59
|
+
* the auto-populated `findings[]` fails JTD validation and every review run
|
|
60
|
+
* that surfaces a finding is rejected with `findings.0.priority: expected
|
|
61
|
+
* number, received string`.
|
|
62
|
+
*/
|
|
63
|
+
export declare function toReviewFinding(details: ReportFindingDetails): ReviewFinding;
|
|
@@ -5,7 +5,6 @@ import type { RenderResultOptions } from "../extensibility/custom-tools/types";
|
|
|
5
5
|
import type { Theme } from "../modes/theme/theme";
|
|
6
6
|
import { type DiscoverableTool } from "../tool-discovery/tool-index";
|
|
7
7
|
import type { ToolSession } from ".";
|
|
8
|
-
export type { DiscoverableMCPSearchIndex, DiscoverableMCPTool, } from "../mcp/discoverable-tool-metadata";
|
|
9
8
|
declare const searchToolBm25Schema: z.ZodObject<{
|
|
10
9
|
query: z.ZodString;
|
|
11
10
|
limit: z.ZodOptional<z.ZodNumber>;
|
|
@@ -63,3 +62,4 @@ export declare const searchToolBm25Renderer: {
|
|
|
63
62
|
mergeCallAndResult: boolean;
|
|
64
63
|
inline: boolean;
|
|
65
64
|
};
|
|
65
|
+
export {};
|
|
@@ -8,12 +8,13 @@ import type { ToolSession } from ".";
|
|
|
8
8
|
import { type OutputMeta } from "./output-meta";
|
|
9
9
|
declare const searchSchema: z.ZodObject<{
|
|
10
10
|
pattern: z.ZodString;
|
|
11
|
-
paths: z.ZodArray<z.ZodString>;
|
|
11
|
+
paths: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>;
|
|
12
12
|
i: z.ZodOptional<z.ZodBoolean>;
|
|
13
13
|
gitignore: z.ZodOptional<z.ZodBoolean>;
|
|
14
14
|
skip: z.ZodOptional<z.ZodNumber>;
|
|
15
15
|
}, z.core.$strict>;
|
|
16
16
|
export type SearchToolInput = z.infer<typeof searchSchema>;
|
|
17
|
+
export declare function toPathList(input: string | string[] | undefined): string[];
|
|
17
18
|
/** Maximum number of distinct files surfaced in a single response. The
|
|
18
19
|
* agent paginates further pages via `skip`. */
|
|
19
20
|
export declare const DEFAULT_FILE_LIMIT = 20;
|
|
@@ -61,7 +62,7 @@ export declare class SearchTool implements AgentTool<typeof searchSchema, Search
|
|
|
61
62
|
readonly description: string;
|
|
62
63
|
readonly parameters: z.ZodObject<{
|
|
63
64
|
pattern: z.ZodString;
|
|
64
|
-
paths: z.ZodArray<z.ZodString>;
|
|
65
|
+
paths: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>;
|
|
65
66
|
i: z.ZodOptional<z.ZodBoolean>;
|
|
66
67
|
gitignore: z.ZodOptional<z.ZodBoolean>;
|
|
67
68
|
skip: z.ZodOptional<z.ZodNumber>;
|
|
@@ -72,7 +73,7 @@ export declare class SearchTool implements AgentTool<typeof searchSchema, Search
|
|
|
72
73
|
}
|
|
73
74
|
interface SearchRenderArgs {
|
|
74
75
|
pattern: string;
|
|
75
|
-
paths?: string[];
|
|
76
|
+
paths?: string | string[];
|
|
76
77
|
i?: boolean;
|
|
77
78
|
gitignore?: boolean;
|
|
78
79
|
skip?: number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type EditMode = "replace" | "patch" | "hashline" | "
|
|
1
|
+
export type EditMode = "replace" | "patch" | "hashline" | "apply_patch";
|
|
2
2
|
export declare const DEFAULT_EDIT_MODE: EditMode;
|
|
3
3
|
export declare const EDIT_MODES: EditMode[];
|
|
4
4
|
export declare function normalizeEditMode(mode?: string | null): EditMode | undefined;
|
package/dist/types/web/kagi.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import type { AuthStorage } from "@oh-my-pi/pi-ai";
|
|
1
2
|
export declare class KagiApiError extends Error {
|
|
2
3
|
readonly statusCode?: number;
|
|
3
4
|
constructor(message: string, statusCode?: number);
|
|
4
5
|
}
|
|
5
6
|
export interface KagiSearchOptions {
|
|
6
7
|
limit?: number;
|
|
8
|
+
sessionId?: string;
|
|
7
9
|
signal?: AbortSignal;
|
|
8
10
|
}
|
|
9
11
|
export interface KagiSearchSource {
|
|
@@ -17,5 +19,5 @@ export interface KagiSearchResult {
|
|
|
17
19
|
sources: KagiSearchSource[];
|
|
18
20
|
relatedQuestions: string[];
|
|
19
21
|
}
|
|
20
|
-
export declare function findKagiApiKey(): Promise<string | null>;
|
|
21
|
-
export declare function searchWithKagi(query: string, options
|
|
22
|
+
export declare function findKagiApiKey(authStorage: AuthStorage, sessionId?: string, signal?: AbortSignal): Promise<string | null>;
|
|
23
|
+
export declare function searchWithKagi(query: string, options: KagiSearchOptions | undefined, authStorage: AuthStorage): Promise<KagiSearchResult>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { AgentStorage } from "../session/agent-storage";
|
|
1
2
|
export interface ParallelUsageItem {
|
|
2
3
|
name?: string;
|
|
3
4
|
count?: number;
|
|
@@ -51,7 +52,7 @@ export declare class ParallelApiError extends Error {
|
|
|
51
52
|
readonly statusCode?: number;
|
|
52
53
|
constructor(message: string, statusCode?: number);
|
|
53
54
|
}
|
|
54
|
-
export declare function findParallelApiKey():
|
|
55
|
+
export declare function findParallelApiKey(storage: AgentStorage | null | undefined): string | null;
|
|
55
56
|
export declare function getParallelExtractContent(document: ParallelExtractDocument): string;
|
|
56
|
-
export declare function searchWithParallel(objective: string, queries: string[], options
|
|
57
|
-
export declare function extractWithParallel(urls: string[], options
|
|
57
|
+
export declare function searchWithParallel(objective: string, queries: string[], options: ParallelSearchOptions, storage: AgentStorage | null | undefined): Promise<ParallelSearchResult>;
|
|
58
|
+
export declare function extractWithParallel(urls: string[], options: ParallelExtractOptions, storage: AgentStorage | null | undefined): Promise<ParallelExtractResult>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { AgentStorage } from "../../session/agent-storage";
|
|
1
2
|
export { formatNumber } from "@oh-my-pi/pi-utils";
|
|
2
3
|
export interface RenderResult {
|
|
3
4
|
url: string;
|
|
@@ -9,7 +10,7 @@ export interface RenderResult {
|
|
|
9
10
|
truncated: boolean;
|
|
10
11
|
notes: string[];
|
|
11
12
|
}
|
|
12
|
-
export type SpecialHandler = (url: string, timeout: number, signal?: AbortSignal) => Promise<RenderResult | null>;
|
|
13
|
+
export type SpecialHandler = (url: string, timeout: number, signal?: AbortSignal, storage?: AgentStorage | null) => Promise<RenderResult | null>;
|
|
13
14
|
export declare const MAX_OUTPUT_CHARS = 500000;
|
|
14
15
|
export declare const MAX_BYTES: number;
|
|
15
16
|
/**
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Single tool supporting Anthropic, Perplexity, Exa, Brave, Jina, Kimi, Gemini, Codex, Tavily, Kagi, Z.AI, SearXNG, and Synthetic
|
|
5
5
|
* providers with provider-specific parameters exposed conditionally.
|
|
6
|
-
*
|
|
7
6
|
*/
|
|
8
7
|
import type { AgentTool, AgentToolContext, AgentToolResult, AgentToolUpdateCallback } from "@oh-my-pi/pi-agent-core";
|
|
8
|
+
import type { AuthStorage } from "@oh-my-pi/pi-ai";
|
|
9
9
|
import * as z from "zod/v4";
|
|
10
10
|
import type { CustomTool } from "../../extensibility/custom-tools/types";
|
|
11
11
|
import type { ToolSession } from "../../tools";
|
|
@@ -31,8 +31,16 @@ export interface SearchQueryParams extends SearchToolParams {
|
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
33
|
* Execute a web search query for CLI/testing workflows.
|
|
34
|
+
*
|
|
35
|
+
* `authStorage` may be omitted; in that case we discover one via the standard
|
|
36
|
+
* factory (`discoverAuthStorage`), which honours `OMP_AUTH_BROKER_URL` and
|
|
37
|
+
* otherwise opens the local SQLite credential store.
|
|
34
38
|
*/
|
|
35
|
-
export declare function runSearchQuery(params: SearchQueryParams
|
|
39
|
+
export declare function runSearchQuery(params: SearchQueryParams, options?: {
|
|
40
|
+
authStorage?: AuthStorage;
|
|
41
|
+
sessionId?: string;
|
|
42
|
+
signal?: AbortSignal;
|
|
43
|
+
}): Promise<{
|
|
36
44
|
content: Array<{
|
|
37
45
|
type: "text";
|
|
38
46
|
text: string;
|
|
@@ -43,9 +51,9 @@ export declare function runSearchQuery(params: SearchQueryParams): Promise<{
|
|
|
43
51
|
* Web search tool implementation.
|
|
44
52
|
*
|
|
45
53
|
* Supports Anthropic, Perplexity, Exa, Brave, Jina, Kimi, Gemini, Codex, Z.AI, SearXNG, and Synthetic providers with automatic fallback.
|
|
46
|
-
* Session is accepted for interface consistency but not used.
|
|
47
54
|
*/
|
|
48
55
|
export declare class WebSearchTool implements AgentTool<typeof webSearchSchema, SearchRenderDetails> {
|
|
56
|
+
#private;
|
|
49
57
|
readonly name = "web_search";
|
|
50
58
|
readonly label = "Web Search";
|
|
51
59
|
readonly description: string;
|
|
@@ -65,7 +73,7 @@ export declare class WebSearchTool implements AgentTool<typeof webSearchSchema,
|
|
|
65
73
|
readonly strict = true;
|
|
66
74
|
readonly loadMode = "discoverable";
|
|
67
75
|
readonly summary = "Search the web for up-to-date information";
|
|
68
|
-
constructor(
|
|
76
|
+
constructor(session: ToolSession);
|
|
69
77
|
execute(_toolCallId: string, params: SearchToolParams, signal?: AbortSignal, _onUpdate?: AgentToolUpdateCallback<SearchRenderDetails>, _context?: AgentToolContext): Promise<AgentToolResult<SearchRenderDetails>>;
|
|
70
78
|
}
|
|
71
79
|
/** Web search tool as CustomTool (for TUI rendering support) */
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { AuthStorage } from "@oh-my-pi/pi-ai";
|
|
1
2
|
import type { SearchProvider } from "./providers/base";
|
|
2
3
|
import type { SearchProviderId } from "./types";
|
|
3
4
|
export type { SearchParams } from "./providers/base";
|
|
@@ -17,4 +18,4 @@ export declare function setPreferredSearchProvider(provider: SearchProviderId |
|
|
|
17
18
|
* Each candidate is loaded (and its `isAvailable()` called) only as the chain
|
|
18
19
|
* is walked, so unconfigured providers never pay the load cost.
|
|
19
20
|
*/
|
|
20
|
-
export declare function resolveProviderChain(preferredProvider?: SearchProviderId | "auto"): Promise<SearchProvider[]>;
|
|
21
|
+
export declare function resolveProviderChain(authStorage: AuthStorage, preferredProvider?: SearchProviderId | "auto"): Promise<SearchProvider[]>;
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Anthropic Web Search Provider
|
|
3
|
+
*
|
|
4
|
+
* Uses Claude's built-in web_search_20250305 tool to search the web.
|
|
5
|
+
* Returns synthesized answers with citations and source metadata.
|
|
6
|
+
*/
|
|
7
|
+
import { type AuthStorage } from "@oh-my-pi/pi-ai";
|
|
1
8
|
import type { SearchResponse } from "../../../web/search/types";
|
|
2
9
|
import type { SearchParams } from "./base";
|
|
3
10
|
import { SearchProvider } from "./base";
|
|
@@ -5,9 +12,7 @@ export interface AnthropicSearchParams {
|
|
|
5
12
|
query: string;
|
|
6
13
|
system_prompt?: string;
|
|
7
14
|
num_results?: number;
|
|
8
|
-
/** Maximum output tokens. Defaults to 4096. */
|
|
9
15
|
max_tokens?: number;
|
|
10
|
-
/** Sampling temperature (0–1). Lower = more focused/factual. */
|
|
11
16
|
temperature?: number;
|
|
12
17
|
signal?: AbortSignal;
|
|
13
18
|
}
|
|
@@ -17,11 +22,11 @@ export interface AnthropicSearchParams {
|
|
|
17
22
|
* @returns Search response with synthesized answer, sources, and citations
|
|
18
23
|
* @throws {Error} If no Anthropic credentials are configured
|
|
19
24
|
*/
|
|
20
|
-
export declare function searchAnthropic(params: AnthropicSearchParams): Promise<SearchResponse>;
|
|
25
|
+
export declare function searchAnthropic(params: SearchParams | AnthropicSearchParams, _legacyStorage?: unknown): Promise<SearchResponse>;
|
|
21
26
|
/** Search provider for Anthropic Claude web search. */
|
|
22
27
|
export declare class AnthropicProvider extends SearchProvider {
|
|
23
28
|
readonly id = "anthropic";
|
|
24
29
|
readonly label = "Anthropic";
|
|
25
|
-
isAvailable(): Promise<boolean
|
|
30
|
+
isAvailable(authStorage: AuthStorage): Promise<boolean> | boolean;
|
|
26
31
|
search(params: SearchParams): Promise<SearchResponse>;
|
|
27
32
|
}
|
|
@@ -1,5 +1,15 @@
|
|
|
1
|
+
import type { AuthStorage } from "@oh-my-pi/pi-ai";
|
|
1
2
|
import type { SearchProviderId, SearchResponse } from "../types";
|
|
2
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* Shared web search parameters passed to providers.
|
|
5
|
+
*
|
|
6
|
+
* `authStorage` is the **only** credential source providers may consult.
|
|
7
|
+
* Opening a sibling SQLite handle or calling provider-direct refresh helpers
|
|
8
|
+
* (e.g. `refreshOpenAICodexToken`, `refreshGoogleCloudToken`) is prohibited:
|
|
9
|
+
* it races the broker's per-credential refresh and POSTs the broker sentinel
|
|
10
|
+
* (`REMOTE_REFRESH_SENTINEL`) to the upstream token endpoint, which classifies
|
|
11
|
+
* as `invalid_grant` and disables the row.
|
|
12
|
+
*/
|
|
3
13
|
export interface SearchParams {
|
|
4
14
|
query: string;
|
|
5
15
|
limit?: number;
|
|
@@ -25,11 +35,33 @@ export interface SearchParams {
|
|
|
25
35
|
googleSearch?: Record<string, unknown>;
|
|
26
36
|
codeExecution?: Record<string, unknown>;
|
|
27
37
|
urlContext?: Record<string, unknown>;
|
|
38
|
+
/**
|
|
39
|
+
* The single source of truth for credentials. Providers MUST consult this
|
|
40
|
+
* handle exclusively (`getApiKey` for bearer-style auth, `getOAuthAccess`
|
|
41
|
+
* when identity metadata is required). Do not open `AgentStorage` or any
|
|
42
|
+
* `AuthCredentialStore` directly — that bypasses the broker pipeline and
|
|
43
|
+
* the per-credential single-flight refresh.
|
|
44
|
+
*/
|
|
45
|
+
authStorage: AuthStorage;
|
|
46
|
+
/**
|
|
47
|
+
* Optional session id used as the round-robin / sticky key when selecting
|
|
48
|
+
* among multiple credentials for the same provider. Pass through from the
|
|
49
|
+
* caller's agent session when available; otherwise omit.
|
|
50
|
+
*/
|
|
51
|
+
sessionId?: string;
|
|
28
52
|
}
|
|
29
53
|
/** Base class for web search providers. */
|
|
30
54
|
export declare abstract class SearchProvider {
|
|
31
55
|
abstract readonly id: SearchProviderId;
|
|
32
56
|
abstract readonly label: string;
|
|
33
|
-
|
|
57
|
+
/**
|
|
58
|
+
* Indicates whether this provider has the credentials/config it needs to
|
|
59
|
+
* service a request right now. Implementations consult the passed
|
|
60
|
+
* {@link AuthStorage} — never a sibling store.
|
|
61
|
+
*/
|
|
62
|
+
abstract isAvailable(authStorage: AuthStorage): Promise<boolean> | boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Execute a search. Credentials MUST be resolved through `params.authStorage`.
|
|
65
|
+
*/
|
|
34
66
|
abstract search(params: SearchParams): Promise<SearchResponse>;
|
|
35
67
|
}
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Brave Web Search Provider
|
|
3
|
+
*
|
|
4
|
+
* Calls Brave's web search REST API and maps results into the unified
|
|
5
|
+
* SearchResponse shape used by the web search tool.
|
|
6
|
+
*/
|
|
7
|
+
import { type AuthStorage } from "@oh-my-pi/pi-ai";
|
|
1
8
|
import type { SearchResponse } from "../../../web/search/types";
|
|
2
9
|
import type { SearchParams } from "./base";
|
|
3
10
|
import { SearchProvider } from "./base";
|
|
@@ -15,6 +22,6 @@ export declare function searchBrave(params: BraveSearchParams): Promise<SearchRe
|
|
|
15
22
|
export declare class BraveProvider extends SearchProvider {
|
|
16
23
|
readonly id = "brave";
|
|
17
24
|
readonly label = "Brave";
|
|
18
|
-
isAvailable():
|
|
25
|
+
isAvailable(_authStorage: AuthStorage): boolean;
|
|
19
26
|
search(params: SearchParams): Promise<SearchResponse>;
|
|
20
27
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type AuthStorage } from "@oh-my-pi/pi-ai";
|
|
1
2
|
import type { SearchResponse } from "../../../web/search/types";
|
|
2
3
|
import type { SearchParams } from "./base";
|
|
3
4
|
import { SearchProvider } from "./base";
|
|
@@ -11,21 +12,24 @@ export interface CodexSearchParams {
|
|
|
11
12
|
}
|
|
12
13
|
/**
|
|
13
14
|
* Executes a web search using OpenAI Codex's built-in web search tool.
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
15
|
+
*
|
|
16
|
+
* Default-model behavior:
|
|
17
|
+
* - If `PI_CODEX_WEB_SEARCH_MODEL` is set, use it exactly once and surface any
|
|
18
|
+
* upstream error verbatim.
|
|
19
|
+
* - Otherwise prefer ChatGPT-account-safe bundled defaults (GPT-5.4, GPT-5
|
|
20
|
+
* Codex, GPT-5, …) and retry the next candidate only when Codex returns the
|
|
21
|
+
* known 400 "model is not supported" family. This avoids selecting
|
|
22
|
+
* `gpt-5-codex-mini` first on ChatGPT accounts, which OpenAI rejects.
|
|
18
23
|
*/
|
|
19
|
-
export declare function searchCodex(params:
|
|
24
|
+
export declare function searchCodex(params: SearchParams): Promise<SearchResponse>;
|
|
20
25
|
/**
|
|
21
26
|
* Checks if Codex web search is available.
|
|
22
|
-
* @returns True if valid OAuth credentials exist for openai-codex
|
|
23
27
|
*/
|
|
24
|
-
export declare function hasCodexSearch(): Promise<boolean>;
|
|
28
|
+
export declare function hasCodexSearch(authStorage: AuthStorage): Promise<boolean>;
|
|
25
29
|
/** Search provider for OpenAI Codex web search. */
|
|
26
30
|
export declare class CodexProvider extends SearchProvider {
|
|
27
31
|
readonly id = "codex";
|
|
28
|
-
readonly label = "
|
|
29
|
-
isAvailable(): Promise<boolean
|
|
32
|
+
readonly label = "OpenAI";
|
|
33
|
+
isAvailable(authStorage: AuthStorage): Promise<boolean> | boolean;
|
|
30
34
|
search(params: SearchParams): Promise<SearchResponse>;
|
|
31
35
|
}
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Exa Web Search Provider
|
|
3
|
+
*
|
|
4
|
+
* High-quality neural search via Exa Search API.
|
|
5
|
+
* Returns structured search results with optional content extraction.
|
|
6
|
+
* Requests per-result summaries via `contents.summary` and synthesizes
|
|
7
|
+
* them into a combined `answer` string on the SearchResponse.
|
|
8
|
+
*/
|
|
9
|
+
import { type AuthStorage } from "@oh-my-pi/pi-ai";
|
|
1
10
|
import type { SearchResponse } from "../../../web/search/types";
|
|
2
11
|
import type { SearchParams } from "./base";
|
|
3
12
|
import { SearchProvider } from "./base";
|
|
@@ -37,7 +46,7 @@ export declare function searchExa(params: ExaSearchParams): Promise<SearchRespon
|
|
|
37
46
|
export declare class ExaProvider extends SearchProvider {
|
|
38
47
|
readonly id = "exa";
|
|
39
48
|
readonly label = "Exa";
|
|
40
|
-
isAvailable(): boolean;
|
|
49
|
+
isAvailable(_authStorage: AuthStorage): boolean;
|
|
41
50
|
search(params: SearchParams): Promise<SearchResponse>;
|
|
42
51
|
}
|
|
43
52
|
export {};
|
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Google Gemini Web Search Provider
|
|
3
|
+
*
|
|
4
|
+
* Uses Gemini's Google Search grounding via Cloud Code Assist API.
|
|
5
|
+
* Auth is resolved through `AuthStorage.getOAuthAccess(...)` for both
|
|
6
|
+
* `google-gemini-cli` (stable prod) and `google-antigravity` (daily sandbox)
|
|
7
|
+
* — the broker is the sole refresh authority, so this module never opens a
|
|
8
|
+
* sibling SQLite store and never POSTs the broker sentinel to a Google token
|
|
9
|
+
* endpoint.
|
|
10
|
+
*/
|
|
11
|
+
import { type AuthStorage } from "@oh-my-pi/pi-ai";
|
|
2
12
|
import type { SearchResponse } from "../../../web/search/types";
|
|
3
13
|
import type { SearchParams } from "./base";
|
|
4
14
|
import { SearchProvider } from "./base";
|
|
@@ -16,45 +26,32 @@ export interface GeminiSearchParams extends GeminiToolParams {
|
|
|
16
26
|
/** Sampling temperature (0–1). Lower = more focused/factual. */
|
|
17
27
|
temperature?: number;
|
|
18
28
|
signal?: AbortSignal;
|
|
29
|
+
authStorage: AuthStorage;
|
|
30
|
+
sessionId?: string;
|
|
19
31
|
}
|
|
20
32
|
export declare function buildGeminiRequestTools(params: GeminiToolParams): Array<Record<string, Record<string, unknown>>>;
|
|
21
|
-
/**
|
|
22
|
-
interface GeminiOAuthCredential {
|
|
23
|
-
type: "oauth";
|
|
24
|
-
access: string;
|
|
25
|
-
refresh?: string;
|
|
26
|
-
expires: number;
|
|
27
|
-
projectId?: string;
|
|
28
|
-
}
|
|
29
|
-
/** Auth info for Gemini API requests */
|
|
33
|
+
/** Resolved auth for a Gemini API request. */
|
|
30
34
|
interface GeminiAuth {
|
|
31
35
|
accessToken: string;
|
|
32
|
-
refreshToken?: string;
|
|
33
36
|
projectId: string;
|
|
34
37
|
isAntigravity: boolean;
|
|
35
|
-
storage: AgentStorage;
|
|
36
|
-
credentialId: number;
|
|
37
|
-
credential: GeminiOAuthCredential;
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
* @
|
|
40
|
+
* Walks the configured Gemini OAuth providers in deterministic order and
|
|
41
|
+
* returns the first one that yields a usable access token + projectId via
|
|
42
|
+
* {@link AuthStorage.getOAuthAccess}. AuthStorage handles refresh + broker
|
|
43
|
+
* routing internally; this helper never touches refresh tokens directly.
|
|
43
44
|
*/
|
|
44
|
-
export declare function findGeminiAuth(): Promise<GeminiAuth | null>;
|
|
45
|
+
export declare function findGeminiAuth(authStorage: AuthStorage, sessionId: string | undefined, signal: AbortSignal | undefined): Promise<GeminiAuth | null>;
|
|
45
46
|
/**
|
|
46
47
|
* Executes a web search using Google Gemini with Google Search grounding.
|
|
47
|
-
* Requires OAuth credentials stored in agent.db for provider "google-gemini-cli" or "google-antigravity".
|
|
48
|
-
* @param params - Search parameters including query and optional settings
|
|
49
|
-
* @returns Search response with synthesized answer, sources, and citations
|
|
50
|
-
* @throws {Error} If no Gemini OAuth credentials are configured
|
|
51
48
|
*/
|
|
52
49
|
export declare function searchGemini(params: GeminiSearchParams): Promise<SearchResponse>;
|
|
53
50
|
/** Search provider for Google Gemini web search. */
|
|
54
51
|
export declare class GeminiProvider extends SearchProvider {
|
|
55
52
|
readonly id = "gemini";
|
|
56
53
|
readonly label = "Gemini";
|
|
57
|
-
isAvailable():
|
|
54
|
+
isAvailable(authStorage: AuthStorage): boolean;
|
|
58
55
|
search(params: SearchParams): Promise<SearchResponse>;
|
|
59
56
|
}
|
|
60
57
|
export {};
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* Uses the Jina Reader `s.jina.ai` endpoint to fetch search results with
|
|
5
5
|
* cleaned content.
|
|
6
6
|
*/
|
|
7
|
+
import { type AuthStorage } from "@oh-my-pi/pi-ai";
|
|
7
8
|
import type { SearchResponse } from "../../../web/search/types";
|
|
8
9
|
import type { SearchParams } from "./base";
|
|
9
10
|
import { SearchProvider } from "./base";
|
|
@@ -20,6 +21,6 @@ export declare function searchJina(params: JinaSearchParams): Promise<SearchResp
|
|
|
20
21
|
export declare class JinaProvider extends SearchProvider {
|
|
21
22
|
readonly id = "jina";
|
|
22
23
|
readonly label = "Jina";
|
|
23
|
-
isAvailable():
|
|
24
|
+
isAvailable(_authStorage: AuthStorage): boolean;
|
|
24
25
|
search(params: SearchParams): Promise<SearchResponse>;
|
|
25
26
|
}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Thin wrapper that adapts shared Kagi API utilities to SearchResponse shape.
|
|
5
5
|
*/
|
|
6
|
+
import type { AuthStorage } from "@oh-my-pi/pi-ai";
|
|
6
7
|
import type { SearchResponse } from "../../../web/search/types";
|
|
7
8
|
import type { SearchParams } from "./base";
|
|
8
9
|
import { SearchProvider } from "./base";
|
|
@@ -11,11 +12,13 @@ export declare function searchKagi(params: {
|
|
|
11
12
|
query: string;
|
|
12
13
|
num_results?: number;
|
|
13
14
|
signal?: AbortSignal;
|
|
15
|
+
authStorage: AuthStorage;
|
|
16
|
+
sessionId?: string;
|
|
14
17
|
}): Promise<SearchResponse>;
|
|
15
18
|
/** Search provider for Kagi web search. */
|
|
16
19
|
export declare class KagiProvider extends SearchProvider {
|
|
17
20
|
readonly id = "kagi";
|
|
18
21
|
readonly label = "Kagi";
|
|
19
|
-
isAvailable():
|
|
22
|
+
isAvailable(authStorage: AuthStorage): boolean;
|
|
20
23
|
search(params: SearchParams): Promise<SearchResponse>;
|
|
21
24
|
}
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Kimi Web Search Provider
|
|
3
|
+
*
|
|
4
|
+
* Uses Moonshot Kimi Code search API to retrieve web results.
|
|
5
|
+
* Endpoint: POST https://api.kimi.com/coding/v1/search
|
|
6
|
+
*/
|
|
7
|
+
import type { AuthStorage } from "@oh-my-pi/pi-ai";
|
|
1
8
|
import type { SearchResponse } from "../../../web/search/types";
|
|
2
9
|
import type { SearchParams } from "./base";
|
|
3
10
|
import { SearchProvider } from "./base";
|
|
@@ -6,6 +13,8 @@ export interface KimiSearchParams {
|
|
|
6
13
|
num_results?: number;
|
|
7
14
|
include_content?: boolean;
|
|
8
15
|
signal?: AbortSignal;
|
|
16
|
+
authStorage: AuthStorage;
|
|
17
|
+
sessionId?: string;
|
|
9
18
|
}
|
|
10
19
|
/** Execute Kimi web search. */
|
|
11
20
|
export declare function searchKimi(params: KimiSearchParams): Promise<SearchResponse>;
|
|
@@ -13,6 +22,6 @@ export declare function searchKimi(params: KimiSearchParams): Promise<SearchResp
|
|
|
13
22
|
export declare class KimiProvider extends SearchProvider {
|
|
14
23
|
readonly id = "kimi";
|
|
15
24
|
readonly label = "Kimi";
|
|
16
|
-
isAvailable():
|
|
25
|
+
isAvailable(authStorage: AuthStorage): boolean;
|
|
17
26
|
search(params: SearchParams): Promise<SearchResponse>;
|
|
18
27
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type AuthStorage } from "@oh-my-pi/pi-ai";
|
|
1
2
|
import type { SearchResponse } from "../../../web/search/types";
|
|
2
3
|
import type { SearchParams } from "./base";
|
|
3
4
|
import { SearchProvider } from "./base";
|
|
@@ -5,10 +6,10 @@ export declare function searchParallel(params: {
|
|
|
5
6
|
query: string;
|
|
6
7
|
num_results?: number;
|
|
7
8
|
signal?: AbortSignal;
|
|
8
|
-
}): Promise<SearchResponse>;
|
|
9
|
+
}, authStorage: AuthStorage, sessionId?: string): Promise<SearchResponse>;
|
|
9
10
|
export declare class ParallelProvider extends SearchProvider {
|
|
10
11
|
readonly id = "parallel";
|
|
11
12
|
readonly label = "Parallel";
|
|
12
|
-
isAvailable():
|
|
13
|
+
isAvailable(authStorage: AuthStorage): boolean;
|
|
13
14
|
search(params: SearchParams): Promise<SearchResponse>;
|
|
14
15
|
}
|
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Supports three auth modes:
|
|
5
5
|
* - Cookies (`PERPLEXITY_COOKIES`) via `www.perplexity.ai/rest/sse/perplexity_ask`
|
|
6
|
-
* - OAuth
|
|
6
|
+
* - OAuth/session bearer via `AuthStorage` and `www.perplexity.ai/rest/sse/perplexity_ask`
|
|
7
7
|
* - API key (`PERPLEXITY_API_KEY`) via `api.perplexity.ai/chat/completions`
|
|
8
8
|
*/
|
|
9
|
+
import { type AuthStorage } from "@oh-my-pi/pi-ai";
|
|
9
10
|
import type { SearchResponse } from "../../../web/search/types";
|
|
10
11
|
import type { SearchParams } from "./base";
|
|
11
12
|
import { SearchProvider } from "./base";
|
|
@@ -21,6 +22,8 @@ export interface PerplexitySearchParams {
|
|
|
21
22
|
temperature?: number;
|
|
22
23
|
/** Number of search results to retrieve. Defaults to 10. */
|
|
23
24
|
num_search_results?: number;
|
|
25
|
+
authStorage: AuthStorage;
|
|
26
|
+
sessionId?: string;
|
|
24
27
|
}
|
|
25
28
|
/** Find PERPLEXITY_API_KEY from environment or .env files (also checks PPLX_API_KEY) */
|
|
26
29
|
export declare function findApiKey(): string | null;
|
|
@@ -30,6 +33,6 @@ export declare function searchPerplexity(params: PerplexitySearchParams): Promis
|
|
|
30
33
|
export declare class PerplexityProvider extends SearchProvider {
|
|
31
34
|
readonly id = "perplexity";
|
|
32
35
|
readonly label = "Perplexity";
|
|
33
|
-
isAvailable():
|
|
36
|
+
isAvailable(authStorage: AuthStorage): boolean;
|
|
34
37
|
search(params: SearchParams): Promise<SearchResponse>;
|
|
35
38
|
}
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
*
|
|
25
25
|
* Reference: https://docs.searxng.org/dev/search_api.html
|
|
26
26
|
*/
|
|
27
|
+
import type { AuthStorage } from "@oh-my-pi/pi-ai";
|
|
27
28
|
import type { SearchResponse } from "../../../web/search/types";
|
|
28
29
|
import type { SearchParams } from "./base";
|
|
29
30
|
import { SearchProvider } from "./base";
|
|
@@ -38,6 +39,6 @@ export declare function searchSearXNG(params: {
|
|
|
38
39
|
export declare class SearXNGProvider extends SearchProvider {
|
|
39
40
|
readonly id = "searxng";
|
|
40
41
|
readonly label = "SearXNG";
|
|
41
|
-
isAvailable(): boolean;
|
|
42
|
+
isAvailable(_authStorage: AuthStorage): boolean;
|
|
42
43
|
search(params: SearchParams): Promise<SearchResponse>;
|
|
43
44
|
}
|