sam-coder-cli 1.0.7 → 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 +14 -26
- 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) {
|
|
@@ -797,16 +780,20 @@ async function runSetup(isReconfig = false) {
|
|
|
797
780
|
console.log('✅ Configuration saved successfully!');
|
|
798
781
|
}
|
|
799
782
|
|
|
800
|
-
rl.close();
|
|
801
783
|
return config;
|
|
802
784
|
}
|
|
803
785
|
|
|
804
786
|
// Start the application
|
|
805
787
|
async function start() {
|
|
788
|
+
const rl = readline.createInterface({
|
|
789
|
+
input: process.stdin,
|
|
790
|
+
output: process.stdout
|
|
791
|
+
});
|
|
792
|
+
|
|
806
793
|
try {
|
|
807
794
|
let config = await readConfig();
|
|
808
795
|
if (!config || !config.OPENROUTER_API_KEY) {
|
|
809
|
-
config = await runSetup();
|
|
796
|
+
config = await runSetup(rl);
|
|
810
797
|
}
|
|
811
798
|
|
|
812
799
|
OPENROUTER_API_KEY = config.OPENROUTER_API_KEY;
|
|
@@ -820,13 +807,14 @@ async function start() {
|
|
|
820
807
|
console.log('1. Tool Calling (for models that support it)');
|
|
821
808
|
console.log('2. Function Calling (legacy)');
|
|
822
809
|
|
|
823
|
-
const useToolCalling = await askForMode();
|
|
810
|
+
const useToolCalling = await askForMode(rl);
|
|
824
811
|
ui.showResponse(`\nStarting in ${useToolCalling ? 'Tool Calling' : 'Function Calling'} mode...\n`);
|
|
825
812
|
|
|
826
813
|
// Start the chat with the selected mode
|
|
827
|
-
await chat(useToolCalling);
|
|
814
|
+
await chat(rl, useToolCalling);
|
|
828
815
|
} catch (error) {
|
|
829
816
|
ui.showError(error);
|
|
817
|
+
rl.close();
|
|
830
818
|
process.exit(1);
|
|
831
819
|
}
|
|
832
820
|
}
|