@autorag/librarian 2.8.0 → 2.10.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/NOTICE +4 -4
- package/README.md +120 -24
- package/dist/agent/agent.d.ts +147 -78
- package/dist/agent/answer-citations.d.ts +22 -0
- package/dist/agent/answer-guidelines.d.ts +9 -9
- package/dist/agent/citations.d.ts +42 -7
- package/dist/agent/datasource-skill.d.ts +30 -16
- package/dist/agent/evidence-judgment.d.ts +58 -0
- package/dist/agent/evidence-ledger.d.ts +54 -0
- package/dist/agent/evidence-origins.d.ts +49 -0
- package/dist/agent/index.d.ts +2 -2
- package/dist/agent/jikji-find-tool.d.ts +2 -1
- package/dist/agent/pi-session.d.ts +8 -1
- package/dist/agent/query-peer-tool.d.ts +3 -0
- package/dist/agent/query-routing.d.ts +71 -10
- package/dist/agent/{emit-results-tool.d.ts → results.d.ts} +11 -11
- package/dist/agent/search-all-tool.d.ts +5 -5
- package/dist/agent/search-documents.d.ts +14 -27
- package/dist/agent/search-minsync-tool.d.ts +5 -5
- package/dist/agent/search-single-datasource-tool.d.ts +9 -8
- package/dist/agent/self-config.d.ts +40 -0
- package/dist/agent/system-prompt.d.ts +2 -3
- package/dist/agent/web-fetch-tool.d.ts +2 -1
- package/dist/agent/web-search-tool.d.ts +2 -1
- package/dist/cli/commands/evidence.d.ts +2 -2
- package/dist/cli/commands/memory.d.ts +1 -1
- package/dist/cli/commands/report.d.ts +2 -2
- package/dist/cli/commands/tui.d.ts +3 -2
- package/dist/cli/config.d.ts +16 -8
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.js +11133 -10103
- package/dist/cli/output.d.ts +2 -6
- package/dist/cloud/authorize.d.ts +12 -0
- package/dist/cloud/callback-server.d.ts +33 -0
- package/dist/cloud/callback.d.ts +23 -0
- package/dist/cloud/config.d.ts +23 -0
- package/dist/cloud/errors.d.ts +46 -0
- package/dist/cloud/index.d.ts +12 -0
- package/dist/cloud/models.d.ts +32 -0
- package/dist/cloud/oauth-login.d.ts +22 -0
- package/dist/cloud/pkce.d.ts +20 -0
- package/dist/cloud/provider.d.ts +40 -0
- package/dist/cloud/token.d.ts +22 -0
- package/dist/config/home.d.ts +6 -0
- package/dist/core.d.ts +10 -21
- package/dist/core.js +15272 -14207
- package/dist/datasource/chunk-store.d.ts +2 -6
- package/dist/datasource/connector-skill.d.ts +2 -3
- package/dist/datasource/index.d.ts +2 -4
- package/dist/datasource/registry.d.ts +11 -13
- package/dist/datasource/scope.d.ts +19 -0
- package/dist/datasource/skills/github-gist/index.d.ts +1 -1
- package/dist/datasource/skills/github-gist/semantic.d.ts +3 -44
- package/dist/datasource/skills/github-gist/skill.d.ts +3 -3
- package/dist/datasource/types.d.ts +14 -28
- package/dist/embedding-runtime/gateway-embedder.d.ts +41 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +15488 -14359
- package/dist/language.d.ts +2 -1
- package/dist/mcp/index.js +15413 -14341
- package/dist/memory/check-memory-tool.d.ts +8 -4
- package/dist/memory/context.d.ts +51 -0
- package/dist/memory/index.d.ts +8 -1
- package/dist/memory/judged-evidence.d.ts +32 -0
- package/dist/memory/memory.d.ts +36 -120
- package/dist/memory/renderer.d.ts +16 -7
- package/dist/memory/similar-queries.d.ts +40 -0
- package/dist/minsync/client.d.ts +1 -1
- package/dist/minsync/errors.d.ts +14 -0
- package/dist/minsync/index.d.ts +1 -0
- package/dist/minsync/installer.d.ts +1 -1
- package/dist/minsync/method.d.ts +3 -3
- package/dist/mirror/sync.d.ts +5 -2
- package/dist/observability/run-log.d.ts +1 -1
- package/dist/parser/defaults.d.ts +16 -5
- package/dist/parser/index.d.ts +1 -1
- package/dist/parser/kordoc.d.ts +8 -1
- package/dist/parser/ocr-engines.d.ts +19 -0
- package/dist/retrieval/bm25.d.ts +19 -0
- package/dist/retrieval/engine.d.ts +17 -58
- package/dist/retrieval/index.d.ts +3 -2
- package/dist/retrieval/merger.d.ts +6 -0
- package/dist/retrieval/rerank.d.ts +2 -2
- package/dist/retrieval/selection.d.ts +33 -41
- package/dist/retrieval/types.d.ts +1 -26
- package/dist/web/search/format.d.ts +5 -2
- package/dist/web/search/index.d.ts +7 -1
- package/package.json +5 -5
- package/skills/autorag/SKILL.md +21 -22
- package/skills/autorag-doctor/SKILL.md +20 -15
- package/skills/autorag-lite-setup/SKILL.md +22 -19
- package/skills/autorag-setup/SKILL.md +34 -21
- package/dist/agent/fast-answer-tool.d.ts +0 -46
- package/dist/cli/commands/feedback.d.ts +0 -8
- package/dist/datasource/access-context.d.ts +0 -43
- package/dist/datasource/result-filter.d.ts +0 -64
- package/dist/parser/ocr.d.ts +0 -31
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { JevJudge } from "./jev-extension.js";
|
|
2
|
+
/**
|
|
3
|
+
* Retrieval memory stores only evidence that really supports the answer, so
|
|
4
|
+
* every cited piece is put back to Jev: does this evidence support the
|
|
5
|
+
* sentence it backs, and is answering the user's question impossible to trust
|
|
6
|
+
* without it? One batched call covers all of a run's evidence at once.
|
|
7
|
+
*
|
|
8
|
+
* The judgment is scoped per evidence and never merges units: a run can cite
|
|
9
|
+
* one result with several evidence pieces, each backing a different sentence,
|
|
10
|
+
* and only some of them needed.
|
|
11
|
+
*/
|
|
12
|
+
/** One evidence a final answer cites. */
|
|
13
|
+
export interface EvidenceJudgmentUnit {
|
|
14
|
+
/** Unique within one call, e.g. `${resultNumber}:${stableEvidenceId}`. */
|
|
15
|
+
readonly id: string;
|
|
16
|
+
/** The cited result [n] this evidence backs. */
|
|
17
|
+
readonly resultNumber: number;
|
|
18
|
+
/** That result's title. */
|
|
19
|
+
readonly title: string;
|
|
20
|
+
/** That result's summary. */
|
|
21
|
+
readonly summary: string;
|
|
22
|
+
/** The query that surfaced the evidence. */
|
|
23
|
+
readonly searchQuery: string;
|
|
24
|
+
/** Retrieval method that surfaced it. */
|
|
25
|
+
readonly method: string;
|
|
26
|
+
/** The evidence text. */
|
|
27
|
+
readonly excerpt: string;
|
|
28
|
+
}
|
|
29
|
+
export interface EvidenceJudgmentInput {
|
|
30
|
+
readonly question: string;
|
|
31
|
+
readonly answer: string;
|
|
32
|
+
readonly units: readonly EvidenceJudgmentUnit[];
|
|
33
|
+
}
|
|
34
|
+
export interface EvidenceJudgment {
|
|
35
|
+
/** Jev's P(evidence supports the question), per unit id, for every unit Jev answered. */
|
|
36
|
+
readonly probabilities: Readonly<Record<string, number>>;
|
|
37
|
+
/** Unit ids with probability >= {@link EVIDENCE_SUPPORT_THRESHOLD}, in input order. */
|
|
38
|
+
readonly kept: readonly string[];
|
|
39
|
+
/** Set when Jev gave no usable verdict for ANY unit (judge threw, or no numeric verdicts); verbatim error / hint text. Absent when Jev decided. */
|
|
40
|
+
readonly fallbackReason?: string;
|
|
41
|
+
}
|
|
42
|
+
/** Jev question id of one evidence support check. */
|
|
43
|
+
export declare const EVIDENCE_QUESTION_ID_PREFIX = "evidence:";
|
|
44
|
+
/** Jev question id of the support check for one evidence unit. */
|
|
45
|
+
export declare function evidenceQuestionId(unitId: string): string;
|
|
46
|
+
/**
|
|
47
|
+
* The sentences/lines of `answer` that cite result `number` with a bracketed
|
|
48
|
+
* `[number]` marker (not a markdown link `[n](...)`). Splits on sentence
|
|
49
|
+
* terminators followed by whitespace or end, so Korean and English bullet
|
|
50
|
+
* lists both survive, and dedupes so one sentence backs a result once.
|
|
51
|
+
*/
|
|
52
|
+
export declare function answerSentencesCiting(answer: string, number: number): string[];
|
|
53
|
+
/**
|
|
54
|
+
* Ask Jev, in one batched call, whether each cited evidence supports its backed
|
|
55
|
+
* sentence. Never throws: a rejecting judge keeps nothing and reports why, and
|
|
56
|
+
* a unit Jev left unanswered is simply absent from `probabilities`.
|
|
57
|
+
*/
|
|
58
|
+
export declare function judgeEvidence(judge: JevJudge, input: EvidenceJudgmentInput): Promise<EvidenceJudgment>;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { RetrievalResult } from "../retrieval/types.js";
|
|
2
|
+
import type { AutoRAGEvidenceRef } from "./results.js";
|
|
3
|
+
export interface LedgerEvidenceInput {
|
|
4
|
+
readonly method: string;
|
|
5
|
+
readonly source: string;
|
|
6
|
+
readonly content: string;
|
|
7
|
+
readonly retrievalResultId?: string;
|
|
8
|
+
readonly chunkIndex?: number;
|
|
9
|
+
readonly lineNumber?: number;
|
|
10
|
+
readonly parserType?: string;
|
|
11
|
+
readonly documentType?: string;
|
|
12
|
+
readonly documentArea?: string;
|
|
13
|
+
readonly evidenceType?: string;
|
|
14
|
+
readonly evidenceLocation?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface LookupEvidenceOptions {
|
|
17
|
+
/** False in remote sessions: only evidence a tool returned this run may be cited. */
|
|
18
|
+
readonly allowLocalFiles: boolean;
|
|
19
|
+
}
|
|
20
|
+
export declare function isRegularFile(path: string): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Per-run record of every piece of evidence a retrieval tool returned.
|
|
23
|
+
*
|
|
24
|
+
* Tools hand the model a short id (`e1`, `e2`, ...) next to each result. The
|
|
25
|
+
* model cites evidence by id; the harness resolves the id back to the exact
|
|
26
|
+
* source, method, content, and chunk metadata it recorded. The model never
|
|
27
|
+
* retypes a path or a chunk, so it cannot misquote or invent one, and the
|
|
28
|
+
* stable evidence id stored in memory is always derived from real evidence.
|
|
29
|
+
*/
|
|
30
|
+
export declare class EvidenceLedger {
|
|
31
|
+
private entries;
|
|
32
|
+
private readonly byKey;
|
|
33
|
+
private readonly byId;
|
|
34
|
+
/**
|
|
35
|
+
* Ordinal of the last issued id. Survives {@link clear}: a hosted (TUI)
|
|
36
|
+
* conversation keeps earlier runs' tool output in context, so restarting at
|
|
37
|
+
* e1 would let a stale id silently resolve to a different chunk.
|
|
38
|
+
*/
|
|
39
|
+
private lastOrdinal;
|
|
40
|
+
/** Record evidence and return its id. The same chunk always gets the same id. */
|
|
41
|
+
register(input: LedgerEvidenceInput): string;
|
|
42
|
+
/** Record one retrieval result as returned by `tool`; backend metadata is carried over. */
|
|
43
|
+
registerResult(tool: string, result: RetrievalResult): string;
|
|
44
|
+
/**
|
|
45
|
+
* Resolve one cited reference to recorded evidence. A ref is an evidence id
|
|
46
|
+
* (`e3` or `[e3]`), the exact source a tool returned (a URL, a datasource
|
|
47
|
+
* id, a path), or the absolute path of a real local file the model opened
|
|
48
|
+
* itself. Returns an empty list when nothing matches: the caller drops the
|
|
49
|
+
* citation instead of failing the run.
|
|
50
|
+
*/
|
|
51
|
+
lookup(raw: string, options: LookupEvidenceOptions): AutoRAGEvidenceRef[];
|
|
52
|
+
/** Forget every recorded entry. Ids are never reissued, so a previous run's id stays unresolvable. */
|
|
53
|
+
clear(): void;
|
|
54
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Remembers which search query and retrieval method surfaced each retrieval
|
|
3
|
+
* result during a run, so a final answer's evidence refs (which carry only a
|
|
4
|
+
* source, method, and text) can be mapped back to the query that found them.
|
|
5
|
+
* Retrieval memory needs both to store an evidence record; the refs alone do
|
|
6
|
+
* not know their query.
|
|
7
|
+
*/
|
|
8
|
+
/** The query, retrieval method, and source of a remembered result. */
|
|
9
|
+
export interface EvidenceOrigin {
|
|
10
|
+
readonly query: string;
|
|
11
|
+
readonly method: string;
|
|
12
|
+
readonly source: string;
|
|
13
|
+
}
|
|
14
|
+
/** One retrieval result the agent saw, together with the query that produced it. */
|
|
15
|
+
export interface EvidenceOriginCandidate extends EvidenceOrigin {
|
|
16
|
+
readonly content: string;
|
|
17
|
+
}
|
|
18
|
+
/** The parts of a cited evidence ref that identify its origin. */
|
|
19
|
+
export interface EvidenceRefLike {
|
|
20
|
+
readonly source: string;
|
|
21
|
+
readonly method: string;
|
|
22
|
+
readonly excerpt?: string;
|
|
23
|
+
readonly content?: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Insertion-ordered index of retrieval results keyed by their source. Matching
|
|
27
|
+
* is deliberately text-based: a final answer's ref text is the same excerpt the
|
|
28
|
+
* retrieval returned, so it shares the candidate's content even when the ref
|
|
29
|
+
* carries a different method.
|
|
30
|
+
*/
|
|
31
|
+
export declare class EvidenceOriginIndex {
|
|
32
|
+
private readonly candidates;
|
|
33
|
+
/** Sources already remembered, to the normalized contents seen for each. */
|
|
34
|
+
private readonly seen;
|
|
35
|
+
/**
|
|
36
|
+
* Remember one retrieval result and the query/method that produced it.
|
|
37
|
+
* First write wins for an identical (source, normalized content) pair.
|
|
38
|
+
*/
|
|
39
|
+
add(candidate: EvidenceOriginCandidate): void;
|
|
40
|
+
/** Where `ref` came from, or undefined when no remembered result matches. */
|
|
41
|
+
resolve(ref: EvidenceRefLike): EvidenceOrigin | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* Match a ref that carries no source (its text is the evidence text the
|
|
44
|
+
* answering model cited, possibly several excerpts joined by newlines)
|
|
45
|
+
* against every remembered candidate by text alone.
|
|
46
|
+
*/
|
|
47
|
+
private resolveSourceless;
|
|
48
|
+
clear(): void;
|
|
49
|
+
}
|
package/dist/agent/index.d.ts
CHANGED
|
@@ -2,11 +2,11 @@ export type { AutoRAGAgentOptions, AutoRefreshOptions, PeerQueryOptions } from "
|
|
|
2
2
|
export { AutoRAGAgent } from "./agent.js";
|
|
3
3
|
export { buildDatasourceSkillsPrompt, createLoadDatasourceSkillTool, type DatasourceSkillProvider, datasourceSkillLocation, formatDatasourceSkillInvocation, LOAD_DATASOURCE_SKILL_TOOL_NAME, type LoadDatasourceSkillDetails, toDatasourceAgentSkill, } from "./datasource-skill.js";
|
|
4
4
|
export { createScanDuplicateDocumentsTool, SCAN_DUPLICATE_DOCUMENTS_TOOL_NAME, type ScanDuplicateDocumentsDetails, type ScanDuplicateDocumentsProvider, } from "./dupey-tool.js";
|
|
5
|
-
export type { AutoRAGEmittedResult, AutoRAGMappingEntry, AutoRAGResultsDetails, } from "./emit-results-tool.js";
|
|
6
|
-
export { createEmitResultsTool, EMIT_AUTORAG_RESULTS_TOOL_NAME, emitResultsSchema, } from "./emit-results-tool.js";
|
|
7
5
|
export { createJevExtension, JEV_TOOL_NAME, type JevBackendName, type JevToolOptions, } from "./jev-extension.js";
|
|
8
6
|
export { createJikjiFindTool, JIKJI_FIND_TOOL_NAME, type JikjiFindDetails, type JikjiFindPerRootPolicy, type JikjiFindProvider, type JikjiFindProviderResult, type MergedJikjiPolicy, } from "./jikji-find-tool.js";
|
|
9
7
|
export { createQueryPeerAgentTool, QUERY_PEER_AGENT_TOOL_NAME, type QueryPeerAgentDetails, type QueryPeerAgentResult, type QueryPeerAgentToolOptions, } from "./query-peer-tool.js";
|
|
8
|
+
export type { AutoRAGEmittedResult, AutoRAGMappingEntry, AutoRAGResultsDetails, } from "./results.js";
|
|
9
|
+
export { reportSchema } from "./results.js";
|
|
10
10
|
export { createSearchAllDocumentsTool, SEARCH_ALL_DOCUMENTS_TOOL_NAME, type SearchAllDocumentsDetails, type SearchAllDocumentsProvider, type SearchAllDocumentsResult, } from "./search-all-tool.js";
|
|
11
11
|
export type { SearchDocumentDiagnostic, SearchDocumentDiagnosticCode, SearchDocumentDiagnosticSeverity, SearchDocumentEvidence, SearchDocumentResult, SearchDocumentsResponse, SearchDocumentsStreamEvent, SearchDocumentWarning, } from "./search-documents.js";
|
|
12
12
|
export { createSearchMinSyncDocumentsTool, SEARCH_MINSYNC_DOCUMENTS_TOOL_NAME, type SearchMinSyncDocumentsDetails, } from "./search-minsync-tool.js";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { AgentTool } from "@earendil-works/pi-agent-core";
|
|
2
2
|
import { Type } from "typebox";
|
|
3
3
|
import type { JikjiAnswerPack, JikjiCandidate, JikjiDiagnostic, JikjiEvidence, JikjiHandoffAction } from "../jikji/index.js";
|
|
4
|
+
import { EvidenceLedger } from "./evidence-ledger.js";
|
|
4
5
|
export declare const JIKJI_FIND_TOOL_NAME = "jikji_find";
|
|
5
6
|
/**
|
|
6
7
|
* Run-scoped merged policy assembled from per-root Jikji answer packs using
|
|
@@ -71,5 +72,5 @@ declare const jikjiFindSchema: Type.TObject<{
|
|
|
71
72
|
* Jikji is unavailable or all roots failed, the tool returns a short fallback
|
|
72
73
|
* message so the agent falls back to bash, and no policy is set.
|
|
73
74
|
*/
|
|
74
|
-
export declare function createJikjiFindTool(provider: JikjiFindProvider): AgentTool<typeof jikjiFindSchema, JikjiFindDetails>;
|
|
75
|
+
export declare function createJikjiFindTool(provider: JikjiFindProvider, ledger?: EvidenceLedger): AgentTool<typeof jikjiFindSchema, JikjiFindDetails>;
|
|
75
76
|
export {};
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import type { AgentMessage, AgentTool } from "@earendil-works/pi-agent-core";
|
|
2
2
|
import type { Api, Model } from "@earendil-works/pi-ai";
|
|
3
|
-
import { type AgentSession, type AgentSessionRuntime, type ExtensionAPI, type ExtensionFactory, type ToolDefinition } from "@earendil-works/pi-coding-agent";
|
|
3
|
+
import { type AgentSession, type AgentSessionRuntime, type ExtensionAPI, type ExtensionFactory, SettingsManager, type ToolDefinition, type TuiMode } from "@earendil-works/pi-coding-agent";
|
|
4
4
|
export declare const PI_BUILTIN_TOOL_NAMES: readonly ["read", "bash", "edit", "write", "grep", "find", "ls"];
|
|
5
|
+
/**
|
|
6
|
+
* Terminal UI mode for AutoRAG's interactive session. pi 1.0 switched its own default to
|
|
7
|
+
* fullscreen; AutoRAG shipped on pi's scrollback UI, so that stays the default. A `tuiMode` the
|
|
8
|
+
* user saved in pi's global or project settings still wins, and `InteractiveMode` accepts the
|
|
9
|
+
* result directly (its constructor otherwise falls back to pi's fullscreen default).
|
|
10
|
+
*/
|
|
11
|
+
export declare function resolveInteractiveTuiMode(settingsManager: SettingsManager): TuiMode;
|
|
5
12
|
export interface AutoRAGPiSessionOptions {
|
|
6
13
|
readonly cwd: string;
|
|
7
14
|
readonly agentDir?: string;
|
|
@@ -3,6 +3,7 @@ import { Type } from "typebox";
|
|
|
3
3
|
import { type SimplexQueryState } from "../p2p/simplex-query-store.js";
|
|
4
4
|
import type { SimplexTransport } from "../p2p/simplex-transport.js";
|
|
5
5
|
import type { PeerQueryResponse } from "../p2p/wire.js";
|
|
6
|
+
import { EvidenceLedger } from "./evidence-ledger.js";
|
|
6
7
|
export declare const QUERY_PEER_AGENT_TOOL_NAME = "query_peer_agent";
|
|
7
8
|
declare const queryPeerAgentSchema: Type.TObject<{
|
|
8
9
|
alias: Type.TString;
|
|
@@ -39,6 +40,8 @@ export interface QueryPeerAgentToolOptions {
|
|
|
39
40
|
readonly sessionId?: () => string | undefined;
|
|
40
41
|
readonly onResponse?: (state: SimplexQueryState, response: PeerQueryResponse) => void;
|
|
41
42
|
readonly onExpired?: (state: SimplexQueryState) => void;
|
|
43
|
+
/** Run evidence ledger; each peer result is registered so the final emit can cite it by id. */
|
|
44
|
+
readonly ledger?: EvidenceLedger;
|
|
42
45
|
}
|
|
43
46
|
export interface QueryPeerAgentTool extends AgentTool<typeof queryPeerAgentSchema, QueryPeerAgentDetails> {
|
|
44
47
|
readonly ready: Promise<void>;
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import type { JevJudge } from "./jev-extension.js";
|
|
2
2
|
/**
|
|
3
3
|
* Where a user question is answered from:
|
|
4
|
-
* - `local`: information
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* - `local`: anything needing information beyond the model's own knowledge —
|
|
5
|
+
* the user's files, chats, mail, or any fact the model cannot reliably recall.
|
|
6
|
+
* Local retrieval runs first; web search is left to the agent after the fast
|
|
7
|
+
* answer, when local evidence falls short.
|
|
8
|
+
* - `direct`: intrinsic knowledge or small talk the model answers on its own.
|
|
9
|
+
* - `config`: the user wants to inspect or change AutoRAG's own settings
|
|
10
|
+
* (model, providers, datasources). Offered only when the host enables
|
|
11
|
+
* agent self-configuration.
|
|
7
12
|
*/
|
|
8
|
-
export type QueryRoute = "local" | "
|
|
9
|
-
/** Jev question id of the
|
|
13
|
+
export type QueryRoute = "local" | "direct" | "config";
|
|
14
|
+
/** Jev question id of the intrinsic-knowledge / local branch. */
|
|
10
15
|
export declare const QUERY_ROUTE_QUESTION_ID = "route";
|
|
11
16
|
/** Jev question id of the "does this need decomposition?" check. */
|
|
12
17
|
export declare const DECOMPOSE_QUESTION_ID = "decompose";
|
|
@@ -18,6 +23,19 @@ export declare const FALLBACK_QUERY_ROUTE: QueryRoute;
|
|
|
18
23
|
export declare const DECOMPOSE_PROBABILITY_THRESHOLD = 0.5;
|
|
19
24
|
/** A `noul` probability at or above this sends the fast answer on to verification. */
|
|
20
25
|
export declare const FOLLOW_UP_PROBABILITY_THRESHOLD = 0.5;
|
|
26
|
+
/**
|
|
27
|
+
* Minimum Jev branch probability required to leave local search. A `direct`
|
|
28
|
+
* branch at or below this floor — or one Jev reported without a probability —
|
|
29
|
+
* keeps the run on local search, the corpus-grounded default.
|
|
30
|
+
* Without the floor a weakly-favored `direct` verdict (observed at p 0.57-0.63
|
|
31
|
+
* on personal-corpus questions) skips retrieval entirely and answers from
|
|
32
|
+
* general knowledge, so the caller loses the evidence the question depends on.
|
|
33
|
+
*/
|
|
34
|
+
export declare const NON_LOCAL_ROUTE_PROBABILITY_THRESHOLD = 0.75;
|
|
35
|
+
/** A `noul` probability at or above this searches that datasource before the fast answer. */
|
|
36
|
+
export declare const DATASOURCE_PROBABILITY_THRESHOLD = 0.5;
|
|
37
|
+
/** Jev question id of the "search this datasource?" check for one datasource. */
|
|
38
|
+
export declare function datasourceQuestionId(datasourceId: string): string;
|
|
21
39
|
export interface FollowUpDecision {
|
|
22
40
|
/** True when the run continues into the verification phase. */
|
|
23
41
|
readonly followUp: boolean;
|
|
@@ -34,21 +52,64 @@ export interface FollowUpDecision {
|
|
|
34
52
|
*/
|
|
35
53
|
export declare function needsFollowUp(judge: JevJudge, query: string, answer: string): Promise<FollowUpDecision>;
|
|
36
54
|
export interface QueryRouteDecision {
|
|
37
|
-
/** Most probable branch; {@link FALLBACK_QUERY_ROUTE} when Jev gave none. */
|
|
55
|
+
/** Most probable branch; {@link FALLBACK_QUERY_ROUTE} when Jev gave none or its non-local branch missed {@link NON_LOCAL_ROUTE_PROBABILITY_THRESHOLD}. */
|
|
38
56
|
readonly route: QueryRoute;
|
|
39
57
|
/** True when Jev judged the question needs decomposition (never for `direct`). */
|
|
40
58
|
readonly decompose: boolean;
|
|
41
|
-
/** Probability Jev gave the
|
|
59
|
+
/** Probability Jev gave the winning branch, including a rejected non-local branch whose floor moved the route to local. */
|
|
42
60
|
readonly routeProbability?: number;
|
|
43
61
|
/** Jev's P(decomposition needed), when it answered. */
|
|
44
62
|
readonly decomposeProbability?: number;
|
|
45
63
|
/** Why the decision fell back instead of following Jev; absent when Jev decided. */
|
|
46
64
|
readonly fallbackReason?: string;
|
|
47
65
|
}
|
|
66
|
+
export interface RouteQueryOptions {
|
|
67
|
+
/** Offer the `config` branch: the agent may change its own settings. */
|
|
68
|
+
readonly selfConfig?: boolean;
|
|
69
|
+
}
|
|
48
70
|
/**
|
|
49
71
|
* Ask Jev, in one batched call about the user question, which branch answers
|
|
50
72
|
* it and whether it needs decomposition. Never throws: a missing credential,
|
|
51
|
-
* an unreachable backend,
|
|
52
|
-
*
|
|
73
|
+
* an unreachable backend, an unusable verdict, or a `direct` branch that does
|
|
74
|
+
* not clear {@link NON_LOCAL_ROUTE_PROBABILITY_THRESHOLD} falls back to a
|
|
75
|
+
* single local search, with the reason recorded.
|
|
76
|
+
*/
|
|
77
|
+
export declare function routeQuery(judge: JevJudge, query: string, options?: RouteQueryOptions): Promise<QueryRouteDecision>;
|
|
78
|
+
/** One configured datasource Jev may send the question to. */
|
|
79
|
+
export interface DatasourceCandidate {
|
|
80
|
+
readonly datasourceId: string;
|
|
81
|
+
/** Content kind, e.g. `chat`, `mail`, `docs`. */
|
|
82
|
+
readonly type: string;
|
|
83
|
+
/** Operator- or connector-authored description of what the datasource holds. */
|
|
84
|
+
readonly description: string;
|
|
85
|
+
}
|
|
86
|
+
export interface DatasourceSelection {
|
|
87
|
+
/** Datasource ids to search, in registration order. */
|
|
88
|
+
readonly selected: readonly string[];
|
|
89
|
+
/** Jev's P(search needed) per datasource id, for every datasource it answered. */
|
|
90
|
+
readonly probabilities: Readonly<Record<string, number>>;
|
|
91
|
+
/** Why no datasource is searched instead of following Jev; absent when Jev decided. */
|
|
92
|
+
readonly fallbackReason?: string;
|
|
93
|
+
}
|
|
94
|
+
/** A similar question asked before, its results, and where each was found. */
|
|
95
|
+
export interface PastSearchHint {
|
|
96
|
+
readonly query: string;
|
|
97
|
+
/**
|
|
98
|
+
* Results it returned. `foundIn` names registered datasource ids, `local
|
|
99
|
+
* files`, or `web`; a title can also record that nothing was found there.
|
|
100
|
+
*/
|
|
101
|
+
readonly results: readonly {
|
|
102
|
+
readonly title: string;
|
|
103
|
+
readonly foundIn: readonly string[];
|
|
104
|
+
}[];
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Ask Jev, in one batched call, one `noul` per registered datasource: does
|
|
108
|
+
* answering the question need that datasource searched? The state describes
|
|
109
|
+
* every datasource (descriptions are flagged as non-exhaustive summaries), so
|
|
110
|
+
* Jev judges each one against the others, plus where similar past questions
|
|
111
|
+
* were answered, when retrieval memory has any. Never throws: a missing
|
|
112
|
+
* credential or an unreachable backend searches no datasource, which is the
|
|
113
|
+
* behavior without Jev.
|
|
53
114
|
*/
|
|
54
|
-
export declare function
|
|
115
|
+
export declare function selectDatasources(judge: JevJudge, query: string, datasources: readonly DatasourceCandidate[], pastSearches?: readonly PastSearchHint[]): Promise<DatasourceSelection>;
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
import type { AgentTool } from "@earendil-works/pi-agent-core";
|
|
2
1
|
import { Type } from "typebox";
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Report schema with the explicit number -> source mapping. This is the
|
|
4
|
+
* persisted/typed shape and the input contract of `autorag report` and the MCP
|
|
5
|
+
* report tool, where an external agent curated the evidence and no harness
|
|
6
|
+
* ledger exists. The librarian itself never produces this shape from the
|
|
7
|
+
* model: it writes a plain answer and the harness derives the results from the
|
|
8
|
+
* evidence ids the answer cites.
|
|
9
|
+
*/
|
|
10
|
+
export declare const reportSchema: Type.TObject<{
|
|
5
11
|
answer: Type.TString;
|
|
6
12
|
results: Type.TArray<Type.TObject<{
|
|
7
13
|
number: Type.TInteger;
|
|
@@ -47,7 +53,8 @@ export interface AutoRAGEmittedResult {
|
|
|
47
53
|
readonly title: string;
|
|
48
54
|
readonly summary: string;
|
|
49
55
|
readonly evidence: readonly AutoRAGEmittedEvidence[];
|
|
50
|
-
|
|
56
|
+
/** Absent for results the harness derived from cited evidence: nothing measured a confidence. */
|
|
57
|
+
readonly confidence?: number;
|
|
51
58
|
}
|
|
52
59
|
export interface AutoRAGEvidenceRef {
|
|
53
60
|
readonly method: string;
|
|
@@ -79,10 +86,3 @@ export interface AutoRAGResultsDetails {
|
|
|
79
86
|
readonly mapping: readonly AutoRAGMappingEntry[];
|
|
80
87
|
readonly warnings: readonly string[];
|
|
81
88
|
}
|
|
82
|
-
/**
|
|
83
|
-
* Builds the terminating structured-result tool. The model calls this exactly
|
|
84
|
-
* once as its final action; the typed `details` plus `terminate: true` end the
|
|
85
|
-
* Pi Agent run and hand the curated results back through `capture` — no
|
|
86
|
-
* assistant-text parsing involved.
|
|
87
|
-
*/
|
|
88
|
-
export declare function createEmitResultsTool(capture: (details: AutoRAGResultsDetails) => void): AgentTool<typeof emitResultsSchema, AutoRAGResultsDetails>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { AgentTool } from "@earendil-works/pi-agent-core";
|
|
2
2
|
import { Type } from "typebox";
|
|
3
3
|
import type { RetrievalDiagnostic, RetrievalResult } from "../retrieval/types.js";
|
|
4
|
+
import { EvidenceLedger } from "./evidence-ledger.js";
|
|
4
5
|
import { type SearchDocumentRetrievalTraceResult } from "./search-documents.js";
|
|
5
6
|
export declare const SEARCH_ALL_DOCUMENTS_TOOL_NAME = "search_all_documents";
|
|
6
7
|
declare const searchAllSchema: Type.TObject<{
|
|
@@ -30,10 +31,9 @@ export interface SearchAllDocumentsDetails {
|
|
|
30
31
|
}
|
|
31
32
|
/**
|
|
32
33
|
* LLM-facing wrapper around multi-method merged retrieval. The
|
|
33
|
-
* schema accepts only `{ query, topK?, scope? }`;
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
* through, so model-provided extra properties cannot widen datasource access.
|
|
34
|
+
* schema accepts only `{ query, topK?, scope? }`; extra model-provided
|
|
35
|
+
* properties are not part of the schema and are never forwarded to the
|
|
36
|
+
* provider — only `query`, `topK`, and `scope` are passed through.
|
|
37
37
|
*/
|
|
38
|
-
export declare function createSearchAllDocumentsTool(provider: SearchAllDocumentsProvider): AgentTool<typeof searchAllSchema, SearchAllDocumentsDetails>;
|
|
38
|
+
export declare function createSearchAllDocumentsTool(provider: SearchAllDocumentsProvider, ledger?: EvidenceLedger): AgentTool<typeof searchAllSchema, SearchAllDocumentsDetails>;
|
|
39
39
|
export {};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { type RetrievalMemory } from "../memory/memory.js";
|
|
2
|
-
import type {
|
|
3
|
-
import type { AutoRAGResultsDetails } from "./
|
|
4
|
-
import type { AutoRAGFastAnswerDetails } from "./fast-answer-tool.js";
|
|
1
|
+
import { type RetrievalMemory, type SessionEvidenceRef } from "../memory/memory.js";
|
|
2
|
+
import type { RetrievalResult } from "../retrieval/types.js";
|
|
3
|
+
import type { AutoRAGMappingEntry, AutoRAGResultsDetails } from "./results.js";
|
|
5
4
|
export type SearchDocumentWarning = "empty-query";
|
|
6
5
|
export type SearchDocumentDiagnosticSeverity = "info" | "warning" | "error";
|
|
7
6
|
/**
|
|
@@ -10,7 +9,7 @@ export type SearchDocumentDiagnosticSeverity = "info" | "warning" | "error";
|
|
|
10
9
|
* (#21/#22) does not require another source-breaking type change; codes not yet
|
|
11
10
|
* emitted are still valid members.
|
|
12
11
|
*/
|
|
13
|
-
export type SearchDocumentDiagnosticCode = "empty-query" | "no-verified-results" | "unknown-warning" | "caller-tool-dropped" | "minsync-
|
|
12
|
+
export type SearchDocumentDiagnosticCode = "empty-query" | "no-verified-results" | "unknown-warning" | "caller-tool-dropped" | "minsync-staging-excluded" | "minsync-sync-failed" | "embedder-unavailable" | "embedding-identity-mismatch" | "parser-skipped" | "parser-failed" | "source-vanished" | "source-unreadable" | "parser-warning" | "duplicate-excluded" | "unsupported-file" | "stale-index" | "deleted-mirror" | "pdf-extract-thin" | "retrieval-method-failed" | "rerank-failed" | "jikji-unavailable" | "jikji-prepare-failed" | "jikji-find-failed" | "everything-index-failed" | "fsearch-index-failed" | "fsearch-binary-missing" | "refresh-failed" | "refresh-interrupted" | "watch-failed" | "watch-limited" | "unknown-datasource-skill" | "no-final-answer" | "model-request-failed" | "search-timeout" | "query-routed" | "query-route-fallback" | "query-decomposition-failed" | "follow-up-skipped" | "follow-up-check-fallback" | "datasources-selected" | "datasource-selection-fallback" | "citation-without-result" | "evidence-judged" | "evidence-judgment-fallback" | "memory-search-fallback" | "self-config-unavailable" | "self-config-rolled-back";
|
|
14
13
|
export interface SearchDocumentDiagnostic {
|
|
15
14
|
readonly code: SearchDocumentDiagnosticCode;
|
|
16
15
|
readonly severity: SearchDocumentDiagnosticSeverity;
|
|
@@ -27,8 +26,8 @@ export interface SearchDocumentResult {
|
|
|
27
26
|
readonly title: string;
|
|
28
27
|
readonly summary: string;
|
|
29
28
|
readonly evidence: readonly SearchDocumentEvidence[];
|
|
30
|
-
|
|
31
|
-
readonly
|
|
29
|
+
/** Absent when nothing measured one: derived results carry no model-reported confidence. */
|
|
30
|
+
readonly confidence?: number;
|
|
32
31
|
readonly source?: string;
|
|
33
32
|
}
|
|
34
33
|
/** One retrieval candidate captured in a run's retrieval trace. */
|
|
@@ -39,7 +38,7 @@ export interface SearchDocumentRetrievalTraceResult {
|
|
|
39
38
|
}
|
|
40
39
|
/**
|
|
41
40
|
* What one retrieval tool execution found during a search run. Attached to the
|
|
42
|
-
* degraded fallback response when the agent never
|
|
41
|
+
* degraded fallback response when the agent never wrote a final answer,
|
|
43
42
|
* so an upstream agent can still inspect the raw candidates.
|
|
44
43
|
*/
|
|
45
44
|
export interface SearchDocumentRetrievalTraceEntry {
|
|
@@ -85,27 +84,15 @@ export type SearchDocumentsStreamEvent = {
|
|
|
85
84
|
readonly type: "complete";
|
|
86
85
|
readonly response: SearchDocumentsResponse;
|
|
87
86
|
};
|
|
88
|
-
type SearchSession = {
|
|
89
|
-
query: string;
|
|
90
|
-
registry: Map<number, CuratedResult>;
|
|
91
|
-
transient?: boolean;
|
|
92
|
-
};
|
|
93
|
-
type SearchSessions = Map<string, SearchSession>;
|
|
94
|
-
type ReadonlySearchSessions = ReadonlyMap<string, {
|
|
95
|
-
query: string;
|
|
96
|
-
registry: ReadonlyMap<number, CuratedResult>;
|
|
97
|
-
transient?: boolean;
|
|
98
|
-
}>;
|
|
99
87
|
/**
|
|
100
88
|
* Build the preliminary (fast-phase) search response. Unlike
|
|
101
|
-
* {@link recordStructuredResultsSession} this NEVER touches memory
|
|
102
|
-
*
|
|
103
|
-
* namespaced with `:preliminary:` so they can never collide with final ids.
|
|
89
|
+
* {@link recordStructuredResultsSession} this NEVER touches memory — the final
|
|
90
|
+
* response owns that.
|
|
104
91
|
*/
|
|
105
|
-
export declare function createPreliminarySearchDocumentsResponse(sessionId: string, query: string, details:
|
|
106
|
-
export declare function createEmptySearchDocumentsResponse(sessionId: string, query: string,
|
|
107
|
-
export declare function
|
|
92
|
+
export declare function createPreliminarySearchDocumentsResponse(sessionId: string, query: string, details: AutoRAGResultsDetails, diagnostics?: readonly SearchDocumentDiagnostic[]): SearchDocumentsResponse;
|
|
93
|
+
export declare function createEmptySearchDocumentsResponse(sessionId: string, query: string, diagnostics?: readonly SearchDocumentDiagnostic[]): SearchDocumentsResponse;
|
|
94
|
+
export declare function normalizeEntryEvidenceRefs(entry: AutoRAGMappingEntry): SessionEvidenceRef[];
|
|
95
|
+
export declare function recordStructuredResultsSession(sessionId: string, query: string, details: AutoRAGResultsDetails, memory: RetrievalMemory, componentDiagnostics?: readonly SearchDocumentDiagnostic[], options?: {
|
|
96
|
+
/** Skip the retrieval-memory write. */
|
|
108
97
|
readonly isolateMemory?: boolean;
|
|
109
98
|
}): SearchDocumentsResponse;
|
|
110
|
-
export declare function recordNumberedFeedback(sessions: ReadonlySearchSessions, memory: RetrievalMemory, sessionId: string, usefulNumbers: readonly number[], notUsefulNumbers: readonly number[]): boolean;
|
|
111
|
-
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { AgentTool } from "@earendil-works/pi-agent-core";
|
|
2
2
|
import { Type } from "typebox";
|
|
3
3
|
import type { MinSyncVectorMethod } from "../minsync/method.js";
|
|
4
|
+
import { EvidenceLedger } from "./evidence-ledger.js";
|
|
4
5
|
import { type SearchDocumentRetrievalTraceResult } from "./search-documents.js";
|
|
5
6
|
export declare const SEARCH_MINSYNC_DOCUMENTS_TOOL_NAME = "semantic_search_local_docs";
|
|
6
7
|
declare const searchMinSyncSchema: Type.TObject<{
|
|
@@ -12,16 +13,15 @@ export interface SearchMinSyncDocumentsDetails {
|
|
|
12
13
|
readonly method: "semantic_search_local_docs";
|
|
13
14
|
readonly resultCount: number;
|
|
14
15
|
readonly sources: readonly string[];
|
|
15
|
-
readonly available: boolean;
|
|
16
16
|
/** Top candidates in traceable shape (additive; used for the run's retrieval trace). */
|
|
17
17
|
readonly results?: readonly SearchDocumentRetrievalTraceResult[];
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
20
|
* LLM-facing wrapper around the {@link MinSyncVectorMethod} vector
|
|
21
21
|
* retrieval. The model can only supply `query`, `topK`, and an opaque `scope`.
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
22
|
+
* MinSync is required, so a missing binary or a failed query is not turned
|
|
23
|
+
* into an "unavailable" result: the error propagates with its own message and
|
|
24
|
+
* the harness reports it as a failed tool call.
|
|
25
25
|
*/
|
|
26
|
-
export declare function createSearchMinSyncDocumentsTool(getMethod: () => MinSyncVectorMethod
|
|
26
|
+
export declare function createSearchMinSyncDocumentsTool(getMethod: () => MinSyncVectorMethod, resolveScope?: (scope: string | undefined) => string | undefined, ledger?: EvidenceLedger): AgentTool<typeof searchMinSyncSchema, SearchMinSyncDocumentsDetails>;
|
|
27
27
|
export {};
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { AgentTool } from "@earendil-works/pi-agent-core";
|
|
2
2
|
import { Type } from "typebox";
|
|
3
3
|
import type { RetrievalDiagnostic, RetrievalResult } from "../retrieval/types.js";
|
|
4
|
+
import { EvidenceLedger } from "./evidence-ledger.js";
|
|
4
5
|
import { type SearchDocumentRetrievalTraceResult } from "./search-documents.js";
|
|
5
6
|
/**
|
|
6
7
|
* Per-datasource search tools.
|
|
7
8
|
*
|
|
8
|
-
* One tool is generated per
|
|
9
|
+
* One tool is generated per configured datasource connection (e.g.
|
|
9
10
|
* `search_datasource_discord`, or `search_datasource_kakao_work` for a
|
|
10
11
|
* `kakao-work` account alias). Its execution registers only that connection's
|
|
11
12
|
* retrieval methods with the retriever, so no other datasource CLI is spawned
|
|
@@ -14,13 +15,13 @@ import { type SearchDocumentRetrievalTraceResult } from "./search-documents.js";
|
|
|
14
15
|
* These generated tools are the only model-facing datasource retrieval
|
|
15
16
|
* surface. Cross-datasource fan-out belongs to `search_all_documents`, which
|
|
16
17
|
* already spans every configured retrieval method — including datasources — so
|
|
17
|
-
* a datasource-only fan-out tool would be redundant. Every
|
|
18
|
+
* a datasource-only fan-out tool would be redundant. Every configured
|
|
18
19
|
* connection must therefore appear here; a datasource with no generated tool
|
|
19
20
|
* would become unreachable except through the full fan-out.
|
|
20
21
|
*
|
|
21
|
-
* Tools are generated from the configured
|
|
22
|
-
*
|
|
23
|
-
*
|
|
22
|
+
* Tools are generated from the configured datasource skills at agent
|
|
23
|
+
* construction; a connection not present in the config never appears in the
|
|
24
|
+
* tool list.
|
|
24
25
|
*/
|
|
25
26
|
export declare const SEARCH_SINGLE_DATASOURCE_TOOL_PREFIX = "search_datasource_";
|
|
26
27
|
/** Model-visible tool name for one datasource connection. */
|
|
@@ -31,7 +32,7 @@ export interface SingleDatasourceToolSpec {
|
|
|
31
32
|
readonly datasourceId: string;
|
|
32
33
|
/** Operator/descriptor-authored context shown in the tool description. */
|
|
33
34
|
readonly description: string;
|
|
34
|
-
/**
|
|
35
|
+
/** Instance roots (e.g. `/kakao/personal`) for the description. */
|
|
35
36
|
readonly instanceScopes: readonly string[];
|
|
36
37
|
}
|
|
37
38
|
export interface SingleDatasourceSearchProvider {
|
|
@@ -52,12 +53,12 @@ export interface SearchSingleDatasourceDetails {
|
|
|
52
53
|
/** Top candidates in traceable shape (additive; used for the run's retrieval trace). */
|
|
53
54
|
readonly results?: readonly SearchDocumentRetrievalTraceResult[];
|
|
54
55
|
}
|
|
55
|
-
export declare function createSingleDatasourceSearchTools(provider: SingleDatasourceSearchProvider, specs: readonly SingleDatasourceToolSpec[]): AgentTool<typeof searchSingleDatasourceSchema, SearchSingleDatasourceDetails>[];
|
|
56
|
+
export declare function createSingleDatasourceSearchTools(provider: SingleDatasourceSearchProvider, specs: readonly SingleDatasourceToolSpec[], ledger?: EvidenceLedger): AgentTool<typeof searchSingleDatasourceSchema, SearchSingleDatasourceDetails>[];
|
|
56
57
|
declare const searchSingleDatasourceSchema: Type.TObject<{
|
|
57
58
|
query: Type.TString;
|
|
58
59
|
topK: Type.TOptional<Type.TInteger>;
|
|
59
60
|
scope: Type.TOptional<Type.TString>;
|
|
60
61
|
}>;
|
|
61
62
|
/** Shared rendering for datasource search tool results (fan-out removed). */
|
|
62
|
-
export declare function formatDatasourceResults(results: readonly RetrievalResult[], diagnostics: readonly RetrievalDiagnostic[]): string;
|
|
63
|
+
export declare function formatDatasourceResults(results: readonly RetrievalResult[], diagnostics: readonly RetrievalDiagnostic[], evidenceIds: readonly string[]): string;
|
|
63
64
|
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host opt-in for agent self-configuration: the Jev `config` branch, where the
|
|
3
|
+
* agent edits its own settings with the full `autorag-setup` skill in hand.
|
|
4
|
+
*/
|
|
5
|
+
export interface SelfConfigOptions {
|
|
6
|
+
/** The active AutoRAG config file the agent may read and edit. */
|
|
7
|
+
readonly configPath: string;
|
|
8
|
+
/** Override for the `autorag-setup` SKILL.md; defaults to the packaged skill. */
|
|
9
|
+
readonly skillPath?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Check the config file after a config turn changed it. Resolves to a
|
|
12
|
+
* problem description when the file no longer works, or `undefined` when it
|
|
13
|
+
* is fine. A reported problem restores the pre-turn file.
|
|
14
|
+
*/
|
|
15
|
+
readonly validate?: (configPath: string) => Promise<string | undefined>;
|
|
16
|
+
}
|
|
17
|
+
/** Full text of the `autorag-setup` skill with its YAML front matter removed. */
|
|
18
|
+
export declare function loadSetupSkill(skillPath?: string): string;
|
|
19
|
+
export interface SelfConfigPromptInput {
|
|
20
|
+
readonly query: string;
|
|
21
|
+
readonly configPath: string;
|
|
22
|
+
readonly agentDir: string;
|
|
23
|
+
readonly skill: string;
|
|
24
|
+
}
|
|
25
|
+
/** The config file's current text, or `undefined` when it does not exist. */
|
|
26
|
+
export declare function snapshotConfigFile(configPath: string): string | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* After a config turn: when the model changed the file and the host's
|
|
29
|
+
* `validate` says the result no longer works, put the pre-turn text back.
|
|
30
|
+
* Returns the problem that triggered the rollback, or `undefined` when the
|
|
31
|
+
* file is unchanged, valid, or the host supplied no validator. An unchanged
|
|
32
|
+
* file is never touched, even if it was already invalid before the turn.
|
|
33
|
+
*/
|
|
34
|
+
export declare function rollbackIfBroken(options: SelfConfigOptions, before: string | undefined): Promise<string | undefined>;
|
|
35
|
+
/**
|
|
36
|
+
* The turn prompt for the `config` branch: the whole setup skill, where this
|
|
37
|
+
* run's config lives, the safety rules for editing it, and the user's request.
|
|
38
|
+
* The turn ends with the model's plain final message; there is no fast answer.
|
|
39
|
+
*/
|
|
40
|
+
export declare function buildSelfConfigPrompt(input: SelfConfigPromptInput): string;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import type { Skill } from "@earendil-works/pi-agent-core";
|
|
2
1
|
import type { StoreManifest } from "../manifest/types.js";
|
|
2
|
+
import type { DatasourceAgentSkill } from "./datasource-skill.js";
|
|
3
3
|
export interface SystemPromptConfig {
|
|
4
4
|
toolNames: string[];
|
|
5
5
|
modelId?: string;
|
|
6
|
-
memorySignalCount?: number;
|
|
7
6
|
memoryEntries?: readonly unknown[];
|
|
8
7
|
manifests: StoreManifest[];
|
|
9
8
|
jikjiIndexingEnabled?: boolean;
|
|
10
|
-
datasourceSkills?: readonly
|
|
9
|
+
datasourceSkills?: readonly DatasourceAgentSkill[];
|
|
11
10
|
retrievedContentGuard?: boolean;
|
|
12
11
|
remoteSession?: boolean;
|
|
13
12
|
}
|