@intella/sdk 0.0.1 → 0.0.2

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.
Files changed (120) hide show
  1. package/dist/agent-manager.d.ts +47 -0
  2. package/dist/agent-manager.d.ts.map +1 -0
  3. package/dist/agent-manager.js +90 -0
  4. package/dist/agent-manager.js.map +1 -0
  5. package/dist/agents/base-agent.d.ts +41 -0
  6. package/dist/agents/base-agent.d.ts.map +1 -0
  7. package/dist/agents/base-agent.js +139 -0
  8. package/dist/agents/base-agent.js.map +1 -0
  9. package/dist/agents/claude-agent.d.ts +24 -0
  10. package/dist/agents/claude-agent.d.ts.map +1 -0
  11. package/dist/agents/claude-agent.js +65 -0
  12. package/dist/agents/claude-agent.js.map +1 -0
  13. package/dist/agents/codex-agent.d.ts +25 -0
  14. package/dist/agents/codex-agent.d.ts.map +1 -0
  15. package/dist/agents/codex-agent.js +62 -0
  16. package/dist/agents/codex-agent.js.map +1 -0
  17. package/dist/agents/intella-lite-agent.d.ts +21 -0
  18. package/dist/agents/intella-lite-agent.d.ts.map +1 -0
  19. package/dist/agents/intella-lite-agent.js +43 -0
  20. package/dist/agents/intella-lite-agent.js.map +1 -0
  21. package/dist/agents/opencode-agent.d.ts +20 -0
  22. package/dist/agents/opencode-agent.d.ts.map +1 -0
  23. package/dist/agents/opencode-agent.js +36 -0
  24. package/dist/agents/opencode-agent.js.map +1 -0
  25. package/dist/filesystem/agentfs-provider.d.ts +42 -0
  26. package/dist/filesystem/agentfs-provider.d.ts.map +1 -0
  27. package/dist/filesystem/agentfs-provider.js +308 -0
  28. package/dist/filesystem/agentfs-provider.js.map +1 -0
  29. package/dist/filesystem/base-provider.d.ts +55 -0
  30. package/dist/filesystem/base-provider.d.ts.map +1 -0
  31. package/dist/filesystem/base-provider.js +44 -0
  32. package/dist/filesystem/base-provider.js.map +1 -0
  33. package/dist/filesystem/index.d.ts +4 -0
  34. package/dist/filesystem/index.d.ts.map +1 -0
  35. package/{src/filesystem/index.ts → dist/filesystem/index.js} +1 -1
  36. package/dist/filesystem/index.js.map +1 -0
  37. package/dist/filesystem/memory-provider.d.ts +44 -0
  38. package/dist/filesystem/memory-provider.d.ts.map +1 -0
  39. package/dist/filesystem/memory-provider.js +227 -0
  40. package/dist/filesystem/memory-provider.js.map +1 -0
  41. package/dist/filesystem-manager.d.ts +75 -0
  42. package/dist/filesystem-manager.d.ts.map +1 -0
  43. package/dist/filesystem-manager.js +164 -0
  44. package/dist/filesystem-manager.js.map +1 -0
  45. package/dist/index.d.ts +18 -0
  46. package/dist/index.d.ts.map +1 -0
  47. package/{src/index.ts → dist/index.js} +3 -46
  48. package/dist/index.js.map +1 -0
  49. package/dist/orchestrator.d.ts +32 -0
  50. package/dist/orchestrator.d.ts.map +1 -0
  51. package/dist/orchestrator.js +136 -0
  52. package/dist/orchestrator.js.map +1 -0
  53. package/dist/sandbox/base-provider.d.ts +106 -0
  54. package/dist/sandbox/base-provider.d.ts.map +1 -0
  55. package/dist/sandbox/base-provider.js +73 -0
  56. package/dist/sandbox/base-provider.js.map +1 -0
  57. package/dist/sandbox/daytona-provider.d.ts +93 -0
  58. package/dist/sandbox/daytona-provider.d.ts.map +1 -0
  59. package/dist/sandbox/daytona-provider.js +378 -0
  60. package/dist/sandbox/daytona-provider.js.map +1 -0
  61. package/dist/sandbox/e2b-provider.d.ts +85 -0
  62. package/dist/sandbox/e2b-provider.d.ts.map +1 -0
  63. package/dist/sandbox/e2b-provider.js +342 -0
  64. package/dist/sandbox/e2b-provider.js.map +1 -0
  65. package/dist/sandbox/modal-provider.d.ts +92 -0
  66. package/dist/sandbox/modal-provider.d.ts.map +1 -0
  67. package/dist/sandbox/modal-provider.js +516 -0
  68. package/dist/sandbox/modal-provider.js.map +1 -0
  69. package/dist/sandbox-manager.d.ts +59 -0
  70. package/dist/sandbox-manager.d.ts.map +1 -0
  71. package/dist/sandbox-manager.js +141 -0
  72. package/dist/sandbox-manager.js.map +1 -0
  73. package/dist/sdk.d.ts +173 -0
  74. package/dist/sdk.d.ts.map +1 -0
  75. package/dist/sdk.js +273 -0
  76. package/dist/sdk.js.map +1 -0
  77. package/dist/types.d.ts +419 -0
  78. package/dist/types.d.ts.map +1 -0
  79. package/dist/types.js +2 -0
  80. package/dist/types.js.map +1 -0
  81. package/dist/utils/code-extractor.d.ts +103 -0
  82. package/dist/utils/code-extractor.d.ts.map +1 -0
  83. package/dist/utils/code-extractor.js +133 -0
  84. package/dist/utils/code-extractor.js.map +1 -0
  85. package/package.json +6 -1
  86. package/examples/claude-code/README.md +0 -178
  87. package/examples/claude-code/advanced-config.ts +0 -55
  88. package/examples/claude-code/basic-usage.ts +0 -56
  89. package/examples/claude-code/model-comparison.ts +0 -50
  90. package/examples/claude-code/orchestration.ts +0 -70
  91. package/examples/claude-code/streaming.ts +0 -69
  92. package/examples/claude-code/tsconfig.json +0 -19
  93. package/examples/code-extractor/README.md +0 -77
  94. package/examples/code-extractor/example.ts +0 -145
  95. package/examples/filesystem/basic-usage.ts +0 -84
  96. package/examples/integrated-task/README.md +0 -68
  97. package/examples/integrated-task/integrated-usage.ts +0 -193
  98. package/examples/integrated-task/simple-example.ts +0 -51
  99. package/examples/integrated-task/tsconfig.json +0 -19
  100. package/examples/sandbox/basic-usage.ts +0 -173
  101. package/src/agent-manager.ts +0 -104
  102. package/src/agents/base-agent.ts +0 -166
  103. package/src/agents/claude-agent.ts +0 -77
  104. package/src/agents/codex-agent.ts +0 -72
  105. package/src/agents/intella-lite-agent.ts +0 -55
  106. package/src/agents/opencode-agent.ts +0 -45
  107. package/src/filesystem/agentfs-provider.ts +0 -328
  108. package/src/filesystem/base-provider.ts +0 -98
  109. package/src/filesystem/memory-provider.ts +0 -267
  110. package/src/filesystem-manager.ts +0 -213
  111. package/src/orchestrator.ts +0 -177
  112. package/src/sandbox/base-provider.ts +0 -184
  113. package/src/sandbox/daytona-provider.ts +0 -462
  114. package/src/sandbox/e2b-provider.ts +0 -419
  115. package/src/sandbox/modal-provider.ts +0 -597
  116. package/src/sandbox-manager.ts +0 -175
  117. package/src/sdk.ts +0 -401
  118. package/src/types.ts +0 -451
  119. package/src/utils/code-extractor.ts +0 -194
  120. package/tsconfig.json +0 -25
