@lloyal-labs/rig 2.1.0 → 3.0.1

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.
Files changed (100) hide show
  1. package/LICENSE +107 -0
  2. package/LICENSE-FAQ.md +256 -0
  3. package/README.md +93 -74
  4. package/dist/bundle.d.ts +211 -0
  5. package/dist/bundle.d.ts.map +1 -0
  6. package/dist/bundle.js +296 -0
  7. package/dist/bundle.js.map +1 -0
  8. package/dist/cancellable-fetch.d.ts +98 -0
  9. package/dist/cancellable-fetch.d.ts.map +1 -0
  10. package/dist/cancellable-fetch.js +133 -0
  11. package/dist/cancellable-fetch.js.map +1 -0
  12. package/dist/config-store.d.ts +30 -0
  13. package/dist/config-store.d.ts.map +1 -0
  14. package/dist/config-store.js +45 -0
  15. package/dist/config-store.js.map +1 -0
  16. package/dist/define-app.d.ts +98 -0
  17. package/dist/define-app.d.ts.map +1 -0
  18. package/dist/define-app.js +232 -0
  19. package/dist/define-app.js.map +1 -0
  20. package/dist/grant-store.d.ts +31 -0
  21. package/dist/grant-store.d.ts.map +1 -0
  22. package/dist/grant-store.js +49 -0
  23. package/dist/grant-store.js.map +1 -0
  24. package/dist/index.d.ts +13 -6
  25. package/dist/index.d.ts.map +1 -1
  26. package/dist/index.js +37 -11
  27. package/dist/index.js.map +1 -1
  28. package/dist/node.d.ts +3 -2
  29. package/dist/node.d.ts.map +1 -1
  30. package/dist/node.js +3 -2
  31. package/dist/node.js.map +1 -1
  32. package/dist/protocol.d.ts +155 -0
  33. package/dist/protocol.d.ts.map +1 -0
  34. package/dist/protocol.js +184 -0
  35. package/dist/protocol.js.map +1 -0
  36. package/dist/registry.d.ts +87 -0
  37. package/dist/registry.d.ts.map +1 -0
  38. package/dist/registry.js +245 -0
  39. package/dist/registry.js.map +1 -0
  40. package/dist/reranker.d.ts +25 -7
  41. package/dist/reranker.d.ts.map +1 -1
  42. package/dist/reranker.js +103 -63
  43. package/dist/reranker.js.map +1 -1
  44. package/dist/resources/types.d.ts +10 -37
  45. package/dist/resources/types.d.ts.map +1 -1
  46. package/dist/resources/types.js +12 -0
  47. package/dist/resources/types.js.map +1 -1
  48. package/dist/spine-render.d.ts +97 -0
  49. package/dist/spine-render.d.ts.map +1 -0
  50. package/dist/spine-render.js +121 -0
  51. package/dist/spine-render.js.map +1 -0
  52. package/dist/tools/index.d.ts +26 -22
  53. package/dist/tools/index.d.ts.map +1 -1
  54. package/dist/tools/index.js +24 -28
  55. package/dist/tools/index.js.map +1 -1
  56. package/dist/tools/keyless-search.d.ts +67 -0
  57. package/dist/tools/keyless-search.d.ts.map +1 -0
  58. package/dist/tools/keyless-search.js +401 -0
  59. package/dist/tools/keyless-search.js.map +1 -0
  60. package/dist/tools/plan.d.ts +31 -4
  61. package/dist/tools/plan.d.ts.map +1 -1
  62. package/dist/tools/plan.js +46 -11
  63. package/dist/tools/plan.js.map +1 -1
  64. package/dist/tools/types.d.ts +12 -56
  65. package/dist/tools/types.d.ts.map +1 -1
  66. package/dist/tools/types.js +17 -0
  67. package/dist/tools/types.js.map +1 -1
  68. package/dist/tools/web-search.d.ts +9 -25
  69. package/dist/tools/web-search.d.ts.map +1 -1
  70. package/dist/tools/web-search.js +11 -119
  71. package/dist/tools/web-search.js.map +1 -1
  72. package/package.json +10 -7
  73. package/dist/sources/corpus.d.ts +0 -80
  74. package/dist/sources/corpus.d.ts.map +0 -1
  75. package/dist/sources/corpus.js +0 -100
  76. package/dist/sources/corpus.js.map +0 -1
  77. package/dist/sources/index.d.ts +0 -12
  78. package/dist/sources/index.d.ts.map +0 -1
  79. package/dist/sources/index.js +0 -14
  80. package/dist/sources/index.js.map +0 -1
  81. package/dist/sources/web.d.ts +0 -67
  82. package/dist/sources/web.d.ts.map +0 -1
  83. package/dist/sources/web.js +0 -104
  84. package/dist/sources/web.js.map +0 -1
  85. package/dist/tools/fetch-page.d.ts +0 -48
  86. package/dist/tools/fetch-page.d.ts.map +0 -1
  87. package/dist/tools/fetch-page.js +0 -309
  88. package/dist/tools/fetch-page.js.map +0 -1
  89. package/dist/tools/grep.d.ts +0 -35
  90. package/dist/tools/grep.d.ts.map +0 -1
  91. package/dist/tools/grep.js +0 -84
  92. package/dist/tools/grep.js.map +0 -1
  93. package/dist/tools/read-file.d.ts +0 -74
  94. package/dist/tools/read-file.d.ts.map +0 -1
  95. package/dist/tools/read-file.js +0 -192
  96. package/dist/tools/read-file.js.map +0 -1
  97. package/dist/tools/search.d.ts +0 -34
  98. package/dist/tools/search.d.ts.map +0 -1
  99. package/dist/tools/search.js +0 -101
  100. package/dist/tools/search.js.map +0 -1
