Skip to content

[Fleet Execution] Add workingBranch and environmentVariablesEnabled to SourceContext #247

@davideast

Description

@davideast

Goal Reference

This issue was generated from .fleet/goals/api-sync.md. The worker agent should read this file for full context including verification commands, constraints, and structural guidance.

Objective

Update the SourceContext type in the SDK to include the new workingBranch and environmentVariablesEnabled optional fields defined in the API Discovery Document.

Code-Level Diagnosis

Code path: packages/core/src/types.ts -> interface SourceContext
Mechanism: The SDK's SourceContext interface only defines source and githubRepoContext. The API Discovery Document now includes workingBranch and environmentVariablesEnabled.
Root cause: Missing type definitions for new optional fields on SourceContext.

Current Implementation

export interface SourceContext {
  /**
   * The name of the source (e.g., "sources/github/owner/repo").
   */
  source: string;
  /**
   * Context specific to GitHub repos.
   */
  githubRepoContext?: {
    startingBranch: string;
  };
}

Proposed Implementation

Files to modify:

  1. packages/core/src/types.ts: Update SourceContext to include workingBranch and environmentVariablesEnabled.
  2. packages/core/src/client.ts (or wherever SourceContext is constructed from SessionConfig): Pass through workingBranch and environmentVariablesEnabled if they are defined on SessionConfig (this requires updating SessionConfig to support them as well).

Let's look closely at SessionConfig in packages/core/src/types.ts:

export interface SessionConfig {
  prompt: string;
  title?: string;
  source?: SourceInput;
  autoPr?: boolean;
  requireApproval?: boolean;
}

We can add workingBranch?: string and environmentVariablesEnabled?: boolean to SourceInput. Wait, workingBranch and environmentVariablesEnabled make sense to be part of the SourceInput or SessionConfig. Let's add them to SessionConfig or SourceInput. The API takes them inside sourceContext.

Integration (Before -> After)

packages/core/src/types.ts

@@ -155,6 +155,14 @@
    */
   github: string;
   baseBranch?: string;
+  /**
+   * The branch to push to for the session.
+   */
+  workingBranch?: string;
+  /**
+   * Enables environment variables in the session.
+   */
+  environmentVariablesEnabled?: boolean;
 }
 
 /**
@@ -382,6 +390,14 @@
   githubRepoContext?: {
     startingBranch: string;
   };
+  /**
+   * The branch to push to for the session.
+   */
+  workingBranch?: string;
+  /**
+   * Enables environment variables in the session.
+   */
+  environmentVariablesEnabled?: boolean;
 }

packages/core/src/client.ts (Assuming this is where sourceContext is built)

@@ -628,6 +628,8 @@
                 startingBranch: sourceInput.baseBranch || 'main',
               },
+              workingBranch: sourceInput.workingBranch,
+              environmentVariablesEnabled: sourceInput.environmentVariablesEnabled,
             }

Test Scenarios

  1. Valid Source Input with new fields: Passing workingBranch and environmentVariablesEnabled in SessionConfig.source propagates correctly to the sourceContext in the API request.

Target Files

  • packages/core/src/types.ts
  • packages/core/src/client.ts

Boundary Rules

Restrict your modifications exclusively to the files listed in the Target Files section. Ensure your source changes are entirely backward-compatible if unowned tests outside your boundary fail. Retain all existing file names and locations outside your explicitly declared target list.


Fleet Context

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions