@mindstudio-ai/agent 0.1.35 → 0.1.36

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.
@@ -1233,8 +1233,11 @@ async function requestWithRetry(config, method, url, body, attempt) {
1233
1233
  try {
1234
1234
  const body2 = JSON.parse(text);
1235
1235
  details = body2;
1236
- const errMsg = body2.error ?? body2.message ?? body2.details;
1236
+ const errMsg = (typeof body2.error === "string" ? body2.error : void 0) ?? (typeof body2.message === "string" ? body2.message : void 0) ?? (typeof body2.details === "string" ? body2.details : void 0);
1237
1237
  if (errMsg) message = errMsg;
1238
+ else if (body2.error || body2.message || body2.details) {
1239
+ message = JSON.stringify(body2.error ?? body2.message ?? body2.details);
1240
+ }
1238
1241
  if (body2.code) code = body2.code;
1239
1242
  } catch {
1240
1243
  if (text && text.length < 500) message = text;
@@ -1474,6 +1477,7 @@ function escapeValue(val) {
1474
1477
  return `'${json.replace(/'/g, "''")}'`;
1475
1478
  }
1476
1479
  function deserializeRow(row, columns) {
1480
+ if (row == null) return row;
1477
1481
  const result = {};
1478
1482
  for (const [key, value] of Object.entries(row)) {
1479
1483
  const col = columns.find((c) => c.name === key);
@@ -2095,6 +2099,8 @@ var init_query = __esm({
2095
2099
  _limit;
2096
2100
  _offset;
2097
2101
  _config;
2102
+ /** @internal Post-process transform applied after row deserialization. */
2103
+ _postProcess;
2098
2104
  constructor(config, options) {
2099
2105
  this._config = config;
2100
2106
  this._predicates = options?.predicates ?? [];
@@ -2102,6 +2108,7 @@ var init_query = __esm({
2102
2108
  this._reversed = options?.reversed ?? false;
2103
2109
  this._limit = options?.limit;
2104
2110
  this._offset = options?.offset;
2111
+ this._postProcess = options?.postProcess;
2105
2112
  }
2106
2113
  _clone(overrides) {
2107
2114
  return new _Query(this._config, {
@@ -2109,7 +2116,8 @@ var init_query = __esm({
2109
2116
  sortAccessor: overrides.sortAccessor ?? this._sortAccessor,
2110
2117
  reversed: overrides.reversed ?? this._reversed,
2111
2118
  limit: overrides.limit ?? this._limit,
2112
- offset: overrides.offset ?? this._offset
2119
+ offset: overrides.offset ?? this._offset,
2120
+ postProcess: overrides.postProcess
2113
2121
  });
2114
2122
  }
2115
2123
  // -------------------------------------------------------------------------
@@ -2133,13 +2141,18 @@ var init_query = __esm({
2133
2141
  // -------------------------------------------------------------------------
2134
2142
  // Terminal methods
2135
2143
  // -------------------------------------------------------------------------
2136
- async first() {
2137
- const rows = await this._clone({ limit: 1 })._execute();
2138
- return rows[0] ?? null;
2144
+ first() {
2145
+ return this._clone({
2146
+ limit: 1,
2147
+ postProcess: (rows) => rows[0] ?? null
2148
+ });
2139
2149
  }
2140
- async last() {
2141
- const rows = await this._clone({ limit: 1, reversed: !this._reversed })._execute();
2142
- return rows[0] ?? null;
2150
+ last() {
2151
+ return this._clone({
2152
+ limit: 1,
2153
+ reversed: !this._reversed,
2154
+ postProcess: (rows) => rows[0] ?? null
2155
+ });
2143
2156
  }
2144
2157
  async count() {
2145
2158
  const compiled = this._compilePredicates();
@@ -2188,10 +2201,10 @@ var init_query = __esm({
2188
2201
  (row) => this._predicates.every((pred) => pred(row))
2189
2202
  );
2190
2203
  }
2191
- async min(accessor) {
2204
+ min(accessor) {
2192
2205
  return this.sortBy(accessor).first();
2193
2206
  }
2194
- async max(accessor) {
2207
+ max(accessor) {
2195
2208
  return this.sortBy(accessor).reverse().first();
2196
2209
  }
2197
2210
  async groupBy(accessor) {
@@ -2230,7 +2243,7 @@ var init_query = __esm({
2230
2243
  limit: this._limit,
2231
2244
  offset: this._offset
2232
2245
  });
2233
- return { type: "query", query, fallbackQuery: null, config: this._config };
2246
+ return { type: "query", query, fallbackQuery: null, config: this._config, postProcess: this._postProcess };
2234
2247
  }
2235
2248
  const fallbackQuery = buildSelect(this._config.tableName);
2236
2249
  return {
@@ -2242,7 +2255,8 @@ var init_query = __esm({
2242
2255
  sortAccessor: this._sortAccessor,
2243
2256
  reversed: this._reversed,
2244
2257
  limit: this._limit,
2245
- offset: this._offset
2258
+ offset: this._offset,
2259
+ postProcess: this._postProcess
2246
2260
  };
2247
2261
  }
2248
2262
  /**
@@ -2259,7 +2273,9 @@ var init_query = __esm({
2259
2273
  compiled.config.columns
2260
2274
  )
2261
2275
  );
2262
- if (compiled.query) return rows;
2276
+ if (compiled.query) {
2277
+ return compiled.postProcess ? compiled.postProcess(rows) : rows;
2278
+ }
2263
2279
  let filtered = compiled.predicates ? rows.filter((row) => compiled.predicates.every((pred) => pred(row))) : rows;
2264
2280
  if (compiled.sortAccessor) {
2265
2281
  const accessor = compiled.sortAccessor;
@@ -2277,16 +2293,19 @@ var init_query = __esm({
2277
2293
  const end = compiled.limit != null ? start + compiled.limit : void 0;
2278
2294
  filtered = filtered.slice(start, end);
2279
2295
  }
2280
- return filtered;
2296
+ return compiled.postProcess ? compiled.postProcess(filtered) : filtered;
2281
2297
  }
2282
2298
  // -------------------------------------------------------------------------
2283
2299
  // PromiseLike
2284
2300
  // -------------------------------------------------------------------------
2285
2301
  then(onfulfilled, onrejected) {
2286
- return this._execute().then(onfulfilled, onrejected);
2302
+ const promise = this._execute().then(
2303
+ (rows) => this._postProcess ? this._postProcess(rows) : rows
2304
+ );
2305
+ return promise.then(onfulfilled, onrejected);
2287
2306
  }
2288
2307
  catch(onrejected) {
2289
- return this._execute().catch(onrejected);
2308
+ return this.then(void 0, onrejected);
2290
2309
  }
2291
2310
  // -------------------------------------------------------------------------
2292
2311
  // Execution internals
@@ -3990,6 +4009,12 @@ var init_client = __esm({
3990
4009
  * ```
3991
4010
  */
3992
4011
  get auth() {
4012
+ if (this._authType === "internal") {
4013
+ const ai = globalThis.ai;
4014
+ if (ai?.auth) {
4015
+ return new AuthContext(ai.auth);
4016
+ }
4017
+ }
3993
4018
  if (!this._auth) {
3994
4019
  this._trySandboxHydration();
3995
4020
  }
@@ -4126,8 +4151,11 @@ var init_client = __esm({
4126
4151
  const text = await res.text();
4127
4152
  try {
4128
4153
  const body = JSON.parse(text);
4129
- const errMsg = body.error ?? body.message ?? body.details;
4154
+ const errMsg = (typeof body.error === "string" ? body.error : void 0) ?? (typeof body.message === "string" ? body.message : void 0) ?? (typeof body.details === "string" ? body.details : void 0);
4130
4155
  if (errMsg) message = errMsg;
4156
+ else if (body.error || body.message || body.details) {
4157
+ message = JSON.stringify(body.error ?? body.message ?? body.details);
4158
+ }
4131
4159
  if (body.code) code = body.code;
4132
4160
  } catch {
4133
4161
  if (text && text.length < 500) message = text;
@@ -4998,7 +5026,7 @@ async function startMcpServer(options) {
4998
5026
  capabilities: { tools: {} },
4999
5027
  serverInfo: {
5000
5028
  name: "mindstudio-agent",
5001
- version: "0.1.35"
5029
+ version: "0.1.36"
5002
5030
  },
5003
5031
  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.'
5004
5032
  });
@@ -5858,7 +5886,7 @@ function isNewerVersion(current, latest) {
5858
5886
  return false;
5859
5887
  }
5860
5888
  async function checkForUpdate() {
5861
- const currentVersion = "0.1.35";
5889
+ const currentVersion = "0.1.36";
5862
5890
  if (!currentVersion) return null;
5863
5891
  try {
5864
5892
  const { loadConfig: loadConfig2, saveConfig: saveConfig2 } = await Promise.resolve().then(() => (init_config(), config_exports));
@@ -5887,7 +5915,7 @@ async function checkForUpdate() {
5887
5915
  }
5888
5916
  }
5889
5917
  function printUpdateNotice(latestVersion) {
5890
- const currentVersion = "0.1.35";
5918
+ const currentVersion = "0.1.36";
5891
5919
  process.stderr.write(
5892
5920
  `
5893
5921
  ${ansi2.cyanBright("Update available")} ${ansi2.gray(currentVersion + " \u2192")} ${ansi2.cyanBold(latestVersion)}
@@ -5900,7 +5928,7 @@ function isStandaloneBinary() {
5900
5928
  return !argv1.includes("node_modules");
5901
5929
  }
5902
5930
  async function cmdUpdate() {
5903
- const currentVersion = "0.1.35";
5931
+ const currentVersion = "0.1.36";
5904
5932
  process.stderr.write(
5905
5933
  ` ${ansi2.gray("Current version:")} ${currentVersion}
5906
5934
  `
@@ -6015,7 +6043,7 @@ async function cmdLogin(options) {
6015
6043
  process.stderr.write("\n");
6016
6044
  printLogo();
6017
6045
  process.stderr.write("\n");
6018
- const ver = "0.1.35";
6046
+ const ver = "0.1.36";
6019
6047
  process.stderr.write(
6020
6048
  ` ${ansi2.bold("MindStudio Agent")} ${ver ? " " + ansi2.gray("v" + ver) : ""}
6021
6049
  `
@@ -6326,7 +6354,7 @@ async function main() {
6326
6354
  try {
6327
6355
  if (command === "version" || command === "-v") {
6328
6356
  process.stdout.write(
6329
- "0.1.35\n"
6357
+ "0.1.36\n"
6330
6358
  );
6331
6359
  return;
6332
6360
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mindstudio-ai/agent",
3
- "version": "0.1.35",
3
+ "version": "0.1.36",
4
4
  "description": "TypeScript SDK for MindStudio direct step execution",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",