@mindstudio-ai/agent 0.1.133 → 0.1.135

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
@@ -380,7 +380,6 @@ interface UserInfoResult {
380
380
  userId: string;
381
381
  displayName: string;
382
382
  role: 'owner' | 'admin' | 'member' | 'guest' | 'agent';
383
- isAgent: boolean;
384
383
  }[];
385
384
  }
386
385
  /**
@@ -745,13 +744,21 @@ interface RunAgentResult {
745
744
  }
746
745
 
747
746
  type AuthType = 'internal' | 'apiKey';
747
+ /**
748
+ * Keeps an execution's calls within the server's concurrency limit, so a
749
+ * `Promise.all` over many steps queues here instead of being refused.
750
+ *
751
+ * The server's limits are per execution (per hook token), so the slots are
752
+ * too: each `runWithContext()` request gets its own, and a persistent sandbox
753
+ * worker's concurrent executions never wait on each other. Outside a request
754
+ * context (API-key use, or one execution per process) the instance holds one
755
+ * set. There is no call cap here: the server enforces it and answers 429 with
756
+ * `Retry-After`, which `http.ts` retries.
757
+ */
748
758
  declare class RateLimiter {
749
- readonly authType: AuthType;
750
- private inflight;
751
759
  private concurrencyLimit;
752
- private callCount;
753
- private callCap;
754
- private queue;
760
+ private perRequest;
761
+ private shared;
755
762
  constructor(authType: AuthType);
756
763
  /** Acquire a slot. Resolves when a concurrent slot is available. */
757
764
  acquire(): Promise<void>;
@@ -759,11 +766,7 @@ declare class RateLimiter {
759
766
  release(): void;
760
767
  /** Update limits from response headers. */
761
768
  updateFromHeaders(headers: Headers): void;
762
- /** Read current rate limit state from response headers. */
763
- static parseHeaders(headers: Headers): {
764
- remaining: number | undefined;
765
- concurrencyRemaining: number | undefined;
766
- };
769
+ private slots;
767
770
  }
768
771
 
769
772
  interface HttpClientConfig {
@@ -3980,9 +3983,9 @@ interface RunTaskResult<T = unknown> {
3980
3983
  * 5. `https://v1.mindstudio-api.com` (production default)
3981
3984
  *
3982
3985
  * Rate limiting is handled automatically:
3983
- * - Concurrent requests are queued to stay within server limits
3986
+ * - Concurrent requests are queued to stay within the server's concurrency
3987
+ * limit, per execution inside MindStudio
3984
3988
  * - 429 responses are retried automatically using the `Retry-After` header
3985
- * - Internal (hook) tokens are capped at 500 calls per execution
3986
3989
  */
3987
3990
  declare class MindStudioAgent$1 {
3988
3991
  /** @internal */
@@ -4055,6 +4058,11 @@ declare class MindStudioAgent$1 {
4055
4058
  * ```
4056
4059
  */
4057
4060
  executeStep<TOutput = unknown>(stepType: string, step: Record<string, unknown>, options?: StepExecutionOptions): Promise<StepExecutionResult<TOutput>>;
4061
+ /**
4062
+ * @internal Async step execution — POST, then poll until the step finishes.
4063
+ * Runs inside one concurrency slot (see `withSlot`).
4064
+ */
4065
+ private _executeStepPolled;
4058
4066
  /**
4059
4067
  * @internal Streaming step execution — sends `Accept: text/event-stream`
4060
4068
  * and parses SSE events for real-time debug logs.
@@ -4075,6 +4083,11 @@ declare class MindStudioAgent$1 {
4075
4083
  * ```
4076
4084
  */
4077
4085
  executeStepBatch(steps: BatchStepInput[], options?: ExecuteStepBatchOptions): Promise<ExecuteStepBatchResult>;
4086
+ /**
4087
+ * @internal Async batch execution — POST, then poll until the batch settles.
4088
+ * Runs inside one concurrency slot (see `withSlot`).
4089
+ */
4090
+ private _executeStepBatchPolled;
4078
4091
  /**
4079
4092
  * Run a task agent — a multi-step tool-use loop that composes SDK actions
4080
4093
  * to produce structured output. The model receives the prompt and tools,
@@ -7958,6 +7971,25 @@ interface TrimMediaStepOutput {
7958
7971
  /** URL of the trimmed media file */
7959
7972
  mediaUrl: string;
7960
7973
  }
7974
+ interface TypesafeEvaluateStepInput {
7975
+ /** The content to evaluate. A string, or a JSON object or array. Text only. */
7976
+ state: string | Record<string, unknown> | unknown[];
7977
+ /** Questions to ask about the state, keyed by an id you choose. */
7978
+ questions: Record<string, unknown>;
7979
+ /** Model id or alias. Defaults to jev-latest. jev-preview tracks the newest release. Pin a version such as jev-1.13.0 when a threshold was tuned against that version. */
7980
+ model?: string;
7981
+ }
7982
+ interface TypesafeEvaluateStepOutput {
7983
+ /** Versioned model id that answered, such as jev-1.13.0. */
7984
+ model: string;
7985
+ /** One answer per question, under the same ids. */
7986
+ answers: Record<string, unknown>;
7987
+ /** Token counts for the call. Input tokens are what the step bills. */
7988
+ usage: {
7989
+ input_tokens: number;
7990
+ output_tokens: number;
7991
+ };
7992
+ }
7961
7993
  interface UpdateGmailLabelsStepInput {
7962
7994
  /** Gmail search query to find messages (alternative to messageIds) */
7963
7995
  query: string;
@@ -8296,7 +8328,7 @@ type GenerateAssetStepOutput = GeneratePdfStepOutput;
8296
8328
  type GenerateTextStepInput = UserMessageStepInput;
8297
8329
  type GenerateTextStepOutput = UserMessageStepOutput;
8298
8330
  /** Union of all available step type names. */
8299
- type StepName = "activeCampaignAddNote" | "activeCampaignCreateContact" | "addSubtitlesToVideo" | "airtableCreateUpdateRecord" | "airtableDeleteRecord" | "airtableGetRecord" | "airtableGetTableRecords" | "analyzeImage" | "analyzeVideo" | "captureThumbnail" | "checkAppRole" | "codaCreateUpdatePage" | "codaCreateUpdateRow" | "codaFindRow" | "codaGetPage" | "codaGetTableRows" | "convertPdfToImages" | "createDataSource" | "createGmailDraft" | "createGoogleCalendarEvent" | "createGoogleDoc" | "createGoogleSheet" | "decomposeImage" | "deleteDataSource" | "deleteDataSourceDocument" | "deleteGmailEmail" | "deleteGoogleCalendarEvent" | "deleteGoogleSheetRows" | "detectChanges" | "detectPII" | "downloadVideo" | "enhanceImageGenerationPrompt" | "enhanceVideoGenerationPrompt" | "enrichPerson" | "extractAudioFromVideo" | "extractText" | "fetchDataSourceDocument" | "fetchGoogleDoc" | "fetchGoogleSheet" | "fetchSlackChannelHistory" | "fetchYoutubeCaptions" | "fetchYoutubeChannel" | "fetchYoutubeComments" | "fetchYoutubeVideo" | "generate3dModel" | "generateImage" | "generateLipsync" | "generateMusic" | "generatePdf" | "generateSound" | "generateStaticVideoFromImage" | "generateVideo" | "getGmailAttachments" | "getGmailDraft" | "getGmailEmail" | "getGmailUnreadCount" | "getGoogleCalendarEvent" | "getGoogleDriveFile" | "getGoogleSheetInfo" | "getMediaMetadata" | "hubspotCreateCompany" | "hubspotCreateContact" | "hubspotGetCompany" | "hubspotGetContact" | "hunterApiCompanyEnrichment" | "hunterApiDomainSearch" | "hunterApiEmailFinder" | "hunterApiEmailVerification" | "hunterApiPersonEnrichment" | "imageFaceSwap" | "imageRemoveWatermark" | "insertVideoClips" | "listDataSources" | "listGmailDrafts" | "listGmailLabels" | "listGoogleCalendarEvents" | "listGoogleDriveFiles" | "listRecentGmailEmails" | "logic" | "makeDotComRunScenario" | "mergeAudio" | "mergeVideos" | "meshyAnimate" | "meshyImageTo3d" | "meshyRemesh" | "meshyRig" | "meshyTextTo3d" | "meshyTexture" | "mixAudioIntoVideo" | "muteVideo" | "n8nRunNode" | "notionCreatePage" | "notionUpdatePage" | "peopleSearch" | "postToLinkedIn" | "postToSlackChannel" | "postToX" | "postToZapier" | "queryDataSource" | "queryExternalDatabase" | "quickbooksApiRequest" | "redactPII" | "removeBackgroundFromImage" | "replyToGmailEmail" | "resizeVideo" | "runFromConnectorRegistry" | "scrapeLinkedInCompany" | "scrapeLinkedInProfile" | "scrapeUrl" | "scrapeXPost" | "scrapeXProfile" | "screenshotUrl" | "searchGmailEmails" | "searchGoogle" | "searchGoogleCalendarEvents" | "searchGoogleDrive" | "searchGoogleImages" | "searchGoogleNews" | "searchGoogleTrends" | "searchPerplexity" | "searchXPosts" | "searchYoutube" | "searchYoutubeTrends" | "sendEmail" | "sendGmailDraft" | "sendGmailMessage" | "sendSlackDirectMessage" | "sendSMS" | "setGmailReadStatus" | "setRunTitle" | "setVariable" | "textToSpeech" | "transcribeAudio" | "trimMedia" | "updateGmailLabels" | "updateGoogleCalendarEvent" | "updateGoogleDoc" | "updateGoogleSheet" | "uploadDataSourceDocument" | "upscaleImage" | "upscaleVideo" | "userMessage" | "videoFaceSwap" | "videoRemoveBackground" | "videoRemoveWatermark" | "watermarkImage" | "watermarkVideo" | "youDotComFinanceResearch" | "youDotComGetPageContent" | "youDotComLiveNews" | "youDotComWebResearch" | "youDotComWebSearch";
8331
+ type StepName = "activeCampaignAddNote" | "activeCampaignCreateContact" | "addSubtitlesToVideo" | "airtableCreateUpdateRecord" | "airtableDeleteRecord" | "airtableGetRecord" | "airtableGetTableRecords" | "analyzeImage" | "analyzeVideo" | "captureThumbnail" | "checkAppRole" | "codaCreateUpdatePage" | "codaCreateUpdateRow" | "codaFindRow" | "codaGetPage" | "codaGetTableRows" | "convertPdfToImages" | "createDataSource" | "createGmailDraft" | "createGoogleCalendarEvent" | "createGoogleDoc" | "createGoogleSheet" | "decomposeImage" | "deleteDataSource" | "deleteDataSourceDocument" | "deleteGmailEmail" | "deleteGoogleCalendarEvent" | "deleteGoogleSheetRows" | "detectChanges" | "detectPII" | "downloadVideo" | "enhanceImageGenerationPrompt" | "enhanceVideoGenerationPrompt" | "enrichPerson" | "extractAudioFromVideo" | "extractText" | "fetchDataSourceDocument" | "fetchGoogleDoc" | "fetchGoogleSheet" | "fetchSlackChannelHistory" | "fetchYoutubeCaptions" | "fetchYoutubeChannel" | "fetchYoutubeComments" | "fetchYoutubeVideo" | "generate3dModel" | "generateImage" | "generateLipsync" | "generateMusic" | "generatePdf" | "generateSound" | "generateStaticVideoFromImage" | "generateVideo" | "getGmailAttachments" | "getGmailDraft" | "getGmailEmail" | "getGmailUnreadCount" | "getGoogleCalendarEvent" | "getGoogleDriveFile" | "getGoogleSheetInfo" | "getMediaMetadata" | "hubspotCreateCompany" | "hubspotCreateContact" | "hubspotGetCompany" | "hubspotGetContact" | "hunterApiCompanyEnrichment" | "hunterApiDomainSearch" | "hunterApiEmailFinder" | "hunterApiEmailVerification" | "hunterApiPersonEnrichment" | "imageFaceSwap" | "imageRemoveWatermark" | "insertVideoClips" | "listDataSources" | "listGmailDrafts" | "listGmailLabels" | "listGoogleCalendarEvents" | "listGoogleDriveFiles" | "listRecentGmailEmails" | "logic" | "makeDotComRunScenario" | "mergeAudio" | "mergeVideos" | "meshyAnimate" | "meshyImageTo3d" | "meshyRemesh" | "meshyRig" | "meshyTextTo3d" | "meshyTexture" | "mixAudioIntoVideo" | "muteVideo" | "n8nRunNode" | "notionCreatePage" | "notionUpdatePage" | "peopleSearch" | "postToLinkedIn" | "postToSlackChannel" | "postToX" | "postToZapier" | "queryDataSource" | "queryExternalDatabase" | "quickbooksApiRequest" | "redactPII" | "removeBackgroundFromImage" | "replyToGmailEmail" | "resizeVideo" | "runFromConnectorRegistry" | "scrapeLinkedInCompany" | "scrapeLinkedInProfile" | "scrapeUrl" | "scrapeXPost" | "scrapeXProfile" | "screenshotUrl" | "searchGmailEmails" | "searchGoogle" | "searchGoogleCalendarEvents" | "searchGoogleDrive" | "searchGoogleImages" | "searchGoogleNews" | "searchGoogleTrends" | "searchPerplexity" | "searchXPosts" | "searchYoutube" | "searchYoutubeTrends" | "sendEmail" | "sendGmailDraft" | "sendGmailMessage" | "sendSlackDirectMessage" | "sendSMS" | "setGmailReadStatus" | "setRunTitle" | "setVariable" | "textToSpeech" | "transcribeAudio" | "trimMedia" | "typesafeEvaluate" | "updateGmailLabels" | "updateGoogleCalendarEvent" | "updateGoogleDoc" | "updateGoogleSheet" | "uploadDataSourceDocument" | "upscaleImage" | "upscaleVideo" | "userMessage" | "videoFaceSwap" | "videoRemoveBackground" | "videoRemoveWatermark" | "watermarkImage" | "watermarkVideo" | "youDotComFinanceResearch" | "youDotComGetPageContent" | "youDotComLiveNews" | "youDotComWebResearch" | "youDotComWebSearch";
8300
8332
  /** Maps step names to their input types. */
8301
8333
  interface StepInputMap {
8302
8334
  activeCampaignAddNote: ActiveCampaignAddNoteStepInput;
@@ -8433,6 +8465,7 @@ interface StepInputMap {
8433
8465
  textToSpeech: TextToSpeechStepInput;
8434
8466
  transcribeAudio: TranscribeAudioStepInput;
8435
8467
  trimMedia: TrimMediaStepInput;
8468
+ typesafeEvaluate: TypesafeEvaluateStepInput;
8436
8469
  updateGmailLabels: UpdateGmailLabelsStepInput;
8437
8470
  updateGoogleCalendarEvent: UpdateGoogleCalendarEventStepInput;
8438
8471
  updateGoogleDoc: UpdateGoogleDocStepInput;
@@ -8588,6 +8621,7 @@ interface StepOutputMap {
8588
8621
  textToSpeech: TextToSpeechStepOutput;
8589
8622
  transcribeAudio: TranscribeAudioStepOutput;
8590
8623
  trimMedia: TrimMediaStepOutput;
8624
+ typesafeEvaluate: TypesafeEvaluateStepOutput;
8591
8625
  updateGmailLabels: UpdateGmailLabelsStepOutput;
8592
8626
  updateGoogleCalendarEvent: UpdateGoogleCalendarEventStepOutput;
8593
8627
  updateGoogleDoc: UpdateGoogleDocStepOutput;
@@ -10869,6 +10903,29 @@ interface StepMethods {
10869
10903
  * ```
10870
10904
  */
10871
10905
  trimMedia(step: TrimMediaStepInput, options?: StepExecutionOptions): Promise<StepExecutionResult<TrimMediaStepOutput>>;
10906
+ /**
10907
+ * Ask TypeSafe structured questions about text or JSON and get calibrated answers. The model returns a probability, a selected option, or a score. It does not write a reply. Each question is a noul (yes or no, as a probability from 0 to 1), a choice (one option from a set you define, with a probability for each), or a score (a rating against ordered levels). Put every question in the same call. The question id is yours: answers come back under the same ids. The model defaults to Jev (jev-latest).
10908
+ *
10909
+ * @remarks
10910
+ * - state is the content to judge: a string, or a JSON object or array (a record, a chat log, application state). Text only. Turn images, audio, and video into text first.
10911
+ * - questions is a map. The key is an id you choose. It is not shown to the model. The answer comes back under the same id.
10912
+ * - A noul asks a yes/no question and returns noul, a probability from 0 (no) to 1 (yes). Optional criteria.true and criteria.false say what a yes and a no mean.
10913
+ * - A choice picks one option. criteria is a map of option id to a short description (or null). At most 255 options. The answer includes the winning choice, a probability for every option, and confidence.
10914
+ * - A score rates the state on an ordered rubric. criteria is 2 to 10 level descriptions, low to high. The answer's score can land between levels, and includes a probability per level plus confidence.
10915
+ * - instructions may be a string, or an object that keeps the question in one field and reference data in the others. Refer to those fields by name in backticks.
10916
+ * - Send every question you need in one call. The model reads the state once and answers them together.
10917
+ * - model defaults to jev-latest, the current stable release. jev-preview tracks the newest release. Pin a version such as jev-1.13.0 when a threshold was tuned against that version. The response model field is the version that answered.
10918
+ * - Billed per input token. Output tokens are free.
10919
+ *
10920
+ * @example
10921
+ * ```typescript
10922
+ * const result = await agent.typesafeEvaluate({
10923
+ * state: ``,
10924
+ * questions: {},
10925
+ * });
10926
+ * ```
10927
+ */
10928
+ typesafeEvaluate(step: TypesafeEvaluateStepInput, options?: StepExecutionOptions): Promise<StepExecutionResult<TypesafeEvaluateStepOutput>>;
10872
10929
  /**
10873
10930
  * Add or remove labels on Gmail messages, identified by message IDs or a search query.
10874
10931
  *
@@ -11784,4 +11841,4 @@ declare const prerender: {
11784
11841
  }>;
11785
11842
  };
11786
11843
 
11787
- export { type Accessor, type ActiveCampaignAddNoteStepInput, type ActiveCampaignAddNoteStepOutput, type ActiveCampaignCreateContactStepInput, type ActiveCampaignCreateContactStepOutput, type AddSubtitlesToVideoStepInput, type AddSubtitlesToVideoStepOutput, type AgentInfo, type AgentOptions, type AggregateRow, type AggregateSelect, type AggregateTerm, type AiSourceVendor, type AirtableCreateUpdateRecordStepInput, type AirtableCreateUpdateRecordStepOutput, type AirtableDeleteRecordStepInput, type AirtableDeleteRecordStepOutput, type AirtableGetRecordStepInput, type AirtableGetRecordStepOutput, type AirtableGetTableRecordsStepInput, type AirtableGetTableRecordsStepOutput, type Analytics, type AnalyticsDateRange, type AnalyticsDimension, type AnalyticsFilter, type AnalyticsFilterOp, type AnalyticsGranularity, type AnalyticsMetric, type AnalyticsQueryResponse, type AnalyticsQueryResultRow, type AnalyticsQuerySpec, type AnalyticsReadOptions, 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 Batchable, 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 CrawlerBucket, type CrawlerHit, type CrawlerOverview, type CreateDataSourceStepInput, type CreateDataSourceStepOutput, type CreateGmailDraftStepInput, type CreateGmailDraftStepOutput, type CreateGoogleCalendarEventStepInput, type CreateGoogleCalendarEventStepOutput, type CreateGoogleDocStepInput, type CreateGoogleDocStepOutput, type CreateGoogleSheetStepInput, type CreateGoogleSheetStepOutput, type Db, type DecomposeImageStepInput, type DecomposeImageStepOutput, 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 DownloadVideoStepInput, type DownloadVideoStepOutput, type EnhanceImageGenerationPromptStepInput, type EnhanceImageGenerationPromptStepOutput, type EnhanceVideoGenerationPromptStepInput, type EnhanceVideoGenerationPromptStepOutput, type EnrichPersonStepInput, type EnrichPersonStepOutput, type EventGrantOptions, type EventGrantResult, type Events, 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 FromSchema, type Generate3dModelStepInput, type Generate3dModelStepOutput, type GenerateAssetStepInput, type GenerateAssetStepOutput, type GenerateImageStepInput, type GenerateImageStepOutput, type GenerateLipsyncStepInput, type GenerateLipsyncStepOutput, type GenerateMusicStepInput, type GenerateMusicStepOutput, type GeneratePdfStepInput, type GeneratePdfStepOutput, type GenerateSoundStepInput, type GenerateSoundStepOutput, 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 Jewel, type JewelConfig, type JewelGradeContext, type JewelMethod, type JewelMethodInput, type JewelPairRecord, type JewelProposal, type JewelProposeOutcome, type JewelProposeResult, type JewelQueueItem, type JewelQueueResolution, type JewelQueueResolveResult, type JewelRunParams, type JewelVerdict, type JewelsApi, type JsonObjectSchema, type JsonSchema, type JsonSchemaTypeName, 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 LiveNow, type LogicStepInput, type LogicStepOutput, MAX_EVENT_PAYLOAD_CHARS, type MakeDotComRunScenarioStepInput, type MakeDotComRunScenarioStepOutput, type MapObject, type MapOutcome, type MapPoint, type MapRunObject, type MapRunOutcome, type MapRunParams, type MapRunRecord, type MapRunResult, type MappedDocument, type Mapper, type MapperConfig, 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 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 QueryDataSourceStepInput, type QueryDataSourceStepOutput, type QueryExternalDatabaseStepInput, type QueryExternalDatabaseStepOutput, type QuickbooksApiRequestStepInput, type QuickbooksApiRequestStepOutput, RawQuery, 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 RunTaskOptions, type RunTaskOptionsWithExample, type RunTaskOptionsWithSchema, type RunTaskResult, type SchemaValidationError, 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 SessionContext, 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 TextToSpeechStepInput, type TextToSpeechStepOutput, type TopSource, 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 Voice, type VoiceCallResult, 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, analytics, auth, blockTypeAliases, dataSources, db, mindstudio as default, defineJewel, defineMapper, deletes, documents, email, events, files, getRequestContext, mindstudio, monacoSnippets, passthrough, prerender, reportIssue, resolveUser, runWithContext, session, skip, stepMetadata, stream, voice, waitUntil };
11844
+ export { type Accessor, type ActiveCampaignAddNoteStepInput, type ActiveCampaignAddNoteStepOutput, type ActiveCampaignCreateContactStepInput, type ActiveCampaignCreateContactStepOutput, type AddSubtitlesToVideoStepInput, type AddSubtitlesToVideoStepOutput, type AgentInfo, type AgentOptions, type AggregateRow, type AggregateSelect, type AggregateTerm, type AiSourceVendor, type AirtableCreateUpdateRecordStepInput, type AirtableCreateUpdateRecordStepOutput, type AirtableDeleteRecordStepInput, type AirtableDeleteRecordStepOutput, type AirtableGetRecordStepInput, type AirtableGetRecordStepOutput, type AirtableGetTableRecordsStepInput, type AirtableGetTableRecordsStepOutput, type Analytics, type AnalyticsDateRange, type AnalyticsDimension, type AnalyticsFilter, type AnalyticsFilterOp, type AnalyticsGranularity, type AnalyticsMetric, type AnalyticsQueryResponse, type AnalyticsQueryResultRow, type AnalyticsQuerySpec, type AnalyticsReadOptions, 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 Batchable, 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 CrawlerBucket, type CrawlerHit, type CrawlerOverview, type CreateDataSourceStepInput, type CreateDataSourceStepOutput, type CreateGmailDraftStepInput, type CreateGmailDraftStepOutput, type CreateGoogleCalendarEventStepInput, type CreateGoogleCalendarEventStepOutput, type CreateGoogleDocStepInput, type CreateGoogleDocStepOutput, type CreateGoogleSheetStepInput, type CreateGoogleSheetStepOutput, type Db, type DecomposeImageStepInput, type DecomposeImageStepOutput, 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 DownloadVideoStepInput, type DownloadVideoStepOutput, type EnhanceImageGenerationPromptStepInput, type EnhanceImageGenerationPromptStepOutput, type EnhanceVideoGenerationPromptStepInput, type EnhanceVideoGenerationPromptStepOutput, type EnrichPersonStepInput, type EnrichPersonStepOutput, type EventGrantOptions, type EventGrantResult, type Events, 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 FromSchema, type Generate3dModelStepInput, type Generate3dModelStepOutput, type GenerateAssetStepInput, type GenerateAssetStepOutput, type GenerateImageStepInput, type GenerateImageStepOutput, type GenerateLipsyncStepInput, type GenerateLipsyncStepOutput, type GenerateMusicStepInput, type GenerateMusicStepOutput, type GeneratePdfStepInput, type GeneratePdfStepOutput, type GenerateSoundStepInput, type GenerateSoundStepOutput, 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 Jewel, type JewelConfig, type JewelGradeContext, type JewelMethod, type JewelMethodInput, type JewelPairRecord, type JewelProposal, type JewelProposeOutcome, type JewelProposeResult, type JewelQueueItem, type JewelQueueResolution, type JewelQueueResolveResult, type JewelRunParams, type JewelVerdict, type JewelsApi, type JsonObjectSchema, type JsonSchema, type JsonSchemaTypeName, 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 LiveNow, type LogicStepInput, type LogicStepOutput, MAX_EVENT_PAYLOAD_CHARS, type MakeDotComRunScenarioStepInput, type MakeDotComRunScenarioStepOutput, type MapObject, type MapOutcome, type MapPoint, type MapRunObject, type MapRunOutcome, type MapRunParams, type MapRunRecord, type MapRunResult, type MappedDocument, type Mapper, type MapperConfig, 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 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 QueryDataSourceStepInput, type QueryDataSourceStepOutput, type QueryExternalDatabaseStepInput, type QueryExternalDatabaseStepOutput, type QuickbooksApiRequestStepInput, type QuickbooksApiRequestStepOutput, RawQuery, 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 RunTaskOptions, type RunTaskOptionsWithExample, type RunTaskOptionsWithSchema, type RunTaskResult, type SchemaValidationError, 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 SessionContext, 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 TextToSpeechStepInput, type TextToSpeechStepOutput, type TopSource, type TranscribeAudioStepInput, type TranscribeAudioStepOutput, type TrimMediaStepInput, type TrimMediaStepOutput, type TypesafeEvaluateStepInput, type TypesafeEvaluateStepOutput, 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 Voice, type VoiceCallResult, 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, analytics, auth, blockTypeAliases, dataSources, db, mindstudio as default, defineJewel, defineMapper, deletes, documents, email, events, files, getRequestContext, mindstudio, monacoSnippets, passthrough, prerender, reportIssue, resolveUser, runWithContext, session, skip, stepMetadata, stream, voice, waitUntil };
package/dist/index.js CHANGED
@@ -23,17 +23,36 @@ var MindStudioError = class extends Error {
23
23
  };
24
24
  }
25
25
  };
26
+ function errorCodeFrom(body, fallback) {
27
+ if (body == null || typeof body !== "object") {
28
+ return fallback;
29
+ }
30
+ const { code, errorString } = body;
31
+ if (typeof code === "string" && code) {
32
+ return code;
33
+ }
34
+ if (typeof errorString === "string" && /^\S+$/.test(errorString)) {
35
+ return errorString;
36
+ }
37
+ return fallback;
38
+ }
26
39
 
27
40
  // src/http.ts
28
41
  async function request(config, method, path, body) {
29
- const url = `${config.baseUrl}/developer/v2${path}`;
42
+ return withSlot(config, () => sendRequest(config, method, path, body));
43
+ }
44
+ async function withSlot(config, fn) {
30
45
  await config.rateLimiter.acquire();
31
46
  try {
32
- return await requestWithRetry(config, method, url, body, 0);
47
+ return await fn();
33
48
  } finally {
34
49
  config.rateLimiter.release();
35
50
  }
36
51
  }
52
+ async function sendRequest(config, method, path, body) {
53
+ const url = `${config.baseUrl}/developer/v2${path}`;
54
+ return requestWithRetry(config, method, url, body, 0);
55
+ }
37
56
  async function requestWithRetry(config, method, url, body, attempt) {
38
57
  const res = await fetch(url, {
39
58
  method,
@@ -66,11 +85,7 @@ async function requestWithRetry(config, method, url, body, attempt) {
66
85
  } else if (body2.error || body2.message || body2.details) {
67
86
  message = JSON.stringify(body2.error ?? body2.message ?? body2.details);
68
87
  }
69
- if (body2.code) {
70
- code = typeof body2.code === "string" ? body2.code : JSON.stringify(body2.code);
71
- } else if (typeof body2.errorString === "string") {
72
- code = body2.errorString;
73
- }
88
+ code = errorCodeFrom(body2, code);
74
89
  } catch {
75
90
  if (text) {
76
91
  const stripped = text.replace(/<[^>]*>/g, " ").replace(/\s+/g, " ").trim();
@@ -393,48 +408,37 @@ async function executeDbBatchOverWs(url, token, databaseId, queries) {
393
408
  }
394
409
 
395
410
  // src/rate-limit.ts
396
- var DEFAULTS = {
397
- internal: { concurrency: 10, callCap: 500 },
398
- apiKey: { concurrency: 20, callCap: Infinity }
411
+ var DEFAULT_CONCURRENCY = {
412
+ internal: 10,
413
+ apiKey: 20
399
414
  };
400
415
  var RateLimiter = class {
416
+ concurrencyLimit;
417
+ // Keyed by the request's context object, so an execution's slots go when it does.
418
+ perRequest = /* @__PURE__ */ new WeakMap();
419
+ shared = { inflight: 0, queue: [] };
401
420
  constructor(authType) {
402
- this.authType = authType;
403
- this.concurrencyLimit = DEFAULTS[authType].concurrency;
404
- this.callCap = DEFAULTS[authType].callCap;
421
+ this.concurrencyLimit = DEFAULT_CONCURRENCY[authType];
405
422
  }
406
- authType;
407
- inflight = 0;
408
- concurrencyLimit;
409
- callCount = 0;
410
- callCap;
411
- queue = [];
412
423
  /** Acquire a slot. Resolves when a concurrent slot is available. */
413
424
  async acquire() {
414
- if (this.callCount >= this.callCap) {
415
- throw new MindStudioError(
416
- `Call cap exceeded (${this.callCap} calls per execution). Reduce the number of API calls or use executeStepBatch() to combine multiple steps.`,
417
- "call_cap_exceeded",
418
- 429
419
- );
420
- }
421
- if (this.inflight < this.concurrencyLimit) {
422
- this.inflight++;
423
- this.callCount++;
425
+ const slots = this.slots();
426
+ if (slots.inflight < this.concurrencyLimit) {
427
+ slots.inflight++;
424
428
  return;
425
429
  }
426
430
  return new Promise((resolve) => {
427
- this.queue.push(() => {
428
- this.inflight++;
429
- this.callCount++;
431
+ slots.queue.push(() => {
432
+ slots.inflight++;
430
433
  resolve();
431
434
  });
432
435
  });
433
436
  }
434
437
  /** Release a slot and let the next queued request proceed. */
435
438
  release() {
436
- this.inflight--;
437
- const next = this.queue.shift();
439
+ const slots = this.slots();
440
+ slots.inflight--;
441
+ const next = slots.queue.shift();
438
442
  if (next) {
439
443
  next();
440
444
  }
@@ -445,21 +449,19 @@ var RateLimiter = class {
445
449
  if (concurrency) {
446
450
  this.concurrencyLimit = parseInt(concurrency, 10);
447
451
  }
448
- const limit = headers.get("x-ratelimit-limit");
449
- if (limit && this.authType === "internal") {
450
- this.callCap = parseInt(limit, 10);
451
- }
452
452
  }
453
- /** Read current rate limit state from response headers. */
454
- static parseHeaders(headers) {
455
- const remaining = headers.get("x-ratelimit-remaining");
456
- const concurrencyRemaining = headers.get(
457
- "x-ratelimit-concurrency-remaining"
458
- );
459
- return {
460
- remaining: remaining != null ? parseInt(remaining, 10) : void 0,
461
- concurrencyRemaining: concurrencyRemaining != null ? parseInt(concurrencyRemaining, 10) : void 0
462
- };
453
+ // Release runs in the same async chain as its acquire, so both resolve the same request's slots.
454
+ slots() {
455
+ const ctx = getRequestContext();
456
+ if (!ctx) {
457
+ return this.shared;
458
+ }
459
+ let slots = this.perRequest.get(ctx);
460
+ if (!slots) {
461
+ slots = { inflight: 0, queue: [] };
462
+ this.perRequest.set(ctx, slots);
463
+ }
464
+ return slots;
463
465
  }
464
466
  };
465
467
 
@@ -4607,6 +4609,13 @@ var stepMetadata = {
4607
4609
  inputSchema: { "type": "object", "properties": { "inputUrl": { "type": "string", "description": "URL of the source audio or video file to trim" }, "start": { "type": ["number", "string"] }, "duration": { "type": ["string", "number"] }, "intermediateAsset": { "type": "boolean", "description": "When true, the asset is created but hidden from the user's gallery (tagged as intermediate)" } }, "required": ["inputUrl"] },
4608
4610
  outputSchema: { "type": "object", "properties": { "mediaUrl": { "type": "string", "description": "URL of the trimmed media file" } }, "required": ["mediaUrl"] }
4609
4611
  },
4612
+ "typesafeEvaluate": {
4613
+ stepType: "typesafeEvaluate",
4614
+ description: "Ask TypeSafe structured questions about text or JSON and get calibrated answers. The model returns a probability, a selected option, or a score. It does not write a reply. Each question is a noul (yes or no, as a probability from 0 to 1), a choice (one option from a set you define, with a probability for each), or a score (a rating against ordered levels). Put every question in the same call. The question id is yours: answers come back under the same ids. The model defaults to Jev (jev-latest).",
4615
+ usageNotes: "- state is the content to judge: a string, or a JSON object or array (a record, a chat log, application state). Text only. Turn images, audio, and video into text first.\n- questions is a map. The key is an id you choose. It is not shown to the model. The answer comes back under the same id.\n- A noul asks a yes/no question and returns noul, a probability from 0 (no) to 1 (yes). Optional criteria.true and criteria.false say what a yes and a no mean.\n- A choice picks one option. criteria is a map of option id to a short description (or null). At most 255 options. The answer includes the winning choice, a probability for every option, and confidence.\n- A score rates the state on an ordered rubric. criteria is 2 to 10 level descriptions, low to high. The answer's score can land between levels, and includes a probability per level plus confidence.\n- instructions may be a string, or an object that keeps the question in one field and reference data in the others. Refer to those fields by name in backticks.\n- Send every question you need in one call. The model reads the state once and answers them together.\n- model defaults to jev-latest, the current stable release. jev-preview tracks the newest release. Pin a version such as jev-1.13.0 when a threshold was tuned against that version. The response model field is the version that answered.\n- Billed per input token. Output tokens are free.",
4616
+ inputSchema: { "type": "object", "properties": { "state": { "anyOf": [{ "type": "string" }, { "type": "object", "properties": {}, "required": [] }, { "type": "array", "items": {} }] }, "questions": { "type": "object", "properties": {}, "required": [], "description": "Questions to ask about the state, keyed by an id you choose." }, "model": { "type": "string", "description": "Model id or alias. Defaults to jev-latest. jev-preview tracks the newest release. Pin a version such as jev-1.13.0 when a threshold was tuned against that version." } }, "required": ["state", "questions"] },
4617
+ outputSchema: { "type": "object", "properties": { "model": { "type": "string", "description": "Versioned model id that answered, such as jev-1.13.0." }, "answers": { "type": "object", "properties": {}, "required": [], "description": "One answer per question, under the same ids." }, "usage": { "type": "object", "properties": { "input_tokens": { "type": "number" }, "output_tokens": { "type": "number" } }, "required": ["input_tokens", "output_tokens"], "description": "Token counts for the call. Input tokens are what the step bills." } }, "required": ["model", "answers", "usage"] }
4618
+ },
4610
4619
  "updateGmailLabels": {
4611
4620
  stepType: "updateGmailLabels",
4612
4621
  description: "Add or remove labels on Gmail messages, identified by message IDs or a search query.",
@@ -5013,7 +5022,7 @@ async function runTaskPoll(httpConfig, body) {
5013
5022
  const errorBody = await res.json().catch(() => ({}));
5014
5023
  throw new MindStudioError(
5015
5024
  errorBody.message ?? errorBody.error ?? `Task poll failed: ${res.status} ${res.statusText}`,
5016
- errorBody.code ?? "poll_error",
5025
+ errorCodeFrom(errorBody, "poll_error"),
5017
5026
  res.status,
5018
5027
  errorBody
5019
5028
  );
@@ -5077,9 +5086,7 @@ async function runTaskStream(httpConfig, body, onEvent) {
5077
5086
  if (errMsg) {
5078
5087
  message = errMsg;
5079
5088
  }
5080
- if (errBody.code) {
5081
- code = errBody.code;
5082
- }
5089
+ code = errorCodeFrom(errBody, code);
5083
5090
  } catch {
5084
5091
  const stripped = text.replace(/<[^>]*>/g, " ").replace(/\s+/g, " ").trim();
5085
5092
  if (stripped) {
@@ -6106,6 +6113,9 @@ function applyStepMethods(AgentClass) {
6106
6113
  proto.trimMedia = function(step, options) {
6107
6114
  return this.executeStep("trimMedia", step, options);
6108
6115
  };
6116
+ proto.typesafeEvaluate = function(step, options) {
6117
+ return this.executeStep("typesafeEvaluate", step, options);
6118
+ };
6109
6119
  proto.updateGmailLabels = function(step, options) {
6110
6120
  return this.executeStep("updateGmailLabels", step, options);
6111
6121
  };
@@ -6294,8 +6304,18 @@ var MindStudioAgent = class {
6294
6304
  options
6295
6305
  );
6296
6306
  }
6307
+ return withSlot(
6308
+ this._httpConfig,
6309
+ () => this._executeStepPolled(stepType, step, options)
6310
+ );
6311
+ }
6312
+ /**
6313
+ * @internal Async step execution — POST, then poll until the step finishes.
6314
+ * Runs inside one concurrency slot (see `withSlot`).
6315
+ */
6316
+ async _executeStepPolled(stepType, step, options) {
6297
6317
  const threadId = options?.threadId ?? (this._reuseThreadId && !getRequestContext() ? this._threadId : void 0);
6298
- const { data: asyncData, headers } = await request(this._currentHttpConfig, "POST", `/steps/${stepType}/execute-async`, {
6318
+ const { data: asyncData, headers } = await sendRequest(this._currentHttpConfig, "POST", `/steps/${stepType}/execute-async`, {
6299
6319
  step,
6300
6320
  ...options?.appId != null && { appId: options.appId },
6301
6321
  ...threadId != null && { threadId },
@@ -6335,7 +6355,7 @@ var MindStudioAgent = class {
6335
6355
  const errorBody = await res.json().catch(() => ({}));
6336
6356
  throw new MindStudioError(
6337
6357
  errorBody.message ?? errorBody.error ?? `[${stepType}] Poll failed: ${res.status} ${res.statusText}`,
6338
- errorBody.code ?? "poll_error",
6358
+ errorCodeFrom(errorBody, "poll_error"),
6339
6359
  res.status,
6340
6360
  errorBody
6341
6361
  );
@@ -6431,9 +6451,7 @@ var MindStudioAgent = class {
6431
6451
  body2.error ?? body2.message ?? body2.details
6432
6452
  );
6433
6453
  }
6434
- if (body2.code) {
6435
- code = body2.code;
6436
- }
6454
+ code = errorCodeFrom(body2, code);
6437
6455
  } catch {
6438
6456
  const stripped = text.replace(/<[^>]*>/g, " ").replace(/\s+/g, " ").trim();
6439
6457
  if (stripped) {
@@ -6585,8 +6603,18 @@ var MindStudioAgent = class {
6585
6603
  * ```
6586
6604
  */
6587
6605
  async executeStepBatch(steps, options) {
6606
+ return withSlot(
6607
+ this._httpConfig,
6608
+ () => this._executeStepBatchPolled(steps, options)
6609
+ );
6610
+ }
6611
+ /**
6612
+ * @internal Async batch execution — POST, then poll until the batch settles.
6613
+ * Runs inside one concurrency slot (see `withSlot`).
6614
+ */
6615
+ async _executeStepBatchPolled(steps, options) {
6588
6616
  const threadId = options?.threadId ?? (this._reuseThreadId && !getRequestContext() ? this._threadId : void 0);
6589
- const { data: asyncData } = await request(this._currentHttpConfig, "POST", "/steps/execute-batch-async", {
6617
+ const { data: asyncData } = await sendRequest(this._currentHttpConfig, "POST", "/steps/execute-batch-async", {
6590
6618
  steps: steps.map((s) => ({
6591
6619
  ...s,
6592
6620
  stepType: resolveStepType2(s.stepType)
@@ -6620,7 +6648,7 @@ var MindStudioAgent = class {
6620
6648
  const errorBody = await res.json().catch(() => ({}));
6621
6649
  throw new MindStudioError(
6622
6650
  errorBody.message ?? errorBody.error ?? `Batch poll failed: ${res.status} ${res.statusText}`,
6623
- errorBody.code ?? "poll_error",
6651
+ errorCodeFrom(errorBody, "poll_error"),
6624
6652
  res.status,
6625
6653
  errorBody
6626
6654
  );
@@ -6916,7 +6944,7 @@ var MindStudioAgent = class {
6916
6944
  const errorBody = await res.json().catch(() => ({}));
6917
6945
  throw new MindStudioError(
6918
6946
  errorBody.message ?? errorBody.error ?? `Poll request failed: ${res.status} ${res.statusText}`,
6919
- errorBody.code ?? "poll_error",
6947
+ errorCodeFrom(errorBody, "poll_error"),
6920
6948
  res.status,
6921
6949
  errorBody
6922
6950
  );
@@ -7604,9 +7632,7 @@ var MindStudioAgent = class {
7604
7632
  body.error ?? body.message ?? body.details
7605
7633
  );
7606
7634
  }
7607
- if (body.code) {
7608
- code = body.code;
7609
- }
7635
+ code = errorCodeFrom(body, code);
7610
7636
  } catch {
7611
7637
  if (text && text.length < 500) {
7612
7638
  message = text;
@@ -8225,7 +8251,7 @@ function deletes(externalIds) {
8225
8251
  };
8226
8252
  }
8227
8253
  var DEFAULT_TIMEOUT_MS = 3e4;
8228
- var DEFAULT_CONCURRENCY = 4;
8254
+ var DEFAULT_CONCURRENCY2 = 4;
8229
8255
  function errorInfo2(e) {
8230
8256
  if (e instanceof Error) {
8231
8257
  return { message: e.message, stack: e.stack };
@@ -8297,7 +8323,7 @@ function defineMapper(source, config) {
8297
8323
  const run = async (params) => {
8298
8324
  const startedAt = Date.now();
8299
8325
  const timeoutMs = params.timeoutMs ?? DEFAULT_TIMEOUT_MS;
8300
- const concurrency = Math.max(1, params.concurrency ?? DEFAULT_CONCURRENCY);
8326
+ const concurrency = Math.max(1, params.concurrency ?? DEFAULT_CONCURRENCY2);
8301
8327
  const objects = Array.isArray(params.objects) ? params.objects : [];
8302
8328
  const outcomes = new Array(objects.length);
8303
8329
  let next = 0;
@@ -8484,6 +8510,7 @@ var monacoSnippets = {
8484
8510
  "textToSpeech": { fields: [["text", "string"]], outputKeys: ["audioUrl"] },
8485
8511
  "transcribeAudio": { fields: [["audioUrl", "string"], ["prompt", "string"]], outputKeys: ["text"] },
8486
8512
  "trimMedia": { fields: [["inputUrl", "string"]], outputKeys: ["mediaUrl"] },
8513
+ "typesafeEvaluate": { fields: [["state", "string"], ["questions", "object"]], outputKeys: ["model", "answers", "usage"] },
8487
8514
  "updateGmailLabels": { fields: [["query", "string"], ["messageIds", "string"], ["addLabelIds", "string"], ["removeLabelIds", "string"]], outputKeys: ["updatedMessageIds"] },
8488
8515
  "updateGoogleCalendarEvent": { fields: [["eventId", "string"]], outputKeys: ["eventId", "htmlLink"] },
8489
8516
  "updateGoogleDoc": { fields: [["documentId", "string"], ["text", "string"], ["textType", ["plain", "html", "markdown"]], ["operationType", ["addToTop", "addToBottom", "overwrite"]]], outputKeys: ["documentUrl"] },