-
Notifications
You must be signed in to change notification settings - Fork 128
[Fleet Execution] Implement appendParam in Code Generator to support FIFE options for Screen.getImage #318
Description
Objective
Extend the SDK's auto-generated getImage() method on the Screen domain class to accept an optional parameter for appending FIFE sizing options (e.g., =w1200), allowing developers to request high-resolution screenshots.
Code-Level Diagnosis
Code path: packages/sdk/scripts/ir-schema.ts, packages/sdk/scripts/generate-sdk.ts, and packages/sdk/generated/domain-map.json
Mechanism: The Screen.getImage() method is automatically generated based on the domain-map.json mapping to the get_screen MCP tool. Currently, generate-sdk.ts assumes all method arguments strictly map to tool parameters and returns the raw string projection directly, meaning it cannot take extra parameters to manipulate the return string.
Root cause: The domain-map.json and code generator lack the ability to declare a method-only parameter that gets appended to a returned string or cached string projection.
Current Implementation
// in ir-schema.ts export const ReturnSpec = z.object({ type: z.string().optional(), class: z.string().optional(), projection: z.array(ProjectionStep), array: z.boolean().optional(), });
Proposed Implementation
Files to modify: Add an appendParam: z.string().optional() field to ReturnSpec in ir-schema.ts. Modify buildMethodBody and method parameter generation in generate-sdk.ts to insert the optional string appending logic if appendParam is defined. Update domain-map.json to include "appendParam": "options" for both returns and cache block (or handle it universally via returns.appendParam for both cache check and standard return). Run bun run generate to update the generated Screen class, and update the test suite to pass arguments and verify the append behavior.
Integration (Before -> After)
// scripts/ir-schema.ts <<<<<<< SEARCH /** Whether the result is an array */ array: z.boolean().optional(), }); export type ReturnSpec = z.infer<typeof ReturnSpec>; ======= /** Whether the result is an array */ array: z.boolean().optional(), /** Optional parameter to accept in the method and append to the returned string */ appendParam: z.string().optional(), }); export type ReturnSpec = z.infer<typeof ReturnSpec>; >>>>>>> REPLACE
Test Scenarios
screen.getImage('=w1200')-> Verify it returns the cached screenshot URL with=w1200appended.screen.getImage('=s800')with no cache -> Verify it callsget_screenviacallTooland returns the URL with=s800appended.
Target Files
- packages/sdk/scripts/ir-schema.ts
- packages/sdk/scripts/generate-sdk.ts
- packages/sdk/generated/domain-map.json
- packages/sdk/generated/src/screen.ts
- packages/sdk/test/unit/sdk.test.ts
- packages/sdk/generated/stitch-sdk.lock
Boundary Rules
Restrict your modifications exclusively to the files listed in the Target Files section. Ensure your source changes are entirely backward-compatible if unowned tests outside your boundary fail. Retain all existing file names and locations outside your explicitly declared target list.
Fleet Context
- Source:
jules:session:4180635254714382826 - Link: https://jules.google.com/session/4180635254714382826