@lloyal-labs/rig 1.2.3 → 1.4.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/sources/corpus.d.ts +37 -23
- package/dist/sources/corpus.d.ts.map +1 -1
- package/dist/sources/corpus.js +16 -48
- package/dist/sources/corpus.js.map +1 -1
- package/dist/sources/index.d.ts +3 -1
- package/dist/sources/index.d.ts.map +1 -1
- package/dist/sources/index.js +1 -1
- package/dist/sources/index.js.map +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 +40 -16
- package/dist/sources/web.d.ts.map +1 -1
- package/dist/sources/web.js +19 -60
- package/dist/sources/web.js.map +1 -1
- package/dist/tools/fetch-page.d.ts +8 -1
- package/dist/tools/fetch-page.d.ts.map +1 -1
- package/dist/tools/fetch-page.js +22 -6
- package/dist/tools/fetch-page.js.map +1 -1
- package/dist/tools/grep.d.ts +6 -1
- package/dist/tools/grep.d.ts.map +1 -1
- package/dist/tools/grep.js +9 -4
- package/dist/tools/grep.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/plan.d.ts +3 -0
- package/dist/tools/plan.d.ts.map +1 -1
- package/dist/tools/plan.js +3 -1
- package/dist/tools/plan.js.map +1 -1
- package/dist/tools/read-file.d.ts +4 -1
- package/dist/tools/read-file.d.ts.map +1 -1
- package/dist/tools/read-file.js +4 -2
- package/dist/tools/read-file.js.map +1 -1
- package/dist/tools/report.d.ts +7 -1
- package/dist/tools/report.d.ts.map +1 -1
- package/dist/tools/report.js +18 -6
- package/dist/tools/report.js.map +1 -1
- package/package.json +5 -5
- 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 -117
- 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 -136
- package/dist/tools/web-research.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Rig —
|
|
2
|
+
* Rig — data sources and tools for the lloyal agent pipeline
|
|
3
3
|
*
|
|
4
4
|
* The default export is platform-agnostic. linkedom + @mozilla/readability
|
|
5
5
|
* are pure JS and work in both Node.js and React Native (Hermes).
|
|
6
6
|
*
|
|
7
|
-
* Node-specific exports (createReranker,
|
|
8
|
-
*
|
|
9
|
-
* via `@lloyal-labs/rig/node`.
|
|
7
|
+
* Node-specific exports (createReranker, loadResources, chunkResources)
|
|
8
|
+
* require node:fs and are available via `@lloyal-labs/rig/node`.
|
|
10
9
|
*
|
|
11
10
|
* @packageDocumentation
|
|
12
11
|
* @category Rig
|
|
13
12
|
*/
|
|
14
|
-
export { createTools, reportTool,
|
|
15
|
-
export type {
|
|
13
|
+
export { createTools, reportTool, ReportTool, WebSearchTool, TavilyProvider, FetchPageTool, PlanTool, } from './tools';
|
|
14
|
+
export type { PlanToolOpts, PlanResult, PlanQuestion, SearchProvider, SearchResult, Reranker, ScoredChunk, ScoredResult, } from './tools';
|
|
15
|
+
export { WebSource } from './sources/web';
|
|
16
|
+
export type { WebSourceOpts } from './sources/web';
|
|
17
|
+
export { CorpusSource } from './sources/corpus';
|
|
18
|
+
export type { CorpusSourceOpts } from './sources/corpus';
|
|
19
|
+
export type { SourceContext } from './sources/types';
|
|
16
20
|
export { chunkFetchedPages, chunkHtml } from './sources/chunking';
|
|
17
21
|
export type { FetchedPage } from './sources/chunking';
|
|
18
|
-
export type { SourceContext } from './sources/types';
|
|
19
22
|
export type { Resource, Chunk } from './resources/types';
|
|
20
23
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
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,GACT,MAAM,SAAS,CAAC;AACjB,YAAY,EACV,YAAY,EACZ,UAAU,EAAE,YAAY,EACxB,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,MAAM,kBAAkB,CAAC;AACzD,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
|
@@ -1,29 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* Rig —
|
|
3
|
+
* Rig — data sources and tools for the lloyal agent pipeline
|
|
4
4
|
*
|
|
5
5
|
* The default export is platform-agnostic. linkedom + @mozilla/readability
|
|
6
6
|
* are pure JS and work in both Node.js and React Native (Hermes).
|
|
7
7
|
*
|
|
8
|
-
* Node-specific exports (createReranker,
|
|
9
|
-
*
|
|
10
|
-
* via `@lloyal-labs/rig/node`.
|
|
8
|
+
* Node-specific exports (createReranker, loadResources, chunkResources)
|
|
9
|
+
* require node:fs and are available via `@lloyal-labs/rig/node`.
|
|
11
10
|
*
|
|
12
11
|
* @packageDocumentation
|
|
13
12
|
* @category Rig
|
|
14
13
|
*/
|
|
15
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.chunkHtml = exports.chunkFetchedPages = exports.
|
|
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;
|
|
17
16
|
// Tools (pure TS + Effection + linkedom — platform-agnostic)
|
|
18
17
|
var tools_1 = require("./tools");
|
|
19
18
|
Object.defineProperty(exports, "createTools", { enumerable: true, get: function () { return tools_1.createTools; } });
|
|
20
19
|
Object.defineProperty(exports, "reportTool", { enumerable: true, get: function () { return tools_1.reportTool; } });
|
|
21
|
-
Object.defineProperty(exports, "
|
|
20
|
+
Object.defineProperty(exports, "ReportTool", { enumerable: true, get: function () { return tools_1.ReportTool; } });
|
|
22
21
|
Object.defineProperty(exports, "WebSearchTool", { enumerable: true, get: function () { return tools_1.WebSearchTool; } });
|
|
23
22
|
Object.defineProperty(exports, "TavilyProvider", { enumerable: true, get: function () { return tools_1.TavilyProvider; } });
|
|
24
23
|
Object.defineProperty(exports, "FetchPageTool", { enumerable: true, get: function () { return tools_1.FetchPageTool; } });
|
|
25
|
-
Object.defineProperty(exports, "WebResearchTool", { enumerable: true, get: function () { return tools_1.WebResearchTool; } });
|
|
26
24
|
Object.defineProperty(exports, "PlanTool", { enumerable: true, get: function () { return tools_1.PlanTool; } });
|
|
25
|
+
// Sources (platform-agnostic — no node:fs)
|
|
26
|
+
var web_1 = require("./sources/web");
|
|
27
|
+
Object.defineProperty(exports, "WebSource", { enumerable: true, get: function () { return web_1.WebSource; } });
|
|
28
|
+
var corpus_1 = require("./sources/corpus");
|
|
29
|
+
Object.defineProperty(exports, "CorpusSource", { enumerable: true, get: function () { return corpus_1.CorpusSource; } });
|
|
27
30
|
// Chunking (platform-agnostic — linkedom is pure JS)
|
|
28
31
|
var chunking_1 = require("./sources/chunking");
|
|
29
32
|
Object.defineProperty(exports, "chunkFetchedPages", { enumerable: true, get: function () { return chunking_1.chunkFetchedPages; } });
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;AAEH,6DAA6D;AAC7D,iCAIiB;AAHf,oGAAA,WAAW,OAAA;AAAE,mGAAA,UAAU,OAAA;AAAE,mGAAA,UAAU,OAAA;AACnC,sGAAA,aAAa,OAAA;AAAE,uGAAA,cAAc,OAAA;AAAE,sGAAA,aAAa,OAAA;AAC5C,iGAAA,QAAQ,OAAA;AASV,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"}
|
package/dist/node.d.ts
CHANGED
|
@@ -4,12 +4,13 @@
|
|
|
4
4
|
* These require node:fs and/or @lloyal-labs/lloyal.node.
|
|
5
5
|
* Import from `@lloyal-labs/rig/node` only in Node.js environments.
|
|
6
6
|
*
|
|
7
|
+
* Sources (WebSource, CorpusSource) are now platform-agnostic and
|
|
8
|
+
* exported from the main `@lloyal-labs/rig` entry.
|
|
9
|
+
*
|
|
7
10
|
* @packageDocumentation
|
|
8
11
|
* @category Rig
|
|
9
12
|
*/
|
|
10
13
|
export * from './index';
|
|
11
14
|
export { createReranker } from './reranker';
|
|
12
|
-
export { WebSource } from './sources/web';
|
|
13
|
-
export { CorpusSource } from './sources/corpus';
|
|
14
15
|
export { loadResources, chunkResources } from './resources';
|
|
15
16
|
//# sourceMappingURL=node.d.ts.map
|
package/dist/node.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,cAAc,SAAS,CAAC;AAGxB,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAG5C,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/node.js
CHANGED
|
@@ -5,6 +5,9 @@
|
|
|
5
5
|
* These require node:fs and/or @lloyal-labs/lloyal.node.
|
|
6
6
|
* Import from `@lloyal-labs/rig/node` only in Node.js environments.
|
|
7
7
|
*
|
|
8
|
+
* Sources (WebSource, CorpusSource) are now platform-agnostic and
|
|
9
|
+
* exported from the main `@lloyal-labs/rig` entry.
|
|
10
|
+
*
|
|
8
11
|
* @packageDocumentation
|
|
9
12
|
* @category Rig
|
|
10
13
|
*/
|
|
@@ -23,17 +26,12 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
23
26
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
24
27
|
};
|
|
25
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.chunkResources = exports.loadResources = exports.
|
|
29
|
+
exports.chunkResources = exports.loadResources = exports.createReranker = void 0;
|
|
27
30
|
// Re-export everything from the platform-agnostic barrel
|
|
28
31
|
__exportStar(require("./index"), exports);
|
|
29
32
|
// Node-only: Reranker factory (requires @lloyal-labs/lloyal.node)
|
|
30
33
|
var reranker_1 = require("./reranker");
|
|
31
34
|
Object.defineProperty(exports, "createReranker", { enumerable: true, get: function () { return reranker_1.createReranker; } });
|
|
32
|
-
// Node-only: Sources (require node:fs)
|
|
33
|
-
var web_1 = require("./sources/web");
|
|
34
|
-
Object.defineProperty(exports, "WebSource", { enumerable: true, get: function () { return web_1.WebSource; } });
|
|
35
|
-
var corpus_1 = require("./sources/corpus");
|
|
36
|
-
Object.defineProperty(exports, "CorpusSource", { enumerable: true, get: function () { return corpus_1.CorpusSource; } });
|
|
37
35
|
// Node-only: Resource loading (requires node:fs)
|
|
38
36
|
var resources_1 = require("./resources");
|
|
39
37
|
Object.defineProperty(exports, "loadResources", { enumerable: true, get: function () { return resources_1.loadResources; } });
|
package/dist/node.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.js","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"node.js","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;;;;;;;;;;;;;;;AAEH,yDAAyD;AACzD,0CAAwB;AAExB,kEAAkE;AAClE,uCAA4C;AAAnC,0GAAA,cAAc,OAAA;AAEvB,iDAAiD;AACjD,yCAA4D;AAAnD,0GAAA,aAAa,OAAA;AAAE,2GAAA,cAAc,OAAA"}
|
package/dist/sources/corpus.d.ts
CHANGED
|
@@ -2,47 +2,61 @@ import type { Operation } from "effection";
|
|
|
2
2
|
import { Source } from "@lloyal-labs/lloyal-agents";
|
|
3
3
|
import type { Tool } from "@lloyal-labs/lloyal-agents";
|
|
4
4
|
import type { Resource, Chunk } from "../resources/types";
|
|
5
|
-
import type {
|
|
5
|
+
import type { Reranker } from "../tools/types";
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* Configuration for {@link CorpusSource}.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
* @category Rig
|
|
10
|
+
*/
|
|
11
|
+
export interface CorpusSourceOpts {
|
|
12
|
+
/** GrepTool configuration */
|
|
13
|
+
grep?: {
|
|
14
|
+
/** Max matches returned. @default 50 */
|
|
15
|
+
maxResults?: number;
|
|
16
|
+
/** Max chars per matched line. @default 200 */
|
|
17
|
+
lineMaxChars?: number;
|
|
18
|
+
};
|
|
19
|
+
/** ReadFileTool configuration */
|
|
20
|
+
readFile?: {
|
|
21
|
+
/** Default max lines when no range specified. @default 100 */
|
|
22
|
+
defaultMaxLines?: number;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Corpus-backed data source using local file search, read, and grep
|
|
27
|
+
*
|
|
28
|
+
* Provides three tools: semantic search (via reranker), file reading,
|
|
29
|
+
* and regex grep. On {@link bind}, tokenizes chunks through the reranker
|
|
30
|
+
* and prepends a reranker-backed search tool.
|
|
14
31
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
32
|
+
* No orchestration, no prompts, no node:fs. Use {@link spawnAgents}
|
|
33
|
+
* from your harness to orchestrate agents with these tools.
|
|
17
34
|
*
|
|
18
35
|
* @category Rig
|
|
19
36
|
*/
|
|
20
|
-
export declare class CorpusSource extends Source<
|
|
37
|
+
export declare class CorpusSource extends Source<{
|
|
38
|
+
reranker: Reranker;
|
|
39
|
+
}, Chunk> {
|
|
21
40
|
private _chunks;
|
|
22
41
|
private _tools;
|
|
23
|
-
private _researchTool;
|
|
24
42
|
private _bound;
|
|
25
43
|
/** @inheritDoc */
|
|
26
44
|
readonly name = "corpus";
|
|
27
45
|
/**
|
|
28
46
|
* @param resources - Loaded file resources for read_file and grep tools
|
|
29
47
|
* @param chunks - Pre-split chunks for reranker-backed search
|
|
48
|
+
* @param opts - Configuration for grep and read_file tools
|
|
30
49
|
*/
|
|
31
|
-
constructor(resources: Resource[], chunks: Chunk[]);
|
|
32
|
-
/** @inheritDoc */
|
|
33
|
-
get researchTool(): Tool;
|
|
50
|
+
constructor(resources: Resource[], chunks: Chunk[], opts?: CorpusSourceOpts);
|
|
34
51
|
/** @inheritDoc */
|
|
35
|
-
get
|
|
52
|
+
get tools(): Tool[];
|
|
36
53
|
/**
|
|
37
|
-
* Late-bind reranker
|
|
38
|
-
*
|
|
39
|
-
* Tokenizes all chunks through the reranker, prepends a {@link SearchTool}
|
|
40
|
-
* to the tool list, then constructs the self-referential
|
|
41
|
-
* {@link ResearchTool} with corpus-specific prompts. Idempotent — skips
|
|
42
|
-
* if already bound.
|
|
43
|
-
*
|
|
54
|
+
* Late-bind reranker: tokenize chunks and prepend SearchTool.
|
|
55
|
+
* Idempotent — skips if already bound.
|
|
44
56
|
* @inheritDoc
|
|
45
57
|
*/
|
|
46
|
-
bind(ctx:
|
|
58
|
+
bind(ctx: {
|
|
59
|
+
reranker: Reranker;
|
|
60
|
+
}): Operation<void>;
|
|
47
61
|
}
|
|
48
62
|
//# sourceMappingURL=corpus.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"corpus.d.ts","sourceRoot":"","sources":["../../src/sources/corpus.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"corpus.d.ts","sourceRoot":"","sources":["../../src/sources/corpus.ts"],"names":[],"mappings":"AACA,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;AACvD,OAAO,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAK/C;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,6BAA6B;IAC7B,IAAI,CAAC,EAAE;QACL,wCAAwC;QACxC,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,+CAA+C;QAC/C,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,CAAC;IACF,iCAAiC;IACjC,QAAQ,CAAC,EAAE;QACT,8DAA8D;QAC9D,eAAe,CAAC,EAAE,MAAM,CAAC;KAC1B,CAAC;CACH;AAED;;;;;;;;;;;GAWG;AACH,qBAAa,YAAa,SAAQ,MAAM,CAAC;IAAE,QAAQ,EAAE,QAAQ,CAAA;CAAE,EAAE,KAAK,CAAC;IACrE,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,MAAM,CAAS;IAEvB,kBAAkB;IAClB,QAAQ,CAAC,IAAI,YAAY;IAEzB;;;;OAIG;gBACS,SAAS,EAAE,QAAQ,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,IAAI,CAAC,EAAE,gBAAgB;IAS3E,kBAAkB;IAClB,IAAI,KAAK,IAAI,IAAI,EAAE,CAAwB;IAE3C;;;;OAIG;IACF,IAAI,CAAC,GAAG,EAAE;QAAE,QAAQ,EAAE,QAAQ,CAAA;KAAE,GAAG,SAAS,CAAC,IAAI,CAAC;CASpD"}
|
package/dist/sources/corpus.js
CHANGED
|
@@ -1,69 +1,47 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CorpusSource = void 0;
|
|
4
|
-
const fs = require("node:fs");
|
|
5
|
-
const path = require("node:path");
|
|
6
4
|
const effection_1 = require("effection");
|
|
7
5
|
const lloyal_agents_1 = require("@lloyal-labs/lloyal-agents");
|
|
8
6
|
const search_1 = require("../tools/search");
|
|
9
7
|
const read_file_1 = require("../tools/read-file");
|
|
10
8
|
const grep_1 = require("../tools/grep");
|
|
11
|
-
const research_1 = require("../tools/research");
|
|
12
|
-
function readTask(name) {
|
|
13
|
-
const raw = fs
|
|
14
|
-
.readFileSync(path.resolve(__dirname, `${name}.md`), "utf8")
|
|
15
|
-
.trim();
|
|
16
|
-
const sep = raw.indexOf("\n---\n");
|
|
17
|
-
if (sep === -1)
|
|
18
|
-
return { system: raw, user: "" };
|
|
19
|
-
return { system: raw.slice(0, sep).trim(), user: raw.slice(sep + 5).trim() };
|
|
20
|
-
}
|
|
21
9
|
/**
|
|
22
|
-
* Corpus-backed
|
|
10
|
+
* Corpus-backed data source using local file search, read, and grep
|
|
23
11
|
*
|
|
24
|
-
* Provides
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* the tool list. The `search` tool is ordered first so the model prefers
|
|
28
|
-
* semantic search before falling back to `read_file` or `grep`.
|
|
12
|
+
* Provides three tools: semantic search (via reranker), file reading,
|
|
13
|
+
* and regex grep. On {@link bind}, tokenizes chunks through the reranker
|
|
14
|
+
* and prepends a reranker-backed search tool.
|
|
29
15
|
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
16
|
+
* No orchestration, no prompts, no node:fs. Use {@link spawnAgents}
|
|
17
|
+
* from your harness to orchestrate agents with these tools.
|
|
32
18
|
*
|
|
33
19
|
* @category Rig
|
|
34
20
|
*/
|
|
35
21
|
class CorpusSource extends lloyal_agents_1.Source {
|
|
36
22
|
_chunks;
|
|
37
|
-
_tools
|
|
38
|
-
_researchTool = null;
|
|
23
|
+
_tools;
|
|
39
24
|
_bound = false;
|
|
40
25
|
/** @inheritDoc */
|
|
41
26
|
name = "corpus";
|
|
42
27
|
/**
|
|
43
28
|
* @param resources - Loaded file resources for read_file and grep tools
|
|
44
29
|
* @param chunks - Pre-split chunks for reranker-backed search
|
|
30
|
+
* @param opts - Configuration for grep and read_file tools
|
|
45
31
|
*/
|
|
46
|
-
constructor(resources, chunks) {
|
|
32
|
+
constructor(resources, chunks, opts) {
|
|
47
33
|
super();
|
|
48
34
|
this._chunks = chunks;
|
|
49
|
-
this._tools = [
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
if (!this._researchTool)
|
|
54
|
-
throw new Error("CorpusSource: bind() must be called first");
|
|
55
|
-
return this._researchTool;
|
|
35
|
+
this._tools = [
|
|
36
|
+
new read_file_1.ReadFileTool(resources, opts?.readFile),
|
|
37
|
+
new grep_1.GrepTool(resources, opts?.grep),
|
|
38
|
+
];
|
|
56
39
|
}
|
|
57
40
|
/** @inheritDoc */
|
|
58
|
-
get
|
|
41
|
+
get tools() { return this._tools; }
|
|
59
42
|
/**
|
|
60
|
-
* Late-bind reranker
|
|
61
|
-
*
|
|
62
|
-
* Tokenizes all chunks through the reranker, prepends a {@link SearchTool}
|
|
63
|
-
* to the tool list, then constructs the self-referential
|
|
64
|
-
* {@link ResearchTool} with corpus-specific prompts. Idempotent — skips
|
|
65
|
-
* if already bound.
|
|
66
|
-
*
|
|
43
|
+
* Late-bind reranker: tokenize chunks and prepend SearchTool.
|
|
44
|
+
* Idempotent — skips if already bound.
|
|
67
45
|
* @inheritDoc
|
|
68
46
|
*/
|
|
69
47
|
*bind(ctx) {
|
|
@@ -74,16 +52,6 @@ class CorpusSource extends lloyal_agents_1.Source {
|
|
|
74
52
|
type: 'source:bind', sourceName: this.name });
|
|
75
53
|
yield* (0, effection_1.call)(() => ctx.reranker.tokenizeChunks(this._chunks));
|
|
76
54
|
this._tools.unshift(new search_1.SearchTool(this._chunks, ctx.reranker));
|
|
77
|
-
const researchPrompt = readTask("corpus-research");
|
|
78
|
-
const research = new research_1.ResearchTool({
|
|
79
|
-
systemPrompt: researchPrompt.system,
|
|
80
|
-
reporterPrompt: ctx.reporterPrompt,
|
|
81
|
-
maxTurns: ctx.maxTurns,
|
|
82
|
-
trace: ctx.trace,
|
|
83
|
-
});
|
|
84
|
-
const toolkit = (0, lloyal_agents_1.createToolkit)([...this._tools, ctx.reportTool, research]);
|
|
85
|
-
research.setToolkit(toolkit);
|
|
86
|
-
this._researchTool = research;
|
|
87
55
|
this._bound = true;
|
|
88
56
|
}
|
|
89
57
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"corpus.js","sourceRoot":"","sources":["../../src/sources/corpus.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"corpus.js","sourceRoot":"","sources":["../../src/sources/corpus.ts"],"names":[],"mappings":";;;AAAA,yCAAiC;AAEjC,8DAA2D;AAI3D,4CAA6C;AAC7C,kDAAkD;AAClD,wCAAyC;AAsBzC;;;;;;;;;;;GAWG;AACH,MAAa,YAAa,SAAQ,sBAAqC;IAC7D,OAAO,CAAU;IACjB,MAAM,CAAS;IACf,MAAM,GAAG,KAAK,CAAC;IAEvB,kBAAkB;IACT,IAAI,GAAG,QAAQ,CAAC;IAEzB;;;;OAIG;IACH,YAAY,SAAqB,EAAE,MAAe,EAAE,IAAuB;QACzE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,MAAM,GAAG;YACZ,IAAI,wBAAY,CAAC,SAAS,EAAE,IAAI,EAAE,QAAQ,CAAC;YAC3C,IAAI,eAAQ,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC;SACpC,CAAC;IACJ,CAAC;IAED,kBAAkB;IAClB,IAAI,KAAK,KAAa,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IAE3C;;;;OAIG;IACH,CAAC,IAAI,CAAC,GAA2B;QAC/B,IAAI,IAAI,CAAC,MAAM;YAAE,OAAO;QACxB,MAAM,EAAE,GAAG,KAAK,CAAC,CAAC,qBAAK,CAAC,MAAM,EAAE,CAAC;QACjC,EAAE,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,EAAE,CAAC,MAAM,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,EAAE,EAAE,WAAW,CAAC,GAAG,EAAE;YACzE,IAAI,EAAE,aAAa,EAAE,UAAU,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;QAChD,KAAK,CAAC,CAAC,IAAA,gBAAI,EAAC,GAAG,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;QAC7D,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,mBAAU,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC;QAChE,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;IACrB,CAAC;CACF;AAvCD,oCAuCC"}
|
package/dist/sources/index.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Source implementations for
|
|
2
|
+
* Source implementations — data backends for agent pipelines
|
|
3
3
|
*
|
|
4
4
|
* @packageDocumentation
|
|
5
5
|
* @category Rig
|
|
6
6
|
*/
|
|
7
7
|
export { WebSource } from './web';
|
|
8
|
+
export type { WebSourceOpts } from './web';
|
|
8
9
|
export { CorpusSource } from './corpus';
|
|
10
|
+
export type { CorpusSourceOpts } from './corpus';
|
|
9
11
|
export type { SourceContext } from './types';
|
|
10
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sources/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sources/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,YAAY,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,YAAY,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AACjD,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC"}
|
package/dist/sources/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CorpusSource = exports.WebSource = void 0;
|
|
4
4
|
/**
|
|
5
|
-
* Source implementations for
|
|
5
|
+
* Source implementations — data backends for agent pipelines
|
|
6
6
|
*
|
|
7
7
|
* @packageDocumentation
|
|
8
8
|
* @category Rig
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sources/index.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,6BAAkC;AAAzB,gGAAA,SAAS,OAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sources/index.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,6BAAkC;AAAzB,gGAAA,SAAS,OAAA;AAElB,mCAAwC;AAA/B,sGAAA,YAAY,OAAA"}
|
package/dist/sources/types.d.ts
CHANGED
|
@@ -1,28 +1,16 @@
|
|
|
1
|
-
import type { Tool } from '@lloyal-labs/lloyal-agents';
|
|
2
1
|
import type { Reranker } from '../tools/types';
|
|
3
2
|
/**
|
|
4
|
-
* Runtime context passed to {@link Source.bind} during pipeline setup
|
|
3
|
+
* Runtime context passed to {@link Source.bind} during pipeline setup.
|
|
5
4
|
*
|
|
6
|
-
* Carries
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
5
|
+
* Carries the reranker instance needed by corpus sources to tokenize
|
|
6
|
+
* chunks and by web sources for fetch-page chunk scoring. Orchestration
|
|
7
|
+
* config (prompts, maxTurns, tools) belongs in {@link spawnAgents} opts,
|
|
8
|
+
* not in the source context.
|
|
10
9
|
*
|
|
11
10
|
* @category Rig
|
|
12
11
|
*/
|
|
13
12
|
export interface SourceContext {
|
|
14
|
-
/** Reranker instance
|
|
13
|
+
/** Reranker instance for chunk tokenization and scoring */
|
|
15
14
|
reranker: Reranker;
|
|
16
|
-
/** System/user prompt pair for the report-writing pass inside research tools */
|
|
17
|
-
reporterPrompt: {
|
|
18
|
-
system: string;
|
|
19
|
-
user: string;
|
|
20
|
-
};
|
|
21
|
-
/** Shared report tool instance injected into every source's research toolkit */
|
|
22
|
-
reportTool: Tool;
|
|
23
|
-
/** Maximum tool-use turns for research sub-agents before forced termination */
|
|
24
|
-
maxTurns: number;
|
|
25
|
-
/** Whether to emit structured trace events during research execution */
|
|
26
|
-
trace: boolean;
|
|
27
15
|
}
|
|
28
16
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/sources/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/sources/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C;;;;;;;;;GASG;AACH,MAAM,WAAW,aAAa;IAC5B,2DAA2D;IAC3D,QAAQ,EAAE,QAAQ,CAAC;CACpB"}
|
package/dist/sources/web.d.ts
CHANGED
|
@@ -2,41 +2,65 @@ import type { Operation } from "effection";
|
|
|
2
2
|
import { Source } from "@lloyal-labs/lloyal-agents";
|
|
3
3
|
import type { Tool } from "@lloyal-labs/lloyal-agents";
|
|
4
4
|
import type { Chunk } from "../resources/types";
|
|
5
|
-
import type { SourceContext } from "./types";
|
|
6
5
|
import type { SearchProvider } from "../tools/types";
|
|
6
|
+
import type { Reranker } from "../tools/types";
|
|
7
7
|
export { chunkFetchedPages, type FetchedPage } from "./chunking";
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* Configuration for {@link WebSource}.
|
|
10
10
|
*
|
|
11
|
-
*
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
* @category Rig
|
|
12
|
+
*/
|
|
13
|
+
export interface WebSourceOpts {
|
|
14
|
+
/** Max search results returned to agents. @default 8 */
|
|
15
|
+
topN?: number;
|
|
16
|
+
/** FetchPageTool configuration */
|
|
17
|
+
fetch?: {
|
|
18
|
+
/** Max chars for full-content fallback (no reranker). @default 6000 */
|
|
19
|
+
maxChars?: number;
|
|
20
|
+
/** Top-K reranked chunks returned. @default 5 */
|
|
21
|
+
topK?: number;
|
|
22
|
+
/** Fetch timeout in ms. @default 10000 */
|
|
23
|
+
timeout?: number;
|
|
24
|
+
/** Reranker token budget for chunk selection. @default 2048 */
|
|
25
|
+
tokenBudget?: number;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Web-backed data source
|
|
30
|
+
*
|
|
31
|
+
* Provides two tools: {@link WebSearchTool} (search the web) and
|
|
32
|
+
* {@link FetchPageTool} (fetch and extract page content with optional
|
|
33
|
+
* reranking). Fetched content is buffered for post-use reranking via
|
|
34
|
+
* {@link getChunks}.
|
|
35
|
+
*
|
|
36
|
+
* No orchestration, no prompts, no node:fs. Works on Node and React
|
|
37
|
+
* Native identically. Use {@link spawnAgents} from your harness to
|
|
38
|
+
* orchestrate agents with these tools.
|
|
15
39
|
*
|
|
16
40
|
* @category Rig
|
|
17
41
|
*/
|
|
18
|
-
export declare class WebSource extends Source<
|
|
42
|
+
export declare class WebSource extends Source<{
|
|
43
|
+
reranker: Reranker;
|
|
44
|
+
}, Chunk> {
|
|
19
45
|
private _buffer;
|
|
20
46
|
private _fetchPage;
|
|
21
47
|
private _webSearch;
|
|
22
|
-
private _researchPrompt;
|
|
23
|
-
private _researchTool;
|
|
24
48
|
/** @inheritDoc */
|
|
25
49
|
readonly name = "web";
|
|
26
50
|
/**
|
|
27
51
|
* @param provider - Search backend (e.g. {@link TavilyProvider}) for web_search calls
|
|
52
|
+
* @param opts - Configuration for search and fetch tools
|
|
28
53
|
*/
|
|
29
|
-
constructor(provider: SearchProvider);
|
|
30
|
-
/** @inheritDoc */
|
|
31
|
-
get researchTool(): Tool;
|
|
54
|
+
constructor(provider: SearchProvider, opts?: WebSourceOpts);
|
|
32
55
|
/** @inheritDoc */
|
|
33
|
-
get
|
|
56
|
+
get tools(): Tool[];
|
|
34
57
|
/**
|
|
35
|
-
* Wire reranker to FetchPageTool
|
|
36
|
-
*
|
|
58
|
+
* Wire reranker to FetchPageTool for chunk scoring.
|
|
37
59
|
* @inheritDoc
|
|
38
60
|
*/
|
|
39
|
-
bind(ctx:
|
|
61
|
+
bind(ctx: {
|
|
62
|
+
reranker: Reranker;
|
|
63
|
+
}): Operation<void>;
|
|
40
64
|
/** @inheritDoc */
|
|
41
65
|
getChunks(): Chunk[];
|
|
42
66
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.d.ts","sourceRoot":"","sources":["../../src/sources/web.ts"],"names":[],"mappings":"
|
|
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,EAAsB,MAAM,4BAA4B,CAAC;AAC3E,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;AAqCjE;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,wDAAwD;IACxD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,kCAAkC;IAClC,KAAK,CAAC,EAAE;QACN,uEAAuE;QACvE,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,iDAAiD;QACjD,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,0CAA0C;QAC1C,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,+DAA+D;QAC/D,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,CAAC;CACH;AAED;;;;;;;;;;;;;GAaG;AACH,qBAAa,SAAU,SAAQ,MAAM,CAAC;IAAE,QAAQ,EAAE,QAAQ,CAAA;CAAE,EAAE,KAAK,CAAC;IAClE,OAAO,CAAC,OAAO,CAAqB;IACpC,OAAO,CAAC,UAAU,CAAqB;IACvC,OAAO,CAAC,UAAU,CAAgB;IAElC,kBAAkB;IAClB,QAAQ,CAAC,IAAI,SAAS;IAEtB;;;OAGG;gBACS,QAAQ,EAAE,cAAc,EAAE,IAAI,CAAC,EAAE,aAAa;IAM1D,kBAAkB;IAClB,IAAI,KAAK,IAAI,IAAI,EAAE,CAElB;IAED;;;OAGG;IACF,IAAI,CAAC,GAAG,EAAE;QAAE,QAAQ,EAAE,QAAQ,CAAA;KAAE,GAAG,SAAS,CAAC,IAAI,CAAC;IAcnD,kBAAkB;IAClB,SAAS,IAAI,KAAK,EAAE;CAGrB"}
|