@autorag/librarian 2.13.3 → 2.13.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/NOTICE +6 -0
  2. package/README.md +50 -19
  3. package/dist/agent/agent.d.ts +110 -39
  4. package/dist/agent/cloud-release-extension.d.ts +43 -0
  5. package/dist/agent/context-token-guard.d.ts +11 -6
  6. package/dist/agent/decision-backends.d.ts +49 -0
  7. package/dist/agent/decision-model-check.d.ts +92 -0
  8. package/dist/agent/dupey-tool.d.ts +2 -0
  9. package/dist/agent/everything-search-tool.d.ts +1 -0
  10. package/dist/agent/fsearch-search-tool.d.ts +1 -0
  11. package/dist/agent/index.d.ts +4 -1
  12. package/dist/agent/jev-extension.d.ts +27 -32
  13. package/dist/agent/jikji-find-tool.d.ts +5 -0
  14. package/dist/agent/name-candidates.d.ts +88 -0
  15. package/dist/agent/permission-gate.d.ts +2 -5
  16. package/dist/agent/query-routing.d.ts +1 -1
  17. package/dist/agent/search-documents.d.ts +1 -1
  18. package/dist/agent/sllm-decision.d.ts +34 -0
  19. package/dist/agent/token-count.d.ts +4 -0
  20. package/dist/cli/commands/duplicates.d.ts +3 -2
  21. package/dist/cli/commands/models.d.ts +2 -0
  22. package/dist/cli/commands/search.d.ts +2 -0
  23. package/dist/cli/config.d.ts +49 -30
  24. package/dist/cli/index.js +11417 -8530
  25. package/dist/cli/setup.d.ts +27 -1
  26. package/dist/cloud/jev-backend.d.ts +26 -4
  27. package/dist/core.js +5905 -3131
  28. package/dist/datasource/connector-skill.d.ts +1 -1
  29. package/dist/datasource/connector.d.ts +1 -1
  30. package/dist/datasource/index.d.ts +2 -3
  31. package/dist/datasource/skills/obsidian/index.d.ts +1 -1
  32. package/dist/datasource/skills/obsidian/methods.d.ts +1 -1
  33. package/dist/datasource/skills/obsidian/skill.d.ts +1 -0
  34. package/dist/datasource/skills/obsidian/vault-index.d.ts +1 -1
  35. package/dist/datasource/skills/wombat/client.d.ts +17 -0
  36. package/dist/datasource/skills/wombat/index.d.ts +4 -0
  37. package/dist/datasource/skills/wombat/methods.d.ts +15 -0
  38. package/dist/datasource/skills/wombat/skill.d.ts +38 -0
  39. package/dist/datasource/skills/wombat/types.d.ts +89 -0
  40. package/dist/dupey/cli.d.ts +21 -1
  41. package/dist/dupey/filter.d.ts +8 -1
  42. package/dist/dupey/index.d.ts +1 -0
  43. package/dist/dupey/scan-plan.d.ts +23 -0
  44. package/dist/embedding/index.d.ts +3 -1
  45. package/dist/everything/client.d.ts +1 -2
  46. package/dist/filesystem/cloud-placeholder.d.ts +313 -21
  47. package/dist/filesystem/shared-exclusive-queue.d.ts +16 -0
  48. package/dist/fsearch/client.d.ts +3 -2
  49. package/dist/index.d.ts +1 -1
  50. package/dist/index.js +6010 -3199
  51. package/dist/jikji/answer-pack.d.ts +7 -1
  52. package/dist/jikji/client.d.ts +28 -14
  53. package/dist/jikji/diagnostics.d.ts +16 -2
  54. package/dist/jikji/index.d.ts +3 -3
  55. package/dist/jikji/installer.d.ts +11 -5
  56. package/dist/jikji/retry-command.d.ts +10 -0
  57. package/dist/jikji/types.d.ts +47 -1
  58. package/dist/jikji/version.d.ts +20 -0
  59. package/dist/mcp/index.js +5980 -3193
  60. package/dist/mcp/server.d.ts +3 -0
  61. package/dist/minsync/binary.d.ts +10 -5
  62. package/dist/minsync/client.d.ts +7 -10
  63. package/dist/minsync/embedder-config.d.ts +11 -10
  64. package/dist/minsync/errors.d.ts +3 -0
  65. package/dist/minsync/index.d.ts +1 -1
  66. package/dist/minsync/installer.d.ts +1 -1
  67. package/dist/minsync/method.d.ts +1 -0
  68. package/dist/minsync/types.d.ts +0 -9
  69. package/dist/minsync/version.d.ts +20 -0
  70. package/dist/mirror/cloud-fingerprints.d.ts +30 -0
  71. package/dist/mirror/cloud.d.ts +79 -0
  72. package/dist/mirror/index.d.ts +4 -0
  73. package/dist/mirror/sync.d.ts +33 -1
  74. package/dist/parser/csv.d.ts +26 -0
  75. package/dist/parser/defaults.d.ts +1 -1
  76. package/dist/parser/index.d.ts +2 -0
  77. package/dist/parser/kordoc.d.ts +6 -3
  78. package/dist/parser/parse-worker.js +668 -28
  79. package/dist/parser/spreadsheet-render.d.ts +53 -0
  80. package/dist/parser/spreadsheet.d.ts +27 -0
  81. package/dist/profiles/loop-guard.d.ts +8 -2
  82. package/dist/profiles/retrieval-tools.d.ts +2 -1
  83. package/dist/profiles.js +13531 -10756
  84. package/dist/retrieval/skip.d.ts +1 -1
  85. package/dist/retrieval/types.d.ts +1 -1
  86. package/package.json +4 -3
  87. package/skills/autorag/SKILL.md +7 -4
  88. package/skills/autorag-doctor/SKILL.md +8 -4
  89. package/skills/autorag-lite-setup/SKILL.md +4 -4
  90. package/skills/autorag-setup/SKILL.md +53 -31
  91. package/dist/datasource/skills/cloud-drive/index.d.ts +0 -2
  92. package/dist/datasource/skills/cloud-drive/rclone-connector.d.ts +0 -49
  93. package/dist/datasource/skills/cloud-drive/skill.d.ts +0 -14
  94. package/dist/datasource/skills/spotlight/connector.d.ts +0 -53
  95. package/dist/datasource/skills/spotlight/index.d.ts +0 -2
  96. package/dist/datasource/skills/spotlight/skill.d.ts +0 -33
  97. package/dist/minsync/kiwi.d.ts +0 -17
  98. package/dist/minsync/lexical-language.d.ts +0 -18
