@mindstudio-ai/agent 0.1.140 → 0.1.142
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 +201 -437
- package/dist/index.d.ts +129 -15
- package/dist/index.js +329 -426
- package/dist/index.js.map +1 -1
- package/dist/postinstall.js +201 -437
- package/llms.txt +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -2543,6 +2543,14 @@ interface AddOptions {
|
|
|
2543
2543
|
* supplying them replaces the whole set, and `[]` clears it.
|
|
2544
2544
|
*/
|
|
2545
2545
|
entities?: string[];
|
|
2546
|
+
/**
|
|
2547
|
+
* On a mapped source, the budget in dollars of the job that takes an
|
|
2548
|
+
* object's documents past the first thousand ({@link AddResult.job}): it
|
|
2549
|
+
* pauses there, and a plan projected over it waits for an approval rather
|
|
2550
|
+
* than starting. Without one the job runs within its plan's projection,
|
|
2551
|
+
* with headroom.
|
|
2552
|
+
*/
|
|
2553
|
+
budgetDollars?: number;
|
|
2546
2554
|
}
|
|
2547
2555
|
/** What {@link DataSource.add} returns. */
|
|
2548
2556
|
interface AddResult {
|
|
@@ -2551,8 +2559,14 @@ interface AddResult {
|
|
|
2551
2559
|
* mapper answered `deletes` — nothing was added.
|
|
2552
2560
|
*/
|
|
2553
2561
|
document: DataSourceDocument | null;
|
|
2554
|
-
/**
|
|
2562
|
+
/**
|
|
2563
|
+
* Every document the bytes became, or the first thousand of an object that
|
|
2564
|
+
* maps to more ({@link job} takes the rest). One entry on an unmapped
|
|
2565
|
+
* source.
|
|
2566
|
+
*/
|
|
2555
2567
|
documents: DataSourceDocument[];
|
|
2568
|
+
/** How many documents the bytes map to in all: `documents.length` unless {@link job} is set. */
|
|
2569
|
+
documentCount: number;
|
|
2556
2570
|
/** Whether any of them was queued for a build (the rest were already current). */
|
|
2557
2571
|
queued: boolean;
|
|
2558
2572
|
/**
|
|
@@ -2562,6 +2576,28 @@ interface AddResult {
|
|
|
2562
2576
|
outcome: 'unmapped' | 'documents' | 'passthrough' | 'deletes';
|
|
2563
2577
|
/** Documents removed or superseded as a result — a `deletes` outcome, a `replaces`. */
|
|
2564
2578
|
removed: number;
|
|
2579
|
+
/**
|
|
2580
|
+
* The documents the mapper produced that failed validation and were not
|
|
2581
|
+
* registered, by their index in its output (`document: 1234` is the
|
|
2582
|
+
* 1,235th it returned or yielded), with why; null when every one passed.
|
|
2583
|
+
* The rest are registered. `add()` throws `mapper_error` only when none
|
|
2584
|
+
* passed.
|
|
2585
|
+
*/
|
|
2586
|
+
invalid: {
|
|
2587
|
+
count: number;
|
|
2588
|
+
examples: {
|
|
2589
|
+
document: number;
|
|
2590
|
+
reason: string;
|
|
2591
|
+
}[];
|
|
2592
|
+
} | null;
|
|
2593
|
+
/**
|
|
2594
|
+
* The job registering and building the rest of an object that maps to more
|
|
2595
|
+
* than a thousand documents; null otherwise. It plans and starts on its own
|
|
2596
|
+
* (within {@link AddOptions.budgetDollars}); follow it with
|
|
2597
|
+
* {@link DataSource.job}. What the object supersedes or retires goes when
|
|
2598
|
+
* the job finishes, once every one of its documents is searchable.
|
|
2599
|
+
*/
|
|
2600
|
+
job: DataSourceJob | null;
|
|
2565
2601
|
}
|
|
2566
2602
|
interface DataSourceDocument {
|
|
2567
2603
|
id: string;
|
|
@@ -2720,8 +2756,9 @@ interface DataSourceJobPlan {
|
|
|
2720
2756
|
}
|
|
2721
2757
|
/**
|
|
2722
2758
|
* A bulk ingestion job — a sync, a corpus load started from the CLI, a remap
|
|
2723
|
-
* of a mapped source's raw copies, a replay of an earlier job's quarantine,
|
|
2724
|
-
*
|
|
2759
|
+
* of a mapped source's raw copies, a replay of an earlier job's quarantine, a
|
|
2760
|
+
* reread of the source's documents by its reader, or the rest of one large
|
|
2761
|
+
* object an {@link DataSource.add} took.
|
|
2725
2762
|
*/
|
|
2726
2763
|
interface DataSourceJob {
|
|
2727
2764
|
id: string;
|
|
@@ -2750,6 +2787,9 @@ interface DataSourceJob {
|
|
|
2750
2787
|
} | {
|
|
2751
2788
|
type: 'reread';
|
|
2752
2789
|
unread: boolean;
|
|
2790
|
+
} | {
|
|
2791
|
+
type: 'object';
|
|
2792
|
+
ref: string;
|
|
2753
2793
|
};
|
|
2754
2794
|
/**
|
|
2755
2795
|
* Objects the mapper skipped or failed on, and documents the reader failed
|
|
@@ -3070,7 +3110,15 @@ declare class DataSource {
|
|
|
3070
3110
|
* as the new one is registered, before its build lands; a search in that
|
|
3071
3111
|
* window sees neither. **Throws `mapper_skipped`** (HTTP 422) when the
|
|
3072
3112
|
* mapper skipped the object — a specific thing it refused, which the caller
|
|
3073
|
-
* should see — and `mapper_error` when the mapper threw
|
|
3113
|
+
* should see — and `mapper_error` when the mapper threw, or when none of
|
|
3114
|
+
* its documents passed validation. A document that fails is left out and
|
|
3115
|
+
* reported in {@link AddResult.invalid}; the rest are registered.
|
|
3116
|
+
*
|
|
3117
|
+
* An object that maps to more than a thousand documents (a large export,
|
|
3118
|
+
* streamed out of the mapper as it parses) registers its first thousand
|
|
3119
|
+
* here and returns {@link AddResult.job}, a job that registers and builds
|
|
3120
|
+
* the rest; `documentCount` says how many there are in all. Another job on
|
|
3121
|
+
* the source refuses it with `data_source_busy`.
|
|
3074
3122
|
*/
|
|
3075
3123
|
add(content: Buffer | Uint8Array | string, options: AddOptions): Promise<AddResult>;
|
|
3076
3124
|
/**
|
|
@@ -3221,6 +3269,17 @@ declare class DataSource {
|
|
|
3221
3269
|
* document has been added.
|
|
3222
3270
|
*/
|
|
3223
3271
|
ensure(name?: string): Promise<void>;
|
|
3272
|
+
/**
|
|
3273
|
+
* @internal A mapper frame's grant to store the next part of its spill: how
|
|
3274
|
+
* `defineMapper`'s executor hands the platform an object's documents a part
|
|
3275
|
+
* at a time once they outgrow the frame's record. Only a mapper frame's
|
|
3276
|
+
* token is granted one.
|
|
3277
|
+
*/
|
|
3278
|
+
_mapSpillGrant(spillId: string): Promise<{
|
|
3279
|
+
part: number;
|
|
3280
|
+
uploadUrl: string;
|
|
3281
|
+
uploadFields: Record<string, string>;
|
|
3282
|
+
}>;
|
|
3224
3283
|
/**
|
|
3225
3284
|
* @internal Content hash of some bytes, matching what the server computes.
|
|
3226
3285
|
* Exposed for callers that want to check whether they already added a file.
|
|
@@ -4110,6 +4169,17 @@ interface RunTaskOptionsBase {
|
|
|
4110
4169
|
model: string;
|
|
4111
4170
|
/** Max loop iterations before forcing final output. Default 20, max 100. */
|
|
4112
4171
|
maxTurns?: number;
|
|
4172
|
+
/**
|
|
4173
|
+
* How much of each tool result reaches the model, in characters of its
|
|
4174
|
+
* JSON. Default 50,000. A larger result is cut to this, and the model gets
|
|
4175
|
+
* a record that says so instead: `{ truncated: true, totalChars, shownChars,
|
|
4176
|
+
* content }`, `content` being the beginning of the result's JSON. The call's
|
|
4177
|
+
* entry in `toolCalls` is marked `truncated` too. Every result stays in the
|
|
4178
|
+
* transcript, which is resent on every later turn, so raising this costs
|
|
4179
|
+
* tokens on every turn after a large result, and the whole transcript has to
|
|
4180
|
+
* fit the model's context window.
|
|
4181
|
+
*/
|
|
4182
|
+
maxToolOutputChars?: number;
|
|
4113
4183
|
/** App ID to execute within. */
|
|
4114
4184
|
appId?: string;
|
|
4115
4185
|
/** Thread ID for state persistence. */
|
|
@@ -4158,6 +4228,8 @@ interface TaskToolCall {
|
|
|
4158
4228
|
name: string;
|
|
4159
4229
|
success: boolean;
|
|
4160
4230
|
durationMs: number;
|
|
4231
|
+
/** The result was over `maxToolOutputChars`, so the model got only its beginning. */
|
|
4232
|
+
truncated?: boolean;
|
|
4161
4233
|
}
|
|
4162
4234
|
/** Usage stats from a task agent execution. */
|
|
4163
4235
|
interface TaskUsage {
|
|
@@ -4179,6 +4251,19 @@ interface RunTaskResult<T = unknown> {
|
|
|
4179
4251
|
parsedSuccessfully: boolean;
|
|
4180
4252
|
/** Number of loop iterations used. */
|
|
4181
4253
|
turns: number;
|
|
4254
|
+
/**
|
|
4255
|
+
* The task used every turn in `maxTurns` and was then asked, with its
|
|
4256
|
+
* tools taken away, for its final output: `output` is whatever it could
|
|
4257
|
+
* say from what it had gathered by then.
|
|
4258
|
+
*/
|
|
4259
|
+
hitMaxTurns: boolean;
|
|
4260
|
+
/**
|
|
4261
|
+
* Why the model stopped on the turn that produced `output`: `end_turn`, or
|
|
4262
|
+
* `max_tokens` when the answer was cut at the output limit (`repetition`
|
|
4263
|
+
* when the platform cut an answer that had begun repeating itself). Null
|
|
4264
|
+
* when that model call failed, and `output` is empty.
|
|
4265
|
+
*/
|
|
4266
|
+
stopReason: string | null;
|
|
4182
4267
|
/** Token and cost usage. */
|
|
4183
4268
|
usage: TaskUsage;
|
|
4184
4269
|
/** Summary of every tool call made during execution. */
|
|
@@ -11659,7 +11744,9 @@ declare function runWithContext<T>(ctx: RequestContext, fn: () => T | Promise<T>
|
|
|
11659
11744
|
* - `documents([...])` — the object becomes these documents (an array is
|
|
11660
11745
|
* one object → many). Each is `{ externalId, title, markdown, metadata?,
|
|
11661
11746
|
* entities?, replaces? }`; `externalId` is the identity the platform
|
|
11662
|
-
* replaces by.
|
|
11747
|
+
* replaces by. Any number: pass a generator (sync or async) to stream an
|
|
11748
|
+
* export of a million rows without holding it. A document that fails
|
|
11749
|
+
* validation is left out and named; the rest of the object goes in.
|
|
11663
11750
|
* - `passthrough({ metadata?, entities? })` — ingest the raw object itself through
|
|
11664
11751
|
* built-in extraction, as an unmapped source would. What lets a mapped
|
|
11665
11752
|
* source still accept a PDF.
|
|
@@ -11672,10 +11759,14 @@ declare function runWithContext<T>(ctx: RequestContext, fn: () => T | Promise<T>
|
|
|
11672
11759
|
* `defineMapper` returns a CALLABLE — the executor — with the config attached
|
|
11673
11760
|
* (the same pattern as `defineJewel`). The platform runs it as an ordinary
|
|
11674
11761
|
* execution frame: one call maps a slice of objects and returns their
|
|
11675
|
-
* outcomes
|
|
11762
|
+
* outcomes, and stores the documents its objects produce as it goes, a part
|
|
11763
|
+
* of up to a thousand at a time, so a frame's memory holds one part
|
|
11764
|
+
* whatever its objects become. Everything a method can do, a mapper can do — call models via
|
|
11676
11765
|
* `runTask`, `fetch` an external API, read the app's tables — and every call
|
|
11677
11766
|
* is spend per object. The mapper's `map` runs under a per-object timeout
|
|
11678
|
-
* (declared in `mindstudio.json`, default 30 s)
|
|
11767
|
+
* (declared in `mindstudio.json`, default 30 s), which also bounds the wait
|
|
11768
|
+
* for each next document a generator yields; a whole object has the frame's
|
|
11769
|
+
* twenty minutes. The executor never throws.
|
|
11679
11770
|
*
|
|
11680
11771
|
* On a job, mapping is its own stage: the mapper turns each object into
|
|
11681
11772
|
* documents, and the platform ingests those documents in parallel batches of
|
|
@@ -11730,9 +11821,11 @@ interface MappedDocument {
|
|
|
11730
11821
|
/** External ids this document replaces (a writethru's original id). */
|
|
11731
11822
|
replaces?: string | string[];
|
|
11732
11823
|
}
|
|
11824
|
+
/** What `documents()` takes: one document, an array, or any iterable or async iterable. */
|
|
11825
|
+
type MappedDocuments = MappedDocument | Iterable<MappedDocument> | AsyncIterable<MappedDocument>;
|
|
11733
11826
|
type MapOutcome = {
|
|
11734
11827
|
kind: 'documents';
|
|
11735
|
-
documents: MappedDocument
|
|
11828
|
+
documents: Iterable<MappedDocument> | AsyncIterable<MappedDocument>;
|
|
11736
11829
|
} | {
|
|
11737
11830
|
kind: 'passthrough';
|
|
11738
11831
|
metadata?: DocumentMetadata;
|
|
@@ -11757,15 +11850,13 @@ interface MapRunObject {
|
|
|
11757
11850
|
etag: string | null;
|
|
11758
11851
|
lastModified: string | null;
|
|
11759
11852
|
metadata: DocumentMetadata | null;
|
|
11760
|
-
|
|
11761
|
-
entities?: string[] | null;
|
|
11853
|
+
entities: string[] | null;
|
|
11762
11854
|
/** Short-lived read URL for the object's bytes. */
|
|
11763
11855
|
url: string;
|
|
11764
11856
|
/**
|
|
11765
11857
|
* The object's bytes, base64, when the platform already held them (it
|
|
11766
11858
|
* hashes and lands every object before mapping, and small objects ride
|
|
11767
|
-
* along). Present, it is the bytes; `url` is the fallback for large objects
|
|
11768
|
-
* and for frames from a platform that predates it.
|
|
11859
|
+
* along). Present, it is the bytes; `url` is the fallback for large objects.
|
|
11769
11860
|
*/
|
|
11770
11861
|
content?: string;
|
|
11771
11862
|
}
|
|
@@ -11776,8 +11867,26 @@ interface MapRunParams {
|
|
|
11776
11867
|
timeoutMs?: number;
|
|
11777
11868
|
/** Objects mapped at once inside the frame. */
|
|
11778
11869
|
concurrency?: number;
|
|
11870
|
+
/** Where the frame's documents are stored, a part at a time. */
|
|
11871
|
+
spill?: {
|
|
11872
|
+
id: string;
|
|
11873
|
+
};
|
|
11779
11874
|
}
|
|
11780
|
-
|
|
11875
|
+
/**
|
|
11876
|
+
* One stored part of a frame's documents: gzipped NDJSON, a line `{ o, i, d }`
|
|
11877
|
+
* per document (the object's index in the frame, the document's index in
|
|
11878
|
+
* that object's output, the document).
|
|
11879
|
+
*/
|
|
11880
|
+
interface MapRunPart {
|
|
11881
|
+
part: number;
|
|
11882
|
+
count: number;
|
|
11883
|
+
}
|
|
11884
|
+
type MapRunOutcome = {
|
|
11885
|
+
kind: 'documents';
|
|
11886
|
+
count: number;
|
|
11887
|
+
} | Exclude<MapOutcome, {
|
|
11888
|
+
kind: 'documents';
|
|
11889
|
+
}> | {
|
|
11781
11890
|
kind: 'error';
|
|
11782
11891
|
error: {
|
|
11783
11892
|
message: string;
|
|
@@ -11794,6 +11903,8 @@ interface MapRunRecord {
|
|
|
11794
11903
|
v: 1;
|
|
11795
11904
|
source: string;
|
|
11796
11905
|
outcomes: MapRunResult[];
|
|
11906
|
+
/** Every document the frame's objects produced, in the order stored. */
|
|
11907
|
+
parts: MapRunPart[];
|
|
11797
11908
|
startedAt: number;
|
|
11798
11909
|
durationMs: number;
|
|
11799
11910
|
}
|
|
@@ -11805,8 +11916,11 @@ interface Mapper {
|
|
|
11805
11916
|
readonly source: string;
|
|
11806
11917
|
readonly config: MapperConfig;
|
|
11807
11918
|
}
|
|
11808
|
-
/**
|
|
11809
|
-
|
|
11919
|
+
/**
|
|
11920
|
+
* The object becomes these documents: one passed bare, an array, or a
|
|
11921
|
+
* generator that yields them, which streams an export of any size.
|
|
11922
|
+
*/
|
|
11923
|
+
declare function documents(list: MappedDocuments): MapOutcome;
|
|
11810
11924
|
/**
|
|
11811
11925
|
* Ingest the raw object itself through built-in extraction. `metadata` and
|
|
11812
11926
|
* `entities`, when given, replace what the origin supplied.
|