@@ -1,65 +1,21 @@
1
- import type { Chunk } from '../resources/types';
2
1
  /**
3
- * A single chunk scored by the {@link Reranker} against a query
2
+ * Rig-resident tool adapter types.
4
3
  *
5
- * Returned as part of {@link ScoredResult} from reranker scoring.
6
- * Contains the file location, heading, relevance score, and line
7
- * range so downstream tools (e.g. {@link ReadFileTool}) can fetch
8
- * the exact content.
4
+ * The reranker abstraction (`Reranker`, `ScoredResult`, `ScoredChunk`)
5
+ * moved to `@lloyal-labs/lloyal-agents` alongside `Chunk`
6
+ * and `Resource` abstract types live in agents, concrete factories
7
+ * (`createReranker`) and chunking utilities (`chunkResources`,
8
+ * `chunkHtml`, `chunkFetchedPages`) stay in rig. Re-exported here for
9
+ * rig-internal callers; new code should import from
10
+ * `@lloyal-labs/lloyal-agents`.
9
11
  *
10
- * @category Rig
11
- */
12
- export interface ScoredChunk {
13
- /** Source filename containing the chunk */
14
- file: string;
15
- /** Leaf section heading (e.g. "Recovery loop") */
16
- heading: string;
17
- /** Hierarchical section path (e.g. "Agents > Lifecycle > Recovery loop"). Empty for web chunks. */
18
- section: string;
19
- /** First ~200 chars of chunk text — gives agents content at search time */
20
- snippet: string;
21
- /** Relevance score (higher = more relevant) */
22
- score: number;
23
- /** Start line in the source file (1-indexed) */
24
- startLine: number;
25
- /** End line in the source file (1-indexed) */
26
- endLine: number;
27
- }
28
- /**
29
- * Progressive reranker output emitted during scoring
30
- *
31
- * Streamed from {@link Reranker.score} as an async iterable,
32
- * allowing callers to report progress while scoring is in flight.
12
+ * `SearchProvider` + `SearchResult` are HTTP-adapter shapes used only
13
+ * by rig's keyless / Tavily provider; they stay rig-resident.
33
14
  *
15
+ * @packageDocumentation
34
16
  * @category Rig
35
17
  */
