@poe-platform/safe-bash 0.1.789 → 0.1.790
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/image-ast/index.browser.js +147 -80
- package/dist/image-ast/index.js +147 -80
- package/dist/mp4-ast/mp4.d.ts +2 -0
- package/dist/pdf-ast/cos/parser.d.ts +1 -0
- package/dist/pdf-ast/cos/security.d.ts +2 -0
- package/dist/pdf-ast/cos/writer.d.ts +1 -0
- package/dist/pdf-ast/document.d.ts +3 -0
- package/dist/pdf-ast/edit/forms.d.ts +1 -0
- package/dist/pdf-ast/index.js +171 -82
- package/dist/safe-bash/chunks/{chunk-L5QQLNTO.js → chunk-22PI65AH.js} +2 -2
- package/dist/safe-bash/chunks/{chunk-KHJGUF2W.js → chunk-2TAGYMPK.js} +43 -42
- package/dist/safe-bash/chunks/{chunk-D4PHJK4T.js → chunk-2W4HTMEK.js} +52 -48
- package/dist/safe-bash/chunks/{chunk-FFZXP6ZC.js → chunk-3M7L7XU2.js} +2 -2
- package/dist/safe-bash/chunks/{chunk-XNODZRVD.js → chunk-3QAO6UYS.js} +2 -2
- package/dist/safe-bash/chunks/{chunk-YPETOVQU.js → chunk-3VKFK3NF.js} +2 -2
- package/dist/safe-bash/chunks/chunk-5OST7NOX.js +42 -0
- package/dist/safe-bash/chunks/{chunk-KEBSX2AX.js → chunk-6HLURHVU.js} +2 -2
- package/dist/safe-bash/chunks/chunk-DYEUZE6Z.js +19 -0
- package/dist/safe-bash/chunks/{chunk-T2TGCHKE.js → chunk-FM3WBSZT.js} +2 -2
- package/dist/safe-bash/chunks/chunk-GAYRKQM6.js +22 -0
- package/dist/safe-bash/chunks/{chunk-Q45QCA4J.js → chunk-I3KSESCR.js} +0 -7
- package/dist/safe-bash/chunks/{chunk-OSKDIBQS.js → chunk-JLIMK5TD.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-2AYZCT5X.js → chunk-JQ2FAJJT.js} +27 -23
- package/dist/safe-bash/chunks/{chunk-QA3NVP43.js → chunk-JRE6Z3T7.js} +2 -2
- package/dist/safe-bash/chunks/{chunk-DC5EHLKS.js → chunk-NDIL6T7Y.js} +5 -5
- package/dist/safe-bash/chunks/{chunk-747G42FY.js → chunk-OPR4UAIT.js} +2 -2
- package/dist/safe-bash/chunks/chunk-OSMQCYSP.js +19 -0
- package/dist/safe-bash/chunks/chunk-OYB332PQ.js +17 -0
- package/dist/safe-bash/chunks/{chunk-X5ZCECM6.js → chunk-QTIH2AFE.js} +77 -69
- package/dist/safe-bash/chunks/{chunk-CTUHLNJM.js → chunk-SBESXWT2.js} +43 -44
- package/dist/safe-bash/chunks/{chunk-4FDQJUFW.js → chunk-SDEPGTOF.js} +1 -1
- package/dist/safe-bash/chunks/chunk-UZU5BIJI.js +32 -0
- package/dist/safe-bash/chunks/{chunk-BI6JV62X.js → chunk-VCCMROTL.js} +7 -10
- package/dist/safe-bash/chunks/chunk-W47GHRRF.js +13 -0
- package/dist/safe-bash/chunks/{chunk-NPMQWZUZ.js → chunk-WS7KZIUM.js} +2 -2
- package/dist/safe-bash/chunks/{chunk-3PZYHMGM.js → chunk-YYAERCWS.js} +7 -7
- package/dist/safe-bash/chunks/{chunk-5U7JECDB.js → chunk-ZPGVEUKF.js} +8 -7
- package/dist/safe-bash/chunks/{csvkit-K55OYAQC.js → csvkit-USUJG62I.js} +65 -11
- package/dist/safe-bash/chunks/{ffmpeg-BEFTQ6DZ.js → ffmpeg-KRGG5DLH.js} +21 -10
- package/dist/safe-bash/chunks/{gh-HQWOWLWE.js → gh-UCFDUZCX.js} +16 -8
- package/dist/safe-bash/chunks/{git-HO7WDPHZ.js → git-LPAF6KDG.js} +7 -9
- package/dist/safe-bash/chunks/{imagemagick-53BMHH6D.js → imagemagick-KGREKK4G.js} +38 -7
- package/dist/safe-bash/chunks/{implementation-QUTAAYMT.js → implementation-FXDRYS5A.js} +34 -8
- package/dist/safe-bash/chunks/{pdfimages-4OYI6FLG.js → pdfimages-UADCF4G4.js} +12 -8
- package/dist/safe-bash/chunks/{pdfinfo-I7U6TQPP.js → pdfinfo-O7UWPF4W.js} +38 -13
- package/dist/safe-bash/chunks/{pdftk-SUA6FMHI.js → pdftk-AERXIJTN.js} +13 -8
- package/dist/safe-bash/chunks/{pdftoppm-4C5DGEWX.js → pdftoppm-L466JQKI.js} +17 -10
- package/dist/safe-bash/chunks/{pdftotext-Y4WI225Y.js → pdftotext-SUSI4WXS.js} +19 -9
- package/dist/safe-bash/chunks/{qpdf-IORB4RV5.js → qpdf-YL24KVRH.js} +14 -8
- package/dist/safe-bash/chunks/{sips-WHAMJFEU.js → sips-QXEQZERX.js} +14 -7
- package/dist/safe-bash/chunks/{soffice-SYEK6WJS.js → soffice-TBITRML3.js} +16 -8
- package/dist/safe-bash/chunks/{wkhtmltopdf-ZIICWJLF.js → wkhtmltopdf-NJA2THRC.js} +27 -7
- package/dist/safe-bash/command-chunks/chunk-2C5BEBPY.js +1388 -0
- package/dist/safe-bash/command-chunks/{chunk-2VTMZTV3.js → chunk-2EXV2ZLV.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-UJOO6DKY.js → chunk-6EASC5EC.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-ZF3ZVGQC.js → chunk-7JRITHKW.js} +150 -80
- package/dist/safe-bash/{chunks/chunk-LD76P7AG.js → command-chunks/chunk-AKDMCNX4.js} +74 -39
- package/dist/safe-bash/command-chunks/{chunk-6F7QJMJ3.js → chunk-CBDVLMJB.js} +1 -1
- package/dist/safe-bash/command-chunks/chunk-H4LWTITX.js +169 -0
- package/dist/safe-bash/command-chunks/chunk-I2MQNBGR.js +145 -0
- package/dist/safe-bash/command-chunks/{chunk-5GRLAARV.js → chunk-IOXI5ZAJ.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-XNHSCU6I.js → chunk-MDPIOQUD.js} +6 -6
- package/dist/safe-bash/command-chunks/chunk-QI4MGIN6.js +6 -0
- package/dist/safe-bash/command-chunks/chunk-QTYZAWSB.js +91 -0
- package/dist/safe-bash/command-chunks/chunk-SNK7K3XW.js +90 -0
- package/dist/safe-bash/command-chunks/chunk-T5OLGM43.js +314 -0
- package/dist/safe-bash/command-chunks/chunk-TB7IFMUZ.js +802 -0
- package/dist/safe-bash/command-chunks/{chunk-AT6ZSOE6.js → chunk-TPPBPIWL.js} +1 -1
- package/dist/safe-bash/command-chunks/chunk-VMK4XVKO.js +82 -0
- package/dist/safe-bash/command-chunks/chunk-VNSJKXDU.js +130 -0
- package/dist/safe-bash/command-chunks/chunk-YFNTMH6Z.js +6 -0
- package/dist/safe-bash/commands/csplit/index.browser.js +2 -2
- package/dist/safe-bash/commands/docx/index.browser.js +2 -2
- package/dist/safe-bash/commands/factor/index.browser.js +2 -2
- package/dist/safe-bash/commands/getopt/index.browser.js +2 -2
- package/dist/safe-bash/commands/hexdump/index.browser.js +2 -2
- package/dist/safe-bash/commands/iconv/index.browser.js +2 -2
- package/dist/safe-bash/commands/line-endings/index.browser.js +2 -2
- package/dist/safe-bash/commands/llm/command.d.ts +1 -4
- package/dist/safe-bash/commands/llm/command.js +1 -248
- package/dist/safe-bash/commands/llm/elevenlabs-stream.d.ts +1 -2
- package/dist/safe-bash/commands/llm/elevenlabs-stream.js +1 -117
- package/dist/safe-bash/commands/llm/elevenlabs.d.ts +1 -15
- package/dist/safe-bash/commands/llm/elevenlabs.js +1 -123
- package/dist/safe-bash/commands/llm/index.browser.js +20 -15
- package/dist/safe-bash/commands/llm/index.d.ts +1 -6
- package/dist/safe-bash/commands/llm/index.js +1 -4
- package/dist/safe-bash/commands/llm/mime.d.ts +1 -2
- package/dist/safe-bash/commands/llm/mime.js +1 -136
- package/dist/safe-bash/commands/llm/openai-http.d.ts +1 -8
- package/dist/safe-bash/commands/llm/openai-http.js +1 -143
- package/dist/safe-bash/commands/llm/openai-sse.d.ts +1 -3
- package/dist/safe-bash/commands/llm/openai-sse.js +1 -78
- package/dist/safe-bash/commands/llm/openai.d.ts +1 -14
- package/dist/safe-bash/commands/llm/openai.js +1 -288
- package/dist/safe-bash/commands/llm/providers/elevenlabs.d.ts +1 -1
- package/dist/safe-bash/commands/llm/providers/elevenlabs.js +1 -1
- package/dist/safe-bash/commands/llm/providers/index.browser.js +6 -6
- package/dist/safe-bash/commands/llm/providers/index.d.ts +1 -3
- package/dist/safe-bash/commands/llm/providers/index.js +1 -2
- package/dist/safe-bash/commands/llm/providers/openai.d.ts +1 -1
- package/dist/safe-bash/commands/llm/providers/openai.js +1 -1
- package/dist/safe-bash/commands/llm/providers/shared.d.ts +1 -23
- package/dist/safe-bash/commands/llm/providers/shared.js +1 -65
- package/dist/safe-bash/commands/llm/service.d.ts +1 -37
- package/dist/safe-bash/commands/llm/service.js +1 -151
- package/dist/safe-bash/commands/llm/types.d.ts +1 -52
- package/dist/safe-bash/commands/llm/types.js +1 -1
- package/dist/safe-bash/commands/mdq/index.browser.js +3 -3
- package/dist/safe-bash/commands/media/index.browser.js +1 -1
- package/dist/safe-bash/commands/network/index.browser.js +9 -9
- package/dist/safe-bash/commands/network/types.d.ts +2 -40
- package/dist/safe-bash/commands/node/index.browser.js +6 -8
- package/dist/safe-bash/commands/op/index.browser.js +3 -3
- package/dist/safe-bash/commands/op/index.js +12 -28
- package/dist/safe-bash/commands/pr/index.browser.js +2 -2
- package/dist/safe-bash/commands/python/index.browser.js +8 -8
- package/dist/safe-bash/commands/python/worker.browser.js +2 -2
- package/dist/safe-bash/commands/tsort/index.browser.js +2 -2
- package/dist/safe-bash/commands/xml/index.browser.js +2 -2
- package/dist/safe-bash/commands/yq/index.browser.js +3 -3
- package/dist/safe-bash/core.browser.js +9775 -10975
- package/dist/safe-bash/core.d.ts +0 -1
- package/dist/safe-bash/core.js +0 -1
- package/dist/safe-bash/jobs.browser.js +5 -4
- package/dist/safe-bash/optional-host.browser.js +61 -88
- package/dist/safe-bash/shell/runtime.js +34 -12
- package/dist/safe-bash/yq-browser/index.js +1 -1
- package/dist/safe-bash-command-ffmpeg/index.js +8130 -8011
- 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-imagemagick/index.js +2 -2
- package/dist/safe-bash-command-llm/LICENSE +21 -0
- package/dist/safe-bash-command-llm/command.d.ts +5 -0
- package/dist/safe-bash-command-llm/command.js +14 -0
- package/dist/safe-bash-command-llm/configuration.d.ts +18 -0
- package/dist/safe-bash-command-llm/elevenlabs-stream.d.ts +2 -0
- package/dist/safe-bash-command-llm/elevenlabs-stream.js +7 -0
- package/dist/safe-bash-command-llm/elevenlabs.d.ts +15 -0
- package/dist/safe-bash-command-llm/elevenlabs.js +10 -0
- package/dist/safe-bash-command-llm/index.d.ts +10 -0
- package/dist/safe-bash-command-llm/index.js +46 -0
- package/dist/safe-bash-command-llm/mime.d.ts +2 -0
- package/dist/safe-bash-command-llm/mime.js +9 -0
- package/dist/safe-bash-command-llm/model-options.d.ts +3 -0
- package/dist/safe-bash-command-llm/openai-http.d.ts +8 -0
- package/dist/safe-bash-command-llm/openai-http.js +17 -0
- package/dist/safe-bash-command-llm/openai-sse.d.ts +3 -0
- package/dist/safe-bash-command-llm/openai-sse.js +8 -0
- package/dist/safe-bash-command-llm/openai.d.ts +14 -0
- package/dist/safe-bash-command-llm/openai.js +12 -0
- package/dist/safe-bash-command-llm/providers/elevenlabs.d.ts +1 -0
- package/dist/safe-bash-command-llm/providers/elevenlabs.js +11 -0
- package/dist/safe-bash-command-llm/providers/index.d.ts +3 -0
- package/dist/safe-bash-command-llm/providers/index.js +24 -0
- package/dist/safe-bash-command-llm/providers/openai.d.ts +1 -0
- package/dist/safe-bash-command-llm/providers/openai.js +13 -0
- package/dist/safe-bash-command-llm/providers/shared.d.ts +23 -0
- package/dist/safe-bash-command-llm/providers/shared.js +13 -0
- package/dist/safe-bash-command-llm/schemas.d.ts +2 -0
- package/dist/safe-bash-command-llm/service.d.ts +42 -0
- package/dist/safe-bash-command-llm/service.js +9 -0
- package/dist/safe-bash-command-llm/templates.d.ts +27 -0
- package/dist/safe-bash-command-llm/types.d.ts +87 -0
- package/dist/safe-bash-command-llm/types.js +6 -0
- package/dist/safe-bash-command-mmdc/command.d.ts +4 -0
- package/dist/safe-bash-command-mmdc/index.d.ts +1 -1
- package/dist/safe-bash-command-mmdc/index.js +7084 -6687
- package/dist/safe-bash-command-mmdc/layout.d.ts +1 -0
- package/dist/safe-bash-command-mmdc/parser.d.ts +1 -0
- package/dist/safe-bash-command-mmdc/png.d.ts +3 -0
- package/dist/safe-bash-command-mmdc/raster.d.ts +1 -0
- 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-pdfimages/index.js +147 -80
- package/dist/safe-bash-command-pdfinfo/index.js +147 -80
- package/dist/safe-bash-command-pdftk/index.js +147 -80
- package/dist/safe-bash-command-pdftoppm/index.js +147 -80
- package/dist/safe-bash-command-pdftotext/index.js +147 -80
- package/dist/safe-bash-command-qpdf/index.js +174 -101
- package/dist/safe-bash-command-sips/index.js +2 -2
- package/dist/safe-bash-command-soffice/index.js +1 -1
- package/dist/safe-bash-command-ssconvert/index.js +147 -80
- package/dist/safe-bash-command-wkhtmltopdf/index.js +147 -80
- package/dist/safe-bash-contracts/default-executor.d.ts +5 -0
- package/dist/safe-bash-contracts/default-executor.js +37 -0
- package/dist/safe-bash-contracts/http.d.ts +41 -0
- package/dist/safe-bash-contracts/http.js +6 -0
- package/dist/safe-bash-io-engine/commands/search/requirements.js +3 -3
- package/dist/safe-bash-io-engine/commands/text-programs/shared.js +3 -3
- package/dist/safe-bash-io-engine/gnu-information.d.ts +1 -1
- package/dist/safe-bash-io-engine/gnu-information.js +1 -1
- package/dist/safe-bash-io-engine/internal.js +2 -2
- package/dist/safe-bash-query-engine/index.js +3 -3
- package/dist/safe-bash-query-engine/interpreter.js +2 -2
- package/dist/safe-bash-query-engine/query-core.js +3 -3
- package/package.json +2 -2
- package/dist/safe-bash/chunks/chunk-2G2T5MEM.js +0 -14
- package/dist/safe-bash/chunks/chunk-2MUJ7RLZ.js +0 -409
- package/dist/safe-bash/chunks/chunk-GJWUEOT6.js +0 -14
- package/dist/safe-bash/chunks/chunk-H7MMJS26.js +0 -37
- package/dist/safe-bash/chunks/chunk-LAPF2XE6.js +0 -14
- package/dist/safe-bash/chunks/chunk-S2LSZFZ6.js +0 -758
- package/dist/safe-bash/chunks/chunk-T3VDYWKZ.js +0 -21
- package/dist/safe-bash/chunks/chunk-VUVKC6HV.js +0 -81
- package/dist/safe-bash/chunks/chunk-VYW4Q6KF.js +0 -12
- package/dist/safe-bash/command-chunks/{chunk-BJ6DGYJA.js → chunk-KNI4GRXF.js} +3 -3
|
@@ -1,152 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
function abortable(start, signal) {
|
|
3
|
-
signal.throwIfAborted();
|
|
4
|
-
return new Promise((resolve, reject) => {
|
|
5
|
-
const abort = () => { signal.removeEventListener("abort", abort); reject(signal.reason); };
|
|
6
|
-
signal.addEventListener("abort", abort, { once: true });
|
|
7
|
-
Promise.resolve().then(() => { signal.throwIfAborted(); return start(); }).then(value => { signal.removeEventListener("abort", abort); if (signal.aborted)
|
|
8
|
-
reject(signal.reason);
|
|
9
|
-
else
|
|
10
|
-
resolve(value); }, error => { signal.removeEventListener("abort", abort); reject(signal.aborted ? signal.reason : error); });
|
|
11
|
-
if (signal.aborted)
|
|
12
|
-
abort();
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
function validateMetadata(value) {
|
|
16
|
-
for (const field of [value.usage, value.metadata]) {
|
|
17
|
-
if (field !== undefined && (!field || typeof field !== "object" || Array.isArray(field)))
|
|
18
|
-
throw new TypeError("Invalid LLM response metadata");
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
function validateOptions(options) {
|
|
22
|
-
for (const [key, value] of Object.entries(options)) {
|
|
23
|
-
if (!key || value !== null && !["string", "number", "boolean"].includes(typeof value) || typeof value === "number" && !Number.isFinite(value)) {
|
|
24
|
-
throw new TypeError(`Invalid model option ${key}: expected a finite scalar`);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
export function createLlmService(options) {
|
|
29
|
-
const models = [];
|
|
30
|
-
const lookup = new Map();
|
|
31
|
-
const defaultModel = options.defaultModel;
|
|
32
|
-
for (const provider of options.providers) {
|
|
33
|
-
if (!provider.name || typeof provider.complete !== "function")
|
|
34
|
-
throw new TypeError("Providers require a name and complete function");
|
|
35
|
-
for (const declared of provider.models) {
|
|
36
|
-
if (!declared.id)
|
|
37
|
-
throw new TypeError("Models require a nonempty id");
|
|
38
|
-
const model = Object.freeze({ ...declared,
|
|
39
|
-
...(declared.capabilities ? { capabilities: Object.freeze([...declared.capabilities]) } : {}),
|
|
40
|
-
...(declared.aliases ? { aliases: Object.freeze([...declared.aliases]) } : {}),
|
|
41
|
-
...(declared.attachmentTypes ? { attachmentTypes: Object.freeze([...declared.attachmentTypes]) } : {}),
|
|
42
|
-
});
|
|
43
|
-
const entry = Object.freeze({ provider, model });
|
|
44
|
-
for (const name of new Set([model.id, `${provider.name}/${model.id}`, ...model.aliases ?? []])) {
|
|
45
|
-
if (!name)
|
|
46
|
-
throw new TypeError("Model aliases must not be empty");
|
|
47
|
-
if (lookup.has(name))
|
|
48
|
-
throw new Error(`Duplicate model id or alias: ${name}`);
|
|
49
|
-
lookup.set(name, entry);
|
|
50
|
-
}
|
|
51
|
-
models.push(entry);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
return Object.freeze({
|
|
55
|
-
version: 1,
|
|
56
|
-
models: Object.freeze(models),
|
|
57
|
-
resolve(model) {
|
|
58
|
-
const selected = model ?? defaultModel;
|
|
59
|
-
if (selected === undefined)
|
|
60
|
-
throw new Error("No model selected; use --model or configure defaultModel");
|
|
61
|
-
const entry = lookup.get(selected);
|
|
62
|
-
if (!entry)
|
|
63
|
-
throw new Error(`Unknown model: ${selected}`);
|
|
64
|
-
return entry;
|
|
65
|
-
},
|
|
66
|
-
complete(request) {
|
|
67
|
-
request.signal.throwIfAborted();
|
|
68
|
-
validateOptions(request.options);
|
|
69
|
-
if (typeof request.prompt !== "string" || request.system !== undefined && typeof request.system !== "string")
|
|
70
|
-
throw new TypeError("Invalid LLM prompt");
|
|
71
|
-
const entry = this.resolve(request.model);
|
|
72
|
-
if (request.messages?.length && !entry.model.capabilities?.includes("messages"))
|
|
73
|
-
throw new Error(`Model ${entry.model.id} does not support messages`);
|
|
74
|
-
if (request.messages?.some(message => !["system", "user", "assistant"].includes(message.role) || typeof message.content !== "string"))
|
|
75
|
-
throw new TypeError("Invalid LLM message");
|
|
76
|
-
if (request.schema !== undefined) {
|
|
77
|
-
if (!entry.model.capabilities?.includes("schema"))
|
|
78
|
-
throw new Error(`Model ${entry.model.id} does not support schema`);
|
|
79
|
-
if (!request.schema || typeof request.schema !== "object" || Array.isArray(request.schema))
|
|
80
|
-
throw new TypeError("Invalid LLM schema");
|
|
81
|
-
}
|
|
82
|
-
for (const attachment of request.attachments) {
|
|
83
|
-
if (!acceptsMimeType(entry.model.attachmentTypes ?? [], attachment.mimeType)) {
|
|
84
|
-
throw new Error(`Model ${entry.model.id} does not accept ${attachment.mimeType}`);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
const { maxOutputBytes: ignoredMaxOutputBytes, ...input } = request;
|
|
88
|
-
return entry.provider.complete({ ...input, model: entry.model.id });
|
|
89
|
-
},
|
|
90
|
-
async *stream(request) {
|
|
91
|
-
const limit = request.maxOutputBytes ?? Infinity;
|
|
92
|
-
if (limit !== Infinity && (!Number.isSafeInteger(limit) || limit < 0))
|
|
93
|
-
throw new RangeError("Invalid LLM output limit");
|
|
94
|
-
const entry = this.resolve(request.model);
|
|
95
|
-
const iterator = this.complete(request)[Symbol.asyncIterator]();
|
|
96
|
-
let ended = false;
|
|
97
|
-
let size = 0;
|
|
98
|
-
try {
|
|
99
|
-
while (true) {
|
|
100
|
-
request.signal.throwIfAborted();
|
|
101
|
-
const result = await abortable(() => iterator.next(), request.signal);
|
|
102
|
-
request.signal.throwIfAborted();
|
|
103
|
-
if (result.done) {
|
|
104
|
-
ended = true;
|
|
105
|
-
const metadata = result.value;
|
|
106
|
-
if (metadata !== undefined && (!metadata || typeof metadata !== "object" || Array.isArray(metadata)))
|
|
107
|
-
throw new TypeError("Invalid LLM response metadata");
|
|
108
|
-
const details = metadata;
|
|
109
|
-
if (details)
|
|
110
|
-
validateMetadata(details);
|
|
111
|
-
yield { type: "response", response: { model: entry.model.id, ...(details?.usage ? { usage: details.usage } : {}), ...(details?.metadata ? { metadata: details.metadata } : {}) } };
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
const chunk = result.value;
|
|
115
|
-
const text = (entry.model.outputType ?? "text/plain").toLowerCase().startsWith("text/");
|
|
116
|
-
if (text ? typeof chunk !== "string" : !(chunk instanceof Uint8Array))
|
|
117
|
-
throw new TypeError("Provider returned an incompatible LLM output chunk");
|
|
118
|
-
size += typeof chunk === "string" ? new TextEncoder().encode(chunk).length : chunk.byteLength;
|
|
119
|
-
if (size > limit)
|
|
120
|
-
throw new RangeError("LLM output byte limit exceeded");
|
|
121
|
-
yield typeof chunk === "string" ? { type: "text", text: chunk } : { type: "bytes", data: new Uint8Array(chunk) };
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
finally {
|
|
125
|
-
if (!ended) {
|
|
126
|
-
const closing = Promise.resolve().then(() => iterator.return?.());
|
|
127
|
-
if (request.signal.aborted)
|
|
128
|
-
void closing.catch(() => undefined);
|
|
129
|
-
else
|
|
130
|
-
await closing;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
},
|
|
134
|
-
async embed(request) {
|
|
135
|
-
request.signal.throwIfAborted();
|
|
136
|
-
validateOptions(request.options);
|
|
137
|
-
if (!Array.isArray(request.inputs) || Array.from(request.inputs).some(input => typeof input !== "string"))
|
|
138
|
-
throw new TypeError("Embedding inputs must be strings");
|
|
139
|
-
const entry = this.resolve(request.model);
|
|
140
|
-
if (!entry.model.capabilities?.includes("embed") || !entry.provider.embed)
|
|
141
|
-
throw new Error(`Model ${entry.model.id} does not support embeddings`);
|
|
142
|
-
const embed = entry.provider.embed.bind(entry.provider);
|
|
143
|
-
const result = await abortable(() => embed({ ...request, model: entry.model.id }), request.signal);
|
|
144
|
-
request.signal.throwIfAborted();
|
|
145
|
-
if (result.model !== entry.model.id || !Array.isArray(result.vectors) || result.vectors.length !== request.inputs.length || Array.from(result.vectors).some(vector => !Array.isArray(vector) || !vector.length || Array.from(vector).some(value => typeof value !== "number" || !Number.isFinite(value)) || vector.length !== result.vectors[0]?.length))
|
|
146
|
-
throw new TypeError("Invalid embedding response");
|
|
147
|
-
validateMetadata(result);
|
|
148
|
-
return result;
|
|
149
|
-
},
|
|
150
|
-
});
|
|
151
|
-
}
|
|
1
|
+
export * from "../../../safe-bash-command-llm/service.js";
|
|
152
2
|
//# sourceMappingURL=service.js.map
|
|
@@ -1,53 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export type LlmOption = string | number | boolean | null;
|
|
3
|
-
export type LlmCapability = "messages" | "schema" | "embed";
|
|
4
|
-
export interface LlmResponseMetadata {
|
|
5
|
-
readonly usage?: Readonly<Record<string, unknown>>;
|
|
6
|
-
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
7
|
-
}
|
|
8
|
-
export interface LlmProvider {
|
|
9
|
-
readonly name: string;
|
|
10
|
-
readonly models: readonly LlmModel[];
|
|
11
|
-
complete(request: LlmRequest): AsyncIterable<string | Uint8Array, LlmResponseMetadata | void>;
|
|
12
|
-
embed?(request: LlmEmbeddingRequest): Promise<LlmEmbeddingResponse>;
|
|
13
|
-
}
|
|
14
|
-
export interface LlmModel {
|
|
15
|
-
readonly id: string;
|
|
16
|
-
readonly aliases?: readonly string[];
|
|
17
|
-
readonly attachmentTypes?: readonly string[];
|
|
18
|
-
readonly outputType?: string;
|
|
19
|
-
readonly capabilities?: readonly LlmCapability[];
|
|
20
|
-
}
|
|
21
|
-
export interface LlmEmbeddingRequest {
|
|
22
|
-
readonly model: string;
|
|
23
|
-
readonly inputs: readonly string[];
|
|
24
|
-
readonly options: Readonly<Record<string, LlmOption>>;
|
|
25
|
-
readonly signal: AbortSignal;
|
|
26
|
-
}
|
|
27
|
-
export interface LlmEmbeddingResponse extends LlmResponseMetadata {
|
|
28
|
-
readonly model: string;
|
|
29
|
-
readonly vectors: readonly (readonly number[])[];
|
|
30
|
-
}
|
|
31
|
-
export interface LlmRequest {
|
|
32
|
-
model: string;
|
|
33
|
-
prompt: string;
|
|
34
|
-
system?: string;
|
|
35
|
-
messages?: readonly {
|
|
36
|
-
readonly role: "system" | "user" | "assistant";
|
|
37
|
-
readonly content: string;
|
|
38
|
-
}[];
|
|
39
|
-
schema?: Readonly<Record<string, unknown>>;
|
|
40
|
-
attachments: readonly {
|
|
41
|
-
mimeType: string;
|
|
42
|
-
bytes: Uint8Array;
|
|
43
|
-
}[];
|
|
44
|
-
options: Readonly<Record<string, LlmOption>>;
|
|
45
|
-
signal: AbortSignal;
|
|
46
|
-
}
|
|
47
|
-
export interface LlmCommandsOptions {
|
|
48
|
-
readonly providers?: readonly LlmProvider[];
|
|
49
|
-
readonly service?: LlmService;
|
|
50
|
-
readonly defaultModel?: string;
|
|
51
|
-
readonly replace?: boolean;
|
|
52
|
-
}
|
|
1
|
+
export * from "../../../safe-bash-command-llm/types.js";
|
|
53
2
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from "../../../safe-bash-command-llm/types.js";
|
|
2
2
|
//# sourceMappingURL=types.js.map
|
|
@@ -7,9 +7,9 @@ import {
|
|
|
7
7
|
mdqCommand,
|
|
8
8
|
mdqCommands,
|
|
9
9
|
parseMdqArguments
|
|
10
|
-
} from "../../chunks/chunk-
|
|
11
|
-
import "../../chunks/chunk-
|
|
12
|
-
import "../../chunks/chunk-
|
|
10
|
+
} from "../../chunks/chunk-YYAERCWS.js";
|
|
11
|
+
import "../../chunks/chunk-5OST7NOX.js";
|
|
12
|
+
import "../../chunks/chunk-I3KSESCR.js";
|
|
13
13
|
export {
|
|
14
14
|
MdqError,
|
|
15
15
|
createMdqCommand,
|
|
@@ -12,15 +12,15 @@ import {
|
|
|
12
12
|
evalSyncCurl,
|
|
13
13
|
evalSyncWget,
|
|
14
14
|
networkCommands
|
|
15
|
-
} from "../../chunks/chunk-
|
|
16
|
-
import "../../chunks/chunk-
|
|
17
|
-
import "../../chunks/chunk-
|
|
18
|
-
import "../../chunks/chunk-
|
|
19
|
-
import "../../chunks/chunk-
|
|
20
|
-
import "../../chunks/chunk-
|
|
21
|
-
import "../../chunks/chunk-
|
|
22
|
-
import "../../chunks/chunk-
|
|
23
|
-
import "../../chunks/chunk-
|
|
15
|
+
} from "../../chunks/chunk-QTIH2AFE.js";
|
|
16
|
+
import "../../chunks/chunk-VCCMROTL.js";
|
|
17
|
+
import "../../chunks/chunk-W47GHRRF.js";
|
|
18
|
+
import "../../chunks/chunk-OYB332PQ.js";
|
|
19
|
+
import "../../chunks/chunk-DYEUZE6Z.js";
|
|
20
|
+
import "../../chunks/chunk-UZU5BIJI.js";
|
|
21
|
+
import "../../chunks/chunk-OSMQCYSP.js";
|
|
22
|
+
import "../../chunks/chunk-5OST7NOX.js";
|
|
23
|
+
import "../../chunks/chunk-I3KSESCR.js";
|
|
24
24
|
export {
|
|
25
25
|
CurlError,
|
|
26
26
|
cloudflareWorkerNetworkLimits,
|
|
@@ -1,43 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export type HttpHeaders
|
|
3
|
-
export interface HttpRequest {
|
|
4
|
-
/** Explicit VFS PEM trust for this request; replaces transport-default CAs. */
|
|
5
|
-
readonly ca?: Uint8Array;
|
|
6
|
-
readonly httpVersion?: "1.0" | "1.1";
|
|
7
|
-
/** Read until EOF rather than using Content-Length; host transport must opt in. */
|
|
8
|
-
readonly ignoreContentLength?: true;
|
|
9
|
-
/** Validated HTTP(S) origin with curl request-target spelling; transports must preserve it. */
|
|
10
|
-
readonly url: string;
|
|
11
|
-
readonly method: string;
|
|
12
|
-
readonly headers: HttpHeaders;
|
|
13
|
-
readonly body?: ByteSource;
|
|
14
|
-
/** Consumer body intent, independent of method. Omitted means "read".
|
|
15
|
-
* "omit" permits an empty body; "omit-on-http-error" permits it only for
|
|
16
|
-
* status >= 400. Neither changes the HTTP request or response status/headers. */
|
|
17
|
-
readonly responseBodyMode?: "omit" | "omit-on-http-error" | "read";
|
|
18
|
-
readonly signal: AbortSignal;
|
|
19
|
-
/** Deadline for DNS, TCP and TLS setup only; absent means no separate connection deadline. */
|
|
20
|
-
readonly connectTimeoutMs?: number;
|
|
21
|
-
readonly registerCleanup?: (cleanup: InvocationCleanup) => void;
|
|
22
|
-
readonly denyPrivateNetworks?: true;
|
|
23
|
-
}
|
|
24
|
-
export interface HttpResponse {
|
|
25
|
-
readonly status: number;
|
|
26
|
-
readonly statusText: string;
|
|
27
|
-
readonly headers: HttpHeaders;
|
|
28
|
-
readonly httpVersion?: string;
|
|
29
|
-
readonly body: ByteSource;
|
|
30
|
-
/** True when the host already decoded Content-Encoding; encoded length is then unavailable. */
|
|
31
|
-
readonly contentDecoded?: boolean;
|
|
32
|
-
dispose(): Promise<void>;
|
|
33
|
-
}
|
|
34
|
-
export type HttpTransport = ((request: HttpRequest) => Promise<HttpResponse>) & {
|
|
35
|
-
readonly supportsRequestCa?: true;
|
|
36
|
-
readonly supportedHttpVersions?: readonly ("1.0" | "1.1")[];
|
|
37
|
-
readonly supportsIgnoreContentLength?: true;
|
|
38
|
-
readonly supportsPrivateNetworkDeny?: true;
|
|
39
|
-
readonly supportsConnectTimeout?: true;
|
|
40
|
-
};
|
|
1
|
+
import type { HttpTransport } from "../../../safe-bash-contracts/http.js";
|
|
2
|
+
export type { HttpHeaders, HttpRequest, HttpResponse, HttpTransport } from "../../../safe-bash-contracts/http.js";
|
|
41
3
|
export interface NetworkAuthorization {
|
|
42
4
|
/** Validated HTTP(S) origin with curl request-target spelling; transports must preserve it. */
|
|
43
5
|
readonly url: string;
|
|
@@ -2,14 +2,12 @@ import {
|
|
|
2
2
|
createSafeJsNodeCommand,
|
|
3
3
|
createSafeJsNodeCommands,
|
|
4
4
|
safeJsNodeCommands
|
|
5
|
-
} from "../../chunks/chunk-
|
|
6
|
-
import "../../chunks/chunk-
|
|
7
|
-
import "../../chunks/chunk-
|
|
8
|
-
import "../../chunks/chunk-
|
|
9
|
-
import "../../chunks/chunk-
|
|
10
|
-
import "../../chunks/chunk-
|
|
11
|
-
import "../../chunks/chunk-GJWUEOT6.js";
|
|
12
|
-
import "../../chunks/chunk-Q45QCA4J.js";
|
|
5
|
+
} from "../../chunks/chunk-SBESXWT2.js";
|
|
6
|
+
import "../../chunks/chunk-W47GHRRF.js";
|
|
7
|
+
import "../../chunks/chunk-UZU5BIJI.js";
|
|
8
|
+
import "../../chunks/chunk-OSMQCYSP.js";
|
|
9
|
+
import "../../chunks/chunk-5OST7NOX.js";
|
|
10
|
+
import "../../chunks/chunk-I3KSESCR.js";
|
|
13
11
|
export {
|
|
14
12
|
createSafeJsNodeCommand as createNodeCommand,
|
|
15
13
|
createSafeJsNodeCommands as createNodeCommands,
|
|
@@ -19,9 +19,9 @@ import {
|
|
|
19
19
|
restoreEnvironment,
|
|
20
20
|
selectOpBackendContext,
|
|
21
21
|
selectOpGlobalFlags
|
|
22
|
-
} from "../../chunks/chunk-
|
|
23
|
-
import "../../chunks/chunk-
|
|
24
|
-
import "../../chunks/chunk-
|
|
22
|
+
} from "../../chunks/chunk-ZPGVEUKF.js";
|
|
23
|
+
import "../../chunks/chunk-5OST7NOX.js";
|
|
24
|
+
import "../../chunks/chunk-I3KSESCR.js";
|
|
25
25
|
export {
|
|
26
26
|
captureEnvironment,
|
|
27
27
|
createDocumentHandlers,
|
|
@@ -1,21 +1,5 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __copyProps = (to, from, except, desc) => {
|
|
6
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
-
for (let key of __getOwnPropNames(from))
|
|
8
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
-
}
|
|
11
|
-
return to;
|
|
12
|
-
};
|
|
13
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
14
|
-
|
|
15
1
|
// packages/safe-bash/src/commands/internal.ts
|
|
16
|
-
|
|
17
|
-
__reExport(internal_exports, internal_star);
|
|
18
|
-
import * as internal_star from "../../../safe-bash-io-engine/internal.js";
|
|
2
|
+
import { RESOLVED_EXIT_ONE, RESOLVED_EXIT_ZERO, RETURN_EXIT_ONE, RETURN_EXIT_TWO, RETURN_EXIT_ZERO, UsageError, assertInputRequirements, bufferLimit, builtInDirectContextExecutors, codeOf, collect, concatenate, decoder, define, diagnostic, eachOperand, emptyInput, encoder, escapeBytes, evalSyncCat, evalSyncCp, evalSyncHeadTail, evalSyncLn, evalSyncMkdir, evalSyncMv, evalSyncRm, evalSyncRmdir, evalSyncSleep, evalSyncTee, evalSyncTouch, evalSyncWc, input, integer, isDefaultCommandOptions, lines, options, output, outputRange, pathOf, registerDefaultExecutor, registerDefaultExecutors, replaceArgument, requireOperands, syncCommandEvaluators, value } from "../../../safe-bash-io-engine/internal.js";
|
|
19
3
|
|
|
20
4
|
// packages/safe-bash/src/commands/op/index.ts
|
|
21
5
|
import {
|
|
@@ -23,7 +7,7 @@ import {
|
|
|
23
7
|
createOpCommands as createRawOpCommands,
|
|
24
8
|
evalSyncOp
|
|
25
9
|
} from "../../../safe-bash-command-op/index.js";
|
|
26
|
-
|
|
10
|
+
import {} from "../../../safe-bash-command-op/index.js";
|
|
27
11
|
import {
|
|
28
12
|
captureEnvironment,
|
|
29
13
|
createDocumentHandlers,
|
|
@@ -42,26 +26,26 @@ import {
|
|
|
42
26
|
selectOpBackendContext,
|
|
43
27
|
selectOpGlobalFlags
|
|
44
28
|
} from "../../../safe-bash-command-op/index.js";
|
|
45
|
-
function createOpCommand(
|
|
46
|
-
const def = createRawOpCommand(
|
|
47
|
-
|
|
29
|
+
function createOpCommand(options2 = {}) {
|
|
30
|
+
const def = createRawOpCommand(options2);
|
|
31
|
+
builtInDirectContextExecutors.add(def.execute);
|
|
48
32
|
return def;
|
|
49
33
|
}
|
|
50
|
-
function createOpCommands(
|
|
51
|
-
const defs = createRawOpCommands(
|
|
52
|
-
for (let i = 0; i < defs.length; i++)
|
|
34
|
+
function createOpCommands(options2 = {}) {
|
|
35
|
+
const defs = createRawOpCommands(options2);
|
|
36
|
+
for (let i = 0; i < defs.length; i++) builtInDirectContextExecutors.add(defs[i].execute);
|
|
53
37
|
return defs;
|
|
54
38
|
}
|
|
55
|
-
function opCommands(
|
|
56
|
-
const commands = createOpCommands(
|
|
39
|
+
function opCommands(options2 = {}) {
|
|
40
|
+
const commands = createOpCommands(options2);
|
|
57
41
|
return {
|
|
58
42
|
name: "op-commands",
|
|
59
43
|
setup(host) {
|
|
60
|
-
for (const command of commands) host.commands.register(command, { replace:
|
|
44
|
+
for (const command of commands) host.commands.register(command, { replace: options2.replace ?? false });
|
|
61
45
|
}
|
|
62
46
|
};
|
|
63
47
|
}
|
|
64
|
-
|
|
48
|
+
syncCommandEvaluators.evalSyncOp = evalSyncOp;
|
|
65
49
|
export {
|
|
66
50
|
captureEnvironment,
|
|
67
51
|
createDocumentHandlers,
|
|
@@ -3,8 +3,8 @@ import {
|
|
|
3
3
|
createPrCommands,
|
|
4
4
|
evalSyncPr,
|
|
5
5
|
prCommands
|
|
6
|
-
} from "../../chunks/chunk-
|
|
7
|
-
import "../../chunks/chunk-
|
|
6
|
+
} from "../../chunks/chunk-FM3WBSZT.js";
|
|
7
|
+
import "../../chunks/chunk-I3KSESCR.js";
|
|
8
8
|
export {
|
|
9
9
|
createPrCommand,
|
|
10
10
|
createPrCommands,
|
|
@@ -16,17 +16,17 @@ import {
|
|
|
16
16
|
pythonCommands,
|
|
17
17
|
pythonDocumentPackages,
|
|
18
18
|
pythonHostFailureCode
|
|
19
|
-
} from "../../chunks/chunk-
|
|
19
|
+
} from "../../chunks/chunk-2W4HTMEK.js";
|
|
20
|
+
import "../../chunks/chunk-OYB332PQ.js";
|
|
21
|
+
import "../../chunks/chunk-DYEUZE6Z.js";
|
|
22
|
+
import "../../chunks/chunk-UZU5BIJI.js";
|
|
23
|
+
import "../../chunks/chunk-OSMQCYSP.js";
|
|
20
24
|
import {
|
|
21
25
|
PythonFailure,
|
|
22
26
|
inspectPythonCapabilities
|
|
23
|
-
} from "../../chunks/chunk-
|
|
24
|
-
import "../../chunks/chunk-
|
|
25
|
-
import "../../chunks/chunk-
|
|
26
|
-
import "../../chunks/chunk-T3VDYWKZ.js";
|
|
27
|
-
import "../../chunks/chunk-GJWUEOT6.js";
|
|
28
|
-
import "../../chunks/chunk-LD76P7AG.js";
|
|
29
|
-
import "../../chunks/chunk-Q45QCA4J.js";
|
|
27
|
+
} from "../../chunks/chunk-JLIMK5TD.js";
|
|
28
|
+
import "../../chunks/chunk-5OST7NOX.js";
|
|
29
|
+
import "../../chunks/chunk-I3KSESCR.js";
|
|
30
30
|
export {
|
|
31
31
|
PythonFailure,
|
|
32
32
|
PythonPackageConflictError,
|
|
@@ -8,10 +8,10 @@ import {
|
|
|
8
8
|
pythonRuntimeRelocation,
|
|
9
9
|
pythonStatProjection,
|
|
10
10
|
pythonTreeCleanup
|
|
11
|
-
} from "../../chunks/chunk-
|
|
11
|
+
} from "../../chunks/chunk-JLIMK5TD.js";
|
|
12
12
|
import {
|
|
13
13
|
init_platform
|
|
14
|
-
} from "../../chunks/chunk-
|
|
14
|
+
} from "../../chunks/chunk-I3KSESCR.js";
|
|
15
15
|
|
|
16
16
|
// packages/safe-bash/src/commands/python/worker.ts
|
|
17
17
|
init_platform();
|
|
@@ -2,8 +2,8 @@ import {
|
|
|
2
2
|
createTsortCommand,
|
|
3
3
|
createTsortCommands,
|
|
4
4
|
tsortCommands
|
|
5
|
-
} from "../../chunks/chunk-
|
|
6
|
-
import "../../chunks/chunk-
|
|
5
|
+
} from "../../chunks/chunk-6HLURHVU.js";
|
|
6
|
+
import "../../chunks/chunk-I3KSESCR.js";
|
|
7
7
|
export {
|
|
8
8
|
createTsortCommand,
|
|
9
9
|
createTsortCommands,
|
|
@@ -7,8 +7,8 @@ import {
|
|
|
7
7
|
evalSyncXq,
|
|
8
8
|
xmlCommands,
|
|
9
9
|
xmllintCommands
|
|
10
|
-
} from "../../chunks/chunk-
|
|
11
|
-
import "../../chunks/chunk-
|
|
10
|
+
} from "../../chunks/chunk-3VKFK3NF.js";
|
|
11
|
+
import "../../chunks/chunk-I3KSESCR.js";
|
|
12
12
|
export {
|
|
13
13
|
createXmlCommands,
|
|
14
14
|
createXmllintCommand,
|
|
@@ -4,9 +4,9 @@ import {
|
|
|
4
4
|
evalSyncYqPrep,
|
|
5
5
|
formatSyncYqYamlLines,
|
|
6
6
|
yqCommands
|
|
7
|
-
} from "../../chunks/chunk-
|
|
8
|
-
import "../../chunks/chunk-
|
|
9
|
-
import "../../chunks/chunk-
|
|
7
|
+
} from "../../chunks/chunk-NDIL6T7Y.js";
|
|
8
|
+
import "../../chunks/chunk-5OST7NOX.js";
|
|
9
|
+
import "../../chunks/chunk-I3KSESCR.js";
|
|
10
10
|
export {
|
|
11
11
|
createYqCommand,
|
|
12
12
|
createYqCommands,
|