@victor-software-house/pi-openai-proxy 4.9.1 → 4.9.2

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.
Files changed (2) hide show
  1. package/dist/index.mjs +6 -3
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -324,6 +324,8 @@ const toolArgsSchema = z.record(z.string().trim(), z.unknown());
324
324
  function convertMessages(messages) {
325
325
  const systemParts = [];
326
326
  const piMessages = [];
327
+ const toolCallNames = /* @__PURE__ */ new Map();
328
+ for (const msg of messages) if (msg !== void 0 && msg.role === "assistant" && "tool_calls" in msg) for (const tc of msg.tool_calls ?? []) toolCallNames.set(tc.id, tc.function.name);
327
329
  for (let i = 0; i < messages.length; i++) {
328
330
  const msg = messages[i];
329
331
  if (msg === void 0) continue;
@@ -337,7 +339,8 @@ function convertMessages(messages) {
337
339
  const assistantMsg = convertAssistantMessage(msg.content ?? null, msg.tool_calls);
338
340
  piMessages.push(assistantMsg);
339
341
  } else if (msg.role === "tool") {
340
- const toolMsg = convertToolMessage(msg.content, msg.tool_call_id);
342
+ const toolName = toolCallNames.get(msg.tool_call_id) ?? "";
343
+ const toolMsg = convertToolMessage(msg.content, msg.tool_call_id, toolName);
341
344
  piMessages.push(toolMsg);
342
345
  }
343
346
  }
@@ -442,11 +445,11 @@ function convertAssistantMessage(textContent, toolCalls) {
442
445
  timestamp: Date.now()
443
446
  };
444
447
  }
445
- function convertToolMessage(content, toolCallId) {
448
+ function convertToolMessage(content, toolCallId, toolName) {
446
449
  return {
447
450
  role: "toolResult",
448
451
  toolCallId,
449
- toolName: "",
452
+ toolName,
450
453
  content: [{
451
454
  type: "text",
452
455
  text: content
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@victor-software-house/pi-openai-proxy",
3
- "version": "4.9.1",
3
+ "version": "4.9.2",
4
4
  "description": "OpenAI-compatible HTTP proxy for pi's multi-provider model registry",
5
5
  "license": "MIT",
6
6
  "author": "Victor Software House",