@mindstudio-ai/agent 0.1.84 → 0.1.86
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 +149 -10
- package/dist/index.d.ts +228 -3
- package/dist/index.js +140 -3
- package/dist/index.js.map +1 -1
- package/dist/postinstall.js +149 -10
- package/llms.txt +28 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1448,8 +1448,10 @@ declare class Store {
|
|
|
1448
1448
|
|
|
1449
1449
|
/**
|
|
1450
1450
|
* The `files` namespace — typed, private-by-default file storage for MindStudio
|
|
1451
|
-
* apps.
|
|
1452
|
-
*
|
|
1451
|
+
* apps. Think of a store as a CDN-backed bucket the app talks to, not app-defined
|
|
1452
|
+
* state like a `db` table: the API is *shaped* like `db` (define a store at module
|
|
1453
|
+
* scope, import the handle into route handlers), but its contents are arbitrary
|
|
1454
|
+
* durable blobs, and one store is shared across dev and prod.
|
|
1453
1455
|
*
|
|
1454
1456
|
* ```ts
|
|
1455
1457
|
* // files/uploads.ts
|
|
@@ -1498,6 +1500,192 @@ interface Files {
|
|
|
1498
1500
|
defineStore(name: string, options?: DefineStoreOptions): Store;
|
|
1499
1501
|
}
|
|
1500
1502
|
|
|
1503
|
+
/** @internal Transport: `POST /_internal/v2/datasources/<op>` with the hook token. */
|
|
1504
|
+
type DataSourcesTransport = (op: string, body: unknown) => Promise<any>;
|
|
1505
|
+
/** Where a retrieved chunk came from — enough to show the user the source. */
|
|
1506
|
+
interface Citation {
|
|
1507
|
+
documentId: string;
|
|
1508
|
+
filename: string | null;
|
|
1509
|
+
/** 1-based. Null for formats with no pagination (plain text, html). */
|
|
1510
|
+
pageNumber: number | null;
|
|
1511
|
+
/** Enclosing headings, outermost first. */
|
|
1512
|
+
headingPath: string[];
|
|
1513
|
+
/**
|
|
1514
|
+
* Region of the page this chunk came from, when the format had a layout to
|
|
1515
|
+
* measure — PDFs do, docx and plain text don't. Precise enough to highlight.
|
|
1516
|
+
*/
|
|
1517
|
+
boundingBox?: {
|
|
1518
|
+
topLeftX: number;
|
|
1519
|
+
topLeftY: number;
|
|
1520
|
+
bottomRightX: number;
|
|
1521
|
+
bottomRightY: number;
|
|
1522
|
+
};
|
|
1523
|
+
/**
|
|
1524
|
+
* Stable on-domain URL for the source document. Drop it in an `<a href>` —
|
|
1525
|
+
* a same-origin logged-in request authorizes automatically, so there's
|
|
1526
|
+
* nothing to await.
|
|
1527
|
+
*/
|
|
1528
|
+
url: string;
|
|
1529
|
+
}
|
|
1530
|
+
interface SearchHit {
|
|
1531
|
+
/** Provider relevance score. Comparable within a response, not across them. */
|
|
1532
|
+
score: number;
|
|
1533
|
+
/** The matched chunk, prefixed with its heading path for context. */
|
|
1534
|
+
text: string;
|
|
1535
|
+
citation: Citation;
|
|
1536
|
+
}
|
|
1537
|
+
/**
|
|
1538
|
+
* Per-query overrides.
|
|
1539
|
+
*
|
|
1540
|
+
* These are the settings that are free to change: none of them touch a stored
|
|
1541
|
+
* vector, so they take effect on the next call and cost nothing. Anything that
|
|
1542
|
+
* would require rebuilding the corpus — chunking, the embedding model, whether
|
|
1543
|
+
* chunks are contextualized — is a property of the data source, configured
|
|
1544
|
+
* with `mindstudio-prod datasources config` rather than passed here.
|
|
1545
|
+
*
|
|
1546
|
+
* The defaults come from the data source's own configuration, so most callers
|
|
1547
|
+
* should pass nothing.
|
|
1548
|
+
*/
|
|
1549
|
+
interface SearchOptions {
|
|
1550
|
+
/** Results to return. Default 5, capped at 50. */
|
|
1551
|
+
topK?: number;
|
|
1552
|
+
/** Drop hits below this score. Provider-specific scale — measure before using. */
|
|
1553
|
+
scoreThreshold?: number;
|
|
1554
|
+
/**
|
|
1555
|
+
* Rerank results with a cross-encoder before returning them. On by default.
|
|
1556
|
+
*
|
|
1557
|
+
* Turn it off on a latency-sensitive path — it adds a round trip for a
|
|
1558
|
+
* meaningful ranking improvement, which is usually the right trade but not
|
|
1559
|
+
* always.
|
|
1560
|
+
*/
|
|
1561
|
+
rerank?: boolean;
|
|
1562
|
+
/**
|
|
1563
|
+
* Combine semantic search with exact keyword matching. On by default.
|
|
1564
|
+
*
|
|
1565
|
+
* Keyword matching is what finds part numbers, error codes and proper nouns
|
|
1566
|
+
* that an embedding model never learned. Rarely worth disabling.
|
|
1567
|
+
*/
|
|
1568
|
+
hybrid?: boolean;
|
|
1569
|
+
}
|
|
1570
|
+
interface AddOptions {
|
|
1571
|
+
/**
|
|
1572
|
+
* Required — the extension selects the extraction route. PDFs and office
|
|
1573
|
+
* formats go to a document model; text and CSV are read directly.
|
|
1574
|
+
*/
|
|
1575
|
+
filename: string;
|
|
1576
|
+
contentType?: string;
|
|
1577
|
+
}
|
|
1578
|
+
interface DataSourceDocument {
|
|
1579
|
+
id: string;
|
|
1580
|
+
filename: string | null;
|
|
1581
|
+
status: 'processing' | 'done' | 'error';
|
|
1582
|
+
errorMessage: string | null;
|
|
1583
|
+
chunkCount: number | null;
|
|
1584
|
+
pageCount: number | null;
|
|
1585
|
+
createdAt: string;
|
|
1586
|
+
ingestedAt: string | null;
|
|
1587
|
+
}
|
|
1588
|
+
/**
|
|
1589
|
+
* A typed handle to one data source. Lazy — nothing executes until a method is
|
|
1590
|
+
* awaited, so it's safe to `defineDataSource()` at module scope and import the
|
|
1591
|
+
* handle into route handlers (same ergonomics as `db.defineTable` and
|
|
1592
|
+
* `files.defineStore`).
|
|
1593
|
+
*/
|
|
1594
|
+
declare class DataSource {
|
|
1595
|
+
private readonly _slug;
|
|
1596
|
+
private readonly _call;
|
|
1597
|
+
constructor(_slug: string, _call: DataSourcesTransport);
|
|
1598
|
+
get name(): string;
|
|
1599
|
+
/**
|
|
1600
|
+
* Search the corpus.
|
|
1601
|
+
*
|
|
1602
|
+
* Returns chunks ranked by relevance, each with a citation. Searching a
|
|
1603
|
+
* source that doesn't exist yet returns no results rather than throwing —
|
|
1604
|
+
* code may name a corpus the build hasn't populated.
|
|
1605
|
+
*/
|
|
1606
|
+
search(query: string, options?: SearchOptions): Promise<{
|
|
1607
|
+
results: SearchHit[];
|
|
1608
|
+
}>;
|
|
1609
|
+
/**
|
|
1610
|
+
* Add a document to the corpus.
|
|
1611
|
+
*
|
|
1612
|
+
* Returns as soon as the document is queued — extraction and embedding run
|
|
1613
|
+
* in the background and take a while, so poll {@link documents} for status
|
|
1614
|
+
* rather than assuming the content is searchable on return.
|
|
1615
|
+
*
|
|
1616
|
+
* **Adding the same bytes twice is free.** Documents are content-addressed,
|
|
1617
|
+
* so a re-add is a no-op when this source has already processed those exact
|
|
1618
|
+
* bytes under its current configuration. Reconfiguring the source is what
|
|
1619
|
+
* makes a re-add do work again — and that is an explicit, owner-triggered
|
|
1620
|
+
* migration, never something a deploy causes.
|
|
1621
|
+
*/
|
|
1622
|
+
add(content: Buffer | Uint8Array | string, options: AddOptions): Promise<{
|
|
1623
|
+
document: DataSourceDocument;
|
|
1624
|
+
queued: boolean;
|
|
1625
|
+
}>;
|
|
1626
|
+
/** Every document in the corpus, with ingest status. */
|
|
1627
|
+
documents(): Promise<DataSourceDocument[]>;
|
|
1628
|
+
/** Remove a document and its vectors. */
|
|
1629
|
+
remove(documentId: string): Promise<void>;
|
|
1630
|
+
/**
|
|
1631
|
+
* Create the data source if it doesn't exist yet.
|
|
1632
|
+
*
|
|
1633
|
+
* Rarely needed — `add` and `search` both handle a missing source. Useful
|
|
1634
|
+
* when you want it to exist (and appear in the dashboard) before any
|
|
1635
|
+
* document has been added.
|
|
1636
|
+
*/
|
|
1637
|
+
ensure(name?: string): Promise<void>;
|
|
1638
|
+
/**
|
|
1639
|
+
* @internal Content hash of some bytes, matching what the server computes.
|
|
1640
|
+
* Exposed for callers that want to check whether they already added a file.
|
|
1641
|
+
*/
|
|
1642
|
+
static contentHash(content: Buffer | Uint8Array | string): string;
|
|
1643
|
+
}
|
|
1644
|
+
|
|
1645
|
+
/**
|
|
1646
|
+
* The `dataSources` namespace — searchable document corpora for MindStudio
|
|
1647
|
+
* apps. The retrieval half of the platform's managed data layer, shaped like
|
|
1648
|
+
* `db` and `files`: declare a source at module scope, import the handle into
|
|
1649
|
+
* route handlers.
|
|
1650
|
+
*
|
|
1651
|
+
* ```ts
|
|
1652
|
+
* // datasources/policies.ts
|
|
1653
|
+
* import { dataSources } from '@mindstudio-ai/agent';
|
|
1654
|
+
* export const Policies = dataSources.defineDataSource('policies');
|
|
1655
|
+
*
|
|
1656
|
+
* // routes/ask.ts
|
|
1657
|
+
* import { Policies } from '../datasources/policies';
|
|
1658
|
+
*
|
|
1659
|
+
* const { results } = await Policies.search('what are the payment terms?');
|
|
1660
|
+
* const context = results.map((r) => r.text).join('\n\n');
|
|
1661
|
+
* ```
|
|
1662
|
+
*
|
|
1663
|
+
* The platform owns parsing, chunking, embedding, storage and isolation. You
|
|
1664
|
+
* declare what the corpus is and search it; every hit comes back with a
|
|
1665
|
+
* citation pointing at the source document.
|
|
1666
|
+
*
|
|
1667
|
+
* **Corpora are usually built at development time**, not through your app's
|
|
1668
|
+
* UI — the agent adds documents while building, and the app is a consumer.
|
|
1669
|
+
* `add()` exists for apps where users upload documents themselves.
|
|
1670
|
+
*
|
|
1671
|
+
* **A data source is live and shared.** Unlike database tables there is no dev
|
|
1672
|
+
* copy and no per-release isolation: adding or removing a document affects
|
|
1673
|
+
* what the deployed app retrieves, immediately. Scenarios never reset a data
|
|
1674
|
+
* source, and re-ingesting a large corpus costs real money.
|
|
1675
|
+
*/
|
|
1676
|
+
|
|
1677
|
+
/** The `dataSources` namespace object. */
|
|
1678
|
+
interface DataSources {
|
|
1679
|
+
/**
|
|
1680
|
+
* Define a data source. Lazy — nothing executes until you await a method on
|
|
1681
|
+
* the returned {@link DataSource}, so it's safe to call at module scope.
|
|
1682
|
+
*
|
|
1683
|
+
* The source is created on first use if it doesn't exist, so naming one the
|
|
1684
|
+
* build hasn't populated yet is not an error; it just searches empty.
|
|
1685
|
+
*/
|
|
1686
|
+
defineDataSource(name: string): DataSource;
|
|
1687
|
+
}
|
|
1688
|
+
|
|
1501
1689
|
/**
|
|
1502
1690
|
* Types for the task agent runtime.
|
|
1503
1691
|
*
|
|
@@ -1652,6 +1840,7 @@ declare class MindStudioAgent$1 {
|
|
|
1652
1840
|
private _db;
|
|
1653
1841
|
/** @internal Cached Files namespace instance (lazy; no context hydration needed). */
|
|
1654
1842
|
private _files;
|
|
1843
|
+
private _dataSources;
|
|
1655
1844
|
/** @internal Auth type — 'internal' for CALLBACK_TOKEN (managed mode), 'apiKey' otherwise. */
|
|
1656
1845
|
private _authType;
|
|
1657
1846
|
/** @internal Usage source sent on step executions (from MINDSTUDIO_REQUEST_SOURCE).
|
|
@@ -1931,11 +2120,32 @@ declare class MindStudioAgent$1 {
|
|
|
1931
2120
|
* ```
|
|
1932
2121
|
*/
|
|
1933
2122
|
get files(): Files;
|
|
2123
|
+
/**
|
|
2124
|
+
* Searchable document corpora.
|
|
2125
|
+
*
|
|
2126
|
+
* @example
|
|
2127
|
+
* ```ts
|
|
2128
|
+
* const Policies = agent.dataSources.defineDataSource('policies');
|
|
2129
|
+
* const { results } = await Policies.search('what are the payment terms?');
|
|
2130
|
+
* ```
|
|
2131
|
+
*/
|
|
2132
|
+
get dataSources(): DataSources;
|
|
1934
2133
|
/**
|
|
1935
2134
|
* @internal Transport for the `files` namespace — POST /_internal/v2/files/<op>
|
|
1936
2135
|
* with the raw hook token (mirrors `_executeDbBatch`).
|
|
1937
2136
|
*/
|
|
1938
2137
|
private _filesRequest;
|
|
2138
|
+
/**
|
|
2139
|
+
* @internal Transport for the `dataSources` namespace —
|
|
2140
|
+
* POST /_internal/v2/datasources/<op> with the raw hook token.
|
|
2141
|
+
*/
|
|
2142
|
+
private _dataSourcesRequest;
|
|
2143
|
+
/**
|
|
2144
|
+
* @internal Shared shape for the brokered `/_internal/v2/<ns>/<op>` data
|
|
2145
|
+
* planes. Factored out rather than copied per namespace so error handling
|
|
2146
|
+
* can't drift between them.
|
|
2147
|
+
*/
|
|
2148
|
+
private _brokeredRequest;
|
|
1939
2149
|
/**
|
|
1940
2150
|
* @internal Execute a batch of SQL queries against a managed database.
|
|
1941
2151
|
* Used as the `executeBatch` callback for Table/Query instances.
|
|
@@ -9209,6 +9419,21 @@ declare const db: Db;
|
|
|
9209
9419
|
* ```
|
|
9210
9420
|
*/
|
|
9211
9421
|
declare const files: Files;
|
|
9422
|
+
/**
|
|
9423
|
+
* Top-level `dataSources` namespace bound to the default singleton.
|
|
9424
|
+
*
|
|
9425
|
+
* Searchable document corpora. Declare one at module scope and import the
|
|
9426
|
+
* handle; the platform owns parsing, chunking, embedding and isolation.
|
|
9427
|
+
*
|
|
9428
|
+
* @example
|
|
9429
|
+
* ```ts
|
|
9430
|
+
* import { dataSources } from '@mindstudio-ai/agent';
|
|
9431
|
+
*
|
|
9432
|
+
* const Policies = dataSources.defineDataSource('policies');
|
|
9433
|
+
* const { results } = await Policies.search('what are the payment terms?');
|
|
9434
|
+
* ```
|
|
9435
|
+
*/
|
|
9436
|
+
declare const dataSources: DataSources;
|
|
9212
9437
|
/**
|
|
9213
9438
|
* Top-level `stream` function bound to the default singleton.
|
|
9214
9439
|
*
|
|
@@ -9272,4 +9497,4 @@ declare const prerender: {
|
|
|
9272
9497
|
}>;
|
|
9273
9498
|
};
|
|
9274
9499
|
|
|
9275
|
-
export { type Accessor, type ActiveCampaignAddNoteStepInput, type ActiveCampaignAddNoteStepOutput, type ActiveCampaignCreateContactStepInput, type ActiveCampaignCreateContactStepOutput, type AddSubtitlesToVideoStepInput, type AddSubtitlesToVideoStepOutput, type AgentInfo, type AgentOptions, type AirtableCreateUpdateRecordStepInput, type AirtableCreateUpdateRecordStepOutput, type AirtableDeleteRecordStepInput, type AirtableDeleteRecordStepOutput, type AirtableGetRecordStepInput, type AirtableGetRecordStepOutput, type AirtableGetTableRecordsStepInput, type AirtableGetTableRecordsStepOutput, type AnalyzeImageStepInput, type AnalyzeImageStepOutput, type AnalyzeVideoStepInput, type AnalyzeVideoStepOutput, type AppAuthContext, type AppContextResult, type AppDatabase, type AppDatabaseColumnSchema, type AppDatabaseTable, type AppRoleAssignment, AuthContext, type AuthTableConfig, type BatchStepInput, type BatchStepResult, type CaptureThumbnailStepInput, type CaptureThumbnailStepOutput, type CheckAppRoleStepInput, type CheckAppRoleStepOutput, type CodaCreateUpdatePageStepInput, type CodaCreateUpdatePageStepOutput, type CodaCreateUpdateRowStepInput, type CodaCreateUpdateRowStepOutput, type CodaFindRowStepInput, type CodaFindRowStepOutput, type CodaGetPageStepInput, type CodaGetPageStepOutput, type CodaGetTableRowsStepInput, type CodaGetTableRowsStepOutput, type Connection, type ConnectorActionDetail, type ConnectorService, type ConvertPdfToImagesStepInput, type ConvertPdfToImagesStepOutput, type CreateDataSourceStepInput, type CreateDataSourceStepOutput, type CreateGmailDraftStepInput, type CreateGmailDraftStepOutput, type CreateGoogleCalendarEventStepInput, type CreateGoogleCalendarEventStepOutput, type CreateGoogleDocStepInput, type CreateGoogleDocStepOutput, type CreateGoogleSheetStepInput, type CreateGoogleSheetStepOutput, type Db, type DefineStoreOptions, type DefineTableOptions, type DeleteDataSourceDocumentStepInput, type DeleteDataSourceDocumentStepOutput, type DeleteDataSourceStepInput, type DeleteDataSourceStepOutput, type DeleteGmailEmailStepInput, type DeleteGmailEmailStepOutput, type DeleteGoogleCalendarEventStepInput, type DeleteGoogleCalendarEventStepOutput, type DeleteGoogleSheetRowsStepInput, type DeleteGoogleSheetRowsStepOutput, type DetectChangesStepInput, type DetectChangesStepOutput, type DetectPIIStepInput, type DetectPIIStepOutput, type DiscordEditMessageStepInput, type DiscordEditMessageStepOutput, type DiscordSendFollowUpStepInput, type DiscordSendFollowUpStepOutput, type DiscordSendMessageStepInput, type DiscordSendMessageStepOutput, type DownloadVideoStepInput, type DownloadVideoStepOutput, type EnhanceImageGenerationPromptStepInput, type EnhanceImageGenerationPromptStepOutput, type EnhanceVideoGenerationPromptStepInput, type EnhanceVideoGenerationPromptStepOutput, type EnrichPersonStepInput, type EnrichPersonStepOutput, type ExecuteStepBatchOptions, type ExecuteStepBatchResult, type ExtractAudioFromVideoStepInput, type ExtractAudioFromVideoStepOutput, type ExtractTextStepInput, type ExtractTextStepOutput, type FetchDataSourceDocumentStepInput, type FetchDataSourceDocumentStepOutput, type FetchGoogleDocStepInput, type FetchGoogleDocStepOutput, type FetchGoogleSheetStepInput, type FetchGoogleSheetStepOutput, type FetchSlackChannelHistoryStepInput, type FetchSlackChannelHistoryStepOutput, type FetchYoutubeCaptionsStepInput, type FetchYoutubeCaptionsStepOutput, type FetchYoutubeChannelStepInput, type FetchYoutubeChannelStepOutput, type FetchYoutubeCommentsStepInput, type FetchYoutubeCommentsStepOutput, type FetchYoutubeVideoStepInput, type FetchYoutubeVideoStepOutput, type FileAccess, type Files, type Generate3dModelStepInput, type Generate3dModelStepOutput, type GenerateAssetStepInput, type GenerateAssetStepOutput, type GenerateChartStepInput, type GenerateChartStepOutput, type GenerateImageStepInput, type GenerateImageStepOutput, type GenerateLipsyncStepInput, type GenerateLipsyncStepOutput, type GenerateMusicStepInput, type GenerateMusicStepOutput, type GeneratePdfStepInput, type GeneratePdfStepOutput, type GenerateStaticVideoFromImageStepInput, type GenerateStaticVideoFromImageStepOutput, type GenerateTextStepInput, type GenerateTextStepOutput, type GenerateVideoStepInput, type GenerateVideoStepOutput, type GetGmailAttachmentsStepInput, type GetGmailAttachmentsStepOutput, type GetGmailDraftStepInput, type GetGmailDraftStepOutput, type GetGmailEmailStepInput, type GetGmailEmailStepOutput, type GetGmailUnreadCountStepInput, type GetGmailUnreadCountStepOutput, type GetGoogleCalendarEventStepInput, type GetGoogleCalendarEventStepOutput, type GetGoogleDriveFileStepInput, type GetGoogleDriveFileStepOutput, type GetGoogleSheetInfoStepInput, type GetGoogleSheetInfoStepOutput, type GetMediaMetadataStepInput, type GetMediaMetadataStepOutput, type HubspotCreateCompanyStepInput, type HubspotCreateCompanyStepOutput, type HubspotCreateContactStepInput, type HubspotCreateContactStepOutput, type HubspotGetCompanyStepInput, type HubspotGetCompanyStepOutput, type HubspotGetContactStepInput, type HubspotGetContactStepOutput, type HunterApiCompanyEnrichmentStepInput, type HunterApiCompanyEnrichmentStepOutput, type HunterApiDomainSearchStepInput, type HunterApiDomainSearchStepOutput, type HunterApiEmailFinderStepInput, type HunterApiEmailFinderStepOutput, type HunterApiEmailVerificationStepInput, type HunterApiEmailVerificationStepOutput, type HunterApiPersonEnrichmentStepInput, type HunterApiPersonEnrichmentStepOutput, type ImageFaceSwapStepInput, type ImageFaceSwapStepOutput, type ImageRemoveWatermarkStepInput, type ImageRemoveWatermarkStepOutput, type InsertVideoClipsStepInput, type InsertVideoClipsStepOutput, type ListAgentsResult, type ListDataSourcesStepInput, type ListDataSourcesStepOutput, type ListGmailDraftsStepInput, type ListGmailDraftsStepOutput, type ListGmailLabelsStepInput, type ListGmailLabelsStepOutput, type ListGoogleCalendarEventsStepInput, type ListGoogleCalendarEventsStepOutput, type ListGoogleDriveFilesStepInput, type ListGoogleDriveFilesStepOutput, type ListOptions, type ListRecentGmailEmailsStepInput, type ListRecentGmailEmailsStepOutput, type LogicStepInput, type LogicStepOutput, type MakeDotComRunScenarioStepInput, type MakeDotComRunScenarioStepOutput, type MergeAudioStepInput, type MergeAudioStepOutput, type MergeVideosStepInput, type MergeVideosStepOutput, type MeshyAnimateStepInput, type MeshyAnimateStepOutput, type MeshyImageTo3dStepInput, type MeshyImageTo3dStepOutput, type MeshyRemeshStepInput, type MeshyRemeshStepOutput, type MeshyRigStepInput, type MeshyRigStepOutput, type MeshyTextTo3dStepInput, type MeshyTextTo3dStepOutput, type MeshyTextureStepInput, type MeshyTextureStepOutput, MindStudioAgent, MindStudioError, type MindStudioModel, type MindStudioModelSummary, type MixAudioIntoVideoStepInput, type MixAudioIntoVideoStepOutput, type ModelType, type MonacoSnippet, type MonacoSnippetField, type MonacoSnippetFieldType, type MuteVideoStepInput, type MuteVideoStepOutput, type N8nRunNodeStepInput, type N8nRunNodeStepOutput, type NotionCreatePageStepInput, type NotionCreatePageStepOutput, type NotionUpdatePageStepInput, type NotionUpdatePageStepOutput, type PackagedWorkflow, type PackagedWorkflowInput, type PackagedWorkflowSignature, type ParticlePodcastsFindMentionsStepInput, type ParticlePodcastsFindMentionsStepOutput, type ParticlePodcastsGetEpisodeStepInput, type ParticlePodcastsGetEpisodeStepOutput, type ParticlePodcastsGetEpisodeTranscriptStepInput, type ParticlePodcastsGetEpisodeTranscriptStepOutput, type ParticlePodcastsSearchCompaniesStepInput, type ParticlePodcastsSearchCompaniesStepOutput, type ParticlePodcastsSearchDialogueStepInput, type ParticlePodcastsSearchDialogueStepOutput, type ParticlePodcastsSearchPodcastsStepInput, type ParticlePodcastsSearchPodcastsStepOutput, type PeopleSearchStepInput, type PeopleSearchStepOutput, type PostToLinkedInStepInput, type PostToLinkedInStepOutput, type PostToSlackChannelStepInput, type PostToSlackChannelStepOutput, type PostToXStepInput, type PostToXStepOutput, type PostToZapierStepInput, type PostToZapierStepOutput, type Predicate, type PushInput, type PutOptions, Query, type QueryAppDatabaseStepInput, type QueryAppDatabaseStepOutput, type QueryDataSourceStepInput, type QueryDataSourceStepOutput, type QueryExternalDatabaseStepInput, type QueryExternalDatabaseStepOutput, type RedactPIIStepInput, type RedactPIIStepOutput, type RemoveBackgroundFromImageStepInput, type RemoveBackgroundFromImageStepOutput, type ReplyToGmailEmailStepInput, type ReplyToGmailEmailStepOutput, type ReportIssueInput, type ReportedIssue, type RequestContext, type ResizeVideoStepInput, type ResizeVideoStepOutput, type ResolvedUser, Roles, type RunAgentOptions, type RunAgentResult, type RunFromConnectorRegistryStepInput, type RunFromConnectorRegistryStepOutput, type RunPackagedWorkflowStepInput, type RunPackagedWorkflowStepOutput, type RunTaskOptions, type RunTaskResult, type ScrapeLinkedInCompanyStepInput, type ScrapeLinkedInCompanyStepOutput, type ScrapeLinkedInProfileStepInput, type ScrapeLinkedInProfileStepOutput, type ScrapeUrlStepInput, type ScrapeUrlStepOutput, type ScrapeXPostStepInput, type ScrapeXPostStepOutput, type ScrapeXProfileStepInput, type ScrapeXProfileStepOutput, type ScreenshotUrlStepInput, type ScreenshotUrlStepOutput, type SearchGmailEmailsStepInput, type SearchGmailEmailsStepOutput, type SearchGoogleCalendarEventsStepInput, type SearchGoogleCalendarEventsStepOutput, type SearchGoogleDriveStepInput, type SearchGoogleDriveStepOutput, type SearchGoogleImagesStepInput, type SearchGoogleImagesStepOutput, type SearchGoogleNewsStepInput, type SearchGoogleNewsStepOutput, type SearchGoogleStepInput, type SearchGoogleStepOutput, type SearchGoogleTrendsStepInput, type SearchGoogleTrendsStepOutput, type SearchPerplexityStepInput, type SearchPerplexityStepOutput, type SearchXPostsStepInput, type SearchXPostsStepOutput, type SearchYoutubeStepInput, type SearchYoutubeStepOutput, type SearchYoutubeTrendsStepInput, type SearchYoutubeTrendsStepOutput, type SendEmailStepInput, type SendEmailStepOutput, type SendGmailDraftStepInput, type SendGmailDraftStepOutput, type SendGmailMessageStepInput, type SendGmailMessageStepOutput, type SendSMSStepInput, type SendSMSStepOutput, type SendSlackDirectMessageStepInput, type SendSlackDirectMessageStepOutput, type SetGmailReadStatusStepInput, type SetGmailReadStatusStepOutput, type SetRunTitleStepInput, type SetRunTitleStepOutput, type SetVariableStepInput, type SetVariableStepOutput, type StepCostEstimateEntry, type StepExecutionMeta, type StepExecutionOptions, type StepExecutionResult, type StepInputMap, type StepLogEvent, type StepMetadata, type StepMethods, type StepName, type StepOutputMap, Store, type StoredFile, type SystemFields, Table, type TaskEvent, type TaskToolCall, type TaskToolConfig, type TaskUsage, type TelegramEditMessageStepInput, type TelegramEditMessageStepOutput, type TelegramReplyToMessageStepInput, type TelegramReplyToMessageStepOutput, type TelegramSendAudioStepInput, type TelegramSendAudioStepOutput, type TelegramSendFileStepInput, type TelegramSendFileStepOutput, type TelegramSendImageStepInput, type TelegramSendImageStepOutput, type TelegramSendMessageStepInput, type TelegramSendMessageStepOutput, type TelegramSendVideoStepInput, type TelegramSendVideoStepOutput, type TelegramSetTypingStepInput, type TelegramSetTypingStepOutput, type TextToSpeechStepInput, type TextToSpeechStepOutput, type TranscribeAudioStepInput, type TranscribeAudioStepOutput, type TrimMediaStepInput, type TrimMediaStepOutput, type UpdateGmailLabelsStepInput, type UpdateGmailLabelsStepOutput, type UpdateGoogleCalendarEventStepInput, type UpdateGoogleCalendarEventStepOutput, type UpdateGoogleDocStepInput, type UpdateGoogleDocStepOutput, type UpdateGoogleSheetStepInput, type UpdateGoogleSheetStepOutput, type UpdateInput, type UploadDataSourceDocumentStepInput, type UploadDataSourceDocumentStepOutput, type UploadFileResult, type UploadToken, type UpscaleImageStepInput, type UpscaleImageStepOutput, type UpscaleVideoStepInput, type UpscaleVideoStepOutput, type User, type UserInfoResult, type UserMessageStepInput, type UserMessageStepOutput, type VideoFaceSwapStepInput, type VideoFaceSwapStepOutput, type VideoRemoveBackgroundStepInput, type VideoRemoveBackgroundStepOutput, type VideoRemoveWatermarkStepInput, type VideoRemoveWatermarkStepOutput, type WatermarkImageStepInput, type WatermarkImageStepOutput, type WatermarkVideoStepInput, type WatermarkVideoStepOutput, type YouDotComFinanceResearchStepInput, type YouDotComFinanceResearchStepOutput, type YouDotComGetPageContentStepInput, type YouDotComGetPageContentStepOutput, type YouDotComLiveNewsStepInput, type YouDotComLiveNewsStepOutput, type YouDotComWebResearchStepInput, type YouDotComWebResearchStepOutput, type YouDotComWebSearchStepInput, type YouDotComWebSearchStepOutput, auth, blockTypeAliases, db, mindstudio as default, files, getRequestContext, mindstudio, monacoSnippets, prerender, reportIssue, resolveUser, runWithContext, stepMetadata, stream };
|
|
9500
|
+
export { type Accessor, type ActiveCampaignAddNoteStepInput, type ActiveCampaignAddNoteStepOutput, type ActiveCampaignCreateContactStepInput, type ActiveCampaignCreateContactStepOutput, type AddSubtitlesToVideoStepInput, type AddSubtitlesToVideoStepOutput, type AgentInfo, type AgentOptions, type AirtableCreateUpdateRecordStepInput, type AirtableCreateUpdateRecordStepOutput, type AirtableDeleteRecordStepInput, type AirtableDeleteRecordStepOutput, type AirtableGetRecordStepInput, type AirtableGetRecordStepOutput, type AirtableGetTableRecordsStepInput, type AirtableGetTableRecordsStepOutput, type AnalyzeImageStepInput, type AnalyzeImageStepOutput, type AnalyzeVideoStepInput, type AnalyzeVideoStepOutput, type AppAuthContext, type AppContextResult, type AppDatabase, type AppDatabaseColumnSchema, type AppDatabaseTable, type AppRoleAssignment, AuthContext, type AuthTableConfig, type BatchStepInput, type BatchStepResult, type CaptureThumbnailStepInput, type CaptureThumbnailStepOutput, type CheckAppRoleStepInput, type CheckAppRoleStepOutput, type CodaCreateUpdatePageStepInput, type CodaCreateUpdatePageStepOutput, type CodaCreateUpdateRowStepInput, type CodaCreateUpdateRowStepOutput, type CodaFindRowStepInput, type CodaFindRowStepOutput, type CodaGetPageStepInput, type CodaGetPageStepOutput, type CodaGetTableRowsStepInput, type CodaGetTableRowsStepOutput, type Connection, type ConnectorActionDetail, type ConnectorService, type ConvertPdfToImagesStepInput, type ConvertPdfToImagesStepOutput, type CreateDataSourceStepInput, type CreateDataSourceStepOutput, type CreateGmailDraftStepInput, type CreateGmailDraftStepOutput, type CreateGoogleCalendarEventStepInput, type CreateGoogleCalendarEventStepOutput, type CreateGoogleDocStepInput, type CreateGoogleDocStepOutput, type CreateGoogleSheetStepInput, type CreateGoogleSheetStepOutput, type Db, type DefineStoreOptions, type DefineTableOptions, type DeleteDataSourceDocumentStepInput, type DeleteDataSourceDocumentStepOutput, type DeleteDataSourceStepInput, type DeleteDataSourceStepOutput, type DeleteGmailEmailStepInput, type DeleteGmailEmailStepOutput, type DeleteGoogleCalendarEventStepInput, type DeleteGoogleCalendarEventStepOutput, type DeleteGoogleSheetRowsStepInput, type DeleteGoogleSheetRowsStepOutput, type DetectChangesStepInput, type DetectChangesStepOutput, type DetectPIIStepInput, type DetectPIIStepOutput, type DiscordEditMessageStepInput, type DiscordEditMessageStepOutput, type DiscordSendFollowUpStepInput, type DiscordSendFollowUpStepOutput, type DiscordSendMessageStepInput, type DiscordSendMessageStepOutput, type DownloadVideoStepInput, type DownloadVideoStepOutput, type EnhanceImageGenerationPromptStepInput, type EnhanceImageGenerationPromptStepOutput, type EnhanceVideoGenerationPromptStepInput, type EnhanceVideoGenerationPromptStepOutput, type EnrichPersonStepInput, type EnrichPersonStepOutput, type ExecuteStepBatchOptions, type ExecuteStepBatchResult, type ExtractAudioFromVideoStepInput, type ExtractAudioFromVideoStepOutput, type ExtractTextStepInput, type ExtractTextStepOutput, type FetchDataSourceDocumentStepInput, type FetchDataSourceDocumentStepOutput, type FetchGoogleDocStepInput, type FetchGoogleDocStepOutput, type FetchGoogleSheetStepInput, type FetchGoogleSheetStepOutput, type FetchSlackChannelHistoryStepInput, type FetchSlackChannelHistoryStepOutput, type FetchYoutubeCaptionsStepInput, type FetchYoutubeCaptionsStepOutput, type FetchYoutubeChannelStepInput, type FetchYoutubeChannelStepOutput, type FetchYoutubeCommentsStepInput, type FetchYoutubeCommentsStepOutput, type FetchYoutubeVideoStepInput, type FetchYoutubeVideoStepOutput, type FileAccess, type Files, type Generate3dModelStepInput, type Generate3dModelStepOutput, type GenerateAssetStepInput, type GenerateAssetStepOutput, type GenerateChartStepInput, type GenerateChartStepOutput, type GenerateImageStepInput, type GenerateImageStepOutput, type GenerateLipsyncStepInput, type GenerateLipsyncStepOutput, type GenerateMusicStepInput, type GenerateMusicStepOutput, type GeneratePdfStepInput, type GeneratePdfStepOutput, type GenerateStaticVideoFromImageStepInput, type GenerateStaticVideoFromImageStepOutput, type GenerateTextStepInput, type GenerateTextStepOutput, type GenerateVideoStepInput, type GenerateVideoStepOutput, type GetGmailAttachmentsStepInput, type GetGmailAttachmentsStepOutput, type GetGmailDraftStepInput, type GetGmailDraftStepOutput, type GetGmailEmailStepInput, type GetGmailEmailStepOutput, type GetGmailUnreadCountStepInput, type GetGmailUnreadCountStepOutput, type GetGoogleCalendarEventStepInput, type GetGoogleCalendarEventStepOutput, type GetGoogleDriveFileStepInput, type GetGoogleDriveFileStepOutput, type GetGoogleSheetInfoStepInput, type GetGoogleSheetInfoStepOutput, type GetMediaMetadataStepInput, type GetMediaMetadataStepOutput, type HubspotCreateCompanyStepInput, type HubspotCreateCompanyStepOutput, type HubspotCreateContactStepInput, type HubspotCreateContactStepOutput, type HubspotGetCompanyStepInput, type HubspotGetCompanyStepOutput, type HubspotGetContactStepInput, type HubspotGetContactStepOutput, type HunterApiCompanyEnrichmentStepInput, type HunterApiCompanyEnrichmentStepOutput, type HunterApiDomainSearchStepInput, type HunterApiDomainSearchStepOutput, type HunterApiEmailFinderStepInput, type HunterApiEmailFinderStepOutput, type HunterApiEmailVerificationStepInput, type HunterApiEmailVerificationStepOutput, type HunterApiPersonEnrichmentStepInput, type HunterApiPersonEnrichmentStepOutput, type ImageFaceSwapStepInput, type ImageFaceSwapStepOutput, type ImageRemoveWatermarkStepInput, type ImageRemoveWatermarkStepOutput, type InsertVideoClipsStepInput, type InsertVideoClipsStepOutput, type ListAgentsResult, type ListDataSourcesStepInput, type ListDataSourcesStepOutput, type ListGmailDraftsStepInput, type ListGmailDraftsStepOutput, type ListGmailLabelsStepInput, type ListGmailLabelsStepOutput, type ListGoogleCalendarEventsStepInput, type ListGoogleCalendarEventsStepOutput, type ListGoogleDriveFilesStepInput, type ListGoogleDriveFilesStepOutput, type ListOptions, type ListRecentGmailEmailsStepInput, type ListRecentGmailEmailsStepOutput, type LogicStepInput, type LogicStepOutput, type MakeDotComRunScenarioStepInput, type MakeDotComRunScenarioStepOutput, type MergeAudioStepInput, type MergeAudioStepOutput, type MergeVideosStepInput, type MergeVideosStepOutput, type MeshyAnimateStepInput, type MeshyAnimateStepOutput, type MeshyImageTo3dStepInput, type MeshyImageTo3dStepOutput, type MeshyRemeshStepInput, type MeshyRemeshStepOutput, type MeshyRigStepInput, type MeshyRigStepOutput, type MeshyTextTo3dStepInput, type MeshyTextTo3dStepOutput, type MeshyTextureStepInput, type MeshyTextureStepOutput, MindStudioAgent, MindStudioError, type MindStudioModel, type MindStudioModelSummary, type MixAudioIntoVideoStepInput, type MixAudioIntoVideoStepOutput, type ModelType, type MonacoSnippet, type MonacoSnippetField, type MonacoSnippetFieldType, type MuteVideoStepInput, type MuteVideoStepOutput, type N8nRunNodeStepInput, type N8nRunNodeStepOutput, type NotionCreatePageStepInput, type NotionCreatePageStepOutput, type NotionUpdatePageStepInput, type NotionUpdatePageStepOutput, type PackagedWorkflow, type PackagedWorkflowInput, type PackagedWorkflowSignature, type ParticlePodcastsFindMentionsStepInput, type ParticlePodcastsFindMentionsStepOutput, type ParticlePodcastsGetEpisodeStepInput, type ParticlePodcastsGetEpisodeStepOutput, type ParticlePodcastsGetEpisodeTranscriptStepInput, type ParticlePodcastsGetEpisodeTranscriptStepOutput, type ParticlePodcastsSearchCompaniesStepInput, type ParticlePodcastsSearchCompaniesStepOutput, type ParticlePodcastsSearchDialogueStepInput, type ParticlePodcastsSearchDialogueStepOutput, type ParticlePodcastsSearchPodcastsStepInput, type ParticlePodcastsSearchPodcastsStepOutput, type PeopleSearchStepInput, type PeopleSearchStepOutput, type PostToLinkedInStepInput, type PostToLinkedInStepOutput, type PostToSlackChannelStepInput, type PostToSlackChannelStepOutput, type PostToXStepInput, type PostToXStepOutput, type PostToZapierStepInput, type PostToZapierStepOutput, type Predicate, type PushInput, type PutOptions, Query, type QueryAppDatabaseStepInput, type QueryAppDatabaseStepOutput, type QueryDataSourceStepInput, type QueryDataSourceStepOutput, type QueryExternalDatabaseStepInput, type QueryExternalDatabaseStepOutput, type RedactPIIStepInput, type RedactPIIStepOutput, type RemoveBackgroundFromImageStepInput, type RemoveBackgroundFromImageStepOutput, type ReplyToGmailEmailStepInput, type ReplyToGmailEmailStepOutput, type ReportIssueInput, type ReportedIssue, type RequestContext, type ResizeVideoStepInput, type ResizeVideoStepOutput, type ResolvedUser, Roles, type RunAgentOptions, type RunAgentResult, type RunFromConnectorRegistryStepInput, type RunFromConnectorRegistryStepOutput, type RunPackagedWorkflowStepInput, type RunPackagedWorkflowStepOutput, type RunTaskOptions, type RunTaskResult, type ScrapeLinkedInCompanyStepInput, type ScrapeLinkedInCompanyStepOutput, type ScrapeLinkedInProfileStepInput, type ScrapeLinkedInProfileStepOutput, type ScrapeUrlStepInput, type ScrapeUrlStepOutput, type ScrapeXPostStepInput, type ScrapeXPostStepOutput, type ScrapeXProfileStepInput, type ScrapeXProfileStepOutput, type ScreenshotUrlStepInput, type ScreenshotUrlStepOutput, type SearchGmailEmailsStepInput, type SearchGmailEmailsStepOutput, type SearchGoogleCalendarEventsStepInput, type SearchGoogleCalendarEventsStepOutput, type SearchGoogleDriveStepInput, type SearchGoogleDriveStepOutput, type SearchGoogleImagesStepInput, type SearchGoogleImagesStepOutput, type SearchGoogleNewsStepInput, type SearchGoogleNewsStepOutput, type SearchGoogleStepInput, type SearchGoogleStepOutput, type SearchGoogleTrendsStepInput, type SearchGoogleTrendsStepOutput, type SearchPerplexityStepInput, type SearchPerplexityStepOutput, type SearchXPostsStepInput, type SearchXPostsStepOutput, type SearchYoutubeStepInput, type SearchYoutubeStepOutput, type SearchYoutubeTrendsStepInput, type SearchYoutubeTrendsStepOutput, type SendEmailStepInput, type SendEmailStepOutput, type SendGmailDraftStepInput, type SendGmailDraftStepOutput, type SendGmailMessageStepInput, type SendGmailMessageStepOutput, type SendSMSStepInput, type SendSMSStepOutput, type SendSlackDirectMessageStepInput, type SendSlackDirectMessageStepOutput, type SetGmailReadStatusStepInput, type SetGmailReadStatusStepOutput, type SetRunTitleStepInput, type SetRunTitleStepOutput, type SetVariableStepInput, type SetVariableStepOutput, type StepCostEstimateEntry, type StepExecutionMeta, type StepExecutionOptions, type StepExecutionResult, type StepInputMap, type StepLogEvent, type StepMetadata, type StepMethods, type StepName, type StepOutputMap, Store, type StoredFile, type SystemFields, Table, type TaskEvent, type TaskToolCall, type TaskToolConfig, type TaskUsage, type TelegramEditMessageStepInput, type TelegramEditMessageStepOutput, type TelegramReplyToMessageStepInput, type TelegramReplyToMessageStepOutput, type TelegramSendAudioStepInput, type TelegramSendAudioStepOutput, type TelegramSendFileStepInput, type TelegramSendFileStepOutput, type TelegramSendImageStepInput, type TelegramSendImageStepOutput, type TelegramSendMessageStepInput, type TelegramSendMessageStepOutput, type TelegramSendVideoStepInput, type TelegramSendVideoStepOutput, type TelegramSetTypingStepInput, type TelegramSetTypingStepOutput, type TextToSpeechStepInput, type TextToSpeechStepOutput, type TranscribeAudioStepInput, type TranscribeAudioStepOutput, type TrimMediaStepInput, type TrimMediaStepOutput, type UpdateGmailLabelsStepInput, type UpdateGmailLabelsStepOutput, type UpdateGoogleCalendarEventStepInput, type UpdateGoogleCalendarEventStepOutput, type UpdateGoogleDocStepInput, type UpdateGoogleDocStepOutput, type UpdateGoogleSheetStepInput, type UpdateGoogleSheetStepOutput, type UpdateInput, type UploadDataSourceDocumentStepInput, type UploadDataSourceDocumentStepOutput, type UploadFileResult, type UploadToken, type UpscaleImageStepInput, type UpscaleImageStepOutput, type UpscaleVideoStepInput, type UpscaleVideoStepOutput, type User, type UserInfoResult, type UserMessageStepInput, type UserMessageStepOutput, type VideoFaceSwapStepInput, type VideoFaceSwapStepOutput, type VideoRemoveBackgroundStepInput, type VideoRemoveBackgroundStepOutput, type VideoRemoveWatermarkStepInput, type VideoRemoveWatermarkStepOutput, type WatermarkImageStepInput, type WatermarkImageStepOutput, type WatermarkVideoStepInput, type WatermarkVideoStepOutput, type YouDotComFinanceResearchStepInput, type YouDotComFinanceResearchStepOutput, type YouDotComGetPageContentStepInput, type YouDotComGetPageContentStepOutput, type YouDotComLiveNewsStepInput, type YouDotComLiveNewsStepOutput, type YouDotComWebResearchStepInput, type YouDotComWebResearchStepOutput, type YouDotComWebSearchStepInput, type YouDotComWebSearchStepOutput, auth, blockTypeAliases, dataSources, db, mindstudio as default, files, getRequestContext, mindstudio, monacoSnippets, prerender, reportIssue, resolveUser, runWithContext, stepMetadata, stream };
|
package/dist/index.js
CHANGED
|
@@ -2112,6 +2112,96 @@ function createFiles(call) {
|
|
|
2112
2112
|
};
|
|
2113
2113
|
}
|
|
2114
2114
|
|
|
2115
|
+
// src/datasources/source.ts
|
|
2116
|
+
import { createHash as createHash2 } from "crypto";
|
|
2117
|
+
var DataSource = class {
|
|
2118
|
+
constructor(_slug, _call) {
|
|
2119
|
+
this._slug = _slug;
|
|
2120
|
+
this._call = _call;
|
|
2121
|
+
}
|
|
2122
|
+
get name() {
|
|
2123
|
+
return this._slug;
|
|
2124
|
+
}
|
|
2125
|
+
/**
|
|
2126
|
+
* Search the corpus.
|
|
2127
|
+
*
|
|
2128
|
+
* Returns chunks ranked by relevance, each with a citation. Searching a
|
|
2129
|
+
* source that doesn't exist yet returns no results rather than throwing —
|
|
2130
|
+
* code may name a corpus the build hasn't populated.
|
|
2131
|
+
*/
|
|
2132
|
+
async search(query, options) {
|
|
2133
|
+
const { results } = await this._call("search", {
|
|
2134
|
+
slug: this._slug,
|
|
2135
|
+
query,
|
|
2136
|
+
...options?.topK !== void 0 ? { topK: options.topK } : {},
|
|
2137
|
+
...options?.scoreThreshold !== void 0 ? { scoreThreshold: options.scoreThreshold } : {},
|
|
2138
|
+
...options?.rerank !== void 0 ? { rerank: options.rerank } : {},
|
|
2139
|
+
...options?.hybrid !== void 0 ? { hybrid: options.hybrid } : {}
|
|
2140
|
+
});
|
|
2141
|
+
return { results: results ?? [] };
|
|
2142
|
+
}
|
|
2143
|
+
/**
|
|
2144
|
+
* Add a document to the corpus.
|
|
2145
|
+
*
|
|
2146
|
+
* Returns as soon as the document is queued — extraction and embedding run
|
|
2147
|
+
* in the background and take a while, so poll {@link documents} for status
|
|
2148
|
+
* rather than assuming the content is searchable on return.
|
|
2149
|
+
*
|
|
2150
|
+
* **Adding the same bytes twice is free.** Documents are content-addressed,
|
|
2151
|
+
* so a re-add is a no-op when this source has already processed those exact
|
|
2152
|
+
* bytes under its current configuration. Reconfiguring the source is what
|
|
2153
|
+
* makes a re-add do work again — and that is an explicit, owner-triggered
|
|
2154
|
+
* migration, never something a deploy causes.
|
|
2155
|
+
*/
|
|
2156
|
+
async add(content, options) {
|
|
2157
|
+
const bytes = typeof content === "string" ? Buffer.from(content) : Buffer.from(content);
|
|
2158
|
+
return this._call("add", {
|
|
2159
|
+
slug: this._slug,
|
|
2160
|
+
filename: options.filename,
|
|
2161
|
+
...options.contentType ? { contentType: options.contentType } : {},
|
|
2162
|
+
body: bytes.toString("base64")
|
|
2163
|
+
});
|
|
2164
|
+
}
|
|
2165
|
+
/** Every document in the corpus, with ingest status. */
|
|
2166
|
+
async documents() {
|
|
2167
|
+
const { documents } = await this._call("documents", { slug: this._slug });
|
|
2168
|
+
return documents ?? [];
|
|
2169
|
+
}
|
|
2170
|
+
/** Remove a document and its vectors. */
|
|
2171
|
+
async remove(documentId) {
|
|
2172
|
+
await this._call("remove", { slug: this._slug, documentId });
|
|
2173
|
+
}
|
|
2174
|
+
/**
|
|
2175
|
+
* Create the data source if it doesn't exist yet.
|
|
2176
|
+
*
|
|
2177
|
+
* Rarely needed — `add` and `search` both handle a missing source. Useful
|
|
2178
|
+
* when you want it to exist (and appear in the dashboard) before any
|
|
2179
|
+
* document has been added.
|
|
2180
|
+
*/
|
|
2181
|
+
async ensure(name) {
|
|
2182
|
+
await this._call("ensure", {
|
|
2183
|
+
slug: this._slug,
|
|
2184
|
+
...name ? { name } : {}
|
|
2185
|
+
});
|
|
2186
|
+
}
|
|
2187
|
+
/**
|
|
2188
|
+
* @internal Content hash of some bytes, matching what the server computes.
|
|
2189
|
+
* Exposed for callers that want to check whether they already added a file.
|
|
2190
|
+
*/
|
|
2191
|
+
static contentHash(content) {
|
|
2192
|
+
return createHash2("sha256").update(Buffer.from(content)).digest("hex");
|
|
2193
|
+
}
|
|
2194
|
+
};
|
|
2195
|
+
|
|
2196
|
+
// src/datasources/index.ts
|
|
2197
|
+
function createDataSources(call) {
|
|
2198
|
+
return {
|
|
2199
|
+
defineDataSource(name) {
|
|
2200
|
+
return new DataSource(name, call);
|
|
2201
|
+
}
|
|
2202
|
+
};
|
|
2203
|
+
}
|
|
2204
|
+
|
|
2115
2205
|
// src/generated/metadata.ts
|
|
2116
2206
|
var stepMetadata = {
|
|
2117
2207
|
"activeCampaignAddNote": {
|
|
@@ -4126,6 +4216,7 @@ var MindStudioAgent = class {
|
|
|
4126
4216
|
_db;
|
|
4127
4217
|
/** @internal Cached Files namespace instance (lazy; no context hydration needed). */
|
|
4128
4218
|
_files;
|
|
4219
|
+
_dataSources;
|
|
4129
4220
|
/** @internal Auth type — 'internal' for CALLBACK_TOKEN (managed mode), 'apiKey' otherwise. */
|
|
4130
4221
|
_authType;
|
|
4131
4222
|
/** @internal Usage source sent on step executions (from MINDSTUDIO_REQUEST_SOURCE).
|
|
@@ -5017,12 +5108,47 @@ var MindStudioAgent = class {
|
|
|
5017
5108
|
get files() {
|
|
5018
5109
|
return this._files ??= createFiles(this._filesRequest.bind(this));
|
|
5019
5110
|
}
|
|
5111
|
+
/**
|
|
5112
|
+
* Searchable document corpora.
|
|
5113
|
+
*
|
|
5114
|
+
* @example
|
|
5115
|
+
* ```ts
|
|
5116
|
+
* const Policies = agent.dataSources.defineDataSource('policies');
|
|
5117
|
+
* const { results } = await Policies.search('what are the payment terms?');
|
|
5118
|
+
* ```
|
|
5119
|
+
*/
|
|
5120
|
+
get dataSources() {
|
|
5121
|
+
return this._dataSources ??= createDataSources(
|
|
5122
|
+
this._dataSourcesRequest.bind(this)
|
|
5123
|
+
);
|
|
5124
|
+
}
|
|
5020
5125
|
/**
|
|
5021
5126
|
* @internal Transport for the `files` namespace — POST /_internal/v2/files/<op>
|
|
5022
5127
|
* with the raw hook token (mirrors `_executeDbBatch`).
|
|
5023
5128
|
*/
|
|
5024
5129
|
async _filesRequest(op, body) {
|
|
5025
|
-
|
|
5130
|
+
return this._brokeredRequest("files", op, body, {
|
|
5131
|
+
fallbackMessage: "File operation failed",
|
|
5132
|
+
fallbackCode: "file_error"
|
|
5133
|
+
});
|
|
5134
|
+
}
|
|
5135
|
+
/**
|
|
5136
|
+
* @internal Transport for the `dataSources` namespace —
|
|
5137
|
+
* POST /_internal/v2/datasources/<op> with the raw hook token.
|
|
5138
|
+
*/
|
|
5139
|
+
async _dataSourcesRequest(op, body) {
|
|
5140
|
+
return this._brokeredRequest("datasources", op, body, {
|
|
5141
|
+
fallbackMessage: "Data source operation failed",
|
|
5142
|
+
fallbackCode: "data_source_error"
|
|
5143
|
+
});
|
|
5144
|
+
}
|
|
5145
|
+
/**
|
|
5146
|
+
* @internal Shared shape for the brokered `/_internal/v2/<ns>/<op>` data
|
|
5147
|
+
* planes. Factored out rather than copied per namespace so error handling
|
|
5148
|
+
* can't drift between them.
|
|
5149
|
+
*/
|
|
5150
|
+
async _brokeredRequest(namespace, op, body, errors) {
|
|
5151
|
+
const url = `${this._currentHttpConfig.baseUrl}/_internal/v2/${namespace}/${op}`;
|
|
5026
5152
|
const res = await fetch(url, {
|
|
5027
5153
|
method: "POST",
|
|
5028
5154
|
headers: {
|
|
@@ -5044,8 +5170,8 @@ var MindStudioAgent = class {
|
|
|
5044
5170
|
}
|
|
5045
5171
|
if (!res.ok) {
|
|
5046
5172
|
const rawMsg = json?.errorMessage ?? (typeof json?.error === "string" ? json.error : json?.error?.message);
|
|
5047
|
-
const message = typeof rawMsg === "string" ? rawMsg :
|
|
5048
|
-
const code = json?.errorString ?? json?.code ??
|
|
5173
|
+
const message = typeof rawMsg === "string" ? rawMsg : `${errors.fallbackMessage}: ${res.status} ${res.statusText}`;
|
|
5174
|
+
const code = json?.errorString ?? json?.code ?? errors.fallbackCode;
|
|
5049
5175
|
throw new MindStudioError(message, code, res.status);
|
|
5050
5176
|
}
|
|
5051
5177
|
return json;
|
|
@@ -5726,6 +5852,16 @@ var files = new Proxy(
|
|
|
5726
5852
|
}
|
|
5727
5853
|
}
|
|
5728
5854
|
);
|
|
5855
|
+
var dataSources = new Proxy(
|
|
5856
|
+
{},
|
|
5857
|
+
{
|
|
5858
|
+
get(_, prop) {
|
|
5859
|
+
const target = mindstudio.dataSources;
|
|
5860
|
+
const value = Reflect.get(target, prop, target);
|
|
5861
|
+
return typeof value === "function" ? value.bind(target) : value;
|
|
5862
|
+
}
|
|
5863
|
+
}
|
|
5864
|
+
);
|
|
5729
5865
|
var stream = (data) => mindstudio.stream(data);
|
|
5730
5866
|
var resolveUser = (userId) => mindstudio.resolveUser(userId);
|
|
5731
5867
|
var reportIssue = (input) => mindstudio.reportIssue(input);
|
|
@@ -5739,6 +5875,7 @@ export {
|
|
|
5739
5875
|
Roles,
|
|
5740
5876
|
auth,
|
|
5741
5877
|
blockTypeAliases,
|
|
5878
|
+
dataSources,
|
|
5742
5879
|
db,
|
|
5743
5880
|
index_default as default,
|
|
5744
5881
|
files,
|