@builder.io/ai-utils 0.29.1 → 0.30.0

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.29.1",
3
+ "version": "0.30.0",
4
4
  "description": "Builder.io AI utils",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
package/src/codegen.d.ts CHANGED
@@ -32,6 +32,8 @@ export interface CustomInstruction {
32
32
  allowedTools?: string[];
33
33
  hideUI?: boolean;
34
34
  isSkill?: boolean;
35
+ disableModelInvocation?: boolean;
36
+ userInvocable?: boolean;
35
37
  }
36
38
  export interface CustomAgentInfo {
37
39
  name: string;
@@ -486,12 +488,15 @@ export interface SendMessageToolInput {
486
488
  channelId: string;
487
489
  markdown: string;
488
490
  status: "starting" | "question" | "will-follow-up" | "done:success" | "done:error";
491
+ loadingMessage?: string;
489
492
  }
490
493
  export interface SpawnBranchToolInput {
491
494
  projectId: string;
492
495
  message: string;
493
496
  builderUserId?: string;
494
497
  hidden?: boolean;
498
+ sourceChannelId?: string;
499
+ sourceDmId?: string;
495
500
  }
496
501
  export interface ReadBranchToolInput {
497
502
  projectId: string;
@@ -2123,7 +2128,7 @@ export interface RepoMetrics {
2123
2128
  languages: LanguageInfo[];
2124
2129
  isEmpty: boolean;
2125
2130
  isMonorepo: boolean;
2126
- monorepoType?: "npm-workspaces" | "yarn-workspaces" | "pnpm-workspaces" | "lerna" | "nx" | "turborepo" | "cargo-workspaces" | "other";
2131
+ monorepoType?: "npm-workspaces" | "yarn-workspaces" | "pnpm-workspaces" | "bun-workspaces" | "lerna" | "nx" | "turborepo" | "rush" | "moon" | "cargo-workspaces" | "go-workspaces" | "other";
2127
2132
  frameworks: FrameworkInfo[];
2128
2133
  setupRequirements: SetupRequirement[];
2129
2134
  packageManagers: string[];
@@ -1,4 +1,5 @@
1
1
  import { mapHttpStatusToErrorCode, mapFetchErrorToConnectivityCode, } from "../error-codes.js";
2
+ import { isBrowser } from "../environment.js";
2
3
  const DEFAULT_TIMEOUT_MS = 30000;
3
4
  const LATENCY_THRESHOLD_MS = 5000;
4
5
  export async function httpCheck(options) {
@@ -10,7 +11,7 @@ export async function httpCheck(options) {
10
11
  const response = await fetchFn(target, {
11
12
  method: "HEAD",
12
13
  signal: controller.signal,
13
- redirect: "follow",
14
+ redirect: isBrowser() ? "follow" : "manual",
14
15
  });
15
16
  clearTimeout(timeoutId);
16
17
  const durationMs = Date.now() - startTime;
package/src/projects.d.ts CHANGED
@@ -927,4 +927,56 @@ export interface MemorySummary extends Pick<MemoryData, (typeof MEMORY_SUMMARY_F
927
927
  export interface GetProjectMemoriesResult {
928
928
  memories: MemorySummary[];
929
929
  }
930
+ interface BaseSendMessageMessage {
931
+ }
932
+ export interface ValidatingBranchMessage extends BaseSendMessageMessage {
933
+ type: "validating-branch";
934
+ message: string;
935
+ projectId: string;
936
+ branchName: string;
937
+ }
938
+ export interface SettingUpContainerMessage extends BaseSendMessageMessage {
939
+ type: "setting-up-container";
940
+ message: string;
941
+ projectId: string;
942
+ branchName: string;
943
+ }
944
+ export interface SendingMessageMessage extends BaseSendMessageMessage {
945
+ type: "sending-message";
946
+ message: string;
947
+ projectId: string;
948
+ branchName: string;
949
+ }
950
+ export interface MessageSentMessage extends BaseSendMessageMessage {
951
+ type: "message-sent";
952
+ message: string;
953
+ projectId: string;
954
+ branchName: string;
955
+ url: string;
956
+ }
957
+ export interface SendMessageErrorMessage extends BaseSendMessageMessage {
958
+ type: "error";
959
+ message: string;
960
+ error: string;
961
+ projectId: string;
962
+ branchName: string;
963
+ }
964
+ export interface EnsureContainerMessage extends BaseSendMessageMessage {
965
+ type: "ensure-container";
966
+ event: ProjectsChunkMessage;
967
+ }
968
+ export interface AiMessage extends BaseSendMessageMessage {
969
+ type: "ai";
970
+ event: GenerateCompletionStep;
971
+ }
972
+ export type SendMessageChunkMessage = ValidatingBranchMessage | SettingUpContainerMessage | SendingMessageMessage | MessageSentMessage | SendMessageErrorMessage | EnsureContainerMessage | AiMessage;
973
+ export interface ExitPlanModeData {
974
+ plan: string;
975
+ sessionMode?: string;
976
+ }
977
+ /**
978
+ * Parses an ExitPlanMode tool result from a streaming chunk
979
+ * Extracts the plan content and sessionMode from the tool's structured result
980
+ */
981
+ export declare function parseExitPlanMode(chunk: CreateBranchChunkMessage | SendMessageChunkMessage): ExitPlanModeData | null;
930
982
  export {};
package/src/projects.js CHANGED
@@ -92,3 +92,71 @@ export const MEMORY_SUMMARY_FIELDS = [
92
92
  "glob",
93
93
  "updatedAt",
94
94
  ];
95
+ /**
96
+ * Parses an ExitPlanMode tool result from a streaming chunk
97
+ * Extracts the plan content and sessionMode from the tool's structured result
98
+ */
99
+ export function parseExitPlanMode(chunk) {
100
+ // Check if this is an AI chunk
101
+ if (chunk.type !== "ai") {
102
+ return null;
103
+ }
104
+ const event = chunk.event;
105
+ // Look for tool_result events for ExitPlanMode
106
+ if (event.type === "tool_result") {
107
+ const result = event.result;
108
+ // Check if this is the ExitPlanMode tool
109
+ if (result.tool_name === "ExitPlanMode") {
110
+ let plan;
111
+ let sessionMode;
112
+ // The content should be a JSON string with the structured result
113
+ if (typeof result.tool_input === "string") {
114
+ try {
115
+ const parsed = JSON.parse(result.tool_input);
116
+ if (parsed && typeof parsed.plan === "string" && !plan) {
117
+ plan = parsed.plan;
118
+ }
119
+ if (parsed &&
120
+ typeof parsed.sessionMode === "string" &&
121
+ !sessionMode) {
122
+ sessionMode = parsed.sessionMode;
123
+ }
124
+ }
125
+ catch (_a) {
126
+ // If parsing fails, ignore and return null
127
+ }
128
+ }
129
+ if (typeof result.content === "string") {
130
+ try {
131
+ const parsed = JSON.parse(result.content);
132
+ if (parsed && typeof parsed.plan === "string" && !plan) {
133
+ plan = parsed.plan;
134
+ }
135
+ if (parsed &&
136
+ typeof parsed.sessionMode === "string" &&
137
+ !sessionMode) {
138
+ sessionMode = parsed.sessionMode;
139
+ }
140
+ }
141
+ catch (_b) {
142
+ // If parsing fails, ignore and return null
143
+ }
144
+ }
145
+ // Also check structured_result directly (fallback)
146
+ if (result.structured_result &&
147
+ typeof result.structured_result.plan === "string" &&
148
+ !plan) {
149
+ plan = result.structured_result.plan;
150
+ }
151
+ if (result.structured_result &&
152
+ typeof result.structured_result.sessionMode === "string" &&
153
+ !sessionMode) {
154
+ sessionMode = result.structured_result.sessionMode;
155
+ }
156
+ if (plan) {
157
+ return { plan, sessionMode };
158
+ }
159
+ }
160
+ }
161
+ return null;
162
+ }