Skip to content
This repository was archived by the owner on Jun 3, 2026. It is now read-only.

Commit 9393de7

Browse files
committed
Merge remote-tracking branch 'upstream/main' into agent-tasks/05
# Conflicts: # src/__tests__/index.test.ts # vitest.config.ts
2 parents a12c105 + f46550f commit 9393de7

25 files changed

Lines changed: 1954 additions & 105 deletions

.github/workflows/integration-test.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,8 @@ jobs:
6767
- name: Install dependencies
6868
run: npm install
6969

70+
- name: Build the package
71+
run: npm run build
72+
7073
- name: Run integration tests
7174
run: npm run test:integ

.github/workflows/task-implementer-agent.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ jobs:
106106
107107
- name: Extract issue ID from PR body
108108
id: extract-issue
109-
if: github.event_name == 'pull_request'
109+
if: github.event_name == 'pull_request' || github.event_name == 'pull_request_review' || github.event_name == 'pull_request_review_comment'
110110
uses: actions/github-script@v7
111111
with:
112112
script: |

.project/tasks/task-03-implement-aws-bedrock-model-provider.md renamed to .project/tasks/completed/task-03-implement-aws-bedrock-model-provider.md

File renamed without changes.

AGENTS.md

Lines changed: 65 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,29 @@ This document provides guidance specifically for AI agents working on the Strand
1717
```
1818
sdk-typescript/
1919
├── src/ # Source code (all production code)
20-
│ ├── __tests__/ # Unit tests (co-located with source)
21-
│ │ ├── hello.test.ts # Tests for hello.ts
20+
│ ├── __tests__/ # Unit tests for root-level source files
21+
│ │ ├── errors.test.ts # Tests for error classes
2222
│ │ └── index.test.ts # Tests for main entry point
23-
│ ├── index.ts # Main SDK entry point (single export point)
24-
│ └── hello.ts # Example: Hello world function
23+
│ │
24+
│ ├── models/ # Model provider implementations
25+
│ │ ├── __tests__/ # Unit tests for model providers
26+
│ │ │ └── bedrock.test.ts # Tests for Bedrock model provider
27+
│ │ ├── bedrock.ts # AWS Bedrock model provider
28+
│ │ ├── model.ts # Base model provider interface
29+
│ │ └── streaming.ts # Streaming event types
30+
│ │
31+
│ ├── tools/ # Tool definitions and types
32+
│ │ └── types.ts # Tool-related type definitions
33+
│ │
34+
│ ├── types/ # Core type definitions
35+
│ │ ├── json.ts # JSON schema and value types
36+
│ │ └── messages.ts # Message and content block types
37+
│ │
38+
│ ├── errors.ts # Custom error classes
39+
│ └── index.ts # Main SDK entry point (single export point)
2540
2641
├── tests_integ/ # Integration tests (separate from source)
27-
│ └── environment.test.ts # Environment compatibility tests
42+
│ └── bedrock.test.ts # Bedrock integration tests (requires AWS credentials)
2843
2944
├── .github/ # GitHub Actions workflows
3045
│ ├── workflows/ # CI/CD workflows
@@ -45,7 +60,7 @@ sdk-typescript/
4560
4661
├── package.json # Project configuration and dependencies
4762
├── tsconfig.json # TypeScript compiler configuration
48-
├── vitest.config.ts # Testing configuration
63+
├── vitest.config.ts # Testing configuration (with unit/integ projects)
4964
├── eslint.config.js # Linting configuration
5065
├── .prettierrc # Code formatting configuration
5166
├── .gitignore # Git ignore rules
@@ -59,11 +74,16 @@ sdk-typescript/
5974
### Directory Purposes
6075

6176
- **`src/`**: All production code lives here with co-located unit tests
62-
- **`src/__tests__/`**: Unit tests for specific source files (tests internal functionality)
77+
- **`src/__tests__/`**: Unit tests for root-level source files
78+
- **`src/models/`**: Model provider implementations (Bedrock, future providers)
79+
- **`src/tools/`**: Tool definitions and types for agent tool use
80+
- **`src/types/`**: Core type definitions used across the SDK
6381
- **`tests_integ/`**: Integration tests (tests public API and external integrations)
6482
- **`.github/workflows/`**: CI/CD automation and quality gates
6583
- **`.project/`**: Task management and project tracking
6684

85+
**IMPORTANT**: After making changes that affect the directory structure (adding new directories, moving files, or adding significant new files), you MUST update this directory structure section to reflect the current state of the repository.
86+
6787
## Development Workflow for Agents
6888

6989
### 1. Environment Setup
@@ -93,23 +113,19 @@ All checks must pass before commit is allowed.
93113

94114
## Coding Patterns and Best Practices
95115

96-
### TypeScript Path Aliases
116+
### Import Organization
97117

98-
Use path aliases for cleaner imports:
118+
Use relative imports for internal modules:
99119

100120
```typescript
101-
// Good: Use path alias
102-
import { hello } from '@/hello'
103-
import { Agent } from '@/agent'
121+
// Good: Relative imports for internal modules
122+
import { hello } from './hello'
123+
import { Agent } from '../agent'
104124

