@lloyal-labs/rig 1.3.0 → 1.5.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/dist/index.d.ts +10 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -7
- package/dist/index.js.map +1 -1
- package/dist/node.d.ts +3 -2
- package/dist/node.d.ts.map +1 -1
- package/dist/node.js +4 -6
- package/dist/node.js.map +1 -1
- package/dist/reranker.d.ts +1 -0
- package/dist/reranker.d.ts.map +1 -1
- package/dist/reranker.js +5 -0
- package/dist/reranker.js.map +1 -1
- package/dist/sources/corpus.d.ts +24 -36
- package/dist/sources/corpus.d.ts.map +1 -1
- package/dist/sources/corpus.js +18 -42
- package/dist/sources/corpus.js.map +1 -1
- package/dist/sources/index.d.ts +1 -1
- package/dist/sources/index.js +1 -1
- package/dist/sources/types.d.ts +6 -18
- package/dist/sources/types.d.ts.map +1 -1
- package/dist/sources/web.d.ts +25 -32
- package/dist/sources/web.d.ts.map +1 -1
- package/dist/sources/web.js +34 -59
- package/dist/sources/web.js.map +1 -1
- package/dist/tools/fetch-page.d.ts.map +1 -1
- package/dist/tools/fetch-page.js +41 -23
- package/dist/tools/fetch-page.js.map +1 -1
- package/dist/tools/index.d.ts +2 -8
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +4 -9
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/search.d.ts.map +1 -1
- package/dist/tools/search.js +5 -1
- package/dist/tools/search.js.map +1 -1
- package/dist/tools/types.d.ts +2 -0
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/tools/web-search.d.ts +2 -2
- package/dist/tools/web-search.d.ts.map +1 -1
- package/dist/tools/web-search.js +36 -2
- package/dist/tools/web-search.js.map +1 -1
- package/package.json +2 -2
- package/dist/sources/corpus-research.md +0 -14
- package/dist/sources/extract.md +0 -5
- package/dist/sources/search-extract.md +0 -6
- package/dist/sources/web-research.md +0 -12
- package/dist/tools/research.d.ts +0 -57
- package/dist/tools/research.d.ts.map +0 -1
- package/dist/tools/research.js +0 -95
- package/dist/tools/research.js.map +0 -1
- package/dist/tools/web-research.d.ts +0 -60
- package/dist/tools/web-research.d.ts.map +0 -1
- package/dist/tools/web-research.js +0 -101
- package/dist/tools/web-research.js.map +0 -1
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
You are a research assistant investigating questions using the web. Your tools:
|
|
2
|
-
- **web_search**: search the web — returns results with titles, snippets, and URLs
|
|
3
|
-
- **fetch_page**: fetch a URL and extract its article content — use to read promising search results or follow links
|
|
4
|
-
- **web_research**: spawn parallel sub-agents that each run their own web_search/fetch_page cycle — call with `{"questions": ["q1", "q2", ...]}`
|
|
5
|
-
- **report**: submit your final findings with direct quotes, data points, and source URLs from the pages you read. Include what you found AND what you checked but could not find
|
|
6
|
-
|
|
7
|
-
Process:
|
|
8
|
-
1. Search the web with focused queries targeting specific aspects of the question.
|
|
9
|
-
2. Read the most promising results with fetch_page. Follow links within pages when they lead to more authoritative content.
|
|
10
|
-
3. After reading results, state what you've established so far and what gaps remain.
|
|
11
|
-
4. If clear gaps remain, call web_research again with targeted sub-questions to fill them.
|
|
12
|
-
5. Call report() with direct quotes, data points, and source URLs. State what you found AND what you checked but could not find. Do not summarize — preserve detail.
|
package/dist/tools/research.d.ts
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import type { Operation } from 'effection';
|
|
2
|
-
import { Tool } from '@lloyal-labs/lloyal-agents';
|
|
3
|
-
import type { JsonSchema, Toolkit, ToolContext, PressureThresholds } from '@lloyal-labs/lloyal-agents';
|
|
4
|
-
/**
|
|
5
|
-
* Configuration for {@link ResearchTool}
|
|
6
|
-
*
|
|
7
|
-
* @category Rig
|
|
8
|
-
*/
|
|
9
|
-
export interface ResearchToolOpts {
|
|
10
|
-
/** System prompt for each spawned research agent */
|
|
11
|
-
systemPrompt: string;
|
|
12
|
-
/** Prompt pair used to extract findings from hard-cut agents */
|
|
13
|
-
reporterPrompt: {
|
|
14
|
-
system: string;
|
|
15
|
-
user: string;
|
|
16
|
-
};
|
|
17
|
-
/** Maximum tool-use turns per research agent (default: 20) */
|
|
18
|
-
maxTurns?: number;
|
|
19
|
-
/** Enable trace logging for sub-agent pools */
|
|
20
|
-
trace?: boolean;
|
|
21
|
-
/** Context pressure thresholds for sub-agent pools */
|
|
22
|
-
pressure?: PressureThresholds;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Spawn parallel research agents for sub-questions (corpus source)
|
|
26
|
-
*
|
|
27
|
-
* Creates a {@link withSharedRoot | shared root} and runs a
|
|
28
|
-
* {@link useAgentPool | pool} of research agents, one per question.
|
|
29
|
-
* Each agent has access to the full toolkit (search, read_file,
|
|
30
|
-
* grep, report). Agents that hit the turn limit without reporting
|
|
31
|
-
* are forced through a reporter pass that extracts partial findings.
|
|
32
|
-
*
|
|
33
|
-
* Call {@link ResearchTool.setToolkit | setToolkit()} before first
|
|
34
|
-
* execution to wire the toolkit into the sub-agent pool.
|
|
35
|
-
*
|
|
36
|
-
* @category Rig
|
|
37
|
-
*/
|
|
38
|
-
export declare class ResearchTool extends Tool<{
|
|
39
|
-
questions: string[];
|
|
40
|
-
}> {
|
|
41
|
-
readonly name = "research";
|
|
42
|
-
readonly description = "Spawn parallel research agents to investigate sub-questions. Each question gets its own agent.";
|
|
43
|
-
readonly parameters: JsonSchema;
|
|
44
|
-
private _systemPrompt;
|
|
45
|
-
private _reporterPrompt;
|
|
46
|
-
private _maxTurns;
|
|
47
|
-
private _trace;
|
|
48
|
-
private _pressure?;
|
|
49
|
-
private _toolkit;
|
|
50
|
-
constructor(opts: ResearchToolOpts);
|
|
51
|
-
/** Inject the toolkit that sub-agents will use. Must be called before execute. */
|
|
52
|
-
setToolkit(toolkit: Toolkit): void;
|
|
53
|
-
execute(args: {
|
|
54
|
-
questions: string[];
|
|
55
|
-
}, context?: ToolContext): Operation<unknown>;
|
|
56
|
-
}
|
|
57
|
-
//# sourceMappingURL=research.d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,EAAE,CAAA;KAAE,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC,OAAO,CAAC;CA+CnF"}
|
package/dist/tools/research.js
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ResearchTool = void 0;
|
|
4
|
-
const lloyal_agents_1 = require("@lloyal-labs/lloyal-agents");
|
|
5
|
-
/**
|
|
6
|
-
* Spawn parallel research agents for sub-questions (corpus source)
|
|
7
|
-
*
|
|
8
|
-
* Creates a {@link withSharedRoot | shared root} and runs a
|
|
9
|
-
* {@link useAgentPool | pool} of research agents, one per question.
|
|
10
|
-
* Each agent has access to the full toolkit (search, read_file,
|
|
11
|
-
* grep, report). Agents that hit the turn limit without reporting
|
|
12
|
-
* are forced through a reporter pass that extracts partial findings.
|
|
13
|
-
*
|
|
14
|
-
* Call {@link ResearchTool.setToolkit | setToolkit()} before first
|
|
15
|
-
* execution to wire the toolkit into the sub-agent pool.
|
|
16
|
-
*
|
|
17
|
-
* @category Rig
|
|
18
|
-
*/
|
|
19
|
-
class ResearchTool extends lloyal_agents_1.Tool {
|
|
20
|
-
name = 'research';
|
|
21
|
-
description = 'Spawn parallel research agents to investigate sub-questions. Each question gets its own agent.';
|
|
22
|
-
parameters = {
|
|
23
|
-
type: 'object',
|
|
24
|
-
properties: {
|
|
25
|
-
questions: {
|
|
26
|
-
type: 'array',
|
|
27
|
-
items: { type: 'string' },
|
|
28
|
-
description: 'Sub-questions to research in parallel',
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
required: ['questions'],
|
|
32
|
-
};
|
|
33
|
-
_systemPrompt;
|
|
34
|
-
_reporterPrompt;
|
|
35
|
-
_maxTurns;
|
|
36
|
-
_trace;
|
|
37
|
-
_pressure;
|
|
38
|
-
_toolkit = null;
|
|
39
|
-
constructor(opts) {
|
|
40
|
-
super();
|
|
41
|
-
this._systemPrompt = opts.systemPrompt;
|
|
42
|
-
this._reporterPrompt = opts.reporterPrompt;
|
|
43
|
-
this._maxTurns = opts.maxTurns ?? 20;
|
|
44
|
-
this._trace = opts.trace ?? false;
|
|
45
|
-
this._pressure = opts.pressure;
|
|
46
|
-
}
|
|
47
|
-
/** Inject the toolkit that sub-agents will use. Must be called before execute. */
|
|
48
|
-
setToolkit(toolkit) {
|
|
49
|
-
this._toolkit = toolkit;
|
|
50
|
-
}
|
|
51
|
-
*execute(args, context) {
|
|
52
|
-
const questions = args?.questions;
|
|
53
|
-
if (!Array.isArray(questions) || questions.length === 0) {
|
|
54
|
-
return { error: 'questions must be a non-empty array of strings', example: '{"questions": ["q1", "q2"]}' };
|
|
55
|
-
}
|
|
56
|
-
if (!this._toolkit)
|
|
57
|
-
throw new Error('ResearchTool: setToolkit() must be called before execute');
|
|
58
|
-
const tw = yield* lloyal_agents_1.Trace.expect();
|
|
59
|
-
const scope = (0, lloyal_agents_1.traceScope)(tw, null, 'researchTool', { questionCount: questions.length });
|
|
60
|
-
const toolkit = this._toolkit;
|
|
61
|
-
const systemPrompt = this._systemPrompt;
|
|
62
|
-
const reporterPrompt = this._reporterPrompt;
|
|
63
|
-
const maxTurns = this._maxTurns;
|
|
64
|
-
const trace = this._trace;
|
|
65
|
-
const pressure = this._pressure;
|
|
66
|
-
return yield* (0, lloyal_agents_1.withSharedRoot)({ systemPrompt, tools: toolkit.toolsJson, parent: context?.branch }, function* (root) {
|
|
67
|
-
const pool = yield* (0, lloyal_agents_1.useAgentPool)({
|
|
68
|
-
tasks: questions.map(q => ({
|
|
69
|
-
systemPrompt,
|
|
70
|
-
content: q,
|
|
71
|
-
tools: toolkit.toolsJson,
|
|
72
|
-
parent: root,
|
|
73
|
-
})),
|
|
74
|
-
tools: toolkit.toolMap,
|
|
75
|
-
terminalTool: 'report',
|
|
76
|
-
pruneOnReport: true,
|
|
77
|
-
maxTurns,
|
|
78
|
-
trace,
|
|
79
|
-
pressure,
|
|
80
|
-
reportPrompt: reporterPrompt,
|
|
81
|
-
});
|
|
82
|
-
const result = {
|
|
83
|
-
findings: pool.agents.map(a => a.findings).filter(Boolean),
|
|
84
|
-
supportingFindings: pool.agents.flatMap(a => a.childFindings ?? []),
|
|
85
|
-
agentCount: pool.agents.length,
|
|
86
|
-
totalTokens: pool.totalTokens,
|
|
87
|
-
totalToolCalls: pool.totalToolCalls,
|
|
88
|
-
};
|
|
89
|
-
scope.close();
|
|
90
|
-
return result;
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
exports.ResearchTool = ResearchTool;
|
|
95
|
-
//# sourceMappingURL=research.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"research.js","sourceRoot":"","sources":["../../src/tools/research.ts"],"names":[],"mappings":";;;AACA,8DAAmG;AAqBnG;;;;;;;;;;;;;GAaG;AACH,MAAa,YAAa,SAAQ,oBAA6B;IACpD,IAAI,GAAG,UAAU,CAAC;IAClB,WAAW,GAAG,gGAAgG,CAAC;IAC/G,UAAU,GAAe;QAChC,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,SAAS,EAAE;gBACT,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBACzB,WAAW,EAAE,uCAAuC;aACrD;SACF;QACD,QAAQ,EAAE,CAAC,WAAW,CAAC;KACxB,CAAC;IAEM,aAAa,CAAS;IACtB,eAAe,CAAmC;IAClD,SAAS,CAAS;IAClB,MAAM,CAAU;IAChB,SAAS,CAAsB;IAC/B,QAAQ,GAAmB,IAAI,CAAC;IAExC,YAAY,IAAsB;QAChC,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,YAAY,CAAC;QACvC,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,cAAc,CAAC;QAC3C,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,QAAQ,IAAI,EAAE,CAAC;QACrC,IAAI,CAAC,M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QAAQ,CAAC,EAAC,IAAI;YACZ,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,IAAA,4BAAY,EAAC;gBAC/B,KAAK,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;oBACzB,YAAY;oBACZ,OAAO,EAAE,CAAC;oBACV,KAAK,EAAE,OAAO,CAAC,SAAS;oBACxB,MAAM,EAAE,IAAI;iBACb,CAAC,CAAC;gBACH,KAAK,EAAE,OAAO,CAAC,OAAO;gBACtB,YAAY,EAAE,QAAQ;gBACtB,aAAa,EAAE,IAAI;gBACnB,QAAQ;gBACR,KAAK;gBACL,QAAQ;gBACR,YAAY,EAAE,cAAc;aAC7B,CAAC,CAAC;YAEH,MAAM,MAAM,GAAG;gBACb,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC;gBAC1D,kBAAkB,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,aAAa,IAAI,EAAE,CAAC;gBACnE,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM;gBAC9B,WAAW,EAAE,IAAI,CAAC,WAAW;gBAC7B,cAAc,EAAE,IAAI,CAAC,cAAc;aACpC,CAAC;YACF,KAAK,CAAC,KAAK,EAAE,CAAC;YACd,OAAO,MAAM,CAAC;QAChB,CAAC,CACF,CAAC;IACJ,CAAC;CACF;AAnFD,oCAmFC"}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import type { Operation } from "effection";
|
|
2
|
-
import { Tool } from "@lloyal-labs/lloyal-agents";
|
|
3
|
-
import type { JsonSchema, Toolkit, ToolContext, PressureThresholds } from "@lloyal-labs/lloyal-agents";
|
|
4
|
-
/**
|
|
5
|
-
* Configuration for {@link WebResearchTool}.
|
|
6
|
-
*
|
|
7
|
-
* @category Rig
|
|
8
|
-
*/
|
|
9
|
-
export interface WebResearchToolOpts {
|
|
10
|
-
/** Override the tool name exposed to the model. @defaultValue "research" */
|
|
11
|
-
name?: string;
|
|
12
|
-
/** Override the tool description exposed to the model. */
|
|
13
|
-
description?: string;
|
|
14
|
-
/** System prompt given to each spawned web-research sub-agent. */
|
|
15
|
-
systemPrompt: string;
|
|
16
|
-
/** Prompts used for grammar-constrained scratchpad extraction on hard-cut agents. */
|
|
17
|
-
reporterPrompt: {
|
|
18
|
-
system: string;
|
|
19
|
-
user: string;
|
|
20
|
-
};
|
|
21
|
-
/** Maximum tool-use turns per sub-agent before hard cut. @defaultValue 20 */
|
|
22
|
-
maxTurns?: number;
|
|
23
|
-
/** Enable trace output for sub-agent execution. @defaultValue false */
|
|
24
|
-
trace?: boolean;
|
|
25
|
-
/** Context pressure thresholds for the sub-agent pool. */
|
|
26
|
-
pressure?: PressureThresholds;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Spawn parallel web-research sub-agents for a set of questions.
|
|
30
|
-
*
|
|
31
|
-
* Similar to {@link ResearchTool} but designed for web-source pipelines.
|
|
32
|
-
* Each question gets its own agent in a shared-root pool with access
|
|
33
|
-
* to web_search, fetch_page, and report tools. Hard-cut agents that
|
|
34
|
-
* exhaust their turns without reporting get a grammar-constrained
|
|
35
|
-
* scratchpad extraction via {@link generate} to recover partial findings.
|
|
36
|
-
*
|
|
37
|
-
* Must call {@link setToolkit} before the tool is executed.
|
|
38
|
-
*
|
|
39
|
-
* @category Rig
|
|
40
|
-
*/
|
|
41
|
-
export declare class WebResearchTool extends Tool<{
|
|
42
|
-
questions: string[];
|
|
43
|
-
}> {
|
|
44
|
-
readonly name: string;
|
|
45
|
-
readonly description: string;
|
|
46
|
-
readonly parameters: JsonSchema;
|
|
47
|
-
private _systemPrompt;
|
|
48
|
-
private _reporterPrompt;
|
|
49
|
-
private _maxTurns;
|
|
50
|
-
private _trace;
|
|
51
|
-
private _pressure?;
|
|
52
|
-
private _toolkit;
|
|
53
|
-
constructor(opts: WebResearchToolOpts);
|
|
54
|
-
/** Inject the toolkit that sub-agents will use. Must be called before execute. */
|
|
55
|
-
setToolkit(toolkit: Toolkit): void;
|
|
56
|
-
execute(args: {
|
|
57
|
-
questions: string[];
|
|
58
|
-
}, context?: ToolContext): Operation<unknown>;
|
|
59
|
-
}
|
|
60
|
-
//# sourceMappingURL=web-research.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"web-research.d.ts","sourceRoot":"","sources":["../../src/tools/web-research.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EACL,IAAI,EAKL,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EACV,UAAU,EACV,OAAO,EACP,WAAW,EACX,kBAAkB,EACnB,MAAM,4BAA4B,CAAC;AAEpC;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,4EAA4E;IAC5E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,0DAA0D;IAC1D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kEAAkE;IAClE,YAAY,EAAE,MAAM,CAAC;IACrB,qFAAqF;IACrF,cAAc,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IACjD,6EAA6E;IAC7E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,uEAAuE;IACvE,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,kBAAkB,CAAC;CAC/B;AAED;;;;;;;;;;;;GAYG;AACH,qBAAa,eAAgB,SAAQ,IAAI,CAAC;IAAE,SAAS,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;IAChE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,UAAU,CAU7B;IAEF,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,eAAe,CAAmC;IAC1D,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,MAAM,CAAU;IACxB,OAAO,CAAC,SAAS,CAAC,CAAqB;IACvC,OAAO,CAAC,QAAQ,CAAwB;gBAE5B,IAAI,EAAE,mBAAmB;IAarC,kFAAkF;IAClF,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAIjC,OAAO,CAAC,IAAI,EAAE;QAAE,SAAS,EAAE,MAAM,EAAE,CAAA;KAAE,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC,OAAO,CAAC;CAsDnF"}
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WebResearchTool = void 0;
|
|
4
|
-
const lloyal_agents_1 = require("@lloyal-labs/lloyal-agents");
|
|
5
|
-
/**
|
|
6
|
-
* Spawn parallel web-research sub-agents for a set of questions.
|
|
7
|
-
*
|
|
8
|
-
* Similar to {@link ResearchTool} but designed for web-source pipelines.
|
|
9
|
-
* Each question gets its own agent in a shared-root pool with access
|
|
10
|
-
* to web_search, fetch_page, and report tools. Hard-cut agents that
|
|
11
|
-
* exhaust their turns without reporting get a grammar-constrained
|
|
12
|
-
* scratchpad extraction via {@link generate} to recover partial findings.
|
|
13
|
-
*
|
|
14
|
-
* Must call {@link setToolkit} before the tool is executed.
|
|
15
|
-
*
|
|
16
|
-
* @category Rig
|
|
17
|
-
*/
|
|
18
|
-
class WebResearchTool extends lloyal_agents_1.Tool {
|
|
19
|
-
name;
|
|
20
|
-
description;
|
|
21
|
-
parameters = {
|
|
22
|
-
type: "object",
|
|
23
|
-
properties: {
|
|
24
|
-
questions: {
|
|
25
|
-
type: "array",
|
|
26
|
-
items: { type: "string" },
|
|
27
|
-
description: "Sub-questions to research in parallel",
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
required: ["questions"],
|
|
31
|
-
};
|
|
32
|
-
_systemPrompt;
|
|
33
|
-
_reporterPrompt;
|
|
34
|
-
_maxTurns;
|
|
35
|
-
_trace;
|
|
36
|
-
_pressure;
|
|
37
|
-
_toolkit = null;
|
|
38
|
-
constructor(opts) {
|
|
39
|
-
super();
|
|
40
|
-
this.name = opts.name ?? "research";
|
|
41
|
-
this.description =
|
|
42
|
-
opts.description ??
|
|
43
|
-
"Spawn parallel research agents to investigate sub-questions. Each question gets its own agent.";
|
|
44
|
-
this._systemPrompt = opts.systemPrompt;
|
|
45
|
-
this._reporterPrompt = opts.reporterPrompt;
|
|
46
|
-
this._maxTurns = opts.maxTurns ?? 20;
|
|
47
|
-
this._trace = opts.trace ?? false;
|
|
48
|
-
this._pressure = opts.pressure;
|
|
49
|
-
}
|
|
50
|
-
/** Inject the toolkit that sub-agents will use. Must be called before execute. */
|
|
51
|
-
setToolkit(toolkit) {
|
|
52
|
-
this._toolkit = toolkit;
|
|
53
|
-
}
|
|
54
|
-
*execute(args, context) {
|
|
55
|
-
const questions = args?.questions;
|
|
56
|
-
if (!Array.isArray(questions) || questions.length === 0) {
|
|
57
|
-
return {
|
|
58
|
-
error: "questions must be a non-empty array of strings",
|
|
59
|
-
example: '{"questions": ["q1", "q2"]}',
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
if (!this._toolkit)
|
|
63
|
-
throw new Error("WebResearchTool: setToolkit() must be called before execute");
|
|
64
|
-
const tw = yield* lloyal_agents_1.Trace.expect();
|
|
65
|
-
const scope = (0, lloyal_agents_1.traceScope)(tw, null, 'webResearchTool', { questionCount: questions.length });
|
|
66
|
-
const toolkit = this._toolkit;
|
|
67
|
-
const systemPrompt = this._systemPrompt;
|
|
68
|
-
const reporterPrompt = this._reporterPrompt;
|
|
69
|
-
const maxTurns = this._maxTurns;
|
|
70
|
-
const trace = this._trace;
|
|
71
|
-
const pressure = this._pressure;
|
|
72
|
-
return yield* (0, lloyal_agents_1.withSharedRoot)({ systemPrompt, tools: toolkit.toolsJson, parent: context?.branch }, function* (root) {
|
|
73
|
-
const pool = yield* (0, lloyal_agents_1.useAgentPool)({
|
|
74
|
-
tasks: questions.map((q) => ({
|
|
75
|
-
systemPrompt,
|
|
76
|
-
content: q,
|
|
77
|
-
tools: toolkit.toolsJson,
|
|
78
|
-
parent: root,
|
|
79
|
-
})),
|
|
80
|
-
tools: toolkit.toolMap,
|
|
81
|
-
terminalTool: "report",
|
|
82
|
-
pruneOnReport: true,
|
|
83
|
-
maxTurns,
|
|
84
|
-
trace,
|
|
85
|
-
pressure,
|
|
86
|
-
reportPrompt: reporterPrompt,
|
|
87
|
-
});
|
|
88
|
-
const result = {
|
|
89
|
-
findings: pool.agents.map((a) => a.findings).filter(Boolean),
|
|
90
|
-
supportingFindings: pool.agents.flatMap((a) => a.childFindings ?? []),
|
|
91
|
-
agentCount: pool.agents.length,
|
|
92
|
-
totalTokens: pool.totalTokens,
|
|
93
|
-
totalToolCalls: pool.totalToolCalls,
|
|
94
|
-
};
|
|
95
|
-
scope.close();
|
|
96
|
-
return result;
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
exports.WebResearchTool = WebResearchTool;
|
|
101
|
-
//# sourceMappingURL=web-research.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"web-research.js","sourceRoot":"","sources":["../../src/tools/web-research.ts"],"names":[],"mappings":";;;AACA,8DAMoC;AA8BpC;;;;;;;;;;;;GAYG;AACH,MAAa,eAAgB,SAAQ,oBAA6B;IACvD,IAAI,CAAS;IACb,WAAW,CAAS;IACpB,UAAU,GAAe;QAChC,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,SAAS,EAAE;gBACT,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBACzB,WAAW,EAAE,uCAAuC;aACrD;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