pi-llama-cpp 0.11.0 → 0.12.0

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,11 +1,6 @@
1
- import { getAgentDir } from "@earendil-works/pi-coding-agent";
2
1
  import { beforeEach, describe, expect, it, vi } from "vitest";
3
2
  import { SettingsStore } from "../src/utils/settingsStore";
4
3
 
5
- vi.mock("@earendil-works/pi-coding-agent", () => ({
6
- getAgentDir: vi.fn().mockReturnValue("/fake/agent/dir"),
7
- }));
8
-
9
4
  const mockReadFile = vi.hoisted(() => vi.fn());
10
5
  const mockWriteFile = vi.hoisted(() => vi.fn());
11
6
  const mockRename = vi.hoisted(() => vi.fn());
@@ -16,14 +11,11 @@ vi.mock("node:fs/promises", () => ({
16
11
  rename: mockRename,
17
12
  }));
18
13
 
19
- const mockGetAgentDir = vi.mocked(getAgentDir);
20
-
21
14
  const SETTINGS_PATH = "/fake/agent/dir/settings.json";
22
15
 
23
16
  describe("SettingsStore.read", () => {
24
17
  beforeEach(() => {
25
18
  vi.clearAllMocks();
26
- mockGetAgentDir.mockReturnValue("/fake/agent/dir");
27
19
  });
28
20
 
29
21
  it("should return {} when the file is missing (ENOENT)", async () => {
@@ -53,21 +45,11 @@ describe("SettingsStore.read", () => {
53
45
 
54
46
  await expect(store.read()).rejects.toMatchObject({ code: "EACCES" });
55
47
  });
56
-
57
- it("should default the path to <agentDir>/settings.json", async () => {
58
- mockReadFile.mockResolvedValue('{"a":1}');
59
-
60
- const store = new SettingsStore();
61
- await store.read();
62
-
63
- expect(mockReadFile).toHaveBeenCalledWith(SETTINGS_PATH, "utf-8");
64
- });
65
48
  });
66
49
 
67
50
  describe("SettingsStore.updateKey — file content", () => {
68
51
  beforeEach(() => {
69
52
  vi.clearAllMocks();
70
- mockGetAgentDir.mockReturnValue("/fake/agent/dir");
71
53
  mockWriteFile.mockResolvedValue(undefined);
72
54
  mockRename.mockResolvedValue(undefined);
73
55
  });
@@ -122,7 +104,6 @@ describe("SettingsStore.updateKey — file content", () => {
122
104
  describe("SettingsStore.updateKey — write path", () => {
123
105
  beforeEach(() => {
124
106
  vi.clearAllMocks();
125
- mockGetAgentDir.mockReturnValue("/fake/agent/dir");
126
107
  mockWriteFile.mockResolvedValue(undefined);
127
108
  mockRename.mockResolvedValue(undefined);
128
109
  });
@@ -47,6 +47,38 @@ describe("SingleModel capabilities", () => {
47
47
 
48
48
  expect(capabilities).toEqual(["text"]);
49
49
  });
50
+
51
+ it("should fall back to the models endpoint when auth fails", async () => {
52
+ mockRpc
53
+ .mockRejectedValueOnce(new Error("401 Unauthorized")) // /props
54
+ .mockRejectedValueOnce(new Error("401 Unauthorized")) // /v1/models in BaseModel's catch
55
+ .mockResolvedValueOnce({
56
+ object: "list",
57
+ data: [],
58
+ models: [{ capabilities: ["multimodal"] }],
59
+ }); // /v1/models retry in SingleModel's catch
60
+
61
+ const model = createModel();
62
+ const capabilities = await model.getCapabilities();
63
+
64
+ expect(capabilities).toEqual(["text", "image"]);
65
+ });
66
+
67
+ it("should fall back to text-only when the models endpoint reports no multimodal", async () => {
68
+ mockRpc
69
+ .mockRejectedValueOnce(new Error("401 Unauthorized")) // /props
70
+ .mockRejectedValueOnce(new Error("401 Unauthorized")) // /v1/models in BaseModel's catch
71
+ .mockResolvedValueOnce({
72
+ object: "list",
73
+ data: [],
74
+ models: [{ capabilities: ["text"] }],
75
+ }); // /v1/models retry in SingleModel's catch
76
+
77
+ const model = createModel();
78
+ const capabilities = await model.getCapabilities();
79
+
80
+ expect(capabilities).toEqual(["text"]);
81
+ });
50
82
  });
51
83
 
52
84
  describe("SingleModel getStatus", () => {
@@ -19,12 +19,12 @@ const createManager = (
19
19
  "",
20
20
  );
21
21
 
22
- describe("SSEManager timeouts", () => {
23
- it("should expose the timeouts of its server", () => {
22
+ describe("SSEManager timeouts", async () => {
23
+ it("should expose the timeouts of its server", async () => {
24
24
  const manager = createManager(5678, 1234);
25
25
 
26
- expect(manager.pollingTimeout).toBe(5678);
27
- expect(manager.serverTimeout).toBe(1234);
26
+ expect(await manager.getPollingTimeout()).toBe(5678);
27
+ expect(await manager.getServerTimeout()).toBe(1234);
28
28
  });
29
29
  });
30
30