@autorag/librarian 2.11.0 → 2.13.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.
Files changed (87) hide show
  1. package/NOTICE +6 -0
  2. package/README.md +14 -6
  3. package/dist/agent/agent.d.ts +136 -33
  4. package/dist/agent/answer-citations.d.ts +34 -2
  5. package/dist/agent/answer-guidelines.d.ts +20 -3
  6. package/dist/agent/ask-user.d.ts +8 -0
  7. package/dist/agent/automation-tool.d.ts +45 -0
  8. package/dist/agent/citation-links.d.ts +23 -0
  9. package/dist/agent/citation-numbers.d.ts +68 -0
  10. package/dist/agent/citation-relevance.d.ts +37 -0
  11. package/dist/agent/conversation-queries.d.ts +31 -0
  12. package/dist/agent/convert-tool.d.ts +28 -0
  13. package/dist/agent/current-date.d.ts +10 -0
  14. package/dist/agent/datasource-skill.d.ts +2 -2
  15. package/dist/agent/environment-prompt.d.ts +20 -0
  16. package/dist/agent/evidence-ledger.d.ts +4 -2
  17. package/dist/agent/evidence-persistence.d.ts +17 -11
  18. package/dist/agent/index.d.ts +1 -0
  19. package/dist/agent/intent-tracing.d.ts +33 -0
  20. package/dist/agent/location-claims.d.ts +14 -0
  21. package/dist/agent/packaged-skill.d.ts +19 -0
  22. package/dist/agent/permission-gate.d.ts +78 -0
  23. package/dist/agent/permission-judgment.d.ts +72 -0
  24. package/dist/agent/permission-paths.d.ts +23 -0
  25. package/dist/agent/query-routing.d.ts +78 -27
  26. package/dist/agent/results.d.ts +10 -2
  27. package/dist/agent/search-documents.d.ts +6 -1
  28. package/dist/agent/self-config.d.ts +6 -4
  29. package/dist/agent/skill-invocation.d.ts +17 -0
  30. package/dist/agent/user-requests.d.ts +52 -0
  31. package/dist/automation/config.d.ts +48 -0
  32. package/dist/automation/daemon.d.ts +31 -0
  33. package/dist/automation/dispatch.d.ts +13 -0
  34. package/dist/automation/run-agent.d.ts +22 -0
  35. package/dist/automation/run.d.ts +32 -0
  36. package/dist/automation/service.d.ts +61 -0
  37. package/dist/cli/commands/automate.d.ts +2 -0
  38. package/dist/cli/commands/evidence.d.ts +2 -0
  39. package/dist/cli/config.d.ts +21 -0
  40. package/dist/cli/index.d.ts +1 -1
  41. package/dist/cli/index.js +19531 -14871
  42. package/dist/cli/open-target.d.ts +9 -0
  43. package/dist/cli/setup.d.ts +14 -0
  44. package/dist/convert/cli.d.ts +77 -0
  45. package/dist/convert/index.d.ts +4 -0
  46. package/dist/convert/installer.d.ts +84 -0
  47. package/dist/convert/matrix.d.ts +27 -0
  48. package/dist/convert/relate.d.ts +30 -0
  49. package/dist/core.js +32479 -28141
  50. package/dist/datasource/connector-timeouts.d.ts +6 -2
  51. package/dist/datasource/crawler-skill.d.ts +1 -0
  52. package/dist/datasource/crawler-types.d.ts +1 -1
  53. package/dist/datasource/index.d.ts +1 -1
  54. package/dist/datasource/sidecar/methods.d.ts +8 -1
  55. package/dist/datasource/skills/clawgallery/skill.d.ts +4 -0
  56. package/dist/datasource/skills/discrawl/skill.d.ts +5 -0
  57. package/dist/datasource/skills/factory.d.ts +5 -1
  58. package/dist/datasource/skills/lazykatok/index.d.ts +1 -1
  59. package/dist/datasource/skills/lazykatok/methods.d.ts +5 -5
  60. package/dist/datasource/skills/lazykatok/skill.d.ts +1 -0
  61. package/dist/datasource/skills/lazykatok/types.d.ts +2 -2
  62. package/dist/datasource/skills/mailcrawl/skill.d.ts +1 -0
  63. package/dist/datasource/skills/mailcrawl/types.d.ts +1 -1
  64. package/dist/dupey/cli.d.ts +18 -0
  65. package/dist/index.d.ts +1 -0
  66. package/dist/index.js +32558 -28145
  67. package/dist/mcp/index.js +32651 -28263
  68. package/dist/memory/memory.d.ts +4 -1
  69. package/dist/minsync/installer.d.ts +1 -1
  70. package/dist/mirror/atomic-write.d.ts +16 -1
  71. package/dist/mirror/sync.d.ts +2 -0
  72. package/dist/profiles/agent-factory.d.ts +60 -0
  73. package/dist/profiles/automation-profiles.d.ts +25 -0
  74. package/dist/profiles/loop-guard.d.ts +23 -0
  75. package/dist/profiles/retrieval-tools.d.ts +24 -0
  76. package/dist/profiles/session-model.d.ts +69 -0
  77. package/dist/profiles.d.ts +13 -0
  78. package/dist/profiles.js +35246 -0
  79. package/dist/retrieval/chunk-location.d.ts +28 -0
  80. package/dist/retrieval/fallback.d.ts +24 -0
  81. package/dist/retrieval/index.d.ts +1 -0
  82. package/dist/retrieval/rerank.d.ts +6 -0
  83. package/dist/retrieval/types.d.ts +16 -0
  84. package/internal-skills/organize/SKILL.md +43 -0
  85. package/package.json +9 -2
  86. package/skills/autorag/SKILL.md +89 -7
  87. package/skills/autorag-setup/SKILL.md +10 -4
