Skip to content

Commit

Permalink
Build from buf files
Browse files Browse the repository at this point in the history
  • Loading branch information
tmcw committed Mar 25, 2024
1 parent b5e3315 commit 7726462
Show file tree
Hide file tree
Showing 10 changed files with 505 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
uses: bahmutov/npm-install@v1

- name: Build project
run: npm run build
run: npm run pages
- name: Setup Pages
uses: actions/configure-pages@v3
- name: Upload artifact
Expand Down
14 changes: 14 additions & 0 deletions buf.gen.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# buf.gen.yaml defines a local generation template.
# For details, see https://docs.buf.build/configuration/v1/buf-gen-yaml
version: v1
plugins:
- plugin: buf.build/bufbuild/es:v1.4.2
out: src/api/proto
opt:
- target=ts
- import_extension=none
- plugin: buf.build/connectrpc/es:v1.1.3
out: src/api/proto
opt:
- target=ts
- import_extension=none
8 changes: 8 additions & 0 deletions buf.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Generated by buf. DO NOT EDIT.
version: v1
deps:
- remote: buf.build
owner: envoyproxy
repository: protoc-gen-validate
commit: 71881f09a0c5420a9545a07987a86728
digest: shake256:d320bbf06653b1b2b45a1f95bfa82bf7b998221a777a042708c50d6f86a30d1a85b50c5704c597142d9b308280efe1295d39d76d1abea5f7046d3df4c8cc3cef
15 changes: 15 additions & 0 deletions buf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: v1
deps:
- buf.build/envoyproxy/protoc-gen-validate
build:
excludes:
- node_modules
lint:
use:
- DEFAULT
except:
- PACKAGE_VERSION_SUFFIX
allow_comment_ignores: true
breaking:
except:
- FILE_NO_DELETE
166 changes: 166 additions & 0 deletions exa/codeium_common_pb/codeium_common.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
// Copyright Exafunction, Inc.

syntax = "proto3";

package exa.codeium_common_pb;

import "google/protobuf/duration.proto";
import "google/protobuf/timestamp.proto";
import "validate/validate.proto";

option go_package = "github.com/Exafunction/Exafunction/exa/codeium_common_pb";

enum ExperimentKey {
UNSPECIFIED = 0;
JUPYTER_FORMAT = 77;
}

// Next ID: 12, Previous field: entropy.
message Completion {
string completion_id = 1;
string text = 2;
string prefix = 3;
string stop = 4;
double score = 5;
repeated uint64 tokens = 6;
repeated string decoded_tokens = 7;
repeated double probabilities = 8;
repeated double adjusted_probabilities = 9;
uint64 generated_length = 10;
}

// Authentication source for users on the cloud service.
enum AuthSource {
AUTH_SOURCE_CODEIUM = 0;
}

// Next ID: 15, Previous field: url.
message Metadata {
string ide_name = 1 [(validate.rules).string.min_len = 1];
string ide_version = 7 [(validate.rules).string.min_len = 1];
string extension_name = 12;
string extension_version = 2 [(validate.rules).string.min_len = 1];
string api_key = 3 [(validate.rules).string.uuid = true];
// Regex derived from https://stackoverflow.com/a/48300605.
// TODO(prem): Should this be mandatory?
string locale = 4 [(validate.rules).string = {
ignore_empty: true,
pattern: "^[A-Za-z]{2,4}([_-][A-Za-z]{4})?([_-]([A-Za-z]{2}|[0-9]{3}))?$"
}];
// UID identifying a single session for the given user.
string session_id = 10;

// Used purely in language server to cancel in flight requests.
// If request_id is 0, then the request is not cancelable.
// This should be a strictly monotonically increasing number
// for the duration of a session.
uint64 request_id = 9;

// Browser-specific information.
string user_agent = 13;
string url = 14 [(validate.rules).string = {
ignore_empty: true,
uri: true
}];

// Authentication source information.
AuthSource auth_source = 15;
}

// Next ID: 3, Previous field: insert_spaces.
message EditorOptions {
uint64 tab_size = 1 [(validate.rules).uint64.gt = 0];
bool insert_spaces = 2;
}

message Event {
EventType event_type = 1;
string event_json = 2;
int64 timestamp_unix_ms = 3;
}

enum EventType {
EVENT_TYPE_UNSPECIFIED = 0;
EVENT_TYPE_ENABLE_CODEIUM = 1;
EVENT_TYPE_DISABLE_CODEIUM = 2;
EVENT_TYPE_SHOW_PREVIOUS_COMPLETION = 3;
EVENT_TYPE_SHOW_NEXT_COMPLETION = 4;
}

