@oh-my-pi/pi-ai 14.5.3 → 14.5.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 CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [14.5.4] - 2026-04-28
6
+ ### Changed
7
+
8
+ - Changed OpenAI custom Lark grammar payloads to strip comments and blank lines before sending provider requests.
9
+
10
+ ### Fixed
11
+
12
+ - Fixed OpenAI Codex GPT model pricing by inheriting matching OpenAI catalog rates for zero-priced discovered Codex entries.
13
+
5
14
  ## [14.5.3] - 2026-04-27
6
15
  ### Added
7
16
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@oh-my-pi/pi-ai",
4
- "version": "14.5.3",
4
+ "version": "14.5.6",
5
5
  "description": "Unified LLM API with automatic model discovery and provider configuration",
6
6
  "homepage": "https://github.com/can1357/oh-my-pi",
7
7
  "author": "Can Boluk",
@@ -46,8 +46,8 @@
46
46
  "@aws-sdk/credential-provider-node": "^3.972.36",
47
47
  "@bufbuild/protobuf": "^2.12.0",
48
48
  "@google/genai": "^1.50.1",
49
- "@oh-my-pi/pi-natives": "14.5.3",
50
- "@oh-my-pi/pi-utils": "14.5.3",
49
+ "@oh-my-pi/pi-natives": "14.5.6",
50
+ "@oh-my-pi/pi-utils": "14.5.6",
51
51
  "@sinclair/typebox": "^0.34.49",
52
52
  "@smithy/node-http-handler": "^4.6.1",
53
53
  "ajv": "^8.20.0",
package/src/models.json CHANGED
@@ -33899,9 +33899,9 @@
33899
33899
  "image"
33900
33900
  ],
33901
33901
  "cost": {
33902
- "input": 0,
33903
- "output": 0,
33904
- "cacheRead": 0,
33902
+ "input": 1.25,
33903
+ "output": 10,
33904
+ "cacheRead": 0.125,
33905
33905
  "cacheWrite": 0
33906
33906
  },
33907
33907
  "contextWindow": 400000,
@@ -33927,9 +33927,9 @@
33927
33927
  "image"
33928
33928
  ],
33929
33929
  "cost": {
33930
- "input": 0,
33931
- "output": 0,
33932
- "cacheRead": 0,
33930
+ "input": 1.25,
33931
+ "output": 10,
33932
+ "cacheRead": 0.125,
33933
33933
  "cacheWrite": 0
33934
33934
  },
33935
33935
  "contextWindow": 272000,
@@ -33983,9 +33983,9 @@
33983
33983
  "image"
33984
33984
  ],
33985
33985
  "cost": {
33986
- "input": 0,
33987
- "output": 0,
33988
- "cacheRead": 0,
33986
+ "input": 1.25,
33987
+ "output": 10,
33988
+ "cacheRead": 0.13,
33989
33989
  "cacheWrite": 0
33990
33990
  },
33991
33991
  "contextWindow": 400000,
@@ -34011,9 +34011,9 @@
34011
34011
  "image"
34012
34012
  ],
34013
34013
  "cost": {
34014
- "input": 0,
34015
- "output": 0,
34016
- "cacheRead": 0,
34014
+ "input": 1.25,
34015
+ "output": 10,
34016
+ "cacheRead": 0.125,
34017
34017
  "cacheWrite": 0
34018
34018
  },
34019
34019
  "contextWindow": 272000,
@@ -34039,9 +34039,9 @@
34039
34039
  "image"
34040
34040
  ],
34041
34041
  "cost": {
34042
- "input": 0,
34043
- "output": 0,
34044
- "cacheRead": 0,
34042
+ "input": 1.25,
34043
+ "output": 10,
34044
+ "cacheRead": 0.125,
34045
34045
  "cacheWrite": 0
34046
34046
  },
34047
34047
  "contextWindow": 272000,
@@ -34067,9 +34067,9 @@
34067
34067
  "image"
34068
34068
  ],
34069
34069
  "cost": {
34070
- "input": 0,
34071
- "output": 0,
34072
- "cacheRead": 0,
34070
+ "input": 0.25,
34071
+ "output": 2,
34072
+ "cacheRead": 0.025,
34073
34073
  "cacheWrite": 0
34074
34074
  },
34075
34075
  "contextWindow": 272000,
@@ -34095,9 +34095,9 @@
34095
34095
  "image"
34096
34096
  ],