@@ -0,0 +1,49 @@
1
+ import type { ClassifierApi, ClassifierContext, ClassifierModel, ClassifierResult, ModelsClassifierOptions } from "@earendil-works/pi-ai";
2
+ import { type BackendRequest, type BackendResponse, type JevBackend } from "jev-use";
3
+ /**
4
+ * Decision models come from pi's model catalog: pi-ai ships every provider's typed-question
5
+ * ("classifier") models next to its chat models, with the transport for each wire dialect
6
+ * (System One on TypeSafe, OpenRouter, Vercel AI Gateway, Cloudflare Workers AI, and OpenCode;
7
+ * OpenAI's Decisions API for GPT-6 Luna), and pi's runtime adds the credentials in `auth.json` and
8
+ * the provider `baseUrl` overrides in `models.json` (a proxy or gateway speaking the same dialect).
9
+ * {@link PiDecisionBackend} puts one of those models behind jev-use's backend contract, so the
10
+ * jev-use engine (screening, escalation) and every AutoRAG judgment stay unchanged.
11
+ */
12
+ /**
13
+ * The decision model asked on each provider when the config names none. OpenRouter stays on
14
+ * `typesafe/jev-1.13`, the model AutoRAG's routing and permission thresholds were calibrated on.
15
+ */
16
+ export declare const DECISION_PROVIDER_DEFAULT_MODELS: Readonly<Record<string, string>>;
17
+ /** The pi providers tried, in this order, when the caller names no decision backend. */
18
+ export declare const DECISION_PROVIDER_ORDER: readonly string[];
19
+ /** What {@link PiDecisionBackend} reads from pi's model runtime. pi's `ModelRuntime` is one. */
20
+ export interface DecisionModelRuntime {
21
+ getModelsOfType(type: "classifier", provider?: string): readonly ClassifierModel<ClassifierApi>[];
22
+ classify(model: ClassifierModel<ClassifierApi>, context: ClassifierContext, options?: ModelsClassifierOptions): Promise<ClassifierResult>;
23
+ }
24
+ export interface PiDecisionBackendOptions {
25
+ /** pi provider id with decision models: `openrouter`, `openai`, `typesafe`, `vercel-ai-gateway`, `cloudflare-workers-ai`, or `opencode`. */
26
+ readonly provider: string;
27
+ /** Decision model id within the provider. Default: {@link DECISION_PROVIDER_DEFAULT_MODELS}, else the provider's first. */
28
+ readonly model?: string;
29
+ /** pi's runtime; built from `agentDir` on the first call when omitted. */
30
+ readonly runtime?: DecisionModelRuntime;
31
+ /** Pi agent home whose `auth.json` and `models.json` the runtime reads. Default: Pi's agent dir. */
32
+ readonly agentDir?: string;
33
+ /** Environment the provider credential is read from, ahead of `process.env`. */
34
+ readonly env?: Record<string, string | undefined>;
35
+ }
36
+ /**
37
+ * One decision model from pi's catalog, as a jev-use backend. Missing credentials, an unknown model,
38
+ * and provider errors surface as `BackendError`s with the provider's own message, which the jev-use
39
+ * engine turns into `unreachable` escalations and the session check into a typed reason.
40
+ */
41
+ export declare class PiDecisionBackend implements JevBackend {
42
+ readonly name: string;
43
+ private readonly modelId;
44
+ private readonly runtime;
45
+ private readonly agentDir;
46
+ private readonly env;
47
+ constructor(options: PiDecisionBackendOptions);
48
+ judge(request: BackendRequest): Promise<BackendResponse>;
49
+ }
@@ -0,0 +1,92 @@
1
+ import { type JevJudge, type JevJudgeOptions } from "./jev-extension.js";
2
+ /**
3
+ * AutoRAG cannot answer without its decision model (Jev, or the small chat LLM when `jev.backend` is `sllm`): routing, the follow-up check, citation and
4
+ * evidence judgment, and the permission gate all ask it, in yes/no and choice questions. The first
5
+ * question of every session therefore puts one tiny probe of each kind to the decision model. When Jev
6
+ * cannot answer, the configured small chat LLM (sLLM) is probed and serves the session in its place,
7
+ * reported as degraded; when neither answers, the run ends with {@link DecisionModelUnavailableError}
8
+ * instead of a pipeline that guesses.
9
+ */
10
+ /** Error code every surface reports when the session's decision model cannot be used. */
11
+ export declare const DECISION_MODEL_UNAVAILABLE_CODE = "decision-model-unavailable";
12
+ /** Question id of the availability probe. */
13
+ export declare const DECISION_MODEL_PROBE_QUESTION_ID = "decision_model_probe";
14
+ /** Question id of the choice probe, asked in the same call. */
15
+ export declare const DECISION_MODEL_CHOICE_PROBE_QUESTION_ID = "decision_model_choice_probe";
16
+ /** Why the decision model could not be used. */
17
+ export type DecisionModelFailureReason =
18
+ /** The caller tried to turn the decision model off (`jev: false`). */
19
+ "disabled"
20
+ /** No credential for the backend: an unset API key or a missing sign-in. */
21
+ | "missing-credential"
22
+ /** The backend rejected the credential (HTTP 401/403). */
23
+ | "unauthorized"
24
+ /** The backend account has no credit left (HTTP 402). */
25
+ | "payment-required"
26
+ /** The backend does not serve the configured model (HTTP 404, or "does not exist"). */
27
+ | "model-not-found"
28
+ /** The backend is throttling (HTTP 429). */
29
+ | "rate-limited"
30
+ /** Network failure, timeout, or a 5xx from the backend. */
31
+ | "unreachable"
32
+ /** The backend rejected a yes/no or choice question (HTTP 400/422): the model cannot answer what AutoRAG asks. */
33
+ | "unsupported-question"
34
+ /** The backend answered, but not with a usable verdict. */
35
+ | "invalid-response";
36
+ export interface DecisionModelFailure {
37
+ readonly reason: DecisionModelFailureReason;
38
+ /** The backend's own error text, verbatim. */
39
+ readonly detail: string;
40
+ /** Backend name, when one was resolved. */
41
+ readonly backend?: string;
42
+ /** Model id the backend reported or was asked for. */
43
+ readonly model?: string;
44
+ }
45
+ /**
46
+ * The session's decision model cannot be used, so AutoRAG cannot answer. Carries a stable `code`
47
+ * ({@link DECISION_MODEL_UNAVAILABLE_CODE}) and the decision model's `reason` a host can branch on;
48
+ * `attempts` lists every model tried, the decision model first and the sLLM fallback after it. The
49
+ * message names the code, each failure with the backend's own error, and what to do about it.
50
+ */
51
+ export declare class DecisionModelUnavailableError extends Error {
52
+ readonly code = "decision-model-unavailable";
53
+ readonly reason: DecisionModelFailureReason;
54
+ readonly detail: string;
55
+ readonly backend?: string;
56
+ readonly model?: string;
57
+ readonly attempts: readonly DecisionModelFailure[];
58
+ constructor(failure: DecisionModelFailure, fallback?: DecisionModelFailure);
59
+ }
60
+ /** Map a backend's error text to a reason. HTTP status wins over wording. */
61
+ export declare function classifyDecisionModelFailure(detail: string): DecisionModelFailureReason;
62
+ /** The decision model that answered the probe. */
63
+ export interface DecisionModelStatus {
64
+ readonly backend: string;
65
+ readonly model?: string;
66
+ /** Set when the sLLM fallback answered: why the decision model itself could not. */
67
+ readonly fallbackFrom?: DecisionModelFailure;
68
+ }
69
+ /**
70
+ * Put the probe questions to the decision model. Resolves with the backend and model that answered;
71
+ * throws {@link DecisionModelUnavailableError} when no backend could be built, or it gave no
72
+ * probability to the yes/no probe or no option to the choice probe. Whether the answers are "right"
73
+ * does not matter: answers to both prove the model is reachable, authorized, served, and able to
74
+ * answer the kinds of question AutoRAG asks.
75
+ */
76
+ export declare function checkDecisionModel(judge: JevJudge): Promise<DecisionModelStatus>;
77
+ /** The session's decision model: the judge every caller asks, and the check that picks what it asks. */
78
+ export interface DecisionModels {
79
+ /** Asks the model the latest {@link DecisionModels.check} selected: Jev, or the sLLM fallback when Jev could not answer. */
80
+ readonly judge: JevJudge;
81
+ /**
82
+ * Probe Jev; when it is unavailable and a fallback is configured, probe the fallback. The first that
83
+ * answers serves every later judgment until the next check. Throws {@link DecisionModelUnavailableError}
84
+ * with every failure when none answers.
85
+ */
86
+ check(): Promise<DecisionModelStatus>;
87
+ }
88
+ /**
89
+ * The session's decision model from `options`: Jev (`options.backend`), with `options.sllm` behind it as
90
+ * the fallback, or the small chat LLM alone when `options.backend` is `"sllm"`.
91
+ */
92
+ export declare function createDecisionModels(options: JevJudgeOptions): DecisionModels;
@@ -4,6 +4,8 @@ import type { DupeyScanResult } from "../dupey/index.js";
4
4
  export declare const SCAN_DUPLICATE_DOCUMENTS_TOOL_NAME = "scan_duplicate_documents";
