@wyattjoh/rfc 0.3.1 → 0.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/README.md +24 -39
- package/package.json +2 -3
- package/src/agent-surface.ts +62 -24
- package/src/agent.ts +9 -2
- package/src/config.ts +5 -88
- package/src/index.ts +11 -2
- package/src/main.ts +82 -44
- package/src/mcp.ts +82 -112
- package/src/operations.ts +22 -12
- package/src/renderers.ts +179 -41
- package/src/live-evaluation-bin.ts +0 -15
- package/src/live-evaluation.ts +0 -215
package/README.md
CHANGED
|
@@ -10,18 +10,17 @@ Run the MCP server over stdio:
|
|
|
10
10
|
rfc mcp
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
An MCP host should launch that command directly and treat standard output as protocol traffic. The server advertises the complete
|
|
13
|
+
An MCP host should launch that command directly and treat standard output as protocol traffic. The server advertises the complete workflow in its initialization instructions and exposes the full Markdown reference at `rfc://docs/agent-workflow`, so a connected model does not need this repository's skill or direct CLI access.
|
|
14
14
|
|
|
15
15
|
The model-facing tools are:
|
|
16
16
|
|
|
17
|
-
- `
|
|
18
|
-
- `rfc_research_topic`
|
|
17
|
+
- `rfc_research`
|
|
19
18
|
- `rfc_verify_citation`
|
|
20
19
|
- `rfc_source_cache_status`
|
|
21
20
|
- `rfc_source_cache_remove`
|
|
22
21
|
- `rfc_auth_status`
|
|
23
22
|
|
|
24
|
-
Each successful tool call returns concise text plus the complete version-
|
|
23
|
+
Each successful tool call returns concise text plus the complete version-three result as validated structured content. Operational failures are MCP tool errors containing the same safe version-three error envelope as the CLI. A question that was not found and every citation verdict remain successful domain results. `rfc_source_cache_remove` requires `confirm: true` and is marked destructive and idempotent.
|
|
25
24
|
|
|
26
25
|
Provider credentials are intentionally outside the model-facing mutation surface. The MCP can inspect safe credential status but can never accept, reveal, add, or remove a key. Configure the credential through `rfc auth login` before launching the server. The stored key is resolved separately for every semantic tool call.
|
|
27
26
|
|
|
@@ -38,40 +37,41 @@ Those values are fixed for the MCP process and never appear in tool input schema
|
|
|
38
37
|
|
|
39
38
|
## Process protocol
|
|
40
39
|
|
|
41
|
-
Research uses the version-
|
|
40
|
+
Research uses the version-three public protocol and accepts canonical JSON on standard input. A request supplies one to four `questions` plus `rfcs`, `searchTerms`, or both, each with one to four entries:
|
|
42
41
|
|
|
43
42
|
```json
|
|
44
43
|
{
|
|
45
|
-
"schemaVersion":
|
|
46
|
-
"
|
|
47
|
-
"
|
|
44
|
+
"schemaVersion": 3,
|
|
45
|
+
"questions": ["What does the 429 status code mean?", "Which header says how long to wait?"],
|
|
46
|
+
"rfcs": ["RFC6585", "RFC9110"]
|
|
48
47
|
}
|
|
49
48
|
```
|
|
50
49
|
|
|
51
|
-
A topic request sets `rfc` to `null` and supplies one to four ordered search terms:
|
|
52
|
-
|
|
53
50
|
```json
|
|
54
51
|
{
|
|
55
|
-
"schemaVersion":
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"searchTerms": ["HTTP semantics", "client request"]
|
|
52
|
+
"schemaVersion": 3,
|
|
53
|
+
"questions": ["How long may a cache reuse a response?"],
|
|
54
|
+
"searchTerms": ["HTTP caching"]
|
|
59
55
|
}
|
|
60
56
|
```
|
|
61
57
|
|
|
62
|
-
When standard input contains non-whitespace input, it is authoritative, convenience flags
|
|
58
|
+
When standard input contains non-whitespace input, it is authoritative, convenience flags are ignored, and JSON output remains the default. When standard input is empty, pass `-q`/`--question` once per question, plus up to four `-r`/`--rfc` and up to four `--search-term` flags. Argument-based operations render human-readable output by default; pass `--format json` for machine-readable output or `--format human` to render structured standard input for a person. `--cache-directory`, `--datatracker-api-url`, and `--typesafe-api-url` are available for deterministic preflight and local testing. Corpus-wide metadata management and bulk source operations are not part of the public client or CLI.
|
|
59
|
+
|
|
60
|
+
Named RFCs are looked up exactly and their current successors are found by recursively following only bounded updating or obsoleting relationships. Topic research issues one bounded title query and one bounded abstract query for each caller-supplied term and deterministically merges candidates in term order. Named RFCs, their current successors, and topic hits form one candidate pool of at most 32 RFCs. Datatracker response bodies are streamed through a 1 MiB cap and decoded with bounded field lengths before any metadata reaches TypeSafe. Only the explicit search terms are sent to Datatracker; the questions are not. Search terms appear in full Datatracker request URLs and can therefore appear in retrieval diagnostics, errors, and upstream access logs. An empty pool returns every question as not found without invoking TypeSafe.
|
|
61
|
+
|
|
62
|
+
Retrieval then makes three kinds of TypeSafe Jev requests. One request ranks the pool for every question and keeps at most two RFCs per question that clear the relevance floor, plus the requested or current partner of a kept RFC when it also clears the floor; ranking is skipped when the pool holds one RFC, and that RFC's `relevance` is `null`. One request per kept RFC chooses up to three sections from its table of contents, using a two-level chapter-then-subsection choice for RFCs with more than 250 sections. One request per kept RFC chooses up to three paragraphs from those sections and assigns each a verdict; an RFC judged not to contain an answer is dropped for that question. The floors and limits live in the exported `retrievalPolicy` and are uncalibrated working values. [ADR 0005](../../docs/adr/0005-jev-ranked-retrieval-without-research-statuses.md) records the design.
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
The result is a `research_result` whose `answers` hold, per question, `found`, the `searched` RFC identifiers, and ranked `hits`. Each hit carries the `rfc` document, its `role` (`requested`, `current`, or `discovered`), `relevance`, an overall `verdict`, and its `passages`. Each passage contains an exact paragraph `quote`, a nullable section heading, its selection `probability`, a `verdict` (`supports`, `partial`, `says_nothing`, or `contradicts`), and provenance with absolute UTF-8 byte offsets into the SHA-256 source, the declared `offsetUnit: "utf8-byte"`, the canonical URL, and the fetch time. Paragraphs never include page furniture; a paragraph interrupted by a page break is returned as two paragraphs. When `rfcs` were supplied, `currency` holds one `{ requested, current, complete, paths }` report per named RFC: its current successors and the relationship path to each, with `complete: false` when a successor was unresolved or cut off by a traversal bound (agent output then appends "(incomplete: some successors were not fetched)"), so a `current` hit is never silently substituted for the RFC the caller named. Human output prints one line per passage naming the RFC, section, verdict, relevance, and `current successor` when applicable, followed by the quote and its byte range.
|
|
65
65
|
|
|
66
|
-
Requested RFC Editor plain text is cached individually with its canonical URL, integrity hash, ETag, and HTTP freshness deadline. Fresh text is reused without a network request. Stale text is conditionally revalidated and is never used when authoritative revalidation fails. `rfc cache status RFC9110` reports a local hit or miss, while `rfc cache remove RFC9110` removes only that named entry; `--rfc RFC9110` remains an equivalent flag form. Neither command performs network access, and no bulk cache command is provided. Source retrieval accepts only a `200` body with an explicit `text/plain` Content-Type or a `304` conditional response, enforces one ten-second deadline across the complete operation, and rejects bodies above 8 MiB while streaming.
|
|
66
|
+
Requested RFC Editor plain text is cached individually with its canonical URL, integrity hash, ETag, and HTTP freshness deadline. Fresh text is reused without a network request. Stale text is conditionally revalidated and is never used when authoritative revalidation fails. `rfc cache status RFC9110` reports a local hit or miss, while `rfc cache remove RFC9110` removes only that named entry; `--rfc RFC9110` remains an equivalent flag form. Neither command performs network access, and no bulk cache command is provided. Source retrieval accepts only a `200` body with an explicit `text/plain` Content-Type or a `304` conditional response, enforces one ten-second deadline across the complete operation, and rejects bodies above 8 MiB while streaming. A named RFC whose source cannot be loaded fails the request; a successor or topic hit whose source cannot be fetched is dropped.
|
|
67
67
|
|
|
68
|
-
|
|
68
|
+
Research diagnostics report the policy version, requested and resolved models, usage and estimated cost, per-stage timings (`metadataMs`, `sourceMs`, `rankMs`, `sectionMs`, `paragraphMs`, `totalMs`), the candidate pool and ranked counts, and a retrieval trace with full upstream URLs, attempts and statuses, the source-cache outcome, and traversal bounds. Topic traces distinguish `upstreamRows`, deduplicated `uniqueCandidates`, the 32-document `mergeLimit`, `semanticCandidates` sent to TypeSafe, and `selectedSources` loaded from the RFC Editor. Public RFC documents omit relationship fields. Topic discovery accepts each bounded first page and reports `topicTruncated: true` when Datatracker advertises additional rows or the deterministic merge reaches its cap; it never follows unbounded pagination.
|
|
69
69
|
|
|
70
70
|
Citation verification accepts canonical JSON with an RFC identifier, factual claim, exact quotation, and optional offset:
|
|
71
71
|
|
|
72
72
|
```json
|
|
73
73
|
{
|
|
74
|
-
"schemaVersion":
|
|
74
|
+
"schemaVersion": 3,
|
|
75
75
|
"rfc": "RFC9110",
|
|
76
76
|
"claim": "The client must send a request.",
|
|
77
77
|
"quote": "The client MUST send a request.",
|
|
@@ -79,17 +79,17 @@ Citation verification accepts canonical JSON with an RFC identifier, factual cla
|
|
|
79
79
|
}
|
|
80
80
|
```
|
|
81
81
|
|
|
82
|
-
The optional `offset` is an absolute UTF-8 byte offset into the exact authoritative RFC Editor source identified by the returned SHA-256 `sourceHash`; it is not a JavaScript UTF-16 string index. Results declare this unit as `provenance.offsetUnit: "utf8-byte"`, and `startOffset`/`endOffset` can be used to slice the hashed source bytes and recover the exact returned quote. Use it with `rfc verify-citation < citation.json`, pass positional `RFC`, `claim`, and `quote` arguments, or provide `--rfc`, `--claim`, `--quote`, and optional `--offset` convenience flags. The verifier performs one request-local exact Datatracker document lookup without successor traversal, loads the live source, locates the quote before making a semantic request, returns `fabricated` for absent text without calling TypeSafe, and rejects ambiguous repeated quotes unless an exact offset selects one occurrence. Present quotes receive version-
|
|
82
|
+
The optional `offset` is an absolute UTF-8 byte offset into the exact authoritative RFC Editor source identified by the returned SHA-256 `sourceHash`; it is not a JavaScript UTF-16 string index. Results declare this unit as `provenance.offsetUnit: "utf8-byte"`, and `startOffset`/`endOffset` can be used to slice the hashed source bytes and recover the exact returned quote. Use it with `rfc verify-citation < citation.json`, pass positional `RFC`, `claim`, and `quote` arguments, or provide `--rfc`, `--claim`, `--quote`, and optional `--offset` convenience flags. The verifier performs one request-local exact Datatracker document lookup without successor traversal, loads the live source, locates the quote before making a semantic request, returns `fabricated` for absent text without calling TypeSafe, and rejects ambiguous repeated quotes unless an exact offset selects one occurrence. Present quotes receive version-three `verified`, `unsupported`, or `contradicted` results with exact provenance, probabilities, confidence, model identity, usage, timings, and retrieval traces including source-cache outcomes.
|
|
83
83
|
|
|
84
84
|
Errors are versioned JSON envelopes on standard error and return a nonzero exit code. Valid domain outcomes, including `fabricated`, use standard output and a zero exit code.
|
|
85
85
|
|
|
86
86
|
Research and citation results report provider usage in `diagnostics.usage`. They also include `diagnostics.inputCost.estimatedUsd` and the `rateUsdPerMillionTokens` used for the estimate. Jev 1.13 input is priced at $0.042 per million tokens; output tokens are free. Missing usage or an unknown provider-resolved model leaves the estimate null rather than applying an assumed price. Human output prints the input-token count and estimated USD cost directly.
|
|
87
87
|
|
|
88
|
-
Every successful research or citation operation also updates the per-user running total at `~/.config/rfc/usage.json`. The versioned JSON file separates priced tokens, unpriced tokens, and operations with no provider-reported usage so `estimatedInputCostUsd` is never mistaken for a complete estimate when pricing is unavailable. Updates use a lock and atomic rename to preserve concurrent CLI invocations. A persistence failure leaves the successful result on standard output and emits a version-
|
|
88
|
+
Every successful research or citation operation also updates the per-user running total at `~/.config/rfc/usage.json`. The versioned JSON file separates priced tokens, unpriced tokens, and operations with no provider-reported usage so `estimatedInputCostUsd` is never mistaken for a complete estimate when pricing is unavailable. Updates use a lock and atomic rename to preserve concurrent CLI invocations. A persistence failure leaves the successful result on standard output and emits a version-three `usage_accounting_failed` warning on standard error instead of encouraging a retry that could incur the provider charge again.
|
|
89
89
|
|
|
90
90
|
Run `rfc costs` to read those cumulative global totals without changing them. Its default human output prints the update timestamp, operation and token coverage, and estimated USD total. `rfc costs --format json` emits the same validated `rfc_usage_totals` document stored on disk. When the usage file does not exist yet, the command reports zero totals and does not create it.
|
|
91
91
|
|
|
92
|
-
The opt-in `bun run benchmark:topic` command performs a normal topic research warm-up and then repeats the same schema-version-
|
|
92
|
+
The opt-in `bun run benchmark:topic` command performs a normal topic research warm-up and then repeats the same schema-version-three request; it has no prefetch-only path. Set `RFC_TOPIC_BENCHMARK=1`, `RFC_CACHE_DIRECTORY`, and optionally `RFC_TOPIC_BENCHMARK_SEARCH_TERMS` as a JSON array of ordered terms. The JSON report separates live RFC discovery, RFC source-cache, rank, section, paragraph, semantic, and total p95 timings and includes the warm-up and measured retrieval traces. Its latency target is provisional, so this explicit benchmark does not claim a release pass and never runs in the normal test suite.
|
|
93
93
|
|
|
94
94
|
## Provider credentials
|
|
95
95
|
|
|
@@ -114,23 +114,8 @@ Bare `auth` reports only whether a key is configured and the service/name identi
|
|
|
114
114
|
|
|
115
115
|
Bun maps the store to the host credential service: macOS Keychain, Linux Secret Service (libsecret, such as GNOME Keyring or KWallet), or Windows Credential Manager. Linux requires a running and unlocked Secret Service daemon; macOS requires Keychain access; Windows requires Credential Manager. This repository pins Bun `1.4.2` in `package.json` and tests against that version because `Bun.secrets` is experimental and may change.
|
|
116
116
|
|
|
117
|
-
To migrate an existing setup, run `rfc auth login`, verify with `rfc auth`, then delete the obsolete plaintext, `.env`, Varlock, dotenv, or 1Password-backed TypeSafe API-key configuration. Research
|
|
118
|
-
|
|
119
|
-
## Precision calibration
|
|
120
|
-
|
|
121
|
-
Automatic answering is off. `answered` requires a locally present calibration report proving a passing release gate, a recorded human acceptance, and explicit runtime enablement; anything weaker fails closed to `needs_review`. The most recent calibration was **rejected**, so a published install returns evidence, provenance, and a non-answer status.
|
|
122
|
-
|
|
123
|
-
Run a calibration against the live provider only through the explicit evaluator, after storing a credential. It costs money and reaches the network:
|
|
124
|
-
|
|
125
|
-
```sh
|
|
126
|
-
rfc auth
|
|
127
|
-
bun run evaluate:live
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
It writes a sanitized report to `.scratch/rfc-evaluation-report.json`, exiting zero for a passing gate and two for a complete report that fails review. The report never contains credentials, prompts, questions beyond the committed corpus, or provider reasoning.
|
|
131
|
-
|
|
132
|
-
What the corpus measures, what the report contains, and the recorded 2026-09-21 rejection are in [ADR 0004](../../docs/adr/0004-gate-automatic-answers-on-a-reviewed-calibration.md). The durable decision itself is committed in `packages/rfc-core/src/precision-v2-release-decision.ts`.
|
|
117
|
+
To migrate an existing setup, run `rfc auth login`, verify with `rfc auth`, then delete the obsolete plaintext, `.env`, Varlock, dotenv, or 1Password-backed TypeSafe API-key configuration. Research and citation verification both resolve this same credential lazily before constructing the provider.
|
|
133
118
|
|
|
134
119
|
## Configuration
|
|
135
120
|
|
|
136
|
-
Non-secret model,
|
|
121
|
+
Non-secret model, cache, and output settings use typed defaults in the CLI composition root. They are not loaded from Varlock, dotenv, `.env` files, or ordinary environment variables. `bunfig.toml` disables Bun dotenv loading. Use explicit CLI flags for command-specific values such as cache and provider URLs; the credential store is the only authority for the TypeSafe API key.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wyattjoh/rfc",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Agent-facing CLI and MCP server for evidence-grounded IETF RFC research.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -35,13 +35,12 @@
|
|
|
35
35
|
"scripts": {
|
|
36
36
|
"build": "bun build src/bin.ts --outdir dist --target bun",
|
|
37
37
|
"test": "bun test",
|
|
38
|
-
"evaluate:live": "cd ../.. && bun run packages/rfc/src/live-evaluation-bin.ts",
|
|
39
38
|
"typecheck": "tsc --noEmit -p tsconfig.json"
|
|
40
39
|
},
|
|
41
40
|
"dependencies": {
|
|
42
41
|
"@effect/platform-node": "4.0.0-rc.117",
|
|
43
42
|
"@modelcontextprotocol/server": "2.0.0",
|
|
44
|
-
"@wyattjoh/rfc-core": "0.
|
|
43
|
+
"@wyattjoh/rfc-core": "0.2.0",
|
|
45
44
|
"effect": "4.0.0-rc.117"
|
|
46
45
|
},
|
|
47
46
|
"devDependencies": {
|
package/src/agent-surface.ts
CHANGED
|
@@ -4,23 +4,68 @@
|
|
|
4
4
|
export const rfcMcpAgentReferenceUri = "rfc://docs/agent-workflow" as const;
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* Clients may truncate MCP server instructions; Claude Code keeps about 2 KB.
|
|
8
8
|
*/
|
|
9
|
-
export const
|
|
9
|
+
export const rfcMcpInstructionsCharacterBudget = 2_000;
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Build the cross-tool workflow for one agent surface.
|
|
13
|
+
*
|
|
14
|
+
* Each rule is stated once. Search-term privacy lives in the `searchTerms`
|
|
15
|
+
* parameter description and citation-verification limits in the
|
|
16
|
+
* `rfc_verify_citation` description. The MCP variant adds the secret-path and
|
|
17
|
+
* resource rules; Pi has neither. Rules that bound tool calls come first and
|
|
18
|
+
* the resource rule last, opening with "Skip", so a client that truncates the
|
|
19
|
+
* instructions drops only guidance whose absence is already the default.
|
|
20
|
+
*
|
|
21
|
+
* @param surface Agent surface the instructions are delivered to.
|
|
22
|
+
* @returns Paragraphs of model-facing workflow instructions.
|
|
23
|
+
*/
|
|
24
|
+
const rfcAgentInstructions = (surface: "mcp" | "pi"): string =>
|
|
25
|
+
[
|
|
26
|
+
`Answer published IETF RFC questions only from ${surface === "mcp" ? "this server" : "these tools"}, never from memory or another provider. Make one rfc_research call per user request, with each fact you need as its own entry in questions. Pass rfcs when you know the RFC numbers and searchTerms otherwise; both may be combined.`,
|
|
27
|
+
"Answer from the returned passages and cite only the RFC and section shown. A passage marked current successor comes from the RFC that replaced the one named; say so rather than attributing it to the named RFC.",
|
|
28
|
+
"When a question is not found, you may make one follow-up rfc_research call with other rfcs or searchTerms; RFC titles often differ from common names. Never re-research or re-verify returned passages. Use rfc_verify_citation only for a user-supplied quotation or an explicitly requested check.",
|
|
29
|
+
`Tool errors are final: keep the typed error code and stop; never substitute memory or another provider. For a missing credential, ask the human operator to run rfc auth login; never request or accept the secret${surface === "mcp" ? " through MCP" : ""}. Never retry a successful paid call over a usage-accounting warning.`,
|
|
30
|
+
...(surface === "mcp"
|
|
31
|
+
? [
|
|
32
|
+
`Skip ${rfcMcpAgentReferenceUri} for ordinary research; read it only for an operational failure or a provenance, privacy, cost, or cache question.`,
|
|
33
|
+
]
|
|
34
|
+
: []),
|
|
35
|
+
].join("\n");
|
|
18
36
|
|
|
19
|
-
|
|
37
|
+
/**
|
|
38
|
+
* Cross-tool instructions sent as the MCP server's initialization instructions.
|
|
39
|
+
*/
|
|
40
|
+
export const rfcMcpInstructions = rfcAgentInstructions("mcp");
|
|
20
41
|
|
|
21
|
-
|
|
42
|
+
/**
|
|
43
|
+
* Cross-tool instructions injected into the Pi system prompt, without the
|
|
44
|
+
* MCP-only secret-path and resource rules.
|
|
45
|
+
*/
|
|
46
|
+
export const rfcPiInstructions = rfcAgentInstructions("pi");
|
|
22
47
|
|
|
23
|
-
|
|
48
|
+
/**
|
|
49
|
+
* Model-facing tool parameter descriptions shared by the MCP and Pi schemas.
|
|
50
|
+
*/
|
|
51
|
+
export const rfcAgentParameterDescriptions = {
|
|
52
|
+
questions:
|
|
53
|
+
"One to four questions, one per fact you need; each is answered independently from the same RFCs",
|
|
54
|
+
question: "One self-contained question",
|
|
55
|
+
rfcs: "One to four published RFC identifiers to search, for example RFC9110; their current successors are searched too",
|
|
56
|
+
rfc: "Exact published RFC identifier, for example RFC9110",
|
|
57
|
+
searchTerms:
|
|
58
|
+
"One to four ordered topic-discovery terms for finding RFCs whose numbers you do not know; preserve caller order. Terms reach upstream logs, so never include private or user-specific details. Standard technical terms, including title words of an RFC you expect to match, are fine; never send a full question as a term unless the user explicitly chose it.",
|
|
59
|
+
searchTerm:
|
|
60
|
+
'Deliberate topic-discovery term sent verbatim in Datatracker query URLs and upstream logs. Matched as a literal case-insensitive substring of an RFC title or abstract, so use a short noun phrase such as "DNS over TLS"; a sentence fragment such as "DNS over TLS default port" matches nothing.',
|
|
61
|
+
citationRfc: "Exact published RFC identifier containing the quotation",
|
|
62
|
+
claim: "One factual claim to check",
|
|
63
|
+
quote: "Exact unchanged RFC quotation",
|
|
64
|
+
offset:
|
|
65
|
+
"Absolute UTF-8 byte offset copied from a research quote range; omit for a unique quotation",
|
|
66
|
+
cacheRfc: "Exact named RFC source-cache entry, for example RFC9110",
|
|
67
|
+
confirm: "Must be true to confirm removal of the named cache entry",
|
|
68
|
+
} as const;
|
|
24
69
|
|
|
25
70
|
const rfcAgentToolAnnotations = {
|
|
26
71
|
semantic: {
|
|
@@ -47,25 +92,18 @@ const rfcAgentToolAnnotations = {
|
|
|
47
92
|
* Shared model-facing metadata for the MCP server and native agent integrations.
|
|
48
93
|
*/
|
|
49
94
|
export const rfcAgentToolMetadata = {
|
|
50
|
-
|
|
51
|
-
name: "
|
|
52
|
-
title: "Research
|
|
53
|
-
description:
|
|
54
|
-
"Inputs: question, rfc. Research one atomic question against a known published RFC. If evidence or a review candidate is returned, answer from it without a verification call. Includes bounded RFC currency traversal, provenance, status, and diagnostics.",
|
|
55
|
-
annotations: rfcAgentToolAnnotations.semantic,
|
|
56
|
-
},
|
|
57
|
-
researchTopic: {
|
|
58
|
-
name: "rfc_research_topic",
|
|
59
|
-
title: "Discover and research RFCs",
|
|
95
|
+
research: {
|
|
96
|
+
name: "rfc_research",
|
|
97
|
+
title: "Research RFCs",
|
|
60
98
|
description:
|
|
61
|
-
"Inputs:
|
|
99
|
+
"Inputs: questions (1-4) plus rfcs and/or searchTerms (1-4 each). Ranks the named RFCs, their current successors, and topic matches, then returns answers in question order (answers[i] is for questions[i]) with the exact paragraphs that answer it with RFC, section, verdict (supports, partial, says_nothing, contradicts), and UTF-8 byte range, or the RFCs that did not contain an answer.",
|
|
62
100
|
annotations: rfcAgentToolAnnotations.semantic,
|
|
63
101
|
},
|
|
64
102
|
verifyCitation: {
|
|
65
103
|
name: "rfc_verify_citation",
|
|
66
104
|
title: "Verify an RFC citation",
|
|
67
105
|
description:
|
|
68
|
-
"Inputs: rfc, claim, quote; optional offset. Check one factual claim against one exact RFC quotation. Returns a verified, unsupported, contradicted, or fabricated verdict with canonical provenance.",
|
|
106
|
+
"Inputs: rfc, claim, quote; optional offset. Check one factual claim against one exact RFC quotation. Returns a verified, unsupported, contradicted, or fabricated verdict with canonical provenance. Verify at most two paraphrased claims, once each, using the exact returned quote and its UTF-8 byte offset; never guess wording or offsets. If a direct verification verdict is fabricated, use at most one research call to locate current wording and one verification call for that replacement. Unsupported, contradicted, or fabricated verdicts cannot support an unqualified claim.",
|
|
69
107
|
annotations: rfcAgentToolAnnotations.semantic,
|
|
70
108
|
},
|
|
71
109
|
sourceCacheStatus: {
|
package/src/agent.ts
CHANGED
|
@@ -3,11 +3,18 @@ export {
|
|
|
3
3
|
datatrackerTopicSearchTermMaximumCharacters,
|
|
4
4
|
schemaVersion,
|
|
5
5
|
} from "@wyattjoh/rfc-core/protocol";
|
|
6
|
-
export { rfcAgentToolMetadata, rfcMcpInstructions } from "./agent-surface";
|
|
7
6
|
export {
|
|
7
|
+
rfcAgentParameterDescriptions,
|
|
8
|
+
rfcAgentToolMetadata,
|
|
9
|
+
rfcMcpInstructions,
|
|
10
|
+
rfcPiInstructions,
|
|
11
|
+
} from "./agent-surface";
|
|
12
|
+
export {
|
|
13
|
+
citationVerificationAgentJson,
|
|
8
14
|
renderAuthStatus,
|
|
9
15
|
renderCitationVerification,
|
|
10
|
-
|
|
16
|
+
renderResearchResult,
|
|
17
|
+
researchResultAgentJson,
|
|
11
18
|
renderSourceCacheRemove,
|
|
12
19
|
renderSourceCacheStatus,
|
|
13
20
|
} from "./renderers";
|
package/src/config.ts
CHANGED
|
@@ -1,25 +1,11 @@
|
|
|
1
|
-
import { readFileSync } from "node:fs";
|
|
2
1
|
import { Schema } from "effect";
|
|
3
|
-
import {
|
|
4
|
-
automaticAnswerActivationFromReport,
|
|
5
|
-
evaluationModelAlias,
|
|
6
|
-
evaluationPolicy,
|
|
7
|
-
pinnedJevModel,
|
|
8
|
-
} from "@wyattjoh/rfc-core";
|
|
9
|
-
import type { AutomaticAnswerActivation } from "@wyattjoh/rfc-core";
|
|
2
|
+
import { retrievalPolicy } from "@wyattjoh/rfc-core";
|
|
10
3
|
|
|
11
4
|
/**
|
|
12
5
|
* Schema for non-secret configuration consumed by the CLI composition root.
|
|
13
6
|
*/
|
|
14
7
|
export const RfcCliConfigSchema = Schema.Struct({
|
|
15
|
-
modelAlias: Schema.Literal(
|
|
16
|
-
policyPreset: Schema.Literal(evaluationPolicy.policyVersion),
|
|
17
|
-
evaluationModel: Schema.Literal(evaluationModelAlias),
|
|
18
|
-
pinnedModel: Schema.Literal(pinnedJevModel),
|
|
19
|
-
liveEvaluation: Schema.Boolean,
|
|
20
|
-
automaticAnswerEnabled: Schema.Boolean,
|
|
21
|
-
evaluationCacheDirectory: Schema.NonEmptyString,
|
|
22
|
-
evaluationOutput: Schema.NonEmptyString,
|
|
8
|
+
modelAlias: Schema.Literal(retrievalPolicy.pinnedModel),
|
|
23
9
|
});
|
|
24
10
|
|
|
25
11
|
/**
|
|
@@ -28,87 +14,18 @@ export const RfcCliConfigSchema = Schema.Struct({
|
|
|
28
14
|
*/
|
|
29
15
|
export type RfcCliConfig = Schema.Schema.Type<typeof RfcCliConfigSchema>;
|
|
30
16
|
|
|
31
|
-
/**
|
|
32
|
-
* Explicit non-secret configuration overrides used by the live evaluator and
|
|
33
|
-
* deterministic callers. Every field is intentionally typed and non-secret.
|
|
34
|
-
*/
|
|
35
|
-
export interface RfcCliConfigOverrides {
|
|
36
|
-
/**
|
|
37
|
-
* Whether the caller explicitly enabled the live evaluator.
|
|
38
|
-
*/
|
|
39
|
-
readonly liveEvaluation: boolean | undefined;
|
|
40
|
-
/**
|
|
41
|
-
* Whether a reviewed calibration report may activate answered results.
|
|
42
|
-
*/
|
|
43
|
-
readonly automaticAnswerEnabled: boolean | undefined;
|
|
44
|
-
/**
|
|
45
|
-
* Directory used for evaluation source caches.
|
|
46
|
-
*/
|
|
47
|
-
readonly evaluationCacheDirectory: string | undefined;
|
|
48
|
-
/**
|
|
49
|
-
* Path used for the sanitized evaluation report.
|
|
50
|
-
*/
|
|
51
|
-
readonly evaluationOutput: string | undefined;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const defaultConfigValue = {
|
|
55
|
-
modelAlias: pinnedJevModel,
|
|
56
|
-
policyPreset: evaluationPolicy.policyVersion,
|
|
57
|
-
evaluationModel: evaluationModelAlias,
|
|
58
|
-
pinnedModel: pinnedJevModel,
|
|
59
|
-
liveEvaluation: false,
|
|
60
|
-
automaticAnswerEnabled: false,
|
|
61
|
-
evaluationCacheDirectory: ".scratch/rfc-evaluation-cache",
|
|
62
|
-
evaluationOutput: ".scratch/rfc-evaluation-report.json",
|
|
63
|
-
} satisfies RfcCliConfig;
|
|
64
|
-
|
|
65
|
-
const noOverrides: RfcCliConfigOverrides = {
|
|
66
|
-
liveEvaluation: undefined,
|
|
67
|
-
automaticAnswerEnabled: undefined,
|
|
68
|
-
evaluationCacheDirectory: undefined,
|
|
69
|
-
evaluationOutput: undefined,
|
|
70
|
-
};
|
|
71
|
-
|
|
72
17
|
/**
|
|
73
18
|
* The typed non-secret defaults used by ordinary CLI commands.
|
|
74
19
|
*/
|
|
75
20
|
export const defaultCliConfig: RfcCliConfig = Object.freeze(
|
|
76
|
-
Schema.decodeUnknownSync(RfcCliConfigSchema)(
|
|
21
|
+
Schema.decodeUnknownSync(RfcCliConfigSchema)({ modelAlias: retrievalPolicy.pinnedModel }),
|
|
77
22
|
);
|
|
78
23
|
|
|
79
24
|
/**
|
|
80
25
|
* Read typed non-secret CLI configuration without consulting environment
|
|
81
26
|
* variables, dotenv files, or a credential store.
|
|
82
27
|
*
|
|
83
|
-
* @param overrides Explicit non-secret values supplied by a command or test.
|
|
84
28
|
* @returns Schema-validated CLI configuration.
|
|
85
29
|
*/
|
|
86
|
-
export const readCliConfig = (
|
|
87
|
-
Schema.decodeUnknownSync(RfcCliConfigSchema)(
|
|
88
|
-
...defaultCliConfig,
|
|
89
|
-
liveEvaluation: overrides.liveEvaluation ?? defaultCliConfig.liveEvaluation,
|
|
90
|
-
automaticAnswerEnabled:
|
|
91
|
-
overrides.automaticAnswerEnabled ?? defaultCliConfig.automaticAnswerEnabled,
|
|
92
|
-
evaluationCacheDirectory:
|
|
93
|
-
overrides.evaluationCacheDirectory ?? defaultCliConfig.evaluationCacheDirectory,
|
|
94
|
-
evaluationOutput: overrides.evaluationOutput ?? defaultCliConfig.evaluationOutput,
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Resolve automatic-answer activation from an explicit opt-in and a passing
|
|
99
|
-
* calibration artifact with the current release attestation.
|
|
100
|
-
*
|
|
101
|
-
* @param config Validated non-secret CLI configuration.
|
|
102
|
-
* @returns An opaque activation proof, or undefined when activation fails closed.
|
|
103
|
-
*/
|
|
104
|
-
export const automaticAnswerActivationFor = (
|
|
105
|
-
config: RfcCliConfig,
|
|
106
|
-
): AutomaticAnswerActivation | undefined => {
|
|
107
|
-
if (!config.automaticAnswerEnabled) return undefined;
|
|
108
|
-
try {
|
|
109
|
-
const report = JSON.parse(readFileSync(config.evaluationOutput, "utf8")) as unknown;
|
|
110
|
-
return automaticAnswerActivationFromReport(report);
|
|
111
|
-
} catch {
|
|
112
|
-
return undefined;
|
|
113
|
-
}
|
|
114
|
-
};
|
|
30
|
+
export const readCliConfig = (): RfcCliConfig =>
|
|
31
|
+
Schema.decodeUnknownSync(RfcCliConfigSchema)(defaultCliConfig);
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
export { command, makeDefaultCliDependencies, run, toCliErrorEnvelope } from "./main";
|
|
2
|
-
export {
|
|
2
|
+
export {
|
|
3
|
+
rfcAgentParameterDescriptions,
|
|
4
|
+
rfcAgentToolMetadata,
|
|
5
|
+
rfcMcpAgentReferenceUri,
|
|
6
|
+
rfcMcpInstructions,
|
|
7
|
+
rfcMcpInstructionsCharacterBudget,
|
|
8
|
+
rfcPiInstructions,
|
|
9
|
+
} from "./agent-surface";
|
|
3
10
|
export { createRfcMcpServer, rfcMcpAgentReference, runRfcMcpServer } from "./mcp";
|
|
4
11
|
export {
|
|
5
12
|
executeAuthStatus,
|
|
@@ -7,9 +14,11 @@ export {
|
|
|
7
14
|
executeResearch,
|
|
8
15
|
executeSourceCacheRemove,
|
|
9
16
|
executeSourceCacheStatus,
|
|
17
|
+
citationVerificationAgentJson,
|
|
10
18
|
renderAuthStatus,
|
|
11
19
|
renderCitationVerification,
|
|
12
|
-
|
|
20
|
+
renderResearchResult,
|
|
21
|
+
researchResultAgentJson,
|
|
13
22
|
renderSourceCacheRemove,
|
|
14
23
|
renderSourceCacheStatus,
|
|
15
24
|
toRfcOperationErrorEnvelope,
|