34097
34097
  "cost": {
34098
- "input": 0,
34099
- "output": 0,
34100
- "cacheRead": 0,
34098
+ "input": 1.75,
34099
+ "output": 14,
34100
+ "cacheRead": 0.175,
34101
34101
  "cacheWrite": 0
34102
34102
  },
34103
34103
  "contextWindow": 272000,
@@ -34123,9 +34123,9 @@
34123
34123
  "image"
34124
34124
  ],
34125
34125
  "cost": {
34126
- "input": 0,
34127
- "output": 0,
34128
- "cacheRead": 0,
34126
+ "input": 1.75,
34127
+ "output": 14,
34128
+ "cacheRead": 0.175,
34129
34129
  "cacheWrite": 0
34130
34130
  },
34131
34131
  "contextWindow": 272000,
@@ -34151,9 +34151,9 @@
34151
34151
  "image"
34152
34152
  ],
34153
34153
  "cost": {
34154
- "input": 0,
34155
- "output": 0,
34156
- "cacheRead": 0,
34154
+ "input": 1.75,
34155
+ "output": 14,
34156
+ "cacheRead": 0.175,
34157
34157
  "cacheWrite": 0
34158
34158
  },
34159
34159
  "contextWindow": 272000,
@@ -34206,9 +34206,9 @@
34206
34206
  "image"
34207
34207
  ],
34208
34208
  "cost": {
34209
- "input": 0,
34210
- "output": 0,
34211
- "cacheRead": 0,
34209
+ "input": 2.5,
34210
+ "output": 15,
34211
+ "cacheRead": 0.25,
34212
34212
  "cacheWrite": 0
34213
34213
  },
34214
34214
  "contextWindow": 272000,
@@ -34234,9 +34234,9 @@
34234
34234
  "image"
34235
34235
  ],
34236
34236
  "cost": {
34237
- "input": 0,
34238
- "output": 0,
34239
- "cacheRead": 0,
34237
+ "input": 0.75,
34238
+ "output": 4.5,
34239
+ "cacheRead": 0.075,
34240
34240
  "cacheWrite": 0
34241
34241
  },
34242
34242
  "contextWindow": 272000,
@@ -34262,9 +34262,9 @@
34262
34262
  "image"
34263
34263
  ],
34264
34264
  "cost": {
34265
- "input": 0,
34266
- "output": 0,
34267
- "cacheRead": 0,
34265
+ "input": 0.2,
34266
+ "output": 1.25,
34267
+ "cacheRead": 0.02,
34268
34268
  "cacheWrite": 0
34269
34269
  },
34270
34270
  "contextWindow": 272000,
@@ -34290,9 +34290,9 @@
34290
34290
  "image"
34291
34291
  ],
34292
34292
  "cost": {
34293
- "input": 0,
34294
- "output": 0,
34295
- "cacheRead": 0,
34293
+ "input": 5,
34294
+ "output": 30,
34295
+ "cacheRead": 0.5,
34296
34296
  "cacheWrite": 0
34297
34297
  },
34298
34298
  "contextWindow": 272000,
@@ -52775,4 +52775,4 @@
52775
52775
  }
52776
52776
  }
52777
52777
  }
52778
- }
52778
+ }
@@ -0,0 +1,70 @@
1
+ export function compactGrammarDefinition(syntax: "lark" | "regex", definition: string): string {
2
+ if (syntax !== "lark") {
3
+ return definition;
4
+ }
5
+
6
+ return compactLarkGrammarDefinition(definition);
7
+ }
8
+
9
+ function compactLarkGrammarDefinition(definition: string): string {
10
+ const lines: string[] = [];
11
+
12
+ for (const line of definition.split(/\r?\n/)) {
13
+ const uncommented = stripLarkLineComment(line).trimEnd();
14
+ if (uncommented.trim()) {
15
+ lines.push(uncommented);
16
+ }
17
+ }
18
+
19
+ return lines.join("\n");
20
+ }
21
+
22
+ function stripLarkLineComment(line: string): string {
23
+ let inString: string | undefined;
24
+ let inRegex = false;
25
+ let escaped = false;
26
+
27
+ for (let i = 0; i < line.length; i++) {
28
+ const char = line[i];
29
+ const next = line[i + 1];
30
+
31
+ if (escaped) {
32
+ escaped = false;
33
+ continue;
34
+ }
35
+
36
+ if (char === "\\") {
37
+ escaped = true;
38
+ continue;
39
+ }
40
+
41
+ if (inString) {
42
+ if (char === inString) {
43
+ inString = undefined;
44
+ }
45
+ continue;
46
+ }
47
+
48
+ if (inRegex) {
49
+ if (char === "/") {
50
+ inRegex = false;
51
+ }
52
+ continue;
53
+ }
54
+
55
+ if (char === "/" && next === "/") {
56
+ return line.slice(0, i);
57
+ }
58
+
59
+ if (char === '"' || char === "'") {
60
+ inString = char;
61
+ continue;
62
+ }
63
+
64
+ if (char === "/") {
65
+ inRegex = true;
66
+ }
67
+ }
68
+
69
+ return line;
70
+ }
@@ -42,6 +42,7 @@ import { finalizeErrorMessage, type RawHttpRequestDump } from "../utils/http-ins
42
42
  import { getOpenAIStreamIdleTimeoutMs, iterateWithIdleTimeout } from "../utils/idle-iterator";
