@mindstudio-ai/agent 0.1.67 → 0.1.68
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 +88 -6
- package/dist/index.d.ts +91 -1
- package/dist/index.js +80 -0
- package/dist/index.js.map +1 -1
- package/dist/postinstall.js +88 -6
- package/package.json +1 -1
package/dist/postinstall.js
CHANGED
|
@@ -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,8 @@ 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
|
+
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).
|
|
5481
|
+
|
|
5400
5482
|
Table options: \`db.defineTable<T>(name, { unique, defaults })\`.
|
|
5401
5483
|
- \`unique: [['email'], ['userId', 'orgId']]\` \u2014 declares unique constraints (SDK communicates to platform, enables upsert).
|
|
5402
5484
|
- \`defaults: { status: 'pending' }\` \u2014 client-side defaults applied in push() and upsert().
|
|
@@ -5983,7 +6065,7 @@ async function startMcpServer(options) {
|
|
|
5983
6065
|
capabilities: { tools: {} },
|
|
5984
6066
|
serverInfo: {
|
|
5985
6067
|
name: "mindstudio-agent",
|
|
5986
|
-
version: "0.1.
|
|
6068
|
+
version: "0.1.68"
|
|
5987
6069
|
},
|
|
5988
6070
|
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
6071
|
});
|
|
@@ -6859,7 +6941,7 @@ function isNewerVersion(current, latest) {
|
|
|
6859
6941
|
return false;
|
|
6860
6942
|
}
|
|
6861
6943
|
async function checkForUpdate() {
|
|
6862
|
-
const currentVersion = "0.1.
|
|
6944
|
+
const currentVersion = "0.1.68";
|
|
6863
6945
|
if (!currentVersion) return null;
|
|
6864
6946
|
try {
|
|
6865
6947
|
const { loadConfig: loadConfig2, saveConfig: saveConfig2 } = await Promise.resolve().then(() => (init_config(), config_exports));
|
|
@@ -6888,7 +6970,7 @@ async function checkForUpdate() {
|
|
|
6888
6970
|
}
|
|
6889
6971
|
}
|
|
6890
6972
|
function printUpdateNotice(latestVersion) {
|
|
6891
|
-
const currentVersion = "0.1.
|
|
6973
|
+
const currentVersion = "0.1.68";
|
|
6892
6974
|
process.stderr.write(
|
|
6893
6975
|
`
|
|
6894
6976
|
${ansi2.cyanBright("Update available")} ${ansi2.gray(currentVersion + " \u2192")} ${ansi2.cyanBold(latestVersion)}
|
|
@@ -6901,7 +6983,7 @@ function isStandaloneBinary() {
|
|
|
6901
6983
|
return !argv1.includes("node_modules");
|
|
6902
6984
|
}
|
|
6903
6985
|
async function cmdUpdate() {
|
|
6904
|
-
const currentVersion = "0.1.
|
|
6986
|
+
const currentVersion = "0.1.68";
|
|
6905
6987
|
process.stderr.write(
|
|
6906
6988
|
` ${ansi2.gray("Current version:")} ${currentVersion}
|
|
6907
6989
|
`
|
|
@@ -7016,7 +7098,7 @@ async function cmdLogin(options) {
|
|
|
7016
7098
|
process.stderr.write("\n");
|
|
7017
7099
|
printLogo();
|
|
7018
7100
|
process.stderr.write("\n");
|
|
7019
|
-
const ver = "0.1.
|
|
7101
|
+
const ver = "0.1.68";
|
|
7020
7102
|
process.stderr.write(
|
|
7021
7103
|
` ${ansi2.bold("MindStudio Agent")} ${ver ? " " + ansi2.gray("v" + ver) : ""}
|
|
7022
7104
|
`
|
|
@@ -7327,7 +7409,7 @@ async function main() {
|
|
|
7327
7409
|
try {
|
|
7328
7410
|
if (command === "version" || command === "-v") {
|
|
7329
7411
|
process.stdout.write(
|
|
7330
|
-
"0.1.
|
|
7412
|
+
"0.1.68\n"
|
|
7331
7413
|
);
|
|
7332
7414
|
return;
|
|
7333
7415
|
}
|