mirror of
https://github.com/badlogic/pi-mono.git
synced 2026-11-05 23:37:25 +00:00
fix(coding-agent): fix CI type check and image-only steering test
- type-check subagent-extension.test.ts against the extension view like the other subagent test - update the test to current ToolRenderContext and ExtensionToolContext types - use a decodable PNG in the image-only steering test; the fake data was omitted by image processing
This commit is contained in:
parent
3e4f872654
commit
a3a1005053
4 changed files with 23 additions and 12 deletions
|
|
@ -189,7 +189,8 @@
|
|||
"include": [
|
||||
"./extensions/**/*",
|
||||
"../../*/src/**/*.d.ts",
|
||||
"../test/suite/regressions/8261-subagent-project-trust.test.ts"
|
||||
"../test/suite/regressions/8261-subagent-project-trust.test.ts",
|
||||
"../test/subagent-extension.test.ts"
|
||||
],
|
||||
"exclude": [
|
||||
"**/node_modules/**",
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import { fauxAssistantMessage, fauxToolCall, type Message } from "@earendil-work
|
|||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import subagentExtension from "../examples/extensions/subagent/index.ts";
|
||||
import { CONFIG_DIR_NAME } from "../src/config.ts";
|
||||
import type { ExtensionAPI, ExtensionContext, ToolDefinition } from "../src/core/extensions/index.ts";
|
||||
import type { ExtensionAPI, ExtensionToolContext, ToolDefinition } from "../src/core/extensions/index.ts";
|
||||
import { DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES } from "../src/core/tools/truncate.ts";
|
||||
import { createHarness, type Harness } from "./suite/harness.ts";
|
||||
|
||||
|
|
@ -111,22 +111,22 @@ function createTool(): ToolDefinition {
|
|||
return registered;
|
||||
}
|
||||
|
||||
function createContext(cwd: string): ExtensionContext {
|
||||
function createContext(cwd: string): ExtensionToolContext {
|
||||
return {
|
||||
cwd,
|
||||
hasUI: false,
|
||||
model: { provider: "test", id: "dispatch-alias" },
|
||||
thinkingLevel: "high",
|
||||
isProjectTrusted: () => false,
|
||||
} as unknown as ExtensionContext;
|
||||
} as unknown as ExtensionToolContext;
|
||||
}
|
||||
|
||||
function createInteractiveContext(
|
||||
base: ExtensionContext,
|
||||
base: ExtensionToolContext,
|
||||
confirm: (title: string, message: string) => Promise<boolean>,
|
||||
trusted = false,
|
||||
): ExtensionContext {
|
||||
return { ...base, hasUI: true, ui: { confirm }, isProjectTrusted: () => trusted } as unknown as ExtensionContext;
|
||||
): ExtensionToolContext {
|
||||
return { ...base, hasUI: true, ui: { confirm }, isProjectTrusted: () => trusted } as unknown as ExtensionToolContext;
|
||||
}
|
||||
|
||||
function singleTask(task: string, overrides: Record<string, unknown> = {}): Record<string, unknown> {
|
||||
|
|
@ -204,6 +204,10 @@ function renderText(tool: ToolDefinition, result: AgentToolResult<unknown>, expa
|
|||
expanded,
|
||||
showImages: false,
|
||||
isError: false,
|
||||
durationMs: undefined,
|
||||
outputPad: 0,
|
||||
keyText: () => "",
|
||||
keyHint: (_keybinding, description) => description,
|
||||
});
|
||||
return component.render(160).join("\n");
|
||||
}
|
||||
|
|
@ -211,7 +215,7 @@ function renderText(tool: ToolDefinition, result: AgentToolResult<unknown>, expa
|
|||
describe("subagent example extension", () => {
|
||||
let tempDir: string;
|
||||
let tool: ToolDefinition;
|
||||
let ctx: ExtensionContext;
|
||||
let ctx: ExtensionToolContext;
|
||||
const harnesses: Harness[] = [];
|
||||
|
||||
function executeSubagent(
|
||||
|
|
@ -219,7 +223,7 @@ describe("subagent example extension", () => {
|
|||
options: {
|
||||
signal?: AbortSignal;
|
||||
onUpdate?: (result: AgentToolResult<unknown>) => void;
|
||||
context?: ExtensionContext;
|
||||
context?: ExtensionToolContext;
|
||||
} = {},
|
||||
): Promise<AgentToolResult<unknown>> {
|
||||
return withFixtureInvocation(() =>
|
||||
|
|
@ -419,7 +423,9 @@ describe("subagent example extension", () => {
|
|||
expect(toolResult?.role).toBe("toolResult");
|
||||
if (toolResult?.role === "toolResult") {
|
||||
expect(toolResult.isError).toBe(true);
|
||||
expect((toolResult.details as TestSubagentDetails).results[0].errorMessage).toBe("provider evidence");
|
||||
expect((toolResult.details as unknown as TestSubagentDetails).results[0].errorMessage).toBe(
|
||||
"provider evidence",
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,10 @@ import { Type } from "typebox";
|
|||
import { afterEach, describe, expect, it } from "vitest";
|
||||
import { createHarness, getAssistantTexts, getMessageText, getUserTexts, type Harness } from "./harness.ts";
|
||||
|
||||
// Image processing omits images it cannot decode, so the fixture must be a real PNG.
|
||||
const TINY_PNG_BASE64 =
|
||||
"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8DwHwAFBQIAX8jx0gAAAABJRU5ErkJggg==";
|
||||
|
||||
async function createWaitingHarness(
|
||||
options: {
|
||||
tools?: AgentTool[];
|
||||
|
|
@ -456,7 +460,7 @@ describe("AgentSession queue characterization", () => {
|
|||
]);
|
||||
|
||||
await waitForToolStart;
|
||||
await harness.session.steer("", [{ type: "image", mimeType: "image/png", data: "ZmFrZQ==" }]);
|
||||
await harness.session.steer("", [{ type: "image", mimeType: "image/png", data: TINY_PNG_BASE64 }]);
|
||||
expect(harness.session.pendingMessageCount).toBe(1);
|
||||
releaseToolExecution();
|
||||
await promptPromise;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue