continue-custom/core/protocol/core.ts
Jazzcort 1611bae1fb Forbid file mentioning for large files
When the context items provided by user overflow the context length
and are truncated, it is very confusing for the user. This is a
first step that catches an common case at the least confusing
time - when the user is selecting a file. A more general check that
warns whenever the most recent message is truncated is something
that can be added later.
Granite-Code/granite-code#22
2025-04-07 17:06:52 -04:00

203 lines
5.7 KiB
TypeScript

import {
ConfigResult,
DevDataLogEvent,
ModelRole,
} from "@continuedev/config-yaml";
import { AutocompleteInput } from "../autocomplete/util/types";
import { SharedConfigSchema } from "../config/sharedConfig";
import { GlobalContextModelSelections } from "../util/GlobalContext";
import type {
BrowserSerializedContinueConfig,
ChatMessage,
ContextItem,
ContextItemWithId,
ContextSubmenuItem,
DiffLine,
DocsIndexingDetails,
ExperimentalModelRoles,
FileSymbolMap,
IdeSettings,
LLMFullCompletionOptions,
ModelDescription,
PromptLog,
RangeInFile,
SerializedContinueConfig,
Session,
SessionMetadata,
SiteIndexingConfig,
SlashCommandDescription,
ToolCall,
} from "../";
import { SerializedOrgWithProfiles } from "../config/ProfileLifecycleManager";
export type OnboardingModes = "Local" | "Best" | "Custom" | "Quickstart";
export interface ListHistoryOptions {
offset?: number;
limit?: number;
}
export type ToCoreFromIdeOrWebviewProtocol = {
// Special
ping: [string, string];
abort: [undefined, void];
// History
"history/list": [ListHistoryOptions, SessionMetadata[]];
"history/delete": [{ id: string }, void];
"history/load": [{ id: string }, Session];
"history/save": [Session, void];
"devdata/log": [DevDataLogEvent, void];
"config/addOpenAiKey": [string, void];
"config/addModel": [
{
model: SerializedContinueConfig["models"][number];
role?: keyof ExperimentalModelRoles;
},
void,
];
"config/newPromptFile": [undefined, void];
"config/ideSettingsUpdate": [IdeSettings, void];
"config/getSerializedProfileInfo": [
undefined,
{
result: ConfigResult<BrowserSerializedContinueConfig>;
profileId: string | null;
organizations: SerializedOrgWithProfiles[];
selectedOrgId: string;
usingContinueForTeams: boolean;
},
];
"config/deleteModel": [{ title: string }, void];
"config/reload": [undefined, ConfigResult<BrowserSerializedContinueConfig>];
"config/refreshProfiles": [undefined, void];
"config/openProfile": [{ profileId: string | undefined }, void];
"config/updateSharedConfig": [SharedConfigSchema, SharedConfigSchema];
"config/updateSelectedModel": [
{
profileId: string;
role: ModelRole;
title: string | null;
},
GlobalContextModelSelections,
];
"context/getContextItems": [
{
name: string;
query: string;
fullInput: string;
selectedCode: RangeInFile[];
selectedModelTitle: string;
},
ContextItemWithId[],
];
"mcp/reloadServer": [
{
id: string;
},
void,
];
"context/getSymbolsForFiles": [{ uris: string[] }, FileSymbolMap];
"context/loadSubmenuItems": [{ title: string }, ContextSubmenuItem[]];
"autocomplete/complete": [AutocompleteInput, string[]];
"context/addDocs": [SiteIndexingConfig, void];
"context/removeDocs": [Pick<SiteIndexingConfig, "startUrl">, void];
"context/indexDocs": [{ reIndex: boolean }, void];
"autocomplete/cancel": [undefined, void];
"autocomplete/accept": [{ completionId: string }, void];
"llm/complete": [
{
prompt: string;
completionOptions: LLMFullCompletionOptions;
title: string;
},
string,
];
"llm/listModels": [{ title: string }, string[] | undefined];
"llm/streamChat": [
{
messages: ChatMessage[];
completionOptions: LLMFullCompletionOptions;
title: string;
legacySlashCommandData?: {
command: SlashCommandDescription;
input: string;
contextItems: ContextItemWithId[];
historyIndex: number;
selectedCode: RangeInFile[];
};
},
AsyncGenerator<ChatMessage, PromptLog>,
];
streamDiffLines: [
{
prefix: string;
highlighted: string;
suffix: string;
input: string;
language: string | undefined;
modelTitle: string | undefined;
},
AsyncGenerator<DiffLine>,
];
"chatDescriber/describe": [
{
selectedModelTitle: string;
text: string;
},
string | undefined,
];
"stats/getTokensPerDay": [
undefined,
{ day: string; promptTokens: number; generatedTokens: number }[],
];
"stats/getTokensPerModel": [
undefined,
{ model: string; promptTokens: number; generatedTokens: number }[],
];
"tts/kill": [undefined, void];
// Codebase indexing
"index/setPaused": [boolean, void];
"index/forceReIndex": [
undefined | { dirs?: string[]; shouldClearIndexes?: boolean },
void,
];
"index/indexingProgressBarInitialized": [undefined, void];
completeOnboarding: [
{
mode: OnboardingModes;
},
void,
];
// File changes
"files/changed": [{ uris?: string[] }, void];
"files/opened": [{ uris?: string[] }, void];
"files/created": [{ uris?: string[] }, void];
"files/deleted": [{ uris?: string[] }, void];
"files/closed": [{ uris?: string[] }, void];
// Docs etc. Indexing. TODO move codebase to this
"indexing/reindex": [{ type: string; id: string }, void];
"indexing/abort": [{ type: string; id: string }, void];
"indexing/setPaused": [{ type: string; id: string; paused: boolean }, void];
"docs/getSuggestedDocs": [undefined, void];
"docs/initStatuses": [undefined, void];
"docs/getDetails": [{ startUrl: string }, DocsIndexingDetails];
addAutocompleteModel: [{ model: ModelDescription }, void];
"auth/getAuthUrl": [{ useOnboarding: boolean }, { url: string }];
"tools/call": [
{ toolCall: ToolCall; selectedModelTitle: string },
{ contextItems: ContextItem[] },
];
"clipboardCache/add": [{ content: string }, void];
"controlPlane/openUrl": [{ path: string; orgSlug: string | undefined }, void];
isItemTooBig: [
{ item: ContextItemWithId; selectedModelTitle: string | undefined },
boolean,
];
};