@cerebriline/core 4.100.240 → 4.100.242

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 (64) hide show
  1. package/assets/skills/README.md +14 -0
  2. package/assets/skills/build-project/SKILL.md +103 -0
  3. package/assets/skills/docker-compose-deploy/SKILL.md +239 -0
  4. package/assets/skills/librarian/SKILL.md +177 -0
  5. package/assets/skills/mandatory-qa-prompt-and-issue-resolution/SKILL.md +58 -0
  6. package/assets/skills/run-project/SKILL.md +103 -0
  7. package/assets/skills/sdd-discuss/SKILL.md +129 -0
  8. package/assets/skills/sdd-execute/SKILL.md +146 -0
  9. package/assets/skills/sdd-plan/SKILL.md +140 -0
  10. package/assets/skills/sdd-quick/SKILL.md +40 -0
  11. package/assets/skills/sdd-status/SKILL.md +75 -0
  12. package/assets/skills/sdd-verify/SKILL.md +122 -0
  13. package/assets/skills/sdd-wizard/SKILL.md +105 -0
  14. package/assets/skills/tdd-coverage/SKILL.md +88 -0
  15. package/assets/skills/tdd-gen/SKILL.md +82 -0
  16. package/assets/skills/tdd-test/SKILL.md +61 -0
  17. package/assets/skills/tdd-wizard/SKILL.md +162 -0
  18. package/dist/document-reader-child.js +23 -0
  19. package/dist/extensions/config/bundled-skills.d.ts +24 -0
  20. package/dist/extensions/config/index.d.ts +2 -1
  21. package/dist/extensions/config/unified-config-file-watcher.d.ts +15 -0
  22. package/dist/extensions/config/user-instruction-config-loader.d.ts +15 -0
  23. package/dist/extensions/tools/executors/document/ebook.d.ts +10 -0
  24. package/dist/extensions/tools/executors/document/formats.d.ts +25 -0
  25. package/dist/extensions/tools/executors/document/ocr.d.ts +8 -0
  26. package/dist/extensions/tools/executors/document/read-job.d.ts +68 -0
  27. package/dist/extensions/tools/executors/document/read-process.d.ts +52 -0
  28. package/dist/extensions/tools/executors/document/read-protocol.d.ts +65 -0
  29. package/dist/extensions/tools/executors/document/recognition.d.ts +14 -5
  30. package/dist/extensions/tools/executors/document-extract.d.ts +120 -1
  31. package/dist/extensions/tools/librarian-tools.d.ts +32 -0
  32. package/dist/extensions/tools/library-import-run.d.ts +79 -0
  33. package/dist/extensions/tools/library-tools.d.ts +88 -0
  34. package/dist/extensions/tools/memory-tools.d.ts +41 -0
  35. package/dist/extensions/tools/sdd-tool.d.ts +215 -0
  36. package/dist/extensions/tools/team/create-agent-tool.d.ts +5 -4
  37. package/dist/hub/daemon/entry.js +607 -603
  38. package/dist/hub/index.js +595 -591
  39. package/dist/index.d.ts +17 -1
  40. package/dist/index.js +1080 -695
  41. package/dist/services/global-settings.d.ts +9 -0
  42. package/dist/services/llms/provider-settings.d.ts +15 -15
  43. package/dist/services/retrieval/catalogue.d.ts +397 -0
  44. package/dist/services/retrieval/chunker.d.ts +44 -0
  45. package/dist/services/retrieval/embedding-client.d.ts +78 -0
  46. package/dist/services/retrieval/fingerprint.d.ts +21 -0
  47. package/dist/services/retrieval/firecrawl.d.ts +77 -0
  48. package/dist/services/retrieval/lancedb-runtime.d.ts +84 -0
  49. package/dist/services/retrieval/lancedb-runtime.manifest.d.ts +17 -0
  50. package/dist/services/retrieval/library-store.d.ts +148 -0
  51. package/dist/services/retrieval/library.d.ts +139 -0
  52. package/dist/services/retrieval/memory-recall.d.ts +97 -0
  53. package/dist/services/retrieval/memory.d.ts +184 -0
  54. package/dist/services/retrieval/retrieve.d.ts +85 -0
  55. package/dist/services/retrieval/running-heads.d.ts +38 -0
  56. package/dist/services/retrieval/tar-extract.d.ts +14 -0
  57. package/dist/services/retrieval/tar-write.d.ts +20 -0
  58. package/dist/services/retrieval/vector-index.d.ts +82 -0
  59. package/dist/services/sdd/sdd-engine.d.ts +248 -0
  60. package/dist/services/telemetry/index.js +1 -1
  61. package/dist/types/config.d.ts +7 -0
  62. package/dist/types/session.d.ts +2 -0
  63. package/package.json +4 -4
  64. package/dist/extensions/tools/code-intel.d.ts +0 -131
