@ax-llm/ax 18.0.6 → 18.0.8
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.cjs +130 -121
- package/index.cjs.map +1 -1
- package/index.global.js +128 -119
- package/index.global.js.map +1 -1
- package/index.js +133 -124
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/skills/ax-agent.md +56 -4
- package/skills/ax-llm.md +1 -1
package/package.json
CHANGED
package/skills/ax-agent.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: ax-agent
|
|
3
3
|
description: This skill helps with building AxAgent-based agents using @ax-llm/ax. Use when the user asks about agent(), AxAgent, child agents, tool functions, RLM mode, stopping agents, or composing multi-agent hierarchies.
|
|
4
|
-
version: "18.0.
|
|
4
|
+
version: "18.0.8"
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# AxAgent Guide (@ax-llm/ax)
|
|
@@ -441,6 +441,31 @@ Available permissions:
|
|
|
441
441
|
|
|
442
442
|
> **Warning**: Granting `WORKERS` allows code to spawn sub-workers that get fresh, unlocked globals. A child worker has full access to `fetch`, `indexedDB`, etc. regardless of the parent's permissions. Only grant `WORKERS` when you trust the executed code.
|
|
443
443
|
|
|
444
|
+
### Consecutive Execution Error Cutoff
|
|
445
|
+
|
|
446
|
+
`AxJSRuntime` can enforce a cutoff for consecutive execution failures:
|
|
447
|
+
|
|
448
|
+
```typescript
|
|
449
|
+
import { AxJSRuntime } from '@ax-llm/ax';
|
|
450
|
+
|
|
451
|
+
const runtime = new AxJSRuntime({
|
|
452
|
+
consecutiveErrorCutoff: 3,
|
|
453
|
+
});
|
|
454
|
+
```
|
|
455
|
+
|
|
456
|
+
Behavior:
|
|
457
|
+
|
|
458
|
+
- The runtime tracks consecutive execution failures.
|
|
459
|
+
- The counter resets on successful execution.
|
|
460
|
+
- When failures hit the configured cutoff, the runtime throws `AxRuntimeExecutionError` and exits the session.
|
|
461
|
+
- Preflight guardrail errors are not counted (for example blocked `"use strict"` and reserved-name reassignment checks).
|
|
462
|
+
|
|
463
|
+
You can manually reset the runtime-level counter:
|
|
464
|
+
|
|
465
|
+
```typescript
|
|
466
|
+
runtime.resetConsecutiveErrorCounter();
|
|
467
|
+
```
|
|
468
|
+
|
|
444
469
|
### Structured Context Fields
|
|
445
470
|
|
|
446
471
|
Context fields aren't limited to plain strings. You can pass structured data — objects and arrays with typed sub-fields:
|
|
@@ -721,18 +746,24 @@ but `globalThis.state = ...` (or mutating a shared `state` object) is the recomm
|
|
|
721
746
|
Errors thrown by code running inside `session.execute(code)` cross the worker boundary and can be caught on the host. Always `await` `session.execute()` inside a try/catch:
|
|
722
747
|
|
|
723
748
|
```typescript
|
|
749
|
+
import { AxRuntimeExecutionError } from '@ax-llm/ax';
|
|
750
|
+
|
|
724
751
|
try {
|
|
725
752
|
const result = await session.execute(code);
|
|
726
753
|
// use result
|
|
727
754
|
} catch (e) {
|
|
728
|
-
|
|
729
|
-
|
|
755
|
+
if (e instanceof AxRuntimeExecutionError) {
|
|
756
|
+
// Consecutive execution failures reached the cutoff; session was exited.
|
|
757
|
+
} else if (e instanceof Error && e.name === 'WaitForUserActionError') {
|
|
730
758
|
// handle domain-specific error
|
|
731
759
|
}
|
|
732
|
-
console.error(e.message);
|
|
760
|
+
console.error(e instanceof Error ? e.message : String(e));
|
|
733
761
|
}
|
|
734
762
|
```
|
|
735
763
|
|
|
764
|
+
- **`AxRuntimeExecutionError`** is thrown when the runtime reaches the configured consecutive execution failure cutoff.
|
|
765
|
+
- The cutoff counter **resets on successful execution**.
|
|
766
|
+
- **Preflight guardrail errors are not counted** toward the cutoff.
|
|
736
767
|
- **`e.name`** and **`e.message`** are preserved, so you can branch on `e.name === 'WaitForUserActionError'` (or other custom error names) and use `e.message` for user-facing context.
|
|
737
768
|
- **`e.cause`** is preserved when structured-cloneable, including recursive cause chains (with a depth limit).
|
|
738
769
|
- **`e.data`** (optional) is preserved when the thrown error has a `data` property set to a structured-cloneable value (object, array, string, number, etc.). Use it for custom payloads (e.g. `(e as Error & { data?: unknown }).data`). Non-cloneable values are omitted.
|
|
@@ -779,6 +810,27 @@ RLM mode does not support true streaming. When using `streamingForward`, RLM run
|
|
|
779
810
|
|
|
780
811
|
## API Reference
|
|
781
812
|
|
|
813
|
+
### `AxJSRuntime`
|
|
814
|
+
|
|
815
|
+
```typescript
|
|
816
|
+
new AxJSRuntime({
|
|
817
|
+
timeout?: number;
|
|
818
|
+
permissions?: readonly AxJSRuntimePermission[];
|
|
819
|
+
outputMode?: 'return' | 'stdout';
|
|
820
|
+
captureConsole?: boolean;
|
|
821
|
+
allowUnsafeNodeHostAccess?: boolean;
|
|
822
|
+
nodeWorkerPoolSize?: number;
|
|
823
|
+
debugNodeWorkerPool?: boolean;
|
|
824
|
+
consecutiveErrorCutoff?: number; // Cutoff for consecutive execution failures
|
|
825
|
+
});
|
|
826
|
+
|
|
827
|
+
runtime.resetConsecutiveErrorCounter(): void; // Resets runtime-level consecutive failure counter
|
|
828
|
+
```
|
|
829
|
+
|
|
830
|
+
### `AxRuntimeExecutionError`
|
|
831
|
+
|
|
832
|
+
Thrown by `AxJSRuntime` when consecutive execution failures reach `consecutiveErrorCutoff`. When this happens, the active runtime session is exited. Preflight guardrail errors are not counted toward this cutoff.
|
|
833
|
+
|
|
782
834
|
### `AxRLMConfig`
|
|
783
835
|
|
|
784
836
|
```typescript
|
package/skills/ax-llm.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: ax
|
|
3
3
|
description: This skill helps with using the @ax-llm/ax TypeScript library for building LLM applications. Use when the user asks about ax(), ai(), f(), s(), agent(), flow(), AxGen, AxAgent, AxFlow, signatures, streaming, or mentions @ax-llm/ax.
|
|
4
|
-
version: "18.0.
|
|
4
|
+
version: "18.0.8"
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# Ax Library (@ax-llm/ax) Usage Guide
|