@poe-platform/safe-bash 0.1.793 → 0.1.795
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-BENDQWMV.js → chunk-6IBTC4YL.js} +16 -2
- package/dist/safe-bash/chunks/{chunk-HEENNMEW.js → chunk-ZXKVOJNL.js} +18 -22
- package/dist/safe-bash/command-chunks/{chunk-JCORWQ2I.js → chunk-7FKUC34S.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-ZJB7XJXD.js → chunk-XAFSZDY2.js} +1 -1
- package/dist/safe-bash/commands/python/index.browser.js +1 -1
- package/dist/safe-bash/commands/python/llm-capability.js +11 -2
- package/dist/safe-bash/commands/python/llm-module.js +6 -0
- package/dist/safe-bash/contracts/escaping.d.ts +2 -0
- package/dist/safe-bash/contracts/escaping.js +2 -0
- package/dist/safe-bash/full-core.browser.js +2 -2
- package/dist/safe-bash/opt-in/optional/commands/shuf/args.js +270 -168
- package/dist/safe-bash/opt-in/optional/commands/shuf/filesystem-output.js +19 -1
- package/dist/safe-bash/opt-in/optional/commands/shuf/input.js +121 -5
- package/dist/safe-bash/opt-in/optional/commands/shuf/random.d.ts +3 -0
- package/dist/safe-bash/opt-in/optional/commands/shuf/random.js +31 -23
- package/dist/safe-bash/opt-in/optional/commands/shuf/shuf.js +39 -37
- package/dist/safe-bash/shell/runtime.d.ts +1 -1
- package/dist/safe-bash/shell/runtime.js +14 -17
- package/dist/safe-bash/shell-entry.browser.js +1 -1
- package/dist/safe-bash-command-shuf/args.d.ts +6 -4
- package/dist/safe-bash-command-shuf/args.js +270 -168
- package/dist/safe-bash-command-shuf/filesystem-output.js +19 -1
- package/dist/safe-bash-command-shuf/input.d.ts +19 -1
- package/dist/safe-bash-command-shuf/input.js +121 -5
- package/dist/safe-bash-command-shuf/random.d.ts +3 -0
- package/dist/safe-bash-command-shuf/random.js +31 -23
- package/dist/safe-bash-command-shuf/shuf.js +39 -37
- package/dist/safe-bash-command-sqlite3/btree.d.ts +1 -1
- package/dist/safe-bash-command-sqlite3/engine.d.ts +1 -1
- package/dist/safe-bash-command-sqlite3/index.js +61 -63
- package/dist/safe-bash-io-engine/commands/search/requirements.js +2 -2
- package/dist/safe-bash-io-engine/commands/text-programs/shared.js +2 -2
- package/dist/safe-bash-io-engine/internal.js +1 -1
- package/package.json +3 -3
|
@@ -1021,7 +1021,7 @@ function createPythonShellCapability(context, options = {}) {
|
|
|
1021
1021
|
|
|
1022
1022
|
// packages/safe-bash/src/commands/python/llm-capability.ts
|
|
1023
1023
|
init_platform();
|
|
1024
|
-
import { getLlmModelAliases, createLlmConfiguration, createLlmTemplateStore, evaluateLlmTemplate, findExtractedRange, llmTemplateUsesInput, validateLlmTemplateParameters } from "../../safe-bash-command-llm/index.js";
|
|
1024
|
+
import { selectLlmModelByQuery, getLlmModelAliases, createLlmConfiguration, createLlmTemplateStore, evaluateLlmTemplate, findExtractedRange, llmTemplateUsesInput, validateLlmTemplateParameters } from "../../safe-bash-command-llm/index.js";
|
|
1025
1025
|
|
|
1026
1026
|
// packages/safe-bash/src/commands/llm/mime.ts
|
|
1027
1027
|
init_platform();
|
|
@@ -1126,7 +1126,7 @@ function createPythonLlmCapability(context, service, options = {}) {
|
|
|
1126
1126
|
const bufferedLimit = options.maxBufferedResponseBytes ?? Infinity;
|
|
1127
1127
|
const eventLimit = options.maxBufferedEvents ?? bufferedLimit;
|
|
1128
1128
|
const metadataLimit = options.maxMetadataBytes ?? bufferedLimit;
|
|
1129
|
-
const maxRemoteBytes = options.maxRemoteTemplateBytes ?? context.inputBudget?.maxBytes ?? 1048576;
|
|
1129
|
+
const maxRemoteBytes = options.maxRemoteTemplateBytes ?? (context.inputBudget?.maxBytes === Infinity ? void 0 : context.inputBudget?.maxBytes) ?? 1048576;
|
|
1130
1130
|
if (!Number.isSafeInteger(maxRemoteBytes) || maxRemoteBytes < 1) throw new RangeError("Invalid Python LLM remote template limit");
|
|
1131
1131
|
const templateLoaderOptions = { maxRemoteBytes, ...options.templateLoaders ? { loaders: options.templateLoaders } : {} };
|
|
1132
1132
|
for (const limit of [bufferedLimit, eventLimit, metadataLimit]) {
|
|
@@ -1329,6 +1329,14 @@ ${input}` : evaluated.prompt : input,
|
|
|
1329
1329
|
signal.throwIfAborted();
|
|
1330
1330
|
const operation = record(value);
|
|
1331
1331
|
const payload = record(operation.payload ?? {});
|
|
1332
|
+
if (operation.operation === "select_model") {
|
|
1333
|
+
const queries = payload.queries;
|
|
1334
|
+
if (!Array.isArray(queries) || !queries.length || queries.some((query) => typeof query !== "string")) throw new TypeError("Model queries must be a nonempty array of strings");
|
|
1335
|
+
const configuration = createLlmConfiguration(configurationContext(context, payload, signal));
|
|
1336
|
+
const selected = await selectLlmModelByQuery(service.models, queries, await configuration.aliases(), signal);
|
|
1337
|
+
jsonBytes(selected.model.id, bufferedLimit);
|
|
1338
|
+
return selected.model.id;
|
|
1339
|
+
}
|
|
1332
1340
|
if (operation.operation === "models") {
|
|
1333
1341
|
const configuration = createLlmConfiguration(configurationContext(context, payload, signal));
|
|
1334
1342
|
const aliases = await configuration.aliases();
|
|
@@ -1927,6 +1935,12 @@ class Client:
|
|
|
1927
1935
|
aliases=copy.deepcopy(value.get("aliases", {})),
|
|
1928
1936
|
model_options=copy.deepcopy(value.get("model_options", {})))
|
|
1929
1937
|
|
|
1938
|
+
async def select_model(self, *queries: str) -> str:
|
|
1939
|
+
if not queries or not all(isinstance(query, str) for query in queries):
|
|
1940
|
+
raise TypeError("Model queries must be one or more strings")
|
|
1941
|
+
payload = {**_configuration_context(), "queries": list(queries)}
|
|
1942
|
+
return await self._run(lambda: self._bridge.call("select_model", payload), self._timeout)
|
|
1943
|
+
|
|
1930
1944
|
async def models(self):
|
|
1931
1945
|
values = await self._run(lambda: self._bridge.call("models", _configuration_context()), self._timeout)
|
|
1932
1946
|
return tuple(Model(id=value["id"], aliases=tuple(value.get("aliases", ())),
|
|
@@ -22496,7 +22496,7 @@ var Runtime = class _Runtime {
|
|
|
22496
22496
|
executeSyncPipelineBody(pipeline, command, state, io, ignored) {
|
|
22497
22497
|
const scope = io[invocationScope];
|
|
22498
22498
|
if (scope.hasFailures || this.budget.limits.maxExpansionFields !== Infinity || this.budget.limits.maxExpansionBytes !== Infinity || this.budget.limits.maxParseUnits !== Infinity) return void 0;
|
|
22499
|
-
if (this.budget._hasExternalSignal && (command.kind === "for" || command.kind === "arithmetic-for")) return void 0;
|
|
22499
|
+
if (this.budget._hasExternalSignal && (command.kind === "for" || command.kind === "arithmetic-for" || command.kind === "while" || command.kind === "until")) return void 0;
|
|
22500
22500
|
const monitor = stateMonitor(state) ?? stateMonitor(trackState(state, this.budget, scope));
|
|
22501
22501
|
if (!monitor) return void 0;
|
|
22502
22502
|
const rawState = monitor.raw;
|
|
@@ -26819,6 +26819,7 @@ var Runtime = class _Runtime {
|
|
|
26819
26819
|
return 0;
|
|
26820
26820
|
}
|
|
26821
26821
|
trySyncLoop(command, pipeline, rawState, monitor, store, existing, elem0, canMutatePipeStatus, io, diagnosticLine, syncReadInputText) {
|
|
26822
|
+
if (this.budget._hasExternalSignal) return void 0;
|
|
26822
26823
|
if (!syncSinks.get(io.stderr)) return void 0;
|
|
26823
26824
|
if (store && !existing) {
|
|
26824
26825
|
if (this.budget.limits.maxExpansionFields !== Infinity || this.budget.limits.maxExpansionBytes !== Infinity || monitor.internalOwner().ledger.checkpoint(this.signal, 0) || publishPipelineStatus(rawState, singleStatusZero, this.signal, io[invocationScope])) {
|
|
@@ -35321,7 +35322,7 @@ ${prefix} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
|
|
|
35321
35322
|
}
|
|
35322
35323
|
this.requireParameter(value === void 0 ? void 0 : shellValueText(value), part.name, state, io, part.line);
|
|
35323
35324
|
if (part.length) return this.valueLength(value ?? "", state, io);
|
|
35324
|
-
if (part.substring) return this.substring(part, value
|
|
35325
|
+
if (part.substring) return this.substring(part, value, state, io);
|
|
35325
35326
|
if (part.transform) return part.transform === "a" || part.transform === "A" || part.transform === "K" || part.transform === "k" ? this.variableMetaTransform(part, state, io) : value === void 0 ? "" : this.transformValue(value, part.transform, state, io);
|
|
35326
35327
|
if (part.operator) return this.parameterPattern(part, value ?? "", state, io, hereString);
|
|
35327
35328
|
return value ?? "";
|
|
@@ -35737,7 +35738,7 @@ ${prefix} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
|
|
|
35737
35738
|
}
|
|
35738
35739
|
if (part.substring) {
|
|
35739
35740
|
this.requireParameter(value, part.name, state, io, part.line);
|
|
35740
|
-
return this.substring(part,
|
|
35741
|
+
return this.substring(part, retained, state, io);
|
|
35741
35742
|
}
|
|
35742
35743
|
if (part.operator) {
|
|
35743
35744
|
if (["#", "##", "%", "%%", "^", "^^", ",", ",,"].includes(part.operator) || part.operator.startsWith("/")) {
|
|
@@ -35824,14 +35825,14 @@ ${prefix} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
|
|
|
35824
35825
|
let retained;
|
|
35825
35826
|
for (const entry of word.parts) {
|
|
35826
35827
|
this.signal.throwIfAborted();
|
|
35827
|
-
const
|
|
35828
|
-
bytes2 += shellValueByteLength(
|
|
35828
|
+
const text3 = entry.kind === "text" ? entry.value : await this.part(entry, state, operandIO);
|
|
35829
|
+
bytes2 += shellValueByteLength(text3);
|
|
35829
35830
|
if (bytes2 > limit) this.budget.fail("maxExpansionBytes");
|
|
35830
|
-
owner?.reserve({ metadata: 32, payload: bytes2, work:
|
|
35831
|
-
const pending = stringCheckpoint(work,
|
|
35831
|
+
owner?.reserve({ metadata: 32, payload: bytes2, work: text3.length + 4 });
|
|
35832
|
+
const pending = stringCheckpoint(work, text3.length + 1);
|
|
35832
35833
|
if (pending) await pending;
|
|
35833
|
-
const next = scratch.reserve((source.length +
|
|
35834
|
-
source +=
|
|
35834
|
+
const next = scratch.reserve((source.length + text3.length) * 2, 0);
|
|
35835
|
+
source += text3;
|
|
35835
35836
|
retained?.release();
|
|
35836
35837
|
retained = next;
|
|
35837
35838
|
}
|
|
@@ -35848,10 +35849,10 @@ ${prefix} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
|
|
|
35848
35849
|
const offsetExpression = await arithmetic(expression.offset);
|
|
35849
35850
|
let bytes;
|
|
35850
35851
|
if (byteLocale(state.variables)) {
|
|
35851
|
-
|
|
35852
|
-
bytes = fastSharedTextEncoder.encode(value);
|
|
35852
|
+
bytes = shellValueBytes(value, scratch);
|
|
35853
35853
|
}
|
|
35854
|
-
const
|
|
35854
|
+
const text2 = shellValueText(value);
|
|
35855
|
+
const size = BigInt(bytes?.byteLength ?? (await scanString(text2, work)).count);
|
|
35855
35856
|
const offset = offsetExpression.value < 0n ? size + offsetExpression.value : offsetExpression.value;
|
|
35856
35857
|
if (offset < 0n || offset > size) return "";
|
|
35857
35858
|
let end = size;
|
|
@@ -35863,17 +35864,12 @@ ${prefix} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
|
|
|
35863
35864
|
}
|
|
35864
35865
|
this.signal.throwIfAborted();
|
|
35865
35866
|
if (!bytes) {
|
|
35866
|
-
const start = (await scanString(
|
|
35867
|
-
const finish = (await scanString(
|
|
35867
|
+
const start = (await scanString(text2, work, 0, text2.length, Number(offset))).end;
|
|
35868
|
+
const finish = (await scanString(text2, work, start, text2.length, Number(end - offset))).end;
|
|
35868
35869
|
if (finish > start) scratch.reserve((finish - start) * 2, 0);
|
|
35869
|
-
return
|
|
35870
|
-
}
|
|
35871
|
-
scratch.reserve(Number(end - offset) * 2, 0);
|
|
35872
|
-
try {
|
|
35873
|
-
return new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(bytes.subarray(Number(offset), Number(end)));
|
|
35874
|
-
} catch {
|
|
35875
|
-
throw new ExpansionFailure("substring expansion splits a UTF-8 character in a byte locale", line);
|
|
35870
|
+
return text2.slice(start, finish);
|
|
35876
35871
|
}
|
|
35872
|
+
return shellValueFromBytes(bytes.subarray(Number(offset), Number(end)), io[valueScope]);
|
|
35877
35873
|
} finally {
|
|
35878
35874
|
scratch.close();
|
|
35879
35875
|
}
|
|
@@ -35961,7 +35957,7 @@ ${prefix} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
|
|
|
35961
35957
|
const replacementIO = part.replacement ? this.parameterOperandIO(part.replacement, state, io) : io;
|
|
35962
35958
|
for (const [index, entry] of (part.replacement?.parts ?? []).entries()) {
|
|
35963
35959
|
let value2 = entry.kind === "text" ? entry.value : await this.part(entry, state, replacementIO, hereString);
|
|
35964
|
-
if (index === 0 && entry.kind === "text" && !
|
|
35960
|
+
if (index === 0 && entry.kind === "text" && !entry.quoted && /^~(?:\/|$)/u.test(value2)) {
|
|
35965
35961
|
const home = state.variables.HOME ?? "~";
|
|
35966
35962
|
scratch.reserve((home.length + value2.length - 1) * 2, 0);
|
|
35967
35963
|
value2 = home + value2.slice(1);
|
|
@@ -59,7 +59,7 @@ async function handleDefineError(context, error, failureCode, usageFailureCode)
|
|
|
59
59
|
return { exitCode: error instanceof UsageError ? usageFailureCode : failureCode };
|
|
60
60
|
}
|
|
61
61
|
var encoder = new TextEncoder();
|
|
62
|
-
var decoder = new TextDecoder();
|
|
62
|
+
var decoder = new TextDecoder("utf-8", { ignoreBOM: true });
|
|
63
63
|
var bufferLimit = Infinity;
|
|
64
64
|
var specificationsCache = /* @__PURE__ */ new Map();
|
|
65
65
|
function options(args, short, long = {}, stopAtOperand = false, onOperand, onValue, onOption) {
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
pythonCommands,
|
|
17
17
|
pythonDocumentPackages,
|
|
18
18
|
pythonHostFailureCode
|
|
19
|
-
} from "../../chunks/chunk-
|
|
19
|
+
} from "../../chunks/chunk-6IBTC4YL.js";
|
|
20
20
|
import "../../chunks/chunk-KCVSVD65.js";
|
|
21
21
|
import "../../chunks/chunk-KMH2DF3I.js";
|
|
22
22
|
import "../../chunks/chunk-IUTD5FH5.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getLlmModelAliases, createLlmConfiguration, createLlmTemplateStore, evaluateLlmTemplate, findExtractedRange, llmTemplateUsesInput, validateLlmTemplateParameters } from "../../../safe-bash-command-llm/index.js";
|
|
1
|
+
import { selectLlmModelByQuery, getLlmModelAliases, createLlmConfiguration, createLlmTemplateStore, evaluateLlmTemplate, findExtractedRange, llmTemplateUsesInput, validateLlmTemplateParameters } from "../../../safe-bash-command-llm/index.js";
|
|
2
2
|
import { sniffMimeType } from '../llm/mime.js';
|
|
3
3
|
import { pathOf } from '../internal.js';
|
|
4
4
|
function record(value) {
|
|
@@ -125,7 +125,7 @@ export function createPythonLlmCapability(context, service, options = {}) {
|
|
|
125
125
|
const bufferedLimit = options.maxBufferedResponseBytes ?? Infinity;
|
|
126
126
|
const eventLimit = options.maxBufferedEvents ?? bufferedLimit;
|
|
127
127
|
const metadataLimit = options.maxMetadataBytes ?? bufferedLimit;
|
|
128
|
-
const maxRemoteBytes = options.maxRemoteTemplateBytes ?? context.inputBudget?.maxBytes ?? 1_048_576;
|
|
128
|
+
const maxRemoteBytes = options.maxRemoteTemplateBytes ?? (context.inputBudget?.maxBytes === Infinity ? undefined : context.inputBudget?.maxBytes) ?? 1_048_576;
|
|
129
129
|
if (!Number.isSafeInteger(maxRemoteBytes) || maxRemoteBytes < 1)
|
|
130
130
|
throw new RangeError('Invalid Python LLM remote template limit');
|
|
131
131
|
const templateLoaderOptions = { maxRemoteBytes, ...(options.templateLoaders ? { loaders: options.templateLoaders } : {}) };
|
|
@@ -343,6 +343,15 @@ export function createPythonLlmCapability(context, service, options = {}) {
|
|
|
343
343
|
signal.throwIfAborted();
|
|
344
344
|
const operation = record(value);
|
|
345
345
|
const payload = record(operation.payload ?? {});
|
|
346
|
+
if (operation.operation === 'select_model') {
|
|
347
|
+
const queries = payload.queries;
|
|
348
|
+
if (!Array.isArray(queries) || !queries.length || queries.some(query => typeof query !== 'string'))
|
|
349
|
+
throw new TypeError('Model queries must be a nonempty array of strings');
|
|
350
|
+
const configuration = createLlmConfiguration(configurationContext(context, payload, signal));
|
|
351
|
+
const selected = await selectLlmModelByQuery(service.models, queries, await configuration.aliases(), signal);
|
|
352
|
+
jsonBytes(selected.model.id, bufferedLimit);
|
|
353
|
+
return selected.model.id;
|
|
354
|
+
}
|
|
346
355
|
if (operation.operation === 'models') {
|
|
347
356
|
const configuration = createLlmConfiguration(configurationContext(context, payload, signal));
|
|
348
357
|
const aliases = await configuration.aliases();
|
|
@@ -386,6 +386,12 @@ class Client:
|
|
|
386
386
|
aliases=copy.deepcopy(value.get("aliases", {})),
|
|
387
387
|
model_options=copy.deepcopy(value.get("model_options", {})))
|
|
388
388
|
|
|
389
|
+
async def select_model(self, *queries: str) -> str:
|
|
390
|
+
if not queries or not all(isinstance(query, str) for query in queries):
|
|
391
|
+
raise TypeError("Model queries must be one or more strings")
|
|
392
|
+
payload = {**_configuration_context(), "queries": list(queries)}
|
|
393
|
+
return await self._run(lambda: self._bridge.call("select_model", payload), self._timeout)
|
|
394
|
+
|
|
389
395
|
async def models(self):
|
|
390
396
|
values = await self._run(lambda: self._bridge.call("models", _configuration_context()), self._timeout)
|
|
391
397
|
return tuple(Model(id=value["id"], aliases=tuple(value.get("aliases", ())),
|
|
@@ -57,7 +57,7 @@ import {
|
|
|
57
57
|
parseShell,
|
|
58
58
|
searchCommands,
|
|
59
59
|
unrtfCommands
|
|
60
|
-
} from "./chunks/chunk-
|
|
60
|
+
} from "./chunks/chunk-ZXKVOJNL.js";
|
|
61
61
|
import {
|
|
62
62
|
createYqCommand,
|
|
63
63
|
createYqCommands,
|
|
@@ -347,7 +347,7 @@ import {
|
|
|
347
347
|
pythonCommands,
|
|
348
348
|
pythonDocumentPackages,
|
|
349
349
|
pythonHostFailureCode
|
|
350
|
-
} from "./chunks/chunk-
|
|
350
|
+
} from "./chunks/chunk-6IBTC4YL.js";
|
|
351
351
|
import "./chunks/chunk-KCVSVD65.js";
|
|
352
352
|
import "./chunks/chunk-KMH2DF3I.js";
|
|
353
353
|
import "./chunks/chunk-IUTD5FH5.js";
|