@dexto/core 1.16.5 → 1.17.0-beta.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.
- package/dist/agent/DextoAgent.cjs +2 -1
- package/dist/agent/DextoAgent.d.ts.map +1 -1
- package/dist/agent/DextoAgent.js +2 -1
- package/dist/agent/schemas.d.ts +2 -2
- package/dist/approval/index.cjs +4 -0
- package/dist/approval/index.d.ts +1 -1
- package/dist/approval/index.d.ts.map +1 -1
- package/dist/approval/index.js +4 -0
- package/dist/events/index.cjs +2 -3
- package/dist/events/index.d.ts +6 -23
- package/dist/events/index.d.ts.map +1 -1
- package/dist/events/index.js +2 -3
- package/dist/llm/auth/index.d.ts +1 -1
- package/dist/llm/auth/index.d.ts.map +1 -1
- package/dist/llm/auth/types.d.ts +14 -0
- package/dist/llm/auth/types.d.ts.map +1 -1
- package/dist/llm/error-codes.cjs +3 -0
- package/dist/llm/error-codes.d.ts +3 -0
- package/dist/llm/error-codes.d.ts.map +1 -1
- package/dist/llm/error-codes.js +3 -0
- package/dist/llm/errors.cjs +27 -0
- package/dist/llm/errors.d.ts +9 -0
- package/dist/llm/errors.d.ts.map +1 -1
- package/dist/llm/errors.js +27 -0
- package/dist/llm/executor/provider-error.cjs +14 -0
- package/dist/llm/executor/provider-error.d.ts.map +1 -1
- package/dist/llm/executor/provider-error.js +14 -0
- package/dist/llm/executor/tool-output-spill.cjs +46 -14
- package/dist/llm/executor/tool-output-spill.d.ts.map +1 -1
- package/dist/llm/executor/tool-output-spill.js +46 -14
- package/dist/llm/executor/turn-executor.cjs +4 -0
- package/dist/llm/executor/turn-executor.d.ts +5 -5
- package/dist/llm/executor/turn-executor.d.ts.map +1 -1
- package/dist/llm/executor/turn-executor.js +4 -0
- package/dist/llm/index.cjs +6 -0
- package/dist/llm/index.d.ts +3 -1
- package/dist/llm/index.d.ts.map +1 -1
- package/dist/llm/index.js +4 -0
- package/dist/llm/private-address.cjs +88 -0
- package/dist/llm/private-address.d.ts +3 -0
- package/dist/llm/private-address.d.ts.map +1 -0
- package/dist/llm/private-address.js +65 -0
- package/dist/llm/providers/codex-app-server.cjs +3 -3
- package/dist/llm/providers/codex-app-server.js +3 -3
- package/dist/llm/providers/local/errors.cjs +4 -4
- package/dist/llm/providers/local/errors.js +4 -4
- package/dist/llm/safe-download.cjs +159 -0
- package/dist/llm/safe-download.d.ts +21 -0
- package/dist/llm/safe-download.d.ts.map +1 -0
- package/dist/llm/safe-download.js +126 -0
- package/dist/llm/services/factory.cjs +204 -14
- package/dist/llm/services/factory.d.ts +1 -1
- package/dist/llm/services/factory.d.ts.map +1 -1
- package/dist/llm/services/factory.js +204 -14
- package/dist/logger/logger.cjs +12 -9
- package/dist/logger/logger.d.ts.map +1 -1
- package/dist/logger/logger.js +12 -9
- package/dist/logger/v2/dexto-logger.cjs +3 -2
- package/dist/logger/v2/dexto-logger.d.ts.map +1 -1
- package/dist/logger/v2/dexto-logger.js +3 -2
- package/dist/mcp/mcp-client.cjs +17 -8
- package/dist/mcp/mcp-client.d.ts +4 -2
- package/dist/mcp/mcp-client.d.ts.map +1 -1
- package/dist/mcp/mcp-client.js +17 -8
- package/dist/mcp/schemas.cjs +3 -0
- package/dist/mcp/schemas.d.ts +3 -0
- package/dist/mcp/schemas.d.ts.map +1 -1
- package/dist/mcp/schemas.js +3 -0
- package/dist/resources/handlers/filesystem-handler.cjs +7 -6
- package/dist/resources/handlers/filesystem-handler.d.ts.map +1 -1
- package/dist/resources/handlers/filesystem-handler.js +7 -6
- package/dist/session/session-manager.cjs +2 -0
- package/dist/session/session-manager.d.ts.map +1 -1
- package/dist/session/session-manager.js +2 -0
- package/dist/systemPrompt/schemas.d.ts +3 -3
- package/dist/telemetry/decorators.cjs +2 -2
- package/dist/telemetry/decorators.js +2 -2
- package/dist/tools/activity.cjs +0 -16
- package/dist/tools/activity.d.ts +0 -2
- package/dist/tools/activity.d.ts.map +1 -1
- package/dist/tools/activity.js +0 -16
- package/dist/tools/tool-call-metadata.cjs +0 -12
- package/dist/tools/tool-call-metadata.d.ts +0 -3
- package/dist/tools/tool-call-metadata.d.ts.map +1 -1
- package/dist/tools/tool-call-metadata.js +0 -12
- package/dist/tools/tool-manager.cjs +10 -93
- package/dist/tools/tool-manager.d.ts.map +1 -1
- package/dist/tools/tool-manager.js +10 -93
- package/dist/tools/tool-output-read.cjs +4 -3
- package/dist/tools/tool-output-read.d.ts.map +1 -1
- package/dist/tools/tool-output-read.js +4 -3
- package/dist/utils/env.cjs +0 -5
- package/dist/utils/env.d.ts +0 -1
- package/dist/utils/env.d.ts.map +1 -1
- package/dist/utils/env.js +0 -4
- package/dist/utils/index.cjs +3 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -0
- package/dist/utils/metadata-address.cjs +138 -0
- package/dist/utils/metadata-address.d.ts +24 -0
- package/dist/utils/metadata-address.d.ts.map +1 -0
- package/dist/utils/metadata-address.js +113 -0
- package/dist/utils/path.cjs +0 -15
- package/dist/utils/path.d.ts +0 -6
- package/dist/utils/path.d.ts.map +1 -1
- package/dist/utils/path.js +0 -14
- package/dist/utils/redactor.cjs +242 -34
- package/dist/utils/redactor.d.ts +15 -0
- package/dist/utils/redactor.d.ts.map +1 -1
- package/dist/utils/redactor.js +238 -34
- package/dist/utils/text-boundary.cjs +32 -0
- package/dist/utils/text-boundary.d.ts +3 -0
- package/dist/utils/text-boundary.d.ts.map +1 -0
- package/dist/utils/text-boundary.js +9 -0
- package/dist/workspace/index.cjs +7 -2
- package/dist/workspace/index.d.ts +1 -0
- package/dist/workspace/index.d.ts.map +1 -1
- package/dist/workspace/index.js +4 -1
- package/dist/workspace/shell-environment.cjs +96 -0
- package/dist/workspace/shell-environment.d.ts +18 -0
- package/dist/workspace/shell-environment.d.ts.map +1 -0
- package/dist/workspace/shell-environment.js +72 -0
- package/dist/workspace/types.d.ts +9 -0
- package/dist/workspace/types.d.ts.map +1 -1
- package/package.json +3 -3
|
@@ -25,12 +25,12 @@ __export(tool_output_spill_exports, {
|
|
|
25
25
|
withToolOutputPreview: () => withToolOutputPreview
|
|
26
26
|
});
|
|
27
27
|
module.exports = __toCommonJS(tool_output_spill_exports);
|
|
28
|
+
var import_text_boundary = require("../../utils/text-boundary.js");
|
|
28
29
|
const TOOL_OUTPUT_READ_TOOL_NAME = "tool_output_read";
|
|
29
30
|
const CHARS_PER_TOKEN = 4;
|
|
30
31
|
const MAX_INLINE_TOKENS = 4e3;
|
|
31
32
|
const INLINE_WINDOW_RATIO = 0.1;
|
|
32
33
|
const STEP_WINDOW_RATIO = 0.4;
|
|
33
|
-
const STEP_SPILL_PREVIEW_CHARS = 16e3;
|
|
34
34
|
const PREVIEW_HEAD_RATIO = 0.75;
|
|
35
35
|
function toolOutputBudget(maxInputTokens) {
|
|
36
36
|
return {
|
|
@@ -46,32 +46,57 @@ function planToolOutputSpills(results, budget) {
|
|
|
46
46
|
let inlineChars = 0;
|
|
47
47
|
for (const result of results) {
|
|
48
48
|
if (result.textLength > budget.inlineCapChars) {
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
const cap = Math.max(
|
|
50
|
+
budget.inlineCapChars,
|
|
51
|
+
outputMarker(result.toolCallId, result.textLength, 0, 0).length
|
|
52
|
+
);
|
|
53
|
+
if (cap < result.textLength) {
|
|
54
|
+
previewChars.set(result.toolCallId, cap);
|
|
55
|
+
inlineChars += cap;
|
|
56
|
+
} else {
|
|
57
|
+
inlineChars += result.textLength;
|
|
58
|
+
}
|
|
51
59
|
} else {
|
|
52
60
|
inlineChars += result.textLength;
|
|
53
61
|
}
|
|
54
62
|
}
|
|
55
|
-
const stepPreviewChars = Math.
|
|
63
|
+
const stepPreviewChars = Math.floor(budget.inlineCapChars / 2);
|
|
56
64
|
const largestFirst = results.filter((result) => result.textLength > stepPreviewChars).sort((left, right) => right.textLength - left.textLength);
|
|
57
65
|
for (const result of largestFirst) {
|
|
58
66
|
if (inlineChars <= budget.stepBudgetChars) break;
|
|
59
67
|
const inlineNow = previewChars.get(result.toolCallId) ?? result.textLength;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
68
|
+
const target = Math.max(
|
|
69
|
+
stepPreviewChars,
|
|
70
|
+
outputMarker(result.toolCallId, result.textLength, 0, 0).length
|
|
71
|
+
);
|
|
72
|
+
if (inlineNow <= target) continue;
|
|
73
|
+
previewChars.set(result.toolCallId, target);
|
|
74
|
+
inlineChars -= inlineNow - target;
|
|
75
|
+
}
|
|
76
|
+
if (inlineChars <= budget.stepBudgetChars) return previewChars;
|
|
77
|
+
for (const result of [...results].sort(
|
|
78
|
+
(a, b) => (previewChars.get(b.toolCallId) ?? b.textLength) - (previewChars.get(a.toolCallId) ?? a.textLength)
|
|
79
|
+
)) {
|
|
80
|
+
if (inlineChars <= budget.stepBudgetChars) break;
|
|
81
|
+
const inlineNow = previewChars.get(result.toolCallId) ?? result.textLength;
|
|
82
|
+
const minimum = outputMarker(result.toolCallId, result.textLength, 0, 0).length;
|
|
83
|
+
const target = Math.max(minimum, inlineNow - (inlineChars - budget.stepBudgetChars));
|
|
84
|
+
if (target >= inlineNow) continue;
|
|
85
|
+
previewChars.set(result.toolCallId, target);
|
|
86
|
+
inlineChars -= inlineNow - target;
|
|
63
87
|
}
|
|
64
88
|
return previewChars;
|
|
65
89
|
}
|
|
66
90
|
function withToolOutputPreview(result, fullText, previewChars) {
|
|
67
|
-
const headChars = Math.floor(previewChars * PREVIEW_HEAD_RATIO);
|
|
68
|
-
const tailChars = previewChars - headChars;
|
|
69
91
|
const id = result.meta.toolCallId;
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
92
|
+
const marker = (head, tail) => outputMarker(id, fullText.length, head, tail);
|
|
93
|
+
const available = Math.max(0, previewChars - marker(previewChars, previewChars).length);
|
|
94
|
+
const headChars = (0, import_text_boundary.safeTextBoundary)(fullText, Math.floor(available * PREVIEW_HEAD_RATIO));
|
|
95
|
+
const tailStart = fullText.length - (available - Math.floor(available * PREVIEW_HEAD_RATIO));
|
|
96
|
+
const safeTailStart = (0, import_text_boundary.safeTextBoundary)(fullText, tailStart) === tailStart ? tailStart : tailStart + 1;
|
|
97
|
+
const tailChars = fullText.length - safeTailStart;
|
|
98
|
+
const previewMarker = marker(headChars, tailChars);
|
|
99
|
+
const preview = fullText.slice(0, headChars) + previewMarker + fullText.slice(safeTailStart);
|
|
75
100
|
const content = [];
|
|
76
101
|
let previewAdded = false;
|
|
77
102
|
for (const part of result.content) {
|
|
@@ -84,6 +109,13 @@ function withToolOutputPreview(result, fullText, previewChars) {
|
|
|
84
109
|
}
|
|
85
110
|
return { ...result, content };
|
|
86
111
|
}
|
|
112
|
+
function outputMarker(id, length, head, tail) {
|
|
113
|
+
return `
|
|
114
|
+
|
|
115
|
+
[Output truncated: showing the first ${head} and last ${tail} of ${length} characters. The full output is stored. Read any part with ${TOOL_OUTPUT_READ_TOOL_NAME}({ "id": "${id}", "offset": <line> }) or search it with ${TOOL_OUTPUT_READ_TOOL_NAME}({ "id": "${id}", "pattern": "<text>" }) instead of re-running the tool.]
|
|
116
|
+
|
|
117
|
+
`;
|
|
118
|
+
}
|
|
87
119
|
// Annotate the CommonJS export names for ESM import in node:
|
|
88
120
|
0 && (module.exports = {
|
|
89
121
|
TOOL_OUTPUT_READ_TOOL_NAME,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-output-spill.d.ts","sourceRoot":"","sources":["../../../src/llm/executor/tool-output-spill.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tool-output-spill.d.ts","sourceRoot":"","sources":["../../../src/llm/executor/tool-output-spill.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAe,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAE/E,2DAA2D;AAC3D,eAAO,MAAM,0BAA0B,qBAAqB,CAAC;AAc7D,MAAM,WAAW,gBAAgB;IAC7B,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;CAC3B;AAED,wBAAgB,gBAAgB,CAAC,cAAc,EAAE,MAAM,GAAG,gBAAgB,CAOzE;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,mBAAmB,GAAG,MAAM,CAElE;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAChC,OAAO,EAAE,aAAa,CAAC;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC,EAClE,MAAM,EAAE,gBAAgB,GACzB,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAqDrB;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CACjC,MAAM,EAAE,mBAAmB,EAC3B,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,GACrB,mBAAmB,CAuBrB"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import "../../chunk-C6A6W6XS.js";
|
|
2
|
+
import { safeTextBoundary } from "../../utils/text-boundary.js";
|
|
2
3
|
const TOOL_OUTPUT_READ_TOOL_NAME = "tool_output_read";
|
|
3
4
|
const CHARS_PER_TOKEN = 4;
|
|
4
5
|
const MAX_INLINE_TOKENS = 4e3;
|
|
5
6
|
const INLINE_WINDOW_RATIO = 0.1;
|
|
6
7
|
const STEP_WINDOW_RATIO = 0.4;
|
|
7
|
-
const STEP_SPILL_PREVIEW_CHARS = 16e3;
|
|
8
8
|
const PREVIEW_HEAD_RATIO = 0.75;
|
|
9
9
|
function toolOutputBudget(maxInputTokens) {
|
|
10
10
|
return {
|
|
@@ -20,32 +20,57 @@ function planToolOutputSpills(results, budget) {
|
|
|
20
20
|
let inlineChars = 0;
|
|
21
21
|
for (const result of results) {
|
|
22
22
|
if (result.textLength > budget.inlineCapChars) {
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
const cap = Math.max(
|
|
24
|
+
budget.inlineCapChars,
|
|
25
|
+
outputMarker(result.toolCallId, result.textLength, 0, 0).length
|
|
26
|
+
);
|
|
27
|
+
if (cap < result.textLength) {
|
|
28
|
+
previewChars.set(result.toolCallId, cap);
|
|
29
|
+
inlineChars += cap;
|
|
30
|
+
} else {
|
|
31
|
+
inlineChars += result.textLength;
|
|
32
|
+
}
|
|
25
33
|
} else {
|
|
26
34
|
inlineChars += result.textLength;
|
|
27
35
|
}
|
|
28
36
|
}
|
|
29
|
-
const stepPreviewChars = Math.
|
|
37
|
+
const stepPreviewChars = Math.floor(budget.inlineCapChars / 2);
|
|
30
38
|
const largestFirst = results.filter((result) => result.textLength > stepPreviewChars).sort((left, right) => right.textLength - left.textLength);
|
|
31
39
|
for (const result of largestFirst) {
|
|
32
40
|
if (inlineChars <= budget.stepBudgetChars) break;
|
|
33
41
|
const inlineNow = previewChars.get(result.toolCallId) ?? result.textLength;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
42
|
+
const target = Math.max(
|
|
43
|
+
stepPreviewChars,
|
|
44
|
+
outputMarker(result.toolCallId, result.textLength, 0, 0).length
|
|
45
|
+
);
|
|
46
|
+
if (inlineNow <= target) continue;
|
|
47
|
+
previewChars.set(result.toolCallId, target);
|
|
48
|
+
inlineChars -= inlineNow - target;
|
|
49
|
+
}
|
|
50
|
+
if (inlineChars <= budget.stepBudgetChars) return previewChars;
|
|
51
|
+
for (const result of [...results].sort(
|
|
52
|
+
(a, b) => (previewChars.get(b.toolCallId) ?? b.textLength) - (previewChars.get(a.toolCallId) ?? a.textLength)
|
|
53
|
+
)) {
|
|
54
|
+
if (inlineChars <= budget.stepBudgetChars) break;
|
|
55
|
+
const inlineNow = previewChars.get(result.toolCallId) ?? result.textLength;
|
|
56
|
+
const minimum = outputMarker(result.toolCallId, result.textLength, 0, 0).length;
|
|
57
|
+
const target = Math.max(minimum, inlineNow - (inlineChars - budget.stepBudgetChars));
|
|
58
|
+
if (target >= inlineNow) continue;
|
|
59
|
+
previewChars.set(result.toolCallId, target);
|
|
60
|
+
inlineChars -= inlineNow - target;
|
|
37
61
|
}
|
|
38
62
|
return previewChars;
|
|
39
63
|
}
|
|
40
64
|
function withToolOutputPreview(result, fullText, previewChars) {
|
|
41
|
-
const headChars = Math.floor(previewChars * PREVIEW_HEAD_RATIO);
|
|
42
|
-
const tailChars = previewChars - headChars;
|
|
43
65
|
const id = result.meta.toolCallId;
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
66
|
+
const marker = (head, tail) => outputMarker(id, fullText.length, head, tail);
|
|
67
|
+
const available = Math.max(0, previewChars - marker(previewChars, previewChars).length);
|
|
68
|
+
const headChars = safeTextBoundary(fullText, Math.floor(available * PREVIEW_HEAD_RATIO));
|
|
69
|
+
const tailStart = fullText.length - (available - Math.floor(available * PREVIEW_HEAD_RATIO));
|
|
70
|
+
const safeTailStart = safeTextBoundary(fullText, tailStart) === tailStart ? tailStart : tailStart + 1;
|
|
71
|
+
const tailChars = fullText.length - safeTailStart;
|
|
72
|
+
const previewMarker = marker(headChars, tailChars);
|
|
73
|
+
const preview = fullText.slice(0, headChars) + previewMarker + fullText.slice(safeTailStart);
|
|
49
74
|
const content = [];
|
|
50
75
|
let previewAdded = false;
|
|
51
76
|
for (const part of result.content) {
|
|
@@ -58,6 +83,13 @@ function withToolOutputPreview(result, fullText, previewChars) {
|
|
|
58
83
|
}
|
|
59
84
|
return { ...result, content };
|
|
60
85
|
}
|
|
86
|
+
function outputMarker(id, length, head, tail) {
|
|
87
|
+
return `
|
|
88
|
+
|
|
89
|
+
[Output truncated: showing the first ${head} and last ${tail} of ${length} characters. The full output is stored. Read any part with ${TOOL_OUTPUT_READ_TOOL_NAME}({ "id": "${id}", "offset": <line> }) or search it with ${TOOL_OUTPUT_READ_TOOL_NAME}({ "id": "${id}", "pattern": "<text>" }) instead of re-running the tool.]
|
|
90
|
+
|
|
91
|
+
`;
|
|
92
|
+
}
|
|
61
93
|
export {
|
|
62
94
|
TOOL_OUTPUT_READ_TOOL_NAME,
|
|
63
95
|
planToolOutputSpills,
|
|
@@ -49,6 +49,7 @@ var import_provider_error = require("./provider-error.js");
|
|
|
49
49
|
var import_empty_response = require("./empty-response.js");
|
|
50
50
|
var import_errors = require("../errors.js");
|
|
51
51
|
var import_error_codes = require("../error-codes.js");
|
|
52
|
+
var import_safe_download = require("../safe-download.js");
|
|
52
53
|
var import_DextoRuntimeError = require("../../errors/DextoRuntimeError.js");
|
|
53
54
|
var import_error_conversion = require("../../utils/error-conversion.js");
|
|
54
55
|
var import_codex_base_url = require("../providers/codex-base-url.js");
|
|
@@ -58,6 +59,7 @@ var import_manager2 = require("../../approval/manager.js");
|
|
|
58
59
|
var import_errors2 = require("../../approval/errors.js");
|
|
59
60
|
var import_content_audit = require("../../context/content-audit.js");
|
|
60
61
|
var import_content_clone = require("../../context/content-clone.js");
|
|
62
|
+
const safeDownload = (0, import_safe_download.createSafeDownload)();
|
|
61
63
|
const MCP_TOOL_PREFIX = "mcp--";
|
|
62
64
|
const MODEL_REQUEST_MAX_RETRIES = 2;
|
|
63
65
|
const EMPTY_RESPONSE_MAX_RETRIES = 1;
|
|
@@ -1328,6 +1330,7 @@ class TurnExecutor {
|
|
|
1328
1330
|
tools: request.tools,
|
|
1329
1331
|
abortSignal,
|
|
1330
1332
|
messages: request.messages,
|
|
1333
|
+
experimental_download: safeDownload,
|
|
1331
1334
|
...this.config.maxOutputTokens !== void 0 && {
|
|
1332
1335
|
maxOutputTokens: this.config.maxOutputTokens
|
|
1333
1336
|
},
|
|
@@ -1430,6 +1433,7 @@ class TurnExecutor {
|
|
|
1430
1433
|
if (this.stepAbortController.signal.aborted) return false;
|
|
1431
1434
|
if (error instanceof import_DextoRuntimeError.DextoRuntimeError) return error.code === import_error_codes.LLMErrorCode.STREAM_STALLED;
|
|
1432
1435
|
if (!import_ai.APICallError.isInstance?.(error)) return false;
|
|
1436
|
+
if (error.statusCode === 401) return false;
|
|
1433
1437
|
return error.isRetryable;
|
|
1434
1438
|
}
|
|
1435
1439
|
async applyModelStepResult(input) {
|
|
@@ -18,9 +18,9 @@ import type { LLMExecutionControl } from '../services/types.js';
|
|
|
18
18
|
export declare const ModelStepResultStateSchema: z.ZodObject<{
|
|
19
19
|
text: z.ZodString;
|
|
20
20
|
finishReason: z.ZodEnum<{
|
|
21
|
+
length: "length";
|
|
21
22
|
error: "error";
|
|
22
23
|
unknown: "unknown";
|
|
23
|
-
length: "length";
|
|
24
24
|
cancelled: "cancelled";
|
|
25
25
|
stop: "stop";
|
|
26
26
|
other: "other";
|
|
@@ -72,9 +72,9 @@ export declare const TurnDriverStateSchema: z.ZodDiscriminatedUnion<[z.ZodObject
|
|
|
72
72
|
cacheWriteTokens?: number | undefined;
|
|
73
73
|
}>>>;
|
|
74
74
|
lastFinishReason: z.ZodEnum<{
|
|
75
|
+
length: "length";
|
|
75
76
|
error: "error";
|
|
76
77
|
unknown: "unknown";
|
|
77
|
-
length: "length";
|
|
78
78
|
cancelled: "cancelled";
|
|
79
79
|
stop: "stop";
|
|
80
80
|
other: "other";
|
|
@@ -117,9 +117,9 @@ export declare const TurnDriverStateSchema: z.ZodDiscriminatedUnion<[z.ZodObject
|
|
|
117
117
|
cacheWriteTokens?: number | undefined;
|
|
118
118
|
}>>>;
|
|
119
119
|
lastFinishReason: z.ZodEnum<{
|
|
120
|
+
length: "length";
|
|
120
121
|
error: "error";
|
|
121
122
|
unknown: "unknown";
|
|
122
|
-
length: "length";
|
|
123
123
|
cancelled: "cancelled";
|
|
124
124
|
stop: "stop";
|
|
125
125
|
other: "other";
|
|
@@ -137,9 +137,9 @@ export declare const TurnDriverStateSchema: z.ZodDiscriminatedUnion<[z.ZodObject
|
|
|
137
137
|
result: z.ZodObject<{
|
|
138
138
|
text: z.ZodString;
|
|
139
139
|
finishReason: z.ZodEnum<{
|
|
140
|
+
length: "length";
|
|
140
141
|
error: "error";
|
|
141
142
|
unknown: "unknown";
|
|
142
|
-
length: "length";
|
|
143
143
|
cancelled: "cancelled";
|
|
144
144
|
stop: "stop";
|
|
145
145
|
other: "other";
|
|
@@ -192,9 +192,9 @@ export declare const TurnDriverStateSchema: z.ZodDiscriminatedUnion<[z.ZodObject
|
|
|
192
192
|
cacheWriteTokens?: number | undefined;
|
|
193
193
|
}>>>;
|
|
194
194
|
lastFinishReason: z.ZodEnum<{
|
|
195
|
+
length: "length";
|
|
195
196
|
error: "error";
|
|
196
197
|
unknown: "unknown";
|
|
197
|
-
length: "length";
|
|
198
198
|
cancelled: "cancelled";
|
|
199
199
|
stop: "stop";
|
|
200
200
|
other: "other";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"turn-executor.d.ts","sourceRoot":"","sources":["../../../src/llm/executor/turn-executor.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,aAAa,EAMb,KAAK,YAAY,EAEpB,MAAM,IAAI,CAAC;AACZ,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAa,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAE3E,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAY1D,OAAO,EACH,WAAW,EAId,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAcpD,OAAO,KAAK,EAAE,cAAc,EAAiB,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEvF,OAAO,KAAK,EACR,UAAU,EACV,kBAAkB,EAClB,UAAU,EAEV,aAAa,EAEhB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAEvD,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC9E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAIxE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{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qB;YAiGrB,oBAAoB;YAmDpB,4BAA4B;IA+C1C,OAAO,CAAC,oBAAoB;YAad,gCAAgC;YA+BhC,gCAAgC;IAyD9C,OAAO,CAAC,mBAAmB;IAY3B,OAAO,CAAC,gBAAgB;IAexB,OAAO,CAAC,2BAA2B;YAkBrB,uBAAuB;IAuBrC;;;;OAIG;YACW,yBAAyB;YAqCzB,sBAAsB;IAsCpC,OAAO,CAAC,YAAY;IAkBpB,OAAO,CAAC,2BAA2B;IAanC,OAAO,CAAC,iCAAiC;IAUzC,OAAO,CAAC,wBAAwB;IA6BhC,OAAO,CAAC,yBAAyB;IAIjC,OAAO,CAAC,4BAA4B;IAmBpC,OAAO,CAAC,wBAAwB;IAMhC,OAAO,CAAC,6BAA6B;IAYrC;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,iBAAiB,CAAU;IACnD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,0BAA0B,CAAO;IACzD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAU;IAE/C,OAAO,CAAC,qBAAqB;IAS7B;;;;OAIG;IACH,OAAO,CAAC,6BAA6B;IAgBrC;;;;;;;;;;;;OAYG;YACW,mBAAmB;IA2DjC;;;;;;OAMG;IACH,OAAO,CAAC,kBAAkB;IAgB1B;;;OAGG;IACH,OAAO,CAAC,OAAO;IASf;;;;;;OAMG;IACH,OAAO,CAAC,aAAa;IAOrB;;;;;;OAMG;IACH,OAAO,CAAC,uBAAuB;IAO/B;;;;;;;;;;;;OAYG;YACW,cAAc;IA2F5B;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAoB9B,OAAO,CAAC,qBAAqB;IAK7B;;OAEG;IACH,OAAO,CAAC,gBAAgB;CAQ3B"}
|
|
@@ -29,6 +29,7 @@ import {
|
|
|
29
29
|
import { isEmptyModelResponse } from "./empty-response.js";
|
|
30
30
|
import { LLMError } from "../errors.js";
|
|
31
31
|
import { LLMErrorCode } from "../error-codes.js";
|
|
32
|
+
import { createSafeDownload } from "../safe-download.js";
|
|
32
33
|
import { DextoRuntimeError } from "../../errors/DextoRuntimeError.js";
|
|
33
34
|
import { toError } from "../../utils/error-conversion.js";
|
|
34
35
|
import { isCodexBaseURL } from "../providers/codex-base-url.js";
|
|
@@ -44,6 +45,7 @@ import {
|
|
|
44
45
|
describeInternalMessageTailForAudit
|
|
45
46
|
} from "../../context/content-audit.js";
|
|
46
47
|
import { cloneStructuredValuePreservingUrls } from "../../context/content-clone.js";
|
|
48
|
+
const safeDownload = createSafeDownload();
|
|
47
49
|
const MCP_TOOL_PREFIX = "mcp--";
|
|
48
50
|
const MODEL_REQUEST_MAX_RETRIES = 2;
|
|
49
51
|
const EMPTY_RESPONSE_MAX_RETRIES = 1;
|
|
@@ -1314,6 +1316,7 @@ class TurnExecutor {
|
|
|
1314
1316
|
tools: request.tools,
|
|
1315
1317
|
abortSignal,
|
|
1316
1318
|
messages: request.messages,
|
|
1319
|
+
experimental_download: safeDownload,
|
|
1317
1320
|
...this.config.maxOutputTokens !== void 0 && {
|
|
1318
1321
|
maxOutputTokens: this.config.maxOutputTokens
|
|
1319
1322
|
},
|
|
@@ -1416,6 +1419,7 @@ class TurnExecutor {
|
|
|
1416
1419
|
if (this.stepAbortController.signal.aborted) return false;
|
|
1417
1420
|
if (error instanceof DextoRuntimeError) return error.code === LLMErrorCode.STREAM_STALLED;
|
|
1418
1421
|
if (!APICallError.isInstance?.(error)) return false;
|
|
1422
|
+
if (error.statusCode === 401) return false;
|
|
1419
1423
|
return error.isRetryable;
|
|
1420
1424
|
}
|
|
1421
1425
|
async applyModelStepResult(input) {
|
package/dist/llm/index.cjs
CHANGED
|
@@ -22,6 +22,7 @@ __export(llm_exports, {
|
|
|
22
22
|
CodexAppServerClient: () => import_codex_app_server.CodexAppServerClient,
|
|
23
23
|
createCodexBaseURL: () => import_codex_base_url.createCodexBaseURL,
|
|
24
24
|
createCodexLanguageModel: () => import_codex_app_server.createCodexLanguageModel,
|
|
25
|
+
createSafeDownload: () => import_safe_download.createSafeDownload,
|
|
25
26
|
getCachedOpenRouterModelsWithInfo: () => import_openrouter_model_registry.getCachedOpenRouterModelsWithInfo,
|
|
26
27
|
getCodexAuthModeLabel: () => import_codex_base_url.getCodexAuthModeLabel,
|
|
27
28
|
getCodexProviderDisplayName: () => import_codex_base_url.getCodexProviderDisplayName,
|
|
@@ -30,6 +31,7 @@ __export(llm_exports, {
|
|
|
30
31
|
getOpenRouterModelContextLength: () => import_openrouter_model_registry.getOpenRouterModelContextLength,
|
|
31
32
|
getOpenRouterModelInfo: () => import_openrouter_model_registry.getOpenRouterModelInfo,
|
|
32
33
|
isCodexBaseURL: () => import_codex_base_url.isCodexBaseURL,
|
|
34
|
+
isPrivateAddress: () => import_private_address.isPrivateAddress,
|
|
33
35
|
loadLlmRegistryCache: () => import_auto_update.loadLlmRegistryCache,
|
|
34
36
|
lookupOpenRouterModel: () => import_openrouter_model_registry.lookupOpenRouterModel,
|
|
35
37
|
parseCodexBaseURL: () => import_codex_base_url.parseCodexBaseURL,
|
|
@@ -47,6 +49,8 @@ __reExport(llm_exports, require("./validation.js"), module.exports);
|
|
|
47
49
|
__reExport(llm_exports, require("./usage-metadata.js"), module.exports);
|
|
48
50
|
__reExport(llm_exports, require("./usage-scope.js"), module.exports);
|
|
49
51
|
__reExport(llm_exports, require("./usage-summary.js"), module.exports);
|
|
52
|
+
var import_private_address = require("./private-address.js");
|
|
53
|
+
var import_safe_download = require("./safe-download.js");
|
|
50
54
|
__reExport(llm_exports, require("./services/index.js"), module.exports);
|
|
51
55
|
__reExport(llm_exports, require("./executor/index.js"), module.exports);
|
|
52
56
|
__reExport(llm_exports, require("./schemas.js"), module.exports);
|
|
@@ -60,6 +64,7 @@ __reExport(llm_exports, require("./providers/local/index.js"), module.exports);
|
|
|
60
64
|
CodexAppServerClient,
|
|
61
65
|
createCodexBaseURL,
|
|
62
66
|
createCodexLanguageModel,
|
|
67
|
+
createSafeDownload,
|
|
63
68
|
getCachedOpenRouterModelsWithInfo,
|
|
64
69
|
getCodexAuthModeLabel,
|
|
65
70
|
getCodexProviderDisplayName,
|
|
@@ -68,6 +73,7 @@ __reExport(llm_exports, require("./providers/local/index.js"), module.exports);
|
|
|
68
73
|
getOpenRouterModelContextLength,
|
|
69
74
|
getOpenRouterModelInfo,
|
|
70
75
|
isCodexBaseURL,
|
|
76
|
+
isPrivateAddress,
|
|
71
77
|
loadLlmRegistryCache,
|
|
72
78
|
lookupOpenRouterModel,
|
|
73
79
|
parseCodexBaseURL,
|
package/dist/llm/index.d.ts
CHANGED
|
@@ -6,7 +6,9 @@ export * from './validation.js';
|
|
|
6
6
|
export * from './usage-metadata.js';
|
|
7
7
|
export * from './usage-scope.js';
|
|
8
8
|
export * from './usage-summary.js';
|
|
9
|
-
export
|
|
9
|
+
export { isPrivateAddress } from './private-address.js';
|
|
10
|
+
export { createSafeDownload, type SafeDownloadOptions } from './safe-download.js';
|
|
11
|
+
export type { LlmAuthResolver, LlmRequestAuth, LlmRuntimeAuthOverrides, ResolveLlmRuntimeAuthInput, } from './auth/index.js';
|
|
10
12
|
export * from './services/index.js';
|
|
11
13
|
export * from './executor/index.js';
|
|
12
14
|
export * from './schemas.js';
|
package/dist/llm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/llm/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,YAAY,EACR,eAAe,EACf,uBAAuB,EACvB,0BAA0B,GAC7B,MAAM,iBAAiB,CAAC;AACzB,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,c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C9B,2BAA2B,EAC3B,2BAA2B,EAC3B,+BAA+B,EAC/B,sBAAsB,EACtB,KAAK,YAAY,EACjB,KAAK,mBAAmB,GAC3B,MAAM,0CAA0C,CAAC;AAClD,OAAO,EACH,kBAAkB,EAClB,qBAAqB,EACrB,2BAA2B,EAC3B,cAAc,EACd,iBAAiB,EACjB,KAAK,aAAa,GACrB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACH,oBAAoB,EACpB,wBAAwB,EACxB,KAAK,2BAA2B,EAChC,KAAK,cAAc,EACnB,KAAK,sBAAsB,GAC9B,MAAM,iCAAiC,CAAC;AAGzC,OAAO,EACH,0BAA0B,EAC1B,uBAAuB,EACvB,oBAAoB,EACpB,8BAA8B,EAC9B,KAAK,2BAA2B,GACnC,MAAM,2BAA2B,CAAC;AAGnC,cAAc,4BAA4B,CAAC"}
|
package/dist/llm/index.js
CHANGED
|
@@ -7,6 +7,8 @@ export * from "./validation.js";
|
|
|
7
7
|
export * from "./usage-metadata.js";
|
|
8
8
|
export * from "./usage-scope.js";
|
|
9
9
|
export * from "./usage-summary.js";
|
|
10
|
+
import { isPrivateAddress } from "./private-address.js";
|
|
11
|
+
import { createSafeDownload } from "./safe-download.js";
|
|
10
12
|
export * from "./services/index.js";
|
|
11
13
|
export * from "./executor/index.js";
|
|
12
14
|
export * from "./schemas.js";
|
|
@@ -41,6 +43,7 @@ export {
|
|
|
41
43
|
CodexAppServerClient,
|
|
42
44
|
createCodexBaseURL,
|
|
43
45
|
createCodexLanguageModel,
|
|
46
|
+
createSafeDownload,
|
|
44
47
|
getCachedOpenRouterModelsWithInfo,
|
|
45
48
|
getCodexAuthModeLabel,
|
|
46
49
|
getCodexProviderDisplayName,
|
|
@@ -49,6 +52,7 @@ export {
|
|
|
49
52
|
getOpenRouterModelContextLength,
|
|
50
53
|
getOpenRouterModelInfo,
|
|
51
54
|
isCodexBaseURL,
|
|
55
|
+
isPrivateAddress,
|
|
52
56
|
loadLlmRegistryCache,
|
|
53
57
|
lookupOpenRouterModel,
|
|
54
58
|
parseCodexBaseURL,
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var private_address_exports = {};
|
|
20
|
+
__export(private_address_exports, {
|
|
21
|
+
isPrivateAddress: () => isPrivateAddress
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(private_address_exports);
|
|
24
|
+
var import_node_net = require("node:net");
|
|
25
|
+
function isPrivateIpv4Octets(a, b, c) {
|
|
26
|
+
if (a === 0) return true;
|
|
27
|
+
if (a === 10) return true;
|
|
28
|
+
if (a === 127) return true;
|
|
29
|
+
if (a === 169 && b === 254) return true;
|
|
30
|
+
if (a === 172 && b >= 16 && b <= 31) return true;
|
|
31
|
+
if (a === 192 && b === 168) return true;
|
|
32
|
+
if (a === 100 && b >= 64 && b <= 127) return true;
|
|
33
|
+
if (a === 192 && b === 0 && c === 0) return true;
|
|
34
|
+
if (a === 192 && b === 0 && c === 2) return true;
|
|
35
|
+
if (a === 198 && b === 51 && c === 100) return true;
|
|
36
|
+
if (a === 203 && b === 0 && c === 113) return true;
|
|
37
|
+
if (a === 198 && (b === 18 || b === 19)) return true;
|
|
38
|
+
if (a >= 224) return true;
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
function isPrivateIpv4(ip) {
|
|
42
|
+
const [a, b, c, d, ...rest] = ip.split(".").map((part) => Number(part));
|
|
43
|
+
if (a === void 0 || b === void 0 || c === void 0 || d === void 0) return false;
|
|
44
|
+
if (rest.length > 0 || [a, b, c, d].some((part) => Number.isNaN(part))) return false;
|
|
45
|
+
return isPrivateIpv4Octets(a, b, c);
|
|
46
|
+
}
|
|
47
|
+
function isPrivateEmbeddedIpv4(high, low) {
|
|
48
|
+
return isPrivateIpv4Octets(high >> 8, high & 255, low >> 8);
|
|
49
|
+
}
|
|
50
|
+
function ipv6Groups(ip) {
|
|
51
|
+
const canonical = new URL(`http://[${ip.split("%")[0]}]/`).hostname.slice(1, -1);
|
|
52
|
+
const [head = "", tail] = canonical.split("::");
|
|
53
|
+
const headGroups = head === "" ? [] : head.split(":");
|
|
54
|
+
const tailGroups = tail === void 0 || tail === "" ? [] : tail.split(":");
|
|
55
|
+
const missing = tail === void 0 ? 0 : 8 - headGroups.length - tailGroups.length;
|
|
56
|
+
return [...headGroups, ...Array(missing).fill("0"), ...tailGroups].map(
|
|
57
|
+
(group) => Number.parseInt(group, 16)
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
function isPrivateIpv6(ip) {
|
|
61
|
+
const [g0 = 0, g1 = 0, g2 = 0, g3 = 0, g4 = 0, g5 = 0, g6 = 0, g7 = 0] = ipv6Groups(ip);
|
|
62
|
+
const upperZero = g0 + g1 + g2 + g3 === 0;
|
|
63
|
+
if (upperZero && g4 + g5 + g6 === 0 && (g7 === 0 || g7 === 1)) return true;
|
|
64
|
+
if (upperZero && g4 === 0 && g5 === 65535) return isPrivateEmbeddedIpv4(g6, g7);
|
|
65
|
+
if (upperZero && g4 === 65535 && g5 === 0) return isPrivateEmbeddedIpv4(g6, g7);
|
|
66
|
+
if (upperZero && g4 === 0 && g5 === 0) return isPrivateEmbeddedIpv4(g6, g7);
|
|
67
|
+
if (g0 === 100 && g1 === 65435) {
|
|
68
|
+
if (g2 + g3 + g4 + g5 === 0) return isPrivateEmbeddedIpv4(g6, g7);
|
|
69
|
+
if (g2 === 1) return true;
|
|
70
|
+
}
|
|
71
|
+
if (g0 === 8194) return isPrivateEmbeddedIpv4(g1, g2);
|
|
72
|
+
if ((g0 & 65472) === 65152) return true;
|
|
73
|
+
if ((g0 & 65472) === 65216) return true;
|
|
74
|
+
if ((g0 & 65024) === 64512) return true;
|
|
75
|
+
if ((g0 & 65280) === 65280) return true;
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
function isPrivateAddress(ip) {
|
|
79
|
+
const address = ip.startsWith("[") && ip.endsWith("]") ? ip.slice(1, -1) : ip;
|
|
80
|
+
const version = (0, import_node_net.isIP)(address.split("%")[0] ?? address);
|
|
81
|
+
if (version === 4) return isPrivateIpv4(address);
|
|
82
|
+
if (version === 6) return isPrivateIpv6(address);
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
86
|
+
0 && (module.exports = {
|
|
87
|
+
isPrivateAddress
|
|
88
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"private-address.d.ts","sourceRoot":"","sources":["../../src/llm/private-address.ts"],"names":[],"mappings":"AA2EA,qFAAqF;AACrF,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAMpD"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import "../chunk-C6A6W6XS.js";
|
|
2
|
+
import { isIP } from "node:net";
|
|
3
|
+
function isPrivateIpv4Octets(a, b, c) {
|
|
4
|
+
if (a === 0) return true;
|
|
5
|
+
if (a === 10) return true;
|
|
6
|
+
if (a === 127) return true;
|
|
7
|
+
if (a === 169 && b === 254) return true;
|
|
8
|
+
if (a === 172 && b >= 16 && b <= 31) return true;
|
|
9
|
+
if (a === 192 && b === 168) return true;
|
|
10
|
+
if (a === 100 && b >= 64 && b <= 127) return true;
|
|
11
|
+
if (a === 192 && b === 0 && c === 0) return true;
|
|
12
|
+
if (a === 192 && b === 0 && c === 2) return true;
|
|
13
|
+
if (a === 198 && b === 51 && c === 100) return true;
|
|
14
|
+
if (a === 203 && b === 0 && c === 113) return true;
|
|
15
|
+
if (a === 198 && (b === 18 || b === 19)) return true;
|
|
16
|
+
if (a >= 224) return true;
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
function isPrivateIpv4(ip) {
|
|
20
|
+
const [a, b, c, d, ...rest] = ip.split(".").map((part) => Number(part));
|
|
21
|
+
if (a === void 0 || b === void 0 || c === void 0 || d === void 0) return false;
|
|
22
|
+
if (rest.length > 0 || [a, b, c, d].some((part) => Number.isNaN(part))) return false;
|
|
23
|
+
return isPrivateIpv4Octets(a, b, c);
|
|
24
|
+
}
|
|
25
|
+
function isPrivateEmbeddedIpv4(high, low) {
|
|
26
|
+
return isPrivateIpv4Octets(high >> 8, high & 255, low >> 8);
|
|
27
|
+
}
|
|
28
|
+
function ipv6Groups(ip) {
|
|
29
|
+
const canonical = new URL(`http://[${ip.split("%")[0]}]/`).hostname.slice(1, -1);
|
|
30
|
+
const [head = "", tail] = canonical.split("::");
|
|
31
|
+
const headGroups = head === "" ? [] : head.split(":");
|
|
32
|
+
const tailGroups = tail === void 0 || tail === "" ? [] : tail.split(":");
|
|
33
|
+
const missing = tail === void 0 ? 0 : 8 - headGroups.length - tailGroups.length;
|
|
34
|
+
return [...headGroups, ...Array(missing).fill("0"), ...tailGroups].map(
|
|
35
|
+
(group) => Number.parseInt(group, 16)
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
function isPrivateIpv6(ip) {
|
|
39
|
+
const [g0 = 0, g1 = 0, g2 = 0, g3 = 0, g4 = 0, g5 = 0, g6 = 0, g7 = 0] = ipv6Groups(ip);
|
|
40
|
+
const upperZero = g0 + g1 + g2 + g3 === 0;
|
|
41
|
+
if (upperZero && g4 + g5 + g6 === 0 && (g7 === 0 || g7 === 1)) return true;
|
|
42
|
+
if (upperZero && g4 === 0 && g5 === 65535) return isPrivateEmbeddedIpv4(g6, g7);
|
|
43
|
+
if (upperZero && g4 === 65535 && g5 === 0) return isPrivateEmbeddedIpv4(g6, g7);
|
|
44
|
+
if (upperZero && g4 === 0 && g5 === 0) return isPrivateEmbeddedIpv4(g6, g7);
|
|
45
|
+
if (g0 === 100 && g1 === 65435) {
|
|
46
|
+
if (g2 + g3 + g4 + g5 === 0) return isPrivateEmbeddedIpv4(g6, g7);
|
|
47
|
+
if (g2 === 1) return true;
|
|
48
|
+
}
|
|
49
|
+
if (g0 === 8194) return isPrivateEmbeddedIpv4(g1, g2);
|
|
50
|
+
if ((g0 & 65472) === 65152) return true;
|
|
51
|
+
if ((g0 & 65472) === 65216) return true;
|
|
52
|
+
if ((g0 & 65024) === 64512) return true;
|
|
53
|
+
if ((g0 & 65280) === 65280) return true;
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
function isPrivateAddress(ip) {
|
|
57
|
+
const address = ip.startsWith("[") && ip.endsWith("]") ? ip.slice(1, -1) : ip;
|
|
58
|
+
const version = isIP(address.split("%")[0] ?? address);
|
|
59
|
+
if (version === 4) return isPrivateIpv4(address);
|
|
60
|
+
if (version === 6) return isPrivateIpv6(address);
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
export {
|
|
64
|
+
isPrivateAddress
|
|
65
|
+
};
|
|
@@ -612,7 +612,7 @@ function enforceAuthMode(authMode, accountState) {
|
|
|
612
612
|
if (accountState.requiresOpenaiAuth) {
|
|
613
613
|
throw import_errors.LLMError.missingConfig(
|
|
614
614
|
"openai-compatible",
|
|
615
|
-
"Codex authentication (run `codex login`
|
|
615
|
+
"Codex authentication (run `codex login`)"
|
|
616
616
|
);
|
|
617
617
|
}
|
|
618
618
|
return;
|
|
@@ -623,13 +623,13 @@ function enforceAuthMode(authMode, accountState) {
|
|
|
623
623
|
if (authMode === "chatgpt" && accountState.account.type !== "chatgpt") {
|
|
624
624
|
throw import_errors.LLMError.missingConfig(
|
|
625
625
|
"openai-compatible",
|
|
626
|
-
"a ChatGPT-backed Codex login (run `codex logout` and sign in with ChatGPT
|
|
626
|
+
"a ChatGPT-backed Codex login (run `codex logout` and sign in with ChatGPT)"
|
|
627
627
|
);
|
|
628
628
|
}
|
|
629
629
|
if (authMode === "apikey" && accountState.account.type !== "apiKey") {
|
|
630
630
|
throw import_errors.LLMError.missingConfig(
|
|
631
631
|
"openai-compatible",
|
|
632
|
-
"an API key-backed Codex login (run `codex login --with-api-key`
|
|
632
|
+
"an API key-backed Codex login (run `codex login --with-api-key`)"
|
|
633
633
|
);
|
|
634
634
|
}
|
|
635
635
|
}
|
|
@@ -579,7 +579,7 @@ function enforceAuthMode(authMode, accountState) {
|
|
|
579
579
|
if (accountState.requiresOpenaiAuth) {
|
|
580
580
|
throw LLMError.missingConfig(
|
|
581
581
|
"openai-compatible",
|
|
582
|
-
"Codex authentication (run `codex login`
|
|
582
|
+
"Codex authentication (run `codex login`)"
|
|
583
583
|
);
|
|
584
584
|
}
|
|
585
585
|
return;
|
|
@@ -590,13 +590,13 @@ function enforceAuthMode(authMode, accountState) {
|
|
|
590
590
|
if (authMode === "chatgpt" && accountState.account.type !== "chatgpt") {
|
|
591
591
|
throw LLMError.missingConfig(
|
|
592
592
|
"openai-compatible",
|
|
593
|
-
"a ChatGPT-backed Codex login (run `codex logout` and sign in with ChatGPT
|
|
593
|
+
"a ChatGPT-backed Codex login (run `codex logout` and sign in with ChatGPT)"
|
|
594
594
|
);
|
|
595
595
|
}
|
|
596
596
|
if (authMode === "apikey" && accountState.account.type !== "apiKey") {
|
|
597
597
|
throw LLMError.missingConfig(
|
|
598
598
|
"openai-compatible",
|
|
599
|
-
"an API key-backed Codex login (run `codex login --with-api-key`
|
|
599
|
+
"an API key-backed Codex login (run `codex login --with-api-key`)"
|
|
600
600
|
);
|
|
601
601
|
}
|
|
602
602
|
}
|