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

# Logs, shell, usage, telemetry, and authentication

> Use SessionRpc in Laravel Copilot SDK for logs, shell, usage, telemetry, authentication, and account selection.

## Logs, shell, usage, telemetry, and authentication

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}
// log: record messages to the session timeline
$session->rpc()->log()->log(new LogRequest(message: 'Processing started'));
$session->rpc()->log()->log(new LogRequest(message: 'Disk usage is high', level: LogLevel::WARNING));
$session->rpc()->log()->log(new LogRequest(message: 'An error occurred', level: LogLevel::ERROR));
$session->rpc()->log()->log(new LogRequest(message: 'Debug info', ephemeral: true));

// shell: run shell commands in the session
$result = $session->rpc()->shell()->exec(new ShellExecRequest(command: 'ls -la'));
// Use $result->processId to get the process ID for killing or tracking output

$session->rpc()->shell()->exec(new ShellExecRequest(
    command: 'npm test',
    cwd: '/path/to/project',
    timeout: 60000, // Milliseconds
));

// Stop a running shell process
$session->rpc()->shell()->kill(new ShellKillRequest(
    processId: $result->processId,
    signal: 'SIGTERM', // SIGTERM (default), SIGKILL, SIGINT
));

// Cancel a user-requested shell command
use Revolution\Copilot\Types\Rpc\ShellExecuteUserRequestedRequest;
use Revolution\Copilot\Types\Rpc\ShellCancelUserRequestedRequest;

$execution = $session->rpc()->shell()->executeUserRequested(new ShellExecuteUserRequestedRequest(
    requestId: 'req-123',
    command: 'pwd',
), timeout: 120.0); // How long to wait for the CLI response (seconds). Defaults to 30 seconds
// $execution->toolCallId / success / output / exitCode / error
// To cancel from another process while it runs, specify the same requestId

$cancelled = $session->rpc()->shell()->cancelUserRequested(
    new ShellCancelUserRequestedRequest(requestId: 'req-123')
);
// $cancelled->cancelled - Whether the cancellation succeeded

// usage (experimental: session usage metrics)
$metrics = $session->rpc()->usage()->getMetrics();
// $metrics->totalPremiumRequestCost - Total cost of premium requests
// $metrics->totalUserRequests - Total number of user requests
// $metrics->codeChanges - Code change metrics (lines added, lines removed, files changed)
// $metrics->modelMetrics - Token usage and request count per model
// $metrics->currentModel - Current model identifier

// telemetry (experimental: session telemetry)
use Revolution\Copilot\Types\Rpc\TelemetrySetFeatureOverridesRequest;

$telemetry = $session->rpc()->telemetry();
$engagement = $telemetry->getEngagementId();
// $engagement->engagementId - The engagement ID when available, otherwise null

$telemetry->setFeatureOverrides(new TelemetrySetFeatureOverridesRequest(
    features: ['feature-key' => 'override-value'],
));
// The overrides are attached to later telemetry events and replace any previous overrides.
// This is separate from SessionConfig::$enableSessionTelemetry (which enables internal telemetry).

// auth: get the session's authentication status
$status = $session->rpc()->gitHubAuth()->getStatus();
// $status->isAuthenticated - Whether authenticated
// $status->authType - Auth type (AuthInfoType enum: gh-cli, token, env, etc.)
// $status->login - GitHub login name
// $status->host - GitHub host
// $status->copilotPlan - Copilot plan (individual, business, etc.)
// $status->statusMessage - Authentication status message
```

## accounts (account selection for interactive login)

Use `accounts()` to enumerate the stored accounts available for login and start an interactive login. Each item's `label` is for display, and `active` indicates whether the identity matches the current session's active account. `accountId` is an opaque ID owned by the provider. Pass it to the login request as is, without parsing or modifying it.

```php theme={null}
use Revolution\Copilot\Enums\AuthLoginMode;
use Revolution\Copilot\Enums\LoginProviderKind;
use Revolution\Copilot\Types\Rpc\AuthLoginBeginRequest;

$accounts = $session->rpc()->accounts();
$identities = $accounts->enumerate(
    'loginAccounts',
    provider: LoginProviderKind::ENTRA,
);

if (isset($identities[0])) {
    $accounts->begin(new AuthLoginBeginRequest(
        kind: LoginProviderKind::ENTRA,
        mode: AuthLoginMode::Default,
        accountId: $identities[0]->accountId,
    ));
}
```

Use `mode: 'default'` to reuse a stored identity with the provider's normal behavior. Use `mode: 'selectAccount'` to explicitly show the provider's account picker. In that case, don't pass `accountId`. For details, see [Authentication](https://kawax.biz/en/packages/laravel-copilot-sdk/auth.md).


## Related topics

- [RPC (Remote Procedure Call)](https://kawax.biz/en/packages/laravel-copilot-sdk/rpc.md)
- [Telemetry](https://kawax.biz/en/packages/laravel-copilot-sdk/telemetry.md)
- [Authentication introduction](https://kawax.biz/en/authentication.md)
- [Socialite (LINE Login) - LINE SDK for Laravel](https://kawax.biz/en/packages/laravel-line-sdk/socialite.md)
- [Custom Authentication Guards](https://kawax.biz/en/advanced/custom-auth-guard.md)


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