File tree Expand file tree Collapse file tree 2 files changed +12
-10
lines changed
app/api/tools/opencode/prompt Expand file tree Collapse file tree 2 files changed +12
-10
lines changed Original file line number Diff line number Diff line change @@ -18,17 +18,17 @@ import { coerceOpenCodeBoolean } from '@/lib/opencode/utils'
1818
1919const logger = createLogger ( 'OpenCodePromptToolAPI' )
2020
21- const optionalTrimmedStringSchema = z . preprocess (
21+ const optionalNullableStringSchema = z . preprocess (
2222 ( value ) => ( value === null ? undefined : value ) ,
2323 z . string ( ) . optional ( )
2424)
2525
2626const OpenCodePromptSchema = z . object ( {
2727 repository : z . string ( ) . min ( 1 , 'repository is required' ) ,
28- systemPrompt : optionalTrimmedStringSchema ,
28+ systemPrompt : optionalNullableStringSchema ,
2929 providerId : z . string ( ) . min ( 1 , 'providerId is required' ) ,
3030 modelId : z . string ( ) . min ( 1 , 'modelId is required' ) ,
31- agent : optionalTrimmedStringSchema ,
31+ agent : optionalNullableStringSchema ,
3232 prompt : z . string ( ) . min ( 1 , 'prompt is required' ) ,
3333 newThread : z . union ( [ z . boolean ( ) , z . string ( ) ] ) . optional ( ) ,
3434 _context : z
Original file line number Diff line number Diff line change @@ -32,20 +32,22 @@ function getOpenCodeBaseUrl(): string {
3232}
3333
3434function getOpenCodeClientKey ( ) : string {
35- return JSON . stringify ( {
36- baseUrl : getOpenCodeBaseUrl ( ) ,
37- authorization : getOpenCodeBasicAuthHeader ( ) ,
38- } )
35+ const baseUrl = getOpenCodeBaseUrl ( )
36+ const authorization = getOpenCodeBasicAuthHeader ( )
37+
38+ return JSON . stringify ( { baseUrl , authorization } )
3939}
4040
4141export function createOpenCodeClient ( ) {
42- const clientKey = getOpenCodeClientKey ( )
42+ const baseUrl = getOpenCodeBaseUrl ( )
43+ const authorization = getOpenCodeBasicAuthHeader ( )
44+ const clientKey = JSON . stringify ( { baseUrl, authorization } )
4345
4446 if ( ! cachedOpenCodeClient || cachedOpenCodeClientKey !== clientKey ) {
4547 cachedOpenCodeClient = createOpencodeClient ( {
46- baseUrl : JSON . parse ( clientKey ) . baseUrl ,
48+ baseUrl,
4749 headers : {
48- Authorization : JSON . parse ( clientKey ) . authorization ,
50+ Authorization : authorization ,
4951 } ,
5052 } )
5153 cachedOpenCodeClientKey = clientKey
You can’t perform that action at this time.
0 commit comments