36
- export interface ScoredResult {
37
- /** Scored chunks accumulated so far, ordered by relevance */
38
- results: ScoredChunk[];
39
- /** Number of chunks scored so far */
40
- filled: number;
41
- /** Total number of chunks to score */
42
- total: number;
43
- }
44
- /**
45
- * Embedding-based reranker for scoring corpus chunks against a query
46
- *
47
- * Implementations tokenize chunks up front via {@link tokenizeChunks},
48
- * then stream progressive results from {@link score}. Used by
49
- * {@link SearchTool} to rank knowledge-base passages.
50
- *
51
- * @category Rig
52
- */
53
- export interface Reranker {
54
- /** Score chunks against a query, streaming progressive results */
55
- score(query: string, chunks: Chunk[]): AsyncIterable<ScoredResult>;
56
- /** Score raw text strings against a query in one batch. Returns scores (0–1) in input order. */
57
- scoreBatch(query: string, texts: string[]): Promise<number[]>;
58
- /** Pre-tokenize chunks for subsequent scoring calls */
59
- tokenizeChunks(chunks: Chunk[]): Promise<void>;
60
- /** Release reranker resources */
61
- dispose(): void;
62
- }
18
+ export type { Reranker, ScoredChunk, ScoredResult } from '@lloyal-labs/lloyal-agents';
63
19
  /**
64
20
  * A single result from a {@link SearchProvider} web search
65
21
  *
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/tools/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAEhD;;;;;;;;;GASG;AACH,MAAM,WAAW,WAAW;IAC1B,2CAA2C;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,kDAAkD;IAClD,OAAO,EAAE,MAAM,CAAC;IAChB,mGAAmG;IACnG,OAAO,EAAE,MAAM,CAAC;IAChB,2EAA2E;IAC3E,OAAO,EAAE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,CAAC,0BAA0B,EAAE,OAAO,CAAC;CAC9C"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/tools/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,YAAY,EAAE,QAAQ,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAItF;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B,iBAAiB;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,eAAe;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,+CAA+C;IAC/C,OAAO,EAAE,MAAM,CAAC;IAChB,mFAAmF;IACnF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,6DAA6D;IAC7D,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,cAAc;IAC7B,qDAAqD;IACrD,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAAC;IACnE,8GAA8G;IAC9G,QAAQ,CAAC,0BAA0B,EAAE,OAAO,CAAC;CAC9C"}
@@ -1,3 +1,20 @@
1
1
  "use strict";
2
+ /**
3
+ * Rig-resident tool adapter types.
4
+ *
5
+ * The reranker abstraction (`Reranker`, `ScoredResult`, `ScoredChunk`)
6
+ * moved to `@lloyal-labs/lloyal-agents` alongside `Chunk`
7
+ * and `Resource` — abstract types live in agents, concrete factories
8
+ * (`createReranker`) and chunking utilities (`chunkResources`,
9
+ * `chunkHtml`, `chunkFetchedPages`) stay in rig. Re-exported here for
10
+ * rig-internal callers; new code should import from
11
+ * `@lloyal-labs/lloyal-agents`.
12
+ *
13
+ * `SearchProvider` + `SearchResult` are HTTP-adapter shapes used only
14
+ * by rig's keyless / Tavily provider; they stay rig-resident.
15
+ *
16
+ * @packageDocumentation
17
+ * @category Rig
18
+ */
2
19
  Object.defineProperty(exports, "__esModule", { value: true });
3
20
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/tools/types.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/tools/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG"}
@@ -1,6 +1,12 @@
1
- import type { Operation } from "effection";
2
- import { Tool } from "@lloyal-labs/lloyal-agents";
3
- import type { JsonSchema, ToolContext } from "@lloyal-labs/lloyal-agents";
1
+ /**
2
+ * Tavily search provider — a {@link SearchProvider} implementation
3
+ * consumed by the `lloyal/web` app's `web_search` tool.
4
+ *
5
+ * The provider is split from the tool: the tool class lives in
6
+ * `@lloyal-labs/web-app` (the App protocol's unit of distribution);
7
+ * this provider stays in rig so apps can swap providers without
8
+ * vendoring the API client.
9
+ */
4
10
  import type { SearchProvider, SearchResult } from "./types";
5
11
  export type { SearchProvider, SearchResult };
