Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion npm/packages/agentic-integration/swarm-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export class SwarmManager extends EventEmitter {
private async spawnInitialAgents(): Promise<void> {
console.log('[SwarmManager] Spawning initial agents...');

const spawnPromises: Promise<void>[] = [];
const spawnPromises: Promise<string>[] = [];

for (const region of this.config.regions) {
for (let i = 0; i < this.config.minAgentsPerRegion; i++) {
Expand Down
21 changes: 21 additions & 0 deletions npm/packages/agentic-integration/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"compilerOptions": {
"target": "ES2022",
"module": "ESNext",
"lib": ["ES2022"],
"moduleResolution": "node",
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"declaration": true,
"declarationMap": true,
"sourceMap": true,
"outDir": "./dist",
"types": ["node"]
},
"include": ["*.ts"],
"exclude": ["node_modules", "dist", "integration-tests.ts"]
}
11 changes: 6 additions & 5 deletions npm/packages/agentic-synth-examples/src/cicd/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,15 +238,16 @@ export class CICDDataGenerator extends EventEmitter {

const pipelines: PipelineExecution[] = await Promise.all(
result.data.map(async (event, index) => {
const pipelineNames = this.config.pipelineNames ?? ['default-pipeline'];
const pipelineName = options.pipelineName ||
this.config.pipelineNames[index % this.config.pipelineNames.length];
pipelineNames[index % pipelineNames.length];

const startTime = new Date(Date.now() - Math.random() * 30 * 24 * 60 * 60 * 1000);
const duration = Math.floor(Math.random() * 600000) + 60000; // 1-10 minutes
const endTime = new Date(startTime.getTime() + duration);

// Determine status based on failure rate
const hasFailed = Math.random() < this.config.failureRate;
const hasFailed = Math.random() < (this.config.failureRate ?? 0.1);
const status: PipelineStatus = hasFailed ? 'failed' : 'success';

// Generate stages
Expand Down Expand Up @@ -295,7 +296,7 @@ export class CICDDataGenerator extends EventEmitter {
this.emit('tests:generating', { pipelineId });

const totalTests = Math.floor(Math.random() * 500) + 100;
const passRate = 1 - this.config.failureRate;
const passRate = 1 - (this.config.failureRate ?? 0.1);
const passed = Math.floor(totalTests * passRate);
const failed = Math.floor((totalTests - passed) * 0.8);
const skipped = totalTests - passed - failed;
Expand Down Expand Up @@ -336,7 +337,7 @@ export class CICDDataGenerator extends EventEmitter {
const duration = Math.floor(Math.random() * 180000) + 30000; // 30s - 3min
const endTime = new Date(startTime.getTime() + duration);

const isSuccess = Math.random() > this.config.failureRate;
const isSuccess = Math.random() > (this.config.failureRate ?? 0.1);

const deployment: DeploymentRecord = {
id: this.generateId('deploy'),
Expand Down Expand Up @@ -415,7 +416,7 @@ export class CICDDataGenerator extends EventEmitter {
source: 'pipeline-monitor',
title: ['High CPU usage', 'Memory leak detected', 'Build timeout', 'Test failures'][Math.floor(Math.random() * 4)],
message: 'Alert details and context',
environment: this.config.environments[Math.floor(Math.random() * this.config.environments.length)],
environment: (this.config.environments ?? ['production'])[Math.floor(Math.random() * (this.config.environments ?? ['production']).length)],
resolved,
resolvedAt: resolved ? new Date(timestamp.getTime() + Math.random() * 3600000) : undefined
};
Expand Down
41 changes: 33 additions & 8 deletions npm/packages/agentic-synth-examples/src/dspy/benchmark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,29 @@ interface ComparisonReport {
};
}

// API Response types
interface OpenAIResponse {
usage?: {
prompt_tokens: number;
completion_tokens: number;
};
choices: {
message: {
content: string;
};
}[];
}

interface AnthropicResponse {
usage?: {
input_tokens: number;
output_tokens: number;
};
content: {
text: string;
}[];
}

// ============================================================================
// Language Model Implementations
// ============================================================================
Expand Down Expand Up @@ -168,7 +191,7 @@ class OpenAILM {
throw new Error(`OpenAI API error: ${response.status} ${error}`);
}

const data = await response.json();
const data = await response.json() as OpenAIResponse;
this.inputTokens += data.usage?.prompt_tokens || 0;
this.outputTokens += data.usage?.completion_tokens || 0;

Expand Down Expand Up @@ -221,7 +244,7 @@ class AnthropicLM {
throw new Error(`Anthropic API error: ${response.status} ${error}`);
}

const data = await response.json();
const data = await response.json() as AnthropicResponse;
this.inputTokens += data.usage?.input_tokens || 0;
this.outputTokens += data.usage?.output_tokens || 0;

Expand Down Expand Up @@ -281,7 +304,7 @@ class DataQualityModule extends PredictModule {
{ name: 'errors', type: 'string', description: 'Any validation errors' }
]
},
promptTemplate: ({ data, schema }) => `
promptTemplate: ({ data, schema }: { data: string; schema: string }) => `
Validate this synthetic data against the schema and provide quality metrics.

Data: ${data}
Expand Down Expand Up @@ -475,7 +498,7 @@ export class MultiModelBenchmark {
const trainset = this.generateTrainingSet(schema, 20);

const optimizer = new BootstrapFewShot(
(input, output, expected) => {
(input: unknown, output: unknown, expected: unknown) => {
if (!expected) return 0;
return this.calculateQualityScore(output, expected);
},
Expand All @@ -501,7 +524,7 @@ export class MultiModelBenchmark {
const trainset = this.generateTrainingSet(schema, 20);

const optimizer = new MIPROv2(
(input, output, expected) => {
(input: unknown, output: unknown, expected: unknown) => {
if (!expected) return 0;
return this.calculateQualityScore(output, expected);
},
Expand Down Expand Up @@ -536,7 +559,7 @@ export class MultiModelBenchmark {
totalScore += score;
count++;
} catch (error) {
console.error(` ⚠ Evaluation error: ${error.message}`);
console.error(` ⚠ Evaluation error: ${error instanceof Error ? error.message : String(error)}`);
}
}

Expand Down Expand Up @@ -567,7 +590,7 @@ export class MultiModelBenchmark {
const latency = performance.now() - start;
latencies.push(latency);
} catch (error) {
console.error(` ⚠ Performance test error: ${error.message}`);
console.error(` ⚠ Performance test error: ${error instanceof Error ? error.message : String(error)}`);
}
}

Expand Down Expand Up @@ -948,7 +971,9 @@ async function main() {

} catch (error) {
console.error('\n❌ Benchmark failed:', error);
console.error(error.stack);
if (error instanceof Error) {
console.error(error.stack);
}
process.exit(1);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1231,12 +1231,4 @@ export class DSPyTrainingSession extends EventEmitter {
// Exports
// ============================================================================

// Note: ModelProvider and TrainingPhase are already exported as enums above
export type {
QualityMetrics,
PerformanceMetrics,
IterationResult,
ModelConfig,
DSPySignature,
TrainingConfig
};
// Note: All types are exported inline where they are defined above
25 changes: 13 additions & 12 deletions npm/packages/agentic-synth-examples/src/stock-market/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ export class StockMarketSimulator extends EventEmitter {
this.synth = new AgenticSynth(this.config);

// Initialize starting prices
this.config.symbols.forEach(symbol => {
this.currentPrice.set(symbol, this.config.startPrice);
(this.config.symbols ?? []).forEach(symbol => {
this.currentPrice.set(symbol, this.config.startPrice ?? 100);
});
}

Expand All @@ -149,7 +149,7 @@ export class StockMarketSimulator extends EventEmitter {
interval?: string;
symbol?: string;
} = {}): Promise<GenerationResult<OHLCVData>> {
const symbol = options.symbol || this.config.symbols[0];
const symbol = options.symbol || this.config.symbols?.[0] || 'STOCK';

this.emit('generation:start', { symbol, options });

Expand All @@ -160,9 +160,9 @@ export class StockMarketSimulator extends EventEmitter {
endDate: options.endDate || new Date(),
interval: options.interval || '1h',
metrics: ['price', 'volume'],
trend: this.mapMarketConditionToTrend(this.config.marketCondition),
trend: this.mapMarketConditionToTrend(this.config.marketCondition ?? 'sideways'),
seasonality: true,
noise: this.config.volatility
noise: this.config.volatility ?? 0.02
};

const result = await this.synth.generateTimeSeries<{ price: number; volume: number }>(
Expand Down Expand Up @@ -221,7 +221,7 @@ export class StockMarketSimulator extends EventEmitter {
headline: event.headline,
sentiment: this.parseSentiment(event.sentiment),
impact: this.parseImpact(event.impact),
affectedSymbols: event.symbols.filter(s => this.config.symbols.includes(s))
affectedSymbols: event.symbols.filter((s: string) => (this.config.symbols ?? []).includes(s))
}));

this.newsEvents.push(...newsEvents);
Expand All @@ -243,12 +243,13 @@ export class StockMarketSimulator extends EventEmitter {
endDate?: Date;
interval?: string;
} = {}): Promise<Map<string, OHLCVData[]>> {
this.emit('multi-symbol:start', { symbols: this.config.symbols });
const symbols = this.config.symbols ?? [];
this.emit('multi-symbol:start', { symbols });

const results = new Map<string, OHLCVData[]>();

// Generate for all symbols in parallel
const promises = this.config.symbols.map(async symbol => {
const promises = symbols.map(async symbol => {
const result = await this.generateMarketData({ ...options, symbol });
return { symbol, data: result.data };
});
Expand All @@ -260,7 +261,7 @@ export class StockMarketSimulator extends EventEmitter {
});

this.emit('multi-symbol:complete', {
symbols: this.config.symbols.length,
symbols: symbols.length,
totalCandles: Array.from(results.values()).reduce((sum, candles) => sum + candles.length, 0)
});

Expand Down Expand Up @@ -341,8 +342,8 @@ export class StockMarketSimulator extends EventEmitter {
reset(): void {
this.generatedCandles = [];
this.newsEvents = [];
this.config.symbols.forEach(symbol => {
this.currentPrice.set(symbol, this.config.startPrice);
(this.config.symbols ?? []).forEach(symbol => {
this.currentPrice.set(symbol, this.config.startPrice ?? 100);
});

this.emit('reset', { timestamp: new Date() });
Expand All @@ -354,7 +355,7 @@ export class StockMarketSimulator extends EventEmitter {
private convertToOHLCV(data: { price: number; volume: number }[], symbol: string): OHLCVData[] {
return data.map((point, i) => {
const basePrice = point.price;
const dailyVolatility = this.config.volatility * basePrice;
const dailyVolatility = (this.config.volatility ?? 0.02) * basePrice;

// Generate realistic OHLC from base price
const open = i === 0 ? basePrice : basePrice * (1 + (Math.random() - 0.5) * 0.01);
Expand Down
9 changes: 5 additions & 4 deletions npm/packages/agentic-synth-examples/src/swarm/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export class SwarmCoordinator extends EventEmitter {

const roles: AgentRole[] = ['generator', 'validator', 'optimizer', 'coordinator', 'learner'];

for (let i = 0; i < this.config.agentCount; i++) {
for (let i = 0; i < (this.config.agentCount ?? 5); i++) {
const agent: Agent = {
id: this.generateId('agent'),
role: roles[i % roles.length],
Expand Down Expand Up @@ -280,7 +280,7 @@ export class SwarmCoordinator extends EventEmitter {

this.emit('coordination:complete', {
taskId: task.id,
duration: task.endTime.getTime() - task.startTime.getTime(),
duration: task.endTime!.getTime() - task.startTime!.getTime(),
resultCount: result.data.length
});

Expand Down Expand Up @@ -516,8 +516,9 @@ export class SwarmCoordinator extends EventEmitter {
});

// Trim short-term memory
if (agent.memory.shortTerm.length > this.config.memorySize) {
agent.memory.shortTerm = agent.memory.shortTerm.slice(-this.config.memorySize);
const memorySize = this.config.memorySize ?? 100;
if (agent.memory.shortTerm.length > memorySize) {
agent.memory.shortTerm = agent.memory.shortTerm.slice(-memorySize);
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const employeeProfileSchema = {
reportingStructure: { type: 'object', required: true, properties: {
managerId: { type: 'string' },
managerName: { type: 'string' },
dotted LineManagerId: { type: 'string' },
dottedLineManagerId: { type: 'string' },
dottedLineManagerName: { type: 'string' },
seniorManagerId: { type: 'string' },
seniorManagerName: { type: 'string' }
Expand Down
2 changes: 1 addition & 1 deletion npm/packages/burst-scaling/capacity-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ export class CapacityManager {
// 3. Process reactive scaling for each region
const scalingActions: ScalingAction[] = [];

for (const [region, capacity] of this.regionCapacities) {
for (const [region, _capacity] of this.regionCapacities) {
// Get current metrics (in production, fetch from monitoring)
const metrics = await this.getCurrentMetrics(region);

Expand Down
9 changes: 8 additions & 1 deletion npm/packages/burst-scaling/reactive-scaler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export class ReactiveScaler {
private readonly historySize = 60; // Keep 60 samples (5 minutes at 5s intervals)

constructor(
private readonly regions: string[] = ['us-central1', 'europe-west1', 'asia-east1'],
private readonly _regions: string[] = ['us-central1', 'europe-west1', 'asia-east1'],
private readonly notifyHook: (message: string) => Promise<void> = async (msg) => {
await execAsync(`npx claude-flow@alpha hooks notify --message "${msg.replace(/"/g, '\\"')}"`);
}
Expand Down Expand Up @@ -91,6 +91,13 @@ export class ReactiveScaler {
};
}

/**
* Get configured regions
*/
getRegions(): string[] {
return this._regions;
}

/**
* Update scaling thresholds
*/
Expand Down
9 changes: 8 additions & 1 deletion npm/packages/core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,11 @@ function loadNativeModule() {
}
}

module.exports = loadNativeModule();
const nativeModule = loadNativeModule();

// Add backwards-compatible alias (VectorDB -> VectorDb)
if (nativeModule.VectorDb && !nativeModule.VectorDB) {
nativeModule.VectorDB = nativeModule.VectorDb;
}

module.exports = nativeModule;
Loading