@apmantza/greedysearch-pi 1.9.2 → 2.1.2
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 +132 -2
- package/README.md +82 -47
- package/bin/cdp.mjs +1153 -1108
- package/bin/launch.mjs +9 -0
- package/bin/search.mjs +318 -81
- package/extractors/bing-copilot.mjs +48 -18
- package/extractors/chatgpt.mjs +553 -0
- package/extractors/common.mjs +213 -22
- package/extractors/consensus.mjs +655 -0
- package/extractors/consent.mjs +182 -18
- package/extractors/gemini.mjs +350 -217
- package/extractors/google-ai.mjs +129 -128
- package/extractors/logically.mjs +629 -0
- package/extractors/perplexity.mjs +547 -217
- package/extractors/selectors.mjs +3 -2
- package/extractors/semantic-scholar.mjs +219 -0
- package/package.json +8 -4
- package/skills/greedy-search/skill.md +20 -12
- package/src/fetcher.mjs +23 -1
- package/src/formatters/results.ts +185 -128
- package/src/search/browser-lifecycle.mjs +27 -5
- package/src/search/challenge-detect.mjs +205 -0
- package/src/search/chrome.mjs +653 -590
- package/src/search/constants.mjs +155 -39
- package/src/search/engines.mjs +114 -76
- package/src/search/fetch-source.mjs +566 -451
- package/src/search/pdf.mjs +68 -0
- package/src/search/progress.mjs +145 -0
- package/src/search/recovery.mjs +73 -45
- package/src/search/research.mjs +1419 -62
- package/src/search/scale-aware.mjs +93 -0
- package/src/search/simple-research.mjs +520 -0
- package/src/search/sources.mjs +52 -22
- package/src/search/synthesis-runner.mjs +105 -26
- package/src/search/synthesis.mjs +286 -246
- package/src/tools/greedy-search-handler.ts +129 -59
- package/src/tools/shared.ts +312 -186
- package/src/types.ts +110 -104
- package/test.mjs +537 -18
package/src/types.ts
CHANGED
|
@@ -1,104 +1,110 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TypeScript interfaces for GreedySearch data structures
|
|
3
|
-
*
|
|
4
|
-
* These types document the shape of data flowing between modules.
|
|
5
|
-
* They can be imported by TypeScript files (index.ts, tool handlers, formatters)
|
|
6
|
-
* and used for type safety without runtime overhead.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
// ============================================================================
|
|
10
|
-
// Search Result Types
|
|
11
|
-
// ============================================================================
|
|
12
|
-
|
|
13
|
-
/** A single source extracted from search results */
|
|
14
|
-
export interface Source {
|
|
15
|
-
url: string;
|
|
16
|
-
title: string;
|
|
17
|
-
type?:
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
//
|
|
57
|
-
//
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
export interface
|
|
79
|
-
content: Array<{ type: "text"; text: string }>;
|
|
80
|
-
details:
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript interfaces for GreedySearch data structures
|
|
3
|
+
*
|
|
4
|
+
* These types document the shape of data flowing between modules.
|
|
5
|
+
* They can be imported by TypeScript files (index.ts, tool handlers, formatters)
|
|
6
|
+
* and used for type safety without runtime overhead.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
// ============================================================================
|
|
10
|
+
// Search Result Types
|
|
11
|
+
// ============================================================================
|
|
12
|
+
|
|
13
|
+
/** A single source extracted from search results */
|
|
14
|
+
export interface Source {
|
|
15
|
+
url: string;
|
|
16
|
+
title: string;
|
|
17
|
+
type?:
|
|
18
|
+
| "official-docs"
|
|
19
|
+
| "maintainer-blog"
|
|
20
|
+
| "repo"
|
|
21
|
+
| "academic"
|
|
22
|
+
| "community"
|
|
23
|
+
| "website";
|
|
24
|
+
domain?: string;
|
|
25
|
+
snippet?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Result from a single search engine */
|
|
29
|
+
export interface SearchResult {
|
|
30
|
+
engine: string;
|
|
31
|
+
answer: string;
|
|
32
|
+
sources: Source[];
|
|
33
|
+
url?: string;
|
|
34
|
+
query?: string;
|
|
35
|
+
error?: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** Synthesis result combining multiple engine results */
|
|
39
|
+
export interface SynthesisResult {
|
|
40
|
+
answer: string;
|
|
41
|
+
agreementLevel?: "consensus" | "majority" | "mixed" | "conflicting";
|
|
42
|
+
claims?: Claim[];
|
|
43
|
+
sourceIds?: string[];
|
|
44
|
+
confidence?: ConfidenceMetrics;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** A single claim within a synthesis */
|
|
48
|
+
export interface Claim {
|
|
49
|
+
text: string;
|
|
50
|
+
sourceIds: string[];
|
|
51
|
+
confidence?: "high" | "medium" | "low";
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** Confidence metrics for a synthesis */
|
|
55
|
+
export interface ConfidenceMetrics {
|
|
56
|
+
overall: number; // 0-1
|
|
57
|
+
consensus: number; // fraction of engines agreeing
|
|
58
|
+
sourceCount: number;
|
|
59
|
+
engineCount: number;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// ============================================================================
|
|
63
|
+
// Source Registry Types
|
|
64
|
+
// ============================================================================
|
|
65
|
+
|
|
66
|
+
/** A classified source in the registry */
|
|
67
|
+
export interface ClassifiedSource extends Source {
|
|
68
|
+
engineOrigin: string[];
|
|
69
|
+
isOfficial: boolean;
|
|
70
|
+
consensus: number; // fraction of engines citing this source
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// ============================================================================
|
|
74
|
+
// Tool Result Types
|
|
75
|
+
// ============================================================================
|
|
76
|
+
|
|
77
|
+
/** Progress update sent via onUpdate during long-running searches */
|
|
78
|
+
export interface ProgressUpdate {
|
|
79
|
+
content: Array<{ type: "text"; text: string }>;
|
|
80
|
+
details: { _progress: true };
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** Pi tool result format */
|
|
84
|
+
export interface ToolResult {
|
|
85
|
+
content: Array<{ type: "text"; text: string }>;
|
|
86
|
+
details: Record<string, unknown>;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// ============================================================================
|
|
90
|
+
// Engine Configuration Types
|
|
91
|
+
// ============================================================================
|
|
92
|
+
|
|
93
|
+
/** Engine definition for the ENGINES map */
|
|
94
|
+
export interface EngineConfig {
|
|
95
|
+
/** Extractor script filename (e.g. "perplexity.mjs") */
|
|
96
|
+
script: string;
|
|
97
|
+
/** Human-readable label for progress messages */
|
|
98
|
+
label: string;
|
|
99
|
+
/** Domain pattern for source matching */
|
|
100
|
+
domain: string;
|
|
101
|
+
/** URL pattern for the engine */
|
|
102
|
+
url: string;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// ============================================================================
|
|
106
|
+
// Constants
|
|
107
|
+
// ============================================================================
|
|
108
|
+
|
|
109
|
+
// Runtime defaults are in src/search/defaults.mjs (since .ts files can't be
|
|
110
|
+
// imported directly by Node.js). Import DEFAULTS from there for runtime values.
|