@oh-my-pi/pi-ai 8.0.15 → 8.0.16

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oh-my-pi/pi-ai",
3
- "version": "8.0.15",
3
+ "version": "8.0.16",
4
4
  "description": "Unified LLM API with automatic model discovery and provider configuration",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
@@ -19,7 +19,7 @@
19
19
  "prepublishOnly": "cp tsconfig.publish.json tsconfig.json"
20
20
  },
21
21
  "dependencies": {
22
- "@oh-my-pi/pi-utils": "8.0.15",
22
+ "@oh-my-pi/pi-utils": "8.0.16",
23
23
  "@anthropic-ai/sdk": "0.71.2",
24
24
  "@aws-sdk/client-bedrock-runtime": "^3.968.0",
25
25
  "@bufbuild/protobuf": "^2.10.2",
@@ -18,7 +18,7 @@ import {
18
18
  ToolResultStatus,
19
19
  } from "@aws-sdk/client-bedrock-runtime";
20
20
 
21
- import { calculateCost } from "$ai/models";
21
+ import { calculateCost } from "@oh-my-pi/pi-ai/models";
22
22
  import type {
23
23
  Api,
24
24
  AssistantMessage,
@@ -34,10 +34,10 @@ import type {
34
34
  Tool,
35
35
  ToolCall,
36
36
  ToolResultMessage,
37
- } from "$ai/types";
38
- import { AssistantMessageEventStream } from "$ai/utils/event-stream";
39
- import { parseStreamingJson } from "$ai/utils/json-parse";
40
- import { sanitizeSurrogates } from "$ai/utils/sanitize-unicode";
37
+ } from "@oh-my-pi/pi-ai/types";
38
+ import { AssistantMessageEventStream } from "@oh-my-pi/pi-ai/utils/event-stream";
39
+ import { parseStreamingJson } from "@oh-my-pi/pi-ai/utils/json-parse";
40
+ import { sanitizeSurrogates } from "@oh-my-pi/pi-ai/utils/sanitize-unicode";
41
41
  import { transformMessages } from "./transform-messages";
42
42
 
43
43
  export interface BedrockOptions extends StreamOptions {
@@ -4,8 +4,8 @@ import type {
4
4
  MessageCreateParamsStreaming,
5
5
  MessageParam,
6
6
  } from "@anthropic-ai/sdk/resources/messages";
7
- import { calculateCost } from "$ai/models";
8
- import { getEnvApiKey, OUTPUT_FALLBACK_BUFFER } from "$ai/stream";
7
+ import { calculateCost } from "@oh-my-pi/pi-ai/models";
8
+ import { getEnvApiKey, OUTPUT_FALLBACK_BUFFER } from "@oh-my-pi/pi-ai/stream";
9
9
  import type {
10
10
  Api,
11
11
  AssistantMessage,
@@ -21,11 +21,11 @@ import type {
21
21
  Tool,
22
22
  ToolCall,
23
23
  ToolResultMessage,
24
- } from "$ai/types";
25
- import { AssistantMessageEventStream } from "$ai/utils/event-stream";
26
- import { parseStreamingJson } from "$ai/utils/json-parse";
27
- import { formatErrorMessageWithRetryAfter } from "$ai/utils/retry-after";
28
- import { sanitizeSurrogates } from "$ai/utils/sanitize-unicode";
24
+ } from "@oh-my-pi/pi-ai/types";
25
+ import { AssistantMessageEventStream } from "@oh-my-pi/pi-ai/utils/event-stream";
26
+ import { parseStreamingJson } from "@oh-my-pi/pi-ai/utils/json-parse";
27
+ import { formatErrorMessageWithRetryAfter } from "@oh-my-pi/pi-ai/utils/retry-after";
28
+ import { sanitizeSurrogates } from "@oh-my-pi/pi-ai/utils/sanitize-unicode";
29
29
 
30
30
  import { transformMessages } from "./transform-messages";
31
31
 
@@ -4,7 +4,7 @@ import http2 from "node:http2";
4
4
  import { create, fromBinary, fromJson, type JsonValue, toBinary, toJson } from "@bufbuild/protobuf";
5
5
  import { ValueSchema } from "@bufbuild/protobuf/wkt";
6
6
  import JSON5 from "json5";
7
- import { calculateCost } from "$ai/models";
7
+ import { calculateCost } from "@oh-my-pi/pi-ai/models";
8
8
  import type {
9
9
  Api,
10
10
  AssistantMessage,
@@ -23,10 +23,10 @@ import type {
23
23
  Tool,
24
24
  ToolCall,
25
25
  ToolResultMessage,
26
- } from "$ai/types";
27
- import { AssistantMessageEventStream } from "$ai/utils/event-stream";
28
- import { parseStreamingJson } from "$ai/utils/json-parse";
29
- import { formatErrorMessageWithRetryAfter } from "$ai/utils/retry-after";
26
+ } from "@oh-my-pi/pi-ai/types";
27
+ import { AssistantMessageEventStream } from "@oh-my-pi/pi-ai/utils/event-stream";
28
+ import { parseStreamingJson } from "@oh-my-pi/pi-ai/utils/json-parse";
29
+ import { formatErrorMessageWithRetryAfter } from "@oh-my-pi/pi-ai/utils/retry-after";
30
30
  import type { McpToolDefinition } from "./cursor/gen/agent_pb";
31
31
  import {
32
32
  AgentClientMessageSchema,
@@ -6,8 +6,8 @@ import type {
6
6
  UsageProvider,
7
7
  UsageReport,
8
8
  UsageWindow,
9
- } from "$ai/usage";
10
- import { refreshGoogleCloudToken } from "$ai/utils/oauth/google-gemini-cli";
9
+ } from "@oh-my-pi/pi-ai/usage";
10
+ import { refreshGoogleCloudToken } from "@oh-my-pi/pi-ai/utils/oauth/google-gemini-cli";
11
11
 
12
12
  const DEFAULT_ENDPOINT = "https://cloudcode-pa.googleapis.com";
13
13
  const CACHE_TTL_MS = 60_000;
@@ -7,7 +7,7 @@
7
7
  import { createHash } from "node:crypto";
8
8
  import type { Content, ThinkingConfig } from "@google/genai";
9
9
  import { abortableSleep } from "@oh-my-pi/pi-utils";
10
- import { calculateCost } from "$ai/models";
10
+ import { calculateCost } from "@oh-my-pi/pi-ai/models";
11
11
  import type {
12
12
  Api,
13
13
  AssistantMessage,
@@ -18,9 +18,9 @@ import type {
18
18
  TextContent,
19
19
  ThinkingContent,
20
20
  ToolCall,
21
- } from "$ai/types";
22
- import { AssistantMessageEventStream } from "$ai/utils/event-stream";
23
- import { sanitizeSurrogates } from "$ai/utils/sanitize-unicode";
21
+ } from "@oh-my-pi/pi-ai/types";
22
+ import { AssistantMessageEventStream } from "@oh-my-pi/pi-ai/utils/event-stream";
23
+ import { sanitizeSurrogates } from "@oh-my-pi/pi-ai/utils/sanitize-unicode";
24
24
  import {
25
25
  convertMessages,
26
26
  convertTools,
@@ -3,8 +3,8 @@
3
3
  */
4
4
 
5
5
  import { type Content, FinishReason, FunctionCallingConfigMode, type Part, type Schema } from "@google/genai";
6
- import type { Context, ImageContent, Model, StopReason, TextContent, Tool } from "$ai/types";
7
- import { sanitizeSurrogates } from "$ai/utils/sanitize-unicode";
6
+ import type { Context, ImageContent, Model, StopReason, TextContent, Tool } from "@oh-my-pi/pi-ai/types";
7
+ import { sanitizeSurrogates } from "@oh-my-pi/pi-ai/utils/sanitize-unicode";
8
8
  import { transformMessages } from "./transform-messages";
9
9
 
10
10
  type GoogleApiType = "google-generative-ai" | "google-gemini-cli" | "google-vertex";
@@ -5,7 +5,7 @@ import {
5
5
  type ThinkingConfig,
6
6
  ThinkingLevel,
7
7
  } from "@google/genai";
8
- import { calculateCost } from "$ai/models";
8
+ import { calculateCost } from "@oh-my-pi/pi-ai/models";
9
9
  import type {
10
10
  Api,
11
11
  AssistantMessage,
@@ -16,10 +16,10 @@ import type {
16
16
  TextContent,
17
17
  ThinkingContent,
18
18
  ToolCall,
19
- } from "$ai/types";
20
- import { AssistantMessageEventStream } from "$ai/utils/event-stream";
21
- import { formatErrorMessageWithRetryAfter } from "$ai/utils/retry-after";
22
- import { sanitizeSurrogates } from "$ai/utils/sanitize-unicode";
19
+ } from "@oh-my-pi/pi-ai/types";
20
+ import { AssistantMessageEventStream } from "@oh-my-pi/pi-ai/utils/event-stream";
21
+ import { formatErrorMessageWithRetryAfter } from "@oh-my-pi/pi-ai/utils/retry-after";
22
+ import { sanitizeSurrogates } from "@oh-my-pi/pi-ai/utils/sanitize-unicode";
23
23
  import type { GoogleThinkingLevel } from "./google-gemini-cli";
24
24
  import {
25
25
  convertMessages,
@@ -4,8 +4,8 @@ import {
4
4
  GoogleGenAI,
5
5
  type ThinkingConfig,
6
6
  } from "@google/genai";
7
- import { calculateCost } from "$ai/models";
8
- import { getEnvApiKey } from "$ai/stream";
7
+ import { calculateCost } from "@oh-my-pi/pi-ai/models";
8
+ import { getEnvApiKey } from "@oh-my-pi/pi-ai/stream";
9
9
  import type {
10
10
  Api,
11
11
  AssistantMessage,
@@ -16,10 +16,10 @@ import type {
16
16
  TextContent,
17
17
  ThinkingContent,
18
18
  ToolCall,
19
- } from "$ai/types";
20
- import { AssistantMessageEventStream } from "$ai/utils/event-stream";
21
- import { formatErrorMessageWithRetryAfter } from "$ai/utils/retry-after";
22
- import { sanitizeSurrogates } from "$ai/utils/sanitize-unicode";
19
+ } from "@oh-my-pi/pi-ai/types";
20
+ import { AssistantMessageEventStream } from "@oh-my-pi/pi-ai/utils/event-stream";
21
+ import { formatErrorMessageWithRetryAfter } from "@oh-my-pi/pi-ai/utils/retry-after";
22
+ import { sanitizeSurrogates } from "@oh-my-pi/pi-ai/utils/sanitize-unicode";
23
23
  import type { GoogleThinkingLevel } from "./google-gemini-cli";
24
24
  import {
25
25
  convertMessages,
@@ -9,8 +9,8 @@ import type {
9
9
  ResponseOutputMessage,
10
10
  ResponseReasoningItem,
11
11
  } from "openai/resources/responses/responses";
12
- import { calculateCost } from "$ai/models";
13
- import { getEnvApiKey } from "$ai/stream";
12
+ import { calculateCost } from "@oh-my-pi/pi-ai/models";
13
+ import { getEnvApiKey } from "@oh-my-pi/pi-ai/stream";
14
14
  import type {
15
15
  Api,
16
16
  AssistantMessage,
@@ -23,11 +23,11 @@ import type {
23
23
  ThinkingContent,
24
24
  Tool,
25
25
  ToolCall,
26
- } from "$ai/types";
27
- import { AssistantMessageEventStream } from "$ai/utils/event-stream";
28
- import { parseStreamingJson } from "$ai/utils/json-parse";
29
- import { formatErrorMessageWithRetryAfter } from "$ai/utils/retry-after";
30
- import { sanitizeSurrogates } from "$ai/utils/sanitize-unicode";
26
+ } from "@oh-my-pi/pi-ai/types";
27
+ import { AssistantMessageEventStream } from "@oh-my-pi/pi-ai/utils/event-stream";
28
+ import { parseStreamingJson } from "@oh-my-pi/pi-ai/utils/json-parse";
29
+ import { formatErrorMessageWithRetryAfter } from "@oh-my-pi/pi-ai/utils/retry-after";
30
+ import { sanitizeSurrogates } from "@oh-my-pi/pi-ai/utils/sanitize-unicode";
31
31
  import packageJson from "../../package.json" with { type: "json" };
32
32
  import {
33
33
  CODEX_BASE_URL,
@@ -8,8 +8,8 @@ import type {
8
8
  ChatCompletionMessageParam,
9
9
  ChatCompletionToolMessageParam,
10
10
  } from "openai/resources/chat/completions";
11
- import { calculateCost } from "$ai/models";
12
- import { getEnvApiKey } from "$ai/stream";
11
+ import { calculateCost } from "@oh-my-pi/pi-ai/models";
12
+ import { getEnvApiKey } from "@oh-my-pi/pi-ai/stream";
13
13
  import type {
14
14
  AssistantMessage,
15
15
  Context,
@@ -24,11 +24,11 @@ import type {
24
24
  Tool,
25
25
  ToolCall,
26
26
  ToolResultMessage,
27
- } from "$ai/types";
28
- import { AssistantMessageEventStream } from "$ai/utils/event-stream";
29
- import { parseStreamingJson } from "$ai/utils/json-parse";
30
- import { formatErrorMessageWithRetryAfter } from "$ai/utils/retry-after";
31
- import { sanitizeSurrogates } from "$ai/utils/sanitize-unicode";
27
+ } from "@oh-my-pi/pi-ai/types";
28
+ import { AssistantMessageEventStream } from "@oh-my-pi/pi-ai/utils/event-stream";
29
+ import { parseStreamingJson } from "@oh-my-pi/pi-ai/utils/json-parse";
30
+ import { formatErrorMessageWithRetryAfter } from "@oh-my-pi/pi-ai/utils/retry-after";
31
+ import { sanitizeSurrogates } from "@oh-my-pi/pi-ai/utils/sanitize-unicode";
32
32
  import { transformMessages } from "./transform-messages";
33
33
 
34
34
  /**
@@ -10,8 +10,8 @@ import type {
10
10
  ResponseOutputMessage,
11
11
  ResponseReasoningItem,
12
12
  } from "openai/resources/responses/responses";
13
- import { calculateCost } from "$ai/models";
14
- import { getEnvApiKey } from "$ai/stream";
13
+ import { calculateCost } from "@oh-my-pi/pi-ai/models";
14
+ import { getEnvApiKey } from "@oh-my-pi/pi-ai/stream";
15
15
  import type {
16
16
  Api,
17
17
  AssistantMessage,
@@ -24,11 +24,11 @@ import type {
24
24
  ThinkingContent,
25
25
  Tool,
26
26
  ToolCall,
27
- } from "$ai/types";
28
- import { AssistantMessageEventStream } from "$ai/utils/event-stream";
29
- import { parseStreamingJson } from "$ai/utils/json-parse";
30
- import { formatErrorMessageWithRetryAfter } from "$ai/utils/retry-after";
31
- import { sanitizeSurrogates } from "$ai/utils/sanitize-unicode";
27
+ } from "@oh-my-pi/pi-ai/types";
28
+ import { AssistantMessageEventStream } from "@oh-my-pi/pi-ai/utils/event-stream";
29
+ import { parseStreamingJson } from "@oh-my-pi/pi-ai/utils/json-parse";
30
+ import { formatErrorMessageWithRetryAfter } from "@oh-my-pi/pi-ai/utils/retry-after";
31
+ import { sanitizeSurrogates } from "@oh-my-pi/pi-ai/utils/sanitize-unicode";
32
32
  import { transformMessages } from "./transform-messages";
33
33
 
34
34
  /** Fast deterministic hash to shorten long strings */
@@ -1,4 +1,4 @@
1
- import type { Api, AssistantMessage, Message, Model, ToolCall, ToolResultMessage } from "$ai/types";
1
+ import type { Api, AssistantMessage, Message, Model, ToolCall, ToolResultMessage } from "@oh-my-pi/pi-ai/types";
2
2
 
3
3
  /**
4
4
  * Normalize tool call ID for cross-provider compatibility.
@@ -7,7 +7,7 @@ import type {
7
7
  UsageReport,
8
8
  UsageStatus,
9
9
  UsageWindow,
10
- } from "$ai/usage";
10
+ } from "@oh-my-pi/pi-ai/usage";
11
11
 
12
12
  const DEFAULT_ENDPOINT = "https://api.anthropic.com/api/oauth";
13
13
  const DEFAULT_CACHE_TTL_MS = 60_000;
@@ -14,7 +14,7 @@ import type {
14
14
  UsageReport,
15
15
  UsageStatus,
16
16
  UsageWindow,
17
- } from "$ai/usage";
17
+ } from "@oh-my-pi/pi-ai/usage";
18
18
 
19
19
  const COPILOT_HEADERS = {
20
20
  "User-Agent": "GitHubCopilotChat/0.35.0",
@@ -7,8 +7,8 @@ import type {
7
7
  UsageReport,
8
8
  UsageStatus,
9
9
  UsageWindow,
10
- } from "$ai/usage";
11
- import { refreshAntigravityToken } from "$ai/utils/oauth/google-antigravity";
10
+ } from "@oh-my-pi/pi-ai/usage";
11
+ import { refreshAntigravityToken } from "@oh-my-pi/pi-ai/utils/oauth/google-antigravity";
12
12
 
13
13
  interface AntigravityQuotaInfo {
14
14
  remainingFraction?: number;
@@ -1,5 +1,5 @@
1
1
  import { Buffer } from "node:buffer";
2
- import { CODEX_BASE_URL } from "$ai/providers/openai-codex/constants";
2
+ import { CODEX_BASE_URL } from "@oh-my-pi/pi-ai/providers/openai-codex/constants";
3
3
  import type {
4
4
  UsageAmount,
5
5
  UsageCache,
@@ -9,7 +9,7 @@ import type {
9
9
  UsageProvider,
10
10
  UsageReport,
11
11
  UsageWindow,
12
- } from "$ai/usage";
12
+ } from "@oh-my-pi/pi-ai/usage";
13
13
 
14
14
  const CODEX_USAGE_PATH = "wham/usage";
15
15
  const DEFAULT_CACHE_TTL_MS = 60_000;
package/src/usage/zai.ts CHANGED
@@ -7,7 +7,7 @@ import type {
7
7
  UsageReport,
8
8
  UsageStatus,
9
9
  UsageWindow,
10
- } from "$ai/usage";
10
+ } from "@oh-my-pi/pi-ai/usage";
11
11
 
12
12
  const DEFAULT_ENDPOINT = "https://api.z.ai";
13
13
  const QUOTA_PATH = "/api/monitor/usage/quota/limit";
@@ -1,4 +1,4 @@
1
- import type { AssistantMessage, AssistantMessageEvent } from "$ai/types";
1
+ import type { AssistantMessage, AssistantMessageEvent } from "@oh-my-pi/pi-ai/types";
2
2
 
3
3
  // Generic event stream class for async iteration
4
4
  export class EventStream<T, R = T> implements AsyncIterable<T> {
@@ -3,7 +3,7 @@
3
3
  */
4
4
 
5
5
  import { abortableSleep } from "@oh-my-pi/pi-utils";
6
- import { getModels } from "$ai/models";
6
+ import { getModels } from "@oh-my-pi/pi-ai/models";
7
7
  import type { OAuthCredentials } from "./types";
8
8
 
9
9
  const decode = (s: string) => atob(s);
@@ -1,4 +1,4 @@
1
- import type { AssistantMessage } from "$ai/types";
1
+ import type { AssistantMessage } from "@oh-my-pi/pi-ai/types";
2
2
 
3
3
  /**
4
4
  * Regex patterns to detect context overflow errors from different providers.
@@ -5,7 +5,7 @@ import addFormatsModule from "ajv-formats";
5
5
  const Ajv = (AjvModule as any).default || AjvModule;
6
6
  const addFormats = (addFormatsModule as any).default || addFormatsModule;
7
7
 
8
- import type { Tool, ToolCall } from "$ai/types";
8
+ import type { Tool, ToolCall } from "@oh-my-pi/pi-ai/types";
9
9
 
10
10
  // ============================================================================
11
11
  // Type Coercion Utilities