@mindstudio-ai/agent 0.1.20 → 0.1.21

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 CHANGED
@@ -4228,7 +4228,15 @@ async function buildSystemPrompt(agent) {
4228
4228
  (s) => `- ${s.id}: ${s.name} (${s.actions?.length ?? 0} actions)`
4229
4229
  ).join("\n") : "(Could not load connectors \u2014 use the getConnectorDetails tool)";
4230
4230
  const llmsContent2 = llmsResult.status === "fulfilled" ? llmsResult.value.llmsContent : "(Could not load action reference \u2014 use getActionDetails tool)";
4231
- const identity = `You are the MindStudio SDK assistant. You answer questions about the @mindstudio-ai/agent TypeScript SDK \u2014 actions, AI models, OAuth connectors, and integrations. Your consumers are AI agents that read your full output in one pass.`;
4231
+ const identity = `You are a senior MindStudio SDK engineer. You help AI coding agents build applications with the @mindstudio-ai/agent TypeScript SDK. You don't just answer questions \u2014 you identify what the caller is actually trying to build and give them the complete approach: which actions to use, how to compose them, and what pitfalls to avoid. Your output is consumed by coding agents that will implement what you propose. Be direct, opinionated, and prescriptive \u2014 don't leave room for the caller to make bad choices.
4232
+
4233
+ ## Scope
4234
+
4235
+ 1. **Actions** \u2014 selecting and composing SDK actions for a use case
4236
+ 2. **AI models** \u2014 model selection, config options, override patterns
4237
+ 3. **OAuth connectors** \u2014 discovering and using the 850+ connector actions
4238
+ 4. **Architecture** \u2014 batch execution, error handling, data flow between actions
4239
+ 5. **Managed databases and auth** \u2014 db, auth, Roles, resolveUser for MindStudio apps`;
4232
4240
  const referenceDocs = `<sdk_reference>
4233
4241
  <quick_reference>
4234
4242
  Auth is always pre-configured. Use \`new MindStudioAgent()\` with no arguments in code examples.
@@ -4279,8 +4287,26 @@ async function buildSystemPrompt(agent) {
4279
4287
  </connector_services>
4280
4288
  </sdk_reference>`;
