@lloyal-labs/rig 1.3.0 → 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 CHANGED
@@ -1,20 +1,23 @@
1
1
  /**
2
- * Rig — research infrastructure for the lloyal agent pipeline
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, WebSource, CorpusSource,
8
- * loadResources, chunkResources) require node:fs and are available
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, ResearchTool, WebSearchTool, TavilyProvider, FetchPageTool, WebResearchTool, PlanTool, } from './tools';
15
- export type { ResearchToolOpts, WebResearchToolOpts, PlanToolOpts, PlanResult, PlanQuestion, SearchProvider, SearchResult, Reranker, ScoredChunk, ScoredResult, } from './tools';
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
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.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AAC;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 — research infrastructure for the lloyal agent pipeline
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, WebSource, CorpusSource,
9
- * loadResources, chunkResources) require node:fs and are available
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.PlanTool = exports.WebResearchTool = exports.FetchPageTool = exports.TavilyProvider = exports.WebSearchTool = exports.ResearchTool = exports.reportTool = exports.createTools = void 0;
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, "ResearchTool", { enumerable: true, get: function () { return tools_1.ResearchTool; } });
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;;;;;;;;;;;;GAYG;;;AAEH,6DAA6D;AAC7D,iCAIiB;AAHf,oGAAA,WAAW,OAAA;AAAE,mGAAA,UAAU,OAAA;AACvB,qGAAA,YAAY,OAAA;AAAE,sGAAA,aAAa,OAAA;AAAE,uGAAA,cAAc,OAAA;AAAE,sGAAA,aAAa,OAAA;AAC1D,wGAAA,eAAe,OAAA;AAAE,iGAAA,QAAQ,OAAA;AAS3B,qDAAqD;AACrD,+CAAkE;AAAzD,6GAAA,iBAAiB,OAAA;AAAE,qGAAA,SAAS,OAAA"}
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
@@ -1 +1 @@
1
- {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,cAAc,SAAS,CAAC;AAGxB,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAG5C,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAGhD,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC"}
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.CorpusSource = exports.WebSource = exports.createReranker = void 0;
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;;;;;;;;GAQG;;;;;;;;;;;;;;;;;AAEH,yDAAyD;AACzD,0CAAwB;AAExB,kEAAkE;AAClE,uCAA4C;AAAnC,0GAAA,cAAc,OAAA;AAEvB,uCAAuC;AACvC,qCAA0C;AAAjC,gGAAA,SAAS,OAAA;AAClB,2CAAgD;AAAvC,sGAAA,YAAY,OAAA;AAErB,iDAAiD;AACjD,yCAA4D;AAAnD,0GAAA,aAAa,OAAA;AAAE,2GAAA,cAAc,OAAA"}
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"}
@@ -1,22 +1,8 @@
1
1
  import type { Operation } from "effection";
2
2
  import { Source } from "@lloyal-labs/lloyal-agents";
3
- import type { Tool, PressureThresholds } from "@lloyal-labs/lloyal-agents";
3
+ import type { Tool } from "@lloyal-labs/lloyal-agents";
4
4
  import type { Resource, Chunk } from "../resources/types";
5
- import type { SourceContext } from "./types";
6
- /**
7
- * Corpus-backed research source using local file search, read, and grep
8
- *
9
- * Provides grounding tools (`search`, `read_file`, `grep`) over a set of
10
- * loaded {@link Resource} / {@link Chunk} pairs. On {@link bind}, tokenizes
11
- * chunks via the reranker and prepends a reranker-backed `search` tool to
12
- * the tool list. The `search` tool is ordered first so the model prefers
13
- * semantic search before falling back to `read_file` or `grep`.
14
- *
15
- * The research tool is a self-referential {@link ResearchTool} that spawns
16
- * sub-agents with corpus-specific prompts and the full grounding toolkit.
17
- *
18
- * @category Rig
19
- */
5
+ import type { Reranker } from "../tools/types";
20
6
  /**
21
7
  * Configuration for {@link CorpusSource}.
22
8
  *
@@ -35,40 +21,42 @@ export interface CorpusSourceOpts {
35
21
  /** Default max lines when no range specified. @default 100 */
36
22
  defaultMaxLines?: number;
37
23
  };
38
- /** ResearchTool overrides */
39
- research?: {
40
- /** Override pressure thresholds for inner research pool */
41
- pressure?: PressureThresholds;
42
- };
43
24
  }
