@poe-platform/safe-bash 0.1.819 → 0.1.821
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/safe-bash/command-chunks/{chunk-V2PJO6JL.js → chunk-GRFJKJFN.js} +34 -3
- package/dist/safe-bash/command-chunks/{chunk-AC4FFCRL.js → chunk-RKAL5VFP.js} +132 -31
- package/dist/safe-bash/command-chunks/{chunk-YNFQ5AXM.js → chunk-SENLC5KK.js} +1 -1
- package/dist/safe-bash-command-llm/command.js +2 -2
- package/dist/safe-bash-command-llm/index.js +2 -2
- package/dist/safe-bash-command-llm/service.js +1 -1
- package/dist/safe-bash-csv-engine/index.js +1 -1
- package/dist/safe-bash-csv-engine/text-decoder.js +1 -1
- package/package.json +2 -2
|
@@ -172,6 +172,37 @@ var PythonMultibyteDecoder = class {
|
|
|
172
172
|
}
|
|
173
173
|
};
|
|
174
174
|
|
|
175
|
+
// packages/safe-bash-csv-engine/src/python-hz.ts
|
|
176
|
+
var PythonHzDecoder = class {
|
|
177
|
+
shifted = false;
|
|
178
|
+
pending;
|
|
179
|
+
gb = new PythonMultibyteDecoder(pythonMultibyteTables.gb2312);
|
|
180
|
+
decode(bytes = new Uint8Array(), options = {}) {
|
|
181
|
+
let pending = this.pending, output = "";
|
|
182
|
+
if (bytes.length) this.pending = void 0;
|
|
183
|
+
for (const byte of bytes) {
|
|
184
|
+
if (pending !== void 0) {
|
|
185
|
+
const lead = pending;
|
|
186
|
+
pending = void 0;
|
|
187
|
+
if (lead === 126) {
|
|
188
|
+
if (!this.shifted && byte === 123) this.shifted = true;
|
|
189
|
+
else if (this.shifted && byte === 125) this.shifted = false;
|
|
190
|
+
else if (!this.shifted && byte === 126) output += "~";
|
|
191
|
+
else if (!this.shifted && byte === 10) continue;
|
|
192
|
+
else throw new PythonTextDecodeError("Invalid HZ input");
|
|
193
|
+
} else if (this.shifted && lead >= 33 && lead <= 125 && byte >= 33 && byte <= 126) {
|
|
194
|
+
output += this.gb.decode(Uint8Array.of(lead + 128, byte + 128));
|
|
195
|
+
} else throw new PythonTextDecodeError("Invalid HZ input");
|
|
196
|
+
} else if (byte >= 128) throw new PythonTextDecodeError("Invalid HZ input");
|
|
197
|
+
else if (this.shifted || byte === 126) pending = byte;
|
|
198
|
+
else output += String.fromCharCode(byte);
|
|
199
|
+
}
|
|
200
|
+
if (!options.stream && pending !== void 0) throw new PythonTextDecodeError("Incomplete HZ input");
|
|
201
|
+
this.pending = pending;
|
|
202
|
+
return output;
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
|
|
175
206
|
// packages/safe-bash-csv-engine/src/python-utf32.ts
|
|
176
207
|
var PythonUtf32Decoder = class {
|
|
177
208
|
little;
|
|
@@ -224,15 +255,15 @@ var PythonTextDecoder = class {
|
|
|
224
255
|
constructor(encoding) {
|
|
225
256
|
const name = normalizeEncoding(encoding);
|
|
226
257
|
const canonical = Object.hasOwn(pythonCodecAliases, name) ? pythonCodecAliases[name] : void 0;
|
|
227
|
-
if (canonical === void 0 || !["utf-8-sig", "utf-8", "utf-16", "utf-16-le", "utf-16-be", "utf-32", "utf-32-le", "utf-32-be"].includes(canonical) && !Object.hasOwn(fileCodepages, canonical) && !Object.hasOwn(pythonMultibyteTables, canonical)) throw new RangeError(`unknown encoding: ${encoding}`);
|
|
258
|
+
if (canonical === void 0 || !["hz", "utf-8-sig", "utf-8", "utf-16", "utf-16-le", "utf-16-be", "utf-32", "utf-32-le", "utf-32-be"].includes(canonical) && !Object.hasOwn(fileCodepages, canonical) && !Object.hasOwn(pythonMultibyteTables, canonical)) throw new RangeError(`unknown encoding: ${encoding}`);
|
|
228
259
|
this.encoding = canonical;
|
|
229
260
|
this.codepoints = fileCodepages[canonical];
|
|
230
261
|
this.signatureComplete = canonical !== "utf-8-sig";
|
|
231
|
-
this.decoder = pythonMultibyteTables[canonical] ? new PythonMultibyteDecoder(pythonMultibyteTables[canonical]) : canonical === "utf-16" || canonical === "utf-16-le" || canonical === "utf-16-be" ? new PythonUtf16Decoder(canonical) : canonical === "utf-32" || canonical === "utf-32-le" || canonical === "utf-32-be" ? new PythonUtf32Decoder(canonical) : new TextDecoder("utf-8", { fatal: true, ignoreBOM: true });
|
|
262
|
+
this.decoder = canonical === "hz" ? new PythonHzDecoder() : pythonMultibyteTables[canonical] ? new PythonMultibyteDecoder(pythonMultibyteTables[canonical]) : canonical === "utf-16" || canonical === "utf-16-le" || canonical === "utf-16-be" ? new PythonUtf16Decoder(canonical) : canonical === "utf-32" || canonical === "utf-32-le" || canonical === "utf-32-be" ? new PythonUtf32Decoder(canonical) : new TextDecoder("utf-8", { fatal: true, ignoreBOM: true });
|
|
232
263
|
}
|
|
233
264
|
decode(bytes, options) {
|
|
234
265
|
if (this.codepoints) return decodePythonSingleByte(bytes ?? new Uint8Array(), this.codepoints, this.encoding);
|
|
235
|
-
if (this.decoder instanceof PythonUtf16Decoder || this.decoder instanceof PythonUtf32Decoder || this.decoder instanceof PythonMultibyteDecoder) return this.decoder.decode(bytes, options);
|
|
266
|
+
if (this.decoder instanceof PythonHzDecoder || this.decoder instanceof PythonUtf16Decoder || this.decoder instanceof PythonUtf32Decoder || this.decoder instanceof PythonMultibyteDecoder) return this.decoder.decode(bytes, options);
|
|
236
267
|
try {
|
|
237
268
|
let offset = 0;
|
|
238
269
|
if (!this.signatureComplete) {
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
import {
|
|
16
16
|
createLlmService,
|
|
17
17
|
validateModelOptions
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-SENLC5KK.js";
|
|
19
19
|
import {
|
|
20
20
|
validateJsonData
|
|
21
21
|
} from "./chunk-3PO534WJ.js";
|
|
@@ -99,6 +99,80 @@ async function pluginsCommand(args, output, diagnostic, step, signal, load) {
|
|
|
99
99
|
return 0;
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
+
// packages/safe-bash-command-llm/src/chat-options.ts
|
|
103
|
+
var chatOptions = [
|
|
104
|
+
"-h",
|
|
105
|
+
"--help",
|
|
106
|
+
"--td",
|
|
107
|
+
"--tools-debug",
|
|
108
|
+
"--ta",
|
|
109
|
+
"--tools-approve",
|
|
110
|
+
"--no-stream",
|
|
111
|
+
"--functions",
|
|
112
|
+
"-T",
|
|
113
|
+
"--tool",
|
|
114
|
+
"--cl",
|
|
115
|
+
"--chain-limit",
|
|
116
|
+
"-f",
|
|
117
|
+
"--fragment",
|
|
118
|
+
"--sf",
|
|
119
|
+
"--system-fragment",
|
|
120
|
+
"-m",
|
|
121
|
+
"--model",
|
|
122
|
+
"-s",
|
|
123
|
+
"--system",
|
|
124
|
+
"-o",
|
|
125
|
+
"--option",
|
|
126
|
+
"-t",
|
|
127
|
+
"--template",
|
|
128
|
+
"-p",
|
|
129
|
+
"--param",
|
|
130
|
+
"--key"
|
|
131
|
+
];
|
|
132
|
+
async function chatOptionSuggestion(value, step) {
|
|
133
|
+
if (!value.startsWith("--")) return "";
|
|
134
|
+
const options = chatOptions.filter((option) => option.startsWith("--"));
|
|
135
|
+
const cutoff = 0.6;
|
|
136
|
+
const maximum = Math.floor(Math.max(...options.map((option) => option.length)) * (2 / cutoff - 1));
|
|
137
|
+
const input = [];
|
|
138
|
+
for (const char of value) {
|
|
139
|
+
await step();
|
|
140
|
+
input.push(char);
|
|
141
|
+
if (input.length > maximum) return "";
|
|
142
|
+
}
|
|
143
|
+
const matches = [];
|
|
144
|
+
for (const option of options) {
|
|
145
|
+
if (2 * Math.min(option.length, input.length) / (option.length + input.length) < cutoff) continue;
|
|
146
|
+
const pending = [[0, option.length, 0, input.length]];
|
|
147
|
+
let matched = 0;
|
|
148
|
+
while (pending.length) {
|
|
149
|
+
const [aStart, aEnd, bStart, bEnd] = pending.pop();
|
|
150
|
+
let bestA = aStart, bestB = bStart, size = 0;
|
|
151
|
+
for (let a = aStart; a < aEnd; a++) {
|
|
152
|
+
await step();
|
|
153
|
+
for (let b = bStart; b < bEnd; b++) {
|
|
154
|
+
let length = 0;
|
|
155
|
+
while (a + length < aEnd && b + length < bEnd && option[a + length] === input[b + length]) length++;
|
|
156
|
+
if (length > size) {
|
|
157
|
+
bestA = a;
|
|
158
|
+
bestB = b;
|
|
159
|
+
size = length;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
if (!size) continue;
|
|
164
|
+
matched += size;
|
|
165
|
+
if (aStart < bestA && bStart < bestB) pending.push([aStart, bestA, bStart, bestB]);
|
|
166
|
+
if (bestA + size < aEnd && bestB + size < bEnd) pending.push([bestA + size, aEnd, bestB + size, bEnd]);
|
|
167
|
+
}
|
|
168
|
+
const score = 2 * matched / (option.length + input.length);
|
|
169
|
+
if (score >= cutoff) matches.push({ option, score });
|
|
170
|
+
}
|
|
171
|
+
matches.sort((left, right) => right.score - left.score || (left.option < right.option ? 1 : left.option > right.option ? -1 : 0));
|
|
172
|
+
const suggestions = matches.slice(0, 3).map((match) => match.option).sort();
|
|
173
|
+
return !suggestions.length ? "" : suggestions.length === 1 ? ` Did you mean ${suggestions[0]}?` : ` (Possible options: ${suggestions.join(", ")})`;
|
|
174
|
+
}
|
|
175
|
+
|
|
102
176
|
// packages/safe-bash-command-llm/src/chat-help.ts
|
|
103
177
|
var chatHelp = "Usage: llm chat [OPTIONS]\n\n Hold an ongoing chat with a model.\n\nOptions:\n -s, --system TEXT System prompt to use\n -m, --model TEXT Model to use\n -f, --fragment TEXT Fragment (alias, URL, hash or file path) to\n add to the prompt\n --sf, --system-fragment TEXT Fragment to add to system prompt\n -t, --template TEXT Template to use\n -p, --param <TEXT TEXT>... Parameters for template\n -o, --option <TEXT TEXT>... key/value options for the model\n --no-stream Do not stream output\n --key TEXT API key to use\n -T, --tool TEXT Name of a tool to make available to the model\n --functions TEXT Python code block or file path defining\n functions to register as tools\n --td, --tools-debug Show full details of tool executions\n --ta, --tools-approve Manually approve every tool execution\n --cl, --chain-limit INTEGER How many chained tool responses to allow,\n default 5, set 0 for unlimited\n -h, --help Show this message and exit.\n";
|
|
104
178
|
|
|
@@ -1855,9 +1929,8 @@ function interpolate(text, params, validateOnly = false, admitText) {
|
|
|
1855
1929
|
while (index + 1 < text.length && "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_".includes(text[index + 1])) name += text[++index];
|
|
1856
1930
|
if (!name || "0123456789".includes(name[0]) || braced && text[index + 1] !== "}") throw new Error(`Invalid placeholder in template at position ${start}`);
|
|
1857
1931
|
if (braced) index++;
|
|
1858
|
-
if (!Object.hasOwn(params, name))
|
|
1859
|
-
|
|
1860
|
-
} else if (!validateOnly) append(String(params[name]));
|
|
1932
|
+
if (!Object.hasOwn(params, name)) missing.push(name);
|
|
1933
|
+
else if (!validateOnly) append(String(params[name]));
|
|
1861
1934
|
}
|
|
1862
1935
|
if (missing.length) throw new Error(`Missing variables: ${missing.join(", ")}`);
|
|
1863
1936
|
return result;
|
|
@@ -2741,10 +2814,10 @@ async function listLlmModels(context, service, tokens, emit, step, maxConfigurat
|
|
|
2741
2814
|
var llmReferenceVersion = "0.27.1";
|
|
2742
2815
|
var LlmPromptUsageError = class extends Error {
|
|
2743
2816
|
};
|
|
2744
|
-
async function parse(length, text, step, chat = false) {
|
|
2745
|
-
const parsed = { toolNames: [], functions: [], chainLimit: 5, prompt: "", queries: [], fragments: [], systemFragments: [], params: {}, options: /* @__PURE__ */ Object.create(null), attachments: [] };
|
|
2817
|
+
async function parse(length, text, step, chat = false, toolsDebugEnv) {
|
|
2818
|
+
const parsed = { toolNames: [], functions: [], chainLimit: 5, prompt: "", queries: [], fragments: [], systemFragments: [], params: {}, optionNames: [], options: /* @__PURE__ */ Object.create(null), attachments: [] };
|
|
2746
2819
|
const operands = [];
|
|
2747
|
-
let ended = false;
|
|
2820
|
+
let ended = false, chainLimit;
|
|
2748
2821
|
for (let index = 0; index < length; index++) {
|
|
2749
2822
|
await step();
|
|
2750
2823
|
const argument = text(index);
|
|
@@ -2767,11 +2840,11 @@ async function parse(length, text, step, chat = false) {
|
|
|
2767
2840
|
if (long) break;
|
|
2768
2841
|
continue;
|
|
2769
2842
|
}
|
|
2770
|
-
if (!
|
|
2843
|
+
if (!chatOptions.includes(flag))
|
|
2771
2844
|
throw new LlmPromptUsageError(`Usage: llm chat [OPTIONS]
|
|
2772
2845
|
Try 'llm chat -h' for help.
|
|
2773
2846
|
|
|
2774
|
-
Error: No such option: ${flag}`);
|
|
2847
|
+
Error: No such option: ${flag}${await chatOptionSuggestion(flag, step)}`);
|
|
2775
2848
|
}
|
|
2776
2849
|
const boolean = ["--async", "--td", "--tools-debug", "--ta", "--tools-approve", "--no-log", "-n", "-x", "--extract", "--xl", "--extract-last", "-u", "--usage", "--no-stream"].includes(flag);
|
|
2777
2850
|
if (boolean) {
|
|
@@ -2794,14 +2867,8 @@ Error: No such option: ${flag}`);
|
|
|
2794
2867
|
const value = attached ?? text(++index);
|
|
2795
2868
|
if (flag === "--functions") parsed.functions.push(value);
|
|
2796
2869
|
else if (flag === "-T" || flag === "--tool") parsed.toolNames.push(value);
|
|
2797
|
-
else if (flag === "--cl" || flag === "--chain-limit")
|
|
2798
|
-
|
|
2799
|
-
if (integer === void 0) throw new LlmPromptUsageError(`Usage: llm prompt [OPTIONS] [PROMPT]
|
|
2800
|
-
Try 'llm prompt --help' for help.
|
|
2801
|
-
|
|
2802
|
-
Error: Invalid value for '--cl' / '--chain-limit': '${value}' is not a valid integer.`);
|
|
2803
|
-
parsed.chainLimit = BigInt(integer);
|
|
2804
|
-
} else if (flag === "-f" || flag === "--fragment") parsed.fragments.push(value);
|
|
2870
|
+
else if (flag === "--cl" || flag === "--chain-limit") chainLimit = value;
|
|
2871
|
+
else if (flag === "-f" || flag === "--fragment") parsed.fragments.push(value);
|
|
2805
2872
|
else if (flag === "--sf" || flag === "--system-fragment") parsed.systemFragments.push(value);
|
|
2806
2873
|
else if (flag === "-q" || flag === "--query") parsed.queries.push(value);
|
|
2807
2874
|
else if (flag === "-t" || flag === "--template") parsed.template = value;
|
|
@@ -2812,13 +2879,33 @@ Error: Invalid value for '--cl' / '--chain-limit': '${value}' is not a valid int
|
|
|
2812
2879
|
else if (flag === "-p" || flag === "--param") Object.defineProperty(parsed.params, value, { value: text(++index), enumerable: true, configurable: true, writable: true });
|
|
2813
2880
|
else if (flag === "-m" || flag === "--model") parsed.model = value;
|
|
2814
2881
|
else if (flag === "-s" || flag === "--system") parsed.system = value;
|
|
2815
|
-
else if (flag === "-o" || flag === "--option")
|
|
2816
|
-
|
|
2882
|
+
else if (flag === "-o" || flag === "--option") {
|
|
2883
|
+
if (!Object.hasOwn(parsed.options, value)) parsed.optionNames.push(value);
|
|
2884
|
+
parsed.options[value] = text(++index);
|
|
2885
|
+
} else if (flag === "--at" || flag === "--attachment-type") parsed.attachments.push({ path: value, mimeType: text(++index) });
|
|
2817
2886
|
else parsed.attachments.push({ path: value });
|
|
2818
2887
|
break;
|
|
2819
2888
|
}
|
|
2820
2889
|
}
|
|
2821
2890
|
if (parsed.help) return parsed;
|
|
2891
|
+
const usage3 = chat ? "Usage: llm chat [OPTIONS]\nTry 'llm chat -h' for help." : "Usage: llm prompt [OPTIONS] [PROMPT]\nTry 'llm prompt --help' for help.";
|
|
2892
|
+
if (chainLimit !== void 0) {
|
|
2893
|
+
const integer = tokenInteger(chainLimit);
|
|
2894
|
+
if (integer === void 0) throw new LlmPromptUsageError(`${usage3}
|
|
2895
|
+
|
|
2896
|
+
Error: Invalid value for '--cl' / '--chain-limit': '${chainLimit}' is not a valid integer.`);
|
|
2897
|
+
parsed.chainLimit = BigInt(integer);
|
|
2898
|
+
}
|
|
2899
|
+
if (!parsed.toolsDebug && toolsDebugEnv) {
|
|
2900
|
+
const raw = toolsDebugEnv, value = stripPythonWhitespace(raw).toLowerCase();
|
|
2901
|
+
if (["1", "true", "t", "yes", "y", "on"].includes(value)) parsed.toolsDebug = true;
|
|
2902
|
+
else if (!["", "0", "false", "f", "no", "n", "off"].includes(value)) {
|
|
2903
|
+
const detail = chat ? "" : " Recognized values: , 0, 1, f, false, n, no, off, on, t, true, y, yes";
|
|
2904
|
+
throw new LlmPromptUsageError(`${usage3}
|
|
2905
|
+
|
|
2906
|
+
Error: Invalid value for '--td' / '--tools-debug': '${raw}' is not a valid boolean.${detail}`);
|
|
2907
|
+
}
|
|
2908
|
+
}
|
|
2822
2909
|
if (chat && operands.length) throw new LlmPromptUsageError(`Usage: llm chat [OPTIONS]
|
|
2823
2910
|
Try 'llm chat -h' for help.
|
|
2824
2911
|
|
|
@@ -3106,19 +3193,11 @@ async function execute(context, service, limits, templateLoaderOptions, collecti
|
|
|
3106
3193
|
}
|
|
3107
3194
|
const isChat = argumentsValue.args[0] === "chat";
|
|
3108
3195
|
const promptOffset = argumentsValue.args[0] === "prompt" || isChat ? 1 : 0;
|
|
3109
|
-
let args = await parse(argumentsValue.args.length - promptOffset, (index) => argumentText(index + promptOffset), step, isChat);
|
|
3196
|
+
let args = await parse(argumentsValue.args.length - promptOffset, (index) => argumentText(index + promptOffset), step, isChat, context.env.LLM_TOOLS_DEBUG);
|
|
3110
3197
|
if (args.help) {
|
|
3111
3198
|
await emitText(chatHelp);
|
|
3112
3199
|
return { exitCode: 0 };
|
|
3113
3200
|
}
|
|
3114
|
-
if (!args.toolsDebug && context.env.LLM_TOOLS_DEBUG) {
|
|
3115
|
-
const raw = context.env.LLM_TOOLS_DEBUG, value = stripPythonWhitespace(raw).toLowerCase();
|
|
3116
|
-
if (["1", "true", "t", "yes", "y", "on"].includes(value)) args.toolsDebug = true;
|
|
3117
|
-
else if (!["", "0", "false", "f", "no", "n", "off"].includes(value)) throw new LlmPromptUsageError(`Usage: llm prompt [OPTIONS] [PROMPT]
|
|
3118
|
-
Try 'llm prompt --help' for help.
|
|
3119
|
-
|
|
3120
|
-
Error: Invalid value for '--td' / '--tools-debug': '${raw}' is not a valid boolean. Recognized values: , 0, 1, f, false, n, no, off, on, t, true, y, yes`);
|
|
3121
|
-
}
|
|
3122
3201
|
const configuration = createLlmConfiguration(context, limits?.maxConfigurationBytes, invocationLoaders);
|
|
3123
3202
|
if (args.model === void 0 && args.queries.length) {
|
|
3124
3203
|
try {
|
|
@@ -3145,7 +3224,7 @@ Error: Invalid value for '--td' / '--tools-debug': '${raw}' is not a valid boole
|
|
|
3145
3224
|
if (stored) {
|
|
3146
3225
|
if (!isChat && stored.schema_object) schema = stored.schema_object;
|
|
3147
3226
|
try {
|
|
3148
|
-
validateLlmTemplateParameters(stored, args.params);
|
|
3227
|
+
if (!isChat) validateLlmTemplateParameters(stored, args.params);
|
|
3149
3228
|
} catch (error) {
|
|
3150
3229
|
throw new Error(`Error: ${error instanceof Error ? error.message : "Invalid template"}`);
|
|
3151
3230
|
}
|
|
@@ -3156,6 +3235,10 @@ Error: Invalid value for '--td' / '--tools-debug': '${raw}' is not a valid boole
|
|
|
3156
3235
|
try {
|
|
3157
3236
|
entry = args.save && selected === void 0 ? void 0 : service.resolve(model, args.async && !args.save ? { async: true } : void 0);
|
|
3158
3237
|
} catch (error) {
|
|
3238
|
+
if (isChat && error instanceof Error && error.message.startsWith("Unknown model: ")) {
|
|
3239
|
+
const missing = selected ?? error.message.slice("Unknown model: ".length);
|
|
3240
|
+
throw new Error(`Error: '${missing}' is not a known model`);
|
|
3241
|
+
}
|
|
3159
3242
|
if (!args.async || args.save) throw error;
|
|
3160
3243
|
let detail = "";
|
|
3161
3244
|
for await (const bytes of pythonRepr(error instanceof Error ? error.message : String(error), signal)) {
|
|
@@ -3171,6 +3254,25 @@ Error: Invalid value for '--td' / '--tools-debug': '${raw}' is not a valid boole
|
|
|
3171
3254
|
Try 'llm chat -h' for help.
|
|
3172
3255
|
|
|
3173
3256
|
Error: Got unexpected extra argument (${args.prompt})`);
|
|
3257
|
+
let chatModelOptions;
|
|
3258
|
+
if (isChat) {
|
|
3259
|
+
const configured = await configuration.modelOptions(entry.model.id);
|
|
3260
|
+
const names = args.optionNames;
|
|
3261
|
+
chatModelOptions = names.length ? args.options : configured;
|
|
3262
|
+
if (names.length) {
|
|
3263
|
+
const rules = entry.model.options ?? {}, errors = [];
|
|
3264
|
+
const ordered = [...Object.keys(rules).filter((name) => Object.hasOwn(args.options, name)), ...names.filter((name) => !Object.hasOwn(rules, name))];
|
|
3265
|
+
for (const name of ordered) {
|
|
3266
|
+
await step();
|
|
3267
|
+
try {
|
|
3268
|
+
validateModelOptions(entry.model, { [name]: args.options[name] });
|
|
3269
|
+
} catch (error) {
|
|
3270
|
+
errors.push(error instanceof Error ? error.message : String(error));
|
|
3271
|
+
}
|
|
3272
|
+
}
|
|
3273
|
+
if (errors.length) throw new Error("Error: " + errors.join("\n"));
|
|
3274
|
+
}
|
|
3275
|
+
}
|
|
3174
3276
|
const loadSelectedTools = async () => {
|
|
3175
3277
|
let selectedTools2;
|
|
3176
3278
|
try {
|
|
@@ -3362,7 +3464,6 @@ Error: Got unexpected extra argument (${args.prompt})`);
|
|
|
3362
3464
|
let initialPromptFragments = [], initialSystemFragments = [];
|
|
3363
3465
|
const initialAttachments = [], initialSourceAttachments = [];
|
|
3364
3466
|
if (chat) {
|
|
3365
|
-
validateModelOptions(entry.model, { ...await configuration.modelOptions(entry.model.id), ...args.options });
|
|
3366
3467
|
initialPromptFragments = await prepareFragments(args.fragments, false);
|
|
3367
3468
|
initialSystemFragments = await prepareFragments(args.systemFragments, true);
|
|
3368
3469
|
initialAttachments.push(...pluginAttachments);
|
|
@@ -3494,7 +3595,7 @@ ${args.prompt}` : evaluated.prompt;
|
|
|
3494
3595
|
}
|
|
3495
3596
|
if (chat && (stored ? ["exit", "quit"].includes(stripPythonWhitespace(prompt)) : chatPrompt.exit)) return { exitCode: 0 };
|
|
3496
3597
|
if (!entry) throw new Error("No model selected; use --model or configure defaultModel");
|
|
3497
|
-
args.options = { ...await configuration.modelOptions(entry.model.id), ...
|
|
3598
|
+
args.options = chat ? { ...chatModelOptions } : { ...await configuration.modelOptions(entry.model.id), ...stored?.options, ...args.options };
|
|
3498
3599
|
args.attachments = [
|
|
3499
3600
|
...(chat ? [] : stored?.attachments ?? []).map((path) => ({ path })),
|
|
3500
3601
|
...args.attachments.filter((item) => item.mimeType === void 0),
|
|
@@ -52,7 +52,7 @@ function validateModelOptions(model, values) {
|
|
|
52
52
|
const text = String(input).toLowerCase();
|
|
53
53
|
if (["true", "1", "yes", "on", "y", "t"].includes(text)) value = true;
|
|
54
54
|
else if (["false", "0", "no", "off", "n", "f"].includes(text)) value = false;
|
|
55
|
-
else fail("Input should be a valid boolean");
|
|
55
|
+
else fail(typeof input === "string" ? "Input should be a valid boolean, unable to interpret input" : "Input should be a valid boolean");
|
|
56
56
|
break;
|
|
57
57
|
}
|
|
58
58
|
case "object":
|
|
@@ -3,11 +3,11 @@ import {
|
|
|
3
3
|
createLlmCommands,
|
|
4
4
|
llmCommands,
|
|
5
5
|
llmReferenceVersion
|
|
6
|
-
} from "../safe-bash/command-chunks/chunk-
|
|
6
|
+
} from "../safe-bash/command-chunks/chunk-RKAL5VFP.js";
|
|
7
7
|
import "../safe-bash/command-chunks/chunk-MCUDSE4H.js";
|
|
8
8
|
import "../safe-bash/command-chunks/chunk-WOT2YXBT.js";
|
|
9
9
|
import "../safe-bash/command-chunks/chunk-BZLLQWRK.js";
|
|
10
|
-
import "../safe-bash/command-chunks/chunk-
|
|
10
|
+
import "../safe-bash/command-chunks/chunk-SENLC5KK.js";
|
|
11
11
|
import "../safe-bash/command-chunks/chunk-3PO534WJ.js";
|
|
12
12
|
import "../safe-bash/command-chunks/chunk-B74LVFAN.js";
|
|
13
13
|
import "../safe-bash/command-chunks/chunk-GDH7OVYK.js";
|
|
@@ -43,7 +43,7 @@ import {
|
|
|
43
43
|
serializeLlmTokenUsage,
|
|
44
44
|
streamLlmToolChain,
|
|
45
45
|
validateLlmTemplateParameters
|
|
46
|
-
} from "../safe-bash/command-chunks/chunk-
|
|
46
|
+
} from "../safe-bash/command-chunks/chunk-RKAL5VFP.js";
|
|
47
47
|
import "../safe-bash/command-chunks/chunk-MCUDSE4H.js";
|
|
48
48
|
import {
|
|
49
49
|
createLlmConfiguration
|
|
@@ -54,7 +54,7 @@ import {
|
|
|
54
54
|
import {
|
|
55
55
|
createLlmService,
|
|
56
56
|
validateModelOptions
|
|
57
|
-
} from "../safe-bash/command-chunks/chunk-
|
|
57
|
+
} from "../safe-bash/command-chunks/chunk-SENLC5KK.js";
|
|
58
58
|
import "../safe-bash/command-chunks/chunk-3PO534WJ.js";
|
|
59
59
|
import {
|
|
60
60
|
getLlmAttachmentUrlId
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createLlmService
|
|
3
|
-
} from "../safe-bash/command-chunks/chunk-
|
|
3
|
+
} from "../safe-bash/command-chunks/chunk-SENLC5KK.js";
|
|
4
4
|
import "../safe-bash/command-chunks/chunk-3PO534WJ.js";
|
|
5
5
|
import "../safe-bash/command-chunks/chunk-CKQ5SXOO.js";
|
|
6
6
|
import "../safe-bash/command-chunks/chunk-B6NAEWHC.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
PythonTextDecoder
|
|
3
|
-
} from "../safe-bash/command-chunks/chunk-
|
|
3
|
+
} from "../safe-bash/command-chunks/chunk-GRFJKJFN.js";
|
|
4
4
|
import "../safe-bash/command-chunks/chunk-OLXMWQJ5.js";
|
|
5
5
|
import "../safe-bash/command-chunks/chunk-OOYVZAWL.js";
|
|
6
6
|
import "../safe-bash/command-chunks/chunk-ZERCTWUI.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@poe-platform/safe-bash",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.821",
|
|
4
4
|
"description": "Extensible virtual shell with pluggable filesystems and streaming commands",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -1407,7 +1407,7 @@
|
|
|
1407
1407
|
"access": "public"
|
|
1408
1408
|
},
|
|
1409
1409
|
"dependencies": {
|
|
1410
|
-
"@poe-platform/safe-fs": "0.1.
|
|
1410
|
+
"@poe-platform/safe-fs": "0.1.821",
|
|
1411
1411
|
"pdf-lib": "1.17.1",
|
|
1412
1412
|
"@types/node": "^25.2.2",
|
|
1413
1413
|
"@formatjs/intl-numberformat": "9.4.0",
|