@stacksjs/ai 0.70.87 → 0.70.88

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@stacksjs/ai",
3
3
  "type": "module",
4
4
  "sideEffects": false,
5
- "version": "0.70.87",
5
+ "version": "0.70.88",
6
6
  "description": "Stacks Artificial Intelligence.",
7
7
  "author": "Chris Breuer",
8
8
  "contributors": [
@@ -1,29 +0,0 @@
1
- import type { AIDriver, StreamingResult } from '../../types';
2
- /**
3
- * Create a local Claude CLI agent
4
- */
5
- export declare function createClaudeLocalAgent(config?: ClaudeAgentConfig): AIDriver;
6
- /**
7
- * Create a remote Claude CLI agent (EC2)
8
- */
9
- export declare function createClaudeEC2Agent(config: ClaudeAgentConfig): AIDriver;
10
- /**
11
- * Process command with streaming output using Claude CLI
12
- *
13
- * Returns a ReadableStream that emits chunks of the response in real-time.
14
- * Uses --output-format stream-json for detailed streaming with tool usage.
15
- */
16
- export declare function processCommandStreaming(command: string, cwd: string): Promise<StreamingResult>;
17
- export declare function resetPromptCount(): void;
18
- export declare const claudeAgent: {
19
- createLocal: typeof createClaudeLocalAgent
20
- createEC2: typeof createClaudeEC2Agent
21
- processStreaming: typeof processCommandStreaming
22
- resetPromptCount: typeof resetPromptCount
23
- };
24
- export declare interface ClaudeAgentConfig {
25
- cwd?: string
26
- ec2Host?: string
27
- ec2User?: string
28
- ec2Key?: string
29
- }
@@ -1,6 +0,0 @@
1
- /**
2
- * AI Agents
3
- *
4
- * Export all available AI agents.
5
- */
6
- export * from './claude/index';
package/dist/buddy.d.ts DELETED
@@ -1,67 +0,0 @@
1
- import type { AIDriver, AIMessage, BuddyApiKeys, BuddyConfig, BuddyState, GitHubCredentials, RepoState, StreamingResult } from './types';
2
- /**
3
- * Build system prompt for AI with repository context
4
- */
5
- export declare function buildSystemPrompt(context: string): string;
6
- /**
7
- * Get driver instance by name
8
- */
9
- export declare function getDriver(driverName: string): AIDriver;
10
- /**
11
- * Get list of available AI drivers
12
- */
13
- export declare function getAvailableDrivers(): string[];
14
- /**
15
- * Get repository structure for context
16
- */
17
- export declare function getRepoContext(repoPath: string): Promise<string>;
18
- /**
19
- * Clone or open a repository
20
- */
21
- export declare function openRepository(input: string): Promise<RepoState>;
22
- /**
23
- * Apply file changes from AI response
24
- */
25
- export declare function applyChanges(aiResponse: string): Promise<string[]>;
26
- /**
27
- * Configure git user for commits
28
- */
29
- export declare function configureGitUser(): Promise<void>;
30
- /**
31
- * Stage and commit changes
32
- */
33
- export declare function commitChanges(): Promise<string>;
34
- /**
35
- * Push changes to remote
36
- */
37
- export declare function pushChanges(): Promise<void>;
38
- /**
39
- * Process command with selected AI driver
40
- */
41
- export declare function processCommand(command: string, driverName?: string): Promise<string>;
42
- /**
43
- * Process command with streaming output using Claude CLI
44
- */
45
- export declare function buddyProcessStreaming(command: string, driverName?: string, history?: Array<{role: string; content: string}>): Promise<StreamingResult>;
46
- /**
47
- * Stream a simple Q&A response using the Anthropic API directly.
48
- * This provides true token-by-token streaming like ChatGPT/Claude web.
49
- * Use this for questions/explanations that don't require agentic tool use.
50
- */
51
- export declare function buddyStreamSimple(command: string, history?: Array<{ role: string; content: string }>): Promise<StreamingResult>;
52
- // =============================================================================
53
- // Configuration
54
- // =============================================================================
55
- export declare const CONFIG: BuddyConfig;
56
- // API Keys state (can be set at runtime via settings endpoint)
57
- export declare const apiKeys: BuddyApiKeys;
58
- export declare const buddyState: BuddyStateManager;
59
- // Buddy State Manager
60
- export declare interface BuddyStateManager {
61
- getState: () => BuddyState
62
- setRepo: (repo: RepoState | null) => void
63
- setCurrentDriver: (driver: string) => void
64
- setGitHub: (github: GitHubCredentials | null) => void
65
- addToHistory: (message: AIMessage) => void
66
- clearHistory: () => void
67
- }
@@ -1,40 +0,0 @@
1
- import type { AIDriver, AIDriverConfig, AIMessage, AIResult, ChatCompletionOptions } from '../../types';
2
- /**
3
- * Configure Anthropic globally
4
- */
5
- export declare function configure(config: AnthropicDriverConfig): void;
6
- export declare function createAnthropicDriver(config: AnthropicDriverConfig): AIDriver;
7
- /**
8
- * Chat completion with full options. Supports tools + structured
9
- * output via `responseFormat` (stacksjs/stacks#1878 A-1).
10
- */
11
- export declare function chat(messages: AIMessage[], options?: ChatCompletionOptions & { system?: string }): Promise<AIResult>;
12
- /**
13
- * Stream chat completion
14
- */
15
- export declare function streamChat(messages: AIMessage[], options?: ChatCompletionOptions & { system?: string }): AsyncGenerator<string>;
16
- /**
17
- * Simple prompt helper
18
- */
19
- export declare function prompt(text: string, options?: ChatCompletionOptions & { system?: string }): Promise<string>;
20
- /**
21
- * Count tokens (approximate)
22
- * Note: This is a rough estimate. For accurate counts, use the tokenizer.
23
- */
24
- export declare function estimateTokens(text: string): number;
25
- export declare const anthropicDriver: { create: typeof createAnthropicDriver };
26
- export declare const anthropic: {
27
- configure: typeof configure;
28
- chat: typeof chat;
29
- streamChat: typeof streamChat;
30
- prompt: typeof prompt;
31
- estimateTokens: typeof estimateTokens;
32
- createDriver: unknown
33
- };
34
- export declare interface AnthropicDriverConfig extends AIDriverConfig {
35
- apiKey: string
36
- model?: string
37
- maxTokens?: number
38
- anthropicVersion?: string
39
- }
40
- export default anthropic;
@@ -1,40 +0,0 @@
1
- import type { AIDriver, AIDriverConfig, StreamingResult } from '../../types';
2
- /**
3
- * Create a Claude Agent SDK driver instance
4
- */
5
- export declare function createClaudeAgentSDKDriver(config?: ClaudeAgentSDKConfig): AIDriver;
6
- /**
7
- * Process a command with streaming and return a StreamingResult
8
- */
9
- export declare function processStreaming(command: string, cwd?: string, config?: Omit<ClaudeAgentSDKConfig, 'cwd'>): Promise<StreamingResult>;
10
- /**
11
- * Resume a previous SDK session
12
- */
13
- export declare function resumeSession(sessionId: string, prompt: string): Promise<string>;
14
- /**
15
- * Get the last session ID for potential resume
16
- */
17
- export declare function getLastSessionId(): string | undefined;
18
- /**
19
- * Clear the stored session ID
20
- */
21
- export declare function clearSession(): void;
22
- // Export the driver creator and utilities
23
- export declare const claudeAgentSDK: {
24
- createDriver: unknown;
25
- processStreaming: typeof processStreaming;
26
- resumeSession: typeof resumeSession;
27
- getLastSessionId: typeof getLastSessionId;
28
- clearSession: typeof clearSession
29
- };
30
- export declare interface ClaudeAgentSDKConfig extends AIDriverConfig {
31
- maxTurns?: number
32
- cwd?: string
33
- allowedTools?: string[]
34
- disallowedTools?: string[]
35
- permissionMode?: 'default' | 'acceptEdits' | 'bypassPermissions' | 'plan'
36
- customSystemPrompt?: string
37
- appendSystemPrompt?: string
38
- resumeSessionId?: string
39
- }
40
- export default claudeAgentSDK;
@@ -1,13 +0,0 @@
1
- export type { AnthropicDriverConfig } from './anthropic/index';
2
- export type { OpenAIDriverConfig } from './openai/index';
3
- export type { OllamaDriverConfig } from './ollama/index';
4
- export type { ClaudeAgentSDKConfig } from './claude-agent-sdk/index';
5
- /**
6
- * AI Drivers
7
- *
8
- * Export all available AI drivers.
9
- */
10
- export { createAnthropicDriver, anthropicDriver, anthropic, estimateTokens } from './anthropic/index';
11
- export { createOpenAIDriver, openaiDriver, openai } from './openai/index';
12
- export { createOllamaDriver, ollamaDriver, ollama } from './ollama/index';
13
- export { createClaudeAgentSDKDriver, claudeAgentSDK, getLastSessionId, clearSession } from './claude-agent-sdk/index';
@@ -1,93 +0,0 @@
1
- import type { AIDriver, AIDriverConfig, AIMessage, AIResult, ChatCompletionOptions } from '../../types';
2
- /**
3
- * Configure Ollama globally
4
- */
5
- export declare function configure(config: OllamaDriverConfig): void;
6
- export declare function createOllamaDriver(config?: OllamaDriverConfig): AIDriver;
7
- /**
8
- * Chat completion with full options
9
- */
10
- export declare function chat(messages: AIMessage[], options?: ChatCompletionOptions): Promise<AIResult>;
11
- /**
12
- * Stream chat completion
13
- */
14
- export declare function streamChat(messages: AIMessage[], options?: ChatCompletionOptions): AsyncGenerator<string>;
15
- /**
16
- * Generate text completion (non-chat)
17
- */
18
- export declare function generate(prompt: string, options?: {
19
- model?: string
20
- system?: string
21
- template?: string
22
- context?: number[]
23
- raw?: boolean
24
- format?: 'json'
25
- images?: string[]
26
- }): Promise<AIResult>;
27
- /**
28
- * Create embeddings
29
- */
30
- export declare function embed(input: string | string[], model?: string): Promise<number[] | number[][]>;
31
- /**
32
- * List available models
33
- */
34
- export declare function listModels(): Promise<Array<{
35
- name: string
36
- modified_at: string
37
- size: number
38
- digest: string
39
- details: {
40
- format: string
41
- family: string
42
- families: string[]
43
- parameter_size: string
44
- quantization_level: string
45
- }
46
- }>>;
47
- /**
48
- * Pull a model from the library
49
- */
50
- export declare function pullModel(name: string, onProgress?: (status: string, completed?: number, total?: number) => void): Promise<void>;
51
- /**
52
- * Delete a model
53
- */
54
- export declare function deleteModel(name: string): Promise<void>;
55
- /**
56
- * Show model information
57
- */
58
- export declare function showModel(_name: string): Promise<{
59
- modelfile: string
60
- parameters: string
61
- template: string
62
- details: {
63
- format: string
64
- family: string
65
- families: string[]
66
- parameter_size: string
67
- quantization_level: string
68
- }
69
- }>;
70
- /**
71
- * Check if Ollama is running
72
- */
73
- export declare function isRunning(): Promise<boolean>;
74
- export declare const ollamaDriver: { create: typeof createOllamaDriver };
75
- export declare const ollama: {
76
- configure: typeof configure;
77
- chat: typeof chat;
78
- streamChat: typeof streamChat;
79
- generate: typeof generate;
80
- embed: typeof embed;
81
- listModels: typeof listModels;
82
- pullModel: typeof pullModel;
83
- deleteModel: typeof deleteModel;
84
- showModel: typeof showModel;
85
- isRunning: typeof isRunning;
86
- createDriver: unknown
87
- };
88
- export declare interface OllamaDriverConfig extends AIDriverConfig {
89
- host?: string
90
- model?: string
91
- embeddingModel?: string
92
- }
93
- export default ollama;
@@ -1,66 +0,0 @@
1
- import type { AIDriver, AIDriverConfig, AIMessage, AIResult, ChatCompletionOptions } from '../../types';
2
- /**
3
- * Configure OpenAI globally
4
- */
5
- export declare function configure(config: OpenAIDriverConfig): void;
6
- export declare function createOpenAIDriver(config: OpenAIDriverConfig): AIDriver;
7
- /**
8
- * Chat completion with full options
9
- */
10
- export declare function chat(messages: AIMessage[], options?: ChatCompletionOptions): Promise<AIResult>;
11
- /**
12
- * Stream chat completion
13
- */
14
- export declare function streamChat(messages: AIMessage[], options?: ChatCompletionOptions): AsyncGenerator<string>;
15
- /**
16
- * Create embeddings
17
- */
18
- export declare function embed(input: string | string[], model?: unknown): Promise<number[] | number[][]>;
19
- /**
20
- * Generate images using DALL-E
21
- */
22
- export declare function generateImage(prompt: string, options?: {
23
- model?: 'dall-e-2' | 'dall-e-3'
24
- size?: '256x256' | '512x512' | '1024x1024' | '1792x1024' | '1024x1792'
25
- quality?: 'standard' | 'hd'
26
- n?: number
27
- responseFormat?: 'url' | 'b64_json'
28
- }): Promise<{ url?: string, b64_json?: string }[]>;
29
- /**
30
- * Transcribe audio using Whisper
31
- */
32
- export declare function transcribe(audioFile: Blob | File, options?: {
33
- model?: 'whisper-1'
34
- language?: string
35
- prompt?: string
36
- responseFormat?: 'json' | 'text' | 'srt' | 'verbose_json' | 'vtt'
37
- temperature?: number
38
- }): Promise<{ text: string }>;
39
- /**
40
- * Text-to-speech using OpenAI TTS
41
- */
42
- export declare function textToSpeech(input: string, options?: {
43
- model?: 'tts-1' | 'tts-1-hd'
44
- voice?: 'alloy' | 'echo' | 'fable' | 'onyx' | 'nova' | 'shimmer'
45
- responseFormat?: 'mp3' | 'opus' | 'aac' | 'flac' | 'wav' | 'pcm'
46
- speed?: number
47
- }): Promise<ArrayBuffer>;
48
- export declare const openaiDriver: { create: typeof createOpenAIDriver };
49
- export declare const openai: {
50
- configure: typeof configure;
51
- chat: typeof chat;
52
- streamChat: typeof streamChat;
53
- embed: typeof embed;
54
- generateImage: typeof generateImage;
55
- transcribe: typeof transcribe;
56
- textToSpeech: typeof textToSpeech;
57
- createDriver: unknown
58
- };
59
- export declare interface OpenAIDriverConfig extends AIDriverConfig {
60
- apiKey: string
61
- model?: string
62
- maxTokens?: number
63
- embeddingModel?: string
64
- baseUrl?: string
65
- }
66
- export default openai;
package/dist/image.d.ts DELETED
@@ -1,83 +0,0 @@
1
- import type { AIResult } from './types';
2
- /**
3
- * Generate images from a text prompt.
4
- * Currently supports OpenAI DALL-E models.
5
- */
6
- export declare function generateImage(prompt: string, options?: ImageGenerationOptions): Promise<ImageGenerationResult>;
7
- /**
8
- * Edit an existing image with a text prompt (OpenAI DALL-E 2).
9
- */
10
- export declare function editImage(image: Blob | File, prompt: string, options?: ImageEditOptions): Promise<ImageGenerationResult>;
11
- /**
12
- * Create variations of an existing image (OpenAI DALL-E 2).
13
- */
14
- export declare function createImageVariation(image: Blob | File, options?: {
15
- model?: 'dall-e-2'
16
- n?: number
17
- size?: '256x256' | '512x512' | '1024x1024'
18
- responseFormat?: 'url' | 'b64_json'
19
- }): Promise<ImageGenerationResult>;
20
- /**
21
- * Analyze an image using AI vision capabilities.
22
- * Supports Anthropic Claude, OpenAI GPT-4V, and Ollama multimodal models.
23
- */
24
- export declare function analyzeImage(imageInput: ImageInput, prompt: string, options?: VisionOptions): Promise<VisionResult>;
25
- /**
26
- * Analyze multiple images together with a prompt.
27
- * Useful for comparison, batch analysis, etc.
28
- */
29
- export declare function analyzeImages(images: ImageInput[], prompt: string, options?: VisionOptions): Promise<VisionResult>;
30
- // ============================================================================
31
- // Exports
32
- // ============================================================================
33
- export declare const image: {
34
- generate: unknown;
35
- edit: unknown;
36
- variation: unknown;
37
- analyze: unknown;
38
- analyzeMultiple: unknown
39
- };
40
- // ============================================================================
41
- // Types
42
- // ============================================================================
43
- export declare interface ImageGenerationOptions {
44
- provider?: 'openai' | 'ollama'
45
- model?: string
46
- size?: '256x256' | '512x512' | '1024x1024' | '1792x1024' | '1024x1792'
47
- quality?: 'standard' | 'hd'
48
- n?: number
49
- responseFormat?: 'url' | 'b64_json'
50
- style?: 'vivid' | 'natural'
51
- }
52
- export declare interface ImageGenerationResult {
53
- images: Array<{
54
- url?: string
55
- b64_json?: string
56
- revisedPrompt?: string
57
- }>
58
- provider: string
59
- model: string
60
- }
61
- export declare interface VisionOptions {
62
- provider?: 'anthropic' | 'openai' | 'ollama'
63
- model?: string
64
- maxTokens?: number
65
- temperature?: number
66
- detail?: 'auto' | 'low' | 'high'
67
- }
68
- export declare interface VisionResult extends AIResult {
69
- provider: string
70
- }
71
- // ============================================================================
72
- // Image Editing
73
- // ============================================================================
74
- export declare interface ImageEditOptions {
75
- mask?: Blob | File
76
- model?: 'dall-e-2'
77
- n?: number
78
- size?: '256x256' | '512x512' | '1024x1024'
79
- responseFormat?: 'url' | 'b64_json'
80
- }
81
- export type ImageInput = | { type: 'url'; url: string }
82
- | { type: 'base64'; data: string; mediaType: string }
83
- | { type: 'file'; path: string }
package/dist/index.d.ts DELETED
@@ -1,39 +0,0 @@
1
- export type { RetryConfig } from './utils/retry';
2
- export type { UsageRecord, UsageReporter } from './utils/usage';
3
- export type { SanitizeResult } from './utils/tokens';
4
- // Types
5
- export * from './types';
6
- // Drivers
7
- export * from './drivers/index';
8
- // Agents
9
- export * from './agents/index';
10
- // Buddy - Voice AI Code Assistant
11
- export * from './buddy';
12
- // Text utilities
13
- export * from './text';
14
- // Image generation & vision
15
- export * from './image';
16
- // Semantic search, embeddings & RAG
17
- export * from './search';
18
- // Personalization, sentiment & classification
19
- export * from './personalization';
20
- // Model Context Protocol (MCP) client
21
- export * from './mcp';
22
- // AWS Bedrock utilities
23
- export * from './utils/client-bedrock';
24
- export * from './utils/client-bedrock-runtime';
25
- // Cross-driver vision helpers (stacksjs/stacks#1878 A-3).
26
- // `buildMessageWithImages(command, images)` constructs portable
27
- // content arrays; `normalizeMessagesForProvider(messages, 'openai' | 'anthropic')`
28
- // translates between the OpenAI image_url and Anthropic image
29
- // source formats so apps can switch providers without rewriting.
30
- export { buildMessageWithImages, normalizeMessagesForProvider } from './utils/vision';
31
- // HTTP retry helper for 429/5xx (stacksjs/stacks#1878 A-5).
32
- export { fetchWithRetry } from './utils/retry';
33
- // Usage tracking (stacksjs/stacks#1878 A-6). Apps install reporters
34
- // via `onUsage(fn)`; drivers fire `recordUsage(...)` per completion.
35
- // Default with no reporters is a no-op.
36
- export { clearUsageReporters, listUsageReporters, onUsage, recordUsage } from './utils/usage';
37
- // Token estimation + prompt-injection heuristics (stacksjs/stacks#1878 A-7).
38
- export { estimateMessageTokens, estimateTokens, sanitizePrompt } from './utils/tokens';
39
- export * from './utils/model-access';