Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 15, 2026

Versions 0.1.10+ fail at runtime with ERR_MODULE_NOT_FOUND because the built dist/sdkProtocolVersion.js imports ../../sdk-protocol-version.json, which is excluded from the published package.

Changes

  • Extended scripts/update-protocol-version.ts to generate TypeScript code (already generates Go/Python/C#)
  • Generated src/sdkProtocolVersion.ts with protocol version as a hardcoded constant
  • Fixed npm script name from generate-protocol-version.tsupdate-protocol-version.ts

Before

import sdkProtocolVersion from "../../sdk-protocol-version.json";

export function getSdkProtocolVersion(): number {
    return sdkProtocolVersion.version;
}

After

export const SDK_PROTOCOL_VERSION = 1;

export function getSdkProtocolVersion(): number {
    return SDK_PROTOCOL_VERSION;
}

Built output now contains no external imports, consistent with other SDK languages.

Original prompt

This section details on the original issue you should resolve

<issue_title>Missing Module Error in SDK Versions 0.1.10 and 0.1.11</issue_title>
<issue_description>## Summary
@github/copilot-sdk versions 0.1.10 and 0.1.11 fail at runtime with ERR_MODULE_NOT_FOUND due to an incorrect import statement in dist/sdkProtocolVersion.js. Version 0.1.9 works correctly.

Environment

  • Node.js: v22.21.1
  • Platform: GitHub Actions (ubuntu-latest)
  • Module Type: ESM ("type": "module")

Error Message

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '@github/sdk-protocol-version.json' 
imported from /home/runner/work/.../node_modules/@github/copilot-sdk/dist/sdkProtocolVersion.js

Affected Versions

Version Status
0.1.9 ✅ Works
0.1.10 ❌ Broken
0.1.11 ❌ Broken

Reproduction Steps

  1. Create a new Node.js project with "type": "module"
  2. Install @github/copilot-sdk@0.1.11 (or 0.1.10)
  3. Import any module from the SDK
  4. Run with Node.js 22.x

Workaround

Pin to version 0.1.9:

"@github/copilot-sdk": "0.1.9"

</issue_description>

<agent_instructions>Make sure to build and test the built package</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits January 15, 2026 02:35
Co-authored-by: friggeri <106686+friggeri@users.noreply.github.com>
Co-authored-by: friggeri <106686+friggeri@users.noreply.github.com>
Co-authored-by: friggeri <106686+friggeri@users.noreply.github.com>
@friggeri friggeri marked this pull request as ready for review January 15, 2026 02:41
@friggeri friggeri requested a review from a team as a code owner January 15, 2026 02:41
Copilot AI review requested due to automatic review settings January 15, 2026 02:41
@friggeri friggeri enabled auto-merge January 15, 2026 02:42
Copilot AI changed the title [WIP] Fix missing module error in SDK versions 0.1.10 and 0.1.11 Fix ERR_MODULE_NOT_FOUND by codegen sdkProtocolVersion.ts Jan 15, 2026
Copilot AI requested a review from friggeri January 15, 2026 02:42
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request fixes a critical module resolution error in SDK versions 0.1.10 and 0.1.11 where the TypeScript SDK was attempting to import sdk-protocol-version.json, but the JSON file was not included in the npm package distribution. The fix generates a TypeScript file with hardcoded protocol version constants instead of importing from JSON, consistent with how Go, Python, and .NET SDKs already handle protocol versioning.

Changes:

  • Updated update-protocol-version.ts script to generate TypeScript code with hardcoded version constant
  • Modified nodejs/src/sdkProtocolVersion.ts to export a constant instead of importing JSON
  • Fixed npm script name from generate-protocol-version to update-protocol-version
  • Updated comments across all language implementations to reference the correct script name

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
nodejs/src/sdkProtocolVersion.ts Replaced JSON import with hardcoded SDK_PROTOCOL_VERSION constant
nodejs/scripts/update-protocol-version.ts Added TypeScript code generation to create version constants
nodejs/package.json Fixed script name to match actual filename
python/copilot/sdk_protocol_version.py Updated generated code comment to reference correct script
go/sdk_protocol_version.go Updated generated code comment to reference correct script
dotnet/src/SdkProtocolVersion.cs Updated generated code comment to reference correct script

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@friggeri friggeri added this pull request to the merge queue Jan 15, 2026
Merged via the queue into main with commit 9f752b7 Jan 15, 2026
31 checks passed
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.

Missing Module Error in SDK Versions 0.1.10 and 0.1.11

3 participants