Merge remote-tracking branch 'origin/main' into fix/pr-7-review
# Conflicts: # index.ts # package.json # tests/test-pi-local.mjs
This commit is contained in:
@@ -54,6 +54,27 @@ describe("streamCommandCode — auth", () => {
|
||||
assert.equal(server.requestCount(), 0)
|
||||
})
|
||||
|
||||
it("ignores the literal env-var name and falls back to env", async () => {
|
||||
server.mockResponse({
|
||||
type: "success",
|
||||
events: [JSON.stringify({ type: "finish", finishReason: "stop" })],
|
||||
})
|
||||
const { streamCommandCode } = createTestDeps({
|
||||
apiBase: server.baseUrl(),
|
||||
env: { COMMANDCODE_API_KEY: "env-key" },
|
||||
})
|
||||
|
||||
await collectEvents(
|
||||
streamCommandCode(makeModel(), makeContext(), { apiKey: "COMMANDCODE_API_KEY" }),
|
||||
)
|
||||
|
||||
assert.equal(
|
||||
server.lastRequestHeaders().authorization,
|
||||
"Bearer env-key",
|
||||
"should resolve from env, not send the literal var name as the token",
|
||||
)
|
||||
})
|
||||
|
||||
it("uses options.apiKey in the Authorization header", async () => {
|
||||
server.mockResponse({
|
||||
type: "success",
|
||||
@@ -362,6 +383,29 @@ describe("streamCommandCode — request serialization", () => {
|
||||
assert.equal(objectAt(server.lastRequestBody(), ["params", "max_tokens"]), 8_192)
|
||||
})
|
||||
|
||||
it("serializes OMP system prompt arrays as a string", async () => {
|
||||
server.mockResponse({
|
||||
type: "success",
|
||||
events: [JSON.stringify({ type: "finish", finishReason: "stop" })],
|
||||
})
|
||||
const { streamCommandCode } = createTestDeps({ apiBase: server.baseUrl() })
|
||||
|
||||
await collectEvents(
|
||||
streamCommandCode(
|
||||
makeModel(),
|
||||
makeContext({
|
||||
systemPrompt: ["You are a test assistant.", "Use concise answers."] as unknown as string,
|
||||
}),
|
||||
{ apiKey: "mock-key" },
|
||||
),
|
||||
)
|
||||
|
||||
assert.equal(
|
||||
objectAt(server.lastRequestBody(), ["params", "system"]),
|
||||
"You are a test assistant.\n\nUse concise answers.",
|
||||
)
|
||||
})
|
||||
|
||||
it("runs onPayload and onResponse hooks", async () => {
|
||||
server.mockResponse({
|
||||
type: "success",
|
||||
|
||||
Reference in New Issue
Block a user