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
1 change: 1 addition & 0 deletions packages/api/src/openshell-gateway-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export interface CreateSandboxOptions {
memory?: string;
providers?: string[];
labels?: Record<string, string>;
uploads?: Array<{ local: string; remote: string }>;
command?: string[];
}

Expand Down
56 changes: 56 additions & 0 deletions packages/main/src/plugin/openshell-cli/openshell-cli.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,62 @@ describe('createSandbox', () => {
]);
});

test('includes single --upload flag when provided', async () => {
vi.spyOn(console, 'log').mockImplementation(() => undefined);
vi.mocked(exec.exec).mockResolvedValue(mockExecResult(''));

await openshellCli.createSandbox({
uploads: [{ local: '.agents/skills', remote: '.agents/skills' }],
});

expect(exec.exec).toHaveBeenCalledWith(OPENSHELL_CLI_PATH, [
'sandbox',
'create',
'--upload',
'.agents/skills:.agents/skills',
]);
});

test('includes multiple --upload flags when provided', async () => {
vi.spyOn(console, 'log').mockImplementation(() => undefined);
vi.mocked(exec.exec).mockResolvedValue(mockExecResult(''));

await openshellCli.createSandbox({
uploads: [
{ local: '.agents/skills/generate-sandbox-policy', remote: '.agents/skills/generate-sandbox-policy' },
{ local: '.agents/skills/openshell-cli', remote: '.agents/skills/openshell-cli' },
],
});

expect(exec.exec).toHaveBeenCalledWith(OPENSHELL_CLI_PATH, [
'sandbox',
'create',
'--upload',
'.agents/skills/generate-sandbox-policy:.agents/skills/generate-sandbox-policy',
'--upload',
'.agents/skills/openshell-cli:.agents/skills/openshell-cli',
]);
});

test('places --upload flags before -- command separator', async () => {
vi.spyOn(console, 'log').mockImplementation(() => undefined);
vi.mocked(exec.exec).mockResolvedValue(mockExecResult(''));

await openshellCli.createSandbox({
uploads: [{ local: '.agents/skills', remote: '.agents/skills' }],
command: ['bash'],
});

expect(exec.exec).toHaveBeenCalledWith(OPENSHELL_CLI_PATH, [
'sandbox',
'create',
'--upload',
'.agents/skills:.agents/skills',
'--',
'bash',
]);
});

test('appends command after -- separator', async () => {
vi.spyOn(console, 'log').mockImplementation(() => undefined);
vi.mocked(exec.exec).mockResolvedValue(mockExecResult(''));
Expand Down
5 changes: 5 additions & 0 deletions packages/main/src/plugin/openshell-cli/openshell-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@ export class OpenshellCli {
args.push('--label', `${key}=${value}`);
}
}
if (options.uploads) {
for (const upload of options.uploads) {
args.push('--upload', `${upload.local}:${upload.remote}`);
}
}
if (options.command?.length) {
args.push('--', ...options.command);
}
Expand Down
Loading