44
- export declare class CorpusSource extends Source<SourceContext, Chunk> {
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.
31
+ *
32
+ * No orchestration, no prompts, no node:fs. Use {@link spawnAgents}
33
+ * from your harness to orchestrate agents with these tools.
34
+ *
35
+ * @category Rig
36
+ */
37
+ export declare class CorpusSource extends Source<{
38
+ reranker: Reranker;
39
+ }, Chunk> {
45
40
  private _chunks;
46
41
  private _tools;
47
- private _researchTool;
48
42
  private _bound;
49
- private _researchOpts?;
50
43
  /** @inheritDoc */
51
44
  readonly name = "corpus";
52
45
  /**
53
46
  * @param resources - Loaded file resources for read_file and grep tools
54
47
  * @param chunks - Pre-split chunks for reranker-backed search
55
- * @param opts - Configuration for grep, read_file, and research tools
48
+ * @param opts - Configuration for grep and read_file tools
56
49
  */
57
50
  constructor(resources: Resource[], chunks: Chunk[], opts?: CorpusSourceOpts);
58
51
  /** @inheritDoc */
59
- get researchTool(): Tool;
60
- /** @inheritDoc */
61
- get groundingTools(): Tool[];
52
+ get tools(): Tool[];
62
53
  /**
63
- * Late-bind reranker and build the research toolkit
64
- *
65
- * Tokenizes all chunks through the reranker, prepends a {@link SearchTool}
66
- * to the tool list, then constructs the self-referential
67
- * {@link ResearchTool} with corpus-specific prompts. Idempotent — skips
68
- * if already bound.
69
- *
54
+ * Late-bind reranker: tokenize chunks and prepend SearchTool.
55
+ * Idempotent — skips if already bound.
70
56
  * @inheritDoc
71
57
  */
72
- bind(ctx: SourceContext): Operation<void>;
58
+ bind(ctx: {
59
+ reranker: Reranker;
60
+ }): Operation<void>;
73
61
  }
74
62
  //# sourceMappingURL=corpus.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"corpus.d.ts","sourceRoot":"","sources":["../../src/sources/corpus.ts"],"names":[],"mappings":"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;QAAE,QAAQ,EAAE,QAAQ,CAAA;KAAE,GAAG,SAAS,CAAC,IAAI,CAAC;CASpD"}
@@ -1,35 +1,33 @@
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
- }
9
+ /**
10
+ * Corpus-backed data source using local file search, read, and grep
11
+ *
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.
15
+ *
16
+ * No orchestration, no prompts, no node:fs. Use {@link spawnAgents}
17
+ * from your harness to orchestrate agents with these tools.
18
+ *
19
+ * @category Rig
20
+ */
21
21
  class CorpusSource extends lloyal_agents_1.Source {
22
22
  _chunks;
23
- _tools = [];
24
- _researchTool = null;
23
+ _tools;
25
24
  _bound = false;
26
- _researchOpts;
27
25
  /** @inheritDoc */
28
26
  name = "corpus";
29
27
  /**
30
28
  * @param resources - Loaded file resources for read_file and grep tools
31
29
  * @param chunks - Pre-split chunks for reranker-backed search
32
- * @param opts - Configuration for grep, read_file, and research tools
30
+ * @param opts - Configuration for grep and read_file tools
33
31
  */
34
32
  constructor(resources, chunks, opts) {
35
33
  super();
@@ -38,24 +36,12 @@ class CorpusSource extends lloyal_agents_1.Source {
38
36
  new read_file_1.ReadFileTool(resources, opts?.readFile),
39
37
  new grep_1.GrepTool(resources, opts?.grep),
40
38
  ];
41
- this._researchOpts = opts?.research;
42
- }
43
- /** @inheritDoc */
44
- get researchTool() {
45
- if (!this._researchTool)
46
- throw new Error("CorpusSource: bind() must be called first");
47
- return this._researchTool;
48
39
  }
49
40
  /** @inheritDoc */
50
- get groundingTools() { return this._tools; }
41
+ get tools() { return this._tools; }
51
42
  /**
52
- * Late-bind reranker and build the research toolkit
53
- *
54
- * Tokenizes all chunks through the reranker, prepends a {@link SearchTool}
55
- * to the tool list, then constructs the self-referential
56
- * {@link ResearchTool} with corpus-specific prompts. Idempotent — skips
57
- * if already bound.
58
- *
43
+ * Late-bind reranker: tokenize chunks and prepend SearchTool.
44
+ * Idempotent — skips if already bound.
59
45
  * @inheritDoc
60
46
  */
61
47
  *bind(ctx) {
@@ -66,17 +52,6 @@ class CorpusSource extends lloyal_agents_1.Source {
66
52
  type: 'source:bind', sourceName: this.name });
67
53
  yield* (0, effection_1.call)(() => ctx.reranker.tokenizeChunks(this._chunks));
68
54
  this._tools.unshift(new search_1.SearchTool(this._chunks, ctx.reranker));
69
- const researchPrompt = readTask("corpus-research");
70
- const research = new research_1.ResearchTool({
71
- systemPrompt: researchPrompt.system,
72
- reporterPrompt: ctx.reporterPrompt,
73
- maxTurns: ctx.maxTurns,
74
- trace: ctx.trace,
75
- pressure: this._researchOpts?.pressure,
76
- });
77
- const toolkit = (0, lloyal_agents_1.createToolkit)([...this._tools, ctx.reportTool, research]);
78
- research.setToolkit(toolkit);
79
- this._researchTool = research;
80
55
  this._bound = true;
81
56
  }
82
57
  }
@@ -1 +1 @@
1
- {"version":3,"file":"corpus.js","sourceRoot":"","sources":["../../src/sources/corpus.ts"],"names":[],"mappings":";;;AAAA,8BAA8B;AAC9B,kCAAkC;AAClC,yCAAiC;AAEjC,8DAA0E;AAI1E,4CAA6C;AAC7C,kDAAkD;AAClD,wCAAyC;AACzC,gDAAiD;AAEjD,SAAS,QAAQ,CAAC,IAAY;IAC5B,MAAM,GAA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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"}
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Source implementations for the research pipeline
2
+ * Source implementations — data backends for agent pipelines
3
3
  *
4
4
  * @packageDocumentation
5
5
  * @category Rig
@@ -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 the research pipeline
5
+ * Source implementations — data backends for agent pipelines
6
6
  *
7
7
  * @packageDocumentation
8
8
  * @category Rig
@@ -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 shared dependencies that are not available at source construction
7
- * time the reranker instance, reporter prompt/tool, and pipeline-level
8
- * configuration. Each source receives the same context so research and
9
- * grounding tools share a consistent environment.
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 used by corpus sources to tokenize chunks and score results */
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,IAAI,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C;;;;;;;;;GASG;AACH,MAAM,WAAW,aAAa;IAC5B,oFAAoF;IACpF,QAAQ,EAAE,QAAQ,CAAC;IACnB,gFAAgF;IAChF,cAAc,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IACjD,gFAAgF;IAChF,UAAU,EAAE,IAAI,CAAC;IACjB,+EAA+E;IAC/E,QAAQ,EAAE,MAAM,CAAC;IACjB,wEAAwE;IACxE,KAAK,EAAE,OAAO,CAAC;CAChB"}
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"}
@@ -1,20 +1,10 @@
1
1
  import type { Operation } from "effection";
2
2
  import { Source } from "@lloyal-labs/lloyal-agents";
