Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 39 additions & 20 deletions dist/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -82115,6 +82115,31 @@ function callFromGptObject(parsed) {
if (!isPlainObject(params)) return null;
return { name: name.trim(), args: normalizeGptArgs(params) };
}
function callFromBashCmdObject(parsed) {
if (!isPlainObject(parsed) || !Array.isArray(parsed.cmd)) return null;
const [bin, flag, command, ...rest] = parsed.cmd;
if (rest.length > 0 || typeof bin !== "string" || typeof flag !== "string" || typeof command !== "string") {
return null;
}
if (bin.split("/").pop() !== "bash" || flag !== "-lc" || command.trim() === "") return null;
const args = { command };
if (typeof parsed.timeout === "number" && Number.isFinite(parsed.timeout)) {
args.timeout = parsed.timeout;
}
return { name: "terminal", args };
}
function callFromNarratedWebSearchObject(parsed, prefix) {
if (!isPlainObject(parsed) || typeof parsed.query !== "string" || parsed.query.trim() === "") {
return null;
}
if (!/\bweb[_-]?search\b/i.test(prefix)) return null;
const args = { query: parsed.query };
for (const key2 of ["top_n", "recency_days"]) {
const value = parsed[key2];
if (typeof value === "number" && Number.isFinite(value)) args[key2] = value;
}
return { name: "web_search", args, consumeProse: true };
}
function findTrailingJsonObject(content) {
let end = content.length;
while (end > 0 && /\s/.test(content[end - 1])) end--;
Expand Down Expand Up @@ -82167,14 +82192,17 @@ function extractGptCalls(content) {
}
const trailing = findTrailingJsonObject(content);
if (trailing) {
const built = callFromGptObject(trailing.parsed);
const prefix = content.slice(0, trailing.start);
const built = callFromGptObject(trailing.parsed) ?? callFromBashCmdObject(trailing.parsed) ?? callFromNarratedWebSearchObject(trailing.parsed, prefix);
if (built) {
const hasProseBefore = content.slice(0, trailing.start).trim() !== "";
const hasProseBefore = prefix.trim() !== "";
const typeIsFunction = trailing.parsed.type === "function";
if (!hasProseBefore || typeIsFunction) {
const isBashCmd = built.name === "terminal" && callFromBashCmdObject(trailing.parsed) !== null;
const consumeProse = "consumeProse" in built && built.consumeProse === true;
if (!hasProseBefore || typeIsFunction || isBashCmd || consumeProse) {
return {
calls: [makeCall(built.name, built.args)],
matches: [{ start: hasProseBefore ? trailing.start : 0, end: content.length }]
matches: [{ start: hasProseBefore && !consumeProse ? trailing.start : 0, end: content.length }]
};
}
}
Expand Down Expand Up @@ -216355,23 +216383,14 @@ function sanitizeErrorResponse(errorBody) {
code: typeof body.code === "string" ? body.code : void 0
};
}
function resolveDefaultTimeout() {
const envVal = typeof process !== "undefined" && process.env ? process.env.BLOCKRUN_CHAT_TIMEOUT : void 0;
if (envVal !== void 0) {
const seconds = Number(envVal);
if (Number.isFinite(seconds) && seconds > 0) {
return seconds * 1e3;
}
}
return 6e5;
}
function sleep2(ms) {
return new Promise((r2) => setTimeout(r2, ms));
}
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;
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;
var init_dist6 = __esm({
"node_modules/@blockrun/llm/dist/index.js"() {
"use strict";
init_index();
init_accounts();
init_accounts();
BlockrunError = class extends Error {
Expand Down Expand Up @@ -216417,7 +216436,6 @@ var init_dist6 = __esm({
LOCALHOST_DOMAINS = ["localhost", "127.0.0.1"];
BLOCKRUN_DIR2 = path2.join(os2.homedir(), ".blockrun");
COST_LOG_FILE = path2.join(BLOCKRUN_DIR2, "cost_log.jsonl");
DEFAULT_TIMEOUT = resolveDefaultTimeout();
SDK_VERSION = "1.5.0";
USER_AGENT2 = `blockrun-ts/${SDK_VERSION}`;
PHONE_PRICES = Object.freeze({
Expand All @@ -216428,8 +216446,8 @@ var init_dist6 = __esm({
"numbers/list": 1e-3,
"numbers/release": 0
});
DEFAULT_API_URL13 = "https://blockrun.ai/api";
DEFAULT_TIMEOUT13 = 6e4;
DEFAULT_API_URL14 = "https://blockrun.ai/api";
DEFAULT_TIMEOUT14 = 6e4;
DEFAULT_POLL_INTERVAL_MS = 5e3;
DEFAULT_POLL_BUDGET_MS = 3e5;
MAX_SIGNED_AUTH_SECONDS = 600;
Expand All @@ -216451,10 +216469,10 @@ var init_dist6 = __esm({
validatePrivateKey(privateKey);
this.privateKey = privateKey;
this.account = privateKeyToAccount(privateKey);
const apiUrl = options.apiUrl || DEFAULT_API_URL13;
const apiUrl = options.apiUrl || DEFAULT_API_URL14;
validateApiUrl(apiUrl);
this.apiUrl = apiUrl.replace(/\/$/, "");
this.timeout = options.timeout || DEFAULT_TIMEOUT13;
this.timeout = options.timeout || DEFAULT_TIMEOUT14;
}
/**
* GET a BlockRun endpoint. `path` is everything after `/api` (a leading
Expand Down Expand Up @@ -216810,6 +216828,7 @@ var init_dist6 = __esm({
DATA_DIR = path4.join(os4.homedir(), ".blockrun", "data");
COST_LOG_FILE2 = path4.join(os4.homedir(), ".blockrun", "cost_log.jsonl");
DEFAULT_TTL = {
"/v1/x/": 3600 * 1e3,
"/v1/partner/": 3600 * 1e3,
"/v1/pm/": 1800 * 1e3,
"/v1/chat/": 0,
Expand Down
2 changes: 1 addition & 1 deletion dist/cli.js.map

Large diffs are not rendered by default.

Loading
Loading