5
5
  export interface ScanDuplicateDocumentsDetails {
6
6
  readonly scans: readonly DupeyScanResult[];
7
+ /** Roots inside a cloud or network folder: `dupey scan` opens file contents, so they were not scanned. */
8
+ readonly skippedRoots: readonly string[];
7
9
  readonly familyCount: number;
8
10
  readonly exactDuplicateCount: number;
9
11
  }
@@ -17,6 +17,7 @@ export interface EverythingSearchDetails {
17
17
  }
18
18
  declare const everythingSearchSchema: Type.TObject<{
19
19
  query: Type.TString;
20
+ alternatives: Type.TOptional<Type.TArray<Type.TString>>;
20
21
  regex: Type.TOptional<Type.TBoolean>;
21
22
  matchCase: Type.TOptional<Type.TBoolean>;
22
23
  matchPath: Type.TOptional<Type.TBoolean>;
@@ -17,6 +17,7 @@ export interface FSearchSearchDetails {
17
17
  }
18
18
  declare const fsearchSearchSchema: Type.TObject<{
19
19
  query: Type.TString;
20
+ alternatives: Type.TOptional<Type.TArray<Type.TString>>;
20
21
  regex: Type.TOptional<Type.TBoolean>;
21
22
  matchCase: Type.TOptional<Type.TBoolean>;
22
23
  matchPath: Type.TOptional<Type.TBoolean>;
@@ -2,8 +2,10 @@ export type { AutoRAGAgentOptions, AutoRefreshOptions } from "./agent.js";
2
2
  export { AutoRAGAgent } from "./agent.js";
3
3
  export { CONVERT_FILES_TOOL_NAME, type ConvertFilesDetails, createConvertFilesTool, createListFileConversionsTool, type FileConversionProvider, LIST_FILE_CONVERSIONS_TOOL_NAME, } from "./convert-tool.js";
4
4
  export { buildDatasourceSkillsPrompt, createLoadDatasourceSkillTool, type DatasourceSkillProvider, datasourceSkillLocation, formatDatasourceSkillInvocation, LOAD_DATASOURCE_SKILL_TOOL_NAME, type LoadDatasourceSkillDetails, toDatasourceAgentSkill, } from "./datasource-skill.js";
5
+ export { DECISION_PROVIDER_DEFAULT_MODELS, type DecisionModelRuntime, PiDecisionBackend, type PiDecisionBackendOptions, } from "./decision-backends.js";
6
+ export { DECISION_MODEL_UNAVAILABLE_CODE, type DecisionModelFailure, type DecisionModelFailureReason, DecisionModelUnavailableError, } from "./decision-model-check.js";
5
7
  export { createScanDuplicateDocumentsTool, SCAN_DUPLICATE_DOCUMENTS_TOOL_NAME, type ScanDuplicateDocumentsDetails, type ScanDuplicateDocumentsProvider, } from "./dupey-tool.js";
6
- export { createJevExtension, JEV_TOOL_NAME, type JevBackendName, type JevToolOptions, } from "./jev-extension.js";
8
+ export { createJevExtension, JEV_TOOL_NAME, type JevToolOptions, } from "./jev-extension.js";
7
9
  export { createJikjiFindTool, JIKJI_FIND_TOOL_NAME, type JikjiFindDetails, type JikjiFindPerRootPolicy, type JikjiFindProvider, type JikjiFindProviderResult, type MergedJikjiPolicy, } from "./jikji-find-tool.js";
8
10
  export type { AutoRAGEmittedResult, AutoRAGMappingEntry, AutoRAGResultsDetails, } from "./results.js";
9
11
  export { reportSchema } from "./results.js";
@@ -11,4 +13,5 @@ export { createSearchAllDocumentsTool, SEARCH_ALL_DOCUMENTS_TOOL_NAME, type Sear
11
13
  export type { SearchDocumentDiagnostic, SearchDocumentDiagnosticCode, SearchDocumentDiagnosticSeverity, SearchDocumentEvidence, SearchDocumentResult, SearchDocumentsResponse, SearchDocumentsStreamEvent, SearchDocumentWarning, } from "./search-documents.js";
12
14
  export { createSearchMinSyncDocumentsTool, SEARCH_MINSYNC_DOCUMENTS_TOOL_NAME, type SearchMinSyncDocumentsDetails, } from "./search-minsync-tool.js";
13
15
  export { createSingleDatasourceSearchTools, formatDatasourceResults, SEARCH_SINGLE_DATASOURCE_TOOL_PREFIX, type SearchSingleDatasourceDetails, type SingleDatasourceSearchProvider, type SingleDatasourceToolSpec, singleDatasourceToolName, } from "./search-single-datasource-tool.js";
16
+ export { SLLM_BACKEND, SLLM_DECISION_TOOL_NAME, SllmDecisionBackend, type SllmDecisionModel } from "./sllm-decision.js";
14
17
  export { buildSystemPrompt, type SystemPromptConfig } from "./system-prompt.js";
@@ -1,46 +1,41 @@
1
1
  import type { ExtensionFactory } from "@earendil-works/pi-coding-agent";
2
2
  import { type JevBackend, type Judgment, type Question, type State } from "jev-use";
3
+ import { type SllmDecisionModel } from "./sllm-decision.js";
3
4
  /** `jev` tool name, kept in AutoRAG's reserved set and system prompt. */
4
5
  export declare const JEV_TOOL_NAME = "jev";
5
6
  /**
6
- * Jev backends the `jev-use` engine resolves from the environment, in
7
- * auto-select order: TypeSafe -> OpenRouter -> Vercel AI Gateway. `dazzi` is
8
- * the hosted Dazzi Models plan, built here rather than resolved by jev-use.
9
- */
10
- export type JevBackendName = "typesafe" | "openrouter" | "vercel" | "dazzi";
11
- /**
12
- * OpenRouter's live Jev model id. `jev-use` 0.8.0 ships `typesafe/jev-latest`,
13
- * which OpenRouter rejects with HTTP 400 ("Model ... does not exist"), so the
14
- * OpenRouter path is pinned here.
15
- */
16
- export declare const OPENROUTER_DEFAULT_MODEL = "typesafe/jev-1.13";
17
- /**
18
- * Options for the `jev` decision tool. Secrets never appear here: `jev-use`
19
- * reads the backend credential from its own environment variable
20
- * (`TYPESAFE_API_KEY`, `OPENROUTER_API_KEY`, or `AI_GATEWAY_API_KEY`).
7
+ * Options for the decision model. Secrets never appear here: a pi provider's credential comes from
8
+ * its environment variable (`OPENROUTER_API_KEY`, `OPENAI_API_KEY`, `TYPESAFE_API_KEY`,
9
+ * `AI_GATEWAY_API_KEY`, `CLOUDFLARE_API_KEY`, `OPENCODE_API_KEY`) or pi's `auth.json`, and the
10
+ * hosted `dazzi` backend uses the `/login` credential.
21
11
  */
22
12
  export interface JevToolOptions {
23
13
  /**
24
- * Force one backend by name; omit to let the first credential present win.
25
- * A ready-made `jev-use` backend instance is a programmatic seam (tests,
26
- * custom transports); config only accepts names.
27
- */
28
- readonly backend?: JevBackendName | JevBackend;
29
- /**
30
- * Wire model id sent with every call. Omit for the backend default;
31
- * OpenRouter is pinned to {@link OPENROUTER_DEFAULT_MODEL} because
32
- * `jev-use` 0.8.0's own default (`typesafe/jev-latest`) is not a live
33
- * OpenRouter model id.
14
+ * The decision backend: `dazzi`, or any pi provider whose catalog carries decision models
15
+ * (`openrouter`, `openai`, `typesafe`, `vercel-ai-gateway`, `cloudflare-workers-ai`, or `opencode`),
16
+ * or `"sllm"` to decide with the small chat LLM in {@link JevToolOptions.sllm} and never
17
+ * call Jev.
18
+ * Omit to take the Dazzi plan when signed in, else the first of
19
+ * {@link DECISION_PROVIDER_ORDER} whose API key is set. A ready-made `jev-use` backend instance is a
20
+ * programmatic seam (tests, custom transports); config only accepts names.
34
21
  */
22
+ readonly backend?: string | JevBackend;
23
+ /** Decision model id within the backend, e.g. `openai/gpt-6-luna-decisions` on OpenRouter. Omit for the backend default. */
35
24
  readonly model?: string;
36
25
  /** Escalate verdicts below this confidence. Default: per-source thresholds. */
37
26
  readonly confidenceThreshold?: number;
27
+ /**
28
+ * The small chat LLM (sLLM): the decision model when `backend` is `"sllm"`, otherwise the
29
+ * fallback the session moves to when the session check finds the decision model unavailable. A
30
+ * `jev-use` backend instance is the programmatic seam. Omit for no fallback.
31
+ */
32
+ readonly sllm?: SllmDecisionModel | JevBackend;
38
33
  }
39
- /** {@link JevToolOptions} plus the environment `jev-use` resolves credentials from. */
34
+ /** {@link JevToolOptions} plus where credentials are read from. */
40
35
  export interface JevJudgeOptions extends JevToolOptions {
41
- /** Environment consulted for the backend credential. Default `process.env`. */
36
+ /** Environment consulted for the backend credential, ahead of `process.env`. */
42
37
  readonly env?: Record<string, string | undefined>;
43
- /** Pi agent home whose `auth.json` holds the Dazzi `/login` credential. Default: Pi's agent dir. */
38
+ /** Pi agent home: `auth.json` (credentials, the Dazzi `/login`) and `models.json`. Default: Pi's agent dir. */
44
39
  readonly agentDir?: string;
45
40
  }
46
41
  /**
@@ -51,11 +46,11 @@ export interface JevJudgeOptions extends JevToolOptions {
51
46
  export type JevJudge = (state: State, questions: Question[], options?: {
52
47
  readonly confidenceThreshold?: number;
53
48
  }) => Promise<Judgment>;
49
+ /** The `jev-use` backend for the small chat LLM: a ready-made backend instance is used as is. */
50
+ export declare function sllmBackend(sllm: SllmDecisionModel | JevBackend): JevBackend;
54
51
  /**
55
- * Builds the Jev judge shared by the `jev` tool and the query router. The
56
- * `jev-use` client is created lazily on the first call, so no credential
57
- * resolves at construction time, and the per-backend model default (the
58
- * OpenRouter pin, or `jev-1.13` on the hosted plan) applies to every caller.
52
+ * Builds a Jev judge over one decision backend. The backend is built lazily on the first call, so
53
+ * no credential resolves at construction time; a missing one rejects that call with a named error.
59
54
  */
60
55
  export declare function createJevJudge(options?: JevJudgeOptions): JevJudge;
61
56
  /**
@@ -14,7 +14,10 @@ export interface MergedJikjiPolicy {
14
14
  readonly forbiddenTools: readonly string[];
15
15
  readonly allowedFollowups: readonly string[];
16
16
  readonly agentShouldNotRerank: boolean;
17
+ /** True only when every root's envelope allowed raw fallback. */
17
18
  readonly rawFallbackAllowed: boolean;
19
+ /** Smallest `max_raw_fallback_commands` any root reported; undefined when none did. */
20
+ readonly maxRawFallbackCommands?: number;
18
21
  }
19
22
  /**
20
23
  * Per-root policy summary for one successful (ok) root, captured BEFORE the
@@ -55,6 +58,8 @@ export interface JikjiFindDetails {
55
58
  readonly handoffAction: JikjiHandoffAction | undefined;
56
59
  readonly stopAfterFind: boolean | undefined;
57
60
  readonly rawFallbackAllowed: boolean | undefined;
61
+ /** Raw shell commands jikji allows once raw fallback is open (`max_raw_fallback_commands`). */
62
+ readonly maxRawFallbackCommands: number | undefined;
58
63
  readonly sources: readonly string[];
59
64
  readonly candidates: readonly JikjiCandidate[];
60
65
  readonly evidencePack: readonly JikjiEvidence[];
@@ -0,0 +1,88 @@
1
+ /**
2
+ * Parallel file-name search over several candidate names.
3
+ *
4
+ * File-name search is cheap (an index lookup), but the right name is rarely
5
+ * known: the user's word, its translation, an abbreviation, a likely
6
+ * extension. Instead of one call per guess, every candidate is searched at the
7
+ * same time and the hits are merged, with each hit labelled by the candidates
8
+ * that found it.
9
+ */
10
+ /** Candidates searched in one call; the rest are reported as dropped, never silently ignored. */
11
+ export declare const MAX_NAME_CANDIDATES = 8;
12
+ export interface NameCandidates {
13
+ readonly candidates: readonly string[];
14
+ /** Distinct candidates beyond {@link MAX_NAME_CANDIDATES} that were not searched. */
15
+ readonly dropped: number;
16
+ }
17
+ /**
18
+ * The query first, then the alternatives, trimmed and without repeats. Case
19
+ * variants count as one candidate unless the search is case-sensitive.
20
+ */
21
+ export declare function collectNameCandidates(query: string, alternatives?: readonly string[], options?: {
22
+ readonly matchCase?: boolean;
23
+ }): NameCandidates;
24
+ /** What one file-name search returned: hits, or a failure that names why. Backends' own results satisfy it. */
25
+ export type NameSearchResult = {
26
+ readonly ok: true;
27
+ readonly results: readonly {
28
+ readonly path: string;
29
+ }[];
30
+ } | {
31
+ readonly ok: false;
32
+ readonly reason: string;
33
+ readonly message: string;
34
+ };
35
+ /** A search that threw, reported as the failure of its own candidate. */
36
+ export interface NameSearchFailure {
37
+ readonly ok: false;
38
+ readonly reason: string;
39
+ readonly message: string;
40
+ }
41
+ /** `Result` is the backend's own result type, so callers keep fields such as `backend` and `total`. */
42
+ export interface NameSearchOutcome<Result extends NameSearchResult = NameSearchResult> {
43
+ readonly candidate: string;
44
+ readonly result: Result | NameSearchFailure;
45
+ }
46
+ /**
47
+ * Search every candidate at once. A search that throws fails only its own
48
+ * candidate; the others still return.
49
+ */
50
+ export declare function searchNameCandidates<Result extends NameSearchResult>(candidates: readonly string[], search: (candidate: string) => Promise<Result>): Promise<NameSearchOutcome<Result>[]>;
51
+ export interface MergedNameHit<Entry extends {
52
+ readonly path: string;
53
+ }> {
54
+ readonly entry: Entry;
55
+ /** Every candidate that found this path, in candidate order. */
56
+ readonly candidates: readonly string[];
57
+ }
58
+ /**
59
+ * One list of hits, each path once. The name indexes (Everything, FSearch) match
60
+ * names exactly and return their hits in a sort order, not by relevance, so no
61
+ * hit is "better" than another within one candidate. What does carry signal is
62
+ * how many of the searched names found a path: those come first. Within the
63
+ * same count, the candidates' lists are interleaved position by position, so the
64
+ * cut at `limit` is shared among the candidates instead of one filling it.
65
+ */
66
+ export declare function mergeNameHits<Entry extends {
67
+ readonly path: string;
68
+ }>(outcomes: readonly {
69
+ readonly candidate: string;
70
+ readonly result: {
71
+ readonly ok: true;
72
+ readonly results: readonly Entry[];
73
+ } | NameSearchFailure;
74
+ }[], limit: number): MergedNameHit<Entry>[];
75
+ /** One hit as a numbered line; `foundBy` is shown only when several names were searched. */
76
+ export declare function renderNameHitLine(index: number, entry: {
77
+ readonly path: string;
78
+ readonly type: string;
79
+ readonly size?: number | undefined;
80
+ readonly dateModified?: string | undefined;
81
+ }, foundBy?: readonly string[]): string;
82
+ /** Lines that say which candidates failed and which were never searched; empty when everything ran. */
83
+ export declare function renderNameSearchProblems(outcomes: readonly {
84
+ readonly candidate: string;
85
+ readonly result: {
86
+ readonly ok: true;
87
+ } | NameSearchFailure;
88
+ }[], dropped: number): string[];
@@ -46,11 +46,8 @@ export declare class PermissionController {
46
46
  }
47
47
  export interface PermissionGateOptions {
48
48
  readonly controller: PermissionController;
49
- /**
50
- * Jev, which classifies every gated call. Without one the gate cannot classify, so in `ask` and `auto` it
51
- * asks the user about every `bash`, `write`, and `edit` call.
52
- */
53
- readonly judge?: JevJudge;
49
+ /** Jev, which classifies every gated call in `auto`. */
50
+ readonly judge: JevJudge;
54
51
  /**
55
52
  * What the user has said in this conversation: the first question, every follow-up, every steer. Jev judges
56
53
  * the call against all of it. The host feeds it from the user's own input, so AutoRAG's internal phase
@@ -161,6 +161,6 @@ export interface PastSearchHint {
161
161
  * withheld when a configured datasource already uses that id
162
162
  * ({@link DatasourceSelection.webIdTaken}), so a question id never names two
163
163
  * candidates. Never throws: a missing credential or an unreachable backend
164
- * searches nothing, which is the behavior without Jev.
164
+ * searches nothing.
165
165
  */
166
166
  export declare function selectDatasources(judge: JevJudge, query: string, datasources: readonly DatasourceCandidate[], pastSearches?: readonly PastSearchHint[], options?: SelectDatasourcesOptions): Promise<DatasourceSelection>;
@@ -9,7 +9,7 @@ export type SearchDocumentDiagnosticSeverity = "info" | "warning" | "error";
9
9
  * (#21/#22) does not require another source-breaking type change; codes not yet
10
10
  * emitted are still valid members.
11
11
  */
12
- export type SearchDocumentDiagnosticCode = "empty-query" | "no-verified-results" | "unknown-warning" | "caller-tool-dropped" | "minsync-staging-excluded" | "minsync-file-skipped" | "minsync-sync-failed" | "minsync-lock-held" | "embedder-unavailable" | "embedding-identity-mismatch" | "lexical-tokenizer-unavailable" | "parser-skipped" | "parser-failed" | "parser-crashed" | "source-changed" | "source-vanished" | "source-unreadable" | "source-read-failed" | "mirror-write-failed" | "parser-warning" | "duplicate-excluded" | "unsupported-file" | "stale-index" | "deleted-mirror" | "search-root-unavailable" | "mass-delete-suppressed" | "walk-truncated" | "directory-unreadable" | "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" | "tool-call-burst" | "query-routed" | "query-route-fallback" | "query-decomposition-failed" | "follow-up-skipped" | "follow-up-check-fallback" | "datasources-selected" | "datasource-selection-fallback" | "web-datasource-id-taken" | "web-search-failed" | "citation-without-result" | "line-reference-unverified" | "citation-irrelevant" | "citation-relevance-fallback" | "evidence-judged" | "evidence-judgment-fallback" | "memory-search-fallback" | "self-config-unavailable" | "self-config-rolled-back" | "organize-skill-unavailable" | "embedding-unavailable";
12
+ export type SearchDocumentDiagnosticCode = "empty-query" | "no-verified-results" | "unknown-warning" | "caller-tool-dropped" | "minsync-staging-excluded" | "minsync-file-skipped" | "minsync-sync-failed" | "minsync-lock-held" | "embedder-unavailable" | "embedding-identity-mismatch" | "parser-skipped" | "parser-failed" | "parser-crashed" | "source-changed" | "source-vanished" | "source-unreadable" | "source-read-failed" | "mirror-write-failed" | "parser-warning" | "duplicate-excluded" | "unsupported-file" | "stale-index" | "deleted-mirror" | "search-root-unavailable" | "mass-delete-suppressed" | "walk-truncated" | "directory-unreadable" | "cloud-download-deferred" | "cloud-placeholder-skipped" | "cloud-evict-failed" | "cloud-fingerprint-failed" | "pdf-extract-thin" | "retrieval-method-failed" | "rerank-failed" | "rerank-disabled" | "jikji-unavailable" | "jikji-prepare-failed" | "jikji-cloud-root-skipped" | "jikji-find-failed" | "jikji-discover-failed" | "jikji-unsupported-version" | "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" | "tool-call-burst" | "decision-model-checked" | "decision-model-fallback" | "query-routed" | "query-route-fallback" | "query-decomposition-failed" | "follow-up-skipped" | "follow-up-check-fallback" | "datasources-selected" | "datasource-selection-fallback" | "web-datasource-id-taken" | "web-search-failed" | "citation-without-result" | "line-reference-unverified" | "citation-irrelevant" | "citation-relevance-fallback" | "evidence-judged" | "evidence-judgment-fallback" | "memory-search-fallback" | "self-config-unavailable" | "self-config-rolled-back" | "organize-skill-unavailable" | "embedding-unavailable";
13
13
  export interface SearchDocumentDiagnostic {
14
14
  readonly code: SearchDocumentDiagnosticCode;
15
15
  readonly severity: SearchDocumentDiagnosticSeverity;
@@ -0,0 +1,34 @@
1
+ import type { Api, Model } from "@earendil-works/pi-ai";
2
+ import { type BackendRequest, type BackendResponse, type JevBackend } from "jev-use";
3
+ /**
4
+ * The decision model's fallback: a small chat LLM (sLLM) answering Jev's typed questions. It is
5
+ * used only when the session check finds Jev unavailable. A chat model's probabilities are its own
6
+ * estimate, not a calibrated decision head, so a session on it is reported as degraded.
7
+ *
8
+ * Every request builds its own answer format: a tool whose arguments are one required key per
9
+ * question (the wire-safe key of its id), holding `yes` for a yes/no question or one named
10
+ * probability per option or level for a choice or score question, plus a confidence. The tool asks
11
+ * for JSON-schema constrained sampling, which providers that support it enforce; the prompt carries
12
+ * the same format as an example reply for the rest. The reply is read from the tool call, or else
13
+ * from the JSON the text holds, leniently. Answers that are missing or malformed are asked again
14
+ * once, alone; whatever is still unanswered then goes back to Jev's engine as unanswered, and the
15
+ * answers that were read are kept.
16
+ */
17
+ /** The small LLM and the credential used only for fallback decisions. */
18
+ export interface SllmDecisionModel {
19
+ readonly model: Model<Api>;
20
+ readonly apiKey?: string;
21
+ }
22
+ /** `jev.backend` value, and the backend name, of the small LLM deciding in Jev's place. */
23
+ export declare const SLLM_BACKEND = "sllm";
24
+ /** The tool the small LLM answers through. */
25
+ export declare const SLLM_DECISION_TOOL_NAME = "submit_decisions";
26
+ /** The small-LLM fallback behind jev-use's backend contract. */
27
+ export declare class SllmDecisionBackend implements JevBackend {
28
+ readonly name = "sllm";
29
+ private readonly target;
30
+ constructor(target: SllmDecisionModel);
31
+ judge(request: BackendRequest): Promise<BackendResponse>;
32
+ /** One request for `pending`: its own tool and example, temperature 0, reasoning off. */
33
+ private ask;
34
+ }
@@ -0,0 +1,4 @@
1
+ /** Tokens in `text`, never fewer than the chars/4 guess so prose keeps the budget it had. */
2
+ export declare function estimateTextTokens(text: string): number;
3
+ /** How many tokens the pieces add beyond their chars/4 guesses; zero for prose. */
4
+ export declare function tokensBeyondCharGuess(parts: readonly string[]): number;
@@ -1,10 +1,11 @@
1
1
  import type { DupeyScanResult } from "../../dupey/index.js";
2
+ import { type CloudFileProbe } from "../../filesystem/cloud-placeholder.js";
2
3
  import type { CommandContext } from "./types.js";
3
- export type DuplicateScanner = (path: string) => Promise<DupeyScanResult>;
4
+ export type DuplicateScanner = (path: string, excludeDirs: readonly string[]) => Promise<DupeyScanResult>;
4
5
  /**
5
6
  * `autorag duplicates` — scan configured roots for exact and near duplicate
6
7
  * document families. Never deletes or moves source files.
7
8
  *
8
9
  * Exit codes: 0 on success, 2 on config error, 1 on runtime error.
9
10
  */
10
- export declare function runDuplicates(ctx: CommandContext, scanner?: DuplicateScanner): Promise<number>;
11
+ export declare function runDuplicates(ctx: CommandContext, scanner?: DuplicateScanner, cloudProbe?: CloudFileProbe | undefined): Promise<number>;
@@ -16,6 +16,8 @@ export interface ModelCatalogOptions {
16
16
  readonly provider?: string;
17
17
  /** Only list models whose provider has complete auth configuration. */
18
18
  readonly available?: boolean;
19
+ /** List decision models (the `jev.backend`/`jev.model` candidates) instead of chat models. */
20
+ readonly decision?: boolean;
19
21
  readonly agentDir?: string;
20
22
  }
21
23
  export interface ModelsCommandDeps {
@@ -1,6 +1,8 @@
1
1
  import { AutoRAGAgent, type AutoRAGAgentOptions } from "../../agent/agent.js";
2
2
  import { type CliConfig, type ResolveAgentModelOptions, type ResolvedAgentModel } from "../config.js";
3
3
  import type { CommandContext } from "./types.js";
4
+ /** Exit status of a search whose session decision model cannot answer: AutoRAG is unusable until it can. */
5
+ export declare const DECISION_MODEL_UNAVAILABLE_EXIT_CODE = 3;
4
6
  /**
5
7
  * A recoverable health hint surfaced when `autorag search` fails for a reason
6
8
  * that `autorag health` can diagnose. The classifier only produces hints for