@axlsdk/axl 0.17.8 → 0.18.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 +7 -5
- package/dist/index.cjs +298 -85
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +133 -9
- package/dist/index.d.ts +133 -9
- package/dist/index.js +297 -85
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1402,6 +1402,100 @@ declare class AxlEventBus implements AsyncIterable<AxlEvent> {
|
|
|
1402
1402
|
get isFinished(): boolean;
|
|
1403
1403
|
}
|
|
1404
1404
|
|
|
1405
|
+
/**
|
|
1406
|
+
* Opt-in client-side rate governor for provider HTTP calls.
|
|
1407
|
+
*
|
|
1408
|
+
* Wraps the single `fetchWithRetry` chokepoint (see `retry.ts`) so a configured
|
|
1409
|
+
* provider can bound how many requests it has *in flight* at once and, optionally,
|
|
1410
|
+
* how closely spaced its request *initiations* are. This is proactive pacing —
|
|
1411
|
+
* complementary to, not a replacement for, the reactive 429/503/529 backoff that
|
|
1412
|
+
* `fetchWithRetry` already does. The motivating case: eval fan-out
|
|
1413
|
+
* (`concurrency × scorerConcurrency`, up to 25 judge calls by default) on a
|
|
1414
|
+
* shared API key can storm a provider's rate limit; a governor smooths that.
|
|
1415
|
+
*
|
|
1416
|
+
* ## Scope & caveats (v1)
|
|
1417
|
+
* - **Caps request concurrency, not token throughput (TPM).** Streaming `chat()`
|
|
1418
|
+
* releases the permit at *headers* (the adapter gets the `Response` from
|
|
1419
|
+
* `fetchWithRetry`, then iterates the body separately), so a slow stream does
|
|
1420
|
+
* NOT hold a permit for its whole lifetime. Non-streaming `chat()` holds the
|
|
1421
|
+
* permit through `res.json()`. Neither bounds tokens/min.
|
|
1422
|
+
* - **Per provider instance.** Providers are singletons per (runtime, provider
|
|
1423
|
+
* type), so one governor governs all calls through that adapter — but NOT
|
|
1424
|
+
* embedder calls (the embedder is constructed outside the registry) and NOT
|
|
1425
|
+
* other processes/runtimes sharing the same API key.
|
|
1426
|
+
* - **`minIntervalMs` is global spacing, not a burst bucket.** A single
|
|
1427
|
+
* last-grant timestamp gates every grant: a permit may be free yet a grant
|
|
1428
|
+
* still waits out the interval. There is no accumulated burst allowance.
|
|
1429
|
+
* - **Nesting is safe.** A permit is held only across one `fetchWithRetry` call,
|
|
1430
|
+
* never across a nested `ctx.ask`, so an agent-as-tool chain on the same
|
|
1431
|
+
* provider under `maxConcurrent: 1` still completes — permits don't stack.
|
|
1432
|
+
*
|
|
1433
|
+
* `observe(res)` is a no-op seam in v1 for a future adaptive (header-driven)
|
|
1434
|
+
* pacing follow-up.
|
|
1435
|
+
*/
|
|
1436
|
+
/** Configuration for a provider's {@link RateLimiter}. All fields optional. */
|
|
1437
|
+
type RateLimitConfig = {
|
|
1438
|
+
/**
|
|
1439
|
+
* Maximum requests in flight at once for this provider. Must be a finite
|
|
1440
|
+
* integer ≥ 1; invalid values disable the concurrency cap (with a warning).
|
|
1441
|
+
* `1` serializes all requests (allowed, with a warning — it's a throughput
|
|
1442
|
+
* floor, not a deadlock: nested same-provider calls still complete because a
|
|
1443
|
+
* permit is never held across a nested ask).
|
|
1444
|
+
*/
|
|
1445
|
+
maxConcurrent?: number;
|
|
1446
|
+
/**
|
|
1447
|
+
* Minimum milliseconds between successive request *grants* (global spacing,
|
|
1448
|
+
* not a per-permit rate). A permit can be free yet a grant still waits out
|
|
1449
|
+
* this interval. No burst bucket.
|
|
1450
|
+
*/
|
|
1451
|
+
minIntervalMs?: number;
|
|
1452
|
+
/**
|
|
1453
|
+
* If set, `acquire()` rejects (fail loud) when a caller has queued longer than
|
|
1454
|
+
* this many ms, instead of waiting indefinitely — surfaces a misconfigured
|
|
1455
|
+
* cap rather than silently hanging the run.
|
|
1456
|
+
*/
|
|
1457
|
+
acquireTimeoutMs?: number;
|
|
1458
|
+
};
|
|
1459
|
+
/**
|
|
1460
|
+
* Counting semaphore + FIFO waiter queue. Dependency-free. Not shared across
|
|
1461
|
+
* processes — purely an in-process pacing aid.
|
|
1462
|
+
*/
|
|
1463
|
+
declare class RateLimiter {
|
|
1464
|
+
private readonly maxConcurrent;
|
|
1465
|
+
private readonly minIntervalMs;
|
|
1466
|
+
private readonly acquireTimeoutMs?;
|
|
1467
|
+
private active;
|
|
1468
|
+
private lastGrantAt;
|
|
1469
|
+
private readonly queue;
|
|
1470
|
+
private spacingTimer?;
|
|
1471
|
+
private warnedQueued;
|
|
1472
|
+
constructor(config?: RateLimitConfig);
|
|
1473
|
+
/**
|
|
1474
|
+
* Acquire a permit. Resolves when one is granted (respecting `maxConcurrent`
|
|
1475
|
+
* and `minIntervalMs`). The caller MUST pair every resolved `acquire()` with
|
|
1476
|
+
* exactly one {@link release}.
|
|
1477
|
+
*
|
|
1478
|
+
* Abort handling:
|
|
1479
|
+
* - Pre-aborted signal ⇒ rejects immediately, no permit taken.
|
|
1480
|
+
* - Aborted while queued ⇒ spliced out of the queue, no counter change, rejects.
|
|
1481
|
+
* - (Once granted, the abort listener is removed — the holder owns the permit
|
|
1482
|
+
* and releases it via `fetchWithRetry`'s `finally`.)
|
|
1483
|
+
*
|
|
1484
|
+
* With `acquireTimeoutMs`, a waiter that sits in the queue too long rejects.
|
|
1485
|
+
*/
|
|
1486
|
+
acquire(signal?: AbortSignal): Promise<void>;
|
|
1487
|
+
/** Release a previously acquired permit and wake the next waiter. */
|
|
1488
|
+
release(): void;
|
|
1489
|
+
/** v1 no-op seam for a future adaptive (rate-limit-header-driven) pacing follow-up. */
|
|
1490
|
+
observe(_res: Response): void;
|
|
1491
|
+
/** Drain the queue: grant head waiters while a permit is free and spacing allows. */
|
|
1492
|
+
private pump;
|
|
1493
|
+
private grant;
|
|
1494
|
+
/** Reject a still-queued waiter (abort or timeout) and remove it cleanly. */
|
|
1495
|
+
private settleWaiter;
|
|
1496
|
+
private clearWaiterTimers;
|
|
1497
|
+
}
|
|
1498
|
+
|
|
1405
1499
|
/** A pending human decision awaiting resolution. */
|
|
1406
1500
|
type PendingDecision = {
|
|
1407
1501
|
executionId: string;
|
|
@@ -1645,6 +1739,15 @@ type MemoryConfig = {
|
|
|
1645
1739
|
type ProviderConfig = {
|
|
1646
1740
|
apiKey?: string;
|
|
1647
1741
|
baseUrl?: string;
|
|
1742
|
+
/**
|
|
1743
|
+
* Opt-in client-side rate governor for this provider's HTTP calls (see
|
|
1744
|
+
* {@link RateLimitConfig}). Bounds in-flight request concurrency (and,
|
|
1745
|
+
* optionally, request spacing) through the shared `fetchWithRetry` chokepoint.
|
|
1746
|
+
* Omitted ⇒ no governor (behavior unchanged). Caveat: governs **chat** calls
|
|
1747
|
+
* through this provider instance only — NOT memory-embedder calls (constructed
|
|
1748
|
+
* outside the registry) and NOT other processes sharing the same API key.
|
|
1749
|
+
*/
|
|
1750
|
+
rateLimit?: RateLimitConfig;
|
|
1648
1751
|
};
|
|
1649
1752
|
/** MCP server configuration */
|
|
1650
1753
|
type McpServerConfig$1 = {
|
|
@@ -2786,6 +2889,26 @@ type EvalProgressEventShape = {
|
|
|
2786
2889
|
totalItems: number;
|
|
2787
2890
|
failures: number;
|
|
2788
2891
|
};
|
|
2892
|
+
/**
|
|
2893
|
+
* Structural shape of `@axlsdk/eval`'s `EvalConfig` as seen by the runtime.
|
|
2894
|
+
* `axl` is a peer of `eval` (eval depends on axl, not the reverse), so the core
|
|
2895
|
+
* can't import the real `EvalConfig` type — it forwards `config` to `runEval`
|
|
2896
|
+
* at runtime regardless. This single declaration is the ONE place to keep in
|
|
2897
|
+
* sync with `EvalConfig`'s forwarded fields, so `eval()` and `runRegisteredEval()`
|
|
2898
|
+
* don't drift apart (they previously carried two hand-copied inline shapes).
|
|
2899
|
+
* `dataset`/`scorers` stay `unknown[]`/`unknown` because their real types live in
|
|
2900
|
+
* `@axlsdk/eval`; only the primitive knobs are structurally typed here.
|
|
2901
|
+
*/
|
|
2902
|
+
type RuntimeEvalConfigShape = {
|
|
2903
|
+
workflow: string;
|
|
2904
|
+
dataset: unknown;
|
|
2905
|
+
scorers: unknown[];
|
|
2906
|
+
concurrency?: number;
|
|
2907
|
+
scorerConcurrency?: number;
|
|
2908
|
+
budget?: string;
|
|
2909
|
+
failOnScorerErrorRate?: number;
|
|
2910
|
+
metadata?: Record<string, unknown>;
|
|
2911
|
+
};
|
|
2789
2912
|
type CreateContextOptions = {
|
|
2790
2913
|
metadata?: Record<string, unknown>;
|
|
2791
2914
|
/** Cost budget for the context (e.g., '$0.50'). Enforced via finish_and_stop policy. */
|
|
@@ -3160,14 +3283,7 @@ declare class AxlRuntime extends EventEmitter {
|
|
|
3160
3283
|
*
|
|
3161
3284
|
* @see Spec Section 13.5
|
|
3162
3285
|
*/
|
|
3163
|
-
eval(config: {
|
|
3164
|
-
workflow: string;
|
|
3165
|
-
dataset: unknown;
|
|
3166
|
-
scorers: unknown[];
|
|
3167
|
-
concurrency?: number;
|
|
3168
|
-
budget?: string;
|
|
3169
|
-
metadata?: Record<string, unknown>;
|
|
3170
|
-
}, options?: {
|
|
3286
|
+
eval(config: RuntimeEvalConfigShape, options?: {
|
|
3171
3287
|
onProgress?: (event: EvalProgressEventShape) => void;
|
|
3172
3288
|
signal?: AbortSignal;
|
|
3173
3289
|
captureTraces?: boolean;
|
|
@@ -3749,9 +3865,11 @@ declare class OpenAIProvider implements Provider {
|
|
|
3749
3865
|
readonly name = "openai";
|
|
3750
3866
|
private baseUrl;
|
|
3751
3867
|
private apiKey;
|
|
3868
|
+
private governor?;
|
|
3752
3869
|
constructor(options?: {
|
|
3753
3870
|
apiKey?: string;
|
|
3754
3871
|
baseUrl?: string;
|
|
3872
|
+
rateLimit?: RateLimitConfig;
|
|
3755
3873
|
});
|
|
3756
3874
|
chat(messages: ChatMessage[], options: ChatOptions): Promise<ProviderResponse>;
|
|
3757
3875
|
stream(messages: ChatMessage[], options: ChatOptions): AsyncGenerator<StreamChunk>;
|
|
@@ -3773,9 +3891,11 @@ declare class OpenAIResponsesProvider implements Provider {
|
|
|
3773
3891
|
readonly name = "openai-responses";
|
|
3774
3892
|
private baseUrl;
|
|
3775
3893
|
private apiKey;
|
|
3894
|
+
private governor?;
|
|
3776
3895
|
constructor(options?: {
|
|
3777
3896
|
apiKey?: string;
|
|
3778
3897
|
baseUrl?: string;
|
|
3898
|
+
rateLimit?: RateLimitConfig;
|
|
3779
3899
|
});
|
|
3780
3900
|
chat(messages: ChatMessage[], options: ChatOptions): Promise<ProviderResponse>;
|
|
3781
3901
|
stream(messages: ChatMessage[], options: ChatOptions): AsyncGenerator<StreamChunk>;
|
|
@@ -3814,9 +3934,11 @@ declare class AnthropicProvider implements Provider {
|
|
|
3814
3934
|
private baseUrl;
|
|
3815
3935
|
private apiKey;
|
|
3816
3936
|
private currentModel?;
|
|
3937
|
+
private governor?;
|
|
3817
3938
|
constructor(options?: {
|
|
3818
3939
|
apiKey?: string;
|
|
3819
3940
|
baseUrl?: string;
|
|
3941
|
+
rateLimit?: RateLimitConfig;
|
|
3820
3942
|
});
|
|
3821
3943
|
chat(messages: ChatMessage[], options: ChatOptions): Promise<ProviderResponse>;
|
|
3822
3944
|
stream(messages: ChatMessage[], options: ChatOptions): AsyncGenerator<StreamChunk>;
|
|
@@ -3876,9 +3998,11 @@ declare class GeminiProvider implements Provider {
|
|
|
3876
3998
|
private baseUrl;
|
|
3877
3999
|
private apiKey;
|
|
3878
4000
|
private callCounter;
|
|
4001
|
+
private governor?;
|
|
3879
4002
|
constructor(options?: {
|
|
3880
4003
|
apiKey?: string;
|
|
3881
4004
|
baseUrl?: string;
|
|
4005
|
+
rateLimit?: RateLimitConfig;
|
|
3882
4006
|
});
|
|
3883
4007
|
chat(messages: ChatMessage[], options: ChatOptions): Promise<ProviderResponse>;
|
|
3884
4008
|
stream(messages: ChatMessage[], options: ChatOptions): AsyncGenerator<StreamChunk>;
|
|
@@ -4361,4 +4485,4 @@ declare class NoopSpanManager implements SpanManager {
|
|
|
4361
4485
|
*/
|
|
4362
4486
|
declare function createSpanManager(config?: TelemetryConfig): Promise<SpanManager>;
|
|
4363
4487
|
|
|
4364
|
-
export { AXL_EVENT_TYPES, type Agent, type AgentCallEndData, type AgentCallInfo, type AgentCallParams, type AgentCallStartData, type AgentConfig, AnthropicProvider, type AnyWorkflow, type AskOptions, type AskScoped, type AwaitHumanData, type AwaitHumanOptions, type AwaitHumanResolvedData, type AxlConfig, AxlError, type AxlEvent, type AxlEventBase, AxlEventBus, type AxlEventOf, type AxlEventType, AxlRuntime, AxlStream, BudgetExceededError, type BudgetOptions, type BudgetResult, CONFIG_CANDIDATES, COST_BEARING_LEAF_TYPES, type CallbackMeta, type ChatMessage, type ChatOptions, type CheckpointEventData, type CoalescedPartialObject, type CreateContextOptions, type DelegateData, type DelegateOptions, type Effort, type EmbedResult, type EmbedUsage, type Embedder, type EvalExecuteWorkflow, type EvalHistoryEntry, type EventStreamOptions, EventStreamOverflowError, type ExecuteOptions, type ExecutionInfo, type ExecutionState, GeminiProvider, type GuardrailBlockHandler, type GuardrailData, GuardrailError, type GuardrailResult, type GuardrailsConfig, type HandoffDescriptor, type HandoffRecord, type HandoffReturnData, type HandoffStartData, type HumanDecision, InMemoryVectorStore, type InputGuardrail, type MapOptions, MaxTurnsError, McpManager, type McpServer, type McpServerConfig, type McpToolDefinition, type McpToolResult, type MemoryConfig, type MemoryEventData, MemoryManager, MemoryStore, NoConsensus, NoopSpanManager, OpenAIEmbedder, OpenAIProvider, OpenAIResponsesProvider, type OutputGuardrail, type OutputValidator, type PendingDecision, type Provider, type ProviderAdapter, ProviderRegistry, type ProviderResponse, QuorumNotMet, REDACTED, REDACTION_RULES, type RaceOptions, type RecallOptions, type RecallResult, RedisStore, type RememberOptions, type RememberResult, type ResolvedThinkingOptions, type Result, type RetryPolicy, SQLiteStore, type SchemaCheckData, Session, type SessionOptions, type SpanHandle, type SpanManager, type SpawnOptions, SqliteVectorStore, type StateStore, type StreamChunk, type StringDeltaData, type StringStreamEvent, type StringStreamFilter, type TelemetryConfig, TimeoutError, type Tool, type ToolApprovalData, type ToolCallData, type ToolCallMessage, type ToolCallStartData, type ToolChoice, type ToolConfig, ToolDenied, type ToolDeniedData, type ToolHooks, type ValidateData, type ValidateResult, ValidationError, type VectorEntry, type VectorResult, type VectorStore, type VerifyData, VerifyError, type VerifyOptions, type VerifyRetry, type VoteOptions, type Workflow, type WorkflowConfig, WorkflowContext, type WorkflowContextInit, type WorkflowEndData, type WorkflowStartData, agent, createSpanManager, defineConfig, eventCostContribution, expandGlob, extractJson, findConfig, importModule, isCostBearingLeaf, isRootLevel, needsTsxLoader, parsePartialJson, pickDefault, pickExport, redactEvent, registerConditions, resolveRuntime, resolveThinkingOptions, stringStreamFromEvents, tool, workflow, zodToJsonSchema };
|
|
4488
|
+
export { AXL_EVENT_TYPES, type Agent, type AgentCallEndData, type AgentCallInfo, type AgentCallParams, type AgentCallStartData, type AgentConfig, AnthropicProvider, type AnyWorkflow, type AskOptions, type AskScoped, type AwaitHumanData, type AwaitHumanOptions, type AwaitHumanResolvedData, type AxlConfig, AxlError, type AxlEvent, type AxlEventBase, AxlEventBus, type AxlEventOf, type AxlEventType, AxlRuntime, AxlStream, BudgetExceededError, type BudgetOptions, type BudgetResult, CONFIG_CANDIDATES, COST_BEARING_LEAF_TYPES, type CallbackMeta, type ChatMessage, type ChatOptions, type CheckpointEventData, type CoalescedPartialObject, type CreateContextOptions, type DelegateData, type DelegateOptions, type Effort, type EmbedResult, type EmbedUsage, type Embedder, type EvalExecuteWorkflow, type EvalHistoryEntry, type EventStreamOptions, EventStreamOverflowError, type ExecuteOptions, type ExecutionInfo, type ExecutionState, GeminiProvider, type GuardrailBlockHandler, type GuardrailData, GuardrailError, type GuardrailResult, type GuardrailsConfig, type HandoffDescriptor, type HandoffRecord, type HandoffReturnData, type HandoffStartData, type HumanDecision, InMemoryVectorStore, type InputGuardrail, type MapOptions, MaxTurnsError, McpManager, type McpServer, type McpServerConfig, type McpToolDefinition, type McpToolResult, type MemoryConfig, type MemoryEventData, MemoryManager, MemoryStore, NoConsensus, NoopSpanManager, OpenAIEmbedder, OpenAIProvider, OpenAIResponsesProvider, type OutputGuardrail, type OutputValidator, type PendingDecision, type Provider, type ProviderAdapter, ProviderRegistry, type ProviderResponse, QuorumNotMet, REDACTED, REDACTION_RULES, type RaceOptions, type RateLimitConfig, RateLimiter, type RecallOptions, type RecallResult, RedisStore, type RememberOptions, type RememberResult, type ResolvedThinkingOptions, type Result, type RetryPolicy, SQLiteStore, type SchemaCheckData, Session, type SessionOptions, type SpanHandle, type SpanManager, type SpawnOptions, SqliteVectorStore, type StateStore, type StreamChunk, type StringDeltaData, type StringStreamEvent, type StringStreamFilter, type TelemetryConfig, TimeoutError, type Tool, type ToolApprovalData, type ToolCallData, type ToolCallMessage, type ToolCallStartData, type ToolChoice, type ToolConfig, ToolDenied, type ToolDeniedData, type ToolHooks, type ValidateData, type ValidateResult, ValidationError, type VectorEntry, type VectorResult, type VectorStore, type VerifyData, VerifyError, type VerifyOptions, type VerifyRetry, type VoteOptions, type Workflow, type WorkflowConfig, WorkflowContext, type WorkflowContextInit, type WorkflowEndData, type WorkflowStartData, agent, createSpanManager, defineConfig, eventCostContribution, expandGlob, extractJson, findConfig, importModule, isCostBearingLeaf, isRootLevel, needsTsxLoader, parsePartialJson, pickDefault, pickExport, redactEvent, registerConditions, resolveRuntime, resolveThinkingOptions, stringStreamFromEvents, tool, workflow, zodToJsonSchema };
|
package/dist/index.d.ts
CHANGED
|
@@ -1402,6 +1402,100 @@ declare class AxlEventBus implements AsyncIterable<AxlEvent> {
|
|
|
1402
1402
|
get isFinished(): boolean;
|
|
1403
1403
|
}
|
|
1404
1404
|
|
|
1405
|
+
/**
|
|
1406
|
+
* Opt-in client-side rate governor for provider HTTP calls.
|
|
1407
|
+
*
|
|
1408
|
+
* Wraps the single `fetchWithRetry` chokepoint (see `retry.ts`) so a configured
|
|
1409
|
+
* provider can bound how many requests it has *in flight* at once and, optionally,
|
|
1410
|
+
* how closely spaced its request *initiations* are. This is proactive pacing —
|
|
1411
|
+
* complementary to, not a replacement for, the reactive 429/503/529 backoff that
|
|
1412
|
+
* `fetchWithRetry` already does. The motivating case: eval fan-out
|
|
1413
|
+
* (`concurrency × scorerConcurrency`, up to 25 judge calls by default) on a
|
|
1414
|
+
* shared API key can storm a provider's rate limit; a governor smooths that.
|
|
1415
|
+
*
|
|
1416
|
+
* ## Scope & caveats (v1)
|
|
1417
|
+
* - **Caps request concurrency, not token throughput (TPM).** Streaming `chat()`
|
|
1418
|
+
* releases the permit at *headers* (the adapter gets the `Response` from
|
|
1419
|
+
* `fetchWithRetry`, then iterates the body separately), so a slow stream does
|
|
1420
|
+
* NOT hold a permit for its whole lifetime. Non-streaming `chat()` holds the
|
|
1421
|
+
* permit through `res.json()`. Neither bounds tokens/min.
|
|
1422
|
+
* - **Per provider instance.** Providers are singletons per (runtime, provider
|
|
1423
|
+
* type), so one governor governs all calls through that adapter — but NOT
|
|
1424
|
+
* embedder calls (the embedder is constructed outside the registry) and NOT
|
|
1425
|
+
* other processes/runtimes sharing the same API key.
|
|
1426
|
+
* - **`minIntervalMs` is global spacing, not a burst bucket.** A single
|
|
1427
|
+
* last-grant timestamp gates every grant: a permit may be free yet a grant
|
|
1428
|
+
* still waits out the interval. There is no accumulated burst allowance.
|
|
1429
|
+
* - **Nesting is safe.** A permit is held only across one `fetchWithRetry` call,
|
|
1430
|
+
* never across a nested `ctx.ask`, so an agent-as-tool chain on the same
|
|
1431
|
+
* provider under `maxConcurrent: 1` still completes — permits don't stack.
|
|
1432
|
+
*
|
|
1433
|
+
* `observe(res)` is a no-op seam in v1 for a future adaptive (header-driven)
|
|
1434
|
+
* pacing follow-up.
|
|
1435
|
+
*/
|
|
1436
|
+
/** Configuration for a provider's {@link RateLimiter}. All fields optional. */
|
|
1437
|
+
type RateLimitConfig = {
|
|
1438
|
+
/**
|
|
1439
|
+
* Maximum requests in flight at once for this provider. Must be a finite
|
|
1440
|
+
* integer ≥ 1; invalid values disable the concurrency cap (with a warning).
|
|
1441
|
+
* `1` serializes all requests (allowed, with a warning — it's a throughput
|
|
1442
|
+
* floor, not a deadlock: nested same-provider calls still complete because a
|
|
1443
|
+
* permit is never held across a nested ask).
|
|
1444
|
+
*/
|
|
1445
|
+
maxConcurrent?: number;
|
|
1446
|
+
/**
|
|
1447
|
+
* Minimum milliseconds between successive request *grants* (global spacing,
|
|
1448
|
+
* not a per-permit rate). A permit can be free yet a grant still waits out
|
|
1449
|
+
* this interval. No burst bucket.
|
|
1450
|
+
*/
|
|
1451
|
+
minIntervalMs?: number;
|
|
1452
|
+
/**
|
|
1453
|
+
* If set, `acquire()` rejects (fail loud) when a caller has queued longer than
|
|
1454
|
+
* this many ms, instead of waiting indefinitely — surfaces a misconfigured
|
|
1455
|
+
* cap rather than silently hanging the run.
|
|
1456
|
+
*/
|
|
1457
|
+
acquireTimeoutMs?: number;
|
|
1458
|
+
};
|
|
1459
|
+
/**
|
|
1460
|
+
* Counting semaphore + FIFO waiter queue. Dependency-free. Not shared across
|
|
1461
|
+
* processes — purely an in-process pacing aid.
|
|
1462
|
+
*/
|
|
1463
|
+
declare class RateLimiter {
|
|
1464
|
+
private readonly maxConcurrent;
|
|
1465
|
+
private readonly minIntervalMs;
|
|
1466
|
+
private readonly acquireTimeoutMs?;
|
|
1467
|
+
private active;
|
|
1468
|
+
private lastGrantAt;
|
|
1469
|
+
private readonly queue;
|
|
1470
|
+
private spacingTimer?;
|
|
1471
|
+
private warnedQueued;
|
|
1472
|
+
constructor(config?: RateLimitConfig);
|
|
1473
|
+
/**
|
|
1474
|
+
* Acquire a permit. Resolves when one is granted (respecting `maxConcurrent`
|
|
1475
|
+
* and `minIntervalMs`). The caller MUST pair every resolved `acquire()` with
|
|
1476
|
+
* exactly one {@link release}.
|
|
1477
|
+
*
|
|
1478
|
+
* Abort handling:
|
|
1479
|
+
* - Pre-aborted signal ⇒ rejects immediately, no permit taken.
|
|
1480
|
+
* - Aborted while queued ⇒ spliced out of the queue, no counter change, rejects.
|
|
1481
|
+
* - (Once granted, the abort listener is removed — the holder owns the permit
|
|
1482
|
+
* and releases it via `fetchWithRetry`'s `finally`.)
|
|
1483
|
+
*
|
|
1484
|
+
* With `acquireTimeoutMs`, a waiter that sits in the queue too long rejects.
|
|
1485
|
+
*/
|
|
1486
|
+
acquire(signal?: AbortSignal): Promise<void>;
|
|
1487
|
+
/** Release a previously acquired permit and wake the next waiter. */
|
|
1488
|
+
release(): void;
|
|
1489
|
+
/** v1 no-op seam for a future adaptive (rate-limit-header-driven) pacing follow-up. */
|
|
1490
|
+
observe(_res: Response): void;
|
|
1491
|
+
/** Drain the queue: grant head waiters while a permit is free and spacing allows. */
|
|
1492
|
+
private pump;
|
|
1493
|
+
private grant;
|
|
1494
|
+
/** Reject a still-queued waiter (abort or timeout) and remove it cleanly. */
|
|
1495
|
+
private settleWaiter;
|
|
1496
|
+
private clearWaiterTimers;
|
|
1497
|
+
}
|
|
1498
|
+
|
|
1405
1499
|
/** A pending human decision awaiting resolution. */
|
|
1406
1500
|
type PendingDecision = {
|
|
1407
1501
|
executionId: string;
|
|
@@ -1645,6 +1739,15 @@ type MemoryConfig = {
|
|
|
1645
1739
|
type ProviderConfig = {
|
|
1646
1740
|
apiKey?: string;
|
|
1647
1741
|
baseUrl?: string;
|
|
1742
|
+
/**
|
|
1743
|
+
* Opt-in client-side rate governor for this provider's HTTP calls (see
|
|
1744
|
+
* {@link RateLimitConfig}). Bounds in-flight request concurrency (and,
|
|
1745
|
+
* optionally, request spacing) through the shared `fetchWithRetry` chokepoint.
|
|
1746
|
+
* Omitted ⇒ no governor (behavior unchanged). Caveat: governs **chat** calls
|
|
1747
|
+
* through this provider instance only — NOT memory-embedder calls (constructed
|
|
1748
|
+
* outside the registry) and NOT other processes sharing the same API key.
|
|
1749
|
+
*/
|
|
1750
|
+
rateLimit?: RateLimitConfig;
|
|
1648
1751
|
};
|
|
1649
1752
|
/** MCP server configuration */
|
|
1650
1753
|
type McpServerConfig$1 = {
|
|
@@ -2786,6 +2889,26 @@ type EvalProgressEventShape = {
|
|
|
2786
2889
|
totalItems: number;
|
|
2787
2890
|
failures: number;
|
|
2788
2891
|
};
|
|
2892
|
+
/**
|
|
2893
|
+
* Structural shape of `@axlsdk/eval`'s `EvalConfig` as seen by the runtime.
|
|
2894
|
+
* `axl` is a peer of `eval` (eval depends on axl, not the reverse), so the core
|
|
2895
|
+
* can't import the real `EvalConfig` type — it forwards `config` to `runEval`
|
|
2896
|
+
* at runtime regardless. This single declaration is the ONE place to keep in
|
|
2897
|
+
* sync with `EvalConfig`'s forwarded fields, so `eval()` and `runRegisteredEval()`
|
|
2898
|
+
* don't drift apart (they previously carried two hand-copied inline shapes).
|
|
2899
|
+
* `dataset`/`scorers` stay `unknown[]`/`unknown` because their real types live in
|
|
2900
|
+
* `@axlsdk/eval`; only the primitive knobs are structurally typed here.
|
|
2901
|
+
*/
|
|
2902
|
+
type RuntimeEvalConfigShape = {
|
|
2903
|
+
workflow: string;
|
|
2904
|
+
dataset: unknown;
|
|
2905
|
+
scorers: unknown[];
|
|
2906
|
+
concurrency?: number;
|
|
2907
|
+
scorerConcurrency?: number;
|
|
2908
|
+
budget?: string;
|
|
2909
|
+
failOnScorerErrorRate?: number;
|
|
2910
|
+
metadata?: Record<string, unknown>;
|
|
2911
|
+
};
|
|
2789
2912
|
type CreateContextOptions = {
|
|
2790
2913
|
metadata?: Record<string, unknown>;
|
|
2791
2914
|
/** Cost budget for the context (e.g., '$0.50'). Enforced via finish_and_stop policy. */
|
|
@@ -3160,14 +3283,7 @@ declare class AxlRuntime extends EventEmitter {
|
|
|
3160
3283
|
*
|
|
3161
3284
|
* @see Spec Section 13.5
|
|
3162
3285
|
*/
|
|
3163
|
-
eval(config: {
|
|
3164
|
-
workflow: string;
|
|
3165
|
-
dataset: unknown;
|
|
3166
|
-
scorers: unknown[];
|
|
3167
|
-
concurrency?: number;
|
|
3168
|
-
budget?: string;
|
|
3169
|
-
metadata?: Record<string, unknown>;
|
|
3170
|
-
}, options?: {
|
|
3286
|
+
eval(config: RuntimeEvalConfigShape, options?: {
|
|
3171
3287
|
onProgress?: (event: EvalProgressEventShape) => void;
|
|
3172
3288
|
signal?: AbortSignal;
|
|
3173
3289
|
captureTraces?: boolean;
|
|
@@ -3749,9 +3865,11 @@ declare class OpenAIProvider implements Provider {
|
|
|
3749
3865
|
readonly name = "openai";
|
|
3750
3866
|
private baseUrl;
|
|
3751
3867
|
private apiKey;
|
|
3868
|
+
private governor?;
|
|
3752
3869
|
constructor(options?: {
|
|
3753
3870
|
apiKey?: string;
|
|
3754
3871
|
baseUrl?: string;
|
|
3872
|
+
rateLimit?: RateLimitConfig;
|
|
3755
3873
|
});
|
|
3756
3874
|
chat(messages: ChatMessage[], options: ChatOptions): Promise<ProviderResponse>;
|
|
3757
3875
|
stream(messages: ChatMessage[], options: ChatOptions): AsyncGenerator<StreamChunk>;
|
|
@@ -3773,9 +3891,11 @@ declare class OpenAIResponsesProvider implements Provider {
|
|
|
3773
3891
|
readonly name = "openai-responses";
|
|
3774
3892
|
private baseUrl;
|
|
3775
3893
|
private apiKey;
|
|
3894
|
+
private governor?;
|
|
3776
3895
|
constructor(options?: {
|
|
3777
3896
|
apiKey?: string;
|
|
3778
3897
|
baseUrl?: string;
|
|
3898
|
+
rateLimit?: RateLimitConfig;
|
|
3779
3899
|
});
|
|
3780
3900
|
chat(messages: ChatMessage[], options: ChatOptions): Promise<ProviderResponse>;
|
|
3781
3901
|
stream(messages: ChatMessage[], options: ChatOptions): AsyncGenerator<StreamChunk>;
|
|
@@ -3814,9 +3934,11 @@ declare class AnthropicProvider implements Provider {
|
|
|
3814
3934
|
private baseUrl;
|
|
3815
3935
|
private apiKey;
|
|
3816
3936
|
private currentModel?;
|
|
3937
|
+
private governor?;
|
|
3817
3938
|
constructor(options?: {
|
|
3818
3939
|
apiKey?: string;
|
|
3819
3940
|
baseUrl?: string;
|
|
3941
|
+
rateLimit?: RateLimitConfig;
|
|
3820
3942
|
});
|
|
3821
3943
|
chat(messages: ChatMessage[], options: ChatOptions): Promise<ProviderResponse>;
|
|
3822
3944
|
stream(messages: ChatMessage[], options: ChatOptions): AsyncGenerator<StreamChunk>;
|
|
@@ -3876,9 +3998,11 @@ declare class GeminiProvider implements Provider {
|
|
|
3876
3998
|
private baseUrl;
|
|
3877
3999
|
private apiKey;
|
|
3878
4000
|
private callCounter;
|
|
4001
|
+
private governor?;
|
|
3879
4002
|
constructor(options?: {
|
|
3880
4003
|
apiKey?: string;
|
|
3881
4004
|
baseUrl?: string;
|
|
4005
|
+
rateLimit?: RateLimitConfig;
|
|
3882
4006
|
});
|
|
3883
4007
|
chat(messages: ChatMessage[], options: ChatOptions): Promise<ProviderResponse>;
|
|
3884
4008
|
stream(messages: ChatMessage[], options: ChatOptions): AsyncGenerator<StreamChunk>;
|
|
@@ -4361,4 +4485,4 @@ declare class NoopSpanManager implements SpanManager {
|
|
|
4361
4485
|
*/
|
|
4362
4486
|
declare function createSpanManager(config?: TelemetryConfig): Promise<SpanManager>;
|
|
4363
4487
|
|
|
4364
|
-
export { AXL_EVENT_TYPES, type Agent, type AgentCallEndData, type AgentCallInfo, type AgentCallParams, type AgentCallStartData, type AgentConfig, AnthropicProvider, type AnyWorkflow, type AskOptions, type AskScoped, type AwaitHumanData, type AwaitHumanOptions, type AwaitHumanResolvedData, type AxlConfig, AxlError, type AxlEvent, type AxlEventBase, AxlEventBus, type AxlEventOf, type AxlEventType, AxlRuntime, AxlStream, BudgetExceededError, type BudgetOptions, type BudgetResult, CONFIG_CANDIDATES, COST_BEARING_LEAF_TYPES, type CallbackMeta, type ChatMessage, type ChatOptions, type CheckpointEventData, type CoalescedPartialObject, type CreateContextOptions, type DelegateData, type DelegateOptions, type Effort, type EmbedResult, type EmbedUsage, type Embedder, type EvalExecuteWorkflow, type EvalHistoryEntry, type EventStreamOptions, EventStreamOverflowError, type ExecuteOptions, type ExecutionInfo, type ExecutionState, GeminiProvider, type GuardrailBlockHandler, type GuardrailData, GuardrailError, type GuardrailResult, type GuardrailsConfig, type HandoffDescriptor, type HandoffRecord, type HandoffReturnData, type HandoffStartData, type HumanDecision, InMemoryVectorStore, type InputGuardrail, type MapOptions, MaxTurnsError, McpManager, type McpServer, type McpServerConfig, type McpToolDefinition, type McpToolResult, type MemoryConfig, type MemoryEventData, MemoryManager, MemoryStore, NoConsensus, NoopSpanManager, OpenAIEmbedder, OpenAIProvider, OpenAIResponsesProvider, type OutputGuardrail, type OutputValidator, type PendingDecision, type Provider, type ProviderAdapter, ProviderRegistry, type ProviderResponse, QuorumNotMet, REDACTED, REDACTION_RULES, type RaceOptions, type RecallOptions, type RecallResult, RedisStore, type RememberOptions, type RememberResult, type ResolvedThinkingOptions, type Result, type RetryPolicy, SQLiteStore, type SchemaCheckData, Session, type SessionOptions, type SpanHandle, type SpanManager, type SpawnOptions, SqliteVectorStore, type StateStore, type StreamChunk, type StringDeltaData, type StringStreamEvent, type StringStreamFilter, type TelemetryConfig, TimeoutError, type Tool, type ToolApprovalData, type ToolCallData, type ToolCallMessage, type ToolCallStartData, type ToolChoice, type ToolConfig, ToolDenied, type ToolDeniedData, type ToolHooks, type ValidateData, type ValidateResult, ValidationError, type VectorEntry, type VectorResult, type VectorStore, type VerifyData, VerifyError, type VerifyOptions, type VerifyRetry, type VoteOptions, type Workflow, type WorkflowConfig, WorkflowContext, type WorkflowContextInit, type WorkflowEndData, type WorkflowStartData, agent, createSpanManager, defineConfig, eventCostContribution, expandGlob, extractJson, findConfig, importModule, isCostBearingLeaf, isRootLevel, needsTsxLoader, parsePartialJson, pickDefault, pickExport, redactEvent, registerConditions, resolveRuntime, resolveThinkingOptions, stringStreamFromEvents, tool, workflow, zodToJsonSchema };
|
|
4488
|
+
export { AXL_EVENT_TYPES, type Agent, type AgentCallEndData, type AgentCallInfo, type AgentCallParams, type AgentCallStartData, type AgentConfig, AnthropicProvider, type AnyWorkflow, type AskOptions, type AskScoped, type AwaitHumanData, type AwaitHumanOptions, type AwaitHumanResolvedData, type AxlConfig, AxlError, type AxlEvent, type AxlEventBase, AxlEventBus, type AxlEventOf, type AxlEventType, AxlRuntime, AxlStream, BudgetExceededError, type BudgetOptions, type BudgetResult, CONFIG_CANDIDATES, COST_BEARING_LEAF_TYPES, type CallbackMeta, type ChatMessage, type ChatOptions, type CheckpointEventData, type CoalescedPartialObject, type CreateContextOptions, type DelegateData, type DelegateOptions, type Effort, type EmbedResult, type EmbedUsage, type Embedder, type EvalExecuteWorkflow, type EvalHistoryEntry, type EventStreamOptions, EventStreamOverflowError, type ExecuteOptions, type ExecutionInfo, type ExecutionState, GeminiProvider, type GuardrailBlockHandler, type GuardrailData, GuardrailError, type GuardrailResult, type GuardrailsConfig, type HandoffDescriptor, type HandoffRecord, type HandoffReturnData, type HandoffStartData, type HumanDecision, InMemoryVectorStore, type InputGuardrail, type MapOptions, MaxTurnsError, McpManager, type McpServer, type McpServerConfig, type McpToolDefinition, type McpToolResult, type MemoryConfig, type MemoryEventData, MemoryManager, MemoryStore, NoConsensus, NoopSpanManager, OpenAIEmbedder, OpenAIProvider, OpenAIResponsesProvider, type OutputGuardrail, type OutputValidator, type PendingDecision, type Provider, type ProviderAdapter, ProviderRegistry, type ProviderResponse, QuorumNotMet, REDACTED, REDACTION_RULES, type RaceOptions, type RateLimitConfig, RateLimiter, type RecallOptions, type RecallResult, RedisStore, type RememberOptions, type RememberResult, type ResolvedThinkingOptions, type Result, type RetryPolicy, SQLiteStore, type SchemaCheckData, Session, type SessionOptions, type SpanHandle, type SpanManager, type SpawnOptions, SqliteVectorStore, type StateStore, type StreamChunk, type StringDeltaData, type StringStreamEvent, type StringStreamFilter, type TelemetryConfig, TimeoutError, type Tool, type ToolApprovalData, type ToolCallData, type ToolCallMessage, type ToolCallStartData, type ToolChoice, type ToolConfig, ToolDenied, type ToolDeniedData, type ToolHooks, type ValidateData, type ValidateResult, ValidationError, type VectorEntry, type VectorResult, type VectorStore, type VerifyData, VerifyError, type VerifyOptions, type VerifyRetry, type VoteOptions, type Workflow, type WorkflowConfig, WorkflowContext, type WorkflowContextInit, type WorkflowEndData, type WorkflowStartData, agent, createSpanManager, defineConfig, eventCostContribution, expandGlob, extractJson, findConfig, importModule, isCostBearingLeaf, isRootLevel, needsTsxLoader, parsePartialJson, pickDefault, pickExport, redactEvent, registerConditions, resolveRuntime, resolveThinkingOptions, stringStreamFromEvents, tool, workflow, zodToJsonSchema };
|