Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 1 addition & 14 deletions src/cli/factories/sagemakerCommandFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,7 @@ import {
runQuickDiagnostics,
formatDiagnosticReport,
} from "../../lib/providers/sagemaker/diagnostics.js";

/**
* Secure configuration container that avoids process.env exposure
*/
interface SecureConfiguration {
accessKeyId: string;
secretAccessKey: string;
region: string;
endpointName: string;
timeout: number;
maxRetries: number;
sessionId: string;
createdAt: number;
}
import type { SecureConfiguration } from "../../lib/types/cli.js";

/**
* Factory for creating SageMaker CLI commands using the Factory Pattern
Expand Down
28 changes: 5 additions & 23 deletions src/lib/providers/amazonBedrock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
BedrockClient,
ListFoundationModelsCommand,
} from "@aws-sdk/client-bedrock";

import { BaseProvider } from "../core/baseProvider.js";
import type {
AIProviderName,
Expand All @@ -27,34 +26,17 @@ import type {
import type { StreamOptions, StreamResult } from "../types/streamTypes.js";
import type { ToolDefinition, ToolArgs } from "../types/tools.js";
import type { JsonValue } from "../types/common.js";
import type {
BedrockContentBlock,
BedrockMessage,
} from "../types/providers.js";
import type { NeuroLink } from "../neurolink.js";
import { logger } from "../utils/logger.js";
import type { DocumentType } from "@smithy/types";
import { zodToJsonSchema } from "zod-to-json-schema";
import type { ZodType } from "zod";

interface BedrockToolUse {
toolUseId: string;
name: string;
input: Record<string, unknown>;
}

interface BedrockToolResult {
toolUseId: string;
content: Array<{ text: string }>;
status: string;
}

interface BedrockContentBlock {
text?: string;
toolUse?: BedrockToolUse;
toolResult?: BedrockToolResult;
}

interface BedrockMessage {
role: "user" | "assistant";
content: BedrockContentBlock[];
}
// Bedrock-specific types now imported from ../types/providerSpecific.js

export class AmazonBedrockProvider extends BaseProvider {
private bedrockClient: BedrockRuntimeClient;
Expand Down
55 changes: 6 additions & 49 deletions src/lib/providers/googleAiStudio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ import type {
AudioChunk,
} from "../types/streamTypes.js";
import type { UnknownRecord } from "../types/common.js";
import type {
LiveServerMessage,
GenAIClient,
GoogleGenAIClass,
} from "../types/providers.js";
import type { NeuroLink } from "../neurolink.js";
import { BaseProvider } from "../core/baseProvider.js";
import { logger } from "../utils/logger.js";
Expand All @@ -23,55 +28,7 @@ import { DEFAULT_MAX_STEPS } from "../core/constants.js";
import { streamAnalyticsCollector } from "../core/streamAnalytics.js";
import { buildMessagesArray } from "../utils/messageBuilder.js";

// Interfaces setup
interface GenAILiveMedia {
data: string;
mimeType: string;
}
interface LiveServerMessagePartInlineData {
data?: string;
}
interface LiveServerMessageModelTurn {
parts?: Array<{ inlineData?: LiveServerMessagePartInlineData }>;
}
interface LiveServerContent {
modelTurn?: LiveServerMessageModelTurn;
interrupted?: boolean;
}
interface LiveServerMessage {
serverContent?: LiveServerContent;
}
interface LiveConnectCallbacks {
onopen?: () => void;
onmessage?: (message: LiveServerMessage) => void;
onerror?: (e: { message?: string }) => void;
onclose?: (e: { code?: number; reason?: string }) => void;
}
interface LiveConnectConfig {
model: string;
callbacks: LiveConnectCallbacks;
config: {
responseModalities: string[];
speechConfig: {
voiceConfig: { prebuiltVoiceConfig: { voiceName: string } };
};
};
}
interface GenAILiveSession {
sendRealtimeInput?: (payload: {
media?: GenAILiveMedia;
event?: string;
}) => Promise<void> | void;
sendInput?: (payload: {
event?: string;
media?: GenAILiveMedia;
}) => Promise<void> | void;
close?: (code?: number, reason?: string) => Promise<void> | void;
}
interface GenAIClient {
live: { connect: (config: LiveConnectConfig) => Promise<GenAILiveSession> };
}
type GoogleGenAIClass = new (cfg: { apiKey: string }) => GenAIClient;
// Google AI Live API types now imported from ../types/providerSpecific.js

// Create Google GenAI client
async function createGoogleGenAIClient(apiKey: string): Promise<GenAIClient> {
Expand Down
28 changes: 28 additions & 0 deletions src/lib/providers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,37 @@ export const PROVIDERS = {
*/
export type ProviderName = keyof typeof PROVIDERS;

Comment thread
This conversation was marked as resolved.
/**
* Type for provider class names
*/
export type ProviderClassName = (typeof PROVIDERS)[ProviderName];

/**
* List of all available provider names
*/
export const AVAILABLE_PROVIDERS: ProviderName[] = Object.keys(
PROVIDERS,
) as ProviderName[];

/**
* List of all provider class names
*/
export const PROVIDER_CLASS_NAMES: ProviderClassName[] = Object.values(
PROVIDERS,
) as ProviderClassName[];

/**
* Type guard to check if a string is a valid provider name
*/
export function isValidProviderName(name: string): name is ProviderName {
return AVAILABLE_PROVIDERS.includes(name as ProviderName);
}

/**
* Get provider class name from provider key
*/
export function getProviderClassName(
providerName: ProviderName,
): ProviderClassName {
return PROVIDERS[providerName];
}
13 changes: 2 additions & 11 deletions src/lib/providers/openaiCompatible.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type { ZodUnknownSchema } from "../types/typeAliases.js";
import type { AIProviderName } from "../types/index.js";
import type { StreamOptions, StreamResult } from "../types/streamTypes.js";
import type { UnknownRecord } from "../types/common.js";
import type { ModelsResponse } from "../types/providers.js";
import type { NeuroLink } from "../neurolink.js";
import { BaseProvider } from "../core/baseProvider.js";
import { logger } from "../utils/logger.js";
Expand Down Expand Up @@ -49,17 +50,7 @@ const getDefaultOpenAICompatibleModel = (): string | undefined => {
return process.env.OPENAI_COMPATIBLE_MODEL || undefined;
};

/**
* Interface for OpenAI-compatible models endpoint response
*/
interface ModelsResponse {
data: Array<{
id: string;
object: string;
created?: number;
owned_by?: string;
}>;
}
// ModelsResponse type now imported from ../types/providerSpecific.js

/**
* OpenAI Compatible Provider - BaseProvider Implementation
Expand Down
Loading
Loading