xlang-ai/CUA-Gym / .claude/skills/mock_websites
mock_websites
FlaggedHow to set up and manipulate mock web application state via HTTP APIs for CUA-Gym tasks. For setup-gen and reward-gen agents.
schemas/visa_portal_ds160_mock.md
View on GitHub# visa_portal_ds160_mock Schema
**Deploy order**: 54 (alphabetical among all *_mock dirs, BASE_PORT=8000 -> port 8054)
**Base URL**: `http://172.17.46.46:8054/`
**Go Endpoint**: `GET /go?sid=<sid>` -> `{initial_state, current_state, state_diff}`
**Inject**: `POST /post?sid=<sid>` with body `{"action":"set","state":{...}}` (use `"merge":true` for partial update)
**Update current only**: `POST /post?sid=<sid>` with body `{"action":"set_current","state":{...}}`
**Reset**: `POST /post?sid=<sid>` with body `{"action":"reset"}`
**Upload files**: `POST /upload?sid=<sid>` (multipart/form-data) -> `{success, files: [{original_name, stored_name, size, content_type, url}]}`
**Serve files**: `GET /files/<sid>/<filename>`
Note: vite.config.js uses `port: 0` (random). Actual port depends on deployment config. The inject endpoint is `/post`, not `/go`. State is stored in localStorage under keys `ds160_state` / `ds160_initialState` (or `ds160_state_<sid>` / `ds160_initialState_<sid>` when a session ID is provided).
## Application Overview
This mock simulates the **U.S. Nonimmigrant Visa Application (DS-160)** form from the Consular Electronic Application Center. It is a multi-step form wizard that walks through sections of the visa application: personal information, address/phone, passport, travel, family, work/education, security, photo upload, review, and sign/submit.
### Routes
| Route | Component | Description |
|-------|-----------|-------------|
| `/` | `Landing` | Start page: select embassy location, enter captcha, start or retrieve application |
| `/retrieve` | `RetrieveApplication` | Retrieve a previously saved application by ID and security question |
| `/application/security-question` | `SecurityQuestion` | Choose and answer a security question (shown after starting a new application) |
| `/application/id-generation` | `AppIdDisplay` | Displays the generated Application ID; user records it before continuing |
| `/application/personal1` | `PersonalInfo1` | Personal Information 1 form (surname, given name, DOB, birth place, etc.) |
| `/application/personal2` | PlaceholderPage | Personal Information 2 (placeholder) |
| `/application/address` | PlaceholderPage | Address & Phone (placeholder) |
| `/application/passport` | PlaceholderPage | Passport (placeholder) |
| `/application/travel` | PlaceholderPage | Travel (placeholder) |
| `/application/usContact` | PlaceholderPage | U.S. Contact (placeholder) |
| `/application/family` | PlaceholderPage | Family (placeholder) |
| `/application/work` | PlaceholderPage | Work / Education / Training (placeholder) |
| `/application/security` | PlaceholderPage | Security and Background (placeholder) |
| `/application/photo` | PlaceholderPage | Photo (placeholder) |
| `/application/review` | PlaceholderPage | Review (placeholder) |
| `/application/sign` | PlaceholderPage | Sign and Submit (placeholder) |
| `/go` | `Go` | State inspector: shows initial_state, current_state, state_diff side-by-side |
Routes under `/application/*` (except `security-question` and `id-generation`) are rendered inside `ApplicationLayout`, which provides a top info bar (location, application ID, session timer), a progress bar, and a sidebar navigation panel.
## State Schema
The entire application state is a single flat object with these top-level keys:
| Key | Type | Description |
|-----|------|-------------|
| `ds160Application` | object | Application metadata: ID, location, status, timestamps, current section |
| `personalInfo` | object | Contains `personal1` and `personal2` sub-objects for applicant personal details |
| `addressAndPhone` | object | Home/mailing address, phone numbers, email addresses |
| `meta` | object | Session metadata: last saved time, session expiration |
### `ds160Application` subfields
| Field | Type | Default | Description |
|-------|------|---------|-------------|
| `applicationId` | string | `""` | Auto-generated ID in format `AA00XXXXXX` (4 prefix chars + 6 random alphanumeric). Generated by `generateAppId()` when starting a new application. |
| `location` | string | `""` | Embassy/consulate location code. Possible values: `"CAN"` (Canada, Toronto), `"CHN"` (China, Beijing), `"FRA"` (France, Paris), `"GBR"` (United Kingdom, London), `"IND"` (India, New Delhi), `"MEX"` (Mexico, Mexico City) |
| `status` | string | `"Not Started"` | Application status. Known value: `"Not Started"` |
| `createdAt` | string\|null | `null` | ISO 8601 timestamp set when application is created (when `generateAppId()` runs) |
| `updatedAt` | string\|null | `null` | ISO 8601 timestamp (not currently set by any handler in the code) |
| `currentSection` | string | `"start"` | Tracks current form section. Possible values: `"start"`, `"personal1"`, `"personal2"`, `"address"`, `"passport"`, `"travel"`, `"travelCompanions"`, `"previousTravel"`, `"usContact"`, `"family"`, `"work"`, `"security"`, `"photo"`, `"review"`, `"sign"` |
### `personalInfo.personal1` subfields
| Field | Type | Default | Description |
|-------|------|---------|-------------|
| `surname` | string | `""` | Family name(s) as in passport (uppercase) |
| `givenName` | string | `""` | Given/first name(s) as in passport (uppercase) |
| `nativeFullName` | string | `""` | Full name in native alphabet characters |
| `nativeFullNameDoesNotApply` | boolean | `false` | Check if native alphabet not applicable |
| `otherNamesUsed` | string | `"No"` | Whether applicant has used other names. Values: `"Yes"`, `"No"` |
| `otherNames` | array | `[]` | List of other names used (when `otherNamesUsed` is `"Yes"`) |
| `telecodeName` | string | `"No"` | Whether applicant has a telecode name. Values: `"Yes"`, `"No"` |
| `telecodeNames` | array | `[]` | List of telecode names |
| `sex` | string | `""` | Applicant sex. Values: `"Male"`, `"Female"`, or `""` |
| `maritalStatus` | string | `""` | Marital status. Values: `"MARRIED"`, `"SINGLE"`, `"WIDOWED"`, `"DIVORCED"`, or `""` |
| `dobDay` | string | `""` | Day of birth (DD format) |
| `dobMonth` | string | `""` | Month of birth (e.g. `"JAN"`, `"FEB"`) |
| `dobYear` | string | `""` | Year of birth (YYYY format) |
| `pobCity` | string | `""` | City of birth |
| `pobState` | string | `""` | State/province of birth |
| `pobStateDoesNotApply` | boolean | `false` | Check if state/province not applicable |
| `pobCountry` | string | `""` | Country/region of birth |
### `personalInfo.personal2` subfields
| Field | Type | Default | Description |
|-------|------|---------|-------------|
| `nationality` | string | `""` | Country of nationality |
| `otherNationalities` | string | `"No"` | Whether applicant holds other nationalities. Values: `"Yes"`, `"No"` |
| `nationalId` | string | `""` | National identification number |
| `nationalIdDoesNotApply` | boolean | `false` | Check if national ID not applicable |
| `ssn` | string | `""` | U.S. Social Security Number |
| `ssnDoesNotApply` | boolean | `false` | Check if SSN not applicable |
| `itin` | string | `""` | U.S. Taxpayer ID (ITIN) |
| `itinDoesNotApply` | boolean | `false` | Check if ITIN not applicable |
### `addressAndPhone` subfields
| Field | Type | Default | Description |
|-------|------|---------|-------------|
| `homeAddress` | object | `{street1:"", street2:"", city:"", state:"", zip:"", country:""}` | Home address |
| `mailingSameAsHome` | string | `"Yes"` | Whether mailing address is same as home. Values: `"Yes"`, `"No"` |
| `mailingAddress` | object | `{}` | Mailing address (same shape as homeAddress when populated) |
| `primaryPhone` | string | `""` | Primary phone number |
| `secondaryPhone` | string | `""` | Secondary phone number |
| `workPhone` | string | `""` | Work phone number |
| `primaryEmail` | string | `""` | Primary email address |
| `secondaryEmail` | string | `""` | Secondary email address |
#### `homeAddress` / `mailingAddress` subfields
| Field | Type | Default | Description |
|-------|------|---------|-------------|
| `street1` | string | `""` | Street address line 1 |
| `street2` | string | `""` | Street address line 2 |
| `city` | string | `""` | City |
| `state` | string | `""` | State/province |
| `zip` | string | `""` | Postal/ZIP code |
| `country` | string | `""` | Country |
### `meta` subfields
| Field | Type | Default | Description |
|-------|------|---------|-------------|
| `lastSavedAt` | string\|null | `null` | ISO 8601 timestamp of last save |
| `sessionExpiresAt` | string\|null | `null` | ISO 8601 timestamp of session expiration |
## State Management Details
- **Pattern**: React Context (`AppContext.jsx`)
- **Context provider**: `AppProvider` wraps entire app
- **State update**: `updateState(path, value)` -- uses dot-notation path (e.g., `"personalInfo.personal1.surname"`)
- **Persistence**: localStorage with keys `ds160_state` (or `ds160_state_<sid>`) and `ds160_initialState` (or `ds160_initialState_<sid>`)
- **Session ID**: Read from URL query param `?sid=<value>` or from `sessionStorage` key `mock_sid`
- **Custom state injection**: On first load for a session, fetches `GET /state?sid=<sid>` to check for server-injected state. Deep-merges with defaults.
- **Initial state snapshot**: Captured once on first load; used by `/go` for diff calculation
## Minimal Inject Example
```json
{
"type": "chrome_open_url",
"parameters": {
"url": "http://172.17.46.46:8054/?sid=task01",
"inject_state": true,
"state_content": {
"action": "set",
"state": {
"ds160Application": {
"applicationId": "AA00K7M2P9",
"location": "CHN",
"status": "Not Started",
"createdAt": "2025-03-01T10:00:00Z",
"updatedAt": null,
"currentSection": "personal1"
},
"personalInfo": {
"personal1": {
"surname": "",
"givenName": "",
"nativeFullName": "",
"nativeFullNameDoesNotApply": false,
"otherNamesUsed": "No",
"otherNames": [],
"telecodeName": "No",
"telecodeNames": [],
"sex": "",
"maritalStatus": "",
"dobDay": "",
"dobMonth": "",
"dobYear": "",
"pobCity": "",
"pobState": "",
"pobStateDoesNotApply": false,
"pobCountry": ""
},
"personal2": {
"nationality": "",
"otherNationalities": "No",
"nationalId": "",
"nationalIdDoesNotApply": false,
"ssn": "",
"ssnDoesNotApply": false,
"itin": "",
"itinDoesNotApply": false
}
},
"addressAndPhone": {
"homeAddress": {
"street1": "",
"street2": "",
"city": "",
"state": "",
"zip": "",
"country": ""
},
"mailingSameAsHome": "Yes",
"mailingAddress": {},
"primaryPhone": "",
"secondaryPhone": "",
"workPhone": "",
"primaryEmail": "",
"secondaryEmail": ""
},
"meta": {
"lastSavedAt": null,
"sessionExpiresAt": null
}
}
}
}
}
```
## Pre-filled State Example (application in progress)
```json
{
"action": "set",
"state": {
"ds160Application": {
"applicationId": "AA00X3RQBN",
"location": "GBR",
"status": "Not Started",
"createdAt": "2025-02-15T14:30:00Z",
"updatedAt": null,
"currentSection": "personal1"
},
"personalInfo": {
"personal1": {
"surname": "WANG",
"givenName": "XIAOMING",
"nativeFullName": "",
"nativeFullNameDoesNotApply": true,
"otherNamesUsed": "No",
"otherNames": [],
"telecodeName": "No",
"telecodeNames": [],
"sex": "Male",
"maritalStatus": "SINGLE",
"dobDay": "15",
"dobMonth": "MAR",
"dobYear": "1990",
"pobCity": "BEIJING",
"pobState": "BEIJING",
"pobStateDoesNotApply": false,
"pobCountry": "CHINA"
},
"personal2": {
"nationality": "CHINA",
"otherNationalities": "No",
"nationalId": "110101199003150011",
"nationalIdDoesNotApply": false,
"ssn": "",
"ssnDoesNotApply": true,
"itin": "",
"itinDoesNotApply": true
}
},
"addressAndPhone": {
"homeAddress": {
"street1": "123 CHANGAN AVENUE",
"street2": "APT 5B",
"city": "BEIJING",
"state": "BEIJING",
"zip": "100000",
"country": "CHINA"
},
"mailingSameAsHome": "Yes",
"mailingAddress": {},
"primaryPhone": "+86-10-12345678",
"secondaryPhone": "",
"workPhone": "+86-10-87654321",
"primaryEmail": "xiaoming.wang@example.com",
"secondaryEmail": ""
},
"meta": {
"lastSavedAt": "2025-02-15T15:00:00Z",
"sessionExpiresAt": null
}
}
}
```
## Observable State Changes (for LLM evaluation)
| User Action | State Field(s) Changed |
|-------------|------------------------|
| Select embassy location and click "START AN APPLICATION" | `ds160Application.location` set to location code (e.g. `"CHN"`), `ds160Application.applicationId` set to generated ID (e.g. `"AA00K7M2P9"`), `ds160Application.createdAt` set to ISO timestamp |
| Fill in surname on Personal 1 page | `personalInfo.personal1.surname` set to entered value |
| Fill in given name on Personal 1 page | `personalInfo.personal1.givenName` set to entered value |
| Enter native full name | `personalInfo.personal1.nativeFullName` set to entered value |
| Check "Does Not Apply" for native name | `personalInfo.personal1.nativeFullNameDoesNotApply` -> `true` |
| Select "Yes" for other names used | `personalInfo.personal1.otherNamesUsed` -> `"Yes"` |
| Check "Does Not Apply" for state of birth | `personalInfo.personal1.pobStateDoesNotApply` -> `true` |
| Retrieve application with matching ID | `ds160Application.applicationId` and `ds160Application.location` updated from form input; navigates to `/application/personal1` |
## Sidebar Navigation Sections
The sidebar in `ApplicationLayout` lists all form sections. These correspond to the `currentSection` values:
1. Getting Started (`start`)
2. Personal 1 (`personal1`)
3. Personal 2 (`personal2`)
4. Address & Phone (`address`)
5. Passport (`passport`)
6. Travel (`travel`)
7. Travel Companions (`travelCompanions`)
8. Previous U.S. Travel (`previousTravel`)
9. U.S. Contact (`usContact`)
10. Family (`family`)
11. Work / Education / Training (`work`)
12. Security and Background (`security`)
13. Photo (`photo`)
14. Review (`review`)
15. Sign and Submit (`sign`)
## Progress Bar Steps
The progress bar at the top of the application layout displays:
`Personal 1` | `Personal 2` | `Address & Phone` | `Passport` | `Travel` | `U.S. Contact` | `Family` | `Work / Education / Training` | `Security & Background` | `Photo` | `Review` | `Sign & Submit` | `Confirmation`
## Notes
- Only `PersonalInfo1` has full form field binding to state. Other sections (`personal2` through `sign`) are placeholder pages with static content and "Next Section" navigation links.
- The `SecurityQuestion` page does NOT persist the chosen question or answer to state -- it only navigates forward on submit.
- The `RetrieveApplication` page validates the entered Application ID against `state.ds160Application.applicationId` in localStorage. If they do not match, a red error banner is shown.
- The `generateAppId()` function creates IDs with prefix `"AA00"` followed by 6 random characters from `A-Z0-9`.
- The comment `// ... other sections initialized empty ...` in `AppContext.jsx` suggests the INITIAL_STATE in the source code may be truncated; the actual default state includes `ds160Application`, `personalInfo`, `addressAndPhone`, and `meta`.
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness. | Stars: 323k | Updated | Claude CodeCodex | Verified | Install |
| dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies | Stars: 323k | Updated | Claude CodeCodex | Verified | Install |
| executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available | Stars: 323k | Updated | Claude CodeCodex | Verified | Install |