mirror of
https://github.com/Kaelio/ktx.git
synced 2026-06-13 08:15:14 +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
43 lines
1.9 KiB
TypeScript
43 lines
1.9 KiB
TypeScript
import { describe, expect, it, vi } from 'vitest';
|
|
import { z } from 'zod';
|
|
import { createAiSdkToolSet, createClaudeSdkTools, normalizeKtxRuntimeToolOutput } from './runtime-tools.js';
|
|
import type { KtxRuntimeToolDescriptor } from './runtime-port.js';
|
|
|
|
describe('runtime tool descriptors', () => {
|
|
const descriptor: KtxRuntimeToolDescriptor<{ id: string }, { ok: boolean }> = {
|
|
name: 'read_thing',
|
|
description: 'Read one thing.',
|
|
inputSchema: z.object({ id: z.string() }),
|
|
execute: vi.fn(async (input) => ({
|
|
markdown: `Read ${input.id}`,
|
|
structured: { ok: true },
|
|
})),
|
|
};
|
|
|
|
it('normalizes string and object tool outputs into markdown plus optional structured payload', () => {
|
|
expect(normalizeKtxRuntimeToolOutput('plain text')).toEqual({ markdown: 'plain text' });
|
|
expect(normalizeKtxRuntimeToolOutput({ markdown: 'shown', structured: { id: 1 } })).toEqual({
|
|
markdown: 'shown',
|
|
structured: { id: 1 },
|
|
});
|
|
expect(normalizeKtxRuntimeToolOutput({ name: 'skill', content: 'body' })).toEqual({
|
|
markdown: '```json\n{\n "name": "skill",\n "content": "body"\n}\n```',
|
|
structured: { name: 'skill', content: 'body' },
|
|
});
|
|
});
|
|
|
|
it('builds AI SDK tools that expose markdown to the model', async () => {
|
|
const tools = createAiSdkToolSet({ read_thing: descriptor });
|
|
const output = await tools.read_thing.execute?.({ id: 'a' }, { toolCallId: 'call-1', messages: [] } as never);
|
|
const modelOutput = tools.read_thing.toModelOutput?.({ output } as never);
|
|
|
|
expect(modelOutput).toEqual({ type: 'text', value: 'Read a' });
|
|
});
|
|
|
|
it('builds Claude SDK tools that return text content only', async () => {
|
|
const tools = createClaudeSdkTools({ read_thing: descriptor });
|
|
const result = await tools[0].handler({ id: 'b' } as never, {});
|
|
|
|
expect(result).toEqual({ content: [{ type: 'text', text: 'Read b' }] });
|
|
});
|
|
});
|