@ssweens/pi-vertex 1.1.13 → 1.3.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 +111 -0
- package/README.md +66 -35
- package/TEST_COVERAGE.md +22 -2
- package/auth.ts +1 -1
- package/config.ts +1 -1
- package/index.ts +16 -7
- package/models/claude.ts +188 -22
- package/models/gemini.ts +171 -42
- package/models/maas.ts +127 -261
- package/package.json +15 -6
- package/streaming/gemini.ts +69 -34
- package/streaming/index.ts +30 -1
- package/streaming/maas.ts +71 -33
- package/streaming/sse-comment-filter.ts +169 -0
- package/tests/first-byte-timeout-check.mjs +53 -0
- package/types.ts +22 -2
- package/utils.ts +5 -3
package/types.ts
CHANGED
|
@@ -22,13 +22,26 @@ export type {
|
|
|
22
22
|
ToolResultMessage,
|
|
23
23
|
Usage,
|
|
24
24
|
UserMessage,
|
|
25
|
-
} from "@
|
|
25
|
+
} from "@earendil-works/pi-ai";
|
|
26
|
+
|
|
27
|
+
import type { ThinkingLevel, ThinkingLevelMap } from "@earendil-works/pi-ai";
|
|
26
28
|
|
|
27
29
|
// Vertex-specific types
|
|
28
30
|
|
|
31
|
+
/**
|
|
32
|
+
* Mirrors pi-ai's `Model["input"]`, which is `("text" | "image")[]`.
|
|
33
|
+
* Do not widen: pi-coding-agent rejects any other modality at registration.
|
|
34
|
+
*/
|
|
29
35
|
export type ModelInputType = "text" | "image";
|
|
30
36
|
export type EndpointType = "gemini" | "maas";
|
|
31
37
|
|
|
38
|
+
/**
|
|
39
|
+
* Wire API for non-Anthropic MaaS models. Most use the OpenAI-compatible Chat
|
|
40
|
+
* Completions endpoint (`/endpoints/openapi`); some publishers (Meta Muse) only
|
|
41
|
+
* serve the OpenAI-compatible Responses API (`/publishers/{publisher}/v1/responses`).
|
|
42
|
+
*/
|
|
43
|
+
export type MaasApi = "chat-completions" | "responses";
|
|
44
|
+
|
|
32
45
|
export interface ModelCost {
|
|
33
46
|
input: number;
|
|
34
47
|
output: number;
|
|
@@ -59,6 +72,13 @@ export interface VertexModelConfig {
|
|
|
59
72
|
*/
|
|
60
73
|
costRegional?: ModelCost;
|
|
61
74
|
region: string;
|
|
75
|
+
/**
|
|
76
|
+
* Pi thinking level → provider level. Passed to Pi so the selector offers only
|
|
77
|
+
* supported levels: `null` hides a level, and `xhigh`/`max` appear only when set.
|
|
78
|
+
*/
|
|
79
|
+
thinkingLevelMap?: ThinkingLevelMap;
|
|
80
|
+
/** Non-Anthropic MaaS wire API. Default: "chat-completions". */
|
|
81
|
+
maasApi?: MaasApi;
|
|
62
82
|
}
|
|
63
83
|
|
|
64
84
|
export interface AuthConfig {
|
|
@@ -70,6 +90,6 @@ export interface AuthConfig {
|
|
|
70
90
|
export interface StreamOptions {
|
|
71
91
|
maxTokens?: number;
|
|
72
92
|
temperature?: number;
|
|
73
|
-
reasoning?:
|
|
93
|
+
reasoning?: ThinkingLevel;
|
|
74
94
|
signal?: AbortSignal;
|
|
75
95
|
}
|
package/utils.ts
CHANGED
|
@@ -80,7 +80,9 @@ function supportsMultimodalFunctionResponse(modelId: string): boolean {
|
|
|
80
80
|
*/
|
|
81
81
|
export function convertToGeminiMessages(messages: Message[], modelId: string): GeminiContent[] {
|
|
82
82
|
const result: GeminiContent[] = [];
|
|
83
|
-
|
|
83
|
+
// Gemini 3 and 4 require thoughtSignature on all functionCall parts.
|
|
84
|
+
const requiresThoughtSignature =
|
|
85
|
+
modelId.startsWith("gemini-3") || modelId.startsWith("gemini-4");
|
|
84
86
|
let pendingToolCalls: ToolCall[] = [];
|
|
85
87
|
let existingToolResultIds = new Set<string>();
|
|
86
88
|
|
|
@@ -225,8 +227,8 @@ export function convertToGeminiMessages(messages: Message[], modelId: string): G
|
|
|
225
227
|
};
|
|
226
228
|
if (thoughtSig) {
|
|
227
229
|
part.thoughtSignature = thoughtSig;
|
|
228
|
-
} else if (
|
|
229
|
-
// Gemini 3
|
|
230
|
+
} else if (requiresThoughtSignature) {
|
|
231
|
+
// Gemini 3/4 require thoughtSignature on all functionCall parts.
|
|
230
232
|
// For cross-provider tool calls (or rare same-provider calls without signatures),
|
|
231
233
|
// use the documented escape hatch to bypass validation.
|
|
232
234
|
// See: https://docs.cloud.google.com/vertex-ai/generative-ai/docs/thought-signatures
|