@cerebriline/core 4.100.245 → 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.
- package/dist/extensions/context/capped-thinking.d.ts +5 -0
- package/dist/extensions/context/compaction.d.ts +6 -0
- package/dist/extensions/tools/code-search.d.ts +16 -0
- package/dist/extensions/tools/library-tools.d.ts +14 -0
- package/dist/extensions/tools/schemas.d.ts +2 -11
- package/dist/extensions/tools/types.d.ts +9 -1
- package/dist/extensions/tools/web-scrape-tool.d.ts +49 -0
- package/dist/extensions/tools/web-site-crawl.d.ts +96 -0
- package/dist/hub/daemon/entry.js +560 -560
- package/dist/hub/index.js +553 -553
- package/dist/index.d.ts +3 -1
- package/dist/index.js +825 -818
- package/dist/runtime/host/local-runtime-host.d.ts +2 -0
- package/dist/services/retrieval/code-index.d.ts +2 -0
- package/dist/services/retrieval/firecrawl.d.ts +15 -0
- package/dist/services/retrieval/web-mirror.d.ts +101 -0
- package/package.json +4 -4
|
@@ -158,6 +158,11 @@ export interface CappedThinkingCondenserConfig {
|
|
|
158
158
|
/** Absent when no provider is resolved yet; the condenser then stands down. */
|
|
159
159
|
providerConfig?: ProviderConfig;
|
|
160
160
|
summarizer?: CoreCompactionSummarizerConfig;
|
|
161
|
+
/**
|
|
162
|
+
* The conversation the notes are written for (`ProviderConfig.sideCallOf`).
|
|
163
|
+
* Set for the lead only: an agent's note must never close the lead.
|
|
164
|
+
*/
|
|
165
|
+
sideCallOf?: string;
|
|
161
166
|
logger?: BasicLogger;
|
|
162
167
|
}
|
|
163
168
|
type PrepareTurnResult = {
|
|
@@ -61,6 +61,12 @@ export interface ContextCompactionPrepareTurnOptions {
|
|
|
61
61
|
* visibility is. See {@link createCompactionJournal}.
|
|
62
62
|
*/
|
|
63
63
|
journal?: CompactionJournal;
|
|
64
|
+
/**
|
|
65
|
+
* The conversation the summaries are written for
|
|
66
|
+
* (`ProviderConfig.sideCallOf`). Set for the lead only: an agent's summary
|
|
67
|
+
* must never close the lead.
|
|
68
|
+
*/
|
|
69
|
+
sideCallOf?: string;
|
|
64
70
|
}
|
|
65
71
|
/**
|
|
66
72
|
* The share of the *content* a compaction aims to leave behind.
|
|
@@ -37,6 +37,11 @@ export interface CreateCodeSearchOptions {
|
|
|
37
37
|
getConfig: () => CodeSearchConfig;
|
|
38
38
|
/** @default the shared code index of the data folder */
|
|
39
39
|
index?: CodeIndex;
|
|
40
|
+
/**
|
|
41
|
+
* Download LanceDB, which holds the vectors, when it is not installed. For
|
|
42
|
+
* a host with no panel to offer the download from. @default false
|
|
43
|
+
*/
|
|
44
|
+
install?: boolean;
|
|
40
45
|
log?: (message: string) => void;
|
|
41
46
|
}
|
|
42
47
|
export interface CodeSearch extends SemanticSearchExecutor {
|
|
@@ -53,3 +58,14 @@ export declare function codeSearchAvailable(config: CodeSearchConfig, root: stri
|
|
|
53
58
|
/** The hits as the model reads them: where each passage is, then the passage. */
|
|
54
59
|
export declare function formatCodeHits(result: CodeSearchResult): string;
|
|
55
60
|
export declare function createCodeSearch(options: CreateCodeSearchOptions): CodeSearch;
|
|
61
|
+
/**
|
|
62
|
+
* The lead's code search as a delegated agent uses it.
|
|
63
|
+
*
|
|
64
|
+
* An agent is built without the lead's executors, so that none of them points
|
|
65
|
+
* its file tools at the real workspace. This one only reads, and what it reads
|
|
66
|
+
* for line numbers goes through the agent's own copy of the folder: a passage
|
|
67
|
+
* in a file the agent has edited is given the lines it is on there.
|
|
68
|
+
*/
|
|
69
|
+
export declare function semanticSearchForAgent(lead: SemanticSearchExecutor | undefined, overlay: {
|
|
70
|
+
read(path: string): Promise<Buffer>;
|
|
71
|
+
} | undefined): SemanticSearchExecutor | undefined;
|
|
@@ -26,6 +26,20 @@ export interface LibraryScrapeConfig extends ScrapeEndpoint {
|
|
|
26
26
|
maxPages: number;
|
|
27
27
|
/** How many links deep a crawl follows. */
|
|
28
28
|
maxDepth: number;
|
|
29
|
+
/**
|
|
30
|
+
* `false`: every task is offered the general `web_scrape`
|
|
31
|
+
* (`web-scrape-tool.ts`), which the librarian then uses too. Otherwise
|
|
32
|
+
* scraping is the librarian's only.
|
|
33
|
+
*/
|
|
34
|
+
librarianOnly?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* What a site crawl may fetch besides its pages: how many files, how
|
|
37
|
+
* large one may be and how much in all, in megabytes. Absent, the
|
|
38
|
+
* defaults of `ScrapeSettings`.
|
|
39
|
+
*/
|
|
40
|
+
maxFiles?: number;
|
|
41
|
+
maxFileMb?: number;
|
|
42
|
+
maxTotalMb?: number;
|
|
29
43
|
}
|
|
30
44
|
export interface LibraryToolsConfig {
|
|
31
45
|
settings: LibrarySettings;
|
|
@@ -775,16 +775,7 @@ export type AskQuestionInput = z.infer<typeof AskQuestionInputSchema>;
|
|
|
775
775
|
* Input for the submit and exit tool
|
|
776
776
|
*/
|
|
777
777
|
export type SubmitInput = z.infer<typeof SubmitInputSchema>;
|
|
778
|
-
|
|
779
|
-
* What `grep`, `sed` and `awk` accept, as against what they advertise.
|
|
780
|
-
*
|
|
781
|
-
* The advertised shape keeps `array`, because that is the shape that batches.
|
|
782
|
-
* These wrappers only widen the door: the one field each of them gets wrong is
|
|
783
|
-
* the file list, and it is always wrong the same way. Every other field is the
|
|
784
|
-
* canonical schema's own, so the parsed output is the canonical type already --
|
|
785
|
-
* no pipe back through it, which `z.coerce` fields make ill-typed anyway.
|
|
786
|
-
*/
|
|
787
|
-
export declare const GrepInputUnionSchema: z.ZodObject<{
|
|
778
|
+
export declare const GrepInputUnionSchema: z.ZodPreprocess<z.ZodObject<{
|
|
788
779
|
pattern: z.ZodString;
|
|
789
780
|
ignore_case: z.ZodOptional<z.ZodBoolean>;
|
|
790
781
|
invert: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -797,7 +788,7 @@ export declare const GrepInputUnionSchema: z.ZodObject<{
|
|
|
797
788
|
context: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
798
789
|
max_count: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
799
790
|
paths: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodString>, z.ZodPipe<z.ZodString, z.ZodTransform<string[], string>>]>>;
|
|
800
|
-
}, z.core.$strip
|
|
791
|
+
}, z.core.$strip>>;
|
|
801
792
|
export declare const SedInputUnionSchema: z.ZodObject<{
|
|
802
793
|
script: z.ZodString;
|
|
803
794
|
in_place: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -62,7 +62,15 @@ export interface SemanticSearchExecutor {
|
|
|
62
62
|
* indexed. One host serves many workspaces, so the answer is per folder.
|
|
63
63
|
*/
|
|
64
64
|
available(cwd: string): boolean;
|
|
65
|
-
search(query: string, cwd: string, context: AgentToolContext): Promise<string>;
|
|
65
|
+
search(query: string, cwd: string, context: AgentToolContext, options?: SemanticSearchOptions): Promise<string>;
|
|
66
|
+
}
|
|
67
|
+
export interface SemanticSearchOptions {
|
|
68
|
+
/**
|
|
69
|
+
* Read a file of the folder as the caller sees it, by absolute path. A
|
|
70
|
+
* delegated agent works on its own copy: the lines a passage is on are the
|
|
71
|
+
* lines of that copy, not of the lead's file.
|
|
72
|
+
*/
|
|
73
|
+
readFile?: (absolutePath: string) => Promise<string | undefined>;
|
|
66
74
|
}
|
|
67
75
|
/**
|
|
68
76
|
* Per-call execution options for a shell executor.
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `web_scrape`: the web through a Firecrawl endpoint.
|
|
3
|
+
*
|
|
4
|
+
* Two shapes of one tool. The librarian's looks at the web to choose what a
|
|
5
|
+
* book is made from: search, map, read. The general one is offered to any
|
|
6
|
+
* task when the user turns "Only for the librarian" off, and adds what a task
|
|
7
|
+
* outside the Library needs: a crawl that saves a site into the workspace.
|
|
8
|
+
* By default that is the site itself -- every page as it was served and as
|
|
9
|
+
* the browser rendered it, with the stylesheets, scripts, pictures and fonts
|
|
10
|
+
* it uses -- beside a markdown reading of each page; `content: "text"` keeps
|
|
11
|
+
* the markdown alone, for notes.
|
|
12
|
+
*
|
|
13
|
+
* The lead's only: it is not in `DELEGATED_HOST_TOOLS`, so a delegated agent,
|
|
14
|
+
* whose writes go through its overlay, is never handed a tool that writes to
|
|
15
|
+
* the workspace directly.
|
|
16
|
+
*/
|
|
17
|
+
import { type AgentTool } from "@cerebriline/shared";
|
|
18
|
+
import type { LibraryScrapeConfig } from "./library-tools";
|
|
19
|
+
export { cleanLink, linkCensus, pageFileName } from "./web-site-crawl";
|
|
20
|
+
export declare const WEB_SCRAPE_TOOL_NAME = "web_scrape";
|
|
21
|
+
export declare const NO_SCRAPER = "Web scraping is not set up for this session. The user sets the endpoint under Settings > Features and allows it in the API configuration; do not call this again in this task.";
|
|
22
|
+
export interface WebScrapeToolOptions {
|
|
23
|
+
/** The folder saved pages are written under. */
|
|
24
|
+
cwd: string;
|
|
25
|
+
/** The endpoint and its limits, read on every call. Undefined: not set up. */
|
|
26
|
+
getScrape: () => LibraryScrapeConfig | undefined;
|
|
27
|
+
/** What stops the tool before the endpoint is asked, said to the model. */
|
|
28
|
+
unavailable?: () => string | undefined;
|
|
29
|
+
/** The general tool: `crawl`, and `save_to`. @default false, the librarian's */
|
|
30
|
+
general?: boolean;
|
|
31
|
+
onError?: (message: string, error: unknown) => void;
|
|
32
|
+
/**
|
|
33
|
+
* A text file the tool wrote, by absolute path. The host forgets what it
|
|
34
|
+
* knew of the file, so a later read is not told that something outside the
|
|
35
|
+
* session changed it.
|
|
36
|
+
*/
|
|
37
|
+
onWrote?: (file: string) => void;
|
|
38
|
+
}
|
|
39
|
+
/** `target` under `cwd`, or nothing when it would leave the folder. */
|
|
40
|
+
export declare function workspacePath(cwd: string, target: string): string | undefined;
|
|
41
|
+
export declare function createWebScrapeTool(options: WebScrapeToolOptions): AgentTool;
|
|
42
|
+
/**
|
|
43
|
+
* The general tool, when scraping is set up, allowed, and not kept for the
|
|
44
|
+
* librarian. Decided at session start, like every other tool list; the
|
|
45
|
+
* endpoint itself is read again on every call.
|
|
46
|
+
*/
|
|
47
|
+
export declare function createWebScrapeTools(options: Omit<WebScrapeToolOptions, "general"> & {
|
|
48
|
+
log?: (message: string) => void;
|
|
49
|
+
}): AgentTool[];
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A site crawled into a folder of the workspace, and continued later.
|
|
3
|
+
*
|
|
4
|
+
* The folder keeps a record of the crawl (`.scrape.json`): the pages read
|
|
5
|
+
* and where each was saved, the files fetched, the pages that are linked and
|
|
6
|
+
* were not read, and the files a limit left out. A later crawl into the same
|
|
7
|
+
* folder with `resume` reads only what is missing -- the pages from that
|
|
8
|
+
* list, one by one through the endpoint, and the files not yet on disk --
|
|
9
|
+
* and nothing that is already there.
|
|
10
|
+
*
|
|
11
|
+
* Every limit that stopped something is said at the top of the result, as an
|
|
12
|
+
* alert the model is told to pass on: the user set those limits, and only
|
|
13
|
+
* the user can raise them.
|
|
14
|
+
*/
|
|
15
|
+
import { type ScrapedPage } from "../../services/retrieval/firecrawl";
|
|
16
|
+
import type { LibraryScrapeConfig } from "./library-tools";
|
|
17
|
+
export declare function plural(count: number, one: string, many?: string): string;
|
|
18
|
+
/** An http(s) address without its fragment, or nothing. */
|
|
19
|
+
export declare function cleanLink(link: string): string | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* A page's file under the crawl's folder: its host and path, with what a
|
|
22
|
+
* file name cannot hold replaced, so two pages of a site never collide and
|
|
23
|
+
* the folder reads like the site.
|
|
24
|
+
*/
|
|
25
|
+
export declare function pageFileName(url: string, taken: Set<string>): string;
|
|
26
|
+
export declare function pageFile(page: ScrapedPage): string;
|
|
27
|
+
/**
|
|
28
|
+
* Where the links of the pages read lead: pages of the same site that were
|
|
29
|
+
* not read, and other sites. It is what tells "the site has no more pages"
|
|
30
|
+
* from "the crawl stopped short" -- the two read the same from a page count.
|
|
31
|
+
*/
|
|
32
|
+
export declare function linkCensus(pages: readonly ScrapedPage[], start: string): {
|
|
33
|
+
unread: string[];
|
|
34
|
+
elsewhere: string[];
|
|
35
|
+
};
|
|
36
|
+
export declare function sitesLine(hosts: readonly string[], most?: number): string;
|
|
37
|
+
/** The record a crawl leaves in its folder. */
|
|
38
|
+
export declare const SITE_RECORD_FILE = ".scrape.json";
|
|
39
|
+
export interface SiteRecord {
|
|
40
|
+
version: 1;
|
|
41
|
+
/** The address the crawl started from. */
|
|
42
|
+
url: string;
|
|
43
|
+
content: "site" | "text";
|
|
44
|
+
wholeSite: boolean;
|
|
45
|
+
include: string[];
|
|
46
|
+
exclude: string[];
|
|
47
|
+
/** Pages read, by address. */
|
|
48
|
+
pages: Record<string, {
|
|
49
|
+
title?: string;
|
|
50
|
+
markdown: string;
|
|
51
|
+
characters: number;
|
|
52
|
+
served?: string;
|
|
53
|
+
rendered?: string;
|
|
54
|
+
}>;
|
|
55
|
+
/** Files fetched, by address. */
|
|
56
|
+
assets: Record<string, {
|
|
57
|
+
file: string;
|
|
58
|
+
bytes: number;
|
|
59
|
+
}>;
|
|
60
|
+
/** Pages of the site that are linked and were not read. */
|
|
61
|
+
unread: string[];
|
|
62
|
+
/** Files a limit left out. */
|
|
63
|
+
assetsLeft: string[];
|
|
64
|
+
/** Files that could not be fetched, with the reason. */
|
|
65
|
+
failed: Record<string, string>;
|
|
66
|
+
/** Pages that could not be read, with the reason. */
|
|
67
|
+
failedPages: Record<string, string>;
|
|
68
|
+
}
|
|
69
|
+
export interface CrawlToFolderRequest {
|
|
70
|
+
scrape: LibraryScrapeConfig;
|
|
71
|
+
url: string;
|
|
72
|
+
/** The folder, absolute. */
|
|
73
|
+
target: string;
|
|
74
|
+
/** The folder as the model named it, for the result. */
|
|
75
|
+
folder: string;
|
|
76
|
+
limit?: number;
|
|
77
|
+
depth?: number;
|
|
78
|
+
include: string[];
|
|
79
|
+
exclude: string[];
|
|
80
|
+
wholeSite?: boolean;
|
|
81
|
+
content?: "site" | "text";
|
|
82
|
+
resume: boolean;
|
|
83
|
+
signal?: AbortSignal;
|
|
84
|
+
emit?: (status: string) => void;
|
|
85
|
+
/** A text file the crawl wrote or rewrote, by absolute path. */
|
|
86
|
+
wrote?: (file: string) => void;
|
|
87
|
+
/** The crawl stopped at a limit of the user's; see `reportStoppedForUser`. */
|
|
88
|
+
stopped?: (reason: string) => void;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Whether a link is one this crawl reads: the same site, below the starting
|
|
92
|
+
* address unless the whole site was asked for, and through the path filters.
|
|
93
|
+
*/
|
|
94
|
+
export declare function inCrawlScope(link: string, record: Pick<SiteRecord, "url" | "wholeSite" | "include" | "exclude">): boolean;
|
|
95
|
+
/** Crawl a site into a folder, or continue the crawl that is there. */
|
|
96
|
+
export declare function crawlToFolder(request: CrawlToFolderRequest): Promise<string>;
|