From a5d70617999663631670b9c89ed5a145637fd418 Mon Sep 17 00:00:00 2001 From: Engel Nyst Date: Fri, 15 May 2026 22:56:17 +0200 Subject: [PATCH 1/3] fix: tighten agent-sdk package contents --- packages/agent-sdk/eslint.config.js | 6 ++- packages/agent-sdk/package.json | 2 + packages/agent-sdk/scripts/verify-pack.mjs | 47 +++++++++++++++++++ .../conversation/Conversation.factory.test.ts | 1 - .../LocalConversation.secretStorage.test.ts | 1 - .../conversation/LocalConversation.test.ts | 2 - .../sdk/security/__tests__/analyzer.test.ts | 1 - .../src/tools/__tests__/zod-tool.test.ts | 3 -- packages/agent-sdk/tsconfig.json | 2 +- 9 files changed, 54 insertions(+), 11 deletions(-) create mode 100644 packages/agent-sdk/scripts/verify-pack.mjs diff --git a/packages/agent-sdk/eslint.config.js b/packages/agent-sdk/eslint.config.js index 105f2333..26ffbac6 100644 --- a/packages/agent-sdk/eslint.config.js +++ b/packages/agent-sdk/eslint.config.js @@ -10,7 +10,7 @@ module.exports = [ }, { files: ['src/**/*.ts'], - ignores: ['src/**/__tests__/**'], + ignores: ['src/**/__tests__/**', 'src/**/*.test.ts', 'src/**/*.spec.ts'], languageOptions: { parser: tsparser, parserOptions: { @@ -36,7 +36,7 @@ module.exports = [ }, }, { - files: ['src/**/__tests__/**/*.ts'], + files: ['src/**/__tests__/**/*.ts', 'src/**/*.test.ts', 'src/**/*.spec.ts'], languageOptions: { parser: tsparser, parserOptions: { @@ -51,7 +51,9 @@ module.exports = [ rules: { ...eslint.configs.recommended.rules, ...tseslint.configs.recommended.rules, + '@typescript-eslint/no-unused-vars': 'off', '@typescript-eslint/no-explicit-any': 'off', + 'no-undef': 'off', 'no-tabs': 'error', }, }, diff --git a/packages/agent-sdk/package.json b/packages/agent-sdk/package.json index 86d4c5c0..78916263 100644 --- a/packages/agent-sdk/package.json +++ b/packages/agent-sdk/package.json @@ -26,6 +26,8 @@ "build:bundle": "tsup --config tsup.config.ts", "build:types": "tsc -p tsconfig.json", "lint": "eslint ./src", + "pack:verify": "npm run build && node scripts/verify-pack.mjs", + "prepublishOnly": "npm run pack:verify", "test": "vitest run", "prepare": "npm run build" }, diff --git a/packages/agent-sdk/scripts/verify-pack.mjs b/packages/agent-sdk/scripts/verify-pack.mjs new file mode 100644 index 00000000..c9511171 --- /dev/null +++ b/packages/agent-sdk/scripts/verify-pack.mjs @@ -0,0 +1,47 @@ +import { execFileSync } from 'node:child_process'; +import { readFileSync } from 'node:fs'; +import path from 'node:path'; +import { fileURLToPath } from 'node:url'; + +const packageDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..'); +const manifest = JSON.parse(readFileSync(path.join(packageDir, 'package.json'), 'utf8')); +const npmCommand = process.platform === 'win32' ? 'npm.cmd' : 'npm'; + +const packed = JSON.parse( + execFileSync( + npmCommand, + ['pack', '--json', '--dry-run', '--ignore-scripts'], + { + cwd: packageDir, + encoding: 'utf8', + stdio: ['ignore', 'pipe', 'inherit'], + }, + ), +); + +if (!Array.isArray(packed) || packed.length !== 1) { + throw new Error(`Expected a single packed artifact, received: ${JSON.stringify(packed)}`); +} + +const [{ name, version, files = [] }] = packed; +const forbiddenEntries = files + .map((file) => file.path) + .filter((filePath) => filePath.endsWith('.test.d.ts') || filePath.endsWith('.spec.d.ts')); + +if (name !== manifest.name) { + throw new Error(`Packed package name mismatch: expected ${manifest.name}, received ${name}`); +} + +if (version !== manifest.version) { + throw new Error(`Packed package version mismatch: expected ${manifest.version}, received ${version}`); +} + +if (forbiddenEntries.length > 0) { + throw new Error( + `Packed artifact unexpectedly includes test declarations:\n${forbiddenEntries + .map((filePath) => `- ${filePath}`) + .join('\n')}`, + ); +} + +console.log(`Verified ${name}@${version} pack contents (${files.length} entries).`); diff --git a/packages/agent-sdk/src/sdk/conversation/Conversation.factory.test.ts b/packages/agent-sdk/src/sdk/conversation/Conversation.factory.test.ts index 4d80804a..368b3549 100644 --- a/packages/agent-sdk/src/sdk/conversation/Conversation.factory.test.ts +++ b/packages/agent-sdk/src/sdk/conversation/Conversation.factory.test.ts @@ -30,7 +30,6 @@ vi.mock('../llm', async () => { ]; return { - // eslint-disable-next-line @typescript-eslint/require-await async *streamChat(_request: unknown) { void _request; const next = sequences[callIndex] ?? []; diff --git a/packages/agent-sdk/src/sdk/conversation/LocalConversation.secretStorage.test.ts b/packages/agent-sdk/src/sdk/conversation/LocalConversation.secretStorage.test.ts index 264ad5bb..91539fa8 100644 --- a/packages/agent-sdk/src/sdk/conversation/LocalConversation.secretStorage.test.ts +++ b/packages/agent-sdk/src/sdk/conversation/LocalConversation.secretStorage.test.ts @@ -25,7 +25,6 @@ vi.mock('../llm', async () => { } return { - // eslint-disable-next-line @typescript-eslint/require-await async *streamChat(_request: ChatCompletionRequest) { void _request; yield { type: 'finish' }; diff --git a/packages/agent-sdk/src/sdk/conversation/LocalConversation.test.ts b/packages/agent-sdk/src/sdk/conversation/LocalConversation.test.ts index 9be208da..0519518b 100644 --- a/packages/agent-sdk/src/sdk/conversation/LocalConversation.test.ts +++ b/packages/agent-sdk/src/sdk/conversation/LocalConversation.test.ts @@ -14,7 +14,6 @@ class FakeLLM implements LLMClient { this.responses = responses; } - // eslint-disable-next-line @typescript-eslint/require-await async *streamChat(_request: ChatCompletionRequest): AsyncGenerator { const next = this.responses.shift() ?? []; for (const chunk of next) { @@ -26,7 +25,6 @@ class FakeLLM implements LLMClient { class RecordingLLM implements LLMClient { requests: ChatCompletionRequest[] = []; - // eslint-disable-next-line @typescript-eslint/require-await async *streamChat(request: ChatCompletionRequest): AsyncGenerator { this.requests.push(request); yield { type: 'finish' }; diff --git a/packages/agent-sdk/src/sdk/security/__tests__/analyzer.test.ts b/packages/agent-sdk/src/sdk/security/__tests__/analyzer.test.ts index 7d505d3f..2add7c5e 100644 --- a/packages/agent-sdk/src/sdk/security/__tests__/analyzer.test.ts +++ b/packages/agent-sdk/src/sdk/security/__tests__/analyzer.test.ts @@ -119,7 +119,6 @@ describe('LLMSecurityAnalyzer', () => { it('returns HIGH risk when securityRisk throws', () => { // Create a subclass that throws class ThrowingAnalyzer extends LLMSecurityAnalyzer { - // eslint-disable-next-line @typescript-eslint/no-unused-vars override securityRisk(action: ActionEvent): SecurityRisk { throw new Error('Unexpected error'); } diff --git a/packages/agent-sdk/src/tools/__tests__/zod-tool.test.ts b/packages/agent-sdk/src/tools/__tests__/zod-tool.test.ts index f5fe6e23..b52f2e05 100644 --- a/packages/agent-sdk/src/tools/__tests__/zod-tool.test.ts +++ b/packages/agent-sdk/src/tools/__tests__/zod-tool.test.ts @@ -12,7 +12,6 @@ class TestTool extends ZodTool<{ message: string; count?: number }, string> { count: z.number().optional(), }); - // eslint-disable-next-line @typescript-eslint/no-unused-vars async execute(args: { message: string; count?: number }, context: ToolContext): Promise { const count = args.count ?? 1; return args.message.repeat(count); @@ -30,7 +29,6 @@ class NestedSchemaTool extends ZodTool<{ config: { enabled: boolean; options: st }), }); - // eslint-disable-next-line @typescript-eslint/no-unused-vars async execute(args: { config: { enabled: boolean; options: string[] } }, context: ToolContext): Promise { // Do nothing } @@ -48,7 +46,6 @@ class CustomParametersTool extends ZodTool<{ value: string }, string> { }, }; - // eslint-disable-next-line @typescript-eslint/no-unused-vars async execute(args: { value: string }, context: ToolContext): Promise { return args.value; } diff --git a/packages/agent-sdk/tsconfig.json b/packages/agent-sdk/tsconfig.json index 3949f8a9..020b1dd1 100644 --- a/packages/agent-sdk/tsconfig.json +++ b/packages/agent-sdk/tsconfig.json @@ -16,5 +16,5 @@ "skipLibCheck": true }, "include": ["src/**/*.ts"], - "exclude": ["src/**/__tests__/**"] + "exclude": ["src/**/__tests__/**", "src/**/*.test.ts", "src/**/*.spec.ts"] } From 24c4398a71748db78d6cabc104014c991e06716f Mon Sep 17 00:00:00 2001 From: Engel Nyst Date: Fri, 15 May 2026 23:55:43 +0200 Subject: [PATCH 2/3] fix: address packaging review feedback --- packages/agent-sdk/eslint.config.js | 2 +- packages/agent-sdk/package.json | 2 +- .../src/sdk/security/__tests__/analyzer.test.ts | 2 +- packages/agent-sdk/src/tools/__tests__/zod-tool.test.ts | 9 ++++++--- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/packages/agent-sdk/eslint.config.js b/packages/agent-sdk/eslint.config.js index 26ffbac6..e1bd398b 100644 --- a/packages/agent-sdk/eslint.config.js +++ b/packages/agent-sdk/eslint.config.js @@ -51,7 +51,7 @@ module.exports = [ rules: { ...eslint.configs.recommended.rules, ...tseslint.configs.recommended.rules, - '@typescript-eslint/no-unused-vars': 'off', + '@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }], '@typescript-eslint/no-explicit-any': 'off', 'no-undef': 'off', 'no-tabs': 'error', diff --git a/packages/agent-sdk/package.json b/packages/agent-sdk/package.json index 78916263..f4664542 100644 --- a/packages/agent-sdk/package.json +++ b/packages/agent-sdk/package.json @@ -27,7 +27,7 @@ "build:types": "tsc -p tsconfig.json", "lint": "eslint ./src", "pack:verify": "npm run build && node scripts/verify-pack.mjs", - "prepublishOnly": "npm run pack:verify", + "prepack": "node scripts/verify-pack.mjs", "test": "vitest run", "prepare": "npm run build" }, diff --git a/packages/agent-sdk/src/sdk/security/__tests__/analyzer.test.ts b/packages/agent-sdk/src/sdk/security/__tests__/analyzer.test.ts index 2add7c5e..ee459574 100644 --- a/packages/agent-sdk/src/sdk/security/__tests__/analyzer.test.ts +++ b/packages/agent-sdk/src/sdk/security/__tests__/analyzer.test.ts @@ -119,7 +119,7 @@ describe('LLMSecurityAnalyzer', () => { it('returns HIGH risk when securityRisk throws', () => { // Create a subclass that throws class ThrowingAnalyzer extends LLMSecurityAnalyzer { - override securityRisk(action: ActionEvent): SecurityRisk { + override securityRisk(_action: ActionEvent): SecurityRisk { throw new Error('Unexpected error'); } } diff --git a/packages/agent-sdk/src/tools/__tests__/zod-tool.test.ts b/packages/agent-sdk/src/tools/__tests__/zod-tool.test.ts index b52f2e05..3b1b730b 100644 --- a/packages/agent-sdk/src/tools/__tests__/zod-tool.test.ts +++ b/packages/agent-sdk/src/tools/__tests__/zod-tool.test.ts @@ -12,7 +12,7 @@ class TestTool extends ZodTool<{ message: string; count?: number }, string> { count: z.number().optional(), }); - async execute(args: { message: string; count?: number }, context: ToolContext): Promise { + async execute(args: { message: string; count?: number }, _context: ToolContext): Promise { const count = args.count ?? 1; return args.message.repeat(count); } @@ -29,7 +29,10 @@ class NestedSchemaTool extends ZodTool<{ config: { enabled: boolean; options: st }), }); - async execute(args: { config: { enabled: boolean; options: string[] } }, context: ToolContext): Promise { + async execute( + _args: { config: { enabled: boolean; options: string[] } }, + _context: ToolContext, + ): Promise { // Do nothing } } @@ -46,7 +49,7 @@ class CustomParametersTool extends ZodTool<{ value: string }, string> { }, }; - async execute(args: { value: string }, context: ToolContext): Promise { + async execute(args: { value: string }, _context: ToolContext): Promise { return args.value; } } From bf748bbc6edd61a0658634bc934ecb2d353925d8 Mon Sep 17 00:00:00 2001 From: Engel Nyst Date: Sat, 16 May 2026 00:39:05 +0200 Subject: [PATCH 3/3] fix: verify packed artifacts after build --- packages/agent-sdk/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/agent-sdk/package.json b/packages/agent-sdk/package.json index f4664542..4ae93d3d 100644 --- a/packages/agent-sdk/package.json +++ b/packages/agent-sdk/package.json @@ -27,7 +27,7 @@ "build:types": "tsc -p tsconfig.json", "lint": "eslint ./src", "pack:verify": "npm run build && node scripts/verify-pack.mjs", - "prepack": "node scripts/verify-pack.mjs", + "prepack": "npm run build && node scripts/verify-pack.mjs", "test": "vitest run", "prepare": "npm run build" },