@poe-platform/safe-bash 0.1.822 → 0.1.823
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/chunks/{chunk-HNT2MR4W.js → chunk-363QOIDR.js} +2 -1
- package/dist/safe-bash/chunks/chunk-AGHV53VF.js +42 -0
- package/dist/safe-bash/chunks/{chunk-VF3Q2V3E.js → chunk-RAFD5ZAH.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-67QE3JLU.js → chunk-TZRVK3NU.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-IRJS54AA.js → chunk-VWLQDZFF.js} +20 -12
- package/dist/safe-bash/chunks/{chunk-NAETSXBW.js → chunk-ZJAXMB5M.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-QX3WKBLI.js → chunk-36FV6BAG.js} +5 -3
- package/dist/safe-bash/command-chunks/{chunk-ZSHXZ3XG.js → chunk-3EAZRKI4.js} +7 -7
- package/dist/safe-bash/command-chunks/chunk-64HIOP7Q.js +993 -0
- package/dist/safe-bash/command-chunks/{chunk-WOT2YXBT.js → chunk-7ZQVMPSB.js} +213 -42
- package/dist/safe-bash/command-chunks/{chunk-4VHCA4KK.js → chunk-AVSINNZ6.js} +80 -3
- package/dist/safe-bash/command-chunks/{chunk-BZLLQWRK.js → chunk-E5CDHXFA.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-RHXV2KG5.js → chunk-EO3RYGUZ.js} +1010 -58
- package/dist/safe-bash/command-chunks/{chunk-MCUDSE4H.js → chunk-EWECMOQ5.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-RKAL5VFP.js → chunk-PLVFJ6FF.js} +255 -616
- package/dist/safe-bash/command-chunks/{chunk-CJIFJ45R.js → chunk-QBCEAYQT.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-4Q3HP33O.js → chunk-RGKHTSUY.js} +146 -123
- package/dist/safe-bash/command-chunks/{chunk-I7MEH76L.js → chunk-UYNJF5QN.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-IAHYG67O.js → chunk-V5ZBRM5R.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-R4NPYXQX.js → chunk-WDTWJFPK.js} +320 -67
- package/dist/safe-bash/command-chunks/{chunk-GQV5RWMN.js → chunk-ZFXHSFTU.js} +1 -1
- package/dist/safe-bash/command-chunks/{prompt-tool-debug-ERJKK3XZ.js → prompt-tool-debug-3POFNRYP.js} +5 -5
- package/dist/safe-bash/commands/bc/index.browser.js +1 -1
- package/dist/safe-bash/commands/llm/index.browser.js +3 -1
- package/dist/safe-bash/commands/llm/index.js +1 -1
- package/dist/safe-bash/commands/python/executor.browser.js +12 -1
- package/dist/safe-bash/commands/python/executor.js +1 -1
- package/dist/safe-bash/commands/python/index.browser.js +23 -1
- package/dist/safe-bash/commands/python/index.js +1 -1
- package/dist/safe-bash/core.browser.js +2 -2
- package/dist/safe-bash/full-core.browser.js +30 -6
- package/dist/safe-bash/plugins/index.browser.js +3 -3
- package/dist/safe-bash/registry-entry.browser.js +2 -2
- package/dist/safe-bash/search.browser.js +1 -1
- package/dist/safe-bash/shell/runtime.d.ts +2 -2
- package/dist/safe-bash/shell/runtime.js +11 -2
- package/dist/safe-bash/shell/sync-extra-evaluators.js +12 -12
- package/dist/safe-bash/shell-entry.browser.js +2 -2
- package/dist/safe-bash-command-llm/collections.js +24 -65
- package/dist/safe-bash-command-llm/command.js +6 -6
- package/dist/safe-bash-command-llm/fragment-loaders.d.ts +3 -2
- package/dist/safe-bash-command-llm/index.d.ts +3 -2
- package/dist/safe-bash-command-llm/index.js +10 -8
- package/dist/safe-bash-command-llm/loader-provider.d.ts +25 -0
- package/dist/safe-bash-command-llm/openai-sse.js +2 -2
- package/dist/safe-bash-command-llm/openai.js +4 -4
- package/dist/safe-bash-command-llm/providers/index.js +4 -4
- package/dist/safe-bash-command-llm/providers/openai.js +4 -4
- package/dist/safe-bash-command-llm/python-unicode.d.ts +2 -0
- package/dist/safe-bash-command-llm/templates.d.ts +7 -2
- package/dist/safe-bash-command-llm/types.d.ts +7 -1
- package/dist/safe-bash-command-mcp/index.browser.js +3 -0
- package/dist/safe-bash-command-mcp/index.js +3 -0
- package/dist/safe-bash-command-python/build-backend.d.ts +51 -0
- package/dist/safe-bash-command-python/build-dependencies.d.ts +12 -0
- package/dist/safe-bash-command-python/build-environment.d.ts +3 -0
- package/dist/safe-bash-command-python/build-wheel.d.ts +8 -0
- package/dist/safe-bash-command-python/executor.d.ts +12 -2
- package/dist/safe-bash-command-python/executor.js +26 -4
- package/dist/safe-bash-command-python/index.js +26 -4
- package/dist/safe-bash-command-python/jspi.js +2 -2
- package/dist/safe-bash-command-python/llm-assets-node.js +1 -1
- package/dist/safe-bash-command-python/llm-fragment-loader.d.ts +6 -0
- package/dist/safe-bash-command-python/llm-functions-loader.d.ts +5 -1
- package/dist/safe-bash-command-python/llm-loader-discovery.d.ts +13 -0
- package/dist/safe-bash-command-python/llm-package-manager.d.ts +7 -0
- package/dist/safe-bash-command-python/llm-template-loader.d.ts +6 -0
- package/dist/safe-bash-command-python/manifest.d.ts +13 -0
- package/dist/safe-bash-command-python/provisioning.d.ts +33 -5
- package/dist/safe-bash-command-python/provisioning.js +1 -1
- package/dist/safe-bash-command-python/source-environment.d.ts +9 -0
- package/dist/safe-bash-command-python/source-snapshot.d.ts +8 -0
- package/dist/safe-bash-command-python/worker.js +3 -185
- package/dist/safe-bash-csv-engine/index.js +1 -1
- package/dist/safe-bash-csv-engine/python-utf7.d.ts +18 -0
- package/dist/safe-bash-csv-engine/text-decoder.d.ts +1 -0
- package/dist/safe-bash-csv-engine/text-decoder.js +5 -3
- package/dist/safe-bash-zip-engine/index.js +1 -1
- package/dist/safe-bash-zip-engine/zip/repair.js +1 -1
- package/dist/safe-bash-zip-engine/zip/sfx.js +1 -1
- package/dist/safe-bash-zip-engine/zip-format.d.ts +3 -1
- package/dist/safe-bash-zip-engine/zip-format.js +1 -1
- package/dist/safe-playwright-cloudflare/shell-browser-resource.d.ts +1 -1
- package/dist/safe-playwright-cloudflare/shell-browser-resource.js +35 -20
- package/package.json +3 -3
- package/dist/safe-bash/chunks/chunk-PSD2RSOS.js +0 -31
- package/dist/safe-bash/command-chunks/chunk-5EFNQ6FY.js +0 -458
|
@@ -2,10 +2,94 @@ import {
|
|
|
2
2
|
createLlmSpool,
|
|
3
3
|
fileSource,
|
|
4
4
|
serializeLlmEmbedding
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-E5CDHXFA.js";
|
|
6
6
|
import {
|
|
7
7
|
sourceBytes
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-36FV6BAG.js";
|
|
9
|
+
|
|
10
|
+
// packages/safe-bash-command-llm/src/help-data.ts
|
|
11
|
+
var packedHelp = "H4sIAAAAAAAAE71bbW8bNxL+K4RbwG3hlYsivQ/GvUCw5UatbBmWkt4hCVJ6RVkb75LbJde2cLn/fjNDct8lrWzd6YMjLcnhvD4zHG7+fZRmKknN0dnRO83vxRmL44TZZ+zD9GY+nl7PPrEPN7fTq5v5p4/yo2Rs9CzC3AjG3UT79EKFeSKk4SZS8oytjEn12ekp0BssuOFaGCMGkToV8lQbfheL0xx3HKxMEnu6PEljoc/sT/wgN8fnPI0Mj5lassuMy1D843jXOAsSdp+a4I3aPVOzYy71k8hYJNks5TLSq2PLwlUemyhI1ALWwF8RaxZyye4E/BPHYsGeIrNi3BgerlB2zeLoQTCzilpCjJ5NxkPDjHg2bAl6o1ksSkAHwAS33wZf0vvasguhwyy6s1O8TjUqORzoKFHyKYrjSCs5kMK4gdOffvzpzWkq4giY1VWSITd2H/bVkl848hU+Aj/5G/Y7SSeZeE6BVmRYEiXCrFNx1p9gADMC++v0SyrurVrmK8GC59MgEE4tKkW3YZkweSY1+5JrUBVMCpU0oFi0GP5cRhkM/PHHH2wpwHwLGF8IJHgXq/DhhEVLpiRsrsE1hYaFAzZeMonPeCb8Qwai+J2Iah7H8ECnSmoxaBjuV/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mUDKvVU71okpcbvW3aPYYZFus9M4r3c7BqSX40x9FB/5N284XPxET6a1apQWzXU5/sMF3irFCzbVYDHbwD9u9UfjXS7CrhWoqatv5LurerVNvXtuV7rawHWsa2UMjjXnj9gGMBlmA1jv1Gg/d1tF/XS+/u4O/P2vOvzZfpvteyEYg6rqsR4csO/Hbw6hjnwPK1a5/Gvs1iiDS/Rbp0A4WJXTtMnxvOWlf//8aXi4uyNYhtNhuyzouksgMEj97P5y8G1VgsSH9fvDYsacVl4pIkXGILsF+HPx8QGuHseDZVtFpRkv4DyC98+lzmlAX/Dv9/atkt5vW/xPLN2yaeU8CjIz9m2k9yVSV+NrKrKMq2/P2fEcP6vAvYWw+DjCqWVmfyri48O5Z2DNyYtanNi3TV3fe6qvfRuf2sNfZ3XVk+RpA/xqO+YzZTrqF0rZUWq1A3hrCfXW37S2yw3vkrjTIXPj2A5jS1XbicPH+xZ756ug//wVqvYljMjgAAA==";
|
|
12
|
+
|
|
13
|
+
// packages/safe-bash-command-llm/src/help-text.ts
|
|
14
|
+
var catalog;
|
|
15
|
+
async function loadLlmHelp(name) {
|
|
16
|
+
catalog ??= new Response(new Blob([Uint8Array.from(atob(packedHelp), (character) => character.charCodeAt(0))]).stream().pipeThrough(new DecompressionStream("gzip"))).json();
|
|
17
|
+
return (await catalog)[name];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// packages/safe-bash-command-llm/src/chat-options.ts
|
|
21
|
+
var chatOptions = [
|
|
22
|
+
"-h",
|
|
23
|
+
"--help",
|
|
24
|
+
"--td",
|
|
25
|
+
"--tools-debug",
|
|
26
|
+
"--ta",
|
|
27
|
+
"--tools-approve",
|
|
28
|
+
"--no-stream",
|
|
29
|
+
"--functions",
|
|
30
|
+
"-T",
|
|
31
|
+
"--tool",
|
|
32
|
+
"--cl",
|
|
33
|
+
"--chain-limit",
|
|
34
|
+
"-f",
|
|
35
|
+
"--fragment",
|
|
36
|
+
"--sf",
|
|
37
|
+
"--system-fragment",
|
|
38
|
+
"-m",
|
|
39
|
+
"--model",
|
|
40
|
+
"-s",
|
|
41
|
+
"--system",
|
|
42
|
+
"-o",
|
|
43
|
+
"--option",
|
|
44
|
+
"-t",
|
|
45
|
+
"--template",
|
|
46
|
+
"-p",
|
|
47
|
+
"--param",
|
|
48
|
+
"--key"
|
|
49
|
+
];
|
|
50
|
+
async function chatOptionSuggestion(value, step, choices = chatOptions) {
|
|
51
|
+
if (!value.startsWith("--")) return "";
|
|
52
|
+
const options = choices.filter((option) => option.startsWith("--"));
|
|
53
|
+
const cutoff = 0.6;
|
|
54
|
+
const maximum = Math.floor(Math.max(...options.map((option) => option.length)) * (2 / cutoff - 1));
|
|
55
|
+
const input = [];
|
|
56
|
+
for (const char of value) {
|
|
57
|
+
await step();
|
|
58
|
+
input.push(char);
|
|
59
|
+
if (input.length > maximum) return "";
|
|
60
|
+
}
|
|
61
|
+
const matches = [];
|
|
62
|
+
for (const option of options) {
|
|
63
|
+
if (2 * Math.min(option.length, input.length) / (option.length + input.length) < cutoff) continue;
|
|
64
|
+
const pending = [[0, option.length, 0, input.length]];
|
|
65
|
+
let matched = 0;
|
|
66
|
+
while (pending.length) {
|
|
67
|
+
const [aStart, aEnd, bStart, bEnd] = pending.pop();
|
|
68
|
+
let bestA = aStart, bestB = bStart, size = 0;
|
|
69
|
+
for (let a = aStart; a < aEnd; a++) {
|
|
70
|
+
await step();
|
|
71
|
+
for (let b = bStart; b < bEnd; b++) {
|
|
72
|
+
let length = 0;
|
|
73
|
+
while (a + length < aEnd && b + length < bEnd && option[a + length] === input[b + length]) length++;
|
|
74
|
+
if (length > size) {
|
|
75
|
+
bestA = a;
|
|
76
|
+
bestB = b;
|
|
77
|
+
size = length;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
if (!size) continue;
|
|
82
|
+
matched += size;
|
|
83
|
+
if (aStart < bestA && bStart < bestB) pending.push([aStart, bestA, bStart, bestB]);
|
|
84
|
+
if (bestA + size < aEnd && bestB + size < bEnd) pending.push([bestA + size, aEnd, bestB + size, bEnd]);
|
|
85
|
+
}
|
|
86
|
+
const score = 2 * matched / (option.length + input.length);
|
|
87
|
+
if (score >= cutoff) matches.push({ option, score });
|
|
88
|
+
}
|
|
89
|
+
matches.sort((left, right) => right.score - left.score || (left.option < right.option ? 1 : left.option > right.option ? -1 : 0));
|
|
90
|
+
const suggestions = matches.slice(0, 3).map((match) => match.option).sort();
|
|
91
|
+
return !suggestions.length ? "" : suggestions.length === 1 ? ` Did you mean ${suggestions[0]}?` : ` (Possible options: ${suggestions.join(", ")})`;
|
|
92
|
+
}
|
|
9
93
|
|
|
10
94
|
// packages/safe-bash-command-llm/src/configuration.ts
|
|
11
95
|
import { FsError as FsError2, toByteSource as toByteSource2 } from "../../safe-bash-contracts/index.js";
|
|
@@ -218,6 +302,7 @@ function createLlmConfiguration(context, maxConfigurationBytes = Infinity, admis
|
|
|
218
302
|
}),
|
|
219
303
|
removeAlias: (name) => serialized(async () => {
|
|
220
304
|
const expected = await stat(filename("aliases.json"));
|
|
305
|
+
if (!expected) throw new Error("No aliases.json file exists");
|
|
221
306
|
const values = await aliases();
|
|
222
307
|
if (!Object.hasOwn(values, name)) throw new Error(`No such alias: ${name}`);
|
|
223
308
|
delete values[name];
|
|
@@ -255,6 +340,100 @@ function createLlmConfiguration(context, maxConfigurationBytes = Infinity, admis
|
|
|
255
340
|
};
|
|
256
341
|
}
|
|
257
342
|
|
|
343
|
+
// packages/safe-bash-command-llm/src/command-arguments.ts
|
|
344
|
+
async function commandArguments(group, tokens, commands, emit, diagnostic, step, prompt, help = (name) => loadLlmHelp(name.replaceAll(" ", "-"))) {
|
|
345
|
+
if (commands.length) {
|
|
346
|
+
let groupHelp = false;
|
|
347
|
+
for (const token of tokens) {
|
|
348
|
+
await step();
|
|
349
|
+
if (token === "--" || !token.startsWith("-")) break;
|
|
350
|
+
if (token.startsWith("--help=")) {
|
|
351
|
+
await diagnostic("Error: Option '--help' does not take a value.\n");
|
|
352
|
+
return 2;
|
|
353
|
+
}
|
|
354
|
+
if (token === "--help" || !token.startsWith("--") && token.includes("h")) groupHelp = true;
|
|
355
|
+
}
|
|
356
|
+
if (groupHelp) {
|
|
357
|
+
await emit(await help(group));
|
|
358
|
+
return 0;
|
|
359
|
+
}
|
|
360
|
+
if (tokens[0] === "--") tokens = tokens.slice(1);
|
|
361
|
+
}
|
|
362
|
+
const command = commands.length ? commands.includes(tokens[0] ?? "") ? tokens[0] : "list" : "";
|
|
363
|
+
if (command && tokens[0] === command) tokens = tokens.slice(1);
|
|
364
|
+
const path = group + (command ? " " + command : "");
|
|
365
|
+
const text = await help(path), usage2 = text.slice(0, text.indexOf("\n"));
|
|
366
|
+
const fail = async (message, withUsage = true) => {
|
|
367
|
+
await diagnostic((withUsage ? usage2 + `
|
|
368
|
+
Try 'llm ${path} -h' for help.
|
|
369
|
+
|
|
370
|
+
` : "") + `Error: ${message}
|
|
371
|
+
`);
|
|
372
|
+
return 2;
|
|
373
|
+
};
|
|
374
|
+
const specs = /* @__PURE__ */ new Map();
|
|
375
|
+
for (const line of text.slice(text.indexOf("Options:\n")).split("\n")) {
|
|
376
|
+
if (!line.startsWith(" -")) continue;
|
|
377
|
+
const declaration = line.trim().split(" ")[0];
|
|
378
|
+
const aliases = declaration.split(", ").map((part) => part.split(" ")[0]);
|
|
379
|
+
const spec = { name: aliases.at(-1), value: declaration.split(", ").at(-1).includes(" ") };
|
|
380
|
+
for (const alias of aliases) specs.set(alias, spec);
|
|
381
|
+
}
|
|
382
|
+
const values = /* @__PURE__ */ new Map(), operands = [];
|
|
383
|
+
let ended = false, wantsHelp = false;
|
|
384
|
+
for (let index = 0; index < tokens.length; index++) {
|
|
385
|
+
await step();
|
|
386
|
+
const token = tokens[index];
|
|
387
|
+
if (!ended && token === "--") {
|
|
388
|
+
ended = true;
|
|
389
|
+
continue;
|
|
390
|
+
}
|
|
391
|
+
if (ended || !token.startsWith("-") || token === "-") {
|
|
392
|
+
operands.push(token);
|
|
393
|
+
continue;
|
|
394
|
+
}
|
|
395
|
+
const long = token.startsWith("--"), equals = token.indexOf("=");
|
|
396
|
+
for (let cursor = long ? 0 : 1; cursor < token.length; cursor++) {
|
|
397
|
+
const flag = long ? token.slice(0, equals < 0 ? void 0 : equals) : "-" + token[cursor];
|
|
398
|
+
const spec = specs.get(flag);
|
|
399
|
+
if (!spec) return fail(`No such option: ${flag}` + await chatOptionSuggestion(flag, step, [...specs.keys()]));
|
|
400
|
+
if (!spec.value) {
|
|
401
|
+
if (long && equals >= 0) return fail(`Option '${flag}' does not take a value.`, false);
|
|
402
|
+
if (spec.name === "--help") wantsHelp = true;
|
|
403
|
+
else values.set(spec.name, []);
|
|
404
|
+
if (long) break;
|
|
405
|
+
continue;
|
|
406
|
+
}
|
|
407
|
+
const value = (long ? equals < 0 ? void 0 : token.slice(equals + 1) : token.slice(cursor + 1) || void 0) ?? tokens[++index];
|
|
408
|
+
if (value === void 0) return fail(`Option '${flag}' requires an argument.`, false);
|
|
409
|
+
const key = spec.name;
|
|
410
|
+
const list = values.get(key) ?? [];
|
|
411
|
+
list.push(value);
|
|
412
|
+
values.set(key, list);
|
|
413
|
+
break;
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
if (wantsHelp) {
|
|
417
|
+
await emit(text);
|
|
418
|
+
return 0;
|
|
419
|
+
}
|
|
420
|
+
const parameters = usage2.split("[OPTIONS]")[1].trim().split(" ").filter(Boolean);
|
|
421
|
+
for (let index = operands.length; index < parameters.length; index++) {
|
|
422
|
+
if (!parameters[index].startsWith("[")) return fail(`Missing argument '${parameters[index]}'.`);
|
|
423
|
+
}
|
|
424
|
+
if (path === "keys set" && !values.has("--value")) {
|
|
425
|
+
const value = await prompt();
|
|
426
|
+
if (value === void 0) {
|
|
427
|
+
await diagnostic("Aborted!\n");
|
|
428
|
+
return 1;
|
|
429
|
+
}
|
|
430
|
+
values.set("--value", [value]);
|
|
431
|
+
}
|
|
432
|
+
const extra = parameters.at(-1)?.endsWith("...") ? [] : operands.slice(parameters.length);
|
|
433
|
+
if (extra.length) return fail(`Got unexpected extra argument${extra.length === 1 ? "" : "s"} (${extra.join(" ")})`);
|
|
434
|
+
return { command, operands, values };
|
|
435
|
+
}
|
|
436
|
+
|
|
258
437
|
// packages/safe-bash-command-llm/src/embed-command.ts
|
|
259
438
|
import { FsError as FsError3 } from "../../safe-bash-contracts/index.js";
|
|
260
439
|
import { pathOf as pathOf3 } from "../../safe-bash-contracts/path.js";
|
|
@@ -335,7 +514,6 @@ async function acquireEmbeddingInput(context, values, binary, admit) {
|
|
|
335
514
|
|
|
336
515
|
// packages/safe-bash-command-llm/src/embed-command.ts
|
|
337
516
|
var usage = "Usage: llm embed [OPTIONS] [COLLECTION] [ID]\n";
|
|
338
|
-
var help = "Usage: llm embed [OPTIONS] [COLLECTION] [ID]\n\n Embed text and store or return the result\n\nOptions:\n -i, --input PATH File to embed\n -m, --model TEXT Embedding model to use\n --store Store the text itself in the database\n -d, --database FILE\n -c, --content TEXT Content to embed\n --binary Treat input as binary data\n --metadata TEXT JSON object metadata to store\n -f, --format [json|blob|base64|hex]\n Output format\n -h, --help Show this message and exit.\n";
|
|
339
517
|
async function embeddingCommand(context, service, tokens, write, diagnostic, step, admit, maxConfigurationBytes = Infinity, stored) {
|
|
340
518
|
const encoder = new TextEncoder();
|
|
341
519
|
const fail = async (message, code = 1, withUsage = false) => {
|
|
@@ -343,45 +521,11 @@ async function embeddingCommand(context, service, tokens, write, diagnostic, ste
|
|
|
343
521
|
`);
|
|
344
522
|
return code;
|
|
345
523
|
};
|
|
346
|
-
const
|
|
347
|
-
|
|
348
|
-
const
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
const token = tokens[index];
|
|
352
|
-
if (!ended && token === "--") {
|
|
353
|
-
ended = true;
|
|
354
|
-
continue;
|
|
355
|
-
}
|
|
356
|
-
if (ended || !token.startsWith("-") || token === "-") {
|
|
357
|
-
operands.push(token);
|
|
358
|
-
continue;
|
|
359
|
-
}
|
|
360
|
-
const long = token.startsWith("--"), equals = token.indexOf("=");
|
|
361
|
-
for (let cursor = long ? 0 : 1; cursor < token.length; cursor++) {
|
|
362
|
-
const flag = long ? token.slice(0, equals < 0 ? void 0 : equals) : "-" + token[cursor];
|
|
363
|
-
if (["--help", "-h", "--store", "--binary"].includes(flag)) {
|
|
364
|
-
if (long && equals >= 0) return fail(`Option '${flag}' does not take a value.`, 2);
|
|
365
|
-
if (flag === "--store") store = true;
|
|
366
|
-
else if (flag === "--binary") binary = true;
|
|
367
|
-
else wantsHelp = true;
|
|
368
|
-
if (long) break;
|
|
369
|
-
continue;
|
|
370
|
-
}
|
|
371
|
-
const name = names[flag];
|
|
372
|
-
if (!name) return fail(`No such option: ${flag}`, 2, true);
|
|
373
|
-
const attached = long ? equals < 0 ? void 0 : token.slice(equals + 1) : token.slice(cursor + 1) || void 0;
|
|
374
|
-
const value = attached ?? tokens[++index];
|
|
375
|
-
if (value === void 0) return fail(`Option '${flag}' requires an argument.`, 2);
|
|
376
|
-
values[name] = value;
|
|
377
|
-
break;
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
if (wantsHelp) {
|
|
381
|
-
await write(encoder.encode(help));
|
|
382
|
-
return 0;
|
|
383
|
-
}
|
|
384
|
-
if (operands.length > 2) return fail(`Got unexpected extra argument${operands.length > 3 ? "s" : ""} (${operands.slice(2).join(" ")})`, 2, true);
|
|
524
|
+
const parsed = await commandArguments("embed", tokens, [], (text) => write(encoder.encode(text)), diagnostic, step);
|
|
525
|
+
if (typeof parsed === "number") return parsed;
|
|
526
|
+
const operands = parsed.operands, store = parsed.values.has("--store"), binary = parsed.values.has("--binary");
|
|
527
|
+
const values = {};
|
|
528
|
+
for (const [flag, entries] of parsed.values) if (entries.length) values[flag.slice(2)] = entries.at(-1);
|
|
385
529
|
if (values.format !== void 0 && !["json", "blob", "base64", "hex"].includes(values.format)) return fail(`Invalid value for '-f' / '--format': '${values.format}' is not one of 'json', 'blob', 'base64', 'hex'.`, 2, true);
|
|
386
530
|
if (values.metadata !== void 0) {
|
|
387
531
|
let metadata;
|
|
@@ -436,7 +580,34 @@ async function embeddingCommand(context, service, tokens, write, diagnostic, ste
|
|
|
436
580
|
}
|
|
437
581
|
}
|
|
438
582
|
|
|
583
|
+
// packages/safe-bash-command-llm/src/python-unicode.ts
|
|
584
|
+
function hasUnpairedSurrogate(value) {
|
|
585
|
+
for (const char of value) {
|
|
586
|
+
const point = char.codePointAt(0);
|
|
587
|
+
if (point >= 55296 && point <= 57343) return true;
|
|
588
|
+
}
|
|
589
|
+
return false;
|
|
590
|
+
}
|
|
591
|
+
var pythonSurrogateId = /* @__PURE__ */ Symbol("pythonSurrogateId");
|
|
592
|
+
function unicodeOrder(left, right) {
|
|
593
|
+
let a = 0, b = 0;
|
|
594
|
+
while (a < left.length && b < right.length) {
|
|
595
|
+
const x = left.codePointAt(a), y = right.codePointAt(b);
|
|
596
|
+
if (x !== y) return x - y;
|
|
597
|
+
a += x > 65535 ? 2 : 1;
|
|
598
|
+
b += y > 65535 ? 2 : 1;
|
|
599
|
+
}
|
|
600
|
+
return (a < left.length ? 1 : 0) - (b < right.length ? 1 : 0);
|
|
601
|
+
}
|
|
602
|
+
|
|
439
603
|
export {
|
|
604
|
+
loadLlmHelp,
|
|
605
|
+
chatOptions,
|
|
606
|
+
chatOptionSuggestion,
|
|
607
|
+
commandArguments,
|
|
608
|
+
hasUnpairedSurrogate,
|
|
609
|
+
pythonSurrogateId,
|
|
610
|
+
unicodeOrder,
|
|
440
611
|
publishConfiguration,
|
|
441
612
|
createLlmConfiguration,
|
|
442
613
|
embeddingText,
|
|
@@ -19,6 +19,82 @@ import {
|
|
|
19
19
|
encodeBase64Latin1
|
|
20
20
|
} from "./chunk-HNEWGADJ.js";
|
|
21
21
|
|
|
22
|
+
// packages/safe-bash-csv-engine/src/python-utf7.ts
|
|
23
|
+
var PythonUtf7EncodingError = class extends TypeError {
|
|
24
|
+
constructor() {
|
|
25
|
+
super("surrogates not allowed");
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
var PythonUtf7FileDecoder = class {
|
|
29
|
+
shifted = false;
|
|
30
|
+
haveSextet = false;
|
|
31
|
+
bits = 0;
|
|
32
|
+
value = 0;
|
|
33
|
+
high;
|
|
34
|
+
loneSurrogate = false;
|
|
35
|
+
unit(point) {
|
|
36
|
+
let output = "";
|
|
37
|
+
if (this.high !== void 0) {
|
|
38
|
+
const high = this.high;
|
|
39
|
+
this.high = void 0;
|
|
40
|
+
if (point >= 56320 && point <= 57343) return String.fromCodePoint(65536 + (high - 55296) * 1024 + point - 56320);
|
|
41
|
+
this.loneSurrogate = true;
|
|
42
|
+
output += String.fromCharCode(high);
|
|
43
|
+
}
|
|
44
|
+
if (point >= 55296 && point <= 56319) this.high = point;
|
|
45
|
+
else {
|
|
46
|
+
if (point >= 56320 && point <= 57343) this.loneSurrogate = true;
|
|
47
|
+
output += String.fromCharCode(point);
|
|
48
|
+
}
|
|
49
|
+
return output;
|
|
50
|
+
}
|
|
51
|
+
decode(bytes = new Uint8Array(), options = {}) {
|
|
52
|
+
let output = "";
|
|
53
|
+
for (const byte of bytes) {
|
|
54
|
+
if (this.shifted) {
|
|
55
|
+
const sextet = byte >= 65 && byte <= 90 ? byte - 65 : byte >= 97 && byte <= 122 ? byte - 71 : byte >= 48 && byte <= 57 ? byte + 4 : byte === 43 ? 62 : byte === 47 ? 63 : -1;
|
|
56
|
+
if (sextet >= 0) {
|
|
57
|
+
this.haveSextet = true;
|
|
58
|
+
this.value = this.value << 6 | sextet;
|
|
59
|
+
this.bits += 6;
|
|
60
|
+
if (this.bits >= 16) {
|
|
61
|
+
this.bits -= 16;
|
|
62
|
+
output += this.unit(this.value >>> this.bits);
|
|
63
|
+
this.value &= (1 << this.bits) - 1;
|
|
64
|
+
}
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
if (!this.haveSextet) {
|
|
68
|
+
if (byte !== 45) throw new PythonTextDecodeError("Invalid UTF-7 shift");
|
|
69
|
+
output += "+";
|
|
70
|
+
} else {
|
|
71
|
+
if (this.bits >= 6 || this.value !== 0) throw new PythonTextDecodeError("Invalid UTF-7 padding");
|
|
72
|
+
if (this.high !== void 0) {
|
|
73
|
+
this.loneSurrogate = true;
|
|
74
|
+
output += String.fromCharCode(this.high);
|
|
75
|
+
this.high = void 0;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
this.shifted = false;
|
|
79
|
+
if (byte === 45) continue;
|
|
80
|
+
}
|
|
81
|
+
if (byte >= 128) throw new PythonTextDecodeError("Invalid UTF-7 byte");
|
|
82
|
+
if (byte === 43) {
|
|
83
|
+
this.shifted = true;
|
|
84
|
+
this.haveSextet = false;
|
|
85
|
+
this.bits = 0;
|
|
86
|
+
this.value = 0;
|
|
87
|
+
} else output += String.fromCharCode(byte);
|
|
88
|
+
}
|
|
89
|
+
if (!options.stream) {
|
|
90
|
+
if (this.shifted && (this.bits >= 6 || this.value !== 0 || this.high !== void 0)) throw new PythonTextDecodeError("Incomplete UTF-7 shift");
|
|
91
|
+
this.shifted = false;
|
|
92
|
+
if (this.loneSurrogate) throw new PythonUtf7EncodingError();
|
|
93
|
+
}
|
|
94
|
+
return output;
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
|
|
22
98
|
// packages/safe-bash-csv-engine/src/python-gb18030-table.ts
|
|
23
99
|
var pythonGb18030Table = { "nativeEncoding": "gb18030", "native": "APwDgIUE+AGAAfgDgAP4AYAB+AOAA/gBgAH4A4AD+AGAAfgDgAP4AYAB+AOAA/gBgAH4A4AD+AGAAfgDgAP4AYAB+AOAA/gBgAH4A4AD+AGAAfgDgAP4AYAB+AOAA/gBgAH4A4AD+AGAAfgDgAP4AYAB+AOAA/gBgAH4A4AD+AGAAfgDgAP4AYAB+AOAA/gBgAH4A4AD+AGAAfgDgAP4AYAB+AOAA/gBgAH4A4AD+AGAAfgDgAP4AYAB+AOAA/gBgAH4A4AD+AGAAfgDgAP4AYAB+AOAA/gBgAH4A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GAR6OQ64CkEOYAWqaATbCAjiiASKkARJmFDQCPAICBAIKBgYWCAwCEgIGBgSWIAqMEAKQEAIOJggCHAICCgICHgLSBAqqAoIE5gOCAmaOAsyhEv7//wE0" };
|
|
24
100
|
|
|
@@ -407,15 +483,15 @@ var PythonTextDecoder = class {
|
|
|
407
483
|
constructor(encoding) {
|
|
408
484
|
const name = normalizeEncoding(encoding);
|
|
409
485
|
const canonical = Object.hasOwn(pythonCodecAliases, name) ? pythonCodecAliases[name] : void 0;
|
|
410
|
-
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(pythonIso2022Charsets, canonical) && !Object.hasOwn(fileCodepages, canonical) && !Object.hasOwn(pythonMultibyteTables, canonical)) throw new RangeError(`unknown encoding: ${encoding}`);
|
|
486
|
+
if (canonical === void 0 || !["utf-7", "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(pythonIso2022Charsets, canonical) && !Object.hasOwn(fileCodepages, canonical) && !Object.hasOwn(pythonMultibyteTables, canonical)) throw new RangeError(`unknown encoding: ${encoding}`);
|
|
411
487
|
this.encoding = canonical;
|
|
412
488
|
this.codepoints = fileCodepages[canonical];
|
|
413
489
|
this.signatureComplete = canonical !== "utf-8-sig";
|
|
414
|
-
this.decoder = Object.hasOwn(pythonIso2022Charsets, canonical) ? new PythonIso2022Decoder(canonical) : 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 });
|
|
490
|
+
this.decoder = canonical === "utf-7" ? new PythonUtf7FileDecoder() : Object.hasOwn(pythonIso2022Charsets, canonical) ? new PythonIso2022Decoder(canonical) : 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 });
|
|
415
491
|
}
|
|
416
492
|
decode(bytes, options) {
|
|
417
493
|
if (this.codepoints) return decodePythonSingleByte(bytes ?? new Uint8Array(), this.codepoints, this.encoding);
|
|
418
|
-
if (this.decoder instanceof PythonIso2022Decoder || this.decoder instanceof PythonHzDecoder || this.decoder instanceof PythonUtf16Decoder || this.decoder instanceof PythonUtf32Decoder || this.decoder instanceof PythonMultibyteDecoder) return this.decoder.decode(bytes, options);
|
|
494
|
+
if (this.decoder instanceof PythonUtf7FileDecoder || this.decoder instanceof PythonIso2022Decoder || this.decoder instanceof PythonHzDecoder || this.decoder instanceof PythonUtf16Decoder || this.decoder instanceof PythonUtf32Decoder || this.decoder instanceof PythonMultibyteDecoder) return this.decoder.decode(bytes, options);
|
|
419
495
|
try {
|
|
420
496
|
let offset = 0;
|
|
421
497
|
if (!this.signatureComplete) {
|
|
@@ -442,6 +518,7 @@ var PythonTextDecoder = class {
|
|
|
442
518
|
};
|
|
443
519
|
|
|
444
520
|
export {
|
|
521
|
+
PythonUtf7EncodingError,
|
|
445
522
|
PythonIso2022PendingError,
|
|
446
523
|
PythonTextDecoder
|
|
447
524
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
base64Stream
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-ZFXHSFTU.js";
|
|
4
4
|
import {
|
|
5
5
|
waitForSource
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-36FV6BAG.js";
|
|
7
7
|
|
|
8
8
|
// packages/safe-bash-command-llm/src/file-source.ts
|
|
9
9
|
import { FsError } from "../../safe-bash-contracts/index.js";
|