@builder.io/ai-utils 0.14.4 → 0.16.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.4",
3
+ "version": "0.16.0",
4
4
  "description": "Builder.io AI utils",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
package/src/codegen.d.ts CHANGED
@@ -467,12 +467,46 @@ export interface GenerateCompletionStepText {
467
467
  type: "text";
468
468
  content: string;
469
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
+ */
470
474
  export interface ContextWindow {
475
+ /** Percentage of context window currently in use (0-1 range) */
471
476
  usage: number;
477
+ /** Total number of tokens currently used in the context */
472
478
  usedTokens: number;
479
+ /** Number of tokens that are cached (reduces cost on subsequent requests) */
473
480
  cachedTokens: number;
481
+ /** Maximum tokens available in the model's context window */
474
482
  totalTokens: number;
475
- 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>;
476
510
  }
477
511
  export interface GenerateCompletionStepDone {
478
512
  type: "done";
package/src/projects.d.ts CHANGED
@@ -265,7 +265,7 @@ export interface PartialBranchData {
265
265
  isDefault: boolean;
266
266
  isPublic: boolean;
267
267
  lockedFusionEnvironment?: FusionExecutionEnvironment;
268
- metadata?: Record<string, unknown>;
268
+ metadata?: BranchMetadata;
269
269
  backup?: BranchBackup;
270
270
  gitAiBranch?: string | null;
271
271
  lastCommitHash?: string | null;
@@ -279,6 +279,29 @@ export interface PartialBranchData {
279
279
  };
280
280
  }
281
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
+ }
282
305
  interface BranchSharedData {
283
306
  appName?: string | null;
284
307
  prNumber?: number | null;
@@ -310,7 +333,7 @@ interface BranchSharedData {
310
333
  allocated: boolean | null;
311
334
  } | null;
312
335
  backup?: BranchBackup;
313
- metadata?: Record<string, unknown>;
336
+ metadata?: BranchMetadata;
314
337
  needsCleanup?: boolean;
315
338
  /** @deprecated Use `state` field instead. Kept for backwards compatibility. */
316
339
  deleted?: boolean;
@@ -324,6 +347,10 @@ interface BranchSharedData {
324
347
  vscodeTunnelUrl?: string | null;
325
348
  vscodeTunnelName?: string | null;
326
349
  vscodeTunnelExpiresAt?: string | null;
350
+ /** Timestamp when an AI agent started activity on this branch, null when inactive (in milliseconds since epoch) */
351
+ lastAgentActivityAt?: number | null;
352
+ /** Timestamp of last activity on this branch - includes both agent and user activity (in milliseconds since epoch) */
353
+ lastActivityAt?: number;
327
354
  }
328
355
  /**
329
356
  * fields that are required in the new branch format, but optional in the legacy branch format.
@@ -336,6 +363,7 @@ interface RequiredBranchSharedData {
336
363
  sessionId: string;
337
364
  createdAt: number;
338
365
  updatedAt: string;
366
+ lastUpdatedAt: number;
339
367
  commitMode: CommitMode;
340
368
  }
341
369
  /**