@builder.io/ai-utils 0.40.0 → 0.41.1
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 +1 -1
- package/src/codegen.d.ts +36 -8
- package/src/events.d.ts +45 -3
- package/src/events.js +4 -0
- package/src/index.d.ts +1 -0
- package/src/index.js +1 -0
- package/src/kube-error.d.ts +6 -0
- package/src/kube-error.js +13 -0
- package/src/organization.d.ts +9 -0
- package/src/projects.d.ts +3 -0
package/package.json
CHANGED
package/src/codegen.d.ts
CHANGED
|
@@ -49,7 +49,7 @@ export interface CustomAgentDefinition {
|
|
|
49
49
|
model?: string;
|
|
50
50
|
roundRobinModels?: string[];
|
|
51
51
|
mode?: CodeGenMode;
|
|
52
|
-
position?:
|
|
52
|
+
position?: CodeGenPosition;
|
|
53
53
|
needDevServer?: boolean;
|
|
54
54
|
needValidation?: boolean;
|
|
55
55
|
includeMemories?: boolean;
|
|
@@ -730,7 +730,7 @@ export type AllCodeGenTools = CodeGenTools | "web_search";
|
|
|
730
730
|
export type SessionMode = "planning" | "normal" | "auto-planning" | "deep-research";
|
|
731
731
|
export type CodeGenMode = "quality" | "quality-v3" | "quality-v4" | "quality-v4-agent";
|
|
732
732
|
export type QueueMode = "next-turn" | "until-idle";
|
|
733
|
-
export type BaseCodeGenPosition = "fusion" | "editor-ai" | "repo-indexing" | "cli" | "create-app-firebase" | "create-app-lovable" | "builder-code-panel" | "dsi-mcp";
|
|
733
|
+
export type BaseCodeGenPosition = "fusion" | "editor-ai" | "repo-indexing" | "cli" | "create-app-firebase" | "create-app-lovable" | "builder-code-panel" | "setup-project" | "code-review-orchestrator" | "project-configuration" | "org-agent" | "browser-testing" | "projects-scheduler-memory-extraction" | "unknown" | "dsi-mcp";
|
|
734
734
|
export type CodeGenPosition = BaseCodeGenPosition | `${BaseCodeGenPosition}-agent`;
|
|
735
735
|
export interface RepoIndexingConfig {
|
|
736
736
|
designSystems: string[];
|
|
@@ -743,7 +743,7 @@ export interface LocalMCPTools {
|
|
|
743
743
|
}
|
|
744
744
|
export type CodeGenCategory = `repair-${string}` | `user-normal` | `user-figma` | `user-pdf` | `user-image` | `setup-agent` | `background-${string}` | `indexing-${string}`;
|
|
745
745
|
export interface CodeGenInputOptions {
|
|
746
|
-
position:
|
|
746
|
+
position: CodeGenPosition;
|
|
747
747
|
eventName?: string;
|
|
748
748
|
sessionId: string;
|
|
749
749
|
codeGenMode?: CodeGenMode;
|
|
@@ -787,6 +787,11 @@ export interface CodeGenInputOptions {
|
|
|
787
787
|
enabledTools?: CodeGenTools[];
|
|
788
788
|
enabledMCPs?: string[];
|
|
789
789
|
skipFileDiff?: boolean;
|
|
790
|
+
/**
|
|
791
|
+
* When true, the agent should interrupt its current task to handle this
|
|
792
|
+
* message immediately, rather than finishing the current task first.
|
|
793
|
+
*/
|
|
794
|
+
interruptActiveTask?: boolean;
|
|
790
795
|
/**
|
|
791
796
|
* Local MCP tool definitions from stdio servers (CLI-side only)
|
|
792
797
|
* These tools will be executed on the client side and passed through from the server
|
|
@@ -828,6 +833,7 @@ export interface CodeGenInputOptions {
|
|
|
828
833
|
projectId?: string;
|
|
829
834
|
branchName?: string;
|
|
830
835
|
repoHash?: string;
|
|
836
|
+
repoBranch?: string;
|
|
831
837
|
/**
|
|
832
838
|
* Server-side branch.agentType cached from middleware Firestore lookup.
|
|
833
839
|
* Used to avoid redundant getBranch calls for billing exemption checks.
|
|
@@ -914,6 +920,7 @@ export interface RankedResult {
|
|
|
914
920
|
}
|
|
915
921
|
export interface GenerateCompletionStepThinking {
|
|
916
922
|
type: "thinking";
|
|
923
|
+
content: string;
|
|
917
924
|
}
|
|
918
925
|
export interface FileInfo {
|
|
919
926
|
filePath: string;
|
|
@@ -925,10 +932,6 @@ export interface GenerateCompletionStepUserInput {
|
|
|
925
932
|
prompt: string;
|
|
926
933
|
files: FileInfo[];
|
|
927
934
|
}
|
|
928
|
-
export interface GenerateCompletionStepPlanning {
|
|
929
|
-
type: "planning";
|
|
930
|
-
content: string;
|
|
931
|
-
}
|
|
932
935
|
export interface GenerateCompletionStepUser {
|
|
933
936
|
type: "user";
|
|
934
937
|
displayPrompt: string | undefined;
|
|
@@ -1294,7 +1297,7 @@ export interface GenerateCompletionStepUpdateSetupValue {
|
|
|
1294
1297
|
};
|
|
1295
1298
|
reason: string;
|
|
1296
1299
|
}
|
|
1297
|
-
export type GenerateCompletionStep =
|
|
1300
|
+
export type GenerateCompletionStep = GenerateCompletionStepThinking | GenerateCompletionStepStart | GenerateCompletionStepDelta | GenerateCompletionStepUser | GenerateCompletionStepFile | GenerateCompletionStepDiff | GenerateCompletionStepTool | GenerateCompletionStepError | GenerateCompletionStepContinue | GenerateCompletionStepWaitForInput | GenerateCompletionStepAbort | GenerateCompletionStepDone | GenerateCompletionStepUserInput | GenerateCompletionStepText | GenerateCompletionStepRestore | GenerateCompletionStepState | GenerateCompletionStepStdio | GenerateCompletionStepSession | GenerateCompletionStepServerToolResult | GenerateCompletionStepGit | GenerateCompletionStepBuilderAction | GenerateCompletionStepToolResult | GenerateCompletionStepFusionConfigPatch | GenerateCompletionStepToolCallRequest | GenerateCodeEventMCPStatus | GenerateCodeEventMCPAuthRequired | GenerateCompletionStepDevServerState | GenerateCompletionStepAgent | GenerateCompletionStepBatch | GenerateCompletionStepTerminals | GenerateCompletionStepMetadata | GenerateCompletionStepMessageQueue | GenerateCompletionStepProposeConfig | GenerateCompletionStepUpdateSetupValue | GenerateCompletionStepIde;
|
|
1298
1301
|
export interface ApplyActionsResult {
|
|
1299
1302
|
filePath: string;
|
|
1300
1303
|
addedLines: number;
|
|
@@ -2369,3 +2372,28 @@ export interface TodoItem {
|
|
|
2369
2372
|
status: "pending" | "in_progress" | "completed";
|
|
2370
2373
|
id: string;
|
|
2371
2374
|
}
|
|
2375
|
+
export interface SessionData {
|
|
2376
|
+
lastCompletionId: string | undefined;
|
|
2377
|
+
ownerId: string;
|
|
2378
|
+
initialUrl?: string;
|
|
2379
|
+
contentOrProjectId?: string;
|
|
2380
|
+
createdAt: number;
|
|
2381
|
+
createdBy?: string;
|
|
2382
|
+
updatedAt: number;
|
|
2383
|
+
lastUpdatedBy?: string;
|
|
2384
|
+
beforeCommit?: GitSnapshot;
|
|
2385
|
+
title?: string;
|
|
2386
|
+
id: string;
|
|
2387
|
+
sessionMode: SessionMode;
|
|
2388
|
+
projectId: string | undefined;
|
|
2389
|
+
branchName: string | undefined;
|
|
2390
|
+
repoHash: string | undefined;
|
|
2391
|
+
repoBranch: string | undefined;
|
|
2392
|
+
description?: string;
|
|
2393
|
+
hasPlanToApply?: boolean;
|
|
2394
|
+
cost: number;
|
|
2395
|
+
totalCompletions: number;
|
|
2396
|
+
numUserMessages: number;
|
|
2397
|
+
numNormalUserMessages: number;
|
|
2398
|
+
metadata?: Record<string, any>;
|
|
2399
|
+
}
|
package/src/events.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { BuilderContent, BuilderElement } from "@builder.io/sdk";
|
|
2
2
|
import type { AssistantMessage, AssistantMessageAction } from "./messages.js";
|
|
3
3
|
import type { AssistantSettings } from "./settings.js";
|
|
4
|
-
import type { ExitState, UserSource } from "./codegen.js";
|
|
4
|
+
import type { ExitState, UserSource, CodeGenPosition } from "./codegen.js";
|
|
5
5
|
import type { FileUpload } from "./messages.js";
|
|
6
6
|
export type BuilderAssistantEventHandler = (ev: BuilderAssistantEvent) => void;
|
|
7
7
|
export type BuilderAssistantEvent = AssistantCompletionResultEvent | AssistantErrorEvent | AssistantStreamErrorEvent | AppCloseEvent | AppMessagesClickEvent | AppMessagesGenerationEvent | AppMessageEditCustomInstructionsEvent | AppPromptAbortEvent | AppPromptFocusEvent | AppPromptSubmitEvent | AppReadyEvent | AppSettingsSetEvent | AppThreadNewEvent | AssistantStatsEvent | AssistantThemeEvent | BuilderEditorAuthEvent | BuilderEditorStateEvent | ContentUpdateEvent | ContentApplySnapshotEvent | ModelUndoEvent | ModelRedoEvent | ResultEvent | ThreadCreatedEvent | ThreadMessageCompletedEvent | ThreadMessageCreatedEvent | ThreadMessageDeltaEvent | ThreadMessageFeedbackEvent | ThreadRunStepCreatedEvent | ThreadRunStepDeltaEvent | AppAcceptChangeEvent | AppAcceptRejectEvent | AssistantTrackEvent | AssistantEditorAuthMessage | AppAttachmentTemplateEvent | AppPasteSmartExportEvent | ThreadMessageRetryEvent | AppFigmaImportEvent | AppWebImportEvent | AppMcpServersEvent | AssistantContentInitialEvent | ThreadMessageSummaryEvent | ThreadMessageSummaryCodegenDeltaEvent | ThreadMessageThinkingDeltaEvent | AssistantHeartbeatEvent | ShowUpgradeDialogEvent | AssistantFusionSuggestionEvent | AppNavigateToFusionEvent | ModelPermissionRequiredEvent | ModelPermissionResponseEvent;
|
|
@@ -505,6 +505,44 @@ export declare const GitPrMergedV1: {
|
|
|
505
505
|
eventName: "git.pr.merged";
|
|
506
506
|
version: "1";
|
|
507
507
|
};
|
|
508
|
+
export type ReviewSubmittedV1 = FusionEventVariant<"review.submitted", {
|
|
509
|
+
projectId: string;
|
|
510
|
+
branchName: string;
|
|
511
|
+
repoFullName: string;
|
|
512
|
+
prNumber: number;
|
|
513
|
+
commitSha: string;
|
|
514
|
+
/** Firestore doc ID (deterministic — config.id or generated upfront) */
|
|
515
|
+
reviewDocId: string;
|
|
516
|
+
/** GitHub review ID (empty string for clean reviews) */
|
|
517
|
+
reviewId: string;
|
|
518
|
+
/** Session ID for cost tracking (empty if unavailable) */
|
|
519
|
+
sessionId: string;
|
|
520
|
+
summary: string;
|
|
521
|
+
/** Whether this review includes a visual recording */
|
|
522
|
+
hasRecording?: boolean;
|
|
523
|
+
/** Recording URL if hasRecording is true */
|
|
524
|
+
recordingUrl?: string;
|
|
525
|
+
/** Posted comments from GitHub API */
|
|
526
|
+
postedComments: Array<{
|
|
527
|
+
id: number;
|
|
528
|
+
node_id: string;
|
|
529
|
+
thread_node_id: string;
|
|
530
|
+
path: string;
|
|
531
|
+
line: number | null;
|
|
532
|
+
start_line?: number | null;
|
|
533
|
+
body: string;
|
|
534
|
+
}>;
|
|
535
|
+
riskLevel: "high" | "medium" | "low";
|
|
536
|
+
totalIssuesSubmitted: number;
|
|
537
|
+
issuesPosted: number;
|
|
538
|
+
issuesHigh: number;
|
|
539
|
+
issuesMedium: number;
|
|
540
|
+
issuesDropped: number;
|
|
541
|
+
}, {}, 1>;
|
|
542
|
+
export declare const ReviewSubmittedV1: {
|
|
543
|
+
eventName: "review.submitted";
|
|
544
|
+
version: "1";
|
|
545
|
+
};
|
|
508
546
|
export type BotMentionExternalPrV1 = FusionEventVariant<"bot.mention.external-pr", {
|
|
509
547
|
projectId: string;
|
|
510
548
|
repoFullName: string;
|
|
@@ -554,7 +592,10 @@ export type ClientDevtoolsSessionIdleEventV1 = FusionEventVariant<"client.devtoo
|
|
|
554
592
|
branchName?: string;
|
|
555
593
|
hasPlanToApply?: boolean;
|
|
556
594
|
sessionMode?: string;
|
|
557
|
-
}, {
|
|
595
|
+
}, {
|
|
596
|
+
projectId?: string;
|
|
597
|
+
branchName?: string;
|
|
598
|
+
}, 1>;
|
|
558
599
|
export declare const ClientDevtoolsSessionIdleEventV1: {
|
|
559
600
|
eventName: "client.devtools.session.idle";
|
|
560
601
|
version: "1";
|
|
@@ -636,6 +677,7 @@ export declare const CodegenCompletionV1: {
|
|
|
636
677
|
version: "1";
|
|
637
678
|
};
|
|
638
679
|
export type CodegenUserPromptV1 = FusionEventVariant<"codegen.user.prompt", {
|
|
680
|
+
position: CodeGenPosition;
|
|
639
681
|
completionId: string;
|
|
640
682
|
role?: string;
|
|
641
683
|
projectId?: string;
|
|
@@ -753,7 +795,7 @@ export interface SendMessageToOrgAgentInput {
|
|
|
753
795
|
*/
|
|
754
796
|
autoCreateProject?: boolean;
|
|
755
797
|
}
|
|
756
|
-
export type FusionEvent = AiTaskCompletedEvent | AiTaskFailedEvent | ClientDevtoolsSessionStartedEvent | ClientDevtoolsSessionIdleEventV1 | FusionProjectCreatedV1 | SetupAgentCompletedV1 | GitPrMergedV1 | GitPrCreatedV1 | GitPrClosedV1 | ForceSetupAgentV1 | ClawMessageSentV1 | CodegenCompletionV1 | CodegenUserPromptV1 | GitWebhooksRegisterV1 | FusionProjectSettingsUpdatedV1 | VideoRecordingCompletedV1 | FusionBranchCreatedV1 | FusionBranchContainerStartedV1 | FusionBranchMessageSentV1 | FusionBranchFailedV1 | BotMentionExternalPrV1;
|
|
798
|
+
export type FusionEvent = AiTaskCompletedEvent | AiTaskFailedEvent | ClientDevtoolsSessionStartedEvent | ClientDevtoolsSessionIdleEventV1 | FusionProjectCreatedV1 | SetupAgentCompletedV1 | GitPrMergedV1 | GitPrCreatedV1 | GitPrClosedV1 | ForceSetupAgentV1 | ClawMessageSentV1 | CodegenCompletionV1 | CodegenUserPromptV1 | GitWebhooksRegisterV1 | FusionProjectSettingsUpdatedV1 | VideoRecordingCompletedV1 | FusionBranchCreatedV1 | FusionBranchContainerStartedV1 | FusionBranchMessageSentV1 | FusionBranchFailedV1 | BotMentionExternalPrV1 | ReviewSubmittedV1;
|
|
757
799
|
export interface ModelPermissionRequiredEvent {
|
|
758
800
|
type: "assistant.model.permission.required";
|
|
759
801
|
data: {
|
package/src/events.js
CHANGED
|
@@ -18,6 +18,10 @@ export const GitPrMergedV1 = {
|
|
|
18
18
|
eventName: "git.pr.merged",
|
|
19
19
|
version: "1",
|
|
20
20
|
};
|
|
21
|
+
export const ReviewSubmittedV1 = {
|
|
22
|
+
eventName: "review.submitted",
|
|
23
|
+
version: "1",
|
|
24
|
+
};
|
|
21
25
|
export const BotMentionExternalPrV1 = {
|
|
22
26
|
eventName: "bot.mention.external-pr",
|
|
23
27
|
version: "1",
|
package/src/index.d.ts
CHANGED
|
@@ -10,5 +10,6 @@ export * from "./organization.js";
|
|
|
10
10
|
export * from "./features.js";
|
|
11
11
|
export * from "./vscode-tunnel.js";
|
|
12
12
|
export * from "./claw.js";
|
|
13
|
+
export * from "./kube-error.js";
|
|
13
14
|
export * from "./connectivity/types.js";
|
|
14
15
|
export { connectivityErrorCodeToLikelyCause, mapConnectivityErrorMessage, } from "./connectivity/error-codes.js";
|
package/src/index.js
CHANGED
|
@@ -10,5 +10,6 @@ export * from "./organization.js";
|
|
|
10
10
|
export * from "./features.js";
|
|
11
11
|
export * from "./vscode-tunnel.js";
|
|
12
12
|
export * from "./claw.js";
|
|
13
|
+
export * from "./kube-error.js";
|
|
13
14
|
export * from "./connectivity/types.js";
|
|
14
15
|
export { connectivityErrorCodeToLikelyCause, mapConnectivityErrorMessage, } from "./connectivity/error-codes.js";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extract the HTTP status code from a Kubernetes client error.
|
|
3
|
+
* ApiException (v1.x) uses numeric `.code`, but raw network errors (e.g. ECONNREFUSED)
|
|
4
|
+
* set `.code` to a string. This helper ensures we always return a number.
|
|
5
|
+
*/
|
|
6
|
+
export declare function kubeErrorStatus(error: any): number;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extract the HTTP status code from a Kubernetes client error.
|
|
3
|
+
* ApiException (v1.x) uses numeric `.code`, but raw network errors (e.g. ECONNREFUSED)
|
|
4
|
+
* set `.code` to a string. This helper ensures we always return a number.
|
|
5
|
+
*/
|
|
6
|
+
export function kubeErrorStatus(error) {
|
|
7
|
+
var _a;
|
|
8
|
+
if (typeof error.code === "number")
|
|
9
|
+
return error.code;
|
|
10
|
+
if (typeof ((_a = error.response) === null || _a === void 0 ? void 0 : _a.statusCode) === "number")
|
|
11
|
+
return error.response.statusCode;
|
|
12
|
+
return 0;
|
|
13
|
+
}
|
package/src/organization.d.ts
CHANGED
|
@@ -54,6 +54,14 @@ export interface FallbackTokensPrivate {
|
|
|
54
54
|
token: string;
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
|
+
export type FusionWebhookEvent = "background.agent.started" | "background.agent.completed" | "background.agent.error";
|
|
58
|
+
export type FusionWebhookEvents = ["all"] | FusionWebhookEvent[];
|
|
59
|
+
export interface FusionWebhook {
|
|
60
|
+
id: string;
|
|
61
|
+
disabled?: boolean;
|
|
62
|
+
url: string;
|
|
63
|
+
events: FusionWebhookEvents;
|
|
64
|
+
}
|
|
57
65
|
interface OrganizationSettings {
|
|
58
66
|
attribution?: string[];
|
|
59
67
|
visualEditorAiStyleInspirationURL?: string;
|
|
@@ -92,6 +100,7 @@ interface OrganizationSettings {
|
|
|
92
100
|
ticketAssessmentPrompt?: string;
|
|
93
101
|
ticketAssessmentModel?: string;
|
|
94
102
|
ticketAssessmentDailyLimit?: number;
|
|
103
|
+
fusionWebhooks?: FusionWebhook[];
|
|
95
104
|
}
|
|
96
105
|
interface RoleOptions {
|
|
97
106
|
read?: boolean;
|
package/src/projects.d.ts
CHANGED
|
@@ -405,6 +405,8 @@ export interface BranchMetadata {
|
|
|
405
405
|
description?: string;
|
|
406
406
|
/** Whether the branch is a cloned branch */
|
|
407
407
|
isClonedBranch?: boolean;
|
|
408
|
+
/** Data passed in via /agents/run api that we echo in webhook response **/
|
|
409
|
+
webhookContext?: Record<string, unknown>;
|
|
408
410
|
[key: string]: unknown;
|
|
409
411
|
}
|
|
410
412
|
export type PRStatus = "open" | "closed" | "merged" | "draft" | "approved";
|
|
@@ -752,6 +754,7 @@ export interface OrganizationPrivate {
|
|
|
752
754
|
createdAt: number;
|
|
753
755
|
updatedAt: number;
|
|
754
756
|
fallbackTokens?: FallbackTokensPrivate;
|
|
757
|
+
fusionWebhookSecrets?: Record<string, string>;
|
|
755
758
|
}
|
|
756
759
|
export interface CreateProjectOptions {
|
|
757
760
|
name?: string;
|