fix: handle ambiguous prompt transport failures
This commit is contained in:
@@ -2,8 +2,21 @@ export const createOpenCodeNetworkRuntime = (deps) => {
|
||||
const {
|
||||
state,
|
||||
getOpenCodeAuthHeaders,
|
||||
configuredOpenCodeHostname = '127.0.0.1',
|
||||
} = deps;
|
||||
|
||||
const resolveConnectHostname = () => {
|
||||
const raw = typeof configuredOpenCodeHostname === 'string' ? configuredOpenCodeHostname.trim() : '';
|
||||
const hostname = raw || '127.0.0.1';
|
||||
if (hostname === '0.0.0.0' || hostname === '::' || hostname === '[::]') {
|
||||
return '127.0.0.1';
|
||||
}
|
||||
if (hostname.startsWith('[') && hostname.endsWith(']')) {
|
||||
return hostname;
|
||||
}
|
||||
return hostname.includes(':') ? `[${hostname}]` : hostname;
|
||||
};
|
||||
|
||||
const normalizeApiPrefix = (prefix) => {
|
||||
if (!prefix) {
|
||||
return '';
|
||||
@@ -77,7 +90,7 @@ export const createOpenCodeNetworkRuntime = (deps) => {
|
||||
const normalizedPath = path.startsWith('/') ? path : `/${path}`;
|
||||
const prefix = normalizeApiPrefix(prefixOverride !== undefined ? prefixOverride : '');
|
||||
const fullPath = `${prefix}${normalizedPath}`;
|
||||
const base = state.openCodeBaseUrl ?? `http://localhost:${state.openCodePort}`;
|
||||
const base = state.openCodeBaseUrl ?? `http://${resolveConnectHostname()}:${state.openCodePort}`;
|
||||
return `${base}${fullPath}`;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user