@cerebriline/core 4.100.243 → 4.100.245

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.
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Search of a workspace's code by meaning, as `search_codebase` uses it.
3
+ *
4
+ * The index is the user's choice per folder (Settings > Library): building it
5
+ * sends every source file in the folder to the embedding model. Where the
6
+ * folder is opted in and an embedding model is set, this is the executor a
7
+ * host hands to the tools; the index is brought up to date in the background,
8
+ * and a search made before that is done says so instead of waiting.
9
+ */
10
+ import { type LibrarySettings } from "@cerebriline/shared";
11
+ import { type CodeIndex, type CodeSearchResult } from "../../services/retrieval/code-index";
12
+ import type { RetrievalEndpoint } from "../../services/retrieval/embedding-client";
13
+ import type { SemanticSearchExecutor } from "./types";
14
+ export interface CodeSearchConfig {
15
+ settings: LibrarySettings;
16
+ /** The embedding model, when the user has set one. */
17
+ embedding?: RetrievalEndpoint;
18
+ /** The reranking model, when the user has set one. */
19
+ reranker?: RetrievalEndpoint;
20
+ }
21
+ export interface CodeIndexProgress {
22
+ /** What the refresh is doing now. */
23
+ phase: "reading" | "embedding";
24
+ done: number;
25
+ total: number;
26
+ }
27
+ export interface CodeIndexRefreshState {
28
+ running: boolean;
29
+ progress?: CodeIndexProgress;
30
+ /** Why the last refresh stopped short, when it did. */
31
+ problem?: string;
32
+ /** When the last refresh finished, in epoch milliseconds. */
33
+ finishedAt?: number;
34
+ }
35
+ export interface CreateCodeSearchOptions {
36
+ /** Read on every call: the settings can change mid-session. */
37
+ getConfig: () => CodeSearchConfig;
38
+ /** @default the shared code index of the data folder */
39
+ index?: CodeIndex;
40
+ log?: (message: string) => void;
41
+ }
42
+ export interface CodeSearch extends SemanticSearchExecutor {
43
+ /**
44
+ * Bring a folder's index up to date: read what changed, then embed what has
45
+ * no vectors. One at a time per folder; a second call joins the first.
46
+ * Resolves when it is done and never rejects: the state says what happened.
47
+ */
48
+ refresh(root: string): Promise<void>;
49
+ state(root: string): CodeIndexRefreshState;
50
+ }
51
+ /** Whether a folder is searched by meaning: opted in, with a model to embed with. */
52
+ export declare function codeSearchAvailable(config: CodeSearchConfig, root: string): boolean;
53
+ /** The hits as the model reads them: where each passage is, then the passage. */
54
+ export declare function formatCodeHits(result: CodeSearchResult): string;
55
+ export declare function createCodeSearch(options: CreateCodeSearchOptions): CodeSearch;
@@ -6,7 +6,7 @@
6
6
  import { type AgentTool, type ShellKind } from "@cerebriline/shared";
7
7
  import { type QaCredential } from "./qa-credentials";
8
8
  import { type ApplyPatchInput, type AskQuestionInput, type AwkToolInput, type EditFileInput, type ExtractDocumentInput, type FetchWebContentInput, type GrepToolInput, type ReadFileRequest, type ReadFilesInput, type SearchCodebaseInput, type SedToolInput, type SkillsInput, type SubmitInput } from "./schemas";
9
- import type { ApplyPatchExecutor, AskQuestionExecutor, AwkExecutor, CreateDefaultToolsOptions, DefaultToolsConfig, EditorExecutor, ExtractDocumentExecutor, FileReadExecutor, GrepExecutor, SearchExecutor, SedExecutor, ShellExecutor, SkillsExecutorWithMetadata, ToolOperationResult, VerifySubmitExecutor, WebFetchExecutor } from "./types";
9
+ import type { ApplyPatchExecutor, AskQuestionExecutor, AwkExecutor, CreateDefaultToolsOptions, DefaultToolsConfig, EditorExecutor, ExtractDocumentExecutor, FileReadExecutor, GrepExecutor, SearchExecutor, SedExecutor, SemanticSearchExecutor, ShellExecutor, SkillsExecutorWithMetadata, ToolOperationResult, VerifySubmitExecutor, WebFetchExecutor } from "./types";
10
10
  /**
11
11
  * What a successful read with no content is told to mean.
12
12
  *
@@ -41,7 +41,7 @@ export declare function createReadFilesTool(executor: FileReadExecutor, config?:
41
41
  *
42
42
  * Performs regex pattern searches across the codebase.
43
43
  */