enum CompletionSource {
COMPLETION_SOURCE_UNSPECIFIED = 0;
COMPLETION_SOURCE_TYPING_AS_SUGGESTED = 1;
COMPLETION_SOURCE_CACHE = 2;
COMPLETION_SOURCE_NETWORK = 3;
}

// Every time this list is updated, we should be redeploying the API server
// since it uses the string representation for BQ.
enum Language {
LANGUAGE_UNSPECIFIED = 0;
LANGUAGE_C = 1;
LANGUAGE_CLOJURE = 2;
LANGUAGE_COFFEESCRIPT = 3;
LANGUAGE_CPP = 4;
LANGUAGE_CSHARP = 5;
LANGUAGE_CSS = 6;
LANGUAGE_CUDACPP = 7;
LANGUAGE_DOCKERFILE = 8;
LANGUAGE_GO = 9;
LANGUAGE_GROOVY = 10;
LANGUAGE_HANDLEBARS = 11;
LANGUAGE_HASKELL = 12;
LANGUAGE_HCL = 13;
LANGUAGE_HTML = 14;
LANGUAGE_INI = 15;
LANGUAGE_JAVA = 16;
LANGUAGE_JAVASCRIPT = 17;
LANGUAGE_JSON = 18;
LANGUAGE_JULIA = 19;
LANGUAGE_KOTLIN = 20;
LANGUAGE_LATEX = 21;
LANGUAGE_LESS = 22;
LANGUAGE_LUA = 23;
LANGUAGE_MAKEFILE = 24;
LANGUAGE_MARKDOWN = 25;
LANGUAGE_OBJECTIVEC = 26;
LANGUAGE_OBJECTIVECPP = 27;
LANGUAGE_PERL = 28;
LANGUAGE_PHP = 29;
LANGUAGE_PLAINTEXT = 30;
LANGUAGE_PROTOBUF = 31;
LANGUAGE_PBTXT = 32;
LANGUAGE_PYTHON = 33;
LANGUAGE_R = 34;
LANGUAGE_RUBY = 35;
LANGUAGE_RUST = 36;
LANGUAGE_SASS = 37;
LANGUAGE_SCALA = 38;
LANGUAGE_SCSS = 39;
LANGUAGE_SHELL = 40;
LANGUAGE_SQL = 41;
LANGUAGE_STARLARK = 42;
LANGUAGE_SWIFT = 43;
LANGUAGE_TSX = 44;
LANGUAGE_TYPESCRIPT = 45;
LANGUAGE_VISUALBASIC = 46;
LANGUAGE_VUE = 47;
LANGUAGE_XML = 48;
LANGUAGE_XSL = 49;
LANGUAGE_YAML = 50;
LANGUAGE_SVELTE = 51;
LANGUAGE_TOML = 52;
LANGUAGE_DART = 53;
LANGUAGE_RST = 54;
LANGUAGE_OCAML = 55;
LANGUAGE_CMAKE = 56;
LANGUAGE_PASCAL = 57;
LANGUAGE_ELIXIR = 58;
LANGUAGE_FSHARP = 59;
LANGUAGE_LISP = 60;
LANGUAGE_MATLAB = 61;
LANGUAGE_POWERSHELL = 62;
LANGUAGE_SOLIDITY = 63;
LANGUAGE_ADA = 64;
LANGUAGE_OCAML_INTERFACE = 65;
}
169 changes: 169 additions & 0 deletions exa/language_server_pb/language_server.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
// Copyright Exafunction, Inc.

syntax = "proto3";

package exa.language_server_pb;

import "exa/codeium_common_pb/codeium_common.proto";
import "validate/validate.proto";

option go_package = "github.com/Exafunction/Exafunction/exa/language_server_pb";

service LanguageServerService {
rpc GetCompletions(GetCompletionsRequest) returns (GetCompletionsResponse) {}
rpc AcceptCompletion(AcceptCompletionRequest) returns (AcceptCompletionResponse) {}
rpc GetAuthToken(GetAuthTokenRequest) returns (GetAuthTokenResponse) {}
}

message MultilineConfig {
// Multiline model threshold. 0-1, higher = more single line, lower = more multiline,
// 0.0 = only_multiline, default is 0.5
float threshold = 1;
}

