@axlsdk/axl 0.24.0 → 0.24.2

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/dist/index.d.cts CHANGED
@@ -151,6 +151,7 @@ declare function summarizeModelInput(input: ModelInput): string;
151
151
  * {@link AccountingReason}, which makes the scope `incomplete` and makes
152
152
  * `knownCost` an explicit lower bound.
153
153
  */
154
+
154
155
  /**
155
156
  * How much of the declared/instrumented scope the numbers actually cover.
156
157
  *
@@ -158,8 +159,9 @@ declare function summarizeModelInput(input: ModelInput): string;
158
159
  *
159
160
  * - `'complete'` — every operation in the scope reached a terminal state with a
160
161
  * usable charge (including known $0).
161
- * - `'incomplete'` — at least one operation settled without a usable charge;
162
- * `knownCost` is a lower bound and `reasons` says why.
162
+ * - `'incomplete'` — at least one operation lacked a usable charge, or the
163
+ * scope detected work from an incompatible loaded copy; `knownCost` is a
164
+ * lower bound and `reasons` says why.
163
165
  * - `'unverified'` — reserved for READERS of artifacts that carry no
164
166
  * accounting at all (legacy eval results). A live scope never produces it.
165
167
  */
@@ -185,9 +187,8 @@ type AccountingReason =
185
187
  /** An external operation finished without calling `report.setCost()`. */
186
188
  | 'external_unreported'
187
189
  /**
188
- * A consumer ran work with no accounting scope available (e.g. `@axlsdk/eval`
189
- * driving a runtime that predates `trackOutcome`). Core defines the name only
190
- * — no core producer emits it.
190
+ * A consumer ran work with no accounting scope available, or another loaded
191
+ * copy attempted work under a scope whose accounting protocol it cannot join.
191
192
  */
192
193
  | 'uninstrumented';
193
194
  /** The instrumented boundaries that can open an operation. */
