@hebo-ai/gateway 0.11.3 → 0.11.5

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.
@@ -200,31 +200,31 @@ function fromInputContent(content) {
200
200
  result.push({ type: "text", text: part.text });
201
201
  break;
202
202
  case "input_image": {
203
- if (part.image_url !== undefined) {
203
+ if (part.image_url !== undefined && part.image_url !== null) {
204
204
  result.push(fromImageInput(part.image_url));
205
205
  }
206
- else if (part.file_id !== undefined) {
206
+ else if (part.file_id !== undefined && part.file_id !== null) {
207
207
  result.push({ type: "image", image: part.file_id });
208
208
  }
209
209
  break;
210
210
  }
211
211
  case "input_file": {
212
- if (part.file_data !== undefined) {
213
- result.push(fromFileInput(part.file_data, part.filename));
212
+ if (part.file_data !== undefined && part.file_data !== null) {
213
+ result.push(fromFileInput(part.file_data, part.filename ?? undefined));
214
214
  }
215
- else if (part.file_url !== undefined) {
215
+ else if (part.file_url !== undefined && part.file_url !== null) {
216
216
  result.push({
217
217
  type: "file",
218
218
  data: parseUrl(part.file_url),
219
- filename: part.filename,
219
+ filename: part.filename ?? undefined,
220
220
  mediaType: "application/octet-stream",
221
221
  });
222
222
  }
223
- else if (part.file_id !== undefined) {
223
+ else if (part.file_id !== undefined && part.file_id !== null) {
224
224
  result.push({
225
225
  type: "file",
226
226
  data: part.file_id,
227
- filename: part.filename,
227
+ filename: part.filename ?? undefined,
228
228
  mediaType: "application/octet-stream",
229
229
  });
230
230
  }
@@ -302,7 +302,7 @@ function fromToolOutput(output) {
302
302
  continue;
303
303
  }
304
304
  if (part.type === "input_image") {
305
- if (part.image_url !== undefined) {
305
+ if (part.image_url !== undefined && part.image_url !== null) {
306
306
  const { image, mediaType } = parseImageInput(part.image_url);
307
307
  if (image instanceof URL) {
308
308
  value.push({ type: "image-url", url: image.toString() });
@@ -315,24 +315,24 @@ function fromToolOutput(output) {
315
315
  });
316
316
  }
317
317
  }
318
- else if (part.file_id !== undefined) {
318
+ else if (part.file_id !== undefined && part.file_id !== null) {
319
319
  value.push({ type: "image-file-id", fileId: part.file_id });
320
320
  }
321
321
  continue;
322
322
  }
323
323
  if (part.type === "input_file") {
324
- if (part.file_data !== undefined) {
324
+ if (part.file_data !== undefined && part.file_data !== null) {
325
325
  value.push({
326
326
  type: "file-data",
327
327
  data: part.file_data,
328
328
  mediaType: "application/octet-stream",
329
- filename: part.filename,
329
+ filename: part.filename ?? undefined,
330
330
  });
331
331
  }
332
- else if (part.file_url !== undefined) {
332
+ else if (part.file_url !== undefined && part.file_url !== null) {
333
333
  value.push({ type: "file-url", url: part.file_url });
334
334
  }
335
- else if (part.file_id !== undefined) {
335
+ else if (part.file_id !== undefined && part.file_id !== null) {
336
336
  value.push({ type: "file-id", fileId: part.file_id });
337
337
  }
338
338
  continue;
@@ -373,13 +373,19 @@ export const convertToToolSet = (tools) => {
373
373
  }
374
374
  const toolSet = {};
375
375
  for (const t of tools) {
376
- toolSet[t.name] = tool({
377
- description: t.description,
378
- inputSchema: jsonSchema(t.parameters),
379
- strict: t.strict,
376
+ // Hosted/built-in tools (e.g. web_search) are accepted at the edge but
377
+ // not executed by the gateway; drop anything that isn't a function tool.
378
+ // FUTURE: log dropped hosted tools at warn level (once per request, batched)
379
+ if (t.type !== "function")
380
+ continue;
381
+ const fn = t;
382
+ toolSet[fn.name] = tool({
383
+ description: fn.description,
384
+ inputSchema: jsonSchema(fn.parameters),
385
+ strict: fn.strict,
380
386
  });
381
387
  }
382
- return toolSet;
388
+ return Object.keys(toolSet).length > 0 ? toolSet : undefined;
383
389
  };
384
390
  export const convertToToolChoiceOptions = (toolChoice) => {
385
391
  if (!toolChoice)
@@ -200,8 +200,10 @@ export const getResponsesResponseAttributes = (responses, signalLevel, finishRea
200
200
  Object.assign(attrs, {
201
201
  "gen_ai.output.messages": responses.output?.map((item) => {
202
202
  const base = {
203
+ role: "assistant",
203
204
  type: item.type,
204
- status: item.status,
205
+ // status is `| null` only because the shared schema is reused for input echo; output items always set it.
206
+ status: item.status ?? undefined,
205
207
  parts: [],
206
208
  };
207
209
  if (item.type === "message") {