@autorag/librarian 2.10.6 → 2.12.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 (86) hide show
  1. package/NOTICE +14 -0
  2. package/README.md +52 -10
  3. package/dist/agent/agent.d.ts +70 -2
  4. package/dist/agent/answer-citations.d.ts +34 -2
  5. package/dist/agent/answer-guidelines.d.ts +24 -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/evidence-persistence.d.ts +17 -11
  14. package/dist/agent/index.d.ts +1 -0
  15. package/dist/agent/intent-tracing.d.ts +33 -0
  16. package/dist/agent/mcp-client.d.ts +27 -0
  17. package/dist/agent/permission-gate.d.ts +78 -0
  18. package/dist/agent/permission-judgment.d.ts +72 -0
  19. package/dist/agent/permission-paths.d.ts +23 -0
  20. package/dist/agent/pi-session.d.ts +8 -0
  21. package/dist/agent/query-routing.d.ts +14 -17
  22. package/dist/agent/search-documents.d.ts +1 -1
  23. package/dist/agent/search-progress.d.ts +96 -0
  24. package/dist/agent/self-config.d.ts +2 -0
  25. package/dist/agent/user-requests.d.ts +52 -0
  26. package/dist/agent/welcome-header.d.ts +35 -0
  27. package/dist/automation/config.d.ts +48 -0
  28. package/dist/automation/daemon.d.ts +31 -0
  29. package/dist/automation/dispatch.d.ts +13 -0
  30. package/dist/automation/run-agent.d.ts +22 -0
  31. package/dist/automation/run.d.ts +32 -0
  32. package/dist/automation/service.d.ts +61 -0
  33. package/dist/cli/commands/automate.d.ts +2 -0
  34. package/dist/cli/commands/setup.d.ts +2 -0
  35. package/dist/cli/config.d.ts +21 -0
  36. package/dist/cli/index.d.ts +1 -1
  37. package/dist/cli/index.js +26740 -21094
  38. package/dist/cli/open-target.d.ts +9 -0
  39. package/dist/cli/setup.d.ts +21 -0
  40. package/dist/convert/cli.d.ts +77 -0
  41. package/dist/convert/index.d.ts +4 -0
  42. package/dist/convert/installer.d.ts +84 -0
  43. package/dist/convert/matrix.d.ts +27 -0
  44. package/dist/convert/relate.d.ts +30 -0
  45. package/dist/core.js +32095 -27288
  46. package/dist/datasource/connector-timeouts.d.ts +6 -2
  47. package/dist/datasource/crawler-types.d.ts +1 -1
  48. package/dist/datasource/errors.d.ts +1 -1
  49. package/dist/datasource/index.d.ts +2 -1
  50. package/dist/datasource/skills/factory.d.ts +3 -0
  51. package/dist/datasource/skills/hister/client.d.ts +83 -0
  52. package/dist/datasource/skills/hister/embedding.d.ts +64 -0
  53. package/dist/datasource/skills/hister/index.d.ts +2 -0
  54. package/dist/datasource/skills/hister/setup.d.ts +87 -0
  55. package/dist/datasource/skills/hister/skill.d.ts +63 -0
  56. package/dist/datasource/skills/lazykatok/types.d.ts +2 -2
  57. package/dist/datasource/skills/mailcrawl/types.d.ts +1 -1
  58. package/dist/datasource/skills/obsidian/index.d.ts +4 -6
  59. package/dist/datasource/skills/obsidian/methods.d.ts +13 -17
  60. package/dist/datasource/skills/obsidian/paths.d.ts +24 -24
  61. package/dist/datasource/skills/obsidian/skill.d.ts +10 -15
  62. package/dist/datasource/skills/obsidian/staging.d.ts +50 -0
  63. package/dist/datasource/skills/obsidian/vault-index.d.ts +44 -0
  64. package/dist/dupey/cli.d.ts +18 -0
  65. package/dist/index.d.ts +1 -0
  66. package/dist/index.js +32263 -27429
  67. package/dist/mcp/index.js +32149 -27342
  68. package/dist/minsync/installer.d.ts +1 -1
  69. package/dist/minsync/workspace-lock.d.ts +7 -0
  70. package/dist/process/terminate-tree.d.ts +4 -5
  71. package/dist/profiles/agent-factory.d.ts +60 -0
  72. package/dist/profiles/automation-profiles.d.ts +25 -0
  73. package/dist/profiles/loop-guard.d.ts +23 -0
  74. package/dist/profiles/retrieval-tools.d.ts +24 -0
  75. package/dist/profiles/session-model.d.ts +69 -0
  76. package/dist/profiles.d.ts +13 -0
  77. package/dist/profiles.js +34739 -0
  78. package/dist/retrieval/rerank.d.ts +6 -0
  79. package/licenses/hister-AGPL-3.0-notice.txt +47 -0
  80. package/package.json +9 -3
  81. package/skills/autorag/SKILL.md +79 -5
  82. package/skills/autorag-doctor/SKILL.md +5 -4
  83. package/skills/autorag-lite-setup/SKILL.md +23 -5
  84. package/skills/autorag-setup/SKILL.md +68 -7
  85. package/dist/datasource/skills/obsidian/client.d.ts +0 -15
  86. package/dist/datasource/skills/obsidian/types.d.ts +0 -92
