Skip to content

Commit 9f752b7

Browse files
Copilotfriggeri
andauthored
Fix ERR_MODULE_NOT_FOUND by codegen sdkProtocolVersion.ts (github#10)
* Initial plan * Fix module import error by generating sdkProtocolVersion.ts from JSON Co-authored-by: friggeri <106686+friggeri@users.noreply.github.com> * Address code review feedback - update comments and regenerate files Co-authored-by: friggeri <106686+friggeri@users.noreply.github.com> * Restore package.json version to 0.1.8 Co-authored-by: friggeri <106686+friggeri@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: friggeri <106686+friggeri@users.noreply.github.com>
1 parent ea35173 commit 9f752b7

File tree

6 files changed

+41
-10
lines changed

6 files changed

+41
-10
lines changed

dotnet/src/SdkProtocolVersion.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Code generated by generate-protocol-version.ts. DO NOT EDIT.
1+
// Code generated by update-protocol-version.ts. DO NOT EDIT.
22

33
namespace GitHub.Copilot.SDK;
44

go/sdk_protocol_version.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

nodejs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"lint:fix": "eslint --fix \"src/**/*.ts\" \"test/**/*.ts\"",
2727
"typecheck": "tsc --noEmit",
2828
"generate:session-types": "tsx scripts/generate-session-types.ts",
29-
"update:protocol-version": "tsx scripts/generate-protocol-version.ts",
29+
"update:protocol-version": "tsx scripts/update-protocol-version.ts",
3030
"prepublishOnly": "npm run build",
3131
"package": "npm run clean && npm run build && node scripts/set-version.js && npm pack && npm version 0.1.0 --no-git-tag-version --allow-same-version"
3232
},

nodejs/scripts/update-protocol-version.ts

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* Generates SDK protocol version constants for all SDK languages.
77
*
88
* Reads from sdk-protocol-version.json and generates:
9+
* - nodejs/src/sdkProtocolVersion.ts
910
* - go/sdk_protocol_version.go
1011
* - python/copilot/sdk_protocol_version.py
1112
* - dotnet/src/SdkProtocolVersion.cs
@@ -26,8 +27,32 @@ const version = versionFile.version;
2627

2728
console.log(`Generating SDK protocol version constants for version ${version}...`);
2829

30+
// Generate TypeScript
31+
const tsCode = `/*---------------------------------------------------------------------------------------------
32+
* Copyright (c) Microsoft Corporation. All rights reserved.
33+
*--------------------------------------------------------------------------------------------*/
34+
35+
// Code generated by update-protocol-version.ts. DO NOT EDIT.
36+
37+
/**
38+
* The SDK protocol version.
39+
* This must match the version expected by the copilot-agent-runtime server.
40+
*/
41+
export const SDK_PROTOCOL_VERSION = ${version};
42+
43+
/**
44+
* Gets the SDK protocol version.
45+
* @returns The protocol version number
46+
*/
47+
export function getSdkProtocolVersion(): number {
48+
return SDK_PROTOCOL_VERSION;
49+
}
50+
`;
51+
fs.writeFileSync(path.join(rootDir, "nodejs", "src", "sdkProtocolVersion.ts"), tsCode);
52+
console.log(" ✓ nodejs/src/sdkProtocolVersion.ts");
53+
2954
// Generate Go
30-
const goCode = `// Code generated by generate-protocol-version.ts. DO NOT EDIT.
55+
const goCode = `// Code generated by update-protocol-version.ts. DO NOT EDIT.
3156
3257
package copilot
3358
@@ -44,7 +69,7 @@ fs.writeFileSync(path.join(rootDir, "go", "sdk_protocol_version.go"), goCode);
4469
console.log(" ✓ go/sdk_protocol_version.go");
4570

4671
// Generate Python
47-
const pythonCode = `# Code generated by generate-protocol-version.ts. DO NOT EDIT.
72+
const pythonCode = `# Code generated by update-protocol-version.ts. DO NOT EDIT.
4873
4974
"""
5075
SDK Protocol Version for the Copilot SDK.
@@ -68,7 +93,7 @@ fs.writeFileSync(path.join(rootDir, "python", "copilot", "sdk_protocol_version.p
6893
console.log(" ✓ python/copilot/sdk_protocol_version.py");
6994

7095
// Generate C#
71-
const csharpCode = `// Code generated by generate-protocol-version.ts. DO NOT EDIT.
96+
const csharpCode = `// Code generated by update-protocol-version.ts. DO NOT EDIT.
7297
7398
namespace GitHub.Copilot.SDK;
7499

nodejs/src/sdkProtocolVersion.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,18 @@
22
* Copyright (c) Microsoft Corporation. All rights reserved.
33
*--------------------------------------------------------------------------------------------*/
44

5-
import sdkProtocolVersion from "../../sdk-protocol-version.json";
5+
// Code generated by update-protocol-version.ts. DO NOT EDIT.
66

77
/**
8-
* Gets the SDK protocol version from sdk-protocol-version.json.
8+
* The SDK protocol version.
9+
* This must match the version expected by the copilot-agent-runtime server.
10+
*/
11+
export const SDK_PROTOCOL_VERSION = 1;
12+
13+
/**
14+
* Gets the SDK protocol version.
915
* @returns The protocol version number
1016
*/
1117
export function getSdkProtocolVersion(): number {
12-
return sdkProtocolVersion.version;
18+
return SDK_PROTOCOL_VERSION;
1319
}

python/copilot/sdk_protocol_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Code generated by generate-protocol-version.ts. DO NOT EDIT.
1+
# Code generated by update-protocol-version.ts. DO NOT EDIT.
22

33
"""
44
SDK Protocol Version for the Copilot SDK.

0 commit comments

Comments
 (0)