@defai.digital/automatosx 12.8.7 → 13.1.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.
- package/LICENSE +1 -1
- package/dist/bin.d.ts +8 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +16 -0
- package/dist/bin.js.map +1 -0
- package/dist/index.d.ts +8 -2
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -74239
- package/dist/index.js.map +1 -0
- package/package.json +35 -160
- package/.github/assets/ax-cli.png +0 -0
- package/.github/assets/axlogo.png +0 -0
- package/CHANGELOG.md +0 -81
- package/README.md +0 -790
- package/SECURITY.md +0 -173
- package/dist/mcp/index.d.ts +0 -2
- package/dist/mcp/index.js +0 -43627
- package/examples/AGENTS_INFO.md +0 -187
- package/examples/README.md +0 -434
- package/examples/abilities/accessibility.md +0 -115
- package/examples/abilities/api-design.md +0 -168
- package/examples/abilities/best-practices.md +0 -102
- package/examples/abilities/caching-strategy.md +0 -165
- package/examples/abilities/ci-cd.md +0 -61
- package/examples/abilities/clean-code.md +0 -398
- package/examples/abilities/code-generation.md +0 -333
- package/examples/abilities/code-review.md +0 -51
- package/examples/abilities/component-architecture.md +0 -112
- package/examples/abilities/content-creation.md +0 -97
- package/examples/abilities/data-modeling.md +0 -171
- package/examples/abilities/data-validation.md +0 -50
- package/examples/abilities/db-modeling.md +0 -167
- package/examples/abilities/debugging.md +0 -52
- package/examples/abilities/design-patterns.md +0 -437
- package/examples/abilities/design-system-implementation.md +0 -126
- package/examples/abilities/documentation.md +0 -54
- package/examples/abilities/etl-pipelines.md +0 -44
- package/examples/abilities/feasibility-study.md +0 -20
- package/examples/abilities/general-assistance.md +0 -26
- package/examples/abilities/idea-evaluation.md +0 -21
- package/examples/abilities/infra-as-code.md +0 -57
- package/examples/abilities/job-orchestration.md +0 -44
- package/examples/abilities/literature-review.md +0 -19
- package/examples/abilities/longform-report.md +0 -25
- package/examples/abilities/mathematical-reasoning.md +0 -170
- package/examples/abilities/observability.md +0 -61
- package/examples/abilities/orbital-mechanics.md +0 -50
- package/examples/abilities/our-architecture-decisions.md +0 -180
- package/examples/abilities/our-code-review-checklist.md +0 -149
- package/examples/abilities/our-coding-standards.md +0 -369
- package/examples/abilities/our-project-structure.md +0 -183
- package/examples/abilities/performance.md +0 -89
- package/examples/abilities/problem-solving.md +0 -50
- package/examples/abilities/propulsion-systems.md +0 -50
- package/examples/abilities/quantum-algorithm-design.md +0 -54
- package/examples/abilities/quantum-error-correction.md +0 -56
- package/examples/abilities/quantum-frameworks-transpilation.md +0 -53
- package/examples/abilities/quantum-noise-modeling.md +0 -58
- package/examples/abilities/refactoring.md +0 -223
- package/examples/abilities/release-strategy.md +0 -58
- package/examples/abilities/secrets-policy.md +0 -61
- package/examples/abilities/secure-coding-review.md +0 -60
- package/examples/abilities/software-architecture.md +0 -394
- package/examples/abilities/solid-principles.md +0 -341
- package/examples/abilities/sql-optimization.md +0 -84
- package/examples/abilities/state-management.md +0 -96
- package/examples/abilities/task-planning.md +0 -65
- package/examples/abilities/technical-writing.md +0 -77
- package/examples/abilities/telemetry-diagnostics.md +0 -51
- package/examples/abilities/testing.md +0 -56
- package/examples/abilities/threat-modeling.md +0 -58
- package/examples/abilities/troubleshooting.md +0 -80
- package/examples/abilities/typescript-zod-validation.md +0 -830
- package/examples/agents/AGENTS_INTEGRATION.md +0 -99
- package/examples/agents/aerospace-scientist.yaml +0 -159
- package/examples/agents/architecture.yaml +0 -244
- package/examples/agents/automatosx.config.json +0 -286
- package/examples/agents/backend.yaml +0 -141
- package/examples/agents/ceo.yaml +0 -105
- package/examples/agents/creative-marketer.yaml +0 -173
- package/examples/agents/cto.yaml +0 -118
- package/examples/agents/data-scientist.yaml +0 -200
- package/examples/agents/data.yaml +0 -106
- package/examples/agents/design.yaml +0 -115
- package/examples/agents/devops.yaml +0 -124
- package/examples/agents/frontend.yaml +0 -171
- package/examples/agents/fullstack.yaml +0 -172
- package/examples/agents/mobile.yaml +0 -185
- package/examples/agents/product.yaml +0 -103
- package/examples/agents/quality.yaml +0 -117
- package/examples/agents/quantum-engineer.yaml +0 -166
- package/examples/agents/researcher.yaml +0 -122
- package/examples/agents/security.yaml +0 -115
- package/examples/agents/standard.yaml +0 -214
- package/examples/agents/writer.yaml +0 -122
- package/examples/providers/README.md +0 -117
- package/examples/providers/claude/CLAUDE_INTEGRATION.md +0 -302
- package/examples/providers/claude/mcp/automatosx.json +0 -244
- package/examples/providers/codex/CODEX_INTEGRATION.md +0 -593
- package/examples/providers/codex/README.md +0 -349
- package/examples/providers/codex/usage-examples.ts +0 -421
- package/examples/providers/gemini/GEMINI_INTEGRATION.md +0 -236
- package/examples/providers/gemini/README.md +0 -76
- package/examples/providers/openai-codex-example.ts +0 -421
- package/examples/pytorch_resnet50_training.py +0 -289
- package/examples/specs/automatosx-release.ax.yaml +0 -380
- package/examples/specs/enterprise.ax.yaml +0 -121
- package/examples/specs/enterprise.yaml.mustache +0 -121
- package/examples/specs/government.ax.yaml +0 -148
- package/examples/specs/government.yaml.mustache +0 -148
- package/examples/specs/minimal.ax.yaml +0 -21
- package/examples/specs/minimal.yaml.mustache +0 -21
- package/examples/teams/business.yaml +0 -56
- package/examples/teams/core.yaml +0 -60
- package/examples/teams/design.yaml +0 -58
- package/examples/teams/engineering.yaml +0 -69
- package/examples/teams/research.yaml +0 -56
- package/examples/use-cases/01-web-app-development.md +0 -374
- package/examples/workflows/analyst.yaml +0 -60
- package/examples/workflows/assistant.yaml +0 -48
- package/examples/workflows/basic-agent.yaml +0 -28
- package/examples/workflows/code-reviewer.yaml +0 -52
- package/examples/workflows/debugger.yaml +0 -63
- package/examples/workflows/designer.yaml +0 -69
- package/examples/workflows/developer.yaml +0 -60
- package/examples/workflows/fullstack-developer.yaml +0 -395
- package/examples/workflows/qa-specialist.yaml +0 -71
- package/schema/ability-metadata.json +0 -21
- package/schema/config.json +0 -703
- package/schema/spec-schema.json +0 -608
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
# Gemini CLI Integration for AutomatosX
|
|
2
|
-
|
|
3
|
-
This directory contains integration files for using AutomatosX with Gemini CLI.
|
|
4
|
-
|
|
5
|
-
## Using AutomatosX with Gemini CLI
|
|
6
|
-
|
|
7
|
-
**Natural Language Interaction (Recommended)**:
|
|
8
|
-
|
|
9
|
-
You can interact with AutomatosX agents using natural language in Gemini CLI. No special commands needed!
|
|
10
|
-
|
|
11
|
-
### Examples
|
|
12
|
-
|
|
13
|
-
```
|
|
14
|
-
"Please use the ax backend agent to create a REST API for authentication"
|
|
15
|
-
"Ask the ax frontend agent to build a responsive navbar"
|
|
16
|
-
"Have the ax security agent audit this code for security vulnerabilities"
|
|
17
|
-
"Work with ax agent quality to write unit tests for this feature"
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
Gemini CLI will understand your intent and invoke the appropriate AutomatosX agent for you.
|
|
21
|
-
|
|
22
|
-
### Available Agents
|
|
23
|
-
|
|
24
|
-
Use any of these agents by mentioning them in natural language:
|
|
25
|
-
|
|
26
|
-
- **backend** (Bob) - Backend development
|
|
27
|
-
- **frontend** (Frank) - Frontend development
|
|
28
|
-
- **security** (Steve) - Security auditing
|
|
29
|
-
- **quality** (Queenie) - QA and testing
|
|
30
|
-
- **devops** (Oliver) - DevOps and infrastructure
|
|
31
|
-
- **product** (Paris) - Product management
|
|
32
|
-
- **design** (Debbee) - UX/UI design
|
|
33
|
-
- And many more!
|
|
34
|
-
|
|
35
|
-
See the full list with: `ax list agents`
|
|
36
|
-
|
|
37
|
-
## Terminal Usage
|
|
38
|
-
|
|
39
|
-
You can also use AutomatosX directly from the terminal:
|
|
40
|
-
|
|
41
|
-
```bash
|
|
42
|
-
# Run any agent with a task
|
|
43
|
-
ax run backend "create a REST API for authentication"
|
|
44
|
-
ax run frontend "build a responsive navbar"
|
|
45
|
-
ax run security "audit code for vulnerabilities"
|
|
46
|
-
|
|
47
|
-
# Check status
|
|
48
|
-
ax status
|
|
49
|
-
|
|
50
|
-
# List agents
|
|
51
|
-
ax list agents
|
|
52
|
-
|
|
53
|
-
# Search memory
|
|
54
|
-
ax memory search "keyword"
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
## Setup
|
|
58
|
-
|
|
59
|
-
When you run `ax setup`, AutomatosX will configure your project for use with Gemini CLI.
|
|
60
|
-
|
|
61
|
-
## Syncing with Gemini CLI
|
|
62
|
-
|
|
63
|
-
```bash
|
|
64
|
-
# Register AutomatosX MCP server
|
|
65
|
-
ax gemini sync-mcp
|
|
66
|
-
|
|
67
|
-
# Check integration status
|
|
68
|
-
ax gemini status
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
## Notes
|
|
72
|
-
|
|
73
|
-
- Use natural language to work with agents - no special syntax required
|
|
74
|
-
- All conversations are saved to persistent memory
|
|
75
|
-
- Agents can delegate tasks to each other automatically
|
|
76
|
-
- See `GEMINI_INTEGRATION.md` for full integration guide
|
|
@@ -1,421 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Codex CLI CLI Integration - Usage Examples
|
|
3
|
-
*
|
|
4
|
-
* This file demonstrates various ways to use the Codex CLI integration
|
|
5
|
-
* with AutomatosX, including basic execution, MCP server management, and
|
|
6
|
-
* advanced patterns.
|
|
7
|
-
*
|
|
8
|
-
* @see docs/integrations/openai-codex.md for complete documentation
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import {
|
|
12
|
-
CodexBridge,
|
|
13
|
-
CodexCLI,
|
|
14
|
-
CodexMCPManager,
|
|
15
|
-
CodexError,
|
|
16
|
-
CodexErrorType,
|
|
17
|
-
getDefaultBridge,
|
|
18
|
-
getDefaultCLI,
|
|
19
|
-
getDefaultMCPManager,
|
|
20
|
-
} from '../../src/integrations/openai-codex/index.js';
|
|
21
|
-
|
|
22
|
-
// ========================================
|
|
23
|
-
// Example 1: Basic CLI Execution
|
|
24
|
-
// ========================================
|
|
25
|
-
|
|
26
|
-
async function example1_basicExecution() {
|
|
27
|
-
console.log('\n=== Example 1: Basic CLI Execution ===\n');
|
|
28
|
-
|
|
29
|
-
const cli = new CodexCLI({
|
|
30
|
-
command: 'codex',
|
|
31
|
-
sandboxMode: 'workspace-write',
|
|
32
|
-
timeout: 60000,
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
try {
|
|
36
|
-
// Check if codex CLI is available
|
|
37
|
-
const available = await cli.isAvailable();
|
|
38
|
-
if (!available) {
|
|
39
|
-
console.error('Codex CLI not found. Install with: npm i -g @openai/codex');
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// Get CLI version
|
|
44
|
-
const version = await cli.getVersion();
|
|
45
|
-
console.log(`Using Codex CLI version: ${version}`);
|
|
46
|
-
|
|
47
|
-
// Execute a simple prompt
|
|
48
|
-
const result = await cli.execute({
|
|
49
|
-
prompt: 'Explain the benefits of TypeScript in 3 sentences',
|
|
50
|
-
temperature: 0.7,
|
|
51
|
-
maxTokens: 200,
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
console.log('\nResponse:');
|
|
55
|
-
console.log(result.content);
|
|
56
|
-
console.log(`\nDuration: ${result.duration}ms`);
|
|
57
|
-
console.log(`Token count: ${result.tokenCount ?? 'N/A'}`);
|
|
58
|
-
} catch (error) {
|
|
59
|
-
if (error instanceof CodexError) {
|
|
60
|
-
console.error(`Codex error [${error.type}]:`, error.message);
|
|
61
|
-
if (error.context) {
|
|
62
|
-
console.error('Context:', error.context);
|
|
63
|
-
}
|
|
64
|
-
} else {
|
|
65
|
-
console.error('Unexpected error:', error);
|
|
66
|
-
}
|
|
67
|
-
} finally {
|
|
68
|
-
await cli.cleanup();
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// ========================================
|
|
73
|
-
// Example 2: Streaming Execution
|
|
74
|
-
// ========================================
|
|
75
|
-
|
|
76
|
-
async function example2_streamingExecution() {
|
|
77
|
-
console.log('\n=== Example 2: Streaming Execution ===\n');
|
|
78
|
-
|
|
79
|
-
const cli = new CodexCLI({
|
|
80
|
-
command: 'codex',
|
|
81
|
-
sandboxMode: 'workspace-write',
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
try {
|
|
85
|
-
const result = await cli.execute({
|
|
86
|
-
prompt: 'Write a short poem about programming',
|
|
87
|
-
streaming: true,
|
|
88
|
-
temperature: 0.9,
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
console.log('Streamed response:');
|
|
92
|
-
console.log(result.content);
|
|
93
|
-
} catch (error) {
|
|
94
|
-
console.error('Error:', error instanceof CodexError ? error.message : error);
|
|
95
|
-
} finally {
|
|
96
|
-
await cli.cleanup();
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// ========================================
|
|
101
|
-
// Example 3: MCP Server Management
|
|
102
|
-
// ========================================
|
|
103
|
-
|
|
104
|
-
async function example3_mcpServer() {
|
|
105
|
-
console.log('\n=== Example 3: MCP Server Management ===\n');
|
|
106
|
-
|
|
107
|
-
const mcpManager = new CodexMCPManager({
|
|
108
|
-
enabled: true,
|
|
109
|
-
command: 'codex',
|
|
110
|
-
transport: 'stdio',
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
try {
|
|
114
|
-
// Start MCP server
|
|
115
|
-
console.log('Starting MCP server...');
|
|
116
|
-
const startStatus = await mcpManager.startServer();
|
|
117
|
-
console.log(`MCP server started (PID: ${startStatus.pid})`);
|
|
118
|
-
|
|
119
|
-
// Check server status
|
|
120
|
-
const status = await mcpManager.getStatus();
|
|
121
|
-
console.log('\nServer Status:');
|
|
122
|
-
console.log(` Running: ${status.running}`);
|
|
123
|
-
console.log(` PID: ${status.pid}`);
|
|
124
|
-
console.log(` Uptime: ${status.uptime ? `${status.uptime}ms` : 'N/A'}`);
|
|
125
|
-
|
|
126
|
-
// Health check
|
|
127
|
-
const healthy = await mcpManager.isHealthy();
|
|
128
|
-
console.log(` Healthy: ${healthy}`);
|
|
129
|
-
|
|
130
|
-
// Wait a bit
|
|
131
|
-
await new Promise((resolve) => setTimeout(resolve, 2000));
|
|
132
|
-
|
|
133
|
-
// Stop server
|
|
134
|
-
console.log('\nStopping MCP server...');
|
|
135
|
-
await mcpManager.stopServer();
|
|
136
|
-
console.log('MCP server stopped');
|
|
137
|
-
} catch (error) {
|
|
138
|
-
if (error instanceof CodexError) {
|
|
139
|
-
console.error(`MCP error [${error.type}]:`, error.message);
|
|
140
|
-
} else {
|
|
141
|
-
console.error('Error:', error);
|
|
142
|
-
}
|
|
143
|
-
} finally {
|
|
144
|
-
await mcpManager.cleanup();
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
// ========================================
|
|
149
|
-
// Example 4: Full Integration with Bridge
|
|
150
|
-
// ========================================
|
|
151
|
-
|
|
152
|
-
async function example4_fullIntegration() {
|
|
153
|
-
console.log('\n=== Example 4: Full Integration with Bridge ===\n');
|
|
154
|
-
|
|
155
|
-
const bridge = new CodexBridge(
|
|
156
|
-
{
|
|
157
|
-
command: 'codex',
|
|
158
|
-
sandboxMode: 'workspace-write',
|
|
159
|
-
timeout: 120000,
|
|
160
|
-
temperature: 0.7,
|
|
161
|
-
},
|
|
162
|
-
{
|
|
163
|
-
enabled: true,
|
|
164
|
-
command: 'codex',
|
|
165
|
-
transport: 'stdio',
|
|
166
|
-
autoStart: false, // Manual start for this example
|
|
167
|
-
}
|
|
168
|
-
);
|
|
169
|
-
|
|
170
|
-
try {
|
|
171
|
-
// Initialize bridge (checks CLI availability)
|
|
172
|
-
console.log('Initializing Codex bridge...');
|
|
173
|
-
const initStatus = await bridge.initialize();
|
|
174
|
-
|
|
175
|
-
console.log('\nIntegration Status:');
|
|
176
|
-
console.log(` CLI Available: ${initStatus.cliAvailable}`);
|
|
177
|
-
console.log(` CLI Version: ${initStatus.version}`);
|
|
178
|
-
console.log(` Initialized: ${initStatus.initialized}`);
|
|
179
|
-
|
|
180
|
-
// Execute a prompt
|
|
181
|
-
console.log('\nExecuting prompt via bridge...');
|
|
182
|
-
const result = await bridge.execute({
|
|
183
|
-
prompt: 'What are the key principles of clean code?',
|
|
184
|
-
maxTokens: 300,
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
console.log('\nResponse:');
|
|
188
|
-
console.log(result.content.substring(0, 200) + '...');
|
|
189
|
-
console.log(`Duration: ${result.duration}ms`);
|
|
190
|
-
|
|
191
|
-
// Start MCP server if needed
|
|
192
|
-
console.log('\nStarting MCP server...');
|
|
193
|
-
await bridge.startMCPServer();
|
|
194
|
-
|
|
195
|
-
const mcpHealthy = await bridge.isMCPServerHealthy();
|
|
196
|
-
console.log(`MCP Server healthy: ${mcpHealthy}`);
|
|
197
|
-
|
|
198
|
-
// Execute another prompt (with MCP server running)
|
|
199
|
-
const result2 = await bridge.execute({
|
|
200
|
-
prompt: 'List 5 design patterns',
|
|
201
|
-
maxTokens: 200,
|
|
202
|
-
});
|
|
203
|
-
|
|
204
|
-
console.log('\nSecond response:');
|
|
205
|
-
console.log(result2.content);
|
|
206
|
-
|
|
207
|
-
// Stop MCP server
|
|
208
|
-
await bridge.stopMCPServer();
|
|
209
|
-
console.log('\nMCP server stopped');
|
|
210
|
-
} catch (error) {
|
|
211
|
-
if (error instanceof CodexError) {
|
|
212
|
-
console.error(`\nError [${error.type}]:`, error.message);
|
|
213
|
-
} else {
|
|
214
|
-
console.error('\nError:', error);
|
|
215
|
-
}
|
|
216
|
-
} finally {
|
|
217
|
-
await bridge.cleanup();
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
// ========================================
|
|
222
|
-
// Example 5: Error Handling Patterns
|
|
223
|
-
// ========================================
|
|
224
|
-
|
|
225
|
-
async function example5_errorHandling() {
|
|
226
|
-
console.log('\n=== Example 5: Error Handling Patterns ===\n');
|
|
227
|
-
|
|
228
|
-
const cli = new CodexCLI({ command: 'codex' });
|
|
229
|
-
|
|
230
|
-
// Pattern 1: Type-specific error handling
|
|
231
|
-
try {
|
|
232
|
-
await cli.execute({ prompt: 'test' });
|
|
233
|
-
} catch (error) {
|
|
234
|
-
if (error instanceof CodexError) {
|
|
235
|
-
switch (error.type) {
|
|
236
|
-
case CodexErrorType.CLI_NOT_FOUND:
|
|
237
|
-
console.error('Install codex: npm i -g @openai/codex');
|
|
238
|
-
break;
|
|
239
|
-
case CodexErrorType.TIMEOUT:
|
|
240
|
-
console.error('Request timed out, try increasing timeout');
|
|
241
|
-
break;
|
|
242
|
-
case CodexErrorType.EXECUTION_FAILED:
|
|
243
|
-
console.error('Execution failed:', error.context);
|
|
244
|
-
break;
|
|
245
|
-
default:
|
|
246
|
-
console.error('Codex error:', error.message);
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
} finally {
|
|
250
|
-
await cli.cleanup();
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
// Pattern 2: Retry with backoff
|
|
254
|
-
async function executeWithRetry(prompt: string, maxRetries = 3) {
|
|
255
|
-
let attempt = 0;
|
|
256
|
-
while (attempt < maxRetries) {
|
|
257
|
-
try {
|
|
258
|
-
return await cli.execute({ prompt });
|
|
259
|
-
} catch (error) {
|
|
260
|
-
attempt++;
|
|
261
|
-
if (attempt >= maxRetries) throw error;
|
|
262
|
-
|
|
263
|
-
const delay = 1000 * Math.pow(2, attempt);
|
|
264
|
-
console.log(`Retry ${attempt}/${maxRetries} after ${delay}ms...`);
|
|
265
|
-
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
try {
|
|
271
|
-
const result = await executeWithRetry('Generate a haiku');
|
|
272
|
-
console.log('Success after retries:', result.content);
|
|
273
|
-
} catch (error) {
|
|
274
|
-
console.error('All retries failed');
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
// ========================================
|
|
279
|
-
// Example 6: Using Default Instances
|
|
280
|
-
// ========================================
|
|
281
|
-
|
|
282
|
-
async function example6_defaultInstances() {
|
|
283
|
-
console.log('\n=== Example 6: Using Default Instances ===\n');
|
|
284
|
-
|
|
285
|
-
// Get default CLI instance (shared across calls)
|
|
286
|
-
const cli = getDefaultCLI();
|
|
287
|
-
|
|
288
|
-
try {
|
|
289
|
-
const result = await cli.execute({
|
|
290
|
-
prompt: 'What is dependency injection?',
|
|
291
|
-
maxTokens: 150,
|
|
292
|
-
});
|
|
293
|
-
|
|
294
|
-
console.log('Response:', result.content);
|
|
295
|
-
} finally {
|
|
296
|
-
await cli.cleanup();
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
// Get default bridge instance
|
|
300
|
-
const bridge = getDefaultBridge(
|
|
301
|
-
{ command: 'codex', sandboxMode: 'workspace-write' },
|
|
302
|
-
{ enabled: false } // MCP disabled
|
|
303
|
-
);
|
|
304
|
-
|
|
305
|
-
try {
|
|
306
|
-
await bridge.initialize();
|
|
307
|
-
const result = await bridge.execute({
|
|
308
|
-
prompt: 'Explain SOLID principles in one sentence each',
|
|
309
|
-
});
|
|
310
|
-
console.log('\nSOLID principles:', result.content);
|
|
311
|
-
} finally {
|
|
312
|
-
await bridge.cleanup();
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
// ========================================
|
|
317
|
-
// Example 7: Advanced Configuration
|
|
318
|
-
// ========================================
|
|
319
|
-
|
|
320
|
-
async function example7_advancedConfiguration() {
|
|
321
|
-
console.log('\n=== Example 7: Advanced Configuration ===\n');
|
|
322
|
-
|
|
323
|
-
// Different sandbox modes
|
|
324
|
-
const modes = ['workspace-write', 'full', 'none'] as const;
|
|
325
|
-
|
|
326
|
-
for (const mode of modes) {
|
|
327
|
-
const cli = new CodexCLI({
|
|
328
|
-
command: 'codex',
|
|
329
|
-
sandboxMode: mode,
|
|
330
|
-
timeout: 30000,
|
|
331
|
-
});
|
|
332
|
-
|
|
333
|
-
try {
|
|
334
|
-
console.log(`\nTesting sandbox mode: ${mode}`);
|
|
335
|
-
const result = await cli.execute({
|
|
336
|
-
prompt: 'Describe file system access in sandbox mode',
|
|
337
|
-
maxTokens: 100,
|
|
338
|
-
});
|
|
339
|
-
console.log(`Response: ${result.content.substring(0, 100)}...`);
|
|
340
|
-
} catch (error) {
|
|
341
|
-
console.error(`Error in ${mode} mode:`, error);
|
|
342
|
-
} finally {
|
|
343
|
-
await cli.cleanup();
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
// MCP with config overrides
|
|
348
|
-
const mcpManager = new CodexMCPManager({
|
|
349
|
-
enabled: true,
|
|
350
|
-
command: 'codex',
|
|
351
|
-
transport: 'stdio',
|
|
352
|
-
configOverrides: {
|
|
353
|
-
timeout: 60000,
|
|
354
|
-
retries: 3,
|
|
355
|
-
},
|
|
356
|
-
});
|
|
357
|
-
|
|
358
|
-
try {
|
|
359
|
-
console.log('\nStarting MCP with custom config...');
|
|
360
|
-
await mcpManager.startServer();
|
|
361
|
-
console.log('MCP server started with custom configuration');
|
|
362
|
-
await mcpManager.stopServer();
|
|
363
|
-
} catch (error) {
|
|
364
|
-
console.error('MCP error:', error);
|
|
365
|
-
} finally {
|
|
366
|
-
await mcpManager.cleanup();
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
// ========================================
|
|
371
|
-
// Main Entry Point
|
|
372
|
-
// ========================================
|
|
373
|
-
|
|
374
|
-
async function main() {
|
|
375
|
-
console.log('Codex CLI Integration - Usage Examples');
|
|
376
|
-
console.log('==========================================\n');
|
|
377
|
-
|
|
378
|
-
const examples = [
|
|
379
|
-
{ name: 'Basic Execution', fn: example1_basicExecution },
|
|
380
|
-
{ name: 'Streaming Execution', fn: example2_streamingExecution },
|
|
381
|
-
{ name: 'MCP Server Management', fn: example3_mcpServer },
|
|
382
|
-
{ name: 'Full Integration', fn: example4_fullIntegration },
|
|
383
|
-
{ name: 'Error Handling', fn: example5_errorHandling },
|
|
384
|
-
{ name: 'Default Instances', fn: example6_defaultInstances },
|
|
385
|
-
{ name: 'Advanced Configuration', fn: example7_advancedConfiguration },
|
|
386
|
-
];
|
|
387
|
-
|
|
388
|
-
// Run examples (comment out ones you don't want to run)
|
|
389
|
-
for (const { name, fn } of examples) {
|
|
390
|
-
console.log(`\n${'='.repeat(60)}`);
|
|
391
|
-
console.log(`Running: ${name}`);
|
|
392
|
-
console.log('='.repeat(60));
|
|
393
|
-
|
|
394
|
-
try {
|
|
395
|
-
await fn();
|
|
396
|
-
} catch (error) {
|
|
397
|
-
console.error(`\nExample failed: ${error}`);
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
// Wait between examples
|
|
401
|
-
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
console.log('\n\nAll examples completed!');
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
// Run if executed directly
|
|
408
|
-
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
409
|
-
main().catch(console.error);
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
// Export examples for use in other files
|
|
413
|
-
export {
|
|
414
|
-
example1_basicExecution,
|
|
415
|
-
example2_streamingExecution,
|
|
416
|
-
example3_mcpServer,
|
|
417
|
-
example4_fullIntegration,
|
|
418
|
-
example5_errorHandling,
|
|
419
|
-
example6_defaultInstances,
|
|
420
|
-
example7_advancedConfiguration,
|
|
421
|
-
};
|