-
Notifications
You must be signed in to change notification settings - Fork 294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Agent: Bundle WASM artifacts #3386
Conversation
"name": "@sourcegraph/cody-agent", | ||
"name": "@sourcegraph/agent", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This rename is necessary so the build artifacts are still called agent-
and not cody-agent-
. We don't use that name anywhere though so it should be fine.
"latest-win-x64", | ||
"latest-macos-arm64" | ||
], | ||
"assets": "dist/*.{wasm,map}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have to use to this pkg
syntax and define the wasm artifact here so it'll be inlined properly.
agent/scripts/test-agent-binary.ts
Outdated
name: 'defaultClient', | ||
accessToken, | ||
}, | ||
'./dist/agent-macos-arm64' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So that test will only work on windows? Can we pickup proper binary depending on the platform?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, I'll copy paste the right version selector here if we ever need to debug on win envs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Closes #3302
This PR ensures that cody agent always has access to the WASM artifacts. While building this, we found out that it is necessary to bundle the wasm inside the binary:
Since we have more than one agent build, this would result in a huge increase in bundle size. We offset that by adding gzip compression. I tried brotli but due to the nature of not having centralized builds yet, it's not worth the additional build time.
Here are the final bundle size changes (for the aarch build):
Test plan
I added a new script that we can use to play around with the binary under
agent/scripts/test-agent-binary.ts
. You can use it to see that WASM works:cd agent/
pnpm run build-agent-binaries
pnpm run test-agent-binary
This will output something like this. Notice the addition of the intent which requires wasm to load 😎