|
1 | 1 | import protobuf from 'protobufjs'; |
2 | 2 | import Long from 'long'; |
3 | | -import { type CodiumCompletionResult } from '@srcbook/shared'; |
4 | 3 |
|
5 | 4 | import languageServerProto from './language-server-proto'; |
6 | 5 |
|
@@ -72,3 +71,50 @@ export async function runCodiumAiAutocomplete( |
72 | 71 |
|
73 | 72 | return responseBody.toJSON() as CodiumCompletionResult; |
74 | 73 | } |
| 74 | + |
| 75 | +type CodiumCompletionItem = { |
| 76 | + completion: { |
| 77 | + completionId: string; |
| 78 | + text: string; |
| 79 | + prefix: string; |
| 80 | + stop: string; |
| 81 | + score: number; |
| 82 | + tokens: Array<string>; |
| 83 | + decoded_tokens: Array<string>; |
| 84 | + probabilities: Array<number>; |
| 85 | + adjustedProbabilities: Array<number>; |
| 86 | + generatedLength: string; |
| 87 | + }; |
| 88 | + completionParts: Array<{ |
| 89 | + text: string; |
| 90 | + offset: string; |
| 91 | + prefix: string; |
| 92 | + type: |
| 93 | + | 'COMPLETION_PART_TYPE_UNSPECIFIED' |
| 94 | + // Single-line completion parts that appear within an existing line of text. |
| 95 | + | 'COMPLETION_PART_TYPE_INLINE' |
| 96 | + // Possibly multi-line completion parts that appear below an existing line of text. |
| 97 | + | 'COMPLETION_PART_TYPE_BLOCK' |
| 98 | + // Like COMPLETION_PART_TYPE_INLINE, but overwrites the existing text. |
| 99 | + | 'COMPLETION_PART_TYPE_INLINE_MASK'; |
| 100 | + }>; |
| 101 | + range: { |
| 102 | + endOffset: string; |
| 103 | + endPosition: { row?: string; col?: string }; |
| 104 | + startPosition: { row?: string; col?: string }; |
| 105 | + }; |
| 106 | +}; |
| 107 | + |
| 108 | +type CodiumCompletionResult = { |
| 109 | + completionItems?: Array<CodiumCompletionItem>; |
| 110 | + state: { |
| 111 | + state: |
| 112 | + | 'CODEIUM_STATE_UNSPECIFIED' |
| 113 | + | 'CODEIUM_STATE_INACTIVE' |
| 114 | + | 'CODEIUM_STATE_PROCESSING' |
| 115 | + | 'CODEIUM_STATE_SUCCESS' |
| 116 | + | 'CODEIUM_STATE_WARNING' |
| 117 | + | 'CODEIUM_STATE_ERROR'; |
| 118 | + status: string; |
| 119 | + }; |
| 120 | +}; |
0 commit comments