@builder.io/ai-utils 0.14.3 → 0.15.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.14.3",
3
+ "version": "0.15.0",
4
4
  "description": "Builder.io AI utils",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
package/src/codegen.d.ts CHANGED
@@ -175,7 +175,8 @@ export interface BuilderEditToolInput {
175
175
  new_str: string;
176
176
  }
177
177
  export interface GetScreenshotToolInput {
178
- url: string;
178
+ href: string;
179
+ url?: string;
179
180
  selector?: string;
180
181
  width?: number;
181
182
  height?: number;
@@ -466,12 +467,46 @@ export interface GenerateCompletionStepText {
466
467
  type: "text";
467
468
  content: string;
468
469
  }
470
+ /**
471
+ * Represents the current state and composition of the AI model's context window.
472
+ * Used to track token usage and provide a breakdown of what content is consuming the context.
473
+ */
469
474
  export interface ContextWindow {
475
+ /** Percentage of context window currently in use (0-1 range) */
470
476
  usage: number;
477
+ /** Total number of tokens currently used in the context */
471
478
  usedTokens: number;
479
+ /** Number of tokens that are cached (reduces cost on subsequent requests) */
472
480
  cachedTokens: number;
481
+ /** Maximum tokens available in the model's context window */
473
482
  totalTokens: number;
474
- details: Record<string, any>;
483
+ /** Reserved token buffer to allow for compaction before hitting the limit */
484
+ compactBufferTokens: number;
485
+ /**
486
+ * Breakdown of context window usage by category, with each value representing
487
+ * the proportion (0-1) of total tokens used by that category.
488
+ *
489
+ * Common keys include:
490
+ * - `tool:<name>` - Tokens from tool calls and results (e.g., `tool:read_file`, `tool:bash`)
491
+ * - `tools:builtin` - Tokens from built-in tool definitions/schemas
492
+ * - `tools:mcp:<server>` - Tokens from MCP server tool definitions (e.g., `tools:mcp:browser`)
493
+ * - `images` - Tokens from image content (estimated at ~1200 tokens per image)
494
+ * - `system` - Tokens from system prompt content
495
+ * - `rules` - Tokens from custom instructions/rules
496
+ * - `memory` - Tokens from memory/context persistence
497
+ * - `reminder` - Tokens from generic system reminders
498
+ * - `reminder:plan` - Tokens from plan mode prompts
499
+ * - `reminder:framework` - Tokens from framework-specific prompts
500
+ * - `reminder:design-system` - Tokens from design system context
501
+ * - `reminder:ui-context` - Tokens from UI context information
502
+ * - `reminder:health` - Tokens from dev server health status
503
+ * - `reminder:url` - Tokens from dev server URL information
504
+ * - `reminder:environment-variables` - Tokens from environment variable context
505
+ * - `reminder:git-status` - Tokens from git status information
506
+ * - `reminder:modified-files-context` - Tokens from modified files diff context
507
+ * - `rest` - Tokens from other text content without a specific tag
508
+ */
509
+ details: Record<string, number>;
475
510
  }
476
511
  export interface GenerateCompletionStepDone {
477
512
  type: "done";
@@ -484,7 +519,7 @@ export interface GenerateCompletionStepDone {
484
519
  model: string;
485
520
  usage: CodegenUsage | undefined;
486
521
  url?: string;
487
- promptVersion: string;
522
+ promptVersion: string | undefined;
488
523
  stopReason: CompletionStopReason;
489
524
  hasChanges: boolean;
490
525
  }
@@ -872,7 +907,7 @@ export interface GenerateCodeEventDone {
872
907
  nextUrl: string;
873
908
  autoContinue: boolean;
874
909
  model: string;
875
- promptVersion: string;
910
+ promptVersion: string | undefined;
876
911
  }
877
912
  export interface GenerateCodeEventError {
878
913
  type: "error";
@@ -1028,13 +1063,13 @@ export interface AccessResult {
1028
1063
  allowed: boolean;
1029
1064
  message: string;
1030
1065
  }
1031
- export type RemoteMachineConfig = {
1066
+ export interface RemoteMachineConfig {
1032
1067
  cpus: number;
1033
1068
  memory: number;
1034
1069
  region: string;
1035
1070
  cpuKind?: CpuKind;
1036
1071
  volumeSize: number;
1037
- };
1072
+ }
1038
1073
  export type MachineConfig = (RemoteMachineConfig & {
1039
1074
  environment: "cloud" | "cloud-v2" | "unknown";
1040
1075
  }) | {
package/src/messages.d.ts CHANGED
@@ -57,6 +57,7 @@ export interface ContentMessageItemToolResult {
57
57
  is_error?: boolean;
58
58
  cache?: boolean;
59
59
  ephemeral?: boolean;
60
+ structured_result?: Record<string, any>;
60
61
  }
61
62
  export interface ImageBase64Source {
62
63
  type: "base64";
@@ -19,11 +19,47 @@ export interface GitlabEnterprisePATValue {
19
19
  botUsername: string;
20
20
  secondaryHost?: string;
21
21
  }
22
+ /**
23
+ * Public metadata for GitLab fallback token (stored in organizations collection).
24
+ */
22
25
  export interface GitlabCloudFallbackToken {
23
- token: string;
26
+ configured: boolean;
27
+ createdBy: string;
28
+ createdAt: number;
29
+ }
30
+ /**
31
+ * Public metadata for Azure fallback token (stored in organizations collection).
32
+ */
33
+ export interface AzureCloudFallbackToken {
34
+ configured: boolean;
35
+ organization: string;
24
36
  createdBy: string;
25
37
  createdAt: number;
26
38
  }
39
+ /**
40
+ * Public metadata for Bitbucket fallback token (stored in organizations collection).
41
+ */
42
+ export interface BitbucketCloudFallbackToken {
43
+ configured: boolean;
44
+ username: string;
45
+ email: string;
46
+ createdBy: string;
47
+ createdAt: number;
48
+ }
49
+ /**
50
+ * Private fallback tokens stored in organizations_private collection.
51
+ */
52
+ export interface FallbackTokensPrivate {
53
+ gitlab?: {
54
+ token: string;
55
+ };
56
+ azure?: {
57
+ token: string;
58
+ };
59
+ bitbucket?: {
60
+ token: string;
61
+ };
62
+ }
27
63
  interface OrganizationSettings {
28
64
  attribution?: string[];
29
65
  visualEditorAiStyleInspirationURL?: string;
@@ -39,6 +75,8 @@ interface OrganizationSettings {
39
75
  githubEnterpriseSetupValue?: GithubEnterpriseSetupValue;
40
76
  gitlabEnterprisePAT?: GitlabEnterprisePATValue;
41
77
  gitlabCloudFallbackToken?: GitlabCloudFallbackToken;
78
+ azureCloudFallbackToken?: AzureCloudFallbackToken;
79
+ bitbucketCloudFallbackToken?: BitbucketCloudFallbackToken;
42
80
  bitbucketEnterprisePAT?: BitbucketEnterprisePAT;
43
81
  useProxy?: boolean;
44
82
  fusionShareableUrlSuffix?: string;
package/src/projects.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import type { FileOverride, EnvironmentVariable, LaunchServerState, LaunchServerStatus, BranchBackup, CommitMode } from "./codegen";
2
+ import type { FallbackTokensPrivate } from "./organization";
2
3
  export interface ConfigStatus {
3
4
  isReady: boolean;
4
5
  lastUpdated: string;
@@ -152,10 +153,11 @@ export interface CleanupCompletedMessage extends BaseMessage {
152
153
  * Messages sent by the container orchestrator.
153
154
  */
154
155
  export type ProjectsChunkMessage = InitializingMessage | FetchingGithubTokenMessage | FetchingFusionKeyMessage | CheckingAppMessage | CleaningUpAppMessage | CreatingAppMessage | CheckingIPMessage | AllocatingIPMessage | CheckingMachineMessage | CheckingVolumeMessage | ForkingVolumeMessage | RetryingWithNewRegionMessage | WaitingBeforePollingMessage | PollingMachineStatusMessage | WarningStateMessage | PingMessage | DebugMessage | ErrorMessage | InfoMessage | WarningMessage | MachineStatusMessage | LogsMessage | ConfigStatusMessage | AppCreatedMessage | MachineCreatedMessage | IpAllocatedMessage | VolumeForkedMessage | ReadyMessage | ErrorStateMessage | CleanupCompletedMessage;
155
- export type GitConfig = {
156
+ export interface GitConfig {
156
157
  url: string;
157
158
  provider: "github" | "bitbucket" | "gitlab" | "azure" | "unknown";
158
- };
159
+ token: string | undefined;
160
+ }
159
161
  export type GitConfigs = Record<string, GitConfig>;
160
162
  export declare const EXAMPLE_REPOS: string[];
161
163
  export declare const STARTER_REPO = "BuilderIO/fusion-starter";
@@ -263,7 +265,7 @@ export interface PartialBranchData {
263
265
  isDefault: boolean;
264
266
  isPublic: boolean;
265
267
  lockedFusionEnvironment?: FusionExecutionEnvironment;
266
- metadata?: Record<string, unknown>;
268
+ metadata?: BranchMetadata;
267
269
  backup?: BranchBackup;
268
270
  gitAiBranch?: string | null;
269
271
  lastCommitHash?: string | null;
@@ -277,6 +279,29 @@ export interface PartialBranchData {
277
279
  };
278
280
  }
279
281
  export type EntityState = "active" | "deleted";
282
+ /**
283
+ * Metadata stored in branches for integration tracking and PR description generation.
284
+ * This type documents the integration context that can be attached to a branch.
285
+ */
286
+ export interface BranchMetadata {
287
+ /** How the branch was created (e.g., "slack", "jira", "api", "cli") */
288
+ createdVia?: string;
289
+ /** JIRA issue key (e.g., "PROJ-123") - used to link back to the JIRA ticket in PR descriptions */
290
+ jiraIssueKey?: string;
291
+ /** JIRA cloud ID - UUID identifier for the Atlassian cloud instance */
292
+ jiraCloudId?: string;
293
+ /** JIRA site name - the subdomain used in the JIRA URL (e.g., "mycompany" for mycompany.atlassian.net) */
294
+ jiraSiteName?: string;
295
+ /** JIRA issue ID - internal JIRA identifier */
296
+ jiraIssueId?: string;
297
+ /** Slack team/workspace ID - used to ensure deep links open in the correct workspace for multi-workspace users */
298
+ slackTeamId?: string;
299
+ /** Slack channel ID - used to link back to the Slack thread in PR descriptions */
300
+ slackChannelId?: string;
301
+ /** Slack thread timestamp - used to construct the Slack thread URL */
302
+ slackThreadTs?: string;
303
+ [key: string]: unknown;
304
+ }
280
305
  interface BranchSharedData {
281
306
  appName?: string | null;
282
307
  prNumber?: number | null;
@@ -308,7 +333,7 @@ interface BranchSharedData {
308
333
  allocated: boolean | null;
309
334
  } | null;
310
335
  backup?: BranchBackup;
311
- metadata?: Record<string, unknown>;
336
+ metadata?: BranchMetadata;
312
337
  needsCleanup?: boolean;
313
338
  /** @deprecated Use `state` field instead. Kept for backwards compatibility. */
314
339
  deleted?: boolean;
@@ -521,6 +546,7 @@ export interface OrganizationPrivate {
521
546
  ids: number[];
522
547
  host: string;
523
548
  }[];
549
+ fallbackTokens?: FallbackTokensPrivate;
524
550
  createdAt: number;
525
551
  updatedAt: number;
526
552
  }