@meuecommerce/frete-adapter-node 0.10.0 → 0.11.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.
@@ -9,7 +9,7 @@ const openAIResponsesAgentRunner_js_1 = require("./openAIResponsesAgentRunner.js
9
9
  * `L3` record so a prompt change can invalidate stale estimates in background
10
10
  * instead of at checkout.
11
11
  */
12
- exports.DIMENSION_PROMPT_VERSION = "2026-09-11.responses.v3-detalhes";
12
+ exports.DIMENSION_PROMPT_VERSION = "2026-09-11.responses.v4-indice";
13
13
  /**
14
14
  * Strict JSON schema for the response.
15
15
  *
@@ -26,6 +26,10 @@ const DIMENSIONS_SCHEMA = {
26
26
  items: {
27
27
  type: "object",
28
28
  properties: {
29
+ // O que liga a resposta de volta ao produto. Número, e não nome: o
30
+ // nome depende do modelo copiar uma string de volta, e ele não copia
31
+ // — ver a nota em `porIndice`.
32
+ index: { type: "integer", description: "O número da linha do produto, exatamente como veio" },
29
33
  name: { type: "string", description: "O nome EXATO recebido, sem reescrever" },
30
34
  length: { type: "number", description: "Comprimento em cm" },
31
35
  width: { type: "number", description: "Largura em cm" },
@@ -43,7 +47,7 @@ const DIMENSIONS_SCHEMA = {
43
47
  additionalProperties: false,
44
48
  },
45
49
  },
46
- required: ["name", "length", "width", "height", "attrs"],
50
+ required: ["index", "name", "length", "width", "height", "attrs"],
47
51
  additionalProperties: false,
48
52
  },
49
53
  },
@@ -96,8 +100,8 @@ function createPrompt(products, boxes, samples) {
96
100
  `- keepUpright: precisa viajar em pé — líquido, tinta, bolo, planta\n` +
97
101
  `Na dúvida responda false. Cada traço afrouxa o encaixe, e afrouxar errado faz o pacote não fechar.\n` +
98
102
  `\n⚠️ REGRAS: respeite os limites; retorne length×width×height em cm; ` +
99
- `copie em "name" o nome EXATO da linha numerada do produto, sem as linhas recuadas de contexto — ` +
100
- `é por ele que a resposta é reconhecida, e um nome diferente descarta a estimativa.`);
103
+ `devolva uma entrada por produto, com "index" igual ao número da linha dele — ` +
104
+ `é por esse número que a resposta é reconhecida, e um índice errado descarta a estimativa.`);
101
105
  }
102
106
  /**
103
107
  * Só os traços verdadeiros, e nada quando não há nenhum.
@@ -142,6 +146,7 @@ function validateAndOptimize(aiResult, products, boxes) {
142
146
  }
143
147
  return {
144
148
  name: product.name,
149
+ ...(typeof product.index === "number" ? { index: product.index } : {}),
145
150
  length: Math.round(length * 10) / 10,
146
151
  width: Math.round(width * 10) / 10,
147
152
  height: Math.round(height * 10) / 10,
@@ -25,7 +25,7 @@ type FetchLike = typeof globalThis.fetch;
25
25
  * `L3` record so a prompt change can invalidate stale estimates in background
26
26
  * instead of at checkout.
27
27
  */
28
- export declare const DIMENSION_PROMPT_VERSION = "2026-09-11.responses.v3-detalhes";
28
+ export declare const DIMENSION_PROMPT_VERSION = "2026-09-11.responses.v4-indice";
29
29
  export interface OpenAIDimensionEstimatorOptions {
30
30
  apiKey?: string;
31
31
  fetch?: FetchLike;
@@ -5,7 +5,7 @@ import { createOpenAIResponsesAgentRunner } from "./openAIResponsesAgentRunner.j
5
5
  * `L3` record so a prompt change can invalidate stale estimates in background
6
6
  * instead of at checkout.
7
7
  */
8
- export const DIMENSION_PROMPT_VERSION = "2026-09-11.responses.v3-detalhes";
8
+ export const DIMENSION_PROMPT_VERSION = "2026-09-11.responses.v4-indice";
9
9
  /**
10
10
  * Strict JSON schema for the response.
11
11
  *
@@ -22,6 +22,10 @@ const DIMENSIONS_SCHEMA = {
22
22
  items: {
23
23
  type: "object",
24
24
  properties: {
25
+ // O que liga a resposta de volta ao produto. Número, e não nome: o
26
+ // nome depende do modelo copiar uma string de volta, e ele não copia
27
+ // — ver a nota em `porIndice`.
28
+ index: { type: "integer", description: "O número da linha do produto, exatamente como veio" },
25
29
  name: { type: "string", description: "O nome EXATO recebido, sem reescrever" },
26
30
  length: { type: "number", description: "Comprimento em cm" },
27
31
  width: { type: "number", description: "Largura em cm" },
@@ -39,7 +43,7 @@ const DIMENSIONS_SCHEMA = {
39
43
  additionalProperties: false,
40
44
  },
41
45
  },
42
- required: ["name", "length", "width", "height", "attrs"],
46
+ required: ["index", "name", "length", "width", "height", "attrs"],
43
47
  additionalProperties: false,
44
48
  },
45
49
  },
@@ -92,8 +96,8 @@ function createPrompt(products, boxes, samples) {
92
96
  `- keepUpright: precisa viajar em pé — líquido, tinta, bolo, planta\n` +
93
97
  `Na dúvida responda false. Cada traço afrouxa o encaixe, e afrouxar errado faz o pacote não fechar.\n` +
94
98
  `\n⚠️ REGRAS: respeite os limites; retorne length×width×height em cm; ` +
95
- `copie em "name" o nome EXATO da linha numerada do produto, sem as linhas recuadas de contexto — ` +
96
- `é por ele que a resposta é reconhecida, e um nome diferente descarta a estimativa.`);
99
+ `devolva uma entrada por produto, com "index" igual ao número da linha dele — ` +
100
+ `é por esse número que a resposta é reconhecida, e um índice errado descarta a estimativa.`);
97
101
  }
98
102
  /**
99
103
  * Só os traços verdadeiros, e nada quando não há nenhum.
@@ -138,6 +142,7 @@ function validateAndOptimize(aiResult, products, boxes) {
138
142
  }
139
143
  return {
140
144
  name: product.name,
145
+ ...(typeof product.index === "number" ? { index: product.index } : {}),
141
146
  length: Math.round(length * 10) / 10,
142
147
  width: Math.round(width * 10) / 10,
143
148
  height: Math.round(height * 10) / 10,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meuecommerce/frete-adapter-node",
3
- "version": "0.10.0",
3
+ "version": "0.11.0",
4
4
  "description": "Node implementation of @meuecommerce/frete ports (Correios HTTP client) using global fetch. Used by the Shopify/Fly deployment and the MCP server.",
5
5
  "type": "module",
6
6
  "main": "./dist/cjs/index.js",
@@ -31,7 +31,7 @@
31
31
  "access": "public"
32
32
  },
33
33
  "dependencies": {
34
- "@meuecommerce/frete": "^0.10.0"
34
+ "@meuecommerce/frete": "^0.11.0"
35
35
  },
36
36
  "module": "./dist/index.js",
37
37
  "repository": {