6
12
  /**
@@ -21,26 +27,4 @@ export declare class TavilyProvider implements SearchProvider {
21
27
  });
22
28
  search(query: string, maxResults: number): Promise<SearchResult[]>;
23
29
  }
24
- /**
25
- * Web search tool backed by a pluggable {@link SearchProvider}.
26
- *
27
- * Delegates to the provider's `search` method and returns an array
28
- * of {@link SearchResult} objects. Use alongside {@link FetchPageTool}
29
- * to let agents read full page content from promising results.
30
- *
31
- * @category Rig
32
- */
33
- export declare class WebSearchTool extends Tool<{
34
- query: string;
35
- }> {
36
- readonly name = "web_search";
37
- readonly description = "Search the web. Returns results with titles, snippets, and URLs.";
38
- readonly parameters: JsonSchema;
39
- private _provider;
40
- private _topN;
41
- constructor(provider: SearchProvider, topN?: number);
42
- execute(args: {
43
- query: string;
44
- }, context?: ToolContext): Operation<unknown>;
45
- }
46
30
  //# sourceMappingURL=web-search.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"web-search.d.ts","sourceRoot":"","sources":["../../src/tools/web-search.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAA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AS,CAAC;AAE5D,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,CAAC;AAE7C;;;;;;;;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;CAyBzE"}
@@ -1,9 +1,15 @@
1
1
  "use strict";
2
+ /**
3
+ * Tavily search provider — a {@link SearchProvider} implementation
4
+ * consumed by the `lloyal/web` app's `web_search` tool.
5
+ *
6
+ * The provider is split from the tool: the tool class lives in
7
+ * `@lloyal-labs/web-app` (the App protocol's unit of distribution);
8
+ * this provider stays in rig so apps can swap providers without
9
+ * vendoring the API client.
10
+ */
2
11
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WebSearchTool = exports.TavilyProvider = void 0;
4
- const effection_1 = require("effection");
5
- const lloyal_agents_1 = require("@lloyal-labs/lloyal-agents");
6
- // ── Tavily provider (default) ───────────────────────────
12
+ exports.TavilyProvider = void 0;
7
13
  /**
8
14
  * {@link SearchProvider} implementation backed by the Tavily search API.
9
15
  *
@@ -40,125 +46,11 @@ class TavilyProvider {
40
46
  title: r.title,
41
47
  url: r.url,
42
48
  snippet: r.content.length > max
43
- ? r.content.slice(0, max) + " [\u2026]"
49
+ ? r.content.slice(0, max) + " []"
44
50
  : r.content,
45
51
  score: r.score,
46
52
  }));
47
53
  }
48
54
  }
49
55
  exports.TavilyProvider = TavilyProvider;
50
- // ── WebSearchTool ───────────────────────────────────────
51
- /**
52
- * Web search tool backed by a pluggable {@link SearchProvider}.
53
- *
54
- * Delegates to the provider's `search` method and returns an array
55
- * of {@link SearchResult} objects. Use alongside {@link FetchPageTool}
56
- * to let agents read full page content from promising results.
57
- *
58
- * @category Rig
59
- */
60
- class WebSearchTool extends lloyal_agents_1.Tool {
61
- name = "web_search";
62
- description = "Search the web. Returns results with titles, snippets, and URLs.";
63
- parameters = {
64
- type: "object",
65
- properties: { query: { type: "string", description: "Search query" } },
66
- required: ["query"],
67
- };
68
- _provider;
69
- _topN;
70
- constructor(provider, topN = 8) {
71
- super();
72
- this._provider = provider;
73
- this._topN = topN;
74
- }
75
- *execute(args, context) {
76
- const query = args.query?.trim();
77
- if (!query)
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
- }
94
- const provider = this._provider;
95
- const topN = this._topN;
96
- let results;
97
- try {
98
- results = yield* (0, effection_1.call)(() => provider.search(query, topN));
99
- }
100
- catch (err) {
101
- return { error: `Search failed: ${err.message}` };
102
- }
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.
113
- const scorer = context?.scorer;
114
- if (!context?.explore && scorer && results.length > 1) {
115
- const snippets = results.map((r) => `${r.title}. ${r.snippet}`);
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]);
120
- let tw;
121
- try {
122
- tw = yield* lloyal_agents_1.Trace.expect();
123
- }
124
- catch {
125
- /* no trace */
126
- }
127
- if (tw) {
128
- tw.write({
129
- traceId: tw.nextId(),
130
- parentTraceId: null,
131
- ts: performance.now(),
132
- type: "entailment:search",
133
- tool: "web_search",
134
- query,
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
- })),
143
- });
144
- }
145
- results = results
146
- .map((r, i) => ({ result: r, score: combined[i] }))
147
- .sort((a, b) => b.score - a.score)
148
- .map((entry) => entry.result);
149
- if (tw) {
150
- tw.write({
151
- traceId: tw.nextId(),
152
- parentTraceId: null,
153
- ts: performance.now(),
154
- type: "entailment:search:reordered",
155
- tool: "web_search",
156
- after: results.map((r) => ({ title: r.title, url: r.url })),
157
- });
158
- }
159
- }
160
- return results;
161
- }
162
- }
163
- exports.WebSearchTool = WebSearchTool;
164
56
  //# sourceMappingURL=web-search.js.map
