@oh-my-pi/pi-ai 13.3.2 → 13.3.3

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,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@oh-my-pi/pi-ai",
4
- "version": "13.3.2",
4
+ "version": "13.3.3",
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",
@@ -38,19 +38,19 @@
38
38
  },
39
39
  "dependencies": {
40
40
  "@anthropic-ai/sdk": "^0.78",
41
- "@aws-sdk/client-bedrock-runtime": "^3.995",
41
+ "@aws-sdk/client-bedrock-runtime": "^3.998",
42
42
  "@bufbuild/protobuf": "^2.11",
43
43
  "@connectrpc/connect": "^2.1",
44
44
  "@connectrpc/connect-node": "^2.1",
45
- "@google/genai": "^1.42",
45
+ "@google/genai": "^1.43",
46
46
  "@mistralai/mistralai": "^1.14",
47
- "@oh-my-pi/pi-utils": "13.3.2",
47
+ "@oh-my-pi/pi-utils": "13.3.3",
48
48
  "@sinclair/typebox": "^0.34",
49
49
  "@smithy/node-http-handler": "^4.4",
50
50
  "ajv": "^8.18",
51
51
  "ajv-formats": "^3.0",
52
52
  "chalk": "^5.6",
53
- "openai": "^6.22",
53
+ "openai": "^6.25",
54
54
  "partial-json": "^0.1",
55
55
  "zod": "^4.3",
56
56
  "zod-to-json-schema": "^3.25"
@@ -1670,6 +1670,7 @@ const MODELS_DEV_PROVIDER_DESCRIPTORS_CODING_PLANS: readonly ModelsDevProviderDe
1670
1670
  // --- MiniMax Coding Plan ---
1671
1671
  openAiCompletionsDescriptor("minimax-coding-plan", "minimax-code", "https://api.minimax.io/v1", {
1672
1672
  compat: {
1673
+ supportsStore: false,
1673
1674
  supportsDeveloperRole: false,
1674
1675
  thinkingFormat: "zai",
1675
1676
  reasoningContentField: "reasoning_content",
@@ -1677,6 +1678,7 @@ const MODELS_DEV_PROVIDER_DESCRIPTORS_CODING_PLANS: readonly ModelsDevProviderDe
1677
1678
  }),
1678
1679
  openAiCompletionsDescriptor("minimax-cn-coding-plan", "minimax-code-cn", "https://api.minimaxi.com/v1", {
1679
1680
  compat: {
1681
+ supportsStore: false,
1680
1682
  supportsDeveloperRole: false,
1681
1683
  thinkingFormat: "zai",
1682
1684
  reasoningContentField: "reasoning_content",
@@ -296,12 +296,18 @@ const PROVIDER_BASE_DELAY_MS = 2000;
296
296
  * Includes malformed JSON stream-envelope parse errors seen from some
297
297
  * Anthropic-compatible proxy endpoints.
298
298
  */
299
+ /** Transient stream corruption errors where the response was truncated mid-JSON. */
300
+ function isTransientStreamParseError(error: unknown): boolean {
301
+ if (!(error instanceof Error)) return false;
302
+ return /json parse error|unterminated string|unexpected end of json input/i.test(error.message);
303
+ }
304
+
299
305
  export function isProviderRetryableError(error: unknown): boolean {
300
306
  if (!(error instanceof Error)) return false;
301
307
  const msg = error.message;
302
308
  return (
303
309
  /rate.?limit|too many requests|overloaded|service.?unavailable|1302/i.test(msg) ||
304
- /json parse error|unterminated string|unexpected end of json input/i.test(msg)
310
+ isTransientStreamParseError(error)
305
311
  );
306
312
  }
307
313
 
@@ -371,9 +377,9 @@ export const streamAnthropic: StreamFunction<"anthropic-messages"> = (
371
377
  type Block = (ThinkingContent | TextContent | (ToolCall & { partialJson: string })) & { index: number };
372
378
  const blocks = output.content as Block[];
373
379
  stream.push({ type: "start", partial: output });
374
- // Retry loop for rate-limit errors from proxies (e.g. z.ai) that the SDK doesn't handle.
375
- // These errors surface when iterating the stream, so we retry the full stream creation.
376
- // Only retry if no content blocks have been emitted yet (safe to restart).
380
+ // Retry loop for transient errors from the stream.
381
+ // Rate-limit/overload: only before content starts (safe to restart).
382
+ // Truncated JSON: also after content starts (partial response is unusable).
377
383
  let providerRetryAttempt = 0;
378
384
  let started = false;
379
385
  do {
@@ -542,12 +548,15 @@ export const streamAnthropic: StreamFunction<"anthropic-messages"> = (
542
548
  }
543
549
  break; // Stream completed successfully
544
550
  } catch (streamError) {
545
- // Only retry if: not aborted, no content emitted yet, retries left, and error is retryable
551
+ // Transient stream parse errors (truncated JSON) are retryable even after content
552
+ // has started streaming, since the partial response is unusable anyway.
553
+ // Rate-limit/overload errors are only retried before content starts.
554
+ const isTransient = isTransientStreamParseError(streamError);
546
555
  if (
547
556
  options?.signal?.aborted ||
548
- firstTokenTime !== undefined ||
549
557
  providerRetryAttempt >= PROVIDER_MAX_RETRIES ||
550
- !isProviderRetryableError(streamError)
558
+ (!isTransient && firstTokenTime !== undefined) ||
559
+ (!isTransient && !isProviderRetryableError(streamError))
551
560
  ) {
552
561
  throw streamError;
553
562
  }
@@ -557,6 +566,8 @@ export const streamAnthropic: StreamFunction<"anthropic-messages"> = (
557
566
  // Reset output state for clean retry
558
567
  output.content.length = 0;
559
568
  output.stopReason = "stop";
569
+ firstTokenTime = undefined;
570
+ started = false;
560
571
  }
561
572
  } while (!started);
562
573
 
@@ -37,6 +37,7 @@ import {
37
37
  AssistantMessageSchema,
38
38
  BackgroundShellSpawnResultSchema,
39
39
  ClientHeartbeatSchema,
40
+ ComputerUseResultSchema,
40
41
  ConversationActionSchema,
41
42
  type ConversationStateStructure,
42
43
  ConversationStateStructureSchema,
@@ -70,6 +71,7 @@ import {
70
71
  GrepUnionResultSchema,
71
72
  KvClientMessageSchema,
72
73
  type KvServerMessage,
74
+ ListMcpResourcesExecResultSchema,
73
75
  type LsDirectoryTreeNode,
74
76
  type LsDirectoryTreeNode_File,
75
77
  LsDirectoryTreeNode_FileSchema,
@@ -88,9 +90,11 @@ import {
88
90
  McpToolResultContentItemSchema,
89
91
  ModelDetailsSchema,
90
92
  ReadErrorSchema,
93
+ ReadMcpResourceExecResultSchema,
91
94
  ReadRejectedSchema,
92
95
  ReadResultSchema,
93
96
  ReadSuccessSchema,
97
+ RecordScreenResultSchema,
94
98
  RequestContextResultSchema,
95
99
  RequestContextSchema,
96
100
  RequestContextSuccessSchema,
@@ -965,6 +969,26 @@ async function handleExecServerMessage(
965
969
  sendExecClientMessage(h2Request, execMsg, "mcpResult", execResult);
966
970
  return;
967
971
  }
972
+ case "listMcpResourcesExecArgs": {
973
+ const execResult = create(ListMcpResourcesExecResultSchema, {});
974
+ sendExecClientMessage(h2Request, execMsg, "listMcpResourcesExecResult", execResult);
975
+ return;
976
+ }
977
+ case "readMcpResourceExecArgs": {
978
+ const execResult = create(ReadMcpResourceExecResultSchema, {});
979
+ sendExecClientMessage(h2Request, execMsg, "readMcpResourceExecResult", execResult);
980
+ return;
981
+ }
982
+ case "recordScreenArgs": {
983
+ const execResult = create(RecordScreenResultSchema, {});
984
+ sendExecClientMessage(h2Request, execMsg, "recordScreenResult", execResult);
985
+ return;
986
+ }
987
+ case "computerUseArgs": {
988
+ const execResult = create(ComputerUseResultSchema, {});
989
+ sendExecClientMessage(h2Request, execMsg, "computerUseResult", execResult);
990
+ return;
991
+ }
968
992
  default:
969
993
  log("warn", "unhandledExecMessage", { execCase });
970
994
  }