* feat(api): classify openai-compatible provider failures * Update src/services/api/providerConfig.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/services/api/errors.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * feat(api): harden openai-compatible diagnostics and env fallback * Update src/services/api/openaiShim.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/services/api/openaiShim.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/services/api/errors.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/services/api/errors.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * fix openaiShim duplicate requests and diagnostics * remove unused url from http failure classifier * dedupe env diagnostic warnings * Remove hardcoded URLs from OpenAI error tests Removed hardcoded URLs from network failure classification tests. * Update providerConfig.envDiagnostics.test.ts * fix(openai-shim): return successful responses and restore localhost classifier tests * Update src/services/api/openaiShim.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/services/api/openaiShim.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/services/api/openaiShim.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * feat(provider): add truthful local generation readiness checks Implement Phase 2 provider readiness behavior by adding structured Ollama generation probes, wiring setup flows to readiness states, extending system-check with generation readiness output, and updating focused tests. * feat(api): add local self-healing fallback retries Implement Phase 3 self-healing behavior for local OpenAI-compatible providers: retry base URL fallbacks for localhost resolution and endpoint mismatches, plus capability-gated toolless retry for tool-incompatible local models; include diagnostics and focused tests. * fix(api): address review blockers for local provider reliability * Update src/utils/providerDiscovery.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/services/api/openaiShim.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * fix: harden readiness probes and cross-platform test stability * fix: refresh toolless retry payload and stabilize osc clipboard test * fix: harden Ollama readiness parsing and redact provider URLs --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
60 lines
1.8 KiB
TypeScript
60 lines
1.8 KiB
TypeScript
import { describe, expect, test } from 'bun:test'
|
|
|
|
import { formatReachabilityFailureDetail } from './system-check.ts'
|
|
|
|
describe('formatReachabilityFailureDetail', () => {
|
|
test('returns generic failure detail for non-codex transport', () => {
|
|
const detail = formatReachabilityFailureDetail(
|
|
'https://api.openai.com/v1/models',
|
|
429,
|
|
'{"error":"rate_limit"}',
|
|
{
|
|
transport: 'chat_completions',
|
|
requestedModel: 'gpt-4o',
|
|
resolvedModel: 'gpt-4o',
|
|
},
|
|
)
|
|
|
|
expect(detail).toBe(
|
|
'Unexpected status 429 from https://api.openai.com/v1/models. Body: {"error":"rate_limit"}',
|
|
)
|
|
})
|
|
|
|
test('redacts credentials and sensitive query parameters in endpoint details', () => {
|
|
const detail = formatReachabilityFailureDetail(
|
|
'http://user:pass@localhost:11434/v1/models?token=abc123&mode=test',
|
|
502,
|
|
'bad gateway',
|
|
{
|
|
transport: 'chat_completions',
|
|
requestedModel: 'llama3.1:8b',
|
|
resolvedModel: 'llama3.1:8b',
|
|
},
|
|
)
|
|
|
|
expect(detail).toBe(
|
|
'Unexpected status 502 from http://redacted:redacted@localhost:11434/v1/models?token=redacted&mode=test. Body: bad gateway',
|
|
)
|
|
})
|
|
|
|
test('adds alias/entitlement hint for codex model support 400s', () => {
|
|
const detail = formatReachabilityFailureDetail(
|
|
'https://chatgpt.com/backend-api/codex/responses',
|
|
400,
|
|
'{"detail":"The \\"gpt-5.3-codex-spark\\" model is not supported when using Codex with a ChatGPT account."}',
|
|
{
|
|
transport: 'codex_responses',
|
|
requestedModel: 'codexspark',
|
|
resolvedModel: 'gpt-5.3-codex-spark',
|
|
},
|
|
)
|
|
|
|
expect(detail).toContain(
|
|
'model alias "codexspark" resolved to "gpt-5.3-codex-spark"',
|
|
)
|
|
expect(detail).toContain(
|
|
'Try "codexplan" or another entitled Codex model.',
|
|
)
|
|
})
|
|
})
|