@@ -2,15 +2,25 @@ import type { JevJudge } from "./jev-extension.js";
2
2
  /**
3
3
  * Where a user question is answered from:
4
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.
5
+ * the user's files, chats, mail, or any fact the model cannot reliably recall,
6
+ * recent, specific, or changing public facts included. Local retrieval runs
7
+ * first, together with every datasource Jev selects, the public web among
8
+ * them when web tools are enabled.
9
+ * - `organize`: the user wants files or folders acted on — move, rename in
10
+ * bulk, rename by content, convert, sort, tidy — rather than information
11
+ * found. No retrieval and no verification: one tool-capable turn does it.
12
+ * - `extra`: neither of the other branches, and no search of the user's own
13
+ * records is needed first: the request is answerable from the model's own
14
+ * knowledge (stable general knowledge, definitions, simple reasoning, small
15
+ * talk), or it is a task for the agent's tools that is not file organization
16
+ * and not AutoRAG configuration (commit, PR, build, write code, run a
17
+ * script). No retrieval, decomposition, fast answer, follow-up check, or
18
+ * verification: one tool-capable turn does it, with every tool available.
9
19
  * - `config`: the user wants to inspect or change AutoRAG's own settings
10
20
  * (model, providers, datasources). Offered only when the host enables
11
21
  * agent self-configuration.
12
22
  */
13
- export type QueryRoute = "local" | "direct" | "config";
23
+ export type QueryRoute = "local" | "organize" | "extra" | "config";
14
24
  /** Jev question id of the intrinsic-knowledge / local branch. */
15
25
  export declare const QUERY_ROUTE_QUESTION_ID = "route";
16
26
  /** Jev question id of the "does this need decomposition?" check. */
@@ -24,18 +34,35 @@ export declare const DECOMPOSE_PROBABILITY_THRESHOLD = 0.5;
24
34
  /** A `noul` probability at or above this sends the fast answer on to verification. */
25
35
  export declare const FOLLOW_UP_PROBABILITY_THRESHOLD = 0.5;
26
36
  /**
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.
37
+ * Minimum Jev branch probability required to leave local search. A non-local
38
+ * branch (`organize`, `extra`, `config`) at or below this floor — or one Jev
39
+ * reported without a probability — keeps the run on local search, the
40
+ * corpus-grounded default, with a `query-route-fallback` diagnostic naming the
41
+ * floor as the reason (the rejected branch's probability is still reported as
42
+ * `routeProbability`). Without the floor a weakly-favored non-local verdict
43
+ * skips retrieval entirely, so a question that depends on the user's own
44
+ * records can be answered from general knowledge instead.
45
+ *
46
+ * The floor does not weaken a real non-local verdict: the fallback is a
47
+ * full local plan (datasource selection and decomposition still run). Removed
48
+ * by #1995 (982e464d) together with the intrinsic-knowledge branch, restored
49
+ * here because the reasons above did not go away.
33
50
  */
34
51
  export declare const NON_LOCAL_ROUTE_PROBABILITY_THRESHOLD = 0.75;
35
52
  /** A `noul` probability at or above this searches that datasource before the fast answer. */
36
53
  export declare const DATASOURCE_PROBABILITY_THRESHOLD = 0.5;
37
54
  /** Jev question id of the "search this datasource?" check for one datasource. */
38
55
  export declare function datasourceQuestionId(datasourceId: string): string;