@@ -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,I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AM,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAE7B,CAAC;QACF,MAAM,GAAG,GAAG,IAAI,CAAC,iBAAiB,CAAC;QACnC,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YAC9B,KAAK,EAAE,CAAC,CAAC,KAAK;YACd,GAAG,EAAE,CAAC,CAAC,GAAG;YACV,OAAO,EACL,CAAC,CAAC,OAAO,CAAC,MAAM,GAAG,GAAG;gBACpB,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,MAAM;gBAClC,CAAC,CAAC,CAAC,CAAC,OAAO;YACf,KAAK,EAAE,CAAC,CAAC,KAAK;SACf,CAAC,CAAC,CAAC;IACN,CAAC;CACF;AAnCD,wCAmCC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lloyal-labs/rig",
3
- "version": "2.1.0",
3
+ "version": "3.0.1",
4
4
  "description": "Retrieval-Interleaved Generation for lloyal-agents",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -34,23 +34,26 @@
34
34
  "agents",
35
35
  "tools"
36
36
  ],
37
- "license": "Apache-2.0",
37
+ "license": "SEE LICENSE IN LICENSE",
38
38
  "type": "commonjs",
39
39
  "scripts": {
40
40
  "build": "tsc -b"
41
41
  },
42
42
  "dependencies": {
43
- "@lloyal-labs/lloyal-agents": "^2.1.0",
44
- "@lloyal-labs/sdk": "^2.1.0",
43
+ "@lloyal-labs/lloyal-agents": "^3.0.0",
44
+ "@lloyal-labs/sdk": "^3.0.0",
45
45
  "@mozilla/readability": "^0.6.0",
46
46
  "effection": "^4.0.2",
47
47
  "ignore": "^7.0.5",
48
- "linkedom": "^0.18.12"
48
+ "linkedom": "^0.18.12",
49
+ "semver": "^7.8.1"
49
50
  },
50
51
  "peerDependencies": {
51
- "@lloyal-labs/lloyal.node": "^2.1.0"
52
+ "@lloyal-labs/lloyal.node": "^3.0.0"
52
53
  },
53
54
  "files": [
54
- "dist/"
55
+ "dist/",
56
+ "LICENSE",
57
+ "LICENSE-FAQ.md"
55
58
  ]
56
59
  }
