continue-custom/core/protocol/core.ts
2024-05-27 20:09:07 -07:00

138 lines
3.5 KiB
TypeScript

import {
BrowserSerializedContinueConfig,
ChatMessage,
ContextItemWithId,
ContextSubmenuItem,
DiffLine,
LLMFullCompletionOptions,
MessageContent,
ModelDescription,
PersistedSessionInfo,
RangeInFile,
SerializedContinueConfig,
SessionInfo,
} from "..";
import { AutocompleteInput } from "../autocomplete/completionProvider";
import { IdeSettings } from "./ideWebview";
export type ProtocolGeneratorType<T> = AsyncGenerator<{
done?: boolean;
content: T;
}>;
export interface ListHistoryOptions {
offset?: number;
limit?: number;
}
export type ToCoreFromIdeOrWebviewProtocol = {
// New
"update/modelChange": [string, void];
// Special
ping: [string, string];
abort: [undefined, void];
// History
"history/list": [ListHistoryOptions, SessionInfo[]];
"history/delete": [{ id: string }, void];
"history/load": [{ id: string }, PersistedSessionInfo];
"history/save": [PersistedSessionInfo, void];
"devdata/log": [{ tableName: string; data: any }, void];
"config/addOpenAiKey": [string, void];
"config/addModel": [
{ model: SerializedContinueConfig["models"][number] },
void,
];
"config/ideSettingsUpdate": [IdeSettings, void];
"config/getBrowserSerialized": [undefined, BrowserSerializedContinueConfig];
"config/deleteModel": [{ title: string }, void];
"config/reload": [undefined, BrowserSerializedContinueConfig];
"context/getContextItems": [
{
name: string;
query: string;
fullInput: string;
selectedCode: RangeInFile[];
},
ContextItemWithId[],
];
"context/loadSubmenuItems": [{ title: string }, ContextSubmenuItem[]];
"context/addDocs": [{ title: string; url: string }, void];
"autocomplete/complete": [AutocompleteInput, string[]];
"autocomplete/cancel": [undefined, void];
"autocomplete/accept": [{ completionId: string }, void];
"command/run": [
{
input: string;
history: ChatMessage[];
modelTitle: string;
slashCommandName: string;
contextItems: ContextItemWithId[];
params: any;
historyIndex: number;
selectedCode: RangeInFile[];
},
ProtocolGeneratorType<string>,
];
"llm/complete": [
{
prompt: string;
completionOptions: LLMFullCompletionOptions;
title: string;
},
string,
];
"llm/listModels": [{ title: string }, string[] | undefined];
"llm/streamComplete": [
{
prompt: string;
completionOptions: LLMFullCompletionOptions;
title: string;
},
ProtocolGeneratorType<string>,
];
"llm/streamChat": [
{
messages: ChatMessage[];
completionOptions: LLMFullCompletionOptions;
title: string;
},
ProtocolGeneratorType<MessageContent>,
];
streamDiffLines: [
{
prefix: string;
highlighted: string;
suffix: string;
input: string;
language: string | undefined;
modelTitle: string | undefined;
},
ProtocolGeneratorType<DiffLine>,
];
"stats/getTokensPerDay": [
undefined,
{ day: string; promptTokens: number; generatedTokens: number }[],
];
"stats/getTokensPerModel": [
undefined,
{ model: string; promptTokens: number; generatedTokens: number }[],
];
"index/setPaused": [boolean, void];
"index/forceReIndex": [undefined | string, void];
completeOnboarding: [
{
mode:
| "local"
| "apiKeys"
| "custom"
| "freeTrial"
| "localExistingUser"
| "optimizedExistingUser"
| "localAfterFreeTrial";
},
void,
];
addAutocompleteModel: [{ model: ModelDescription }, void];
};