@@ -82115,6 +82115,19 @@ function callFromGptObject(parsed) {
8211582115 if (!isPlainObject(params)) return null;
8211682116 return { name: name.trim(), args: normalizeGptArgs(params) };
8211782117}
82118+ function callFromBashCmdObject(parsed) {
82119+ if (!isPlainObject(parsed) || !Array.isArray(parsed.cmd)) return null;
82120+ const [bin, flag, command, ...rest] = parsed.cmd;
82121+ if (rest.length > 0 || typeof bin !== "string" || typeof flag !== "string" || typeof command !== "string") {
82122+ return null;
82123+ }
82124+ if (bin.split("/").pop() !== "bash" || flag !== "-lc" || command.trim() === "") return null;
82125+ const args = { command };
82126+ if (typeof parsed.timeout === "number" && Number.isFinite(parsed.timeout)) {
82127+ args.timeout = parsed.timeout;
82128+ }
82129+ return { name: "terminal", args };
82130+ }
8211882131function findTrailingJsonObject(content) {
8211982132 let end = content.length;
8212082133 while (end > 0 && /\s/.test(content[end - 1])) end--;
@@ -82167,11 +82180,12 @@ function extractGptCalls(content) {
8216782180 }
8216882181 const trailing = findTrailingJsonObject(content);
8216982182 if (trailing) {
82170- const built = callFromGptObject(trailing.parsed);
82183+ const built = callFromGptObject(trailing.parsed) ?? callFromBashCmdObject(trailing.parsed) ;
8217182184 if (built) {
8217282185 const hasProseBefore = content.slice(0, trailing.start).trim() !== "";
8217382186 const typeIsFunction = trailing.parsed.type === "function";
82174- if (!hasProseBefore || typeIsFunction) {
82187+ const isBashCmd = built.name === "terminal" && callFromBashCmdObject(trailing.parsed) !== null;
82188+ if (!hasProseBefore || typeIsFunction || isBashCmd) {
8217582189 return {
8217682190 calls: [makeCall(built.name, built.args)],
8217782191 matches: [{ start: hasProseBefore ? trailing.start : 0, end: content.length }]
@@ -216355,23 +216369,14 @@ function sanitizeErrorResponse(errorBody) {
216355216369 code: typeof body.code === "string" ? body.code : void 0
216356216370 };
216357216371}
216358- function resolveDefaultTimeout() {
216359- const envVal = typeof process !== "undefined" && process.env ? process.env.BLOCKRUN_CHAT_TIMEOUT : void 0;
216360- if (envVal !== void 0) {
216361- const seconds = Number(envVal);
216362- if (Number.isFinite(seconds) && seconds > 0) {
216363- return seconds * 1e3;
216364- }
216365- }
216366- return 6e5;
216367- }
216368216372function sleep2(ms) {
216369216373 return new Promise((r2) => setTimeout(r2, ms));
216370216374}
216371- var BlockrunError, PaymentError, APIError, BASE_CHAIN_ID2, USDC_BASE2, USDC_DOMAIN, TRANSFER_TYPES, LOCALHOST_DOMAINS, BLOCKRUN_DIR2, COST_LOG_FILE, DEFAULT_TIMEOUT, SDK_VERSION, USER_AGENT2, PHONE_PRICES, DEFAULT_API_URL13, DEFAULT_TIMEOUT13 , DEFAULT_POLL_INTERVAL_MS, DEFAULT_POLL_BUDGET_MS, MAX_SIGNED_AUTH_SECONDS, BlockrunClient, WALLET_DIR2, WALLET_FILE3, WALLET_DIR22, SOLANA_WALLET_FILE, SDK_VERSION2, USER_AGENT22, CACHE_DIR, DATA_DIR, COST_LOG_FILE2, DEFAULT_TTL;
216375+ var BlockrunError, PaymentError, APIError, BASE_CHAIN_ID2, USDC_BASE2, USDC_DOMAIN, TRANSFER_TYPES, LOCALHOST_DOMAINS, BLOCKRUN_DIR2, COST_LOG_FILE, SDK_VERSION, USER_AGENT2, PHONE_PRICES, DEFAULT_API_URL14, DEFAULT_TIMEOUT14 , DEFAULT_POLL_INTERVAL_MS, DEFAULT_POLL_BUDGET_MS, MAX_SIGNED_AUTH_SECONDS, BlockrunClient, WALLET_DIR2, WALLET_FILE3, WALLET_DIR22, SOLANA_WALLET_FILE, SDK_VERSION2, USER_AGENT22, CACHE_DIR, DATA_DIR, COST_LOG_FILE2, DEFAULT_TTL;
216372216376var init_dist6 = __esm({
216373216377 "node_modules/@blockrun/llm/dist/index.js"() {
216374216378 "use strict";
216379+ init_index();
216375216380 init_accounts();
216376216381 init_accounts();
216377216382 BlockrunError = class extends Error {
@@ -216417,7 +216422,6 @@ var init_dist6 = __esm({
216417216422 LOCALHOST_DOMAINS = ["localhost", "127.0.0.1"];
216418216423 BLOCKRUN_DIR2 = path2.join(os2.homedir(), ".blockrun");
216419216424 COST_LOG_FILE = path2.join(BLOCKRUN_DIR2, "cost_log.jsonl");
216420- DEFAULT_TIMEOUT = resolveDefaultTimeout();
216421216425 SDK_VERSION = "1.5.0";
216422216426 USER_AGENT2 = `blockrun-ts/${SDK_VERSION}`;
216423216427 PHONE_PRICES = Object.freeze({
@@ -216428,8 +216432,8 @@ var init_dist6 = __esm({
216428216432 "numbers/list": 1e-3,
216429216433 "numbers/release": 0
216430216434 });
216431- DEFAULT_API_URL13 = "https://blockrun.ai/api";
216432- DEFAULT_TIMEOUT13 = 6e4;
216435+ DEFAULT_API_URL14 = "https://blockrun.ai/api";
216436+ DEFAULT_TIMEOUT14 = 6e4;
216433216437 DEFAULT_POLL_INTERVAL_MS = 5e3;
216434216438 DEFAULT_POLL_BUDGET_MS = 3e5;
216435216439 MAX_SIGNED_AUTH_SECONDS = 600;
@@ -216451,10 +216455,10 @@ var init_dist6 = __esm({
216451216455 validatePrivateKey(privateKey);
216452216456 this.privateKey = privateKey;
216453216457 this.account = privateKeyToAccount(privateKey);
216454- const apiUrl = options.apiUrl || DEFAULT_API_URL13 ;
216458+ const apiUrl = options.apiUrl || DEFAULT_API_URL14 ;
216455216459 validateApiUrl(apiUrl);
216456216460 this.apiUrl = apiUrl.replace(/\/$/, "");
216457- this.timeout = options.timeout || DEFAULT_TIMEOUT13 ;
216461+ this.timeout = options.timeout || DEFAULT_TIMEOUT14 ;
216458216462 }
216459216463 /**
216460216464 * GET a BlockRun endpoint. `path` is everything after `/api` (a leading
@@ -216810,6 +216814,7 @@ var init_dist6 = __esm({
216810216814 DATA_DIR = path4.join(os4.homedir(), ".blockrun", "data");
216811216815 COST_LOG_FILE2 = path4.join(os4.homedir(), ".blockrun", "cost_log.jsonl");
216812216816 DEFAULT_TTL = {
216817+ "/v1/x/": 3600 * 1e3,
216813216818 "/v1/partner/": 3600 * 1e3,
216814216819 "/v1/pm/": 1800 * 1e3,
216815216820 "/v1/chat/": 0,
0 commit comments