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
7 changes: 7 additions & 0 deletions src/Types/ResumeSessionConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
readonly class ResumeSessionConfig implements Arrayable
{
public function __construct(
/**
* Client name to identify the application using the SDK.
* Included in the User-Agent header for API requests.
*/
public ?string $clientName = null,
/**
* Model to use for this session.
*/
Expand Down Expand Up @@ -146,6 +151,7 @@ public static function fromArray(array $data): self
}

return new self(
clientName: $data['clientName'] ?? null,
model: $data['model'] ?? null,
reasoningEffort: $data['reasoningEffort'] ?? null,
configDir: $data['configDir'] ?? null,
Expand Down Expand Up @@ -194,6 +200,7 @@ public function toArray(): array
: $this->hooks;

return array_filter([
'clientName' => $this->clientName,
'model' => $this->model,
'reasoningEffort' => $reasoningEffort,
'configDir' => $this->configDir,
Expand Down
7 changes: 7 additions & 0 deletions src/Types/SessionConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ public function __construct(
* If not provided, server will generate one.
*/
public ?string $sessionId = null,
/**
* Client name to identify the application using the SDK.
* Included in the User-Agent header for API requests.
*/
public ?string $clientName = null,
/**
* Model to use for this session.
*/
Expand Down Expand Up @@ -145,6 +150,7 @@ public static function fromArray(array $data): self

return new self(
sessionId: $data['sessionId'] ?? null,
clientName: $data['clientName'] ?? null,
model: $data['model'] ?? null,
reasoningEffort: $data['reasoningEffort'] ?? null,
configDir: $data['configDir'] ?? null,
Expand Down Expand Up @@ -193,6 +199,7 @@ public function toArray(): array

return array_filter([
'sessionId' => $this->sessionId,
'clientName' => $this->clientName,
'model' => $this->model,
'reasoningEffort' => $reasoningEffort,
'configDir' => $this->configDir,
Expand Down
4 changes: 4 additions & 0 deletions tests/Unit/Types/ResumeSessionConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
$preToolUseHook = fn () => null;

$config = ResumeSessionConfig::fromArray([
'clientName' => 'my-app',
'model' => 'claude-opus-4.6',
'reasoningEffort' => ReasoningEffort::XHIGH,
'configDir' => './src',
Expand All @@ -38,6 +39,7 @@
]);

expect($config->tools)->toBe([['name' => 'test_tool']])
->and($config->clientName)->toBe('my-app')
->and($config->model)->toBe('claude-opus-4.6')
->and($config->reasoningEffort)->toBe(ReasoningEffort::XHIGH)
->and($config->systemMessage->content)->toBe('Instructions')
Expand Down Expand Up @@ -96,6 +98,7 @@
$preToolUseHook = fn () => null;

$config = new ResumeSessionConfig(
clientName: 'my-app',
model: 'claude-opus-4.6',
reasoningEffort: ReasoningEffort::XHIGH,
configDir: './src',
Expand All @@ -120,6 +123,7 @@
$array = $config->toArray();

expect($array['tools'])->toBe([['name' => 'tool1']])
->and($array['clientName'])->toBe('my-app')
->and($array['provider'])->toBe(['baseUrl' => 'https://api.test.com'])
->and($array['onPermissionRequest'])->toBe($handler)
->and($array['onUserInputRequest'])->toBe($userInputHandler)
Expand Down
5 changes: 5 additions & 0 deletions tests/Unit/Types/SessionConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

$config = SessionConfig::fromArray([
'sessionId' => 'test-session-id',
'clientName' => 'my-app',
'model' => 'claude-sonnet-4.5',
'configDir' => '/tmp/config',
'tools' => [['name' => 'test_tool']],
Expand All @@ -37,6 +38,7 @@
]);

expect($config->sessionId)->toBe('test-session-id')
->and($config->clientName)->toBe('my-app')
->and($config->model)->toBe('claude-sonnet-4.5')
->and($config->configDir)->toBe('/tmp/config')
->and($config->tools)->toBe([['name' => 'test_tool']])
Expand All @@ -63,6 +65,7 @@
$config = SessionConfig::fromArray([]);

expect($config->sessionId)->toBeNull()
->and($config->clientName)->toBeNull()
->and($config->model)->toBeNull()
->and($config->configDir)->toBeNull()
->and($config->tools)->toBeNull()
Expand Down Expand Up @@ -107,6 +110,7 @@

$config = new SessionConfig(
sessionId: 'session-123',
clientName: 'my-app',
model: 'gpt-4',
configDir: '/config',
tools: [['name' => 'tool1']],
Expand All @@ -129,6 +133,7 @@
$array = $config->toArray();

expect($array['sessionId'])->toBe('session-123')
->and($array['clientName'])->toBe('my-app')
->and($array['model'])->toBe('gpt-4')
->and($array['configDir'])->toBe('/config')
->and($array['tools'])->toBe([['name' => 'tool1']])
Expand Down