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

# 워크스페이스·Agent·Fleet·Skills

> SessionRpc로 워크스페이스, Agent, Fleet, Skills, autopilotObjective를 다루는 사용 예시입니다.

## 워크스페이스·Agent·Fleet·Skills

대상: SessionRpc (Session에 연결된 세션 단위 작업)

RPC 전체 개요와 페이지 목록은 [RPC](https://kawax.biz/ko/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 (세션의 인스트럭션 소스 가져오기)
$result = $session->rpc()->instructions()->getSources();
// $result->sources - InstructionsSources 의 배열
$session->rpc()->instructions()->reload();

// LSP 설정을 명시적으로 다시 불러오기(experimental)
$session->rpc()->lsp()->initialize([
    'workingDirectory' => base_path(),
    'gitRoot' => base_path(),
    'force' => true,
]);

// LSP 서버 목록·시작·진단·활성 상태 전환·중지
$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 (인스트럭션 파일 검출)
use Revolution\Copilot\Types\Rpc\InstructionsDiscoverRequest;

$result = $session->rpc()->instructions()->discover();
// $result->sources - InstructionSource 의 배열
$result = $session->rpc()->instructions()->discover(new InstructionsDiscoverRequest(
    projectPaths: ['/path/to/project'],
    excludeHostInstructions: true, // 호스트 레벨 인스트럭션 제외
));

// fleet
$session->rpc()->fleet()->start(new FleetStartRequest(prompt: '...'));
// 자세한 내용은 fleet-mode.md 참고

// 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: 스킬 관리)
$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(); // 아직 로드되지 않은 스킬을 로드 (다시 로드하지 않음)
$invoked = $session->rpc()->skills()->getInvoked();
// $invoked->skills - 세션 중 호출된 스킬 기록
```

## autopilotObjective

`autopilotObjective()->getState()`는 세션의 현재 Autopilot objective 상태를 타입이 지정된 값으로 반환합니다. objective가 없으면 `state`는 `null`입니다. Workspace에 저장된 objective의 유무를 확인하는 `workspaces()->autopilotObjectiveExists()`와는 다른 API입니다.

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

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

`setStayInAutopilot()`으로 objective 완료·일시 정지 시 interactive mode로 돌아가라는 요청을 억제할 수 있습니다. 이 설정은 클라이언트 메모리에 유지되며 기본값은 `true`입니다. `value`에 `false`를 전달하면 억제를 해제할 수 있습니다. 다시 연결한 경우에는 다시 설정하세요.

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


## Related topics

- [Skills·Plugins·Agents·Instructions·Extensions](https://kawax.biz/ko/packages/laravel-copilot-sdk/rpc/server-skills-plugins.md)
- [SessionRpc 개요](https://kawax.biz/ko/packages/laravel-copilot-sdk/rpc/session-overview.md)
- [RPC(Remote Procedure Call)](https://kawax.biz/ko/packages/laravel-copilot-sdk/rpc.md)
- [laravel/agent-skills — Laravel 공식 AI 에이전트 스킬 모음](https://kawax.biz/ko/blog/agent-skills-introduction.md)
- [Skills](https://kawax.biz/ko/packages/laravel-copilot-sdk/skills.md)


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