@agentfield/sdk 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +40 -0
- package/dist/index.d.ts +823 -0
- package/dist/index.js +2257 -0
- package/dist/index.js.map +1 -0
- package/package.json +59 -0
package/README.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# AgentField TypeScript SDK
|
|
2
|
+
|
|
3
|
+
The TypeScript SDK provides an idiomatic Node.js interface for building and running AgentField agents. It mirrors the Python SDK APIs, including AI, memory, discovery, and MCP tooling.
|
|
4
|
+
|
|
5
|
+
## Installing
|
|
6
|
+
```bash
|
|
7
|
+
npm install @agentfield/sdk
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Rate limiting
|
|
11
|
+
AI calls are wrapped with a stateless rate limiter that matches the Python SDK: exponential backoff, container-scoped jitter, Retry-After support, and a circuit breaker.
|
|
12
|
+
|
|
13
|
+
Configure per-agent via `aiConfig`:
|
|
14
|
+
```ts
|
|
15
|
+
import { Agent } from '@agentfield/sdk';
|
|
16
|
+
|
|
17
|
+
const agent = new Agent({
|
|
18
|
+
nodeId: 'demo',
|
|
19
|
+
aiConfig: {
|
|
20
|
+
model: 'gpt-4o',
|
|
21
|
+
enableRateLimitRetry: true, // default: true
|
|
22
|
+
rateLimitMaxRetries: 20, // max retry attempts
|
|
23
|
+
rateLimitBaseDelay: 1.0, // seconds
|
|
24
|
+
rateLimitMaxDelay: 300.0, // seconds cap
|
|
25
|
+
rateLimitJitterFactor: 0.25, // ±25% jitter
|
|
26
|
+
rateLimitCircuitBreakerThreshold: 10, // consecutive failures before opening
|
|
27
|
+
rateLimitCircuitBreakerTimeout: 300 // seconds before closing breaker
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
To disable retries, set `enableRateLimitRetry: false`.
|
|
33
|
+
|
|
34
|
+
You can also use the limiter directly:
|
|
35
|
+
```ts
|
|
36
|
+
import { StatelessRateLimiter } from '@agentfield/sdk';
|
|
37
|
+
|
|
38
|
+
const limiter = new StatelessRateLimiter({ maxRetries: 3, baseDelay: 0.5 });
|
|
39
|
+
const result = await limiter.executeWithRetry(() => makeAiCall());
|
|
40
|
+
```
|