@mindstudio-ai/agent 0.1.147 → 0.1.149

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
@@ -1073,7 +1073,10 @@ type Accessor<T, R = unknown> = (row: T) => R;
1073
1073
  * queries against the correct database.
1074
1074
  */
1075
1075
  interface TableConfig {
1076
- /** The managed database ID (from app context metadata). */
1076
+ /**
1077
+ * The managed database ID (from app context metadata). Empty on a lazy
1078
+ * table until its context is loaded (`ready`).
1079
+ */
1077
1080
  databaseId: string;
1078
1081
  /** The SQL table name (as declared in defineTable). */
1079
1082
  tableName: string;
@@ -1120,6 +1123,15 @@ interface TableConfig {
1120
1123
  * @returns Array of results in the same order as the input queries
1121
1124
  */
1122
1125
  executeBatch: (queries: SqlQuery[]) => Promise<SqlResult[]>;
1126
+ /**
1127
+ * Loads the app's context, for a table defined before it was available
1128
+ * (the lazy db's `defineTable`). Such a table's database, columns and
1129
+ * managed columns read the context whenever they're read, so whatever
1130
+ * builds SQL from them awaits this first: built without them, a write
1131
+ * stores a user ID with no `@@user@@` prefix and skips the managed-column
1132
+ * check. Absent on a table made with its context in hand.
1133
+ */
1134
+ ready?: () => Promise<void>;
1123
1135
  }
1124
1136
  /** A single SQL query with optional positional bind params. */
1125
1137
  interface SqlQuery {
@@ -1469,6 +1481,14 @@ interface CompiledQuery<T, TResult = T[]> {
1469
1481
  * then bundles it with other operations into a single round trip. After
1470
1482
  * execution, `_processResults()` deserializes the raw SQL results.
1471
1483
  *
1484
+ * ## SQL is built when it runs
1485
+ *
1486
+ * A Mutation holds a builder rather than its statements, called when it's
1487
+ * compiled or executed. The statements depend on the table's columns (a user
1488
+ * column's `@@user@@` prefix) and managed columns, which a lazy table only
1489
+ * knows once the app's context is loaded (`TableConfig.ready`), and that can
1490
+ * be after the write method was called.
1491
+ *
1472
1492
  * ## Non-batchable mutations
1473
1493
  *
1474
1494
  * Some mutations (e.g. `removeAll` with a JS-fallback predicate) require
@@ -1487,12 +1507,12 @@ declare class Mutation<TResult> implements PromiseLike<TResult> {
1487
1507
  /** @internal */
1488
1508
  private readonly _config;
1489
1509
  /** @internal */
1490
- private readonly _queries;
1510
+ private readonly _build;
1491
1511
  /** @internal */
1492
1512
  private readonly _processResult;
1493
1513
  /** @internal Non-batchable executor for complex mutations (e.g. removeAll JS fallback). */
1494
1514
  private readonly _executor;
1495
- constructor(config: TableConfig, queries: SqlQuery[], processResult: (results: SqlResult[]) => TResult);
1515
+ constructor(config: TableConfig, build: () => SqlQuery[], processResult: (results: SqlResult[]) => TResult);
1496
1516
  /**
1497
1517
  * Create a non-batchable mutation that wraps an async executor.
1498
1518
  * Used for operations that require multi-step execution (e.g. removeAll
@@ -1668,10 +1688,11 @@ interface CompiledRawQuery<TResult> {
1668
1688
  processResult: (result: SqlResult) => TResult;
1669
1689
  }
1670
1690
  declare class RawQuery<TResult = Record<string, unknown>[]> implements PromiseLike<TResult> {
1691
+ /** Read when it's compiled: the lazy db's database is known only once its context is. */
1671
1692
  private readonly _databaseId;
1672
1693
  private readonly _executeBatch;
1673
1694
  private readonly _query;
1674
- constructor(databaseId: string, executeBatch: (queries: SqlQuery[]) => Promise<SqlResult[]>, query: SqlQuery);
1695
+ constructor(databaseId: () => string, executeBatch: (queries: SqlQuery[]) => Promise<SqlResult[]>, query: SqlQuery);
1675
1696
  then<T1 = TResult, T2 = never>(onfulfilled?: ((value: TResult) => T1 | PromiseLike<T1>) | null, onrejected?: ((reason: unknown) => T2 | PromiseLike<T2>) | null): Promise<T1 | T2>;
1676
1697
  catch<T2 = never>(onrejected?: ((reason: unknown) => T2 | PromiseLike<T2>) | null): Promise<TResult | T2>;
1677
1698
  /** @internal Compile for db.batch(). */
@@ -5479,7 +5500,12 @@ interface CreateDataSourceStepInput {
5479
5500
  /** Name for the new data source (supports variable interpolation) */
5480
5501
  name: string;
5481
5502
  }
5482
- type CreateDataSourceStepOutput = unknown;
5503
+ interface CreateDataSourceStepOutput {
5504
+ /** ID of the newly created data source */
5505
+ dataSourceId: string;
5506
+ /** Resolved name of the data source */
5507
+ name: string;
5508
+ }
5483
5509
  interface CreateGmailDraftStepInput {
5484
5510
  /** Recipient email address(es), comma-separated for multiple */
5485
5511
  to: string;
@@ -5563,14 +5589,22 @@ interface DeleteDataSourceStepInput {
5563
5589
  /** ID of the data source to delete (supports variable interpolation) */
5564
5590
  dataSourceId: string;
5565
5591
  }
5566
- type DeleteDataSourceStepOutput = unknown;
5592
+ interface DeleteDataSourceStepOutput {
5593
+ /** ID of the deleted data source */
5594
+ dataSourceId: string;
5595
+ }
5567
5596
  interface DeleteDataSourceDocumentStepInput {
5568
5597
  /** ID of the data source containing the document (supports variable interpolation) */
5569
5598
  dataSourceId: string;
5570
5599
  /** ID of the document to delete (supports variable interpolation) */
5571
5600
  documentId: string;
5572
5601
  }
5573
- type DeleteDataSourceDocumentStepOutput = unknown;
5602
+ interface DeleteDataSourceDocumentStepOutput {
5603
+ /** ID of the data source */
5604
+ dataSourceId: string;
5605
+ /** ID of the deleted document */
5606
+ documentId: string;
5607
+ }
5574
5608
  interface DeleteGmailEmailStepInput {
5575
5609
  /** Gmail message ID to delete (move to trash) */
5576
5610
  messageId: string;
@@ -5780,7 +5814,18 @@ interface FetchDataSourceDocumentStepInput {
5780
5814
  /** ID of the document to fetch (supports variable interpolation) */
5781
5815
  documentId: string;
5782
5816
  }
5783
- type FetchDataSourceDocumentStepOutput = unknown;
5817
+ interface FetchDataSourceDocumentStepOutput {
5818
+ /** ID of the document */
5819
+ documentId: string;
5820
+ /** Document name */
5821
+ name: string;
5822
+ /** Full extracted text content */
5823
+ content: string;
5824
+ /** Document summary */
5825
+ summary: string;
5826
+ /** Word count */
5827
+ numWords: number;
5828
+ }
5784
5829
  interface FetchGoogleDocStepInput {
5785
5830
  /** Google Document ID (from the document URL) */
5786
5831
  documentId: string;
@@ -6331,13 +6376,16 @@ interface GenerateLipsyncStepInput {
6331
6376
  * The watermark is a product mark on assets generated in the MindStudio UI. A step run directly via the SDK or API is producing the app's own asset, so it is never watermarked and this flag has no effect there.
6332
6377
  */
6333
6378
  addWatermark?: boolean;
6334
- /** Optional model configuration override. Uses the workflow's default lipsync model if not specified */
6379
+ /** The lip sync model to run and its config, whose keys come from the model: the media (`image` or `video`, and `audio`) and the model's options */
6335
6380
  lipsyncModelOverride?: {
6336
6381
  model: string;
6337
6382
  config?: Record<string, unknown>;
6338
6383
  };
6339
6384
  }
6340
- type GenerateLipsyncStepOutput = unknown;
6385
+ interface GenerateLipsyncStepOutput {
6386
+ /** URL of the generated lip sync video */
6387
+ videoUrl: string;
6388
+ }
6341
6389
  interface GenerateMusicStepInput {
6342
6390
  /** The instructions (prompt) for the music generation */
6343
6391
  text: string;
@@ -6349,7 +6397,10 @@ interface GenerateMusicStepInput {
6349
6397
  config?: Record<string, unknown>;
6350
6398
  };
6351
6399
  }
6352
- type GenerateMusicStepOutput = unknown;
6400
+ interface GenerateMusicStepOutput {
6401
+ /** URL of the generated audio file */
6402
+ audioUrl: string;
6403
+ }
6353
6404
  interface GeneratePdfStepInput {
6354
6405
  /** The HTML or Markdown source template for the asset */
6355
6406
  source: string;
@@ -6498,7 +6549,15 @@ interface GetGmailAttachmentsStepInput {
6498
6549
  /** Google OAuth connection ID */
6499
6550
  connectionId?: string;
6500
6551
  }
6501
- type GetGmailAttachmentsStepOutput = unknown;
6552
+ interface GetGmailAttachmentsStepOutput {
6553
+ /** List of attachments with CDN URLs */
6554
+ attachments: {
6555
+ filename: string;
6556
+ mimeType: string;
6557
+ size: number;
6558
+ url: string;
6559
+ }[];
6560
+ }
6502
6561
  interface GetGmailDraftStepInput {
6503
6562
  /** Gmail draft ID to retrieve */
6504
6563
  draftId: string;
@@ -6545,7 +6604,10 @@ interface GetGmailUnreadCountStepInput {
6545
6604
  /** Google OAuth connection ID */
6546
6605
  connectionId?: string;
6547
6606
  }
6548
- type GetGmailUnreadCountStepOutput = unknown;
6607
+ interface GetGmailUnreadCountStepOutput {
6608
+ /** Number of unread messages in the inbox */
6609
+ unreadCount: number;
6610
+ }
6549
6611
  interface GetGoogleCalendarEventStepInput {
6550
6612
  /** Google OAuth connection ID */
6551
6613
  connectionId?: string;
@@ -6983,7 +7045,25 @@ interface InsertVideoClipsStepOutput {
6983
7045
  videoUrl: string;
6984
7046
  }
6985
7047
  type ListDataSourcesStepInput = Record<string, unknown>;
6986
- type ListDataSourcesStepOutput = unknown;
7048
+ interface ListDataSourcesStepOutput {
7049
+ /** All data sources for the current app version */
7050
+ dataSources: ({
7051
+ id: string;
7052
+ name: string;
7053
+ description: string;
7054
+ /** One of: `loaded`, `hibernating`. */
7055
+ status: "loaded" | "hibernating";
7056
+ dateCreated: string;
7057
+ documents: ({
7058
+ id: string;
7059
+ name: string;
7060
+ /** One of: `processing`, `done`, `error`. */
7061
+ status: "processing" | "done" | "error";
7062
+ numWords?: number;
7063
+ dateUploaded: string;
7064
+ })[];
7065
+ })[];
7066
+ }
6987
7067
  interface ListGmailDraftsStepInput {
6988
7068
  /** Google OAuth connection ID */
6989
7069
  connectionId?: string;
@@ -7011,7 +7091,14 @@ interface ListGmailLabelsStepInput {
7011
7091
  /** Google OAuth connection ID */
7012
7092
  connectionId?: string;
7013
7093
  }
7014
- type ListGmailLabelsStepOutput = unknown;
7094
+ interface ListGmailLabelsStepOutput {
7095
+ /** List of Gmail labels */
7096
+ labels: {
7097
+ id: string;
7098
+ name: string;
7099
+ type: string;
7100
+ }[];
7101
+ }
7015
7102
  interface ListGoogleCalendarEventsStepInput {
7016
7103
  /** Google OAuth connection ID */
7017
7104
  connectionId?: string;
@@ -7094,7 +7181,27 @@ interface ListRecentGmailEmailsStepInput {
7094
7181
  /** Maximum number of emails to return (1-100, default: 5) */
7095
7182
  limit: string;
7096
7183
  }
7097
- type ListRecentGmailEmailsStepOutput = unknown;
7184
+ interface ListRecentGmailEmailsStepOutput {
7185
+ /** List of recent email messages */
7186
+ emails: {
7187
+ /** Gmail message ID */
7188
+ id: string;
7189
+ /** Email subject line */
7190
+ subject: string;
7191
+ /** Sender email address */
7192
+ from: string;
7193
+ /** Recipient email address */
7194
+ to: string;
7195
+ /** Email date */
7196
+ date: string;
7197
+ /** Plain text body content */
7198
+ plainBody: string;
7199
+ /** HTML body content (if available) */
7200
+ htmlBody: string;
7201
+ /** Comma-separated label IDs applied to the email */
7202
+ labels: string;
7203
+ }[];
7204
+ }
7098
7205
  interface LogicStepInput {
7099
7206
  /** Evaluation mode: 'ai' for LLM-based, 'comparison' for operator-based. Default: 'ai' */
7100
7207
  mode?: "ai" | "comparison";
@@ -8317,7 +8424,10 @@ interface SendGmailDraftStepInput {
8317
8424
  /** Google OAuth connection ID */
8318
8425
  connectionId?: string;
8319
8426
  }
8320
- type SendGmailDraftStepOutput = unknown;
8427
+ interface SendGmailDraftStepOutput {
8428
+ /** Gmail message ID of the sent email */
8429
+ messageId: string;
8430
+ }
8321
8431
  interface SendGmailMessageStepInput {
8322
8432
  /** Recipient email address(es), comma-separated for multiple */
8323
8433
  to: string;
@@ -8362,7 +8472,10 @@ interface SetGmailReadStatusStepInput {
8362
8472
  /** Google OAuth connection ID */
8363
8473
  connectionId?: string;
8364
8474
  }
8365
- type SetGmailReadStatusStepOutput = unknown;
8475
+ interface SetGmailReadStatusStepOutput {
8476
+ /** IDs of the updated messages */
8477
+ messageIds: string[];
8478
+ }
8366
8479
  interface SetRunTitleStepInput {
8367
8480
  /** The title to assign to the agent run (supports variable interpolation) */
8368
8481
  title: string;
@@ -8454,19 +8567,21 @@ interface TrimMediaStepOutput {
8454
8567
  mediaUrl: string;
8455
8568
  }
8456
8569
  interface TypesafeEvaluateStepInput {
8457
- /** The content to evaluate. A string, or a JSON object or array. Text only. */
8570
+ /** The content to evaluate. A string, or a JSON object or array. */
8458
8571
  state: string | Record<string, unknown> | unknown[];
8459
8572
  /** Questions to ask about the state, keyed by an id you choose. */
8460
8573
  questions: Record<string, unknown>;
8461
- /** 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. */
8574
+ /** Model id or alias. Defaults to jev-latest. jev-preview tracks the newest TypeSafe release. Pin a version such as jev-1.13.0 when a threshold was tuned against that version. clef and clef-flash run Cloudflare Clef, with the same questions and answers. */
8462
8575
  model?: string;
8576
+ /** Images for Clef to read, up to 4. Each entry is a URL or a data URL (PNG, JPEG, or WebP). A Jev call that includes images is rejected. */
8577
+ images?: string[];
8463
8578
  }
8464
8579
  interface TypesafeEvaluateStepOutput {
8465
8580
  /** Versioned model id that answered, such as jev-1.13.0. */
8466
8581
  model: string;
8467
8582
  /** One answer per question, under the same ids. */
8468
8583
  answers: Record<string, unknown>;
8469
- /** Token counts for the call. Input tokens are what the step bills. */
8584
+ /** Token counts for the call. Input tokens are what the model bills. */
8470
8585
  usage: {
8471
8586
  input_tokens: number;
8472
8587
  output_tokens: number;
@@ -8554,7 +8669,14 @@ interface UploadDataSourceDocumentStepInput {
8554
8669
  /** Display name for the document (supports variable interpolation) */
8555
8670
  fileName: string;
8556
8671
  }
8557
- type UploadDataSourceDocumentStepOutput = unknown;
8672
+ interface UploadDataSourceDocumentStepOutput {
8673
+ /** ID of the uploaded document */
8674
+ documentId: string;
8675
+ /** ID of the data source it was uploaded to */
8676
+ dataSourceId: string;
8677
+ /** Resolved file name */
8678
+ fileName: string;
8679
+ }
8558
8680
  interface UpscaleImageStepInput {
8559
8681
  /** URL of the image to upscale */
8560
8682
  imageUrl: string;
@@ -9928,7 +10050,7 @@ interface StepMethods {
9928
10050
  */
9929
10051
  generateImage(step: GenerateImageStepInput, options?: StepExecutionOptions): Promise<StepExecutionResult<GenerateImageStepOutput>>;
9930
10052
  /**
9931
- * Generate a lip sync video from provided audio and image.
10053
+ * Generate a lip sync video from audio and an image or video.
9932
10054
  *
9933
10055
  * @remarks
9934
10056
  * - In foreground mode, the video is displayed to the user. In background mode, the URL is saved to a variable.
@@ -10877,7 +10999,7 @@ interface StepMethods {
10877
10999
  * - `variables` overrides the composition's `data-composition-variables` defaults, which it reads with `window.__hyperframes.getVariables()`
10878
11000
  * - Whatever the composition loads itself (fonts, scripts, images, video) is fetched as it renders, so each is in the project or at a public URL; a private app file needs a signed URL
10879
11001
  * - fps 24, 30 or 60 (default 30); quality draft, standard or high (default standard); format mp4 (default), webm or mov (both keep transparency), or gif
10880
- * - One render per call, finishing within 15 minutes
11002
+ * - An mp4, webm or mov renders in chunks of about 10 seconds side by side, so a long video takes little longer than a short one; a call finishes within about 30 minutes, and reports its progress as it goes. A gif renders whole, within 15 minutes
10881
11003
  * - A composition HyperFrames can't render fails with HyperFrames' own reason
10882
11004
  *
10883
11005
  * @example
@@ -11471,18 +11593,19 @@ interface StepMethods {
11471
11593
  */
11472
11594
  trimMedia(step: TrimMediaStepInput, options?: StepExecutionOptions): Promise<StepExecutionResult<TrimMediaStepOutput>>;
11473
11595
  /**
11474
- * 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).
11596
+ * Ask structured questions about text, JSON, or images 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). Pass clef or clef-flash to run Cloudflare Clef with the same questions and answers. Clef and Clef Flash can also read up to 4 images.
11475
11597
  *
11476
11598
  * @remarks
11477
- * - 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.
11599
+ * - state is the content to judge: a string, or a JSON object or array (a record, a chat log, application state).
11600
+ * - images is for Clef and Clef Flash. Pass up to 4 PNG, JPEG, or WebP images as URLs. Each file is at most 4 MiB, and 8 MiB together. A call on Jev that includes images is rejected.
11478
11601
  * - 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.
11479
11602
  * - 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.
11480
11603
  * - 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.
11481
11604
  * - 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.
11482
11605
  * - 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.
11483
11606
  * - Send every question you need in one call. The model reads the state once and answers them together.
11484
- * - 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.
11485
- * - Billed per input token. Output tokens are free.
11607
+ * - model defaults to jev-latest, the current stable TypeSafe release. jev-preview tracks the newest TypeSafe release. Pin a version such as jev-1.13.0 when a threshold was tuned against that version. clef and clef-flash run Cloudflare Clef on the same questions and answers. clef is the larger model. clef-flash is the faster one. @cf/cloudflare/clef and @cf/cloudflare/clef-flash name the same two. Clef accepts at most 64 questions, and a question id may use only letters, digits, underscore, dot, and hyphen, up to 100 characters. The response model field is the version that answered.
11608
+ * - Billed per input token. Output tokens are free. Clef and Clef-flash have their own rates.
11486
11609
  *
11487
11610
  * @example
11488
11611
  * ```typescript