> ## Documentation Index
> Fetch the complete documentation index at: https://kawax.biz/llms.txt
> Use this file to discover all available pages before exploring further.

# Workspaces, agents, Fleet, and skills

> Use SessionRpc in Laravel Copilot SDK to work with workspaces, agents, Fleet, skills, and the autopilotObjective.

## Workspaces, agents, Fleet, and skills

Scope: SessionRpc (per-session operations tied to a Session)

For an overview of RPC and the list of all RPC pages, see [RPC](https://kawax.biz/en/packages/laravel-copilot-sdk/rpc.md).

```php theme={null}
// workspaces
$session->rpc()->workspaces()->getWorkspace();
$session->rpc()->workspaces()->listFiles();
$session->rpc()->workspaces()->readFile(new WorkspacesReadFileRequest(path: 'file.txt'));
$session->rpc()->workspaces()->createFile(new WorkspacesCreateFileRequest(path: 'file.txt', content: '...'));
$session->rpc()->workspaces()->statFile(new WorkspacesStatFileRequest(path: 'file.txt'));
$session->rpc()->workspaces()->createDirectory(new WorkspacesCreateDirectoryRequest(path: 'new/dir', recursive: true));
$session->rpc()->workspaces()->removePath(new WorkspacesRemovePathRequest(path: 'old/dir', recursive: true, force: true));
$session->rpc()->workspaces()->renamePath(new WorkspacesRenamePathRequest(source: 'old.txt', destination: 'new.txt'));

// instructions (get the session's instruction sources)
$result = $session->rpc()->instructions()->getSources();
// $result->sources - Array of InstructionsSources
$session->rpc()->instructions()->reload();

// Explicitly reload LSP settings (experimental)
$session->rpc()->lsp()->initialize([
    'workingDirectory' => base_path(),
    'gitRoot' => base_path(),
    'force' => true,
]);

// List, start, diagnose, enable or disable, and stop LSP servers
$lsp = $session->rpc()->lsp();
$configs = $lsp->list(['workingDirectory' => base_path()]);
$started = $lsp->start();
$diagnosis = $lsp->diagnose(['serverId' => 'php']);
$lsp->set(['serverId' => 'php', 'enabled' => true]);
$lsp->stop();

// instructions discover (detect instruction files)
use Revolution\Copilot\Types\Rpc\InstructionsDiscoverRequest;

$result = $session->rpc()->instructions()->discover();
// $result->sources - Array of InstructionSource
$result = $session->rpc()->instructions()->discover(new InstructionsDiscoverRequest(
    projectPaths: ['/path/to/project'],
    excludeHostInstructions: true, // Exclude host-level instructions
));

// fleet
$session->rpc()->fleet()->start(new FleetStartRequest(prompt: '...'));
// See fleet-mode.md for details

// agent
$session->rpc()->agent()->list();
$session->rpc()->agent()->getCurrent();
$session->rpc()->agent()->select(new AgentSelectRequest(agentId: '...'));
$session->rpc()->agent()->deselect();
$session->rpc()->agent()->reload();

// skills (experimental: skill management)
$session->rpc()->skills()->list();
$session->rpc()->skills()->enable(new SkillsEnableRequest(name: 'skill-name'));
$session->rpc()->skills()->disable(new SkillsDisableRequest(name: 'skill-name'));
$session->rpc()->skills()->reload();
$session->rpc()->skills()->ensureLoaded(); // Load skills that aren't loaded yet (doesn't reload)
$invoked = $session->rpc()->skills()->getInvoked();
// $invoked->skills - History of skills invoked during the session
```

## autopilotObjective

`autopilotObjective()->getState()` returns the session's current Autopilot objective state as a typed object. If no objective exists, `state` is `null`. This API differs from `workspaces()->autopilotObjectiveExists()`, which checks whether an objective is saved in the workspace.

```php theme={null}
$state = $session->rpc()->autopilotObjective()->getState()->state;

if ($state !== null) {
    dump($state->objective, $state->status, $state->turnCount, $state->creditLimit);
}
```

`setStayInAutopilot()` suppresses requests to return to interactive mode when an objective completes or pauses. The setting is kept in client memory and defaults to `true`. Pass `false` as `value` to stop suppressing. Set it again after you reconnect.

```php theme={null}
$session->rpc()->autopilotObjective()->setStayInAutopilot(['value' => true]);
```


## Related topics

- [Skills, plugins, agents, instructions, and extensions](https://kawax.biz/en/packages/laravel-copilot-sdk/rpc/server-skills-plugins.md)
- [SessionRpc overview](https://kawax.biz/en/packages/laravel-copilot-sdk/rpc/session-overview.md)
- [RPC (Remote Procedure Call)](https://kawax.biz/en/packages/laravel-copilot-sdk/rpc.md)
- [Skills](https://kawax.biz/en/packages/laravel-copilot-sdk/skills.md)
- [laravel/agent-skills — Laravel's official AI agent skills](https://kawax.biz/en/blog/agent-skills-introduction.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.