fix(coding-agent): repaired type errors from merge sweep
- Restored CustomInputRow.priority field dropped in 3b80dc01d ask row budgeting.
- Narrowed dereferenced schema properties via isRecord in yield-assembly and output-schema-validator instead of untyped object access.
- Renamed stale advisorReadOnlyTools to advisorTools in advisor parity test.
- Narrowed AgentMessage content access in session-loader-stream test.
- Reformatted browser-schema test to satisfy biome.
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
* depends only on the yield type and the output-schema validator.
|
||||
*/
|
||||
import { dereferenceJsonSchema } from "@oh-my-pi/pi-ai/utils/schema";
|
||||
import { isRecord } from "@oh-my-pi/pi-utils";
|
||||
import { buildOutputValidator } from "../tools/output-schema-validator";
|
||||
import type { YieldItem } from "./types";
|
||||
|
||||
@@ -107,12 +108,9 @@ export function arrayValuedLabels(outputSchema: unknown): ReadonlySet<string> {
|
||||
const { jsonSchema } = buildOutputValidator(outputSchema);
|
||||
if (jsonSchema === undefined) return labels;
|
||||
const dereferenced = dereferenceJsonSchema(jsonSchema);
|
||||
const labelSchema =
|
||||
dereferenced !== null && typeof dereferenced === "object" && !Array.isArray(dereferenced)
|
||||
? dereferenced
|
||||
: jsonSchema;
|
||||
const labelSchema = isRecord(dereferenced) ? dereferenced : jsonSchema;
|
||||
const properties = labelSchema.properties;
|
||||
if (properties === null || typeof properties !== "object" || Array.isArray(properties)) return labels;
|
||||
if (!isRecord(properties)) return labels;
|
||||
for (const key in properties) {
|
||||
if (isArrayTypedSchema(properties[key])) labels.add(key);
|
||||
}
|
||||
|
||||
@@ -262,6 +262,7 @@ interface CustomInputRow {
|
||||
/** Lower priority drops first when over budget; negative values are pinned.
|
||||
* Gap markers are budgeted rows too so sparse checked selections cannot
|
||||
* push the editor input off-screen. */
|
||||
priority: number;
|
||||
}
|
||||
|
||||
function buildCustomInputRows(
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
type JsonSchemaValidationResult,
|
||||
validateJsonSchemaValue,
|
||||
} from "@oh-my-pi/pi-ai/utils/schema";
|
||||
import { isRecord } from "@oh-my-pi/pi-utils";
|
||||
import { jtdToJsonSchema, normalizeSchema } from "./jtd-to-json-schema";
|
||||
|
||||
/** A validator bound to a specific output schema. */
|
||||
@@ -119,10 +120,10 @@ function buildSectionValidators(
|
||||
): ReadonlyMap<string, (value: unknown) => JsonSchemaValidationResult> {
|
||||
const validators = new Map<string, (value: unknown) => JsonSchemaValidationResult>();
|
||||
const properties = jsonSchema.properties;
|
||||
if (properties === null || typeof properties !== "object" || Array.isArray(properties)) return validators;
|
||||
if (!isRecord(properties)) return validators;
|
||||
for (const label in properties) {
|
||||
const raw = properties[label];
|
||||
const propRecord = raw !== null && typeof raw === "object" && !Array.isArray(raw) ? raw : undefined;
|
||||
const propRecord = isRecord(raw) ? raw : undefined;
|
||||
const sectionSchema =
|
||||
propRecord?.type === "array" && propRecord.items !== undefined && propRecord.items !== null
|
||||
? propRecord.items
|
||||
|
||||
@@ -186,7 +186,7 @@ describe("AgentSession advisor provider-options parity", () => {
|
||||
sessionManager,
|
||||
settings: settings(),
|
||||
modelRegistry,
|
||||
advisorReadOnlyTools: [],
|
||||
advisorTools: [],
|
||||
});
|
||||
session.settings.setModelRole("advisor", "anthropic/claude-sonnet-4-5");
|
||||
expect(session.setAdvisorEnabled(true)).toBe(true);
|
||||
|
||||
@@ -55,7 +55,9 @@ function messageTexts(entries: FileEntry[]): string[] {
|
||||
const texts: string[] = [];
|
||||
for (const entry of entries) {
|
||||
if (entry.type !== "message") continue;
|
||||
const content = entry.message.content;
|
||||
const message: unknown = entry.message;
|
||||
if (!message || typeof message !== "object" || !("content" in message)) continue;
|
||||
const content = message.content;
|
||||
if (!Array.isArray(content)) continue;
|
||||
const first = content[0];
|
||||
if (
|
||||
|
||||
@@ -35,9 +35,9 @@ describe("browser tool schema", () => {
|
||||
|
||||
expect(validateJsonSchemaValue(toolWireSchema(tool), call.arguments).success).toBe(true);
|
||||
expect(validateToolCall([tool], call)).toEqual(call.arguments);
|
||||
await expect(
|
||||
tool.execute("browser-run-without-code", args),
|
||||
).rejects.toThrow(/Missing required parameter 'code' for action 'run'/);
|
||||
await expect(tool.execute("browser-run-without-code", args)).rejects.toThrow(
|
||||
/Missing required parameter 'code' for action 'run'/,
|
||||
);
|
||||
});
|
||||
|
||||
it("accepts run calls with code at schema validation", () => {
|
||||
|
||||
Reference in New Issue
Block a user