@mindstudio-ai/agent 0.1.70 → 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.
@@ -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",
@@ -5617,6 +5758,7 @@ var init_instructions = __esm({
5617
5758
  Google: \`gemini-3-flash\`, \`gemini-3-pro\`, \`gemini-3.1-pro\`
5618
5759
  OpenAI: \`gpt-4o-mini\`, \`gpt-4o\`, \`gpt-5-mini\`, \`gpt-5\`, \`gpt-5.1\`, \`gpt-5.2\`
5619
5760
  Grok: \`grok-build-0.1\`, \`grok-4.5\`
5761
+ Meta: \`muse-spark-1.1\`
5620
5762
 
5621
5763
  Default to \`claude-4-6-sonnet\` unless the user has a preference. Do NOT recommend o-series reasoning models (o3, o4) for tasks \u2014 they are optimized for reasoning, not tool-use loops. Do NOT recommend Gemini 2.x when 3.x is available.
5622
5764
  </model_guidance>
@@ -6067,7 +6209,7 @@ async function startMcpServer(options) {
6067
6209
  capabilities: { tools: {} },
6068
6210
  serverInfo: {
6069
6211
  name: "mindstudio-agent",
6070
- version: "0.1.70"
6212
+ version: "0.1.72"
6071
6213
  },
6072
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.'
6073
6215
  });
@@ -6943,7 +7085,7 @@ function isNewerVersion(current, latest) {
6943
7085
  return false;
6944
7086
  }
6945
7087
  async function checkForUpdate() {
6946
- const currentVersion = "0.1.70";
7088
+ const currentVersion = "0.1.72";
6947
7089
  if (!currentVersion) return null;
6948
7090
  try {
6949
7091
  const { loadConfig: loadConfig2, saveConfig: saveConfig2 } = await Promise.resolve().then(() => (init_config(), config_exports));
@@ -6972,7 +7114,7 @@ async function checkForUpdate() {
6972
7114
  }
6973
7115
  }
6974
7116
  function printUpdateNotice(latestVersion) {
6975
- const currentVersion = "0.1.70";
7117
+ const currentVersion = "0.1.72";
6976
7118
  process.stderr.write(
6977
7119
  `
6978
7120
  ${ansi2.cyanBright("Update available")} ${ansi2.gray(currentVersion + " \u2192")} ${ansi2.cyanBold(latestVersion)}
@@ -6985,7 +7127,7 @@ function isStandaloneBinary() {
6985
7127
  return !argv1.includes("node_modules");
6986
7128
  }
6987
7129
  async function cmdUpdate() {
6988
- const currentVersion = "0.1.70";
7130
+ const currentVersion = "0.1.72";
6989
7131
  process.stderr.write(
6990
7132
  ` ${ansi2.gray("Current version:")} ${currentVersion}
6991
7133
  `
@@ -7100,7 +7242,7 @@ async function cmdLogin(options) {
7100
7242
  process.stderr.write("\n");
7101
7243
  printLogo();
7102
7244
  process.stderr.write("\n");
7103
- const ver = "0.1.70";
7245
+ const ver = "0.1.72";
7104
7246
  process.stderr.write(
7105
7247
  ` ${ansi2.bold("MindStudio Agent")} ${ver ? " " + ansi2.gray("v" + ver) : ""}
7106
7248
  `
@@ -7411,7 +7553,7 @@ async function main() {
7411
7553
  try {
7412
7554
  if (command === "version" || command === "-v") {
7413
7555
  process.stdout.write(
7414
- "0.1.70\n"
7556
+ "0.1.72\n"
7415
7557
  );
7416
7558
  return;
7417
7559
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mindstudio-ai/agent",
3
- "version": "0.1.70",
3
+ "version": "0.1.72",
4
4
  "description": "TypeScript SDK for MindStudio direct step execution",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",