// Next ID: 9, Previous field: disable_cache.
message GetCompletionsRequest {
codeium_common_pb.Metadata metadata = 1 [(validate.rules).message.required = true];
Document document = 2 [(validate.rules).message.required = true];
codeium_common_pb.EditorOptions editor_options = 3 [(validate.rules).message.required = true];
repeated Document other_documents = 5;
ExperimentConfig experiment_config = 7;

string model_name = 10;
MultilineConfig multiline_config = 13;
}

// Next ID: 5, Previous field: latency_info.
message GetCompletionsResponse {
State state = 1;
repeated CompletionItem completion_items = 2;
}

// Next ID: 3, Previous field: completion_id.
message AcceptCompletionRequest {
codeium_common_pb.Metadata metadata = 1 [(validate.rules).message.required = true];
string completion_id = 2;
}

// Next ID: 1, Previous field: N/A.
message AcceptCompletionResponse {}

// Next ID: 1, Previous field: N/A.
message GetAuthTokenRequest {}

// Next ID: 3, Previous field: uuid.
message GetAuthTokenResponse {
string auth_token = 1;
string uuid = 2;
}

/*****************************************************************************/
/* Helper Messages */
/*****************************************************************************/

message DocumentPosition {
// 0-indexed. Measured in UTF-8 bytes.
uint64 row = 1;
// 0-indexed. Measured in UTF-8 bytes.
uint64 col = 2;
}

// Next ID: 9, Previous field: cursor_position.
message Document {
string absolute_path = 1;
// Path relative to the root of the workspace.
string relative_path = 2;
string text = 3;
// Language ID provided by the editor.
string editor_language = 4 [(validate.rules).string.min_len = 1];
// Language enum standardized across editors.
codeium_common_pb.Language language = 5;
// Measured in number of UTF-8 bytes.
uint64 cursor_offset = 6;
// May be present instead of cursor_offset.
DocumentPosition cursor_position = 8;
// \n or \r\n, if known.
string line_ending = 7 [(validate.rules).string = {
in: [
"",
"\n",
"\r\n"
]
}];
}

message ExperimentConfig {
repeated codeium_common_pb.ExperimentKey force_enable_experiments = 1 [(validate.rules).repeated.unique = true];
}

enum CodeiumState {
CODEIUM_STATE_UNSPECIFIED = 0;
CODEIUM_STATE_INACTIVE = 1;
CODEIUM_STATE_PROCESSING = 2;
CODEIUM_STATE_SUCCESS = 3;
CODEIUM_STATE_WARNING = 4;
CODEIUM_STATE_ERROR = 5;
}

// Next ID: 3, Previous field: message.
message State {
CodeiumState state = 1;
string message = 2;
}

enum LineType {
LINE_TYPE_UNSPECIFIED = 0;
LINE_TYPE_SINGLE = 1;
LINE_TYPE_MULTI = 2;
}

// Next ID: 5, Previous field: end_position.
message Range {
uint64 start_offset = 1;
uint64 end_offset = 2;
DocumentPosition start_position = 3;
DocumentPosition end_position = 4;
}

message Suffix {
// Text to insert after the cursor when accepting the completion.
string text = 1;
// Cursor position delta (as signed offset) from the end of the inserted
// completion (including the suffix).
int64 delta_cursor_offset = 2;
}

enum CompletionPartType {
COMPLETION_PART_TYPE_UNSPECIFIED = 0;
// Single-line completion parts that appear within an existing line of text.
COMPLETION_PART_TYPE_INLINE = 1;
// Possibly multi-line completion parts that appear below an existing line of text.
COMPLETION_PART_TYPE_BLOCK = 2;
// Like COMPLETION_PART_TYPE_INLINE, but overwrites the existing text.
COMPLETION_PART_TYPE_INLINE_MASK = 3;
}

// Represents a contiguous part of the completion text that is not
// already in the document.
// Next ID: 4, Previous field: prefix.
message CompletionPart {
string text = 1;
// Offset in the original document where the part starts. For block
// parts, this is always the end of the line before the block.
uint64 offset = 2;
CompletionPartType type = 3;
// The section of the original line that came before this part. Only valid for
// COMPLETION_PART_TYPE_INLINE.
string prefix = 4;
// In the case of COMPLETION_PART_TYPE_BLOCK, represents the line it is below.
uint64 line = 5;
}

// Next ID: 9, Previous field: completion_parts.
message CompletionItem {
codeium_common_pb.Completion completion = 1;
Suffix suffix = 5;
Range range = 2;
codeium_common_pb.CompletionSource source = 3;
repeated CompletionPart completion_parts = 8;
}
Loading

0 comments on commit 7726462

Please sign in to comment.