@builder.io/ai-utils 0.27.0 → 0.27.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@builder.io/ai-utils",
3
- "version": "0.27.0",
3
+ "version": "0.27.2",
4
4
  "description": "Builder.io AI utils",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
package/src/claw.d.ts ADDED
@@ -0,0 +1,56 @@
1
+ export interface OrgTreeMemorySummary {
2
+ id: string;
3
+ category: string;
4
+ memory: string;
5
+ when: string;
6
+ glob: string | null;
7
+ updatedAt: number;
8
+ }
9
+ export interface OrgBranchCreator {
10
+ userId: string;
11
+ userName?: string;
12
+ userEmail?: string;
13
+ }
14
+ export interface OrgBranch {
15
+ name: string;
16
+ friendlyName?: string;
17
+ projectId: string;
18
+ lastUpdatedAt: number;
19
+ state: string;
20
+ createdBy?: OrgBranchCreator;
21
+ }
22
+ export interface OrgProject {
23
+ id: string;
24
+ name: string;
25
+ repoFullName?: string;
26
+ repoUrl?: string;
27
+ pinned?: boolean;
28
+ archived?: boolean;
29
+ branchCount: number;
30
+ memories?: OrgTreeMemorySummary[];
31
+ }
32
+ export interface OrgTreeResult {
33
+ branches: OrgBranch[];
34
+ projects: OrgProject[];
35
+ }
36
+ export interface ClawMessageContext {
37
+ channelId: string;
38
+ sender: {
39
+ userId?: string;
40
+ displayName?: string;
41
+ };
42
+ timestamp: number;
43
+ }
44
+ export interface ParsedChannelId {
45
+ platform: string;
46
+ type: string;
47
+ ids: string[];
48
+ }
49
+ /**
50
+ * Parses a URI-style channelId into its components.
51
+ *
52
+ * Examples:
53
+ * "slack/thread/T01234/C56789/1234567890.123456" → { platform: "slack", type: "thread", ids: ["T01234", "C56789", "1234567890.123456"] }
54
+ * "jira/comment/cloud-id/PROJ-123" → { platform: "jira", type: "comment", ids: ["cloud-id", "PROJ-123"] }
55
+ */
56
+ export declare function parseChannelId(channelId: string): ParsedChannelId;
package/src/claw.js ADDED
@@ -0,0 +1,16 @@
1
+ // ── Org Tree types (shared between service endpoint and CLI) ──
2
+ /**
3
+ * Parses a URI-style channelId into its components.
4
+ *
5
+ * Examples:
6
+ * "slack/thread/T01234/C56789/1234567890.123456" → { platform: "slack", type: "thread", ids: ["T01234", "C56789", "1234567890.123456"] }
7
+ * "jira/comment/cloud-id/PROJ-123" → { platform: "jira", type: "comment", ids: ["cloud-id", "PROJ-123"] }
8
+ */
9
+ export function parseChannelId(channelId) {
10
+ const parts = channelId.split("/");
11
+ if (parts.length < 2) {
12
+ throw new Error(`Invalid channelId format: ${channelId}`);
13
+ }
14
+ const [platform, type, ...ids] = parts;
15
+ return { platform, type, ids };
16
+ }
package/src/codegen.d.ts CHANGED
@@ -4,7 +4,7 @@ import type { Options as PrettierOptions } from "prettier";
4
4
  import type { UserContext } from "./mapping";
5
5
  import type { ForcedBackup, SetupDependency, GitDiagnostics } from "./projects";
6
6
  import type { Feature } from "./features";
7
- import type { CpuKind } from "./projects";
7
+ import type { CpuKind, BranchType } from "./projects";
8
8
  export type GitSnapshot = unknown;
9
9
  export type ImportType = "named" | "default";
