@autorag/librarian 2.0.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 (110) hide show
  1. package/LICENSE +27 -0
  2. package/README.md +275 -0
  3. package/dist/agent/agent.d.ts +294 -0
  4. package/dist/agent/bash-tool.d.ts +41 -0
  5. package/dist/agent/datasource-skill.d.ts +45 -0
  6. package/dist/agent/emit-results-tool.d.ts +75 -0
  7. package/dist/agent/index.d.ts +11 -0
  8. package/dist/agent/jikji-find-tool.d.ts +73 -0
  9. package/dist/agent/search-all-tool.d.ts +36 -0
  10. package/dist/agent/search-bm25-tool.d.ts +18 -0
  11. package/dist/agent/search-datasource-tool.d.ts +26 -0
  12. package/dist/agent/search-documents.d.ts +56 -0
  13. package/dist/agent/search-minsync-tool.d.ts +24 -0
  14. package/dist/agent/system-prompt.d.ts +13 -0
  15. package/dist/agent/watch-refresh.d.ts +29 -0
  16. package/dist/cli/commands/feedback.d.ts +8 -0
  17. package/dist/cli/commands/health.d.ts +146 -0
  18. package/dist/cli/commands/index.d.ts +9 -0
  19. package/dist/cli/commands/init.d.ts +9 -0
  20. package/dist/cli/commands/memory.d.ts +8 -0
  21. package/dist/cli/commands/refresh.d.ts +19 -0
  22. package/dist/cli/commands/search.d.ts +34 -0
  23. package/dist/cli/commands/status.d.ts +7 -0
  24. package/dist/cli/commands/types.d.ts +10 -0
  25. package/dist/cli/commands/watch.d.ts +8 -0
  26. package/dist/cli/config.d.ts +172 -0
  27. package/dist/cli/index.d.ts +10 -0
  28. package/dist/cli/index.js +10845 -0
  29. package/dist/cli/output.d.ts +32 -0
  30. package/dist/config/home.d.ts +2 -0
  31. package/dist/datasource/access-context.d.ts +49 -0
  32. package/dist/datasource/diagnostics.d.ts +20 -0
  33. package/dist/datasource/index.d.ts +9 -0
  34. package/dist/datasource/polling.d.ts +51 -0
  35. package/dist/datasource/registry.d.ts +52 -0
  36. package/dist/datasource/result-filter.d.ts +63 -0
  37. package/dist/datasource/scope.d.ts +38 -0
  38. package/dist/datasource/skills/katok/client.d.ts +24 -0
  39. package/dist/datasource/skills/katok/index.d.ts +12 -0
  40. package/dist/datasource/skills/katok/methods.d.ts +40 -0
  41. package/dist/datasource/skills/katok/paths.d.ts +40 -0
  42. package/dist/datasource/skills/katok/skill.d.ts +33 -0
  43. package/dist/datasource/skills/katok/types.d.ts +146 -0
  44. package/dist/datasource/types.d.ts +183 -0
  45. package/dist/filesystem/file-lock.d.ts +16 -0
  46. package/dist/filesystem/source-paths.d.ts +38 -0
  47. package/dist/index.d.ts +11 -0
  48. package/dist/index.js +9361 -0
  49. package/dist/jikji/answer-pack.d.ts +31 -0
  50. package/dist/jikji/client.d.ts +18 -0
  51. package/dist/jikji/diagnostics.d.ts +26 -0
  52. package/dist/jikji/index.d.ts +10 -0
  53. package/dist/jikji/installer.d.ts +46 -0
  54. package/dist/jikji/path-map.d.ts +8 -0
  55. package/dist/jikji/types.d.ts +112 -0
  56. package/dist/manifest/index.d.ts +2 -0
  57. package/dist/manifest/loader.d.ts +3 -0
  58. package/dist/manifest/types.d.ts +8 -0
  59. package/dist/memory/check-memory-tool.d.ts +13 -0
  60. package/dist/memory/index.d.ts +5 -0
  61. package/dist/memory/memory.d.ts +179 -0
  62. package/dist/memory/renderer.d.ts +6 -0
  63. package/dist/minsync/client.d.ts +14 -0
  64. package/dist/minsync/embedder-config.d.ts +22 -0
  65. package/dist/minsync/index.d.ts +7 -0
  66. package/dist/minsync/installer.d.ts +27 -0
  67. package/dist/minsync/method.d.ts +37 -0
  68. package/dist/minsync/paths.d.ts +4 -0
  69. package/dist/minsync/process.d.ts +10 -0
  70. package/dist/minsync/types.d.ts +33 -0
  71. package/dist/minsync/workspace.d.ts +14 -0
  72. package/dist/mirror/index-store.d.ts +16 -0
  73. package/dist/mirror/index.d.ts +5 -0
  74. package/dist/mirror/paths.d.ts +6 -0
  75. package/dist/mirror/sync.d.ts +38 -0
  76. package/dist/observability/run-log.d.ts +53 -0
  77. package/dist/parser/defaults.d.ts +6 -0
  78. package/dist/parser/eml.d.ts +6 -0
  79. package/dist/parser/errors.d.ts +5 -0
  80. package/dist/parser/hwp.d.ts +6 -0
  81. package/dist/parser/index.d.ts +10 -0
  82. package/dist/parser/ocr.d.ts +25 -0
  83. package/dist/parser/office.d.ts +16 -0
  84. package/dist/parser/opendataloader-pdf.d.ts +21 -0
  85. package/dist/parser/plain-text.d.ts +6 -0
  86. package/dist/parser/registry.d.ts +8 -0
  87. package/dist/parser/text.d.ts +2 -0
  88. package/dist/parser/types.d.ts +14 -0
  89. package/dist/parser/xml-text.d.ts +2 -0
  90. package/dist/retrieval/evidence-id.d.ts +16 -0
  91. package/dist/retrieval/index.d.ts +7 -0
  92. package/dist/retrieval/merger.d.ts +18 -0
  93. package/dist/retrieval/methods/bm25.d.ts +52 -0
  94. package/dist/retrieval/registry.d.ts +8 -0
  95. package/dist/retrieval/scope.d.ts +4 -0
  96. package/dist/retrieval/types.d.ts +64 -0
  97. package/dist/subagents/contracts.d.ts +90 -0
  98. package/dist/subagents/dispatch-templates.d.ts +104 -0
  99. package/dist/subagents/dispatch-validation.d.ts +169 -0
  100. package/dist/subagents/explorer-tools-extension.d.ts +4 -0
  101. package/dist/subagents/explorer-tools-extension.js +130 -0
  102. package/dist/subagents/local-models.d.ts +14 -0
  103. package/dist/subagents/model-policy.d.ts +31 -0
  104. package/dist/subagents/runtime.d.ts +52 -0
  105. package/dist/tool/index.d.ts +1 -0
  106. package/dist/types/errors.d.ts +4 -0
  107. package/dist/types/index.d.ts +1 -0
  108. package/package.json +66 -0
  109. package/skills/autorag/SKILL.md +149 -0
  110. package/skills/autorag-setup/SKILL.md +396 -0
