UNPKG

@sourcegraph/the-orb-is-awake

Version:

TypeScript SDK for Amp CLI - Build custom AI agents with Amp's capabilities

249 lines 8.32 kB
/** * TypeScript SDK types for Amp CLI * * These types are compatible with the Amp CLI --stream-json output. */ import { z } from 'zod'; /** Text content block containing plain text */ export interface TextContent { type: 'text'; text: string; } /** Tool use content block representing a tool call request */ export interface ToolUseContent { type: 'tool_use'; id: string; name: string; input: Record<string, unknown>; } /** Tool result content block containing the result of a tool execution */ export interface ToolResultContent { type: 'tool_result'; tool_use_id: string; content: string; is_error: boolean; } /** Token usage information for API calls */ export interface Usage { input_tokens: number; cache_creation_input_tokens?: number; cache_read_input_tokens?: number; output_tokens: number; service_tier?: string; } /** Base interface for all message types */ interface BaseMessage { type: 'system' | 'assistant' | 'user' | 'result'; session_id: string; } /** System initialization message containing session info and available tools */ export interface SystemMessage extends BaseMessage { type: 'system'; subtype: 'init'; cwd: string; tools: string[]; mcp_servers: { name: string; status: 'connected' | 'connecting' | 'connection-failed' | 'disabled'; }[]; } /** AI assistant response message with text and tool usage */ export interface AssistantMessage extends BaseMessage { type: 'assistant'; message: { id: string; type: 'message'; role: 'assistant'; model: string; content: Array<TextContent | ToolUseContent>; stop_reason: 'end_turn' | 'tool_use' | 'max_tokens' | null; stop_sequence: string | null; usage?: Usage; }; parent_tool_use_id: string | null; } /** User input message containing text or tool results */ export interface UserMessage extends BaseMessage { type: 'user'; message: { role: 'user'; content: Array<TextContent | ToolResultContent>; }; parent_tool_use_id: string | null; } /** Base interface for result messages */ interface BaseResultMessage extends BaseMessage { type: 'result'; duration_ms: number; num_turns: number; usage?: Usage; permission_denials?: string[]; } /** Successful execution result message */ export interface ResultMessage extends BaseResultMessage { subtype: 'success'; is_error: false; result: string; } /** Error result message indicating execution failure */ export interface ErrorResultMessage extends BaseResultMessage { subtype: 'error_during_execution' | 'error_max_turns'; is_error: true; error: string; } export type StreamMessage = SystemMessage | AssistantMessage | UserMessage | ResultMessage | ErrorResultMessage; export declare const UserInputMessageSchema: z.ZodObject<{ type: z.ZodLiteral<"user">; message: z.ZodObject<{ role: z.ZodLiteral<"user">; content: z.ZodArray<z.ZodObject<{ type: z.ZodLiteral<"text">; text: z.ZodString; }, "strip", z.ZodTypeAny, { text: string; type: "text"; }, { text: string; type: "text"; }>, "many">; }, "strip", z.ZodTypeAny, { role: "user"; content: { text: string; type: "text"; }[]; }, { role: "user"; content: { text: string; type: "text"; }[]; }>; }, "strip", z.ZodTypeAny, { message: { role: "user"; content: { text: string; type: "text"; }[]; }; type: "user"; }, { message: { role: "user"; content: { text: string; type: "text"; }[]; }; type: "user"; }>; export declare const MCPServerSchema: z.ZodObject<{ command: z.ZodString; args: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>; disabled: z.ZodOptional<z.ZodBoolean>; }, "strip", z.ZodTypeAny, { command: string; disabled?: boolean | undefined; args?: string[] | undefined; env?: Record<string, string> | undefined; }, { command: string; disabled?: boolean | undefined; args?: string[] | undefined; env?: Record<string, string> | undefined; }>; export declare const MCPConfigSchema: z.ZodRecord<z.ZodString, z.ZodObject<{ command: z.ZodString; args: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>; disabled: z.ZodOptional<z.ZodBoolean>; }, "strip", z.ZodTypeAny, { command: string; disabled?: boolean | undefined; args?: string[] | undefined; env?: Record<string, string> | undefined; }, { command: string; disabled?: boolean | undefined; args?: string[] | undefined; env?: Record<string, string> | undefined; }>>; export declare const AmpOptionsSchema: z.ZodObject<{ cwd: z.ZodOptional<z.ZodString>; dangerouslyAllowAll: z.ZodOptional<z.ZodBoolean>; visibility: z.ZodOptional<z.ZodDefault<z.ZodEnum<["private", "public", "workspace", "group"]>>>; settingsFile: z.ZodOptional<z.ZodString>; logLevel: z.ZodOptional<z.ZodEnum<["debug", "info", "warn", "error", "audit"]>>; logFile: z.ZodOptional<z.ZodString>; mcpConfig: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodRecord<z.ZodString, z.ZodObject<{ command: z.ZodString; args: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>; disabled: z.ZodOptional<z.ZodBoolean>; }, "strip", z.ZodTypeAny, { command: string; disabled?: boolean | undefined; args?: string[] | undefined; env?: Record<string, string> | undefined; }, { command: string; disabled?: boolean | undefined; args?: string[] | undefined; env?: Record<string, string> | undefined; }>>]>>; env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>; continue: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodString]>>; toolbox: z.ZodOptional<z.ZodString>; }, "strict", z.ZodTypeAny, { env?: Record<string, string> | undefined; cwd?: string | undefined; dangerouslyAllowAll?: boolean | undefined; visibility?: "private" | "public" | "workspace" | "group" | undefined; settingsFile?: string | undefined; logLevel?: "debug" | "info" | "warn" | "error" | "audit" | undefined; logFile?: string | undefined; mcpConfig?: string | Record<string, { command: string; disabled?: boolean | undefined; args?: string[] | undefined; env?: Record<string, string> | undefined; }> | undefined; continue?: string | boolean | undefined; toolbox?: string | undefined; }, { env?: Record<string, string> | undefined; cwd?: string | undefined; dangerouslyAllowAll?: boolean | undefined; visibility?: "private" | "public" | "workspace" | "group" | undefined; settingsFile?: string | undefined; logLevel?: "debug" | "info" | "warn" | "error" | "audit" | undefined; logFile?: string | undefined; mcpConfig?: string | Record<string, { command: string; disabled?: boolean | undefined; args?: string[] | undefined; env?: Record<string, string> | undefined; }> | undefined; continue?: string | boolean | undefined; toolbox?: string | undefined; }>; /** User input message for streaming conversations */ export type UserInputMessage = z.infer<typeof UserInputMessageSchema>; /** MCP server configuration */ export type MCPServer = z.infer<typeof MCPServerSchema>; /** MCP configuration object */ export type MCPConfig = z.infer<typeof MCPConfigSchema>; /** Configuration options for Amp CLI execution */ export type AmpOptions = z.infer<typeof AmpOptionsSchema>; /** Input type for prompts - either a string or streaming user messages */ type PromptInput = string | AsyncIterable<UserInputMessage>; /** Options for executing Amp CLI commands */ export interface ExecuteOptions { prompt: PromptInput; options?: AmpOptions; signal?: AbortSignal; } export {}; //# sourceMappingURL=types.d.ts.map