Download the PHP package koh/sylius-agent-contracts without Composer
On this page you can find all versions of the php package koh/sylius-agent-contracts. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download koh/sylius-agent-contracts
More information about koh/sylius-agent-contracts
Files in koh/sylius-agent-contracts
Package sylius-agent-contracts
Short Description Shared contracts for the koh Sylius agent-readiness bundles: provider interfaces, DI tags, the channel-aware AgentContext and the single response-header listener.
License MIT
Homepage https://ole-hartwig.eu/open-source/sylius-agent-contracts
Informations about the package sylius-agent-contracts
koh/sylius-agent-contracts
Shared contracts for the koh Sylius agent-readiness bundles.
This package serves no endpoint. It exists so that the granular
one-package-per-protocol split stays composable: /.well-known/api-catalog,
/.well-known/agent-skills/index.json, the A2A agent card, llms.txt, auth.md
and the Link: response headers all need to know what the other, independently
installable bundles offer — and none of them may depend on each other to find out.
Install
Configure
What you get
AgentContext
Resolved once per request, passed through every provider. Sylius has N channels where a CMS has one site, so every discovery document is channel- and locale-dependent.
AgentContext::cacheKey() is the only sanctioned way to build a cache key in
this package family. Skipping it is the classic multi-channel bug: one channel
warms the cache and every other channel is served its documents.
Depend on AgentContextFactoryInterface, not the concrete class — the
implementation reaches into Sylius' channel and locale contexts, which a unit
test of your listener has no business booting.
The factory resolves the channel in three stages — Sylius' channel context,
then a hostname lookup, then the first enabled channel. The fallback matters:
ChannelContextInterface throws when no channel matches the host, which is
exactly what a bot arriving over the bare IP, a preview hostname or a
misconfigured proxy produces. Unhandled, that turns every /.well-known/*
request into a 500 — the most common reason an agent-readiness scan fails on a
multi-channel shop.
Provider interfaces
Implement one (or several) and it is picked up automatically —
registerForAutoconfiguration() is registered container-wide, so this works for
services in your own App\ namespace with no wiring at all.
| Interface | DI tag | Consumed by |
|---|---|---|
AgentEndpointProviderInterface |
koh_agent.endpoint |
llms.txt, api-catalog |
ApiCatalogEntryProviderInterface |
koh_agent.api_catalog_entry |
api-catalog, Link: headers |
AgentSkillProviderInterface |
koh_agent.skill |
A2A card, agent-skills index, MCP |
LlmsTxtSectionProviderInterface |
koh_agent.llms_txt_section |
llms.txt, llms-full.txt |
MarkdownRepresentationProviderInterface |
koh_agent.markdown |
Accept: text/markdown |
AuthMethodDescriptorInterface |
koh_agent.auth_method |
auth.md, agent_auth metadata |
PayableOperationProviderInterface |
koh_agent.payable_operation |
MPP x-payment-info (only where isMppOffer()), x402 |
ResponseHeaderContributorInterface |
koh_agent.response_header |
the shared response listener |
PaymentBypassVoterInterface |
koh_agent.payment_bypass |
x402 |
Example — adding your own section to llms.txt:
AgentJsonResponder
One consistent response shape for every discovery document: public, max-age=3600, stale-while-revalidate=86400, an ETag (returning crawlers send
If-None-Match, and a 304 is far cheaper than a rebuild),
X-Content-Type-Options: nosniff and Access-Control-Allow-Origin: * — in-browser
agents read these cross-origin.
CartHandoff
The one way the protocol bundles (ACP's continue_url, UCP's permalink) hand
an agent's selection over to the buyer's own storefront cart. The bundle parses
its link and resolves the variants; CartHandoff does the rest:
- Each line goes into the cart through
sylius.cart_item_add, the event the storefront's add-to-cart button fires, so every gate the shop hangs on it (age confirmation, quantity rules) runs as if the buyer had clicked. handOver()returns aCartHandoffResult:Added(cart saved),Refused(a gate said no; lines added before are undone, nothing is saved, the exception is in$result->refusal) orNothingAdded(no lines; the cart was not touched).- The session ledger keeps the latest 20 handoffs per key, so opening a link
twice does not add the items twice; a new
$versionhands over again. redirect()answers withCache-Control: no-storeandReferrer-Policy: no-referrer.
Gate refusals. A gate refuses by throwing. Implement
Koh\SyliusAgentContracts\Cart\CartGateRefusalInterface on that exception
so the handoff can tell a refusal from a failure:
For backwards compatibility any \RuntimeException still counts as a refusal
(logged at info). Once your gates implement the interface, set
koh_agent.cart_handoff.runtime_exception_is_refusal: false, and a listener
that breaks shows up as the error it is instead of a "blocked" notice.
The service keeps no request state; it is safe in FrankenPHP worker mode.
AgentResponseHeaderListener
The single kernel.response listener for the whole family. Link,
Content-Signal, Vary and CORS all land on the same response; with one
listener per bundle they overwrite each other depending on registration order.
The merge rules are enforced here:
Linkis appended, never replaced — Sylius and API Platform set their own (rel="preload", HydraapiDocumentation) and clobbering them breaks the app.Varyis merged, never replaced.
Deployment note
.well-known paths fall inside Sylius' shop firewall, which is stateful
(context: shop, remember_me). Without an exemption every bot hit starts a
session and the responses become uncacheable. Add a dedicated entry above
the Sylius firewalls — access_control is not enough, it is evaluated only
after the firewall has already matched:
Decommission
Removing the package is safe once no sibling bundle is installed: drop the
composer require, the entry in config/bundles.php, config/packages/koh_agent.yaml
and the koh_agent_public firewall. It owns no database table, no route and no
cache pool of its own.
Security
Report vulnerabilities privately — see SECURITY.md. Advisories are published as CSAF 2.0 at https://ole-hartwig.eu/.well-known/csaf/.
The family threat model, covering this package, is at https://github.com/ohartwig/sylius-agent-ready/blob/main/docs/threat-model.md.
Licence
MIT — see LICENSE.
All versions of sylius-agent-contracts with dependencies
doctrine/persistence Version ^3.3 || ^4.0
psr/log Version ^1.1 || ^2.0 || ^3.0
sylius/resource Version ^1.14.2
sylius/sylius Version ^2.2.9 || ^2.3.0
symfony/config Version ^7.4 || ^8.0
symfony/console Version ^7.4 || ^8.0
symfony/dependency-injection Version ^7.4 || ^8.0
symfony/event-dispatcher Version ^7.4 || ^8.0
symfony/event-dispatcher-contracts Version ^3.8.1
symfony/http-foundation Version ^7.4 || ^8.0
symfony/http-kernel Version ^7.4 || ^8.0
symfony/routing Version ^7.4 || ^8.0