@@ -1,4 +1,4 @@
1
- export declare const MINSYNC_VERSION = "0.4.11";
1
+ export declare const MINSYNC_VERSION = "0.4.12";
2
2
  export declare const MINSYNC_CARGO_INSTALL_TIMEOUT_MS: number;
3
3
  export interface MinSyncReleaseAsset {
4
4
  readonly name: string;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Run a sync (anything that rewrites the workspace). The in-flight count is raised
3
+ * before this returns, so a query issued right after the call already sees the sync.
4
+ */
5
+ export declare function runWorkspaceSync<T>(workspacePath: string, run: () => Promise<T>): Promise<T>;
6
+ /** Run a query. It is refused while a sync is pending, because the index is mid-rewrite. */
7
+ export declare function runWorkspaceQuery<T>(workspacePath: string, run: () => Promise<T>): Promise<T>;
@@ -4,11 +4,10 @@ export declare const TREE_KILL_GRACE_MS = 500;
4
4
  /**
5
5
  * Terminate a spawned external CLI together with the descendants it created.
6
6
  *
7
- * CLIs such as qmd 2.8.3 are launchers: the process AutoRAG spawns starts a
8
- * runtime descendant that inherits the launcher's stdout/stderr pipes. Node
9
- * emits `close` only once every holder of those pipes has exited, so signalling
10
- * just the direct child leaves the caller waiting on a descendant that may live
11
- * for minutes — the hang reported in #1578.
7
+ * CLIs that are launchers (an npm shim, a wrapper script) start a runtime descendant that inherits
8
+ * the launcher's stdout/stderr pipes. Node emits `close` only once every holder of those pipes has
9
+ * exited, so signalling just the direct child leaves the caller waiting on a descendant that may
10
+ * live for minutes — the hang reported in #1578.
12
11
  *
13
12
  * Spawn the child with `detached: true` on POSIX so it leads its own process
14
13
  * group; the group survives the direct child and stays addressable as `-pid`.
@@ -0,0 +1,60 @@
1
+ import type { Api, Model } from "@earendil-works/pi-ai";
2
+ import { type AgentSession, type CreateAgentSessionOptions, type ToolDefinition } from "@earendil-works/pi-coding-agent";
3
+ /**
4
+ * Plain pi agent sessions for helper features, one per {@link AgentProfile}.
5
+ *
6
+ * The AutoRAG agent (`AutoRAGAgent`) answers searches and is not touched here.
7
+ * Every other helper agent (smart indexing in the desktop app, file-triggered
8
+ * automations, and whatever follows) is a vanilla pi session: its own system
9
+ * prompt, its own tool set, and its own choice of what pi would otherwise load
10
+ * on its own (AGENTS.md, skills, extensions). What the profiles share is the
11
+ * account: the model the AutoRAG agent runs on, and the credential store under
12
+ * the same agent dir (`auth.json`, `models.json`), so a sign-in or key change
13
+ * reaches them without a second login.
14
+ *
15
+ * A session lives in memory and is gone with `dispose()`: nothing is written
16
+ * under the agent dir or the working directory, and the user's own pi settings
17
+ * (default tools, themes, ...) never apply. A profile session never reads or
18
+ * writes AutoRAG's retrieval memory.
19
+ */
20
+ /** How hard the model thinks; the same levels pi's session takes. */
21
+ export type ProfileThinking = NonNullable<CreateAgentSessionOptions["thinkingLevel"]>;
22
+ /** What pi loads on its own besides the profile's prompt and tools. Everything is off unless a profile turns it on. */
23
+ export interface ProfileContext {
24
+ /** AGENTS.md style instruction files from the agent dir and the working directory. */
25
+ readonly projectFiles?: boolean;
26
+ readonly skills?: boolean;
27
+ /** Extensions from the agent dir and the working directory. An extension's tools still have to be named in {@link AgentProfile.tools}. */
28
+ readonly extensions?: boolean;
29
+ }
30
+ export interface AgentProfile {
31
+ readonly id: string;
32
+ readonly systemPrompt: string;
33
+ /**
34
+ * Names of the pi tools the model may call (`read`, `ls`, `find`, `grep`, and
35
+ * `bash`/`edit`/`write` for a profile that may change things; an extension's
36
+ * tool when {@link ProfileContext.extensions} is on). Tools in
37
+ * {@link customTools} are always allowed and need no entry here.
38
+ */
39
+ readonly tools: readonly string[];
40
+ readonly customTools?: readonly ToolDefinition[];
41
+ readonly thinking: ProfileThinking;
42
+ readonly context?: ProfileContext;
43
+ }
44
+ /** The model a session runs on and the credentials resolved for it; see `resolveSessionModel`. */
45
+ export interface ProfileModel {
46
+ readonly model: Model<Api>;
47
+ readonly apiKey?: string;
48
+ readonly providerApiKeys?: Readonly<Record<string, string>>;
49
+ }
50
+ export interface ProfileSessionOptions {
51
+ readonly profile: AgentProfile;
52
+ /** Working directory of the session: relative paths and project context resolve against it. */
53
+ readonly cwd: string;
54
+ /** pi's agent dir; `auth.json` and `models.json` in it are the shared credential store. */
55
+ readonly agentDir: string;
56
+ readonly env: NodeJS.ProcessEnv;
57
+ readonly model: ProfileModel;
58
+ }
59
+ /** Builds a ready session for `profile`; the caller prompts it and disposes it. */
60
+ export declare function createProfileSession(options: ProfileSessionOptions): Promise<AgentSession>;
@@ -0,0 +1,25 @@
1
+ import type { AgentProfile } from "./agent-factory.js";
2
+ /**
3
+ * Agent profiles an automation rule can name (`"agent": { "profile": "<id>" }`).
4
+ *
5
+ * A rule only carries the id, never a prompt or a tool list: what an agent may
6
+ * do is decided here, in code, so a rules file (which the librarian agent can
7
+ * itself edit) cannot grant `bash` or `write` to an agent that was meant to read.
8
+ * The runner appends the mandatory loop guard (`loop-guard.ts`) to every
9
+ * profile's prompt, writing profiles included.
10
+ */
11
+ /** What a profile builder is told about the run it serves. */
12
+ export interface AutomationProfileInput {
13
+ /** The rule's own instruction for this run; a profile folds it into its prompt. */
14
+ readonly task: string;
15
+ }
16
+ export interface AutomationProfileDefinition {
17
+ readonly id: string;
18
+ readonly description: string;
19
+ /** True when the profile may change files (offers `bash`, `edit` or `write`). */
20
+ readonly writes: boolean;
21
+ build(input: AutomationProfileInput): AgentProfile;
22
+ }
23
+ export declare function registerAutomationProfile(definition: AutomationProfileDefinition): void;
24
+ export declare function getAutomationProfile(id: string): AutomationProfileDefinition | undefined;
25
+ export declare function listAutomationProfiles(): readonly AutomationProfileDefinition[];
@@ -0,0 +1,23 @@
1
+ /** The part of an automation rule the loop guard describes to the agent. */
2
+ export interface LoopGuardRule {
3
+ readonly id: string;
4
+ readonly paths: readonly string[];
5
+ readonly events: readonly string[];
6
+ readonly include: readonly string[];
7
+ readonly exclude: readonly string[];
8
+ }
9
+ /**
10
+ * File extensions a rule's include globs name (`**\/*.pdf`, `*.{md,txt}`), lower-case with the dot.
11
+ * Empty when some glob names no extension (`**`, `docs/**`): the rule then fires on every file type.
12
+ */
13
+ export declare function includedExtensions(include: readonly string[]): readonly string[];
14
+ /**
15
+ * The system-prompt section every agent run started by an automation carries.
16
+ *
17
+ * The automation runner appends it to the profile's own prompt; a profile cannot
18
+ * leave it out. An agent that may write files could otherwise change a file the
19
+ * rule watches, which fires the rule again and starts another run of the agent:
20
+ * an endless loop. The section names the rule's folders, file types, and events,
21
+ * and forbids every change that would fire the rule.
22
+ */
23
+ export declare function loopGuardPrompt(rule: LoopGuardRule): string;
@@ -0,0 +1,24 @@
1
+ import type { ToolDefinition } from "@earendil-works/pi-coding-agent";
2
+ import { type CliConfig } from "../cli/config.js";
3
+ /** Which of AutoRAG's retrieval tools a profile session is offered, on top of its own tools. */
4
+ export interface RetrievalToolOptions {
5
+ /** `search_all_documents`: fan-out across every configured retrieval method. */
6
+ readonly searchAll?: boolean;
7
+ /** Datasource ids to offer one `search_datasource_<id>` tool for each. */
8
+ readonly datasources?: readonly string[];
9
+ }
10
+ export interface RetrievalToolkit {
11
+ readonly tools: readonly ToolDefinition[];
12
+ dispose(): Promise<void>;
13
+ }
14
+ export declare function hasRetrievalTools(options: RetrievalToolOptions | undefined): boolean;
15
+ /**
16
+ * Retrieval tools for a profile session, backed by the configured indexes.
17
+ *
18
+ * Retrieval memory is never connected: the backing agent is pointed at a
19
+ * throwaway memory file with the memory embedder off, so nothing the profile
20
+ * searches is read from or recorded into the user's real `memory.json`. Only
21
+ * the search tools are handed out; the backing agent's other surfaces (web,
22
+ * Everything, FSearch, Jev, duplicate scan) stay off.
23
+ */
24
+ export declare function createRetrievalToolkit(config: CliConfig, options: RetrievalToolOptions): Promise<RetrievalToolkit>;
@@ -0,0 +1,69 @@
1
+ import { ModelRuntime } from "@earendil-works/pi-coding-agent";
2
+ import { type CliConfig } from "../cli/config.js";
3
+ import type { ProfileModel } from "./agent-factory.js";
4
+ /**
5
+ * Why the hosted plan's key must not ride along as a session API key.
6
+ *
7
+ * The `dazzi` provider is OAuth-only: its credential is the `/login` entry in
8
+ * Pi's `auth.json`. Handing the resolved key to `ModelRuntime.setRuntimeApiKey`
9
+ * replaces that OAuth credential with an `api_key` one, and an OAuth-only
10
+ * provider accepts no API key, so the session stops with "No API key found for
11
+ * dazzi" even though the user is signed in. That only happens when the
12
+ * session's runtime already lists the model (the persisted catalog snapshot the
13
+ * sign-in writes); a model the runtime does not list is registered from the key
14
+ * instead and works.
15
+ *
16
+ * So for a plan model the runtime lists, the key is dropped and Pi resolves the
17
+ * stored OAuth credential itself. A model it does not list keeps the key.
18
+ */
19
+ /** The slice of Pi's `ModelRuntime` this module reads. */
20
+ export interface PlanRuntime {
21
+ getModel(provider: string, id: string): unknown;
22
+ refresh(options: {
23
+ readonly allowNetwork: boolean;
24
+ readonly providers: readonly string[];
25
+ readonly force: boolean;
26
+ }): Promise<unknown>;
27
+ }
28
+ /** A resolved agent model with the credentials a session receives. */
29
+ export interface SessionModelAuth {
30
+ readonly model: {
31
+ readonly provider: string;
32
+ readonly id: string;
33
+ };
34
+ readonly apiKey?: string;
35
+ readonly providerApiKeys?: Readonly<Record<string, string>>;
36
+ }
37
+ /** Open Pi's runtime on `agentDir` with the plan provider registered, offline until asked. */
38
+ export declare function openPlanRuntime(agentDir: string, env: NodeJS.ProcessEnv): Promise<ModelRuntime>;
39
+ /**
40
+ * Drop the plan's API key from a resolved model when Pi can authenticate it
41
+ * from the stored OAuth credential. Any other model, or a plan model Pi cannot
42
+ * list (offline, unknown id), is returned unchanged.
43
+ */
44
+ export declare function preferPlanOAuth<T extends SessionModelAuth>(resolved: T, openRuntime: () => Promise<PlanRuntime>): Promise<T>;
45
+ /**
46
+ * The Dazzi `/v1/models` catalog omits `thinkingLevelMap` for its OpenRouter-backed
47
+ * model ids (e.g. `z-ai/glm-5.3-flash`, `anthropic/claude-haiku-5.5`). Without it,
48
+ * Pi's `clampThinkingLevel(model, "off")` keeps `"off"` and `openai-responses`
49
+ * sends `reasoning: { effort: "none" }`, which mandatory-reasoning endpoints
50
+ * reject with HTTP 400 (`Reasoning is mandatory for this endpoint and cannot be
51
+ * disabled`). Inherit the upstream OpenRouter `thinkingLevelMap` when present so
52
+ * `"off"` clamps to `"low"` for those models.
53
+ */
54
+ export declare function applyDazziThinkingLevels<T extends {
55
+ readonly provider: string;
56
+ readonly id: string;
57
+ readonly thinkingLevelMap?: unknown;
58
+ }>(model: T): T;
59
+ /**
60
+ * The model every profile agent runs on: the one the shared AutoRAG config names
61
+ * for the AutoRAG agent, with its credentials. AI Search and the profile agents
62
+ * both resolve it, so there is one answer to "which model, which key".
63
+ *
64
+ * Credentials are read fresh on every call, so a login or key change reaches the
65
+ * next session without a restart.
66
+ */
67
+ export declare function resolveSessionModel(config: CliConfig, env: NodeJS.ProcessEnv, cwd: string, agentDir: string): Promise<ProfileModel>;
68
+ /** {@link resolveSessionModel} for the config file the app and the CLI share. */
69
+ export declare function resolveConfiguredSessionModel(env: NodeJS.ProcessEnv, cwd: string, agentDir: string): Promise<ProfileModel>;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * `@autorag/librarian/profiles`: agent profiles for helper features.
3
+ *
4
+ * A profile is a system prompt, a tool set, and a thinking level; the factory turns
5
+ * one into a plain in-memory pi session on the AutoRAG agent's own model and
6
+ * credentials. The desktop app's smart indexing and file-triggered automations
7
+ * are built on it. No profile session touches AutoRAG's retrieval memory.
8
+ */
9
+ export { type AgentProfile, createProfileSession, type ProfileContext, type ProfileModel, type ProfileSessionOptions, type ProfileThinking, } from "./profiles/agent-factory.js";
10
+ export { type AutomationProfileDefinition, type AutomationProfileInput, getAutomationProfile, listAutomationProfiles, registerAutomationProfile, } from "./profiles/automation-profiles.js";
11
+ export { includedExtensions, type LoopGuardRule, loopGuardPrompt } from "./profiles/loop-guard.js";
12
+ export { createRetrievalToolkit, hasRetrievalTools, type RetrievalToolkit, type RetrievalToolOptions, } from "./profiles/retrieval-tools.js";
13
+ export { applyDazziThinkingLevels, openPlanRuntime, type PlanRuntime, preferPlanOAuth, resolveConfiguredSessionModel, resolveSessionModel, type SessionModelAuth, } from "./profiles/session-model.js";