105-
// Avoid: Relative paths
106-
import { hello } from '../hello'
107-
import { Agent } from '../../agent'
125+
// Good: External dependencies
126+
import { something } from 'external-package'
108127
```
109128

110-
**Configuration**: Path aliases are configured in `tsconfig.json` and `vitest.config.ts`:
111-
- `@/*` maps to `src/*`
112-
113129
### File Organization Pattern
114130

115131
**For source files**:
@@ -133,7 +149,7 @@ Follow this nested describe pattern for consistency:
133149
**For functions**:
134150
```typescript
135151
import { describe, it, expect } from 'vitest'
136-
import { functionName } from '@/module'
152+
import { functionName } from '../module'
137153

138154
describe('functionName', () => {
139155
describe('when called with valid input', () => {
@@ -155,7 +171,7 @@ describe('functionName', () => {
155171
**For classes**:
156172
```typescript
157173
import { describe, it, expect } from 'vitest'
158-
import { ClassName } from '@/module'
174+
import { ClassName } from '../module'
159175

160176
describe('ClassName', () => {
161177
describe('methodName', () => {
@@ -274,11 +290,33 @@ export function functionName(paramName: string, optionalParam?: number): string
274290
}
275291
```
276292

293+
**Interface property documentation**:
294+
295+
```typescript
296+
/**
297+
* Interface description.
298+
*/
299+
export interface MyConfig {
300+
/**
301+
* Single-line description of the property.
302+
*/
303+
propertyName: string
304+
305+
/**
306+
* Single-line description with optional reference link.
307+
* @see https://docs.example.com/property-details
308+
*/
309+
anotherProperty?: number
310+
}
311+
```
312+
277313
**Requirements**:
278314
- All exported functions, classes, and interfaces must have TSDoc
279315
- Include `@param` for all parameters
280316
- Include `@returns` for return values
281317
- Include `@example` for complex functionality
318+
- Interface properties MUST have single-line descriptions
319+
- Interface properties MAY include an optional `@see` link for additional details
282320
- TSDoc validation enforced by ESLint
283321

284322
### Code Style Guidelines
@@ -313,12 +351,12 @@ Organize imports in this order:
313351
// 1. External dependencies
314352
import { something } from 'external-package'
315353

316-
// 2. Internal modules (using path aliases)
317-
import { Agent } from '@/agent'
318-
import { Tool } from '@/tools'
354+
// 2. Internal modules (using relative paths)
355+
import { Agent } from '../agent'
356+
import { Tool } from '../tools'
319357

320358
// 3. Types (if separate)
321-
import type { Options, Config } from '@/types'
359+
import type { Options, Config } from '../types'
322360
```
323361