4281
4289
  const instructions = `<instructions>
4290
+ <principles>
4291
+ - Respond to intent, not just the question. When asked "how do I call generateText," also surface relevant configuration the caller probably doesn't know about \u2014 structured output options, response format controls, model-specific features. When asked "how do I parse JSON from a model response," recognize they're probably doing it wrong and suggest built-in structured output instead.
4292
+ - Think at the workflow level. When the caller describes a multi-step process ("take user input, call an LLM, extract entities, save to database"), respond with the complete architectural approach: which actions to use, how to chain them, where to use batch execution, what error handling to add. Not just the signature for one action.
4293
+ - Be opinionated about SDK usage. Make concrete recommendations about the right way to build things. "Use executeStepBatch here" is better than "you could optionally batch these." But stay grounded on model claims \u2014 only state facts from model metadata, not editorial judgments about quality.
4294
+ - Match depth to the question. A simple "what params does generateImage take" gets a concise answer with a code example. A workflow question gets the full architectural response. Don't over-explain simple lookups, don't under-serve complex ones.
4295
+ </principles>
4296
+
4297
+ <anti_patterns>
4298
+ Flag these when the caller's question implies them:
4299
+
4300
+ - **Manual JSON parsing from LLM output** \u2014 if they're calling generateText and then parsing the response, they probably want structured output / response format controls instead of \`JSON.parse(content)\`.
4301
+ - **Sequential calls that should be batched** \u2014 multiple independent action calls (generate image + text-to-speech + search) should use \`executeStepBatch()\`. Three round trips become one.
4302
+ - **Building custom HTTP integrations when a connector exists** \u2014 if they're asking how to call the Slack API, Airtable API, HubSpot API, etc. via \`httpRequest\`, the answer is \`runFromConnectorRegistry\` with an existing OAuth connector. 850+ connector actions exist for this.
4303
+ - **Missing MindStudioError handling** \u2014 the SDK has structured errors with \`code\`, \`status\`, \`details\`. Catching generic \`Error\` loses actionable information. Always include \`MindStudioError\` handling in code examples.
4304
+ - **One-at-a-time db writes when batch exists** \u2014 N sequential \`update()\` or \`push()\` calls should be a single \`db.batch()\` call. One round trip instead of N.
4305
+ - **Hardcoded model IDs without context** \u2014 model IDs can change. When writing code with a specific model, include a comment noting which model it is and why it was chosen, so the caller can swap it later.
4306
+ </anti_patterns>
4307
+
4282
4308
  <tools>
4283
- You have 3 tools for detailed lookups. Most questions can be answered from the reference above without tools.
4309
+ You have 3 tools for detailed lookups. Most questions can be answered from the reference above without tools. Sometimes you already know the answer \u2014 you don't need to look up every action schema to answer a question about how to use it. Use tools when you need exact param types, model config options, or connector action details.
4284
4310
 
4285
4311
  - **getActionDetails(actionName)** \u2014 Full JSON schema for a specific action. Use when you need exact param types/enums to write correct code.
4286
4312
  - **listModels(type?, details?)** \u2014 Model catalog. By default returns compact summaries. With \`details: true\`, returns full model objects including the \`inputs\` array that defines config options (width, height, seed, etc.). Use \`details: true\` when writing code with a specific model, or when checking model capabilities (e.g. which models support source images). You can filter the full response yourself \u2014 one call with details is better than many individual lookups.
@@ -4288,15 +4314,14 @@ async function buildSystemPrompt(agent) {
4288
4314
  </tools>
4289
4315
 
4290
4316
  <response_format>
4291
- - Be terse. Lead with code \u2014 if the question implies code, the code block is the first thing in your response.
4292
- - Return complete, copy-paste-ready TypeScript code with correct model IDs, config options, and types.
4317
+ - Lead with the right approach, then code. If the caller is about to do something the hard way, say so before giving them the code.
4318
+ - Every response that involves code must include a complete, copy-paste-ready TypeScript example that handles the full use case \u2014 not just the one method call they asked about, but the surrounding pattern (error handling with MindStudioError, response destructuring, type annotations where helpful).
4293
4319
  - When writing code that uses a specific model, call listModels with details=true to get the model's config options and include them.
4294
4320
  - When building code examples, use getActionDetails to get the exact input schema first.
4295
4321
  - After the code block, optionally list config constraints (ranges, defaults) in a compact format.
4296
4322
  - For discovery questions ("what can I do?"), return a compact list from the reference docs.
4297
4323
  - Assume the caller already knows what the SDK is, how to install it, and how auth works.
4298
- - Only state facts from the data you have. Do not editorialize, recommend, or compare models/actions beyond what their metadata says. If the data does not say a model is "strong" or "best" at something, do not claim it is.
4299
- - Model tags in the summary are editorial labels, not technical specs. When answering questions about model capabilities (supported inputs, config options, dimensions, etc.), call listModels with details=true to check the \`inputs\` array \u2014 that is the source of truth. For example, a model supports start frame images if it has an input with type "imageUrl" or "imageUrlArray", not because its tags say "Source Image".
4324
+ - Model tags in the summary are editorial labels, not technical specs. When answering questions about model capabilities (supported inputs, config options, dimensions, etc.), call listModels with details=true to check the \`inputs\` array \u2014 that is the source of truth.
4300
4325
  </response_format>
4301
4326
  </instructions>`;
4302
4327
  return `${identity}
@@ -4522,7 +4547,7 @@ async function startMcpServer(options) {
4522
4547
  capabilities: { tools: {} },
4523
4548
  serverInfo: {
4524
4549
  name: "mindstudio-agent",
4525
- version: "0.1.20"
4550
+ version: "0.1.21"
4526
4551
  },
4527
4552
  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.'
4528
4553
  });
@@ -4991,6 +5016,7 @@ Account:
4991
5016
  change-name <name> Update your display name
4992
5017
  change-profile-picture <url> Update your profile picture
4993
5018
  upload <filepath> Upload a file to the MindStudio CDN
5019
+ update Update to the latest version
4994
5020
 
4995
5021
  OAuth integrations:
4996
5022
  list-connectors [<id> [<actionId>]] Browse OAuth connector services
@@ -5456,7 +5482,7 @@ function isNewerVersion(current, latest) {
5456
5482
  return false;
5457
5483
  }
5458
5484
  async function checkForUpdate() {
5459
- const currentVersion = "0.1.20";
5485
+ const currentVersion = "0.1.21";
5460
5486
  if (!currentVersion) return null;
5461
5487
  try {
5462
5488
  const { loadConfig: loadConfig2, saveConfig: saveConfig2 } = await Promise.resolve().then(() => (init_config(), config_exports));
@@ -5485,13 +5511,86 @@ async function checkForUpdate() {
5485
5511
  }
5486
5512
  }
5487
5513
  function printUpdateNotice(latestVersion) {
5488
- const currentVersion = "0.1.20";
5514
+ const currentVersion = "0.1.21";
5489
5515
  process.stderr.write(
5490
5516
  `
5491
5517
  ${ansi2.cyanBright("Update available")} ${ansi2.gray(currentVersion + " \u2192")} ${ansi2.cyanBold(latestVersion)}
