@mindstudio-ai/agent 0.1.18 → 0.1.20

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/index.d.ts CHANGED
@@ -726,6 +726,7 @@ declare class Query<T> implements PromiseLike<T[]> {
726
726
  * (fast path) or a fallback SELECT * with JS processing metadata.
727
727
  */
728
728
  interface CompiledQuery<T> {
729
+ type: 'query';
729
730
  /** Compiled SQL query, or null if JS fallback needed. */
730
731
  query: SqlQuery | null;
731
732
  /** SELECT * fallback query, or null if SQL compiled. */
@@ -744,12 +745,76 @@ interface CompiledQuery<T> {
744
745
  offset?: number;
745
746
  }
746
747
 
748
+ /**
749
+ * Mutation<T> — a lazy write operation backed by SQLite.
750
+ *
751
+ * Created by Table write methods (push, update, remove, removeAll, clear).
752
+ * Like Query, implements PromiseLike so `await` triggers execution. Unlike
753
+ * Query, there's no chaining — a Mutation is a fixed set of SQL statements
754
+ * with a result processor.
755
+ *
756
+ * ## Batch support
757
+ *
758
+ * `db.batch()` calls `_compile()` to extract the SQL without executing,
759
+ * then bundles it with other operations into a single round trip. After
760
+ * execution, `_processResults()` deserializes the raw SQL results.
761
+ *
762
+ * ## Non-batchable mutations
763
+ *
764
+ * Some mutations (e.g. `removeAll` with a JS-fallback predicate) require
765
+ * multi-step execution that can't be expressed as a fixed SQL batch.
766
+ * These are created via `Mutation.fromExecutor()` and work fine when
767
+ * awaited standalone, but throw if passed to `db.batch()`.
768
+ */
769
+
770
+ interface CompiledMutation<TResult> {
771
+ type: 'mutation';
772
+ queries: SqlQuery[];
773
+ config: TableConfig;
774
+ processResult: (results: SqlResult[]) => TResult;
775
+ }
776
+ declare class Mutation<TResult> implements PromiseLike<TResult> {
777
+ /** @internal */
778
+ private readonly _config;
779
+ /** @internal */
780
+ private readonly _queries;
781
+ /** @internal */
782
+ private readonly _processResult;
783
+ /** @internal Non-batchable executor for complex mutations (e.g. removeAll JS fallback). */
784
+ private readonly _executor;
785
+ constructor(config: TableConfig, queries: SqlQuery[], processResult: (results: SqlResult[]) => TResult);
786
+ /**
787
+ * Create a non-batchable mutation that wraps an async executor.
788
+ * Used for operations that require multi-step execution (e.g. removeAll
789
+ * with a JS-fallback predicate: fetch all rows → filter → delete).
790
+ *
791
+ * Works fine when awaited standalone. Throws if passed to db.batch().
792
+ *
793
+ * @internal
794
+ */
795
+ static fromExecutor<T>(config: TableConfig, executor: () => Promise<T>): Mutation<T>;
796
+ then<T1 = TResult, T2 = never>(onfulfilled?: ((value: TResult) => T1 | PromiseLike<T1>) | null, onrejected?: ((reason: unknown) => T2 | PromiseLike<T2>) | null): Promise<T1 | T2>;
797
+ /**
798
+ * @internal Compile this mutation into SQL for batch execution.
799
+ * Returns the queries and a result processor.
800
+ *
801
+ * Throws if this is a non-batchable mutation (created via fromExecutor).
802
+ */
803
+ _compile(): CompiledMutation<TResult>;
804
+ /**
805
+ * @internal Process raw SQL results into the typed result.
806
+ * Used by db.batch() after executing the compiled queries.
807
+ */
808
+ static _processResults<T>(results: SqlResult[], compiled: CompiledMutation<T>): T;
809
+ private _execute;
810
+ }
811
+
747
812
  /**
748
813
  * Table<T> — a typed persistent collection backed by SQLite.
749
814
  *
750
815
  * Created via `db.defineTable<T>(name)`. Every method either returns a
751
- * chainable Query<T> (for lazy reads) or a Promise (for terminal reads
752
- * and writes).
816
+ * chainable Query<T> (for lazy reads), a Mutation<T> (for lazy writes),
817
+ * or a Promise (for terminal reads).
753
818
  *
754
819
  * ## Write operations use RETURNING
755
820
  *
@@ -781,19 +846,19 @@ declare class Table<T> {
781
846
  * Uses `INSERT ... RETURNING *` so the created row comes back in a
782
847
  * single round trip — no separate SELECT needed.
783
848
  */
784
- push(data: PushInput<T>): Promise<T>;
785
- push(data: PushInput<T>[]): Promise<T[]>;
849
+ push(data: PushInput<T>): Mutation<T>;
850
+ push(data: PushInput<T>[]): Mutation<T[]>;
786
851
  /**
787
852
  * Update a row by ID. Only the provided fields are changed.
788
853
  * Returns the updated row via `UPDATE ... RETURNING *`.
789
854
  */
790
- update(id: string, data: UpdateInput<T>): Promise<T>;
791
- remove(id: string): Promise<void>;
855
+ update(id: string, data: UpdateInput<T>): Mutation<T>;
856
+ remove(id: string): Mutation<void>;
792
857
  /**
793
858
  * Remove all rows matching a predicate. Returns the count removed.
794
859
  */
795
- removeAll(predicate: Predicate<T>): Promise<number>;
796
- clear(): Promise<void>;
860
+ removeAll(predicate: Predicate<T>): Mutation<number>;
861
+ clear(): Mutation<void>;
797
862
  }
798
863
 
799
864
  /**
@@ -904,18 +969,21 @@ interface Db {
904
969
  /** Returns a unix timestamp for (now + duration). Use with days/hours/minutes. */
905
970
  fromNow(ms: number): number;
906
971
  /**
907
- * Execute multiple queries in a single round trip. All queries run on
908
- * the same database connection, eliminating per-query HTTP overhead.
972
+ * Execute multiple reads and writes in a single round trip. All
973
+ * operations run on the same database connection, eliminating
974
+ * per-operation HTTP overhead. Writes execute in argument order.
909
975
  *
910
- * Accepts Query objects (lazy, not yet executed). Compiles them to SQL,
976
+ * Accepts Query objects (reads) and Mutation objects (writes from
977
+ * push, update, remove, removeAll, clear). Compiles them to SQL,
911
978
  * sends all in one batch request, and returns typed results.
912
979
  *
913
980
  * @example
914
981
  * ```ts
915
- * const [orders, approvals, vendors] = await db.batch(
916
- * Orders.filter(o => o.status === 'active').take(10),
917
- * Approvals.filter(a => a.status === 'pending').take(25),
918
- * Vendors.sortBy(v => v.createdAt).reverse().take(5),
982
+ * // Mixed reads and writes in one round trip
983
+ * const [, newCard, cards] = await db.batch(
984
+ * Cards.update(card1.id, { position: 1 }),
985
+ * Cards.push({ title: 'New', columnId, position: 0 }),
986
+ * Cards.filter(c => c.columnId === columnId),
919
987
  * );
920
988
  * ```
921
989
  */
@@ -3924,6 +3992,23 @@ interface ScrapeXProfileStepOutput {
3924
3992
  };
3925
3993
  };
