@lloyal-labs/rig 1.5.6 → 1.7.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 +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 +45 -0
- package/dist/tools/delegate.d.ts.map +1 -0
- package/dist/tools/delegate.js +174 -0
- package/dist/tools/delegate.js.map +1 -0
- package/dist/tools/fetch-page.d.ts +5 -5
- package/dist/tools/fetch-page.d.ts.map +1 -1
- package/dist/tools/fetch-page.js +95 -43
- 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 +27 -12
- package/dist/tools/plan.d.ts.map +1 -1
- package/dist/tools/plan.js +40 -40
- package/dist/tools/plan.js.map +1 -1
- package/dist/tools/web-search.d.ts +5 -5
- package/dist/tools/web-search.d.ts.map +1 -1
- package/dist/tools/web-search.js +68 -27
- package/dist/tools/web-search.js.map +1 -1
- package/package.json +4 -4
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, PlanQuestion, SearchProvider, SearchResult, Reranker, ScoredChunk, ScoredResult, } from './tools';
|
|
13
|
+
export { createTools, reportTool, ReportTool, WebSearchTool, TavilyProvider, FetchPageTool, DelegateTool, PlanTool, taskToContent, } from './tools';
|
|
14
|
+
export type { DelegateToolOpts, PlanToolOpts, PlanResult, PlanQuestion, 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,YAAY,EAAE,YAAY,EACtC,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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AE;QAAE,QAAQ,EAAE,QAAQ,CAAA;KAAE,GAAG,SAAS,CAAC,IAAI,CAAC;IAgBnD,kBAAkB;IAClB,SAAS,IAAI,KAAK,EAAE;CAGrB"}
|
package/dist/sources/web.js
CHANGED
|
@@ -32,8 +32,8 @@ class BufferingFetchPage extends fetch_page_1.FetchPageTool {
|
|
|
32
32
|
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,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,CAAC,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;QACpE,IAAI,CAAC,UAAU,GAAG,IAAI,0BAAa,CAAC,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC5D,CAAC;IAED,kBAAkB;IAClB,IAAI,KAAK;QACP,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,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,45 @@
|
|
|
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. */
|
|
19
|
+
poolOpts: CreateAgentPoolOpts;
|
|
20
|
+
/** Factory for per-invocation policy. Called fresh each time the tool fires so time budgets start from delegation, not from pool setup. */
|
|
21
|
+
createPolicy?: () => AgentPolicy;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Tool that calls agentPool() recursively.
|
|
25
|
+
*
|
|
26
|
+
* Agents can delegate sub-tasks to parallel sub-agents at arbitrary depth,
|
|
27
|
+
* bounded by KV pressure. Sub-agents fork from the calling agent's branch
|
|
28
|
+
* (Continuous Context) and inherit the full attention state.
|
|
29
|
+
*
|
|
30
|
+
* Includes entailment gating (filters drifted tasks) and echo detection
|
|
31
|
+
* (rejects paraphrases of the calling agent's own task).
|
|
32
|
+
*
|
|
33
|
+
* @category Rig
|
|
34
|
+
*/
|
|
35
|
+
export declare class DelegateTool extends Tool<Record<string, unknown>> {
|
|
36
|
+
readonly name: string;
|
|
37
|
+
readonly description: string;
|
|
38
|
+
readonly parameters: JsonSchema;
|
|
39
|
+
private _poolOpts;
|
|
40
|
+
private _extractTasks;
|
|
41
|
+
private _createPolicy?;
|
|
42
|
+
constructor(opts: DelegateToolOpts);
|
|
43
|
+
execute(args: Record<string, unknown>, context?: ToolContext): Operation<unknown>;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=delegate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delegate.d.ts","sourceRoot":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ty(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
|
+
_extractTasks;
|
|
35
|
+
_createPolicy;
|
|
36
|
+
constructor(opts) {
|
|
37
|
+
super();
|
|
38
|
+
this.name = opts.name ?? 'delegate';
|
|
39
|
+
this.description = opts.description ?? 'Delegate sub-tasks to parallel agents. Each task gets its own agent.';
|
|
40
|
+
this.parameters = opts.argsSchema ?? DEFAULT_ARGS_SCHEMA;
|
|
41
|
+
this._extractTasks = opts.extractTasks ?? ((args) => args.tasks);
|
|
42
|
+
this._poolOpts = opts.poolOpts;
|
|
43
|
+
this._createPolicy = opts.createPolicy;
|
|
44
|
+
}
|
|
45
|
+
*execute(args, context) {
|
|
46
|
+
let tasks;
|
|
47
|
+
try {
|
|
48
|
+
tasks = this._extractTasks(args);
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
return { error: 'Failed to extract tasks from arguments.' };
|
|
52
|
+
}
|
|
53
|
+
if (!Array.isArray(tasks) || tasks.length === 0) {
|
|
54
|
+
return { error: 'Tasks must be a non-empty array of strings.' };
|
|
55
|
+
}
|
|
56
|
+
const tw = yield* lloyal_agents_1.Trace.expect();
|
|
57
|
+
// Entailment gate: filter drifted/echoed tasks before spawning
|
|
58
|
+
const scorer = context?.scorer;
|
|
59
|
+
let filtered;
|
|
60
|
+
if (scorer) {
|
|
61
|
+
const allTasks = [...tasks];
|
|
62
|
+
const scores = yield* (0, effection_1.call)(() => scorer.scoreEntailmentBatch(tasks));
|
|
63
|
+
const surviving = [];
|
|
64
|
+
const rejected = [];
|
|
65
|
+
for (let i = 0; i < tasks.length; i++) {
|
|
66
|
+
if (scorer.shouldProceed(scores[i])) {
|
|
67
|
+
surviving.push(tasks[i]);
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
rejected.push({ task: tasks[i], score: scores[i] });
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (rejected.length > 0)
|
|
74
|
+
filtered = rejected;
|
|
75
|
+
let _diagAgent;
|
|
76
|
+
try {
|
|
77
|
+
_diagAgent = yield* lloyal_agents_1.CallingAgent.get();
|
|
78
|
+
}
|
|
79
|
+
catch { /* top-level */ }
|
|
80
|
+
tw.write({
|
|
81
|
+
traceId: tw.nextId(), parentTraceId: null, ts: performance.now(),
|
|
82
|
+
type: 'entailment:delegate',
|
|
83
|
+
tool: this.name,
|
|
84
|
+
callingAgentId: _diagAgent?.id,
|
|
85
|
+
callingAgentTaskLength: _diagAgent?.task?.length,
|
|
86
|
+
callingAgentTask: _diagAgent?.task?.slice(0, 200),
|
|
87
|
+
tasks: allTasks.map((text, i) => ({
|
|
88
|
+
text: text.slice(0, 200),
|
|
89
|
+
score: scores[i],
|
|
90
|
+
kept: scorer.shouldProceed(scores[i]),
|
|
91
|
+
})),
|
|
92
|
+
});
|
|
93
|
+
if (surviving.length === 0) {
|
|
94
|
+
return { filtered, error: 'All proposed tasks drifted from the original query.' };
|
|
95
|
+
}
|
|
96
|
+
tasks = surviving;
|
|
97
|
+
// Echo guard — only fires when the calling agent has a parent (depth 2+).
|
|
98
|
+
// At depth 1 (first delegation from a harness-spawned agent), there's no relay
|
|
99
|
+
// chain to detect — sub-questions are expected to be similar to the task they decompose.
|
|
100
|
+
const echoThreshold = this._poolOpts.echoThreshold ?? 0.8;
|
|
101
|
+
let callingAgent;
|
|
102
|
+
try {
|
|
103
|
+
callingAgent = yield* lloyal_agents_1.CallingAgent.get();
|
|
104
|
+
}
|
|
105
|
+
catch { /* top-level */ }
|
|
106
|
+
if (callingAgent?.task && callingAgent.parent) {
|
|
107
|
+
const echoScores = yield* (0, effection_1.call)(() => scorer.scoreSimilarityBatch(callingAgent.task, tasks));
|
|
108
|
+
const minEchoScore = Math.min(...echoScores);
|
|
109
|
+
const echoRejected = minEchoScore > echoThreshold;
|
|
110
|
+
tw.write({
|
|
111
|
+
traceId: tw.nextId(), parentTraceId: null, ts: performance.now(),
|
|
112
|
+
type: 'entailment:delegate:echo',
|
|
113
|
+
tool: this.name,
|
|
114
|
+
agentTask: callingAgent.task.slice(0, 200),
|
|
115
|
+
tasks: tasks.map((text, i) => ({ text: text.slice(0, 200), echoScore: echoScores[i] })),
|
|
116
|
+
threshold: echoThreshold,
|
|
117
|
+
rejected: echoRejected,
|
|
118
|
+
});
|
|
119
|
+
if (echoRejected) {
|
|
120
|
+
return {
|
|
121
|
+
filtered,
|
|
122
|
+
echoRejected: true,
|
|
123
|
+
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.',
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
if (this._poolOpts.checkAncestorEcho) {
|
|
127
|
+
const ancestorTasks = callingAgent.walkAncestors(a => a.task ? [a.task] : [])
|
|
128
|
+
.filter(t => t !== callingAgent.task);
|
|
129
|
+
for (const ancestorTask of ancestorTasks) {
|
|
130
|
+
const ancestorScores = yield* (0, effection_1.call)(() => scorer.scoreSimilarityBatch(ancestorTask, tasks));
|
|
131
|
+
if (Math.min(...ancestorScores) > echoThreshold) {
|
|
132
|
+
tw.write({
|
|
133
|
+
traceId: tw.nextId(), parentTraceId: null, ts: performance.now(),
|
|
134
|
+
type: 'entailment:delegate:echo',
|
|
135
|
+
tool: this.name,
|
|
136
|
+
agentTask: ancestorTask.slice(0, 200),
|
|
137
|
+
tasks: tasks.map((text, i) => ({ text: text.slice(0, 200), echoScore: ancestorScores[i] })),
|
|
138
|
+
threshold: echoThreshold,
|
|
139
|
+
rejected: true,
|
|
140
|
+
});
|
|
141
|
+
return {
|
|
142
|
+
filtered,
|
|
143
|
+
echoRejected: true,
|
|
144
|
+
error: 'Your sub-questions echo an ancestor task. Report what you found instead of re-delegating.',
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
const opts = this._poolOpts;
|
|
152
|
+
const scope = (0, lloyal_agents_1.traceScope)(tw, null, `delegate:${this.name}`, { taskCount: tasks.length, filtered: filtered?.length ?? 0 });
|
|
153
|
+
const pool = yield* (0, lloyal_agents_1.agentPool)({
|
|
154
|
+
...opts,
|
|
155
|
+
...(this._createPolicy ? { policy: this._createPolicy() } : {}),
|
|
156
|
+
tasks: tasks.map(t => ({ systemPrompt: opts.systemPrompt, content: t })),
|
|
157
|
+
parent: context?.branch,
|
|
158
|
+
pruneOnReport: opts.pruneOnReport ?? true,
|
|
159
|
+
scorer: context?.scorer,
|
|
160
|
+
});
|
|
161
|
+
const result = {
|
|
162
|
+
results: pool.agents.map((a) => a.result).filter(Boolean),
|
|
163
|
+
nestedResults: pool.agents.flatMap((a) => a.nestedResults ?? []),
|
|
164
|
+
agentCount: pool.agents.length,
|
|
165
|
+
totalTokens: pool.totalTokens,
|
|
166
|
+
totalToolCalls: pool.totalToolCalls,
|
|
167
|
+
...(filtered ? { filtered } : {}),
|
|
168
|
+
};
|
|
169
|
+
scope.close();
|
|
170
|
+
return result;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
exports.DelegateTool = DelegateTool;
|
|
174
|
+
//# sourceMappingURL=delegate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delegate.js","sourceRoot":"","sources":["../../src/tools/delegate.ts"],"names":[],"mappings":";;;AACA,yCAAiC;AACjC,8DAMoC;AA6BpC,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,CAAsB;IAC/B,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,CAAC,IAA6B,EAAE,EAAE,CAAC,IAAI,CAAC,KAAiB,CAAC,CAAC;QACtG,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC/B,IAAI,C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AAM;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;AA1JD,oCA0JC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { Operation } from
|
|
2
|
-
import { Tool } from
|
|
3
|
-
import type { JsonSchema, ToolContext } from
|
|
4
|
-
import type { Reranker } from
|
|
1
|
+
import type { Operation } from "effection";
|
|
2
|
+
import { Tool } from "@lloyal-labs/lloyal-agents";
|
|
3
|
+
import type { JsonSchema, ToolContext } from "@lloyal-labs/lloyal-agents";
|
|
4
|
+
import type { Reranker } from "./types";
|
|
5
5
|
/**
|
|
6
6
|
* Fetch a web page and extract readable article content.
|
|
7
7
|
*
|
|
@@ -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,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,7 +9,7 @@ function selectTopChunks(scored, chunks, topK, tokenBudget) {
|
|
|
9
9
|
const selected = [];
|
|
10
10
|
let tokenTotal = 0;
|
|
11
11
|
for (const sc of scored.slice(0, topK)) {
|
|
12
|
-
const chunk = chunks.find(c => c.resource === sc.file && c.startLine === sc.startLine);
|
|
12
|
+
const chunk = chunks.find((c) => c.resource === sc.file && c.startLine === sc.startLine);
|
|
13
13
|
if (!chunk?.text)
|
|
14
14
|
continue;
|
|
15
15
|
const chunkTokens = chunk.tokens.length || Math.ceil(chunk.text.length / 4);
|
|
@@ -18,10 +18,14 @@ function selectTopChunks(scored, chunks, topK, tokenBudget) {
|
|
|
18
18
|
if (selected.length === 0) {
|
|
19
19
|
const charLimit = tokenBudget * 4;
|
|
20
20
|
let truncated = chunk.text.slice(0, charLimit);
|
|
21
|
-
const lastBreak = Math.max(truncated.lastIndexOf(
|
|
21
|
+
const lastBreak = Math.max(truncated.lastIndexOf("\n\n"), truncated.lastIndexOf(". "));
|
|
22
22
|
if (lastBreak > charLimit * 0.4)
|
|
23
23
|
truncated = truncated.slice(0, lastBreak + 1);
|
|
24
|
-
selected.push({
|
|
24
|
+
selected.push({
|
|
25
|
+
text: truncated + "\n\n[truncated]",
|
|
26
|
+
heading: sc.heading,
|
|
27
|
+
score: sc.score,
|
|
28
|
+
});
|
|
25
29
|
}
|
|
26
30
|
break;
|
|
27
31
|
}
|
|
@@ -49,15 +53,18 @@ function selectTopChunks(scored, chunks, topK, tokenBudget) {
|
|
|
49
53
|
* @category Rig
|
|
50
54
|
*/
|
|
51
55
|
class FetchPageTool extends lloyal_agents_1.Tool {
|
|
52
|
-
name =
|
|
53
|
-
description =
|
|
56
|
+
name = "fetch_page";
|
|
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.";
|
|
54
58
|
parameters = {
|
|
55
|
-
type:
|
|
59
|
+
type: "object",
|
|
56
60
|
properties: {
|
|
57
|
-
url: { type:
|
|
58
|
-
query: {
|
|
61
|
+
url: { type: "string", description: "URL to fetch" },
|
|
62
|
+
query: {
|
|
63
|
+
type: "string",
|
|
64
|
+
description: "What to look for in this page (optional — improves relevance of returned content)",
|
|
65
|
+
},
|
|
59
66
|
},
|
|
60
|
-
required: [
|
|
67
|
+
required: ["url"],
|
|
61
68
|
};
|
|
62
69
|
_maxChars;
|
|
63
70
|
_reranker = null;
|
|
@@ -78,11 +85,30 @@ class FetchPageTool extends lloyal_agents_1.Tool {
|
|
|
78
85
|
*execute(args, context) {
|
|
79
86
|
const url = args.url?.trim();
|
|
80
87
|
if (!url)
|
|
81
|
-
return { error:
|
|
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
|
+
}
|
|
82
103
|
// Early reject PDF URLs
|
|
83
104
|
const lowerUrl = url.toLowerCase();
|
|
84
|
-
if (lowerUrl.endsWith(
|
|
85
|
-
|
|
105
|
+
if (lowerUrl.endsWith(".pdf") ||
|
|
106
|
+
lowerUrl.includes(".pdf?") ||
|
|
107
|
+
lowerUrl.includes(".pdf#")) {
|
|
108
|
+
return {
|
|
109
|
+
error: "PDF documents cannot be extracted. Try searching for an HTML version of this content.",
|
|
110
|
+
url,
|
|
111
|
+
};
|
|
86
112
|
}
|
|
87
113
|
const maxChars = this._maxChars;
|
|
88
114
|
const reranker = this._reranker;
|
|
@@ -96,48 +122,61 @@ class FetchPageTool extends lloyal_agents_1.Tool {
|
|
|
96
122
|
let res;
|
|
97
123
|
try {
|
|
98
124
|
res = await fetch(url, {
|
|
99
|
-
headers: {
|
|
125
|
+
headers: {
|
|
126
|
+
"User-Agent": "Mozilla/5.0 (compatible; lloyal-agents/1.0)",
|
|
127
|
+
},
|
|
100
128
|
signal: controller.signal,
|
|
101
129
|
});
|
|
102
130
|
}
|
|
103
131
|
catch (err) {
|
|
104
|
-
return {
|
|
132
|
+
return {
|
|
133
|
+
error: `Fetch failed: ${err.message}`,
|
|
134
|
+
url,
|
|
135
|
+
};
|
|
105
136
|
}
|
|
106
137
|
finally {
|
|
107
138
|
clearTimeout(timer);
|
|
108
139
|
}
|
|
109
140
|
if (!res.ok)
|
|
110
141
|
return { error: `HTTP ${res.status} ${res.statusText}`, url };
|
|
111
|
-
const contentType = res.headers.get(
|
|
112
|
-
if (contentType.includes(
|
|
113
|
-
return {
|
|
142
|
+
const contentType = res.headers.get("content-type") || "";
|
|
143
|
+
if (contentType.includes("application/pdf")) {
|
|
144
|
+
return {
|
|
145
|
+
error: "PDF documents cannot be extracted. Try searching for an HTML version of this content.",
|
|
146
|
+
url,
|
|
147
|
+
};
|
|
114
148
|
}
|
|
115
149
|
const html = await res.text();
|
|
116
|
-
const { parseHTML } = await Promise.resolve().then(() => require(
|
|
150
|
+
const { parseHTML } = await Promise.resolve().then(() => require("linkedom"));
|
|
117
151
|
const { document } = parseHTML(html);
|
|
118
152
|
if (!document || !document.documentElement) {
|
|
119
|
-
return { url, content:
|
|
153
|
+
return { url, content: "[Could not parse HTML]" };
|
|
120
154
|
}
|
|
121
|
-
const { Readability } = await Promise.resolve().then(() => require(
|
|
155
|
+
const { Readability } = await Promise.resolve().then(() => require("@mozilla/readability"));
|
|
122
156
|
const article = new Readability(document).parse();
|
|
123
157
|
if (!article)
|
|
124
|
-
return { url, content:
|
|
158
|
+
return { url, content: "[Could not extract article content]" };
|
|
125
159
|
return {
|
|
126
160
|
url,
|
|
127
|
-
title: article.title ??
|
|
128
|
-
content: article.textContent ??
|
|
129
|
-
articleHtml: article.content ??
|
|
130
|
-
excerpt: article.excerpt ??
|
|
161
|
+
title: article.title ?? "",
|
|
162
|
+
content: article.textContent ?? "",
|
|
163
|
+
articleHtml: article.content ?? "",
|
|
164
|
+
excerpt: article.excerpt ?? "",
|
|
131
165
|
};
|
|
132
166
|
});
|
|
133
167
|
// Early return on error or no article
|
|
134
|
-
if (
|
|
168
|
+
if ("error" in fetched)
|
|
135
169
|
return fetched;
|
|
136
170
|
if (!fetched.articleHtml) {
|
|
137
171
|
let content = fetched.content;
|
|
138
172
|
if (content.length > maxChars)
|
|
139
|
-
content = content.slice(0, maxChars) +
|
|
140
|
-
return {
|
|
173
|
+
content = content.slice(0, maxChars) + "\n\n[truncated]";
|
|
174
|
+
return {
|
|
175
|
+
url: fetched.url,
|
|
176
|
+
title: fetched.title,
|
|
177
|
+
content,
|
|
178
|
+
excerpt: fetched.excerpt,
|
|
179
|
+
};
|
|
141
180
|
}
|
|
142
181
|
// Step 2: Reranker path — chunk HTML structurally, score, return top-K
|
|
143
182
|
if (reranker && args.query) {
|
|
@@ -147,19 +186,25 @@ class FetchPageTool extends lloyal_agents_1.Tool {
|
|
|
147
186
|
try {
|
|
148
187
|
tw = yield* lloyal_agents_1.Trace.expect();
|
|
149
188
|
}
|
|
150
|
-
catch {
|
|
189
|
+
catch {
|
|
190
|
+
/* no trace context */
|
|
191
|
+
}
|
|
151
192
|
const rerankT0 = performance.now();
|
|
152
193
|
if (tw) {
|
|
153
194
|
tw.write({
|
|
154
195
|
traceId: tw.nextId(),
|
|
155
196
|
parentTraceId: null,
|
|
156
197
|
ts: rerankT0,
|
|
157
|
-
type:
|
|
198
|
+
type: "rerank:start",
|
|
158
199
|
query: args.query,
|
|
159
200
|
chunkCount: chunks.length,
|
|
160
|
-
tool:
|
|
201
|
+
tool: "fetch_page",
|
|
161
202
|
url,
|
|
162
|
-
chunks: chunks.map(c => ({
|
|
203
|
+
chunks: chunks.map((c) => ({
|
|
204
|
+
heading: c.heading,
|
|
205
|
+
textLength: c.text.length,
|
|
206
|
+
startLine: c.startLine,
|
|
207
|
+
})),
|
|
163
208
|
});
|
|
164
209
|
}
|
|
165
210
|
if (chunks.length > 0) {
|
|
@@ -181,18 +226,25 @@ class FetchPageTool extends lloyal_agents_1.Tool {
|
|
|
181
226
|
// Exploit mode (!explore): dual scoring via scoreRelevanceBatch.
|
|
182
227
|
if (!context?.explore && context?.scorer && scored.length > 0) {
|
|
183
228
|
const chunkTexts = scored.map((sc) => {
|
|
184
|
-
const chunk = chunks.find(c => c.resource === sc.file && c.startLine === sc.startLine);
|
|
185
|
-
return chunk?.text ??
|
|
229
|
+
const chunk = chunks.find((c) => c.resource === sc.file && c.startLine === sc.startLine);
|
|
230
|
+
return chunk?.text ?? "";
|
|
186
231
|
});
|
|
187
232
|
const combinedScores = yield* (0, effection_1.call)(() => context.scorer.scoreRelevanceBatch(chunkTexts, args.query));
|
|
188
233
|
const reordered = scored
|
|
189
|
-
.map((sc, i) => ({
|
|
234
|
+
.map((sc, i) => ({
|
|
235
|
+
...sc,
|
|
236
|
+
score: combinedScores[i],
|
|
237
|
+
_toolQueryScore: sc.score,
|
|
238
|
+
}))
|
|
190
239
|
.sort((a, b) => b.score - a.score);
|
|
191
240
|
scored = reordered;
|
|
192
241
|
if (tw) {
|
|
193
242
|
tw.write({
|
|
194
|
-
traceId: tw.nextId(),
|
|
195
|
-
|
|
243
|
+
traceId: tw.nextId(),
|
|
244
|
+
parentTraceId: null,
|
|
245
|
+
ts: performance.now(),
|
|
246
|
+
type: "entailment:content:exploit",
|
|
247
|
+
tool: "fetch_page",
|
|
196
248
|
pressure: {
|
|
197
249
|
percentAvailable: context.pressurePercentAvailable ?? -1,
|
|
198
250
|
remaining: -1,
|
|
@@ -213,8 +265,8 @@ class FetchPageTool extends lloyal_agents_1.Tool {
|
|
|
213
265
|
traceId: tw.nextId(),
|
|
214
266
|
parentTraceId: null,
|
|
215
267
|
ts: performance.now(),
|
|
216
|
-
type:
|
|
217
|
-
topResults: topChunks.map(c => ({
|
|
268
|
+
type: "rerank:end",
|
|
269
|
+
topResults: topChunks.map((c) => ({
|
|
218
270
|
file: url,
|
|
219
271
|
heading: c.heading,
|
|
220
272
|
score: c.score,
|
|
@@ -223,14 +275,14 @@ class FetchPageTool extends lloyal_agents_1.Tool {
|
|
|
223
275
|
selectedPassageCount: topChunks.length,
|
|
224
276
|
totalChars: topChunks.reduce((sum, c) => sum + c.text.length, 0),
|
|
225
277
|
durationMs: performance.now() - rerankT0,
|
|
226
|
-
tool:
|
|
278
|
+
tool: "fetch_page",
|
|
227
279
|
url,
|
|
228
280
|
});
|
|
229
281
|
}
|
|
230
282
|
if (topChunks.length > 0) {
|
|
231
283
|
// Discovery signal: headings of chunks that didn't make the cut.
|
|
232
284
|
// Lightweight (~50 tokens) but gives the agent topics to explore.
|
|
233
|
-
const selectedHeadings = new Set(topChunks.map(c => c.heading));
|
|
285
|
+
const selectedHeadings = new Set(topChunks.map((c) => c.heading));
|
|
234
286
|
const alsoOnPage = scored
|
|
235
287
|
.filter((sc) => !selectedHeadings.has(sc.heading))
|
|
236
288
|
.map((sc) => sc.heading)
|
|
@@ -238,7 +290,7 @@ class FetchPageTool extends lloyal_agents_1.Tool {
|
|
|
238
290
|
return {
|
|
239
291
|
url,
|
|
240
292
|
title: fetched.title,
|
|
241
|
-
content: topChunks.map(c => c.text).join(
|
|
293
|
+
content: topChunks.map((c) => c.text).join("\n\n---\n\n"),
|
|
242
294
|
chunks: topChunks.length,
|
|
243
295
|
...(alsoOnPage.length > 0 ? { alsoOnPage } : {}),
|
|
244
296
|
};
|
|
@@ -248,7 +300,7 @@ class FetchPageTool extends lloyal_agents_1.Tool {
|
|
|
248
300
|
// Fallback: return full content, truncated
|
|
249
301
|
let content = fetched.content;
|
|
250
302
|
if (content.length > maxChars) {
|
|
251
|
-
content = content.slice(0, maxChars) +
|
|
303
|
+
content = content.slice(0, maxChars) + "\n\n[truncated]";
|
|
252
304
|
}
|
|
253
305
|
return { url, title: fetched.title, content, excerpt: fetched.excerpt };
|
|
254
306
|
}
|
|
@@ -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,UAAU,GAAG,CAAC,CAAC;IAEnB,KAAK,MAAM,EAAE,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,CAAC;QACvC,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,
|
|
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,UAAU,GAAG,CAAC,CAAC;IAEnB,KAAK,MAAM,EAAE,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,CAAC;QACvC,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CACvB,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,EAAE,CAAC,IAAI,IAAI,CAAC,CAAC,SAAS,KAAK,EAAE,CAAC,SAAS,CAC9D,CAAC;QACF,IAAI,CAAC,KAAK,EAAE,IAAI;YAAE,SAAS;QAE3B,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAE5E,IAAI,UAAU,GAAG,W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|
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, PlanQuestion, PlanToolOpts } from './plan';
|
|
11
|
+
export { PlanTool, taskToContent } from './plan';
|
|
12
|
+
export type { PlanResult, PlanQuestion, 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,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEnF;;;;;;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,21 +8,39 @@ 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
|
+
/**
|
|
24
|
+
* A structured research task produced by the planner.
|
|
25
|
+
*
|
|
26
|
+
* @category Rig
|
|
27
|
+
*/
|
|
28
|
+
export interface ResearchTask {
|
|
29
|
+
/** What to find out — a specific, actionable research assignment. */
|
|
30
|
+
description: string;
|
|
31
|
+
/** Whether the task is answerable via research or needs user clarification. */
|
|
32
|
+
intent: 'research' | 'clarify';
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Convert a ResearchTask to agent content string.
|
|
36
|
+
*
|
|
37
|
+
* @category Rig
|
|
38
|
+
*/
|
|
39
|
+
export declare function taskToContent(task: ResearchTask): string;
|
|
23
40
|
/**
|
|
24
41
|
* A single sub-question produced by the planner with intent classification.
|
|
25
42
|
*
|
|
43
|
+
* @deprecated Use {@link ResearchTask} instead.
|
|
26
44
|
* @category Rig
|
|
27
45
|
*/
|
|
28
46
|
export interface PlanQuestion {
|
|
@@ -37,7 +55,9 @@ export interface PlanQuestion {
|
|
|
37
55
|
* @category Rig
|
|
38
56
|
*/
|
|
39
57
|
export interface PlanResult {
|
|
40
|
-
/**
|
|
58
|
+
/** Structured research tasks with optional entry points. */
|
|
59
|
+
tasks: ResearchTask[];
|
|
60
|
+
/** @deprecated Use tasks. Adapter — maps tasks to the old PlanQuestion shape. */
|
|
41
61
|
questions: PlanQuestion[];
|
|
42
62
|
/** Number of tokens generated during planning. */
|
|
43
63
|
tokenCount: number;
|
|
@@ -47,15 +67,10 @@ export interface PlanResult {
|
|
|
47
67
|
/**
|
|
48
68
|
* Grammar-constrained query decomposition and intent classification.
|
|
49
69
|
*
|
|
50
|
-
* Analyzes a research query and produces an array of {@link
|
|
51
|
-
*
|
|
70
|
+
* Analyzes a research query and produces an array of {@link ResearchTask}
|
|
71
|
+
* tasks, each classified as `"research"` (answerable via search)
|
|
52
72
|
* or `"clarify"` (needs user input). Uses a JSON grammar to guarantee
|
|
53
|
-
* structured output.
|
|
54
|
-
* enough to research directly.
|
|
55
|
-
*
|
|
56
|
-
* The harness interprets the result: all-research triggers parallel
|
|
57
|
-
* dispatch, all-clarify returns to the user, mixed drops clarify
|
|
58
|
-
* questions and dispatches only research ones.
|
|
73
|
+
* structured output.
|
|
59
74
|
*
|
|
60
75
|
* @category Rig
|
|
61
76
|
*/
|
|
@@ -64,7 +79,7 @@ export declare class PlanTool extends Tool<{
|
|
|
64
79
|
context?: string;
|
|
65
80
|
}> {
|
|
66
81
|
readonly name = "plan";
|
|
67
|
-
readonly description = "Analyze a research query. Return
|
|
82
|
+
readonly description = "Analyze a research query. Return research tasks classified as \"research\" (answerable via web search) or \"clarify\" (needs user input). Return empty array if the query is focused enough to research directly.";
|
|
68
83
|
readonly parameters: JsonSchema;
|
|
69
84
|
private _prompt;
|
|
70
85
|
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,EAAE,MAAM,CAAC;IACrB,6DAA6D;IAC7D,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B,qEAAqE;IACrE,WAAW,EAAE,MAAM,CAAC;IACpB,+EAA+E;IAC/E,MAAM,EAAE,UAAU,GAAG,SAAS,CAAC;CAChC;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,YAAY,GAAG,MAAM,CAExD;AAED;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B,6BAA6B;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,qFAAqF;IACrF,MAAM,EAAE,UAAU,GAAG,SAAS,CAAC;CAChC;AAED;;;;GAIG;AACH,MAAM,WAAW,UAAU;IACzB,4DAA4D;IAC5D,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB,iFAAiF;IACjF,SAAS,EAAE,YAAY,EAAE,CAAC;IAC1B,kDAAkD;IAClD,UAAU,EAAE,MAAM,CAAC;IACnB,6DAA6D;IAC7D,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;GASG;AACH,qBAAa,QAAS,SAAQ,IAAI,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;IACrE,QAAQ,CAAC,IAAI,UAAU;IACvB,QAAQ,CAAC,WAAW,uNAAmN;IACvO,QAAQ,CAAC,UAAU,EAAE,UAAU,CAO7B;IAEF,OAAO,CAAC,OAAO,CAAmC;IAClD,OAAO,CAAC,QAAQ,CAAU;IAC1B,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,YAAY,CAAS;gBAEjB,IAAI,EAAE,YAAY;IAQ7B,OAAO,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,CAAC,OAAO,CAAC;CA2DxE"}
|
package/dist/tools/plan.js
CHANGED
|
@@ -1,26 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
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
|
+
/**
|
|
7
|
+
* Convert a ResearchTask to agent content string.
|
|
8
|
+
*
|
|
9
|
+
* @category Rig
|
|
10
|
+
*/
|
|
11
|
+
function taskToContent(task) {
|
|
12
|
+
return task.description;
|
|
13
|
+
}
|
|
6
14
|
/**
|
|
7
15
|
* Grammar-constrained query decomposition and intent classification.
|
|
8
16
|
*
|
|
9
|
-
* Analyzes a research query and produces an array of {@link
|
|
10
|
-
*
|
|
17
|
+
* Analyzes a research query and produces an array of {@link ResearchTask}
|
|
18
|
+
* tasks, each classified as `"research"` (answerable via search)
|
|
11
19
|
* or `"clarify"` (needs user input). Uses a JSON grammar to guarantee
|
|
12
|
-
* structured output.
|
|
13
|
-
* enough to research directly.
|
|
14
|
-
*
|
|
15
|
-
* The harness interprets the result: all-research triggers parallel
|
|
16
|
-
* dispatch, all-clarify returns to the user, mixed drops clarify
|
|
17
|
-
* questions and dispatches only research ones.
|
|
20
|
+
* structured output.
|
|
18
21
|
*
|
|
19
22
|
* @category Rig
|
|
20
23
|
*/
|
|
21
24
|
class PlanTool extends lloyal_agents_1.Tool {
|
|
22
25
|
name = 'plan';
|
|
23
|
-
description = 'Analyze a research query. Return
|
|
26
|
+
description = 'Analyze a research query. Return research tasks classified as "research" (answerable via web search) or "clarify" (needs user input). Return empty array if the query is focused enough to research directly.';
|
|
24
27
|
parameters = {
|
|
25
28
|
type: 'object',
|
|
26
29
|
properties: {
|
|
@@ -41,58 +44,55 @@ class PlanTool extends lloyal_agents_1.Tool {
|
|
|
41
44
|
this._maxQuestions = opts.maxQuestions;
|
|
42
45
|
}
|
|
43
46
|
*execute(args) {
|
|
44
|
-
const ctx = yield* lloyal_agents_1.Ctx.expect();
|
|
45
47
|
const t = performance.now();
|
|
46
48
|
const schema = {
|
|
47
49
|
type: 'object',
|
|
48
50
|
properties: {
|
|
49
|
-
|
|
51
|
+
tasks: {
|
|
50
52
|
type: 'array',
|
|
51
53
|
items: {
|
|
52
54
|
type: 'object',
|
|
53
55
|
properties: {
|
|
54
|
-
|
|
56
|
+
description: { type: 'string' },
|
|
55
57
|
intent: { type: 'string', enum: ['research', 'clarify'] },
|
|
56
58
|
},
|
|
57
|
-
required: ['
|
|
59
|
+
required: ['description', 'intent'],
|
|
58
60
|
},
|
|
59
61
|
maxItems: this._maxQuestions,
|
|
60
62
|
},
|
|
61
63
|
},
|
|
62
|
-
required: ['
|
|
64
|
+
required: ['tasks'],
|
|
63
65
|
};
|
|
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,
|
|
66
|
+
const userContent = (0, lloyal_agents_1.renderTemplate)(this._prompt.user, {
|
|
67
|
+
query: args.query,
|
|
68
|
+
count: this._maxQuestions,
|
|
69
|
+
context: args.context || null,
|
|
70
|
+
});
|
|
71
|
+
const planAgent = yield* (0, lloyal_agents_1.agent)({
|
|
72
|
+
systemPrompt: this._prompt.system,
|
|
73
|
+
task: userContent,
|
|
74
|
+
schema,
|
|
80
75
|
params: { temperature: this._temperature },
|
|
81
|
-
|
|
76
|
+
session: this._session,
|
|
82
77
|
});
|
|
83
|
-
const { output, tokenCount } = result;
|
|
84
78
|
const timeMs = performance.now() - t;
|
|
79
|
+
const tokenCount = planAgent.tokenCount;
|
|
85
80
|
try {
|
|
86
|
-
const parsed = JSON.parse(
|
|
87
|
-
const raw = (parsed.
|
|
88
|
-
const
|
|
81
|
+
const parsed = JSON.parse(planAgent.rawOutput);
|
|
82
|
+
const raw = (parsed.tasks || []);
|
|
83
|
+
const tasks = raw
|
|
89
84
|
.slice(0, this._maxQuestions)
|
|
90
|
-
.filter(
|
|
91
|
-
.map(
|
|
92
|
-
|
|
85
|
+
.filter(t => typeof t.description === 'string' && (t.intent === 'research' || t.intent === 'clarify'))
|
|
86
|
+
.map(t => ({
|
|
87
|
+
description: t.description,
|
|
88
|
+
intent: t.intent,
|
|
89
|
+
}));
|
|
90
|
+
// Adapter: populate deprecated questions from tasks
|
|
91
|
+
const questions = tasks.map(t => ({ text: t.description, intent: t.intent }));
|
|
92
|
+
return { tasks, questions, tokenCount, timeMs };
|
|
93
93
|
}
|
|
94
94
|
catch {
|
|
95
|
-
return { questions: [], tokenCount, timeMs };
|
|
95
|
+
return { tasks: [], questions: [], tokenCount, timeMs };
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
}
|
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":";;;AAsCA,sCAEC;AAvCD,8DAAyE;AAgCzE;;;;GAIG;AACH,SAAgB,aAAa,CAAC,IAAkB;IAC9C,OAAO,IAAI,CAAC,WAAW,CAAC;AAC1B,CAAC;AA+BD;;;;;;;;;GASG;AACH,MAAa,QAAS,SAAQ,oBAAyC;IAC5D,IAAI,GAAG,MAAM,CAAC;IACd,WAAW,GAAG,+MAA+M,CAAC;IAC9N,UAAU,GAAe;QAChC,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,+BAA+B,EAAE;YACvE,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,2CAA2C,EAAE;SACtF;QACD,QAAQ,EAAE,CAAC,OAAO,CAAC;KACpB,CAAC;IAEM,OAAO,CAAmC;IAC1C,QAAQ,CAAU;IAClB,aAAa,CAAS;IACtB,YAAY,CAAS;IAE7B,YAAY,IAAkB;QAC5B,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC;QAC3B,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,WAAW,IAAI,GAAG,CAAC;QAC5C,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC;QAC7B,IAAI,CAAC,aAAa,GAAG,IAAI,CA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,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;YAC/C,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE,CAG5B,CAAC;YACJ,MAAM,KAAK,GAAmB,GAAG;iBAC9B,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC;iBAC5B,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,WAAW,KAAK,QAAQ,IAAI,CAAC,CAAC,CAAC,MAAM,KAAK,UAAU,IAAI,CAAC,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC;iBACrG,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;gBACT,WAAW,EAAE,CAAC,CAAC,WAAY;gBAC3B,MAAM,EAAE,CAAC,CAAC,MAAgC;aAC3C,CAAC,CAAC,CAAC;YACN,oDAAoD;YACpD,MAAM,SAAS,GAAmB,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;YAC9F,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,EAAuB,CAAC;QACvE,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,EAAuB,CAAC;QAC/E,CAAC;IACH,CAAC;CACF;AApFD,4BAoFC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { Operation } from
|
|
2
|
-
import { Tool } from
|
|
3
|
-
import type { JsonSchema, ToolContext } from
|
|
4
|
-
import type { SearchProvider, SearchResult } from
|
|
1
|
+
import type { Operation } from "effection";
|
|
2
|
+
import { Tool } from "@lloyal-labs/lloyal-agents";
|
|
3
|
+
import type { JsonSchema, ToolContext } from "@lloyal-labs/lloyal-agents";
|
|
4
|
+
import type { SearchProvider, SearchResult } from "./types";
|
|
5
5
|
export type { SearchProvider, SearchResult };
|
|
6
6
|
/**
|
|
7
7
|
* {@link SearchProvider} implementation backed by the Tavily search API.
|
|
@@ -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,cAAc,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5D,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,CAAC;AAI7C;;;;;;;;GAQG;AACH,qBAAa,cAAe,YAAW,cAAc;IACnD,QAAQ,CAAC,0BAA0B,SAAS;IAC5C,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,iBAAiB,CAAS;gBAEtB,MAAM,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;QAAE,gBAAgB,CAAC,EAAE,MAAM,CAAA;KAAE;IAK3D,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"web-search.d.ts","sourceRoot":"","sources":["../../src/tools/web-search.ts"],"names":[],"mapp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Key, opts) {
|
|
21
|
-
this._apiKey = apiKey || process.env.TAVILY_API_KEY ||
|
|
21
|
+
this._apiKey = apiKey || process.env.TAVILY_API_KEY || "";
|
|
22
22
|
this._snippetMaxLength = opts?.snippetMaxLength ?? 500;
|
|
23
23
|
}
|
|
24
24
|
async search(query, maxResults) {
|
|
25
25
|
if (!this._apiKey)
|
|
26
|
-
throw new Error(
|
|
27
|
-
const res = await fetch(
|
|
28
|
-
method:
|
|
26
|
+
throw new Error("TAVILY_API_KEY not set");
|
|
27
|
+
const res = await fetch("https://api.tavily.com/search", {
|
|
28
|
+
method: "POST",
|
|
29
29
|
headers: {
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
"Content-Type": "application/json",
|
|
31
|
+
Authorization: `Bearer ${this._apiKey}`,
|
|
32
32
|
},
|
|
33
33
|
body: JSON.stringify({ query, max_results: maxResults }),
|
|
34
34
|
});
|
|
35
35
|
if (!res.ok)
|
|
36
36
|
throw new Error(`Tavily ${res.status}: ${await res.text()}`);
|
|
37
|
-
const data = await res.json();
|
|
37
|
+
const data = (await res.json());
|
|
38
38
|
const max = this._snippetMaxLength;
|
|
39
|
-
return data.results.map(r => ({
|
|
39
|
+
return data.results.map((r) => ({
|
|
40
40
|
title: r.title,
|
|
41
41
|
url: r.url,
|
|
42
42
|
snippet: r.content.length > max
|
|
43
|
-
? r.content.slice(0, max) +
|
|
43
|
+
? r.content.slice(0, max) + " [\u2026]"
|
|
44
44
|
: r.content,
|
|
45
|
+
score: r.score,
|
|
45
46
|
}));
|
|
46
47
|
}
|
|
47
48
|
}
|
|
@@ -57,12 +58,12 @@ exports.TavilyProvider = TavilyProvider;
|
|
|
57
58
|
* @category Rig
|
|
58
59
|
*/
|
|
59
60
|
class WebSearchTool extends lloyal_agents_1.Tool {
|
|
60
|
-
name =
|
|
61
|
-
description =
|
|
61
|
+
name = "web_search";
|
|
62
|
+
description = "Search the web. Returns results with titles, snippets, and URLs.";
|
|
62
63
|
parameters = {
|
|
63
|
-
type:
|
|
64
|
-
properties: { query: { type:
|
|
65
|
-
required: [
|
|
64
|
+
type: "object",
|
|
65
|
+
properties: { query: { type: "string", description: "Search query" } },
|
|
66
|
+
required: ["query"],
|
|
66
67
|
};
|
|
67
68
|
_provider;
|
|
68
69
|
_topN;
|
|
@@ -74,7 +75,22 @@ class WebSearchTool extends lloyal_agents_1.Tool {
|
|
|
74
75
|
*execute(args, context) {
|
|
75
76
|
const query = args.query?.trim();
|
|
76
77
|
if (!query)
|
|
77
|
-
return { error:
|
|
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,34 +100,59 @@ 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();
|
|
95
123
|
}
|
|
96
|
-
catch {
|
|
124
|
+
catch {
|
|
125
|
+
/* no trace */
|
|
126
|
+
}
|
|
97
127
|
if (tw) {
|
|
98
128
|
tw.write({
|
|
99
|
-
traceId: tw.nextId(),
|
|
100
|
-
|
|
101
|
-
|
|
129
|
+
traceId: tw.nextId(),
|
|
130
|
+
parentTraceId: null,
|
|
131
|
+
ts: performance.now(),
|
|
132
|
+
type: "entailment:search",
|
|
133
|
+
tool: "web_search",
|
|
102
134
|
query,
|
|
103
|
-
|
|
135
|
+
mode: "exploit",
|
|
136
|
+
before: results.map((r, i) => ({
|
|
137
|
+
title: r.title,
|
|
138
|
+
url: r.url,
|
|
139
|
+
providerScore: r.score ?? null,
|
|
140
|
+
entailment: entailment[i],
|
|
141
|
+
combined: combined[i],
|
|
142
|
+
})),
|
|
104
143
|
});
|
|
105
144
|
}
|
|
106
145
|
results = results
|
|
107
|
-
.map((r, i) => ({ result: r, score:
|
|
146
|
+
.map((r, i) => ({ result: r, score: combined[i] }))
|
|
108
147
|
.sort((a, b) => b.score - a.score)
|
|
109
148
|
.map((entry) => entry.result);
|
|
110
149
|
if (tw) {
|
|
111
150
|
tw.write({
|
|
112
|
-
traceId: tw.nextId(),
|
|
113
|
-
|
|
114
|
-
|
|
151
|
+
traceId: tw.nextId(),
|
|
152
|
+
parentTraceId: null,
|
|
153
|
+
ts: performance.now(),
|
|
154
|
+
type: "entailment:search:reordered",
|
|
155
|
+
tool: "web_search",
|
|
115
156
|
after: results.map((r) => ({ title: r.title, url: r.url })),
|
|
116
157
|
});
|
|
117
158
|
}
|
|
@@ -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,
|
|
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,CA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AAC,CAAC;YAEhC,IAAI,EAAE,EAAE,CAAC;gBACP,EAAE,CAAC,KAAK,CAAC;oBACP,OAAO,EAAE,EAAE,CAAC,MAAM,EAAE;oBACpB,aAAa,EAAE,IAAI;oBACnB,EAAE,EAAE,WAAW,CAAC,GAAG,EAAE;oBACrB,IAAI,EAAE,6BAA6B;oBACnC,IAAI,EAAE,YAAY;oBAClB,KAAK,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": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "Retrieval-Interleaved Generation for lloyal-agents",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -40,14 +40,14 @@
|
|
|
40
40
|
"build": "tsc -b"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@lloyal-labs/lloyal-agents": "^1.
|
|
44
|
-
"@lloyal-labs/sdk": "^1.
|
|
43
|
+
"@lloyal-labs/lloyal-agents": "^1.7.0",
|
|
44
|
+
"@lloyal-labs/sdk": "^1.7.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/"
|