@mindstudio-ai/agent 0.1.71 → 0.1.72
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 +147 -6
- package/dist/index.js +133 -0
- package/dist/index.js.map +1 -1
- package/dist/postinstall.js +147 -6
- package/package.json +1 -1
package/dist/postinstall.js
CHANGED
|
@@ -1375,6 +1375,131 @@ 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(new DbWsTransportError(err?.message || "ws send failed"));
|
|
1481
|
+
}
|
|
1482
|
+
});
|
|
1483
|
+
}
|
|
1484
|
+
var WS_REQUEST_TIMEOUT_MS, WS_OPEN_TIMEOUT_MS, WS_OPEN, WS_MAX_FRAME_CHARS, DbWsTransportError, socket, opening, idCounter, pending;
|
|
1485
|
+
var init_db_ws = __esm({
|
|
1486
|
+
"src/db-ws.ts"() {
|
|
1487
|
+
"use strict";
|
|
1488
|
+
init_errors();
|
|
1489
|
+
WS_REQUEST_TIMEOUT_MS = 3e5;
|
|
1490
|
+
WS_OPEN_TIMEOUT_MS = 5e3;
|
|
1491
|
+
WS_OPEN = 1;
|
|
1492
|
+
WS_MAX_FRAME_CHARS = 9e5;
|
|
1493
|
+
DbWsTransportError = class extends Error {
|
|
1494
|
+
name = "DbWsTransportError";
|
|
1495
|
+
};
|
|
1496
|
+
socket = null;
|
|
1497
|
+
opening = null;
|
|
1498
|
+
idCounter = 0;
|
|
1499
|
+
pending = /* @__PURE__ */ new Map();
|
|
1500
|
+
}
|
|
1501
|
+
});
|
|
1502
|
+
|
|
1378
1503
|
// src/rate-limit.ts
|
|
1379
1504
|
var DEFAULTS, RateLimiter;
|
|
1380
1505
|
var init_rate_limit = __esm({
|
|
@@ -3939,6 +4064,7 @@ var init_client = __esm({
|
|
|
3939
4064
|
init_http();
|
|
3940
4065
|
init_errors();
|
|
3941
4066
|
await init_context();
|
|
4067
|
+
init_db_ws();
|
|
3942
4068
|
init_rate_limit();
|
|
3943
4069
|
init_config();
|
|
3944
4070
|
init_auth();
|
|
@@ -4850,6 +4976,21 @@ var init_client = __esm({
|
|
|
4850
4976
|
* enabling RETURNING clauses and multi-statement batches.
|
|
4851
4977
|
*/
|
|
4852
4978
|
async _executeDbBatch(databaseId, queries) {
|
|
4979
|
+
const dbWsUrl = typeof process !== "undefined" ? process.env?.DB_WS_URL : void 0;
|
|
4980
|
+
if (dbWsUrl) {
|
|
4981
|
+
try {
|
|
4982
|
+
return await executeDbBatchOverWs(
|
|
4983
|
+
dbWsUrl,
|
|
4984
|
+
this._token,
|
|
4985
|
+
databaseId,
|
|
4986
|
+
queries
|
|
4987
|
+
);
|
|
4988
|
+
} catch (err) {
|
|
4989
|
+
if (!(err instanceof DbWsTransportError)) {
|
|
4990
|
+
throw err;
|
|
4991
|
+
}
|
|
4992
|
+
}
|
|
4993
|
+
}
|
|
4853
4994
|
const url = `${this._currentHttpConfig.baseUrl}/_internal/v2/db/query`;
|
|
4854
4995
|
const res = await fetch(url, {
|
|
4855
4996
|
method: "POST",
|
|
@@ -6068,7 +6209,7 @@ async function startMcpServer(options) {
|
|
|
6068
6209
|
capabilities: { tools: {} },
|
|
6069
6210
|
serverInfo: {
|
|
6070
6211
|
name: "mindstudio-agent",
|
|
6071
|
-
version: "0.1.
|
|
6212
|
+
version: "0.1.72"
|
|
6072
6213
|
},
|
|
6073
6214
|
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
6215
|
});
|
|
@@ -6944,7 +7085,7 @@ function isNewerVersion(current, latest) {
|
|
|
6944
7085
|
return false;
|
|
6945
7086
|
}
|
|
6946
7087
|
async function checkForUpdate() {
|
|
6947
|
-
const currentVersion = "0.1.
|
|
7088
|
+
const currentVersion = "0.1.72";
|
|
6948
7089
|
if (!currentVersion) return null;
|
|
6949
7090
|
try {
|
|
6950
7091
|
const { loadConfig: loadConfig2, saveConfig: saveConfig2 } = await Promise.resolve().then(() => (init_config(), config_exports));
|
|
@@ -6973,7 +7114,7 @@ async function checkForUpdate() {
|
|
|
6973
7114
|
}
|
|
6974
7115
|
}
|
|
6975
7116
|
function printUpdateNotice(latestVersion) {
|
|
6976
|
-
const currentVersion = "0.1.
|
|
7117
|
+
const currentVersion = "0.1.72";
|
|
6977
7118
|
process.stderr.write(
|
|
6978
7119
|
`
|
|
6979
7120
|
${ansi2.cyanBright("Update available")} ${ansi2.gray(currentVersion + " \u2192")} ${ansi2.cyanBold(latestVersion)}
|
|
@@ -6986,7 +7127,7 @@ function isStandaloneBinary() {
|
|
|
6986
7127
|
return !argv1.includes("node_modules");
|
|
6987
7128
|
}
|
|
6988
7129
|
async function cmdUpdate() {
|
|
6989
|
-
const currentVersion = "0.1.
|
|
7130
|
+
const currentVersion = "0.1.72";
|
|
6990
7131
|
process.stderr.write(
|
|
6991
7132
|
` ${ansi2.gray("Current version:")} ${currentVersion}
|
|
6992
7133
|
`
|
|
@@ -7101,7 +7242,7 @@ async function cmdLogin(options) {
|
|
|
7101
7242
|
process.stderr.write("\n");
|
|
7102
7243
|
printLogo();
|
|
7103
7244
|
process.stderr.write("\n");
|
|
7104
|
-
const ver = "0.1.
|
|
7245
|
+
const ver = "0.1.72";
|
|
7105
7246
|
process.stderr.write(
|
|
7106
7247
|
` ${ansi2.bold("MindStudio Agent")} ${ver ? " " + ansi2.gray("v" + ver) : ""}
|
|
7107
7248
|
`
|
|
@@ -7412,7 +7553,7 @@ async function main() {
|
|
|
7412
7553
|
try {
|
|
7413
7554
|
if (command === "version" || command === "-v") {
|
|
7414
7555
|
process.stdout.write(
|
|
7415
|
-
"0.1.
|
|
7556
|
+
"0.1.72\n"
|
|
7416
7557
|
);
|
|
7417
7558
|
return;
|
|
7418
7559
|
}
|