@lloyal-labs/rig 1.5.8 → 2.0.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 +72 -44
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/sources/web.d.ts.map +1 -1
- package/dist/sources/web.js +2 -2
- package/dist/sources/web.js.map +1 -1
- package/dist/tools/delegate.d.ts +49 -0
- package/dist/tools/delegate.d.ts.map +1 -0
- package/dist/tools/delegate.js +176 -0
- package/dist/tools/delegate.js.map +1 -0
- package/dist/tools/fetch-page.d.ts +1 -1
- package/dist/tools/fetch-page.d.ts.map +1 -1
- package/dist/tools/fetch-page.js +15 -1
- package/dist/tools/fetch-page.js.map +1 -1
- package/dist/tools/index.d.ts +4 -2
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +4 -1
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/plan.d.ts +41 -21
- package/dist/tools/plan.d.ts.map +1 -1
- package/dist/tools/plan.js +54 -42
- package/dist/tools/plan.js.map +1 -1
- package/dist/tools/web-search.d.ts +1 -1
- package/dist/tools/web-search.d.ts.map +1 -1
- package/dist/tools/web-search.js +37 -6
- package/dist/tools/web-search.js.map +1 -1
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @lloyal-labs/rig
|
|
2
2
|
|
|
3
|
-
Retrieval-Interleaved Generation for [lloyal
|
|
3
|
+
Retrieval-Interleaved Generation for the [lloyal HDK](https://github.com/lloyal-ai/hdk).
|
|
4
4
|
|
|
5
5
|
```bash
|
|
6
6
|
npm i @lloyal-labs/rig @lloyal-labs/lloyal-agents @lloyal-labs/lloyal.node
|
|
@@ -10,7 +10,7 @@ npm i @lloyal-labs/rig @lloyal-labs/lloyal-agents @lloyal-labs/lloyal.node
|
|
|
10
10
|
|
|
11
11
|
RAG retrieves first, then generates. A retrieval step runs upfront — query the vector DB, get top-k passages, inject them into the prompt, call the model once. The model sees static context. Retrieval and generation are separate phases.
|
|
12
12
|
|
|
13
|
-
RIG interleaves retrieval and generation inside the decode loop
|
|
13
|
+
RIG interleaves retrieval and generation **inside the decode loop**. Agents generate reasoning, decide to search, process results, reason further, fetch a page, form hypotheses from the content, search again with refined queries. Retrieval decisions emerge from ongoing generation — each search query is informed by everything the agent has already discovered.
|
|
14
14
|
|
|
15
15
|
The difference is observable in tool call inputs. A RAG system constructs search queries from the original user question. A RIG agent constructs queries from hypotheses formed during generation:
|
|
16
16
|
|
|
@@ -30,7 +30,7 @@ The last search — `"pool drain connection lifecycle interaction"` — is the s
|
|
|
30
30
|
|
|
31
31
|
This behavior is not prompted or engineered. It emerges from the concurrency semantics of `lloyal-agents`.
|
|
32
32
|
|
|
33
|
-
The
|
|
33
|
+
The five-phase tick loop creates a clean decision boundary between each tool call and the next generation step:
|
|
34
34
|
|
|
35
35
|
1. Agent generates tokens, hits stop token, tool call extracted
|
|
36
36
|
2. Tool executes to completion — agent is suspended
|
|
@@ -42,17 +42,15 @@ Step 5 is the critical moment. The model's next-token prediction operates on a c
|
|
|
42
42
|
|
|
43
43
|
An agent that greps with a narrow pattern and gets 0 matches will broaden the pattern on its next grep — not because it's prompted to retry, but because the 0-match result is in context and the model naturally adjusts. An agent that reads a section and discovers an unexpected connection will construct a search query targeting that specific connection — the read result is in context, and the model forms a hypothesis from it.
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
Depth scales with `maxTurns`. At 2 turns, agents do single-shot retrieval. At 6 turns, agents do 3-4 rounds of iterative refinement. At 20 turns, agents go deep — following citation chains, cross-referencing claims, building evidence maps. The quality difference is in the later tool call inputs.
|
|
45
|
+
Depth scales with `maxTurns`. At 2 turns, agents do single-shot retrieval. At 6 turns, agents do 3–4 rounds of iterative refinement. At 20 turns, agents go deep — following citation chains, cross-referencing claims, building evidence maps. The quality difference is in the later tool call inputs.
|
|
48
46
|
|
|
49
47
|
## Sources
|
|
50
48
|
|
|
51
49
|
`@lloyal-labs/rig` provides two `Source` implementations (extending the base class from `lloyal-agents`):
|
|
52
50
|
|
|
53
|
-
|
|
51
|
+
**`CorpusSource`** — local files with grep, semantic search, read_file, and recursive delegation. Agents investigate a knowledge base by pattern matching, reading sections in context, and spawning sub-agents for deeper investigation.
|
|
54
52
|
|
|
55
|
-
|
|
53
|
+
**`WebSource`** — web search via [Tavily](https://tavily.com), page fetching with attention-based content extraction, and recursive delegation. `BufferingFetchPage` wraps fetch results — full content goes to the agent for reasoning, while a parallel buffer stores content for post-research reranking. Content extraction uses an ephemeral fork to attend over the fetched page and extract summary + links via grammar-constrained generation, then prunes the fork — zero net KV cost per extraction.
|
|
56
54
|
|
|
57
55
|
Sources are composable. A pipeline can use one source, both, or custom implementations:
|
|
58
56
|
|
|
@@ -61,20 +59,17 @@ import {
|
|
|
61
59
|
CorpusSource,
|
|
62
60
|
WebSource,
|
|
63
61
|
TavilyProvider,
|
|
64
|
-
loadResources,
|
|
65
|
-
chunkResources,
|
|
66
62
|
} from "@lloyal-labs/rig";
|
|
63
|
+
import { loadResources, chunkResources } from "@lloyal-labs/rig/node";
|
|
67
64
|
|
|
68
65
|
const sources = [];
|
|
69
66
|
|
|
70
|
-
// Local knowledge base
|
|
71
67
|
if (corpusDir) {
|
|
72
68
|
const resources = loadResources(corpusDir);
|
|
73
69
|
const chunks = chunkResources(resources);
|
|
74
70
|
sources.push(new CorpusSource(resources, chunks));
|
|
75
71
|
}
|
|
76
72
|
|
|
77
|
-
// Web search
|
|
78
73
|
if (process.env.TAVILY_API_KEY) {
|
|
79
74
|
sources.push(new WebSource(new TavilyProvider()));
|
|
80
75
|
}
|
|
@@ -82,9 +77,20 @@ if (process.env.TAVILY_API_KEY) {
|
|
|
82
77
|
|
|
83
78
|
When multiple sources are used, they run sequentially — each source gets the full KV budget. After source N completes, its inner branches are pruned and KV is freed for source N+1.
|
|
84
79
|
|
|
80
|
+
### Cross-encoder reranker — four scoring roles
|
|
81
|
+
|
|
82
|
+
The reranker (a small cross-encoder GGUF — Qwen3-Reranker-0.6B is the recommended default) drives an `EntailmentScorer` with four distinct methods:
|
|
83
|
+
|
|
84
|
+
- **`scoreEntailmentBatch`** — texts vs. the original query. Boundary entailment for retrieved content.
|
|
85
|
+
- **`scoreRelevanceBatch`** — dual-score `min(toolQueryScore, originalQueryScore)`. Used in exploit mode when KV pressure tightens focus.
|
|
86
|
+
- **`scoreSimilarityBatch`** — texts vs. an arbitrary reference. Powers echo detection at delegation boundaries (the agent's own task as reference).
|
|
87
|
+
- **`shouldProceed`** — floor gate. Default `_entailmentFloor = 0.25`.
|
|
88
|
+
|
|
89
|
+
One model, four roles. The reranker is RIG infrastructure, not a fetch optimization.
|
|
90
|
+
|
|
85
91
|
### Bridge
|
|
86
92
|
|
|
87
|
-
Between sources, a bridge
|
|
93
|
+
Between sources, a bridge structures discoveries from the completed source as durable context for the next source's investigation:
|
|
88
94
|
|
|
89
95
|
```
|
|
90
96
|
Corpus research → Bridge → Web research → Synthesize
|
|
@@ -93,19 +99,11 @@ Corpus research → Bridge → Web research → Synthesize
|
|
|
93
99
|
The bridge extracts three tiers of discovery:
|
|
94
100
|
|
|
95
101
|
1. **What was established** — specific data points, study details, statistics, quotes. Evidence preserved verbatim.
|
|
96
|
-
2. **Where evidence is incomplete** — acknowledged limitations, absent study designs, uncertain mechanisms.
|
|
102
|
+
2. **Where evidence is incomplete** — acknowledged limitations, absent study designs, uncertain mechanisms. Well-researched claims with identified evidence gaps.
|
|
97
103
|
3. **What was not covered** — topics mentioned but not substantiated, or entirely absent.
|
|
98
104
|
|
|
99
105
|
The distinction between (2) and (3) is critical. A topic with six sections of evidence but no experimental validation is not a gap — it is a well-researched claim with an identified evidence limitation. The bridge flags the limitation, not the topic. This prevents the next source from re-investigating what the previous source already covered, and directs it toward genuine gaps.
|
|
100
106
|
|
|
101
|
-
Bridge discoveries condition the next source's questions:
|
|
102
|
-
|
|
103
|
-
```typescript
|
|
104
|
-
activeQuestions = questions.map(
|
|
105
|
-
(q) => `${q}\n\nPrior research discoveries:\n${discoveries}`,
|
|
106
|
-
);
|
|
107
|
-
```
|
|
108
|
-
|
|
109
107
|
## Pipeline
|
|
110
108
|
|
|
111
109
|
A typical RIG pipeline:
|
|
@@ -114,11 +112,11 @@ A typical RIG pipeline:
|
|
|
114
112
|
Plan → Research → [Bridge →] Synthesize → Eval
|
|
115
113
|
```
|
|
116
114
|
|
|
117
|
-
**Plan.** Grammar-constrained decomposition of the user query into sub-questions with intent classification (`research` vs `clarify`). If the query is focused enough to investigate directly, produces an empty array (passthrough).
|
|
115
|
+
**Plan.** Grammar-constrained decomposition of the user query into sub-questions with intent classification (`research` vs `clarify`). If the query is focused enough to investigate directly, produces an empty array (passthrough). `PlanTool` uses `agent()` with a JSON schema grammar — the model outputs structured `{ questions: [{ text, intent }] }` in a single generation pass.
|
|
118
116
|
|
|
119
|
-
**Research.** Each source's
|
|
117
|
+
**Research.** Each source's tools are passed to an `agentPool` that investigates sub-questions in parallel (or in chain mode, sequentially with spine extension). Agents interleave retrieval and generation — searching, reading, forming hypotheses, searching again. Within each source, all agents run concurrently on shared GPU compute. Sources run sequentially, each getting the full KV budget.
|
|
120
118
|
|
|
121
|
-
Agents that get cut by context pressure (their tool results exceeded KV headroom) are recovered via scratchpad extraction —
|
|
119
|
+
Agents that get cut by context pressure (their tool results exceeded KV headroom) are recovered via scratchpad extraction — a grammar-constrained reporter prompt attends over the agent's accumulated KV and extracts findings. The agent paid the KV cost of reasoning; the extraction recovers the value.
|
|
122
120
|
|
|
123
121
|
**Bridge.** Runs between sources when multiple sources are configured. A single agent with report-only tools structures discoveries from the completed source. The bridge output conditions the next source's sub-questions, directing investigation toward gaps rather than re-covering established ground.
|
|
124
122
|
|
|
@@ -126,6 +124,8 @@ Agents that get cut by context pressure (their tool results exceeded KV headroom
|
|
|
126
124
|
|
|
127
125
|
**Eval.** Multi-branch semantic comparison via `diverge()`. Fork N branches from a shared frontier, generate independently with the same verify prompt, check convergence. Where branches agree, the model is confident. Where they diverge, the answer needs refinement.
|
|
128
126
|
|
|
127
|
+
Full architectural walkthrough: [RIG Pipeline reference](https://docs.lloyal.ai/reference/rig/pipeline).
|
|
128
|
+
|
|
129
129
|
## Tools
|
|
130
130
|
|
|
131
131
|
### Corpus tools
|
|
@@ -135,24 +135,44 @@ Agents that get cut by context pressure (their tool results exceeded KV headroom
|
|
|
135
135
|
| `SearchTool` | Semantic search over corpus chunks via reranker scoring |
|
|
136
136
|
| `GrepTool` | Exhaustive regex pattern matching across all files |
|
|
137
137
|
| `ReadFileTool` | Read file content at specified line ranges, tracks per-agent read state |
|
|
138
|
-
| `ResearchTool` | Spawn sub-agent pool for deeper investigation of sub-questions |
|
|
139
138
|
| `ReportTool` | Terminal tool — agents call this to submit findings |
|
|
140
139
|
|
|
141
140
|
### Web tools
|
|
142
141
|
|
|
143
|
-
| Tool
|
|
144
|
-
|
|
|
145
|
-
| `WebSearchTool`
|
|
146
|
-
| `FetchPageTool`
|
|
147
|
-
| `WebResearchTool` | Spawn sub-agent pool with web tools for recursive investigation |
|
|
142
|
+
| Tool | Description |
|
|
143
|
+
| --------------- | --------------------------------------------------------------- |
|
|
144
|
+
| `WebSearchTool` | Web search via configurable provider (`TavilyProvider` included) |
|
|
145
|
+
| `FetchPageTool` | Fetch URL, extract article text via Readability |
|
|
148
146
|
|
|
149
147
|
### Pipeline tools
|
|
150
148
|
|
|
151
|
-
| Tool
|
|
152
|
-
|
|
|
153
|
-
| `PlanTool`
|
|
154
|
-
| `
|
|
155
|
-
| `
|
|
149
|
+
| Tool | Description |
|
|
150
|
+
| ---------------------- | ---------------------------------------------------------------------------- |
|
|
151
|
+
| `PlanTool` | Grammar-constrained query decomposition with intent classification |
|
|
152
|
+
| `DelegateTool` | Generic recursive-delegation tool — agent calls it to spawn a sub-agent pool |
|
|
153
|
+
| `createTools(opts)` | Build corpus toolkit from resources, chunks, and reranker |
|
|
154
|
+
| `createReranker(path)` | (`/node` subpath) Semantic reranker for chunk scoring and passage selection |
|
|
155
|
+
|
|
156
|
+
### `DelegateTool`
|
|
157
|
+
|
|
158
|
+
`DelegateTool` is the canonical recursive-delegation primitive. It takes a tool name, a sub-task extractor, a system prompt, and pool options — when the agent calls it, the tool spawns an inner `agentPool` with `parent: context.branch` (warm path) so sub-agents inherit the calling agent's full KV state at zero marginal cost.
|
|
159
|
+
|
|
160
|
+
```typescript
|
|
161
|
+
import { DelegateTool, reportTool } from "@lloyal-labs/rig";
|
|
162
|
+
|
|
163
|
+
const delegate = new DelegateTool({
|
|
164
|
+
name: "web_research",
|
|
165
|
+
extractTasks: (a) => a.questions as string[],
|
|
166
|
+
systemPrompt: RESEARCH_PROMPT,
|
|
167
|
+
poolOpts: {
|
|
168
|
+
tools: [...sourceTools, reportTool],
|
|
169
|
+
terminalTool: "report",
|
|
170
|
+
scorer,
|
|
171
|
+
},
|
|
172
|
+
});
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
The agent sees `web_research` (or whatever `name` you give it) as a callable tool. Calling it spawns parallel sub-agents that recurse into the corpus or web. The deeper an investigation goes, the richer the attention state at depth — and the cost of inheritance is zero.
|
|
156
176
|
|
|
157
177
|
## Custom Sources
|
|
158
178
|
|
|
@@ -162,17 +182,19 @@ Extend `Source` from `lloyal-agents` to create custom sources:
|
|
|
162
182
|
import { Source } from "@lloyal-labs/lloyal-agents";
|
|
163
183
|
import type { Tool } from "@lloyal-labs/lloyal-agents";
|
|
164
184
|
|
|
165
|
-
class DatabaseSource extends Source<
|
|
185
|
+
class DatabaseSource extends Source<DatabaseContext, Row> {
|
|
166
186
|
readonly name = "database";
|
|
167
187
|
|
|
168
|
-
get
|
|
169
|
-
return this.
|
|
188
|
+
get tools(): Tool[] {
|
|
189
|
+
return this._tools;
|
|
170
190
|
}
|
|
171
191
|
|
|
172
|
-
*bind(ctx:
|
|
173
|
-
// Set up tools
|
|
174
|
-
|
|
175
|
-
|
|
192
|
+
*bind(ctx: DatabaseContext) {
|
|
193
|
+
// Set up tools, reranker, scorer state
|
|
194
|
+
this._tools = [
|
|
195
|
+
new QueryTool(/* ... */),
|
|
196
|
+
new SchemaInspectTool(/* ... */),
|
|
197
|
+
];
|
|
176
198
|
}
|
|
177
199
|
|
|
178
200
|
getChunks(): Row[] {
|
|
@@ -181,7 +203,13 @@ class DatabaseSource extends Source<SourceContext, Row> {
|
|
|
181
203
|
}
|
|
182
204
|
```
|
|
183
205
|
|
|
184
|
-
The `bind()` lifecycle receives a
|
|
206
|
+
The `bind()` lifecycle receives a context with reranker and scorer plumbing. Your tools call `agentPool` or `useAgent` internally for recursive patterns — same primitives the built-in sources use.
|
|
207
|
+
|
|
208
|
+
See [custom sources](https://docs.lloyal.ai/reference/rig/custom-sources) for the full contract.
|
|
209
|
+
|
|
210
|
+
## Documentation
|
|
211
|
+
|
|
212
|
+
Full positioning, source contract, reranker mechanics, and pipeline patterns at [docs.lloyal.ai](https://docs.lloyal.ai).
|
|
185
213
|
|
|
186
214
|
## License
|
|
187
215
|
|
package/dist/index.d.ts
CHANGED
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
* @packageDocumentation
|
|
11
11
|
* @category Rig
|
|
12
12
|
*/
|
|
13
|
-
export { createTools, reportTool, ReportTool, WebSearchTool, TavilyProvider, FetchPageTool, PlanTool, } from './tools';
|
|
14
|
-
export type { PlanToolOpts, PlanResult,
|
|
13
|
+
export { createTools, reportTool, ReportTool, WebSearchTool, TavilyProvider, FetchPageTool, DelegateTool, PlanTool, taskToContent, } from './tools';
|
|
14
|
+
export type { DelegateToolOpts, PlanToolOpts, PlanResult, PlanIntent, ResearchTask, SearchProvider, SearchResult, Reranker, ScoredChunk, ScoredResult, } from './tools';
|
|
15
15
|
export { WebSource } from './sources/web';
|
|
16
16
|
export type { WebSourceOpts } from './sources/web';
|
|
17
17
|
export { CorpusSource } from './sources/corpus';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EACL,WAAW,EAAE,UAAU,EAAE,UAAU,EACnC,aAAa,EAAE,cAAc,EAAE,aAAa,EAC5C,QAAQ,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EACL,WAAW,EAAE,UAAU,EAAE,UAAU,EACnC,aAAa,EAAE,cAAc,EAAE,aAAa,EAC5C,YAAY,EACZ,QAAQ,EAAE,aAAa,GACxB,MAAM,SAAS,CAAC;AACjB,YAAY,EACV,gBAAgB,EAChB,YAAY,EACZ,UAAU,EAAE,UAAU,EAAE,YAAY,EACpC,cAAc,EAAE,YAAY,EAC5B,QAAQ,EAAE,WAAW,EAAE,YAAY,GACpC,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,YAAY,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAC3E,YAAY,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGrD,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAClE,YAAY,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAGtD,YAAY,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* @category Rig
|
|
13
13
|
*/
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.chunkHtml = exports.chunkFetchedPages = exports.CorpusSource = exports.WebSource = exports.PlanTool = exports.FetchPageTool = exports.TavilyProvider = exports.WebSearchTool = exports.ReportTool = exports.reportTool = exports.createTools = void 0;
|
|
15
|
+
exports.chunkHtml = exports.chunkFetchedPages = exports.CorpusSource = exports.WebSource = exports.taskToContent = exports.PlanTool = exports.DelegateTool = exports.FetchPageTool = exports.TavilyProvider = exports.WebSearchTool = exports.ReportTool = exports.reportTool = exports.createTools = void 0;
|
|
16
16
|
// Tools (pure TS + Effection + linkedom — platform-agnostic)
|
|
17
17
|
var tools_1 = require("./tools");
|
|
18
18
|
Object.defineProperty(exports, "createTools", { enumerable: true, get: function () { return tools_1.createTools; } });
|
|
@@ -21,7 +21,9 @@ Object.defineProperty(exports, "ReportTool", { enumerable: true, get: function (
|
|
|
21
21
|
Object.defineProperty(exports, "WebSearchTool", { enumerable: true, get: function () { return tools_1.WebSearchTool; } });
|
|
22
22
|
Object.defineProperty(exports, "TavilyProvider", { enumerable: true, get: function () { return tools_1.TavilyProvider; } });
|
|
23
23
|
Object.defineProperty(exports, "FetchPageTool", { enumerable: true, get: function () { return tools_1.FetchPageTool; } });
|
|
24
|
+
Object.defineProperty(exports, "DelegateTool", { enumerable: true, get: function () { return tools_1.DelegateTool; } });
|
|
24
25
|
Object.defineProperty(exports, "PlanTool", { enumerable: true, get: function () { return tools_1.PlanTool; } });
|
|
26
|
+
Object.defineProperty(exports, "taskToContent", { enumerable: true, get: function () { return tools_1.taskToContent; } });
|
|
25
27
|
// Sources (platform-agnostic — no node:fs)
|
|
26
28
|
var web_1 = require("./sources/web");
|
|
27
29
|
Object.defineProperty(exports, "WebSource", { enumerable: true, get: function () { return web_1.WebSource; } });
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;AAEH,6DAA6D;AAC7D,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;AAEH,6DAA6D;AAC7D,iCAKiB;AAJf,oGAAA,WAAW,OAAA;AAAE,mGAAA,UAAU,OAAA;AAAE,mGAAA,UAAU,OAAA;AACnC,sGAAA,aAAa,OAAA;AAAE,uGAAA,cAAc,OAAA;AAAE,sGAAA,aAAa,OAAA;AAC5C,qGAAA,YAAY,OAAA;AACZ,iGAAA,QAAQ,OAAA;AAAE,sGAAA,aAAa,OAAA;AAUzB,2CAA2C;AAC3C,qCAA0C;AAAjC,gGAAA,SAAS,OAAA;AAElB,2CAAgD;AAAvC,sGAAA,YAAY,OAAA;AAIrB,qDAAqD;AACrD,+CAAkE;AAAzD,6GAAA,iBAAiB,OAAA;AAAE,qGAAA,SAAS,OAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.d.ts","sourceRoot":"","sources":["../../src/sources/web.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAS,MAAM,4BAA4B,CAAC;AAC3D,OAAO,KAAK,EAAE,IAAI,EAAe,MAAM,4BAA4B,CAAC;AACpE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAO/C,OAAO,EAAE,iBAAiB,EAAE,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"web.d.ts","sourceRoot":"","sources":["../../src/sources/web.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAS,MAAM,4BAA4B,CAAC;AAC3D,OAAO,KAAK,EAAE,IAAI,EAAe,MAAM,4BAA4B,CAAC;AACpE,OA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const result = yield* super.execute(args, context);
|
|
33
33
|
this._urlCache.set(args.url, result);
|
|
34
34
|
const r = result;
|
|
35
|
-
const hasContent = typeof r?.content === "string"
|
|
36
|
-
|
|
35
|
+
const hasContent = typeof r?.content === "string" &&
|
|
36
|
+
r.content !== "[Could not extract article content]";
|
|
37
37
|
if (hasContent) {
|
|
38
38
|
this._buffer.push({
|
|
39
39
|
url: r.url || args.url,
|
package/dist/sources/web.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/sources/web.ts"],"names":[],"mappings":";;;AACA,8DAA2D;AAK3D,oDAAoD;AACpD,oDAAoD;AACpD,yCAA+C;AAG/C,wCAAwC;AACxC,uCAAiE;AAAxD,6GAAA,iBAAiB,OAAA;AAE1B,gEAAgE;AAEhE;;;;;GAKG;AACH,MAAM,kBAAmB,SAAQ,0BAAa;IACpC,OAAO,CAAgB;IACvB,SAAS,GAAG,IAAI,GAAG,EAAmB,CAAC;IAE/C,
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/sources/web.ts"],"names":[],"mappings":";;;AACA,8DAA2D;AAK3D,oDAAoD;AACpD,oDAAoD;AACpD,yCAA+C;AAG/C,wCAAwC;AACxC,uCAAiE;AAAxD,6GAAA,iBAAiB,OAAA;AAE1B,gEAAgE;AAEhE;;;;;GAKG;AACH,MAAM,kBAAmB,SAAQ,0BAAa;IACpC,OAAO,CAAgB;IACvB,SAAS,GAAG,IAAI,GAAG,EAAmB,CAAC;IAE/C,YACE,MAAqB,EACrB,IAKC;QAED,KAAK,CAAC,IAAI,CAAC,CAAC;QACZ,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAED,UAAU;QACR,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;IACzB,CAAC;IAED,CAAC,OAAO,CACN,IAAqC,EACrC,OAAqB;QAErB,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAA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AE,IAAI,CAAC,UAAU,CAAC,CAAC;IAC5C,CAAC;IAED;;;OAGG;IACH,CAAC,IAAI,CAAC,GAA2B;QAC/B,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;QACxB,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,CAAC;QAC7B,IAAI,CAAC,SAAS,GAAG,GAAG,CAAC,QAAQ,CAAC;QAC9B,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAE1C,MAAM,EAAE,GAAG,KAAK,CAAC,CAAC,qBAAK,CAAC,MAAM,EAAE,CAAC;QACjC,EAAE,CAAC,KAAK,CAAC;YACP,OAAO,EAAE,EAAE,CAAC,MAAM,EAAE;YACpB,aAAa,EAAE,IAAI;YACnB,EAAE,EAAE,WAAW,CAAC,GAAG,EAAE;YACrB,IAAI,EAAE,aAAa;YACnB,UAAU,EAAE,IAAI,CAAC,IAAI;SACtB,CAAC,CAAC;IACL,CAAC;IAED,kBAAkB;IAClB,SAAS;QACP,OAAO,IAAA,4BAAiB,EAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACzC,CAAC;CACF;AA/CD,8BA+CC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { Operation } from 'effection';
|
|
2
|
+
import { Tool } from '@lloyal-labs/lloyal-agents';
|
|
3
|
+
import type { JsonSchema, ToolContext, CreateAgentPoolOpts, AgentPolicy } from '@lloyal-labs/lloyal-agents';
|
|
4
|
+
/**
|
|
5
|
+
* Configuration for {@link DelegateTool}.
|
|
6
|
+
*
|
|
7
|
+
* @category Rig
|
|
8
|
+
*/
|
|
9
|
+
export interface DelegateToolOpts {
|
|
10
|
+
/** Tool name agents see in their toolkit. @default "delegate" */
|
|
11
|
+
name?: string;
|
|
12
|
+
/** Tool description shown in the agent's tool schema. */
|
|
13
|
+
description?: string;
|
|
14
|
+
/** JSON schema for the tool's arguments. */
|
|
15
|
+
argsSchema?: JsonSchema;
|
|
16
|
+
/** Extract task strings from parsed tool arguments. */
|
|
17
|
+
extractTasks?: (args: Record<string, unknown>) => string[];
|
|
18
|
+
/** Pool options propagated to the inner agentPool call. Orchestrator is set
|
|
19
|
+
* by DelegateTool (one agent per extracted task, parallel). */
|
|
20
|
+
poolOpts: Omit<CreateAgentPoolOpts, 'orchestrate'>;
|
|
21
|
+
/** System prompt applied to each delegated sub-agent. */
|
|
22
|
+
systemPrompt: string;
|
|
23
|
+
/** Factory for per-invocation policy. Called fresh each time the tool fires so time budgets start from delegation, not from pool setup. */
|
|
24
|
+
createPolicy?: () => AgentPolicy;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Tool that calls agentPool() recursively.
|
|
28
|
+
*
|
|
29
|
+
* Agents can delegate sub-tasks to parallel sub-agents at arbitrary depth,
|
|
30
|
+
* bounded by KV pressure. Sub-agents fork from the calling agent's branch
|
|
31
|
+
* (Continuous Context) and inherit the full attention state.
|
|
32
|
+
*
|
|
33
|
+
* Includes entailment gating (filters drifted tasks) and echo detection
|
|
34
|
+
* (rejects paraphrases of the calling agent's own task).
|
|
35
|
+
*
|
|
36
|
+
* @category Rig
|
|
37
|
+
*/
|
|
38
|
+
export declare class DelegateTool extends Tool<Record<string, unknown>> {
|
|
39
|
+
readonly name: string;
|
|
40
|
+
readonly description: string;
|
|
41
|
+
readonly parameters: JsonSchema;
|
|
42
|
+
private _poolOpts;
|
|
43
|
+
private _systemPrompt;
|
|
44
|
+
private _extractTasks;
|
|
45
|
+
private _createPolicy?;
|
|
46
|
+
constructor(opts: DelegateToolOpts);
|
|
47
|
+
execute(args: Record<string, unknown>, context?: ToolContext): Operation<unknown>;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=delegate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delegate.d.ts","sourceRoot":"","sources":["../../src/tools/delegate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAA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+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DelegateTool = void 0;
|
|
4
|
+
const effection_1 = require("effection");
|
|
5
|
+
const lloyal_agents_1 = require("@lloyal-labs/lloyal-agents");
|
|
6
|
+
const DEFAULT_ARGS_SCHEMA = {
|
|
7
|
+
type: 'object',
|
|
8
|
+
properties: {
|
|
9
|
+
tasks: {
|
|
10
|
+
type: 'array',
|
|
11
|
+
items: { type: 'string' },
|
|
12
|
+
description: 'Sub-tasks to delegate to parallel agents',
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
required: ['tasks'],
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Tool that calls agentPool() recursively.
|
|
19
|
+
*
|
|
20
|
+
* Agents can delegate sub-tasks to parallel sub-agents at arbitrary depth,
|
|
21
|
+
* bounded by KV pressure. Sub-agents fork from the calling agent's branch
|
|
22
|
+
* (Continuous Context) and inherit the full attention state.
|
|
23
|
+
*
|
|
24
|
+
* Includes entailment gating (filters drifted tasks) and echo detection
|
|
25
|
+
* (rejects paraphrases of the calling agent's own task).
|
|
26
|
+
*
|
|
27
|
+
* @category Rig
|
|
28
|
+
*/
|
|
29
|
+
class DelegateTool extends lloyal_agents_1.Tool {
|
|
30
|
+
name;
|
|
31
|
+
description;
|
|
32
|
+
parameters;
|
|
33
|
+
_poolOpts;
|
|
34
|
+
_systemPrompt;
|
|
35
|
+
_extractTasks;
|
|
36
|
+
_createPolicy;
|
|
37
|
+
constructor(opts) {
|
|
38
|
+
super();
|
|
39
|
+
this.name = opts.name ?? 'delegate';
|
|
40
|
+
this.description = opts.description ?? 'Delegate sub-tasks to parallel agents. Each task gets its own agent.';
|
|
41
|
+
this.parameters = opts.argsSchema ?? DEFAULT_ARGS_SCHEMA;
|
|
42
|
+
this._extractTasks = opts.extractTasks ?? ((args) => args.tasks);
|
|
43
|
+
this._poolOpts = opts.poolOpts;
|
|
44
|
+
this._systemPrompt = opts.systemPrompt;
|
|
45
|
+
this._createPolicy = opts.createPolicy;
|
|
46
|
+
}
|
|
47
|
+
*execute(args, context) {
|
|
48
|
+
let tasks;
|
|
49
|
+
try {
|
|
50
|
+
tasks = this._extractTasks(args);
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
return { error: 'Failed to extract tasks from arguments.' };
|
|
54
|
+
}
|
|
55
|
+
if (!Array.isArray(tasks) || tasks.length === 0) {
|
|
56
|
+
return { error: 'Tasks must be a non-empty array of strings.' };
|
|
57
|
+
}
|
|
58
|
+
const tw = yield* lloyal_agents_1.Trace.expect();
|
|
59
|
+
// Entailment gate: filter drifted/echoed tasks before spawning
|
|
60
|
+
const scorer = context?.scorer;
|
|
61
|
+
let filtered;
|
|
62
|
+
if (scorer) {
|
|
63
|
+
const allTasks = [...tasks];
|
|
64
|
+
const scores = yield* (0, effection_1.call)(() => scorer.scoreEntailmentBatch(tasks));
|
|
65
|
+
const surviving = [];
|
|
66
|
+
const rejected = [];
|
|
67
|
+
for (let i = 0; i < tasks.length; i++) {
|
|
68
|
+
if (scorer.shouldProceed(scores[i])) {
|
|
69
|
+
surviving.push(tasks[i]);
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
rejected.push({ task: tasks[i], score: scores[i] });
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (rejected.length > 0)
|
|
76
|
+
filtered = rejected;
|
|
77
|
+
let _diagAgent;
|
|
78
|
+
try {
|
|
79
|
+
_diagAgent = yield* lloyal_agents_1.CallingAgent.get();
|
|
80
|
+
}
|
|
81
|
+
catch { /* top-level */ }
|
|
82
|
+
tw.write({
|
|
83
|
+
traceId: tw.nextId(), parentTraceId: null, ts: performance.now(),
|
|
84
|
+
type: 'entailment:delegate',
|
|
85
|
+
tool: this.name,
|
|
86
|
+
callingAgentId: _diagAgent?.id,
|
|
87
|
+
callingAgentTaskLength: _diagAgent?.task?.length,
|
|
88
|
+
callingAgentTask: _diagAgent?.task?.slice(0, 200),
|
|
89
|
+
tasks: allTasks.map((text, i) => ({
|
|
90
|
+
text: text.slice(0, 200),
|
|
91
|
+
score: scores[i],
|
|
92
|
+
kept: scorer.shouldProceed(scores[i]),
|
|
93
|
+
})),
|
|
94
|
+
});
|
|
95
|
+
if (surviving.length === 0) {
|
|
96
|
+
return { filtered, error: 'All proposed tasks drifted from the original query.' };
|
|
97
|
+
}
|
|
98
|
+
tasks = surviving;
|
|
99
|
+
// Echo guard — only fires when the calling agent has a parent (depth 2+).
|
|
100
|
+
// At depth 1 (first delegation from a harness-spawned agent), there's no relay
|
|
101
|
+
// chain to detect — sub-questions are expected to be similar to the task they decompose.
|
|
102
|
+
const echoThreshold = this._poolOpts.echoThreshold ?? 0.8;
|
|
103
|
+
let callingAgent;
|
|
104
|
+
try {
|
|
105
|
+
callingAgent = yield* lloyal_agents_1.CallingAgent.get();
|
|
106
|
+
}
|
|
107
|
+
catch { /* top-level */ }
|
|
108
|
+
if (callingAgent?.task && callingAgent.parent) {
|
|
109
|
+
const echoScores = yield* (0, effection_1.call)(() => scorer.scoreSimilarityBatch(callingAgent.task, tasks));
|
|
110
|
+
const minEchoScore = Math.min(...echoScores);
|
|
111
|
+
const echoRejected = minEchoScore > echoThreshold;
|
|
112
|
+
tw.write({
|
|
113
|
+
traceId: tw.nextId(), parentTraceId: null, ts: performance.now(),
|
|
114
|
+
type: 'entailment:delegate:echo',
|
|
115
|
+
tool: this.name,
|
|
116
|
+
agentTask: callingAgent.task.slice(0, 200),
|
|
117
|
+
tasks: tasks.map((text, i) => ({ text: text.slice(0, 200), echoScore: echoScores[i] })),
|
|
118
|
+
threshold: echoThreshold,
|
|
119
|
+
rejected: echoRejected,
|
|
120
|
+
});
|
|
121
|
+
if (echoRejected) {
|
|
122
|
+
return {
|
|
123
|
+
filtered,
|
|
124
|
+
echoRejected: true,
|
|
125
|
+
error: 'Your sub-questions are too similar to your own task. You have already searched and read content on this topic. Call report() with what you found, including what you checked but could not find.',
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
if (this._poolOpts.checkAncestorEcho) {
|
|
129
|
+
const ancestorTasks = callingAgent.walkAncestors(a => a.task ? [a.task] : [])
|
|
130
|
+
.filter(t => t !== callingAgent.task);
|
|
131
|
+
for (const ancestorTask of ancestorTasks) {
|
|
132
|
+
const ancestorScores = yield* (0, effection_1.call)(() => scorer.scoreSimilarityBatch(ancestorTask, tasks));
|
|
133
|
+
if (Math.min(...ancestorScores) > echoThreshold) {
|
|
134
|
+
tw.write({
|
|
135
|
+
traceId: tw.nextId(), parentTraceId: null, ts: performance.now(),
|
|
136
|
+
type: 'entailment:delegate:echo',
|
|
137
|
+
tool: this.name,
|
|
138
|
+
agentTask: ancestorTask.slice(0, 200),
|
|
139
|
+
tasks: tasks.map((text, i) => ({ text: text.slice(0, 200), echoScore: ancestorScores[i] })),
|
|
140
|
+
threshold: echoThreshold,
|
|
141
|
+
rejected: true,
|
|
142
|
+
});
|
|
143
|
+
return {
|
|
144
|
+
filtered,
|
|
145
|
+
echoRejected: true,
|
|
146
|
+
error: 'Your sub-questions echo an ancestor task. Report what you found instead of re-delegating.',
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
const opts = this._poolOpts;
|
|
154
|
+
const scope = (0, lloyal_agents_1.traceScope)(tw, null, `delegate:${this.name}`, { taskCount: tasks.length, filtered: filtered?.length ?? 0 });
|
|
155
|
+
const pool = yield* (0, lloyal_agents_1.agentPool)({
|
|
156
|
+
...opts,
|
|
157
|
+
...(this._createPolicy ? { policy: this._createPolicy() } : {}),
|
|
158
|
+
orchestrate: (0, lloyal_agents_1.parallel)(tasks.map(t => ({ systemPrompt: this._systemPrompt, content: t }))),
|
|
159
|
+
parent: context?.branch,
|
|
160
|
+
pruneOnReport: opts.pruneOnReport ?? true,
|
|
161
|
+
scorer: context?.scorer,
|
|
162
|
+
});
|
|
163
|
+
const result = {
|
|
164
|
+
results: pool.agents.map((a) => a.result).filter(Boolean),
|
|
165
|
+
nestedResults: pool.agents.flatMap((a) => a.nestedResults ?? []),
|
|
166
|
+
agentCount: pool.agents.length,
|
|
167
|
+
totalTokens: pool.totalTokens,
|
|
168
|
+
totalToolCalls: pool.totalToolCalls,
|
|
169
|
+
...(filtered ? { filtered } : {}),
|
|
170
|
+
};
|
|
171
|
+
scope.close();
|
|
172
|
+
return result;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
exports.DelegateTool = DelegateTool;
|
|
176
|
+
//# sourceMappingURL=delegate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delegate.js","sourceRoot":"","sources":["../../src/tools/delegate.ts"],"names":[],"mappings":";;;AACA,yCAAiC;AACjC,8DAOoC;AAgCpC,MAAM,mBAAmB,GAAe;IACtC,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,KAAK,EAAE;YACL,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YACzB,WAAW,EAAE,0CAA0C;SACxD;KACF;IACD,QAAQ,EAAE,CAAC,OAAO,CAAC;CACpB,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,MAAa,YAAa,SAAQ,oBAA6B;IACpD,IAAI,CAAS;IACb,WAAW,CAAS;IACpB,UAAU,CAAa;IAExB,SAAS,CAA2C;IACpD,aAAa,CAAS;IACtB,aAAa,CAA8C;IAC3D,aAAa,CAAqB;IAE1C,YAAY,IAAsB;QAChC,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,IAAI,UAAU,CAAC;QACpC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,IAAI,sEAAsE,CAAC;QAC9G,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,IAAI,mBAAmB,CAAC;QACzD,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,YAAY,IAAI,CAAC,CA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AAC,MAAM,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC;YACzD,aAAa,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,IAAI,EAAE,CAAC;YAChE,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM;YAC9B,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,cAAc,EAAE,IAAI,CAAC,cAAc;YACnC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAClC,CAAC;QACF,KAAK,CAAC,KAAK,EAAE,CAAC;QACd,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AA5JD,oCA4JC"}
|
|
@@ -25,7 +25,7 @@ export declare class FetchPageTool extends Tool<{
|
|
|
25
25
|
query?: string;
|
|
26
26
|
}> {
|
|
27
27
|
readonly name = "fetch_page";
|
|
28
|
-
readonly description = "Fetch a web page and extract its article content. Returns readable text with title and excerpt.
|
|
28
|
+
readonly description = "Fetch a web page and extract its article content. Returns readable text with title and excerpt. Pass a query to get only the most relevant sections.";
|
|
29
29
|
readonly parameters: JsonSchema;
|
|
30
30
|
private _maxChars;
|
|
31
31
|
private _reranker;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch-page.d.ts","sourceRoot":"","sources":["../../src/tools/fetch-page.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAS,MAAM,4BAA4B,CAAC;AACzD,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAG1E,OAAO,KAAK,EAAE,QAAQ,EAAe,MAAM,SAAS,CAAC;AA+CrD;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,aAAc,SAAQ,IAAI,CAAC;IAAE,GAAG,EAAE,MA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B,SAAS,CAAC,OAAO,CAAC;CAwPtB"}
|
package/dist/tools/fetch-page.js
CHANGED
|
@@ -54,7 +54,7 @@ function selectTopChunks(scored, chunks, topK, tokenBudget) {
|
|
|
54
54
|
*/
|
|
55
55
|
class FetchPageTool extends lloyal_agents_1.Tool {
|
|
56
56
|
name = "fetch_page";
|
|
57
|
-
description = "Fetch a web page and extract its article content. Returns readable text with title and excerpt.
|
|
57
|
+
description = "Fetch a web page and extract its article content. Returns readable text with title and excerpt. Pass a query to get only the most relevant sections.";
|
|
58
58
|
parameters = {
|
|
59
59
|
type: "object",
|
|
60
60
|
properties: {
|
|
@@ -86,6 +86,20 @@ class FetchPageTool extends lloyal_agents_1.Tool {
|
|
|
86
86
|
const url = args.url?.trim();
|
|
87
87
|
if (!url)
|
|
88
88
|
return { error: "url must not be empty" };
|
|
89
|
+
// Cross-agent dedup: another worker in this pool already fetched this URL
|
|
90
|
+
if (context?.peerHistory?.some(h => {
|
|
91
|
+
if (h.name !== 'fetch_page')
|
|
92
|
+
return false;
|
|
93
|
+
try {
|
|
94
|
+
const prev = JSON.parse(h.args).url;
|
|
95
|
+
return prev === url;
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
})) {
|
|
101
|
+
return { error: 'Resource unavailable. Try a different URL.' };
|
|
102
|
+
}
|
|
89
103
|
// Early reject PDF URLs
|
|
90
104
|
const lowerUrl = url.toLowerCase();
|
|
91
105
|
if (lowerUrl.endsWith(".pdf") ||
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch-page.js","sourceRoot":"","sources":["../../src/tools/fetch-page.ts"],"names":[],"mappings":";;;AAAA,yCAAiC;AAEjC,8DAAyD;AAEzD,kDAAgD;AAIhD,wDAAwD;AACxD,SAAS,eAAe,CACtB,MAAqB,EACrB,MAAe,EACf,IAAY,EACZ,WAAmB;IAEnB,MAAM,QAAQ,GAA4D,EAAE,CAAC;IAC7E,IAAI,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EAAE,CAAC,OAAO,CAAC,CAAC;yBACjD,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,OAAO,CAAC;yBACvB,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;oBAE/C,OAAO;wBACL,GAAG;wBACH,KAAK,EAAE,OAAO,CAAC,KAAK;wBACpB,OAAO,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC;wBACzD,MAAM,EAAE,SAAS,CAAC,MAAM;wBACxB,GAAG,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;qBACjD,CAAC;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;QAED,2CAA2C;QAC3C,IAAI,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QAC9B,IAAI,OAAO,CAAC,MAAM,GAAG,QAAQ,EAAE,CAAC;YAC9B,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,CAAC,GAAG,iBAAiB,CAAC;QAC3D,CAAC;QACD,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC;IAC1E,CAAC;CACF;AApSD,sCAoSC"}
|
package/dist/tools/index.d.ts
CHANGED
|
@@ -5,9 +5,11 @@ import { ReportTool } from './report';
|
|
|
5
5
|
export { WebSearchTool, TavilyProvider } from './web-search';
|
|
6
6
|
export { FetchPageTool } from './fetch-page';
|
|
7
7
|
export { ReportTool } from './report';
|
|
8
|
+
export { DelegateTool } from './delegate';
|
|
9
|
+
export type { DelegateToolOpts } from './delegate';
|
|
8
10
|
export type { SearchProvider, SearchResult, Reranker, ScoredChunk, ScoredResult } from './types';
|
|
9
|
-
export { PlanTool } from './plan';
|
|
10
|
-
export type { PlanResult,
|
|
11
|
+
export { PlanTool, taskToContent } from './plan';
|
|
12
|
+
export type { PlanResult, PlanIntent, PlanToolOpts, ResearchTask } from './plan';
|
|
11
13
|
/**
|
|
12
14
|
* Shared singleton {@link ReportTool} instance.
|
|
13
15
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAIxC,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,QAAQ,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACjG,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAIxC,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,YAAY,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACnD,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,QAAQ,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACjG,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACjD,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEjF;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,YAAmB,CAAC;AAE3C;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE;IAChC,SAAS,EAAE,QAAQ,EAAE,CAAC;IACtB,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,QAAQ,EAAE,QAAQ,CAAC;CACpB,GAAG,OAAO,CAOV"}
|
package/dist/tools/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.reportTool = exports.PlanTool = exports.ReportTool = exports.FetchPageTool = exports.TavilyProvider = exports.WebSearchTool = void 0;
|
|
3
|
+
exports.reportTool = exports.taskToContent = exports.PlanTool = exports.DelegateTool = exports.ReportTool = exports.FetchPageTool = exports.TavilyProvider = exports.WebSearchTool = void 0;
|
|
4
4
|
exports.createTools = createTools;
|
|
5
5
|
const lloyal_agents_1 = require("@lloyal-labs/lloyal-agents");
|
|
6
6
|
const search_1 = require("./search");
|
|
@@ -14,8 +14,11 @@ var fetch_page_1 = require("./fetch-page");
|
|
|
14
14
|
Object.defineProperty(exports, "FetchPageTool", { enumerable: true, get: function () { return fetch_page_1.FetchPageTool; } });
|
|
15
15
|
var report_2 = require("./report");
|
|
16
16
|
Object.defineProperty(exports, "ReportTool", { enumerable: true, get: function () { return report_2.ReportTool; } });
|
|
17
|
+
var delegate_1 = require("./delegate");
|
|
18
|
+
Object.defineProperty(exports, "DelegateTool", { enumerable: true, get: function () { return delegate_1.DelegateTool; } });
|
|
17
19
|
var plan_1 = require("./plan");
|
|
18
20
|
Object.defineProperty(exports, "PlanTool", { enumerable: true, get: function () { return plan_1.PlanTool; } });
|
|
21
|
+
Object.defineProperty(exports, "taskToContent", { enumerable: true, get: function () { return plan_1.taskToContent; } });
|
|
19
22
|
/**
|
|
20
23
|
* Shared singleton {@link ReportTool} instance.
|
|
21
24
|
*
|
package/dist/tools/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":";;;AAoCA,kCAWC;AA/CD,8DAA2D;AAI3D,qCAAsC;AACtC,2CAA2C;AAC3C,iCAAkC;AAClC,qCAAsC;AAEtC,2CAA6D;AAApD,2GAAA,aAAa,OAAA;AAAE,4GAAA,cAAc,OAAA;AACtC,2CAA6C;AAApC,2GAAA,aAAa,OAAA;AACtB,mCAAsC;AAA7B,oGAAA,UAAU,OAAA;AACnB,uCAA0C;AAAjC,wGAAA,YAAY,OAAA;AAGrB,+BAAiD;AAAxC,gGAAA,QAAQ,OAAA;AAAE,qGAAA,aAAa,OAAA;AAGhC;;;;;;GAMG;AACU,QAAA,UAAU,GAAG,IAAI,mBAAU,EAAE,CAAC;AAE3C;;;;;;;;GAQG;AACH,SAAgB,WAAW,CAAC,IAI3B;IACC,OAAO,IAAA,6BAAa,EAAC;QACnB,IAAI,mBAAU,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC;QAC1C,IAAI,wBAAY,CAAC,IAAI,CAAC,SAAS,CAAC;QAChC,IAAI,eAAQ,CAAC,IAAI,CAAC,SAAS,CAAC;QAC5B,kBAAU;KACX,CAAC,CAAC;AACL,CAAC"}
|
package/dist/tools/plan.d.ts
CHANGED
|
@@ -8,54 +8,74 @@ import { Session } from '@lloyal-labs/sdk';
|
|
|
8
8
|
* @category Rig
|
|
9
9
|
*/
|
|
10
10
|
export interface PlanToolOpts {
|
|
11
|
-
/** System
|
|
11
|
+
/** System prompt + user template. User template is rendered via Eta with `{ query, count, context? }`. */
|
|
12
12
|
prompt: {
|
|
13
13
|
system: string;
|
|
14
14
|
user: string;
|
|
15
15
|
};
|
|
16
16
|
/** Active session whose trunk is used as the parent branch for generation. */
|
|
17
17
|
session: Session;
|
|
18
|
-
/** Maximum number of
|
|
18
|
+
/** Maximum number of tasks the planner may produce. */
|
|
19
19
|
maxQuestions: number;
|
|
20
20
|
/** Sampling temperature for plan generation. @default 0.3 */
|
|
21
21
|
temperature?: number;
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
|
-
* A
|
|
24
|
+
* A structured research task produced by the planner.
|
|
25
|
+
*
|
|
26
|
+
* Intent is a plan-level decision (see {@link PlanIntent}), not a per-task
|
|
27
|
+
* attribute — a task is always a research assignment when emitted.
|
|
25
28
|
*
|
|
26
29
|
* @category Rig
|
|
27
30
|
*/
|
|
28
|
-
export interface
|
|
29
|
-
/**
|
|
30
|
-
|
|
31
|
-
/** Whether the question can be answered via research or needs user clarification. */
|
|
32
|
-
intent: 'research' | 'clarify';
|
|
31
|
+
export interface ResearchTask {
|
|
32
|
+
/** What to find out — a specific, actionable research assignment. */
|
|
33
|
+
description: string;
|
|
33
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* Convert a ResearchTask to agent content string.
|
|
37
|
+
*
|
|
38
|
+
* @category Rig
|
|
39
|
+
*/
|
|
40
|
+
export declare function taskToContent(task: ResearchTask): string;
|
|
41
|
+
/**
|
|
42
|
+
* Plan-level disposition for the user's query.
|
|
43
|
+
*
|
|
44
|
+
* - **clarify** — query is genuinely ambiguous; planner emits `clarifyQuestions`,
|
|
45
|
+
* harness returns to REPL for user input.
|
|
46
|
+
* - **passthrough** — query is a follow-up answerable from session.trunk's prior
|
|
47
|
+
* Q&A turns; harness skips research pipeline, streams answer from trunk, commits turn.
|
|
48
|
+
* - **research** — query needs full decomposition; planner emits `tasks`, harness
|
|
49
|
+
* runs the chain → synth → verify pipeline.
|
|
50
|
+
*
|
|
51
|
+
* @category Rig
|
|
52
|
+
*/
|
|
53
|
+
export type PlanIntent = 'clarify' | 'passthrough' | 'research';
|
|
34
54
|
/**
|
|
35
55
|
* Output returned by {@link PlanTool} execution.
|
|
36
56
|
*
|
|
37
57
|
* @category Rig
|
|
38
58
|
*/
|
|
39
59
|
export interface PlanResult {
|
|
40
|
-
/**
|
|
41
|
-
|
|
60
|
+
/** Plan-level disposition: how should the harness route this query? */
|
|
61
|
+
intent: PlanIntent;
|
|
62
|
+
/** Research tasks (non-empty when intent === 'research'; empty otherwise). */
|
|
63
|
+
tasks: ResearchTask[];
|
|
64
|
+
/** Clarification questions for the user (non-empty when intent === 'clarify'; empty otherwise). */
|
|
65
|
+
clarifyQuestions: string[];
|
|
42
66
|
/** Number of tokens generated during planning. */
|
|
43
67
|
tokenCount: number;
|
|
44
68
|
/** Wall-clock time for the planning pass in milliseconds. */
|
|
45
69
|
timeMs: number;
|
|
46
70
|
}
|
|
47
71
|
/**
|
|
48
|
-
* Grammar-constrained query
|
|
49
|
-
*
|
|
50
|
-
* Analyzes a research query and produces an array of {@link PlanQuestion}
|
|
51
|
-
* sub-questions, each classified as `"research"` (answerable via search)
|
|
52
|
-
* or `"clarify"` (needs user input). Uses a JSON grammar to guarantee
|
|
53
|
-
* structured output. Returns an empty array if the query is focused
|
|
54
|
-
* enough to research directly.
|
|
72
|
+
* Grammar-constrained query planner.
|
|
55
73
|
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
74
|
+
* Analyzes the user's query (with prior conversation in KV via warm session fork)
|
|
75
|
+
* and produces a {@link PlanResult} that commits to one disposition: clarify /
|
|
76
|
+
* passthrough / research. Uses a JSON grammar to guarantee structured output;
|
|
77
|
+
* the planner must choose one of the three intents and populate the matching
|
|
78
|
+
* fields (tasks for research, clarifyQuestions for clarify, neither for passthrough).
|
|
59
79
|
*
|
|
60
80
|
* @category Rig
|
|
61
81
|
*/
|
|
@@ -64,7 +84,7 @@ export declare class PlanTool extends Tool<{
|
|
|
64
84
|
context?: string;
|
|
65
85
|
}> {
|
|
66
86
|
readonly name = "plan";
|
|
67
|
-
readonly description = "Analyze a
|
|
87
|
+
readonly description = "Analyze a user query and decide how to handle it: ask for clarification, pass through for direct answer from conversation history, or decompose into research tasks.";
|
|
68
88
|
readonly parameters: JsonSchema;
|
|
69
89
|
private _prompt;
|
|
70
90
|
private _session;
|
package/dist/tools/plan.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plan.d.ts","sourceRoot":"","sources":["../../src/tools/plan.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"plan.d.ts","sourceRoot":"","sources":["../../src/tools/plan.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAyB,MAAM,4BAA4B,CAAC;AACzE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B,0GAA0G;IAC1G,MAAM,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IACzC,8EAA8E;IAC9E,OAAO,EAAE,OAAO,CAAC;IACjB,uDAAuD;IACvD,YAAY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
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PlanTool = void 0;
|
|
4
|
-
|
|
4
|
+
exports.taskToContent = taskToContent;
|
|
5
5
|
const lloyal_agents_1 = require("@lloyal-labs/lloyal-agents");
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* Convert a ResearchTask to agent content string.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
* @category Rig
|
|
10
|
+
*/
|
|
11
|
+
function taskToContent(task) {
|
|
12
|
+
return task.description;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Grammar-constrained query planner.
|
|
14
16
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
17
|
+
* Analyzes the user's query (with prior conversation in KV via warm session fork)
|
|
18
|
+
* and produces a {@link PlanResult} that commits to one disposition: clarify /
|
|
19
|
+
* passthrough / research. Uses a JSON grammar to guarantee structured output;
|
|
20
|
+
* the planner must choose one of the three intents and populate the matching
|
|
21
|
+
* fields (tasks for research, clarifyQuestions for clarify, neither for passthrough).
|
|
18
22
|
*
|
|
19
23
|
* @category Rig
|
|
20
24
|
*/
|
|
21
25
|
class PlanTool extends lloyal_agents_1.Tool {
|
|
22
26
|
name = 'plan';
|
|
23
|
-
description = 'Analyze a
|
|
27
|
+
description = 'Analyze a user query and decide how to handle it: ask for clarification, pass through for direct answer from conversation history, or decompose into research tasks.';
|
|
24
28
|
parameters = {
|
|
25
29
|
type: 'object',
|
|
26
30
|
properties: {
|
|
@@ -41,58 +45,66 @@ class PlanTool extends lloyal_agents_1.Tool {
|
|
|
41
45
|
this._maxQuestions = opts.maxQuestions;
|
|
42
46
|
}
|
|
43
47
|
*execute(args) {
|
|
44
|
-
const ctx = yield* lloyal_agents_1.Ctx.expect();
|
|
45
48
|
const t = performance.now();
|
|
46
49
|
const schema = {
|
|
47
50
|
type: 'object',
|
|
48
51
|
properties: {
|
|
49
|
-
|
|
52
|
+
intent: { type: 'string', enum: ['clarify', 'passthrough', 'research'] },
|
|
53
|
+
tasks: {
|
|
50
54
|
type: 'array',
|
|
51
55
|
items: {
|
|
52
56
|
type: 'object',
|
|
53
57
|
properties: {
|
|
54
|
-
|
|
55
|
-
intent: { type: 'string', enum: ['research', 'clarify'] },
|
|
58
|
+
description: { type: 'string' },
|
|
56
59
|
},
|
|
57
|
-
required: ['
|
|
60
|
+
required: ['description'],
|
|
58
61
|
},
|
|
59
62
|
maxItems: this._maxQuestions,
|
|
60
63
|
},
|
|
64
|
+
clarifyQuestions: {
|
|
65
|
+
type: 'array',
|
|
66
|
+
items: { type: 'string' },
|
|
67
|
+
},
|
|
61
68
|
},
|
|
62
|
-
required: ['
|
|
69
|
+
required: ['intent'],
|
|
63
70
|
};
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
{ role: 'user', content: userContent },
|
|
74
|
-
];
|
|
75
|
-
const { prompt } = yield* (0, effection_1.call)(() => ctx.formatChat(JSON.stringify(messages), { enableThinking: false }));
|
|
76
|
-
const parent = this._session.trunk ?? undefined;
|
|
77
|
-
const result = yield* (0, lloyal_agents_1.generate)({
|
|
78
|
-
prompt,
|
|
79
|
-
grammar,
|
|
71
|
+
const userContent = (0, lloyal_agents_1.renderTemplate)(this._prompt.user, {
|
|
72
|
+
query: args.query,
|
|
73
|
+
count: this._maxQuestions,
|
|
74
|
+
context: args.context || null,
|
|
75
|
+
});
|
|
76
|
+
const planAgent = yield* (0, lloyal_agents_1.agent)({
|
|
77
|
+
systemPrompt: this._prompt.system,
|
|
78
|
+
task: userContent,
|
|
79
|
+
schema,
|
|
80
80
|
params: { temperature: this._temperature },
|
|
81
|
-
|
|
81
|
+
session: this._session,
|
|
82
82
|
});
|
|
83
|
-
const { output, tokenCount } = result;
|
|
84
83
|
const timeMs = performance.now() - t;
|
|
84
|
+
const tokenCount = planAgent.tokenCount;
|
|
85
85
|
try {
|
|
86
|
-
const parsed = JSON.parse(
|
|
87
|
-
const
|
|
88
|
-
|
|
86
|
+
const parsed = JSON.parse(planAgent.rawOutput);
|
|
87
|
+
const intent = parsed.intent === 'clarify' || parsed.intent === 'passthrough' || parsed.intent === 'research'
|
|
88
|
+
? parsed.intent
|
|
89
|
+
: 'research';
|
|
90
|
+
const tasks = (parsed.tasks ?? [])
|
|
89
91
|
.slice(0, this._maxQuestions)
|
|
90
|
-
.filter(
|
|
91
|
-
.map(
|
|
92
|
-
|
|
92
|
+
.filter(t => typeof t.description === 'string')
|
|
93
|
+
.map(t => ({ description: t.description }));
|
|
94
|
+
const clarifyQuestions = (parsed.clarifyQuestions ?? []).filter(q => typeof q === 'string');
|
|
95
|
+
return { intent, tasks, clarifyQuestions, tokenCount, timeMs };
|
|
93
96
|
}
|
|
94
97
|
catch {
|
|
95
|
-
|
|
98
|
+
// Grammar should prevent this; fall through to passthrough on malformed output
|
|
99
|
+
// so the harness routes to a direct trunk-stream answer rather than running a
|
|
100
|
+
// research pipeline with no real plan.
|
|
101
|
+
return {
|
|
102
|
+
intent: 'passthrough',
|
|
103
|
+
tasks: [],
|
|
104
|
+
clarifyQuestions: [],
|
|
105
|
+
tokenCount,
|
|
106
|
+
timeMs,
|
|
107
|
+
};
|
|
96
108
|
}
|
|
97
109
|
}
|
|
98
110
|
}
|
package/dist/tools/plan.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plan.js","sourceRoot":"","sources":["../../src/tools/plan.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"plan.js","sourceRoot":"","sources":["../../src/tools/plan.ts"],"names":[],"mappings":";;;AAuCA,sCAEC;AAxCD,8DAAyE;AAiCzE;;;;GAIG;AACH,SAAgB,aAAa,CAAC,IAAkB;IAC9C,OAAO,IAAI,CAAC,WAAW,CAAC;AAC1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C,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,WAAW,KAAK,QAAQ,CAAC;iBAC9C,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,WAAY,EAAE,CAAC,CAAC,CAAC;YAE/C,MAAM,gBAAgB,GAAG,CAAC,MAAM,CAAC,gBAAgB,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC;YAE5F,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,EAAuB,CAAC;QACtF,CAAC;QAAC,MAAM,CAAC;YACP,+EAA+E;YAC/E,8EAA8E;YAC9E,uCAAuC;YACvC,OAAO;gBACL,MAAM,EAAE,aAAa;gBACrB,KAAK,EAAE,EAAE;gBACT,gBAAgB,EAAE,EAAE;gBACpB,UAAU;gBACV,MAAM;aACc,CAAC;QACzB,CAAC;IACH,CAAC;CACF;AArGD,4BAqGC"}
|
|
@@ -34,7 +34,7 @@ export declare class WebSearchTool extends Tool<{
|
|
|
34
34
|
query: string;
|
|
35
35
|
}> {
|
|
36
36
|
readonly name = "web_search";
|
|
37
|
-
readonly description = "Search the web. Returns results with titles, snippets, and URLs.
|
|
37
|
+
readonly description = "Search the web. Returns results with titles, snippets, and URLs.";
|
|
38
38
|
readonly parameters: JsonSchema;
|
|
39
39
|
private _provider;
|
|
40
40
|
private _topN;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web-search.d.ts","sourceRoot":"","sources":["../../src/tools/web-search.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAS,MAAM,4BAA4B,CAAC;AACzD,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC1E,OAAO,KAAK,EAAE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KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;IACxD,QAAQ,CAAC,IAAI,gBAAgB;IAC7B,QAAQ,CAAC,WAAW,sEACiD;IACrE,QAAQ,CAAC,UAAU,EAAE,UAAU,CAI7B;IAEF,OAAO,CAAC,SAAS,CAAiB;IAClC,OAAO,CAAC,KAAK,CAAS;gBAEV,QAAQ,EAAE,cAAc,EAAE,IAAI,SAAI;IAM7C,OAAO,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC,OAAO,CAAC;CA6F7E"}
|
package/dist/tools/web-search.js
CHANGED
|
@@ -42,6 +42,7 @@ class TavilyProvider {
|
|
|
42
42
|
snippet: r.content.length > max
|
|
43
43
|
? r.content.slice(0, max) + " [\u2026]"
|
|
44
44
|
: r.content,
|
|
45
|
+
score: r.score,
|
|
45
46
|
}));
|
|
46
47
|
}
|
|
47
48
|
}
|
|
@@ -58,7 +59,7 @@ exports.TavilyProvider = TavilyProvider;
|
|
|
58
59
|
*/
|
|
59
60
|
class WebSearchTool extends lloyal_agents_1.Tool {
|
|
60
61
|
name = "web_search";
|
|
61
|
-
description = "Search the web. Returns results with titles, snippets, and URLs.
|
|
62
|
+
description = "Search the web. Returns results with titles, snippets, and URLs.";
|
|
62
63
|
parameters = {
|
|
63
64
|
type: "object",
|
|
64
65
|
properties: { query: { type: "string", description: "Search query" } },
|
|
@@ -75,6 +76,21 @@ class WebSearchTool extends lloyal_agents_1.Tool {
|
|
|
75
76
|
const query = args.query?.trim();
|
|
76
77
|
if (!query)
|
|
77
78
|
return { error: "query must not be empty" };
|
|
79
|
+
// Cross-agent dedup: another worker in this pool already issued this query
|
|
80
|
+
const queryLower = query.toLowerCase();
|
|
81
|
+
if (context?.peerHistory?.some(h => {
|
|
82
|
+
if (h.name !== 'web_search')
|
|
83
|
+
return false;
|
|
84
|
+
try {
|
|
85
|
+
const prev = JSON.parse(h.args).query?.toLowerCase();
|
|
86
|
+
return prev === queryLower;
|
|
87
|
+
}
|
|
88
|
+
catch {
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
})) {
|
|
92
|
+
return { error: 'Resource unavailable. Try a different query.' };
|
|
93
|
+
}
|
|
78
94
|
const provider = this._provider;
|
|
79
95
|
const topN = this._topN;
|
|
80
96
|
let results;
|
|
@@ -84,11 +100,23 @@ class WebSearchTool extends lloyal_agents_1.Tool {
|
|
|
84
100
|
catch (err) {
|
|
85
101
|
return { error: `Search failed: ${err.message}` };
|
|
86
102
|
}
|
|
87
|
-
//
|
|
103
|
+
// Explore mode: preserve provider ordering — the search engine's
|
|
104
|
+
// ranking reflects the agent's local query intent. Reranking in
|
|
105
|
+
// explore mode kills topically divergent results with high
|
|
106
|
+
// information gain (e.g. an HN discussion thread scored lower
|
|
107
|
+
// on entailment but linking to the entire landscape).
|
|
108
|
+
//
|
|
109
|
+
// Exploit mode: rerank by min(provider score, entailment score).
|
|
110
|
+
// Provider score is the search engine's local-query relevance.
|
|
111
|
+
// Entailment score is original-query relevance. Both must be
|
|
112
|
+
// high — same contract as fetch_page and corpus search.
|
|
88
113
|
const scorer = context?.scorer;
|
|
89
|
-
if (scorer && results.length > 1) {
|
|
114
|
+
if (!context?.explore && scorer && results.length > 1) {
|
|
90
115
|
const snippets = results.map((r) => `${r.title}. ${r.snippet}`);
|
|
91
|
-
const
|
|
116
|
+
const entailment = yield* (0, effection_1.call)(() => scorer.scoreEntailmentBatch(snippets));
|
|
117
|
+
// Combine: min(provider score, entailment) when provider score
|
|
118
|
+
// is available; entailment-only as fallback for providers without scores
|
|
119
|
+
const combined = results.map((r, i) => r.score != null ? Math.min(r.score, entailment[i]) : entailment[i]);
|
|
92
120
|
let tw;
|
|
93
121
|
try {
|
|
94
122
|
tw = yield* lloyal_agents_1.Trace.expect();
|
|
@@ -104,15 +132,18 @@ class WebSearchTool extends lloyal_agents_1.Tool {
|
|
|
104
132
|
type: "entailment:search",
|
|
105
133
|
tool: "web_search",
|
|
106
134
|
query,
|
|
135
|
+
mode: "exploit",
|
|
107
136
|
before: results.map((r, i) => ({
|
|
108
137
|
title: r.title,
|
|
109
138
|
url: r.url,
|
|
110
|
-
|
|
139
|
+
providerScore: r.score ?? null,
|
|
140
|
+
entailment: entailment[i],
|
|
141
|
+
combined: combined[i],
|
|
111
142
|
})),
|
|
112
143
|
});
|
|
113
144
|
}
|
|
114
145
|
results = results
|
|
115
|
-
.map((r, i) => ({ result: r, score:
|
|
146
|
+
.map((r, i) => ({ result: r, score: combined[i] }))
|
|
116
147
|
.sort((a, b) => b.score - a.score)
|
|
117
148
|
.map((entry) => entry.result);
|
|
118
149
|
if (tw) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web-search.js","sourceRoot":"","sources":["../../src/tools/web-search.ts"],"names":[],"mappings":";;;AAAA,yCAAiC;AAEjC,8DAAyD;AAMzD,2DAA2D;AAE3D;;;;;;;;GAQG;AACH,MAAa,cAAc;IAChB,0BAA0B,GAAG,KAAK,CAAC;IACpC,OAAO,CAAS;IAChB,iBAAiB,CAAS;IAElC,YAAY,MAAe,EAAE,IAAoC;QAC/D,IAAI,CAAC,OAAO,GAAG,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,EAAE,CAAC;QAC1D,IAAI,CAAC,iBAAiB,GAAG,IAAI,EAAE,gBAAgB,IAAI,GAAG,CAAC;IACzD,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,KAAa,EAAE,UAAkB;QAC5C,IAAI,CAAC,IAAI,CAAC,OAAO;YAAE,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAC7D,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,+BAA+B,EAAE;YACvD,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;gBAClC,aAAa,EAAE,UAAU,IAAI,CAAC,OAAO,EAAE;aACxC;YACD,IAAI,EAAE,I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EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC;iBAC5D,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AAhHD,sCAgHC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lloyal-labs/rig",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Retrieval-Interleaved Generation for lloyal-agents",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -19,12 +19,12 @@
|
|
|
19
19
|
},
|
|
20
20
|
"repository": {
|
|
21
21
|
"type": "git",
|
|
22
|
-
"url": "git+https://github.com/lloyal-ai/
|
|
22
|
+
"url": "git+https://github.com/lloyal-ai/hdk.git",
|
|
23
23
|
"directory": "packages/rig"
|
|
24
24
|
},
|
|
25
|
-
"homepage": "https://github.com/lloyal-ai/
|
|
25
|
+
"homepage": "https://github.com/lloyal-ai/hdk/tree/main/packages/rig#readme",
|
|
26
26
|
"bugs": {
|
|
27
|
-
"url": "https://github.com/lloyal-ai/
|
|
27
|
+
"url": "https://github.com/lloyal-ai/hdk/issues"
|
|
28
28
|
},
|
|
29
29
|
"keywords": [
|
|
30
30
|
"llm",
|
|
@@ -40,14 +40,14 @@
|
|
|
40
40
|
"build": "tsc -b"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@lloyal-labs/lloyal-agents": "^
|
|
44
|
-
"@lloyal-labs/sdk": "^
|
|
43
|
+
"@lloyal-labs/lloyal-agents": "^2.0.0",
|
|
44
|
+
"@lloyal-labs/sdk": "^2.0.0",
|
|
45
45
|
"@mozilla/readability": "^0.6.0",
|
|
46
46
|
"effection": "^4.0.2",
|
|
47
47
|
"linkedom": "^0.18.12"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@lloyal-labs/lloyal.node": "^2.0
|
|
50
|
+
"@lloyal-labs/lloyal.node": "^2.1.0"
|
|
51
51
|
},
|
|
52
52
|
"files": [
|
|
53
53
|
"dist/"
|