@@ -0,0 +1,65 @@
1
+ /**
2
+ * What the session and its reader process say to each other.
3
+ *
4
+ * Sent over Node's IPC channel with structured-clone serialization, so byte
5
+ * arrays arrive as byte arrays.
6
+ */
7
+ import type { AgentImageToDescribe } from "@cerebriline/shared";
8
+ import type { DocumentFormat, DocumentReadResult, ReadProgress } from "./formats";
9
+ import type { ExtractedImage } from "./images";
10
+ import type { ReadJob } from "./read-job";
11
+ /** Where, inside the job's scratch directory, the pictures are handed back. */
12
+ export declare const READ_OUTPUT_DIRECTORY = ".out";
13
+ export type ParentMessage = {
14
+ type: "start";
15
+ job: ReadJob;
16
+ hasVision: boolean;
17
+ } | {
18
+ type: "abort";
19
+ }
20
+ /** The answer arrived whole: the reader may go. */
21
+ | {
22
+ type: "received";
23
+ } | {
24
+ type: "described";
25
+ id: number;
26
+ descriptions?: (string | undefined)[];
27
+ error?: string;
28
+ };
29
+ export type ChildMessage = {
30
+ type: "ready";
31
+ } | {
32
+ type: "progress";
33
+ progress: ReadProgress;
34
+ } | {
35
+ type: "note";
36
+ line: string;
37
+ } | {
38
+ type: "describe";
39
+ id: number;
40
+ images: AgentImageToDescribe[];
41
+ } | {
42
+ type: "done";
43
+ format: DocumentFormat;
44
+ result: DocumentReadResult;
45
+ /** Each picture's bytes are in `file`. */
46
+ images: {
47
+ image: ExtractedImage;
48
+ file: string;
49
+ }[];
50
+ recognitionNotes: string[];
51
+ recognitionProblems: string[];
52
+ attachments: {
53
+ page: number;
54
+ png: Uint8Array;
55
+ }[];
56
+ problems: string[];
57
+ usage: {
58
+ ms: number;
59
+ peakRssMb: number;
60
+ };
61
+ } | {
62
+ type: "failed";
63
+ message: string;
64
+ aborted: boolean;
65
+ };
@@ -35,6 +35,11 @@ export interface RecognitionPlan {
35
35
  }[];
36
36
  /** Sentences for the result header. */
37
37
  notes(scannedPages: readonly number[], recognizedPages: readonly number[]): string[];
38
+ /**
39
+ * Every scanned page that has no recognized text, with the reason, a line
40
+ * each. `notes` is the summary a reader skims; this is the whole account.
41
+ */
42
+ problems(scannedPages: readonly number[], recognizedPages: readonly number[]): string[];
38
43
  close(): Promise<void>;
39
44
  }
40
45
  interface PlanInput {
@@ -43,6 +48,12 @@ interface PlanInput {
43
48
  settings: DocumentReaderSettings;
44
49
  describeImages?: DescribeImages;
45
50
  modelSupportsImages: boolean;
51
+ /**
52
+ * How many scanned pages are recognized. A book kept in the Library is
53
+ * read whole: its call is long by design and reports as it goes.
54
+ * @default the engine's per-call limit
55
+ */
56
+ pageLimit?: number;
46
57
  }
47
58
  /**
48
59
  * The recognition a call will do, ready to hand to the reader.
@@ -54,13 +65,11 @@ export declare function planRecognition(input: PlanInput): RecognitionPlan;
54
65
  export interface PictureToDescribe {
55
66
  link: string;
56
67
  mediaType: string;
57
- data: Uint8Array;
68
+ /** The bytes, or where to read them when they are asked for: one picture in memory at a time. */
69
+ data: Uint8Array | (() => Promise<Uint8Array>);
58
70
  source?: string;
59
71
  }
