Reverse engineer anything with agents, from app behavior down to native binaries.
TypeScript agent-skillsai-agentsbinary-analysisclaude-codeclicodexcordisdecompilerdeveloper-toolsdshdsh-pluginghidrahopperllmmcpmodel-context-protocolreareverse-engineeringstatic-analysistouhou
fix(browser): reserve the initial scenario step id from action inputs (#3493)
The one -Niu4fe88a7e3fd7
diff --git a/src/browser/PlaywrightBrowserScenarioProvider.ts b/src/browser/PlaywrightBrowserScenarioProvider.tsindex 018adbeba..dd897d295 100644--- a/src/browser/PlaywrightBrowserScenarioProvider.ts+++ b/src/browser/PlaywrightBrowserScenarioProvider.ts@@ -14,7 +14,10 @@ import type {ProviderIdentity,} from "../application/AnalysisProvider.js";import type { BrowserScenario } from "../domain/browserScenario.js";-import type { BrowserScenarioAction } from "../domain/browserScenarioValues.js";+import {+ BROWSER_SCENARIO_START_STEP_ID,+ type BrowserScenarioAction,+} from "../domain/browserScenarioValues.js";import {browserScenarioCaptureSchema,type BrowserScenarioCapture,@@ -147,7 +150,7 @@ const initialStep = async (input: {);return createStep({stepIndex: 0,- stepId: "scenario_start",+ stepId: BROWSER_SCENARIO_START_STEP_ID,action: "goto_start",status: "completed",elapsedMs,diff --git a/src/domain/browserScenario.test.ts b/src/domain/browserScenario.test.tsindex 5d393a692..877c55bc0 100644--- a/src/domain/browserScenario.test.ts+++ b/src/domain/browserScenario.test.ts@@ -197,6 +197,28 @@ it("accepts caller-selected viewport sizes and click counts without ceilings", (expect(parsed.actions[0]).toMatchObject({ click_count: 4 });});+it("refuses an action step id that the provider reserves for the initial state", () => {+ const scenario = (secondStepId: string) => ({+ browser: { mode: "launch", executable_path: "/opt/chromium" },+ start_url: { url: "https://app.example.test/" },+ actions: [+ { step_id: "open", action: "wait_for_timeout", duration_ms: 10 },+ { step_id: secondStepId, action: "wait_for_timeout", duration_ms: 10 },+ ],+ });++ expect(() => browserScenarioSchema.parse(scenario("scenario_start"))).toThrow(+ /reserved/u,+ );+ const rejected = browserScenarioSchema.safeParse(scenario("scenario_start"));+ expect(rejected.success).toBe(false);+ expect(rejected.error?.issues[0]?.path).toEqual(["actions", 1, "step_id"]);+ // Only the exact identity is reserved; a similar caller id stays valid.+ expect(+ browserScenarioSchema.parse(scenario("scenario_start_2")).actions,+ ).toHaveLength(2);+});+it.each([{field: "duration_ms",diff --git a/src/domain/browserScenario.ts b/src/domain/browserScenario.tsindex 2fd26b6a6..8be14f8cc 100644--- a/src/domain/browserScenario.ts+++ b/src/domain/browserScenario.ts@@ -2,6 +2,7 @@ import { z } from "zod";import {browserScenarioActionSchema,+ BROWSER_SCENARIO_START_STEP_ID,browserScenarioBrowserSchema,browserScenarioCaptureSchema,browserScenarioEnvironmentSchema,@@ -111,6 +112,15 @@ const validateBrowserScenario = ("Action step IDs",context,);+ const reservedIndex = scenario.actions.findIndex(+ ({ step_id: id }) => id === BROWSER_SCENARIO_START_STEP_ID,+ );+ if (reservedIndex !== -1)+ addIssue(+ context,+ ["actions", reservedIndex, "step_id"],+ "Action step IDs must not reuse the reserved initial step identity",+ );assertUnique(scenario.secrets.map(({ secret_id: id }) => id),["secrets"],diff --git a/src/domain/browserScenarioValues.ts b/src/domain/browserScenarioValues.tsindex 409579331..17f40e3c8 100644--- a/src/domain/browserScenarioValues.ts+++ b/src/domain/browserScenarioValues.ts@@ -17,6 +17,12 @@ import {export const scenarioIdentifierSchema = z.string().regex(IDENTIFIER_PATTERN);+/**+ * Step identity the provider owns for the initial-state step. Callers cannot+ * claim it, because two capture steps with one identity cannot be aligned.+ */+export const BROWSER_SCENARIO_START_STEP_ID = "scenario_start";+const browserScenarioBaseUrlSchema = z.string().min(1)