5492
- ${ansi2.gray("Run")} npm install -g @mindstudio-ai/agent ${ansi2.gray("to update")}
5518
+ ${ansi2.gray("Run")} mindstudio update ${ansi2.gray("to update")}
5519
+ `
5520
+ );
5521
+ }
5522
+ function isStandaloneBinary() {
5523
+ const argv1 = process.argv[1] ?? "";
5524
+ return !argv1.includes("node_modules");
5525
+ }
5526
+ async function cmdUpdate() {
5527
+ const currentVersion = "0.1.21";
5528
+ process.stderr.write(
5529
+ ` ${ansi2.gray("Current version:")} ${currentVersion}
5530
+ `
5531
+ );
5532
+ process.stderr.write(` ${ansi2.gray("Checking for updates...")}
5533
+ `);
5534
+ let latestVersion;
5535
+ try {
5536
+ const res = await fetch(
5537
+ "https://registry.npmjs.org/@mindstudio-ai/agent/latest",
5538
+ { signal: AbortSignal.timeout(1e4) }
5539
+ );
5540
+ if (!res.ok) {
5541
+ fatal("Failed to check for updates. Please try again later.");
5542
+ }
5543
+ const data = await res.json();
5544
+ latestVersion = data.version ?? "";
5545
+ if (!latestVersion) {
5546
+ fatal("Failed to check for updates. Please try again later.");
5547
+ }
5548
+ } catch {
5549
+ fatal(
5550
+ "Failed to check for updates. Please check your internet connection."
5551
+ );
5552
+ }
5553
+ if (!isNewerVersion(currentVersion, latestVersion)) {
5554
+ process.stderr.write(
5555
+ ` ${ansi2.greenBold("Already up to date!")} ${ansi2.gray("(" + currentVersion + ")")}
5556
+ `
5557
+ );
5558
+ return;
5559
+ }
5560
+ process.stderr.write(
5561
+ ` ${ansi2.cyanBright("Updating")} ${ansi2.gray(currentVersion + " \u2192")} ${ansi2.cyanBold(latestVersion)}
5493
5562
  `
5494
5563
  );
5564
+ if (isStandaloneBinary()) {
5565
+ const platform = process.platform;
5566
+ try {
5567
+ if (platform === "win32") {
5568
+ execSync(
5569
+ 'powershell -Command "irm https://msagent.ai/install.ps1 | iex"',
5570
+ { stdio: "inherit" }
5571
+ );
5572
+ } else {
5573
+ execSync("curl -fsSL https://msagent.ai/install.sh | bash", {
5574
+ stdio: "inherit"
5575
+ });
5576
+ }
5577
+ process.stderr.write(
5578
+ `
5579
+ ${ansi2.greenBold("Updated to " + latestVersion)}
5580
+ `
5581
+ );
5582
+ } catch {
5583
+ fatal("Update failed. Try running the install command manually.");
5584
+ }
5585
+ } else {
5586
+ process.stderr.write(
5587
+ `
5588
+ ${ansi2.gray("Run the following command to update:")}
5589
+
5590
+ npm install -g @mindstudio-ai/agent@latest
5591
+ `
5592
+ );
5593
+ }
5495
5594
  }
5496
5595
  var LOGO = ` .=+-. :++.
5497
5596
  *@@@@@+ :%@@@@%:
@@ -5560,7 +5659,7 @@ async function cmdLogin(options) {
5560
5659
  process.stderr.write("\n");
5561
5660
  printLogo();
5562
5661
  process.stderr.write("\n");
5563
- const ver = "0.1.20";
5662
+ const ver = "0.1.21";
5564
5663
  process.stderr.write(
5565
5664
  ` ${ansi2.bold("MindStudio Agent")} ${ver ? " " + ansi2.gray("v" + ver) : ""}
5566
5665
  `
@@ -5869,11 +5968,11 @@ async function main() {
5869
5968
  process.exit(1);
5870
5969
  }
5871
5970
  const command = positionals[0];
5872
- const updatePromise = command !== "mcp" && command !== "login" ? checkForUpdate() : Promise.resolve(null);
5971
+ const updatePromise = command !== "mcp" && command !== "login" && command !== "update" ? checkForUpdate() : Promise.resolve(null);
5873
5972
  try {
5874
5973
  if (command === "version" || command === "-v") {
5875
5974
  process.stdout.write(
5876
- "0.1.20\n"
5975
+ "0.1.21\n"
5877
5976
  );
5878
5977
  return;
5879
5978
  }
@@ -5894,6 +5993,10 @@ async function main() {
5894
5993
  });
5895
5994
  return;
5896
5995
  }
5996
+ if (command === "update") {
5997
+ await cmdUpdate();
5998
+ return;
5999
+ }
5897
6000
  if (command === "ask") {
5898
6001
  let question = positionals.slice(1).join(" ");
5899
6002
  if (!question && !process.stdin.isTTY) {