@builder.io/ai-utils 0.53.1 → 0.55.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.53.1",
3
+ "version": "0.55.0",
4
4
  "description": "Builder.io AI utils",
5
5
  "files": [
6
6
  "src"
package/src/codegen.d.ts CHANGED
@@ -38,10 +38,14 @@ export interface CustomInstruction {
38
38
  }
39
39
  /** Reasoning effort level for LLM completions. */
40
40
  export declare const ReasoningEffortSchema: z.ZodEnum<{
41
+ none: "none";
41
42
  low: "low";
42
43
  medium: "medium";
43
44
  high: "high";
45
+ auto: "auto";
44
46
  minimal: "minimal";
47
+ xhigh: "xhigh";
48
+ max: "max";
45
49
  }>;
46
50
  export type ReasoningEffort = z.infer<typeof ReasoningEffortSchema>;
47
51
  export interface CustomAgentInfo {
@@ -64,7 +68,6 @@ export interface CustomAgentDefinition {
64
68
  tools?: string[];
65
69
  model?: string;
66
70
  roundRobinModels?: string[];
67
- mode?: CodeGenMode;
68
71
  position?: CodeGenPosition;
69
72
  needDevServer?: boolean;
70
73
  needValidation?: boolean;
@@ -72,6 +75,17 @@ export interface CustomAgentDefinition {
72
75
  resetAfterRun?: boolean;
73
76
  mcpServers?: boolean;
74
77
  asyncSubAgents?: boolean;
78
+ /**
79
+ * Expressive queue behavior for messages sent to this agent. See
80
+ * {@link QueueBehavior}. When both `queueBehavior` and `queueMode` are
81
+ * provided, `queueBehavior` wins.
82
+ */
83
+ queueBehavior?: QueueBehavior;
84
+ /**
85
+ * @deprecated Use {@link CustomAgentDefinition.queueBehavior} instead.
86
+ * Kept as a string alias for backwards compatibility with existing agent
87
+ * definitions in the wild.
88
+ */
75
89
  queueMode?: QueueMode;
76
90
  softContextWindow?: number;
77
91
  filePath?: string;
@@ -737,19 +751,6 @@ export interface ReportIssueToolInput {
737
751
  body: string;
738
752
  }
739
753
  export interface CodeGenToolMap {
740
- view_path: ReadToolInput;
741
- glob_search: GlobSearchToolInput;
742
- grep_search: GrepSearchToolInput;
743
- get_rule: GetRuleToolInput;
744
- get_style_inspiration: GetStyleInspirationToolInput;
745
- get_screenshot: GetScreenshotToolInput;
746
- dev_server_control: DevServerControlInput;
747
- bash: BashToolInput;
748
- powershell: PowerShellToolInput;
749
- web_search: WebSearchToolInput;
750
- write_file: WriteFileInput;
751
- search_replace_file: SearchReplaceInput;
752
- find_media: FindMediaToolInput;
753
754
  Read: ReadToolInput;
754
755
  Write: WriteFileInput;
755
756
  Edit: SearchReplaceInput;
@@ -812,6 +813,7 @@ export interface CodeGenToolMap {
812
813
  IDEDiagnostics: IDEDiagnosticsToolInput;
813
814
  EscalateToPlanner: EscalateToPlanner;
814
815
  PullPrototype: PullPrototypeToolInput;
816
+ ConnectMCP: ConnectMCPToolInput;
815
817
  }
816
818
  export interface EscalateToPlanner {
817
819
  /** What's blocking execution */
@@ -825,11 +827,80 @@ export interface EscalateToPlanner {
825
827
  }
826
828
  export interface GetLastBrowserTestToolInput {
827
829
  }
830
+ export interface ConnectMCPToolInput {
831
+ /** Human-readable name of the MCP service, e.g. "Jira", "Linear", "Sentry" */
832
+ name: string;
833
+ /** Remote MCP endpoint URL. When omitted, discovery is performed for the named service. */
834
+ url?: string;
835
+ }
828
836
  export type CodeGenTools = keyof CodeGenToolMap;
829
837
  export type AllCodeGenTools = CodeGenTools | "web_search";
830
838
  export type SessionMode = "planning" | "normal" | "auto-planning" | "deep-research";
831
- export type CodeGenMode = "quality" | "quality-v3" | "quality-v4" | "quality-v4-agent";
832
- export type QueueMode = "next-turn" | "until-idle";
839
+ export type CodeGenMode = "quality" | "quality-v4"
840
+ /**
841
+ * @deprecated Use `quality-v4` instead. Kept for backwards compatibility
842
+ * with older dev-tools clients in the wild that may still request this mode
843
+ * for sub-agents. New code should not produce this value.
844
+ */
845
+ | "quality-v4-agent";
846
+ /**
847
+ * When a queued message gets picked up by the scheduler.
848
+ *
849
+ * - `next-turn`: process queued messages as soon as the current LLM turn
850
+ * finishes (i.e. between turns of an in-flight run).
851
+ * - `until-idle`: hold queued messages until the agent is fully idle
852
+ * (current run has ended). Messages never interrupt an in-flight run.
853
+ * - `interrupt`: abort the in-flight run as soon as a new message arrives
854
+ * and start processing it. Reserved for high-priority/reactive cases.
855
+ * - `interrupt-clear`: like `interrupt`, but also clears the session
856
+ * (turn history, queued messages, last user, accumulated credits) before
857
+ * processing the new message. Use when the new message should start from
858
+ * a clean slate.
859
+ * - `interrupt-replace`: equivalent to abort + rewind to the previous
860
+ * user message + replace it with the new one. Use when a fresh
861
+ * request supersedes the in-flight one (e.g. incremental code-review
862
+ * requests where a newer review should replace the still-running
863
+ * previous review). The in-flight user prompt and any partial
864
+ * assistant output for it are discarded.
865
+ */
866
+ export type QueueSchedule = "next-turn" | "until-idle" | "interrupt" | "interrupt-clear" | "interrupt-replace";
867
+ /**
868
+ * What happens when multiple messages are pending in the queue.
869
+ *
870
+ * - `merge`: combine all pending messages into a single user message before
871
+ * the next turn. This is the historical default for `"next-turn"`.
872
+ * - `replace-latest`: discard older pending messages and keep only the
873
+ * most recently queued one (useful when stale inputs are obsolete, e.g.
874
+ * a typing user replacing their previous draft).
875
+ * - `preserve-order`: never merge; pop one message at a time in FIFO order.
876
+ * This is the historical behavior for `"until-idle"`.
877
+ */
878
+ export type QueueCoalesce = "merge" | "replace-latest" | "preserve-order";
879
+ /**
880
+ * Expressive queue behavior built from two orthogonal axes:
881
+ * `schedule` (when to dispatch) and `coalesce` (how to combine pending).
882
+ */
883
+ export interface QueueBehavior {
884
+ schedule: QueueSchedule;
885
+ coalesce: QueueCoalesce;
886
+ }
887
+ /**
888
+ * Backwards-compatible queue mode. Accepts either a legacy string alias
889
+ * or the full {@link QueueBehavior} object.
890
+ *
891
+ * Legacy aliases:
892
+ * - `"next-turn"` → `{ schedule: "next-turn", coalesce: "merge" }`
893
+ * - `"until-idle"` → `{ schedule: "until-idle", coalesce: "preserve-order" }`
894
+ */
895
+ export type QueueMode = "next-turn" | "until-idle" | QueueBehavior;
896
+ export declare const DEFAULT_QUEUE_BEHAVIOR: QueueBehavior;
897
+ /**
898
+ * Normalize any accepted queue-mode shape into a concrete {@link QueueBehavior}.
899
+ * `undefined` resolves to {@link DEFAULT_QUEUE_BEHAVIOR}.
900
+ */
901
+ /** True for any schedule that aborts the in-flight run on enqueue. */
902
+ export declare function isInterruptSchedule(schedule: QueueSchedule): boolean;
903
+ export declare function normalizeQueueMode(mode: QueueMode | undefined): QueueBehavior;
833
904
  export declare const BASE_CODEGEN_POSITIONS: readonly ["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", "builder-code", "unknown", "dsi-mcp"];
834
905
  export type BaseCodeGenPosition = (typeof BASE_CODEGEN_POSITIONS)[number];
835
906
  export type CodeGenPosition = BaseCodeGenPosition | `${BaseCodeGenPosition}-agent`;
@@ -1102,7 +1173,7 @@ export interface ContextWindow {
1102
1173
  * the proportion (0-1) of total tokens used by that category.
1103
1174
  *
1104
1175
  * Common keys include:
1105
- * - `tool:<name>` - Tokens from tool calls and results (e.g., `tool:read_file`, `tool:bash`)
1176
+ * - `tool:<name>` - Tokens from tool calls and results (e.g., `tool:Read`, `tool:Bash`)
1106
1177
  * - `tools:builtin` - Tokens from built-in tool definitions/schemas
1107
1178
  * - `tools:mcp:<server>` - Tokens from MCP server tool definitions (e.g., `tools:mcp:browser`)
1108
1179
  * - `images` - Tokens from image content (estimated at ~1200 tokens per image)
@@ -2230,6 +2301,23 @@ export interface SyncChangesFromRemote {
2230
2301
  uncommittedChanges?: "stash" | "commit" | "fail";
2231
2302
  requestRefresh?: boolean;
2232
2303
  allowUnrelatedHistory?: boolean;
2304
+ /**
2305
+ * When true, reset the AI branch hard to the remote feature/base branch instead
2306
+ * of merging. This gives a clean slate that exactly matches the checked-out
2307
+ * feature branch on remote, avoiding any merge-style conflicts or divergence.
2308
+ * Fails clearly if the feature/base branch cannot be determined or is absent
2309
+ * from the remote.
2310
+ */
2311
+ resetToBase?: boolean;
2312
+ /**
2313
+ * Whether to update the internal "last AI commits" baseline after the sync
2314
+ * completes. Defaults to `true` for backwards compatibility.
2315
+ *
2316
+ * Set to `false` when the caller wants `getChangesReport()` to keep diffing
2317
+ * from the pre-sync baseline (e.g. so a downstream prompt can see exactly
2318
+ * what changed since the last reset/sync).
2319
+ */
2320
+ updateLastCommits?: boolean;
2233
2321
  }
2234
2322
  export type PushChangesArgs = PushChangesOptions | boolean;
2235
2323
  export type CodegenApiResult = CodegenApiSuccess | CodegenApiFailure;
package/src/codegen.js CHANGED
@@ -1,8 +1,31 @@
1
1
  import { z } from "zod";
2
2
  /** Reasoning effort level for LLM completions. */
3
3
  export const ReasoningEffortSchema = z
4
- .enum(["low", "medium", "high", "minimal"])
4
+ .enum(["auto", "none", "minimal", "low", "medium", "high", "xhigh", "max"])
5
5
  .meta({ title: "ReasoningEffort" });
6
+ export const DEFAULT_QUEUE_BEHAVIOR = {
7
+ schedule: "next-turn",
8
+ coalesce: "merge",
9
+ };
10
+ /**
11
+ * Normalize any accepted queue-mode shape into a concrete {@link QueueBehavior}.
12
+ * `undefined` resolves to {@link DEFAULT_QUEUE_BEHAVIOR}.
13
+ */
14
+ /** True for any schedule that aborts the in-flight run on enqueue. */
15
+ export function isInterruptSchedule(schedule) {
16
+ return (schedule === "interrupt" ||
17
+ schedule === "interrupt-clear" ||
18
+ schedule === "interrupt-replace");
19
+ }
20
+ export function normalizeQueueMode(mode) {
21
+ if (mode === undefined)
22
+ return { ...DEFAULT_QUEUE_BEHAVIOR };
23
+ if (mode === "next-turn")
24
+ return { schedule: "next-turn", coalesce: "merge" };
25
+ if (mode === "until-idle")
26
+ return { schedule: "until-idle", coalesce: "preserve-order" };
27
+ return { schedule: mode.schedule, coalesce: mode.coalesce };
28
+ }
6
29
  export const BASE_CODEGEN_POSITIONS = [
7
30
  "fusion",
8
31
  "editor-ai",
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,58 @@
1
+ import { describe, it, expect } from "vitest";
2
+ import { DEFAULT_QUEUE_BEHAVIOR, isInterruptSchedule, normalizeQueueMode, } from "./codegen";
3
+ describe("normalizeQueueMode", () => {
4
+ it("returns the default behavior when input is undefined", () => {
5
+ expect(normalizeQueueMode(undefined)).toEqual(DEFAULT_QUEUE_BEHAVIOR);
6
+ });
7
+ it("maps the legacy 'next-turn' alias to merge between turns", () => {
8
+ expect(normalizeQueueMode("next-turn")).toEqual({
9
+ schedule: "next-turn",
10
+ coalesce: "merge",
11
+ });
12
+ });
13
+ it("maps the legacy 'until-idle' alias to FIFO at idle", () => {
14
+ expect(normalizeQueueMode("until-idle")).toEqual({
15
+ schedule: "until-idle",
16
+ coalesce: "preserve-order",
17
+ });
18
+ });
19
+ it("returns an object input as a normalized copy", () => {
20
+ const input = {
21
+ schedule: "interrupt",
22
+ coalesce: "replace-latest",
23
+ };
24
+ const out = normalizeQueueMode(input);
25
+ expect(out).toEqual(input);
26
+ expect(out).not.toBe(input);
27
+ });
28
+ it("supports next-turn + preserve-order (FIFO between turns)", () => {
29
+ expect(normalizeQueueMode({ schedule: "next-turn", coalesce: "preserve-order" })).toEqual({ schedule: "next-turn", coalesce: "preserve-order" });
30
+ });
31
+ it("supports until-idle + replace-latest (debounce on idle)", () => {
32
+ expect(normalizeQueueMode({
33
+ schedule: "until-idle",
34
+ coalesce: "replace-latest",
35
+ })).toEqual({ schedule: "until-idle", coalesce: "replace-latest" });
36
+ });
37
+ it("supports interrupt-clear and interrupt-replace schedules", () => {
38
+ expect(normalizeQueueMode({
39
+ schedule: "interrupt-clear",
40
+ coalesce: "merge",
41
+ })).toEqual({ schedule: "interrupt-clear", coalesce: "merge" });
42
+ expect(normalizeQueueMode({
43
+ schedule: "interrupt-replace",
44
+ coalesce: "merge",
45
+ })).toEqual({ schedule: "interrupt-replace", coalesce: "merge" });
46
+ });
47
+ });
48
+ describe("isInterruptSchedule", () => {
49
+ it("returns true for every interrupt-* schedule", () => {
50
+ expect(isInterruptSchedule("interrupt")).toBe(true);
51
+ expect(isInterruptSchedule("interrupt-clear")).toBe(true);
52
+ expect(isInterruptSchedule("interrupt-replace")).toBe(true);
53
+ });
54
+ it("returns false for non-interrupt schedules", () => {
55
+ expect(isInterruptSchedule("next-turn")).toBe(false);
56
+ expect(isInterruptSchedule("until-idle")).toBe(false);
57
+ });
58
+ });
@@ -461,5 +461,11 @@ export interface Organization {
461
461
  fusionReferrals?: string;
462
462
  githubInstallationIds?: number[];
463
463
  disableFigmaImageUpload?: boolean;
464
+ blocked?: boolean;
465
+ archived?: boolean;
466
+ gatewaySuspended?: boolean;
467
+ gatewaySuspendedAt?: number;
468
+ gatewaySuspendedBy?: string;
469
+ gatewaySuspendedReason?: string;
464
470
  }
465
471
  export {};