Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions packages/core/src/mappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,18 +236,12 @@ export function mapRestSessionToSdkSession(
requirePlanApproval: rest.requirePlanApproval,
automationMode: rest.automationMode as AutomationMode,
outputs: (rest.outputs || []).map(mapRestOutputToSdkOutput),
source: rest.source ? mapRestSourceToSdkSource(rest.source) : undefined,
generatedFiles: rest.generatedFiles,
source: undefined,
generatedFiles: undefined,
activities: undefined,
outcome: undefined as any,
};

if (rest.activities && platform) {
session.activities = rest.activities.map((a) =>
mapRestActivityToSdkActivity(a, platform),
);
}

try {
session.outcome = mapSessionResourceToOutcome(session);
} catch (error) {
Expand Down
5 changes: 2 additions & 3 deletions packages/core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,6 @@ export interface RestSessionResource {
id: string;
prompt: string;
sourceContext: SourceContext;
source?: RestSource;
title: string;
createTime: string;
updateTime: string;
Expand All @@ -302,9 +301,9 @@ export interface RestSessionResource {
automationMode?: string;
url: string;
outputs?: RestSessionOutput[];
activities?: any[];
generatedFiles?: GeneratedFile[];
archived?: boolean;
// Index signature to allow for forward compatibility and legacy test support
[key: string]: unknown;
}

/**
Expand Down
27 changes: 27 additions & 0 deletions packages/core/tests/mappers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,4 +341,31 @@ describe('mapRestSessionToSdkSession', () => {
expect(sdk.requirePlanApproval).toBe(true);
expect(sdk.automationMode).toBe('AUTO_CREATE_PR');
});

it('should initialize source, activities, and generatedFiles to undefined', () => {
const rest: RestSessionResource = {
name: 'sessions/123',
id: '123',
prompt: 'prompt',
title: 'title',
createTime: '2023-01-01',
updateTime: '2023-01-01',
state: 'IN_PROGRESS',
url: 'url',
outputs: [],
sourceContext: { source: 's' },
// Even if we provide these (via index signature), they should be ignored/undefined in SDK object
source: {
name: 'sources/github/test/repo',
id: 'github/test/repo',
githubRepo: { owner: 'test', repo: 'repo', isPrivate: false },
},
activities: [],
generatedFiles: [],
};
const sdk = mapRestSessionToSdkSession(rest, mockPlatform);
expect(sdk.source).toBeUndefined();
expect(sdk.activities).toBeUndefined();
expect(sdk.generatedFiles).toBeUndefined();
});
});
Loading