56
+ /**
57
+ * Reserved candidate id of the public web in the datasource gate.
58
+ *
59
+ * Datasource ids come from the config's `datasources` keys, which are only
60
+ * required to be non-empty (see `DatasourceSkillRegistry.register`), so a
61
+ * configured datasource *can* be called `web`. When one is, the web candidate
62
+ * is withheld and {@link DatasourceSelection.webIdTaken} says so, so the
63
+ * question id `datasource:web` always names exactly one candidate.
64
+ */
65
+ export declare const WEB_DATASOURCE_ID = "web";
39
66
  export interface FollowUpDecision {
40
67
  /** True when the run continues into the verification phase. */
41
68
  readonly followUp: boolean;
@@ -54,7 +81,7 @@ export declare function needsFollowUp(judge: JevJudge, query: string, answer: st
54
81
  export interface QueryRouteDecision {
55
82
  /** Most probable branch; {@link FALLBACK_QUERY_ROUTE} when Jev gave none or its non-local branch missed {@link NON_LOCAL_ROUTE_PROBABILITY_THRESHOLD}. */
56
83
  readonly route: QueryRoute;
57
- /** True when Jev judged the question needs decomposition (never for `direct`). */
84
+ /** True when Jev judged the question needs decomposition; only a `local` route acts on it. */
58
85
  readonly decompose: boolean;
59
86
  /** Probability Jev gave the winning branch, including a rejected non-local branch whose floor moved the route to local. */
60
87
  readonly routeProbability?: number;
@@ -62,17 +89,27 @@ export interface QueryRouteDecision {
62
89
  readonly decomposeProbability?: number;
63
90
  /** Why the decision fell back instead of following Jev; absent when Jev decided. */
64
91
  readonly fallbackReason?: string;
92
+ /**
93
+ * True when a non-local branch won but did not clear
94
+ * {@link NON_LOCAL_ROUTE_PROBABILITY_THRESHOLD}: `route` is `local` and the
95
+ * full local plan still runs (datasource selection and decomposition),
96
+ * unlike a fallback from an unavailable or unusable verdict, which keeps a
97
+ * bare single-query local search.
98
+ */
99
+ readonly floorApplied?: boolean;
65
100
  }
66
101
  export interface RouteQueryOptions {
67
102
  /** Offer the `config` branch: the agent may change its own settings. */
68
103
  readonly selfConfig?: boolean;
69
104
  }
70
105
  /**
71
- * Ask Jev, in one batched call about the user question, which branch answers
72
- * it and whether it needs decomposition. Never throws: a missing credential,
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.
106
+ * Ask Jev, in one batched call about the user question, which branch handles it
107
+ * and whether it needs decomposition. The most probable branch wins once it
108
+ * clears {@link NON_LOCAL_ROUTE_PROBABILITY_THRESHOLD}: a weakly-favored or
109
+ * probability-less `organize`, `extra`, or `config` verdict keeps the local
110
+ * default and still runs the full local plan (`floorApplied`). Never throws: a
111
+ * missing credential, an unreachable backend, or an unusable verdict falls back
112
+ * to a single local search, with the reason recorded.
76
113
  */
77
114
  export declare function routeQuery(judge: JevJudge, query: string, options?: RouteQueryOptions): Promise<QueryRouteDecision>;
78
115
  /** One configured datasource Jev may send the question to. */
@@ -84,12 +121,23 @@ export interface DatasourceCandidate {
84
121
  readonly description: string;
85
122
  }
86
123
  export interface DatasourceSelection {
87
- /** Datasource ids to search, in registration order. */
124
+ /** Datasource ids to search, in registration order; the web candidate's id is {@link WEB_DATASOURCE_ID}. */
88
125
  readonly selected: readonly string[];
89
- /** Jev's P(search needed) per datasource id, for every datasource it answered. */
126
+ /** Jev's P(search needed) per candidate id, for every candidate it answered. */
90
127
  readonly probabilities: Readonly<Record<string, number>>;
91
128
  /** Why no datasource is searched instead of following Jev; absent when Jev decided. */
92
129
  readonly fallbackReason?: string;
130
+ /**
131
+ * True when the web candidate was withheld because a configured datasource
132
+ * already uses {@link WEB_DATASOURCE_ID}: `datasource:web` then names that
133
+ * configured datasource, and the run searches no web before the fast answer.
134
+ */
135
+ readonly webIdTaken?: boolean;
136
+ }
137
+ /** Options of {@link selectDatasources}. */
138
+ export interface SelectDatasourcesOptions {
139
+ /** Offer the public web as one more candidate (the host has web tools enabled). */
140
+ readonly web?: boolean;
93
141
  }
94
142
  /** A similar question asked before, its results, and where each was found. */
95
143
  export interface PastSearchHint {
@@ -104,12 +152,15 @@ export interface PastSearchHint {
104
152
  }[];
105
153
  }
106
154
  /**
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.
155
+ * Ask Jev, in one batched call, one `noul` per candidate: does answering the
156
+ * question need that datasource searched? The state describes every candidate
157
+ * (descriptions are flagged as non-exhaustive summaries), so Jev judges each
158
+ * one against the others, plus where similar past questions were answered,
159
+ * when retrieval memory has any. With `options.web`, the public web is one
160
+ * more candidate, under the reserved id {@link WEB_DATASOURCE_ID}; it is
161
+ * withheld when a configured datasource already uses that id
162
+ * ({@link DatasourceSelection.webIdTaken}), so a question id never names two
163
+ * candidates. Never throws: a missing credential or an unreachable backend
164
+ * searches nothing, which is the behavior without Jev.
114
165
  */
115
- export declare function selectDatasources(judge: JevJudge, query: string, datasources: readonly DatasourceCandidate[], pastSearches?: readonly PastSearchHint[]): Promise<DatasourceSelection>;
166
+ export declare function selectDatasources(judge: JevJudge, query: string, datasources: readonly DatasourceCandidate[], pastSearches?: readonly PastSearchHint[], options?: SelectDatasourcesOptions): Promise<DatasourceSelection>;
@@ -16,6 +16,8 @@ export declare const reportSchema: Type.TObject<{
16
16
  evidence: Type.TArray<Type.TObject<{
17
17
  excerpt: Type.TString;
18
18
  lineNumber: Type.TOptional<Type.TInteger>;
19
+ lineEnd: Type.TOptional<Type.TInteger>;
20
+ section: Type.TOptional<Type.TString>;
19
21
  }>>;
20
22
  confidence: Type.TNumber;
21
23
  }>>;
@@ -38,7 +40,8 @@ export declare const reportSchema: Type.TObject<{
38
40
  documentType: Type.TOptional<Type.TString>;
39
41
  documentArea: Type.TOptional<Type.TString>;
40
42
  evidenceType: Type.TOptional<Type.TString>;
41
- evidenceLocation: Type.TOptional<Type.TString>;
43
+ lineEnd: Type.TOptional<Type.TInteger>;
44
+ section: Type.TOptional<Type.TString>;
42
45
  confidence: Type.TOptional<Type.TNumber>;
43
46
  }>>>;
44
47
  }>>;
@@ -47,6 +50,10 @@ export declare const reportSchema: Type.TObject<{
47
50
  export interface AutoRAGEmittedEvidence {
48
51
  readonly excerpt: string;
49
52
  readonly lineNumber?: number;
53
+ /** Last line of the chunk; with {@link lineNumber} the exact range in the parsed document. */
54
+ readonly lineEnd?: number;
55
+ /** Article or heading the chunk sits in. */
56
+ readonly section?: string;
50
57
  }
51
58
  export interface AutoRAGEmittedResult {
52
59
  readonly number: number;
@@ -64,13 +71,14 @@ export interface AutoRAGEvidenceRef {
64
71
  readonly retrievalResultId?: string;
65
72
  readonly chunkIndex?: number;
66
73
  readonly lineNumber?: number;
74
+ readonly lineEnd?: number;
75
+ readonly section?: string;
67
76
  readonly stableEvidenceId?: string;
68
77
  readonly retrieverMix?: readonly string[];
69
78
  readonly parserType?: string;
70
79
  readonly documentType?: string;
71
80
  readonly documentArea?: string;
72
81
  readonly evidenceType?: string;
73
- readonly evidenceLocation?: string;
74
82
  readonly confidence?: number;
75
83
  }
76
84
  export interface AutoRAGMappingEntry {
@@ -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-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" | "citation-without-result" | "evidence-judged" | "evidence-judgment-fallback" | "memory-search-fallback" | "self-config-unavailable" | "self-config-rolled-back" | "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" | "lexical-tokenizer-unavailable" | "parser-skipped" | "parser-failed" | "parser-crashed" | "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";
13
13
  export interface SearchDocumentDiagnostic {
14
14
  readonly code: SearchDocumentDiagnosticCode;
15
15
  readonly severity: SearchDocumentDiagnosticSeverity;
@@ -19,7 +19,12 @@ export interface SearchDocumentDiagnostic {
19
19
  }
20
20
  export interface SearchDocumentEvidence {
21
21
  readonly excerpt: string;
22
+ /** First line of the chunk in its parsed document, measured by the harness. */
22
23
  readonly lineNumber?: number;
24
+ /** Last line of the chunk in its parsed document. */
25
+ readonly lineEnd?: number;
26
+ /** Article or heading the chunk sits in. */
27
+ readonly section?: string;
23
28
  }
24
29
  export interface SearchDocumentResult {
25
30
  readonly number: number;
@@ -1,3 +1,4 @@
1
+ import type { PackagedAgentSkill } from "./packaged-skill.js";
1
2
  /**
2
3
  * Host opt-in for agent self-configuration: the Jev `config` branch, where the
3
4
  * agent edits its own settings with the full `autorag-setup` skill in hand.
@@ -5,7 +6,7 @@
5
6
  export interface SelfConfigOptions {
6
7
  /** The active AutoRAG config file the agent may read and edit. */
7
8
  readonly configPath: string;
8
- /** Override for the `autorag-setup` SKILL.md; defaults to the packaged skill. */
9
+ /** Override for the packaged `autorag-setup` skill file; defaults to the packaged skill. */
9
10
  readonly skillPath?: string;
10
11
  /**
11
12
  * Check the config file after a config turn changed it. Resolves to a
@@ -14,13 +15,14 @@ export interface SelfConfigOptions {
14
15
  */
15
16
  readonly validate?: (configPath: string) => Promise<string | undefined>;
16
17
  }
17
- /** Full text of the `autorag-setup` skill with its YAML front matter removed. */
18
- export declare function loadSetupSkill(skillPath?: string): string;
19
18
  export interface SelfConfigPromptInput {
20
19
  readonly query: string;
21
20
  readonly configPath: string;
22
21
  readonly agentDir: string;
23
- readonly skill: string;
22
+ /** The loaded `autorag-setup` skill, embedded as a `<skill …>` invocation. */
23
+ readonly skill: PackagedAgentSkill;
24
+ /** True when `manage_automations` is available: file-triggered automations are then in scope. */
25
+ readonly automations?: boolean;
24
26
  }
25
27
  /** The config file's current text, or `undefined` when it does not exist. */
26
28
  export declare function snapshotConfigFile(configPath: string): string | undefined;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * The `<skill name="…" location="…">…</skill>` invocation block AutoRAG embeds
3
+ * in a turn prompt: the shape pi uses for its file-backed skills, with a
4
+ * path-opaque `location`. AutoRAG loads skills that have no path the model
5
+ * should resolve against (datasource skills and its own packaged skills), so
6
+ * the location names the skill without exposing a real filesystem path.
7
+ */
8
+ export interface SkillInvocation {
9
+ /** Skill name, as listed in the prompt's skill listing. */
10
+ readonly name: string;
11
+ /** Opaque, path-free location: `datasource://<name>` or `autorag-skill://<name>`. */
12
+ readonly location: string;
13
+ /** Full skill instructions. */
14
+ readonly content: string;
15
+ }
16
+ /** Render one skill's full instructions in the shared invocation shape. */
17
+ export declare function formatSkillInvocation(skill: SkillInvocation): string;
@@ -0,0 +1,52 @@
1
+ import type { ExtensionFactory } from "@earendil-works/pi-coding-agent";
2
+ /** Custom session entry type under which a conversation persists what the user said. */
3
+ export declare const USER_REQUEST_ENTRY_TYPE = "autorag.user-request";
4
+ /**
5
+ * `request`: a new question or a follow-up. `steer`: a correction typed while a search runs, which
6
+ * adjusts the request it interrupts rather than starting a new one.
7
+ */
8
+ export type UserRequestKind = "request" | "steer";
9
+ export interface UserRequest {
10
+ readonly text: string;
11
+ readonly kind: UserRequestKind;
12
+ }
13
+ type SaveEntry = (request: UserRequest) => void;
14
+ /**
15
+ * What the user has said in this conversation, in order, exactly as typed: the first question, every
16
+ * follow-up, every steer. AutoRAG's own phase prompts (fast answer, verification, the extra/organize/config
17
+ * turn, steer continuation) never enter it, because it is fed where the user's words arrive, not from the transcript.
18
+ *
19
+ * It is not truncated here. Whoever consumes it fits it to its own limit.
20
+ */
21
+ export declare class UserRequestLog {
22
+ private items;
23
+ private save;
24
+ record(text: string, kind?: UserRequestKind): void;
25
+ entries(): readonly UserRequest[];
26
+ /** Forgets everything: a new conversation. */
27
+ reset(): void;
28
+ /** Replaces the log with a conversation read back from a session. */
29
+ restore(requests: readonly UserRequest[]): void;
30
+ /**
31
+ * Where each recorded message is saved. Returns a detach that only unplugs this saver: a session that
32
+ * shut down late must not unplug the one that replaced it. Detached, the log is in-memory only.
33
+ */
34
+ attach(save: SaveEntry): () => void;
35
+ }
36
+ /**
37
+ * pi extension that keeps the conversation's {@link UserRequestLog} in the session file, next to the
38
+ * transcript. Starting, resuming, forking, or navigating the session tree rebuilds the log from the branch
39
+ * now in view, so `/new` begins empty and `/resume` brings the earlier requests back.
40
+ */
41
+ export declare function createUserRequestPersistence(log: UserRequestLog): ExtensionFactory;
42
+ /** `text` cut to `max` characters by dropping its middle, so both what it starts with and ends with survive. */
43
+ export declare function cutMiddle(text: string, max: number): string;
44
+ /**
45
+ * The conversation as the Jev gate reads it: every user message in order, verbatim and numbered, with
46
+ * corrections marked. Nothing is shortened while it fits in `maxChars`. Over that, the opening request and
47
+ * the newest messages stay and the middle is dropped with a count (the numbering shows where), because the
48
+ * first message says what the user came for and the last ones say where they ended up. Only when even
49
+ * those two do not fit is a single message cut, in the middle.
50
+ */
51
+ export declare function renderUserRequests(requests: readonly UserRequest[], maxChars: number): string;
52
+ export {};
@@ -0,0 +1,48 @@
1
+ export type AutomationEventType = "create" | "update" | "delete";
2
+ export declare const AUTOMATION_EVENT_TYPES: readonly AutomationEventType[];
3
+ export interface AutomationEvent {
4
+ readonly type: AutomationEventType;
5
+ readonly path: string;
6
+ }
7
+ /** Which retrieval tools an agent rule's session is offered; retrieval memory is never connected. */
8
+ export interface AutomationAgentRetrieval {
9
+ readonly searchAll: boolean;
10
+ readonly datasources: readonly string[];
11
+ }
12
+ /** What an agent rule runs: a registered agent profile, spawned in-process on each batch of events. */
13
+ export interface AutomationAgent {
14
+ readonly profile: string;
15
+ readonly task: string;
16
+ readonly retrieval: AutomationAgentRetrieval;
17
+ }
18
+ /** A rule runs exactly one of `run` (a command) or `agent` (a profile session). */
19
+ export interface Automation {
20
+ readonly id: string;
21
+ readonly paths: readonly string[];
22
+ readonly events: readonly AutomationEventType[];
23
+ readonly include: readonly string[];
24
+ readonly exclude: readonly string[];
25
+ readonly run?: readonly string[];
26
+ readonly agent?: AutomationAgent;
27
+ readonly appendFiles: boolean;
28
+ readonly debounceMs: number;
29
+ readonly timeoutMs: number;
30
+ }
31
+ export declare const DEFAULT_DEBOUNCE_MS = 1000;
32
+ export declare const DEFAULT_TIMEOUT_MS = 600000;
33
+ export declare const DEFAULT_EXCLUDES: readonly string[];
34
+ export declare class AutomationConfigError extends Error {
35
+ constructor(message: string);
36
+ }
37
+ export declare function automationsConfigPath(env?: NodeJS.ProcessEnv): string;
38
+ export declare function parseAutomations(raw: unknown, env?: NodeJS.ProcessEnv): Automation[];
39
+ export declare function loadAutomations(configPath?: string, env?: NodeJS.ProcessEnv): Automation[];
40
+ /**
41
+ * Insert or replace the rule with `id`, keeping every other rule as written. The
42
+ * whole file is validated before it is written, so an invalid rule never lands
43
+ * on disk and the running daemon never reloads a broken file.
44
+ */
45
+ export declare function saveAutomation(configPath: string, id: string, rule: Readonly<Record<string, unknown>>, env?: NodeJS.ProcessEnv): Automation;
46
+ export declare function deleteAutomation(configPath: string, id: string): void;
47
+ export declare function matchesAutomationPath(automation: Automation, watchedRoot: string, filePath: string): boolean;
48
+ export declare function matchesAutomation(automation: Automation, watchedRoot: string, event: AutomationEvent): boolean;
@@ -0,0 +1,31 @@
1
+ import { type Automation, type AutomationEvent } from "./config.js";
2
+ import type { AutomationRunRecord } from "./run.js";
3
+ export declare const DEFAULT_MAX_RUNS_PER_MINUTE = 20;
4
+ /** An agent run costs model calls, so a rule that starts agents trips the self-trigger breaker sooner. */
5
+ export declare const DEFAULT_MAX_AGENT_RUNS_PER_MINUTE = 6;
6
+ export interface AutomationSubscription {
7
+ unsubscribe(): Promise<void>;
8
+ }
9
+ export type AutomationWatcherBackend = (dir: string, onEvents: (events: readonly AutomationEvent[]) => void, onError?: (error: Error) => void) => Promise<AutomationSubscription>;
10
+ export type AutomationRunner = (automation: Automation, events: readonly AutomationEvent[]) => Promise<AutomationRunRecord>;
11
+ export interface AutomationDaemonOptions {
12
+ readonly home?: string;
13
+ readonly env?: NodeJS.ProcessEnv;
14
+ readonly selfCommand?: readonly string[];
15
+ readonly watcher?: AutomationWatcherBackend;
16
+ readonly runner?: AutomationRunner;
17
+ readonly maxRunsPerMinute?: number;
18
+ readonly watchConfigFile?: boolean;
19
+ readonly onRun?: (automation: Automation, record: AutomationRunRecord) => void;
20
+ readonly onError?: (message: string) => void;
21
+ }
22
+ export interface AutomationDaemonHandle {
23
+ reload(): Promise<void>;
24
+ stop(): Promise<void>;
25
+ }
26
+ export declare class AutomationDaemonAlreadyRunningError extends Error {
27
+ constructor(home: string);
28
+ }
29
+ export declare function automationDaemonLockPath(home?: string): string;
30
+ export declare function isAutomationDaemonRunning(home?: string): boolean;
31
+ export declare function startAutomationDaemon(options?: AutomationDaemonOptions): Promise<AutomationDaemonHandle>;
@@ -0,0 +1,13 @@
1
+ import type { Automation, AutomationEvent } from "./config.js";
2
+ import { type AutomationRunRecord, type RunAutomationOptions } from "./run.js";
3
+ import { type RunAgentAutomationOptions } from "./run-agent.js";
4
+ /**
5
+ * Agent runs the process may have in flight at once, across every rule. A run
6
+ * holds a model session and, with retrieval tools, the configured indexes, so
7
+ * rules wait their turn instead of running in parallel. Events that arrive
8
+ * while a rule waits stay in its pending batch and are handled together.
9
+ */
10
+ export declare const AGENT_RUN_CONCURRENCY = 1;
11
+ export type RunRuleOptions = RunAutomationOptions & RunAgentAutomationOptions;
12
+ /** Run one rule: its command, or its agent profile. The single entry for the daemon, the CLI and the tool. */
13
+ export declare function runRule(automation: Automation, events: readonly AutomationEvent[], options?: RunRuleOptions): Promise<AutomationRunRecord>;
@@ -0,0 +1,22 @@
1
+ import { type AgentProfile, type ProfileModel } from "../profiles/agent-factory.js";
2
+ import type { Automation, AutomationEvent } from "./config.js";
3
+ import { type AutomationRunRecord } from "./run.js";
4
+ export interface RunAgentAutomationOptions {
5
+ readonly home?: string;
6
+ readonly env?: NodeJS.ProcessEnv;
7
+ /** pi's agent dir (the shared credential store); defaults to pi's own. */
8
+ readonly agentDir?: string;
9
+ /** Resolves the model the session runs on; defaults to the AutoRAG agent's configured model. */
10
+ readonly resolveModel?: (cwd: string) => Promise<ProfileModel>;
11
+ }
12
+ /** The profile an agent rule runs, with the loop guard appended. A profile cannot leave the guard out. */
13
+ export declare function buildAutomationProfile(automation: Automation): AgentProfile;
14
+ /** The user message of a run: one `type: path` line per changed file, capped like `appendFiles`. */
15
+ export declare function eventsPrompt(events: readonly AutomationEvent[]): string;
16
+ /**
17
+ * Run an agent rule: spawn its profile as an in-memory pi session, hand it the
18
+ * changed files, and wait for its final reply. The session never touches
19
+ * AutoRAG's retrieval memory; retrieval tools, when the rule asks for them, run
20
+ * against a throwaway memory file.
21
+ */
22
+ export declare function runAgentAutomation(automation: Automation, events: readonly AutomationEvent[], options?: RunAgentAutomationOptions): Promise<AutomationRunRecord>;
@@ -0,0 +1,32 @@
1
+ import type { Automation, AutomationEvent } from "./config.js";
2
+ export declare const AUTOMATION_MAX_APPEND_FILES = 100;
3
+ export interface AutomationRunRecord {
4
+ readonly id: string;
5
+ readonly startedAt: string;
6
+ readonly durationMs: number;
7
+ readonly eventCount: number;
8
+ readonly filesOverflow: boolean;
9
+ readonly exitCode: number | null;
10
+ readonly signal: NodeJS.Signals | null;
11
+ readonly timedOut: boolean;
12
+ readonly stdout: string;
13
+ readonly stderr: string;
14
+ readonly error?: string;
15
+ }
16
+ export interface RunAutomationOptions {
17
+ readonly home?: string;
18
+ readonly env?: NodeJS.ProcessEnv;
19
+ /** Override `[nodePath, cliEntry]` used when `run[0] === "autorag"`. */
20
+ readonly selfCommand?: readonly string[];
21
+ }
22
+ export declare function automationLogPath(home: string | undefined, id: string): string;
23
+ export declare function appendAutomationRunLog(home: string, record: AutomationRunRecord): void;
24
+ export declare function readLastAutomationRun(home: string, id: string): AutomationRunRecord | undefined;
25
+ /**
26
+ * `[runtime, cliEntry]` for this AutoRAG install, found by walking up from this
27
+ * module to the package root. `process.argv[1]` is not used: inside the MCP
28
+ * server or a library host it is not the AutoRAG CLI. Bundled installs run
29
+ * `dist/cli/index.js`; a source checkout without a build runs the TypeScript entry.
30
+ */
31
+ export declare function autoragCliCommand(): readonly string[];
32
+ export declare function runAutomation(automation: Automation, events: readonly AutomationEvent[], options?: RunAutomationOptions): Promise<AutomationRunRecord>;
@@ -0,0 +1,61 @@
1
+ import { type Automation } from "./config.js";
2
+ import { type AutomationRunRecord } from "./run.js";
3
+ export interface AutomationServiceSpec {
4
+ readonly id: string;
5
+ readonly nodePath: string;
6
+ readonly cliEntry: string;
7
+ readonly envFilePath: string;
8
+ readonly logPath: string;
9
+ readonly home: string;
10
+ readonly pathEnv: string;
11
+ readonly configPath?: string;
12
+ }
13
+ export interface AutomationServiceDescriptor {
14
+ readonly platform: NodeJS.Platform;
15
+ readonly id: string;
16
+ readonly definitionPath: string;
17
+ readonly envFilePath: string;
18
+ readonly logPath: string;
19
+ }
20
+ export interface ServiceExecResult {
21
+ readonly code: number;
22
+ readonly stdout: string;
23
+ readonly stderr: string;
24
+ }
25
+ export type ServiceCommandExec = (cmd: string, args: readonly string[]) => Promise<ServiceExecResult>;
26
+ export interface AutomationServiceOptions {
27
+ readonly platform?: NodeJS.Platform;
28
+ readonly home?: string;
29
+ readonly env?: NodeJS.ProcessEnv;
30
+ readonly selfCommand?: readonly string[];
31
+ readonly exec?: ServiceCommandExec;
32
+ /** How long install waits for the daemon to hold its lock. Default 15000. */
33
+ readonly waitForRunningMs?: number;
34
+ }
35
+ export interface AutomationServiceInstallResult extends AutomationServiceDescriptor {
36
+ /** Whether the daemon was observed running before install returned. */
37
+ readonly running: boolean;
38
+ }
39
+ export interface AutomationStatusEntry extends Automation {
40
+ readonly lastRun?: AutomationRunRecord;
41
+ }
42
+ export interface AutomationStatusReport {
43
+ readonly service: {
44
+ readonly platform: NodeJS.Platform;
45
+ readonly id: string;
46
+ readonly definitionPath: string;
47
+ readonly logPath: string;
48
+ readonly installed: boolean;
49
+ readonly running: boolean;
50
+ };
51
+ readonly configPath: string;
52
+ readonly configError?: string;
53
+ readonly automations: readonly AutomationStatusEntry[];
54
+ }
55
+ export declare function automationServiceDescriptor(options?: AutomationServiceOptions): AutomationServiceDescriptor;
56
+ export declare function renderLaunchdPlist(spec: AutomationServiceSpec): string;
57
+ export declare function renderSystemdUnit(spec: AutomationServiceSpec): string;
58
+ export declare function renderWindowsTaskXml(spec: AutomationServiceSpec): string;
59
+ export declare function installAutomationService(options?: AutomationServiceOptions): Promise<AutomationServiceInstallResult>;
60
+ export declare function uninstallAutomationService(options?: AutomationServiceOptions): Promise<AutomationServiceDescriptor>;
61
+ export declare function getAutomationStatus(options?: AutomationServiceOptions): AutomationStatusReport;
@@ -0,0 +1,2 @@
1
+ import type { CommandContext } from "./types.js";
2
+ export declare function runAutomate(ctx: CommandContext): Promise<number>;
@@ -9,6 +9,8 @@ interface EvidenceView {
9
9
  readonly retrievalResultId?: string;
10
10
  readonly chunkIndex?: number;
11
11
  readonly lineNumber?: number;
12
+ readonly lineEnd?: number;
13
+ readonly section?: string;
12
14
  readonly metadata?: Record<string, unknown>;
13
15
  }
14
16
  export declare function evidenceFor(schema: MemorySchema, sessionId: string, resultNumber?: number): {
@@ -3,6 +3,7 @@ import { ModelRuntime } from "@earendil-works/pi-coding-agent";
3
3
  import type { AutoRAGAgentOptions, AutoRAGRefreshLimits, AutoRAGRetrievalLimits } from "../agent/agent.js";
4
4
  import type { JevBackendName } from "../agent/jev-extension.js";
5
5
  import { type LoadLocalAutoRAGModelOptions } from "../agent/local-model.js";
6
+ import { type PermissionMode } from "../agent/permission-gate.js";
6
7
  import type { DecompositionModel } from "../agent/query-decomposition.js";
7
8
  import { type DatasourcesConfig } from "../datasource/skills/factory.js";
8
9
  import type { EnsureMinSyncBinaryOptions, MinSyncEmbedderConfig } from "../minsync/index.js";
@@ -169,6 +170,11 @@ export interface CliConfig {
169
170
  * agent's own model decompose.
170
171
  */
171
172
  queryDecomposition?: QueryDecompositionConfig | false;
173
+ /**
174
+ * Approval gate for file changes by the agent: `auto` (default for the TUI: Jev first, user as fallback; `full` for `search` and a bridged TUI), `ask`
175
+ * (the user approves every file-capable call, Jev unused), or `full` (no gate). `--permission-mode` and `AUTORAG_PERMISSION_MODE` override the file.
176
+ */
177
+ permissionMode?: PermissionMode;
172
178
  /** Post-merge reranking. Absent ⇒ reranking disabled. `false` disables it. */
173
179
  rerank?: RerankConfig | false;
174
180
  parserOptions?: Record<string, unknown>;
@@ -178,6 +184,16 @@ export interface CliConfig {
178
184
  timeoutMs?: number;
179
185
  };
180
186
  excludeExactDuplicates?: boolean;
187
+ /** Filee command line behind the `convert_files` tool. `enabled: false` removes the conversion tools. */
188
+ filee?: {
189
+ enabled?: boolean;
190
+ binaryPath?: string;
191
+ /** Download the pinned filee-cli into `<AUTORAG_HOME>/tools` when none is found. Default true. */
192
+ autoInstall?: boolean;
193
+ timeoutMs?: number;
194
+ /** Folder for Filee's own settings and engines (`FILEE_DATA_DIR`); default is Filee's per-user folder. */
195
+ dataDir?: string;
196
+ };
181
197
  /** Absolute or workspace-relative files/directories omitted from local indexing. */
182
198
  excludePaths?: string[];
183
199
  /** Hard caps on retrieval, baseline prefetch, and model-facing candidate lists. */
@@ -192,6 +208,11 @@ export interface ResolveConfigInput {
192
208
  env?: NodeJS.ProcessEnv;
193
209
  cwd?: string;
194
210
  readOnly?: boolean;
211
+ /**
212
+ * Mode when no flag, environment variable, or config file sets one. Commands that run with nobody to approve
213
+ * (`search`) or through a remote bridge pass `full`; the interactive TUI leaves it to the default (`auto`).
214
+ */
215
+ defaultPermissionMode?: PermissionMode;
195
216
  }
196
217
  export interface ResolvedConfigPath {
197
218
  configPath: string;
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- declare const COMMANDS: readonly ["init", "setup", "refresh", "status", "search", "evidence", "memory", "index", "watch", "health", "duplicates", "tui", "lite", "models", "update-check"];
2
+ declare const COMMANDS: readonly ["init", "setup", "refresh", "status", "search", "evidence", "memory", "index", "watch", "health", "duplicates", "tui", "lite", "models", "update-check", "automate"];
3
3
  type CommandName = (typeof COMMANDS)[number];
4
4
  export type { CommandName };
5
5
  interface ParsedArgs {