acpd_http 1.0.0
acpd_http: ^1.0.0 copied to clipboard
HTTP/SSE and WebSocket client and server transports for acpd, the Dart Agent Client Protocol SDK.
acpd_http #
English · 简体中文
HTTP + scoped SSE and WebSocket clients and servers for acpd.
Client #
AcpHttpClient selects the transport from the URL scheme:
http/https: POST requests plus connection/session-scoped SSE streams.ws/wss: one bidirectional text-frame WebSocket.
import 'package:acpd/acpd.dart';
import 'package:acpd_http/acpd_http.dart';
final client = await AcpHttpClient('https://agent.example').connectClient(
ClientRole(),
);
Use AcpHttpClient.withEndpoint when the supplied URL is already the exact ACP endpoint. Otherwise /acp is appended automatically.
Server #
import 'dart:io';
import 'package:acpd/acpd.dart';
import 'package:acpd_http/acpd_http.dart';
final server = AcpHttpServer(
() => AgentRole().handle('initialize', (params, context) {
return const InitializeResponse(
protocolVersion: ProtocolVersion.v1,
agentInfo: Implementation(name: 'my-agent', version: '1.0.0'),
).toJson();
}),
authorize: (request) => request.headers.value('authorization') != null,
);
await server.listen(InternetAddress.loopbackIPv4, 8080);
print(server.endpoint);
The server supports POST, SSE, WebSocket upgrade, connection deletion, health checks, CORS policy, authorization callbacks, body limits, queue limits, initialization deadlines, batch frames, and isolated concurrent sessions. ACPD never reads a keychain or stores credentials.
This package supports Dart VM and native Flutter platforms. It does not support Web.
See the package example/ for runnable client/server entrypoints.
License #
Apache License 2.0. See LICENSE.