Skip to content

Conversation

constewart9
Copy link

@constewart9 constewart9 commented Aug 14, 2025

Problem

Definitions in chat.ts are not shared between FLARE and IDE Q plugins. Differences in definitions can lead to runtime errors. Need to move towards a single source of truth that can be used to generate definitions in all client languages, starting with TypeScript.

Solution

This tool allows the generation of TypeScript and Java definitions from a single source of truth: an OpenAPI spec JSON file. The chat.ts definitions have been translated to JSON in chatTypes.json. The TypeScript and Java definitions are then generated by OpenAPI generator along with custom mustache templates to format the output. Configuration options are set in openapitools.json that further customize the generated definitions. The other changes related to imports/exports allow for local testing, however these will change once the types are uploaded to npm and pulled in at build time.

To generate definitions, do npm run generate in types/codegen. Definitions will be generated in generated/src/models/index.ts. To build and test LSR locally with these definitions, run npm run build in types/codegen/generated/typescript. Then build LSR as normal. For sake of ease, a script was added in the root package.json called npm run gen-comp which performs all of these steps.

Developers can place as many JSON files in the types/codegen/schema as desired. generate-complete-schema.js is a script that pieces together all present JSON files, checks for formatting consistency and tests across files for overlapping definition names to prevent errors. The script then dynamically gets the version number and prepends the complete-schema.json with the appropriate OpenAPI spec header. This allows devs to split up the types into different JSON files without worrying about headers and catching compatibility issues.

This file is then used to generate types in TypeScript and Java. These types are tested to ensure completeness/extraneous definitions generated. If a definition is present in the input schema but missing in either language output, the developer is alerted with an error. Finally, some post processing of the typescript file adds import statements and type aliases that are ignored by the generator. The java generator does not ignore import statements so this step is not necessary for the java files.

NOTE: This contains changes that will be removed once upstream npm and Maven Central are set up for distribution. For example, @ local/language-server-runtimes-generated-types should be renamed to @ aws once npm is configured.

License

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@constewart9 constewart9 requested a review from a team as a code owner August 14, 2025 00:45
@constewart9 constewart9 changed the title Conorstw/types new FLARE Protocol Codegen Project to Feature Branch Aug 14, 2025
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be updated?

@@ -18,6 +18,7 @@
"author": "Amazon Web Services",
"license": "Apache-2.0",
"dependencies": {
"@aws/language-server-runtimes-types": "^0.1.56"
"@aws/language-server-runtimes-types": "^0.1.56",
"@local/language-server-runtimes-generated-types": "file:../types/codegen/generated/typescript"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you please add a comment here on what the final state should be?

tsmithsz and others added 5 commits August 18, 2025 15:02
## Problem
PAC (Proxy Auto-Configuration) file URLs were being returned directly as
proxy URLs, causing the HTTP agent to attempt CONNECT requests to PAC
file servers instead of parsing the PAC file to determine the actual
proxy configuration. This resulted in "Bad response: 501/400" errors
when enterprises used PAC files for proxy configuration.

- `501` "Not Implemented": The PAC file server doesn't support the
CONNECT method at all (like Python's http.server in the bug report)

- `400` "Bad Request": The PAC file server recognizes CONNECT but
considers it malformed or inappropriate for that endpoint

Issues: 
- aws/aws-toolkit-vscode#7900
- aws/aws-toolkit-vscode#7878


## Solution

Modified `getMacSystemProxy()` to skip PAC URLs when detected and fall
back to manual HTTP/HTTPS proxy settings. This prevents PAC file URLs
from being incorrectly used as direct proxy servers while PAC file
parsing is not yet implemented

TODO:
- Implement a PAC parser (This is a significant feature requiring
JavaScript evaluation and HTTP fetching, which is why it's currently
marked as a TODO)

## Testing


1. Created a simple PAC file server:

    ```
      # Created local.pac with content:
      function FindProxyForURL(url, host) {
          return "PROXY localhost:8080";
      }
    ```

    ```
     # Served using Python:
     python3 -m http.server 8082
   ```

    

2. Configured system to use PAC file:

    ```
sudo networksetup -setautoproxyurl "Wi-Fi"
"http://localhost:8082/local.pac"
      sudo networksetup -setautoproxystate "Wi-Fi" on
   ```

    

Test Results:

    With PAC Configuration:
        AWS extension incorrectly tried to use PAC file URL as proxy
        
       
<img width="505" height="161" alt="Screenshot 2025-08-18 at 1 05 49 PM"
src="https://github.com/user-attachments/assets/f9d70581-7f34-41c0-83a7-f0324701d288"
/>


    Without PAC:
        Successfully connected
        
<img width="1624" height="971" alt="Screenshot 2025-08-18 at 1 41 38 PM"
src="https://github.com/user-attachments/assets/34db6523-e3ed-4afd-8276-b3c117c5855e"
/>


<!---
    REMINDER:
    - Read CONTRIBUTING.md first.
    - Add test coverage for your changes.
    - Link to related issues/commits.
    - Testing: how did you test your changes?
    - Screenshots if applicable
-->

## License

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.
🤖 I have created a release *beep* *boop*
---


<details><summary>language-server-runtimes: 0.2.126</summary>

##
[0.2.126](aws/language-server-runtimes@language-server-runtimes/v0.2.125...language-server-runtimes/v0.2.126)
(2025-08-18)


### Bug Fixes

* skip PAC URLs in macOS proxy detection
([aws#664](aws#664))
([92fb02d](aws@92fb02d))
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
constewart9 and others added 7 commits August 19, 2025 12:29
## Problem
VSCode Q chat experiences ~60-second delays when the telemetry endpoint
`aws-language-servers.us-east-1.amazonaws.com` is not allowlisted in
corporate networks.

Root Cause:
- Telemetry initialization runs synchronously during LSP server startup
- OTLPMetricExporter and OTLPLogExporter each attempt HTTP connections
with timeouts
- Chat remains unresponsive until all telemetry timeouts complete


https://github.com/user-attachments/assets/88f89a4d-5321-4019-a3ec-8e6c87631d77

## Solution
Make telemetry initialization to be non-blocking.

Changes:
- Wrap telemetry setup in setImmediate() callback
- LSP initialization returns immediately with `{ capabilities: {} }`
- Telemetry initializes asynchronously in background

## Testing
Chat responds quickly even when telemetry URL is blocked


https://github.com/user-attachments/assets/463bff7f-df24-4daf-80e9-086b073551f2

<!---
    REMINDER:
    - Read CONTRIBUTING.md first.
    - Add test coverage for your changes.
    - Link to related issues/commits.
    - Testing: how did you test your changes?
    - Screenshots if applicable
-->

## License

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.
…ure (aws#589)

## Problem
No log output for initializeAuth failure

## Solution
Add a timeout before process kill to ensure the buffer flushes

Tested locally by directly modifying the prod artifact. Note that the
webpacked version appears to only output to `stdout` (instead of
`stderr`, which should be expected with a `console.error`
<!---
    REMINDER:
    - Read CONTRIBUTING.md first.
    - Add test coverage for your changes.
    - Link to related issues/commits.
    - Testing: how did you test your changes?
    - Screenshots if applicable
-->

## License

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.
@constewart9 constewart9 force-pushed the conorstw/types-NEW branch 2 times, most recently from 2040623 to 5d7fd5e Compare August 22, 2025 22:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants