@reinsjs/lowering-fetch 0.5.3 → 0.6.1
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 +37 -0
- package/README.md +9 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +235 -99
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,42 @@
|
|
|
1
1
|
# @reinsjs/lowering-fetch
|
|
2
2
|
|
|
3
|
+
## 0.6.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 45bfc8d: Stop semantics, no replay of interrupted writes, a stop request in the server, and narrower resume validation.
|
|
8
|
+
|
|
9
|
+
- **Stop is a kind of abort.** `controller.abort(new RunStop())` makes every pause point close the pending tool calls with an error result ("Not executed: the run was stopped by the user…"; calls that had already started get "outcome unknown" or "interrupted"), so the next run asks the model directly instead of re-running what the user stopped. Approval-pending and client-tool calls are closed too. The result is still `paused` / `host` with the note `stopped by the user`. `new RunStop("host")` is for a host closing calls left by an interrupted run: the same closing, but the texts say an earlier run was interrupted instead of blaming the user (`stopTextsOf`). A run whose signal is already aborted when it starts no longer writes `core.tools_bound` or the tool-change note. Other abort reasons keep the old behaviour (pending calls are replayed on resume). An abort that lands while the request is still connecting now ends as `paused(host)` instead of `error`.
|
|
10
|
+
- **Interrupted writes are not replayed.** New `Tool.replayable` (default: only `risk: "low"` tools) and `isReplayable()`. Non-replayable tools get a model-invisible `core.tool_started` event before `execute`; on resume, a started call without a result is closed with "outcome unknown, check the current state before retrying" instead of running again. A signal-aware write tool cut off by an abort gets the same result instead of "Tool execution failed". Tools that do not declare `risk` now write one extra event per call.
|
|
11
|
+
- **Server stop request.** `POST { sessionId, stop: true }` answers JSON `{ status: "stopping" | "idle", sessionId }` without waiting for the run. `SessionAuthzInput.method` gains `"STOP"` — hooks that allow writes only for `"POST"` will refuse stop requests until they accept `"STOP"`.
|
|
12
|
+
- **`asTool`** declares `replayable: true`, resumes a child only when the parent already recorded `tool_started` for that call (a stopped expert's next task is no longer swallowed), and closes a child's leftover pending calls with `RunStop("host")` before starting a new task.
|
|
13
|
+
- **Narrower resume validation.** `SerializedRunState` gains optional `modelDigest` / `pendingToolsDigest` (included in the signature when present). States carrying them only check the model and the definitions of the tools behind the pending calls, so adding an unrelated tool no longer makes paused sessions answer `409 config_mismatch`; older states still compare the whole configuration hash.
|
|
14
|
+
- Lowerings and the AG-UI encoder declare landings for `core.tool_started` (dropped / `CUSTOM`). The TanStack adapter writes `tool_started` in `onBeforeToolCall` and applies the same no-replay rule; stop handling and resume validation stay out of its scope.
|
|
15
|
+
|
|
16
|
+
**Rollback risk:** sessions that contain `core.tool_started` cannot be read by `@reinsjs/core` 0.9 or earlier. Sessions paused inside a sub-agent before upgrading resume the child as a new task after upgrading; let them finish first.
|
|
17
|
+
|
|
18
|
+
- Updated dependencies [45bfc8d]
|
|
19
|
+
- @reinsjs/core@0.10.0
|
|
20
|
+
|
|
21
|
+
## 0.6.0
|
|
22
|
+
|
|
23
|
+
### Minor Changes
|
|
24
|
+
|
|
25
|
+
- 179f891: Video and audio content parts.
|
|
26
|
+
|
|
27
|
+
- 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.
|
|
28
|
+
- 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.
|
|
29
|
+
- lowering-pi: video / audio parts become placeholder text (`lossy`); pi-ai has no such content.
|
|
30
|
+
- server: the HTTP whitelist accepts `video` / `audio` parts with the same shape rules as core.
|
|
31
|
+
- 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.
|
|
32
|
+
- ui-agui: video / audio parts become `[video <mime>]` / `[audio <mime>]` placeholders, recorded in `dropped`.
|
|
33
|
+
- tools-mcp: MCP `audio` blocks and `video/*` / `audio/*` embedded resources become audio / video parts instead of descriptions.
|
|
34
|
+
|
|
35
|
+
### Patch Changes
|
|
36
|
+
|
|
37
|
+
- Updated dependencies [179f891]
|
|
38
|
+
- @reinsjs/core@0.9.0
|
|
39
|
+
|
|
3
40
|
## 0.5.3
|
|
4
41
|
|
|
5
42
|
### 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;
|