meshagent_service 0.9.0
meshagent_service: ^0.9.0 copied to clipboard
A library for building meshagent servers with dart
Meshagent Dart Service #
Utilities for building Meshagent services and agents in Dart. This package provides a small server harness, webhook handling, and agent/runner helpers so you can expose Dart code as Meshagent-ready services.
What you get #
ServiceHostto bind HTTP, expose liveness at/, and publish a service spec at/.well-known/meshagent-service.json.ServiceWebhookServer/WebhookServerto receiveroom.started,room.ended, androom.callevents (with optional signature validation).SingleRoomAgentandTaskRunnerto implement agents that join rooms, install required toolkits/schemas, and respond toagent.ask.- Thin helpers such as
sendWebhook,noArgumentsSchema, and a lightweight JSON-schema validator to keep agent inputs/outputs in check.
Install #
dart pub add meshagent_service
You also need meshagent in your project (already declared as a dependency
here). The package targets Dart SDK ^3.10.1.
Quick start: expose an agent #
import 'package:meshagent/meshagent.dart';
import 'package:meshagent_service/meshagent_service.dart';
class EchoRunner extends TaskRunner {
EchoRunner() : super(name: 'echo', supportsTools: true);
@override
Future<Map<String, dynamic>> ask({
required AgentCallContext context,
required Map<String, dynamic> arguments,
}) async {
await validateArguments(arguments);
return {'echo': arguments};
}
}
Future<void> main() async {
final host = ServiceHost(host: '0.0.0.0', port: 9090, name: 'echo-service');
host.addPath('/agent', factory: () => EchoRunner());
await host.start();
}
Run it with dart run bin/main.dart (or any entrypoint you choose). Set
MESHAGENT_HOST/MESHAGENT_PORT env vars to override bind host/port.
Examples #
example/server.dart: single-room agent exporting a toolkit and invoking UI helpers on connected participants.example/runner.dart: minimalTaskRunnerthat responds toagent.ask.example/llm_adapter.dart: streams chat-style output over messaging.
Run an example with dart run example/server.dart (adjust the path as needed).
Service spec #
ServiceHost.getServiceSpec builds the Meshagent service description that is
served automatically at /.well-known/meshagent-service.json. Use it to
publish container metadata, ports, and endpoints that Meshagent can consume.
Development notes #
- The JSON-schema helper is minimal; swap in a full validator if you need full draft support.
- JWT handling relies on a shared secret; ensure
webhookSecretis set in production before enabling signature validation.