@sigrun/ext-tool-search 0.0.0-stage → 0.1.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/CHANGELOG.md +21 -0
- package/LICENSE +21 -0
- package/README.md +117 -2
- package/dist/extension.d.ts +51 -0
- package/dist/extension.js +68 -0
- package/dist/index.d.ts +51 -0
- package/dist/index.js +48 -0
- package/package.json +54 -5
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [0.1.0] - 2026-10-13
|
|
11
|
+
### Added
|
|
12
|
+
- Renamed to `@sigrun/ext-tool-search` for the 0.1.0 release (repo
|
|
13
|
+
stays `sigrun-ai/sigrun-ext-tool-search`): published package metadata
|
|
14
|
+
(`publishConfig` access/provenance), host modules moved to
|
|
15
|
+
`peerDependencies` mirrored in `devDependencies` at exact `1.3.0`, the
|
|
16
|
+
test-only `@sigrun/ext-mcp` devDependency re-keyed to its published
|
|
17
|
+
name (`file:` dev shape until Task 8), CHANGELOG.md joined the files
|
|
18
|
+
whitelist, and a manifest hygiene check wired into `npm test`.
|
|
19
|
+
- sigrun loader-contract wrapper over pi-durable's `createToolSearchExtension`
|
|
20
|
+
(BM25 tool_search over `agent.deferred`), plus the installed-not-offered
|
|
21
|
+
notice section and the end-to-end deferred-tools suite.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Michael MacLeod
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,118 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @sigrun/ext-tool-search
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The tool-search extension for sigrun (pi-durable): the `tool_search`
|
|
4
|
+
tool — BM25 search over DEFERRED tool metadata that loads the matches
|
|
5
|
+
into the model-offered set — installed via upstream's
|
|
6
|
+
`createToolSearchExtension` (`@earendil-works/pi-durable/tool-search`),
|
|
7
|
+
verbatim, plus one sigrun addition: the companion `tool_search_notice`
|
|
8
|
+
section (the same warn-if-not-offered channel as sigrun-ext-codemode's
|
|
9
|
+
`codemode_notice`).
|
|
10
|
+
|
|
11
|
+
The sigrun extension-package contract: the default export is a factory
|
|
12
|
+
taking no arguments, returning `{ extension }`.
|
|
13
|
+
|
|
14
|
+
## What the factory does
|
|
15
|
+
|
|
16
|
+
Returns upstream's `tool-search` extension — name `"tool-search"`, the
|
|
17
|
+
`tool_search` tool named exactly, `callers: ["model"]`, `replay:
|
|
18
|
+
"safe"` — spread with one additional section (below). Upstream ships
|
|
19
|
+
the BM25 ranker inside pi-durable itself (`dist/search.js`), so there
|
|
20
|
+
is no separate ranker dependency (rev-3 ruling: sigrun-tool-ranker
|
|
21
|
+
DROPPED). The extension is stateless; the wiring has no lifecycle to
|
|
22
|
+
close.
|
|
23
|
+
|
|
24
|
+
## The load mechanism (verified against pi-durable 1.2.0)
|
|
25
|
+
|
|
26
|
+
Deferred tools — sigrun-ext-mcp's `exposure: "deferred"` servers, i.e.
|
|
27
|
+
MCP tools registered `deferred: true` — sit in `agent.deferred`:
|
|
28
|
+
model-callable, NOT model-offered. `tool_search` ranks them (BM25 over
|
|
29
|
+
name, description, and parameter-schema text; `DEFAULT_TOOL_SEARCH_
|
|
30
|
+
LIMIT` 8) and returns `control: { addTools: <names> }`, which the
|
|
31
|
+
harness applies to the conversation's `pi.agent.modelTools` (`add`).
|
|
32
|
+
|
|
33
|
+
Replacement semantics — what the write means:
|
|
34
|
+
|
|
35
|
+
- **The offered set, next call.** The next request's offered set
|
|
36
|
+
(`agent.tools`) includes the loaded names. The run CONTINUES after
|
|
37
|
+
the tool round (the generation hands over within the same
|
|
38
|
+
submission), so search → load → invoke is one turn.
|
|
39
|
+
- **Per branch, durable.** The write is on the conversation's
|
|
40
|
+
`pi.agent` document, so the loaded set stays offered on that branch —
|
|
41
|
+
across later entries, forks (copied as-of the fork entry), and
|
|
42
|
+
compactions. A different branch that never searched sees nothing.
|
|
43
|
+
- **Deferred until offered.** `agent.deferred` is computed — "deferred
|
|
44
|
+
tools the model may call and is not offered YET" — so loading a tool
|
|
45
|
+
removes it from the deferred set; the still-unloaded siblings remain
|
|
46
|
+
search candidates. Nothing is unregistered.
|
|
47
|
+
- **Empty is not error.** A query matching nothing (or no deferred
|
|
48
|
+
tools at all) returns `details: { loaded: [] }` with the text
|
|
49
|
+
"No matching tools found." and NO control — never an error, and the
|
|
50
|
+
offered set does not grow.
|
|
51
|
+
|
|
52
|
+
On the transcript, a load appears as a `pi.system` entry whose
|
|
53
|
+
`toolsAdded` lists the loaded tool — the prompt-cache DIFF against the
|
|
54
|
+
previous request, so the FIRST request's `toolsAdded` names
|
|
55
|
+
`tool_search` itself; that first entry is not a load.
|
|
56
|
+
|
|
57
|
+
## The warn-if-not-offered section
|
|
58
|
+
|
|
59
|
+
Upstream's `tool_search` description tells the model to "always use
|
|
60
|
+
tool_search" for tool discovery — a model whose Settings → default
|
|
61
|
+
tools excluded `tool_search` would be pointed at a tool it cannot call,
|
|
62
|
+
and every `exposure: "deferred"` MCP server would be unreachable from
|
|
63
|
+
the model entirely. When the extension is installed yet the tool is not
|
|
64
|
+
model-offered in a request, the companion `tool_search_notice` section
|
|
65
|
+
renders:
|
|
66
|
+
|
|
67
|
+
> deferred tools are searchable but the tool_search tool is not
|
|
68
|
+
> offered; enable it via Settings → default tools
|
|
69
|
+
|
|
70
|
+
When the tool is offered the section renders NOTHING (returns
|
|
71
|
+
`undefined`; no tag is written). Installation is read from
|
|
72
|
+
`agent.extensions[*].tools` — NOT `agent.callable`, which holds only
|
|
73
|
+
tools-callable tools and never sees `tool_search` (`callers: ["model"]`)
|
|
74
|
+
— the same trap the codemode notice caught in Task 5; the mechanism
|
|
75
|
+
(companion section, keyed to the exact not-offered condition,
|
|
76
|
+
registered on the one extension this package installs) mirrors
|
|
77
|
+
sigrun-ext-codemode's choice for review consistency.
|
|
78
|
+
|
|
79
|
+
## Package replacement semantics (slice 4)
|
|
80
|
+
|
|
81
|
+
Replace this package by not installing it and installing yours: the
|
|
82
|
+
surface is one tool named exactly `tool_search` (plus the companion
|
|
83
|
+
`tool_search_notice` section), so a per-name replacement is trivial —
|
|
84
|
+
uninstall ours, install the replacement under the same tool name. Do NOT
|
|
85
|
+
co-install: pi-durable resolves cross-extension duplicate tool names
|
|
86
|
+
last-selected-wins, so a co-installed replacement silently shadows the
|
|
87
|
+
original. Sigrun's extension loader now makes the shadowing visible at
|
|
88
|
+
boot (it `console.warn`s once per duplicate tool name, naming the
|
|
89
|
+
extensions and the last-wins resolution), but the warning changes nothing:
|
|
90
|
+
last-wins stands. Replace, don't co-install.
|
|
91
|
+
|
|
92
|
+
(Not to be confused with "Replacement semantics — what the write means"
|
|
93
|
+
above: that section is about the `modelTools` write this package performs;
|
|
94
|
+
this one is about replacing this package itself.)
|
|
95
|
+
|
|
96
|
+
## Dependencies
|
|
97
|
+
|
|
98
|
+
- `@earendil-works/pi-durable` (peer, exact `1.3.0`): the extension
|
|
99
|
+
itself and the deferred/modelTools machinery.
|
|
100
|
+
- `@sigrun/ext-mcp` (devDependency, `file:../sigrun-ext-mcp` until
|
|
101
|
+
Task 8 publishes it; then `0.1.0`): NOT used
|
|
102
|
+
by the shipped code — only by the test suite, which drives deferred
|
|
103
|
+
tools through the REAL mcp extension (Task 4's verified
|
|
104
|
+
`exposure: "deferred"` config shape) so the e2e covers exactly the
|
|
105
|
+
machinery that produces deferred tools in prod. Per Ruling Z the
|
|
106
|
+
sigrun tree does not pin these repos (Task 8 wires the image).
|
|
107
|
+
|
|
108
|
+
## Development
|
|
109
|
+
|
|
110
|
+
```sh
|
|
111
|
+
npm install && npm test # vitest run
|
|
112
|
+
npm run typecheck
|
|
113
|
+
npm run build
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
The suite opens a REAL pi-durable harness (registry + faux provider)
|
|
117
|
+
with both extensions installed against a copied stub MCP server
|
|
118
|
+
(`test/stub-mcp-server.mjs`, sigrun-ext-mcp's idiom).
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The tool-search notice section (sigrun-ext-tool-search): the same
|
|
3
|
+
* warn-if-not-offered channel, mechanism, and wording shape as
|
|
4
|
+
* sigrun-ext-codemode's `codemode_notice` (Task 5; consistency across both
|
|
5
|
+
* repos is a review criterion).
|
|
6
|
+
*
|
|
7
|
+
* When the extension is installed but the `tool_search` TOOL is not
|
|
8
|
+
* model-offered in a request (Settings → default tools removes it via
|
|
9
|
+
* `pi.agent.modelTools`), the model would otherwise be told by
|
|
10
|
+
* `tool_search`'s own description to "always use tool_search" for tool
|
|
11
|
+
* discovery while having no way to call it — and sigrun-ext-mcp's
|
|
12
|
+
* `exposure: "deferred"` servers would be unreachable from the model
|
|
13
|
+
* entirely. The companion `tool_search_notice` section renders the enable
|
|
14
|
+
* notice; when the tool IS offered it renders NOTHING (returns
|
|
15
|
+
* `undefined`, so no tag is written), which de-duplicates by construction.
|
|
16
|
+
*
|
|
17
|
+
* Mechanism choice (mirroring Task 5's, documented there and in both
|
|
18
|
+
* READMEs): a companion section rather than a `wrapSection("tool-search", …)`
|
|
19
|
+
* — upstream's tool-search extension ships NO section at all (verified:
|
|
20
|
+
* `createToolSearchExtension()` registers only the tool), so the companion
|
|
21
|
+
* is the only shape that can carry the notice, and it keys the notice to
|
|
22
|
+
* the not-offered condition exactly, leaving the upstream extension
|
|
23
|
+
* untouched. The companion section is registered on the same extension
|
|
24
|
+
* object this package installs (upstream's spread + our section), so the
|
|
25
|
+
* pair always travels together.
|
|
26
|
+
*
|
|
27
|
+
* The installation read is `agent.extensions[*].tools` — NOT
|
|
28
|
+
* `agent.callable`: that set holds only tools-callable tools, and
|
|
29
|
+
* `tool_search` registers `callers: ["model"]` (the same trap the codemode
|
|
30
|
+
* notice caught in Task 5; TOOLS_SEARCH_TOOL_NAME is imported from
|
|
31
|
+
* upstream so the name never drifts).
|
|
32
|
+
*/
|
|
33
|
+
import { createToolSearchExtension } from "@earendil-works/pi-durable/tool-search";
|
|
34
|
+
import { type Extension, type PromptInput } from "@earendil-works/pi-durable";
|
|
35
|
+
/** Our companion section's key. */
|
|
36
|
+
export declare const TOOL_SEARCH_NOTICE_SECTION_KEY = "tool_search_notice";
|
|
37
|
+
/** The enable notice, the codemode notice's wording shape. */
|
|
38
|
+
export declare const TOOL_SEARCH_NOT_OFFERED_NOTICE: string;
|
|
39
|
+
/**
|
|
40
|
+
* The companion section render: the notice ONLY when the tool_search tool
|
|
41
|
+
* is installed (one of the selected extensions registers it) yet not
|
|
42
|
+
* model-offered in this request (`agent.tools` is the offered set);
|
|
43
|
+
* `undefined` otherwise (offered, or not installed — nothing to warn
|
|
44
|
+
* about).
|
|
45
|
+
*/
|
|
46
|
+
export declare function renderToolSearchNotice(input: PromptInput): string | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* The sigrun tool-search extension: upstream's `tool-search` extension
|
|
49
|
+
* (the `tool_search` tool) plus the companion notice section.
|
|
50
|
+
*/
|
|
51
|
+
export declare function addToolSearchNotice(upstream: ReturnType<typeof createToolSearchExtension>): Extension;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The tool-search notice section (sigrun-ext-tool-search): the same
|
|
3
|
+
* warn-if-not-offered channel, mechanism, and wording shape as
|
|
4
|
+
* sigrun-ext-codemode's `codemode_notice` (Task 5; consistency across both
|
|
5
|
+
* repos is a review criterion).
|
|
6
|
+
*
|
|
7
|
+
* When the extension is installed but the `tool_search` TOOL is not
|
|
8
|
+
* model-offered in a request (Settings → default tools removes it via
|
|
9
|
+
* `pi.agent.modelTools`), the model would otherwise be told by
|
|
10
|
+
* `tool_search`'s own description to "always use tool_search" for tool
|
|
11
|
+
* discovery while having no way to call it — and sigrun-ext-mcp's
|
|
12
|
+
* `exposure: "deferred"` servers would be unreachable from the model
|
|
13
|
+
* entirely. The companion `tool_search_notice` section renders the enable
|
|
14
|
+
* notice; when the tool IS offered it renders NOTHING (returns
|
|
15
|
+
* `undefined`, so no tag is written), which de-duplicates by construction.
|
|
16
|
+
*
|
|
17
|
+
* Mechanism choice (mirroring Task 5's, documented there and in both
|
|
18
|
+
* READMEs): a companion section rather than a `wrapSection("tool-search", …)`
|
|
19
|
+
* — upstream's tool-search extension ships NO section at all (verified:
|
|
20
|
+
* `createToolSearchExtension()` registers only the tool), so the companion
|
|
21
|
+
* is the only shape that can carry the notice, and it keys the notice to
|
|
22
|
+
* the not-offered condition exactly, leaving the upstream extension
|
|
23
|
+
* untouched. The companion section is registered on the same extension
|
|
24
|
+
* object this package installs (upstream's spread + our section), so the
|
|
25
|
+
* pair always travels together.
|
|
26
|
+
*
|
|
27
|
+
* The installation read is `agent.extensions[*].tools` — NOT
|
|
28
|
+
* `agent.callable`: that set holds only tools-callable tools, and
|
|
29
|
+
* `tool_search` registers `callers: ["model"]` (the same trap the codemode
|
|
30
|
+
* notice caught in Task 5; TOOLS_SEARCH_TOOL_NAME is imported from
|
|
31
|
+
* upstream so the name never drifts).
|
|
32
|
+
*/
|
|
33
|
+
import { TOOL_SEARCH_TOOL_NAME, } from "@earendil-works/pi-durable/tool-search";
|
|
34
|
+
import { defineExtension, } from "@earendil-works/pi-durable";
|
|
35
|
+
/** Our companion section's key. */
|
|
36
|
+
export const TOOL_SEARCH_NOTICE_SECTION_KEY = "tool_search_notice";
|
|
37
|
+
/** The enable notice, the codemode notice's wording shape. */
|
|
38
|
+
export const TOOL_SEARCH_NOT_OFFERED_NOTICE = "deferred tools are searchable but the tool_search tool is not offered; " +
|
|
39
|
+
"enable it via Settings → default tools";
|
|
40
|
+
/**
|
|
41
|
+
* The companion section render: the notice ONLY when the tool_search tool
|
|
42
|
+
* is installed (one of the selected extensions registers it) yet not
|
|
43
|
+
* model-offered in this request (`agent.tools` is the offered set);
|
|
44
|
+
* `undefined` otherwise (offered, or not installed — nothing to warn
|
|
45
|
+
* about).
|
|
46
|
+
*/
|
|
47
|
+
export function renderToolSearchNotice(input) {
|
|
48
|
+
const installed = input.agent.extensions.some((extension) => (extension.tools ?? []).some((tool) => tool.name === TOOL_SEARCH_TOOL_NAME));
|
|
49
|
+
if (!installed)
|
|
50
|
+
return undefined; // not installed: no lie to correct
|
|
51
|
+
const offered = input.agent.tools.some((tool) => tool.name === TOOL_SEARCH_TOOL_NAME);
|
|
52
|
+
return offered ? undefined : TOOL_SEARCH_NOT_OFFERED_NOTICE;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* The sigrun tool-search extension: upstream's `tool-search` extension
|
|
56
|
+
* (the `tool_search` tool) plus the companion notice section.
|
|
57
|
+
*/
|
|
58
|
+
export function addToolSearchNotice(upstream) {
|
|
59
|
+
return defineExtension({
|
|
60
|
+
...upstream,
|
|
61
|
+
sections: [
|
|
62
|
+
{
|
|
63
|
+
key: TOOL_SEARCH_NOTICE_SECTION_KEY,
|
|
64
|
+
render: renderToolSearchNotice,
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
});
|
|
68
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* sigrun-ext-tool-search: the tool-search factory (the loader contract).
|
|
3
|
+
*
|
|
4
|
+
* The sigrun extension-package contract (sigrun's src/harness/loader.ts):
|
|
5
|
+
* the default export is a FACTORY TAKING NO ARGUMENTS, returning
|
|
6
|
+
* `{ extension }`. The loader calls it synchronously at boot, before
|
|
7
|
+
* `Harness.open` reads the registry.
|
|
8
|
+
*
|
|
9
|
+
* What the factory returns is UPSTREAM'S tool-search extension, VERBATIM:
|
|
10
|
+
* `createToolSearchExtension()` from `@earendil-works/pi-durable/tool-search`
|
|
11
|
+
* (name "tool-search", the `tool_search` tool named exactly, with
|
|
12
|
+
* `callers: ["model"]` and `replay: "safe"`), plus one sigrun addition —
|
|
13
|
+
* the companion `tool_search_notice` section (src/extension.ts), the same
|
|
14
|
+
* mechanism and the same wording channel as sigrun-ext-codemode's
|
|
15
|
+
* `codemode_notice` (Task 5; consistency across both repos is a review
|
|
16
|
+
* criterion). Upstream ships BM25 ranking inside pi-durable itself, so
|
|
17
|
+
* there is no separate ranker dependency (rev-3 ruling: sigrun-tool-ranker
|
|
18
|
+
* DROPPED).
|
|
19
|
+
*
|
|
20
|
+
* Deferred-tool lifecycle (verified against pi-durable 1.2.0
|
|
21
|
+
* `dist/tool-search/tool-search.js` + `dist/harness/agent.js`): tools
|
|
22
|
+
* registered `deferred: true` (sigrun-ext-mcp's `exposure: "deferred"`)
|
|
23
|
+
* sit in `agent.deferred` — model-callable, NOT model-offered — until
|
|
24
|
+
* `tool_search` matches them (BM25 over name/description/parameter text,
|
|
25
|
+
* `DEFAULT_TOOL_SEARCH_LIMIT` 8) and returns
|
|
26
|
+
* `control: { addTools: <names> }`. The harness applies that to the
|
|
27
|
+
* conversation's `pi.agent.modelTools` (its `add`), so the NEXT request
|
|
28
|
+
* offers the loaded tools, and the write is on the conversation document —
|
|
29
|
+
* the loaded set travels the branch, forks included. A query matching
|
|
30
|
+
* nothing returns an EMPTY result ("No matching tools found."), never an
|
|
31
|
+
* error.
|
|
32
|
+
*/
|
|
33
|
+
import type { Extension } from "@earendil-works/pi-durable";
|
|
34
|
+
/** What {@link createToolSearchWiring} returns (the loader contract). */
|
|
35
|
+
export interface ToolSearchWiring {
|
|
36
|
+
/** The extension to install into the harness registry. */
|
|
37
|
+
readonly extension: Extension;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The tool-search factory (the loader contract: no arguments). Upstream's
|
|
41
|
+
* extension is stateless (the search reads `agent.deferred` at execution
|
|
42
|
+
* time; ranking is pure), so one wiring has no lifecycle to close.
|
|
43
|
+
*/
|
|
44
|
+
export declare function createToolSearchWiring(): ToolSearchWiring;
|
|
45
|
+
/**
|
|
46
|
+
* The sigrun extension-package contract: the default export is a factory
|
|
47
|
+
* taking no arguments, returning `{ extension }`.
|
|
48
|
+
*/
|
|
49
|
+
declare const _default: typeof createToolSearchWiring;
|
|
50
|
+
export default _default;
|
|
51
|
+
export { TOOL_SEARCH_NOTICE_SECTION_KEY, TOOL_SEARCH_NOT_OFFERED_NOTICE, renderToolSearchNotice, } from "./extension.js";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* sigrun-ext-tool-search: the tool-search factory (the loader contract).
|
|
3
|
+
*
|
|
4
|
+
* The sigrun extension-package contract (sigrun's src/harness/loader.ts):
|
|
5
|
+
* the default export is a FACTORY TAKING NO ARGUMENTS, returning
|
|
6
|
+
* `{ extension }`. The loader calls it synchronously at boot, before
|
|
7
|
+
* `Harness.open` reads the registry.
|
|
8
|
+
*
|
|
9
|
+
* What the factory returns is UPSTREAM'S tool-search extension, VERBATIM:
|
|
10
|
+
* `createToolSearchExtension()` from `@earendil-works/pi-durable/tool-search`
|
|
11
|
+
* (name "tool-search", the `tool_search` tool named exactly, with
|
|
12
|
+
* `callers: ["model"]` and `replay: "safe"`), plus one sigrun addition —
|
|
13
|
+
* the companion `tool_search_notice` section (src/extension.ts), the same
|
|
14
|
+
* mechanism and the same wording channel as sigrun-ext-codemode's
|
|
15
|
+
* `codemode_notice` (Task 5; consistency across both repos is a review
|
|
16
|
+
* criterion). Upstream ships BM25 ranking inside pi-durable itself, so
|
|
17
|
+
* there is no separate ranker dependency (rev-3 ruling: sigrun-tool-ranker
|
|
18
|
+
* DROPPED).
|
|
19
|
+
*
|
|
20
|
+
* Deferred-tool lifecycle (verified against pi-durable 1.2.0
|
|
21
|
+
* `dist/tool-search/tool-search.js` + `dist/harness/agent.js`): tools
|
|
22
|
+
* registered `deferred: true` (sigrun-ext-mcp's `exposure: "deferred"`)
|
|
23
|
+
* sit in `agent.deferred` — model-callable, NOT model-offered — until
|
|
24
|
+
* `tool_search` matches them (BM25 over name/description/parameter text,
|
|
25
|
+
* `DEFAULT_TOOL_SEARCH_LIMIT` 8) and returns
|
|
26
|
+
* `control: { addTools: <names> }`. The harness applies that to the
|
|
27
|
+
* conversation's `pi.agent.modelTools` (its `add`), so the NEXT request
|
|
28
|
+
* offers the loaded tools, and the write is on the conversation document —
|
|
29
|
+
* the loaded set travels the branch, forks included. A query matching
|
|
30
|
+
* nothing returns an EMPTY result ("No matching tools found."), never an
|
|
31
|
+
* error.
|
|
32
|
+
*/
|
|
33
|
+
import { createToolSearchExtension } from "@earendil-works/pi-durable/tool-search";
|
|
34
|
+
import { addToolSearchNotice } from "./extension.js";
|
|
35
|
+
/**
|
|
36
|
+
* The tool-search factory (the loader contract: no arguments). Upstream's
|
|
37
|
+
* extension is stateless (the search reads `agent.deferred` at execution
|
|
38
|
+
* time; ranking is pure), so one wiring has no lifecycle to close.
|
|
39
|
+
*/
|
|
40
|
+
export function createToolSearchWiring() {
|
|
41
|
+
return { extension: addToolSearchNotice(createToolSearchExtension()) };
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* The sigrun extension-package contract: the default export is a factory
|
|
45
|
+
* taking no arguments, returning `{ extension }`.
|
|
46
|
+
*/
|
|
47
|
+
export default createToolSearchWiring;
|
|
48
|
+
export { TOOL_SEARCH_NOTICE_SECTION_KEY, TOOL_SEARCH_NOT_OFFERED_NOTICE, renderToolSearchNotice, } from "./extension.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,55 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
"name": "@sigrun/ext-tool-search",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Tool-search extension for sigrun (pi-durable): the `tool_search` tool over deferred MCP tools \u2014 thin wrapper over pi-durable's own createToolSearchExtension",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"engines": {
|
|
7
|
+
"node": ">=22.19.0"
|
|
8
|
+
},
|
|
9
|
+
"main": "dist/index.js",
|
|
10
|
+
"types": "dist/index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"default": "./dist/index.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist",
|
|
19
|
+
"CHANGELOG.md"
|
|
20
|
+
],
|
|
21
|
+
"scripts": {
|
|
22
|
+
"test": "node scripts/check-manifest.mjs --expect-name @sigrun/ext-tool-search && vitest run",
|
|
23
|
+
"typecheck": "tsc --noEmit",
|
|
24
|
+
"build": "tsc -p tsconfig.build.json",
|
|
25
|
+
"prepare": "npm run build"
|
|
26
|
+
},
|
|
27
|
+
"peerDependencies": {
|
|
28
|
+
"@earendil-works/chord": "1.3.0",
|
|
29
|
+
"@earendil-works/pi-ai": "1.3.0",
|
|
30
|
+
"@earendil-works/pi-durable": "1.3.0"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@earendil-works/chord": "1.3.0",
|
|
34
|
+
"@earendil-works/pi-ai": "1.3.0",
|
|
35
|
+
"@earendil-works/pi-durable": "1.3.0",
|
|
36
|
+
"@sigrun/ext-mcp": "file:../sigrun-ext-mcp",
|
|
37
|
+
"@types/node": "^26.6.4",
|
|
38
|
+
"tsx": "^4.23.15",
|
|
39
|
+
"typescript": "^7.0.2",
|
|
40
|
+
"vitest": "^5.0.3"
|
|
41
|
+
},
|
|
42
|
+
"license": "MIT",
|
|
43
|
+
"repository": {
|
|
44
|
+
"type": "github",
|
|
45
|
+
"url": "git+https://github.com/sigrun-ai/sigrun-ext-tool-search.git"
|
|
46
|
+
},
|
|
47
|
+
"bugs": {
|
|
48
|
+
"url": "https://github.com/sigrun-ai/sigrun-ext-tool-search/issues"
|
|
49
|
+
},
|
|
50
|
+
"homepage": "https://github.com/sigrun-ai/sigrun-ext-tool-search#readme",
|
|
51
|
+
"publishConfig": {
|
|
52
|
+
"access": "public",
|
|
53
|
+
"provenance": true
|
|
54
|
+
}
|
|
55
|
+
}
|