@mindstudio-ai/agent 0.1.101 → 0.1.103
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/README.md +6 -0
- package/dist/cli.js +37 -19
- package/dist/index.d.ts +58 -0
- package/dist/index.js +48 -14
- package/dist/index.js.map +1 -1
- package/dist/postinstall.js +37 -19
- package/llms.txt +7 -5
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -22,6 +22,18 @@ interface PutOptions {
|
|
|
22
22
|
* assets baked into source.
|
|
23
23
|
*/
|
|
24
24
|
contentAddressed?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Cache-Control header stored on the object and served by the CDN — this is
|
|
27
|
+
* how you control public-read freshness. Defaults (public stores):
|
|
28
|
+
* auto-minted keys (`key` omitted — UUID or content-addressed, never
|
|
29
|
+
* reused) → `public, max-age=31536000, immutable`; explicitly named
|
|
30
|
+
* (overwritable) keys → `public, max-age=300`, so an overwrite propagates
|
|
31
|
+
* within ~5 minutes. Recipes: `'public, max-age=31536000, immutable'`
|
|
32
|
+
* (content never changes at this key), `'public, max-age=60'` (near-live
|
|
33
|
+
* config), `'no-store'` (revalidate every read). Validated server-side —
|
|
34
|
+
* known directives only.
|
|
35
|
+
*/
|
|
36
|
+
cacheControl?: string;
|
|
25
37
|
}
|
|
26
38
|
/** Options for {@link Store.list}. */
|
|
27
39
|
interface ListOptions {
|
|
@@ -150,6 +162,12 @@ declare class Store {
|
|
|
150
162
|
filename?: string;
|
|
151
163
|
maxSize?: number;
|
|
152
164
|
expiresIn?: number;
|
|
165
|
+
/**
|
|
166
|
+
* Cache-Control header stored on the uploaded object and served by the
|
|
167
|
+
* CDN (see {@link PutOptions.cacheControl}). Public uploads default to
|
|
168
|
+
* `public, max-age=300` server-side.
|
|
169
|
+
*/
|
|
170
|
+
cacheControl?: string;
|
|
153
171
|
}): Promise<UploadToken>;
|
|
154
172
|
private _toFile;
|
|
155
173
|
}
|
|
@@ -1618,10 +1636,20 @@ type JewelMethodInput<M extends JewelMethod> = Parameters<M> extends [] ? undefi
|
|
|
1618
1636
|
interface JewelProposal<I> {
|
|
1619
1637
|
input: I | null;
|
|
1620
1638
|
reasoning: string;
|
|
1639
|
+
/**
|
|
1640
|
+
* Transcript id(s) of the runTask call(s) that constitute this decision
|
|
1641
|
+
* (`task.traceId`; an array for escalation chains). Attaching preserves
|
|
1642
|
+
* the full model transcript with the pair — the training row and, at
|
|
1643
|
+
* auto, the audit trail. Helper/formatting calls stay unattached: the
|
|
1644
|
+
* attachment is the label for which run WAS the decision.
|
|
1645
|
+
*/
|
|
1646
|
+
trace?: string | string[];
|
|
1621
1647
|
}
|
|
1622
1648
|
interface JewelVerdict {
|
|
1623
1649
|
verdict: 'agree' | 'disagree' | 'skip';
|
|
1624
1650
|
notes?: string;
|
|
1651
|
+
/** Transcript id(s) of the judge's runTask call(s), when grade used one. */
|
|
1652
|
+
trace?: string | string[];
|
|
1625
1653
|
}
|
|
1626
1654
|
/**
|
|
1627
1655
|
* Argument to a custom `grade`. `proposed` is null when the jewel abstained;
|
|
@@ -1712,6 +1740,14 @@ interface JewelPairRecord<I = unknown, S = unknown> {
|
|
|
1712
1740
|
message: string;
|
|
1713
1741
|
stack?: string;
|
|
1714
1742
|
};
|
|
1743
|
+
/**
|
|
1744
|
+
* Transcript ids attached by propose. The transcripts themselves live
|
|
1745
|
+
* platform-side, recorded per turn and keyed by (run id, trace id) — the
|
|
1746
|
+
* record carries only the ids.
|
|
1747
|
+
*/
|
|
1748
|
+
trace?: string[];
|
|
1749
|
+
/** Transcript ids attached by a custom grade's verdict. */
|
|
1750
|
+
gradeTrace?: string[];
|
|
1715
1751
|
/**
|
|
1716
1752
|
* Whether this jewel declares a custom `grade`. The platform's deferred
|
|
1717
1753
|
* grading dispatches a grade-mode run when true; when false it grades
|
|
@@ -2561,6 +2597,14 @@ interface RunTaskResult<T = unknown> {
|
|
|
2561
2597
|
usage: TaskUsage;
|
|
2562
2598
|
/** Summary of every tool call made during execution. */
|
|
2563
2599
|
toolCalls: TaskToolCall[];
|
|
2600
|
+
/**
|
|
2601
|
+
* Stable id for this task's model transcript. Inside a jewel, attach it to
|
|
2602
|
+
* the propose/grade return (`trace: task.traceId`) to preserve the full
|
|
2603
|
+
* transcript with the pair — the training row and the audit trail. The
|
|
2604
|
+
* platform records transcripts server-side per turn; only the id rides the
|
|
2605
|
+
* result.
|
|
2606
|
+
*/
|
|
2607
|
+
traceId: string;
|
|
2564
2608
|
}
|
|
2565
2609
|
|
|
2566
2610
|
/**
|
|
@@ -6077,6 +6121,8 @@ interface SearchGoogleStepInput {
|
|
|
6077
6121
|
dateRange?: "hour" | "day" | "week" | "month" | "year" | "any";
|
|
6078
6122
|
/** Number of results to return (1-100, default: 30) */
|
|
6079
6123
|
numResults?: number;
|
|
6124
|
+
/** Read the page content of the first N results in this same step (0-10, default 0 = off), rather than following up with a Scrape URL step per result. Each page is a full scrape, so this costs substantially more than the search alone. */
|
|
6125
|
+
fetchTopN?: number;
|
|
6080
6126
|
}
|
|
6081
6127
|
interface SearchGoogleStepOutput {
|
|
6082
6128
|
/** List of search result entries */
|
|
@@ -6087,7 +6133,17 @@ interface SearchGoogleStepOutput {
|
|
|
6087
6133
|
description: string;
|
|
6088
6134
|
/** URL of the search result page */
|
|
6089
6135
|
url: string;
|
|
6136
|
+
/** Page content, only present when fetchTopN covered this result */
|
|
6137
|
+
content?: string;
|
|
6138
|
+
}[];
|
|
6139
|
+
/** Google's "People also ask" entries, when Google returned any */
|
|
6140
|
+
peopleAlsoAsk?: {
|
|
6141
|
+
question?: string;
|
|
6142
|
+
snippet?: string;
|
|
6143
|
+
link?: string;
|
|
6090
6144
|
}[];
|
|
6145
|
+
/** Google's related-search suggestions, when Google returned any */
|
|
6146
|
+
relatedSearches?: string[];
|
|
6091
6147
|
}
|
|
6092
6148
|
interface SearchGoogleCalendarEventsStepInput {
|
|
6093
6149
|
/** Text search term */
|
|
@@ -9346,6 +9402,8 @@ interface StepMethods {
|
|
|
9346
9402
|
* - Defaults to us/english, but can optionally specify country and/or language.
|
|
9347
9403
|
* - Defaults to any time, but can optionally specify last hour, last day, week, month, or year.
|
|
9348
9404
|
* - Defaults to top 30 results, but can specify 1 to 100 results to return.
|
|
9405
|
+
* - Set fetchTopN to also read the page content of the first N results in the same step, instead of following up with a separate Scrape URL step per result. Costs meaningfully more (each page is a full scrape), so ask for the fewest you need.
|
|
9406
|
+
* - Also returns Google's "people also ask" and related searches when available, which are useful for choosing a follow-up query.
|
|
9349
9407
|
*
|
|
9350
9408
|
* @example
|
|
9351
9409
|
* ```typescript
|
package/dist/index.js
CHANGED
|
@@ -1968,12 +1968,14 @@ var Store = class {
|
|
|
1968
1968
|
async put(content, options) {
|
|
1969
1969
|
const ext = extensionFor(options?.filename);
|
|
1970
1970
|
const key = options?.key ?? (options?.contentAddressed ? `${createHash("sha256").update(content).digest("hex")}${ext}` : `${randomUUID()}${ext}`);
|
|
1971
|
+
const cacheControl = options?.cacheControl ?? (!options?.key && this._access === "public" ? "public, max-age=31536000, immutable" : void 0);
|
|
1971
1972
|
const meta = await this._call("put", {
|
|
1972
1973
|
store: this._store,
|
|
1973
1974
|
access: this._access,
|
|
1974
1975
|
key,
|
|
1975
1976
|
body: toBase64(content),
|
|
1976
|
-
...options?.contentType ? { contentType: options.contentType } : {}
|
|
1977
|
+
...options?.contentType ? { contentType: options.contentType } : {},
|
|
1978
|
+
...cacheControl ? { cacheControl } : {}
|
|
1977
1979
|
});
|
|
1978
1980
|
return this._toFile(key, meta);
|
|
1979
1981
|
}
|
|
@@ -2082,7 +2084,8 @@ var Store = class {
|
|
|
2082
2084
|
key,
|
|
2083
2085
|
...options?.contentType ? { contentType: options.contentType } : {},
|
|
2084
2086
|
...maxSize ? { maxSize } : {},
|
|
2085
|
-
...options?.expiresIn ? { expiresIn: options.expiresIn } : {}
|
|
2087
|
+
...options?.expiresIn ? { expiresIn: options.expiresIn } : {},
|
|
2088
|
+
...options?.cacheControl ? { cacheControl: options.cacheControl } : {}
|
|
2086
2089
|
});
|
|
2087
2090
|
return {
|
|
2088
2091
|
key,
|
|
@@ -2275,6 +2278,9 @@ function createVoice(call) {
|
|
|
2275
2278
|
};
|
|
2276
2279
|
}
|
|
2277
2280
|
|
|
2281
|
+
// src/task/index.ts
|
|
2282
|
+
import { randomUUID as randomUUID2 } from "crypto";
|
|
2283
|
+
|
|
2278
2284
|
// src/generated/metadata.ts
|
|
2279
2285
|
var stepMetadata = {
|
|
2280
2286
|
"activeCampaignAddNote": {
|
|
@@ -3169,9 +3175,13 @@ var stepMetadata = {
|
|
|
3169
3175
|
"searchGoogle": {
|
|
3170
3176
|
stepType: "searchGoogle",
|
|
3171
3177
|
description: "Search the web using Google and return structured results.",
|
|
3172
|
-
usageNotes:
|
|
3173
|
-
|
|
3174
|
-
|
|
3178
|
+
usageNotes: `- Defaults to us/english, but can optionally specify country and/or language.
|
|
3179
|
+
- Defaults to any time, but can optionally specify last hour, last day, week, month, or year.
|
|
3180
|
+
- Defaults to top 30 results, but can specify 1 to 100 results to return.
|
|
3181
|
+
- Set fetchTopN to also read the page content of the first N results in the same step, instead of following up with a separate Scrape URL step per result. Costs meaningfully more (each page is a full scrape), so ask for the fewest you need.
|
|
3182
|
+
- Also returns Google's "people also ask" and related searches when available, which are useful for choosing a follow-up query.`,
|
|
3183
|
+
inputSchema: { "type": "object", "properties": { "query": { "type": "string", "description": "The search query to send to Google" }, "exportType": { "enum": ["text", "json"], "type": "string", "description": 'Format for the variable value: "text" or "json"' }, "countryCode": { "type": "string", "description": "Google gl country code (defaults to US)" }, "languageCode": { "type": "string", "description": 'Google hl language code (defaults to "en")' }, "dateRange": { "enum": ["hour", "day", "week", "month", "year", "any"], "type": "string", "description": 'Time range filter: "hour", "day", "week", "month", "year", or "any"' }, "numResults": { "type": "number", "description": "Number of results to return (1-100, default: 30)" }, "fetchTopN": { "type": "number", "description": "Read the page content of the first N results in this same step (0-10, default 0 = off), rather than following up with a Scrape URL step per result. Each page is a full scrape, so this costs substantially more than the search alone." } }, "required": ["query", "exportType"] },
|
|
3184
|
+
outputSchema: { "type": "object", "properties": { "results": { "type": "array", "items": { "type": "object", "properties": { "title": { "type": "string", "description": "Title of the search result" }, "description": { "type": "string", "description": "Snippet/description of the search result" }, "url": { "type": "string", "description": "URL of the search result page" }, "content": { "type": "string", "description": "Page content, only present when fetchTopN covered this result" } }, "required": ["title", "description", "url"] }, "description": "List of search result entries" }, "peopleAlsoAsk": { "type": "array", "items": { "type": "object", "properties": { "question": { "type": "string" }, "snippet": { "type": "string" }, "link": { "type": "string" } } }, "description": `Google's "People also ask" entries, when Google returned any` }, "relatedSearches": { "type": "array", "items": { "type": "string" }, "description": "Google's related-search suggestions, when Google returned any" } }, "required": ["results"] }
|
|
3175
3185
|
},
|
|
3176
3186
|
"searchGoogleCalendarEvents": {
|
|
3177
3187
|
stepType: "searchGoogleCalendarEvents",
|
|
@@ -3747,6 +3757,7 @@ function logTaskResult(result) {
|
|
|
3747
3757
|
);
|
|
3748
3758
|
}
|
|
3749
3759
|
async function runTaskPoll(httpConfig, body) {
|
|
3760
|
+
const traceId = randomUUID2();
|
|
3750
3761
|
const { data } = await request(
|
|
3751
3762
|
httpConfig,
|
|
3752
3763
|
"POST",
|
|
@@ -3805,13 +3816,15 @@ async function runTaskPoll(httpConfig, body) {
|
|
|
3805
3816
|
outputTokens: 0,
|
|
3806
3817
|
totalBillingCost: 0
|
|
3807
3818
|
},
|
|
3808
|
-
toolCalls: poll.toolCalls ?? []
|
|
3819
|
+
toolCalls: poll.toolCalls ?? [],
|
|
3820
|
+
traceId
|
|
3809
3821
|
};
|
|
3810
3822
|
logTaskResult(result);
|
|
3811
3823
|
return result;
|
|
3812
3824
|
}
|
|
3813
3825
|
}
|
|
3814
3826
|
async function runTaskStream(httpConfig, body, onEvent) {
|
|
3827
|
+
const traceId = randomUUID2();
|
|
3815
3828
|
const url = `${httpConfig.baseUrl}/developer/v2/task`;
|
|
3816
3829
|
const res = await fetch(url, {
|
|
3817
3830
|
method: "POST",
|
|
@@ -3876,7 +3889,8 @@ async function runTaskStream(httpConfig, body, onEvent) {
|
|
|
3876
3889
|
outputTokens: 0,
|
|
3877
3890
|
totalBillingCost: 0
|
|
3878
3891
|
},
|
|
3879
|
-
toolCalls: event.toolCalls ?? []
|
|
3892
|
+
toolCalls: event.toolCalls ?? [],
|
|
3893
|
+
traceId
|
|
3880
3894
|
};
|
|
3881
3895
|
}
|
|
3882
3896
|
} catch (err) {
|
|
@@ -3906,7 +3920,8 @@ async function runTaskStream(httpConfig, body, onEvent) {
|
|
|
3906
3920
|
outputTokens: 0,
|
|
3907
3921
|
totalBillingCost: 0
|
|
3908
3922
|
},
|
|
3909
|
-
toolCalls: event.toolCalls ?? []
|
|
3923
|
+
toolCalls: event.toolCalls ?? [],
|
|
3924
|
+
traceId
|
|
3910
3925
|
};
|
|
3911
3926
|
}
|
|
3912
3927
|
} catch (err) {
|
|
@@ -3925,6 +3940,7 @@ async function runTaskStream(httpConfig, body, onEvent) {
|
|
|
3925
3940
|
}
|
|
3926
3941
|
|
|
3927
3942
|
// src/task/local.ts
|
|
3943
|
+
import { randomUUID as randomUUID3 } from "crypto";
|
|
3928
3944
|
var DEFAULT_MAX_TURNS = 20;
|
|
3929
3945
|
var MAX_TURNS_LIMIT = 100;
|
|
3930
3946
|
var MAX_SCHEMA_REPAIR_ATTEMPTS = 3;
|
|
@@ -4156,6 +4172,7 @@ ${structuredOutputExample}
|
|
|
4156
4172
|
Math.max(options.maxTurns || DEFAULT_MAX_TURNS, 1),
|
|
4157
4173
|
MAX_TURNS_LIMIT
|
|
4158
4174
|
);
|
|
4175
|
+
const traceId = randomUUID3();
|
|
4159
4176
|
const messages = [
|
|
4160
4177
|
{ role: "user", content: JSON.stringify(options.input) }
|
|
4161
4178
|
];
|
|
@@ -4175,7 +4192,8 @@ ${structuredOutputExample}
|
|
|
4175
4192
|
parsedSuccessfully: parsedSuccessfully2,
|
|
4176
4193
|
turns,
|
|
4177
4194
|
usage: totalUsage,
|
|
4178
|
-
toolCalls: toolCallLog
|
|
4195
|
+
toolCalls: toolCallLog,
|
|
4196
|
+
traceId
|
|
4179
4197
|
});
|
|
4180
4198
|
const accumulate = (turn) => {
|
|
4181
4199
|
totalUsage.inputTokens += turn.usage.inputTokens ?? 0;
|
|
@@ -4243,7 +4261,8 @@ ${structuredOutputExample}
|
|
|
4243
4261
|
model: options.model,
|
|
4244
4262
|
system,
|
|
4245
4263
|
messages,
|
|
4246
|
-
tools: wireTools
|
|
4264
|
+
tools: wireTools,
|
|
4265
|
+
traceId
|
|
4247
4266
|
});
|
|
4248
4267
|
} catch (err) {
|
|
4249
4268
|
if (loopCount === 1 && err instanceof TurnError && err.status === 404 && err.errorCode === "not_found") {
|
|
@@ -4355,7 +4374,8 @@ ${formatValidationErrors(errors)}`
|
|
|
4355
4374
|
model: options.model,
|
|
4356
4375
|
system,
|
|
4357
4376
|
messages,
|
|
4358
|
-
tools: []
|
|
4377
|
+
tools: [],
|
|
4378
|
+
traceId
|
|
4359
4379
|
});
|
|
4360
4380
|
accumulate(turn);
|
|
4361
4381
|
finalText = turn.text;
|
|
@@ -6647,15 +6667,24 @@ function defineJewel(method, config) {
|
|
|
6647
6667
|
durationMs: Date.now() - startedAt,
|
|
6648
6668
|
...rest
|
|
6649
6669
|
});
|
|
6670
|
+
const traceIds = (t) => {
|
|
6671
|
+
if (t === void 0) return void 0;
|
|
6672
|
+
const ids = (Array.isArray(t) ? t : [t]).filter(
|
|
6673
|
+
(id) => typeof id === "string" && id.length > 0
|
|
6674
|
+
);
|
|
6675
|
+
return ids.length > 0 ? ids : void 0;
|
|
6676
|
+
};
|
|
6650
6677
|
if (Object.prototype.hasOwnProperty.call(params, "grade")) {
|
|
6651
6678
|
const ctx = params.grade;
|
|
6652
6679
|
const verdict2 = await runGrade(ctx.proposed, ctx.actual);
|
|
6680
|
+
const gradeTrace2 = traceIds(verdict2.trace);
|
|
6653
6681
|
return done({
|
|
6654
6682
|
mode: "grade",
|
|
6655
6683
|
proposed: ctx.proposed,
|
|
6656
6684
|
actual: ctx.actual,
|
|
6657
6685
|
verdict: verdict2.verdict,
|
|
6658
|
-
...verdict2.notes !== void 0 ? { notes: verdict2.notes } : {}
|
|
6686
|
+
...verdict2.notes !== void 0 ? { notes: verdict2.notes } : {},
|
|
6687
|
+
...gradeTrace2 ? { gradeTrace: gradeTrace2 } : {}
|
|
6659
6688
|
});
|
|
6660
6689
|
}
|
|
6661
6690
|
const isShadow = Object.prototype.hasOwnProperty.call(params, "humanInput");
|
|
@@ -6682,15 +6711,18 @@ function defineJewel(method, config) {
|
|
|
6682
6711
|
error: { phase: "propose", ...errorInfo(e) }
|
|
6683
6712
|
});
|
|
6684
6713
|
}
|
|
6714
|
+
const trace = traceIds(proposal.trace);
|
|
6685
6715
|
if (!isShadow) {
|
|
6686
6716
|
return done({
|
|
6687
6717
|
mode,
|
|
6688
6718
|
subject,
|
|
6689
6719
|
proposed: proposal.input,
|
|
6690
|
-
reasoning: proposal.reasoning
|
|
6720
|
+
reasoning: proposal.reasoning,
|
|
6721
|
+
...trace ? { trace } : {}
|
|
6691
6722
|
});
|
|
6692
6723
|
}
|
|
6693
6724
|
const verdict = await runGrade(proposal.input, actual);
|
|
6725
|
+
const gradeTrace = traceIds(verdict.trace);
|
|
6694
6726
|
return done({
|
|
6695
6727
|
mode,
|
|
6696
6728
|
subject,
|
|
@@ -6698,7 +6730,9 @@ function defineJewel(method, config) {
|
|
|
6698
6730
|
reasoning: proposal.reasoning,
|
|
6699
6731
|
actual,
|
|
6700
6732
|
verdict: verdict.verdict,
|
|
6701
|
-
...verdict.notes !== void 0 ? { notes: verdict.notes } : {}
|
|
6733
|
+
...verdict.notes !== void 0 ? { notes: verdict.notes } : {},
|
|
6734
|
+
...trace ? { trace } : {},
|
|
6735
|
+
...gradeTrace ? { gradeTrace } : {}
|
|
6702
6736
|
});
|
|
6703
6737
|
};
|
|
6704
6738
|
return Object.assign(run, {
|