takumi
Version:
A coding agent CLI to enhance your development workflow.
548 lines (484 loc) • 15.6 kB
TypeScript
import { Agent } from '@openai/agents';
import { AgentOutputItem } from '@openai/agents';
import { checkAndUpdate as _checkAndUpdate } from 'upgear';
import { createAnthropic as _createAnthropic } from '@ai-sdk/anthropic';
import { createDeepSeek as _createDeepSeek } from '@ai-sdk/deepseek';
import { createOpenAI as _createOpenAI } from '@ai-sdk/openai';
import type { LanguageModelV1 } from '@ai-sdk/provider';
import { LanguageModelV1CallWarning } from '@ai-sdk/provider';
import { LanguageModelV1FinishReason } from '@ai-sdk/provider';
import { LanguageModelV1FunctionToolCall } from '@ai-sdk/provider';
import { LanguageModelV1LogProbs } from '@ai-sdk/provider';
import { LanguageModelV1ProviderMetadata } from '@ai-sdk/provider';
import { LanguageModelV1Source } from '@ai-sdk/provider';
import { MCPServerStdio } from '@openai/agents';
import { MCPServerStreamableHttp } from '@openai/agents';
import { Model } from '@openai/agents';
import { ModelProvider } from '@openai/agents';
import { ModelRequest } from '@openai/agents';
import { default as _picocolors } from 'picocolors';
import { ResponseStreamEvent } from '@openai/agents';
import { Runner } from '@openai/agents';
import { Tool } from '@openai/agents';
import { tool as _tool } from '@openai/agents';
import { Usage } from '@openai/agents';
import { default as WebSocket_2 } from 'ws';
import { z as _zod } from 'zod';
export { Agent }
declare type AgentType = 'code' | 'plan';
/**
* Wraps a model from the AI SDK that adheres to the LanguageModelV1 spec to be used used as a model
* in the OpenAI Agents SDK to use other models.
*
* While you can use this with the OpenAI models, it is recommended to use the default OpenAI model
* provider instead.
*
* If tracing is enabled, the model will send generation spans to your traces processor.
*
* ```ts
* import { aisdk } from '@openai/agents-extensions';
* import { openai } from '@ai-sdk/openai';
*
* const model = aisdk(openai('gpt-4o'));
*
* const agent = new Agent({
* name: 'My Agent',
* model
* });
* ```
*
* @param model - The Vercel AI SDK model to wrap.
* @returns The wrapped model.
*/
export declare function _aisdk(model: LanguageModelV1): AiSdkModel;
/**
* Wraps a model from the AI SDK that adheres to the LanguageModelV1 spec to be used used as a model
* in the OpenAI Agents SDK to use other models.
*
* While you can use this with the OpenAI models, it is recommended to use the default OpenAI model
* provider instead.
*
* If tracing is enabled, the model will send generation spans to your traces processor.
*
* ```ts
* import { aisdk } from '@openai/agents-extensions';
* import { openai } from '@ai-sdk/openai';
*
* const model = aisdk(openai('gpt-4o'));
*
* const agent = new Agent({
* name: 'My Agent',
* model
* });
* ```
*
* @param model - The Vercel AI SDK model to wrap.
* @returns The wrapped model.
*/
declare class AiSdkModel implements Model {
#private;
constructor(model: LanguageModelV1);
getResponse(request: ModelRequest): Promise<{
responseId: string;
usage: Usage;
output: AgentOutputItem[];
providerData: {
text?: string;
reasoning?: string | Array<{
type: "text";
text: string;
signature?: string;
} | {
type: "redacted";
data: string;
}>;
files?: Array<{
data: string | Uint8Array;
mimeType: string;
}>;
toolCalls?: Array<LanguageModelV1FunctionToolCall>;
finishReason: LanguageModelV1FinishReason;
usage: {
promptTokens: number;
completionTokens: number;
};
rawCall: {
rawPrompt: unknown;
rawSettings: Record<string, unknown>;
};
rawResponse?: {
headers?: Record<string, string>;
body?: unknown;
};
request?: {
body?: string;
};
response?: {
id?: string;
timestamp?: Date;
modelId?: string;
};
warnings?: LanguageModelV1CallWarning[];
providerMetadata?: LanguageModelV1ProviderMetadata;
sources?: LanguageModelV1Source[];
logprobs?: LanguageModelV1LogProbs;
};
}>;
getStreamedResponse(request: ModelRequest): AsyncIterable<ResponseStreamEvent>;
}
declare type ApprovalContext = {
toolName: string;
params: Record<string, any>;
approvalMode: string;
context: any;
};
declare type ApprovalMode = 'default' | 'autoEdit' | 'yolo';
declare interface BaseResponse {
success: boolean;
message?: string;
}
declare interface BaseSlashCommand {
name: string;
description: string;
}
export { _checkAndUpdate }
declare interface CloseAllDiffTabsResponse extends BaseResponse {
closedCount: number;
}
declare interface CloseTabResponse extends BaseResponse {
message: string;
}
declare type Config = {
model: string;
smallModel: string;
planModel: string;
language: string;
quiet: boolean;
approvalMode: ApprovalMode;
plugins: string[];
mcpServers: Record<string, McpServerConfig>;
systemPrompt?: string;
};
export declare class Context {
cwd: string;
productName: string;
version: string;
config: Config;
argvConfig: Partial<Config>;
pluginManager: PluginManager;
mcpManager: MCPManager;
mcpTools: Tool[];
git: string | null;
ide: IDE;
history: string[];
generalInfo: Record<string, string>;
paths: Paths;
slashCommands: SlashCommandRegistry;
env: Env;
constructor(opts: ContextOpts);
static create(opts: CreateContextOpts): Promise<Context>;
getModelProvider(): ModelProvider;
addHistory(prompt: string): void;
buildSystemPrompts(): Promise<string[]>;
apply(applyOpts: Omit<PluginApplyOpts, 'pluginContext'>): Promise<any>;
destroy(): Promise<void>;
}
declare type ContextOpts = CreateContextOpts & {
config: Config;
pluginManager: PluginManager;
mcpManager: MCPManager;
mcpTools: Tool[];
git: string | null;
ide: IDE;
generalInfo: Record<string, string>;
paths: Paths;
slashCommands: SlashCommandRegistry;
env: Env;
};
export { _createAnthropic }
declare interface CreateContextOpts {
cwd: string;
argvConfig?: Partial<Config>;
productName?: string;
version?: string;
plugins?: Plugin_2[];
traceFile?: string;
}
export { _createDeepSeek }
export { _createOpenAI }
declare interface DiagnosticItem {
message: string;
severity: string;
range: {
start: {
line: number;
character: number;
};
end: {
line: number;
character: number;
};
};
}
declare interface DiagnosticsResponse {
diagnostics: Array<{
uri: string;
diagnostics: DiagnosticItem[];
}>;
}
declare interface EditorInfo {
filePath: string;
isActive: boolean;
}
declare type Enforce = 'pre' | 'post';
declare type EnhancedTool = Tool<any> & {
approval?: ToolApprovalInfo;
};
export declare function _enhanceTool(tool: Tool<any>, approval?: ToolApprovalInfo): EnhancedTool;
declare type Env = {
hasInternetAccess: boolean;
platform: string;
nodeVersion: string;
terminal: string | null;
};
declare class IDE {
ws: WebSocket_2 | null;
private requestId;
private pendingRequests;
constructor();
findPort(): Promise<number | undefined>;
connect(): Promise<void>;
disconnect(): Promise<void>;
handleMessage(message: WSMessage): void;
request(method: string, params?: Record<string, unknown>): Promise<unknown>;
openFile(filePath: string, options?: {
preview?: boolean;
}): Promise<OpenFileResponse>;
openDiff(old_file_path: string, new_file_path: string, new_file_contents: string, tab_name: string): Promise<OpenDiffResponse>;
getWorkspaceFolders(): Promise<WorkspaceFoldersResponse>;
getOpenEditors(): Promise<OpenEditorsResponse>;
getDiagnostics(): Promise<DiagnosticsResponse>;
getCurrentSelection(): Promise<SelectionResult>;
getLatestSelection(): Promise<SelectionResult>;
closeTab(tab_name: string): Promise<CloseTabResponse>;
closeAllDiffTabs(): Promise<CloseAllDiffTabsResponse>;
setupIDEIntegration(terminal: string): Promise<InstallationResult | undefined>;
}
declare interface InstallationResult {
installed: boolean;
error: string | null;
installedVersion: string | null;
}
declare interface LocalCommand extends BaseSlashCommand {
type: 'local';
call(args: string, context: Context): Promise<string>;
}
declare interface LocalJSXCommand extends BaseSlashCommand {
type: 'local-jsx';
call(onDone: (result: string) => void, context: Context): Promise<React.ReactNode>;
}
declare type MCP = MCPServerStdio | MCPServerStreamableHttp;
declare interface MCPConfig {
type?: 'stdio' | 'sse';
command?: string;
args?: string[];
env?: Record<string, string>;
url?: string;
disable?: boolean;
}
declare class MCPManager {
private servers;
constructor(servers: Map<string, MCP>);
static create(mcpServers: Record<string, MCPConfig>): Promise<MCPManager>;
getAllTools(): Promise<Tool<unknown>[]>;
getTools(keys: string[]): Promise<Tool<unknown>[]>;
destroy(): Promise<void>;
}
declare type McpServerConfig = McpStdioServerConfig | McpSSEServerConfig;
declare type McpSSEServerConfig = {
type: 'sse';
url: string;
disable?: boolean;
};
declare type McpStdioServerConfig = {
type?: 'stdio';
command: string;
args: string[];
env?: Record<string, string>;
disable?: boolean;
};
declare interface OpenDiffResponse extends BaseResponse {
message: string;
}
declare interface OpenEditorsResponse {
editors: EditorInfo[];
}
declare interface OpenFileResponse extends BaseResponse {
filePath?: string;
}
declare type Paths = {
globalConfigDir: string;
projectConfigDir: string;
};
export { _picocolors }
declare type Plugin_2 = {
enforce?: Enforce;
name?: string;
config?: (this: TempPluginContext) => any | Promise<any>;
configResolved?: (this: TempPluginContext, opts: {
resolvedConfig: any;
}) => Promise<any> | any;
generalInfo?: (this: TempPluginContext) => any | Promise<any>;
cliStart?: (this: PluginContext) => Promise<any> | any;
cliEnd?: (this: PluginContext, opts: {
startTime: number;
endTime: number;
error?: any;
}) => Promise<any> | any;
contextStart?: (this: PluginContext, opts: {
prompt: string;
}) => Promise<any> | any;
context?: (this: PluginContext, opts: {
prompt: string;
}) => Promise<any> | any;
toolUse?: (this: PluginContext, opts: {
callId: string;
name: string;
params: any;
}) => Promise<any> | any;
toolUseResult?: (this: PluginContext, opts: {
callId: string;
name: string;
params: any;
result: any;
}) => Promise<any> | any;
query?: (this: PluginContext, opts: {
text: string;
parsed: any;
input: any;
}) => Promise<any> | any;
env?: (this: PluginContext) => Record<string, string>;
model?: (this: PluginContext, opts: {
modelName: string;
aisdk: any;
createOpenAI: any;
createDeepSeek: any;
createAnthropic: any;
}) => Promise<any> | any;
tool?: (this: PluginContext, opts: {
agentType: AgentType;
}) => Promise<any>;
serverAppData?: (this: PluginContext, opts: {
context: any;
cwd: string;
}) => Promise<any> | any;
serverRoutes?: (this: PluginContext, opts: {
app: any;
prefix: string;
opts: any;
}) => Promise<any> | any;
serverRouteCompletions?: (this: PluginContext, opts: {
message: {
role: 'user';
content: string;
attachedContexts: any[];
contextContent: string;
};
attachedContexts: any[];
}) => Promise<any> | any;
command?: (this: PluginContext) => Promise<any[]> | any[];
};
export { Plugin_2 as Plugin }
declare type PluginApplyOpts = {
hook: keyof Plugin_2;
args: any[];
memo?: any;
type: PluginHookType;
pluginContext: any;
};
declare type PluginContext = Omit<Context, 'destroy' | 'getModelProvider' | 'buildSystemPrompts' | 'addHistory'>;
declare enum PluginHookType {
First = "first",
Series = "series",
SeriesMerge = "seriesMerge",
SeriesLast = "seriesLast",
Parallel = "parallel"
}
declare class PluginManager {
#private;
constructor(rawPlugins: Plugin_2[]);
apply({ hook, args, memo, type, pluginContext, }: PluginApplyOpts): Promise<any>;
}
declare interface PromptCommand extends BaseSlashCommand {
type: 'prompt';
argNames?: string[];
progressMessage: string;
getPromptForCommand(args: string): Promise<Array<{
role: string;
content: string;
}>>;
}
export declare function runCli(opts: RunCliOpts): Promise<void>;
export declare interface RunCliOpts {
cwd: string;
productName: string;
version: string;
plugins?: Plugin_2[];
}
export { Runner }
declare interface SelectionErrorResponse {
error: string;
}
declare interface SelectionInfo {
filePath: string;
text: string;
selection: {
start: {
line: number;
character: number;
};
end: {
line: number;
character: number;
};
};
}
declare interface SelectionResponse extends SelectionInfo {
}
declare type SelectionResult = SelectionResponse | SelectionErrorResponse;
declare type SlashCommand = LocalCommand | LocalJSXCommand | PromptCommand;
declare interface SlashCommandRegistry {
register(command: SlashCommand): void;
unregister(name: string): void;
get(name: string): SlashCommand | undefined;
getAll(): SlashCommand[];
hasCommand(name: string): boolean;
getMatchingCommands(prefix: string): SlashCommand[];
}
declare type TempPluginContext = CreateContextOpts & {
pluginManager: PluginManager;
config: Config;
apply: (opts: PluginApplyOpts) => Promise<any> | any;
};
export { _tool }
declare type ToolApprovalInfo = {
needsApproval?: (context: ApprovalContext) => Promise<boolean> | boolean;
category?: 'read' | 'write' | 'command' | 'network';
riskLevel?: 'low' | 'medium' | 'high';
};
declare interface WorkspaceFolder {
name: string;
uri: string;
}
declare interface WorkspaceFoldersResponse {
folders: WorkspaceFolder[];
}
declare interface WSMessage {
id?: number;
error?: {
message: string;
};
result?: unknown;
}
export { _zod }
export { }