@@ -216,7 +217,7 @@ type Accounting = {
216
217
  /** Sum of settled, usable, disjoint charges. Never includes caller aggregates. */
217
218
  knownCost: number;
218
219
  completeness: AccountingCompleteness;
219
- /** Reason → count of operations carrying it. Empty object when complete. */
220
+ /** Reason → count of unresolved operations or coverage failures. */
220
221
  reasons: Partial<Record<AccountingReason, number>>;
221
222
  usage: AccountingUsage;
222
223
  operations: {
@@ -229,7 +230,7 @@ type Accounting = {
229
230
  total: number;
230
231
  /** Terminal with a usable cost, including a known $0. */
231
232
  settled: number;
232
- /** Terminal or abandoned without a usable cost. Drives `completeness`. */
233
+ /** Terminal or abandoned without a usable cost. Coverage failures can also make `incomplete`. */
233
234
  unknown: number;
234
235
  /** Refused admission — never dispatched, contributes nothing anywhere. */
235
236
  denied: number;
@@ -423,6 +424,8 @@ type ToolChoice = 'auto' | 'none' | 'required' | {
423
424
  */
424
425
  type ChatOptions = {
425
426
  model: string;
427
+ /** @internal Full URI of a `ctx.ask` agent turn for cross-runtime diagnostics. */
428
+ accountingModelUri?: string;
426
429
  temperature?: number;
427
430
  tools?: ToolDefinition[];
428
431
  maxTokens?: number;
@@ -2121,7 +2124,6 @@ declare class EventStreamOverflowError extends Error {
2121
2124
  readonly cause?: unknown;
2122
2125
  constructor(maxQueued: number, eventType: string, cause?: unknown);
2123
2126
  }
2124
- /** A known tool failure whose author-provided model message is safe to expose. */
2125
2127
  declare class ToolFailure extends AxlError {
2126
2128
  readonly modelMessage: string;
2127
2129
  readonly cause?: unknown;
@@ -3012,7 +3014,8 @@ type RateLimitConfig = {
3012
3014
  * `adaptive`), a call first waits out any active rate-limit brake and only
3013
3015
  * then starts this clock; a call already queued when a brake begins keeps
3014
3016
  * its clock running through it. A retry's re-acquire after a rate-limit 429
3015
- * is exempt: it is bounded by `maxRateLimitRetries` and the ask's `timeout`.
3017
+ * is exempt: it is bounded by `maxRateLimitRetries`, or by the ask's abort
3018
+ * signal when the caller needs a strict deadline.
3016
3019
  */
3017
3020
  acquireTimeoutMs?: number;
3018
3021
  /**
@@ -3025,12 +3028,10 @@ type RateLimitConfig = {
3025
3028
  * recovered linearly on success, dropped once traffic stays well below it;
3026
3029
  * tuning is internal) until it reopens. Nothing waits before the first 429.
3027
3030
  *
3028
- * Only first-party OpenAI (`openai:`, `openai-responses:`) and Anthropic at
3029
- * the vendor's default endpoint origin read the 429 body: there a spend-cap
3030
- * 429 fails fast, and a low quota header holds recovery. Everywhere else
3031
- * (Gemini, OpenAI-compatible presets, a proxy or gateway `baseUrl`) every
3032
- * 429 is a rate limit, so a spend-cap or daily-quota 429 fails only once
3033
- * `maxRateLimitRetries` is spent.
3031
+ * First-party OpenAI, Anthropic, and Gemini at their vendor origins read
3032
+ * 429 bodies: explicit terminal quota/billing limits fail fast. Only OpenAI
3033
+ * and Anthropic read 2xx quota hints. Unrecognized Gemini 429s, presets,
3034
+ * and proxy/gateway origins retry as rate limits.
3034
3035
  *
3035
3036
  * `false` restores the plain behavior: a 429 shares the transient retry
3036
3037
  * budget, holds up no other call, and nothing is paced. Ignored by a
@@ -3225,10 +3226,10 @@ type QuotaDialect = {
3225
3226
  * share one predicate, `Date.now() < brakeUntil`. A scope that does not adapt
3226
3227
  * never brakes, so it behaves exactly as a plain `RateLimiter`.
3227
3228
  *
3228
- * Adapting needs no quota dialect. A dialect (first-party OpenAI and Anthropic
3229
- * at the vendor origin, see `quota.ts`) adds only two vendor-specific extras:
3230
- * spend-cap classification of a 429 body, and the 2xx quota hint that holds
3231
- * recovery. Without one, every 429 is treated as a rate limit and the hint is
3229
+ * Adapting needs no quota dialect. A dialect (first-party OpenAI, Anthropic,
3230
+ * or Gemini at the vendor origin, see `quota.ts`) adds classification of a
3231
+ * 429 body; OpenAI and Anthropic also provide 2xx quota hints. Without one,
3232
+ * every 429 is treated as a rate limit and the hint is
3232
3233
  * never read, so recovery and reopening proceed as if the account were healthy.
3233
3234
  */
3234
3235
  declare class ScopeGovernor extends RateLimiter {
@@ -5840,7 +5841,7 @@ type ModelTimingRollup = Record<string, {
5840
5841
  /** Timed calls that reported a `firstTokenMs` — the denominator for it. */
5841
5842
  firstTokenCalls?: number;
5842
5843
  /**
5843
- * The per-call blocks the sums were built from, in event order.
5844
+ * The per-call blocks the sums were built from, in settlement order.
5844
5845
  * `length === calls`. Present only under `captureTimingSamples`, because
5845
5846
  * retaining it is O(calls) in memory and the sums alone are O(models) — a
5846
5847
  * caller that needs a real DISTRIBUTION (percentiles, min/max) cannot
@@ -6517,8 +6518,9 @@ declare class AxlRuntime extends EventEmitter {
6517
6518
  * new paid operations once known spend reaches the limit. Already-dispatched
6518
6519
  * work still settles and is still counted.
6519
6520
  *
6520
- * `metadata`, `modelTiming` and `traces` remain EVENT-derived and therefore
6521
- * depend on trace configuration; `accounting` never does.
6521
+ * Model metadata and timing share the settlement scope with accounting, so
6522
+ * they cross runtimes and compatible ESM/CJS copies. Workflow names and
6523
+ * captured traces still come from this runtime's events.
6522
6524
  */
6523
6525
  trackOutcome<T>(fn: () => Promise<T>, options?: TrackOutcomeOptions): Promise<TrackedOutcome<T>>;
6524
6526
  /**
package/dist/index.d.ts CHANGED
@@ -151,6 +151,7 @@ declare function summarizeModelInput(input: ModelInput): string;
151
151
  * {@link AccountingReason}, which makes the scope `incomplete` and makes
152
152
  * `knownCost` an explicit lower bound.
153
153
  */
154
+
154
155
  /**
155
156
  * How much of the declared/instrumented scope the numbers actually cover.
156
157
  *
@@ -158,8 +159,9 @@ declare function summarizeModelInput(input: ModelInput): string;
158
159
  *
159
160
  * - `'complete'` — every operation in the scope reached a terminal state with a
160
161
  * usable charge (including known $0).
161
- * - `'incomplete'` — at least one operation settled without a usable charge;
162
- * `knownCost` is a lower bound and `reasons` says why.
162
+ * - `'incomplete'` — at least one operation lacked a usable charge, or the
163
+ * scope detected work from an incompatible loaded copy; `knownCost` is a
164
+ * lower bound and `reasons` says why.
163
165
  * - `'unverified'` — reserved for READERS of artifacts that carry no
164
166
  * accounting at all (legacy eval results). A live scope never produces it.
165
167
  */
@@ -185,9 +187,8 @@ type AccountingReason =
185
187
  /** An external operation finished without calling `report.setCost()`. */
186
188
  | 'external_unreported'
187
189
  /**
188
- * A consumer ran work with no accounting scope available (e.g. `@axlsdk/eval`
189
- * driving a runtime that predates `trackOutcome`). Core defines the name only
190
- * — no core producer emits it.
190
+ * A consumer ran work with no accounting scope available, or another loaded
191
+ * copy attempted work under a scope whose accounting protocol it cannot join.
191
192
  */
192
193
  | 'uninstrumented';
193
194
  /** The instrumented boundaries that can open an operation. */
@@ -216,7 +217,7 @@ type Accounting = {
216
217
  /** Sum of settled, usable, disjoint charges. Never includes caller aggregates. */
217
218
  knownCost: number;
218
219
  completeness: AccountingCompleteness;
219
- /** Reason → count of operations carrying it. Empty object when complete. */
220
+ /** Reason → count of unresolved operations or coverage failures. */
220
221
  reasons: Partial<Record<AccountingReason, number>>;
221
222
  usage: AccountingUsage;
222
223
  operations: {
@@ -229,7 +230,7 @@ type Accounting = {
229
230
  total: number;
230
231
  /** Terminal with a usable cost, including a known $0. */
231
232
  settled: number;
232
- /** Terminal or abandoned without a usable cost. Drives `completeness`. */
233
+ /** Terminal or abandoned without a usable cost. Coverage failures can also make `incomplete`. */
233
234
  unknown: number;
234
235
  /** Refused admission — never dispatched, contributes nothing anywhere. */
235
236
  denied: number;
@@ -423,6 +424,8 @@ type ToolChoice = 'auto' | 'none' | 'required' | {
423
424
  */
424
425
  type ChatOptions = {
425
426
  model: string;
427
+ /** @internal Full URI of a `ctx.ask` agent turn for cross-runtime diagnostics. */
428
+ accountingModelUri?: string;
426
429
  temperature?: number;
427
430
  tools?: ToolDefinition[];
428
431
  maxTokens?: number;
@@ -2121,7 +2124,6 @@ declare class EventStreamOverflowError extends Error {
2121
2124
  readonly cause?: unknown;
2122
2125
  constructor(maxQueued: number, eventType: string, cause?: unknown);
2123
2126
  }
2124
- /** A known tool failure whose author-provided model message is safe to expose. */
2125
2127
  declare class ToolFailure extends AxlError {
2126
2128
  readonly modelMessage: string;
2127
2129
  readonly cause?: unknown;
@@ -3012,7 +3014,8 @@ type RateLimitConfig = {
3012
3014
  * `adaptive`), a call first waits out any active rate-limit brake and only
3013
3015
  * then starts this clock; a call already queued when a brake begins keeps
3014
3016
  * its clock running through it. A retry's re-acquire after a rate-limit 429
3015
- * is exempt: it is bounded by `maxRateLimitRetries` and the ask's `timeout`.
3017
+ * is exempt: it is bounded by `maxRateLimitRetries`, or by the ask's abort
3018
+ * signal when the caller needs a strict deadline.
3016
3019
  */
3017
3020
  acquireTimeoutMs?: number;
3018
3021
  /**
@@ -3025,12 +3028,10 @@ type RateLimitConfig = {
3025
3028
  * recovered linearly on success, dropped once traffic stays well below it;
3026
3029
  * tuning is internal) until it reopens. Nothing waits before the first 429.
3027
3030
  *
3028
- * Only first-party OpenAI (`openai:`, `openai-responses:`) and Anthropic at
3029
- * the vendor's default endpoint origin read the 429 body: there a spend-cap
3030
- * 429 fails fast, and a low quota header holds recovery. Everywhere else
3031
- * (Gemini, OpenAI-compatible presets, a proxy or gateway `baseUrl`) every
3032
- * 429 is a rate limit, so a spend-cap or daily-quota 429 fails only once
3033
- * `maxRateLimitRetries` is spent.
3031
+ * First-party OpenAI, Anthropic, and Gemini at their vendor origins read
3032
+ * 429 bodies: explicit terminal quota/billing limits fail fast. Only OpenAI
3033
+ * and Anthropic read 2xx quota hints. Unrecognized Gemini 429s, presets,
3034
+ * and proxy/gateway origins retry as rate limits.
3034
3035
  *
3035
3036
  * `false` restores the plain behavior: a 429 shares the transient retry
3036
3037
  * budget, holds up no other call, and nothing is paced. Ignored by a
@@ -3225,10 +3226,10 @@ type QuotaDialect = {
3225
3226
  * share one predicate, `Date.now() < brakeUntil`. A scope that does not adapt
3226
3227
  * never brakes, so it behaves exactly as a plain `RateLimiter`.
3227
3228
  *
3228
- * Adapting needs no quota dialect. A dialect (first-party OpenAI and Anthropic
3229
- * at the vendor origin, see `quota.ts`) adds only two vendor-specific extras:
3230
- * spend-cap classification of a 429 body, and the 2xx quota hint that holds
3231
- * recovery. Without one, every 429 is treated as a rate limit and the hint is
3229
+ * Adapting needs no quota dialect. A dialect (first-party OpenAI, Anthropic,
3230
+ * or Gemini at the vendor origin, see `quota.ts`) adds classification of a
3231
+ * 429 body; OpenAI and Anthropic also provide 2xx quota hints. Without one,
3232
+ * every 429 is treated as a rate limit and the hint is
3232
3233
  * never read, so recovery and reopening proceed as if the account were healthy.
3233
3234
  */
3234
3235
  declare class ScopeGovernor extends RateLimiter {
@@ -5840,7 +5841,7 @@ type ModelTimingRollup = Record<string, {
5840
5841
  /** Timed calls that reported a `firstTokenMs` — the denominator for it. */
5841
5842
  firstTokenCalls?: number;
5842
5843
  /**
5843
- * The per-call blocks the sums were built from, in event order.
5844
+ * The per-call blocks the sums were built from, in settlement order.
5844
5845
  * `length === calls`. Present only under `captureTimingSamples`, because
5845
5846
  * retaining it is O(calls) in memory and the sums alone are O(models) — a
5846
5847
  * caller that needs a real DISTRIBUTION (percentiles, min/max) cannot
@@ -6517,8 +6518,9 @@ declare class AxlRuntime extends EventEmitter {
6517
6518
  * new paid operations once known spend reaches the limit. Already-dispatched
6518
6519
  * work still settles and is still counted.
6519
6520
  *
6520
- * `metadata`, `modelTiming` and `traces` remain EVENT-derived and therefore
6521
- * depend on trace configuration; `accounting` never does.
6521
+ * Model metadata and timing share the settlement scope with accounting, so
6522
+ * they cross runtimes and compatible ESM/CJS copies. Workflow names and
6523
+ * captured traces still come from this runtime's events.
6522
6524
  */
6523
6525
  trackOutcome<T>(fn: () => Promise<T>, options?: TrackOutcomeOptions): Promise<TrackedOutcome<T>>;
6524
6526
  /**