- Implement tests for random ID generation, ensuring preference for crypto.randomUUID. - Create tests for runtime context capabilities, validating the injection of enabled skill capabilities. - Add tests for skill capability parsing, including classification and command example extraction. - Introduce tests for the skill planner, verifying tool call planning based on user requests and attachment requirements. - Establish tests for UV setup, ensuring proper handling of Python installation scenarios and environment checks.
117 lines
2.4 KiB
TypeScript
117 lines
2.4 KiB
TypeScript
export interface ChatOptions {
|
|
signal?: AbortSignal;
|
|
}
|
|
|
|
export interface GatewayTextContentBlock {
|
|
type: 'text';
|
|
text: string;
|
|
}
|
|
|
|
export interface GatewayThinkingContentBlock {
|
|
type: 'thinking';
|
|
thinking: string;
|
|
signature?: string;
|
|
}
|
|
|
|
export interface GatewayToolUseContentBlock {
|
|
type: 'tool_use';
|
|
id: string;
|
|
name: string;
|
|
input?: unknown;
|
|
summary?: string;
|
|
}
|
|
|
|
export interface GatewayToolResultContentBlock {
|
|
type: 'tool_result';
|
|
toolCallId?: string;
|
|
content?: string | GatewayChatContentBlock[];
|
|
result?: unknown;
|
|
summary?: string;
|
|
ok?: boolean;
|
|
error?: unknown;
|
|
}
|
|
|
|
export type GatewayChatContentBlock =
|
|
| GatewayTextContentBlock
|
|
| GatewayThinkingContentBlock
|
|
| GatewayToolUseContentBlock
|
|
| GatewayToolResultContentBlock;
|
|
|
|
export type GatewayChatMessageRole =
|
|
| 'system'
|
|
| 'user'
|
|
| 'assistant'
|
|
| 'tool'
|
|
| 'toolresult'
|
|
| 'tool_result';
|
|
|
|
export interface GatewayChatMessage {
|
|
role: GatewayChatMessageRole;
|
|
content: string | GatewayChatContentBlock[];
|
|
name?: string;
|
|
toolCallId?: string;
|
|
metadata?: Record<string, unknown>;
|
|
}
|
|
|
|
export interface GatewayToolDefinition {
|
|
name: string;
|
|
description?: string;
|
|
inputSchema?: unknown;
|
|
}
|
|
|
|
export type GatewayToolChoice =
|
|
| 'auto'
|
|
| 'none'
|
|
| 'required'
|
|
| {
|
|
type: 'tool';
|
|
name: string;
|
|
};
|
|
|
|
export interface ToolCapableChatOptions extends ChatOptions {
|
|
tools?: GatewayToolDefinition[];
|
|
toolChoice?: GatewayToolChoice;
|
|
metadata?: Record<string, unknown>;
|
|
}
|
|
|
|
export interface ProviderToolCallDelta {
|
|
index?: number;
|
|
id?: string;
|
|
name?: string;
|
|
argumentsDelta?: string;
|
|
raw?: unknown;
|
|
}
|
|
|
|
export interface ProviderCapabilities {
|
|
structuredMessages: boolean;
|
|
toolCalls: boolean;
|
|
toolResults: boolean;
|
|
thinking: boolean;
|
|
}
|
|
|
|
export interface ProviderStreamChunk extends UniversalChunk {
|
|
content?: GatewayChatContentBlock[];
|
|
toolCalls?: ProviderToolCallDelta[];
|
|
finishReason?: string | null;
|
|
raw?: unknown;
|
|
}
|
|
|
|
export const DEFAULT_PROVIDER_CAPABILITIES: ProviderCapabilities = {
|
|
structuredMessages: false,
|
|
toolCalls: false,
|
|
toolResults: false,
|
|
thinking: false,
|
|
};
|
|
|
|
export abstract class BaseProvider {
|
|
getCapabilities(): ProviderCapabilities {
|
|
return DEFAULT_PROVIDER_CAPABILITIES;
|
|
}
|
|
|
|
abstract chat(
|
|
messages: GatewayChatMessage[],
|
|
modelName: string,
|
|
options?: ToolCapableChatOptions
|
|
): Promise<AsyncIterable<ProviderStreamChunk>>
|
|
}
|