sam-coder-cli 1.0.6 → 1.0.8
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/bin/agi-cli.js +24 -30
- package/package.json +1 -1
package/bin/agi-cli.js
CHANGED
|
@@ -683,22 +683,16 @@ async function processQuery(query, conversation = []) {
|
|
|
683
683
|
}
|
|
684
684
|
|
|
685
685
|
// Main chat loop
|
|
686
|
-
async function chat(useToolCalling) {
|
|
686
|
+
async function chat(rl, useToolCalling) {
|
|
687
687
|
const conversation = [];
|
|
688
|
-
ui.showHeader();
|
|
689
688
|
console.log('Type your message, or "exit" to quit.');
|
|
690
689
|
|
|
691
|
-
|
|
692
|
-
input: process.stdin,
|
|
693
|
-
output: process.stdout,
|
|
694
|
-
prompt: '> '
|
|
695
|
-
});
|
|
696
|
-
|
|
690
|
+
rl.setPrompt('> ');
|
|
697
691
|
rl.prompt();
|
|
698
692
|
|
|
699
693
|
rl.on('line', async (input) => {
|
|
700
694
|
if (input.toLowerCase() === '/setup') {
|
|
701
|
-
await runSetup(true);
|
|
695
|
+
await runSetup(rl, true);
|
|
702
696
|
console.log('\nSetup complete. Please restart the application to apply changes.');
|
|
703
697
|
rl.close();
|
|
704
698
|
return;
|
|
@@ -727,15 +721,9 @@ async function chat(useToolCalling) {
|
|
|
727
721
|
}
|
|
728
722
|
|
|
729
723
|
// Ask user for mode selection
|
|
730
|
-
function askForMode() {
|
|
731
|
-
const rl = readline.createInterface({
|
|
732
|
-
input: process.stdin,
|
|
733
|
-
output: process.stdout
|
|
734
|
-
});
|
|
735
|
-
|
|
724
|
+
function askForMode(rl) {
|
|
736
725
|
return new Promise((resolve) => {
|
|
737
726
|
rl.question('Select mode (1 for tool calling, 2 for function calling): ', (answer) => {
|
|
738
|
-
rl.close();
|
|
739
727
|
resolve(answer.trim() === '1');
|
|
740
728
|
});
|
|
741
729
|
});
|
|
@@ -758,12 +746,7 @@ async function writeConfig(config) {
|
|
|
758
746
|
await fs.writeFile(CONFIG_PATH, JSON.stringify(config, null, 2), 'utf-8');
|
|
759
747
|
}
|
|
760
748
|
|
|
761
|
-
async function runSetup(isReconfig = false) {
|
|
762
|
-
const rl = readline.createInterface({
|
|
763
|
-
input: process.stdin,
|
|
764
|
-
output: process.stdout
|
|
765
|
-
});
|
|
766
|
-
|
|
749
|
+
async function runSetup(rl, isReconfig = false) {
|
|
767
750
|
const askQuestion = (query) => new Promise(resolve => rl.question(query, resolve));
|
|
768
751
|
|
|
769
752
|
if (!isReconfig) {
|
|
@@ -784,23 +767,33 @@ async function runSetup(isReconfig = false) {
|
|
|
784
767
|
const customEndpoint = await askQuestion('Enter custom OpenAI-compatible API endpoint: ');
|
|
785
768
|
config.isPro = true;
|
|
786
769
|
config.customApiBase = customEndpoint;
|
|
770
|
+
await writeConfig(config);
|
|
771
|
+
console.log('✅ Configuration saved successfully!');
|
|
787
772
|
} else if (proCode) {
|
|
788
|
-
|
|
773
|
+
await writeConfig(config);
|
|
774
|
+
console.log('⚠️ Invalid activation code. Standard plan configured.');
|
|
775
|
+
console.log('\nPlease restart the application to continue.');
|
|
776
|
+
rl.close();
|
|
777
|
+
process.exit(0);
|
|
778
|
+
} else {
|
|
779
|
+
await writeConfig(config);
|
|
780
|
+
console.log('✅ Configuration saved successfully!');
|
|
789
781
|
}
|
|
790
782
|
|
|
791
|
-
await writeConfig(config);
|
|
792
|
-
|
|
793
|
-
console.log('✅ Configuration saved successfully!');
|
|
794
|
-
rl.close();
|
|
795
783
|
return config;
|
|
796
784
|
}
|
|
797
785
|
|
|
798
786
|
// Start the application
|
|
799
787
|
async function start() {
|
|
788
|
+
const rl = readline.createInterface({
|
|
789
|
+
input: process.stdin,
|
|
790
|
+
output: process.stdout
|
|
791
|
+
});
|
|
792
|
+
|
|
800
793
|
try {
|
|
801
794
|
let config = await readConfig();
|
|
802
795
|
if (!config || !config.OPENROUTER_API_KEY) {
|
|
803
|
-
config = await runSetup();
|
|
796
|
+
config = await runSetup(rl);
|
|
804
797
|
}
|
|
805
798
|
|
|
806
799
|
OPENROUTER_API_KEY = config.OPENROUTER_API_KEY;
|
|
@@ -814,13 +807,14 @@ async function start() {
|
|
|
814
807
|
console.log('1. Tool Calling (for models that support it)');
|
|
815
808
|
console.log('2. Function Calling (legacy)');
|
|
816
809
|
|
|
817
|
-
const useToolCalling = await askForMode();
|
|
810
|
+
const useToolCalling = await askForMode(rl);
|
|
818
811
|
ui.showResponse(`\nStarting in ${useToolCalling ? 'Tool Calling' : 'Function Calling'} mode...\n`);
|
|
819
812
|
|
|
820
813
|
// Start the chat with the selected mode
|
|
821
|
-
await chat(useToolCalling);
|
|
814
|
+
await chat(rl, useToolCalling);
|
|
822
815
|
} catch (error) {
|
|
823
816
|
ui.showError(error);
|
|
817
|
+
rl.close();
|
|
824
818
|
process.exit(1);
|
|
825
819
|
}
|
|
826
820
|
}
|