config-options.test.ts 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. import { describe, expect } from "bun:test"
  2. import type { SetSessionConfigOptionResponse } from "@agentclientprotocol/sdk"
  3. import { Effect } from "effect"
  4. import { cliIt } from "../../lib/cli-process"
  5. import { expectOk, flattenSelectOptions, selectConfigOption } from "./acp-test-client"
  6. import {
  7. createAcpClient,
  8. expectAlternateValue,
  9. expectSelectOption,
  10. initialize,
  11. newSession,
  12. verifierConfig,
  13. } from "./helpers"
  14. describe("kirincode acp config option subprocess", () => {
  15. cliIt.live(
  16. 'model option is listed with category "model"',
  17. ({ home, llm, kirincode }) =>
  18. Effect.gen(function* () {
  19. const acp = yield* createAcpClient(
  20. { kirincode },
  21. { KIRINCODE_CONFIG_CONTENT: JSON.stringify(verifierConfig(llm.url)) },
  22. )
  23. yield* initialize(acp)
  24. const model = expectSelectOption((yield* newSession(acp, home)).configOptions, "model")
  25. expect(model.category).toBe("model")
  26. expect(model.currentValue).toBe("test/test-model")
  27. expect(flattenSelectOptions(model).length).toBeGreaterThanOrEqual(2)
  28. }),
  29. 60_000,
  30. )
  31. cliIt.live(
  32. "model switch updates currentValue",
  33. ({ home, llm, kirincode }) =>
  34. Effect.gen(function* () {
  35. const acp = yield* createAcpClient(
  36. { kirincode },
  37. { KIRINCODE_CONFIG_CONTENT: JSON.stringify(verifierConfig(llm.url)) },
  38. )
  39. yield* initialize(acp)
  40. const session = yield* newSession(acp, home)
  41. const model = expectSelectOption(session.configOptions, "model")
  42. const nextModel = flattenSelectOptions(model).find((option) => option.value === "test/second-model")?.value
  43. expect(nextModel).toBe("test/second-model")
  44. const updated = expectOk(
  45. yield* acp.request<SetSessionConfigOptionResponse>("session/set_config_option", {
  46. sessionId: session.sessionId,
  47. configId: "model",
  48. value: nextModel,
  49. }),
  50. )
  51. expect(selectConfigOption(updated.configOptions, "model")?.currentValue).toBe(nextModel)
  52. }),
  53. 60_000,
  54. )
  55. cliIt.live(
  56. 'effort option is listed with category "thought_level" when selected model supports variants',
  57. ({ home, llm, kirincode }) =>
  58. Effect.gen(function* () {
  59. const acp = yield* createAcpClient(
  60. { kirincode },
  61. { KIRINCODE_CONFIG_CONTENT: JSON.stringify(verifierConfig(llm.url)) },
  62. )
  63. yield* initialize(acp)
  64. const effort = expectSelectOption((yield* newSession(acp, home)).configOptions, "effort")
  65. expect(effort.category).toBe("thought_level")
  66. expect(effort.currentValue).toBe("low")
  67. expect(flattenSelectOptions(effort).map((option) => option.value)).toEqual(["low", "high"])
  68. }),
  69. 60_000,
  70. )
  71. cliIt.live(
  72. "effort switch updates currentValue",
  73. ({ home, llm, kirincode }) =>
  74. Effect.gen(function* () {
  75. const acp = yield* createAcpClient(
  76. { kirincode },
  77. { KIRINCODE_CONFIG_CONTENT: JSON.stringify(verifierConfig(llm.url)) },
  78. )
  79. yield* initialize(acp)
  80. const session = yield* newSession(acp, home)
  81. const nextEffort = expectAlternateValue(expectSelectOption(session.configOptions, "effort"))
  82. const updated = expectOk(
  83. yield* acp.request<SetSessionConfigOptionResponse>("session/set_config_option", {
  84. sessionId: session.sessionId,
  85. configId: "effort",
  86. value: nextEffort,
  87. }),
  88. )
  89. expect(selectConfigOption(updated.configOptions, "effort")?.currentValue).toBe(nextEffort)
  90. }),
  91. 60_000,
  92. )
  93. })