meshagent_service 0.9.2 copy "meshagent_service: ^0.9.2" to clipboard
meshagent_service: ^0.9.2 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 #

  • ServiceHost to bind HTTP, expose liveness at /, and publish a service spec at /.well-known/meshagent-service.json.
  • ServiceWebhookServer/WebhookServer to receive room.started, room.ended, and room.call events (with optional signature validation).
  • SingleRoomAgent and TaskRunner to implement agents that join rooms, install required toolkits/schemas, and respond to agent.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: minimal TaskRunner that responds to agent.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 webhookSecret is set in production before enabling signature validation.
0
likes
0
points
646
downloads

Publisher

verified publishermeshagent.com

Weekly Downloads

A library for building meshagent servers with dart

Homepage

License

unknown (license)

Dependencies

crypto, dart_jsonwebtoken, globe_runtime, http, logging, meshagent, shelf, shelf_router

More

Packages that depend on meshagent_service