@majkapp/plugin-kit 3.5.3 → 3.5.5
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/README.md +67 -0
- package/bin/promptable-cli.js +12 -0
- package/dist/generator/cli.js +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/majk-interface-types.d.ts +380 -0
- package/dist/majk-interface-types.d.ts.map +1 -1
- package/dist/majk-interface-types.js +15 -0
- package/dist/transports.d.ts +59 -0
- package/dist/transports.d.ts.map +1 -0
- package/dist/transports.js +171 -0
- package/docs/AI.md +830 -0
- package/docs/FULL.md +233 -5
- package/docs/INDEX.md +2 -0
- package/docs/TEAMMATES.md +585 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -365,6 +365,7 @@ The main MAJK API:
|
|
|
365
365
|
|
|
366
366
|
```typescript
|
|
367
367
|
interface MajkInterface {
|
|
368
|
+
ai: AIAPI; // AI providers and LLMs
|
|
368
369
|
conversations: ConversationAPI;
|
|
369
370
|
todos: TodoAPI;
|
|
370
371
|
projects: ProjectAPI;
|
|
@@ -379,6 +380,72 @@ interface MajkInterface {
|
|
|
379
380
|
}
|
|
380
381
|
```
|
|
381
382
|
|
|
383
|
+
### AI API
|
|
384
|
+
|
|
385
|
+
Access AI providers and language models:
|
|
386
|
+
|
|
387
|
+
```typescript
|
|
388
|
+
// Get the default LLM
|
|
389
|
+
const llm = ctx.majk.ai.getDefaultLLM();
|
|
390
|
+
|
|
391
|
+
// Send a prompt
|
|
392
|
+
const result = await llm.prompt({
|
|
393
|
+
messages: [
|
|
394
|
+
{ role: 'system', content: 'You are a helpful assistant' },
|
|
395
|
+
{ role: 'user', content: 'What is 2+2?' }
|
|
396
|
+
],
|
|
397
|
+
temperature: 0.7,
|
|
398
|
+
maxTokens: 100
|
|
399
|
+
});
|
|
400
|
+
|
|
401
|
+
console.log(result.content); // "4"
|
|
402
|
+
|
|
403
|
+
// Stream responses
|
|
404
|
+
const stream = llm.promptStream({
|
|
405
|
+
messages: [{ role: 'user', content: 'Tell me a story' }]
|
|
406
|
+
});
|
|
407
|
+
|
|
408
|
+
for await (const chunk of stream) {
|
|
409
|
+
if (chunk.type === 'content_delta') {
|
|
410
|
+
process.stdout.write(chunk.content);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
// List available providers
|
|
415
|
+
const providers = ctx.majk.ai.listProviders();
|
|
416
|
+
console.log(`Available: ${providers.map(p => p.name).join(', ')}`);
|
|
417
|
+
|
|
418
|
+
// Get specific provider
|
|
419
|
+
const bedrock = ctx.majk.ai.getProvider('bedrock');
|
|
420
|
+
if (bedrock) {
|
|
421
|
+
const claude = bedrock.getLLM('anthropic.claude-3-5-sonnet-20241022-v2:0');
|
|
422
|
+
// Use Claude...
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
// Query by capability
|
|
426
|
+
const imageProviders = ctx.majk.ai.getProvidersWithCapability('imageGeneration');
|
|
427
|
+
if (imageProviders.length > 0) {
|
|
428
|
+
const image = await imageProviders[0].generateImage({
|
|
429
|
+
prompt: 'A beautiful sunset over mountains'
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
**Key Features:**
|
|
435
|
+
- **Provider-agnostic**: Works with OpenAI, Anthropic, Bedrock, local models, etc.
|
|
436
|
+
- **Streaming support**: Real-time response streaming
|
|
437
|
+
- **Function calling**: LLM can invoke functions
|
|
438
|
+
- **Structured output**: JSON schema enforcement
|
|
439
|
+
- **Advanced capabilities**: Image generation, embeddings, transcription
|
|
440
|
+
- **Capability discovery**: Query providers by features
|
|
441
|
+
|
|
442
|
+
**Use Cases:**
|
|
443
|
+
- Add AI features to your plugin
|
|
444
|
+
- Create AI-powered tools
|
|
445
|
+
- Build custom AI workflows
|
|
446
|
+
- Integrate multiple AI providers
|
|
447
|
+
- Generate content, analyze data, summarize text
|
|
448
|
+
|
|
382
449
|
### PluginStorage
|
|
383
450
|
|
|
384
451
|
Simple key-value storage scoped to your plugin:
|
package/bin/promptable-cli.js
CHANGED
|
@@ -58,6 +58,18 @@ cli.addCommand('--services',
|
|
|
58
58
|
{ description: 'Organize functions by service' }
|
|
59
59
|
);
|
|
60
60
|
|
|
61
|
+
// Teammates
|
|
62
|
+
cli.addCommand('--teammates',
|
|
63
|
+
cli.createFullDocCommand('TEAMMATES.md'),
|
|
64
|
+
{ description: 'AI teammates and agents' }
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
// AI API
|
|
68
|
+
cli.addCommand('--ai',
|
|
69
|
+
cli.createFullDocCommand('AI.md'),
|
|
70
|
+
{ description: 'AI providers and LLMs' }
|
|
71
|
+
);
|
|
72
|
+
|
|
61
73
|
// Lifecycle hooks
|
|
62
74
|
cli.addCommand('--lifecycle',
|
|
63
75
|
cli.createFullDocCommand('LIFECYCLE.md'),
|
package/dist/generator/cli.js
CHANGED
|
@@ -171,6 +171,7 @@ commander_1.program
|
|
|
171
171
|
.option('--llm:hooks', 'Show generated hooks documentation')
|
|
172
172
|
.option('--llm:context', 'Show context API documentation')
|
|
173
173
|
.option('--llm:services', 'Show service grouping documentation')
|
|
174
|
+
.option('--llm:teammates', 'Show AI teammates documentation')
|
|
174
175
|
.option('--llm:lifecycle', 'Show lifecycle hooks documentation')
|
|
175
176
|
.option('--llm:testing', 'Show testing guide')
|
|
176
177
|
.option('--llm:config', 'Show project configuration guide')
|
package/dist/index.d.ts
CHANGED
|
@@ -19,5 +19,5 @@ export { FunctionRegistryImpl, FunctionProviderImpl } from './registry';
|
|
|
19
19
|
export { FilesystemResourceProvider } from './resource-provider';
|
|
20
20
|
export { generateClient } from './generator/generator';
|
|
21
21
|
export type { PluginContext, PluginLogger, PluginStorage, ScopedTimers, ScopedIpcRegistry, PluginCapabilities, PluginCapability, ToolImplementation, InProcessPlugin, PluginHealthStatus, ToolSpec, ToolHandler, ApiMethod, ApiRouteDef, JsonSchema, RouteHandler, RequestLike, ResponseLike, UiConfig, HistoryMode, ScreenBase, ReactScreen, HtmlScreen, ConfigWizardDef, SettingsDef, Scope, EntityType, CleanupFn, HealthCheckFn, MCPServerEntity, TeamMemberEntity, ServiceFunctionBinding, FunctionHandler, SubscriptionHandler, FunctionDefinition, SubscriptionDefinition, FunctionRegistry, ClientGenerationConfig, Plugin, FunctionProvider, ResourceProvider, FunctionInfo, AsyncPluginHealthStatus, ServiceCapability, ServiceMetadata, ServiceFunctionMetadata, ServiceParameterMetadata, ServiceReturnMetadata, FunctionEnrichment, IdentityDefinitionCapability, IdentityProviderInfo, IdentitySetupInstructions, IdentityTestConfig, IdentityRequirement } from './types';
|
|
22
|
-
export type { MajkInterface, EntityId, Unsubscribe, BaseEntity, StandardEventType, PluginEventType, RepositoryEventType, EntityType as MajkEntityType, RepositoryEvent, EventFilter, EventListener, Subscription, QueryBuilder, QueryableEventChannel, EventBusAPI, PluginInfo, PluginHealth, PluginCapabilityInfo, PluginLog, InstallPluginOptions, InstallPluginResult, GetLogsOptions, PluginManagementAPI, SecretScope, SecretInfo, ScopedSecretsAPI, SecretsAPI, StartTaskRequest, TaskFilter, TaskMessage, TaskProgress, TaskResult, TaskError, TaskHandle, TaskEventHandler, TaskEvent, TaskAPI, AccountType, AccountMetadata, TimeWindow, CredentialOptions, RefreshOptions, RefreshResult, ValidationResult, TokenInfo, AutoRefreshConfig, AutoRefreshHandle, AwsSdkCredentials, CognitoTokenSet, AzureSdkCredentials, AccountJSON, AwsCognitoCredentials, AzureEntraCredentials, ApiKeyCredentials, SystemDefaultCredentials, Credentials, SystemAccount, OAuthAccount, AwsAccount, AzureAccount, AuthEvent, AuthStateChangeEvent, AuthTokenRefreshedEvent, AuthErrorEvent, AccountChangedEvent, AuthAPI, Message, Conversation, Agent, TeamMember, TeamMemberSkills, TeamMemberPersonality, TeamMemberCodeStats, TeamMemberMetadata, ServiceFunctionBinding as MajkServiceFunctionBinding, Todo, WorkStrategy, Project, MCPServer, ConversationFilter, MessageQueryOptions, ConversationHandle, ConversationAPI, CreateTeammateRequest, TeammateUpdate, TeammateFilter, TeammateHandle, TeammateAPI, CreateTodoRequest, TodoUpdate, TodoFilter, SpawnOptions, TodoHandle, TodoAPI, CreateProjectRequest, ProjectUpdate, ProjectFilter, ProjectHandle, ProjectAPI, CreateMCPServerRequest, MCPServerUpdate, MCPServerFilter, ConnectionTestResult, MCPServerHandle, MCPServerScopedHandle, DiscoveredTool, MCPServerAPI, EverywhereScope, EverywhereScopedHandle, CreateAgentRequest, AgentUpdate, AgentFilter, TestResult, AgentHandle, AgentAPI, AddKnowledgeInput, KnowledgeNode, KnowledgeTree, KnowledgeSearchOptions, KnowledgeAPI } from './majk-interface-types';
|
|
22
|
+
export type { MajkInterface, EntityId, Unsubscribe, BaseEntity, StandardEventType, PluginEventType, RepositoryEventType, EntityType as MajkEntityType, RepositoryEvent, EventFilter, EventListener, Subscription, QueryBuilder, QueryableEventChannel, EventBusAPI, PluginInfo, PluginHealth, PluginCapabilityInfo, PluginLog, InstallPluginOptions, InstallPluginResult, GetLogsOptions, PluginManagementAPI, SecretScope, SecretInfo, ScopedSecretsAPI, SecretsAPI, StartTaskRequest, TaskFilter, TaskMessage, TaskProgress, TaskResult, TaskError, TaskHandle, TaskEventHandler, TaskEvent, TaskAPI, AccountType, AccountMetadata, TimeWindow, CredentialOptions, RefreshOptions, RefreshResult, ValidationResult, TokenInfo, AutoRefreshConfig, AutoRefreshHandle, AwsSdkCredentials, CognitoTokenSet, AzureSdkCredentials, AccountJSON, AwsCognitoCredentials, AzureEntraCredentials, ApiKeyCredentials, SystemDefaultCredentials, Credentials, SystemAccount, OAuthAccount, AwsAccount, AzureAccount, AuthEvent, AuthStateChangeEvent, AuthTokenRefreshedEvent, AuthErrorEvent, AccountChangedEvent, AuthAPI, Message, Conversation, Agent, TeamMember, TeamMemberSkills, TeamMemberPersonality, TeamMemberCodeStats, TeamMemberMetadata, ServiceFunctionBinding as MajkServiceFunctionBinding, Todo, WorkStrategy, Project, MCPServer, ConversationFilter, MessageQueryOptions, ConversationHandle, ConversationAPI, CreateTeammateRequest, TeammateUpdate, TeammateFilter, TeammateHandle, TeammateAPI, CreateTodoRequest, TodoUpdate, TodoFilter, SpawnOptions, TodoHandle, TodoAPI, CreateProjectRequest, ProjectUpdate, ProjectFilter, ProjectHandle, ProjectAPI, CreateMCPServerRequest, MCPServerUpdate, MCPServerFilter, ConnectionTestResult, MCPServerHandle, MCPServerScopedHandle, DiscoveredTool, MCPServerAPI, EverywhereScope, EverywhereScopedHandle, CreateAgentRequest, AgentUpdate, AgentFilter, TestResult, AgentHandle, AgentAPI, AddKnowledgeInput, KnowledgeNode, KnowledgeTree, KnowledgeSearchOptions, KnowledgeAPI, AIAPI, AIProvider, AIProviderCapabilities, AIProviderError, LLMInterface, ModelInfo, AIMessage, ContentBlock, PromptParams, PromptResult, PromptChunk, AIFunctionDefinition, AIJsonSchema, FunctionCallParams, FunctionCallResult, ImageGenerationParams, ImageResult, TranscriptionParams, TranscriptionResult, ProviderStatus } from './majk-interface-types';
|
|
23
23
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC3E,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AACxE,OAAO,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,YAAY,EACV,aAAa,EACb,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,EACf,kBAAkB,EAClB,QAAQ,EACR,WAAW,E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rB,iBAAiB,EACjB,wBAAwB,EACxB,WAAW,EACX,aAAa,EACb,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,SAAS,EACT,oBAAoB,EACpB,uBAAuB,EACvB,cAAc,EACd,mBAAmB,EACnB,OAAO,EACP,OAAO,EACP,YAAY,EACZ,KAAK,EACL,UAAU,EACV,gBAAgB,EAChB,qBAAqB,EACrB,mBAAmB,EACnB,kBAAkB,EAClB,sBAAsB,IAAI,0BAA0B,EACpD,IAAI,EACJ,YAAY,EACZ,OAAO,EACP,SAAS,EACT,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,EAClB,eAAe,EACf,qBAAqB,EACrB,cAAc,EACd,cAAc,EACd,cAAc,EACd,WAAW,EACX,iBAAiB,EACjB,UAAU,EACV,UAAU,EACV,YAAY,EACZ,UAAU,EACV,OAAO,EACP,oBAAoB,EACpB,aAAa,EACb,aAAa,EACb,aAAa,EACb,UAAU,EACV,sBAAsB,EACtB,eAAe,EACf,eAAe,EACf,oBAAoB,EACpB,eAAe,EACf,qBAAqB,EACrB,cAAc,EACd,YAAY,EACZ,eAAe,EACf,sBAAsB,EACtB,kBAAkB,EAClB,WAAW,EACX,WAAW,EACX,UAAU,EACV,WAAW,EACX,QAAQ,EACR,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,sBAAsB,EACtB,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC3E,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AACxE,OAAO,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,YAAY,EACV,aAAa,EACb,YAAY,EACZ,aAAa,EACb,YAAY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6 +1021,385 @@ export interface KnowledgeAPI {
|
|
|
1021
1021
|
getTree(conversationId: string, treeName: string): Promise<KnowledgeTree>;
|
|
1022
1022
|
listTrees(conversationId: string): Promise<string[]>;
|
|
1023
1023
|
}
|
|
1024
|
+
/**
|
|
1025
|
+
* Capabilities that an AI provider may support.
|
|
1026
|
+
* Providers declare which capabilities they implement.
|
|
1027
|
+
*/
|
|
1028
|
+
export interface AIProviderCapabilities {
|
|
1029
|
+
/** Core language model prompting */
|
|
1030
|
+
llm: boolean;
|
|
1031
|
+
/** Image generation (DALL-E, Stable Diffusion, etc.) */
|
|
1032
|
+
imageGeneration?: boolean;
|
|
1033
|
+
/** Text embeddings for semantic search */
|
|
1034
|
+
embeddings?: boolean;
|
|
1035
|
+
/** Audio transcription (Whisper, etc.) */
|
|
1036
|
+
audioTranscription?: boolean;
|
|
1037
|
+
/** Function/tool calling support */
|
|
1038
|
+
functionCalling?: boolean;
|
|
1039
|
+
/** Structured JSON output with schema enforcement */
|
|
1040
|
+
structuredOutput?: boolean;
|
|
1041
|
+
/** Streaming response support */
|
|
1042
|
+
streaming?: boolean;
|
|
1043
|
+
}
|
|
1044
|
+
/**
|
|
1045
|
+
* Information about an AI model
|
|
1046
|
+
*/
|
|
1047
|
+
export interface ModelInfo {
|
|
1048
|
+
/** Model identifier (e.g., "gpt-4", "claude-3-opus") */
|
|
1049
|
+
id: string;
|
|
1050
|
+
/** Human-readable name */
|
|
1051
|
+
name: string;
|
|
1052
|
+
/** Model description */
|
|
1053
|
+
description?: string;
|
|
1054
|
+
/** Context window size in tokens */
|
|
1055
|
+
contextWindow?: number;
|
|
1056
|
+
/** Supported capabilities */
|
|
1057
|
+
capabilities?: Partial<AIProviderCapabilities>;
|
|
1058
|
+
/** Pricing information (optional) */
|
|
1059
|
+
pricing?: {
|
|
1060
|
+
inputTokens?: number;
|
|
1061
|
+
outputTokens?: number;
|
|
1062
|
+
};
|
|
1063
|
+
}
|
|
1064
|
+
/**
|
|
1065
|
+
* Message in a conversation with an LLM
|
|
1066
|
+
*/
|
|
1067
|
+
export interface AIMessage {
|
|
1068
|
+
/** Role of the message sender */
|
|
1069
|
+
role: 'system' | 'user' | 'assistant';
|
|
1070
|
+
/** Message content (string or structured blocks) */
|
|
1071
|
+
content: string | ContentBlock[];
|
|
1072
|
+
/** Optional message name (for function calls) */
|
|
1073
|
+
name?: string;
|
|
1074
|
+
}
|
|
1075
|
+
/**
|
|
1076
|
+
* Structured content block (images, tool use, etc.)
|
|
1077
|
+
*/
|
|
1078
|
+
export interface ContentBlock {
|
|
1079
|
+
/** Type of content */
|
|
1080
|
+
type: 'text' | 'image' | 'tool_use' | 'tool_result';
|
|
1081
|
+
/** Block-specific data */
|
|
1082
|
+
[key: string]: any;
|
|
1083
|
+
}
|
|
1084
|
+
/**
|
|
1085
|
+
* Parameters for LLM prompting
|
|
1086
|
+
*/
|
|
1087
|
+
export interface PromptParams {
|
|
1088
|
+
/** Conversation messages */
|
|
1089
|
+
messages: AIMessage[];
|
|
1090
|
+
/** Sampling temperature (0-1, higher = more random) */
|
|
1091
|
+
temperature?: number;
|
|
1092
|
+
/** Maximum tokens to generate */
|
|
1093
|
+
maxTokens?: number;
|
|
1094
|
+
/** Stop sequences */
|
|
1095
|
+
stopSequences?: string[];
|
|
1096
|
+
/** Top-p sampling */
|
|
1097
|
+
topP?: number;
|
|
1098
|
+
/** System prompt override (if not in messages) */
|
|
1099
|
+
system?: string;
|
|
1100
|
+
/** Provider-specific metadata */
|
|
1101
|
+
metadata?: Record<string, any>;
|
|
1102
|
+
}
|
|
1103
|
+
/**
|
|
1104
|
+
* Result from an LLM prompt
|
|
1105
|
+
*/
|
|
1106
|
+
export interface PromptResult {
|
|
1107
|
+
/** Generated text content */
|
|
1108
|
+
content: string;
|
|
1109
|
+
/** Structured content blocks (if any) */
|
|
1110
|
+
contentBlocks?: ContentBlock[];
|
|
1111
|
+
/** Stop reason */
|
|
1112
|
+
stopReason?: 'end_turn' | 'max_tokens' | 'stop_sequence' | 'tool_use';
|
|
1113
|
+
/** Token usage information */
|
|
1114
|
+
usage?: {
|
|
1115
|
+
inputTokens: number;
|
|
1116
|
+
outputTokens: number;
|
|
1117
|
+
totalTokens: number;
|
|
1118
|
+
};
|
|
1119
|
+
/** Provider-specific metadata */
|
|
1120
|
+
metadata?: Record<string, any>;
|
|
1121
|
+
}
|
|
1122
|
+
/**
|
|
1123
|
+
* Streaming chunk from an LLM
|
|
1124
|
+
*/
|
|
1125
|
+
export interface PromptChunk {
|
|
1126
|
+
/** Chunk type */
|
|
1127
|
+
type: 'content_start' | 'content_delta' | 'content_end' | 'message_start' | 'message_end';
|
|
1128
|
+
/** Partial content (for delta chunks) */
|
|
1129
|
+
content?: string;
|
|
1130
|
+
/** Content block (for structured content) */
|
|
1131
|
+
contentBlock?: ContentBlock;
|
|
1132
|
+
/** Final message (for message_end) */
|
|
1133
|
+
message?: PromptResult;
|
|
1134
|
+
}
|
|
1135
|
+
/**
|
|
1136
|
+
* Function definition for function calling
|
|
1137
|
+
*/
|
|
1138
|
+
export interface AIFunctionDefinition {
|
|
1139
|
+
/** Function name */
|
|
1140
|
+
name: string;
|
|
1141
|
+
/** Function description */
|
|
1142
|
+
description: string;
|
|
1143
|
+
/** Parameter schema (JSON Schema) */
|
|
1144
|
+
parameters: AIJsonSchema;
|
|
1145
|
+
}
|
|
1146
|
+
/**
|
|
1147
|
+
* JSON Schema for structured output
|
|
1148
|
+
*/
|
|
1149
|
+
export interface AIJsonSchema {
|
|
1150
|
+
type: string;
|
|
1151
|
+
properties?: Record<string, any>;
|
|
1152
|
+
required?: string[];
|
|
1153
|
+
[key: string]: any;
|
|
1154
|
+
}
|
|
1155
|
+
/**
|
|
1156
|
+
* Parameters for function calling
|
|
1157
|
+
*/
|
|
1158
|
+
export interface FunctionCallParams extends PromptParams {
|
|
1159
|
+
/** Available functions */
|
|
1160
|
+
functions: AIFunctionDefinition[];
|
|
1161
|
+
/** Force a specific function to be called */
|
|
1162
|
+
functionCall?: 'auto' | 'none' | {
|
|
1163
|
+
name: string;
|
|
1164
|
+
};
|
|
1165
|
+
}
|
|
1166
|
+
/**
|
|
1167
|
+
* Result from a function call
|
|
1168
|
+
*/
|
|
1169
|
+
export interface FunctionCallResult extends PromptResult {
|
|
1170
|
+
/** Function call details (if model invoked a function) */
|
|
1171
|
+
functionCall?: {
|
|
1172
|
+
name: string;
|
|
1173
|
+
arguments: Record<string, any>;
|
|
1174
|
+
};
|
|
1175
|
+
}
|
|
1176
|
+
/**
|
|
1177
|
+
* Parameters for image generation
|
|
1178
|
+
*/
|
|
1179
|
+
export interface ImageGenerationParams {
|
|
1180
|
+
/** Image generation prompt */
|
|
1181
|
+
prompt: string;
|
|
1182
|
+
/** Negative prompt (what to avoid) */
|
|
1183
|
+
negativePrompt?: string;
|
|
1184
|
+
/** Image size */
|
|
1185
|
+
size?: string;
|
|
1186
|
+
/** Number of images to generate */
|
|
1187
|
+
n?: number;
|
|
1188
|
+
/** Quality/detail level */
|
|
1189
|
+
quality?: 'standard' | 'hd';
|
|
1190
|
+
/** Style preset */
|
|
1191
|
+
style?: string;
|
|
1192
|
+
/** Provider-specific parameters */
|
|
1193
|
+
metadata?: Record<string, any>;
|
|
1194
|
+
}
|
|
1195
|
+
/**
|
|
1196
|
+
* Result from image generation
|
|
1197
|
+
*/
|
|
1198
|
+
export interface ImageResult {
|
|
1199
|
+
/** Generated image URLs or data URLs */
|
|
1200
|
+
images: string[];
|
|
1201
|
+
/** Revised prompt (if provider modified it) */
|
|
1202
|
+
revisedPrompt?: string;
|
|
1203
|
+
/** Generation metadata */
|
|
1204
|
+
metadata?: Record<string, any>;
|
|
1205
|
+
}
|
|
1206
|
+
/**
|
|
1207
|
+
* Parameters for audio transcription
|
|
1208
|
+
*/
|
|
1209
|
+
export interface TranscriptionParams {
|
|
1210
|
+
/** Audio data buffer */
|
|
1211
|
+
audio: Buffer;
|
|
1212
|
+
/** Audio format */
|
|
1213
|
+
format?: 'mp3' | 'wav' | 'webm' | 'ogg';
|
|
1214
|
+
/** Language hint (ISO 639-1) */
|
|
1215
|
+
language?: string;
|
|
1216
|
+
/** Include timestamps */
|
|
1217
|
+
timestamps?: boolean;
|
|
1218
|
+
}
|
|
1219
|
+
/**
|
|
1220
|
+
* Result from audio transcription
|
|
1221
|
+
*/
|
|
1222
|
+
export interface TranscriptionResult {
|
|
1223
|
+
/** Transcribed text */
|
|
1224
|
+
text: string;
|
|
1225
|
+
/** Language detected */
|
|
1226
|
+
language?: string;
|
|
1227
|
+
/** Word-level timestamps (if requested) */
|
|
1228
|
+
timestamps?: Array<{
|
|
1229
|
+
word: string;
|
|
1230
|
+
start: number;
|
|
1231
|
+
end: number;
|
|
1232
|
+
}>;
|
|
1233
|
+
/** Confidence score */
|
|
1234
|
+
confidence?: number;
|
|
1235
|
+
}
|
|
1236
|
+
/**
|
|
1237
|
+
* Core interface for language model operations.
|
|
1238
|
+
* Represents a specific model from a provider.
|
|
1239
|
+
*/
|
|
1240
|
+
export interface LLMInterface {
|
|
1241
|
+
/** Provider identifier */
|
|
1242
|
+
readonly provider: string;
|
|
1243
|
+
/** Model identifier */
|
|
1244
|
+
readonly model: string;
|
|
1245
|
+
/**
|
|
1246
|
+
* Send a prompt to the model
|
|
1247
|
+
* @param params - Prompt parameters
|
|
1248
|
+
* @returns Promise resolving to the model's response
|
|
1249
|
+
* @throws AIProviderError if the request fails
|
|
1250
|
+
*/
|
|
1251
|
+
prompt(params: PromptParams): Promise<PromptResult>;
|
|
1252
|
+
/**
|
|
1253
|
+
* Send a prompt with streaming response
|
|
1254
|
+
* @param params - Prompt parameters
|
|
1255
|
+
* @returns Async iterator of response chunks
|
|
1256
|
+
* @throws AIProviderError if the request fails
|
|
1257
|
+
*/
|
|
1258
|
+
promptStream(params: PromptParams): AsyncIterableIterator<PromptChunk>;
|
|
1259
|
+
/**
|
|
1260
|
+
* Prompt for structured JSON output
|
|
1261
|
+
* @param params - Prompt parameters with optional schema
|
|
1262
|
+
* @returns Promise resolving to parsed JSON
|
|
1263
|
+
* @throws AIProviderError if the request fails or JSON is invalid
|
|
1264
|
+
*/
|
|
1265
|
+
promptForJson<T = any>(params: PromptParams & {
|
|
1266
|
+
schema?: AIJsonSchema;
|
|
1267
|
+
}): Promise<T>;
|
|
1268
|
+
/**
|
|
1269
|
+
* Prompt with function calling
|
|
1270
|
+
* @param params - Prompt parameters with function definitions
|
|
1271
|
+
* @returns Promise resolving to response with optional function call
|
|
1272
|
+
* @throws AIProviderError if the request fails
|
|
1273
|
+
*/
|
|
1274
|
+
functionCall(params: FunctionCallParams): Promise<FunctionCallResult>;
|
|
1275
|
+
}
|
|
1276
|
+
/**
|
|
1277
|
+
* Provider health and status information
|
|
1278
|
+
*/
|
|
1279
|
+
export interface ProviderStatus {
|
|
1280
|
+
/** Is the provider available? */
|
|
1281
|
+
available: boolean;
|
|
1282
|
+
/** Is authentication configured and valid? */
|
|
1283
|
+
authenticated: boolean;
|
|
1284
|
+
/** Rate limit remaining (if applicable) */
|
|
1285
|
+
rateLimitRemaining?: number;
|
|
1286
|
+
/** Last error message (if any) */
|
|
1287
|
+
lastError?: string;
|
|
1288
|
+
/** Last successful request timestamp */
|
|
1289
|
+
lastSuccess?: Date;
|
|
1290
|
+
/** Provider-specific status info */
|
|
1291
|
+
metadata?: Record<string, any>;
|
|
1292
|
+
}
|
|
1293
|
+
/**
|
|
1294
|
+
* Main AI provider interface.
|
|
1295
|
+
* Plugins implement this to provide AI capabilities.
|
|
1296
|
+
*/
|
|
1297
|
+
export interface AIProvider {
|
|
1298
|
+
/** Unique provider identifier (e.g., "openai", "anthropic") */
|
|
1299
|
+
readonly id: string;
|
|
1300
|
+
/** Human-readable provider name */
|
|
1301
|
+
readonly name: string;
|
|
1302
|
+
/** Declared capabilities */
|
|
1303
|
+
readonly capabilities: AIProviderCapabilities;
|
|
1304
|
+
/**
|
|
1305
|
+
* Get an LLM interface for a specific model
|
|
1306
|
+
* @param model - Model identifier (optional, uses provider default if omitted)
|
|
1307
|
+
* @returns LLM interface for prompting
|
|
1308
|
+
* @throws AIProviderError if model is not available
|
|
1309
|
+
*/
|
|
1310
|
+
getLLM(model?: string): LLMInterface;
|
|
1311
|
+
/**
|
|
1312
|
+
* List available models
|
|
1313
|
+
* @returns Promise resolving to array of model information
|
|
1314
|
+
* @throws AIProviderError if listing fails
|
|
1315
|
+
*/
|
|
1316
|
+
listModels(): Promise<ModelInfo[]>;
|
|
1317
|
+
/**
|
|
1318
|
+
* Generate an image (if provider supports it)
|
|
1319
|
+
* @param params - Image generation parameters
|
|
1320
|
+
* @returns Promise resolving to generated images
|
|
1321
|
+
* @throws AIProviderError if not supported or generation fails
|
|
1322
|
+
*/
|
|
1323
|
+
generateImage?(params: ImageGenerationParams): Promise<ImageResult>;
|
|
1324
|
+
/**
|
|
1325
|
+
* Generate text embeddings (if provider supports it)
|
|
1326
|
+
* @param text - Text to embed
|
|
1327
|
+
* @returns Promise resolving to embedding vector
|
|
1328
|
+
* @throws AIProviderError if not supported or generation fails
|
|
1329
|
+
*/
|
|
1330
|
+
generateEmbedding?(text: string): Promise<number[]>;
|
|
1331
|
+
/**
|
|
1332
|
+
* Transcribe audio (if provider supports it)
|
|
1333
|
+
* @param params - Transcription parameters
|
|
1334
|
+
* @returns Promise resolving to transcription
|
|
1335
|
+
* @throws AIProviderError if not supported or transcription fails
|
|
1336
|
+
*/
|
|
1337
|
+
transcribeAudio?(params: TranscriptionParams): Promise<TranscriptionResult>;
|
|
1338
|
+
}
|
|
1339
|
+
/**
|
|
1340
|
+
* Main AI API exposed via majk.ai
|
|
1341
|
+
* Provides access to registered AI providers and convenience methods.
|
|
1342
|
+
*/
|
|
1343
|
+
export interface AIAPI {
|
|
1344
|
+
/**
|
|
1345
|
+
* Get a specific AI provider by ID
|
|
1346
|
+
* @param providerId - Provider identifier (e.g., "openai", "anthropic")
|
|
1347
|
+
* @returns Provider instance or undefined if not found
|
|
1348
|
+
*/
|
|
1349
|
+
getProvider(providerId: string): AIProvider | undefined;
|
|
1350
|
+
/**
|
|
1351
|
+
* List all registered providers
|
|
1352
|
+
* @returns Array of all available providers
|
|
1353
|
+
*/
|
|
1354
|
+
listProviders(): AIProvider[];
|
|
1355
|
+
/**
|
|
1356
|
+
* Get the default AI provider
|
|
1357
|
+
* @returns Default provider
|
|
1358
|
+
* @throws AIProviderError if no providers are registered
|
|
1359
|
+
*/
|
|
1360
|
+
getDefaultProvider(): AIProvider;
|
|
1361
|
+
/**
|
|
1362
|
+
* Set the default provider
|
|
1363
|
+
* @param providerId - Provider ID to set as default
|
|
1364
|
+
* @throws AIProviderError if provider not found
|
|
1365
|
+
*/
|
|
1366
|
+
setDefaultProvider(providerId: string): Promise<void>;
|
|
1367
|
+
/**
|
|
1368
|
+
* Get an LLM from the default provider
|
|
1369
|
+
* @param model - Optional model identifier
|
|
1370
|
+
* @returns LLM interface using default provider
|
|
1371
|
+
* @throws AIProviderError if no providers registered
|
|
1372
|
+
*/
|
|
1373
|
+
getLLM(model?: string): LLMInterface;
|
|
1374
|
+
/**
|
|
1375
|
+
* Get the default LLM (default provider, default model)
|
|
1376
|
+
* @returns LLM interface with all defaults
|
|
1377
|
+
* @throws AIProviderError if no providers registered
|
|
1378
|
+
*/
|
|
1379
|
+
getDefaultLLM(): LLMInterface;
|
|
1380
|
+
/**
|
|
1381
|
+
* Get all providers that support a specific capability
|
|
1382
|
+
* @param capability - Capability to filter by
|
|
1383
|
+
* @returns Array of providers supporting the capability
|
|
1384
|
+
*/
|
|
1385
|
+
getProvidersWithCapability(capability: keyof AIProviderCapabilities): AIProvider[];
|
|
1386
|
+
/**
|
|
1387
|
+
* Get provider status and health information
|
|
1388
|
+
* @param providerId - Provider to check
|
|
1389
|
+
* @returns Promise resolving to status information
|
|
1390
|
+
*/
|
|
1391
|
+
getProviderStatus(providerId: string): Promise<ProviderStatus>;
|
|
1392
|
+
}
|
|
1393
|
+
/**
|
|
1394
|
+
* Standard error class for AI provider operations
|
|
1395
|
+
*/
|
|
1396
|
+
export declare class AIProviderError extends Error {
|
|
1397
|
+
readonly providerId?: string | undefined;
|
|
1398
|
+
readonly code?: string | undefined;
|
|
1399
|
+
readonly statusCode?: number | undefined;
|
|
1400
|
+
readonly cause?: Error | undefined;
|
|
1401
|
+
constructor(message: string, providerId?: string | undefined, code?: string | undefined, statusCode?: number | undefined, cause?: Error | undefined);
|
|
1402
|
+
}
|
|
1024
1403
|
export interface MajkInterface {
|
|
1025
1404
|
readonly version: string;
|
|
1026
1405
|
readonly plugins: PluginManagementAPI;
|
|
@@ -1028,6 +1407,7 @@ export interface MajkInterface {
|
|
|
1028
1407
|
readonly tasks: TaskAPI;
|
|
1029
1408
|
readonly eventBus: EventBusAPI;
|
|
1030
1409
|
readonly auth: AuthAPI;
|
|
1410
|
+
readonly ai: AIAPI;
|
|
1031
1411
|
readonly conversations: ConversationAPI;
|
|
1032
1412
|
readonly todos: TodoAPI;
|
|
1033
1413
|
readonly projects: ProjectAPI;
|