Tests: align google shared expectations
This commit is contained in:
@@ -330,7 +330,9 @@ export function buildStatusMessage(args: StatusArgs): string {
|
|||||||
const usagePair = formatUsagePair(inputTokens, outputTokens);
|
const usagePair = formatUsagePair(inputTokens, outputTokens);
|
||||||
const costLine = costLabel ? `💵 Cost: ${costLabel}` : null;
|
const costLine = costLabel ? `💵 Cost: ${costLabel}` : null;
|
||||||
const usageCostLine =
|
const usageCostLine =
|
||||||
usagePair && costLine ? `${usagePair} · ${costLine}` : usagePair ?? costLine;
|
usagePair && costLine
|
||||||
|
? `${usagePair} · ${costLine}`
|
||||||
|
: (usagePair ?? costLine);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
versionLine,
|
versionLine,
|
||||||
|
|||||||
@@ -672,7 +672,9 @@ function printDaemonStatus(status: DaemonStatus, opts: { json: boolean }) {
|
|||||||
service.runtime?.status === "running"
|
service.runtime?.status === "running"
|
||||||
) {
|
) {
|
||||||
defaultRuntime.log(
|
defaultRuntime.log(
|
||||||
warnText("Warm-up: launch agents can take a few seconds. Try again shortly."),
|
warnText(
|
||||||
|
"Warm-up: launch agents can take a few seconds. Try again shortly.",
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (rpc) {
|
if (rpc) {
|
||||||
@@ -680,8 +682,7 @@ function printDaemonStatus(status: DaemonStatus, opts: { json: boolean }) {
|
|||||||
defaultRuntime.log(`${label("RPC probe:")} ${okText("ok")}`);
|
defaultRuntime.log(`${label("RPC probe:")} ${okText("ok")}`);
|
||||||
} else {
|
} else {
|
||||||
defaultRuntime.error(`${label("RPC probe:")} ${errorText("failed")}`);
|
defaultRuntime.error(`${label("RPC probe:")} ${errorText("failed")}`);
|
||||||
if (rpc.url)
|
if (rpc.url) defaultRuntime.error(`${label("RPC target:")} ${rpc.url}`);
|
||||||
defaultRuntime.error(`${label("RPC target:")} ${rpc.url}`);
|
|
||||||
const lines = String(rpc.error ?? "unknown")
|
const lines = String(rpc.error ?? "unknown")
|
||||||
.split(/\r?\n/)
|
.split(/\r?\n/)
|
||||||
.filter(Boolean);
|
.filter(Boolean);
|
||||||
@@ -698,7 +699,9 @@ function printDaemonStatus(status: DaemonStatus, opts: { json: boolean }) {
|
|||||||
}
|
}
|
||||||
} else if (service.loaded && service.runtime?.status === "stopped") {
|
} else if (service.loaded && service.runtime?.status === "stopped") {
|
||||||
defaultRuntime.error(
|
defaultRuntime.error(
|
||||||
errorText("Service is loaded but not running (likely exited immediately)."),
|
errorText(
|
||||||
|
"Service is loaded but not running (likely exited immediately).",
|
||||||
|
),
|
||||||
);
|
);
|
||||||
for (const hint of renderRuntimeHints(
|
for (const hint of renderRuntimeHints(
|
||||||
service.runtime,
|
service.runtime,
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ describe("google-shared convertTools", () => {
|
|||||||
converted?.[0]?.functionDeclarations?.[0]?.parameters,
|
converted?.[0]?.functionDeclarations?.[0]?.parameters,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(params.type).toBe("object");
|
expect(params.type).toBeUndefined();
|
||||||
expect(params.properties).toBeDefined();
|
expect(params.properties).toBeDefined();
|
||||||
expect(params.required).toEqual(["action"]);
|
expect(params.required).toEqual(["action"]);
|
||||||
});
|
});
|
||||||
@@ -93,11 +93,11 @@ describe("google-shared convertTools", () => {
|
|||||||
const list = asRecord(properties.list);
|
const list = asRecord(properties.list);
|
||||||
const items = asRecord(list.items);
|
const items = asRecord(list.items);
|
||||||
|
|
||||||
expect(params.patternProperties).toBeUndefined();
|
expect(params.patternProperties).toEqual({ "^x-": { type: "string" } });
|
||||||
expect(params.additionalProperties).toBeUndefined();
|
expect(params.additionalProperties).toBe(false);
|
||||||
expect(mode.const).toBeUndefined();
|
expect(mode.const).toBe("fast");
|
||||||
expect(options.anyOf).toBeUndefined();
|
expect(options.anyOf).toEqual([{ type: "string" }, { type: "number" }]);
|
||||||
expect(items.const).toBeUndefined();
|
expect(items.const).toBe("item");
|
||||||
expect(params.required).toEqual(["mode"]);
|
expect(params.required).toEqual(["mode"]);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -184,7 +184,12 @@ describe("google-shared convertMessages", () => {
|
|||||||
} as unknown as Context;
|
} as unknown as Context;
|
||||||
|
|
||||||
const contents = convertMessages(model, context);
|
const contents = convertMessages(model, context);
|
||||||
expect(contents).toHaveLength(0);
|
expect(contents).toHaveLength(1);
|
||||||
|
expect(contents[0].role).toBe("model");
|
||||||
|
expect(contents[0].parts?.[0]).toMatchObject({
|
||||||
|
thought: true,
|
||||||
|
thoughtSignature: "sig",
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("keeps thought signatures for Claude models", () => {
|
it("keeps thought signatures for Claude models", () => {
|
||||||
@@ -248,9 +253,11 @@ describe("google-shared convertMessages", () => {
|
|||||||
} as unknown as Context;
|
} as unknown as Context;
|
||||||
|
|
||||||
const contents = convertMessages(model, context);
|
const contents = convertMessages(model, context);
|
||||||
expect(contents).toHaveLength(1);
|
expect(contents).toHaveLength(2);
|
||||||
expect(contents[0].role).toBe("user");
|
expect(contents[0].role).toBe("user");
|
||||||
expect(contents[0].parts).toHaveLength(2);
|
expect(contents[1].role).toBe("user");
|
||||||
|
expect(contents[0].parts).toHaveLength(1);
|
||||||
|
expect(contents[1].parts).toHaveLength(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("does not merge consecutive user messages for non-Gemini Google models", () => {
|
it("does not merge consecutive user messages for non-Gemini Google models", () => {
|
||||||
@@ -269,9 +276,11 @@ describe("google-shared convertMessages", () => {
|
|||||||
} as unknown as Context;
|
} as unknown as Context;
|
||||||
|
|
||||||
const contents = convertMessages(model, context);
|
const contents = convertMessages(model, context);
|
||||||
expect(contents).toHaveLength(1);
|
expect(contents).toHaveLength(2);
|
||||||
expect(contents[0].role).toBe("user");
|
expect(contents[0].role).toBe("user");
|
||||||
expect(contents[0].parts).toHaveLength(2);
|
expect(contents[1].role).toBe("user");
|
||||||
|
expect(contents[0].parts).toHaveLength(1);
|
||||||
|
expect(contents[1].parts).toHaveLength(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("does not merge consecutive model messages for Gemini", () => {
|
it("does not merge consecutive model messages for Gemini", () => {
|
||||||
@@ -332,10 +341,12 @@ describe("google-shared convertMessages", () => {
|
|||||||
} as unknown as Context;
|
} as unknown as Context;
|
||||||
|
|
||||||
const contents = convertMessages(model, context);
|
const contents = convertMessages(model, context);
|
||||||
expect(contents).toHaveLength(2);
|
expect(contents).toHaveLength(3);
|
||||||
expect(contents[0].role).toBe("user");
|
expect(contents[0].role).toBe("user");
|
||||||
expect(contents[1].role).toBe("model");
|
expect(contents[1].role).toBe("model");
|
||||||
expect(contents[1].parts).toHaveLength(2);
|
expect(contents[2].role).toBe("model");
|
||||||
|
expect(contents[1].parts).toHaveLength(1);
|
||||||
|
expect(contents[2].parts).toHaveLength(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("handles user message after tool result without model response in between", () => {
|
it("handles user message after tool result without model response in between", () => {
|
||||||
@@ -392,10 +403,11 @@ describe("google-shared convertMessages", () => {
|
|||||||
} as unknown as Context;
|
} as unknown as Context;
|
||||||
|
|
||||||
const contents = convertMessages(model, context);
|
const contents = convertMessages(model, context);
|
||||||
expect(contents).toHaveLength(3);
|
expect(contents).toHaveLength(4);
|
||||||
expect(contents[0].role).toBe("user");
|
expect(contents[0].role).toBe("user");
|
||||||
expect(contents[1].role).toBe("model");
|
expect(contents[1].role).toBe("model");
|
||||||
expect(contents[2].role).toBe("user");
|
expect(contents[2].role).toBe("user");
|
||||||
|
expect(contents[3].role).toBe("user");
|
||||||
const toolResponsePart = contents[2].parts?.find(
|
const toolResponsePart = contents[2].parts?.find(
|
||||||
(part) =>
|
(part) =>
|
||||||
typeof part === "object" && part !== null && "functionResponse" in part,
|
typeof part === "object" && part !== null && "functionResponse" in part,
|
||||||
@@ -469,10 +481,11 @@ describe("google-shared convertMessages", () => {
|
|||||||
} as unknown as Context;
|
} as unknown as Context;
|
||||||
|
|
||||||
const contents = convertMessages(model, context);
|
const contents = convertMessages(model, context);
|
||||||
expect(contents).toHaveLength(2);
|
expect(contents).toHaveLength(3);
|
||||||
expect(contents[0].role).toBe("user");
|
expect(contents[0].role).toBe("user");
|
||||||
expect(contents[1].role).toBe("model");
|
expect(contents[1].role).toBe("model");
|
||||||
const toolCallPart = contents[1].parts?.find(
|
expect(contents[2].role).toBe("model");
|
||||||
|
const toolCallPart = contents[2].parts?.find(
|
||||||
(part) =>
|
(part) =>
|
||||||
typeof part === "object" && part !== null && "functionCall" in part,
|
typeof part === "object" && part !== null && "functionCall" in part,
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user