324362
### Interface and Type Organization
@@ -519,9 +557,9 @@ it('yields expected stream events', async () => {
519557

520558
**Example Implementation Test:**
521559
```typescript
522-
describe('BedrockModelProvider', () => {
560+
describe('BedrockModel', () => {
523561
it('streams messages correctly', async () => {
524-
const provider = new BedrockModelProvider(config)
562+
const provider = new BedrockModel(config)
525563
const stream = provider.stream(messages)
526564

527565
for await (const event of stream) {
@@ -536,7 +574,7 @@ describe('BedrockModelProvider', () => {
536574
## Things to Do
537575

538576
**Do**:
539-
- Use path aliases (`@/`) for all imports
577+
- Use relative imports for internal modules
540578
- Co-locate unit tests with source under `__tests__` directories
541579
- Follow nested describe pattern for test organization
542580
- Write explicit return types for all functions
@@ -550,7 +588,6 @@ describe('BedrockModelProvider', () => {
550588

551589
**Don't**:
552590
- Use `any` type (enforced by ESLint)
553-
- Use relative paths like `../` when path aliases are available
554591
- Put unit tests in separate `tests/` directory (use `src/**/__tests__/**`)
555592
- Skip documentation for exported functions
556593
- Use semicolons (Prettier will remove them)
@@ -576,13 +613,6 @@ npm run build # Compile TypeScript
576613

577614
## Troubleshooting Common Issues
578615

579-
### Path Alias Not Resolving
580-
581-
If `@/` imports don't work:
582-
1. Verify `tsconfig.json` has `baseUrl` and `paths` configured
583-
2. Verify `vitest.config.ts` has alias configuration
584-
3. Restart your IDE/editor
585-
586616
### Tests Not Found
587617

588618
If tests aren't discovered:

eslint.config.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ export default [
1313
ecmaVersion: 2022,
1414
sourceType: 'module',
1515
project: './tsconfig.json'
16+
},
17+
globals: {
18+
console: 'readonly'
1619
}
1720
},
1821
plugins: {
@@ -34,11 +37,11 @@ export default [
3437
parser: tsparser,
3538
parserOptions: {
3639
ecmaVersion: 2022,
37-
sourceType: 'module',
38-
project: './tsconfig.json'
40+
sourceType: 'module'
3941
},
4042
globals: {
41-
process: 'readonly'
43+
process: 'readonly',
44+
console: 'readonly'
4245
}
4346
},
4447
plugins: {

package.json

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,12 @@
1717
},
1818
"scripts": {
1919
"build": "tsc",
20+
"check": "npm run lint && npm run format && npm run type-check && npm run test:coverage",
2021
"clean": "rm -rf node_modules dist package-lock.json",
21-
"test": "vitest run",
22-
"test:watch": "vitest",
23-
"test:coverage": "vitest run --coverage",
24-
"test:integ": "vitest run tests_integ",
22+
"test": "vitest run --project unit",
23+
"test:watch": "vitest --project unit",
24+
"test:coverage": "vitest run --coverage --project unit",
25+
"test:integ": "vitest run --project integ",
2526
"lint": "eslint src tests_integ",
2627
"lint:fix": "eslint src tests_integ --fix",
2728
"format": "prettier --write src tests_integ",
@@ -39,6 +40,7 @@
3940
"author": "Strands Agents",
4041
"license": "Apache-2.0",
4142
"devDependencies": {
43+
"@aws-sdk/credential-providers": "^3.913.0",
4244
"@types/json-schema": "^7.0.15",
4345
"@types/node": "^24.6.0",
4446
"@typescript-eslint/eslint-plugin": "^8.0.0",
@@ -61,5 +63,8 @@
6163
"bugs": {
6264
"url": "https://github.com/strands-agents/sdk-typescript/issues"
6365
},
64-
"homepage": "https://github.com/strands-agents/sdk-typescript#readme"
66+
"homepage": "https://github.com/strands-agents/sdk-typescript#readme",
67+
"dependencies": {
68+
"@aws-sdk/client-bedrock-runtime": "^3.911.0"
69+
}
6570
}

src/__tests__/.gitkeep

Whitespace-only changes.

src/__tests__/errors.test.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { describe, it, expect } from 'vitest'
2+
import { ContextWindowOverflowError } from '../errors'
3+
4+
describe('ContextWindowOverflowError', () => {
5+
describe('when instantiated with a message', () => {
6+
it('creates an error with the correct message', () => {
7+
const message = 'Context window overflow occurred'
8+
const error = new ContextWindowOverflowError(message)
9+
10+
expect(error.message).toBe(message)
11+
})
12+
13+
it('has the correct error name', () => {
14+
const error = new ContextWindowOverflowError('test')
15+
16+
expect(error.name).toBe('ContextWindowOverflowError')
17+
})
18+
19+
it('is an instance of Error', () => {
20+
const error = new ContextWindowOverflowError('test')
21+
22+
expect(error).toBeInstanceOf(Error)
23+
})
24+
})
25+
})

src/__tests__/index.test.ts

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,35 @@
1-
import { describe, it } from 'vitest'
1+
import { describe, it, expect } from 'vitest'
2+
import * as SDK from '../index'
23

3-
describe('index.ts', () => {
4-
it('can be imported without error', async () => {
5-
await import('../index')
4+
describe('index', () => {
5+
describe('when importing from main entry point', () => {
6+
it('exports error classes', () => {
7+
expect(SDK.ContextWindowOverflowError).toBeDefined()
8+
})
9+
10+
it('exports BedrockModel', () => {
11+
expect(SDK.BedrockModel).toBeDefined()
12+
})
13+
14+
it('can instantiate BedrockModel', () => {
15+
const provider = new SDK.BedrockModel({ region: 'us-west-2' })
16+
expect(provider).toBeInstanceOf(SDK.BedrockModel)
17+
expect(provider.getConfig()).toBeDefined()
18+
})
19+
20+
it('exports all required types', () => {
21+
// This test ensures all type exports compile correctly
22+
// If any exports are missing, TypeScript will error
23+
const _typeCheck: {
24+
// Error types
25+
contextError: typeof SDK.ContextWindowOverflowError
26+
// Model provider
27+
provider: typeof SDK.BedrockModel
28+
} = {
29+
contextError: SDK.ContextWindowOverflowError,
30+
provider: SDK.BedrockModel,
31+
}
32+
expect(_typeCheck).toBeDefined()
33+
})
634
})
735
})

src/errors.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
* Error types for the Strands Agents TypeScript SDK.
3+
*
4+
* These error classes represent specific error conditions that can occur
5+
* during agent execution and model provider interactions.
6+
*/
7+
8+
/**
9+
* Error thrown when input exceeds the model's context window.
10+
*
11+
* This error indicates that the combined length of the input (prompt, messages,
12+
* system prompt, and tool definitions) exceeds the maximum context window size
13+
* supported by the model.
14+
*/
15+
export class ContextWindowOverflowError extends Error {
16+
/**
17+
* Creates a new ContextWindowOverflowError.
18+
*
19+
* @param message - Error message describing the context overflow
20+
*/
21+
constructor(message: string) {
22+
super(message)
23+
this.name = 'ContextWindowOverflowError'
24+
}
25+
}

0 commit comments

Comments
 (0)