@@ -0,0 +1,183 @@
1
+ /**
2
+ * Datasource core contract.
3
+ *
4
+ * A *datasource* is an external, server-bound source of retrieval evidence
5
+ * (e.g. a KakaoTalk export reached through the external `katok` CLI). The
6
+ * datasource layer sits *on top of* the existing retrieval pipeline: it owns
7
+ * access gating and slash-hierarchical source naming, while actual retrieval
8
+ * still flows through {@link RetrievalMethod} instances returned by a skill.
9
+ *
10
+ * Security invariants (enforced by {@link DatasourceAccessContext}):
11
+ * - Access is **default-deny**: when no trusted allow-tags are configured,
12
+ * every datasource descriptor and source is denied.
13
+ * - Deny is always an explicit `false` boolean / predicate return — never
14
+ * `undefined`-as-deny.
15
+ * - Model/tool arguments never grant access. Only the trusted server-supplied
16
+ * {@link DatasourceAccessContext} can authorize a datasource.
17
+ * - Datasource sources are slash-hierarchical opaque paths such as
18
+ * `/kakao/<instance-id>/chunks/<chunk-id>`; `#` fragments are rejected.
19
+ */
20
+ import type { RetrievalMethod } from "../retrieval/types.js";
21
+ export type { RetrievalMethod } from "../retrieval/types.js";
22
+ /**
23
+ * Descriptor for a datasource skill (e.g. KakaoTalk via `katok`).
24
+ *
25
+ * Structurally compatible with {@link RetrievalMethodDescriptor} so that
26
+ * retrieval method descriptors can be gated by the same access context.
27
+ */
28
+ export interface DatasourceSkillDescriptor {
29
+ /** Stable skill name, e.g. `"kakao"`. */
30
+ readonly name: string;
31
+ /** Compatibility alias for public API examples; equal to `name` when present. */
32
+ readonly id?: string;
33
+ /** Skill kind, e.g. `"kakao"` or `"chat-export"`. */
34
+ readonly type: string;
35
+ readonly description: string;
36
+ /** Capability tags such as `"chat"`, `"external-cli"`, `"polling"`. */
37
+ readonly capabilities: readonly string[];
38
+ /**
39
+ * Authorization tags. A descriptor is accessible only when at least one tag
40
+ * intersects the trusted allow-tags on the access context.
41
+ */
42
+ readonly tags: readonly string[];
43
+ readonly status: "active" | "stub";
44
+ /** True when the skill shells out to an external CLI (e.g. `katok`). */
45
+ readonly requiresExternalCli?: boolean;
46
+ /**
47
+ * Set when this descriptor describes a datasource-backed surface.
48
+ * Non-datasource descriptors (e.g. plain `posix` retrieval methods) leave
49
+ * this undefined and are passed through by the access context.
50
+ */
51
+ readonly datasourceId?: string;
52
+ /** Optional primary instance id for single-instance skills. */
53
+ readonly instanceId?: string;
54
+ /** Optional list of instance ids this skill reports. */
55
+ readonly instances?: readonly string[];
56
+ }
57
+ /**
58
+ * Minimal structural shape required to gate a descriptor by access context.
59
+ * Both {@link DatasourceSkillDescriptor} and `RetrievalMethodDescriptor`
60
+ * satisfy this interface structurally.
61
+ */
62
+ export interface DatasourceAccessible {
63
+ readonly datasourceId?: string;
64
+ readonly tags?: readonly string[];
65
+ }
66
+ /**
67
+ * A pluggable datasource skill. Skills are server-bound: they are constructed
68
+ * with trusted configuration and never derive authority from model/tool args.
69
+ * Methods never throw — failures surface as {@link DatasourceDiagnostic}
70
+ * entries on a {@link DatasourceIndexResult} fail variant.
71
+ */
72
+ export interface DatasourceSkill {
73
+ describe(): DatasourceSkillDescriptor;
74
+ /** Current polling/indexing metadata for this skill. */
75
+ polling(): PollingMetadata;
76
+ /**
77
+ * Index (or re-index) the skill's instances. Returns an ok/fail union;
78
+ * never throws. Remote embedding egress MUST be rejected here and reported
79
+ * via a `datasource-embedding-egress-rejected` diagnostic.
80
+ */
81
+ index(): Promise<DatasourceIndexResult>;
82
+ /** Retrieval methods exposed by this skill, fed into the shared pipeline. */
83
+ retrievalMethods(): readonly RetrievalMethod[];
84
+ /** Opaque source descriptions for the skill's current evidence set. */
85
+ describeSources(): readonly SourceDescription[];
86
+ /**
87
+ * Progressive-disclosure agent-skill manifest (Pi agent-skill layer). The
88
+ * `name`/`description` appear in the system prompt; `content` is loaded on
89
+ * demand via the `load_datasource_skill` tool.
90
+ */
91
+ skillManifest(): DatasourceSkillManifest;
92
+ }
93
+ /**
94
+ * Progressive-disclosure agent-skill manifest for a datasource skill.
95
+ *
96
+ * Mirrors the Pi agent-skill layer (`Skill` from `@earendil-works/pi-agent-core`):
97
+ * `name` + `description` are injected into the system prompt for progressive
98
+ * disclosure, and `content` is the full skill instruction body loaded on demand
99
+ * via the model's `load_datasource_skill` tool call. `content` MUST stay
100
+ * path/PII opaque — reference only slash-hierarchical opaque scopes.
101
+ */
102
+ export interface DatasourceSkillManifest {
103
+ /** Stable, model-visible skill name used for lookup and the skills listing. */
104
+ readonly name: string;
105
+ /** Short "when to use" description for the system-prompt skills block. */
106
+ readonly description: string;
107
+ /** Full skill instructions (SKILL.md-style), loaded on demand. */
108
+ readonly content: string;
109
+ }
110
+ /**
111
+ * A configured, running instance of a datasource skill (e.g. one KakaoTalk
112
+ * account reached through `katok`).
113
+ */
114
+ export interface DatasourceInstance {
115
+ /** Stable instance id, unique within a skill. */
116
+ readonly id: string;
117
+ readonly skill: DatasourceSkill;
118
+ readonly descriptor: DatasourceSkillDescriptor;
119
+ /** Slash-hierarchical opaque root, e.g. `/kakao/<instance-id>`. */
120
+ readonly sourcePath: string;
121
+ readonly polling?: PollingMetadata;
122
+ }
123
+ /** Polling / indexing metadata for a datasource skill or instance. */
124
+ export interface PollingMetadata {
125
+ readonly mode: "none" | "poll" | "cron";
126
+ readonly intervalMs?: number;
127
+ readonly cronExpr?: string;
128
+ /** Epoch milliseconds of the last successful index. */
129
+ readonly lastIndexedAt?: number;
130
+ /** Epoch milliseconds of the last poll attempt. */
131
+ readonly lastPolledAt?: number;
132
+ readonly lastError?: string;
133
+ }
134
+ /** Successful indexing outcome. */
135
+ export interface DatasourceIndexOk {
136
+ readonly ok: true;
137
+ readonly instanceId: string;
138
+ readonly skill: string;
139
+ readonly chunkCount: number;
140
+ readonly indexedAt: number;
141
+ readonly diagnostics: readonly DatasourceDiagnostic[];
142
+ }
143
+ /** Failed indexing outcome. Never thrown; returned with diagnostics. */
144
+ export interface DatasourceIndexFail {
145
+ readonly ok: false;
146
+ readonly instanceId: string;
147
+ readonly skill: string;
148
+ readonly indexedAt: number;
149
+ readonly diagnostics: readonly DatasourceDiagnostic[];
150
+ readonly error?: string;
151
+ readonly code?: DatasourceDiagnosticCode;
152
+ readonly message?: string;
153
+ }
154
+ /**
155
+ * Index result — an ok/fail discriminated union. Skills MUST NOT throw from
156
+ * `index()`; they return a fail variant instead.
157
+ */
158
+ export type DatasourceIndexResult = DatasourceIndexOk | DatasourceIndexFail;
159
+ export type DatasourceDiagnosticCode = "datasource-unavailable" | "datasource-cli-error" | "datasource-empty" | "datasource-rate-limited" | "datasource-auth-error" | "datasource-embedding-egress-rejected" | "datasource-index-failed" | "datasource-permission-denied" | "datasource-remote-embedding-rejected";
160
+ /** Path-opaque diagnostic emitted by the datasource layer. */
161
+ export interface DatasourceDiagnostic {
162
+ readonly code: DatasourceDiagnosticCode;
163
+ readonly severity: "info" | "warning" | "error";
164
+ readonly message: string;
165
+ readonly instanceId?: string;
166
+ /** Opaque component/source label — never a real filesystem path. */
167
+ readonly source?: string;
168
+ }
169
+ /**
170
+ * Description of a single datasource-backed source (a chunk, document, or
171
+ * instance root). `source` is always a slash-hierarchical opaque path with no
172
+ * `#` fragment.
173
+ */
174
+ export interface SourceDescription {
175
+ /** Slash-hierarchical opaque path, e.g. `/kakao/acct-1/chunks/c-42`. */
176
+ readonly source: string;
177
+ readonly datasourceId?: string;
178
+ readonly skill?: string;
179
+ readonly instanceId?: string;
180
+ readonly chunkId?: string;
181
+ readonly contentType?: string;
182
+ readonly metadata: Readonly<Record<string, unknown>>;
183
+ }
@@ -0,0 +1,16 @@
1
+ export interface FileLockOptions {
2
+ readonly timeoutMs: number;
3
+ readonly staleMs: number;
4
+ readonly retryMs?: number;
5
+ readonly timeoutError: () => Error;
6
+ }
7
+ export interface FileLockHandle {
8
+ readonly path: string;
9
+ readonly contents: string;
10
+ assertOwned(): void;
11
+ release(): void;
12
+ }
13
+ export declare class FileLockOwnershipError extends Error {
14
+ constructor(lockPath: string);
15
+ }
16
+ export declare function acquireFileLock(lockPath: string, options: FileLockOptions): FileLockHandle;
@@ -0,0 +1,38 @@
1
+ export interface SourceRoot {
2
+ readonly rootPath: string;
3
+ readonly prefix: string;
4
+ }
5
+ export declare function planSourceRoots(searchPaths: readonly string[]): readonly SourceRoot[];
6
+ export declare function sourceIdentifier(sourceRoot: SourceRoot, sourcePath: string): string;
7
+ /**
8
+ * Resolved mapping from an opaque virtual source id back to a real filesystem
9
+ * path within a configured source root. Real paths NEVER leave this module:
10
+ * callers surface only `sourceId` (opaque) in tool content/details.
11
+ */
12
+ export interface ResolvedVirtualSource {
13
+ readonly root: SourceRoot;
14
+ readonly realPath: string;
15
+ readonly sourceId: string;
16
+ }
17
+ /**
18
+ * Normalize an opaque virtual source id. Returns the normalized id, or
19
+ * `undefined` when the input is syntactically invalid or unsafe (no leading
20
+ * slash, URL scheme, fragment/query, traversal, NUL, backslash). Never throws
21
+ * and never returns a real path — failures are signaled as `undefined`.
22
+ */
23
+ export declare function normalizeVirtualPath(virtual: string | undefined | null): string | undefined;
24
+ /**
25
+ * Exact-prefix boundary match: `/docs` matches `/docs` and `/docs/...` but NOT
26
+ * `/docs-2`. Prevents prefix confusion between sibling roots like `/docs` and
27
+ * `/docs-2`.
28
+ */
29
+ export declare function virtualRootMatches(virtual: string, root: SourceRoot): boolean;
30
+ /**
31
+ * Reverse-resolve an opaque virtual source id to a real path within a
32
+ * configured source root. Selects the longest matching root by exact-prefix
33
+ * boundary, then verifies containment via `realpath` against the selected
34
+ * root's realpath. Symlinks that escape the root are rejected. Returns
35
+ * `undefined` (path-free failure) instead of throwing when the source is
36
+ * missing, out-of-scope, or escapes containment.
37
+ */
38
+ export declare function resolveVirtualSource(virtual: string, sourceRoots: readonly SourceRoot[]): ResolvedVirtualSource | undefined;
@@ -0,0 +1,11 @@
1
+ export { AutoRAGAgent, type AutoRAGAgentOptions, type AutoRAGRefreshComponentStatus, type AutoRAGRefreshOptions, type AutoRAGRefreshResult, type AutoRAGRefreshStatus, type AutoRAGWatchRefreshHandle, type AutoRAGWatchRefreshOptions, type AutoRefreshOptions, type RefreshMethod, } from "./agent/agent.js";
2
+ export { type AutoRAGResultsDetails, createEmitResultsTool, EMIT_AUTORAG_RESULTS_TOOL_NAME, type SearchDocumentDiagnostic, type SearchDocumentDiagnosticCode, type SearchDocumentDiagnosticSeverity, type SearchDocumentsResponse, type SearchDocumentWarning, } from "./agent/index.js";
3
+ export { buildSystemPrompt, type SystemPromptConfig } from "./agent/system-prompt.js";
4
+ export * from "./datasource/index.js";
5
+ export * from "./jikji/index.js";
6
+ export * from "./manifest/index.js";
7
+ export * from "./memory/index.js";
8
+ export * from "./minsync/index.js";
9
+ export * from "./mirror/index.js";
10
+ export * from "./parser/index.js";
11
+ export * from "./retrieval/index.js";