@cerebriline/core 4.100.244 → 4.100.246

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.
@@ -59,6 +59,8 @@ export declare class LocalRuntimeHost implements RuntimeHost {
59
59
  private readonly sessions;
60
60
  private readonly manifestMutationQueues;
61
61
  private readonly usageBySession;
62
+ /** Per session: the listener for its background requests' waits. */
63
+ private readonly sideCallUnsubscribes;
62
64
  private readonly aggregateUsageBySession;
63
65
  private readonly subAgentStarts;
64
66
  private readonly pendingPromptsController;
@@ -0,0 +1,117 @@
1
+ /**
2
+ * Search a workspace's code by meaning.
3
+ *
4
+ * `search_codebase` is a regex: it finds a name the model already knows.
5
+ * `ask_lsp` resolves a symbol the model already has. Neither answers "where
6
+ * does this app check a user's password" when no word of the question is in
7
+ * the code. An embedding model does, and the Library already has everything
8
+ * that needs: chunking, a keyword index, vectors, the merge of the two and a
9
+ * reranker.
10
+ *
11
+ * So the code index is a second Library, kept apart from the user's books
12
+ * under `<data dir>/code-index`, with one collection per workspace and one
13
+ * document per source file. Nothing here knows about embeddings beyond what
14
+ * it hands on.
15
+ *
16
+ * It is opt-in per workspace: indexing sends every source file to the
17
+ * embedder, which on a large repository is real work for a GPU.
18
+ */
19
+ import { type LibrarySettings } from "@cerebriline/shared";
20
+ import type { RetrievalEndpoint } from "./embedding-client";
21
+ import { type EmbedPendingResult, Library } from "./library";
22
+ import type { RetrieveResult } from "./retrieve";
23
+ export declare function resolveCodeIndexDirectory(): string;
24
+ /** A source file larger than this is a data file or a bundle, not code to search. */
25
+ export declare const CODE_INDEX_MAX_FILE_BYTES: number;
26
+ /** Files indexed per workspace, at most. Past it the rest is left out and said so. */
27
+ export declare const CODE_INDEX_MAX_FILES = 20000;
28
+ export declare function isIndexableCodePath(relativePath: string): boolean;
29
+ export interface CodeIndexOptions {
30
+ /** @default <data dir>/code-index */
31
+ directory?: string;
32
+ /** Where LanceDB is installed. @default the Library's */
33
+ runtimeDirectory?: string;
34
+ fetch?: typeof fetch;
35
+ }
36
+ export interface CodeSyncOptions {
37
+ settings?: LibrarySettings;
38
+ /** The workspace's files, relative with forward slashes. @default ripgrep's list, which honours .gitignore */
39
+ listFiles?: (root: string) => Promise<Iterable<string>>;
40
+ onProgress?: (done: number, total: number) => void;
41
+ signal?: AbortSignal;
42
+ }
43
+ export interface CodeSyncResult {
44
+ /** Files in the index after the run. */
45
+ files: number;
46
+ added: number;
47
+ updated: number;
48
+ removed: number;
49
+ /** Files left out: too large, binary, generated, or unreadable. */
50
+ skipped: number;
51
+ /** Set when the workspace has more files than are indexed. */
52
+ truncated?: number;
53
+ }
54
+ export interface CodeEmbedOptions {
55
+ embedding: RetrievalEndpoint;
56
+ settings?: LibrarySettings;
57
+ /** Download LanceDB when it is not installed. */
58
+ install?: boolean;
59
+ onProgress?: (documentsDone: number, documents: number) => void;
60
+ signal?: AbortSignal;
61
+ }
62
+ export interface CodeSearchOptions {
63
+ settings?: LibrarySettings;
64
+ embedding?: RetrievalEndpoint;
65
+ reranker?: RetrievalEndpoint;
66
+ /** Passages returned. @default 8 */
67
+ limit?: number;
68
+ /** How the folder's files are read for line numbers. @default from disk */
69
+ readFile?: (absolutePath: string) => Promise<string | undefined>;
70
+ signal?: AbortSignal;
71
+ }
72
+ export interface CodeHit {
73
+ /** Relative to the workspace, forward slashes. */
74
+ path: string;
75
+ /** 1-based, inclusive. Absent when the file has changed since it was indexed. */
76
+ startLine?: number;
77
+ endLine?: number;
78
+ text: string;
79
+ rerankScore?: number;
80
+ similarity?: number;
81
+ }
82
+ export interface CodeSearchResult {
83
+ hits: CodeHit[];
84
+ mode: RetrieveResult["mode"];
85
+ reranked: boolean;
86
+ notes: string[];
87
+ }
88
+ export interface CodeIndexStatus {
89
+ indexed: boolean;
90
+ files: number;
91
+ chunks: number;
92
+ }
93
+ /** One name for a workspace however its path was spelled. */
94
+ export declare function codeCollectionName(root: string): string;
95
+ export declare class CodeIndex {
96
+ readonly library: Library;
97
+ constructor(options?: CodeIndexOptions);
98
+ private collection;
99
+ status(root: string): CodeIndexStatus;
100
+ /**
101
+ * Bring the index in line with the files on disk: new and changed files
102
+ * are read and chunked, files that are gone are dropped. A file whose size
103
+ * and modification time are what they were is not read again.
104
+ *
105
+ * Searchable by keyword when this returns; `embed` adds the vectors.
106
+ */
107
+ sync(root: string, options?: CodeSyncOptions): Promise<CodeSyncResult>;
108
+ /** Give vectors to every indexed file that has none for this embedding model. */
109
+ embed(root: string, options: CodeEmbedOptions): Promise<EmbedPendingResult>;
110
+ search(root: string, query: string, options?: CodeSearchOptions): Promise<CodeSearchResult>;
111
+ /** Forget a workspace: its files, chunks and vectors. */
112
+ remove(root: string): Promise<boolean>;
113
+ close(): Promise<void>;
114
+ }
115
+ /** The code index of the data folder, opened once. */
116
+ export declare function sharedCodeIndex(): CodeIndex;
117
+ export declare function closeSharedCodeIndex(): Promise<void>;
@@ -21,6 +21,11 @@ export interface ScrapedPage {
21
21
  sha256: string;
22
22
  /** The links on the page, when they were asked for. */
23
23
  links?: string[];
24
+ /**
25
+ * The whole page as the browser held it after its scripts ran, when it
26
+ * was asked for: every tag, nothing cleaned out.
27
+ */
28
+ rawHtml?: string;
24
29
  }
25
30
  export interface ScrapeFailure {
26
31
  url: string;
@@ -34,6 +39,15 @@ export interface CrawlOptions {
34
39
  /** Only paths matching these (regular expressions), when given. */
35
40
  includePaths?: readonly string[];
36
41
  excludePaths?: readonly string[];
42
+ /**
43
+ * Follow links anywhere on the site. Without it a crawl stays below the
44
+ * address it starts from: from `/docs/intro` it never reaches `/docs/api`.
45
+ */
46
+ entireDomain?: boolean;
47
+ /** Also give each page's links, to tell what a crawl left unread. */
48
+ links?: boolean;
49
+ /** Also give each page whole, as rendered (`ScrapedPage.rawHtml`). */
50
+ rawHtml?: boolean;
37
51
  signal?: AbortSignal;
38
52
  fetch?: typeof fetch;
39
53
  /** How long to wait for the crawl. @default 20 minutes */
@@ -62,6 +76,7 @@ export declare function htmlToMarkdown(html: string): Promise<string>;
62
76
  /** Read one page. */
63
77
  export declare function scrapePage(endpoint: ScrapeEndpoint, url: string, options?: RequestOptions & {
64
78
  links?: boolean;
79
+ rawHtml?: boolean;
65
80
  }): Promise<ScrapedPage>;
66
81
  /** Read a page and the pages it links to, as deep and as many as `options` allow. */
67
82
  export declare function crawlSite(endpoint: ScrapeEndpoint, url: string, options: CrawlOptions): Promise<CrawlResult>;
@@ -0,0 +1,101 @@
1
+ /**
2
+ * A site's pages and the files they need, saved as they are.
3
+ *
4
+ * The scraping endpoint reads pages in a browser and gives back their content;
5
+ * it does not give back a stylesheet, a script, a picture or a font. Those are
6
+ * fetched here, straight from the site, by the machine this runs on.
7
+ *
8
+ * Nothing is rewritten. A page is saved as the site served it, byte for byte,
9
+ * and beside it as the browser held it once its scripts had run -- on a site
10
+ * built by JavaScript the first is a shell of a few lines and the second is
11
+ * the page. Links inside them still point where they pointed.
12
+ */
13
+ export interface MirrorPage {
14
+ url: string;
15
+ /** The page as rendered, when the scraper gave it. */
16
+ rawHtml?: string;
17
+ }
18
+ export interface MirrorLimits {
19
+ /** Files fetched besides the pages, at most. @default 2000 */
20
+ maxAssets?: number;
21
+ /** One file's size, at most. @default 25 MB */
22
+ maxAssetBytes?: number;
23
+ /** Everything fetched, at most. @default 300 MB */
24
+ maxTotalBytes?: number;
25
+ /** How many requests run at once. @default 6 */
26
+ concurrency?: number;
27
+ /** How long one request may take. @default 30 s */
28
+ timeoutMs?: number;
29
+ }
30
+ export interface MirrorOptions extends MirrorLimits {
31
+ /** The folder everything is written under. */
32
+ root: string;
33
+ fetch?: typeof fetch;
34
+ signal?: AbortSignal;
35
+ onProgress?: (done: number, known: number) => void;
36
+ /**
37
+ * The file already saved for an address, from an earlier crawl into the
38
+ * same folder: it is not fetched again.
39
+ */
40
+ have?: (url: string) => string | undefined;
41
+ /** Files to fetch besides those the pages name: what an earlier crawl left. */
42
+ also?: readonly string[];
43
+ }
44
+ export interface MirroredPage {
45
+ url: string;
46
+ /** As the site served it; absent when the direct request failed. */
47
+ served?: string;
48
+ /** As the browser rendered it; absent when the scraper gave none. */
49
+ rendered?: string;
50
+ /** Why there is no `served`. */
51
+ problem?: string;
52
+ }
53
+ export interface MirrorReport {
54
+ pages: MirroredPage[];
55
+ /** Files saved besides the pages, by their path under the folder. */
56
+ assets: {
57
+ url: string;
58
+ file: string;
59
+ bytes: number;
60
+ }[];
61
+ failed: {
62
+ url: string;
63
+ reason: string;
64
+ }[];
65
+ /** Files left out because a limit was reached. */
66
+ skipped: number;
67
+ /** Their addresses, for a later crawl to fetch. */
68
+ left: string[];
69
+ /** How many of them the limit of files stopped, and how many the total size. */
70
+ leftForCount: number;
71
+ leftForSize: number;
72
+ /** Files over the size one file may have; they are in `failed` too. */
73
+ tooLarge: number;
74
+ /** Files an earlier crawl had already saved. */
75
+ reused: number;
76
+ bytes: number;
77
+ }
78
+ /**
79
+ * Where a page or a file of a site goes under the folder: its host, then its
80
+ * path as the site has it. A page always ends in `.html`; a path ending in `/`
81
+ * is that folder's `index.html`. A page's query is part of its name, since two
82
+ * queries are two pages; a file's is not, since it is nearly always a cache
83
+ * stamp on one file.
84
+ */
85
+ export declare function mirrorPath(url: string, kind: "page" | "asset", contentType?: string): string | undefined;
86
+ /** `X.html` as `X.rendered.html`. */
87
+ export declare function renderedPath(served: string): string;
88
+ /** The files a stylesheet needs: what it imports, and every `url(...)`. */
89
+ export declare function cssLinks(css: string, base: string): string[];
90
+ /**
91
+ * The files a page needs to look and behave as it does: stylesheets, scripts,
92
+ * pictures, fonts, icons, media. Not the pages it links to.
93
+ */
94
+ export declare function assetLinks(html: string, pageUrl: string): string[];
95
+ /**
96
+ * Save `pages` and every file they need under `options.root`.
97
+ *
98
+ * Never throws for a page or a file that could not be had: each is in the
99
+ * report with its reason. Throws only when the run is aborted.
100
+ */
101
+ export declare function mirrorSite(pages: readonly MirrorPage[], options: MirrorOptions): Promise<MirrorReport>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cerebriline/core",
3
3
  "description": "Cerebriline Core SDK for Node Runtime",
4
- "version": "4.100.244",
4
+ "version": "4.100.246",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/mann1x/cline.git",
@@ -69,9 +69,9 @@
69
69
  "ws": "^8.20.0",
70
70
  "yaml": "^2.8.2",
71
71
  "zod": "^4.3.6",
72
- "@cerebriline/agents": "4.100.244",
73
- "@cerebriline/llms": "4.100.244",
74
- "@cerebriline/shared": "4.100.244"
72
+ "@cerebriline/agents": "4.100.246",
73
+ "@cerebriline/llms": "4.100.246",
74
+ "@cerebriline/shared": "4.100.246"
75
75
  },
76
76
  "peerDependencies": {
77
77
  "posthog-node": "^5.8.0"