@ax-llm/ax 21.0.10 → 21.0.12

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/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { Histogram, Counter, Gauge, Meter, Context, Tracer, Span } from '@opentelemetry/api';
1
+ import { Histogram, Counter, Gauge, Context, Tracer, Span, Meter } from '@opentelemetry/api';
2
2
 
3
3
  type AxMemoryMessageValue = Omit<AxChatRequest['chatPrompt'][number], 'role'> | Omit<AxChatResponseResult, 'index'>;
4
4
  type AxMemoryData = {
@@ -1224,9 +1224,27 @@ declare class AxProgram<IN = any, OUT = any> implements AxUsable, AxTunable<IN,
1224
1224
  protected applyLocalOptimizedComponents(updates: Readonly<Record<string, string>>): void;
1225
1225
  }
1226
1226
 
1227
- type AxGenerateResult<OUT> = OUT & {
1228
- thought?: string;
1229
- };
1227
+ type AxFieldProcessorProcess = (value: AxFieldValue, context?: Readonly<{
1228
+ values?: AxGenOut;
1229
+ sessionId?: string;
1230
+ done?: boolean;
1231
+ }>) => unknown | Promise<unknown>;
1232
+ type AxStreamingFieldProcessorProcess = (value: string, context?: Readonly<{
1233
+ values?: AxGenOut;
1234
+ sessionId?: string;
1235
+ done?: boolean;
1236
+ }>) => unknown | Promise<unknown>;
1237
+ interface AxFieldProcessor {
1238
+ field: Readonly<AxField>;
1239
+ /**
1240
+ * Process the field value and return a new value (or undefined if no update is needed).
1241
+ * The returned value may be merged back into memory.
1242
+ * @param value - The current field value.
1243
+ * @param context - Additional context (e.g. memory and session id).
1244
+ */
1245
+ process: AxFieldProcessorProcess | AxStreamingFieldProcessorProcess;
1246
+ }
1247
+
1230
1248
  interface AxResponseHandlerArgs<T> {
1231
1249
  ai: Readonly<AxAIService>;
1232
1250
  model?: string;
@@ -1243,6 +1261,10 @@ interface AxResponseHandlerArgs<T> {
1243
1261
  debugPromptMetrics?: Readonly<AxPromptMetrics>;
1244
1262
  onFunctionCall?: (call: Readonly<AxFunctionCallTrace>) => void | Promise<void>;
1245
1263
  }
1264
+
1265
+ type AxGenerateResult<OUT> = OUT & {
1266
+ thought?: string;
1267
+ };
1246
1268
  interface AxStreamingEvent<T> {
1247
1269
  event: 'delta' | 'done' | 'error';
1248
1270
  data: {
@@ -4392,6 +4414,14 @@ type AxAgentContextEvent = {
4392
4414
  resolvedByTurn: number;
4393
4415
  source: 'deterministic' | 'model';
4394
4416
  summaryChars: number;
4417
+ } | {
4418
+ kind: 'action_compacted';
4419
+ stage: AxAgentContextStage;
4420
+ turn: number;
4421
+ mode: 'distill' | 'compact';
4422
+ reason: 'structured_output' | 'superseded' | 'pressure' | 'proactive' | 'lean';
4423
+ originalChars: number;
4424
+ renderedChars: number;
4395
4425
  };
4396
4426
  type AxAgentOnContextEvent = (event: Readonly<AxAgentContextEvent>) => void | Promise<void>;
4397
4427
 
@@ -4405,7 +4435,8 @@ type AxAgentOnContextEvent = (event: Readonly<AxAgentContextEvent>) => void | Pr
4405
4435
 
4406
4436
  type ActionLogTag = 'error' | 'dead-end' | 'foundational' | 'pivot' | 'superseded';
4407
4437
  type ActionLogStepKind = 'explore' | 'transform' | 'query' | 'finalize' | 'error';
4408
- type ActionReplayMode = 'full' | 'omit';
4438
+ type ActionReplayMode = 'full' | 'distill' | 'compact' | 'omit';
4439
+ type ActionLogHygieneMode = 'none' | 'pressure' | 'proactive' | 'aggressive';
4409
4440
  type ActionLogFunctionCall = {
4410
4441
  qualifiedName: string;
4411
4442
  name?: string;
@@ -5705,6 +5736,10 @@ type AxResolvedContextPolicy = {
5705
5736
  summarizerOptions?: Omit<AxProgramForwardOptions<string>, 'functions'>;
5706
5737
  actionReplay: 'full' | 'adaptive' | 'minimal' | 'checkpointed';
5707
5738
  recentFullActions: number;
5739
+ contextHygiene: {
5740
+ defaultMode: ActionLogHygieneMode;
5741
+ pressureMode?: ActionLogHygieneMode;
5742
+ };
5708
5743
  errorPruning: boolean;
5709
5744
  hindsightEvaluation: boolean;
5710
5745
  pruneRank: number;
@@ -9620,27 +9655,6 @@ declare class AxTestPrompt<IN extends AxGenIn = AxGenIn, OUT extends AxGenOut =
9620
9655
  run(metricFn: AxMetricFn): Promise<void>;
9621
9656
  }
9622
9657
 
9623
- type AxFieldProcessorProcess = (value: AxFieldValue, context?: Readonly<{
9624
- values?: AxGenOut;
9625
- sessionId?: string;
9626
- done?: boolean;
9627
- }>) => unknown | Promise<unknown>;
9628
- type AxStreamingFieldProcessorProcess = (value: string, context?: Readonly<{
9629
- values?: AxGenOut;
9630
- sessionId?: string;
9631
- done?: boolean;
9632
- }>) => unknown | Promise<unknown>;
9633
- interface AxFieldProcessor {
9634
- field: Readonly<AxField>;
9635
- /**
9636
- * Process the field value and return a new value (or undefined if no update is needed).
9637
- * The returned value may be merged back into memory.
9638
- * @param value - The current field value.
9639
- * @param context - Additional context (e.g. memory and session id).
9640
- */
9641
- process: AxFieldProcessorProcess | AxStreamingFieldProcessorProcess;
9642
- }
9643
-
9644
9658
  type AxFunctionResultFormatter = (result: unknown) => string;
9645
9659
  declare const axGlobals: {
9646
9660
  signatureStrict: boolean;
package/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Histogram, Counter, Gauge, Meter, Context, Tracer, Span } from '@opentelemetry/api';
1
+ import { Histogram, Counter, Gauge, Context, Tracer, Span, Meter } from '@opentelemetry/api';
2
2
 
3
3
  type AxMemoryMessageValue = Omit<AxChatRequest['chatPrompt'][number], 'role'> | Omit<AxChatResponseResult, 'index'>;
4
4
  type AxMemoryData = {
@@ -1224,9 +1224,27 @@ declare class AxProgram<IN = any, OUT = any> implements AxUsable, AxTunable<IN,
1224
1224
  protected applyLocalOptimizedComponents(updates: Readonly<Record<string, string>>): void;
1225
1225
  }
1226
1226
 
1227
- type AxGenerateResult<OUT> = OUT & {
1228
- thought?: string;
1229
- };
1227
+ type AxFieldProcessorProcess = (value: AxFieldValue, context?: Readonly<{
1228
+ values?: AxGenOut;
1229
+ sessionId?: string;
1230
+ done?: boolean;
1231
+ }>) => unknown | Promise<unknown>;
1232
+ type AxStreamingFieldProcessorProcess = (value: string, context?: Readonly<{
1233
+ values?: AxGenOut;
1234
+ sessionId?: string;
1235
+ done?: boolean;
1236
+ }>) => unknown | Promise<unknown>;
1237
+ interface AxFieldProcessor {
1238
+ field: Readonly<AxField>;
1239
+ /**
1240
+ * Process the field value and return a new value (or undefined if no update is needed).
1241
+ * The returned value may be merged back into memory.
1242
+ * @param value - The current field value.
1243
+ * @param context - Additional context (e.g. memory and session id).
1244
+ */
1245
+ process: AxFieldProcessorProcess | AxStreamingFieldProcessorProcess;
1246
+ }
1247
+
1230
1248
  interface AxResponseHandlerArgs<T> {
1231
1249
  ai: Readonly<AxAIService>;
1232
1250
  model?: string;
@@ -1243,6 +1261,10 @@ interface AxResponseHandlerArgs<T> {
1243
1261
  debugPromptMetrics?: Readonly<AxPromptMetrics>;
1244
1262
  onFunctionCall?: (call: Readonly<AxFunctionCallTrace>) => void | Promise<void>;
1245
1263
  }
1264
+
1265
+ type AxGenerateResult<OUT> = OUT & {
1266
+ thought?: string;
1267
+ };
1246
1268
  interface AxStreamingEvent<T> {
1247
1269
  event: 'delta' | 'done' | 'error';
1248
1270
  data: {
@@ -4392,6 +4414,14 @@ type AxAgentContextEvent = {
4392
4414
  resolvedByTurn: number;
4393
4415
  source: 'deterministic' | 'model';
4394
4416
  summaryChars: number;
4417
+ } | {
4418
+ kind: 'action_compacted';
4419
+ stage: AxAgentContextStage;
4420
+ turn: number;
4421
+ mode: 'distill' | 'compact';
4422
+ reason: 'structured_output' | 'superseded' | 'pressure' | 'proactive' | 'lean';
4423
+ originalChars: number;
4424
+ renderedChars: number;
4395
4425
  };
4396
4426
  type AxAgentOnContextEvent = (event: Readonly<AxAgentContextEvent>) => void | Promise<void>;
4397
4427
 
@@ -4405,7 +4435,8 @@ type AxAgentOnContextEvent = (event: Readonly<AxAgentContextEvent>) => void | Pr
4405
4435
 
4406
4436
  type ActionLogTag = 'error' | 'dead-end' | 'foundational' | 'pivot' | 'superseded';
4407
4437
  type ActionLogStepKind = 'explore' | 'transform' | 'query' | 'finalize' | 'error';
4408
- type ActionReplayMode = 'full' | 'omit';
4438
+ type ActionReplayMode = 'full' | 'distill' | 'compact' | 'omit';
4439
+ type ActionLogHygieneMode = 'none' | 'pressure' | 'proactive' | 'aggressive';
4409
4440
  type ActionLogFunctionCall = {
4410
4441
  qualifiedName: string;
4411
4442
  name?: string;
@@ -5705,6 +5736,10 @@ type AxResolvedContextPolicy = {
5705
5736
  summarizerOptions?: Omit<AxProgramForwardOptions<string>, 'functions'>;
5706
5737
  actionReplay: 'full' | 'adaptive' | 'minimal' | 'checkpointed';
5707
5738
  recentFullActions: number;
5739
+ contextHygiene: {
5740
+ defaultMode: ActionLogHygieneMode;
5741
+ pressureMode?: ActionLogHygieneMode;
5742
+ };
5708
5743
  errorPruning: boolean;
5709
5744
  hindsightEvaluation: boolean;
5710
5745
  pruneRank: number;
@@ -9620,27 +9655,6 @@ declare class AxTestPrompt<IN extends AxGenIn = AxGenIn, OUT extends AxGenOut =
9620
9655
  run(metricFn: AxMetricFn): Promise<void>;
9621
9656
  }
9622
9657
 
9623
- type AxFieldProcessorProcess = (value: AxFieldValue, context?: Readonly<{
9624
- values?: AxGenOut;
9625
- sessionId?: string;
9626
- done?: boolean;
9627
- }>) => unknown | Promise<unknown>;
9628
- type AxStreamingFieldProcessorProcess = (value: string, context?: Readonly<{
9629
- values?: AxGenOut;
9630
- sessionId?: string;
9631
- done?: boolean;
9632
- }>) => unknown | Promise<unknown>;
9633
- interface AxFieldProcessor {
9634
- field: Readonly<AxField>;
9635
- /**
9636
- * Process the field value and return a new value (or undefined if no update is needed).
9637
- * The returned value may be merged back into memory.
9638
- * @param value - The current field value.
9639
- * @param context - Additional context (e.g. memory and session id).
9640
- */
9641
- process: AxFieldProcessorProcess | AxStreamingFieldProcessorProcess;
9642
- }
9643
-
9644
9658
  type AxFunctionResultFormatter = (result: unknown) => string;
9645
9659
  declare const axGlobals: {
9646
9660
  signatureStrict: boolean;