mirror of
https://github.com/Kaelio/ktx.git
synced 2026-07-04 10:52:13 +02:00
* docs: revise claude-code ingest backend spec * docs: keep claude-code spec focused on ingest * docs: expand claude-code spec to full llm parity * Refine claude-code backend spec after adversarial review iteration 1 * Refine claude-code backend spec after adversarial review iteration 2 * Refine claude-code backend spec after adversarial review iteration 3 * feat: recognize claude-code llm backend * feat: add ktx llm runtime port * feat: add claude-code llm runtime * feat: route non-agent llm calls through runtime * feat: run ingest agents through llm runtime * feat: support claude-code setup and status * test: verify claude-code backend runtime * docs: add claude-code backend v1 runtime plan * fix: close claude-code runtime isolation checks * fix: warn on claude-code prompt caching during setup * chore: verify claude-code v1 closure * docs: add claude-code backend v1 isolation closure plan * fix: update claude-code ingest setup guidance * docs: add claude-code backend v1 ingest guidance closure plan * docs: align claude-code isolation spec with sdk metadata * test: cover claude-code host discovery metadata * fix: tolerate claude-code host discovery metadata * docs: clarify claude-code host discovery metadata * docs: add claude-code auth-probe isolation fix plan * chore: prepare kaelio ktx rc1 release * chore: add semantic release workflow * fix: unblock ci checks * chore(release): 0.1.0-rc.1 * feat: add Claude Code model selection to setup * fix: keep git maintenance attached in local repos
77 lines
2.4 KiB
TypeScript
77 lines
2.4 KiB
TypeScript
import { wrapLanguageModel as defaultWrapLanguageModel } from 'ai';
|
|
import { describe, expect, it, vi } from 'vitest';
|
|
import { runKtxLlmHealthCheck } from './model-health.js';
|
|
|
|
const anthropicModel = { modelId: 'claude-sonnet-4-6' } as never;
|
|
|
|
describe('KTX LLM health check', () => {
|
|
it('runs a minimal non-streaming model call through the configured provider', async () => {
|
|
const generateText = vi.fn(async () => ({ text: 'ok' }));
|
|
const createAnthropic = vi.fn(() => vi.fn(() => anthropicModel));
|
|
const wrapLanguageModel = vi.fn(defaultWrapLanguageModel);
|
|
|
|
await expect(
|
|
runKtxLlmHealthCheck(
|
|
{
|
|
backend: 'anthropic',
|
|
anthropic: { apiKey: 'sk-ant-test' }, // pragma: allowlist secret
|
|
modelSlots: { default: 'claude-sonnet-4-6' },
|
|
},
|
|
{ deps: { createAnthropic, generateText, devtoolsEnabled: true, wrapLanguageModel } },
|
|
),
|
|
).resolves.toEqual({ ok: true });
|
|
|
|
expect(createAnthropic).toHaveBeenCalledWith(
|
|
expect.objectContaining({
|
|
apiKey: 'sk-ant-test', // pragma: allowlist secret
|
|
}),
|
|
);
|
|
expect(generateText).toHaveBeenCalledWith(
|
|
expect.objectContaining({
|
|
model: anthropicModel,
|
|
prompt: 'Reply with exactly: ok',
|
|
temperature: 0,
|
|
maxOutputTokens: 8,
|
|
}),
|
|
);
|
|
expect(wrapLanguageModel).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it('returns a failed result without exposing secret values', async () => {
|
|
const generateText = vi.fn(async () => {
|
|
throw new Error('401 invalid x-api-key sk-ant-secret');
|
|
});
|
|
|
|
await expect(
|
|
runKtxLlmHealthCheck(
|
|
{
|
|
backend: 'anthropic',
|
|
anthropic: { apiKey: 'sk-ant-secret' }, // pragma: allowlist secret
|
|
modelSlots: { default: 'claude-sonnet-4-6' },
|
|
},
|
|
{
|
|
deps: {
|
|
createAnthropic: vi.fn(() => vi.fn(() => anthropicModel)),
|
|
generateText,
|
|
},
|
|
},
|
|
),
|
|
).resolves.toEqual({
|
|
ok: false,
|
|
message: '401 invalid x-api-key [redacted]',
|
|
});
|
|
});
|
|
|
|
it('reports claude-code as unsupported by the AI SDK health check', async () => {
|
|
const result = await runKtxLlmHealthCheck({
|
|
backend: 'claude-code',
|
|
modelSlots: { default: 'sonnet' },
|
|
promptCaching: { enabled: false },
|
|
});
|
|
|
|
expect(result).toEqual({
|
|
ok: false,
|
|
message: expect.stringContaining('claude-code is not an AI SDK LanguageModel backend'),
|
|
});
|
|
});
|
|
});
|