@oh-my-pi/pi-ai 15.7.3 → 15.7.6
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 +14 -0
- package/dist/types/auth-gateway/types.d.ts +3 -1
- package/dist/types/providers/anthropic-messages-server-schema.d.ts +15 -0
- package/dist/types/types.d.ts +15 -0
- package/dist/types/utils/idle-iterator.d.ts +14 -0
- package/package.json +2 -2
- package/src/auth-gateway/server.ts +1 -0
- package/src/auth-gateway/types.ts +10 -1
- package/src/models.json +803 -84
- package/src/providers/anthropic-messages-server-schema.ts +13 -0
- package/src/providers/anthropic-messages-server.ts +3 -0
- package/src/providers/anthropic.ts +28 -4
- package/src/providers/azure-openai-responses.ts +3 -2
- package/src/providers/openai-codex-responses.ts +2 -2
- package/src/providers/openai-completions.ts +10 -9
- package/src/providers/openai-responses.ts +3 -2
- package/src/providers/register-builtins.ts +4 -1
- package/src/stream.ts +1 -0
- package/src/types.ts +16 -0
- package/src/utils/idle-iterator.ts +27 -0
- package/src/utils/oauth/anthropic.ts +1 -1
- package/src/utils/oauth/xiaomi.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,9 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [15.7.5] - 2026-06-01
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- Added Anthropic task budget support, forwarding `taskBudget` as `output_config.task_budget` with the required `task-budgets-2026-03-13` beta header and accepting Anthropic gateway requests that send `output_config.task_budget`.
|
|
10
|
+
|
|
11
|
+
### Fixed
|
|
12
|
+
|
|
13
|
+
- Fixed OpenAI-family first-event timeouts so `PI_OPENAI_STREAM_IDLE_TIMEOUT_MS` cannot be undercut by a lower generic `PI_STREAM_FIRST_EVENT_TIMEOUT_MS` while local OpenAI-compatible servers are still processing large prompts. `PI_OPENAI_STREAM_FIRST_EVENT_TIMEOUT_MS` is now available for an explicit OpenAI-specific first-event override. ([#1603](https://github.com/can1357/oh-my-pi/issues/1603))
|
|
14
|
+
|
|
15
|
+
## [15.7.4] - 2026-05-31
|
|
16
|
+
|
|
5
17
|
### Fixed
|
|
6
18
|
|
|
7
19
|
- Fixed Anthropic stream idle-timeout retries after the provider stream has already begun.
|
|
20
|
+
- Fixed Xiaomi MiMo `/login` rejecting token-plan (`tp-`) keys with `401 Invalid API Key`. The validation request was still sending the legacy Anthropic `x-api-key` header against the OpenAI-compatible `/v1/chat/completions` endpoint; switched to `Authorization: Bearer`, matching the runtime path. ([#1580](https://github.com/can1357/oh-my-pi/issues/1580))
|
|
21
|
+
- Fixed OpenAI-compatible tool-call replay to send empty assistant content instead of `null`, avoiding strict custom backends that crash with `str`/`NoneType` concatenation after subagent tool results. ([#1585](https://github.com/can1357/oh-my-pi/issues/1585))
|
|
8
22
|
|
|
9
23
|
## [15.7.3] - 2026-05-31
|
|
10
24
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Effort } from "../model-thinking";
|
|
2
|
-
import type { AssistantMessage, AssistantMessageEventStream, CacheRetention, Context, ServiceTier } from "../types";
|
|
2
|
+
import type { AssistantMessage, AssistantMessageEventStream, CacheRetention, Context, ServiceTier, TokenTaskBudget } from "../types";
|
|
3
3
|
/**
|
|
4
4
|
* Wire types for the omp auth-gateway.
|
|
5
5
|
*
|
|
@@ -54,6 +54,8 @@ export interface AuthGatewayParsedRequestOptions {
|
|
|
54
54
|
thinkingBudgets?: Partial<Record<Effort, number>>;
|
|
55
55
|
/** Suppress the provider's reasoning summary stream. */
|
|
56
56
|
hideThinkingSummary?: boolean;
|
|
57
|
+
/** Anthropic `output_config.task_budget` advisory loop budget. */
|
|
58
|
+
taskBudget?: TokenTaskBudget;
|
|
57
59
|
/** OpenAI service tier (auto|default|flex|scale|priority). */
|
|
58
60
|
serviceTier?: ServiceTier;
|
|
59
61
|
/** Cache retention hint derived from inbound `cache_control` markers. */
|
|
@@ -429,6 +429,21 @@ export declare const anthropicMessagesRequestSchema: z.ZodObject<{
|
|
|
429
429
|
budget_tokens: z.ZodOptional<z.ZodNumber>;
|
|
430
430
|
display: z.ZodOptional<z.ZodUnknown>;
|
|
431
431
|
}, z.core.$strip>], "type">>;
|
|
432
|
+
output_config: z.ZodOptional<z.ZodObject<{
|
|
433
|
+
effort: z.ZodOptional<z.ZodEnum<{
|
|
434
|
+
high: "high";
|
|
435
|
+
low: "low";
|
|
436
|
+
max: "max";
|
|
437
|
+
medium: "medium";
|
|
438
|
+
xhigh: "xhigh";
|
|
439
|
+
}>>;
|
|
440
|
+
task_budget: z.ZodOptional<z.ZodObject<{
|
|
441
|
+
type: z.ZodLiteral<"tokens">;
|
|
442
|
+
total: z.ZodNumber;
|
|
443
|
+
remaining: z.ZodOptional<z.ZodNumber>;
|
|
444
|
+
}, z.core.$strip>>;
|
|
445
|
+
format: z.ZodOptional<z.ZodUnknown>;
|
|
446
|
+
}, z.core.$strip>>;
|
|
432
447
|
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
433
448
|
container: z.ZodOptional<z.ZodUnknown>;
|
|
434
449
|
context_management: z.ZodOptional<z.ZodUnknown>;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -55,6 +55,11 @@ import type { Effort } from "./model-thinking";
|
|
|
55
55
|
export type ThinkingBudgets = {
|
|
56
56
|
[key in Effort]?: number;
|
|
57
57
|
};
|
|
58
|
+
export interface TokenTaskBudget {
|
|
59
|
+
type: "tokens";
|
|
60
|
+
total: number;
|
|
61
|
+
remaining?: number;
|
|
62
|
+
}
|
|
58
63
|
export type MessageAttribution = "user" | "agent";
|
|
59
64
|
export type ToolChoice = "auto" | "none" | "any" | "required" | {
|
|
60
65
|
type: "function";
|
|
@@ -184,6 +189,11 @@ export interface StreamOptions {
|
|
|
184
189
|
* For example, Anthropic uses `user_id` for abuse tracking and rate limiting.
|
|
185
190
|
*/
|
|
186
191
|
metadata?: Record<string, unknown>;
|
|
192
|
+
/**
|
|
193
|
+
* Advisory token budget for a full agentic loop. Anthropic encodes this as
|
|
194
|
+
* `output_config.task_budget` with the `task-budgets-2026-03-13` beta header.
|
|
195
|
+
*/
|
|
196
|
+
taskBudget?: TokenTaskBudget;
|
|
187
197
|
/**
|
|
188
198
|
* Optional session identifier for providers that support session-based
|
|
189
199
|
* routing, request affinity, or transport reuse. Providers may also use this
|
|
@@ -228,6 +238,11 @@ export interface StreamOptions {
|
|
|
228
238
|
* `0` to disable both layers for this request. After the first semantic
|
|
229
239
|
* event arrives, `streamIdleTimeoutMs` governs inter-event stalls. Falls
|
|
230
240
|
* back to `PI_STREAM_FIRST_EVENT_TIMEOUT_MS` and then to a 100s default.
|
|
241
|
+
* OpenAI-family transports additionally honor
|
|
242
|
+
* `PI_OPENAI_STREAM_FIRST_EVENT_TIMEOUT_MS` as the most-specific override and
|
|
243
|
+
* floor the first-event budget at the resolved idle (per-call
|
|
244
|
+
* `streamIdleTimeoutMs` or `PI_OPENAI_STREAM_IDLE_TIMEOUT_MS`) so slow local
|
|
245
|
+
* OpenAI-compatible servers are not undercut during prompt processing.
|
|
231
246
|
*
|
|
232
247
|
* Iterator-level honored by: every built-in provider (via the lazy-stream
|
|
233
248
|
* forwarder in `register-builtins`). SDK-request honored by:
|
|
@@ -32,6 +32,20 @@ export declare function getOpenAIStreamIdleTimeoutMs(fallbackMs?: number): numbe
|
|
|
32
32
|
* env overrides still trump the fallback.
|
|
33
33
|
*/
|
|
34
34
|
export declare function getStreamFirstEventTimeoutMs(idleTimeoutMs?: number, fallbackMs?: number): number | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* Returns the first-event timeout used for OpenAI-family streaming transports.
|
|
37
|
+
*
|
|
38
|
+
* Precedence: explicit `PI_OPENAI_STREAM_FIRST_EVENT_TIMEOUT_MS` (including a
|
|
39
|
+
* `"0"` disable) wins outright. Otherwise the resolved idle (caller-supplied
|
|
40
|
+
* `idleTimeoutMs` — which itself already encompasses per-call
|
|
41
|
+
* `streamIdleTimeoutMs` or `PI_OPENAI_STREAM_IDLE_TIMEOUT_MS` resolved
|
|
42
|
+
* upstream) floors the first-event budget so slow local OpenAI-compatible
|
|
43
|
+
* servers are not undercut by a shorter `PI_STREAM_FIRST_EVENT_TIMEOUT_MS`
|
|
44
|
+
* or the global default during prompt processing.
|
|
45
|
+
*
|
|
46
|
+
* Returns `undefined` when an explicit env knob disables the watchdog.
|
|
47
|
+
*/
|
|
48
|
+
export declare function getOpenAIStreamFirstEventTimeoutMs(idleTimeoutMs?: number, fallbackMs?: number): number | undefined;
|
|
35
49
|
export interface IdleTimeoutIteratorOptions {
|
|
36
50
|
idleTimeoutMs?: number;
|
|
37
51
|
firstItemTimeoutMs?: number;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@oh-my-pi/pi-ai",
|
|
4
|
-
"version": "15.7.
|
|
4
|
+
"version": "15.7.6",
|
|
5
5
|
"description": "Unified LLM API with automatic model discovery and provider configuration",
|
|
6
6
|
"homepage": "https://omp.sh",
|
|
7
7
|
"author": "Can Boluk",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@anthropic-ai/sdk": "^0.99.0",
|
|
42
42
|
"@bufbuild/protobuf": "^2.12.0",
|
|
43
|
-
"@oh-my-pi/pi-utils": "15.7.
|
|
43
|
+
"@oh-my-pi/pi-utils": "15.7.6",
|
|
44
44
|
"openai": "^6.39.0",
|
|
45
45
|
"partial-json": "^0.1.7",
|
|
46
46
|
"zod": "4.4.3"
|
|
@@ -141,6 +141,7 @@ function buildStreamOptions(parsed: ParsedFormatRequest, api: Api, signal: Abort
|
|
|
141
141
|
if (options.reasoning !== undefined) opts.reasoning = options.reasoning;
|
|
142
142
|
if (options.disableReasoning !== undefined) opts.disableReasoning = options.disableReasoning;
|
|
143
143
|
if (options.hideThinkingSummary !== undefined) opts.hideThinkingSummary = options.hideThinkingSummary;
|
|
144
|
+
if (options.taskBudget !== undefined) opts.taskBudget = options.taskBudget;
|
|
144
145
|
if (options.serviceTier !== undefined) opts.serviceTier = options.serviceTier;
|
|
145
146
|
if (options.cacheRetention !== undefined) opts.cacheRetention = options.cacheRetention;
|
|
146
147
|
// Client-supplied `prompt_cache_key` wins; otherwise derive a stable
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import type { Effort } from "../model-thinking";
|
|
2
|
-
import type {
|
|
2
|
+
import type {
|
|
3
|
+
AssistantMessage,
|
|
4
|
+
AssistantMessageEventStream,
|
|
5
|
+
CacheRetention,
|
|
6
|
+
Context,
|
|
7
|
+
ServiceTier,
|
|
8
|
+
TokenTaskBudget,
|
|
9
|
+
} from "../types";
|
|
3
10
|
|
|
4
11
|
/**
|
|
5
12
|
* Wire types for the omp auth-gateway.
|
|
@@ -61,6 +68,8 @@ export interface AuthGatewayParsedRequestOptions {
|
|
|
61
68
|
thinkingBudgets?: Partial<Record<Effort, number>>;
|
|
62
69
|
/** Suppress the provider's reasoning summary stream. */
|
|
63
70
|
hideThinkingSummary?: boolean;
|
|
71
|
+
/** Anthropic `output_config.task_budget` advisory loop budget. */
|
|
72
|
+
taskBudget?: TokenTaskBudget;
|
|
64
73
|
|
|
65
74
|
// ── Service / routing ─────────────────────────────────────────────────
|
|
66
75
|
/** OpenAI service tier (auto|default|flex|scale|priority). */
|