Skip to content

Commit a390aef

Browse files
committed
feat: complete ARCP v1.1 PHP support
1 parent 22a4580 commit a390aef

63 files changed

Lines changed: 2503 additions & 374 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Added
1111

12+
- ARCP v1.1 feature coverage for `session.list_jobs` / `session.jobs`,
13+
versioned `name@version` tool resolution, `job.result_chunk`, and
14+
`cost.budget` enforcement.
15+
- `Arcp\Errors\BudgetExhaustedException` and
16+
`Arcp\Errors\AgentVersionNotAvailableException` mapped to their v1.1
17+
canonical wire codes.
1218
- `Arcp\Errors\ARCPExceptionInterface` — root marker for every exception
1319
the SDK can throw. Implemented by the existing abstract
1420
`Arcp\Errors\ARCPException` (no migration needed for existing catch
@@ -39,5 +45,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3945

4046
### Added
4147

42-
- Initial reference SDK release aligned with ARCP protocol v1.0 (see README status).
43-
48+
- Initial reference SDK release aligned with ARCP protocol v1.1 (see README status).

README.md

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -133,14 +133,21 @@ to keep the example self-contained:
133133

134134
Topic guides under [docs/](docs/):
135135

136-
- [docs/authentication.md](docs/authentication.md) — built-in schemes,
136+
- [docs/getting-started.md](docs/getting-started.md) — install and run
137+
an in-process client/runtime demo.
138+
- [docs/architecture.md](docs/architecture.md) — PHP namespace layout
139+
and runtime/client layering.
140+
- [docs/transports.md](docs/transports.md) — WebSocket, stdio, and
141+
in-memory transports.
142+
- [docs/guides/auth.md](docs/guides/auth.md) — built-in schemes,
137143
AuthRouter wiring, custom schemes, failure semantics.
138-
- [docs/errors.md](docs/errors.md) — full exception hierarchy, retry
139-
defaults, code-driven dispatch.
140-
- [docs/retries.md](docs/retries.md) — when to retry, backoff with
141-
jitter, idempotency keys.
142-
- [docs/subscriptions.md](docs/subscriptions.md) — subscribe API,
143-
filter shape, backfill markers, backpressure.
144+
- [docs/guides/errors.md](docs/guides/errors.md) — full exception
145+
hierarchy, retry defaults, code-driven dispatch.
146+
- [docs/guides/jobs.md](docs/guides/jobs.md) — tool invocation, job
147+
state, cancellation, budgets, and agent versions.
148+
- [docs/guides/job-events.md](docs/guides/job-events.md) — progress,
149+
metrics, streams, subscriptions, and result chunks.
150+
- [docs/recipes.md](docs/recipes.md) — PHP recipes for common flows.
144151

145152
## Supported PHP versions
146153

docs/README.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# ARCP PHP SDK documentation
2+
3+
Reference docs for the ARCP PHP SDK. The top-level
4+
[README](../README.md) is the front door; these pages go deeper into
5+
the runtime, client, transports, and protocol features.
6+
7+
<picture>
8+
<source media="(prefers-color-scheme: dark)" srcset="./diagrams/architecture-dark.svg">
9+
<img alt="ARCP PHP SDK architecture" src="./diagrams/architecture-light.svg">
10+
</picture>
11+
12+
## Start here
13+
14+
- [Getting started](./getting-started.md) - install, create an in-process runtime + client, run the checks.
15+
- [Architecture](./architecture.md) - how the PHP namespaces fit together.
16+
- [Transports](./transports.md) - WebSocket, stdio, and memory transports.
17+
- [CLI](./cli.md) - the `bin/arcp` command shipped by `arcp/arcp`.
18+
19+
## Guides (one per spec section)
20+
21+
| Page | Spec |
22+
| --- | --- |
23+
| [Sessions](./guides/sessions.md) | §6 |
24+
| [Resume](./guides/resume.md) | §6.3 |
25+
| [Authentication](./guides/auth.md) | §6.1 |
26+
| [Jobs](./guides/jobs.md) | §7 |
27+
| [Job events](./guides/job-events.md) | §8 |
28+
| [Leases](./guides/leases.md) | §9 |
29+
| [Delegation](./guides/delegation.md) | §10 |
30+
| [Observability](./guides/observability.md) | §11 |
31+
| [Errors](./guides/errors.md) | §12 |
32+
| [Vendor extensions](./guides/vendor-extensions.md) | §15 |
33+
34+
## PHP Namespaces
35+
36+
The TypeScript SDK has package-specific docs because its code is split
37+
across multiple npm packages. PHP ships as one Composer package,
38+
`arcp/arcp`, so this documentation follows the namespace layout under
39+
`src/`.
40+
41+
| Namespace | Purpose |
42+
| --- | --- |
43+
| `Arcp\Envelope`, `Arcp\Json` | Wire envelope model and serialization |
44+
| `Arcp\Messages` | Typed protocol payloads |
45+
| `Arcp\Errors` | Canonical error codes and exceptions |
46+
| `Arcp\Client` | `ARCPClient` and client-side handlers |
47+
| `Arcp\Runtime` | `ARCPRuntime`, jobs, leases, artifacts, subscriptions |
48+
| `Arcp\Transport` | WebSocket, stdio, and in-memory transports |
49+
| `Arcp\Auth` | Built-in auth schemes and `AuthRouter` |
50+
| `Arcp\Store` | Event log and idempotency persistence |
51+
| `Arcp\Extensions` | Vendor extension classification |
52+
| `Arcp\Cli` | `bin/arcp` commands |
53+
54+
## Reference
55+
56+
- [Recipes](./recipes.md) - copy-paste PHP solutions to common problems.
57+
- [Conformance](./conformance.md) - implemented and deferred protocol surfaces.
58+
- [Troubleshooting](./troubleshooting.md) - error codes and fixes.
59+
60+
## Diagrams
61+
62+
The diagram above is generated from Graphviz. Source files and the
63+
authoring guide live in [`./diagrams/`](./diagrams/).

docs/architecture.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Architecture
2+
3+
The PHP SDK is a single Composer package, `arcp/arcp`, with namespaces
4+
that map to the same layers as the TypeScript SDK packages.
5+
6+
## Layering
7+
8+
| Layer | PHP namespace |
9+
| --- | --- |
10+
| Wire/core | `Arcp\Envelope`, `Arcp\Messages`, `Arcp\Errors`, `Arcp\Ids` |
11+
| Client | `Arcp\Client` |
12+
| Runtime | `Arcp\Runtime`, `Arcp\Internal\Runtime` |
13+
| Transports | `Arcp\Transport` |
14+
| Persistence | `Arcp\Store` |
15+
| Extensions | `Arcp\Extensions` |
16+
17+
The public surface is intentionally small: `ARCPClient`, `ARCPRuntime`,
18+
the message DTOs, transports, typed errors, and IDs. Internal dispatch
19+
collaborators live under `Arcp\Internal`.
20+
21+
## Core
22+
23+
`Arcp\Envelope\Envelope` is the top-level wire object. Payload
24+
polymorphism is handled by `MessageTypeRegistry`; the default registry is
25+
created by `MessageCatalog::create()`.
26+
27+
Serialization is handled by `Arcp\Json\EnvelopeSerializer`, which turns
28+
envelopes into protocol JSON and back without reflection.
29+
30+
## Client
31+
32+
`Arcp\Client\ARCPClient` owns:
33+
34+
- session handshake,
35+
- the background read loop,
36+
- correlated response routing,
37+
- subscription callbacks,
38+
- helper APIs such as `invokeTool()`, `listJobs()`, `subscribe()`,
39+
`cancelJob()`, `putArtifact()`, and `fetchArtifact()`.
40+
41+
## Runtime
42+
43+
`Arcp\Runtime\ARCPRuntime` owns:
44+
45+
- registered tools and versioned tool resolution,
46+
- session negotiation,
47+
- job lifecycle,
48+
- permissions and leases,
49+
- artifacts,
50+
- subscriptions,
51+
- event logging.
52+
53+
Tool handlers implement `Arcp\Runtime\ToolHandler` and receive a
54+
`JobContext` for progress, streams, metrics, permissions, artifacts, and
55+
result chunks.
56+
57+
## CLI
58+
59+
The aggregate package exposes `bin/arcp`, implemented with Symfony
60+
Console under `Arcp\Cli`.
61+
62+
## Middleware
63+
64+
There are no separate PHP middleware packages. PHP hosts should adapt
65+
`Arcp\Transport\Transport` to their framework or process model.
66+
67+
## Wire format
68+
69+
All messages are PHP value objects extending `MessageType`. Unknown core
70+
types are rejected as `UNIMPLEMENTED`; extension handling is delegated to
71+
`ExtensionRegistry`.
72+
73+
## Where to read the code
74+
75+
- `src/Client/ARCPClient.php`
76+
- `src/Runtime/ARCPRuntime.php`
77+
- `src/Envelope/MessageCatalog.php`
78+
- `src/Internal/Runtime/Dispatcher.php`
79+
- `src/Internal/Runtime/ToolInvocationHandler.php`

docs/authentication.md

Lines changed: 0 additions & 97 deletions
This file was deleted.

docs/cli.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# CLI
2+
3+
The PHP SDK ships `bin/arcp`, registered as a Composer binary.
4+
5+
## Install
6+
7+
```sh
8+
composer install
9+
bin/arcp --help
10+
```
11+
12+
## `arcp serve`
13+
14+
Run a WebSocket runtime:
15+
16+
```sh
17+
bin/arcp serve --host 127.0.0.1 --port 8765
18+
```
19+
20+
Useful options:
21+
22+
| Option | Meaning |
23+
| --- | --- |
24+
| `--host` | Bind address. |
25+
| `--port` | TCP port. |
26+
27+
## `arcp send`
28+
29+
Invoke a tool and print the terminal result:
30+
31+
```sh
32+
bin/arcp send ws://127.0.0.1:8765 echo -a '{"message":"hello"}'
33+
```
34+
35+
Arguments are JSON objects.
36+
37+
## `arcp tail`
38+
39+
Subscribe to envelopes and print events:
40+
41+
```sh
42+
bin/arcp tail ws://127.0.0.1:8765
43+
```
44+
45+
## `arcp replay`
46+
47+
Replay an event log file:
48+
49+
```sh
50+
bin/arcp replay events.sqlite -a msg_previous
51+
```
52+
53+
## stdio
54+
55+
Use `StdioTransport` directly from PHP when the runtime is a child
56+
process. The CLI focuses on WebSocket serving, sending, tailing, and log
57+
replay.
58+
59+
## Exit codes
60+
61+
The command exits non-zero on invalid input, failed connection, failed
62+
serialization, or a protocol error returned by the runtime.

0 commit comments

Comments
 (0)