@caupulican/pi-ai 0.91.4 → 0.93.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.
@@ -415,12 +415,15 @@ function buildRequestBody(model, context, options, cacheSessionId) {
415
415
  const toolNameMap = createOpenAIResponsesToolNameMap(context.tools ?? []);
416
416
  const messages = convertResponsesMessages(model, context, CODEX_TOOL_CALL_PROVIDERS, {
417
417
  imageDetail: lite ? null : "auto",
418
+ includeMessageType: lite,
418
419
  toolNameMap,
419
420
  });
420
- const instructions = buildResponsesInstructions(context) || "You are a helpful assistant.";
421
- const tools = context.tools && context.tools.length > 0
422
- ? convertResponsesTools(context.tools, { strict: null, toolNameMap })
421
+ const configuredInstructions = buildResponsesInstructions(context);
422
+ const instructions = configuredInstructions || "You are a helpful assistant.";
423
+ const convertedTools = context.tools && context.tools.length > 0
424
+ ? convertResponsesTools(context.tools, { strict: lite ? false : null, toolNameMap })
423
425
  : [];
426
+ const tools = lite ? groupCodexResponsesLiteTools(convertedTools) : convertedTools;
424
427
  const input = lite
425
428
  ? [
426
429
  {
@@ -428,11 +431,15 @@ function buildRequestBody(model, context, options, cacheSessionId) {
428
431
  role: "developer",
429
432
  tools,
430
433
  },
431
- {
432
- type: "message",
433
- role: "developer",
434
- content: [{ type: "input_text", text: instructions }],
435
- },
434
+ ...(configuredInstructions
435
+ ? [
436
+ {
437
+ type: "message",
438
+ role: "developer",
439
+ content: [{ type: "input_text", text: configuredInstructions }],
440
+ },
441
+ ]
442
+ : []),
436
443
  ...messages,
437
444
  ]
438
445
  : messages;
@@ -475,6 +482,24 @@ function buildRequestBody(model, context, options, cacheSessionId) {
475
482
  }
476
483
  return body;
477
484
  }
485
+ function groupCodexResponsesLiteTools(tools) {
486
+ if (tools.length === 0)
487
+ return [];
488
+ const functions = tools.map((tool) => {
489
+ if (tool.type !== "function") {
490
+ throw new Error(`Unsupported Responses Lite tool type: ${tool.type}`);
491
+ }
492
+ return tool;
493
+ });
494
+ return [
495
+ {
496
+ type: "namespace",
497
+ name: "functions",
498
+ description: "",
499
+ tools: functions,
500
+ },
501
+ ];
502
+ }
478
503
  function resolveCodexServiceTier(responseServiceTier, requestServiceTier) {
479
504
  if (responseServiceTier === "default" && (requestServiceTier === "flex" || requestServiceTier === "priority")) {
480
505
  return requestServiceTier;