@poe-platform/safe-bash 0.1.797 → 0.1.799
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/README.md +2 -1
- package/dist/pdf/index.d.ts +1 -1
- package/dist/pdf/model.d.ts +7 -2
- package/dist/safe-bash/chunks/{chunk-D2XB7XIC.js → chunk-AZAJJVFX.js} +7 -11
- package/dist/safe-bash/chunks/{chunk-C2NYCU7O.js → chunk-JSVX4VIA.js} +5 -1
- package/dist/safe-bash/chunks/{chunk-TCWZNUVP.js → chunk-SPYL72GN.js} +1 -25
- package/dist/safe-bash/chunks/{chunk-TGOF7VO5.js → chunk-TRVGCN3U.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-ZXKVOJNL.js → chunk-WUNK5NXJ.js} +6 -5
- package/dist/safe-bash/command-chunks/{chunk-JG5W2ENK.js → chunk-43GSSUAY.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-OAJUAAWH.js → chunk-464RVBGB.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-25BLI6S6.js → chunk-4Y3WVMK4.js} +1 -14
- package/dist/safe-bash/command-chunks/{chunk-SSBFTMVI.js → chunk-4ZALPDBV.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-YMQKVEIF.js → chunk-52PCQXD2.js} +2 -13
- package/dist/safe-bash/command-chunks/{chunk-ZCKDQGKY.js → chunk-5HDSFHGW.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-JHVZYB4R.js → chunk-5MPOQ6V3.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-AUAF5YBT.js → chunk-5WPI42ZW.js} +0 -7
- package/dist/safe-bash/command-chunks/{chunk-PPOIPMY4.js → chunk-5ZSM4UFN.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-RECJB2BO.js → chunk-7BS66BXN.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-GRWOVSFK.js → chunk-7D7JRRML.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-E6IYUYVA.js → chunk-7L24L4UO.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-HBXQWTJR.js → chunk-A5ZAV6DO.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-LW34AKDM.js → chunk-AB4MXHVS.js} +4 -14
- package/dist/safe-bash/command-chunks/{chunk-EELNLEEP.js → chunk-AXK3H4PX.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-Y55OCH37.js → chunk-AYUTO323.js} +3 -10
- package/dist/safe-bash/command-chunks/{chunk-DY36FDDC.js → chunk-B5BKA5WH.js} +4 -4
- package/dist/safe-bash/command-chunks/{chunk-YB6KVU6H.js → chunk-BDBVVZY6.js} +4 -14
- package/dist/safe-bash/command-chunks/{chunk-QAN7KKDZ.js → chunk-BZDDAPSV.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-HZCPWYWA.js → chunk-BZPAWTUL.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-RT2J5ATD.js → chunk-CPPGTBZF.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-A7RIYQIF.js → chunk-DDLQ5YDB.js} +172 -167
- package/dist/safe-bash/command-chunks/{chunk-JEPY4UY4.js → chunk-EIVW3X3N.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-C2DUYVYZ.js → chunk-ESMCX3YV.js} +138 -36
- package/dist/safe-bash/command-chunks/chunk-EZ7D6DXC.js +6 -0
- package/dist/safe-bash/command-chunks/{chunk-QGVOS3EY.js → chunk-HFII3QYO.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-5EWTQJSC.js → chunk-HHP343KT.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-5UA3BEGA.js → chunk-I3K5RYU4.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-4MS5WZJC.js → chunk-IKS2YXZQ.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-CZVBYCB5.js → chunk-IL53SJL4.js} +2 -12
- package/dist/safe-bash/command-chunks/{chunk-HLMUPSM6.js → chunk-JCNNOMBV.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-2LLZBNLL.js → chunk-JWE54GHQ.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-QLDIP3OP.js → chunk-JZSNU2MY.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-2HOESGFJ.js → chunk-KMCZ6P4O.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-U3ONEICA.js → chunk-KVFCSLKK.js} +1 -11
- package/dist/safe-bash/command-chunks/{chunk-THS4YAKG.js → chunk-LLCXZKZ6.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-3TANKHBX.js → chunk-MRW5HD2D.js} +1 -6
- package/dist/safe-bash/command-chunks/{chunk-3WKA57FA.js → chunk-N5FGCXQJ.js} +1 -9
- package/dist/safe-bash/command-chunks/{chunk-ULZ7HIZP.js → chunk-NETECMOF.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-2Q7UQ7R4.js → chunk-OPUJSTHS.js} +12 -12
- package/dist/safe-bash/command-chunks/{chunk-HVI6ALJF.js → chunk-PFAADCB5.js} +2 -4
- package/dist/safe-bash/command-chunks/{chunk-JXU2N6GN.js → chunk-Q7Q5GM5S.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-Z5TFSVNU.js → chunk-QAKKSRNV.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-KAHH4XOU.js → chunk-QNXI2UP6.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-ECAK3JHR.js → chunk-QRRYN2KO.js} +21 -12
- package/dist/safe-bash/command-chunks/{chunk-WYOL5JNT.js → chunk-SX2X3IH4.js} +4 -4
- package/dist/safe-bash/command-chunks/{chunk-WBJKOTSP.js → chunk-UI32HWGS.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-AC6X7Q4I.js → chunk-VVI4Z73I.js} +1 -8
- package/dist/safe-bash/command-chunks/{chunk-JCVXAX2G.js → chunk-XWZBMJ5B.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-UUR2S7AD.js → chunk-Y6TUZWPS.js} +28 -1
- package/dist/safe-bash/command-chunks/{chunk-23XLM73P.js → chunk-YEOPI5SK.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-PRCT7FKJ.js → chunk-YZ5SVZFD.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-OGUMMTTD.js → chunk-ZJBR5Q5I.js} +4 -4
- package/dist/safe-bash/command-chunks/{chunk-VZ64JXHC.js → chunk-ZS3QPNUL.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-VKQCNX32.js → chunk-ZT4KSS2V.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-6N5V4VBN.js → chunk-ZXKW7SJ2.js} +2 -2
- package/dist/safe-bash/command-chunks/{pptx-KY2OJWZW-76LBHCHD.js → pptx-GBPNWNEP-7EQEVXV5.js} +8 -2
- package/dist/safe-bash/commands/diff-patch/shared.d.ts +0 -2
- package/dist/safe-bash/commands/diff-patch/shared.js +2 -11
- package/dist/safe-bash/commands/llm/index.browser.js +9 -1
- package/dist/safe-bash/commands/llm/providers/index.browser.js +6 -2
- package/dist/safe-bash/commands/text.js +1 -25
- package/dist/safe-bash/core.browser.js +1 -1
- package/dist/safe-bash/core.d.ts +5 -1
- package/dist/safe-bash/core.js +5 -1
- package/dist/safe-bash/full-core.browser.js +134 -5
- package/dist/safe-bash/lazy-optional.d.ts +13 -0
- package/dist/safe-bash/lazy-optional.js +118 -0
- package/dist/safe-bash/opt-in/commands/dd/index.js +4 -13
- package/dist/safe-bash/opt-in/commands/yq/native-work.js +2 -1
- package/dist/safe-bash/opt-in/optional/commands/shuf/input.js +3 -21
- package/dist/safe-bash/opt-in/optional/commands/shuf/shuf.js +4 -27
- package/dist/safe-bash/plugins/index.browser.js +3 -3
- package/dist/safe-bash/registry-entry.browser.js +2 -2
- package/dist/safe-bash/shell/env-warning.js +3 -2
- package/dist/safe-bash/shell/runtime.js +2 -2
- package/dist/safe-bash/shell-entry.browser.js +2 -2
- package/dist/safe-bash-command-csvkit/index.js +528 -498
- package/dist/safe-bash-command-dd/index.js +4 -13
- package/dist/safe-bash-command-du/budget.d.ts +0 -2
- package/dist/safe-bash-command-du/budget.js +1 -1
- package/dist/safe-bash-command-du/du.js +2 -2
- package/dist/safe-bash-command-du/index.js +2 -2
- package/dist/safe-bash-command-file/index.js +1 -1
- package/dist/safe-bash-command-file/shared.d.ts +0 -2
- package/dist/safe-bash-command-file/shared.js +1 -1
- package/dist/safe-bash-command-fmt/index.js +3 -15
- package/dist/safe-bash-command-git/git_rust.wasm +0 -0
- package/dist/safe-bash-command-git/wasm.generated.js +1 -1
- package/dist/safe-bash-command-html-to-markdown/budget.d.ts +0 -3
- package/dist/safe-bash-command-html-to-markdown/budget.js +1 -1
- package/dist/safe-bash-command-html-to-markdown/entities.js +3 -3
- package/dist/safe-bash-command-html-to-markdown/index.js +6 -6
- package/dist/safe-bash-command-html-to-markdown/input.js +5 -5
- package/dist/safe-bash-command-html-to-markdown/parser.js +4 -4
- package/dist/safe-bash-command-html-to-markdown/render.js +5 -5
- package/dist/safe-bash-command-html-to-markdown/text.js +2 -2
- package/dist/safe-bash-command-iconv/command.js +5 -5
- package/dist/safe-bash-command-iconv/index.js +5 -5
- package/dist/safe-bash-command-iconv/internal.d.ts +0 -2
- package/dist/safe-bash-command-iconv/internal.js +1 -1
- package/dist/safe-bash-command-iconv/lifecycle.js +2 -2
- package/dist/safe-bash-command-iconv/options.js +2 -2
- package/dist/safe-bash-command-iconv/reader.js +2 -2
- package/dist/safe-bash-command-llm/base64-stream.d.ts +2 -0
- package/dist/safe-bash-command-llm/chat-json.d.ts +10 -0
- package/dist/safe-bash-command-llm/index.d.ts +2 -1
- package/dist/safe-bash-command-llm/index.js +11 -2
- package/dist/safe-bash-command-llm/json-string.d.ts +2 -0
- package/dist/safe-bash-command-llm/json-value.d.ts +2 -0
- package/dist/safe-bash-command-llm/openai.d.ts +1 -0
- package/dist/safe-bash-command-llm/openai.js +4 -2
- package/dist/safe-bash-command-llm/provider-serialization.d.ts +6 -0
- package/dist/safe-bash-command-llm/providers/index.d.ts +2 -1
- package/dist/safe-bash-command-llm/providers/index.js +12 -3
- package/dist/safe-bash-command-llm/providers/openai.d.ts +1 -1
- package/dist/safe-bash-command-llm/providers/openai.js +4 -2
- package/dist/safe-bash-command-numfmt/index.js +4 -18
- package/dist/safe-bash-command-pandoc/citeproc-filters.js +1 -1
- package/dist/safe-bash-command-pandoc/command.js +3 -3
- package/dist/safe-bash-command-pandoc/index.js +3 -3
- package/dist/safe-bash-command-pr/command.js +5 -5
- package/dist/safe-bash-command-pr/format.js +2 -2
- package/dist/safe-bash-command-pr/index.js +5 -5
- package/dist/safe-bash-command-pr/internal.d.ts +0 -2
- package/dist/safe-bash-command-pr/internal.js +1 -1
- package/dist/safe-bash-command-pr/io.js +2 -2
- package/dist/safe-bash-command-pr/options.js +2 -2
- package/dist/safe-bash-command-shuf/input.js +3 -21
- package/dist/safe-bash-command-shuf/shuf.js +4 -27
- package/dist/safe-bash-command-split/index.js +3 -3
- package/dist/safe-bash-command-split/io.d.ts +0 -2
- package/dist/safe-bash-command-split/io.js +1 -1
- package/dist/safe-bash-command-split/outputs.js +2 -2
- package/dist/safe-bash-command-split/split.js +3 -3
- package/dist/safe-bash-command-ssconvert/index.js +1 -1
- package/dist/safe-bash-command-tree/arguments.js +3 -3
- package/dist/safe-bash-command-tree/charset.js +1 -1
- package/dist/safe-bash-command-tree/index.js +4 -4
- package/dist/safe-bash-command-tree/io.d.ts +0 -1
- package/dist/safe-bash-command-tree/io.js +1 -1
- package/dist/safe-bash-command-tree/pattern.js +2 -2
- package/dist/safe-bash-command-tree/tree.js +4 -4
- package/dist/safe-bash-command-tsort/command.js +4 -4
- package/dist/safe-bash-command-tsort/graph.js +2 -2
- package/dist/safe-bash-command-tsort/index.js +4 -4
- package/dist/safe-bash-command-tsort/internal.d.ts +0 -2
- package/dist/safe-bash-command-tsort/internal.js +1 -1
- package/dist/safe-bash-command-tsort/io.js +2 -2
- package/dist/safe-bash-command-yq/native-work.js +2 -1
- package/dist/safe-bash-io-engine/commands/archive/internal.d.ts +0 -1
- package/dist/safe-bash-io-engine/commands/archive/internal.js +3 -7
- package/dist/safe-bash-io-engine/shell/pattern.js +1 -1
- package/dist/safe-bash-io-engine/shell/string-operations.d.ts +0 -2
- package/dist/safe-bash-io-engine/shell/string-operations.js +1 -1
- package/dist/safe-bash-line-ending-engine/internal.d.ts +0 -2
- package/dist/safe-bash-line-ending-engine/internal.js +1 -9
- package/dist/safe-bash-query-engine/capture.js +5 -5
- package/dist/safe-bash-query-engine/dates.js +2 -2
- package/dist/safe-bash-query-engine/delpaths.js +5 -5
- package/dist/safe-bash-query-engine/formats.js +3 -3
- package/dist/safe-bash-query-engine/index.js +15 -15
- package/dist/safe-bash-query-engine/indices.js +5 -5
- package/dist/safe-bash-query-engine/input.js +2 -2
- package/dist/safe-bash-query-engine/interpreter.js +13 -13
- package/dist/safe-bash-query-engine/limits.js +1 -1
- package/dist/safe-bash-query-engine/parser.js +2 -2
- package/dist/safe-bash-query-engine/query-core.js +15 -15
- package/dist/safe-bash-query-engine/recurse.js +2 -2
- package/dist/safe-bash-query-engine/regex.js +5 -5
- package/dist/safe-bash-query-engine/split.js +2 -2
- package/dist/safe-bash-query-engine/splits.js +6 -6
- package/dist/safe-bash-query-engine/values.js +4 -4
- package/dist/safe-bash-regex-engine/ere/limits.d.ts +0 -1
- package/dist/safe-bash-regex-engine/ere/limits.js +1 -1
- package/dist/safe-bash-regex-engine/ere/matcher.js +5 -5
- package/dist/safe-bash-regex-engine/ere/syntax.js +2 -2
- package/dist/safe-bash-regex-engine/execution/bounded-provider.js +2 -4
- package/dist/safe-bash-text-stream-engine/stream-format/shared.d.ts +0 -2
- package/dist/safe-bash-text-stream-engine/stream-format/shared.js +1 -9
- package/dist/safe-bash-xml-engine/document.js +2 -2
- package/dist/safe-bash-xml-engine/index.js +3 -3
- package/dist/safe-bash-xml-engine/io.js +1 -1
- package/dist/safe-bash-xml-engine/limits.d.ts +0 -2
- package/dist/safe-bash-xml-engine/limits.js +1 -1
- package/dist/safe-bash-xml-engine/query.js +2 -2
- package/package.json +5 -4
|
@@ -27,173 +27,6 @@ import {
|
|
|
27
27
|
// packages/safe-bash-command-llm/src/openai.ts
|
|
28
28
|
init_buffer();
|
|
29
29
|
|
|
30
|
-
// packages/safe-bash-command-llm/src/openai-chat-options.ts
|
|
31
|
-
init_buffer();
|
|
32
|
-
|
|
33
|
-
// packages/safe-bash-command-llm/src/token-integer.ts
|
|
34
|
-
init_buffer();
|
|
35
|
-
var decimalZeroes = [
|
|
36
|
-
48,
|
|
37
|
-
1632,
|
|
38
|
-
1776,
|
|
39
|
-
1984,
|
|
40
|
-
2406,
|
|
41
|
-
2534,
|
|
42
|
-
2662,
|
|
43
|
-
2790,
|
|
44
|
-
2918,
|
|
45
|
-
3046,
|
|
46
|
-
3174,
|
|
47
|
-
3302,
|
|
48
|
-
3430,
|
|
49
|
-
3558,
|
|
50
|
-
3664,
|
|
51
|
-
3792,
|
|
52
|
-
3872,
|
|
53
|
-
4160,
|
|
54
|
-
4240,
|
|
55
|
-
6112,
|
|
56
|
-
6160,
|
|
57
|
-
6470,
|
|
58
|
-
6608,
|
|
59
|
-
6784,
|
|
60
|
-
6800,
|
|
61
|
-
6992,
|
|
62
|
-
7088,
|
|
63
|
-
7232,
|
|
64
|
-
7248,
|
|
65
|
-
42528,
|
|
66
|
-
43216,
|
|
67
|
-
43264,
|
|
68
|
-
43472,
|
|
69
|
-
43504,
|
|
70
|
-
43600,
|
|
71
|
-
44016,
|
|
72
|
-
65296,
|
|
73
|
-
66720,
|
|
74
|
-
68912,
|
|
75
|
-
69734,
|
|
76
|
-
69872,
|
|
77
|
-
69942,
|
|
78
|
-
70096,
|
|
79
|
-
70384,
|
|
80
|
-
70736,
|
|
81
|
-
70864,
|
|
82
|
-
71248,
|
|
83
|
-
71360,
|
|
84
|
-
71472,
|
|
85
|
-
71904,
|
|
86
|
-
72016,
|
|
87
|
-
72784,
|
|
88
|
-
73040,
|
|
89
|
-
73120,
|
|
90
|
-
92768,
|
|
91
|
-
93008,
|
|
92
|
-
120782,
|
|
93
|
-
120792,
|
|
94
|
-
120802,
|
|
95
|
-
120812,
|
|
96
|
-
120822,
|
|
97
|
-
123200,
|
|
98
|
-
123632,
|
|
99
|
-
125264,
|
|
100
|
-
130032
|
|
101
|
-
];
|
|
102
|
-
function digit(code) {
|
|
103
|
-
if (code === void 0) return void 0;
|
|
104
|
-
if (code >= 48 && code <= 57) return code - 48;
|
|
105
|
-
for (const zero of decimalZeroes) if (code >= zero && code < zero + 10) return code - zero;
|
|
106
|
-
return void 0;
|
|
107
|
-
}
|
|
108
|
-
function whitespace(code) {
|
|
109
|
-
return code >= 9 && code <= 13 || code === 32 || code === 133 || code === 160 || code === 5760 || code >= 8192 && code <= 8202 || code === 8232 || code === 8233 || code === 8239 || code === 8287 || code === 12288;
|
|
110
|
-
}
|
|
111
|
-
function tokenInteger(input) {
|
|
112
|
-
let start = 0, end = input.length;
|
|
113
|
-
while (start < end && whitespace(input.charCodeAt(start))) start++;
|
|
114
|
-
while (end > start && whitespace(input.charCodeAt(end - 1))) end--;
|
|
115
|
-
let normalized = "", previousDigit = false, digits = 0;
|
|
116
|
-
if (input[start] === "+" || input[start] === "-") normalized = input[start++];
|
|
117
|
-
for (let index = start; index < end; ) {
|
|
118
|
-
const code = input.codePointAt(index);
|
|
119
|
-
const value = digit(code);
|
|
120
|
-
if (value !== void 0) {
|
|
121
|
-
normalized += String(value);
|
|
122
|
-
digits++;
|
|
123
|
-
previousDigit = true;
|
|
124
|
-
} else if (code === 95 && previousDigit && digit(input.codePointAt(index + 1)) !== void 0) previousDigit = false;
|
|
125
|
-
else return void 0;
|
|
126
|
-
index += code > 65535 ? 2 : 1;
|
|
127
|
-
}
|
|
128
|
-
return digits ? BigInt(normalized).toString() : void 0;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
// packages/safe-bash-command-llm/src/openai-chat-options.ts
|
|
132
|
-
function biasInteger(value) {
|
|
133
|
-
if (typeof value === "boolean") return Number(value);
|
|
134
|
-
if (typeof value === "number") return Number.isFinite(value) ? Math.trunc(value) : void 0;
|
|
135
|
-
if (typeof value !== "string") return void 0;
|
|
136
|
-
const integer = tokenInteger(value);
|
|
137
|
-
return integer === void 0 ? void 0 : Number(integer);
|
|
138
|
-
}
|
|
139
|
-
function dictionaryKeys(json) {
|
|
140
|
-
const keys = /* @__PURE__ */ new Set();
|
|
141
|
-
let depth = 0;
|
|
142
|
-
let expectingKey = false;
|
|
143
|
-
for (let index = 0; index < json.length; index++) {
|
|
144
|
-
const char = json[index];
|
|
145
|
-
if (char === '"') {
|
|
146
|
-
const start = index;
|
|
147
|
-
while (++index < json.length) {
|
|
148
|
-
if (json[index] === "\\") index++;
|
|
149
|
-
else if (json[index] === '"') break;
|
|
150
|
-
}
|
|
151
|
-
if (depth === 1 && expectingKey) {
|
|
152
|
-
keys.add(JSON.parse(json.slice(start, index + 1)));
|
|
153
|
-
expectingKey = false;
|
|
154
|
-
}
|
|
155
|
-
} else if (char === "{" || char === "[") {
|
|
156
|
-
depth++;
|
|
157
|
-
if (depth === 1) expectingKey = true;
|
|
158
|
-
} else if (char === "}" || char === "]") depth--;
|
|
159
|
-
else if (char === "," && depth === 1) expectingKey = true;
|
|
160
|
-
}
|
|
161
|
-
return [...keys];
|
|
162
|
-
}
|
|
163
|
-
function logitBias(input) {
|
|
164
|
-
if (typeof input !== "string") throw new TypeError("Invalid OpenAI logit_bias: expected a JSON dictionary");
|
|
165
|
-
let parsed;
|
|
166
|
-
try {
|
|
167
|
-
parsed = JSON.parse(input);
|
|
168
|
-
} catch {
|
|
169
|
-
throw new TypeError("Invalid OpenAI logit_bias: Invalid JSON in logit_bias string");
|
|
170
|
-
}
|
|
171
|
-
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) throw new TypeError("Invalid OpenAI logit_bias: expected a JSON dictionary");
|
|
172
|
-
const result = {};
|
|
173
|
-
for (const key of dictionaryKeys(input)) {
|
|
174
|
-
const value = parsed[key];
|
|
175
|
-
const token = tokenInteger(key);
|
|
176
|
-
const bias = biasInteger(value);
|
|
177
|
-
if (token === void 0 || bias === void 0 || !Number.isSafeInteger(bias) || bias < -100 || bias > 100) throw new TypeError("Invalid OpenAI logit_bias: Invalid key-value pair in logit_bias dictionary");
|
|
178
|
-
Object.defineProperty(result, token, { value: bias, enumerable: true, configurable: true, writable: true });
|
|
179
|
-
}
|
|
180
|
-
return result;
|
|
181
|
-
}
|
|
182
|
-
function openAiChatOptions(options) {
|
|
183
|
-
const { json_object: jsonObject, logit_bias: bias, ...values } = options;
|
|
184
|
-
const result = { ...values };
|
|
185
|
-
if (bias !== void 0 && bias !== null) result.logit_bias = logitBias(bias);
|
|
186
|
-
if (jsonObject !== void 0 && jsonObject !== null) {
|
|
187
|
-
const text = String(jsonObject).toLowerCase();
|
|
188
|
-
if (!["true", "false", "1", "0", "yes", "no", "on", "off", "y", "n", "t", "f"].includes(text)) throw new TypeError("Invalid OpenAI json_object: expected boolean");
|
|
189
|
-
if (["true", "1", "yes", "on", "y", "t"].includes(text)) {
|
|
190
|
-
if (Object.hasOwn(values, "response_format")) throw new TypeError("OpenAI json_object conflicts with response_format");
|
|
191
|
-
result.response_format = { type: "json_object" };
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
return result;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
30
|
// packages/safe-bash-command-llm/src/chat-json.ts
|
|
198
31
|
init_buffer();
|
|
199
32
|
|
|
@@ -377,6 +210,7 @@ function jsonValue(value, signal) {
|
|
|
377
210
|
// packages/safe-bash-command-llm/src/chat-json.ts
|
|
378
211
|
function chatJson(request, limit) {
|
|
379
212
|
request.signal.throwIfAborted();
|
|
213
|
+
if (limit !== Infinity && (!Number.isSafeInteger(limit) || limit < 0)) throw new RangeError("Invalid provider request byte limit");
|
|
380
214
|
for (const field of ["model", "messages", "stream"]) if (Object.hasOwn(request.options, field)) throw new TypeError(`${field} is controlled by the provider`);
|
|
381
215
|
if (request.schema && Object.hasOwn(request.options, "response_format")) throw new TypeError("schema conflicts with response_format");
|
|
382
216
|
for (const attachment of request.attachments) if (!acceptsMimeType(["image/*"], attachment.mimeType)) throw new TypeError("Only image attachments are supported");
|
|
@@ -426,6 +260,173 @@ function chatJson(request, limit) {
|
|
|
426
260
|
return limited();
|
|
427
261
|
}
|
|
428
262
|
|
|
263
|
+
// packages/safe-bash-command-llm/src/openai-chat-options.ts
|
|
264
|
+
init_buffer();
|
|
265
|
+
|
|
266
|
+
// packages/safe-bash-command-llm/src/token-integer.ts
|
|
267
|
+
init_buffer();
|
|
268
|
+
var decimalZeroes = [
|
|
269
|
+
48,
|
|
270
|
+
1632,
|
|
271
|
+
1776,
|
|
272
|
+
1984,
|
|
273
|
+
2406,
|
|
274
|
+
2534,
|
|
275
|
+
2662,
|
|
276
|
+
2790,
|
|
277
|
+
2918,
|
|
278
|
+
3046,
|
|
279
|
+
3174,
|
|
280
|
+
3302,
|
|
281
|
+
3430,
|
|
282
|
+
3558,
|
|
283
|
+
3664,
|
|
284
|
+
3792,
|
|
285
|
+
3872,
|
|
286
|
+
4160,
|
|
287
|
+
4240,
|
|
288
|
+
6112,
|
|
289
|
+
6160,
|
|
290
|
+
6470,
|
|
291
|
+
6608,
|
|
292
|
+
6784,
|
|
293
|
+
6800,
|
|
294
|
+
6992,
|
|
295
|
+
7088,
|
|
296
|
+
7232,
|
|
297
|
+
7248,
|
|
298
|
+
42528,
|
|
299
|
+
43216,
|
|
300
|
+
43264,
|
|
301
|
+
43472,
|
|
302
|
+
43504,
|
|
303
|
+
43600,
|
|
304
|
+
44016,
|
|
305
|
+
65296,
|
|
306
|
+
66720,
|
|
307
|
+
68912,
|
|
308
|
+
69734,
|
|
309
|
+
69872,
|
|
310
|
+
69942,
|
|
311
|
+
70096,
|
|
312
|
+
70384,
|
|
313
|
+
70736,
|
|
314
|
+
70864,
|
|
315
|
+
71248,
|
|
316
|
+
71360,
|
|
317
|
+
71472,
|
|
318
|
+
71904,
|
|
319
|
+
72016,
|
|
320
|
+
72784,
|
|
321
|
+
73040,
|
|
322
|
+
73120,
|
|
323
|
+
92768,
|
|
324
|
+
93008,
|
|
325
|
+
120782,
|
|
326
|
+
120792,
|
|
327
|
+
120802,
|
|
328
|
+
120812,
|
|
329
|
+
120822,
|
|
330
|
+
123200,
|
|
331
|
+
123632,
|
|
332
|
+
125264,
|
|
333
|
+
130032
|
|
334
|
+
];
|
|
335
|
+
function digit(code) {
|
|
336
|
+
if (code === void 0) return void 0;
|
|
337
|
+
if (code >= 48 && code <= 57) return code - 48;
|
|
338
|
+
for (const zero of decimalZeroes) if (code >= zero && code < zero + 10) return code - zero;
|
|
339
|
+
return void 0;
|
|
340
|
+
}
|
|
341
|
+
function whitespace(code) {
|
|
342
|
+
return code >= 9 && code <= 13 || code === 32 || code === 133 || code === 160 || code === 5760 || code >= 8192 && code <= 8202 || code === 8232 || code === 8233 || code === 8239 || code === 8287 || code === 12288;
|
|
343
|
+
}
|
|
344
|
+
function tokenInteger(input) {
|
|
345
|
+
let start = 0, end = input.length;
|
|
346
|
+
while (start < end && whitespace(input.charCodeAt(start))) start++;
|
|
347
|
+
while (end > start && whitespace(input.charCodeAt(end - 1))) end--;
|
|
348
|
+
let normalized = "", previousDigit = false, digits = 0;
|
|
349
|
+
if (input[start] === "+" || input[start] === "-") normalized = input[start++];
|
|
350
|
+
for (let index = start; index < end; ) {
|
|
351
|
+
const code = input.codePointAt(index);
|
|
352
|
+
const value = digit(code);
|
|
353
|
+
if (value !== void 0) {
|
|
354
|
+
normalized += String(value);
|
|
355
|
+
digits++;
|
|
356
|
+
previousDigit = true;
|
|
357
|
+
} else if (code === 95 && previousDigit && digit(input.codePointAt(index + 1)) !== void 0) previousDigit = false;
|
|
358
|
+
else return void 0;
|
|
359
|
+
index += code > 65535 ? 2 : 1;
|
|
360
|
+
}
|
|
361
|
+
return digits ? BigInt(normalized).toString() : void 0;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
// packages/safe-bash-command-llm/src/openai-chat-options.ts
|
|
365
|
+
function biasInteger(value) {
|
|
366
|
+
if (typeof value === "boolean") return Number(value);
|
|
367
|
+
if (typeof value === "number") return Number.isFinite(value) ? Math.trunc(value) : void 0;
|
|
368
|
+
if (typeof value !== "string") return void 0;
|
|
369
|
+
const integer = tokenInteger(value);
|
|
370
|
+
return integer === void 0 ? void 0 : Number(integer);
|
|
371
|
+
}
|
|
372
|
+
function dictionaryKeys(json) {
|
|
373
|
+
const keys = /* @__PURE__ */ new Set();
|
|
374
|
+
let depth = 0;
|
|
375
|
+
let expectingKey = false;
|
|
376
|
+
for (let index = 0; index < json.length; index++) {
|
|
377
|
+
const char = json[index];
|
|
378
|
+
if (char === '"') {
|
|
379
|
+
const start = index;
|
|
380
|
+
while (++index < json.length) {
|
|
381
|
+
if (json[index] === "\\") index++;
|
|
382
|
+
else if (json[index] === '"') break;
|
|
383
|
+
}
|
|
384
|
+
if (depth === 1 && expectingKey) {
|
|
385
|
+
keys.add(JSON.parse(json.slice(start, index + 1)));
|
|
386
|
+
expectingKey = false;
|
|
387
|
+
}
|
|
388
|
+
} else if (char === "{" || char === "[") {
|
|
389
|
+
depth++;
|
|
390
|
+
if (depth === 1) expectingKey = true;
|
|
391
|
+
} else if (char === "}" || char === "]") depth--;
|
|
392
|
+
else if (char === "," && depth === 1) expectingKey = true;
|
|
393
|
+
}
|
|
394
|
+
return [...keys];
|
|
395
|
+
}
|
|
396
|
+
function logitBias(input) {
|
|
397
|
+
if (typeof input !== "string") throw new TypeError("Invalid OpenAI logit_bias: expected a JSON dictionary");
|
|
398
|
+
let parsed;
|
|
399
|
+
try {
|
|
400
|
+
parsed = JSON.parse(input);
|
|
401
|
+
} catch {
|
|
402
|
+
throw new TypeError("Invalid OpenAI logit_bias: Invalid JSON in logit_bias string");
|
|
403
|
+
}
|
|
404
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) throw new TypeError("Invalid OpenAI logit_bias: expected a JSON dictionary");
|
|
405
|
+
const result = {};
|
|
406
|
+
for (const key of dictionaryKeys(input)) {
|
|
407
|
+
const value = parsed[key];
|
|
408
|
+
const token = tokenInteger(key);
|
|
409
|
+
const bias = biasInteger(value);
|
|
410
|
+
if (token === void 0 || bias === void 0 || !Number.isSafeInteger(bias) || bias < -100 || bias > 100) throw new TypeError("Invalid OpenAI logit_bias: Invalid key-value pair in logit_bias dictionary");
|
|
411
|
+
Object.defineProperty(result, token, { value: bias, enumerable: true, configurable: true, writable: true });
|
|
412
|
+
}
|
|
413
|
+
return result;
|
|
414
|
+
}
|
|
415
|
+
function openAiChatOptions(options) {
|
|
416
|
+
const { json_object: jsonObject, logit_bias: bias, ...values } = options;
|
|
417
|
+
const result = { ...values };
|
|
418
|
+
if (bias !== void 0 && bias !== null) result.logit_bias = logitBias(bias);
|
|
419
|
+
if (jsonObject !== void 0 && jsonObject !== null) {
|
|
420
|
+
const text = String(jsonObject).toLowerCase();
|
|
421
|
+
if (!["true", "false", "1", "0", "yes", "no", "on", "off", "y", "n", "t", "f"].includes(text)) throw new TypeError("Invalid OpenAI json_object: expected boolean");
|
|
422
|
+
if (["true", "1", "yes", "on", "y", "t"].includes(text)) {
|
|
423
|
+
if (Object.hasOwn(values, "response_format")) throw new TypeError("OpenAI json_object conflicts with response_format");
|
|
424
|
+
result.response_format = { type: "json_object" };
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
return result;
|
|
428
|
+
}
|
|
429
|
+
|
|
429
430
|
// packages/safe-bash-command-llm/src/openai.ts
|
|
430
431
|
var numericOptions = {
|
|
431
432
|
chat: /* @__PURE__ */ new Map([
|
|
@@ -728,5 +729,9 @@ function createOpenAiProvider(options) {
|
|
|
728
729
|
}
|
|
729
730
|
|
|
730
731
|
export {
|
|
732
|
+
jsonString,
|
|
733
|
+
jsonValue,
|
|
734
|
+
base64Stream,
|
|
735
|
+
chatJson,
|
|
731
736
|
createOpenAiProvider
|
|
732
737
|
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
regexError
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-KMCZ6P4O.js";
|
|
4
4
|
import {
|
|
5
5
|
describe
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-YZ5SVZFD.js";
|
|
7
7
|
import {
|
|
8
8
|
JqError
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-VVI4Z73I.js";
|
|
10
10
|
import {
|
|
11
11
|
utf8ByteLength
|
|
12
12
|
} from "./chunk-PDKXAR4Y.js";
|