3
- import type { Tool, PressureThresholds } from "@lloyal-labs/lloyal-agents";
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
- /**
9
- * Web-backed research source
10
- *
11
- * Agents search the web via {@link WebSearchTool} (returns titles, snippets,
12
- * URLs), then fetch promising pages via {@link FetchPageTool} (returns
13
- * reranked relevant chunks). Fetched content is buffered for post-research
14
- * passage reranking via {@link getChunks}.
15
- *
16
- * @category Rig
17
- */
18
8
  /**
19
9
  * Configuration for {@link WebSource}.
20
10
  *
@@ -34,40 +24,43 @@ export interface WebSourceOpts {
34
24
  /** Reranker token budget for chunk selection. @default 2048 */
35
25
  tokenBudget?: number;
36
26
  };
37
- /** WebResearchTool overrides (applied on top of SourceContext) */
38
- research?: {
39
- /** Override tool name. @default "web_research" */
40
- name?: string;
41
- /** Override tool description */
42
- description?: string;
43
- /** Override pressure thresholds for inner research pool */
44
- pressure?: PressureThresholds;
45
- };
46
27
  }
47
- export declare class WebSource extends Source<SourceContext, Chunk> {
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.
39
+ *
40
+ * @category Rig
41
+ */
42
+ export declare class WebSource extends Source<{
43
+ reranker: Reranker;
44
+ }, Chunk> {
48
45
  private _buffer;
49
46
  private _fetchPage;
50
47
  private _webSearch;
51
- private _researchPrompt;
52
- private _researchTool;
53
- private _researchOpts?;
54
48
  /** @inheritDoc */
55
49
  readonly name = "web";
56
50
  /**
57
51
  * @param provider - Search backend (e.g. {@link TavilyProvider}) for web_search calls
58
- * @param opts - Configuration for search, fetch, and research tools
52
+ * @param opts - Configuration for search and fetch tools
59
53
  */
60
54
  constructor(provider: SearchProvider, opts?: WebSourceOpts);
61
55
  /** @inheritDoc */
62
- get researchTool(): Tool;
63
- /** @inheritDoc */
64
- get groundingTools(): Tool[];
56
+ get tools(): Tool[];
65
57
  /**
66
- * Wire reranker to FetchPageTool and build the research toolkit
67
- *
58
+ * Wire reranker to FetchPageTool for chunk scoring.
68
59
  * @inheritDoc
69
60
  */
70
- bind(ctx: SourceContext): Operation<void>;
61
+ bind(ctx: {
62
+ reranker: Reranker;
63
+ }): Operation<void>;
71
64
  /** @inheritDoc */
72
65
  getChunks(): Chunk[];
73
66
  }
@@ -1 +1 @@
1
- {"version":3,"file":"web.d.ts","sourceRoot":"","sources":["../../src/sources/web.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAwB,MAAM,4BAA4B,CAAC;AAC1E,OAAO,KAAK,EAAE,IAAI,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAC3E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAQrD,OAAO,EAAE,iBAAiB,EAAE,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AAmDjE;;;;;;;;;GASG;AACH;;;;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;IACF,kEAAkE;IAClE,QAAQ,CAAC,EAAE;QACT,kDAAkD;QAClD,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,gCAAg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AAM,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"}
@@ -1,33 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.WebSource = exports.chunkFetchedPages = void 0;
4
- const fs = require("node:fs");
5
- const path = require("node:path");
6
4
  const lloyal_agents_1 = require("@lloyal-labs/lloyal-agents");
7
5
  const web_search_1 = require("../tools/web-search");
8
6
  const fetch_page_1 = require("../tools/fetch-page");
9
- const web_research_1 = require("../tools/web-research");
10
7
  const chunking_1 = require("./chunking");
11
8
  // Re-export for backwards compatibility
12
9
  var chunking_2 = require("./chunking");
13
10
  Object.defineProperty(exports, "chunkFetchedPages", { enumerable: true, get: function () { return chunking_2.chunkFetchedPages; } });
14
- // ── Task loader ──────────────────────────────────────────────────
15
- function readTask(name) {
16
- const raw = fs
17
- .readFileSync(path.resolve(__dirname, `${name}.md`), "utf8")
18
- .trim();
19
- const sep = raw.indexOf("\n---\n");
20
- if (sep === -1)
21
- return { system: raw, user: "" };
22
- return { system: raw.slice(0, sep).trim(), user: raw.slice(sep + 5).trim() };
23
- }
24
- // ── BufferingFetchPage ───────────────────────────────────────────
11
+ // ── BufferingFetchPage ───────────────────────────────────────
25
12
  /**
26
13
  * Thin wrapper over {@link FetchPageTool} that buffers fetched content
27
- * for post-research reranking via {@link WebSource.getChunks}.
28
- *
29
- * No scratchpad extraction. No content transformation. Just buffers
30
- * the raw text alongside returning the reranked result to the agent.
14
+ * for post-use reranking via {@link WebSource.getChunks}.
31
15
  *
32
16
  * @category Rig
33
17
  */
@@ -51,44 +35,45 @@ class BufferingFetchPage extends fetch_page_1.FetchPageTool {
51
35
  return result;
52
36
  }
53
37
  }
38
+ /**
39
+ * Web-backed data source
40
+ *
41
+ * Provides two tools: {@link WebSearchTool} (search the web) and
42
+ * {@link FetchPageTool} (fetch and extract page content with optional
43
+ * reranking). Fetched content is buffered for post-use reranking via
44
+ * {@link getChunks}.
45
+ *
46
+ * No orchestration, no prompts, no node:fs. Works on Node and React
47
+ * Native identically. Use {@link spawnAgents} from your harness to
48
+ * orchestrate agents with these tools.
49
+ *
50
+ * @category Rig
51
+ */
54
52
  class WebSource extends lloyal_agents_1.Source {
55
53
  _buffer = [];
56
54
  _fetchPage;
57
55
  _webSearch;
58
- _researchPrompt;
59
- _researchTool = null;
60
- _researchOpts;
61
56
  /** @inheritDoc */
62
57
  name = "web";
63
58
  /**
64
59
  * @param provider - Search backend (e.g. {@link TavilyProvider}) for web_search calls
65
- * @param opts - Configuration for search, fetch, and research tools
60
+ * @param opts - Configuration for search and fetch tools
66
61
  */
67
62
  constructor(provider, opts) {
68
63
  super();
69
- this._researchPrompt = readTask("web-research");
70
64
  this._fetchPage = new BufferingFetchPage(this._buffer, opts?.fetch);
71
65
  this._webSearch = new web_search_1.WebSearchTool(provider, opts?.topN);
72
- this._researchOpts = opts?.research;
73
- }
74
- /** @inheritDoc */
75
- get researchTool() {
76
- if (!this._researchTool)
77
- throw new Error("WebSource: bind() must be called first");
78
- return this._researchTool;
79
66
  }
80
67
  /** @inheritDoc */
81
- get groundingTools() {
68
+ get tools() {
82
69
  return [this._webSearch, this._fetchPage];
83
70
  }
84
71
  /**
85
- * Wire reranker to FetchPageTool and build the research toolkit
86
- *
72
+ * Wire reranker to FetchPageTool for chunk scoring.
87
73
  * @inheritDoc
88
74
  */
89
75
  *bind(ctx) {
90
76
  this._buffer.length = 0;
91
- // Wire reranker to FetchPageTool for chunk scoring
92
77
  this._fetchPage.setReranker(ctx.reranker);
93
78
  const tw = yield* lloyal_agents_1.Trace.expect();
94
79
  tw.write({
@@ -98,27 +83,6 @@ class WebSource extends lloyal_agents_1.Source {
98
83
  type: "source:bind",
99
84
  sourceName: this.name,
100
85
  });
101
- if (!this._researchTool) {
102
- const ro = this._researchOpts;
103
- const webResearch = new web_research_1.WebResearchTool({
104
- name: ro?.name ?? "web_research",
105
- description: ro?.description ??
106
- "Spawn parallel web research agents that search the web, fetch pages, and report findings.",
107
- systemPrompt: this._researchPrompt.system,
108
- reporterPrompt: ctx.reporterPrompt,
109
- maxTurns: ctx.maxTurns,
110
- trace: ctx.trace,
111
- pressure: ro?.pressure,
112
- });
113
- const toolkit = (0, lloyal_agents_1.createToolkit)([
114
- this._webSearch,
115
- this._fetchPage,
116
- ctx.reportTool,
117
- webResearch,
118
- ]);
119
- webResearch.setToolkit(toolkit);
120
- this._researchTool = webResearch;
121
- }
122
86
  }
123
87
  /** @inheritDoc */
124
88
  getChunks() {
@@ -1 +1 @@
1
- {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/sources/web.ts"],"names":[],"mappings":";;;AAAA,8BAA8B;AA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K,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,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;AA7CD,8BA6CC"}
@@ -2,13 +2,10 @@ import type { Toolkit } from '@lloyal-labs/lloyal-agents';
2
2
  import type { Resource, Chunk } from '../resources/types';
3
3
  import type { Reranker } from './types';
4
4
  import { ReportTool } from './report';
5
- export { ResearchTool } from './research';
6
- export type { ResearchToolOpts } from './research';
7
5
  export { WebSearchTool, TavilyProvider } from './web-search';
8
6
  export { FetchPageTool } from './fetch-page';
7
+ export { ReportTool } from './report';
9
8
  export type { SearchProvider, SearchResult, Reranker, ScoredChunk, ScoredResult } from './types';
10
- export { WebResearchTool } from './web-research';
11
- export type { WebResearchToolOpts } from './web-research';
12
9
  export { PlanTool } from './plan';
13
10
  export type { PlanResult, PlanQuestion, PlanToolOpts } from './plan';
14
11
  /**
@@ -20,15 +17,12 @@ export type { PlanResult, PlanQuestion, PlanToolOpts } from './plan';
20
17
  */
21
18
  export declare const reportTool: ReportTool;
22
19
  /**
23
- * Build the standard corpus-research toolkit.
20
+ * Build the standard corpus toolkit.
24
21
  *
25
22
  * Returns a {@link Toolkit} containing {@link SearchTool},
26
23
  * {@link ReadFileTool}, {@link GrepTool}, and {@link ReportTool}
27
24
  * wired to the provided resources, chunks, and reranker.
28
25
  *
29
- * @param opts - Resources, chunks, and reranker to bind into the tools.
30
- * @returns A ready-to-use toolkit for corpus research agents.
31
- *
32
26
  * @category Rig
33
27
  */
34
28
  export declare function createTools(opts: {
@@ -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,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,YAAY,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,QAAQ,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACjG,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,YAAY,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAClC,YAAY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CAOV"}
@@ -1,21 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.reportTool = exports.PlanTool = exports.WebResearchTool = exports.FetchPageTool = exports.TavilyProvider = exports.WebSearchTool = exports.ResearchTool = void 0;
3
+ exports.reportTool = exports.PlanTool = 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");
7
7
  const read_file_1 = require("./read-file");
8
8
  const grep_1 = require("./grep");
9
9
  const report_1 = require("./report");
10
- var research_1 = require("./research");
11
- Object.defineProperty(exports, "ResearchTool", { enumerable: true, get: function () { return research_1.ResearchTool; } });
12
10
  var web_search_1 = require("./web-search");
13
11
  Object.defineProperty(exports, "WebSearchTool", { enumerable: true, get: function () { return web_search_1.WebSearchTool; } });
14
12
  Object.defineProperty(exports, "TavilyProvider", { enumerable: true, get: function () { return web_search_1.TavilyProvider; } });
15
13
  var fetch_page_1 = require("./fetch-page");
16
14
  Object.defineProperty(exports, "FetchPageTool", { enumerable: true, get: function () { return fetch_page_1.FetchPageTool; } });
17
- var web_research_1 = require("./web-research");
18
- Object.defineProperty(exports, "WebResearchTool", { enumerable: true, get: function () { return web_research_1.WebResearchTool; } });
15
+ var report_2 = require("./report");
16
+ Object.defineProperty(exports, "ReportTool", { enumerable: true, get: function () { return report_2.ReportTool; } });
19
17
  var plan_1 = require("./plan");
20
18
  Object.defineProperty(exports, "PlanTool", { enumerable: true, get: function () { return plan_1.PlanTool; } });
21
19
  /**
@@ -27,15 +25,12 @@ Object.defineProperty(exports, "PlanTool", { enumerable: true, get: function ()
27
25
  */
28
26
  exports.reportTool = new report_1.ReportTool();
29
27
  /**
30
- * Build the standard corpus-research toolkit.
28
+ * Build the standard corpus toolkit.
31
29
  *
32
30
  * Returns a {@link Toolkit} containing {@link SearchTool},
33
31
  * {@link ReadFileTool}, {@link GrepTool}, and {@link ReportTool}
34
32
  * wired to the provided resources, chunks, and reranker.
35
33
  *
36
- * @param opts - Resources, chunks, and reranker to bind into the tools.
37
- * @returns A ready-to-use toolkit for corpus research agents.
38
- *
39
34
  * @category Rig
40
35
  */
41
36
  function createTools(opts) {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":";;;AAwCA,kCAWC;AAnDD,8DAA2D;AAI3D,qCAAsC;AACtC,2CAA2C;AAC3C,iCAAkC;AAClC,qCAAsC;AAEtC,uCAA0C;AAAjC,wGAAA,YAAY,OAAA;AAErB,2CAA6D;AAApD,2GAAA,aAAa,OAAA;AAAE,4GAAA,cAAc,OAAA;AACtC,2CAA6C;AAApC,2GAAA,aAAa,OAAA;AAEtB,+CAAiD;AAAxC,+GAAA,eAAe,OAAA;AAExB,+BAAkC;AAAzB,gGAAA,QAAQ,OAAA;AAGjB;;;;;;GAMG;AACU,QAAA,UAAU,GAAG,IAAI,mBAAU,EAAE,CAAC;AAE3C;;;;;;;;;;;GAWG;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"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":";;;AAkCA,kCAWC;AA7CD,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;AAEnB,+BAAkC;AAAzB,gGAAA,QAAQ,OAAA;AAGjB;;;;;;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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lloyal-labs/rig",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "description": "Retrieval-Interleaved Generation for lloyal-agents",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -37,7 +37,7 @@
37
37
  "license": "Apache-2.0",
38
38
  "type": "commonjs",
39
39
  "scripts": {
40
- "build": "tsc -b && mkdir -p dist/sources && cp src/sources/*.md dist/sources/"
40
+ "build": "tsc -b"
41
41
  },
42
42
  "dependencies": {
43
43
  "@lloyal-labs/lloyal-agents": "*",
@@ -1,14 +0,0 @@
1
- You are a research assistant analyzing a knowledge base. Your tools:
2
- - **grep**: regex pattern matching — use for precise, exhaustive retrieval
3
- - **search**: semantic relevance ranking — use to discover related content
4
- - **read_file**: read specific line ranges — use to verify and get context
5
- - **research**: spawn parallel sub-agents that each run their own grep/search/read_file cycle — call with `{"questions": ["q1", "q2", ...]}`
6
- - **report**: submit your final findings with evidence
7
-
8
- Process — follow every step in order:
9
- 1. Grep with short, simple patterns first. Use single keywords or two-word phrases — never combine multiple clauses with `.*`. Run multiple greps if needed.
10
- 2. Use search to discover content that grep may miss (different phrasing, synonyms).
11
- 3. Read every matching line with read_file to verify in context. Do not rely on grep/search summaries alone.
12
- 4. Grep again with a different pattern targeting what you have NOT yet found. This is a completeness check, not confirmation of existing results.
13
- 5. Call research with sub-questions only if your findings point to specific topics you haven't fully investigated.
14
- 6. Report with line numbers and direct quotes as evidence. State what you found and what you checked.
@@ -1,5 +0,0 @@
1
- You extract key information from web page content. Produce a concise summary and list any URLs/links found in the text that are worth following. Output JSON only.
2
- ---
3
- Page: {{title}} ({{url}})
4
-
5
- {{content}}
@@ -1,6 +0,0 @@
1
- You select the most relevant search results for a research query. Pick URLs most likely to contain substantive information and summarize the key findings. Output JSON only.
2
- ---
3
- Query: {{query}}
4
-
5
- Search results:
6
- {{results}}
@@ -1,12 +0,0 @@
1
- You are a research assistant investigating questions using the web. Your tools:
2
- - **web_search**: search the web — returns results with titles, snippets, and URLs
3
- - **fetch_page**: fetch a URL and extract its article content — use to read promising search results or follow links
4
- - **web_research**: spawn parallel sub-agents that each run their own web_search/fetch_page cycle — call with `{"questions": ["q1", "q2", ...]}`
5
- - **report**: submit your final findings with direct quotes, data points, and source URLs from the pages you read. Include what you found AND what you checked but could not find
6
-
7
- Process:
8
- 1. Search the web with focused queries targeting specific aspects of the question.
9
- 2. Read the most promising results with fetch_page. Follow links within pages when they lead to more authoritative content.
10
- 3. After reading results, state what you've established so far and what gaps remain.
11
- 4. If clear gaps remain, call web_research again with targeted sub-questions to fill them.
12
- 5. Call report() with direct quotes, data points, and source URLs. State what you found AND what you checked but could not find. Do not summarize — preserve detail.
@@ -1,57 +0,0 @@
1
- import type { Operation } from 'effection';
2
- import { Tool } from '@lloyal-labs/lloyal-agents';
3
- import type { JsonSchema, Toolkit, ToolContext, PressureThresholds } from '@lloyal-labs/lloyal-agents';
4
- /**
5
- * Configuration for {@link ResearchTool}
6
- *
7
- * @category Rig
8
- */
9
- export interface ResearchToolOpts {
10
- /** System prompt for each spawned research agent */
11
- systemPrompt: string;
12
- /** Prompt pair used to extract findings from hard-cut agents */
13
- reporterPrompt: {
14
- system: string;
15
- user: string;
16
- };
17
- /** Maximum tool-use turns per research agent (default: 20) */
18
- maxTurns?: number;
19
- /** Enable trace logging for sub-agent pools */
20
- trace?: boolean;
21
- /** Context pressure thresholds for sub-agent pools */
22
- pressure?: PressureThresholds;
23
- }
24
- /**
25
- * Spawn parallel research agents for sub-questions (corpus source)
26
- *
27
- * Creates a {@link withSharedRoot | shared root} and runs a
28
- * {@link useAgentPool | pool} of research agents, one per question.
29
- * Each agent has access to the full toolkit (search, read_file,
30
- * grep, report). Agents that hit the turn limit without reporting
31
- * are forced through a reporter pass that extracts partial findings.
32
- *
33
- * Call {@link ResearchTool.setToolkit | setToolkit()} before first
34
- * execution to wire the toolkit into the sub-agent pool.
35
- *
36
- * @category Rig
37
- */
38
- export declare class ResearchTool extends Tool<{
39
- questions: string[];
40
- }> {
41
- readonly name = "research";
42
- readonly description = "Spawn parallel research agents to investigate sub-questions. Each question gets its own agent.";
43
- readonly parameters: JsonSchema;
44
- private _systemPrompt;
45
- private _reporterPrompt;
46
- private _maxTurns;
47
- private _trace;
48
- private _pressure?;
49
- private _toolkit;
50
- constructor(opts: ResearchToolOpts);
51
- /** Inject the toolkit that sub-agents will use. Must be called before execute. */
52
- setToolkit(toolkit: Toolkit): void;
53
- execute(args: {
54
- questions: string[];
55
- }, context?: ToolContext): Operation<unknown>;
56
- }
57
- //# sourceMappingURL=research.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"research.d.ts","sourceRoot":"","sources":["../../src/tools/research.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAmD,MAAM,4BAA4B,CAAC;AACnG,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAEvG;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,oDAAoD;IACpD,YAAY,EAAE,MAAM,CAAC;IACrB,gEAAgE;IAChE,cAAc,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IACjD,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,+CAA+C;IAC/C,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,sDAAsD;IACtD,QAAQ,CAAC,EAAE,kBAAkB,CAAC;CAC/B;AAED;;;;;;;;;;;;;GAaG;AACH,qBAAa,YAAa,SAAQ,IAAI,CAAC;IAAE,SAAS,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;IAC7D,QAAQ,CAAC,IAAI,cAAc;IAC3B,QAAQ,CAAC,WAAW,oGAAoG;IACxH,QAAQ,CAAC,UAAU,EAAE,UAAU,CAU7B;IAEF,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,eAAe,CAAmC;IAC1D,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,MAAM,CAAU;IACxB,OAAO,CAAC,SAAS,CAAC,CAAqB;IACvC,OAAO,CAAC,QAAQ,CAAwB;gBAE5B,IAAI,EAAE,gBAAgB;IASlC,kFAAkF;IAClF,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAIjC,OAAO,CAAC,IAAI,EAAE;QAAE,SAAS,EAAE,MAAM,EAAE,CAAA;KAAE,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC,OAAO,CAAC;CA+CnF"}
@@ -1,95 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ResearchTool = void 0;
4
- const lloyal_agents_1 = require("@lloyal-labs/lloyal-agents");
5
- /**
6
- * Spawn parallel research agents for sub-questions (corpus source)
7
- *
8
- * Creates a {@link withSharedRoot | shared root} and runs a
9
- * {@link useAgentPool | pool} of research agents, one per question.
10
- * Each agent has access to the full toolkit (search, read_file,
11
- * grep, report). Agents that hit the turn limit without reporting
12
- * are forced through a reporter pass that extracts partial findings.
13
- *
14
- * Call {@link ResearchTool.setToolkit | setToolkit()} before first
15
- * execution to wire the toolkit into the sub-agent pool.
16
- *
17
- * @category Rig
18
- */
19
- class ResearchTool extends lloyal_agents_1.Tool {
20
- name = 'research';
21
- description = 'Spawn parallel research agents to investigate sub-questions. Each question gets its own agent.';
22
- parameters = {
23
- type: 'object',
24
- properties: {
25
- questions: {
26
- type: 'array',
27
- items: { type: 'string' },
28
- description: 'Sub-questions to research in parallel',
29
- },
30
- },
31
- required: ['questions'],
32
- };
33
- _systemPrompt;
34
- _reporterPrompt;
35
- _maxTurns;
36
- _trace;
37
- _pressure;
38
- _toolkit = null;
39
- constructor(opts) {
40
- super();
41
- this._systemPrompt = opts.systemPrompt;
42
- this._reporterPrompt = opts.reporterPrompt;
43
- this._maxTurns = opts.maxTurns ?? 20;
44
- this._trace = opts.trace ?? false;
45
- this._pressure = opts.pressure;
46
- }
47
- /** Inject the toolkit that sub-agents will use. Must be called before execute. */
48
- setToolkit(toolkit) {
49
- this._toolkit = toolkit;
50
- }
51
- *execute(args, context) {
52
- const questions = args?.questions;
53
- if (!Array.isArray(questions) || questions.length === 0) {
54
- return { error: 'questions must be a non-empty array of strings', example: '{"questions": ["q1", "q2"]}' };
55
- }
56
- if (!this._toolkit)
57
- throw new Error('ResearchTool: setToolkit() must be called before execute');
58
- const tw = yield* lloyal_agents_1.Trace.expect();
59
- const scope = (0, lloyal_agents_1.traceScope)(tw, null, 'researchTool', { questionCount: questions.length });
60
- const toolkit = this._toolkit;
61
- const systemPrompt = this._systemPrompt;
62
- const reporterPrompt = this._reporterPrompt;
63
- const maxTurns = this._maxTurns;
64
- const trace = this._trace;
65
- const pressure = this._pressure;
66
- return yield* (0, lloyal_agents_1.withSharedRoot)({ systemPrompt, tools: toolkit.toolsJson, parent: context?.branch }, function* (root) {
67
- const pool = yield* (0, lloyal_agents_1.useAgentPool)({
68
- tasks: questions.map(q => ({
69
- systemPrompt,
70
- content: q,
71
- tools: toolkit.toolsJson,
72
- parent: root,
73
- })),
74
- tools: toolkit.toolMap,
75
- terminalTool: 'report',
76
- pruneOnReport: true,
77
- maxTurns,
78
- trace,
79
- pressure,
80
- reportPrompt: reporterPrompt,
81
- });
82
- const result = {
83
- findings: pool.agents.map(a => a.findings).filter(Boolean),
84
- supportingFindings: pool.agents.flatMap(a => a.childFindings ?? []),
85
- agentCount: pool.agents.length,
86
- totalTokens: pool.totalTokens,
87
- totalToolCalls: pool.totalToolCalls,
88
- };
89
- scope.close();
90
- return result;
91
- });
92
- }
93
- }
94
- exports.ResearchTool = ResearchTool;
95
- //# sourceMappingURL=research.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"research.js","sourceRoot":"","sources":["../../src/tools/research.ts"],"names":[],"mappings":";;;AACA,8DAAmG;AAqBnG;;;;;;;;;;;;;GAaG;AACH,MAAa,YAAa,SAAQ,oBAA6B;IACpD,IAAI,GAAG,UAAU,CAAC;IAClB,WAAW,GAAG,gGAAgG,CAAC;IAC/G,UAAU,GAAe;QAChC,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,SAAS,EAAE;gBACT,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBACzB,WAAW,EAAE,uCAAuC;aACrD;SACF;QACD,QAAQ,EAAE,CAAC,WAAW,CAAC;KACxB,CAAC;IAEM,aAAa,CAAS;IACtB,eAAe,CAAmC;IAClD,SAAS,CAAS;IAClB,MAAM,CAAU;IAChB,SAAS,CAAsB;IAC/B,QAAQ,GAAmB,IAAI,CAAC;IAExC,YAAY,IAAsB;QAChC,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,YAAY,CAAC;QACvC,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,cAAc,CAAC;QAC3C,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,QAAQ,IAAI,EAAE,CAAC;QACrC,IAAI,CAAC,MAAM,GAAG,IAAI,CA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IAAI;YACZ,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,IAAA,4BAAY,EAAC;gBAC/B,KAAK,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;oBACzB,YAAY;oBACZ,OAAO,EAAE,CAAC;oBACV,KAAK,EAAE,OAAO,CAAC,SAAS;oBACxB,MAAM,EAAE,IAAI;iBACb,CAAC,CAAC;gBACH,KAAK,EAAE,OAAO,CAAC,OAAO;gBACtB,YAAY,EAAE,QAAQ;gBACtB,aAAa,EAAE,IAAI;gBACnB,QAAQ;gBACR,KAAK;gBACL,QAAQ;gBACR,YAAY,EAAE,cAAc;aAC7B,CAAC,CAAC;YAEH,MAAM,MAAM,GAAG;gBACb,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC;gBAC1D,kBAAkB,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,aAAa,IAAI,EAAE,CAAC;gBACnE,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM;gBAC9B,WAAW,EAAE,IAAI,CAAC,WAAW;gBAC7B,cAAc,EAAE,IAAI,CAAC,cAAc;aACpC,CAAC;YACF,KAAK,CAAC,KAAK,EAAE,CAAC;YACd,OAAO,MAAM,CAAC;QAChB,CAAC,CACF,CAAC;IACJ,CAAC;CACF;AAnFD,oCAmFC"}
@@ -1,60 +0,0 @@
1
- import type { Operation } from "effection";
2
- import { Tool } from "@lloyal-labs/lloyal-agents";
3
- import type { JsonSchema, Toolkit, ToolContext, PressureThresholds } from "@lloyal-labs/lloyal-agents";
4
- /**
5
- * Configuration for {@link WebResearchTool}.
6
- *
7
- * @category Rig
8
- */
9
- export interface WebResearchToolOpts {
10
- /** Override the tool name exposed to the model. @defaultValue "research" */
11
- name?: string;
12
- /** Override the tool description exposed to the model. */
13
- description?: string;
14
- /** System prompt given to each spawned web-research sub-agent. */
15
- systemPrompt: string;
16
- /** Prompts used for grammar-constrained scratchpad extraction on hard-cut agents. */
17
- reporterPrompt: {
18
- system: string;
19
- user: string;
20
- };
21
- /** Maximum tool-use turns per sub-agent before hard cut. @defaultValue 20 */
22
- maxTurns?: number;
23
- /** Enable trace output for sub-agent execution. @defaultValue false */
24
- trace?: boolean;
25
- /** Context pressure thresholds for the sub-agent pool. */
26
- pressure?: PressureThresholds;
27
- }
28
- /**
29
- * Spawn parallel web-research sub-agents for a set of questions.
30
- *
31
- * Similar to {@link ResearchTool} but designed for web-source pipelines.
32
- * Each question gets its own agent in a shared-root pool with access
33
- * to web_search, fetch_page, and report tools. Hard-cut agents that
34
- * exhaust their turns without reporting get a grammar-constrained
35
- * scratchpad extraction via {@link generate} to recover partial findings.
36
- *
37
- * Must call {@link setToolkit} before the tool is executed.
38
- *
39
- * @category Rig
40
- */
41
- export declare class WebResearchTool extends Tool<{
42
- questions: string[];
43
- }> {
44
- readonly name: string;
45
- readonly description: string;
46
- readonly parameters: JsonSchema;
47
- private _systemPrompt;
48
- private _reporterPrompt;
49
- private _maxTurns;
50
- private _trace;
51
- private _pressure?;
52
- private _toolkit;
53
- constructor(opts: WebResearchToolOpts);
54
- /** Inject the toolkit that sub-agents will use. Must be called before execute. */
55
- setToolkit(toolkit: Toolkit): void;
56
- execute(args: {
57
- questions: string[];
58
- }, context?: ToolContext): Operation<unknown>;
59
- }
60
- //# sourceMappingURL=web-research.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"web-research.d.ts","sourceRoot":"","sources":["../../src/tools/web-research.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EACL,IAAI,EAKL,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EACV,UAAU,EACV,OAAO,EACP,WAAW,EACX,kBAAkB,EACnB,MAAM,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
4
- const lloyal_agents_1 = require("@lloyal-labs/lloyal-agents");
5
- /**
6
- * Spawn parallel web-research sub-agents for a set of questions.
7
- *
8
- * Similar to {@link ResearchTool} but designed for web-source pipelines.
9
- * Each question gets its own agent in a shared-root pool with access
10
- * to web_search, fetch_page, and report tools. Hard-cut agents that
11
- * exhaust their turns without reporting get a grammar-constrained
12
- * scratchpad extraction via {@link generate} to recover partial findings.
13
- *
14
- * Must call {@link setToolkit} before the tool is executed.
15
- *
16
- * @category Rig
17
- */
18
- class WebResearchTool extends lloyal_agents_1.Tool {
19
- name;
20
- description;
21
- parameters = {
22
- type: "object",
23
- properties: {
24
- questions: {
25
- type: "array",
26
- items: { type: "string" },
27
- description: "Sub-questions to research in parallel",
28
- },
29
- },
30
- required: ["questions"],
31
- };
32
- _systemPrompt;
33
- _reporterPrompt;
34
- _maxTurns;
35
- _trace;
36
- _pressure;
37
- _toolkit = null;
38
- constructor(opts) {
39
- super();
40
- this.name = opts.name ?? "research";
41
- this.description =
42
- opts.description ??
43
- "Spawn parallel research agents to investigate sub-questions. Each question gets its own agent.";
44
- this._systemPrompt = opts.systemPrompt;
45
- this._reporterPrompt = opts.reporterPrompt;
46
- this._maxTurns = opts.maxTurns ?? 20;
47
- this._trace = opts.trace ?? false;
48
- this._pressure = opts.pressure;
49
- }
50
- /** Inject the toolkit that sub-agents will use. Must be called before execute. */
51
- setToolkit(toolkit) {
52
- this._toolkit = toolkit;
53
- }
54
- *execute(args, context) {
55
- const questions = args?.questions;
56
- if (!Array.isArray(questions) || questions.length === 0) {
57
- return {
58
- error: "questions must be a non-empty array of strings",
59
- example: '{"questions": ["q1", "q2"]}',
60
- };
61
- }
62
- if (!this._toolkit)
63
- throw new Error("WebResearchTool: setToolkit() must be called before execute");
64
- const tw = yield* lloyal_agents_1.Trace.expect();
65
- const scope = (0, lloyal_agents_1.traceScope)(tw, null, 'webResearchTool', { questionCount: questions.length });
66
- const toolkit = this._toolkit;
67
- const systemPrompt = this._systemPrompt;
68
- const reporterPrompt = this._reporterPrompt;
69
- const maxTurns = this._maxTurns;
70
- const trace = this._trace;
71
- const pressure = this._pressure;
72
- return yield* (0, lloyal_agents_1.withSharedRoot)({ systemPrompt, tools: toolkit.toolsJson, parent: context?.branch }, function* (root) {
73
- const pool = yield* (0, lloyal_agents_1.useAgentPool)({
74
- tasks: questions.map((q) => ({
75
- systemPrompt,
76
- content: q,
77
- tools: toolkit.toolsJson,
78
- parent: root,
79
- })),
80
- tools: toolkit.toolMap,
81
- terminalTool: "report",
82
- pruneOnReport: true,
83
- maxTurns,
84
- trace,
85
- pressure,
86
- reportPrompt: reporterPrompt,
87
- });
88
- const result = {
89
- findings: pool.agents.map((a) => a.findings).filter(Boolean),
90
- supportingFindings: pool.agents.flatMap((a) => a.childFindings ?? []),
91
- agentCount: pool.agents.length,
92
- totalTokens: pool.totalTokens,
93
- totalToolCalls: pool.totalToolCalls,
94
- };
95
- scope.close();
96
- return result;
97
- });
98
- }
99
- }
100
- exports.WebResearchTool = WebResearchTool;
101
- //# sourceMappingURL=web-research.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"web-research.js","sourceRoot":"","sources":["../../src/tools/web-research.ts"],"names":[],"mappings":";;;AACA,8DAMoC;AA8BpC;;;;;;;;;;;;GAYG;AACH,MAAa,eAAgB,SAAQ,oBAA6B;IACvD,IAAI,CAAS;IACb,WAAW,CAAS;IACpB,UAAU,GAAe;QAChC,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,SAAS,EAAE;gBACT,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBACzB,WAAW,EAAE,uCAAuC;aACrD;SACF;QACD,QAAQ,EAAE,CAAC,WAAW,CAAC;KACxB,CAAC;IAEM,aAAa,CAAS;IACtB,eAAe,CAAmC;IAClD,SAAS,CAAS;IAClB,MAAM,CAAU;IAChB,SAAS,CAAsB;IAC/B,QAAQ,GAAmB,IAAI,CAAC;IAExC,YAAY,I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