@mindstudio-ai/agent 0.1.101 → 0.1.102
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 +30 -16
- package/dist/index.d.ts +44 -0
- package/dist/index.js +41 -11
- package/dist/index.js.map +1 -1
- package/dist/postinstall.js +30 -16
- package/llms.txt +3 -3
- 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
|
/**
|
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": {
|
|
@@ -3747,6 +3753,7 @@ function logTaskResult(result) {
|
|
|
3747
3753
|
);
|
|
3748
3754
|
}
|
|
3749
3755
|
async function runTaskPoll(httpConfig, body) {
|
|
3756
|
+
const traceId = randomUUID2();
|
|
3750
3757
|
const { data } = await request(
|
|
3751
3758
|
httpConfig,
|
|
3752
3759
|
"POST",
|
|
@@ -3805,13 +3812,15 @@ async function runTaskPoll(httpConfig, body) {
|
|
|
3805
3812
|
outputTokens: 0,
|
|
3806
3813
|
totalBillingCost: 0
|
|
3807
3814
|
},
|
|
3808
|
-
toolCalls: poll.toolCalls ?? []
|
|
3815
|
+
toolCalls: poll.toolCalls ?? [],
|
|
3816
|
+
traceId
|
|
3809
3817
|
};
|
|
3810
3818
|
logTaskResult(result);
|
|
3811
3819
|
return result;
|
|
3812
3820
|
}
|
|
3813
3821
|
}
|
|
3814
3822
|
async function runTaskStream(httpConfig, body, onEvent) {
|
|
3823
|
+
const traceId = randomUUID2();
|
|
3815
3824
|
const url = `${httpConfig.baseUrl}/developer/v2/task`;
|
|
3816
3825
|
const res = await fetch(url, {
|
|
3817
3826
|
method: "POST",
|
|
@@ -3876,7 +3885,8 @@ async function runTaskStream(httpConfig, body, onEvent) {
|
|
|
3876
3885
|
outputTokens: 0,
|
|
3877
3886
|
totalBillingCost: 0
|
|
3878
3887
|
},
|
|
3879
|
-
toolCalls: event.toolCalls ?? []
|
|
3888
|
+
toolCalls: event.toolCalls ?? [],
|
|
3889
|
+
traceId
|
|
3880
3890
|
};
|
|
3881
3891
|
}
|
|
3882
3892
|
} catch (err) {
|
|
@@ -3906,7 +3916,8 @@ async function runTaskStream(httpConfig, body, onEvent) {
|
|
|
3906
3916
|
outputTokens: 0,
|
|
3907
3917
|
totalBillingCost: 0
|
|
3908
3918
|
},
|
|
3909
|
-
toolCalls: event.toolCalls ?? []
|
|
3919
|
+
toolCalls: event.toolCalls ?? [],
|
|
3920
|
+
traceId
|
|
3910
3921
|
};
|
|
3911
3922
|
}
|
|
3912
3923
|
} catch (err) {
|
|
@@ -3925,6 +3936,7 @@ async function runTaskStream(httpConfig, body, onEvent) {
|
|
|
3925
3936
|
}
|
|
3926
3937
|
|
|
3927
3938
|
// src/task/local.ts
|
|
3939
|
+
import { randomUUID as randomUUID3 } from "crypto";
|
|
3928
3940
|
var DEFAULT_MAX_TURNS = 20;
|
|
3929
3941
|
var MAX_TURNS_LIMIT = 100;
|
|
3930
3942
|
var MAX_SCHEMA_REPAIR_ATTEMPTS = 3;
|
|
@@ -4156,6 +4168,7 @@ ${structuredOutputExample}
|
|
|
4156
4168
|
Math.max(options.maxTurns || DEFAULT_MAX_TURNS, 1),
|
|
4157
4169
|
MAX_TURNS_LIMIT
|
|
4158
4170
|
);
|
|
4171
|
+
const traceId = randomUUID3();
|
|
4159
4172
|
const messages = [
|
|
4160
4173
|
{ role: "user", content: JSON.stringify(options.input) }
|
|
4161
4174
|
];
|
|
@@ -4175,7 +4188,8 @@ ${structuredOutputExample}
|
|
|
4175
4188
|
parsedSuccessfully: parsedSuccessfully2,
|
|
4176
4189
|
turns,
|
|
4177
4190
|
usage: totalUsage,
|
|
4178
|
-
toolCalls: toolCallLog
|
|
4191
|
+
toolCalls: toolCallLog,
|
|
4192
|
+
traceId
|
|
4179
4193
|
});
|
|
4180
4194
|
const accumulate = (turn) => {
|
|
4181
4195
|
totalUsage.inputTokens += turn.usage.inputTokens ?? 0;
|
|
@@ -4243,7 +4257,8 @@ ${structuredOutputExample}
|
|
|
4243
4257
|
model: options.model,
|
|
4244
4258
|
system,
|
|
4245
4259
|
messages,
|
|
4246
|
-
tools: wireTools
|
|
4260
|
+
tools: wireTools,
|
|
4261
|
+
traceId
|
|
4247
4262
|
});
|
|
4248
4263
|
} catch (err) {
|
|
4249
4264
|
if (loopCount === 1 && err instanceof TurnError && err.status === 404 && err.errorCode === "not_found") {
|
|
@@ -4355,7 +4370,8 @@ ${formatValidationErrors(errors)}`
|
|
|
4355
4370
|
model: options.model,
|
|
4356
4371
|
system,
|
|
4357
4372
|
messages,
|
|
4358
|
-
tools: []
|
|
4373
|
+
tools: [],
|
|
4374
|
+
traceId
|
|
4359
4375
|
});
|
|
4360
4376
|
accumulate(turn);
|
|
4361
4377
|
finalText = turn.text;
|
|
@@ -6647,15 +6663,24 @@ function defineJewel(method, config) {
|
|
|
6647
6663
|
durationMs: Date.now() - startedAt,
|
|
6648
6664
|
...rest
|
|
6649
6665
|
});
|
|
6666
|
+
const traceIds = (t) => {
|
|
6667
|
+
if (t === void 0) return void 0;
|
|
6668
|
+
const ids = (Array.isArray(t) ? t : [t]).filter(
|
|
6669
|
+
(id) => typeof id === "string" && id.length > 0
|
|
6670
|
+
);
|
|
6671
|
+
return ids.length > 0 ? ids : void 0;
|
|
6672
|
+
};
|
|
6650
6673
|
if (Object.prototype.hasOwnProperty.call(params, "grade")) {
|
|
6651
6674
|
const ctx = params.grade;
|
|
6652
6675
|
const verdict2 = await runGrade(ctx.proposed, ctx.actual);
|
|
6676
|
+
const gradeTrace2 = traceIds(verdict2.trace);
|
|
6653
6677
|
return done({
|
|
6654
6678
|
mode: "grade",
|
|
6655
6679
|
proposed: ctx.proposed,
|
|
6656
6680
|
actual: ctx.actual,
|
|
6657
6681
|
verdict: verdict2.verdict,
|
|
6658
|
-
...verdict2.notes !== void 0 ? { notes: verdict2.notes } : {}
|
|
6682
|
+
...verdict2.notes !== void 0 ? { notes: verdict2.notes } : {},
|
|
6683
|
+
...gradeTrace2 ? { gradeTrace: gradeTrace2 } : {}
|
|
6659
6684
|
});
|
|
6660
6685
|
}
|
|
6661
6686
|
const isShadow = Object.prototype.hasOwnProperty.call(params, "humanInput");
|
|
@@ -6682,15 +6707,18 @@ function defineJewel(method, config) {
|
|
|
6682
6707
|
error: { phase: "propose", ...errorInfo(e) }
|
|
6683
6708
|
});
|
|
6684
6709
|
}
|
|
6710
|
+
const trace = traceIds(proposal.trace);
|
|
6685
6711
|
if (!isShadow) {
|
|
6686
6712
|
return done({
|
|
6687
6713
|
mode,
|
|
6688
6714
|
subject,
|
|
6689
6715
|
proposed: proposal.input,
|
|
6690
|
-
reasoning: proposal.reasoning
|
|
6716
|
+
reasoning: proposal.reasoning,
|
|
6717
|
+
...trace ? { trace } : {}
|
|
6691
6718
|
});
|
|
6692
6719
|
}
|
|
6693
6720
|
const verdict = await runGrade(proposal.input, actual);
|
|
6721
|
+
const gradeTrace = traceIds(verdict.trace);
|
|
6694
6722
|
return done({
|
|
6695
6723
|
mode,
|
|
6696
6724
|
subject,
|
|
@@ -6698,7 +6726,9 @@ function defineJewel(method, config) {
|
|
|
6698
6726
|
reasoning: proposal.reasoning,
|
|
6699
6727
|
actual,
|
|
6700
6728
|
verdict: verdict.verdict,
|
|
6701
|
-
...verdict.notes !== void 0 ? { notes: verdict.notes } : {}
|
|
6729
|
+
...verdict.notes !== void 0 ? { notes: verdict.notes } : {},
|
|
6730
|
+
...trace ? { trace } : {},
|
|
6731
|
+
...gradeTrace ? { gradeTrace } : {}
|
|
6702
6732
|
});
|
|
6703
6733
|
};
|
|
6704
6734
|
return Object.assign(run, {
|