@agent-smith/cli 0.0.93 → 0.0.94

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.
@@ -1,7 +1,7 @@
1
1
  import { Lm } from "@locallm/api";
2
2
  declare const backend: import("@vue/reactivity").Ref<Lm | undefined, Lm | undefined>;
3
3
  declare const backends: Record<string, Lm>;
4
- declare function initBackends(isVerbose?: boolean): Promise<void>;
4
+ declare function initBackends(): Promise<void>;
5
5
  declare function setBackend(name: string, isVerbose?: boolean): Promise<void>;
6
6
  declare function listBackends(): Promise<void>;
7
7
  export { backend, backends, initBackends, listBackends, setBackend };
@@ -7,30 +7,38 @@ import { runtimeDataError } from "../utils/user_msgs.js";
7
7
  const backend = ref();
8
8
  const backends = reactive({});
9
9
  const isBackendUp = ref(false);
10
- async function initBackends(isVerbose = false) {
10
+ async function initBackends() {
11
11
  const rmb = readBackends();
12
12
  let defaultBackendName = null;
13
13
  for (const bk of Object.values(rmb)) {
14
+ let name = bk.name;
15
+ let apiKey = "";
16
+ if (bk?.apiKey) {
17
+ if (bk.apiKey == "$OPENROUTER_API_KEY") {
18
+ const apk = process.env.OPENROUTER_API_KEY;
19
+ if (apk === undefined) {
20
+ runtimeDataError("No $OPENROUTER_API_KEY environment variable found, required for ", name);
21
+ return;
22
+ }
23
+ apiKey = apk;
24
+ }
25
+ else {
26
+ apiKey = bk.apiKey;
27
+ }
28
+ }
29
+ ;
14
30
  const lm = new Lm({
15
31
  providerType: bk.type,
16
32
  serverUrl: bk.url,
33
+ apiKey: apiKey.length > 0 ? apiKey : undefined,
17
34
  });
18
- lm.name = bk.name;
19
- if (bk?.apiKey) {
20
- lm.apiKey = bk.apiKey;
21
- }
22
- ;
23
- backends[bk.name] = lm;
35
+ backends[name] = lm;
24
36
  if (bk.isDefault) {
25
37
  defaultBackendName = bk.name;
26
38
  }
27
39
  }
28
40
  if (defaultBackendName !== null) {
29
41
  backend.value = backends[defaultBackendName];
30
- isBackendUp.value = await probeBackend(backend.value, isVerbose);
31
- if (isBackendUp.value && backend.value.providerType == "ollama") {
32
- await backend.value.modelsInfo();
33
- }
34
42
  }
35
43
  }
36
44
  async function setBackend(name, isVerbose = false) {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@agent-smith/cli",
3
3
  "description": "Agent Smith: terminal client for language model agents",
4
4
  "repository": "https://github.com/synw/agent-smith",
5
- "version": "0.0.93",
5
+ "version": "0.0.94",
6
6
  "scripts": {
7
7
  "buildrl": "rm -rf dist/* && rollup -c",
8
8
  "build": "rm -rf dist/* && tsc",