@mindstudio-ai/agent 0.1.67 → 0.1.69

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.
@@ -5052,6 +5052,84 @@ var init_client = __esm({
5052
5052
  return data;
5053
5053
  }
5054
5054
  // -------------------------------------------------------------------------
5055
+ // Issue reporting
5056
+ // -------------------------------------------------------------------------
5057
+ /**
5058
+ * File a bug report or feature idea into this app's issue tracker.
5059
+ *
5060
+ * For building an in-app "Report a bug" feature: wire the frontend UI to
5061
+ * an app backend method that calls this. The issue lands in the app's
5062
+ * issue tracker, visible to the app's team and available to the Remy agent.
5063
+ *
5064
+ * **Backend / managed-context only.** It authenticates with the app's hook
5065
+ * token (the same credential used for `db` queries), and the app id is
5066
+ * derived from that token server-side. Calling it outside a managed
5067
+ * context (e.g. with a plain API key) will fail with `401`.
5068
+ *
5069
+ * Rate limited per app (20 / 60s). On the limit this throws a
5070
+ * `MindStudioError` with `code === 'rate_limited'` and `status === 429` —
5071
+ * catch it to show a graceful "try again shortly" message. Every call
5072
+ * creates a new issue (no dedupe), so guard against double-submit in the UI.
5073
+ *
5074
+ * @returns The filed issue. Show `issue.number` to confirm "Reported as #42".
5075
+ *
5076
+ * @example
5077
+ * ```ts
5078
+ * // app backend method, e.g. exported as `reportBug`
5079
+ * export async function reportBug({ title, details, userEmail }) {
5080
+ * try {
5081
+ * const { number } = await mindstudio.reportIssue({
5082
+ * title,
5083
+ * body: details,
5084
+ * kind: 'bug',
5085
+ * reporter: userEmail, // free-form label; omit for anonymous
5086
+ * });
5087
+ * return { ok: true, issueNumber: number };
5088
+ * } catch (e) {
5089
+ * if (e instanceof MindStudioError && e.code === 'rate_limited') {
5090
+ * return { ok: false, retry: true };
5091
+ * }
5092
+ * throw e;
5093
+ * }
5094
+ * }
5095
+ * ```
5096
+ */
5097
+ async reportIssue(input) {
5098
+ const title = input.title?.trim();
5099
+ if (!title) {
5100
+ throw new MindStudioError("title is required", "missing_title", 400);
5101
+ }
5102
+ const url = `${this._currentHttpConfig.baseUrl}/_internal/v2/report-issue`;
5103
+ const res = await fetch(url, {
5104
+ method: "POST",
5105
+ headers: {
5106
+ "Content-Type": "application/json",
5107
+ Authorization: this._token
5108
+ },
5109
+ body: JSON.stringify({
5110
+ title,
5111
+ ...input.body !== void 0 && { body: input.body },
5112
+ ...input.kind !== void 0 && { kind: input.kind },
5113
+ ...input.reporter !== void 0 && { reporter: input.reporter }
5114
+ })
5115
+ });
5116
+ if (!res.ok) {
5117
+ let code = "report_issue_error";
5118
+ let message = `Report issue failed: ${res.status} ${res.statusText}`;
5119
+ let details;
5120
+ try {
5121
+ const body = await res.json();
5122
+ details = body;
5123
+ if (typeof body.errorString === "string") code = body.errorString;
5124
+ message = typeof body.errorMessage === "string" && body.errorMessage || typeof body.errorString === "string" && body.errorString || message;
5125
+ } catch {
5126
+ }
5127
+ throw new MindStudioError(message, code, res.status, details);
5128
+ }
5129
+ const data = await res.json();
5130
+ return data.issue;
5131
+ }
5132
+ // -------------------------------------------------------------------------
5055
5133
  // App context
5056
5134
  // -------------------------------------------------------------------------
5057
5135
  /**
@@ -5387,6 +5465,8 @@ function buildReferenceDocs(data) {
5387
5465
  \`\`\`
5388
5466
  Without this pattern, long-running operations appear to hang with no feedback to the user.
5389
5467
 
5468
+ Prompt caching and cost: Anthropic prompt caching is enabled automatically on every LLM call. There is NO SDK toggle, no opt-in flag, no configuration \u2014 it cannot be enabled or disabled. The platform marks the static portion of each request (system prompt + tool descriptions + leading conversation history) for caching, and subsequent calls within the 5-minute TTL read from cache at roughly 10% of full input cost. The \`$billingCost\` returned on every step result is the post-cache amount. In multi-turn chatbot / RAG / tool-use loops, expect 40-60% of input tokens to be served from cache after the first turn. NEVER tell a user "MindStudio doesn't support prompt caching" or "the SDK doesn't expose caching" \u2014 both are wrong. Caching is on, automatic, and already discounted. The SDK does not currently surface per-call cache hit/miss counts (no \`$cacheReadTokens\` field today), but the discount IS being applied. Real cost levers for chat/RAG/tool-using agents, in priority order: (1) trim tool descriptions \u2014 JSON tool schemas are larger than people expect and add to every turn, (2) cap conversation history by turn count or token budget with summarization on overflow (single biggest variable cost driver in multi-turn chat), (3) pre-filter large contexts via embedding retrieval before passing to the expensive model rather than dumping a whole library in the prompt, (4) shorten the system prompt \u2014 every K saved is one K not in the cache footprint either. Do NOT recommend "enabling prompt caching" as a cost-reduction strategy; it's already on and the savings are already in \`$billingCost\`.
5469
+
5390
5470
  Database queries (Query, Mutation) support both \`await\` and \`.then()/.catch()\` \u2014 use standard try/catch with await or chain \`.catch()\` directly.
5391
5471
 
5392
5472
  Filter predicates and bindings: Filters compile to SQL when the predicate uses field comparisons, &&/||, .includes(), null checks, and boolean fields with literal values. Predicates that reference outer-scope variables (e.g. \`o => o.companyId === input.companyId\`) cannot be compiled \u2014 JavaScript closures aren't inspectable from outside the function \u2014 so they fall back to JS and scan the whole table. For filters on tables that may grow, ALWAYS use the explicit-bindings form so the filter compiles to SQL: \`Investments.filter((i, $) => i.companyId === $.companyId, { companyId: input.companyId })\`. The second predicate parameter (any name \u2014 \`$\`, \`vars\`, \`b\`) signals that bindings are in play; the third argument provides the values. Supported on filter, findOne, count, some, every, removeAll. Bound array \u2192 \`$.ids.includes(o.field)\` compiles to IN; bound string \u2192 \`o.field.includes($.text)\` compiles to LIKE. Missing keys fall back to JS \u2014 the SDK does not substitute NULL. ALWAYS include an inline code comment when you write the bindings form so downstream coding agents don't "simplify" the bindings argument away, e.g. \`{ companyId: input.companyId } // bindings: lifts closure var so filter compiles to SQL\`.
@@ -5397,6 +5477,10 @@ function buildReferenceDocs(data) {
5397
5477
 
5398
5478
  Task agents: For multi-step tasks requiring autonomous tool use, use \`runTask()\`. Provide a prompt, input, SDK action names as tools (with optional default overrides), a \`structuredOutputExample\`, and a model. The platform runs a tool-use loop and returns structured output. Tools can include any SDK action \u2014 e.g. \`['searchGoogle', 'fetchUrl', { method: 'generateImage', defaults: { imageModelOverride: { model: 'seedream-4.5' } } }]\`. Supports SSE streaming via \`onEvent\` callback.
5399
5479
 
5480
+ Uploading files / getting a hosted URL: There are TWO ways to upload a file to the MindStudio CDN, depending on context. (1) From app backend code, call \`await mindstudio.uploadFile(bytes, { extension: 'png', type?: 'image/png' })\` \u2192 returns \`{ url }\` (a permanent public URL); \`bytes\` is a \`Buffer\`/\`Uint8Array\`, so read/fetch the content first. (2) From the terminal \u2014 e.g. you generated an icon or asset locally and just need its URL \u2014 run \`mindstudio upload <filepath>\` (alias: \`mindstudio upload-file\`). It prints the public URL to stdout. IMPORTANT: to host a one-off local file, use the CLI command directly \u2014 do NOT write a throwaway app method that calls \`uploadFile\` just to trigger it. The CLI does this in one step. More generally: some SDK capabilities are exposed as \`mindstudio\` CLI commands (upload, list-actions, run-agent, exec, batch, \u2026), not only as code \u2014 reach for the CLI for one-off operations instead of writing and running code.
5481
+
5482
+ Reporting bugs / ideas (\`reportIssue\`): For building an in-app "Report a bug" or feedback feature, use \`mindstudio.reportIssue({ title, body?, kind?, reporter? })\` (also importable directly as \`reportIssue\`). It files an issue into the app's issue tracker \u2014 visible to the app's team in the dashboard and pickup-able by the Remy agent. Backend only: wire it as frontend UI \u2192 app backend method \u2192 \`reportIssue\` (a browser can't call it; it uses the app's hook token, and the app id is derived server-side). \`kind\` is \`'bug'\` (default) or \`'idea'\`. \`reporter\` is a free-form display label (a name, email, or ticket id) \u2014 NOT an identity check and not tied to a user; pass the current user's email if you have it, or omit for anonymous. It returns the created issue \u2014 show \`result.number\` to confirm "Reported as #42". Rate limited per app (20/min): catch \`MindStudioError\` with \`code === 'rate_limited'\` and show a graceful "try again shortly" message, and debounce the submit button (every call creates a new issue \u2014 no dedupe).
5483
+
5400
5484
  Table options: \`db.defineTable<T>(name, { unique, defaults })\`.
5401
5485
  - \`unique: [['email'], ['userId', 'orgId']]\` \u2014 declares unique constraints (SDK communicates to platform, enables upsert).
5402
5486
  - \`defaults: { status: 'pending' }\` \u2014 client-side defaults applied in push() and upsert().
@@ -5983,7 +6067,7 @@ async function startMcpServer(options) {
5983
6067
  capabilities: { tools: {} },
5984
6068
  serverInfo: {
5985
6069
  name: "mindstudio-agent",
5986
- version: "0.1.67"
6070
+ version: "0.1.69"
5987
6071
  },
5988
6072
  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.'
5989
6073
  });
@@ -6859,7 +6943,7 @@ function isNewerVersion(current, latest) {
6859
6943
  return false;
6860
6944
  }
6861
6945
  async function checkForUpdate() {
6862
- const currentVersion = "0.1.67";
6946
+ const currentVersion = "0.1.69";
6863
6947
  if (!currentVersion) return null;
6864
6948
  try {
6865
6949
  const { loadConfig: loadConfig2, saveConfig: saveConfig2 } = await Promise.resolve().then(() => (init_config(), config_exports));
@@ -6888,7 +6972,7 @@ async function checkForUpdate() {
6888
6972
  }
6889
6973
  }
6890
6974
  function printUpdateNotice(latestVersion) {
6891
- const currentVersion = "0.1.67";
6975
+ const currentVersion = "0.1.69";
6892
6976
  process.stderr.write(
6893
6977
  `
6894
6978
  ${ansi2.cyanBright("Update available")} ${ansi2.gray(currentVersion + " \u2192")} ${ansi2.cyanBold(latestVersion)}
@@ -6901,7 +6985,7 @@ function isStandaloneBinary() {
6901
6985
  return !argv1.includes("node_modules");
6902
6986
  }
6903
6987
  async function cmdUpdate() {
6904
- const currentVersion = "0.1.67";
6988
+ const currentVersion = "0.1.69";
6905
6989
  process.stderr.write(
6906
6990
  ` ${ansi2.gray("Current version:")} ${currentVersion}
6907
6991
  `
@@ -7016,7 +7100,7 @@ async function cmdLogin(options) {
7016
7100
  process.stderr.write("\n");
7017
7101
  printLogo();
7018
7102
  process.stderr.write("\n");
7019
- const ver = "0.1.67";
7103
+ const ver = "0.1.69";
7020
7104
  process.stderr.write(
7021
7105
  ` ${ansi2.bold("MindStudio Agent")} ${ver ? " " + ansi2.gray("v" + ver) : ""}
7022
7106
  `
@@ -7327,7 +7411,7 @@ async function main() {
7327
7411
  try {
7328
7412
  if (command === "version" || command === "-v") {
7329
7413
  process.stdout.write(
7330
- "0.1.67\n"
7414
+ "0.1.69\n"
7331
7415
  );
7332
7416
  return;
7333
7417
  }
@@ -7517,20 +7601,22 @@ async function main() {
7517
7601
  });
7518
7602
  return;
7519
7603
  }
7520
- if (command === "upload") {
7604
+ if (command === "upload" || command === "upload-file") {
7521
7605
  const filePath = positionals[1];
7522
7606
  if (!filePath)
7523
7607
  usageBlock([
7524
- "upload \u2014 Upload a file to the MindStudio CDN",
7608
+ "upload \u2014 Upload a file to the MindStudio CDN (alias: upload-file)",
7525
7609
  "",
7526
7610
  "Usage:",
7527
7611
  " mindstudio upload <filepath>",
7528
7612
  "",
7529
7613
  "Returns the permanent public URL for the uploaded file.",
7614
+ "Use this to host a local file (e.g. a generated icon) and get a",
7615
+ "URL \u2014 no need to write or trigger an app method.",
7530
7616
  "",
7531
7617
  "Examples:",
7532
7618
  " mindstudio upload photo.png",
7533
- " mindstudio upload /path/to/document.pdf"
7619
+ " mindstudio upload-file /path/to/document.pdf"
7534
7620
  ]);
7535
7621
  await cmdUpload(filePath, {
7536
7622
  apiKey: values["api-key"],
@@ -7800,7 +7886,7 @@ Account:
7800
7886
  whoami Show current user and organization
7801
7887
  change-name <name> Update your display name
7802
7888
  change-profile-picture <url> Update your profile picture
7803
- upload <filepath> Upload a file to the MindStudio CDN
7889
+ upload <filepath> Upload a file to the CDN, print its URL (alias: upload-file)
7804
7890
  update Update to the latest version
7805
7891
 
7806
7892
  OAuth integrations:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mindstudio-ai/agent",
3
- "version": "0.1.67",
3
+ "version": "0.1.69",
4
4
  "description": "TypeScript SDK for MindStudio direct step execution",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",