Repository navigation
feat(protocol): share role and text locator contracts - #3190
supremeboxlogos wants to merge 6 commits into
Conversation
…t-locators-protocol # Conflicts: # packages/sdk-go/internal/extensionassets/stagehand-extension.zip
🦋 Changeset detectedLatest commit: f74395e The changes in this PR will be included in the next version bump. This PR includes changesets to release 25 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
1 issue found across 32 files
Confidence score: 3/5
build-json-rpc-schema.tsdrops custom refinements, so generated SDKs can accept locator queries thatdecodeLocatorQueryrejects, including queries starting withnthor containing a nested semantic envelope. Preserve those refinements in the emitted schema.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/protocol/json-rpc/build-json-rpc-schema.ts">
<violation number="1" location="packages/protocol/json-rpc/build-json-rpc-schema.ts:64">
P2: The emitted schema drops `SemanticLocatorQuerySchema`'s custom refinements, so generated SDK models accept queries starting with `nth` or selectors containing a nested semantic envelope that `decodeLocatorQuery` rejects. Preserve these invariants in the published schema so generated models reflect the query contract.</violation>
</file>
Architecture diagram
sequenceDiagram
participant Ext as Extension
participant Proto as Protocol Package
participant SDKTs as TS SDK
participant SDKPy as Python SDK
participant SDKGo as Go SDK
participant Gen as Generator
Note over Ext,Proto: NEW: Shared Locator Query Contract
Ext->>Proto: Import decodeLocatorQuery/encodeLocatorQuery
Ext->>Proto: Import QueryStep/TextPattern types
Proto-->>Ext: Canonical query contract
Note over Proto: NEW: Schema generation
Proto->>Proto: Generate stagehand.v4.json locator_builder_models
Proto->>Proto: Export ./locator-query subpath
Note over SDKPy: NEW: Generated Python models
Proto-->>SDKPy: Schema catalog
SDKPy->>SDKPy: Generate AriaRole, GetByRoleOptions, GetByTextOptions
SDKPy->>SDKPy: Generate QueryStep, TextPattern, SemanticLocatorQuery
SDKPy->>SDKPy: WireModel with extra="forbid" validation
Note over SDKGo: NEW: Generated Go models
Proto-->>SDKGo: Schema catalog
SDKGo->>SDKGo: Generate typed structs with omitempty
SDKGo->>SDKGo: NEW: TextMatch string-or-regex type
SDKGo->>SDKGo: Strict JSON validation on unmarshal
SDKGo->>SDKGo: Non-mutating decode failures
Note over Ext: CHANGED: Import path relocation
Ext->>Ext: Switch to protocol package imports
Ext->>Ext: Generate embedded ZIP refresh
Note over Gen: NEW: Include locator models
SDKGo->>Gen: reachableDefinitions includes locator_builder_models
Gen-->>SDKGo: Generate model catalog entries
Gen-->>SDKPy: Generate model classes
alt SDK Go encoding TextMatch
SDKGo->>SDKGo: Marshal literal string or regex object
else SDK Go decoding TextMatch
SDKGo->>SDKGo: Validate strict shape without mutation
end
Note over Ext,SDKGo: Runtime usage in semantic selectors
Ext->>Ext: encodeLocatorQuery to wire format
Ext->>Ext: decodeLocatorQuery from wire format
Ext-->>SDKTs: Shared contract for integration tests
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
| .strictObject({ | ||
| roleOptions: GetByRoleOptionsSchema, | ||
| textOptions: GetByTextOptionsSchema, | ||
| query: SemanticLocatorQuerySchema, |
There was a problem hiding this comment.
P2: The emitted schema drops SemanticLocatorQuerySchema's custom refinements, so generated SDK models accept queries starting with nth or selectors containing a nested semantic envelope that decodeLocatorQuery rejects. Preserve these invariants in the published schema so generated models reflect the query contract.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At packages/protocol/json-rpc/build-json-rpc-schema.ts, line 64:
<comment>The emitted schema drops `SemanticLocatorQuerySchema`'s custom refinements, so generated SDK models accept queries starting with `nth` or selectors containing a nested semantic envelope that `decodeLocatorQuery` rejects. Preserve these invariants in the published schema so generated models reflect the query contract.</comment>
<file context>
@@ -52,6 +57,13 @@ const StagehandProtocolDocumentSchema = z
+ .strictObject({
+ roleOptions: GetByRoleOptionsSchema,
+ textOptions: GetByTextOptionsSchema,
+ query: SemanticLocatorQuerySchema,
+ })
+ .optional(),
</file context>
why
Give the SDKs one canonical locator query contract before introducing language-specific builders. Stacked on #3189. Approximately 1,060 changed lines, primarily generated contracts, with public SDK methods deliberately held for separate PRs.
what changed
test plan