@absolutejs/ai 0.2.6 → 0.2.7

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/CHANGELOG.md CHANGED
@@ -6,6 +6,12 @@ This file is generated by `absolute-changelog` from the entries in
6
6
  `changelog/`. Edit an entry, not this file — and add new ones under
7
7
  `changelog/unreleased/`.
8
8
 
9
+ ## 0.2.7 — 2026-09-24
10
+
11
+ ### Added
12
+
13
+ - **Add injected evidence research orchestration and per-request transport retry limits for host-owned accounting** (`GenerateAIOptions`, `GenerateObjectAIOptions`, `AIProviderStreamParams`)
14
+
9
15
  ## 0.2.6 — 2026-09-20
10
16
 
11
17
  ### Fixed
package/README.md CHANGED
@@ -539,3 +539,5 @@ Consumers must separately explain whether attachments, hosted search, structured
539
539
  output, and media generation are enabled in their UI and endpoint. Context windows
540
540
  are documented provider limits, not a substitute for runtime token budgeting.
541
541
  Regional features are omitted when they are not consistently supported.
542
+
543
+ `@absolutejs/ai/research` separates an injected `SearchProvider` from evidence-only synthesis. It returns sources, findings, searches, limitations and explicit availability, and excludes invented source references/quotes. Quotation checks establish provenance; they are not a substitute for claim entailment or entity review. Hosts can set `maxRetries: 0` on one-shot or stream requests when they own attempt accounting, and independently bound `maxRepairAttempts` and disable context recovery.
package/changelog.json CHANGED
@@ -1,263 +1,278 @@
1
1
  {
2
- "contract": 1,
3
- "name": "@absolutejs/ai",
4
- "releases": [
5
- {
6
- "changes": [
7
- {
8
- "kind": "fixed",
9
- "summary": "Count supported Anthropic caller input when hosted tools cannot be pre-counted, preserving full generation requests and exposing honest count scope",
10
- "symbols": [
11
- "anthropic",
12
- "inspectAIInput",
13
- "AIInputCapacity",
14
- "AIProviderConfig",
15
- "createAIProviderRouter"
16
- ]
17
- }
18
- ],
19
- "date": "2026-09-20",
20
- "version": "0.2.6"
21
- },
22
- {
23
- "changes": [
24
- {
25
- "kind": "fixed",
26
- "summary": "Allow SSE tool loops to reread changed files without silently completing; retain turn, time and token limits",
27
- "symbols": [
28
- "streamAIToSSE"
29
- ]
30
- }
31
- ],
32
- "date": "2026-09-20",
33
- "version": "0.2.5"
34
- },
35
- {
36
- "changes": [
37
- {
38
- "kind": "added",
39
- "summary": "Add reviewed per-model reasoning controls, provider translations, and compatible thinking stream replay.",
40
- "symbols": [
41
- "MODEL_REASONING",
42
- "REASONING_EFFORTS",
43
- "getModelReasoning",
44
- "isReasoningSelection",
45
- "supportsReasoningSelection",
46
- "reasoningSelectionLabel",
47
- "ModelReasoning",
48
- "ReasoningSelection",
49
- "ReasoningEffort"
50
- ]
51
- }
52
- ],
53
- "date": "2026-09-20",
54
- "version": "0.2.4"
55
- },
56
- {
57
- "changes": [
58
- {
59
- "kind": "internal",
60
- "summary": "Republish the capability catalog using npm packaging after the 0.2.2 registry artifact remained unavailable"
61
- }
62
- ],
63
- "date": "2026-09-20",
64
- "version": "0.2.3"
65
- },
66
- {
67
- "changes": [
68
- {
69
- "kind": "added",
70
- "summary": "Add browser-safe typed model capability metadata with verified provider sources, separate input and output modalities, context windows, and capability descriptions",
71
- "symbols": [
72
- "ModelModality",
73
- "ModelFeature",
74
- "ModelMetadata",
75
- "ModelCapability",
76
- "MODEL_CAPABILITY_DESCRIPTIONS",
77
- "MODEL_METADATA",
78
- "modelCapabilities",
79
- "getModelMetadata"
80
- ]
81
- }
82
- ],
83
- "date": "2026-09-20",
84
- "version": "0.2.2"
85
- },
86
- {
87
- "changes": [
88
- {
89
- "kind": "fixed",
90
- "summary": "Preserve provider output reservations and context-error recognition when routing models",
91
- "symbols": [
92
- "createAIProviderRouter"
93
- ]
94
- }
95
- ],
96
- "date": "2026-09-16",
97
- "version": "0.2.1"
98
- },
99
- {
100
- "changes": [
101
- {
102
- "kind": "added",
103
- "summary": "Expose each tool-loop turn response metadata so consumers can price the actual served processing tier",
104
- "symbols": [
105
- "streamAIWithTools",
106
- "StreamAIWithToolsEvent"
107
- ]
108
- },
109
- {
110
- "kind": "added",
111
- "summary": "Route exact model IDs to the same provider for token counting, capacity checks, preparation and generation",
112
- "symbols": [
113
- "createAIProviderRouter"
114
- ]
115
- }
116
- ],
117
- "date": "2026-09-16",
118
- "version": "0.2.0"
119
- },
120
- {
121
- "changes": [
122
- {
123
- "kind": "fixed",
124
- "summary": "Exclude OpenAI cache-write tokens from ordinary input so cache-aware billing never charges the same tokens twice",
125
- "symbols": [
126
- "openai",
127
- "openaiResponses"
128
- ]
129
- }
130
- ],
131
- "date": "2026-09-16",
132
- "version": "0.1.3"
133
- },
134
- {
135
- "changes": [
136
- {
137
- "kind": "fixed",
138
- "summary": "Preserve every parallel OpenAI tool result and subsequent conversation turn without overwriting expanded messages",
139
- "symbols": [
140
- "openai"
141
- ]
142
- }
143
- ],
144
- "date": "2026-09-16",
145
- "version": "0.1.2"
146
- },
147
- {
148
- "changes": [
149
- {
150
- "kind": "added",
151
- "summary": "Allow a separate preparation model with its own verified capacity while preserving the final answer model and invalidating notes when the preparation model changes",
152
- "symbols": [
153
- "PrepareAITextInputOptions",
154
- "prepareAITextInput",
155
- "prepareAITextInputStep"
156
- ]
157
- },
158
- {
159
- "kind": "fixed",
160
- "summary": "Fill preparation sections with bounded tokenizer-checked refinement, avoid duplicate final counting, and honor cancellation before generation",
161
- "symbols": [
162
- "prepareAITextInput",
163
- "prepareAITextInputStep"
164
- ]
165
- }
166
- ],
167
- "date": "2026-09-16",
168
- "version": "0.1.1"
169
- },
170
- {
171
- "changes": [
172
- {
173
- "kind": "changed",
174
- "summary": "Validate model capacity by default across generation, structured output, WebSocket and SSE entry points; reserve token headroom and support one protocol-preserving context recovery attempt. Providers without counting capability now fail explicitly; contextPolicy: false opts into raw behavior.",
175
- "symbols": [
176
- "generateAI",
177
- "generateAIWithTools",
178
- "generateObjectAI",
179
- "streamAI",
180
- "streamAIToSSE",
181
- "streamAIWithTools",
182
- "inspectAIContext",
183
- "createAIStoredToolResultRecovery",
184
- "StreamAIWithToolsOptions",
185
- "GenerateAIOptions",
186
- "GenerateAIResult",
187
- "GenerateObjectAIOptions",
188
- "AIProviderConfig",
189
- "StreamAIOptions",
190
- "AIChatPluginConfig"
191
- ]
192
- },
193
- {
194
- "kind": "added",
195
- "summary": "Add one-section text preparation steps for durable workers, with explicit pending/ready outcomes and checkpoint persistence before yielding",
196
- "symbols": [
197
- "prepareAITextInputStep",
198
- "AITextPreparationStep"
199
- ]
200
- },
201
- {
202
- "kind": "added",
203
- "summary": "Budget final retrieval instructions and tools before compacting text, with matching checkpoint invalidation",
204
- "symbols": [
205
- "PrepareAITextInputOptions",
206
- "prepareAITextInput"
207
- ]
208
- },
209
- {
210
- "kind": "fixed",
211
- "summary": "Preserve conversation origin across long-text preparation sections, distinguish source facts from embedded instructions, reserve more of the available context for factual notes, and invalidate checkpoints from the previous preparation policy",
212
- "symbols": [
213
- "prepareAITextInput",
214
- "prepareAITextInputStep"
215
- ]
216
- }
217
- ],
218
- "date": "2026-09-16",
219
- "version": "0.1.0"
220
- },
221
- {
222
- "changes": [
223
- {
224
- "kind": "added",
225
- "summary": "Keep compacted text useful with read-only original-source search, checkpointed ingestion, and capacity-checked terminal tool loops",
226
- "symbols": [
227
- "createAITextSource",
228
- "prepareAITextInput",
229
- "PrepareAITextInputOptions",
230
- "streamAIWithTools",
231
- "StreamAIWithToolsOptions"
232
- ]
233
- }
234
- ],
235
- "date": "2026-09-15",
236
- "version": "0.0.58"
237
- },
238
- {
239
- "changes": [
240
- {
241
- "kind": "internal",
242
- "summary": "Regenerate the OpenRouter client declaration with equivalent reordered response union types",
243
- "symbols": [
244
- "createOpenRouterClient"
245
- ]
246
- },
247
- {
248
- "kind": "added",
249
- "summary": "Add model-specific token capacity, optional provider capacity configuration, and recoverable long-text preparation",
250
- "symbols": [
251
- "inspectAIInput",
252
- "prepareAITextInput",
253
- "AIProviderConfig",
254
- "OpenAIConfig",
255
- "OpenAIResponsesConfig"
256
- ]
257
- }
258
- ],
259
- "date": "2026-09-15",
260
- "version": "0.0.57"
261
- }
262
- ]
2
+ "contract": 1,
3
+ "name": "@absolutejs/ai",
4
+ "releases": [
5
+ {
6
+ "changes": [
7
+ {
8
+ "kind": "added",
9
+ "summary": "Add injected evidence research orchestration and per-request transport retry limits for host-owned accounting",
10
+ "symbols": [
11
+ "GenerateAIOptions",
12
+ "GenerateObjectAIOptions",
13
+ "AIProviderStreamParams"
14
+ ]
15
+ }
16
+ ],
17
+ "date": "2026-09-24",
18
+ "version": "0.2.7"
19
+ },
20
+ {
21
+ "changes": [
22
+ {
23
+ "kind": "fixed",
24
+ "summary": "Count supported Anthropic caller input when hosted tools cannot be pre-counted, preserving full generation requests and exposing honest count scope",
25
+ "symbols": [
26
+ "anthropic",
27
+ "inspectAIInput",
28
+ "AIInputCapacity",
29
+ "AIProviderConfig",
30
+ "createAIProviderRouter"
31
+ ]
32
+ }
33
+ ],
34
+ "date": "2026-09-20",
35
+ "version": "0.2.6"
36
+ },
37
+ {
38
+ "changes": [
39
+ {
40
+ "kind": "fixed",
41
+ "summary": "Allow SSE tool loops to reread changed files without silently completing; retain turn, time and token limits",
42
+ "symbols": [
43
+ "streamAIToSSE"
44
+ ]
45
+ }
46
+ ],
47
+ "date": "2026-09-20",
48
+ "version": "0.2.5"
49
+ },
50
+ {
51
+ "changes": [
52
+ {
53
+ "kind": "added",
54
+ "summary": "Add reviewed per-model reasoning controls, provider translations, and compatible thinking stream replay.",
55
+ "symbols": [
56
+ "MODEL_REASONING",
57
+ "REASONING_EFFORTS",
58
+ "getModelReasoning",
59
+ "isReasoningSelection",
60
+ "supportsReasoningSelection",
61
+ "reasoningSelectionLabel",
62
+ "ModelReasoning",
63
+ "ReasoningSelection",
64
+ "ReasoningEffort"
65
+ ]
66
+ }
67
+ ],
68
+ "date": "2026-09-20",
69
+ "version": "0.2.4"
70
+ },
71
+ {
72
+ "changes": [
73
+ {
74
+ "kind": "internal",
75
+ "summary": "Republish the capability catalog using npm packaging after the 0.2.2 registry artifact remained unavailable"
76
+ }
77
+ ],
78
+ "date": "2026-09-20",
79
+ "version": "0.2.3"
80
+ },
81
+ {
82
+ "changes": [
83
+ {
84
+ "kind": "added",
85
+ "summary": "Add browser-safe typed model capability metadata with verified provider sources, separate input and output modalities, context windows, and capability descriptions",
86
+ "symbols": [
87
+ "ModelModality",
88
+ "ModelFeature",
89
+ "ModelMetadata",
90
+ "ModelCapability",
91
+ "MODEL_CAPABILITY_DESCRIPTIONS",
92
+ "MODEL_METADATA",
93
+ "modelCapabilities",
94
+ "getModelMetadata"
95
+ ]
96
+ }
97
+ ],
98
+ "date": "2026-09-20",
99
+ "version": "0.2.2"
100
+ },
101
+ {
102
+ "changes": [
103
+ {
104
+ "kind": "fixed",
105
+ "summary": "Preserve provider output reservations and context-error recognition when routing models",
106
+ "symbols": [
107
+ "createAIProviderRouter"
108
+ ]
109
+ }
110
+ ],
111
+ "date": "2026-09-16",
112
+ "version": "0.2.1"
113
+ },
114
+ {
115
+ "changes": [
116
+ {
117
+ "kind": "added",
118
+ "summary": "Expose each tool-loop turn response metadata so consumers can price the actual served processing tier",
119
+ "symbols": [
120
+ "streamAIWithTools",
121
+ "StreamAIWithToolsEvent"
122
+ ]
123
+ },
124
+ {
125
+ "kind": "added",
126
+ "summary": "Route exact model IDs to the same provider for token counting, capacity checks, preparation and generation",
127
+ "symbols": [
128
+ "createAIProviderRouter"
129
+ ]
130
+ }
131
+ ],
132
+ "date": "2026-09-16",
133
+ "version": "0.2.0"
134
+ },
135
+ {
136
+ "changes": [
137
+ {
138
+ "kind": "fixed",
139
+ "summary": "Exclude OpenAI cache-write tokens from ordinary input so cache-aware billing never charges the same tokens twice",
140
+ "symbols": [
141
+ "openai",
142
+ "openaiResponses"
143
+ ]
144
+ }
145
+ ],
146
+ "date": "2026-09-16",
147
+ "version": "0.1.3"
148
+ },
149
+ {
150
+ "changes": [
151
+ {
152
+ "kind": "fixed",
153
+ "summary": "Preserve every parallel OpenAI tool result and subsequent conversation turn without overwriting expanded messages",
154
+ "symbols": [
155
+ "openai"
156
+ ]
157
+ }
158
+ ],
159
+ "date": "2026-09-16",
160
+ "version": "0.1.2"
161
+ },
162
+ {
163
+ "changes": [
164
+ {
165
+ "kind": "added",
166
+ "summary": "Allow a separate preparation model with its own verified capacity while preserving the final answer model and invalidating notes when the preparation model changes",
167
+ "symbols": [
168
+ "PrepareAITextInputOptions",
169
+ "prepareAITextInput",
170
+ "prepareAITextInputStep"
171
+ ]
172
+ },
173
+ {
174
+ "kind": "fixed",
175
+ "summary": "Fill preparation sections with bounded tokenizer-checked refinement, avoid duplicate final counting, and honor cancellation before generation",
176
+ "symbols": [
177
+ "prepareAITextInput",
178
+ "prepareAITextInputStep"
179
+ ]
180
+ }
181
+ ],
182
+ "date": "2026-09-16",
183
+ "version": "0.1.1"
184
+ },
185
+ {
186
+ "changes": [
187
+ {
188
+ "kind": "changed",
189
+ "summary": "Validate model capacity by default across generation, structured output, WebSocket and SSE entry points; reserve token headroom and support one protocol-preserving context recovery attempt. Providers without counting capability now fail explicitly; contextPolicy: false opts into raw behavior.",
190
+ "symbols": [
191
+ "generateAI",
192
+ "generateAIWithTools",
193
+ "generateObjectAI",
194
+ "streamAI",
195
+ "streamAIToSSE",
196
+ "streamAIWithTools",
197
+ "inspectAIContext",
198
+ "createAIStoredToolResultRecovery",
199
+ "StreamAIWithToolsOptions",
200
+ "GenerateAIOptions",
201
+ "GenerateAIResult",
202
+ "GenerateObjectAIOptions",
203
+ "AIProviderConfig",
204
+ "StreamAIOptions",
205
+ "AIChatPluginConfig"
206
+ ]
207
+ },
208
+ {
209
+ "kind": "added",
210
+ "summary": "Add one-section text preparation steps for durable workers, with explicit pending/ready outcomes and checkpoint persistence before yielding",
211
+ "symbols": [
212
+ "prepareAITextInputStep",
213
+ "AITextPreparationStep"
214
+ ]
215
+ },
216
+ {
217
+ "kind": "added",
218
+ "summary": "Budget final retrieval instructions and tools before compacting text, with matching checkpoint invalidation",
219
+ "symbols": [
220
+ "PrepareAITextInputOptions",
221
+ "prepareAITextInput"
222
+ ]
223
+ },
224
+ {
225
+ "kind": "fixed",
226
+ "summary": "Preserve conversation origin across long-text preparation sections, distinguish source facts from embedded instructions, reserve more of the available context for factual notes, and invalidate checkpoints from the previous preparation policy",
227
+ "symbols": [
228
+ "prepareAITextInput",
229
+ "prepareAITextInputStep"
230
+ ]
231
+ }
232
+ ],
233
+ "date": "2026-09-16",
234
+ "version": "0.1.0"
235
+ },
236
+ {
237
+ "changes": [
238
+ {
239
+ "kind": "added",
240
+ "summary": "Keep compacted text useful with read-only original-source search, checkpointed ingestion, and capacity-checked terminal tool loops",
241
+ "symbols": [
242
+ "createAITextSource",
243
+ "prepareAITextInput",
244
+ "PrepareAITextInputOptions",
245
+ "streamAIWithTools",
246
+ "StreamAIWithToolsOptions"
247
+ ]
248
+ }
249
+ ],
250
+ "date": "2026-09-15",
251
+ "version": "0.0.58"
252
+ },
253
+ {
254
+ "changes": [
255
+ {
256
+ "kind": "internal",
257
+ "summary": "Regenerate the OpenRouter client declaration with equivalent reordered response union types",
258
+ "symbols": [
259
+ "createOpenRouterClient"
260
+ ]
261
+ },
262
+ {
263
+ "kind": "added",
264
+ "summary": "Add model-specific token capacity, optional provider capacity configuration, and recoverable long-text preparation",
265
+ "symbols": [
266
+ "inspectAIInput",
267
+ "prepareAITextInput",
268
+ "AIProviderConfig",
269
+ "OpenAIConfig",
270
+ "OpenAIResponsesConfig"
271
+ ]
272
+ }
273
+ ],
274
+ "date": "2026-09-15",
275
+ "version": "0.0.57"
276
+ }
277
+ ]
263
278
  }