60
- /**
61
- * Descriptions of a document's pictures, one request each, in order.
62
- * `undefined` for any the vision model could not describe.
63
- */
72
+ export declare function describePicture(describeImages: DescribeImages, picture: PictureToDescribe, documentName: string): Promise<string | undefined>;
64
73
  export declare function describePictures(describeImages: DescribeImages, pictures: readonly PictureToDescribe[], documentName: string): Promise<(string | undefined)[]>;
65
74
  /** A description short enough for alt text: its first sentences, up to 300 characters. */
66
75
  export declare function altTextOf(description: string): string;
@@ -8,6 +8,7 @@
8
8
  */
9
9
  import type { AgentOverlay } from "../../../runtime/sandbox/overlay-fs";
10
10
  import type { ExtractDocumentExecutor } from "../types";
11
+ import { type DocumentFormat, type ReadProgress } from "./document/formats";
11
12
  import type { DocumentReaderSettings } from "./document/ocr";
12
13
  import { type DescribeImages } from "./document/recognition";
13
14
  /** Where extractions go when the call names no `output_dir`. */
@@ -17,7 +18,7 @@ export interface DocumentExtractExecutorOptions {
17
18
  cwd?: string;
18
19
  /** A delegated agent's overlay: reads fall through, writes stay private. */
19
20
  overlay?: AgentOverlay;
20
- /** @default 200 MB */
21
+ /** Over the reader's `maxFileMb` setting. @default 1 GB */
21
22
  maxFileSizeBytes?: number;
22
23
  /** The user's Document Reader settings: how scanned pages are read, and descriptions. */
23
24
  reader?: DocumentReaderSettings;
@@ -28,6 +29,18 @@ export interface DocumentExtractExecutorOptions {
28
29
  */
29
30
  describeImages?: DescribeImages;
30
31
  }
32
+ /**
33
+ * The largest file read unless the settings say otherwise.
34
+ *
35
+ * 200 MB once, when a book was read inside the session's own process and one
36
+ * large enough could take it down. Each is read in a process of its own now,
37
+ * and out of memory there is one file's error. Measured with that reader on
38
+ * the largest books of a real shelf: a 228 MB EPUB, 812 MB at its peak in 3 s;
39
+ * a 411 MB PDF, 2.6 GB in 80 s.
40
+ */
41
+ export declare const DEFAULT_MAX_FILE_MB = 1024;
42
+ /** The limit in bytes: an explicit one, else the setting, else the default. */
43
+ export declare function documentReaderLimitBytes(maxFileSizeBytes: number | undefined, reader: DocumentReaderSettings | undefined): number;
31
44
  /**
32
45
  * The executor options a session's configuration gives the tool: the user's
33
46
  * settings and the session's vision model. The same for the lead and every
@@ -52,4 +65,110 @@ export declare function markdownToText(markdown: string): string;
52
65
  * and all of it is tokens.
53
66
  */
54
67
  export declare function tidyMarkdown(markdown: string): string;
68
+ export interface DocumentText {
69
+ /** The document as markdown. */
70
+ markdown: string;
71
+ format: DocumentFormat;
72
+ title?: string;
73
+ author?: string;
74
+ bytes: number;
75
+ /** What was skipped or could not be read, in sentences. */
76
+ notes: string[];
77
+ }
78
+ /**
79
+ * A document's text, and nothing written anywhere: what the Library indexes.
80
+ *
81
+ * The same readers as the tool, without the pictures. Scanned pages are read
82
+ * when the settings name an engine that needs no model in the conversation
83
+ * (tesseract, or the vision model when one is given).
84
+ */
85
+ export declare function readDocumentText(filePath: string, options: {
86
+ /** Removed afterwards. Not the system temp directory: a book's pages can be large. */
87
+ scratchDir: string;
88
+ maxFileSizeBytes?: number;
89
+ reader?: DocumentReaderSettings;
90
+ describeImages?: DescribeImages;
91
+ }): Promise<DocumentText>;
92
+ export interface BookDocument extends DocumentText {
93
+ /**
94
+ * The pictures inside it; the markdown links them as `images/<file>`.
95
+ * Each one's bytes are in the file at `path`, not in memory: a scanned
96
+ * book is a picture a page. They are there until `release`.
97
+ */
98
+ images: {
99
+ file: string;
100
+ path: string;
101
+ mediaType: string;
102
+ width?: number;
103
+ height?: number;
104
+ origin?: string;
105
+ description?: string;
106
+ /** `description` is a vision model's, not the caption the document gave. */
107
+ described?: boolean;
108
+ }[];
109
+ /** Pages or chapters it has, and how many were read. */
110
+ units?: {
111
+ name: string;
112
+ total: number;
113
+ read: number;
114
+ };
115
+ /** Scanned pages, and how many of them had their text recognized. */
116
+ scanned?: {
117
+ pages: number;
118
+ recognized: number;
119
+ };
120
+ /**
121
+ * Everything that was left out, a line each: a scanned page with no
122
+ * recognized text, a picture that could not be taken out. Empty when the
123
+ * whole document was read.
124
+ */
125
+ problems: string[];
126
+ /**
127
+ * Removes the pictures' files. Called once the book is filed or given
128
+ * up, on every path; a session that dies first leaves them for
129
+ * `sweepAbandonedReads`.
130
+ */
131
+ release(): Promise<void>;
132
+ }
133
+ /**
134
+ * Remove scratch directories that reads left behind: a session that ended
135
+ * between reading a book and filing it never released its pictures.
136
+ */
137
+ export declare function sweepAbandonedReads(scratchDir: string, olderThanMs?: number): Promise<void>;
138
+ /**
139
+ * A document as the Library keeps a book: its text and its pictures.
140
+ * Nothing is written anywhere the caller sees; the caller puts the pictures
141
+ * where the book is kept, `describeBookPictures` has a vision model look at
142
+ * them, and `release` removes them.
143
+ */
144
+ export declare function readDocumentForBook(filePath: string, options: {
145
+ scratchDir: string;
146
+ maxFileSizeBytes?: number;
147
+ reader?: DocumentReaderSettings;
148
+ describeImages?: DescribeImages;
149
+ /**
150
+ * Take the pictures out as well. Off for a read that only compares
151
+ * text: a scanned book is a picture a page, a gigabyte of them decoded.
152
+ * @default true
153
+ */
154
+ pictures?: boolean;
155
+ /** Stops the read at the next page or chapter; the read throws. */
156
+ signal?: AbortSignal;
157
+ onProgress?: (progress: ReadProgress) => void;
158
+ /** Lines for the log: what the decoder warned about, a picture asked for twice. */
159
+ onNote?: (line: string) => void;
160
+ }): Promise<BookDocument>;
161
+ /**
162
+ * Have the vision model describe a book's pictures: each description is kept
163
+ * with its picture and becomes the alt text where the text shows it, so a
164
+ * search for what a figure shows finds the page it is on. Resolves with how
165
+ * many were described and how many could have been.
166
+ */
167
+ export declare function describeBookPictures(book: BookDocument, describeImages: DescribeImages, options: {
168
+ documentName: string;
169
+ limit?: number;
170
+ }): Promise<{
171
+ described: number;
172
+ candidates: number;
173
+ }>;
55
174
  export declare function createDocumentExtractExecutor(options?: DocumentExtractExecutorOptions): ExtractDocumentExecutor;
@@ -0,0 +1,32 @@
1
+ /**
2
+ * The librarian's tools: everything that changes the Library.
3
+ *
4
+ * They come with the `librarian` skill, which says how the work is done:
5
+ * check whether a book is already here before adding it, ask the user when
6
+ * it is another edition, put it on the shelf it belongs on. The tools keep
7
+ * the rules that must hold whoever is asking: nothing is added over a book
8
+ * that looks the same without being told to, and nothing is deleted, only
9
+ * moved to the trash.
10
+ */
11
+ import { type AgentTool } from "@cerebriline/shared";
12
+ import { type BookDocument } from "./executors/document-extract";
13
+ import { type CreateLibraryToolsOptions } from "./library-tools";
14
+ export declare const LIBRARIAN_TOOL_NAMES: readonly ["library_check", "library_add", "library_organize", "library_transfer", "web_scrape", "library_web_book"];
15
+ export interface ReadSource {
16
+ file: string;
17
+ name: string;
18
+ sha256: string;
19
+ document: BookDocument;
20
+ isbn?: string;
21
+ fingerprint: number[];
22
+ /** The lines on most of its pages: which document it is, see running-heads.ts. */
23
+ runningHeads: string[];
24
+ }
25
+ /** An ISBN printed in the first pages, when there is one. */
26
+ export declare function findIsbn(markdown: string): string | undefined;
27
+ export declare function compareBatch(sources: readonly ReadSource[]): Map<string, string[]>;
28
+ /**
29
+ * The librarian's tools. The two web tools are there only when a scraping
30
+ * endpoint is configured and the session's profile allows it.
31
+ */
32
+ export declare function createLibrarianTools(options: CreateLibraryToolsOptions): AgentTool[];
@@ -0,0 +1,79 @@
1
+ /**
2
+ * One librarian call that reads files, as the person watching sees it.
3
+ *
4
+ * Reading a book is minutes: every page of a PDF, every scanned page through
5
+ * recognition. A row that sits unchanged for that long reads as a hang, and
6
+ * a real hang looks the same. So the call says where it is, file by file,
7
+ * and says so when a file has stopped moving; it can be cancelled from its
8
+ * row; and however it ends, the model is told what was read, what was left
9
+ * out and why, a line for each.
10
+ */
11
+ import type { AgentToolContext } from "@cerebriline/shared";
12
+ import type { ReadProgress } from "./executors/document/formats";
13
+ /**
14
+ * Cancels every librarian call that is reading files. Each one ends as a
15
+ * failed tool call whose error is its full report.
16
+ * @returns how many were cancelled
17
+ */
18
+ export declare function cancelLibraryImports(): number;
19
+ /** Whether a librarian call is reading files right now. */
20
+ export declare function hasActiveLibraryImports(): boolean;
21
+ export declare class LibraryImportCancelled extends Error {
22
+ constructor(reason: string);
23
+ }
24
+ export declare class LibraryImportRun {
25
+ private readonly what;
26
+ private readonly context;
27
+ private readonly log?;
28
+ private readonly entries;
29
+ private readonly controller;
30
+ private readonly startedAt;
31
+ private readonly timer;
32
+ private readonly onOuterAbort;
33
+ private lastEmit;
34
+ private lastLog;
35
+ private pendingEmit;
36
+ private cancelReason;
37
+ private closed;
38
+ private rejectOnCancel;
39
+ private readonly cancelled;
40
+ constructor(what: string, files: readonly string[], context: AgentToolContext | undefined, log?: ((message: string) => void) | undefined,
41
+ /** What an item is called on its line. @default the file's name */
42
+ label?: (item: string) => string);
43
+ /** Handed to the reader: it stops at the next page or chapter. */
44
+ get signal(): AbortSignal;
45
+ get isCancelled(): boolean;
46
+ /** @returns false when it was already cancelled or over */
47
+ cancel(reason: string): boolean;
48
+ /**
49
+ * The work, or the cancellation, whichever is first. A reader notices a
50
+ * cancellation at its next page; one that is waiting on something that
51
+ * never answers does not, and the call must still end.
52
+ */
53
+ guard<T>(work: Promise<T>): Promise<T>;
54
+ private entry;
55
+ start(file: string): void;
56
+ progress(file: string, progress: ReadProgress): void;
57
+ /** A line about a file for the log alone. */
58
+ note(file: string, line: string): void;
59
+ /** What a file is doing after it was read: "describing pictures". */
60
+ stage(file: string, stage: string | undefined): void;
61
+ done(file: string, outcome: string, problems?: readonly string[]): void;
62
+ fail(file: string, why: string): void;
63
+ private line;
64
+ private counts;
65
+ /** The row's text: a line of totals, then a line a file. */
66
+ statusText(): string;
67
+ /** Where the files in progress are, for the log and for a cancellation. */
68
+ private standing;
69
+ private tick;
70
+ private emit;
71
+ /**
72
+ * What happened to every file, for the model: read or not, how far, and
73
+ * every page and picture that was left out, with the reason.
74
+ */
75
+ report(): string[];
76
+ /** The error a cancelled call ends with: why, and the whole report. */
77
+ cancellation(extra?: readonly string[]): Error;
78
+ close(): void;
79
+ }
@@ -0,0 +1,88 @@
1
+ /**
2
+ * The Library's tools: what the model sees of it.
3
+ *
4
+ * `search_library` finds passages in the books the user has collected and
5
+ * `list_library` says what is there, shelf by shelf. Both are offered
6
+ * whenever the Library is on. Everything that changes the Library is the
7
+ * librarian's (`librarian-tools.ts`), and offered only with that skill.
8
+ *
9
+ * They work on keywords alone; an embedding model and a reranker, when the
10
+ * user has configured them, make the search better and change nothing else.
11
+ */
12
+ import { type AgentTool, type LibrarySettings } from "@cerebriline/shared";
13
+ import type { Catalogue, LibraryBook, LibraryShelf } from "../../services/retrieval/catalogue";
14
+ import type { RetrievalEndpoint } from "../../services/retrieval/embedding-client";
15
+ import type { ScrapeEndpoint } from "../../services/retrieval/firecrawl";
16
+ import { type Library } from "../../services/retrieval/library";
17
+ import type { RetrieveResult } from "../../services/retrieval/retrieve";
18
+ import type { DocumentReaderSettings } from "./executors/document/ocr";
19
+ import type { DescribeImages } from "./executors/document/recognition";
20
+ export declare const LIBRARY_TOOL_NAMES: readonly ["search_library", "list_library"];
21
+ export type LibraryToolName = (typeof LIBRARY_TOOL_NAMES)[number];
22
+ /** The built-in skill that brings the librarian's tools with it. */
23
+ export declare const LIBRARIAN_SKILL_NAME = "librarian";
24
+ export interface LibraryScrapeConfig extends ScrapeEndpoint {
25
+ /** Pages one crawl reads, at most. */
26
+ maxPages: number;
27
+ /** How many links deep a crawl follows. */
28
+ maxDepth: number;
29
+ }
30
+ export interface LibraryToolsConfig {
31
+ settings: LibrarySettings;
32
+ /** The embedding model, when the user has set one. */
33
+ embedding?: RetrievalEndpoint;
34
+ /** The reranking model, when the user has set one. */
35
+ reranker?: RetrievalEndpoint;
36
+ documentReader?: DocumentReaderSettings;
37
+ /**
38
+ * The scraping endpoint, when it is set up under Features and the
39
+ * session's profile allows it. Without it the librarian has no web tools.
40
+ */
41
+ scrape?: LibraryScrapeConfig;
42
+ }
43
+ export interface CreateLibraryToolsOptions {
44
+ cwd: string;
45
+ /**
46
+ * Read on every call: the settings can change mid-session. Undefined, or
47
+ * settings with `enabled` off, means the Library is off.
48
+ */
49
+ getConfig: () => LibraryToolsConfig | undefined;
50
+ /** @default the shared Library of the data folder */
51
+ library?: Library;
52
+ /**
53
+ * The model that describes a book's pictures, read when a book is added.
54
+ * May take a moment: a host can ask a server whether a model reads images.
55
+ */
56
+ getDescribeImages?: () => DescribeImages | undefined | Promise<DescribeImages | undefined>;
57
+ /** Whether the librarian's tools are offered. @default the librarian skill is on */
58
+ librarian?: boolean;
59
+ onError?: (message: string, error: unknown) => void;
60
+ log?: (message: string) => void;
61
+ }
62
+ export declare const LIBRARY_OFF = "The Library is turned off. The user turns it on under Settings > Library; do not call this again in this task.";
63
+ export declare function errorText(error: unknown): string;
64
+ export declare function strings(value: unknown): string[];
65
+ export declare function text(value: unknown): string;
66
+ export declare function activeConfig(options: CreateLibraryToolsOptions): LibraryToolsConfig | undefined;
67
+ export declare function plural(count: number, one: string, many?: string): string;
68
+ /** What is on the shelves, as the model is shown it. */
69
+ export declare function describeShelves(catalogue: Catalogue): string;
70
+ /**
71
+ * A shelf as the model names it: "Section / Shelf", or the shelf's name
72
+ * alone when only one shelf has it.
73
+ */
74
+ export declare function resolveShelf(catalogue: Catalogue, reference: string, section?: string): (LibraryShelf & {
75
+ section: string;
76
+ }) | undefined;
77
+ export declare function describeBookLine(book: LibraryBook): string;
78
+ export declare function describeSearch(query: string, result: RetrieveResult, collectionName: (id: number) => string): string;
79
+ /** One book in full: what it is, what it was made from, its pictures. */
80
+ export declare function describeBook(catalogue: Catalogue, book: LibraryBook): string;
81
+ /** Whether the user has the librarian skill turned on. */
82
+ export declare function isLibrarianEnabled(): boolean;
83
+ /**
84
+ * The Library's tools, when the Library is on at session start. Whether it
85
+ * is on is read again on every call, so turning it off mid-session stops the
86
+ * tools answering without a restart.
87
+ */
88
+ export declare function createLibraryTools(options: CreateLibraryToolsOptions): AgentTool[];
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Memory's tools: `remember`, `recall` and `forget`.
3
+ *
4
+ * What the model keeps from one task to the next. The store works on
5
+ * keywords alone; the embedding and reranking models of the Embedding tab,
6
+ * when set, make a recall find a note by what it means.
7
+ *
8
+ * Which memories a session uses is the user's choice per workspace, made in
9
+ * the Memory panel: one memory new notes are kept in, and the memories that
10
+ * are searched. The tools take no memory name: a model cannot store to, or
11
+ * read from, a memory the user did not allow this workspace.
12
+ */
13
+ import { type AgentTool, type MemorySettings } from "@cerebriline/shared";
14
+ import { type Memory, type MemoryEndpoints } from "../../services/retrieval/memory";
15
+ export declare const MEMORY_TOOL_NAMES: readonly ["remember", "recall", "forget"];
16
+ export type MemoryToolName = (typeof MEMORY_TOOL_NAMES)[number];
17
+ export interface MemoryToolsConfig extends MemoryEndpoints {
18
+ settings: MemorySettings;
19
+ }
20
+ export interface CreateMemoryToolsOptions {
21
+ /** The workspace, which is what the user's choice of memories is filed under. */
22
+ cwd: string;
23
+ /** Read on every call. Undefined, or `enabled` off, means Memory is off. */
24
+ getConfig: () => MemoryToolsConfig | undefined;
25
+ /** @default the shared Memory of the data folder */
26
+ memory?: Memory;
27
+ onError?: (message: string, error: unknown) => void;
28
+ log?: (message: string) => void;
29
+ }
30
+ /**
31
+ * The memories this workspace uses, held to the ones that exist: a memory
32
+ * deleted after it was picked is left out of the search, and notes go to
33
+ * the main memory rather than nowhere.
34
+ */
35
+ export declare function resolveMemoryAccess(memory: Memory, settings: MemorySettings, cwd: string): {
36
+ store: string;
37
+ recall: string[];
38
+ storeFellBack?: string;
39
+ };
40
+ /** Memory's tools, when Memory is on at session start. */
41
+ export declare function createMemoryTools(options: CreateMemoryToolsOptions): AgentTool[];