3926
3994
  }
3995
+ interface ScreenshotUrlStepInput {
3996
+ /** URL to screenshot */
3997
+ url: string;
3998
+ /** Screenshot mode: viewport captures visible area, fullPage captures entire page */
3999
+ mode?: "viewport" | "fullPage";
4000
+ /** Viewport width in pixels (default: 1280) */
4001
+ width?: number;
4002
+ /** Viewport height in pixels (default: 800, ignored for fullPage mode) */
4003
+ height?: number;
4004
+ /** Milliseconds to wait before capturing (default: 0) */
4005
+ delay?: number;
4006
+ /** CSS selector to wait for before capturing */
4007
+ waitFor?: string;
4008
+ }
4009
+ interface ScreenshotUrlStepOutput {
4010
+ screenshotUrl: string;
4011
+ }
3927
4012
  interface SearchGmailEmailsStepInput {
3928
4013
  /** Gmail search query (e.g. "from:user@example.com", "subject:invoice", "is:unread") */
3929
4014
  query: string;
@@ -4717,7 +4802,7 @@ type GenerateAssetStepOutput = GeneratePdfStepOutput;
4717
4802
  type GenerateTextStepInput = UserMessageStepInput;
4718
4803
  type GenerateTextStepOutput = UserMessageStepOutput;
4719
4804
  /** Union of all available step type names. */
4720
- type StepName = "activeCampaignAddNote" | "activeCampaignCreateContact" | "addSubtitlesToVideo" | "airtableCreateUpdateRecord" | "airtableDeleteRecord" | "airtableGetRecord" | "airtableGetTableRecords" | "analyzeImage" | "analyzeVideo" | "captureThumbnail" | "checkAppRole" | "codaCreateUpdatePage" | "codaCreateUpdateRow" | "codaFindRow" | "codaGetPage" | "codaGetTableRows" | "convertPdfToImages" | "createDataSource" | "createGmailDraft" | "createGoogleCalendarEvent" | "createGoogleDoc" | "createGoogleSheet" | "deleteDataSource" | "deleteDataSourceDocument" | "deleteGmailEmail" | "deleteGoogleCalendarEvent" | "deleteGoogleSheetRows" | "detectChanges" | "detectPII" | "discordEditMessage" | "discordSendFollowUp" | "discordSendMessage" | "downloadVideo" | "enhanceImageGenerationPrompt" | "enhanceVideoGenerationPrompt" | "enrichPerson" | "extractAudioFromVideo" | "extractText" | "fetchDataSourceDocument" | "fetchGoogleDoc" | "fetchGoogleSheet" | "fetchSlackChannelHistory" | "fetchYoutubeCaptions" | "fetchYoutubeChannel" | "fetchYoutubeComments" | "fetchYoutubeVideo" | "generateChart" | "generateImage" | "generateLipsync" | "generateMusic" | "generatePdf" | "generateStaticVideoFromImage" | "generateVideo" | "getGmailAttachments" | "getGmailDraft" | "getGmailEmail" | "getGmailUnreadCount" | "getGoogleCalendarEvent" | "getGoogleDriveFile" | "getGoogleSheetInfo" | "getMediaMetadata" | "httpRequest" | "hubspotCreateCompany" | "hubspotCreateContact" | "hubspotGetCompany" | "hubspotGetContact" | "hunterApiCompanyEnrichment" | "hunterApiDomainSearch" | "hunterApiEmailFinder" | "hunterApiEmailVerification" | "hunterApiPersonEnrichment" | "imageFaceSwap" | "imageRemoveWatermark" | "insertVideoClips" | "listDataSources" | "listGmailDrafts" | "listGmailLabels" | "listGoogleCalendarEvents" | "listGoogleDriveFiles" | "listRecentGmailEmails" | "logic" | "makeDotComRunScenario" | "mergeAudio" | "mergeVideos" | "mixAudioIntoVideo" | "muteVideo" | "n8nRunNode" | "notionCreatePage" | "notionUpdatePage" | "peopleSearch" | "postToLinkedIn" | "postToSlackChannel" | "postToX" | "postToZapier" | "queryAppDatabase" | "queryDataSource" | "queryExternalDatabase" | "redactPII" | "removeBackgroundFromImage" | "replyToGmailEmail" | "resizeVideo" | "runFromConnectorRegistry" | "runPackagedWorkflow" | "scrapeFacebookPage" | "scrapeFacebookPosts" | "scrapeInstagramComments" | "scrapeInstagramMentions" | "scrapeInstagramPosts" | "scrapeInstagramProfile" | "scrapeInstagramReels" | "scrapeLinkedInCompany" | "scrapeLinkedInProfile" | "scrapeMetaThreadsProfile" | "scrapeUrl" | "scrapeXPost" | "scrapeXProfile" | "searchGmailEmails" | "searchGoogle" | "searchGoogleCalendarEvents" | "searchGoogleDrive" | "searchGoogleImages" | "searchGoogleNews" | "searchGoogleTrends" | "searchPerplexity" | "searchXPosts" | "searchYoutube" | "searchYoutubeTrends" | "sendEmail" | "sendGmailDraft" | "sendGmailMessage" | "sendSMS" | "setGmailReadStatus" | "setRunTitle" | "setVariable" | "telegramEditMessage" | "telegramReplyToMessage" | "telegramSendAudio" | "telegramSendFile" | "telegramSendImage" | "telegramSendMessage" | "telegramSendVideo" | "telegramSetTyping" | "textToSpeech" | "transcribeAudio" | "trimMedia" | "updateGmailLabels" | "updateGoogleCalendarEvent" | "updateGoogleDoc" | "updateGoogleSheet" | "uploadDataSourceDocument" | "upscaleImage" | "upscaleVideo" | "userMessage" | "videoFaceSwap" | "videoRemoveBackground" | "videoRemoveWatermark" | "watermarkImage" | "watermarkVideo";
4805
+ type StepName = "activeCampaignAddNote" | "activeCampaignCreateContact" | "addSubtitlesToVideo" | "airtableCreateUpdateRecord" | "airtableDeleteRecord" | "airtableGetRecord" | "airtableGetTableRecords" | "analyzeImage" | "analyzeVideo" | "captureThumbnail" | "checkAppRole" | "codaCreateUpdatePage" | "codaCreateUpdateRow" | "codaFindRow" | "codaGetPage" | "codaGetTableRows" | "convertPdfToImages" | "createDataSource" | "createGmailDraft" | "createGoogleCalendarEvent" | "createGoogleDoc" | "createGoogleSheet" | "deleteDataSource" | "deleteDataSourceDocument" | "deleteGmailEmail" | "deleteGoogleCalendarEvent" | "deleteGoogleSheetRows" | "detectChanges" | "detectPII" | "discordEditMessage" | "discordSendFollowUp" | "discordSendMessage" | "downloadVideo" | "enhanceImageGenerationPrompt" | "enhanceVideoGenerationPrompt" | "enrichPerson" | "extractAudioFromVideo" | "extractText" | "fetchDataSourceDocument" | "fetchGoogleDoc" | "fetchGoogleSheet" | "fetchSlackChannelHistory" | "fetchYoutubeCaptions" | "fetchYoutubeChannel" | "fetchYoutubeComments" | "fetchYoutubeVideo" | "generateChart" | "generateImage" | "generateLipsync" | "generateMusic" | "generatePdf" | "generateStaticVideoFromImage" | "generateVideo" | "getGmailAttachments" | "getGmailDraft" | "getGmailEmail" | "getGmailUnreadCount" | "getGoogleCalendarEvent" | "getGoogleDriveFile" | "getGoogleSheetInfo" | "getMediaMetadata" | "httpRequest" | "hubspotCreateCompany" | "hubspotCreateContact" | "hubspotGetCompany" | "hubspotGetContact" | "hunterApiCompanyEnrichment" | "hunterApiDomainSearch" | "hunterApiEmailFinder" | "hunterApiEmailVerification" | "hunterApiPersonEnrichment" | "imageFaceSwap" | "imageRemoveWatermark" | "insertVideoClips" | "listDataSources" | "listGmailDrafts" | "listGmailLabels" | "listGoogleCalendarEvents" | "listGoogleDriveFiles" | "listRecentGmailEmails" | "logic" | "makeDotComRunScenario" | "mergeAudio" | "mergeVideos" | "mixAudioIntoVideo" | "muteVideo" | "n8nRunNode" | "notionCreatePage" | "notionUpdatePage" | "peopleSearch" | "postToLinkedIn" | "postToSlackChannel" | "postToX" | "postToZapier" | "queryAppDatabase" | "queryDataSource" | "queryExternalDatabase" | "redactPII" | "removeBackgroundFromImage" | "replyToGmailEmail" | "resizeVideo" | "runFromConnectorRegistry" | "runPackagedWorkflow" | "scrapeFacebookPage" | "scrapeFacebookPosts" | "scrapeInstagramComments" | "scrapeInstagramMentions" | "scrapeInstagramPosts" | "scrapeInstagramProfile" | "scrapeInstagramReels" | "scrapeLinkedInCompany" | "scrapeLinkedInProfile" | "scrapeMetaThreadsProfile" | "scrapeUrl" | "scrapeXPost" | "scrapeXProfile" | "screenshotUrl" | "searchGmailEmails" | "searchGoogle" | "searchGoogleCalendarEvents" | "searchGoogleDrive" | "searchGoogleImages" | "searchGoogleNews" | "searchGoogleTrends" | "searchPerplexity" | "searchXPosts" | "searchYoutube" | "searchYoutubeTrends" | "sendEmail" | "sendGmailDraft" | "sendGmailMessage" | "sendSMS" | "setGmailReadStatus" | "setRunTitle" | "setVariable" | "telegramEditMessage" | "telegramReplyToMessage" | "telegramSendAudio" | "telegramSendFile" | "telegramSendImage" | "telegramSendMessage" | "telegramSendVideo" | "telegramSetTyping" | "textToSpeech" | "transcribeAudio" | "trimMedia" | "updateGmailLabels" | "updateGoogleCalendarEvent" | "updateGoogleDoc" | "updateGoogleSheet" | "uploadDataSourceDocument" | "upscaleImage" | "upscaleVideo" | "userMessage" | "videoFaceSwap" | "videoRemoveBackground" | "videoRemoveWatermark" | "watermarkImage" | "watermarkVideo";
4721
4806
  /** Maps step names to their input types. */
4722
4807
  interface StepInputMap {
4723
4808
  activeCampaignAddNote: ActiveCampaignAddNoteStepInput;
@@ -4836,6 +4921,7 @@ interface StepInputMap {
4836
4921
  scrapeUrl: ScrapeUrlStepInput;
4837
4922
  scrapeXPost: ScrapeXPostStepInput;
4838
4923
  scrapeXProfile: ScrapeXProfileStepInput;
4924
+ screenshotUrl: ScreenshotUrlStepInput;
4839
4925
  searchGmailEmails: SearchGmailEmailsStepInput;
4840
4926
  searchGoogle: SearchGoogleStepInput;
4841
4927
  searchGoogleCalendarEvents: SearchGoogleCalendarEventsStepInput;
@@ -4997,6 +5083,7 @@ interface StepOutputMap {
4997
5083
  scrapeUrl: ScrapeUrlStepOutput;
4998
5084
  scrapeXPost: ScrapeXPostStepOutput;
4999
5085
  scrapeXProfile: ScrapeXProfileStepOutput;
5086
+ screenshotUrl: ScreenshotUrlStepOutput;
5000
5087
  searchGmailEmails: SearchGmailEmailsStepOutput;
5001
5088
  searchGoogle: SearchGoogleStepOutput;
5002
5089
  searchGoogleCalendarEvents: SearchGoogleCalendarEventsStepOutput;
@@ -6938,6 +7025,23 @@ interface StepMethods {
6938
7025
  * ```
6939
7026
  */
6940
7027
  scrapeXProfile(step: ScrapeXProfileStepInput, options?: StepExecutionOptions): Promise<StepExecutionResult<ScrapeXProfileStepOutput>>;
7028
+ /**
7029
+ * Capture a screenshot of a web page as a PNG image.
7030
+ *
7031
+ * @remarks
7032
+ * - Takes a viewport or full-page screenshot of the given URL.
7033
+ * - Returns a CDN-hosted PNG image URL.
7034
+ * - Viewport mode captures only the visible area; fullPage captures the entire scrollable page.
7035
+ * - You can customize viewport width/height, add a delay, or wait for a CSS selector before capturing.
7036
+ *
7037
+ * @example
7038
+ * ```typescript
7039
+ * const result = await agent.screenshotUrl({
7040
+ * url: ``,
7041
+ * });
7042
+ * ```
7043
+ */
7044
+ screenshotUrl(step: ScreenshotUrlStepInput, options?: StepExecutionOptions): Promise<StepExecutionResult<ScreenshotUrlStepOutput>>;
6941
7045
  /**
6942
7046
  * Search for emails in the connected Gmail account using a Gmail search query. To list recent inbox emails, pass an empty query string.
6943
7047
  *
@@ -7765,4 +7869,4 @@ declare const stream: (data: string | Record<string, unknown>) => Promise<void>;
7765
7869
  */
7766
7870
  declare const resolveUser: (userId: string) => Promise<ResolvedUser | null>;
7767
7871
 
7768
- 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 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 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 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 HttpRequestStepInput, type HttpRequestStepOutput, 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 ListRecentGmailEmailsStepInput, type ListRecentGmailEmailsStepOutput, type LogicStepInput, type LogicStepOutput, type MakeDotComRunScenarioStepInput, type MakeDotComRunScenarioStepOutput, type MergeAudioStepInput, type MergeAudioStepOutput, type MergeVideosStepInput, type MergeVideosStepOutput, 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 PeopleSearchStepInput, type PeopleSearchStepOutput, type PostToLinkedInStepInput, type PostToLinkedInStepOutput, type PostToSlackChannelStepInput, type PostToSlackChannelStepOutput, type PostToXStepInput, type PostToXStepOutput, type PostToZapierStepInput, type PostToZapierStepOutput, type Predicate, type PushInput, 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 ResizeVideoStepInput, type ResizeVideoStepOutput, type ResolvedUser, Roles, type RunAgentOptions, type RunAgentResult, type RunFromConnectorRegistryStepInput, type RunFromConnectorRegistryStepOutput, type RunPackagedWorkflowStepInput, type RunPackagedWorkflowStepOutput, type ScrapeFacebookPageStepInput, type ScrapeFacebookPageStepOutput, type ScrapeFacebookPostsStepInput, type ScrapeFacebookPostsStepOutput, type ScrapeInstagramCommentsStepInput, type ScrapeInstagramCommentsStepOutput, type ScrapeInstagramMentionsStepInput, type ScrapeInstagramMentionsStepOutput, type ScrapeInstagramPostsStepInput, type ScrapeInstagramPostsStepOutput, type ScrapeInstagramProfileStepInput, type ScrapeInstagramProfileStepOutput, type ScrapeInstagramReelsStepInput, type ScrapeInstagramReelsStepOutput, type ScrapeLinkedInCompanyStepInput, type ScrapeLinkedInCompanyStepOutput, type ScrapeLinkedInProfileStepInput, type ScrapeLinkedInProfileStepOutput, type ScrapeMetaThreadsProfileStepInput, type ScrapeMetaThreadsProfileStepOutput, type ScrapeUrlStepInput, type ScrapeUrlStepOutput, type ScrapeXPostStepInput, type ScrapeXPostStepOutput, type ScrapeXProfileStepInput, type ScrapeXProfileStepOutput, 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 SetGmailReadStatusStepInput, type SetGmailReadStatusStepOutput, type SetRunTitleStepInput, type SetRunTitleStepOutput, type SetVariableStepInput, type SetVariableStepOutput, type StepCostEstimateEntry, type StepExecutionMeta, type StepExecutionOptions, type StepExecutionResult, type StepInputMap, type StepMetadata, type StepMethods, type StepName, type StepOutputMap, type SystemFields, Table, 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 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, auth, blockTypeAliases, db, mindstudio as default, mindstudio, monacoSnippets, resolveUser, stepMetadata, stream };
7872
+ 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 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 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 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 HttpRequestStepInput, type HttpRequestStepOutput, 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 ListRecentGmailEmailsStepInput, type ListRecentGmailEmailsStepOutput, type LogicStepInput, type LogicStepOutput, type MakeDotComRunScenarioStepInput, type MakeDotComRunScenarioStepOutput, type MergeAudioStepInput, type MergeAudioStepOutput, type MergeVideosStepInput, type MergeVideosStepOutput, 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 PeopleSearchStepInput, type PeopleSearchStepOutput, type PostToLinkedInStepInput, type PostToLinkedInStepOutput, type PostToSlackChannelStepInput, type PostToSlackChannelStepOutput, type PostToXStepInput, type PostToXStepOutput, type PostToZapierStepInput, type PostToZapierStepOutput, type Predicate, type PushInput, 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 ResizeVideoStepInput, type ResizeVideoStepOutput, type ResolvedUser, Roles, type RunAgentOptions, type RunAgentResult, type RunFromConnectorRegistryStepInput, type RunFromConnectorRegistryStepOutput, type RunPackagedWorkflowStepInput, type RunPackagedWorkflowStepOutput, type ScrapeFacebookPageStepInput, type ScrapeFacebookPageStepOutput, type ScrapeFacebookPostsStepInput, type ScrapeFacebookPostsStepOutput, type ScrapeInstagramCommentsStepInput, type ScrapeInstagramCommentsStepOutput, type ScrapeInstagramMentionsStepInput, type ScrapeInstagramMentionsStepOutput, type ScrapeInstagramPostsStepInput, type ScrapeInstagramPostsStepOutput, type ScrapeInstagramProfileStepInput, type ScrapeInstagramProfileStepOutput, type ScrapeInstagramReelsStepInput, type ScrapeInstagramReelsStepOutput, type ScrapeLinkedInCompanyStepInput, type ScrapeLinkedInCompanyStepOutput, type ScrapeLinkedInProfileStepInput, type ScrapeLinkedInProfileStepOutput, type ScrapeMetaThreadsProfileStepInput, type ScrapeMetaThreadsProfileStepOutput, 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 SetGmailReadStatusStepInput, type SetGmailReadStatusStepOutput, type SetRunTitleStepInput, type SetRunTitleStepOutput, type SetVariableStepInput, type SetVariableStepOutput, type StepCostEstimateEntry, type StepExecutionMeta, type StepExecutionOptions, type StepExecutionResult, type StepInputMap, type StepMetadata, type StepMethods, type StepName, type StepOutputMap, type SystemFields, Table, 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 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, auth, blockTypeAliases, db, mindstudio as default, mindstudio, monacoSnippets, resolveUser, stepMetadata, stream };
package/dist/index.js CHANGED
@@ -951,10 +951,11 @@ var Query = class _Query {
951
951
  limit: this._limit,
952
952
  offset: this._offset
953
953
  });
954
- return { query, fallbackQuery: null, config: this._config };
954
+ return { type: "query", query, fallbackQuery: null, config: this._config };
955
955
  }
956
956
  const fallbackQuery = buildSelect(this._config.tableName);
957
957
  return {
958
+ type: "query",
958
959
  query: null,
959
960
  fallbackQuery,
960
961
  config: this._config,
@@ -1084,6 +1085,83 @@ function extractFieldName(accessor) {
1084
1085
  return match?.[2] ?? null;
1085
1086
  }
1086
1087
 
1088
+ // src/db/mutation.ts
1089
+ var Mutation = class _Mutation {
1090
+ /** @internal */
1091
+ _config;
1092
+ /** @internal */
1093
+ _queries;
1094
+ /** @internal */
1095
+ _processResult;
1096
+ /** @internal Non-batchable executor for complex mutations (e.g. removeAll JS fallback). */
1097
+ _executor;
1098
+ constructor(config, queries, processResult) {
1099
+ this._config = config;
1100
+ this._queries = queries;
1101
+ this._processResult = processResult;
1102
+ this._executor = void 0;
1103
+ }
1104
+ /**
1105
+ * Create a non-batchable mutation that wraps an async executor.
1106
+ * Used for operations that require multi-step execution (e.g. removeAll
1107
+ * with a JS-fallback predicate: fetch all rows → filter → delete).
1108
+ *
1109
+ * Works fine when awaited standalone. Throws if passed to db.batch().
1110
+ *
1111
+ * @internal
1112
+ */
1113
+ static fromExecutor(config, executor) {
1114
+ const m = new _Mutation(config, [], () => void 0);
1115
+ Object.defineProperty(m, "_executor", { value: executor });
1116
+ return m;
1117
+ }
1118
+ // -------------------------------------------------------------------------
1119
+ // PromiseLike — executes on await
1120
+ // -------------------------------------------------------------------------
1121
+ then(onfulfilled, onrejected) {
1122
+ return this._execute().then(onfulfilled, onrejected);
1123
+ }
1124
+ // -------------------------------------------------------------------------
1125
+ // Batch compilation — used by db.batch()
1126
+ // -------------------------------------------------------------------------
1127
+ /**
1128
+ * @internal Compile this mutation into SQL for batch execution.
1129
+ * Returns the queries and a result processor.
1130
+ *
1131
+ * Throws if this is a non-batchable mutation (created via fromExecutor).
1132
+ */
1133
+ _compile() {
1134
+ if (this._executor) {
1135
+ throw new Error(
1136
+ "This operation cannot be batched (e.g. removeAll with a predicate that cannot compile to SQL). Await it separately."
1137
+ );
1138
+ }
1139
+ return {
1140
+ type: "mutation",
1141
+ queries: this._queries,
1142
+ config: this._config,
1143
+ processResult: this._processResult
1144
+ };
1145
+ }
1146
+ /**
1147
+ * @internal Process raw SQL results into the typed result.
1148
+ * Used by db.batch() after executing the compiled queries.
1149
+ */
1150
+ static _processResults(results, compiled) {
1151
+ return compiled.processResult(results);
1152
+ }
1153
+ // -------------------------------------------------------------------------
1154
+ // Execution
1155
+ // -------------------------------------------------------------------------
1156
+ async _execute() {
1157
+ if (this._executor) {
1158
+ return this._executor();
1159
+ }
1160
+ const results = await this._config.executeBatch(this._queries);
1161
+ return this._processResult(results);
1162
+ }
1163
+ };
1164
+
1087
1165
  // src/db/table.ts
1088
1166
  var Table = class {
1089
1167
  /** @internal */
@@ -1147,7 +1225,7 @@ var Table = class {
1147
1225
  sortBy(accessor) {
1148
1226
  return new Query(this._config).sortBy(accessor);
1149
1227
  }
1150
- async push(data) {
1228
+ push(data) {
1151
1229
  const isArray = Array.isArray(data);
1152
1230
  const items = isArray ? data : [data];
1153
1231
  const queries = items.map(
@@ -1157,71 +1235,76 @@ var Table = class {
1157
1235
  this._config.columns
1158
1236
  )
1159
1237
  );
1160
- const results = await this._config.executeBatch(queries);
1161
- const rows = results.map((r) => {
1162
- if (r.rows.length > 0) {
1163
- return deserializeRow(
1164
- r.rows[0],
1165
- this._config.columns
1166
- );
1167
- }
1168
- return void 0;
1238
+ return new Mutation(this._config, queries, (results) => {
1239
+ const rows = results.map((r) => {
1240
+ if (r.rows.length > 0) {
1241
+ return deserializeRow(
1242
+ r.rows[0],
1243
+ this._config.columns
1244
+ );
1245
+ }
1246
+ return void 0;
1247
+ });
1248
+ return isArray ? rows : rows[0];
1169
1249
  });
1170
- return isArray ? rows : rows[0];
1171
1250
  }
1172
1251
  /**
1173
1252
  * Update a row by ID. Only the provided fields are changed.
1174
1253
  * Returns the updated row via `UPDATE ... RETURNING *`.
1175
1254
  */
1176
- async update(id, data) {
1255
+ update(id, data) {
1177
1256
  const query = buildUpdate(
1178
1257
  this._config.tableName,
1179
1258
  id,
1180
1259
  data,
1181
1260
  this._config.columns
1182
1261
  );
1183
- const results = await this._config.executeBatch([query]);
1184
- return deserializeRow(
1185
- results[0].rows[0],
1186
- this._config.columns
1262
+ return new Mutation(
1263
+ this._config,
1264
+ [query],
1265
+ (results) => deserializeRow(
1266
+ results[0].rows[0],
1267
+ this._config.columns
1268
+ )
1187
1269
  );
1188
1270
  }
1189
- async remove(id) {
1271
+ remove(id) {
1190
1272
  const query = buildDelete(this._config.tableName, `id = ?`, [id]);
1191
- await this._config.executeBatch([query]);
1273
+ return new Mutation(this._config, [query], () => void 0);
1192
1274
  }
1193
1275
  /**
1194
1276
  * Remove all rows matching a predicate. Returns the count removed.
1195
1277
  */
1196
- async removeAll(predicate) {
1278
+ removeAll(predicate) {
1197
1279
  const compiled = compilePredicate(predicate);
1198
1280
  if (compiled.type === "sql") {
1199
1281
  const query = buildDelete(this._config.tableName, compiled.where);
1200
- const results = await this._config.executeBatch([query]);
1201
- return results[0].changes;
1282
+ return new Mutation(this._config, [query], (results) => results[0].changes);
1202
1283
  }
1203
- console.warn(
1204
- `[mindstudio] removeAll predicate on ${this._config.tableName} could not be compiled to SQL \u2014 fetching all rows first`
1205
- );
1206
- const allQuery = buildSelect(this._config.tableName);
1207
- const allResults = await this._config.executeBatch([allQuery]);
1208
- const allRows = allResults[0].rows.map(
1209
- (r) => deserializeRow(
1210
- r,
1211
- this._config.columns
1212
- )
1213
- );
1214
- const matching = allRows.filter((row) => predicate(row));
1215
- if (matching.length === 0) return 0;
1216
- const deleteQueries = matching.filter((row) => row.id).map((row) => buildDelete(this._config.tableName, `id = ?`, [row.id]));
1217
- if (deleteQueries.length > 0) {
1218
- await this._config.executeBatch(deleteQueries);
1219
- }
1220
- return matching.length;
1284
+ return Mutation.fromExecutor(this._config, async () => {
1285
+ console.warn(
1286
+ `[mindstudio] removeAll predicate on ${this._config.tableName} could not be compiled to SQL \u2014 fetching all rows first`
1287
+ );
1288
+ const allQuery = buildSelect(this._config.tableName);
1289
+ const allResults = await this._config.executeBatch([allQuery]);
1290
+ const allRows = allResults[0].rows.map(
1291
+ (r) => deserializeRow(
1292
+ r,
1293
+ this._config.columns
1294
+ )
1295
+ );
1296
+ const matching = allRows.filter((row) => predicate(row));
1297
+ if (matching.length === 0) return 0;
1298
+ const deleteQueries = matching.filter((row) => row.id).map((row) => buildDelete(this._config.tableName, `id = ?`, [row.id]));
1299
+ if (deleteQueries.length > 0) {
1300
+ await this._config.executeBatch(deleteQueries);
1301
+ }
1302
+ return matching.length;
1303
+ });
1221
1304
  }
1222
- async clear() {
1305
+ clear() {
1223
1306
  const query = buildDelete(this._config.tableName);
1224
- await this._config.executeBatch([query]);
1307
+ return new Mutation(this._config, [query], () => void 0);
1225
1308
  }
1226
1309
  };
1227
1310
 
@@ -1247,44 +1330,64 @@ function createDb(databases, executeBatch) {
1247
1330
  ago: (ms) => Date.now() - ms,
1248
1331
  fromNow: (ms) => Date.now() + ms,
1249
1332
  // --- Batch execution ---
1250
- batch: ((...queries) => {
1333
+ batch: ((...operations) => {
1251
1334
  return (async () => {
1252
- const compiled = queries.map((q) => {
1253
- if (!(q instanceof Query)) {
1254
- throw new MindStudioError(
1255
- "db.batch() only accepts Query objects (from .filter(), .sortBy(), etc.)",
1256
- "invalid_batch_query",
1257
- 400
1258
- );
1335
+ const compiled = operations.map((op) => {
1336
+ if (op instanceof Query) {
1337
+ return op._compile();
1338
+ }
1339
+ if (op instanceof Mutation) {
1340
+ return op._compile();
1259
1341
  }
1260
- return q._compile();
1342
+ throw new MindStudioError(
1343
+ "db.batch() only accepts Query and Mutation objects (from .filter(), .update(), .push(), etc.)",
1344
+ "invalid_batch_operation",
1345
+ 400
1346
+ );
1261
1347
  });
1262
1348
  const groups = /* @__PURE__ */ new Map();
1263
1349
  for (let i = 0; i < compiled.length; i++) {
1264
1350
  const c = compiled[i];
1265
1351
  const dbId = c.config.databaseId;
1266
- const sqlQuery = c.query ?? c.fallbackQuery;
1267
1352
  if (!groups.has(dbId)) groups.set(dbId, []);
1268
- groups.get(dbId).push({ index: i, sqlQuery });
1353
+ if (c.type === "query") {
1354
+ const sqlQuery = c.query ?? c.fallbackQuery;
1355
+ groups.get(dbId).push({ opIndex: i, sqlQueries: [sqlQuery] });
1356
+ } else {
1357
+ groups.get(dbId).push({ opIndex: i, sqlQueries: c.queries });
1358
+ }
1269
1359
  }
1270
- const allResults = new Array(compiled.length);
1360
+ const opResults = /* @__PURE__ */ new Map();
1271
1361
  await Promise.all(
1272
1362
  Array.from(groups.entries()).map(async ([dbId, entries]) => {
1273
- const sqlQueries = entries.map((e) => e.sqlQuery);
1274
- const results = await executeBatch(dbId, sqlQueries);
1275
- for (let i = 0; i < entries.length; i++) {
1276
- allResults[entries[i].index] = results[i];
1363
+ const flatQueries = [];
1364
+ const slices = [];
1365
+ for (const entry of entries) {
1366
+ slices.push({
1367
+ opIndex: entry.opIndex,
1368
+ start: flatQueries.length,
1369
+ count: entry.sqlQueries.length
1370
+ });
1371
+ flatQueries.push(...entry.sqlQueries);
1372
+ }
1373
+ const results = await executeBatch(dbId, flatQueries);
1374
+ for (const { opIndex, start, count } of slices) {
1375
+ opResults.set(opIndex, results.slice(start, start + count));
1277
1376
  }
1278
1377
  })
1279
1378
  );
1280
1379
  return compiled.map((c, i) => {
1281
- const result = allResults[i];
1282
- if (!c.query && c.predicates?.length) {
1283
- console.warn(
1284
- `[mindstudio] db.batch(): filter on ${c.config.tableName} could not be compiled to SQL \u2014 processing in JS`
1285
- );
1380
+ const results = opResults.get(i);
1381
+ if (c.type === "query") {
1382
+ if (!c.query && c.predicates?.length) {
1383
+ console.warn(
1384
+ `[mindstudio] db.batch(): filter on ${c.config.tableName} could not be compiled to SQL \u2014 processing in JS`
1385
+ );
1386
+ }
1387
+ return Query._processResults(results[0], c);
1388
+ } else {
1389
+ return Mutation._processResults(results, c);
1286
1390
  }
1287
- return Query._processResults(result, c);
1288
1391
  });
1289
1392
  })();
1290
1393
  })
@@ -1689,6 +1792,9 @@ function applyStepMethods(AgentClass) {
1689
1792
  proto.scrapeXProfile = function(step, options) {
1690
1793
  return this.executeStep("scrapeXProfile", step, options);
1691
1794
  };
1795
+ proto.screenshotUrl = function(step, options) {
1796
+ return this.executeStep("screenshotUrl", step, options);
1797
+ };
1692
1798
  proto.searchGmailEmails = function(step, options) {
1693
1799
  return this.executeStep("searchGmailEmails", step, options);
1694
1800
  };
@@ -2723,6 +2829,7 @@ var monacoSnippets = {
2723
2829
  "scrapeUrl": { fields: [["url", "string"]], outputKeys: ["content"] },
2724
2830
  "scrapeXPost": { fields: [["url", "string"]], outputKeys: ["post"] },
2725
2831
  "scrapeXProfile": { fields: [["url", "string"]], outputKeys: ["profile"] },
2832
+ "screenshotUrl": { fields: [["url", "string"]], outputKeys: ["screenshotUrl"] },
2726
2833
  "searchGmailEmails": { fields: [["query", "string"], ["exportType", ["json", "text"]], ["limit", "string"]], outputKeys: ["emails"] },
2727
2834
  "searchGoogle": { fields: [["query", "string"], ["exportType", ["text", "json"]]], outputKeys: ["results"] },
2728
2835
  "searchGoogleCalendarEvents": { fields: [["exportType", ["json", "text"]]], outputKeys: ["events"] },
@@ -3618,6 +3725,13 @@ var stepMetadata = {
3618
3725
  inputSchema: { "type": "object", "properties": { "url": { "type": "string", "description": "Full URL or username for the X profile (e.g. https://x.com/elonmusk)" } }, "required": ["url"] },
3619
3726
  outputSchema: { "type": "object", "properties": { "profile": { "type": "object", "properties": { "text": { "type": "string", "description": "Markdown/plain-text content of the scraped page" }, "html": { "type": "string", "description": "Raw HTML content of the scraped page" }, "json": { "type": "object", "description": "Structured data extracted from the page" }, "screenshotUrl": { "type": "string", "description": "Screenshot URL of the page (if requested)" }, "metadata": { "type": "object", "properties": { "title": { "type": "string", "description": "Page title" }, "description": { "type": "string", "description": "Page meta description" }, "url": { "type": "string", "description": "Canonical URL" }, "image": { "type": "string", "description": "Open Graph image URL" } }, "required": ["title", "description", "url", "image"], "description": "Page metadata (Open Graph / meta tags)" } }, "required": ["text", "html"], "description": "Scraped profile data including text, HTML, and optional structured JSON" } }, "required": ["profile"] }
3620
3727
  },
3728
+ "screenshotUrl": {
3729
+ stepType: "screenshotUrl",
3730
+ description: "Capture a screenshot of a web page as a PNG image.",
3731
+ usageNotes: "- Takes a viewport or full-page screenshot of the given URL.\n- Returns a CDN-hosted PNG image URL.\n- Viewport mode captures only the visible area; fullPage captures the entire scrollable page.\n- You can customize viewport width/height, add a delay, or wait for a CSS selector before capturing.",
3732
+ inputSchema: { "type": "object", "properties": { "url": { "type": "string", "description": "URL to screenshot" }, "mode": { "enum": ["viewport", "fullPage"], "type": "string", "description": "Screenshot mode: viewport captures visible area, fullPage captures entire page" }, "width": { "type": "number", "description": "Viewport width in pixels (default: 1280)" }, "height": { "type": "number", "description": "Viewport height in pixels (default: 800, ignored for fullPage mode)" }, "delay": { "type": "number", "description": "Milliseconds to wait before capturing (default: 0)" }, "waitFor": { "type": "string", "description": "CSS selector to wait for before capturing" } }, "required": ["url"] },
3733
+ outputSchema: { "type": "object", "properties": { "screenshotUrl": { "type": "string" } }, "required": ["screenshotUrl"] }
3734
+ },
3621
3735
  "searchGmailEmails": {
3622
3736
  stepType: "searchGmailEmails",
3623
3737
  description: "Search for emails in the connected Gmail account using a Gmail search query. To list recent inbox emails, pass an empty query string.",