@mindstudio-ai/agent 0.1.119 → 0.1.121
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 +62 -13
- package/dist/index.d.ts +56 -5
- package/dist/index.js +58 -7
- package/dist/index.js.map +1 -1
- package/dist/postinstall.js +62 -13
- package/llms.txt +6 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -2521,6 +2521,12 @@ interface DataSourceDocument {
|
|
|
2521
2521
|
createdAt: string;
|
|
2522
2522
|
ingestedAt: string | null;
|
|
2523
2523
|
}
|
|
2524
|
+
/** One page of a corpus. See {@link DataSource.documentsPage}. */
|
|
2525
|
+
interface DataSourceDocumentPage {
|
|
2526
|
+
documents: DataSourceDocument[];
|
|
2527
|
+
/** Pass to the next call; null when this was the last page. */
|
|
2528
|
+
nextCursor: string | null;
|
|
2529
|
+
}
|
|
2524
2530
|
/** One chunk exactly as it was indexed. See {@link DataSource.chunks}. */
|
|
2525
2531
|
interface DataSourceChunk {
|
|
2526
2532
|
index: number;
|
|
@@ -2749,6 +2755,13 @@ declare class DataSource {
|
|
|
2749
2755
|
* corpora reload inside the search and never raise it. Sources on dedicated
|
|
2750
2756
|
* capacity are never evicted, so they never raise it either; they raise
|
|
2751
2757
|
* `capacity_hibernated` and friends instead when their capacity is parked.
|
|
2758
|
+
*
|
|
2759
|
+
* **Throws `index_building`** (HTTP 503) on dedicated capacity while a bulk
|
|
2760
|
+
* load runs and after one finishes: the index is not built behind every
|
|
2761
|
+
* write during a load, it is built once at the end, and until then a search
|
|
2762
|
+
* would scan the corpus unindexed. The message carries "N of M vectors
|
|
2763
|
+
* indexed". Handle it like `index_warming`: the knowledge base is being
|
|
2764
|
+
* built, never empty; say so and retry later.
|
|
2752
2765
|
*/
|
|
2753
2766
|
search(query: string, options?: SearchOptions): Promise<{
|
|
2754
2767
|
results: SearchHit[];
|
|
@@ -2821,16 +2834,41 @@ declare class DataSource {
|
|
|
2821
2834
|
/**
|
|
2822
2835
|
* Documents in the corpus, with ingest status.
|
|
2823
2836
|
*
|
|
2824
|
-
* Without options this is the first
|
|
2825
|
-
* a small corpus
|
|
2826
|
-
*
|
|
2827
|
-
* queued, pass the ids it returned:
|
|
2828
|
-
* at most two hundred per call.
|
|
2837
|
+
* Without options this is the first page only: the oldest thousand, enough
|
|
2838
|
+
* to show a small corpus. To walk a corpus of any size use
|
|
2839
|
+
* {@link allDocuments} (or {@link documentsPage} for one page at a time). To
|
|
2840
|
+
* follow what {@link add} just queued, pass the ids it returned:
|
|
2841
|
+
* `documents({ ids })` answers only those, at most two hundred per call.
|
|
2829
2842
|
*/
|
|
2830
2843
|
documents(options?: {
|
|
2831
2844
|
/** Only these documents (at most 200). */
|
|
2832
2845
|
ids?: string[];
|
|
2833
2846
|
}): Promise<DataSourceDocument[]>;
|
|
2847
|
+
/**
|
|
2848
|
+
* One page of the corpus, oldest first, with the cursor for the next page.
|
|
2849
|
+
* `limit` is at most 1,000 (the default).
|
|
2850
|
+
*/
|
|
2851
|
+
documentsPage(options?: {
|
|
2852
|
+
cursor?: string | null;
|
|
2853
|
+
limit?: number;
|
|
2854
|
+
}): Promise<DataSourceDocumentPage>;
|
|
2855
|
+
/**
|
|
2856
|
+
* Every document in the corpus, oldest first, a page at a time behind the
|
|
2857
|
+
* scenes. This is how an app builds its own view of a large corpus (a
|
|
2858
|
+
* timeline, counts by year, a table of ids) after an ingest: walk it once,
|
|
2859
|
+
* then keep up with what each sync adds. Millions of documents is thousands
|
|
2860
|
+
* of pages, so run it in a background task, not a request.
|
|
2861
|
+
*
|
|
2862
|
+
* ```ts
|
|
2863
|
+
* for await (const doc of Archive.allDocuments()) {
|
|
2864
|
+
* await index.upsert({ id: doc.id, year: doc.metadata?.year });
|
|
2865
|
+
* }
|
|
2866
|
+
* ```
|
|
2867
|
+
*/
|
|
2868
|
+
allDocuments(options?: {
|
|
2869
|
+
/** Documents per page, at most 1,000 (the default). */
|
|
2870
|
+
pageSize?: number;
|
|
2871
|
+
}): AsyncGenerator<DataSourceDocument, void, undefined>;
|
|
2834
2872
|
/** Remove a document and its vectors. */
|
|
2835
2873
|
remove(documentId: string): Promise<void>;
|
|
2836
2874
|
/**
|
|
@@ -2886,6 +2924,12 @@ declare class DataSource {
|
|
|
2886
2924
|
sync(options?: {
|
|
2887
2925
|
/** Override the connector's per-sync budget for this run, in dollars. */
|
|
2888
2926
|
budgetDollars?: number;
|
|
2927
|
+
/**
|
|
2928
|
+
* Embed at the provider's priority tier for this run: calls are admitted
|
|
2929
|
+
* ahead of the provider's queue at 1.5x the embedding price. For the sync
|
|
2930
|
+
* where the clock matters more than the price; off by default.
|
|
2931
|
+
*/
|
|
2932
|
+
priority?: boolean;
|
|
2889
2933
|
}): Promise<{
|
|
2890
2934
|
job: DataSourceJob;
|
|
2891
2935
|
}>;
|
|
@@ -11817,6 +11861,13 @@ interface MapRunObject {
|
|
|
11817
11861
|
metadata: DocumentMetadata | null;
|
|
11818
11862
|
/** Short-lived read URL for the object's bytes. */
|
|
11819
11863
|
url: string;
|
|
11864
|
+
/**
|
|
11865
|
+
* The object's bytes, base64, when the platform already held them (it
|
|
11866
|
+
* hashes and lands every object before mapping, and small objects ride
|
|
11867
|
+
* along). Present, it is the bytes; `url` is the fallback for large objects
|
|
11868
|
+
* and for frames from a platform that predates it.
|
|
11869
|
+
*/
|
|
11870
|
+
content?: string;
|
|
11820
11871
|
}
|
|
11821
11872
|
interface MapRunParams {
|
|
11822
11873
|
v: 1;
|
package/dist/index.js
CHANGED
|
@@ -2874,6 +2874,13 @@ var DataSource = class {
|
|
|
2874
2874
|
* corpora reload inside the search and never raise it. Sources on dedicated
|
|
2875
2875
|
* capacity are never evicted, so they never raise it either; they raise
|
|
2876
2876
|
* `capacity_hibernated` and friends instead when their capacity is parked.
|
|
2877
|
+
*
|
|
2878
|
+
* **Throws `index_building`** (HTTP 503) on dedicated capacity while a bulk
|
|
2879
|
+
* load runs and after one finishes: the index is not built behind every
|
|
2880
|
+
* write during a load, it is built once at the end, and until then a search
|
|
2881
|
+
* would scan the corpus unindexed. The message carries "N of M vectors
|
|
2882
|
+
* indexed". Handle it like `index_warming`: the knowledge base is being
|
|
2883
|
+
* built, never empty; say so and retry later.
|
|
2877
2884
|
*/
|
|
2878
2885
|
async search(query, options) {
|
|
2879
2886
|
const { results, mode, latencyMs } = await this._call("search", {
|
|
@@ -2979,11 +2986,11 @@ var DataSource = class {
|
|
|
2979
2986
|
/**
|
|
2980
2987
|
* Documents in the corpus, with ingest status.
|
|
2981
2988
|
*
|
|
2982
|
-
* Without options this is the first
|
|
2983
|
-
* a small corpus
|
|
2984
|
-
*
|
|
2985
|
-
* queued, pass the ids it returned:
|
|
2986
|
-
* at most two hundred per call.
|
|
2989
|
+
* Without options this is the first page only: the oldest thousand, enough
|
|
2990
|
+
* to show a small corpus. To walk a corpus of any size use
|
|
2991
|
+
* {@link allDocuments} (or {@link documentsPage} for one page at a time). To
|
|
2992
|
+
* follow what {@link add} just queued, pass the ids it returned:
|
|
2993
|
+
* `documents({ ids })` answers only those, at most two hundred per call.
|
|
2987
2994
|
*/
|
|
2988
2995
|
async documents(options) {
|
|
2989
2996
|
const { documents: documents2 } = await this._call("documents", {
|
|
@@ -2992,6 +2999,47 @@ var DataSource = class {
|
|
|
2992
2999
|
});
|
|
2993
3000
|
return documents2 ?? [];
|
|
2994
3001
|
}
|
|
3002
|
+
/**
|
|
3003
|
+
* One page of the corpus, oldest first, with the cursor for the next page.
|
|
3004
|
+
* `limit` is at most 1,000 (the default).
|
|
3005
|
+
*/
|
|
3006
|
+
async documentsPage(options) {
|
|
3007
|
+
const { documents: documents2, nextCursor } = await this._call("documents", {
|
|
3008
|
+
slug: this._slug,
|
|
3009
|
+
...options?.cursor ? { cursor: options.cursor } : {},
|
|
3010
|
+
...options?.limit ? { limit: options.limit } : {}
|
|
3011
|
+
});
|
|
3012
|
+
return { documents: documents2 ?? [], nextCursor: nextCursor ?? null };
|
|
3013
|
+
}
|
|
3014
|
+
/**
|
|
3015
|
+
* Every document in the corpus, oldest first, a page at a time behind the
|
|
3016
|
+
* scenes. This is how an app builds its own view of a large corpus (a
|
|
3017
|
+
* timeline, counts by year, a table of ids) after an ingest: walk it once,
|
|
3018
|
+
* then keep up with what each sync adds. Millions of documents is thousands
|
|
3019
|
+
* of pages, so run it in a background task, not a request.
|
|
3020
|
+
*
|
|
3021
|
+
* ```ts
|
|
3022
|
+
* for await (const doc of Archive.allDocuments()) {
|
|
3023
|
+
* await index.upsert({ id: doc.id, year: doc.metadata?.year });
|
|
3024
|
+
* }
|
|
3025
|
+
* ```
|
|
3026
|
+
*/
|
|
3027
|
+
async *allDocuments(options) {
|
|
3028
|
+
let cursor = null;
|
|
3029
|
+
while (true) {
|
|
3030
|
+
const page = await this.documentsPage({
|
|
3031
|
+
cursor,
|
|
3032
|
+
...options?.pageSize ? { limit: options.pageSize } : {}
|
|
3033
|
+
});
|
|
3034
|
+
for (const doc of page.documents) {
|
|
3035
|
+
yield doc;
|
|
3036
|
+
}
|
|
3037
|
+
if (!page.nextCursor || page.documents.length === 0) {
|
|
3038
|
+
return;
|
|
3039
|
+
}
|
|
3040
|
+
cursor = page.nextCursor;
|
|
3041
|
+
}
|
|
3042
|
+
}
|
|
2995
3043
|
/** Remove a document and its vectors. */
|
|
2996
3044
|
async remove(documentId) {
|
|
2997
3045
|
await this._call("remove", { slug: this._slug, documentId });
|
|
@@ -3061,7 +3109,8 @@ var DataSource = class {
|
|
|
3061
3109
|
async sync(options) {
|
|
3062
3110
|
return this._call("sync", {
|
|
3063
3111
|
slug: this._slug,
|
|
3064
|
-
...options?.budgetDollars !== void 0 ? { budgetDollars: options.budgetDollars } : {}
|
|
3112
|
+
...options?.budgetDollars !== void 0 ? { budgetDollars: options.budgetDollars } : {},
|
|
3113
|
+
...options?.priority ? { priority: true } : {}
|
|
3065
3114
|
});
|
|
3066
3115
|
}
|
|
3067
3116
|
/** Recent ingestion jobs on this source (syncs and CLI loads), newest first. */
|
|
@@ -7914,7 +7963,9 @@ function objectFor(input) {
|
|
|
7914
7963
|
let cached = null;
|
|
7915
7964
|
const bytes = () => {
|
|
7916
7965
|
if (!cached) {
|
|
7917
|
-
cached =
|
|
7966
|
+
cached = input.content !== void 0 ? Promise.resolve(
|
|
7967
|
+
new Uint8Array(Buffer.from(input.content, "base64"))
|
|
7968
|
+
) : (async () => {
|
|
7918
7969
|
const response = await fetch(input.url);
|
|
7919
7970
|
if (!response.ok) {
|
|
7920
7971
|
throw new Error(
|