@axlsdk/axl 0.22.2 → 0.22.3
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 +1 -1
- package/dist/index.cjs +365 -136
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +164 -3
- package/dist/index.d.ts +164 -3
- package/dist/index.js +365 -136
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -228,7 +228,46 @@ interface Provider {
|
|
|
228
228
|
* JSON instruction instead (e.g. Anthropic).
|
|
229
229
|
*/
|
|
230
230
|
nativeStructuredOutputSupport?(model: string): 'schema' | 'downgraded' | 'lossy' | 'unsupported';
|
|
231
|
+
/**
|
|
232
|
+
* How this provider resolved the unified `effort` knob for this request.
|
|
233
|
+
*
|
|
234
|
+
* Adapters clamp `effort` to what each model actually accepts (Gemini 3.x
|
|
235
|
+
* cannot disable thinking; OpenAI Chat Completions caps `'max'` at `'xhigh'`;
|
|
236
|
+
* Anthropic models that always think fall back to adaptive `'low'`). That
|
|
237
|
+
* clamp used to be invisible to run provenance. The runtime calls this once
|
|
238
|
+
* per ask, right after provider resolution, and emits a
|
|
239
|
+
* `provider_diagnostic { kind: 'effort_clamped' }` event plus a deduped
|
|
240
|
+
* `console.warn` when `clamped` is true — the adapter only *reports*, the
|
|
241
|
+
* runtime decides how to surface it (only the runtime can see
|
|
242
|
+
* `AxlConfig.diagnostics.silent`).
|
|
243
|
+
*
|
|
244
|
+
* The adapter applies its own `providerOptions.model` override before
|
|
245
|
+
* resolving, so the report describes the model actually sent.
|
|
246
|
+
*
|
|
247
|
+
* Optional, and optional to answer: return `undefined` when there is nothing
|
|
248
|
+
* to report (no effort requested, the model is unknown, or the effort is
|
|
249
|
+
* honored verbatim). An adapter MAY also report an honored resolution with
|
|
250
|
+
* `clamped: false`; the runtime stays silent for those.
|
|
251
|
+
*/
|
|
252
|
+
effortResolution?(options: Pick<ChatOptions, 'model' | 'effort' | 'thinkingBudget' | 'includeThoughts' | 'providerOptions'>): EffortResolution | undefined;
|
|
231
253
|
}
|
|
254
|
+
/**
|
|
255
|
+
* An adapter's report of how it resolved the unified `effort` for one request.
|
|
256
|
+
*
|
|
257
|
+
* `effective` is a provider-NATIVE level string rather than an `Effort` because
|
|
258
|
+
* not every effective value maps back onto the unified union (Gemini's
|
|
259
|
+
* `'minimal'`, OpenAI's `'minimal'`, Anthropic's adaptive `'low'`).
|
|
260
|
+
*/
|
|
261
|
+
type EffortResolution = {
|
|
262
|
+
/** The unified effort the caller asked for. */
|
|
263
|
+
requested: Effort;
|
|
264
|
+
/** The provider-native level actually sent (e.g. `'minimal'`, `'xhigh'`, `'low'`). */
|
|
265
|
+
effective: string;
|
|
266
|
+
/** True when `effective` is not what `requested` asked for. */
|
|
267
|
+
clamped: boolean;
|
|
268
|
+
/** Human-readable reason, surfaced verbatim on the diagnostic event. */
|
|
269
|
+
cause?: string;
|
|
270
|
+
};
|
|
232
271
|
/**
|
|
233
272
|
* Alias for Provider. Used for backward compatibility with index.ts exports.
|
|
234
273
|
*/
|
|
@@ -374,6 +413,10 @@ type AskOptions<T = unknown> = {
|
|
|
374
413
|
validate?: OutputValidator<T>;
|
|
375
414
|
/** Maximum retries for validate failures (default: 2). */
|
|
376
415
|
validateRetries?: number;
|
|
416
|
+
/** Rewrite the corrective feedback the model sees when the guardrail, schema, or validate
|
|
417
|
+
* gate rejects an attempt — or abort the retry with `{ retry: false }`. See
|
|
418
|
+
* `RetryFeedbackHook`. */
|
|
419
|
+
retryFeedback?: RetryFeedbackHook<T>;
|
|
377
420
|
/** Per-call metadata passed to dynamic model/system selector functions. */
|
|
378
421
|
metadata?: Record<string, unknown>;
|
|
379
422
|
/** Override temperature for this call. */
|
|
@@ -415,6 +458,9 @@ type DelegateOptions<T = unknown> = {
|
|
|
415
458
|
validate?: OutputValidator<T>;
|
|
416
459
|
/** Maximum retries for validate failures (default: 2). Passed through to the final `ctx.ask()` call. */
|
|
417
460
|
validateRetries?: number;
|
|
461
|
+
/** Custom gate-retry feedback. Passed through to the final `ctx.ask()` call on both the
|
|
462
|
+
* single-candidate and the routed path. See `RetryFeedbackHook`. */
|
|
463
|
+
retryFeedback?: RetryFeedbackHook<T>;
|
|
418
464
|
};
|
|
419
465
|
/** Race options */
|
|
420
466
|
type RaceOptions<T = unknown> = {
|
|
@@ -430,11 +476,11 @@ type ExecutionStatus = 'running' | 'completed' | 'failed' | 'waiting';
|
|
|
430
476
|
* derive `AxlEventType` from this tuple and use it to validate stream filters,
|
|
431
477
|
* redaction tables, and exhaustiveness assertions.
|
|
432
478
|
*/
|
|
433
|
-
declare const AXL_EVENT_TYPES: readonly ["workflow_start", "workflow_end", "transcription_start", "transcription_end", "ask_start", "ask_end", "agent_call_start", "agent_call_end", "token", "tool_call_start", "tool_call_end", "tool_call_rejected", "tool_approval", "delegate", "handoff_start", "handoff_return", "pipeline", "partial_object", "string_delta", "verify", "schema_diagnostic", "log", "memory_remember", "memory_recall", "memory_forget", "checkpoint_save", "checkpoint_replay", "await_human", "await_human_resolved", "guardrail", "schema_check", "validate", "done", "error"];
|
|
479
|
+
declare const AXL_EVENT_TYPES: readonly ["workflow_start", "workflow_end", "transcription_start", "transcription_end", "ask_start", "ask_end", "agent_call_start", "agent_call_end", "token", "tool_call_start", "tool_call_end", "tool_call_rejected", "tool_approval", "delegate", "handoff_start", "handoff_return", "pipeline", "partial_object", "string_delta", "verify", "schema_diagnostic", "provider_diagnostic", "log", "memory_remember", "memory_recall", "memory_forget", "checkpoint_save", "checkpoint_replay", "await_human", "await_human_resolved", "guardrail", "schema_check", "validate", "done", "error"];
|
|
434
480
|
/** Discriminator union derived from `AXL_EVENT_TYPES`. */
|
|
435
481
|
type AxlEventType = (typeof AXL_EVENT_TYPES)[number];
|
|
436
482
|
/** Backward-compatible name for the canonical v2 writer discriminator list. */
|
|
437
|
-
declare const AXL_EVENT_TYPES_V2: readonly ["workflow_start", "workflow_end", "transcription_start", "transcription_end", "ask_start", "ask_end", "agent_call_start", "agent_call_end", "token", "tool_call_start", "tool_call_end", "tool_call_rejected", "tool_approval", "delegate", "handoff_start", "handoff_return", "pipeline", "partial_object", "string_delta", "verify", "schema_diagnostic", "log", "memory_remember", "memory_recall", "memory_forget", "checkpoint_save", "checkpoint_replay", "await_human", "await_human_resolved", "guardrail", "schema_check", "validate", "done", "error"];
|
|
483
|
+
declare const AXL_EVENT_TYPES_V2: readonly ["workflow_start", "workflow_end", "transcription_start", "transcription_end", "ask_start", "ask_end", "agent_call_start", "agent_call_end", "token", "tool_call_start", "tool_call_end", "tool_call_rejected", "tool_approval", "delegate", "handoff_start", "handoff_return", "pipeline", "partial_object", "string_delta", "verify", "schema_diagnostic", "provider_diagnostic", "log", "memory_remember", "memory_recall", "memory_forget", "checkpoint_save", "checkpoint_replay", "await_human", "await_human_resolved", "guardrail", "schema_check", "validate", "done", "error"];
|
|
438
484
|
/** Accepted/rejected tool lifecycle discriminators in event schema v2. */
|
|
439
485
|
declare const AXL_TOOL_LIFECYCLE_TYPES_V2: readonly ["tool_call_start", "tool_call_end", "tool_call_rejected"];
|
|
440
486
|
/** Resolved model parameters sent to the provider for an LLM call. */
|
|
@@ -779,6 +825,34 @@ type SchemaDiagnosticData = {
|
|
|
779
825
|
provider?: string;
|
|
780
826
|
support: 'downgraded' | 'lossy' | 'unsupported';
|
|
781
827
|
};
|
|
828
|
+
/**
|
|
829
|
+
* Data for the `provider_diagnostic` event — a `kind`-discriminated payload
|
|
830
|
+
* (like `SchemaDiagnosticData`) reporting that the resolved provider could not
|
|
831
|
+
* honor a portable request knob verbatim.
|
|
832
|
+
*
|
|
833
|
+
* - `effort_clamped` — the adapter clamped the unified `effort` to what the
|
|
834
|
+
* model actually accepts (Gemini 3.x cannot disable thinking; OpenAI Chat
|
|
835
|
+
* Completions caps `'max'` at `'xhigh'`; Anthropic models that always think
|
|
836
|
+
* fall back to adaptive `'low'`). `requested` is the unified value the caller
|
|
837
|
+
* asked for; `effective` is the provider-native level actually sent, which is
|
|
838
|
+
* deliberately a free string because not every native level maps back onto
|
|
839
|
+
* `Effort`. One per ask, emitted before the first `agent_call_start` — join it
|
|
840
|
+
* to `agent_call_start` (which keeps reporting the *requested* effort) by
|
|
841
|
+
* `askId` for full provenance.
|
|
842
|
+
*
|
|
843
|
+
* The union is `kind`-discriminated so later provider cliffs can join without a
|
|
844
|
+
* new event type.
|
|
845
|
+
*/
|
|
846
|
+
type ProviderDiagnosticData = {
|
|
847
|
+
kind: 'effort_clamped';
|
|
848
|
+
/** Provider name (`provider.name`), when the adapter exposes one. */
|
|
849
|
+
provider?: string;
|
|
850
|
+
/** The model the request is actually sent to (after any `providerOptions.model`). */
|
|
851
|
+
model: string;
|
|
852
|
+
requested: Effort;
|
|
853
|
+
effective: string;
|
|
854
|
+
cause: string;
|
|
855
|
+
};
|
|
782
856
|
/** Data shape for legacy `guardrail` events. Replaced by `pipeline` in PR 2. */
|
|
783
857
|
type GuardrailData = {
|
|
784
858
|
guardrailType: 'input' | 'output';
|
|
@@ -1132,6 +1206,9 @@ type LegacyAxlEventPayloadV1 = (AxlEventBase & {
|
|
|
1132
1206
|
}) | (AxlEventBase & AskScoped & {
|
|
1133
1207
|
type: 'schema_diagnostic';
|
|
1134
1208
|
data: SchemaDiagnosticData;
|
|
1209
|
+
}) | (AxlEventBase & AskScoped & {
|
|
1210
|
+
type: 'provider_diagnostic';
|
|
1211
|
+
data: ProviderDiagnosticData;
|
|
1135
1212
|
}) | (AxlEventBase & Partial<AskScoped> & {
|
|
1136
1213
|
type: 'guardrail';
|
|
1137
1214
|
data?: GuardrailData;
|
|
@@ -1319,6 +1396,43 @@ type ValidateResult = {
|
|
|
1319
1396
|
type OutputValidator<T = unknown> = (output: T, ctx: {
|
|
1320
1397
|
metadata: Record<string, unknown>;
|
|
1321
1398
|
}) => ValidateResult | Promise<ValidateResult>;
|
|
1399
|
+
/** What a rejecting output gate tells a `retryFeedback` hook about the attempt it is
|
|
1400
|
+
* about to retry. One shape for all three gates — `stage` discriminates. */
|
|
1401
|
+
type RetryFeedbackInfo<T = unknown> = {
|
|
1402
|
+
/** Which gate rejected: JSON/Zod parse, post-schema `validate`, or output guardrail. */
|
|
1403
|
+
stage: 'schema' | 'validate' | 'guardrail';
|
|
1404
|
+
/** 1-based index of the attempt that was just rejected. */
|
|
1405
|
+
attempt: number;
|
|
1406
|
+
/** Total attempts this gate allows (`retries` + 1). */
|
|
1407
|
+
maxAttempts: number;
|
|
1408
|
+
/** Raw model output that was rejected. */
|
|
1409
|
+
output: string;
|
|
1410
|
+
/** The parsed, schema-valid object, typed by the ask's `schema`. Present only for
|
|
1411
|
+
* `stage: 'validate'` — the other gates run before or without a parsed value. */
|
|
1412
|
+
parsed?: T;
|
|
1413
|
+
/** The gate's own reason (Zod message, `ValidateResult.reason`, guardrail reason). */
|
|
1414
|
+
reason: string;
|
|
1415
|
+
/** The `ZodError` (or non-Zod parse error) for `schema`; the validator's thrown error for
|
|
1416
|
+
* `validate` when it threw. Absent for `guardrail` and for a clean `validate` rejection. */
|
|
1417
|
+
error?: unknown;
|
|
1418
|
+
/** The feedback text the runtime would send if the hook did not intervene. */
|
|
1419
|
+
defaultMessage: string;
|
|
1420
|
+
};
|
|
1421
|
+
/** A non-empty string replaces `defaultMessage` verbatim; `undefined` (or `''`) keeps it;
|
|
1422
|
+
* `{ retry: false }` stops retrying and makes the gate throw its typed terminal error. */
|
|
1423
|
+
type RetryFeedbackResult = string | undefined | {
|
|
1424
|
+
retry: false;
|
|
1425
|
+
};
|
|
1426
|
+
/** Rewrites (or aborts) the corrective turn the model sees after an output gate rejects an
|
|
1427
|
+
* attempt. Runs only while a retry is still permitted — never on the exhausting attempt —
|
|
1428
|
+
* and after the gate's own event is emitted. Exceptions propagate to the caller.
|
|
1429
|
+
*
|
|
1430
|
+
* `void` is accepted alongside `RetryFeedbackResult` so a hook used purely for logging or
|
|
1431
|
+
* inspection — a block body that never returns — type-checks; it keeps the default text.
|
|
1432
|
+
* Any other return value is a contract violation and throws a `TypeError`. */
|
|
1433
|
+
type RetryFeedbackHook<T = unknown> = (info: RetryFeedbackInfo<T>, ctx: {
|
|
1434
|
+
metadata: Record<string, unknown>;
|
|
1435
|
+
}) => RetryFeedbackResult | void | Promise<RetryFeedbackResult | void>;
|
|
1322
1436
|
/** Execution info */
|
|
1323
1437
|
type ExecutionInfoV1 = {
|
|
1324
1438
|
executionId: string;
|
|
@@ -3534,6 +3648,20 @@ declare class WorkflowContext<TInput = unknown> {
|
|
|
3534
3648
|
private observeToolInvocation;
|
|
3535
3649
|
ask<T = string>(agent: Agent, prompt: ModelInput, options?: AskOptions<T>): Promise<T>;
|
|
3536
3650
|
private executeAgentCall;
|
|
3651
|
+
/**
|
|
3652
|
+
* Resolve the corrective feedback text for one rejected attempt, giving an optional
|
|
3653
|
+
* caller-supplied `retryFeedback` hook the chance to replace it or to stop retrying.
|
|
3654
|
+
*
|
|
3655
|
+
* Called by all three output gates, only while a retry is still permitted (never on the
|
|
3656
|
+
* exhausting attempt) and only after the gate's own event has been emitted, so a hook that
|
|
3657
|
+
* throws or aborts can never erase the evidence that the gate rejected. A non-empty string
|
|
3658
|
+
* replaces `defaultMessage` verbatim; `undefined` / `''` keeps it; `{ retry: false }` asks
|
|
3659
|
+
* the gate to throw its typed terminal error. Hook exceptions propagate — a bug in caller
|
|
3660
|
+
* code is not a model failure and must not be retried into silence, and neither is a
|
|
3661
|
+
* return value outside the contract: an unrecognized shape throws instead of silently
|
|
3662
|
+
* degrading to the default text, which would hide the defect behind extra token spend.
|
|
3663
|
+
*/
|
|
3664
|
+
private resolveRetryFeedback;
|
|
3537
3665
|
/**
|
|
3538
3666
|
* Push the final assistant message into session history, preserving providerMetadata
|
|
3539
3667
|
* (e.g., Gemini thought signatures needed for multi-turn reasoning context) and
|
|
@@ -3557,6 +3685,20 @@ declare class WorkflowContext<TInput = unknown> {
|
|
|
3557
3685
|
* (expected behavior for any tool-using agent, not a surprise).
|
|
3558
3686
|
*/
|
|
3559
3687
|
private emitSchemaDiagnostics;
|
|
3688
|
+
/**
|
|
3689
|
+
* Emit a `provider_diagnostic` when the resolved provider reports that it
|
|
3690
|
+
* could not honor the unified `effort` verbatim (P3/R6/R7).
|
|
3691
|
+
*
|
|
3692
|
+
* The adapter only *resolves* — it returns the requested and effective levels
|
|
3693
|
+
* from the same pure resolver its request builder uses. The runtime decides
|
|
3694
|
+
* how to surface that, because only the runtime can see the event bus and
|
|
3695
|
+
* `AxlConfig.diagnostics.silent` (adapters receive `ProviderConfig` only).
|
|
3696
|
+
*
|
|
3697
|
+
* Called once per ask, so a tool loop with N provider round trips still emits
|
|
3698
|
+
* one event; the `console.warn` dedupes once per process per distinct clamp.
|
|
3699
|
+
* A throwing `effortResolution` is a provider bug and propagates.
|
|
3700
|
+
*/
|
|
3701
|
+
private emitProviderDiagnostics;
|
|
3560
3702
|
private buildToolDefs;
|
|
3561
3703
|
/**
|
|
3562
3704
|
* Summarize old messages to fit within context window.
|
|
@@ -5145,6 +5287,7 @@ declare const REDACTION_RULES: {
|
|
|
5145
5287
|
string_delta: RuleFor<"string_delta">;
|
|
5146
5288
|
verify: RuleFor<"verify">;
|
|
5147
5289
|
schema_diagnostic: RuleFor<"schema_diagnostic">;
|
|
5290
|
+
provider_diagnostic: RuleFor<"provider_diagnostic">;
|
|
5148
5291
|
log: RuleFor<"log">;
|
|
5149
5292
|
memory_remember: RuleFor<"memory_remember">;
|
|
5150
5293
|
memory_recall: RuleFor<"memory_recall">;
|
|
@@ -5272,6 +5415,9 @@ declare class OpenAIProvider extends OpenAICompatibleProvider {
|
|
|
5272
5415
|
dangerouslyAllowInsecureHttp?: boolean;
|
|
5273
5416
|
rateLimit?: RateLimitConfig;
|
|
5274
5417
|
});
|
|
5418
|
+
/** Report a clamped `effort` — Chat Completions caps `'max'` at `'xhigh'` and
|
|
5419
|
+
* rejects `'none'` before gpt-5.1 (clamped to `'minimal'`). */
|
|
5420
|
+
effortResolution(options: Pick<ChatOptions, 'model' | 'effort' | 'thinkingBudget' | 'includeThoughts' | 'providerOptions'>): EffortResolution | undefined;
|
|
5275
5421
|
protected computeCost(model: string, usage: ProviderResponse['usage'], _reportedCost: number | undefined, context?: DirectOpenAIPricingContext): number | undefined;
|
|
5276
5422
|
}
|
|
5277
5423
|
|
|
@@ -5289,6 +5435,10 @@ declare class OpenAIResponsesProvider implements Provider {
|
|
|
5289
5435
|
sources: readonly InputMediaSource['type'][];
|
|
5290
5436
|
};
|
|
5291
5437
|
};
|
|
5438
|
+
/** Report a clamped `effort`. Responses accepts the native `'max'` tier that
|
|
5439
|
+
* Chat Completions caps, but still clamps `'none'` before gpt-5.1, `'xhigh'`
|
|
5440
|
+
* below gpt-5.2, and everything to `'high'` on gpt-5-pro. */
|
|
5441
|
+
effortResolution(options: Pick<ChatOptions, 'model' | 'effort' | 'thinkingBudget' | 'includeThoughts' | 'providerOptions'>): EffortResolution | undefined;
|
|
5292
5442
|
validateInput(request: ProviderInputValidationRequest): ProviderInputValidationResult;
|
|
5293
5443
|
/** The Responses API honors `json_schema` (structured outputs) natively. */
|
|
5294
5444
|
nativeStructuredOutputSupport(): 'schema';
|
|
@@ -5342,6 +5492,12 @@ declare class OpenAIResponsesProvider implements Provider {
|
|
|
5342
5492
|
*/
|
|
5343
5493
|
declare class AnthropicProvider implements Provider {
|
|
5344
5494
|
readonly name = "anthropic";
|
|
5495
|
+
/** Report a clamped `effort`. Anthropic clamps to each model's supported
|
|
5496
|
+
* `output_config.effort` levels, and models that always think fall back to
|
|
5497
|
+
* adaptive `'low'` when asked to disable thinking. Only reported when the
|
|
5498
|
+
* effective level is what the request body actually carries; an explicit
|
|
5499
|
+
* `thinkingBudget` is documented to override `effort`, so it is not a clamp. */
|
|
5500
|
+
effortResolution(options: Pick<ChatOptions, 'model' | 'effort' | 'thinkingBudget' | 'includeThoughts' | 'providerOptions'>): EffortResolution | undefined;
|
|
5345
5501
|
inputCapabilities(model: string): {
|
|
5346
5502
|
image?: {
|
|
5347
5503
|
sources: readonly InputMediaSource['type'][];
|
|
@@ -5428,6 +5584,11 @@ declare class GeminiProvider implements Provider {
|
|
|
5428
5584
|
* keywords it doesn't support (`$ref`/`$defs`/`additionalProperties`/…), so a
|
|
5429
5585
|
* derived schema can lose constraints — lossy, not faithful. */
|
|
5430
5586
|
nativeStructuredOutputSupport(): 'lossy';
|
|
5587
|
+
/** Report a clamped `effort` (R7a). Gemini 3.x cannot disable thinking and
|
|
5588
|
+
* caps at `'high'`, so `'none'`, `'xhigh'` and `'max'` are not honored
|
|
5589
|
+
* verbatim there. Everything else — including 2.x disabled thinking — is
|
|
5590
|
+
* sent as asked, so there is nothing to report. */
|
|
5591
|
+
effortResolution(options: Pick<ChatOptions, 'model' | 'effort' | 'thinkingBudget' | 'includeThoughts' | 'providerOptions'>): EffortResolution | undefined;
|
|
5431
5592
|
private baseUrl;
|
|
5432
5593
|
private apiKeySource;
|
|
5433
5594
|
private callCounter;
|
|
@@ -6109,4 +6270,4 @@ declare class NoopSpanManager implements SpanManager {
|
|
|
6109
6270
|
*/
|
|
6110
6271
|
declare function createSpanManager(config?: TelemetryConfig): Promise<SpanManager>;
|
|
6111
6272
|
|
|
6112
|
-
export { AXL_EVENT_TYPES, AXL_EVENT_TYPES_V2, AXL_TOOL_LIFECYCLE_TYPES_V2, AZURE_PROFILE, type Agent, type AgentCallEndData, type AgentCallInfo, type AgentCallParams, type AgentCallStartData, type AgentConfig, AnthropicProvider, type AnyWorkflow, type ApiKeySource, type AskOptions, type AskScoped, type AuthHeader, type AwaitHumanData, type AwaitHumanOptions, type AwaitHumanResolvedData, type AxlConfig, AxlError, type AxlEvent, type AxlEventBase, AxlEventBus, type AxlEventOf, type AxlEventType, type AxlEventV2, type AxlEventV2Of, AxlRuntime, AxlStream, BEDROCK_PROFILE, BUILTIN_PROFILES, BudgetExceededError, type BudgetOptions, type BudgetResult, CONFIG_CANDIDATES, COST_BEARING_LEAF_TYPES, type CapabilityFlags, type ChatMessage, type ChatOptions, type CheckpointEventData, type CoalescedPartialObject, type CreateContextOptions, DEEPSEEK_PROFILE, type DecisionCleanupFailedEvent, type DelegateData, type DelegateOptions, type Effort, type EmbedResult, type EmbedUsage, type Embedder, type EvalExecuteWorkflow, type EvalHistoryEntry, type EventStreamOptions, EventStreamOverflowError, type ExecuteOptions, type ExecutionInfo, type ExecutionInfoV1, type ExecutionInfoV2, type ExecutionState, GROQ_PROFILE, GeminiProvider, GeminiTranscriptionProvider, type GuardrailBlockHandler, type GuardrailData, GuardrailError, type GuardrailResult, type GuardrailsConfig, type HandoffDescriptor, type HandoffRecord, type HandoffReturnData, type HandoffStartData, type HistoricalAxlEvent, type HistoricalExecutionInfo, type HumanDecision, InMemoryVectorStore, type InputContentPart, type InputGuardrail, type InputImagePart, type InputMediaSource, type InputModalitySupport, type InputTextPart, InvalidModelInputError, InvalidTranscriptionInputError, LLAMACPP_PROFILE, LMSTUDIO_PROFILE, type LegacyAxlEventV1, type LegacyExecutionInfoV1, MAX_INLINE_MODEL_INPUT_BYTES, MAX_INLINE_TRANSCRIPTION_BYTES, MISTRAL_PROFILE, type MapOptions, MaxTurnsError, McpManager, type McpServer, type McpServerConfig, type McpToolDefinition, type McpToolResult, type MemoryConfig, type MemoryEventData, MemoryManager, MemoryStore, type ModelInput, type ModelInputDescriptor, NoConsensus, NoopSpanManager, OLLAMA_PROFILE, OPENAI_PRICING, OPENAI_PROFILE, OPENROUTER_PROFILE, type ObservationStatus, type OpenAICompatibleOptions, OpenAICompatibleProvider, OpenAIEmbedder, OpenAIProvider, OpenAIResponsesProvider, OpenAITranscriptionProvider, OpenRouterTranscriptionProvider, type OutputGuardrail, type OutputValidator, type PendingDecision, type PerModel, type PricingSource, type PricingTable, type Provider, type ProviderAdapter, ProviderError, type ProviderInputValidationRequest, type ProviderInputValidationResult, type ProviderProfile, ProviderRegistry, type ProviderResponse, QuorumNotMet, REDACTED, REDACTION_RULES, type RaceOptions, type RateLimitConfig, RateLimiter, type ReasoningCapture, type ReasoningEmit, type ReasoningProfile, type ReasoningRoundTrip, type RecallOptions, type RecallResult, type RecordedAudioSource, RedisStore, type RememberOptions, type RememberResult, type ResolvedThinkingOptions, type Result, type RetryPolicy, SGLANG_PROFILE, SQLiteStore, type SchemaCheckData, type SchemaDiagnosticData, type SchemaPromptOption, Session, type SessionOptions, type SpanHandle, type SpanManager, type SpawnOptions, SqliteVectorStore, type StateStore, type StreamChunk, type StringDeltaData, type StringStreamEvent, type StringStreamFilter, type TelemetryConfig, ThinkTagScanner, TimeoutError, type Tool, type ToolApprovalData, type ToolArgumentIssue, type ToolCallCancellation, type ToolCallData, type ToolCallEndData, type ToolCallFailure, type ToolCallMessage, type ToolCallOutcome, type ToolCallRejectedData, type ToolCallRejectedEvent, type ToolCallStartData, type ToolCallStartDataV2, type ToolChoice, type ToolConfig, type ToolDeniedData, type ToolEventError, ToolFailure, type ToolFailureConstructor, type ToolFailureOptions, type ToolHooks, type ToolLifecycleEventV2, type ToolModelOutput, ToolModelOutputError, type Transcript, type TranscriptionCapabilities, TranscriptionOperationError, type TranscriptionProvider, TranscriptionProviderRegistry, type TranscriptionProviderRequest, type TranscriptionProviderResult, type TranscriptionRequest, UnsupportedEventSchemaVersionError, UnsupportedModelInputError, UnsupportedTranscriptionInputError, VLLM_PROFILE, 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, XAI_PROFILE, agent, createSpanManager, defineConfig, estimateOpenAICost, eventCostContribution, expandGlob, extractJson, extractThinkTags, findConfig, getEventSchemaVersion, getExecutionEventSchemaVersion, hasPositiveBillableWork, hasPositiveTokens, importModule, inputText, isCostBearingLeaf, isRetryableStatus, isRootLevel, isUnpricedLeaf, isUsableCost, needsTsxLoader, normalizeStoredExecution, openaiReasoningEmit, parsePartialJson, pickDefault, pickExport, priceFromTable, reasoningEffortEmit, reasoningObjectEmit, redactEvent, redactHistoricalEvent, registerConditions, resolveApiKey, resolvePerModel, resolveRuntime, resolveThinkingOptions, stringStreamFromEvents, tool, workflow, zodToJsonSchema };
|
|
6273
|
+
export { AXL_EVENT_TYPES, AXL_EVENT_TYPES_V2, AXL_TOOL_LIFECYCLE_TYPES_V2, AZURE_PROFILE, type Agent, type AgentCallEndData, type AgentCallInfo, type AgentCallParams, type AgentCallStartData, type AgentConfig, AnthropicProvider, type AnyWorkflow, type ApiKeySource, type AskOptions, type AskScoped, type AuthHeader, type AwaitHumanData, type AwaitHumanOptions, type AwaitHumanResolvedData, type AxlConfig, AxlError, type AxlEvent, type AxlEventBase, AxlEventBus, type AxlEventOf, type AxlEventType, type AxlEventV2, type AxlEventV2Of, AxlRuntime, AxlStream, BEDROCK_PROFILE, BUILTIN_PROFILES, BudgetExceededError, type BudgetOptions, type BudgetResult, CONFIG_CANDIDATES, COST_BEARING_LEAF_TYPES, type CapabilityFlags, type ChatMessage, type ChatOptions, type CheckpointEventData, type CoalescedPartialObject, type CreateContextOptions, DEEPSEEK_PROFILE, type DecisionCleanupFailedEvent, type DelegateData, type DelegateOptions, type Effort, type EffortResolution, type EmbedResult, type EmbedUsage, type Embedder, type EvalExecuteWorkflow, type EvalHistoryEntry, type EventStreamOptions, EventStreamOverflowError, type ExecuteOptions, type ExecutionInfo, type ExecutionInfoV1, type ExecutionInfoV2, type ExecutionState, GROQ_PROFILE, GeminiProvider, GeminiTranscriptionProvider, type GuardrailBlockHandler, type GuardrailData, GuardrailError, type GuardrailResult, type GuardrailsConfig, type HandoffDescriptor, type HandoffRecord, type HandoffReturnData, type HandoffStartData, type HistoricalAxlEvent, type HistoricalExecutionInfo, type HumanDecision, InMemoryVectorStore, type InputContentPart, type InputGuardrail, type InputImagePart, type InputMediaSource, type InputModalitySupport, type InputTextPart, InvalidModelInputError, InvalidTranscriptionInputError, LLAMACPP_PROFILE, LMSTUDIO_PROFILE, type LegacyAxlEventV1, type LegacyExecutionInfoV1, MAX_INLINE_MODEL_INPUT_BYTES, MAX_INLINE_TRANSCRIPTION_BYTES, MISTRAL_PROFILE, type MapOptions, MaxTurnsError, McpManager, type McpServer, type McpServerConfig, type McpToolDefinition, type McpToolResult, type MemoryConfig, type MemoryEventData, MemoryManager, MemoryStore, type ModelInput, type ModelInputDescriptor, NoConsensus, NoopSpanManager, OLLAMA_PROFILE, OPENAI_PRICING, OPENAI_PROFILE, OPENROUTER_PROFILE, type ObservationStatus, type OpenAICompatibleOptions, OpenAICompatibleProvider, OpenAIEmbedder, OpenAIProvider, OpenAIResponsesProvider, OpenAITranscriptionProvider, OpenRouterTranscriptionProvider, type OutputGuardrail, type OutputValidator, type PendingDecision, type PerModel, type PricingSource, type PricingTable, type Provider, type ProviderAdapter, type ProviderDiagnosticData, ProviderError, type ProviderInputValidationRequest, type ProviderInputValidationResult, type ProviderProfile, ProviderRegistry, type ProviderResponse, QuorumNotMet, REDACTED, REDACTION_RULES, type RaceOptions, type RateLimitConfig, RateLimiter, type ReasoningCapture, type ReasoningEmit, type ReasoningProfile, type ReasoningRoundTrip, type RecallOptions, type RecallResult, type RecordedAudioSource, RedisStore, type RememberOptions, type RememberResult, type ResolvedThinkingOptions, type Result, type RetryFeedbackHook, type RetryFeedbackInfo, type RetryFeedbackResult, type RetryPolicy, SGLANG_PROFILE, SQLiteStore, type SchemaCheckData, type SchemaDiagnosticData, type SchemaPromptOption, Session, type SessionOptions, type SpanHandle, type SpanManager, type SpawnOptions, SqliteVectorStore, type StateStore, type StreamChunk, type StringDeltaData, type StringStreamEvent, type StringStreamFilter, type TelemetryConfig, ThinkTagScanner, TimeoutError, type Tool, type ToolApprovalData, type ToolArgumentIssue, type ToolCallCancellation, type ToolCallData, type ToolCallEndData, type ToolCallFailure, type ToolCallMessage, type ToolCallOutcome, type ToolCallRejectedData, type ToolCallRejectedEvent, type ToolCallStartData, type ToolCallStartDataV2, type ToolChoice, type ToolConfig, type ToolDeniedData, type ToolEventError, ToolFailure, type ToolFailureConstructor, type ToolFailureOptions, type ToolHooks, type ToolLifecycleEventV2, type ToolModelOutput, ToolModelOutputError, type Transcript, type TranscriptionCapabilities, TranscriptionOperationError, type TranscriptionProvider, TranscriptionProviderRegistry, type TranscriptionProviderRequest, type TranscriptionProviderResult, type TranscriptionRequest, UnsupportedEventSchemaVersionError, UnsupportedModelInputError, UnsupportedTranscriptionInputError, VLLM_PROFILE, 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, XAI_PROFILE, agent, createSpanManager, defineConfig, estimateOpenAICost, eventCostContribution, expandGlob, extractJson, extractThinkTags, findConfig, getEventSchemaVersion, getExecutionEventSchemaVersion, hasPositiveBillableWork, hasPositiveTokens, importModule, inputText, isCostBearingLeaf, isRetryableStatus, isRootLevel, isUnpricedLeaf, isUsableCost, needsTsxLoader, normalizeStoredExecution, openaiReasoningEmit, parsePartialJson, pickDefault, pickExport, priceFromTable, reasoningEffortEmit, reasoningObjectEmit, redactEvent, redactHistoricalEvent, registerConditions, resolveApiKey, resolvePerModel, resolveRuntime, resolveThinkingOptions, stringStreamFromEvents, tool, workflow, zodToJsonSchema };
|
package/dist/index.d.ts
CHANGED
|
@@ -228,7 +228,46 @@ interface Provider {
|
|
|
228
228
|
* JSON instruction instead (e.g. Anthropic).
|
|
229
229
|
*/
|
|
230
230
|
nativeStructuredOutputSupport?(model: string): 'schema' | 'downgraded' | 'lossy' | 'unsupported';
|
|
231
|
+
/**
|
|
232
|
+
* How this provider resolved the unified `effort` knob for this request.
|
|
233
|
+
*
|
|
234
|
+
* Adapters clamp `effort` to what each model actually accepts (Gemini 3.x
|
|
235
|
+
* cannot disable thinking; OpenAI Chat Completions caps `'max'` at `'xhigh'`;
|
|
236
|
+
* Anthropic models that always think fall back to adaptive `'low'`). That
|
|
237
|
+
* clamp used to be invisible to run provenance. The runtime calls this once
|
|
238
|
+
* per ask, right after provider resolution, and emits a
|
|
239
|
+
* `provider_diagnostic { kind: 'effort_clamped' }` event plus a deduped
|
|
240
|
+
* `console.warn` when `clamped` is true — the adapter only *reports*, the
|
|
241
|
+
* runtime decides how to surface it (only the runtime can see
|
|
242
|
+
* `AxlConfig.diagnostics.silent`).
|
|
243
|
+
*
|
|
244
|
+
* The adapter applies its own `providerOptions.model` override before
|
|
245
|
+
* resolving, so the report describes the model actually sent.
|
|
246
|
+
*
|
|
247
|
+
* Optional, and optional to answer: return `undefined` when there is nothing
|
|
248
|
+
* to report (no effort requested, the model is unknown, or the effort is
|
|
249
|
+
* honored verbatim). An adapter MAY also report an honored resolution with
|
|
250
|
+
* `clamped: false`; the runtime stays silent for those.
|
|
251
|
+
*/
|
|
252
|
+
effortResolution?(options: Pick<ChatOptions, 'model' | 'effort' | 'thinkingBudget' | 'includeThoughts' | 'providerOptions'>): EffortResolution | undefined;
|
|
231
253
|
}
|
|
254
|
+
/**
|
|
255
|
+
* An adapter's report of how it resolved the unified `effort` for one request.
|
|
256
|
+
*
|
|
257
|
+
* `effective` is a provider-NATIVE level string rather than an `Effort` because
|
|
258
|
+
* not every effective value maps back onto the unified union (Gemini's
|
|
259
|
+
* `'minimal'`, OpenAI's `'minimal'`, Anthropic's adaptive `'low'`).
|
|
260
|
+
*/
|
|
261
|
+
type EffortResolution = {
|
|
262
|
+
/** The unified effort the caller asked for. */
|
|
263
|
+
requested: Effort;
|
|
264
|
+
/** The provider-native level actually sent (e.g. `'minimal'`, `'xhigh'`, `'low'`). */
|
|
265
|
+
effective: string;
|
|
266
|
+
/** True when `effective` is not what `requested` asked for. */
|
|
267
|
+
clamped: boolean;
|
|
268
|
+
/** Human-readable reason, surfaced verbatim on the diagnostic event. */
|
|
269
|
+
cause?: string;
|
|
270
|
+
};
|
|
232
271
|
/**
|
|
233
272
|
* Alias for Provider. Used for backward compatibility with index.ts exports.
|
|
234
273
|
*/
|
|
@@ -374,6 +413,10 @@ type AskOptions<T = unknown> = {
|
|
|
374
413
|
validate?: OutputValidator<T>;
|
|
375
414
|
/** Maximum retries for validate failures (default: 2). */
|
|
376
415
|
validateRetries?: number;
|
|
416
|
+
/** Rewrite the corrective feedback the model sees when the guardrail, schema, or validate
|
|
417
|
+
* gate rejects an attempt — or abort the retry with `{ retry: false }`. See
|
|
418
|
+
* `RetryFeedbackHook`. */
|
|
419
|
+
retryFeedback?: RetryFeedbackHook<T>;
|
|
377
420
|
/** Per-call metadata passed to dynamic model/system selector functions. */
|
|
378
421
|
metadata?: Record<string, unknown>;
|
|
379
422
|
/** Override temperature for this call. */
|
|
@@ -415,6 +458,9 @@ type DelegateOptions<T = unknown> = {
|
|
|
415
458
|
validate?: OutputValidator<T>;
|
|
416
459
|
/** Maximum retries for validate failures (default: 2). Passed through to the final `ctx.ask()` call. */
|
|
417
460
|
validateRetries?: number;
|
|
461
|
+
/** Custom gate-retry feedback. Passed through to the final `ctx.ask()` call on both the
|
|
462
|
+
* single-candidate and the routed path. See `RetryFeedbackHook`. */
|
|
463
|
+
retryFeedback?: RetryFeedbackHook<T>;
|
|
418
464
|
};
|
|
419
465
|
/** Race options */
|
|
420
466
|
type RaceOptions<T = unknown> = {
|
|
@@ -430,11 +476,11 @@ type ExecutionStatus = 'running' | 'completed' | 'failed' | 'waiting';
|
|
|
430
476
|
* derive `AxlEventType` from this tuple and use it to validate stream filters,
|
|
431
477
|
* redaction tables, and exhaustiveness assertions.
|
|
432
478
|
*/
|
|
433
|
-
declare const AXL_EVENT_TYPES: readonly ["workflow_start", "workflow_end", "transcription_start", "transcription_end", "ask_start", "ask_end", "agent_call_start", "agent_call_end", "token", "tool_call_start", "tool_call_end", "tool_call_rejected", "tool_approval", "delegate", "handoff_start", "handoff_return", "pipeline", "partial_object", "string_delta", "verify", "schema_diagnostic", "log", "memory_remember", "memory_recall", "memory_forget", "checkpoint_save", "checkpoint_replay", "await_human", "await_human_resolved", "guardrail", "schema_check", "validate", "done", "error"];
|
|
479
|
+
declare const AXL_EVENT_TYPES: readonly ["workflow_start", "workflow_end", "transcription_start", "transcription_end", "ask_start", "ask_end", "agent_call_start", "agent_call_end", "token", "tool_call_start", "tool_call_end", "tool_call_rejected", "tool_approval", "delegate", "handoff_start", "handoff_return", "pipeline", "partial_object", "string_delta", "verify", "schema_diagnostic", "provider_diagnostic", "log", "memory_remember", "memory_recall", "memory_forget", "checkpoint_save", "checkpoint_replay", "await_human", "await_human_resolved", "guardrail", "schema_check", "validate", "done", "error"];
|
|
434
480
|
/** Discriminator union derived from `AXL_EVENT_TYPES`. */
|
|
435
481
|
type AxlEventType = (typeof AXL_EVENT_TYPES)[number];
|
|
436
482
|
/** Backward-compatible name for the canonical v2 writer discriminator list. */
|
|
437
|
-
declare const AXL_EVENT_TYPES_V2: readonly ["workflow_start", "workflow_end", "transcription_start", "transcription_end", "ask_start", "ask_end", "agent_call_start", "agent_call_end", "token", "tool_call_start", "tool_call_end", "tool_call_rejected", "tool_approval", "delegate", "handoff_start", "handoff_return", "pipeline", "partial_object", "string_delta", "verify", "schema_diagnostic", "log", "memory_remember", "memory_recall", "memory_forget", "checkpoint_save", "checkpoint_replay", "await_human", "await_human_resolved", "guardrail", "schema_check", "validate", "done", "error"];
|
|
483
|
+
declare const AXL_EVENT_TYPES_V2: readonly ["workflow_start", "workflow_end", "transcription_start", "transcription_end", "ask_start", "ask_end", "agent_call_start", "agent_call_end", "token", "tool_call_start", "tool_call_end", "tool_call_rejected", "tool_approval", "delegate", "handoff_start", "handoff_return", "pipeline", "partial_object", "string_delta", "verify", "schema_diagnostic", "provider_diagnostic", "log", "memory_remember", "memory_recall", "memory_forget", "checkpoint_save", "checkpoint_replay", "await_human", "await_human_resolved", "guardrail", "schema_check", "validate", "done", "error"];
|
|
438
484
|
/** Accepted/rejected tool lifecycle discriminators in event schema v2. */
|
|
439
485
|
declare const AXL_TOOL_LIFECYCLE_TYPES_V2: readonly ["tool_call_start", "tool_call_end", "tool_call_rejected"];
|
|
440
486
|
/** Resolved model parameters sent to the provider for an LLM call. */
|
|
@@ -779,6 +825,34 @@ type SchemaDiagnosticData = {
|
|
|
779
825
|
provider?: string;
|
|
780
826
|
support: 'downgraded' | 'lossy' | 'unsupported';
|
|
781
827
|
};
|
|
828
|
+
/**
|
|
829
|
+
* Data for the `provider_diagnostic` event — a `kind`-discriminated payload
|
|
830
|
+
* (like `SchemaDiagnosticData`) reporting that the resolved provider could not
|
|
831
|
+
* honor a portable request knob verbatim.
|
|
832
|
+
*
|
|
833
|
+
* - `effort_clamped` — the adapter clamped the unified `effort` to what the
|
|
834
|
+
* model actually accepts (Gemini 3.x cannot disable thinking; OpenAI Chat
|
|
835
|
+
* Completions caps `'max'` at `'xhigh'`; Anthropic models that always think
|
|
836
|
+
* fall back to adaptive `'low'`). `requested` is the unified value the caller
|
|
837
|
+
* asked for; `effective` is the provider-native level actually sent, which is
|
|
838
|
+
* deliberately a free string because not every native level maps back onto
|
|
839
|
+
* `Effort`. One per ask, emitted before the first `agent_call_start` — join it
|
|
840
|
+
* to `agent_call_start` (which keeps reporting the *requested* effort) by
|
|
841
|
+
* `askId` for full provenance.
|
|
842
|
+
*
|
|
843
|
+
* The union is `kind`-discriminated so later provider cliffs can join without a
|
|
844
|
+
* new event type.
|
|
845
|
+
*/
|
|
846
|
+
type ProviderDiagnosticData = {
|
|
847
|
+
kind: 'effort_clamped';
|
|
848
|
+
/** Provider name (`provider.name`), when the adapter exposes one. */
|
|
849
|
+
provider?: string;
|
|
850
|
+
/** The model the request is actually sent to (after any `providerOptions.model`). */
|
|
851
|
+
model: string;
|
|
852
|
+
requested: Effort;
|
|
853
|
+
effective: string;
|
|
854
|
+
cause: string;
|
|
855
|
+
};
|
|
782
856
|
/** Data shape for legacy `guardrail` events. Replaced by `pipeline` in PR 2. */
|
|
783
857
|
type GuardrailData = {
|
|
784
858
|
guardrailType: 'input' | 'output';
|
|
@@ -1132,6 +1206,9 @@ type LegacyAxlEventPayloadV1 = (AxlEventBase & {
|
|
|
1132
1206
|
}) | (AxlEventBase & AskScoped & {
|
|
1133
1207
|
type: 'schema_diagnostic';
|
|
1134
1208
|
data: SchemaDiagnosticData;
|
|
1209
|
+
}) | (AxlEventBase & AskScoped & {
|
|
1210
|
+
type: 'provider_diagnostic';
|
|
1211
|
+
data: ProviderDiagnosticData;
|
|
1135
1212
|
}) | (AxlEventBase & Partial<AskScoped> & {
|
|
1136
1213
|
type: 'guardrail';
|
|
1137
1214
|
data?: GuardrailData;
|
|
@@ -1319,6 +1396,43 @@ type ValidateResult = {
|
|
|
1319
1396
|
type OutputValidator<T = unknown> = (output: T, ctx: {
|
|
1320
1397
|
metadata: Record<string, unknown>;
|
|
1321
1398
|
}) => ValidateResult | Promise<ValidateResult>;
|
|
1399
|
+
/** What a rejecting output gate tells a `retryFeedback` hook about the attempt it is
|
|
1400
|
+
* about to retry. One shape for all three gates — `stage` discriminates. */
|
|
1401
|
+
type RetryFeedbackInfo<T = unknown> = {
|
|
1402
|
+
/** Which gate rejected: JSON/Zod parse, post-schema `validate`, or output guardrail. */
|
|
1403
|
+
stage: 'schema' | 'validate' | 'guardrail';
|
|
1404
|
+
/** 1-based index of the attempt that was just rejected. */
|
|
1405
|
+
attempt: number;
|
|
1406
|
+
/** Total attempts this gate allows (`retries` + 1). */
|
|
1407
|
+
maxAttempts: number;
|
|
1408
|
+
/** Raw model output that was rejected. */
|
|
1409
|
+
output: string;
|
|
1410
|
+
/** The parsed, schema-valid object, typed by the ask's `schema`. Present only for
|
|
1411
|
+
* `stage: 'validate'` — the other gates run before or without a parsed value. */
|
|
1412
|
+
parsed?: T;
|
|
1413
|
+
/** The gate's own reason (Zod message, `ValidateResult.reason`, guardrail reason). */
|
|
1414
|
+
reason: string;
|
|
1415
|
+
/** The `ZodError` (or non-Zod parse error) for `schema`; the validator's thrown error for
|
|
1416
|
+
* `validate` when it threw. Absent for `guardrail` and for a clean `validate` rejection. */
|
|
1417
|
+
error?: unknown;
|
|
1418
|
+
/** The feedback text the runtime would send if the hook did not intervene. */
|
|
1419
|
+
defaultMessage: string;
|
|
1420
|
+
};
|
|
1421
|
+
/** A non-empty string replaces `defaultMessage` verbatim; `undefined` (or `''`) keeps it;
|
|
1422
|
+
* `{ retry: false }` stops retrying and makes the gate throw its typed terminal error. */
|
|
1423
|
+
type RetryFeedbackResult = string | undefined | {
|
|
1424
|
+
retry: false;
|
|
1425
|
+
};
|
|
1426
|
+
/** Rewrites (or aborts) the corrective turn the model sees after an output gate rejects an
|
|
1427
|
+
* attempt. Runs only while a retry is still permitted — never on the exhausting attempt —
|
|
1428
|
+
* and after the gate's own event is emitted. Exceptions propagate to the caller.
|
|
1429
|
+
*
|
|
1430
|
+
* `void` is accepted alongside `RetryFeedbackResult` so a hook used purely for logging or
|
|
1431
|
+
* inspection — a block body that never returns — type-checks; it keeps the default text.
|
|
1432
|
+
* Any other return value is a contract violation and throws a `TypeError`. */
|
|
1433
|
+
type RetryFeedbackHook<T = unknown> = (info: RetryFeedbackInfo<T>, ctx: {
|
|
1434
|
+
metadata: Record<string, unknown>;
|
|
1435
|
+
}) => RetryFeedbackResult | void | Promise<RetryFeedbackResult | void>;
|
|
1322
1436
|
/** Execution info */
|
|
1323
1437
|
type ExecutionInfoV1 = {
|
|
1324
1438
|
executionId: string;
|
|
@@ -3534,6 +3648,20 @@ declare class WorkflowContext<TInput = unknown> {
|
|
|
3534
3648
|
private observeToolInvocation;
|
|
3535
3649
|
ask<T = string>(agent: Agent, prompt: ModelInput, options?: AskOptions<T>): Promise<T>;
|
|
3536
3650
|
private executeAgentCall;
|
|
3651
|
+
/**
|
|
3652
|
+
* Resolve the corrective feedback text for one rejected attempt, giving an optional
|
|
3653
|
+
* caller-supplied `retryFeedback` hook the chance to replace it or to stop retrying.
|
|
3654
|
+
*
|
|
3655
|
+
* Called by all three output gates, only while a retry is still permitted (never on the
|
|
3656
|
+
* exhausting attempt) and only after the gate's own event has been emitted, so a hook that
|
|
3657
|
+
* throws or aborts can never erase the evidence that the gate rejected. A non-empty string
|
|
3658
|
+
* replaces `defaultMessage` verbatim; `undefined` / `''` keeps it; `{ retry: false }` asks
|
|
3659
|
+
* the gate to throw its typed terminal error. Hook exceptions propagate — a bug in caller
|
|
3660
|
+
* code is not a model failure and must not be retried into silence, and neither is a
|
|
3661
|
+
* return value outside the contract: an unrecognized shape throws instead of silently
|
|
3662
|
+
* degrading to the default text, which would hide the defect behind extra token spend.
|
|
3663
|
+
*/
|
|
3664
|
+
private resolveRetryFeedback;
|
|
3537
3665
|
/**
|
|
3538
3666
|
* Push the final assistant message into session history, preserving providerMetadata
|
|
3539
3667
|
* (e.g., Gemini thought signatures needed for multi-turn reasoning context) and
|
|
@@ -3557,6 +3685,20 @@ declare class WorkflowContext<TInput = unknown> {
|
|
|
3557
3685
|
* (expected behavior for any tool-using agent, not a surprise).
|
|
3558
3686
|
*/
|
|
3559
3687
|
private emitSchemaDiagnostics;
|
|
3688
|
+
/**
|
|
3689
|
+
* Emit a `provider_diagnostic` when the resolved provider reports that it
|
|
3690
|
+
* could not honor the unified `effort` verbatim (P3/R6/R7).
|
|
3691
|
+
*
|
|
3692
|
+
* The adapter only *resolves* — it returns the requested and effective levels
|
|
3693
|
+
* from the same pure resolver its request builder uses. The runtime decides
|
|
3694
|
+
* how to surface that, because only the runtime can see the event bus and
|
|
3695
|
+
* `AxlConfig.diagnostics.silent` (adapters receive `ProviderConfig` only).
|
|
3696
|
+
*
|
|
3697
|
+
* Called once per ask, so a tool loop with N provider round trips still emits
|
|
3698
|
+
* one event; the `console.warn` dedupes once per process per distinct clamp.
|
|
3699
|
+
* A throwing `effortResolution` is a provider bug and propagates.
|
|
3700
|
+
*/
|
|
3701
|
+
private emitProviderDiagnostics;
|
|
3560
3702
|
private buildToolDefs;
|
|
3561
3703
|
/**
|
|
3562
3704
|
* Summarize old messages to fit within context window.
|
|
@@ -5145,6 +5287,7 @@ declare const REDACTION_RULES: {
|
|
|
5145
5287
|
string_delta: RuleFor<"string_delta">;
|
|
5146
5288
|
verify: RuleFor<"verify">;
|
|
5147
5289
|
schema_diagnostic: RuleFor<"schema_diagnostic">;
|
|
5290
|
+
provider_diagnostic: RuleFor<"provider_diagnostic">;
|
|
5148
5291
|
log: RuleFor<"log">;
|
|
5149
5292
|
memory_remember: RuleFor<"memory_remember">;
|
|
5150
5293
|
memory_recall: RuleFor<"memory_recall">;
|
|
@@ -5272,6 +5415,9 @@ declare class OpenAIProvider extends OpenAICompatibleProvider {
|
|
|
5272
5415
|
dangerouslyAllowInsecureHttp?: boolean;
|
|
5273
5416
|
rateLimit?: RateLimitConfig;
|
|
5274
5417
|
});
|
|
5418
|
+
/** Report a clamped `effort` — Chat Completions caps `'max'` at `'xhigh'` and
|
|
5419
|
+
* rejects `'none'` before gpt-5.1 (clamped to `'minimal'`). */
|
|
5420
|
+
effortResolution(options: Pick<ChatOptions, 'model' | 'effort' | 'thinkingBudget' | 'includeThoughts' | 'providerOptions'>): EffortResolution | undefined;
|
|
5275
5421
|
protected computeCost(model: string, usage: ProviderResponse['usage'], _reportedCost: number | undefined, context?: DirectOpenAIPricingContext): number | undefined;
|
|
5276
5422
|
}
|
|
5277
5423
|
|
|
@@ -5289,6 +5435,10 @@ declare class OpenAIResponsesProvider implements Provider {
|
|
|
5289
5435
|
sources: readonly InputMediaSource['type'][];
|
|
5290
5436
|
};
|
|
5291
5437
|
};
|
|
5438
|
+
/** Report a clamped `effort`. Responses accepts the native `'max'` tier that
|
|
5439
|
+
* Chat Completions caps, but still clamps `'none'` before gpt-5.1, `'xhigh'`
|
|
5440
|
+
* below gpt-5.2, and everything to `'high'` on gpt-5-pro. */
|
|
5441
|
+
effortResolution(options: Pick<ChatOptions, 'model' | 'effort' | 'thinkingBudget' | 'includeThoughts' | 'providerOptions'>): EffortResolution | undefined;
|
|
5292
5442
|
validateInput(request: ProviderInputValidationRequest): ProviderInputValidationResult;
|
|
5293
5443
|
/** The Responses API honors `json_schema` (structured outputs) natively. */
|
|
5294
5444
|
nativeStructuredOutputSupport(): 'schema';
|
|
@@ -5342,6 +5492,12 @@ declare class OpenAIResponsesProvider implements Provider {
|
|
|
5342
5492
|
*/
|
|
5343
5493
|
declare class AnthropicProvider implements Provider {
|
|
5344
5494
|
readonly name = "anthropic";
|
|
5495
|
+
/** Report a clamped `effort`. Anthropic clamps to each model's supported
|
|
5496
|
+
* `output_config.effort` levels, and models that always think fall back to
|
|
5497
|
+
* adaptive `'low'` when asked to disable thinking. Only reported when the
|
|
5498
|
+
* effective level is what the request body actually carries; an explicit
|
|
5499
|
+
* `thinkingBudget` is documented to override `effort`, so it is not a clamp. */
|
|
5500
|
+
effortResolution(options: Pick<ChatOptions, 'model' | 'effort' | 'thinkingBudget' | 'includeThoughts' | 'providerOptions'>): EffortResolution | undefined;
|
|
5345
5501
|
inputCapabilities(model: string): {
|
|
5346
5502
|
image?: {
|
|
5347
5503
|
sources: readonly InputMediaSource['type'][];
|
|
@@ -5428,6 +5584,11 @@ declare class GeminiProvider implements Provider {
|
|
|
5428
5584
|
* keywords it doesn't support (`$ref`/`$defs`/`additionalProperties`/…), so a
|
|
5429
5585
|
* derived schema can lose constraints — lossy, not faithful. */
|
|
5430
5586
|
nativeStructuredOutputSupport(): 'lossy';
|
|
5587
|
+
/** Report a clamped `effort` (R7a). Gemini 3.x cannot disable thinking and
|
|
5588
|
+
* caps at `'high'`, so `'none'`, `'xhigh'` and `'max'` are not honored
|
|
5589
|
+
* verbatim there. Everything else — including 2.x disabled thinking — is
|
|
5590
|
+
* sent as asked, so there is nothing to report. */
|
|
5591
|
+
effortResolution(options: Pick<ChatOptions, 'model' | 'effort' | 'thinkingBudget' | 'includeThoughts' | 'providerOptions'>): EffortResolution | undefined;
|
|
5431
5592
|
private baseUrl;
|
|
5432
5593
|
private apiKeySource;
|
|
5433
5594
|
private callCounter;
|
|
@@ -6109,4 +6270,4 @@ declare class NoopSpanManager implements SpanManager {
|
|
|
6109
6270
|
*/
|
|
6110
6271
|
declare function createSpanManager(config?: TelemetryConfig): Promise<SpanManager>;
|
|
6111
6272
|
|
|
6112
|
-
export { AXL_EVENT_TYPES, AXL_EVENT_TYPES_V2, AXL_TOOL_LIFECYCLE_TYPES_V2, AZURE_PROFILE, type Agent, type AgentCallEndData, type AgentCallInfo, type AgentCallParams, type AgentCallStartData, type AgentConfig, AnthropicProvider, type AnyWorkflow, type ApiKeySource, type AskOptions, type AskScoped, type AuthHeader, type AwaitHumanData, type AwaitHumanOptions, type AwaitHumanResolvedData, type AxlConfig, AxlError, type AxlEvent, type AxlEventBase, AxlEventBus, type AxlEventOf, type AxlEventType, type AxlEventV2, type AxlEventV2Of, AxlRuntime, AxlStream, BEDROCK_PROFILE, BUILTIN_PROFILES, BudgetExceededError, type BudgetOptions, type BudgetResult, CONFIG_CANDIDATES, COST_BEARING_LEAF_TYPES, type CapabilityFlags, type ChatMessage, type ChatOptions, type CheckpointEventData, type CoalescedPartialObject, type CreateContextOptions, DEEPSEEK_PROFILE, type DecisionCleanupFailedEvent, type DelegateData, type DelegateOptions, type Effort, type EmbedResult, type EmbedUsage, type Embedder, type EvalExecuteWorkflow, type EvalHistoryEntry, type EventStreamOptions, EventStreamOverflowError, type ExecuteOptions, type ExecutionInfo, type ExecutionInfoV1, type ExecutionInfoV2, type ExecutionState, GROQ_PROFILE, GeminiProvider, GeminiTranscriptionProvider, type GuardrailBlockHandler, type GuardrailData, GuardrailError, type GuardrailResult, type GuardrailsConfig, type HandoffDescriptor, type HandoffRecord, type HandoffReturnData, type HandoffStartData, type HistoricalAxlEvent, type HistoricalExecutionInfo, type HumanDecision, InMemoryVectorStore, type InputContentPart, type InputGuardrail, type InputImagePart, type InputMediaSource, type InputModalitySupport, type InputTextPart, InvalidModelInputError, InvalidTranscriptionInputError, LLAMACPP_PROFILE, LMSTUDIO_PROFILE, type LegacyAxlEventV1, type LegacyExecutionInfoV1, MAX_INLINE_MODEL_INPUT_BYTES, MAX_INLINE_TRANSCRIPTION_BYTES, MISTRAL_PROFILE, type MapOptions, MaxTurnsError, McpManager, type McpServer, type McpServerConfig, type McpToolDefinition, type McpToolResult, type MemoryConfig, type MemoryEventData, MemoryManager, MemoryStore, type ModelInput, type ModelInputDescriptor, NoConsensus, NoopSpanManager, OLLAMA_PROFILE, OPENAI_PRICING, OPENAI_PROFILE, OPENROUTER_PROFILE, type ObservationStatus, type OpenAICompatibleOptions, OpenAICompatibleProvider, OpenAIEmbedder, OpenAIProvider, OpenAIResponsesProvider, OpenAITranscriptionProvider, OpenRouterTranscriptionProvider, type OutputGuardrail, type OutputValidator, type PendingDecision, type PerModel, type PricingSource, type PricingTable, type Provider, type ProviderAdapter, ProviderError, type ProviderInputValidationRequest, type ProviderInputValidationResult, type ProviderProfile, ProviderRegistry, type ProviderResponse, QuorumNotMet, REDACTED, REDACTION_RULES, type RaceOptions, type RateLimitConfig, RateLimiter, type ReasoningCapture, type ReasoningEmit, type ReasoningProfile, type ReasoningRoundTrip, type RecallOptions, type RecallResult, type RecordedAudioSource, RedisStore, type RememberOptions, type RememberResult, type ResolvedThinkingOptions, type Result, type RetryPolicy, SGLANG_PROFILE, SQLiteStore, type SchemaCheckData, type SchemaDiagnosticData, type SchemaPromptOption, Session, type SessionOptions, type SpanHandle, type SpanManager, type SpawnOptions, SqliteVectorStore, type StateStore, type StreamChunk, type StringDeltaData, type StringStreamEvent, type StringStreamFilter, type TelemetryConfig, ThinkTagScanner, TimeoutError, type Tool, type ToolApprovalData, type ToolArgumentIssue, type ToolCallCancellation, type ToolCallData, type ToolCallEndData, type ToolCallFailure, type ToolCallMessage, type ToolCallOutcome, type ToolCallRejectedData, type ToolCallRejectedEvent, type ToolCallStartData, type ToolCallStartDataV2, type ToolChoice, type ToolConfig, type ToolDeniedData, type ToolEventError, ToolFailure, type ToolFailureConstructor, type ToolFailureOptions, type ToolHooks, type ToolLifecycleEventV2, type ToolModelOutput, ToolModelOutputError, type Transcript, type TranscriptionCapabilities, TranscriptionOperationError, type TranscriptionProvider, TranscriptionProviderRegistry, type TranscriptionProviderRequest, type TranscriptionProviderResult, type TranscriptionRequest, UnsupportedEventSchemaVersionError, UnsupportedModelInputError, UnsupportedTranscriptionInputError, VLLM_PROFILE, 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, XAI_PROFILE, agent, createSpanManager, defineConfig, estimateOpenAICost, eventCostContribution, expandGlob, extractJson, extractThinkTags, findConfig, getEventSchemaVersion, getExecutionEventSchemaVersion, hasPositiveBillableWork, hasPositiveTokens, importModule, inputText, isCostBearingLeaf, isRetryableStatus, isRootLevel, isUnpricedLeaf, isUsableCost, needsTsxLoader, normalizeStoredExecution, openaiReasoningEmit, parsePartialJson, pickDefault, pickExport, priceFromTable, reasoningEffortEmit, reasoningObjectEmit, redactEvent, redactHistoricalEvent, registerConditions, resolveApiKey, resolvePerModel, resolveRuntime, resolveThinkingOptions, stringStreamFromEvents, tool, workflow, zodToJsonSchema };
|
|
6273
|
+
export { AXL_EVENT_TYPES, AXL_EVENT_TYPES_V2, AXL_TOOL_LIFECYCLE_TYPES_V2, AZURE_PROFILE, type Agent, type AgentCallEndData, type AgentCallInfo, type AgentCallParams, type AgentCallStartData, type AgentConfig, AnthropicProvider, type AnyWorkflow, type ApiKeySource, type AskOptions, type AskScoped, type AuthHeader, type AwaitHumanData, type AwaitHumanOptions, type AwaitHumanResolvedData, type AxlConfig, AxlError, type AxlEvent, type AxlEventBase, AxlEventBus, type AxlEventOf, type AxlEventType, type AxlEventV2, type AxlEventV2Of, AxlRuntime, AxlStream, BEDROCK_PROFILE, BUILTIN_PROFILES, BudgetExceededError, type BudgetOptions, type BudgetResult, CONFIG_CANDIDATES, COST_BEARING_LEAF_TYPES, type CapabilityFlags, type ChatMessage, type ChatOptions, type CheckpointEventData, type CoalescedPartialObject, type CreateContextOptions, DEEPSEEK_PROFILE, type DecisionCleanupFailedEvent, type DelegateData, type DelegateOptions, type Effort, type EffortResolution, type EmbedResult, type EmbedUsage, type Embedder, type EvalExecuteWorkflow, type EvalHistoryEntry, type EventStreamOptions, EventStreamOverflowError, type ExecuteOptions, type ExecutionInfo, type ExecutionInfoV1, type ExecutionInfoV2, type ExecutionState, GROQ_PROFILE, GeminiProvider, GeminiTranscriptionProvider, type GuardrailBlockHandler, type GuardrailData, GuardrailError, type GuardrailResult, type GuardrailsConfig, type HandoffDescriptor, type HandoffRecord, type HandoffReturnData, type HandoffStartData, type HistoricalAxlEvent, type HistoricalExecutionInfo, type HumanDecision, InMemoryVectorStore, type InputContentPart, type InputGuardrail, type InputImagePart, type InputMediaSource, type InputModalitySupport, type InputTextPart, InvalidModelInputError, InvalidTranscriptionInputError, LLAMACPP_PROFILE, LMSTUDIO_PROFILE, type LegacyAxlEventV1, type LegacyExecutionInfoV1, MAX_INLINE_MODEL_INPUT_BYTES, MAX_INLINE_TRANSCRIPTION_BYTES, MISTRAL_PROFILE, type MapOptions, MaxTurnsError, McpManager, type McpServer, type McpServerConfig, type McpToolDefinition, type McpToolResult, type MemoryConfig, type MemoryEventData, MemoryManager, MemoryStore, type ModelInput, type ModelInputDescriptor, NoConsensus, NoopSpanManager, OLLAMA_PROFILE, OPENAI_PRICING, OPENAI_PROFILE, OPENROUTER_PROFILE, type ObservationStatus, type OpenAICompatibleOptions, OpenAICompatibleProvider, OpenAIEmbedder, OpenAIProvider, OpenAIResponsesProvider, OpenAITranscriptionProvider, OpenRouterTranscriptionProvider, type OutputGuardrail, type OutputValidator, type PendingDecision, type PerModel, type PricingSource, type PricingTable, type Provider, type ProviderAdapter, type ProviderDiagnosticData, ProviderError, type ProviderInputValidationRequest, type ProviderInputValidationResult, type ProviderProfile, ProviderRegistry, type ProviderResponse, QuorumNotMet, REDACTED, REDACTION_RULES, type RaceOptions, type RateLimitConfig, RateLimiter, type ReasoningCapture, type ReasoningEmit, type ReasoningProfile, type ReasoningRoundTrip, type RecallOptions, type RecallResult, type RecordedAudioSource, RedisStore, type RememberOptions, type RememberResult, type ResolvedThinkingOptions, type Result, type RetryFeedbackHook, type RetryFeedbackInfo, type RetryFeedbackResult, type RetryPolicy, SGLANG_PROFILE, SQLiteStore, type SchemaCheckData, type SchemaDiagnosticData, type SchemaPromptOption, Session, type SessionOptions, type SpanHandle, type SpanManager, type SpawnOptions, SqliteVectorStore, type StateStore, type StreamChunk, type StringDeltaData, type StringStreamEvent, type StringStreamFilter, type TelemetryConfig, ThinkTagScanner, TimeoutError, type Tool, type ToolApprovalData, type ToolArgumentIssue, type ToolCallCancellation, type ToolCallData, type ToolCallEndData, type ToolCallFailure, type ToolCallMessage, type ToolCallOutcome, type ToolCallRejectedData, type ToolCallRejectedEvent, type ToolCallStartData, type ToolCallStartDataV2, type ToolChoice, type ToolConfig, type ToolDeniedData, type ToolEventError, ToolFailure, type ToolFailureConstructor, type ToolFailureOptions, type ToolHooks, type ToolLifecycleEventV2, type ToolModelOutput, ToolModelOutputError, type Transcript, type TranscriptionCapabilities, TranscriptionOperationError, type TranscriptionProvider, TranscriptionProviderRegistry, type TranscriptionProviderRequest, type TranscriptionProviderResult, type TranscriptionRequest, UnsupportedEventSchemaVersionError, UnsupportedModelInputError, UnsupportedTranscriptionInputError, VLLM_PROFILE, 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, XAI_PROFILE, agent, createSpanManager, defineConfig, estimateOpenAICost, eventCostContribution, expandGlob, extractJson, extractThinkTags, findConfig, getEventSchemaVersion, getExecutionEventSchemaVersion, hasPositiveBillableWork, hasPositiveTokens, importModule, inputText, isCostBearingLeaf, isRetryableStatus, isRootLevel, isUnpricedLeaf, isUsableCost, needsTsxLoader, normalizeStoredExecution, openaiReasoningEmit, parsePartialJson, pickDefault, pickExport, priceFromTable, reasoningEffortEmit, reasoningObjectEmit, redactEvent, redactHistoricalEvent, registerConditions, resolveApiKey, resolvePerModel, resolveRuntime, resolveThinkingOptions, stringStreamFromEvents, tool, workflow, zodToJsonSchema };
|