@mindstudio-ai/agent 0.1.71 → 0.1.73
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/cli.js +152 -6
- package/dist/index.js +138 -0
- package/dist/index.js.map +1 -1
- package/dist/postinstall.js +152 -6
- package/package.json +1 -1
package/dist/postinstall.js
CHANGED
|
@@ -1375,6 +1375,133 @@ var init_context = __esm({
|
|
|
1375
1375
|
}
|
|
1376
1376
|
});
|
|
1377
1377
|
|
|
1378
|
+
// src/db-ws.ts
|
|
1379
|
+
function getOrOpen(url) {
|
|
1380
|
+
if (socket && socket.readyState === WS_OPEN) {
|
|
1381
|
+
return Promise.resolve(socket);
|
|
1382
|
+
}
|
|
1383
|
+
if (opening) {
|
|
1384
|
+
return opening;
|
|
1385
|
+
}
|
|
1386
|
+
const WebSocketCtor = globalThis.WebSocket;
|
|
1387
|
+
if (!WebSocketCtor) {
|
|
1388
|
+
return Promise.reject(
|
|
1389
|
+
new DbWsTransportError("global WebSocket unavailable")
|
|
1390
|
+
);
|
|
1391
|
+
}
|
|
1392
|
+
opening = new Promise((resolve, reject) => {
|
|
1393
|
+
let ws;
|
|
1394
|
+
const fail = (err) => {
|
|
1395
|
+
clearTimeout(openTimer);
|
|
1396
|
+
if (socket === ws) {
|
|
1397
|
+
socket = null;
|
|
1398
|
+
}
|
|
1399
|
+
opening = null;
|
|
1400
|
+
for (const [, p] of pending) {
|
|
1401
|
+
clearTimeout(p.timer);
|
|
1402
|
+
p.reject(err);
|
|
1403
|
+
}
|
|
1404
|
+
pending.clear();
|
|
1405
|
+
reject(err);
|
|
1406
|
+
};
|
|
1407
|
+
const openTimer = setTimeout(() => {
|
|
1408
|
+
try {
|
|
1409
|
+
ws?.close();
|
|
1410
|
+
} catch {
|
|
1411
|
+
}
|
|
1412
|
+
fail(new DbWsTransportError("ws open timed out"));
|
|
1413
|
+
}, WS_OPEN_TIMEOUT_MS);
|
|
1414
|
+
try {
|
|
1415
|
+
ws = new WebSocketCtor(url);
|
|
1416
|
+
} catch (err) {
|
|
1417
|
+
fail(new DbWsTransportError(err?.message || "ws construct failed"));
|
|
1418
|
+
return;
|
|
1419
|
+
}
|
|
1420
|
+
ws.onopen = () => {
|
|
1421
|
+
clearTimeout(openTimer);
|
|
1422
|
+
socket = ws;
|
|
1423
|
+
opening = null;
|
|
1424
|
+
resolve(ws);
|
|
1425
|
+
};
|
|
1426
|
+
ws.onmessage = (ev) => {
|
|
1427
|
+
let msg;
|
|
1428
|
+
try {
|
|
1429
|
+
msg = JSON.parse(
|
|
1430
|
+
typeof ev.data === "string" ? ev.data : String(ev.data)
|
|
1431
|
+
);
|
|
1432
|
+
} catch {
|
|
1433
|
+
return;
|
|
1434
|
+
}
|
|
1435
|
+
if (!msg || msg.t !== "db-result" || msg.id == null) {
|
|
1436
|
+
return;
|
|
1437
|
+
}
|
|
1438
|
+
const p = pending.get(msg.id);
|
|
1439
|
+
if (!p) {
|
|
1440
|
+
return;
|
|
1441
|
+
}
|
|
1442
|
+
clearTimeout(p.timer);
|
|
1443
|
+
pending.delete(msg.id);
|
|
1444
|
+
if (msg.error) {
|
|
1445
|
+
p.reject(
|
|
1446
|
+
new MindStudioError(
|
|
1447
|
+
`[db] ${msg.error.message || "Database query failed"}`,
|
|
1448
|
+
msg.error.code || "db_query_error",
|
|
1449
|
+
400,
|
|
1450
|
+
msg.error
|
|
1451
|
+
)
|
|
1452
|
+
);
|
|
1453
|
+
} else {
|
|
1454
|
+
p.resolve(msg.results);
|
|
1455
|
+
}
|
|
1456
|
+
};
|
|
1457
|
+
ws.onerror = () => fail(new DbWsTransportError("ws error"));
|
|
1458
|
+
ws.onclose = () => fail(new DbWsTransportError("ws closed"));
|
|
1459
|
+
});
|
|
1460
|
+
return opening;
|
|
1461
|
+
}
|
|
1462
|
+
async function executeDbBatchOverWs(url, token, databaseId, queries) {
|
|
1463
|
+
const id = ++idCounter;
|
|
1464
|
+
const frame = JSON.stringify({ t: "db", id, token, databaseId, queries });
|
|
1465
|
+
if (frame.length > WS_MAX_FRAME_CHARS) {
|
|
1466
|
+
throw new DbWsTransportError("payload too large for ws");
|
|
1467
|
+
}
|
|
1468
|
+
const ws = await getOrOpen(url);
|
|
1469
|
+
return await new Promise((resolve, reject) => {
|
|
1470
|
+
const timer = setTimeout(() => {
|
|
1471
|
+
pending.delete(id);
|
|
1472
|
+
reject(new DbWsTransportError("ws execute timed out"));
|
|
1473
|
+
}, WS_REQUEST_TIMEOUT_MS);
|
|
1474
|
+
pending.set(id, { resolve, reject, timer });
|
|
1475
|
+
try {
|
|
1476
|
+
ws.send(frame);
|
|
1477
|
+
} catch (err) {
|
|
1478
|
+
clearTimeout(timer);
|
|
1479
|
+
pending.delete(id);
|
|
1480
|
+
reject(
|
|
1481
|
+
new DbWsTransportError(`ws send failed: ${err?.message || "unknown"}`)
|
|
1482
|
+
);
|
|
1483
|
+
}
|
|
1484
|
+
});
|
|
1485
|
+
}
|
|
1486
|
+
var WS_REQUEST_TIMEOUT_MS, WS_OPEN_TIMEOUT_MS, WS_OPEN, WS_MAX_FRAME_CHARS, DbWsTransportError, socket, opening, idCounter, pending;
|
|
1487
|
+
var init_db_ws = __esm({
|
|
1488
|
+
"src/db-ws.ts"() {
|
|
1489
|
+
"use strict";
|
|
1490
|
+
init_errors();
|
|
1491
|
+
WS_REQUEST_TIMEOUT_MS = 3e5;
|
|
1492
|
+
WS_OPEN_TIMEOUT_MS = 5e3;
|
|
1493
|
+
WS_OPEN = 1;
|
|
1494
|
+
WS_MAX_FRAME_CHARS = 9e5;
|
|
1495
|
+
DbWsTransportError = class extends Error {
|
|
1496
|
+
name = "DbWsTransportError";
|
|
1497
|
+
};
|
|
1498
|
+
socket = null;
|
|
1499
|
+
opening = null;
|
|
1500
|
+
idCounter = 0;
|
|
1501
|
+
pending = /* @__PURE__ */ new Map();
|
|
1502
|
+
}
|
|
1503
|
+
});
|
|
1504
|
+
|
|
1378
1505
|
// src/rate-limit.ts
|
|
1379
1506
|
var DEFAULTS, RateLimiter;
|
|
1380
1507
|
var init_rate_limit = __esm({
|
|
@@ -3939,6 +4066,7 @@ var init_client = __esm({
|
|
|
3939
4066
|
init_http();
|
|
3940
4067
|
init_errors();
|
|
3941
4068
|
await init_context();
|
|
4069
|
+
init_db_ws();
|
|
3942
4070
|
init_rate_limit();
|
|
3943
4071
|
init_config();
|
|
3944
4072
|
init_auth();
|
|
@@ -4850,6 +4978,24 @@ var init_client = __esm({
|
|
|
4850
4978
|
* enabling RETURNING clauses and multi-statement batches.
|
|
4851
4979
|
*/
|
|
4852
4980
|
async _executeDbBatch(databaseId, queries) {
|
|
4981
|
+
const dbWsUrl = typeof process !== "undefined" ? process.env?.DB_WS_URL : void 0;
|
|
4982
|
+
if (dbWsUrl) {
|
|
4983
|
+
try {
|
|
4984
|
+
return await executeDbBatchOverWs(
|
|
4985
|
+
dbWsUrl,
|
|
4986
|
+
this._token,
|
|
4987
|
+
databaseId,
|
|
4988
|
+
queries
|
|
4989
|
+
);
|
|
4990
|
+
} catch (err) {
|
|
4991
|
+
if (!(err instanceof DbWsTransportError)) {
|
|
4992
|
+
throw err;
|
|
4993
|
+
}
|
|
4994
|
+
console.warn(
|
|
4995
|
+
`[mindstudio] db: WebSocket transport unavailable (${err.message}); using HTTP for this query.`
|
|
4996
|
+
);
|
|
4997
|
+
}
|
|
4998
|
+
}
|
|
4853
4999
|
const url = `${this._currentHttpConfig.baseUrl}/_internal/v2/db/query`;
|
|
4854
5000
|
const res = await fetch(url, {
|
|
4855
5001
|
method: "POST",
|
|
@@ -6068,7 +6214,7 @@ async function startMcpServer(options) {
|
|
|
6068
6214
|
capabilities: { tools: {} },
|
|
6069
6215
|
serverInfo: {
|
|
6070
6216
|
name: "mindstudio-agent",
|
|
6071
|
-
version: "0.1.
|
|
6217
|
+
version: "0.1.73"
|
|
6072
6218
|
},
|
|
6073
6219
|
instructions: 'Welcome to MindStudio \u2014 a platform with 200+ AI models, 850+ third-party integrations, and pre-built agents.\n\nGetting started:\n1. Call `ask` with any question about the SDK \u2014 it knows every action, model, and connector and returns working code with real model IDs and config options. Examples: ask("generate an image with FLUX"), ask("what models support vision?"), ask("how do I send a Slack message?").\n2. Call `changeName` to set your display name \u2014 use your name or whatever your user calls you. This is how you\'ll appear in MindStudio request logs.\n3. If you have a profile picture or icon, call `uploadFile` to upload it, then `changeProfilePicture` with the returned URL.\n4. For manual browsing, call `listActions` to discover all available actions.\n\nThen use the tools to generate text, images, video, audio, search the web, work with data sources, run agents, and more.\n\nImportant:\n- AI-powered actions (text generation, image generation, video, audio, etc.) cost money. Before running these, call `estimateActionCost` and confirm with the user before proceeding \u2014 unless they\'ve explicitly told you to go ahead.\n- Not all agents from `listAgents` are configured for API use. Do not try to run an agent just because it appears in the list \u2014 it will likely fail. Only run agents the user specifically asks you to run.'
|
|
6074
6220
|
});
|
|
@@ -6944,7 +7090,7 @@ function isNewerVersion(current, latest) {
|
|
|
6944
7090
|
return false;
|
|
6945
7091
|
}
|
|
6946
7092
|
async function checkForUpdate() {
|
|
6947
|
-
const currentVersion = "0.1.
|
|
7093
|
+
const currentVersion = "0.1.73";
|
|
6948
7094
|
if (!currentVersion) return null;
|
|
6949
7095
|
try {
|
|
6950
7096
|
const { loadConfig: loadConfig2, saveConfig: saveConfig2 } = await Promise.resolve().then(() => (init_config(), config_exports));
|
|
@@ -6973,7 +7119,7 @@ async function checkForUpdate() {
|
|
|
6973
7119
|
}
|
|
6974
7120
|
}
|
|
6975
7121
|
function printUpdateNotice(latestVersion) {
|
|
6976
|
-
const currentVersion = "0.1.
|
|
7122
|
+
const currentVersion = "0.1.73";
|
|
6977
7123
|
process.stderr.write(
|
|
6978
7124
|
`
|
|
6979
7125
|
${ansi2.cyanBright("Update available")} ${ansi2.gray(currentVersion + " \u2192")} ${ansi2.cyanBold(latestVersion)}
|
|
@@ -6986,7 +7132,7 @@ function isStandaloneBinary() {
|
|
|
6986
7132
|
return !argv1.includes("node_modules");
|
|
6987
7133
|
}
|
|
6988
7134
|
async function cmdUpdate() {
|
|
6989
|
-
const currentVersion = "0.1.
|
|
7135
|
+
const currentVersion = "0.1.73";
|
|
6990
7136
|
process.stderr.write(
|
|
6991
7137
|
` ${ansi2.gray("Current version:")} ${currentVersion}
|
|
6992
7138
|
`
|
|
@@ -7101,7 +7247,7 @@ async function cmdLogin(options) {
|
|
|
7101
7247
|
process.stderr.write("\n");
|
|
7102
7248
|
printLogo();
|
|
7103
7249
|
process.stderr.write("\n");
|
|
7104
|
-
const ver = "0.1.
|
|
7250
|
+
const ver = "0.1.73";
|
|
7105
7251
|
process.stderr.write(
|
|
7106
7252
|
` ${ansi2.bold("MindStudio Agent")} ${ver ? " " + ansi2.gray("v" + ver) : ""}
|
|
7107
7253
|
`
|
|
@@ -7412,7 +7558,7 @@ async function main() {
|
|
|
7412
7558
|
try {
|
|
7413
7559
|
if (command === "version" || command === "-v") {
|
|
7414
7560
|
process.stdout.write(
|
|
7415
|
-
"0.1.
|
|
7561
|
+
"0.1.73\n"
|
|
7416
7562
|
);
|
|
7417
7563
|
return;
|
|
7418
7564
|
}
|