44
- export declare function createSearchTool(executor: SearchExecutor, config?: Pick<DefaultToolsConfig, "cwd" | "searchTimeoutMs">): AgentTool<SearchCodebaseInput, ToolOperationResult[]>;
44
+ export declare function createSearchTool(executor: SearchExecutor, config?: Pick<DefaultToolsConfig, "cwd" | "searchTimeoutMs">, semantic?: SemanticSearchExecutor["search"]): AgentTool<SearchCodebaseInput, ToolOperationResult[]>;
45
45
  /**
46
46
  * Build the run_commands tool description for the shell that will actually
47
47
  * execute the commands. The shell kind decides the syntax guidance (quoting,
@@ -16,7 +16,7 @@ export { type BuiltinToolAvailabilityContext, getCoreAcpToolNames, getCoreBuilti
16
16
  export { type ApplyPatchInput, ApplyPatchInputSchema, type AskQuestionInput, AskQuestionInputSchema, AwkInputSchema, type AwkToolInput, type EditFileInput, EditFileInputSchema, type ExtractDocumentInput, ExtractDocumentInputSchema, type FetchWebContentInput, FetchWebContentInputSchema, GrepInputSchema, type GrepToolInput, type ReadFileRequest, ReadFileRequestSchema, type ReadFilesInput, ReadFilesInputSchema, type RunCommandsInput, RunCommandsInputSchema, type SearchCodebaseInput, SearchCodebaseInputSchema, SedInputSchema, type SedToolInput, type SkillsInput, SkillsInputSchema, type StructuredCommandInput, StructuredCommandInputSchema, type SubmitInput, SubmitInputSchema, type WebFetchRequest, WebFetchRequestSchema, } from "./schemas";
17
17
  export { buildTaskProgressReminder, buildTaskProgressState, DEFAULT_TASK_PROGRESS_REMINDER_INTERVAL, parseTaskProgress, readTaskProgress, TASK_PROGRESS_PARAM, TASK_PROGRESS_PARAM_DESCRIPTION, type TaskProgressItem, type TaskProgressState, TaskProgressTracker, type TaskProgressTrackerOptions, withTaskProgressCapture, withTaskProgressParam, } from "./task-progress";
18
18
  export { TEAM_TOOL_NAMES } from "./team/team-tools";
19
- export type { ApplyPatchExecutor, AskQuestionExecutor, AwkExecutor, CreateDefaultToolsOptions, DefaultToolName, DefaultToolsConfig, EditorExecutor, FileReadExecutor, GrepExecutor, SearchExecutor, SedExecutor, ShellExecutionOptions, ShellExecutor, SkillsExecutor, SkillsExecutorSkillMetadata, SkillsExecutorWithMetadata, ToolExecutors, ToolOperationResult, VerifySubmitExecutor, WebFetchExecutor, } from "./types";
19
+ export type { ApplyPatchExecutor, AskQuestionExecutor, AwkExecutor, CreateDefaultToolsOptions, DefaultToolName, DefaultToolsConfig, EditorExecutor, FileReadExecutor, GrepExecutor, SearchExecutor, SedExecutor, SemanticSearchExecutor, ShellExecutionOptions, ShellExecutor, SkillsExecutor, SkillsExecutorSkillMetadata, SkillsExecutorWithMetadata, ToolExecutors, ToolOperationResult, VerifySubmitExecutor, WebFetchExecutor, } from "./types";
20
20
  import { type AgentTool } from "@cerebriline/shared";
21
21
  import { type DefaultExecutorsOptions } from "./executors/index";
22
22
  import type { CreateDefaultToolsOptions, ToolExecutors } from "./types";
@@ -51,6 +51,19 @@ export interface SearchQueryOptions {
51
51
  maxPerFile?: number;
52
52
  }
53
53
  export type SearchExecutor = (query: string, cwd: string, context: AgentToolContext, options?: SearchQueryOptions) => Promise<string>;
54
+ /**
55
+ * Search of the workspace's code by meaning, for `search_codebase`'s
56
+ * `mode: "semantic"`. A host supplies it only where the workspace is indexed:
57
+ * its presence is what adds the mode to the tool.
58
+ */
59
+ export interface SemanticSearchExecutor {
60
+ /**
61
+ * Asked once, when a session's tools are built: whether this folder is
62
+ * indexed. One host serves many workspaces, so the answer is per folder.
63
+ */
64
+ available(cwd: string): boolean;
65
+ search(query: string, cwd: string, context: AgentToolContext): Promise<string>;
66
+ }
54
67
  /**
55
68
  * Per-call execution options for a shell executor.
56
69
  */
@@ -209,6 +222,8 @@ export interface ToolExecutors {
209
222
  readFile?: FileReadExecutor;
210
223
  /** Codebase search implementation */
211
224
  search?: SearchExecutor;
225
+ /** Code search by meaning; adds `mode: "semantic"` to search_codebase */
226
+ semanticSearch?: SemanticSearchExecutor;
212
227
  /** Shell command execution implementation */
213
228
  bash?: ShellExecutor;
214
229
  /** Web content fetching implementation */