@openhoo/hoopilot 2.1.9 → 2.1.11
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/{chunk-FH6WSFOC.js → chunk-2GIR4W4A.js} +11 -3
- package/dist/chunk-2GIR4W4A.js.map +1 -0
- package/dist/cli.js +47 -16
- package/dist/cli.js.map +1 -1
- package/dist/codexx.js +1 -1
- package/dist/index.js +56 -17
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-FH6WSFOC.js.map +0 -1
package/dist/codexx.js
CHANGED
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
|
-
|
|
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);
|
|
@@ -1054,15 +1062,10 @@ function responsesCompactionRequestBody(request) {
|
|
|
1054
1062
|
return JSON.stringify(
|
|
1055
1063
|
removeUndefined({
|
|
1056
1064
|
...request,
|
|
1057
|
-
input:
|
|
1058
|
-
|
|
1059
|
-
{
|
|
1060
|
-
content: [{ text: COMPACTION_SUMMARIZATION_PROMPT, type: "input_text" }],
|
|
1061
|
-
role: "user",
|
|
1062
|
-
type: "message"
|
|
1063
|
-
}
|
|
1064
|
-
],
|
|
1065
|
+
input: compactionInputItemsForCopilot(request.input),
|
|
1066
|
+
instructions: compactionInstructionsForCopilot(request.instructions),
|
|
1065
1067
|
parallel_tool_calls: false,
|
|
1068
|
+
reasoning: void 0,
|
|
1066
1069
|
stream: false,
|
|
1067
1070
|
tool_choice: "none",
|
|
1068
1071
|
tools: []
|
|
@@ -1393,6 +1396,9 @@ function compactionInputItemsForCopilot(input) {
|
|
|
1393
1396
|
}
|
|
1394
1397
|
] : [];
|
|
1395
1398
|
}
|
|
1399
|
+
function compactionInstructionsForCopilot(instructions) {
|
|
1400
|
+
return contentToText(instructions).trim() ? instructions : COMPACTION_SUMMARIZATION_PROMPT;
|
|
1401
|
+
}
|
|
1396
1402
|
function responseInputItems(input) {
|
|
1397
1403
|
return Array.isArray(input) ? input : [];
|
|
1398
1404
|
}
|
|
@@ -2409,7 +2415,7 @@ function anthropicMessagesToResponsesInput(messages) {
|
|
|
2409
2415
|
arguments: JSON.stringify(asRecord(part.input)),
|
|
2410
2416
|
cache_control: anthropicCacheControl(part.cache_control),
|
|
2411
2417
|
call_id: textValue(part.id) || `call_hoopilot_${fallbackToolCallIndex++}`,
|
|
2412
|
-
name:
|
|
2418
|
+
name: requiredAnthropicText(part.name, "tool_use name"),
|
|
2413
2419
|
type: "function_call"
|
|
2414
2420
|
})
|
|
2415
2421
|
);
|
|
@@ -2555,7 +2561,7 @@ function anthropicTools(tools) {
|
|
|
2555
2561
|
return removeUndefined({
|
|
2556
2562
|
cache_control: anthropicCacheControl(record.cache_control),
|
|
2557
2563
|
description: record.description,
|
|
2558
|
-
name: record.name,
|
|
2564
|
+
name: requiredAnthropicText(record.name, "tool name"),
|
|
2559
2565
|
parameters: record.input_schema,
|
|
2560
2566
|
strict: record.strict,
|
|
2561
2567
|
type: "function"
|
|
@@ -2628,12 +2634,19 @@ function anthropicToolChoice(toolChoice) {
|
|
|
2628
2634
|
return "none";
|
|
2629
2635
|
}
|
|
2630
2636
|
if (type === "tool") {
|
|
2631
|
-
return { name:
|
|
2637
|
+
return { name: requiredAnthropicText(record.name, "tool_choice name"), type: "function" };
|
|
2632
2638
|
}
|
|
2633
2639
|
throw new AnthropicCompatibilityError(
|
|
2634
2640
|
`Anthropic tool_choice type "${type || "unknown"}" is not supported.`
|
|
2635
2641
|
);
|
|
2636
2642
|
}
|
|
2643
|
+
function requiredAnthropicText(value, field) {
|
|
2644
|
+
const text = textValue(value).trim();
|
|
2645
|
+
if (!text) {
|
|
2646
|
+
throw new AnthropicCompatibilityError(`Anthropic ${field} is required.`);
|
|
2647
|
+
}
|
|
2648
|
+
return text;
|
|
2649
|
+
}
|
|
2637
2650
|
function anthropicThinkingToReasoning(thinking) {
|
|
2638
2651
|
const record = asRecord(thinking);
|
|
2639
2652
|
if (Object.keys(record).length === 0) {
|
|
@@ -3922,6 +3935,17 @@ function isLoopbackOrigin(origin) {
|
|
|
3922
3935
|
}
|
|
3923
3936
|
|
|
3924
3937
|
// src/http/responses.ts
|
|
3938
|
+
var HOP_BY_HOP_HEADERS = [
|
|
3939
|
+
"connection",
|
|
3940
|
+
"keep-alive",
|
|
3941
|
+
"proxy-authenticate",
|
|
3942
|
+
"proxy-authorization",
|
|
3943
|
+
"te",
|
|
3944
|
+
"trailer",
|
|
3945
|
+
"transfer-encoding",
|
|
3946
|
+
"upgrade"
|
|
3947
|
+
];
|
|
3948
|
+
var STALE_BODY_HEADERS = ["content-encoding", "content-length"];
|
|
3925
3949
|
function jsonResponse(body, status = 200) {
|
|
3926
3950
|
return new Response(JSON.stringify(body), {
|
|
3927
3951
|
headers: {
|
|
@@ -3961,9 +3985,7 @@ function responseFromText(source, text) {
|
|
|
3961
3985
|
}
|
|
3962
3986
|
function proxyResponse(upstream) {
|
|
3963
3987
|
const headers = new Headers(upstream.headers);
|
|
3964
|
-
headers
|
|
3965
|
-
headers.delete("content-length");
|
|
3966
|
-
headers.delete("transfer-encoding");
|
|
3988
|
+
stripProxyUnsafeHeaders(headers);
|
|
3967
3989
|
for (const [key, value] of Object.entries(corsHeaders())) {
|
|
3968
3990
|
headers.set(key, value);
|
|
3969
3991
|
}
|
|
@@ -3989,6 +4011,23 @@ function websocketUnsupportedResponse() {
|
|
|
3989
4011
|
response.headers.set("upgrade", "websocket");
|
|
3990
4012
|
return response;
|
|
3991
4013
|
}
|
|
4014
|
+
function stripProxyUnsafeHeaders(headers) {
|
|
4015
|
+
const connection = headers.get("connection");
|
|
4016
|
+
if (connection) {
|
|
4017
|
+
for (const name of connection.split(",")) {
|
|
4018
|
+
const trimmed = name.trim();
|
|
4019
|
+
if (trimmed) {
|
|
4020
|
+
headers.delete(trimmed);
|
|
4021
|
+
}
|
|
4022
|
+
}
|
|
4023
|
+
}
|
|
4024
|
+
for (const name of HOP_BY_HOP_HEADERS) {
|
|
4025
|
+
headers.delete(name);
|
|
4026
|
+
}
|
|
4027
|
+
for (const name of STALE_BODY_HEADERS) {
|
|
4028
|
+
headers.delete(name);
|
|
4029
|
+
}
|
|
4030
|
+
}
|
|
3992
4031
|
|
|
3993
4032
|
// src/version.ts
|
|
3994
4033
|
var BAKED_VERSION = typeof HOOPILOT_VERSION !== "undefined" ? HOOPILOT_VERSION : void 0;
|
|
@@ -4851,7 +4890,7 @@ function dashboardResponse() {
|
|
|
4851
4890
|
}
|
|
4852
4891
|
async function handleUsage(metrics, readUsage, request) {
|
|
4853
4892
|
const view = new URL(request.url).searchParams.get("view");
|
|
4854
|
-
const { copilot, error } = await readUsage(
|
|
4893
|
+
const { copilot, error } = await readUsage();
|
|
4855
4894
|
const proxy = view === DASHBOARD_USAGE_VIEW ? metrics.snapshot({
|
|
4856
4895
|
excludeRoutes: DASHBOARD_EXCLUDED_ROUTES,
|
|
4857
4896
|
excludeUpstreamPaths: DASHBOARD_EXCLUDED_UPSTREAM_PATHS
|