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
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,12 @@ await client.revokeCredential(cred.id);

## Configuration

| Option | Type | Default | Description |
| --------- | -------- | --------------------------- | ------------------------ |
| `apiKey` | `string` | --- | API key from [agentscore.sh](https://agentscore.sh) |
| `baseUrl` | `string` | `https://api.agentscore.sh` | API base URL |
| `timeout` | `number` | `10000` | Request timeout in ms |
| Option | Type | Default | Description |
| ----------- | -------- | --------------------------- | ------------------------ |
| `apiKey` | `string` | --- | API key from [agentscore.sh](https://agentscore.sh) |
| `baseUrl` | `string` | `https://api.agentscore.sh` | API base URL |
| `timeout` | `number` | `10000` | Request timeout in ms |
| `userAgent` | `string` | --- | Prepended to the default `User-Agent` as `"{userAgent} (@agent-score/sdk@{version})"`. Use to attribute API calls to your app. |

## Error Handling

Expand Down
34 changes: 17 additions & 17 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@agent-score/sdk",
"version": "1.6.0",
"version": "1.7.0",
"description": "TypeScript client for the AgentScore trust and reputation API",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
Expand Down Expand Up @@ -58,7 +58,7 @@
"eslint-plugin-unused-imports": "^4.4.1",
"tsup": "^8.5.1",
"typescript": "^6.0.3",
"typescript-eslint": "^8.58.2",
"typescript-eslint": "^8.59.0",
"vitest": "^4.1.4"
}
}
5 changes: 4 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export class AgentScore {
private readonly baseUrl: string;
private readonly apiKey: string;
private readonly timeout: number;
private readonly userAgent: string;

constructor(config: AgentScoreConfig) {
if (!config.apiKey) {
Expand All @@ -37,6 +38,8 @@ export class AgentScore {
this.baseUrl = base;
this.apiKey = config.apiKey;
this.timeout = config.timeout ?? DEFAULT_TIMEOUT;
const defaultUa = `@agent-score/sdk@${__VERSION__}`;
this.userAgent = config.userAgent ? `${config.userAgent} (${defaultUa})` : defaultUa;
}

async getReputation(address: string, options?: GetReputationOptions): Promise<ReputationResponse> {
Expand Down Expand Up @@ -115,7 +118,7 @@ export class AgentScore {
const headers: Record<string, string> = {
...(options?.headers as Record<string, string>),
'X-API-Key': this.apiKey,
'User-Agent': `agentscore-sdk/${__VERSION__}`,
'User-Agent': this.userAgent,
};

const controller = new AbortController();
Expand Down
2 changes: 2 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ export interface AgentScoreConfig {
apiKey: string;
baseUrl?: string;
timeout?: number;
/** Prepended to the default User-Agent as `"{userAgent} (@agent-score/sdk@{version})"`. Use to attribute API calls to your app. */
userAgent?: string;
}

export type Grade = 'A' | 'B' | 'C' | 'D' | 'F';
Expand Down
Loading
Loading