mirror of
https://github.com/Kaelio/ktx.git
synced 2026-06-25 08:48:08 +02:00
rename klo to ktx
This commit is contained in:
parent
1a42152e6f
commit
3ce510b55b
704 changed files with 10205 additions and 10255 deletions
|
|
@ -1,6 +1,6 @@
|
|||
import { tool } from 'ai';
|
||||
import { z, type ZodType } from 'zod';
|
||||
import { noopLogger, type KloLogger } from '../core/index.js';
|
||||
import { noopLogger, type KtxLogger } from '../core/index.js';
|
||||
import type { IngestToolMetadata, ToolSession } from './tool-session.js';
|
||||
|
||||
export interface ToolOutput<T = unknown> {
|
||||
|
|
@ -72,11 +72,11 @@ export interface MethodologyEntry {
|
|||
* SECURITY: All tools require authentication. userId must always be provided in ToolContext.
|
||||
*/
|
||||
export abstract class BaseTool<TInput extends ZodType = ZodType> {
|
||||
protected readonly logger: KloLogger;
|
||||
protected readonly logger: KtxLogger;
|
||||
|
||||
abstract readonly name: string;
|
||||
|
||||
constructor(logger: KloLogger = noopLogger) {
|
||||
constructor(logger: KtxLogger = noopLogger) {
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { createHash } from 'node:crypto';
|
||||
import { z } from 'zod';
|
||||
import type { KloEmbeddingPort } from '../core/index.js';
|
||||
import type { KtxEmbeddingPort } from '../core/index.js';
|
||||
import { buildContextCandidateEmbeddingText } from '../ingest/context-candidates/index.js';
|
||||
import { BaseTool, type ToolContext, type ToolOutput } from './base-tool.js';
|
||||
import { chunkIdSchema } from './context-evidence-ids.js';
|
||||
|
|
@ -40,7 +40,7 @@ export class ContextCandidateWriteTool extends BaseTool<typeof contextCandidateW
|
|||
|
||||
constructor(
|
||||
private readonly store: ContextEvidenceToolStorePort,
|
||||
private readonly embeddingService: Pick<KloEmbeddingPort, 'computeEmbedding'>,
|
||||
private readonly embeddingService: Pick<KtxEmbeddingPort, 'computeEmbedding'>,
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { z } from 'zod';
|
||||
import type { KloEmbeddingPort } from '../core/index.js';
|
||||
import type { KtxEmbeddingPort } from '../core/index.js';
|
||||
import { BaseTool, type ToolContext, type ToolOutput } from './base-tool.js';
|
||||
import type { ContextEvidenceToolStorePort } from './context-evidence-tool-store.js';
|
||||
import { ingestMetadataRequired, resolveIngestMetadata, type ToolFailure } from './context-ingest-metadata.js';
|
||||
|
|
@ -48,7 +48,7 @@ export class ContextEvidenceSearchTool extends BaseTool<typeof contextEvidenceSe
|
|||
|
||||
constructor(
|
||||
private readonly store: ContextEvidenceToolStorePort,
|
||||
private readonly embeddingService: Pick<KloEmbeddingPort, 'computeEmbedding'>,
|
||||
private readonly embeddingService: Pick<KtxEmbeddingPort, 'computeEmbedding'>,
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import { mkdtemp, rm } from 'node:fs/promises';
|
|||
import { tmpdir } from 'node:os';
|
||||
import { join } from 'node:path';
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import type { KloEmbeddingPort } from '../core/index.js';
|
||||
import type { KtxEmbeddingPort } from '../core/index.js';
|
||||
import { SqliteContextEvidenceStore } from '../ingest/context-evidence/sqlite-context-evidence-store.js';
|
||||
import { ContextCandidateMarkTool } from './context-candidate-mark.tool.js';
|
||||
import { ContextCandidateWriteTool } from './context-candidate-write.tool.js';
|
||||
|
|
@ -39,11 +39,11 @@ const ingestContext = (): ToolContext => ({
|
|||
} as unknown as ToolSession,
|
||||
});
|
||||
|
||||
const makeEmbeddingService = (overrides: Partial<KloEmbeddingPort> = {}) =>
|
||||
const makeEmbeddingService = (overrides: Partial<KtxEmbeddingPort> = {}) =>
|
||||
({
|
||||
computeEmbedding: vi.fn().mockResolvedValue([0.25, 0.5, 0.75]),
|
||||
...overrides,
|
||||
}) as Partial<KloEmbeddingPort> as KloEmbeddingPort;
|
||||
}) as Partial<KtxEmbeddingPort> as KtxEmbeddingPort;
|
||||
|
||||
describe('context evidence tools', () => {
|
||||
it('searches context evidence with ingest defaults', async () => {
|
||||
|
|
@ -86,7 +86,7 @@ describe('context evidence tools', () => {
|
|||
} as Partial<ContextEvidenceToolStorePort> as ContextEvidenceToolStorePort;
|
||||
const embeddings = {
|
||||
computeEmbedding: vi.fn().mockResolvedValue([0.1, ...Array.from({ length: 383 }, () => 0)]),
|
||||
} as Partial<KloEmbeddingPort> as KloEmbeddingPort;
|
||||
} as Partial<KtxEmbeddingPort> as KtxEmbeddingPort;
|
||||
|
||||
const tool = new ContextEvidenceSearchTool(repository, embeddings);
|
||||
const result = await tool.call({ query: 'revenue refunds', limit: 5, includeDeleted: false }, ingestContext());
|
||||
|
|
@ -116,7 +116,7 @@ describe('context evidence tools', () => {
|
|||
it('returns a structured ingest metadata error outside ingest sessions', async () => {
|
||||
const tool = new ContextEvidenceSearchTool(
|
||||
{ searchRRF: vi.fn() } as Partial<ContextEvidenceToolStorePort> as ContextEvidenceToolStorePort,
|
||||
{ computeEmbedding: vi.fn() } as Partial<KloEmbeddingPort> as KloEmbeddingPort,
|
||||
{ computeEmbedding: vi.fn() } as Partial<KtxEmbeddingPort> as KtxEmbeddingPort,
|
||||
);
|
||||
|
||||
const result = await tool.call(
|
||||
|
|
@ -446,8 +446,8 @@ describe('context evidence tools against real SqliteContextEvidenceStore', () =>
|
|||
let dbPath: string;
|
||||
|
||||
beforeEach(async () => {
|
||||
tempDir = await mkdtemp(join(tmpdir(), 'klo-context-tools-sqlite-'));
|
||||
dbPath = join(tempDir, '.klo', 'db.sqlite');
|
||||
tempDir = await mkdtemp(join(tmpdir(), 'ktx-context-tools-sqlite-'));
|
||||
dbPath = join(tempDir, '.ktx', 'db.sqlite');
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
|
|
@ -530,7 +530,7 @@ describe('context evidence tools against real SqliteContextEvidenceStore', () =>
|
|||
|
||||
const tool = new ContextCandidateWriteTool(store, {
|
||||
computeEmbedding: vi.fn().mockResolvedValue([0.1, 0.2, 0.3]),
|
||||
} as Partial<KloEmbeddingPort> as KloEmbeddingPort);
|
||||
} as Partial<KtxEmbeddingPort> as KtxEmbeddingPort);
|
||||
|
||||
const parsed = tool.parseInput({
|
||||
candidateKey: 'revenue-definition',
|
||||
|
|
@ -558,7 +558,7 @@ describe('context evidence tools against real SqliteContextEvidenceStore', () =>
|
|||
it('candidate write schema rejects a bare UUID without the ctxchunk- prefix', () => {
|
||||
const tool = new ContextCandidateWriteTool(
|
||||
{} as ContextEvidenceToolStorePort,
|
||||
{ computeEmbedding: vi.fn() } as Partial<KloEmbeddingPort> as KloEmbeddingPort,
|
||||
{ computeEmbedding: vi.fn() } as Partial<KtxEmbeddingPort> as KtxEmbeddingPort,
|
||||
);
|
||||
|
||||
expect(() =>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import type { GitService, KloFileStorePort } from '../core/index.js';
|
||||
import type { GitService, KtxFileStorePort } from '../core/index.js';
|
||||
import type { SemanticLayerService } from '../sl/index.js';
|
||||
import type { KnowledgeWikiService } from '../wiki/index.js';
|
||||
import type { TouchedSlSourceSet } from './touched-sl-sources.js';
|
||||
|
|
@ -47,7 +47,7 @@ export interface ToolSession {
|
|||
actions: MemoryAction[];
|
||||
semanticLayerService: SemanticLayerService;
|
||||
wikiService: KnowledgeWikiService;
|
||||
configService: KloFileStorePort;
|
||||
configService: KtxFileStorePort;
|
||||
gitService: GitService;
|
||||
ingest?: IngestToolMetadata;
|
||||
evictionDecisions?: EvictionDecisionRecord[];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue