@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.
Files changed (207) hide show
  1. package/dist/image-ast/index.browser.js +147 -80
  2. package/dist/image-ast/index.js +147 -80
  3. package/dist/mp4-ast/mp4.d.ts +2 -0
  4. package/dist/pdf-ast/cos/parser.d.ts +1 -0
  5. package/dist/pdf-ast/cos/security.d.ts +2 -0
  6. package/dist/pdf-ast/cos/writer.d.ts +1 -0
  7. package/dist/pdf-ast/document.d.ts +3 -0
  8. package/dist/pdf-ast/edit/forms.d.ts +1 -0
  9. package/dist/pdf-ast/index.js +171 -82
  10. package/dist/safe-bash/chunks/{chunk-L5QQLNTO.js → chunk-22PI65AH.js} +2 -2
  11. package/dist/safe-bash/chunks/{chunk-KHJGUF2W.js → chunk-2TAGYMPK.js} +43 -42
  12. package/dist/safe-bash/chunks/{chunk-D4PHJK4T.js → chunk-2W4HTMEK.js} +52 -48
  13. package/dist/safe-bash/chunks/{chunk-FFZXP6ZC.js → chunk-3M7L7XU2.js} +2 -2
  14. package/dist/safe-bash/chunks/{chunk-XNODZRVD.js → chunk-3QAO6UYS.js} +2 -2
  15. package/dist/safe-bash/chunks/{chunk-YPETOVQU.js → chunk-3VKFK3NF.js} +2 -2
  16. package/dist/safe-bash/chunks/chunk-5OST7NOX.js +42 -0
  17. package/dist/safe-bash/chunks/{chunk-KEBSX2AX.js → chunk-6HLURHVU.js} +2 -2
  18. package/dist/safe-bash/chunks/chunk-DYEUZE6Z.js +19 -0
  19. package/dist/safe-bash/chunks/{chunk-T2TGCHKE.js → chunk-FM3WBSZT.js} +2 -2
  20. package/dist/safe-bash/chunks/chunk-GAYRKQM6.js +22 -0
  21. package/dist/safe-bash/chunks/{chunk-Q45QCA4J.js → chunk-I3KSESCR.js} +0 -7
  22. package/dist/safe-bash/chunks/{chunk-OSKDIBQS.js → chunk-JLIMK5TD.js} +1 -1
  23. package/dist/safe-bash/chunks/{chunk-2AYZCT5X.js → chunk-JQ2FAJJT.js} +27 -23
  24. package/dist/safe-bash/chunks/{chunk-QA3NVP43.js → chunk-JRE6Z3T7.js} +2 -2
  25. package/dist/safe-bash/chunks/{chunk-DC5EHLKS.js → chunk-NDIL6T7Y.js} +5 -5
  26. package/dist/safe-bash/chunks/{chunk-747G42FY.js → chunk-OPR4UAIT.js} +2 -2
  27. package/dist/safe-bash/chunks/chunk-OSMQCYSP.js +19 -0
  28. package/dist/safe-bash/chunks/chunk-OYB332PQ.js +17 -0
  29. package/dist/safe-bash/chunks/{chunk-X5ZCECM6.js → chunk-QTIH2AFE.js} +77 -69
  30. package/dist/safe-bash/chunks/{chunk-CTUHLNJM.js → chunk-SBESXWT2.js} +43 -44
  31. package/dist/safe-bash/chunks/{chunk-4FDQJUFW.js → chunk-SDEPGTOF.js} +1 -1
  32. package/dist/safe-bash/chunks/chunk-UZU5BIJI.js +32 -0
  33. package/dist/safe-bash/chunks/{chunk-BI6JV62X.js → chunk-VCCMROTL.js} +7 -10
  34. package/dist/safe-bash/chunks/chunk-W47GHRRF.js +13 -0
  35. package/dist/safe-bash/chunks/{chunk-NPMQWZUZ.js → chunk-WS7KZIUM.js} +2 -2
  36. package/dist/safe-bash/chunks/{chunk-3PZYHMGM.js → chunk-YYAERCWS.js} +7 -7
  37. package/dist/safe-bash/chunks/{chunk-5U7JECDB.js → chunk-ZPGVEUKF.js} +8 -7
  38. package/dist/safe-bash/chunks/{csvkit-K55OYAQC.js → csvkit-USUJG62I.js} +65 -11
  39. package/dist/safe-bash/chunks/{ffmpeg-BEFTQ6DZ.js → ffmpeg-KRGG5DLH.js} +21 -10
  40. package/dist/safe-bash/chunks/{gh-HQWOWLWE.js → gh-UCFDUZCX.js} +16 -8
  41. package/dist/safe-bash/chunks/{git-HO7WDPHZ.js → git-LPAF6KDG.js} +7 -9
  42. package/dist/safe-bash/chunks/{imagemagick-53BMHH6D.js → imagemagick-KGREKK4G.js} +38 -7
  43. package/dist/safe-bash/chunks/{implementation-QUTAAYMT.js → implementation-FXDRYS5A.js} +34 -8
  44. package/dist/safe-bash/chunks/{pdfimages-4OYI6FLG.js → pdfimages-UADCF4G4.js} +12 -8
  45. package/dist/safe-bash/chunks/{pdfinfo-I7U6TQPP.js → pdfinfo-O7UWPF4W.js} +38 -13
  46. package/dist/safe-bash/chunks/{pdftk-SUA6FMHI.js → pdftk-AERXIJTN.js} +13 -8
  47. package/dist/safe-bash/chunks/{pdftoppm-4C5DGEWX.js → pdftoppm-L466JQKI.js} +17 -10
  48. package/dist/safe-bash/chunks/{pdftotext-Y4WI225Y.js → pdftotext-SUSI4WXS.js} +19 -9
  49. package/dist/safe-bash/chunks/{qpdf-IORB4RV5.js → qpdf-YL24KVRH.js} +14 -8
  50. package/dist/safe-bash/chunks/{sips-WHAMJFEU.js → sips-QXEQZERX.js} +14 -7
  51. package/dist/safe-bash/chunks/{soffice-SYEK6WJS.js → soffice-TBITRML3.js} +16 -8
  52. package/dist/safe-bash/chunks/{wkhtmltopdf-ZIICWJLF.js → wkhtmltopdf-NJA2THRC.js} +27 -7
  53. package/dist/safe-bash/command-chunks/chunk-2C5BEBPY.js +1388 -0
  54. package/dist/safe-bash/command-chunks/{chunk-2VTMZTV3.js → chunk-2EXV2ZLV.js} +2 -2
  55. package/dist/safe-bash/command-chunks/{chunk-UJOO6DKY.js → chunk-6EASC5EC.js} +1 -1
  56. package/dist/safe-bash/command-chunks/{chunk-ZF3ZVGQC.js → chunk-7JRITHKW.js} +150 -80
  57. package/dist/safe-bash/{chunks/chunk-LD76P7AG.js → command-chunks/chunk-AKDMCNX4.js} +74 -39
  58. package/dist/safe-bash/command-chunks/{chunk-6F7QJMJ3.js → chunk-CBDVLMJB.js} +1 -1
  59. package/dist/safe-bash/command-chunks/chunk-H4LWTITX.js +169 -0
  60. package/dist/safe-bash/command-chunks/chunk-I2MQNBGR.js +145 -0
  61. package/dist/safe-bash/command-chunks/{chunk-5GRLAARV.js → chunk-IOXI5ZAJ.js} +1 -1
  62. package/dist/safe-bash/command-chunks/{chunk-XNHSCU6I.js → chunk-MDPIOQUD.js} +6 -6
  63. package/dist/safe-bash/command-chunks/chunk-QI4MGIN6.js +6 -0
  64. package/dist/safe-bash/command-chunks/chunk-QTYZAWSB.js +91 -0
  65. package/dist/safe-bash/command-chunks/chunk-SNK7K3XW.js +90 -0
  66. package/dist/safe-bash/command-chunks/chunk-T5OLGM43.js +314 -0
  67. package/dist/safe-bash/command-chunks/chunk-TB7IFMUZ.js +802 -0
  68. package/dist/safe-bash/command-chunks/{chunk-AT6ZSOE6.js → chunk-TPPBPIWL.js} +1 -1
  69. package/dist/safe-bash/command-chunks/chunk-VMK4XVKO.js +82 -0
  70. package/dist/safe-bash/command-chunks/chunk-VNSJKXDU.js +130 -0
  71. package/dist/safe-bash/command-chunks/chunk-YFNTMH6Z.js +6 -0
  72. package/dist/safe-bash/commands/csplit/index.browser.js +2 -2
  73. package/dist/safe-bash/commands/docx/index.browser.js +2 -2
  74. package/dist/safe-bash/commands/factor/index.browser.js +2 -2
  75. package/dist/safe-bash/commands/getopt/index.browser.js +2 -2
  76. package/dist/safe-bash/commands/hexdump/index.browser.js +2 -2
  77. package/dist/safe-bash/commands/iconv/index.browser.js +2 -2
  78. package/dist/safe-bash/commands/line-endings/index.browser.js +2 -2
  79. package/dist/safe-bash/commands/llm/command.d.ts +1 -4
  80. package/dist/safe-bash/commands/llm/command.js +1 -248
  81. package/dist/safe-bash/commands/llm/elevenlabs-stream.d.ts +1 -2
  82. package/dist/safe-bash/commands/llm/elevenlabs-stream.js +1 -117
  83. package/dist/safe-bash/commands/llm/elevenlabs.d.ts +1 -15
  84. package/dist/safe-bash/commands/llm/elevenlabs.js +1 -123
  85. package/dist/safe-bash/commands/llm/index.browser.js +20 -15
  86. package/dist/safe-bash/commands/llm/index.d.ts +1 -6
  87. package/dist/safe-bash/commands/llm/index.js +1 -4
  88. package/dist/safe-bash/commands/llm/mime.d.ts +1 -2
  89. package/dist/safe-bash/commands/llm/mime.js +1 -136
  90. package/dist/safe-bash/commands/llm/openai-http.d.ts +1 -8
  91. package/dist/safe-bash/commands/llm/openai-http.js +1 -143
  92. package/dist/safe-bash/commands/llm/openai-sse.d.ts +1 -3
  93. package/dist/safe-bash/commands/llm/openai-sse.js +1 -78
  94. package/dist/safe-bash/commands/llm/openai.d.ts +1 -14
  95. package/dist/safe-bash/commands/llm/openai.js +1 -288
  96. package/dist/safe-bash/commands/llm/providers/elevenlabs.d.ts +1 -1
  97. package/dist/safe-bash/commands/llm/providers/elevenlabs.js +1 -1
  98. package/dist/safe-bash/commands/llm/providers/index.browser.js +6 -6
  99. package/dist/safe-bash/commands/llm/providers/index.d.ts +1 -3
  100. package/dist/safe-bash/commands/llm/providers/index.js +1 -2
  101. package/dist/safe-bash/commands/llm/providers/openai.d.ts +1 -1
  102. package/dist/safe-bash/commands/llm/providers/openai.js +1 -1
  103. package/dist/safe-bash/commands/llm/providers/shared.d.ts +1 -23
  104. package/dist/safe-bash/commands/llm/providers/shared.js +1 -65
  105. package/dist/safe-bash/commands/llm/service.d.ts +1 -37
  106. package/dist/safe-bash/commands/llm/service.js +1 -151
  107. package/dist/safe-bash/commands/llm/types.d.ts +1 -52
  108. package/dist/safe-bash/commands/llm/types.js +1 -1
  109. package/dist/safe-bash/commands/mdq/index.browser.js +3 -3
  110. package/dist/safe-bash/commands/media/index.browser.js +1 -1
  111. package/dist/safe-bash/commands/network/index.browser.js +9 -9
  112. package/dist/safe-bash/commands/network/types.d.ts +2 -40
  113. package/dist/safe-bash/commands/node/index.browser.js +6 -8
  114. package/dist/safe-bash/commands/op/index.browser.js +3 -3
  115. package/dist/safe-bash/commands/op/index.js +12 -28
  116. package/dist/safe-bash/commands/pr/index.browser.js +2 -2
  117. package/dist/safe-bash/commands/python/index.browser.js +8 -8
  118. package/dist/safe-bash/commands/python/worker.browser.js +2 -2
  119. package/dist/safe-bash/commands/tsort/index.browser.js +2 -2
  120. package/dist/safe-bash/commands/xml/index.browser.js +2 -2
  121. package/dist/safe-bash/commands/yq/index.browser.js +3 -3
  122. package/dist/safe-bash/core.browser.js +9775 -10975
  123. package/dist/safe-bash/core.d.ts +0 -1
  124. package/dist/safe-bash/core.js +0 -1
  125. package/dist/safe-bash/jobs.browser.js +5 -4
  126. package/dist/safe-bash/optional-host.browser.js +61 -88
  127. package/dist/safe-bash/shell/runtime.js +34 -12
  128. package/dist/safe-bash/yq-browser/index.js +1 -1
  129. package/dist/safe-bash-command-ffmpeg/index.js +8130 -8011
  130. package/dist/safe-bash-command-git/git_rust.wasm +0 -0
  131. package/dist/safe-bash-command-git/wasm.generated.js +1 -1
  132. package/dist/safe-bash-command-imagemagick/index.js +2 -2
  133. package/dist/safe-bash-command-llm/LICENSE +21 -0
  134. package/dist/safe-bash-command-llm/command.d.ts +5 -0
  135. package/dist/safe-bash-command-llm/command.js +14 -0
  136. package/dist/safe-bash-command-llm/configuration.d.ts +18 -0
  137. package/dist/safe-bash-command-llm/elevenlabs-stream.d.ts +2 -0
  138. package/dist/safe-bash-command-llm/elevenlabs-stream.js +7 -0
  139. package/dist/safe-bash-command-llm/elevenlabs.d.ts +15 -0
  140. package/dist/safe-bash-command-llm/elevenlabs.js +10 -0
  141. package/dist/safe-bash-command-llm/index.d.ts +10 -0
  142. package/dist/safe-bash-command-llm/index.js +46 -0
  143. package/dist/safe-bash-command-llm/mime.d.ts +2 -0
  144. package/dist/safe-bash-command-llm/mime.js +9 -0
  145. package/dist/safe-bash-command-llm/model-options.d.ts +3 -0
  146. package/dist/safe-bash-command-llm/openai-http.d.ts +8 -0
  147. package/dist/safe-bash-command-llm/openai-http.js +17 -0
  148. package/dist/safe-bash-command-llm/openai-sse.d.ts +3 -0
  149. package/dist/safe-bash-command-llm/openai-sse.js +8 -0
  150. package/dist/safe-bash-command-llm/openai.d.ts +14 -0
  151. package/dist/safe-bash-command-llm/openai.js +12 -0
  152. package/dist/safe-bash-command-llm/providers/elevenlabs.d.ts +1 -0
  153. package/dist/safe-bash-command-llm/providers/elevenlabs.js +11 -0
  154. package/dist/safe-bash-command-llm/providers/index.d.ts +3 -0
  155. package/dist/safe-bash-command-llm/providers/index.js +24 -0
  156. package/dist/safe-bash-command-llm/providers/openai.d.ts +1 -0
  157. package/dist/safe-bash-command-llm/providers/openai.js +13 -0
  158. package/dist/safe-bash-command-llm/providers/shared.d.ts +23 -0
  159. package/dist/safe-bash-command-llm/providers/shared.js +13 -0
  160. package/dist/safe-bash-command-llm/schemas.d.ts +2 -0
  161. package/dist/safe-bash-command-llm/service.d.ts +42 -0
  162. package/dist/safe-bash-command-llm/service.js +9 -0
  163. package/dist/safe-bash-command-llm/templates.d.ts +27 -0
  164. package/dist/safe-bash-command-llm/types.d.ts +87 -0
  165. package/dist/safe-bash-command-llm/types.js +6 -0
  166. package/dist/safe-bash-command-mmdc/command.d.ts +4 -0
  167. package/dist/safe-bash-command-mmdc/index.d.ts +1 -1
  168. package/dist/safe-bash-command-mmdc/index.js +7084 -6687
  169. package/dist/safe-bash-command-mmdc/layout.d.ts +1 -0
  170. package/dist/safe-bash-command-mmdc/parser.d.ts +1 -0
  171. package/dist/safe-bash-command-mmdc/png.d.ts +3 -0
  172. package/dist/safe-bash-command-mmdc/raster.d.ts +1 -0
  173. package/dist/safe-bash-command-pandoc/command.js +3 -3
  174. package/dist/safe-bash-command-pandoc/index.js +3 -3
  175. package/dist/safe-bash-command-pdfimages/index.js +147 -80
  176. package/dist/safe-bash-command-pdfinfo/index.js +147 -80
  177. package/dist/safe-bash-command-pdftk/index.js +147 -80
  178. package/dist/safe-bash-command-pdftoppm/index.js +147 -80
  179. package/dist/safe-bash-command-pdftotext/index.js +147 -80
  180. package/dist/safe-bash-command-qpdf/index.js +174 -101
  181. package/dist/safe-bash-command-sips/index.js +2 -2
  182. package/dist/safe-bash-command-soffice/index.js +1 -1
  183. package/dist/safe-bash-command-ssconvert/index.js +147 -80
  184. package/dist/safe-bash-command-wkhtmltopdf/index.js +147 -80
  185. package/dist/safe-bash-contracts/default-executor.d.ts +5 -0
  186. package/dist/safe-bash-contracts/default-executor.js +37 -0
  187. package/dist/safe-bash-contracts/http.d.ts +41 -0
  188. package/dist/safe-bash-contracts/http.js +6 -0
  189. package/dist/safe-bash-io-engine/commands/search/requirements.js +3 -3
  190. package/dist/safe-bash-io-engine/commands/text-programs/shared.js +3 -3
  191. package/dist/safe-bash-io-engine/gnu-information.d.ts +1 -1
  192. package/dist/safe-bash-io-engine/gnu-information.js +1 -1
  193. package/dist/safe-bash-io-engine/internal.js +2 -2
  194. package/dist/safe-bash-query-engine/index.js +3 -3
  195. package/dist/safe-bash-query-engine/interpreter.js +2 -2
  196. package/dist/safe-bash-query-engine/query-core.js +3 -3
  197. package/package.json +2 -2
  198. package/dist/safe-bash/chunks/chunk-2G2T5MEM.js +0 -14
  199. package/dist/safe-bash/chunks/chunk-2MUJ7RLZ.js +0 -409
  200. package/dist/safe-bash/chunks/chunk-GJWUEOT6.js +0 -14
  201. package/dist/safe-bash/chunks/chunk-H7MMJS26.js +0 -37
  202. package/dist/safe-bash/chunks/chunk-LAPF2XE6.js +0 -14
  203. package/dist/safe-bash/chunks/chunk-S2LSZFZ6.js +0 -758
  204. package/dist/safe-bash/chunks/chunk-T3VDYWKZ.js +0 -21
  205. package/dist/safe-bash/chunks/chunk-VUVKC6HV.js +0 -81
  206. package/dist/safe-bash/chunks/chunk-VYW4Q6KF.js +0 -12
  207. package/dist/safe-bash/command-chunks/{chunk-BJ6DGYJA.js → chunk-KNI4GRXF.js} +3 -3
@@ -1,152 +1,2 @@
1
- import { acceptsMimeType } from "./mime.js";
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
- import type { LlmService } from "./service.js";
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-3PZYHMGM.js";
11
- import "../../chunks/chunk-GJWUEOT6.js";
12
- import "../../chunks/chunk-Q45QCA4J.js";
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,
@@ -3,7 +3,7 @@ import {
3
3
  __commonJS,
4
4
  __toESM,
5
5
  init_platform
6
- } from "../../chunks/chunk-Q45QCA4J.js";
6
+ } from "../../chunks/chunk-I3KSESCR.js";
7
7
 
8
8
  // node_modules/xmlchars/xml/1.0/ed5.js
9
9
  var require_ed5 = __commonJS({
@@ -12,15 +12,15 @@ import {
12
12
  evalSyncCurl,
13
13
  evalSyncWget,
14
14
  networkCommands
15
- } from "../../chunks/chunk-X5ZCECM6.js";
16
- import "../../chunks/chunk-BI6JV62X.js";
17
- import "../../chunks/chunk-2G2T5MEM.js";
18
- import "../../chunks/chunk-VUVKC6HV.js";
19
- import "../../chunks/chunk-LAPF2XE6.js";
20
- import "../../chunks/chunk-H7MMJS26.js";
21
- import "../../chunks/chunk-T3VDYWKZ.js";
22
- import "../../chunks/chunk-GJWUEOT6.js";
23
- import "../../chunks/chunk-Q45QCA4J.js";
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 { ByteSource, InvocationCleanup } from "../../contracts/index.js";
2
- export type HttpHeaders = readonly (readonly [string, string])[];
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-CTUHLNJM.js";
6
- import "../../chunks/chunk-2G2T5MEM.js";
7
- import "../../chunks/chunk-VUVKC6HV.js";
8
- import "../../chunks/chunk-LAPF2XE6.js";
9
- import "../../chunks/chunk-H7MMJS26.js";
10
- import "../../chunks/chunk-T3VDYWKZ.js";
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-5U7JECDB.js";
23
- import "../../chunks/chunk-GJWUEOT6.js";
24
- import "../../chunks/chunk-Q45QCA4J.js";
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
- var internal_exports = {};
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
- export * from "../../../safe-bash-command-op/index.js";
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(options = {}) {
46
- const def = createRawOpCommand(options);
47
- internal_exports.builtInDirectContextExecutors.add(def.execute);
29
+ function createOpCommand(options2 = {}) {
30
+ const def = createRawOpCommand(options2);
31
+ builtInDirectContextExecutors.add(def.execute);
48
32
  return def;
49
33
  }
50
- function createOpCommands(options = {}) {
51
- const defs = createRawOpCommands(options);
52
- for (let i = 0; i < defs.length; i++) internal_exports.builtInDirectContextExecutors.add(defs[i].execute);
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(options = {}) {
56
- const commands = createOpCommands(options);
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: options.replace ?? false });
44
+ for (const command of commands) host.commands.register(command, { replace: options2.replace ?? false });
61
45
  }
62
46
  };
63
47
  }
64
- internal_exports.syncCommandEvaluators.evalSyncOp = evalSyncOp;
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-T2TGCHKE.js";
7
- import "../../chunks/chunk-Q45QCA4J.js";
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-D4PHJK4T.js";
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-OSKDIBQS.js";
24
- import "../../chunks/chunk-LAPF2XE6.js";
25
- import "../../chunks/chunk-H7MMJS26.js";
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-OSKDIBQS.js";
11
+ } from "../../chunks/chunk-JLIMK5TD.js";
12
12
  import {
13
13
  init_platform
14
- } from "../../chunks/chunk-Q45QCA4J.js";
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-KEBSX2AX.js";
6
- import "../../chunks/chunk-Q45QCA4J.js";
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-YPETOVQU.js";
11
- import "../../chunks/chunk-Q45QCA4J.js";
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-DC5EHLKS.js";
8
- import "../../chunks/chunk-GJWUEOT6.js";
9
- import "../../chunks/chunk-Q45QCA4J.js";
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,