Lines 2713-2772javascript
2713 if (text.length <= maxChars) {
2719 const markerReserve = omissionMarker(text.length).length;
2720 const usable = Math.max(0, maxChars - markerReserve);
2721 const headChars = Math.floor(usable * 0.7);
2722 const tailChars = usable - headChars;
2723 const head = text.slice(0, headChars);
2724 const tail = tailChars > 0 ? text.slice(text.length - tailChars) : "";
2725 const omitted = text.length - head.length - tail.length;
2727 text: `${head}${omissionMarker(omitted)}${tail}`,
2731var init_output_utils = () => {};
2733// packages/ai/src/bash/runtime.ts
2734import { exec } from "child_process";
2735import { promisify } from "util";
HighRemote Agent Bridge
Source exposes local file and command tools to a remote model endpoint.
server.jsView on unpkg · L2733 2736function isRecord5(value) {
2737 return typeof value === "object" && value !== null;
2739function toRecord(value) {
2740 return isRecord5(value) ? value : {};
2742function getStringProperty(record, key) {
2743 const value = record[key];
2744 return typeof value === "string" ? value : undefined;
2746function getNumericExitCode(record) {
2747 const value = record.code;
2748 return typeof value === "number" ? value : 1;
2750async function executeBash(input, workspaceContext = getDefaultWorkspaceContext()) {
2751 const parsedInput = bashInputSchema.parse(input);
2753 const result = await execAsync(parsedInput.command, {
2754 cwd: workspaceContext.root,
2755 timeout: parsedInput.timeoutMs,
2756 maxBuffer: 10 * 1024 * 1024,
2759 const stdoutTruncated = truncateText(result.stdout, parsedInput.maxOutputChars);
2760 const stderrTruncated = truncateText(result.stderr, Math.max(2000, Math.floor(parsedInput.maxOutputChars / 4)));
2761 return bashOutputSchema.parse({
2762 command: parsedInput.command,
2763 cwd: workspaceContext.root,
2764 stdout: stdoutTruncated.text,
2765 stderr: stderrTruncated.text,
2767 truncated: stdoutTruncated.truncated || stderrTruncated.truncated
2770 const errorRecord = toRecord(error);
2771 const stdout = getStringProperty(errorRecord, "stdout") ?? "";
2772 const stderr = getStringProperty(errorRecord, "stderr") ?? getStringProperty(errorRecord, "message") ?? "Command failed.";