@openhoo/hoopilot 2.1.9 → 2.1.10

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/dist/codexx.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  buildCodexxInvocation,
4
4
  main,
5
5
  verifyCodexxModel
6
- } from "./chunk-FH6WSFOC.js";
6
+ } from "./chunk-2GIR4W4A.js";
7
7
  export {
8
8
  buildCodexxInvocation,
9
9
  main,
package/dist/index.js CHANGED
@@ -3,6 +3,7 @@ import { chmodSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync }
3
3
  import { dirname, join } from "path";
4
4
 
5
5
  // src/util.ts
6
+ import { isIP } from "net";
6
7
  function trimTrailingSlash(value) {
7
8
  return value.replace(/\/+$/, "");
8
9
  }
@@ -39,9 +40,16 @@ function parseUrl(rawUrl) {
39
40
  }
40
41
  return url;
41
42
  }
42
- var LOOPBACK_HOSTNAMES = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "::1", "[::1]"]);
43
43
  function isLoopbackHostname(host) {
44
- return LOOPBACK_HOSTNAMES.has(host);
44
+ const normalized = host.trim().toLowerCase();
45
+ const address = normalized.startsWith("[") && normalized.endsWith("]") ? normalized.slice(1, -1) : normalized;
46
+ if (address === "localhost") {
47
+ return true;
48
+ }
49
+ if (isIP(address) === 4) {
50
+ return address.startsWith("127.");
51
+ }
52
+ return isIP(address) === 6 && (address === "::1" || address === "0:0:0:0:0:0:0:1");
45
53
  }
46
54
  function isLoopbackHttpUrl(url) {
47
55
  return url.protocol === "http:" && isLoopbackHostname(url.hostname);
@@ -2409,7 +2417,7 @@ function anthropicMessagesToResponsesInput(messages) {
2409
2417
  arguments: JSON.stringify(asRecord(part.input)),
2410
2418
  cache_control: anthropicCacheControl(part.cache_control),
2411
2419
  call_id: textValue(part.id) || `call_hoopilot_${fallbackToolCallIndex++}`,
2412
- name: textValue(part.name),
2420
+ name: requiredAnthropicText(part.name, "tool_use name"),
2413
2421
  type: "function_call"
2414
2422
  })
2415
2423
  );
@@ -2555,7 +2563,7 @@ function anthropicTools(tools) {
2555
2563
  return removeUndefined({
2556
2564
  cache_control: anthropicCacheControl(record.cache_control),
2557
2565
  description: record.description,
2558
- name: record.name,
2566
+ name: requiredAnthropicText(record.name, "tool name"),
2559
2567
  parameters: record.input_schema,
2560
2568
  strict: record.strict,
2561
2569
  type: "function"
@@ -2628,12 +2636,19 @@ function anthropicToolChoice(toolChoice) {
2628
2636
  return "none";
2629
2637
  }
2630
2638
  if (type === "tool") {
2631
- return { name: textValue(record.name), type: "function" };
2639
+ return { name: requiredAnthropicText(record.name, "tool_choice name"), type: "function" };
2632
2640
  }
2633
2641
  throw new AnthropicCompatibilityError(
2634
2642
  `Anthropic tool_choice type "${type || "unknown"}" is not supported.`
2635
2643
  );
2636
2644
  }
2645
+ function requiredAnthropicText(value, field) {
2646
+ const text = textValue(value).trim();
2647
+ if (!text) {
2648
+ throw new AnthropicCompatibilityError(`Anthropic ${field} is required.`);
2649
+ }
2650
+ return text;
2651
+ }
2637
2652
  function anthropicThinkingToReasoning(thinking) {
2638
2653
  const record = asRecord(thinking);
2639
2654
  if (Object.keys(record).length === 0) {
@@ -3922,6 +3937,17 @@ function isLoopbackOrigin(origin) {
3922
3937
  }
3923
3938
 
3924
3939
  // src/http/responses.ts
3940
+ var HOP_BY_HOP_HEADERS = [
3941
+ "connection",
3942
+ "keep-alive",
3943
+ "proxy-authenticate",
3944
+ "proxy-authorization",
3945
+ "te",
3946
+ "trailer",
3947
+ "transfer-encoding",
3948
+ "upgrade"
3949
+ ];
3950
+ var STALE_BODY_HEADERS = ["content-encoding", "content-length"];
3925
3951
  function jsonResponse(body, status = 200) {
3926
3952
  return new Response(JSON.stringify(body), {
3927
3953
  headers: {
@@ -3961,9 +3987,7 @@ function responseFromText(source, text) {
3961
3987
  }
3962
3988
  function proxyResponse(upstream) {
3963
3989
  const headers = new Headers(upstream.headers);
3964
- headers.delete("content-encoding");
3965
- headers.delete("content-length");
3966
- headers.delete("transfer-encoding");
3990
+ stripProxyUnsafeHeaders(headers);
3967
3991
  for (const [key, value] of Object.entries(corsHeaders())) {
3968
3992
  headers.set(key, value);
3969
3993
  }
@@ -3989,6 +4013,23 @@ function websocketUnsupportedResponse() {
3989
4013
  response.headers.set("upgrade", "websocket");
3990
4014
  return response;
3991
4015
  }
4016
+ function stripProxyUnsafeHeaders(headers) {
4017
+ const connection = headers.get("connection");
4018
+ if (connection) {
4019
+ for (const name of connection.split(",")) {
4020
+ const trimmed = name.trim();
4021
+ if (trimmed) {
4022
+ headers.delete(trimmed);
4023
+ }
4024
+ }
4025
+ }
4026
+ for (const name of HOP_BY_HOP_HEADERS) {
4027
+ headers.delete(name);
4028
+ }
4029
+ for (const name of STALE_BODY_HEADERS) {
4030
+ headers.delete(name);
4031
+ }
4032
+ }
3992
4033
 
3993
4034
  // src/version.ts
3994
4035
  var BAKED_VERSION = typeof HOOPILOT_VERSION !== "undefined" ? HOOPILOT_VERSION : void 0;
@@ -4851,7 +4892,7 @@ function dashboardResponse() {
4851
4892
  }
4852
4893
  async function handleUsage(metrics, readUsage, request) {
4853
4894
  const view = new URL(request.url).searchParams.get("view");
4854
- const { copilot, error } = await readUsage(request.signal);
4895
+ const { copilot, error } = await readUsage();
4855
4896
  const proxy = view === DASHBOARD_USAGE_VIEW ? metrics.snapshot({
4856
4897
  excludeRoutes: DASHBOARD_EXCLUDED_ROUTES,
4857
4898
  excludeUpstreamPaths: DASHBOARD_EXCLUDED_UPSTREAM_PATHS