@mindstudio-ai/agent 0.1.140 → 0.1.141
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 +143 -421
- package/dist/index.d.ts +103 -15
- package/dist/index.js +271 -410
- package/dist/index.js.map +1 -1
- package/dist/postinstall.js +143 -421
- 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.
|
|
@@ -11659,7 +11718,9 @@ declare function runWithContext<T>(ctx: RequestContext, fn: () => T | Promise<T>
|
|
|
11659
11718
|
* - `documents([...])` — the object becomes these documents (an array is
|
|
11660
11719
|
* one object → many). Each is `{ externalId, title, markdown, metadata?,
|
|
11661
11720
|
* entities?, replaces? }`; `externalId` is the identity the platform
|
|
11662
|
-
* replaces by.
|
|
11721
|
+
* replaces by. Any number: pass a generator (sync or async) to stream an
|
|
11722
|
+
* export of a million rows without holding it. A document that fails
|
|
11723
|
+
* validation is left out and named; the rest of the object goes in.
|
|
11663
11724
|
* - `passthrough({ metadata?, entities? })` — ingest the raw object itself through
|
|
11664
11725
|
* built-in extraction, as an unmapped source would. What lets a mapped
|
|
11665
11726
|
* source still accept a PDF.
|
|
@@ -11672,10 +11733,14 @@ declare function runWithContext<T>(ctx: RequestContext, fn: () => T | Promise<T>
|
|
|
11672
11733
|
* `defineMapper` returns a CALLABLE — the executor — with the config attached
|
|
11673
11734
|
* (the same pattern as `defineJewel`). The platform runs it as an ordinary
|
|
11674
11735
|
* execution frame: one call maps a slice of objects and returns their
|
|
11675
|
-
* outcomes
|
|
11736
|
+
* outcomes, and stores the documents its objects produce as it goes, a part
|
|
11737
|
+
* of up to a thousand at a time, so a frame's memory holds one part
|
|
11738
|
+
* whatever its objects become. Everything a method can do, a mapper can do — call models via
|
|
11676
11739
|
* `runTask`, `fetch` an external API, read the app's tables — and every call
|
|
11677
11740
|
* is spend per object. The mapper's `map` runs under a per-object timeout
|
|
11678
|
-
* (declared in `mindstudio.json`, default 30 s)
|
|
11741
|
+
* (declared in `mindstudio.json`, default 30 s), which also bounds the wait
|
|
11742
|
+
* for each next document a generator yields; a whole object has the frame's
|
|
11743
|
+
* twenty minutes. The executor never throws.
|
|
11679
11744
|
*
|
|
11680
11745
|
* On a job, mapping is its own stage: the mapper turns each object into
|
|
11681
11746
|
* documents, and the platform ingests those documents in parallel batches of
|
|
@@ -11730,9 +11795,11 @@ interface MappedDocument {
|
|
|
11730
11795
|
/** External ids this document replaces (a writethru's original id). */
|
|
11731
11796
|
replaces?: string | string[];
|
|
11732
11797
|
}
|
|
11798
|
+
/** What `documents()` takes: one document, an array, or any iterable or async iterable. */
|
|
11799
|
+
type MappedDocuments = MappedDocument | Iterable<MappedDocument> | AsyncIterable<MappedDocument>;
|
|
11733
11800
|
type MapOutcome = {
|
|
11734
11801
|
kind: 'documents';
|
|
11735
|
-
documents: MappedDocument
|
|
11802
|
+
documents: Iterable<MappedDocument> | AsyncIterable<MappedDocument>;
|
|
11736
11803
|
} | {
|
|
11737
11804
|
kind: 'passthrough';
|
|
11738
11805
|
metadata?: DocumentMetadata;
|
|
@@ -11757,15 +11824,13 @@ interface MapRunObject {
|
|
|
11757
11824
|
etag: string | null;
|
|
11758
11825
|
lastModified: string | null;
|
|
11759
11826
|
metadata: DocumentMetadata | null;
|
|
11760
|
-
|
|
11761
|
-
entities?: string[] | null;
|
|
11827
|
+
entities: string[] | null;
|
|
11762
11828
|
/** Short-lived read URL for the object's bytes. */
|
|
11763
11829
|
url: string;
|
|
11764
11830
|
/**
|
|
11765
11831
|
* The object's bytes, base64, when the platform already held them (it
|
|
11766
11832
|
* 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.
|
|
11833
|
+
* along). Present, it is the bytes; `url` is the fallback for large objects.
|
|
11769
11834
|
*/
|
|
11770
11835
|
content?: string;
|
|
11771
11836
|
}
|
|
@@ -11776,8 +11841,26 @@ interface MapRunParams {
|
|
|
11776
11841
|
timeoutMs?: number;
|
|
11777
11842
|
/** Objects mapped at once inside the frame. */
|
|
11778
11843
|
concurrency?: number;
|
|
11844
|
+
/** Where the frame's documents are stored, a part at a time. */
|
|
11845
|
+
spill?: {
|
|
11846
|
+
id: string;
|
|
11847
|
+
};
|
|
11779
11848
|
}
|
|
11780
|
-
|
|
11849
|
+
/**
|
|
11850
|
+
* One stored part of a frame's documents: gzipped NDJSON, a line `{ o, i, d }`
|
|
11851
|
+
* per document (the object's index in the frame, the document's index in
|
|
11852
|
+
* that object's output, the document).
|
|
11853
|
+
*/
|
|
11854
|
+
interface MapRunPart {
|
|
11855
|
+
part: number;
|
|
11856
|
+
count: number;
|
|
11857
|
+
}
|
|
11858
|
+
type MapRunOutcome = {
|
|
11859
|
+
kind: 'documents';
|
|
11860
|
+
count: number;
|
|
11861
|
+
} | Exclude<MapOutcome, {
|
|
11862
|
+
kind: 'documents';
|
|
11863
|
+
}> | {
|
|
11781
11864
|
kind: 'error';
|
|
11782
11865
|
error: {
|
|
11783
11866
|
message: string;
|
|
@@ -11794,6 +11877,8 @@ interface MapRunRecord {
|
|
|
11794
11877
|
v: 1;
|
|
11795
11878
|
source: string;
|
|
11796
11879
|
outcomes: MapRunResult[];
|
|
11880
|
+
/** Every document the frame's objects produced, in the order stored. */
|
|
11881
|
+
parts: MapRunPart[];
|
|
11797
11882
|
startedAt: number;
|
|
11798
11883
|
durationMs: number;
|
|
11799
11884
|
}
|
|
@@ -11805,8 +11890,11 @@ interface Mapper {
|
|
|
11805
11890
|
readonly source: string;
|
|
11806
11891
|
readonly config: MapperConfig;
|
|
11807
11892
|
}
|
|
11808
|
-
/**
|
|
11809
|
-
|
|
11893
|
+
/**
|
|
11894
|
+
* The object becomes these documents: one passed bare, an array, or a
|
|
11895
|
+
* generator that yields them, which streams an export of any size.
|
|
11896
|
+
*/
|
|
11897
|
+
declare function documents(list: MappedDocuments): MapOutcome;
|
|
11810
11898
|
/**
|
|
11811
11899
|
* Ingest the raw object itself through built-in extraction. `metadata` and
|
|
11812
11900
|
* `entities`, when given, replace what the origin supplied.
|