config-options.subprocess.test.ts 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import type { SetSessionConfigOptionResponse } from "@agentclientprotocol/sdk"
  2. import { describe, expect, test } from "bun:test"
  3. import {
  4. alternateValue,
  5. createAcpFixture,
  6. expectOk,
  7. flattenSelectOptions,
  8. initialize,
  9. newSession,
  10. requireSelectOption,
  11. selectConfigOption,
  12. } from "./subprocess"
  13. describe("acp config option subprocess", () => {
  14. test('model option is listed with category "model"', async () => {
  15. await using fixture = await createAcpFixture()
  16. const acp = fixture.spawn()
  17. await initialize(acp)
  18. const model = requireSelectOption((await newSession(acp, fixture.home)).configOptions, "model")
  19. expect(model.category).toBe("model")
  20. expect(model.currentValue).toBe("test/test-model")
  21. expect(flattenSelectOptions(model).length).toBeGreaterThanOrEqual(2)
  22. }, 60_000)
  23. test("model switch updates currentValue", async () => {
  24. await using fixture = await createAcpFixture()
  25. const acp = fixture.spawn()
  26. await initialize(acp)
  27. const session = await newSession(acp, fixture.home)
  28. const model = requireSelectOption(session.configOptions, "model")
  29. const nextModel = flattenSelectOptions(model).find((option) => option.value === "test/second-model")?.value
  30. expect(nextModel).toBe("test/second-model")
  31. const updated = expectOk(
  32. await acp.request<SetSessionConfigOptionResponse>("session/set_config_option", {
  33. sessionId: session.sessionId,
  34. configId: "model",
  35. value: nextModel,
  36. }),
  37. )
  38. expect(selectConfigOption(updated.configOptions, "model")?.currentValue).toBe(nextModel)
  39. }, 60_000)
  40. test('effort option is listed with category "thought_level" when selected model supports variants', async () => {
  41. await using fixture = await createAcpFixture()
  42. const acp = fixture.spawn()
  43. await initialize(acp)
  44. const effort = requireSelectOption((await newSession(acp, fixture.home)).configOptions, "effort")
  45. expect(effort.category).toBe("thought_level")
  46. expect(effort.currentValue).toBe("low")
  47. expect(flattenSelectOptions(effort).map((option) => option.value)).toEqual(["low", "high"])
  48. }, 60_000)
  49. test("effort switch updates currentValue", async () => {
  50. await using fixture = await createAcpFixture()
  51. const acp = fixture.spawn()
  52. await initialize(acp)
  53. const session = await newSession(acp, fixture.home)
  54. const nextEffort = alternateValue(requireSelectOption(session.configOptions, "effort"))
  55. const updated = expectOk(
  56. await acp.request<SetSessionConfigOptionResponse>("session/set_config_option", {
  57. sessionId: session.sessionId,
  58. configId: "effort",
  59. value: nextEffort,
  60. }),
  61. )
  62. expect(selectConfigOption(updated.configOptions, "effort")?.currentValue).toBe(nextEffort)
  63. }, 60_000)
  64. })