Skip to content

Commit 8f47005

Browse files
committed
refactor: consolodate codeium types with the codeium request code
1 parent fe224e6 commit 8f47005

4 files changed

Lines changed: 47 additions & 49 deletions

File tree

packages/shared/index.mts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,5 @@ export * from './src/types/cells.mjs';
77
export * from './src/types/tsserver.mjs';
88
export * from './src/types/websockets.mjs';
99
export * from './src/types/secrets.mjs';
10-
export * from './src/types/ai-autocomplete.mjs';
1110
export * from './src/utils.mjs';
1211
export * from './src/ai.mjs';

packages/shared/src/types/ai-autocomplete.mts

Lines changed: 0 additions & 46 deletions
This file was deleted.

packages/web/src/lib/ai-autocomplete/index.ts

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import protobuf from 'protobufjs';
22
import Long from 'long';
3-
import { type CodiumCompletionResult } from '@srcbook/shared';
43

54
import languageServerProto from './language-server-proto';
65

@@ -72,3 +71,50 @@ export async function runCodiumAiAutocomplete(
7271

7372
return responseBody.toJSON() as CodiumCompletionResult;
7473
}
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+
};

packages/web/src/lib/server.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import type {
44
MarkdownCellType,
55
CodeCellType,
66
SecretWithAssociatedSessions,
7-
CodiumCompletionResult,
87
} from '@srcbook/shared';
98
import { SessionType, ExampleSrcbookType } from '@/types';
109
import SRCBOOK_CONFIG from '@/config';

0 commit comments

Comments
 (0)