@@ -1,173 +0,0 @@
1
- /**
2
- * Basic Sandbox Usage Example
3
- *
4
- * This example demonstrates how to use the sandbox functionality
5
- * with E2B, Daytona, and Modal providers.
6
- *
7
- * Prerequisites:
8
- * - For E2B: Set E2B_API_KEY environment variable
9
- * - For Daytona: Set DAYTONA_API_KEY and DAYTONA_API_URL environment variables
10
- * - For Modal: Set MODAL_TOKEN_ID and MODAL_TOKEN_SECRET environment variables
11
- */
12
-
13
- import { IntellaSDK } from '../../src/index.js';
14
- import 'dotenv/config';
15
-
16
- async function main() {
17
- const sdk = new IntellaSDK();
18
-
19
- console.log('Available sandbox providers:', sdk.listSandboxProviders());
20
-
21
- try {
22
- // Example 1: Using E2B Sandbox
23
- console.log('\n=== E2B Sandbox Example ===');
24
-
25
- await sdk.initializeSandbox('e2b', {
26
- templateId: 'base', // Use 'base' template or your custom template ID
27
- env: {
28
- NODE_ENV: 'development',
29
- },
30
- });
31
-
32
- console.log('E2B Sandbox initialized');
33
-
34
- // Execute a command
35
- const result = await sdk.executeInSandbox('echo "Hello from E2B Sandbox!"');
36
- console.log('Command result:', result.result.stdout);
37
- console.log('Exit code:', result.result.exitCode);
38
-
39
- // Write a file
40
- const sandbox = sdk.getActiveSandbox();
41
- if (sandbox) {
42
- await sandbox.writeFile('/tmp/test.txt', 'Hello, World!');
43
- const content = await sandbox.readFile('/tmp/test.txt');
44
- console.log('File content:', content);
45
- }
46
-
47
- // Close the sandbox
48
- await sdk.closeSandbox();
49
- console.log('E2B Sandbox closed');
50
-
51
- } catch (error) {
52
- console.error('E2B Error:', error);
53
- }
54
-
55
- try {
56
- // Example 2: Using Daytona Sandbox
57
- console.log('\n=== Daytona Sandbox Example ===');
58
-
59
- await sdk.initializeSandbox('daytona', {
60
- templateId: 'default', // Workspace template ID
61
- baseURL: process.env.DAYTONA_API_URL || 'http://localhost:3000',
62
- env: {
63
- NODE_ENV: 'development',
64
- },
65
- });
66
-
67
- console.log('Daytona Sandbox initialized');
68
-
69
- // Execute a command
70
- const result = await sdk.executeInSandbox('echo "Hello from Daytona Sandbox!"');
71
- console.log('Command result:', result.result.stdout);
72
- console.log('Exit code:', result.result.exitCode);
73
-
74
- // Get sandbox status
75
- const sandbox = sdk.getActiveSandbox();
76
- if (sandbox) {
77
- const status = await sandbox.getStatus();
78
- console.log('Sandbox status:', status);
79
-
80
- // Get detailed sandbox information
81
- const info = await sandbox.getInfo();
82
- console.log('Sandbox info:', {
83
- sandboxId: info.sandboxId,
84
- provider: info.provider,
85
- isRunning: info.isRunning,
86
- isInitialized: info.isInitialized,
87
- });
88
- }
89
-
90
- // Close the sandbox
91
- await sdk.closeSandbox();
92
- console.log('Daytona Sandbox closed');
93
-
94
- } catch (error) {
95
- console.error('Daytona Error:', error);
96
- }
97
-
98
- // Example 3: Execute task with sandbox
99
- console.log('\n=== Task Execution with Sandbox ===');
100
-
101
- try {
102
- await sdk.initializeSandbox('e2b', {
103
- templateId: 'base',
104
- });
105
-
106
- // Configure an agent
107
- sdk.selectAgent('claude', {
108
- model: 'sonnet',
109
- });
110
-
111
- // Execute a task and then run it in sandbox
112
- const combinedResult = await sdk.executeTaskInSandbox(
113
- 'Write a simple Python script that prints "Hello, World!"',
114
- 'python3 /tmp/script.py',
115
- 'claude',
116
- {
117
- cwd: '/tmp',
118
- }
119
- );
120
-
121
- console.log('Agent response:', combinedResult.agentResponse.text);
122
- console.log('Sandbox execution:', combinedResult.sandboxResult.result.stdout);
123
-
124
- await sdk.closeSandbox();
125
- } catch (error) {
126
- console.error('Combined execution error:', error);
127
- }
128
-
129
- // Example 4: Connecting to existing sandbox and getting info
130
- console.log('\n=== Connecting to Existing Sandbox ===');
131
-
132
- try {
133
- // First, create a sandbox and get its ID
134
- await sdk.initializeSandbox('e2b', {
135
- templateId: 'base',
136
- });
137
-
138
- const initialSandbox = sdk.getActiveSandbox();
139
- if (initialSandbox) {
140
- const sandboxId = initialSandbox.getSandboxId();
141
- console.log('Created sandbox ID:', sandboxId);
142
-
143
- // Get info for the active sandbox
144
- const info = await initialSandbox.getInfo();
145
- console.log('Sandbox info:', {
146
- sandboxId: info.sandboxId,
147
- provider: info.provider,
148
- isRunning: info.isRunning,
149
- createdAt: info.createdAt,
150
- });
151
-
152
- await sdk.closeSandbox();
153
-
154
- // Now connect to the same sandbox (if it still exists)
155
- // Note: E2B sandboxes are ephemeral, so this may not work
156
- // This example is more useful for Modal and Daytona
157
- try {
158
- await sdk.initializeSandbox('e2b', {
159
- fromSandboxId: sandboxId || '',
160
- });
161
- console.log('Reconnected to existing sandbox');
162
- await sdk.closeSandbox();
163
- } catch (reconnectError) {
164
- console.log('Could not reconnect (sandbox may have expired):', reconnectError);
165
- }
166
- }
167
- } catch (error) {
168
- console.error('Existing sandbox example error:', error);
169
- }
170
- }
171
-
172
- main().catch(console.error);
173
-
@@ -1,104 +0,0 @@
1
- import type { AgentType, AgentConfig, IAgent } from './types.js';
2
- import { IntellaLiteAgent } from './agents/intella-lite-agent.js';
3
- import { ClaudeAgent } from './agents/claude-agent.js';
4
- import { CodexAgent } from './agents/codex-agent.js';
5
- import { OpenCodeAgent } from './agents/opencode-agent.js';
6
-
7
- /**
8
- * Agent Manager
9
- * Manages agent instances and configurations
10
- */
11
- export class AgentManager {
12
- private agents: Map<AgentType, IAgent> = new Map();
13
- private defaultAgentType: AgentType = 'intella-lite';
14
-
15
- constructor() {
16
- // Initialize default agents
17
- this.registerAgent('intella-lite', new IntellaLiteAgent());
18
- this.registerAgent('claude', new ClaudeAgent());
19
- this.registerAgent('codex', new CodexAgent());
20
- this.registerAgent('opencode', new OpenCodeAgent());
21
- }
22
-
23
- /**
24
- * Register or update an agent instance
25
- */
26
- registerAgent(type: AgentType, agent: IAgent): void {
27
- if (agent.type !== type) {
28
- throw new Error(`Agent type mismatch: expected ${type}, got ${agent.type}`);
29
- }
30
- this.agents.set(type, agent);
31
- }
32
-
33
- /**
34
- * Get an agent instance
35
- */
36
- getAgent(type?: AgentType): IAgent {
37
- const agentType = type || this.defaultAgentType;
38
- const agent = this.agents.get(agentType);
39
-
40
- if (!agent) {
41
- throw new Error(`Agent ${agentType} is not registered`);
42
- }
43
-
44
- return agent;
45
- }
46
-
47
- /**
48
- * List all available agents
49
- */
50
- listAgents(): AgentType[] {
51
- return Array.from(this.agents.keys());
52
- }
53
-
54
- /**
55
- * Check if an agent is registered
56
- */
57
- hasAgent(type: AgentType): boolean {
58
- return this.agents.has(type);
59
- }
60
-
61
- /**
62
- * Update agent configuration
63
- */
64
- updateConfig(type: AgentType, config: AgentConfig): void {
65
- const agent = this.getAgent(type);
66
- agent.configure(config);
67
- }
68
-
69
- /**
70
- * Get agent configuration
71
- */
72
- getConfig(type: AgentType): AgentConfig {
73
- const agent = this.getAgent(type);
74
- return agent.getConfig();
75
- }
76
-
77
- /**
78
- * Set the default agent type
79
- */
80
- setDefaultAgent(type: AgentType): void {
81
- if (!this.agents.has(type)) {
82
- throw new Error(`Agent ${type} is not registered`);
83
- }
84
- this.defaultAgentType = type;
85
- }
86
-
87
- /**
88
- * Get the default agent type
89
- */
90
- getDefaultAgentType(): AgentType {
91
- return this.defaultAgentType;
92
- }
93
-
94
- /**
95
- * Remove an agent (cannot remove default agent)
96
- */
97
- removeAgent(type: AgentType): void {
98
- if (type === this.defaultAgentType) {
99
- throw new Error('Cannot remove the default agent');
100
- }
101
- this.agents.delete(type);
102
- }
103
- }
104
-
@@ -1,166 +0,0 @@
1
- import { generateText, streamText, type LanguageModel, type ModelMessage } from 'ai';
2
- import type { AgentType, AgentConfig, TaskRequest, TaskResponse, StreamChunk, IAgent, MessageContent } from '../types.js';
3
-
4
- /**
5
- * Abstract base class for all agents
6
- * Provides common functionality using AI SDK v6
7
- */
8
- export abstract class BaseAgent implements IAgent {
9
- protected config: AgentConfig;
10
- public readonly type: AgentType;
11
-
12
- constructor(type: AgentType, config: AgentConfig = {}) {
13
- this.type = type;
14
- this.config = { ...config };
15
- }
16
-
17
- /**
18
- * Get the language model instance
19
- * Must be implemented by subclasses
20
- */
21
- abstract getModel(): LanguageModel | Promise<LanguageModel>;
22
-
23
- /**
24
- * Execute a task and return the response
25
- */
26
- async execute(request: TaskRequest): Promise<TaskResponse> {
27
- const model = await Promise.resolve(this.getModel());
28
- const messages = this.buildMessages(request);
29
-
30
- const result = await generateText({
31
- model,
32
- messages,
33
- temperature: request.temperature ?? this.config.temperature,
34
- maxOutputTokens: request.maxTokens ?? this.config.maxTokens,
35
- });
36
-
37
- return {
38
- text: result.text,
39
- agentType: this.type,
40
- metadata: {
41
- usage: result.usage,
42
- finishReason: result.finishReason,
43
- },
44
- };
45
- }
46
-
47
- /**
48
- * Stream a task execution
49
- */
50
- async *stream(request: TaskRequest): AsyncIterable<StreamChunk> {
51
- const model = await Promise.resolve(this.getModel());
52
- const messages = this.buildMessages(request);
53
-
54
- const result = streamText({
55
- model,
56
- messages,
57
- temperature: request.temperature ?? this.config.temperature,
58
- maxOutputTokens: request.maxTokens ?? this.config.maxTokens,
59
- });
60
-
61
- let fullText = '';
62
- for await (const chunk of result.textStream) {
63
- fullText += chunk;
64
- yield {
65
- text: chunk,
66
- agentType: this.type,
67
- isDone: false,
68
- };
69
- }
70
-
71
- // Final chunk to indicate completion
72
- yield {
73
- text: '',
74
- agentType: this.type,
75
- isDone: true,
76
- };
77
- }
78
-
79
- /**
80
- * Configure the agent
81
- */
82
- configure(config: AgentConfig): void {
83
- this.config = { ...this.config, ...config };
84
- }
85
-
86
- /**
87
- * Get current configuration
88
- */
89
- getConfig(): AgentConfig {
90
- return { ...this.config };
91
- }
92
-
93
- /**
94
- * Convert TaskRequest content to AI SDK ModelMessage content format
95
- */
96
- private convertContent(content: MessageContent): string | Array<{ type: 'text'; text: string } | { type: 'file'; data: string | Uint8Array | ArrayBuffer | Buffer | URL; filename?: string; mediaType: string }> {
97
- // If content is a string, return as-is
98
- if (typeof content === 'string') {
99
- return content;
100
- }
101
-
102
- // If content is an array, convert to AI SDK format
103
- return content.map(part => {
104
- if (part.type === 'text') {
105
- return {
106
- type: 'text' as const,
107
- text: part.text,
108
- };
109
- } else if (part.type === 'file') {
110
- return {
111
- type: 'file' as const,
112
- data: part.data,
113
- filename: part.filename,
114
- mediaType: part.mediaType,
115
- };
116
- }
117
- // Fallback for unknown types
118
- return {
119
- type: 'text' as const,
120
- text: String(part),
121
- };
122
- });
123
- }
124
-
125
- /**
126
- * Build messages array from request
127
- */
128
- protected buildMessages(request: TaskRequest): ModelMessage[] {
129
- const messages: ModelMessage[] = [];
130
-
131
- // Add system prompt if provided
132
- if (request.systemPrompt) {
133
- messages.push({
134
- role: 'system',
135
- content: request.systemPrompt,
136
- });
137
- }
138
-
139
- // Add previous messages if provided
140
- if (request.messages && request.messages.length > 0) {
141
- for (const msg of request.messages) {
142
- // Skip system messages in the messages array (they're handled separately)
143
- if (msg.role === 'system') {
144
- continue;
145
- }
146
-
147
- messages.push({
148
- role: msg.role,
149
- content: this.convertContent(msg.content),
150
- });
151
- }
152
- }
153
-
154
- // Add the main prompt as user message (only if not empty)
155
- // If prompt is empty, the message is likely already in the messages array
156
- if (request.prompt && request.prompt.trim()) {
157
- messages.push({
158
- role: 'user',
159
- content: request.prompt,
160
- });
161
- }
162
-
163
- return messages;
164
- }
165
- }
166
-
@@ -1,77 +0,0 @@
1
- import { BaseAgent } from './base-agent.js';
2
- import type { AgentConfig } from '../types.js';
3
- import type { LanguageModel } from 'ai';
4
-
5
- import { claudeCode, createClaudeCode, McpServerConfig } from 'ai-sdk-provider-claude-code';
6
-
7
-
8
- /**
9
- * Claude Agent
10
- * Powered by Claude Code provider
11
- */
12
- export class ClaudeAgent extends BaseAgent {
13
- private modelInstance: LanguageModel | null = null;
14
-
15
- constructor(config: AgentConfig = {}) {
16
- super('claude', config);
17
- }
18
-
19
- /**
20
- * Get or create the language model instance
21
- *
22
- * Supports Claude Code provider options:
23
- * - allowedTools, disallowedTools, mcpServers, permissionMode, maxTurns, cwd, verbose
24
- * See: https://ai-sdk.dev/providers/community-providers/claude-code
25
- */
26
- async getModel(): Promise<LanguageModel> {
27
- if (!this.modelInstance) {
28
- // Dynamic import to handle optional peer dependency
29
-
30
- // Claude Code provider takes model ID as string parameter
31
- // Uses CLI authentication (claude login) - API key not needed in code
32
- // Model shortcuts: 'opus', 'sonnet', 'haiku'
33
- const modelId = this.config.model || 'sonnet';
34
-
35
- // Check if custom provider options are provided
36
- const hasCustomOptions =
37
- this.config.allowedTools ||
38
- this.config.disallowedTools ||
39
- this.config.mcpServers ||
40
- this.config.permissionMode ||
41
- this.config.maxTurns ||
42
- this.config.cwd !== undefined ||
43
- this.config.verbose !== undefined;
44
-
45
- if (hasCustomOptions) {
46
- // Create custom provider instance with options
47
- const customProvider = createClaudeCode({
48
- defaultSettings: {
49
- allowedTools: this.config.allowedTools as string[] | undefined,
50
- disallowedTools: this.config.disallowedTools as string[] | undefined,
51
- mcpServers: this.config.mcpServers as Record<string, McpServerConfig> | undefined,
52
- permissionMode: this.config.permissionMode as 'default' | 'acceptEdits' | 'bypassPermissions' | 'plan' | undefined,
53
- maxTurns: this.config.maxTurns as number | undefined,
54
- cwd: this.config.cwd as string | undefined,
55
- verbose: this.config.verbose as boolean | undefined,
56
- }
57
- });
58
- this.modelInstance = customProvider(modelId);
59
- } else {
60
- // Use default provider instance
61
- this.modelInstance = claudeCode(modelId);
62
- }
63
- }
64
-
65
- return this.modelInstance;
66
- }
67
-
68
- /**
69
- * Override configure to reset model instance when config changes
70
- */
71
- configure(config: AgentConfig): void {
72
- super.configure(config);
73
- // Reset model instance so it's recreated with new config
74
- this.modelInstance = null;
75
- }
76
- }
77
-
@@ -1,72 +0,0 @@
1
- import { BaseAgent } from './base-agent.js';
2
- import type { AgentConfig } from '../types.js';
3
- import type { LanguageModel } from 'ai';
4
-
5
- /**
6
- * Codex Agent
7
- * Powered by Codex CLI provider
8
- */
9
- export class CodexAgent extends BaseAgent {
10
- private modelInstance: LanguageModel | null = null;
11
-
12
- constructor(config: AgentConfig = {}) {
13
- super('codex', config);
14
- }
15
-
16
- /**
17
- * Get or create the language model instance
18
- *
19
- * Supports Codex CLI provider options:
20
- * - reasoningEffort, approvalMode, sandboxMode, mcpServers, verbose, logger
21
- * - Can use OPENAI_API_KEY environment variable for authentication
22
- * See: https://ai-sdk.dev/providers/community-providers/codex-cli
23
- */
24
- async getModel(): Promise<LanguageModel> {
25
- if (!this.modelInstance) {
26
- // Dynamic import to handle optional peer dependency
27
- const { codexCli } = await import('ai-sdk-provider-codex-cli');
28
-
29
- // Codex CLI provider takes model ID as string parameter
30
- // Uses CLI authentication or OPENAI_API_KEY env var
31
- // Current models: 'gpt-5.2-codex', 'gpt-5.2', 'gpt-5.1-codex-max', 'gpt-5.1-codex-mini'
32
- const modelId = this.config.model || 'gpt-5.2-codex';
33
-
34
- // Check if per-model settings are provided
35
- const hasModelSettings =
36
- this.config.reasoningEffort !== undefined ||
37
- this.config.approvalMode !== undefined ||
38
- this.config.sandboxMode !== undefined ||
39
- this.config.mcpServers !== undefined ||
40
- this.config.verbose !== undefined ||
41
- this.config.logger !== undefined;
42
-
43
- if (hasModelSettings) {
44
- // Pass settings as second parameter
45
- // Using type assertion for flexibility with provider-specific types
46
- this.modelInstance = codexCli(modelId, {
47
- reasoningEffort: this.config.reasoningEffort as 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | undefined,
48
- approvalMode: this.config.approvalMode as 'untrusted' | 'on-failure' | 'on-request' | 'never' | undefined,
49
- sandboxMode: this.config.sandboxMode as 'read-only' | 'workspace-write' | 'danger-full-access' | undefined,
50
- mcpServers: this.config.mcpServers as any,
51
- verbose: this.config.verbose as boolean | undefined,
52
- logger: this.config.logger as any,
53
- } as any);
54
- } else {
55
- // Create model instance without additional settings
56
- this.modelInstance = codexCli(modelId);
57
- }
58
- }
59
-
60
- return this.modelInstance;
61
- }
62
-
63
- /**
64
- * Override configure to reset model instance when config changes
65
- */
66
- configure(config: AgentConfig): void {
67
- super.configure(config);
68
- // Reset model instance so it's recreated with new config
69
- this.modelInstance = null;
70
- }
71
- }
72
-
@@ -1,55 +0,0 @@
1
- import { createOpenAI } from '@ai-sdk/openai';
2
- import type { LanguageModel } from 'ai';
3
- import { BaseAgent } from './base-agent.js';
4
- import type { AgentConfig } from '../types.js';
5
-
6
- /**
7
- * Intella Lite Agent
8
- * Lightweight default agent using OpenAI-compatible interface
9
- * This is a separate implementation from Mielto
10
- */
11
- export class IntellaLiteAgent extends BaseAgent {
12
- private modelInstance: LanguageModel | null = null;
13
-
14
- constructor(config: AgentConfig = {}) {
15
- super('intella-lite', config);
16
- }
17
-
18
- /**
19
- * Get or create the language model instance
20
- */
21
- getModel(): LanguageModel {
22
- if (!this.modelInstance) {
23
- // Use OpenAI provider as base for Intella Lite
24
- // Default to a lightweight model if not specified
25
- const modelId = this.config.model || 'gpt-4o-mini';
26
-
27
- const apiKey = this.config.apiKey || process.env.OPENAI_API_KEY;
28
- if (!apiKey) {
29
- throw new Error(
30
- 'OpenAI API key is required for Intella Lite agent. Set OPENAI_API_KEY environment variable or provide apiKey in config.'
31
- );
32
- }
33
-
34
- const provider = createOpenAI({
35
- apiKey,
36
- baseURL: this.config.baseURL || process.env.OPENAI_BASE_URL,
37
- headers: this.config.headers,
38
- });
39
-
40
- this.modelInstance = provider.chat(modelId);
41
- }
42
-
43
- return this.modelInstance;
44
- }
45
-
46
- /**
47
- * Override configure to reset model instance when config changes
48
- */
49
- configure(config: AgentConfig): void {
50
- super.configure(config);
51
- // Reset model instance so it's recreated with new config
52
- this.modelInstance = null;
53
- }
54
- }
55
-
@@ -1,45 +0,0 @@
1
- import { BaseAgent } from './base-agent.js';
2
- import type { AgentConfig } from '../types.js';
3
- import type { LanguageModel } from 'ai';
4
-
5
- /**
6
- * OpenCode Agent
7
- * Powered by OpenCode SDK provider
8
- */
9
- export class OpenCodeAgent extends BaseAgent {
10
- private modelInstance: LanguageModel | null = null;
11
-
12
- constructor(config: AgentConfig = {}) {
13
- super('opencode', config);
14
- }
15
-
16
- /**
17
- * Get or create the language model instance
18
- */
19
- async getModel(): Promise<LanguageModel> {
20
- if (!this.modelInstance) {
21
- // Dynamic import to handle optional peer dependency
22
- const { opencode } = await import('ai-sdk-provider-opencode-sdk');
23
-
24
- // OpenCode provider takes model ID as string parameter
25
- // Uses CLI authentication (opencode login) - API key not needed in code
26
- // Model format: 'provider/model-id' (e.g., 'anthropic/claude-sonnet-4-5-20250929')
27
- const modelId = this.config.model || 'anthropic/claude-sonnet-4-5-20250929';
28
-
29
- // Create model instance directly
30
- this.modelInstance = opencode(modelId);
31
- }
32
-
33
- return this.modelInstance;
34
- }
35
-
36
- /**
37
- * Override configure to reset model instance when config changes
38
- */
39
- configure(config: AgentConfig): void {
40
- super.configure(config);
41
- // Reset model instance so it's recreated with new config
42
- this.modelInstance = null;
43
- }
44
- }
45
-