10
10
  export interface ESMImport {
@@ -31,6 +31,7 @@ export interface CustomInstruction {
31
31
  description?: string;
32
32
  allowedTools?: string[];
33
33
  hideUI?: boolean;
34
+ isSkill?: boolean;
34
35
  }
35
36
  export interface CustomAgentInfo {
36
37
  name: string;
@@ -42,11 +43,16 @@ export interface CustomAgentDefinition {
42
43
  systemPrompt?: string;
43
44
  tools?: string[];
44
45
  model?: string;
46
+ mode?: CodeGenMode;
45
47
  position?: string;
46
48
  needDevServer?: boolean;
47
49
  needValidation?: boolean;
48
50
  includeMemories?: boolean;
49
51
  resetAfterRun?: boolean;
52
+ mcpServers?: boolean;
53
+ asyncSubAgents?: boolean;
54
+ queueMode?: QueueMode;
55
+ filePath?: string;
50
56
  }
51
57
  export type CodeGenFramework = "react" | "html" | "mitosis" | "react-native" | "angular" | "vue" | "svelte" | "qwik" | "solid" | "marko" | "swiftui" | "jetpack-compose" | "flutter";
52
58
  export type CodeGenStyleLibrary = "tailwind" | "tailwind-precise" | "emotion" | "styled-components" | "styled-jsx" | "react-native" | undefined;
@@ -200,6 +206,9 @@ export interface GetScreenshotToolInput {
200
206
  width?: number;
201
207
  height?: number;
202
208
  }
209
+ export interface NavigatePreviewToolInput {
210
+ href: string;
211
+ }
203
212
  export interface WebFetchToolInput {
204
213
  url: string;
205
214
  prompt?: string;
@@ -301,11 +310,14 @@ export interface ExitToolInput {
301
310
  question: string;
302
311
  context: string;
303
312
  header?: string;
313
+ /** Question type: "select" for single-choice, "multi-select" for multiple choices, "text" for free-form input. Defaults to "select" if options are present, "text" if not. */
314
+ type?: "select" | "multi-select" | "text";
315
+ /** Placeholder text for text-type questions (e.g., "Enter your API key", "https://localhost:3000") */
316
+ placeholder?: string;
304
317
  options?: Array<{
305
318
  label: string;
306
319
  description: string;
307
320
  }>;
308
- multiSelect?: boolean;
309
321
  }>;
310
322
  isMonorepo?: boolean;
311
323
  isMicrofrontend?: boolean;
@@ -329,11 +341,14 @@ export interface ProposedConfig {
329
341
  context: string;
330
342
  whatYouTried?: string;
331
343
  header?: string;
344
+ /** Question type: "select" for single-choice, "multi-select" for multiple choices, "text" for free-form input */
345
+ type?: "select" | "multi-select" | "text";
346
+ /** Placeholder text for text-type questions */
347
+ placeholder?: string;
332
348
  options?: Array<{
333
349
  label: string;
334
350
  description: string;
335
351
  }>;
336
- multiSelect?: boolean;
337
352
  }>;
338
353
  configuration: {
339
354
  setupCommand: {
@@ -461,6 +476,24 @@ export interface SetEnvVariableToolInput {
461
476
  placeholder?: boolean;
462
477
  explanation?: string;
463
478
  }
479
+ export interface SendMessageToolInput {
480
+ channelId: string;
481
+ markdown: string;
482
+ status: "starting" | "question" | "done:success" | "done:error";
483
+ }
484
+ export interface ReadChannelToolInput {
485
+ channelId: string;
486
+ limit?: number;
487
+ }
488
+ export interface SpawnBranchToolInput {
489
+ projectId: string;
490
+ message: string;
491
+ }
492
+ export interface SendMessageToBranchToolInput {
493
+ projectId: string;
494
+ branchName: string;
495
+ message: string;
496
+ }
464
497
  /** Comment for PR review - used by both SubmitPRReview and SubmitRecording */
465
498
  export interface PRReviewComment {
466
499
  file_path: string;
@@ -521,6 +554,7 @@ export interface CodeGenToolMap {
521
554
  ReadRule: GetRuleToolInput;
522
555
  GetStyleInspiration: GetStyleInspirationToolInput;
523
556
  GetScreenshot: GetScreenshotToolInput;
557
+ NavigatePreview: NavigatePreviewToolInput;
524
558
  MultiEdit: MultiSearchReplaceInput;
525
559
  FindMedia: FindMediaToolInput;
526
560
  Media: MediaToolInput;
@@ -561,11 +595,16 @@ export interface CodeGenToolMap {
561
595
  VerifyValidateCommand: VerifyValidateCommandToolInput;
562
596
  VerifyRuntimeDependency: VerifyRuntimeDependencyToolInput;
563
597
  SetEnvVariable: SetEnvVariableToolInput;
598
+ SendMessage: SendMessageToolInput;
599
+ ReadChannel: ReadChannelToolInput;
600
+ SpawnBranch: SpawnBranchToolInput;
601
+ SendMessageToBranch: SendMessageToBranchToolInput;
564
602
  }
565
603
  export type CodeGenTools = keyof CodeGenToolMap;
566
604
  export type AllCodeGenTools = CodeGenTools | "web_search";
567
605
  export type SessionMode = "planning" | "normal" | "auto-planning" | "deep-research";
568
606
  export type CodeGenMode = "quality" | "quality-v3" | "quality-v4" | "quality-v4-agent";
607
+ export type QueueMode = "next-turn" | "until-idle";
569
608
  export type BaseCodeGenPosition = "fusion" | "editor-ai" | "repo-indexing" | "cli" | "create-app-firebase" | "create-app-lovable" | "builder-code-panel" | "dsi-mcp";
570
609
  export type CodeGenPosition = BaseCodeGenPosition | `${BaseCodeGenPosition}-agent`;
571
610
  export interface RepoIndexingConfig {
@@ -1017,6 +1056,7 @@ export interface CustomInstructionDefinition {
1017
1056
  description: string;
1018
1057
  type: "agent-mode" | "always";
1019
1058
  glob?: string;
1059
+ isSkill?: boolean;
1020
1060
  }
1021
1061
  export interface GenerateCompletionStepSession {
1022
1062
  type: "session";
@@ -1557,7 +1597,7 @@ export interface FusionConfig {
1557
1597
  sessionId?: string;
1558
1598
  browserAutomationInstructions?: string;
1559
1599
  /** Whether this branch is for a code review - affects enabled agents and tools */
1560
- branchType?: "code-review" | "setup-project";
1600
+ branchType?: BranchType;
1561
1601
  featureBranch?: string;
1562
1602
  aiBranch?: string;
1563
1603
  /** Whether this is a fork PR - affects git operations (read-only, can't push) */
package/src/events.d.ts CHANGED
@@ -519,7 +519,21 @@ export declare const ForceSetupAgentV1: {
519
519
  eventName: "fusion.setup.force";
520
520
  version: "1";
521
521
  };
522
- export type FusionEvent = AiTaskCompletedEvent | AiTaskFailedEvent | GitPrCreatedEvent | ClientDevtoolsSessionStartedEvent | FusionProjectCreatedV1 | SetupAgentCompletedV1 | ForceSetupAgentV1;
522
+ export type ClawMessageSentV1 = FusionEventVariant<"claw.message.sent", {
523
+ branchName: string;
524
+ messageType: "text" | "task-result" | "cron-trigger";
525
+ content: string;
526
+ senderType: "user" | "sub-agent" | "system";
527
+ senderId?: string;
528
+ correlationId?: string;
529
+ channelId?: string;
530
+ senderDisplayName?: string;
531
+ }, {}, 1>;
532
+ export declare const ClawMessageSentV1: {
533
+ eventName: "claw.message.sent";
534
+ version: "1";
535
+ };
536
+ export type FusionEvent = AiTaskCompletedEvent | AiTaskFailedEvent | GitPrCreatedEvent | ClientDevtoolsSessionStartedEvent | FusionProjectCreatedV1 | SetupAgentCompletedV1 | ForceSetupAgentV1 | ClawMessageSentV1;
523
537
  export interface ModelPermissionRequiredEvent {
524
538
  type: "assistant.model.permission.required";
525
539
  data: {
package/src/events.js CHANGED
@@ -26,3 +26,7 @@ export const ForceSetupAgentV1 = {
26
26
  eventName: "fusion.setup.force",
27
27
  version: "1",
28
28
  };
29
+ export const ClawMessageSentV1 = {
30
+ eventName: "claw.message.sent",
31
+ version: "1",
32
+ };
package/src/index.d.ts CHANGED
@@ -9,5 +9,6 @@ export * from "./repo-indexing.js";
9
9
  export * from "./organization.js";
10
10
  export * from "./features.js";
11
11
  export * from "./vscode-tunnel.js";
12
+ export * from "./claw.js";
12
13
  export * from "./connectivity/types.js";
13
14
  export { connectivityErrorCodeToLikelyCause, mapConnectivityErrorMessage, } from "./connectivity/error-codes.js";
package/src/index.js CHANGED
@@ -9,5 +9,6 @@ export * from "./repo-indexing.js";
9
9
  export * from "./organization.js";
10
10
  export * from "./features.js";
11
11
  export * from "./vscode-tunnel.js";
12
+ export * from "./claw.js";
12
13
  export * from "./connectivity/types.js";
13
14
  export { connectivityErrorCodeToLikelyCause, mapConnectivityErrorMessage, } from "./connectivity/error-codes.js";
package/src/projects.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { ConnectivityErrorCode, CheckType, LikelyCause } from "./connectivity/types.js";
2
- import type { FileOverride, EnvironmentVariable, LaunchServerState, LaunchServerStatus, BranchBackup, CommitMode, CustomInstruction, CustomAgentDefinition, GitSnapshot, AutoPushMode } from "./codegen";
2
+ import type { FileOverride, EnvironmentVariable, LaunchServerState, LaunchServerStatus, BranchBackup, CommitMode, CustomInstruction, CustomAgentDefinition, GitSnapshot, AutoPushMode, GenerateUserMessage, CodeGenToolMap } from "./codegen";
3
3
  import type { FallbackTokensPrivate } from "./organization";
4
4
  /**
5
5
  * Temporary type for date fields during migration.
@@ -275,6 +275,8 @@ export interface RecordScreenshotOptions {
275
275
  }
276
276
  export type GitBackupRecordBody = GitBackupRecordOptions | {
277
277
  backups: GitBackupRecordOptions[];
278
+ elapsedTime: number;
279
+ error?: string;
278
280
  };
279
281
  export interface GitBackupRecordResult {
280
282
  success: boolean;
@@ -335,7 +337,7 @@ export interface SetupScriptDependency {
335
337
  script: string;
336
338
  }
337
339
  export type FusionExecutionEnvironment = "containerized" | "container-less" | "cloud" | "cloud-v2";
338
- export type AgentType = "setup-project" | "project-configuration";
340
+ export type AgentType = "setup-project" | "project-configuration" | "org-agent";
339
341
  export interface PartialBranchData {
340
342
  name?: string;
341
343
  createdBy: string;
@@ -393,6 +395,10 @@ export interface BranchMetadata {
393
395
  slackChannelId?: string;
394
396
  /** Slack thread timestamp - used to construct the Slack thread URL */
395
397
  slackThreadTs?: string;
398
+ /** User-provided description of what reviewers should focus on */
399
+ description?: string;
400
+ /** Whether the branch is a cloned branch */
401
+ isClonedBranch?: boolean;
396
402
  [key: string]: unknown;
397
403
  }
398
404
  export type PRStatus = "open" | "closed" | "merged" | "draft" | "approved";
@@ -403,7 +409,13 @@ export interface BranchReview {
403
409
  createdAt: number;
404
410
  updatedAt: number;
405
411
  }
406
- export type BranchType = "code-review" | "setup-project";
412
+ export interface OrgAgentConfig {
413
+ maxSubAgents: number;
414
+ syncIntervalMinutes: number;
415
+ enabledTools: string[];
416
+ longLived: boolean;
417
+ }
418
+ export type BranchType = "code-review" | "setup-project" | "org-agent" | "org-worker";
407
419
  export interface BranchSharedData {
408
420
  appName?: string | null;
409
421
  prNumber?: number | null;
@@ -670,6 +682,12 @@ export interface Project {
670
682
  useBranchesCollection?: boolean;
671
683
  /** When true, the project is in code-only mode */
672
684
  codeOnlyMode?: boolean;
685
+ /** When true, this project is an org-level Claw agent */
686
+ isOrgAgent?: boolean;
687
+ /** Configuration for the org agent */
688
+ orgAgentConfig?: OrgAgentConfig;
689
+ /** When true, the project is hidden from normal project listings */
690
+ hidden?: boolean;
673
691
  }
674
692
  /**
675
693
  * Get the state of a branch, checking `state` first and falling back to `deleted` for backwards compatibility.
@@ -733,4 +751,41 @@ export interface BuilderMyContext {
733
751
  };
734
752
  error?: string;
735
753
  }
754
+ export interface WebhookConfig {
755
+ url: string;
756
+ secret?: string;
757
+ timeout?: number;
758
+ }
759
+ export interface CreateBranchOptions {
760
+ projectId: string;
761
+ userMessage: GenerateUserMessage;
762
+ devToolsVersion?: string;
763
+ webhook?: WebhookConfig;
764
+ branchFriendlyName?: string;
765
+ agentType?: AgentType;
766
+ actor: string;
767
+ hidden?: boolean;
768
+ featureFlags?: Record<string, boolean>;
769
+ checkoutBranch?: string | null;
770
+ canHandleTools?: (keyof CodeGenToolMap)[];
771
+ useKube?: boolean;
772
+ fireAndForget?: boolean;
773
+ /** PR number for QA bot branches */
774
+ prNumber?: number;
775
+ /** Whether this branch is for a fork PR - affects git operations */
776
+ isFork?: boolean;
777
+ type?: BranchType;
778
+ /** Optional suffix to append to generated branch names (e.g., model short name for parallel branches) */
779
+ branchNameSuffix?: string;
780
+ }
781
+ export interface SendMessageOptions {
782
+ projectId: string;
783
+ branchName: string;
784
+ userMessage: GenerateUserMessage;
785
+ devToolsVersion?: string;
786
+ featureFlags?: Record<string, boolean>;
787
+ webhook?: WebhookConfig;
788
+ fireAndForget?: boolean;
789
+ canHandleTools?: (keyof CodeGenToolMap)[];
790
+ }
736
791
  export {};