@reinsjs/lowering-fetch 0.5.2 → 0.6.0
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 +26 -0
- package/README.md +9 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +228 -99
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# @reinsjs/lowering-fetch
|
|
2
2
|
|
|
3
|
+
## 0.6.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 179f891: Video and audio content parts.
|
|
8
|
+
|
|
9
|
+
- core: `ContentPart` gains `VideoPart` (`type: "video"`) and `AudioPart` (`type: "audio"`): `mime` must start with `video/` / `audio/`, base64 `data`, optional `durationSec` (finite, positive). `LoweringCapabilities` gains optional `video` / `audio`; absent means the model does not take them. Token estimates follow duration (100 / s for video, 32 / s for audio); without `durationSec` the byte size is converted at 1 Mbps / 64 kbps with a 30-second floor. `isContentPart` checks the new parts and is now also what `runLoop` uses to validate input — which also means `runLoop` input now rejects a `tool_reference` part whose `inputSchema` is an array (tool results already did). A tool returning an array of video / audio-shaped parts now yields media parts instead of JSON text. The budget-truncation summary writes `[video]` / `[audio]` / `[tool <name>]` instead of `[image]` for non-image parts. No `schemaVersion` bump: existing logs read unchanged, but a log containing video or audio parts cannot be read by an older version.
|
|
10
|
+
- lowering-fetch: new `video` / `audio` model options (default `false`, including every built-in model). When on, video and audio travel in each protocol's image slot — a relay dialect official endpoints reject; `input_audio` is deliberately not used. When off, they become placeholder text and the event is `lossy`. Chat lifts video / audio from tool results like images; a result with images only lowers byte-for-byte as before. Fix: `deepseek-v4-pro` is text-only (`images: false`) — the built-in table and `deepseek()` used to claim images, which the provider silently dropped.
|
|
11
|
+
- lowering-pi: video / audio parts become placeholder text (`lossy`); pi-ai has no such content.
|
|
12
|
+
- server: the HTTP whitelist accepts `video` / `audio` parts with the same shape rules as core.
|
|
13
|
+
- adapter-tanstack-ai: data-sourced video / audio parts translate both ways (TanStack has no duration field). URL-sourced parts are now reported in `dropped` as `audio(url)` / `video(url)` instead of `audio` / `video`, and data parts whose mime type does not match their kind as `video(<mime>)` / `audio(<mime>)`. Imported client parts are now checked with core's `isContentPart`: a malformed one (missing `mimeType`, non-string `value`, non-string text) becomes a placeholder reported in `dropped` instead of throwing or reaching the log.
|
|
14
|
+
- ui-agui: video / audio parts become `[video <mime>]` / `[audio <mime>]` placeholders, recorded in `dropped`.
|
|
15
|
+
- tools-mcp: MCP `audio` blocks and `video/*` / `audio/*` embedded resources become audio / video parts instead of descriptions.
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Updated dependencies [179f891]
|
|
20
|
+
- @reinsjs/core@0.9.0
|
|
21
|
+
|
|
22
|
+
## 0.5.3
|
|
23
|
+
|
|
24
|
+
### Patch Changes
|
|
25
|
+
|
|
26
|
+
- Updated dependencies [54fed37]
|
|
27
|
+
- @reinsjs/core@0.8.0
|
|
28
|
+
|
|
3
29
|
## 0.5.2
|
|
4
30
|
|
|
5
31
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -64,6 +64,7 @@ No `node:*`, no `process`, no `Buffer` — the same `dist/index.js` runs on Node
|
|
|
64
64
|
| `apiKey` | required; use `auth: "none"` when the credential lives in `headers` (Cloudflare AI Gateway's `cf-aig-authorization`) |
|
|
65
65
|
| `baseUrl` | protocol root; `/chat/completions` (OpenAI: `…/v1`, DeepSeek: the bare host), `/messages` (Anthropic: `…/v1`) or `/responses` (OpenAI: `…/v1`) is appended |
|
|
66
66
|
| `contextWindow`, `maxOutputTokens`, `reasoning`, `images`, `cost`, `midConversationSystem` | override the built-in table; unknown models start from conservative defaults (128k / 16k / no reasoning / no images) |
|
|
67
|
+
| `video`, `audio` | whether the model takes video / audio content parts (default `false` everywhere, including the built-in table). See "Video and audio" below before turning them on |
|
|
67
68
|
| `chat.reasoningContent` | DeepSeek dialect: replay `reasoning_content` (on by default in `deepseek()`, see below) |
|
|
68
69
|
| `chat.liftToolImages` | when the model takes images, move images in tool results into a `user` message right after the batch of `tool` messages (default `true`); set `false` for an upstream that rejects that shape and images become a placeholder again |
|
|
69
70
|
| `anthropic.betas` | values for the `anthropic-beta` header; sent only when set (mid-conversation system needs none) |
|
|
@@ -110,6 +111,14 @@ Declared in `LOSS_MATRIX["openai-responses"]`, cell for cell comparable with `@r
|
|
|
110
111
|
- Usage: `input_tokens` includes cached and cache-write tokens, so `input` is `input_tokens − cached_tokens − cache_write_tokens`, with the two mapped to `cacheRead` / `cacheWrite`. `status: "incomplete"` with `max_output_tokens` is `length`; with `content_filter` a non-retryable `error`; `response.failed` and `error` frames are errors carrying the provider's code and message. Automatic prefix caching is best-effort on OpenAI's side; pass `prompt_cache_key` in `requestOptions` to improve hit rates.
|
|
111
112
|
- Built-in table: the gpt-5 family (5.5 / 5.4 / 5.4-mini / 5.2 / 5.1 / 5 / 5-mini / 5-nano), o3 / o4-mini and gpt-4.1 / 4.1-mini / 4o-mini on Responses; the same OpenAI ids also exist as Chat Completions entries, which `openaiChat()` picks by protocol. A bare `{ provider: "openai", id }` on a `FetchLowering` you construct yourself resolves to Responses.
|
|
112
113
|
|
|
114
|
+
## Video and audio
|
|
115
|
+
|
|
116
|
+
`video` and `audio` content parts follow one rule on all three protocols: when the model declares `video: true` / `audio: true` they travel in that protocol's **image slot** with their own mime type (Chat `image_url` data URI, Responses `input_image`, Anthropic `image` block — cache breakpoints still apply); otherwise they become a placeholder such as `[video omitted: this model does not accept video (video/mp4, 72 s)]` and the event is `lossy`. On Chat, video and audio in tool results are moved after the batch like images, labelled by kind (`video 2:`) with an "N attachment(s)" header; a result with images only is lowered exactly as before.
|
|
117
|
+
|
|
118
|
+
- **This is a relay dialect.** The image-slot shape is what OpenAI-compatible relays in front of Gemini accept; the official OpenAI, Anthropic and DeepSeek endpoints reject it. Only declare `video` / `audio` for an endpoint you have verified (the landing note says "relay dialect"), and re-check when the relay changes (`spikes/media-parts/`).
|
|
119
|
+
- **Never `input_audio`.** The layer deliberately does not use it: the relay we measured answers 200 to `input_audio` but silently drops the audio, and the model then makes up what it "heard" — worse than an error.
|
|
120
|
+
- `deepseek-v4-pro` takes text only (its `/models` entry lists no image input; images were silently dropped), so the built-in table says `images: false` and images become placeholders; pass `images: true` only if that changes.
|
|
121
|
+
|
|
113
122
|
## Errors and retries
|
|
114
123
|
|
|
115
124
|
Non-2xx responses throw `HttpError` with `status`, `headers` and the raw body (`"<status> <body>"`, the same shape the official SDKs use), so `runLoop`'s transient-failure rule applies unchanged: 408 / 409 / 429 / 5xx retry, everything else does not. Network failures propagate from `fetch` untouched.
|
package/dist/index.d.ts
CHANGED
|
@@ -196,6 +196,13 @@ interface FetchModel {
|
|
|
196
196
|
/** 模型会产出 thinking / reasoning */
|
|
197
197
|
reasoning: boolean;
|
|
198
198
|
images?: boolean;
|
|
199
|
+
/**
|
|
200
|
+
* 收不收视频 / 音频片段(2026-11-05);缺省 false,不收时落文字占位并记 lossy。
|
|
201
|
+
* ⚠️ 收的话三条线都放进图片槽——这是中转站方言(P0 实测公司中转站 Gemini 认),三家官方端点都不收,
|
|
202
|
+
* 所以内置表一律不开,只对确认收的中转站模型声明。视频里的音轨不要求 `audio`
|
|
203
|
+
*/
|
|
204
|
+
video?: boolean;
|
|
205
|
+
audio?: boolean;
|
|
199
206
|
cost?: ModelCost;
|
|
200
207
|
/** 额外请求头(私有网关鉴权等),与降级层级别的 headers 合并、以模型级为准 */
|
|
201
208
|
headers?: Record<string, string>;
|
|
@@ -561,6 +568,9 @@ interface ModelOptions {
|
|
|
561
568
|
maxOutputTokens?: number;
|
|
562
569
|
reasoning?: boolean;
|
|
563
570
|
images?: boolean;
|
|
571
|
+
/** 收不收视频 / 音频;缺省 false。⚠️ 走图片槽是中转站方言,只对确认收的中转站模型声明,见 models.ts FetchModel.video */
|
|
572
|
+
video?: boolean;
|
|
573
|
+
audio?: boolean;
|
|
564
574
|
cost?: ModelCost;
|
|
565
575
|
/** 上游是否接受中途 role:"system";Chat 缺省 true,Anthropic 按模型族推断 */
|
|
566
576
|
midConversationSystem?: boolean;
|