@@ -1,80 +0,0 @@
1
- import type { Operation } from "effection";
2
- import { Source } from "@lloyal-labs/lloyal-agents";
3
- import type { Tool } from "@lloyal-labs/lloyal-agents";
4
- import type { Resource, Chunk } from "../resources/types";
5
- import type { Reranker } from "../tools/types";
6
- /** Data for rendering the corpus-research Eta template */
7
- export interface CorpusPromptData {
8
- toc: string;
9
- }
10
- /**
11
- * Configuration for {@link CorpusSource}.
12
- *
13
- * @category Rig
14
- */
15
- export interface CorpusSourceOpts {
16
- /** GrepTool configuration */
17
- grep?: {
18
- /** Max matches returned. @default 50 */
19
- maxResults?: number;
20
- /** Max chars per matched line. @default 200 */
21
- lineMaxChars?: number;
22
- };
23
- /** ReadFileTool configuration */
24
- readFile?: {
25
- /** Default max lines when no range specified. @default 100 */
26
- defaultMaxLines?: number;
27
- };
28
- }
29
- /**
30
- * Corpus-backed data source using local file search, read, and grep
31
- *
32
- * Provides three tools: semantic search (via reranker), file reading,
33
- * and regex grep. On {@link bind}, tokenizes chunks through the reranker
34
- * and prepends a reranker-backed search tool.
35
- *
36
- * System prompt data is provided via {@link promptData}: the reranker
37
- * scores the task against chunk section paths to find semantically
38
- * relevant starting points. The harness renders this data into an
39
- * Eta template (same pattern as synthesize.eta).
40
- *
41
- * @category Rig
42
- */
43
- export declare class CorpusSource extends Source<{
44
- reranker: Reranker;
45
- }, Chunk> {
46
- private _chunks;
47
- private _tools;
48
- private _bound;
49
- /** @inheritDoc */
50
- readonly name = "corpus";
51
- /**
52
- * @param resources - Loaded file resources for read_file and grep tools
53
- * @param chunks - Pre-split chunks for reranker-backed search
54
- * @param opts - Configuration for grep and read_file tools
55
- */
56
- constructor(resources: Resource[], chunks: Chunk[], opts?: CorpusSourceOpts);
57
- /** @inheritDoc */
58
- get tools(): Tool[];
59
- /**
60
- * Provide data for rendering the corpus-research Eta template.
61
- *
62
- * Returns the TOC (structural orientation). The harness renders
63
- * this into its corpus-research.eta template (same pattern as
64
- * synthesize.eta). Agents discover relevant content through their
65
- * tools (search snippets, read_file relatedSections), not through
66
- * pre-scored suggestions in the prompt.
67
- */
68
- promptData(): CorpusPromptData;
69
- /** Build table of contents from chunk index: file → top-level headings */
70
- private _buildToc;
71
- /**
72
- * Late-bind reranker: tokenize chunks and prepend SearchTool.
73
- * Idempotent — skips if already bound.
74
- * @inheritDoc
75
- */
76
- bind(ctx: {
77
- reranker: Reranker;
78
- }): Operation<void>;
79
- }
80
- //# sourceMappingURL=corpus.d.ts.map
@@ -1 +0,0 @@
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,0DAA0D;AAC1D,MAAM,WAAW,gBAAgB;IAC/B,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;;;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;;;;;;;;;;;;;GAaG;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;;;;;;;;OAQG;IACH,UAAU,IAAI,gBAAgB;IAI9B,0EAA0E;IAC1E,OAAO,CAAC,SAAS;IAwBjB;;;;OAIG;IACF,IAAI,CAAC,GAAG,EAAE;QAAE,QAAQ,EAAE,QAAQ,CAAA;KAAE,GAAG,SAAS,CAAC,IAAI,CAAC;CAUpD"}
@@ -1,100 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CorpusSource = void 0;
4
- const effection_1 = require("effection");
5
- const lloyal_agents_1 = require("@lloyal-labs/lloyal-agents");
6
- const search_1 = require("../tools/search");
7
- const read_file_1 = require("../tools/read-file");
8
- const grep_1 = require("../tools/grep");
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
- * System prompt data is provided via {@link promptData}: the reranker
17
- * scores the task against chunk section paths to find semantically
18
- * relevant starting points. The harness renders this data into an
19
- * Eta template (same pattern as synthesize.eta).
20
- *
21
- * @category Rig
22
- */
23
- class CorpusSource extends lloyal_agents_1.Source {
24
- _chunks;
25
- _tools;
26
- _bound = false;
27
- /** @inheritDoc */
28
- name = "corpus";
29
- /**
30
- * @param resources - Loaded file resources for read_file and grep tools
31
- * @param chunks - Pre-split chunks for reranker-backed search
32
- * @param opts - Configuration for grep and read_file tools
33
- */
34
- constructor(resources, chunks, opts) {
35
- super();
36
- this._chunks = chunks;
37
- this._tools = [
38
- new read_file_1.ReadFileTool(resources, { ...opts?.readFile, chunks }),
39
- new grep_1.GrepTool(resources, opts?.grep),
40
- ];
41
- }
42
- /** @inheritDoc */
43
- get tools() { return this._tools; }
44
- /**
45
- * Provide data for rendering the corpus-research Eta template.
46
- *
47
- * Returns the TOC (structural orientation). The harness renders
48
- * this into its corpus-research.eta template (same pattern as
49
- * synthesize.eta). Agents discover relevant content through their
50
- * tools (search snippets, read_file relatedSections), not through
51
- * pre-scored suggestions in the prompt.
52
- */
53
- promptData() {
54
- return { toc: this._buildToc() };
55
- }
56
- /** Build table of contents from chunk index: file → top-level headings */
57
- _buildToc() {
58
- const byFile = new Map();
59
- for (const c of this._chunks) {
60
- if (!c.section)
61
- continue;
62
- const isTopLevel = !c.section.includes(' > ');
63
- if (!isTopLevel)
64
- continue;
65
- const topics = byFile.get(c.resource) ?? [];
66
- if (!topics.includes(c.heading))
67
- topics.push(c.heading);
68
- byFile.set(c.resource, topics);
69
- }
70
- for (const c of this._chunks) {
71
- if (!byFile.has(c.resource))
72
- byFile.set(c.resource, []);
73
- }
74
- const lines = [];
75
- for (const [file, topics] of byFile) {
76
- lines.push(topics.length > 0
77
- ? `${file} (topics: ${topics.join(', ')})`
78
- : file);
79
- }
80
- return lines.join('\n');
81
- }
82
- /**
83
- * Late-bind reranker: tokenize chunks and prepend SearchTool.
84
- * Idempotent — skips if already bound.
85
- * @inheritDoc
86
- */
87
- *bind(ctx) {
88
- if (this._bound)
89
- return;
90
- this._reranker = ctx.reranker;
91
- const tw = yield* lloyal_agents_1.Trace.expect();
92
- tw.write({ traceId: tw.nextId(), parentTraceId: null, ts: performance.now(),
93
- type: 'source:bind', sourceName: this.name });
94
- yield* (0, effection_1.call)(() => ctx.reranker.tokenizeChunks(this._chunks));
95
- this._tools.unshift(new search_1.SearchTool(this._chunks, ctx.reranker));
96
- this._bound = true;
97
- }
98
- }
99
- exports.CorpusSource = CorpusSource;
100
- //# sourceMappingURL=corpus.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"corpus.js","sourceRoot":"","sources":["../../src/sources/corpus.ts"],"names":[],"mappings":";;;AAAA,yCAAiC;AAEjC,8DAA2D;AAI3D,4CAA6C;AAC7C,kDAAkD;AAClD,wCAAyC;AA2BzC;;;;;;;;;;;;;GAaG;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,EAAE,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;YAC1D,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;;;;;;;;OAQG;IACH,UAAU;QACR,OAAO,EAAE,GAAG,EAAE,IAAI,CAAC,SAAS,EAAE,EAAE,CAAC;IACnC,CAAC;IAED,0EAA0E;IAClE,SAAS;QACf,MAAM,MAAM,GAAG,IAAI,GAAG,EAAoB,CAAC;QAC3C,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YAC7B,IAAI,CAAC,CAAC,CAAC,OAAO;gBAAE,SAAS;YACzB,MAAM,UAAU,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA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,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;AA9ED,oCA8EC"}
@@ -1,12 +0,0 @@
1
- /**
2
- * Source implementations — data backends for agent pipelines
3
- *
4
- * @packageDocumentation
5
- * @category Rig
6
- */
7
- export { WebSource } from './web';
8
- export type { WebSourceOpts } from './web';
9
- export { CorpusSource } from './corpus';
10
- export type { CorpusSourceOpts } from './corpus';
11
- export type { SourceContext } from './types';
12
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
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"}
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CorpusSource = exports.WebSource = void 0;
4
- /**
5
- * Source implementations — data backends for agent pipelines
6
- *
7
- * @packageDocumentation
8
- * @category Rig
9
- */
10
- var web_1 = require("./web");
11
- Object.defineProperty(exports, "WebSource", { enumerable: true, get: function () { return web_1.WebSource; } });
12
- var corpus_1 = require("./corpus");
13
- Object.defineProperty(exports, "CorpusSource", { enumerable: true, get: function () { return corpus_1.CorpusSource; } });
14
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
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"}