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

# 설정·관리 설정

> ServerRpc로 contentExclusion, 관리 설정, 설정 파일, 프로바이더 설정을 다루는 사용 예시입니다.

## 설정·관리 설정

대상: ServerRpc (Client에 연결된 서버 전체 작업)

RPC 전체 개요와 페이지 목록은 [RPC](https://kawax.biz/ko/packages/laravel-copilot-sdk/rpc.md)를 참조하세요.

```php theme={null}
// user settings (사용자 설정)
// 현재 CLI에는 user.settings.reload RPC가 없습니다. get()의 대상은 settings.json입니다.
Copilot::client()->rpc()->userSettings()->set(['settings' => ['theme' => 'dark']]); // 반환값 없음
```

## contentExclusion

세션을 만들기 전에 콘텐츠 제외 정책 JSON을 검증할 수 있습니다.

```php theme={null}
use Revolution\Copilot\Types\Rpc\ContentExclusionValidatePoliciesRequest;

$result = Copilot::client()->rpc()->contentExclusion()->validatePolicies(
    new ContentExclusionValidatePoliciesRequest(policiesJson: $policiesJson),
);
// $result->policies 는 검증되고 정규화된 정책
```

`policiesJson`은 파싱되지 않은 JSON 문자열 그대로 CLI에 전달됩니다. JSON 파싱 또는 스키마 검증에 실패하면 CLI에서 RPC 오류(`JsonRpcException`)가 발생합니다.

이것은 정책 자체를 검증하는 서버 스코프 RPC입니다. 세션 작업 디렉터리 안의 경로를 실제 제외 정책에 비추어 확인하려면 세션 스코프의 `contentExclusion()->checkPaths()`를 사용합니다.

## managedSettings (experimental: 관리 설정)

관리 설정 읽기, 정책 해석, 스키마 조회, 검증, 합성 미리보기, 캐시 폐기를 수행합니다.

```php theme={null}
$managedSettings = $client->rpc()->managedSettings()->read();
$effective = $client->rpc()->managedSettings()->resolve([
    'selectionId' => 'selection-id',
    'workingDirectory' => '/path/to/project',
]);
$schema = $client->rpc()->managedSettings()->schema();
$validation = $client->rpc()->managedSettings()->validate(['content' => ['permissions' => []]]);
$preview = $client->rpc()->managedSettings()->compose(['layers' => [
    ['source' => 'device', 'settings' => ['permissions' => []]],
]]);
$client->rpc()->managedSettings()->clearCache();
```

## settings (experimental: 설정 파일 조작)

설정 파일에서 지정한 키를 삭제하고, 표시용으로 비밀 값을 치환합니다. `removeRawKey()`는 읽기에 실패한 키 등 정규 설정 경로가 아닌 키도 그대로 삭제할 수 있습니다. 파일을 파싱할 수 없으면 덮어쓰지 않고 `status`가 `invalid`가 됩니다. `redactValueForDisplay()`는 `basePath`로 지정한 설정 트리상의 위치를 기준으로 비밀 값을 플레이스홀더로 치환하므로, 사용자에게 표시하거나 로그로 출력할 때 사용할 수 있습니다.

```php theme={null}
$result = $client->rpc()->settings()->removeRawKey([
    'filePath' => '/path/to/settings.json',
    'rawKey' => 'misspelledKey',
]);
// $result->status는 'ok' 또는 'invalid'

$redacted = $client->rpc()->settings()->redactValueForDisplay([
    'value' => ['apiKey' => 'secret-value', 'name' => 'visible'],
    'basePath' => ['providers', 'openai'],
]);
// $redacted->value 중 비밀 값은 플레이스홀더로 대체되어 있습니다
```

## providersConfig (experimental: 프로바이더 설정)

`providersConfig()->addModel()`은 서버에 저장된 프로바이더 설정에 모델을 추가하는 실험적 RPC입니다. 프로바이더가 저장되어 있지 않으면 생성되며, `providerAdded`로 확인할 수 있습니다. 영구적인 작업이지만 실행 중인 세션은 변경하지 않습니다.

```php theme={null}
use Revolution\Copilot\Facades\Copilot;

$result = Copilot::client()->rpc()->providersConfig()->addModel([
    'provider' => ['name' => 'my-provider', 'baseUrl' => 'https://example.com/v1'],
    'model' => ['id' => 'my-model', 'provider' => 'my-provider'],
    // 'credential' => $apiKey,
]);

// $result->providerAdded
```

배열 대신 `ProvidersConfigAddModelRequest`를 전달할 수 있습니다. 선택적인 `credential`은 CLI가 OS 키체인에 저장하며 결과에는 반환되지 않습니다.

같은 `providersConfig()`에서 저장된 설정을 읽기·수정·삭제할 수 있습니다. 이것들도 실험적 API이며 실행 중인 세션은 변경하지 않습니다.

```php theme={null}
$config = Copilot::client()->rpc()->providersConfig();
$saved = $config->read(); // $saved->providers와 $saved->models

$provider = $config->updateProvider([
    'provider' => ['name' => 'my-provider', 'baseUrl' => 'https://example.com/v2'],
    // 'credential' => $apiKey,
]); // $provider->providerName

$model = $config->updateModel([
    'model' => ['id' => 'my-model', 'provider' => 'my-provider', 'maxOutputTokens' => 4096],
]); // $model->providerName과 $model->modelId

$removed = $config->removeModel([
    'providerName' => 'my-provider',
    'modelId' => 'my-model',
]); // $removed->providerRemoved
```

`read()`는 저장 순서대로 설정을 반환하지만 인증 정보, 헤더, 명령 등 비밀 정보는 반환하지 않습니다. 각 프로바이더의 `credentialStatus`는 `present`, `absent`, `unavailable` 중 하나입니다. `updateProvider()`는 공통 설정을 교체하고, 생략된 인증 정보, 커스텀 헤더, 로컬 모델 설정은 유지합니다. `updateModel()`은 지정한 프로바이더 이름과 모델 ID의 모델 정의를 교체합니다. `removeModel()`이 마지막 모델을 삭제한 경우 프로바이더와 관리 대상 인증 정보도 삭제되며 `providerRemoved`가 `true`가 됩니다. 각 수정·삭제에는 대응하는 `ProvidersConfigUpdateProviderRequest`, `ProvidersConfigUpdateModelRequest`, `ProvidersConfigRemoveModelRequest`도 사용할 수 있습니다.


## Related topics

- [RPC(Remote Procedure Call)](https://kawax.biz/ko/packages/laravel-copilot-sdk/rpc.md)
- [설정](https://kawax.biz/ko/configuration.md)
- [관리 설정·debug·기록](https://kawax.biz/ko/packages/laravel-copilot-sdk/rpc/session-settings.md)
- [비밀번호 재설정](https://kawax.biz/ko/passwords.md)
- [패키지 설정 병합과 캐시](https://kawax.biz/ko/advanced/package-config-merging.md)


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