@oh-my-pi/pi-ai 16.4.6 → 16.5.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 +18 -0
- package/dist/types/auth-gateway/http.d.ts +18 -1
- package/dist/types/providers/google-auth.d.ts +0 -8
- package/dist/types/providers/google-shared.d.ts +0 -13
- package/dist/types/types.d.ts +0 -16
- package/package.json +7 -7
- package/src/auth-gateway/http.ts +35 -2
- package/src/auth-gateway/server.ts +23 -3
- package/src/error/provider.ts +5 -4
- package/src/providers/google-auth.ts +0 -20
- package/src/providers/google-shared.ts +0 -13
- package/src/providers/google-vertex.ts +62 -108
- package/src/providers/google.ts +11 -51
- package/src/providers/openai-codex/request-transformer.ts +1 -1
- package/src/stream.ts +0 -3
- package/src/types.ts +0 -16
- package/dist/types/providers/google-interactions.d.ts +0 -65
- package/src/providers/google-interactions.ts +0 -753
package/src/stream.ts
CHANGED
|
@@ -1432,9 +1432,6 @@ function mapOptionsForApi<TApi extends Api>(
|
|
|
1432
1432
|
streamFirstEventTimeoutMs: options?.streamFirstEventTimeoutMs,
|
|
1433
1433
|
streamIdleTimeoutMs: options?.streamIdleTimeoutMs,
|
|
1434
1434
|
providerSessionState: options?.providerSessionState,
|
|
1435
|
-
useInteractionsApi: options?.useInteractionsApi,
|
|
1436
|
-
storeInteraction: options?.storeInteraction,
|
|
1437
|
-
previousInteractionId: options?.previousInteractionId,
|
|
1438
1435
|
maxInFlightRequests: options?.maxInFlightRequests,
|
|
1439
1436
|
onPayload: options?.onPayload,
|
|
1440
1437
|
onResponse: options?.onResponse,
|
package/src/types.ts
CHANGED
|
@@ -424,22 +424,6 @@ export interface StreamOptions {
|
|
|
424
424
|
providerSessionState?: Map<string, ProviderSessionState>;
|
|
425
425
|
/** Canonical Codex compaction classification; ignored by other providers. */
|
|
426
426
|
codexCompaction?: CodexCompactionRequestContext;
|
|
427
|
-
/**
|
|
428
|
-
* Force Gemini model-mode Interactions API transport for providers that support it.
|
|
429
|
-
* When unset, those providers may still use Interactions to continue known
|
|
430
|
-
* server-side conversation lineage via `previousInteractionId` or stored state.
|
|
431
|
-
*/
|
|
432
|
-
useInteractionsApi?: boolean;
|
|
433
|
-
/**
|
|
434
|
-
* Whether supported Interactions transports should store server-side conversation
|
|
435
|
-
* state and return response ids for follow-up turns. Defaults to true.
|
|
436
|
-
*/
|
|
437
|
-
storeInteraction?: boolean;
|
|
438
|
-
/**
|
|
439
|
-
* Explicit Interactions response id to continue. Mutually exclusive with
|
|
440
|
-
* `storeInteraction: false` because the follow-up itself must be storable.
|
|
441
|
-
*/
|
|
442
|
-
previousInteractionId?: string;
|
|
443
427
|
/**
|
|
444
428
|
* Optional per-provider concurrent request cap for LLM stream calls. Keys are
|
|
445
429
|
* provider ids (`model.provider`); positive numeric values cap in-flight
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import type { Context, FetchImpl, Model, ProviderSessionState } from "../types.js";
|
|
2
|
-
import { AssistantMessageEventStream } from "../utils/event-stream.js";
|
|
3
|
-
import { type GoogleSharedStreamOptions } from "./google-shared.js";
|
|
4
|
-
type GoogleInteractionsApi = "google-generative-ai" | "google-vertex";
|
|
5
|
-
/** Provider session state storing the last Gemini Interactions response id. */
|
|
6
|
-
export interface GoogleInteractionsProviderSessionState extends ProviderSessionState {
|
|
7
|
-
lastInteractionId?: string;
|
|
8
|
-
}
|
|
9
|
-
/** Conversation anchor for continuing an Interactions turn from a prior assistant response. */
|
|
10
|
-
export interface InteractionAnchor {
|
|
11
|
-
id?: string;
|
|
12
|
-
messageIndex?: number;
|
|
13
|
-
}
|
|
14
|
-
/** Provider-specific URL, headers, and fetch implementation for an Interactions request. */
|
|
15
|
-
export interface GoogleInteractionsPlan {
|
|
16
|
-
url: string;
|
|
17
|
-
headers: Record<string, string>;
|
|
18
|
-
fetch?: FetchImpl;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Streams Gemini Interactions API model-mode responses for direct Google and Vertex providers.
|
|
22
|
-
*
|
|
23
|
-
* `fallback`, when supplied, is the legacy `:streamGenerateContent` stream factory. It runs
|
|
24
|
-
* transparently — forwarding its events into this stream — when the Interactions attempt fails
|
|
25
|
-
* before any content is emitted with a signal that the model/endpoint does not support
|
|
26
|
-
* Interactions (HTTP 404/400). Provide it only for auto-selected Interactions requests so an
|
|
27
|
-
* explicit `useInteractionsApi: true` still surfaces failures.
|
|
28
|
-
*/
|
|
29
|
-
export declare function streamGoogleInteractions<T extends GoogleInteractionsApi>(args: {
|
|
30
|
-
model: Model<T>;
|
|
31
|
-
context: Context;
|
|
32
|
-
options: GoogleSharedStreamOptions | undefined;
|
|
33
|
-
api: T;
|
|
34
|
-
anchor: InteractionAnchor;
|
|
35
|
-
state: GoogleInteractionsProviderSessionState | undefined;
|
|
36
|
-
prepare: () => GoogleInteractionsPlan | Promise<GoogleInteractionsPlan>;
|
|
37
|
-
fallback?: () => AssistantMessageEventStream;
|
|
38
|
-
}): AssistantMessageEventStream;
|
|
39
|
-
/**
|
|
40
|
-
* Whether a model is served by the Gemini Interactions API. Interactions is a Gemini 3-era
|
|
41
|
-
* transport, so the catalog subset that supports it is Gemini 3.0+. Older Gemini and non-Gemini
|
|
42
|
-
* ids keep `:streamGenerateContent`, which covers the full catalog.
|
|
43
|
-
*/
|
|
44
|
-
export declare function modelSupportsInteractions(model: Pick<Model, "id">): boolean;
|
|
45
|
-
/**
|
|
46
|
-
* Resolves whether a Google provider call should use Interactions and which lineage anchor to send.
|
|
47
|
-
*
|
|
48
|
-
* Precedence: explicit `useInteractionsApi: false` always wins (force generateContent); otherwise
|
|
49
|
-
* Interactions engages when explicitly requested, when continuing a stored interaction
|
|
50
|
-
* (`previousInteractionId`/assistant lineage/session state), or when `autoEligible` (the
|
|
51
|
-
* zero-config default for the capable model subset on the official endpoint). `auto` flags the
|
|
52
|
-
* last case for the caller — it is the only mode that wires up the generateContent fallback.
|
|
53
|
-
*/
|
|
54
|
-
export declare function resolveInteractionDispatch(args: {
|
|
55
|
-
context: Context;
|
|
56
|
-
options: GoogleSharedStreamOptions | undefined;
|
|
57
|
-
provider: string;
|
|
58
|
-
autoEligible: boolean;
|
|
59
|
-
}): {
|
|
60
|
-
useInteractions: boolean;
|
|
61
|
-
auto: boolean;
|
|
62
|
-
anchor: InteractionAnchor;
|
|
63
|
-
state: GoogleInteractionsProviderSessionState | undefined;
|
|
64
|
-
};
|
|
65
|
-
export {};
|