summaryrefslogtreecommitdiffhomepage
path: root/packages/transport-http/src/logic.test.ts
diff options
context:
space:
mode:
authorAdam Malczewski <[email protected]>2026-06-05 21:20:12 +0900
committerAdam Malczewski <[email protected]>2026-06-05 21:20:12 +0900
commit7fb3269c698ae583ea7997ce206c4ae252fd3218 (patch)
tree247d03408ecccd633290ea56b1b08811ebe460ec /packages/transport-http/src/logic.test.ts
parent4283d1f8a0bc3953e65962a2364c903d0015f047 (diff)
downloaddispatch-7fb3269c698ae583ea7997ce206c4ae252fd3218.tar.gz
dispatch-7fb3269c698ae583ea7997ce206c4ae252fd3218.zip
feat(backend): credential-store + model selection/catalog (GET /models) + per-turn cwd through orchestrator/transport/host-bin
Diffstat (limited to 'packages/transport-http/src/logic.test.ts')
-rw-r--r--packages/transport-http/src/logic.test.ts57
1 files changed, 57 insertions, 0 deletions
diff --git a/packages/transport-http/src/logic.test.ts b/packages/transport-http/src/logic.test.ts
index a0f3fe6..141549f 100644
--- a/packages/transport-http/src/logic.test.ts
+++ b/packages/transport-http/src/logic.test.ts
@@ -73,6 +73,63 @@ describe("parseChatBody", () => {
expect(result.message).toBe("hello world");
}
});
+
+ it("extracts model when present", () => {
+ const result = parseChatBody({ message: "hi", model: "opencode/m1" }, fakeId);
+ expect(isParseError(result)).toBe(false);
+ if (!isParseError(result)) {
+ expect(result.model).toBe("opencode/m1");
+ }
+ });
+
+ it("extracts cwd when present", () => {
+ const result = parseChatBody({ message: "hi", cwd: "/tmp" }, fakeId);
+ expect(isParseError(result)).toBe(false);
+ if (!isParseError(result)) {
+ expect(result.cwd).toBe("/tmp");
+ }
+ });
+
+ it("extracts both model and cwd", () => {
+ const result = parseChatBody({ message: "hi", model: "openai/gpt-4", cwd: "/home" }, fakeId);
+ expect(isParseError(result)).toBe(false);
+ if (!isParseError(result)) {
+ expect(result.model).toBe("openai/gpt-4");
+ expect(result.cwd).toBe("/home");
+ }
+ });
+
+ it("omits model when absent", () => {
+ const result = parseChatBody({ message: "hi" }, fakeId);
+ expect(isParseError(result)).toBe(false);
+ if (!isParseError(result)) {
+ expect(result.model).toBeUndefined();
+ }
+ });
+
+ it("omits cwd when absent", () => {
+ const result = parseChatBody({ message: "hi" }, fakeId);
+ expect(isParseError(result)).toBe(false);
+ if (!isParseError(result)) {
+ expect(result.cwd).toBeUndefined();
+ }
+ });
+
+ it("returns error when model is not a string", () => {
+ const result = parseChatBody({ message: "hi", model: 42 }, fakeId);
+ expect(isParseError(result)).toBe(true);
+ if (isParseError(result)) {
+ expect(result.error).toContain("model");
+ }
+ });
+
+ it("returns error when cwd is not a string", () => {
+ const result = parseChatBody({ message: "hi", cwd: true }, fakeId);
+ expect(isParseError(result)).toBe(true);
+ if (isParseError(result)) {
+ expect(result.error).toContain("cwd");
+ }
+ });
});
describe("serializeEventLine", () => {