@absolutejs/ai 0.0.56 → 0.0.57
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 +17 -0
- package/README.md +42 -0
- package/changelog.json +30 -0
- package/dist/ai/index.js +1261 -778
- package/dist/ai/index.js.map +13 -10
- package/dist/ai/providers/anthropic.js +117 -1
- package/dist/ai/providers/anthropic.js.map +7 -6
- package/dist/ai/providers/gemini.js +97 -4
- package/dist/ai/providers/gemini.js.map +7 -6
- package/dist/ai/providers/ollama.js +3 -1
- package/dist/ai/providers/ollama.js.map +4 -4
- package/dist/ai/providers/openai.js +875 -41
- package/dist/ai/providers/openai.js.map +9 -6
- package/dist/ai/providers/openaiCompatible.js +875 -41
- package/dist/ai/providers/openaiCompatible.js.map +9 -6
- package/dist/ai/providers/openaiResponses.js +297 -3
- package/dist/ai/providers/openaiResponses.js.map +8 -6
- package/dist/ai/providers/openrouter.js +1088 -737
- package/dist/ai/providers/openrouter.js.map +10 -8
- package/dist/src/ai/index.d.ts +4 -0
- package/dist/src/ai/inputCapacity.d.ts +25 -0
- package/dist/src/ai/prepareTextInput.d.ts +21 -0
- package/dist/src/ai/providers/gemini.d.ts +1 -0
- package/dist/src/ai/providers/openai.d.ts +1 -0
- package/dist/src/ai/providers/openaiCapacity.d.ts +11 -0
- package/dist/src/ai/providers/openaiResponses.d.ts +2 -0
- package/dist/src/ai/providers/openrouterClient.d.ts +1 -1
- package/dist/types/ai.d.ts +5 -0
- package/package.json +11 -6
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `@absolutejs/ai`.
|
|
4
|
+
|
|
5
|
+
This file is generated by `absolute-changelog` from the entries in
|
|
6
|
+
`changelog/`. Edit an entry, not this file — and add new ones under
|
|
7
|
+
`changelog/unreleased/`.
|
|
8
|
+
|
|
9
|
+
## 0.0.57 — 2026-09-15
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- **Add model-specific token capacity, optional provider capacity configuration, and recoverable long-text preparation** (`inspectAIInput`, `prepareAITextInput`, `AIProviderConfig`, `OpenAIConfig`, `OpenAIResponsesConfig`)
|
|
14
|
+
|
|
15
|
+
### Internal
|
|
16
|
+
|
|
17
|
+
- **Regenerate the OpenRouter client declaration with equivalent reordered response union types** (`createOpenRouterClient`)
|
package/README.md
CHANGED
|
@@ -329,3 +329,45 @@ Use `openrouterResponses(config)` when an AbsoluteJS agent should stream through
|
|
|
329
329
|
OpenRouter's stateless Responses API, or `openrouterMessages(config)` for the
|
|
330
330
|
native Anthropic Messages protocol. Both accept the same model/provider policies
|
|
331
331
|
and `providerOptions.openrouter` controls, including replayable hosted-tool data.
|
|
332
|
+
|
|
333
|
+
### Model capacity and long text
|
|
334
|
+
|
|
335
|
+
Use `inspectAIInput(provider, params)` to count the complete request, including
|
|
336
|
+
instructions and tools, and reserve room for the requested reply. The result
|
|
337
|
+
includes `inputTokens`, `availableInputTokens`, model `limits`, and `fits`.
|
|
338
|
+
There is no package-wide character limit or character-to-token estimate.
|
|
339
|
+
|
|
340
|
+
For text conversations, `prepareAITextInput(provider, params, options)` returns
|
|
341
|
+
`{ params, compacted, sectionsProcessed }`. Requests that fit pass through
|
|
342
|
+
unchanged. Oversized text is read in counted sections into rolling notes; the
|
|
343
|
+
final request is counted again before being returned. Summaries can lose detail,
|
|
344
|
+
so persist the original source first and retain it for download and resume.
|
|
345
|
+
|
|
346
|
+
```ts
|
|
347
|
+
import { prepareAITextInput } from "@absolutejs/ai";
|
|
348
|
+
|
|
349
|
+
// Save original messages before preparation. This may make additional model calls.
|
|
350
|
+
const prepared = await prepareAITextInput(provider, params, {
|
|
351
|
+
onProgress: ({ processedCharacters, totalCharacters }) => {
|
|
352
|
+
reportProgress(processedCharacters, totalCharacters);
|
|
353
|
+
},
|
|
354
|
+
onUsage: (usage) => recordSectionUsage(usage),
|
|
355
|
+
});
|
|
356
|
+
for await (const chunk of provider.stream(prepared.params)) {
|
|
357
|
+
// Render the reply and record its usage as usual.
|
|
358
|
+
}
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
Anthropic and Gemini retrieve native model metadata and count using their native
|
|
362
|
+
APIs. OpenAI uses its input-token counting API and an exact, documented model
|
|
363
|
+
catalog because its model-list API does not expose context limits. OpenAI
|
|
364
|
+
providers accept `modelLimits` for additional model IDs or compatible endpoints.
|
|
365
|
+
Unknown models/providers fail with `AIInputError` (`capacity_unavailable`) rather
|
|
366
|
+
than guessing. Custom providers can implement the optional `inputCapacity`
|
|
367
|
+
capability. Existing `stream` calls remain unchanged.
|
|
368
|
+
|
|
369
|
+
Automatic preparation supports text-only history. It rejects oversized tool or
|
|
370
|
+
multimodal histories rather than flattening them. Handle preparation errors in
|
|
371
|
+
the UI while preserving the original input; expose retry without clearing the
|
|
372
|
+
conversation. File upload/storage limits are application transport limits and
|
|
373
|
+
should be reported separately from model capacity.
|
package/changelog.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"contract": 1,
|
|
3
|
+
"name": "@absolutejs/ai",
|
|
4
|
+
"releases": [
|
|
5
|
+
{
|
|
6
|
+
"changes": [
|
|
7
|
+
{
|
|
8
|
+
"kind": "internal",
|
|
9
|
+
"summary": "Regenerate the OpenRouter client declaration with equivalent reordered response union types",
|
|
10
|
+
"symbols": [
|
|
11
|
+
"createOpenRouterClient"
|
|
12
|
+
]
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"kind": "added",
|
|
16
|
+
"summary": "Add model-specific token capacity, optional provider capacity configuration, and recoverable long-text preparation",
|
|
17
|
+
"symbols": [
|
|
18
|
+
"inspectAIInput",
|
|
19
|
+
"prepareAITextInput",
|
|
20
|
+
"AIProviderConfig",
|
|
21
|
+
"OpenAIConfig",
|
|
22
|
+
"OpenAIResponsesConfig"
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
],
|
|
26
|
+
"date": "2026-09-15",
|
|
27
|
+
"version": "0.0.57"
|
|
28
|
+
}
|
|
29
|
+
]
|
|
30
|
+
}
|