@apmantza/greedysearch-pi 1.4.1 → 1.4.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/README.md +219 -208
- package/cdp.mjs +16 -16
- package/extractors/bing-copilot.mjs +12 -21
- package/extractors/consent.mjs +10 -3
- package/extractors/gemini.mjs +12 -53
- package/extractors/google-ai.mjs +7 -10
- package/extractors/perplexity.mjs +28 -31
- package/extractors/selectors.mjs +52 -52
- package/index.ts +623 -623
- package/launch.mjs +33 -33
- package/newfeaturesideas.md +105 -0
- package/package.json +1 -1
- package/skills/greedy-search/SKILL.md +145 -145
- package/test.sh +298 -298
package/launch.mjs
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
// the "Allow remote debugging?" dialog entirely. It runs on port 9222 so it doesn't
|
|
6
6
|
// conflict with your main Chrome session (which may use port 9223).
|
|
7
7
|
//
|
|
8
|
-
// search.mjs passes CDP_PROFILE_DIR so cdp.mjs targets this dedicated Chrome
|
|
9
|
-
// without ever touching the user's main Chrome DevToolsActivePort file.
|
|
8
|
+
// search.mjs passes CDP_PROFILE_DIR so cdp.mjs targets this dedicated Chrome
|
|
9
|
+
// without ever touching the user's main Chrome DevToolsActivePort file.
|
|
10
10
|
//
|
|
11
11
|
// Usage:
|
|
12
12
|
// node launch.mjs — launch (or report if already running)
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
// node launch.mjs --status — check if running
|
|
15
15
|
|
|
16
16
|
import { spawn } from 'child_process';
|
|
17
|
-
import { existsSync, writeFileSync, readFileSync, mkdirSync, unlinkSync } from 'fs';
|
|
18
|
-
import { tmpdir, platform } from 'os';
|
|
17
|
+
import { existsSync, writeFileSync, readFileSync, mkdirSync, unlinkSync } from 'fs';
|
|
18
|
+
import { tmpdir, platform } from 'os';
|
|
19
19
|
import { join } from 'path';
|
|
20
20
|
import http from 'http';
|
|
21
21
|
|
|
@@ -42,8 +42,8 @@ function findChrome() {
|
|
|
42
42
|
return candidates.find(existsSync) || null;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
const CHROME_FLAGS = [
|
|
46
|
-
`--remote-debugging-port=${PORT}`,
|
|
45
|
+
const CHROME_FLAGS = [
|
|
46
|
+
`--remote-debugging-port=${PORT}`,
|
|
47
47
|
'--disable-features=DevToolsPrivacyUI', // suppresses "Allow remote debugging?" dialog
|
|
48
48
|
'--no-first-run',
|
|
49
49
|
'--no-default-browser-check',
|
|
@@ -97,21 +97,21 @@ async function writePortFile(timeoutMs = 15000) {
|
|
|
97
97
|
return false;
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
// ---------------------------------------------------------------------------
|
|
100
|
+
// ---------------------------------------------------------------------------
|
|
101
101
|
|
|
102
102
|
async function main() {
|
|
103
103
|
const arg = process.argv[2];
|
|
104
104
|
|
|
105
|
-
if (arg === '--kill') {
|
|
106
|
-
const pid = isRunning();
|
|
107
|
-
if (pid) {
|
|
108
|
-
try { process.kill(pid, 'SIGTERM'); console.log(`Stopped Chrome (pid ${pid}).`); }
|
|
109
|
-
catch (e) { console.error(`Failed: ${e.message}`); }
|
|
110
|
-
} else {
|
|
111
|
-
console.log('GreedySearch Chrome is not running.');
|
|
112
|
-
}
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
105
|
+
if (arg === '--kill') {
|
|
106
|
+
const pid = isRunning();
|
|
107
|
+
if (pid) {
|
|
108
|
+
try { process.kill(pid, 'SIGTERM'); console.log(`Stopped Chrome (pid ${pid}).`); }
|
|
109
|
+
catch (e) { console.error(`Failed: ${e.message}`); }
|
|
110
|
+
} else {
|
|
111
|
+
console.log('GreedySearch Chrome is not running.');
|
|
112
|
+
}
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
115
|
|
|
116
116
|
if (arg === '--status') {
|
|
117
117
|
const pid = isRunning();
|
|
@@ -123,12 +123,12 @@ async function main() {
|
|
|
123
123
|
// Already running?
|
|
124
124
|
const existing = isRunning();
|
|
125
125
|
if (existing) {
|
|
126
|
-
const ready = await writePortFile(5000);
|
|
127
|
-
if (ready) {
|
|
128
|
-
console.log(`GreedySearch Chrome already running (pid ${existing}, port ${PORT}).`);
|
|
129
|
-
console.log('Dedicated GreedySearch DevToolsActivePort is ready.');
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
126
|
+
const ready = await writePortFile(5000);
|
|
127
|
+
if (ready) {
|
|
128
|
+
console.log(`GreedySearch Chrome already running (pid ${existing}, port ${PORT}).`);
|
|
129
|
+
console.log('Dedicated GreedySearch DevToolsActivePort is ready.');
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
132
|
// Stale PID — process alive but not Chrome on port 9223. Fall through to fresh launch.
|
|
133
133
|
console.log(`Stale PID ${existing} detected (not Chrome on port ${PORT}) — launching fresh.`);
|
|
134
134
|
try { unlinkSync(PID_FILE); } catch {}
|
|
@@ -152,15 +152,15 @@ async function main() {
|
|
|
152
152
|
proc.unref();
|
|
153
153
|
writeFileSync(PID_FILE, String(proc.pid));
|
|
154
154
|
|
|
155
|
-
// Wait for Chrome HTTP endpoint and build the dedicated DevToolsActivePort file
|
|
156
|
-
const portFileReady = await writePortFile();
|
|
157
|
-
if (!portFileReady) {
|
|
158
|
-
console.error('Chrome did not become ready within 15s.');
|
|
159
|
-
process.exit(1);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
console.log(`Ready. No more "Allow remote debugging?" dialogs.`);
|
|
163
|
-
console.log('GreedySearch now uses its own isolated DevToolsActivePort file.');
|
|
164
|
-
}
|
|
155
|
+
// Wait for Chrome HTTP endpoint and build the dedicated DevToolsActivePort file
|
|
156
|
+
const portFileReady = await writePortFile();
|
|
157
|
+
if (!portFileReady) {
|
|
158
|
+
console.error('Chrome did not become ready within 15s.');
|
|
159
|
+
process.exit(1);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
console.log(`Ready. No more "Allow remote debugging?" dialogs.`);
|
|
163
|
+
console.log('GreedySearch now uses its own isolated DevToolsActivePort file.');
|
|
164
|
+
}
|
|
165
165
|
|
|
166
166
|
main();
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# New Feature Ideas
|
|
2
|
+
|
|
3
|
+
Ideas for future features — thinking from the perspective of an AI assistant using these tools.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 1. Source Verification
|
|
8
|
+
|
|
9
|
+
**Problem:** I get sources but can't verify if they're live, updated, or actually support the claimed content.
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
verify_sources({ urls: ["https://...", "https://..."] })
|
|
13
|
+
→ [{ url, status: 200, title, snippet, lastModified, claim: "supports X" }]
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
**Use cases:**
|
|
17
|
+
- Before citing a source, verify it's not 404
|
|
18
|
+
- Check if a page actually contains the claimed information
|
|
19
|
+
- Get last-modified dates to assess freshness
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## 2. Incremental / Continuation Research
|
|
24
|
+
|
|
25
|
+
**Problem:** After deep_research on "RAG vs fine-tuning", going deeper on just RAG means re-running everything with a new query and losing original context.
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
deep_research({ query: "RAG vs fine-tuning", ... }) // initial
|
|
29
|
+
continue_research({ previousId: "...", query: "production RAG architectures" }) // goes deeper on RAG
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
**Use cases:**
|
|
33
|
+
- Drill into a specific aspect after initial broad research
|
|
34
|
+
- Build on previous results without re-fetching everything
|
|
35
|
+
- Progressive disclosure of complex topics
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## 3. Multi-Query Synthesis
|
|
40
|
+
|
|
41
|
+
**Problem:** One query isn't enough for complex research. I chain multiple greedy_search calls manually.
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
multi_research({
|
|
45
|
+
queries: ["auth best practices", "NextAuth vs Clerk vs Lucia", "Next.js auth security"],
|
|
46
|
+
synthesize: true
|
|
47
|
+
})
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
**Use cases:**
|
|
51
|
+
- "Best auth for Next.js" needs multiple angles
|
|
52
|
+
- Research with different facets (comparison, security, performance)
|
|
53
|
+
- Casting a wider net when single query returns narrow results
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## 4. Structured Extraction
|
|
58
|
+
|
|
59
|
+
**Problem:** When researching "which libraries are maintained", I want tables (name, stars, last commit, license), not prose.
|
|
60
|
+
|
|
61
|
+
```
|
|
62
|
+
extract_structured({
|
|
63
|
+
query: "Python HTTP client libraries 2026",
|
|
64
|
+
schema: { name: "string", stars: "number", lastUpdated: "date", async: "boolean" }
|
|
65
|
+
})
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
**Use cases:**
|
|
69
|
+
- Library comparisons as structured data
|
|
70
|
+
- Dependency audits
|
|
71
|
+
- Feature matrices for tools/frameworks
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## 5. Confidence Scoring on Specific Claims
|
|
76
|
+
|
|
77
|
+
**Problem:** I say "high confidence" but it's hand-wavy. What if I could ask: "how confident are we that library X is actively maintained?"
|
|
78
|
+
|
|
79
|
+
```
|
|
80
|
+
verify_claim({
|
|
81
|
+
claim: "Prisma is actively maintained",
|
|
82
|
+
evidence: ["last commit: 2 weeks ago", "open issues: 45", "npm downloads: 2M/week"]
|
|
83
|
+
})
|
|
84
|
+
→ { confidence: 0.95, reasoning: "..." }
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## 6. Research Cache / History
|
|
90
|
+
|
|
91
|
+
**Problem:** I do expensive deep_research, then the user asks a follow-up. I have to re-run everything.
|
|
92
|
+
|
|
93
|
+
```
|
|
94
|
+
get_research(id: "...") // retrieve previous results
|
|
95
|
+
list_research({ query: "RAG" }) // find related previous research
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## Priority
|
|
101
|
+
|
|
102
|
+
1. **Source verification** — high value, relatively simple, fixes trust gap
|
|
103
|
+
2. **Multi-query synthesis** — high value, complex but powerful
|
|
104
|
+
3. **Incremental research** — medium value, nice UX improvement
|
|
105
|
+
4. **Structured extraction** — medium value, specialized use cases
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apmantza/greedysearch-pi",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.2",
|
|
4
4
|
"description": "Pi extension: browser-automation tool that searches Perplexity, Bing Copilot, and Google AI in parallel, extracts answers and sources via CDP, with optional Gemini synthesis — grounded AI answers from real browser interactions.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -1,145 +1,145 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: greedy-search
|
|
3
|
-
description: Multi-engine AI web search — greedy_search, deep_research, and coding_task. Use for high-quality research where training data may be stale or single-engine results are insufficient.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# GreedySearch Tools
|
|
7
|
-
|
|
8
|
-
## Tool Overview
|
|
9
|
-
|
|
10
|
-
| Tool | Speed | Use for |
|
|
11
|
-
|------|-------|---------|
|
|
12
|
-
| `greedy_search` | 15-90s | Quick lookups, comparisons, debugging errors |
|
|
13
|
-
| `deep_research` | 60-120s | Architecture decisions, thorough research, source-backed answers |
|
|
14
|
-
| `coding_task` | 60-180s | Second opinions on code, reviews, debugging tricky issues |
|
|
15
|
-
|
|
16
|
-
## When to Use Which
|
|
17
|
-
|
|
18
|
-
- **`greedy_search`** — Default. Fast enough for most things. Use when you need current info.
|
|
19
|
-
- **`deep_research`** — When the answer *matters*. Gives you a structured document with confidence scores, deduplicated sources ranked by consensus, Gemini synthesis, AND actual content from top sources.
|
|
20
|
-
- **`coding_task`** — When you need a "second opinion" on hard problems. Best for `debug` and `plan` modes on tricky issues.
|
|
21
|
-
|
|
22
|
-
---
|
|
23
|
-
|
|
24
|
-
# greedy_search
|
|
25
|
-
|
|
26
|
-
Multi-engine AI web search with streaming progress.
|
|
27
|
-
|
|
28
|
-
```greedy_search({ query: "what changed in React 19", engine: "all" })```
|
|
29
|
-
|
|
30
|
-
| Parameter | Type | Default | Description |
|
|
31
|
-
|-----------|------|---------|-------------|
|
|
32
|
-
| `query` | string | required | The search question |
|
|
33
|
-
| `engine` | string | `"all"` | `all`, `perplexity`, `bing`, `google`, `gemini` |
|
|
34
|
-
| `synthesize` | boolean | `false` | Synthesize via Gemini |
|
|
35
|
-
| `fullAnswer` | boolean | `false` | Complete answer vs ~300 char summary |
|
|
36
|
-
|
|
37
|
-
**When to use:** Quick lookups, error messages, comparing tools, "what's new in X".
|
|
38
|
-
|
|
39
|
-
---
|
|
40
|
-
|
|
41
|
-
# deep_research
|
|
42
|
-
|
|
43
|
-
Comprehensive research with source fetching and synthesis. Returns a structured document.
|
|
44
|
-
|
|
45
|
-
```deep_research({ query: "RAG vs fine-tuning for production" })```
|
|
46
|
-
|
|
47
|
-
Returns:
|
|
48
|
-
- Full answers from all 3 engines (Perplexity, Bing, Google)
|
|
49
|
-
- Gemini synthesis combining all perspectives
|
|
50
|
-
- Deduplicated sources ranked by consensus (3/3 > 2/3 > 1/3)
|
|
51
|
-
- Fetched content from top 5 sources (no CDP — uses native fetch)
|
|
52
|
-
- Confidence metadata (which engines responded, consensus score)
|
|
53
|
-
|
|
54
|
-
**When to use:** Architecture decisions, "which library should I use", research for a writeup, anything where you need source-backed confidence.
|
|
55
|
-
|
|
56
|
-
---
|
|
57
|
-
|
|
58
|
-
# coding_task
|
|
59
|
-
|
|
60
|
-
Browser-based coding assistant using Gemini and/or Copilot.
|
|
61
|
-
|
|
62
|
-
```coding_task({ task: "debug this race condition", mode: "debug", engine: "all" })```
|
|
63
|
-
|
|
64
|
-
| Parameter | Type | Default | Description |
|
|
65
|
-
|-----------|------|---------|-------------|
|
|
66
|
-
| `task` | string | required | The coding task/question |
|
|
67
|
-
| `engine` | string | `"gemini"` | `gemini`, `copilot`, or `all` |
|
|
68
|
-
| `mode` | string | `"code"` | See modes below |
|
|
69
|
-
| `context` | string | — | Code snippet to include |
|
|
70
|
-
|
|
71
|
-
**Modes:**
|
|
72
|
-
|
|
73
|
-
| Mode | Use when |
|
|
74
|
-
|------|----------|
|
|
75
|
-
| `debug` | Stuck on a tricky bug. Fresh eyes catch different failure modes. |
|
|
76
|
-
| `plan` | About to refactor something big. Gemini plays devil's advocate. |
|
|
77
|
-
| `review` | Code review before merge. High-stakes code benefits from second opinion. |
|
|
78
|
-
| `test` | Need edge cases the author missed. |
|
|
79
|
-
| `code` | Just need the code written (but you can probably do this yourself faster). |
|
|
80
|
-
|
|
81
|
-
**When to use:** Debugging tricky issues, planning major refactors, security-critical reviews. **Skip for** simple code generation — you're faster.
|
|
82
|
-
|
|
83
|
-
## Greedy Search vs Built-in Web Search
|
|
84
|
-
|
|
85
|
-
| | `web_search` | `greedy_search` |
|
|
86
|
-
|---|---|---|
|
|
87
|
-
| Speed | Instant (~2s) | 15-60s (one engine) / 30-90s (all engines) |
|
|
88
|
-
| Quality | Good for simple lookups | Higher — 3 AI engines cross-verify |
|
|
89
|
-
| Synthesis | Single engine answer | Optional Gemini synthesis (cleanest answer) |
|
|
90
|
-
| Use for | Quick facts, simple questions | Research, decisions, complex topics |
|
|
91
|
-
|
|
92
|
-
**Rule of thumb:** Use `web_search` for quick facts. Use `greedy_search` when the answer matters — architecture decisions, comparing libraries, understanding new releases, debugging tricky errors.
|
|
93
|
-
|
|
94
|
-
## When to Use
|
|
95
|
-
|
|
96
|
-
- **Version-specific changes** — "What changed in React 19?" / "Breaking changes in FastAPI 0.100"
|
|
97
|
-
- **Choosing between tools** — "Prisma vs Drizzle in 2026" / "Best auth library for Next.js 15"
|
|
98
|
-
- **Debugging** — User pastes an error message or stack trace
|
|
99
|
-
- **Research tasks** — When you need to synthesize information from multiple sources
|
|
100
|
-
- **Best practices** — "How to structure a monorepo" / "Auth patterns for SaaS"
|
|
101
|
-
- **Anything where training data might be stale** — 2025+, 2026+, "latest", "current", "still maintained"
|
|
102
|
-
|
|
103
|
-
## Engine Selection
|
|
104
|
-
|
|
105
|
-
```greedy_search({ query: "what changed in React 19", engine: "all" })```
|
|
106
|
-
|
|
107
|
-
| Engine | Latency | Best for |
|
|
108
|
-
|---|---|---|
|
|
109
|
-
| `all` (default) | 30-90s | Highest confidence — all 3 engines in parallel |
|
|
110
|
-
| `perplexity` | 15-30s | Technical Q&A, code explanations, documentation |
|
|
111
|
-
| `bing` | 15-30s | Recent news, Microsoft ecosystem |
|
|
112
|
-
| `google` | 15-30s | Broad coverage, multiple perspectives |
|
|
113
|
-
| `gemini` | 15-30s | Google's perspective, different training data |
|
|
114
|
-
|
|
115
|
-
Use a single engine when speed matters and the question isn't contentious.
|
|
116
|
-
|
|
117
|
-
## Synthesis Mode
|
|
118
|
-
|
|
119
|
-
For complex research questions, use `synthesize: true` with `engine: "all"`:
|
|
120
|
-
|
|
121
|
-
```greedy_search({ query: "best auth patterns for SaaS in 2026", engine: "all", synthesize: true })```
|
|
122
|
-
|
|
123
|
-
This deduplicates sources across engines and feeds them to Gemini for one clean, synthesized answer. Adds ~30s but produces the highest quality output — ideal for research tasks where you'd otherwise need to parse 3 separate answers.
|
|
124
|
-
|
|
125
|
-
Use synthesis when:
|
|
126
|
-
- You need one definitive answer, not multiple perspectives
|
|
127
|
-
- You're researching a topic to write about or make a decision
|
|
128
|
-
- The question has a lot of noise and you want the signal
|
|
129
|
-
|
|
130
|
-
Skip synthesis when:
|
|
131
|
-
- You want to see where engines disagree (useful for controversial topics)
|
|
132
|
-
- Speed matters
|
|
133
|
-
|
|
134
|
-
## Full vs Short Answers
|
|
135
|
-
|
|
136
|
-
Default mode returns ~300 char summaries to save tokens. Use `fullAnswer: true` when you need the complete response:
|
|
137
|
-
|
|
138
|
-
```greedy_search({ query: "explain the React compiler", engine: "perplexity", fullAnswer: true })```
|
|
139
|
-
|
|
140
|
-
## Interpreting Results
|
|
141
|
-
|
|
142
|
-
- **All 3 agree** → High confidence, present as fact
|
|
143
|
-
- **2 agree, 1 differs** → Likely correct but note the dissent
|
|
144
|
-
- **All differ** → Present the different perspectives to the user
|
|
145
|
-
- **Sources with `[3/3]` or `[2/3]`** → Cited by multiple engines, higher confidence
|
|
1
|
+
---
|
|
2
|
+
name: greedy-search
|
|
3
|
+
description: Multi-engine AI web search — greedy_search, deep_research, and coding_task. Use for high-quality research where training data may be stale or single-engine results are insufficient.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# GreedySearch Tools
|
|
7
|
+
|
|
8
|
+
## Tool Overview
|
|
9
|
+
|
|
10
|
+
| Tool | Speed | Use for |
|
|
11
|
+
|------|-------|---------|
|
|
12
|
+
| `greedy_search` | 15-90s | Quick lookups, comparisons, debugging errors |
|
|
13
|
+
| `deep_research` | 60-120s | Architecture decisions, thorough research, source-backed answers |
|
|
14
|
+
| `coding_task` | 60-180s | Second opinions on code, reviews, debugging tricky issues |
|
|
15
|
+
|
|
16
|
+
## When to Use Which
|
|
17
|
+
|
|
18
|
+
- **`greedy_search`** — Default. Fast enough for most things. Use when you need current info.
|
|
19
|
+
- **`deep_research`** — When the answer *matters*. Gives you a structured document with confidence scores, deduplicated sources ranked by consensus, Gemini synthesis, AND actual content from top sources.
|
|
20
|
+
- **`coding_task`** — When you need a "second opinion" on hard problems. Best for `debug` and `plan` modes on tricky issues.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
# greedy_search
|
|
25
|
+
|
|
26
|
+
Multi-engine AI web search with streaming progress.
|
|
27
|
+
|
|
28
|
+
```greedy_search({ query: "what changed in React 19", engine: "all" })```
|
|
29
|
+
|
|
30
|
+
| Parameter | Type | Default | Description |
|
|
31
|
+
|-----------|------|---------|-------------|
|
|
32
|
+
| `query` | string | required | The search question |
|
|
33
|
+
| `engine` | string | `"all"` | `all`, `perplexity`, `bing`, `google`, `gemini` |
|
|
34
|
+
| `synthesize` | boolean | `false` | Synthesize via Gemini |
|
|
35
|
+
| `fullAnswer` | boolean | `false` | Complete answer vs ~300 char summary |
|
|
36
|
+
|
|
37
|
+
**When to use:** Quick lookups, error messages, comparing tools, "what's new in X".
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
# deep_research
|
|
42
|
+
|
|
43
|
+
Comprehensive research with source fetching and synthesis. Returns a structured document.
|
|
44
|
+
|
|
45
|
+
```deep_research({ query: "RAG vs fine-tuning for production" })```
|
|
46
|
+
|
|
47
|
+
Returns:
|
|
48
|
+
- Full answers from all 3 engines (Perplexity, Bing, Google)
|
|
49
|
+
- Gemini synthesis combining all perspectives
|
|
50
|
+
- Deduplicated sources ranked by consensus (3/3 > 2/3 > 1/3)
|
|
51
|
+
- Fetched content from top 5 sources (no CDP — uses native fetch)
|
|
52
|
+
- Confidence metadata (which engines responded, consensus score)
|
|
53
|
+
|
|
54
|
+
**When to use:** Architecture decisions, "which library should I use", research for a writeup, anything where you need source-backed confidence.
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
# coding_task
|
|
59
|
+
|
|
60
|
+
Browser-based coding assistant using Gemini and/or Copilot.
|
|
61
|
+
|
|
62
|
+
```coding_task({ task: "debug this race condition", mode: "debug", engine: "all" })```
|
|
63
|
+
|
|
64
|
+
| Parameter | Type | Default | Description |
|
|
65
|
+
|-----------|------|---------|-------------|
|
|
66
|
+
| `task` | string | required | The coding task/question |
|
|
67
|
+
| `engine` | string | `"gemini"` | `gemini`, `copilot`, or `all` |
|
|
68
|
+
| `mode` | string | `"code"` | See modes below |
|
|
69
|
+
| `context` | string | — | Code snippet to include |
|
|
70
|
+
|
|
71
|
+
**Modes:**
|
|
72
|
+
|
|
73
|
+
| Mode | Use when |
|
|
74
|
+
|------|----------|
|
|
75
|
+
| `debug` | Stuck on a tricky bug. Fresh eyes catch different failure modes. |
|
|
76
|
+
| `plan` | About to refactor something big. Gemini plays devil's advocate. |
|
|
77
|
+
| `review` | Code review before merge. High-stakes code benefits from second opinion. |
|
|
78
|
+
| `test` | Need edge cases the author missed. |
|
|
79
|
+
| `code` | Just need the code written (but you can probably do this yourself faster). |
|
|
80
|
+
|
|
81
|
+
**When to use:** Debugging tricky issues, planning major refactors, security-critical reviews. **Skip for** simple code generation — you're faster.
|
|
82
|
+
|
|
83
|
+
## Greedy Search vs Built-in Web Search
|
|
84
|
+
|
|
85
|
+
| | `web_search` | `greedy_search` |
|
|
86
|
+
|---|---|---|
|
|
87
|
+
| Speed | Instant (~2s) | 15-60s (one engine) / 30-90s (all engines) |
|
|
88
|
+
| Quality | Good for simple lookups | Higher — 3 AI engines cross-verify |
|
|
89
|
+
| Synthesis | Single engine answer | Optional Gemini synthesis (cleanest answer) |
|
|
90
|
+
| Use for | Quick facts, simple questions | Research, decisions, complex topics |
|
|
91
|
+
|
|
92
|
+
**Rule of thumb:** Use `web_search` for quick facts. Use `greedy_search` when the answer matters — architecture decisions, comparing libraries, understanding new releases, debugging tricky errors.
|
|
93
|
+
|
|
94
|
+
## When to Use
|
|
95
|
+
|
|
96
|
+
- **Version-specific changes** — "What changed in React 19?" / "Breaking changes in FastAPI 0.100"
|
|
97
|
+
- **Choosing between tools** — "Prisma vs Drizzle in 2026" / "Best auth library for Next.js 15"
|
|
98
|
+
- **Debugging** — User pastes an error message or stack trace
|
|
99
|
+
- **Research tasks** — When you need to synthesize information from multiple sources
|
|
100
|
+
- **Best practices** — "How to structure a monorepo" / "Auth patterns for SaaS"
|
|
101
|
+
- **Anything where training data might be stale** — 2025+, 2026+, "latest", "current", "still maintained"
|
|
102
|
+
|
|
103
|
+
## Engine Selection
|
|
104
|
+
|
|
105
|
+
```greedy_search({ query: "what changed in React 19", engine: "all" })```
|
|
106
|
+
|
|
107
|
+
| Engine | Latency | Best for |
|
|
108
|
+
|---|---|---|
|
|
109
|
+
| `all` (default) | 30-90s | Highest confidence — all 3 engines in parallel |
|
|
110
|
+
| `perplexity` | 15-30s | Technical Q&A, code explanations, documentation |
|
|
111
|
+
| `bing` | 15-30s | Recent news, Microsoft ecosystem |
|
|
112
|
+
| `google` | 15-30s | Broad coverage, multiple perspectives |
|
|
113
|
+
| `gemini` | 15-30s | Google's perspective, different training data |
|
|
114
|
+
|
|
115
|
+
Use a single engine when speed matters and the question isn't contentious.
|
|
116
|
+
|
|
117
|
+
## Synthesis Mode
|
|
118
|
+
|
|
119
|
+
For complex research questions, use `synthesize: true` with `engine: "all"`:
|
|
120
|
+
|
|
121
|
+
```greedy_search({ query: "best auth patterns for SaaS in 2026", engine: "all", synthesize: true })```
|
|
122
|
+
|
|
123
|
+
This deduplicates sources across engines and feeds them to Gemini for one clean, synthesized answer. Adds ~30s but produces the highest quality output — ideal for research tasks where you'd otherwise need to parse 3 separate answers.
|
|
124
|
+
|
|
125
|
+
Use synthesis when:
|
|
126
|
+
- You need one definitive answer, not multiple perspectives
|
|
127
|
+
- You're researching a topic to write about or make a decision
|
|
128
|
+
- The question has a lot of noise and you want the signal
|
|
129
|
+
|
|
130
|
+
Skip synthesis when:
|
|
131
|
+
- You want to see where engines disagree (useful for controversial topics)
|
|
132
|
+
- Speed matters
|
|
133
|
+
|
|
134
|
+
## Full vs Short Answers
|
|
135
|
+
|
|
136
|
+
Default mode returns ~300 char summaries to save tokens. Use `fullAnswer: true` when you need the complete response:
|
|
137
|
+
|
|
138
|
+
```greedy_search({ query: "explain the React compiler", engine: "perplexity", fullAnswer: true })```
|
|
139
|
+
|
|
140
|
+
## Interpreting Results
|
|
141
|
+
|
|
142
|
+
- **All 3 agree** → High confidence, present as fact
|
|
143
|
+
- **2 agree, 1 differs** → Likely correct but note the dissent
|
|
144
|
+
- **All differ** → Present the different perspectives to the user
|
|
145
|
+
- **Sources with `[3/3]` or `[2/3]`** → Cited by multiple engines, higher confidence
|