chore: merge main into feat/signature-posture
Resolve generated-metadata conflicts by regenerating them on top of main. The skill references gain the inspect_signature paragraph, so the skill version moves to 29 (main already uses 28). The MCP tool catalog is now built rather than committed (#997), so it is removed here. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -5,6 +5,7 @@ import { fileURLToPath } from "node:url";
|
||||
import { execFileOutput } from "../process/ExecFileOutput.js";
|
||||
import { safeParseJson } from "../domain/safeJson.js";
|
||||
import type { NativeUiHelper } from "./NativeUiObservation.js";
|
||||
import { NATIVE_UI_HELPER_MAX_BUFFER } from "./NativeUiOutputBudget.js";
|
||||
|
||||
/** Lazily compile one owned helper per observation/scenario and remove its compiler cache. */
|
||||
export const createNativeUiHelperRuntime = () => {
|
||||
@@ -50,7 +51,7 @@ export const createNativeUiHelperRuntime = () => {
|
||||
[JSON.stringify(parameters)],
|
||||
{
|
||||
timeout: 30_000,
|
||||
maxBuffer: 16 * 1024 * 1024,
|
||||
maxBuffer: NATIVE_UI_HELPER_MAX_BUFFER,
|
||||
...(signal === undefined ? {} : { signal }),
|
||||
},
|
||||
);
|
||||
|
||||
@@ -62,7 +62,6 @@ describe("native UI screenshot validation", () => {
|
||||
{ base64: "%%%=" },
|
||||
{ base64: Buffer.from("not a PNG").toString("base64") },
|
||||
{ width: 2 },
|
||||
{ sha256: "0".repeat(64) },
|
||||
])(
|
||||
"rejects invalid screenshot field variants from the helper",
|
||||
async (change) => {
|
||||
@@ -111,6 +110,37 @@ describe("native UI screenshot validation", () => {
|
||||
);
|
||||
expect(result.ok).toBe(true);
|
||||
});
|
||||
|
||||
it("preserves an unknown AX child count and its truncation gap", async () => {
|
||||
const partial = {
|
||||
...snapshot,
|
||||
nodes: [
|
||||
{
|
||||
path: [],
|
||||
role: "AXWindow",
|
||||
title: "Fixture",
|
||||
value: null,
|
||||
actions: [],
|
||||
children_count: null,
|
||||
},
|
||||
],
|
||||
truncated: true,
|
||||
gaps: ["AX child count unavailable at path []: AXError -25204"],
|
||||
};
|
||||
const result = await observeNativeUi(
|
||||
target,
|
||||
"observe_native_ui",
|
||||
{ ...scope, accessibility: true },
|
||||
{ invoke: async () => ({ ok: true, result: partial }) },
|
||||
);
|
||||
expect(result.ok).toBe(true);
|
||||
if (result.ok)
|
||||
expect(result.value.initial).toMatchObject({
|
||||
truncated: true,
|
||||
gaps: ["AX child count unavailable at path []: AXError -25204"],
|
||||
nodes: [{ children_count: null }],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("native UI capture selection and budgets", () => {
|
||||
@@ -205,6 +235,27 @@ describe("native UI capture selection and budgets", () => {
|
||||
outcome: "cancelled",
|
||||
});
|
||||
});
|
||||
it("reports aggregate output exhaustion after individually valid captures", async () => {
|
||||
const largeSnapshot = {
|
||||
...snapshot,
|
||||
window: { ...snapshot.window, title: "x".repeat(17 * 1024 * 1024) },
|
||||
};
|
||||
const result = await observeNativeUi(
|
||||
target,
|
||||
"capture_native_ui_scenario",
|
||||
{
|
||||
...scope,
|
||||
steps: [{ kind: "wait", milliseconds: 0 }],
|
||||
},
|
||||
{ invoke: async () => ({ ok: true, result: largeSnapshot }) },
|
||||
);
|
||||
expect(result.ok).toBe(true);
|
||||
if (result.ok)
|
||||
expect(result.value.steps[0]).toMatchObject({
|
||||
outcome: "failed",
|
||||
reason: expect.stringContaining("64 MiB output budget"),
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("native UI target and cancellation failures", () => {
|
||||
|
||||
@@ -16,6 +16,10 @@ import { ProviderAdapterError } from "../domain/providerAdapterError.js";
|
||||
import { type AnalysisError } from "../domain/analysisErrorBase.js";
|
||||
import { err, ok, type Result } from "../domain/result.js";
|
||||
import { createNativeUiHelperRuntime } from "./NativeUiHelperRuntime.js";
|
||||
import {
|
||||
NATIVE_UI_OUTPUT_BUDGET_BYTES,
|
||||
NATIVE_UI_OUTPUT_WEIGHT,
|
||||
} from "./NativeUiOutputBudget.js";
|
||||
|
||||
const helper = fileURLToPath(
|
||||
new URL("../../bridge/native/ReaNativeUI.swift", import.meta.url),
|
||||
@@ -135,8 +139,10 @@ const observeWithHelper = async (
|
||||
),
|
||||
);
|
||||
launchTime = response.result.window.launch_time;
|
||||
outputBytes += 2 * Buffer.byteLength(JSON.stringify(response.result));
|
||||
if (outputBytes > 64 * 1024 * 1024)
|
||||
outputBytes +=
|
||||
NATIVE_UI_OUTPUT_WEIGHT *
|
||||
Buffer.byteLength(JSON.stringify(response.result));
|
||||
if (outputBytes > NATIVE_UI_OUTPUT_BUDGET_BYTES)
|
||||
return err(
|
||||
new AnalysisCapabilityUnavailableError(
|
||||
"native-macos",
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
const HELPER_SUCCESS_WRAPPER = Buffer.from(
|
||||
JSON.stringify({ ok: true, result: {} }),
|
||||
);
|
||||
|
||||
/** Scenario output is charged at twice the encoded result size before return. */
|
||||
export const NATIVE_UI_OUTPUT_BUDGET_BYTES = 64 * 1024 * 1024;
|
||||
export const NATIVE_UI_OUTPUT_WEIGHT = 2;
|
||||
|
||||
/** Bytes added around a result by the helper's success JSON response. */
|
||||
export const NATIVE_UI_HELPER_ENVELOPE_BYTES =
|
||||
HELPER_SUCCESS_WRAPPER.byteLength - Buffer.byteLength("{}");
|
||||
|
||||
/** Raw helper output is bounded by the scenario's existing unweighted byte budget. */
|
||||
export const NATIVE_UI_HELPER_MAX_BUFFER =
|
||||
NATIVE_UI_OUTPUT_BUDGET_BYTES + NATIVE_UI_HELPER_ENVELOPE_BYTES;
|
||||
@@ -1,36 +0,0 @@
|
||||
import { expect, it } from "vitest";
|
||||
import { parseDemangledSymbols } from "./demangle.js";
|
||||
|
||||
it.each(["ordinary name ", "ordinary\t", " "])(
|
||||
"preserves unchanged final symbol text: %j",
|
||||
(input) => {
|
||||
expect(parseDemangledSymbols([input], `${input}\n`)).toEqual([
|
||||
{ input, output: input, status: "unchanged" },
|
||||
]);
|
||||
},
|
||||
);
|
||||
|
||||
it.each(["carriage\r", "\r", "mid\rdle"])(
|
||||
"keeps carriage returns that belong to the symbol: %j",
|
||||
(input) => {
|
||||
expect(parseDemangledSymbols([input], `${input}\n`)).toEqual([
|
||||
{ input, output: input, status: "unchanged" },
|
||||
]);
|
||||
},
|
||||
);
|
||||
|
||||
it("removes only the line terminator and preserves mixed output ordering", () => {
|
||||
expect(
|
||||
parseDemangledSymbols(
|
||||
["$s4main5helloyyF", "plain "],
|
||||
"main.hello() -> ()\nplain \n",
|
||||
),
|
||||
).toEqual([
|
||||
{
|
||||
input: "$s4main5helloyyF",
|
||||
output: "main.hello() -> ()",
|
||||
status: "demangled",
|
||||
},
|
||||
{ input: "plain ", output: "plain ", status: "unchanged" },
|
||||
]);
|
||||
});
|
||||
Reference in New Issue
Block a user