@lloyal-labs/rig 2.0.1 → 3.0.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/LICENSE +107 -0
- package/LICENSE-FAQ.md +256 -0
- package/README.md +78 -72
- package/dist/bundle.d.ts +211 -0
- package/dist/bundle.d.ts.map +1 -0
- package/dist/bundle.js +296 -0
- package/dist/bundle.js.map +1 -0
- package/dist/cancellable-fetch.d.ts +98 -0
- package/dist/cancellable-fetch.d.ts.map +1 -0
- package/dist/cancellable-fetch.js +133 -0
- package/dist/cancellable-fetch.js.map +1 -0
- package/dist/config-store.d.ts +30 -0
- package/dist/config-store.d.ts.map +1 -0
- package/dist/config-store.js +45 -0
- package/dist/config-store.js.map +1 -0
- package/dist/define-app.d.ts +98 -0
- package/dist/define-app.d.ts.map +1 -0
- package/dist/define-app.js +232 -0
- package/dist/define-app.js.map +1 -0
- package/dist/grant-store.d.ts +31 -0
- package/dist/grant-store.d.ts.map +1 -0
- package/dist/grant-store.js +49 -0
- package/dist/grant-store.js.map +1 -0
- package/dist/index.d.ts +13 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +37 -11
- 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 +3 -2
- package/dist/node.js.map +1 -1
- package/dist/protocol.d.ts +155 -0
- package/dist/protocol.d.ts.map +1 -0
- package/dist/protocol.js +184 -0
- package/dist/protocol.js.map +1 -0
- package/dist/registry.d.ts +87 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +245 -0
- package/dist/registry.js.map +1 -0
- package/dist/reranker.d.ts +25 -7
- package/dist/reranker.d.ts.map +1 -1
- package/dist/reranker.js +103 -63
- package/dist/reranker.js.map +1 -1
- package/dist/resources/types.d.ts +10 -37
- package/dist/resources/types.d.ts.map +1 -1
- package/dist/resources/types.js +12 -0
- package/dist/resources/types.js.map +1 -1
- package/dist/spine-render.d.ts +97 -0
- package/dist/spine-render.d.ts.map +1 -0
- package/dist/spine-render.js +121 -0
- package/dist/spine-render.js.map +1 -0
- package/dist/tools/delegate.js +1 -1
- package/dist/tools/index.d.ts +26 -22
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +24 -28
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/keyless-search.d.ts +67 -0
- package/dist/tools/keyless-search.d.ts.map +1 -0
- package/dist/tools/keyless-search.js +401 -0
- package/dist/tools/keyless-search.js.map +1 -0
- package/dist/tools/plan.d.ts +31 -4
- package/dist/tools/plan.d.ts.map +1 -1
- package/dist/tools/plan.js +46 -11
- package/dist/tools/plan.js.map +1 -1
- package/dist/tools/report.d.ts +4 -3
- package/dist/tools/report.d.ts.map +1 -1
- package/dist/tools/report.js +4 -3
- package/dist/tools/report.js.map +1 -1
- package/dist/tools/types.d.ts +12 -56
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/tools/types.js +17 -0
- package/dist/tools/types.js.map +1 -1
- package/dist/tools/web-search.d.ts +9 -25
- package/dist/tools/web-search.d.ts.map +1 -1
- package/dist/tools/web-search.js +11 -119
- package/dist/tools/web-search.js.map +1 -1
- package/package.json +9 -6
- package/dist/sources/corpus.d.ts +0 -80
- package/dist/sources/corpus.d.ts.map +0 -1
- package/dist/sources/corpus.js +0 -100
- package/dist/sources/corpus.js.map +0 -1
- package/dist/sources/index.d.ts +0 -12
- package/dist/sources/index.d.ts.map +0 -1
- package/dist/sources/index.js +0 -14
- package/dist/sources/index.js.map +0 -1
- package/dist/sources/web.d.ts +0 -67
- package/dist/sources/web.d.ts.map +0 -1
- package/dist/sources/web.js +0 -104
- package/dist/sources/web.js.map +0 -1
- package/dist/tools/fetch-page.d.ts +0 -48
- package/dist/tools/fetch-page.d.ts.map +0 -1
- package/dist/tools/fetch-page.js +0 -309
- package/dist/tools/fetch-page.js.map +0 -1
- package/dist/tools/grep.d.ts +0 -35
- package/dist/tools/grep.d.ts.map +0 -1
- package/dist/tools/grep.js +0 -84
- package/dist/tools/grep.js.map +0 -1
- package/dist/tools/read-file.d.ts +0 -74
- package/dist/tools/read-file.d.ts.map +0 -1
- package/dist/tools/read-file.js +0 -192
- package/dist/tools/read-file.js.map +0 -1
- package/dist/tools/search.d.ts +0 -34
- package/dist/tools/search.d.ts.map +0 -1
- package/dist/tools/search.js +0 -101
- package/dist/tools/search.js.map +0 -1
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Spine + per-spawn preamble assembly.
|
|
3
|
+
*
|
|
4
|
+
* Two pure render functions. Both pull bytes from `protocol.ts`
|
|
5
|
+
* constants rather than inlining literals — the codified protocol
|
|
6
|
+
* has exactly one source of truth.
|
|
7
|
+
*
|
|
8
|
+
* ## `renderSpine`
|
|
9
|
+
*
|
|
10
|
+
* Assembles the Level-1 shared-prefix system prompt. **Carries no
|
|
11
|
+
* free-form prose surface**: framework-owned literal strings +
|
|
12
|
+
* grammar-sanitized app catalog metadata. No `supplementaryContent`
|
|
13
|
+
* parameter, no per-app prose argument.
|
|
14
|
+
*
|
|
15
|
+
* Output structure:
|
|
16
|
+
*
|
|
17
|
+
* ```
|
|
18
|
+
* <FRAMEWORK_INTRO>
|
|
19
|
+
*
|
|
20
|
+
* # Protocols
|
|
21
|
+
*
|
|
22
|
+
* <CATALOG_ENTRY for each app, in registration order>
|
|
23
|
+
*
|
|
24
|
+
* <TOOL_SELECTION_RULE>
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* App `examples.eta` content goes through `renderAgentPreamble` into
|
|
28
|
+
* per-spawn preambles, never into this output.
|
|
29
|
+
*
|
|
30
|
+
* ## `renderAgentPreamble`
|
|
31
|
+
*
|
|
32
|
+
* The *only* place the framework emits the boundary marker.
|
|
33
|
+
* Called once per spawn with the assigned app's templates only — no
|
|
34
|
+
* other app's `skill.eta` / `examples.eta` enters this rendering, which
|
|
35
|
+
* is what makes per-spawn isolation a framework invariant rather than
|
|
36
|
+
* a convention.
|
|
37
|
+
*
|
|
38
|
+
* @packageDocumentation
|
|
39
|
+
* @category Protocol
|
|
40
|
+
*/
|
|
41
|
+
import type { App, AgentRenderCtx } from '@lloyal-labs/lloyal-agents';
|
|
42
|
+
/**
|
|
43
|
+
* Arguments for {@link renderSpine}. `apps` order is observable to
|
|
44
|
+
* the model — catalog entries emit in registration order; harness
|
|
45
|
+
* registration order is the input order here.
|
|
46
|
+
*/
|
|
47
|
+
export interface RenderSpineOptions {
|
|
48
|
+
/**
|
|
49
|
+
* Registered apps to compose into the catalog. Pass
|
|
50
|
+
* `registry.enabled()` from {@link AppRegistryCtx}, or any
|
|
51
|
+
* subset/ordering the harness wants reflected in the spine.
|
|
52
|
+
*/
|
|
53
|
+
apps: readonly App[];
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Render the shared-spine system prompt.
|
|
57
|
+
*
|
|
58
|
+
* The output has a fixed shape across pool sizes and pool composition
|
|
59
|
+
* — the only variability is the per-app catalog block, sourced from
|
|
60
|
+
* each app's `manifest.protocol`. No app prose; no harness prose.
|
|
61
|
+
*
|
|
62
|
+
* The returned string is intended for `SpineOptions.systemPrompt` in
|
|
63
|
+
* `withSpine(...)`; tool schemas pass through `SpineOptions.tools =
|
|
64
|
+
* apps.flatMap(a => a.tools)` separately and are decoded into KV at
|
|
65
|
+
* spine prefill.
|
|
66
|
+
*/
|
|
67
|
+
export declare function renderSpine(opts: RenderSpineOptions): string;
|
|
68
|
+
/**
|
|
69
|
+
* Render the per-spawn preamble for a single agent assigned to
|
|
70
|
+
* `app`. The framework calls this when constructing a spawn's
|
|
71
|
+
* user-role message; the output is the *only* place the boundary
|
|
72
|
+
* marker bytes appear at runtime.
|
|
73
|
+
*
|
|
74
|
+
* Output:
|
|
75
|
+
*
|
|
76
|
+
* ```
|
|
77
|
+
* <BOUNDARY_MARKER(app.manifest.protocol.name)>
|
|
78
|
+
* <renderTemplate(app.skill, params)>
|
|
79
|
+
*
|
|
80
|
+
* <renderTemplate(app.examples, examplesParams)> // if app.examples is defined
|
|
81
|
+
* ```
|
|
82
|
+
*
|
|
83
|
+
* `app.manifest.protocol.name` is grammar-restricted at `defineApp`
|
|
84
|
+
* time: matches `[a-z][a-z0-9_-]{1,63}`, so it cannot
|
|
85
|
+
* break the markdown bold or inject newlines into the marker bytes.
|
|
86
|
+
*
|
|
87
|
+
* `app.examples` (if present) receives an extended render context
|
|
88
|
+
* carrying the protocol `name` and `tools[]` in addition to the
|
|
89
|
+
* standard {@link AgentRenderCtx} fields, allowing discipline content
|
|
90
|
+
* to reference the protocol identity directly.
|
|
91
|
+
*
|
|
92
|
+
* `params` accepts app-specific render data beyond {@link AgentRenderCtx}
|
|
93
|
+
* (e.g. a corpus app merges its `source.promptData()` to supply `it.toc`).
|
|
94
|
+
* Extra keys are spread into the Eta render data unchanged.
|
|
95
|
+
*/
|
|
96
|
+
export declare function renderAgentPreamble(app: App, params: AgentRenderCtx & Record<string, unknown>): string;
|
|
97
|
+
//# sourceMappingURL=spine-render.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spine-render.d.ts","sourceRoot":"","sources":["../src/spine-render.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAGH,OAAO,KAAK,EACV,GAAG,EACH,cAAc,EAIf,MAAM,4BAA4B,CAAC;AAQpC;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;;OAIG;IACH,IAAI,EAAE,SAAS,GAAG,EAAE,CAAC;CACtB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,kBAAkB,GAAG,MAAM,CAkB5D;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,GAAG,EACR,MAAM,EAAE,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/C,MAAM,CAeR"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Spine + per-spawn preamble assembly.
|
|
4
|
+
*
|
|
5
|
+
* Two pure render functions. Both pull bytes from `protocol.ts`
|
|
6
|
+
* constants rather than inlining literals — the codified protocol
|
|
7
|
+
* has exactly one source of truth.
|
|
8
|
+
*
|
|
9
|
+
* ## `renderSpine`
|
|
10
|
+
*
|
|
11
|
+
* Assembles the Level-1 shared-prefix system prompt. **Carries no
|
|
12
|
+
* free-form prose surface**: framework-owned literal strings +
|
|
13
|
+
* grammar-sanitized app catalog metadata. No `supplementaryContent`
|
|
14
|
+
* parameter, no per-app prose argument.
|
|
15
|
+
*
|
|
16
|
+
* Output structure:
|
|
17
|
+
*
|
|
18
|
+
* ```
|
|
19
|
+
* <FRAMEWORK_INTRO>
|
|
20
|
+
*
|
|
21
|
+
* # Protocols
|
|
22
|
+
*
|
|
23
|
+
* <CATALOG_ENTRY for each app, in registration order>
|
|
24
|
+
*
|
|
25
|
+
* <TOOL_SELECTION_RULE>
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* App `examples.eta` content goes through `renderAgentPreamble` into
|
|
29
|
+
* per-spawn preambles, never into this output.
|
|
30
|
+
*
|
|
31
|
+
* ## `renderAgentPreamble`
|
|
32
|
+
*
|
|
33
|
+
* The *only* place the framework emits the boundary marker.
|
|
34
|
+
* Called once per spawn with the assigned app's templates only — no
|
|
35
|
+
* other app's `skill.eta` / `examples.eta` enters this rendering, which
|
|
36
|
+
* is what makes per-spawn isolation a framework invariant rather than
|
|
37
|
+
* a convention.
|
|
38
|
+
*
|
|
39
|
+
* @packageDocumentation
|
|
40
|
+
* @category Protocol
|
|
41
|
+
*/
|
|
42
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
+
exports.renderSpine = renderSpine;
|
|
44
|
+
exports.renderAgentPreamble = renderAgentPreamble;
|
|
45
|
+
const lloyal_agents_1 = require("@lloyal-labs/lloyal-agents");
|
|
46
|
+
const protocol_1 = require("./protocol");
|
|
47
|
+
/**
|
|
48
|
+
* Render the shared-spine system prompt.
|
|
49
|
+
*
|
|
50
|
+
* The output has a fixed shape across pool sizes and pool composition
|
|
51
|
+
* — the only variability is the per-app catalog block, sourced from
|
|
52
|
+
* each app's `manifest.protocol`. No app prose; no harness prose.
|
|
53
|
+
*
|
|
54
|
+
* The returned string is intended for `SpineOptions.systemPrompt` in
|
|
55
|
+
* `withSpine(...)`; tool schemas pass through `SpineOptions.tools =
|
|
56
|
+
* apps.flatMap(a => a.tools)` separately and are decoded into KV at
|
|
57
|
+
* spine prefill.
|
|
58
|
+
*/
|
|
59
|
+
function renderSpine(opts) {
|
|
60
|
+
const catalogBlocks = opts.apps
|
|
61
|
+
.map((app) => (0, protocol_1.CATALOG_ENTRY)(app.manifest.protocol.name, [...app.manifest.protocol.tools], app.manifest.protocol.useWhen))
|
|
62
|
+
.join('\n');
|
|
63
|
+
return (protocol_1.FRAMEWORK_INTRO +
|
|
64
|
+
'\n\n# Protocols\n\n' +
|
|
65
|
+
catalogBlocks +
|
|
66
|
+
'\n' +
|
|
67
|
+
protocol_1.TOOL_SELECTION_RULE);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Render the per-spawn preamble for a single agent assigned to
|
|
71
|
+
* `app`. The framework calls this when constructing a spawn's
|
|
72
|
+
* user-role message; the output is the *only* place the boundary
|
|
73
|
+
* marker bytes appear at runtime.
|
|
74
|
+
*
|
|
75
|
+
* Output:
|
|
76
|
+
*
|
|
77
|
+
* ```
|
|
78
|
+
* <BOUNDARY_MARKER(app.manifest.protocol.name)>
|
|
79
|
+
* <renderTemplate(app.skill, params)>
|
|
80
|
+
*
|
|
81
|
+
* <renderTemplate(app.examples, examplesParams)> // if app.examples is defined
|
|
82
|
+
* ```
|
|
83
|
+
*
|
|
84
|
+
* `app.manifest.protocol.name` is grammar-restricted at `defineApp`
|
|
85
|
+
* time: matches `[a-z][a-z0-9_-]{1,63}`, so it cannot
|
|
86
|
+
* break the markdown bold or inject newlines into the marker bytes.
|
|
87
|
+
*
|
|
88
|
+
* `app.examples` (if present) receives an extended render context
|
|
89
|
+
* carrying the protocol `name` and `tools[]` in addition to the
|
|
90
|
+
* standard {@link AgentRenderCtx} fields, allowing discipline content
|
|
91
|
+
* to reference the protocol identity directly.
|
|
92
|
+
*
|
|
93
|
+
* `params` accepts app-specific render data beyond {@link AgentRenderCtx}
|
|
94
|
+
* (e.g. a corpus app merges its `source.promptData()` to supply `it.toc`).
|
|
95
|
+
* Extra keys are spread into the Eta render data unchanged.
|
|
96
|
+
*/
|
|
97
|
+
function renderAgentPreamble(app, params) {
|
|
98
|
+
const marker = (0, protocol_1.BOUNDARY_MARKER)(app.manifest.protocol.name);
|
|
99
|
+
const body = renderSkillBody(app.skill, params);
|
|
100
|
+
if (!app.examples) {
|
|
101
|
+
return marker + body;
|
|
102
|
+
}
|
|
103
|
+
const examplesParams = {
|
|
104
|
+
...params,
|
|
105
|
+
name: app.manifest.protocol.name,
|
|
106
|
+
tools: app.manifest.protocol.tools,
|
|
107
|
+
};
|
|
108
|
+
const examples = renderExamples(app.examples, examplesParams);
|
|
109
|
+
return marker + body + '\n\n' + examples;
|
|
110
|
+
}
|
|
111
|
+
function renderSkillBody(skill, params) {
|
|
112
|
+
return typeof skill === 'function'
|
|
113
|
+
? skill(params)
|
|
114
|
+
: (0, lloyal_agents_1.renderTemplate)(skill, params);
|
|
115
|
+
}
|
|
116
|
+
function renderExamples(examples, params) {
|
|
117
|
+
return typeof examples === 'function'
|
|
118
|
+
? examples(params)
|
|
119
|
+
: (0, lloyal_agents_1.renderTemplate)(examples, params);
|
|
120
|
+
}
|
|
121
|
+
//# sourceMappingURL=spine-render.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spine-render.js","sourceRoot":"","sources":["../src/spine-render.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;;AA2CH,kCAkBC;AA8BD,kDAkBC;AA3GD,8DAA4D;AAQ5D,yCAKoB;AAgBpB;;;;;;;;;;;GAWG;AACH,SAAgB,WAAW,CAAC,IAAwB;IAClD,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI;SAC5B,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CACX,IAAA,wBAAa,EACX,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAC1B,CAAC,GAAG,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,EAChC,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAC9B,CACF;SACA,IAAI,CAAC,IAAI,CAAC,CAAC;IAEd,OAAO,CACL,0BAAe;QACf,qBAAqB;QACrB,aAAa;QACb,IAAI;QACJ,8BAAmB,CACpB,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,SAAgB,mBAAmB,CACjC,GAAQ,EACR,MAAgD;IAEhD,MAAM,MAAM,GAAG,IAAA,0BAAe,EAAC,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC3D,MAAM,IAAI,GAAG,eAAe,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAEhD,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;QAClB,OAAO,MAAM,GAAG,IAAI,CAAC;IACvB,CAAC;IAED,MAAM,cAAc,GAAsB;QACxC,GAAG,MAAM;QACT,IAAI,EAAE,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI;QAChC,KAAK,EAAE,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK;KACnC,CAAC;IACF,MAAM,QAAQ,GAAG,cAAc,CAAC,GAAG,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;IAC9D,OAAO,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,QAAQ,CAAC;AAC3C,CAAC;AAED,SAAS,eAAe,CACtB,KAA+B,EAC/B,MAAsB;IAEtB,OAAO,OAAO,KAAK,KAAK,UAAU;QAChC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC;QACf,CAAC,CAAC,IAAA,8BAAc,EAAC,KAAK,EAAE,MAA4C,CAAC,CAAC;AAC1E,CAAC;AAED,SAAS,cAAc,CACrB,QAAqC,EACrC,MAAyB;IAEzB,OAAO,OAAO,QAAQ,KAAK,UAAU;QACnC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC;QAClB,CAAC,CAAC,IAAA,8BAAc,EAAC,QAAQ,EAAE,MAA4C,CAAC,CAAC;AAC7E,CAAC"}
|
package/dist/tools/delegate.js
CHANGED
|
@@ -157,7 +157,7 @@ class DelegateTool extends lloyal_agents_1.Tool {
|
|
|
157
157
|
...(this._createPolicy ? { policy: this._createPolicy() } : {}),
|
|
158
158
|
orchestrate: (0, lloyal_agents_1.parallel)(tasks.map(t => ({ systemPrompt: this._systemPrompt, content: t }))),
|
|
159
159
|
parent: context?.branch,
|
|
160
|
-
|
|
160
|
+
pruneOnReturn: opts.pruneOnReturn ?? true,
|
|
161
161
|
scorer: context?.scorer,
|
|
162
162
|
});
|
|
163
163
|
const result = {
|
package/dist/tools/index.d.ts
CHANGED
|
@@ -1,35 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Rig — framework-level tools, search providers, and shared types.
|
|
3
|
+
*
|
|
4
|
+
* **Framework tools (consumed by harnesses):**
|
|
5
|
+
* - {@link reportTool} / {@link ReportTool} — the standard terminal tool.
|
|
6
|
+
* - {@link DelegateTool} — delegation primitive for sub-agent spawning.
|
|
7
|
+
* - {@link PlanTool} — grammar-constrained query planner.
|
|
8
|
+
*
|
|
9
|
+
* **Search providers (consumed by apps' Source implementations):**
|
|
10
|
+
* - {@link TavilyProvider} — Tavily-backed web search.
|
|
11
|
+
* - {@link createKeylessSearchProvider} — keyless DuckDuckGo fallback.
|
|
12
|
+
*
|
|
13
|
+
* App-scoped Tool classes (`web_search`, `fetch_page`, `search`,
|
|
14
|
+
* `read_file`, `grep`) live in `@lloyal-labs/{web,corpus}-app`, not
|
|
15
|
+
* here — those are unit-of-distribution surfaces under the App
|
|
16
|
+
* protocol, installed via `harness.dev install`.
|
|
17
|
+
*/
|
|
4
18
|
import { ReportTool } from './report';
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
19
|
+
export { TavilyProvider } from './web-search';
|
|
20
|
+
export type { SearchProvider, SearchResult } from './web-search';
|
|
21
|
+
export { createKeylessSearchProvider } from './keyless-search';
|
|
22
|
+
export type { KeylessSearchOptions } from './keyless-search';
|
|
7
23
|
export { ReportTool } from './report';
|
|
8
24
|
export { DelegateTool } from './delegate';
|
|
9
25
|
export type { DelegateToolOpts } from './delegate';
|
|
10
|
-
export type {
|
|
26
|
+
export type { Reranker, ScoredChunk, ScoredResult } from './types';
|
|
11
27
|
export { PlanTool, taskToContent } from './plan';
|
|
12
28
|
export type { PlanResult, PlanIntent, PlanToolOpts, ResearchTask } from './plan';
|
|
13
29
|
/**
|
|
14
|
-
* Shared
|
|
30
|
+
* Shared {@link ReportTool} instance — the conventional terminal tool.
|
|
15
31
|
*
|
|
16
|
-
*
|
|
32
|
+
* `ReportTool` is stateless, so one shared instance is reused across
|
|
33
|
+
* pools. Pass it as the `terminal` of `agentPool` / `useAgent`. For a
|
|
34
|
+
* custom description, construct your own via `new ReportTool({...})`.
|
|
17
35
|
*
|
|
18
36
|
* @category Rig
|
|
19
37
|
*/
|
|
20
38
|
export declare const reportTool: ReportTool;
|
|
21
|
-
/**
|
|
22
|
-
* Build the standard corpus toolkit.
|
|
23
|
-
*
|
|
24
|
-
* Returns a {@link Toolkit} containing {@link SearchTool},
|
|
25
|
-
* {@link ReadFileTool}, {@link GrepTool}, and {@link ReportTool}
|
|
26
|
-
* wired to the provided resources, chunks, and reranker.
|
|
27
|
-
*
|
|
28
|
-
* @category Rig
|
|
29
|
-
*/
|
|
30
|
-
export declare function createTools(opts: {
|
|
31
|
-
resources: Resource[];
|
|
32
|
-
chunks: Chunk[];
|
|
33
|
-
reranker: Reranker;
|
|
34
|
-
}): Toolkit;
|
|
35
39
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAC;AAC/D,YAAY,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,YAAY,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACnD,YAAY,EAAE,QAAQ,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACjD,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEjF;;;;;;;;GAQG;AACH,eAAO,MAAM,UAAU,YAAmB,CAAC"}
|
package/dist/tools/index.js
CHANGED
|
@@ -1,17 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Rig — framework-level tools, search providers, and shared types.
|
|
4
|
+
*
|
|
5
|
+
* **Framework tools (consumed by harnesses):**
|
|
6
|
+
* - {@link reportTool} / {@link ReportTool} — the standard terminal tool.
|
|
7
|
+
* - {@link DelegateTool} — delegation primitive for sub-agent spawning.
|
|
8
|
+
* - {@link PlanTool} — grammar-constrained query planner.
|
|
9
|
+
*
|
|
10
|
+
* **Search providers (consumed by apps' Source implementations):**
|
|
11
|
+
* - {@link TavilyProvider} — Tavily-backed web search.
|
|
12
|
+
* - {@link createKeylessSearchProvider} — keyless DuckDuckGo fallback.
|
|
13
|
+
*
|
|
14
|
+
* App-scoped Tool classes (`web_search`, `fetch_page`, `search`,
|
|
15
|
+
* `read_file`, `grep`) live in `@lloyal-labs/{web,corpus}-app`, not
|
|
16
|
+
* here — those are unit-of-distribution surfaces under the App
|
|
17
|
+
* protocol, installed via `harness.dev install`.
|
|
18
|
+
*/
|
|
2
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.reportTool = exports.taskToContent = exports.PlanTool = exports.DelegateTool = exports.ReportTool = exports.
|
|
4
|
-
exports.createTools = createTools;
|
|
5
|
-
const lloyal_agents_1 = require("@lloyal-labs/lloyal-agents");
|
|
6
|
-
const search_1 = require("./search");
|
|
7
|
-
const read_file_1 = require("./read-file");
|
|
8
|
-
const grep_1 = require("./grep");
|
|
20
|
+
exports.reportTool = exports.taskToContent = exports.PlanTool = exports.DelegateTool = exports.ReportTool = exports.createKeylessSearchProvider = exports.TavilyProvider = void 0;
|
|
9
21
|
const report_1 = require("./report");
|
|
10
22
|
var web_search_1 = require("./web-search");
|
|
11
|
-
Object.defineProperty(exports, "WebSearchTool", { enumerable: true, get: function () { return web_search_1.WebSearchTool; } });
|
|
12
23
|
Object.defineProperty(exports, "TavilyProvider", { enumerable: true, get: function () { return web_search_1.TavilyProvider; } });
|
|
13
|
-
var
|
|
14
|
-
Object.defineProperty(exports, "
|
|
24
|
+
var keyless_search_1 = require("./keyless-search");
|
|
25
|
+
Object.defineProperty(exports, "createKeylessSearchProvider", { enumerable: true, get: function () { return keyless_search_1.createKeylessSearchProvider; } });
|
|
15
26
|
var report_2 = require("./report");
|
|
16
27
|
Object.defineProperty(exports, "ReportTool", { enumerable: true, get: function () { return report_2.ReportTool; } });
|
|
17
28
|
var delegate_1 = require("./delegate");
|
|
@@ -20,28 +31,13 @@ var plan_1 = require("./plan");
|
|
|
20
31
|
Object.defineProperty(exports, "PlanTool", { enumerable: true, get: function () { return plan_1.PlanTool; } });
|
|
21
32
|
Object.defineProperty(exports, "taskToContent", { enumerable: true, get: function () { return plan_1.taskToContent; } });
|
|
22
33
|
/**
|
|
23
|
-
* Shared
|
|
34
|
+
* Shared {@link ReportTool} instance — the conventional terminal tool.
|
|
24
35
|
*
|
|
25
|
-
*
|
|
36
|
+
* `ReportTool` is stateless, so one shared instance is reused across
|
|
37
|
+
* pools. Pass it as the `terminal` of `agentPool` / `useAgent`. For a
|
|
38
|
+
* custom description, construct your own via `new ReportTool({...})`.
|
|
26
39
|
*
|
|
27
40
|
* @category Rig
|
|
28
41
|
*/
|
|
29
42
|
exports.reportTool = new report_1.ReportTool();
|
|
30
|
-
/**
|
|
31
|
-
* Build the standard corpus toolkit.
|
|
32
|
-
*
|
|
33
|
-
* Returns a {@link Toolkit} containing {@link SearchTool},
|
|
34
|
-
* {@link ReadFileTool}, {@link GrepTool}, and {@link ReportTool}
|
|
35
|
-
* wired to the provided resources, chunks, and reranker.
|
|
36
|
-
*
|
|
37
|
-
* @category Rig
|
|
38
|
-
*/
|
|
39
|
-
function createTools(opts) {
|
|
40
|
-
return (0, lloyal_agents_1.createToolkit)([
|
|
41
|
-
new search_1.SearchTool(opts.chunks, opts.reranker),
|
|
42
|
-
new read_file_1.ReadFileTool(opts.resources),
|
|
43
|
-
new grep_1.GrepTool(opts.resources),
|
|
44
|
-
exports.reportTool,
|
|
45
|
-
]);
|
|
46
|
-
}
|
|
47
43
|
//# sourceMappingURL=index.js.map
|
package/dist/tools/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;;AAEH,qCAAsC;AAEtC,2CAA8C;AAArC,4GAAA,cAAc,OAAA;AAEvB,mDAA+D;AAAtD,6HAAA,2BAA2B,OAAA;AAEpC,mCAAsC;AAA7B,oGAAA,UAAU,OAAA;AACnB,uCAA0C;AAAjC,wGAAA,YAAY,OAAA;AAGrB,+BAAiD;AAAxC,gGAAA,QAAQ,OAAA;AAAE,qGAAA,aAAa,OAAA;AAGhC;;;;;;;;GAQG;AACU,QAAA,UAAU,GAAG,IAAI,mBAAU,EAAE,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { Operation } from "effection";
|
|
2
|
+
import type { SearchProvider } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Configuration for {@link createKeylessSearchProvider}.
|
|
5
|
+
*
|
|
6
|
+
* The defaults are tuned for residential-IP safety: ~1 request every 3–5 s
|
|
7
|
+
* to the primary engine. Lowering `paceBaseMs` below the default risks
|
|
8
|
+
* being blocked by DuckDuckGo. Setting it to zero throws at construction.
|
|
9
|
+
*
|
|
10
|
+
* @category Rig
|
|
11
|
+
*/
|
|
12
|
+
export interface KeylessSearchOptions {
|
|
13
|
+
/** Pacer base interval in ms between primary-engine requests. @default 3000 */
|
|
14
|
+
paceBaseMs?: number;
|
|
15
|
+
/** Pacer jitter added on top of base (uniform [0, paceJitterMs)). @default 2000 */
|
|
16
|
+
paceJitterMs?: number;
|
|
17
|
+
/** Consecutive hard failures before the breaker opens. @default 2 */
|
|
18
|
+
breakerThreshold?: number;
|
|
19
|
+
/** Ms the breaker stays open before allowing a half-open probe. @default 15000 */
|
|
20
|
+
breakerCooldownMs?: number;
|
|
21
|
+
/** Per-request timeout in ms (must stay below fetch-page's 10s ceiling). @default 8000 */
|
|
22
|
+
requestTimeoutMs?: number;
|
|
23
|
+
/** User-Agent header to send to the primary engine. */
|
|
24
|
+
userAgent?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Sleep operation used by the pacer and timeout race. Defaults to
|
|
27
|
+
* effection's `sleep`. Tests inject a tick-driven mock for determinism.
|
|
28
|
+
*/
|
|
29
|
+
sleepOp?: (ms: number) => Operation<void>;
|
|
30
|
+
/** Fetch implementation. Defaults to global `fetch`. Tests inject mocks. */
|
|
31
|
+
fetchImpl?: typeof fetch;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Create the keyless, in-process default {@link SearchProvider}.
|
|
35
|
+
*
|
|
36
|
+
* Two engines, primary with circuit-broken fallback:
|
|
37
|
+
*
|
|
38
|
+
* - **Primary**: DuckDuckGo HTML (`html.duckduckgo.com/html/`). Static,
|
|
39
|
+
* no-JS endpoint. Paced behind a shared FIFO request limiter to avoid
|
|
40
|
+
* triggering rate-limit responses on a residential IP. Wrapped in a
|
|
41
|
+
* circuit breaker that opens on consecutive hard failures (403/429/
|
|
42
|
+
* network/timeout) and recovers via a half-open probe after a cooldown.
|
|
43
|
+
*
|
|
44
|
+
* - **Fallback**: Marginalia public JSON API (`api2.marginalia-search.com`,
|
|
45
|
+
* shared `public` API key via header). Independent niche index;
|
|
46
|
+
* shared-key saturation surfaces as 503/429 and is treated as soft-empty.
|
|
47
|
+
*
|
|
48
|
+
* Returned results omit the `score` field by design — the upstream
|
|
49
|
+
* `WebSearchTool` exploit-mode ranking falls back cleanly to entailment-only
|
|
50
|
+
* when scores are absent, while a fabricated provider score would corrupt
|
|
51
|
+
* `min(providerScore, entailment)`.
|
|
52
|
+
*
|
|
53
|
+
* The provider is bound to the scope where this factory is yielded — the
|
|
54
|
+
* pacer's central tick loop is halted when that scope exits.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* yield* initAgents(ctx);
|
|
59
|
+
* const provider = yield* createKeylessSearchProvider();
|
|
60
|
+
* // Inject into an App factory (e.g. createWebApp) that constructs its
|
|
61
|
+
* // Source bound to the provider + reranker.
|
|
62
|
+
* ```
|
|
63
|
+
*
|
|
64
|
+
* @category Rig
|
|
65
|
+
*/
|
|
66
|
+
export declare function createKeylessSearchProvider(opts?: KeylessSearchOptions): Operation<SearchProvider>;
|
|
67
|
+
//# sourceMappingURL=keyless-search.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keyless-search.d.ts","sourceRoot":"","sources":["../../src/tools/keyless-search.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE3C,OAAO,KAAK,EAAE,cAAc,EAAgB,MAAM,SAAS,CAAC;AAwB5D;;;;;;;;GAQG;AACH,MAAM,WAAW,oBAAoB;IACnC,+EAA+E;IAC/E,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,mFAAmF;IACnF,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,qEAAqE;IACrE,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,kFAAkF;IAClF,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,0FAA0F;IAC1F,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,uDAAuD;IACvD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,OAAO,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,SAAS,CAAC,IAAI,CAAC,CAAC;IAC1C,4EAA4E;IAC5E,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;CAC1B;AA0QD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,2BAA2B,CACzC,IAAI,GAAE,oBAAyB,GAC9B,SAAS,CAAC,cAAc,CAAC,CA8I3B"}
|