@artemiskit/cli 0.2.4 → 0.3.1
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/CHANGELOG.md +150 -0
- package/adapters/openai/dist/index.js +5626 -0
- package/dist/index.js +1874 -50
- package/dist/src/adapters.d.ts.map +1 -1
- package/dist/src/commands/redteam.d.ts +5 -0
- package/dist/src/commands/redteam.d.ts.map +1 -1
- package/dist/src/commands/run.d.ts.map +1 -1
- package/dist/src/config/schema.d.ts +32 -0
- package/dist/src/config/schema.d.ts.map +1 -1
- package/dist/src/utils/adapter.d.ts.map +1 -1
- package/package.json +8 -6
- package/src/__tests__/integration/ui.test.ts +17 -17
- package/src/adapters.ts +30 -0
- package/src/commands/redteam.ts +157 -9
- package/src/commands/run.ts +2 -1
- package/src/config/schema.ts +6 -0
- package/src/utils/adapter.ts +167 -0
package/src/utils/adapter.ts
CHANGED
|
@@ -119,6 +119,30 @@ export function buildAdapterConfig(options: AdapterConfigOptions): AdapterConfig
|
|
|
119
119
|
fileProviderConfig,
|
|
120
120
|
});
|
|
121
121
|
|
|
122
|
+
case 'langchain':
|
|
123
|
+
return buildLangChainConfig({
|
|
124
|
+
provider,
|
|
125
|
+
providerSource,
|
|
126
|
+
model,
|
|
127
|
+
modelSource,
|
|
128
|
+
temperature,
|
|
129
|
+
maxTokens,
|
|
130
|
+
scenarioConfig,
|
|
131
|
+
fileProviderConfig,
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
case 'deepagents':
|
|
135
|
+
return buildDeepAgentsConfig({
|
|
136
|
+
provider,
|
|
137
|
+
providerSource,
|
|
138
|
+
model,
|
|
139
|
+
modelSource,
|
|
140
|
+
temperature,
|
|
141
|
+
maxTokens,
|
|
142
|
+
scenarioConfig,
|
|
143
|
+
fileProviderConfig,
|
|
144
|
+
});
|
|
145
|
+
|
|
122
146
|
default:
|
|
123
147
|
// Fallback for unknown providers - treat as OpenAI-compatible
|
|
124
148
|
return buildOpenAIConfig({
|
|
@@ -478,6 +502,149 @@ function buildAnthropicConfig(options: ProviderBuildOptions): AdapterConfigResul
|
|
|
478
502
|
};
|
|
479
503
|
}
|
|
480
504
|
|
|
505
|
+
function buildLangChainConfig(options: ProviderBuildOptions): AdapterConfigResult {
|
|
506
|
+
const {
|
|
507
|
+
provider,
|
|
508
|
+
providerSource,
|
|
509
|
+
model,
|
|
510
|
+
modelSource,
|
|
511
|
+
temperature,
|
|
512
|
+
maxTokens,
|
|
513
|
+
scenarioConfig,
|
|
514
|
+
fileProviderConfig,
|
|
515
|
+
} = options;
|
|
516
|
+
|
|
517
|
+
const resolvedModel = resolveValueWithSource<string>(
|
|
518
|
+
{ value: model, source: modelSource },
|
|
519
|
+
{ value: scenarioConfig?.defaultModel, source: 'scenario' },
|
|
520
|
+
{ value: fileProviderConfig?.defaultModel, source: 'config' }
|
|
521
|
+
);
|
|
522
|
+
|
|
523
|
+
const resolvedName = resolveValueWithSource<string>(
|
|
524
|
+
{ value: scenarioConfig?.name, source: 'scenario' },
|
|
525
|
+
{ value: fileProviderConfig?.name, source: 'config' }
|
|
526
|
+
);
|
|
527
|
+
|
|
528
|
+
const resolvedRunnableType = resolveValueWithSource<string>(
|
|
529
|
+
{ value: scenarioConfig?.runnableType, source: 'scenario' },
|
|
530
|
+
{ value: fileProviderConfig?.runnableType, source: 'config' }
|
|
531
|
+
);
|
|
532
|
+
|
|
533
|
+
const resolvedTimeout = resolveValueWithSource<number>(
|
|
534
|
+
{ value: scenarioConfig?.timeout, source: 'scenario' },
|
|
535
|
+
{ value: fileProviderConfig?.timeout, source: 'config' }
|
|
536
|
+
);
|
|
537
|
+
|
|
538
|
+
// Temperature and maxTokens only come from CLI options
|
|
539
|
+
const resolvedTemperature = resolveValueWithSource<number>({ value: temperature, source: 'cli' });
|
|
540
|
+
const resolvedMaxTokens = resolveValueWithSource<number>({ value: maxTokens, source: 'cli' });
|
|
541
|
+
|
|
542
|
+
return {
|
|
543
|
+
adapterConfig: {
|
|
544
|
+
provider: 'langchain',
|
|
545
|
+
name: resolvedName.value,
|
|
546
|
+
runnableType: resolvedRunnableType.value as 'chain' | 'agent' | 'llm' | 'runnable',
|
|
547
|
+
defaultModel: resolvedModel.value,
|
|
548
|
+
timeout: resolvedTimeout.value,
|
|
549
|
+
},
|
|
550
|
+
resolvedConfig: {
|
|
551
|
+
provider,
|
|
552
|
+
model: resolvedModel.value,
|
|
553
|
+
name: resolvedName.value,
|
|
554
|
+
runnable_type: resolvedRunnableType.value,
|
|
555
|
+
timeout: resolvedTimeout.value,
|
|
556
|
+
temperature: resolvedTemperature.value,
|
|
557
|
+
max_tokens: resolvedMaxTokens.value,
|
|
558
|
+
source: {
|
|
559
|
+
provider: providerSource,
|
|
560
|
+
model: resolvedModel.source,
|
|
561
|
+
name: resolvedName.source,
|
|
562
|
+
runnable_type: resolvedRunnableType.source,
|
|
563
|
+
timeout: resolvedTimeout.source,
|
|
564
|
+
temperature: resolvedTemperature.source,
|
|
565
|
+
max_tokens: resolvedMaxTokens.source,
|
|
566
|
+
},
|
|
567
|
+
},
|
|
568
|
+
};
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
function buildDeepAgentsConfig(options: ProviderBuildOptions): AdapterConfigResult {
|
|
572
|
+
const {
|
|
573
|
+
provider,
|
|
574
|
+
providerSource,
|
|
575
|
+
model,
|
|
576
|
+
modelSource,
|
|
577
|
+
temperature,
|
|
578
|
+
maxTokens,
|
|
579
|
+
scenarioConfig,
|
|
580
|
+
fileProviderConfig,
|
|
581
|
+
} = options;
|
|
582
|
+
|
|
583
|
+
const resolvedModel = resolveValueWithSource<string>(
|
|
584
|
+
{ value: model, source: modelSource },
|
|
585
|
+
{ value: scenarioConfig?.defaultModel, source: 'scenario' },
|
|
586
|
+
{ value: fileProviderConfig?.defaultModel, source: 'config' }
|
|
587
|
+
);
|
|
588
|
+
|
|
589
|
+
const resolvedName = resolveValueWithSource<string>(
|
|
590
|
+
{ value: scenarioConfig?.name, source: 'scenario' },
|
|
591
|
+
{ value: fileProviderConfig?.name, source: 'config' }
|
|
592
|
+
);
|
|
593
|
+
|
|
594
|
+
const resolvedTimeout = resolveValueWithSource<number>(
|
|
595
|
+
{ value: scenarioConfig?.timeout, source: 'scenario' },
|
|
596
|
+
{ value: fileProviderConfig?.timeout, source: 'config' },
|
|
597
|
+
{ value: 300000, source: 'default' } // 5 minute default for multi-agent systems
|
|
598
|
+
);
|
|
599
|
+
|
|
600
|
+
const resolvedCaptureTraces = resolveValueWithSource<boolean>(
|
|
601
|
+
{ value: scenarioConfig?.captureTraces, source: 'scenario' },
|
|
602
|
+
{ value: fileProviderConfig?.captureTraces, source: 'config' },
|
|
603
|
+
{ value: true, source: 'default' }
|
|
604
|
+
);
|
|
605
|
+
|
|
606
|
+
const resolvedCaptureMessages = resolveValueWithSource<boolean>(
|
|
607
|
+
{ value: scenarioConfig?.captureMessages, source: 'scenario' },
|
|
608
|
+
{ value: fileProviderConfig?.captureMessages, source: 'config' },
|
|
609
|
+
{ value: true, source: 'default' }
|
|
610
|
+
);
|
|
611
|
+
|
|
612
|
+
// Temperature and maxTokens only come from CLI options
|
|
613
|
+
const resolvedTemperature = resolveValueWithSource<number>({ value: temperature, source: 'cli' });
|
|
614
|
+
const resolvedMaxTokens = resolveValueWithSource<number>({ value: maxTokens, source: 'cli' });
|
|
615
|
+
|
|
616
|
+
return {
|
|
617
|
+
adapterConfig: {
|
|
618
|
+
provider: 'deepagents',
|
|
619
|
+
name: resolvedName.value,
|
|
620
|
+
defaultModel: resolvedModel.value,
|
|
621
|
+
timeout: resolvedTimeout.value,
|
|
622
|
+
captureTraces: resolvedCaptureTraces.value,
|
|
623
|
+
captureMessages: resolvedCaptureMessages.value,
|
|
624
|
+
},
|
|
625
|
+
resolvedConfig: {
|
|
626
|
+
provider,
|
|
627
|
+
model: resolvedModel.value,
|
|
628
|
+
name: resolvedName.value,
|
|
629
|
+
timeout: resolvedTimeout.value,
|
|
630
|
+
capture_traces: resolvedCaptureTraces.value,
|
|
631
|
+
capture_messages: resolvedCaptureMessages.value,
|
|
632
|
+
temperature: resolvedTemperature.value,
|
|
633
|
+
max_tokens: resolvedMaxTokens.value,
|
|
634
|
+
source: {
|
|
635
|
+
provider: providerSource,
|
|
636
|
+
model: resolvedModel.source,
|
|
637
|
+
name: resolvedName.source,
|
|
638
|
+
timeout: resolvedTimeout.source,
|
|
639
|
+
capture_traces: resolvedCaptureTraces.source,
|
|
640
|
+
capture_messages: resolvedCaptureMessages.source,
|
|
641
|
+
temperature: resolvedTemperature.source,
|
|
642
|
+
max_tokens: resolvedMaxTokens.source,
|
|
643
|
+
},
|
|
644
|
+
},
|
|
645
|
+
};
|
|
646
|
+
}
|
|
647
|
+
|
|
481
648
|
/**
|
|
482
649
|
* Resolve a configuration value with source tracking
|
|
483
650
|
* Returns the first defined (non-undefined) value and its source
|