@ax-llm/ax 25.4.0 → 25.4.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/README.md +29 -0
- package/cli/index.mjs +70 -317
- package/index.cjs +1 -1
- package/index.cjs.map +1 -1
- package/index.d.cts +2 -1
- package/index.d.ts +2 -1
- package/index.global.js +1 -1
- package/index.global.js.map +1 -1
- package/index.js +1 -1
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/scripts/postinstall.mjs +16 -202
- package/scripts/skill-bundles.mjs +70 -0
- package/scripts/skill-config.mjs +59 -0
- package/scripts/skill-install.mjs +123 -0
- package/skills/ax-agent-context.md +1 -1
- package/skills/ax-agent-memory-skills.md +1 -1
- package/skills/ax-agent-observability.md +1 -1
- package/skills/ax-agent-optimize.md +1 -1
- package/skills/ax-agent-rlm.md +1 -1
- package/skills/ax-agent.md +1 -1
- package/skills/ax-ai.md +1 -1
- package/skills/ax-audio.md +1 -1
- package/skills/ax-flow.md +1 -1
- package/skills/ax-gen.md +1 -1
- package/skills/ax-gepa.md +1 -1
- package/skills/ax-llm.md +46 -353
- package/skills/ax-mcp.md +1 -1
- package/skills/ax-playbook.md +1 -1
- package/skills/ax-refine.md +1 -1
- package/skills/ax-signature.md +1 -1
- package/skills/ax-typesafe.md +5 -5
- package/skills/references/quickstart.md +354 -0
package/skills/ax-llm.md
CHANGED
|
@@ -1,361 +1,54 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: ax-llm
|
|
3
|
-
description:
|
|
4
|
-
version: "25.4.
|
|
3
|
+
description: Build or debug TypeScript LLM applications with @ax-llm/ax. Use for Ax providers, structured generation, signatures, agents and tools, memory, MCP, workflows, audio, and optimization.
|
|
4
|
+
version: "25.4.2"
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
# Ax
|
|
7
|
+
# Ax For TypeScript
|
|
8
|
+
|
|
9
|
+
Use this entry point for `@ax-llm/ax`. Read the guides relevant to the task before
|
|
10
|
+
writing code; the linked guides are bundled locally and need no extra skill
|
|
11
|
+
installation. Load additional guides when the task crosses into another area.
|
|
12
|
+
|
|
13
|
+
## Choose A Guide
|
|
14
|
+
|
|
15
|
+
| Task | Read |
|
|
16
|
+
| --- | --- |
|
|
17
|
+
| Start a program, choose factories, or find basic examples | [Quick reference](references/quickstart.md) |
|
|
18
|
+
| Configure providers, models, reasoning, embeddings, routing, or balancing | [AI providers](ax-ai.md) |
|
|
19
|
+
| Make typed decisions, use Jev, or retain probabilities and scores | [Typesafe / Jev](ax-typesafe.md) |
|
|
20
|
+
| Define signatures, field types, schemas, or validation | [Signatures](ax-signature.md) |
|
|
21
|
+
| Generate structured output, stream results, or attach tools | [Generation](ax-gen.md) |
|
|
22
|
+
| Build agents, use tools, or delegate to child agents | [Agents](ax-agent.md) |
|
|
23
|
+
| Configure code execution, RLM loops, sessions, or runtime state | [Agent runtime](ax-agent-rlm.md) |
|
|
24
|
+
| Choose context maps, trajectory policy, optimization, or recall | [Agent context](ax-agent-context.md) |
|
|
25
|
+
| Add persistent memory, recall, or dynamic skill discovery | [Memory and skills](ax-agent-memory-skills.md) |
|
|
26
|
+
| Inspect tracing, callbacks, logs, usage, or replay | [Agent observability](ax-agent-observability.md) |
|
|
27
|
+
| Evaluate or tune agents and their playbooks | [Agent optimization](ax-agent-optimize.md) |
|
|
28
|
+
| Compose workflow graphs, branches, or parallel steps | [Workflows](ax-flow.md) |
|
|
29
|
+
| Connect MCP servers, transports, authentication, or catalogs | [MCP](ax-mcp.md) |
|
|
30
|
+
| Ingest events, schedule wakeups, resume runs, or use stores and sinks | [Event runtime](ax-event-runtime.md) |
|
|
31
|
+
| Transcribe, synthesize, or exchange conversational audio | [Audio](ax-audio.md) |
|
|
32
|
+
| Optimize prompts with BootstrapFewShot or GEPA | [Optimization](ax-gepa.md) |
|
|
33
|
+
| Evolve reusable context or learn from run-end feedback | [Playbooks](ax-playbook.md) |
|
|
34
|
+
| Improve candidates using reward scores and evaluator feedback | [Refinement](ax-refine.md) |
|
|
35
|
+
|
|
36
|
+
## Essential Conventions
|
|
37
|
+
|
|
38
|
+
- Prefer `ai(...)`, `ax(...)`, `agent(...)`, `flow(...)`, `optimize(...)`,
|
|
39
|
+
`s(...)`, and `fn(...)`. Use string signatures or fluent `f()` field builders.
|
|
40
|
+
- Check the installed package's types and version before borrowing an example
|
|
41
|
+
from another release. These guides ship with the package version above.
|
|
42
|
+
- Use provider credentials from the application's environment.
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
import { ai, ax } from '@ax-llm/ax';
|
|
8
46
|
|
|
9
|
-
Ax is a TypeScript library for building LLM-powered applications with type-safe signatures, streaming support, and multi-provider compatibility.
|
|
10
|
-
|
|
11
|
-
> **Detailed skills available:** ax-ai (providers, routing, adaptive balancing), ax-typesafe (Typesafe/Jev decisions, criteria, native scoring), ax-signature (signatures/types), ax-gen (generators), ax-agent (core agents/tools), ax-agent-rlm (agent runtime/RLM/delegation), ax-agent-observability (callbacks/logs/usage), ax-agent-memory-skills (recall and dynamic skill loading), ax-agent-optimize (agent tuning/eval), ax-flow (workflows), ax-gepa (top-level `optimize(...)`, BootstrapFewShot -> GEPA, Pareto optimization).
|
|
12
|
-
|
|
13
|
-
## Imports & Factories
|
|
14
|
-
|
|
15
|
-
```typescript
|
|
16
|
-
// Prefer factory functions: ax(), ai(), agent(), flow(); avoid class constructors.
|
|
17
|
-
import { ax, ai, f, s, fn, agent, flow, AxMemory, AxMCPClient } from '@ax-llm/ax';
|
|
18
|
-
import { z } from 'zod'; // optional — any Standard Schema v1 library works
|
|
19
|
-
|
|
20
|
-
// AI provider
|
|
21
47
|
const llm = ai({ name: 'openai', apiKey: process.env.OPENAI_APIKEY });
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const gen = ax('question:string -> answer:string');
|
|
25
|
-
|
|
26
|
-
// Generator (from fluent signature)
|
|
27
|
-
const fluentGen = ax(
|
|
28
|
-
f()
|
|
29
|
-
.input('question', f.string('User question'))
|
|
30
|
-
.output('answer', f.string('AI response'))
|
|
31
|
-
.build()
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
// Generator (from zod — Standard Schema v1, also works with valibot/arktype)
|
|
35
|
-
const zodGen = ax(
|
|
36
|
-
f()
|
|
37
|
-
.input(z.object({ question: z.string().describe('User question') }))
|
|
38
|
-
.output(z.object({ answer: z.string().describe('AI response') }))
|
|
39
|
-
.build()
|
|
40
|
-
);
|
|
41
|
-
|
|
42
|
-
// Reusable signature
|
|
43
|
-
const sig = s('question:string, context:string[] -> answer:string');
|
|
44
|
-
|
|
45
|
-
// Agent
|
|
46
|
-
const myAgent = agent('userInput:string -> response:string', {
|
|
47
|
-
agentIdentity: {
|
|
48
|
-
name: 'helper',
|
|
49
|
-
description: 'A helpful assistant',
|
|
50
|
-
},
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
// Flow
|
|
54
|
-
const wf = flow<{ input: string }, { output: string }>()
|
|
55
|
-
.node('step1', 'input:string -> output:string')
|
|
56
|
-
.execute('step1', (state) => ({ input: state.input }))
|
|
57
|
-
.returns((state) => ({ output: state.step1Result.output }));
|
|
58
|
-
|
|
59
|
-
// Function tool — native fluent
|
|
60
|
-
const tool = fn('search')
|
|
61
|
-
.description('Search the web')
|
|
62
|
-
.arg('query', f.string('Search query'))
|
|
63
|
-
.returns(f.string('Search results'))
|
|
64
|
-
.handler(({ query }) => searchWeb(query))
|
|
65
|
-
.build();
|
|
66
|
-
|
|
67
|
-
// Function tool — zod schema (Standard Schema v1: also works with valibot, arktype)
|
|
68
|
-
const zodTool = fn('calculateTax')
|
|
69
|
-
.description('Calculate tax for an amount')
|
|
70
|
-
.arg(z.object({
|
|
71
|
-
amount: z.number().positive().describe('Pre-tax amount in USD'),
|
|
72
|
-
region: z.enum(['US', 'EU', 'UK']).describe('Tax region'),
|
|
73
|
-
}))
|
|
74
|
-
.returns(z.object({ tax: z.number(), total: z.number() }))
|
|
75
|
-
.handler(async ({ amount }) => ({ tax: amount * 0.1, total: amount * 1.1 }))
|
|
76
|
-
.build();
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
## Running
|
|
80
|
-
|
|
81
|
-
```typescript
|
|
82
|
-
// Forward (blocking)
|
|
83
|
-
const result = await gen.forward(llm, { question: 'What is 2+2?' });
|
|
84
|
-
|
|
85
|
-
// Streaming
|
|
86
|
-
for await (const chunk of gen.streamingForward(llm, { question: 'Tell a story' })) {
|
|
87
|
-
if (chunk.delta.answer) process.stdout.write(chunk.delta.answer);
|
|
88
|
-
}
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
## Forward Options Quick Reference
|
|
92
|
-
|
|
93
|
-
Provider capabilities determine which outputs and options apply. Typesafe/Jev
|
|
94
|
-
and OpenAI Decisions support required boolean/class/rubric score signatures.
|
|
95
|
-
Use `(evidence)` or `.withEvidence()` for probabilities, scores, and native
|
|
96
|
-
confidence through AxGen; provenance distinguishes native and elicited evidence.
|
|
97
|
-
Use native clients for advanced request shapes, and generative providers for
|
|
98
|
-
prose or tools. See
|
|
99
|
-
the [ax-typesafe skill](https://github.com/ax-llm/ax/blob/main/src/ax/skills/ax-typesafe.md)
|
|
100
|
-
before applying the general generation options below to Jev.
|
|
101
|
-
|
|
102
|
-
| Goal | Option | Example |
|
|
103
|
-
|------|--------|---------|
|
|
104
|
-
| Model override | `model` | `{ model: 'gpt-5.4-mini' }` |
|
|
105
|
-
| Temperature | `modelConfig.temperature` | `{ modelConfig: { temperature: 0.8 } }` |
|
|
106
|
-
| Max tokens | `modelConfig.maxTokens` | `{ modelConfig: { maxTokens: 500 } }` |
|
|
107
|
-
| Retry on failure | `maxRetries` | `{ maxRetries: 3 }` |
|
|
108
|
-
| Max agent steps | `maxSteps` | `{ maxSteps: 10 }` |
|
|
109
|
-
| Fail fast | `fastFail` | `{ fastFail: true }` |
|
|
110
|
-
| Thinking budget | `thinkingTokenBudget` | `{ thinkingTokenBudget: 'medium' }` |
|
|
111
|
-
| Show thoughts | `showThoughts` | `{ showThoughts: true }` |
|
|
112
|
-
| Context caching | `contextCache` | `{ contextCache: { cacheBreakpoint: 'after-examples' } }` |
|
|
113
|
-
| Multi-sampling | `sampleCount` | `{ sampleCount: 5 }` |
|
|
114
|
-
| Debug logging | `debug` | `{ debug: true }` |
|
|
115
|
-
| Abort signal | `abortSignal` | `{ abortSignal: controller.signal }` |
|
|
116
|
-
| Memory | `mem` | `{ mem: new AxMemory() }` |
|
|
117
|
-
| Stop function | `stopFunction` | `{ stopFunction: 'finalAnswer' }` |
|
|
118
|
-
| Function mode | `functionCallMode` | `{ functionCallMode: 'auto' }` |
|
|
119
|
-
|
|
120
|
-
Global runtime defaults can be set with `axGlobals` and are read live by future AI, AxGen, and AxFlow calls:
|
|
121
|
-
|
|
122
|
-
```typescript
|
|
123
|
-
import { axGlobals, axCreateDefaultColorLogger } from '@ax-llm/ax';
|
|
124
|
-
import { metrics, trace } from '@opentelemetry/api';
|
|
125
|
-
|
|
126
|
-
axGlobals.rateLimiter = async (next, info) => next();
|
|
127
|
-
axGlobals.tracer = trace.getTracer('my-app');
|
|
128
|
-
axGlobals.meter = metrics.getMeter('my-app');
|
|
129
|
-
axGlobals.debug = true;
|
|
130
|
-
axGlobals.logger = axCreateDefaultColorLogger();
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
Runtime hooks resolve as: forward/direct-call hooks, enclosing program defaults, child-program defaults, AI-service hooks, then globals snapshotted at operation start. They are native run-scoped values and never enter AxIR JSON state, cache keys, exported state, traces, or optimizer artifacts. Agent and flow forwards carry them through every internal generator and model call without mutating children or leaking across concurrent runs. Limiter failures propagate; tracer, meter, and usage-observer failures are fail-open. `customLabels` merge by precedence, and `abortSignal` values are combined so either global or local cancellation works.
|
|
134
|
-
|
|
135
|
-
## Memory and Context
|
|
136
|
-
|
|
137
|
-
```typescript
|
|
138
|
-
import { AxMemory } from '@ax-llm/ax';
|
|
139
|
-
|
|
140
|
-
const memory = new AxMemory();
|
|
141
|
-
|
|
142
|
-
// Multi-turn conversation
|
|
143
|
-
await gen.forward(llm, { userMessage: 'My name is Alice' }, { mem: memory });
|
|
144
|
-
const r = await gen.forward(llm, { userMessage: 'What is my name?' }, { mem: memory });
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
## Few-Shot Examples
|
|
148
|
-
|
|
149
|
-
```typescript
|
|
150
|
-
const classifier = ax('reviewText:string -> sentiment:class "positive, negative, neutral"');
|
|
151
|
-
|
|
152
|
-
classifier.setExamples([
|
|
153
|
-
{ reviewText: 'I love this!', sentiment: 'positive' },
|
|
154
|
-
{ reviewText: 'Terrible.', sentiment: 'negative' },
|
|
155
|
-
{ reviewText: 'It works.', sentiment: 'neutral' },
|
|
156
|
-
]);
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
## Common Patterns
|
|
160
|
-
|
|
161
|
-
### Classification
|
|
162
|
-
|
|
163
|
-
```typescript
|
|
164
|
-
const classifier = ax(
|
|
165
|
-
f()
|
|
166
|
-
.input('text', f.string())
|
|
167
|
-
.output('category', f.class(['spam', 'ham', 'uncertain']))
|
|
168
|
-
.output('confidence', f.number().min(0).max(1))
|
|
169
|
-
.build()
|
|
170
|
-
);
|
|
171
|
-
```
|
|
172
|
-
|
|
173
|
-
### Extraction
|
|
174
|
-
|
|
175
|
-
```typescript
|
|
176
|
-
const extractor = ax(
|
|
177
|
-
f()
|
|
178
|
-
.input('text', f.string())
|
|
179
|
-
.output('entities', f.object({
|
|
180
|
-
people: f.string().array(),
|
|
181
|
-
organizations: f.string().array(),
|
|
182
|
-
locations: f.string().array()
|
|
183
|
-
}))
|
|
184
|
-
.build()
|
|
185
|
-
);
|
|
186
|
-
```
|
|
187
|
-
|
|
188
|
-
### Multi-modal (Images)
|
|
189
|
-
|
|
190
|
-
```typescript
|
|
191
|
-
const analyzer = ax(
|
|
192
|
-
f()
|
|
193
|
-
.input('image', f.image('Image to analyze'))
|
|
194
|
-
.input('question', f.string('Question').optional())
|
|
195
|
-
.output('description', f.string())
|
|
196
|
-
.output('objects', f.string().array())
|
|
197
|
-
.build()
|
|
198
|
-
);
|
|
199
|
-
|
|
200
|
-
const result = await analyzer.forward(llm, {
|
|
201
|
-
image: { mimeType: 'image/jpeg', data: base64Data },
|
|
202
|
-
question: 'What objects are in this image?'
|
|
203
|
-
});
|
|
204
|
-
```
|
|
205
|
-
|
|
206
|
-
### Chaining Generators
|
|
207
|
-
|
|
208
|
-
```typescript
|
|
209
|
-
const researcher = ax('topic:string -> research:string, keyFacts:string[]');
|
|
210
|
-
const writer = ax('research:string, keyFacts:string[] -> article:string');
|
|
211
|
-
|
|
212
|
-
const research = await researcher.forward(llm, { topic: 'AGI' });
|
|
213
|
-
const draft = await writer.forward(llm, { research: research.research, keyFacts: research.keyFacts });
|
|
214
|
-
```
|
|
215
|
-
|
|
216
|
-
## Error Handling
|
|
217
|
-
|
|
218
|
-
```typescript
|
|
219
|
-
import { AxGenerateError, AxAIServiceError, AxAIServiceAbortedError } from '@ax-llm/ax';
|
|
220
|
-
|
|
221
|
-
try {
|
|
222
|
-
const result = await gen.forward(llm, { input: 'test' });
|
|
223
|
-
} catch (error) {
|
|
224
|
-
if (error instanceof AxGenerateError) {
|
|
225
|
-
console.error('Generation failed:', error.details.model, error.details.signature);
|
|
226
|
-
} else if (error instanceof AxAIServiceAbortedError) {
|
|
227
|
-
console.log('Request was aborted');
|
|
228
|
-
} else if (error instanceof AxAIServiceError) {
|
|
229
|
-
console.error('AI service error:', error.message);
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
```
|
|
233
|
-
|
|
234
|
-
## Debugging
|
|
235
|
-
|
|
236
|
-
```typescript
|
|
237
|
-
import { axCreateDefaultColorLogger, axGlobals } from '@ax-llm/ax';
|
|
238
|
-
|
|
239
|
-
const result = await gen.forward(llm, { input: 'test' }, {
|
|
240
|
-
debug: true,
|
|
241
|
-
logger: axCreateDefaultColorLogger(),
|
|
242
|
-
// OpenTelemetry
|
|
243
|
-
tracer: openTelemetryTracer,
|
|
244
|
-
meter: openTelemetryMeter,
|
|
245
|
-
});
|
|
246
|
-
|
|
247
|
-
// Or set live app-wide defaults for future calls:
|
|
248
|
-
axGlobals.tracer = openTelemetryTracer;
|
|
249
|
-
axGlobals.meter = openTelemetryMeter;
|
|
250
|
-
```
|
|
251
|
-
|
|
252
|
-
## MCP Integration
|
|
253
|
-
|
|
254
|
-
Use the `ax-mcp` skill for the complete native client, transport,
|
|
255
|
-
authentication, catalog, task, subscription, event, and replay workflow.
|
|
256
|
-
|
|
257
|
-
```typescript
|
|
258
|
-
import { AxMCPClient, agent } from '@ax-llm/ax';
|
|
259
|
-
import { AxMCPStdioTransport } from '@ax-llm/ax-tools';
|
|
260
|
-
|
|
261
|
-
// Stdio transport (local MCP server)
|
|
262
|
-
const transport = new AxMCPStdioTransport({
|
|
263
|
-
command: 'npx',
|
|
264
|
-
args: ['-y', '@modelcontextprotocol/server-memory'],
|
|
265
|
-
});
|
|
266
|
-
|
|
267
|
-
const mcpClient = new AxMCPClient(transport, { namespace: 'memory' });
|
|
268
|
-
|
|
269
|
-
// Native MCP context is initialized once and inherited by all agent stages.
|
|
270
|
-
const myAgent = agent('userMessage:string -> response:string', {
|
|
271
|
-
mcp: mcpClient,
|
|
272
|
-
functionDiscovery: true,
|
|
273
|
-
contextFields: [],
|
|
274
|
-
});
|
|
275
|
-
|
|
276
|
-
const result = await myAgent.forward(llm, { userMessage: 'Remember this.' });
|
|
277
|
-
await mcpClient.close(); // caller-owned clients remain caller-owned
|
|
278
|
-
```
|
|
279
|
-
|
|
280
|
-
### HTTP Transport (Remote MCP)
|
|
281
|
-
|
|
282
|
-
```typescript
|
|
283
|
-
import { AxMCPStreamableHTTPTransport } from '@ax-llm/ax';
|
|
284
|
-
|
|
285
|
-
const transport = new AxMCPStreamableHTTPTransport('https://remote.example/mcp', {
|
|
286
|
-
headers: { 'x-pd-project-id': projectId },
|
|
287
|
-
authorization: `Bearer ${accessToken}`,
|
|
288
|
-
});
|
|
48
|
+
const answer = ax('question:string -> answer:string');
|
|
49
|
+
const result = await answer.forward(llm, { question: 'What is a signature?' });
|
|
289
50
|
```
|
|
290
51
|
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
- Use `mcpContext` to inject attributed prompts/resources before the first model call.
|
|
295
|
-
- Use `mcpInheritance: 'all' | 'none' | string[]` to restrict child programs.
|
|
296
|
-
- Tool calls retain raw MCP content, metadata, errors, tasks, and protocol provenance in memory.
|
|
297
|
-
- AxAgent exposes native modules as `mcp.<namespace>` and `ucp.<namespace>`.
|
|
298
|
-
- `inspectCatalog()` discovers tool/prompt names, concrete resources, and URI
|
|
299
|
-
templates from only an endpoint. Resource event sources default to no
|
|
300
|
-
subscriptions and require an explicit all/URI/selector policy.
|
|
301
|
-
- `toFunction()` remains a compatibility adapter only; native Ax execution never uses it.
|
|
302
|
-
- Live optimization is rejected by default. Use recording/replay or explicitly opt into live MCP evaluation.
|
|
303
|
-
|
|
304
|
-
```typescript
|
|
305
|
-
const catalog = await mcpClient.inspectCatalog();
|
|
306
|
-
const tools = catalog.tools;
|
|
307
|
-
const prompts = await mcpClient.listPrompts();
|
|
308
|
-
const resource = await mcpClient.readResource('docs://guide');
|
|
309
|
-
const tasks = await mcpClient.listTasks();
|
|
310
|
-
```
|
|
311
|
-
|
|
312
|
-
### Function Overrides
|
|
313
|
-
|
|
314
|
-
```typescript
|
|
315
|
-
const mcpClient = new AxMCPClient(transport, {
|
|
316
|
-
functionOverrides: [
|
|
317
|
-
{ name: 'search_documents', updates: { name: 'findDocs', description: 'Search docs' } }
|
|
318
|
-
]
|
|
319
|
-
});
|
|
320
|
-
```
|
|
321
|
-
|
|
322
|
-
## Type Reference
|
|
323
|
-
|
|
324
|
-
All programs use `forward(ai, values, options?)` and
|
|
325
|
-
`streamingForward(ai, values, options?)`. For an AI service type `T`, use the
|
|
326
|
-
exported option types below instead of constructor options:
|
|
327
|
-
|
|
328
|
-
| Program | Forward options | Streaming options |
|
|
329
|
-
| --- | --- | --- |
|
|
330
|
-
| `AxGen` | `AxProgramForwardOptionsWithModels<T>` | `AxProgramStreamingForwardOptionsWithModels<T>` |
|
|
331
|
-
| `AxAgent` | `AxAgentForwardOptions<T>` | `AxAgentStreamingForwardOptions<T>` |
|
|
332
|
-
| `AxFlow` | `AxFlowForwardOptions<T>` | `AxProgramStreamingForwardOptionsWithModels<T>` |
|
|
333
|
-
|
|
334
|
-
`forward()` returns `Promise<OUT>`. `streamingForward()` returns
|
|
335
|
-
`AxGenStreamingOut<OUT>` with `{ version, index, delta }` chunks. Agent input
|
|
336
|
-
values can also include a per-run `memories` array. `AxAgentOptions<IN>` is for
|
|
337
|
-
constructing an agent, not for its forward call.
|
|
338
|
-
|
|
339
|
-
- `AxGen`: `setExamples(...)`, `addAssert(...)`, `addStreamingAssert(...)`,
|
|
340
|
-
`addFieldProcessor(...)`, `addStreamingFieldProcessor(...)`, and `stop()`.
|
|
341
|
-
See `ax-gen` for their callback contracts.
|
|
342
|
-
- `AxAgent`: `getFunction()` exposes a child-agent tool and requires
|
|
343
|
-
`agentIdentity` at construction. See `ax-agent`.
|
|
344
|
-
- `AxFlow`: define nodes with `.node(...)`, execute them with `.execute(...)`,
|
|
345
|
-
and select outputs with `.returns(...)`. See `ax-flow`.
|
|
346
|
-
|
|
347
|
-
## Event-Driven Programs
|
|
348
|
-
|
|
349
|
-
Use `eventRuntime()` when notifications, webhooks, timers, or remote tasks
|
|
350
|
-
should wake or resume an Ax program. Sources publish into an inbox; explicit
|
|
351
|
-
routes choose `observe`, `invalidate`, `wake`, or `resume`. Event payloads are
|
|
352
|
-
never inserted as user messages automatically. See `ax-event-runtime.md`.
|
|
353
|
-
|
|
354
|
-
## Examples
|
|
355
|
-
|
|
356
|
-
Fetch these for full working code:
|
|
357
|
-
|
|
358
|
-
- [Standard Schema (zod)](https://raw.githubusercontent.com/ax-llm/ax/refs/heads/main/src/examples/standard-schema.ts) — zod with f() and fn()
|
|
359
|
-
- [Chat Log](https://raw.githubusercontent.com/ax-llm/ax/refs/heads/main/src/examples/chat-log.ts) — inspect conversation history and multi-step tool calls
|
|
360
|
-
- [Marketing](https://raw.githubusercontent.com/ax-llm/ax/refs/heads/main/src/examples/marketing.ts) — product use case
|
|
361
|
-
- [MCP Integration](https://raw.githubusercontent.com/ax-llm/ax/refs/heads/main/src/examples/mcp-client-memory.ts) — MCP integration
|
|
52
|
+
For example, an agent with persistent recall needs the agent and memory guides;
|
|
53
|
+
a provider-backed workflow needs the provider, generation, and workflow guides.
|
|
54
|
+
Specialist skills remain optional for users who want separate skill entries.
|
package/skills/ax-mcp.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: ax-mcp
|
|
3
3
|
description: This skill helps an LLM build correct native Model Context Protocol integrations with @ax-llm/ax. Use when the user asks about AxMCPClient, MCP transports, tools, prompts, resources, subscriptions, tasks, sampling, elicitation, roots, authentication, OAuth, MCP Apps, recording/replay, or MCP integration with AxGen, AxAgent, AxFlow, chat, optimization, and AxEventRuntime.
|
|
4
|
-
version: "25.4.
|
|
4
|
+
version: "25.4.2"
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# Native MCP With Ax
|
package/skills/ax-playbook.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: ax-playbook
|
|
3
3
|
description: This skill helps an LLM generate correct playbook code using @ax-llm/ax. Use when the user asks about playbook(), AxPlaybook, context playbooks, evolving context, ACE / Agentic Context Engineering, agent.playbook(), or growing/applying task knowledge offline and online with evolve() and update().
|
|
4
|
-
version: "25.4.
|
|
4
|
+
version: "25.4.2"
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# Playbook Codegen Rules (@ax-llm/ax)
|
package/skills/ax-refine.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: ax-refine
|
|
3
3
|
description: Use this skill when writing or reviewing Ax bestOfN/refine code, reward functions, thresholds, native sample selection, serial attempts, generated advice, and attempt diagnostics.
|
|
4
|
-
version: "25.4.
|
|
4
|
+
version: "25.4.2"
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# Ax Refine And BestOfN
|
package/skills/ax-signature.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: ax-signature
|
|
3
3
|
description: This skill helps an LLM generate correct DSPy signature code using @ax-llm/ax. Use when the user asks about signatures, s(), f(), field types, string syntax, fluent builder API, validation constraints, or type-safe inputs/outputs.
|
|
4
|
-
version: "25.4.
|
|
4
|
+
version: "25.4.2"
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# Ax Signature Reference
|
package/skills/ax-typesafe.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: ax-typesafe
|
|
3
3
|
description: Use Typesafe Jev models with @ax-llm/ax in TypeScript. Covers images, box outputs, and boolean/class/rubric score signatures with decision evidence, value descriptions, provider trueThreshold, native Noul/Choice/Score questions, structured criteria, probability-based decisions, and explicit hybrid generation.
|
|
4
|
-
version: "25.4.
|
|
4
|
+
version: "25.4.2"
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
<!-- cspell:ignore noul -->
|
|
@@ -144,7 +144,7 @@ multiple completion samples, and generation controls such as `temperature` or
|
|
|
144
144
|
`maxTokens` are unsupported. There is no token streaming; Ax's
|
|
145
145
|
`streamingForward()` can deliver a completed result.
|
|
146
146
|
|
|
147
|
-
## Image inputs and Box outputs
|
|
147
|
+
## Image inputs and Box outputs
|
|
148
148
|
|
|
149
149
|
```typescript
|
|
150
150
|
const vision = ai({
|
|
@@ -197,9 +197,9 @@ boolean/class/score questions, but has no documented native Box primitive;
|
|
|
197
197
|
Ax rejects Box outputs on that endpoint before transport. Use a generative
|
|
198
198
|
OpenAI vision model for Box instead.
|
|
199
199
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
`src/examples
|
|
200
|
+
Image and Box signatures are available in TypeScript, Python, Java, C++, Go, and
|
|
201
|
+
Rust. Runnable image localization examples live under each language’s
|
|
202
|
+
`src/examples/<language>/generation/` directory. See the upstream
|
|
203
203
|
[Images](https://docs.typesafe.ai/images) and
|
|
204
204
|
[Box](https://docs.typesafe.ai/primitives/box) contracts.
|
|
205
205
|
|