@bike4mind/cli 0.2.4 → 0.2.5-feat-cli-dynamic-model-fetching.17089

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.
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
package/dist/index.js CHANGED
@@ -685,100 +685,119 @@ var EXPORT_FORMAT_OPTIONS = [
685
685
  { label: "markdown", value: "markdown" },
686
686
  { label: "json", value: "json" }
687
687
  ];
688
- var CONFIG_ITEMS = [
689
- {
690
- key: "maxIterations",
691
- label: "Max Iterations",
692
- type: "select",
693
- options: MAX_ITERATIONS_OPTIONS,
694
- getValue: (config) => config.preferences.maxIterations,
695
- setValue: (config, value) => ({
696
- ...config,
697
- preferences: {
698
- ...config.preferences,
699
- maxIterations: value
700
- }
701
- })
702
- },
703
- {
704
- key: "maxTokens",
705
- label: "Max Tokens",
706
- type: "number",
707
- min: 256,
708
- max: 128e3,
709
- step: 256,
710
- getValue: (config) => config.preferences.maxTokens,
711
- setValue: (config, value) => ({
712
- ...config,
713
- preferences: {
714
- ...config.preferences,
715
- maxTokens: value
716
- }
717
- })
718
- },
719
- {
720
- key: "temperature",
721
- label: "Temperature",
722
- type: "number",
723
- min: 0,
724
- max: 2,
725
- step: 0.1,
726
- getValue: (config) => config.preferences.temperature,
727
- setValue: (config, value) => ({
728
- ...config,
729
- preferences: {
730
- ...config.preferences,
731
- temperature: value
732
- }
733
- })
734
- },
735
- {
736
- key: "autoSave",
737
- label: "Auto Save",
738
- type: "boolean",
739
- getValue: (config) => config.preferences.autoSave,
740
- setValue: (config, value) => ({
741
- ...config,
742
- preferences: {
743
- ...config.preferences,
744
- autoSave: value
745
- }
746
- })
747
- },
748
- {
749
- key: "theme",
750
- label: "Theme",
751
- type: "select",
752
- options: THEME_OPTIONS,
753
- getValue: (config) => config.preferences.theme,
754
- setValue: (config, value) => ({
755
- ...config,
756
- preferences: {
757
- ...config.preferences,
758
- theme: value
759
- }
760
- })
761
- },
762
- {
763
- key: "exportFormat",
764
- label: "Export Format",
765
- type: "select",
766
- options: EXPORT_FORMAT_OPTIONS,
767
- getValue: (config) => config.preferences.exportFormat,
768
- setValue: (config, value) => ({
769
- ...config,
770
- preferences: {
771
- ...config.preferences,
772
- exportFormat: value
773
- }
774
- })
775
- }
776
- ];
777
- function ConfigEditor({ config, onSave, onClose }) {
688
+ function buildConfigItems(availableModels) {
689
+ const modelOptions = availableModels.map((model) => ({
690
+ label: model.name,
691
+ value: model.id
692
+ }));
693
+ return [
694
+ // Model selection - first item (most important)
695
+ {
696
+ key: "model",
697
+ label: "Model",
698
+ type: "select",
699
+ options: modelOptions,
700
+ getValue: (config) => config.defaultModel,
701
+ setValue: (config, value) => ({
702
+ ...config,
703
+ defaultModel: value
704
+ })
705
+ },
706
+ {
707
+ key: "maxIterations",
708
+ label: "Max Iterations",
709
+ type: "select",
710
+ options: MAX_ITERATIONS_OPTIONS,
711
+ getValue: (config) => config.preferences.maxIterations,
712
+ setValue: (config, value) => ({
713
+ ...config,
714
+ preferences: {
715
+ ...config.preferences,
716
+ maxIterations: value
717
+ }
718
+ })
719
+ },
720
+ {
721
+ key: "maxTokens",
722
+ label: "Max Tokens",
723
+ type: "number",
724
+ min: 256,
725
+ max: 128e3,
726
+ step: 256,
727
+ getValue: (config) => config.preferences.maxTokens,
728
+ setValue: (config, value) => ({
729
+ ...config,
730
+ preferences: {
731
+ ...config.preferences,
732
+ maxTokens: value
733
+ }
734
+ })
735
+ },
736
+ {
737
+ key: "temperature",
738
+ label: "Temperature",
739
+ type: "number",
740
+ min: 0,
741
+ max: 2,
742
+ step: 0.1,
743
+ getValue: (config) => config.preferences.temperature,
744
+ setValue: (config, value) => ({
745
+ ...config,
746
+ preferences: {
747
+ ...config.preferences,
748
+ temperature: value
749
+ }
750
+ })
751
+ },
752
+ {
753
+ key: "autoSave",
754
+ label: "Auto Save",
755
+ type: "boolean",
756
+ getValue: (config) => config.preferences.autoSave,
757
+ setValue: (config, value) => ({
758
+ ...config,
759
+ preferences: {
760
+ ...config.preferences,
761
+ autoSave: value
762
+ }
763
+ })
764
+ },
765
+ {
766
+ key: "theme",
767
+ label: "Theme",
768
+ type: "select",
769
+ options: THEME_OPTIONS,
770
+ getValue: (config) => config.preferences.theme,
771
+ setValue: (config, value) => ({
772
+ ...config,
773
+ preferences: {
774
+ ...config.preferences,
775
+ theme: value
776
+ }
777
+ })
778
+ },
779
+ {
780
+ key: "exportFormat",
781
+ label: "Export Format",
782
+ type: "select",
783
+ options: EXPORT_FORMAT_OPTIONS,
784
+ getValue: (config) => config.preferences.exportFormat,
785
+ setValue: (config, value) => ({
786
+ ...config,
787
+ preferences: {
788
+ ...config.preferences,
789
+ exportFormat: value
790
+ }
791
+ })
792
+ }
793
+ ];
794
+ }
795
+ function ConfigEditor({ config, availableModels, onSave, onClose }) {
778
796
  const [selectedIndex, setSelectedIndex] = useState2(0);
779
797
  const [editedConfig, setEditedConfig] = useState2(config);
780
798
  const [saveError, setSaveError] = useState2(null);
781
799
  const [isSaving, setIsSaving] = useState2(false);
800
+ const configItems = useMemo2(() => buildConfigItems(availableModels), [availableModels]);
782
801
  const hasChanges = useMemo2(() => {
783
802
  return JSON.stringify(config.preferences) !== JSON.stringify(editedConfig.preferences);
784
803
  }, [config.preferences, editedConfig.preferences]);
@@ -798,13 +817,13 @@ function ConfigEditor({ config, onSave, onClose }) {
798
817
  onClose();
799
818
  };
800
819
  useInput2((input, key) => {
801
- const currentItem = CONFIG_ITEMS[selectedIndex];
820
+ const currentItem = configItems[selectedIndex];
802
821
  if (key.upArrow) {
803
- setSelectedIndex((prev) => prev > 0 ? prev - 1 : CONFIG_ITEMS.length - 1);
822
+ setSelectedIndex((prev) => prev > 0 ? prev - 1 : configItems.length - 1);
804
823
  return;
805
824
  }
806
825
  if (key.downArrow) {
807
- setSelectedIndex((prev) => prev < CONFIG_ITEMS.length - 1 ? prev + 1 : 0);
826
+ setSelectedIndex((prev) => prev < configItems.length - 1 ? prev + 1 : 0);
808
827
  return;
809
828
  }
810
829
  if ((key.escape || input === "q") && !isSaving) {
@@ -862,7 +881,7 @@ function ConfigEditor({ config, onSave, onClose }) {
862
881
  }
863
882
  return String(value);
864
883
  };
865
- return /* @__PURE__ */ React8.createElement(Box8, { flexDirection: "column", borderStyle: "round", borderColor: "cyan", paddingX: 2, paddingY: 1, marginY: 1 }, /* @__PURE__ */ React8.createElement(Box8, { justifyContent: "space-between", marginBottom: 1 }, /* @__PURE__ */ React8.createElement(Text7, { bold: true, color: "cyan" }, "Settings"), isSaving ? /* @__PURE__ */ React8.createElement(Text7, { color: "yellow" }, "Saving...") : hasChanges ? /* @__PURE__ */ React8.createElement(Text7, { dimColor: true, color: "yellow" }, "(unsaved changes)") : null), saveError && /* @__PURE__ */ React8.createElement(Box8, { marginBottom: 1 }, /* @__PURE__ */ React8.createElement(Text7, { color: "red" }, "Error: ", saveError)), /* @__PURE__ */ React8.createElement(Box8, { flexDirection: "column", marginBottom: 1 }, CONFIG_ITEMS.map((item, index) => {
884
+ return /* @__PURE__ */ React8.createElement(Box8, { flexDirection: "column", borderStyle: "round", borderColor: "cyan", paddingX: 2, paddingY: 1, marginY: 1 }, /* @__PURE__ */ React8.createElement(Box8, { justifyContent: "space-between", marginBottom: 1 }, /* @__PURE__ */ React8.createElement(Text7, { bold: true, color: "cyan" }, "Settings"), isSaving ? /* @__PURE__ */ React8.createElement(Text7, { color: "yellow" }, "Saving...") : hasChanges ? /* @__PURE__ */ React8.createElement(Text7, { dimColor: true, color: "yellow" }, "(unsaved changes)") : null), saveError && /* @__PURE__ */ React8.createElement(Box8, { marginBottom: 1 }, /* @__PURE__ */ React8.createElement(Text7, { color: "red" }, "Error: ", saveError)), /* @__PURE__ */ React8.createElement(Box8, { flexDirection: "column", marginBottom: 1 }, configItems.map((item, index) => {
866
885
  const isSelected = index === selectedIndex;
867
886
  const value = item.getValue(editedConfig);
868
887
  const displayValue = formatValue(item, value);
@@ -992,6 +1011,7 @@ function App({
992
1011
  onPermissionResponse,
993
1012
  commandHistory = [],
994
1013
  config,
1014
+ availableModels = [],
995
1015
  onSaveConfig
996
1016
  }) {
997
1017
  const messages = useCliStore((state) => state.session?.messages || []);
@@ -1033,7 +1053,15 @@ ${errorBlock}`;
1033
1053
  },
1034
1054
  [onMessage, onCommand, setIsThinking]
1035
1055
  );
1036
- return /* @__PURE__ */ React9.createElement(Box9, { flexDirection: "column" }, /* @__PURE__ */ React9.createElement(StatusBar, { sessionName, model: currentModel, tokenUsage: totalTokens }), showConfigEditor && config && onSaveConfig ? /* @__PURE__ */ React9.createElement(Box9, { flexDirection: "column", paddingX: 1 }, /* @__PURE__ */ React9.createElement(ConfigEditor, { config, onSave: onSaveConfig, onClose: () => setShowConfigEditor(false) })) : permissionPrompt ? /* @__PURE__ */ React9.createElement(Box9, { flexDirection: "column", paddingX: 1 }, /* @__PURE__ */ React9.createElement(
1056
+ return /* @__PURE__ */ React9.createElement(Box9, { flexDirection: "column" }, /* @__PURE__ */ React9.createElement(StatusBar, { sessionName, model: currentModel, tokenUsage: totalTokens }), showConfigEditor && config && onSaveConfig ? /* @__PURE__ */ React9.createElement(Box9, { flexDirection: "column", paddingX: 1 }, /* @__PURE__ */ React9.createElement(
1057
+ ConfigEditor,
1058
+ {
1059
+ config,
1060
+ availableModels,
1061
+ onSave: onSaveConfig,
1062
+ onClose: () => setShowConfigEditor(false)
1063
+ }
1064
+ )) : permissionPrompt ? /* @__PURE__ */ React9.createElement(Box9, { flexDirection: "column", paddingX: 1 }, /* @__PURE__ */ React9.createElement(
1037
1065
  PermissionPrompt,
1038
1066
  {
1039
1067
  toolName: permissionPrompt.toolName,
@@ -9215,9 +9243,32 @@ var ServerLlmBackend = class {
9215
9243
  }
9216
9244
  /**
9217
9245
  * Get available models from server
9218
- * For now, returns hardcoded list of supported models
9246
+ * Fetches from /api/models and filters for CLI-compatible models
9247
+ * Falls back to hardcoded list if API fails
9219
9248
  */
9220
9249
  async getModelInfo() {
9250
+ try {
9251
+ logger.debug("[ServerLlmBackend] Fetching models from /api/models");
9252
+ const response = await this.apiClient.get("/api/models");
9253
+ const filteredModels = response.models.filter((model) => model.type === "text" && model.supportsTools === true);
9254
+ logger.debug(`[ServerLlmBackend] Fetched ${filteredModels.length} CLI-compatible models`);
9255
+ if (filteredModels.length === 0) {
9256
+ logger.warn("[ServerLlmBackend] No CLI-compatible models found from API, using fallback");
9257
+ return this.getFallbackModels();
9258
+ }
9259
+ return filteredModels;
9260
+ } catch (error) {
9261
+ logger.warn(
9262
+ `[ServerLlmBackend] Failed to fetch models from API, using fallback: ${error instanceof Error ? error.message : String(error)}`
9263
+ );
9264
+ return this.getFallbackModels();
9265
+ }
9266
+ }
9267
+ /**
9268
+ * Fallback models when API is unavailable
9269
+ * Returns hardcoded list of commonly supported models
9270
+ */
9271
+ getFallbackModels() {
9221
9272
  return [
9222
9273
  {
9223
9274
  id: "claude-sonnet-4-5-20250929",
@@ -9402,7 +9453,7 @@ import { isAxiosError as isAxiosError2 } from "axios";
9402
9453
  // package.json
9403
9454
  var package_default = {
9404
9455
  name: "@bike4mind/cli",
9405
- version: "0.2.4",
9456
+ version: "0.2.5-feat-cli-dynamic-model-fetching.17089+db1b07944",
9406
9457
  type: "module",
9407
9458
  description: "Interactive CLI tool for Bike4Mind with ReAct agents",
9408
9459
  license: "UNLICENSED",
@@ -9503,11 +9554,11 @@ var package_default = {
9503
9554
  zustand: "^4.5.4"
9504
9555
  },
9505
9556
  devDependencies: {
9506
- "@bike4mind/agents": "workspace:*",
9507
- "@bike4mind/common": "workspace:*",
9508
- "@bike4mind/mcp": "workspace:*",
9509
- "@bike4mind/services": "workspace:*",
9510
- "@bike4mind/utils": "workspace:*",
9557
+ "@bike4mind/agents": "0.1.0",
9558
+ "@bike4mind/common": "2.37.1-feat-cli-dynamic-model-fetching.17089+db1b07944",
9559
+ "@bike4mind/mcp": "1.19.6-feat-cli-dynamic-model-fetching.17089+db1b07944",
9560
+ "@bike4mind/services": "2.32.2-feat-cli-dynamic-model-fetching.17089+db1b07944",
9561
+ "@bike4mind/utils": "2.1.1-feat-cli-dynamic-model-fetching.17089+db1b07944",
9511
9562
  "@types/diff": "^5.0.9",
9512
9563
  "@types/jsonwebtoken": "^9.0.4",
9513
9564
  "@types/node": "^22.9.0",
@@ -9518,7 +9569,8 @@ var package_default = {
9518
9569
  tsx: "^4.21.0",
9519
9570
  typescript: "^5.9.3",
9520
9571
  vitest: "^3.2.4"
9521
- }
9572
+ },
9573
+ gitHead: "db1b079442c65e5ec9a8c27df0190d14e6950889"
9522
9574
  };
9523
9575
 
9524
9576
  // src/config/constants.ts
@@ -9801,8 +9853,10 @@ Remember: Use context from previous messages to understand follow-up questions.`
9801
9853
  agent,
9802
9854
  mcpManager,
9803
9855
  permissionManager,
9804
- config
9856
+ config,
9805
9857
  // Store config for synchronous access
9858
+ availableModels: models
9859
+ // Store models for ConfigEditor
9806
9860
  }));
9807
9861
  setStoreSession(newSession);
9808
9862
  setIsInitialized(true);
@@ -10238,6 +10292,7 @@ No usage data available for the last ${USAGE_DAYS} days.`);
10238
10292
  onCommand: handleCommand,
10239
10293
  commandHistory,
10240
10294
  config: state.config,
10295
+ availableModels: state.availableModels,
10241
10296
  onSaveConfig: handleSaveConfig,
10242
10297
  onPermissionResponse: (response) => {
10243
10298
  if (state.permissionPrompt) {
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bike4mind/cli",
3
- "version": "0.2.4",
3
+ "version": "0.2.5-feat-cli-dynamic-model-fetching.17089+db1b07944",
4
4
  "type": "module",
5
5
  "description": "Interactive CLI tool for Bike4Mind with ReAct agents",
6
6
  "license": "UNLICENSED",
@@ -30,6 +30,15 @@
30
30
  "dist",
31
31
  "bin"
32
32
  ],
33
+ "scripts": {
34
+ "dev": "tsx src/index.tsx",
35
+ "build": "tsup",
36
+ "typecheck": "tsc --noEmit",
37
+ "test": "vitest run",
38
+ "test:watch": "vitest",
39
+ "start": "node dist/index.js",
40
+ "prepublishOnly": "pnpm build"
41
+ },
33
42
  "dependencies": {
34
43
  "@anthropic-ai/sdk": "^0.22.0",
35
44
  "@aws-sdk/client-apigatewaymanagementapi": "3.654.0",
@@ -92,6 +101,11 @@
92
101
  "zustand": "^4.5.4"
93
102
  },
94
103
  "devDependencies": {
104
+ "@bike4mind/agents": "0.1.0",
105
+ "@bike4mind/common": "2.37.1-feat-cli-dynamic-model-fetching.17089+db1b07944",
106
+ "@bike4mind/mcp": "1.19.6-feat-cli-dynamic-model-fetching.17089+db1b07944",
107
+ "@bike4mind/services": "2.32.2-feat-cli-dynamic-model-fetching.17089+db1b07944",
108
+ "@bike4mind/utils": "2.1.1-feat-cli-dynamic-model-fetching.17089+db1b07944",
95
109
  "@types/diff": "^5.0.9",
96
110
  "@types/jsonwebtoken": "^9.0.4",
97
111
  "@types/node": "^22.9.0",
@@ -101,19 +115,7 @@
101
115
  "tsup": "^8.5.1",
102
116
  "tsx": "^4.21.0",
103
117
  "typescript": "^5.9.3",
104
- "vitest": "^3.2.4",
105
- "@bike4mind/agents": "0.1.0",
106
- "@bike4mind/mcp": "1.19.5",
107
- "@bike4mind/services": "2.32.1",
108
- "@bike4mind/utils": "2.1.0",
109
- "@bike4mind/common": "2.37.0"
118
+ "vitest": "^3.2.4"
110
119
  },
111
- "scripts": {
112
- "dev": "tsx src/index.tsx",
113
- "build": "tsup",
114
- "typecheck": "tsc --noEmit",
115
- "test": "vitest run",
116
- "test:watch": "vitest",
117
- "start": "node dist/index.js"
118
- }
119
- }
120
+ "gitHead": "db1b079442c65e5ec9a8c27df0190d14e6950889"
121
+ }