Skip to content
Merged
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
4 changes: 4 additions & 0 deletions api/server/services/Files/Code/process.js
Original file line number Diff line number Diff line change
Expand Up @@ -1279,6 +1279,7 @@ async function editWorkspaceFile({
file_path,
edits,
expected_base_sha256,
matching,
workspace_id,
workspace_instance_id,
linked_worktrees,
Expand Down Expand Up @@ -1311,6 +1312,7 @@ async function editWorkspaceFile({
path: file_path,
edits,
...(expected_base_sha256 ? { expectedBaseSha256: expected_base_sha256 } : {}),
matching,
},
...(signal ? { signal } : {}),
});
Expand All @@ -1320,6 +1322,7 @@ async function editWorkspaceFile({
async function previewWorkspaceEdit({
file_path,
edits,
matching,
workspace_id,
workspace_instance_id,
linked_worktrees,
Expand Down Expand Up @@ -1351,6 +1354,7 @@ async function previewWorkspaceEdit({
...(workspace_instance_id ? { workspaceInstanceId: workspace_instance_id } : {}),
path: file_path,
edits,
matching,
},
...(signal ? { signal } : {}),
});
Expand Down
26 changes: 26 additions & 0 deletions api/server/services/Files/Code/process.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2358,6 +2358,32 @@ describe('Code Process', () => {
);
});

it('forwards negotiated matching and replaceAll on edits and previews', async () => {
const edits = [{ oldText: 'false', newText: 'true', replaceAll: true }];
mockExecuteWorkspaceTool.mockResolvedValue({});
const shared = {
file_path: 'src/app.ts',
edits,
matching: 'tolerant',
workspace_id: 'primary',
codeApiBaseUrl: 'https://attached-code.example.com/v1',
executionProfile: 'stateful',
bridgeWorkerId: 'worker-user-1',
req: mockReq,
};

await editWorkspaceFile(shared);
await previewWorkspaceEdit(shared);

for (const operation of ['edit_file', 'preview_edit']) {
expect(mockExecuteWorkspaceTool).toHaveBeenCalledWith(
expect.objectContaining({
request: expect.objectContaining({ operation, edits, matching: 'tolerant' }),
}),
);
}
});

it('forwards a non-mutating attached-workspace edit preview', async () => {
const result = {
protocolVersion: 1,
Expand Down
3 changes: 3 additions & 0 deletions packages/api/src/agents/execution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import type {
StatefulCodeEnvironment,
TAgentsEndpoint,
} from 'librechat-data-provider';
import type { WorkspaceEditFileFeature } from '~/code/edits';

export const CODE_API_EXPECTED_PROFILE_HEADER = 'X-CodeAPI-Expected-Profile';
export const CODE_API_BRIDGE_WORKER_HEADER = 'X-LibreChat-Code-Worker-ID';
Expand Down Expand Up @@ -48,6 +49,8 @@ export interface CodeExecutionContext {
linkedWorktrees?: boolean;
/** Live Code API execution ceiling. Omitted by older deployments. */
maxCommandTimeoutMs?: number;
/** Edit features the worker negotiated with the Code API. Omitted by older workers. */
editFileFeatures?: WorkspaceEditFileFeature[];
instructions?: CodeWorkspaceDescriptor['instructions'];
environment?: CodeWorkspaceDescriptor['environment'];
};
Expand Down
Loading
Loading