package/dist/ai/index.js CHANGED
@@ -512,7 +512,7 @@ var withResilience = (provider, providerName = "unknown") => {
512
512
  noteSuccess(providerName);
513
513
  } catch (err) {
514
514
  const providerError = ProviderError.from(err, providerName);
515
- const canRetry = !yielded && providerError.retryable && attemptNo < config.maxRetries && !params.signal?.aborted;
515
+ const canRetry = !yielded && providerError.retryable && attemptNo < (params.maxRetries === undefined ? config.maxRetries : Math.max(0, Math.min(config.maxRetries, params.maxRetries))) && !params.signal?.aborted;
516
516
  if (canRetry) {
517
517
  await sleep(backoffDelay(attemptNo), params.signal);
518
518
  yield* attempt(params, attemptNo + 1);
@@ -5650,6 +5650,7 @@ var generateAI = async (options) => {
5650
5650
  const stream = streamWithAIContext(options.provider, {
5651
5651
  cacheSystemPrompt: options.cacheSystemPrompt,
5652
5652
  maxTokens: options.maxTokens,
5653
+ maxRetries: options.maxRetries,
5653
5654
  messages: options.messages,
5654
5655
  model: options.model,
5655
5656
  promptCaching: options.promptCaching,
@@ -5854,6 +5855,7 @@ var generateObjectAI = async (options) => {
5854
5855
  contextPolicy: options.contextPolicy,
5855
5856
  cacheSystemPrompt: options.cacheSystemPrompt,
5856
5857
  maxTokens: options.maxTokens,
5858
+ maxRetries: options.maxRetries,
5857
5859
  messages,
5858
5860
  model: options.model,
5859
5861
  promptCaching: options.promptCaching,
@@ -8900,5 +8902,5 @@ export {
8900
8902
  xai
8901
8903
  };
8902
8904
 
8903
- //# debugId=33E15B35E923B1E064756E2164756E21
8905
+ //# debugId=F8FFC7094E06DA7B64756E2164756E21
8904
8906
  //# sourceMappingURL=index.js.map