43
43
  import { parseStreamingJson } from "../utils/json-parse";
44
44
  import { adaptSchemaForStrict, NO_STRICT } from "../utils/schema";
45
+ import { compactGrammarDefinition } from "./grammar";
45
46
  import {
46
47
  CODEX_BASE_URL,
47
48
  getCodexAccountId,
@@ -647,17 +648,31 @@ async function reopenCodexWebSocketRuntimeStream(
647
648
  runtime: CodexStreamRuntime,
648
649
  state: CodexWebSocketSessionState,
649
650
  ): Promise<void> {
650
- const next = await openCodexWebSocketTransport(
651
- context.requestContext,
652
- context.requestSetup,
653
- context.options,
654
- state,
655
- runtime.websocketStreamRetries,
656
- );
657
- runtime.eventStream = next.eventStream;
658
- runtime.requestBodyForState = next.requestBodyForState;
659
- runtime.transport = next.transport;
660
- state.lastTransport = next.transport;
651
+ try {
652
+ const next = await openCodexWebSocketTransport(
653
+ context.requestContext,
654
+ context.requestSetup,
655
+ context.options,
656
+ state,
657
+ runtime.websocketStreamRetries,
658
+ );
659
+ runtime.eventStream = next.eventStream;
660
+ runtime.requestBodyForState = next.requestBodyForState;
661
+ runtime.transport = next.transport;
662
+ state.lastTransport = next.transport;
663
+ } catch (error) {
664
+ const wsError = error instanceof Error ? error : new Error(String(error));
665
+ if (!isCodexWebSocketTransportError(wsError)) throw error;
666
+ // Reopen failed at the websocket layer (handshake refused, connect timeout, etc.).
667
+ // Activate fallback so subsequent turns use SSE, and replay this turn over SSE
668
+ // instead of surfacing a raw transport error to the caller.
669
+ recordCodexWebSocketFailure(state, true);
670
+ logCodexDebug("codex websocket reopen failed, falling back to SSE", {
671
+ error: wsError.message,
672
+ retry: runtime.websocketStreamRetries,
673
+ });
674
+ await reopenCodexSseRuntimeStream(context, runtime, state);
675
+ }
661
676
  }
662
677
 
663
678
  async function reopenCodexSseRuntimeStream(
@@ -2379,7 +2394,7 @@ export function convertTools(tools: Tool[], model: Model<"openai-codex-responses
2379
2394
  format: {
2380
2395
  type: "grammar",
2381
2396
  syntax: tool.customFormat.syntax,
2382
- definition: tool.customFormat.definition,
2397
+ definition: compactGrammarDefinition(tool.customFormat.syntax, tool.customFormat.definition),
2383
2398
  },
2384
2399
  };
2385
2400
  }
@@ -46,6 +46,7 @@ import {
46
46
  hasCopilotVisionInput,
47
47
  resolveGitHubCopilotBaseUrl,
48
48
  } from "./github-copilot-headers";
49
+ import { compactGrammarDefinition } from "./grammar";
49
50
  import {
50
51
  appendResponsesToolResultMessages,
51
52
  collectCustomCallIds,
@@ -577,7 +578,7 @@ export function convertTools(tools: Tool[], strictMode: boolean, model: Model<"o
577
578
  format: {
578
579
  type: "grammar",
579
580
  syntax: tool.customFormat.syntax,
580
- definition: tool.customFormat.definition,
581
+ definition: compactGrammarDefinition(tool.customFormat.syntax, tool.customFormat.definition),
581
582
  },
582
583
  } as unknown as OpenAITool;
583
584
  }