-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.php
More file actions
43 lines (34 loc) · 1.09 KB
/
main.php
File metadata and controls
43 lines (34 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
declare(strict_types=1);
use Amp\Cancellation;
use Arcp\Client\ARCPClient;
use Arcp\Errors\AgentVersionNotAvailableException;
use Arcp\Runtime\ARCPRuntime;
use Arcp\Runtime\JobContext;
use Arcp\Runtime\ToolHandler;
require __DIR__ . '/../../vendor/autoload.php';
function elidedClient(): ARCPClient
{
throw new RuntimeException('client setup elided');
}
$runtime = new ARCPRuntime();
foreach (['1.0.0', '2.0.0'] as $version) {
$runtime->registerToolVersion('planner', $version, new class ($version) implements ToolHandler {
public function __construct(private readonly string $version)
{
}
public function invoke(array $arguments, JobContext $ctx, ?Cancellation $cancellation = null): mixed
{
return ['planner_version' => $this->version];
}
});
}
$runtime->setDefaultToolVersion('planner', '2.0.0');
$client = elidedClient();
$client->invokeTool('planner');
$client->invokeTool('planner@1.0.0');
try {
$client->invokeTool('planner@9.9.9');
} catch (AgentVersionNotAvailableException $e) {
printf("%s\n", $e->code()->value);
}