Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions packages/agent-sdk/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -36,7 +36,7 @@ module.exports = [
},
},
{
files: ['src/**/__tests__/**/*.ts'],
files: ['src/**/__tests__/**/*.ts', 'src/**/*.test.ts', 'src/**/*.spec.ts'],
languageOptions: {
parser: tsparser,
parserOptions: {
Expand All @@ -51,7 +51,9 @@ module.exports = [
rules: {
...eslint.configs.recommended.rules,
...tseslint.configs.recommended.rules,
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
'@typescript-eslint/no-explicit-any': 'off',
'no-undef': 'off',
'no-tabs': 'error',
},
},
Expand Down
2 changes: 2 additions & 0 deletions packages/agent-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
"prepack": "npm run build && node scripts/verify-pack.mjs",
"test": "vitest run",
"prepare": "npm run build"
},
Expand Down
47 changes: 47 additions & 0 deletions packages/agent-sdk/scripts/verify-pack.mjs
Original file line number Diff line number Diff line change
@@ -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).`);
Original file line number Diff line number Diff line change
Expand Up @@ -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] ?? [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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' };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ class FakeLLM implements LLMClient {
this.responses = responses;
}

// eslint-disable-next-line @typescript-eslint/require-await
async *streamChat(_request: ChatCompletionRequest): AsyncGenerator<LLMStreamChunk> {
const next = this.responses.shift() ?? [];
for (const chunk of next) {
Expand All @@ -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<LLMStreamChunk> {
this.requests.push(request);
yield { type: 'finish' };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,7 @@ 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 {
override securityRisk(_action: ActionEvent): SecurityRisk {
throw new Error('Unexpected error');
}
}
Expand Down
12 changes: 6 additions & 6 deletions packages/agent-sdk/src/tools/__tests__/zod-tool.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ 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<string> {
async execute(args: { message: string; count?: number }, _context: ToolContext): Promise<string> {
const count = args.count ?? 1;
return args.message.repeat(count);
}
Expand All @@ -30,8 +29,10 @@ 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<void> {
async execute(
_args: { config: { enabled: boolean; options: string[] } },
_context: ToolContext,
): Promise<void> {
// Do nothing
}
}
Expand All @@ -48,8 +49,7 @@ class CustomParametersTool extends ZodTool<{ value: string }, string> {
},
};

// eslint-disable-next-line @typescript-eslint/no-unused-vars
async execute(args: { value: string }, context: ToolContext): Promise<string> {
async execute(args: { value: string }, _context: ToolContext): Promise<string> {
return args.value;
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/agent-sdk/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
"skipLibCheck": true
},
"include": ["src/**/*.ts"],
"exclude": ["src/**/__tests__/**"]
"exclude": ["src/**/__tests__/**", "src/**/*.test.ts", "src/**/*.spec.ts"]
}
Loading